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:
authorXhmikosR <xhmikosr@users.sourceforge.net>2011-01-10 03:05:13 +0300
committerXhmikosR <xhmikosr@users.sourceforge.net>2011-01-10 03:05:13 +0300
commit0eb98dcebf3ff5c8fbdc1235474c0d5640f9a04c (patch)
tree65e403462fdb55541e4a98358c824aa8a15b8027
parent93411f0c1eef8de213410b0544b246dd7086be74 (diff)
legacy branch: merge r2785-r2825,r2827 from trunk
git-svn-id: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/branches/legacy@2830 10f7b99b-c216-0410-bff0-8a66a9350fd8
-rw-r--r--Compilation.txt213
-rw-r--r--build.bat2
-rw-r--r--build_2010.bat2
-rw-r--r--distrib/Languages/Belarusian.isl (renamed from distrib/Languages/Belarus.isl)0
-rw-r--r--distrib/custom_messages.iss2
-rw-r--r--distrib/mpc-hc_setup.iss56
-rw-r--r--include/IBitRateInfo.h3
-rw-r--r--include/IBufferInfo.h3
-rw-r--r--include/IChapterInfo.h3
-rw-r--r--include/IFilterVersion.h3
-rw-r--r--include/IKeyFrameInfo.h3
-rw-r--r--include/ITrackInfo.h3
-rw-r--r--include/Version.h6
-rw-r--r--include/dsm/dsm.h5
-rw-r--r--include/moreuuids.h24
-rw-r--r--src/CmdUI/CmdUI.cpp62
-rw-r--r--src/DSUtil/DSMPropertyBag.cpp131
-rw-r--r--src/DSUtil/DSMPropertyBag.h30
-rw-r--r--src/DSUtil/DSUtil.cpp971
-rw-r--r--src/DSUtil/DSUtil.h35
-rw-r--r--src/DSUtil/FontInstaller.cpp41
-rw-r--r--src/DSUtil/GolombBuffer.cpp16
-rw-r--r--src/DSUtil/H264Nalu.cpp26
-rw-r--r--src/DSUtil/H264Nalu.h27
-rw-r--r--src/DSUtil/HdmvClipInfo.cpp247
-rw-r--r--src/DSUtil/HdmvClipInfo.h39
-rw-r--r--src/DSUtil/MediaTypeEx.cpp309
-rw-r--r--src/DSUtil/MediaTypes.cpp49
-rw-r--r--src/DSUtil/MediaTypes.h6
-rw-r--r--src/DSUtil/Mpeg2Def.h12
-rw-r--r--src/DSUtil/NullRenderers.cpp170
-rw-r--r--src/DSUtil/SharedInclude.h16
-rw-r--r--src/DSUtil/text.cpp82
-rw-r--r--src/DSUtil/text.h27
-rw-r--r--src/DeCSS/CSSauth.cpp39
-rw-r--r--src/DeCSS/CSSscramble.cpp35
-rw-r--r--src/DeCSS/DeCSSInputPin.cpp313
-rw-r--r--src/DeCSS/DeCSSInputPin.h24
-rw-r--r--src/DeCSS/VobDec.cpp62
-rw-r--r--src/DeCSS/VobFile.cpp280
-rw-r--r--src/DeCSS/VobFile.h13
-rw-r--r--src/DeCSS/udf.cpp182
-rw-r--r--src/DeCSS/udf.h72
-rw-r--r--src/SubPic/CoordGeom.cpp53
-rw-r--r--src/SubPic/CoordGeom.h2
-rw-r--r--src/SubPic/DX7SubPic.cpp84
-rw-r--r--src/SubPic/DX9SubPic.cpp165
-rw-r--r--src/SubPic/DX9SubPic.h9
-rw-r--r--src/SubPic/ISubPic.h24
-rw-r--r--src/SubPic/ISubRender.h9
-rw-r--r--src/SubPic/MemSubPic.cpp392
-rw-r--r--src/SubPic/SubPicAllocatorPresenterImpl.cpp89
-rw-r--r--src/SubPic/SubPicAllocatorPresenterImpl.h6
-rw-r--r--src/SubPic/SubPicImpl.cpp40
-rw-r--r--src/SubPic/SubPicImpl.h56
-rw-r--r--src/SubPic/SubPicQueueImpl.cpp289
-rw-r--r--src/SubPic/SubPicQueueImpl.h12
-rw-r--r--src/Subtitles/BaseSub.h3
-rw-r--r--src/Subtitles/CCDecoder.cpp252
-rw-r--r--src/Subtitles/CompositionObject.cpp274
-rw-r--r--src/Subtitles/CompositionObject.h3
-rw-r--r--src/Subtitles/DVBSub.cpp244
-rw-r--r--src/Subtitles/DVBSub.h42
-rw-r--r--src/Subtitles/GFN.cpp75
-rw-r--r--src/Subtitles/HdmvSub.cpp179
-rw-r--r--src/Subtitles/HdmvSub.h18
-rw-r--r--src/Subtitles/RTS.cpp2460
-rw-r--r--src/Subtitles/RTS.h20
-rw-r--r--src/Subtitles/Rasterizer.cpp862
-rw-r--r--src/Subtitles/RealTextParser.cpp379
-rw-r--r--src/Subtitles/RealTextParser.h6
-rw-r--r--src/Subtitles/RenderedHdmvSubtitle.cpp44
-rw-r--r--src/Subtitles/RenderedHdmvSubtitle.h2
-rw-r--r--src/Subtitles/SSF.cpp309
-rw-r--r--src/Subtitles/SSF.h60
-rw-r--r--src/Subtitles/STS.cpp1845
-rw-r--r--src/Subtitles/STS.h18
-rw-r--r--src/Subtitles/SeparableFilter.h56
-rw-r--r--src/Subtitles/SubtitleInputPin.cpp200
-rw-r--r--src/Subtitles/TextFile.cpp351
-rw-r--r--src/Subtitles/USFSubtitles.cpp465
-rw-r--r--src/Subtitles/USFSubtitles.h31
-rw-r--r--src/Subtitles/VobSubFile.cpp1144
-rw-r--r--src/Subtitles/VobSubFile.h6
-rw-r--r--src/Subtitles/VobSubFileRipper.cpp655
-rw-r--r--src/Subtitles/VobSubFileRipper.h24
-rw-r--r--src/Subtitles/VobSubImage.cpp896
-rw-r--r--src/Subtitles/VobSubImage.h15
-rw-r--r--src/Subtitles/libssf/Arabic.cpp39
-rw-r--r--src/Subtitles/libssf/Arabic.h6
-rw-r--r--src/Subtitles/libssf/Array.cpp6
-rw-r--r--src/Subtitles/libssf/Array.h93
-rw-r--r--src/Subtitles/libssf/Exception.cpp12
-rw-r--r--src/Subtitles/libssf/Exception.h12
-rw-r--r--src/Subtitles/libssf/File.cpp193
-rw-r--r--src/Subtitles/libssf/File.h6
-rw-r--r--src/Subtitles/libssf/FontWrapper.cpp12
-rw-r--r--src/Subtitles/libssf/FontWrapper.h18
-rw-r--r--src/Subtitles/libssf/Glyph.cpp89
-rw-r--r--src/Subtitles/libssf/Glyph.h10
-rw-r--r--src/Subtitles/libssf/GlyphPath.cpp85
-rw-r--r--src/Subtitles/libssf/GlyphPath.h8
-rw-r--r--src/Subtitles/libssf/Node.cpp293
-rw-r--r--src/Subtitles/libssf/Node.h26
-rw-r--r--src/Subtitles/libssf/NodeFactory.cpp55
-rw-r--r--src/Subtitles/libssf/NodeFactory.h10
-rw-r--r--src/Subtitles/libssf/Rasterizer.cpp327
-rw-r--r--src/Subtitles/libssf/Rasterizer.h33
-rw-r--r--src/Subtitles/libssf/Renderer.cpp366
-rw-r--r--src/Subtitles/libssf/Renderer.h56
-rw-r--r--src/Subtitles/libssf/Split.cpp43
-rw-r--r--src/Subtitles/libssf/Split.h10
-rw-r--r--src/Subtitles/libssf/Stream.cpp285
-rw-r--r--src/Subtitles/libssf/Stream.h10
-rw-r--r--src/Subtitles/libssf/StringMap.cpp6
-rw-r--r--src/Subtitles/libssf/StringMap.h24
-rw-r--r--src/Subtitles/libssf/Subtitle.cpp353
-rw-r--r--src/Subtitles/libssf/Subtitle.h103
-rw-r--r--src/Subtitles/libssf/SubtitleFile.cpp179
-rw-r--r--src/Subtitles/libssf/SubtitleFile.h13
-rw-r--r--src/Subtitles/libssf/stdafx.cpp6
-rw-r--r--src/Subtitles/libssf/stdafx.h8
-rw-r--r--src/apps/MPCTestAPI/MPCTestAPI.cpp7
-rw-r--r--src/apps/MPCTestAPI/MPCTestAPI.h4
-rw-r--r--src/apps/MPCTestAPI/MPCTestAPIDlg.cpp235
-rw-r--r--src/apps/MPCTestAPI/MPCTestAPIDlg.h6
-rw-r--r--src/apps/SubResync/SubResync.cpp7
-rw-r--r--src/apps/SubResync/SubResync.h4
-rw-r--r--src/apps/SubResync/SubResyncDlg.cpp24
-rw-r--r--src/apps/SubResync/SubResyncDlg.h6
-rw-r--r--src/apps/VSConv/VSConv.cpp94
-rw-r--r--src/apps/VSConv/VSConv.h4
-rw-r--r--src/apps/VSConv/VSConvDlg.cpp24
-rw-r--r--src/apps/VSConv/VSConvDlg.h6
-rw-r--r--src/apps/VSRip/VSRip.cpp7
-rw-r--r--src/apps/VSRip/VSRip.h4
-rw-r--r--src/apps/VSRip/VSRipDlg.cpp77
-rw-r--r--src/apps/VSRip/VSRipDlg.h6
-rw-r--r--src/apps/VSRip/VSRipFileDlg.cpp21
-rw-r--r--src/apps/VSRip/VSRipFileDlg.h14
-rw-r--r--src/apps/VSRip/VSRipIndexingDlg.cpp41
-rw-r--r--src/apps/VSRip/VSRipIndexingDlg.h20
-rw-r--r--src/apps/VSRip/VSRipPGCDlg.cpp60
-rw-r--r--src/apps/VSRip/VSRipPGCDlg.h11
-rw-r--r--src/apps/VSRip/VSRipPage.h26
-rw-r--r--src/apps/asf2mkv/asf2mkv.cpp10
-rw-r--r--src/apps/asf2mkv/asf2mkv.h4
-rw-r--r--src/apps/asf2mkv/asf2mkvDlg.cpp193
-rw-r--r--src/apps/asf2mkv/asf2mkvDlg.h6
-rw-r--r--src/apps/mpcinfo/mpcinfo.cpp94
-rw-r--r--src/apps/mpcinfo/mpcinfo.h2
-rw-r--r--src/apps/mplayerc/AppSettings.cpp675
-rw-r--r--src/apps/mplayerc/AppSettings.h66
-rw-r--r--src/apps/mplayerc/AuthDlg.cpp38
-rw-r--r--src/apps/mplayerc/AuthDlg.h2
-rw-r--r--src/apps/mplayerc/Authors.txt9
-rw-r--r--src/apps/mplayerc/BaseGraph.cpp47
-rw-r--r--src/apps/mplayerc/BaseGraph.h9
-rw-r--r--src/apps/mplayerc/CGdiPlusBitmap.h66
-rw-r--r--src/apps/mplayerc/CShockwaveFlash.h232
-rw-r--r--src/apps/mplayerc/Changelog.txt4
-rw-r--r--src/apps/mplayerc/ChildView.cpp229
-rw-r--r--src/apps/mplayerc/ChildView.h3
-rw-r--r--src/apps/mplayerc/ComPropertyPage.cpp7
-rw-r--r--src/apps/mplayerc/ComPropertyPage.h2
-rw-r--r--src/apps/mplayerc/ComPropertySheet.cpp91
-rw-r--r--src/apps/mplayerc/ComPropertySheet.h10
-rw-r--r--src/apps/mplayerc/DVBChannel.cpp76
-rw-r--r--src/apps/mplayerc/DVBChannel.h114
-rw-r--r--src/apps/mplayerc/DeinterlacerFilter.cpp45
-rw-r--r--src/apps/mplayerc/EditListEditor.cpp244
-rw-r--r--src/apps/mplayerc/EditListEditor.h12
-rw-r--r--src/apps/mplayerc/FGFilter.cpp312
-rw-r--r--src/apps/mplayerc/FGFilter.h40
-rw-r--r--src/apps/mplayerc/FGManager.cpp955
-rw-r--r--src/apps/mplayerc/FGManager.h3
-rw-r--r--src/apps/mplayerc/FGManagerBDA.cpp399
-rw-r--r--src/apps/mplayerc/FGManagerBDA.h60
-rw-r--r--src/apps/mplayerc/FakeFilterMapper2.cpp195
-rw-r--r--src/apps/mplayerc/FakeFilterMapper2.h9
-rw-r--r--src/apps/mplayerc/FavoriteAddDlg.cpp14
-rw-r--r--src/apps/mplayerc/FavoriteAddDlg.h2
-rw-r--r--src/apps/mplayerc/FavoriteOrganizeDlg.cpp63
-rw-r--r--src/apps/mplayerc/FavoriteOrganizeDlg.h4
-rw-r--r--src/apps/mplayerc/FileDropTarget.cpp4
-rw-r--r--src/apps/mplayerc/FileDropTarget.h17
-rw-r--r--src/apps/mplayerc/FilterEnum.h19
-rw-r--r--src/apps/mplayerc/FloatEdit.cpp30
-rw-r--r--src/apps/mplayerc/FullscreenWnd.cpp71
-rw-r--r--src/apps/mplayerc/GoToDlg.cpp77
-rw-r--r--src/apps/mplayerc/GoToDlg.h2
-rw-r--r--src/apps/mplayerc/IGraphBuilder2.h12
-rw-r--r--src/apps/mplayerc/ISDb.cpp34
-rw-r--r--src/apps/mplayerc/ISDb.h24
-rw-r--r--src/apps/mplayerc/Ifo.cpp57
-rw-r--r--src/apps/mplayerc/Ifo.h33
-rw-r--r--src/apps/mplayerc/LcdSupport.cpp133
-rw-r--r--src/apps/mplayerc/LcdSupport.h3
-rw-r--r--src/apps/mplayerc/MainFrm.cpp9204
-rw-r--r--src/apps/mplayerc/MainFrm.h52
-rw-r--r--src/apps/mplayerc/MediaFormats.cpp110
-rw-r--r--src/apps/mplayerc/MediaFormats.h18
-rw-r--r--src/apps/mplayerc/MediaTypesDlg.cpp38
-rw-r--r--src/apps/mplayerc/MediaTypesDlg.h4
-rw-r--r--src/apps/mplayerc/MiniDump.cpp43
-rw-r--r--src/apps/mplayerc/MiniDump.h3
-rw-r--r--src/apps/mplayerc/Monitors.cpp11
-rw-r--r--src/apps/mplayerc/Monitors.h14
-rw-r--r--src/apps/mplayerc/MpcApi.h12
-rw-r--r--src/apps/mplayerc/Mpeg2SectionData.cpp292
-rw-r--r--src/apps/mplayerc/Mpeg2SectionData.h6
-rw-r--r--src/apps/mplayerc/MultiMonitor.cpp10
-rw-r--r--src/apps/mplayerc/MultiMonitor.h20
-rw-r--r--src/apps/mplayerc/OpenCapDeviceDlg.cpp248
-rw-r--r--src/apps/mplayerc/OpenCapDeviceDlg.h4
-rw-r--r--src/apps/mplayerc/OpenDirHelper.cpp37
-rw-r--r--src/apps/mplayerc/OpenDirHelper.h3
-rw-r--r--src/apps/mplayerc/OpenDlg.cpp27
-rw-r--r--src/apps/mplayerc/OpenDlg.h4
-rw-r--r--src/apps/mplayerc/OpenFileDlg.cpp54
-rw-r--r--src/apps/mplayerc/PPageAccelTbl.cpp2650
-rw-r--r--src/apps/mplayerc/PPageAccelTbl.h2
-rw-r--r--src/apps/mplayerc/PPageAudioSwitcher.cpp85
-rw-r--r--src/apps/mplayerc/PPageAudioSwitcher.h2
-rw-r--r--src/apps/mplayerc/PPageBase.cpp15
-rw-r--r--src/apps/mplayerc/PPageBase.h2
-rw-r--r--src/apps/mplayerc/PPageCapture.cpp226
-rw-r--r--src/apps/mplayerc/PPageCapture.h2
-rw-r--r--src/apps/mplayerc/PPageCasimir.cpp27
-rw-r--r--src/apps/mplayerc/PPageCasimir.h2
-rw-r--r--src/apps/mplayerc/PPageDVD.cpp18
-rw-r--r--src/apps/mplayerc/PPageDVD.h2
-rw-r--r--src/apps/mplayerc/PPageExternalFilters.cpp218
-rw-r--r--src/apps/mplayerc/PPageExternalFilters.h2
-rw-r--r--src/apps/mplayerc/PPageFileInfoClip.cpp50
-rw-r--r--src/apps/mplayerc/PPageFileInfoClip.h2
-rw-r--r--src/apps/mplayerc/PPageFileInfoDetails.cpp139
-rw-r--r--src/apps/mplayerc/PPageFileInfoDetails.h2
-rw-r--r--src/apps/mplayerc/PPageFileInfoRes.cpp36
-rw-r--r--src/apps/mplayerc/PPageFileInfoRes.h2
-rw-r--r--src/apps/mplayerc/PPageFileInfoSheet.cpp15
-rw-r--r--src/apps/mplayerc/PPageFileMediaInfo.cpp29
-rw-r--r--src/apps/mplayerc/PPageFileMediaInfo.h2
-rw-r--r--src/apps/mplayerc/PPageFormats.cpp425
-rw-r--r--src/apps/mplayerc/PPageFormats.h2
-rw-r--r--src/apps/mplayerc/PPageFullscreen.cpp98
-rw-r--r--src/apps/mplayerc/PPageFullscreen.h4
-rw-r--r--src/apps/mplayerc/PPageInternalFilters.cpp211
-rw-r--r--src/apps/mplayerc/PPageInternalFilters.h2
-rw-r--r--src/apps/mplayerc/PPageLogo.cpp38
-rw-r--r--src/apps/mplayerc/PPageLogo.h2
-rw-r--r--src/apps/mplayerc/PPageOutput.cpp203
-rw-r--r--src/apps/mplayerc/PPageOutput.h4
-rw-r--r--src/apps/mplayerc/PPagePlayback.cpp13
-rw-r--r--src/apps/mplayerc/PPagePlayback.h2
-rw-r--r--src/apps/mplayerc/PPagePlayer.cpp21
-rw-r--r--src/apps/mplayerc/PPagePlayer.h2
-rw-r--r--src/apps/mplayerc/PPageSheet.cpp23
-rw-r--r--src/apps/mplayerc/PPageSheet.h3
-rw-r--r--src/apps/mplayerc/PPageSubMisc.cpp14
-rw-r--r--src/apps/mplayerc/PPageSubMisc.h2
-rw-r--r--src/apps/mplayerc/PPageSubStyle.cpp62
-rw-r--r--src/apps/mplayerc/PPageSubStyle.h15
-rw-r--r--src/apps/mplayerc/PPageSubtitles.cpp67
-rw-r--r--src/apps/mplayerc/PPageSubtitles.h2
-rw-r--r--src/apps/mplayerc/PPageSync.cpp23
-rw-r--r--src/apps/mplayerc/PPageTweaks.cpp29
-rw-r--r--src/apps/mplayerc/PPageTweaks.h2
-rw-r--r--src/apps/mplayerc/PPageWebServer.cpp45
-rw-r--r--src/apps/mplayerc/PPageWebServer.h2
-rw-r--r--src/apps/mplayerc/PlayerCaptureBar.cpp9
-rw-r--r--src/apps/mplayerc/PlayerCaptureDialog.cpp753
-rw-r--r--src/apps/mplayerc/PlayerCaptureDialog.h224
-rw-r--r--src/apps/mplayerc/PlayerInfoBar.cpp46
-rw-r--r--src/apps/mplayerc/PlayerListCtrl.cpp226
-rw-r--r--src/apps/mplayerc/PlayerNavigationBar.cpp15
-rw-r--r--src/apps/mplayerc/PlayerNavigationDialog.cpp50
-rw-r--r--src/apps/mplayerc/PlayerNavigationDialog.h4
-rw-r--r--src/apps/mplayerc/PlayerPlaylistBar.cpp871
-rw-r--r--src/apps/mplayerc/PlayerPlaylistBar.h2
-rw-r--r--src/apps/mplayerc/PlayerSeekBar.cpp55
-rw-r--r--src/apps/mplayerc/PlayerSeekBar.h4
-rw-r--r--src/apps/mplayerc/PlayerShaderEditorBar.cpp15
-rw-r--r--src/apps/mplayerc/PlayerStatusBar.cpp93
-rw-r--r--src/apps/mplayerc/PlayerStatusBar.h2
-rw-r--r--src/apps/mplayerc/PlayerSubresyncBar.cpp1106
-rw-r--r--src/apps/mplayerc/PlayerSubresyncBar.h8
-rw-r--r--src/apps/mplayerc/PlayerToolBar.cpp82
-rw-r--r--src/apps/mplayerc/PlayerToolBar.h4
-rw-r--r--src/apps/mplayerc/Playlist.cpp157
-rw-r--r--src/apps/mplayerc/PnSPresetsDlg.cpp71
-rw-r--r--src/apps/mplayerc/PnSPresetsDlg.h2
-rw-r--r--src/apps/mplayerc/QuicktimeGraph.cpp236
-rw-r--r--src/apps/mplayerc/QuicktimeGraph.h140
-rw-r--r--src/apps/mplayerc/RealMediaGraph.cpp229
-rw-r--r--src/apps/mplayerc/RealMediaGraph.h317
-rw-r--r--src/apps/mplayerc/RealMediaWindowlessSite.cpp196
-rw-r--r--src/apps/mplayerc/RealMediaWindowlessSite.h281
-rw-r--r--src/apps/mplayerc/RegFilterChooserDlg.cpp36
-rw-r--r--src/apps/mplayerc/RegFilterChooserDlg.h4
-rw-r--r--src/apps/mplayerc/SaveDlg.cpp75
-rw-r--r--src/apps/mplayerc/SaveDlg.h2
-rw-r--r--src/apps/mplayerc/SaveTextFileDialog.cpp36
-rw-r--r--src/apps/mplayerc/SaveTextFileDialog.h3
-rw-r--r--src/apps/mplayerc/SaveThumbnailsDialog.cpp7
-rw-r--r--src/apps/mplayerc/SelectMediaType.cpp6
-rw-r--r--src/apps/mplayerc/SelectMediaType.h2
-rw-r--r--src/apps/mplayerc/ShaderAutoCompleteDlg.cpp14
-rw-r--r--src/apps/mplayerc/ShaderAutoCompleteDlg.h2
-rw-r--r--src/apps/mplayerc/ShaderCombineDlg.cpp60
-rw-r--r--src/apps/mplayerc/ShaderCombineDlg.h2
-rw-r--r--src/apps/mplayerc/ShaderEditorDlg.cpp137
-rw-r--r--src/apps/mplayerc/ShaderEditorDlg.h2
-rw-r--r--src/apps/mplayerc/ShockwaveGraph.cpp108
-rw-r--r--src/apps/mplayerc/ShockwaveGraph.h94
-rw-r--r--src/apps/mplayerc/StaticLink.cpp34
-rw-r--r--src/apps/mplayerc/StaticLink.h9
-rw-r--r--src/apps/mplayerc/StatusLabel.cpp3
-rw-r--r--src/apps/mplayerc/StatusLabel.h3
-rw-r--r--src/apps/mplayerc/SubtitleDlDlg.cpp18
-rw-r--r--src/apps/mplayerc/SubtitleDlDlg.h4
-rw-r--r--src/apps/mplayerc/TextPassThruFilter.cpp77
-rw-r--r--src/apps/mplayerc/TunerScanDlg.cpp39
-rw-r--r--src/apps/mplayerc/TunerScanDlg.h2
-rw-r--r--src/apps/mplayerc/VMROSD.cpp191
-rw-r--r--src/apps/mplayerc/VMROSD.h6
-rw-r--r--src/apps/mplayerc/VolumeCtrl.cpp120
-rw-r--r--src/apps/mplayerc/WebClientSocket.cpp331
-rw-r--r--src/apps/mplayerc/WebClientSocket.h3
-rw-r--r--src/apps/mplayerc/WebServer.cpp262
-rw-r--r--src/apps/mplayerc/WebServerSocket.cpp3
-rw-r--r--src/apps/mplayerc/jpeg.cpp118
-rw-r--r--src/apps/mplayerc/jpeg_tables.h30
-rw-r--r--src/apps/mplayerc/libpng.c31
-rw-r--r--src/apps/mplayerc/libpng.h18
-rw-r--r--src/apps/mplayerc/mpciconlib/mpciconlib.cpp307
-rw-r--r--src/apps/mplayerc/mpcresources/mplayerc.br.rcbin350064 -> 350316 bytes
-rw-r--r--src/apps/mplayerc/mpcresources/mplayerc.by.rcbin344228 -> 344462 bytes
-rw-r--r--src/apps/mplayerc/mpcresources/mplayerc.ca.rcbin348216 -> 348562 bytes
-rw-r--r--src/apps/mplayerc/mpcresources/mplayerc.cz.rcbin345134 -> 345374 bytes
-rw-r--r--src/apps/mplayerc/mpcresources/mplayerc.de.rcbin346830 -> 347066 bytes
-rw-r--r--src/apps/mplayerc/mpcresources/mplayerc.es.rcbin350436 -> 350686 bytes
-rw-r--r--src/apps/mplayerc/mpcresources/mplayerc.fr.rcbin350498 -> 350780 bytes
-rw-r--r--src/apps/mplayerc/mpcresources/mplayerc.hu.rcbin350888 -> 351136 bytes
-rw-r--r--src/apps/mplayerc/mpcresources/mplayerc.hy.rcbin344608 -> 344890 bytes
-rw-r--r--src/apps/mplayerc/mpcresources/mplayerc.it.rcbin346946 -> 347194 bytes
-rw-r--r--src/apps/mplayerc/mpcresources/mplayerc.ja.rcbin319816 -> 320098 bytes
-rw-r--r--src/apps/mplayerc/mpcresources/mplayerc.kr.rcbin317344 -> 317058 bytes
-rw-r--r--src/apps/mplayerc/mpcresources/mplayerc.nl.rcbin345002 -> 345238 bytes
-rw-r--r--src/apps/mplayerc/mpcresources/mplayerc.pl.rcbin354642 -> 354914 bytes
-rw-r--r--src/apps/mplayerc/mpcresources/mplayerc.ru.rcbin345972 -> 346666 bytes
-rw-r--r--src/apps/mplayerc/mpcresources/mplayerc.sc.rcbin310112 -> 310366 bytes
-rw-r--r--src/apps/mplayerc/mpcresources/mplayerc.sk.rcbin348436 -> 348686 bytes
-rw-r--r--src/apps/mplayerc/mpcresources/mplayerc.sv.rcbin342502 -> 342752 bytes
-rw-r--r--src/apps/mplayerc/mpcresources/mplayerc.tc.rcbin312102 -> 312344 bytes
-rw-r--r--src/apps/mplayerc/mpcresources/mplayerc.tr.rcbin343260 -> 343510 bytes
-rw-r--r--src/apps/mplayerc/mpcresources/mplayerc.ua.rcbin344468 -> 345176 bytes
-rw-r--r--src/apps/mplayerc/mpcresources/text/mplayerc.br.rc.txtbin141708 -> 141794 bytes
-rw-r--r--src/apps/mplayerc/mpcresources/text/mplayerc.by.rc.txtbin136226 -> 136294 bytes
-rw-r--r--src/apps/mplayerc/mpcresources/text/mplayerc.ca.rc.txtbin139742 -> 139922 bytes
-rw-r--r--src/apps/mplayerc/mpcresources/text/mplayerc.cz.rc.txtbin136880 -> 136954 bytes
-rw-r--r--src/apps/mplayerc/mpcresources/text/mplayerc.de.rc.txtbin138418 -> 138488 bytes
-rw-r--r--src/apps/mplayerc/mpcresources/text/mplayerc.es.rc.txtbin142312 -> 142396 bytes
-rw-r--r--src/apps/mplayerc/mpcresources/text/mplayerc.fr.rc.txtbin143252 -> 143368 bytes
-rw-r--r--src/apps/mplayerc/mpcresources/text/mplayerc.hu.rc.txtbin143160 -> 143242 bytes
-rw-r--r--src/apps/mplayerc/mpcresources/text/mplayerc.hy.rc.txtbin134540 -> 134656 bytes
-rw-r--r--src/apps/mplayerc/mpcresources/text/mplayerc.it.rc.txtbin137910 -> 137992 bytes
-rw-r--r--src/apps/mplayerc/mpcresources/text/mplayerc.ja.rc.txtbin106454 -> 106570 bytes
-rw-r--r--src/apps/mplayerc/mpcresources/text/mplayerc.kr.rc.txtbin103968 -> 103516 bytes
-rw-r--r--src/apps/mplayerc/mpcresources/text/mplayerc.nl.rc.txtbin136274 -> 136344 bytes
-rw-r--r--src/apps/mplayerc/mpcresources/text/mplayerc.pl.rc.txtbin147274 -> 147380 bytes
-rw-r--r--src/apps/mplayerc/mpcresources/text/mplayerc.ru.rc.txtbin138088 -> 138616 bytes
-rw-r--r--src/apps/mplayerc/mpcresources/text/mplayerc.sc.rc.txtbin95730 -> 95818 bytes
-rw-r--r--src/apps/mplayerc/mpcresources/text/mplayerc.sk.rc.txtbin140586 -> 140670 bytes
-rw-r--r--src/apps/mplayerc/mpcresources/text/mplayerc.sv.rc.txtbin133010 -> 133094 bytes
-rw-r--r--src/apps/mplayerc/mpcresources/text/mplayerc.tc.rc.txtbin97060 -> 97136 bytes
-rw-r--r--src/apps/mplayerc/mpcresources/text/mplayerc.tr.rc.txtbin134340 -> 134424 bytes
-rw-r--r--src/apps/mplayerc/mpcresources/text/mplayerc.ua.rc.txtbin136440 -> 136982 bytes
-rw-r--r--src/apps/mplayerc/mplayerc.cpp1077
-rw-r--r--src/apps/mplayerc/mplayerc.h13
-rw-r--r--src/apps/mplayerc/mplayerc.rcbin337944 -> 338198 bytes
-rw-r--r--src/apps/mplayerc/resource.hbin119762 -> 119762 bytes
-rw-r--r--src/filters/FilterApp.cpp3
-rw-r--r--src/filters/InternalPropertyPage.cpp87
-rw-r--r--src/filters/InternalPropertyPage.h19
-rw-r--r--src/filters/PinInfoWnd.cpp90
-rw-r--r--src/filters/PinInfoWnd.h3
-rw-r--r--src/filters/muxer/BaseMuxer/BaseMuxer.cpp259
-rw-r--r--src/filters/muxer/BaseMuxer/BaseMuxerInputPin.cpp102
-rw-r--r--src/filters/muxer/BaseMuxer/BaseMuxerInputPin.h3
-rw-r--r--src/filters/muxer/BaseMuxer/BaseMuxerOutputPin.cpp235
-rw-r--r--src/filters/muxer/BaseMuxer/BaseMuxerRelatedPin.h3
-rw-r--r--src/filters/muxer/BaseMuxer/BitStream.cpp24
-rw-r--r--src/filters/muxer/BaseMuxer/BitStream.h3
-rw-r--r--src/filters/muxer/DSMMuxer/DSMMuxer.cpp123
-rw-r--r--src/filters/muxer/MatroskaMuxer/MatroskaFile.cpp250
-rw-r--r--src/filters/muxer/MatroskaMuxer/MatroskaFile.h730
-rw-r--r--src/filters/muxer/MatroskaMuxer/MatroskaMuxer.cpp834
-rw-r--r--src/filters/muxer/MatroskaMuxer/MatroskaMuxer.h3
-rw-r--r--src/filters/muxer/WavDest/WavDest.cpp94
-rw-r--r--src/filters/parser/AviSplitter/AviFile.cpp548
-rw-r--r--src/filters/parser/AviSplitter/AviFile.h25
-rw-r--r--src/filters/parser/AviSplitter/AviReportWnd.cpp116
-rw-r--r--src/filters/parser/AviSplitter/AviReportWnd.h4
-rw-r--r--src/filters/parser/AviSplitter/AviSplitter.cpp550
-rw-r--r--src/filters/parser/AviSplitter/AviSplitter.h12
-rw-r--r--src/filters/parser/AviSplitter/stdafx.cpp6
-rw-r--r--src/filters/parser/AviSplitter/stdafx.h6
-rw-r--r--src/filters/parser/BaseSplitter/AsyncReader.cpp117
-rw-r--r--src/filters/parser/BaseSplitter/AsyncReader.h56
-rw-r--r--src/filters/parser/BaseSplitter/BaseSplitter.cpp723
-rw-r--r--src/filters/parser/BaseSplitter/BaseSplitter.h154
-rw-r--r--src/filters/parser/BaseSplitter/BaseSplitterFile.cpp88
-rw-r--r--src/filters/parser/BaseSplitter/BaseSplitterFile.h18
-rw-r--r--src/filters/parser/BaseSplitter/BaseSplitterFileEx.cpp924
-rw-r--r--src/filters/parser/BaseSplitter/BaseSplitterFileEx.h44
-rw-r--r--src/filters/parser/BaseSplitter/MultiFiles.cpp85
-rw-r--r--src/filters/parser/BaseSplitter/MultiFiles.h12
-rw-r--r--src/filters/parser/BaseSplitter/stdafx.cpp6
-rw-r--r--src/filters/parser/BaseSplitter/stdafx.h6
-rw-r--r--src/filters/parser/DSMSplitter/DSMSplitter.cpp104
-rw-r--r--src/filters/parser/DSMSplitter/DSMSplitter.h10
-rw-r--r--src/filters/parser/DSMSplitter/DSMSplitterFile.cpp213
-rw-r--r--src/filters/parser/DSMSplitter/DSMSplitterFile.h7
-rw-r--r--src/filters/parser/DSMSplitter/stdafx.cpp6
-rw-r--r--src/filters/parser/DSMSplitter/stdafx.h6
-rw-r--r--src/filters/parser/DiracSplitter/DiracSplitter.cpp844
-rw-r--r--src/filters/parser/DiracSplitter/DiracSplitter.h12
-rw-r--r--src/filters/parser/DiracSplitter/DiracSplitterFile.cpp286
-rw-r--r--src/filters/parser/DiracSplitter/DiracSplitterFile.h10
-rw-r--r--src/filters/parser/DiracSplitter/stdafx.cpp6
-rw-r--r--src/filters/parser/DiracSplitter/stdafx.h32
-rw-r--r--src/filters/parser/FLVSplitter/FLVSplitter.cpp646
-rw-r--r--src/filters/parser/FLVSplitter/FLVSplitter.h24
-rw-r--r--src/filters/parser/FLVSplitter/stdafx.cpp6
-rw-r--r--src/filters/parser/FLVSplitter/stdafx.h6
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Core/Ap4Atom.h10
-rw-r--r--src/filters/parser/MP4Splitter/AP4/Core/Ap4AtomFactory.cpp6
-rw-r--r--src/filters/parser/MP4Splitter/Ap4AsyncReaderStream.cpp33
-rw-r--r--src/filters/parser/MP4Splitter/MP4Splitter.cpp1215
-rw-r--r--src/filters/parser/MP4Splitter/MP4Splitter.h19
-rw-r--r--src/filters/parser/MP4Splitter/MP4SplitterFile.cpp8
-rw-r--r--src/filters/parser/MP4Splitter/stdafx.cpp6
-rw-r--r--src/filters/parser/MP4Splitter/stdafx.h6
-rw-r--r--src/filters/parser/MatroskaSplitter/MatroskaFile.cpp1178
-rw-r--r--src/filters/parser/MatroskaSplitter/MatroskaFile.h797
-rw-r--r--src/filters/parser/MatroskaSplitter/MatroskaSplitter.cpp789
-rw-r--r--src/filters/parser/MatroskaSplitter/MatroskaSplitter.h29
-rw-r--r--src/filters/parser/MatroskaSplitter/stdafx.cpp6
-rw-r--r--src/filters/parser/MatroskaSplitter/stdafx.h6
-rw-r--r--src/filters/parser/MpaSplitter/MpaSplitter.cpp74
-rw-r--r--src/filters/parser/MpaSplitter/MpaSplitter.h12
-rw-r--r--src/filters/parser/MpaSplitter/MpaSplitterFile.cpp199
-rw-r--r--src/filters/parser/MpaSplitter/MpaSplitterFile.h22
-rw-r--r--src/filters/parser/MpaSplitter/stdafx.cpp6
-rw-r--r--src/filters/parser/MpaSplitter/stdafx.h6
-rw-r--r--src/filters/parser/MpegSplitter/MpegSplitter.cpp1082
-rw-r--r--src/filters/parser/MpegSplitter/MpegSplitter.h26
-rw-r--r--src/filters/parser/MpegSplitter/MpegSplitterFile.cpp564
-rw-r--r--src/filters/parser/MpegSplitter/MpegSplitterFile.h75
-rw-r--r--src/filters/parser/MpegSplitter/stdafx.cpp6
-rw-r--r--src/filters/parser/MpegSplitter/stdafx.h6
-rw-r--r--src/filters/parser/NutSplitter/NutFile.cpp125
-rw-r--r--src/filters/parser/NutSplitter/NutFile.h47
-rw-r--r--src/filters/parser/NutSplitter/NutSplitter.cpp193
-rw-r--r--src/filters/parser/NutSplitter/NutSplitter.h16
-rw-r--r--src/filters/parser/NutSplitter/stdafx.cpp6
-rw-r--r--src/filters/parser/NutSplitter/stdafx.h6
-rw-r--r--src/filters/parser/OggSplitter/OggFile.cpp44
-rw-r--r--src/filters/parser/OggSplitter/OggFile.h29
-rw-r--r--src/filters/parser/OggSplitter/OggSplitter.cpp634
-rw-r--r--src/filters/parser/OggSplitter/OggSplitter.h42
-rw-r--r--src/filters/parser/OggSplitter/stdafx.cpp6
-rw-r--r--src/filters/parser/OggSplitter/stdafx.h6
-rw-r--r--src/filters/parser/RealMediaSplitter/RealMediaSplitter.cpp1367
-rw-r--r--src/filters/parser/RealMediaSplitter/RealMediaSplitter.h120
-rw-r--r--src/filters/parser/RoQSplitter/RoQSplitter.cpp530
-rw-r--r--src/filters/parser/RoQSplitter/RoQSplitter.h51
-rw-r--r--src/filters/parser/RoQSplitter/stdafx.cpp6
-rw-r--r--src/filters/parser/RoQSplitter/stdafx.h6
-rw-r--r--src/filters/parser/SSFSplitter/SSFSplitter.cpp110
-rw-r--r--src/filters/parser/SSFSplitter/SSFSplitter.h13
-rw-r--r--src/filters/parser/SSFSplitter/stdafx.cpp6
-rw-r--r--src/filters/parser/SSFSplitter/stdafx.h6
-rw-r--r--src/filters/parser/StreamDriveThru/StreamDriveThru.cpp330
-rw-r--r--src/filters/parser/StreamDriveThru/StreamDriveThru.h34
-rw-r--r--src/filters/parser/StreamDriveThru/stdafx.cpp6
-rw-r--r--src/filters/parser/StreamDriveThru/stdafx.h6
-rw-r--r--src/filters/reader/CDDAReader/CDDAReader.cpp254
-rw-r--r--src/filters/reader/CDDAReader/CDDAReader.h89
-rw-r--r--src/filters/reader/CDDAReader/stdafx.cpp6
-rw-r--r--src/filters/reader/CDDAReader/stdafx.h6
-rw-r--r--src/filters/reader/CDXAReader/CDXAReader.cpp228
-rw-r--r--src/filters/reader/CDXAReader/CDXAReader.h29
-rw-r--r--src/filters/reader/CDXAReader/stdafx.cpp6
-rw-r--r--src/filters/reader/CDXAReader/stdafx.h6
-rw-r--r--src/filters/reader/UDPReader/UDPReader.cpp290
-rw-r--r--src/filters/reader/UDPReader/UDPReader.h36
-rw-r--r--src/filters/reader/UDPReader/stdafx.cpp6
-rw-r--r--src/filters/reader/UDPReader/stdafx.h6
-rw-r--r--src/filters/reader/VTSReader/VTSReader.cpp76
-rw-r--r--src/filters/reader/VTSReader/VTSReader.h26
-rw-r--r--src/filters/reader/VTSReader/stdafx.cpp6
-rw-r--r--src/filters/reader/VTSReader/stdafx.h6
-rw-r--r--src/filters/renderer/MpcAudioRenderer/IMpcAudioRendererFilter.h5
-rw-r--r--src/filters/renderer/MpcAudioRenderer/MpcAudioRenderer.cpp761
-rw-r--r--src/filters/renderer/MpcAudioRenderer/MpcAudioRenderer.h19
-rw-r--r--src/filters/renderer/MpcAudioRenderer/MpcAudioRendererSettingsWnd.cpp67
-rw-r--r--src/filters/renderer/MpcAudioRenderer/MpcAudioRendererSettingsWnd.h9
-rw-r--r--src/filters/renderer/MpcAudioRenderer/resource.h1
-rw-r--r--src/filters/renderer/MpcAudioRenderer/stdafx.h2
-rw-r--r--src/filters/renderer/SyncClock/Interfaces.h4
-rw-r--r--src/filters/renderer/SyncClock/SyncClock.cpp59
-rw-r--r--src/filters/renderer/SyncClock/SyncClock.h31
-rw-r--r--src/filters/renderer/SyncClock/stdafx.cpp8
-rw-r--r--src/filters/renderer/SyncClock/stdafx.h8
-rw-r--r--src/filters/renderer/VideoRenderers/AllocatorCommon.cpp408
-rw-r--r--src/filters/renderer/VideoRenderers/AllocatorCommon.h3
-rw-r--r--src/filters/renderer/VideoRenderers/AllocatorCommon7.cpp13
-rw-r--r--src/filters/renderer/VideoRenderers/D3DFont.cpp238
-rw-r--r--src/filters/renderer/VideoRenderers/DX7AllocatorPresenter.cpp215
-rw-r--r--src/filters/renderer/VideoRenderers/DX7AllocatorPresenter.h48
-rw-r--r--src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.cpp1403
-rw-r--r--src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.h508
-rw-r--r--src/filters/renderer/VideoRenderers/DX9RenderingEngine.cpp734
-rw-r--r--src/filters/renderer/VideoRenderers/DX9RenderingEngine.h261
-rw-r--r--src/filters/renderer/VideoRenderers/DXRAllocatorPresenter.cpp141
-rw-r--r--src/filters/renderer/VideoRenderers/DXRAllocatorPresenter.h132
-rw-r--r--src/filters/renderer/VideoRenderers/Dither.cpp3
-rw-r--r--src/filters/renderer/VideoRenderers/EVRAllocatorPresenter.cpp1849
-rw-r--r--src/filters/renderer/VideoRenderers/EVRAllocatorPresenter.h489
-rw-r--r--src/filters/renderer/VideoRenderers/IPinHook.cpp449
-rw-r--r--src/filters/renderer/VideoRenderers/IPinHook.h18
-rw-r--r--src/filters/renderer/VideoRenderers/IQTVideoSurface.h3
-rw-r--r--src/filters/renderer/VideoRenderers/MacrovisionKicker.cpp18
-rw-r--r--src/filters/renderer/VideoRenderers/PixelShaderCompiler.cpp43
-rw-r--r--src/filters/renderer/VideoRenderers/QT7AllocatorPresenter.cpp25
-rw-r--r--src/filters/renderer/VideoRenderers/QT7AllocatorPresenter.h40
-rw-r--r--src/filters/renderer/VideoRenderers/QT9AllocatorPresenter.cpp25
-rw-r--r--src/filters/renderer/VideoRenderers/QT9AllocatorPresenter.h32
-rw-r--r--src/filters/renderer/VideoRenderers/RM7AllocatorPresenter.cpp77
-rw-r--r--src/filters/renderer/VideoRenderers/RM7AllocatorPresenter.h46
-rw-r--r--src/filters/renderer/VideoRenderers/RM9AllocatorPresenter.cpp79
-rw-r--r--src/filters/renderer/VideoRenderers/RM9AllocatorPresenter.h56
-rw-r--r--src/filters/renderer/VideoRenderers/RenderersSettings.cpp46
-rw-r--r--src/filters/renderer/VideoRenderers/RenderersSettings.h30
-rw-r--r--src/filters/renderer/VideoRenderers/SyncAllocatorPresenter.h3
-rw-r--r--src/filters/renderer/VideoRenderers/SyncRenderer.cpp2252
-rw-r--r--src/filters/renderer/VideoRenderers/SyncRenderer.h1168
-rw-r--r--src/filters/renderer/VideoRenderers/VMR7AllocatorPresenter.cpp118
-rw-r--r--src/filters/renderer/VideoRenderers/VMR7AllocatorPresenter.h88
-rw-r--r--src/filters/renderer/VideoRenderers/VMR9AllocatorPresenter.cpp1112
-rw-r--r--src/filters/renderer/VideoRenderers/VMR9AllocatorPresenter.h88
-rw-r--r--src/filters/renderer/VideoRenderers/madVRAllocatorPresenter.cpp146
-rw-r--r--src/filters/renderer/VideoRenderers/madVRAllocatorPresenter.h134
-rw-r--r--src/filters/source/BaseSource/BaseSource.cpp82
-rw-r--r--src/filters/source/BaseSource/BaseSource.h61
-rw-r--r--src/filters/source/BaseSource/stdafx.cpp6
-rw-r--r--src/filters/source/BaseSource/stdafx.h6
-rw-r--r--src/filters/source/D2VSource/D2VSource.cpp150
-rw-r--r--src/filters/source/D2VSource/D2VSource.h20
-rw-r--r--src/filters/source/DTSAC3Source/DTSAC3Source.cpp239
-rw-r--r--src/filters/source/DTSAC3Source/DTSAC3Source.h18
-rw-r--r--src/filters/source/DTSAC3Source/stdafx.cpp6
-rw-r--r--src/filters/source/DTSAC3Source/stdafx.h6
-rw-r--r--src/filters/source/FLICSource/FLICSource.cpp437
-rw-r--r--src/filters/source/FLICSource/FLICSource.h52
-rw-r--r--src/filters/source/FLICSource/stdafx.cpp6
-rw-r--r--src/filters/source/FLICSource/stdafx.h6
-rw-r--r--src/filters/source/FlacSource/FlacSource.cpp136
-rw-r--r--src/filters/source/FlacSource/FlacSource.h24
-rw-r--r--src/filters/source/FlacSource/stdafx.cpp6
-rw-r--r--src/filters/source/FlacSource/stdafx.h6
-rw-r--r--src/filters/source/ShoutcastSource/ShoutcastSource.cpp365
-rw-r--r--src/filters/source/ShoutcastSource/ShoutcastSource.h122
-rw-r--r--src/filters/source/ShoutcastSource/stdafx.cpp6
-rw-r--r--src/filters/source/ShoutcastSource/stdafx.h6
-rw-r--r--src/filters/source/SubtitleSource/SubtitleSource.cpp388
-rw-r--r--src/filters/source/SubtitleSource/SubtitleSource.h42
-rw-r--r--src/filters/source/SubtitleSource/stdafx.cpp6
-rw-r--r--src/filters/source/SubtitleSource/stdafx.h6
-rw-r--r--src/filters/switcher/AudioSwitcher/Audio.cpp108
-rw-r--r--src/filters/switcher/AudioSwitcher/Audio.h8
-rw-r--r--src/filters/switcher/AudioSwitcher/AudioSwitcher.cpp382
-rw-r--r--src/filters/switcher/AudioSwitcher/AudioSwitcher.h24
-rw-r--r--src/filters/switcher/AudioSwitcher/StreamSwitcher.cpp779
-rw-r--r--src/filters/switcher/AudioSwitcher/StreamSwitcher.h142
-rw-r--r--src/filters/switcher/AudioSwitcher/stdafx.cpp6
-rw-r--r--src/filters/switcher/AudioSwitcher/stdafx.h6
-rw-r--r--src/filters/transform/AVI2AC3Filter/AVI2AC3Filter.cpp320
-rw-r--r--src/filters/transform/AVI2AC3Filter/AVI2AC3Filter.h23
-rw-r--r--src/filters/transform/AVI2AC3Filter/stdafx.cpp6
-rw-r--r--src/filters/transform/AVI2AC3Filter/stdafx.h6
-rw-r--r--src/filters/transform/BaseVideoFilter/BaseVideoFilter.cpp448
-rw-r--r--src/filters/transform/BaseVideoFilter/BaseVideoFilter.h25
-rw-r--r--src/filters/transform/BaseVideoFilter/stdafx.cpp6
-rw-r--r--src/filters/transform/BaseVideoFilter/stdafx.h6
-rw-r--r--src/filters/transform/BufferFilter/BufferFilter.cpp129
-rw-r--r--src/filters/transform/BufferFilter/BufferFilter.h49
-rw-r--r--src/filters/transform/BufferFilter/stdafx.cpp6
-rw-r--r--src/filters/transform/BufferFilter/stdafx.h6
-rw-r--r--src/filters/transform/DeCSSFilter/DeCSSFilter.cpp157
-rw-r--r--src/filters/transform/DeCSSFilter/DeCSSFilter.h18
-rw-r--r--src/filters/transform/DeCSSFilter/stdafx.cpp6
-rw-r--r--src/filters/transform/DeCSSFilter/stdafx.h6
-rw-r--r--src/filters/transform/MPCVideoDec/CpuId.cpp4
-rw-r--r--src/filters/transform/MPCVideoDec/DXVADecoder.cpp545
-rw-r--r--src/filters/transform/MPCVideoDec/DXVADecoder.h15
-rw-r--r--src/filters/transform/MPCVideoDec/DXVADecoderH264.cpp236
-rw-r--r--src/filters/transform/MPCVideoDec/DXVADecoderMpeg2.cpp81
-rw-r--r--src/filters/transform/MPCVideoDec/DXVADecoderVC1.cpp95
-rw-r--r--src/filters/transform/MPCVideoDec/DXVADecoderVC1.h18
-rw-r--r--src/filters/transform/MPCVideoDec/FfmpegContext.c387
-rw-r--r--src/filters/transform/MPCVideoDec/FfmpegContext.h3
-rw-r--r--src/filters/transform/MPCVideoDec/H264QuantizationMatrix.h116
-rw-r--r--src/filters/transform/MPCVideoDec/IMPCVideoDecFilter.h6
-rw-r--r--src/filters/transform/MPCVideoDec/MPCAudioDecFilter.cpp380
-rw-r--r--src/filters/transform/MPCVideoDec/MPCAudioDecFilter.h70
-rw-r--r--src/filters/transform/MPCVideoDec/MPCFfmpegDec.cpp9
-rw-r--r--src/filters/transform/MPCVideoDec/MPCVideoDecFilter.cpp1047
-rw-r--r--src/filters/transform/MPCVideoDec/MPCVideoDecFilter.h65
-rw-r--r--src/filters/transform/MPCVideoDec/MPCVideoDecSettingsWnd.cpp131
-rw-r--r--src/filters/transform/MPCVideoDec/MPCVideoDecSettingsWnd.h3
-rw-r--r--src/filters/transform/MPCVideoDec/TlibavcodecExt.cpp6
-rw-r--r--src/filters/transform/MPCVideoDec/TlibavcodecExt.h3
-rw-r--r--src/filters/transform/MPCVideoDec/VideoDecDXVAAllocator.cpp70
-rw-r--r--src/filters/transform/MPCVideoDec/VideoDecDXVAAllocator.h17
-rw-r--r--src/filters/transform/MPCVideoDec/VideoDecOutputPin.cpp31
-rw-r--r--src/filters/transform/MPCVideoDec/ffImgfmt.cpp1785
-rw-r--r--src/filters/transform/MPCVideoDec/ffmpeg/PODtypes.h76
-rw-r--r--src/filters/transform/MPCVideoDec/ffmpeg/array_allocator.h83
-rw-r--r--src/filters/transform/MPCVideoDec/ffmpeg/char_t.h340
-rw-r--r--src/filters/transform/MPCVideoDec/ffmpeg/config.h15
-rw-r--r--src/filters/transform/MPCVideoDec/ffmpeg/ffImgfmt.h549
-rw-r--r--src/filters/transform/MPCVideoDec/ffmpeg/ffcodecs.h389
-rw-r--r--src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/ac3dec_data.c6
-rw-r--r--src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/ac3dec_data.h1
-rw-r--r--src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/ac3tab.c6
-rw-r--r--src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/ac3tab.h1
-rw-r--r--src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/allcodecs.c3
-rw-r--r--src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/avcodec.h29
-rw-r--r--src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/dsputil.c1
-rw-r--r--src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/h264.c4
-rw-r--r--src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/h264pred.c75
-rw-r--r--src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/h264pred.h22
-rw-r--r--src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/intelh263dec.c18
-rw-r--r--src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/mpeg12.c7
-rw-r--r--src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/mpeg12.h8
-rw-r--r--src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/mpeg4videodec.c1
-rw-r--r--src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/mpegvideo.c8
-rw-r--r--src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/utils.c16
-rw-r--r--src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp8.c173
-rw-r--r--src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/wmv2dec.c2
-rw-r--r--src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/config.asm3
-rw-r--r--src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/dsputil_mmx.c2
-rw-r--r--src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/dsputil_mmx.h38
-rw-r--r--src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/h264_chromamc.asm6
-rw-r--r--src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/h264_intrapred.asm1720
-rw-r--r--src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/h264_intrapred_init.c78
-rw-r--r--src/filters/transform/MPCVideoDec/ffmpeg/libavutil/common.h17
-rw-r--r--src/filters/transform/MPCVideoDec/stdafx.cpp6
-rw-r--r--src/filters/transform/MpaDecFilter/IMpaDecFilter.h6
-rw-r--r--src/filters/transform/MpaDecFilter/MpaDecFilter.cpp1641
-rw-r--r--src/filters/transform/MpaDecFilter/MpaDecFilter.h12
-rw-r--r--src/filters/transform/MpaDecFilter/MpaDecSettingsWnd.cpp68
-rw-r--r--src/filters/transform/MpaDecFilter/MpaDecSettingsWnd.h3
-rw-r--r--src/filters/transform/Mpeg2DecFilter/IMpeg2DecFilter.h10
-rw-r--r--src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.cpp1410
-rw-r--r--src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.h125
-rw-r--r--src/filters/transform/Mpeg2DecFilter/Mpeg2DecSettingsWnd.cpp30
-rw-r--r--src/filters/transform/Mpeg2DecFilter/Mpeg2DecSettingsWnd.h21
-rw-r--r--src/filters/transform/Mpeg2DecFilter/idct_sse2.cpp478
-rw-r--r--src/filters/transform/Mpeg2DecFilter/mc_sse2.cpp767
-rw-r--r--src/filters/transform/Mpeg2DecFilter/stdafx.cpp6
-rw-r--r--src/filters/transform/Mpeg2DecFilter/stdafx.h6
-rw-r--r--src/filters/transform/VSFilter/AvgLines.cpp75
-rw-r--r--src/filters/transform/VSFilter/Copy.cpp111
-rw-r--r--src/filters/transform/VSFilter/DirectVobSub.cpp248
-rw-r--r--src/filters/transform/VSFilter/DirectVobSub.h8
-rw-r--r--src/filters/transform/VSFilter/DirectVobSubFilter.cpp848
-rw-r--r--src/filters/transform/VSFilter/DirectVobSubFilter.h3
-rw-r--r--src/filters/transform/VSFilter/DirectVobSubPropPage.cpp851
-rw-r--r--src/filters/transform/VSFilter/IDirectVobSub.h9
-rw-r--r--src/filters/transform/VSFilter/Scale2x.cpp65
-rw-r--r--src/filters/transform/VSFilter/StyleEditorDialog.cpp60
-rw-r--r--src/filters/transform/VSFilter/StyleEditorDialog.h5
-rw-r--r--src/filters/transform/VSFilter/Systray.cpp335
-rw-r--r--src/filters/transform/VSFilter/VSFilter.cpp40
-rw-r--r--src/filters/transform/VSFilter/csri.h532
-rw-r--r--src/filters/transform/VSFilter/csriapi.cpp43
-rw-r--r--src/filters/transform/VSFilter/plugins.cpp1828
-rw-r--r--src/filters/transform/VSFilter/vfr.cpp39
-rw-r--r--src/filters/transform/VSFilter/vfr.h3
-rw-r--r--src/thirdparty/MediaInfo/MediaInfoLib.vcproj22
-rw-r--r--src/thirdparty/MediaInfo/MediaInfoLib.vcxproj12
-rw-r--r--src/thirdparty/MediaInfo/MediaInfoLib.vcxproj.filters12
-rw-r--r--src/thirdparty/lcms2/src/cmsintrp.c2
697 files changed, 53151 insertions, 51118 deletions
diff --git a/Compilation.txt b/Compilation.txt
index 51bd2045d..24ef63fef 100644
--- a/Compilation.txt
+++ b/Compilation.txt
@@ -3,104 +3,123 @@ For up to date instructions on how to compile mpc-hc visit the wiki page:
http://sourceforge.net/apps/trac/mpc-hc/wiki/How_to_compile_the_MPC
+Part A: Preparing the Visual Studio environment
+
+ Visual Studio 2008
+ 1. Install Visual C++ 2008, part of the Visual Studio package which can be downloaded here: http://msdn.microsoft.com/en-us/evalcenter/bb633753.aspx
+ Note: Express edition won't work (it's missing MFC, which MPC-HC uses).
+ 2. Install Service Pack 1 (SP1) for Visual Studio 2008 and all the Visual Studio updates via Windows Update (>300MB). -> http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=fbee1648-7106-44a7-9649-6d9f6d58056e
+ 3. Install Visual Studio 2008 Service Pack 1 ATL Security Update (Comes with Windows Update) -> http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=294de390-3c94-49fb-a014-9a38580e64cb
+ 4. Install DirectX SDK (June 2010) -> http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=3021d52b-514e-41d3-ad02-438a3ba730ba
+ 5. Install Windows SDK v7.1 and use its configuration tool to make it the default SDK. -> http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=35aeda01-421d-4ba5-b44b-543dc8c33a20
+ Note: This version has a known bug regarding registering itself as the default SDK (on specific systems).
+ More info about it is available here -> http://blogs.msdn.com/windowssdk/archive/2009/08/21/windows-sdk-configuration-tool-may-report-an-error-when-os-display-format-is-not-english.aspx
+
+ Visual Studio 2010
+ Simply install Visual C++ 2010, part of Visual Studio 2010 Professional (Express won't work, other editions work fine), the DirectX SDK and the SDK 7.1 from above.
+
+Part B: Preparing the GCC environment
+ NOTES:
+ * If you installed the MSYS/MinGW package in an other directory you will have to use that path in the following steps.
+ * If you don't use TortoiseSVN then the revision number will be a hard-coded one, like 1.4.0.0.
+
+ 1. Download and extract MSYS_MinGW_GCC_452_x86-x64.7z to C:\MSYS\ -> http://xhmikosr.1f0.de/tools/MSYS_MinGW_GCC_452_x86-x64.7z
+ For the components and their version see: http://xhmikosr.1f0.de/tools/MSYS_MinGW_GCC_452_x86-x64_components.txt
+ 2. Edit the "fstab" file in C:\MSYS\etc\ to specify your MinGW path.
+ Add this to it: C:\MSYS\mingw \mingw
+ Note the tab-space between mingw and \mingw
+ 3. Add the following environment variables (in System Properties->Advanced->Environment Variables):
+
+ Variable Value
+ CC gcc
+ MSYS C:\MSYS
+ MINGW32 C:\MSYS\mingw
+ MINGW64 C:\MSYS\mingw
+
+Modify the "Path" environment variable by adding at the end: ;%MINGW32%\bin;%MSYS%\bin
+
+ * Optional, if you wish to use the cutting edge GCC branch you can instead follow these steps:
+ a. Delete everything in this folder: C:\MSYS\mingw\
+ b. Download and extract the new MinGW GCC version into C:\MSYS\mingw\ from: http://www.xvidvideo.ru/component/docman/cat_view/28-cross-mingwgcc-x86x64.html
+
+
+Part C: Downloading and compiling the MPC-HC source
+
+1. Use a subversion client to checkout MPC-HC's trunk to C:\mpc-hc (or anywhere else you like)
+ Repository URL: https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk
+ The recommended SVN client is TortoiseSVN (grab it from http://tortoisesvn.net/downloads)
+2. When using TortoiseSVN
+ a) Create an empty directory where you want to store the source files. e.g: C:\mpc-hc
+ b) Right-click on that directory and choose "SVN checkout".
+ c) Put https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc/trunk in "URL of Repository" and press OK.
+ d) Wait for the source tree to be downloaded.
+
+3. Open the solution file C:\mpc-hc\mpc-hc.sln
+ Change the solution's configuration to "Release" (in the toolbar).
+4. Right click the MPCVideoDec project, and open up its Properties.
+ There, go to Configuration Properties->Librarian->General. Change the "Additional Library Directories" to:
+ For Win32 platform $(OutDir);$(SolutionDir)lib;$(MINGW32)\lib\gcc\i686-pc-mingw32\4.5.1;$(MINGW32)\i686-pc-mingw32\lib\
+ For x64 platform $(OutDir);$(SolutionDir)lib64;$(MINGW64)\lib\gcc\x86_64-w64-mingw32\4.5.1;$(MINGW64)\x86_64-w64-mingw32\lib\
+
+Note: If you update your GCC, make sure you change the version number in the above paths, e.g. 4.5.2
+Another way to do it, is by copying the needed MinGW libs (libgcc.a and libmingwex.a) into the C:\mpc-hc\lib and C:\mpc-hc\lib64 folders.
+
+
+@ECHO OFF
+REM Save this script to your mpc-hc source dir
+REM Get the GCC version
+FOR /f "tokens=3,4 delims= " %%K IN (
+'gcc --version ^| FINDSTR /C:"gcc (GCC)"'
+) DO (
+SET "gccver=%%K"&Call :SubGCCVer %%gccver:*Z=%%
+)
+
+REM Copy the needed libs
+COPY "%MINGW32%\i686-pc-mingw32\lib\libmingwex.a" "lib\" /V
+rem See Part D for libmingwex.a x64
+COPY "%MINGW32%\lib\gcc\i686-pc-mingw32\%gccver%\libgcc.a" "lib\" /V
+COPY "%MINGW64%\lib\gcc\x86_64-w64-mingw32\%gccver%\libgcc.a" "lib64\" /V
+
+PAUSE
+EXIT /B
+
+:SubGCCVer
+SET gccver=%*
+GOTO :EOF
+
+
+5. Press OK to save the changes and close the Properties window.
+6. Press F7 to build the solution.
+7. You now have mpc-hc.exe under C:\mpc-hc\bin\mpc-hc_x86
+8. Open the solution file C:\mpc-hc\mpciconlib.sln
+9. Press F7 to build the solution.
+10. You now have mpciconlib.dll under C:\mpc-hc\bin\mpc-hc_x86
+11. Open the solution file C:\mpc-hc\mpcresources.sln
+ In Visual Studio go to Build->Batch Build->Press Select All->Press Build
+12. You now have mpcresources.XX.dll under C:\mpc-hc\bin\mpc-hc_x86
+
+Alternatively, you can use the build.bat or build_2010.bat files (run: build.bat help for more info)
+
+
+Part D: Building FFmpeg x64 (libavcodec) with GCC
+
+When building FFmpeg (project libavcodec_gcc) in 32 bit mode, GCC is used and according to the makefile that is automatically invoked from the solution. Doing so for 64 bit, requires some additional steps:
+ 1. Run MSYS and cd to the trunk\src\filters\transform\MPCVideoDec\ffmpeg_x64 folder
+Example: cd /c/mpc-hc/src/filters/transform/MPCVideoDec/ffmpeg_x64/
+(notice that the first part will most probably differ for the exact paths)
+ 2. checkout the MinGW64 files by running: buildmingwlibs.sh --updatemingw
+ 3. run the buildmingwlibs.sh script, only to compile:
+ buildmingwlibs.sh --compilemingw
+ Or
+ buildmingwlibs.sh --updatemingw --compilemingw
-### Requirements for 32-bit and 64-bit builds ###
+After the compilation is done, libgcc.a and libmingwex.a will be placed in C:\mpc-hc\lib64
-* TortoiseSVN
-http://tortoisesvn.net/downloads
+Now libavcodec can be compiled from within the MPC-HC visual studio solution file, and it will be linked correctly with the other components.
-* Visual Studio 2008 SP1
-http://msdn.microsoft.com/en-us/evalcenter/bb655861.aspx
-Visual Studio 2008 Service Pack 1 (Installer)
-http://www.microsoft.com/downloads/details.aspx?FamilyId=FBEE1648-7106-44A7-9649-6D9F6D58056E&displaylang=en
-Visual Studio 2008 Service Pack 1 (ISO)
-http://www.microsoft.com/downloads/details.aspx?familyid=27673C47-B3B5-4C67-BD99-84E525B5CE61&displaylang=en
+Part E: Building the installer
+
+Download Inno Setup Quick Start Pack Unicode v5.4.0 or newer from: http://www.jrsoftware.org/isdl.php#qsp
+Install everything and then go to C:\mpc-hc\distrib, open mpc-hc_setup.iss with Inno Setup and compile it.
+Note: ISTool does not handle Unicode well so don't use it. Use Inno Setup built-in IDE.
-* DirectX SDK (latest version)
-http://msdn.microsoft.com/en-us/directx/aa937788.aspx
-
-* Microsoft Windows SDK for Windows 7
-http://www.microsoft.com/downloads/details.aspx?familyid=C17BA869-9671-4330-A63E-1FD44E0E2505&displaylang=en
-
-* Visual Studio 2008 Service Pack 1 ATL Security Update
-http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=294de390-3c94-49fb-a014-9a38580e64cb
-
-* MinGW32
-http://sourceforge.net/projects/mingw/
-
-* YASM
-http://www.tortall.net/projects/yasm/wiki/Download
-
-
-TIP:
-An easy to use custom installer for MinGW32 can be downloaded here:
-http://sourceforge.net/projects/ffdshow-tryout/files/Tools/
-
-This installer includes a full MinGW32 environment, including MSYS and YASM.
-It also automatically adds the required CC/MING32/MSYS environment variables,
-so there is no need to create them manually.
-
-
-### Additional requirements for 64-bit build ###
-
-* MinGW64
-http://sourceforge.net/projects/mingw-w64/files/
-
-
-### Lib files ###
-
-* x86: Copy the following two files from the MinGW32 lib directory to the lib
-directory of the source code:
-libgcc.a
-libmingwex.a
-
-* x64: use the script buildmingwlibs.sh, run it from MSYS bash.
-1) Start the MSYS bash previously configured for x64
- Ex : c:\MinGW64\MSYS\msys.bat
-2) Change current folder to the "ffmpeg_x64" folder
- Ex : if your working folder is d:\sources\mpc-hc execute
- $ cd /d/sources/mpc-hc/trunk/src/filters/transform/MPCVideoDec/ffmpeg_x64
-3) Get the latest Mingw64 sources and compile the library with the script
- $ ./buildmingwlibs.sh --updatemingw --compilemingw
-
-
-### Windows Environment variables ###
-
-* Add an environment variable called "CC" and give it the value "gcc" (both without quotes).
-* Add an environment variable called "MSYS" and set it with the path of the MSYS root directory
- Ex : MSYS = c:\MSYS\
-* Add an environment variable called "MINGW32" and set it with the path of the MinGW32 root directory
- Ex : MINGW32 = c:\MinGW32\
-* Add an environment variable called "MINGW64" and set it with the path of the MinGW64 root directory
- Ex : MINGW64 = c:\MinGW64\
-
-
-### How to checkout the source code from the SVN repository ###
-
-This assumes you have TortoiseSVN installed.
-1) Create an empty directory where you want to store the source files.
-2) Right-click on that directory and choose "SVN checkout".
-3) Put https://mpc-hc.svn.sourceforge.net/svnroot/mpc-hc mpc-hc in "URL of Repository" and press OK.
-4) Wait for the source tree to be downloaded.
-
-
-### Configuring Visual Studio ###
-
-You need to add the locations of the DirectX SDK directories to the settings in Visual Studio.
-This is usually already done automatically by the DirectX SDK installer.
-
-1) In the Visual Studio menu, go to: Tools -> Options -> Projects and Solutions -> VC++ Directories
-2) Add the location of the Include directory of the latest DirectX SDK.
-3) Repeat the step 2 for the x64 platform.
-4) Add the location of the Lib\x86 directory of the latest DirectX SDK to the Win32 platform.
-5) Add the location of the Lib\x64 directory of the latest DirectX SDK to the x64 platform.
-
-
-### Integration of Windows 7 SDK (Optional) ###
-
-To build MPC-HC with Windows 7 SDK follow these steps:
-
-1) Download and install Windows 7 SDK from Microsoft website (http://www.microsoft.com/downloads/details.aspx?FamilyID=71deb800-c591-4f97-a900-bea146e4fae1&displaylang=en)
-2) Open regional settings, and set it to English (see this link for explanations : http://blogs.msdn.com/windowssdk/archive/2009/08/21/windows-sdk-configuration-tool-may-report-an-error-when-os-display-format-is-not-english.aspx)
-3) Start "Windows SDK Configuration Tool" from start menu, and set "Installed Windows SDK" to "v7.0"
-4) Revert your regional settings to initial value \ No newline at end of file
diff --git a/build.bat b/build.bat
index f1d682f8f..66c742fef 100644
--- a/build.bat
+++ b/build.bat
@@ -159,7 +159,7 @@ GOTO :EOF
:skipx86installer
IF /I "%Platform%" == "Win32" GOTO :END
IF DEFINED InnoSetupPath (
-"%InnoSetupPath%\iscc.exe" /Q /O"bin" "distrib\mpc-hc_setup.iss" /DBuildx64=True
+"%InnoSetupPath%\iscc.exe" /Q /O"bin" "distrib\mpc-hc_setup.iss" /Dx64Build
IF %ERRORLEVEL% NEQ 0 GOTO :EndWithError
) ELSE (
GOTO :END
diff --git a/build_2010.bat b/build_2010.bat
index 9b922777e..55d02327c 100644
--- a/build_2010.bat
+++ b/build_2010.bat
@@ -159,7 +159,7 @@ GOTO :EOF
:skipx86installer
IF /I "%Platform%" == "Win32" GOTO :END
IF DEFINED InnoSetupPath (
-"%InnoSetupPath%\iscc.exe" /Q /O"bin10" "distrib\mpc-hc_setup.iss" /DVS2010build /DBuildx64=True
+"%InnoSetupPath%\iscc.exe" /Q /O"bin10" "distrib\mpc-hc_setup.iss" /DVS2010build /Dx64Build
IF %ERRORLEVEL% NEQ 0 GOTO :EndWithError
) ELSE (
GOTO :END
diff --git a/distrib/Languages/Belarus.isl b/distrib/Languages/Belarusian.isl
index e6e2ac72d..e6e2ac72d 100644
--- a/distrib/Languages/Belarus.isl
+++ b/distrib/Languages/Belarusian.isl
diff --git a/distrib/custom_messages.iss b/distrib/custom_messages.iss
index 2ebb6e340..a9a91da6a 100644
--- a/distrib/custom_messages.iss
+++ b/distrib/custom_messages.iss
@@ -26,7 +26,7 @@ en.ViewChangelog=View Changelog
-#if localize
+#ifdef localize
;Portuguese (Brasil)
br.langid=00000017
diff --git a/distrib/mpc-hc_setup.iss b/distrib/mpc-hc_setup.iss
index 93451bee1..054e22836 100644
--- a/distrib/mpc-hc_setup.iss
+++ b/distrib/mpc-hc_setup.iss
@@ -1,16 +1,16 @@
; Requirements:
-; Inno Setup QuickStart Pack 5.3.11(+) Unicode
+; Inno Setup QuickStart Pack 5.4.0 Unicode
; http://www.jrsoftware.org/isdl.php#qsp
;
; $Id$
-;If you want to compile the 64bit version, change the "is64bit" to "True"
-#define is64bit = False
-#define include_license = True
-#define localize = True
-;If you want to compile the MSVC2010 build installer, change the "VS2010" to "True"
-#define VS2010 = False
+;If you want to compile the 64bit version, define "x64build"
+;#define x64Build
+#define include_license
+#define localize
+;If you want to compile the MSVC2010 build installer, define "VS2010build"
+;#define VS2010build
;Don't forget to update the DirectX SDK number (not updated so often)
#define DIRECTX_SDK_NUMBER = 43
@@ -27,17 +27,7 @@
#define app_url "http://mpc-hc.sourceforge.net/"
-;workaround in order to be able to build the 64bit installer through cmd; we define Buildx64=True for that.
-#ifdef Buildx64
- #define is64bit = True
-#endif
-
-;workaround in order to be able to build the MSVC2010 installer through cmd; we define VS2010build=True for that.
-#ifdef VS2010build
- #define VS2010 = True
-#endif
-
-#if is64bit
+#ifdef x64Build
#define mpchc_exe = 'mpc-hc64.exe'
#define mpchc_ini = 'mpc-hc64.ini'
#else
@@ -45,7 +35,7 @@
#define mpchc_ini = 'mpc-hc.ini'
#endif
-#if VS2010
+#ifdef VS2010build
#define bindir = '..\bin10'
#define sse_required = False
#define sse2_required = True
@@ -57,11 +47,11 @@
[Setup]
-#if is64bit
+#ifdef x64Build
AppId={{2ACBF1FA-F5C3-4B19-A774-B22A31F231B9}
DefaultGroupName={#app_name} x64
UninstallDisplayName={#app_name} v{#app_version} x64
-#if VS2010
+#ifdef VS2010build
OutputBaseFilename=MPC-HomeCinema.{#app_version}.x64.MSVC2010
#else
OutputBaseFilename=MPC-HomeCinema.{#app_version}.x64
@@ -72,7 +62,7 @@ ArchitecturesInstallIn64BitMode=x64
AppId={{2624B969-7135-4EB1-B0F6-2D8C397B45F7}
DefaultGroupName={#app_name}
UninstallDisplayName={#app_name} v{#app_version}
-#if VS2010
+#ifdef VS2010build
OutputBaseFilename=MPC-HomeCinema.{#app_version}.x86.MSVC2010
#else
OutputBaseFilename=MPC-HomeCinema.{#app_version}.x86
@@ -87,9 +77,9 @@ AppPublisherURL={#app_url}
AppSupportURL={#app_url}
AppUpdatesURL={#app_url}
AppContact={#app_url}
-AppCopyright=Copyright © 2002-2010, see AUTHORS file
+AppCopyright=Copyright © 2002-2011, see AUTHORS file
VersionInfoCompany=MPC-HC Team
-VersionInfoCopyright=Copyright © 2002-2010, MPC-HC Team
+VersionInfoCopyright=Copyright © 2002-2011, MPC-HC Team
VersionInfoDescription={#app_name} {#app_version} Setup
VersionInfoTextVersion={#app_version}
VersionInfoVersion={#app_version}
@@ -99,7 +89,7 @@ VersionInfoProductTextVersion={#app_version}
UninstallDisplayIcon={app}\{#mpchc_exe}
DefaultDirName={code:GetInstallFolder}
-#if include_license
+#ifdef include_license
LicenseFile=..\COPYING.txt
#endif
@@ -125,9 +115,9 @@ AppMutex=MediaPlayerClassicW
[Languages]
Name: en; MessagesFile: compiler:Default.isl
-#if localize
+#ifdef localize
Name: br; MessagesFile: compiler:Languages\BrazilianPortuguese.isl
-Name: by; MessagesFile: Languages\Belarus.isl
+Name: by; MessagesFile: Languages\Belarusian.isl
Name: ca; MessagesFile: compiler:Languages\Catalan.isl
Name: cz; MessagesFile: compiler:Languages\Czech.isl
Name: de; MessagesFile: compiler:Languages\German.isl
@@ -165,7 +155,7 @@ Name: custom; Description: {cm:types_CustomInstallation}; Flags: iscustom
[Components]
Name: main; Description: {#app_name} v{#app_version}; Types: default custom; Flags: fixed
Name: mpciconlib; Description: {cm:comp_mpciconlib}; Types: default custom
-#if localize
+#ifdef localize
Name: mpcresources; Description: {cm:comp_mpcresources}; Types: default custom
#endif
@@ -182,16 +172,16 @@ Name: reset_settings; Description: {cm:tsk_ResetSettings}; GroupDescription: {cm
; For CPU detection
Source: WinCPUID.dll; Flags: dontcopy noencryption
-#if is64bit
+#ifdef x64Build
Source: {#bindir}\mpc-hc_x64\mpc-hc64.exe; DestDir: {app}; Components: main; Flags: ignoreversion
Source: {#bindir}\mpc-hc_x64\mpciconlib.dll; DestDir: {app}; Components: mpciconlib; Flags: ignoreversion
-#if localize
+#ifdef localize
Source: {#bindir}\mpc-hc_x64\mpcresources.??.dll; DestDir: {app}; Components: mpcresources; Flags: ignoreversion
#endif
#else
Source: {#bindir}\mpc-hc_x86\mpc-hc.exe; DestDir: {app}; Components: main; Flags: ignoreversion
Source: {#bindir}\mpc-hc_x86\mpciconlib.dll; DestDir: {app}; Components: mpciconlib; Flags: ignoreversion
-#if localize
+#ifdef localize
Source: {#bindir}\mpc-hc_x86\mpcresources.??.dll; DestDir: {app}; Components: mpcresources; Flags: ignoreversion
#endif
#endif
@@ -207,7 +197,7 @@ Filename: {app}\Changelog.txt; Description: {cm:ViewChangelog}; WorkingDir: {app
[Icons]
-#if is64bit
+#ifdef x64Build
Name: {group}\{#app_name} x64; Filename: {app}\{#mpchc_exe}; Comment: {#app_name} v{#app_version} x64; WorkingDir: {app}; IconFilename: {app}\{#mpchc_exe}; IconIndex: 0
Name: {commondesktop}\{#app_name} x64; Filename: {app}\{#mpchc_exe}; Tasks: desktopicon\common; Comment: {#app_name} v{#app_version} x64; WorkingDir: {app}; IconFilename: {app}\{#mpchc_exe}; IconIndex: 0
Name: {userdesktop}\{#app_name} x64; Filename: {app}\{#mpchc_exe}; Tasks: desktopicon\user; Comment: {#app_name} v{#app_version} x64; WorkingDir: {app}; IconFilename: {app}\{#mpchc_exe}; IconIndex: 0
@@ -382,7 +372,7 @@ begin
#endif
- #if is64bit
+ #ifdef x64Build
is_update := RegKeyExists(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{2ACBF1FA-F5C3-4B19-A774-B22A31F231B9}_is1');
#else
is_update := RegKeyExists(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{2624B969-7135-4EB1-B0F6-2D8C397B45F7}_is1');
diff --git a/include/IBitRateInfo.h b/include/IBitRateInfo.h
index dca71b2a8..7f735e909 100644
--- a/include/IBitRateInfo.h
+++ b/include/IBitRateInfo.h
@@ -25,8 +25,7 @@
interface __declspec(uuid("EB2CD9E6-BA08-4acb-AA0F-3D8D0DD521CA"))
IBitRateInfo :
-public IUnknown
-{
+public IUnknown {
STDMETHOD_(DWORD, GetCurrentBitRate) () = 0;
STDMETHOD_(DWORD, GetAverageBitRate) () = 0;
};
diff --git a/include/IBufferInfo.h b/include/IBufferInfo.h
index b1fa4bca0..b00b1a8a4 100644
--- a/include/IBufferInfo.h
+++ b/include/IBufferInfo.h
@@ -25,8 +25,7 @@
interface __declspec(uuid("46070104-1318-4A82-8822-E99AB7CD15C1"))
IBufferInfo :
-public IUnknown
-{
+public IUnknown {
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 2978873c9..9acb8a766 100644
--- a/include/IChapterInfo.h
+++ b/include/IChapterInfo.h
@@ -52,8 +52,7 @@ struct ChapterElement2 : ChapterElement {
interface __declspec(uuid("8E128709-3DC8-4e49-B632-380FCF496B6D"))
IChapterInfo :
-public IUnknown
-{
+public IUnknown {
#define CHAPTER_BAD_ID 0xFFFFFFFF
#define CHAPTER_ROOT_ID 0
diff --git a/include/IFilterVersion.h b/include/IFilterVersion.h
index d0d6a6d67..ee60c4e83 100644
--- a/include/IFilterVersion.h
+++ b/include/IFilterVersion.h
@@ -25,7 +25,6 @@
interface __declspec(uuid("A0DD28E1-61C0-4539-A7E6-14544AFF092E"))
IFilterVersion :
-public IUnknown
-{
+public IUnknown {
STDMETHOD_(DWORD, GetFilterVersion) () = 0;
};
diff --git a/include/IKeyFrameInfo.h b/include/IKeyFrameInfo.h
index 5046f6caa..92767c8c4 100644
--- a/include/IKeyFrameInfo.h
+++ b/include/IKeyFrameInfo.h
@@ -25,8 +25,7 @@
interface __declspec(uuid("01A5BBD3-FE71-487C-A2EC-F585918A8724"))
IKeyFrameInfo :
-public IUnknown
-{
+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;
};
diff --git a/include/ITrackInfo.h b/include/ITrackInfo.h
index 9ec4489e8..6db7b6203 100644
--- a/include/ITrackInfo.h
+++ b/include/ITrackInfo.h
@@ -45,8 +45,7 @@ struct TrackExtendedInfoAudio {
interface __declspec(uuid("03E98D51-DDE7-43aa-B70C-42EF84A3A23D"))
ITrackInfo :
-public IUnknown
-{
+public IUnknown {
STDMETHOD_(UINT, GetTrackCount) () = 0;
// \param aTrackIdx the track index (from 0 to GetTrackCount()-1)
diff --git a/include/Version.h b/include/Version.h
index 7f40828e9..f09cb11a6 100644
--- a/include/Version.h
+++ b/include/Version.h
@@ -5,13 +5,13 @@
// It's used in mpcresources and mpciconlib projects.
// * ISPP_IS_BUGGY is defined in the installer script only and it's just a workaround
// for ISPP being buggy and throwing an error.
-// * DIRECTX_SDK_DATE is the date of the DirectX SDK used for compilation and it's used
+// * DIRECTX_SDK_DATE is the date of the DirectX SDK used for compilation and it's used
// in the error message in mpc-hc and in the installer when the DX runtime is out of date.
#pragma once
#ifndef NO_VERSION_REV_NEEDED
- #include "Version_rev.h"
+#include "Version_rev.h"
#endif
#define DO_MAKE_STR(x) #x
@@ -22,7 +22,7 @@
#define MPC_VERSION_PATCH 0
#define MPC_COMP_NAME "MPC-HC Team"
-#define MPC_COPYRIGHT "Copyright (C) 2002-2010 see AUTHORS file"
+#define MPC_COPYRIGHT "Copyright (C) 2002-2011 see AUTHORS file"
#ifndef ISPP_IS_BUGGY
#define MPC_VERSION MPC_VERSION_MAJOR,MPC_VERSION_MINOR,MPC_VERSION_REV,MPC_VERSION_PATCH
diff --git a/include/dsm/dsm.h b/include/dsm/dsm.h
index fc13a94d6..c63a24428 100644
--- a/include/dsm/dsm.h
+++ b/include/dsm/dsm.h
@@ -26,8 +26,7 @@
#define DSMSW 0x44534D53ui64
#define DSMSW_SIZE 4
-enum dsmp_t
-{
+enum dsmp_t {
DSMP_FILEINFO = 0,
DSMP_STREAMINFO = 1,
DSMP_MEDIATYPE = 2,
@@ -35,4 +34,4 @@ enum dsmp_t
DSMP_SAMPLE = 4,
DSMP_SYNCPOINTS = 5,
DSMP_RESOURCE = 6
-}; \ No newline at end of file
+};
diff --git a/include/moreuuids.h b/include/moreuuids.h
index 8daa21c15..44abe4f96 100644
--- a/include/moreuuids.h
+++ b/include/moreuuids.h
@@ -134,8 +134,7 @@ DEFINE_GUID(MEDIASUBTYPE_DiracVideo,
DEFINE_GUID(FORMAT_DiracVideoInfo,
0xd2667a7e, 0x4055, 0x4244, 0xa6, 0x5f, 0xdd, 0xdd, 0xf2, 0xb7, 0x4b, 0xd7);
-struct DIRACINFOHEADER
-{
+struct DIRACINFOHEADER {
VIDEOINFOHEADER2 hdr;
DWORD cbSequenceHeader;
DWORD dwSequenceHeader[1];
@@ -325,8 +324,7 @@ DEFINE_GUID(MEDIASUBTYPE_PCM_FL32_le,
DEFINE_GUID(MEDIASUBTYPE_PCM_FL64_le,
0x666C3634, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
-enum
-{
+enum {
WAVE_FORMAT_14_4 = 0x2002,
WAVE_FORMAT_28_8 = 0x2003,
WAVE_FORMAT_ATRC = 0x0270, //WAVE_FORMAT_SONY_SCX,
@@ -351,12 +349,10 @@ DEFINE_GUID(MEDIASUBTYPE_PS2_PCM,
DEFINE_GUID(MEDIASUBTYPE_PS2_ADPCM,
WAVE_FORMAT_PS2_ADPCM, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
-struct WAVEFORMATEXPS2 : public WAVEFORMATEX
-{
+struct WAVEFORMATEXPS2 : public WAVEFORMATEX {
DWORD dwInterleave;
- struct WAVEFORMATEXPS2()
- {
+ struct WAVEFORMATEXPS2() {
memset(this, 0, sizeof(*this));
cbSize = sizeof(WAVEFORMATEXPS2) - sizeof(WAVEFORMATEX);
}
@@ -423,8 +419,7 @@ DEFINE_GUID(MEDIASUBTYPE_Vorbis,
DEFINE_GUID(FORMAT_VorbisFormat,
0x6bddfa7e, 0x9f22, 0x46a9, 0xab, 0x5e, 0x88, 0x4e, 0xff, 0x29, 0x4d, 0x9f);
-typedef struct tagVORBISFORMAT
-{
+typedef struct tagVORBISFORMAT {
WORD nChannels;
DWORD nSamplesPerSec;
DWORD nMinBitsPerSec;
@@ -441,8 +436,7 @@ DEFINE_GUID(MEDIASUBTYPE_Vorbis2,
DEFINE_GUID(FORMAT_VorbisFormat2,
0xb36e107f, 0xa938, 0x4387, 0x93, 0xc7, 0x55, 0xe9, 0x66, 0x75, 0x74, 0x73);
-typedef struct tagVORBISFORMAT2
-{
+typedef struct tagVORBISFORMAT2 {
DWORD Channels;
DWORD SamplesPerSec;
DWORD BitsPerSample;
@@ -1035,12 +1029,10 @@ DEFINE_GUID(MEDIASUBTYPE_NELLYMOSER,
DEFINE_GUID(MEDIASUBTYPE_HDMV_LPCM_AUDIO,
0x949f97fd, 0x56f6, 0x4527, 0xb4, 0xae, 0xdd, 0xeb, 0x37, 0x5a, 0xb8, 0xf);
-struct WAVEFORMATEX_HDMV_LPCM : public WAVEFORMATEX
-{
+struct WAVEFORMATEX_HDMV_LPCM : public WAVEFORMATEX {
BYTE channel_conf;
- struct WAVEFORMATEX_HDMV_LPCM()
- {
+ struct WAVEFORMATEX_HDMV_LPCM() {
memset(this, 0, sizeof(*this));
cbSize = sizeof(WAVEFORMATEX_HDMV_LPCM) - sizeof(WAVEFORMATEX);
}
diff --git a/src/CmdUI/CmdUI.cpp b/src/CmdUI/CmdUI.cpp
index 5944f5798..262aca22c 100644
--- a/src/CmdUI/CmdUI.cpp
+++ b/src/CmdUI/CmdUI.cpp
@@ -52,8 +52,7 @@ LRESULT CCmdUIDialog::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
LRESULT ret = __super::DefWindowProc(message, wParam, lParam);
- if(message == WM_INITDIALOG)
- {
+ if(message == WM_INITDIALOG) {
SendMessage(WM_KICKIDLE);
}
@@ -90,20 +89,16 @@ void CCmdUIDialog::OnInitMenuPopup(CMenu *pPopupMenu, UINT /*nIndex*/, BOOL /*bS
// 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)
+ if (AfxGetThreadState()->m_hTrackingMenu == pPopupMenu->m_hMenu) {
state.m_pParentMenu = pPopupMenu; // Parent == child for tracking popup.
- else if ((hParentMenu = ::GetMenu(m_hWnd)) != NULL)
- {
+ } 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)
- {
+ (hParentMenu = ::GetMenu(pParent->m_hWnd)) != NULL) {
int nIndexMax = ::GetMenuItemCount(hParentMenu);
- for (int nIndex = 0; nIndex < nIndexMax; nIndex++)
- {
- if (::GetSubMenu(hParentMenu, nIndex) == pPopupMenu->m_hMenu)
- {
+ 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;
@@ -114,28 +109,24 @@ void CCmdUIDialog::OnInitMenuPopup(CMenu *pPopupMenu, UINT /*nIndex*/, BOOL /*bS
state.m_nIndexMax = pPopupMenu->GetMenuItemCount();
for (state.m_nIndex = 0; state.m_nIndex < state.m_nIndexMax;
- state.m_nIndex++)
- {
+ state.m_nIndex++) {
state.m_nID = pPopupMenu->GetMenuItemID(state.m_nIndex);
- if (state.m_nID == 0)
- continue; // Menu separator or invalid cmd - ignore it.
+ 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)
- {
+ 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)
- {
+ 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
- {
+ } else {
// Normal menu item.
// Auto enable/disable if frame window has m_bAutoMenuEnable
// set and command is _not_ a system command.
@@ -145,12 +136,10 @@ void CCmdUIDialog::OnInitMenuPopup(CMenu *pPopupMenu, UINT /*nIndex*/, BOOL /*bS
// Adjust for menu deletions and additions.
UINT nCount = pPopupMenu->GetMenuItemCount();
- if (nCount < state.m_nIndexMax)
- {
+ 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)
- {
+ pPopupMenu->GetMenuItemID(state.m_nIndex) == state.m_nID) {
state.m_nIndex++;
}
}
@@ -172,23 +161,20 @@ 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:
- ;
+ 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)
- {
+ if(message == WM_INITDIALOG) {
SendMessage(WM_KICKIDLE);
}
diff --git a/src/DSUtil/DSMPropertyBag.cpp b/src/DSUtil/DSMPropertyBag.cpp
index b63de0042..09869c19c 100644
--- a/src/DSUtil/DSMPropertyBag.cpp
+++ b/src/DSUtil/DSMPropertyBag.cpp
@@ -19,9 +19,13 @@ IDSMPropertyBagImpl::~IDSMPropertyBagImpl()
STDMETHODIMP IDSMPropertyBagImpl::Read(LPCOLESTR pszPropName, VARIANT* pVar, IErrorLog* pErrorLog)
{
CheckPointer(pVar, E_POINTER);
- if(pVar->vt != VT_EMPTY) return E_INVALIDARG;
+ if(pVar->vt != VT_EMPTY) {
+ return E_INVALIDARG;
+ }
CStringW value = Lookup(pszPropName);
- if(value.IsEmpty()) return E_FAIL;
+ if(value.IsEmpty()) {
+ return E_FAIL;
+ }
CComVariant(value).Detach(pVar);
return S_OK;
}
@@ -38,8 +42,9 @@ STDMETHODIMP IDSMPropertyBagImpl::Read(ULONG cProperties, PROPBAG2* pPropBag, IE
CheckPointer(pPropBag, E_POINTER);
CheckPointer(pvarValue, E_POINTER);
CheckPointer(phrError, E_POINTER);
- for(ULONG i = 0; i < cProperties; phrError[i] = S_OK, i++)
+ for(ULONG i = 0; i < cProperties; phrError[i] = S_OK, i++) {
CComVariant(Lookup(pPropBag[i].pstrName)).Detach(pvarValue);
+ }
return S_OK;
}
@@ -47,8 +52,9 @@ STDMETHODIMP IDSMPropertyBagImpl::Write(ULONG cProperties, PROPBAG2* pPropBag, V
{
CheckPointer(pPropBag, E_POINTER);
CheckPointer(pvarValue, E_POINTER);
- for(ULONG i = 0; i < cProperties; i++)
+ for(ULONG i = 0; i < cProperties; i++) {
SetProperty(pPropBag[i].pstrName, &pvarValue[i]);
+ }
return S_OK;
}
@@ -63,11 +69,12 @@ STDMETHODIMP IDSMPropertyBagImpl::GetPropertyInfo(ULONG iProperty, ULONG cProper
{
CheckPointer(pPropBag, E_POINTER);
CheckPointer(pcProperties, E_POINTER);
- for(ULONG i = 0; i < cProperties; i++, iProperty++, (*pcProperties)++)
- {
+ 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;
+ if(!pPropBag[i].pstrName) {
+ return E_FAIL;
+ }
wcscpy_s(pPropBag[i].pstrName, key.GetLength()+1, key);
}
return S_OK;
@@ -84,8 +91,11 @@ 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);
+ if(!Lookup(key).IsEmpty()) {
+ SetAt(key, value);
+ } else {
+ Add(key, value);
+ }
return S_OK;
}
@@ -93,7 +103,9 @@ 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;
+ if((var->vt & (VT_BSTR | VT_BYREF)) != VT_BSTR) {
+ return E_INVALIDARG;
+ }
return SetProperty(key, var->bstrVal);
}
@@ -102,7 +114,9 @@ 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;
+ if(i < 0) {
+ return E_FAIL;
+ }
*value = GetValueAt(i).AllocSysString();
return S_OK;
}
@@ -189,38 +203,58 @@ STDMETHODIMP_(DWORD) IDSMResourceBagImpl::ResGetCount()
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((INT_PTR)iIndex >= m_resources.GetCount())
+ if((INT_PTR)iIndex >= m_resources.GetCount()) {
return E_INVALIDARG;
+ }
CDSMResource& r = m_resources[iIndex];
- if(ppName) *ppName = r.name.AllocSysString();
- if(ppDesc) *ppDesc = r.desc.AllocSysString();
- if(ppMime) *ppMime = r.mime.AllocSysString();
+ if(ppName) {
+ *ppName = r.name.AllocSysString();
+ }
+ if(ppDesc) {
+ *ppDesc = r.desc.AllocSysString();
+ }
+ if(ppMime) {
+ *ppMime = r.mime.AllocSysString();
+ }
if(ppData) {
*pDataLen = r.data.GetCount();
memcpy(*ppData = (BYTE*)CoTaskMemAlloc(*pDataLen), r.data.GetData(), *pDataLen);
}
- if(pTag) *pTag = r.tag;
+ if(pTag) {
+ *pTag = r.tag;
+ }
return S_OK;
}
STDMETHODIMP IDSMResourceBagImpl::ResSet(DWORD iIndex, LPCWSTR pName, LPCWSTR pDesc, LPCWSTR pMime, BYTE* pData, DWORD len, DWORD_PTR tag)
{
- if((INT_PTR)iIndex >= m_resources.GetCount())
+ if((INT_PTR)iIndex >= m_resources.GetCount()) {
return E_INVALIDARG;
+ }
CDSMResource& r = m_resources[iIndex];
- if(pName) r.name = pName;
- if(pDesc) r.desc = pDesc;
- if(pMime) r.mime = pMime;
+ 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());
+ if(pData) {
+ memcpy(r.data.GetData(), pData, r.data.GetCount());
+ }
}
r.tag = tag;
@@ -234,8 +268,9 @@ STDMETHODIMP IDSMResourceBagImpl::ResAppend(LPCWSTR pName, LPCWSTR pDesc, LPCWST
STDMETHODIMP IDSMResourceBagImpl::ResRemoveAt(DWORD iIndex)
{
- if((INT_PTR)iIndex >= m_resources.GetCount())
+ if((INT_PTR)iIndex >= m_resources.GetCount()) {
return E_INVALIDARG;
+ }
m_resources.RemoveAt(iIndex);
@@ -244,14 +279,12 @@ STDMETHODIMP IDSMResourceBagImpl::ResRemoveAt(DWORD iIndex)
STDMETHODIMP IDSMResourceBagImpl::ResRemoveAll(DWORD_PTR tag)
{
- if(tag)
- {
+ if(tag) {
for(ptrdiff_t i = m_resources.GetCount() - 1; i >= 0; i--)
- if(m_resources[i].tag == tag)
+ if(m_resources[i].tag == tag) {
m_resources.RemoveAt(i);
- }
- else
- {
+ }
+ } else {
m_resources.RemoveAll();
}
@@ -292,8 +325,11 @@ 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);
- 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;
}
@@ -316,26 +352,34 @@ STDMETHODIMP_(DWORD) IDSMChapterBagImpl::ChapGetCount()
STDMETHODIMP IDSMChapterBagImpl::ChapGet(DWORD iIndex, REFERENCE_TIME* prt, BSTR* ppName)
{
- if((INT_PTR)iIndex >= m_chapters.GetCount())
+ if((INT_PTR)iIndex >= m_chapters.GetCount()) {
return E_INVALIDARG;
+ }
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;
}
STDMETHODIMP IDSMChapterBagImpl::ChapSet(DWORD iIndex, REFERENCE_TIME rt, LPCWSTR pName)
{
- if((INT_PTR)iIndex >= m_chapters.GetCount())
+ if((INT_PTR)iIndex >= m_chapters.GetCount()) {
return E_INVALIDARG;
+ }
CDSMChapter& c = m_chapters[iIndex];
c.rt = rt;
- if(pName) c.name = pName;
+ if(pName) {
+ c.name = pName;
+ }
m_fSorted = false;
@@ -349,8 +393,9 @@ STDMETHODIMP IDSMChapterBagImpl::ChapAppend(REFERENCE_TIME rt, LPCWSTR pName)
STDMETHODIMP IDSMChapterBagImpl::ChapRemoveAt(DWORD iIndex)
{
- if((INT_PTR)iIndex >= m_chapters.GetCount())
+ if((INT_PTR)iIndex >= m_chapters.GetCount()) {
return E_INVALIDARG;
+ }
m_chapters.RemoveAt(iIndex);
@@ -373,17 +418,23 @@ STDMETHODIMP_(long) IDSMChapterBagImpl::ChapLookup(REFERENCE_TIME* prt, BSTR* pp
ChapSort();
int i = range_bsearch(m_chapters, *prt);
- if(i < 0) return -1;
+ if(i < 0) {
+ return -1;
+ }
*prt = m_chapters[i].rt;
- if(ppName) *ppName = m_chapters[i].name.AllocSysString();
+ if(ppName) {
+ *ppName = m_chapters[i].name.AllocSysString();
+ }
return i;
}
STDMETHODIMP IDSMChapterBagImpl::ChapSort()
{
- if(m_fSorted) return S_FALSE;
+ if(m_fSorted) {
+ return S_FALSE;
+ }
qsort(m_chapters.GetData(), m_chapters.GetCount(), sizeof(CDSMChapter), CDSMChapter::Compare);
m_fSorted = true;
return S_OK;
diff --git a/src/DSUtil/DSMPropertyBag.h b/src/DSUtil/DSMPropertyBag.h
index 73862d3ae..638e38b31 100644
--- a/src/DSUtil/DSMPropertyBag.h
+++ b/src/DSUtil/DSMPropertyBag.h
@@ -6,8 +6,7 @@
interface __declspec(uuid("232FD5D2-4954-41E7-BF9B-09E1257B1A95"))
IDSMPropertyBag :
-public IPropertyBag2
-{
+public IPropertyBag2 {
STDMETHOD(SetProperty) (LPCWSTR key, LPCWSTR value) = 0;
STDMETHOD(SetProperty) (LPCWSTR key, VARIANT* var) = 0;
STDMETHOD(GetProperty) (LPCWSTR key, BSTR* value) = 0;
@@ -54,8 +53,7 @@ public:
interface __declspec(uuid("EBAFBCBE-BDE0-489A-9789-05D5692E3A93"))
IDSMResourceBag :
-public IUnknown
-{
+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;
@@ -107,8 +105,7 @@ public:
interface __declspec(uuid("2D0EBE73-BA82-4E90-859B-C7C48ED3650F"))
IDSMChapterBag :
-public IUnknown
-{
+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;
@@ -172,23 +169,26 @@ template<class T>
int range_bsearch(const CAtlArray<T>& array, REFERENCE_TIME rt)
{
int i = 0, j = array.GetCount() - 1, ret = -1;
- if(j >= 0 && rt >= array[j].rt) return j;
- while(i < j)
- {
+ if(j >= 0 && rt >= array[j].rt) {
+ return j;
+ }
+ while(i < j) {
int mid = (i + j) >> 1;
REFERENCE_TIME midrt = array[mid].rt;
if(rt == midrt) {
ret = mid;
break;
- }
- else if(rt < midrt) {
+ } else if(rt < midrt) {
ret = -1;
- if(j == mid) mid--;
+ if(j == mid) {
+ mid--;
+ }
j = mid;
- }
- else if(rt > midrt) {
+ } else if(rt > midrt) {
ret = mid;
- if(i == mid) mid++;
+ if(i == mid) {
+ mid++;
+ }
i = mid;
}
}
diff --git a/src/DSUtil/DSUtil.cpp b/src/DSUtil/DSUtil.cpp
index 3242f3b16..fd2045352 100644
--- a/src/DSUtil/DSUtil.cpp
+++ b/src/DSUtil/DSUtil.cpp
@@ -40,22 +40,22 @@ void DumpStreamConfig(TCHAR* fn, IAMStreamConfig* pAMVSCCap)
{
CString s;
CStdioFile f;
- if(!f.Open(fn, CFile::modeCreate|CFile::modeWrite|CFile::typeText))
+ if(!f.Open(fn, CFile::modeCreate|CFile::modeWrite|CFile::typeText)) {
return;
+ }
int cnt = 0, size = 0;
- if(FAILED(pAMVSCCap->GetNumberOfCapabilities(&cnt, &size)))
+ if(FAILED(pAMVSCCap->GetNumberOfCapabilities(&cnt, &size))) {
return;
+ }
s.Empty();
s.Format(_T("cnt %d, size %d\n"), cnt, size);
f.WriteString(s);
- if(size == sizeof(VIDEO_STREAM_CONFIG_CAPS))
- {
+ if(size == sizeof(VIDEO_STREAM_CONFIG_CAPS)) {
CString ss;
- for(ptrdiff_t i = 0; i < cnt; i++)
- {
+ for(ptrdiff_t i = 0; i < cnt; i++) {
AM_MEDIA_TYPE* pmt = NULL;
VIDEO_STREAM_CONFIG_CAPS caps;
@@ -66,8 +66,9 @@ void DumpStreamConfig(TCHAR* fn, IAMStreamConfig* pAMVSCCap)
s += ss;
f.WriteString(s);
- if(FAILED(pAMVSCCap->GetStreamCaps(i, &pmt, (BYTE*)&caps)))
+ if(FAILED(pAMVSCCap->GetStreamCaps(i, &pmt, (BYTE*)&caps))) {
continue;
+ }
{
s.Empty();
@@ -101,8 +102,7 @@ void DumpStreamConfig(TCHAR* fn, IAMStreamConfig* pAMVSCCap)
}
BITMAPINFOHEADER* pbh;
- if(pmt->formattype == FORMAT_VideoInfo)
- {
+ if(pmt->formattype == FORMAT_VideoInfo) {
VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->pbFormat;
pbh = &vih->bmiHeader;
@@ -116,9 +116,7 @@ void DumpStreamConfig(TCHAR* fn, IAMStreamConfig* pAMVSCCap)
ss.Format(_T("\trcTarget %d,%d,%d,%d\n"), vih->rcTarget);
s += ss;
f.WriteString(s);
- }
- else if(pmt->formattype == FORMAT_VideoInfo2)
- {
+ } else if(pmt->formattype == FORMAT_VideoInfo2) {
VIDEOINFOHEADER2* vih = (VIDEOINFOHEADER2*)pmt->pbFormat;
pbh = &vih->bmiHeader;
@@ -136,9 +134,7 @@ void DumpStreamConfig(TCHAR* fn, IAMStreamConfig* pAMVSCCap)
ss.Format(_T("\tdwPictAspectRatio %d:%d\n"), vih->dwPictAspectRatioX, vih->dwPictAspectRatioY);
s += ss;
f.WriteString(s);
- }
- else
- {
+ } else {
DeleteMediaType(pmt);
continue;
}
@@ -162,9 +158,7 @@ void DumpStreamConfig(TCHAR* fn, IAMStreamConfig* pAMVSCCap)
DeleteMediaType(pmt);
}
- }
- else if(size == sizeof(AUDIO_STREAM_CONFIG_CAPS))
- {
+ } else if(size == sizeof(AUDIO_STREAM_CONFIG_CAPS)) {
// TODO
}
}
@@ -174,21 +168,22 @@ int CountPins(IBaseFilter* pBF, int& nIn, int& nOut, int& nInC, int& nOutC)
nIn = nOut = 0;
nInC = nOutC = 0;
- BeginEnumPins(pBF, pEP, pPin)
- {
+ BeginEnumPins(pBF, pEP, pPin) {
PIN_DIRECTION dir;
- if(SUCCEEDED(pPin->QueryDirection(&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) {
+ if(pPinConnectedTo) {
+ nInC++;
+ }
+ } else if(dir == PINDIR_OUTPUT) {
nOut++;
- if(pPinConnectedTo) nOutC++;
+ if(pPinConnectedTo) {
+ nOutC++;
+ }
}
}
}
@@ -214,8 +209,9 @@ bool IsMultiplexer(IBaseFilter* pBF, bool fCountConnectedOnly)
bool IsStreamStart(IBaseFilter* pBF)
{
CComQIPtr<IAMFilterMiscFlags> pAMMF(pBF);
- if(pAMMF && pAMMF->GetMiscFlags()&AM_FILTER_MISC_FLAGS_IS_SOURCE)
+ if(pAMMF && pAMMF->GetMiscFlags()&AM_FILTER_MISC_FLAGS_IS_SOURCE) {
return(true);
+ }
int nIn, nOut, nInC, nOutC;
CountPins(pBF, nIn, nOut, nInC, nOutC);
@@ -237,18 +233,17 @@ bool IsVideoRenderer(IBaseFilter* pBF)
int nIn, nOut, nInC, nOutC;
CountPins(pBF, nIn, nOut, nInC, nOutC);
- if(nInC > 0 && nOut == 0)
- {
- BeginEnumPins(pBF, pEP, pPin)
- {
+ if(nInC > 0 && nOut == 0) {
+ BeginEnumPins(pBF, pEP, pPin) {
AM_MEDIA_TYPE mt;
- if(S_OK != pPin->ConnectionMediaType(&mt))
+ if(S_OK != pPin->ConnectionMediaType(&mt)) {
continue;
+ }
FreeMediaType(mt);
return(!!(mt.majortype == MEDIATYPE_Video));
- /*&& (mt.formattype == FORMAT_VideoInfo || mt.formattype == FORMAT_VideoInfo2));*/
+ /*&& (mt.formattype == FORMAT_VideoInfo || mt.formattype == FORMAT_VideoInfo2));*/
}
EndEnumPins
}
@@ -270,18 +265,17 @@ bool IsAudioWaveRenderer(IBaseFilter* pBF)
int nIn, nOut, nInC, nOutC;
CountPins(pBF, nIn, nOut, nInC, nOutC);
- if(nInC > 0 && nOut == 0 && CComQIPtr<IBasicAudio>(pBF))
- {
- BeginEnumPins(pBF, pEP, pPin)
- {
+ if(nInC > 0 && nOut == 0 && CComQIPtr<IBasicAudio>(pBF)) {
+ BeginEnumPins(pBF, pEP, pPin) {
AM_MEDIA_TYPE mt;
- if(S_OK != pPin->ConnectionMediaType(&mt))
+ if(S_OK != pPin->ConnectionMediaType(&mt)) {
continue;
+ }
FreeMediaType(mt);
return(!!(mt.majortype == MEDIATYPE_Audio)
- /*&& mt.formattype == FORMAT_WaveFormatEx*/);
+ /*&& mt.formattype == FORMAT_WaveFormatEx*/);
}
EndEnumPins
}
@@ -291,7 +285,7 @@ bool IsAudioWaveRenderer(IBaseFilter* pBF)
pBF->GetClassID(&clsid);
return(clsid == CLSID_DSoundRender || clsid == CLSID_AudioRender || clsid == CLSID_ReClock
- || clsid == __uuidof(CNullAudioRenderer) || clsid == __uuidof(CNullUAudioRenderer));
+ || clsid == __uuidof(CNullAudioRenderer) || clsid == __uuidof(CNullUAudioRenderer));
}
IBaseFilter* GetUpStreamFilter(IBaseFilter* pBF, IPin* pInputPin)
@@ -301,15 +295,15 @@ IBaseFilter* GetUpStreamFilter(IBaseFilter* pBF, IPin* 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)))
- {
+ && SUCCEEDED(pPin->ConnectedTo(&pPinConnectedTo))) {
IPin* pRet = pPinConnectedTo.Detach();
pRet->Release();
return(pRet);
@@ -322,14 +316,14 @@ IPin* GetUpStreamPin(IBaseFilter* pBF, IPin* pInputPin)
IPin* GetFirstPin(IBaseFilter* pBF, PIN_DIRECTION dir)
{
- if(!pBF) return(NULL);
+ if(!pBF) {
+ return(NULL);
+ }
- BeginEnumPins(pBF, pEP, pPin)
- {
+ BeginEnumPins(pBF, pEP, pPin) {
PIN_DIRECTION dir2;
pPin->QueryDirection(&dir2);
- if(dir == dir2)
- {
+ if(dir == dir2) {
IPin* pRet = pPin.Detach();
pRet->Release();
return(pRet);
@@ -342,15 +336,15 @@ IPin* GetFirstPin(IBaseFilter* pBF, PIN_DIRECTION dir)
IPin* GetFirstDisconnectedPin(IBaseFilter* pBF, PIN_DIRECTION dir)
{
- if(!pBF) return(NULL);
+ if(!pBF) {
+ return(NULL);
+ }
- BeginEnumPins(pBF, pEP, pPin)
- {
+ BeginEnumPins(pBF, pEP, pPin) {
PIN_DIRECTION dir2;
pPin->QueryDirection(&dir2);
CComPtr<IPin> pPinTo;
- if(dir == dir2 && (S_OK != pPin->ConnectedTo(&pPinTo)))
- {
+ if(dir == dir2 && (S_OK != pPin->ConnectedTo(&pPinTo))) {
IPin* pRet = pPin.Detach();
pRet->Release();
return(pRet);
@@ -370,11 +364,11 @@ IBaseFilter* FindFilter(LPCWSTR clsid, IFilterGraph* pFG)
IBaseFilter* FindFilter(const CLSID& clsid, IFilterGraph* pFG)
{
- BeginEnumFilters(pFG, pEF, pBF)
- {
+ BeginEnumFilters(pFG, pEF, pBF) {
CLSID clsid2;
- if(SUCCEEDED(pBF->GetClassID(&clsid2)) && clsid == clsid2)
+ if(SUCCEEDED(pBF->GetClassID(&clsid2)) && clsid == clsid2) {
return(pBF);
+ }
}
EndEnumFilters
@@ -384,18 +378,14 @@ IBaseFilter* FindFilter(const CLSID& clsid, IFilterGraph* pFG)
IPin* FindPin(IBaseFilter* pBF, PIN_DIRECTION direction, const AM_MEDIA_TYPE* pRequestedMT)
{
PIN_DIRECTION pindir;
- BeginEnumPins(pBF, pEP, pPin)
- {
+ 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)
- {
+ pPin->ConnectedTo(&pFellow) == VFW_E_NOT_CONNECTED) {
+ BeginEnumMediaTypes(pPin, pEM, pmt) {
+ if (pmt->majortype == pRequestedMT->majortype && pmt->subtype == pRequestedMT->subtype) {
return (pPin);
}
}
@@ -411,8 +401,9 @@ CStringW GetFilterName(IBaseFilter* pBF)
{
CStringW name;
CFilterInfo fi;
- if(pBF && SUCCEEDED(pBF->QueryFilterInfo(&fi)))
+ if(pBF && SUCCEEDED(pBF->QueryFilterInfo(&fi))) {
name = fi.achName;
+ }
return(name);
}
@@ -420,30 +411,39 @@ CStringW GetPinName(IPin* pPin)
{
CStringW name;
CPinInfo pi;
- if(pPin && SUCCEEDED(pPin->QueryPinInfo(&pi)))
+ if(pPin && SUCCEEDED(pPin->QueryPinInfo(&pi))) {
name = pi.achName;
- if(!name.Find(_T("Apple"))) name.Delete(0,1);
+ }
+ if(!name.Find(_T("Apple"))) {
+ name.Delete(0,1);
+ }
return(name);
}
IFilterGraph* GetGraphFromFilter(IBaseFilter* pBF)
{
- if(!pBF) return NULL;
+ if(!pBF) {
+ return NULL;
+ }
IFilterGraph* pGraph = NULL;
CFilterInfo fi;
- if(pBF && SUCCEEDED(pBF->QueryFilterInfo(&fi)))
+ if(pBF && SUCCEEDED(pBF->QueryFilterInfo(&fi))) {
pGraph = fi.pGraph;
+ }
return(pGraph);
}
IBaseFilter* GetFilterFromPin(IPin* pPin)
{
- if(!pPin) return NULL;
+ if(!pPin) {
+ return NULL;
+ }
IBaseFilter* pBF = NULL;
CPinInfo pi;
- if(pPin && SUCCEEDED(pPin->QueryPinInfo(&pi)))
+ if(pPin && SUCCEEDED(pPin->QueryPinInfo(&pi))) {
pBF = pi.pFilter;
+ }
return(pBF);
}
@@ -453,172 +453,174 @@ IPin* AppendFilter(IPin* pPin, CString DisplayName, IGraphBuilder* pGB)
CInterfaceList<IBaseFilter> pFilters;
- do
- {
- if(!pPin || DisplayName.IsEmpty() || !pGB)
+ 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)))
+ 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))
+ if(S_OK != MkParseDisplayName(pBindCtx, CComBSTR(DisplayName), &chEaten, &pMoniker)) {
break;
+ }
CComPtr<IBaseFilter> pBF;
- if(FAILED(pMoniker->BindToObject(pBindCtx, 0, IID_IBaseFilter, (void**)&pBF)) || !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)))
+ if(FAILED(pMoniker->BindToStorage(pBindCtx, 0, IID_IPropertyBag, (void**)&pPB))) {
break;
+ }
CComVariant var;
- if(FAILED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL)))
+ 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))))
+ if(FAILED(pGB->AddFilter(pBF, CStringW(var.bstrVal)))) {
break;
+ }
BeginEnumFilters(pGB, pEnum, pBF2)
- if(!pFilters.Find(pBF2) && SUCCEEDED(pGB->RemoveFilter(pBF2)))
+ if(!pFilters.Find(pBF2) && SUCCEEDED(pGB->RemoveFilter(pBF2))) {
pEnum->Reset();
+ }
EndEnumFilters
pPinTo = GetFirstPin(pBF, PINDIR_INPUT);
- if(!pPinTo)
- {
+ if(!pPinTo) {
pGB->RemoveFilter(pBF);
break;
}
HRESULT hr;
- if(FAILED(hr = pGB->ConnectDirect(pPin, pPinTo, NULL)))
- {
+ 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)))
+ if(!pFilters.Find(pBF2) && SUCCEEDED(pGB->RemoveFilter(pBF2))) {
pEnum->Reset();
+ }
EndEnumFilters
pRet = GetFirstPin(pBF, PINDIR_OUTPUT);
- if(!pRet)
- {
+ if(!pRet) {
pRet = pPin;
pGB->RemoveFilter(pBF);
break;
}
- }
- while(false);
+ } while(false);
return(pRet);
}
IPin* InsertFilter(IPin* pPin, CString DisplayName, IGraphBuilder* pGB)
{
- do
- {
- if(!pPin || DisplayName.IsEmpty() || !pGB)
+ do {
+ if(!pPin || DisplayName.IsEmpty() || !pGB) {
break;
+ }
PIN_DIRECTION dir;
- if(FAILED(pPin->QueryDirection(&dir)))
+ if(FAILED(pPin->QueryDirection(&dir))) {
break;
+ }
CComPtr<IPin> pFrom, pTo;
- if(dir == PINDIR_INPUT)
- {
+ if(dir == PINDIR_INPUT) {
pPin->ConnectedTo(&pFrom);
pTo = pPin;
- }
- else if(dir == PINDIR_OUTPUT)
- {
+ } else if(dir == PINDIR_OUTPUT) {
pFrom = pPin;
pPin->ConnectedTo(&pTo);
}
- if(!pFrom || !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))
+ if(S_OK != MkParseDisplayName(pBindCtx, CComBSTR(DisplayName), &chEaten, &pMoniker)) {
break;
+ }
CComPtr<IBaseFilter> pBF;
- if(FAILED(pMoniker->BindToObject(pBindCtx, 0, IID_IBaseFilter, (void**)&pBF)) || !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)))
+ if(FAILED(pMoniker->BindToStorage(pBindCtx, 0, IID_IPropertyBag, (void**)&pPB))) {
break;
+ }
CComVariant var;
- if(FAILED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL)))
+ if(FAILED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL))) {
break;
+ }
- if(FAILED(pGB->AddFilter(pBF, CStringW(var.bstrVal))))
+ if(FAILED(pGB->AddFilter(pBF, CStringW(var.bstrVal)))) {
break;
+ }
CComPtr<IPin> pFromTo = GetFirstPin(pBF, PINDIR_INPUT);
- if(!pFromTo)
- {
+ if(!pFromTo) {
pGB->RemoveFilter(pBF);
break;
}
- if(FAILED(pGB->Disconnect(pFrom)) || FAILED(pGB->Disconnect(pTo)))
- {
+ 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)))
- {
+ 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)
- {
+ if(!pToFrom) {
pGB->RemoveFilter(pBF);
pGB->ConnectDirect(pFrom, pTo, NULL);
break;
}
- if(FAILED(pGB->ConnectDirect(pToFrom, pTo, NULL)))
- {
+ if(FAILED(pGB->ConnectDirect(pToFrom, pTo, NULL))) {
pGB->RemoveFilter(pBF);
pGB->ConnectDirect(pFrom, pTo, NULL);
break;
}
pPin = pToFrom;
- }
- while(false);
+ } while(false);
return(pPin);
}
@@ -627,18 +629,16 @@ void ExtractMediaTypes(IPin* pPin, CAtlArray<GUID>& types)
{
types.RemoveAll();
- BeginEnumMediaTypes(pPin, pEM, pmt)
- {
+ 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)
+ 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)
- {
+ if(!fFound) {
types.Add(pmt->majortype);
types.Add(pmt->subtype);
}
@@ -650,20 +650,18 @@ void ExtractMediaTypes(IPin* pPin, CAtlList<CMediaType>& mts)
{
mts.RemoveAll();
- BeginEnumMediaTypes(pPin, pEM, pmt)
- {
+ BeginEnumMediaTypes(pPin, pEM, pmt) {
bool fFound = false;
POSITION pos = mts.GetHeadPosition();
- while(!fFound && pos)
- {
+ while(!fFound && pos) {
CMediaType& mt = mts.GetNext(pos);
- if(mt.majortype == pmt->majortype && mt.subtype == pmt->subtype)
+ if(mt.majortype == pmt->majortype && mt.subtype == pmt->subtype) {
fFound = true;
+ }
}
- if(!fFound)
- {
+ if(!fFound) {
mts.AddTail(CMediaType(*pmt));
}
}
@@ -672,8 +670,7 @@ void ExtractMediaTypes(IPin* pPin, CAtlList<CMediaType>& mts)
int Eval_Exception(int n_except)
{
- if(n_except == STATUS_ACCESS_VIOLATION)
- {
+ 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 :)"));
}
@@ -682,12 +679,10 @@ int Eval_Exception(int n_except)
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
- {
+ __try {
OleCreatePropertyFrame(hwndOwner, x, y, lpszCaption, cObjects, lplpUnk, cPages, lpPageClsID, lcid, dwReserved, lpvReserved);
}
- __except(Eval_Exception(GetExceptionCode()))
- {
+ __except(Eval_Exception(GetExceptionCode())) {
// No code; this block never executed.
}
}
@@ -699,12 +694,14 @@ void ShowPPage(CString DisplayName, HWND hParentWnd)
CComPtr<IMoniker> pMoniker;
ULONG chEaten;
- if(S_OK != MkParseDisplayName(pBindCtx, CStringW(DisplayName), &chEaten, &pMoniker))
+ if(S_OK != MkParseDisplayName(pBindCtx, CStringW(DisplayName), &chEaten, &pMoniker)) {
return;
+ }
CComPtr<IBaseFilter> pBF;
- if(FAILED(pMoniker->BindToObject(pBindCtx, 0, IID_IBaseFilter, (void**)&pBF)) || !pBF)
+ if(FAILED(pMoniker->BindToObject(pBindCtx, 0, IID_IBaseFilter, (void**)&pBF)) || !pBF) {
return;
+ }
ShowPPage(pBF, hParentWnd);
}
@@ -712,7 +709,9 @@ void ShowPPage(CString DisplayName, HWND hParentWnd)
void ShowPPage(IUnknown* pUnk, HWND hParentWnd)
{
CComQIPtr<ISpecifyPropertyPages> pSPP = pUnk;
- if(!pSPP) return;
+ if(!pSPP) {
+ return;
+ }
CString str;
@@ -720,15 +719,15 @@ void ShowPPage(IUnknown* pUnk, HWND hParentWnd)
CFilterInfo fi;
CComQIPtr<IPin> pPin = pSPP;
CPinInfo pi;
- if(pBF && SUCCEEDED(pBF->QueryFilterInfo(&fi)))
+ if(pBF && SUCCEEDED(pBF->QueryFilterInfo(&fi))) {
str = fi.achName;
- else if(pPin && SUCCEEDED(pPin->QueryPinInfo(&pi)))
+ } else if(pPin && SUCCEEDED(pPin->QueryPinInfo(&pi))) {
str = pi.achName;
+ }
CAUUID caGUID;
caGUID.pElems = NULL;
- if(SUCCEEDED(pSPP->GetPages(&caGUID)))
- {
+ if(SUCCEEDED(pSPP->GetPages(&caGUID))) {
IUnknown* lpUnk = NULL;
pSPP.QueryInterface(&lpUnk);
MyOleCreatePropertyFrame(
@@ -738,14 +737,18 @@ void ShowPPage(IUnknown* pUnk, HWND hParentWnd)
0, 0, NULL);
lpUnk->Release();
- if(caGUID.pElems) CoTaskMemFree(caGUID.pElems);
+ if(caGUID.pElems) {
+ CoTaskMemFree(caGUID.pElems);
+ }
}
}
CLSID GetCLSID(IBaseFilter* pBF)
{
CLSID clsid = GUID_NULL;
- if(pBF) pBF->GetClassID(&clsid);
+ if(pBF) {
+ pBF->GetClassID(&clsid);
+ }
return(clsid);
}
@@ -760,7 +763,7 @@ bool IsCLSIDRegistered(LPCTSTR 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);
+ || ERROR_SUCCESS == CRegKey().Open(HKEY_CLASSES_ROOT, rootkey2 + clsid, KEY_READ);
}
bool IsCLSIDRegistered(const CLSID& clsid)
@@ -768,8 +771,7 @@ bool IsCLSIDRegistered(const CLSID& clsid)
bool fRet = false;
LPOLESTR pStr = NULL;
- if(S_OK == StringFromCLSID(clsid, &pStr) && pStr)
- {
+ if(S_OK == StringFromCLSID(clsid, &pStr) && pStr) {
fRet = IsCLSIDRegistered(CString(pStr));
CoTaskMemFree(pStr);
}
@@ -786,23 +788,25 @@ void CStringToBin(CString str, CAtlArray<BYTE>& data)
BYTE b = 0;
str.MakeUpper();
- for(size_t i = 0, j = str.GetLength(); i < j; i++)
- {
+ for(size_t i = 0, j = str.GetLength(); i < j; i++) {
TCHAR c = str[i];
- if(c >= '0' && c <= '9')
- {
- if(!(i&1)) b = ((char(c-'0')<<4)&0xf0)|(b&0x0f);
- else b = (char(c-'0')&0x0f)|(b&0xf0);
- }
- else if(c >= 'A' && c <= 'F')
- {
- if(!(i&1)) b = ((char(c-'A'+10)<<4)&0xf0)|(b&0x0f);
- else b = (char(c-'A'+10)&0x0f)|(b&0xf0);
+ if(c >= '0' && c <= '9') {
+ if(!(i&1)) {
+ b = ((char(c-'0')<<4)&0xf0)|(b&0x0f);
+ } else {
+ b = (char(c-'0')&0x0f)|(b&0xf0);
+ }
+ } else if(c >= 'A' && c <= 'F') {
+ if(!(i&1)) {
+ b = ((char(c-'A'+10)<<4)&0xf0)|(b&0x0f);
+ } else {
+ b = (char(c-'A'+10)&0x0f)|(b&0xf0);
+ }
+ } else {
+ break;
}
- else break;
- if(i&1)
- {
+ if(i&1) {
data[i>>1] = b;
b = 0;
}
@@ -813,8 +817,7 @@ CString BinToCString(BYTE* ptr, int len)
{
CString ret;
- while(len-- > 0)
- {
+ while(len-- > 0) {
TCHAR high, low;
high = (*ptr>>4) >= 10 ? (*ptr>>4)-10 + 'A' : (*ptr>>4) + '0';
low = (*ptr&0xf) >= 10 ? (*ptr&0xf)-10 + 'A' : (*ptr&0xf) + '0';
@@ -837,12 +840,10 @@ static void FindFiles(CString fn, CAtlList<CString>& files)
WIN32_FIND_DATA findData;
HANDLE h = FindFirstFile(fn, &findData);
- if(h != INVALID_HANDLE_VALUE)
- {
+ if(h != INVALID_HANDLE_VALUE) {
do {
files.AddTail(path + findData.cFileName);
- }
- while(FindNextFile(h, &findData));
+ } while(FindNextFile(h, &findData));
FindClose(h);
}
@@ -855,8 +856,7 @@ cdrom_t GetCDROMType(TCHAR drive, CAtlList<CString>& files)
CString path;
path.Format(_T("%c:"), drive);
- if(GetDriveType(path + _T("\\")) == DRIVE_CDROM)
- {
+ if(GetDriveType(path + _T("\\")) == DRIVE_CDROM) {
// CDROM_VideoCD
FindFiles(path + _T("\\mpegav\\avseq??.dat"), files);
FindFiles(path + _T("\\mpegav\\avseq??.mpg"), files);
@@ -866,29 +866,28 @@ cdrom_t GetCDROMType(TCHAR drive, CAtlList<CString>& 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;
+ 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;
+ if(files.GetCount() > 0) {
+ return CDROM_DVDVideo;
+ }
// CDROM_Audio
- if(!(GetVersion()&0x80000000))
- {
+ if(!(GetVersion()&0x80000000)) {
HANDLE hDrive = CreateFile(CString(_T("\\\\.\\")) + path, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, (HANDLE)NULL);
- if(hDrive != INVALID_HANDLE_VALUE)
- {
+ 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++)
- {
+ 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)
- {
+ 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);
@@ -899,7 +898,9 @@ cdrom_t GetCDROMType(TCHAR drive, CAtlList<CString>& files)
CloseHandle(hDrive);
}
}
- if(files.GetCount() > 0) return CDROM_Audio;
+ if(files.GetCount() > 0) {
+ return CDROM_Audio;
+ }
// it is a cdrom but nothing special
return CDROM_Unknown;
@@ -918,8 +919,7 @@ CString GetDriveLabel(TCHAR drive)
DWORD VolumeSerialNumber, MaximumComponentLength, FileSystemFlags;
if(GetVolumeInformation(path,
VolumeNameBuffer, MAX_PATH, &VolumeSerialNumber, &MaximumComponentLength,
- &FileSystemFlags, FileSystemNameBuffer, MAX_PATH))
- {
+ &FileSystemFlags, FileSystemNameBuffer, MAX_PATH)) {
label = VolumeNameBuffer;
}
@@ -931,39 +931,35 @@ bool GetKeyFrames(CString fn, CUIntArray& kfs)
kfs.RemoveAll();
CString fn2 = CString(fn).MakeLower();
- if(fn2.Mid(fn2.ReverseFind('.')+1) == _T("avi"))
- {
+ if(fn2.Mid(fn2.ReverseFind('.')+1) == _T("avi")) {
AVIFileInit();
PAVIFILE pfile;
- if(AVIFileOpen(&pfile, fn, OF_SHARE_DENY_WRITE, 0L) == 0)
- {
+ 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)
- {
+ if(AVIFileGetStream(pfile, &pavi, streamtypeVIDEO, 0) == AVIERR_OK) {
AVISTREAMINFO si;
AVIStreamInfo(pavi, &si, sizeof(si));
- if(afi.dwCaps&AVIFILECAPS_ALLKEYFRAMES)
- {
+ if(afi.dwCaps&AVIFILECAPS_ALLKEYFRAMES) {
kfs.SetSize(si.dwLength);
- for(ptrdiff_t kf = 0; kf < (int)si.dwLength; kf++) kfs[kf] = kf;
- }
- else
- {
- for(ptrdiff_t kf = 0; ; kf++)
- {
+ for(ptrdiff_t kf = 0; kf < (int)si.dwLength; kf++) {
+ kfs[kf] = kf;
+ }
+ } else {
+ for(ptrdiff_t kf = 0; ; kf++) {
kf = pavi->FindSample(kf, FIND_KEY|FIND_NEXT);
- if(kf < 0 || kfs.GetCount() > 0 && kfs[kfs.GetCount()-1] >= (UINT)kf) break;
+ 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)
- {
+ if(kfs.GetCount() > 0 && kfs[kfs.GetCount()-1] < si.dwLength-1) {
kfs.Add(si.dwLength-1);
}
}
@@ -980,8 +976,7 @@ bool GetKeyFrames(CString fn, CUIntArray& kfs)
DVD_HMSF_TIMECODE RT2HMSF(REFERENCE_TIME rt, double fps)
{
- DVD_HMSF_TIMECODE hmsf =
- {
+ DVD_HMSF_TIMECODE hmsf = {
(BYTE)((rt/10000000/60/60)),
(BYTE)((rt/10000000/60)%60),
(BYTE)((rt/10000000)%60),
@@ -1003,10 +998,8 @@ REFERENCE_TIME HMSF2RT(DVD_HMSF_TIMECODE hmsf, double fps)
void memsetd(void* dst, unsigned int c, size_t nbytes)
{
#ifndef _WIN64
- if (!(g_cpuid.m_flags & g_cpuid.sse2))
- {
- __asm
- {
+ if (!(g_cpuid.m_flags & g_cpuid.sse2)) {
+ __asm {
mov eax, c
mov ecx, nbytes
shr ecx, 2
@@ -1021,25 +1014,23 @@ void memsetd(void* dst, unsigned int c, size_t nbytes)
size_t o = n - (n % 4);
__m128i val = _mm_set1_epi32 ( (int)c );
- if (((uintptr_t)dst & 0x0F) == 0) // 16-byte aligned
- {
- for (ptrdiff_t i = 0; i < o; i+=4)
+ if (((uintptr_t)dst & 0x0F) == 0) { // 16-byte aligned
+ for (ptrdiff_t i = 0; i < o; i+=4) {
_mm_store_si128( (__m128i*)&(((DWORD*)dst)[i]), val );
- }
- else
- {
- for (ptrdiff_t i = 0; i < o; i+=4)
+ }
+ } else {
+ for (ptrdiff_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;
+ switch(n - o) {
+ case 3:
+ ((DWORD*)dst)[o + 2] = c;
+ case 2:
+ ((DWORD*)dst)[o + 1] = c;
+ case 1:
+ ((DWORD*)dst)[o + 0] = c;
}
}
@@ -1049,42 +1040,33 @@ void memsetw(void* dst, unsigned short c, size_t nbytes)
size_t n = nbytes / 2;
size_t o = (n / 2) * 2;
- if ((n - o) == 1)
+ if ((n - o) == 1) {
((WORD*)dst)[o] = c;
+ }
}
bool ExtractBIH(const AM_MEDIA_TYPE* pmt, BITMAPINFOHEADER* bih)
{
- if(pmt && bih)
- {
+ if(pmt && bih) {
memset(bih, 0, sizeof(*bih));
- if(pmt->formattype == FORMAT_VideoInfo)
- {
+ if(pmt->formattype == FORMAT_VideoInfo) {
VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->pbFormat;
memcpy(bih, &vih->bmiHeader, sizeof(BITMAPINFOHEADER));
return true;
- }
- else if(pmt->formattype == FORMAT_VideoInfo2)
- {
+ } 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)
- {
+ } 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)
- {
+ } 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)
- {
+ } else if(pmt->formattype == FORMAT_DiracVideoInfo) {
VIDEOINFOHEADER2* vih = &((DIRACINFOHEADER*)pmt->pbFormat)->hdr;
memcpy(bih, &vih->bmiHeader, sizeof(BITMAPINFOHEADER));
return true;
@@ -1096,16 +1078,17 @@ bool ExtractBIH(const AM_MEDIA_TYPE* pmt, BITMAPINFOHEADER* bih)
bool ExtractAvgTimePerFrame(const AM_MEDIA_TYPE* pmt, REFERENCE_TIME& rtAvgTimePerFrame)
{
- if (pmt->formattype==FORMAT_VideoInfo)
+ if (pmt->formattype==FORMAT_VideoInfo) {
rtAvgTimePerFrame = ((VIDEOINFOHEADER*)pmt->pbFormat)->AvgTimePerFrame;
- else if (pmt->formattype==FORMAT_VideoInfo2)
+ } else if (pmt->formattype==FORMAT_VideoInfo2) {
rtAvgTimePerFrame = ((VIDEOINFOHEADER2*)pmt->pbFormat)->AvgTimePerFrame;
- else if (pmt->formattype==FORMAT_MPEGVideo)
+ } else if (pmt->formattype==FORMAT_MPEGVideo) {
rtAvgTimePerFrame = ((MPEG1VIDEOINFO*)pmt->pbFormat)->hdr.AvgTimePerFrame;
- else if (pmt->formattype==FORMAT_MPEG2Video)
+ } else if (pmt->formattype==FORMAT_MPEG2Video) {
rtAvgTimePerFrame = ((MPEG2VIDEOINFO*)pmt->pbFormat)->hdr.AvgTimePerFrame;
- else
+ } else {
return false;
+ }
return true;
}
@@ -1115,8 +1098,7 @@ bool ExtractBIH(IMediaSample* pMS, BITMAPINFOHEADER* bih)
{
AM_MEDIA_TYPE* pmt = NULL;
pMS->GetMediaType(&pmt);
- if(pmt)
- {
+ if(pmt) {
bool fRet = ExtractBIH(pmt, bih);
DeleteMediaType(pmt);
return(fRet);
@@ -1129,29 +1111,23 @@ 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)
- {
+ 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)
- {
+ } 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
- {
+ } else {
return(false);
}
- if(!arx || !ary)
- {
+ if(!arx || !ary) {
arx = w;
ary = h;
}
@@ -1159,17 +1135,14 @@ bool ExtractDim(const AM_MEDIA_TYPE* pmt, int& w, int& h, int& arx, int& ary)
BYTE* ptr = NULL;
DWORD len = 0;
- if(pmt->formattype == FORMAT_MPEGVideo)
- {
+ if(pmt->formattype == FORMAT_MPEGVideo) {
ptr = ((MPEG1VIDEOINFO*)pmt->pbFormat)->bSequenceHeader;
len = ((MPEG1VIDEOINFO*)pmt->pbFormat)->cbSequenceHeader;
- if(ptr && len >= 8 && *(DWORD*)ptr == 0xb3010000)
- {
+ if(ptr && len >= 8 && *(DWORD*)ptr == 0xb3010000) {
w = (ptr[4]<<4)|(ptr[5]>>4);
h = ((ptr[5]&0xf)<<8)|ptr[6];
- float ar[] =
- {
+ 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,
@@ -1178,14 +1151,11 @@ bool ExtractDim(const AM_MEDIA_TYPE* pmt, int& w, int& h, int& arx, int& ary)
arx = (int)((float)w / ar[ptr[7]>>4] + 0.5);
ary = h;
}
- }
- else if(pmt->formattype == FORMAT_MPEG2_VIDEO)
- {
+ } 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)
- {
+ if(ptr && len >= 8 && *(DWORD*)ptr == 0xb3010000) {
w = (ptr[4]<<4)|(ptr[5]>>4);
h = ((ptr[5]&0xf)<<8)|ptr[6];
struct {
@@ -1197,8 +1167,7 @@ bool ExtractDim(const AM_MEDIA_TYPE* pmt, int& w, int& h, int& arx, int& ary)
}
}
- if(ptr && len >= 8)
- {
+ if(ptr && len >= 8) {
}
@@ -1208,30 +1177,48 @@ bool ExtractDim(const AM_MEDIA_TYPE* pmt, int& w, int& h, int& arx, int& ary)
a = b % tmp;
b = tmp;
}
- if(b) arx /= b, ary /= b;
+ 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) return false;
+ if(len < 4 || *(DWORD*)seqhdr != 0xb3010000) {
+ return false;
+ }
BYTE* seqhdr_ext = NULL;
BYTE* seqhdr_end = seqhdr + 11;
- if(seqhdr_end - seqhdr > (long)len) return false;
- if(*seqhdr_end & 0x02) seqhdr_end += 64;
- if(seqhdr_end - seqhdr > (long)len) return false;
- if(*seqhdr_end & 0x01) seqhdr_end += 64;
- if(seqhdr_end - seqhdr > (long)len) return false;
+ if(seqhdr_end - seqhdr > (long)len) {
+ return false;
+ }
+ if(*seqhdr_end & 0x02) {
+ seqhdr_end += 64;
+ }
+ if(seqhdr_end - seqhdr > (long)len) {
+ return false;
+ }
+ if(*seqhdr_end & 0x01) {
+ seqhdr_end += 64;
+ }
+ if(seqhdr_end - seqhdr > (long)len) {
+ return false;
+ }
seqhdr_end++;
- if(seqhdr_end - seqhdr > (long)len) return false;
+ if(seqhdr_end - seqhdr > (long)len) {
+ return false;
+ }
if(len - (seqhdr_end - seqhdr) > 4 && *(DWORD*)seqhdr_end == 0xb5010000) {
seqhdr_ext = seqhdr_end;
seqhdr_end += 10;
}
- if(seqhdr_end - seqhdr > (long)len) return false;
+ if(seqhdr_end - seqhdr > (long)len) {
+ return false;
+ }
len = seqhdr_end - seqhdr;
@@ -1251,22 +1238,19 @@ bool MakeMPEG2MediaType(CMediaType& mt, BYTE* seqhdr, DWORD len, int w, int h)
memcpy(pSequenceHeader, seqhdr, len);
vih->cbSequenceHeader = len;
- static char profile[8] =
- {
+ 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] =
- {
+ 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)
- {
+ if(seqhdr_ext && (seqhdr_ext[4] & 0xf0) == 0x10) {
vih->dwProfile = profile[seqhdr_ext[4] & 0x07];
vih->dwLevel = level[seqhdr_ext[5] >> 4];
}
@@ -1283,14 +1267,11 @@ unsigned __int64 GetFileVersion(LPCTSTR fn)
DWORD d; // a variable that GetFileVersionInfoSize sets to zero (but why is it needed ?????????????????????????????? :)
DWORD len = GetFileVersionInfoSize((TCHAR*)fn, &d);
- if(len)
- {
+ if(len) {
TCHAR* b1 = DNew TCHAR[len];
- if(b1)
- {
+ if(b1) {
UINT uLen;
- if(GetFileVersionInfo((TCHAR*)fn, 0, len, b1) && VerQueryValue(b1, _T("\\"), (void**)&pvsf, &uLen))
- {
+ if(GetFileVersionInfo((TCHAR*)fn, 0, len, b1) && VerQueryValue(b1, _T("\\"), (void**)&pvsf, &uLen)) {
ret = ((unsigned __int64)pvsf->dwFileVersionMS<<32) | pvsf->dwFileVersionLS;
}
@@ -1303,7 +1284,9 @@ unsigned __int64 GetFileVersion(LPCTSTR fn)
bool CreateFilter(CStringW DisplayName, IBaseFilter** ppBF, CStringW& FriendlyName)
{
- if(!ppBF) return(false);
+ if(!ppBF) {
+ return(false);
+ }
*ppBF = NULL;
FriendlyName.Empty();
@@ -1313,65 +1296,73 @@ bool CreateFilter(CStringW DisplayName, IBaseFilter** ppBF, CStringW& FriendlyNa
CComPtr<IMoniker> pMoniker;
ULONG chEaten;
- if(S_OK != MkParseDisplayName(pBindCtx, CComBSTR(DisplayName), &chEaten, &pMoniker))
+ if(S_OK != MkParseDisplayName(pBindCtx, CComBSTR(DisplayName), &chEaten, &pMoniker)) {
return(false);
+ }
- if(FAILED(pMoniker->BindToObject(pBindCtx, 0, IID_IBaseFilter, (void**)ppBF)) || !*ppBF)
+ 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)))
+ && SUCCEEDED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL))) {
FriendlyName = var.bstrVal;
+ }
return(true);
}
IBaseFilter* AppendFilter(IPin* pPin, IMoniker* pMoniker, IGraphBuilder* pGB)
{
- do
- {
- if(!pPin || !pMoniker || !pGB)
+ do {
+ if(!pPin || !pMoniker || !pGB) {
break;
+ }
CComPtr<IPin> pPinTo;
PIN_DIRECTION dir;
- if(FAILED(pPin->QueryDirection(&dir)) || dir != PINDIR_OUTPUT || SUCCEEDED(pPin->ConnectedTo(&pPinTo)))
+ if(FAILED(pPin->QueryDirection(&dir)) || dir != PINDIR_OUTPUT || SUCCEEDED(pPin->ConnectedTo(&pPinTo))) {
break;
+ }
CComPtr<IBindCtx> pBindCtx;
CreateBindCtx(0, &pBindCtx);
CComPtr<IPropertyBag> pPB;
- if(FAILED(pMoniker->BindToStorage(pBindCtx, 0, IID_IPropertyBag, (void**)&pPB)))
+ if(FAILED(pMoniker->BindToStorage(pBindCtx, 0, IID_IPropertyBag, (void**)&pPB))) {
break;
+ }
CComVariant var;
- if(FAILED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL)))
+ if(FAILED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL))) {
break;
+ }
CComPtr<IBaseFilter> pBF;
- if(FAILED(pMoniker->BindToObject(pBindCtx, 0, IID_IBaseFilter, (void**)&pBF)) || !pBF)
+ if(FAILED(pMoniker->BindToObject(pBindCtx, 0, IID_IBaseFilter, (void**)&pBF)) || !pBF) {
break;
+ }
- if(FAILED(pGB->AddFilter(pBF, CStringW(var.bstrVal))))
+ if(FAILED(pGB->AddFilter(pBF, CStringW(var.bstrVal)))) {
break;
+ }
- BeginEnumPins(pBF, pEP, pPinTo)
- {
+ BeginEnumPins(pBF, pEP, pPinTo) {
PIN_DIRECTION dir;
- if(FAILED(pPinTo->QueryDirection(&dir)) || dir != PINDIR_INPUT)
+ if(FAILED(pPinTo->QueryDirection(&dir)) || dir != PINDIR_INPUT) {
continue;
+ }
- if(SUCCEEDED(pGB->ConnectDirect(pPin, pPinTo, NULL)))
+ if(SUCCEEDED(pGB->ConnectDirect(pPin, pPinTo, NULL))) {
return(pBF);
+ }
}
EndEnumFilters
pGB->RemoveFilter(pBF);
- }
- while(false);
+ } while(false);
return(NULL);
}
@@ -1385,20 +1376,21 @@ CStringW GetFriendlyName(CStringW DisplayName)
CComPtr<IMoniker> pMoniker;
ULONG chEaten;
- if(S_OK != MkParseDisplayName(pBindCtx, CComBSTR(DisplayName), &chEaten, &pMoniker))
+ 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)))
+ && SUCCEEDED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL))) {
FriendlyName = var.bstrVal;
+ }
return FriendlyName;
}
-typedef struct
-{
+typedef struct {
CString path;
HINSTANCE hInst;
CLSID clsid;
@@ -1416,11 +1408,9 @@ HRESULT LoadExternalObject(LPCTSTR path, REFCLSID clsid, REFIID iid, void** ppv)
bool fFound = false;
POSITION pos = s_extobjs.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
ExternalObject& eo = s_extobjs.GetNext(pos);
- if(!eo.path.CompareNoCase(fullpath))
- {
+ if(!eo.path.CompareNoCase(fullpath)) {
hInst = eo.hInst;
fFound = true;
break;
@@ -1429,31 +1419,27 @@ HRESULT LoadExternalObject(LPCTSTR path, REFCLSID clsid, REFIID iid, void** ppv)
HRESULT hr = E_FAIL;
- if(!hInst)
+ if(!hInst) {
hInst = CoLoadLibrary(CComBSTR(fullpath), TRUE);
- if(hInst)
- {
+ }
+ 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)))
- {
+ if(p && FAILED(hr = p(clsid, iid, ppv))) {
CComPtr<IClassFactory> pCF;
- if(SUCCEEDED(hr = p(clsid, __uuidof(IClassFactory), (void**)&pCF)))
- {
+ if(SUCCEEDED(hr = p(clsid, __uuidof(IClassFactory), (void**)&pCF))) {
hr = pCF->CreateInstance(NULL, iid, ppv);
}
}
}
- if(FAILED(hr) && hInst && !fFound)
- {
+ if(FAILED(hr) && hInst && !fFound) {
CoFreeLibrary(hInst);
return hr;
}
- if(hInst && !fFound)
- {
+ if(hInst && !fFound) {
ExternalObject eo;
eo.path = fullpath;
eo.hInst = hInst;
@@ -1472,14 +1458,14 @@ HRESULT LoadExternalFilter(LPCTSTR path, REFCLSID clsid, IBaseFilter** ppBF)
HRESULT LoadExternalPropertyPage(IPersist* pP, REFCLSID clsid, IPropertyPage** ppPP)
{
CLSID clsid2 = GUID_NULL;
- if(FAILED(pP->GetClassID(&clsid2))) return E_FAIL;
+ if(FAILED(pP->GetClassID(&clsid2))) {
+ return E_FAIL;
+ }
POSITION pos = s_extobjs.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
ExternalObject& eo = s_extobjs.GetNext(pos);
- if(eo.clsid == clsid2)
- {
+ if(eo.clsid == clsid2) {
return LoadExternalObject(eo.path, clsid, __uuidof(IPropertyPage), (void**)ppPP);
}
}
@@ -1490,8 +1476,7 @@ HRESULT LoadExternalPropertyPage(IPersist* pP, REFCLSID clsid, IPropertyPage** p
void UnloadExternalObjects()
{
POSITION pos = s_extobjs.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
ExternalObject& eo = s_extobjs.GetNext(pos);
CoFreeLibrary(eo.hInst);
}
@@ -1507,13 +1492,10 @@ CString MakeFullPath(LPCTSTR path)
fn.ReleaseBuffer(GetModuleFileName(AfxGetInstanceHandle(), fn.GetBuffer(MAX_PATH), MAX_PATH));
CPath p(fn);
- if(full.GetLength() >= 2 && full[0] == '\\' && full[1] != '\\')
- {
+ if(full.GetLength() >= 2 && full[0] == '\\' && full[1] != '\\') {
p.StripToRoot();
full = CString(p) + full.Mid(1);
- }
- else if(full.Find(_T(":\\")) < 0)
- {
+ } else if(full.Find(_T(":\\")) < 0) {
p.RemoveFileSpec();
p.AddBackslash();
full = CString(p) + full;
@@ -1532,17 +1514,15 @@ CString GetMediaTypeName(const GUID& guid)
? _T("Any type")
: CString(GuidNames[guid]);
- if(ret == _T("FOURCC GUID"))
- {
+ if(ret == _T("FOURCC GUID")) {
CString str;
- if(guid.Data1 >= 0x10000)
+ 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
+ } else {
str.Format(_T("Audio: 0x%08x"), guid.Data1);
+ }
ret = str;
- }
- else if(ret == _T("Unknown GUID Name"))
- {
+ } 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));
@@ -1576,7 +1556,9 @@ CStringW UTF8To16(LPCSTR utf8)
{
CStringW str;
int n = MultiByteToWideChar(CP_UTF8, 0, utf8, -1, NULL, 0)-1;
- if(n < 0) return str;
+ if(n < 0) {
+ return str;
+ }
str.ReleaseBuffer(MultiByteToWideChar(CP_UTF8, 0, utf8, -1, str.GetBuffer(n), n+1)-1);
return str;
}
@@ -1585,7 +1567,9 @@ CStringA UTF16To8(LPCWSTR utf16)
{
CStringA str;
int n = WideCharToMultiByte(CP_UTF8, 0, utf16, -1, NULL, 0, NULL, NULL)-1;
- if(n < 0) return str;
+ if(n < 0) {
+ return str;
+ }
str.ReleaseBuffer(WideCharToMultiByte(CP_UTF8, 0, utf16, -1, str.GetBuffer(n), n+1, NULL, NULL)-1);
return str;
}
@@ -1593,8 +1577,7 @@ CStringA UTF16To8(LPCWSTR utf16)
static struct {
LPCSTR name, iso6392, iso6391;
LCID lcid;
-} s_isolangs[] = // TODO : fill LCID !!!
-{
+} s_isolangs[] = { // TODO : fill LCID !!!
{"Abkhazian", "abk", "ab"},
{"Achinese", "ace", ""},
{"Acoli", "ach", ""},
@@ -2133,11 +2116,12 @@ CString ISO6391ToLanguage(LPCSTR code)
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))
- {
+ 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);
+ if(i > 0) {
+ ret = ret.Left(i);
+ }
return ret;
}
return(_T(""));
@@ -2149,13 +2133,13 @@ CString ISO6392ToLanguage(LPCSTR code)
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))
- {
+ 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);
+ if(i > 0) {
+ ret = ret.Left(i);
+ }
return ret;
}
}
@@ -2168,10 +2152,8 @@ LCID ISO6391ToLcid(LPCSTR code)
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))
- {
+ for(ptrdiff_t i = 0, j = countof(s_isolangs); i < j; i++) {
+ if(!strcmp(s_isolangs[i].iso6391, code)) {
return s_isolangs[i].lcid;
}
}
@@ -2184,10 +2166,8 @@ LCID ISO6392ToLcid(LPCSTR code)
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))
- {
+ for(ptrdiff_t i = 0, j = countof(s_isolangs); i < j; i++) {
+ if(!strcmp(s_isolangs[i].iso6392, tmp)) {
return s_isolangs[i].lcid;
}
}
@@ -2201,8 +2181,9 @@ CString ISO6391To6392(LPCSTR code)
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))
+ if(!strcmp(s_isolangs[i].iso6391, tmp)) {
return CString(CStringA(s_isolangs[i].iso6392));
+ }
return _T("");
}
@@ -2213,8 +2194,9 @@ CString ISO6392To6391(LPCSTR code)
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))
+ if(!strcmp(s_isolangs[i].iso6392, tmp)) {
return CString(CStringA(s_isolangs[i].iso6391));
+ }
return _T("");
}
@@ -2222,15 +2204,14 @@ CString LanguageToISO6392(LPCTSTR lang)
{
CString str = lang;
str.MakeLower();
- for(ptrdiff_t i = 0, j = countof(s_isolangs); i < j; i++)
- {
+ 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)))
+ while(pos) {
+ if(!str.CompareNoCase(sl.GetNext(pos))) {
return CString(s_isolangs[i].iso6392);
+ }
}
}
return _T("");
@@ -2240,40 +2221,65 @@ 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;
+ 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)
- {
+ 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;
+ 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);
@@ -2287,12 +2293,9 @@ int MakeAACInitData(BYTE* pData, int profile, int freq, int channels)
BOOL CFileGetStatus(LPCTSTR lpszFileName, CFileStatus& status)
{
- try
- {
+ try {
return CFile::GetStatus(lpszFileName, status);
- }
- catch(CException* e)
- {
+ } 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"));
@@ -2309,10 +2312,10 @@ bool DeleteRegKey(LPCTSTR pszKey, LPCTSTR pszSubkey)
HKEY hKey;
LONG ec = ::RegOpenKeyEx(HKEY_CLASSES_ROOT, pszKey, 0, KEY_ALL_ACCESS, &hKey);
- if(ec == ERROR_SUCCESS)
- {
- if(pszSubkey != 0)
+ if(ec == ERROR_SUCCESS) {
+ if(pszSubkey != 0) {
ec = ::RegDeleteKey(hKey, pszSubkey);
+ }
bOK = (ec == ERROR_SUCCESS);
@@ -2327,15 +2330,14 @@ bool SetRegKeyValue(LPCTSTR pszKey, LPCTSTR pszSubkey, LPCTSTR pszValueName, LPC
bool bOK = false;
CString szKey(pszKey);
- if(pszSubkey != 0)
+ 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)
- {
+ if(ec == ERROR_SUCCESS) {
+ if(pszValue != 0) {
ec = ::RegSetValueEx(hKey, pszValueName, 0, REG_SZ,
reinterpret_cast<BYTE*>(const_cast<LPTSTR>(pszValue)),
(_tcslen(pszValue) + 1) * sizeof(TCHAR));
@@ -2367,8 +2369,9 @@ void RegisterSourceFilter(const CLSID& clsid, const GUID& subtype2, LPCTSTR chkb
va_list marker;
va_start(marker, ext);
- for(; ext; ext = va_arg(marker, LPCTSTR))
+ for(; ext; ext = va_arg(marker, LPCTSTR)) {
DeleteRegKey(_T("Media Type\\Extensions"), ext);
+ }
va_end(marker);
}
@@ -2379,8 +2382,7 @@ void RegisterSourceFilter(const CLSID& clsid, const GUID& subtype2, const CAtlLi
CString subtype = CStringFromGUID(subtype2);
POSITION pos = chkbytes.GetHeadPosition();
- for(ptrdiff_t i = 0; pos; i++)
- {
+ for(ptrdiff_t i = 0; pos; i++) {
CString idx;
idx.Format(_T("%d"), i);
SetRegKeyValue(_T("Media Type\\") + majortype, subtype, idx, chkbytes.GetNext(pos));
@@ -2392,8 +2394,9 @@ void RegisterSourceFilter(const CLSID& clsid, const GUID& subtype2, const CAtlLi
va_list marker;
va_start(marker, ext);
- for(; ext; ext = va_arg(marker, LPCTSTR))
+ for(; ext; ext = va_arg(marker, LPCTSTR)) {
DeleteRegKey(_T("Media Type\\Extensions"), ext);
+ }
va_end(marker);
}
@@ -2403,14 +2406,12 @@ void UnRegisterSourceFilter(const GUID& subtype)
}
-typedef struct
-{
+typedef struct {
const GUID* Guid;
const LPCTSTR Description;
} DXVA2_DECODER;
-static const DXVA2_DECODER DXVA2Decoder[] =
-{
+static const DXVA2_DECODER DXVA2Decoder[] = {
{ &GUID_NULL, _T("Unknown") },
{ &GUID_NULL, _T("Not using DXVA") },
{ &DXVA2_ModeH264_A, _T("H.264 motion compensation, no FGT") },
@@ -2443,10 +2444,8 @@ LPCTSTR GetDXVAMode(const GUID* guidDecoder)
{
int nPos = 0;
- for (int i=1; i<countof(DXVA2Decoder); i++)
- {
- if (*guidDecoder == *DXVA2Decoder[i].Guid)
- {
+ for (int i=1; i<countof(DXVA2Decoder); i++) {
+ if (*guidDecoder == *DXVA2Decoder[i].Guid) {
nPos = i;
break;
}
@@ -2460,23 +2459,23 @@ 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++)
- {
+ for (int i=0; i<3; i++) {
+ for (int j=0; j<32; j++) {
nPos = i*32 + j;
- if (nPos >= nSize) break;
+ if (nPos >= nSize) {
+ break;
+ }
strMsg.AppendFormat (L"%02x ", pBuffer[nPos]);
}
- if (nPos >= nSize) break;
+ if (nPos >= nSize) {
+ break;
+ }
strMsg.AppendFormat (L"\n");
}
- if (nSize > 32*3)
- {
+ if (nSize > 32*3) {
strMsg.AppendFormat (L".../...\n");
- for (int j=32; j>0; j--)
- {
+ for (int j=32; j>0; j--) {
strMsg.AppendFormat (L"%02x ", pBuffer[nSize - j]);
}
}
@@ -2527,8 +2526,7 @@ REFERENCE_TIME StringToReftime(LPCTSTR strVal)
int lSecond = 0;
int lMillisec = 0;
- if (_stscanf_s (strVal, _T("%02d:%02d:%02d,%03d"), &lHour, &lMinute, &lSecond, &lMillisec) == 4)
- {
+ if (_stscanf_s (strVal, _T("%02d:%02d:%02d,%03d"), &lHour, &lMinute, &lSecond, &lMillisec) == 4) {
rt = ( (((lHour*24)+lMinute)*60 + lSecond) * MILLISECONDS + lMillisec ) * (UNITS/MILLISECONDS);
}
@@ -2586,11 +2584,9 @@ DWORD YCrCbToRGB_Rec709(BYTE A, BYTE Y, BYTE Cr, BYTE Cb)
void TraceFilterInfo(IBaseFilter* pBF)
{
FILTER_INFO Info;
- if (SUCCEEDED (pBF->QueryFilterInfo(&Info)))
- {
+ if (SUCCEEDED (pBF->QueryFilterInfo(&Info))) {
TRACE (" === Filter info : %S\n", Info.achName);
- BeginEnumPins(pBF, pEnum, pPin)
- {
+ BeginEnumPins(pBF, pEnum, pPin) {
TracePinInfo(pPin);
}
@@ -2608,8 +2604,7 @@ void TracePinInfo(IPin* pPin)
CComPtr<IPin> pConnected;
memset (&ConnectedInfo, 0, sizeof(ConnectedInfo));
memset (&ConnectedFilterInfo, 0, sizeof(ConnectedFilterInfo));
- if (SUCCEEDED (pPin->ConnectedTo (&pConnected)))
- {
+ if (SUCCEEDED (pPin->ConnectedTo (&pConnected))) {
pConnected->QueryPinInfo (&ConnectedInfo);
ConnectedInfo.pFilter->QueryFilterInfo(&ConnectedFilterInfo);
ConnectedInfo.pFilter->Release();
@@ -2627,44 +2622,43 @@ void TracePinInfo(IPin* pPin)
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";
+ 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;
}
@@ -2672,8 +2666,7 @@ const wchar_t *StreamTypeToName(PES_STREAM_TYPE _Type)
//
// Usage: SetThreadName (-1, "MainThread");
//
-typedef struct tagTHREADNAME_INFO
-{
+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)
@@ -2688,11 +2681,9 @@ void SetThreadName( DWORD dwThreadID, LPCSTR szThreadName)
info.dwThreadID = dwThreadID;
info.dwFlags = 0;
- __try
- {
+ __try {
RaiseException( 0x406D1388, 0, sizeof(info)/sizeof(DWORD), (ULONG_PTR*)&info );
}
- __except(EXCEPTION_CONTINUE_EXECUTION)
- {
+ __except(EXCEPTION_CONTINUE_EXECUTION) {
}
} \ No newline at end of file
diff --git a/src/DSUtil/DSUtil.h b/src/DSUtil/DSUtil.h
index 891f86940..f01c18be0 100644
--- a/src/DSUtil/DSUtil.h
+++ b/src/DSUtil/DSUtil.h
@@ -130,7 +130,9 @@ public:
pFilter = NULL;
}
~CPinInfo() {
- if(pFilter) pFilter->Release();
+ if(pFilter) {
+ pFilter->Release();
+ }
}
};
@@ -141,7 +143,9 @@ public:
pGraph = NULL;
}
~CFilterInfo() {
- if(pGraph) pGraph->Release();
+ if(pGraph) {
+ pGraph->Release();
+ }
}
};
@@ -151,7 +155,7 @@ public:
{ \
for(CComPtr<IBaseFilter> pBaseFilter; S_OK == pEnumFilters->Next(1, &pBaseFilter, 0); pBaseFilter = NULL) \
{ \
-
+
#define EndEnumFilters }}}
#define BeginEnumCachedFilters(pGraphConfig, pEnumFilters, pBaseFilter) \
@@ -160,7 +164,7 @@ public:
{ \
for(CComPtr<IBaseFilter> pBaseFilter; S_OK == pEnumFilters->Next(1, &pBaseFilter, 0); pBaseFilter = NULL) \
{ \
-
+
#define EndEnumCachedFilters }}}
#define BeginEnumPins(pBaseFilter, pEnumPins, pPin) \
@@ -169,7 +173,7 @@ public:
{ \
for(CComPtr<IPin> pPin; S_OK == pEnumPins->Next(1, &pPin, 0); pPin = NULL) \
{ \
-
+
#define EndEnumPins }}}
#define BeginEnumMediaTypes(pPin, pEnumMediaTypes, pMediaType) \
@@ -179,7 +183,7 @@ public:
AM_MEDIA_TYPE* pMediaType = NULL; \
for(; S_OK == pEnumMediaTypes->Next(1, &pMediaType, NULL); DeleteMediaType(pMediaType), pMediaType = NULL) \
{ \
-
+
#define EndEnumMediaTypes(pMediaType) } if(pMediaType) DeleteMediaType(pMediaType); }}
#define BeginEnumSysDev(clsid, pMoniker) \
@@ -191,7 +195,7 @@ public:
{ \
for(CComPtr<IMoniker> pMoniker; pClassEnum4$##clsid->Next(1, &pMoniker, 0) == S_OK; pMoniker = NULL) \
{ \
-
+
#define EndEnumSysDev }}}
#define QI(i) (riid == __uuidof(i)) ? GetInterface((i*)this, ppv) :
@@ -210,7 +214,9 @@ static CUnknown* WINAPI CreateInstance(LPUNKNOWN lpunk, HRESULT* phr)
{
*phr = S_OK;
CUnknown* punk = DNew T(lpunk, phr);
- if(punk == NULL) *phr = E_OUTOFMEMORY;
+ if(punk == NULL) {
+ *phr = E_OUTOFMEMORY;
+ }
return punk;
}
@@ -220,12 +226,15 @@ static CUnknown* WINAPI CreateInstance(LPUNKNOWN lpunk, HRESULT* phr)
inline int LNKO(int a, int b)
{
- if(a == 0 || b == 0)
+ if(a == 0 || b == 0) {
return(1);
- while(a != b)
- {
- if(a < b) b -= a;
- else if(a > b) a -= b;
+ }
+ 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 b8910de0b..175c55f87 100644
--- a/src/DSUtil/FontInstaller.cpp
+++ b/src/DSUtil/FontInstaller.cpp
@@ -3,16 +3,14 @@
CFontInstaller::CFontInstaller()
{
- if(HMODULE hGdi = GetModuleHandle(_T("gdi32.dll")))
- {
+ 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, "AddFontResourceExA");
pRemoveFontMemResourceEx = (BOOL (WINAPI *)(HANDLE))GetProcAddress(hGdi, "RemoveFontMemResourceEx");
pRemoveFontResourceEx = (BOOL (WINAPI *)(LPCTSTR,DWORD,PVOID))GetProcAddress(hGdi, "RemoveFontResourceExA");
}
- if(HMODULE hGdi = GetModuleHandle(_T("kernel32.dll")))
- {
+ if(HMODULE hGdi = GetModuleHandle(_T("kernel32.dll"))) {
pMoveFileEx = (BOOL (WINAPI *)(LPCTSTR, LPCTSTR, DWORD))GetProcAddress(hGdi, "MoveFileExA");
}
}
@@ -34,22 +32,22 @@ bool CFontInstaller::InstallFont(const void* pData, UINT len)
void CFontInstaller::UninstallFonts()
{
- if(pRemoveFontMemResourceEx)
- {
+ if(pRemoveFontMemResourceEx) {
POSITION pos = m_fonts.GetHeadPosition();
- while(pos) pRemoveFontMemResourceEx(m_fonts.GetNext(pos));
+ while(pos) {
+ pRemoveFontMemResourceEx(m_fonts.GetNext(pos));
+ }
m_fonts.RemoveAll();
}
- if(pRemoveFontResourceEx)
- {
+ if(pRemoveFontResourceEx) {
POSITION pos = m_files.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CString fn = m_files.GetNext(pos);
pRemoveFontResourceEx(fn, FR_PRIVATE, 0);
- if(!DeleteFile(fn) && pMoveFileEx)
+ if(!DeleteFile(fn) && pMoveFileEx) {
pMoveFileEx(fn, NULL, MOVEFILE_DELAY_UNTIL_REBOOT);
+ }
}
m_files.RemoveAll();
@@ -58,32 +56,35 @@ void CFontInstaller::UninstallFonts()
bool CFontInstaller::InstallFontMemory(const void* pData, UINT len)
{
- if(!pAddFontMemResourceEx)
+ if(!pAddFontMemResourceEx) {
return false;
+ }
DWORD nFonts = 0;
HANDLE hFont = pAddFontMemResourceEx((PVOID)pData, len, NULL, &nFonts);
- if(hFont && nFonts > 0) m_fonts.AddTail(hFont);
+ if(hFont && nFonts > 0) {
+ m_fonts.AddTail(hFont);
+ }
return hFont && nFonts > 0;
}
bool CFontInstaller::InstallFontFile(const void* pData, UINT len)
{
- if(!pAddFontResourceEx)
+ 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))
+ if(!GetTempPath(MAX_PATH, path) || !GetTempFileName(path, _T("g_font"), 0, fn)) {
return false;
+ }
- if(f.Open(fn, CFile::modeWrite))
- {
+ if(f.Open(fn, CFile::modeWrite)) {
f.Write(pData, len);
f.Close();
- if(pAddFontResourceEx(fn, FR_PRIVATE, 0) > 0)
- {
+ if(pAddFontResourceEx(fn, FR_PRIVATE, 0) > 0) {
m_files.AddTail(fn);
return true;
}
diff --git a/src/DSUtil/GolombBuffer.cpp b/src/DSUtil/GolombBuffer.cpp
index 4e4a15639..4fd1a4a52 100644
--- a/src/DSUtil/GolombBuffer.cpp
+++ b/src/DSUtil/GolombBuffer.cpp
@@ -35,13 +35,14 @@ CGolombBuffer::CGolombBuffer(BYTE* pBuffer, int nSize)
UINT64 CGolombBuffer::BitRead(int nBits, bool fPeek)
{
-// ASSERT(nBits >= 0 && nBits <= 64);
+ // ASSERT(nBits >= 0 && nBits <= 64);
- while(m_bitlen < nBits)
- {
+ 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;
@@ -51,8 +52,7 @@ UINT64 CGolombBuffer::BitRead(int nBits, bool fPeek)
UINT64 ret = (m_bitbuff >> bitlen) & ((1ui64 << nBits) - 1);
- if(!fPeek)
- {
+ if(!fPeek) {
m_bitbuff &= ((1ui64 << bitlen) - 1);
m_bitlen = bitlen;
}
@@ -64,7 +64,9 @@ UINT64 CGolombBuffer::BitRead(int nBits, bool fPeek)
UINT64 CGolombBuffer::UExpGolombRead()
{
int n = -1;
- for(BYTE b = 0; !b; n++) b = (BYTE)BitRead(1);
+ for(BYTE b = 0; !b; n++) {
+ b = (BYTE)BitRead(1);
+ }
return (1ui64 << n) - 1 + BitRead(n);
}
diff --git a/src/DSUtil/H264Nalu.cpp b/src/DSUtil/H264Nalu.cpp
index 67df1a20c..f39b32485 100644
--- a/src/DSUtil/H264Nalu.cpp
+++ b/src/DSUtil/H264Nalu.cpp
@@ -39,18 +39,15 @@ bool CH264Nalu::MoveToNextStartcode()
{
int nBuffEnd = (m_nNextRTP > 0) ? min (m_nNextRTP, m_nSize-4) : m_nSize-4;
- for (int i=m_nCurPos; i<nBuffEnd; i++)
- {
- if ((*((DWORD*)(m_pBuffer+i)) & 0x00FFFFFF) == 0x00010000)
- {
+ for (int i=m_nCurPos; i<nBuffEnd; i++) {
+ if ((*((DWORD*)(m_pBuffer+i)) & 0x00FFFFFF) == 0x00010000) {
// Find next AnnexB Nal
m_nCurPos = i;
return true;
}
}
- if ((m_nNALSize != 0) && (m_nNextRTP < m_nSize))
- {
+ if ((m_nNALSize != 0) && (m_nNextRTP < m_nSize)) {
m_nCurPos = m_nNextRTP;
return true;
}
@@ -62,26 +59,25 @@ bool CH264Nalu::MoveToNextStartcode()
bool CH264Nalu::ReadNext()
{
- if (m_nCurPos >= m_nSize) return false;
+ if (m_nCurPos >= m_nSize) {
+ return false;
+ }
- if ((m_nNALSize != 0) && (m_nCurPos == m_nNextRTP))
- {
+ 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;
int nTemp = 0;
- for (int i=0; i<m_nNALSize; i++)
- {
+ for (int i=0; i<m_nNALSize; i++) {
nTemp = (nTemp << 8) + m_pBuffer[m_nCurPos++];
}
m_nNextRTP += nTemp + m_nNALSize;
MoveToNextStartcode();
- }
- else
- {
+ } else {
// Remove trailing bits
- while (m_pBuffer[m_nCurPos]==0x00 && ((*((DWORD*)(m_pBuffer+m_nCurPos)) & 0x00FFFFFF) != 0x00010000))
+ 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;
diff --git a/src/DSUtil/H264Nalu.h b/src/DSUtil/H264Nalu.h
index 30655b701..6f3a67f5e 100644
--- a/src/DSUtil/H264Nalu.h
+++ b/src/DSUtil/H264Nalu.h
@@ -23,8 +23,7 @@
#pragma once
-typedef enum
-{
+typedef enum {
NALU_TYPE_SLICE = 1,
NALU_TYPE_DPA = 2,
NALU_TYPE_DPB = 3,
@@ -60,39 +59,31 @@ private :
bool MoveToNextStartcode();
public :
- NALU_TYPE GetType() const
- {
+ NALU_TYPE GetType() const {
return nal_unit_type;
};
- bool IsRefFrame() const
- {
+ bool IsRefFrame() const {
return (nal_reference_idc != 0);
};
- int GetDataLength() const
- {
+ int GetDataLength() const {
return m_nCurPos - m_nNALDataPos;
};
- BYTE* GetDataBuffer()
- {
+ BYTE* GetDataBuffer() {
return m_pBuffer + m_nNALDataPos;
};
- int GetRoundedDataLength() const
- {
+ int GetRoundedDataLength() const {
int nSize = m_nCurPos - m_nNALDataPos;
return nSize + 128 - (nSize %128);
}
- int GetLength() const
- {
+ int GetLength() const {
return m_nCurPos - m_nNALStartPos;
};
- BYTE* GetNALBuffer()
- {
+ BYTE* GetNALBuffer() {
return m_pBuffer + m_nNALStartPos;
};
- bool IsEOF() const
- {
+ bool IsEOF() const {
return m_nCurPos >= m_nSize;
};
diff --git a/src/DSUtil/HdmvClipInfo.cpp b/src/DSUtil/HdmvClipInfo.cpp
index 1cbe6fb16..b10b3a2ba 100644
--- a/src/DSUtil/HdmvClipInfo.cpp
+++ b/src/DSUtil/HdmvClipInfo.cpp
@@ -39,8 +39,7 @@ CHdmvClipInfo::~CHdmvClipInfo()
HRESULT CHdmvClipInfo::CloseFile(HRESULT hr)
{
- if (m_hFile != INVALID_HANDLE_VALUE)
- {
+ if (m_hFile != INVALID_HANDLE_VALUE) {
CloseHandle(m_hFile);
m_hFile = INVALID_HANDLE_VALUE;
}
@@ -85,15 +84,13 @@ HRESULT CHdmvClipInfo::ReadProgramInfo()
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++)
- {
+ 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++)
- {
+ 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
@@ -102,62 +99,57 @@ HRESULT CHdmvClipInfo::ReadProgramInfo()
dwPos += ReadByte(); // 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 :
+ 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++;
@@ -176,13 +168,16 @@ HRESULT CHdmvClipInfo::ReadInfo(LPCTSTR strFile)
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)
- {
+ if(m_hFile != INVALID_HANDLE_VALUE) {
ReadBuffer(Buff, 4);
- if (memcmp (Buff, "HDMV", 4)) return CloseFile(VFW_E_INVALID_FILE_FORMAT);
+ 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);
+ 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();
@@ -200,10 +195,10 @@ HRESULT CHdmvClipInfo::ReadInfo(LPCTSTR strFile)
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)
+ for (size_t i=0; i<nStreams; i++) {
+ if (m_Streams[i].m_PID == wPID) {
return &m_Streams[i];
+ }
}
return NULL;
@@ -211,46 +206,45 @@ CHdmvClipInfo::Stream* CHdmvClipInfo::FindStream(SHORT wPID)
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");
}
}
@@ -270,13 +264,16 @@ HRESULT CHdmvClipInfo::ReadPlaylist(CString strPlaylistFile, REFERENCE_TIME& rtD
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)
- {
+ if(m_hFile != INVALID_HANDLE_VALUE) {
ReadBuffer(Buff, 4);
- if (memcmp (Buff, "MPLS", 4)) return CloseFile(VFW_E_INVALID_FILE_FORMAT);
+ 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);
+ if ((memcmp (Buff, "0200", 4)!=0) && (memcmp (Buff, "0100", 4)!=0)) {
+ return CloseFile(VFW_E_INVALID_FILE_FORMAT);
+ }
DWORD dwPos;
DWORD dwTemp;
@@ -291,8 +288,7 @@ HRESULT CHdmvClipInfo::ReadPlaylist(CString strPlaylistFile, REFERENCE_TIME& rtD
ReadShort();
dwPos += 10;
- for (size_t i=0; i<nPlaylistItems; i++)
- {
+ for (size_t i=0; i<nPlaylistItems; i++) {
PlaylistItem Item;
SetFilePointer(m_hFile, dwPos, NULL, FILE_BEGIN);
dwPos = dwPos + ReadShort() + 2;
@@ -300,7 +296,9 @@ HRESULT CHdmvClipInfo::ReadPlaylist(CString strPlaylistFile, REFERENCE_TIME& rtD
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);
+ if (memcmp (Buff, "M2TS", 4)) {
+ return CloseFile(VFW_E_INVALID_FILE_FORMAT);
+ }
ReadBuffer(Buff, 3);
dwTemp = ReadDword();
@@ -311,8 +309,9 @@ HRESULT CHdmvClipInfo::ReadPlaylist(CString strPlaylistFile, REFERENCE_TIME& rtD
rtDuration += (Item.m_rtOut - Item.m_rtIn);
- if (Playlist.Find(Item) != NULL)
+ 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));
@@ -342,30 +341,28 @@ HRESULT CHdmvClipInfo::FindMainMovie(LPCTSTR strFolder, CString& strPlaylistFile
strFilter.Format (_T("%sPLAYLIST\\*.mpls"), strPath);
HANDLE hFind = FindFirstFile(strFilter, &fd);
- if(hFind != INVALID_HANDLE_VALUE)
- {
+ if(hFind != INVALID_HANDLE_VALUE) {
REFERENCE_TIME rtMax = 0;
REFERENCE_TIME rtCurrent;
CString strCurrentPlaylist;
- do
- {
+ 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 && rtCurrent > rtMax)
- {
+ if (ReadPlaylist(strCurrentPlaylist, rtCurrent, Playlist) == S_OK && rtCurrent > rtMax) {
rtMax = rtCurrent;
strPlaylistFile = strCurrentPlaylist;
MainPlaylist.RemoveAll();
POSITION pos = Playlist.GetHeadPosition();
- while(pos) MainPlaylist.AddTail(Playlist.GetNext(pos));
+ while(pos) {
+ MainPlaylist.AddTail(Playlist.GetNext(pos));
+ }
hr = S_OK;
}
- }
- while(FindNextFile(hFind, &fd));
+ } while(FindNextFile(hFind, &fd));
FindClose(hFind);
}
diff --git a/src/DSUtil/HdmvClipInfo.h b/src/DSUtil/HdmvClipInfo.h
index a5677c464..269a382df 100644
--- a/src/DSUtil/HdmvClipInfo.h
+++ b/src/DSUtil/HdmvClipInfo.h
@@ -24,8 +24,7 @@
#include "Mpeg2Def.h"
-enum BDVM_VideoFormat
-{
+enum BDVM_VideoFormat {
BDVM_VideoFormat_Unknown = 0,
BDVM_VideoFormat_480i = 1,
BDVM_VideoFormat_576i = 2,
@@ -36,8 +35,7 @@ enum BDVM_VideoFormat
BDVM_VideoFormat_576p = 7,
};
-enum BDVM_FrameRate
-{
+enum BDVM_FrameRate {
BDVM_FrameRate_Unknown = 0,
BDVM_FrameRate_23_976 = 1,
BDVM_FrameRate_24 = 2,
@@ -47,16 +45,14 @@ enum BDVM_FrameRate
BDVM_FrameRate_59_94 = 7
};
-enum BDVM_AspectRatio
-{
+enum BDVM_AspectRatio {
BDVM_AspectRatio_Unknown = 0,
BDVM_AspectRatio_4_3 = 2,
BDVM_AspectRatio_16_9 = 3,
BDVM_AspectRatio_2_21 = 4
};
-enum BDVM_ChannelLayout
-{
+enum BDVM_ChannelLayout {
BDVM_ChannelLayout_Unknown = 0,
BDVM_ChannelLayout_MONO = 1,
BDVM_ChannelLayout_STEREO = 3,
@@ -64,8 +60,7 @@ enum BDVM_ChannelLayout
BDVM_ChannelLayout_COMBO = 12
};
-enum BDVM_SampleRate
-{
+enum BDVM_SampleRate {
BDVM_SampleRate_Unknown = 0,
BDVM_SampleRate_48 = 1,
BDVM_SampleRate_96 = 4,
@@ -89,10 +84,8 @@ class CHdmvClipInfo
{
public:
- struct Stream
- {
- Stream()
- {
+ struct Stream {
+ Stream() {
memset(this, 0, sizeof(*this));
}
SHORT m_PID;
@@ -111,19 +104,16 @@ public:
LPCTSTR Format();
};
- struct PlaylistItem
- {
+ struct PlaylistItem {
CString m_strFileName;
REFERENCE_TIME m_rtIn;
REFERENCE_TIME m_rtOut;
- REFERENCE_TIME Duration() const
- {
+ REFERENCE_TIME Duration() const {
return m_rtOut - m_rtIn;
}
- bool operator == (const PlaylistItem& pi) const
- {
+ bool operator == (const PlaylistItem& pi) const {
return pi.m_strFileName == m_strFileName;
}
};
@@ -133,16 +123,13 @@ public:
HRESULT ReadInfo(LPCTSTR strFile);
Stream* FindStream(SHORT wPID);
- bool IsHdmv() const
- {
+ bool IsHdmv() const {
return m_bIsHdmv;
};
- size_t GetStreamNumber()
- {
+ size_t GetStreamNumber() {
return m_Streams.GetCount();
};
- Stream* GetStreamByIndex(size_t nIndex)
- {
+ Stream* GetStreamByIndex(size_t nIndex) {
return (nIndex < m_Streams.GetCount()) ? &m_Streams[nIndex] : NULL;
};
diff --git a/src/DSUtil/MediaTypeEx.cpp b/src/DSUtil/MediaTypeEx.cpp
index 95654d4ab..4a7e01d66 100644
--- a/src/DSUtil/MediaTypeEx.cpp
+++ b/src/DSUtil/MediaTypeEx.cpp
@@ -7,8 +7,7 @@
#include <moreuuids.h>
#pragma pack(push, 1)
-typedef struct
-{
+typedef struct {
WAVEFORMATEX Format;
BYTE bBigEndian;
BYTE bsid;
@@ -28,21 +27,15 @@ CString CMediaTypeEx::ToString(IPin* pPin)
// TODO
- if(majortype == MEDIATYPE_DVD_ENCRYPTED_PACK)
- {
+ if(majortype == MEDIATYPE_DVD_ENCRYPTED_PACK) {
packing = _T("Encrypted MPEG2 Pack");
- }
- else if(majortype == MEDIATYPE_MPEG2_PACK)
- {
+ } else if(majortype == MEDIATYPE_MPEG2_PACK) {
packing = _T("MPEG2 Pack");
- }
- else if(majortype == MEDIATYPE_MPEG2_PES)
- {
+ } else if(majortype == MEDIATYPE_MPEG2_PES) {
packing = _T("MPEG2 PES");
}
- if(majortype == MEDIATYPE_Video)
- {
+ if(majortype == MEDIATYPE_Video) {
type = _T("Video");
BITMAPINFOHEADER bih;
@@ -51,127 +44,149 @@ CString CMediaTypeEx::ToString(IPin* pPin)
int w, h, arx, ary;
bool fDim = ExtractDim(this, w, h, arx, ary);
- if(fBIH && bih.biCompression)
- {
+ if(fBIH && bih.biCompression) {
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(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)
- {
+ if(fDim) {
dim.Format(_T("%dx%d"), w, h);
- if(w*ary != h*arx) dim.Format(_T("%s (%d:%d)"), CString(dim), arx, ary);
+ if(w*ary != h*arx) {
+ dim.Format(_T("%s (%d:%d)"), CString(dim), arx, ary);
+ }
}
- if(formattype == FORMAT_VideoInfo || formattype == FORMAT_MPEGVideo)
- {
+ if(formattype == FORMAT_VideoInfo || formattype == FORMAT_MPEGVideo) {
VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pbFormat;
- if(vih->AvgTimePerFrame) rate.Format(_T("%0.2ffps "), 10000000.0f / vih->AvgTimePerFrame);
- if(vih->dwBitRate) rate.Format(_T("%s%dkbps"), CString(rate), vih->dwBitRate/1000);
- }
- else if(formattype == FORMAT_VideoInfo2 || formattype == FORMAT_MPEG2_VIDEO || formattype == FORMAT_DiracVideoInfo)
- {
+ if(vih->AvgTimePerFrame) {
+ rate.Format(_T("%0.2ffps "), 10000000.0f / vih->AvgTimePerFrame);
+ }
+ if(vih->dwBitRate) {
+ rate.Format(_T("%s%dkbps"), CString(rate), 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.2ffps "), 10000000.0f / vih->AvgTimePerFrame);
- if(vih->dwBitRate) rate.Format(_T("%s%dkbps"), CString(rate), vih->dwBitRate/1000);
+ if(vih->AvgTimePerFrame) {
+ rate.Format(_T("%0.2ffps "), 10000000.0f / vih->AvgTimePerFrame);
+ }
+ if(vih->dwBitRate) {
+ rate.Format(_T("%s%dkbps"), CString(rate), vih->dwBitRate/1000);
+ }
}
rate.Trim();
- if(subtype == MEDIASUBTYPE_DVD_SUBPICTURE)
- {
+ if(subtype == MEDIASUBTYPE_DVD_SUBPICTURE) {
type = _T("Subtitle");
codec = _T("DVD Subpicture");
}
- }
- else if(majortype == MEDIATYPE_Audio)
- {
+ } else if(majortype == MEDIATYPE_Audio) {
type = _T("Audio");
- if(formattype == FORMAT_WaveFormatEx)
- {
+ 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)
- {
+ || subtype != GUID_NULL) {
codec = GetAudioCodecName(subtype, wfe->wFormatTag);
dim.Format(_T("%dHz"), wfe->nSamplesPerSec);
- if(wfe->nChannels == 1) dim.Format(_T("%s mono"), CString(dim));
- else if(wfe->nChannels == 2) dim.Format(_T("%s stereo"), CString(dim));
- else dim.Format(_T("%s %dch"), CString(dim), wfe->nChannels);
- if(wfe->nAvgBytesPerSec) rate.Format(_T("%dkbps"), wfe->nAvgBytesPerSec*8/1000);
+ if(wfe->nChannels == 1) {
+ dim.Format(_T("%s mono"), CString(dim));
+ } else if(wfe->nChannels == 2) {
+ dim.Format(_T("%s stereo"), CString(dim));
+ } else {
+ dim.Format(_T("%s %dch"), CString(dim), wfe->nChannels);
+ }
+ if(wfe->nAvgBytesPerSec) {
+ rate.Format(_T("%dkbps"), wfe->nAvgBytesPerSec*8/1000);
+ }
}
- }
- else if(formattype == FORMAT_VorbisFormat)
- {
+ } else if(formattype == FORMAT_VorbisFormat) {
VORBISFORMAT* vf = (VORBISFORMAT*)Format();
codec = GetAudioCodecName(subtype, 0);
dim.Format(_T("%dHz"), vf->nSamplesPerSec);
- if(vf->nChannels == 1) dim.Format(_T("%s mono"), CString(dim));
- else if(vf->nChannels == 2) dim.Format(_T("%s stereo"), CString(dim));
- else dim.Format(_T("%s %dch"), CString(dim), vf->nChannels);
- if(vf->nAvgBitsPerSec) rate.Format(_T("%dkbps"), vf->nAvgBitsPerSec/1000);
- }
- else if(formattype == FORMAT_VorbisFormat2)
- {
+ if(vf->nChannels == 1) {
+ dim.Format(_T("%s mono"), CString(dim));
+ } else if(vf->nChannels == 2) {
+ dim.Format(_T("%s stereo"), CString(dim));
+ } else {
+ dim.Format(_T("%s %dch"), CString(dim), 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.Format(_T("%s mono"), CString(dim));
- else if(vf->Channels == 2) dim.Format(_T("%s stereo"), CString(dim));
- else dim.Format(_T("%s %dch"), CString(dim), vf->Channels);
+ if(vf->Channels == 1) {
+ dim.Format(_T("%s mono"), CString(dim));
+ } else if(vf->Channels == 2) {
+ dim.Format(_T("%s stereo"), CString(dim));
+ } else {
+ dim.Format(_T("%s %dch"), CString(dim), vf->Channels);
+ }
}
- }
- else if(majortype == MEDIATYPE_Text)
- {
+ } else if(majortype == MEDIATYPE_Text) {
type = _T("Text");
- }
- else if(majortype == MEDIATYPE_Subtitle)
- {
+ } else if(majortype == MEDIATYPE_Subtitle) {
type = _T("Subtitle");
codec = GetSubtitleCodecName(subtype);
- }
- else
- {
+ } else {
type = _T("Unknown");
}
- if(CComQIPtr<IMediaSeeking> pMS = pPin)
- {
+ if(CComQIPtr<IMediaSeeking> pMS = pPin) {
REFERENCE_TIME rtDur = 0;
- if(SUCCEEDED(pMS->GetDuration(&rtDur)) && rtDur)
- {
+ 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);
+ 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(" ");
+ 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;
+ if(!str.IsEmpty()) {
+ str = type + _T(": ") + str;
+ } else {
+ str = type;
+ }
return str;
}
@@ -182,8 +197,7 @@ CString CMediaTypeEx::GetVideoCodecName(const GUID& subtype, DWORD biCompression
static CAtlMap<DWORD, CString> names;
- if(names.IsEmpty())
- {
+ if(names.IsEmpty()) {
names['WMV1'] = _T("Windows Media Video 7");
names['WMV2'] = _T("Windows Media Video 8");
names['WMV3'] = _T("Windows Media Video 9");
@@ -211,20 +225,24 @@ CString CMediaTypeEx::GetVideoCodecName(const GUID& subtype, DWORD biCompression
// names[''] = _T("");
}
- if(biCompression)
- {
+ if(biCompression) {
BYTE* b = (BYTE*)&biCompression;
for(ptrdiff_t i = 0; i < 4; i++)
- if(b[i] >= 'a' && b[i] <= 'z')
+ 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");
+ 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(biCompression < 256) {
+ str.Format(_T("%d"), biCompression);
+ } else {
+ str.Format(_T("%4.4hs"), &biCompression);
+ }
}
}
@@ -237,8 +255,7 @@ CString CMediaTypeEx::GetAudioCodecName(const GUID& subtype, WORD wFormatTag)
static CAtlMap<WORD, CString> names;
- if(names.IsEmpty())
- {
+ 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");
@@ -306,22 +323,32 @@ CString CMediaTypeEx::GetAudioCodecName(const GUID& subtype, WORD wFormatTag)
// 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");
+ 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 == ) str = _T("");
- else str.Format(_T("0x%04x"), wFormatTag);
+ 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)");
+ if(wFormatTag == WAVE_FORMAT_PCM) {
+ if(subtype == MEDIASUBTYPE_DOLBY_AC3) {
+ str += _T(" (AC3)");
+ } else if(subtype == MEDIASUBTYPE_DTS) {
+ str += _T(" (DTS)");
+ }
}
return str;
@@ -333,8 +360,7 @@ CString CMediaTypeEx::GetSubtitleCodecName(const GUID& subtype)
static CAtlMap<GUID, CString> names;
- if(names.IsEmpty())
- {
+ if(names.IsEmpty()) {
names[MEDIASUBTYPE_UTF8] = _T("UTF-8");
names[MEDIASUBTYPE_SSA] = _T("SubStation Alpha");
names[MEDIASUBTYPE_ASS] = _T("Advanced SubStation Alpha");
@@ -345,8 +371,7 @@ CString CMediaTypeEx::GetSubtitleCodecName(const GUID& subtype)
// names[''] = _T("");
}
- if(names.Lookup(subtype, str))
- {
+ if(names.Lookup(subtype, str)) {
}
@@ -386,8 +411,7 @@ void CMediaTypeEx::Dump(CAtlList<CString>& sl)
sl.AddTail(_T(""));
if(formattype == FORMAT_VideoInfo || formattype == FORMAT_VideoInfo2
- || formattype == FORMAT_MPEGVideo || formattype == FORMAT_MPEG2_VIDEO)
- {
+ || formattype == FORMAT_MPEGVideo || formattype == FORMAT_MPEG2_VIDEO) {
fmtsize =
formattype == FORMAT_VideoInfo ? sizeof(VIDEOINFOHEADER) :
formattype == FORMAT_VideoInfo2 ? sizeof(VIDEOINFOHEADER2) :
@@ -412,8 +436,7 @@ void CMediaTypeEx::Dump(CAtlList<CString>& sl)
sl.AddTail(_T(""));
- if(formattype == FORMAT_VideoInfo2 || formattype == FORMAT_MPEG2_VIDEO)
- {
+ if(formattype == FORMAT_VideoInfo2 || formattype == FORMAT_MPEG2_VIDEO) {
VIDEOINFOHEADER2& vih = *(VIDEOINFOHEADER2*)pbFormat;
bih = &vih.bmiHeader;
@@ -434,8 +457,7 @@ void CMediaTypeEx::Dump(CAtlList<CString>& sl)
sl.AddTail(_T(""));
}
- if(formattype == FORMAT_MPEGVideo)
- {
+ if(formattype == FORMAT_MPEGVideo) {
MPEG1VIDEOINFO& mvih = *(MPEG1VIDEOINFO*)pbFormat;
sl.AddTail(_T("MPEG1VIDEOINFO:"));
@@ -445,9 +467,7 @@ void CMediaTypeEx::Dump(CAtlList<CString>& sl)
sl.AddTail(str);
sl.AddTail(_T(""));
- }
- else if(formattype == FORMAT_MPEG2_VIDEO)
- {
+ } else if(formattype == FORMAT_MPEG2_VIDEO) {
MPEG2VIDEOINFO& mvih = *(MPEG2VIDEOINFO*)pbFormat;
sl.AddTail(_T("MPEG2VIDEOINFO:"));
@@ -476,8 +496,11 @@ void CMediaTypeEx::Dump(CAtlList<CString>& sl)
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);
+ 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);
@@ -491,9 +514,7 @@ void CMediaTypeEx::Dump(CAtlList<CString>& sl)
sl.AddTail(str);
sl.AddTail(_T(""));
- }
- else if(formattype == FORMAT_WaveFormatEx)
- {
+ } else if(formattype == FORMAT_WaveFormatEx) {
fmtsize = sizeof(WAVEFORMATEX);
WAVEFORMATEX& wfe = *(WAVEFORMATEX*)pbFormat;
@@ -516,17 +537,18 @@ void CMediaTypeEx::Dump(CAtlList<CString>& sl)
sl.AddTail(_T(""));
- if(wfe.wFormatTag != WAVE_FORMAT_PCM && wfe.cbSize > 0)
- {
- if(wfe.wFormatTag == WAVE_FORMAT_EXTENSIBLE && wfe.cbSize == sizeof(WAVEFORMATEXTENSIBLE)-sizeof(WAVEFORMATEX))
- {
+ if(wfe.wFormatTag != WAVE_FORMAT_PCM && wfe.cbSize > 0) {
+ 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);
+ 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);
@@ -534,9 +556,7 @@ void CMediaTypeEx::Dump(CAtlList<CString>& sl)
sl.AddTail(str);
sl.AddTail(_T(""));
- }
- else if(wfe.wFormatTag == WAVE_FORMAT_DOLBY_AC3 && wfe.cbSize == sizeof(DOLBYAC3WAVEFORMAT)-sizeof(WAVEFORMATEX))
- {
+ } else if(wfe.wFormatTag == WAVE_FORMAT_DOLBY_AC3 && wfe.cbSize == sizeof(DOLBYAC3WAVEFORMAT)-sizeof(WAVEFORMATEX)) {
fmtsize = sizeof(DOLBYAC3WAVEFORMAT);
DOLBYAC3WAVEFORMAT& wfe = *(DOLBYAC3WAVEFORMAT*)pbFormat;
@@ -556,9 +576,7 @@ void CMediaTypeEx::Dump(CAtlList<CString>& sl)
sl.AddTail(_T(""));
}
}
- }
- else if(formattype == FORMAT_VorbisFormat)
- {
+ } else if(formattype == FORMAT_VorbisFormat) {
fmtsize = sizeof(VORBISFORMAT);
VORBISFORMAT& vf = *(VORBISFORMAT*)pbFormat;
@@ -578,9 +596,7 @@ void CMediaTypeEx::Dump(CAtlList<CString>& sl)
sl.AddTail(str);
sl.AddTail(_T(""));
- }
- else if(formattype == FORMAT_VorbisFormat2)
- {
+ } else if(formattype == FORMAT_VorbisFormat2) {
fmtsize = sizeof(VORBISFORMAT2);
VORBISFORMAT2& vf = *(VORBISFORMAT2*)pbFormat;
@@ -596,9 +612,7 @@ void CMediaTypeEx::Dump(CAtlList<CString>& sl)
sl.AddTail(str);
sl.AddTail(_T(""));
- }
- else if(formattype == FORMAT_SubtitleInfo)
- {
+ } else if(formattype == FORMAT_SubtitleInfo) {
fmtsize = sizeof(SUBTITLEINFO);
SUBTITLEINFO& si = *(SUBTITLEINFO*)pbFormat;
@@ -614,30 +628,25 @@ void CMediaTypeEx::Dump(CAtlList<CString>& sl)
sl.AddTail(_T(""));
}
- if(cbFormat > 0)
- {
+ if(cbFormat > 0) {
sl.AddTail(_T("pbFormat:"));
- for(ptrdiff_t i = 0, j = (cbFormat + 15) & ~15; i < j; i += 16)
- {
+ 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++)
- {
+ 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++)
- {
+ 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++)
- {
+ 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 : '.');
diff --git a/src/DSUtil/MediaTypes.cpp b/src/DSUtil/MediaTypes.cpp
index b8cf59760..608087648 100644
--- a/src/DSUtil/MediaTypes.cpp
+++ b/src/DSUtil/MediaTypes.cpp
@@ -33,8 +33,7 @@
#define VIH2_BITFIELDS (sizeof(VIDEOINFOHEADER2)+3*sizeof(RGBQUAD))
#define BIH_SIZE (sizeof(BITMAPINFOHEADER))
-VIH vihs[] =
-{
+VIH vihs[] = {
// YUY2
{
{
@@ -177,8 +176,7 @@ VIH vihs[] =
},
};
-VIH2 vih2s[] =
-{
+VIH2 vih2s[] = {
// YUY2
{
{
@@ -326,51 +324,56 @@ 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
+ 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
+ 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);
- if(mt.formattype == FORMAT_VideoInfo)
- {
+ if(mt.formattype == FORMAT_VideoInfo) {
VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)mt.pbFormat;
- for(ptrdiff_t i = 0; i < VIHSIZE; i++)
- {
+ for(ptrdiff_t i = 0; i < VIHSIZE; i++) {
if(mt.subtype == *vihs[i].subtype
- && vih->bmiHeader.biCompression == vihs[i].vih.bmiHeader.biCompression)
- {
+ && 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)
- {
+ } else if(mt.formattype == FORMAT_VideoInfo2) {
VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*)mt.pbFormat;
- for(ptrdiff_t i = 0; i < VIHSIZE; i++)
- {
+ for(ptrdiff_t i = 0; i < VIHSIZE; i++) {
if(mt.subtype == *vih2s[i].subtype
- && vih2->bmiHeader.biCompression == vih2s[i].vih.bmiHeader.biCompression)
- {
+ && 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));
diff --git a/src/DSUtil/MediaTypes.h b/src/DSUtil/MediaTypes.h
index e18e5eca9..4a97d86ac 100644
--- a/src/DSUtil/MediaTypes.h
+++ b/src/DSUtil/MediaTypes.h
@@ -24,15 +24,13 @@
#pragma once
#pragma pack(1)
-struct VIH
-{
+struct VIH {
VIDEOINFOHEADER vih;
UINT mask[3];
int size;
const GUID* subtype;
};
-struct VIH2
-{
+struct VIH2 {
VIDEOINFOHEADER2 vih;
UINT mask[3];
int size;
diff --git a/src/DSUtil/Mpeg2Def.h b/src/DSUtil/Mpeg2Def.h
index b968e1710..cdb855872 100644
--- a/src/DSUtil/Mpeg2Def.h
+++ b/src/DSUtil/Mpeg2Def.h
@@ -23,8 +23,7 @@
#pragma once
-enum PES_STREAM_TYPE
-{
+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
@@ -74,8 +73,7 @@ enum PES_STREAM_TYPE
};
-enum MPEG2_PID
-{
+enum MPEG2_PID {
PID_PAT = 0x000, // Program Association Table
PID_CAT = 0x001, // Conditional Access Table
PID_TSDT = 0x002, // Transport Stream Description Table
@@ -92,8 +90,7 @@ enum MPEG2_PID
PID_NULL = 0x1fff // Null packet
};
-enum DVB_SI
-{
+enum DVB_SI {
SI_undef = -1,
SI_PAT = 0x00,
SI_CAT = 0x01,
@@ -115,8 +112,7 @@ enum DVB_SI
};
-enum MPEG2_DESCRIPTOR
-{
+enum MPEG2_DESCRIPTOR {
// http://www.coolstf.com/tsreader/descriptors.html
DT_VIDEO_STREAM = 0x02,
DT_AUDIO_STREAM = 0x03,
diff --git a/src/DSUtil/NullRenderers.cpp b/src/DSUtil/NullRenderers.cpp
index bf27238c5..16542eef9 100644
--- a/src/DSUtil/NullRenderers.cpp
+++ b/src/DSUtil/NullRenderers.cpp
@@ -43,9 +43,9 @@ typedef HRESULT (__stdcall *PTR_DXVA2CreateVideoService)(IDirect3DDevice9* pDD,
class CNullVideoRendererInputPin : public CRendererInputPin,
- public IMFGetService,
- public IDirectXVideoMemoryConfiguration,
- public IMFVideoDisplayControl
+ public IMFGetService,
+ public IDirectXVideoMemoryConfiguration,
+ public IMFVideoDisplayControl
{
public :
CNullVideoRendererInputPin(CBaseRenderer *pRenderer, HRESULT *phr, LPCWSTR Name);
@@ -53,14 +53,12 @@ public :
DECLARE_IUNKNOWN
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- STDMETHODIMP GetAllocator(IMemAllocator **ppAllocator)
- {
+ STDMETHODIMP GetAllocator(IMemAllocator **ppAllocator) {
// Renderer shouldn't manage allocator for DXVA
return E_NOTIMPL;
}
- STDMETHODIMP GetAllocatorRequirements(ALLOCATOR_PROPERTIES* pProps)
- {
+ STDMETHODIMP GetAllocatorRequirements(ALLOCATOR_PROPERTIES* pProps) {
// 1 buffer required
memset (pProps, 0, sizeof(ALLOCATOR_PROPERTIES));
pProps->cbBuffer = 1;
@@ -153,14 +151,12 @@ CNullVideoRendererInputPin::CNullVideoRendererInputPin(CBaseRenderer *pRenderer,
pfDXVA2CreateVideoService = hLib ? (PTR_DXVA2CreateVideoService) GetProcAddress (hLib, "DXVA2CreateVideoService") : NULL;
- if (hLib != NULL)
- {
+ if (hLib != NULL) {
pfDXVA2CreateDirect3DDeviceManager9 (&m_nResetTocken, &m_pD3DDeviceManager);
}
// Initialize Device Manager with DX surface
- if (m_pD3DDev)
- {
+ if (m_pD3DDev) {
HRESULT hr;
hr = m_pD3DDeviceManager->ResetDevice (m_pD3DDev, m_nResetTocken);
hr = m_pD3DDeviceManager->OpenDeviceHandle(&m_hDevice);
@@ -172,8 +168,7 @@ void CNullVideoRendererInputPin::CreateSurface()
{
HRESULT hr;
m_pD3D.Attach(Direct3DCreate9(D3D_SDK_VERSION));
- if(!m_pD3D)
- {
+ if(!m_pD3D) {
m_pD3D.Attach(Direct3DCreate9(D3D9b_SDK_VERSION));
}
@@ -196,9 +191,9 @@ void CNullVideoRendererInputPin::CreateSurface()
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);
+ D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, m_hWnd,
+ D3DCREATE_SOFTWARE_VERTEXPROCESSING|D3DCREATE_MULTITHREADED, //D3DCREATE_MANAGED
+ &pp, &m_pD3DDev);
}
STDMETHODIMP CNullVideoRendererInputPin::NonDelegatingQueryInterface(REFIID riid, void** ppv)
@@ -212,31 +207,20 @@ STDMETHODIMP CNullVideoRendererInputPin::NonDelegatingQueryInterface(REFIID riid
STDMETHODIMP CNullVideoRendererInputPin::GetService(REFGUID guidService, REFIID riid, LPVOID *ppvObject)
{
- if (m_pD3DDeviceManager != NULL && guidService == MR_VIDEO_ACCELERATION_SERVICE)
- {
- if (riid == __uuidof(IDirect3DDeviceManager9))
- {
+ 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) )
- {
+ } else if (riid == __uuidof(IDirectXVideoDecoderService) || riid == __uuidof(IDirectXVideoProcessorService) ) {
return m_pD3DDeviceManager->GetVideoService (m_hDevice, riid, ppvObject);
- }
- else if (riid == __uuidof(IDirectXVideoAccelerationService))
- {
+ } else if (riid == __uuidof(IDirectXVideoAccelerationService)) {
// TODO : to be tested....
return pfDXVA2CreateVideoService(m_pD3DDev, riid, ppvObject);
- }
- else if (riid == __uuidof(IDirectXVideoMemoryConfiguration))
- {
+ } else if (riid == __uuidof(IDirectXVideoMemoryConfiguration)) {
GetInterface ((IDirectXVideoMemoryConfiguration*)this, ppvObject);
return S_OK;
}
- }
- else if (guidService == MR_VIDEO_RENDER_SERVICE)
- {
- if (riid == __uuidof(IMFVideoDisplayControl))
- {
+ } else if (guidService == MR_VIDEO_RENDER_SERVICE) {
+ if (riid == __uuidof(IMFVideoDisplayControl)) {
GetInterface ((IMFVideoDisplayControl*)this, ppvObject);
return S_OK;
}
@@ -255,13 +239,12 @@ STDMETHODIMP CNullVideoRendererInputPin::GetService(REFGUID guidService, REFIID
STDMETHODIMP CNullVideoRendererInputPin::GetAvailableSurfaceTypeByIndex(DWORD dwTypeIndex, DXVA2_SurfaceType *pdwType)
{
- if (dwTypeIndex == 0)
- {
+ if (dwTypeIndex == 0) {
*pdwType = DXVA2_SurfaceType_DecoderRenderTarget;
return S_OK;
- }
- else
+ } else {
return MF_E_NO_MORE_TYPES;
+ }
}
STDMETHODIMP CNullVideoRendererInputPin::SetSurfaceType(DXVA2_SurfaceType dwType)
@@ -301,9 +284,9 @@ CNullVideoRenderer::CNullVideoRenderer(LPUNKNOWN pUnk, HRESULT* phr)
HRESULT CNullVideoRenderer::CheckMediaType(const CMediaType* pmt)
{
return pmt->majortype == MEDIATYPE_Video
- || pmt->subtype == MEDIASUBTYPE_MPEG2_VIDEO
- ? S_OK
- : E_FAIL;
+ || pmt->subtype == MEDIASUBTYPE_MPEG2_VIDEO
+ ? S_OK
+ : E_FAIL;
}
//
@@ -321,39 +304,38 @@ CNullUVideoRenderer::CNullUVideoRenderer(LPUNKNOWN pUnk, HRESULT* phr)
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;
+ && (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)
- {
+ if (pService != NULL) {
CComPtr<IDirect3DSurface9> pSurface;
pService->GetService (MR_BUFFER_SERVICE, __uuidof(IDirect3DSurface9), (void**)&pSurface);
// TODO : render surface...
@@ -375,17 +357,17 @@ CNullAudioRenderer::CNullAudioRenderer(LPUNKNOWN pUnk, HRESULT* 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
- || pmt->subtype == MEDIASUBTYPE_MPEG1Audio
- ? S_OK
- : E_FAIL;
+ || 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
+ || pmt->subtype == MEDIASUBTYPE_MPEG1Audio
+ ? S_OK
+ : E_FAIL;
}
//
@@ -400,14 +382,14 @@ CNullUAudioRenderer::CNullUAudioRenderer(LPUNKNOWN pUnk, HRESULT* 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;
+ && (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;
}
//
@@ -417,13 +399,13 @@ 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;
+ || 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;
}
#pragma warning (disable : 4355)
diff --git a/src/DSUtil/SharedInclude.h b/src/DSUtil/SharedInclude.h
index 6855048ea..c8123efdc 100644
--- a/src/DSUtil/SharedInclude.h
+++ b/src/DSUtil/SharedInclude.h
@@ -14,18 +14,18 @@
#pragma warning(disable:4267)
#ifdef _DEBUG
- #define _CRTDBG_MAP_ALLOC // include Microsoft memory leak detection procedures
+#define _CRTDBG_MAP_ALLOC // include Microsoft memory leak detection procedures
- #if 0
- #include <crtdbg.h>
- #define DNew new(_NORMAL_BLOCK, __FILE__, __LINE__)
- #else
- #define DNew new(__FILE__, __LINE__)
- #endif
+#if 0
+#include <crtdbg.h>
+#define DNew new(_NORMAL_BLOCK, __FILE__, __LINE__)
+#else
+#define DNew new(__FILE__, __LINE__)
+#endif
#else
- #define DNew new
+#define DNew new
#endif
#endif // IncDSUtil_SharedInclude_h
diff --git a/src/DSUtil/text.cpp b/src/DSUtil/text.cpp
index faadaf119..cf953105c 100644
--- a/src/DSUtil/text.cpp
+++ b/src/DSUtil/text.cpp
@@ -70,8 +70,12 @@ CString Implode(CAtlList<CString>& sl, TCHAR sep)
DWORD CharSetToCodePage(DWORD dwCharSet)
{
- if(dwCharSet == CP_UTF8) return CP_UTF8;
- if(dwCharSet == CP_UTF7) return CP_UTF7;
+ 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;
@@ -108,13 +112,15 @@ CStringA UrlEncode(CStringA str, bool fRaw)
{
CStringA urlstr;
- for(size_t i = 0; i < str.GetLength(); i++)
- {
+ for(size_t 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 {
+ 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;
@@ -132,27 +138,29 @@ CStringA UrlDecode(CStringA str, bool fRaw)
CHAR* e = s + str.GetLength();
CHAR* s1 = s;
CHAR* s2 = s;
- while(s1 < e)
- {
+ 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[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;
+ 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;
+ 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
- {
+ } else {
*s2 = *s1 == '+' && !fRaw ? ' ' : *s1;
}
@@ -174,25 +182,32 @@ CString ExtractTag(CString tag, CMapStringToString& attribs, bool& fClosing)
tag.TrimLeft('/');
int i = tag.Find(' ');
- if(i < 0) i = tag.GetLength();
+ if(i < 0) {
+ i = tag.GetLength();
+ }
CString type = tag.Left(i).MakeLower();
tag = tag.Mid(i).Trim();
- while((i = tag.Find('=')) > 0)
- {
+ 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++);
+ 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();
}
- else i = tag.Find(' ');
- if(i < 0) i = tag.GetLength();
CString param = tag.Left(i).Trim();
- if(!param.IsEmpty())
+ if(!param.IsEmpty()) {
attribs[attrib] = param;
+ }
tag = i+1 < tag.GetLength() ? tag.Mid(i+1) : _T("");
}
@@ -202,26 +217,31 @@ CString ExtractTag(CString tag, CMapStringToString& attribs, bool& fClosing)
CAtlList<CString>& MakeLower(CAtlList<CString>& sl)
{
POSITION pos = sl.GetHeadPosition();
- while(pos) sl.GetNext(pos).MakeLower();
+ while(pos) {
+ sl.GetNext(pos).MakeLower();
+ }
return sl;
}
CAtlList<CString>& MakeUpper(CAtlList<CString>& sl)
{
POSITION pos = sl.GetHeadPosition();
- while(pos) sl.GetNext(pos).MakeUpper();
+ while(pos) {
+ sl.GetNext(pos).MakeUpper();
+ }
return sl;
}
CAtlList<CString>& RemoveStrings(CAtlList<CString>& sl, int minlen, int maxlen)
{
POSITION pos = sl.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
POSITION tmp = pos;
CString& str = sl.GetNext(pos);
int len = str.GetLength();
- if(len < minlen || len > maxlen) sl.RemoveAt(tmp);
+ if(len < minlen || len > maxlen) {
+ sl.RemoveAt(tmp);
+ }
}
return sl;
}
diff --git a/src/DSUtil/text.h b/src/DSUtil/text.h
index c9ab75363..ccec847f9 100644
--- a/src/DSUtil/text.h
+++ b/src/DSUtil/text.h
@@ -11,17 +11,13 @@ T Explode(T str, CAtlList<T>& sl, SEP sep, size_t limit = 0)
{
sl.RemoveAll();
- for(ptrdiff_t i = 0, j = 0; ; i = j+1)
- {
+ for(ptrdiff_t i = 0, j = 0; ; i = j+1) {
j = str.Find(sep, i);
- if(j < 0 || sl.GetCount() == limit-1)
- {
+ if(j < 0 || sl.GetCount() == limit-1) {
sl.AddTail(str.Mid(i).Trim());
break;
- }
- else
- {
+ } else {
sl.AddTail(str.Mid(i, j-i).Trim());
}
}
@@ -34,13 +30,15 @@ T ExplodeMin(T str, CAtlList<T>& sl, SEP sep, size_t limit = 0)
{
Explode(str, sl, sep, limit);
POSITION pos = sl.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
POSITION tmp = pos;
- if(sl.GetNext(pos).IsEmpty())
+ if(sl.GetNext(pos).IsEmpty()) {
sl.RemoveAt(tmp);
+ }
+ }
+ if(sl.IsEmpty()) {
+ sl.AddTail(T()); // eh
}
- if(sl.IsEmpty()) sl.AddTail(T()); // eh
return sl.GetHead();
}
@@ -50,10 +48,11 @@ T Implode(CAtlList<T>& sl, SEP sep)
{
T ret;
POSITION pos = sl.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
ret += sl.GetNext(pos);
- if(pos) ret += sep;
+ if(pos) {
+ ret += sep;
+ }
}
return(ret);
}
diff --git a/src/DeCSS/CSSauth.cpp b/src/DeCSS/CSSauth.cpp
index 10aa2135b..1007ed46b 100644
--- a/src/DeCSS/CSSauth.cpp
+++ b/src/DeCSS/CSSauth.cpp
@@ -9,8 +9,9 @@ void CSSkey1(int varient,unsigned char const *challenge,unsigned char *key)
unsigned char scratch[10];
int i;
- for (i = 9; i >= 0; --i)
+ for (i = 9; i >= 0; --i) {
scratch[i] = challenge[perm_challenge[i]];
+ }
CSSengine(varient, scratch, key);
}
@@ -23,13 +24,15 @@ void CSSkey2(int varient,unsigned char const *challenge,unsigned char *key)
0x0a, 0x08, 0x0e, 0x0c, 0x0b, 0x09, 0x0f, 0x0d,
0x1a, 0x18, 0x1e, 0x1c, 0x1b, 0x19, 0x1f, 0x1d,
0x02, 0x00, 0x06, 0x04, 0x03, 0x01, 0x07, 0x05,
- 0x12, 0x10, 0x16, 0x14, 0x13, 0x11, 0x17, 0x15};
+ 0x12, 0x10, 0x16, 0x14, 0x13, 0x11, 0x17, 0x15
+ };
unsigned char scratch[10];
int i;
- for (i = 9; i >= 0; --i)
+ for (i = 9; i >= 0; --i) {
scratch[i] = challenge[perm_challenge[i]];
+ }
CSSengine(perm_varient[varient], scratch, key);
}
@@ -41,13 +44,15 @@ void CSSbuskey(int varient,unsigned char const *challenge,unsigned char *key)
0x12, 0x1a, 0x16, 0x1e, 0x02, 0x0a, 0x06, 0x0e,
0x10, 0x18, 0x14, 0x1c, 0x00, 0x08, 0x04, 0x0c,
0x13, 0x1b, 0x17, 0x1f, 0x03, 0x0b, 0x07, 0x0f,
- 0x11, 0x19, 0x15, 0x1d, 0x01, 0x09, 0x05, 0x0d};
+ 0x11, 0x19, 0x15, 0x1d, 0x01, 0x09, 0x05, 0x0d
+ };
unsigned char scratch[10];
int i;
- for (i = 9; i >= 0; --i)
+ for (i = 9; i >= 0; --i) {
scratch[i] = challenge[perm_challenge[i]];
+ }
CSSengine(perm_varient[varient], scratch, key);
}
@@ -76,10 +81,10 @@ static void CSSgenbits(unsigned char *output, int len,unsigned char const *s)
unsigned char combined;
o_lfsr0 = ((lfsr0 >> 24) ^ (lfsr0 >> 21) ^ (lfsr0 >> 20) ^ (lfsr0 >> 12)) & 1;
- lfsr0 = (lfsr0 << 1) | o_lfsr0;
+ lfsr0 = (lfsr0 << 1) | o_lfsr0;
o_lfsr1 = ((lfsr1 >> 16) ^ (lfsr1 >> 2)) & 1;
- lfsr1 = (lfsr1 << 1) | o_lfsr1;
+ lfsr1 = (lfsr1 << 1) | o_lfsr1;
#define BIT0(x) ((x) & 1)
#define BIT1(x) (((x) >> 1) & 1)
@@ -88,7 +93,7 @@ static void CSSgenbits(unsigned char *output, int len,unsigned char const *s)
b1_combined = BIT1(combined);
val |= BIT0(combined) << bit;
}
-
+
*--output = val;
} while (--len > 0);
}
@@ -113,8 +118,9 @@ static void CSSengine(int varient, unsigned char const *input,unsigned char *out
* we alter the seed to the LFSR's used above, then
* generate the bits to play with.
*/
- for (i = 5; --i >= 0; )
+ for (i = 5; --i >= 0; ) {
temp1[i] = input[5 + i] ^ CSSsecret[i] ^ CSStable2[i];
+ }
CSSgenbits(&bits[29], sizeof bits, temp1);
@@ -183,7 +189,8 @@ static unsigned char CSSvarients[] = {
0xB7, 0x74, 0x85, 0xD0, 0xCC, 0xDB, 0xCA, 0x73,
0x03, 0xFE, 0x31, 0x03, 0x52, 0xE0, 0xB7, 0x42,
0x63, 0x16, 0xF2, 0x2A, 0x79, 0x52, 0xFF, 0x1B,
- 0x7A, 0x11, 0xCA, 0x1A, 0x9B, 0x40, 0xAD, 0x01};
+ 0x7A, 0x11, 0xCA, 0x1A, 0x9B, 0x40, 0xAD, 0x01
+};
static unsigned char CSSsecret[] = {0x55, 0xD6, 0xC4, 0xC5, 0x28};
@@ -219,7 +226,8 @@ static unsigned char CSStable0[] = {
0xDB, 0x2A, 0x90, 0xA9, 0x8A, 0x3D, 0x39, 0x18,
0xA3, 0x8E, 0x58, 0x6C, 0xE0, 0x12, 0xBB, 0x25,
0xCD, 0x71, 0x22, 0xA2, 0x64, 0xC6, 0xE7, 0xFB,
- 0xAD, 0x94, 0x77, 0x04, 0x9A, 0x39, 0xCF, 0x7C};
+ 0xAD, 0x94, 0x77, 0x04, 0x9A, 0x39, 0xCF, 0x7C
+};
static unsigned char CSStable1[] = {
0x8C, 0x47, 0xB0, 0xE1, 0xEB, 0xFC, 0xEB, 0x56,
@@ -253,7 +261,8 @@ static unsigned char CSStable1[] = {
0xD0, 0xA9, 0x92, 0x2F, 0x8B, 0xBC, 0x39, 0x9C,
0xAC, 0x09, 0x5E, 0xEE, 0xE5, 0x97, 0xBF, 0xA5,
0xCE, 0xFA, 0x28, 0x2C, 0x6D, 0x4F, 0xEF, 0x77,
- 0xAA, 0x1B, 0x79, 0x8E, 0x97, 0xB4, 0xC3, 0xF4};
+ 0xAA, 0x1B, 0x79, 0x8E, 0x97, 0xB4, 0xC3, 0xF4
+};
static unsigned char CSStable2[] = {
0xB7, 0x75, 0x81, 0xD5, 0xDC, 0xCA, 0xDE, 0x66,
@@ -287,7 +296,8 @@ static unsigned char CSStable2[] = {
0x4B, 0x3B, 0x03, 0xBB, 0x1C, 0x2A, 0xAC, 0x0C,
0x3F, 0x93, 0xC7, 0x72, 0x7A, 0x09, 0x22, 0x3D,
0x45, 0x78, 0xA9, 0xA8, 0xEA, 0xC9, 0x6A, 0xF7,
- 0x29, 0x91, 0xF0, 0x02, 0x18, 0x3A, 0x4E, 0x7C};
+ 0x29, 0x91, 0xF0, 0x02, 0x18, 0x3A, 0x4E, 0x7C
+};
static unsigned char CSStable3[] = {
0x73, 0x51, 0x95, 0xE1, 0x12, 0xE4, 0xC0, 0x58,
@@ -325,4 +335,5 @@ static unsigned char CSStable3[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x33, 0x72, 0x39, 0x25, 0x67, 0x26, 0x6D, 0x71,
0x36, 0x77, 0x3C, 0x20, 0x62, 0x23, 0x68, 0x74,
- 0xC3, 0x82, 0xC9, 0x15, 0x57, 0x16, 0x5D, 0x81};
+ 0xC3, 0x82, 0xC9, 0x15, 0x57, 0x16, 0x5D, 0x81
+};
diff --git a/src/DeCSS/CSSscramble.cpp b/src/DeCSS/CSSscramble.cpp
index 87f251d21..089473823 100644
--- a/src/DeCSS/CSSscramble.cpp
+++ b/src/DeCSS/CSSscramble.cpp
@@ -4,10 +4,9 @@
#define countof(array) (sizeof(array)/sizeof(array[0]))
#endif
-unsigned int CSStab0[11]={5,0,1,2,3,4,0,1,2,3,4};
+unsigned int CSStab0[11]= {5,0,1,2,3,4,0,1,2,3,4};
-unsigned char CSStab1[256]=
-{
+unsigned char CSStab1[256]= {
0x33,0x73,0x3b,0x26,0x63,0x23,0x6b,0x76,0x3e,0x7e,0x36,0x2b,0x6e,0x2e,0x66,0x7b,
0xd3,0x93,0xdb,0x06,0x43,0x03,0x4b,0x96,0xde,0x9e,0xd6,0x0b,0x4e,0x0e,0x46,0x9b,
0x57,0x17,0x5f,0x82,0xc7,0x87,0xcf,0x12,0x5a,0x1a,0x52,0x8f,0xca,0x8a,0xc2,0x1f,
@@ -26,8 +25,7 @@ unsigned char CSStab1[256]=
0xb7,0xf7,0xbf,0xa2,0xe7,0xa7,0xef,0xf2,0xba,0xfa,0xb2,0xaf,0xea,0xaa,0xe2,0xff
};
-unsigned char CSStab2[256]=
-{
+unsigned char CSStab2[256]= {
0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x09,0x08,0x0b,0x0a,0x0d,0x0c,0x0f,0x0e,
0x12,0x13,0x10,0x11,0x16,0x17,0x14,0x15,0x1b,0x1a,0x19,0x18,0x1f,0x1e,0x1d,0x1c,
0x24,0x25,0x26,0x27,0x20,0x21,0x22,0x23,0x2d,0x2c,0x2f,0x2e,0x29,0x28,0x2b,0x2a,
@@ -46,8 +44,7 @@ unsigned char CSStab2[256]=
0xed,0xec,0xef,0xee,0xe9,0xe8,0xeb,0xea,0xe4,0xe5,0xe6,0xe7,0xe0,0xe1,0xe2,0xe3
};
-unsigned char CSStab3[512]=
-{
+unsigned char CSStab3[512]= {
0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff,0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff,
0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff,0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff,
0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff,0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff,
@@ -82,8 +79,7 @@ unsigned char CSStab3[512]=
0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff,0x00,0x24,0x49,0x6d,0x92,0xb6,0xdb,0xff
};
-unsigned char CSStab4[256]=
-{
+unsigned char CSStab4[256]= {
0x00,0x80,0x40,0xc0,0x20,0xa0,0x60,0xe0,0x10,0x90,0x50,0xd0,0x30,0xb0,0x70,0xf0,
0x08,0x88,0x48,0xc8,0x28,0xa8,0x68,0xe8,0x18,0x98,0x58,0xd8,0x38,0xb8,0x78,0xf8,
0x04,0x84,0x44,0xc4,0x24,0xa4,0x64,0xe4,0x14,0x94,0x54,0xd4,0x34,0xb4,0x74,0xf4,
@@ -102,8 +98,7 @@ unsigned char CSStab4[256]=
0x0f,0x8f,0x4f,0xcf,0x2f,0xaf,0x6f,0xef,0x1f,0x9f,0x5f,0xdf,0x3f,0xbf,0x7f,0xff
};
-unsigned char CSStab5[256]=
-{
+unsigned char CSStab5[256]= {
0xff,0x7f,0xbf,0x3f,0xdf,0x5f,0x9f,0x1f,0xef,0x6f,0xaf,0x2f,0xcf,0x4f,0x8f,0x0f,
0xf7,0x77,0xb7,0x37,0xd7,0x57,0x97,0x17,0xe7,0x67,0xa7,0x27,0xc7,0x47,0x87,0x07,
0xfb,0x7b,0xbb,0x3b,0xdb,0x5b,0x9b,0x1b,0xeb,0x6b,0xab,0x2b,0xcb,0x4b,0x8b,0x0b,
@@ -134,8 +129,7 @@ void CSSdescramble(unsigned char *sec,unsigned char *tkey)
t3=t3*2+8-t4;
sec+=0x80;
t5=0;
- while(sec!=end)
- {
+ while(sec!=end) {
t4=CSStab2[t2]^CSStab3[t1];
t2=t1>>1;
t1=((t1&1)<<8)^t4;
@@ -161,8 +155,7 @@ void CSSdisckey(unsigned char *dkey,unsigned char *pkey)
t4=t3&7;
t3=t3*2+8-t4;
t5=0;
- for(i=0;i<5;i++)
- {
+ for(i=0; i<5; i++) {
t4=CSStab2[t2]^CSStab3[t1];
t2=t1>>1;
t1=((t1&1)<<8)^t4;
@@ -174,8 +167,9 @@ void CSSdisckey(unsigned char *dkey,unsigned char *pkey)
k[i]=t5&0xff;
t5>>=8;
}
- for(i=9;i>=0;i--)
+ for(i=9; i>=0; i--) {
dkey[CSStab0[i+1]]=k[CSStab0[i+1]]^CSStab1[dkey[CSStab0[i+1]]]^dkey[CSStab0[i]];
+ }
}
void CSStitlekey(unsigned char *tkey,unsigned char *dkey)
@@ -190,8 +184,7 @@ void CSStitlekey(unsigned char *tkey,unsigned char *dkey)
t4=t3&7;
t3=t3*2+8-t4;
t5=0;
- for(i=0;i<5;i++)
- {
+ for(i=0; i<5; i++) {
t4=CSStab2[t2]^CSStab3[t1];
t2=t1>>1;
t1=((t1&1)<<8)^t4;
@@ -203,12 +196,12 @@ void CSStitlekey(unsigned char *tkey,unsigned char *dkey)
k[i]=t5&0xff;
t5>>=8;
}
- for(i=9;i>=0;i--)
+ for(i=9; i>=0; i--) {
tkey[CSStab0[i+1]]=k[CSStab0[i+1]]^CSStab1[tkey[CSStab0[i+1]]]^tkey[CSStab0[i]];
+ }
}
-unsigned char g_PlayerKeys[][6] =
-{
+unsigned char g_PlayerKeys[][6] = {
// from mplayer:
{0x01, 0xaf, 0xe3, 0x12, 0x80},
{0x12, 0x11, 0xca, 0x04, 0x3b},
diff --git a/src/DeCSS/DeCSSInputPin.cpp b/src/DeCSS/DeCSSInputPin.cpp
index 8b343ea49..ff23980dc 100644
--- a/src/DeCSS/DeCSSInputPin.cpp
+++ b/src/DeCSS/DeCSSInputPin.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -49,11 +49,11 @@ CDeCSSInputPin::CDeCSSInputPin(TCHAR* pObjectName, CTransformFilter* pFilter, HR
STDMETHODIMP CDeCSSInputPin::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
return
QI(IKsPropertySet)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
// IMemInputPin
@@ -61,22 +61,18 @@ STDMETHODIMP CDeCSSInputPin::NonDelegatingQueryInterface(REFIID riid, void** ppv
STDMETHODIMP CDeCSSInputPin::Receive(IMediaSample* pSample)
{
long len = pSample->GetActualDataLength();
-
+
BYTE* p = NULL;
- if(SUCCEEDED(pSample->GetPointer(&p)) && len > 0)
- {
- if(m_mt.majortype == MEDIATYPE_DVD_ENCRYPTED_PACK && len == 2048 && (p[0x14]&0x30))
- {
+ if(SUCCEEDED(pSample->GetPointer(&p)) && len > 0) {
+ if(m_mt.majortype == MEDIATYPE_DVD_ENCRYPTED_PACK && len == 2048 && (p[0x14]&0x30)) {
CSSdescramble(p, m_TitleKey);
p[0x14] &= ~0x30;
- if(CComQIPtr<IMediaSample2> pMS2 = pSample)
- {
+ if(CComQIPtr<IMediaSample2> pMS2 = pSample) {
AM_SAMPLE2_PROPERTIES props;
memset(&props, 0, sizeof(props));
if(SUCCEEDED(pMS2->GetProperties(sizeof(props), (BYTE*)&props))
- && (props.dwTypeSpecificFlags & AM_UseNewCSSKey))
- {
+ && (props.dwTypeSpecificFlags & AM_UseNewCSSKey)) {
props.dwTypeSpecificFlags &= ~AM_UseNewCSSKey;
pMS2->SetProperties(sizeof(props), (BYTE*)&props);
}
@@ -87,7 +83,7 @@ STDMETHODIMP CDeCSSInputPin::Receive(IMediaSample* pSample)
HRESULT hr = Transform(pSample);
return hr == S_OK ? __super::Receive(pSample) :
- hr == S_FALSE ? S_OK : hr;
+ hr == S_FALSE ? S_OK : hr;
}
void CDeCSSInputPin::StripPacket(BYTE*& p, long& len)
@@ -95,126 +91,142 @@ void CDeCSSInputPin::StripPacket(BYTE*& p, long& len)
GUID majortype = m_mt.majortype;
if(majortype == MEDIATYPE_MPEG2_PACK || majortype == MEDIATYPE_DVD_ENCRYPTED_PACK)
- if(len > 0 && *(DWORD*)p == 0xba010000) // MEDIATYPE_*_PACK
- {
- len -= 14; p += 14;
- if(int stuffing = (p[-1]&7)) {len -= stuffing; p += stuffing;}
- majortype = MEDIATYPE_MPEG2_PES;
- }
+ if(len > 0 && *(DWORD*)p == 0xba010000) { // MEDIATYPE_*_PACK
+ len -= 14;
+ p += 14;
+ if(int stuffing = (p[-1]&7)) {
+ len -= stuffing;
+ p += stuffing;
+ }
+ majortype = MEDIATYPE_MPEG2_PES;
+ }
if(majortype == MEDIATYPE_MPEG2_PES)
- if(len > 0 && *(DWORD*)p == 0xbb010000)
- {
- len -= 4; p += 4;
- int hdrlen = ((p[0]<<8)|p[1]) + 2;
- len -= hdrlen; p += hdrlen;
- }
+ if(len > 0 && *(DWORD*)p == 0xbb010000) {
+ len -= 4;
+ p += 4;
+ int hdrlen = ((p[0]<<8)|p[1]) + 2;
+ len -= hdrlen;
+ p += hdrlen;
+ }
if(majortype == MEDIATYPE_MPEG2_PES)
- if(len > 0
- && ((*(DWORD*)p&0xf0ffffff) == 0xe0010000
- || (*(DWORD*)p&0xe0ffffff) == 0xc0010000
- || (*(DWORD*)p&0xbdffffff) == 0xbd010000)) // PES
- {
- bool ps1 = (*(DWORD*)p&0xbdffffff) == 0xbd010000;
-
- len -= 4; p += 4;
- int expected = ((p[0]<<8)|p[1]);
- len -= 2; p += 2;
- BYTE* p0 = p;
-
- for(int i = 0; i < 16 && *p == 0xff; i++, len--, p++);
-
- if((*p&0xc0) == 0x80) // mpeg2
- {
- len -= 2; p += 2;
- len -= *p+1; p += *p+1;
- }
- else // mpeg1
- {
- if((*p&0xc0) == 0x40)
- {
- len -= 2; p += 2;
+ if(len > 0
+ && ((*(DWORD*)p&0xf0ffffff) == 0xe0010000
+ || (*(DWORD*)p&0xe0ffffff) == 0xc0010000
+ || (*(DWORD*)p&0xbdffffff) == 0xbd010000)) { // PES
+ bool ps1 = (*(DWORD*)p&0xbdffffff) == 0xbd010000;
+
+ len -= 4;
+ p += 4;
+ int expected = ((p[0]<<8)|p[1]);
+ len -= 2;
+ p += 2;
+ BYTE* p0 = p;
+
+ for(int i = 0; i < 16 && *p == 0xff; i++, len--, p++) {
+ ;
}
- if((*p&0x30) == 0x30 || (*p&0x30) == 0x20)
- {
- bool pts = !!(*p&0x20), dts = !!(*p&0x10);
- if(pts) len -= 5; p += 5;
- if(dts) {ASSERT((*p&0xf0) == 0x10); len -= 5; p += 5;}
+ if((*p&0xc0) == 0x80) { // mpeg2
+ len -= 2;
+ p += 2;
+ len -= *p+1;
+ p += *p+1;
+ } else { // mpeg1
+ if((*p&0xc0) == 0x40) {
+ len -= 2;
+ p += 2;
+ }
+
+ if((*p&0x30) == 0x30 || (*p&0x30) == 0x20) {
+ bool pts = !!(*p&0x20), dts = !!(*p&0x10);
+ if(pts) {
+ len -= 5;
+ }
+ p += 5;
+ if(dts) {
+ ASSERT((*p&0xf0) == 0x10);
+ len -= 5;
+ p += 5;
+ }
+ } else {
+ len--;
+ p++;
+ }
}
- else
- {
- len--; p++;
+
+ if(ps1) {
+ len--;
+ p++;
+ if(m_mt.subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO) {
+ len -= 6;
+ p += 6;
+ } else if(m_mt.subtype == MEDIASUBTYPE_DOLBY_AC3 || m_mt.subtype == MEDIASUBTYPE_WAVE_DOLBY_AC3
+ || m_mt.subtype == MEDIASUBTYPE_DTS || m_mt.subtype == MEDIASUBTYPE_WAVE_DTS) {
+ len -= 3;
+ p += 3;
+ }
}
- }
- if(ps1)
- {
- len--; p++;
- if(m_mt.subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO) {len -= 6; p += 6;}
- else if(m_mt.subtype == MEDIASUBTYPE_DOLBY_AC3 || m_mt.subtype == MEDIASUBTYPE_WAVE_DOLBY_AC3
- || m_mt.subtype == MEDIASUBTYPE_DTS || m_mt.subtype == MEDIASUBTYPE_WAVE_DTS) {len -= 3; p += 3;}
+ if(expected > 0) {
+ expected -= (p - p0);
+ len = min(expected, len);
+ }
}
- if(expected > 0)
- {
- expected -= (p - p0);
- len = min(expected, len);
- }
+ if(len < 0) {
+ ASSERT(0);
+ len = 0;
}
-
- if(len < 0) {ASSERT(0); len = 0;}
}
// IKsPropertySet
STDMETHODIMP CDeCSSInputPin::Set(REFGUID PropSet, ULONG Id, LPVOID pInstanceData, ULONG InstanceLength, LPVOID pPropertyData, ULONG DataLength)
{
- if(PropSet != AM_KSPROPSETID_CopyProt)
+ if(PropSet != AM_KSPROPSETID_CopyProt) {
return E_NOTIMPL;
+ }
- switch(Id)
- {
- case AM_PROPERTY_COPY_MACROVISION:
- break;
- case AM_PROPERTY_DVDCOPY_CHLG_KEY: // 3. auth: receive drive nonce word, also store and encrypt the buskey made up of the two nonce words
- {
+ switch(Id) {
+ case AM_PROPERTY_COPY_MACROVISION:
+ break;
+ case AM_PROPERTY_DVDCOPY_CHLG_KEY: { // 3. auth: receive drive nonce word, also store and encrypt the buskey made up of the two nonce words
AM_DVDCOPY_CHLGKEY* pChlgKey = (AM_DVDCOPY_CHLGKEY*)pPropertyData;
- for(int i = 0; i < 10; i++)
+ for(int i = 0; i < 10; i++) {
m_Challenge[i] = pChlgKey->ChlgKey[9-i];
+ }
CSSkey2(m_varient, m_Challenge, &m_Key[5]);
CSSbuskey(m_varient, m_Key, m_KeyCheck);
}
break;
- case AM_PROPERTY_DVDCOPY_DISC_KEY: // 5. receive the disckey
- {
+ case AM_PROPERTY_DVDCOPY_DISC_KEY: { // 5. receive the disckey
AM_DVDCOPY_DISCKEY* pDiscKey = (AM_DVDCOPY_DISCKEY*)pPropertyData; // pDiscKey->DiscKey holds the disckey encrypted with itself and the 408 disckeys encrypted with the playerkeys
bool fSuccess = false;
- for(int j = 0; j < g_nPlayerKeys; j++)
- {
- for(int k = 1; k < 409; k++)
- {
+ for(int j = 0; j < g_nPlayerKeys; j++) {
+ for(int k = 1; k < 409; k++) {
BYTE DiscKey[6];
- for(int i = 0; i < 5; i++)
+ for(int i = 0; i < 5; i++) {
DiscKey[i] = pDiscKey->DiscKey[k*5+i] ^ m_KeyCheck[4-i];
+ }
DiscKey[5] = 0;
CSSdisckey(DiscKey, g_PlayerKeys[j]);
BYTE Hash[6];
- for(int i = 0; i < 5; i++)
+ for(int i = 0; i < 5; i++) {
Hash[i] = pDiscKey->DiscKey[i] ^ m_KeyCheck[4-i];
+ }
Hash[5] = 0;
CSSdisckey(Hash, DiscKey);
- if(!memcmp(Hash, DiscKey, 6))
- {
+ if(!memcmp(Hash, DiscKey, 6)) {
memcpy(m_DiscKey, DiscKey, 6);
j = g_nPlayerKeys;
fSuccess = true;
@@ -223,42 +235,43 @@ STDMETHODIMP CDeCSSInputPin::Set(REFGUID PropSet, ULONG Id, LPVOID pInstanceData
}
}
- if(!fSuccess)
+ if(!fSuccess) {
return E_FAIL;
+ }
}
break;
- case AM_PROPERTY_DVDCOPY_DVD_KEY1: // 2. auth: receive our drive-encrypted nonce word and decrypt it for verification
- {
+ case AM_PROPERTY_DVDCOPY_DVD_KEY1: { // 2. auth: receive our drive-encrypted nonce word and decrypt it for verification
AM_DVDCOPY_BUSKEY* pKey1 = (AM_DVDCOPY_BUSKEY*)pPropertyData;
- for(int i = 0; i < 5; i++)
+ for(int i = 0; i < 5; i++) {
m_Key[i] = pKey1->BusKey[4-i];
+ }
m_varient = -1;
- for(int i = 31; i >= 0; i--)
- {
+ for(int i = 31; i >= 0; i--) {
CSSkey1(i, m_Challenge, m_KeyCheck);
- if(memcmp(m_KeyCheck, &m_Key[0], 5) == 0)
+ if(memcmp(m_KeyCheck, &m_Key[0], 5) == 0) {
m_varient = i;
+ }
}
}
break;
- case AM_PROPERTY_DVDCOPY_REGION:
- break;
- case AM_PROPERTY_DVDCOPY_SET_COPY_STATE:
- break;
- case AM_PROPERTY_DVDCOPY_TITLE_KEY: // 6. receive the title key and decrypt it with the disc key
- {
+ case AM_PROPERTY_DVDCOPY_REGION:
+ break;
+ case AM_PROPERTY_DVDCOPY_SET_COPY_STATE:
+ break;
+ case AM_PROPERTY_DVDCOPY_TITLE_KEY: { // 6. receive the title key and decrypt it with the disc key
AM_DVDCOPY_TITLEKEY* pTitleKey = (AM_DVDCOPY_TITLEKEY*)pPropertyData;
- for(int i = 0; i < 5; i++)
+ for(int i = 0; i < 5; i++) {
m_TitleKey[i] = pTitleKey->TitleKey[i] ^ m_KeyCheck[4-i];
+ }
m_TitleKey[5] = 0;
CSStitlekey(m_TitleKey, m_DiscKey);
}
break;
- default:
- return E_PROP_ID_UNSUPPORTED;
+ default:
+ return E_PROP_ID_UNSUPPORTED;
}
return S_OK;
@@ -266,44 +279,42 @@ STDMETHODIMP CDeCSSInputPin::Set(REFGUID PropSet, ULONG Id, LPVOID pInstanceData
STDMETHODIMP CDeCSSInputPin::Get(REFGUID PropSet, ULONG Id, LPVOID pInstanceData, ULONG InstanceLength, LPVOID pPropertyData, ULONG DataLength, ULONG* pBytesReturned)
{
- if(PropSet != AM_KSPROPSETID_CopyProt)
+ if(PropSet != AM_KSPROPSETID_CopyProt) {
return E_NOTIMPL;
+ }
- switch(Id)
- {
- case AM_PROPERTY_DVDCOPY_CHLG_KEY: // 1. auth: send our nonce word
- {
+ switch(Id) {
+ case AM_PROPERTY_DVDCOPY_CHLG_KEY: { // 1. auth: send our nonce word
AM_DVDCOPY_CHLGKEY* pChlgKey = (AM_DVDCOPY_CHLGKEY*)pPropertyData;
- for(int i = 0; i < 10; i++)
+ for(int i = 0; i < 10; i++) {
pChlgKey->ChlgKey[i] = 9 - (m_Challenge[i] = i);
+ }
*pBytesReturned = sizeof(AM_DVDCOPY_CHLGKEY);
}
break;
- case AM_PROPERTY_DVDCOPY_DEC_KEY2: // 4. auth: send back the encrypted drive nonce word to finish the authentication
- {
+ case AM_PROPERTY_DVDCOPY_DEC_KEY2: { // 4. auth: send back the encrypted drive nonce word to finish the authentication
AM_DVDCOPY_BUSKEY* pKey2 = (AM_DVDCOPY_BUSKEY*)pPropertyData;
- for(int i = 0; i < 5; i++)
+ for(int i = 0; i < 5; i++) {
pKey2->BusKey[4-i] = m_Key[5+i];
+ }
*pBytesReturned = sizeof(AM_DVDCOPY_BUSKEY);
}
break;
- case AM_PROPERTY_DVDCOPY_REGION:
- {
+ case AM_PROPERTY_DVDCOPY_REGION: {
DVD_REGION* pRegion = (DVD_REGION*)pPropertyData;
pRegion->RegionData = 0;
pRegion->SystemRegion = 0;
*pBytesReturned = sizeof(DVD_REGION);
}
break;
- case AM_PROPERTY_DVDCOPY_SET_COPY_STATE:
- {
+ case AM_PROPERTY_DVDCOPY_SET_COPY_STATE: {
AM_DVDCOPY_SET_COPY_STATE* pState = (AM_DVDCOPY_SET_COPY_STATE*)pPropertyData;
pState->DVDCopyState = AM_DVDCOPYSTATE_AUTHENTICATION_REQUIRED;
*pBytesReturned = sizeof(AM_DVDCOPY_SET_COPY_STATE);
}
break;
- default:
- return E_PROP_ID_UNSUPPORTED;
+ default:
+ return E_PROP_ID_UNSUPPORTED;
}
return S_OK;
@@ -311,37 +322,37 @@ STDMETHODIMP CDeCSSInputPin::Get(REFGUID PropSet, ULONG Id, LPVOID pInstanceData
STDMETHODIMP CDeCSSInputPin::QuerySupported(REFGUID PropSet, ULONG Id, ULONG* pTypeSupport)
{
- if(PropSet != AM_KSPROPSETID_CopyProt)
+ if(PropSet != AM_KSPROPSETID_CopyProt) {
return E_NOTIMPL;
+ }
- switch(Id)
- {
- case AM_PROPERTY_COPY_MACROVISION:
- *pTypeSupport = KSPROPERTY_SUPPORT_SET;
- break;
- case AM_PROPERTY_DVDCOPY_CHLG_KEY:
- *pTypeSupport = KSPROPERTY_SUPPORT_GET | KSPROPERTY_SUPPORT_SET;
- break;
- case AM_PROPERTY_DVDCOPY_DEC_KEY2:
- *pTypeSupport = KSPROPERTY_SUPPORT_GET;
- break;
- case AM_PROPERTY_DVDCOPY_DISC_KEY:
- *pTypeSupport = KSPROPERTY_SUPPORT_SET;
- break;
- case AM_PROPERTY_DVDCOPY_DVD_KEY1:
- *pTypeSupport = KSPROPERTY_SUPPORT_SET;
- break;
- case AM_PROPERTY_DVDCOPY_REGION:
- *pTypeSupport = KSPROPERTY_SUPPORT_GET | KSPROPERTY_SUPPORT_SET;
- break;
- case AM_PROPERTY_DVDCOPY_SET_COPY_STATE:
- *pTypeSupport = KSPROPERTY_SUPPORT_GET | KSPROPERTY_SUPPORT_SET;
- break;
- case AM_PROPERTY_DVDCOPY_TITLE_KEY:
- *pTypeSupport = KSPROPERTY_SUPPORT_SET;
- break;
- default:
- return E_PROP_ID_UNSUPPORTED;
+ switch(Id) {
+ case AM_PROPERTY_COPY_MACROVISION:
+ *pTypeSupport = KSPROPERTY_SUPPORT_SET;
+ break;
+ case AM_PROPERTY_DVDCOPY_CHLG_KEY:
+ *pTypeSupport = KSPROPERTY_SUPPORT_GET | KSPROPERTY_SUPPORT_SET;
+ break;
+ case AM_PROPERTY_DVDCOPY_DEC_KEY2:
+ *pTypeSupport = KSPROPERTY_SUPPORT_GET;
+ break;
+ case AM_PROPERTY_DVDCOPY_DISC_KEY:
+ *pTypeSupport = KSPROPERTY_SUPPORT_SET;
+ break;
+ case AM_PROPERTY_DVDCOPY_DVD_KEY1:
+ *pTypeSupport = KSPROPERTY_SUPPORT_SET;
+ break;
+ case AM_PROPERTY_DVDCOPY_REGION:
+ *pTypeSupport = KSPROPERTY_SUPPORT_GET | KSPROPERTY_SUPPORT_SET;
+ break;
+ case AM_PROPERTY_DVDCOPY_SET_COPY_STATE:
+ *pTypeSupport = KSPROPERTY_SUPPORT_GET | KSPROPERTY_SUPPORT_SET;
+ break;
+ case AM_PROPERTY_DVDCOPY_TITLE_KEY:
+ *pTypeSupport = KSPROPERTY_SUPPORT_SET;
+ break;
+ default:
+ return E_PROP_ID_UNSUPPORTED;
}
return S_OK;
diff --git a/src/DeCSS/DeCSSInputPin.h b/src/DeCSS/DeCSSInputPin.h
index 2e6e1a293..3cf79e321 100644
--- a/src/DeCSS/DeCSSInputPin.h
+++ b/src/DeCSS/DeCSSInputPin.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -28,23 +28,25 @@ class CDeCSSInputPin : public CTransformInputPin, public IKsPropertySet
BYTE m_DiscKey[6], m_TitleKey[6];
protected:
- // return S_FALSE here if you don't want the base class
+ // return S_FALSE here if you don't want the base class
// to call CTransformFilter::Receive with this sample
- virtual HRESULT Transform(IMediaSample* pSample) {return S_OK;}
+ virtual HRESULT Transform(IMediaSample* pSample) {
+ return S_OK;
+ }
public:
- CDeCSSInputPin(TCHAR* pObjectName, CTransformFilter* pFilter, HRESULT* phr, LPWSTR pName);
+ CDeCSSInputPin(TCHAR* pObjectName, CTransformFilter* pFilter, HRESULT* phr, LPWSTR pName);
DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
void StripPacket(BYTE*& p, long& len);
// IMemInputPin
- STDMETHODIMP Receive(IMediaSample* pSample);
+ STDMETHODIMP Receive(IMediaSample* pSample);
// 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);
+ 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);
}; \ No newline at end of file
diff --git a/src/DeCSS/VobDec.cpp b/src/DeCSS/VobDec.cpp
index 09c89ccd9..c2b724953 100644
--- a/src/DeCSS/VobDec.cpp
+++ b/src/DeCSS/VobDec.cpp
@@ -1,8 +1,7 @@
#include "stdafx.h"
#include "vobdec.h"
-static BYTE reverse[0x100], table[0x100] =
-{
+static BYTE reverse[0x100], table[0x100] = {
0x33, 0x73, 0x3B, 0x26, 0x63, 0x23, 0x6B, 0x76, 0x3E, 0x7E, 0x36, 0x2B, 0x6E, 0x2E, 0x66, 0x7B,
0xD3, 0x93, 0xDB, 0x06, 0x43, 0x03, 0x4B, 0x96, 0xDE, 0x9E, 0xD6, 0x0B, 0x4E, 0x0E, 0x46, 0x9B,
0x57, 0x17, 0x5F, 0x82, 0xC7, 0x87, 0xCF, 0x12, 0x5A, 0x1A, 0x52, 0x8F, 0xCA, 0x8A, 0xC2, 0x1F,
@@ -25,12 +24,10 @@ CVobDec::CVobDec()
{
m_fFoundKey = false;
- for(DWORD loop0 = 0; loop0 < 0x100; loop0++)
- {
+ for(DWORD loop0 = 0; loop0 < 0x100; loop0++) {
BYTE value = 0;
- for(DWORD loop1 = 0; loop1 < 8; loop1++)
- {
+ for(DWORD loop1 = 0; loop1 < 8; loop1++) {
value |= ((loop0 >> loop1) & 1) << (7 - loop1);
}
@@ -75,44 +72,35 @@ int CVobDec::FindLfsr(const BYTE *crypt, int offset, const BYTE *plain)
{
int loop0, loop1, lfsr0, lfsr1, carry, count;
- for(loop0 = count = 0; loop0 != (1 << 18); loop0++)
- {
+ for(loop0 = count = 0; loop0 != (1 << 18); loop0++) {
lfsr0 = loop0 >> 1;
carry = loop0 & 0x01;
- for(loop1 = lfsr1 = 0; loop1 != 4; loop1++)
- {
+ for(loop1 = lfsr1 = 0; loop1 != 4; loop1++) {
ClockLfsr0Forward(lfsr0);
carry = (table[crypt[offset + loop1]] ^ plain[loop1]) - ((lfsr0 >> 9) ^ 0xFF) - carry;
lfsr1 = (lfsr1 >> 8) | ((carry & 0xFF) << 17);
carry = (carry >> 8) & 0x01;
}
- for( ; loop1 != 7; loop1++)
- {
+ for( ; loop1 != 7; loop1++) {
ClockLfsr0Forward(lfsr0);
ClockLfsr1Forward(lfsr1);
carry += ((lfsr0 >> 9) ^ 0xFF) + (lfsr1 >> 17);
- if((carry & 0xFF) != (table[crypt[offset + loop1]] ^ plain[loop1]))
- {
+ if((carry & 0xFF) != (table[crypt[offset + loop1]] ^ plain[loop1])) {
break;
}
carry >>= 8;
}
- if(loop1 == 7)
- {
- for(loop1 = 0; loop1 != 6; loop1++)
- {
+ if(loop1 == 7) {
+ for(loop1 = 0; loop1 != 6; loop1++) {
ClockBackward(lfsr0, lfsr1);
}
carry = ((lfsr0 >> 9) ^ 0xFF) + (lfsr1 >> 17) + (loop0 & 0x01);
- if((carry & 0xFF) == (table[crypt[offset]] ^ plain[0]))
- {
- for(loop1 = 0; loop1 != offset + 1; loop1++)
- {
+ if((carry & 0xFF) == (table[crypt[offset]] ^ plain[0])) {
+ for(loop1 = 0; loop1 != offset + 1; loop1++) {
ClockBackward(lfsr0, lfsr1);
}
- if(lfsr0 & 0x100 && lfsr1 & 0x200000)
- {
+ if(lfsr0 & 0x100 && lfsr1 & 0x200000) {
m_lfsr0 = lfsr0;
m_lfsr1 = lfsr1;
count++;
@@ -131,27 +119,21 @@ bool CVobDec::FindKey(BYTE* buff)
m_fFoundKey = false;
- if(buff[0x14] & 0x30)
- {
+ if(buff[0x14] & 0x30) {
flag |= 0x01;
- if(*(DWORD*)&buff[0x00] == 0xba010000 && (*(DWORD*)&buff[0x0e] & 0xffffff) == 0x010000)
- {
+ if(*(DWORD*)&buff[0x00] == 0xba010000 && (*(DWORD*)&buff[0x0e] & 0xffffff) == 0x010000) {
offset = 0x14 + (buff[0x12] << 8) + buff[0x13];
- if(0x80 <= offset && offset <= 0x7F9)
- {
+ if(0x80 <= offset && offset <= 0x7F9) {
flag |= 0x02;
left = 0x800 - offset - 6;
plain[4] = (char)(left >> 8);
plain[5] = (char)left;
- if((count = FindLfsr(buff + 0x80, offset - 0x80, plain)) == 1)
- {
+ if((count = FindLfsr(buff + 0x80, offset - 0x80, plain)) == 1) {
Salt(buff + 0x54, m_lfsr0, m_lfsr1);
m_fFoundKey = true;
- }
- else if(count)
- {
-// printf(_T("\rblock %d reported %d possible keys, skipping\n"), block, count);
+ } else if(count) {
+ // printf(_T("\rblock %d reported %d possible keys, skipping\n"), block, count);
}
}
}
@@ -162,18 +144,16 @@ bool CVobDec::FindKey(BYTE* buff)
void CVobDec::Decrypt(BYTE* buff)
{
- if(buff[0x14] & 0x30)
- {
+ if(buff[0x14] & 0x30) {
buff[0x14] &= ~0x30;
int lfsr0 = m_lfsr0, lfsr1 = m_lfsr1;
Salt(buff + 0x54, lfsr0, lfsr1);
-
+
buff += 0x80;
- for(int loop0 = 0, carry = 0; loop0 != 0x800 - 0x80; loop0++, buff++)
- {
+ for(int loop0 = 0, carry = 0; loop0 != 0x800 - 0x80; loop0++, buff++) {
ClockLfsr0Forward(lfsr0);
ClockLfsr1Forward(lfsr1);
carry += ((lfsr0 >> 9) ^ 0xFF) + (lfsr1 >> 17);
diff --git a/src/DeCSS/VobFile.cpp b/src/DeCSS/VobFile.cpp
index 8428f220a..16c4c56fb 100644
--- a/src/DeCSS/VobFile.cpp
+++ b/src/DeCSS/VobFile.cpp
@@ -27,18 +27,18 @@ bool CDVDSession::Open(LPCTSTR path)
CString fn = path;
CString drive = _T("\\\\.\\") + fn.Left(fn.Find(':')+1);
- 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)
+ 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);
+ }
return(true);
}
void CDVDSession::Close()
{
- if(m_hDrive != INVALID_HANDLE_VALUE)
- {
+ if(m_hDrive != INVALID_HANDLE_VALUE) {
CloseHandle(m_hDrive);
m_hDrive = INVALID_HANDLE_VALUE;
}
@@ -48,16 +48,15 @@ bool CDVDSession::BeginSession()
{
EndSession();
- if(m_hDrive == INVALID_HANDLE_VALUE)
+ if(m_hDrive == INVALID_HANDLE_VALUE) {
return(false);
+ }
DWORD BytesReturned;
- if(!DeviceIoControl(m_hDrive, IOCTL_DVD_START_SESSION, NULL, 0, &m_session, sizeof(m_session), &BytesReturned, NULL))
- {
+ if(!DeviceIoControl(m_hDrive, IOCTL_DVD_START_SESSION, NULL, 0, &m_session, sizeof(m_session), &BytesReturned, NULL)) {
m_session = DVD_END_ALL_SESSIONS;
if(!DeviceIoControl(m_hDrive, IOCTL_DVD_END_SESSION, &m_session, sizeof(m_session), NULL, 0, &BytesReturned, NULL)
- || !DeviceIoControl(m_hDrive, IOCTL_DVD_START_SESSION, NULL, 0, &m_session, sizeof(m_session), &BytesReturned, NULL))
- {
+ || !DeviceIoControl(m_hDrive, IOCTL_DVD_START_SESSION, NULL, 0, &m_session, sizeof(m_session), &BytesReturned, NULL)) {
Close();
DWORD err = GetLastError();
UNUSED_ALWAYS(err);
@@ -70,46 +69,52 @@ bool CDVDSession::BeginSession()
void CDVDSession::EndSession()
{
- if(m_session != DVD_END_ALL_SESSIONS)
- {
+ if(m_session != DVD_END_ALL_SESSIONS) {
DWORD BytesReturned;
DeviceIoControl(m_hDrive, IOCTL_DVD_END_SESSION, &m_session, sizeof(m_session), NULL, 0, &BytesReturned, NULL);
- m_session = DVD_END_ALL_SESSIONS;
+ m_session = DVD_END_ALL_SESSIONS;
}
}
bool CDVDSession::Authenticate()
{
- if(m_session == DVD_END_ALL_SESSIONS)
+ if(m_session == DVD_END_ALL_SESSIONS) {
return(false);
+ }
BYTE Challenge[10], Key[10];
- for(int i = 0; i < 10; i++) Challenge[i] = i;
+ for(int i = 0; i < 10; i++) {
+ Challenge[i] = i;
+ }
- if(!SendKey(DvdChallengeKey, Challenge))
+ if(!SendKey(DvdChallengeKey, Challenge)) {
return(false);
+ }
- if(!ReadKey(DvdBusKey1, Key))
+ if(!ReadKey(DvdBusKey1, Key)) {
return(false);
+ }
int varient = -1;
- for(int i = 31; i >= 0; i--)
- {
+ for(int i = 31; i >= 0; i--) {
BYTE KeyCheck[5];
CSSkey1(i, Challenge, KeyCheck);
- if(!memcmp(KeyCheck, Key, 5))
+ if(!memcmp(KeyCheck, Key, 5)) {
varient = i;
+ }
}
- if(!ReadKey(DvdChallengeKey, Challenge))
+ if(!ReadKey(DvdChallengeKey, Challenge)) {
return(false);
+ }
CSSkey2(varient, Challenge, &Key[5]);
- if(!SendKey(DvdBusKey2, &Key[5]))
+ if(!SendKey(DvdBusKey2, &Key[5])) {
return(false);
+ }
CSSbuskey(varient, Key, m_SessionKey);
@@ -118,17 +123,17 @@ bool CDVDSession::Authenticate()
bool CDVDSession::GetDiscKey()
{
- if(m_session == DVD_END_ALL_SESSIONS)
+ if(m_session == DVD_END_ALL_SESSIONS) {
return(false);
+ }
BYTE DiscKeys[2048];
- if(!ReadKey(DvdDiskKey, DiscKeys))
+ if(!ReadKey(DvdDiskKey, DiscKeys)) {
return(false);
+ }
- for(int i = 0; i < g_nPlayerKeys; i++)
- {
- for(int j = 1; j < 409; j++)
- {
+ for(int i = 0; i < g_nPlayerKeys; i++) {
+ for(int j = 1; j < 409; j++) {
BYTE DiscKey[6];
memcpy(DiscKey, &DiscKeys[j*5], 5);
DiscKey[5] = 0;
@@ -141,8 +146,7 @@ bool CDVDSession::GetDiscKey()
CSSdisckey(Hash, DiscKey);
- if(!memcmp(Hash, DiscKey, 6))
- {
+ if(!memcmp(Hash, DiscKey, 6)) {
memcpy(m_DiscKey, DiscKey, 6);
return(true);
}
@@ -154,14 +158,17 @@ bool CDVDSession::GetDiscKey()
bool CDVDSession::GetTitleKey(int lba, BYTE* pKey)
{
- if(m_session == DVD_END_ALL_SESSIONS)
+ if(m_session == DVD_END_ALL_SESSIONS) {
return(false);
+ }
- if(!ReadKey(DvdTitleKey, pKey, lba))
+ if(!ReadKey(DvdTitleKey, pKey, lba)) {
return(false);
+ }
- if(!(pKey[0]|pKey[1]|pKey[2]|pKey[3]|pKey[4]))
+ if(!(pKey[0]|pKey[1]|pKey[2]|pKey[3]|pKey[4])) {
return(false);
+ }
pKey[5] = 0;
@@ -172,15 +179,14 @@ bool CDVDSession::GetTitleKey(int lba, BYTE* pKey)
static void Reverse(BYTE* d, BYTE* s, int len)
{
- if(d == s)
- {
- for(s += len-1; d < s; d++, s--)
+ if(d == s) {
+ for(s += len-1; d < s; d++, s--) {
*d ^= *s, *s ^= *d, *d ^= *s;
- }
- else
- {
- for(int i = 0; i < len; i++)
+ }
+ } else {
+ for(int i = 0; i < len; i++) {
d[i] = s[len-1 - i];
+ }
}
}
@@ -188,9 +194,8 @@ bool CDVDSession::SendKey(DVD_KEY_TYPE KeyType, BYTE* pKeyData)
{
CAutoPtr<DVD_COPY_PROTECT_KEY> key;
- switch(KeyType)
- {
- case DvdChallengeKey:
+ switch(KeyType) {
+ case DvdChallengeKey:
key.Attach((DVD_COPY_PROTECT_KEY*)DNew BYTE[DVD_CHALLENGE_KEY_LENGTH]);
key->KeyLength = DVD_CHALLENGE_KEY_LENGTH;
Reverse(key->KeyData, pKeyData, 10);
@@ -200,12 +205,13 @@ bool CDVDSession::SendKey(DVD_KEY_TYPE KeyType, BYTE* pKeyData)
key->KeyLength = DVD_BUS_KEY_LENGTH;
Reverse(key->KeyData, pKeyData, 5);
break;
- default:
+ default:
break;
}
- if(!key)
+ if(!key) {
return(false);
+ }
key->SessionId = m_session;
key->KeyType = KeyType;
@@ -219,9 +225,8 @@ bool CDVDSession::ReadKey(DVD_KEY_TYPE KeyType, BYTE* pKeyData, int lba)
{
CAutoPtr<DVD_COPY_PROTECT_KEY> key;
- switch(KeyType)
- {
- case DvdChallengeKey:
+ switch(KeyType) {
+ case DvdChallengeKey:
key.Attach((DVD_COPY_PROTECT_KEY*)DNew BYTE[DVD_CHALLENGE_KEY_LENGTH]);
key->KeyLength = DVD_CHALLENGE_KEY_LENGTH;
key->Parameters.TitleOffset.QuadPart = 0;
@@ -241,27 +246,26 @@ bool CDVDSession::ReadKey(DVD_KEY_TYPE KeyType, BYTE* pKeyData, int lba)
key->KeyLength = DVD_TITLE_KEY_LENGTH;
key->Parameters.TitleOffset.QuadPart = 2048i64*lba;
break;
- default:
+ default:
break;
}
- if(!key)
+ if(!key) {
return(false);
+ }
key->SessionId = m_session;
key->KeyType = KeyType;
key->KeyFlags = 0;
DWORD BytesReturned;
- if(!DeviceIoControl(m_hDrive, IOCTL_DVD_READ_KEY, key, key->KeyLength, key, key->KeyLength, &BytesReturned, NULL))
- {
+ if(!DeviceIoControl(m_hDrive, IOCTL_DVD_READ_KEY, key, key->KeyLength, key, key->KeyLength, &BytesReturned, NULL)) {
DWORD err = GetLastError();
UNUSED_ALWAYS(err);
return(false);
}
- switch(KeyType)
- {
+ switch(KeyType) {
case DvdChallengeKey:
Reverse(pKeyData, key->KeyData, 10);
break;
@@ -270,15 +274,17 @@ bool CDVDSession::ReadKey(DVD_KEY_TYPE KeyType, BYTE* pKeyData, int lba)
break;
case DvdDiskKey:
memcpy(pKeyData, key->KeyData, 2048);
- for(int i = 0; i < 2048/5; i++)
+ for(int i = 0; i < 2048/5; i++) {
pKeyData[i] ^= m_SessionKey[4-(i%5)];
+ }
break;
case DvdTitleKey:
memcpy(pKeyData, key->KeyData, 5);
- for(int i = 0; i < 5; i++)
+ for(int i = 0; i < 5; i++) {
pKeyData[i] ^= m_SessionKey[4-(i%5)];
+ }
break;
- default:
+ default:
break;
}
@@ -311,8 +317,9 @@ bool CLBAFile::Open(LPCTSTR path)
void CLBAFile::Close()
{
- if(m_hFile != hFileNull)
+ if(m_hFile != hFileNull) {
CFile::Close();
+ }
}
int CLBAFile::GetLength()
@@ -355,27 +362,33 @@ bool CVobFile::IsDVD()
bool CVobFile::HasDiscKey(BYTE* key)
{
- if(key) memcpy(key, m_DiscKey, 5);
+ if(key) {
+ memcpy(key, m_DiscKey, 5);
+ }
return m_fHasDiscKey;
}
bool CVobFile::HasTitleKey(BYTE* key)
{
- if(key) memcpy(key, m_TitleKey, 5);
+ if(key) {
+ memcpy(key, m_TitleKey, 5);
+ }
return m_fHasTitleKey;
}
bool CVobFile::Open(CString fn, CAtlList<CString>& vobs)
{
CFile f;
- if(!f.Open(fn, CFile::modeRead|CFile::typeBinary|CFile::shareDenyNone))
+ if(!f.Open(fn, CFile::modeRead|CFile::typeBinary|CFile::shareDenyNone)) {
return(false);
+ }
char hdr[13];
f.Read(hdr, 12);
hdr[12] = 0;
- if(strcmp(hdr, "DVDVIDEO-VTS"))
+ if(strcmp(hdr, "DVDVIDEO-VTS")) {
return(false);
+ }
f.Close();
@@ -385,29 +398,31 @@ bool CVobFile::Open(CString fn, CAtlList<CString>& vobs)
fn = fn.Left(fn.ReverseFind('.')+1);
fn.TrimRight(_T(".0123456789"));
- for(int i = 0; i < 100; i++)
- {
+ for(int i = 0; i < 100; i++) {
CString vob;
vob.Format(_T("%s%d.vob"), fn, i);
CFileStatus status;
- if(!CFile::GetStatus(vob, status))
- {
- if(i == 0) continue;
- else break;
+ if(!CFile::GetStatus(vob, status)) {
+ if(i == 0) {
+ continue;
+ } else {
+ break;
+ }
}
- if(status.m_size&0x7ff)
- {
+ if(status.m_size&0x7ff) {
vobs.RemoveAll();
break;
}
- if(status.m_size > 0)
+ if(status.m_size > 0) {
vobs.AddTail(vob);
+ }
- if(i == 0)
+ if(i == 0) {
offset = (int)(status.m_size/0x800);
+ }
}
return Open(vobs, offset);
@@ -417,23 +432,23 @@ bool CVobFile::Open(CAtlList<CString>& vobs, int offset)
{
Close();
- if(vobs.GetCount() == 0)
+ if(vobs.GetCount() == 0) {
return(false);
+ }
- if(vobs.GetCount() == 1)
+ if(vobs.GetCount() == 1) {
offset = -1;
+ }
m_offset = offset;
POSITION pos = vobs.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CString fn = vobs.GetNext(pos);
WIN32_FIND_DATA fd;
HANDLE h = FindFirstFile(fn, &fd);
- if(h == INVALID_HANDLE_VALUE)
- {
+ if(h == INVALID_HANDLE_VALUE) {
m_files.RemoveAll();
return(false);
}
@@ -447,37 +462,28 @@ bool CVobFile::Open(CAtlList<CString>& vobs, int offset)
m_size += f.size;
}
- if(m_files.GetCount() > 0 && CDVDSession::Open(m_files[0].fn))
- {
- for(int i = 0; !m_fHasTitleKey && i < m_files.GetCount(); i++)
- {
- if(BeginSession())
- {
+ if(m_files.GetCount() > 0 && CDVDSession::Open(m_files[0].fn)) {
+ for(int i = 0; !m_fHasTitleKey && i < m_files.GetCount(); i++) {
+ if(BeginSession()) {
m_fDVD = true;
Authenticate();
m_fHasDiscKey = GetDiscKey();
EndSession();
- }
- else
- {
+ } else {
CString fn = m_files[0].fn;
fn.MakeLower();
- if(fn.Find(_T(":\\video_ts")) == 1 && GetDriveType(fn.Left(3)) == DRIVE_CDROM)
- {
+ if(fn.Find(_T(":\\video_ts")) == 1 && GetDriveType(fn.Left(3)) == DRIVE_CDROM) {
m_fDVD = true;
}
break;
}
- if(tp_udf_file f = udf_find_file(m_hDrive, 0, CStringA(m_files[i].fn.Mid(m_files[i].fn.Find(':')+1))))
- {
+ if(tp_udf_file f = udf_find_file(m_hDrive, 0, CStringA(m_files[i].fn.Mid(m_files[i].fn.Find(':')+1)))) {
DWORD start, end;
- if(udf_get_lba(m_hDrive, f, &start, &end))
- {
- if(BeginSession())
- {
+ if(udf_get_lba(m_hDrive, f, &start, &end)) {
+ if(BeginSession()) {
Authenticate();
m_fHasTitleKey = GetTitleKey(start + f->partition_lba, m_TitleKey);
EndSession();
@@ -488,29 +494,22 @@ bool CVobFile::Open(CAtlList<CString>& vobs, int offset)
}
BYTE key[5];
- if(HasTitleKey(key) && i == 0 && offset >= 0)
- {
+ if(HasTitleKey(key) && i == 0 && offset >= 0) {
i++;
- if(BeginSession())
- {
+ if(BeginSession()) {
m_fDVD = true;
Authenticate();
m_fHasDiscKey = GetDiscKey();
EndSession();
- }
- else
- {
+ } else {
break;
}
- if(tp_udf_file f = udf_find_file(m_hDrive, 0, CStringA(m_files[i].fn.Mid(m_files[i].fn.Find(':')+1))))
- {
+ if(tp_udf_file f = udf_find_file(m_hDrive, 0, CStringA(m_files[i].fn.Mid(m_files[i].fn.Find(':')+1)))) {
DWORD start, end;
- if(udf_get_lba(m_hDrive, f, &start, &end))
- {
- if(BeginSession())
- {
+ if(udf_get_lba(m_hDrive, f, &start, &end)) {
+ if(BeginSession()) {
Authenticate();
m_fHasTitleKey = GetTitleKey(start + f->partition_lba, m_TitleKey);
EndSession();
@@ -520,26 +519,25 @@ bool CVobFile::Open(CAtlList<CString>& vobs, int offset)
udf_free(f);
}
- if(!m_fHasTitleKey)
- {
+ if(!m_fHasTitleKey) {
memcpy(m_TitleKey, key, 5);
m_fHasTitleKey = true;
}
}
}
}
-/*
- if(m_files.GetCount() > 0 && !m_fDVD)
- {
- CString fn = m_files[0].fn;
- fn.MakeLower();
-
- if(fn.Find(_T(":\\video_ts")) == 1 && GetDriveType(fn.Left(3)) == DRIVE_CDROM)
+ /*
+ if(m_files.GetCount() > 0 && !m_fDVD)
{
- m_fDVD = true;
+ CString fn = m_files[0].fn;
+ fn.MakeLower();
+
+ if(fn.Find(_T(":\\video_ts")) == 1 && GetDriveType(fn.Left(3)) == DRIVE_CDROM)
+ {
+ m_fDVD = true;
+ }
}
- }
-*/
+ */
m_offset = max(offset, 0);
return(true);
@@ -573,13 +571,14 @@ int CVobFile::Seek(int pos)
int size = 0;
// this suxx, but won't take long
- do size += m_files[++i].size;
- while(i < m_files.GetCount() && pos >= size);
+ do {
+ size += m_files[++i].size;
+ } while(i < m_files.GetCount() && pos >= size);
- if(i != m_iFile && i < m_files.GetCount())
- {
- if(!m_file.Open(m_files[i].fn))
+ if(i != m_iFile && i < m_files.GetCount()) {
+ if(!m_file.Open(m_files[i].fn)) {
return(m_pos);
+ }
m_iFile = i;
}
@@ -594,44 +593,37 @@ int CVobFile::Seek(int pos)
bool CVobFile::Read(BYTE* buff)
{
- if(m_pos >= m_size) return(false);
+ if(m_pos >= m_size) {
+ return(false);
+ }
- if(m_file.IsOpen() && m_file.GetPosition() == m_file.GetLength())
- {
+ if(m_file.IsOpen() && m_file.GetPosition() == m_file.GetLength()) {
m_file.Close();
}
- if(!m_file.IsOpen())
- {
- if(m_iFile >= m_files.GetCount()-1)
- {
+ if(!m_file.IsOpen()) {
+ if(m_iFile >= m_files.GetCount()-1) {
return(false);
}
- if(!m_file.Open(m_files[++m_iFile].fn))
- {
- m_iFile = -1;
+ if(!m_file.Open(m_files[++m_iFile].fn)) {
+ m_iFile = -1;
return(false);
}
}
- if(!m_file.Read(buff))
- {
+ if(!m_file.Read(buff)) {
// dvd still locked?
return(false);
}
m_pos++;
- if(buff[0x14] & 0x30)
- {
- if(m_fHasTitleKey)
- {
+ if(buff[0x14] & 0x30) {
+ if(m_fHasTitleKey) {
CSSdescramble(buff, m_TitleKey);
buff[0x14] &= ~0x30;
- }
- else
- {
+ } else {
// under win9x this is normal, but I'm not developing under win9x :P
ASSERT(0);
}
diff --git a/src/DeCSS/VobFile.h b/src/DeCSS/VobFile.h
index c5f083851..922b5d727 100644
--- a/src/DeCSS/VobFile.h
+++ b/src/DeCSS/VobFile.h
@@ -30,8 +30,12 @@ public:
bool Open(LPCTSTR path);
void Close();
- operator HANDLE() const {return m_hDrive;}
- operator DVD_SESSION_ID() const {return m_session;}
+ operator HANDLE() const {
+ return m_hDrive;
+ }
+ operator DVD_SESSION_ID() const {
+ return m_session;
+ }
bool SendKey(DVD_KEY_TYPE KeyType, BYTE* pKeyData);
bool ReadKey(DVD_KEY_TYPE KeyType, BYTE* pKeyData, int lba = 0);
@@ -57,7 +61,10 @@ public:
class CVobFile : public CDVDSession
{
// all files
- typedef struct {CString fn; int size;} file_t;
+ typedef struct {
+ CString fn;
+ int size;
+ } file_t;
CAtlArray<file_t> m_files;
int m_iFile;
int m_pos, m_size, m_offset;
diff --git a/src/DeCSS/udf.cpp b/src/DeCSS/udf.cpp
index c021ccf83..eb2d310c0 100644
--- a/src/DeCSS/udf.cpp
+++ b/src/DeCSS/udf.cpp
@@ -23,17 +23,16 @@ static bool aspi_ReadSectors(const HANDLE hDrive, int lba, int nSectors, DWORD s
{
DWORD nbr = 0;
return lba*sec_size == SetFilePointer(hDrive, lba*sec_size, NULL, FILE_BEGIN)
- && ReadFile(hDrive, sector, nSectors*sec_size, &nbr, NULL);
+ && ReadFile(hDrive, sector, nSectors*sec_size, &nbr, NULL);
}
static bool udf_GetLBA(const tp_udf_FileEntry fe, const DWORD sec_size, DWORD *start, DWORD *end)
{
- if (fe->LengthofAllocationDescriptors == 0)
+ if (fe->LengthofAllocationDescriptors == 0) {
return false;
- switch (fe->ICBTag.Flags & udf_icbf_Mask)
- {
- case udf_icbf_ShortAd:
- {
+ }
+ switch (fe->ICBTag.Flags & udf_icbf_Mask) {
+ case udf_icbf_ShortAd: {
tp_udf_short_ad ad = (tp_udf_short_ad)(fe->ExtendedAttributes + fe->LengthofExtendedAttributes);
*start = ad->Location;
@@ -41,8 +40,7 @@ static bool udf_GetLBA(const tp_udf_FileEntry fe, const DWORD sec_size, DWORD *s
return true;
}
break;
- case udf_icbf_LongAd:
- {
+ case udf_icbf_LongAd: {
tp_udf_long_ad ad = (tp_udf_long_ad)(fe->ExtendedAttributes + fe->LengthofExtendedAttributes);
*start = ad->Location.Location; // ignore partition number
@@ -50,8 +48,7 @@ static bool udf_GetLBA(const tp_udf_FileEntry fe, const DWORD sec_size, DWORD *s
return true;
}
break;
- case udf_icbf_ExtAd:
- {
+ case udf_icbf_ExtAd: {
tp_udf_ext_ad ad = (tp_udf_ext_ad)(fe->ExtendedAttributes + fe->LengthofExtendedAttributes);
*start = ad->Location.Location; // ignore partition number
@@ -74,23 +71,25 @@ tp_udf_file udf_get_root(const HANDLE hDrive, const WORD partition_number)
tp_udf_AnchorVolumeDescriptorPointer avd;
bool res, part_valid, vol_valid;
- if (!aspi_GetSectorInfo(hDrive, &sec_size, &max_sec))
+ if (!aspi_GetSectorInfo(hDrive, &sec_size, &max_sec)) {
return NULL;
+ }
- if (sec_size != fio_SECTOR_SIZE || max_sec < 256)
+ if (sec_size != fio_SECTOR_SIZE || max_sec < 256) {
return NULL;
-
+ }
+
// read AnchorVolumeDescriptorPointer at 256 (or MaxSec) (Tag == 2)
res = aspi_ReadSectors(hDrive, 256, 1, sec_size, sector);
- if (!res || tag->TagIdentifier != udf_TAG_AnchorVolumeDescriptor)
- {
+ if (!res || tag->TagIdentifier != udf_TAG_AnchorVolumeDescriptor) {
res = aspi_ReadSectors(hDrive, max_sec, 1, sec_size, sector);
- if (!res || tag->TagIdentifier != udf_TAG_AnchorVolumeDescriptor)
+ if (!res || tag->TagIdentifier != udf_TAG_AnchorVolumeDescriptor) {
return NULL;
+ }
}
-
+
// check Static Structures
-
+
// get MainVolumeDescriptorSequence Location & Length
avd = (tp_udf_AnchorVolumeDescriptorPointer)sector;
MVDS_lba = avd->MainVolumeDescriptorSequenceExtent.Location;
@@ -102,65 +101,58 @@ tp_udf_file udf_get_root(const HANDLE hDrive, const WORD partition_number)
part_valid = vol_valid = false;
i = 1;
- do
- { // try twice (if we need to) for ReserveAnchor
+ do {
+ // try twice (if we need to) for ReserveAnchor
j = MVDS_lba;
- do
- {
+ do {
res = aspi_ReadSectors(hDrive, j++, 1, sec_size, sector);
- if (res)
- {
- if (tag->TagIdentifier == udf_TAG_PartitionDescriptor && !part_valid)
- { // get stuff out of partition
+ if (res) {
+ if (tag->TagIdentifier == udf_TAG_PartitionDescriptor && !part_valid) {
+ // get stuff out of partition
tp_udf_PartitionDescriptor par = (tp_udf_PartitionDescriptor )sector;
part_valid = par->PartitionNumber == partition_number;
- if (part_valid)
- { // extract par->PartitionStartingLocation, par->PartitionLength
+ if (part_valid) {
+ // extract par->PartitionStartingLocation, par->PartitionLength
partition_lba = par->PartitionStartingLocation;
}
- }
- else if (tag->TagIdentifier == udf_TAG_LogicalVolumeDescriptor && !vol_valid)
- { // get stuff out of volume
+ } else if (tag->TagIdentifier == udf_TAG_LogicalVolumeDescriptor && !vol_valid) {
+ // get stuff out of volume
tp_udf_LogicalVolumeDescriptor vol = (tp_udf_LogicalVolumeDescriptor)sector;
// check_volume sector size
vol_valid = (vol->LogicalBlockSize == sec_size) && (partition_number == vol->FileSetDescriptorSequence.Location.PartitionNumber);
- if (vol_valid)
- { // extract vol->FileSetDescriptorSequence
+ if (vol_valid) {
+ // extract vol->FileSetDescriptorSequence
FileDescriptorSequence_lba = vol->FileSetDescriptorSequence.Location.Location;
FileDescriptorSequence_lba_end = FileDescriptorSequence_lba + ((vol->FileSetDescriptorSequence.Length & udf_LengthMask) - 1) / sec_size;
}
}
- }
- else
+ } else {
tag->TagIdentifier = 0;
+ }
} while (j <= MVDS_lba_end && tag->TagIdentifier != udf_TAG_TerminatingDescriptor && ((!part_valid) || (!vol_valid)));
- if ((!part_valid) || (!vol_valid))
- { // try backup
+ if ((!part_valid) || (!vol_valid)) {
+ // try backup
MVDS_lba = MVDS_back_lba;
MVDS_lba_end = MVDS_back_lba_end;
}
} while (i-- && ((!part_valid) || (!vol_valid)));
- if (part_valid && vol_valid)
- { // read FileSetDescriptor, get RootDir Location & Length, RootDir Length != 0
+ if (part_valid && vol_valid) {
+ // read FileSetDescriptor, get RootDir Location & Length, RootDir Length != 0
res = aspi_ReadSectors(hDrive, FileDescriptorSequence_lba + partition_lba, 1, sec_size, sector);
- if (res && tag->TagIdentifier == udf_TAG_FileSetDescriptor)
- {
+ if (res && tag->TagIdentifier == udf_TAG_FileSetDescriptor) {
tp_udf_FileSetDescriptor fsd = (tp_udf_FileSetDescriptor)sector;
- if (partition_number == fsd->RootDirectoryICB.Location.PartitionNumber)
- {
+ if (partition_number == fsd->RootDirectoryICB.Location.PartitionNumber) {
parent_icb = fsd->RootDirectoryICB.Location.Location;
res = aspi_ReadSectors(hDrive, partition_lba + parent_icb, 1, sec_size, sector);
- if (res && tag->TagIdentifier == udf_TAG_FileEntry)
- {
+ if (res && tag->TagIdentifier == udf_TAG_FileEntry) {
tp_udf_FileEntry fe = (tp_udf_FileEntry)sector;
- if (fe->ICBTag.FileType == udf_FT_Directory)
- {
+ if (fe->ICBTag.FileType == udf_FT_Directory) {
tp_udf_file root = (tp_udf_file)malloc(sizeof *root);
root->partition_lba = partition_lba;
@@ -178,7 +170,7 @@ tp_udf_file udf_get_root(const HANDLE hDrive, const WORD partition_number)
}
}
}
-
+
return NULL;
}
@@ -186,20 +178,21 @@ static void udf_GetName(const BYTE *data, const DWORD len, char *target)
{
DWORD p = 1, i = 0;
- if (len == 0 || !(data[0] & 0x18))
+ if (len == 0 || !(data[0] & 0x18)) {
target[0] = '\0';
+ }
- if (data[0] & 0x10)
- { // ignore MSB of unicode16
+ if (data[0] & 0x10) {
+ // ignore MSB of unicode16
p++;
- while (p < len)
+ while (p < len) {
target[i++] = data[p += 2];
- }
- else
- {
- while (p < len)
+ }
+ } else {
+ while (p < len) {
target[i++] = data[p++];
+ }
}
target[i]='\0';
@@ -207,22 +200,21 @@ static void udf_GetName(const BYTE *data, const DWORD len, char *target)
tp_udf_file udf_get_sub(const HANDLE hDrive, tp_udf_file f)
{
- if (f->is_dir && !f->is_parent && f->fid)
- {
+ if (f->is_dir && !f->is_parent && f->fid) {
BYTE sector[fio_SECTOR_SIZE];
tp_udf_tag tag = (tp_udf_tag)sector;
bool res;
res = aspi_ReadSectors(hDrive, f->partition_lba + f->fid->ICB.Location.Location, 1, f->sec_size, sector);
- if (res && tag->TagIdentifier == udf_TAG_FileEntry)
- {
+ if (res && tag->TagIdentifier == udf_TAG_FileEntry) {
tp_udf_FileEntry fe = (tp_udf_FileEntry)sector;
- if (fe->ICBTag.FileType == udf_FT_Directory)
- {
+ if (fe->ICBTag.FileType == udf_FT_Directory) {
tp_udf_file newf = (tp_udf_file)malloc(sizeof *newf);
- if (newf == NULL) return NULL;
+ if (newf == NULL) {
+ return NULL;
+ }
memset(newf, 0, sizeof(*newf));
strcpy(newf->name, f->name); // maybe just ""?
@@ -245,34 +237,33 @@ tp_udf_file udf_get_next(const HANDLE hDrive, tp_udf_file f)
{
bool res = true;
- if (f->dir_left <= 0)
- {
+ if (f->dir_left <= 0) {
f->fid = NULL;
return NULL;
}
-
- if (f->fid)
- { // advance to next FileIdentifierDescriptor
+
+ if (f->fid) {
+ // advance to next FileIdentifierDescriptor
DWORD ofs = 4 * ((sizeof *(f->fid) + f->fid->LengthofImplementationUse + f->fid->LengthofFileIdentifier + 3) / 4);
f->fid = (tp_udf_FileIdentifierDescriptor)((BYTE *)f->fid + ofs);
}
-
- if (f->fid == NULL)
- {
+
+ if (f->fid == NULL) {
DWORD size = f->sec_size * (f->dir_end_lba - f->dir_lba + 1);
- if (!f->sector)
+ if (!f->sector) {
f->sector = (BYTE*)malloc(size);
+ }
res = aspi_ReadSectors(hDrive, f->partition_lba + f->dir_lba, (WORD)(f->dir_end_lba - f->dir_lba + 1), f->sec_size, f->sector);
- if (res)
+ if (res) {
f->fid = (tp_udf_FileIdentifierDescriptor)f->sector;
- else
+ } else {
f->fid = NULL;
+ }
}
-
- if (f->fid && f->fid->DescriptorTag.TagIdentifier == udf_TAG_FileIdentifierDescriptor)
- {
+
+ if (f->fid && f->fid->DescriptorTag.TagIdentifier == udf_TAG_FileIdentifierDescriptor) {
DWORD ofs = 4 * ((sizeof *f->fid + f->fid->LengthofImplementationUse + f->fid->LengthofFileIdentifier + 3) / 4);
f->dir_left -= ofs;
@@ -286,10 +277,10 @@ tp_udf_file udf_get_next(const HANDLE hDrive, tp_udf_file f)
void udf_free(tp_udf_file f)
{
- if (f)
- {
- if (f->sector)
+ if (f) {
+ if (f->sector) {
free(f->sector);
+ }
free(f);
}
}
@@ -298,24 +289,21 @@ void udf_free(tp_udf_file f)
static tp_udf_file udf_ff_traverse(const HANDLE hDrive, tp_udf_file f, char *token)
{
- while (udf_get_next(hDrive, f))
- {
- if (stricmp(token, f->name) == 0)
- {
+ while (udf_get_next(hDrive, f)) {
+ if (stricmp(token, f->name) == 0) {
char *next_tok = strtok(NULL, udf_PATH_DELIMITERS);
- if (!next_tok)
- return f; // found
- else if (f->is_dir)
- {
+ if (!next_tok) {
+ return f; // found
+ } else if (f->is_dir) {
tp_udf_file f2 = udf_get_sub(hDrive, f);
- if (f2)
- {
+ if (f2) {
tp_udf_file f3 = udf_ff_traverse(hDrive, f2, next_tok);
- if (!f3)
+ if (!f3) {
udf_free(f2);
+ }
return f3;
}
}
@@ -328,15 +316,15 @@ tp_udf_file udf_find_file(const HANDLE hDrive, const WORD partition, const char
{
tp_udf_file f = udf_get_root(hDrive, partition), f2 = NULL;
- if (f)
- {
+ if (f) {
char tokenline[udf_MAX_PATHLEN];
char *token;
strcpy(tokenline, name);
token = strtok(tokenline, udf_PATH_DELIMITERS);
- if (token)
+ if (token) {
f2 = udf_ff_traverse(hDrive, f, token);
+ }
udf_free(f);
}
return f2;
@@ -344,15 +332,15 @@ tp_udf_file udf_find_file(const HANDLE hDrive, const WORD partition, const char
bool udf_get_lba(const HANDLE hDrive, const tp_udf_file f, DWORD *start_lba, DWORD *end_lba)
{
- if (f->fid)
- {
+ if (f->fid) {
BYTE sector[2048];
tp_udf_FileEntry fe = (tp_udf_FileEntry)sector;
bool res;
res = aspi_ReadSectors(hDrive, f->partition_lba + f->fid->ICB.Location.Location, 1, f->sec_size, sector);
- if (res && fe->DescriptorTag.TagIdentifier == udf_TAG_FileEntry)
+ if (res && fe->DescriptorTag.TagIdentifier == udf_TAG_FileEntry) {
return udf_GetLBA(fe, f->sec_size, start_lba, end_lba);
+ }
}
return false;
}
diff --git a/src/DeCSS/udf.h b/src/DeCSS/udf.h
index c108f59d1..603f6b150 100644
--- a/src/DeCSS/udf.h
+++ b/src/DeCSS/udf.h
@@ -39,33 +39,28 @@ typedef char dstring; // last BYTE of string indicates encoding/length
#pragma pack(push, 1)
-typedef struct
-{
+typedef struct {
DWORD Length; // 00, high 2 bits: 0 ^= recorded & used, 1 ^= not recorded & used, 2 ^= not recorded & not used, 3 ^= linked list
DWORD Location; // 04
} t_udf_short_ad, *tp_udf_short_ad; // 08
-typedef struct
-{
+typedef struct {
DWORD Length; // 00
DWORD Location; // 04
} t_udf_extent_ad, *tp_udf_extent_ad; // 08
-typedef struct
-{
+typedef struct {
DWORD Location; // 00, relative to volume
WORD PartitionNumber; // 04
} t_udf_lb_addr; // 06
-typedef struct
-{
+typedef struct {
DWORD Length; // 00, high 2 bits: 0 ^= recorded & used, 1 ^= not recorded & used, 2 ^= not recorded & not used, 3 ^= linked list
t_udf_lb_addr Location; // 04
BYTE ImplementationUse[6]; // 10
} t_udf_long_ad, *tp_udf_long_ad; // 16
-typedef struct
-{
+typedef struct {
DWORD Length; // 00, high 2 bits: 0 ^= recorded & used, 1 ^= not recorded & used, 2 ^= not recorded & not used, 3 ^= linked list
DWORD RecordedLength; // 04
DWORD InformationLength; // 08
@@ -73,14 +68,13 @@ typedef struct
BYTE ImplementationUse[2]; // 18
} t_udf_ext_ad, *tp_udf_ext_ad; // 20
-typedef struct
-{
+typedef struct {
BYTE CharacterSetType; // 00
BYTE CharacterSetInfo[63]; // 01
} t_udf_charspec; // 64
-typedef struct
-{ /* ECMA 167 1/7.3 */
+typedef struct {
+ /* ECMA 167 1/7.3 */
WORD TypeAndTimezone; // 00
WORD Year; // 02
BYTE Month; // 04
@@ -93,8 +87,8 @@ typedef struct
BYTE Microseconds; // 11
} t_udf_timestamp; // 12
-typedef struct
-{ /* ISO 13346 3/7.2 */
+typedef struct {
+ /* ISO 13346 3/7.2 */
WORD TagIdentifier; // 00
WORD DescriptorVersion; // 02
BYTE TagChecksum; // 04
@@ -105,30 +99,30 @@ typedef struct
DWORD TagLocation; // 12
} t_udf_tag, *tp_udf_tag; // 16
-typedef struct
-{ /* ISO 13346 1/7.4 */
+typedef struct {
+ /* ISO 13346 1/7.4 */
BYTE Flags; // 00
char Identifier[23]; // 01
char IdentifierSuffix[8]; // 24
} t_udf_EntityID; // 32
-typedef struct
-{ /* ISO 13346 3/10.2 */
+typedef struct {
+ /* ISO 13346 3/10.2 */
t_udf_tag DescriptorTag; // 00
t_udf_extent_ad MainVolumeDescriptorSequenceExtent; // 16
t_udf_extent_ad ReserveVolumeDescriptorSequenceExtent; // 24
BYTE Reserved[480]; // 32
} t_udf_AnchorVolumeDescriptorPointer, *tp_udf_AnchorVolumeDescriptorPointer; // 512
-typedef struct
-{ /* ISO 13346 3/10.6 */
+typedef struct {
+ /* ISO 13346 3/10.6 */
t_udf_tag DescriptorTag; // 00
DWORD VolumeDescriptorSequenceNumber; // 16
t_udf_charspec DescriptorCharacterSet; // 20
dstring LogicalVolumeIdentifier[128]; // 84
DWORD LogicalBlockSize; // 212
t_udf_EntityID DomainIdentifier; // 244
-// BYTE LogicalVolumeContentsUse[16]; // 276
+ // BYTE LogicalVolumeContentsUse[16]; // 276
t_udf_long_ad FileSetDescriptorSequence; // 276
DWORD MapTableLength; // 292
DWORD NumberofPartitionMaps; // 296
@@ -138,8 +132,7 @@ typedef struct
BYTE PartitionMaps[1]; // 468
} t_udf_LogicalVolumeDescriptor, *tp_udf_LogicalVolumeDescriptor;
-typedef struct
-{
+typedef struct {
t_udf_short_ad UnallocatedSpaceTable; // 00
t_udf_short_ad UnallocatedSpaceBitmap; // 08
t_udf_short_ad PartitionIntegrityTable; // 16
@@ -148,8 +141,8 @@ typedef struct
BYTE Reserved[88]; // 40
} t_udf_PartitionHeaderDescriptor; // 128
-typedef struct
-{ /* ECMA 167 3/10.5 */
+typedef struct {
+ /* ECMA 167 3/10.5 */
t_udf_tag DescriptorTag; // 00
DWORD VolumeDescriptorSequenceNumber; // 16
WORD PartitionFlags; // 20
@@ -164,8 +157,8 @@ typedef struct
BYTE Reserved[156]; // 356
} t_udf_PartitionDescriptor, *tp_udf_PartitionDescriptor; // 512
-typedef struct
-{ /* ECMA 167 4/14.1 */
+typedef struct {
+ /* ECMA 167 4/14.1 */
t_udf_tag DescriptorTag; // 00
t_udf_timestamp RecordingDateandTime; // 16
WORD InterchangeLevel; // 28
@@ -187,8 +180,8 @@ typedef struct
BYTE Reserved[32]; // 480
} t_udf_FileSetDescriptor, *tp_udf_FileSetDescriptor; // 512
-typedef struct
-{ /* ECMA 167 4/14.6 */
+typedef struct {
+ /* ECMA 167 4/14.6 */
DWORD PriorRecordedNumberofDirectEntries; // 00
WORD StrategyType; // 04
BYTE StrategyParameter[2]; // 06
@@ -199,8 +192,8 @@ typedef struct
WORD Flags; // 18
} t_udf_icbtag; // 20
-typedef struct
-{ /* ECMA 167 4/14.9 */
+typedef struct {
+ /* ECMA 167 4/14.9 */
t_udf_tag DescriptorTag; // 00
t_udf_icbtag ICBTag; // 16
DWORD Uid; // 36
@@ -222,11 +215,11 @@ typedef struct
DWORD LengthofExtendedAttributes; // 168
DWORD LengthofAllocationDescriptors; // 172
BYTE ExtendedAttributes[]; // 176
-// BYTE AllocationDescriptors[]; // 176
+ // BYTE AllocationDescriptors[]; // 176
} t_udf_FileEntry, *tp_udf_FileEntry; // >= 176
-typedef struct
-{ /* ECMA 167 4/14.4 */
+typedef struct {
+ /* ECMA 167 4/14.4 */
t_udf_tag DescriptorTag; // 00
WORD FileVersionNumber; // 16
BYTE FileCharacteristics; // 18
@@ -234,15 +227,14 @@ typedef struct
t_udf_long_ad ICB; // 20
WORD LengthofImplementationUse; // 36
BYTE ImplementationUse[]; // 38
-// char FileIdentifier[]; // 38
-// BYTE Padding[]; // 38
+ // char FileIdentifier[]; // 38
+ // BYTE Padding[]; // 38
} t_udf_FileIdentifierDescriptor, *tp_udf_FileIdentifierDescriptor; // >= 38
#define udf_MAX_NAMELEN 256
#define udf_MAX_PATHLEN 2048
-typedef struct
-{
+typedef struct {
// public
char name[udf_MAX_NAMELEN];
bool is_dir, is_parent;
diff --git a/src/SubPic/CoordGeom.cpp b/src/SubPic/CoordGeom.cpp
index 018fb495a..dde63e033 100644
--- a/src/SubPic/CoordGeom.cpp
+++ b/src/SubPic/CoordGeom.cpp
@@ -75,7 +75,9 @@ Vector Vector::Pow(float exp)
Vector Vector::Unit()
{
float l = Length();
- if(!l || l == 1) return(*this);
+ if(!l || l == 1) {
+ return(*this);
+ }
return(*this * (1 / l));
}
@@ -106,9 +108,13 @@ void Vector::Angle(float& u, float& v)
u = asin(n.y);
- if(IsZero(n.z)) v = 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) ? PI : (PI * Sgn(n.x) + atan(n.x / n.z));
+ if(IsZero(n.z)) {
+ v = 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) ? PI : (PI * Sgn(n.x) + atan(n.x / n.z));
+ }
}
Vector Vector::Angle()
@@ -157,8 +163,7 @@ Vector Vector::Refract(Vector& N, float nFront, float nBack, float* nOut)
float len_sin_T = sin_T | sin_T;
- if(len_sin_T > 1)
- {
+ if(len_sin_T > 1) {
if(nOut) {
*nOut = N_dot_D >= 0 ? nFront : nBack;
}
@@ -166,7 +171,9 @@ Vector Vector::Refract(Vector& N, float nFront, float nBack, float* nOut)
}
float N_dot_T = sqrt(1.0 - len_sin_T);
- if(N_dot_D < 0) N_dot_T = -N_dot_T;
+ if(N_dot_D < 0) {
+ N_dot_T = -N_dot_T;
+ }
if(nOut) {
*nOut = N_dot_D >= 0 ? nBack : nFront;
@@ -187,8 +194,7 @@ Vector Vector::Refract2(Vector& N, float nFrom, float nTo, float* nOut)
float len_sin_T = sin_T | sin_T;
- if(len_sin_T > 1)
- {
+ if(len_sin_T > 1) {
if(nOut) {
*nOut = nFrom;
}
@@ -196,7 +202,9 @@ Vector Vector::Refract2(Vector& N, float nFrom, float nTo, float* nOut)
}
float N_dot_T = sqrt(1.0 - len_sin_T);
- if(N_dot_D < 0) N_dot_T = -N_dot_T;
+ if(N_dot_D < 0) {
+ N_dot_T = -N_dot_T;
+ }
if(nOut) {
*nOut = nTo;
@@ -227,7 +235,9 @@ Vector Vector::operator - ()
bool Vector::operator == (const Vector& v) const
{
- if(IsZero(x - v.x) && IsZero(y - v.y) && IsZero(z - v.z)) return(true);
+ if(IsZero(x - v.x) && IsZero(y - v.y) && IsZero(z - v.z)) {
+ return(true);
+ }
return(false);
}
@@ -359,7 +369,9 @@ void Ray::Set(Vector& p, Vector& d)
float Ray::GetDistanceFrom(Ray& r)
{
float t = (d | r.d);
- if(IsZero(t)) return(-BIGNUMBER); // plane is paralell to the ray, return -infinite
+ if(IsZero(t)) {
+ return(-BIGNUMBER); // plane is paralell to the ray, return -infinite
+ }
return(((r.p - p) | r.d) / t);
}
@@ -393,15 +405,12 @@ void XForm::Initalize(Ray& r, Vector& s, bool isWorldToLocal)
Initalize();
m_isWorldToLocal = isWorldToLocal;
- if(isWorldToLocal)
- {
+ if(isWorldToLocal) {
*this -= r.p;
*this >>= r.d;
*this /= s;
- }
- else
- {
+ } else {
*this *= s;
*this <<= r.d;
*this += r.p;
@@ -543,16 +552,16 @@ XForm::Matrix XForm::Matrix::operator * (Matrix& m)
{
Matrix ret;
- for(ptrdiff_t i = 0; i < 4; i++)
- {
- for(ptrdiff_t j = 0; j < 4; 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;
+ }
}
}
diff --git a/src/SubPic/CoordGeom.h b/src/SubPic/CoordGeom.h
index 4b2bf9e48..7edd7aa1f 100644
--- a/src/SubPic/CoordGeom.h
+++ b/src/SubPic/CoordGeom.h
@@ -138,7 +138,7 @@ public:
void operator -= (Vector& t); // translate
void operator >>= (Vector& r); // rotate
-// transformations
+ // 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 976510f37..3296c53d3 100644
--- a/src/SubPic/DX7SubPic.cpp
+++ b/src/SubPic/DX7SubPic.cpp
@@ -36,8 +36,7 @@ CDX7SubPic::CDX7SubPic(IDirect3DDevice7* pD3DDev, IDirectDrawSurface7* pSurface)
{
DDSURFACEDESC2 ddsd;
INITDDSTRUCT(ddsd);
- if(SUCCEEDED(m_pSurface->GetSurfaceDesc(&ddsd)))
- {
+ if(SUCCEEDED(m_pSurface->GetSurfaceDesc(&ddsd))) {
m_maxsize.SetSize(ddsd.dwWidth, ddsd.dwHeight);
m_rcDirty.SetRect(0, 0, ddsd.dwWidth, ddsd.dwHeight);
}
@@ -54,8 +53,9 @@ STDMETHODIMP CDX7SubPic::GetDesc(SubPicDesc& spd)
{
DDSURFACEDESC2 ddsd;
INITDDSTRUCT(ddsd);
- if(FAILED(m_pSurface->GetSurfaceDesc(&ddsd)))
+ if(FAILED(m_pSurface->GetSurfaceDesc(&ddsd))) {
return E_FAIL;
+ }
spd.type = 0;
spd.w = m_size.cx;
@@ -71,8 +71,9 @@ STDMETHODIMP CDX7SubPic::GetDesc(SubPicDesc& spd)
STDMETHODIMP CDX7SubPic::CopyTo(ISubPic* pSubPic)
{
HRESULT hr;
- if(FAILED(hr = __super::CopyTo(pSubPic)))
+ 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);
@@ -82,8 +83,9 @@ STDMETHODIMP CDX7SubPic::CopyTo(ISubPic* pSubPic)
STDMETHODIMP CDX7SubPic::ClearDirtyRect(DWORD color)
{
- if(m_rcDirty.IsRectEmpty())
+ if(m_rcDirty.IsRectEmpty()) {
return S_FALSE;
+ }
DDBLTFX fx;
INITDDSTRUCT(fx);
@@ -99,8 +101,9 @@ STDMETHODIMP CDX7SubPic::Lock(SubPicDesc& spd)
{
DDSURFACEDESC2 ddsd;
INITDDSTRUCT(ddsd);
- if(FAILED(m_pSurface->Lock(NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR|DDLOCK_WAIT, NULL)))
+ if(FAILED(m_pSurface->Lock(NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR|DDLOCK_WAIT, NULL))) {
return E_FAIL;
+ }
spd.type = 0;
spd.w = m_size.cx;
@@ -117,14 +120,11 @@ STDMETHODIMP CDX7SubPic::Unlock(RECT* pDirtyRect)
{
m_pSurface->Unlock(NULL);
- if(pDirtyRect)
- {
+ if(pDirtyRect) {
m_rcDirty = *pDirtyRect;
m_rcDirty.InflateRect(1, 1);
m_rcDirty &= CRect(CPoint(0, 0), m_size);
- }
- else
- {
+ } else {
m_rcDirty = CRect(CPoint(0, 0), m_size);
}
@@ -135,42 +135,41 @@ STDMETHODIMP CDX7SubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget)
{
ASSERT(pTarget == NULL);
- if(!m_pD3DDev || !m_pSurface || !pSrc || !pDst)
+ if(!m_pD3DDev || !m_pSurface || !pSrc || !pDst) {
return E_POINTER;
+ }
CRect src(*pSrc), dst(*pDst);
HRESULT hr;
- do
- {
+ do {
DDSURFACEDESC2 ddsd;
INITDDSTRUCT(ddsd);
- if(FAILED(hr = m_pSurface->GetSurfaceDesc(&ddsd)))
+ if(FAILED(hr = m_pSurface->GetSurfaceDesc(&ddsd))) {
break;
+ }
float w = (float)ddsd.dwWidth;
float h = (float)ddsd.dwHeight;
- struct
- {
+ struct {
float x, y, z, rhw;
float tu, tv;
}
- pVertices[] =
- {
+ 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;
- }
-*/
+ /*
+ 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);
@@ -202,8 +201,9 @@ STDMETHODIMP CDX7SubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget)
*///
- if(FAILED(hr = m_pD3DDev->BeginScene()))
+ if(FAILED(hr = m_pD3DDev->BeginScene())) {
break;
+ }
hr = m_pD3DDev->DrawPrimitive(D3DPT_TRIANGLESTRIP,
D3DFVF_XYZRHW | D3DFVF_TEX1,
@@ -215,8 +215,7 @@ STDMETHODIMP CDX7SubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget)
m_pD3DDev->SetTexture(0, NULL);
return S_OK;
- }
- while(0);
+ } while(0);
return E_FAIL;
}
@@ -237,7 +236,9 @@ CDX7SubPicAllocator::CDX7SubPicAllocator(IDirect3DDevice7* pD3DDev, SIZE maxsize
STDMETHODIMP CDX7SubPicAllocator::ChangeDevice(IUnknown* pDev)
{
CComQIPtr<IDirect3DDevice7, &IID_IDirect3DDevice7> pD3DDev = pDev;
- if(!pD3DDev) return E_NOINTERFACE;
+ if(!pD3DDev) {
+ return E_NOINTERFACE;
+ }
CAutoLock cAutoLock(this);
m_pD3DDev = pD3DDev;
@@ -249,8 +250,9 @@ STDMETHODIMP CDX7SubPicAllocator::ChangeDevice(IUnknown* pDev)
bool CDX7SubPicAllocator::Alloc(bool fStatic, ISubPic** ppSubPic)
{
- if(!ppSubPic)
+ if(!ppSubPic) {
return(false);
+ }
CAutoLock cAutoLock(this);
@@ -269,26 +271,32 @@ bool CDX7SubPicAllocator::Alloc(bool fStatic, ISubPic** ppSubPic)
ddsd.ddpfPixelFormat.dwGBitMask = 0x0000FF00;
ddsd.ddpfPixelFormat.dwBBitMask = 0x000000FF;
- if(m_fPow2Textures)
- {
+ if(m_fPow2Textures) {
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;
+ 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))
+ if(FAILED(m_pD3DDev->GetDirect3D(&pD3D)) || !pD3D || !(pDD = pD3D)) {
return(false);
+ }
CComPtr<IDirectDrawSurface7> pSurface;
- if(FAILED(pDD->CreateSurface(&ddsd, &pSurface, NULL)))
+ if(FAILED(pDD->CreateSurface(&ddsd, &pSurface, NULL))) {
return(false);
+ }
*ppSubPic = DNew CDX7SubPic(m_pD3DDev, pSurface);
- if(!(*ppSubPic))
+ if(!(*ppSubPic)) {
return(false);
+ }
(*ppSubPic)->AddRef();
diff --git a/src/SubPic/DX9SubPic.cpp b/src/SubPic/DX9SubPic.cpp
index 54743ad1d..fa769b33d 100644
--- a/src/SubPic/DX9SubPic.cpp
+++ b/src/SubPic/DX9SubPic.cpp
@@ -35,8 +35,7 @@ CDX9SubPic::CDX9SubPic(IDirect3DSurface9* pSurface, CDX9SubPicAllocator *pAlloca
{
D3DSURFACE_DESC d3dsd;
ZeroMemory(&d3dsd, sizeof(d3dsd));
- if(SUCCEEDED(m_pSurface->GetDesc(&d3dsd)))
- {
+ if(SUCCEEDED(m_pSurface->GetDesc(&d3dsd))) {
m_maxsize.SetSize(d3dsd.Width, d3dsd.Height);
m_rcDirty.SetRect(0, 0, d3dsd.Width, d3dsd.Height);
}
@@ -47,14 +46,11 @@ CDX9SubPic::~CDX9SubPic()
{
CAutoLock Lock(&CDX9SubPicAllocator::ms_SurfaceQueueLock);
// Add surface to cache
- if (m_pAllocator)
- {
- for (POSITION pos = m_pAllocator->m_AllocatedSurfaces.GetHeadPosition(); pos; )
- {
+ 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)
- {
+ if (pSubPic == this) {
m_pAllocator->m_AllocatedSurfaces.RemoveAt(ThisPos);
break;
}
@@ -70,8 +66,9 @@ CDX9SubPic::~CDX9SubPic()
STDMETHODIMP_(void*) CDX9SubPic::GetObject()
{
CComPtr<IDirect3DTexture9> pTexture;
- if(SUCCEEDED(m_pSurface->GetContainer(IID_IDirect3DTexture9, (void**)&pTexture)))
+ if(SUCCEEDED(m_pSurface->GetContainer(IID_IDirect3DTexture9, (void**)&pTexture))) {
return (void*)(IDirect3DTexture9*)pTexture;
+ }
return NULL;
}
@@ -80,8 +77,9 @@ STDMETHODIMP CDX9SubPic::GetDesc(SubPicDesc& spd)
{
D3DSURFACE_DESC d3dsd;
ZeroMemory(&d3dsd, sizeof(d3dsd));
- if(FAILED(m_pSurface->GetDesc(&d3dsd)))
+ if(FAILED(m_pSurface->GetDesc(&d3dsd))) {
return E_FAIL;
+ }
spd.type = 0;
spd.w = m_size.cx;
@@ -99,15 +97,18 @@ STDMETHODIMP CDX9SubPic::GetDesc(SubPicDesc& spd)
STDMETHODIMP CDX9SubPic::CopyTo(ISubPic* pSubPic)
{
HRESULT hr;
- if(FAILED(hr = __super::CopyTo(pSubPic)))
+ if(FAILED(hr = __super::CopyTo(pSubPic))) {
return hr;
+ }
- if(m_rcDirty.IsRectEmpty())
+ if(m_rcDirty.IsRectEmpty()) {
return S_FALSE;
+ }
CComPtr<IDirect3DDevice9> pD3DDev;
- if(!m_pSurface || FAILED(m_pSurface->GetDevice(&pD3DDev)) || !pD3DDev)
+ if(!m_pSurface || FAILED(m_pSurface->GetDevice(&pD3DDev)) || !pD3DDev) {
return E_FAIL;
+ }
IDirect3DTexture9* pSrcTex = (IDirect3DTexture9*)GetObject();
CComPtr<IDirect3DSurface9> pSrcSurf;
@@ -125,52 +126,48 @@ STDMETHODIMP CDX9SubPic::CopyTo(ISubPic* pSubPic)
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));
+ // ASSERT (SUCCEEDED (hr));
return SUCCEEDED(hr) ? S_OK : E_FAIL;
}
STDMETHODIMP CDX9SubPic::ClearDirtyRect(DWORD color)
{
- if(m_rcDirty.IsRectEmpty())
+ if(m_rcDirty.IsRectEmpty()) {
return S_FALSE;
+ }
CComPtr<IDirect3DDevice9> pD3DDev;
- if(!m_pSurface || FAILED(m_pSurface->GetDevice(&pD3DDev)) || !pD3DDev)
+ if(!m_pSurface || FAILED(m_pSurface->GetDevice(&pD3DDev)) || !pD3DDev) {
return E_FAIL;
+ }
SubPicDesc spd;
- if(SUCCEEDED(Lock(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)
- {
+ if(spd.bpp == 16) {
+ while(h-- > 0) {
memsetw(ptr, color, 2 * m_rcDirty.Width());
ptr += spd.pitch;
}
- }
- else if(spd.bpp == 32)
- {
- while(h-- > 0)
- {
+ } 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;
-*/
+ /*
+ 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);
+ // HRESULT hr = pD3DDev->ColorFill(m_pSurface, m_rcDirty, color);
m_rcDirty.SetRectEmpty();
@@ -181,13 +178,15 @@ STDMETHODIMP CDX9SubPic::Lock(SubPicDesc& spd)
{
D3DSURFACE_DESC d3dsd;
ZeroMemory(&d3dsd, sizeof(d3dsd));
- if(FAILED(m_pSurface->GetDesc(&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)))
+ if(FAILED(m_pSurface->LockRect(&LockedRect, NULL, D3DLOCK_NO_DIRTY_UPDATE|D3DLOCK_NOSYSLOCK))) {
return E_FAIL;
+ }
spd.type = 0;
spd.w = m_size.cx;
@@ -206,11 +205,9 @@ STDMETHODIMP CDX9SubPic::Unlock(RECT* pDirtyRect)
{
HRESULT hr = m_pSurface->UnlockRect();
- if(pDirtyRect)
- {
+ if(pDirtyRect) {
m_rcDirty = *pDirtyRect;
- if (!((CRect*)pDirtyRect)->IsRectEmpty())
- {
+ if (!((CRect*)pDirtyRect)->IsRectEmpty()) {
m_rcDirty.InflateRect(1, 1);
m_rcDirty.left &= ~127;
m_rcDirty.top &= ~63;
@@ -218,15 +215,14 @@ STDMETHODIMP CDX9SubPic::Unlock(RECT* pDirtyRect)
m_rcDirty.bottom = (m_rcDirty.bottom + 63) & ~63;
m_rcDirty &= CRect(CPoint(0, 0), m_size);
}
- }
- else
- {
+ } else {
m_rcDirty = CRect(CPoint(0, 0), m_size);
}
CComPtr<IDirect3DTexture9> pTexture = (IDirect3DTexture9*)GetObject();
- if (pTexture && !((CRect*)pDirtyRect)->IsRectEmpty())
+ if (pTexture && !((CRect*)pDirtyRect)->IsRectEmpty()) {
hr = pTexture->AddDirtyRect(&m_rcDirty);
+ }
return S_OK;
}
@@ -235,47 +231,47 @@ STDMETHODIMP CDX9SubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget)
{
ASSERT(pTarget == NULL);
- if(!pSrc || !pDst)
+ 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)
+ if(!pTexture || FAILED(pTexture->GetDevice(&pD3DDev)) || !pD3DDev) {
return E_NOINTERFACE;
+ }
HRESULT hr;
- do
- {
+ do {
D3DSURFACE_DESC d3dsd;
ZeroMemory(&d3dsd, sizeof(d3dsd));
- if(FAILED(pTexture->GetLevelDesc(0, &d3dsd)) /*|| d3dsd.Type != D3DRTYPE_TEXTURE*/)
+ if(FAILED(pTexture->GetLevelDesc(0, &d3dsd)) /*|| d3dsd.Type != D3DRTYPE_TEXTURE*/) {
break;
+ }
float w = (float)d3dsd.Width;
float h = (float)d3dsd.Height;
- struct
- {
+ struct {
float x, y, z, rhw;
float tu, tv;
}
- pVertices[] =
- {
+ 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;
- }
-*/
+ /*
+ for(ptrdiff_t i = 0; i < countof(pVertices); i++)
+ {
+ pVertices[i].x -= 0.5;
+ pVertices[i].y -= 0.5;
+ }
+ */
hr = pD3DDev->SetTexture(0, pTexture);
@@ -318,13 +314,13 @@ STDMETHODIMP CDX9SubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget)
hr = pD3DDev->SetPixelShader(NULL);
-// if(FAILED(hr = pD3DDev->BeginScene()))
-// break;
+ // if(FAILED(hr = pD3DDev->BeginScene()))
+ // break;
hr = pD3DDev->SetFVF(D3DFVF_XYZRHW | D3DFVF_TEX1);
hr = pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, pVertices, sizeof(pVertices[0]));
-// hr = pD3DDev->EndScene();
+ // hr = pD3DDev->EndScene();
//
@@ -335,8 +331,7 @@ STDMETHODIMP CDX9SubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget)
pD3DDev->SetRenderState(D3DRS_DESTBLEND, db);
return S_OK;
- }
- while(0);
+ } while(0);
return E_FAIL;
}
@@ -373,8 +368,7 @@ void CDX9SubPicAllocator::ClearCache()
{
// Clear the allocator of any remaining subpics
CAutoLock Lock(&ms_SurfaceQueueLock);
- for (POSITION pos = m_AllocatedSurfaces.GetHeadPosition(); pos; )
- {
+ for (POSITION pos = m_AllocatedSurfaces.GetHeadPosition(); pos; ) {
CDX9SubPic *pSubPic = m_AllocatedSurfaces.GetNext(pos);
pSubPic->m_pAllocator = NULL;
}
@@ -389,7 +383,9 @@ STDMETHODIMP CDX9SubPicAllocator::ChangeDevice(IUnknown* pDev)
{
ClearCache();
CComQIPtr<IDirect3DDevice9> pD3DDev = pDev;
- if(!pD3DDev) return E_NOINTERFACE;
+ if(!pD3DDev) {
+ return E_NOINTERFACE;
+ }
CAutoLock cAutoLock(this);
m_pD3DDev = pD3DDev;
@@ -409,8 +405,9 @@ STDMETHODIMP CDX9SubPicAllocator::SetMaxTextureSize(SIZE MaxTextureSize)
bool CDX9SubPicAllocator::Alloc(bool fStatic, ISubPic** ppSubPic)
{
- if(!ppSubPic)
+ if(!ppSubPic) {
return(false);
+ }
CAutoLock cAutoLock(this);
@@ -421,41 +418,43 @@ bool CDX9SubPicAllocator::Alloc(bool fStatic, ISubPic** ppSubPic)
int Width = m_maxsize.cx;
int Height = m_maxsize.cy;
- if(m_fPow2Textures)
- {
+ if(m_fPow2Textures) {
Width = Height = 1;
- while(Width < m_maxsize.cx) Width <<= 1;
- while(Height < m_maxsize.cy) Height <<= 1;
+ while(Width < m_maxsize.cx) {
+ Width <<= 1;
+ }
+ while(Height < m_maxsize.cy) {
+ Height <<= 1;
+ }
}
- if (!fStatic)
- {
+ if (!fStatic) {
CAutoLock cAutoLock(&ms_SurfaceQueueLock);
POSITION FreeSurf = m_FreeSurfaces.GetHeadPosition();
- if (FreeSurf)
- {
+ if (FreeSurf) {
pSurface = m_FreeSurfaces.GetHead();
m_FreeSurfaces.RemoveHead();
}
}
- if (!pSurface)
- {
+ if (!pSurface) {
CComPtr<IDirect3DTexture9> pTexture;
- if(FAILED(m_pD3DDev->CreateTexture(Width, Height, 1, 0, D3DFMT_A8R8G8B8, fStatic?D3DPOOL_SYSTEMMEM:D3DPOOL_DEFAULT, &pTexture, NULL)))
+ 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)))
+ if(FAILED(pTexture->GetSurfaceLevel(0, &pSurface))) {
return(false);
+ }
}
*ppSubPic = DNew CDX9SubPic(pSurface, fStatic ? 0 : this);
- if(!(*ppSubPic))
+ if(!(*ppSubPic)) {
return(false);
+ }
(*ppSubPic)->AddRef();
- if (!fStatic)
- {
+ if (!fStatic) {
CAutoLock cAutoLock(&ms_SurfaceQueueLock);
m_AllocatedSurfaces.AddHead((CDX9SubPic *)*ppSubPic);
}
diff --git a/src/SubPic/DX9SubPic.h b/src/SubPic/DX9SubPic.h
index a1abf02a8..e6fac0c32 100644
--- a/src/SubPic/DX9SubPic.h
+++ b/src/SubPic/DX9SubPic.h
@@ -48,22 +48,19 @@ public:
class TCLocker
{
public:
- static void fs_Locker(void *_pLock)
- {
+ static void fs_Locker(void *_pLock) {
((t_Lock *)_pLock)->Unlock();
}
};
template <typename t_Lock>
- CScopeLock(t_Lock &_Lock)
- {
+ CScopeLock(t_Lock &_Lock) {
_Lock.Lock();
m_pLock = &_Lock;
m_pUnlockFunc = TCLocker<t_Lock>::fs_Locker;
}
- ~CScopeLock()
- {
+ ~CScopeLock() {
m_pUnlockFunc(m_pLock);
}
};
diff --git a/src/SubPic/ISubPic.h b/src/SubPic/ISubPic.h
index 87fde2191..826e8ba77 100644
--- a/src/SubPic/ISubPic.h
+++ b/src/SubPic/ISubPic.h
@@ -28,8 +28,7 @@
#include "CoordGeom.h"
#pragma pack(push, 1)
-struct SubPicDesc
-{
+struct SubPicDesc {
int type;
int w, h, bpp, pitch, pitchUV;
void* bits;
@@ -52,8 +51,7 @@ struct SubPicDesc
interface __declspec(uuid("449E11F3-52D1-4a27-AA61-E2733AC92CC0"))
ISubPic :
-public IUnknown
-{
+public IUnknown {
STDMETHOD_(void*, GetObject) () PURE;
STDMETHOD_(REFERENCE_TIME, GetStart) () PURE;
@@ -91,8 +89,7 @@ public IUnknown
interface __declspec(uuid("CF7C3C23-6392-4a42-9E72-0736CFF793CB"))
ISubPicAllocator :
-public IUnknown
-{
+public IUnknown {
STDMETHOD (SetCurSize) (SIZE size /*[in]*/) PURE;
STDMETHOD (SetCurVidRect) (RECT curvidrect) PURE;
@@ -112,8 +109,7 @@ public IUnknown
interface __declspec(uuid("D62B9A1A-879A-42db-AB04-88AA8F243CFD"))
ISubPicProvider :
-public IUnknown
-{
+public IUnknown {
STDMETHOD (Lock) () PURE;
STDMETHOD (Unlock) () PURE;
@@ -136,8 +132,7 @@ public IUnknown
interface __declspec(uuid("C8334466-CD1E-4ad1-9D2D-8EE8519BD180"))
ISubPicQueue :
-public IUnknown
-{
+public IUnknown {
STDMETHOD (SetSubPicProvider) (ISubPicProvider* pSubPicProvider /*[in]*/) PURE;
STDMETHOD (GetSubPicProvider) (ISubPicProvider** pSubPicProvider /*[out]*/) PURE;
@@ -158,8 +153,7 @@ public IUnknown
interface __declspec(uuid("CF75B1F0-535C-4074-8869-B15F177F944E"))
ISubPicAllocatorPresenter :
-public IUnknown
-{
+public IUnknown {
STDMETHOD (CreateRenderer) (IUnknown** ppRenderer) PURE;
STDMETHOD_(SIZE, GetVideoSize) (bool fCorrectAR = true) PURE;
@@ -184,8 +178,7 @@ public IUnknown
interface __declspec(uuid("767AEBA8-A084-488a-89C8-F6B74E53A90F"))
ISubPicAllocatorPresenter2 :
-public ISubPicAllocatorPresenter
-{
+public ISubPicAllocatorPresenter {
STDMETHOD (SetPixelShader2) (LPCSTR pSrcData, LPCSTR pTarget, bool bScreenSpace) PURE;
STDMETHOD_(SIZE, GetVisibleVideoSize) () PURE;
};
@@ -197,8 +190,7 @@ public ISubPicAllocatorPresenter
interface __declspec(uuid("DE11E2FB-02D3-45e4-A174-6B7CE2783BDB"))
ISubStream :
-public IPersist
-{
+public IPersist {
STDMETHOD_(int, GetStreamCount) () PURE;
STDMETHOD (GetStreamInfo) (int i, WCHAR** ppName, LCID* pLCID) PURE;
STDMETHOD_(int, GetStream) () PURE;
diff --git a/src/SubPic/ISubRender.h b/src/SubPic/ISubRender.h
index 4894c996b..8252604f4 100644
--- a/src/SubPic/ISubRender.h
+++ b/src/SubPic/ISubRender.h
@@ -27,8 +27,7 @@
interface __declspec(uuid("CD6D2AA5-20D3-4ebe-A8A9-34D3B00CC253"))
ISubRenderCallback :
-public IUnknown
-{
+public IUnknown {
// NULL means release current device, textures and other resources
STDMETHOD(SetDevice)(IDirect3DDevice9 *dev) = 0;
@@ -41,8 +40,7 @@ public IUnknown
interface __declspec(uuid("E602585E-C05A-4828-AC69-AF92997F2E0C"))
ISubRenderCallback2 :
-public ISubRenderCallback
-{
+public ISubRenderCallback {
STDMETHOD(RenderEx)(REFERENCE_TIME rtStart, REFERENCE_TIME rtStop,
REFERENCE_TIME AvgTimePerFrame,
int left, int top, int right, int bottom,
@@ -51,7 +49,6 @@ public ISubRenderCallback
interface __declspec(uuid("9CC7F9F7-3ED1-493c-AF65-527EA1D9947F"))
ISubRender :
-public IUnknown
-{
+public IUnknown {
STDMETHOD(SetCallback)(ISubRenderCallback *cb) = 0;
};
diff --git a/src/SubPic/MemSubPic.cpp b/src/SubPic/MemSubPic.cpp
index 77ad6b083..ba814def8 100644
--- a/src/SubPic/MemSubPic.cpp
+++ b/src/SubPic/MemSubPic.cpp
@@ -59,19 +59,19 @@ bool fColorConvInitOK = false;
void ColorConvInit()
{
- if(fColorConvInitOK) return;
+ if(fColorConvInitOK) {
+ return;
+ }
int i;
- for(i = 0; i < 256; 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++)
- {
+ for(i = 0; i < 256; i++) {
c2y_yb[i] = c2y_cyb*i;
c2y_yg[i] = c2y_cyg*i;
c2y_yr[i] = c2y_cyr*i;
@@ -135,38 +135,40 @@ STDMETHODIMP CMemSubPic::GetDesc(SubPicDesc& spd)
STDMETHODIMP CMemSubPic::CopyTo(ISubPic* pSubPic)
{
HRESULT hr;
- if(FAILED(hr = __super::CopyTo(pSubPic)))
+ if(FAILED(hr = __super::CopyTo(pSubPic))) {
return hr;
+ }
SubPicDesc src, dst;
- if(FAILED(GetDesc(src)) || FAILED(pSubPic->GetDesc(dst)))
+ if(FAILED(GetDesc(src)) || FAILED(pSubPic->GetDesc(dst))) {
return E_FAIL;
+ }
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;
- for(ptrdiff_t j = 0; j < h; j++, s += src.pitch, d += dst.pitch)
+ for(ptrdiff_t j = 0; j < h; j++, s += src.pitch, d += dst.pitch) {
memcpy(d, s, w*4);
+ }
return S_OK;
}
STDMETHODIMP CMemSubPic::ClearDirtyRect(DWORD color)
{
- if(m_rcDirty.IsRectEmpty())
+ 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)
- {
+ 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
#else
- __asm
- {
+ __asm {
mov eax, color
mov ecx, w
mov edi, p
@@ -190,20 +192,18 @@ STDMETHODIMP CMemSubPic::Unlock(RECT* pDirtyRect)
{
m_rcDirty = pDirtyRect ? *pDirtyRect : CRect(0,0,m_spd.w,m_spd.h);
- if(m_rcDirty.IsRectEmpty())
+ 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)
- {
+ 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)
- {
+ 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)
- {
+ if(m_spd.type == MSP_YV12 || m_spd.type == MSP_IYUV) {
m_rcDirty.top &= ~1;
m_rcDirty.bottom = (m_rcDirty.bottom+1)&~1;
}
@@ -215,42 +215,30 @@ STDMETHODIMP CMemSubPic::Unlock(RECT* pDirtyRect)
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)
- {
+ 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++)
- {
+ 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);
+ // *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)
- {
+ } 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++)
- {
+ 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);
+ // *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)
- {
+ } 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)
- {
+ 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;
@@ -258,33 +246,24 @@ STDMETHODIMP CMemSubPic::Unlock(RECT* pDirtyRect)
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
- {
+ } 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)
- {
+ } 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)
- {
+ 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
- {
+ } else {
s[0] = s[1] = 0x80;
s[2] = 0x10;
}
@@ -305,13 +284,10 @@ void AlphaBlt_YUY2_SSE2(int w, int h, BYTE* d, int dstpitch, BYTE* s, int srcpit
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++)
- {
+ 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)
- {
+ if(ia < 0xff) {
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];
@@ -348,17 +324,13 @@ void AlphaBlt_YUY2_MMX(int w, int h, BYTE* d, int dstpitch, BYTE* s, int srcpitc
static const __int64 _8181 = 0x0080001000800010i64;
- for(ptrdiff_t j = 0; j < h; j++, s += srcpitch, d += dstpitch)
- {
- for(; s2 < s2end; s2 += 8, d2++)
- {
+ 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)
- {
+ if(ia < 0xff) {
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
- {
+ __asm {
mov esi, s2
mov edi, d2
pxor mm0, mm0
@@ -392,13 +364,10 @@ void AlphaBlt_YUY2_C(int w, int h, BYTE* d, int dstpitch, BYTE* s, int srcpitch)
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++)
- {
+ 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)
- {
+ if(ia < 0xff) {
c = (s2[4]<<24)|(s2[5]<<16)|(s2[0]<<8)|s2[1]; // (v<<24)|(y2<<16)|(u<<8)|y1;
// YUY2 colorspace fix. rewrited from sse2 asm
@@ -416,192 +385,165 @@ STDMETHODIMP CMemSubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget)
{
ASSERT(pTarget);
- if(!pSrc || !pDst || !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)
+ if(src.type != dst.type) {
return E_INVALIDARG;
+ }
CRect rs(*pSrc), rd(*pDst);
- if(dst.h < 0)
- {
+ 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()))
+ 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(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)
- {
+ || 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)
- {
+ } else if(dst.type == MSP_YV12 || dst.type == MSP_IYUV) {
d = (BYTE*)dst.bits + dst.pitch*(rd.top-1) + (rd.left*8>>3);
- }
- else
- {
+ } 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)
- {
+ 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++)
- {
-#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);
+ 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);
+ }
#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_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_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_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_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 = 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];
+ 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;
+ break;
+ default:
+ return E_NOTIMPL;
}
dst.pitch = abs(dst.pitch);
- if(dst.type == MSP_YV12 || dst.type == MSP_IYUV)
- {
+ if(dst.type == MSP_YV12 || dst.type == MSP_IYUV) {
int h2 = h/2;
- if(!dst.pitchUV)
- {
+ if(!dst.pitchUV) {
dst.pitchUV = dst.pitch/2;
}
@@ -609,13 +551,11 @@ STDMETHODIMP CMemSubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget)
ss[0] = (BYTE*)src.bits + src.pitch*rs.top + rs.left*4;
ss[1] = ss[0] + 4;
- if(!dst.bitsU || !dst.bitsV)
- {
+ 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)
- {
+ if(dst.type == MSP_YV12) {
BYTE* p = dst.bitsU;
dst.bitsU = dst.bitsV;
dst.bitsV = p;
@@ -626,29 +566,24 @@ STDMETHODIMP CMemSubPic::AlphaBlt(RECT* pSrc, RECT* pDst, SubPicDesc* pTarget)
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)
- {
+ 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++)
- {
+ 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)
- {
+ 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)
- {
+ 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)
- {
+ if(ia < 0xff) {
*d2 = (((*d2-0x80)*ia)>>8) + ((s2[0]+s2[src.pitch])>>1);
}
}
@@ -679,8 +614,9 @@ CMemSubPicAllocator::CMemSubPicAllocator(int type, SIZE maxsize)
bool CMemSubPicAllocator::Alloc(bool fStatic, ISubPic** ppSubPic)
{
- if(!ppSubPic)
+ if(!ppSubPic) {
return(false);
+ }
SubPicDesc spd;
spd.w = m_maxsize.cx;
@@ -689,12 +625,14 @@ bool CMemSubPicAllocator::Alloc(bool fStatic, ISubPic** ppSubPic)
spd.pitch = (spd.w*spd.bpp)>>3;
spd.type = m_type;
spd.bits = DNew BYTE[spd.pitch*spd.h];
- if(!spd.bits)
+ if(!spd.bits) {
return(false);
+ }
*ppSubPic = DNew CMemSubPic(spd);
- if(!(*ppSubPic))
+ if(!(*ppSubPic)) {
return(false);
+ }
(*ppSubPic)->AddRef();
diff --git a/src/SubPic/SubPicAllocatorPresenterImpl.cpp b/src/SubPic/SubPicAllocatorPresenterImpl.cpp
index 936940d14..2d90c85fd 100644
--- a/src/SubPic/SubPicAllocatorPresenterImpl.cpp
+++ b/src/SubPic/SubPicAllocatorPresenterImpl.cpp
@@ -35,11 +35,11 @@ CSubPicAllocatorPresenterImpl::CSubPicAllocatorPresenterImpl(HWND hWnd, HRESULT&
, m_bDeviceResetRequested(false)
, m_bPendingResetDevice(false)
{
- if(!IsWindow(m_hWnd))
- {
+ if(!IsWindow(m_hWnd)) {
hr = E_INVALIDARG;
- if (_pError)
+ if (_pError) {
*_pError += "Invalid window handle in ISubPicAllocatorPresenterImpl\n";
+ }
return;
}
GetWindowRect(m_hWnd, &m_WindowRect);
@@ -63,31 +63,31 @@ STDMETHODIMP CSubPicAllocatorPresenterImpl::NonDelegatingQueryInterface(REFIID r
void CSubPicAllocatorPresenterImpl::AlphaBltSubPic(CSize size, SubPicDesc* pTarget)
{
CComPtr<ISubPic> pSubPic;
- if(m_pSubPicQueue->LookupSubPic(m_rtNow, pSubPic))
- {
+ if(m_pSubPicQueue->LookupSubPic(m_rtNow, pSubPic)) {
CRect rcSource, rcDest;
- if (SUCCEEDED (pSubPic->GetSourceAndDest(&size, 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);
}
-*/
+ /* 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);
+ }
+ */
}
}
@@ -97,8 +97,9 @@ STDMETHODIMP_(SIZE) CSubPicAllocatorPresenterImpl::GetVideoSize(bool fCorrectAR)
{
CSize VideoSize(GetVisibleVideoSize());
- if(fCorrectAR && m_AspectRatio.cx > 0 && m_AspectRatio.cy > 0)
+ 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);
}
@@ -114,34 +115,31 @@ STDMETHODIMP_(void) CSubPicAllocatorPresenterImpl::SetPosition(RECT w, RECT v)
m_VideoRect = v;
- if(fWindowSizeChanged || fVideoRectChanged)
- {
- if(m_pAllocator)
- {
+ if(fWindowSizeChanged || fVideoRectChanged) {
+ if(m_pAllocator) {
m_pAllocator->SetCurSize(m_WindowRect.Size());
m_pAllocator->SetCurVidRect(m_VideoRect);
}
- if(m_pSubPicQueue)
- {
+ if(m_pSubPicQueue) {
m_pSubPicQueue->Invalidate();
}
}
- if(fWindowPosChanged || fVideoRectChanged)
+ if(fWindowPosChanged || fVideoRectChanged) {
Paint(fWindowSizeChanged || fVideoRectChanged);
+ }
}
STDMETHODIMP_(void) CSubPicAllocatorPresenterImpl::SetTime(REFERENCE_TIME rtNow)
{
-/*
- if(m_rtNow <= rtNow && rtNow <= m_rtNow + 1000000)
- return;
-*/
+ /*
+ if(m_rtNow <= rtNow && rtNow <= m_rtNow + 1000000)
+ return;
+ */
m_rtNow = rtNow - m_rtSubtitleDelay;
- if(m_pSubPicQueue)
- {
+ if(m_pSubPicQueue) {
m_pSubPicQueue->SetTime(m_rtNow);
}
}
@@ -165,14 +163,16 @@ STDMETHODIMP_(void) CSubPicAllocatorPresenterImpl::SetSubPicProvider(ISubPicProv
{
m_SubPicProvider = pSubPicProvider;
- if(m_pSubPicQueue)
+ if(m_pSubPicQueue) {
m_pSubPicQueue->SetSubPicProvider(pSubPicProvider);
+ }
}
STDMETHODIMP_(void) CSubPicAllocatorPresenterImpl::Invalidate(REFERENCE_TIME rtInvalidate)
{
- if(m_pSubPicQueue)
+ if(m_pSubPicQueue) {
m_pSubPicQueue->Invalidate(rtInvalidate);
+ }
}
#include <math.h>
@@ -187,8 +187,7 @@ void CSubPicAllocatorPresenterImpl::Transform(CRect r, Vector v[4])
Vector center(r.CenterPoint().x, r.CenterPoint().y, 0);
int l = (int)(Vector(r.Size().cx, r.Size().cy, 0).Length()*1.5f)+1;
- for(ptrdiff_t i = 0; i < 4; i++)
- {
+ for(ptrdiff_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;
@@ -200,6 +199,8 @@ void CSubPicAllocatorPresenterImpl::Transform(CRect r, Vector v[4])
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);
+ if(fRepaint) {
+ Paint(true);
+ }
return S_OK;
}
diff --git a/src/SubPic/SubPicAllocatorPresenterImpl.h b/src/SubPic/SubPicAllocatorPresenterImpl.h
index 99b987299..171078617 100644
--- a/src/SubPic/SubPicAllocatorPresenterImpl.h
+++ b/src/SubPic/SubPicAllocatorPresenterImpl.h
@@ -95,10 +95,10 @@ public:
STDMETHODIMP SetPixelShader(LPCSTR pSrcData, LPCSTR pTarget) {
return E_NOTIMPL;
}
- STDMETHODIMP SetPixelShader2(LPCSTR pSrcData, LPCSTR pTarget, bool bScreenSpace)
- {
- if (!bScreenSpace)
+ 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 7d6dc5f01..66b85b03f 100644
--- a/src/SubPic/SubPicImpl.cpp
+++ b/src/SubPic/SubPicImpl.cpp
@@ -59,15 +59,17 @@ STDMETHODIMP_(REFERENCE_TIME) CSubPicImpl::GetStop()
STDMETHODIMP_(REFERENCE_TIME) CSubPicImpl::GetSegmentStart()
{
- if (m_rtSegmentStart)
+ if (m_rtSegmentStart) {
return(m_rtSegmentStart);
+ }
return(m_rtStart);
}
STDMETHODIMP_(REFERENCE_TIME) CSubPicImpl::GetSegmentStop()
{
- if (m_rtSegmentStop)
+ if (m_rtSegmentStop) {
return(m_rtSegmentStop);
+ }
return(m_rtStop);
}
@@ -95,8 +97,9 @@ STDMETHODIMP_(void) CSubPicImpl::SetStop(REFERENCE_TIME rtStop)
STDMETHODIMP CSubPicImpl::CopyTo(ISubPic* pSubPic)
{
- if(!pSubPic)
+ if(!pSubPic) {
return E_POINTER;
+ }
pSubPic->SetStart(m_rtStart);
pSubPic->SetStop(m_rtStop);
@@ -119,8 +122,7 @@ STDMETHODIMP CSubPicImpl::GetSourceAndDest(SIZE* pSize, RECT* pRcSource, RECT* p
CheckPointer (pRcSource, E_POINTER);
CheckPointer (pRcDest, E_POINTER);
- if(m_size.cx > 0 && m_size.cy > 0)
- {
+ if(m_size.cx > 0 && m_size.cy > 0) {
CRect rcTemp = m_rcDirty;
// FIXME
@@ -135,9 +137,9 @@ STDMETHODIMP CSubPicImpl::GetSourceAndDest(SIZE* pSize, RECT* pRcSource, RECT* p
rcTemp.bottom * pSize->cy / m_VirtualTextureSize.cy);
return S_OK;
- }
- else
+ } else {
return E_INVALIDARG;
+ }
}
STDMETHODIMP CSubPicImpl::SetDirtyRect(RECT* pDirtyRect)
@@ -155,20 +157,17 @@ STDMETHODIMP CSubPicImpl::SetSize(SIZE size, RECT vidrect)
m_size = size;
m_vidrect = vidrect;
- if(m_size.cx > m_maxsize.cx)
- {
+ 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)
- {
+ 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)
- {
+ 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);
@@ -223,13 +222,14 @@ STDMETHODIMP CSubPicAllocatorImpl::SetCurVidRect(RECT curvidrect)
STDMETHODIMP CSubPicAllocatorImpl::GetStatic(ISubPic** ppSubPic)
{
- if(!ppSubPic)
+ if(!ppSubPic) {
return E_POINTER;
+ }
- if(!m_pStatic)
- {
- if(!Alloc(true, &m_pStatic) || !m_pStatic)
+ if(!m_pStatic) {
+ if(!Alloc(true, &m_pStatic) || !m_pStatic) {
return E_OUTOFMEMORY;
+ }
}
m_pStatic->SetSize(m_cursize, m_curvidrect);
@@ -241,11 +241,13 @@ STDMETHODIMP CSubPicAllocatorImpl::GetStatic(ISubPic** ppSubPic)
STDMETHODIMP CSubPicAllocatorImpl::AllocDynamic(ISubPic** ppSubPic)
{
- if(!ppSubPic)
+ if(!ppSubPic) {
return E_POINTER;
+ }
- if(!Alloc(false, ppSubPic) || !*ppSubPic)
+ if(!Alloc(false, ppSubPic) || !*ppSubPic) {
return E_OUTOFMEMORY;
+ }
(*ppSubPic)->SetSize(m_cursize, m_curvidrect);
diff --git a/src/SubPic/SubPicImpl.h b/src/SubPic/SubPicImpl.h
index e0de8e943..ad5e3528a 100644
--- a/src/SubPic/SubPicImpl.h
+++ b/src/SubPic/SubPicImpl.h
@@ -37,34 +37,34 @@ protected:
CSize m_VirtualTextureSize;
CPoint m_VirtualTextureTopLeft;
-/*
-
- Texture
- +-------+---------------------------------+
- | . | .
- | . m_maxsize | .
- TextureTopLeft .<=============================== |======> . Video
- | . . . +-------------------------------- | -----+ +-----------------------------------+
- | | . | | | m_vidrect |
- | | . | | | |
- | | . | | | |
- | | +-----------+ . | | | |
- | | | m_rcDirty | . | | | |
- | | | | . | | | |
- | | +-----------+ . | | | |
- | +-------------------------------- | -----+ | |
- | m_size | | |
- | <=========================> | | |
- | | | |
- | | +-----------------------------------+
- | | .
- | | .
- | | .
- +-----------------------------------------+
- m_VirtualTextureSize
- <=========================================>
-
-*/
+ /*
+
+ Texture
+ +-------+---------------------------------+
+ | . | .
+ | . m_maxsize | .
+ TextureTopLeft .<=============================== |======> . Video
+ | . . . +-------------------------------- | -----+ +-----------------------------------+
+ | | . | | | m_vidrect |
+ | | . | | | |
+ | | . | | | |
+ | | +-----------+ . | | | |
+ | | | m_rcDirty | . | | | |
+ | | | | . | | | |
+ | | +-----------+ . | | | |
+ | +-------------------------------- | -----+ | |
+ | m_size | | |
+ | <=========================> | | |
+ | | | |
+ | | +-----------------------------------+
+ | | .
+ | | .
+ | | .
+ +-----------------------------------------+
+ m_VirtualTextureSize
+ <=========================================>
+
+ */
public:
diff --git a/src/SubPic/SubPicQueueImpl.cpp b/src/SubPic/SubPicQueueImpl.cpp
index 59fe3ccd9..7f8d89ec3 100644
--- a/src/SubPic/SubPicQueueImpl.cpp
+++ b/src/SubPic/SubPicQueueImpl.cpp
@@ -36,11 +36,14 @@ CSubPicQueueImpl::CSubPicQueueImpl(ISubPicAllocator* pAllocator, HRESULT* phr)
, m_rtNowLast(0)
, m_fps(25.0)
{
- if(phr) *phr = S_OK;
+ if(phr) {
+ *phr = S_OK;
+ }
- if(!m_pAllocator)
- {
- if(phr) *phr = E_FAIL;
+ if(!m_pAllocator) {
+ if(phr) {
+ *phr = E_FAIL;
+ }
return;
}
}
@@ -62,7 +65,7 @@ STDMETHODIMP CSubPicQueueImpl::SetSubPicProvider(ISubPicProvider* pSubPicProvide
{
CAutoLock cAutoLock(&m_csSubPicProvider);
-// if(m_pSubPicProvider != pSubPicProvider)
+ // if(m_pSubPicProvider != pSubPicProvider)
{
m_pSubPicProvider = pSubPicProvider;
@@ -74,13 +77,13 @@ STDMETHODIMP CSubPicQueueImpl::SetSubPicProvider(ISubPicProvider* pSubPicProvide
STDMETHODIMP CSubPicQueueImpl::GetSubPicProvider(ISubPicProvider** pSubPicProvider)
{
- if(!pSubPicProvider)
+ if(!pSubPicProvider) {
return E_POINTER;
+ }
CAutoLock cAutoLock(&m_csSubPicProvider);
- if(m_pSubPicProvider)
- {
+ if(m_pSubPicProvider) {
*pSubPicProvider = m_pSubPicProvider;
(*pSubPicProvider)->AddRef();
}
@@ -108,19 +111,21 @@ HRESULT CSubPicQueueImpl::RenderTo(ISubPic* pSubPic, REFERENCE_TIME rtStart, REF
{
HRESULT hr = E_FAIL;
- if(!pSubPic)
+ if(!pSubPic) {
return hr;
+ }
CComPtr<ISubPicProvider> pSubPicProvider;
- if(FAILED(GetSubPicProvider(&pSubPicProvider)) || !pSubPicProvider)
+ if(FAILED(GetSubPicProvider(&pSubPicProvider)) || !pSubPicProvider) {
return hr;
+ }
SubPicDesc spd;
hr = pSubPic->ClearDirtyRect(0xFF000000);
- if (SUCCEEDED(hr))
+ if (SUCCEEDED(hr)) {
hr = pSubPic->Lock(spd);
- if (SUCCEEDED(hr))
- {
+ }
+ if (SUCCEEDED(hr)) {
CRect r(0,0,0,0);
hr = pSubPicProvider->Render(spd, bIsAnimated ? rtStart : ((rtStart+rtStop)/2), fps, r);
@@ -144,18 +149,21 @@ CSubPicQueue::CSubPicQueue(int nMaxSubPic, BOOL bDisableAnim, ISubPicAllocator*
,m_rtQueueMin(0)
,m_rtQueueMax(0)
{
- if(phr && FAILED(*phr))
+ if(phr && FAILED(*phr)) {
return;
+ }
- if(m_nMaxSubPic < 1)
- {
- if(phr) *phr = E_INVALIDARG;
+ if(m_nMaxSubPic < 1) {
+ if(phr) {
+ *phr = E_INVALIDARG;
+ }
return;
}
m_fBreakBuffering = false;
- for(ptrdiff_t i = 0; i < EVENT_COUNT; i++)
+ for(ptrdiff_t i = 0; i < EVENT_COUNT; i++) {
m_ThreadEvents[i] = CreateEvent(NULL, FALSE, FALSE, NULL);
+ }
CAMThread::Create();
}
@@ -164,8 +172,9 @@ CSubPicQueue::~CSubPicQueue()
m_fBreakBuffering = true;
SetEvent(m_ThreadEvents[EVENT_EXIT]);
CAMThread::Close();
- for(ptrdiff_t i = 0; i < EVENT_COUNT; i++)
+ for(ptrdiff_t i = 0; i < EVENT_COUNT; i++) {
CloseHandle(m_ThreadEvents[i]);
+ }
}
// ISubPicQueue
@@ -173,7 +182,9 @@ CSubPicQueue::~CSubPicQueue()
STDMETHODIMP CSubPicQueue::SetFPS(double fps)
{
HRESULT hr = __super::SetFPS(fps);
- if(FAILED(hr)) return hr;
+ if(FAILED(hr)) {
+ return hr;
+ }
SetEvent(m_ThreadEvents[EVENT_TIME]);
@@ -183,7 +194,9 @@ STDMETHODIMP CSubPicQueue::SetFPS(double fps)
STDMETHODIMP CSubPicQueue::SetTime(REFERENCE_TIME rtNow)
{
HRESULT hr = __super::SetTime(rtNow);
- if(FAILED(hr)) return hr;
+ if(FAILED(hr)) {
+ return hr;
+ }
SetEvent(m_ThreadEvents[EVENT_TIME]);
@@ -193,8 +206,8 @@ STDMETHODIMP CSubPicQueue::SetTime(REFERENCE_TIME rtNow)
STDMETHODIMP CSubPicQueue::Invalidate(REFERENCE_TIME rtInvalidate)
{
{
-// CAutoLock cQueueLock(&m_csQueueLock);
-// RemoveAll();
+ // CAutoLock cQueueLock(&m_csQueueLock);
+ // RemoveAll();
m_rtInvalidate = rtInvalidate;
m_fBreakBuffering = true;
@@ -218,43 +231,39 @@ STDMETHODIMP_(bool) CSubPicQueue::LookupSubPic(REFERENCE_TIME rtNow, CComPtr<ISu
#if DSubPicTraceLevel > 2
TRACE("Find: ");
#endif
- while(pos)
- {
+ 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)
- {
+ if(rtNow >= rtStart && rtNow < rtSegmentStop) {
REFERENCE_TIME Diff = rtNow - rtStop;
- if (Diff < rtBestStop)
- {
+ if (Diff < rtBestStop) {
rtBestStop = Diff;
-// TRACE(" %f->%f", double(Diff) / 10000000.0, double(rtStop) / 10000000.0);
+ // TRACE(" %f->%f", double(Diff) / 10000000.0, double(rtStop) / 10000000.0);
ppSubPic = pSubPic;
}
#if DSubPicTraceLevel > 2
- else
+ else {
TRACE(" !%f->%f", double(Diff) / 10000000.0, double(rtStop) / 10000000.0);
+ }
#endif
}
#if DSubPicTraceLevel > 2
- else
+ else {
TRACE(" !!%f->%f", double(rtStart) / 10000000.0, double(rtSegmentStop) / 10000000.0);
+ }
#endif
}
#if DSubPicTraceLevel > 2
TRACE("\n");
#endif
- if (!ppSubPic)
- {
+ if (!ppSubPic) {
#if DSubPicTraceLevel > 1
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();
@@ -274,11 +283,13 @@ STDMETHODIMP CSubPicQueue::GetStats(int& nSubPics, REFERENCE_TIME& rtNow, REFERE
nSubPics = m_Queue.GetCount();
rtNow = m_rtNow;
rtStart = m_rtQueueMin;
- if (rtStart == 0x7fffffffffffffffi64)
+ if (rtStart == 0x7fffffffffffffffi64) {
rtStart = 0;
+ }
rtStop = m_rtQueueMax;
- if (rtStop == 0xffffffffffffffffi64)
+ if (rtStop == 0xffffffffffffffffi64) {
rtStop = 0;
+ }
return S_OK;
}
@@ -289,16 +300,12 @@ STDMETHODIMP CSubPicQueue::GetStats(int nSubPic, REFERENCE_TIME& rtStart, REFERE
rtStart = rtStop = -1;
- if(nSubPic >= 0 && nSubPic < (int)m_Queue.GetCount())
- {
- if(POSITION pos = m_Queue.FindIndex(nSubPic))
- {
+ 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
- {
+ } else {
return E_INVALIDARG;
}
@@ -314,13 +321,10 @@ REFERENCE_TIME CSubPicQueue::UpdateQueue()
REFERENCE_TIME rtNow = m_rtNow;
REFERENCE_TIME rtNowCompare = rtNow;
- if (rtNow < m_rtNowLast)
- {
+ if (rtNow < m_rtNowLast) {
m_Queue.RemoveAll();
m_rtNowLast = rtNow;
- }
- else
- {
+ } else {
m_rtNowLast = rtNow;
m_rtQueueMin = 0x7fffffffffffffffi64;
@@ -330,18 +334,15 @@ REFERENCE_TIME CSubPicQueue::UpdateQueue()
POSITION SavePos = 0;
{
POSITION Iter = m_Queue.GetHeadPosition();
- while(Iter)
- {
+ 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)
- {
+ if(rtNow >= rtStart && rtNow < rtSegmentStop) {
REFERENCE_TIME Diff = rtNow - rtStop;
- if (Diff < rtBestStop)
- {
+ if (Diff < rtBestStop) {
rtBestStop = Diff;
SavePos = ThisPos;
}
@@ -349,35 +350,33 @@ REFERENCE_TIME CSubPicQueue::UpdateQueue()
}
}
- #if DSubPicTraceLevel > 3
- if (SavePos)
- {
+#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);
}
- #endif
+#endif
{
POSITION Iter = m_Queue.GetHeadPosition();
- while(Iter)
- {
+ while(Iter) {
POSITION ThisPos = Iter;
ISubPic *pSubPic = m_Queue.GetNext(Iter);
REFERENCE_TIME rtStart = pSubPic->GetStart();
REFERENCE_TIME rtStop = pSubPic->GetStop();
- if (rtStop <= rtNowCompare && ThisPos != SavePos)
- {
- #if DSubPicTraceLevel > 0
+ if (rtStop <= rtNowCompare && ThisPos != SavePos) {
+#if DSubPicTraceLevel > 0
TRACE("Remove: %f->%f\n", double(rtStart) / 10000000.0, double(rtStop) / 10000000.0);
- #endif
+#endif
m_Queue.RemoveAt(ThisPos);
continue;
}
- if (rtStop > rtNow)
+ if (rtStop > rtNow) {
rtNow = rtStop;
+ }
m_rtQueueMin = min(m_rtQueueMin, rtStart);
m_rtQueueMax = max(m_rtQueueMax, rtStop);
}
@@ -409,15 +408,15 @@ DWORD CSubPicQueue::ThreadProc()
SetThreadPriority(m_hThread, bDisableAnim ? THREAD_PRIORITY_LOWEST : THREAD_PRIORITY_ABOVE_NORMAL/*THREAD_PRIORITY_BELOW_NORMAL*/);
bool bAgain = true;
- while(1)
- {
+ while(1) {
DWORD Ret = WaitForMultipleObjects(EVENT_COUNT, m_ThreadEvents, FALSE, bAgain ? 0 : INFINITE);
bAgain = false;
- if (Ret == WAIT_TIMEOUT)
+ if (Ret == WAIT_TIMEOUT) {
;
- else if ((Ret - WAIT_OBJECT_0) != EVENT_TIME)
+ } else if ((Ret - WAIT_OBJECT_0) != EVENT_TIME) {
break;
+ }
double fps = m_fps;
REFERENCE_TIME rtTimePerFrame = 10000000.0/fps;
REFERENCE_TIME rtNow = UpdateQueue();
@@ -426,46 +425,46 @@ DWORD CSubPicQueue::ThreadProc()
CComPtr<ISubPicProvider> pSubPicProvider;
if(SUCCEEDED(GetSubPicProvider(&pSubPicProvider)) && pSubPicProvider
- && SUCCEEDED(pSubPicProvider->Lock()))
- {
+ && SUCCEEDED(pSubPicProvider->Lock())) {
for(POSITION pos = pSubPicProvider->GetStartPosition(rtNow, fps);
pos && !m_fBreakBuffering && GetQueueCount() < (size_t)nMaxSubPic;
- pos = pSubPicProvider->GetNext(pos))
- {
+ 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(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
+ if(rtStart >= m_rtNow + 60*10000000i64) { // we are already one minute ahead, this should be enough
break;
+ }
- if(rtNow < rtStop)
- {
+ if(rtNow < rtStop) {
REFERENCE_TIME rtCurrent = max(rtNow, rtStart);
bool bIsAnimated = pSubPicProvider->IsAnimated(pos) && !bDisableAnim;
- while (rtCurrent < rtStop)
- {
+ while (rtCurrent < rtStop) {
SIZE MaxTextureSize, VirtualSize;
POINT VirtualTopLeft;
HRESULT hr2;
- if (SUCCEEDED (hr2 = pSubPicProvider->GetTextureSize(pos, MaxTextureSize, VirtualSize, VirtualTopLeft)))
+ if (SUCCEEDED (hr2 = pSubPicProvider->GetTextureSize(pos, MaxTextureSize, VirtualSize, VirtualTopLeft))) {
m_pAllocator->SetMaxTextureSize(MaxTextureSize);
+ }
CComPtr<ISubPic> pStatic;
- if(FAILED(m_pAllocator->GetStatic(&pStatic)))
+ if(FAILED(m_pAllocator->GetStatic(&pStatic))) {
break;
+ }
HRESULT hr;
- if (bIsAnimated)
- {
- if (rtCurrent < m_rtNow + rtTimePerFrame)
+ 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);
@@ -479,38 +478,40 @@ DWORD CSubPicQueue::ThreadProc()
rtCurrent = rtEndThis;
- }
- else
- {
+ } else {
hr = RenderTo(pStatic, rtStart, rtStop, fps, bIsAnimated);
rtCurrent = rtStop;
}
#if DSubPicTraceLevel > 0
- if (m_rtNow > rtCurrent)
- {
+ if (m_rtNow > rtCurrent) {
TRACE("BEHIND\n");
}
#endif
- if(FAILED(hr))
+ if(FAILED(hr)) {
break;
+ }
- if(S_OK != hr) // subpic was probably empty
+ if(S_OK != hr) { // subpic was probably empty
continue;
+ }
CComPtr<ISubPic> pDynamic;
if(FAILED(m_pAllocator->AllocDynamic(&pDynamic))
- || FAILED(pStatic->CopyTo(pDynamic)))
+ || FAILED(pStatic->CopyTo(pDynamic))) {
break;
+ }
- if (SUCCEEDED (hr2))
+ if (SUCCEEDED (hr2)) {
pDynamic->SetVirtualTextureSize (VirtualSize, VirtualTopLeft);
+ }
AppendQueue(pDynamic);
bAgain = true;
- if (GetQueueCount() >= (size_t)nMaxSubPic)
+ if (GetQueueCount() >= (size_t)nMaxSubPic) {
break;
+ }
}
}
}
@@ -518,24 +519,21 @@ DWORD CSubPicQueue::ThreadProc()
pSubPicProvider->Unlock();
}
- if(m_fBreakBuffering)
- {
+ if(m_fBreakBuffering) {
bAgain = true;
CAutoLock cQueueLock(&m_csQueueLock);
REFERENCE_TIME rtInvalidate = m_rtInvalidate;
POSITION Iter = m_Queue.GetHeadPosition();
- while(Iter)
- {
+ while(Iter) {
POSITION ThisPos = Iter;
ISubPic *pSubPic = m_Queue.GetNext(Iter);
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);
#endif
@@ -544,16 +542,16 @@ DWORD CSubPicQueue::ThreadProc()
}
}
-/*
- while(GetCount() && GetTail()->GetStop() > rtInvalidate)
- {
- if(GetTail()->GetStart() < rtInvalidate) GetTail()->SetStop(rtInvalidate);
- else
- {
- RemoveTail();
- }
- }
-*/
+ /*
+ while(GetCount() && GetTail()->GetStop() > rtInvalidate)
+ {
+ if(GetTail()->GetStart() < rtInvalidate) GetTail()->SetStop(rtInvalidate);
+ else
+ {
+ RemoveTail();
+ }
+ }
+ */
m_fBreakBuffering = false;
}
@@ -593,70 +591,65 @@ STDMETHODIMP_(bool) CSubPicQueueNoThread::LookupSubPic(REFERENCE_TIME rtNow, CCo
{
CAutoLock cAutoLock(&m_csLock);
- if(!m_pSubPic)
- {
- if(FAILED(m_pAllocator->AllocDynamic(&m_pSubPic)))
+ if(!m_pSubPic) {
+ if(FAILED(m_pAllocator->AllocDynamic(&m_pSubPic))) {
return(false);
+ }
}
pSubPic = m_pSubPic;
}
- if(pSubPic->GetStart() <= rtNow && rtNow < pSubPic->GetStop())
- {
+ if(pSubPic->GetStart() <= rtNow && rtNow < pSubPic->GetStop()) {
ppSubPic = pSubPic;
- }
- else
- {
+ } else {
CComPtr<ISubPicProvider> pSubPicProvider;
GetSubPicProvider(&pSubPicProvider);
- if (pSubPicProvider)
- {
+ if (pSubPicProvider) {
double fps = m_fps;
POSITION pos = pSubPicProvider->GetStartPosition(rtNow, fps);
- if(pos != 0)
- {
+ if(pos != 0) {
REFERENCE_TIME rtStart = pSubPicProvider->GetStart(pos, fps);
REFERENCE_TIME rtStop = pSubPicProvider->GetStop(pos, fps);
- if(pSubPicProvider->IsAnimated(pos))
- {
+ if(pSubPicProvider->IsAnimated(pos)) {
rtStart = rtNow;
rtStop = rtNow+1;
}
- if(rtStart <= rtNow && rtNow < rtStop)
- {
+ if(rtStart <= rtNow && rtNow < rtStop) {
SIZE MaxTextureSize, VirtualSize;
POINT VirtualTopLeft;
HRESULT hr2;
- if (SUCCEEDED (hr2 = pSubPicProvider->GetTextureSize(pos, MaxTextureSize, VirtualSize, VirtualTopLeft)))
+ if (SUCCEEDED (hr2 = pSubPicProvider->GetTextureSize(pos, MaxTextureSize, VirtualSize, VirtualTopLeft))) {
m_pAllocator->SetMaxTextureSize(MaxTextureSize);
+ }
- if(m_pAllocator->IsDynamicWriteOnly())
- {
+ if(m_pAllocator->IsDynamicWriteOnly()) {
CComPtr<ISubPic> pStatic;
HRESULT hr = m_pAllocator->GetStatic(&pStatic);
- if(SUCCEEDED(hr))
+ if(SUCCEEDED(hr)) {
hr = RenderTo(pStatic, rtStart, rtStop, fps, false);
- if(SUCCEEDED(hr))
+ }
+ if(SUCCEEDED(hr)) {
hr = pStatic->CopyTo(pSubPic);
- if(SUCCEEDED(hr))
+ }
+ if(SUCCEEDED(hr)) {
ppSubPic = pSubPic;
- }
- else
- {
- if(SUCCEEDED(RenderTo(m_pSubPic, rtStart, rtStop, fps, false)))
+ }
+ } else {
+ if(SUCCEEDED(RenderTo(m_pSubPic, rtStart, rtStop, fps, false))) {
ppSubPic = pSubPic;
+ }
}
- if (SUCCEEDED(hr2))
+ if (SUCCEEDED(hr2)) {
pSubPic->SetVirtualTextureSize (VirtualSize, VirtualTopLeft);
+ }
}
}
- if(ppSubPic)
- {
+ if(ppSubPic) {
CAutoLock cAutoLock(&m_csLock);
m_pSubPic = ppSubPic;
@@ -675,8 +668,7 @@ STDMETHODIMP CSubPicQueueNoThread::GetStats(int& nSubPics, REFERENCE_TIME& rtNow
rtNow = m_rtNow;
rtStart = rtStop = 0;
- if(m_pSubPic)
- {
+ if(m_pSubPic) {
nSubPics = 1;
rtStart = m_pSubPic->GetStart();
rtStop = m_pSubPic->GetStop();
@@ -689,8 +681,9 @@ STDMETHODIMP CSubPicQueueNoThread::GetStats(int nSubPic, REFERENCE_TIME& rtStart
{
CAutoLock cAutoLock(&m_csLock);
- if(!m_pSubPic || nSubPic != 0)
+ if(!m_pSubPic || nSubPic != 0) {
return E_INVALIDARG;
+ }
rtStart = m_pSubPic->GetStart();
rtStop = m_pSubPic->GetStop();
diff --git a/src/SubPic/SubPicQueueImpl.h b/src/SubPic/SubPicQueueImpl.h
index 9c3d7c4cc..15e612009 100644
--- a/src/SubPic/SubPicQueueImpl.h
+++ b/src/SubPic/SubPicQueueImpl.h
@@ -53,13 +53,13 @@ public:
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 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
diff --git a/src/Subtitles/BaseSub.h b/src/Subtitles/BaseSub.h
index 032367d8c..05a0d5e20 100644
--- a/src/Subtitles/BaseSub.h
+++ b/src/Subtitles/BaseSub.h
@@ -25,8 +25,7 @@
#include "CompositionObject.h"
-enum SUBTITLE_TYPE
-{
+enum SUBTITLE_TYPE {
ST_DVB,
ST_HDMV
};
diff --git a/src/Subtitles/CCDecoder.cpp b/src/Subtitles/CCDecoder.cpp
index 9731b8ca0..5c48deca5 100644
--- a/src/Subtitles/CCDecoder.cpp
+++ b/src/Subtitles/CCDecoder.cpp
@@ -34,14 +34,14 @@ CCDecoder::CCDecoder(CString fn, CString rawfn) : m_fn(fn), m_rawfn(rawfn)
memset(m_disp, 0, sizeof(m_disp));
m_cursor = CPoint(0, 0);
- if(!m_rawfn.IsEmpty())
+ if(!m_rawfn.IsEmpty()) {
_tremove(m_rawfn);
+ }
}
CCDecoder::~CCDecoder()
{
- if(!m_sts.IsEmpty() && !m_fn.IsEmpty())
- {
+ 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);
@@ -53,10 +53,18 @@ CCDecoder::~CCDecoder()
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;
+ 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)
@@ -74,60 +82,63 @@ void CCDecoder::SaveDisp(__int64 time)
{
CStringW str;
- for(ptrdiff_t row = 0; row < 16; row++)
- {
+ for(ptrdiff_t row = 0; row < 16; row++) {
bool fNonEmptyRow = false;
- for(ptrdiff_t col = 0; col < 32; col++)
- {
- if(m_disp[row][col])
- {
+ for(ptrdiff_t col = 0; col < 32; col++) {
+ if(m_disp[row][col]) {
CStringW str2(&m_disp[row][col]);
- if(fNonEmptyRow) str += ' ';
+ if(fNonEmptyRow) {
+ str += ' ';
+ }
str += str2;
col += str2.GetLength();
fNonEmptyRow = true;
}
}
- if(fNonEmptyRow) str += '\n';
+ if(fNonEmptyRow) {
+ str += '\n';
+ }
}
- if(str.IsEmpty()) return;
+ 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())
- {
- if(FILE* f = _tfopen(m_rawfn, _T("at")))
- {
+ if(!m_rawfn.IsEmpty()) {
+ if(FILE* f = _tfopen(m_rawfn, _T("at"))) {
_ftprintf(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++)
- {
+ for(ptrdiff_t i = 0; i < len; i++) {
_ftprintf(f, _T("%02x"), buff[i]);
- if(i < len-1) _ftprintf(f, _T(" "));
- if(i > 0 && (i&15)==15) _ftprintf(f, _T("\n"));
+ if(i < len-1) {
+ _ftprintf(f, _T(" "));
+ }
+ if(i > 0 && (i&15)==15) {
+ _ftprintf(f, _T("\n"));
+ }
+ }
+ if(len > 0) {
+ _ftprintf(f, _T("\n\n"));
}
- if(len > 0) _ftprintf(f, _T("\n\n"));
fclose(f);
}
}
- for(ptrdiff_t i = 0; i < len; i++)
- {
+ for(ptrdiff_t i = 0; i < len; i++) {
BYTE c = buff[i]&0x7f;
- if(c >= 0x20)
- {
- static WCHAR charmap[0x60] =
- {
+ 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',
@@ -137,26 +148,19 @@ void CCDecoder::DecodeCC(BYTE* buff, int len, __int64 time)
};
PutChar(charmap[c - 0x20]);
- }
- else if(buff[i] != 0x80 && i < len-1)
- {
+ } 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])
+ 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
- {
+ if(buff[i] == 0x91 && c >= 0x20 && c < 0x30) { // formating
// TODO
- }
- else if(buff[i] == 0x91 && c == 0x39) // transparent space
- {
+ } 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] =
- {
+ } else if(buff[i] == 0x91 && c >= 0x30 && c < 0x40) { // special characters
+ static WCHAR charmap[0x10] = {
0x00ae, // (r)egistered
0x00b0, // degree
0x00bd, // 1/2
@@ -176,11 +180,8 @@ void CCDecoder::DecodeCC(BYTE* buff, int len, __int64 time)
};
PutChar(charmap[c - 0x30]);
- }
- else if(buff[i] == 0x92 && c >= 0x20 && c < 0x40) // extended characters
- {
- static WCHAR charmap[0x20] =
- {
+ } else if(buff[i] == 0x92 && c >= 0x20 && c < 0x40) { // extended characters
+ static WCHAR charmap[0x20] = {
0x00c0, // A'
0x00c9, // E'
0x00d3, // O'
@@ -217,11 +218,8 @@ void CCDecoder::DecodeCC(BYTE* buff, int len, __int64 time)
};
PutChar(charmap[c - 0x20]);
- }
- else if(buff[i] == 0x13 && c >= 0x20 && c < 0x40) // more extended characters
- {
- static WCHAR charmap[0x20] =
- {
+ } else if(buff[i] == 0x13 && c >= 0x20 && c < 0x40) { // more extended characters
+ static WCHAR charmap[0x20] = {
0x00c3, // A~
0x00e3, // a~
0x00cd, // I'
@@ -258,78 +256,69 @@ void CCDecoder::DecodeCC(BYTE* buff, int len, __int64 time)
};
PutChar(charmap[c - 0x20]);
- }
- else if(buff[i] == 0x94 && buff[i+1] == 0xae) // Erase Non-displayed [buffer] Memory
- {
+ } 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
- {
+ } 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)
+ } 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)
- {
+ } 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
- {
+ } 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
- {
+ } 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;
+ 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++;
}
- 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;
+ if(col == 0 || (col > 0 && !(buff[i+1]&0x10))) {
+ col = 0;
+ } else {
+ col <<= 1;
+ }
MoveCursor(col, row);
}
@@ -341,55 +330,58 @@ void CCDecoder::DecodeCC(BYTE* buff, int len, __int64 time)
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)
- {
+ 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)
- {
+ if(nBytes > 0) {
nBytes = (nBytes+1)&~1;
BYTE* pData1 = new BYTE[nBytes];
BYTE* pData2 = new BYTE[nBytes];
- if(pData1 && pData2)
- {
+ if(pData1 && pData2) {
int nBytes1 = 0, nBytes2 = 0;
- for(ptrdiff_t j = 0; j < nBytes && i < 0x800;)
- {
- if(buff[i++] == 0xff)
- {
+ for(ptrdiff_t j = 0; j < nBytes && i < 0x800;) {
+ if(buff[i++] == 0xff) {
pData1[nBytes1++] = buff[i++];
pData1[nBytes1++] = buff[i++];
+ } else {
+ i+=2;
}
- else i+=2;
j++;
- if(j >= nBytes) break;
+ if(j >= nBytes) {
+ break;
+ }
- if(buff[i++] == 0xff)
- {
+ if(buff[i++] == 0xff) {
pData2[nBytes2++] = buff[i++];
pData2[nBytes2++] = buff[i++];
+ } else {
+ i+=2;
}
- else i+=2;
j++;
}
- if(nBytes1 > 0)
+ if(nBytes1 > 0) {
DecodeCC(pData1, nBytes1, time);
+ }
- if(nBytes2 > 0)
+ if(nBytes2 > 0) {
DecodeCC(pData2, nBytes2, time);
+ }
}
- if(pData1) delete [] pData1;
- if(pData2) delete [] pData2;
+ if(pData1) {
+ delete [] pData1;
+ }
+ if(pData2) {
+ delete [] pData2;
+ }
}
break;
diff --git a/src/Subtitles/CompositionObject.cpp b/src/Subtitles/CompositionObject.cpp
index f2ae18607..c6c38e4c8 100644
--- a/src/Subtitles/CompositionObject.cpp
+++ b/src/Subtitles/CompositionObject.cpp
@@ -46,16 +46,16 @@ void CompositionObject::SetPalette (int nNbEntry, HDMV_PALETTE* pPalette, bool b
{
m_nColorNumber = nNbEntry;
- for (int i=0; i<m_nColorNumber; i++)
- {
-// if (pPalette[i].T != 0) // Prevent ugly background when Alpha=0 (but RGB different from 0)
+ for (int i=0; i<m_nColorNumber; i++) {
+ // if (pPalette[i].T != 0) // Prevent ugly background when Alpha=0 (but RGB different from 0)
{
- if (bIsHD)
+ if (bIsHD) {
m_Colors[pPalette[i].entry_id] = YCrCbToRGB_Rec709 (pPalette[i].T, pPalette[i].Y, pPalette[i].Cr, pPalette[i].Cb);
- else
+ } else {
m_Colors[pPalette[i].entry_id] = YCrCbToRGB_Rec601 (pPalette[i].T, pPalette[i].Y, pPalette[i].Cr, pPalette[i].Cb);
+ }
}
-// TRACE_HDMVSUB ("%03d : %08x\n", pPalette[i].entry_id, m_Colors[pPalette[i].entry_id]);
+ // TRACE_HDMVSUB ("%03d : %08x\n", pPalette[i].entry_id, m_Colors[pPalette[i].entry_id]);
}
}
@@ -73,8 +73,7 @@ void CompositionObject::SetRLEData(BYTE* pBuffer, int nSize, int nTotalSize)
void CompositionObject::AppendRLEData(BYTE* pBuffer, int nSize)
{
ASSERT (m_nRLEPos+nSize <= m_nRLEDataSize);
- if (m_nRLEPos+nSize <= m_nRLEDataSize)
- {
+ if (m_nRLEPos+nSize <= m_nRLEDataSize) {
memcpy (m_pRLEData+m_nRLEPos, pBuffer, nSize);
m_nRLEPos += nSize;
}
@@ -83,8 +82,9 @@ void CompositionObject::AppendRLEData(BYTE* pBuffer, int nSize)
void CompositionObject::RenderHdmv(SubPicDesc& spd)
{
- if (!m_pRLEData)
+ if (!m_pRLEData) {
return;
+ }
CGolombBuffer GBuffer (m_pRLEData, m_nRLEDataSize);
BYTE bTemp;
@@ -95,54 +95,40 @@ void CompositionObject::RenderHdmv(SubPicDesc& spd)
SHORT nX = 0;
SHORT nY = 0;
- while ((nY < m_height) && !GBuffer.IsEOF())
- {
+ while ((nY < m_height) && !GBuffer.IsEOF()) {
bTemp = GBuffer.ReadByte();
- if (bTemp != 0)
- {
+ if (bTemp != 0) {
nPaletteIndex = bTemp;
nCount = 1;
- }
- else
- {
+ } else {
bSwitch = GBuffer.ReadByte();
- if (!(bSwitch & 0x80))
- {
- if (!(bSwitch & 0x40))
- {
+ if (!(bSwitch & 0x80)) {
+ if (!(bSwitch & 0x40)) {
nCount = bSwitch & 0x3F;
- if (nCount > 0)
+ if (nCount > 0) {
nPaletteIndex = 0;
- }
- else
- {
+ }
+ } else {
nCount = (bSwitch&0x3F) <<8 | (SHORT)GBuffer.ReadByte();
nPaletteIndex = 0;
}
- }
- else
- {
- if (!(bSwitch & 0x40))
- {
+ } else {
+ if (!(bSwitch & 0x40)) {
nCount = bSwitch & 0x3F;
nPaletteIndex = GBuffer.ReadByte();
- }
- else
- {
+ } 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)
+ 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
- {
+ } else {
nY++;
nX = 0;
}
@@ -152,8 +138,9 @@ void CompositionObject::RenderHdmv(SubPicDesc& spd)
void CompositionObject::RenderDvb(SubPicDesc& spd, SHORT nX, SHORT nY)
{
- if (!m_pRLEData)
+ if (!m_pRLEData) {
return;
+ }
CGolombBuffer gb (m_pRLEData, m_nRLEDataSize);
SHORT sTopFieldLength;
@@ -176,36 +163,34 @@ void CompositionObject::DvbRenderField(SubPicDesc& spd, CGolombBuffer& gb, SHORT
SHORT nX = nXStart;
SHORT nY = nYStart;
INT64 nEnd = gb.GetPos()+nLength;
- while (gb.GetPos() < nEnd)
- {
+ 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;
+ 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;
}
}
}
@@ -218,58 +203,47 @@ void CompositionObject::Dvb2PixelsCodeString(SubPicDesc& spd, CGolombBuffer& gb,
SHORT nCount;
bool bQuit = false;
- while (!bQuit && !gb.IsEOF())
- {
+ while (!bQuit && !gb.IsEOF()) {
nCount = 0;
nPaletteIndex = 0;
bTemp = (BYTE)gb.BitRead(2);
- if (bTemp != 0)
- {
+ if (bTemp != 0) {
nPaletteIndex = bTemp;
nCount = 1;
- }
- else
- {
- if (gb.BitRead(1) == 1) // switch_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 {
+ 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
+ } else {
nCount = 1;
+ }
}
}
- if (nX+nCount > m_width)
- {
+ if (nX+nCount > m_width) {
ASSERT (FALSE);
break;
}
- if (nCount>0)
- {
+ if (nCount>0) {
FillSolidRect (spd, nX, nY, nCount, 1, m_Colors[nPaletteIndex]);
nX += nCount;
}
@@ -285,64 +259,52 @@ void CompositionObject::Dvb4PixelsCodeString(SubPicDesc& spd, CGolombBuffer& gb,
SHORT nCount;
bool bQuit = false;
- while (!bQuit && !gb.IsEOF())
- {
+ while (!bQuit && !gb.IsEOF()) {
nCount = 0;
nPaletteIndex = 0;
bTemp = (BYTE)gb.BitRead(4);
- if (bTemp != 0)
- {
+ if (bTemp != 0) {
nPaletteIndex = bTemp;
nCount = 1;
- }
- else
- {
- if (gb.BitRead(1) == 0) // switch_1
- {
+ } else {
+ if (gb.BitRead(1) == 0) { // switch_1
nCount = (SHORT)gb.BitRead(3); // run_length_3-9
- if (nCount != 0)
+ if (nCount != 0) {
nCount += 2;
- else
+ } else {
bQuit = true;
- }
- else
- {
- if (gb.BitRead(1) == 0) // switch_2
- {
+ }
+ } 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;
+ } 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 (nX+nCount > m_width)
- {
+ if (nX+nCount > m_width) {
ASSERT (FALSE);
break;
}
- if (nCount>0)
- {
+ if (nCount>0) {
FillSolidRect (spd, nX, nY, nCount, 1, m_Colors[nPaletteIndex]);
nX += nCount;
}
@@ -358,39 +320,31 @@ void CompositionObject::Dvb8PixelsCodeString(SubPicDesc& spd, CGolombBuffer& gb,
SHORT nCount;
bool bQuit = false;
- while (!bQuit && !gb.IsEOF())
- {
+ while (!bQuit && !gb.IsEOF()) {
nCount = 0;
nPaletteIndex = 0;
bTemp = gb.ReadByte();
- if (bTemp != 0)
- {
+ if (bTemp != 0) {
nPaletteIndex = bTemp;
nCount = 1;
- }
- else
- {
- if (gb.BitRead(1) == 0) // switch_1
- {
+ } else {
+ if (gb.BitRead(1) == 0) { // switch_1
nCount = (SHORT)gb.BitRead(7); // run_length_1-127
- if (nCount == 0)
+ if (nCount == 0) {
bQuit = true;
- }
- else
- {
+ }
+ } else {
nCount = (SHORT)gb.BitRead(7); // run_length_3-127
nPaletteIndex = gb.ReadByte();
}
}
- if (nX+nCount > m_width)
- {
+ if (nX+nCount > m_width) {
ASSERT (FALSE);
break;
}
- if (nCount>0)
- {
+ if (nCount>0) {
FillSolidRect (spd, nX, nY, nCount, 1, m_Colors[nPaletteIndex]);
nX += nCount;
}
diff --git a/src/Subtitles/CompositionObject.h b/src/Subtitles/CompositionObject.h
index 7b965d191..21e8f4406 100644
--- a/src/Subtitles/CompositionObject.h
+++ b/src/Subtitles/CompositionObject.h
@@ -26,8 +26,7 @@
#include "Rasterizer.h"
-struct HDMV_PALETTE
-{
+struct HDMV_PALETTE {
BYTE entry_id;
BYTE Y;
BYTE Cr;
diff --git a/src/Subtitles/DVBSub.cpp b/src/Subtitles/DVBSub.cpp
index aa4a3ff7b..231281239 100644
--- a/src/Subtitles/DVBSub.cpp
+++ b/src/Subtitles/DVBSub.cpp
@@ -26,9 +26,9 @@
#include "../DSUtil/GolombBuffer.h"
#if (1) // Set to 1 to activate DVB subtitles traces
- #define TRACE_DVB TRACE
+#define TRACE_DVB TRACE
#else
- #define TRACE_DVB
+#define TRACE_DVB
#endif
#define BUFFER_CHUNK_GROW 0x1000
@@ -52,12 +52,12 @@ CDVBSub::DVB_PAGE* CDVBSub::FindPage(REFERENCE_TIME rt)
{
POSITION pos = m_Pages.GetHeadPosition();
- while (pos)
- {
+ while (pos) {
DVB_PAGE* pPage = m_Pages.GetAt (pos);
- if (rt >= pPage->rtStart && rt < pPage->rtStop)
+ if (rt >= pPage->rtStart && rt < pPage->rtStop) {
return pPage;
+ }
m_Pages.GetNext(pos);
}
@@ -67,12 +67,11 @@ CDVBSub::DVB_PAGE* CDVBSub::FindPage(REFERENCE_TIME rt)
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)
+ if (pPage != NULL) {
+ for (int i=0; i<pPage->RegionCount; i++) {
+ if (pPage->Regions[i].Id == bRegionId) {
return &pPage->Regions[i];
+ }
}
}
return NULL;
@@ -80,12 +79,11 @@ CDVBSub::DVB_REGION* CDVBSub::FindRegion(DVB_PAGE* pPage, BYTE bRegionId)
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)
+ 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;
@@ -93,16 +91,15 @@ CDVBSub::DVB_CLUT* CDVBSub::FindClut(DVB_PAGE* pPage, BYTE bClutId)
CompositionObject* CDVBSub::FindObject(DVB_PAGE* pPage, SHORT sObjectId)
{
- if (pPage != NULL)
- {
+ if (pPage != NULL) {
POSITION pos = pPage->Objects.GetHeadPosition();
- while (pos)
- {
+ while (pos) {
CompositionObject* pObject = pPage->Objects.GetAt (pos);
- if (pObject->m_object_id_ref == sObjectId)
+ if (pObject->m_object_id_ref == sObjectId) {
return pObject;
+ }
pPage->Objects.GetNext(pos);
}
@@ -114,18 +111,14 @@ 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)
- {
+ 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)
- {
+ 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);
@@ -137,8 +130,7 @@ HRESULT CDVBSub::AddToBuffer(BYTE* pData, int nSize)
BYTE* pPrev = m_pBuffer;
m_nBufferSize = max (m_nBufferWritePos+nSize, m_nBufferSize+BUFFER_CHUNK_GROW);
m_pBuffer = new BYTE[m_nBufferSize];
- if (pPrev != NULL)
- {
+ if (pPrev != NULL) {
memcpy_s (m_pBuffer, m_nBufferSize, pPrev, m_nBufferWritePos);
SAFE_DELETE (pPrev);
}
@@ -161,18 +153,21 @@ HRESULT CDVBSub::ParseSample (IMediaSample* pSample)
DVB_SEGMENT_TYPE nCurSegment;
hr = pSample->GetPointer(&pData);
- if(FAILED(hr) || pData == NULL) return hr;
+ if(FAILED(hr) || pData == NULL) {
+ return hr;
+ }
nSize = pSample->GetActualDataLength();
- if (*((LONG*)pData) == 0xBD010000)
- {
+ if (*((LONG*)pData) == 0xBD010000) {
CGolombBuffer gb (pData, nSize);
gb.SkipBytes(4);
WORD wLength = (WORD)gb.BitRead(16);
UNUSED_ALWAYS(wLength);
- if (gb.BitRead(2) != 2) return E_FAIL; // type
+ if (gb.BitRead(2) != 2) {
+ return E_FAIL; // type
+ }
gb.BitRead(2); // scrambling
gb.BitRead(1); // priority
@@ -189,8 +184,7 @@ HRESULT CDVBSub::ParseSample (IMediaSample* pSample)
gb.BitRead(1); // extension
gb.BitRead(8); // hdrlen
- if(fpts)
- {
+ if(fpts) {
BYTE b = (BYTE)gb.BitRead(4);
if(!(fdts && b == 3 || !fdts && b == 2)) {
ASSERT(0);
@@ -208,9 +202,7 @@ HRESULT CDVBSub::ParseSample (IMediaSample* pSample)
m_rtStart = pts;
m_rtStop = pts+1;
- }
- else
- {
+ } else {
m_rtStart = INVALID_TIME;
m_rtStop = INVALID_TIME;
}
@@ -219,9 +211,9 @@ HRESULT CDVBSub::ParseSample (IMediaSample* pSample)
pData += 14;
pSample->GetTime(&m_rtStart, &m_rtStop);
pSample->GetMediaTime(&m_rtStart, &m_rtStop);
- }
- else if (SUCCEEDED (pSample->GetTime(&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)
@@ -234,15 +226,12 @@ HRESULT CDVBSub::ParseSample (IMediaSample* pSample)
// fclose(hFile);
//}
- if (AddToBuffer (pData, nSize) == S_OK)
- {
+ 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)
- {
+ while (!gb.IsEOF()) {
+ if (gb.ReadByte() == 0x0F) {
WORD wPageId;
WORD wSegLength;
@@ -250,56 +239,51 @@ HRESULT CDVBSub::ParseSample (IMediaSample* pSample)
wPageId = gb.ReadShort();
wSegLength = gb.ReadShort();
- if (gb.RemainingSize() < wSegLength)
- {
+ 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)
- {
- m_pCurrentPage = pPage;
- m_pCurrentPage->rtStart = m_rtStart;
- TRACE_DVB ("DVB - Page started %S\n", ReftimeToString(m_rtStart));
- m_rtStart = INVALID_TIME;
- }
- else
- TRACE_DVB ("DVB - Page update\n");
- }
- 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);
- break;
- case END_OF_DISPLAY :
- if (m_pCurrentPage != NULL && m_rtStart != INVALID_TIME)
- {
- 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());
+ switch (nCurSegment) {
+ case PAGE : {
+ CAutoPtr<DVB_PAGE> pPage;
+ ParsePage(gb, wSegLength, pPage);
+
+ if (pPage->PageState == DPS_ACQUISITION) {
+ m_pCurrentPage = pPage;
+ m_pCurrentPage->rtStart = m_rtStart;
+ TRACE_DVB ("DVB - Page started %S\n", ReftimeToString(m_rtStart));
+ m_rtStart = INVALID_TIME;
+ } else {
+ TRACE_DVB ("DVB - Page update\n");
+ }
}
break;
- default :
-// gb.SkipBytes(wSegLength);
- 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);
+ break;
+ case END_OF_DISPLAY :
+ if (m_pCurrentPage != NULL && m_rtStart != INVALID_TIME) {
+ 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 :
+ // gb.SkipBytes(wSegLength);
+ break;
}
nLastPos = gb.GetPos();
}
@@ -314,17 +298,13 @@ void CDVBSub::Render(SubPicDesc& spd, REFERENCE_TIME rt, RECT& bbox)
{
DVB_PAGE* pPage = FindPage (rt);
- if (pPage != NULL)
- {
+ if (pPage != NULL) {
pPage->Rendered = true;
- for (int i=0; i<pPage->RegionCount; i++)
- {
+ for (int i=0; i<pPage->RegionCount; i++) {
CDVBSub::DVB_REGION* pRegion = &pPage->Regions[i];
- for (int j=0; j<pRegion->ObjectCount; j++)
- {
+ for (int j=0; j<pRegion->ObjectCount; j++) {
CompositionObject* pObject = FindObject (pPage, pRegion->Objects[j].object_id);
- if (pObject)
- {
+ if (pObject) {
SHORT nX, nY;
nX = pRegion->HorizAddr + pRegion->Objects[j].object_horizontal_position;
nY = pRegion->VertAddr + pRegion->Objects[j].object_vertical_position;
@@ -367,21 +347,20 @@ POSITION CDVBSub::GetStartPosition(REFERENCE_TIME rt, double fps)
DVB_PAGE* pPage;
// Cleanup old PG
- while (m_Pages.GetCount()>0)
- {
+ while (m_Pages.GetCount()>0) {
pPage = m_Pages.GetHead();
- if (pPage->rtStop < rt)
- {
- if (!pPage->Rendered)
+ if (pPage->rtStop < rt) {
+ if (!pPage->Rendered) {
TRACE_DVB ("DVB - remove unrendered object, %S - %S\n", ReftimeToString(pPage->rtStart), ReftimeToString(pPage->rtStop));
+ }
//TRACE_HDMVSUB ("CHdmvSub:HDMV remove object %d %S => %S (rt=%S)\n", pPage->GetRLEDataSize(),
// ReftimeToString (pPage->rtStart), ReftimeToString(pPage->rtStop), ReftimeToString(rt));
m_Pages.RemoveHead();
delete pPage;
- }
- else
+ } else {
break;
+ }
}
return m_Pages.GetHeadPosition();
@@ -414,8 +393,7 @@ void CDVBSub::Reset()
m_pCurrentPage.Free();
DVB_PAGE* pPage;
- while (m_Pages.GetCount() > 0)
- {
+ while (m_Pages.GetCount() > 0) {
pPage = m_Pages.RemoveHead();
delete pPage;
}
@@ -433,10 +411,8 @@ HRESULT CDVBSub::ParsePage(CGolombBuffer& gb, WORD wSegLength, CAutoPtr<DVB_PAGE
pPage->PageState = (BYTE)gb.BitRead(2);
pPage->RegionCount = 0;
gb.BitRead(2); // Reserved
- while (gb.GetPos() < wEnd)
- {
- if (nPos < MAX_REGIONS)
- {
+ while (gb.GetPos() < wEnd) {
+ if (nPos < MAX_REGIONS) {
pPage->Regions[nPos].Id = gb.ReadByte();
gb.ReadByte(); // Reserved
pPage->Regions[nPos].HorizAddr = gb.ReadShort();
@@ -456,8 +432,7 @@ HRESULT CDVBSub::ParseDisplay(CGolombBuffer& gb, WORD wSegLength)
gb.BitRead(3); // reserved
m_Display.width = gb.ReadShort();
m_Display.height = gb.ReadShort();
- if (m_Display.display_window_flag)
- {
+ 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();
@@ -475,11 +450,11 @@ HRESULT CDVBSub::ParseRegion(CGolombBuffer& gb, WORD wSegLength)
pRegion = FindRegion (m_pCurrentPage, gb.ReadByte());
- if (pRegion == NULL)
+ if (pRegion == NULL) {
pRegion = &DummyRegion;
+ }
- if (pRegion != NULL)
- {
+ if (pRegion != NULL) {
pRegion->version_number = (BYTE)gb.BitRead(4);
pRegion->fill_flag = (BYTE)gb.BitRead(1);
gb.BitRead(3); // Reserved
@@ -495,8 +470,7 @@ HRESULT CDVBSub::ParseRegion(CGolombBuffer& gb, WORD wSegLength)
gb.BitRead(2); // Reserved
pRegion->ObjectCount = 0;
- while (gb.GetPos() < wEnd)
- {
+ while (gb.GetPos() < wEnd) {
DVB_OBJECT* pObject = &pRegion->Objects[pRegion->ObjectCount];
pObject->object_id = gb.ReadShort();
pObject->object_type = (BYTE)gb.BitRead(2);
@@ -504,16 +478,15 @@ HRESULT CDVBSub::ParseRegion(CGolombBuffer& gb, WORD wSegLength)
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)
- {
+ if (pObject->object_type == 0x01 || pObject->object_type == 0x02) {
pObject->foreground_pixel_code = gb.ReadByte();
pObject->background_pixel_code = gb.ReadByte();
}
pRegion->ObjectCount++;
}
- }
- else
+ } else {
gb.SkipBytes (wSegLength-1);
+ }
return S_OK;
}
@@ -525,15 +498,13 @@ HRESULT CDVBSub::ParseClut(CGolombBuffer& gb, WORD wSegLength)
CDVBSub::DVB_CLUT* pClut;
pClut = FindClut (m_pCurrentPage, gb.ReadByte());
-// ASSERT (pClut != NULL);
- if (pClut != NULL)
- {
+ // ASSERT (pClut != NULL);
+ if (pClut != NULL) {
pClut->version_number = (BYTE)gb.BitRead(4);
gb.BitRead(4); // Reserved
pClut->Size = 0;
- while (gb.GetPos() < wEnd)
- {
+ while (gb.GetPos() < wEnd) {
BYTE entry_id = gb.ReadByte()+1;
BYTE _2_bit = (BYTE)gb.BitRead(1);
BYTE _4_bit = (BYTE)gb.BitRead(1);
@@ -544,15 +515,12 @@ HRESULT CDVBSub::ParseClut(CGolombBuffer& gb, WORD wSegLength)
gb.BitRead(4); // Reserved
pClut->Palette[entry_id].entry_id = entry_id;
- if (gb.BitRead(1))
- {
+ 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 = 255-gb.ReadByte();
- }
- else
- {
+ } 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;
@@ -569,8 +537,7 @@ HRESULT CDVBSub::ParseObject(CGolombBuffer& gb, WORD wSegLength)
{
HRESULT hr = E_FAIL;
- if (m_pCurrentPage && wSegLength > 2)
- {
+ if (m_pCurrentPage && wSegLength > 2) {
CompositionObject* pObject = DNew CompositionObject();
BYTE object_coding_method;
@@ -581,15 +548,12 @@ HRESULT CDVBSub::ParseObject(CGolombBuffer& gb, WORD wSegLength)
gb.BitRead(1); // non_modifying_colour_flag
gb.BitRead(1); // reserved
- if (object_coding_method == 0x00)
- {
+ 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
- {
+ } else {
delete pObject;
hr = E_NOTIMPL;
}
diff --git a/src/Subtitles/DVBSub.h b/src/Subtitles/DVBSub.h
index 92640ea73..c4c441498 100644
--- a/src/Subtitles/DVBSub.h
+++ b/src/Subtitles/DVBSub.h
@@ -46,8 +46,7 @@ public:
virtual void Reset();
// EN 300-743, table 2
- enum DVB_SEGMENT_TYPE
- {
+ enum DVB_SEGMENT_TYPE {
NO_SEGMENT = 0xFFFF,
PAGE = 0x10,
REGION = 0x11,
@@ -58,37 +57,32 @@ public:
};
// EN 300-743, table 6
- enum DVB_OBJECT_TYPE
- {
+ enum DVB_OBJECT_TYPE {
OT_BASIC_BITMAP = 0x00,
OT_BASIC_CHAR = 0x01,
OT_COMPOSITE_STRING = 0x02
};
- enum DVB_PAGE_STATE
- {
+ enum DVB_PAGE_STATE {
DPS_NORMAL = 0x00,
DPS_ACQUISITION = 0x01,
DPS_MODE = 0x02,
DPS_RESERVED = 0x03
};
- struct DVB_CLUT
- {
+ struct DVB_CLUT {
BYTE id;
BYTE version_number;
BYTE Size;
HDMV_PALETTE Palette[256];
- DVB_CLUT()
- {
+ DVB_CLUT() {
memset (Palette, 0, sizeof(Palette));
}
};
- struct DVB_DISPLAY
- {
+ struct DVB_DISPLAY {
BYTE version_number;
BYTE display_window_flag;
SHORT width;
@@ -98,8 +92,7 @@ public:
SHORT vertical_position_minimun;
SHORT vertical_position_maximum;
- DVB_DISPLAY()
- {
+ DVB_DISPLAY() {
// Default value (§5.1.3)
version_number = 0;
width = 720;
@@ -107,8 +100,7 @@ public:
}
};
- struct DVB_OBJECT
- {
+ struct DVB_OBJECT {
SHORT object_id;
BYTE object_type;
BYTE object_provider_flag;
@@ -117,8 +109,7 @@ public:
BYTE foreground_pixel_code;
BYTE background_pixel_code;
- DVB_OBJECT()
- {
+ DVB_OBJECT() {
object_id = 0xFF;
object_type = 0;
object_provider_flag = 0;
@@ -129,8 +120,7 @@ public:
}
};
- struct DVB_REGION
- {
+ struct DVB_REGION {
BYTE Id;
WORD HorizAddr;
WORD VertAddr;
@@ -149,8 +139,7 @@ public:
DVB_CLUT Clut;
- DVB_REGION()
- {
+ DVB_REGION() {
Id = 0;
HorizAddr = 0;
VertAddr = 0;
@@ -180,8 +169,7 @@ public:
CAtlList<CompositionObject*> Objects;
bool Rendered;
- DVB_PAGE()
- {
+ DVB_PAGE() {
PageTimeOut = 0;
PageVersionNumber = 0;
PageState = 0;
@@ -189,11 +177,9 @@ public:
Rendered = false;
}
- ~DVB_PAGE()
- {
+ ~DVB_PAGE() {
CompositionObject* pPage;
- while (Objects.GetCount() > 0)
- {
+ while (Objects.GetCount() > 0) {
pPage = Objects.RemoveHead();
delete pPage;
}
diff --git a/src/Subtitles/GFN.cpp b/src/Subtitles/GFN.cpp
index 2c2d1a892..8c34e69b3 100644
--- a/src/Subtitles/GFN.cpp
+++ b/src/Subtitles/GFN.cpp
@@ -26,15 +26,13 @@
#include "TextFile.h"
#include "GFN.h"
-TCHAR* exttypestr[] =
-{
+TCHAR* exttypestr[] = {
_T("srt"), _T("sub"), _T("smi"), _T("psb"),
_T("ssa"), _T("ass"), _T("idx"), _T("usf"),
_T("xss"), _T("txt"), _T("ssf"), _T("rt"), _T("sup")
};
-static TCHAR* ext[3][countof(exttypestr)] =
-{
+static TCHAR* ext[3][countof(exttypestr)] = {
{
_T(".srt"), _T(".sub"), _T(".smi"), _T(".psb"),
_T(".ssa"), _T(".ass"), _T(".idx"), _T(".usf"),
@@ -70,7 +68,7 @@ void GetSubFileNames(CString fn, CAtlArray<CString>& paths, CAtlArray<SubFile>&
bool fWeb = false;
{
-// int i = fn.Find(_T("://"));
+ // int i = fn.Find(_T("://"));
int i = fn.Find(_T("http://"));
if(i > 0) {
fn = _T("http") + fn.Mid(i);
@@ -81,29 +79,33 @@ void GetSubFileNames(CString fn, CAtlArray<CString>& paths, CAtlArray<SubFile>&
int l = fn.GetLength(), l2 = l;
l2 = fn.ReverseFind('.');
l = fn.ReverseFind('/') + 1;
- if(l2 < l) l2 = l;
+ if(l2 < l) {
+ l2 = l;
+ }
CString orgpath = fn.Left(l);
CString title = fn.Mid(l, l2-l);
CString filename = title + _T(".nooneexpectsthespanishinquisition");
- if(!fWeb)
- {
+ if(!fWeb) {
// struct _tfinddata_t file, file2;
// long hFile, hFile2 = 0;
WIN32_FIND_DATA wfd, wfd2;
HANDLE hFile, hFile2;
- for(ptrdiff_t k = 0; k < paths.GetCount(); k++)
- {
+ for(ptrdiff_t k = 0; k < paths.GetCount(); k++) {
CString path = paths[k];
path.Replace('\\', '/');
l = path.GetLength();
- if(l > 0 && path[l-1] != '/') path += '/';
+ if(l > 0 && path[l-1] != '/') {
+ path += '/';
+ }
- if(path.Find(':') == -1 && path.Find(_T("\\\\")) != 0) path = orgpath + path;
+ if(path.Find(':') == -1 && path.Find(_T("\\\\")) != 0) {
+ path = orgpath + path;
+ }
path.Replace(_T("/./"), _T("/"));
path.Replace('/', '\\');
@@ -112,64 +114,51 @@ void GetSubFileNames(CString fn, CAtlArray<CString>& paths, CAtlArray<SubFile>&
bool fEmpty = true;
- if((hFile = FindFirstFile(path + title + _T("*"), &wfd)) != INVALID_HANDLE_VALUE)
- {
- do
- {
- if(filename.CompareNoCase(wfd.cFileName) != 0)
- {
+ 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));
+ } 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
- {
+ 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)
- {
+ 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)
- {
+ if(hFile2 != INVALID_HANDLE_VALUE) {
FindClose(hFile2);
}
- }
- while(FindNextFile(hFile, &wfd));
+ } while(FindNextFile(hFile, &wfd));
FindClose(hFile);
}
}
}
}
- }
- else if(l > 7)
- {
+ } else if(l > 7) {
CWebTextFile wtf; // :)
- if(wtf.Open(orgpath + title + WEBSUBEXT))
- {
+ if(wtf.Open(orgpath + title + WEBSUBEXT)) {
CString fn;
- while(wtf.ReadString(fn) && fn.Find(_T("://")) >= 0)
- {
+ while(wtf.ReadString(fn) && fn.Find(_T("://")) >= 0) {
SubFile f;
f.fn = fn;
ret.Add(f);
diff --git a/src/Subtitles/HdmvSub.cpp b/src/Subtitles/HdmvSub.cpp
index 43a21d6b0..376eab8a6 100644
--- a/src/Subtitles/HdmvSub.cpp
+++ b/src/Subtitles/HdmvSub.cpp
@@ -60,8 +60,7 @@ CHdmvSub::~CHdmvSub()
void CHdmvSub::AllocSegment(int nSize)
{
- if (nSize > m_nTotalSegBuffer)
- {
+ if (nSize > m_nTotalSegBuffer) {
delete[] m_pSegBuffer;
m_pSegBuffer = DNew BYTE[nSize];
m_nTotalSegBuffer = nSize;
@@ -75,18 +74,16 @@ POSITION CHdmvSub::GetStartPosition(REFERENCE_TIME rt, double fps)
CompositionObject* pObject;
// Cleanup old PG
- while (m_pObjects.GetCount()>0)
- {
+ while (m_pObjects.GetCount()>0) {
pObject = m_pObjects.GetHead();
- if (pObject->m_rtStop < rt)
- {
+ 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
+ } else {
break;
+ }
}
return m_pObjects.GetHeadPosition();
@@ -101,92 +98,84 @@ HRESULT CHdmvSub::ParseSample(IMediaSample* pSample)
int lSampleLen;
hr = pSample->GetPointer(&pData);
- if(FAILED(hr) || pData == NULL) return hr;
+ if(FAILED(hr) || pData == NULL) {
+ return hr;
+ }
lSampleLen = pSample->GetActualDataLength();
pSample->GetTime(&rtStart, &rtStop);
- if (pData)
- {
+ if (pData) {
CGolombBuffer SampleBuffer (pData, lSampleLen);
- while (!SampleBuffer.IsEOF())
- {
- if (m_nCurSegment == NO_SEGMENT)
- {
+ 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;
+ 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)
- {
+ 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)
- {
+ 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)
- {
- 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);
+ 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) {
+ 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;
@@ -211,8 +200,7 @@ int CHdmvSub::ParsePresentationSegment(CGolombBuffer* pGBuffer)
palette_id_ref = pGBuffer->ReadByte();
nObjectNumber = pGBuffer->ReadByte();
- if (nObjectNumber > 0)
- {
+ if (nObjectNumber > 0) {
delete m_pCurrentObject;
m_pCurrentObject = DNew CompositionObject();
ParseCompositionObject (pGBuffer, m_pCurrentObject);
@@ -233,16 +221,16 @@ void CHdmvSub::ParsePalette(CGolombBuffer* pGBuffer, USHORT nSize) // #497
nNbEntry = (nSize-2) / sizeof(HDMV_PALETTE);
HDMV_PALETTE* pPalette = (HDMV_PALETTE*)pGBuffer->GetBufferPos();
- if (m_pDefaultPalette == NULL || m_nDefaultPaletteNbEntry != nNbEntry)
- {
+ if (m_pDefaultPalette == NULL || m_nDefaultPaletteNbEntry != nNbEntry) {
delete[] m_pDefaultPalette;
m_pDefaultPalette = new HDMV_PALETTE[nNbEntry];
m_nDefaultPaletteNbEntry = nNbEntry;
}
memcpy (m_pDefaultPalette, pPalette, nNbEntry*sizeof(HDMV_PALETTE));
- if (m_pCurrentObject)
+ if (m_pCurrentObject) {
m_pCurrentObject->SetPalette (nNbEntry, pPalette, m_VideoDescriptor.nVideoWidth>720);
+ }
}
void CHdmvSub::ParseObject(CGolombBuffer* pGBuffer, USHORT nUnitSize) // #498
@@ -252,13 +240,11 @@ void CHdmvSub::ParseObject(CGolombBuffer* pGBuffer, USHORT nUnitSize) // #498
BYTE m_sequence_desc;
ASSERT (m_pCurrentObject != NULL);
- if (m_pCurrentObject)// && m_pCurrentObject->m_object_id_ref == object_id)
- {
+ 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)
- {
+ if (m_sequence_desc & 0x80) {
DWORD object_data_length = (DWORD)pGBuffer->BitRead(24);
m_pCurrentObject->m_width = pGBuffer->ReadShort();
@@ -268,9 +254,9 @@ void CHdmvSub::ParseObject(CGolombBuffer* pGBuffer, USHORT nUnitSize) // #498
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
+ } else {
m_pCurrentObject->AppendRLEData (pGBuffer->GetBufferPos(), nUnitSize-4);
+ }
}
}
@@ -285,8 +271,7 @@ void CHdmvSub::ParseCompositionObject(CGolombBuffer* pGBuffer, CompositionObject
pCompositionObject->m_horizontal_position = pGBuffer->ReadShort();
pCompositionObject->m_vertical_position = pGBuffer->ReadShort();
- if (pCompositionObject->m_object_cropped_flag)
- {
+ 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();
@@ -313,10 +298,10 @@ void CHdmvSub::Render(SubPicDesc& spd, REFERENCE_TIME rt, RECT& bbox)
ASSERT (pObject!=NULL && spd.w >= pObject->m_width && spd.h >= pObject->m_height);
- if (pObject && spd.w >= pObject->m_width && spd.h >= pObject->m_height)
- {
- if (!pObject->HavePalette())
+ if (pObject && spd.w >= pObject->m_width && spd.h >= 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);
@@ -332,8 +317,7 @@ void CHdmvSub::Render(SubPicDesc& spd, REFERENCE_TIME rt, RECT& bbox)
HRESULT CHdmvSub::GetTextureSize (POSITION pos, SIZE& MaxTextureSize, SIZE& VideoSize, POINT& VideoTopLeft)
{
CompositionObject* pObject = m_pObjects.GetAt (pos);
- if (pObject)
- {
+ if (pObject) {
MaxTextureSize.cx = m_VideoDescriptor.nVideoWidth;
MaxTextureSize.cy = m_VideoDescriptor.nVideoHeight;
@@ -354,8 +338,7 @@ HRESULT CHdmvSub::GetTextureSize (POSITION pos, SIZE& MaxTextureSize, SIZE& Vide
void CHdmvSub::Reset()
{
CompositionObject* pObject;
- while (m_pObjects.GetCount() > 0)
- {
+ while (m_pObjects.GetCount() > 0) {
pObject = m_pObjects.RemoveHead();
delete pObject;
}
@@ -365,12 +348,12 @@ CompositionObject* CHdmvSub::FindObject(REFERENCE_TIME rt)
{
POSITION pos = m_pObjects.GetHeadPosition();
- while (pos)
- {
+ while (pos) {
CompositionObject* pObject = m_pObjects.GetAt (pos);
- if (rt >= pObject->m_rtStart && rt < pObject->m_rtStop)
+ if (rt >= pObject->m_rtStart && rt < pObject->m_rtStop) {
return pObject;
+ }
m_pObjects.GetNext(pos);
}
diff --git a/src/Subtitles/HdmvSub.h b/src/Subtitles/HdmvSub.h
index 50c949781..6c4c42646 100644
--- a/src/Subtitles/HdmvSub.h
+++ b/src/Subtitles/HdmvSub.h
@@ -32,8 +32,7 @@ public:
static const REFERENCE_TIME INVALID_TIME = _I64_MIN;
- enum HDMV_SEGMENT_TYPE
- {
+ enum HDMV_SEGMENT_TYPE {
NO_SEGMENT = 0xFFFF,
PALETTE = 0x14,
OBJECT = 0x15,
@@ -46,21 +45,18 @@ public:
};
- struct VIDEO_DESCRIPTOR
- {
+ struct VIDEO_DESCRIPTOR {
SHORT nVideoWidth;
SHORT nVideoHeight;
BYTE bFrameRate; // <= Frame rate here!
};
- struct COMPOSITION_DESCRIPTOR
- {
+ struct COMPOSITION_DESCRIPTOR {
SHORT nNumber;
BYTE bState;
};
- struct SEQUENCE_DESCRIPTOR
- {
+ struct SEQUENCE_DESCRIPTOR {
BYTE bFirstIn : 1;
BYTE bLastIn : 1;
BYTE bReserved : 8;
@@ -79,13 +75,11 @@ public:
};
- virtual REFERENCE_TIME GetStart(POSITION nPos)
- {
+ 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)
- {
+ virtual REFERENCE_TIME GetStop(POSITION nPos) {
CompositionObject* pObject = m_pObjects.GetAt(nPos);
return pObject!=NULL ? pObject->m_rtStop : INVALID_TIME;
};
diff --git a/src/Subtitles/RTS.cpp b/src/Subtitles/RTS.cpp
index b59346da0..fa1d9c085 100644
--- a/src/Subtitles/RTS.cpp
+++ b/src/Subtitles/RTS.cpp
@@ -54,8 +54,7 @@ CMyFont::CMyFont(STSStyle& style)
lf.lfOrientation = (LONG)style.mod_fontOrient;
#endif
- if(!CreateFontIndirect(&lf))
- {
+ if(!CreateFontIndirect(&lf)) {
_tcscpy(lf.lfFaceName, _T("Arial"));
CreateFontIndirect(&lf);
}
@@ -78,8 +77,7 @@ CWord::CWord(STSStyle& style, CStringW str, int ktype, int kstart, int kend)
, m_fLineBreak(false), m_fWhiteSpaceChar(false)
, m_pOpaqueBox(NULL)
{
- if(str.IsEmpty())
- {
+ if(str.IsEmpty()) {
m_fWhiteSpaceChar = m_fLineBreak = true;
}
@@ -91,14 +89,18 @@ CWord::CWord(STSStyle& style, CStringW str, int ktype, int kstart, int kend)
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);
+ || 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;
@@ -112,38 +114,45 @@ bool CWord::Append(CWord* w)
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));
- if(!ScanConvert()) 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;
+ if(!ScanConvert()) {
+ 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;
- 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))
- {
+ 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;
- if(m_pOpaqueBox)
+ if(m_pOpaqueBox) {
m_pOpaqueBox->Paint(p, org);
+ }
}
void CWord::Transform(CPoint org)
@@ -152,16 +161,18 @@ void CWord::Transform(CPoint org)
// CPUID from VDub
bool fSSE2 = !!(g_cpuid.m_flags & CCpuID::sse2);
- if(fSSE2) // SSE code
+ if(fSSE2) { // SSE code
Transform_SSE2(org);
- else // C-code
+ } else // C-code
#endif
Transform_C(org);
}
bool CWord::CreateOpaqueBox()
{
- if(m_pOpaqueBox) return(true);
+ if(m_pOpaqueBox) {
+ return(true);
+ }
STSStyle style = m_style;
style.borderStyle = 0;
@@ -210,14 +221,20 @@ void CWord::Transform_C( CPoint &org )
int minx = INT_MAX, miny = INT_MAX, maxx = -INT_MAX, maxy = -INT_MAX;
bool is_dist = m_style.mod_distort.enabled;
- if (is_dist)
- {
- for(int i = 0; i < mPathPoints; i++)
- {
- if(minx > mpPathPoints[i].x) minx = mpPathPoints[i].x;
- if(miny > mpPathPoints[i].y) miny = mpPathPoints[i].y;
- if(maxx < mpPathPoints[i].x) maxx = mpPathPoints[i].x;
- if(maxy < mpPathPoints[i].y) maxy = mpPathPoints[i].y;
+ if (is_dist) {
+ for(int i = 0; i < mPathPoints; i++) {
+ if(minx > mpPathPoints[i].x) {
+ minx = mpPathPoints[i].x;
+ }
+ if(miny > mpPathPoints[i].y) {
+ miny = mpPathPoints[i].y;
+ }
+ if(maxx < mpPathPoints[i].x) {
+ maxx = mpPathPoints[i].x;
+ }
+ if(maxy < mpPathPoints[i].y) {
+ maxy = mpPathPoints[i].y;
+ }
}
xsz = max(maxx - minx, 0);
@@ -232,8 +249,7 @@ void CWord::Transform_C( CPoint &org )
}
#endif
- for(ptrdiff_t i = 0; i < mPathPoints; i++)
- {
+ for(ptrdiff_t i = 0; i < mPathPoints; i++) {
double x, y, z, xx, yy, zz;
x = mpPathPoints[i].x;
@@ -243,8 +259,7 @@ void CWord::Transform_C( CPoint &org )
z = m_style.mod_z;
double u, v;
- if (is_dist)
- {
+ if (is_dist) {
u = (x-minx) / xsz;
v = (y-miny) / ysz;
@@ -331,10 +346,8 @@ void CWord::Transform_SSE2( CPoint &org )
__m128 __max = _mm_set_ps(-INT_MAX, -INT_MAX, 1, 1);
bool is_dist = m_style.mod_distort.enabled;
- if(is_dist)
- {
- for(int i = 0; i < mPathPoints; i++)
- {
+ if(is_dist) {
+ for(int i = 0; i < mPathPoints; i++) {
__m128 __point = _mm_set_ps(mpPathPoints[i].x, mpPathPoints[i].y, 0, 0);
__minx = _mm_min_ps(__minx, __point);
__max = _mm_max_ps(__max, __point);
@@ -375,34 +388,29 @@ void CWord::Transform_SSE2( CPoint &org )
int mPathPointsD4 = mPathPoints / 4;
int mPathPointsM4 = mPathPoints % 4;
- for(ptrdiff_t i = 0; i < mPathPointsD4 + 1; i++)
- {
+ for(ptrdiff_t i = 0; i < mPathPointsD4 + 1; i++) {
__m128 __pointx, __pointy;
// we can't use load .-.
- if(i != mPathPointsD4)
- {
+ if(i != mPathPointsD4) {
__pointx = _mm_set_ps(mpPathPoints[4 * i + 0].x, mpPathPoints[4 * i + 1].x, mpPathPoints[4 * i + 2].x, mpPathPoints[4 * i + 3].x);
__pointy = _mm_set_ps(mpPathPoints[4 * i + 0].y, mpPathPoints[4 * i + 1].y, mpPathPoints[4 * i + 2].y, mpPathPoints[4 * i + 3].y);
- }
- else // last cycle
- {
- switch(mPathPointsM4)
- {
- default:
- case 0:
- continue;
- case 1:
- __pointx = _mm_set_ps(mpPathPoints[4 * i + 0].x, 0, 0, 0);
- __pointy = _mm_set_ps(mpPathPoints[4 * i + 0].y, 0, 0, 0);
- break;
- case 2:
- __pointx = _mm_set_ps(mpPathPoints[4 * i + 0].x, mpPathPoints[4 * i + 1].x, 0, 0);
- __pointy = _mm_set_ps(mpPathPoints[4 * i + 0].y, mpPathPoints[4 * i + 1].y, 0, 0);
- break;
- case 3:
- __pointx = _mm_set_ps(mpPathPoints[4 * i + 0].x, mpPathPoints[4 * i + 1].x, mpPathPoints[4 * i + 2].x, 0);
- __pointy = _mm_set_ps(mpPathPoints[4 * i + 0].y, mpPathPoints[4 * i + 1].y, mpPathPoints[4 * i + 2].y, 0);
- break;
+ } else { // last cycle
+ switch(mPathPointsM4) {
+ default:
+ case 0:
+ continue;
+ case 1:
+ __pointx = _mm_set_ps(mpPathPoints[4 * i + 0].x, 0, 0, 0);
+ __pointy = _mm_set_ps(mpPathPoints[4 * i + 0].y, 0, 0, 0);
+ break;
+ case 2:
+ __pointx = _mm_set_ps(mpPathPoints[4 * i + 0].x, mpPathPoints[4 * i + 1].x, 0, 0);
+ __pointy = _mm_set_ps(mpPathPoints[4 * i + 0].y, mpPathPoints[4 * i + 1].y, 0, 0);
+ break;
+ case 3:
+ __pointx = _mm_set_ps(mpPathPoints[4 * i + 0].x, mpPathPoints[4 * i + 1].x, mpPathPoints[4 * i + 2].x, 0);
+ __pointy = _mm_set_ps(mpPathPoints[4 * i + 0].y, mpPathPoints[4 * i + 1].y, mpPathPoints[4 * i + 2].y, 0);
+ break;
}
}
@@ -410,8 +418,7 @@ void CWord::Transform_SSE2( CPoint &org )
__m128 __pointz = _mm_set_ps1(m_style.mod_z);
// distort
- if(is_dist)
- {
+ if(is_dist) {
//P = P0 + (P1 - P0)u + (P3 - P0)v + (P0 + P2 - P1 - P3)uv
__m128 __u = _mm_sub_ps(__pointx, __minx);
__m128 __v = _mm_sub_ps(__pointy, __miny);
@@ -446,33 +453,28 @@ void CWord::Transform_SSE2( CPoint &org )
}
// randomize
- if(xrnd!=0 || yrnd!=0 || zrnd!=0)
- {
+ if(xrnd!=0 || yrnd!=0 || zrnd!=0) {
__declspec(align(16)) float rx[4], ry[4], rz[4];
- for(int k=0; k<4; k++)
- {
+ for(int k=0; k<4; k++) {
rx[k] = xrnd > 0 ? (xrnd - rand() % (int)(xrnd * 2 + 1)) : 0;
ry[k] = yrnd > 0 ? (yrnd - rand() % (int)(yrnd * 2 + 1)) : 0;
rz[k] = zrnd > 0 ? (zrnd - rand() % (int)(zrnd * 2 + 1)) : 0;
}
__m128 __001 = _mm_set_ps1(0.01f);
- if(xrnd!=0)
- {
+ if(xrnd!=0) {
__m128 __rx = _mm_load_ps(rx);
__rx = _mm_mul_ps(__rx, __001);
__pointx = _mm_add_ps(__pointx, __rx);
}
- if(yrnd!=0)
- {
+ if(yrnd!=0) {
__m128 __ry = _mm_load_ps(ry);
__ry = _mm_mul_ps(__ry, __001);
__pointy = _mm_add_ps(__pointy, __ry);
}
- if(zrnd!=0)
- {
+ if(zrnd!=0) {
__m128 __rz = _mm_load_ps(rz);
__rz = _mm_mul_ps(__rz, __001);
__pointz = _mm_add_ps(__pointz, __rz);
@@ -484,26 +486,20 @@ void CWord::Transform_SSE2( CPoint &org )
// scale and shift
__m128 __tmpx;
- if(m_style.fontShiftX!=0)
- {
+ if(m_style.fontShiftX!=0) {
__tmpx = _mm_mul_ps(__xshift, __pointy);
__tmpx = _mm_add_ps(__tmpx, __pointx);
- }
- else
- {
+ } else {
__tmpx = __pointx;
}
__tmpx = _mm_mul_ps(__tmpx, __xscale);
__tmpx = _mm_sub_ps(__tmpx, __xorg);
__m128 __tmpy;
- if(m_style.fontShiftY!=0)
- {
+ if(m_style.fontShiftY!=0) {
__tmpy = _mm_mul_ps(__yshift, __pointx);
__tmpy = _mm_add_ps(__tmpy, __pointy);
- }
- else
- {
+ } else {
__tmpy = __pointy;
}
__tmpy = _mm_mul_ps(__tmpy, __yscale);
@@ -552,18 +548,13 @@ void CWord::Transform_SSE2( CPoint &org )
__pointx = _mm_add_ps(__pointx, __05);
__pointy = _mm_add_ps(__pointy, __05);
- if(i == mPathPointsD4) // last cycle
- {
- for(int k=0; k<mPathPointsM4; k++)
- {
+ 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++)
- {
+ } 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]);
}
@@ -577,8 +568,7 @@ void CWord::Transform_SSE2( CPoint &org )
CText::CText(STSStyle& style, CStringW str, int ktype, int kstart, int kend)
: CWord(style, str, ktype, kstart, kend)
{
- if(m_str == L" ")
- {
+ if(m_str == L" ") {
m_fWhiteSpaceChar = true;
}
@@ -589,13 +579,10 @@ CText::CText(STSStyle& style, CStringW str, int ktype, int kstart, int kend)
#ifdef _VSMOD // patch m007. symbol rotating
double t = (double)m_style.mod_fontOrient * 3.1415926 / 1800;
#endif
- if(m_style.fontSpacing || (long)GetVersion() < 0)
- {
- for(LPCWSTR s = m_str; *s; s++)
- {
+ if(m_style.fontSpacing || (long)GetVersion() < 0) {
+ for(LPCWSTR s = m_str; *s; s++) {
CSize extent;
- if(!GetTextExtentPoint32W(g_hDC, s, 1, &extent))
- {
+ if(!GetTextExtentPoint32W(g_hDC, s, 1, &extent)) {
SelectFont(g_hDC, hOldFont);
ASSERT(0);
return;
@@ -606,13 +593,10 @@ CText::CText(STSStyle& style, CStringW str, int ktype, int kstart, int kend)
m_width += extent.cx + (int)m_style.fontSpacing;
#endif
}
-// m_width -= (int)m_style.fontSpacing; // TODO: subtract only at the end of the line
- }
- else
- {
+ // m_width -= (int)m_style.fontSpacing; // TODO: subtract only at the end of the line
+ } else {
CSize extent;
- if(!GetTextExtentPoint32W(g_hDC, m_str, wcslen(str), &extent))
- {
+ if(!GetTextExtentPoint32W(g_hDC, m_str, wcslen(str), &extent)) {
SelectFont(g_hDC, hOldFont);
ASSERT(0);
return;
@@ -647,15 +631,12 @@ bool CText::CreatePath()
int width = 0;
- if(m_style.fontSpacing || (long)GetVersion() < 0)
- {
+ if(m_style.fontSpacing || (long)GetVersion() < 0) {
bool bFirstPath = true;
- for(LPCWSTR s = m_str; *s; s++)
- {
+ for(LPCWSTR s = m_str; *s; s++) {
CSize extent;
- if(!GetTextExtentPoint32W(g_hDC, s, 1, &extent))
- {
+ if(!GetTextExtentPoint32W(g_hDC, s, 1, &extent)) {
SelectFont(g_hDC, hOldFont);
ASSERT(0);
return(false);
@@ -668,12 +649,9 @@ bool CText::CreatePath()
width += extent.cx + (int)m_style.fontSpacing;
}
- }
- else
- {
+ } else {
CSize extent;
- if(!GetTextExtentPoint32W(g_hDC, m_str, m_str.GetLength(), &extent))
- {
+ if(!GetTextExtentPoint32W(g_hDC, m_str, m_str.GetLength(), &extent)) {
SelectFont(g_hDC, hOldFont);
ASSERT(0);
return(false);
@@ -710,7 +688,9 @@ CWord* CPolygon::Copy()
bool CPolygon::Append(CWord* w)
{
CPolygon* p = dynamic_cast<CPolygon*>(w);
- if(!p) return(false);
+ if(!p) {
+ return(false);
+ }
// TODO
return(false);
@@ -733,7 +713,9 @@ bool CPolygon::GetPOINT(CStringW& str, POINT& ret)
bool CPolygon::ParseStr()
{
- if(m_pathTypesOrg.GetCount() > 0) return(true);
+ if(m_pathTypesOrg.GetCount() > 0) {
+ return(true);
+ }
CPoint p;
int i, j, lastsplinestart = -1, firstmoveto = -1, lastmoveto = -1;
@@ -749,96 +731,95 @@ bool CPolygon::ParseStr()
str.Replace(L"c", L"*c");
int k = 0;
- for(CStringW s = str.Tokenize(L"*", k); !s.IsEmpty(); s = str.Tokenize(L"*", k))
- {
+ 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 = 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 = m_pathTypesOrg.GetCount();
- if (j < 1) break;
- while(GetPOINT(s, p))
- {
- m_pathTypesOrg.Add(PT_BEZIERTO);
- m_pathPointsOrg.Add(p);
- j++;
- }
- j = 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 = 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;
+ switch(c) {
+ case 'm':
+ lastmoveto = 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 = m_pathTypesOrg.GetCount();
+ if (j < 1) {
+ break;
+ }
+ while(GetPOINT(s, p)) {
+ m_pathTypesOrg.Add(PT_BEZIERTO);
+ m_pathPointsOrg.Add(p);
+ j++;
+ }
+ j = 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 = 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)
- {
+ if(lastmoveto == -1 || firstmoveto > 0) {
m_pathTypesOrg.RemoveAll();
m_pathPointsOrg.RemoveAll();
return(false);
@@ -846,14 +827,21 @@ bool CPolygon::ParseStr()
int minx = INT_MAX, miny = INT_MAX, maxx = -INT_MAX, maxy = -INT_MAX;
- for(i = 0; i < m_pathTypesOrg.GetCount(); i++)
- {
+ for(i = 0; i < m_pathTypesOrg.GetCount(); i++) {
m_pathPointsOrg[i].x = (int)(64 * m_scalex * m_pathPointsOrg[i].x);
m_pathPointsOrg[i].y = (int)(64 * m_scaley * m_pathPointsOrg[i].y);
- if(minx > m_pathPointsOrg[i].x) minx = m_pathPointsOrg[i].x;
- if(miny > m_pathPointsOrg[i].y) miny = m_pathPointsOrg[i].y;
- if(maxx < m_pathPointsOrg[i].x) maxx = m_pathPointsOrg[i].x;
- if(maxy < m_pathPointsOrg[i].y) maxy = m_pathPointsOrg[i].y;
+ if(minx > m_pathPointsOrg[i].x) {
+ minx = m_pathPointsOrg[i].x;
+ }
+ if(miny > m_pathPointsOrg[i].y) {
+ miny = m_pathPointsOrg[i].y;
+ }
+ if(maxx < m_pathPointsOrg[i].x) {
+ maxx = m_pathPointsOrg[i].x;
+ }
+ if(maxy < m_pathPointsOrg[i].y) {
+ maxy = m_pathPointsOrg[i].y;
+ }
}
m_width = max(maxx - minx, 0);
@@ -873,13 +861,16 @@ bool CPolygon::ParseStr()
bool CPolygon::CreatePath()
{
size_t len = m_pathTypesOrg.GetCount();
- if(len == 0) return(false);
+ if(len == 0) {
+ return(false);
+ }
- if(mPathPoints != len)
- {
+ if(mPathPoints != len) {
mpPathTypes = (BYTE*)realloc(mpPathTypes, len*sizeof(BYTE));
mpPathPoints = (POINT*)realloc(mpPathPoints, len*sizeof(POINT));
- if(!mpPathTypes || !mpPathPoints) return(false);
+ if(!mpPathTypes || !mpPathPoints) {
+ return(false);
+ }
mPathPoints = len;
}
@@ -897,12 +888,14 @@ CClipper::CClipper(CStringW str, CSize size, double scalex, double scaley, bool
m_size.cx = m_size.cy = 0;
m_pAlphaMask = NULL;
- if(size.cx < 0 || size.cy < 0)
+ if(size.cx < 0 || size.cy < 0) {
return;
+ }
m_pAlphaMask = DNew BYTE[size.cx*size.cy];
- if (!m_pAlphaMask)
+ if (!m_pAlphaMask) {
return;
+ }
m_size = size;
m_inverse = inverse;
@@ -926,34 +919,42 @@ CClipper::CClipper(CStringW str, CSize size, double scalex, double scaley, bool
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(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;
+ 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)
+ while(h--) {
+ for(ptrdiff_t wt=0; wt<w; ++wt) {
dst[wt] = src[wt*2];
+ }
src += 2*mOverlayWidth;
dst += m_size.cx;
}
- if(inverse)
- {
+ 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
+ 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;
+ if(m_pAlphaMask) {
+ delete [] m_pAlphaMask;
+ }
m_pAlphaMask = NULL;
}
@@ -972,16 +973,19 @@ bool CClipper::Append(CWord* w)
CLine::~CLine()
{
POSITION pos = GetHeadPosition();
- while(pos) delete GetNext(pos);
+ while(pos) {
+ delete GetNext(pos);
+ }
}
void CLine::Compact()
{
POSITION pos = GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CWord* w = GetNext(pos);
- if(!w->m_fWhiteSpaceChar) break;
+ if(!w->m_fWhiteSpaceChar) {
+ break;
+ }
m_width -= w->m_width;
delete w;
@@ -989,17 +993,20 @@ void CLine::Compact()
}
pos = GetTailPosition();
- while(pos)
- {
+ while(pos) {
CWord* w = GetPrev(pos);
- if(!w->m_fWhiteSpaceChar) break;
+ if(!w->m_fWhiteSpaceChar) {
+ break;
+ }
m_width -= w->m_width;
delete w;
RemoveTail();
}
- if(IsEmpty()) return;
+ if(IsEmpty()) {
+ return;
+ }
CLine l;
l.AddTailList(this);
@@ -1008,25 +1015,32 @@ void CLine::Compact()
CWord* last = NULL;
pos = l.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CWord* w = l.GetNext(pos);
- if(!last || !last->Append(w))
+ if(!last || !last->Append(w)) {
AddTail(last = w->Copy());
+ }
}
m_ascent = m_descent = m_borderX = m_borderY = 0;
pos = GetHeadPosition();
- while(pos)
- {
+ 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);
+ 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);
+ }
}
}
@@ -1039,14 +1053,14 @@ CRect CLine::PaintShadow(SubPicDesc& spd, CRect& clipRect, BYTE* pAlphaMask, CPo
CRect bbox(0, 0, 0, 0);
POSITION pos = GetHeadPosition();
- while(pos)
- {
+ 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)
- {
+ if(w->m_style.shadowDepthX != 0 || w->m_style.shadowDepthY != 0) {
int x = p.x + (int)(w->m_style.shadowDepthX+0.5);
#ifdef _VSMOD // patch m001. Vertical fontspacing
int y = p.y - w->m_style.mod_verticalSpace + m_ascent - w->m_ascent + (int)(w->m_style.shadowDepthY+0.5);
@@ -1054,7 +1068,9 @@ CRect CLine::PaintShadow(SubPicDesc& spd, CRect& clipRect, BYTE* pAlphaMask, CPo
int y = p.y + m_ascent - w->m_ascent + (int)(w->m_style.shadowDepthY+0.5);
#endif
DWORD a = 0xff - w->m_style.alpha[3];
- if(alpha > 0) a = MulDiv(a, 0xff - alpha, 0xff);
+ if(alpha > 0) {
+ a = MulDiv(a, 0xff - alpha, 0xff);
+ }
COLORREF shadow = revcolor(w->m_style.colors[3]) | (a<<24);
DWORD sw[6] = {shadow, (DWORD)-1};
@@ -1070,8 +1086,7 @@ CRect CLine::PaintShadow(SubPicDesc& spd, CRect& clipRect, BYTE* pAlphaMask, CPo
#endif
w->Paint(CPoint(x, y), org);
- if(w->m_style.borderStyle == 0)
- {
+ if(w->m_style.borderStyle == 0) {
#ifdef _VSMOD // patch m004. gradient colors
bbox |= w->Draw(spd, clipRect, pAlphaMask, x, y, sw,
w->m_ktype > 0 || w->m_style.alpha[0] < 0xff,
@@ -1081,9 +1096,7 @@ CRect CLine::PaintShadow(SubPicDesc& spd, CRect& clipRect, BYTE* pAlphaMask, CPo
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));
#endif
- }
- else if(w->m_style.borderStyle == 1 && w->m_pOpaqueBox)
- {
+ } else if(w->m_style.borderStyle == 1 && w->m_pOpaqueBox) {
#ifdef _VSMOD // patch m004. gradient colors
bbox |= w->m_pOpaqueBox->Draw(spd, clipRect, pAlphaMask, x, y, sw, true, false,3,w->m_style.mod_grad, mod_vc);
#else
@@ -1107,14 +1120,14 @@ CRect CLine::PaintOutline(SubPicDesc& spd, CRect& clipRect, BYTE* pAlphaMask, CP
CRect bbox(0, 0, 0, 0);
POSITION pos = GetHeadPosition();
- while(pos)
- {
+ 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))
- {
+ if(w->m_style.outlineWidthX+w->m_style.outlineWidthY > 0 && !(w->m_ktype == 2 && time < w->m_kstart)) {
int x = p.x;
#ifdef _VSMOD // patch m001. Vertical fontspacing
int y = p.y - w->m_style.mod_verticalSpace + m_ascent - w->m_ascent;
@@ -1122,7 +1135,9 @@ CRect CLine::PaintOutline(SubPicDesc& spd, CRect& clipRect, BYTE* pAlphaMask, CP
int y = p.y + m_ascent - w->m_ascent;
#endif
DWORD aoutline = w->m_style.alpha[2];
- if(alpha > 0) aoutline += MulDiv(alpha, 0xff - w->m_style.alpha[2], 0xff);
+ if(alpha > 0) {
+ aoutline += MulDiv(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};
@@ -1139,16 +1154,13 @@ CRect CLine::PaintOutline(SubPicDesc& spd, CRect& clipRect, BYTE* pAlphaMask, CP
w->Paint(CPoint(x, y), org);
- if(w->m_style.borderStyle == 0)
- {
+ if(w->m_style.borderStyle == 0) {
#ifdef _VSMOD // patch m004. gradient colors
bbox |= w->Draw(spd, clipRect, pAlphaMask, x, y, sw, !w->m_style.alpha[0] && !w->m_style.alpha[1] && !alpha, true,2,w->m_style.mod_grad, mod_vc);
#else
bbox |= w->Draw(spd, clipRect, pAlphaMask, x, y, sw, !w->m_style.alpha[0] && !w->m_style.alpha[1] && !alpha, true);
#endif
- }
- else if(w->m_style.borderStyle == 1 && w->m_pOpaqueBox)
- {
+ } else if(w->m_style.borderStyle == 1 && w->m_pOpaqueBox) {
#ifdef _VSMOD // patch m004. gradient colors
bbox |= w->m_pOpaqueBox->Draw(spd, clipRect, pAlphaMask, x, y, sw, true, false,2,w->m_style.mod_grad, mod_vc);
#else
@@ -1172,11 +1184,12 @@ CRect CLine::PaintBody(SubPicDesc& spd, CRect& clipRect, BYTE* pAlphaMask, CPoin
CRect bbox(0, 0, 0, 0);
POSITION pos = GetHeadPosition();
- while(pos)
- {
+ 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;
#ifdef _VSMOD // patch m001. Vertical fontspacing
@@ -1187,11 +1200,15 @@ CRect CLine::PaintBody(SubPicDesc& spd, CRect& clipRect, BYTE* pAlphaMask, CPoin
// colors
DWORD aprimary = w->m_style.alpha[0];
- if(alpha > 0) aprimary += MulDiv(alpha, 0xff - w->m_style.alpha[0], 0xff);
+ if(alpha > 0) {
+ aprimary += MulDiv(alpha, 0xff - w->m_style.alpha[0], 0xff);
+ }
COLORREF primary = revcolor(w->m_style.colors[0]) | ((0xff-aprimary)<<24);
DWORD asecondary = w->m_style.alpha[1];
- if(alpha > 0) asecondary += MulDiv(alpha, 0xff - w->m_style.alpha[1], 0xff);
+ if(alpha > 0) {
+ asecondary += MulDiv(alpha, 0xff - w->m_style.alpha[1], 0xff);
+ }
COLORREF secondary = revcolor(w->m_style.colors[1]) | ((0xff-asecondary)<<24);
DWORD sw[6] = {primary, 0, secondary};
@@ -1200,40 +1217,38 @@ CRect CLine::PaintBody(SubPicDesc& spd, CRect& clipRect, BYTE* pAlphaMask, CPoin
double t;
- if(w->m_ktype == 0 || w->m_ktype == 2)
- {
+ 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)
- {
+ } 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)
- {
+ if(angle > 90 && angle < 270) {
t = 1-t;
COLORREF tmp = sw[0];
sw[0] = sw[2];
sw[2] = tmp;
}
+ } else {
+ t = 1.0;
}
- else t = 1.0;
}
- if(t >= 1)
- {
+ if(t >= 1) {
sw[1] = 0xFFFFFFF;
}
// move dividerpoint
int bluradjust = 0;
- if (w->m_style.fGaussianBlur > 0)
+ if (w->m_style.fGaussianBlur > 0) {
bluradjust += (int)(w->m_style.fGaussianBlur*3*8 + 0.5) | 1;
- if (w->m_style.fBlur)
+ }
+ if (w->m_style.fBlur) {
bluradjust += 8;
+ }
double tx = w->m_style.fontAngleZ;
UNUSED_ALWAYS(tx);
sw[4] = sw[2];
@@ -1284,18 +1299,25 @@ CSubtitle::~CSubtitle()
void CSubtitle::Empty()
{
POSITION pos = GetHeadPosition();
- while(pos) delete GetNext(pos);
+ while(pos) {
+ delete GetNext(pos);
+ }
pos = m_words.GetHeadPosition();
- while(pos) delete m_words.GetNext(pos);
+ while(pos) {
+ delete m_words.GetNext(pos);
+ }
- for(ptrdiff_t i = 0; i < EF_NUMBEROFEFFECTS; i++)
- {
- if(m_effects[i]) delete m_effects[i];
+ 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);
- if(m_pClipper) delete m_pClipper;
+ if(m_pClipper) {
+ delete m_pClipper;
+ }
m_pClipper = NULL;
}
@@ -1304,7 +1326,9 @@ int CSubtitle::GetFullWidth()
int width = 0;
POSITION pos = m_words.GetHeadPosition();
- while(pos) width += m_words.GetNext(pos)->m_width;
+ while(pos) {
+ width += m_words.GetNext(pos)->m_width;
+ }
return(width);
}
@@ -1313,10 +1337,11 @@ int CSubtitle::GetFullLineWidth(POSITION pos)
{
int width = 0;
- while(pos)
- {
+ while(pos) {
CWord* w = m_words.GetNext(pos);
- if(w->m_fLineBreak) break;
+ if(w->m_fLineBreak) {
+ break;
+ }
width += w->m_width;
}
@@ -1325,35 +1350,32 @@ int CSubtitle::GetFullLineWidth(POSITION pos)
int CSubtitle::GetWrapWidth(POSITION pos, int maxwidth)
{
- if(m_wrapStyle == 0 || m_wrapStyle == 3)
- {
- if(maxwidth > 0)
- {
-// int fullwidth = GetFullWidth();
+ 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 width = 0, wordwidth = 0;
- while(pos && width < minwidth)
- {
+ while(pos && width < minwidth) {
CWord* w = m_words.GetNext(pos);
wordwidth = w->m_width;
- if(abs(width + wordwidth) < abs(maxwidth)) width += wordwidth;
+ if(abs(width + wordwidth) < abs(maxwidth)) {
+ width += wordwidth;
+ }
}
maxwidth = width;
- if(m_wrapStyle == 3 && pos) maxwidth -= wordwidth;
+ if(m_wrapStyle == 3 && pos) {
+ maxwidth -= wordwidth;
+ }
}
- }
- else if(m_wrapStyle == 1)
- {
-// maxwidth = maxwidth;
- }
- else if(m_wrapStyle == 2)
- {
+ } else if(m_wrapStyle == 1) {
+ // maxwidth = maxwidth;
+ } else if(m_wrapStyle == 2) {
maxwidth = INT_MAX;
}
@@ -1362,10 +1384,14 @@ int CSubtitle::GetWrapWidth(POSITION pos, int 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);
+ if(!ret) {
+ return(NULL);
+ }
ret->m_width = ret->m_ascent = ret->m_descent = ret->m_borderX = ret->m_borderY = 0;
@@ -1373,19 +1399,24 @@ CLine* CSubtitle::GetNextLine(POSITION& pos, int maxwidth)
bool fEmptyLine = true;
- while(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)
- {
+ if(w->m_fLineBreak) {
+ if(fEmptyLine) {
ret->m_ascent /= 2;
ret->m_descent /= 2;
ret->m_borderX = ret->m_borderY = 0;
@@ -1402,30 +1433,30 @@ CLine* CSubtitle::GetNextLine(POSITION& pos, int maxwidth)
int width = w->m_width;
POSITION pos2 = pos;
- while(pos2)
- {
+ while(pos2) {
if(m_words.GetAt(pos2)->m_fWhiteSpaceChar != fWSC
- || m_words.GetAt(pos2)->m_fLineBreak) break;
+ || m_words.GetAt(pos2)->m_fLineBreak) {
+ break;
+ }
CWord* w2 = m_words.GetNext(pos2);
width += w2->m_width;
}
- if((ret->m_width += width) <= maxwidth || ret->IsEmpty())
- {
+ if((ret->m_width += width) <= maxwidth || ret->IsEmpty()) {
ret->AddTail(w->Copy());
- while(pos != pos2)
- {
+ while(pos != pos2) {
ret->AddTail(m_words.GetNext(pos)->Copy());
}
pos = pos2;
- }
- else
- {
- if(pos) m_words.GetPrev(pos);
- else pos = m_words.GetTailPosition();
+ } else {
+ if(pos) {
+ m_words.GetPrev(pos);
+ } else {
+ pos = m_words.GetTailPosition();
+ }
ret->m_width -= width;
@@ -1443,30 +1474,30 @@ void CSubtitle::CreateClippers(CSize size)
size.cx >>= 3;
size.cy >>= 3;
- if(m_effects[EF_BANNER] && m_effects[EF_BANNER]->param[2])
- {
+ 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)
- {
+ 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);
- if(!m_pClipper) return;
+ 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)
- {
+ 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)
+ for(ptrdiff_t i = 0; i < k; i++, a += da) {
am[i] = (am[i]*a)>>14;
+ }
a = 0x40<<8;
k = w-width;
@@ -1476,22 +1507,22 @@ void CSubtitle::CreateClippers(CSize size)
k = 0;
}
- for(ptrdiff_t i = k; i < w; i++, a -= da)
+ 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])
- {
+ } 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)
- {
+ 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);
- if(!m_pClipper) return;
+ if(!m_pClipper) {
+ return;
+ }
}
int da = (64<<8)/height;
@@ -1506,16 +1537,15 @@ void CSubtitle::CreateClippers(CSize size)
l = h;
}
- if(k < 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++)
+ for(ptrdiff_t j = k; j < l; j++, a += da) {
+ for(ptrdiff_t i = 0; i < w; i++, am++) {
*am = ((*am)*a)>>14;
+ }
}
}
@@ -1531,15 +1561,14 @@ void CSubtitle::CreateClippers(CSize size)
l = h;
}
- if(k < 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++)
+ 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);
@@ -1558,13 +1587,13 @@ void CSubtitle::MakeLines(CSize size, CRect marginRect)
CLine* l = NULL;
POSITION pos = m_words.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
l = GetNextLine(pos, size.cx - marginRect.left - marginRect.right);
- if(!l) break;
+ if(!l) {
+ break;
+ }
- if(fFirstLine)
- {
+ if(fFirstLine) {
m_topborder = l->m_borderY;
fFirstLine = false;
}
@@ -1575,7 +1604,9 @@ void CSubtitle::MakeLines(CSize size, CRect marginRect)
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
@@ -1597,27 +1628,25 @@ void CScreenLayoutAllocator::Empty()
void CScreenLayoutAllocator::AdvanceToSegment(int segment, const CAtlArray<int>& sa)
{
POSITION pos = m_subrects.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
POSITION prev = pos;
SubRect& sr = m_subrects.GetNext(pos);
bool fFound = false;
- if(abs(sr.segment - segment) <= 1) // using abs() makes it possible to play the subs backwards, too :)
- {
- for(ptrdiff_t i = 0; i < sa.GetCount() && !fFound; i++)
- {
- if(sa[i] == sr.entry)
- {
+ if(abs(sr.segment - segment) <= 1) { // using abs() makes it possible to play the subs backwards, too :)
+ for(ptrdiff_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);
+ }
}
}
@@ -1626,11 +1655,9 @@ CRect CScreenLayoutAllocator::AllocRect(CSubtitle* s, int segment, int entry, in
// TODO: handle collisions == 1 (reversed collisions)
POSITION pos = m_subrects.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
SubRect& sr = m_subrects.GetNext(pos);
- if(sr.segment == segment && sr.entry == entry)
- {
+ if(sr.segment == segment && sr.entry == entry) {
return(sr.r + CRect(0, -s->m_topborder, 0, -s->m_bottomborder));
}
}
@@ -1641,24 +1668,18 @@ CRect CScreenLayoutAllocator::AllocRect(CSubtitle* s, int segment, int entry, in
bool fOK;
- do
- {
+ do {
fOK = true;
pos = m_subrects.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
SubRect& sr = m_subrects.GetNext(pos);
- if(layer == sr.layer && !(r & sr.r).IsRectEmpty())
- {
- if(fSearchDown)
- {
+ if(layer == sr.layer && !(r & sr.r).IsRectEmpty()) {
+ if(fSearchDown) {
r.bottom = sr.r.bottom + r.Height();
r.top = sr.r.bottom;
- }
- else
- {
+ } else {
r.top = sr.r.top - r.Height();
r.bottom = sr.r.top;
}
@@ -1666,8 +1687,7 @@ CRect CScreenLayoutAllocator::AllocRect(CSubtitle* s, int segment, int entry, in
fOK = false;
}
}
- }
- while(!fOK);
+ } while(!fOK);
SubRect sr;
sr.r = r;
@@ -1686,8 +1706,7 @@ CRenderedTextSubtitle::CRenderedTextSubtitle(CCritSec* pLock, STSStyle *styleOve
{
m_size = CSize(0, 0);
- if(g_hDC_refcnt == 0)
- {
+ if(g_hDC_refcnt == 0) {
g_hDC = CreateCompatibleDC(NULL);
#ifdef _VSMOD // patch m007. symbol rotating
SetGraphicsMode(g_hDC, GM_ADVANCED); // patch for lfOrientation
@@ -1705,7 +1724,9 @@ CRenderedTextSubtitle::~CRenderedTextSubtitle()
Deinit();
g_hDC_refcnt--;
- if(g_hDC_refcnt == 0) DeleteDC(g_hDC);
+ if(g_hDC_refcnt == 0) {
+ DeleteDC(g_hDC);
+ }
}
void CRenderedTextSubtitle::Copy(CSimpleTextSubtitle& sts)
@@ -1714,8 +1735,7 @@ void CRenderedTextSubtitle::Copy(CSimpleTextSubtitle& sts)
m_size = CSize(0, 0);
- if(CRenderedTextSubtitle* pRTS = dynamic_cast<CRenderedTextSubtitle*>(&sts))
- {
+ if(CRenderedTextSubtitle* pRTS = dynamic_cast<CRenderedTextSubtitle*>(&sts)) {
m_size = pRTS->m_size;
}
}
@@ -1732,8 +1752,7 @@ void CRenderedTextSubtitle::OnChanged()
__super::OnChanged();
POSITION pos = m_subtitleCache.GetStartPosition();
- while(pos)
- {
+ while(pos) {
int i;
CSubtitle* s;
m_subtitleCache.GetNextAssoc(pos, i, s);
@@ -1760,8 +1779,7 @@ bool CRenderedTextSubtitle::Init(CSize size, CRect vidrect)
void CRenderedTextSubtitle::Deinit()
{
POSITION pos = m_subtitleCache.GetStartPosition();
- while(pos)
- {
+ while(pos) {
int i;
CSubtitle* s;
m_subtitleCache.GetNextAssoc(pos, i, s);
@@ -1779,24 +1797,28 @@ void CRenderedTextSubtitle::Deinit()
void CRenderedTextSubtitle::ParseEffect(CSubtitle* sub, CString str)
{
str.Trim();
- if(!sub || str.IsEmpty()) return;
+ if(!sub || str.IsEmpty()) {
+ return;
+ }
const TCHAR* s = _tcschr(str, ';');
- if(!s)
- {
+ if(!s) {
s = (LPTSTR)(LPCTSTR)str;
s += str.GetLength() - 1;
}
s++;
CString effect = str.Left(s - str);
- if(!effect.CompareNoCase(_T("Banner;")))
- {
+ if(!effect.CompareNoCase(_T("Banner;"))) {
int delay, lefttoright = 0, fadeawaywidth = 0;
- if(_stscanf(s, _T("%d;%d;%d"), &delay, &lefttoright, &fadeawaywidth) < 1) return;
+ if(_stscanf(s, _T("%d;%d;%d"), &delay, &lefttoright, &fadeawaywidth) < 1) {
+ return;
+ }
Effect* e = DNew Effect;
- if(!e) return;
+ if(!e) {
+ return;
+ }
sub->m_effects[e->type = EF_BANNER] = e;
e->param[0] = (int)(max(1.0*delay/sub->m_scalex, 1));
@@ -1804,21 +1826,22 @@ void CRenderedTextSubtitle::ParseEffect(CSubtitle* sub, CString str)
e->param[2] = (int)(sub->m_scalex*fadeawaywidth);
sub->m_wrapStyle = 2;
- }
- else if(!effect.CompareNoCase(_T("Scroll up;")) || !effect.CompareNoCase(_T("Scroll down;")))
- {
+ } else if(!effect.CompareNoCase(_T("Scroll up;")) || !effect.CompareNoCase(_T("Scroll down;"))) {
int top, bottom, delay, fadeawayheight = 0;
- if(_stscanf(s, _T("%d;%d;%d;%d"), &top, &bottom, &delay, &fadeawayheight) < 3) return;
+ if(_stscanf(s, _T("%d;%d;%d;%d"), &top, &bottom, &delay, &fadeawayheight) < 3) {
+ return;
+ }
- if(top > bottom)
- {
+ if(top > bottom) {
int tmp = top;
top = bottom;
bottom = tmp;
}
Effect* e = DNew Effect;
- if(!e) return;
+ if(!e) {
+ return;
+ }
sub->m_effects[e->type = EF_SCROLL] = e;
e->param[0] = (int)(sub->m_scaley*top*8);
@@ -1831,40 +1854,35 @@ void CRenderedTextSubtitle::ParseEffect(CSubtitle* sub, CString str)
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");
- for(size_t i = 0, j = 0, len = str.GetLength(); j <= len; j++)
- {
+ for(size_t i = 0, j = 0, len = str.GetLength(); j <= len; j++) {
WCHAR c = str[j];
- if(c != '\n' && c != ' ' && c != '\x00A0' && c != 0)
+ if(c != '\n' && c != ' ' && c != '\x00A0' && c != 0) {
continue;
+ }
- if(i < j)
- {
- if(CWord* w = DNew CText(style, str.Mid(i, j-i), m_ktype, 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 == '\n')
- {
- if(CWord* w = DNew CText(style, CStringW(), m_ktype, m_kstart, m_kend))
- {
+ if(c == '\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 == ' ' || c == '\x00A0')
- {
- if(CWord* w = DNew CText(style, CStringW(c), m_ktype, m_kstart, m_kend))
- {
+ } else if(c == ' ' || c == '\x00A0') {
+ if(CWord* w = DNew CText(style, CStringW(c), m_ktype, m_kstart, m_kend)) {
sub->m_words.AddTail(w);
m_kstart = m_kend;
}
@@ -1878,10 +1896,11 @@ void CRenderedTextSubtitle::ParseString(CSubtitle* sub, CStringW str, STSStyle&
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))
- {
+ 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;
}
@@ -1889,181 +1908,209 @@ void CRenderedTextSubtitle::ParsePolygon(CSubtitle* sub, CStringW str, STSStyle&
bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle& style, STSStyle& org, bool fAnimate)
{
- if(!sub) return(false);
+ if(!sub) {
+ return(false);
+ }
int nTags = 0, nUnrecognizedTags = 0;
- for(int i = 0, j; (j = str.Find('\\', i)) >= 0; i = j)
- {
+ 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]);
+ for(WCHAR c = str[++j]; c && c != '(' && c != '\\'; cmd += c, c = str[++j]) {
+ ;
+ }
cmd.Trim();
- if(cmd.IsEmpty()) continue;
+ if(cmd.IsEmpty()) {
+ continue;
+ }
CAtlArray<CStringW> params;
- if(str[j] == '(')
- {
+ 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;
+ 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())
- {
+ while(!param.IsEmpty()) {
int i = param.Find(','), j = param.Find('\\');
- if(i >= 0 && (j < 0 || i < j))
- {
+ if(i >= 0 && (j < 0 || i < j)) {
CStringW s = param.Left(i).Trim();
- if(!s.IsEmpty()) params.Add(s);
+ if(!s.IsEmpty()) {
+ params.Add(s);
+ }
param = i+1 < param.GetLength() ? param.Mid(i+1) : L"";
- }
- else
- {
+ } else {
param.Trim();
- if(!param.IsEmpty()) params.Add(param);
+ 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"))
+ 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"))
+ } 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);
+ }
#ifdef _VSMOD // patch m010. png background
- else if(!cmd.Find(L"1img") || !cmd.Find(L"2img") || !cmd.Find(L"3img") || !cmd.Find(L"4img"))
- ;//params.Add(cmd.Mid(4)), cmd = cmd.Left(4);
+ else if(!cmd.Find(L"1img") || !cmd.Find(L"2img") || !cmd.Find(L"3img") || !cmd.Find(L"4img")) {
+ ; //params.Add(cmd.Mid(4)), cmd = cmd.Left(4);
+ }
#endif
#ifdef _VSMOD // patch m004. gradient colors
- else if(!cmd.Find(L"1vc") || !cmd.Find(L"2vc") || !cmd.Find(L"3vc") || !cmd.Find(L"4vc"))
- ;//params.Add(cmd.Mid(3)), cmd = cmd.Left(3);
- else if(!cmd.Find(L"1va") || !cmd.Find(L"2va") || !cmd.Find(L"3va") || !cmd.Find(L"4va"))
- ;//params.Add(cmd.Mid(3)), cmd = cmd.Left(3);
+ else if(!cmd.Find(L"1vc") || !cmd.Find(L"2vc") || !cmd.Find(L"3vc") || !cmd.Find(L"4vc")) {
+ ; //params.Add(cmd.Mid(3)), cmd = cmd.Left(3);
+ } else if(!cmd.Find(L"1va") || !cmd.Find(L"2va") || !cmd.Find(L"3va") || !cmd.Find(L"4va")) {
+ ; //params.Add(cmd.Mid(3)), cmd = cmd.Left(3);
+ }
#endif
- else if(!cmd.Find(L"alpha"))
+ else if(!cmd.Find(L"alpha")) {
params.Add(cmd.Mid(5).Trim(L"&H")), cmd = cmd.Left(5);
- else if(!cmd.Find(L"an"))
+ } else if(!cmd.Find(L"an")) {
params.Add(cmd.Mid(2)), cmd = cmd.Left(2);
- else if(!cmd.Find(L"a"))
+ } else if(!cmd.Find(L"a")) {
params.Add(cmd.Mid(1)), cmd = cmd.Left(1);
- else if(!cmd.Find(L"blur"))
+ } else if(!cmd.Find(L"blur")) {
params.Add(cmd.Mid(4)), cmd = cmd.Left(4);
- else if(!cmd.Find(L"bord"))
+ } else if(!cmd.Find(L"bord")) {
params.Add(cmd.Mid(4)), cmd = cmd.Left(4);
- else if(!cmd.Find(L"be"))
+ } else if(!cmd.Find(L"be")) {
params.Add(cmd.Mid(2)), cmd = cmd.Left(2);
- else if(!cmd.Find(L"b"))
+ } 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"clip")) {
;
- else if(!cmd.Find(L"c"))
+ } else if(!cmd.Find(L"c")) {
params.Add(cmd.Mid(1).Trim(L"&H")), cmd = cmd.Left(1);
+ }
#ifdef _VSMOD // patch m008. distort
- else if(!cmd.Find(L"distort"))
+ else if(!cmd.Find(L"distort")) {
;
+ }
#endif
- else if(!cmd.Find(L"fade"))
+ else if(!cmd.Find(L"fade")) {
;
- else if(!cmd.Find(L"fe"))
+ } else if(!cmd.Find(L"fe")) {
params.Add(cmd.Mid(2)), cmd = cmd.Left(2);
- else if(!cmd.Find(L"fn"))
+ } 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"))
+ } else if(!cmd.Find(L"frx") || !cmd.Find(L"fry") || !cmd.Find(L"frz")) {
params.Add(cmd.Mid(3)), cmd = cmd.Left(3);
+ }
#ifdef _VSMOD // patch m007. symbol rotating
- else if(!cmd.Find(L"frs"))
+ else if(!cmd.Find(L"frs")) {
params.Add(cmd.Mid(3)), cmd = cmd.Left(3);
+ }
#endif
- else if(!cmd.Find(L"fax") || !cmd.Find(L"fay"))
+ 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"))
+ } 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"))
+ } 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"))
+ } else if(!cmd.Find(L"fsc")) {
params.Add(cmd.Mid(3)), cmd = cmd.Left(3);
- else if(!cmd.Find(L"fsp"))
+ } else if(!cmd.Find(L"fsp")) {
params.Add(cmd.Mid(3)), cmd = cmd.Left(3);
+ }
#ifdef _VSMOD// patch m001. Vertical fontspacing
- else if(!cmd.Find(L"fsvp"))
+ else if(!cmd.Find(L"fsvp")) {
params.Add(cmd.Mid(4)), cmd = cmd.Left(4);
+ }
#endif
- else if(!cmd.Find(L"fs"))
+ 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"iclip")) {
;
- else if(!cmd.Find(L"i"))
+ } else if(!cmd.Find(L"i")) {
params.Add(cmd.Mid(1)), cmd = cmd.Left(1);
+ }
#ifdef _VSMOD // patch m011. jitter
- else if(!cmd.Find(L"jitter"))
+ else if(!cmd.Find(L"jitter")) {
;
+ }
#endif
- else if(!cmd.Find(L"kt") || !cmd.Find(L"kf") || !cmd.Find(L"ko"))
+ 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"))
+ } else if(!cmd.Find(L"k") || !cmd.Find(L"K")) {
params.Add(cmd.Mid(1)), cmd = cmd.Left(1);
+ }
#ifdef _VSMOD // patch m005. add some move types
- else if(!cmd.Find(L"mover")) // radial move
+ else if(!cmd.Find(L"mover")) { // radial move
;
- else if(!cmd.Find(L"moves3")) // square spline
+ } else if(!cmd.Find(L"moves3")) { // square spline
;
- else if(!cmd.Find(L"moves4")) // cubic spline
+ } else if(!cmd.Find(L"moves4")) { // cubic spline
;
+ }
#endif
#ifdef _VSMOD // patch m006. moveable vector clip
- else if(!cmd.Find(L"movevc"))
+ else if(!cmd.Find(L"movevc")) {
;
+ }
#endif
- else if(!cmd.Find(L"move"))
+ else if(!cmd.Find(L"move")) {
;
- else if(!cmd.Find(L"org"))
+ } else if(!cmd.Find(L"org")) {
;
- else if(!cmd.Find(L"pbo"))
+ } 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"pos")) {
;
- else if(!cmd.Find(L"p"))
+ } else if(!cmd.Find(L"p")) {
params.Add(cmd.Mid(1)), cmd = cmd.Left(1);
- else if(!cmd.Find(L"q"))
+ } else if(!cmd.Find(L"q")) {
params.Add(cmd.Mid(1)), cmd = cmd.Left(1);
+ }
#ifdef _VSMOD // patch m003. random text points
- else if(!cmd.Find(L"rndx") || !cmd.Find(L"rndy") || !cmd.Find(L"rndz") || !cmd.Find(L"rnds"))
+ else if(!cmd.Find(L"rndx") || !cmd.Find(L"rndy") || !cmd.Find(L"rndz") || !cmd.Find(L"rnds")) {
params.Add(cmd.Mid(4)), cmd = cmd.Left(4);
- else if(!cmd.Find(L"rnd"))
+ } else if(!cmd.Find(L"rnd")) {
params.Add(cmd.Mid(3)), cmd = cmd.Left(3);
+ }
#endif
- else if(!cmd.Find(L"r"))
+ else if(!cmd.Find(L"r")) {
params.Add(cmd.Mid(1)), cmd = cmd.Left(1);
- else if(!cmd.Find(L"shad"))
+ } else if(!cmd.Find(L"shad")) {
params.Add(cmd.Mid(4)), cmd = cmd.Left(4);
- else if(!cmd.Find(L"s"))
+ } 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"t")) {
;
- else if(!cmd.Find(L"u"))
+ } else if(!cmd.Find(L"u")) {
params.Add(cmd.Mid(1)), cmd = cmd.Left(1);
- else if(!cmd.Find(L"xbord"))
+ } else if(!cmd.Find(L"xbord")) {
params.Add(cmd.Mid(5)), cmd = cmd.Left(5);
- else if(!cmd.Find(L"xshad"))
+ } else if(!cmd.Find(L"xshad")) {
params.Add(cmd.Mid(5)), cmd = cmd.Left(5);
- else if(!cmd.Find(L"ybord"))
+ } else if(!cmd.Find(L"ybord")) {
params.Add(cmd.Mid(5)), cmd = cmd.Left(5);
- else if(!cmd.Find(L"yshad"))
+ } else if(!cmd.Find(L"yshad")) {
params.Add(cmd.Mid(5)), cmd = cmd.Left(5);
+ }
#ifdef _VSMOD // patch m002. Z-coord
- else if(!cmd.Find(L"z"))
+ else if(!cmd.Find(L"z")) {
params.Add(cmd.Mid(1)), cmd = cmd.Left(1);
+ }
#endif
- else
+ else {
nUnrecognizedTags++;
+ }
nTags++;
@@ -2071,8 +2118,7 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle&
CStringW p = params.GetCount() > 0 ? params[0] : L"";
- if(cmd == "1c" || cmd == L"2c" || cmd == L"3c" || cmd == L"4c")
- {
+ if(cmd == "1c" || cmd == L"2c" || cmd == L"3c" || cmd == L"4c") {
int i = cmd[0] - '1';
DWORD c = wcstol(p, NULL, 16);
@@ -2083,22 +2129,17 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle&
: org.colors[i];
#ifdef _VSMOD // patch m004. gradient colors
style.mod_grad.colors[i] = style.colors[i];
- if (!fAnimate)
- {
+ if (!fAnimate) {
style.mod_grad.mode[i] = 0;
- for (int j=0; j<4; j++)
- {
+ for (int j=0; j<4; j++) {
style.mod_grad.color[i][j] = !p.IsEmpty()
? ((int)c&0xff
|(int)c&0xff00
|(int)c&0xff0000)
: org.mod_grad.color[i][j];
}
- }
- else if(style.mod_grad.mode[i] != 0)
- {
- for (int j=0; j<4; j++)
- {
+ } else if(style.mod_grad.mode[i] != 0) {
+ for (int j=0; j<4; j++) {
style.mod_grad.color[i][j] = !p.IsEmpty()
? (((int)CalcAnimation(c&0xff, style.mod_grad.color[i][j]&0xff, fAnimate))&0xff
|((int)CalcAnimation(c&0xff00, style.mod_grad.color[i][j]&0xff00, fAnimate))&0xff00
@@ -2107,9 +2148,7 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle&
}
}
#endif
- }
- else if(cmd == L"1a" || cmd == L"2a" || cmd == L"3a" || cmd == L"4a")
- {
+ } 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';
@@ -2119,20 +2158,15 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle&
#ifdef _VSMOD // patch m004. gradient colors
style.mod_grad.alphas[i] = style.alpha[i];
style.mod_grad.b_images[i].alpha = 255-style.alpha[i];
- if (!fAnimate)
- {
+ if (!fAnimate) {
//style.mod_grad.mode[i] = 0;
- for (int j=0; j<4; j++)
- {
+ for (int j=0; j<4; j++) {
style.mod_grad.alpha[i][j] = !p.IsEmpty()
? al
: org.mod_grad.alpha[i][j];
}
- }
- else if (style.mod_grad.mode[i] != 0)
- {
- for (int j=0; j<4; j++)
- {
+ } else if (style.mod_grad.mode[i] != 0) {
+ for (int j=0; j<4; j++) {
style.mod_grad.alpha[i][j] = !p.IsEmpty()
? (((int)CalcAnimation(al, style.mod_grad.alpha[i][j], fAnimate)))
: org.alpha[i];
@@ -2141,58 +2175,45 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle&
#endif
}
#ifdef _VSMOD // patch m010. png background
- else if(cmd == L"1img" || cmd == L"2img" || cmd == L"3img" || cmd == L"4img")
- {
+ else if(cmd == L"1img" || cmd == L"2img" || cmd == L"3img" || cmd == L"4img") {
int i = cmd[0] - '1';
- if(params.GetCount() >= 1)// file[,xoffset,yoffset[,angle]]
- {
- if (!fAnimate)
- {
+ if(params.GetCount() >= 1) { // file[,xoffset,yoffset[,angle]]
+ if (!fAnimate) {
CString fpath = m_path.Left(m_path.ReverseFind('\\')+1);
bool t_init = false;
// buffer
- for(ptrdiff_t k = 0, j = mod_images.GetCount(); k < j; k++)
- {
+ for(ptrdiff_t k = 0, j = mod_images.GetCount(); k < j; k++) {
MOD_PNGIMAGE t_temp = mod_images[k];
- if(t_temp.filename==params[0]) // found buffered image
- {
+ if(t_temp.filename==params[0]) { // found buffered image
style.mod_grad.b_images[i] = t_temp;
t_init = true;
break;
}
- if(t_temp.filename==fpath+params[0]) // found buffered image
- {
+ if(t_temp.filename==fpath+params[0]) { // found buffered image
style.mod_grad.b_images[i] = t_temp;
t_init = true;
break;
}
}
- if(t_init)
- {
+ if(t_init) {
style.mod_grad.mode[i] = 2;
- }
- else
- {
+ } else {
// not found
MOD_PNGIMAGE t_temp;
- if(t_temp.initImage(params[0])) // absolute path or default directory
- {
+ if(t_temp.initImage(params[0])) { // absolute path or default directory
style.mod_grad.mode[i] = 2;
style.mod_grad.b_images[i] = t_temp;
mod_images.Add(t_temp);
- }
- else if(t_temp.initImage(fpath+params[0])) // path + relative path
- {
+ } else if(t_temp.initImage(fpath+params[0])) { // path + relative path
style.mod_grad.mode[i] = 2;
style.mod_grad.b_images[i] = t_temp;
mod_images.Add(t_temp);
}
}
}
- if(params.GetCount() >= 3)
- {
+ if(params.GetCount() >= 3) {
style.mod_grad.b_images[i].xoffset = !p.IsEmpty()
? CalcAnimation(wcstol(params[1], NULL, 10), style.mod_grad.b_images[i].xoffset, fAnimate)
: org.mod_grad.b_images[i].xoffset;
@@ -2204,15 +2225,12 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle&
}
#endif
#ifdef _VSMOD // patch m004. gradient colors
- else if(cmd == L"1vc" || cmd == L"2vc" || cmd == L"3vc" || cmd == L"4vc")
- {
+ else if(cmd == L"1vc" || cmd == L"2vc" || cmd == L"3vc" || cmd == L"4vc") {
int i = cmd[0] - '1';
- if(params.GetCount() >= 4)
- {
+ if(params.GetCount() >= 4) {
DWORD c;
- for (int j=0; j<4; j++)
- {
+ for (int j=0; j<4; j++) {
c = wcstol(params[j].Trim(L"&H"), NULL, 16);
style.mod_grad.color[i][j] = !p.IsEmpty()
? (((int)CalcAnimation((c&0xff0000)>>16, style.mod_grad.color[i][j]&0xff, fAnimate))&0xff
@@ -2220,34 +2238,26 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle&
|((int)CalcAnimation((c&0xff)<<16, style.mod_grad.color[i][j]&0xff0000, fAnimate))&0xff0000)
: org.mod_grad.color[i][j];
}
- if (style.mod_grad.mode[i]==0)
- {
- for (int j=0; j<4; j++)
- {
+ if (style.mod_grad.mode[i]==0) {
+ for (int j=0; j<4; j++) {
style.mod_grad.alpha[i][j] = style.alpha[i];
}
}
//if (!fAnimate)
style.mod_grad.mode[i] = 1;
}
- }
- else if(cmd == L"1va" || cmd == L"2va" || cmd == L"3va" || cmd == L"4va")
- {
+ } else if(cmd == L"1va" || cmd == L"2va" || cmd == L"3va" || cmd == L"4va") {
int i = cmd[0] - '1';
- if(params.GetCount() >= 4)
- {
+ if(params.GetCount() >= 4) {
int a;
- for (int j=0; j<4; j++)
- {
+ for (int j=0; j<4; j++) {
a = wcstol(params[j].Trim(L"&H"), NULL, 16);
style.mod_grad.alpha[i][j] = !p.IsEmpty()
? (int)CalcAnimation(a, style.mod_grad.alpha[i][j], fAnimate) : org.mod_grad.alpha[i][j];
}
- if (style.mod_grad.mode[i]==0)
- {
- for (int j=0; j<4; j++)
- {
+ if (style.mod_grad.mode[i]==0) {
+ for (int j=0; j<4; j++) {
style.mod_grad.color[i][j] = style.colors[i];
}
}
@@ -2256,31 +2266,24 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle&
}
}
#endif
- else if(cmd == L"alpha")
- {
- for(ptrdiff_t i = 0; i < 4; 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];
#ifdef _VSMOD // patch m004. gradient colors
style.mod_grad.alphas[i] = style.alpha[i];
- if (!fAnimate)
- {
+ if (!fAnimate) {
//style.mod_grad.mode[i] = 0;
- for (int j=0; j<4; j++)
- {
+ for (int j=0; j<4; j++) {
style.mod_grad.alpha[i][j] = !p.IsEmpty()
? al
: org.mod_grad.alpha[i][j];
style.mod_grad.b_images[i].alpha = 255-al;
}
- }
- else if(style.mod_grad.mode[i] != 0)
- {
- for (int j=0; j<4; j++)
- {
+ } else if(style.mod_grad.mode[i] != 0) {
+ for (int j=0; j<4; j++) {
style.mod_grad.alpha[i][j] = !p.IsEmpty()
? (((int)CalcAnimation(al, style.mod_grad.alpha[i][j], fAnimate)))
: org.alpha[i];
@@ -2289,28 +2292,22 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle&
}
#endif
}
- }
- else if(cmd == L"an")
- {
+ } else if(cmd == L"an") {
int n = wcstol(p, NULL, 10);
- if(sub->m_scrAlignment < 0)
+ if(sub->m_scrAlignment < 0) {
sub->m_scrAlignment = (n > 0 && n < 10) ? n : org.scrAlignment;
- }
- else if(cmd == L"a")
- {
+ }
+ } else if(cmd == L"a") {
int n = wcstol(p, NULL, 10);
- if(sub->m_scrAlignment < 0)
+ 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")
- {
+ }
+ } 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")
- {
+ } else if(cmd == L"bord") {
double dst = wcstod(p, NULL);
double nx = CalcAnimation(dst, style.outlineWidthX, fAnimate);
style.outlineWidthX = !p.IsEmpty()
@@ -2320,36 +2317,25 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle&
style.outlineWidthY = !p.IsEmpty()
? (ny < 0 ? 0 : ny)
: org.outlineWidthY;
- }
- else if(cmd == L"be")
- {
+ } 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")
- {
+ } 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")
- {
+ } else if(cmd == L"clip" || cmd == L"iclip") {
bool invert = (cmd == L"iclip");
- if(params.GetCount() == 1 && !sub->m_pClipper)
- {
+ 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);
- }
- else if(params.GetCount() == 2 && !sub->m_pClipper)
- {
+ } else if(params.GetCount() == 2 && !sub->m_pClipper) {
int scale = max(wcstol(p, NULL, 10), 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);
- }
- else if(params.GetCount() == 4)
- {
+ } else if(params.GetCount() == 4) {
CRect r;
sub->m_clipInverse = invert;
@@ -2362,8 +2348,7 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle&
CPoint o(0, 0);
- if(sub->m_relativeTo == 1) // TODO: this should also apply to the other two clippings above
- {
+ if(sub->m_relativeTo == 1) { // TODO: this should also apply to the other two clippings above
o.x = m_vidrect.left>>3;
o.y = m_vidrect.top>>3;
}
@@ -2374,9 +2359,7 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle&
(int)CalcAnimation(sub->m_scalex*r.right + o.x, sub->m_clip.right, fAnimate),
(int)CalcAnimation(sub->m_scaley*r.bottom + o.y, sub->m_clip.bottom, fAnimate));
}
- }
- else if(cmd == L"c")
- {
+ } 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
@@ -2385,22 +2368,17 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle&
: org.colors[0];
#ifdef _VSMOD // patch m004. gradient colors
style.mod_grad.colors[0] = style.colors[0];
- if (!fAnimate)
- {
+ if (!fAnimate) {
style.mod_grad.mode[0] = 0;
- for (int j=0; j<4; j++)
- {
+ for (int j=0; j<4; j++) {
style.mod_grad.color[0][j] = !p.IsEmpty()
? ((int)c&0xff
|(int)c&0xff00
|(int)c&0xff0000)
: org.mod_grad.color[0][j];
}
- }
- else if (style.mod_grad.mode[0] != 0)
- {
- for (int j=0; j<4; j++)
- {
+ } else if (style.mod_grad.mode[0] != 0) {
+ for (int j=0; j<4; j++) {
style.mod_grad.color[0][j] = !p.IsEmpty()
? (((int)CalcAnimation(c&0xff, style.mod_grad.color[0][j]&0xff, fAnimate))&0xff
|((int)CalcAnimation(c&0xff00, style.mod_grad.color[0][j]&0xff00, fAnimate))&0xff00
@@ -2411,13 +2389,10 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle&
#endif
}
#ifdef _VSMOD // patch m008. distort
- else if(cmd == L"distort")
- {
- if(params.GetCount() >= 6)
- {
+ else if(cmd == L"distort") {
+ if(params.GetCount() >= 6) {
DWORD c;
- for (int j=0; j<3; j++)
- {
+ for (int j=0; j<3; j++) {
style.mod_distort.pointsx[j] = !p.IsEmpty()
? (CalcAnimation(wcstod(params[j*2], NULL), style.mod_distort.pointsx[j], fAnimate))
: org.mod_distort.pointsx[j];
@@ -2429,31 +2404,28 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle&
}
}
#endif
- 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++)
+ 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++)
+ }
+ for(ptrdiff_t i = 0; i < 4; i++) {
e->t[i] = wcstol(params[3+i], NULL, 10);
+ }
sub->m_effects[EF_FADE] = e;
}
#ifdef _VSMOD // patch f005. don't cache animated
sub->m_fAnimated = true;
#endif
- }
- else if(params.GetCount() == 2 && !sub->m_effects[EF_FADE]) // {\fad(t1=t[1], t2=t[2])
- {
- if(Effect* e = DNew Effect)
- {
+ } 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++)
+ 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;
@@ -2462,35 +2434,26 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle&
sub->m_fAnimated = true;
#endif
}
- }
- else if(cmd == L"fax")
- {
+ } else if(cmd == L"fax") {
style.fontShiftX = !p.IsEmpty()
? CalcAnimation(wcstod(p, NULL), style.fontShiftX, fAnimate)
: org.fontShiftX;
- }
- else if(cmd == L"fay")
- {
+ } else if(cmd == L"fay") {
style.fontShiftY = !p.IsEmpty()
? CalcAnimation(wcstod(p, NULL), style.fontShiftY, fAnimate)
: org.fontShiftY;
- }
- else if(cmd == L"fe")
- {
+ } else if(cmd == L"fe") {
int n = wcstol(p, NULL, 10);
style.charSet = !p.IsEmpty()
? n
: org.charSet;
- }
- else if(cmd == L"fn")
- {
+ } else if(cmd == L"fn") {
style.fontName = (!p.IsEmpty() && p != '0')
? CString(p).Trim()
: org.fontName;
}
#ifdef _VSMOD // patch m007. symbol rotating
- else if(cmd == L"frs")
- {
+ else if(cmd == L"frs") {
double dst = wcstod(p, NULL)*10;
style.mod_fontOrient = !p.IsEmpty()
@@ -2498,40 +2461,29 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle&
: org.mod_fontOrient;
}
#endif
- else if(cmd == L"frx")
- {
+ else if(cmd == L"frx") {
style.fontAngleX = !p.IsEmpty()
? CalcAnimation(wcstod(p, NULL), style.fontAngleX, fAnimate)
: org.fontAngleX;
- }
- else if(cmd == L"fry")
- {
+ } 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")
- {
+ } 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")
- {
+ } 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")
- {
+ } 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")
- {
+ } else if(cmd == L"fsc") {
#ifdef _VSMOD // patch f004. \fsc(%f) is working
double dst = wcstod(p, NULL);
double nx = CalcAnimation(dst, style.fontScaleX, fAnimate);
@@ -2546,53 +2498,39 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle&
style.fontScaleX = org.fontScaleX;
style.fontScaleY = org.fontScaleY;
#endif
- }
- else if(cmd == L"fsp")
- {
+ } else if(cmd == L"fsp") {
style.fontSpacing = !p.IsEmpty()
? CalcAnimation(wcstod(p, NULL), style.fontSpacing, fAnimate)
: org.fontSpacing;
}
#ifdef _VSMOD // patch m001. Vertical fontspacing
- else if(cmd == L"fsvp")
- {
+ else if(cmd == L"fsvp") {
double dst = wcstod(p, NULL)*8;
double nx = CalcAnimation(dst, style.mod_verticalSpace, fAnimate);
style.mod_verticalSpace = !p.IsEmpty() ? nx : org.mod_verticalSpace;
}
#endif
- else if(cmd == L"fs")
- {
- if(!p.IsEmpty())
- {
- if(p[0] == '-' || p[0] == '+')
- {
+ 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
- {
+ } else {
double n = CalcAnimation(wcstol(p, NULL, 10), style.fontSize, fAnimate);
style.fontSize = (n > 0) ? n : org.fontSize;
}
- }
- else
- {
+ } else {
style.fontSize = org.fontSize;
}
- }
- else if(cmd == L"i")
- {
+ } 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;
}
#ifdef _VSMOD // patch m011. jitter
- else if(cmd == L"jitter") // {\jitter(left,right,up,down,period,[seed])}
- {
- if((params.GetCount() >= 4))
- {
+ else if(cmd == L"jitter") { // {\jitter(left,right,up,down,period,[seed])}
+ if((params.GetCount() >= 4)) {
int left = (int)abs(wcstol(params[0], NULL,10))*8;
int right = (int)abs(wcstol(params[1], NULL,10))*8;
int up = (int)abs(wcstol(params[2], NULL,10))*8;
@@ -2603,12 +2541,10 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle&
style.mod_jitter.offset.right = CalcAnimation(right, style.mod_jitter.offset.right, fAnimate);
style.mod_jitter.enabled = true;
- if(params.GetCount() >= 5)
- {
+ if(params.GetCount() >= 5) {
int period = wcstol(params[4], NULL, 10) * 10000;
style.mod_jitter.period = CalcAnimation(period, style.mod_jitter.period, fAnimate);
- if(params.GetCount() >= 6)
- {
+ if(params.GetCount() >= 6) {
style.mod_jitter.seed = wcstol(params[5], NULL, 10);
}
}
@@ -2617,15 +2553,12 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle&
}
}
#endif
- else if(cmd == L"kt")
- {
+ 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")
- {
+ } else if(cmd == L"kf" || cmd == L"K") {
m_ktype = 1;
m_kstart = m_kend;
m_kend += !p.IsEmpty()
@@ -2634,9 +2567,7 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle&
#ifdef _VSMOD // patch f005. don't cache animated
sub->m_fAnimated = true;
#endif
- }
- else if(cmd == L"ko")
- {
+ } else if(cmd == L"ko") {
m_ktype = 2;
m_kstart = m_kend;
m_kend += !p.IsEmpty()
@@ -2645,9 +2576,7 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle&
#ifdef _VSMOD // patch f005. don't cache animated
sub->m_fAnimated = true;
#endif
- }
- else if(cmd == L"k")
- {
+ } else if(cmd == L"k") {
m_ktype = 0;
m_kstart = m_kend;
m_kend += !p.IsEmpty()
@@ -2655,12 +2584,9 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle&
: 1000;
}
#ifdef _VSMOD // patch m005. add some move types
- else if(cmd == L"mover") // {\mover(x1,x2,x2,y2,alp1,alp2,r1,r2,t1,t2)}
- {
- if((params.GetCount() == 8 || params.GetCount() == 10) && !sub->m_effects[EF_MOVE])
- {
- if(Effect* e = new Effect)
- {
+ else if(cmd == L"mover") { // {\mover(x1,x2,x2,y2,alp1,alp2,r1,r2,t1,t2)}
+ if((params.GetCount() == 8 || params.GetCount() == 10) && !sub->m_effects[EF_MOVE]) {
+ if(Effect* e = new Effect) {
e->param[0] = 1;
e->param[1] = (int)(sub->m_scalex*wcstod(params[0], NULL)*8); // x1
e->param[2] = (int)(sub->m_scaley*wcstod(params[1], NULL)*8); // y1
@@ -2673,23 +2599,19 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle&
e->t[0] = e->t[1] = -1;
- if(params.GetCount() == 10)
- {
- for(int i = 0; i < 2; i++)
+ if(params.GetCount() == 10) {
+ for(int i = 0; i < 2; i++) {
e->t[i] = wcstol(params[8+i], NULL, 10);
+ }
}
sub->m_effects[EF_MOVE] = e;
}
// patch f005. don't cache animated
-// sub->m_fAnimated = true;
+ // sub->m_fAnimated = true;
}
- }
- else if(cmd == L"moves3") // {\moves3(x1,x2,x2,y2,x3,y3[,t1,t2])}
- {
- if((params.GetCount() == 6 || params.GetCount() == 8) && !sub->m_effects[EF_MOVE])
- {
- if(Effect* e = new Effect)
- {
+ } else if(cmd == L"moves3") { // {\moves3(x1,x2,x2,y2,x3,y3[,t1,t2])}
+ if((params.GetCount() == 6 || params.GetCount() == 8) && !sub->m_effects[EF_MOVE]) {
+ if(Effect* e = new Effect) {
e->param[0] = 2; // square spline
e->param[1] = (int)(sub->m_scalex*wcstod(params[0], NULL)*8); // x1
e->param[2] = (int)(sub->m_scaley*wcstod(params[1], NULL)*8); // y1
@@ -2699,23 +2621,19 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle&
e->param[6] = (int)(sub->m_scaley*wcstod(params[5], NULL)*8); // y3
e->t[0] = e->t[1] = -1;
- if(params.GetCount() == 8)
- {
- for(int i = 0; i < 2; i++)
+ if(params.GetCount() == 8) {
+ for(int i = 0; i < 2; i++) {
e->t[i] = wcstol(params[6+i], NULL, 10);
+ }
}
sub->m_effects[EF_MOVE] = e;
}
// patch f005. don't cache animated
-// sub->m_fAnimated = true;
+ // sub->m_fAnimated = true;
}
- }
- else if(cmd == L"moves4") // {\moves4(x1,x2,x2,y2,x3,y3,x4,y4[,t1,t2])}
- {
- if((params.GetCount() == 8 || params.GetCount() == 10) && !sub->m_effects[EF_MOVE])
- {
- if(Effect* e = new Effect)
- {
+ } else if(cmd == L"moves4") { // {\moves4(x1,x2,x2,y2,x3,y3,x4,y4[,t1,t2])}
+ if((params.GetCount() == 8 || params.GetCount() == 10) && !sub->m_effects[EF_MOVE]) {
+ if(Effect* e = new Effect) {
e->param[0] = 3; // cubic spline
e->param[1] = (int)(sub->m_scalex*wcstod(params[0], NULL)*8); // x1
e->param[2] = (int)(sub->m_scaley*wcstod(params[1], NULL)*8); // y1
@@ -2727,36 +2645,31 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle&
e->param[8] = (int)(sub->m_scaley*wcstod(params[7], NULL)*8); // y4
e->t[0] = e->t[1] = -1;
- if(params.GetCount() == 10)
- {
- for(int i = 0; i < 2; i++)
+ if(params.GetCount() == 10) {
+ for(int i = 0; i < 2; i++) {
e->t[i] = wcstol(params[8+i], NULL, 10);
+ }
}
sub->m_effects[EF_MOVE] = e;
}
// patch f005. don't cache animated
-// sub->m_fAnimated = true;
+ // sub->m_fAnimated = true;
}
}
#endif
#ifdef _VSMOD // patch m006. moveable vector clip
- else if(cmd == L"movevc")
- {
- if((params.GetCount() == 2 || params.GetCount() == 4 || params.GetCount() == 6) && !sub->m_effects[EF_VECTCLP])
- {
- if(Effect* e = new Effect)
- {
+ else if(cmd == L"movevc") {
+ if((params.GetCount() == 2 || params.GetCount() == 4 || params.GetCount() == 6) && !sub->m_effects[EF_VECTCLP]) {
+ if(Effect* e = new Effect) {
e->param[0] = e->param[2] = (int)(sub->m_scalex*wcstod(params[0], NULL));
e->param[1] = e->param[3] = (int)(sub->m_scaley*wcstod(params[1], NULL));
e->t[0] = e->t[1] = -1;
- if(params.GetCount() >= 4)
- {
+ if(params.GetCount() >= 4) {
e->param[2] = (int)(sub->m_scalex*wcstod(params[2], NULL));
e->param[3] = (int)(sub->m_scaley*wcstod(params[3], NULL));
}
- if(params.GetCount() == 6)
- {
+ if(params.GetCount() == 6) {
e->t[0] = (int)(sub->m_scalex*wcstod(params[4], NULL));
e->t[1] = (int)(sub->m_scaley*wcstod(params[5], NULL));
}
@@ -2767,12 +2680,9 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle&
}
}
#endif
- 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)
- {
+ 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) {
#ifdef _VSMOD // patch m005. add some move types
e->param[0] = 0;
e->param[1] = (int)(sub->m_scalex*wcstod(params[0], NULL)*8);
@@ -2787,37 +2697,31 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle&
#endif
e->t[0] = e->t[1] = -1;
- if(params.GetCount() == 6)
- {
- for(ptrdiff_t i = 0; i < 2; i++)
+ 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;
}
#ifdef _VSMOD // patch f005. don't cache animated
-// sub->m_fAnimated = true;
+ // sub->m_fAnimated = true;
#endif
}
- }
- else if(cmd == L"org") // {\org(x=param[0], y=param[1])}
- {
+ } else if(cmd == L"org") { // {\org(x=param[0], y=param[1])}
#ifdef _VSMOD // patch f003. moving \org for some karaoke effects. part 1
- if((params.GetCount() == 2 || params.GetCount() == 4 || params.GetCount() == 6) && !sub->m_effects[EF_ORG])
- {
- if(Effect* e = new Effect)
- {
+ if((params.GetCount() == 2 || params.GetCount() == 4 || params.GetCount() == 6) && !sub->m_effects[EF_ORG]) {
+ if(Effect* e = new 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] = -1;
- if(params.GetCount() >= 4)
- {
+ if(params.GetCount() >= 4) {
e->param[2] = (int)(sub->m_scalex*wcstod(params[2], NULL)*8);
e->param[3] = (int)(sub->m_scaley*wcstod(params[3], NULL)*8);
}
- if(params.GetCount() == 6)
- {
+ if(params.GetCount() == 6) {
e->t[0] = (int)(sub->m_scalex*wcstod(params[4], NULL)*8);
e->t[1] = (int)(sub->m_scaley*wcstod(params[5], NULL)*8);
}
@@ -2825,10 +2729,8 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle&
}
}
#else
- if(params.GetCount() == 2 && !sub->m_effects[EF_ORG])
- {
- if(Effect* e = DNew Effect)
- {
+ if(params.GetCount() == 2 && !sub->m_effects[EF_ORG]) {
+ 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);
@@ -2836,17 +2738,11 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle&
}
}
#endif
- }
- else if(cmd == L"pbo")
- {
+ } 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)
- {
+ } else if(cmd == L"pos") {
+ if(params.GetCount() == 2 && !sub->m_effects[EF_MOVE]) {
+ if(Effect* e = DNew Effect) {
#ifdef _VSMOD // patch m005. add some move types
e->param[0] = 0; // usual move
e->param[1] = e->param[3] = (int)(sub->m_scalex*wcstod(params[0], NULL)*8);
@@ -2861,10 +2757,8 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle&
}
}
#ifdef _VSMOD // patch m002. Z-coord
- else if(params.GetCount() == 3 && !sub->m_effects[EF_MOVE])
- {
- if(Effect* e = DNew Effect)
- {
+ else if(params.GetCount() == 3 && !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;
@@ -2874,59 +2768,43 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle&
}
}
#endif
- }
- else if(cmd == L"p")
- {
+ } else if(cmd == L"p") {
int n = wcstol(p, NULL, 10);
m_nPolygon = (n <= 0 ? 0 : n);
- }
- else if(cmd == L"q")
- {
+ } else if(cmd == L"q") {
int n = wcstol(p, NULL, 10);
sub->m_wrapStyle = !p.IsEmpty() && (0 <= n && n <= 3)
? n
: m_defaultWrapStyle;
}
#ifdef _VSMOD // patch m003. random text points
- else if(cmd == L"rnds")
- {
+ else if(cmd == L"rnds") {
double dst = wcstol(p, NULL, 16);
double nx = CalcAnimation(dst, style.mod_rand.Seed, fAnimate);
style.mod_rand.Seed = !p.IsEmpty() ? nx : org.mod_rand.Seed;
- }
- else if(cmd == L"rndx")
- {
+ } else if(cmd == L"rndx") {
double dst = wcstod(p, NULL)*8;
double nx = CalcAnimation(dst, style.mod_rand.X, fAnimate);
style.mod_rand.X = !p.IsEmpty() ? nx : org.mod_rand.X;
- }
- else if(cmd == L"rndy")
- {
+ } else if(cmd == L"rndy") {
double dst = wcstod(p, NULL)*8;
double nx = CalcAnimation(dst, style.mod_rand.Y, fAnimate);
style.mod_rand.Y = !p.IsEmpty() ? nx : org.mod_rand.Y;
- }
- else if(cmd == L"rndz")
- {
+ } else if(cmd == L"rndz") {
double dst = wcstod(p, NULL)*8;
double nx = CalcAnimation(dst, style.mod_rand.Z, fAnimate);
style.mod_rand.Z = !p.IsEmpty() ? nx : org.mod_rand.Z;
- }
- else if(cmd == L"rnd")
- {
+ } else if(cmd == L"rnd") {
double dst = wcstod(p, NULL)*8;
style.mod_rand.X = !p.IsEmpty() ? CalcAnimation(dst, style.mod_rand.X, fAnimate) : org.mod_rand.X;
style.mod_rand.Y = !p.IsEmpty() ? CalcAnimation(dst, style.mod_rand.Y, fAnimate) : org.mod_rand.Y;
style.mod_rand.Z = !p.IsEmpty() ? CalcAnimation(dst, style.mod_rand.Z, fAnimate) : org.mod_rand.Z;
}
#endif
- else if(cmd == L"r")
- {
+ else if(cmd == L"r") {
STSStyle* val;
style = (!p.IsEmpty() && m_styles.Lookup(CString(p), val) && val) ? *val : org;
- }
- else if(cmd == L"shad")
- {
+ } else if(cmd == L"shad") {
double dst = wcstod(p, NULL);
double nx = CalcAnimation(dst, style.shadowDepthX, fAnimate);
style.shadowDepthX = !p.IsEmpty()
@@ -2936,38 +2814,27 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle&
style.shadowDepthY = !p.IsEmpty()
? (ny < 0 ? 0 : ny)
: org.shadowDepthY;
- }
- else if(cmd == L"s")
- {
+ } 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>)
- {
+ } 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)
- {
+ if(params.GetCount() == 1) {
p = params[0];
- }
- else if(params.GetCount() == 2)
- {
+ } else if(params.GetCount() == 2) {
m_animAccel = wcstod(params[0], NULL);
p = params[1];
- }
- else if(params.GetCount() == 3)
- {
+ } 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)
- {
+ } 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);
@@ -2977,40 +2844,30 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle&
ParseSSATag(sub, p, style, org, true);
sub->m_fAnimated = true;
- }
- else if(cmd == L"u")
- {
+ } 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")
- {
+ } 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")
- {
+ } 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")
- {
+ } 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")
- {
+ } else if(cmd == L"yshad") {
double dst = wcstod(p, NULL);
double ny = CalcAnimation(dst, style.shadowDepthY, fAnimate);
style.shadowDepthY = !p.IsEmpty()
@@ -3018,8 +2875,7 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle&
: org.shadowDepthY;
}
#ifdef _VSMOD // patch m002. Z-coord
- else if(cmd == L"z")
- {
+ else if(cmd == L"z") {
double dst = wcstod(p, NULL)*80;
double nx = CalcAnimation(dst, style.mod_z, fAnimate);
style.mod_z = !p.IsEmpty() ? nx : org.mod_z;
@@ -3027,123 +2883,112 @@ bool CRenderedTextSubtitle::ParseSSATag(CSubtitle* sub, CStringW str, STSStyle&
#endif
}
-// return(nUnrecognizedTags < nTags);
+ // return(nUnrecognizedTags < nTags);
return(true); // there are ppl keeping coments inside {}, lets make them happy now
}
bool CRenderedTextSubtitle::ParseHtmlTag(CSubtitle* sub, CStringW str, STSStyle& style, STSStyle& org)
{
- if(str.Find(L"!--") == 0)
+ if(str.Find(L"!--") == 0) {
return(true);
+ }
bool fClosing = str[0] == '/';
str.Trim(L" /");
int i = str.Find(' ');
- if(i < 0) i = str.GetLength();
+ 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)
- {
+ while((i = str.Find('=')) > 0) {
attribs.Add(str.Left(i).Trim().MakeLower());
str = str.Mid(i+1);
- for(i = 0; _istspace(str[i]); i++);
+ for(i = 0; _istspace(str[i]); i++) {
+ ;
+ }
str = str.Mid(i);
- if(str[0] == '\"')
- {
+ if(str[0] == '\"') {
str = str.Mid(1);
i = str.Find('\"');
+ } else {
+ i = str.Find(' ');
+ }
+ if(i < 0) {
+ i = str.GetLength();
}
- 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")
+ if(tag == L"text") {
;
- else if(tag == L"b" || tag == L"strong")
+ } else if(tag == L"b" || tag == L"strong") {
style.fontWeight = !fClosing ? FW_BOLD : org.fontWeight;
- else if(tag == L"i" || tag == L"em")
+ } else if(tag == L"i" || tag == L"em") {
style.fItalic = !fClosing ? true : org.fItalic;
- else if(tag == L"u")
+ } else if(tag == L"u") {
style.fUnderline = !fClosing ? true : org.fUnderline;
- else if(tag == L"s" || tag == L"strike" || tag == L"del")
+ } 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(i = 0; i < attribs.GetCount(); i++)
- {
- if(params[i].IsEmpty()) continue;
+ } else if(tag == L"font") {
+ if(!fClosing) {
+ for(i = 0; i < attribs.GetCount(); i++) {
+ if(params[i].IsEmpty()) {
+ continue;
+ }
int nColor = -1;
- if(attribs[i] == L"face")
- {
+ if(attribs[i] == L"face") {
style.fontName = params[i];
- }
- else if(attribs[i] == L"size")
- {
- if(params[i][0] == '+')
+ } else if(attribs[i] == L"size") {
+ if(params[i][0] == '+') {
style.fontSize += wcstol(params[i], NULL, 10);
- else if(params[i][0] == '-')
+ } else if(params[i][0] == '-') {
style.fontSize -= wcstol(params[i], NULL, 10);
- else
+ } else {
style.fontSize = wcstol(params[i], NULL, 10);
- }
- else if(attribs[i] == L"color")
- {
+ }
+ } else if(attribs[i] == L"color") {
nColor = 0;
- }
- else if(attribs[i] == L"outline-color")
- {
+ } else if(attribs[i] == L"outline-color") {
nColor = 2;
- }
- else if(attribs[i] == L"outline-level")
- {
+ } else if(attribs[i] == L"outline-level") {
style.outlineWidthX = style.outlineWidthY = wcstol(params[i], NULL, 10);
- }
- else if(attribs[i] == L"shadow-color")
- {
+ } else if(attribs[i] == L"shadow-color") {
nColor = 3;
- }
- else if(attribs[i] == L"shadow-level")
- {
+ } else if(attribs[i] == L"shadow-level") {
style.shadowDepthX = style.shadowDepthY = wcstol(params[i], NULL, 10);
}
- if(nColor >= 0 && nColor < 4)
- {
+ if(nColor >= 0 && nColor < 4) {
CString key = WToT(params[i]).TrimLeft('#');
DWORD val;
- if(g_colors.Lookup(key, 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
+ } 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
- {
+ } 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")
- {
+ } 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
+ } else {
return(false);
+ }
return(true);
}
@@ -3153,15 +2998,14 @@ double CRenderedTextSubtitle::CalcAnimation(double dst, double src, bool fAnimat
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)
- {
+ 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;
+ // else dst = dst;
}
return(dst);
@@ -3170,56 +3014,48 @@ double CRenderedTextSubtitle::CalcAnimation(double dst, double src, bool fAnimat
CSubtitle* CRenderedTextSubtitle::GetSubtitle(int entry)
{
CSubtitle* sub;
- if(m_subtitleCache.Lookup(entry, sub))
- {
- if(sub->m_fAnimated)
- {
+ if(m_subtitleCache.Lookup(entry, sub)) {
+ if(sub->m_fAnimated) {
delete sub;
sub = NULL;
+ } else {
+ return(sub);
}
- else return(sub);
}
sub = DNew CSubtitle();
- if(!sub) return(NULL);
+ if(!sub) {
+ return(NULL);
+ }
CStringW str = GetStrW(entry, true);
STSStyle stss, orgstss;
- if(m_doOverrideStyle && m_pStyleOverride != NULL)
- {
+ if(m_doOverrideStyle && m_pStyleOverride != NULL) {
// this RTS has been signaled to ignore embedded styles, use the built-in one
stss = *m_pStyleOverride;
- }
- else
- {
+ } 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)
+ 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
+ } 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)
+ } 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
+ } else {
stss.fontScaleY /= m_dPARCompensation;
+ }
}
- }
- else if (m_ePARCompensationType == EPCTAccurateSize)
- {
- if (stss.fontScaleX / stss.fontScaleY == 1.0 && m_dPARCompensation != 1.0)
- {
+ } else if (m_ePARCompensationType == EPCTAccurateSize) {
+ if (stss.fontScaleX / stss.fontScaleY == 1.0 && m_dPARCompensation != 1.0) {
stss.fontScaleX *= m_dPARCompensation;
}
}
@@ -3235,14 +3071,11 @@ CSubtitle* CRenderedTextSubtitle::GetSubtitle(int entry)
// 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 != NULL)
- {
+ if(m_doOverrideStyle && m_pStyleOverride != NULL) {
// so mind the default values, stated here to increase comprehension
sub->m_scalex = (stss.relativeTo == 1 ? m_vidrect.Width() : m_size.cx) / (384 * 8);
sub->m_scaley = (stss.relativeTo == 1 ? m_vidrect.Height() : m_size.cy) / (288 * 8);
- }
- else
- {
+ } 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;
}
@@ -3255,43 +3088,43 @@ CSubtitle* CRenderedTextSubtitle::GetSubtitle(int entry)
#ifdef _VSMOD // patch m004. gradient colors
// allow init gradient without \$vc \$va
for (int i=0; i<4; i++)
- for (int j=0; j<4; j++)
- {
+ for (int j=0; j<4; j++) {
stss.mod_grad.alpha[i][j] = stss.alpha[i];
stss.mod_grad.color[i][j] = stss.colors[i];
}
#endif
ParseEffect(sub, GetAt(entry).effect);
- while(!str.IsEmpty())
- {
+ while(!str.IsEmpty()) {
bool fParsed = false;
int i;
- if(str[0] == '{' && (i = str.Find(L'}')) > 0)
- {
+ if(str[0] == '{' && (i = str.Find(L'}')) > 0) {
fParsed = ParseSSATag(sub, str.Mid(1, i-1), stss, orgstss);
- if(fParsed)
+ if(fParsed) {
str = str.Mid(i+1);
- }
- else if(str[0] == '<' && (i = str.Find(L'>')) > 0)
- {
+ }
+ } else if(str[0] == '<' && (i = str.Find(L'>')) > 0) {
fParsed = ParseHtmlTag(sub, str.Mid(1, i-1), stss, orgstss);
- if(fParsed)
+ if(fParsed) {
str = str.Mid(i+1);
+ }
}
- if(fParsed)
- {
+ if(fParsed) {
i = str.FindOneOf(L"{<");
- if(i < 0) i = str.GetLength();
- if(i == 0) continue;
- }
- else
- {
+ if(i < 0) {
+ i = str.GetLength();
+ }
+ if(i == 0) {
+ continue;
+ }
+ } else {
i = str.Mid(1).FindOneOf(L"{<");
- if(i < 0) i = str.GetLength()-1;
+ if(i < 0) {
+ i = str.GetLength()-1;
+ }
i++;
}
@@ -3306,12 +3139,9 @@ CSubtitle* CRenderedTextSubtitle::GetSubtitle(int entry)
tmp.shadowDepthX *= (m_fScaledBAS ? sub->m_scalex : 1) * 8;
tmp.shadowDepthY *= (m_fScaledBAS ? sub->m_scaley : 1) * 8;
- if(m_nPolygon)
- {
+ if(m_nPolygon) {
ParsePolygon(sub, str.Left(i), tmp);
- }
- else
- {
+ } else {
ParseString(sub, str.Left(i), tmp);
}
@@ -3319,24 +3149,32 @@ CSubtitle* CRenderedTextSubtitle::GetSubtitle(int entry)
}
// 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]))
+ 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;
+ 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)
- {
+ if(stss.relativeTo == 1) {
marginRect.left += m_vidrect.left;
marginRect.top += m_vidrect.top;
marginRect.right += m_size.cx - m_vidrect.right;
@@ -3373,7 +3211,9 @@ STDMETHODIMP_(POSITION) CRenderedTextSubtitle::GetStartPosition(REFERENCE_TIME r
int iSegment = -1;
SearchSubs((int)(rt/10000), fps, &iSegment, NULL);
- if(iSegment < 0) iSegment = 0;
+ if(iSegment < 0) {
+ iSegment = 0;
+ }
return(GetNext((POSITION)iSegment));
}
@@ -3383,8 +3223,7 @@ STDMETHODIMP_(POSITION) CRenderedTextSubtitle::GetNext(POSITION pos)
int iSegment = (int)pos;
const STSSegment* stss = GetSegment(iSegment);
- while(stss && stss->subs.GetCount() == 0)
- {
+ while(stss && stss->subs.GetCount() == 0) {
iSegment++;
stss = GetSegment(iSegment);
}
@@ -3407,15 +3246,16 @@ STDMETHODIMP_(bool) CRenderedTextSubtitle::IsAnimated(POSITION pos)
return(true);
}
-struct LSub
-{
+struct LSub {
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;
+ if(!ret) {
+ ret = ((LSub*)ls1)->readorder - ((LSub*)ls2)->readorder;
+ }
return(ret);
}
@@ -3423,27 +3263,28 @@ STDMETHODIMP CRenderedTextSubtitle::Render(SubPicDesc& spd, REFERENCE_TIME rt, d
{
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))
+ 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;
+ 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)
- {
+ 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))
- {
+ if(stse.end <= (t-30000) || stse.start > (t+30000)) {
delete value;
m_subtitleCache.RemoveKey(key);
pos = m_subtitleCache.GetStartPosition();
@@ -3455,8 +3296,7 @@ STDMETHODIMP CRenderedTextSubtitle::Render(SubPicDesc& spd, REFERENCE_TIME rt, d
CAtlArray<LSub> subs;
- for(ptrdiff_t i = 0, j = stss->subs.GetCount(); i < j; i++)
- {
+ 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;
@@ -3466,8 +3306,7 @@ STDMETHODIMP CRenderedTextSubtitle::Render(SubPicDesc& spd, REFERENCE_TIME rt, d
qsort(subs.GetData(), subs.GetCount(), sizeof(LSub), lscomp);
- for(ptrdiff_t i = 0, j = subs.GetCount(); i < j; i++)
- {
+ for(ptrdiff_t i = 0, j = subs.GetCount(); i < j; i++) {
int entry = subs[i].idx;
STSEntry stse = GetAt(entry);
@@ -3479,7 +3318,9 @@ STDMETHODIMP CRenderedTextSubtitle::Render(SubPicDesc& spd, REFERENCE_TIME rt, d
}
CSubtitle* s = GetSubtitle(entry);
- if(!s) continue;
+ if(!s) {
+ continue;
+ }
CRect clipRect = s->m_clip;
CRect r = s->m_rect;
@@ -3502,316 +3343,306 @@ STDMETHODIMP CRenderedTextSubtitle::Render(SubPicDesc& spd, REFERENCE_TIME rt, d
mod_vc.size = s->m_pClipper?s->m_pClipper->m_size : CSize(0,0);
#endif
- for(int k = 0; k < EF_NUMBEROFEFFECTS; k++)
- {
- if(!s->m_effects[k]) continue;
+ 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;
+ 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;
#ifdef _VSMOD // patch m005. add some move types
- if (s->m_effects[k]->param[0]==0)
- {
- CPoint p1(s->m_effects[k]->param[1], s->m_effects[k]->param[2]);
- CPoint p2(s->m_effects[k]->param[3], s->m_effects[k]->param[4]);
+ if (s->m_effects[k]->param[0]==0) {
+ CPoint p1(s->m_effects[k]->param[1], s->m_effects[k]->param[2]);
+ CPoint p2(s->m_effects[k]->param[3], s->m_effects[k]->param[4]);
#else
- 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]);
+ 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]);
#endif
- int t1 = s->m_effects[k]->t[0];
- int t2 = s->m_effects[k]->t[1];
+ 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(t2 < t1) {
+ int t = t1;
+ t1 = t2;
+ t2 = t;
+ }
- if(t1 <= 0 && t2 <= 0)
- {
- t1 = 0;
- t2 = m_delay;
- }
+ 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;
+ 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;
+ }
#ifdef _VSMOD // patch m005. add some move types
- }
- else if (s->m_effects[k]->param[0]==1) // radial move
- {
- CPoint p1(s->m_effects[k]->param[1], s->m_effects[k]->param[2]); // p0
- CPoint p2(s->m_effects[k]->param[3], s->m_effects[k]->param[4]); // p1
- CPoint r0(s->m_effects[k]->param[7], s->m_effects[k]->param[8]);
- double alp1 = s->m_effects[k]->param[5]*PI/1800000; // alp1
- double alp2 = s->m_effects[k]->param[6]*PI/1800000; // alp2
- int t1 = s->m_effects[k]->t[0];
- int t2 = s->m_effects[k]->t[1];
+ } else if (s->m_effects[k]->param[0]==1) { // radial move
+ CPoint p1(s->m_effects[k]->param[1], s->m_effects[k]->param[2]); // p0
+ CPoint p2(s->m_effects[k]->param[3], s->m_effects[k]->param[4]); // p1
+ CPoint r0(s->m_effects[k]->param[7], s->m_effects[k]->param[8]);
+ double alp1 = s->m_effects[k]->param[5]*PI/1800000; // alp1
+ double alp2 = s->m_effects[k]->param[6]*PI/1800000; // alp2
+ int t1 = s->m_effects[k]->t[0];
+ int t2 = s->m_effects[k]->t[1];
+
+ CPoint pr1 = (p1.x + cos(alp1)*r0.x, p1.y + sin(alp1)*r0.x);
+ CPoint pr2 = (p2.x + cos(alp2)*r0.y, p2.y + sin(alp2)*r0.y);
+
+ if(t2 < t1) {
+ int t = t1;
+ t1 = t2;
+ t2 = t;
+ }
- CPoint pr1 = (p1.x + cos(alp1)*r0.x, p1.y + sin(alp1)*r0.x);
- CPoint pr2 = (p2.x + cos(alp2)*r0.y, p2.y + sin(alp2)*r0.y);
+ if(t1 <= 0 && t2 <= 0) {
+ t1 = 0;
+ t2 = m_delay;
+ }
- if(t2 < t1)
- {
- int t = t1;
- t1 = t2;
- t2 = t;
- }
+ if(m_time <= t1) {
+ p = pr1;
+ }
+ //else if (p1 == p2) p = pr1; // jfs: avoid rounding error problems sometimes causing subtitles with \pos to jump around a bit
+ else if((t1 < m_time) && (m_time < t2)) {
+ double t = (double)(m_time-t1)/(t2-t1);
+ double alp = ((1-t)*alp1 + t*alp2);
+ double rt = ((1-t)*r0.x + t*r0.y);
+
+ p.x = (int)((1-t)*p1.x + t*p2.x); // origin point
+ p.y = (int)((1-t)*p1.y + t*p2.y);
+ p.x += (int)(cos(alp)*rt);
+ p.y -= (int)(sin(alp)*rt);
+ } else {
+ p = pr2;
+ }
+ } else if (s->m_effects[k]->param[0]==2) { // square spline
+ CPoint p1(s->m_effects[k]->param[1], s->m_effects[k]->param[2]);
+ CPoint p2(s->m_effects[k]->param[3], s->m_effects[k]->param[4]);
+ CPoint p3(s->m_effects[k]->param[5], s->m_effects[k]->param[6]);
+
+ 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(t1 <= 0 && t2 <= 0) {
+ t1 = 0;
+ t2 = m_delay;
+ }
+
+ if(m_time <= t1) {
+ p = p1;
+ } else if (p1 == p2) {
+ p = p1; // jfs: avoid rounding error problems sometimes causing subtitles with \pos to jump around a bit
+ } else if(t1 < m_time && m_time < t2) {
+ double t = (double)(m_time-t1)/(t2-t1);
+ p.x = (int)((1-t)*(1-t)*p1.x + 2*t*(1-t)*p2.x + t*t*p3.x);
+ p.y = (int)((1-t)*(1-t)*p1.y + 2*t*(1-t)*p2.y + t*t*p3.y);
+ } else {
+ p = p3;
+ }
+ } else if (s->m_effects[k]->param[0]==3) { // cubic spline
+ CPoint p1(s->m_effects[k]->param[1], s->m_effects[k]->param[2]);
+ CPoint p2(s->m_effects[k]->param[3], s->m_effects[k]->param[4]);
+ CPoint p3(s->m_effects[k]->param[5], s->m_effects[k]->param[6]);
+ CPoint p4(s->m_effects[k]->param[7], s->m_effects[k]->param[8]);
+
+ 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; // jfs: avoid rounding error problems sometimes causing subtitles with \pos to jump around a bit
+ } else if(t1 < m_time && m_time < t2) {
+ double t = (double)(m_time-t1)/(t2-t1);
+ p.x = (int)((1-t)*(1-t)*(1-t)*p1.x + 3*t*(1-t)*(1-t)*p2.x + 3*t*t*(1-t)*p3.x + t*t*t*p4.x);
+ p.y = (int)((1-t)*(1-t)*(1-t)*p1.y + 3*t*(1-t)*(1-t)*p2.y + 3*t*t*(1-t)*p3.y + t*t*t*p4.y);
+ } else {
+ p = p4;
+ }
}
+#endif
+ 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(m_time <= t1) p = pr1;
- //else if (p1 == p2) p = pr1; // jfs: avoid rounding error problems sometimes causing subtitles with \pos to jump around a bit
- else if((t1 < m_time) && (m_time < t2))
- {
- double t = (double)(m_time-t1)/(t2-t1);
- double alp = ((1-t)*alp1 + t*alp2);
- double rt = ((1-t)*r0.x + t*r0.y);
-
- p.x = (int)((1-t)*p1.x + t*p2.x); // origin point
- p.y = (int)((1-t)*p1.y + t*p2.y);
- p.x += (int)(cos(alp)*rt);
- p.y -= (int)(sin(alp)*rt);
+ if(s->m_relativeTo == 1) {
+ r.OffsetRect(m_vidrect.TopLeft());
}
- else p = pr2;
+ fPosOverride = true;
}
- else if (s->m_effects[k]->param[0]==2) // square spline
- {
- CPoint p1(s->m_effects[k]->param[1], s->m_effects[k]->param[2]);
- CPoint p2(s->m_effects[k]->param[3], s->m_effects[k]->param[4]);
- CPoint p3(s->m_effects[k]->param[5], s->m_effects[k]->param[6]);
-
- 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;
+ break;
+ case EF_ORG: { // {\org(x=param[0], y=param[1])}
+#ifdef _VSMOD // patch f003. moving \org for some karaoke effects
+ CPoint orgA(s->m_effects[k]->param[0], s->m_effects[k]->param[1]);
+ CPoint orgB(s->m_effects[k]->param[2], s->m_effects[k]->param[3]);
+ int to1 = s->m_effects[k]->t[0];
+ int to2 = s->m_effects[k]->t[1];
+
+ if(to2 < to1) {
+ int to = to1;
+ to1 = to2;
+ to2 = to;
}
- if(t1 <= 0 && t2 <= 0)
- {
- t1 = 0;
- t2 = m_delay;
+ if(to1 <= 0 && to2 <= 0) {
+ to1 = 0;
+ to2 = m_delay;
}
- if(m_time <= t1) p = p1;
- else if (p1 == p2) p = p1; // jfs: avoid rounding error problems sometimes causing subtitles with \pos to jump around a bit
- else if(t1 < m_time && m_time < t2)
- {
- double t = (double)(m_time-t1)/(t2-t1);
- p.x = (int)((1-t)*(1-t)*p1.x + 2*t*(1-t)*p2.x + t*t*p3.x);
- p.y = (int)((1-t)*(1-t)*p1.y + 2*t*(1-t)*p2.y + t*t*p3.y);
+ if(m_time <= to1) {
+ org2 = orgA;
+ } else if (to1 == to2) {
+ org2 = orgA; // jfs: avoid rounding error problems sometimes causing subtitles with \pos to jump around a bit
+ } else if(to1 < m_time && m_time < to2) {
+ double t = 1.0*(m_time-to1)/(to2-to1);
+ org2.x = (int)((1-t)*orgA.x + t*orgB.x);
+ org2.y = (int)((1-t)*orgA.y + t*orgB.y);
+ } else {
+ org2 = orgB;
}
- else p = p3;
+#else
+ org2 = CPoint(s->m_effects[k]->param[0], s->m_effects[k]->param[1]);
+#endif
+ fOrgOverride = true;
}
- else if (s->m_effects[k]->param[0]==3) // cubic spline
- {
- CPoint p1(s->m_effects[k]->param[1], s->m_effects[k]->param[2]);
- CPoint p2(s->m_effects[k]->param[3], s->m_effects[k]->param[4]);
- CPoint p3(s->m_effects[k]->param[5], s->m_effects[k]->param[6]);
- CPoint p4(s->m_effects[k]->param[7], s->m_effects[k]->param[8]);
-
+ 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(t2 < t1)
- {
- int t = t1;
- t1 = t2;
- t2 = t;
- }
-
- if(t1 <= 0 && t2 <= 0)
- {
+ if(t1 == -1 && t4 == -1) {
t1 = 0;
- t2 = m_delay;
+ t3 = m_delay - t3;
+ t4 = m_delay;
}
- if(m_time <= t1) p = p1;
- else if (p1 == p2) p = p1; // jfs: avoid rounding error problems sometimes causing subtitles with \pos to jump around a bit
- else if(t1 < m_time && m_time < t2)
- {
- double t = (double)(m_time-t1)/(t2-t1);
- p.x = (int)((1-t)*(1-t)*(1-t)*p1.x + 3*t*(1-t)*(1-t)*p2.x + 3*t*t*(1-t)*p3.x + t*t*t*p4.x);
- p.y = (int)((1-t)*(1-t)*(1-t)*p1.y + 3*t*(1-t)*(1-t)*p2.y + 3*t*t*(1-t)*p3.y + t*t*t*p4.y);
+ 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];
}
- else p = p4;
}
-#endif
- 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);
+ 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;
- if(s->m_relativeTo == 1)
- r.OffsetRect(m_vidrect.TopLeft());
- fPosOverride = true;
- }
- break;
- case EF_ORG: // {\org(x=param[0], y=param[1])}
- {
-#ifdef _VSMOD // patch f003. moving \org for some karaoke effects
- CPoint orgA(s->m_effects[k]->param[0], s->m_effects[k]->param[1]);
- CPoint orgB(s->m_effects[k]->param[2], s->m_effects[k]->param[3]);
- int to1 = s->m_effects[k]->t[0];
- int to2 = s->m_effects[k]->t[1];
-
- if(to2 < to1)
- {
- int to = to1;
- to1 = to2;
- to2 = to;
- }
+ 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]);
- if(to1 <= 0 && to2 <= 0)
- {
- to1 = 0;
- to2 = m_delay;
- }
+ r.right = r.left + spaceNeeded.cx;
- if(m_time <= to1) org2 = orgA;
- else if (to1 == to2) org2 = orgA; // jfs: avoid rounding error problems sometimes causing subtitles with \pos to jump around a bit
- else if(to1 < m_time && m_time < to2)
- {
- double t = 1.0*(m_time-to1)/(to2-to1);
- org2.x = (int)((1-t)*orgA.x + t*orgB.x);
- org2.y = (int)((1-t)*orgA.y + t*orgB.y);
- }
- else org2 = orgB;
-#else
- org2 = CPoint(s->m_effects[k]->param[0], s->m_effects[k]->param[1]);
-#endif
- 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;
- }
+ clipRect &= CRect(left>>3, clipRect.top, right>>3, clipRect.bottom);
- 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);
+ fPosOverride = true;
}
- 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]);
+ 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;
+ 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);
+ 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;
+ 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;
+ clipRect &= cr;
- fPosOverride = true;
- }
-#ifdef _VSMOD // patch m006. moveable vector clip
- case EF_VECTCLP:
- {
- CPoint vcpos1(s->m_effects[k]->param[0], s->m_effects[k]->param[1]);
- CPoint vcpos2(s->m_effects[k]->param[2], s->m_effects[k]->param[3]);
- int to1 = s->m_effects[k]->t[0];
- int to2 = s->m_effects[k]->t[1];
-
- if(to2 < to1)
- {
- int to = to1;
- to1 = to2;
- to2 = to;
+ fPosOverride = true;
}
+#ifdef _VSMOD // patch m006. moveable vector clip
+ case EF_VECTCLP: {
+ CPoint vcpos1(s->m_effects[k]->param[0], s->m_effects[k]->param[1]);
+ CPoint vcpos2(s->m_effects[k]->param[2], s->m_effects[k]->param[3]);
+ int to1 = s->m_effects[k]->t[0];
+ int to2 = s->m_effects[k]->t[1];
+
+ if(to2 < to1) {
+ int to = to1;
+ to1 = to2;
+ to2 = to;
+ }
- if(to1 <= 0 && to2 <= 0)
- {
- to1 = 0;
- to2 = m_delay;
- }
+ if(to1 <= 0 && to2 <= 0) {
+ to1 = 0;
+ to2 = m_delay;
+ }
- if(m_time <= to1) mod_vc.pos = vcpos1;
- else if (to1 == to2) mod_vc.pos = vcpos1; // jfs: avoid rounding error problems sometimes causing subtitles with \pos to jump around a bit
- else if(to1 < m_time && m_time < to2)
- {
- double t = 1.0*(m_time-to1)/(to2-to1);
- mod_vc.pos.x = (int)((1-t)*vcpos1.x + t*vcpos2.x);
- mod_vc.pos.y = (int)((1-t)*vcpos1.y + t*vcpos2.y);
+ if(m_time <= to1) {
+ mod_vc.pos = vcpos1;
+ } else if (to1 == to2) {
+ mod_vc.pos = vcpos1; // jfs: avoid rounding error problems sometimes causing subtitles with \pos to jump around a bit
+ } else if(to1 < m_time && m_time < to2) {
+ double t = 1.0*(m_time-to1)/(to2-to1);
+ mod_vc.pos.x = (int)((1-t)*vcpos1.x + t*vcpos2.x);
+ mod_vc.pos.y = (int)((1-t)*vcpos1.y + t*vcpos2.y);
+ } else {
+ mod_vc.pos = vcpos2;
+ }
+ mod_vc.enable = true;
}
- else mod_vc.pos = vcpos2;
- mod_vc.enable = true;
- }
#endif
- break;
- default:
break;
+ default:
+ break;
}
}
- if(!fPosOverride && !fOrgOverride && !s->m_fAnimated)
+ 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;
+ if(!fOrgOverride) {
+ org2 = org;
+ }
CPoint p, p2(0, r.top);
@@ -3827,8 +3658,7 @@ STDMETHODIMP CRenderedTextSubtitle::Render(SubPicDesc& spd, REFERENCE_TIME rt, d
iclipRect[3] = CRect(0, clipRect.bottom, spd.w, spd.h);
pos = s->GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CLine* l = s->GetNext(pos);
p.x = (s->m_scrAlignment%3) == 1 ? org.x
@@ -3836,27 +3666,21 @@ STDMETHODIMP CRenderedTextSubtitle::Render(SubPicDesc& spd, REFERENCE_TIME rt, d
: org.x - (l->m_width/2);
#ifdef _VSMOD // patch m006. moveable vector clip
- if (s->m_clipInverse)
- {
+ if (s->m_clipInverse) {
bbox2 |= l->PaintShadow(spd, iclipRect[0], pAlphaMask, p, org2, m_time, alpha, mod_vc, rt);
bbox2 |= l->PaintShadow(spd, iclipRect[1], pAlphaMask, p, org2, m_time, alpha, mod_vc, rt);
bbox2 |= l->PaintShadow(spd, iclipRect[2], pAlphaMask, p, org2, m_time, alpha, mod_vc, rt);
bbox2 |= l->PaintShadow(spd, iclipRect[3], pAlphaMask, p, org2, m_time, alpha, mod_vc, rt);
- }
- else
- {
+ } else {
bbox2 |= l->PaintShadow(spd, clipRect, pAlphaMask, p, org2, m_time, alpha, mod_vc, rt);
}
#else
- if (s->m_clipInverse)
- {
+ 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
- {
+ } else {
bbox2 |= l->PaintShadow(spd, clipRect, pAlphaMask, p, org2, m_time, alpha);
}
#endif
@@ -3866,8 +3690,7 @@ STDMETHODIMP CRenderedTextSubtitle::Render(SubPicDesc& spd, REFERENCE_TIME rt, d
p = p2;
pos = s->GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CLine* l = s->GetNext(pos);
p.x = (s->m_scrAlignment%3) == 1 ? org.x
@@ -3875,27 +3698,21 @@ STDMETHODIMP CRenderedTextSubtitle::Render(SubPicDesc& spd, REFERENCE_TIME rt, d
: org.x - (l->m_width/2);
#ifdef _VSMOD // patch m006. movable vector clip
- if (s->m_clipInverse)
- {
+ if (s->m_clipInverse) {
bbox2 |= l->PaintOutline(spd, iclipRect[0], pAlphaMask, p, org2, m_time, alpha, mod_vc, rt);
bbox2 |= l->PaintOutline(spd, iclipRect[1], pAlphaMask, p, org2, m_time, alpha, mod_vc, rt);
bbox2 |= l->PaintOutline(spd, iclipRect[2], pAlphaMask, p, org2, m_time, alpha, mod_vc, rt);
bbox2 |= l->PaintOutline(spd, iclipRect[3], pAlphaMask, p, org2, m_time, alpha, mod_vc, rt);
- }
- else
- {
+ } else {
bbox2 |= l->PaintOutline(spd, clipRect, pAlphaMask, p, org2, m_time, alpha, mod_vc, rt);
}
#else
- if (s->m_clipInverse)
- {
+ 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
- {
+ } else {
bbox2 |= l->PaintOutline(spd, clipRect, pAlphaMask, p, org2, m_time, alpha);
}
#endif
@@ -3905,8 +3722,7 @@ STDMETHODIMP CRenderedTextSubtitle::Render(SubPicDesc& spd, REFERENCE_TIME rt, d
p = p2;
pos = s->GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CLine* l = s->GetNext(pos);
p.x = (s->m_scrAlignment%3) == 1 ? org.x
@@ -3914,27 +3730,21 @@ STDMETHODIMP CRenderedTextSubtitle::Render(SubPicDesc& spd, REFERENCE_TIME rt, d
: org.x - (l->m_width/2);
#ifdef _VSMOD // patch m006. moveable vector clip
- if (s->m_clipInverse)
- {
+ if (s->m_clipInverse) {
bbox2 |= l->PaintBody(spd, iclipRect[0], pAlphaMask, p, org2, m_time, alpha, mod_vc, rt);
bbox2 |= l->PaintBody(spd, iclipRect[1], pAlphaMask, p, org2, m_time, alpha, mod_vc, rt);
bbox2 |= l->PaintBody(spd, iclipRect[2], pAlphaMask, p, org2, m_time, alpha, mod_vc, rt);
bbox2 |= l->PaintBody(spd, iclipRect[3], pAlphaMask, p, org2, m_time, alpha, mod_vc, rt);
- }
- else
- {
+ } else {
bbox2 |= l->PaintBody(spd, clipRect, pAlphaMask, p, org2, m_time, alpha, mod_vc, rt);
}
#else
- if (s->m_clipInverse)
- {
+ 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
- {
+ } else {
bbox2 |= l->PaintBody(spd, clipRect, pAlphaMask, p, org2, m_time, alpha);
}
#endif
@@ -3964,21 +3774,23 @@ STDMETHODIMP_(int) CRenderedTextSubtitle::GetStreamCount()
STDMETHODIMP CRenderedTextSubtitle::GetStreamInfo(int iStream, WCHAR** ppName, LCID* pLCID)
{
USES_CONVERSION;
- if(iStream != 0) return E_INVALIDARG;
+ if(iStream != 0) {
+ return E_INVALIDARG;
+ }
- if(ppName)
- {
+ if(ppName) {
*ppName = (WCHAR*)CoTaskMemAlloc((m_name.GetLength()+1)*sizeof(WCHAR));
- if(!(*ppName))
+ if(!(*ppName)) {
return E_OUTOFMEMORY;
+ }
wcscpy(*ppName, CStringW(m_name));
- if(pLCID)
- {
+ if(pLCID) {
*pLCID = ISO6391ToLcid (W2A(*ppName));
- if (*pLCID == 0)
+ if (*pLCID == 0) {
*pLCID = ISO6392ToLcid (W2A(*ppName));
+ }
}
}
@@ -3998,6 +3810,8 @@ STDMETHODIMP CRenderedTextSubtitle::SetStream(int iStream)
STDMETHODIMP CRenderedTextSubtitle::Reload()
{
CFileStatus s;
- if(!CFile::GetStatus(m_path, s)) return E_FAIL;
+ if(!CFile::GetStatus(m_path, s)) {
+ return E_FAIL;
+ }
return !m_path.IsEmpty() && Open(m_path, DEFAULT_CHARSET) ? S_OK : E_FAIL;
} \ No newline at end of file
diff --git a/src/Subtitles/RTS.h b/src/Subtitles/RTS.h
index 880e8221b..b41d31b7f 100644
--- a/src/Subtitles/RTS.h
+++ b/src/Subtitles/RTS.h
@@ -143,8 +143,7 @@ public:
#endif
};
-enum eftype
-{
+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])
@@ -156,9 +155,9 @@ enum eftype
};
#ifdef _VSMOD // patch m006. moveable vector clip
- #define EF_NUMBEROFEFFECTS 6
+#define EF_NUMBEROFEFFECTS 6
#else
- #define EF_NUMBEROFEFFECTS 5
+#define EF_NUMBEROFEFFECTS 5
#endif
class Effect
@@ -206,8 +205,7 @@ public:
class CScreenLayoutAllocator
{
- typedef struct
- {
+ typedef struct {
CRect r;
int segment, entry, layer;
} SubRect;
@@ -215,7 +213,8 @@ class CScreenLayoutAllocator
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);
@@ -262,10 +261,11 @@ public:
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)
- {
+ void SetOverride(bool doOverride = true, STSStyle *styleOverride = NULL) {
m_doOverrideStyle = doOverride;
- if(styleOverride != NULL) m_pStyleOverride = styleOverride;
+ if(styleOverride != NULL) {
+ m_pStyleOverride = styleOverride;
+ }
}
public:
diff --git a/src/Subtitles/Rasterizer.cpp b/src/Subtitles/Rasterizer.cpp
index 2a37926d2..06cec1cc2 100644
--- a/src/Subtitles/Rasterizer.cpp
+++ b/src/Subtitles/Rasterizer.cpp
@@ -30,13 +30,13 @@
#include "SeparableFilter.h"
#ifndef _MAX /* avoid collision with common (nonconforming) macros */
- #define _MAX (max)
- #define _MIN (min)
- #define _IMPL_MAX max
- #define _IMPL_MIN min
+#define _MAX (max)
+#define _MIN (min)
+#define _IMPL_MAX max
+#define _IMPL_MIN min
#else
- #define _IMPL_MAX _MAX
- #define _IMPL_MIN _MIN
+#define _IMPL_MAX _MAX
+#define _IMPL_MIN _MIN
#endif
int Rasterizer::getOverlayWidth()
@@ -68,8 +68,9 @@ void Rasterizer::_TrashPath()
void Rasterizer::_TrashOverlay()
{
- if (mpOverlayBuffer)
+ if (mpOverlayBuffer) {
_aligned_free(mpOverlayBuffer);
+ }
mpOverlayBuffer = NULL;
}
@@ -97,8 +98,7 @@ void Rasterizer::_EvaluateBezier(int ptbase, bool fBSpline)
double cx3, cx2, cx1, cx0, cy3, cy2, cy1, cy0;
- if(fBSpline)
- {
+ if(fBSpline) {
// 1 [-1 +3 -3 +1]
// - * [+3 -6 +3 0]
// 6 [-3 0 +3 0]
@@ -115,9 +115,7 @@ void Rasterizer::_EvaluateBezier(int ptbase, bool fBSpline)
cy2 = _1div6*( 3*y0-6*y1+3*y2);
cy1 = _1div6*(-3*y0 +3*y2);
cy0 = _1div6*( y0+4*y1+1*y2);
- }
- else // bezier
- {
+ } else { // bezier
// [-1 +3 -3 +1]
// [+3 -6 +3 0]
// [-3 +3 0 0]
@@ -156,7 +154,9 @@ void Rasterizer::_EvaluateBezier(int ptbase, bool fBSpline)
double maxaccel = maxaccel1 > maxaccel2 ? maxaccel1 : maxaccel2;
double h = 1.0;
- if(maxaccel > 8.0) h = sqrt(8.0 / maxaccel);
+ if(maxaccel > 8.0) {
+ h = sqrt(8.0 / maxaccel);
+ }
if(!fFirstSet) {
firstp.x = (LONG)cx0;
@@ -165,8 +165,7 @@ void Rasterizer::_EvaluateBezier(int ptbase, bool fBSpline)
fFirstSet = true;
}
- for(double t = 0; t < 1.0; t += h)
- {
+ 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);
@@ -187,8 +186,7 @@ void Rasterizer::_EvaluateLine(int pt1idx, int pt2idx)
void Rasterizer::_EvaluateLine(int x0, int y0, int x1, int y1)
{
- if(lastp.x != x0 || lastp.y != y0)
- {
+ if(lastp.x != x0 || lastp.y != y0) {
_EvaluateLine(lastp.x, lastp.y, x0, y0);
}
@@ -200,8 +198,7 @@ void Rasterizer::_EvaluateLine(int x0, int y0, int x1, int y1)
lastp.x = x1;
lastp.y = y1;
- if(y1 > y0) // down
- {
+ if(y1 > y0) { // down
__int64 xacc = (__int64)x0 << 13;
// prestep y0 down
@@ -212,17 +209,16 @@ void Rasterizer::_EvaluateLine(int x0, int y0, int x1, int y1)
y1 = (y1 - 5) >> 3;
- if(iy <= y1)
- {
+ if(iy <= y1) {
__int64 invslope = (__int64(x1 - x0) << 16) / dy;
- while(mEdgeNext + y1 + 1 - iy > mEdgeHeapSize)
+ while(mEdgeNext + y1 + 1 - iy > mEdgeHeapSize) {
_ReallocEdgeBuffer(mEdgeHeapSize*2);
+ }
xacc += (invslope * (y - y0)) >> 3;
- while(iy <= y1)
- {
+ while(iy <= y1) {
int ix = (int)((xacc + 32768) >> 16);
mpEdgeBuffer[mEdgeNext].next = mpScanBuffer[iy];
@@ -234,9 +230,7 @@ void Rasterizer::_EvaluateLine(int x0, int y0, int x1, int y1)
xacc += invslope;
}
}
- }
- else if(y1 < y0) // up
- {
+ } else if(y1 < y0) { // up
__int64 xacc = (__int64)x1 << 13;
// prestep y1 down
@@ -247,17 +241,16 @@ void Rasterizer::_EvaluateLine(int x0, int y0, int x1, int y1)
y0 = (y0 - 5) >> 3;
- if(iy <= y0)
- {
+ if(iy <= y0) {
__int64 invslope = (__int64(x0 - x1) << 16) / dy;
- while(mEdgeNext + y0 + 1 - iy > mEdgeHeapSize)
+ while(mEdgeNext + y0 + 1 - iy > mEdgeHeapSize) {
_ReallocEdgeBuffer(mEdgeHeapSize*2);
+ }
xacc += (invslope * (y - y1)) >> 3;
- while(iy <= y0)
- {
+ while(iy <= y0) {
int ix = (int)((xacc + 32768) >> 16);
mpEdgeBuffer[mEdgeNext].next = mpScanBuffer[iy];
@@ -283,18 +276,19 @@ bool Rasterizer::EndPath(HDC hdc)
{
::CloseFigure(hdc);
- if(::EndPath(hdc))
- {
+ if(::EndPath(hdc)) {
mPathPoints = GetPath(hdc, NULL, NULL, 0);
- if(!mPathPoints)
+ if(!mPathPoints) {
return true;
+ }
mpPathTypes = (BYTE*)malloc(sizeof(BYTE) * mPathPoints);
mpPathPoints = (POINT*)malloc(sizeof(POINT) * mPathPoints);
- if(mPathPoints == (size_t)GetPath(hdc, mpPathPoints, mpPathTypes, mPathPoints))
+ if(mPathPoints == (size_t)GetPath(hdc, mpPathPoints, mpPathTypes, mPathPoints)) {
return true;
+ }
}
::AbortPath(hdc);
@@ -304,8 +298,9 @@ bool Rasterizer::EndPath(HDC hdc)
bool Rasterizer::PartialBeginPath(HDC hdc, bool bClearPath)
{
- if(bClearPath)
+ if(bClearPath) {
_TrashPath();
+ }
return !!::BeginPath(hdc);
}
@@ -314,33 +309,33 @@ bool Rasterizer::PartialEndPath(HDC hdc, long dx, long dy)
{
::CloseFigure(hdc);
- if(::EndPath(hdc))
- {
+ if(::EndPath(hdc)) {
int nPoints;
BYTE* pNewTypes;
POINT* pNewPoints;
nPoints = GetPath(hdc, NULL, NULL, 0);
- if(!nPoints)
+ if(!nPoints) {
return true;
+ }
pNewTypes = (BYTE*)realloc(mpPathTypes, (mPathPoints + nPoints) * sizeof(BYTE));
pNewPoints = (POINT*)realloc(mpPathPoints, (mPathPoints + nPoints) * sizeof(POINT));
- if(pNewTypes)
+ if(pNewTypes) {
mpPathTypes = pNewTypes;
+ }
- if(pNewPoints)
+ if(pNewPoints) {
mpPathPoints = pNewPoints;
+ }
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)
- {
+ 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];
@@ -351,9 +346,9 @@ bool Rasterizer::PartialEndPath(HDC hdc, long dx, long dy)
delete[] pTypes;
delete[] pPoints;
return true;
- }
- else
+ } else {
DebugBreak();
+ }
delete[] pTypes;
delete[] pPoints;
@@ -377,8 +372,7 @@ bool Rasterizer::ScanConvert()
// Determine bounding box
- if(!mPathPoints)
- {
+ if(!mPathPoints) {
mPathOffsetX = mPathOffsetY = 0;
mWidth = mHeight = 0;
return 0;
@@ -389,15 +383,22 @@ bool Rasterizer::ScanConvert()
ptrdiff_t maxx = INT_MIN;
ptrdiff_t maxy = INT_MIN;
- for(i=0; i<mPathPoints; ++i)
- {
+ for(i=0; i<mPathPoints; ++i) {
ptrdiff_t ix = mpPathPoints[i].x;
ptrdiff_t iy = mpPathPoints[i].y;
- if(ix < minx) minx = ix;
- if(ix > maxx) maxx = ix;
- if(iy < miny) miny = iy;
- if(iy > maxy) maxy = iy;
+ if(ix < minx) {
+ minx = ix;
+ }
+ if(ix > maxx) {
+ maxx = ix;
+ }
+ if(iy < miny) {
+ miny = iy;
+ }
+ if(iy > maxy) {
+ maxy = iy;
+ }
}
minx = (minx >> 3) & ~7;
@@ -405,14 +406,12 @@ bool Rasterizer::ScanConvert()
maxx = (maxx + 7) >> 3;
maxy = (maxy + 7) >> 3;
- for(i=0; i<mPathPoints; ++i)
- {
+ for(i=0; i<mPathPoints; ++i) {
mpPathPoints[i].x -= minx*8;
mpPathPoints[i].y -= miny*8;
}
- if(minx > maxx || miny > maxy)
- {
+ if(minx > maxx || miny > maxy) {
mWidth = mHeight = 0;
mPathOffsetX = mPathOffsetY = 0;
_TrashPath();
@@ -446,40 +445,48 @@ bool Rasterizer::ScanConvert()
firstp.x = firstp.y = 0;
lastp.x = lastp.y = 0;
- for(i=0; i<mPathPoints; ++i)
- {
+ 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)
+ 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.
@@ -497,14 +504,12 @@ bool Rasterizer::ScanConvert()
__int64 y = 0;
- for(y=0; y<mHeight; ++y)
- {
+ for(y=0; y<mHeight; ++y) {
int count = 0;
// Detangle scanline into edge heap.
- for(size_t ptr = (mpScanBuffer[y]&size_t(-1)); ptr; ptr = mpEdgeBuffer[ptr].next)
- {
+ for(size_t ptr = (mpScanBuffer[y]&size_t(-1)); ptr; ptr = mpEdgeBuffer[ptr].next) {
heap.push_back(mpEdgeBuffer[ptr].posandflag);
}
@@ -523,24 +528,25 @@ bool Rasterizer::ScanConvert()
size_t x1 = 0;
size_t x2;
- for(; itX1 != itX2; ++itX1)
- {
+ for(; itX1 != itX2; ++itX1) {
size_t x = *itX1;
- if(!count)
+ if(!count) {
x1 = (x>>1);
+ }
- if(x&1)
+ if(x&1) {
++count;
- else
+ } else {
--count;
+ }
- if(!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! :)
+ if(x2>x1) {
+ mOutline.push_back(std::pair<__int64,__int64>((y<<32)+x1+0x4000000040000000i64, (y<<32)+x2+0x4000000040000000i64)); // G: damn Avery, this is evil! :)
+ }
}
}
@@ -577,10 +583,8 @@ void Rasterizer::_OverlapRegion(tSpanBuffer& dst, tSpanBuffer& src, int dx, int
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)
- {
+ while(itA != itAE && itB != itBE) {
+ if((*itB).first + offset1 < (*itA).first) {
// B span is earlier. Use it.
unsigned __int64 x1 = (*itB).first + offset1;
@@ -590,39 +594,36 @@ void Rasterizer::_OverlapRegion(tSpanBuffer& dst, tSpanBuffer& src, int dx, int
// B spans don't overlap, so begin merge loop with A first.
- for(;;)
- {
+ 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)
+ if(itA == itAE || (*itA).first > x2) {
break;
+ }
do {
x2 = _MAX(x2, (*itA++).second);
- }
- while(itA != itAE && (*itA).first <= x2);
+ } 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(itB == itBE || (*itB).first + offset1 > x2)
+ if(itB == itBE || (*itB).first + offset1 > x2) {
break;
+ }
do {
x2 = _MAX(x2, (*itB++).second + offset2);
- }
- while(itB != itBE && (*itB).first + offset1 <= x2);
+ } while(itB != itBE && (*itB).first + offset1 <= x2);
}
// Flush span.
dst.push_back(tSpan(x1, x2));
- }
- else
- {
+ } else {
// A span is earlier. Use it.
unsigned __int64 x1 = (*itA).first;
@@ -632,31 +633,30 @@ void Rasterizer::_OverlapRegion(tSpanBuffer& dst, tSpanBuffer& src, int dx, int
// A spans don't overlap, so begin merge loop with B first.
- for(;;)
- {
+ 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)
+ if(itB == itBE || (*itB).first + offset1 > x2) {
break;
+ }
do {
x2 = _MAX(x2, (*itB++).second + offset2);
- }
- while(itB != itBE && (*itB).first + offset1 <= x2);
+ } 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(itA == itAE || (*itA).first > x2)
+ if(itA == itAE || (*itA).first > x2) {
break;
+ }
do {
x2 = _MAX(x2, (*itA++).second);
- }
- while(itA != itAE && (*itA).first <= x2);
+ } while(itA != itAE && (*itA).first <= x2);
}
// Flush span.
@@ -667,11 +667,11 @@ void Rasterizer::_OverlapRegion(tSpanBuffer& dst, tSpanBuffer& src, int dx, int
// Copy over leftover spans.
- while(itA != itAE)
+ while(itA != itAE) {
dst.push_back(*itA++);
+ }
- while(itB != itBE)
- {
+ while(itB != itBE) {
dst.push_back(tSpan((*itB).first + offset1, (*itB).second + offset2));
++itB;
}
@@ -679,24 +679,24 @@ void Rasterizer::_OverlapRegion(tSpanBuffer& dst, tSpanBuffer& src, int dx, int
bool Rasterizer::CreateWidenedRegion(int rx, int ry)
{
- if(rx < 0) rx = 0;
- if(ry < 0) ry = 0;
+ if(rx < 0) {
+ rx = 0;
+ }
+ if(ry < 0) {
+ ry = 0;
+ }
mWideBorder = max(rx,ry);
- if (ry > 0)
- {
+ if (ry > 0) {
// Do a half circle.
// _OverlapRegion mirrors this so both halves are done.
- for(ptrdiff_t y = -ry; y <= ry; ++y)
- {
+ for(ptrdiff_t 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)
- {
+ } 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);
@@ -715,8 +715,7 @@ bool Rasterizer::Rasterize(int xsub, int ysub, int fBlur, double fGaussianBlur)
{
_TrashOverlay();
- if(!mWidth || !mHeight)
- {
+ if(!mWidth || !mHeight) {
mOverlayWidth = mOverlayHeight = 0;
return true;
}
@@ -732,13 +731,14 @@ bool Rasterizer::Rasterize(int xsub, int ysub, int fBlur, double fGaussianBlur)
mWideBorder = (mWideBorder+7)&~7;
- if(!mWideOutline.empty() || fBlur || fGaussianBlur > 0)
- {
+ if(!mWideOutline.empty() || fBlur || fGaussianBlur > 0) {
int bluradjust = 0;
- if (fGaussianBlur > 0)
+ if (fGaussianBlur > 0) {
bluradjust += (int)(fGaussianBlur*3*8 + 0.5) | 1;
- if (fBlur)
+ }
+ 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;
@@ -764,13 +764,11 @@ bool Rasterizer::Rasterize(int xsub, int ysub, int fBlur, double fGaussianBlur)
tSpanBuffer* pOutline[2] = {&mOutline, &mWideOutline};
- for(ptrdiff_t i = countof(pOutline)-1; i >= 0; i--)
- {
+ 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)
- {
+ for(; it!=itEnd; ++it) {
unsigned __int64 f = (*it).first;
size_t y = (f >> 32) - 0x40000000 + ysub;
size_t x1 = (f & 0xffffffff) - 0x40000000 + xsub;
@@ -778,21 +776,18 @@ bool Rasterizer::Rasterize(int xsub, int ysub, int fBlur, double fGaussianBlur)
unsigned __int64 s = (*it).second;
size_t x2 = (s & 0xffffffff) - 0x40000000 + xsub;
- if(x2 > x1)
- {
+ if(x2 > x1) {
size_t first = x1>>3;
size_t last = (x2-1)>>3;
byte* dst = mpOverlayBuffer + 2*(mOverlayWidth*(y>>3) + first) + i;
- if(first == last)
+ if(first == last) {
*dst += x2-x1;
- else
- {
+ } else {
*dst += ((first+1)<<3) - x1;
dst += 2;
- while(++first < last)
- {
+ while(++first < last) {
*dst += 0x08;
dst += 2;
}
@@ -804,15 +799,15 @@ bool Rasterizer::Rasterize(int xsub, int ysub, int fBlur, double fGaussianBlur)
}
// Do some gaussian blur magic
- if (fGaussianBlur > 0)
- {
+ if (fGaussianBlur > 0) {
GaussianKernel filter(fGaussianBlur);
- if (mOverlayWidth >= filter.width && mOverlayHeight >= filter.width)
- {
+ if (mOverlayWidth >= filter.width && mOverlayHeight >= filter.width) {
size_t pitch = mOverlayWidth*2;
byte *tmp = DNew byte[pitch*mOverlayHeight];
- if(!tmp) return(false);
+ if(!tmp) {
+ return(false);
+ }
int border = !mWideOutline.empty() ? 1 : 0;
@@ -827,27 +822,25 @@ bool Rasterizer::Rasterize(int xsub, int ysub, int fBlur, double fGaussianBlur)
// 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)
- {
+ 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);
+ if(!tmp) {
+ return(false);
+ }
memcpy(tmp, mpOverlayBuffer, pitch*mOverlayHeight);
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++)
- {
+ 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)
- {
+ 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;
@@ -971,10 +964,10 @@ void Rasterizer::Draw_noAlpha_spFF_Body_0(RasterizerNfo& rnfo)
// 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)
+ 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);
}
@@ -995,10 +988,10 @@ void Rasterizer::Draw_noAlpha_spFF_noBody_0(RasterizerNfo& rnfo)
// 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)
+ 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);
@@ -1018,12 +1011,13 @@ void Rasterizer::Draw_noAlpha_sp_Body_0(RasterizerNfo& rnfo)
// (So switchpts stores both colours *and* coordinates?)
int gran = min(rnfo.sw[3]+1-rnfo.xo,rnfo.w);
int color2 = rnfo.sw[2];
- while(h--)
- {
- for(int wt=0; wt<gran; ++wt)
+ while(h--) {
+ for(int wt=0; wt<gran; ++wt) {
pixmix(&dst[wt], color, s[wt*2]);
- for(int wt=gran; wt<rnfo.w; ++wt)
+ }
+ 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);
}
@@ -1039,12 +1033,13 @@ void Rasterizer::Draw_noAlpha_sp_noBody_0(RasterizerNfo& rnfo)
int gran = min(rnfo.sw[3]+1-rnfo.xo,rnfo.w);
int color2 = rnfo.sw[2];
- while(h--)
- {
- for(int wt=0; wt<gran; ++wt)
+ 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)
+ }
+ 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);
}
@@ -1067,8 +1062,7 @@ void Rasterizer::Draw_Alpha_spFF_Body_0(RasterizerNfo& rnfo)
// clipping mask.
// Multiplying them together yields a 12-bit number.
// I think some imprecision is introduced here??
- while(h--)
- {
+ while(h--) {
for(int wt=0; wt<rnfo.w; ++wt)
#ifdef _VSMOD // patch m006. moveable vector clip
pixmix2(&dst[wt], color, s[wt*2], mod_vc.GetAlphaValue(wt,h));
@@ -1096,18 +1090,21 @@ void Rasterizer::Draw_Alpha_spFF_noBody_0(RasterizerNfo& rnfo)
int gran = min(rnfo.sw[3]+1-rnfo.xo,rnfo.w);
int color2 = rnfo.sw[2];
- while(h--)
- {
+ while(h--) {
#ifdef _VSMOD // patch m006. moveable vector clip
- for(int wt=0; wt<gran; ++wt)
+ for(int wt=0; wt<gran; ++wt) {
pixmix2(&dst[wt], color, safe_subtract(src[wt*2+1], src[wt*2]), mod_vc.GetAlphaValue(wt,h));
- for(int wt=gran; wt<rnfo.w; ++wt)
+ }
+ for(int wt=gran; wt<rnfo.w; ++wt) {
pixmix2(&dst[wt], color2, safe_subtract(src[wt*2+1], src[wt*2]), mod_vc.GetAlphaValue(wt,h));
+ }
#else
- for(int wt=0; wt<gran; ++wt)
+ 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)
+ }
+ 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;
#endif
src += 2*rnfo.overlayp;
@@ -1128,10 +1125,8 @@ void Rasterizer::Draw_Alpha_sp_Body_0(RasterizerNfo& rnfo)
byte* s = rnfo.s;
DWORD* dst = rnfo.dst;
- while(h--)
- {
- for(int wt=0; wt<rnfo.w; ++wt)
- {
+ while(h--) {
+ for(int wt=0; wt<rnfo.w; ++wt) {
#ifdef _VSMOD // patch m006. moveable vector clip
pixmix2(&dst[wt], color, s[wt*2], mod_vc.GetAlphaValue(wt,h));
}
@@ -1160,18 +1155,21 @@ void Rasterizer::Draw_Alpha_sp_noBody_0(RasterizerNfo& rnfo)
DWORD* dst = rnfo.dst;
int gran = min(rnfo.sw[3]+1-rnfo.xo,rnfo.w);
int color2 = rnfo.sw[2];
- while(h--)
- {
+ while(h--) {
#ifdef _VSMOD // patch m006. moveable vector clip
- for(int wt=0; wt<gran; ++wt)
+ for(int wt=0; wt<gran; ++wt) {
pixmix2(&dst[wt], color, safe_subtract(src[wt*2+1], src[wt*2]), mod_vc.GetAlphaValue(wt,h));
- for(int wt=gran; wt<rnfo.w; ++wt)
+ }
+ for(int wt=gran; wt<rnfo.w; ++wt) {
pixmix2(&dst[wt], color2, safe_subtract(src[wt*2+1], src[wt*2]), mod_vc.GetAlphaValue(wt,h));
+ }
#else
- for(int wt=0; wt<gran; ++wt)
+ 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)
+ }
+ 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;
#endif
src += 2*rnfo.overlayp;
@@ -1190,10 +1188,10 @@ void Rasterizer::Draw_noAlpha_spFF_Body_sse2(RasterizerNfo& rnfo)
// 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)
+ while(h--) {
+ for(int wt=0; wt<rnfo.w; ++wt) {
pixmix_sse2(&dst[wt], color, s[wt*2]);
+ }
s += 2*rnfo.overlayp;
dst = (DWORD*)((char *)dst + rnfo.pitch);
}
@@ -1214,10 +1212,10 @@ void Rasterizer::Draw_noAlpha_spFF_noBody_sse2(RasterizerNfo& rnfo)
// 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)
+ 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);
@@ -1237,12 +1235,13 @@ void Rasterizer::Draw_noAlpha_sp_Body_sse2(RasterizerNfo& rnfo)
// (So switchpts stores both colours *and* coordinates?)
int gran = min(rnfo.sw[3]+1-rnfo.xo,rnfo.w);
int color2 = rnfo.sw[2];
- while(h--)
- {
- for(int wt=0; wt<gran; ++wt)
+ while(h--) {
+ for(int wt=0; wt<gran; ++wt) {
pixmix_sse2(&dst[wt], color, s[wt*2]);
- for(int wt=gran; wt<rnfo.w; ++wt)
+ }
+ for(int wt=gran; wt<rnfo.w; ++wt) {
pixmix_sse2(&dst[wt], color2, s[wt*2]);
+ }
s += 2*rnfo.overlayp;
dst = (DWORD*)((char *)dst + rnfo.pitch);
}
@@ -1258,12 +1257,13 @@ void Rasterizer::Draw_noAlpha_sp_noBody_sse2(RasterizerNfo& rnfo)
DWORD* dst = rnfo.dst;
int gran = min(rnfo.sw[3]+1-rnfo.xo,rnfo.w);
int color2 = rnfo.sw[2];
- while(h--)
- {
- for(int wt=0; wt<gran; ++wt)
+ 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)
+ }
+ 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);
}
@@ -1286,8 +1286,7 @@ void Rasterizer::Draw_Alpha_spFF_Body_sse2(RasterizerNfo& rnfo)
// clipping mask.
// Multiplying them together yields a 12-bit number.
// I think some imprecision is introduced here??
- while(h--)
- {
+ while(h--) {
for(int wt=0; wt<rnfo.w; ++wt)
#ifdef _VSMOD // patch m006. moveable vector clip
pixmix2_sse2(&dst[wt], color, s[wt*2], mod_vc.GetAlphaValue(wt,h));
@@ -1313,8 +1312,7 @@ void Rasterizer::Draw_Alpha_spFF_noBody_sse2(RasterizerNfo& rnfo)
byte* src = rnfo.src;
DWORD* dst = rnfo.dst;
- while(h--)
- {
+ while(h--) {
for(int wt=0; wt<rnfo.w; ++wt)
#ifdef _VSMOD // patch m006. moveable vector clip
pixmix2_sse2(&dst[wt], color, safe_subtract_sse2(src[wt*2+1], src[wt*2]), mod_vc.GetAlphaValue(wt,h));
@@ -1343,18 +1341,21 @@ void Rasterizer::Draw_Alpha_sp_Body_sse2(RasterizerNfo& rnfo)
int gran = min(rnfo.sw[3]+1-rnfo.xo,rnfo.w);
int color2 = rnfo.sw[2];
- while(h--)
- {
+ while(h--) {
#ifdef _VSMOD // patch m006. moveable vector clip
- for(int wt=0; wt<gran; ++wt)
+ for(int wt=0; wt<gran; ++wt) {
pixmix2_sse2(&dst[wt], color, s[wt*2], mod_vc.GetAlphaValue(wt,h));
- for(int wt=gran; wt<rnfo.w; ++wt)
+ }
+ for(int wt=gran; wt<rnfo.w; ++wt) {
pixmix2_sse2(&dst[wt], color2, s[wt*2], mod_vc.GetAlphaValue(wt,h));
+ }
#else
- for(int wt=0; wt<gran; ++wt)
+ 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)
+ }
+ for(int wt=gran; wt<rnfo.w; ++wt) {
pixmix2_sse2(&dst[wt], color2, s[wt*2], am[wt]);
+ }
am += rnfo.spdw;
#endif
s += 2*rnfo.overlayp;
@@ -1379,18 +1380,21 @@ void Rasterizer::Draw_Alpha_sp_noBody_sse2(RasterizerNfo& rnfo)
int gran = min(rnfo.sw[3]+1-rnfo.xo,rnfo.w);
int color2 = rnfo.sw[2];
UNUSED_ALWAYS(color2);
- while(h--)
- {
+ while(h--) {
#ifdef _VSMOD // patch m006. moveable vector clip
- for(int wt=0; wt<gran; ++wt)
+ for(int wt=0; wt<gran; ++wt) {
pixmix2_sse2(&dst[wt], color, safe_subtract_sse2(src[wt*2+1], src[wt*2]), mod_vc.GetAlphaValue(wt,h));
- for(int wt=gran; wt<rnfo.w; ++wt)
+ }
+ for(int wt=gran; wt<rnfo.w; ++wt) {
pixmix2_sse2(&dst[wt], color, safe_subtract_sse2(src[wt*2+1], src[wt*2]), mod_vc.GetAlphaValue(wt,h));
+ }
#else
- for(int wt=0; wt<gran; ++wt)
+ 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)
+ }
+ 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;
#endif
src += 2*rnfo.overlayp;
@@ -1409,10 +1413,10 @@ void Rasterizer::Draw_Grad_noAlpha_spFF_Body_0(RasterizerNfo& rnfo)
int typ = rnfo.typ;
int h = rnfo.h;
int w = rnfo.w;
- while(h--)
- {
- for(int wt=0; wt<w; ++wt)
+ while(h--) {
+ for(int wt=0; wt<w; ++wt) {
pixmix(&dst[wt], mod_grad.getmixcolor(wt,h,typ), s[wt*2]);
+ }
s += 2*rnfo.overlayp;
dst = (DWORD*)((char *)dst + rnfo.pitch);
}
@@ -1428,10 +1432,10 @@ void Rasterizer::Draw_Grad_noAlpha_spFF_noBody_0(RasterizerNfo& rnfo)
int typ = rnfo.typ;
int h = rnfo.h;
int w = rnfo.w;
- while(h--)
- {
- for(int wt=0; wt<w; ++wt)
+ while(h--) {
+ for(int wt=0; wt<w; ++wt) {
pixmix(&dst[wt], mod_grad.getmixcolor(wt,h,typ), safe_subtract(src[wt*2+1], src[wt*2]));
+ }
src += 2*rnfo.overlayp;
dst = (DWORD*)((char *)dst + rnfo.pitch);
@@ -1449,12 +1453,13 @@ void Rasterizer::Draw_Grad_noAlpha_sp_Body_0(RasterizerNfo& rnfo)
int w = rnfo.w;
int gran = max(rnfo.sw[3]+1-rnfo.xo,0);
- while(h--)
- {
- for(int wt=0; wt<gran; ++wt)
+ while(h--) {
+ for(int wt=0; wt<gran; ++wt) {
pixmix(&dst[wt], mod_grad.getmixcolor(wt,h,0), s[wt*2]);
- for(int wt=gran; wt<w; ++wt)
+ }
+ for(int wt=gran; wt<w; ++wt) {
pixmix(&dst[wt], mod_grad.getmixcolor(wt,h,1), s[wt*2]);
+ }
s += 2*rnfo.overlayp;
dst = (DWORD*)((char *)dst + rnfo.pitch);
}
@@ -1471,12 +1476,13 @@ void Rasterizer::Draw_Grad_noAlpha_sp_noBody_0(RasterizerNfo& rnfo)
int w = rnfo.w;
int gran = min(rnfo.sw[3]+1-rnfo.xo,rnfo.w);
- while(h--)
- {
- for(int wt=0; wt<gran; ++wt)
+ while(h--) {
+ for(int wt=0; wt<gran; ++wt) {
pixmix(&dst[wt], mod_grad.getmixcolor(wt,h,0), safe_subtract(src[wt*2+1], src[wt*2]));
- for(int wt=gran; wt<w; ++wt)
+ }
+ for(int wt=gran; wt<w; ++wt) {
pixmix(&dst[wt], mod_grad.getmixcolor(wt,h,1), safe_subtract(src[wt*2+1], src[wt*2]));
+ }
src += 2*rnfo.overlayp;
dst = (DWORD*)((char *)dst + rnfo.pitch);
}
@@ -1492,10 +1498,10 @@ void Rasterizer::Draw_Grad_Alpha_spFF_Body_0(RasterizerNfo& rnfo)
int typ = rnfo.typ;
int h = rnfo.h;
int w = rnfo.w;
- while(h--)
- {
- for(int wt=0; wt<w; ++wt)
+ while(h--) {
+ for(int wt=0; wt<w; ++wt) {
pixmix2(&dst[wt], mod_grad.getmixcolor(wt,h,typ), s[wt*2], mod_vc.GetAlphaValue(wt,h));
+ }
s += 2*rnfo.overlayp;
dst = (DWORD*)((char *)dst + rnfo.pitch);
}
@@ -1511,10 +1517,10 @@ void Rasterizer::Draw_Grad_Alpha_spFF_noBody_0(RasterizerNfo& rnfo)
int typ = rnfo.typ;
int h = rnfo.h;
int w = rnfo.w;
- while(h--)
- {
- for(int wt=0; wt<w; ++wt)
+ while(h--) {
+ for(int wt=0; wt<w; ++wt) {
pixmix2(&dst[wt], mod_grad.getmixcolor(wt,h,typ), safe_subtract(src[wt*2+1], src[wt*2]), mod_vc.GetAlphaValue(wt,h));
+ }
src += 2*rnfo.overlayp;
dst = (DWORD*)((char *)dst + rnfo.pitch);
}
@@ -1532,12 +1538,13 @@ void Rasterizer::Draw_Grad_Alpha_sp_Body_0(RasterizerNfo& rnfo)
int h = rnfo.h;
int w = rnfo.w;
- while(h--)
- {
- for(int wt=0; wt<gran; ++wt)
+ while(h--) {
+ for(int wt=0; wt<gran; ++wt) {
pixmix2(&dst[wt], mod_grad.getmixcolor(wt,h,0), s[wt*2], mod_vc.GetAlphaValue(wt,h));
- for(int wt=gran; wt<w; ++wt)
+ }
+ for(int wt=gran; wt<w; ++wt) {
pixmix2(&dst[wt], mod_grad.getmixcolor(wt,h,1), s[wt*2], mod_vc.GetAlphaValue(wt,h));
+ }
s += 2*rnfo.overlayp;
dst = (DWORD*)((char *)dst + rnfo.pitch);
}
@@ -1555,12 +1562,13 @@ void Rasterizer::Draw_Grad_Alpha_sp_noBody_0(RasterizerNfo& rnfo)
int h = rnfo.h;
int w = rnfo.w;
- while(h--)
- {
- for(int wt=0; wt<gran; ++wt)
+ while(h--) {
+ for(int wt=0; wt<gran; ++wt) {
pixmix2(&dst[wt], mod_grad.getmixcolor(wt,h,0), safe_subtract(src[wt*2+1], src[wt*2]), mod_vc.GetAlphaValue(wt,h));
- for(int wt=gran; wt<w; ++wt)
+ }
+ for(int wt=gran; wt<w; ++wt) {
pixmix2(&dst[wt], mod_grad.getmixcolor(wt,h,1), safe_subtract(src[wt*2+1], src[wt*2]), mod_vc.GetAlphaValue(wt,h));
+ }
src += 2*rnfo.overlayp;
dst = (DWORD*)((char *)dst + rnfo.pitch);
}
@@ -1577,10 +1585,10 @@ void Rasterizer::Draw_Grad_noAlpha_spFF_Body_sse2(RasterizerNfo& rnfo)
int h = rnfo.h;
int w = rnfo.w;
- while(h--)
- {
- for(int wt=0; wt<w; ++wt)
+ while(h--) {
+ for(int wt=0; wt<w; ++wt) {
pixmix_sse2(&dst[wt], mod_grad.getmixcolor(wt,h,typ), s[wt*2]);
+ }
s += 2*rnfo.overlayp;
dst = (DWORD*)((char *)dst + rnfo.pitch);
}
@@ -1596,10 +1604,10 @@ void Rasterizer::Draw_Grad_noAlpha_spFF_noBody_sse2(RasterizerNfo& rnfo)
int h = rnfo.h;
int w = rnfo.w;
- while(h--)
- {
- for(int wt=0; wt<w; ++wt)
+ while(h--) {
+ for(int wt=0; wt<w; ++wt) {
pixmix_sse2(&dst[wt], mod_grad.getmixcolor(wt,h,typ), safe_subtract_sse2(src[wt*2+1], src[wt*2]));
+ }
src += 2*rnfo.overlayp;
dst = (DWORD*)((char *)dst + rnfo.pitch);
@@ -1616,12 +1624,13 @@ void Rasterizer::Draw_Grad_noAlpha_sp_Body_sse2(RasterizerNfo& rnfo)
int h = rnfo.h;
int w = rnfo.w;
int gran = min(rnfo.sw[3]+1-rnfo.xo,rnfo.w);
- while(h--)
- {
- for(int wt=0; wt<gran; ++wt)
+ while(h--) {
+ for(int wt=0; wt<gran; ++wt) {
pixmix_sse2(&dst[wt], mod_grad.getmixcolor(wt,h,0), s[wt*2]);
- for(int wt=gran; wt<w; ++wt)
+ }
+ for(int wt=gran; wt<w; ++wt) {
pixmix_sse2(&dst[wt], mod_grad.getmixcolor(wt,h,1), s[wt*2]);
+ }
s += 2*rnfo.overlayp;
dst = (DWORD*)((char *)dst + rnfo.pitch);
}
@@ -1637,12 +1646,13 @@ void Rasterizer::Draw_Grad_noAlpha_sp_noBody_sse2(RasterizerNfo& rnfo)
int h = rnfo.h;
int w = rnfo.w;
int gran = min(rnfo.sw[3]+1-rnfo.xo,rnfo.w);
- while(h--)
- {
- for(int wt=0; wt<gran; ++wt)
+ while(h--) {
+ for(int wt=0; wt<gran; ++wt) {
pixmix_sse2(&dst[wt], mod_grad.getmixcolor(wt,h,0), safe_subtract_sse2(src[wt*2+1], src[wt*2]));
- for(int wt=gran; wt<w; ++wt)
+ }
+ for(int wt=gran; wt<w; ++wt) {
pixmix_sse2(&dst[wt], mod_grad.getmixcolor(wt,h,1), safe_subtract_sse2(src[wt*2+1], src[wt*2]));
+ }
src += 2*rnfo.overlayp;
dst = (DWORD*)((char *)dst + rnfo.pitch);
}
@@ -1659,10 +1669,10 @@ void Rasterizer::Draw_Grad_Alpha_spFF_Body_sse2(RasterizerNfo& rnfo)
int typ = rnfo.typ;
int h = rnfo.h;
int w = rnfo.w;
- while(h--)
- {
- for(int wt=0; wt<w; ++wt)
+ while(h--) {
+ for(int wt=0; wt<w; ++wt) {
pixmix2_sse2(&dst[wt], mod_grad.getmixcolor(wt,h,typ), s[wt*2], mod_vc.GetAlphaValue(wt,h));
+ }
s += 2*rnfo.overlayp;
dst = (DWORD*)((char *)dst + rnfo.pitch);
}
@@ -1679,10 +1689,10 @@ void Rasterizer::Draw_Grad_Alpha_spFF_noBody_sse2(RasterizerNfo& rnfo)
int typ = rnfo.typ;
int h = rnfo.h;
int w = rnfo.w;
- while(h--)
- {
- for(int wt=0; wt<w; ++wt)
+ while(h--) {
+ for(int wt=0; wt<w; ++wt) {
pixmix2_sse2(&dst[wt], mod_grad.getmixcolor(wt,h,typ), safe_subtract_sse2(src[wt*2+1], src[wt*2]), mod_vc.GetAlphaValue(wt,h));
+ }
src += 2*rnfo.overlayp;
dst = (DWORD*)((char *)dst + rnfo.pitch);
}
@@ -1699,12 +1709,13 @@ void Rasterizer::Draw_Grad_Alpha_sp_Body_sse2(RasterizerNfo& rnfo)
int h = rnfo.h;
int w = rnfo.w;
int gran = min(rnfo.sw[3]+1-rnfo.xo,rnfo.w);
- while(h--)
- {
- for(int wt=0; wt<gran; ++wt)
+ while(h--) {
+ for(int wt=0; wt<gran; ++wt) {
pixmix2_sse2(&dst[wt], mod_grad.getmixcolor(wt,h,0), s[wt*2], mod_vc.GetAlphaValue(wt,h));
- for(int wt=gran; wt<w; ++wt)
+ }
+ for(int wt=gran; wt<w; ++wt) {
pixmix2_sse2(&dst[wt], mod_grad.getmixcolor(wt,h,1), s[wt*2], mod_vc.GetAlphaValue(wt,h));
+ }
s += 2*rnfo.overlayp;
dst = (DWORD*)((char *)dst + rnfo.pitch);
}
@@ -1721,12 +1732,13 @@ void Rasterizer::Draw_Grad_Alpha_sp_noBody_sse2(RasterizerNfo& rnfo)
int h = rnfo.h;
int w = rnfo.w;
int gran = min(rnfo.sw[3]+1-rnfo.xo,rnfo.w);
- while(h--)
- {
- for(int wt=0; wt<gran; ++wt)
+ while(h--) {
+ for(int wt=0; wt<gran; ++wt) {
pixmix2_sse2(&dst[wt], mod_grad.getmixcolor(wt,h,0), safe_subtract_sse2(src[wt*2+1], src[wt*2]), mod_vc.GetAlphaValue(wt,h));
- for(int wt=gran; wt<w; ++wt)
+ }
+ for(int wt=gran; wt<w; ++wt) {
pixmix2_sse2(&dst[wt], mod_grad.getmixcolor(wt,h,1), safe_subtract_sse2(src[wt*2+1], src[wt*2]), mod_vc.GetAlphaValue(wt,h));
+ }
src += 2*rnfo.overlayp;
dst = (DWORD*)((char *)dst + rnfo.pitch);
}
@@ -1751,7 +1763,9 @@ CRect Rasterizer::Draw(SubPicDesc& spd, CRect& clipRect, byte* pAlphaMask, int x
{
CRect bbox(0, 0, 0, 0);
- if(!switchpts || !fBody && !fBorder) return(bbox);
+ 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);
@@ -1777,11 +1791,17 @@ CRect Rasterizer::Draw(SubPicDesc& spd, CRect& clipRect, byte* pAlphaMask, int x
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;
+ 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);
+ if(w <= 0 || h <= 0) {
+ return(bbox);
+ }
bbox.SetRect(x, y, x+w, y+h);
bbox &= CRect(0, 0, spd.w, spd.h);
@@ -1834,242 +1854,159 @@ CRect Rasterizer::Draw(SubPicDesc& spd, CRect& clipRect, byte* pAlphaMask, int x
if(((typ==0)&&((mod_grad.mode[0]==0)&&(mod_grad.mode[1]==0)))||(mod_grad.mode[typ]==0))
// No gradient
#endif
- if(!pAlphaMask)
- {
+ 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)
- {
+ if(switchpts[1] == 0xFFFFFFFF) {
// fBody is true if we're rendering a fill or a shadow.
- if(fBody)
- {
- if(fSSE2)
- {
+ if(fBody) {
+ if(fSSE2) {
Draw_noAlpha_spFF_Body_sse2(rnfo);
- }
- else
- {
+ } else {
Draw_noAlpha_spFF_Body_0(rnfo);
}
}
// Not painting body, ie. painting border without fill in it
- else
- {
- if(fSSE2)
- {
+ else {
+ if(fSSE2) {
Draw_noAlpha_spFF_noBody_sse2(rnfo);
- }
- else
- {
+ } else {
Draw_noAlpha_spFF_noBody_0(rnfo);
}
}
}
// not (switchpts[1] == 0xFFFFFFFF)
- else
- {
+ else {
// switchpts plays an important rule here
//const long *sw = switchpts;
- if(fBody)
- {
- if(fSSE2)
- {
+ if(fBody) {
+ if(fSSE2) {
Draw_noAlpha_sp_Body_sse2(rnfo);
- }
- else
- {
+ } else {
Draw_noAlpha_sp_Body_0(rnfo);
}
}
// Not body
- else
- {
- if(fSSE2)
- {
+ else {
+ if(fSSE2) {
Draw_noAlpha_sp_noBody_sse2(rnfo);
- }
- else
- {
+ } else {
Draw_noAlpha_sp_noBody_0(rnfo);
}
}
}
}
// Here we *do* have an alpha mask
- else
- {
- if(switchpts[1] == 0xFFFFFFFF)
- {
- if(fBody)
- {
- if(fSSE2)
- {
+ else {
+ if(switchpts[1] == 0xFFFFFFFF) {
+ if(fBody) {
+ if(fSSE2) {
Draw_Alpha_spFF_Body_sse2(rnfo);
- }
- else
- {
+ } else {
Draw_Alpha_spFF_Body_0(rnfo);
}
- }
- else
- {
- if(fSSE2)
- {
+ } else {
+ if(fSSE2) {
Draw_Alpha_spFF_noBody_sse2(rnfo);
- }
- else
- {
+ } else {
Draw_Alpha_spFF_noBody_0(rnfo);
}
}
- }
- else
- {
+ } else {
//const long *sw = switchpts;
- if(fBody)
- {
- if(fSSE2)
- {
+ if(fBody) {
+ if(fSSE2) {
Draw_Alpha_sp_Body_sse2(rnfo);
- }
- else
- {
+ } else {
Draw_Alpha_sp_Body_0(rnfo);
}
- }
- else
- {
- if(fSSE2)
- {
+ } else {
+ if(fSSE2) {
Draw_Alpha_sp_noBody_sse2(rnfo);
- }
- else
- {
+ } else {
Draw_Alpha_sp_noBody_0(rnfo);
}
}
}
}
#ifdef _VSMOD // patch m004. gradient colors
- else
- {
- if(!pAlphaMask)
- {
+ else {
+ 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)
- {
+ if(switchpts[1] == 0xFFFFFFFF) {
// fBody is true if we're rendering a fill or a shadow.
- if(fBody)
- {
- if(fSSE2)
- {
+ if(fBody) {
+ if(fSSE2) {
Draw_Grad_noAlpha_spFF_Body_sse2(rnfo);
- }
- else
- {
+ } else {
Draw_Grad_noAlpha_spFF_Body_0(rnfo);
}
}
// Not painting body, ie. painting border without fill in it
- else
- {
- if(fSSE2)
- {
+ else {
+ if(fSSE2) {
Draw_Grad_noAlpha_spFF_noBody_sse2(rnfo);
- }
- else
- {
+ } else {
Draw_Grad_noAlpha_spFF_noBody_0(rnfo);
}
}
}
// not (switchpts[1] == 0xFFFFFFFF)
- else
- {
+ else {
// switchpts plays an important rule here
//const long *sw = switchpts;
- if(fBody)
- {
- if(fSSE2)
- {
+ if(fBody) {
+ if(fSSE2) {
Draw_Grad_noAlpha_sp_Body_sse2(rnfo);
- }
- else
- {
+ } else {
Draw_Grad_noAlpha_sp_Body_0(rnfo);
}
}
// Not body
- else
- {
- if(fSSE2)
- {
+ else {
+ if(fSSE2) {
Draw_Grad_noAlpha_sp_noBody_sse2(rnfo);
- }
- else
- {
+ } else {
Draw_Grad_noAlpha_sp_noBody_0(rnfo);
}
}
}
}
// Here we *do* have an alpha mask
- else
- {
- if(switchpts[1] == 0xFFFFFFFF)
- {
- if(fBody)
- {
- if(fSSE2)
- {
+ else {
+ if(switchpts[1] == 0xFFFFFFFF) {
+ if(fBody) {
+ if(fSSE2) {
Draw_Grad_Alpha_spFF_Body_sse2(rnfo);
- }
- else
- {
+ } else {
Draw_Grad_Alpha_spFF_Body_0(rnfo);
}
- }
- else
- {
- if(fSSE2)
- {
+ } else {
+ if(fSSE2) {
Draw_Grad_Alpha_spFF_noBody_sse2(rnfo);
- }
- else
- {
+ } else {
Draw_Grad_Alpha_spFF_noBody_0(rnfo);
}
}
- }
- else
- {
+ } else {
//const long *sw = switchpts;
- if(fBody)
- {
- if(fSSE2)
- {
+ if(fBody) {
+ if(fSSE2) {
Draw_Grad_Alpha_sp_Body_sse2(rnfo);
- }
- else
- {
+ } else {
Draw_Grad_Alpha_sp_Body_0(rnfo);
}
- }
- else
- {
- if(fSSE2)
- {
+ } else {
+ if(fSSE2) {
Draw_Grad_Alpha_sp_noBody_sse2(rnfo);
- }
- else
- {
+ } else {
Draw_Grad_Alpha_sp_noBody_0(rnfo);
}
}
@@ -2095,8 +2032,7 @@ void Rasterizer::FillSolidRect(SubPicDesc& spd, int x, int y, int nWidth, int nH
DWORD alpha = (lColor >> 24) & 0xff;
lColor = (255 - alpha) << 24 | lColor & 0xffffff;
// Warning : lColor is AARRGGBB (same format as DirectX D3DCOLOR_ARGB)
- for (int wy=y; wy<y+nHeight; wy++)
- {
+ for (int wy=y; wy<y+nHeight; wy++) {
DWORD* dst = (DWORD*)((BYTE*)spd.bits + spd.pitch * wy) + x;
memsetd(dst, lColor, nWidth*4);
@@ -2107,22 +2043,19 @@ void Rasterizer::FillSolidRect(SubPicDesc& spd, int x, int y, int nWidth, int nH
{
bool fSSE2 = !!(g_cpuid.m_flags & CCpuID::sse2);
- if(fSSE2)
- {
- for (int wy=y; wy<y+nHeight; wy++)
- {
+ if(fSSE2) {
+ 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)
- pixmix_sse2(&dst[wt], lColor, 0x40); // 0x40 because >> 6 in pixmix (to preserve tranparency)
+ for(int wt=0; wt<nWidth; ++wt) {
+ pixmix_sse2(&dst[wt], lColor, 0x40); // 0x40 because >> 6 in pixmix (to preserve tranparency)
+ }
}
- }
- else
- {
- for (int wy=y; wy<y+nHeight; wy++)
- {
+ } else {
+ 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)
+ for(int wt=0; wt<nWidth; ++wt) {
pixmix(&dst[wt], lColor, 0x40);
+ }
}
}
}
@@ -2139,7 +2072,7 @@ void MOD_MOVEVC::clear()
enable = false;
size = CSize(0,0);
pos = CPoint(0,0);
-// canvas = CSize(0,0);
+ // canvas = CSize(0,0);
spd = CSize(0,0);
curpos = CPoint(0,0);
hfull = 0;
@@ -2149,16 +2082,21 @@ void MOD_MOVEVC::clear()
byte MOD_MOVEVC::GetAlphaValue(int wx,int wy)
{
byte alpham;
- if(!enable)
- {
-// return 0xFF;
+ if(!enable) {
+ // return 0xFF;
return alphamask[wx+((hfull-wy)*spd.cx)];
}
- if ((wx-pos.x)<-curpos.x+1) alpham=0;
- else if ((wx-pos.x)>spd.cx-1) alpham=0;//canvas.cx
- else if ((hfull-wy-pos.y)<-curpos.y+1) alpham=0;
- else if ((hfull-wy-pos.y)>spd.cy-1) alpham=0;
- else alpham=alphamask[wx-pos.x - pos.y*spd.cx+((hfull-wy)*spd.cx)];
+ if ((wx-pos.x)<-curpos.x+1) {
+ alpham=0;
+ } else if ((wx-pos.x)>spd.cx-1) {
+ alpham=0; //canvas.cx
+ } else if ((hfull-wy-pos.y)<-curpos.y+1) {
+ alpham=0;
+ } else if ((hfull-wy-pos.y)>spd.cy-1) {
+ alpham=0;
+ } else {
+ alpham=alphamask[wx-pos.x - pos.y*spd.cx+((hfull-wy)*spd.cx)];
+ }
return alpham;
}
@@ -2182,11 +2120,11 @@ RasterizerNfo::RasterizerNfo()
src = NULL;
dst = NULL;
-#ifdef _VSMOD
+ #ifdef _VSMOD
mod_grad.clear();
mod_vc.clear();
-#else
+ #else
am = NULL;
-#endif
+ #endif
*/
} \ No newline at end of file
diff --git a/src/Subtitles/RealTextParser.cpp b/src/Subtitles/RealTextParser.cpp
index 9a0e5e089..6e8366585 100644
--- a/src/Subtitles/RealTextParser.cpp
+++ b/src/Subtitles/RealTextParser.cpp
@@ -26,130 +26,111 @@ bool CRealTextParser::ParseRealText(wstring p_szFile)
list<Tag> listTags;
list<Tag> listPreviousOpenTags;
- while (p_szFile.length() > 0)
- {
- if (p_szFile.at(0) == '<')
- {
+ while (p_szFile.length() > 0) {
+ if (p_szFile.at(0) == '<') {
Tag oTag;
- if (!ExtractTag(p_szFile, oTag))
+ if (!ExtractTag(p_szFile, oTag)) {
return false;
+ }
- if (oTag.m_bComment)
+ if (oTag.m_bComment) {
continue;
+ }
- if (oTag.m_szName == L"time")
- {
+ if (oTag.m_szName == L"time") {
int iStartTimecode = GetTimecode(oTag.m_mapAttributes[L"begin"]);
int iEndTimecode = GetTimecode(oTag.m_mapAttributes[L"end"]);
-// FilterReduntantTags(listTags);
+ // FilterReduntantTags(listTags);
wstring szLine = RenderTags(listTags);
- if (bPrevEndTimeMissing)
- {
+ 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)
- {
+ if (pairTimecodes.first >= pairTimecodes.second) {
pairTimecodes.second = pairTimecodes.first + m_iDefaultSubtitleDurationInMillisecs;
}
- if (szLine.length() > 0)
+ if (szLine.length() > 0) {
m_RealText.m_mapLines[pairTimecodes] = szLine;
+ }
bPrevEndTimeMissing = false;
- }
- else if (vStartTimecodes.size() > 0 && vEndTimecodes.size() > 0)
- {
+ } else if (vStartTimecodes.size() > 0 && vEndTimecodes.size() > 0) {
pair<int, int> pairTimecodes(vStartTimecodes.back(), vEndTimecodes.back());
- if (szLine.length() > 0)
+ if (szLine.length() > 0) {
m_RealText.m_mapLines[pairTimecodes] = szLine;
+ }
}
vStartTimecodes.push_back(iStartTimecode);
- if (iEndTimecode <= 0)
- {
+ if (iEndTimecode <= 0) {
bPrevEndTimeMissing = true;
- }
- else
- {
+ } 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)
+ } 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)
+ if (oTag.m_bClose) {
PopTag(listPreviousOpenTags, oTag.m_szName);
+ }
listTags.push_back(oTag);
- }
- else if (oTag.m_szName == L"clear")
- {
+ } 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)
+ } 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")
- {
+ } else if (oTag.m_szName == L"center") {
m_RealText.m_bCenter = true;
- }
- else if (oTag.m_szName == L"required")
- {
+ } else if (oTag.m_szName == L"required") {
// Ignore
- }
- else if (oTag.m_szName == L"")
- {
+ } else if (oTag.m_szName == L"") {
// Ignore
- }
- else
- {
+ } else {
// assume formating tag (handled later)
listTags.push_back(oTag);
}
- }
- else
- {
+ } else {
Tag oTextTag;
- if (!ExtractTextTag(p_szFile, oTextTag))
+ if (!ExtractTextTag(p_szFile, oTextTag)) {
return false;
+ }
listTags.push_back(oTextTag);
}
}
// Handle final line
-// FilterReduntantTags(listTags);
+ // FilterReduntantTags(listTags);
wstring szLine = RenderTags(listTags);
- if (bPrevEndTimeMissing)
- {
+ if (bPrevEndTimeMissing) {
pair<int, int> pairTimecodes(vStartTimecodes.back(), vStartTimecodes.back() + m_iDefaultSubtitleDurationInMillisecs);
- if (szLine.length() > 0)
+ if (szLine.length() > 0) {
m_RealText.m_mapLines[pairTimecodes] = szLine;
+ }
bPrevEndTimeMissing = false;
- }
- else if (vStartTimecodes.size() > 0 && vEndTimecodes.size() > 0)
- {
+ } else if (vStartTimecodes.size() > 0 && vEndTimecodes.size() > 0) {
pair<int, int> pairTimecodes(vStartTimecodes.back(), vEndTimecodes.back());
- if (szLine.length() > 0)
+ if (szLine.length() > 0) {
m_RealText.m_mapLines[pairTimecodes] = szLine;
+ }
}
@@ -163,23 +144,19 @@ const CRealTextParser::Subtitles& CRealTextParser::GetParsedSubtitles()
bool CRealTextParser::ExtractTag(wstring& p_rszLine, Tag& p_rTag)
{
- if (p_rszLine.length() < 2 || p_rszLine.at(0) != '<')
- {
- if (m_bTryToIgnoreErrors)
- {
+ if (p_rszLine.length() < 2 || p_rszLine.at(0) != '<') {
+ if (m_bTryToIgnoreErrors) {
size_t iTempPos = p_rszLine.find_first_of('<');
- if (iTempPos != wstring::npos)
- {
+ if (iTempPos != wstring::npos) {
p_rszLine = p_rszLine.substr(iTempPos);
- if (p_rszLine.length() < 2)
+ if (p_rszLine.length() < 2) {
return false;
+ }
}
- }
- else
- {
+ } else {
return false;
}
}
@@ -187,8 +164,7 @@ bool CRealTextParser::ExtractTag(wstring& p_rszLine, Tag& p_rTag)
unsigned int iPos = 1;
// skip comments
- if (p_rszLine.at(iPos) == '!')
- {
+ if (p_rszLine.at(iPos) == '!') {
p_rTag.m_bComment = true;
wstring szComment;
@@ -198,69 +174,58 @@ bool CRealTextParser::ExtractTag(wstring& p_rszLine, Tag& p_rTag)
++iPos; // Skip >
p_rszLine = p_rszLine.substr(iPos);
return true;
- }
- else
- {
+ } else {
p_rTag.m_bComment = false;
}
- if (!SkipSpaces(p_rszLine, iPos))
+ if (!SkipSpaces(p_rszLine, iPos)) {
return false;
+ }
- if (p_rszLine.at(iPos) == '/')
- {
+ if (p_rszLine.at(iPos) == '/') {
p_rTag.m_bOpen = false;
p_rTag.m_bClose = true;
++iPos;
- }
- else
- {
+ } else {
p_rTag.m_bOpen = true;
p_rTag.m_bClose = false;
}
- if (!GetString(p_rszLine, iPos, p_rTag.m_szName, L"\r\n\t />"))
+ 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))
+ if (!GetAttributes(p_rszLine, iPos, p_rTag.m_mapAttributes)) {
return false;
+ }
- if (p_rszLine.at(iPos) == '/')
- {
+ if (p_rszLine.at(iPos) == '/') {
++iPos;
p_rTag.m_bClose = true;
}
- if (p_rszLine.at(iPos) == '>')
- {
+ if (p_rszLine.at(iPos) == '>') {
++iPos;
p_rszLine = p_rszLine.substr(iPos);
return true;
- }
- else
- {
- if (m_bTryToIgnoreErrors)
- {
+ } else {
+ if (m_bTryToIgnoreErrors) {
size_t iTempPos = p_rszLine.find_first_of('>');
- if (iTempPos != wstring::npos)
- {
- if (iTempPos - 1 >= p_rszLine.length())
+ if (iTempPos != wstring::npos) {
+ if (iTempPos - 1 >= p_rszLine.length()) {
return false;
+ }
p_rszLine = p_rszLine.substr(iTempPos + 1);
return true;
- }
- else
- {
+ } else {
return false;
}
- }
- else
- {
+ } else {
return false;
}
}
@@ -274,26 +239,24 @@ bool CRealTextParser::ExtractTextTag(wstring& p_rszLine, Tag& p_rTag)
bool CRealTextParser::ExtractString(wstring& p_rszLine, wstring& p_rszString)
{
- if (p_rszLine.length() == 0 || p_rszLine.at(0) == '<')
- {
- if (m_bTryToIgnoreErrors)
- {
+ if (p_rszLine.length() == 0 || p_rszLine.at(0) == '<') {
+ if (m_bTryToIgnoreErrors) {
p_rszString = L"";
return true;
- }
- else
- {
+ } else {
return false;
}
}
unsigned int iPos = 0;
- if (!SkipSpaces(p_rszLine, iPos))
+ if (!SkipSpaces(p_rszLine, iPos)) {
return false;
+ }
- if (!GetString(p_rszLine, iPos, p_rszString, L"<"))
+ if (!GetString(p_rszLine, iPos, p_rszString, L"<")) {
return false;
+ }
p_rszLine = p_rszLine.substr(iPos);
return true;
@@ -301,8 +264,7 @@ bool CRealTextParser::ExtractString(wstring& p_rszLine, wstring& p_rszString)
bool CRealTextParser::SkipSpaces(wstring& p_rszLine, unsigned int& p_riPos)
{
- while (p_rszLine.length() > p_riPos && iswspace(p_rszLine.at(p_riPos)))
- {
+ while (p_rszLine.length() > p_riPos && iswspace(p_rszLine.at(p_riPos))) {
++p_riPos;
}
@@ -311,8 +273,7 @@ bool CRealTextParser::SkipSpaces(wstring& p_rszLine, unsigned int& 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)
- {
+ 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;
}
@@ -322,69 +283,71 @@ bool CRealTextParser::GetString(wstring& p_rszLine, unsigned int& p_riPos, wstri
bool CRealTextParser::GetAttributes(wstring& p_rszLine, unsigned int& p_riPos, map<wstring, wstring>& p_rmapAttributes)
{
- if (!SkipSpaces(p_rszLine, 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) != '>')
- {
+ 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 ="))
+ if (!GetString(p_rszLine, p_riPos, szName, L"\r\n\t =")) {
return false;
+ }
- if (!SkipSpaces(p_rszLine, p_riPos))
+ if (!SkipSpaces(p_rszLine, p_riPos)) {
return false;
+ }
- if (p_rszLine.at(p_riPos) != '=')
- {
- if (m_bTryToIgnoreErrors)
- {
+ if (p_rszLine.at(p_riPos) != '=') {
+ if (m_bTryToIgnoreErrors) {
p_riPos = p_rszLine.find_first_of('=', p_riPos);
- if (p_riPos == wstring::npos)
+ if (p_riPos == wstring::npos) {
return false;
- }
- else
- {
+ }
+ } else {
return false;
}
}
++p_riPos;
- if (!SkipSpaces(p_rszLine, p_riPos))
+ if (!SkipSpaces(p_rszLine, p_riPos)) {
return false;
+ }
bool bUsesQuotes(false);
- if (p_rszLine.at(p_riPos) == '\'' || p_rszLine.at(p_riPos) == '\"')
- {
+ if (p_rszLine.at(p_riPos) == '\'' || p_rszLine.at(p_riPos) == '\"') {
++p_riPos;
bUsesQuotes = true;
}
- if (!SkipSpaces(p_rszLine, p_riPos))
+ if (!SkipSpaces(p_rszLine, p_riPos)) {
return false;
+ }
wstring szValue;
- if (bUsesQuotes)
- {
- if (!GetString(p_rszLine, p_riPos, szValue, L"\"\'/>"))
+ if (bUsesQuotes) {
+ if (!GetString(p_rszLine, p_riPos, szValue, L"\"\'/>")) {
return false;
- }
- else
- {
- if (!GetString(p_rszLine, p_riPos, szValue, L" \t/>"))
+ }
+ } else {
+ if (!GetString(p_rszLine, p_riPos, szValue, L" \t/>")) {
return false;
+ }
}
p_rmapAttributes[StringToLower(szName)] = szValue;
- if (!SkipSpaces(p_rszLine, p_riPos))
+ if (!SkipSpaces(p_rszLine, p_riPos)) {
return false;
+ }
- if (p_rszLine.at(p_riPos) == '\'' || p_rszLine.at(p_riPos) == '\"')
+ if (p_rszLine.at(p_riPos) == '\'' || p_rszLine.at(p_riPos) == '\"') {
++p_riPos;
+ }
- if (!SkipSpaces(p_rszLine, p_riPos))
+ if (!SkipSpaces(p_rszLine, p_riPos)) {
return false;
+ }
}
return p_rszLine.length() > p_riPos;
@@ -396,36 +359,30 @@ int CRealTextParser::GetTimecode(const wstring& p_crszTimecode)
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)
+ if (p_crszTimecode.find_first_of('.') == wstring::npos && p_crszTimecode.find_first_of(':') == wstring::npos) {
iMultiplier = 1000;
+ }
wstring szCurrentPart;
- for (int i = p_crszTimecode.length() - 1; i >= 0; --i)
- {
- if (p_crszTimecode.at(i) == '.' || p_crszTimecode.at(i) == ':')
- {
- if (iMultiplier == 1)
- {
- while (szCurrentPart.length() < 3)
+ for (int 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());
- if (iMultiplier == 1)
- {
+ if (iMultiplier == 1) {
iMultiplier = 1000;
- }
- else
- {
+ } else {
iMultiplier *= 60;
}
szCurrentPart = L"";
- }
- else
- {
+ } else {
szCurrentPart = p_crszTimecode.substr(i, 1) + szCurrentPart;
}
}
@@ -459,8 +416,9 @@ wstring CRealTextParser::FormatTimecode(int iTimecode,
int iMilliSeconds = iTimecode % 1000;
- if (iMillisecondPrecision < 3)
+ if (iMillisecondPrecision < 3) {
iMilliSeconds /= 10 * (3 - iMillisecondPrecision);
+ }
ossTimecode << p_crszMillisecondSeparator;
ossTimecode << iMilliSeconds;
@@ -471,8 +429,7 @@ wstring CRealTextParser::FormatTimecode(int iTimecode,
wstring CRealTextParser::StringToLower(const wstring& p_crszString)
{
wstring szLowercaseString;
- for(unsigned int i=0; i < p_crszString.length(); ++i)
- {
+ for(unsigned int i=0; i < p_crszString.length(); ++i) {
szLowercaseString += towlower(p_crszString.at(i));
}
return szLowercaseString;
@@ -483,69 +440,54 @@ 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)
- {
+ for (list<Tag>::const_iterator iter = p_crlTags.begin(); iter != p_crlTags.end(); ++iter) {
Tag oTag(*iter);
- if (oTag.m_szName == L"br")
- {
+ if (oTag.m_szName == L"br") {
szString += L"\n";
- }
- else if (oTag.m_szName == L"b")
- {
- if (!m_bIgnoreFontWeight)
- {
- if (oTag.m_bOpen)
- {
+ } else if (oTag.m_szName == L"b") {
+ if (!m_bIgnoreFontWeight) {
+ if (oTag.m_bOpen) {
szString += L"<b>";
- }
- else if (oTag.m_bClose)
- {
+ } else if (oTag.m_bClose) {
szString += L"</b>";
}
}
- }
- else if (oTag.m_szName == L"i")
- {
- if (!m_bIgnoreFontWeight)
- {
- if (oTag.m_bOpen)
- {
+ } else if (oTag.m_szName == L"i") {
+ if (!m_bIgnoreFontWeight) {
+ if (oTag.m_bOpen) {
szString += L"<i>";
- }
- else if (oTag.m_bClose)
- {
+ } else if (oTag.m_bClose) {
szString += L"</i>";
}
}
- }
- else if (oTag.m_szName == L"font")
- {
- if (!m_bIgnoreFont)
- {
- if (oTag.m_bOpen)
- {
+ } 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")
+ 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")
+ if (m_bIgnoreFontColor && i->first == L"color") {
continue;
+ }
- if (m_bIgnoreFontFace && i->first == L"face")
+ if (m_bIgnoreFontFace && i->first == L"face") {
continue;
+ }
- if (i->first == L"size" && i->second.length() > 0 && ::iswdigit(i->second.at(0)))
- {
+ 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)
+ if (iSize > 0 && iSize < m_iMinFontSize) {
continue;
+ }
- if (iSize > m_iMaxFontSize)
+ if (iSize > m_iMaxFontSize) {
continue;
+ }
}
szString += L" ";
@@ -557,29 +499,26 @@ wstring CRealTextParser::RenderTags(const list<Tag>& p_crlTags)
szString += L">";
}
- if (oTag.m_bClose)
- {
+ if (oTag.m_bClose) {
szString += L"</font>";
}
}
- }
- else if (oTag.m_bText)
- {
+ } else if (oTag.m_bText) {
szString += oTag.m_szName;
- if (!oTag.m_szName.empty())
+ if (!oTag.m_szName.empty()) {
bEmpty = false;
- }
- else
- {
-// AfxMessageBox(CString(_T("Unknown RealText-tag: ")) + oTag.m_szName.c_str());
+ }
+ } else {
+ // AfxMessageBox(CString(_T("Unknown RealText-tag: ")) + oTag.m_szName.c_str());
}
}
- if (bEmpty)
+ if (bEmpty) {
return L"";
- else
+ } else {
return szString;
+ }
}
bool CRealTextParser::OutputSRT(wostream& p_rOutput)
@@ -587,8 +526,7 @@ 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)
- {
+ ++i) {
p_rOutput << iCounter++;
p_rOutput << endl;
@@ -607,10 +545,8 @@ bool CRealTextParser::OutputSRT(wostream& p_rOutput)
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)
- {
+ 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;
}
@@ -620,13 +556,10 @@ void CRealTextParser::PopTag(list<Tag>& p_rlistTags, const wstring& p_crszTagNam
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())
- {
+ 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)
- {
+ iterPrev->m_bOpen && iterCurrent->m_bOpen) {
p_rlistTags.erase(iterPrev);
}
}
diff --git a/src/Subtitles/RealTextParser.h b/src/Subtitles/RealTextParser.h
index cdb0013bd..28f93f1be 100644
--- a/src/Subtitles/RealTextParser.h
+++ b/src/Subtitles/RealTextParser.h
@@ -27,8 +27,7 @@ public:
CRealTextParser();
virtual ~CRealTextParser(void);
- struct Tag
- {
+ struct Tag {
Tag(): m_bOpen(false), m_bClose(false), m_bComment(false), m_bText(false) {}
wstring m_szName;
@@ -42,8 +41,7 @@ public:
map<wstring, wstring> m_mapAttributes;
};
- struct Subtitles
- {
+ struct Subtitles {
Subtitles(): m_WindowTag(), m_FontTag(), m_bCenter(false) {}
Tag m_WindowTag;
diff --git a/src/Subtitles/RenderedHdmvSubtitle.cpp b/src/Subtitles/RenderedHdmvSubtitle.cpp
index 2bb95c3cf..3c066ff2b 100644
--- a/src/Subtitles/RenderedHdmvSubtitle.cpp
+++ b/src/Subtitles/RenderedHdmvSubtitle.cpp
@@ -26,22 +26,21 @@
#include "DVBSub.h"
#include "RenderedHdmvSubtitle.h"
-CRenderedHdmvSubtitle::CRenderedHdmvSubtitle(CCritSec* pLock, SUBTITLE_TYPE nType)
- : CSubPicProviderImpl(pLock)
-{
- switch (nType)
- {
- case ST_DVB :
- m_pSub = DNew CDVBSub();
- m_name = "DVB Embedded Subtitle";
- break;
- case ST_HDMV :
- m_pSub = DNew CHdmvSub();
- m_name = "HDMV Embedded Subtitle";
- break;
- default :
- ASSERT (FALSE);
- m_pSub = NULL;
+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()) m_name = "DVB Embedded Subtitle";
+ break;
+ case ST_HDMV :
+ m_pSub = DNew CHdmvSub();
+ if (name.IsEmpty()) m_name = "HDMV Embedded Subtitle";
+ break;
+ default :
+ ASSERT (FALSE);
+ m_pSub = NULL;
}
m_rtStart = 0;
}
@@ -126,19 +125,20 @@ STDMETHODIMP_(int) CRenderedHdmvSubtitle::GetStreamCount()
STDMETHODIMP CRenderedHdmvSubtitle::GetStreamInfo(int iStream, WCHAR** ppName, LCID* pLCID)
{
- if(iStream != 0) return E_INVALIDARG;
+ if(iStream != 0) {
+ return E_INVALIDARG;
+ }
- if(ppName)
- {
+ if(ppName) {
*ppName = (WCHAR*)CoTaskMemAlloc((m_name.GetLength()+1)*sizeof(WCHAR));
- if(!(*ppName))
+ if(!(*ppName)) {
return E_OUTOFMEMORY;
+ }
wcscpy_s (*ppName, m_name.GetLength()+1, CStringW(m_name));
}
- if(pLCID)
- {
+ if(pLCID) {
*pLCID = m_lcid;
}
diff --git a/src/Subtitles/RenderedHdmvSubtitle.h b/src/Subtitles/RenderedHdmvSubtitle.h
index 5f68b0c8f..56445293a 100644
--- a/src/Subtitles/RenderedHdmvSubtitle.h
+++ b/src/Subtitles/RenderedHdmvSubtitle.h
@@ -33,7 +33,7 @@ class __declspec(uuid("FCA68599-C83E-4ea5-94A3-C2E1B0E326B9"))
CRenderedHdmvSubtitle : public CSubPicProviderImpl, public ISubStream
{
public:
- CRenderedHdmvSubtitle(CCritSec* pLock, SUBTITLE_TYPE nType);
+ CRenderedHdmvSubtitle(CCritSec* pLock, SUBTITLE_TYPE nType, const CString& name, LCID lcid);
~CRenderedHdmvSubtitle(void);
DECLARE_IUNKNOWN
diff --git a/src/Subtitles/SSF.cpp b/src/Subtitles/SSF.cpp
index 4909d4f39..f367dd854 100644
--- a/src/Subtitles/SSF.cpp
+++ b/src/Subtitles/SSF.cpp
@@ -33,213 +33,208 @@
namespace ssf
{
-CRenderer::CRenderer(CCritSec* pLock)
- : CSubPicProviderImpl(pLock)
-{
-}
-
-CRenderer::~CRenderer()
-{
-}
-
-bool CRenderer::Open(CString fn, CString name)
-{
- m_fn.Empty();
- m_name.Empty();
- m_file.Free();
- m_renderer.Free();
-
- if(name.IsEmpty())
+ CRenderer::CRenderer(CCritSec* pLock)
+ : CSubPicProviderImpl(pLock)
{
- CString str = fn;
- str.Replace('\\', '/');
- name = str.Left(str.ReverseFind('.'));
- name = name.Mid(name.ReverseFind('/')+1);
- name = name.Mid(name.ReverseFind('.')+1);
}
- try
+ CRenderer::~CRenderer()
{
- if(Open(FileInputStream(fn), name))
- {
- m_fn = fn;
- return true;
- }
}
- catch(Exception& e)
+
+ bool CRenderer::Open(CString fn, CString name)
{
- UNREFERENCED_PARAMETER(e);
- TRACE(_T("%s\n"), e.ToString());
- }
+ m_fn.Empty();
+ m_name.Empty();
+ m_file.Free();
+ m_renderer.Free();
+
+ if(name.IsEmpty()) {
+ CString str = fn;
+ str.Replace('\\', '/');
+ name = str.Left(str.ReverseFind('.'));
+ name = name.Mid(name.ReverseFind('/')+1);
+ name = name.Mid(name.ReverseFind('.')+1);
+ }
- return false;
-}
+ try {
+ if(Open(FileInputStream(fn), name)) {
+ m_fn = fn;
+ return true;
+ }
+ } catch(Exception& e) {
+ UNREFERENCED_PARAMETER(e);
+ TRACE(_T("%s\n"), e.ToString());
+ }
-bool CRenderer::Open(InputStream& s, CString name)
-{
- m_fn.Empty();
- m_name.Empty();
- m_file.Free();
- m_renderer.Free();
+ return false;
+ }
- try
+ bool CRenderer::Open(InputStream& s, CString name)
{
- m_file.Attach(DNew SubtitleFile());
- m_file->Parse(s);
- m_renderer.Attach(DNew Renderer());
- m_name = name;
- return true;
+ m_fn.Empty();
+ m_name.Empty();
+ m_file.Free();
+ m_renderer.Free();
+
+ try {
+ m_file.Attach(DNew SubtitleFile());
+ m_file->Parse(s);
+ m_renderer.Attach(DNew Renderer());
+ m_name = name;
+ return true;
+ } catch(Exception& e) {
+ UNREFERENCED_PARAMETER(e);
+ TRACE(_T("%s\n"), e.ToString());
+ }
+
+ return false;
}
- catch(Exception& e)
+
+ void CRenderer::Append(REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, LPCWSTR str)
{
- UNREFERENCED_PARAMETER(e);
- TRACE(_T("%s\n"), e.ToString());
+ if(!m_file) {
+ return;
+ }
+
+ try {
+ m_file->Append(ssf::WCharInputStream(str), (float)rtStart / 10000000, (float)rtStop / 10000000);
+ } catch(Exception& e) {
+ UNREFERENCED_PARAMETER(e);
+ TRACE(_T("%s\n"), e.ToString());
+ }
}
- return false;
-}
+ STDMETHODIMP CRenderer::NonDelegatingQueryInterface(REFIID riid, void** ppv)
+ {
+ CheckPointer(ppv, E_POINTER);
+ *ppv = NULL;
+
+ return
+ QI(IPersist)
+ QI(ISubStream)
+ QI(ISubPicProvider)
+ __super::NonDelegatingQueryInterface(riid, ppv);
+ }
-void CRenderer::Append(REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, LPCWSTR str)
-{
- if(!m_file) return;
+ // ISubPicProvider
- try
+ STDMETHODIMP_(POSITION) CRenderer::GetStartPosition(REFERENCE_TIME rt, double fps)
{
- m_file->Append(ssf::WCharInputStream(str), (float)rtStart / 10000000, (float)rtStop / 10000000);
+ size_t k;
+ return m_file && m_file->m_segments.Lookup((float)rt/10000000, k) ? (POSITION)(++k) : NULL;
}
- catch(Exception& e)
+
+ STDMETHODIMP_(POSITION) CRenderer::GetNext(POSITION pos)
{
- UNREFERENCED_PARAMETER(e);
- TRACE(_T("%s\n"), e.ToString());
+ size_t k = (size_t)pos;
+ return m_file && m_file->m_segments.GetSegment(k) ? (POSITION)(++k) : NULL;
}
-}
-STDMETHODIMP CRenderer::NonDelegatingQueryInterface(REFIID riid, void** ppv)
-{
- CheckPointer(ppv, E_POINTER);
- *ppv = NULL;
-
- return
- QI(IPersist)
- QI(ISubStream)
- QI(ISubPicProvider)
- __super::NonDelegatingQueryInterface(riid, ppv);
-}
+ STDMETHODIMP_(REFERENCE_TIME) CRenderer::GetStart(POSITION pos, double fps)
+ {
+ size_t k = (size_t)pos-1;
+ const SubtitleFile::Segment* s = m_file ? m_file->m_segments.GetSegment(k) : NULL;
+ return s ? (REFERENCE_TIME)(s->m_start*10000000) : 0;
+ }
-// ISubPicProvider
+ STDMETHODIMP_(REFERENCE_TIME) CRenderer::GetStop(POSITION pos, double fps)
+ {
+ CheckPointer(m_file, 0);
-STDMETHODIMP_(POSITION) CRenderer::GetStartPosition(REFERENCE_TIME rt, double fps)
-{
- size_t k;
- return m_file && m_file->m_segments.Lookup((float)rt/10000000, k) ? (POSITION)(++k) : NULL;
-}
+ size_t k = (size_t)pos-1;
+ const SubtitleFile::Segment* s = m_file ? m_file->m_segments.GetSegment(k) : NULL;
+ return s ? (REFERENCE_TIME)(s->m_stop*10000000) : 0;
+ }
-STDMETHODIMP_(POSITION) CRenderer::GetNext(POSITION pos)
-{
- size_t k = (size_t)pos;
- return m_file && m_file->m_segments.GetSegment(k) ? (POSITION)(++k) : NULL;
-}
+ STDMETHODIMP_(bool) CRenderer::IsAnimated(POSITION pos)
+ {
+ return true;
+ }
-STDMETHODIMP_(REFERENCE_TIME) CRenderer::GetStart(POSITION pos, double fps)
-{
- size_t k = (size_t)pos-1;
- const SubtitleFile::Segment* s = m_file ? m_file->m_segments.GetSegment(k) : NULL;
- return s ? (REFERENCE_TIME)(s->m_start*10000000) : 0;
-}
+ STDMETHODIMP CRenderer::Render(SubPicDesc& spd, REFERENCE_TIME rt, double fps, RECT& bbox)
+ {
+ CheckPointer(m_file, E_UNEXPECTED);
+ CheckPointer(m_renderer, E_UNEXPECTED);
-STDMETHODIMP_(REFERENCE_TIME) CRenderer::GetStop(POSITION pos, double fps)
-{
- CheckPointer(m_file, 0);
+ if(spd.type != MSP_RGB32) {
+ return E_INVALIDARG;
+ }
- size_t k = (size_t)pos-1;
- const SubtitleFile::Segment* s = m_file ? m_file->m_segments.GetSegment(k) : NULL;
- return s ? (REFERENCE_TIME)(s->m_stop*10000000) : 0;
-}
+ CAutoLock csAutoLock(m_pLock);
-STDMETHODIMP_(bool) CRenderer::IsAnimated(POSITION pos)
-{
- return true;
-}
+ CRect bbox2;
+ bbox2.SetRectEmpty();
-STDMETHODIMP CRenderer::Render(SubPicDesc& spd, REFERENCE_TIME rt, double fps, RECT& bbox)
-{
- CheckPointer(m_file, E_UNEXPECTED);
- CheckPointer(m_renderer, E_UNEXPECTED);
+ CAutoPtrList<Subtitle> subs;
+ m_file->Lookup((float)rt/10000000, subs);
- if(spd.type != MSP_RGB32) return E_INVALIDARG;
+ m_renderer->NextSegment(subs);
- CAutoLock csAutoLock(m_pLock);
+ POSITION pos = subs.GetHeadPosition();
+ while(pos) {
+ const Subtitle* s = subs.GetNext(pos);
+ const RenderedSubtitle* rs = m_renderer->Lookup(s, CSize(spd.w, spd.h), spd.vidrect);
+ if(rs) {
+ bbox2 |= rs->Draw(spd);
+ }
+ }
- CRect bbox2;
- bbox2.SetRectEmpty();
+ bbox = bbox2 & CRect(0, 0, spd.w, spd.h);
- CAutoPtrList<Subtitle> subs;
- m_file->Lookup((float)rt/10000000, subs);
+ return S_OK;
+ }
- m_renderer->NextSegment(subs);
+ // IPersist
- POSITION pos = subs.GetHeadPosition();
- while(pos)
+ STDMETHODIMP CRenderer::GetClassID(CLSID* pClassID)
{
- const Subtitle* s = subs.GetNext(pos);
- const RenderedSubtitle* rs = m_renderer->Lookup(s, CSize(spd.w, spd.h), spd.vidrect);
- if(rs) bbox2 |= rs->Draw(spd);
+ return pClassID ? *pClassID = __uuidof(this), S_OK : E_POINTER;
}
- bbox = bbox2 & CRect(0, 0, spd.w, spd.h);
+ // ISubStream
- return S_OK;
-}
+ STDMETHODIMP_(int) CRenderer::GetStreamCount()
+ {
+ return 1;
+ }
-// IPersist
+ STDMETHODIMP CRenderer::GetStreamInfo(int iStream, WCHAR** ppName, LCID* pLCID)
+ {
+ if(iStream != 0) {
+ return E_INVALIDARG;
+ }
-STDMETHODIMP CRenderer::GetClassID(CLSID* pClassID)
-{
- return pClassID ? *pClassID = __uuidof(this), S_OK : E_POINTER;
-}
+ if(ppName) {
+ *ppName = (WCHAR*)CoTaskMemAlloc((m_name.GetLength()+1)*sizeof(WCHAR));
+ if(!(*ppName)) {
+ return E_OUTOFMEMORY;
+ }
-// ISubStream
+ wcscpy(*ppName, CStringW(m_name));
+ }
-STDMETHODIMP_(int) CRenderer::GetStreamCount()
-{
- return 1;
-}
+ if(pLCID) {
+ *pLCID = 0; // TODO
+ }
-STDMETHODIMP CRenderer::GetStreamInfo(int iStream, WCHAR** ppName, LCID* pLCID)
-{
- if(iStream != 0) return E_INVALIDARG;
+ return S_OK;
+ }
- if(ppName)
+ STDMETHODIMP_(int) CRenderer::GetStream()
{
- *ppName = (WCHAR*)CoTaskMemAlloc((m_name.GetLength()+1)*sizeof(WCHAR));
- if(!(*ppName))
- return E_OUTOFMEMORY;
-
- wcscpy(*ppName, CStringW(m_name));
+ return 0;
}
- if(pLCID)
+ STDMETHODIMP CRenderer::SetStream(int iStream)
{
- *pLCID = 0; // TODO
+ return iStream == 0 ? S_OK : E_FAIL;
}
- return S_OK;
-}
-
-STDMETHODIMP_(int) CRenderer::GetStream()
-{
- return 0;
-}
-
-STDMETHODIMP CRenderer::SetStream(int iStream)
-{
- return iStream == 0 ? S_OK : E_FAIL;
-}
-
-STDMETHODIMP CRenderer::Reload()
-{
- CAutoLock csAutoLock(m_pLock);
+ STDMETHODIMP CRenderer::Reload()
+ {
+ CAutoLock csAutoLock(m_pLock);
- return !m_fn.IsEmpty() && Open(m_fn, m_name) ? S_OK : E_FAIL;
-}
+ return !m_fn.IsEmpty() && Open(m_fn, m_name) ? S_OK : E_FAIL;
+ }
}
diff --git a/src/Subtitles/SSF.h b/src/Subtitles/SSF.h
index 8aa5e0f79..e4f19a1bf 100644
--- a/src/Subtitles/SSF.h
+++ b/src/Subtitles/SSF.h
@@ -31,42 +31,42 @@
namespace ssf
{
-class __declspec(uuid("E0593632-0AB7-47CA-8BE1-E9D2A6A4825E"))
- CRenderer : public CSubPicProviderImpl, public ISubStream
-{
- CString m_fn, m_name;
- CAutoPtr<SubtitleFile> m_file;
- CAutoPtr<Renderer> m_renderer;
+ class __declspec(uuid("E0593632-0AB7-47CA-8BE1-E9D2A6A4825E"))
+ CRenderer : public CSubPicProviderImpl, public ISubStream
+ {
+ CString m_fn, m_name;
+ CAutoPtr<SubtitleFile> m_file;
+ CAutoPtr<Renderer> m_renderer;
-public:
- CRenderer(CCritSec* pLock);
- virtual ~CRenderer();
+ public:
+ CRenderer(CCritSec* pLock);
+ virtual ~CRenderer();
- bool Open(CString fn, CString name = _T(""));
- bool Open(InputStream& s, CString name);
+ bool Open(CString fn, CString name = _T(""));
+ bool Open(InputStream& s, CString name);
- void Append(REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, LPCWSTR str);
+ void Append(REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, LPCWSTR str);
- 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();
+ };
} \ No newline at end of file
diff --git a/src/Subtitles/STS.cpp b/src/Subtitles/STS.cpp
index 9658f6727..3cec7288f 100644
--- a/src/Subtitles/STS.cpp
+++ b/src/Subtitles/STS.cpp
@@ -33,8 +33,7 @@
struct htmlcolor {
TCHAR* name;
DWORD color;
-} hmtlcolors[] =
-{
+} hmtlcolors[] = {
{_T("white"), 0xffffff},
{_T("whitesmoke"), 0xf5f5f5},
{_T("ghostwhite"), 0xf8f8ff},
@@ -183,16 +182,16 @@ struct htmlcolor {
CHtmlColorMap::CHtmlColorMap()
{
- for(ptrdiff_t i = 0; i < countof(hmtlcolors); i++)
+ for(ptrdiff_t i = 0; i < countof(hmtlcolors); i++) {
SetAt(hmtlcolors[i].name, hmtlcolors[i].color);
+ }
}
CHtmlColorMap g_colors;
//
-BYTE CharSetList[] =
-{
+BYTE CharSetList[] = {
ANSI_CHARSET,
DEFAULT_CHARSET,
SYMBOL_CHARSET,
@@ -215,8 +214,7 @@ BYTE CharSetList[] =
BALTIC_CHARSET
};
-TCHAR* CharSetNames[] =
-{
+TCHAR* CharSetNames[] = {
_T("ANSI"),
_T("DEFAULT"),
_T("SYMBOL"),
@@ -252,32 +250,39 @@ static DWORD CharSetToCodePage(DWORD dwCharSet)
int FindChar(CStringW str, WCHAR c, int pos, bool fUnicode, int CharSet)
{
- if(fUnicode) return(str.Find(c, pos));
+ if(fUnicode) {
+ return(str.Find(c, pos));
+ }
int fStyleMod = 0;
DWORD cp = CharSetToCodePage(CharSet);
int OrgCharSet = CharSet;
- for(size_t i = 0, j = str.GetLength(), k; i < j; i++)
- {
+ for(size_t 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(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")
- {
+ 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;
+ for(k = i+1; _istdigit(str[k]); k++) {
+ CharSet = CharSet*10 + (str[k] - '0');
+ }
+ if(k == i+1) {
+ CharSet = OrgCharSet;
+ }
cp = CharSetToCodePage(CharSet);
}
@@ -300,19 +305,16 @@ static CStringW ToMBCS(CStringW str, DWORD CharSet)
DWORD cp = CharSetToCodePage(CharSet);
- for(ptrdiff_t i = 0, j = str.GetLength(); i < j; i++)
- {
+ for(ptrdiff_t 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++)
+ 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
- {
+ }
+ } else {
ret += '?';
}
}
@@ -326,29 +328,27 @@ static CStringW UnicodeSSAToMBCS(CStringW str, DWORD CharSet)
int OrgCharSet = CharSet;
- for(ptrdiff_t j = 0; j < str.GetLength(); )
- {
+ for(ptrdiff_t j = 0; j < str.GetLength(); ) {
j = str.Find('{', j);
- if(j >= 0)
- {
+ if(j >= 0) {
ret += ToMBCS(str.Left(j), CharSet);
str = str.Mid(j);
j = str.Find('}');
- if(j < 0)
- {
+ if(j < 0) {
ret += ToMBCS(str, CharSet);
break;
- }
- else
- {
+ } else {
int k = str.Find(L"\\fe");
- if(k >= 0 && k < j)
- {
+ 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;
+ for(; _istdigit(str[l]); l++) {
+ CharSet = CharSet*10 + (str[l] - '0');
+ }
+ if(l == k+3) {
+ CharSet = OrgCharSet;
+ }
}
j++;
@@ -357,9 +357,7 @@ static CStringW UnicodeSSAToMBCS(CStringW str, DWORD CharSet)
str = str.Mid(j);
j = 0;
}
- }
- else
- {
+ } else {
ret += ToMBCS(str, CharSet);
break;
}
@@ -374,26 +372,21 @@ static CStringW ToUnicode(CStringW str, DWORD CharSet)
DWORD cp = CharSetToCodePage(CharSet);
- for(ptrdiff_t i = 0, j = str.GetLength(); i < j; i++)
- {
+ for(ptrdiff_t i = 0, j = str.GetLength(); i < j; i++) {
WCHAR wc = str.GetAt(i);
char c = wc&0xff;
- if(IsDBCSLeadByteEx(cp, (BYTE)wc))
- {
+ if(IsDBCSLeadByteEx(cp, (BYTE)wc)) {
i++;
- if(i < j)
- {
+ if(i < j) {
char cc[2];
cc[0] = c;
cc[1] = (char)str.GetAt(i);
MultiByteToWideChar(cp, 0, cc, 2, &wc, 1);
}
- }
- else
- {
+ } else {
MultiByteToWideChar(cp, 0, &c, 1, &wc, 1);
}
@@ -409,31 +402,29 @@ static CStringW MBCSSSAToUnicode(CStringW str, int CharSet)
int OrgCharSet = CharSet;
- for(ptrdiff_t j = 0; j < str.GetLength(); )
- {
+ for(ptrdiff_t j = 0; j < str.GetLength(); ) {
j = FindChar(str, '{', 0, false, CharSet);
- if(j >= 0)
- {
+ if(j >= 0) {
ret += ToUnicode(str.Left(j), CharSet);
str = str.Mid(j);
j = FindChar(str, '}', 0, false, CharSet);
- if(j < 0)
- {
+ if(j < 0) {
ret += ToUnicode(str, CharSet);
break;
- }
- else
- {
+ } else {
int k = str.Find(L"\\fe");
- if(k >= 0 && k < j)
- {
+ 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;
+ for(; _istdigit(str[l]); l++) {
+ CharSet = CharSet*10 + (str[l] - '0');
+ }
+ if(l == k+3) {
+ CharSet = OrgCharSet;
+ }
}
j++;
@@ -442,9 +433,7 @@ static CStringW MBCSSSAToUnicode(CStringW str, int CharSet)
str = str.Mid(j);
j = 0;
}
- }
- else
- {
+ } else {
ret += ToUnicode(str, CharSet);
break;
}
@@ -458,10 +447,13 @@ CStringW RemoveSSATags(CStringW str, bool fUnicode, int CharSet)
str.Replace (L"{\\i1}", L"<i>");
str.Replace (L"{\\i}", L"</i>");
- for(ptrdiff_t i = 0, j; i < str.GetLength(); )
- {
- if((i = FindChar(str, '{', i, fUnicode, CharSet)) < 0) break;
- if((j = FindChar(str, '}', i, fUnicode, CharSet)) < 0) break;
+ for(ptrdiff_t 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);
}
@@ -491,10 +483,11 @@ static bool OpenSubRipper(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet
int num = 0;
CStringW buff;
- while(file->ReadString(buff))
- {
+ while(file->ReadString(buff)) {
buff.Trim();
- if(buff.IsEmpty()) continue;
+ if(buff.IsEmpty()) {
+ continue;
+ }
WCHAR sep;
int hh1, mm1, ss1, ms1, hh2, mm2, ss2, ms2;
@@ -502,25 +495,22 @@ static bool OpenSubRipper(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet
&hh1, &sep, &mm1, &sep, &ss1, &sep, &ms1,
&hh2, &sep, &mm2, &sep, &ss2, &sep, &ms2);
- if(c == 1) // numbering
- {
+ if(c == 1) { // numbering
num = hh1;
- }
- else if(c == 14) // time info
- {
+ } else if(c == 14) { // time info
CStringW str, tmp;
bool fFoundEmpty = false;
- while(file->ReadString(tmp))
- {
+ while(file->ReadString(tmp)) {
tmp.Trim();
- if(tmp.IsEmpty()) fFoundEmpty = true;
+ if(tmp.IsEmpty()) {
+ fFoundEmpty = true;
+ }
int num2;
WCHAR c;
- if(swscanf(tmp, L"%d%c", &num2, &c) == 1 && fFoundEmpty)
- {
+ if(swscanf(tmp, L"%d%c", &num2, &c) == 1 && fFoundEmpty) {
num = num2;
break;
}
@@ -533,9 +523,7 @@ static bool OpenSubRipper(CTextFile* file, CSimpleTextSubtitle& ret, int 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
- {
+ } else if(c != EOF) { // might be another format
return(false);
}
}
@@ -546,30 +534,29 @@ static bool OpenSubRipper(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet
static bool OpenOldSubRipper(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet)
{
CStringW buff;
- while(file->ReadString(buff))
- {
+ while(file->ReadString(buff)) {
buff.Trim();
- if(buff.IsEmpty()) continue;
+ if(buff.IsEmpty()) {
+ continue;
+ }
- for(ptrdiff_t i = 0; i < buff.GetLength(); i++)
- {
- if((i = FindChar(buff, '|', i, file->IsUnicode(), CharSet)) < 0) break;
+ for(ptrdiff_t 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(buff, L"{%d:%d:%d}{%d:%d:%d}", &hh1, &mm1, &ss1, &hh2, &mm2, &ss2);
- if(c == 6)
- {
+ 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
- {
+ } else if(c != EOF) { // might be another format
return(false);
}
}
@@ -587,17 +574,18 @@ static bool OpenSubViewer(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet
bool fUnderline = false;
CStringW buff;
- while(file->ReadString(buff))
- {
+ while(file->ReadString(buff)) {
buff.Trim();
- if(buff.IsEmpty()) continue;
+ if(buff.IsEmpty()) {
+ continue;
+ }
- if(buff[0] == '[')
- {
- for(size_t i = 0; i < buff.GetLength() && buff[i]== '['; )
- {
+ if(buff[0] == '[') {
+ for(size_t i = 0; i < buff.GetLength() && buff[i]== '['; ) {
int j = buff.Find(']', ++i);
- if(j < i) break;
+ if(j < i) {
+ break;
+ }
CStringW tag = buff.Mid(i,j-i);
tag.Trim();
@@ -606,27 +594,25 @@ static bool OpenSubViewer(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet
i += j-i;
j = buff.Find('[', ++i);
- if(j < 0) j = buff.GetLength();
+ if(j < 0) {
+ j = buff.GetLength();
+ }
CStringW param = buff.Mid(i,j-i);
param.Trim(L" \\t,");
i = j;
- if(tag == L"font")
+ if(tag == L"font") {
font = def.fontName.CompareNoCase(WToT(param)) ? param : L"";
- else if(tag == L"colf")
+ } else if(tag == L"colf") {
color = def.colors[0] != (DWORD)wcstol(((LPCWSTR)param)+2, 0, 16) ? param : L"";
- else if(tag == L"size")
+ } 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)
- {
+ } else if(tag == L"style") {
+ if(param.Find(L"no") >= 0) {
fBold = fItalic = fStriked = fUnderline = false;
- }
- else
- {
+ } 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;
@@ -643,30 +629,43 @@ static bool OpenSubViewer(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet
int c = swscanf(buff, L"%d:%d:%d%c%d,%d:%d:%d%c%d\n",
&hh1, &mm1, &ss1, &sep, &hs1, &hh2, &mm2, &ss2, &sep, &hs2);
- if(c == 10)
- {
+ 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;
+ 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
- {
+ } else if(c != EOF) { // might be another format
return(false);
}
}
@@ -677,49 +676,56 @@ static bool OpenSubViewer(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet
static STSStyle* GetMicroDVDStyle(CString str, int CharSet)
{
STSStyle* ret = DNew STSStyle();
- if(!ret) return(NULL);
+ if(!ret) {
+ return(NULL);
+ }
- for(ptrdiff_t i = 0, len = str.GetLength(); i < len; i++)
- {
+ for(ptrdiff_t i = 0, len = str.GetLength(); i < len; i++) {
int j = str.Find('{', i);
- if(j < 0) j = len;
+ if(j < 0) {
+ j = len;
+ }
- if(j >= len) break;
+ if(j >= len) {
+ break;
+ }
int k = str.Find('}', j);
- if(k < 0) k = len;
+ if(k < 0) {
+ k = len;
+ }
CString code = str.Mid(j, k-j);
- if(code.GetLength() > 2) code.SetAt(1, (TCHAR)towlower(code[1]));
+ if(code.GetLength() > 2) {
+ code.SetAt(1, (TCHAR)towlower(code[1]));
+ }
- if(!_tcsnicmp(code, _T("{c:$"), 4))
- {
+ if(!_tcsnicmp(code, _T("{c:$"), 4)) {
_stscanf(code, _T("{c:$%x"), &ret->colors[0]);
- }
- else if(!_tcsnicmp(code, _T("{f:"), 3))
- {
+ } else if(!_tcsnicmp(code, _T("{f:"), 3)) {
ret->fontName = code.Mid(3);
- }
- else if(!_tcsnicmp(code, _T("{s:"), 3))
- {
+ } else if(!_tcsnicmp(code, _T("{s:"), 3)) {
float f;
- if(1 == _stscanf(code, _T("{s:%f"), &f))
+ if(1 == _stscanf(code, _T("{s:%f"), &f)) {
ret->fontSize = f;
- }
- else if(!_tcsnicmp(code, _T("{h:"), 3))
- {
+ }
+ } else if(!_tcsnicmp(code, _T("{h:"), 3)) {
_stscanf(code, _T("{h:%d"), &ret->charSet);
- }
- else if(!_tcsnicmp(code, _T("{y:"), 3))
- {
+ } 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))
- {
+ 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(code, _T("{p:%d"), &p);
ret->scrAlignment = (p == 0) ? 8 : 2;
@@ -740,29 +746,34 @@ static CStringW MicroDVD2SSA(CStringW str, bool fUnicode, int CharSet)
int fRestoreLen = 8;
memset(fRestore, 0, sizeof(bool)*fRestoreLen);
- for(ptrdiff_t pos = 0, eol; pos < str.GetLength(); pos++)
- {
- if((eol = FindChar(str, '|', pos, fUnicode, CharSet)) < 0) eol = str.GetLength();
+ for(ptrdiff_t 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(ptrdiff_t i = 0, j, k, len = line.GetLength(); i < len; i++)
- {
- if((j = FindChar(line, '{', i, fUnicode, CharSet)) < 0) j = str.GetLength();
+ for(ptrdiff_t 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(j >= len) {
+ break;
+ }
- if((k = FindChar(line, '}', j, fUnicode, CharSet)) < 0) k = len;
+ if((k = FindChar(line, '}', j, fUnicode, CharSet)) < 0) {
+ k = len;
+ }
{
CStringW code = line.Mid(j, k-j);
- if(!wcsnicmp(code, L"{c:$", 4))
- {
+ if(!wcsnicmp(code, L"{c:$", 4)) {
fRestore[COLOR] = (iswupper(code[1]) == 0);
code.MakeLower();
@@ -770,16 +781,12 @@ static CStringW MicroDVD2SSA(CStringW str, bool fUnicode, int CharSet)
swscanf(code, L"{c:$%x", &color);
code.Format(L"{\\c&H%x&}", color);
ret += code;
- }
- else if(!wcsnicmp(code, L"{f:", 3))
- {
+ } 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))
- {
+ } else if(!wcsnicmp(code, L"{s:", 3)) {
fRestore[FONTSIZE] = (iswupper(code[1]) == 0);
code.MakeLower();
@@ -787,9 +794,7 @@ static CStringW MicroDVD2SSA(CStringW str, bool fUnicode, int CharSet)
swscanf(code, L"{s:%f", &size);
code.Format(L"{\\fs%f}", size);
ret += code;
- }
- else if(!wcsnicmp(code, L"{h:", 3))
- {
+ } else if(!wcsnicmp(code, L"{h:", 3)) {
fRestore[COLOR] = (_istupper(code[1]) == 0);
code.MakeLower();
@@ -797,9 +802,7 @@ static CStringW MicroDVD2SSA(CStringW str, bool fUnicode, int CharSet)
swscanf(code, L"{h:%d", &CharSet);
code.Format(L"{\\fe%d}", CharSet);
ret += code;
- }
- else if(!wcsnicmp(code, L"{y:", 3))
- {
+ } else if(!wcsnicmp(code, L"{y:", 3)) {
bool f = (_istupper(code[1]) == 0);
code.MakeLower();
@@ -822,9 +825,7 @@ static CStringW MicroDVD2SSA(CStringW str, bool fUnicode, int CharSet)
fRestore[STRIKEOUT] = f;
}
ret += '}';
- }
- else if(!wcsnicmp(code, L"{o:", 3))
- {
+ } else if(!wcsnicmp(code, L"{o:", 3)) {
code.MakeLower();
int x, y;
@@ -832,47 +833,47 @@ static CStringW MicroDVD2SSA(CStringW str, bool fUnicode, int CharSet)
swscanf(code, L"{o:%d%c%d", &x, &c, &y);
code.Format(L"{\\move(%d,%d,0,0,0,0)}", x, y);
ret += code;
+ } else {
+ ret += code;
}
- else ret += code;
}
i = k;
}
- if(pos >= str.GetLength()) break;
+ 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;
+ 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;
}
}
}
@@ -892,32 +893,28 @@ static bool OpenMicroDVD(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet)
CString style(_T("Default"));
CStringW buff;
- while(file->ReadString(buff))
- {
+ while(file->ReadString(buff)) {
buff.Trim();
- if(buff.IsEmpty()) continue;
+ if(buff.IsEmpty()) {
+ continue;
+ }
int start, end;
int c = swscanf(buff, L"{%d}{%d}", &start, &end);
- if(c != 2)
- {
+ if(c != 2) {
c = swscanf(buff, L"{%d}{}", &start) + 1;
end = start + 60;
fCheck = true;
}
- if(c != 2)
- {
+ 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))
- {
+ 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())
- {
+ if(style.GetLength()) {
CString str = style.Mid(1);
str.MakeLower();
style = style.Left(1) + str;
@@ -929,10 +926,8 @@ static bool OpenMicroDVD(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet)
}
}
- if(c == 2)
- {
- if(fCheck2 && ret.GetCount())
- {
+ if(c == 2) {
+ if(fCheck2 && ret.GetCount()) {
STSEntry& stse = ret[ret.GetCount()-1];
stse.end = min(stse.end, start);
fCheck2 = false;
@@ -944,14 +939,11 @@ static bool OpenMicroDVD(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet)
start, end,
style);
- if(fCheck)
- {
+ if(fCheck) {
fCheck = false;
fCheck2 = true;
}
- }
- else if(c != EOF) // might be another format
- {
+ } else if(c != EOF) { // might be another format
return(false);
}
}
@@ -966,18 +958,17 @@ static void ReplaceNoCase(CStringW& str, CStringW from, CStringW to)
int i, j, k;
- for(i = 0, j = str.GetLength(); i < j; )
- {
- if((k = lstr.Find(from, i)) >= 0)
- {
+ 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;
}
- else break;
}
}
@@ -996,20 +987,22 @@ static CStringW SMI2SSA(CStringW str, int CharSet)
// maven@maven.de
// now parse line
- for(ptrdiff_t i = 0, j = str.GetLength(); i < j; )
- {
+ for(ptrdiff_t i = 0, j = str.GetLength(); i < j; ) {
int k;
- if((k = lstr.Find('<', i)) < 0) break;
+ if((k = lstr.Find('<', i)) < 0) {
+ break;
+ }
int chars_inserted = 0;
int l = 1;
- for(; k+l < j && lstr[k+l] != '>'; l++);
+ for(; k+l < j && lstr[k+l] != '>'; l++) {
+ ;
+ }
l++;
-// Modified by Cookie Monster
- if (lstr.Find(L"<font ", k) == k)
- {
+ // Modified by Cookie Monster
+ if (lstr.Find(L"<font ", k) == k) {
CStringW args = lstr.Mid(k+6, l-6); // delete "<font "
CStringW arg ;
@@ -1018,82 +1011,82 @@ static CStringW SMI2SSA(CStringW str, int CharSet)
arg.TrimLeft();
arg.TrimRight(L" >");
- for (;;)
- {
+ for (;;) {
args.TrimLeft();
arg = args.SpanExcluding(L" \t>");
args = args.Mid(arg.GetLength());
- if(arg.IsEmpty())
+ if(arg.IsEmpty()) {
break;
- if (arg.Find(L"color=") == 0 )
- {
+ }
+ if (arg.Find(L"color=") == 0 ) {
DWORD color;
arg = arg.Mid(6); // delete "color="
- if ( arg.IsEmpty())
+ if ( arg.IsEmpty()) {
continue;
+ }
DWORD val;
- if(g_colors.Lookup(CString(arg), val))
+ if(g_colors.Lookup(CString(arg), val)) {
color = (DWORD)val;
- else if((color = wcstol(arg, NULL, 16) ) == 0)
- color = 0x00ffffff; // default is white
+ } 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;
- }
-*/
+ /*
+ 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 * " + #
+ // 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" >");
+ arg.Remove('\"');
+ arg.Remove('#');
+ arg.TrimLeft(); arg.TrimRight(L" >");
- if(arg.GetLength() > 0)
- {
- DWORD color;
+ 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);
+ 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)
- {
+ 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;
@@ -1116,12 +1109,15 @@ static bool OpenSami(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet)
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);
@@ -1129,36 +1125,34 @@ static bool OpenSami(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet)
int start_time = 0;
- while(file->ReadString(buff))
- {
+ while(file->ReadString(buff)) {
buff.Trim();
- if(buff.IsEmpty()) continue;
+ if(buff.IsEmpty()) {
+ continue;
+ }
CStringW ubuff = buff;
ubuff.MakeUpper();
- if(ubuff.Find(L"<!--") >= 0 || ubuff.Find(L"<TITLE>") >= 0)
+ if(ubuff.Find(L"<!--") >= 0 || ubuff.Find(L"<TITLE>") >= 0) {
fComment = true;
+ }
- if(!fComment)
- {
+ if(!fComment) {
int i;
- if((i = ubuff.Find(L"<SYNC START=")) >= 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]))
- {
+ 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;
}
- else break;
}
ret.Add(
@@ -1173,8 +1167,9 @@ static bool OpenSami(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet)
caption += buff;
}
- if(ubuff.Find(L"-->") >= 0 || ubuff.Find(L"</TITLE>") >= 0)
+ if(ubuff.Find(L"-->") >= 0 || ubuff.Find(L"</TITLE>") >= 0) {
fComment = false;
+ }
}
ret.Add(
@@ -1188,30 +1183,29 @@ static bool OpenSami(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet)
static bool OpenVPlayer(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet)
{
CStringW buff;
- while(file->ReadString(buff))
- {
+ while(file->ReadString(buff)) {
buff.Trim();
- if(buff.IsEmpty()) continue;
+ if(buff.IsEmpty()) {
+ continue;
+ }
- for(ptrdiff_t i = 0; i < buff.GetLength(); i++)
- {
- if((i = FindChar(buff, '|', i, file->IsUnicode(), CharSet)) < 0) break;
+ for(ptrdiff_t 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(buff, L"%d:%d:%d:", &hh, &mm, &ss);
- if(c == 3)
- {
+ 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
- {
+ } else if(c != EOF) { // might be another format
return(false);
}
}
@@ -1224,14 +1218,17 @@ CStringW GetStr(CStringW& buff, char sep = ',') //throw(...)
buff.TrimLeft();
int pos = buff.Find(sep);
- if(pos < 0)
- {
+ if(pos < 0) {
pos = buff.GetLength();
- if(pos < 1) throw 1;
+ if(pos < 1) {
+ throw 1;
+ }
}
CStringW ret = buff.Left(pos);
- if(pos < buff.GetLength()) buff = buff.Mid(pos+1);
+ if(pos < buff.GetLength()) {
+ buff = buff.Mid(pos+1);
+ }
return(ret);
}
@@ -1248,7 +1245,9 @@ int GetInt(CStringW& buff, char sep = ',') //throw(...)
: L"%d";
int ret;
- if(swscanf(str, fmtstr, &ret) != 1) throw 1;
+ if(swscanf(str, fmtstr, &ret) != 1) {
+ throw 1;
+ }
return(ret);
}
@@ -1261,7 +1260,9 @@ double GetFloat(CStringW& buff, char sep = ',') //throw(...)
str.MakeLower();
float ret;
- if(swscanf(str, L"%f", &ret) != 1) throw 1;
+ if(swscanf(str, L"%f", &ret) != 1) {
+ throw 1;
+ }
return((double)ret);
}
@@ -1271,15 +1272,17 @@ static bool LoadFont(CString& font)
int len = font.GetLength();
CAutoVectorPtr<BYTE> pData;
- if(len == 0 || (len&3) == 1 || !pData.Allocate(len))
+ 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;
+ 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)
- {
+ 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);
@@ -1287,23 +1290,18 @@ static bool LoadFont(CString& font)
int datalen = (len&~3)*3/4;
- if((len&3) == 2)
- {
+ if((len&3) == 2) {
pData[datalen++] = ((pData[(len&~3)+0]&63)<<2)|((pData[(len&~3)+1]>>4)&3);
- }
- else if((len&3) == 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;
- if(HMODULE hModule = LoadLibrary(_T("GDI32.DLL")))
- {
+ 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"))
- {
+ if(PAddFontMemResourceEx f = (PAddFontMemResourceEx)GetProcAddress(hModule, "AddFontMemResourceEx")) {
DWORD cFonts;
hFont = f(pData, datalen, NULL, &cFonts);
}
@@ -1311,24 +1309,22 @@ static bool LoadFont(CString& font)
FreeLibrary(hModule);
}
- if(hFont == INVALID_HANDLE_VALUE)
- {
+ 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++)
+ 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);
CFileStatus fs;
- if(!CFileGetStatus(fn, fs))
- {
+ if(!CFileGetStatus(fn, fs)) {
CFile f;
- if(f.Open(fn, CFile::modeCreate|CFile::modeWrite|CFile::typeBinary|CFile::shareDenyNone))
- {
+ if(f.Open(fn, CFile::modeCreate|CFile::modeWrite|CFile::typeBinary|CFile::shareDenyNone)) {
f.Write(pData, datalen);
f.Close();
}
@@ -1343,21 +1339,32 @@ static bool LoadFont(CString& font)
static bool LoadUUEFont(CTextFile* file)
{
CString s, font;
- while(file->ReadString(s))
- {
+ 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)
- {
+ 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;
@@ -1366,8 +1373,9 @@ static bool LoadUUEFont(CTextFile* file)
font += s;
}
- if(!font.IsEmpty())
+ if(!font.IsEmpty()) {
LoadFont(font);
+ }
return(true);
}
@@ -1378,15 +1386,17 @@ bool CSimpleTextSubtitle::LoadEfile(CString& img, CString m_fn)
int len = img.GetLength();
CAutoVectorPtr<BYTE> pData;
- if(len == 0 || (len&3) == 1 || !pData.Allocate(len))
+ if(len == 0 || (len&3) == 1 || !pData.Allocate(len)) {
return(false);
+ }
const TCHAR* s = img;
const TCHAR* e = s + len;
- for(BYTE* p = pData; s < e; s++, p++) *p = *s - 33;
+ 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)
- {
+ 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);
@@ -1394,20 +1404,16 @@ bool CSimpleTextSubtitle::LoadEfile(CString& img, CString m_fn)
int datalen = (len&~3)*3/4;
- if((len&3) == 2)
- {
+ if((len&3) == 2) {
pData[datalen++] = ((pData[(len&~3)+0]&63)<<2)|((pData[(len&~3)+1]>>4)&3);
- }
- else if((len&3) == 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);
}
// load png image
MOD_PNGIMAGE t_temp;
- if(t_temp.initImage(pData.m_p,m_fn)) // save path
- {
+ if(t_temp.initImage(pData.m_p,m_fn)) { // save path
mod_images.Add(t_temp);
}
return(true);
@@ -1417,22 +1423,33 @@ bool CSimpleTextSubtitle::LoadEfile(CString& img, CString m_fn)
bool CSimpleTextSubtitle::LoadUUEFile(CTextFile* file, CString m_fn)
{
CString s, img;
- while(file->ReadString(s))
- {
+ 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.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;
+ }
}
// next file
- if(s.Find(_T("filename:")) == 0)
- {
+ if(s.Find(_T("filename:")) == 0) {
LoadEfile(img, m_fn);
m_fn = s.Mid(10);
img.Empty();
@@ -1442,8 +1459,9 @@ bool CSimpleTextSubtitle::LoadUUEFile(CTextFile* file, CString m_fn)
img += s;
}
- if(!img.IsEmpty())
+ if(!img.IsEmpty()) {
LoadEfile(img, m_fn);
+ }
return(true);
}
@@ -1456,157 +1474,163 @@ static bool OpenSubStationAlpha(CTextFile* file, CSimpleTextSubtitle& ret, int C
int version = 3, sver = 3;
CStringW buff;
- while(file->ReadString(buff))
- {
+ while(file->ReadString(buff)) {
buff.Trim();
- if(buff.IsEmpty() || buff.GetAt(0) == ';') continue;
+ if(buff.IsEmpty() || buff.GetAt(0) == ';') {
+ continue;
+ }
CStringW entry;
-// try {
- entry = GetStr(buff, ':');
-// }
-// catch(...) {continue;}
+ // try {
+ entry = GetStr(buff, ':');
+ // }
+ // catch(...) {continue;}
entry.MakeLower();
- if(entry == L"[script info]")
- {
+ if(entry == L"[script info]") {
fRet = true;
- }
- else if(entry == L"playresx")
- {
- try
- {
+ } else if(entry == L"playresx") {
+ try {
ret.m_dstScreenSize.cx = GetInt(buff);
- }
- catch(...)
- {
+ } catch(...) {
ret.m_dstScreenSize = CSize(0, 0);
return(false);
}
- if(ret.m_dstScreenSize.cy <= 0)
- {
+ 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
- {
+ } else if(entry == L"playresy") {
+ try {
ret.m_dstScreenSize.cy = GetInt(buff);
- }
- catch(...)
- {
+ } catch(...) {
ret.m_dstScreenSize = CSize(0, 0);
return(false);
}
- if(ret.m_dstScreenSize.cx <= 0)
- {
+ 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
- {
+ } else if(entry == L"wrapstyle") {
+ try {
ret.m_defaultWrapStyle = GetInt(buff);
- }
- catch(...)
- {
+ } 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")
- {
+ } 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")
- {
+ } else if(entry == L"scaledborderandshadow") {
buff = GetStr(buff);
buff.MakeLower();
ret.m_fScaledBAS = buff.Find(L"yes") >= 0;
- }
- else if(entry == L"[v4 styles]")
- {
+ } else if(entry == L"[v4 styles]") {
fRet = true;
sver = 4;
- }
- else if(entry == L"[v4+ styles]")
- {
+ } else if(entry == L"[v4+ styles]") {
fRet = true;
sver = 5;
- }
- else if(entry == L"[v4++ styles]")
- {
+ } else if(entry == L"[v4++ styles]") {
fRet = true;
sver = 6;
- }
- else if(entry == L"style")
- {
+ } else if(entry == L"style") {
STSStyle* style = DNew STSStyle;
- if(!style) return(false);
+ if(!style) {
+ return(false);
+ }
- try
- {
+ try {
CString StyleName;
int alpha = 0;
StyleName = WToT(GetStr(buff));
style->fontName = WToT(GetStr(buff));
style->fontSize = GetFloat(buff);
- for(ptrdiff_t i = 0; i < 4; i++) style->colors[i] = (COLORREF)GetInt(buff);
+ for(ptrdiff_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);
+ 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);
+ 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 >= 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(ptrdiff_t i = 0; i < 3; i++) style->alpha[i] = alpha;
+ 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(ptrdiff_t i = 0; i < 3; i++) {
+ style->alpha[i] = alpha;
+ }
style->alpha[3] = 0x80;
}
- if(sver >= 5) for(ptrdiff_t i = 0; i < 4; i++)
- {
+ if(sver >= 5) for(ptrdiff_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);
+ if(sver >= 5) {
+ style->fontScaleX = max(style->fontScaleX, 0);
+ }
+ if(sver >= 5) {
+ style->fontScaleY = max(style->fontScaleY, 0);
+ }
#ifndef _VSMOD // patch f002. negative fontspacing at style
- if(sver >= 5) style->fontSpacing = max(style->fontSpacing, 0);
+ if(sver >= 5) {
+ style->fontSpacing = max(style->fontSpacing, 0);
+ }
#endif
style->fontAngleX = style->fontAngleY = 0;
style->borderStyle = style->borderStyle == 1 ? 0 : style->borderStyle == 3 ? 1 : 0;
@@ -1621,31 +1645,25 @@ static bool OpenSubStationAlpha(CTextFile* file, CSimpleTextSubtitle& ret, int C
StyleName.TrimLeft('*');
ret.AddStyle(StyleName, style);
- }
- catch(...)
- {
+ } catch(...) {
delete style;
return(false);
}
- }
- else if(entry == L"[events]")
- {
+ } else if(entry == L"[events]") {
fRet = true;
- }
- else if(entry == _T("dialogue"))
- {
- try
- {
+ } 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)
- {
+ if(version <= 4) {
GetStr(buff, '='); /* Marked = */
GetInt(buff);
}
- if(version >= 5)layer = GetInt(buff);
+ if(version >= 5) {
+ layer = GetInt(buff);
+ }
hh1 = GetInt(buff, ':');
mm1 = GetInt(buff, ':');
ss1 = GetInt(buff, '.');
@@ -1659,14 +1677,20 @@ static bool OpenSubStationAlpha(CTextFile* file, CSimpleTextSubtitle& ret, int C
marginRect.left = GetInt(buff);
marginRect.right = GetInt(buff);
marginRect.top = marginRect.bottom = GetInt(buff);
- if(version >= 6)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();
+ if(Effect.Left(len) == WToT(buff.Left(len))) {
+ Effect.Empty();
+ }
Style.TrimLeft('*');
- if(!Style.CompareNoCase(_T("Default"))) Style = _T("Default");
+ if(!Style.CompareNoCase(_T("Default"))) {
+ Style = _T("Default");
+ }
ret.Add(buff,
file->IsUnicode(),
@@ -1675,19 +1699,14 @@ static bool OpenSubStationAlpha(CTextFile* file, CSimpleTextSubtitle& ret, int C
Style, Actor, Effect,
marginRect,
layer);
- }
- catch(...)
- {
+ } catch(...) {
return(false);
}
- }
- else if(entry == L"fontname")
- {
+ } else if(entry == L"fontname") {
LoadUUEFont(file);
}
#ifdef _VSMOD // load png graphic from text resources
- else if(entry == L"filename")
- {
+ else if(entry == L"filename") {
ret.LoadUUEFile(file,GetStr(buff));
}
#endif
@@ -1700,79 +1719,70 @@ static bool OpenXombieSub(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet
{
float version = 0;
-// CMapStringToPtr stylemap;
+ // CMapStringToPtr stylemap;
CStringW buff;
- while(file->ReadString(buff))
- {
+ while(file->ReadString(buff)) {
buff.Trim();
- if(buff.IsEmpty() || buff.GetAt(0) == ';') continue;
+ if(buff.IsEmpty() || buff.GetAt(0) == ';') {
+ continue;
+ }
CStringW entry;
-// try {
- entry = GetStr(buff, '=');
-// }
-// catch(...) {continue;}
+ // try {
+ entry = GetStr(buff, '=');
+ // }
+ // catch(...) {continue;}
entry.MakeLower();
- if(entry == L"version")
- {
+ if(entry == L"version") {
version = (float)GetFloat(buff);
- }
- else if(entry == L"screenhorizontal")
- {
- try
- {
+ } else if(entry == L"screenhorizontal") {
+ try {
ret.m_dstScreenSize.cx = GetInt(buff);
- }
- catch(...)
- {
+ } catch(...) {
ret.m_dstScreenSize = CSize(0, 0);
return(false);
}
- if(ret.m_dstScreenSize.cy <= 0)
- {
+ 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
- {
+ } else if(entry == L"screenvertical") {
+ try {
ret.m_dstScreenSize.cy = GetInt(buff);
- }
- catch(...)
- {
+ } catch(...) {
ret.m_dstScreenSize = CSize(0, 0);
return(false);
}
- if(ret.m_dstScreenSize.cx <= 0)
- {
+ 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")
- {
+ } else if(entry == L"style") {
STSStyle* style = DNew STSStyle;
- if(!style) return(false);
+ if(!style) {
+ return(false);
+ }
- try
- {
+ try {
CString StyleName;
StyleName = WToT(GetStr(buff)) + _T("_") + WToT(GetStr(buff));
style->fontName = WToT(GetStr(buff));
style->fontSize = GetFloat(buff);
- for(ptrdiff_t i = 0; i < 4; i++) style->colors[i] = (COLORREF)GetInt(buff);
- for(ptrdiff_t i = 0; i < 4; i++) style->alpha[i] = GetInt(buff);
+ for(ptrdiff_t i = 0; i < 4; i++) {
+ style->colors[i] = (COLORREF)GetInt(buff);
+ }
+ for(ptrdiff_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);
@@ -1803,23 +1813,20 @@ static bool OpenXombieSub(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet
style->shadowDepthY = max(style->shadowDepthY, 0);
ret.AddStyle(StyleName, style);
- }
- catch(...)
- {
+ } catch(...) {
delete style;
return(false);
}
- }
- else if(entry == L"line")
- {
- try
- {
+ } 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;
+ if(GetStr(buff) != L"D") {
+ continue;
+ }
id = GetStr(buff);
layer = GetInt(buff);
hh1 = GetInt(buff, ':');
@@ -1837,7 +1844,9 @@ static bool OpenXombieSub(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet
marginRect.top = marginRect.bottom = GetInt(buff);
Style.TrimLeft('*');
- if(!Style.CompareNoCase(_T("Default"))) Style = _T("Default");
+ if(!Style.CompareNoCase(_T("Default"))) {
+ Style = _T("Default");
+ }
ret.Add(buff,
file->IsUnicode(),
@@ -1846,19 +1855,14 @@ static bool OpenXombieSub(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet
Style, Actor, _T(""),
marginRect,
layer);
- }
- catch(...)
- {
+ } catch(...) {
return(false);
}
- }
- else if(entry == L"fontname")
- {
+ } else if(entry == L"fontname") {
LoadUUEFont(file);
}
#ifdef _VSMOD // load png graphic from text resources
- else if(entry == L"filename")
- {
+ else if(entry == L"filename") {
ret.LoadUUEFile(file,GetStr(buff));
}
#endif
@@ -1872,13 +1876,12 @@ static bool OpenXombieSub(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet
static bool OpenUSF(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet)
{
CString str;
- while(file->ReadString(str))
- {
- if(str.Find(_T("USFSubtitles")) >= 0)
- {
+ while(file->ReadString(str)) {
+ if(str.Find(_T("USFSubtitles")) >= 0) {
CUSFSubtitles usf;
- if(usf.Read(file->GetFilePath()) && usf.ConvertToSTS(ret))
+ if(usf.Read(file->GetFilePath()) && usf.ConvertToSTS(ret)) {
return(true);
+ }
break;
}
@@ -1892,11 +1895,9 @@ static CStringW MPL22SSA(CStringW str)
CAtlList<CStringW> sl;
Explode(str, sl, '|');
POSITION pos = sl.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CStringW& s = sl.GetNext(pos);
- if(s[0] == '/')
- {
+ if(s[0] == '/') {
s = L"{\\i1}" + s.Mid(1) + L"{\\i0}";
}
}
@@ -1908,23 +1909,21 @@ static CStringW MPL22SSA(CStringW str)
static bool OpenMPL2(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet)
{
CStringW buff;
- while(file->ReadString(buff))
- {
+ while(file->ReadString(buff)) {
buff.Trim();
- if(buff.IsEmpty()) continue;
+ if(buff.IsEmpty()) {
+ continue;
+ }
int start, end;
int c = swscanf(buff, L"[%d][%d]", &start, &end);
- if(c == 2)
- {
+ 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
- {
+ } else if(c != EOF) { // might be another format
return(false);
}
}
@@ -1936,15 +1935,13 @@ typedef bool (*STSOpenFunct)(CTextFile* file, CSimpleTextSubtitle& ret, int Char
static bool OpenRealText(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet);
-typedef struct
-{
+typedef struct {
STSOpenFunct open;
tmode mode;
exttype type;
} OpenFunctStruct;
-static OpenFunctStruct OpenFuncts[] =
-{
+static OpenFunctStruct OpenFuncts[] = {
OpenSubRipper, TIME, EXTSRT,
OpenOldSubRipper, TIME, EXTSRT,
OpenSubViewer, TIME, EXTSUB,
@@ -1999,8 +1996,7 @@ CSimpleTextSubtitle& CSimpleTextSubtitle::operator = (CSimpleTextSubtitle& sts)
void CSimpleTextSubtitle::Copy(CSimpleTextSubtitle& sts)
{
- if(this != &sts)
- {
+ if(this != &sts) {
Empty();
m_name = sts.m_name;
@@ -2021,15 +2017,12 @@ void CSimpleTextSubtitle::Copy(CSimpleTextSubtitle& sts)
void CSimpleTextSubtitle::Append(CSimpleTextSubtitle& sts, int timeoff)
{
- if(timeoff < 0)
- {
+ if(timeoff < 0) {
timeoff = GetCount() > 0 ? GetAt(GetCount()-1).end : 0;
}
- for(ptrdiff_t i = 0, j = GetCount(); i < j; i++)
- {
- if(GetAt(i).start > timeoff)
- {
+ for(ptrdiff_t i = 0, j = GetCount(); i < j; i++) {
+ if(GetAt(i).start > timeoff) {
RemoveAt(i, j - i);
break;
}
@@ -2037,8 +2030,7 @@ void CSimpleTextSubtitle::Append(CSimpleTextSubtitle& sts, int timeoff)
CopyStyles(sts.m_styles, true);
- for(ptrdiff_t i = 0, j = sts.GetCount(); i < j; i++)
- {
+ for(ptrdiff_t i = 0, j = sts.GetCount(); i < j; i++) {
STSEntry stse = sts.GetAt(i);
stse.start += timeoff;
stse.end += timeoff;
@@ -2052,8 +2044,7 @@ void CSimpleTextSubtitle::Append(CSimpleTextSubtitle& sts, int timeoff)
void CSTSStyleMap::Free()
{
POSITION pos = GetStartPosition();
- while(pos)
- {
+ while(pos) {
CString key;
STSStyle* val;
GetNextAssoc(pos, key, val);
@@ -2065,17 +2056,20 @@ void CSTSStyleMap::Free()
bool CSimpleTextSubtitle::CopyStyles(const CSTSStyleMap& styles, bool fAppend)
{
- if(!fAppend) m_styles.Free();
+ if(!fAppend) {
+ m_styles.Free();
+ }
POSITION pos = styles.GetStartPosition();
- while(pos)
- {
+ while(pos) {
CString key;
STSStyle* val;
styles.GetNextAssoc(pos, key, val);
STSStyle* s = DNew STSStyle;
- if(!s) return(false);
+ if(!s) {
+ return(false);
+ }
*s = *val;
@@ -2093,8 +2087,7 @@ void CSimpleTextSubtitle::Empty()
RemoveAll();
#ifdef _VSMOD // indexing
- if(ind_size>0)
- {
+ if(ind_size>0) {
delete ind_time;
delete ind_pos;
}
@@ -2103,11 +2096,15 @@ void CSimpleTextSubtitle::Empty()
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;
+ if(str.Trim().IsEmpty() || start > end) {
+ return;
+ }
str.Remove('\r');
str.Replace(L"\n", L"\\N");
- if(style.IsEmpty()) style = _T("Default");
+ if(style.IsEmpty()) {
+ style = _T("Default");
+ }
style.TrimLeft('*');
STSEntry sub;
@@ -2127,46 +2124,38 @@ void CSimpleTextSubtitle::Add(CStringW str, bool fUnicode, int start, int end, C
#ifndef _VSMOD
int len = m_segments.GetCount();
- if(len == 0)
- {
+ if(len == 0) {
STSSegment stss(start, end);
stss.subs.Add(n);
m_segments.Add(stss);
- }
- else if(end <= m_segments[0].start)
- {
+ } 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)
- {
+ } 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)
- {
+ } 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(ptrdiff_t i = 0; i < m_segments.GetCount(); i++)
- {
+ for(ptrdiff_t i = 0; i < m_segments.GetCount(); i++) {
STSSegment& s = m_segments[i];
- if(start >= s.end)
+ if(start >= s.end) {
continue;
+ }
- if(end <= s.start)
+ if(end <= s.start) {
break;
+ }
- if(s.start < start && start < s.end)
- {
+ if(s.start < start && start < s.end) {
STSSegment stss(s.start, start);
stss.subs.Copy(s.subs);
s.start = start;
@@ -2174,33 +2163,30 @@ void CSimpleTextSubtitle::Add(CStringW str, bool fUnicode, int start, int end, C
continue;
}
- if(start <= s.start && s.end <= end)
- {
- for(ptrdiff_t j = 0, k = s.subs.GetCount(); j <= k; j++)
- {
- if(j == k || sub.readorder < GetAt(s.subs[j]).readorder)
+ if(start <= s.start && s.end <= end) {
+ for(ptrdiff_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);
+ // s.subs.Add(n);
}
- if(s.start < end && end < s.end)
- {
+ if(s.start < end && end < s.end) {
STSSegment stss(s.start, end);
stss.subs.Copy(s.subs);
- for(ptrdiff_t j = 0, k = s.subs.GetCount(); j <= k; j++)
- {
- if(j == k || sub.readorder < GetAt(stss.subs[j]).readorder)
+ for(ptrdiff_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);
+ // stss.subs.Add(n);
s.start = end;
m_segments.InsertAt(i, stss);
}
}
- if(end > m_segments[m_segments.GetCount()-1].end)
- {
+ 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);
@@ -2214,20 +2200,14 @@ void CSimpleTextSubtitle::Add(CStringW str, bool fUnicode, int start, int end, C
void CSimpleTextSubtitle::MakeIndex(int SizeOfSegment)
{
int cnt = m_segments.GetCount();
- if (SizeOfSegment==0) // autosize
- {
+ if (SizeOfSegment==0) { // autosize
// 100000 lines == 1300 segments
// TODO: make gooood =D
- if(cnt<100)
- {
+ if(cnt<100) {
SizeOfSegment = (cnt==0) ? 1 : cnt;
- }
- else if (cnt<1000)
- {
+ } else if (cnt<1000) {
SizeOfSegment = cnt / 50;
- }
- else
- {
+ } else {
SizeOfSegment = cnt / 100;
}
}
@@ -2237,8 +2217,7 @@ void CSimpleTextSubtitle::MakeIndex(int SizeOfSegment)
ind_time = new DWORD[ind_size];
ind_pos = new DWORD[ind_size];
- for(int i = 0; i<ind_size; i++)
- {
+ for(int i = 0; i<ind_size; i++) {
int pos = i * SizeOfSegment;
ind_time[i] = m_segments[pos].start;
ind_pos[i] = pos;
@@ -2252,17 +2231,14 @@ STSStyle* CSimpleTextSubtitle::CreateDefaultStyle(int CharSet)
STSStyle* ret = NULL;
- if(!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
- {
+ } else {
m_fUsingAutoGeneratedDefaultStyle = false;
}
@@ -2274,20 +2250,18 @@ void CSimpleTextSubtitle::ChangeUnknownStylesToDefault()
CAtlMap<CString, STSStyle*, CStringElementTraits<CString> > unknown;
bool fReport = true;
- for(ptrdiff_t i = 0; i < GetCount(); i++)
- {
+ for(ptrdiff_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)
- {
+ 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;
+ if(MessageBox(NULL, msg, _T("Warning"), MB_OKCANCEL|MB_ICONWARNING) != IDOK) {
+ fReport = false;
+ }
}
unknown[stse.style] = NULL;
@@ -2302,47 +2276,47 @@ void CSimpleTextSubtitle::AddStyle(CString name, STSStyle* style)
{
int i, j;
- if(name.IsEmpty()) name = _T("Default");
+ if(name.IsEmpty()) {
+ name = _T("Default");
+ }
STSStyle* val;
- if(m_styles.Lookup(name, val))
- {
- if(*val == *style)
- {
+ if(m_styles.Lookup(name, val)) {
+ if(*val == *style) {
delete style;
return;
}
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;
CString name2 = name;
- if(i < len && _stscanf(name.Right(len-i), _T("%d"), &idx) == 1)
- {
+ if(i < len && _stscanf(name.Right(len-i), _T("%d"), &idx) == 1) {
name2 = name.Left(i);
}
idx++;
CString name3;
- do
- {
+ do {
name3.Format(_T("%s%d"), name2, idx);
idx++;
- }
- while(m_styles.Lookup(name3));
+ } while(m_styles.Lookup(name3));
m_styles.RemoveKey(name);
m_styles[name3] = val;
- for(i = 0, j = GetCount(); i < j; i++)
- {
+ for(i = 0, j = GetCount(); i < j; i++) {
STSEntry& stse = GetAt(i);
- if(stse.style == name) stse.style = name3;
+ if(stse.style == name) {
+ stse.style = name3;
+ }
}
}
@@ -2352,7 +2326,9 @@ void CSimpleTextSubtitle::AddStyle(CString name, STSStyle* style)
bool CSimpleTextSubtitle::SetDefaultStyle(STSStyle& s)
{
STSStyle* val;
- if(!m_styles.Lookup(_T("Default"), val)) return false;
+ if(!m_styles.Lookup(_T("Default"), val)) {
+ return false;
+ }
*val = s;
m_fUsingAutoGeneratedDefaultStyle = false;
return true;
@@ -2361,17 +2337,20 @@ bool CSimpleTextSubtitle::SetDefaultStyle(STSStyle& s)
bool CSimpleTextSubtitle::GetDefaultStyle(STSStyle& s)
{
STSStyle* val;
- if(!m_styles.Lookup(_T("Default"), val)) return false;
+ 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(ptrdiff_t i = 0, j = GetCount(); i < j; i++)
- {
+ for(ptrdiff_t i = 0, j = GetCount(); i < j; i++) {
STSEntry& stse = (*this)[i];
stse.start = int(1.0 * stse.start * 1000 / fps + 0.5);
stse.end = int(1.0 * stse.end * 1000 / fps + 0.5);
@@ -2384,10 +2363,11 @@ void CSimpleTextSubtitle::ConvertToTimeBased(double fps)
void CSimpleTextSubtitle::ConvertToFrameBased(double fps)
{
- if(m_mode == FRAME) return;
+ if(m_mode == FRAME) {
+ return;
+ }
- for(ptrdiff_t i = 0, j = GetCount(); i < j; i++)
- {
+ for(ptrdiff_t i = 0, j = GetCount(); i < j; i++) {
STSEntry& stse = (*this)[i];
stse.start = int(1.0 * stse.start * fps / 1000 + 0.5);
stse.end = int(1.0 * stse.end * fps / 1000 + 0.5);
@@ -2402,33 +2382,32 @@ int CSimpleTextSubtitle::SearchSub(int t, double fps)
{
int i = 0, j = GetCount() - 1, ret = -1;
- if(j >= 0 && t >= TranslateStart(j, fps))
- {
+ if(j >= 0 && t >= TranslateStart(j, fps)) {
return(j);
}
- while(i < 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--;
+ if(t == midt) {
+ while(mid > 0 && t == TranslateStart(mid-1, fps)) {
+ mid--;
+ }
ret = mid;
break;
- }
- else if(t < midt)
- {
+ } else if(t < midt) {
ret = -1;
- if(j == mid) mid--;
+ if(j == mid) {
+ mid--;
+ }
j = mid;
- }
- else if(t > midt)
- {
+ } else if(t > midt) {
ret = mid;
- if(i == mid) mid++;
+ if(i == mid) {
+ mid++;
+ }
i = mid;
}
}
@@ -2440,37 +2419,42 @@ const STSSegment* CSimpleTextSubtitle::SearchSubs(int t, double fps, /*[out]*/ i
{
int i = 0, j = m_segments.GetCount() - 1, ret = -1;
- if(nSegments) *nSegments = j+1;
+ if(nSegments) {
+ *nSegments = j+1;
+ }
// last segment
- if(j >= 0 && t >= TranslateSegmentStart(j, fps) && t < TranslateSegmentEnd(j, fps))
- {
- if(iSegment) *iSegment = j;
+ 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;
+ 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;
+ if(j > 0 && t < TranslateSegmentStart(i, fps)) {
+ if(iSegment) {
+ *iSegment = -1;
+ }
return(NULL);
}
#ifdef _VSMOD
// find bounds
// is this nya?
- for(ptrdiff_t k = 0; k < ind_size; k++)
- {
- if(ind_time[k]>t)
- {
- if(k==0) break;
+ for(ptrdiff_t k = 0; k < ind_size; k++) {
+ if(ind_time[k]>t) {
+ if(k==0) {
+ break;
+ }
i = ind_pos[k-1];
j = ind_pos[k];
break;
@@ -2478,40 +2462,38 @@ const STSSegment* CSimpleTextSubtitle::SearchSubs(int t, double fps, /*[out]*/ i
}
#endif
- while(i < j)
- {
+ while(i < j) {
int mid = (i + j) >> 1;
int midt = TranslateSegmentStart(mid, fps);
- if(t == midt)
- {
+ if(t == midt) {
ret = mid;
break;
- }
- else if(t < midt)
- {
+ } else if(t < midt) {
ret = -1;
- if(j == mid) mid--;
+ if(j == mid) {
+ mid--;
+ }
j = mid;
- }
- else if(t > midt)
- {
+ } else if(t > midt) {
ret = mid;
- if(i == mid) mid++;
+ if(i == mid) {
+ mid++;
+ }
i = mid;
}
}
- if(0 <= ret && ret < m_segments.GetCount())
- {
- if(iSegment) *iSegment = ret;
+ if(0 <= ret && ret < m_segments.GetCount()) {
+ if(iSegment) {
+ *iSegment = ret;
+ }
}
if(0 <= ret && ret < m_segments.GetCount()
&& m_segments[ret].subs.GetCount() > 0
- && TranslateSegmentStart(ret, fps) <= t && t < TranslateSegmentEnd(ret, fps))
- {
+ && TranslateSegmentStart(ret, fps) <= t && t < TranslateSegmentEnd(ret, fps)) {
return(&m_segments[ret]);
}
@@ -2560,8 +2542,7 @@ STSStyle* CSimpleTextSubtitle::GetStyle(int i)
STSStyle* defstyle = NULL;
m_styles.Lookup(def, defstyle);
- if(!style)
- {
+ if(!style) {
style = defstyle;
}
@@ -2580,25 +2561,23 @@ bool CSimpleTextSubtitle::GetStyle(int i, STSStyle& stss)
STSStyle* defstyle = NULL;
m_styles.Lookup(def, defstyle);
- if(!style)
- {
- if(!defstyle)
- {
+ if(!style) {
+ if(!defstyle) {
defstyle = CreateDefaultStyle(DEFAULT_CHARSET);
}
style = defstyle;
}
- if(!style)
- {
+ if(!style) {
ASSERT(0);
return false;
}
stss = *style;
- if(stss.relativeTo == 2 && defstyle)
+ if(stss.relativeTo == 2 && defstyle) {
stss.relativeTo = defstyle->relativeTo;
+ }
return true;
}
@@ -2619,8 +2598,7 @@ void CSimpleTextSubtitle::ConvertUnicode(int i, bool fUnicode)
{
STSEntry& stse = GetAt(i);
- if(stse.fUnicode ^ fUnicode)
- {
+ if(stse.fUnicode ^ fUnicode) {
int CharSet = GetCharSet(i);
stse.str = fUnicode
@@ -2643,11 +2621,13 @@ CStringW CSimpleTextSubtitle::GetStrW(int i, bool fSSA)
CStringW str = GetAt(i).str;
- if(!fUnicode)
+ if(!fUnicode) {
str = MBCSSSAToUnicode(str, CharSet);
+ }
- if(!fSSA)
+ if(!fSSA) {
str = RemoveSSATags(str, fUnicode, CharSet);
+ }
return(str);
}
@@ -2659,11 +2639,13 @@ CStringW CSimpleTextSubtitle::GetStrWA(int i, bool fSSA)
CStringW str = GetAt(i).str;
- if(fUnicode)
+ if(fUnicode) {
str = UnicodeSSAToMBCS(str, CharSet);
+ }
- if(!fSSA)
+ if(!fSSA) {
str = RemoveSSATags(str, fUnicode, CharSet);
+ }
return(str);
}
@@ -2679,16 +2661,24 @@ void CSimpleTextSubtitle::SetStr(int i, CStringW str, bool fUnicode)
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;
+ if(ret == 0) {
+ ret = ((STSEntry*)a)->layer - ((STSEntry*)b)->layer;
+ }
+ if(ret == 0) {
+ ret = ((STSEntry*)a)->readorder - ((STSEntry*)b)->readorder;
+ }
return(ret);
}
@@ -2716,8 +2706,7 @@ void CSimpleTextSubtitle::CreateSegments()
CAtlArray<int> breakpoints;
- for(i = 0; i < GetCount(); i++)
- {
+ for(i = 0; i < GetCount(); i++) {
STSEntry& stse = GetAt(i);
breakpoints.Add(stse.start);
breakpoints.Add(stse.end);
@@ -2727,39 +2716,39 @@ void CSimpleTextSubtitle::CreateSegments()
int* ptr = breakpoints.GetData(), prev = ptr ? *ptr : NULL;
- for(i = breakpoints.GetCount(); i > 0; i--, ptr++)
- {
- if(*ptr != prev)
- {
+ 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++)
- {
+ 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++)
+ 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(i);
+ }
}
OnChanged();
-/*
- for(i = 0, j = m_segments.GetCount(); i < j; i++)
- {
- STSSegment& stss = m_segments[i];
+ /*
+ 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(ptrdiff_t k = 0, l = stss.subs.GetCount(); k < l; k++)
- {
- TRACE(_T(", %d"), stss.subs[k]);
- }
+ for(ptrdiff_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)
@@ -2767,17 +2756,19 @@ bool CSimpleTextSubtitle::Open(CString fn, int CharSet, CString name)
Empty();
CWebTextFile f;
- if(!f.Open(fn)) return(false);
+ if(!f.Open(fn)) {
+ return(false);
+ }
fn.Replace('\\', '/');
- if(name.IsEmpty())
- {
+ 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)
+ if ((len - pos) > 1) {
name = name.Mid(pos);
+ }
}
return(Open(&f, CharSet, name));
@@ -2788,7 +2779,9 @@ 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++;
+ while(f->ReadString(s) && f->GetPosition() < to) {
+ n++;
+ }
return(n);
}
@@ -2798,12 +2791,9 @@ bool CSimpleTextSubtitle::Open(CTextFile* f, int CharSet, CString name)
ULONGLONG pos = f->GetPosition();
- for(ptrdiff_t i = 0; i < nOpenFuncts; i++)
- {
- if(!OpenFuncts[i].open(f, *this, CharSet) /*|| !GetCount()*/)
- {
- if(GetCount() > 0)
- {
+ 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);
@@ -2823,20 +2813,23 @@ bool CSimpleTextSubtitle::Open(CTextFile* f, int CharSet, CString name)
m_encoding = f->GetEncoding();
m_path = f->GetFilePath();
-// Sort();
+ // Sort();
CreateSegments();
#ifdef _VSMOD // indexing
MakeIndex(0);
#endif
CWebTextFile f2;
- if(f2.Open(f->GetFilePath() + _T(".style")))
+ if(f2.Open(f->GetFilePath() + _T(".style"))) {
OpenSubStationAlpha(&f2, *this, CharSet);
+ }
CreateDefaultStyle(CharSet);
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);
}
@@ -2847,17 +2840,27 @@ bool CSimpleTextSubtitle::Open(CTextFile* f, int CharSet, CString name)
bool CSimpleTextSubtitle::Open(BYTE* data, int len, int CharSet, CString name)
{
TCHAR path[_MAX_PATH];
- if(!GetTempPath(_MAX_PATH, path)) return(false);
+ if(!GetTempPath(_MAX_PATH, path)) {
+ return(false);
+ }
TCHAR fn[_MAX_PATH];
- if(!GetTempFileName(path, _T("vs"), 0, fn)) return(false);
+ if(!GetTempFileName(path, _T("vs"), 0, fn)) {
+ return(false);
+ }
FILE* tmp = _tfopen(fn, _T("wb"));
- if(!tmp) return(false);
+ if(!tmp) {
+ 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);
+ for(; i <= (len-1024); i += 1024) {
+ fwrite(&data[i], 1024, 1, tmp);
+ }
+ if(len > i) {
+ fwrite(&data[i], len - i, 1, tmp);
+ }
fclose(tmp);
@@ -2870,18 +2873,19 @@ bool CSimpleTextSubtitle::Open(BYTE* data, int len, int CharSet, CString name)
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(".");
+ 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))
+ if(!f.Save(fn, e)) {
return(false);
+ }
- if(et == EXTSMI)
- {
+ if(et == EXTSMI) {
CString str;
str += _T("<SAMI>\n<HEAD>\n");
@@ -2897,9 +2901,7 @@ bool CSimpleTextSubtitle::SaveAs(CString fn, exttype et, double fps, CTextFile::
str += _T("<BODY>\n");
f.WriteString(str);
- }
- else if(et == EXTSSA || et == EXTASS)
- {
+ } else if(et == EXTSSA || et == EXTASS) {
CString str;
str = _T("[Script Info]\n");
@@ -2908,8 +2910,7 @@ bool CSimpleTextSubtitle::SaveAs(CString fn, exttype et, double fps, CTextFile::
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)
- {
+ 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");
@@ -2921,7 +2922,9 @@ bool CSimpleTextSubtitle::SaveAs(CString fn, exttype et, double fps, CTextFile::
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");
+ 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");
@@ -2939,14 +2942,12 @@ bool CSimpleTextSubtitle::SaveAs(CString fn, exttype et, double fps, CTextFile::
: _T("Style: %s,%s,%d,&H%08x,&H%08x,&H%08x,&H%08x,%d,%d,%d,%d,%d,%d,%d,%.2f,%d,%d,%d,%d,%d,%d,%d,%d\n");
POSITION pos = m_styles.GetStartPosition();
- while(pos)
- {
+ while(pos) {
CString key;
STSStyle* s;
m_styles.GetNextAssoc(pos, key, s);
- if(et == EXTSSA)
- {
+ if(et == EXTSSA) {
CString str2;
str2.Format(str, key,
s->fontName, (int)s->fontSize,
@@ -2962,9 +2963,7 @@ bool CSimpleTextSubtitle::SaveAs(CString fn, exttype et, double fps, CTextFile::
s->alpha[0],
s->charSet);
f.WriteString(str2);
- }
- else
- {
+ } else {
CString str2;
str2.Format(str, key,
s->fontName, (int)s->fontSize,
@@ -2985,8 +2984,7 @@ bool CSimpleTextSubtitle::SaveAs(CString fn, exttype et, double fps, CTextFile::
}
}
- if(GetCount() > 0)
- {
+ if(GetCount() > 0) {
str = _T("\n");
str += _T("[Events]\n");
str += (et == EXTSSA)
@@ -3003,16 +3001,14 @@ bool CSimpleTextSubtitle::SaveAs(CString fn, exttype et, double fps, CTextFile::
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);
+ L"";
+ // Sort(true);
- for(ptrdiff_t i = 0, j = GetCount(), k = 0; i < j; i++)
- {
+ for(ptrdiff_t i = 0, j = GetCount(), k = 0; i < j; i++) {
STSEntry& stse = GetAt(i);
int t1 = TranslateStart(i, fps);
- if(t1 < 0)
- {
+ if(t1 < 0) {
k++;
continue;
}
@@ -3034,27 +3030,18 @@ bool CSimpleTextSubtitle::SaveAs(CString fn, exttype et, double fps, CTextFile::
CStringW str2;
- if(et == EXTSRT)
- {
+ if(et == EXTSRT) {
str2.Format(fmt, i-k+1, hh1, mm1, ss1, ms1, hh2, mm2, ss2, ms2, str);
- }
- else if(et == EXTSUB)
- {
+ } else if(et == EXTSUB) {
str.Replace('\n', '|');
str2.Format(fmt, int(t1*fps/1000), int(t2*fps/1000), str);
- }
- else if(et == EXTSMI)
- {
+ } else if(et == EXTSMI) {
str.Replace(L"\n", L"<br>");
str2.Format(fmt, t1, str, t2);
- }
- else if(et == EXTPSB)
- {
+ } else if(et == EXTPSB) {
str.Replace('\n', '|');
str2.Format(fmt, hh1, mm1, ss1, hh2, mm2, ss2, str);
- }
- else if(et == EXTSSA)
- {
+ } else if(et == EXTSSA) {
str.Replace(L"\n", L"\\N");
str2.Format(fmt,
hh1, mm1, ss1, ms1/10,
@@ -3062,9 +3049,7 @@ bool CSimpleTextSubtitle::SaveAs(CString fn, exttype et, double fps, CTextFile::
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)
- {
+ } else if(et == EXTASS) {
str.Replace(L"\n", L"\\N");
str2.Format(fmt,
stse.layer,
@@ -3078,19 +3063,18 @@ bool CSimpleTextSubtitle::SaveAs(CString fn, exttype et, double fps, CTextFile::
f.WriteString(str2);
}
-// Sort();
+ // Sort();
- if(et == EXTSMI)
- {
+ 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)
- {
+ if(!m_fUsingAutoGeneratedDefaultStyle && m_styles.Lookup(_T("Default"), s) && et != EXTSSA && et != EXTASS) {
CTextFile f;
- if(!f.Save(fn + _T(".style"), e))
+ if(!f.Save(fn + _T(".style"), e)) {
return(false);
+ }
CString str, str2;
@@ -3298,8 +3282,9 @@ void STSStyle::mod_CopyStyleFrom(STSStyle& s)
STSStyle STSStyle::operator = (const STSStyle& s)
{
- if(this != &s)
+ if(this != &s) {
mod_CopyStyleFrom(s);
+ }
return *this;
}
#endif
@@ -3311,7 +3296,7 @@ STSStyle& STSStyle::operator = (LOGFONT& lf)
HDC hDC = GetDC(0);
fontSize = -MulDiv(lf.lfHeight, 72, GetDeviceCaps(hDC, LOGPIXELSY));
ReleaseDC(0, hDC);
-// fontAngleZ = (float)(1.0*lf.lfEscapement/10);
+ // fontAngleZ = (float)(1.0*lf.lfEscapement/10);
fontWeight = lf.lfWeight;
fItalic = !!lf.lfItalic;
fUnderline = !!lf.lfUnderline;
@@ -3370,11 +3355,9 @@ STSStyle& operator <<= (STSStyle& s, CString& style)
{
s.SetDefault();
- try
- {
+ try {
CStringW str = TToW(style);
- if(str.Find(';')>=0)
- {
+ if(str.Find(';')>=0) {
s.marginRect.left = GetInt(str, ';');
s.marginRect.right = GetInt(str, ';');
s.marginRect.top = GetInt(str, ';');
@@ -3385,8 +3368,12 @@ STSStyle& operator <<= (STSStyle& s, CString& style)
s.outlineWidthY = GetFloat(str, ';');
s.shadowDepthX = GetFloat(str, ';');
s.shadowDepthY = GetFloat(str, ';');
- for(ptrdiff_t i = 0; i < 4; i++) s.colors[i] = (COLORREF)GetInt(str, ';');
- for(ptrdiff_t i = 0; i < 4; i++) s.alpha[i] = GetInt(str, ';');
+ for(ptrdiff_t i = 0; i < 4; i++) {
+ s.colors[i] = (COLORREF)GetInt(str, ';');
+ }
+ for(ptrdiff_t i = 0; i < 4; i++) {
+ s.alpha[i] = GetInt(str, ';');
+ }
s.charSet = GetInt(str, ';');
s.fontName = WToT(GetStr(str, ';'));
s.fontSize = GetFloat(str, ';');
@@ -3404,9 +3391,7 @@ STSStyle& operator <<= (STSStyle& s, CString& style)
s.fontAngleY = GetFloat(str, ';');
s.relativeTo = GetInt(str, ';');
}
- }
- catch(...)
- {
+ } catch(...) {
s.SetDefault();
}
@@ -3418,24 +3403,25 @@ static bool OpenRealText(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet)
wstring szFile;
CStringW buff;
- while(file->ReadString(buff))
- {
+ while(file->ReadString(buff)) {
buff.Trim();
- if(buff.IsEmpty()) continue;
+ if(buff.IsEmpty()) {
+ continue;
+ }
szFile += CStringW(_T("\n")) + buff.GetBuffer();
}
CRealTextParser RealTextParser;
- if (!RealTextParser.ParseRealText(szFile))
+ if (!RealTextParser.ParseRealText(szFile)) {
return false;
+ }
CRealTextParser::Subtitles crRealText = RealTextParser.GetParsedSubtitles();
for (map<pair<int, int>, wstring>::const_iterator i = crRealText.m_mapLines.begin();
i != crRealText.m_mapLines.end();
- ++i)
- {
+ ++i) {
ret.Add(
SubRipper2SSA(i->second.c_str(), CharSet),
file->IsUnicode(),
@@ -3443,8 +3429,8 @@ static bool OpenRealText(CTextFile* file, CSimpleTextSubtitle& ret, int CharSet)
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);
}
@@ -3489,8 +3475,9 @@ void png_default_read_edata(png_structp png_ptr, png_bytep data, png_size_t leng
{
png_size_t check;
- if (png_ptr->io_ptr == NULL)
+ if (png_ptr->io_ptr == NULL) {
return;
+ }
BYTE* eldata = (BYTE*)png_ptr->io_ptr;
@@ -3517,9 +3504,13 @@ bool MOD_PNGIMAGE::processData(png_structp png_ptr)
/* initialize stuff */
info_ptr = png_create_info_struct(png_ptr);
- if (!info_ptr) return false; // png_create_info_struct failed
+ if (!info_ptr) {
+ return false; // png_create_info_struct failed
+ }
- if (setjmp(png_jmpbuf(png_ptr))) return false; // Error during init_io
+ if (setjmp(png_jmpbuf(png_ptr))) {
+ return false; // Error during init_io
+ }
png_set_sig_bytes(png_ptr, 8);
@@ -3531,38 +3522,46 @@ bool MOD_PNGIMAGE::processData(png_structp png_ptr)
bit_depth = info_ptr->bit_depth;
// palette
- if (color_type==PNG_COLOR_TYPE_PALETTE)
+ if (color_type==PNG_COLOR_TYPE_PALETTE) {
png_set_palette_to_rgb(png_ptr);
+ }
// expand to 8 bits
- if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8)
+ if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) {
png_set_expand_gray_1_2_4_to_8(png_ptr);
+ }
- if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
+ if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)) {
png_set_tRNS_to_alpha(png_ptr);
+ }
// Strip 16 bit depth files to 8 bit depth
- if (bit_depth == 16)
+ if (bit_depth == 16) {
png_set_strip_16(png_ptr);
+ }
// ARGB -> RGBA
-// if (color_type == PNG_COLOR_TYPE_RGB_ALPHA)
-// png_set_swap_alpha(png_ptr);
+ // if (color_type == PNG_COLOR_TYPE_RGB_ALPHA)
+ // png_set_swap_alpha(png_ptr);
// grayscale -> RGB
- if (color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
+ if (color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_GRAY_ALPHA) {
png_set_gray_to_rgb(png_ptr);
+ }
number_of_passes = png_set_interlace_handling(png_ptr);
png_read_update_info(png_ptr, info_ptr);
/* read file */
- if (setjmp(png_jmpbuf(png_ptr))) return false; // Error during read_image
+ if (setjmp(png_jmpbuf(png_ptr))) {
+ return false; // Error during read_image
+ }
bpp = info_ptr->rowbytes / width;
pointer = (png_bytep*) malloc(sizeof(png_bytep) * height);
- for (int y=0; y<height; y++)
+ for (int y=0; y<height; y++) {
pointer[y] = (png_byte*) malloc(info_ptr->rowbytes);
+ }
png_read_image(png_ptr, pointer);
return true;
@@ -3570,7 +3569,9 @@ bool MOD_PNGIMAGE::processData(png_structp png_ptr)
bool MOD_PNGIMAGE::initImage(CString m_fn)
{
- if((m_fn==filename)&&(pointer!=NULL)) return true; // already loaded
+ if((m_fn==filename)&&(pointer!=NULL)) {
+ return true; // already loaded
+ }
char header[8]; // 8 is the maximum size that can be check
png_structp png_ptr;
@@ -3583,17 +3584,17 @@ bool MOD_PNGIMAGE::initImage(CString m_fn)
filename = m_fn;
FILE *fp = fopen(fn, "rb");
- if (!fp) return false; // File could not be opened for reading
+ if (!fp) {
+ return false; // File could not be opened for reading
+ }
fread(header, 1, 8, fp);
- if (png_sig_cmp((png_bytep)header, 0, 8)) // File is not recognized as a PNG file
- {
+ if (png_sig_cmp((png_bytep)header, 0, 8)) { // File is not recognized as a PNG file
fclose(fp);
return false;
}
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
- if (!png_ptr) // png_create_read_struct failed
- {
+ if (!png_ptr) { // png_create_read_struct failed
fclose(fp);
return false;
}
@@ -3606,8 +3607,12 @@ bool MOD_PNGIMAGE::initImage(CString m_fn)
bool MOD_PNGIMAGE::initImage(BYTE* data, CString m_fn)
{
- if((m_fn==filename)&&(pointer!=NULL)) return true; // already loaded
- if(data == NULL) return false; // not loaded
+ if((m_fn==filename)&&(pointer!=NULL)) {
+ return true; // already loaded
+ }
+ if(data == NULL) {
+ return false; // not loaded
+ }
char header[8]; // 8 is the maximum size that can be check
png_structp png_ptr;
@@ -3615,11 +3620,15 @@ bool MOD_PNGIMAGE::initImage(BYTE* data, CString m_fn)
filename = m_fn;
memcpy(header,data,8);
- if (png_sig_cmp((png_bytep)header, 0, 8)) return false; // File is not recognized as a PNG file
+ if (png_sig_cmp((png_bytep)header, 0, 8)) {
+ return false; // File is not recognized as a PNG file
+ }
data += 8; // don't forget modify pointer
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
- if (!png_ptr) return false; // png_create_read_struct failed
+ if (!png_ptr) {
+ return false; // png_create_read_struct failed
+ }
png_set_read_fn(png_ptr, (png_voidp)data, &png_default_read_edata);
return processData(png_ptr);
@@ -3627,7 +3636,9 @@ bool MOD_PNGIMAGE::initImage(BYTE* data, CString m_fn)
void MOD_PNGIMAGE::freeImage()
{
- if(pointer!=NULL) delete [] pointer;
+ if(pointer!=NULL) {
+ delete [] pointer;
+ }
}
MOD_GRADIENT::MOD_GRADIENT()
@@ -3704,12 +3715,10 @@ DWORD MOD_GRADIENT::getmixcolor(int tx, int ty, int i) // too slow T.T
DWORD colorb = 0;
tx += xoffset;
// gradient
- if(mode[i]==1)
- {
+ if(mode[i]==1) {
double x = (double)tx/(double)width;
double y = (double)ty/(double)height;
- for(int j=0; j<3; j++)
- {
+ for(int j=0; j<3; j++) {
colorb |= ((DWORD)(((color[i][0]>>(8*j))&0xff)*(1-x)*y +
((color[i][1]>>(8*j))&0xff)*x*y+
((color[i][2]>>(8*j))&0xff)*(1-y)*(1-x)+
@@ -3723,15 +3732,22 @@ DWORD MOD_GRADIENT::getmixcolor(int tx, int ty, int i) // too slow T.T
return colorb;
}
// png background
- if(mode[i]==2)
- {
+ if(mode[i]==2) {
// unwarp
tx += b_images[i].xoffset;
ty += b_images[i].yoffset;
- while(tx>b_images[i].width-1) tx-=b_images[i].width;
- while(ty>b_images[i].height-1) ty-=b_images[i].height;
- while(tx<0) tx+=b_images[i].width;
- while(ty<0) ty+=b_images[i].height;
+ while(tx>b_images[i].width-1) {
+ tx-=b_images[i].width;
+ }
+ while(ty>b_images[i].height-1) {
+ ty-=b_images[i].height;
+ }
+ while(tx<0) {
+ tx+=b_images[i].width;
+ }
+ while(ty<0) {
+ ty+=b_images[i].height;
+ }
// now tx and ty are valid array indexes
// rows are inverted last,...,n,...,1,0
bool nlastpixx = (tx>0);
@@ -3745,22 +3761,17 @@ DWORD MOD_GRADIENT::getmixcolor(int tx, int ty, int i) // too slow T.T
BYTE b = dst11[2];
BYTE a = (b_images[i].bpp==4) ? dst11[3] : 0xFF;
// subpixel positioning
- if(nlastpixx&&!nlastpixy) // last row
- {
+ if(nlastpixx&&!nlastpixy) { // last row
r = (r*(8-subpixx)+dst12[0]*subpixx)>>3;
g = (g*(8-subpixx)+dst12[1]*subpixx)>>3;
b = (b*(8-subpixx)+dst12[2]*subpixx)>>3;
a = (b_images[i].bpp==4) ? (a*(8-subpixx)+dst12[3]*subpixx)>>3 : 0xFF;
- }
- else if(nlastpixy&&!nlastpixx) // last col
- {
+ } else if(nlastpixy&&!nlastpixx) { // last col
r = (r*(subpixy)+dst21[0]*(8-subpixy))>>3;
g = (g*(subpixy)+dst21[1]*(8-subpixy))>>3;
b = (b*(subpixy)+dst21[2]*(8-subpixy))>>3;
a = (b_images[i].bpp==4) ? (a*(subpixy)+dst21[3]*(8-subpixy))>>3 : 0xFF;
- }
- else if(nlastpixy&&nlastpixx)
- {
+ } else if(nlastpixy&&nlastpixx) {
// T.T
r = (((dst21[0]*(8-subpixx)+dst22[0]*subpixx)>>3)*(subpixy)+((r*(8-subpixx)+dst12[0]*subpixx)>>3)*(8-subpixy))>>3;
g = (((dst21[1]*(8-subpixx)+dst22[1]*subpixx)>>3)*(subpixy)+((g*(8-subpixx)+dst12[1]*subpixx)>>3)*(8-subpixy))>>3;
@@ -3774,8 +3785,8 @@ DWORD MOD_GRADIENT::getmixcolor(int tx, int ty, int i) // too slow T.T
return colorb;
}
// usual color
-// if(mode[i]==0)
- return (colors[i]|alphas[i]<<24);
+ // if(mode[i]==0)
+ return (colors[i]|alphas[i]<<24);
}
#endif
@@ -3821,8 +3832,12 @@ bool MOD_JITTER::operator == (MOD_JITTER& mj)
CPoint MOD_JITTER::getOffset(REFERENCE_TIME rt)
{
- if (!enabled) return CPoint(0,0);
- if(period==0) period = 1;
+ if (!enabled) {
+ return CPoint(0,0);
+ }
+ if(period==0) {
+ period = 1;
+ }
int rseed = (seed + rt / period)*100;
srand(rseed);
diff --git a/src/Subtitles/STS.h b/src/Subtitles/STS.h
index 6e4ba4a95..fe62dfcff 100644
--- a/src/Subtitles/STS.h
+++ b/src/Subtitles/STS.h
@@ -39,7 +39,7 @@ public:
int Z;
int Seed; // random seed
-//MOD_RANDOM();
+ //MOD_RANDOM();
bool operator == (MOD_RANDOM& mr);
void clear();
@@ -88,7 +88,7 @@ public:
BYTE alpha[4][4]; // va
int mode[4];
-// for renderer
+ // for renderer
int height;
int width;
int xoffset;
@@ -100,7 +100,7 @@ public:
BYTE img_alpha;
-// for background image
+ // for background image
MOD_PNGIMAGE b_images[4];
MOD_GRADIENT();
@@ -216,8 +216,7 @@ public:
void Free();
};
-typedef struct
-{
+typedef struct {
CStringW str;
bool fUnicode;
CString style, actor, effect;
@@ -245,8 +244,7 @@ public:
*this = stss;
}
STSSegment& operator = (const STSSegment& stss) {
- if(this != &stss)
- {
+ if(this != &stss) {
start = stss.start;
end = stss.end;
subs.Copy(stss.subs);
@@ -289,8 +287,7 @@ public:
DWORD* ind_pos; // segment indexes array (start)
#endif
- enum EPARCompensationType
- {
+ enum EPARCompensationType {
EPCTDisabled = 0,
EPCTDownscale = 1,
EPCTUpscale = 2,
@@ -370,7 +367,8 @@ extern BYTE CharSetList[];
extern TCHAR* CharSetNames[];
extern int CharSetLen;
-class CHtmlColorMap : public CAtlMap<CString, DWORD, CStringElementTraits<CString> > {
+class CHtmlColorMap : public CAtlMap<CString, DWORD, CStringElementTraits<CString> >
+{
public:
CHtmlColorMap();
};
diff --git a/src/Subtitles/SeparableFilter.h b/src/Subtitles/SeparableFilter.h
index 7661fb389..49327c7a5 100644
--- a/src/Subtitles/SeparableFilter.h
+++ b/src/Subtitles/SeparableFilter.h
@@ -34,7 +34,7 @@
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)
{
-#pragma omp parallel for
+ #pragma omp parallel for
for (int y = 0; y < height; y++) {
unsigned char *in = src + y*stride;
unsigned char *out = dst + y*stride;
@@ -42,13 +42,21 @@ void SeparableFilterX(unsigned char *src, unsigned char *dst, int width, int hei
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;
+ 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;
+ if (accum > 255) {
+ accum = 255;
+ }
+ if (accum < 0) {
+ accum = 0;
+ }
*out = (unsigned char)accum;
in+=PixelDist;
out+=PixelDist;
@@ -65,7 +73,7 @@ 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)
{
width *= PixelDist;
-#pragma omp parallel for
+ #pragma omp parallel for
for (int x = 0; x < width; x+=PixelDist) {
unsigned char *in = src + x;
unsigned char *out = dst + x;
@@ -73,13 +81,21 @@ void SeparableFilterY(unsigned char *src, unsigned char *dst, int width, int hei
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;
+ 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;
+ if (accum > 255) {
+ accum = 255;
+ }
+ if (accum < 0) {
+ accum = 0;
+ }
*out = (unsigned char)accum;
in += stride;
out += stride;
@@ -90,9 +106,13 @@ void SeparableFilterY(unsigned char *src, unsigned char *dst, int width, int hei
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));
+ }
}
@@ -100,10 +120,11 @@ struct GaussianKernel {
int *kernel;
int width;
int divisor;
- inline GaussianKernel(double sigma)
- {
+ 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;
+ if (width < 3) {
+ width = 3;
+ }
kernel = DNew int[width];
kernel[width/2] = (int)(NormalDist(sigma, 0) * 255);
divisor = kernel[width/2];
@@ -114,8 +135,7 @@ struct GaussianKernel {
kernel[width - x - 1] = val;
}
}
- inline ~GaussianKernel()
- {
+ inline ~GaussianKernel() {
delete[] kernel;
}
};
diff --git a/src/Subtitles/SubtitleInputPin.cpp b/src/Subtitles/SubtitleInputPin.cpp
index 19ede8ce8..e17c59c2f 100644
--- a/src/Subtitles/SubtitleInputPin.cpp
+++ b/src/Subtitles/SubtitleInputPin.cpp
@@ -73,51 +73,52 @@ HRESULT CSubtitleInputPin::CheckMediaType(const CMediaType* pmt)
HRESULT CSubtitleInputPin::CompleteConnect(IPin* pReceivePin)
{
- if(m_mt.majortype == MEDIATYPE_Text)
- {
- if(!(m_pSubStream = DNew CRenderedTextSubtitle(m_pSubLock))) return E_FAIL;
+ 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)
- {
+ } else if(m_mt.majortype == MEDIATYPE_Subtitle) {
SUBTITLEINFO* psi = (SUBTITLEINFO*)m_mt.pbFormat;
DWORD dwOffset = 0;
CString name;
LCID lcid = 0;
- if (psi != NULL)
- {
+ if (psi != NULL) {
dwOffset = psi->dwOffset;
name = ISO6392ToLanguage(psi->IsoLang);
lcid = ISO6392ToLcid(psi->IsoLang);
- if(name.IsEmpty()) name = _T("Unknown");
- if(wcslen(psi->TrackName) > 0) name += _T(" (") + CString(psi->TrackName) + _T(")");
+ if(name.IsEmpty()) {
+ name = _T("Unknown");
+ }
+ if(wcslen(psi->TrackName) > 0) {
+ name += _T(" (") + CString(psi->TrackName) + _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;
+ /*|| 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)
- {
+ 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)
- {
+ && mt.pbFormat[dwOffset+1] != 0xbb
+ && mt.pbFormat[dwOffset+2] != 0xfb) {
dwOffset -= 3;
mt.pbFormat[dwOffset+0] = 0xef;
mt.pbFormat[dwOffset+1] = 0xbb;
@@ -127,22 +128,22 @@ HRESULT CSubtitleInputPin::CompleteConnect(IPin* pReceivePin)
pRTS->Open(mt.pbFormat + dwOffset, mt.cbFormat - dwOffset, DEFAULT_CHARSET, pRTS->m_name);
}
- }
- else if(m_mt.subtype == MEDIASUBTYPE_SSF)
- {
- if(!(m_pSubStream = DNew ssf::CRenderer(m_pSubLock))) return E_FAIL;
+ } else if(m_mt.subtype == MEDIASUBTYPE_SSF) {
+ if(!(m_pSubStream = DNew ssf::CRenderer(m_pSubLock))) {
+ return E_FAIL;
+ }
ssf::CRenderer* pSSF = (ssf::CRenderer*)(ISubStream*)m_pSubStream;
pSSF->Open(ssf::MemoryInputStream(m_mt.pbFormat + dwOffset, m_mt.cbFormat - dwOffset, false, false), name);
- }
- else if(m_mt.subtype == MEDIASUBTYPE_VOBSUB)
- {
- if(!(m_pSubStream = DNew CVobSubStream(m_pSubLock))) return E_FAIL;
+ } 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))) return E_FAIL;
+ } 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;
+ }
}
}
@@ -163,8 +164,7 @@ HRESULT CSubtitleInputPin::BreakConnect()
STDMETHODIMP CSubtitleInputPin::ReceiveConnection(IPin* pConnector, const AM_MEDIA_TYPE* pmt)
{
- if(m_Connected)
- {
+ if(m_Connected) {
RemoveSubStream(m_pSubStream);
m_pSubStream = NULL;
@@ -182,33 +182,26 @@ STDMETHODIMP CSubtitleInputPin::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME
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))
- {
+ /*|| 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_SSF)
- {
+ } else if(m_mt.majortype == MEDIATYPE_Subtitle && m_mt.subtype == MEDIASUBTYPE_SSF) {
CAutoLock cAutoLock(m_pSubLock);
ssf::CRenderer* pSSF = (ssf::CRenderer*)(ISubStream*)m_pSubStream;
// LAME, implement RemoveSubtitles
DWORD dwOffset = ((SUBTITLEINFO*)m_mt.pbFormat)->dwOffset;
pSSF->Open(ssf::MemoryInputStream(m_mt.pbFormat + dwOffset, m_mt.cbFormat - dwOffset, false, false), _T(""));
// pSSF->RemoveSubtitles();
- }
- else if(m_mt.majortype == MEDIATYPE_Subtitle && (m_mt.subtype == MEDIASUBTYPE_VOBSUB))
- {
+ } 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))
- {
+ } else if (IsHdmvSub(&m_mt)) {
CAutoLock cAutoLock(m_pSubLock);
CRenderedHdmvSubtitle* pHdmvSubtitle = (CRenderedHdmvSubtitle*)(ISubStream*)m_pSubStream;
pHdmvSubtitle->NewSegment (tStart, tStop, dRate);
@@ -219,8 +212,7 @@ STDMETHODIMP CSubtitleInputPin::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME
interface __declspec(uuid("D3D92BC3-713B-451B-9122-320095D51EA5"))
IMpeg2DemultiplexerTesting :
-public IUnknown
-{
+public IUnknown {
STDMETHOD(GetMpeg2StreamType)(ULONG* plType) = NULL;
STDMETHOD(toto)() = NULL;
};
@@ -231,7 +223,9 @@ STDMETHODIMP CSubtitleInputPin::Receive(IMediaSample* pSample)
HRESULT hr;
hr = __super::Receive(pSample);
- if(FAILED(hr)) return hr;
+ if(FAILED(hr)) {
+ return hr;
+ }
CAutoLock cAutoLock(&m_csReceive);
@@ -242,120 +236,95 @@ STDMETHODIMP CSubtitleInputPin::Receive(IMediaSample* pSample)
BYTE* pData = NULL;
hr = pSample->GetPointer(&pData);
- if(FAILED(hr) || pData == NULL) return hr;
+ if(FAILED(hr) || pData == NULL) {
+ return hr;
+ }
int len = pSample->GetActualDataLength();
bool fInvalidate = false;
- if(m_mt.majortype == MEDIATYPE_Text)
- {
+ if(m_mt.majortype == MEDIATYPE_Text) {
CAutoLock cAutoLock(m_pSubLock);
CRenderedTextSubtitle* pRTS = (CRenderedTextSubtitle*)(ISubStream*)m_pSubStream;
- if(!strncmp((char*)pData, __GAB1__, strlen(__GAB1__)))
- {
+ if(!strncmp((char*)pData, __GAB1__, strlen(__GAB1__))) {
char* ptr = (char*)&pData[strlen(__GAB1__)+1];
char* end = (char*)&pData[len];
- while(ptr < end)
- {
+ while(ptr < end) {
WORD tag = *((WORD*)(ptr));
ptr += 2;
WORD size = *((WORD*)(ptr));
ptr += 2;
- if(tag == __GAB1_LANGUAGE__)
- {
+ if(tag == __GAB1_LANGUAGE__) {
pRTS->m_name = CString(ptr);
- }
- else if(tag == __GAB1_ENTRY__)
- {
+ } else if(tag == __GAB1_ENTRY__) {
pRTS->Add(AToW(&ptr[8]), false, *(int*)ptr, *(int*)(ptr+4));
fInvalidate = true;
- }
- else if(tag == __GAB1_LANGUAGE_UNICODE__)
- {
+ } else if(tag == __GAB1_LANGUAGE_UNICODE__) {
pRTS->m_name = (WCHAR*)ptr;
- }
- else if(tag == __GAB1_ENTRY_UNICODE__)
- {
+ } 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__)))
- {
+ } else if(!strncmp((char*)pData, __GAB2__, strlen(__GAB2__))) {
char* ptr = (char*)&pData[strlen(__GAB2__)+1];
char* end = (char*)&pData[len];
- while(ptr < end)
- {
+ while(ptr < end) {
WORD tag = *((WORD*)(ptr));
ptr += 2;
DWORD size = *((DWORD*)(ptr));
ptr += 4;
- if(tag == __GAB1_LANGUAGE_UNICODE__)
- {
+ if(tag == __GAB1_LANGUAGE_UNICODE__) {
pRTS->m_name = (WCHAR*)ptr;
- }
- else if(tag == __GAB1_RAWTEXTSUBTITLE__)
- {
+ } 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)
- {
+ } else if(pData != 0 && len > 1 && *pData != 0) {
CStringA str((char*)pData, len);
str.Replace("\r\n", "\n");
str.Trim();
- if(!str.IsEmpty())
- {
+ if(!str.IsEmpty()) {
pRTS->Add(AToW(str), false, (int)(tStart / 10000), (int)(tStop / 10000));
fInvalidate = true;
}
}
- }
- else if(m_mt.majortype == MEDIATYPE_Subtitle)
- {
+ } else if(m_mt.majortype == MEDIATYPE_Subtitle) {
CAutoLock cAutoLock(m_pSubLock);
- if(m_mt.subtype == MEDIASUBTYPE_UTF8)
- {
+ if(m_mt.subtype == MEDIASUBTYPE_UTF8) {
CRenderedTextSubtitle* pRTS = (CRenderedTextSubtitle*)(ISubStream*)m_pSubStream;
CStringW str = UTF8To16(CStringA((LPCSTR)pData, len)).Trim();
- if(!str.IsEmpty())
- {
+ 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)
- {
+ } 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())
- {
+ 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)
- {
+ if(sl.GetCount() == (size_t)fields) {
stse.readorder = wcstol(sl.RemoveHead(), NULL, 10);
stse.layer = wcstol(sl.RemoveHead(), NULL, 10);
stse.style = sl.RemoveHead();
@@ -363,45 +332,38 @@ STDMETHODIMP CSubtitleInputPin::Receive(IMediaSample* pSample)
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);
+ if(fields == 10) {
+ stse.marginRect.bottom = wcstol(sl.RemoveHead(), NULL, 10);
+ }
stse.effect = sl.RemoveHead();
stse.str = sl.RemoveHead();
}
- if(!stse.str.IsEmpty())
- {
+ 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_SSF)
- {
+ } else if(m_mt.subtype == MEDIASUBTYPE_SSF) {
ssf::CRenderer* pSSF = (ssf::CRenderer*)(ISubStream*)m_pSubStream;
CStringW str = UTF8To16(CStringA((LPCSTR)pData, len)).Trim();
- if(!str.IsEmpty())
- {
+ if(!str.IsEmpty()) {
pSSF->Append(tStart, tStop, str);
fInvalidate = true;
}
- }
- else if(m_mt.subtype == MEDIASUBTYPE_VOBSUB)
- {
+ } else if(m_mt.subtype == MEDIASUBTYPE_VOBSUB) {
CVobSubStream* pVSS = (CVobSubStream*)(ISubStream*)m_pSubStream;
pVSS->Add(tStart, tStop, pData, len);
- }
- else if (IsHdmvSub(&m_mt))
- {
+ } else if (IsHdmvSub(&m_mt)) {
CAutoLock cAutoLock(m_pSubLock);
CRenderedHdmvSubtitle* pHdmvSubtitle = (CRenderedHdmvSubtitle*)(ISubStream*)m_pSubStream;
pHdmvSubtitle->ParseSample (pSample);
}
}
- if(fInvalidate)
- {
+ if(fInvalidate) {
TRACE(_T("InvalidateSubtitle(%I64d, ..)\n"), tStart);
// IMPORTANT: m_pSubLock must not be locked when calling this
InvalidateSubtitle(tStart, m_pSubStream);
@@ -416,8 +378,8 @@ STDMETHODIMP CSubtitleInputPin::Receive(IMediaSample* pSample)
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;
+ 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/TextFile.cpp b/src/Subtitles/TextFile.cpp
index e08c31f58..2a64547a8 100644
--- a/src/Subtitles/TextFile.cpp
+++ b/src/Subtitles/TextFile.cpp
@@ -34,47 +34,43 @@ CTextFile::CTextFile(enc e)
bool CTextFile::Open(LPCTSTR lpszFileName)
{
- if(!__super::Open(lpszFileName, modeRead|typeBinary|shareDenyNone))
+ if(!__super::Open(lpszFileName, modeRead|typeBinary|shareDenyNone)) {
return(false);
+ }
m_encoding = m_defaultencoding;
m_offset = 0;
- if(__super::GetLength() >= 2)
- {
+ if(__super::GetLength() >= 2) {
WORD w;
- if(sizeof(w) != Read(&w, sizeof(w)))
+ if(sizeof(w) != Read(&w, sizeof(w))) {
return Close(), false;
+ }
- if(w == 0xfeff)
- {
+ if(w == 0xfeff) {
m_encoding = LE16;
m_offset = 2;
- }
- else if(w == 0xfffe)
- {
+ } else if(w == 0xfffe) {
m_encoding = BE16;
m_offset = 2;
- }
- else if(w == 0xbbef && __super::GetLength() >= 3)
- {
+ } else if(w == 0xbbef && __super::GetLength() >= 3) {
BYTE b;
- if(sizeof(b) != Read(&b, sizeof(b)))
+ if(sizeof(b) != Read(&b, sizeof(b))) {
return Close(), false;
+ }
- if(b == 0xbf)
- {
+ if(b == 0xbf) {
m_encoding = UTF8;
m_offset = 3;
}
}
}
- if(m_encoding == m_defaultencoding)
- {
+ 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))
+ if(!__super::Open(lpszFileName, modeRead|typeText|shareDenyNone)) {
return(false);
+ }
}
return(true);
@@ -82,21 +78,17 @@ bool CTextFile::Open(LPCTSTR lpszFileName)
bool CTextFile::Save(LPCTSTR lpszFileName, enc e)
{
- if(!__super::Open(lpszFileName, modeCreate|modeWrite|shareDenyWrite|(e==ASCII?typeText:typeBinary)))
+ if(!__super::Open(lpszFileName, modeCreate|modeWrite|shareDenyWrite|(e==ASCII?typeText:typeBinary))) {
return(false);
+ }
- if(e == UTF8)
- {
+ if(e == UTF8) {
BYTE b[3] = {0xef,0xbb,0xbf};
Write(b, sizeof(b));
- }
- else if(e == LE16)
- {
+ } else if(e == LE16) {
BYTE b[2] = {0xff,0xfe};
Write(b, sizeof(b));
- }
- else if(e == BE16)
- {
+ } else if(e == BE16) {
BYTE b[2] = {0xfe,0xff};
Write(b, sizeof(b));
}
@@ -146,17 +138,16 @@ 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;
+ switch(nFrom) {
+ default:
+ case begin:
+ break;
+ case current:
+ lOff = pos + lOff;
+ break;
+ case end:
+ lOff = len - lOff;
+ break;
}
lOff = max(min(lOff, len), 0) + m_offset;
@@ -170,25 +161,16 @@ void CTextFile::WriteString(LPCSTR lpsz/*CStringA str*/)
{
CStringA str(lpsz);
- if(m_encoding == ASCII)
- {
+ if(m_encoding == ASCII) {
__super::WriteString(AToT(str));
- }
- else if(m_encoding == ANSI)
- {
+ } else if(m_encoding == ANSI) {
str.Replace("\n", "\r\n");
Write((LPCSTR)str, str.GetLength());
- }
- else if(m_encoding == UTF8)
- {
+ } else if(m_encoding == UTF8) {
WriteString(AToW(str));
- }
- else if(m_encoding == LE16)
- {
+ } else if(m_encoding == LE16) {
WriteString(AToW(str));
- }
- else if(m_encoding == BE16)
- {
+ } else if(m_encoding == BE16) {
WriteString(AToW(str));
}
}
@@ -197,57 +179,41 @@ void CTextFile::WriteString(LPCWSTR lpsz/*CStringW str*/)
{
CStringW str(lpsz);
- if(m_encoding == ASCII)
- {
+ if(m_encoding == ASCII) {
__super::WriteString(WToT(str));
- }
- else if(m_encoding == ANSI)
- {
+ } 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)
- {
+ } else if(m_encoding == UTF8) {
str.Replace(L"\n", L"\r\n");
- for(size_t i = 0; i < str.GetLength(); i++)
- {
+ for(size_t i = 0; i < str.GetLength(); i++) {
DWORD c = (WORD)str[i];
- if(0 <= c && c < 0x80) // 0xxxxxxx
- {
+ if(0 <= c && c < 0x80) { // 0xxxxxxx
Write(&c, 1);
- }
- else if(0x80 <= c && c < 0x800) // 110xxxxx 10xxxxxx
- {
+ } 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
- {
+ } 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
- {
+ } else {
c = '?';
Write(&c, 1);
}
}
- }
- else if(m_encoding == LE16)
- {
+ } else if(m_encoding == LE16) {
str.Replace(L"\n", L"\r\n");
Write((LPCWSTR)str, str.GetLength()*2);
- }
- else if(m_encoding == BE16)
- {
+ } else if(m_encoding == BE16) {
str.Replace(L"\n", L"\r\n");
- for(size_t i = 0; i < str.GetLength(); i++)
+ for(size_t i = 0; i < str.GetLength(); i++) {
str.SetAt(i, ((str[i]>>8)&0x00ff)|((str[i]<<8)&0xff00));
+ }
Write((LPCWSTR)str, str.GetLength()*2);
}
}
@@ -258,71 +224,79 @@ BOOL CTextFile::ReadString(CStringA& str)
str.Empty();
- if(m_encoding == ASCII)
- {
+ if(m_encoding == ASCII) {
CString s;
fEOF = !__super::ReadString(s);
str = TToA(s);
- }
- else if(m_encoding == ANSI)
- {
+ } else if(m_encoding == ANSI) {
char c;
- while(Read(&c, sizeof(c)) == sizeof(c))
- {
+ while(Read(&c, sizeof(c)) == sizeof(c)) {
fEOF = false;
- if(c == '\r') continue;
- if(c == '\n') break;
+ if(c == '\r') {
+ continue;
+ }
+ if(c == '\n') {
+ break;
+ }
str += c;
}
- }
- else if(m_encoding == UTF8)
- {
+ } else if(m_encoding == UTF8) {
BYTE b;
- while(Read(&b, sizeof(b)) == sizeof(b))
- {
+ while(Read(&b, sizeof(b)) == sizeof(b)) {
fEOF = false;
char c = '?';
- if(!(b&0x80)) // 0xxxxxxx
- {
+ 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;
+ }
}
- else if((b&0xe0) == 0xc0) // 110xxxxx 10xxxxxx
- {
- if(Read(&b, sizeof(b)) != sizeof(b)) break;
+ if(c == '\r') {
+ continue;
}
- 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 == '\n') {
+ break;
}
- if(c == '\r') continue;
- if(c == '\n') break;
str += c;
}
- }
- else if(m_encoding == LE16)
- {
+ } else if(m_encoding == LE16) {
WORD w;
- while(Read(&w, sizeof(w)) == sizeof(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;
+ if(!(w&0xff00)) {
+ c = w&0xff;
+ }
+ if(c == '\r') {
+ continue;
+ }
+ if(c == '\n') {
+ break;
+ }
str += c;
}
- }
- else if(m_encoding == BE16)
- {
+ } else if(m_encoding == BE16) {
WORD w;
- while(Read(&w, sizeof(w)) == sizeof(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;
+ if(!(w&0xff)) {
+ c = w>>8;
+ }
+ if(c == '\r') {
+ continue;
+ }
+ if(c == '\n') {
+ break;
+ }
str += c;
}
}
@@ -336,75 +310,79 @@ BOOL CTextFile::ReadString(CStringW& str)
str.Empty();
- if(m_encoding == ASCII)
- {
+ if(m_encoding == ASCII) {
CString s;
fEOF = !__super::ReadString(s);
str = TToW(s);
- }
- else if(m_encoding == ANSI)
- {
+ } else if(m_encoding == ANSI) {
CStringA stra;
char c;
- while(Read(&c, sizeof(c)) == sizeof(c))
- {
+ while(Read(&c, sizeof(c)) == sizeof(c)) {
fEOF = false;
- if(c == '\r') continue;
- if(c == '\n') break;
+ if(c == '\r') {
+ continue;
+ }
+ if(c == '\n') {
+ break;
+ }
stra += c;
}
str = CStringW(CString(stra)); // TODO: codepage
- }
- else if(m_encoding == UTF8)
- {
+ } else if(m_encoding == UTF8) {
BYTE b;
- while(Read(&b, sizeof(b)) == sizeof(b))
- {
+ while(Read(&b, sizeof(b)) == sizeof(b)) {
fEOF = false;
WCHAR c = '?';
- if(!(b&0x80)) // 0xxxxxxx
- {
+ if(!(b&0x80)) { // 0xxxxxxx
c = b&0x7f;
- }
- else if((b&0xe0) == 0xc0) // 110xxxxx 10xxxxxx
- {
+ } else if((b&0xe0) == 0xc0) { // 110xxxxx 10xxxxxx
c = (b&0x1f)<<6;
- if(Read(&b, sizeof(b)) != sizeof(b)) break;
+ if(Read(&b, sizeof(b)) != sizeof(b)) {
+ break;
+ }
c |= (b&0x3f);
- }
- else if((b&0xf0) == 0xe0) // 1110xxxx 10xxxxxx 10xxxxxx
- {
+ } else if((b&0xf0) == 0xe0) { // 1110xxxx 10xxxxxx 10xxxxxx
c = (b&0x0f)<<12;
- if(Read(&b, sizeof(b)) != sizeof(b)) break;
+ if(Read(&b, sizeof(b)) != sizeof(b)) {
+ break;
+ }
c |= (b&0x3f)<<6;
- if(Read(&b, sizeof(b)) != sizeof(b)) break;
+ if(Read(&b, sizeof(b)) != sizeof(b)) {
+ break;
+ }
c |= (b&0x3f);
}
- if(c == '\r') continue;
- if(c == '\n') break;
+ if(c == '\r') {
+ continue;
+ }
+ if(c == '\n') {
+ break;
+ }
str += c;
}
- }
- else if(m_encoding == LE16)
- {
+ } else if(m_encoding == LE16) {
WCHAR wc;
- while(Read(&wc, sizeof(wc)) == sizeof(wc))
- {
+ while(Read(&wc, sizeof(wc)) == sizeof(wc)) {
fEOF = false;
- if(wc == '\r') continue;
- if(wc == '\n') break;
+ if(wc == '\r') {
+ continue;
+ }
+ if(wc == '\n') {
+ break;
+ }
str += wc;
}
- }
- else if(m_encoding == BE16)
- {
+ } else if(m_encoding == BE16) {
WCHAR wc;
- while(Read(&wc, sizeof(wc)) == sizeof(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;
+ if(wc == '\r') {
+ continue;
+ }
+ if(wc == '\n') {
+ break;
+ }
str += wc;
}
}
@@ -425,41 +403,45 @@ bool CWebTextFile::Open(LPCTSTR lpszFileName)
{
CString fn(lpszFileName);
- if(fn.Find(_T("http://")) != 0)
+ if(fn.Find(_T("http://")) != 0) {
return __super::Open(lpszFileName);
+ }
- try
- {
+ try {
CInternetSession is;
CAutoPtr<CStdioFile> f(is.OpenURL(fn, 1, INTERNET_FLAG_TRANSFER_BINARY|INTERNET_FLAG_EXISTING_CONNECT));
- if(!f) return(false);
+ 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);
+ if(i > 0) {
+ fn = fn.Left(i);
+ }
CFile temp;
- if(!temp.Open(fn, modeCreate|modeWrite|typeBinary|shareDenyWrite))
- {
+ 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))
+ 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);
- 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)
- {
+ } catch(CInternetException* ie) {
ie->Delete();
return(false);
}
@@ -478,8 +460,7 @@ void CWebTextFile::Close()
{
__super::Close();
- if(!m_tempfn.IsEmpty())
- {
+ if(!m_tempfn.IsEmpty()) {
_tremove(m_tempfn);
m_tempfn.Empty();
}
@@ -490,32 +471,36 @@ void CWebTextFile::Close()
CStringW AToW(CStringA str)
{
CStringW ret;
- for(size_t i = 0, j = str.GetLength(); i < j; i++)
+ for(size_t i = 0, j = str.GetLength(); i < j; i++) {
ret += (WCHAR)(BYTE)str[i];
+ }
return(ret);
}
CStringA WToA(CStringW str)
{
CStringA ret;
- for(size_t i = 0, j = str.GetLength(); i < j; i++)
+ for(size_t i = 0, j = str.GetLength(); i < j; i++) {
ret += (CHAR)(WORD)str[i];
+ }
return(ret);
}
CString AToT(CStringA str)
{
CString ret;
- for(size_t i = 0, j = str.GetLength(); i < j; i++)
+ for(size_t i = 0, j = str.GetLength(); i < j; i++) {
ret += (TCHAR)(BYTE)str[i];
+ }
return(ret);
}
CString WToT(CStringW str)
{
CString ret;
- for(size_t i = 0, j = str.GetLength(); i < j; i++)
+ for(size_t i = 0, j = str.GetLength(); i < j; i++) {
ret += (TCHAR)(WORD)str[i];
+ }
return(ret);
}
@@ -523,8 +508,9 @@ CStringA TToA(CString str)
{
CStringA ret;
#ifdef UNICODE
- for(size_t i = 0, j = str.GetLength(); i < j; i++)
+ for(size_t i = 0, j = str.GetLength(); i < j; i++) {
ret += (CHAR)(BYTE)str[i];
+ }
#else
ret = str;
#endif
@@ -537,8 +523,9 @@ CStringW TToW(CString str)
#ifdef UNICODE
ret = str;
#else
- for(size_t i = 0, j = str.GetLength(); i < j; i++)
+ for(size_t i = 0, j = str.GetLength(); i < j; i++) {
ret += (WCHAR)(BYTE)str[i];
+ }
#endif
return(ret);
}
diff --git a/src/Subtitles/USFSubtitles.cpp b/src/Subtitles/USFSubtitles.cpp
index fe1edf730..a4f921049 100644
--- a/src/Subtitles/USFSubtitles.cpp
+++ b/src/Subtitles/USFSubtitles.cpp
@@ -64,10 +64,10 @@ static CStringW GetXML(CComPtr<IXMLDOMNode> pNode)
CStringW str(bstr);
str.Remove('\r');
str.Replace('\n', ' ');
- for(size_t i = 0; (i = str.Find(L" ", i)) >= 0; )
- {
- for(++i; i < str.GetLength() && (str[i] == ' ');)
+ for(size_t i = 0; (i = str.Find(L" ", i)) >= 0; ) {
+ for(++i; i < str.GetLength() && (str[i] == ' ');) {
str.Delete(i);
+ }
}
return(str);
}
@@ -76,12 +76,10 @@ static CStringW GetAttrib(CStringW attrib, CComPtr<IXMLDOMNode> pNode)
{
CStringW ret;
- BeginEnumAttribs(pNode, pChild)
- {
+ BeginEnumAttribs(pNode, pChild) {
DeclareNameAndValue(pChild, name, val);
- if(CStringW(name) == attrib && val.vt == VT_BSTR) // TODO: prepare for other types
- {
+ if(CStringW(name) == attrib && val.vt == VT_BSTR) { // TODO: prepare for other types
ret = val.bstrVal;
break;
}
@@ -95,22 +93,25 @@ 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))
+ for(CStringW token = str.Tokenize(L":.,", i); !token.IsEmpty(); token = str.Tokenize(L":.,", i)) {
sl.AddHead(token);
+ }
- if(sl.GetCount() > 4)
+ 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++)
- {
+ 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);
+ if(s >= tmp) {
+ return(-1);
+ }
time += t * mul[i];
}
@@ -119,23 +120,27 @@ static int TimeToInt(CStringW str)
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;
- if(str[0] == '#')
- {
+ if(str[0] == '#') {
ret = (DWORD)wcstol(str.TrimLeft('#'), NULL, 16);
- }
- else
- {
+ } else {
g_colors.Lookup(CString(str), ret);
}
@@ -163,10 +168,11 @@ static int TranslateMargin(CStringW margin, int wndsize)
{
int ret = 0;
- if(!margin.IsEmpty())
- {
+ if(!margin.IsEmpty()) {
ret = wcstol(margin, NULL, 10);
- if(margin.Find('%') >= 0) ret = wndsize * ret / 100;
+ if(margin.Find('%') >= 0) {
+ ret = wndsize * ret / 100;
+ }
}
return(ret);
@@ -187,63 +193,106 @@ 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)
+ || 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)))
+ if(!ParseUSFSubtitles(CComQIPtr<IXMLDOMNode>(pDoc))) {
return(false);
+ }
POSITION pos = styles.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
style_t* def = styles.GetNext(pos);
- if(def->name.CompareNoCase(L"Default"))
+ if(def->name.CompareNoCase(L"Default")) {
continue;
+ }
POSITION pos2 = styles.GetHeadPosition();
- while(pos2)
- {
+ while(pos2) {
style_t* s = styles.GetNext(pos2);
- if(!s->name.CompareNoCase(L"Default"))
+ 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];
+ 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)
- {
+ while(pos) {
text_t* t = texts.GetNext(pos);
- if(t->style.IsEmpty()) t->style = L"Default";
+ if(t->style.IsEmpty()) {
+ t->style = L"Default";
+ }
}
return(true);
@@ -261,12 +310,10 @@ bool CUSFSubtitles::ConvertToSTS(CSimpleTextSubtitle& sts)
int charSet = DEFAULT_CHARSET;
POSITION pos = styles.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
style_t* s = styles.GetNext(pos);
- if(!s->name.CompareNoCase(L"Default") && !s->fontstyle.wrap.IsEmpty())
- {
+ 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 :
@@ -274,26 +321,33 @@ bool CUSFSubtitles::ConvertToSTS(CSimpleTextSubtitle& sts)
}
STSStyle* stss = DNew STSStyle;
- if(!stss) continue;
+ if(!stss) {
+ continue;
+ }
- if(!s->pal.horizontal_margin.IsEmpty())
+ 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())
+ }
+ 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;
+ !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);
+ 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(ptrdiff_t i = 0; i < 4; i++)
- {
+ for(ptrdiff_t i = 0; i < 4; i++) {
DWORD color = ColorToDWORD(s->fontstyle.color[i]);
int alpha = (BYTE)wcstol(s->fontstyle.alpha, NULL, 10);
@@ -303,20 +357,36 @@ bool CUSFSubtitles::ConvertToSTS(CSimpleTextSubtitle& sts)
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.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);
+ !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;
@@ -324,12 +394,10 @@ bool CUSFSubtitles::ConvertToSTS(CSimpleTextSubtitle& sts)
}
pos = texts.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
text_t* t = texts.GetNext(pos);
- if(!t->pal.alignment.IsEmpty())
- {
+ if(!t->pal.alignment.IsEmpty()) {
CStringW s;
s.Format(L"{\\an%d}", TranslateAlignment(t->pal.alignment));
t->str = s + t->str;
@@ -338,37 +406,33 @@ bool CUSFSubtitles::ConvertToSTS(CSimpleTextSubtitle& sts)
CRect marginRect;
marginRect.SetRectEmpty();
- if(!t->pal.horizontal_margin.IsEmpty())
+ 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())
+ }
+ 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(ptrdiff_t i = 0; i < 3; i++)
- {
- if(int angle = wcstol(t->pal.rotate[i], NULL, 10))
- {
+ for(ptrdiff_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)
- {
+ if(t->style.CompareNoCase(L"Default") != 0) {
POSITION pos = styles.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
style_t* s = styles.GetNext(pos);
- if(s->name == t->style && !s->fontstyle.wrap.IsEmpty())
- {
+ 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)
- {
+ if(WrapStyle != sts.m_defaultWrapStyle) {
CStringW str;
str.Format(L"{\\q%d}", WrapStyle);
t->str = str + t->str;
@@ -391,16 +455,13 @@ bool CUSFSubtitles::ParseUSFSubtitles(CComPtr<IXMLDOMNode> pNode)
{
DeclareNameAndValue(pNode, name, val);
- if(name == L"usfsubtitles")
- {
+ if(name == L"usfsubtitles") {
// metadata
- BeginEnumChildren(pNode, pChild)
- {
+ BeginEnumChildren(pNode, pChild) {
DeclareNameAndValue(pChild, name, val);
- if(name == L"metadata")
- {
+ if(name == L"metadata") {
ParseMetadata(pChild, metadata);
}
}
@@ -408,21 +469,16 @@ bool CUSFSubtitles::ParseUSFSubtitles(CComPtr<IXMLDOMNode> pNode)
// styles
- BeginEnumChildren(pNode, pChild)
- {
+ BeginEnumChildren(pNode, pChild) {
DeclareNameAndValue(pChild, name, val);
- if(name == L"styles")
- {
- BeginEnumChildren(pChild, pGrandChild) // :)
- {
+ if(name == L"styles") {
+ BeginEnumChildren(pChild, pGrandChild) { // :)
DeclareNameAndValue(pGrandChild, name, val);
- if(name == L"style")
- {
+ if(name == L"style") {
CAutoPtr<style_t> s(DNew style_t);
- if(s)
- {
+ if(s) {
ParseStyle(pGrandChild, s);
styles.AddTail(s);
}
@@ -435,21 +491,16 @@ bool CUSFSubtitles::ParseUSFSubtitles(CComPtr<IXMLDOMNode> pNode)
// effects
- BeginEnumChildren(pNode, pChild)
- {
+ BeginEnumChildren(pNode, pChild) {
DeclareNameAndValue(pChild, name, val);
- if(name == L"effects")
- {
- BeginEnumChildren(pChild, pGrandChild) // :)
- {
+ if(name == L"effects") {
+ BeginEnumChildren(pChild, pGrandChild) { // :)
DeclareNameAndValue(pGrandChild, name, val);
- if(name == L"effect")
- {
+ if(name == L"effect") {
CAutoPtr<effect_t> e(DNew effect_t);
- if(e)
- {
+ if(e) {
ParseEffect(pGrandChild, e);
effects.AddTail(e);
}
@@ -462,23 +513,20 @@ bool CUSFSubtitles::ParseUSFSubtitles(CComPtr<IXMLDOMNode> pNode)
// subtitles
- BeginEnumChildren(pNode, pChild)
- {
+ BeginEnumChildren(pNode, pChild) {
DeclareNameAndValue(pChild, name, val);
- if(name == L"subtitles")
- {
- BeginEnumChildren(pChild, pGrandChild) // :)
- {
+ if(name == L"subtitles") {
+ BeginEnumChildren(pChild, pGrandChild) { // :)
DeclareNameAndValue(pGrandChild, name, val);
- if(name == L"subtitle")
- {
+ 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()))
+ if(sstart.IsEmpty() || (sstop.IsEmpty() && sduration.IsEmpty())) {
continue;
+ }
int start = TimeToInt(sstart);
int stop = !sstop.IsEmpty() ? TimeToInt(sstop) : (start + TimeToInt(sduration));
@@ -494,10 +542,8 @@ bool CUSFSubtitles::ParseUSFSubtitles(CComPtr<IXMLDOMNode> pNode)
return(true);
}
- BeginEnumChildren(pNode, pChild)
- {
- if(ParseUSFSubtitles(pChild))
- {
+ BeginEnumChildren(pNode, pChild) {
+ if(ParseUSFSubtitles(pChild)) {
return(true);
}
}
@@ -510,48 +556,36 @@ void CUSFSubtitles::ParseMetadata(CComPtr<IXMLDOMNode> pNode, metadata_t& m)
{
DeclareNameAndValue(pNode, name, val);
- if(name == L"title")
- {
+ if(name == L"title") {
m.title = GetText(pNode);
- }
- else if(name == L"date")
- {
+ } else if(name == L"date") {
m.date = GetText(pNode);
- }
- else if(name == L"comment")
- {
+ } else if(name == L"comment") {
m.comment = GetText(pNode);
- }
- else if(name == L"author")
- {
- BeginEnumChildren(pNode, pChild)
- {
+ } else if(name == L"author") {
+ BeginEnumChildren(pNode, pChild) {
DeclareNameAndValue(pChild, name, val);
- if(name == L"name")
+ if(name == L"name") {
m.author.name = GetText(pChild);
- else if(name == L"email")
+ } else if(name == L"email") {
m.author.email = GetText(pChild);
- else if(name == L"url")
+ } else if(name == L"url") {
m.author.url = GetText(pChild);
+ }
}
EndEnumChildren
return;
- }
- else if(name == L"language")
- {
+ } else if(name == L"language") {
m.language.text = GetText(pNode);
m.language.code = GetAttrib(L"code", pNode);
- }
- else if(name == L"languageext")
- {
+ } else if(name == L"languageext") {
m.languageext.text = GetText(pNode);
m.languageext.code = GetAttrib(L"code", pNode);
}
- BeginEnumChildren(pNode, pChild)
- {
+ BeginEnumChildren(pNode, pChild) {
ParseMetadata(pChild, metadata);
}
EndEnumChildren
@@ -561,23 +595,17 @@ void CUSFSubtitles::ParseStyle(CComPtr<IXMLDOMNode> pNode, style_t* s)
{
DeclareNameAndValue(pNode, name, val);
- if(name == L"style")
- {
+ if(name == L"style") {
s->name = GetAttrib(L"name", pNode);
- }
- else if(name == L"fontstyle")
- {
+ } else if(name == L"fontstyle") {
ParseFontstyle(pNode, s->fontstyle);
return;
- }
- else if(name == L"position")
- {
+ } else if(name == L"position") {
ParsePal(pNode, s->pal);
return;
}
- BeginEnumChildren(pNode, pChild)
- {
+ BeginEnumChildren(pNode, pChild) {
ParseStyle(pChild, s);
}
EndEnumChildren
@@ -615,21 +643,15 @@ void CUSFSubtitles::ParseEffect(CComPtr<IXMLDOMNode> pNode, effect_t* e)
{
DeclareNameAndValue(pNode, name, val);
- if(name == L"effect")
- {
+ if(name == L"effect") {
e->name = GetAttrib(L"name", pNode);
- }
- else if(name == L"keyframes")
- {
- BeginEnumChildren(pNode, pChild)
- {
+ } else if(name == L"keyframes") {
+ BeginEnumChildren(pNode, pChild) {
DeclareNameAndValue(pChild, name, val);
- if(name == L"keyframe")
- {
+ if(name == L"keyframe") {
CAutoPtr<keyframe_t> k(DNew keyframe_t);
- if(k)
- {
+ if(k) {
ParseKeyframe(pChild, k);
e->keyframes.AddTail(k);
}
@@ -640,8 +662,7 @@ void CUSFSubtitles::ParseEffect(CComPtr<IXMLDOMNode> pNode, effect_t* e)
return;
}
- BeginEnumChildren(pNode, pChild)
- {
+ BeginEnumChildren(pNode, pChild) {
ParseEffect(pChild, e);
}
EndEnumChildren
@@ -651,17 +672,12 @@ void CUSFSubtitles::ParseKeyframe(CComPtr<IXMLDOMNode> pNode, keyframe_t* k)
{
DeclareNameAndValue(pNode, name, val);
- if(name == L"keyframe")
- {
+ if(name == L"keyframe") {
k->position = GetAttrib(L"position", pNode);
- }
- else if(name == L"fontstyle")
- {
+ } else if(name == L"fontstyle") {
ParseFontstyle(pNode, k->fontstyle);
return;
- }
- else if(name == L"position")
- {
+ } else if(name == L"position") {
ParsePal(pNode, k->pal);
return;
}
@@ -671,11 +687,9 @@ void CUSFSubtitles::ParseSubtitle(CComPtr<IXMLDOMNode> pNode, int start, int sto
{
DeclareNameAndValue(pNode, name, val);
- if(name == L"text" || name == L"karaoke")
- {
+ if(name == L"text" || name == L"karaoke") {
CAutoPtr<text_t> t(DNew text_t);
- if(t)
- {
+ if(t) {
t->start = start;
t->stop = stop;
t->style = GetAttrib(L"style", pNode);
@@ -687,10 +701,9 @@ void CUSFSubtitles::ParseSubtitle(CComPtr<IXMLDOMNode> pNode, int start, int sto
return;
}
-// else if
+ // else if
- BeginEnumChildren(pNode, pChild)
- {
+ BeginEnumChildren(pNode, pChild) {
ParseSubtitle(pChild, start, stop);
}
EndEnumChildren
@@ -702,51 +715,38 @@ void CUSFSubtitles::ParseText(CComPtr<IXMLDOMNode> pNode, CStringW& str)
CStringW prefix, postfix;
- if(name == L"b")
- {
+ if(name == L"b") {
prefix = L"{\\b1}";
postfix = L"{\\b}";
- }
- else if(name == L"i")
- {
+ } else if(name == L"i") {
prefix = L"{\\i1}";
postfix = L"{\\i}";
- }
- else if(name == L"u")
- {
+ } else if(name == L"u") {
prefix = L"{\\u1}";
postfix = L"{\\u}";
- }
- else if(name == L"font")
- {
+ } else if(name == L"font") {
fontstyle_t fs;
ParseFontstyle(pNode, fs);
- if(!fs.face.IsEmpty())
- {
+ if(!fs.face.IsEmpty()) {
prefix += L"{\\fn" + fs.face + L"}";
postfix += L"{\\fn}";
}
- if(!fs.size.IsEmpty())
- {
+ if(!fs.size.IsEmpty()) {
prefix += L"{\\fs" + fs.size + L"}";
postfix += L"{\\fs}";
}
- if(!fs.outline.IsEmpty())
- {
+ if(!fs.outline.IsEmpty()) {
prefix += L"{\\bord" + fs.outline + L"}";
postfix += L"{\\bord}";
}
- if(!fs.shadow.IsEmpty())
- {
+ if(!fs.shadow.IsEmpty()) {
prefix += L"{\\shad" + fs.shadow + L"}";
postfix += L"{\\shad}";
}
- for(ptrdiff_t i = 0; i < 4; i++)
- {
- if(!fs.color[i].IsEmpty())
- {
+ for(ptrdiff_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;
@@ -754,28 +754,21 @@ void CUSFSubtitles::ParseText(CComPtr<IXMLDOMNode> pNode, CStringW& str)
postfix += s;
}
}
- }
- else if(name == L"k")
- {
+ } 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")
- {
+ } else if(name == L"br") {
str += L"\\N";
return;
- }
- else if(name == L"#text")
- {
+ } else if(name == L"#text") {
str += GetXML(pNode);
return;
}
- BeginEnumChildren(pNode, pChild)
- {
+ BeginEnumChildren(pNode, pChild) {
CStringW s;
ParseText(pChild, s);
str += s;
diff --git a/src/Subtitles/USFSubtitles.h b/src/Subtitles/USFSubtitles.h
index ddae59bbd..8470192cb 100644
--- a/src/Subtitles/USFSubtitles.h
+++ b/src/Subtitles/USFSubtitles.h
@@ -27,50 +27,41 @@
#include "STS.h"
// metadata
-typedef struct
-{
+typedef struct {
CStringW name, email, url;
} author_t;
-typedef struct
-{
+typedef struct {
CStringW code, text;
} language_t;
-typedef struct
-{
+typedef struct {
CStringW title, date, comment;
author_t author;
language_t language, languageext;
} metadata_t;
// style
-typedef struct
-{
+typedef struct {
CStringW alignment, relativeto, horizontal_margin, vertical_margin, rotate[3];
} posattriblist_t;
-typedef struct
-{
+typedef struct {
CStringW face, size, color[4], weight, italic, underline, alpha, outline, shadow, wrap;
} fontstyle_t;
-typedef struct
-{
+typedef struct {
CStringW name;
fontstyle_t fontstyle;
posattriblist_t pal;
} style_t;
// effect
-typedef struct
-{
+typedef struct {
CStringW position;
fontstyle_t fontstyle;
posattriblist_t pal;
} keyframe_t;
-typedef struct
-{
+typedef struct {
CStringW name;
CAutoPtrList<keyframe_t> keyframes;
} effect_t;
// subtitle/text
-typedef struct
-{
+typedef struct {
int start, stop;
CStringW effect, style, str;
posattriblist_t pal;
@@ -94,7 +85,7 @@ public:
virtual ~CUSFSubtitles();
bool Read(LPCTSTR fn);
-// bool Write(LPCTSTR fn); // TODO
+ // bool Write(LPCTSTR fn); // TODO
metadata_t metadata;
CAutoPtrList<style_t> styles;
@@ -102,5 +93,5 @@ public:
CAutoPtrList<text_t> texts;
bool ConvertToSTS(CSimpleTextSubtitle& sts);
-// bool ConvertFromSTS(CSimpleTextSubtitle& sts); // TODO
+ // bool ConvertFromSTS(CSimpleTextSubtitle& sts); // TODO
};
diff --git a/src/Subtitles/VobSubFile.cpp b/src/Subtitles/VobSubFile.cpp
index ab9cb9c5a..cdd3a480d 100644
--- a/src/Subtitles/VobSubFile.cpp
+++ b/src/Subtitles/VobSubFile.cpp
@@ -32,8 +32,7 @@
struct lang_type {
unsigned short id;
LPCSTR lang_long;
-} lang_tbl[] =
-{
+} lang_tbl[] = {
{'--', "(Not detected)"},
{'cc', "Closed Caption"},
{'aa', "Afar"},
@@ -184,12 +183,15 @@ int find_lang(unsigned short id)
{
int mid, lo = 0, hi = countof(lang_tbl) - 1;
- while(lo < hi)
- {
+ 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);
+ 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);
@@ -227,8 +229,7 @@ bool CVobSubFile::Copy(CVobSubFile& vsf)
m_sub.SetLength(vsf.m_sub.GetLength());
m_sub.SeekToBegin();
- for(ptrdiff_t i = 0; i < 32; i++)
- {
+ for(ptrdiff_t i = 0; i < 32; i++) {
SubLang& src = vsf.m_langs[i];
SubLang& dst = m_langs[i];
@@ -236,13 +237,15 @@ bool CVobSubFile::Copy(CVobSubFile& vsf)
dst.name = src.name;
dst.alt = src.alt;
- for(ptrdiff_t j = 0; j < src.subpos.GetCount(); j++)
- {
+ for(ptrdiff_t j = 0; j < src.subpos.GetCount(); j++) {
SubPos& sp = src.subpos[j];
- if(!sp.fValid) continue;
+ if(!sp.fValid) {
+ continue;
+ }
- if(sp.filepos != (__int64)vsf.m_sub.Seek(sp.filepos, CFile::begin))
+ if(sp.filepos != (__int64)vsf.m_sub.Seek(sp.filepos, CFile::begin)) {
continue;
+ }
sp.filepos = m_sub.GetPosition();
@@ -254,16 +257,15 @@ bool CVobSubFile::Copy(CVobSubFile& vsf)
for(ptrdiff_t k = 0, size, sizeleft = packetsize - 4;
k < packetsize - 4;
- k += size, sizeleft -= size)
- {
+ 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);
@@ -284,12 +286,12 @@ bool CVobSubFile::Copy(CVobSubFile& vsf)
void CVobSubFile::TrimExtension(CString& fn)
{
int i = fn.ReverseFind('.');
- if(i > 0)
- {
+ 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"))
+ || ext == _T(".sst") || ext == _T(".son") || ext == _T(".rar")) {
fn = fn.Left(i);
+ }
}
}
@@ -297,52 +299,56 @@ bool CVobSubFile::Open(CString fn)
{
TrimExtension(fn);
- do
- {
+ do {
Close();
int ver;
- if(!ReadIdx(fn + _T(".idx"), ver))
+ if(!ReadIdx(fn + _T(".idx"), ver)) {
break;
+ }
- if(ver < 6 && !ReadIfo(fn + _T(".ifo")))
+ if(ver < 6 && !ReadIfo(fn + _T(".ifo"))) {
break;
+ }
- if(!ReadSub(fn + _T(".sub")) && !ReadRar(fn + _T(".rar")))
+ if(!ReadSub(fn + _T(".sub")) && !ReadRar(fn + _T(".rar"))) {
break;
+ }
m_title = fn;
- for(ptrdiff_t i = 0; i < 32; i++)
- {
+ for(ptrdiff_t i = 0; i < 32; i++) {
CAtlArray<SubPos>& sp = m_langs[i].subpos;
- for(ptrdiff_t j = 0; j < sp.GetCount(); j++)
- {
+ for(ptrdiff_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(j, packetsize, datasize, i);
- if(!buff) continue;
+ if(!buff) {
+ continue;
+ }
m_img.delay = j < (sp.GetCount()-1) ? sp[j+1].start - sp[j].start : 3000;
m_img.GetPacketInfo(buff, packetsize, datasize);
- if(j < (sp.GetCount()-1)) m_img.delay = min(m_img.delay, sp[j+1].start - sp[j].start);
+ if(j < (sp.GetCount()-1)) {
+ 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;
- if(j > 0 && 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;
}
}
return(true);
- }
- while(false);
+ } while(false);
Close();
@@ -354,25 +360,25 @@ bool CVobSubFile::Save(CString fn, SubFormat sf)
TrimExtension(fn);
CVobSubFile vsf(NULL);
- if(!vsf.Copy(*this))
+ 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;
+ 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);
@@ -385,8 +391,7 @@ void CVobSubFile::Close()
m_sub.SetLength(0);
m_img.Invalidate();
m_iLang = -1;
- for(ptrdiff_t i = 0; i < 32; i++)
- {
+ for(ptrdiff_t i = 0; i < 32; i++) {
m_langs[i].id = 0;
m_langs[i].name.Empty();
m_langs[i].alt.Empty();
@@ -399,8 +404,9 @@ void CVobSubFile::Close()
bool CVobSubFile::ReadIdx(CString fn, int& ver)
{
CWebTextFile f;
- if(!f.Open(fn))
+ if(!f.Open(fn)) {
return(false);
+ }
bool fError = false;
@@ -408,38 +414,30 @@ bool CVobSubFile::ReadIdx(CString fn, int& ver)
__int64 celltimestamp = 0;
CString str;
- for(ptrdiff_t line = 0; !fError && f.ReadString(str); line++)
- {
+ for(ptrdiff_t line = 0; !fError && f.ReadString(str); line++) {
str.Trim();
- if(line == 0)
- {
+ if(line == 0) {
TCHAR buff[] = _T("VobSub index file, v");
const TCHAR* s = str;
int i = str.Find(buff);
if(i < 0 || _stscanf(&s[i+_tcslen(buff)], _T("%d"), &ver) != 1
- || ver > VOBSUBIDXVER)
- {
+ || ver > VOBSUBIDXVER) {
AfxMessageBox(_T("Wrong file version!"));
fError = true;
continue;
}
- }
- else if(!str.GetLength())
- {
+ } else if(!str.GetLength()) {
continue;
- }
- else if(str[0] == _T('#'))
- {
+ } else if(str[0] == _T('#')) {
TCHAR buff[] = _T("Vob/Cell ID:");
const TCHAR* s = str;
int i = str.Find(buff);
- if(i >= 0)
- {
+ if(i >= 0) {
_stscanf(&s[i+_tcslen(buff)], _T("%d, %d (PTS: %d)"), &vobid, &cellid, &celltimestamp);
}
@@ -447,96 +445,110 @@ bool CVobSubFile::ReadIdx(CString fn, int& ver)
}
int i = str.Find(':');
- if(i <= 0) continue;
+ if(i <= 0) {
+ continue;
+ }
CString entry = str.Left(i).MakeLower();
str = str.Mid(i+1);
str.Trim();
- if(str.IsEmpty()) continue;
+ if(str.IsEmpty()) {
+ continue;
+ }
- if(entry == _T("size"))
- {
+ if(entry == _T("size")) {
int x, y;
- if(_stscanf(str, _T("%dx%d"), &x, &y) != 2) fError = true;
+ if(_stscanf(str, _T("%dx%d"), &x, &y) != 2) {
+ fError = true;
+ }
m_size.cx = x;
m_size.cy = y;
- }
- else if(entry == _T("org"))
- {
- if(_stscanf(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)
- {
+ } else if(entry == _T("org")) {
+ if(_stscanf(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(str, _T("%d%%"), &scale) != 1) fError = true;
+ if(_stscanf(str, _T("%d%%"), &scale) != 1) {
+ fError = true;
+ }
m_scale_x = m_scale_y = scale;
+ } else {
+ if(_stscanf(str, _T("%d%%,%d%%"), &m_scale_x, &m_scale_y) != 2) {
+ fError = true;
+ }
}
- else
- {
- if(_stscanf(str, _T("%d%%,%d%%"), &m_scale_x, &m_scale_y) != 2) fError = true;
+ } else if(entry == _T("alpha")) {
+ if(_stscanf(str, _T("%d"), &m_alpha) != 1) {
+ fError = true;
}
- }
- else if(entry == _T("alpha"))
- {
- if(_stscanf(str, _T("%d"), &m_alpha) != 1) fError = true;
- }
- else if(entry == _T("smooth"))
- {
+ } 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(str, _T("%d,%d"), &m_fadein, &m_fadeout) != 2) fError = true;
- }
- else if(entry == _T("align"))
- {
+ 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(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)
- {
+ 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;
+ 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"))
- {
+ } else if(entry == _T("time offset")) {
bool fNegative = false;
- if(str[0] == '-') fNegative = true;
+ if(str[0] == '-') {
+ fNegative = true;
+ }
str.TrimLeft(_T("+-"));
TCHAR c;
@@ -548,35 +560,39 @@ bool CVobSubFile::ReadIdx(CString fn, int& ver)
: 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"))
- {
+ } 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(str, _T("%d"), &m_iLang) != 1) fError = true;
- }
- else if(entry == _T("palette"))
- {
+ 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(str, _T("%d"), &m_iLang) != 1) {
+ fError = true;
+ }
+ } else if(entry == _T("palette")) {
if(_stscanf(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"))
- {
+ ) != 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;
+ 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) {
@@ -606,9 +622,7 @@ bool CVobSubFile::ReadIdx(CString fn, int& ver)
}
SetCustomPal(pal, tridx);
- }
- else if(entry == _T("id"))
- {
+ } else if(entry == _T("id")) {
str.MakeLower();
int langid = ((str[0]&0xff)<<8)|(str[1]&0xff);
@@ -624,22 +638,22 @@ bool CVobSubFile::ReadIdx(CString fn, int& ver)
fError = true;
continue;
}
- if(m_iLang < 0) m_iLang = id;
+ 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"))
- {
+ } else if(id >= 0 && entry == _T("alt")) {
m_langs[id].alt = str;
- }
- else if(id >= 0 && entry == _T("delay"))
- {
+ } else if(id >= 0 && entry == _T("delay")) {
bool fNegative = false;
- if(str[0] == '-') fNegative = true;
+ if(str[0] == '-') {
+ fNegative = true;
+ }
str.TrimLeft(_T("+-"));
TCHAR c;
@@ -650,9 +664,7 @@ bool CVobSubFile::ReadIdx(CString fn, int& ver)
}
delay += (hh*60*60*1000 + mm*60*1000 + ss*1000 + ms) * (fNegative ? -1 : 1);
- }
- else if(id >= 0 && entry == _T("timestamp"))
- {
+ } else if(id >= 0 && entry == _T("timestamp")) {
SubPos sb;
sb.vobid = vobid;
@@ -661,7 +673,9 @@ bool CVobSubFile::ReadIdx(CString fn, int& ver)
sb.fValid = true;
bool fNegative = false;
- if(str[0] == '-') fNegative = true;
+ if(str[0] == '-') {
+ fNegative = true;
+ }
str.TrimLeft(_T("+-"));
TCHAR c;
@@ -685,20 +699,19 @@ bool CVobSubFile::ReadIdx(CString fn, int& ver)
continue;
}
- if(delay < 0 && m_langs[id].subpos.GetCount() > 0)
- {
+ 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)
- {
+ if(sb.start < ts) {
delay += (int)(ts - sb.start);
sb.start = ts;
}
}
m_langs[id].subpos.Add(sb);
+ } else {
+ fError = true;
}
- else fError = true;
}
return(!fError);
@@ -707,16 +720,18 @@ bool CVobSubFile::ReadIdx(CString fn, int& ver)
bool CVobSubFile::ReadSub(CString fn)
{
CFile f;
- if(!f.Open(fn, CFile::modeRead|CFile::typeBinary|CFile::shareDenyNone))
+ if(!f.Open(fn, CFile::modeRead|CFile::typeBinary|CFile::shareDenyNone)) {
return(false);
+ }
m_sub.SetLength(f.GetLength());
m_sub.SeekToBegin();
int len;
BYTE buff[2048];
- while((len = f.Read(buff, sizeof(buff))) > 0 && *(DWORD*)buff == 0xba010000)
+ while((len = f.Read(buff, sizeof(buff))) > 0 && *(DWORD*)buff == 0xba010000) {
m_sub.Write(buff, len);
+ }
return(true);
}
@@ -741,7 +756,9 @@ bool CVobSubFile::ReadRar(CString fn)
#else
HMODULE h = LoadLibrary(_T("unrar.dll"));
#endif
- if(!h) return(false);
+ if(!h) {
+ return(false);
+ }
RAROpenArchiveEx OpenArchiveEx = (RAROpenArchiveEx)GetProcAddress(h, "RAROpenArchiveEx");
RARCloseArchive CloseArchive = (RARCloseArchive)GetProcAddress(h, "RARCloseArchive");
@@ -752,8 +769,7 @@ bool CVobSubFile::ReadRar(CString fn)
RARSetPassword SetPassword = (RARSetPassword)GetProcAddress(h, "RARSetPassword");
if(!(OpenArchiveEx && CloseArchive && ReadHeaderEx && ProcessFile
- && SetChangeVolProc && SetProcessDataProc && SetPassword))
- {
+ && SetChangeVolProc && SetProcessDataProc && SetPassword)) {
FreeLibrary(h);
return(false);
}
@@ -763,7 +779,9 @@ bool CVobSubFile::ReadRar(CString fn)
#ifdef UNICODE
ArchiveDataEx.ArcNameW = (LPTSTR)(LPCTSTR)fn;
char fnA[_MAX_PATH];
- if(wcstombs(fnA, fn, fn.GetLength()+1) == -1) fnA[0] = 0;
+ if(wcstombs(fnA, fn, fn.GetLength()+1) == -1) {
+ fnA[0] = 0;
+ }
ArchiveDataEx.ArcName = fnA;
#else
ArchiveDataEx.ArcName = (LPTSTR)(LPCTSTR)fn;
@@ -771,8 +789,7 @@ bool CVobSubFile::ReadRar(CString fn)
ArchiveDataEx.OpenMode = RAR_OM_EXTRACT;
ArchiveDataEx.CmtBuf = 0;
HANDLE hrar = OpenArchiveEx(&ArchiveDataEx);
- if(!hrar)
- {
+ if(!hrar) {
FreeLibrary(h);
return(false);
}
@@ -782,19 +799,16 @@ bool CVobSubFile::ReadRar(CString fn)
struct RARHeaderDataEx HeaderDataEx;
HeaderDataEx.CmtBuf = NULL;
- while(ReadHeaderEx(hrar, &HeaderDataEx) == 0)
- {
+ while(ReadHeaderEx(hrar, &HeaderDataEx) == 0) {
#ifdef UNICODE
CString subfn(HeaderDataEx.FileNameW);
#else
CString subfn(HeaderDataEx.FileName);
#endif
- if(!subfn.Right(4).CompareNoCase(_T(".sub")))
- {
+ if(!subfn.Right(4).CompareNoCase(_T(".sub"))) {
CAutoVectorPtr<BYTE> buff;
- if(!buff.Allocate(HeaderDataEx.UnpSize))
- {
+ if(!buff.Allocate(HeaderDataEx.UnpSize)) {
CloseArchive(hrar);
FreeLibrary(h);
return(false);
@@ -803,8 +817,7 @@ bool CVobSubFile::ReadRar(CString fn)
RARbuff = buff;
RARpos = 0;
- if(ProcessFile(hrar, RAR_TEST, NULL, NULL))
- {
+ if(ProcessFile(hrar, RAR_TEST, NULL, NULL)) {
CloseArchive(hrar);
FreeLibrary(h);
@@ -840,8 +853,9 @@ bool CVobSubFile::ReadRar(CString fn)
bool CVobSubFile::ReadIfo(CString fn)
{
CFile f;
- if(!f.Open(fn, CFile::modeRead|CFile::typeBinary|CFile::shareDenyNone))
+ if(!f.Open(fn, CFile::modeRead|CFile::typeBinary|CFile::shareDenyNone)) {
return(false);
+ }
/* PGC1 */
@@ -859,8 +873,7 @@ bool CVobSubFile::ReadIfo(CString fn)
f.Seek(pos*0x800 + offset + 0xa4, CFile::begin);
- for(ptrdiff_t i = 0; i < 16; i++)
- {
+ for(ptrdiff_t i = 0; i < 16; i++) {
BYTE y, u, v, tmp;
f.Read(&tmp, 1);
@@ -881,8 +894,9 @@ bool CVobSubFile::ReadIfo(CString fn)
bool CVobSubFile::WriteIdx(CString fn)
{
CTextFile f;
- if(!f.Save(fn, CTextFile::ASCII))
+ 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);
@@ -989,35 +1003,40 @@ bool CVobSubFile::WriteIdx(CString fn)
// Subs
- for(ptrdiff_t i = 0; i < 32; i++)
- {
+ for(ptrdiff_t i = 0; i < 32; i++) {
SubLang& sl = m_langs[i];
CAtlArray<SubPos>& sp = sl.subpos;
- if(sp.IsEmpty() && !sl.id) continue;
+ if(sp.IsEmpty() && !sl.id) {
+ continue;
+ }
str.Format(_T("# %s\n"), sl.name);
f.WriteString(str);
ASSERT(sl.id);
- if(!sl.id) 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.Format(_T("# Decomment 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;
+ if(sl.name == sl.alt) {
+ str = _T("# ") + str;
+ }
f.WriteString(str);
char vobid = -1, cellid = -1;
- for(ptrdiff_t j = 0; j < sp.GetCount(); j++)
- {
- if(!sp[j].fValid) continue;
+ for(ptrdiff_t j = 0; j < sp.GetCount(); j++) {
+ if(!sp[j].fValid) {
+ continue;
+ }
- if(sp[j].vobid != vobid || sp[j].cellid != cellid)
- {
+ 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;
@@ -1043,18 +1062,21 @@ bool CVobSubFile::WriteIdx(CString fn)
bool CVobSubFile::WriteSub(CString fn)
{
CFile f;
- if(!f.Open(fn, CFile::modeCreate|CFile::modeWrite|CFile::typeBinary|CFile::shareDenyWrite))
+ 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();
int len;
BYTE buff[2048];
- while((len = m_sub.Read(buff, sizeof(buff))) > 0 && *(DWORD*)buff == 0xba010000)
+ while((len = m_sub.Read(buff, sizeof(buff))) > 0 && *(DWORD*)buff == 0xba010000) {
f.Write(buff, len);
+ }
return(true);
}
@@ -1065,77 +1087,86 @@ BYTE* CVobSubFile::GetPacket(int idx, int& packetsize, int& datasize, int iLang)
{
BYTE* ret = NULL;
- if(iLang < 0 || iLang >= 32) iLang = m_iLang;
+ if(iLang < 0 || iLang >= 32) {
+ iLang = m_iLang;
+ }
CAtlArray<SubPos>& sp = m_langs[iLang].subpos;
- do
- {
- if(idx < 0 || idx >= sp.GetCount())
+ do {
+ if(idx < 0 || idx >= sp.GetCount()) {
break;
+ }
- if((__int64)m_sub.Seek(sp[idx].filepos, CFile::begin) != sp[idx].filepos)
+ 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)))
+ 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)
+ || *(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;
+ if(!ret) {
+ break;
+ }
int i = 0, sizeleft = packetsize;
for(ptrdiff_t size;
i < packetsize;
- i += size, sizeleft -= size)
- {
+ 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))
+ 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)
+ if(i != packetsize || sizeleft > 0) {
delete [] ret, ret = NULL;
- }
- while(false);
+ }
+ } while(false);
return(ret);
}
bool CVobSubFile::GetFrame(int idx, int iLang)
{
- if(iLang < 0 || iLang >= 32) iLang = m_iLang;
+ if(iLang < 0 || iLang >= 32) {
+ iLang = m_iLang;
+ }
CAtlArray<SubPos>& sp = m_langs[iLang].subpos;
- if(idx < 0 || idx >= sp.GetCount())
+ if(idx < 0 || idx >= sp.GetCount()) {
return(false);
+ }
- if(m_img.iLang != iLang || m_img.iIdx != idx)
- {
+ 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(!buff || packetsize <= 0 || datasize <= 0) {
+ return(false);
+ }
m_img.start = sp[idx].start;
m_img.delay = idx < (sp.GetCount()-1)
@@ -1144,10 +1175,13 @@ bool CVobSubFile::GetFrame(int idx, int iLang)
bool ret = m_img.Decode(buff, packetsize, datasize, m_fCustomPal, m_tridx, m_orgpal, m_cuspal, true);
- if(idx < (sp.GetCount()-1))
+ if(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;
@@ -1163,36 +1197,36 @@ bool CVobSubFile::GetFrameByTimeStamp(__int64 time)
int CVobSubFile::GetFrameIdxByTimeStamp(__int64 time)
{
- if(m_iLang < 0 || m_iLang >= 32)
+ if(m_iLang < 0 || m_iLang >= 32) {
return(-1);
+ }
CAtlArray<SubPos>& sp = m_langs[m_iLang].subpos;
int i = 0, j = (int)sp.GetCount() - 1, ret = -1;
- if(j >= 0 && time >= sp[j].start)
+ if(j >= 0 && time >= sp[j].start) {
return(j);
+ }
- while(i < j)
- {
+ while(i < j) {
int mid = (i + j) >> 1;
int midstart = (int)sp[mid].start;
- if(time == midstart)
- {
+ if(time == midstart) {
ret = mid;
break;
- }
- else if(time < midstart)
- {
+ } else if(time < midstart) {
ret = -1;
- if(j == mid) mid--;
+ if(j == mid) {
+ mid--;
+ }
j = mid;
- }
- else if(time > midstart)
- {
+ } else if(time > midstart) {
ret = mid;
- if(i == mid) mid++;
+ if(i == mid) {
+ mid++;
+ }
i = mid;
}
}
@@ -1224,13 +1258,14 @@ STDMETHODIMP_(POSITION) CVobSubFile::GetStartPosition(REFERENCE_TIME rt, double
int i = GetFrameIdxByTimeStamp(rt);
- if(!GetFrame(i))
+ if(!GetFrame(i)) {
return(NULL);
+ }
- if(rt >= (m_img.start + m_img.delay))
- {
- if(!GetFrame(++i))
+ if(rt >= (m_img.start + m_img.delay)) {
+ if(!GetFrame(++i)) {
return(NULL);
+ }
}
return((POSITION)(i+1));
@@ -1261,15 +1296,19 @@ STDMETHODIMP_(bool) CVobSubFile::IsAnimated(POSITION pos)
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;
- if(!GetFrame(GetFrameIdxByTimeStamp(rt)))
+ if(!GetFrame(GetFrameIdxByTimeStamp(rt))) {
return E_FAIL;
+ }
- if(rt >= (m_img.start + m_img.delay))
+ if(rt >= (m_img.start + m_img.delay)) {
return E_FAIL;
+ }
return __super::Render(spd, bbox);
}
@@ -1287,30 +1326,31 @@ STDMETHODIMP_(int) CVobSubFile::GetStreamCount()
{
int iStreamCount = 0;
for(ptrdiff_t i = 0; i < 32; i++)
- if(m_langs[i].subpos.GetCount()) iStreamCount++;
+ if(m_langs[i].subpos.GetCount()) {
+ iStreamCount++;
+ }
return(iStreamCount);
}
STDMETHODIMP CVobSubFile::GetStreamInfo(int iStream, WCHAR** ppName, LCID* pLCID)
{
- for(ptrdiff_t i = 0; i < 32; i++)
- {
+ for(ptrdiff_t i = 0; i < 32; i++) {
SubLang& sl = m_langs[i];
- if(sl.subpos.IsEmpty() || iStream-- > 0)
+ if(sl.subpos.IsEmpty() || iStream-- > 0) {
continue;
+ }
- if(ppName)
- {
+ if(ppName) {
*ppName = (WCHAR*)CoTaskMemAlloc((sl.alt.GetLength() + 1) * sizeof(WCHAR));
- if(!(*ppName))
+ if(!(*ppName)) {
return E_OUTOFMEMORY;
+ }
wcscpy(*ppName, CStringW(sl.alt));
}
- if(pLCID)
- {
+ if(pLCID) {
*pLCID = 0; // TODO: make lcid out of "sl.id"
}
@@ -1325,19 +1365,21 @@ STDMETHODIMP_(int) CVobSubFile::GetStream()
int iStream = 0;
for(ptrdiff_t i = 0; i < m_iLang; i++)
- if(!m_langs[i].subpos.IsEmpty()) iStream++;
+ if(!m_langs[i].subpos.IsEmpty()) {
+ iStream++;
+ }
return(iStream);
}
STDMETHODIMP CVobSubFile::SetStream(int iStream)
{
- for(ptrdiff_t i = 0; i < 32; i++)
- {
+ for(ptrdiff_t i = 0; i < 32; i++) {
CAtlArray<SubPos>& sp = m_langs[i].subpos;
- if(sp.IsEmpty() || iStream-- > 0)
+ if(sp.IsEmpty() || iStream-- > 0) {
continue;
+ }
m_iLang = i;
@@ -1352,7 +1394,9 @@ STDMETHODIMP CVobSubFile::SetStream(int iStream)
STDMETHODIMP CVobSubFile::Reload()
{
CFileStatus s;
- if(!CFile::GetStatus(m_title + _T(".idx"), s)) return E_FAIL;
+ if(!CFile::GetStatus(m_title + _T(".idx"), s)) {
+ return E_FAIL;
+ }
return !m_title.IsEmpty() && Open(m_title) ? S_OK : E_FAIL;
}
@@ -1382,20 +1426,24 @@ static void PixelAtBiLinear(RGBQUAD& c, int x, int y, CVobSubImage& src)
v2u2 = int(v2*u2 >> 16) * c22.rgbReserved;
c.rgbRed = (c11.rgbRed * v1u1 + c12.rgbRed * v1u2
- + c21.rgbRed * v2u1 + c22.rgbRed * v2u2) >> 24;
+ + c21.rgbRed * v2u1 + c22.rgbRed * v2u2) >> 24;
c.rgbGreen = (c11.rgbGreen * v1u1 + c12.rgbGreen * v1u2
- + c21.rgbGreen * v2u1 + c22.rgbGreen * v2u2) >> 24;
+ + c21.rgbGreen * v2u1 + c22.rgbGreen * v2u2) >> 24;
c.rgbBlue = (c11.rgbBlue * v1u1 + c12.rgbBlue * v1u2
- + c21.rgbBlue * v2u1 + c22.rgbBlue * v2u2) >> 24;
+ + c21.rgbBlue * v2u1 + c22.rgbBlue * v2u2) >> 24;
c.rgbReserved = (v1u1 + v1u2
- + v2u1 + v2u2) >> 16;
+ + v2u1 + v2u2) >> 16;
}
static void StretchBlt(SubPicDesc& spd, CRect dstrect, CVobSubImage& src)
{
- if(dstrect.IsRectEmpty()) return;
+ if(dstrect.IsRectEmpty()) {
+ return;
+ }
- if((dstrect & CRect(0, 0, spd.w, spd.h)).IsRectEmpty()) return;
+ if((dstrect & CRect(0, 0, spd.w, spd.h)).IsRectEmpty()) {
+ return;
+ }
int sw = src.rect.Width(),
sh = src.rect.Height(),
@@ -1407,39 +1455,35 @@ static void StretchBlt(SubPicDesc& spd, CRect dstrect, CVobSubImage& src)
srcdx = (sw << 16) / dw >> 1,
srcdy = (sh << 16) / dh >> 1;
- if(dstrect.left < 0)
- {
+ if(dstrect.left < 0) {
srcx = -dstrect.left * (srcdx << 1);
dstrect.left = 0;
}
- if(dstrect.top < 0)
- {
+ if(dstrect.top < 0) {
srcy = -dstrect.top * (srcdy << 1);
dstrect.top = 0;
}
- if(dstrect.right > spd.w)
- {
+ if(dstrect.right > spd.w) {
dstrect.right = spd.w;
}
- if(dstrect.bottom > spd.h)
- {
+ if(dstrect.bottom > spd.h) {
dstrect.bottom = spd.h;
}
- if((dstrect & CRect(0, 0, spd.w, spd.h)).IsRectEmpty()) return;
+ if((dstrect & CRect(0, 0, spd.w, spd.h)).IsRectEmpty()) {
+ return;
+ }
dw = dstrect.Width();
dh = dstrect.Height();
- for(ptrdiff_t y = dstrect.top; y < dstrect.bottom; y++, srcy += (srcdy<<1))
- {
+ for(ptrdiff_t 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(ptrdiff_t sx = srcx; ptr < endptr; sx += (srcdx<<1), ptr++)
- {
-// PixelAtBiLinear(*ptr, sx, srcy, src);
-////
+ for(ptrdiff_t sx = srcx; ptr < endptr; sx += (srcdx<<1), ptr++) {
+ // PixelAtBiLinear(*ptr, sx, srcy, src);
+ ////
RGBQUAD cc[4];
PixelAtBiLinear(cc[0], sx, srcy, src);
@@ -1451,7 +1495,7 @@ static void StretchBlt(SubPicDesc& spd, CRect dstrect, CVobSubImage& src)
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;
@@ -1493,7 +1537,9 @@ void CVobSubSettings::SetCustomPal(RGBQUAD* cuspal, int tridx)
{
memcpy(m_cuspal, cuspal, sizeof(RGBQUAD)*4);
m_tridx = tridx & 0xf;
- for(ptrdiff_t i = 0; i < 4; i++) m_cuspal[i].rgbReserved = (tridx&(1<<i)) ? 0 : 0xff;
+ for(ptrdiff_t i = 0; i < 4; i++) {
+ m_cuspal[i].rgbReserved = (tridx&(1<<i)) ? 0 : 0xff;
+ }
m_img.Invalidate();
}
@@ -1502,53 +1548,48 @@ 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)
- {
+ 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;
+ } 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;
+ 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;
}
}
@@ -1568,15 +1609,12 @@ void CVobSubSettings::GetDestrect(CRect& r, int w, int h)
void CVobSubSettings::SetAlignment(bool fAlign, int x, int y, int hor, int ver)
{
m_fAlign = fAlign;
- if(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
- {
+ } else {
m_org.x = m_x;
m_org.y = m_y;
}
@@ -1589,16 +1627,16 @@ 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);
-*/
+ /*
+ 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;
@@ -1608,14 +1646,14 @@ HRESULT CVobSubSettings::Render(SubPicDesc& spd, RECT& bbox)
static bool CompressFile(CString fn)
{
- if(GetVersion() < 0)
+ if(GetVersion() < 0) {
return(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)
- {
+ 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);
@@ -1635,26 +1673,27 @@ bool CVobSubFile::SaveWinSubMux(CString fn)
TrimExtension(fn);
CStdioFile f;
- if(!f.Open(fn + _T(".sub"), CFile::modeCreate|CFile::modeWrite|CFile::typeText|CFile::shareDenyWrite))
+ 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))
+ if(!p4bpp.Allocate(720*576/2)) {
return(false);
+ }
CAtlArray<SubPos>& sp = m_langs[m_iLang].subpos;
- for(ptrdiff_t i = 0; i < sp.GetCount(); i++)
- {
- if(!GetFrame(i)) continue;
+ for(ptrdiff_t i = 0; i < sp.GetCount(); i++) {
+ if(!GetFrame(i)) {
+ continue;
+ }
int pal[4] = {0, 1, 2, 3};
- for(ptrdiff_t j = 0; j < 5; j++)
- {
- if(j == 4 || !m_img.pal[j].tr)
- {
+ for(ptrdiff_t 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];
@@ -1666,15 +1705,12 @@ bool CVobSubFile::SaveWinSubMux(CString fn)
DWORD uipal[4+12];
- if(!m_fCustomPal)
- {
+ 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
- {
+ } 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;
@@ -1693,16 +1729,13 @@ bool CVobSubFile::SaveWinSubMux(CString fn)
int h = m_img.rect.Height()-2;
int pitch = (((w+1)>>1) + 3) & ~3;
- for(ptrdiff_t y = 0; y < h; y++)
- {
+ 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++)
- {
+ for(ptrdiff_t x = 0; x < w; x++, p++) {
BYTE c = 0;
- if(*p & 0xff000000)
- {
+ if(*p & 0xff000000) {
DWORD uic = *p & 0xffffff;
palmap.Lookup(uic, c);
}
@@ -1716,8 +1749,12 @@ bool CVobSubFile::SaveWinSubMux(CString fn)
ASSERT(t2>t1);
- if(t2 <= 0) continue;
- if(t1 < 0) t1 = 0;
+ if(t2 <= 0) {
+ continue;
+ }
+ if(t1 < 0) {
+ t1 = 0;
+ }
CString bmpfn;
bmpfn.Format(_T("%s_%06d.bmp"), fn, i+1);
@@ -1731,16 +1768,14 @@ bool CVobSubFile::SaveWinSubMux(CString fn)
(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 =
- {
+ BITMAPFILEHEADER fhdr = {
0x4d42,
sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + 16*sizeof(RGBQUAD) + pitch*h,
0, 0,
sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + 16*sizeof(RGBQUAD)
};
- BITMAPINFOHEADER ihdr =
- {
+ BITMAPINFOHEADER ihdr = {
sizeof(BITMAPINFOHEADER),
w, h, 1, 4, 0,
0,
@@ -1749,8 +1784,7 @@ bool CVobSubFile::SaveWinSubMux(CString fn)
};
CFile bmp;
- if(bmp.Open(bmpfn, CFile::modeCreate|CFile::modeWrite|CFile::typeBinary|CFile::shareDenyWrite))
- {
+ 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);
@@ -1769,8 +1803,9 @@ bool CVobSubFile::SaveScenarist(CString fn)
TrimExtension(fn);
CStdioFile f;
- if(!f.Open(fn + _T(".sst"), CFile::modeCreate|CFile::modeWrite|CFile::typeText|CFile::shareDenyWrite))
+ if(!f.Open(fn + _T(".sst"), CFile::modeCreate|CFile::modeWrite|CFile::typeText|CFile::shareDenyWrite)) {
return(false);
+ }
m_img.Invalidate();
@@ -1778,13 +1813,15 @@ bool CVobSubFile::SaveScenarist(CString fn)
CString title = fn.Mid(fn.ReverseFind('/')+1);
TCHAR buff[_MAX_PATH], * pFilePart = buff;
- if(GetFullPathName(fn, MAX_PATH, buff, &pFilePart) == 0)
+ if(GetFullPathName(fn, MAX_PATH, buff, &pFilePart) == 0) {
return(false);
+ }
CString fullpath = CString(buff).Left(pFilePart - buff);
fullpath.TrimRight(_T("\\/"));
- if(fullpath.IsEmpty())
+ if(fullpath.IsEmpty()) {
return(false);
+ }
CString str, str2;
str += _T("st_format\t2\n");
@@ -1815,8 +1852,7 @@ bool CVobSubFile::SaveScenarist(CString fn)
f.Flush();
- RGBQUAD pal[16] =
- {
+ RGBQUAD pal[16] = {
{255, 0, 0, 0},
{0, 0, 255, 0},
{0, 0, 0, 0},
@@ -1835,16 +1871,14 @@ bool CVobSubFile::SaveScenarist(CString fn)
{125, 0, 125, 0},
};
- BITMAPFILEHEADER fhdr =
- {
+ 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 =
- {
+ BITMAPINFOHEADER ihdr = {
sizeof(BITMAPINFOHEADER),
720, m_size.cy-2, 1, 4, 0,
360*(m_size.cy-2),
@@ -1859,17 +1893,16 @@ bool CVobSubFile::SaveScenarist(CString fn)
memcpy(m_cuspal, newCusPal, sizeof(m_cuspal));
CAutoVectorPtr<BYTE> p4bpp;
- if(!p4bpp.Allocate((m_size.cy-2)*360))
+ if(!p4bpp.Allocate((m_size.cy-2)*360)) {
return(false);
+ }
BYTE colormap[16];
- for(ptrdiff_t i = 0; i < 16; i++)
- {
+ for(ptrdiff_t i = 0; i < 16; i++) {
int idx = 0, maxdif = 255*255*3+1;
- for(ptrdiff_t j = 0; j < 16 && maxdif; j++)
- {
+ for(ptrdiff_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;
@@ -1887,29 +1920,28 @@ bool CVobSubFile::SaveScenarist(CString fn)
int pc[4] = {1, 1, 1, 1}, pa[4] = {15, 15, 15, 0};
CAtlArray<SubPos>& sp = m_langs[m_iLang].subpos;
- for(ptrdiff_t i = 0, k = 0; i < sp.GetCount(); i++)
- {
- if(!GetFrame(i)) continue;
-
- for(ptrdiff_t j = 0; j < 5; j++)
- {
- if(j == 4 || !m_img.pal[j].tr)
- {
+ for(ptrdiff_t i = 0, k = 0; i < sp.GetCount(); i++) {
+ if(!GetFrame(i)) {
+ continue;
+ }
+
+ for(ptrdiff_t 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++)
- {
+ 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;
+ 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++)
- {
+ 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)];
@@ -1925,8 +1957,7 @@ bool CVobSubFile::SaveScenarist(CString fn)
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)))
- {
+ 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);
@@ -1936,8 +1967,7 @@ bool CVobSubFile::SaveScenarist(CString fn)
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)))
- {
+ 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);
@@ -1951,22 +1981,22 @@ bool CVobSubFile::SaveScenarist(CString fn)
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(t2 <= 0) {
+ continue;
+ }
+ if(t1 < 0) {
+ t1 = 0;
+ }
- if(h1 == h2 && m1 == m2 && s1 == s2 && f1 == f2)
- {
+ if(h1 == h2 && m1 == m2 && s1 == s2 && f1 == f2) {
f2++;
- if(f2 == (m_size.cy == 480 ? 30 : 25))
- {
+ if(f2 == (m_size.cy == 480 ? 30 : 25)) {
f2 = 0;
s2++;
- if(s2 == 60)
- {
+ if(s2 == 60) {
s2 = 0;
m2++;
- if(m2 == 60)
- {
+ if(m2 == 60) {
m2 = 0;
h2++;
}
@@ -1974,46 +2004,43 @@ bool CVobSubFile::SaveScenarist(CString fn)
}
}
- if(i < sp.GetCount()-1)
- {
+ if(i < sp.GetCount()-1) {
int t3 = 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)
- {
+ if(h3 == h2 && m3 == m2 && s3 == s2 && f3 == f2) {
f2--;
- if(f2 == -1)
- {
+ if(f2 == -1) {
f2 = (m_size.cy == 480 ? 29 : 24);
s2--;
- if(s2 == -1)
- {
+ if(s2 == -1) {
s2 = 59;
m2--;
- if(m2 == -1)
- {
+ if(m2 == -1) {
m2 = 59;
- if(h2 > 0) h2--;
+ if(h2 > 0) {
+ h2--;
+ }
}
}
}
}
}
- if(h1 == h2 && m1 == m2 && s1 == s2 && f1 == f2)
+ 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);
+ ++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))
- {
+ 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);
@@ -2035,8 +2062,9 @@ bool CVobSubFile::SaveMaestro(CString fn)
TrimExtension(fn);
CStdioFile f;
- if(!f.Open(fn + _T(".son"), CFile::modeCreate|CFile::modeWrite|CFile::typeText|CFile::shareDenyWrite))
+ if(!f.Open(fn + _T(".son"), CFile::modeCreate|CFile::modeWrite|CFile::typeText|CFile::shareDenyWrite)) {
return(false);
+ }
m_img.Invalidate();
@@ -2044,13 +2072,15 @@ bool CVobSubFile::SaveMaestro(CString fn)
CString title = fn.Mid(fn.ReverseFind('/')+1);
TCHAR buff[_MAX_PATH], * pFilePart = buff;
- if(GetFullPathName(fn, MAX_PATH, buff, &pFilePart) == 0)
+ if(GetFullPathName(fn, MAX_PATH, buff, &pFilePart) == 0) {
return(false);
+ }
CString fullpath = CString(buff).Left(pFilePart - buff);
fullpath.TrimRight(_T("\\/"));
- if(fullpath.IsEmpty())
+ if(fullpath.IsEmpty()) {
return(false);
+ }
CString str, str2;
str += _T("st_format\t2\n");
@@ -2065,27 +2095,25 @@ bool CVobSubFile::SaveMaestro(CString fn)
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);
+ !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 =
- {
+ 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 =
- {
+ BITMAPINFOHEADER ihdr = {
sizeof(BITMAPINFOHEADER),
720, m_size.cy-2, 1, 4, 0,
360*(m_size.cy-2),
@@ -2100,18 +2128,18 @@ bool CVobSubFile::SaveMaestro(CString fn)
memcpy(m_cuspal, newCusPal, sizeof(m_cuspal));
CAutoVectorPtr<BYTE> p4bpp;
- if(!p4bpp.Allocate((m_size.cy-2)*360))
+ if(!p4bpp.Allocate((m_size.cy-2)*360)) {
return(false);
+ }
BYTE colormap[16];
- for(ptrdiff_t i = 0; i < 16; i++)
+ for(ptrdiff_t i = 0; i < 16; i++) {
colormap[i] = i;
+ }
CFile spf;
- if(spf.Open(fn + _T(".spf"), CFile::modeCreate|CFile::modeWrite|CFile::typeBinary))
- {
- for(ptrdiff_t i = 0; i < 16; i++)
- {
+ if(spf.Open(fn + _T(".spf"), CFile::modeCreate|CFile::modeWrite|CFile::typeBinary)) {
+ for(ptrdiff_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));
}
@@ -2122,29 +2150,28 @@ bool CVobSubFile::SaveMaestro(CString fn)
int pc[4] = {1,1,1,1}, pa[4] = {15,15,15,0};
CAtlArray<SubPos>& sp = m_langs[m_iLang].subpos;
- for(ptrdiff_t i = 0, k = 0; i < sp.GetCount(); i++)
- {
- if(!GetFrame(i)) continue;
-
- for(ptrdiff_t j = 0; j < 5; j++)
- {
- if(j == 4 || !m_img.pal[j].tr)
- {
+ for(ptrdiff_t i = 0, k = 0; i < sp.GetCount(); i++) {
+ if(!GetFrame(i)) {
+ continue;
+ }
+
+ for(ptrdiff_t 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++)
- {
+ 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;
+ 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++)
- {
+ 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)];
@@ -2159,8 +2186,7 @@ bool CVobSubFile::SaveMaestro(CString fn)
// 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)))
- {
+ 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);
@@ -2169,8 +2195,7 @@ bool CVobSubFile::SaveMaestro(CString fn)
// 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)))
- {
+ 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);
@@ -2184,22 +2209,22 @@ bool CVobSubFile::SaveMaestro(CString fn)
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(t2 <= 0) {
+ continue;
+ }
+ if(t1 < 0) {
+ t1 = 0;
+ }
- if(h1 == h2 && m1 == m2 && s1 == s2 && f1 == f2)
- {
+ if(h1 == h2 && m1 == m2 && s1 == s2 && f1 == f2) {
f2++;
- if(f2 == (m_size.cy == 480 ? 30 : 25))
- {
+ if(f2 == (m_size.cy == 480 ? 30 : 25)) {
f2 = 0;
s2++;
- if(s2 == 60)
- {
+ if(s2 == 60) {
s2 = 0;
m2++;
- if(m2 == 60)
- {
+ if(m2 == 60) {
m2 = 0;
h2++;
}
@@ -2207,46 +2232,43 @@ bool CVobSubFile::SaveMaestro(CString fn)
}
}
- if(i < sp.GetCount()-1)
- {
+ if(i < sp.GetCount()-1) {
int t3 = 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)
- {
+ if(h3 == h2 && m3 == m2 && s3 == s2 && f3 == f2) {
f2--;
- if(f2 == -1)
- {
+ if(f2 == -1) {
f2 = (m_size.cy == 480 ? 29 : 24);
s2--;
- if(s2 == -1)
- {
+ if(s2 == -1) {
s2 = 59;
m2--;
- if(m2 == -1)
- {
+ if(m2 == -1) {
m2 = 59;
- if(h2 > 0) h2--;
+ if(h2 > 0) {
+ h2--;
+ }
}
}
}
}
}
- if(h1 == h2 && m1 == m2 && s1 == s2 && f1 == f2)
+ 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);
+ ++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))
- {
+ 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);
@@ -2284,72 +2306,69 @@ void CVobSubStream::Open(CString name, BYTE* pData, int len)
CAtlList<CString> lines;
Explode(CString(CStringA((CHAR*)pData, len)), lines, '\n');
- while(lines.GetCount())
- {
+ while(lines.GetCount()) {
CAtlList<CString> sl;
Explode(lines.RemoveHead(), sl, ':', 2);
- if(sl.GetCount() != 2) continue;
+ if(sl.GetCount() != 2) {
+ continue;
+ }
CString key = sl.GetHead();
CString value = sl.GetTail();
- if(key == _T("size"))
+ if(key == _T("size")) {
_stscanf(value, _T("%dx %d"), &m_size.cx, &m_size.cy);
- else if(key == _T("org"))
+ } else if(key == _T("org")) {
_stscanf(value, _T("%d, %d"), &m_org.x, &m_org.y);
- else if(key == _T("scale"))
+ } else if(key == _T("scale")) {
_stscanf(value, _T("%d%%, %d%%"), &m_scale_x, &m_scale_y);
- else if(key == _T("alpha"))
+ } else if(key == _T("alpha")) {
_stscanf(value, _T("%d%%"), &m_alpha);
- else if(key == _T("smooth"))
+ } 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"))
- {
+ 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)
- {
+ 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"))
+ } else if(key == _T("fade in/out")) {
_stscanf(value, _T("%d%, %d%"), &m_fadein, &m_fadeout);
- else if(key == _T("time offset"))
+ } else if(key == _T("time offset")) {
m_toff = _tcstol(value, NULL, 10);
- else if(key == _T("forced subs"))
+ } else if(key == _T("forced subs")) {
m_fOnlyShowForcedSubs = value == _T("1") || value == _T("ON");
- else if(key == _T("palette"))
- {
+ } else if(key == _T("palette")) {
Explode(value, sl, ',', 16);
- for(ptrdiff_t i = 0; i < 16 && sl.GetCount(); i++)
+ for(ptrdiff_t i = 0; i < 16 && sl.GetCount(); i++) {
*(DWORD*)&m_orgpal[i] = _tcstol(sl.RemoveHead(), NULL, 16);
- }
- else if(key == _T("custom colors"))
- {
+ }
+ } else if(key == _T("custom colors")) {
m_fCustomPal = Explode(value, sl, ',', 3) == _T("ON");
- if(sl.GetCount() == 3)
- {
+ if(sl.GetCount() == 3) {
sl.RemoveHead();
CAtlList<CString> tridx, colors;
Explode(sl.RemoveHead(), tridx, ':', 2);
- if(tridx.RemoveHead() == _T("tridx"))
- {
+ if(tridx.RemoveHead() == _T("tridx")) {
TCHAR tr[4];
_stscanf(tridx.RemoveHead(), _T("%c%c%c%c"), &tr[0], &tr[1], &tr[2], &tr[3]);
- for(ptrdiff_t i = 0; i < 4; i++)
+ for(ptrdiff_t i = 0; i < 4; i++) {
m_tridx |= ((tr[i]=='1')?1:0)<<i;
+ }
}
Explode(sl.RemoveHead(), colors, ':', 2);
- if(colors.RemoveHead() == _T("colors"))
- {
+ if(colors.RemoveHead() == _T("colors")) {
Explode(colors.RemoveHead(), colors, ',', 4);
- for(ptrdiff_t i = 0; i < 4 && colors.GetCount(); i++)
+ for(ptrdiff_t i = 0; i < 4 && colors.GetCount(); i++) {
*(DWORD*)&m_cuspal[i] = _tcstol(colors.RemoveHead(), NULL, 16);
+ }
}
}
}
@@ -2358,7 +2377,9 @@ void CVobSubStream::Open(CString name, BYTE* pData, int len)
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]);
@@ -2370,8 +2391,7 @@ void CVobSubStream::Add(REFERENCE_TIME tStart, REFERENCE_TIME tStop, BYTE* pData
memcpy(p->pData.GetData(), pData, p->pData.GetCount());
CAutoLock cAutoLock(&m_csSubPics);
- while(m_subpics.GetCount() && m_subpics.GetTail()->tStart >= tStart)
- {
+ while(m_subpics.GetCount() && m_subpics.GetTail()->tStart >= tStart) {
m_subpics.RemoveTail();
m_img.iIdx = -1;
}
@@ -2391,10 +2411,10 @@ STDMETHODIMP CVobSubStream::NonDelegatingQueryInterface(REFIID riid, void** ppv)
*ppv = NULL;
return
- QI(IPersist)
- QI(ISubStream)
- QI(ISubPicProvider)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ QI(IPersist)
+ QI(ISubStream)
+ QI(ISubPicProvider)
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
// ISubPicProvider
@@ -2403,12 +2423,12 @@ STDMETHODIMP_(POSITION) CVobSubStream::GetStartPosition(REFERENCE_TIME rt, doubl
{
CAutoLock cAutoLock(&m_csSubPics);
POSITION pos = m_subpics.GetTailPosition();
- for(; pos; m_subpics.GetPrev(pos))
- {
+ for(; pos; m_subpics.GetPrev(pos)) {
SubPic* sp = m_subpics.GetAt(pos);
- if(sp->tStart <= rt)
- {
- if(sp->tStop <= rt) m_subpics.GetNext(pos);
+ if(sp->tStart <= rt) {
+ if(sp->tStop <= rt) {
+ m_subpics.GetNext(pos);
+ }
break;
}
}
@@ -2441,16 +2461,15 @@ STDMETHODIMP_(bool) CVobSubStream::IsAnimated(POSITION pos)
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))
- {
+ 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)
- {
+ 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],
@@ -2483,16 +2502,15 @@ STDMETHODIMP CVobSubStream::GetStreamInfo(int i, WCHAR** ppName, LCID* pLCID)
{
CAutoLock cAutoLock(&m_csSubPics);
- if(ppName)
- {
+ if(ppName) {
*ppName = (WCHAR*)CoTaskMemAlloc((m_name.GetLength() + 1) * sizeof(WCHAR));
- if(!(*ppName))
+ if(!(*ppName)) {
return E_OUTOFMEMORY;
+ }
wcscpy(*ppName, CStringW(m_name));
}
- if(pLCID)
- {
+ if(pLCID) {
*pLCID = 0; // TODO
}
diff --git a/src/Subtitles/VobSubFile.h b/src/Subtitles/VobSubFile.h
index 652e61493..38a58047d 100644
--- a/src/Subtitles/VobSubFile.h
+++ b/src/Subtitles/VobSubFile.h
@@ -91,8 +91,7 @@ protected:
bool SaveMaestro(CString fn);
public:
- typedef struct
- {
+ typedef struct {
__int64 filepos;
__int64 start, stop;
bool fForced;
@@ -101,8 +100,7 @@ public:
bool fValid;
} SubPos;
- typedef struct
- {
+ typedef struct {
int id;
CString name, alt;
CAtlArray<SubPos> subpos;
diff --git a/src/Subtitles/VobSubFileRipper.cpp b/src/Subtitles/VobSubFileRipper.cpp
index d484a8150..7e3c61c35 100644
--- a/src/Subtitles/VobSubFileRipper.cpp
+++ b/src/Subtitles/VobSubFileRipper.cpp
@@ -56,7 +56,9 @@ STDMETHODIMP CVobSubFileRipper::NonDelegatingQueryInterface(REFIID riid, void**
void CVobSubFileRipper::Log(log_t type, LPCTSTR lpszFormat, ...)
{
CAutoLock cAutoLock(&m_csCallback);
- if(!m_pCallback) return;
+ if(!m_pCallback) {
+ return;
+ }
TCHAR buff[1024];
@@ -66,18 +68,17 @@ void CVobSubFileRipper::Log(log_t type, LPCTSTR lpszFormat, ...)
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;
+ 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;
@@ -88,7 +89,9 @@ void CVobSubFileRipper::Log(log_t type, LPCTSTR lpszFormat, ...)
void CVobSubFileRipper::Progress(double progress)
{
CAutoLock cAutoLock(&m_csCallback);
- if(!m_pCallback) return;
+ if(!m_pCallback) {
+ return;
+ }
m_pCallback->OnProgress(progress);
}
@@ -96,7 +99,9 @@ void CVobSubFileRipper::Progress(double progress)
void CVobSubFileRipper::Finished(bool fSucceeded)
{
CAutoLock cAutoLock(&m_csCallback);
- if(!m_pCallback) return;
+ if(!m_pCallback) {
+ return;
+ }
m_pCallback->OnFinished(fSucceeded);
}
@@ -119,15 +124,13 @@ bool CVobSubFileRipper::LoadIfo(CString fn)
CString str;
CFileStatus status;
- if(!CFileGetStatus(fn, status) || !status.m_size)
- {
+ 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))
- {
+ if(!f.Open(fn, CFile::modeRead|CFile::typeBinary|CFile::shareDenyNone)) {
Log(LOG_ERROR, _T("Cannot open ifo"));
return(false);
}
@@ -137,8 +140,7 @@ bool CVobSubFileRipper::LoadIfo(CString fn)
char hdr[13];
f.Read(hdr, 12);
hdr[12] = 0;
- if(strcmp(hdr, "DVDVIDEO-VTS"))
- {
+ if(strcmp(hdr, "DVDVIDEO-VTS")) {
Log(LOG_ERROR, _T("Not a Video Title Set IFO file!"));
return(false);
}
@@ -153,11 +155,12 @@ bool CVobSubFileRipper::LoadIfo(CString fn)
int len = 0;
ReadBEw(len);
- for(ptrdiff_t i = 0; i < len; i++)
- {
+ for(ptrdiff_t i = 0; i < len; i++) {
f.Seek(2, CFile::current); // 01 00 ?
ReadBEw(ids[i]);
- if(ids[i] == 0) ids[i] = '--';
+ if(ids[i] == 0) {
+ ids[i] = '--';
+ }
f.Seek(2, CFile::current); // 00 00 ?
}
@@ -166,8 +169,7 @@ bool CVobSubFileRipper::LoadIfo(CString fn)
f.Seek(0x200, CFile::begin);
f.Read(&m_rd.vidinfo, 2);
- SIZE res[4][2] =
- {
+ SIZE res[4][2] = {
{{720,480},{720,576}},
{{704,480},{704,576}},
{{352,480},{352,576}},
@@ -195,8 +197,7 @@ bool CVobSubFileRipper::LoadIfo(CString fn)
m_rd.pgcs.RemoveAll();
m_rd.pgcs.SetCount(nPGC);
- for(ptrdiff_t i = 0; i < nPGC; i++)
- {
+ for(ptrdiff_t i = 0; i < nPGC; i++) {
PGC& pgc = m_rd.pgcs[i];
f.Seek(pgcpos + 8 + i*8 + 4, CFile::begin);
@@ -220,16 +221,15 @@ bool CVobSubFileRipper::LoadIfo(CString fn)
f.Seek(offset + 0x1c, CFile::begin);
f.Read(splinfo, 32*4);
- for(ptrdiff_t j = 0; j < 32; j++)
- {
- if(splinfo[j].id1 || splinfo[i].id2)
- {
+ for(ptrdiff_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;
+ 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];
@@ -243,8 +243,7 @@ bool CVobSubFileRipper::LoadIfo(CString fn)
f.Seek(offset + 0xa4, CFile::begin);
- for(ptrdiff_t j = 0; j < 16; j++)
- {
+ for(ptrdiff_t j = 0; j < 16; j++) {
BYTE y, u, v, tmp;
f.Read(&tmp, 1);
@@ -284,8 +283,7 @@ bool CVobSubFileRipper::LoadIfo(CString fn)
//
f.Seek(offset + vobcelloff, CFile::begin);
- for(ptrdiff_t j = 0; j < nCells; j++)
- {
+ for(ptrdiff_t j = 0; j < nCells; j++) {
ReadBEw(pgc.angles[0][j].vob);
ReadBEw(pgc.angles[0][j].cell);
}
@@ -299,24 +297,22 @@ bool CVobSubFileRipper::LoadIfo(CString fn)
pgc.nAngles = 0;
f.Seek(offset + celladdroff, CFile::begin);
- for(ptrdiff_t j = 0; j < nCells; j++)
- {
+ for(ptrdiff_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)
+ 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);
@@ -328,15 +324,14 @@ bool CVobSubFileRipper::LoadIfo(CString fn)
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;
+ 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;
@@ -347,7 +342,9 @@ bool CVobSubFileRipper::LoadIfo(CString fn)
pgc.angles[0][j].tTime = (DWORD)((((hh*60+mm)*60+ss)*1000+ms)*rate);
// time discontinuity
- if(b&0x02) tOffset = tTotal;
+ if(b&0x02) {
+ tOffset = tTotal;
+ }
pgc.angles[0][j].fDiscontinuity = !!(b&0x02);
pgc.angles[0][j].tTotal = tTotal;
@@ -356,19 +353,20 @@ bool CVobSubFileRipper::LoadIfo(CString fn)
tTotal += pgc.angles[0][j].tTime;
}
- for(iAngle = 1; iAngle <= 9; iAngle++)
- {
+ for(iAngle = 1; iAngle <= 9; iAngle++) {
tOffset = tTotal = 0;
- for(ptrdiff_t j = 0, k = 0; j < nCells; j++)
- {
+ for(ptrdiff_t j = 0, k = 0; j < nCells; j++) {
if(pgc.angles[0][j].iAngle != 0
- && pgc.angles[0][j].iAngle != iAngle)
+ && pgc.angles[0][j].iAngle != iAngle) {
continue;
+ }
pgc.angles[iAngle].Add(pgc.angles[0][j]);
- if(pgc.angles[iAngle][k].fDiscontinuity) tOffset = tTotal;
+ if(pgc.angles[iAngle][k].fDiscontinuity) {
+ tOffset = tTotal;
+ }
pgc.angles[iAngle][k].tTotal = tTotal;
pgc.angles[iAngle][k].tOffset = tOffset;
@@ -389,87 +387,87 @@ bool CVobSubFileRipper::LoadIfo(CString fn)
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(ptrdiff_t i = 0; i < 100; i++)
- {
- CString vob;
- vob.Format(_T("%s%d.vob"), fn, i);
+ /*
+ CAtlList<CString> m_vobs;
- CFileStatus status;
- if(!(CFileGetStatus(vob, status) && status.m_size))
+ fn = fn.Left(fn.ReverseFind('.')+1);
+ fn.TrimRight(_T(".0123456789"));
+ for(ptrdiff_t i = 0; i < 100; i++)
{
- if(i > 0) break;
- else continue;
- }
+ CString vob;
+ vob.Format(_T("%s%d.vob"), fn, i);
- if(status.m_size&0x7ff)
- {
- Log(LOG_ERROR, _T("Length of %s is not n*2048!"), vob);
- m_vobs.RemoveAll();
- break;
- }
+ CFileStatus status;
+ if(!(CFileGetStatus(vob, status) && status.m_size))
+ {
+ if(i > 0) break;
+ else continue;
+ }
- CString str = _T("Found ") + vob;
+ if(status.m_size&0x7ff)
+ {
+ Log(LOG_ERROR, _T("Length of %s is not n*2048!"), vob);
+ m_vobs.RemoveAll();
+ break;
+ }
- if(i == 0)
- {
- str += _T(" (skipping, if not a menu vob rename it)");
+ 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);
}
- else
+
+ if(m_vobs.GetCount() <= 0)
{
- m_vobs.AddTail(vob);
+ Log(LOG_ERROR, _T("Nothing found! (%s*.vob)"), fn);
+ return(false);
}
-
- 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*/))
- {
+ if(!m_vob.Open(fn, vobs/*m_vobs*/)) {
Log(LOG_ERROR, _T("Cannot open vob sequence"));
return(false);
}
- if(vobs.GetCount() <= 0)
- {
+ 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));
+ while(pos) {
+ Log(LOG_INFO, _T("Found ") + vobs.GetNext(pos));
+ }
- if(m_vob.IsDVD())
- {
+ if(m_vob.IsDVD()) {
Log(LOG_INFO, _T("DVD detected..."));
BYTE key[5];
- if(m_vob.HasDiscKey(key))
+ 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
+ } else {
Log(LOG_WARNING, _T("Couldn't get the disc key"));
+ }
- if(m_vob.HasTitleKey(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
+ } else {
Log(LOG_WARNING, _T("Couldn't get the title key"));
+ }
BYTE buff[2048];
m_vob.Seek(0);
- if(!m_vob.Read(buff))
- {
+ if(!m_vob.Read(buff)) {
Log(LOG_ERROR, _T("Can't read vob, please unlock it with a software player!"));
return(false);
}
@@ -483,31 +481,29 @@ DWORD CVobSubFileRipper::ThreadProc()
{
SetThreadPriority(m_hThread, THREAD_PRIORITY_BELOW_NORMAL);
- while(1)
- {
+ while(1) {
DWORD cmd = GetRequest();
m_fThreadActive = true;
- switch(cmd)
- {
- case CMD_EXIT:
- Reply(S_OK);
- return 0;
+ 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;
+ 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;
+ default:
+ Reply((DWORD)E_FAIL);
+ return (DWORD)-1;
}
m_fBreakThread = false;
@@ -526,30 +522,26 @@ bool CVobSubFileRipper::Create()
{
CAutoLock cAutoLock(&m_csAccessLock);
- if(m_rd.iSelPGC < 0 || m_rd.iSelPGC >= m_rd.pgcs.GetCount())
- {
+ if(m_rd.iSelPGC < 0 || 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];
- if(pgc.iSelAngle < 0 || pgc.iSelAngle > 9 || pgc.angles[pgc.iSelAngle].GetCount() == 0)
- {
+ 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];
- if(m_rd.selids.GetCount() == 0 && !m_rd.fClosedCaption)
- {
+ 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)
- {
+ if(m_rd.selvcs.GetCount() == 0) {
Log(LOG_ERROR, _T("No valid vob/cell id set to be extacted!"));
return(false);
}
@@ -575,10 +567,10 @@ bool CVobSubFileRipper::Create()
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++)
+ 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);
@@ -586,20 +578,20 @@ bool CVobSubFileRipper::Create()
CAtlMap<DWORD, int> selvcmap;
selvcmap.RemoveAll();
- for(ptrdiff_t i = 0; i < m_rd.selvcs.GetCount(); i++)
+ for(ptrdiff_t i = 0; i < m_rd.selvcs.GetCount(); i++) {
selvcmap[m_rd.selvcs[i]] = 90000;
+ }
CAtlArray<vcchunk> chunks, foundchunks, loadedchunks;
- if(m_vob.IsDVD())
- {
+ if(m_vob.IsDVD()) {
Log(LOG_INFO, _T("Indexing mode: DVD"));
- for(ptrdiff_t i = 0; i < angle.GetCount(); i++)
- {
+ for(ptrdiff_t i = 0; i < angle.GetCount(); i++) {
DWORD vc = (angle[i].vob<<16)|angle[i].cell;
- if(!selvcmap.Lookup(vc))
+ if(!selvcmap.Lookup(vc)) {
continue;
+ }
vcchunk c = {2048i64*angle[i].start, 2048i64*angle[i].end+2048, vc};
chunks.Add(c);
@@ -607,24 +599,20 @@ bool CVobSubFileRipper::Create()
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))
- {
+ } else if(LoadChunks(loadedchunks)) {
Log(LOG_INFO, _T("Indexing mode: File"));
- for(ptrdiff_t i = 0; i < loadedchunks.GetCount(); i++)
- {
+ for(ptrdiff_t i = 0; i < loadedchunks.GetCount(); i++) {
DWORD vcid = loadedchunks[i].vc;
- if(!selvcmap.Lookup(vcid))
+ if(!selvcmap.Lookup(vcid)) {
continue;
+ }
chunks.Add(loadedchunks[i]);
}
Log(LOG_INFO, _T(".chunk file loaded"));
- }
- else
- {
+ } else {
Log(LOG_INFO, _T("Indexing mode: File"));
chunks.RemoveAll();
@@ -633,56 +621,52 @@ bool CVobSubFileRipper::Create()
}
__int64 sizedone = 0, sizetotal = 0;
- for(ptrdiff_t i = 0; i < chunks.GetCount(); i++)
+ for(ptrdiff_t i = 0; i < chunks.GetCount(); i++) {
sizetotal += chunks[i].end - chunks[i].start;
+ }
- for(ptrdiff_t i = 0; !m_fBreakThread && i < chunks.GetCount(); i++)
- {
+ for(ptrdiff_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))
+ 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))
- {
+ 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)
- {
+ 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))
- {
+ 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))
+ if(vd.FindKey(buff)) {
break;
+ }
}
- if(m_fBreakThread)
+ if(m_fBreakThread) {
break;
+ }
- if(!vd.m_fFoundKey)
- {
+ if(!vd.m_fFoundKey) {
Log(LOG_ERROR, _T("Key not found, can't decrypt!"));
return(false);
}
@@ -696,12 +680,10 @@ bool CVobSubFileRipper::Create()
vd.Decrypt(buff);
}
- if(*((DWORD*)&buff[0]) != 0xba010000)
- {
+ 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)
- {
+ if(AfxMessageBox(_T("Bad packet header found, do you want to continue?"), MB_YESNO) == IDNO) {
Log(LOG_ERROR, _T("Terminated!"));
return(false);
}
@@ -718,8 +700,7 @@ bool CVobSubFileRipper::Create()
bool hasPTS = false;
if((*(DWORD*)&buff[0x0e] == 0xe0010000 || *(DWORD*)&buff[0x0e] == 0xbd010000)
- && buff[0x15] & 0x80)
- {
+ && 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)
@@ -729,22 +710,20 @@ bool CVobSubFileRipper::Create()
hasPTS = true;
}
- if(*((DWORD*)&buff[0x0e]) == 0xbb010000)
- {
+ if(*((DWORD*)&buff[0x0e]) == 0xbb010000) {
fNavpackFound = true;
- if(vob == buff[0x420] && cell == buff[0x422])
+ if(vob == buff[0x420] && cell == buff[0x422]) {
continue;
+ }
vob = buff[0x420];
cell = buff[0x422];
tOffset = tTotal = 0;
- for(ptrdiff_t i = 0; i < angle.GetCount(); i++)
- {
- if(angle[i].vob == vob && angle[i].cell == cell)
- {
+ for(ptrdiff_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;
@@ -754,9 +733,10 @@ bool CVobSubFileRipper::Create()
}
}
- if(curchunk.vc != (DWORD)((vob<<16)|cell))
- {
- if(curchunk.vc != 0) foundchunks.Add(curchunk);
+ if(curchunk.vc != (DWORD)((vob<<16)|cell)) {
+ if(curchunk.vc != 0) {
+ foundchunks.Add(curchunk);
+ }
curchunk.start = curchunk.end = curpos;
curchunk.vc = (vob<<16)|cell;
}
@@ -764,21 +744,21 @@ bool CVobSubFileRipper::Create()
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);
+ 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))
+ if(!selvcmap.Lookup(vcid, minPTSframeoffset)) {
continue;
+ }
- if(hasPTS && fDiscontinuity && !fDiscontinuityFixApplied)
- {
+ if(hasPTS && fDiscontinuity && !fDiscontinuityFixApplied) {
__int64 tDiff = tOffset - tPrevOffset;
- if(tDiff > 0 && tDiff < (PTS/90+1000))
- {
+ if(tDiff > 0 && tDiff < (PTS/90+1000)) {
CString str;
str.Format(_T("False discontinuity detected, correcting time by %I64dms"), -tDiff);
Log(LOG_INFO, str);
@@ -788,29 +768,23 @@ bool CVobSubFileRipper::Create()
fDiscontinuityFixApplied = true;
}
- if(*(DWORD*)&buff[0x0e] == 0xe0010000)
- {
- if(fDiscontinuity)
- {
- if(PTS < minPTSframeoffset)
- {
+ if(*(DWORD*)&buff[0x0e] == 0xe0010000) {
+ if(fDiscontinuity) {
+ if(PTS < minPTSframeoffset) {
selvcmap[vcid] = PTSframeoffset = PTS;
}
fDiscontinuity = false;
}
- if(m_rd.fClosedCaption)
+ if(m_rd.fClosedCaption) {
ccdec.ExtractCC(buff, 2048, tOffset + ((PTS - PTSframeoffset) / 90) - tStart);
- }
- else if(*(DWORD*)&buff[0x0e] == 0xbd010000)
- {
+ }
+ } 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)
- {
+ 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;
@@ -826,25 +800,26 @@ bool CVobSubFileRipper::Create()
}
}
- if(curchunk.vc != (DWORD)((vob<<16)|cell))
- {
- if(curchunk.vc != 0) foundchunks.Add(curchunk);
+ 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)
- {
+ if(sizedone < sizetotal) {
Log(LOG_ERROR, _T("Indexing terminated before reaching the end!"));
Progress(0);
return(false);
}
- if(!fNavpackFound)
- {
+ 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."));
+ if(!m_vob.IsDVD()) {
+ Log(LOG_ERROR, _T("Make sure the ripper doesn't strip these packets."));
+ }
Progress(0);
return(false);
}
@@ -852,28 +827,26 @@ bool CVobSubFileRipper::Create()
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 = i;
+ for(ptrdiff_t i = 0; i < 32; i++) {
+ if(m_iLang == -1 && m_langs[i].subpos.GetCount() > 0) {
+ m_iLang = 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)
- {
+ 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++)
- {
+ 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(j, packetsize, datasize, i))
- {
+ if(BYTE* buff = GetPacket(j, packetsize, datasize, i)) {
m_img.GetPacketInfo(buff, packetsize, datasize);
sp[j].fValid = m_img.fForced;
delete [] buff;
@@ -886,10 +859,8 @@ bool CVobSubFileRipper::Create()
Log(LOG_INFO, _T("Saving files..."));
- if(m_iLang != -1)
- {
- if(!Save(m_title))
- {
+ if(m_iLang != -1) {
+ if(!Save(m_title)) {
Log(LOG_ERROR, _T("Could not save output files!"));
return(false);
}
@@ -897,10 +868,8 @@ bool CVobSubFileRipper::Create()
Log(LOG_INFO, _T("Subtitles saved"));
- if(!m_vob.IsDVD() && loadedchunks.GetCount() == 0)
- {
- if(SaveChunks(foundchunks))
- {
+ if(!m_vob.IsDVD() && loadedchunks.GetCount() == 0) {
+ if(SaveChunks(foundchunks)) {
Log(LOG_INFO, _T(".chunk file saved"));
}
}
@@ -923,11 +892,11 @@ bool CVobSubFileRipper::LoadChunks(CAtlArray<vcchunk>& chunks)
DWORD chksum = 0, chunklen, version;
__int64 voblen = 0;
- if(!f.Open(fn, CFile::modeRead|CFile::typeBinary|CFile::shareDenyNone))
+ if(!f.Open(fn, CFile::modeRead|CFile::typeBinary|CFile::shareDenyNone)) {
return(false);
+ }
f.Read(&version, sizeof(version));
- if(version == 1)
- {
+ if(version == 1) {
f.Read(&chksum, sizeof(chksum));
f.Read(&voblen, sizeof(voblen));
f.Read(&chunklen, sizeof(chunklen));
@@ -936,20 +905,21 @@ bool CVobSubFileRipper::LoadChunks(CAtlArray<vcchunk>& chunks)
}
f.Close();
- if(voblen != m_vob.GetLength())
- {
+ if(voblen != m_vob.GetLength()) {
chunks.RemoveAll();
return(false);
}
- if(!f.Open(m_infn, CFile::modeRead|CFile::typeBinary|CFile::shareDenyNone))
+ 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;
+ while(f.Read(&dw, sizeof(dw)) == sizeof(dw)) {
+ chksum2 += dw;
+ }
f.Close();
- if(chksum != chksum2)
- {
+ if(chksum != chksum2) {
chunks.RemoveAll();
return(false);
}
@@ -968,14 +938,18 @@ bool CVobSubFileRipper::SaveChunks(CAtlArray<vcchunk>& chunks)
DWORD chksum = 0, chunklen = chunks.GetCount();
__int64 voblen = m_vob.GetLength();
- if(!f.Open(m_infn, CFile::modeRead|CFile::typeBinary|CFile::shareDenyNone))
+ 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;
+ while(f.Read(&dw, sizeof(dw)) == sizeof(dw)) {
+ chksum += dw;
+ }
f.Close();
- if(!f.Open(fn, CFile::modeCreate|CFile::modeWrite|CFile::typeBinary|CFile::shareDenyWrite))
+ 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));
@@ -1002,8 +976,9 @@ STDMETHODIMP CVobSubFileRipper::LoadParamFile(CString fn)
m_rd.Reset();
CStdioFile f;
- if(!f.Open(fn, CFile::modeRead|CFile::typeText))
+ if(!f.Open(fn, CFile::modeRead|CFile::typeText)) {
return E_FAIL;
+ }
TCHAR langid[256];
@@ -1011,102 +986,89 @@ STDMETHODIMP CVobSubFileRipper::LoadParamFile(CString fn)
int phase = P_INPUT;
CString line;
- while(f.ReadString(line))
- {
- if(line.Trim().IsEmpty() || line[0] == '#') continue;
+ while(f.ReadString(line)) {
+ if(line.Trim().IsEmpty() || line[0] == '#') {
+ continue;
+ }
- if(phase == P_INPUT)
- {
- if(S_OK != SetInput(line)) break;
+ if(phase == P_INPUT) {
+ if(S_OK != SetInput(line)) {
+ break;
+ }
phase = P_OUTPUT;
- }
- else if(phase == P_OUTPUT)
- {
- if(S_OK != SetOutput(line)) break;
+ } else if(phase == P_OUTPUT) {
+ if(S_OK != SetOutput(line)) {
+ break;
+ }
phase = P_PGC;
- }
- else if(phase == P_PGC)
- {
+ } else if(phase == P_PGC) {
m_rd.iSelPGC = _tcstol(line, NULL, 10)-1;
- if(m_rd.iSelPGC < 0 || m_rd.iSelPGC >= m_rd.pgcs.GetCount()) break;
+ if(m_rd.iSelPGC < 0 || m_rd.iSelPGC >= m_rd.pgcs.GetCount()) {
+ break;
+ }
phase = P_ANGLE;
- }
- else if(phase == 3)
- {
+ } 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;
+ 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)
- {
+ 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)
- {
+ while(s < e) {
+ if(*s == 'v' || s == e-1) {
s++;
- if(vob != 0 && cell == 0)
- {
- for(ptrdiff_t i = 0; i < angle.GetCount(); i++)
- {
- if(angle[i].vob == vob)
+ if(vob != 0 && cell == 0) {
+ for(ptrdiff_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)
- {
+ } else if(*s == 'c' && vob > 0) {
s++;
cell = _tcstol(s, &s, 10);
- for(ptrdiff_t i = 0; i < angle.GetCount(); i++)
- {
- if(angle[i].vob == vob && angle[i].cell == cell)
- {
+ for(ptrdiff_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
- {
+ } else {
s++;
}
}
- }
- else
- {
- for(ptrdiff_t i = 0; i < angle.GetCount(); i++)
+ } else {
+ for(ptrdiff_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(ptrdiff_t i = 0; i < 32; i++) m_rd.selids[i] = true;
+ } else if(phase == 4) {
+ if(!line.CompareNoCase(_T("ALL"))) {
+ for(ptrdiff_t i = 0; i < 32; i++) {
+ m_rd.selids[i] = true;
+ }
m_rd.fClosedCaption = true;
phase = P_OPTIONS;
- }
- else
- {
+ } else {
line += ' ';
- while(line.GetLength() > 0)
- {
+ while(line.GetLength() > 0) {
int n = line.Find(_T(" "));
CString lang = line.Left(n);
@@ -1118,48 +1080,50 @@ STDMETHODIMP CVobSubFileRipper::LoadParamFile(CString fn)
int langnum;
- if(_istdigit(lang[0]))
- {
+ if(_istdigit(lang[0])) {
n = _stscanf(lang, _T("%d"), &langnum);
- if(n != 1) break;
+ if(n != 1) {
+ break;
+ }
m_rd.selids[langnum] = true;
- }
- else if(_istalpha(lang[0]))
- {
+ } else if(_istalpha(lang[0])) {
n = _stscanf(lang, _T("%s"), langid);
- if(n != 1) break;
+ if(n != 1) {
+ break;
+ }
int id = (langid[0] << 8) + langid[1];
- if(id == 'cc')
- {
+ if(id == 'cc') {
m_rd.fClosedCaption = true;
- }
- else
- {
+ } else {
m_rd.selids[id] = true;
}
+ } else {
+ break;
}
- else break;
- if(n != 1) break;
+ if(n != 1) {
+ break;
+ }
}
- if((m_rd.selids.GetCount() > 0 || m_rd.fClosedCaption) && line.IsEmpty())
+ if((m_rd.selids.GetCount() > 0 || m_rd.fClosedCaption) && line.IsEmpty()) {
phase = P_OPTIONS;
+ }
}
- }
- else if(phase == 5 && !line.CompareNoCase(_T("CLOSE")))
+ } else if(phase == 5 && !line.CompareNoCase(_T("CLOSE"))) {
m_rd.fClose = true;
- else if(phase == 5 && !line.CompareNoCase(_T("BEEP")))
+ } else if(phase == 5 && !line.CompareNoCase(_T("BEEP"))) {
m_rd.fBeep = true;
- else if(phase == 5 && !line.CompareNoCase(_T("RESETTIME")))
+ } else if(phase == 5 && !line.CompareNoCase(_T("RESETTIME"))) {
m_rd.fResetTime = true;
- else if(phase == 5 && !line.CompareNoCase(_T("FORCEDONLY")))
+ } else if(phase == 5 && !line.CompareNoCase(_T("FORCEDONLY"))) {
m_rd.fForcedOnly = true;
- else if(phase == 5 && !line.CompareNoCase(_T("CLOSEIGNOREERRORS")))
+ } else if(phase == 5 && !line.CompareNoCase(_T("CLOSEIGNOREERRORS"))) {
m_rd.fCloseIgnoreError = true;
+ }
}
@@ -1174,8 +1138,9 @@ STDMETHODIMP CVobSubFileRipper::SetInput(CString infn)
m_rd.Reset();
- if(!LoadIfo(infn) || !LoadVob(infn))
+ if(!LoadIfo(infn) || !LoadVob(infn)) {
return E_INVALIDARG;
+ }
m_infn = infn;
@@ -1205,7 +1170,9 @@ STDMETHODIMP CVobSubFileRipper::UpdateRipperData(VSFRipperData& rd)
STDMETHODIMP CVobSubFileRipper::Index()
{
- if(m_fIndexing) return E_FAIL;
+ if(m_fIndexing) {
+ return E_FAIL;
+ }
CAMThread::CallWorker(CMD_INDEX);
return S_OK;
}
@@ -1245,16 +1212,15 @@ void VSFRipperData::Copy(VSFRipperData& rd)
vidsize = rd.vidsize;
vidinfo = rd.vidinfo;
- if(int len = rd.pgcs.GetCount())
- {
+ if(int len = rd.pgcs.GetCount()) {
pgcs.SetCount(len);
- for(ptrdiff_t i = 0; i < len; i++)
- {
+ for(ptrdiff_t i = 0; i < len; i++) {
PGC& src = rd.pgcs[i];
PGC& dst = pgcs[i];
dst.nAngles = src.nAngles;
- for(ptrdiff_t i = 0; i < countof(dst.angles); i++)
+ for(ptrdiff_t i = 0; i < countof(dst.angles); i++) {
dst.angles[i].Copy(src.angles[i]);
+ }
dst.iSelAngle = src.iSelAngle;
memcpy(dst.pal, src.pal, sizeof(src.pal));
memcpy(dst.ids, src.ids, sizeof(src.ids));
@@ -1270,8 +1236,7 @@ void VSFRipperData::Copy(VSFRipperData& rd)
fCloseIgnoreError = rd.fCloseIgnoreError;
selvcs.Copy(rd.selvcs);
POSITION pos = rd.selids.GetStartPosition();
- while(pos)
- {
+ while(pos) {
BYTE key;
bool val;
rd.selids.GetNextAssoc(pos, key, val);
diff --git a/src/Subtitles/VobSubFileRipper.h b/src/Subtitles/VobSubFileRipper.h
index af78d01ff..fb29fe9c2 100644
--- a/src/Subtitles/VobSubFileRipper.h
+++ b/src/Subtitles/VobSubFileRipper.h
@@ -30,8 +30,7 @@
#pragma pack(push)
#pragma pack(1)
-typedef struct
-{
+typedef struct {
WORD perm_displ : 2;
WORD ratio : 2;
WORD system : 2;
@@ -44,8 +43,7 @@ typedef struct
WORD line21_1 : 1;
} vidinfo;
-typedef struct
-{
+typedef struct {
BYTE vob, cell;
DWORD tTime, tOffset, tTotal;
DWORD start, end;
@@ -53,8 +51,7 @@ typedef struct
bool fDiscontinuity;
} vc_t;
-typedef struct
-{
+typedef struct {
int nAngles;
CAtlArray<vc_t> angles[10];
int iSelAngle;
@@ -62,8 +59,7 @@ typedef struct
WORD ids[32];
} PGC;
-typedef struct VSFRipperData_t
-{
+typedef struct VSFRipperData_t {
CSize vidsize;
vidinfo vidinfo;
CAtlArray<PGC> pgcs;
@@ -81,8 +77,7 @@ typedef struct VSFRipperData_t
} VSFRipperData;
-typedef struct
-{
+typedef struct {
__int64 start, end;
DWORD vc;
} vcchunk;
@@ -97,8 +92,7 @@ typedef struct
interface __declspec(uuid("9E2EBB5C-AD7C-452f-A48B-38685716AC46"))
IVSFRipperCallback :
-public IUnknown
-{
+public IUnknown {
STDMETHOD (OnMessage) (LPCTSTR msg) PURE;
STDMETHOD (OnProgress) (double progress /*0->1*/) PURE;
STDMETHOD (OnFinished) (bool fSucceeded) PURE;
@@ -114,8 +108,7 @@ class IVSFRipperCallbackImpl : public CUnknown, public IVSFRipperCallback
{
protected:
DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv)
- {
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv) {
return
QI(IVSFRipperCallback)
__super::NonDelegatingQueryInterface(riid, ppv);
@@ -142,8 +135,7 @@ public:
interface __declspec(uuid("69F935BB-B8D0-43f5-AA2E-BBD0851CC9A6"))
IVSFRipper :
-public IUnknown
-{
+public IUnknown {
STDMETHOD (SetCallBack) (IVSFRipperCallback* pCallback) PURE;
STDMETHOD (LoadParamFile) (CString fn) PURE;
STDMETHOD (SetInput) (CString infn) PURE;
diff --git a/src/Subtitles/VobSubImage.cpp b/src/Subtitles/VobSubImage.cpp
index 9a87bc4b2..3443aa54b 100644
--- a/src/Subtitles/VobSubImage.cpp
+++ b/src/Subtitles/VobSubImage.cpp
@@ -45,12 +45,13 @@ bool CVobSubImage::Alloc(int w, int h)
// 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))
- {
+ 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);
+ if(!lpTemp1) {
+ return(false);
+ }
lpTemp2 = DNew RGBQUAD[(w+2)*(h+2)];
if(!lpTemp2) {
@@ -70,10 +71,14 @@ bool CVobSubImage::Alloc(int w, int h)
void CVobSubImage::Free()
{
- if(lpTemp1) delete [] lpTemp1;
+ if(lpTemp1) {
+ delete [] lpTemp1;
+ }
lpTemp1 = NULL;
- if(lpTemp2) delete [] lpTemp2;
+ if(lpTemp2) {
+ delete [] lpTemp2;
+ }
lpTemp2 = NULL;
lpPixels = NULL;
@@ -87,7 +92,9 @@ bool CVobSubImage::Decode(BYTE* lpData, int packetsize, int datasize,
{
GetPacketInfo(lpData, packetsize, datasize);
- if(!Alloc(rect.Width(), rect.Height())) return(false);
+ if(!Alloc(rect.Width(), rect.Height())) {
+ return(false);
+ }
lpPixels = lpTemp1;
@@ -104,22 +111,24 @@ bool CVobSubImage::Decode(BYTE* lpData, int packetsize, int datasize,
int end0 = nOffset[1];
int end1 = datasize;
- while((nPlane == 0 && nOffset[0] < end0) || (nPlane == 1 && nOffset[1] < end1))
- {
+ 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)
- {
+ || (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((p.x += code >> 2) < rect.right) {
+ continue;
+ }
}
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++;
@@ -128,20 +137,21 @@ bool CVobSubImage::Decode(BYTE* lpData, int packetsize, int datasize,
rect.bottom = min(p.y, rect.bottom);
- if(fTrim) TrimSubImage();
+ if(fTrim) {
+ TrimSubImage();
+ }
return(true);
}
void CVobSubImage::GetPacketInfo(BYTE* lpData, int packetsize, int datasize)
{
-// delay = 0;
+ // delay = 0;
int i, nextctrlblk = datasize;
WORD pal = 0, tr = 0;
- do
- {
+ do {
i = nextctrlblk;
int t = (lpData[i] << 8) | lpData[i+1];
@@ -149,98 +159,91 @@ void CVobSubImage::GetPacketInfo(BYTE* lpData, int packetsize, int datasize)
nextctrlblk = (lpData[i] << 8) | lpData[i+1];
i += 2;
- if(nextctrlblk > packetsize || nextctrlblk < datasize)
- {
+ if(nextctrlblk > packetsize || nextctrlblk < datasize) {
ASSERT(0);
return;
}
bool fBreak = false;
- while(!fBreak)
- {
+ 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;
+ 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)
- {
+ 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;
+ 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);
+ } while(i <= nextctrlblk && i < packetsize);
- for(i = 0; i < 4; i++)
- {
+ for(i = 0; i < 4; i++) {
this->pal[i].pal = (pal >> (i << 2)) & 0xf;
this->pal[i].tr = (tr >> (i << 2)) & 0xf;
}
@@ -258,32 +261,34 @@ BYTE CVobSubImage::GetNibble(BYTE* lpData)
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)
- {
+ || 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;
+ 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)
- {
+ if(!fCustomPal) {
c = orgpal[pal[colorid].pal];
c.rgbReserved = (pal[colorid].tr<<4)|pal[colorid].tr;
- }
- else
- {
+ } else {
c = cuspal[colorid];
}
- while(length-- > 0) *ptr++ = c;
+ while(length-- > 0) {
+ *ptr++ = c;
+ }
}
void CVobSubImage::TrimSubImage()
@@ -296,21 +301,28 @@ void CVobSubImage::TrimSubImage()
RGBQUAD* ptr = lpTemp1;
- for(ptrdiff_t j = 0, y = rect.Height(); j < y; j++)
- {
- for(ptrdiff_t 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(ptrdiff_t j = 0, y = rect.Height(); j < y; j++) {
+ for(ptrdiff_t 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);
@@ -327,8 +339,7 @@ void CVobSubImage::TrimSubImage()
memset(lpTemp2, 0, (1 + w + 1)*sizeof(RGBQUAD));
- for(ptrdiff_t height = h; height; height--, src += rect.Width())
- {
+ for(ptrdiff_t height = h; height; height--, src += rect.Width()) {
*dst++ = 0;
memcpy(dst, src, w*sizeof(RGBQUAD));
dst += w;
@@ -352,54 +363,65 @@ void CVobSubImage::TrimSubImage()
CAutoPtrList<COutline>* CVobSubImage::GetOutlineList(CPoint& topleft)
{
int w = rect.Width(), h = rect.Height(), len = w*h;
- if(len <= 0) return NULL;
+ if(len <= 0) {
+ return NULL;
+ }
CAutoVectorPtr<BYTE> p;
- if(!p.Allocate(len)) return NULL;
+ if(!p.Allocate(len)) {
+ return NULL;
+ }
CAutoPtrList<COutline>* ol = DNew CAutoPtrList<COutline>();
- if(!ol) return NULL;
+ if(!ol) {
+ return NULL;
+ }
BYTE* cp = p;
RGBQUAD* rgbp = (RGBQUAD*)lpPixels;
- for(ptrdiff_t i = 0; i < len; i++, cp++, rgbp++)
+ for(ptrdiff_t i = 0; i < len; i++, cp++, rgbp++) {
*cp = !!rgbp->rgbReserved;
+ }
enum {UP, RIGHT, DOWN, LEFT};
topleft.x = topleft.y = INT_MAX;
- while(1)
- {
+ while(1) {
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;
+ 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;
+ if(x < w-1) {
+ break;
+ }
cp++;
}
- if(y == h) break;
+ if(y == h) {
+ break;
+ }
int prevdir, dir = UP;
int ox = x, oy = y, odir = dir;
CAutoPtr<COutline> o(DNew COutline);
- if(!o) break;
+ if(!o) {
+ break;
+ }
- do
- {
+ do {
CPoint pp;
BYTE fl = 0;
BYTE fr = 0;
@@ -407,32 +429,31 @@ CAutoPtrList<COutline>* CVobSubImage::GetOutlineList(CPoint& topleft)
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;
+ 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:
@@ -444,61 +465,70 @@ CAutoPtrList<COutline>* CVobSubImage::GetOutlineList(CPoint& topleft)
//
// 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) {
+ 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;
+ 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(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))
- {
+ if(o->pa.GetCount() > 0 && (x == ox && y == oy && dir == odir)) {
ol->AddTail(o);
- }
- else
- {
+ } else {
ASSERT(0);
}
}
@@ -509,23 +539,37 @@ CAutoPtrList<COutline>* CVobSubImage::GetOutlineList(CPoint& topleft)
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...
+ 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--);
+ 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);
+ if(end-start < 8 || end-start < (len-end)+(start-0)) {
+ return(false);
+ }
CUIntArray la, ra;
int 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);
+ 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;
}
@@ -534,16 +578,28 @@ static bool FitLine(COutline& o, int& start, int& end)
// these tests are completly heuristic and might be redundant a bit...
for(i = 0, j = la.GetSize(); i < j && fl; i++) {
- if(la[i] != 1) fl = false;
+ if(la[i] != 1) {
+ fl = false;
+ }
}
for(i = 0, j = ra.GetSize(); i < j && fr; i++) {
- if(ra[i] != 1) fr = false;
+ 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); // -''-
+ 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;
@@ -551,19 +607,27 @@ static bool FitLine(COutline& o, int& start, int& end)
int sum = 0;
- for(i = 0, j = INT_MAX, k = 0; i < len; i++)
- {
- if(j > a[i]) j = a[i];
- if(k < a[i]) k = a[i];
+ for(i = 0, j = INT_MAX, k = 0; i < 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(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);
+ if((la.GetSize()/2+ra.GetSize()/2)/2 <= 2) {
+ if((k+j)/2 < 2 && k*j!=1) {
+ return(false);
+ }
}
double err = 0;
@@ -576,18 +640,20 @@ static bool FitLine(COutline& o, int& start, int& end)
vx /= l;
vy /= l;
- for(i = start+1, j = end-1; i <= j; i++)
- {
+ 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;
+ if(minerr > -t) {
+ minerr = -t;
+ }
+ } else {
+ if(maxerr < t) {
+ maxerr = t;
+ }
}
}
@@ -600,10 +666,8 @@ static int CalcPossibleCurveDegree(COutline& o)
CUIntArray la;
- for(ptrdiff_t i = 0, j = 0; j < len2; j++)
- {
- if(j == len2-1 || o.da[j])
- {
+ for(ptrdiff_t i = 0, j = 0; j < len2; j++) {
+ if(j == len2-1 || o.da[j]) {
la.Add(j-i);
i = j;
}
@@ -619,23 +683,22 @@ static int CalcPossibleCurveDegree(COutline& o)
int penalty = 0;
int ma[2] = {0, 0};
- for(ptrdiff_t i = 0; i < len; i++) ma[i&1] += la[i];
+ 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++)
- {
+ 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];
- if(len2 > 16 && (fabs(c1-c2) > 0.7 || (c3 > 0.6 && la[i] > 5)))
- {
+ 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))
- {
+ if(fabs(c1-c2) > 0.6 || (c3 > 0.4 && la[i] > 5)) {
penalty = 1;
}
}
@@ -646,8 +709,7 @@ static int CalcPossibleCurveDegree(COutline& o)
la[0] <<= 1;
la[len-1] <<= 1;
- for(ptrdiff_t i = 0; i < len; i+=2)
- {
+ 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--;
@@ -672,7 +734,9 @@ static bool MinMaxCosfi(COutline& o, double& mincf, double& maxcf) // not really
CAtlArray<CPoint>& pa = o.pa;
int len = (int)pa.GetCount();
- if(len < 6) return(false);
+ if(len < 6) {
+ return(false);
+ }
mincf = 1;
maxcf = -1;
@@ -681,8 +745,7 @@ static bool MinMaxCosfi(COutline& o, double& mincf, double& maxcf) // not really
double l = vectlen(p);
UNUSED_ALWAYS(l);
- for(ptrdiff_t i = 2; i < len-2; i++) // skip the endpoints, they aren't accurate
- {
+ 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;
@@ -690,8 +753,12 @@ static bool MinMaxCosfi(COutline& o, double& mincf, double& maxcf) // not really
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;
+ if(mincf > cosfi) {
+ mincf = cosfi;
+ }
+ if(maxcf < cosfi) {
+ maxcf = cosfi;
+ }
}
return(true);
@@ -705,12 +772,9 @@ static bool FitBezierVH(COutline& o, CPoint& p1, CPoint& p2)
int len = (int)pa.GetCount();
- if(len <= 1)
- {
+ if(len <= 1) {
return(false);
- }
- else if(len == 2)
- {
+ } else if(len == 2) {
CPoint mid = pa[0]+pa[1];
mid.x >>= 1;
mid.y >>= 1;
@@ -719,18 +783,20 @@ static bool FitBezierVH(COutline& o, CPoint& p1, CPoint& p2)
}
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((dir1.x&&dir1.y)||(dir2.x&&dir2.y)) {
+ return(false); // we are only fitting beziers with hor./ver. endings
+ }
- if(CalcPossibleCurveDegree(o) > 3)
+ if(CalcPossibleCurveDegree(o) > 3) {
return(false);
+ }
double mincf, maxcf;
- if(MinMaxCosfi(o, mincf, maxcf))
- {
+ if(MinMaxCosfi(o, mincf, maxcf)) {
if(maxcf-mincf > 0.8
- || maxcf-mincf > 0.6 && (maxcf >= 0.4 || mincf <= -0.4))
+ || maxcf-mincf > 0.6 && (maxcf >= 0.4 || mincf <= -0.4)) {
return(false);
+ }
}
CPoint p0 = p1 = pa[0];
@@ -743,14 +809,12 @@ static bool FitBezierVH(COutline& o, CPoint& p1, CPoint& p2)
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++)
- {
+ 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++)
- {
+ for(i = 0; i < len; i++) {
double t1 = pl[i] / length;
double t2 = t1*t1;
double t3 = t2*t1;
@@ -776,40 +840,32 @@ static bool FitBezierVH(COutline& o, CPoint& p1, CPoint& p2)
c2y += pa[i].y*dc2;
}
- if(dir1.y == 0 && dir2.x == 0)
- {
+ 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)
- {
+ } 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)
- {
+ } 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)
- {
+ } 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
- {
+ } 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)
+ if((dir1.x*dir3.x+dir1.y*dir3.y) <= 0 || (dir2.x*dir4.x+dir2.y*dir4.y) <= 0) {
return(false);
+ }
return(true);
}
@@ -823,16 +879,18 @@ int CVobSubImage::GrabSegment(int start, COutline& o, COutline& ret)
int cur = (start)%len, first = -1, last = -1;
int lastDir = 0;
- for(ptrdiff_t i = 0; i < len; i++)
- {
+ for(ptrdiff_t i = 0; i < len; i++) {
cur = (cur+1)%len;
- if(o.da[cur] == 0) continue;
+ if(o.da[cur] == 0) {
+ continue;
+ }
- if(first == -1) first = cur;
+ if(first == -1) {
+ first = cur;
+ }
- if(lastDir == o.da[cur])
- {
+ if(lastDir == o.da[cur]) {
CPoint startp = o.pa[first]+o.pa[start];
startp.x >>= 1;
startp.y >>= 1;
@@ -840,21 +898,30 @@ int CVobSubImage::GrabSegment(int start, COutline& o, COutline& ret)
endp.x >>= 1;
endp.y >>= 1;
- if(first < start) first += len;
+ if(first < start) {
+ first += len;
+ }
start = ((start+first)>>1)+1;
- if(start >= len) start -= len;
- if(cur < last) cur += len;
+ if(start >= len) {
+ start -= len;
+ }
+ if(cur < last) {
+ cur += len;
+ }
cur = ((last+cur+1)>>1);
- if(cur >= len) cur -= len;
+ if(cur >= len) {
+ cur -= len;
+ }
ret.Add(startp, 0);
- while(start != cur)
- {
+ while(start != cur) {
ret.Add(o.pa[start], o.da[start]);
start++;
- if(start >= len) start -= len;
+ if(start >= len) {
+ start -= len;
+ }
}
ret.Add(endp, 0);
@@ -874,16 +941,16 @@ int CVobSubImage::GrabSegment(int start, COutline& o, COutline& ret)
void CVobSubImage::SplitOutline(COutline& o, COutline& o1, COutline& o2)
{
int len = int(o.pa.GetCount());
- if(len < 4) return;
+ if(len < 4) {
+ return;
+ }
CAtlArray<UINT> la, sa, ea;
int i, j, k;
- for(i = 0, j = 0; j < len; j++)
- {
- if(j == len-1 || o.da[j])
- {
+ for(i = 0, j = 0; j < len; j++) {
+ if(j == len-1 || o.da[j]) {
la.Add(j-i);
sa.Add(i);
ea.Add(j);
@@ -894,33 +961,32 @@ void CVobSubImage::SplitOutline(COutline& o, COutline& o1, COutline& o2)
int maxlen = 0, maxidx = -1;
int maxlen2 = 0, maxidx2 = -1;
- for(i = 0; i < la.GetCount(); i++)
- {
- if(maxlen < la[i])
- {
+ 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)
- {
+ 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
+ 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++)
+ for(i = 0; i <= j; i++) {
o1.Add(o.pa[i], o.da[i]);
+ }
- if(j != k)
- {
+ if(j != k) {
CPoint mid = o.pa[j]+o.pa[k];
mid.x >>= 1;
mid.y >>= 1;
@@ -928,44 +994,45 @@ void CVobSubImage::SplitOutline(COutline& o, COutline& o1, COutline& o2)
o2.Add(mid, 0);
}
- for(i = k; i < len; i++)
+ 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;
+ 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
- {
+ if(nLeftTurns == 0 && nRightTurns == 0) { // line
pathTypes.Add(PT_LINETO);
pathPoints.Add(o.pa[len-1]);
return;
}
- if(nLeftTurns == 0 || nRightTurns == 0) // b-spline
- {
+ 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++)
- {
+ for(i = 0; i < 3; i++) {
pathTypes.Add(PT_BSPLINETO);
pathPoints.Add(o.pa[i]);
}
- for(; i < len; i++)
- {
+ for(; i < len; i++) {
pathTypes.Add(PT_BSPLINEPATCHTO);
pathPoints.Add(o.pa[i]);
}
@@ -980,8 +1047,7 @@ void CVobSubImage::AddSegment(COutline& o, CAtlArray<BYTE>& pathTypes, CAtlArray
}
int start, end;
- if(FitLine(o, start, end)) // b-spline, line, b-spline
- {
+ 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]));
@@ -1003,18 +1069,14 @@ void CVobSubImage::AddSegment(COutline& o, CAtlArray<BYTE>& pathTypes, CAtlArray
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)
- {
+ if(start == 1) {
pathTypes.Add(PT_BSPLINETO);
pathPoints.Add(p[0]);
- }
- else
- {
+ } else {
pathTypes.Add(PT_BSPLINETO);
pathPoints.Add(o.pa[2]);
- for(ptrdiff_t i = 3; i <= start; i++)
- {
+ for(ptrdiff_t i = 3; i <= start; i++) {
pathTypes.Add(PT_BSPLINEPATCHTO);
pathPoints.Add(o.pa[i]);
}
@@ -1038,8 +1100,7 @@ void CVobSubImage::AddSegment(COutline& o, CAtlArray<BYTE>& pathTypes, CAtlArray
pathTypes.Add(PT_BSPLINEPATCHTO);
pathPoints.Add(p[3]);
- for(i = end; i < len; i++)
- {
+ for(i = end; i < len; i++) {
pathTypes.Add(PT_BSPLINEPATCHTO);
pathPoints.Add(o.pa[i]);
}
@@ -1054,8 +1115,7 @@ void CVobSubImage::AddSegment(COutline& o, CAtlArray<BYTE>& pathTypes, CAtlArray
}
CPoint p1, p2;
- if(FitBezierVH(o, p1, p2)) // bezier
- {
+ if(FitBezierVH(o, p1, p2)) { // bezier
pathTypes.Add(PT_BEZIERTO);
pathPoints.Add(p1);
pathTypes.Add(PT_BEZIERTO);
@@ -1076,38 +1136,36 @@ bool CVobSubImage::Polygonize(CAtlArray<BYTE>& pathTypes, CAtlArray<CPoint>& pat
{
CPoint topleft;
CAutoPtr<CAutoPtrList<COutline> > ol(GetOutlineList(topleft));
- if(!ol) return(false);
+ if(!ol) {
+ return(false);
+ }
POSITION pos;
pos = ol->GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CAtlArray<CPoint>& pa = ol->GetNext(pos)->pa;
- for(ptrdiff_t i = 0; i < pa.GetCount(); i++)
- {
+ for(ptrdiff_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)
- {
+ while(pos) {
COutline& o = *ol->GetNext(pos), o2;
- if(fSmooth)
- {
+ if(fSmooth) {
int i = 0, iFirst = -1;
- while(1)
- {
+ while(1) {
i = GrabSegment(i, o, o2);
- if(i == iFirst) break;
+ if(i == iFirst) {
+ break;
+ }
- if(iFirst < 0)
- {
+ if(iFirst < 0) {
iFirst = i;
pathTypes.Add(PT_MOVETO);
pathPoints.Add(o2.pa[0]);
@@ -1115,33 +1173,30 @@ bool CVobSubImage::Polygonize(CAtlArray<BYTE>& pathTypes, CAtlArray<CPoint>& pat
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;
- }
- }
-*/
+ } 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(ptrdiff_t i = 1, len = int(o.pa.GetCount()); i < len; i++)
- {
+ for(ptrdiff_t i = 1, len = int(o.pa.GetCount()); i < len; i++) {
pathTypes.Add(PT_LINETO);
pathPoints.Add(o.pa[i]);
}
@@ -1156,54 +1211,63 @@ bool CVobSubImage::Polygonize(CStringW& assstr, bool fSmooth, int scale)
CAtlArray<BYTE> pathTypes;
CAtlArray<CPoint> pathPoints;
- if(!Polygonize(pathTypes, pathPoints, fSmooth, scale))
+ 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);
+ // assstr.Format(L"{\\p%d}", 1+scale);
BYTE lastType = 0;
int nPoints = int(pathTypes.GetCount());
- for(ptrdiff_t i = 0; i < nPoints; i++)
- {
+ for(ptrdiff_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 < nPoints-2)
- {
- 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 < nPoints-2)
- {
- 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;
+ 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 < nPoints-2) {
+ 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 < nPoints-2) {
+ 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];
@@ -1223,10 +1287,8 @@ void CVobSubImage::Scale2x()
DWORD* src = (DWORD*)lpPixels;
DWORD* dst = DNew DWORD[w*h];
- for(ptrdiff_t y = 0; y < h; y++)
- {
- for(ptrdiff_t x = 0; x < w; x++, src++, dst++)
- {
+ for(ptrdiff_t y = 0; y < h; y++) {
+ for(ptrdiff_t x = 0; x < w; x++, src++, dst++) {
DWORD E = *src;
DWORD A = x > 0 && y > 0 ? src[-w-1] : E;
diff --git a/src/Subtitles/VobSubImage.h b/src/Subtitles/VobSubImage.h
index 2da5497c2..c0f1669dc 100644
--- a/src/Subtitles/VobSubImage.h
+++ b/src/Subtitles/VobSubImage.h
@@ -25,17 +25,14 @@
#include <atlcoll.h>
-typedef struct
-{
+typedef struct {
CAtlArray<CPoint> pa;
CAtlArray<int> da;
- void RemoveAll()
- {
+ void RemoveAll() {
pa.RemoveAll();
da.RemoveAll();
}
- void Add(CPoint p, int d)
- {
+ void Add(CPoint p, int d) {
pa.Add(p);
da.Add(d);
}
@@ -68,8 +65,7 @@ public:
bool fForced;
__int64 start, delay;
CRect rect;
- typedef struct
- {
+ typedef struct {
BYTE pal: 4, tr: 4;
} SubPal;
SubPal pal[4];
@@ -78,8 +74,7 @@ public:
CVobSubImage();
virtual ~CVobSubImage();
- void Invalidate()
- {
+ void Invalidate() {
iLang = iIdx = -1;
}
diff --git a/src/Subtitles/libssf/Arabic.cpp b/src/Subtitles/libssf/Arabic.cpp
index e08e07c36..d918d82cc 100644
--- a/src/Subtitles/libssf/Arabic.cpp
+++ b/src/Subtitles/libssf/Arabic.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -26,15 +26,13 @@
namespace ssf
{
- static const struct arabicforms
- {
+ static const struct arabicforms {
unsigned short initial, medial, final, isolated;
unsigned int isletter: 1;
unsigned int joindual: 1;
unsigned int required_lig_with_alef: 1;
}
- ArabicForms[256] =
- {
+ ArabicForms[256] = {
{ 0x0600, 0x0600, 0x0600, 0x0600, 0, 0, 0 },
{ 0x0601, 0x0601, 0x0601, 0x0601, 0, 0, 0 },
{ 0x0602, 0x0602, 0x0602, 0x0602, 0, 0, 0 },
@@ -300,16 +298,25 @@ namespace ssf
bool Arabic::Replace(WCHAR& c, pres_form_t pf)
{
- if(!IsArabic(c)) return false;
+ if(!IsArabic(c)) {
+ return false;
+ }
const arabicforms& af = ArabicForms[c - 0x600];
- switch(pf)
- {
- case isol: c = af.isolated; break;
- case init: c = af.initial; break;
- case medi: c = af.medial; break;
- case fina: c = af.final; break;
+ switch(pf) {
+ case isol:
+ c = af.isolated;
+ break;
+ case init:
+ c = af.initial;
+ break;
+ case medi:
+ c = af.medial;
+ break;
+ case fina:
+ c = af.final;
+ break;
}
return true;
@@ -317,7 +324,9 @@ namespace ssf
bool Arabic::Replace(WCHAR& c, WCHAR prev, WCHAR next)
{
- if(!IsArabic(c)) return false;
+ if(!IsArabic(c)) {
+ return false;
+ }
bool p = IsArabic(prev);
bool n = IsArabic(next);
diff --git a/src/Subtitles/libssf/Arabic.h b/src/Subtitles/libssf/Arabic.h
index 23aa73d2f..3dae6fc11 100644
--- a/src/Subtitles/libssf/Arabic.h
+++ b/src/Subtitles/libssf/Arabic.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/Subtitles/libssf/Array.cpp b/src/Subtitles/libssf/Array.cpp
index 5f8155ec3..a709c2859 100644
--- a/src/Subtitles/libssf/Array.cpp
+++ b/src/Subtitles/libssf/Array.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/Subtitles/libssf/Array.h b/src/Subtitles/libssf/Array.h
index b50ded1af..7e9ac50fd 100644
--- a/src/Subtitles/libssf/Array.h
+++ b/src/Subtitles/libssf/Array.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -23,10 +23,10 @@
namespace ssf
{
- // simple array class for simple types without constructors,
+ // simple array class for simple types without constructors,
// and it doesn't free its reserves on SetCount(0)
- template<class T>
+ template<class T>
class Array
{
T* m_pData;
@@ -35,18 +35,23 @@ namespace ssf
size_t m_nGrowBy;
public:
- Array() {m_pData = NULL; m_nSize = m_nMaxSize = 0; m_nGrowBy = 4096;}
- virtual ~Array() {if(m_pData) _aligned_free(m_pData);}
+ Array() {
+ m_pData = NULL;
+ m_nSize = m_nMaxSize = 0;
+ m_nGrowBy = 4096;
+ }
+ virtual ~Array() {
+ if(m_pData) {
+ _aligned_free(m_pData);
+ }
+ }
- void SetCount(size_t nSize, size_t nGrowBy = 0)
- {
- if(nGrowBy > 0)
- {
+ void SetCount(size_t nSize, size_t nGrowBy = 0) {
+ if(nGrowBy > 0) {
m_nGrowBy = nGrowBy;
}
- if(nSize > m_nMaxSize)
- {
+ if(nSize > m_nMaxSize) {
m_nMaxSize = nSize + max(m_nGrowBy, m_nSize);
size_t nBytes = m_nMaxSize * sizeof(T);
m_pData = m_pData ? (T*)_aligned_realloc(m_pData, nBytes, 16) : (T*)_aligned_malloc(nBytes, 16);
@@ -55,54 +60,70 @@ namespace ssf
m_nSize = nSize;
}
- size_t GetCount() const {return m_nSize;}
+ size_t GetCount() const {
+ return m_nSize;
+ }
- void RemoveAll() {m_nSize = 0;}
- bool IsEmpty() const {return m_nSize == 0;}
+ void RemoveAll() {
+ m_nSize = 0;
+ }
+ bool IsEmpty() const {
+ return m_nSize == 0;
+ }
- T* GetData() {return m_pData;}
+ T* GetData() {
+ return m_pData;
+ }
- void Add(const T& t)
- {
+ void Add(const T& t) {
size_t nPos = m_nSize;
SetCount(m_nSize+1);
m_pData[nPos] = t;
}
- void Append(const Array& a, size_t nGrowBy = 0)
- {
+ void Append(const Array& a, size_t nGrowBy = 0) {
Append(a.m_pData, a.m_nSize, nGrowBy);
}
- void Append(const T* ptr, size_t nSize, size_t nGrowBy = 0)
- {
- if(!nSize) return;
+ void Append(const T* ptr, size_t nSize, size_t nGrowBy = 0) {
+ if(!nSize) {
+ return;
+ }
size_t nOldSize = m_nSize;
SetCount(nOldSize + nSize);
memcpy(m_pData + nOldSize, ptr, nSize * sizeof(T));
}
- const T& operator [] (size_t i) const {return m_pData[i];}
- T& operator [] (size_t i) {return m_pData[i];}
+ const T& operator [] (size_t i) const {
+ return m_pData[i];
+ }
+ T& operator [] (size_t i) {
+ return m_pData[i];
+ }
- void Copy(const Array& v)
- {
+ void Copy(const Array& v) {
SetCount(v.GetCount());
memcpy(m_pData, v.m_pData, m_nSize * sizeof(T));
}
- void Move(Array& v)
- {
+ void Move(Array& v) {
Swap(v);
v.SetCount(0);
}
- void Swap(Array& v)
- {
- T* pData = m_pData; m_pData = v.m_pData; v.m_pData = pData;
- size_t nSize = m_nSize; m_nSize = v.m_nSize; v.m_nSize = nSize;
- size_t nMaxSize = m_nMaxSize; m_nMaxSize = v.m_nMaxSize; v.m_nMaxSize = nMaxSize;
- size_t nGrowBy = m_nGrowBy; m_nGrowBy = v.m_nGrowBy; v.m_nGrowBy = nGrowBy;
+ void Swap(Array& v) {
+ T* pData = m_pData;
+ m_pData = v.m_pData;
+ v.m_pData = pData;
+ size_t nSize = m_nSize;
+ m_nSize = v.m_nSize;
+ v.m_nSize = nSize;
+ size_t nMaxSize = m_nMaxSize;
+ m_nMaxSize = v.m_nMaxSize;
+ v.m_nMaxSize = nMaxSize;
+ size_t nGrowBy = m_nGrowBy;
+ m_nGrowBy = v.m_nGrowBy;
+ v.m_nGrowBy = nGrowBy;
}
};
} \ No newline at end of file
diff --git a/src/Subtitles/libssf/Exception.cpp b/src/Subtitles/libssf/Exception.cpp
index 00f251cd5..2253e9926 100644
--- a/src/Subtitles/libssf/Exception.cpp
+++ b/src/Subtitles/libssf/Exception.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -24,12 +24,14 @@
namespace ssf
{
- Exception::Exception(LPCTSTR fmt, ...)
+ Exception::Exception(LPCTSTR fmt, ...)
{
va_list args;
va_start(args, fmt);
int len = _vsctprintf(fmt, args) + 1;
- if(len > 0) _vstprintf_s(m_msg.GetBufferSetLength(len), len, fmt, args);
+ if(len > 0) {
+ _vstprintf_s(m_msg.GetBufferSetLength(len), len, fmt, args);
+ }
va_end(args);
}
} \ No newline at end of file
diff --git a/src/Subtitles/libssf/Exception.h b/src/Subtitles/libssf/Exception.h
index 2aff08a90..f2cd2e076 100644
--- a/src/Subtitles/libssf/Exception.h
+++ b/src/Subtitles/libssf/Exception.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -29,7 +29,9 @@ namespace ssf
public:
Exception(LPCTSTR fmt, ...);
-
- CString ToString() const {return m_msg;}
+
+ CString ToString() const {
+ return m_msg;
+ }
};
} \ No newline at end of file
diff --git a/src/Subtitles/libssf/File.cpp b/src/Subtitles/libssf/File.cpp
index dc2154dbe..b0305ed3b 100644
--- a/src/Subtitles/libssf/File.cpp
+++ b/src/Subtitles/libssf/File.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -42,8 +42,12 @@ namespace ssf
SetPredefined(true);
- try {ParseDefs(WCharInputStream(predef), pRef);}
- catch(Exception& e) {ASSERT(0); TRACE(_T("%s\n"), e.ToString());}
+ try {
+ ParseDefs(WCharInputStream(predef), pRef);
+ } catch(Exception& e) {
+ ASSERT(0);
+ TRACE(_T("%s\n"), e.ToString());
+ }
SetPredefined(false);
@@ -51,55 +55,65 @@ namespace ssf
Commit();
- if(s.PeekChar() != Stream::EOS)
- {
+ if(s.PeekChar() != Stream::EOS) {
TRACE(_T("Warning: parsing ended before EOF!\n"));
}
}
void File::ParseDefs(InputStream& s, Reference* pParentRef)
{
- while(s.SkipWhiteSpace(L";") != '}' && s.PeekChar() != Stream::EOS)
- {
+ while(s.SkipWhiteSpace(L";") != '}' && s.PeekChar() != Stream::EOS) {
NodePriority priority = PNormal;
CAtlList<CStringW> types;
CStringW name;
int c = s.SkipWhiteSpace();
- if(c == '*') {s.GetChar(); priority = PLow;}
- else if(c == '!') {s.GetChar(); priority = PHigh;}
+ if(c == '*') {
+ s.GetChar();
+ priority = PLow;
+ } else if(c == '!') {
+ s.GetChar();
+ priority = PHigh;
+ }
ParseTypes(s, types);
- if(s.SkipWhiteSpace() == '#')
- {
+ if(s.SkipWhiteSpace() == '#') {
s.GetChar();
ParseName(s, name);
}
- if(types.IsEmpty())
- {
- if(name.IsEmpty()) s.ThrowError(_T("syntax error"));
+ if(types.IsEmpty()) {
+ if(name.IsEmpty()) {
+ s.ThrowError(_T("syntax error"));
+ }
types.AddTail(L"?");
}
Reference* pRef = pParentRef;
- while(types.GetCount() > 1)
+ while(types.GetCount() > 1) {
pRef = CreateRef(CreateDef(pRef, types.RemoveHead()));
+ }
Definition* pDef = NULL;
- if(!types.IsEmpty())
+ if(!types.IsEmpty()) {
pDef = CreateDef(pRef, types.RemoveHead(), name, priority);
+ }
c = s.SkipWhiteSpace(L":=");
- if(c == '"' || c == '\'') ParseQuotedString(s, pDef);
- else if(iswdigit(c) || c == '+' || c == '-') ParseNumber(s, pDef);
- else if(pDef->IsType(L"@")) ParseBlock(s, pDef);
- else ParseRefs(s, pDef);
+ if(c == '"' || c == '\'') {
+ ParseQuotedString(s, pDef);
+ } else if(iswdigit(c) || c == '+' || c == '-') {
+ ParseNumber(s, pDef);
+ } else if(pDef->IsType(L"@")) {
+ ParseBlock(s, pDef);
+ } else {
+ ParseRefs(s, pDef);
+ }
}
s.GetChar();
@@ -111,29 +125,32 @@ namespace ssf
CStringW str;
- for(int c = s.SkipWhiteSpace(); iswcsym(c) || c == '.' || c == '@'; c = s.PeekChar())
- {
+ for(int c = s.SkipWhiteSpace(); iswcsym(c) || c == '.' || c == '@'; c = s.PeekChar()) {
c = s.GetChar();
- if(c == '.')
- {
- if(str.IsEmpty()) s.ThrowError(_T("'type' cannot be an empty string"));
- if(!iswcsym(s.PeekChar())) s.ThrowError(_T("unexpected dot after type '%s'"), CString(str));
+ if(c == '.') {
+ if(str.IsEmpty()) {
+ s.ThrowError(_T("'type' cannot be an empty string"));
+ }
+ if(!iswcsym(s.PeekChar())) {
+ s.ThrowError(_T("unexpected dot after type '%s'"), CString(str));
+ }
types.AddTail(str);
str.Empty();
- }
- else
- {
- if(str.IsEmpty() && iswdigit(c)) s.ThrowError(_T("'type' cannot start with a number"));
- if((!str.IsEmpty() || !types.IsEmpty()) && c == '@') s.ThrowError(_T("unexpected @ in 'type'"));
+ } else {
+ if(str.IsEmpty() && iswdigit(c)) {
+ s.ThrowError(_T("'type' cannot start with a number"));
+ }
+ if((!str.IsEmpty() || !types.IsEmpty()) && c == '@') {
+ s.ThrowError(_T("unexpected @ in 'type'"));
+ }
str += (WCHAR)c;
}
}
- if(!str.IsEmpty())
- {
+ if(!str.IsEmpty()) {
types.AddTail(str);
}
}
@@ -142,9 +159,10 @@ namespace ssf
{
name.Empty();
- for(int c = s.SkipWhiteSpace(); iswcsym(c); c = s.PeekChar())
- {
- if(name.IsEmpty() && iswdigit(c)) s.ThrowError(_T("'name' cannot start with a number"));
+ for(int c = s.SkipWhiteSpace(); iswcsym(c); c = s.PeekChar()) {
+ if(name.IsEmpty() && iswdigit(c)) {
+ s.ThrowError(_T("'name' cannot start with a number"));
+ }
name += (WCHAR)s.GetChar();
}
}
@@ -154,16 +172,26 @@ namespace ssf
CStringW v;
int quote = s.SkipWhiteSpace();
- if(quote != '"' && quote != '\'') s.ThrowError(_T("expected qouted string"));
+ if(quote != '"' && quote != '\'') {
+ s.ThrowError(_T("expected qouted string"));
+ }
s.GetChar();
- for(int c = s.PeekChar(); c != Stream::EOS; c = s.PeekChar())
- {
+ for(int c = s.PeekChar(); c != Stream::EOS; c = s.PeekChar()) {
c = s.GetChar();
- if(c == quote) {pDef->SetAsValue(Definition::string, v); return;}
- if(c == '\n') s.ThrowError(_T("qouted string terminated unexpectedly by a new-line character"));
- if(c == '\\') c = s.GetChar();
- if(c == Stream::EOS) s.ThrowError(_T("qouted string terminated unexpectedly by EOS"));
+ if(c == quote) {
+ pDef->SetAsValue(Definition::string, v);
+ return;
+ }
+ if(c == '\n') {
+ s.ThrowError(_T("qouted string terminated unexpectedly by a new-line character"));
+ }
+ if(c == '\\') {
+ c = s.GetChar();
+ }
+ if(c == Stream::EOS) {
+ s.ThrowError(_T("qouted string terminated unexpectedly by EOS"));
+ }
v += (WCHAR)c;
}
@@ -174,24 +202,23 @@ namespace ssf
{
CStringW v, u;
- for(int c = s.SkipWhiteSpace(); iswxdigit(c) || wcschr(L"+-.x:", c); c = s.PeekChar())
- {
+ for(int c = s.SkipWhiteSpace(); iswxdigit(c) || wcschr(L"+-.x:", c); c = s.PeekChar()) {
if((c == '+' || c == '-') && !v.IsEmpty()
- || (c == '.' && (v.IsEmpty() || v.Find('.') >= 0 || v.Find('x') >= 0))
- || (c == 'x' && v != '0')
- || (c >= 'a' && c <= 'f' || c >= 'A' && c <= 'F') && v.Find(L"0x") != 0
- || (c == ':' && v.IsEmpty()))
- {
+ || (c == '.' && (v.IsEmpty() || v.Find('.') >= 0 || v.Find('x') >= 0))
+ || (c == 'x' && v != '0')
+ || (c >= 'a' && c <= 'f' || c >= 'A' && c <= 'F') && v.Find(L"0x") != 0
+ || (c == ':' && v.IsEmpty())) {
s.ThrowError(_T("unexpected character '%c' in number"), (TCHAR)c);
}
v += (WCHAR)s.GetChar();
}
- if(v.IsEmpty()) s.ThrowError(_T("invalid number"));
+ if(v.IsEmpty()) {
+ s.ThrowError(_T("invalid number"));
+ }
- for(int c = s.SkipWhiteSpace(); iswcsym(c); c = s.PeekChar())
- {
+ for(int c = s.SkipWhiteSpace(); iswcsym(c); c = s.PeekChar()) {
u += (WCHAR)s.GetChar();
}
@@ -203,19 +230,30 @@ namespace ssf
CStringW v;
int c = s.SkipWhiteSpace(L":=");
- if(c != '{') s.ThrowError(_T("expected '{'"));
+ if(c != '{') {
+ s.ThrowError(_T("expected '{'"));
+ }
s.GetChar();
int depth = 0;
- for(int c = s.PeekChar(); c != Stream::EOS; c = s.PeekChar())
- {
+ for(int c = s.PeekChar(); c != Stream::EOS; c = s.PeekChar()) {
c = s.GetChar();
- if(c == '}' && depth == 0) {pDef->SetAsValue(Definition::block, v); return;}
- if(c == '\\') {v += (WCHAR)c; c = s.GetChar();}
- else if(c == '{') depth++;
- else if(c == '}') depth--;
- if(c == Stream::EOS) s.ThrowError(_T("block terminated unexpectedly by EOS"));
+ if(c == '}' && depth == 0) {
+ pDef->SetAsValue(Definition::block, v);
+ return;
+ }
+ if(c == '\\') {
+ v += (WCHAR)c;
+ c = s.GetChar();
+ } else if(c == '{') {
+ depth++;
+ } else if(c == '}') {
+ depth--;
+ }
+ if(c == Stream::EOS) {
+ s.ThrowError(_T("block terminated unexpectedly by EOS"));
+ }
v += (WCHAR)c;
}
@@ -226,36 +264,35 @@ namespace ssf
{
int c = s.SkipWhiteSpace();
- do
- {
- if(pParentDef->IsValue()) s.ThrowError(_T("cannot mix references with other values"));
+ do {
+ if(pParentDef->IsValue()) {
+ s.ThrowError(_T("cannot mix references with other values"));
+ }
- if(c == '{')
- {
+ if(c == '{') {
s.GetChar();
ParseDefs(s, CreateRef(pParentDef));
- }
- else if(iswcsym(c))
- {
+ } else if(iswcsym(c)) {
CStringW str;
ParseName(s, str);
// TODO: allow spec references: parent.<type>, self.<type>, child.<type>
Definition* pDef = GetDefByName(str);
- if(!pDef) s.ThrowError(_T("cannot find definition of '%s'"), CString(str));
+ if(!pDef) {
+ s.ThrowError(_T("cannot find definition of '%s'"), CString(str));
+ }
- if(!pParentDef->IsVisible(pDef)) s.ThrowError(_T("cannot access '%s' from here"), CString(str));
+ if(!pParentDef->IsVisible(pDef)) {
+ s.ThrowError(_T("cannot access '%s' from here"), CString(str));
+ }
pParentDef->AddTail(pDef);
- }
- else if(!wcschr(term, c) && c != Stream::EOS)
- {
+ } else if(!wcschr(term, c) && c != Stream::EOS) {
s.ThrowError(_T("unexpected character '%c'"), (TCHAR)c);
}
c = s.SkipWhiteSpace();
- }
- while(!wcschr(term, c) && c != Stream::EOS);
+ } while(!wcschr(term, c) && c != Stream::EOS);
}
}
diff --git a/src/Subtitles/libssf/File.h b/src/Subtitles/libssf/File.h
index 501d3d80d..1a2250f14 100644
--- a/src/Subtitles/libssf/File.h
+++ b/src/Subtitles/libssf/File.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/Subtitles/libssf/FontWrapper.cpp b/src/Subtitles/libssf/FontWrapper.cpp
index 07d4a665b..40fd717a7 100644
--- a/src/Subtitles/libssf/FontWrapper.cpp
+++ b/src/Subtitles/libssf/FontWrapper.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -32,12 +32,12 @@ namespace ssf
GetTextMetrics(hDC, &m_tm);
- if(DWORD nNumPairs = GetKerningPairs(hDC, 0, NULL))
- {
+ if(DWORD nNumPairs = GetKerningPairs(hDC, 0, NULL)) {
KERNINGPAIR* kp = DNew KERNINGPAIR[nNumPairs];
GetKerningPairs(hDC, nNumPairs, kp);
- for(DWORD i = 0; i < nNumPairs; i++)
+ for(DWORD i = 0; i < nNumPairs; i++) {
m_kerning[(kp[i].wFirst<<16)|kp[i].wSecond] = kp[i].iKernAmount;
+ }
delete [] kp;
}
diff --git a/src/Subtitles/libssf/FontWrapper.h b/src/Subtitles/libssf/FontWrapper.h
index 176a1341e..d18eac670 100644
--- a/src/Subtitles/libssf/FontWrapper.h
+++ b/src/Subtitles/libssf/FontWrapper.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -33,9 +33,15 @@ namespace ssf
public:
FontWrapper(HDC hDC, HFONT hFont, const CStringW& key);
virtual ~FontWrapper();
- operator HFONT() const {return m_hFont;}
- operator LPCWSTR() const {return m_key;}
- const TEXTMETRIC& GetTextMetric() const {return m_tm;}
+ operator HFONT() const {
+ return m_hFont;
+ }
+ operator LPCWSTR() const {
+ return m_key;
+ }
+ const TEXTMETRIC& GetTextMetric() const {
+ return m_tm;
+ }
int GetKernAmount(WCHAR c1, WCHAR c2);
};
} \ No newline at end of file
diff --git a/src/Subtitles/libssf/Glyph.cpp b/src/Subtitles/libssf/Glyph.cpp
index a8f37dd81..58a3fecab 100644
--- a/src/Subtitles/libssf/Glyph.cpp
+++ b/src/Subtitles/libssf/Glyph.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -67,14 +67,10 @@ namespace ssf
{
path_bkg.RemoveAll();
- if(style.background.type == L"enlarge" && style.background.size > 0)
- {
+ if(style.background.type == L"enlarge" && style.background.size > 0) {
path_bkg.Enlarge(path, GetBackgroundSize());
- }
- else if(style.background.type == L"box" && style.background.size >= 0)
- {
- if(c != ssf::Text::LSEP)
- {
+ } else if(style.background.type == L"box" && style.background.size >= 0) {
+ if(c != ssf::Text::LSEP) {
int s = (int)(GetBackgroundSize() + 0.5);
int x0 = (!vertical ? -spacing/2 : ascent - row_ascent);
int y0 = (!vertical ? ascent - row_ascent : -spacing/2);
@@ -98,8 +94,9 @@ namespace ssf
{
spline.RemoveAll();
- if(style.placement.path.IsEmpty())
+ if(style.placement.path.IsEmpty()) {
return;
+ }
size_t i = 0, j = style.placement.path.GetCount();
@@ -108,22 +105,17 @@ namespace ssf
Point p;
- while(i < j)
- {
+ while(i < j) {
p.x = style.placement.path[i].x * scale.cx + spdrc.left * 64;
p.y = style.placement.path[i].y * scale.cy + spdrc.top * 64;
pts[++i] = p;
}
- if(pts.GetCount() >= 4)
- {
- if(pts[1].x == pts[j].x && pts[1].y == pts[j].y)
- {
+ if(pts.GetCount() >= 4) {
+ if(pts[1].x == pts[j].x && pts[1].y == pts[j].y) {
pts.SetAt(0, pts[j-1]);
pts.SetAt(j+1, pts[2]);
- }
- else
- {
+ } else {
p.x = pts[1].x*2 - pts[2].x;
p.y = pts[1].y*2 - pts[2].y;
pts.SetAt(0, p);
@@ -135,8 +127,7 @@ namespace ssf
spline.SetCount(pts.GetCount()-3);
- for(size_t i = 0, j = pts.GetCount()-4; i <= j; i++)
- {
+ for(size_t i = 0, j = pts.GetCount()-4; i <= j; i++) {
static const float _1div6 = 1.0f / 6;
SplineCoeffs sc;
@@ -174,20 +165,17 @@ namespace ssf
float cay = cos(deg2rad(style.placement.angle.y));
float say = sin(deg2rad(style.placement.angle.y));
- for(size_t i = 0, j = path.types.GetCount(); i < j; i++)
- {
+ for(size_t i = 0, j = path.types.GetCount(); i < j; i++) {
CPoint p = path.points[i];
- if(bscale)
- {
+ if(bscale) {
float x, y, z, xx, yy, zz;
x = sx * (p.x - org.x);
y = sy * (p.y - org.y);
z = 0;
- if(bspline)
- {
+ if(bspline) {
float pos = vertical ? y + org.y + tl.y - subrect.top : x + org.x + tl.x - subrect.left;
float size = vertical ? subrect.Size().cy : subrect.Size().cx;
float dist = vertical ? x : y;
@@ -195,13 +183,10 @@ namespace ssf
const SplineCoeffs* sc;
float t;
- if(pos >= size)
- {
+ if(pos >= size) {
sc = &spline[spline.GetCount() - 1];
t = 1;
- }
- else
- {
+ } else {
float u = size / spline.GetCount();
sc = &spline[max((int)(pos / u), 0)];
t = fmod(pos, u) / u;
@@ -218,8 +203,7 @@ namespace ssf
y = sc->cy[0] + t*(sc->cy[1] + t*(sc->cy[2] + t*sc->cy[3])) + nx * dist - org.y - tl.y;
}
- if(brotate)
- {
+ if(brotate) {
xx = x*caz + y*saz;
yy = -(x*saz - y*caz);
zz = z;
@@ -244,17 +228,29 @@ namespace ssf
path.points[i] = p;
}
- if(p.x < bbox.left) bbox.left = p.x;
- if(p.x > bbox.right) bbox.right = p.x;
- if(p.y < bbox.top) bbox.top = p.y;
- if(p.y > bbox.bottom) bbox.bottom = p.y;
+ if(p.x < bbox.left) {
+ bbox.left = p.x;
+ }
+ if(p.x > bbox.right) {
+ bbox.right = p.x;
+ }
+ if(p.y < bbox.top) {
+ bbox.top = p.y;
+ }
+ if(p.y > bbox.bottom) {
+ bbox.bottom = p.y;
+ }
}
}
void Glyph::Transform(CPoint org, const CRect& subrect)
{
- if(!style.placement.org.auto_x) org.x = style.placement.org.x * scale.cx;
- if(!style.placement.org.auto_y) org.y = style.placement.org.y * scale.cy;
+ if(!style.placement.org.auto_x) {
+ org.x = style.placement.org.x * scale.cx;
+ }
+ if(!style.placement.org.auto_y) {
+ org.y = style.placement.org.y * scale.cy;
+ }
org -= tl;
@@ -268,16 +264,14 @@ namespace ssf
void Glyph::Rasterize()
{
- if(!path_bkg.IsEmpty())
- {
+ if(!path_bkg.IsEmpty()) {
ras_bkg.ScanConvert(path_bkg, bbox);
ras_bkg.Rasterize(tl.x, tl.y);
}
ras.ScanConvert(path, bbox);
- if(style.background.type == L"outline" && style.background.size > 0)
- {
+ if(style.background.type == L"outline" && style.background.size > 0) {
ras.CreateWidenedRegion((int)(GetBackgroundSize() + 0.5));
}
@@ -285,12 +279,11 @@ namespace ssf
Rasterizer* r = path_bkg.IsEmpty() ? &ras : &ras_bkg;
int plane = path_bkg.IsEmpty() ? (style.font.color.a < 255 ? 2 : 1) : 0;
-
+
ras.Rasterize(tl.x, tl.y);
r->Blur(style.background.blur, plane);
- if(style.shadow.depth > 0)
- {
+ if(style.shadow.depth > 0) {
ras_shadow.Reuse(*r);
float depth = GetShadowDepth();
diff --git a/src/Subtitles/libssf/Glyph.h b/src/Subtitles/libssf/Glyph.h
index 68a1e4b98..7334e6fe3 100644
--- a/src/Subtitles/libssf/Glyph.h
+++ b/src/Subtitles/libssf/Glyph.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -32,7 +32,9 @@ namespace ssf
{
void Transform(GlyphPath& path, CPoint org, const CRect& subrect);
- struct SplineCoeffs {float cx[4], cy[4];};
+ struct SplineCoeffs {
+ float cx[4], cy[4];
+ };
public:
WCHAR c;
diff --git a/src/Subtitles/libssf/GlyphPath.cpp b/src/Subtitles/libssf/GlyphPath.cpp
index c444469a4..d4835ca33 100644
--- a/src/Subtitles/libssf/GlyphPath.cpp
+++ b/src/Subtitles/libssf/GlyphPath.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -31,8 +31,7 @@ namespace ssf
GlyphPath& GlyphPath::operator = (const GlyphPath& path)
{
- if(this != &path)
- {
+ if(this != &path) {
types.Copy(path.types);
points.Copy(path.points);
}
@@ -57,18 +56,15 @@ namespace ssf
unsigned int i = 0;
- if(!!(g_cpuid.m_flags & CCpuID::sse2) && !((DWORD_PTR)p & 7))
- {
- for( ; i < n && ((DWORD_PTR)&p[i] & 15); i++)
- {
+ if(!!(g_cpuid.m_flags & CCpuID::sse2) && !((DWORD_PTR)p & 7)) {
+ for( ; i < n && ((DWORD_PTR)&p[i] & 15); i++) {
p[i].x += o.x;
p[i].y += o.y;
}
__m128i oo = _mm_set_epi32(o.y, o.x, o.y, o.x);
- for(unsigned int j = i + ((n - i) & ~7); i < j; i += 8)
- {
+ for(unsigned int j = i + ((n - i) & ~7); i < j; i += 8) {
__m128i r0 = _mm_load_si128((__m128i*)&p[i+0]);
__m128i r1 = _mm_load_si128((__m128i*)&p[i+2]);
__m128i r2 = _mm_load_si128((__m128i*)&p[i+4]);
@@ -80,8 +76,7 @@ namespace ssf
}
}
- for(; i < n; i++)
- {
+ for(; i < n; i++) {
p[i].x += o.x;
p[i].y += o.y;
}
@@ -96,10 +91,8 @@ namespace ssf
size_t start = 0, end = 0;
- for(size_t i = 0, j = src.types.GetCount(); i <= j; i++)
- {
- if(i > 0 && (i == j || (src.types[i] & ~PT_CLOSEFIGURE) == PT_MOVETO))
- {
+ for(size_t i = 0, j = src.types.GetCount(); i <= j; i++) {
+ if(i > 0 && (i == j || (src.types[i] & ~PT_CLOSEFIGURE) == PT_MOVETO)) {
end = i-1;
bool cw = true; // TODO: determine orientation (ttf is always cw and we are sill before Transform)
@@ -108,19 +101,20 @@ namespace ssf
CPoint prev = src.points[end];
CPoint cur = src.points[start];
- for(size_t k = start; k <= end; k++)
- {
+ for(size_t k = start; k <= end; k++) {
CPoint next = k < end ? src.points[k+1] : src.points[start];
- for(int l = int(k-1); prev == cur; l--)
- {
- if(l < (int)start) l = int(end);
+ for(int l = int(k-1); prev == cur; l--) {
+ if(l < (int)start) {
+ l = int(end);
+ }
prev = src.points[l];
}
- for(int l = int(k+1); next == cur; l++)
- {
- if(l > (int)end) l = int(start);
+ for(int l = int(k+1); next == cur; l++) {
+ if(l > (int)end) {
+ l = int(start);
+ }
next = src.points[l];
}
@@ -130,24 +124,41 @@ namespace ssf
float angle_in = atan2((float)in.y, (float)in.x);
float angle_out = atan2((float)out.y, (float)out.x);
float angle_diff = angle_out - angle_in;
- if(angle_diff < 0) angle_diff += M_PI*2;
- if(angle_diff > M_PI) angle_diff -= M_PI*2;
+ if(angle_diff < 0) {
+ angle_diff += M_PI*2;
+ }
+ if(angle_diff > M_PI) {
+ angle_diff -= M_PI*2;
+ }
float scale = cos(angle_diff / 2);
CPoint p;
- if(angle_diff < 0)
- {
- if(angle_diff > -M_PI/8) {if(scale < 1) scale = 1;}
- else {if(scale < 0.50) scale = 0.50;}
- }
- else
- {
- if(angle_diff < M_PI/8) {if(scale < 0.75) scale = 0.75;}
- else {if(scale < 0.25) scale = 0.25;}
+ if(angle_diff < 0) {
+ if(angle_diff > -M_PI/8) {
+ if(scale < 1) {
+ scale = 1;
+ }
+ } else {
+ if(scale < 0.50) {
+ scale = 0.50;
+ }
+ }
+ } else {
+ if(angle_diff < M_PI/8) {
+ if(scale < 0.75) {
+ scale = 0.75;
+ }
+ } else {
+ if(scale < 0.25) {
+ scale = 0.25;
+ }
+ }
}
- if(scale < 0.1) scale = 0.1;
+ if(scale < 0.1) {
+ scale = 0.1;
+ }
float angle = angle_in + angle_diff / 2 - rotate;
float radius = -size / scale; // FIXME
diff --git a/src/Subtitles/libssf/GlyphPath.h b/src/Subtitles/libssf/GlyphPath.h
index 9fbfefe97..98f8e6d34 100644
--- a/src/Subtitles/libssf/GlyphPath.h
+++ b/src/Subtitles/libssf/GlyphPath.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -36,7 +36,7 @@ namespace ssf
bool IsEmpty();
void RemoveAll();
- void MovePoints(const CPoint& o);
+ void MovePoints(const CPoint& o);
void Enlarge(const GlyphPath& src, float size);
CAtlArray<BYTE> types;
diff --git a/src/Subtitles/libssf/Node.cpp b/src/Subtitles/libssf/Node.cpp
index 0aa04d458..93b111616 100644
--- a/src/Subtitles/libssf/Node.cpp
+++ b/src/Subtitles/libssf/Node.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -42,8 +42,7 @@ namespace ssf
void Node::AddTail(Node* pNode)
{
- if(POSITION pos = m_nodes.Find(pNode)) // TODO: slow
- {
+ if(POSITION pos = m_nodes.Find(pNode)) { // TODO: slow
m_nodes.MoveToTail(pos);
return;
}
@@ -71,25 +70,20 @@ namespace ssf
{
CAtlList<Definition*> rdl[3];
- if(fFirst)
- {
- if(Definition* pDef = m_pnf->GetDefByName(m_type))
- {
+ if(fFirst) {
+ if(Definition* pDef = m_pnf->GetDefByName(m_type)) {
pDef->GetChildDefs(rdl[pDef->m_priority], type, false);
}
}
POSITION pos = m_nodes.GetHeadPosition();
- while(pos)
- {
- if(Node* pNode = m_nodes.GetNext(pos))
- {
+ while(pos) {
+ if(Node* pNode = m_nodes.GetNext(pos)) {
pNode->GetChildDefs(rdl[pNode->m_priority], type, false);
}
}
- for(int i = 0; i < sizeof(rdl)/sizeof(rdl[0]); i++)
- {
+ for(int i = 0; i < sizeof(rdl)/sizeof(rdl[0]); i++) {
l.AddTailList(&rdl[i]);
}
}
@@ -110,26 +104,24 @@ namespace ssf
CAtlList<Definition*> rdl[3];
POSITION pos = m_nodes.GetHeadPosition();
- while(pos)
- {
- if(Definition* pDef = dynamic_cast<Definition*>(m_nodes.GetNext(pos)))
- {
- if(!type || pDef->m_type == type) // TODO: faster lookup
- {
+ while(pos) {
+ if(Definition* pDef = dynamic_cast<Definition*>(m_nodes.GetNext(pos))) {
+ if(!type || pDef->m_type == type) { // TODO: faster lookup
rdl[pDef->m_priority].AddTail(pDef);
}
}
}
- for(int i = 0; i < sizeof(rdl)/sizeof(rdl[0]); i++)
- {
+ for(int i = 0; i < sizeof(rdl)/sizeof(rdl[0]); i++) {
l.AddTailList(&rdl[i]);
}
}
void Reference::Dump(OutputStream& s, int level, bool fLast)
{
- if(m_predefined) return;
+ if(m_predefined) {
+ return;
+ }
CStringW tabs(' ', level*4);
@@ -137,12 +129,10 @@ namespace ssf
s.PutString(L" {\n");
POSITION pos = m_nodes.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
Node* pNode = m_nodes.GetNext(pos);
- if(Definition* pDef = dynamic_cast<Definition*>(pNode))
- {
+ if(Definition* pDef = dynamic_cast<Definition*>(pNode)) {
pDef->Dump(s, level + 1, pos == NULL);
}
}
@@ -168,10 +158,8 @@ namespace ssf
{
Node* pNode = m_parent;
- while(pNode)
- {
- if(pNode->m_name2node.Lookup(pDef->m_name))
- {
+ while(pNode) {
+ if(pNode->m_name2node.Lookup(pDef->m_name)) {
return true;
}
@@ -183,15 +171,14 @@ namespace ssf
void Definition::AddTail(Node* pNode)
{
-// if(Reference* pRef = dynamic_cast<Reference*>(pNode))
+ // if(Reference* pRef = dynamic_cast<Reference*>(pNode))
{
ASSERT(m_status == node);
m_status = node;
- if(IsTypeUnknown() && !pNode->IsTypeUnknown())
- {
- m_type = pNode->m_type;
+ if(IsTypeUnknown() && !pNode->IsTypeUnknown()) {
+ m_type = pNode->m_type;
m_autotype = true;
}
@@ -201,11 +188,12 @@ namespace ssf
__super::AddTail(pNode);
}
- Definition& Definition::operator[] (LPCWSTR type)
+ Definition& Definition::operator[] (LPCWSTR type)
{
Definition* pRetDef = NULL;
- if(m_type2def.Lookup(type, pRetDef))
+ if(m_type2def.Lookup(type, pRetDef)) {
return *pRetDef;
+ }
pRetDef = DNew Definition(m_pnf, L"");
pRetDef->m_priority = PLow;
@@ -215,20 +203,16 @@ namespace ssf
CAtlList<Definition*> l;
GetChildDefs(l, type);
- while(!l.IsEmpty())
- {
+ while(!l.IsEmpty()) {
Definition* pDef = l.RemoveHead();
pRetDef->m_priority = pDef->m_priority;
pRetDef->m_parent = pDef->m_parent;
- if(pDef->IsValue())
- {
+ if(pDef->IsValue()) {
pRetDef->SetAsValue(pDef->m_status, pDef->m_value, pDef->m_unit);
- }
- else
- {
- pRetDef->m_status = node;
+ } else {
+ pRetDef->m_status = node;
pRetDef->m_nodes.AddTailList(&pDef->m_nodes);
}
}
@@ -238,13 +222,12 @@ namespace ssf
void Definition::RemoveFromCache(LPCWSTR type)
{
- if(!type)
- {
+ if(!type) {
POSITION pos = m_type2def.GetStartPosition();
- while(pos) delete m_type2def.GetNextValue(pos);
- }
- else if(StringMapW<Definition*>::CPair* p = m_type2def.Lookup(type))
- {
+ while(pos) {
+ delete m_type2def.GetNextValue(pos);
+ }
+ } else if(StringMapW<Definition*>::CPair* p = m_type2def.Lookup(type)) {
delete p->m_value;
m_type2def.RemoveKey(type);
}
@@ -276,7 +259,7 @@ namespace ssf
GetAsNumber(n); // will throw an exception if not a number
}
- template<class T>
+ template<class T>
void Definition::GetAsNumber(Number<T>& n, StringMapW<T>* n2n)
{
CStringW str = m_value;
@@ -286,80 +269,104 @@ namespace ssf
n.unit = m_unit;
n.sign = 0;
- if(n2n)
- {
- if(m_status == node) throw Exception(_T("expected value type"));
+ if(n2n) {
+ if(m_status == node) {
+ throw Exception(_T("expected value type"));
+ }
- if(StringMapW<T>::CPair* p = n2n->Lookup(str))
- {
+ if(StringMapW<T>::CPair* p = n2n->Lookup(str)) {
n.value = p->m_value;
return;
}
}
- if(m_status != number) throw Exception(_T("expected number"));
+ if(m_status != number) {
+ throw Exception(_T("expected number"));
+ }
n.sign = str.Find('+') == 0 ? 1 : str.Find('-') == 0 ? -1 : 0;
str.TrimLeft(L"+-");
- if(str.Find(L"0x") == 0)
- {
- if(n.sign) throw Exception(_T("hex values must be unsigned"));
+ if(str.Find(L"0x") == 0) {
+ if(n.sign) {
+ throw Exception(_T("hex values must be unsigned"));
+ }
n.value = (T)wcstoul(str.Mid(2), NULL, 16);
- }
- else
- {
+ } else {
CStringW num_string = m_value + m_unit;
- if(m_num_string != num_string)
- {
+ if(m_num_string != num_string) {
Split sa(':', str);
Split sa2('.', sa ? sa[sa-1] : L"");
- if(sa == 0 || sa2 == 0 || sa2 > 2) throw Exception(_T("invalid number"));
+ if(sa == 0 || sa2 == 0 || sa2 > 2) {
+ throw Exception(_T("invalid number"));
+ }
float f = 0;
- for(size_t i = 0; i < sa; i++) {f *= 60; f += wcstoul(sa[i], NULL, 10);}
- if(sa2 > 1) f += (float)wcstoul(sa2[1], NULL, 10) / pow((float)10, sa2[1].GetLength());
+ for(size_t i = 0; i < sa; i++) {
+ f *= 60;
+ f += wcstoul(sa[i], NULL, 10);
+ }
+ if(sa2 > 1) {
+ f += (float)wcstoul(sa2[1], NULL, 10) / pow((float)10, sa2[1].GetLength());
+ }
- if(n.unit == L"ms") {f /= 1000; n.unit = L"s";}
- else if(n.unit == L"m") {f *= 60; n.unit = L"s";}
- else if(n.unit == L"h") {f *= 3600; n.unit = L"s";}
+ if(n.unit == L"ms") {
+ f /= 1000;
+ n.unit = L"s";
+ } else if(n.unit == L"m") {
+ f *= 60;
+ n.unit = L"s";
+ } else if(n.unit == L"h") {
+ f *= 3600;
+ n.unit = L"s";
+ }
m_num.value = f;
m_num.unit = n.unit;
m_num_string = num_string;
n.value = (T)f;
- }
- else
- {
+ } else {
n.value = (T)m_num.value;
n.unit = m_num.unit;
}
- if(n.sign) n.value *= n.sign;
+ if(n.sign) {
+ n.value *= n.sign;
+ }
}
}
void Definition::GetAsString(CStringW& str)
{
- if(m_status == node) throw Exception(_T("expected value type"));
+ if(m_status == node) {
+ throw Exception(_T("expected value type"));
+ }
- str = m_value;
+ str = m_value;
}
- void Definition::GetAsNumber(Number<int>& n, StringMapW<int>* n2n) {return GetAsNumber<int>(n, n2n);}
- void Definition::GetAsNumber(Number<DWORD>& n, StringMapW<DWORD>* n2n) {return GetAsNumber<DWORD>(n, n2n);}
- void Definition::GetAsNumber(Number<float>& n, StringMapW<float>* n2n) {return GetAsNumber<float>(n, n2n);}
+ void Definition::GetAsNumber(Number<int>& n, StringMapW<int>* n2n)
+ {
+ return GetAsNumber<int>(n, n2n);
+ }
+ void Definition::GetAsNumber(Number<DWORD>& n, StringMapW<DWORD>* n2n)
+ {
+ return GetAsNumber<DWORD>(n, n2n);
+ }
+ void Definition::GetAsNumber(Number<float>& n, StringMapW<float>* n2n)
+ {
+ return GetAsNumber<float>(n, n2n);
+ }
void Definition::GetAsBoolean(bool& b)
{
static StringMapW<bool> s2b;
- if(s2b.IsEmpty())
- {
+ if(s2b.IsEmpty()) {
s2b[L"true"] = true;
s2b[L"on"] = true;
s2b[L"yes"] = true;
@@ -370,8 +377,7 @@ namespace ssf
s2b[L"0"] = false;
}
- if(!s2b.Lookup(m_value, b)) // m_status != boolean && m_status != number ||
- {
+ if(!s2b.Lookup(m_value, b)) { // m_status != boolean && m_status != number ||
throw Exception(_T("expected boolean"));
}
}
@@ -381,24 +387,34 @@ namespace ssf
Definition& time = (*this)[L"time"];
CStringW id;
- if(time[L"id"].IsValue()) id = time[L"id"];
- else id.Format(L"%d", default_id);
+ if(time[L"id"].IsValue()) {
+ id = time[L"id"];
+ } else {
+ id.Format(L"%d", default_id);
+ }
float scale = time[L"scale"].IsValue() ? time[L"scale"] : 1.0f;
- if(time[L"start"].IsValue() && time[L"stop"].IsValue())
- {
+ if(time[L"start"].IsValue() && time[L"stop"].IsValue()) {
time[L"start"].GetAsNumber(t.start, n2n);
time[L"stop"].GetAsNumber(t.stop, n2n);
- if(t.start.unit.IsEmpty()) t.start.value *= scale;
- if(t.stop.unit.IsEmpty()) t.stop.value *= scale;
+ if(t.start.unit.IsEmpty()) {
+ t.start.value *= scale;
+ }
+ if(t.stop.unit.IsEmpty()) {
+ t.stop.value *= scale;
+ }
float o = 0;
offset.Lookup(id, o);
- if(t.start.sign != 0) t.start.value = o + t.start.value;
- if(t.stop.sign != 0) t.stop.value = t.start.value + t.stop.value;
+ if(t.start.sign != 0) {
+ t.start.value = o + t.start.value;
+ }
+ if(t.stop.sign != 0) {
+ t.stop.value = t.start.value + t.stop.value;
+ }
offset[id] = t.stop.value;
@@ -435,38 +451,33 @@ namespace ssf
Split split('.', path);
- for(size_t i = 0, j = split-1; i <= j; i++)
- {
+ for(size_t i = 0, j = split-1; i <= j; i++) {
CStringW type = split[i];
- if(pDef->m_nodes.IsEmpty() || !dynamic_cast<Reference*>(pDef->m_nodes.GetTail()))
- {
+ if(pDef->m_nodes.IsEmpty() || !dynamic_cast<Reference*>(pDef->m_nodes.GetTail())) {
EXECUTE_ASSERT(m_pnf->CreateRef(pDef) != NULL);
}
- if(Reference* pRef = dynamic_cast<Reference*>(pDef->m_nodes.GetTail()))
- {
+ if(Reference* pRef = dynamic_cast<Reference*>(pDef->m_nodes.GetTail())) {
pDef = NULL;
POSITION pos = pRef->m_nodes.GetTailPosition();
- while(pos)
- {
+ while(pos) {
Definition* pChildDef = dynamic_cast<Definition*>(pRef->m_nodes.GetPrev(pos));
- if(pChildDef->IsType(type))
- {
- if(pChildDef->IsNameUnknown()) pDef = pChildDef;
+ if(pChildDef->IsType(type)) {
+ if(pChildDef->IsNameUnknown()) {
+ pDef = pChildDef;
+ }
break;
}
}
- if(!pDef)
- {
+ if(!pDef) {
pDef = m_pnf->CreateDef(pRef, type);
}
- if(i == j)
- {
+ if(i == j) {
pDef->SetAsValue(s, v, u);
return pDef;
}
@@ -488,32 +499,38 @@ namespace ssf
void Definition::Dump(OutputStream& s, int level, bool fLast)
{
- if(m_predefined) return;
+ if(m_predefined) {
+ return;
+ }
CStringW tabs(' ', level*4);
CStringW str = tabs;
- if(m_predefined) str += '?';
- if(m_priority == PLow) str += '*';
- else if(m_priority == PHigh) str += '!';
- if(!IsTypeUnknown() && !m_autotype) str += m_type;
- if(!IsNameUnknown()) str += '#' + m_name;
+ if(m_predefined) {
+ str += '?';
+ }
+ if(m_priority == PLow) {
+ str += '*';
+ } else if(m_priority == PHigh) {
+ str += '!';
+ }
+ if(!IsTypeUnknown() && !m_autotype) {
+ str += m_type;
+ }
+ if(!IsNameUnknown()) {
+ str += '#' + m_name;
+ }
str += ':';
s.PutString(L"%s", str);
- if(!m_nodes.IsEmpty())
- {
+ if(!m_nodes.IsEmpty()) {
POSITION pos = m_nodes.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
Node* pNode = m_nodes.GetNext(pos);
- if(Reference* pRef = dynamic_cast<Reference*>(pNode))
- {
+ if(Reference* pRef = dynamic_cast<Reference*>(pNode)) {
pRef->Dump(s, level, fLast);
- }
- else
- {
+ } else {
ASSERT(!pNode->IsNameUnknown());
s.PutString(L" %s", pNode->m_name);
}
@@ -521,30 +538,24 @@ namespace ssf
s.PutString(L";\n");
- if(!fLast && (!m_nodes.IsEmpty() || level == 0)) s.PutString(L"\n");
- }
- else if(m_status == string)
- {
+ if(!fLast && (!m_nodes.IsEmpty() || level == 0)) {
+ s.PutString(L"\n");
+ }
+ } else if(m_status == string) {
CStringW str = m_value;
str.Replace(L"\"", L"\\\"");
s.PutString(L" \"%s\";\n", str);
- }
- else if(m_status == number)
- {
+ } else if(m_status == number) {
CStringW str = m_value;
- if(!m_unit.IsEmpty()) str += m_unit;
+ if(!m_unit.IsEmpty()) {
+ str += m_unit;
+ }
s.PutString(L" %s;\n", str);
- }
- else if(m_status == boolean)
- {
+ } else if(m_status == boolean) {
s.PutString(L" %s;\n", m_value);
- }
- else if(m_status == block)
- {
+ } else if(m_status == block) {
s.PutString(L" {%s};\n", m_value);
- }
- else
- {
+ } else {
s.PutString(L" null;\n");
}
}
diff --git a/src/Subtitles/libssf/Node.h b/src/Subtitles/libssf/Node.h
index 586453432..018befb87 100644
--- a/src/Subtitles/libssf/Node.h
+++ b/src/Subtitles/libssf/Node.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -69,8 +69,14 @@ namespace ssf
class Definition : public Node
{
public:
- template<typename T> struct Number {T value; int sign; CStringW unit;};
- struct Time {Number<float> start, stop;};
+ template<typename T> struct Number {
+ T value;
+ int sign;
+ CStringW unit;
+ };
+ struct Time {
+ Number<float> start, stop;
+ };
enum status_t {node, string, number, boolean, block};
@@ -84,7 +90,7 @@ namespace ssf
StringMapW<Definition*> m_type2def;
void RemoveFromCache(LPCWSTR type = NULL);
- template<typename T>
+ template<typename T>
void GetAsNumber(Number<T>& n, StringMapW<T>* n2n = NULL);
public:
@@ -107,8 +113,12 @@ namespace ssf
void GetAsNumber(Number<int>& n, StringMapW<int>* n2n = NULL);
void GetAsNumber(Number<DWORD>& n, StringMapW<DWORD>* n2n = NULL);
void GetAsNumber(Number<float>& n, StringMapW<float>* n2n = NULL);
- template<typename T>
- void GetAsNumber(T& t, StringMapW<T>* n2n = NULL) {Number<T> n; GetAsNumber(n, n2n); t = n.value;}
+ template<typename T>
+ void GetAsNumber(T& t, StringMapW<T>* n2n = NULL) {
+ Number<T> n;
+ GetAsNumber(n, n2n);
+ t = n.value;
+ }
void GetAsBoolean(bool& b);
bool GetAsTime(Time& t, StringMapW<float>& offset, StringMapW<float>* n2n = NULL, int default_id = 0);
diff --git a/src/Subtitles/libssf/NodeFactory.cpp b/src/Subtitles/libssf/NodeFactory.cpp
index a502778a5..d9a73eaaa 100644
--- a/src/Subtitles/libssf/NodeFactory.cpp
+++ b/src/Subtitles/libssf/NodeFactory.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -49,7 +49,9 @@ namespace ssf
m_root = NULL;
POSITION pos = m_nodes.GetStartPosition();
- while(pos) delete m_nodes.GetNextValue(pos);
+ while(pos) {
+ delete m_nodes.GetNextValue(pos);
+ }
m_nodes.RemoveAll();
m_newnodes.RemoveAll();
@@ -63,10 +65,8 @@ namespace ssf
void NodeFactory::Rollback()
{
POSITION pos = m_newnodes.GetTailPosition();
- while(pos)
- {
- if(StringMap<Node*, CStringW>::CPair* p = m_nodes.Lookup(m_newnodes.GetPrev(pos)))
- {
+ while(pos) {
+ if(StringMap<Node*, CStringW>::CPair* p = m_nodes.Lookup(m_newnodes.GetPrev(pos))) {
delete p->m_value; // TODO: remove it from "parent"->m_nodes too
m_nodes.RemoveKey(p->m_key);
}
@@ -95,8 +95,7 @@ namespace ssf
m_nodes.SetAt(name, pRef);
m_newnodes.AddTail(name);
- if(pParentDef)
- {
+ if(pParentDef) {
pParentDef->AddTail(pRef);
pRef->m_parent = pParentDef;
}
@@ -108,37 +107,29 @@ namespace ssf
{
Definition* pDef = NULL;
- if(name.IsEmpty())
- {
+ if(name.IsEmpty()) {
name = GenName();
- }
- else
- {
+ } else {
pDef = GetDefByName(name);
- if(pDef)
- {
- if(!pDef->m_predefined)
- {
+ if(pDef) {
+ if(!pDef->m_predefined) {
throw Exception(_T("redefinition of '%s' is not allowed"), CString(name));
}
- if(!pDef->IsTypeUnknown() && !pDef->IsType(type))
- {
+ if(!pDef->IsTypeUnknown() && !pDef->IsType(type)) {
throw Exception(_T("cannot redefine type of %s to %s"), CString(name), CString(type));
}
}
}
- if(!pDef)
- {
+ if(!pDef) {
pDef = DNew Definition(this, name);
m_nodes.SetAt(name, pDef);
m_newnodes.AddTail(name);
- if(pParentRef)
- {
+ if(pParentRef) {
pParentRef->AddTail(pDef);
pDef->m_parent = pParentRef;
}
@@ -163,10 +154,8 @@ namespace ssf
defs.RemoveAll();
POSITION pos = m_newnodes.GetHeadPosition();
- while(pos)
- {
- if(Definition* pDef = GetDefByName(m_newnodes.GetNext(pos)))
- {
+ while(pos) {
+ if(Definition* pDef = GetDefByName(m_newnodes.GetNext(pos))) {
defs.AddTail(pDef);
}
}
@@ -174,9 +163,13 @@ namespace ssf
void NodeFactory::Dump(OutputStream& s) const
{
- if(!m_root) return;
+ if(!m_root) {
+ return;
+ }
POSITION pos = m_root->m_nodes.GetHeadPosition();
- while(pos) m_root->m_nodes.GetNext(pos)->Dump(s);
+ while(pos) {
+ m_root->m_nodes.GetNext(pos)->Dump(s);
+ }
}
}
diff --git a/src/Subtitles/libssf/NodeFactory.h b/src/Subtitles/libssf/NodeFactory.h
index 0f0cd0b8b..c7ed4c80f 100644
--- a/src/Subtitles/libssf/NodeFactory.h
+++ b/src/Subtitles/libssf/NodeFactory.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -41,7 +41,9 @@ namespace ssf
virtual void RemoveAll();
- void SetPredefined(bool predefined) {m_predefined = predefined;}
+ void SetPredefined(bool predefined) {
+ m_predefined = predefined;
+ }
void Commit();
void Rollback();
diff --git a/src/Subtitles/libssf/Rasterizer.cpp b/src/Subtitles/libssf/Rasterizer.cpp
index 239bbc30e..19497c732 100644
--- a/src/Subtitles/libssf/Rasterizer.cpp
+++ b/src/Subtitles/libssf/Rasterizer.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -34,8 +34,14 @@
namespace ssf
{
- template<class T> T mymax(T a, T b) {return a > b ? a : b;}
- template<class T> T mymin(T a, T b) {return a < b ? a : b;}
+ template<class T> T mymax(T a, T b)
+ {
+ return a > b ? a : b;
+ }
+ template<class T> T mymin(T a, T b)
+ {
+ return a < b ? a : b;
+ }
Rasterizer::Rasterizer()
{
@@ -52,7 +58,9 @@ namespace ssf
void Rasterizer::_TrashOverlay()
{
- if(mpOverlayBuffer) delete [] mpOverlayBuffer;
+ if(mpOverlayBuffer) {
+ delete [] mpOverlayBuffer;
+ }
mpOverlayBuffer = NULL;
}
@@ -65,14 +73,11 @@ namespace ssf
void Rasterizer::_EvaluateBezier(const CPoint& p0, const CPoint& p1, const CPoint& p2, const CPoint& p3)
{
if(abs(p0.x + p2.x - p1.x*2) +
- abs(p0.y + p2.y - p1.y*2) +
- abs(p1.x + p3.x - p2.x*2) +
- abs(p1.y + p3.y - p2.y*2) <= max(2, 1<<FONT_AA))
- {
+ abs(p0.y + p2.y - p1.y*2) +
+ abs(p1.x + p3.x - p2.x*2) +
+ abs(p1.y + p3.y - p2.y*2) <= max(2, 1<<FONT_AA)) {
_EvaluateLine(p0, p3);
- }
- else
- {
+ } else {
CPoint p01, p12, p23, p012, p123, p0123;
p01.x = (p0.x + p1.x + 1) >> 1;
@@ -95,23 +100,20 @@ namespace ssf
void Rasterizer::_EvaluateLine(CPoint p0, CPoint p1)
{
- if(lastp != p0)
- {
+ if(lastp != p0) {
_EvaluateLine(lastp, p0);
}
- if(!fFirstSet)
- {
- firstp = p0;
+ if(!fFirstSet) {
+ firstp = p0;
fFirstSet = true;
}
lastp = p1;
- // TODO: ((1<<FONT_SCALE)/2+-1)
+ // TODO: ((1<<FONT_SCALE)/2+-1)
- if(p1.y > p0.y) // down
- {
+ if(p1.y > p0.y) { // down
int xacc = p0.x << (8 - FONT_SCALE);
// prestep p0.y down
@@ -122,17 +124,16 @@ namespace ssf
p1.y = (p1.y - ((1<<FONT_SCALE)/2+1)) >> FONT_SCALE;
- if(iy <= p1.y)
- {
+ if(iy <= p1.y) {
int invslope = ((p1.x - p0.x) << 8) / dy;
- while(mEdgeNext + p1.y + 1 - iy > mEdgeHeapSize)
+ while(mEdgeNext + p1.y + 1 - iy > mEdgeHeapSize) {
_ReallocEdgeBuffer(mEdgeHeapSize*2);
+ }
xacc += (invslope * (y - p0.y)) >> FONT_SCALE;
- while(iy <= p1.y)
- {
+ while(iy <= p1.y) {
int ix = (xacc + 128) >> 8;
mpEdgeBuffer[mEdgeNext].next = mpScanBuffer[iy];
@@ -144,9 +145,7 @@ namespace ssf
xacc += invslope;
}
}
- }
- else if(p1.y < p0.y) // up
- {
+ } else if(p1.y < p0.y) { // up
int xacc = p1.x << (8 - FONT_SCALE);
// prestep p1.y down
@@ -157,17 +156,16 @@ namespace ssf
p0.y = (p0.y - ((1<<FONT_SCALE)/2+1)) >> FONT_SCALE;
- if(iy <= p0.y)
- {
+ if(iy <= p0.y) {
int invslope = ((p0.x - p1.x) << 8) / dy;
- while(mEdgeNext + p0.y + 1 - iy > mEdgeHeapSize)
+ while(mEdgeNext + p0.y + 1 - iy > mEdgeHeapSize) {
_ReallocEdgeBuffer(mEdgeHeapSize*2);
+ }
xacc += (invslope * (y - p1.y)) >> FONT_SCALE;
- while(iy <= p0.y)
- {
+ while(iy <= p0.y) {
int ix = (xacc + 128) >> 8;
mpEdgeBuffer[mEdgeNext].next = mpScanBuffer[iy];
@@ -189,8 +187,7 @@ namespace ssf
mOutline.RemoveAll();
mWideOutline.RemoveAll();
- if(path.types.IsEmpty() || path.points.IsEmpty() || bbox.IsRectEmpty())
- {
+ if(path.types.IsEmpty() || path.points.IsEmpty() || bbox.IsRectEmpty()) {
mPathOffsetX = mPathOffsetY = 0;
mWidth = mHeight = 0;
return 0;
@@ -203,8 +200,7 @@ namespace ssf
path.MovePoints(CPoint(-minx*(1<<FONT_SCALE), -miny*(1<<FONT_SCALE)));
- if(minx > maxx || miny > maxy)
- {
+ if(minx > maxx || miny > maxy) {
mWidth = mHeight = 0;
mPathOffsetX = mPathOffsetY = 0;
return true;
@@ -242,27 +238,33 @@ namespace ssf
BYTE* type = path.types.GetData();
POINT* pt = path.points.GetData();
- for(size_t i = 0, j = path.types.GetCount(); i < j; i++)
- {
- switch(type[i] & ~PT_CLOSEFIGURE)
- {
- case PT_MOVETO:
- if(lastmoveto >= 0 && firstp != lastp) _EvaluateLine(lastp, firstp);
- lastmoveto = int(i);
- fFirstSet = false;
- lastp = pt[i];
- break;
- case PT_LINETO:
- if(j - (i-1) >= 2) _EvaluateLine(pt[i-1], pt[i]);
- break;
- case PT_BEZIERTO:
- if(j - (i-1) >= 4) _EvaluateBezier(pt[i-1], pt[i], pt[i+1], pt[i+2]);
- i += 2;
- break;
+ for(size_t i = 0, j = path.types.GetCount(); i < j; i++) {
+ switch(type[i] & ~PT_CLOSEFIGURE) {
+ case PT_MOVETO:
+ if(lastmoveto >= 0 && firstp != lastp) {
+ _EvaluateLine(lastp, firstp);
+ }
+ lastmoveto = int(i);
+ fFirstSet = false;
+ lastp = pt[i];
+ break;
+ case PT_LINETO:
+ if(j - (i-1) >= 2) {
+ _EvaluateLine(pt[i-1], pt[i]);
+ }
+ break;
+ case PT_BEZIERTO:
+ if(j - (i-1) >= 4) {
+ _EvaluateBezier(pt[i-1], pt[i], pt[i+1], pt[i+2]);
+ }
+ i += 2;
+ break;
}
}
- if(lastmoveto >= 0 && firstp != lastp) _EvaluateLine(lastp, firstp);
+ if(lastmoveto >= 0 && firstp != lastp) {
+ _EvaluateLine(lastp, firstp);
+ }
// 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
@@ -274,14 +276,12 @@ namespace ssf
mOutline.SetCount(0, mEdgeNext / 2);
- for(int y = 0; y < mHeight; y++)
- {
+ for(int y = 0; y < mHeight; y++) {
int count = 0;
// Detangle scanline into edge heap.
- for(unsigned int ptr = mpScanBuffer[y]; ptr; ptr = mpEdgeBuffer[ptr].next)
- {
+ for(unsigned int ptr = mpScanBuffer[y]; ptr; ptr = mpEdgeBuffer[ptr].next) {
heap.push_back(mpEdgeBuffer[ptr].posandflag);
}
@@ -299,22 +299,23 @@ namespace ssf
int x1 = 0;
- for(; itX1 != itX2; ++itX1)
- {
+ for(; itX1 != itX2; ++itX1) {
int x = *itX1;
- if(!count)
+ if(!count) {
x1 = x >> 1;
+ }
- if(x&1) ++count;
- else --count;
+ if(x&1) {
+ ++count;
+ } else {
+ --count;
+ }
- if(!count)
- {
+ if(!count) {
int x2 = x >> 1;
- if(x2 > x1)
- {
+ if(x2 > x1) {
Span s(x1, y, x2, y);
s.first += 0x4000000040000000i64;
s.second += 0x4000000040000000i64;
@@ -349,12 +350,10 @@ namespace ssf
o.first -= dx;
o.second += dx;
- while(a != ae && b != be)
- {
+ while(a != ae && b != be) {
Span x;
- if(b->first + o.first < a->first)
- {
+ if(b->first + o.first < a->first) {
// B span is earlier. Use it.
x.first = b->first + o.first;
@@ -364,31 +363,32 @@ namespace ssf
// B spans don't overlap, so begin merge loop with A first.
- for(;;)
- {
+ 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(a == ae || a->first > x.second)
+ if(a == ae || a->first > x.second) {
break;
+ }
- do {x.second = mymax(x.second, a->second);}
- while(++a != ae && a->first <= x.second);
+ do {
+ x.second = mymax(x.second, a->second);
+ } while(++a != ae && a->first <= x.second);
// 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(b == be || b->first + o.first > x.second)
+ if(b == be || b->first + o.first > x.second) {
break;
+ }
- do {x.second = mymax(x.second, b->second + o.second);}
- while(++b != be && b->first + o.first <= x.second);
+ do {
+ x.second = mymax(x.second, b->second + o.second);
+ } while(++b != be && b->first + o.first <= x.second);
}
- }
- else
- {
+ } else {
// A span is earlier. Use it.
x = *a;
@@ -397,27 +397,30 @@ namespace ssf
// A spans don't overlap, so begin merge loop with B first.
- for(;;)
- {
+ 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(b == be || b->first + o.first > x.second)
+ if(b == be || b->first + o.first > x.second) {
break;
+ }
- do {x.second = mymax(x.second, b->second + o.second);}
- while(++b != be && b->first + o.first <= x.second);
+ do {
+ x.second = mymax(x.second, b->second + o.second);
+ } while(++b != be && b->first + o.first <= x.second);
// 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(a == ae || a->first > x.second)
+ if(a == ae || a->first > x.second) {
break;
+ }
- do {x.second = mymax(x.second, a->second);}
- while(++a != ae && a->first <= x.second);
+ do {
+ x.second = mymax(x.second, a->second);
+ } while(++a != ae && a->first <= x.second);
}
}
@@ -430,20 +433,20 @@ namespace ssf
dst.Append(a, ae - a);
- for(; b != be; b++)
- {
+ for(; b != be; b++) {
dst.Add(Span(b->first + o.first, b->second + o.second));
}
}
bool Rasterizer::CreateWidenedRegion(int r)
{
- if(r < 0) r = 0;
+ if(r < 0) {
+ r = 0;
+ }
r >>= FONT_SCALE;
- for(int y = -r; y <= r; ++y)
- {
+ for(int y = -r; y <= r; ++y) {
int x = (int)(0.5f + sqrt(float(r*r - y*y)));
_OverlapRegion(mWideOutline, mOutline, x, y);
@@ -458,8 +461,7 @@ namespace ssf
{
_TrashOverlay();
- if(!mWidth || !mHeight)
- {
+ if(!mWidth || !mHeight) {
mOverlayWidth = mOverlayHeight = 0;
return true;
}
@@ -478,8 +480,7 @@ namespace ssf
int border = ((mWideBorder + ((1<<FONT_AA)-1)) & ~((1<<FONT_AA)-1)) + (1<<FONT_AA)*4;
- if(!mWideOutline.IsEmpty())
- {
+ if(!mWideOutline.IsEmpty()) {
width += 2*border;
height += 2*border;
@@ -498,34 +499,27 @@ namespace ssf
Array<Span>* pOutline[2] = {&mOutline, &mWideOutline};
- for(int i = 0; i < countof(pOutline); i++)
- {
+ for(int i = 0; i < countof(pOutline); i++) {
const Span* s = pOutline[i]->GetData();
- for(size_t j = 0, k = pOutline[i]->GetCount(); j < k; j++)
- {
+ for(size_t j = 0, k = pOutline[i]->GetCount(); j < k; j++) {
int y = s[j].y1 - 0x40000000 + ysub;
int x1 = s[j].x1 - 0x40000000 + xsub;
int x2 = s[j].x2 - 0x40000000 + xsub;
- if(x2 > x1)
- {
+ if(x2 > x1) {
int first = x1 >> FONT_AA;
int last = (x2-1) >> FONT_AA;
BYTE* dst = mpOverlayBuffer + 4*(mOverlayWidth * (y >> FONT_AA) + first) + i;
- if(first == last)
- {
+ if(first == last) {
*dst += x2 - x1;
- }
- else
- {
+ } else {
*dst += (((first+1) << FONT_AA) - x1) << (6 - FONT_AA*2);
dst += 4;
- while(++first < last)
- {
+ while(++first < last) {
*dst += (1 << FONT_AA) << (6 - FONT_AA*2);
dst += 4;
}
@@ -536,14 +530,11 @@ namespace ssf
}
}
- if(!mWideOutline.IsEmpty())
- {
+ if(!mWideOutline.IsEmpty()) {
BYTE* p = mpOverlayBuffer;
- for(int j = 0; j < mOverlayHeight; j++, p += mOverlayWidth*4)
- {
- for(int i = 0; i < mOverlayWidth; i++)
- {
+ for(int j = 0; j < mOverlayHeight; j++, p += mOverlayWidth*4) {
+ for(int i = 0; i < mOverlayWidth; i++) {
p[i*4+2] = min(p[i*4+1], (1<<6) - p[i*4]); // TODO: sse2
}
}
@@ -554,37 +545,37 @@ namespace ssf
void Rasterizer::Blur(float n, int plane)
{
- if(n <= 0 || !mOverlayWidth || !mOverlayHeight || !mpOverlayBuffer)
+ if(n <= 0 || !mOverlayWidth || !mOverlayHeight || !mpOverlayBuffer) {
return;
+ }
int w = mOverlayWidth;
int h = mOverlayHeight;
int pitch = w*4;
BYTE* q0 = DNew BYTE[w*h];
- for(int pass = 0; pass < n; pass++)
- {
+ for(int pass = 0; pass < n; pass++) {
BYTE* p = mpOverlayBuffer + plane;
BYTE* q = q0;
- for(int y = 0; y < h; y++, p += pitch, q += w)
- {
+ for(int y = 0; y < h; y++, p += pitch, q += w) {
q[0] = (2*p[0] + p[4]) >> 2;
int x = 0;
- for(x = 1; x < w-1; x++)
+ for(x = 1; x < w-1; x++) {
q[x] = (p[(x-1)*4] + 2*p[x*4] + p[(x+1)*4]) >> 2;
+ }
q[x] = (p[(x-1)*4] + 2*p[x*4]) >> 2;
}
p = mpOverlayBuffer + plane;
q = q0;
- for(int x = 0; x < w; x++, p += 4, q++)
- {
+ for(int x = 0; x < w; x++, p += 4, q++) {
p[0] = (2*q[0] + q[w]) >> 2;
int y = 0, yp, yq;
- for(y = 1, yp = y*pitch, yq = y*w; y < h-1; y++, yp += pitch, yq += w)
+ for(y = 1, yp = y*pitch, yq = y*w; y < h-1; y++, yp += pitch, yq += w) {
p[yp] = (q[yq-w] + 2*q[yq] + q[yq+w]) >> 2;
+ }
p[yp] = (q[yq-w] + 2*q[yq]) >> 2;
}
}
@@ -611,7 +602,7 @@ namespace ssf
int ia = 0xff - a;
*dst = ((((*dst & 0x00ff00ff)*ia + (color & 0x00ff00ff)*a) & 0xff00ff00) >> 8)
- | ((((*dst>>8) & 0x00ff00ff)*ia + ((color>>8) & 0x000000ff)*a) & 0xff00ff00);
+ | ((((*dst>>8) & 0x00ff00ff)*ia + ((color>>8) & 0x000000ff)*a) & 0xff00ff00);
}
static __forceinline void pixmix_sse2(DWORD* dst, DWORD color, DWORD alpha)
@@ -637,7 +628,9 @@ namespace ssf
{
CRect bbox(0, 0, 0, 0);
- if(!switchpts) return bbox;
+ if(!switchpts) {
+ return bbox;
+ }
// clip
@@ -653,12 +646,26 @@ namespace ssf
int h = mOverlayHeight;
int xo = 0, yo = 0;
- 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;
+ 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;
+ }
- if(w <= 0 || h <= 0) return bbox;
+ if(w <= 0 || h <= 0) {
+ return bbox;
+ }
bbox.SetRect(x, y, x + w, y + h);
bbox &= CRect(0, 0, spd.w, spd.h);
@@ -672,29 +679,37 @@ namespace ssf
bool fSSE2 = !!(g_cpuid.m_flags & CCpuID::sse2);
- while(h--)
- {
- if(switchpts[1] == 0xffffffff)
- {
- if(fSSE2) for(int wt=0; wt<w; ++wt) pixmix_sse2(&dst[wt], color, src[wt*4]);
- else for(int wt=0; wt<w; ++wt) pixmix_c(&dst[wt], color, src[wt*4]);
- }
- else
- {
+ while(h--) {
+ if(switchpts[1] == 0xffffffff) {
+ if(fSSE2) for(int wt=0; wt<w; ++wt) {
+ pixmix_sse2(&dst[wt], color, src[wt*4]);
+ }
+ else for(int wt=0; wt<w; ++wt) {
+ pixmix_c(&dst[wt], color, src[wt*4]);
+ }
+ } else {
const DWORD* sw = switchpts;
- if(fSSE2)
- for(int wt=0; wt<w; ++wt)
- {
- if(wt+xo >= sw[1]) {while(wt+xo >= sw[1]) sw += 2; color = sw[-2];}
- pixmix_sse2(&dst[wt], color, src[wt*4]);
- }
+ if(fSSE2)
+ for(int wt=0; wt<w; ++wt) {
+ if(wt+xo >= sw[1]) {
+ while(wt+xo >= sw[1]) {
+ sw += 2;
+ }
+ color = sw[-2];
+ }
+ pixmix_sse2(&dst[wt], color, src[wt*4]);
+ }
else
- for(int wt=0; wt<w; ++wt)
- {
- if(wt+xo >= sw[1]) {while(wt+xo >= sw[1]) sw += 2; color = sw[-2];}
- pixmix_c(&dst[wt], color, src[wt*4]);
- }
+ for(int wt=0; wt<w; ++wt) {
+ if(wt+xo >= sw[1]) {
+ while(wt+xo >= sw[1]) {
+ sw += 2;
+ }
+ color = sw[-2];
+ }
+ pixmix_c(&dst[wt], color, src[wt*4]);
+ }
}
src += 4*mOverlayWidth;
diff --git a/src/Subtitles/libssf/Rasterizer.h b/src/Subtitles/libssf/Rasterizer.h
index 051b61271..263a2adf9 100644
--- a/src/Subtitles/libssf/Rasterizer.h
+++ b/src/Subtitles/libssf/Rasterizer.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -37,19 +37,32 @@ namespace ssf
private:
int mWidth, mHeight;
- union Span
- {
- struct {int x1, y1, x2, y2;};
- struct {unsigned __int64 first, second;};
+ union Span {
+ struct {
+ int x1, y1, x2, y2;
+ };
+ struct {
+ unsigned __int64 first, second;
+ };
union Span() {}
- union Span(int _x1, int _y1, int _x2, int _y2) {x1 = _x1; y1 = _y1; x2 = _x2; y2 = _y2;}
- union Span(unsigned __int64 _first, unsigned __int64 _second) {first = _first; second = _second;}
+ union Span(int _x1, int _y1, int _x2, int _y2) {
+ x1 = _x1;
+ y1 = _y1;
+ x2 = _x2;
+ y2 = _y2;
+ }
+ union Span(unsigned __int64 _first, unsigned __int64 _second) {
+ first = _first;
+ second = _second;
+ }
};
Array<Span> mOutline, mWideOutline, mWideOutlineTmp;
int mWideBorder;
- struct Edge {int next, posandflag;}* mpEdgeBuffer;
+ struct Edge {
+ int next, posandflag;
+ }* mpEdgeBuffer;
unsigned int mEdgeHeapSize;
unsigned int mEdgeNext;
unsigned int* mpScanBuffer;
diff --git a/src/Subtitles/libssf/Renderer.cpp b/src/Subtitles/libssf/Renderer.cpp
index c0ffa24d3..619b74b25 100644
--- a/src/Subtitles/libssf/Renderer.cpp
+++ b/src/Subtitles/libssf/Renderer.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -31,8 +31,7 @@ namespace ssf
void ReverseList(T& l)
{
POSITION pos = l.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
POSITION cur = pos;
l.GetNext(pos);
l.AddHead(l.GetAt(cur));
@@ -45,14 +44,14 @@ namespace ssf
CPoint p;
p.x = frame.left;
- p.x += placement.pos.auto_x
- ? placement.align.h * (frame.Width() - size.cx)
- : placement.pos.x * scale.cx - placement.align.h * size.cx;
+ p.x += placement.pos.auto_x
+ ? placement.align.h * (frame.Width() - size.cx)
+ : placement.pos.x * scale.cx - placement.align.h * size.cx;
p.y = frame.top;
- p.y += placement.pos.auto_y
- ? placement.align.v * (frame.Height() - size.cy)
- : placement.pos.y * scale.cy - placement.align.v * size.cy;
+ p.y += placement.pos.auto_y
+ ? placement.align.v * (frame.Height() - size.cy)
+ : placement.pos.y * scale.cy - placement.align.v * size.cy;
return p;
}
@@ -68,8 +67,8 @@ namespace ssf
Renderer::Renderer()
{
m_hDC = CreateCompatibleDC(NULL);
- SetBkMode(m_hDC, TRANSPARENT);
- SetTextColor(m_hDC, 0xffffff);
+ SetBkMode(m_hDC, TRANSPARENT);
+ SetTextColor(m_hDC, 0xffffff);
SetMapMode(m_hDC, MM_TEXT);
}
@@ -82,14 +81,17 @@ namespace ssf
{
StringMapW<bool> names;
POSITION pos = subs.GetHeadPosition();
- while(pos) names[subs.GetNext(pos)->m_name] = true;
+ while(pos) {
+ names[subs.GetNext(pos)->m_name] = true;
+ }
pos = m_sra.GetStartPosition();
- while(pos)
- {
+ while(pos) {
POSITION cur = pos;
const CStringW& name = m_sra.GetNextKey(pos);
- if(!names.Lookup(name)) m_sra.RemoveAtPos(cur);
+ if(!names.Lookup(name)) {
+ m_sra.RemoveAtPos(cur);
+ }
}
}
@@ -97,20 +99,22 @@ namespace ssf
{
m_sra.UpdateTarget(vs, vr);
- if(s->m_text.IsEmpty())
+ if(s->m_text.IsEmpty()) {
return NULL;
+ }
CRect spdrc = s->m_frame.reference == _T("video") ? vr : CRect(CPoint(0, 0), vs);
- if(spdrc.IsRectEmpty())
+ if(spdrc.IsRectEmpty()) {
return NULL;
+ }
RenderedSubtitle* rs = NULL;
- if(m_rsc.Lookup(s->m_name, rs))
- {
- if(!s->m_animated && rs->m_spdrc == spdrc)
+ if(m_rsc.Lookup(s->m_name, rs)) {
+ if(!s->m_animated && rs->m_spdrc == spdrc) {
return rs;
+ }
m_rsc.Invalidate(s->m_name);
}
@@ -131,14 +135,26 @@ namespace ssf
CRect clip;
- if(style.placement.clip.l == -1) clip.left = 0;
- else clip.left = (int)(spdrc.left + style.placement.clip.l * scale.cx);
- if(style.placement.clip.t == -1) clip.top = 0;
- else clip.top = (int)(spdrc.top + style.placement.clip.t * scale.cy);
- if(style.placement.clip.r == -1) clip.right = vs.cx;
- else clip.right = (int)(spdrc.left + style.placement.clip.r * scale.cx);
- if(style.placement.clip.b == -1) clip.bottom = vs.cy;
- else clip.bottom = (int)(spdrc.top + style.placement.clip.b * scale.cy);
+ if(style.placement.clip.l == -1) {
+ clip.left = 0;
+ } else {
+ clip.left = (int)(spdrc.left + style.placement.clip.l * scale.cx);
+ }
+ if(style.placement.clip.t == -1) {
+ clip.top = 0;
+ } else {
+ clip.top = (int)(spdrc.top + style.placement.clip.t * scale.cy);
+ }
+ if(style.placement.clip.r == -1) {
+ clip.right = vs.cx;
+ } else {
+ clip.right = (int)(spdrc.left + style.placement.clip.r * scale.cx);
+ }
+ if(style.placement.clip.b == -1) {
+ clip.bottom = vs.cy;
+ } else {
+ clip.bottom = (int)(spdrc.top + style.placement.clip.b * scale.cy);
+ }
clip.left = max(clip.left, 0);
clip.top = max(clip.top, 0);
@@ -157,8 +173,7 @@ namespace ssf
CAutoPtrList<Glyph> glyphs;
POSITION pos = s->m_text.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
const Text& t = s->m_text.GetNext(pos);
LOGFONT lf;
@@ -177,13 +192,11 @@ namespace ssf
FontWrapper* font = m_fc.Create(m_hDC, lf);
- if(!font)
- {
+ if(!font) {
_tcscpy_s(lf.lfFaceName, _T("Arial"));
font = m_fc.Create(m_hDC, lf);
- if(!font)
- {
+ if(!font) {
ASSERT(0);
continue;
}
@@ -193,8 +206,7 @@ namespace ssf
const TEXTMETRIC& tm = font->GetTextMetric();
- for(LPCWSTR c = t.str; *c; c++)
- {
+ for(LPCWSTR c = t.str; *c; c++) {
CAutoPtr<Glyph> g(DNew Glyph());
g->c = *c;
@@ -211,38 +223,34 @@ namespace ssf
GetTextExtentPoint32W(m_hDC, &g->c, 1, &extent);
ASSERT(extent.cx >= 0 && extent.cy >= 0);
- if(vertical)
- {
+ if(vertical) {
g->spacing = (int)(t.style.font.spacing * scale.cy + 0.5);
g->ascent = extent.cx / 2;
g->descent = extent.cx - g->ascent;
g->width = extent.cy;
// TESTME
- if(g->c == Text::SP)
- {
+ if(g->c == Text::SP) {
g->width /= 2;
}
- }
- else
- {
+ } else {
g->spacing = (int)(t.style.font.spacing * scale.cx + 0.5);
g->ascent = tm.tmAscent;
g->descent = tm.tmDescent;
g->width = extent.cx;
}
- if(g->c == Text::LSEP)
- {
+ if(g->c == Text::LSEP) {
g->spacing = 0;
g->width = 0;
g->ascent /= 2;
g->descent /= 2;
- }
- else
- {
+ } else {
GlyphPath* path = m_gpc.Create(m_hDC, font, g->c);
- if(!path) {ASSERT(0); continue;}
+ if(!path) {
+ ASSERT(0);
+ continue;
+ }
g->path = *path;
}
@@ -258,70 +266,67 @@ namespace ssf
CAutoPtr<Row> row;
pos = glyphs.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CAutoPtr<Glyph> g = glyphs.GetNext(pos);
- if(!row) row.Attach(DNew Row());
+ if(!row) {
+ row.Attach(DNew Row());
+ }
WCHAR c = g->c;
row->AddTail(g);
- if(c == Text::LSEP || !pos) rows.AddTail(row);
+ if(c == Text::LSEP || !pos) {
+ rows.AddTail(row);
+ }
}
// kerning
- if(s->m_direction.primary == _T("right")) // || s->m_direction.primary == _T("left")
- {
- for(POSITION rpos = rows.GetHeadPosition(); rpos; rows.GetNext(rpos))
- {
+ if(s->m_direction.primary == _T("right")) { // || s->m_direction.primary == _T("left")
+ for(POSITION rpos = rows.GetHeadPosition(); rpos; rows.GetNext(rpos)) {
Row* r = rows.GetAt(rpos);
POSITION gpos = r->GetHeadPosition();
- while(gpos)
- {
+ while(gpos) {
Glyph* g1 = r->GetNext(gpos);
- if(!gpos) break;
+ if(!gpos) {
+ break;
+ }
Glyph* g2 = r->GetAt(gpos);
- if(g1->font != g2->font || !g1->style.font.kerning || !g2->style.font.kerning)
+ if(g1->font != g2->font || !g1->style.font.kerning || !g2->style.font.kerning) {
continue;
+ }
- if(int size = g1->font->GetKernAmount(g1->c, g2->c))
- {
+ if(int size = g1->font->GetKernAmount(g1->c, g2->c)) {
g2->path.MovePoints(CPoint(size, 0));
g2->width += size;
}
}
- }
+ }
}
// wrap rows
- if(s->m_wrap == _T("normal") || s->m_wrap == _T("even"))
- {
+ if(s->m_wrap == _T("normal") || s->m_wrap == _T("even")) {
int maxwidth = abs((int)(vertical ? frame.Height() : frame.Width()));
int minwidth = 0;
- for(POSITION rpos = rows.GetHeadPosition(); rpos; rows.GetNext(rpos))
- {
+ for(POSITION rpos = rows.GetHeadPosition(); rpos; rows.GetNext(rpos)) {
Row* r = rows.GetAt(rpos);
-
+
POSITION brpos = NULL;
- if(s->m_wrap == _T("even"))
- {
+ if(s->m_wrap == _T("even")) {
int fullwidth = 0;
- for(POSITION gpos = r->GetHeadPosition(); gpos; r->GetNext(gpos))
- {
+ for(POSITION gpos = r->GetHeadPosition(); gpos; r->GetNext(gpos)) {
const Glyph* g = r->GetAt(gpos);
fullwidth += g->width + g->spacing;
}
fullwidth = abs(fullwidth);
-
- if(fullwidth > maxwidth)
- {
+
+ if(fullwidth > maxwidth) {
maxwidth = fullwidth / ((fullwidth / maxwidth) + 1);
minwidth = maxwidth;
}
@@ -329,29 +334,29 @@ namespace ssf
int width = 0;
- for(POSITION gpos = r->GetHeadPosition(); gpos; r->GetNext(gpos))
- {
+ for(POSITION gpos = r->GetHeadPosition(); gpos; r->GetNext(gpos)) {
const Glyph* g = r->GetAt(gpos);
width += g->width + g->spacing;
- if(brpos && abs(width) > maxwidth && g->c != Text::SP)
- {
+ if(brpos && abs(width) > maxwidth && g->c != Text::SP) {
row.Attach(DNew Row());
POSITION next = brpos;
r->GetNext(next);
- do {row->AddHead(r->GetPrev(brpos));} while(brpos);
+ do {
+ row->AddHead(r->GetPrev(brpos));
+ } while(brpos);
rows.InsertBefore(rpos, row);
- while(!r->IsEmpty() && r->GetHeadPosition() != next) r->RemoveHeadNoReturn();
+ while(!r->IsEmpty() && r->GetHeadPosition() != next) {
+ r->RemoveHeadNoReturn();
+ }
g = r->GetAt(gpos = next);
width = g->width + g->spacing;
}
- if(abs(width) >= minwidth)
- {
+ if(abs(width) >= minwidth) {
if(g->style.linebreak == _T("char")
- || g->style.linebreak == _T("word") && g->c == Text::SP)
- {
+ || g->style.linebreak == _T("word") && g->c == Text::SP) {
brpos = gpos;
}
}
@@ -361,15 +366,16 @@ namespace ssf
// trim rows
- for(POSITION pos = rows.GetHeadPosition(); pos; rows.GetNext(pos))
- {
+ for(POSITION pos = rows.GetHeadPosition(); pos; rows.GetNext(pos)) {
Row* r = rows.GetAt(pos);
- while(!r->IsEmpty() && r->GetHead()->c == Text::SP)
+ while(!r->IsEmpty() && r->GetHead()->c == Text::SP) {
r->RemoveHead();
+ }
- while(!r->IsEmpty() && r->GetTail()->c == Text::SP)
+ while(!r->IsEmpty() && r->GetTail()->c == Text::SP) {
r->RemoveTail();
+ }
}
// calc fill width for each glyph
@@ -378,21 +384,17 @@ namespace ssf
int fill_id = 0;
int fill_width = 0;
- for(POSITION pos = rows.GetHeadPosition(); pos; rows.GetNext(pos))
- {
+ for(POSITION pos = rows.GetHeadPosition(); pos; rows.GetNext(pos)) {
Row* r = rows.GetAt(pos);
POSITION gpos = r->GetHeadPosition();
- while(gpos)
- {
+ while(gpos) {
Glyph* g = r->GetNext(gpos);
- if(!glypsh2fill.IsEmpty() && fill_id && (g->style.fill.id != fill_id || !pos && !gpos))
- {
+ if(!glypsh2fill.IsEmpty() && fill_id && (g->style.fill.id != fill_id || !pos && !gpos)) {
int w = (int)(g->style.fill.width * fill_width + 0.5);
- while(!glypsh2fill.IsEmpty())
- {
+ while(!glypsh2fill.IsEmpty()) {
Glyph* g = glypsh2fill.RemoveTail();
fill_width -= g->width;
g->fill = w - fill_width;
@@ -407,8 +409,7 @@ namespace ssf
fill_id = g->style.fill.id;
- if(g->style.fill.id)
- {
+ if(g->style.fill.id) {
glypsh2fill.AddTail(g);
fill_width += g->width;
}
@@ -419,49 +420,49 @@ namespace ssf
CSize size(0, 0);
- if(s->m_direction.secondary == _T("left") || s->m_direction.secondary == _T("up"))
+ if(s->m_direction.secondary == _T("left") || s->m_direction.secondary == _T("up")) {
ReverseList(rows);
+ }
- for(POSITION pos = rows.GetHeadPosition(); pos; rows.GetNext(pos))
- {
+ for(POSITION pos = rows.GetHeadPosition(); pos; rows.GetNext(pos)) {
Row* r = rows.GetAt(pos);
- if(s->m_direction.primary == _T("left") || s->m_direction.primary == _T("up"))
+ if(s->m_direction.primary == _T("left") || s->m_direction.primary == _T("up")) {
ReverseList(*r);
+ }
int w = 0, h = 0;
r->width = 0;
- for(POSITION gpos = r->GetHeadPosition(); gpos; r->GetNext(gpos))
- {
+ for(POSITION gpos = r->GetHeadPosition(); gpos; r->GetNext(gpos)) {
const Glyph* g = r->GetAt(gpos);
w += g->width;
- if(gpos) w += g->spacing;
+ if(gpos) {
+ w += g->spacing;
+ }
h = max(h, g->ascent + g->descent);
r->width += g->width;
- if(gpos) r->width += g->spacing;
+ if(gpos) {
+ r->width += g->spacing;
+ }
r->ascent = max(r->ascent, g->ascent);
r->descent = max(r->descent, g->descent);
r->border = max(r->border, g->GetBackgroundSize());
}
- for(POSITION gpos = r->GetHeadPosition(); gpos; r->GetNext(gpos))
- {
+ for(POSITION gpos = r->GetHeadPosition(); gpos; r->GetNext(gpos)) {
Glyph* g = r->GetAt(gpos);
g->row_ascent = r->ascent;
g->row_descent = r->descent;
}
- if(vertical)
- {
+ if(vertical) {
size.cx += h;
size.cy = max(size.cy, w);
- }
- else
- {
+ } else {
size.cx = max(size.cx, w);
size.cy += h;
}
@@ -476,8 +477,7 @@ namespace ssf
// collision detection
- if(!s->m_animated)
- {
+ if(!s->m_animated) {
int tlb = !rows.IsEmpty() ? rows.GetHead()->border : 0;
int brb = !rows.IsEmpty() ? rows.GetTail()->border : 0;
@@ -491,19 +491,16 @@ namespace ssf
// continue positioning
- for(POSITION pos = rows.GetHeadPosition(); pos; rows.GetNext(pos))
- {
+ for(POSITION pos = rows.GetHeadPosition(); pos; rows.GetNext(pos)) {
Row* r = rows.GetAt(pos);
CSize rsize;
rsize.cx = rsize.cy = r->width;
- if(vertical)
- {
+ if(vertical) {
p.y = GetAlignPoint(style.placement, scale, frame, rsize).y;
- for(POSITION gpos = r->GetHeadPosition(); gpos; r->GetNext(gpos))
- {
+ for(POSITION gpos = r->GetHeadPosition(); gpos; r->GetNext(gpos)) {
CAutoPtr<Glyph> g = r->GetAt(gpos);
g->tl.x = p.x + (int)(g->style.placement.offset.x * scale.cx + 0.5) + r->ascent - g->ascent;
g->tl.y = p.y + (int)(g->style.placement.offset.y * scale.cy + 0.5);
@@ -512,13 +509,10 @@ namespace ssf
}
p.x += r->ascent + r->descent;
- }
- else
- {
+ } else {
p.x = GetAlignPoint(style.placement, scale, frame, rsize).x;
- for(POSITION gpos = r->GetHeadPosition(); gpos; r->GetNext(gpos))
- {
+ for(POSITION gpos = r->GetHeadPosition(); gpos; r->GetNext(gpos)) {
CAutoPtr<Glyph> g = r->GetAt(gpos);
g->tl.x = p.x + (int)(g->style.placement.offset.x * scale.cx + 0.5);
g->tl.y = p.y + (int)(g->style.placement.offset.y * scale.cy + 0.5) + r->ascent - g->ascent;
@@ -533,8 +527,7 @@ namespace ssf
// bkg, precalc style.placement.path, transform
pos = rs->m_glyphs.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
Glyph* g = rs->m_glyphs.GetNext(pos);
g->CreateBkg();
g->CreateSplineCoeffs(spdrc);
@@ -546,8 +539,7 @@ namespace ssf
Glyph* g0 = NULL;
pos = rs->m_glyphs.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
POSITION cur = pos;
Glyph* g = rs->m_glyphs.GetNext(pos);
@@ -565,12 +557,9 @@ namespace ssf
r.right = (r.right + 32) >> 6;
r.bottom = (r.bottom + 32) >> 6;
- if((r & clip).IsRectEmpty()) // clip
- {
+ if((r & clip).IsRectEmpty()) { // clip
rs->m_glyphs.RemoveAt(cur);
- }
- else if(g0 && g0->style.IsSimilar(g->style)) // append
- {
+ } else if(g0 && g0->style.IsSimilar(g->style)) { // append
CPoint o = g->tl - g0->tl;
g->path.MovePoints(o);
@@ -586,9 +575,7 @@ namespace ssf
g0->bbox |= g->bbox + o;
rs->m_glyphs.RemoveAt(cur);
- }
- else // leave alone
- {
+ } else { // leave alone
g0 = g;
}
}
@@ -596,7 +583,9 @@ namespace ssf
// rasterize
pos = rs->m_glyphs.GetHeadPosition();
- while(pos) rs->m_glyphs.GetNext(pos)->Rasterize();
+ while(pos) {
+ rs->m_glyphs.GetNext(pos)->Rasterize();
+ }
// cache
@@ -617,11 +606,12 @@ namespace ssf
// shadow
POSITION pos = m_glyphs.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
Glyph* g = m_glyphs.GetNext(pos);
- if(g->style.shadow.depth <= 0) continue;
+ if(g->style.shadow.depth <= 0) {
+ continue;
+ }
DWORD c = g->style.shadow.color;
DWORD sw[6] = {c, (DWORD)-1};
@@ -634,20 +624,16 @@ namespace ssf
// background
pos = m_glyphs.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
Glyph* g = m_glyphs.GetNext(pos);
DWORD c = g->style.background.color;
DWORD sw[6] = {c, (DWORD)-1};
- if(g->style.background.type == L"outline" && g->style.background.size > 0)
- {
+ if(g->style.background.type == L"outline" && g->style.background.size > 0) {
bbox |= g->ras.Draw(spd, m_clip, g->tl.x, g->tl.y, sw, g->style.font.color.a < 255 ? 2 : 1);
- }
- else if(g->style.background.type == L"enlarge" && g->style.background.size > 0
- || g->style.background.type == L"box" && g->style.background.size >= 0)
- {
+ } else if(g->style.background.type == L"enlarge" && g->style.background.size > 0
+ || g->style.background.type == L"box" && g->style.background.size >= 0) {
bbox |= g->ras_bkg.Draw(spd, m_clip, g->tl.x, g->tl.y, sw, 0);
}
}
@@ -655,8 +641,7 @@ namespace ssf
// body
pos = m_glyphs.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
Glyph* g = m_glyphs.GetNext(pos);
DWORD c = g->style.font.color;
@@ -672,11 +657,13 @@ namespace ssf
void SubRectAllocator::UpdateTarget(const CSize& s, const CRect& r)
{
- if(vs != s || vr != r) RemoveAll();
+ if(vs != s || vr != r) {
+ RemoveAll();
+ }
vs = s;
vr = r;
}
-
+
void SubRectAllocator::GetRect(CRect& rect, const Subtitle* s, const Align& align, int tlb, int brb)
{
SubRect sr(rect, s->m_layer);
@@ -684,51 +671,37 @@ namespace ssf
StringMapW<SubRect>::CPair* pPair = Lookup(s->m_name);
- if(pPair && pPair->m_value.rect != sr.rect)
- {
+ if(pPair && pPair->m_value.rect != sr.rect) {
RemoveKey(s->m_name);
pPair = NULL;
}
- if(!pPair)
- {
+ if(!pPair) {
bool vertical = s->m_direction.primary == _T("down") || s->m_direction.primary == _T("up");
bool fOK = false;
- while(!fOK)
- {
+ while(!fOK) {
fOK = true;
POSITION pos = GetStartPosition();
- while(pos)
- {
+ while(pos) {
const SubRect& sr2 = GetNextValue(pos);
- if(sr.layer == sr2.layer && !(sr.rect & sr2.rect).IsRectEmpty())
- {
- if(vertical)
- {
- if(align.h < 0.5)
- {
+ if(sr.layer == sr2.layer && !(sr.rect & sr2.rect).IsRectEmpty()) {
+ if(vertical) {
+ if(align.h < 0.5) {
sr.rect.right = sr2.rect.right + sr.rect.Width();
sr.rect.left = sr2.rect.right;
- }
- else
- {
+ } else {
sr.rect.left = sr2.rect.left - sr.rect.Width();
sr.rect.right = sr2.rect.left;
}
- }
- else
- {
- if(align.v < 0.5)
- {
+ } else {
+ if(align.v < 0.5) {
sr.rect.bottom = sr2.rect.bottom + sr.rect.Height();
sr.rect.top = sr2.rect.bottom;
- }
- else
- {
+ } else {
sr.rect.top = sr2.rect.top - sr.rect.Height();
sr.rect.bottom = sr2.rect.top;
}
@@ -752,21 +725,19 @@ namespace ssf
{
CStringW key;
- key.Format(L"%s,%d,%d,%d",
- CStringW(lf.lfFaceName), lf.lfHeight, lf.lfWeight,
- ((lf.lfItalic&1)<<2) | ((lf.lfUnderline&1)<<1) | ((lf.lfStrikeOut&1)<<0));
+ key.Format(L"%s,%d,%d,%d",
+ CStringW(lf.lfFaceName), lf.lfHeight, lf.lfWeight,
+ ((lf.lfItalic&1)<<2) | ((lf.lfUnderline&1)<<1) | ((lf.lfStrikeOut&1)<<0));
FontWrapper* pFW = NULL;
- if(m_key2obj.Lookup(key, pFW))
- {
+ if(m_key2obj.Lookup(key, pFW)) {
return pFW;
}
HFONT hFont = CreateFontIndirect(&lf);
- if(!hFont)
- {
+ if(!hFont) {
ASSERT(0);
return NULL;
}
@@ -786,27 +757,28 @@ namespace ssf
GlyphPath* path = NULL;
- if(m_key2obj.Lookup(key, path))
- {
+ if(m_key2obj.Lookup(key, path)) {
return path;
}
BeginPath(hDC);
TextOutW(hDC, 0, 0, &c, 1);
CloseFigure(hDC);
- if(!EndPath(hDC)) {AbortPath(hDC); ASSERT(0); return NULL;}
+ if(!EndPath(hDC)) {
+ AbortPath(hDC);
+ ASSERT(0);
+ return NULL;
+ }
path = DNew GlyphPath();
int count = GetPath(hDC, NULL, NULL, 0);
- if(count > 0)
- {
+ if(count > 0) {
path->points.SetCount(count);
path->types.SetCount(count);
- if(count != GetPath(hDC, path->points.GetData(), path->types.GetData(), count))
- {
+ if(count != GetPath(hDC, path->points.GetData(), path->types.GetData(), count)) {
ASSERT(0);
delete path;
return NULL;
diff --git a/src/Subtitles/libssf/Renderer.h b/src/Subtitles/libssf/Renderer.h
index ea0bc9b7e..bf2bd1826 100644
--- a/src/Subtitles/libssf/Renderer.h
+++ b/src/Subtitles/libssf/Renderer.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -35,31 +35,38 @@ namespace ssf
size_t m_limit;
public:
- Cache(size_t limit) {m_limit = max(1, limit);}
- virtual ~Cache() {RemoveAll();}
+ Cache(size_t limit) {
+ m_limit = max(1, limit);
+ }
+ virtual ~Cache() {
+ RemoveAll();
+ }
- void RemoveAll()
- {
+ void RemoveAll() {
POSITION pos = m_key2obj.GetStartPosition();
- while(pos) delete m_key2obj.GetNextValue(pos);
+ while(pos) {
+ delete m_key2obj.GetNextValue(pos);
+ }
m_key2obj.RemoveAll();
m_objs.RemoveAll();
}
- void Add(const CStringW& key, T& obj, bool fFlush = true)
- {
- if(StringMapW<T>::CPair* p = m_key2obj.Lookup(key)) delete p->m_value;
- else m_objs.AddTail(key);
+ void Add(const CStringW& key, T& obj, bool fFlush = true) {
+ if(StringMapW<T>::CPair* p = m_key2obj.Lookup(key)) {
+ delete p->m_value;
+ } else {
+ m_objs.AddTail(key);
+ }
m_key2obj[key] = obj;
- if(fFlush) Flush();
+ if(fFlush) {
+ Flush();
+ }
}
- void Flush()
- {
- while(m_objs.GetCount() > m_limit)
- {
+ void Flush() {
+ while(m_objs.GetCount() > m_limit) {
CStringW key = m_objs.RemoveHead();
ASSERT(m_key2obj.Lookup(key));
delete m_key2obj[key];
@@ -67,23 +74,20 @@ namespace ssf
}
}
- bool Lookup(const CStringW& key, T& val)
- {
+ bool Lookup(const CStringW& key, T& val) {
return m_key2obj.Lookup(key, val) && val;
}
- void Invalidate(const CStringW& key)
- {
+ void Invalidate(const CStringW& key) {
T val;
- if(m_key2obj.Lookup(key, val))
- {
+ if(m_key2obj.Lookup(key, val)) {
delete val;
m_key2obj[key] = NULL;
}
}
};
- class FontCache : public Cache<FontWrapper*>
+ class FontCache : public Cache<FontWrapper*>
{
public:
FontCache() : Cache(20) {}
@@ -101,7 +105,9 @@ namespace ssf
{
public:
int ascent, descent, border, width;
- Row() {ascent = descent = border = width = 0;}
+ Row() {
+ ascent = descent = border = width = 0;
+ }
};
class RenderedSubtitle
diff --git a/src/Subtitles/libssf/Split.cpp b/src/Subtitles/libssf/Split.cpp
index c7be38489..6c620703c 100644
--- a/src/Subtitles/libssf/Split.cpp
+++ b/src/Subtitles/libssf/Split.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -39,22 +39,27 @@ namespace ssf
{
RemoveAll();
- if(size_t seplen = wcslen(sep))
- {
- for(int i = 0, j = 0, len = str.GetLength();
- i <= len && (limit == 0 || GetCount() < limit);
- i = j + (int)seplen)
- {
+ if(size_t seplen = wcslen(sep)) {
+ for(int i = 0, j = 0, len = str.GetLength();
+ i <= len && (limit == 0 || GetCount() < limit);
+ i = j + (int)seplen) {
j = str.Find(sep, i);
- if(j < 0) j = len;
+ if(j < 0) {
+ j = len;
+ }
CStringW s = i < j ? str.Mid(i, j - i) : L"";
- switch(type)
- {
- case Min: s.Trim(); // fall through
- case Def: if(s.IsEmpty()) break; // else fall through
- case Max: Add(s); break;
+ switch(type) {
+ case Min:
+ s.Trim(); // fall through
+ case Def:
+ if(s.IsEmpty()) {
+ break; // else fall through
+ }
+ case Max:
+ Add(s);
+ break;
}
}
}
@@ -62,13 +67,17 @@ namespace ssf
int Split::GetAtInt(size_t i)
{
- if(i >= GetCount()) throw Exception(_T("Index out of bounds"));
+ if(i >= GetCount()) {
+ throw Exception(_T("Index out of bounds"));
+ }
return _wtoi(GetAt(i));
}
float Split::GetAtFloat(size_t i)
{
- if(i >= GetCount()) throw Exception(_T("Index out of bounds"));
+ if(i >= GetCount()) {
+ throw Exception(_T("Index out of bounds"));
+ }
return (float)_wtof(GetAt(i));
}
} \ No newline at end of file
diff --git a/src/Subtitles/libssf/Split.h b/src/Subtitles/libssf/Split.h
index 5cef60415..5a0c44341 100644
--- a/src/Subtitles/libssf/Split.h
+++ b/src/Subtitles/libssf/Split.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -30,7 +30,9 @@ namespace ssf
Split();
Split(LPCWSTR sep, CStringW str, size_t limit = 0, SplitType type = Def);
Split(WCHAR sep, CStringW str, size_t limit = 0, SplitType type = Def);
- operator size_t() {return GetCount();}
+ operator size_t() {
+ return GetCount();
+ }
void DoSplit(LPCWSTR sep, CStringW str, size_t limit, SplitType type);
int GetAtInt(size_t i);
float GetAtFloat(size_t i);
diff --git a/src/Subtitles/libssf/Stream.cpp b/src/Subtitles/libssf/Stream.cpp
index 7b4a9be02..fd4c3e400 100644
--- a/src/Subtitles/libssf/Stream.cpp
+++ b/src/Subtitles/libssf/Stream.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -30,7 +30,7 @@ namespace ssf
, m_line(0)
, m_col(-1)
{
-
+
}
Stream::~Stream()
@@ -43,7 +43,9 @@ namespace ssf
va_start(args, fmt);
int len = _vsctprintf(fmt, args) + 1;
CString str;
- if(len > 0) _vstprintf_s(str.GetBufferSetLength(len), len, fmt, args);
+ if(len > 0) {
+ _vstprintf_s(str.GetBufferSetLength(len), len, fmt, args);
+ }
va_end(args);
throw Exception(_T("Error (Ln %d Col %d): %s"), m_line+1, m_col+1, str);
@@ -58,7 +60,7 @@ namespace ssf
InputStream::InputStream()
{
-
+
}
InputStream::~InputStream()
@@ -67,26 +69,29 @@ namespace ssf
int InputStream::NextChar()
{
- if(m_encoding == none)
- {
+ if(m_encoding == none) {
m_encoding = unknown;
- switch(NextByte())
- {
- case 0xef:
- if(NextByte() == 0xbb && NextByte() == 0xbf) m_encoding = utf8;
- break;
- case 0xff:
- if(NextByte() == 0xfe) m_encoding = utf16le;
- break;
- case 0xfe:
- if(NextByte() == 0xff) m_encoding = utf16be;
- break;
+ switch(NextByte()) {
+ case 0xef:
+ if(NextByte() == 0xbb && NextByte() == 0xbf) {
+ m_encoding = utf8;
+ }
+ break;
+ case 0xff:
+ if(NextByte() == 0xfe) {
+ m_encoding = utf16le;
+ }
+ break;
+ case 0xfe:
+ if(NextByte() == 0xff) {
+ m_encoding = utf16be;
+ }
+ break;
}
}
- if(m_encoding == unknown)
- {
+ if(m_encoding == unknown) {
throw Exception(_T("unknown character encoding, missing BOM"));
}
@@ -94,25 +99,39 @@ namespace ssf
int cur = NextByte();
- switch(m_encoding)
- {
- case utf8:
- for(i = 7; i >= 0 && (cur & (1 << i)); i--);
- cur &= (1 << i) - 1;
- while(++i < 7) {c = NextByte(); if(c == EOS) {cur = EOS; break;} cur = (cur << 6) | (c & 0x3f);}
- break;
- case utf16le:
- c = NextByte();
- if(c == EOS) {cur = EOS; break;}
- cur = (c << 8) | cur;
- break;
- case utf16be:
- c = NextByte();
- if(c == EOS) {cur = EOS; break;}
- cur = cur | (c << 8);
- break;
- case wchar:
- break;
+ switch(m_encoding) {
+ case utf8:
+ for(i = 7; i >= 0 && (cur & (1 << i)); i--) {
+ ;
+ }
+ cur &= (1 << i) - 1;
+ while(++i < 7) {
+ c = NextByte();
+ if(c == EOS) {
+ cur = EOS;
+ break;
+ }
+ cur = (cur << 6) | (c & 0x3f);
+ }
+ break;
+ case utf16le:
+ c = NextByte();
+ if(c == EOS) {
+ cur = EOS;
+ break;
+ }
+ cur = (c << 8) | cur;
+ break;
+ case utf16be:
+ c = NextByte();
+ if(c == EOS) {
+ cur = EOS;
+ break;
+ }
+ cur = cur | (c << 8);
+ break;
+ case wchar:
+ break;
}
return cur;
@@ -127,13 +146,17 @@ namespace ssf
int InputStream::PopChar()
{
- if(m_queue.IsEmpty()) ThrowError(_T("fatal stream error"));
+ if(m_queue.IsEmpty()) {
+ ThrowError(_T("fatal stream error"));
+ }
int c = m_queue.RemoveHead();
- if(c != EOS)
- {
- if(c == '\n') {m_line++; m_col = -1;}
+ if(c != EOS) {
+ if(c == '\n') {
+ m_line++;
+ m_col = -1;
+ }
m_col++;
}
@@ -142,23 +165,32 @@ namespace ssf
int InputStream::PeekChar()
{
- while(m_queue.GetCount() < 2) PushChar();
+ while(m_queue.GetCount() < 2) {
+ PushChar();
+ }
ASSERT(m_queue.GetCount() == 2);
- if(m_queue.GetHead() == '/' && m_queue.GetTail() == '/')
- {
- while(!m_queue.IsEmpty()) PopChar();
+ if(m_queue.GetHead() == '/' && m_queue.GetTail() == '/') {
+ while(!m_queue.IsEmpty()) {
+ PopChar();
+ }
int c;
- do {PushChar(); c = PopChar();} while(!(c == '\n' || c == EOS));
+ do {
+ PushChar();
+ c = PopChar();
+ } while(!(c == '\n' || c == EOS));
return PeekChar();
- }
- else if(m_queue.GetHead() == '/' && m_queue.GetTail() == '*')
- {
- while(!m_queue.IsEmpty()) PopChar();
+ } else if(m_queue.GetHead() == '/' && m_queue.GetTail() == '*') {
+ while(!m_queue.IsEmpty()) {
+ PopChar();
+ }
int c1, c2;
PushChar();
- do {c2 = PushChar(); c1 = PopChar();} while(!((c1 == '*' && c2 == '/') || c1 == EOS));
+ do {
+ c2 = PushChar();
+ c1 = PopChar();
+ } while(!((c1 == '*' && c2 == '/') || c1 == EOS));
PopChar();
return PeekChar();
}
@@ -168,34 +200,44 @@ namespace ssf
int InputStream::GetChar()
{
- if(m_queue.GetCount() < 2) PeekChar();
+ if(m_queue.GetCount() < 2) {
+ PeekChar();
+ }
return PopChar();
}
int InputStream::SkipWhiteSpace(LPCWSTR morechars)
{
int c = PeekChar();
- for(; IsWhiteSpace(c, morechars); c = PeekChar())
+ for(; IsWhiteSpace(c, morechars); c = PeekChar()) {
GetChar();
+ }
return c;
}
// FileInputStream
- FileInputStream::FileInputStream(const TCHAR* fn)
+ FileInputStream::FileInputStream(const TCHAR* fn)
: m_file(NULL)
{
- if(_tfopen_s(&m_file, fn, _T("r")) != 0) ThrowError(_T("cannot open file '%s'"), fn);
+ if(_tfopen_s(&m_file, fn, _T("r")) != 0) {
+ ThrowError(_T("cannot open file '%s'"), fn);
+ }
}
FileInputStream::~FileInputStream()
{
- if(m_file) {fclose(m_file); m_file = NULL;}
+ if(m_file) {
+ fclose(m_file);
+ m_file = NULL;
+ }
}
int FileInputStream::NextByte()
{
- if(!m_file) ThrowError(_T("file pointer is NULL"));
+ if(!m_file) {
+ ThrowError(_T("file pointer is NULL"));
+ }
return fgetc(m_file);
}
@@ -206,36 +248,43 @@ namespace ssf
, m_pos(0)
, m_len(len)
{
- if(fCopy)
- {
+ if(fCopy) {
m_pBytes = DNew BYTE[len];
- if(m_pBytes) memcpy(m_pBytes, pBytes, len);
+ if(m_pBytes) {
+ memcpy(m_pBytes, pBytes, len);
+ }
m_fFree = true;
- }
- else
- {
+ } else {
m_pBytes = pBytes;
m_fFree = fFree;
}
- if(!m_pBytes) ThrowError(_T("memory stream pointer is NULL"));
+ if(!m_pBytes) {
+ ThrowError(_T("memory stream pointer is NULL"));
+ }
}
MemoryInputStream::~MemoryInputStream()
{
- if(m_fFree) delete [] m_pBytes;
+ if(m_fFree) {
+ delete [] m_pBytes;
+ }
m_pBytes = NULL;
}
int MemoryInputStream::NextByte()
{
- if(!m_pBytes) ThrowError(_T("memory stream pointer is NULL"));
- if(m_pos >= m_len) return Stream::EOS;
+ if(!m_pBytes) {
+ ThrowError(_T("memory stream pointer is NULL"));
+ }
+ if(m_pos >= m_len) {
+ return Stream::EOS;
+ }
return (int)m_pBytes[m_pos++];
}
// WCharInputStream
-
+
WCharInputStream::WCharInputStream(CStringW str)
: m_str(str)
, m_pos(0)
@@ -245,7 +294,9 @@ namespace ssf
int WCharInputStream::NextByte()
{
- if(m_pos >= m_str.GetLength()) return Stream::EOS;
+ if(m_pos >= m_str.GetLength()) {
+ return Stream::EOS;
+ }
return m_str[m_pos++];
}
@@ -263,54 +314,44 @@ namespace ssf
void OutputStream::PutChar(WCHAR c)
{
- if(m_bof)
- {
+ if(m_bof) {
m_bof = false;
- switch(m_encoding)
- {
- case utf8:
- case utf16le:
- case utf16be:
- PutChar(0xfeff);
- break;
+ switch(m_encoding) {
+ case utf8:
+ case utf16le:
+ case utf16be:
+ PutChar(0xfeff);
+ break;
}
}
- switch(m_encoding)
- {
- case utf8:
- if(0 <= c && c < 0x80) // 0xxxxxxx
- {
+ switch(m_encoding) {
+ case utf8:
+ if(0 <= c && c < 0x80) { // 0xxxxxxx
+ NextByte(c);
+ } else if(0x80 <= c && c < 0x800) { // 110xxxxx 10xxxxxx
+ NextByte(0xc0 | ((c<<2)&0x1f));
+ NextByte(0x80 | ((c<<0)&0x3f));
+ } else if(0x800 <= c && c < 0xFFFF) { // 1110xxxx 10xxxxxx 10xxxxxx
+ NextByte(0xe0 | ((c<<4)&0x0f));
+ NextByte(0x80 | ((c<<2)&0x3f));
+ NextByte(0x80 | ((c<<0)&0x3f));
+ } else {
+ NextByte('?');
+ }
+ break;
+ case utf16le:
+ NextByte(c & 0xff);
+ NextByte((c >> 8) & 0xff);
+ break;
+ case utf16be:
+ NextByte((c >> 8) & 0xff);
+ NextByte(c & 0xff);
+ break;
+ case wchar:
NextByte(c);
- }
- else if(0x80 <= c && c < 0x800) // 110xxxxx 10xxxxxx
- {
- NextByte(0xc0 | ((c<<2)&0x1f));
- NextByte(0x80 | ((c<<0)&0x3f));
- }
- else if(0x800 <= c && c < 0xFFFF) // 1110xxxx 10xxxxxx 10xxxxxx
- {
- NextByte(0xe0 | ((c<<4)&0x0f));
- NextByte(0x80 | ((c<<2)&0x3f));
- NextByte(0x80 | ((c<<0)&0x3f));
- }
- else
- {
- NextByte('?');
- }
- break;
- case utf16le:
- NextByte(c & 0xff);
- NextByte((c >> 8) & 0xff);
- break;
- case utf16be:
- NextByte((c >> 8) & 0xff);
- NextByte(c & 0xff);
- break;
- case wchar:
- NextByte(c);
- break;
+ break;
}
}
@@ -321,11 +362,15 @@ namespace ssf
va_list args;
va_start(args, fmt);
int len = _vscwprintf(fmt, args) + 1;
- if(len > 0) vswprintf_s(str.GetBufferSetLength(len), len, fmt, args);
+ if(len > 0) {
+ vswprintf_s(str.GetBufferSetLength(len), len, fmt, args);
+ }
va_end(args);
LPCWSTR s = str;
- while(*s) PutChar(*s++);
+ while(*s) {
+ PutChar(*s++);
+ }
}
// WCharOutputStream
@@ -354,7 +399,11 @@ namespace ssf
void DebugOutputStream::NextByte(int b)
{
- if(b == '\n') {TRACE(_T("%s\n"), m_str); m_str.Empty();}
- else if(b != '\r') m_str += (WCHAR)b;
+ if(b == '\n') {
+ TRACE(_T("%s\n"), m_str);
+ m_str.Empty();
+ } else if(b != '\r') {
+ m_str += (WCHAR)b;
+ }
}
} \ No newline at end of file
diff --git a/src/Subtitles/libssf/Stream.h b/src/Subtitles/libssf/Stream.h
index a95375ad5..a24fe46c1 100644
--- a/src/Subtitles/libssf/Stream.h
+++ b/src/Subtitles/libssf/Stream.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -126,7 +126,9 @@ namespace ssf
public:
WCharOutputStream();
- const CStringW& GetString() {return m_str;}
+ const CStringW& GetString() {
+ return m_str;
+ }
};
class DebugOutputStream : public OutputStream
diff --git a/src/Subtitles/libssf/StringMap.cpp b/src/Subtitles/libssf/StringMap.cpp
index a3a90383b..7cc59e1b3 100644
--- a/src/Subtitles/libssf/StringMap.cpp
+++ b/src/Subtitles/libssf/StringMap.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/Subtitles/libssf/StringMap.h b/src/Subtitles/libssf/StringMap.h
index 0952c66a2..30f528b4d 100644
--- a/src/Subtitles/libssf/StringMap.h
+++ b/src/Subtitles/libssf/StringMap.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -23,24 +23,28 @@
namespace ssf
{
- template <class T = CString, class S = CString>
+ template <class T = CString, class S = CString>
class StringMap : public CAtlMap<S, T, CStringElementTraits<S> >
{
public:
StringMap() {}
- StringMap(const StringMap& s2t) {*this = s2t;}
- StringMap& operator = (const StringMap& s2t)
- {
+ StringMap(const StringMap& s2t) {
+ *this = s2t;
+ }
+ StringMap& operator = (const StringMap& s2t) {
RemoveAll();
POSITION pos = s2t.GetStartPosition();
- while(pos) {const StringMap::CPair* p = s2t.GetNext(pos); SetAt(p->m_key, p->m_value);}
+ while(pos) {
+ const StringMap::CPair* p = s2t.GetNext(pos);
+ SetAt(p->m_key, p->m_value);
+ }
return *this;
}
};
- template <class T = CStringA, class S = CStringA>
+ template <class T = CStringA, class S = CStringA>
class StringMapA : public StringMap<T, S> {};
- template <class T = CStringW, class S = CStringW>
+ template <class T = CStringW, class S = CStringW>
class StringMapW : public StringMap<T, S> {};
} \ No newline at end of file
diff --git a/src/Subtitles/libssf/Subtitle.cpp b/src/Subtitles/libssf/Subtitle.cpp
index eb56b0531..288d6b0a9 100644
--- a/src/Subtitles/libssf/Subtitle.cpp
+++ b/src/Subtitles/libssf/Subtitle.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -28,42 +28,38 @@ namespace ssf
{
struct Subtitle::n2n_t Subtitle::m_n2n;
- Subtitle::Subtitle(File* pFile)
+ Subtitle::Subtitle(File* pFile)
: m_pFile(pFile)
, m_animated(false)
{
- if(m_n2n.align[0].IsEmpty())
- {
+ if(m_n2n.align[0].IsEmpty()) {
m_n2n.align[0][L"left"] = 0;
m_n2n.align[0][L"center"] = 0.5;
m_n2n.align[0][L"middle"] = 0.5;
m_n2n.align[0][L"right"] = 1;
}
-
- if(m_n2n.align[1].IsEmpty())
- {
+
+ if(m_n2n.align[1].IsEmpty()) {
m_n2n.align[1][L"top"] = 0;
m_n2n.align[1][L"middle"] = 0.5;
m_n2n.align[1][L"center"] = 0.5;
m_n2n.align[1][L"bottom"] = 1;
}
-
- if(m_n2n.weight.IsEmpty())
- {
+
+ if(m_n2n.weight.IsEmpty()) {
m_n2n.weight[L"thin"] = FW_THIN;
m_n2n.weight[L"normal"] = FW_NORMAL;
m_n2n.weight[L"bold"] = FW_BOLD;
}
- if(m_n2n.transition.IsEmpty())
- {
+ if(m_n2n.transition.IsEmpty()) {
m_n2n.transition[L"start"] = 0;
m_n2n.transition[L"stop"] = 1e10;
m_n2n.transition[L"linear"] = 1;
}
}
- Subtitle::~Subtitle()
+ Subtitle::~Subtitle()
{
}
@@ -84,8 +80,7 @@ namespace ssf
m_pFile->Commit();
- try
- {
+ try {
Definition& frame = (*pDef)[L"frame"];
m_frame.reference = frame[L"reference"];
@@ -110,21 +105,20 @@ namespace ssf
// TODO: trimming should be done by the renderer later, after breaking the words into lines
- while(!m_text.IsEmpty() && (m_text.GetHead().str == Text::SP || m_text.GetHead().str == Text::LSEP))
+ while(!m_text.IsEmpty() && (m_text.GetHead().str == Text::SP || m_text.GetHead().str == Text::LSEP)) {
m_text.RemoveHead();
+ }
- while(!m_text.IsEmpty() && (m_text.GetTail().str == Text::SP || m_text.GetTail().str == Text::LSEP))
+ while(!m_text.IsEmpty() && (m_text.GetTail().str == Text::SP || m_text.GetTail().str == Text::LSEP)) {
m_text.RemoveTail();
+ }
- for(POSITION pos = m_text.GetHeadPosition(); pos; m_text.GetNext(pos))
- {
- if(m_text.GetAt(pos).str == Text::LSEP)
- {
+ for(POSITION pos = m_text.GetHeadPosition(); pos; m_text.GetNext(pos)) {
+ if(m_text.GetAt(pos).str == Text::LSEP) {
POSITION prev = pos;
m_text.GetPrev(prev);
- while(prev && m_text.GetAt(prev).str == Text::SP)
- {
+ while(prev && m_text.GetAt(prev).str == Text::SP) {
POSITION tmp = prev;
m_text.GetPrev(prev);
m_text.RemoveAt(tmp);
@@ -133,17 +127,14 @@ namespace ssf
POSITION next = pos;
m_text.GetNext(next);
- while(next && m_text.GetAt(next).str == Text::SP)
- {
+ while(next && m_text.GetAt(next).str == Text::SP) {
POSITION tmp = next;
m_text.GetNext(next);
m_text.RemoveAt(tmp);
}
}
}
- }
- catch(Exception& e)
- {
+ } catch(Exception& e) {
UNREFERENCED_PARAMETER(e);
TRACE(_T("%s"), e.ToString());
return false;
@@ -181,19 +172,26 @@ namespace ssf
Definition& clip = placement[L"clip"];
- if(clip.IsValue(Definition::string))
- {
+ if(clip.IsValue(Definition::string)) {
CStringW str = clip;
- if(str == L"frame") style.placement.clip = frame;
+ if(str == L"frame") {
+ style.placement.clip = frame;
+ }
// else ?
- }
- else
- {
- if(clip[L"t"].IsValue()) style.placement.clip.t = clip[L"t"];
- if(clip[L"r"].IsValue()) style.placement.clip.r = clip[L"r"];
- if(clip[L"b"].IsValue()) style.placement.clip.b = clip[L"b"];
- if(clip[L"l"].IsValue()) style.placement.clip.l = clip[L"l"];
+ } else {
+ if(clip[L"t"].IsValue()) {
+ style.placement.clip.t = clip[L"t"];
+ }
+ if(clip[L"r"].IsValue()) {
+ style.placement.clip.r = clip[L"r"];
+ }
+ if(clip[L"b"].IsValue()) {
+ style.placement.clip.b = clip[L"b"];
+ }
+ if(clip[L"l"].IsValue()) {
+ style.placement.clip.l = clip[L"l"];
+ }
}
StringMapW<float> n2n_margin[2];
@@ -215,8 +213,14 @@ namespace ssf
placement[L"align"][L"h"].GetAsNumber(style.placement.align.h, &m_n2n.align[0]);
placement[L"align"][L"v"].GetAsNumber(style.placement.align.v, &m_n2n.align[1]);
- if(placement[L"pos"][L"x"].IsValue()) {style.placement.pos.x = placement[L"pos"][L"x"]; style.placement.pos.auto_x = false;}
- if(placement[L"pos"][L"y"].IsValue()) {style.placement.pos.y = placement[L"pos"][L"y"]; style.placement.pos.auto_y = false;}
+ if(placement[L"pos"][L"x"].IsValue()) {
+ style.placement.pos.x = placement[L"pos"][L"x"];
+ style.placement.pos.auto_x = false;
+ }
+ if(placement[L"pos"][L"y"].IsValue()) {
+ style.placement.pos.y = placement[L"pos"][L"y"];
+ style.placement.pos.auto_y = false;
+ }
placement[L"offset"][L"x"].GetAsNumber(style.placement.offset.x);
placement[L"offset"][L"y"].GetAsNumber(style.placement.offset.y);
@@ -225,8 +229,14 @@ namespace ssf
style.placement.angle.y = placement[L"angle"][L"y"];
style.placement.angle.z = placement[L"angle"][L"z"];
- if(placement[L"org"][L"x"].IsValue()) {style.placement.org.x = placement[L"org"][L"x"]; style.placement.org.auto_x = false;}
- if(placement[L"org"][L"y"].IsValue()) {style.placement.org.y = placement[L"org"][L"y"]; style.placement.org.auto_y = false;}
+ if(placement[L"org"][L"x"].IsValue()) {
+ style.placement.org.x = placement[L"org"][L"x"];
+ style.placement.org.auto_x = false;
+ }
+ if(placement[L"org"][L"y"].IsValue()) {
+ style.placement.org.y = placement[L"org"][L"y"];
+ style.placement.org.auto_y = false;
+ }
style.placement.path = placement[L"path"];
@@ -280,88 +290,93 @@ namespace ssf
{
float t = 1;
- try
- {
+ try {
StringMapW<float> n2n;
n2n[L"start"] = 0;
n2n[L"stop"] = m_time.stop - m_time.start;
Definition::Time time;
- if(pDef->GetAsTime(time, offset, &n2n, default_id) && time.start.value < time.stop.value)
- {
+ if(pDef->GetAsTime(time, offset, &n2n, default_id) && time.start.value < time.stop.value) {
t = (at - time.start.value) / (time.stop.value - time.start.value);
float u = t;
- if(t < 0) t = 0;
- else if(t >= 1) t = 0.99999f; // doh
+ if(t < 0) {
+ t = 0;
+ } else if(t >= 1) {
+ t = 0.99999f; // doh
+ }
- if((*pDef)[L"loop"].IsValue()) t *= (float)(*pDef)[L"loop"];
+ if((*pDef)[L"loop"].IsValue()) {
+ t *= (float)(*pDef)[L"loop"];
+ }
CStringW direction = (*pDef)[L"direction"].IsValue() ? (*pDef)[L"direction"] : L"fw";
- if(direction == L"fwbw" || direction == L"bwfw") t *= 2;
+ if(direction == L"fwbw" || direction == L"bwfw") {
+ t *= 2;
+ }
float n;
t = modf(t, &n);
- if(direction == L"bw"
- || direction == L"fwbw" && ((int)n & 1)
- || direction == L"bwfw" && !((int)n & 1))
+ if(direction == L"bw"
+ || direction == L"fwbw" && ((int)n & 1)
+ || direction == L"bwfw" && !((int)n & 1)) {
t = 1 - t;
+ }
float accel = 1;
- if((*pDef)[L"transition"].IsValue())
- {
+ if((*pDef)[L"transition"].IsValue()) {
Definition::Number<float> n;
(*pDef)[L"transition"].GetAsNumber(n, &m_n2n.transition);
- if(n.value >= 0) accel = n.value;
+ if(n.value >= 0) {
+ accel = n.value;
+ }
}
- if(t == 0.99999f) t = 1;
+ if(t == 0.99999f) {
+ t = 1;
+ }
- if(u >= 0 && u < 1)
- {
- t = accel == 0 ? 1 :
- accel == 1 ? t :
+ if(u >= 0 && u < 1) {
+ t = accel == 0 ? 1 :
+ accel == 1 ? t :
accel >= 1e10 ? 0 :
pow(t, accel);
}
}
- }
- catch(Exception&)
- {
+ } catch(Exception&) {
}
return t;
}
- template<class T>
+ template<class T>
bool Subtitle::MixValue(Definition& def, T& value, float t)
{
StringMapW<T> n2n;
return MixValue(def, value, t, &n2n);
}
- template<>
+ template<>
bool Subtitle::MixValue(Definition& def, float& value, float t)
{
StringMapW<float> n2n;
return MixValue(def, value, t, &n2n);
}
- template<class T>
+ template<class T>
bool Subtitle::MixValue(Definition& def, T& value, float t, StringMapW<T>* n2n)
{
- if(!def.IsValue()) return false;
-
- if(t >= 0.5)
- {
- if(n2n && def.IsValue(Definition::string))
- {
- if(StringMapW<T>::CPair* p = n2n->Lookup(def))
- {
+ if(!def.IsValue()) {
+ return false;
+ }
+
+ if(t >= 0.5) {
+ if(n2n && def.IsValue(Definition::string)) {
+ if(StringMapW<T>::CPair* p = n2n->Lookup(def)) {
value = p->m_value;
return true;
}
@@ -373,17 +388,16 @@ namespace ssf
return true;
}
- template<>
+ template<>
bool Subtitle::MixValue(Definition& def, float& value, float t, StringMapW<float>* n2n)
{
- if(!def.IsValue()) return false;
-
- if(t > 0)
- {
- if(n2n && def.IsValue(Definition::string))
- {
- if(StringMap<float, CStringW>::CPair* p = n2n->Lookup(def))
- {
+ if(!def.IsValue()) {
+ return false;
+ }
+
+ if(t > 0) {
+ if(n2n && def.IsValue(Definition::string)) {
+ if(StringMap<float, CStringW>::CPair* p = n2n->Lookup(def)) {
value += (p->m_value - value) * t;
return true;
}
@@ -398,20 +412,17 @@ namespace ssf
template<>
bool Subtitle::MixValue(Definition& def, Path& src, float t)
{
- if(!def.IsValue(Definition::string)) return false;
+ if(!def.IsValue(Definition::string)) {
+ return false;
+ }
- if(t >= 1)
- {
+ if(t >= 1) {
src = (LPCWSTR)def;
- }
- else if(t > 0)
- {
+ } else if(t > 0) {
Path dst = (LPCWSTR)def;
- if(src.GetCount() == dst.GetCount())
- {
- for(size_t i = 0, j = src.GetCount(); i < j; i++)
- {
+ if(src.GetCount() == dst.GetCount()) {
+ for(size_t i = 0, j = src.GetCount(); i < j; i++) {
Point& s = src[i];
const Point& d = dst[i];
s.x += (d.x - s.x) * t;
@@ -427,8 +438,11 @@ namespace ssf
{
const Style src = dst;
- if(t <= 0) return;
- else if(t > 1) t = 1;
+ if(t <= 0) {
+ return;
+ } else if(t > 1) {
+ t = 1;
+ }
MixValue((*pDef)[L"linebreak"], dst.linebreak, t);
@@ -496,9 +510,10 @@ namespace ssf
MixValue(fill[L"color"][L"b"], dst.fill.color.b, t);
MixValue(fill[L"width"], dst.fill.width, t);
- if(fill.m_priority >= PNormal) // this assumes there is no way to set low priority inline overrides
- {
- if(dst.fill.id > 0) throw Exception(_T("cannot apply fill more than once on the same text"));
+ if(fill.m_priority >= PNormal) { // this assumes there is no way to set low priority inline overrides
+ if(dst.fill.id > 0) {
+ throw Exception(_T("cannot apply fill more than once on the same text"));
+ }
dst.fill.id = ++Fill::gen_id;
}
}
@@ -508,12 +523,10 @@ namespace ssf
Text text;
text.style = style;
- for(int c = s.PeekChar(); c != Stream::EOS; c = s.PeekChar())
- {
+ for(int c = s.PeekChar(); c != Stream::EOS; c = s.PeekChar()) {
s.GetChar();
- if(c == '[')
- {
+ if(c == '[') {
AddText(text);
style = text.style;
@@ -522,69 +535,64 @@ namespace ssf
int default_id = 0;
- do
- {
+ do {
Definition* pDef = m_pFile->CreateDef(pParentRef);
m_pFile->ParseRefs(s, pDef, L",;]");
ASSERT(pDef->IsType(L"style") || pDef->IsTypeUnknown());
- if((*pDef)[L"time"][L"start"].IsValue() && (*pDef)[L"time"][L"stop"].IsValue())
- {
+ if((*pDef)[L"time"][L"start"].IsValue() && (*pDef)[L"time"][L"stop"].IsValue()) {
m_animated = true;
}
float t = GetMixWeight(pDef, at, offset, ++default_id);
MixStyle(pDef, style, t);
- if((*pDef)[L"@"].IsValue())
- {
+ if((*pDef)[L"@"].IsValue()) {
Parse(WCharInputStream((LPCWSTR)(*pDef)[L"@"]), style, at, offset, pParentRef);
}
s.SkipWhiteSpace();
c = s.GetChar();
- }
- while(c == ',' || c == ';');
+ } while(c == ',' || c == ';');
- if(c != ']') s.ThrowError(_T("unterminated override"));
+ if(c != ']') {
+ s.ThrowError(_T("unterminated override"));
+ }
bool fWhiteSpaceNext = s.IsWhiteSpace(s.PeekChar());
c = s.SkipWhiteSpace();
- if(c == '{')
- {
+ if(c == '{') {
s.GetChar();
Parse(s, style, at, inneroffset, pParentRef);
- }
- else
- {
- if(fWhiteSpaceNext) text.str += (WCHAR)Text::SP;
+ } else {
+ if(fWhiteSpaceNext) {
+ text.str += (WCHAR)Text::SP;
+ }
text.style = style;
}
- }
- else if(c == ']')
- {
+ } else if(c == ']') {
s.ThrowError(_T("unexpected ] found"));
- }
- else if(c == '{')
- {
+ } else if(c == '{') {
AddText(text);
Parse(s, text.style, at, offset, pParentRef);
- }
- else if(c == '}')
- {
+ } else if(c == '}') {
break;
- }
- else
- {
- if(c == '\\')
- {
+ } else {
+ if(c == '\\') {
c = s.GetChar();
- if(c == Stream::EOS) break;
- else if(c == 'n') {AddText(text); text.str = (WCHAR)Text::LSEP; AddText(text); continue;}
- else if(c == 'h') c = Text::NBSP;
+ if(c == Stream::EOS) {
+ break;
+ } else if(c == 'n') {
+ AddText(text);
+ text.str = (WCHAR)Text::LSEP;
+ AddText(text);
+ continue;
+ } else if(c == 'h') {
+ c = Text::NBSP;
+ }
}
AddChar(text, (WCHAR)c);
@@ -598,33 +606,36 @@ namespace ssf
{
bool f1 = !t.str.IsEmpty() && Stream::IsWhiteSpace(t.str[t.str.GetLength()-1]);
bool f2 = Stream::IsWhiteSpace(c);
- if(f2) c = Text::SP;
- if(!f1 || !f2) t.str += (WCHAR)c;
+ if(f2) {
+ c = Text::SP;
+ }
+ if(!f1 || !f2) {
+ t.str += (WCHAR)c;
+ }
}
void Subtitle::AddText(Text& t)
{
- if(t.str.IsEmpty()) return;
+ if(t.str.IsEmpty()) {
+ return;
+ }
Split sa(' ', t.str, 0, Split::Max);
- for(size_t i = 0, n = sa; i < n; i++)
- {
+ for(size_t i = 0, n = sa; i < n; i++) {
CStringW str = sa[i];
- if(!str.IsEmpty())
- {
+ if(!str.IsEmpty()) {
t.str = str;
m_text.AddTail(t);
}
- if(i < n-1 && (m_text.IsEmpty() || m_text.GetTail().str != Text::SP))
- {
+ if(i < n-1 && (m_text.IsEmpty() || m_text.GetTail().str != Text::SP)) {
t.str = (WCHAR)Text::SP;
m_text.AddTail(t);
}
}
-
+
t.str.Empty();
}
@@ -634,7 +645,7 @@ namespace ssf
Color::operator DWORD()
{
- DWORD c =
+ DWORD c =
(min(max((DWORD)b, 0), 255) << 0) |
(min(max((DWORD)g, 0), 255) << 8) |
(min(max((DWORD)r, 0), 255) << 16) |
@@ -649,8 +660,7 @@ namespace ssf
SetCount(s/2);
- for(size_t i = 0, j = GetCount(); i < j; i++)
- {
+ for(size_t i = 0, j = GetCount(); i < j; i++) {
Point p;
p.x = s.GetAtFloat(i*2+0);
p.y = s.GetAtFloat(i*2+1);
@@ -664,8 +674,7 @@ namespace ssf
{
CStringW ret;
- for(size_t i = 0, j = GetCount(); i < j; i++)
- {
+ for(size_t i = 0, j = GetCount(); i < j; i++) {
const Point& p = GetAt(i);
CStringW str;
@@ -678,25 +687,25 @@ namespace ssf
bool Style::IsSimilar(const Style& s)
{
- return
- font.color.r == s.font.color.r
- && font.color.g == s.font.color.g
- && font.color.b == s.font.color.b
- && font.color.a == s.font.color.a
- && background.color.r == s.background.color.r
- && background.color.g == s.background.color.g
- && background.color.b == s.background.color.b
- && background.color.a == s.background.color.a
- && background.size == s.background.size
- && background.type == s.background.type
- && background.blur == s.background.blur
- && shadow.color.r == s.shadow.color.r
- && shadow.color.g == s.shadow.color.g
- && shadow.color.b == s.shadow.color.b
- && shadow.color.a == s.shadow.color.a
- && shadow.depth == s.shadow.depth
- && shadow.angle == s.shadow.angle
- && shadow.blur == s.shadow.blur
- && fill.id == s.fill.id;
+ return
+ font.color.r == s.font.color.r
+ && font.color.g == s.font.color.g
+ && font.color.b == s.font.color.b
+ && font.color.a == s.font.color.a
+ && background.color.r == s.background.color.r
+ && background.color.g == s.background.color.g
+ && background.color.b == s.background.color.b
+ && background.color.a == s.background.color.a
+ && background.size == s.background.size
+ && background.type == s.background.type
+ && background.blur == s.background.blur
+ && shadow.color.r == s.shadow.color.r
+ && shadow.color.g == s.shadow.color.g
+ && shadow.color.b == s.shadow.color.b
+ && shadow.color.a == s.shadow.color.a
+ && shadow.depth == s.shadow.depth
+ && shadow.angle == s.shadow.angle
+ && shadow.blur == s.shadow.blur
+ && fill.id == s.fill.id;
}
}
diff --git a/src/Subtitles/libssf/Subtitle.h b/src/Subtitles/libssf/Subtitle.h
index 840647712..3f97a4d6f 100644
--- a/src/Subtitles/libssf/Subtitle.h
+++ b/src/Subtitles/libssf/Subtitle.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -25,43 +25,77 @@
namespace ssf
{
- struct Point {float x, y;};
- struct PointAuto : public Point {bool auto_x, auto_y;};
- struct Size {float cx, cy;};
- struct Rect {float t, r, b, l;};
- struct Align {float v, h;};
- struct Angle {float x, y, z;};
- struct Color {float a, r, g, b; operator DWORD(); };
- struct Frame {CStringW reference; Size resolution;};
- struct Direction {CStringW primary, secondary;};
- struct Time {float start, stop;};
- struct Background {Color color; float size, blur; CStringW type;};
- struct Shadow {Color color; float depth, angle, blur;};
+ struct Point {
+ float x, y;
+ };
+ struct PointAuto : public Point {
+ bool auto_x, auto_y;
+ };
+ struct Size {
+ float cx, cy;
+ };
+ struct Rect {
+ float t, r, b, l;
+ };
+ struct Align {
+ float v, h;
+ };
+ struct Angle {
+ float x, y, z;
+ };
+ struct Color {
+ float a, r, g, b;
+ operator DWORD();
+ };
+ struct Frame {
+ CStringW reference;
+ Size resolution;
+ };
+ struct Direction {
+ CStringW primary, secondary;
+ };
+ struct Time {
+ float start, stop;
+ };
+ struct Background {
+ Color color;
+ float size, blur;
+ CStringW type;
+ };
+ struct Shadow {
+ Color color;
+ float depth, angle, blur;
+ };
class Path : public CAtlArray<Point>
{
- public:
- Path() {}
- Path(const Path& path) {*this = path;}
- Path& operator = (const Path& path) {Copy(path); return *this;}
- Path(LPCWSTR str) {*this = str;}
+ public:
+ Path() {}
+ Path(const Path& path) {
+ *this = path;
+ }
+ Path& operator = (const Path& path) {
+ Copy(path);
+ return *this;
+ }
+ Path(LPCWSTR str) {
+ *this = str;
+ }
Path& operator = (LPCWSTR str);
CStringW ToString();
};
- struct Placement
- {
- Rect clip, margin;
- Align align;
- PointAuto pos;
+ struct Placement {
+ Rect clip, margin;
+ Align align;
+ PointAuto pos;
Point offset;
- Angle angle;
+ Angle angle;
PointAuto org;
Path path;
};
- struct Font
- {
+ struct Font {
CStringW face;
float size, weight;
Color color;
@@ -71,8 +105,7 @@ namespace ssf
bool kerning;
};
- struct Fill
- {
+ struct Fill {
static unsigned int gen_id;
int id;
Color color;
@@ -80,8 +113,7 @@ namespace ssf
struct Fill() : id(0) {}
};
- struct Style
- {
+ struct Style {
CStringW linebreak;
Placement placement;
Font font;
@@ -92,8 +124,7 @@ namespace ssf
bool IsSimilar(const Style& s);
};
- struct Text
- {
+ struct Text {
enum {SP = 0x20, NBSP = 0xa0, LSEP = 0x0a};
Style style;
CStringW str;
@@ -101,7 +132,9 @@ namespace ssf
class Subtitle
{
- static struct n2n_t {StringMapW<float> align[2], weight, transition;} m_n2n;
+ static struct n2n_t {
+ StringMapW<float> align[2], weight, transition;
+ } m_n2n;
File* m_pFile;
diff --git a/src/Subtitles/libssf/SubtitleFile.cpp b/src/Subtitles/libssf/SubtitleFile.cpp
index 41e86a816..35c5e3ed6 100644
--- a/src/Subtitles/libssf/SubtitleFile.cpp
+++ b/src/Subtitles/libssf/SubtitleFile.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -42,25 +42,20 @@ namespace ssf
CAtlList<Definition*> defs;
GetRootRef()->GetChildDefs(defs, L"subtitle");
-
+
StringMapW<float> offset;
POSITION pos = defs.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
Definition* pDef = defs.GetNext(pos);
- try
- {
+ try {
Definition::Time time;
- if(pDef->GetAsTime(time, offset) && (*pDef)[L"@"].IsValue())
- {
+ if(pDef->GetAsTime(time, offset) && (*pDef)[L"@"].IsValue()) {
m_segments.Insert(time.start.value, time.stop.value, pDef);
}
- }
- catch(Exception&)
- {
+ } catch(Exception&) {
}
}
}
@@ -75,26 +70,21 @@ namespace ssf
GetNewDefs(defs);
POSITION pos = defs.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
Definition* pDef = defs.GetNext(pos);
- if(pDef->m_parent == pRootRef && pDef->m_type == L"subtitle" && (*pDef)[L"@"].IsValue())
- {
+ if(pDef->m_parent == pRootRef && pDef->m_type == L"subtitle" && (*pDef)[L"@"].IsValue()) {
m_segments.Insert(start, stop, pDef);
- if(fSetTime)
- {
- try
- {
+ if(fSetTime) {
+ try {
Definition::Time time;
StringMapW<float> offset;
pDef->GetAsTime(time, offset);
- if(time.start.value == start && time.stop.value == stop)
+ if(time.start.value == start && time.stop.value == stop) {
continue;
- }
- catch(Exception&)
- {
+ }
+ } catch(Exception&) {
}
CStringW str;
@@ -111,31 +101,29 @@ namespace ssf
bool SubtitleFile::Lookup(float at, CAutoPtrList<Subtitle>& subs)
{
- if(!subs.IsEmpty()) {ASSERT(0); return false;}
+ if(!subs.IsEmpty()) {
+ ASSERT(0);
+ return false;
+ }
CAtlList<SegmentItem> sis;
m_segments.Lookup(at, sis);
POSITION pos = sis.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
SegmentItem& si = sis.GetNext(pos);
CAutoPtr<Subtitle> s(DNew Subtitle(this));
- if(s->Parse(si.pDef, si.start, si.stop, at))
- {
- for(POSITION pos = subs.GetHeadPosition(); pos; subs.GetNext(pos))
- {
- if(s->m_layer < subs.GetAt(pos)->m_layer)
- {
+ if(s->Parse(si.pDef, si.start, si.stop, at)) {
+ for(POSITION pos = subs.GetHeadPosition(); pos; subs.GetNext(pos)) {
+ if(s->m_layer < subs.GetAt(pos)->m_layer) {
subs.InsertBefore(pos, s);
break;
}
}
- if(s)
- {
+ if(s) {
subs.AddTail(s);
}
}
@@ -150,7 +138,9 @@ namespace ssf
{
m_start = start;
m_stop = stop;
- if(si) AddTail(*si);
+ if(si) {
+ AddTail(*si);
+ }
}
SubtitleFile::Segment::Segment(const Segment& s)
@@ -160,11 +150,10 @@ namespace ssf
SubtitleFile::Segment& SubtitleFile::Segment::operator = (const Segment& s)
{
- if(this != &s)
- {
- m_start = s.m_start;
- m_stop = s.m_stop;
- RemoveAll();
+ if(this != &s) {
+ m_start = s.m_start;
+ m_stop = s.m_stop;
+ RemoveAll();
AddTailList(&s);
}
return *this;
@@ -180,67 +169,63 @@ namespace ssf
void SubtitleFile::SegmentList::Insert(float start, float stop, Definition* pDef)
{
- if(start >= stop) {ASSERT(0); return;}
+ if(start >= stop) {
+ ASSERT(0);
+ return;
+ }
m_index.RemoveAll();
SegmentItem si = {pDef, start, stop};
- if(IsEmpty())
- {
+ if(IsEmpty()) {
AddTail(Segment(start, stop, &si));
return;
}
-
+
Segment& head = GetHead();
Segment& tail = GetTail();
-
- if(start >= tail.m_stop && stop > tail.m_stop)
- {
- if(start > tail.m_stop) AddTail(Segment(tail.m_stop, start));
+
+ if(start >= tail.m_stop && stop > tail.m_stop) {
+ if(start > tail.m_stop) {
+ AddTail(Segment(tail.m_stop, start));
+ }
AddTail(Segment(start, stop, &si));
- }
- else if(start < head.m_start && stop <= head.m_start)
- {
- if(stop < head.m_start) AddHead(Segment(stop, head.m_start));
+ } else if(start < head.m_start && stop <= head.m_start) {
+ if(stop < head.m_start) {
+ AddHead(Segment(stop, head.m_start));
+ }
AddHead(Segment(start, stop, &si));
- }
- else
- {
- if(start < head.m_start)
- {
+ } else {
+ if(start < head.m_start) {
AddHead(Segment(start, head.m_start, &si));
start = head.m_start;
}
- if(stop > tail.m_stop)
- {
+ if(stop > tail.m_stop) {
AddTail(Segment(tail.m_stop, stop, &si));
stop = tail.m_stop;
}
- for(POSITION pos = GetHeadPosition(); pos; GetNext(pos))
- {
+ for(POSITION pos = GetHeadPosition(); pos; GetNext(pos)) {
Segment& s = GetAt(pos);
- if(start >= s.m_stop) continue;
- if(stop <= s.m_start) break;
+ if(start >= s.m_stop) {
+ continue;
+ }
+ if(stop <= s.m_start) {
+ break;
+ }
- if(s.m_start < start && start < s.m_stop)
- {
+ if(s.m_start < start && start < s.m_stop) {
Segment s2 = s;
s2.m_start = start;
InsertAfter(pos, s2);
s.m_stop = start;
- }
- else if(s.m_start == start)
- {
- if(stop > s.m_stop)
- {
+ } else if(s.m_start == start) {
+ if(stop > s.m_stop) {
start = s.m_stop;
- }
- else if(stop < s.m_stop)
- {
+ } else if(stop < s.m_stop) {
Segment s2 = s;
s2.m_start = stop;
InsertAfter(pos, s2);
@@ -255,11 +240,12 @@ namespace ssf
size_t SubtitleFile::SegmentList::Index(bool fForce)
{
- if(m_index.IsEmpty() || fForce)
- {
+ if(m_index.IsEmpty() || fForce) {
m_index.RemoveAll();
POSITION pos = GetHeadPosition();
- while(pos) m_index.Add(&GetNext(pos));
+ while(pos) {
+ m_index.Add(&GetNext(pos));
+ }
}
return m_index.GetCount();
@@ -270,27 +256,36 @@ namespace ssf
sis.RemoveAll();
size_t k;
- if(Lookup(at, k))
- {
+ if(Lookup(at, k)) {
sis.AddTailList(GetSegment(k));
}
}
bool SubtitleFile::SegmentList::Lookup(float at, size_t& k)
{
- if(!Index()) return false;
+ if(!Index()) {
+ return false;
+ }
size_t i = 0, j = m_index.GetCount()-1;
if(m_index[i]->m_start <= at && at < m_index[j]->m_stop)
- do
- {
- k = (i+j)/2;
- if(m_index[k]->m_start <= at && at < m_index[k]->m_stop) {return true;}
- else if(at < m_index[k]->m_start) {if(j == k) k--; j = k;}
- else if(at >= m_index[k]->m_stop) {if(i == k) k++; i = k;}
- }
- while(i <= j);
+ do {
+ k = (i+j)/2;
+ if(m_index[k]->m_start <= at && at < m_index[k]->m_stop) {
+ return true;
+ } else if(at < m_index[k]->m_start) {
+ if(j == k) {
+ k--;
+ }
+ j = k;
+ } else if(at >= m_index[k]->m_stop) {
+ if(i == k) {
+ k++;
+ }
+ i = k;
+ }
+ } while(i <= j);
return false;
}
@@ -302,10 +297,10 @@ namespace ssf
// TODO: this should be overridable from outside
- LPCWSTR SubtitleFile::s_predef =
+ LPCWSTR SubtitleFile::s_predef =
L"color#white {a: 255; r: 255; g: 255; b: 255;}; \n"
L"color#black {a: 255; r: 0; g: 0; b: 0;}; \n"
- L"color#gray {a: 255; r: 128; g: 128; b: 128;}; \n"
+ L"color#gray {a: 255; r: 128; g: 128; b: 128;}; \n"
L"color#red {a: 255; r: 255; g: 0; b: 0;}; \n"
L"color#green {a: 255; r: 0; g: 255; b: 0;}; \n"
L"color#blue {a: 255; r: 0; g: 0; b: 255;}; \n"
@@ -354,7 +349,7 @@ namespace ssf
L" style \n"
L" { \n"
L" linebreak: \"word\"; \n"
- L" \n"
+ L" \n"
L" placement \n"
L" { \n"
L" clip: \"none\"; \n"
diff --git a/src/Subtitles/libssf/SubtitleFile.h b/src/Subtitles/libssf/SubtitleFile.h
index 964141fe2..9fa5b9856 100644
--- a/src/Subtitles/libssf/SubtitleFile.h
+++ b/src/Subtitles/libssf/SubtitleFile.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -31,8 +31,7 @@ namespace ssf
static LPCWSTR s_predef;
public:
- struct SegmentItem
- {
+ struct SegmentItem {
Definition* pDef;
float start, stop;
};
@@ -40,14 +39,14 @@ namespace ssf
class Segment : public CAtlList<SegmentItem>
{
public:
- float m_start, m_stop;
+ float m_start, m_stop;
Segment() {}
Segment(float start, float stop, const SegmentItem* si = NULL);
Segment(const Segment& s);
Segment& operator = (const Segment& s);
};
- class SegmentList : public CAtlList<Segment>
+ class SegmentList : public CAtlList<Segment>
{
CAtlArray<Segment*> m_index;
size_t Index(bool fForce = false);
diff --git a/src/Subtitles/libssf/stdafx.cpp b/src/Subtitles/libssf/stdafx.cpp
index 13934d005..bea3f980a 100644
--- a/src/Subtitles/libssf/stdafx.cpp
+++ b/src/Subtitles/libssf/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/Subtitles/libssf/stdafx.h b/src/Subtitles/libssf/stdafx.h
index 5860671e6..40d219e40 100644
--- a/src/Subtitles/libssf/stdafx.h
+++ b/src/Subtitles/libssf/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -25,7 +25,7 @@
#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later.
#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows.
-#endif
+#endif
#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later.
#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
diff --git a/src/apps/MPCTestAPI/MPCTestAPI.cpp b/src/apps/MPCTestAPI/MPCTestAPI.cpp
index 3887155d2..5a99a25de 100644
--- a/src/apps/MPCTestAPI/MPCTestAPI.cpp
+++ b/src/apps/MPCTestAPI/MPCTestAPI.cpp
@@ -58,13 +58,10 @@ BOOL CRegisterCopyDataApp::InitInstance()
CRegisterCopyDataDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
- if (nResponse == IDOK)
- {
+ if (nResponse == IDOK) {
// TODO: Place code here to handle when the dialog is
// dismissed with OK
- }
- else if (nResponse == IDCANCEL)
- {
+ } else if (nResponse == IDCANCEL) {
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
diff --git a/src/apps/MPCTestAPI/MPCTestAPI.h b/src/apps/MPCTestAPI/MPCTestAPI.h
index 11e90ae6e..75c7c7651 100644
--- a/src/apps/MPCTestAPI/MPCTestAPI.h
+++ b/src/apps/MPCTestAPI/MPCTestAPI.h
@@ -18,14 +18,14 @@ class CRegisterCopyDataApp : public CWinApp
public:
CRegisterCopyDataApp();
-// Overrides
+ // Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CRegisterCopyDataApp)
public:
virtual BOOL InitInstance();
//}}AFX_VIRTUAL
-// Implementation
+ // Implementation
//{{AFX_MSG(CRegisterCopyDataApp)
// NOTE - the ClassWizard will add and remove member functions here.
diff --git a/src/apps/MPCTestAPI/MPCTestAPIDlg.cpp b/src/apps/MPCTestAPI/MPCTestAPIDlg.cpp
index 81fa51d86..5ecf1eb76 100644
--- a/src/apps/MPCTestAPI/MPCTestAPIDlg.cpp
+++ b/src/apps/MPCTestAPI/MPCTestAPIDlg.cpp
@@ -15,24 +15,23 @@ static char THIS_FILE[] = __FILE__;
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");
}
}
@@ -44,7 +43,7 @@ class CAboutDlg : public CDialog
public:
CAboutDlg();
-// Dialog Data
+ // Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
@@ -55,7 +54,7 @@ protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
-// Implementation
+ // Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
@@ -135,12 +134,10 @@ BOOL CRegisterCopyDataDlg::OnInitDialog()
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
- if (pSysMenu != NULL)
- {
+ if (pSysMenu != NULL) {
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
- if (!strAboutMenu.IsEmpty())
- {
+ if (!strAboutMenu.IsEmpty()) {
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
@@ -152,19 +149,19 @@ BOOL CRegisterCopyDataDlg::OnInitDialog()
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
- #if (_MSC_VER == 1600)
- #if defined (_DEBUG)
- m_strMPCPath = _T("..\\..\\..\\..\\..\\bin10\\mpc-hc_x86_Debug\\mpc-hc.exe");
- #else
- m_strMPCPath = _T("..\\..\\..\\..\\..\\bin10\\mpc-hc_x86\\mpc-hc.exe");
- #endif
- #elif (_MSC_VER < 1600)
- #if defined (_DEBUG)
- m_strMPCPath = _T("..\\..\\..\\..\\..\\bin\\mpc-hc_x86_Debug\\mpc-hc.exe");
- #else
- m_strMPCPath = _T("..\\..\\..\\..\\..\\bin\\mpc-hc_x86\\mpc-hc.exe");
- #endif
- #endif
+#if (_MSC_VER == 1600)
+#if defined (_DEBUG)
+ m_strMPCPath = _T("..\\..\\..\\..\\..\\bin10\\mpc-hc_x86_Debug\\mpc-hc.exe");
+#else
+ m_strMPCPath = _T("..\\..\\..\\..\\..\\bin10\\mpc-hc_x86\\mpc-hc.exe");
+#endif
+#elif (_MSC_VER < 1600)
+#if defined (_DEBUG)
+ m_strMPCPath = _T("..\\..\\..\\..\\..\\bin\\mpc-hc_x86_Debug\\mpc-hc.exe");
+#else
+ m_strMPCPath = _T("..\\..\\..\\..\\..\\bin\\mpc-hc_x86\\mpc-hc.exe");
+#endif
+#endif
UpdateData(FALSE);
@@ -173,13 +170,10 @@ BOOL CRegisterCopyDataDlg::OnInitDialog()
void CRegisterCopyDataDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
- if ((nID & 0xFFF0) == IDM_ABOUTBOX)
- {
+ if ((nID & 0xFFF0) == IDM_ABOUTBOX) {
CAboutDlg dlgAbout;
dlgAbout.DoModal();
- }
- else
- {
+ } else {
CDialog::OnSysCommand(nID, lParam);
}
}
@@ -190,8 +184,7 @@ void CRegisterCopyDataDlg::OnSysCommand(UINT nID, LPARAM lParam)
void CRegisterCopyDataDlg::OnPaint()
{
- if (IsIconic())
- {
+ if (IsIconic()) {
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
@@ -206,9 +199,7 @@ void CRegisterCopyDataDlg::OnPaint()
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
- }
- else
- {
+ } else {
CDialog::OnPaint();
}
}
@@ -238,8 +229,7 @@ void CRegisterCopyDataDlg::OnButtonFindwindow()
}
-struct MyStruct
-{
+struct MyStruct {
int nNum;
TCHAR szData[256];
@@ -247,8 +237,7 @@ struct MyStruct
void CRegisterCopyDataDlg::Senddata(MPCAPI_COMMAND nCmd, LPCTSTR strCommand)
{
- if (m_hWndMPC)
- {
+ if (m_hWndMPC) {
COPYDATASTRUCT MyCDS;
MyCDS.dwData = nCmd;
@@ -264,8 +253,9 @@ BOOL CRegisterCopyDataDlg::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruc
CString strMsg;
MyStruct *tcsBuff=(MyStruct*)(pCopyDataStruct->lpData);
- if (pCopyDataStruct->dwData == CMD_CONNECT)
+ 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_lbLog.InsertString (0, strMsg);
@@ -279,76 +269,75 @@ 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;
+ 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/apps/MPCTestAPI/MPCTestAPIDlg.h b/src/apps/MPCTestAPI/MPCTestAPIDlg.h
index d3f86f147..bb362241b 100644
--- a/src/apps/MPCTestAPI/MPCTestAPIDlg.h
+++ b/src/apps/MPCTestAPI/MPCTestAPIDlg.h
@@ -14,12 +14,12 @@
class CRegisterCopyDataDlg : public CDialog
{
-// Construction
+ // Construction
public:
HWND m_RemoteWindow;
CRegisterCopyDataDlg(CWnd* pParent = NULL); // standard constructor
-// Dialog Data
+ // Dialog Data
//{{AFX_DATA(CRegisterCopyDataDlg)
enum { IDD = IDD_REGISTERCOPYDATA_DIALOG };
// NOTE: the ClassWizard will add data members here
@@ -31,7 +31,7 @@ protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
-// Implementation
+ // Implementation
protected:
HICON m_hIcon;
HWND m_hWndMPC;
diff --git a/src/apps/SubResync/SubResync.cpp b/src/apps/SubResync/SubResync.cpp
index 42c354938..c25c7743a 100644
--- a/src/apps/SubResync/SubResync.cpp
+++ b/src/apps/SubResync/SubResync.cpp
@@ -67,13 +67,10 @@ BOOL CSubresyncApp::InitInstance()
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();
- if (nResponse == IDOK)
- {
+ if (nResponse == IDOK) {
// TODO: Place code here to handle when the dialog is
// dismissed with OK
- }
- else if (nResponse == IDCANCEL)
- {
+ } else if (nResponse == IDCANCEL) {
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
diff --git a/src/apps/SubResync/SubResync.h b/src/apps/SubResync/SubResync.h
index a65478338..00ab35209 100644
--- a/src/apps/SubResync/SubResync.h
+++ b/src/apps/SubResync/SubResync.h
@@ -38,12 +38,12 @@ class CSubresyncApp : public CWinApp
public:
CSubresyncApp();
-// Overrides
+ // Overrides
public:
virtual BOOL InitInstance();
virtual int ExitInstance();
-// Implementation
+ // Implementation
DECLARE_MESSAGE_MAP()
};
diff --git a/src/apps/SubResync/SubResyncDlg.cpp b/src/apps/SubResync/SubResyncDlg.cpp
index 46c21f6dd..b47a3c52b 100644
--- a/src/apps/SubResync/SubResyncDlg.cpp
+++ b/src/apps/SubResync/SubResyncDlg.cpp
@@ -31,13 +31,13 @@ class CAboutDlg : public CDialog
public:
CAboutDlg();
-// Dialog Data
+ // Dialog Data
enum { IDD = IDD_ABOUTBOX };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
-// Implementation
+ // Implementation
protected:
DECLARE_MESSAGE_MAP()
};
@@ -92,12 +92,10 @@ BOOL CSubresyncDlg::OnInitDialog()
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
- if (pSysMenu != NULL)
- {
+ if (pSysMenu != NULL) {
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
- if (!strAboutMenu.IsEmpty())
- {
+ if (!strAboutMenu.IsEmpty()) {
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
@@ -115,13 +113,10 @@ BOOL CSubresyncDlg::OnInitDialog()
void CSubresyncDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
- if ((nID & 0xFFF0) == IDM_ABOUTBOX)
- {
+ if ((nID & 0xFFF0) == IDM_ABOUTBOX) {
CAboutDlg dlgAbout;
dlgAbout.DoModal();
- }
- else
- {
+ } else {
CDialog::OnSysCommand(nID, lParam);
}
}
@@ -132,8 +127,7 @@ void CSubresyncDlg::OnSysCommand(UINT nID, LPARAM lParam)
void CSubresyncDlg::OnPaint()
{
- if (IsIconic())
- {
+ if (IsIconic()) {
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
@@ -148,9 +142,7 @@ void CSubresyncDlg::OnPaint()
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
- }
- else
- {
+ } else {
CDialog::OnPaint();
}
}
diff --git a/src/apps/SubResync/SubResyncDlg.h b/src/apps/SubResync/SubResyncDlg.h
index 1dea143a6..eea377fea 100644
--- a/src/apps/SubResync/SubResyncDlg.h
+++ b/src/apps/SubResync/SubResyncDlg.h
@@ -61,7 +61,7 @@ public:
// CSubresyncDlg dialog
class CSubresyncDlg : public CDialog
{
-// Construction
+ // Construction
public:
CSubresyncDlg(CWnd* pParent = NULL); // standard constructor
virtual ~CSubresyncDlg();
@@ -69,7 +69,7 @@ public:
bool Open(CString fn, int CharSet = DEFAULT_CHARSET, bool fAppend = false, int timeoff = 0);
bool Save(CString fn, exttype et, CTextFile::enc e, bool fClearImgLetterDb = false, bool fOcrDll = false);
-// Dialog Data
+ // Dialog Data
enum { IDD = IDD_SUBRESYNC_DIALOG };
CListCtrl m_list;
CButton m_saveasbtn;
@@ -86,7 +86,7 @@ protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
-// Implementation
+ // Implementation
protected:
HICON m_hIcon;
diff --git a/src/apps/VSConv/VSConv.cpp b/src/apps/VSConv/VSConv.cpp
index 0d69ae918..fc5dfda2a 100644
--- a/src/apps/VSConv/VSConv.cpp
+++ b/src/apps/VSConv/VSConv.cpp
@@ -61,7 +61,7 @@ BOOL CvsconvApp::InitInstance()
AfxEnableControlContainer();
// TODO
-// if(__argc > 1)
+ // if(__argc > 1)
{
CString in, out;
CVobSubFile::SubFormat sf = CVobSubFile::None;
@@ -69,88 +69,79 @@ BOOL CvsconvApp::InitInstance()
bool fIgnoreForcedOnly = false;
bool fForcedOnly = false;
- try
- {
- for(int i = 1; i < __argc; i++)
- {
- if(__targv[i][0] == '-' || __targv[i][0] == '/')
- {
+ try {
+ for(int i = 1; i < __argc; i++) {
+ if(__targv[i][0] == '-' || __targv[i][0] == '/') {
CString sw(&__targv[i][1]);
- if(sw == _T("f"))
- {
- if(++i < __argc && __targv[i][0] != '-' && __targv[i][0] != '/')
- {
+ if(sw == _T("f")) {
+ if(++i < __argc && __targv[i][0] != '-' && __targv[i][0] != '/') {
CString fmt = CString(__targv[i]).MakeLower();
- if(fmt == _T("winsubmux"))
+ if(fmt == _T("winsubmux")) {
sf = CVobSubFile::WinSubMux;
- else if(fmt == _T("scenarist"))
+ } else if(fmt == _T("scenarist")) {
sf = CVobSubFile::Scenarist;
- else if(fmt == _T("maestro"))
+ } else if(fmt == _T("maestro")) {
sf = CVobSubFile::Maestro;
- else
+ } else {
throw _T("Unrecognized conversion format");
- }
- else
+ }
+ } else {
throw _T("No conversion format given");
- }
- else if(sw == _T("i"))
- {
- if(++i < __argc && __targv[i][0] != '-' && __targv[i][0] != '/')
+ }
+ } else if(sw == _T("i")) {
+ if(++i < __argc && __targv[i][0] != '-' && __targv[i][0] != '/') {
in = __targv[i];
- else
+ } else {
throw _T("Missing input file");
- }
- else if(sw == _T("o"))
- {
- if(++i < __argc && __targv[i][0] != '-' && __targv[i][0] != '/')
+ }
+ } else if(sw == _T("o")) {
+ if(++i < __argc && __targv[i][0] != '-' && __targv[i][0] != '/') {
out = __targv[i];
- else
+ } else {
throw _T("Missing output file");
- }
- else if(sw == _T("id"))
- {
- if(++i < __argc && __targv[i][0] != '-' && __targv[i][0] != '/')
+ }
+ } else if(sw == _T("id")) {
+ if(++i < __argc && __targv[i][0] != '-' && __targv[i][0] != '/') {
iLang = _tcstol(__targv[i], NULL, 10);
- else
+ } else {
throw _T("Missing stream id");
- }
- else if(sw == _T("ignoreforcedonly"))
- {
+ }
+ } else if(sw == _T("ignoreforcedonly")) {
fIgnoreForcedOnly = true;
- }
- else if(sw == _T("forcedonly"))
- {
+ } else if(sw == _T("forcedonly")) {
fForcedOnly = true;
}
}
}
- if(!in.IsEmpty() && !out.IsEmpty() && sf != CVobSubFile::None)
- {
+ if(!in.IsEmpty() && !out.IsEmpty() && sf != CVobSubFile::None) {
CVobSubFile vsf(NULL);
- if(!vsf.Open(in))
+ if(!vsf.Open(in)) {
throw _T("Can't open input");
+ }
- if(iLang >= 0 && iLang < 32)
+ if(iLang >= 0 && iLang < 32) {
vsf.m_iLang = iLang;
+ }
- if(fForcedOnly)
+ if(fForcedOnly) {
vsf.m_fOnlyShowForcedSubs = true;
+ }
- if(fIgnoreForcedOnly)
+ if(fIgnoreForcedOnly) {
vsf.m_fOnlyShowForcedSubs = false;
+ }
- if(!vsf.Save(out, sf))
+ if(!vsf.Save(out, sf)) {
throw _T("Can't save output");
+ }
return FALSE;
}
- }
- catch(LPCTSTR msg)
- {
+ } catch(LPCTSTR msg) {
AfxMessageBox(CString(_T("Error: ")) + msg);
}
@@ -174,13 +165,10 @@ BOOL CvsconvApp::InitInstance()
CvsconvDlg dlg;
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();
- if (nResponse == IDOK)
- {
+ if (nResponse == IDOK) {
// TODO: Place code here to handle when the dialog is
// dismissed with OK
- }
- else if (nResponse == IDCANCEL)
- {
+ } else if (nResponse == IDCANCEL) {
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
diff --git a/src/apps/VSConv/VSConv.h b/src/apps/VSConv/VSConv.h
index ff07cdce8..f17780678 100644
--- a/src/apps/VSConv/VSConv.h
+++ b/src/apps/VSConv/VSConv.h
@@ -39,11 +39,11 @@ class CvsconvApp : public CWinApp
public:
CvsconvApp();
-// Overrides
+ // Overrides
public:
virtual BOOL InitInstance();
-// Implementation
+ // Implementation
DECLARE_MESSAGE_MAP()
};
diff --git a/src/apps/VSConv/VSConvDlg.cpp b/src/apps/VSConv/VSConvDlg.cpp
index 9cee2a72d..9d5033f72 100644
--- a/src/apps/VSConv/VSConvDlg.cpp
+++ b/src/apps/VSConv/VSConvDlg.cpp
@@ -32,13 +32,13 @@ class CAboutDlg : public CDialog
public:
CAboutDlg();
-// Dialog Data
+ // Dialog Data
enum { IDD = IDS_ABOUTBOX };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
-// Implementation
+ // Implementation
protected:
DECLARE_MESSAGE_MAP()
};
@@ -92,12 +92,10 @@ BOOL CvsconvDlg::OnInitDialog()
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
- if (pSysMenu != NULL)
- {
+ if (pSysMenu != NULL) {
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
- if (!strAboutMenu.IsEmpty())
- {
+ if (!strAboutMenu.IsEmpty()) {
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
@@ -115,13 +113,10 @@ BOOL CvsconvDlg::OnInitDialog()
void CvsconvDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
- if ((nID & 0xFFF0) == IDM_ABOUTBOX)
- {
+ if ((nID & 0xFFF0) == IDM_ABOUTBOX) {
CAboutDlg dlgAbout;
dlgAbout.DoModal();
- }
- else
- {
+ } else {
CDialog::OnSysCommand(nID, lParam);
}
}
@@ -132,8 +127,7 @@ void CvsconvDlg::OnSysCommand(UINT nID, LPARAM lParam)
void CvsconvDlg::OnPaint()
{
- if (IsIconic())
- {
+ if (IsIconic()) {
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
@@ -148,9 +142,7 @@ void CvsconvDlg::OnPaint()
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
- }
- else
- {
+ } else {
CDialog::OnPaint();
}
}
diff --git a/src/apps/VSConv/VSConvDlg.h b/src/apps/VSConv/VSConvDlg.h
index 72ffd0ba2..5fb18bdc8 100644
--- a/src/apps/VSConv/VSConvDlg.h
+++ b/src/apps/VSConv/VSConvDlg.h
@@ -27,18 +27,18 @@
// CvsconvDlg dialog
class CvsconvDlg : public CDialog
{
-// Construction
+ // Construction
public:
CvsconvDlg(CWnd* pParent = NULL); // standard constructor
-// Dialog Data
+ // Dialog Data
enum { IDD = IDD_VSCONV_DIALOG };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
-// Implementation
+ // Implementation
protected:
HICON m_hIcon;
diff --git a/src/apps/VSRip/VSRip.cpp b/src/apps/VSRip/VSRip.cpp
index 70a157683..af4c601f5 100644
--- a/src/apps/VSRip/VSRip.cpp
+++ b/src/apps/VSRip/VSRip.cpp
@@ -59,13 +59,10 @@ BOOL CVSRipApp::InitInstance()
CVSRipDlg dlg;
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();
- if (nResponse == IDOK)
- {
+ if (nResponse == IDOK) {
// TODO: Place code here to handle when the dialog is
// dismissed with OK
- }
- else if (nResponse == IDCANCEL)
- {
+ } else if (nResponse == IDCANCEL) {
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
diff --git a/src/apps/VSRip/VSRip.h b/src/apps/VSRip/VSRip.h
index 164ec920b..52321d160 100644
--- a/src/apps/VSRip/VSRip.h
+++ b/src/apps/VSRip/VSRip.h
@@ -35,11 +35,11 @@ class CVSRipApp : public CWinApp
public:
CVSRipApp();
-// Overrides
+ // Overrides
public:
virtual BOOL InitInstance();
-// Implementation
+ // Implementation
DECLARE_MESSAGE_MAP()
};
diff --git a/src/apps/VSRip/VSRipDlg.cpp b/src/apps/VSRip/VSRipDlg.cpp
index 8b2995f3c..ac78012df 100644
--- a/src/apps/VSRip/VSRipDlg.cpp
+++ b/src/apps/VSRip/VSRipDlg.cpp
@@ -56,14 +56,12 @@ void CVSRipDlg::ShowNext()
POSITION prev = m_dlgpos;
m_dlgpos = GetNext();
- if(prev && prev != m_dlgpos)
- {
+ if(prev && prev != m_dlgpos) {
m_dlgs.GetAt(prev)->OnNext();
m_dlgs.GetAt(prev)->ShowWindow(SW_HIDE);
}
- if(m_dlgpos)
- {
+ if(m_dlgpos) {
CVSRipPage* pDlg = m_dlgs.GetAt(m_dlgpos);
CRect dr;
m_dlgrect.GetClientRect(dr);
@@ -79,14 +77,12 @@ void CVSRipDlg::ShowPrev()
POSITION next = m_dlgpos;
m_dlgpos = GetPrev();
- if(next && next != m_dlgpos)
- {
+ if(next && next != m_dlgpos) {
m_dlgs.GetAt(next)->OnPrev();
m_dlgs.GetAt(next)->ShowWindow(SW_HIDE);
}
- if(m_dlgpos)
- {
+ if(m_dlgpos) {
CVSRipPage* pDlg = m_dlgs.GetAt(m_dlgpos);
CRect dr;
m_dlgrect.GetClientRect(dr);
@@ -100,18 +96,26 @@ void CVSRipDlg::ShowPrev()
POSITION CVSRipDlg::GetNext()
{
POSITION pos = m_dlgpos;
- if(pos && m_dlgs.GetAt(pos)->CanGoNext()) m_dlgs.GetNext(pos);
- else if(pos && !m_dlgs.GetAt(pos)->CanGoNext()) pos = NULL;
- else pos = m_dlgs.GetHeadPosition();
+ if(pos && m_dlgs.GetAt(pos)->CanGoNext()) {
+ m_dlgs.GetNext(pos);
+ } else if(pos && !m_dlgs.GetAt(pos)->CanGoNext()) {
+ pos = NULL;
+ } else {
+ pos = m_dlgs.GetHeadPosition();
+ }
return(pos);
}
POSITION CVSRipDlg::GetPrev()
{
POSITION pos = m_dlgpos;
- if(pos && m_dlgs.GetAt(pos)->CanGoPrev()) m_dlgs.GetPrev(pos);
- else if(pos && !m_dlgs.GetAt(pos)->CanGoPrev()) pos = NULL;
- else pos = m_dlgs.GetTailPosition();
+ if(pos && m_dlgs.GetAt(pos)->CanGoPrev()) {
+ m_dlgs.GetPrev(pos);
+ } else if(pos && !m_dlgs.GetAt(pos)->CanGoPrev()) {
+ pos = NULL;
+ } else {
+ pos = m_dlgs.GetTailPosition();
+ }
return(pos);
}
@@ -138,8 +142,7 @@ BOOL CVSRipDlg::OnInitDialog()
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
- if(CMenu* pSysMenu = GetSystemMenu(FALSE))
- {
+ if(CMenu* pSysMenu = GetSystemMenu(FALSE)) {
pSysMenu->RemoveMenu(SC_SIZE, MF_BYCOMMAND);
pSysMenu->RemoveMenu(SC_MAXIMIZE, MF_BYCOMMAND);
}
@@ -176,21 +179,17 @@ BOOL CVSRipDlg::OnInitDialog()
pPage->Create(CVSRipIndexingDlg::IDD, this);
m_dlgs.AddTail(pPage);
- if(__argc > 1)
- {
+ if(__argc > 1) {
m_pVSFRipper->SetCallBack((IVSFRipperCallback*)m_dlgs.GetTail());
- if(S_OK != m_pVSFRipper->LoadParamFile(CString(__targv[1])))
- {
+ if(S_OK != m_pVSFRipper->LoadParamFile(CString(__targv[1]))) {
AfxMessageBox(_T("Error parsing parameter file!"), MB_OK);
EndDialog(IDCANCEL);
return FALSE;
}
ShowPrev();
- }
- else
- {
+ } else {
ShowNext();
}
@@ -203,8 +202,7 @@ BOOL CVSRipDlg::OnInitDialog()
void CVSRipDlg::OnPaint()
{
- if (IsIconic())
- {
+ if (IsIconic()) {
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
@@ -219,9 +217,7 @@ void CVSRipDlg::OnPaint()
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
- }
- else
- {
+ } else {
CPaintDC dc(this); // device context for painting
CWnd* pHdrSep = GetDlgItem(IDC_HEADERSEP);
@@ -232,8 +228,7 @@ void CVSRipDlg::OnPaint()
GetClientRect(cr);
dc.FillSolidRect(CRect(0,0,cr.right,r.top), 0xffffff);
- if(m_dlgpos)
- {
+ if(m_dlgpos) {
CVSRipPage* pWnd = m_dlgs.GetAt(m_dlgpos);
CFont hdrfont, descfont;
hdrfont.CreateFont(16,0,0,0,FW_BOLD,0,0,0,DEFAULT_CHARSET,
@@ -257,10 +252,10 @@ void CVSRipDlg::OnKickIdle()
{
UpdateDialogControls(this, false);
- for(CWnd* pChild = GetWindow(GW_CHILD); pChild; pChild = pChild->GetNextWindow())
- {
- if(pChild->IsKindOf(RUNTIME_CLASS(CVSRipPage)))
+ for(CWnd* pChild = GetWindow(GW_CHILD); pChild; pChild = pChild->GetNextWindow()) {
+ if(pChild->IsKindOf(RUNTIME_CLASS(CVSRipPage))) {
pChild->UpdateDialogControls(pChild, false);
+ }
}
}
@@ -278,7 +273,9 @@ void CVSRipDlg::OnPrev()
void CVSRipDlg::OnUpdatePrev(CCmdUI* pCmdUI)
{
- if(m_dlgpos) pCmdUI->SetText(m_dlgs.GetAt(m_dlgpos)->GetPrevText());
+ if(m_dlgpos) {
+ pCmdUI->SetText(m_dlgs.GetAt(m_dlgpos)->GetPrevText());
+ }
pCmdUI->Enable(!!GetPrev());
}
@@ -289,19 +286,25 @@ void CVSRipDlg::OnNext()
void CVSRipDlg::OnUpdateNext(CCmdUI* pCmdUI)
{
- if(m_dlgpos) pCmdUI->SetText(m_dlgs.GetAt(m_dlgpos)->GetNextText());
+ if(m_dlgpos) {
+ pCmdUI->SetText(m_dlgs.GetAt(m_dlgpos)->GetNextText());
+ }
pCmdUI->Enable(!!GetNext());
}
void CVSRipDlg::OnClose()
{
- if(m_dlgpos) m_dlgs.GetAt(m_dlgpos)->OnClose();
+ if(m_dlgpos) {
+ m_dlgs.GetAt(m_dlgpos)->OnClose();
+ }
OnCancel();
}
void CVSRipDlg::OnUpdateClose(CCmdUI* pCmdUI)
{
- if(m_dlgpos) pCmdUI->SetText(m_dlgs.GetAt(m_dlgpos)->GetCloseText());
+ if(m_dlgpos) {
+ pCmdUI->SetText(m_dlgs.GetAt(m_dlgpos)->GetCloseText());
+ }
pCmdUI->Enable(!m_dlgpos || m_dlgs.GetAt(m_dlgpos)->CanClose());
}
diff --git a/src/apps/VSRip/VSRipDlg.h b/src/apps/VSRip/VSRipDlg.h
index b50a42dec..66bb84c4e 100644
--- a/src/apps/VSRip/VSRipDlg.h
+++ b/src/apps/VSRip/VSRipDlg.h
@@ -30,19 +30,19 @@
// CVSRipDlg dialog
class CVSRipDlg : public CDialog
{
-// Construction
+ // Construction
public:
CVSRipDlg(CWnd* pParent = NULL); // standard constructor
virtual ~CVSRipDlg();
-// Dialog Data
+ // Dialog Data
enum { IDD = IDD_VSRIP_DIALOG };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual BOOL OnInitDialog();
-// Implementation
+ // Implementation
protected:
HICON m_hIcon;
diff --git a/src/apps/VSRip/VSRipFileDlg.cpp b/src/apps/VSRip/VSRipFileDlg.cpp
index 7f4ad626e..a877f8c06 100644
--- a/src/apps/VSRip/VSRipFileDlg.cpp
+++ b/src/apps/VSRip/VSRipFileDlg.cpp
@@ -56,8 +56,7 @@ END_MESSAGE_MAP()
STDMETHODIMP CVSRipFileDlg::OnMessage(LPCTSTR msg)
{
- if(CEdit* pLog = (CEdit*)CEdit::FromHandle(m_log.m_hWnd))
- {
+ if(CEdit* pLog = (CEdit*)CEdit::FromHandle(m_log.m_hWnd)) {
CString str = msg;
str += _T("\r\n");
int len = pLog->GetWindowTextLength();
@@ -76,13 +75,14 @@ void CVSRipFileDlg::OnBnClickedButton1()
OFN_EXPLORER|OFN_ENABLESIZING|OFN_PATHMUSTEXIST,
_T("Video Title Set IFO file (*.ifo)|*.ifo|"), this, 0);
- if(fd.DoModal() == IDOK)
- {
+ if(fd.DoModal() == IDOK) {
m_log.SetWindowText(_T(""));
m_log.SetMargins(0, 0);
CString fn = fd.GetPathName();
- if(FAILED(m_pVSFRipper->SetInput(fn))) fn.Empty();
+ if(FAILED(m_pVSFRipper->SetInput(fn))) {
+ fn.Empty();
+ }
m_infn = fn;
UpdateData(FALSE);
@@ -94,16 +94,19 @@ void CVSRipFileDlg::OnBnClickedButton2()
{
CString fn = m_infn.Mid(m_infn.ReverseFind('\\')+1);
int i = fn.ReverseFind('.');
- if(i > 0) fn = fn.Left(i);
+ if(i > 0) {
+ fn = fn.Left(i);
+ }
CFileDialog fd(FALSE, NULL, fn,
OFN_EXPLORER|OFN_ENABLESIZING|OFN_OVERWRITEPROMPT|OFN_PATHMUSTEXIST,
_T("VobSub index file (*.idx)|*.idx|"), this, 0);
- if(fd.DoModal() == IDOK)
- {
+ if(fd.DoModal() == IDOK) {
CString fn = fd.GetPathName();
- if(FAILED(m_pVSFRipper->SetOutput(fn))) fn.Empty();
+ if(FAILED(m_pVSFRipper->SetOutput(fn))) {
+ fn.Empty();
+ }
m_outfn = fn;
UpdateData(FALSE);
diff --git a/src/apps/VSRip/VSRipFileDlg.h b/src/apps/VSRip/VSRipFileDlg.h
index 8c5108c1b..5e152c1bb 100644
--- a/src/apps/VSRip/VSRipFileDlg.h
+++ b/src/apps/VSRip/VSRipFileDlg.h
@@ -39,26 +39,22 @@ public:
CVSRipFileDlg(IVSFRipper* pVSFRipper, CWnd* pParent = NULL); // standard constructor
virtual ~CVSRipFileDlg();
- virtual bool CanGoPrev()
- {
+ virtual bool CanGoPrev() {
return(false);
}
- virtual bool CanGoNext()
- {
+ virtual bool CanGoNext() {
return(!m_infn.IsEmpty() && !m_outfn.IsEmpty());
}
- virtual CString GetHeaderText()
- {
+ virtual CString GetHeaderText() {
return(_T("Select input and output"));
}
- virtual CString GetDescText()
- {
+ virtual CString GetDescText() {
return(_T("First choose a video title set ifo, then select an ")
_T("output path for the idx/sub files. Make sure the vob files ")
_T("have some standard naming, this util can't read your mind."));
}
-// Dialog Data
+ // Dialog Data
enum { IDD = IDD_DIALOG_FILE };
CEdit m_log;
CString m_infn, m_outfn;
diff --git a/src/apps/VSRip/VSRipIndexingDlg.cpp b/src/apps/VSRip/VSRipIndexingDlg.cpp
index db0793489..6eb69c39a 100644
--- a/src/apps/VSRip/VSRipIndexingDlg.cpp
+++ b/src/apps/VSRip/VSRipIndexingDlg.cpp
@@ -52,8 +52,7 @@ void CVSRipIndexingDlg::DoDataExchange(CDataExchange* pDX)
STDMETHODIMP CVSRipIndexingDlg::OnMessage(LPCTSTR msg)
{
- if(CEdit* pLog = (CEdit*)CEdit::FromHandle(m_log.m_hWnd))
- {
+ if(CEdit* pLog = (CEdit*)CEdit::FromHandle(m_log.m_hWnd)) {
CString str = msg;
str += _T("\r\n");
int len = pLog->GetWindowTextLength();
@@ -66,8 +65,7 @@ STDMETHODIMP CVSRipIndexingDlg::OnMessage(LPCTSTR msg)
STDMETHODIMP CVSRipIndexingDlg::OnProgress(double progress)
{
- if(CProgressCtrl* pProgress = (CProgressCtrl*)CProgressCtrl::FromHandle(m_progress.m_hWnd))
- {
+ if(CProgressCtrl* pProgress = (CProgressCtrl*)CProgressCtrl::FromHandle(m_progress.m_hWnd)) {
pProgress->SetPos((int)(progress * 100));
}
@@ -80,14 +78,19 @@ STDMETHODIMP CVSRipIndexingDlg::OnFinished(bool fSucceeded)
GetParent()->PostMessage(WM_KICKIDLE); // and kick it hard :)
- if(m_fFinished && m_bBeep) MessageBeep(-1);
- if(m_fFinished && m_bExit) GetParent()->PostMessage(WM_COMMAND, IDCANCEL);
+ if(m_fFinished && m_bBeep) {
+ MessageBeep(-1);
+ }
+ if(m_fFinished && m_bExit) {
+ GetParent()->PostMessage(WM_COMMAND, IDCANCEL);
+ }
- if(!fSucceeded)
- {
+ if(!fSucceeded) {
VSFRipperData rd;
m_pVSFRipper->GetRipperData(rd);
- if(rd.fCloseIgnoreError) GetParent()->PostMessage(WM_COMMAND, IDCANCEL);
+ if(rd.fCloseIgnoreError) {
+ GetParent()->PostMessage(WM_COMMAND, IDCANCEL);
+ }
}
return S_OK;
@@ -106,12 +109,9 @@ END_MESSAGE_MAP()
void CVSRipIndexingDlg::OnIndex()
{
- if(S_OK == m_pVSFRipper->IsIndexing())
- {
+ if(S_OK == m_pVSFRipper->IsIndexing()) {
m_pVSFRipper->Abort(false);
- }
- else
- {
+ } else {
m_progress.SetRange(0, 100);
m_progress.SetPos(0);
m_log.SetWindowText(_T(""));
@@ -134,8 +134,7 @@ void CVSRipIndexingDlg::OnShowWindow(BOOL bShow, UINT nStatus)
m_fFinished = false;
- if(bShow)
- {
+ if(bShow) {
VSFRipperData rd;
m_pVSFRipper->GetRipperData(rd);
m_bBeep = rd.fBeep;
@@ -143,10 +142,8 @@ void CVSRipIndexingDlg::OnShowWindow(BOOL bShow, UINT nStatus)
m_fAuto = rd.fAuto;
UpdateData(FALSE);
- if(S_OK != m_pVSFRipper->IsIndexing())
- {
- if(!m_fAuto)
- {
+ if(S_OK != m_pVSFRipper->IsIndexing()) {
+ if(!m_fAuto) {
m_progress.SetRange(0, 100);
m_progress.SetPos(0);
m_log.SetWindowText(_T(""));
@@ -155,9 +152,7 @@ void CVSRipIndexingDlg::OnShowWindow(BOOL bShow, UINT nStatus)
m_pVSFRipper->Index();
}
- }
- else
- {
+ } else {
VSFRipperData rd;
m_pVSFRipper->GetRipperData(rd);
UpdateData();
diff --git a/src/apps/VSRip/VSRipIndexingDlg.h b/src/apps/VSRip/VSRipIndexingDlg.h
index 135139322..c3ef24052 100644
--- a/src/apps/VSRip/VSRipIndexingDlg.h
+++ b/src/apps/VSRip/VSRipIndexingDlg.h
@@ -44,28 +44,22 @@ public:
CVSRipIndexingDlg(IVSFRipper* pVSFRipper, CWnd* pParent = NULL); // standard constructor
virtual ~CVSRipIndexingDlg();
- virtual bool CanGoPrev()
- {
+ virtual bool CanGoPrev() {
return(S_OK != m_pVSFRipper->IsIndexing() && !m_fAuto);
}
- virtual bool CanGoNext()
- {
+ virtual bool CanGoNext() {
return(false);
}
- virtual bool CanClose()
- {
+ virtual bool CanClose() {
return(S_OK != m_pVSFRipper->IsIndexing());
}
- virtual CString GetCloseText()
- {
+ virtual CString GetCloseText() {
return(m_fFinished ? _T("&Close") : _T("&Cancel"));
}
- virtual CString GetHeaderText()
- {
+ virtual CString GetHeaderText() {
return(_T("Extracting subtitles"));
}
- virtual CString GetDescText()
- {
+ virtual CString GetDescText() {
return(_T("This may take a while, please sit back and relax... ")
_T("If you wish you can abort the process and go back to ")
_T("adjust the settings again."));
@@ -73,7 +67,7 @@ public:
bool m_fFinished;
-// Dialog Data
+ // Dialog Data
enum { IDD = IDD_DIALOG_INDEXING };
CEdit m_log;
diff --git a/src/apps/VSRip/VSRipPGCDlg.cpp b/src/apps/VSRip/VSRipPGCDlg.cpp
index 4c88161d5..d325cb5e5 100644
--- a/src/apps/VSRip/VSRipPGCDlg.cpp
+++ b/src/apps/VSRip/VSRipPGCDlg.cpp
@@ -68,22 +68,22 @@ void CVSRipPGCDlg::OnNext()
m_rd.iSelPGC = m_pgclist.GetCurSel();
m_rd.selids.RemoveAll();
- if(items.Allocate(m_langlist.GetSelCount()))
- {
+ if(items.Allocate(m_langlist.GetSelCount())) {
int j = m_langlist.GetSelItems(m_langlist.GetSelCount(), items);
- for(int i = 0; i < j; i++)
+ for(int i = 0; i < j; i++) {
m_rd.selids[(BYTE)m_langlist.GetItemData(items[i])] = true;
+ }
items.Free();
}
m_rd.pgcs[m_rd.iSelPGC].iSelAngle = m_anglelist.GetCurSel();
m_rd.selvcs.RemoveAll();
- if(items.Allocate(m_vclist.GetSelCount()))
- {
+ if(items.Allocate(m_vclist.GetSelCount())) {
int j = m_vclist.GetSelItems(m_vclist.GetSelCount(), items);
- for(int i = 0; i < j; i++)
+ for(int i = 0; i < j; i++) {
m_rd.selvcs.Add((DWORD)m_vclist.GetItemData(items[i]));
+ }
items.Free();
}
@@ -110,8 +110,7 @@ void CVSRipPGCDlg::SetupPGCList()
m_pgclist.ResetContent();
- for(int i = 0; i < (int)m_rd.pgcs.GetCount(); i++)
- {
+ for(int i = 0; i < (int)m_rd.pgcs.GetCount(); i++) {
CString str;
str.Format(_T("PGC %d"), i+1);
m_pgclist.AddString(str);
@@ -127,22 +126,16 @@ void CVSRipPGCDlg::SetupLangList()
{
m_langlist.ResetContent();
- for(BYTE i = 0; i < 32; i++)
- {
+ for(BYTE i = 0; i < 32; i++) {
WORD id = m_rd.pgcs[m_rd.iSelPGC].ids[i];
CString str;
- if(id == 0)
- {
+ if(id == 0) {
str.Format(_T("%02d (empty)"), (int)i);
- }
- else if(!isalpha(id>>8) || !isalpha(id&0xff))
- {
+ } else if(!isalpha(id>>8) || !isalpha(id&0xff)) {
str.Format(_T("%02d (unknown)"), (int)i);
- }
- else
- {
+ } else {
str.Format(_T("%02d %s (%c%c)"), (int)i, FindLangFromId(id), TCHAR(id>>8), TCHAR(id&0xff));
}
@@ -160,19 +153,16 @@ void CVSRipPGCDlg::SetupAngleList()
m_rd.pgcs[m_rd.iSelPGC].iSelAngle = m_rd.pgcs[m_rd.iSelPGC].nAngles > 0 ? 1 : 0;
- for(int i = 0; i < 10; i++)
- {
+ for(int i = 0; i < 10; i++) {
CString str;
- if(i == 0)
- {
+ if(i == 0) {
str = _T("Everything");
- }
- else
- {
+ } else {
str.Format(_T("Angle %d"), i);
- if(i > m_rd.pgcs[m_rd.iSelPGC].nAngles)
+ if(i > m_rd.pgcs[m_rd.iSelPGC].nAngles) {
str += _T(" (empty)");
+ }
}
m_anglelist.AddString(str);
@@ -189,8 +179,7 @@ void CVSRipPGCDlg::SetupVCList()
CAtlArray<vc_t>& vca =( m_rd.pgcs[m_rd.iSelPGC].angles[m_rd.pgcs[m_rd.iSelPGC].iSelAngle]);
- for(int i = 0; i < (int)vca.GetCount(); i++)
- {
+ for(int i = 0; i < (int)vca.GetCount(); i++) {
CString str;
str.Format(_T("V%02d C%02d"), vca[i].vob, vca[i].cell);
@@ -215,14 +204,18 @@ END_MESSAGE_MAP()
void CVSRipPGCDlg::OnLbnSelchangeList1()
{
- if(m_rd.iSelPGC == m_pgclist.GetCurSel()) return;
+ if(m_rd.iSelPGC == m_pgclist.GetCurSel()) {
+ return;
+ }
m_rd.iSelPGC = m_pgclist.GetCurSel();
SetupAngleList();
}
void CVSRipPGCDlg::OnLbnSelchangeList2()
{
- if(m_rd.pgcs[m_rd.iSelPGC].iSelAngle == m_anglelist.GetCurSel()) return;
+ if(m_rd.pgcs[m_rd.iSelPGC].iSelAngle == m_anglelist.GetCurSel()) {
+ return;
+ }
m_rd.pgcs[m_rd.iSelPGC].iSelAngle = m_anglelist.GetCurSel();
SetupVCList();
}
@@ -231,12 +224,13 @@ void CVSRipPGCDlg::OnShowWindow(BOOL bShow, UINT nStatus)
{
CVSRipPage::OnShowWindow(bShow, nStatus);
- if(!bShow) return;
+ if(!bShow) {
+ return;
+ }
m_pVSFRipper->GetRipperData(m_rd);
- if(m_rd.iSelPGC == -1)
- {
+ if(m_rd.iSelPGC == -1) {
m_rd.iSelPGC = 0;
SetupPGCList();
diff --git a/src/apps/VSRip/VSRipPGCDlg.h b/src/apps/VSRip/VSRipPGCDlg.h
index 2b993f81a..841005b50 100644
--- a/src/apps/VSRip/VSRipPGCDlg.h
+++ b/src/apps/VSRip/VSRipPGCDlg.h
@@ -45,23 +45,20 @@ public:
virtual void OnPrev();
virtual void OnNext();
- virtual bool CanGoPrev()
- {
+ virtual bool CanGoPrev() {
return(true);
}
virtual bool CanGoNext();
- virtual CString GetHeaderText()
- {
+ virtual CString GetHeaderText() {
return(_T("Extraction settings"));
}
- virtual CString GetDescText()
- {
+ virtual CString GetDescText() {
return(_T("Select the program chain and angle you did or ")
_T("will do in the dvd ripper. Optionally, remove any not ")
_T("needed language streams and vob/cell ids."));
}
-// Dialog Data
+ // Dialog Data
enum { IDD = IDD_DIALOG_PGC };
CListBox m_pgclist;
CListBox m_anglelist;
diff --git a/src/apps/VSRip/VSRipPage.h b/src/apps/VSRip/VSRipPage.h
index ace06838e..41db7d5dd 100644
--- a/src/apps/VSRip/VSRipPage.h
+++ b/src/apps/VSRip/VSRipPage.h
@@ -39,41 +39,33 @@ public:
CVSRipPage(IVSFRipper* pVSFRipper, UINT nIDTemplate, CWnd* pParent = NULL); // standard constructor
virtual ~CVSRipPage();
-// static bool ParseParamFile(CString fn);
+ // static bool ParseParamFile(CString fn);
virtual void OnPrev() {}
virtual void OnNext() {}
virtual void OnClose() {}
- virtual bool CanGoPrev()
- {
+ virtual bool CanGoPrev() {
return(false);
}
- virtual bool CanGoNext()
- {
+ virtual bool CanGoNext() {
return(false);
}
- virtual bool CanClose()
- {
+ virtual bool CanClose() {
return(true);
}
- virtual CString GetPrevText()
- {
+ virtual CString GetPrevText() {
return(_T("< &Back"));
}
- virtual CString GetNextText()
- {
+ virtual CString GetNextText() {
return(_T("&Next >"));
}
- virtual CString GetCloseText()
- {
+ virtual CString GetCloseText() {
return(_T("&Cancel"));
}
- virtual CString GetHeaderText()
- {
+ virtual CString GetHeaderText() {
return(_T("Header Text"));
}
- virtual CString GetDescText()
- {
+ virtual CString GetDescText() {
return(_T("Hello World"));
}
diff --git a/src/apps/asf2mkv/asf2mkv.cpp b/src/apps/asf2mkv/asf2mkv.cpp
index 1b19f3815..03ea4b023 100644
--- a/src/apps/asf2mkv/asf2mkv.cpp
+++ b/src/apps/asf2mkv/asf2mkv.cpp
@@ -67,8 +67,7 @@ BOOL Casf2mkvApp::InitInstance()
SetRegistryKey(_T("Gabest"));
HRESULT hr;
- if(FAILED(hr = OleInitialize(0)))
- {
+ if(FAILED(hr = OleInitialize(0))) {
AfxMessageBox(_T("OleInitialize failed!"));
return FALSE;
}
@@ -76,13 +75,10 @@ BOOL Casf2mkvApp::InitInstance()
Casf2mkvDlg dlg;
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();
- if (nResponse == IDOK)
- {
+ if (nResponse == IDOK) {
// TODO: Place code here to handle when the dialog is
// dismissed with OK
- }
- else if (nResponse == IDCANCEL)
- {
+ } else if (nResponse == IDCANCEL) {
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
diff --git a/src/apps/asf2mkv/asf2mkv.h b/src/apps/asf2mkv/asf2mkv.h
index e89d11be4..9ec4b0716 100644
--- a/src/apps/asf2mkv/asf2mkv.h
+++ b/src/apps/asf2mkv/asf2mkv.h
@@ -39,11 +39,11 @@ class Casf2mkvApp : public CWinApp
public:
Casf2mkvApp();
-// Overrides
+ // Overrides
public:
virtual BOOL InitInstance();
-// Implementation
+ // Implementation
DECLARE_MESSAGE_MAP()
virtual int ExitInstance();
diff --git a/src/apps/asf2mkv/asf2mkvDlg.cpp b/src/apps/asf2mkv/asf2mkvDlg.cpp
index 6f07076f2..246573fb3 100644
--- a/src/apps/asf2mkv/asf2mkvDlg.cpp
+++ b/src/apps/asf2mkv/asf2mkvDlg.cpp
@@ -41,13 +41,13 @@ class CAboutDlg : public CDialog
public:
CAboutDlg();
-// Dialog Data
+ // Dialog Data
enum { IDD = IDD_ABOUTBOX };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
-// Implementation
+ // Implementation
protected:
DECLARE_MESSAGE_MAP()
};
@@ -86,14 +86,11 @@ BOOL CUrlDropTarget::OnDrop(CWnd* pWnd, COleDataObject* pDataObject, DROPEFFECT
BOOL bResult = FALSE;
- if(pDataObject->IsDataAvailable(CF_URL))
- {
+ if(pDataObject->IsDataAvailable(CF_URL)) {
FORMATETC fmt = {CF_URL, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
- if(HGLOBAL hGlobal = pDataObject->GetGlobalData(CF_URL, &fmt))
- {
+ if(HGLOBAL hGlobal = pDataObject->GetGlobalData(CF_URL, &fmt)) {
LPCSTR pText = (LPCSTR)GlobalLock(hGlobal);
- if(AfxIsValidString(pText))
- {
+ if(AfxIsValidString(pText)) {
AfxGetMainWnd()->SendMessage(WM_OPENURL, 0, (LPARAM)pText);
GlobalUnlock(hGlobal);
bResult = TRUE;
@@ -134,8 +131,8 @@ Casf2mkvDlg::Casf2mkvDlg(CWnd* pParent /*=NULL*/)
osver.dwOSVersionInfoSize = sizeof( OSVERSIONINFO );
bIsVistaOrAbove = GetVersionEx( &osver ) &&
- osver.dwPlatformId == VER_PLATFORM_WIN32_NT &&
- (osver.dwMajorVersion >= 6 );
+ osver.dwPlatformId == VER_PLATFORM_WIN32_NT &&
+ (osver.dwMajorVersion >= 6 );
}
void Casf2mkvDlg::DoDataExchange(CDataExchange* pDX)
@@ -150,14 +147,14 @@ void Casf2mkvDlg::SetupCombo()
{
m_combo.ResetContent();
for(int i = 0; i < m_mru.GetSize(); i++)
- if(!m_mru[i].IsEmpty())
+ if(!m_mru[i].IsEmpty()) {
m_combo.AddString(m_mru[i]);
+ }
}
void Casf2mkvDlg::SetVideoRect()
{
- if(pVW)
- {
+ if(pVW) {
CRect r;
m_video.GetWindowRect(r);
r -= r.TopLeft();
@@ -195,12 +192,10 @@ BOOL Casf2mkvDlg::OnInitDialog()
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
- if (pSysMenu != NULL)
- {
+ if (pSysMenu != NULL) {
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
- if (!strAboutMenu.IsEmpty())
- {
+ if (!strAboutMenu.IsEmpty()) {
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
@@ -239,13 +234,10 @@ BOOL Casf2mkvDlg::DestroyWindow()
void Casf2mkvDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
- if ((nID & 0xFFF0) == IDM_ABOUTBOX)
- {
+ if ((nID & 0xFFF0) == IDM_ABOUTBOX) {
CAboutDlg dlgAbout;
dlgAbout.DoModal();
- }
- else
- {
+ } else {
__super::OnSysCommand(nID, lParam);
}
}
@@ -256,8 +248,7 @@ void Casf2mkvDlg::OnSysCommand(UINT nID, LPARAM lParam)
void Casf2mkvDlg::OnPaint()
{
- if (IsIconic())
- {
+ if (IsIconic()) {
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
@@ -272,9 +263,7 @@ void Casf2mkvDlg::OnPaint()
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
- }
- else
- {
+ } else {
__super::OnPaint();
}
}
@@ -292,14 +281,11 @@ LRESULT Casf2mkvDlg::OnGraphNotify(WPARAM wParam, LPARAM lParam)
HRESULT hr = S_OK;
LONG evCode, evParam1, evParam2;
- while(pME && SUCCEEDED(pME->GetEvent(&evCode, (LONG_PTR*)&evParam1, (LONG_PTR*)&evParam2, 0)))
- {
+ while(pME && SUCCEEDED(pME->GetEvent(&evCode, (LONG_PTR*)&evParam1, (LONG_PTR*)&evParam2, 0))) {
hr = pME->FreeEventParams(evCode, evParam1, evParam2);
- if(EC_COMPLETE == evCode)
- {
- if(m_fRecording)
- {
+ if(EC_COMPLETE == evCode) {
+ if(m_fRecording) {
OnRecord();
break;
}
@@ -315,16 +301,14 @@ void Casf2mkvDlg::OnRecord()
HRESULT hr;
- if(!m_fRecording)
- {
+ if(!m_fRecording) {
m_fRecording = true;
UpdateDialogControls(this, FALSE);
hr = E_FAIL;
- do
- {
+ do {
// i/o
CString src;
@@ -335,7 +319,9 @@ void Casf2mkvDlg::OnRecord()
OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_EXPLORER|OFN_ENABLESIZING,
_T("Matroska file (*.mkv;*.mka)|*.mkv;*.mka||"),
this);
- if(fd.DoModal() != IDOK) break;
+ if(fd.DoModal() != IDOK) {
+ break;
+ }
m_dst = fd.GetPathName();
m_mru.Add(src);
@@ -343,48 +329,56 @@ void Casf2mkvDlg::OnRecord()
SetupCombo();
m_combo.SetWindowText(src);
- if(src.Trim().IsEmpty() || m_dst.Trim().IsEmpty())
+ if(src.Trim().IsEmpty() || m_dst.Trim().IsEmpty()) {
break;
+ }
// filer graph
- if(FAILED(hr = pGB.CoCreateInstance(CLSID_FilterGraph)))
+ if(FAILED(hr = pGB.CoCreateInstance(CLSID_FilterGraph))) {
break;
+ }
pMC = pGB;
pME = pGB;
pMS = pGB;
pVW = pGB;
pBV = pGB;
- if(!pMC || !pME || !pMS || !pVW || !pBV)
+ if(!pMC || !pME || !pMS || !pVW || !pBV) {
break;
+ }
- if(FAILED(hr = pME->SetNotifyWindow((OAHWND)m_hWnd, WM_GRAPHNOTIFY, 0)))
+ if(FAILED(hr = pME->SetNotifyWindow((OAHWND)m_hWnd, WM_GRAPHNOTIFY, 0))) {
break;
+ }
// windows media source filter or windows asf reader
GUID asfreader = bIsVistaOrAbove? CLSID_WMAsfReader : CLSID_NetShowSource;
CComPtr<IBaseFilter> pSrc;
- if(FAILED(hr = pSrc.CoCreateInstance(asfreader))
+ if(FAILED(hr = pSrc.CoCreateInstance(asfreader))
|| FAILED(hr = pGB->AddFilter(pSrc, CStringW(src)))
- || FAILED(hr = CComQIPtr<IFileSourceFilter>(pSrc)->Load(CStringW(src), NULL)))
+ || FAILED(hr = CComQIPtr<IFileSourceFilter>(pSrc)->Load(CStringW(src), NULL))) {
break;
+ }
// matroska muxer
CComPtr<IBaseFilter> pMux;
if(FAILED(hr = pMux.CoCreateInstance(__uuidof(CMatroskaMuxerFilter)))
&& !(pMux = new CMatroskaMuxerFilter(NULL, NULL))
- || FAILED(hr = pGB->AddFilter(pMux, L"Matroska Muxer")))
+ || FAILED(hr = pGB->AddFilter(pMux, L"Matroska Muxer"))) {
break;
+ }
BeginEnumPins(pSrc, pEP, pPin)
- if(FAILED(hr = pGB->Connect(pPin, GetFirstDisconnectedPin(pMux, PINDIR_INPUT))))
+ if(FAILED(hr = pGB->Connect(pPin, GetFirstDisconnectedPin(pMux, PINDIR_INPUT)))) {
break;
+ }
EndEnumPins
- if(FAILED(hr))
+ if(FAILED(hr)) {
break;
+ }
// file writer
@@ -393,37 +387,37 @@ void Casf2mkvDlg::OnRecord()
|| FAILED(hr = pGB->AddFilter(pFW, CStringW(m_dst)))
|| FAILED(hr = CComQIPtr<IFileSinkFilter2>(pFW)->SetFileName(CStringW(m_dst), NULL))
|| FAILED(hr = CComQIPtr<IFileSinkFilter2>(pFW)->SetMode(AM_FILE_OVERWRITE))
- || FAILED(hr = pGB->Connect(GetFirstDisconnectedPin(pMux, PINDIR_OUTPUT), GetFirstDisconnectedPin(pFW, PINDIR_INPUT))))
+ || FAILED(hr = pGB->Connect(GetFirstDisconnectedPin(pMux, PINDIR_OUTPUT), GetFirstDisconnectedPin(pFW, PINDIR_INPUT)))) {
break;
+ }
// insert inf. pin tee
- BeginEnumPins(pMux, pEP, pPin)
- {
+ BeginEnumPins(pMux, pEP, pPin) {
PIN_DIRECTION dir;
CComPtr<IPin> pPinTo;
CMediaType mt;
if(FAILED(pPin->QueryDirection(&dir)) || dir != PINDIR_INPUT
|| FAILED(pPin->ConnectedTo(&pPinTo))
- || FAILED(pPin->ConnectionMediaType(&mt)))
+ || FAILED(pPin->ConnectionMediaType(&mt))) {
continue;
+ }
// FIXME: the inf pin tee filter makes the video messed up, like when seeking
// onto a non-keyframe and starting to decode from that point. (audio seems to be ok)
CComPtr<IBaseFilter> pInfPinTee;
if(mt.majortype == MEDIATYPE_Video
- || mt.majortype == MEDIATYPE_Audio)
- {
+ || mt.majortype == MEDIATYPE_Audio) {
if(FAILED(pGB->Disconnect(pPin))
|| FAILED(pGB->Disconnect(pPinTo))
|| FAILED(pInfPinTee.CoCreateInstance(CLSID_InfTee))
- || FAILED(pGB->AddFilter(pInfPinTee, L"Infinite Pin Tee")))
+ || FAILED(pGB->AddFilter(pInfPinTee, L"Infinite Pin Tee"))) {
continue;
+ }
if(FAILED(pGB->Connect(pPinTo, GetFirstDisconnectedPin(pInfPinTee, PINDIR_INPUT)))
- || FAILED(pGB->Connect(GetFirstDisconnectedPin(pInfPinTee, PINDIR_OUTPUT), pPin)))
- {
+ || FAILED(pGB->Connect(GetFirstDisconnectedPin(pInfPinTee, PINDIR_OUTPUT), pPin))) {
pGB->RemoveFilter(pInfPinTee);
pGB->ConnectDirect(pPinTo, pPin, NULL);
continue;
@@ -434,23 +428,22 @@ void Casf2mkvDlg::OnRecord()
CComPtr<IBaseFilter> pRenderer;
- if(mt.majortype == MEDIATYPE_Video)
- {
+ if(mt.majortype == MEDIATYPE_Video) {
if(SUCCEEDED(pRenderer.CoCreateInstance(CLSID_VideoRendererDefault))
- || SUCCEEDED(pRenderer.CoCreateInstance(CLSID_VideoRenderer)))
+ || SUCCEEDED(pRenderer.CoCreateInstance(CLSID_VideoRenderer))) {
pPinTo = ::GetFirstDisconnectedPin(pRenderer, PINDIR_INPUT);
- }
- else if(mt.majortype == MEDIATYPE_Audio)
- {
- if(SUCCEEDED(pRenderer.CoCreateInstance(CLSID_DSoundRender)))
+ }
+ } else if(mt.majortype == MEDIATYPE_Audio) {
+ if(SUCCEEDED(pRenderer.CoCreateInstance(CLSID_DSoundRender))) {
pPinTo = ::GetFirstDisconnectedPin(pRenderer, PINDIR_INPUT);
+ }
}
- if(pPin && pPinTo && pRenderer)
- {
+ if(pPin && pPinTo && pRenderer) {
if(SUCCEEDED(pGB->AddFilter(pRenderer, L"Renderer"))
- && FAILED(pGB->Connect(pPin, pPinTo)))
+ && FAILED(pGB->Connect(pPin, pPinTo))) {
pGB->RemoveFilter(pRenderer);
+ }
}
}
EndEnumPins
@@ -459,8 +452,7 @@ void Casf2mkvDlg::OnRecord()
if(SUCCEEDED(pVW->put_Owner((OAHWND)m_video.m_hWnd))
&& SUCCEEDED(pVW->put_WindowStyle(WS_CHILD|WS_CLIPSIBLINGS|WS_CLIPCHILDREN))
- && SUCCEEDED(pVW->put_MessageDrain((OAHWND)m_hWnd)))
- {
+ && SUCCEEDED(pVW->put_MessageDrain((OAHWND)m_hWnd))) {
SetVideoRect();
}
@@ -470,18 +462,20 @@ void Casf2mkvDlg::OnRecord()
// go!
- if(FAILED(hr = pMC->Run()))
+ if(FAILED(hr = pMC->Run())) {
break;
+ }
hr = S_OK;
- }
- while(false);
+ } while(false);
- if(FAILED(hr)) OnRecord();
- }
- else
- {
- if(pMC) pMC->Stop();
+ if(FAILED(hr)) {
+ OnRecord();
+ }
+ } else {
+ if(pMC) {
+ pMC->Stop();
+ }
pMC.Release();
pME.Release();
@@ -524,25 +518,23 @@ void Casf2mkvDlg::OnSize(UINT nType, int cx, int cy)
void Casf2mkvDlg::OnTimer(UINT_PTR nIDEvent)
{
- if(nIDEvent == 1)
- {
- if(pMS)
- {
+ if(nIDEvent == 1) {
+ if(pMS) {
REFERENCE_TIME rtPos = 0, rtDur = 0;
pMS->GetCurrentPosition(&rtPos);
pMS->GetDuration(&rtDur);
CString title;
- if(rtDur > 0) title.Format(_T("%s (progress: %I64d%%)"), ResStr(IDS_TITLE), 100i64 * rtPos / rtDur);
- else title = ResStr(IDS_TITLE) + _T(" (live)");
+ if(rtDur > 0) {
+ title.Format(_T("%s (progress: %I64d%%)"), ResStr(IDS_TITLE), 100i64 * rtPos / rtDur);
+ } else {
+ title = ResStr(IDS_TITLE) + _T(" (live)");
+ }
- BeginEnumFilters(pGB, pEF, pBF)
- {
- if(CComQIPtr<IAMNetworkStatus, &IID_IAMNetworkStatus> pAMNS = pBF)
- {
+ BeginEnumFilters(pGB, pEF, pBF) {
+ if(CComQIPtr<IAMNetworkStatus, &IID_IAMNetworkStatus> pAMNS = pBF) {
long BufferingProgress = 0;
- if(SUCCEEDED(pAMNS->get_BufferingProgress(&BufferingProgress)) && BufferingProgress > 0)
- {
+ if(SUCCEEDED(pAMNS->get_BufferingProgress(&BufferingProgress)) && BufferingProgress > 0) {
CString str;
str.Format(_T(" (buffer: %d%%)"), BufferingProgress);
title += str;
@@ -563,7 +555,9 @@ void Casf2mkvDlg::OnBnClickedButton2()
{
CComPtr<IBaseFilter> pBF;
pBF.CoCreateInstance(CLSID_NetShowSource);
- if(pBF) ShowPPage(pBF, m_hWnd);
+ if(pBF) {
+ ShowPPage(pBF, m_hWnd);
+ }
}
LRESULT Casf2mkvDlg::OnUrlOpen(WPARAM wParam, LPARAM lParam)
@@ -590,27 +584,30 @@ void Casf2mkvDlg::CRecentFileAndURLList::Add(LPCTSTR lpszPathName)
ASSERT(lpszPathName != NULL);
ASSERT(AfxIsValidString(lpszPathName));
- if(CString(lpszPathName).MakeLower().Find(_T("@device:")) >= 0)
+ if(CString(lpszPathName).MakeLower().Find(_T("@device:")) >= 0) {
return;
+ }
bool fURL = (CString(lpszPathName).Find(_T("://")) >= 0);
// fully qualify the path name
TCHAR szTemp[_MAX_PATH];
- if(fURL) _tcscpy(szTemp, lpszPathName);
- else AfxFullPath(szTemp, lpszPathName);
+ if(fURL) {
+ _tcscpy(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++)
- {
+ 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
+ || AfxComparePath(m_arrNames[iMRU], szTemp)) {
+ break; // iMRU will point to matching entry
+ }
}
// move MRU strings before this one down
- for (; iMRU > 0; iMRU--)
- {
+ for (; iMRU > 0; iMRU--) {
ASSERT(iMRU > 0);
ASSERT(iMRU < m_nSize);
m_arrNames[iMRU] = m_arrNames[iMRU-1];
diff --git a/src/apps/asf2mkv/asf2mkvDlg.h b/src/apps/asf2mkv/asf2mkvDlg.h
index fa68e2234..a9a70da6e 100644
--- a/src/apps/asf2mkv/asf2mkvDlg.h
+++ b/src/apps/asf2mkv/asf2mkvDlg.h
@@ -73,17 +73,17 @@ class Casf2mkvDlg : public CResizableDialog
CUrlDropTarget m_urlDropTarget;
-// Construction
+ // Construction
public:
Casf2mkvDlg(CWnd* pParent = NULL); // standard constructor
-// Dialog Data
+ // Dialog Data
enum { IDD = IDD_ASF2MKV_DIALOG };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
-// Implementation
+ // Implementation
protected:
HICON m_hIcon;
diff --git a/src/apps/mpcinfo/mpcinfo.cpp b/src/apps/mpcinfo/mpcinfo.cpp
index 8d5468117..da2056db4 100644
--- a/src/apps/mpcinfo/mpcinfo.cpp
+++ b/src/apps/mpcinfo/mpcinfo.cpp
@@ -89,42 +89,50 @@ BOOL CmpcinfoApp::InitInstance()
static bool GetFilterGraph(IFilterGraph** ppFG)
{
- if(!ppFG) return(false);
+ if(!ppFG) {
+ return(false);
+ }
CComPtr<IRunningObjectTable> pROT;
- if(FAILED(GetRunningObjectTable(0, &pROT)))
+ if(FAILED(GetRunningObjectTable(0, &pROT))) {
return 1;
+ }
CComPtr<IEnumMoniker> pEM;
- if(FAILED(pROT->EnumRunning(&pEM)))
+ if(FAILED(pROT->EnumRunning(&pEM))) {
return 1;
+ }
CComPtr<IBindCtx> pBindCtx;
CreateBindCtx(0, &pBindCtx);
- for(CComPtr<IMoniker> pMoniker; S_OK == pEM->Next(1, &pMoniker, NULL); pMoniker = NULL)
- {
+ for(CComPtr<IMoniker> pMoniker; S_OK == pEM->Next(1, &pMoniker, NULL); pMoniker = NULL) {
LPOLESTR pDispName = NULL;
- if(FAILED(pMoniker->GetDisplayName(pBindCtx, NULL, &pDispName)))
+ if(FAILED(pMoniker->GetDisplayName(pBindCtx, NULL, &pDispName))) {
continue;
+ }
CStringW strw(pDispName);
CComPtr<IMalloc> pMalloc;
- if(FAILED(CoGetMalloc(1, &pMalloc)))
+ if(FAILED(CoGetMalloc(1, &pMalloc))) {
continue;
+ }
pMalloc->Free(pDispName);
- if(strw.Find(L"(MPC)") < 0)
+ if(strw.Find(L"(MPC)") < 0) {
continue;
+ }
CComPtr<IUnknown> pUnk;
- if(S_OK != pROT->GetObject(pMoniker, &pUnk))
+ if(S_OK != pROT->GetObject(pMoniker, &pUnk)) {
continue;
+ }
CComQIPtr<IFilterGraph> pFG = pUnk;
- if(!pFG)
+ if(!pFG) {
continue;
+ }
*ppFG = pFG.Detach();
@@ -137,24 +145,25 @@ static bool GetFilterGraph(IFilterGraph** ppFG)
extern "C" int WINAPI file(HWND,HWND,char *data,char*,BOOL,BOOL)
{
CComPtr<IFilterGraph> pFG;
- if(!GetFilterGraph(&pFG))
+ if(!GetFilterGraph(&pFG)) {
return 1;
+ }
CString fn;
CComPtr<IEnumFilters> pEF;
- if(FAILED(pFG->EnumFilters(&pEF)))
+ if(FAILED(pFG->EnumFilters(&pEF))) {
return 1;
+ }
ULONG cFetched = 0;
- for(CComPtr<IBaseFilter> pBF; S_OK == pEF->Next(1, &pBF, &cFetched); pBF = NULL)
- {
- if(CComQIPtr<IFileSourceFilter> pFSF = pBF)
- {
+ for(CComPtr<IBaseFilter> pBF; S_OK == pEF->Next(1, &pBF, &cFetched); pBF = NULL) {
+ if(CComQIPtr<IFileSourceFilter> pFSF = pBF) {
LPOLESTR pFileName = NULL;
AM_MEDIA_TYPE mt;
- if(FAILED(pFSF->GetCurFile(&pFileName, &mt)))
+ if(FAILED(pFSF->GetCurFile(&pFileName, &mt))) {
continue;
+ }
fn = CStringW(pFileName);
@@ -165,8 +174,9 @@ extern "C" int WINAPI file(HWND,HWND,char *data,char*,BOOL,BOOL)
}
}
- if(fn.IsEmpty())
+ if(fn.IsEmpty()) {
return 1;
+ }
size_t len = strlen(data);
sprintf_s(data,len+1, _T("%s"), fn);
@@ -176,15 +186,17 @@ extern "C" int WINAPI file(HWND,HWND,char *data,char*,BOOL,BOOL)
extern "C" int WINAPI size(HWND,HWND,char *data,char*,BOOL,BOOL)
{
- if(file(0,0,data,0,0,0) != 3)
+ if(file(0,0,data,0,0,0) != 3) {
return 1;
+ }
CString fn = CStringA(data);
data[0] = 0;
HANDLE hFile = CreateFile(fn, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, (HANDLE)NULL);
- if(hFile == INVALID_HANDLE_VALUE)
+ if(hFile == INVALID_HANDLE_VALUE) {
return 1;
+ }
LARGE_INTEGER size;
size.QuadPart = 0;
@@ -201,26 +213,25 @@ extern "C" int WINAPI size(HWND,HWND,char *data,char*,BOOL,BOOL)
extern "C" int WINAPI pos(HWND,HWND,char *data,char*,BOOL,BOOL)
{
CComPtr<IFilterGraph> pFG;
- if(!GetFilterGraph(&pFG))
+ if(!GetFilterGraph(&pFG)) {
return 1;
+ }
CComQIPtr<IMediaSeeking> pMS = pFG;
REFERENCE_TIME pos, dur;
- if(FAILED(pMS->GetCurrentPosition(&pos)) || FAILED(pMS->GetDuration(&dur)))
+ if(FAILED(pMS->GetCurrentPosition(&pos)) || FAILED(pMS->GetDuration(&dur))) {
return 1;
+ }
size_t len = strlen(data);
- if(dur > 10000000i64*60*60)
- {
+ if(dur > 10000000i64*60*60) {
sprintf_s(data,len+1, _T("%02d:%02d:%02d/%02d:%02d:%02d"),
- (int)(pos/10000000/60/60), (int)(pos/10000000/60)%60, (int)(pos/10000000)%60,
- (int)(dur/10000000/60/60), (int)(dur/10000000/60)%60, (int)(dur/10000000)%60);
- }
- else
- {
+ (int)(pos/10000000/60/60), (int)(pos/10000000/60)%60, (int)(pos/10000000)%60,
+ (int)(dur/10000000/60/60), (int)(dur/10000000/60)%60, (int)(dur/10000000)%60);
+ } else {
sprintf_s(data,len+1, _T("%02d:%02d/%02d:%02d"),
- (int)(pos/10000000/60)%60, (int)(pos/10000000)%60,
- (int)(dur/10000000/60)%60, (int)(dur/10000000)%60);
+ (int)(pos/10000000/60)%60, (int)(pos/10000000)%60,
+ (int)(dur/10000000/60)%60, (int)(dur/10000000)%60);
}
return 3;
@@ -229,13 +240,19 @@ extern "C" int WINAPI pos(HWND,HWND,char *data,char*,BOOL,BOOL)
extern "C" int WINAPI info(HWND,HWND,char *data,char*,BOOL,BOOL)
{
CStringA ret;
- if(file(0,0,data,0,0,0)!=3) return 1;
+ if(file(0,0,data,0,0,0)!=3) {
+ return 1;
+ }
ret += data;
ret += ", ";
- if(size(0,0,data,0,0,0)!=3) return 1;
+ if(size(0,0,data,0,0,0)!=3) {
+ return 1;
+ }
ret += data;
ret += ", ";
- if(pos(0,0,data,0,0,0)!=3) return 1;
+ if(pos(0,0,data,0,0,0)!=3) {
+ return 1;
+ }
ret += data;
size_t len = strlen(data) + 1;
@@ -252,8 +269,9 @@ extern "C" int WINAPI stopped(HWND,HWND,char *data,char*,BOOL,BOOL)
CComPtr<IFilterGraph> pFG;
CComQIPtr<IMediaControl> pMC;
OAFilterState fs;
- if(!GetFilterGraph(&pFG) || !(pMC = pFG) || FAILED(pMC->GetState(0, &fs)))
+ if(!GetFilterGraph(&pFG) || !(pMC = pFG) || FAILED(pMC->GetState(0, &fs))) {
return 3;
+ }
sprintf_s(data,len, _T("%d"), fs == State_Stopped ? 1 : 0);
@@ -268,8 +286,9 @@ extern "C" int WINAPI paused(HWND,HWND,char *data,char*,BOOL,BOOL)
CComPtr<IFilterGraph> pFG;
CComQIPtr<IMediaControl> pMC;
OAFilterState fs;
- if(!GetFilterGraph(&pFG) || !(pMC = pFG) || FAILED(pMC->GetState(0, &fs)))
+ if(!GetFilterGraph(&pFG) || !(pMC = pFG) || FAILED(pMC->GetState(0, &fs))) {
return 3;
+ }
sprintf_s(data,len, _T("%d"), fs == State_Paused ? 1 : 0);
@@ -284,8 +303,9 @@ extern "C" int WINAPI running(HWND,HWND,char *data,char*,BOOL,BOOL)
CComPtr<IFilterGraph> pFG;
CComQIPtr<IMediaControl> pMC;
OAFilterState fs;
- if(!GetFilterGraph(&pFG) || !(pMC = pFG) || FAILED(pMC->GetState(0, &fs)))
+ if(!GetFilterGraph(&pFG) || !(pMC = pFG) || FAILED(pMC->GetState(0, &fs))) {
return 3;
+ }
sprintf_s(data,len, _T("%d"), fs == State_Running ? 1 : 0);
diff --git a/src/apps/mpcinfo/mpcinfo.h b/src/apps/mpcinfo/mpcinfo.h
index 29bc96c29..63d790277 100644
--- a/src/apps/mpcinfo/mpcinfo.h
+++ b/src/apps/mpcinfo/mpcinfo.h
@@ -38,7 +38,7 @@ class CmpcinfoApp : public CWinApp
public:
CmpcinfoApp();
-// Overrides
+ // Overrides
public:
virtual BOOL InitInstance();
diff --git a/src/apps/mplayerc/AppSettings.cpp b/src/apps/mplayerc/AppSettings.cpp
index 6b1f788f8..407131fdf 100644
--- a/src/apps/mplayerc/AppSettings.cpp
+++ b/src/apps/mplayerc/AppSettings.cpp
@@ -36,7 +36,7 @@ CAppSettings::CAppSettings()
, nCmdlnWebServerPort(-1)
, fShowDebugInfo(false)
{
-// Internal source filter
+ // Internal source filter
#if INTERNAL_SOURCEFILTER_CDDA
SrcFiltersKeys[SRC_CDDA] = _T("SRC_CDDA");
#endif
@@ -99,7 +99,7 @@ CAppSettings::CAppSettings()
SrcFiltersKeys[SRC_FLAC] = _T("SRC_FLAC");
#endif
-// Internal decoders
+ // Internal decoders
#if INTERNAL_DECODER_MPEG1
TraFiltersKeys[TRA_MPEG1] = _T("TRA_MPEG1");
#endif
@@ -147,7 +147,7 @@ CAppSettings::CAppSettings()
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");
#endif
@@ -158,7 +158,7 @@ CAppSettings::CAppSettings()
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");
#endif
@@ -370,24 +370,27 @@ void CAppSettings::CreateCommands()
CAppSettings::~CAppSettings()
{
- if(hAccel)
+ if(hAccel) {
DestroyAcceleratorTable(hAccel);
+ }
}
bool CAppSettings::IsD3DFullscreen() const
{
- if(nCLSwitches&CLSW_D3DFULLSCREEN)
+ if(nCLSwitches&CLSW_D3DFULLSCREEN) {
return true;
- else
+ } else {
return fD3DFullscreen;
+ }
}
CString CAppSettings::SelectedAudioRenderer() const
{
CString strResult;
- if(AfxGetMyApp()->m_AudioRendererDisplayName_CL != _T(""))
+ if(AfxGetMyApp()->m_AudioRendererDisplayName_CL != _T("")) {
strResult = AfxGetMyApp()->m_AudioRendererDisplayName_CL;
- else
+ } else {
strResult = AfxGetAppSettings().strAudioRendererDisplayName;
+ }
return strResult;
}
@@ -400,29 +403,27 @@ void CAppSettings::ResetPositions()
DVD_POSITION* CAppSettings::CurrentDVDPosition()
{
- if (nCurrentDvdPosition != -1)
+ if (nCurrentDvdPosition != -1) {
return &DvdPosition[nCurrentDvdPosition];
- else
+ } else {
return NULL;
+ }
}
bool CAppSettings::NewDvd(ULONGLONG llDVDGuid)
{
- int i;
-
// Look for the DVD position
- for (i=0; i<MAX_DVD_POSITION; i++)
- {
- if (DvdPosition[i].llDVDGuid == llDVDGuid)
- {
+ 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--)
+ 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;
@@ -430,29 +431,25 @@ bool CAppSettings::NewDvd(ULONGLONG llDVDGuid)
FILE_POSITION* CAppSettings::CurrentFilePosition()
{
- if (nCurrentFilePosition != -1)
+ if (nCurrentFilePosition != -1) {
return &FilePosition[nCurrentFilePosition];
- else
+ } else {
return NULL;
+ }
}
bool CAppSettings::NewFile(LPCTSTR strFileName)
{
- int i;
-
// Look for the file position
- for (i=0; i<MAX_FILE_POSITION; i++)
- {
- if (FilePosition[i].strFile == strFileName)
- {
+ 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--)
- {
+ for (int i=MAX_FILE_POSITION-1; i>0; i--) {
FilePosition[i].strFile = FilePosition[i-1].strFile;
FilePosition[i].llPosition = FilePosition[i-1].llPosition;
}
@@ -467,8 +464,7 @@ void CAppSettings::DeserializeHex (LPCTSTR strVal, BYTE* pBuffer, int nBufSize)
{
long lRes;
- for (int i=0; i<nBufSize; i++)
- {
+ for (int i=0; i<nBufSize; i++) {
_stscanf_s (strVal+(i*2), _T("%02x"), &lRes);
pBuffer[i] = (BYTE)lRes;
}
@@ -479,8 +475,7 @@ CString CAppSettings::SerializeHex (BYTE* pBuffer, int nBufSize) const
CString strTemp;
CString strResult;
- for (int i=0; i<nBufSize; i++)
- {
+ for (int i=0; i<nBufSize; i++) {
strTemp.Format (_T("%02x"), pBuffer[i]);
strResult += strTemp;
}
@@ -496,9 +491,10 @@ void CAppSettings::UpdateData(bool fSave)
UINT len;
BYTE* ptr = NULL;
- if(fSave)
- {
- if(!fInitialized) return;
+ if(fSave) {
+ if(!fInitialized) {
+ return;
+ }
pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_HIDECAPTIONMENU, iCaptionMenuMode);
pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_HIDENAVIGATION, fHideNavigation);
@@ -536,6 +532,12 @@ void CAppSettings::UpdateData(bool fSave)
pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_RMVIDEORENDERERTYPE, iRMVideoRendererType);
pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_QTVIDEORENDERERTYPE, iQTVideoRendererType);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, _T("ShufflePlaylistItems"), bShufflePlaylistItems);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, _T("RememberPlaylistItems"), bRememberPlaylistItems);
+ pApp->WriteProfileInt(IDS_R_SETTINGS, _T("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));
@@ -637,8 +639,7 @@ void CAppSettings::UpdateData(bool fSave)
int iChannel = 0;
POSITION pos = m_DVBChannels.GetHeadPosition();
- while (pos)
- {
+ while (pos) {
CString strTemp;
CString strChannel;
CDVBChannel& Channel = m_DVBChannels.GetNext(pos);
@@ -650,10 +651,8 @@ void CAppSettings::UpdateData(bool fSave)
// 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++)
- {
+ if (fKeepHistory) {
+ for (int i=0; i<MAX_DVD_POSITION; i++) {
CString strDVDPos;
CString strValue;
@@ -663,8 +662,7 @@ void CAppSettings::UpdateData(bool fSave)
}
// playback positions for last played files
- for (int i=0; i<MAX_FILE_POSITION; i++)
- {
+ for (int i=0; i<MAX_FILE_POSITION; i++) {
CString strFilePos;
CString strValue;
@@ -680,50 +678,46 @@ void CAppSettings::UpdateData(bool fSave)
// CASIMIR666 : end of new settings
{
- for(int i = 0; ; i++)
- {
+ for(int i = 0; ; i++) {
CString key;
key.Format(_T("%s\\%04d"), IDS_R_FILTERS, i);
int j = pApp->GetProfileInt(key, _T("Enabled"), -1);
pApp->WriteProfileString(key, NULL, NULL);
- if(j < 0) break;
+ if(j < 0) {
+ break;
+ }
}
pApp->WriteProfileString(IDS_R_FILTERS, NULL, NULL);
POSITION pos = m_filters.GetHeadPosition();
- for(int i = 0; pos; i++)
- {
+ for(int i = 0; pos; i++) {
FilterOverride* f = m_filters.GetNext(pos);
- if(f->fTemporary)
+ if(f->fTemporary) {
continue;
+ }
CString key;
key.Format(_T("%s\\%04d"), IDS_R_FILTERS, i);
pApp->WriteProfileInt(key, _T("SourceType"), (int)f->type);
pApp->WriteProfileInt(key, _T("Enabled"), (int)!f->fDisabled);
- if(f->type == FilterOverride::REGISTERED)
- {
+ 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)
- {
+ } 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(int i = 0; pos2; i++)
- {
+ for(int i = 0; pos2; i++) {
CString val;
val.Format(_T("org%04d"), i);
pApp->WriteProfileString(key, val, CStringFromGUID(f->backup.GetNext(pos2)));
}
pos2 = f->guids.GetHeadPosition();
- for(int i = 0; pos2; i++)
- {
+ for(int i = 0; pos2; i++) {
CString val;
val.Format(_T("mod%04d"), i);
pApp->WriteProfileString(key, val, CStringFromGUID(f->guids.GetNext(pos2)));
@@ -739,8 +733,7 @@ void CAppSettings::UpdateData(bool fSave)
//pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_REALMEDIAFPS, *((DWORD*)&dRealMediaQuickTimeFPS));
pApp->WriteProfileString(IDS_R_SETTINGS _T("\\") IDS_RS_PNSPRESETS, NULL, NULL);
- for(int i = 0, j = m_pnspresets.GetCount(); i < j; i++)
- {
+ for(int i = 0, j = m_pnspresets.GetCount(); i < j; i++) {
CString str;
str.Format(_T("Preset%d"), i);
pApp->WriteProfileString(IDS_R_SETTINGS _T("\\") IDS_RS_PNSPRESETS, str, m_pnspresets[i]);
@@ -748,11 +741,9 @@ void CAppSettings::UpdateData(bool fSave)
pApp->WriteProfileString(IDS_R_COMMANDS, NULL, NULL);
pos = wmcmds.GetHeadPosition();
- for(int i = 0; pos; )
- {
+ for(int i = 0; pos; ) {
wmcmd& wc = wmcmds.GetNext(pos);
- if(wc.IsModified())
- {
+ if(wc.IsModified()) {
CString str;
str.Format(_T("CommandMod%d"), i);
CString str2;
@@ -785,14 +776,18 @@ void CAppSettings::UpdateData(bool fSave)
m_Formats.UpdateData(true);
// Internal filters
- for (int f=0; f<SRC_LAST; f++)
+ 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++)
+ }
+ 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++)
+ }
+ 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++)
+ }
+ 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);
@@ -828,12 +823,10 @@ void CAppSettings::UpdateData(bool fSave)
pos = m_shaders.GetHeadPosition();
- for(int i = 0; pos; i++)
- {
+ for(int i = 0; pos; i++) {
const Shader& s = m_shaders.GetNext(pos);
- if(!s.label.IsEmpty())
- {
+ if(!s.label.IsEmpty()) {
CString index;
index.Format(_T("%d"), i);
CString srcdata = s.srcdata;
@@ -844,24 +837,21 @@ void CAppSettings::UpdateData(bool fSave)
}
}
- if(pApp->m_pszRegistryKey)
- {
+ 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;
+ } else {
+ if(fInitialized) {
+ return;
+ }
iDXVer = 0;
CRegKey dxver;
- if(ERROR_SUCCESS == dxver.Open(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\DirectX"), KEY_READ))
- {
+ 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))
- {
+ 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);
@@ -871,7 +861,9 @@ void CAppSettings::UpdateData(bool fSave)
// Set interface language first!
iLanguage = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_LANGUAGE, CMPlayerCApp::GetDefLanguage());
- if (iLanguage != 0) CMPlayerCApp::SetLanguage(iLanguage);
+ if (iLanguage != 0) {
+ CMPlayerCApp::SetLanguage(iLanguage);
+ }
CreateCommands();
iCaptionMenuMode = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_HIDECAPTIONMENU, MODE_SHOWCAPTIONMENU);
@@ -926,16 +918,14 @@ void CAppSettings::UpdateData(bool fSave)
// 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) )
+ if ( pApp->GetProfileBinary(IDS_R_SETTINGS, IDS_RS_FULLSCREENRES, &ptr, &len) ) {
+ if ( len == sizeof(AChFR) ) {
memcpy( &AutoChangeFullscrRes, ptr, sizeof(AChFR) );
- else
+ } else {
AutoChangeFullscrRes.bEnabled = false;
+ }
delete [] ptr;
- }
- else
- {
+ } else {
AutoChangeFullscrRes.bEnabled = false;
}
@@ -947,19 +937,24 @@ void CAppSettings::UpdateData(bool fSave)
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) )
+ if ( pApp->GetProfileBinary(IDS_R_SETTINGS, IDS_RS_LASTWINDOWRECT, &ptr, &len) ) {
+ if ( len == sizeof(CRect) ) {
memcpy( &rcLastWindowPos, ptr, sizeof(CRect) );
- else
+ } else {
fRememberWindowPos = false;
+ }
delete [] ptr;
- }
- else
- {
+ } else {
fRememberWindowPos = false;
}
nLastWindowType = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_LASTWINDOWTYPE, SIZE_RESTORED);
+
+ bShufflePlaylistItems = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("ShufflePlaylistItems"), FALSE);
+ bRememberPlaylistItems = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("RememberPlaylistItems"), TRUE);
+ bHidePlaylistFullScreen = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("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);
@@ -970,8 +965,9 @@ void CAppSettings::UpdateData(bool fSave)
{
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
+ 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);
@@ -990,16 +986,14 @@ void CAppSettings::UpdateData(bool fSave)
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) )
- {
+ if ( bResult && len == sizeof(pSpeakerToChannelMap) ) {
memcpy( pSpeakerToChannelMap, ptr, sizeof(pSpeakerToChannelMap) );
- }
- else
- {
+ } else {
memset(pSpeakerToChannelMap, 0, sizeof(pSpeakerToChannelMap));
for(int j = 0; j < 18; j++)
- for(int i = 0; i <= j; i++)
+ for(int i = 0; i <= j; i++) {
pSpeakerToChannelMap[j][i] = 1<<i;
+ }
pSpeakerToChannelMap[0][0] = 1<<0;
pSpeakerToChannelMap[0][1] = 1<<0;
@@ -1018,19 +1012,21 @@ void CAppSettings::UpdateData(bool fSave)
pSpeakerToChannelMap[4][4] = 1<<3;
pSpeakerToChannelMap[4][5] = 1<<4;
}
- if ( bResult )
+ 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;
+ if (dAudioBoost_dB<0 || dAudioBoost_dB>10) {
+ dAudioBoost_dB = 0;
+ }
nSpeakerChannels = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_SPEAKERCHANNELS, 2);
{
- for(int i = 0; ; i++)
- {
+ for(int i = 0; ; i++) {
CString key;
key.Format(_T("%s\\%04d"), IDS_R_FILTERS, i);
@@ -1039,47 +1035,46 @@ void CAppSettings::UpdateData(bool fSave)
f->fDisabled = !pApp->GetProfileInt(key, _T("Enabled"), 0);
UINT j = pApp->GetProfileInt(key, _T("SourceType"), -1);
- if(j == 0)
- {
+ 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)
- {
+ } 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
- {
+ } else {
pApp->WriteProfileString(key, NULL, 0);
break;
}
f->backup.RemoveAll();
- for(int i = 0; ; i++)
- {
+ for(int i = 0; ; i++) {
CString val;
val.Format(_T("org%04d"), i);
CString guid = pApp->GetProfileString(key, val, _T(""));
- if(guid.IsEmpty()) break;
+ if(guid.IsEmpty()) {
+ break;
+ }
f->backup.AddTail(GUIDFromCString(guid));
}
f->guids.RemoveAll();
- for(int i = 0; ; i++)
- {
+ for(int i = 0; ; i++) {
CString val;
val.Format(_T("mod%04d"), i);
CString guid = pApp->GetProfileString(key, val, _T(""));
- if(guid.IsEmpty()) break;
+ if(guid.IsEmpty()) {
+ break;
+ }
f->guids.AddTail(GUIDFromCString(guid));
}
f->iLoadType = (int)pApp->GetProfileInt(key, _T("LoadType"), -1);
- if(f->iLoadType < 0) break;
+ if(f->iLoadType < 0) {
+ break;
+ }
f->dwMerit = pApp->GetProfileInt(key, _T("Merit"), MERIT_DO_NOT_USE+1);
@@ -1094,16 +1089,16 @@ void CAppSettings::UpdateData(bool fSave)
//*((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++)
- {
+ 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;
+ if(str.IsEmpty()) {
+ break;
+ }
m_pnspresets.Add(str);
}
- if(m_pnspresets.IsEmpty())
- {
+ if(m_pnspresets.IsEmpty()) {
double _4p3 = 4.0/3.0;
double _16p9 = 16.0/9.0;
double _185p1 = 1.85/1.0;
@@ -1119,25 +1114,30 @@ void CAppSettings::UpdateData(bool fSave)
m_pnspresets.Add(str);
}
- for(int i = 0; i < wmcmds.GetCount(); i++)
- {
+ 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;
+ if(str.IsEmpty()) {
+ break;
+ }
int cmd, fVirt, key, repcnt, mouse, appcmd;
TCHAR buff[128];
int n;
- if(5 > (n = _stscanf_s(str, _T("%d %x %x %s %d %d %d"), &cmd, &fVirt, &key, buff, countof(buff), &repcnt, &mouse, &appcmd)))
+ if(5 > (n = _stscanf_s(str, _T("%d %x %x %s %d %d %d"), &cmd, &fVirt, &key, buff, countof(buff), &repcnt, &mouse, &appcmd))) {
break;
- if(POSITION pos = wmcmds.Find(cmd))
- {
+ }
+ 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 = (UINT)mouse;
- if(n >= 7) wc.appcmd = (UINT)appcmd;
+ if(n >= 6) {
+ wc.mouse = (UINT)mouse;
+ }
+ if(n >= 7) {
+ wc.appcmd = (UINT)appcmd;
+ }
wc.rmcmd = CStringA(buff).Trim('\"');
wc.rmrepcnt = repcnt;
}
@@ -1146,7 +1146,9 @@ void CAppSettings::UpdateData(bool fSave)
CAtlArray<ACCEL> pAccel;
pAccel.SetCount(wmcmds.GetCount());
POSITION pos = wmcmds.GetHeadPosition();
- for(int i = 0; pos; i++) pAccel[i] = wmcmds.GetNext(pos);
+ for(int i = 0; pos; i++) {
+ pAccel[i] = wmcmds.GetNext(pos);
+ }
hAccel = CreateAcceleratorTable(pAccel.GetData(), pAccel.GetCount());
strWinLircAddr = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_WINLIRCADDR, _T("127.0.0.1:8765"));
@@ -1167,14 +1169,18 @@ void CAppSettings::UpdateData(bool fSave)
m_Formats.UpdateData(false);
// Internal filters
- for (int f=0; f<SRC_LAST; f++)
+ 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++)
+ }
+ 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++)
+ }
+ 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++)
+ }
+ for (int f=0; f<FFM_LAST; f++) {
FFmpegFilters[f] = !!pApp->GetProfileInt(IDS_R_INTERNAL_FILTERS, FFMFiltersKeys[f], 1);
+ }
strLogoFileName = pApp->GetProfileString(IDS_R_SETTINGS, IDS_RS_LOGOFILE, _T(""));
nLogoId = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_LOGOID, DEF_LOGO);
@@ -1201,11 +1207,13 @@ void CAppSettings::UpdateData(bool fSave)
// 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))
- {
+ 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();
+ 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"));
@@ -1245,16 +1253,19 @@ void CAppSettings::UpdateData(bool fSave)
shaders[_T("denoise")] = IDF_SHADER_DENOISE;
shaders[_T("YV12 Chroma Upsampling")] = IDF_SHADER_YV12CHROMAUP;
- for(int iShader=0; ; iShader++)
- {
+ for(int iShader=0; ; iShader++) {
CString str;
str.Format(_T("%d"), iShader);
str = pApp->GetProfileString(_T("Shaders"), str);
CAtlList<CString> sl;
CString label = Explode(str, sl, '|');
- if(label.IsEmpty()) break;
- if(sl.GetCount() < 3) continue;
+ if(label.IsEmpty()) {
+ break;
+ }
+ if(sl.GetCount() < 3) {
+ continue;
+ }
Shader s;
s.label = sl.RemoveHead();
@@ -1268,28 +1279,25 @@ void CAppSettings::UpdateData(bool fSave)
}
pos = shaders.GetStartPosition();
- while(pos)
- {
+ while(pos) {
CAtlStringMap<UINT>::CPair* pPair = shaders.GetNext(pos);
CStringA srcdata;
- if(LoadResource(pPair->m_value, srcdata, _T("FILE")))
- {
+ 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;
+ 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);
@@ -1330,14 +1338,15 @@ void CAppSettings::UpdateData(bool fSave)
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++)
- {
+ 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;
+ if (strChannel.IsEmpty()) {
+ break;
+ }
Channel.FromString(strChannel);
m_DVBChannels.AddTail (Channel);
}
@@ -1346,15 +1355,13 @@ void CAppSettings::UpdateData(bool fSave)
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++)
- {
+ 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))
- {
+ if (strValue.GetLength()/2 == sizeof(DVD_POSITION)) {
DeserializeHex(strValue, (BYTE*)&DvdPosition[i], sizeof(DVD_POSITION));
}
}
@@ -1362,8 +1369,7 @@ void CAppSettings::UpdateData(bool fSave)
// 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++)
- {
+ for (int i=0; i<MAX_FILE_POSITION; i++) {
CString strFilePos;
CString strValue;
@@ -1384,7 +1390,9 @@ void CAppSettings::UpdateData(bool fSave)
strShadercombine = pApp->GetProfileString(_T("Shaders"), _T("Combine"), _T(""));
strShadercombineScreenSpace = pApp->GetProfileString(_T("Shaders"), _T("CombineScreenSpace"), _T(""));
- if(fLaunchfullscreen) nCLSwitches |= CLSW_FULLSCREEN;
+ if(fLaunchfullscreen) {
+ nCLSwitches |= CLSW_FULLSCREEN;
+ }
fInitialized = true;
}
@@ -1395,10 +1403,9 @@ void CAppSettings::UpdateRenderersData(bool fSave)
CWinApp* pApp = AfxGetApp();
CRenderersSettings& r = m_RenderersSettings;
- if(fSave)
- {
+ if(fSave) {
pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_APSURACEFUSAGE, r.iAPSurfaceUsage);
-// pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_VMRSYNCFIX, fVMRSyncFix);
+ // pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_VMRSYNCFIX, fVMRSyncFix);
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);
@@ -1446,11 +1453,9 @@ void CAppSettings::UpdateRenderersData(bool fSave)
pApp->WriteProfileInt(IDS_R_SETTINGS, IDS_RS_EVR_BUFFERS, r.iEvrBuffers);
pApp->WriteProfileString(IDS_R_SETTINGS, IDS_D3D9RENDERDEVICE, r.D3D9RenderDevice);
- }
- else
- {
+ } else {
r.iAPSurfaceUsage = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_APSURACEFUSAGE, (IsVistaOrAbove() ? VIDRNDT_AP_TEXTURE3D : VIDRNDT_AP_TEXTURE2D));
-// fVMRSyncFix = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_VMRSYNCFIX, FALSE);
+ // fVMRSyncFix = !!pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_VMRSYNCFIX, FALSE);
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);
@@ -1487,19 +1492,16 @@ void CAppSettings::UpdateRenderersData(bool fSave)
double *dPtr;
UINT dSize;
- if(pApp->GetProfileBinary(IDS_R_SETTINGS, _T("CycleDelta"), (LPBYTE*)&dPtr, &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))
- {
+ 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))
- {
+ if(pApp->GetProfileBinary(IDS_R_SETTINGS, _T("ControlLimit"), (LPBYTE*)&dPtr, &dSize)) {
renderSettings.fControlLimit = *dPtr;
delete [] dPtr;
}
@@ -1513,8 +1515,9 @@ void CAppSettings::UpdateRenderersData(bool fSave)
bool bAllowAnimationWhenBuffering = true;
SYSTEM_INFO SysInfo;
GetSystemInfo(&SysInfo);
- if (SysInfo.dwNumberOfProcessors < 3)
+ if (SysInfo.dwNumberOfProcessors < 3) {
bAllowAnimationWhenBuffering = false;
+ }
r.fSPCAllowAnimationWhenBuffering = !!pApp->GetProfileInt(IDS_R_SETTINGS, _T("SPCAllowAnimationWhenBuffering"), bAllowAnimationWhenBuffering);
r.iEvrBuffers = pApp->GetProfileInt(IDS_R_SETTINGS, IDS_RS_EVR_BUFFERS, 5);
@@ -1555,28 +1558,22 @@ __int64 CAppSettings::ConvertTimeToMSec(CString& time) const
__int64 mult = 1;
int pos = time.GetLength() - 1;
- if (pos < 3) return 0;
+ if (pos < 3) {
+ return 0;
+ }
- while (pos >= 0)
- {
+ while (pos >= 0) {
TCHAR ch = time[pos];
- if (ch == '.')
- {
+ if (ch == '.') {
mSec = Sec * 1000 / mult;
Sec = 0;
mult = 1;
- }
- else if (ch == ':')
- {
+ } else if (ch == ':') {
mult = mult * 6 / 10;
- }
- else if (ch >= '0' && ch <= '9')
- {
+ } else if (ch >= '0' && ch <= '9') {
Sec += (ch - '0') * mult;
mult *= 10;
- }
- else
- {
+ } else {
mSec = Sec = 0;
break;
}
@@ -1590,23 +1587,20 @@ 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;
+ 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;
}
}
}
@@ -1630,106 +1624,112 @@ void CAppSettings::ParseCommandLine(CAtlList<CString>& cmdln)
strPnSPreset.Empty();
POSITION pos = cmdln.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CString param = cmdln.GetNext(pos);
- if(param.IsEmpty()) continue;
+ if(param.IsEmpty()) {
+ continue;
+ }
- if((param[0] == '-' || param[0] == '/') && param.GetLength() > 1)
- {
+ 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(cmdln.GetNext(pos));
- else if(sw == _T("dubdelay") && pos)
- {
+ 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(cmdln.GetNext(pos));
+ } else if(sw == _T("dubdelay") && pos) {
CString strFile = cmdln.GetNext(pos);
int nPos = strFile.Find (_T("DELAY"));
- if (nPos != -1)
+ if (nPos != -1) {
rtShift = 10000 * _tstol(strFile.Mid(nPos + 6));
+ }
slDubs.AddTail(strFile);
- }
- else if(sw == _T("sub") && pos) slSubs.AddTail(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("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)
- {
+ } else if(sw == _T("sub") && pos) {
+ slSubs.AddTail(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("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)
- {
+ } 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("d3dfs")) nCLSwitches |= CLSW_D3DFULLSCREEN;
- else if(sw == _T("adminoption"))
- {
+ } 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("d3dfs")) {
+ nCLSwitches |= CLSW_D3DFULLSCREEN;
+ } else if(sw == _T("adminoption")) {
nCLSwitches |= CLSW_ADMINOPTION;
iAdminOption = _ttoi (cmdln.GetNext(pos));
- }
- else if(sw == _T("slave"))
- {
+ } else if(sw == _T("slave")) {
nCLSwitches |= CLSW_SLAVE;
hMasterWnd = (HWND)_ttol (cmdln.GetNext(pos));
- }
- else if(sw == _T("fixedsize") && pos)
- {
+ } else if(sw == _T("fixedsize") && pos) {
CAtlList<CString> sl;
Explode(cmdln.GetNext(pos), sl, ',', 2);
- if(sl.GetCount() == 2)
- {
+ if(sl.GetCount() == 2) {
sizeFixedWindow.SetSize(_ttol(sl.GetHead()), _ttol(sl.GetTail()));
- if(sizeFixedWindow.cx > 0 && sizeFixedWindow.cy > 0)
+ if(sizeFixedWindow.cx > 0 && sizeFixedWindow.cy > 0) {
nCLSwitches |= CLSW_FIXEDSIZE;
+ }
}
- }
- else if(sw == _T("monitor") && pos)
- {
+ } else if(sw == _T("monitor") && pos) {
iMonitor = _tcstol(cmdln.GetNext(pos), NULL, 10);
nCLSwitches |= CLSW_MONITOR;
- }
- else if(sw == _T("minidump"))
- {
+ } else if(sw == _T("minidump")) {
CMiniDump::Enable();
- }
- else if(sw == _T("pns")) strPnSPreset = cmdln.GetNext(pos);
- else if(sw == _T("webport") && pos)
- {
+ } 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 )
+ if ( tmpport >= 0 && tmpport <= 65535 ) {
nCmdlnWebServerPort = tmpport;
- }
- else if(sw == _T("debug"))
- {
+ }
+ } else if(sw == _T("debug")) {
fShowDebugInfo = true;
- }
- else if(sw == _T("audiorenderer") && pos)
- {
+ } else if(sw == _T("audiorenderer") && pos) {
SetAudioRenderer(_ttoi(cmdln.GetNext(pos)));
+ } else {
+ nCLSwitches |= CLSW_HELP|CLSW_UNRECOGNIZEDSWITCH;
}
- else nCLSwitches |= CLSW_HELP|CLSW_UNRECOGNIZEDSWITCH;
- }
- else
- {
+ } else {
slFiles.AddTail(param);
}
}
@@ -1741,27 +1741,27 @@ void CAppSettings::GetFav(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;
+ 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++)
- {
+ for(int i = 0; ; i++) {
CString s;
s.Format(_T("Name%d"), i);
s = AfxGetApp()->GetProfileString(root, s, NULL);
- if(s.IsEmpty()) break;
+ if(s.IsEmpty()) {
+ break;
+ }
sl.AddTail(s);
}
}
@@ -1770,27 +1770,25 @@ 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;
+ 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)
- {
+ while(pos) {
CString s;
s.Format(_T("Name%d"), i++);
AfxGetApp()->WriteProfileString(root, s, sl.GetNext(pos));
@@ -1801,7 +1799,9 @@ void CAppSettings::AddFav(favtype ft, CString s)
{
CAtlList<CString> sl;
GetFav(ft, sl);
- if(sl.Find(s)) return;
+ if(sl.Find(s)) {
+ return;
+ }
sl.AddTail(s);
SetFav(ft, sl);
}
@@ -1809,11 +1809,9 @@ void CAppSettings::AddFav(favtype ft, CString s)
CDVBChannel* CAppSettings::FindChannelByPref(int nPrefNumber)
{
POSITION pos = m_DVBChannels.GetHeadPosition();
- while (pos)
- {
+ while (pos) {
CDVBChannel& Channel = m_DVBChannels.GetNext (pos);
- if (Channel.GetPrefNumber() == nPrefNumber)
- {
+ if (Channel.GetPrefNumber() == nPrefNumber) {
return &Channel;
}
}
@@ -1840,27 +1838,30 @@ void CAppSettings::CRecentFileAndURLList::Add(LPCTSTR lpszPathName)
ASSERT(lpszPathName != NULL);
ASSERT(AfxIsValidString(lpszPathName));
- if(CString(lpszPathName).MakeLower().Find(_T("@device:")) >= 0)
+ 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);
+ 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++)
- {
+ 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
+ || AfxComparePath(m_arrNames[iMRU], szTemp)) {
+ break; // iMRU will point to matching entry
+ }
}
// move MRU strings before this one down
- for (; iMRU > 0; iMRU--)
- {
+ for (; iMRU > 0; iMRU--) {
ASSERT(iMRU > 0);
ASSERT(iMRU < m_nSize);
m_arrNames[iMRU] = m_arrNames[iMRU-1];
diff --git a/src/apps/mplayerc/AppSettings.h b/src/apps/mplayerc/AppSettings.h
index 63ea68d6d..4b978add6 100644
--- a/src/apps/mplayerc/AppSettings.h
+++ b/src/apps/mplayerc/AppSettings.h
@@ -31,8 +31,7 @@
#include "DVBChannel.h"
// flags for AppSettings::nCS
-enum
-{
+enum {
CS_NONE=0,
CS_SEEKBAR=1,
CS_TOOLBAR=CS_SEEKBAR<<1,
@@ -42,8 +41,7 @@ enum
CS_LAST=CS_STATUSBAR
};
-enum
-{
+enum {
CLSW_NONE=0,
CLSW_OPEN=1,
CLSW_PLAY=CLSW_OPEN<<1,
@@ -74,16 +72,14 @@ enum
CLSW_UNRECOGNIZEDSWITCH=CLSW_AUDIORENDERER<<1
};
-enum
-{
+enum {
MODE_SHOWCAPTIONMENU,
MODE_BORDERLESS,
MODE_FRAMEONLY,
MODE_COUNT
}; // flags for Caption & Menu Mode
-enum
-{
+enum {
VIDRNDT_DS_DEFAULT,
VIDRNDT_DS_OLDRENDERER,
VIDRNDT_DS_OVERLAYMIXER,
@@ -101,8 +97,7 @@ enum
};
// Enumeration for MCE remote control (careful : add 0x010000 for all keys!)
-enum MCE_RAW_INPUT
-{
+enum MCE_RAW_INPUT {
MCE_DETAILS = 0x010209,
MCE_GUIDE = 0x01008D,
MCE_TVJUMP = 0x010025,
@@ -131,8 +126,7 @@ enum MCE_RAW_INPUT
#define AUDRNDT_NULL_UNCOMP _T("Null Audio Renderer (Uncompressed)")
#define AUDRNDT_MPC _T("MPC Audio Renderer")
-typedef enum
-{
+typedef enum {
DVS_HALF,
DVS_NORMAL,
DVS_DOUBLE,
@@ -143,38 +137,33 @@ typedef enum
DVS_ZOOM2
} dvstype;
-typedef enum
-{
+typedef enum {
FAV_FILE,
FAV_DVD,
FAV_DEVICE
} favtype;
#define MAX_DVD_POSITION 20
-typedef struct
-{
+typedef struct {
ULONGLONG llDVDGuid;
ULONG lTitle;
DVD_HMSF_TIMECODE Timecode;
} DVD_POSITION;
#define MAX_FILE_POSITION 20
-typedef struct
-{
+typedef struct {
CString strFile;
LONGLONG llPosition;
} FILE_POSITION;
#pragma pack(push, 1)
-typedef struct
-{
+typedef struct {
bool fValid;
CSize size;
int bpp, freq;
DWORD dmDisplayFlags;
} dispmode;
-typedef struct
-{
+typedef struct {
bool bEnabled;
dispmode dmFullscreenRes24Hz;
dispmode dmFullscreenRes25Hz;
@@ -198,12 +187,10 @@ public:
UINT mouse;
CStringA rmcmd;
int rmrepcnt;
- wmcmd(WORD cmd = 0)
- {
+ wmcmd(WORD cmd = 0) {
this->cmd = cmd;
}
- wmcmd(WORD cmd, WORD key, BYTE fVirt, DWORD dwname, UINT appcmd = 0, UINT mouse = NONE, LPCSTR rmcmd = "", int rmrepcnt = 5)
- {
+ wmcmd(WORD cmd, WORD key, BYTE fVirt, DWORD dwname, UINT appcmd = 0, UINT mouse = NONE, LPCSTR rmcmd = "", int rmrepcnt = 5) {
this->cmd = cmd;
this->key = key;
this->fVirt = fVirt;
@@ -214,25 +201,21 @@ public:
this->rmrepcnt = rmrepcnt;
backup = *this;
}
- bool operator == (const wmcmd& wc) const
- {
+ bool operator == (const wmcmd& wc) const {
return(cmd > 0 && cmd == wc.cmd);
}
- CString GetName() const
- {
+ CString GetName() const {
return ResStr (dwname);
}
- void Restore()
- {
+ void Restore() {
*(ACCEL*)this = backup;
appcmd = appcmdorg;
mouse = mouseorg;
rmcmd.Empty();
rmrepcnt = 5;
}
- bool IsModified() const
- {
+ bool IsModified() const {
return(memcmp((const ACCEL*)this, &backup, sizeof(ACCEL)) || appcmd != appcmdorg || mouse != mouseorg || !rmcmd.IsEmpty() || rmrepcnt != 5);
}
};
@@ -259,8 +242,7 @@ public:
CRemoteCtrlClient();
void SetHWND(HWND hWnd);
void Connect(CString addr);
- int GetStatus() const
- {
+ int GetStatus() const {
return(m_nStatus);
}
};
@@ -310,8 +292,7 @@ public:
DVD_HMSF_TIMECODE DVDPosition;
CSize sizeFixedWindow;
- bool HasFixedWindowSize() const
- {
+ bool HasFixedWindowSize() const {
return sizeFixedWindow.cx > 0 || sizeFixedWindow.cy > 0;
}
//int iFixedWidth, iFixedHeight;
@@ -384,6 +365,12 @@ public:
bool fKeepHistory;
UINT nLastUsedPage;
+ bool bShufflePlaylistItems;
+ bool bRememberPlaylistItems;
+ bool bHidePlaylistFullScreen;
+ bool bFavRememberPos;
+ bool bFavRelativeDrive;
+
CString strDVDPath;
bool fUseDVDPath;
LCID idMenuLang, idAudioLang, idSubtitlesLang;
@@ -474,8 +461,7 @@ public:
CString strISDb;
- struct Shader
- {
+ struct Shader {
CString label;
CString target;
CString srcdata;
diff --git a/src/apps/mplayerc/AuthDlg.cpp b/src/apps/mplayerc/AuthDlg.cpp
index ad4cf6f5a..29feb12c6 100644
--- a/src/apps/mplayerc/AuthDlg.cpp
+++ b/src/apps/mplayerc/AuthDlg.cpp
@@ -53,8 +53,9 @@ void CAuthDlg::DoDataExchange(CDataExchange* pDX)
CString CAuthDlg::DEncrypt(CString str)
{
- for(int i = 0; i < str.GetLength(); i++)
+ for(int i = 0; i < str.GetLength(); i++) {
str.SetAt(i, str[i]^5);
+ }
return str;
}
@@ -74,33 +75,25 @@ BOOL CAuthDlg::OnInitDialog()
CWinApp* pApp = AfxGetApp();
- if(pApp->m_pszRegistryKey)
- {
+ if(pApp->m_pszRegistryKey) {
CRegKey hSecKey(pApp->GetSectionKey(IDS_R_LOGINS));
- if(hSecKey)
- {
+ if(hSecKey) {
int i = 0;
TCHAR username[256], password[256];
- while(1)
- {
+ while(1) {
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))
- {
+ hSecKey, i++, username, &unlen, 0, &type, (BYTE*)password, &pwlen)) {
m_logins[username] = DEncrypt(password);
m_usernamectrl.AddString(username);
- }
- else
- {
+ } else {
break;
}
}
}
- }
- else
- {
+ } else {
CAutoVectorPtr<TCHAR> buff;
buff.Allocate(32767/sizeof(TCHAR));
@@ -108,15 +101,13 @@ BOOL CAuthDlg::OnInitDialog()
IDS_R_LOGINS, buff, 32767/sizeof(TCHAR), pApp->m_pszProfileName);
TCHAR* p = buff;
- while(*p && len > 0)
- {
+ 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)
- {
+ if(sl.GetCount() == 2) {
m_logins[sl.GetHead()] = DEncrypt(sl.GetTail());
m_usernamectrl.AddString(sl.GetHead());
}
@@ -133,8 +124,7 @@ void CAuthDlg::OnBnClickedOk()
{
UpdateData();
- if(!m_username.IsEmpty())
- {
+ if(!m_username.IsEmpty()) {
CWinApp* pApp = AfxGetApp();
pApp->WriteProfileString(IDS_R_LOGINS, m_username, m_remember ? DEncrypt(m_password) : _T(""));
}
@@ -149,8 +139,7 @@ void CAuthDlg::OnCbnSelchangeCombo1()
m_usernamectrl.GetLBText(m_usernamectrl.GetCurSel(), username);
CString password;
- if(m_logins.Lookup(username, password))
- {
+ if(m_logins.Lookup(username, password)) {
m_password = password;
m_remember = TRUE;
UpdateData(FALSE);
@@ -162,8 +151,7 @@ void CAuthDlg::OnEnSetfocusEdit3()
UpdateData();
CString password;
- if(m_logins.Lookup(m_username, password))
- {
+ if(m_logins.Lookup(m_username, password)) {
m_password = password;
m_remember = TRUE;
UpdateData(FALSE);
diff --git a/src/apps/mplayerc/AuthDlg.h b/src/apps/mplayerc/AuthDlg.h
index 748cbffe7..89d589967 100644
--- a/src/apps/mplayerc/AuthDlg.h
+++ b/src/apps/mplayerc/AuthDlg.h
@@ -40,7 +40,7 @@ public:
CAuthDlg(CWnd* pParent = NULL); // standard constructor
virtual ~CAuthDlg();
-// Dialog Data
+ // Dialog Data
enum { IDD = IDD_AUTH_DLG };
CComboBox m_usernamectrl;
CString m_username;
diff --git a/src/apps/mplayerc/Authors.txt b/src/apps/mplayerc/Authors.txt
index 77be5cf9e..c3e1d2261 100644
--- a/src/apps/mplayerc/Authors.txt
+++ b/src/apps/mplayerc/Authors.txt
@@ -20,6 +20,7 @@ Attila T. Afra <attila.afra@gmail.com> (Code)
Di Luo (sansnom05) <sansnom05@users.sourceforge.net> (Code)
xpc1000 <xpc1000@users.sourceforge.net> (Code)
Underground78 <Underground78@users.sourceforge.net> (Code)
+v0lt <v0lt@users.sourceforge.net> (Code)
Translators:
@@ -48,8 +49,12 @@ hrant77 <hrant77@users.sourceforge.net> (Armenian)
Contributors: (listed alphabetically)
------------------------------------------------
-Alexx999, foxx1337, heksesang, mtrz, nielsm, skaarj1, thevbm, v0lt,
-VSFilterMod team, X-Dron
+Alexx999, foxx1337, heksesang, mtrz, nielsm, skaarj1, VSFilterMod team, X-Dron
+
+
+Trac moderators:
+------------------------------------------------
+namaiki, thevbm
Many thanks to everyone who supported development without having
diff --git a/src/apps/mplayerc/BaseGraph.cpp b/src/apps/mplayerc/BaseGraph.cpp
index 39d1af02b..3f3c27c3c 100644
--- a/src/apps/mplayerc/BaseGraph.cpp
+++ b/src/apps/mplayerc/BaseGraph.cpp
@@ -32,8 +32,9 @@
BOOL CPlayerWindow::PreCreateWindow(CREATESTRUCT& cs)
{
- if(!CWnd::PreCreateWindow(cs))
+ if(!CWnd::PreCreateWindow(cs)) {
return FALSE;
+ }
cs.style &= ~WS_BORDER;
cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS,
@@ -48,9 +49,10 @@ 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);
@@ -101,8 +103,7 @@ STDMETHODIMP CBaseGraph::NonDelegatingQueryInterface(REFIID riid, void** ppv)
void CBaseGraph::ClearMessageQueue()
{
- while(!m_msgqueue.IsEmpty())
- {
+ while(!m_msgqueue.IsEmpty()) {
GMSG msg = m_msgqueue.RemoveHead();
FreeEventParams(msg.m_lEventCode, msg.m_lParam1, msg.m_lParam2);
}
@@ -111,7 +112,9 @@ void CBaseGraph::ClearMessageQueue()
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;
@@ -302,12 +305,20 @@ STDMETHODIMP CBaseGraph::GetEventHandle(OAEVENT* hEvent)
}
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;
+ if(lEventCode) {
+ *lEventCode = msg.m_lEventCode;
+ }
+ if(lParam1) {
+ *lParam1 = msg.m_lParam1;
+ }
+ if(lParam2) {
+ *lParam2 = msg.m_lParam2;
+ }
return S_OK;
}
@@ -325,9 +336,10 @@ STDMETHODIMP CBaseGraph::RestoreDefaultHandling(long lEvCode)
}
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;
@@ -340,8 +352,7 @@ STDMETHODIMP CBaseGraph::SetNotifyWindow(OAHWND hwnd, long lMsg, LONG_PTR lInsta
m_lNotifyMsg = lMsg;
m_lNotifyInstData = lInstanceData;
- if(!IsWindow((HWND)m_hNotifyWnd))
- {
+ if(!IsWindow((HWND)m_hNotifyWnd)) {
m_hNotifyWnd = NULL;
return E_FAIL;
}
@@ -366,7 +377,9 @@ STDMETHODIMP CBaseGraph::CheckCapabilities(DWORD* pCapabilities)
{
CheckPointer(pCapabilities, E_POINTER);
- if(*pCapabilities == 0) return S_OK;
+ if(*pCapabilities == 0) {
+ return S_OK;
+ }
DWORD caps;
GetCapabilities(&caps);
diff --git a/src/apps/mplayerc/BaseGraph.h b/src/apps/mplayerc/BaseGraph.h
index 5e7c10935..13661d4ba 100644
--- a/src/apps/mplayerc/BaseGraph.h
+++ b/src/apps/mplayerc/BaseGraph.h
@@ -41,13 +41,11 @@ typedef enum {DirectShow = 0, RealMedia, QuickTime, ShockWave} engine_t;
interface __declspec(uuid("B110CDE5-6331-4118-8AAF-A870D6F7E2E4"))
IGraphEngine :
-public IUnknown
-{
+public IUnknown {
STDMETHOD_(engine_t, GetEngine) () = 0;
};
-enum
-{
+enum {
EC_BG_AUDIO_CHANGED = EC_USER+1,
EC_BG_ERROR
};
@@ -68,8 +66,7 @@ class CBaseGraph
long m_lNotifyMsg;
LONG_PTR m_lNotifyInstData;
- typedef struct
- {
+ typedef struct {
long m_lEventCode;
LONG_PTR m_lParam1, m_lParam2;
} GMSG;
diff --git a/src/apps/mplayerc/CGdiPlusBitmap.h b/src/apps/mplayerc/CGdiPlusBitmap.h
index bf251e392..1ea829478 100644
--- a/src/apps/mplayerc/CGdiPlusBitmap.h
+++ b/src/apps/mplayerc/CGdiPlusBitmap.h
@@ -6,35 +6,29 @@ public:
Gdiplus::Bitmap* m_pBitmap;
public:
- CGdiPlusBitmap()
- {
+ CGdiPlusBitmap() {
m_pBitmap = NULL;
}
- CGdiPlusBitmap(LPCWSTR pFile)
- {
+ CGdiPlusBitmap(LPCWSTR pFile) {
m_pBitmap = NULL;
Load(pFile);
}
- virtual ~CGdiPlusBitmap()
- {
+ virtual ~CGdiPlusBitmap() {
Empty();
}
- void Empty()
- {
+ void Empty() {
delete m_pBitmap;
m_pBitmap = NULL;
}
- bool Load(LPCWSTR pFile)
- {
+ bool Load(LPCWSTR pFile) {
Empty();
m_pBitmap = Gdiplus::Bitmap::FromFile(pFile);
return m_pBitmap->GetLastStatus() == Gdiplus::Ok;
}
- operator Gdiplus::Bitmap*() const
- {
+ operator Gdiplus::Bitmap*() const {
return m_pBitmap;
}
};
@@ -46,39 +40,32 @@ protected:
HGLOBAL m_hBuffer;
public:
- CGdiPlusBitmapResource()
- {
+ CGdiPlusBitmapResource() {
m_hBuffer = NULL;
}
- CGdiPlusBitmapResource(LPCTSTR pName, LPCTSTR pType = RT_RCDATA, HMODULE hInst = NULL)
- {
+ CGdiPlusBitmapResource(LPCTSTR pName, LPCTSTR pType = RT_RCDATA, HMODULE hInst = NULL) {
m_hBuffer = NULL;
Load(pName, pType, hInst);
}
- CGdiPlusBitmapResource(UINT id, LPCTSTR pType = RT_RCDATA, HMODULE hInst = NULL)
- {
+ CGdiPlusBitmapResource(UINT id, LPCTSTR pType = RT_RCDATA, HMODULE hInst = NULL) {
m_hBuffer = NULL;
Load(id, pType, hInst);
}
- CGdiPlusBitmapResource(UINT id, UINT type, HMODULE hInst = NULL)
- {
+ CGdiPlusBitmapResource(UINT id, UINT type, HMODULE hInst = NULL) {
m_hBuffer = NULL;
Load(id, type, hInst);
}
- virtual ~CGdiPlusBitmapResource()
- {
+ virtual ~CGdiPlusBitmapResource() {
Empty();
}
void Empty();
bool Load(LPCTSTR pName, LPCTSTR pType = RT_RCDATA, HMODULE hInst = NULL);
- bool Load(UINT id, LPCTSTR pType = RT_RCDATA, HMODULE hInst = NULL)
- {
+ bool Load(UINT id, LPCTSTR pType = RT_RCDATA, HMODULE hInst = NULL) {
return Load(MAKEINTRESOURCE(id), pType, hInst);
}
- bool Load(UINT id, UINT type, HMODULE hInst = NULL)
- {
+ bool Load(UINT id, UINT type, HMODULE hInst = NULL) {
return Load(MAKEINTRESOURCE(id), MAKEINTRESOURCE(type), hInst);
}
};
@@ -87,8 +74,7 @@ inline
void CGdiPlusBitmapResource::Empty()
{
CGdiPlusBitmap::Empty();
- if (m_hBuffer)
- {
+ if (m_hBuffer) {
::GlobalUnlock(m_hBuffer);
::GlobalFree(m_hBuffer);
m_hBuffer = NULL;
@@ -101,34 +87,34 @@ bool CGdiPlusBitmapResource::Load(LPCTSTR pName, LPCTSTR pType, HMODULE hInst)
Empty();
HRSRC hResource = ::FindResource(hInst, pName, pType);
- if (!hResource)
+ if (!hResource) {
return false;
+ }
DWORD imageSize = ::SizeofResource(hInst, hResource);
- if (!imageSize)
+ if (!imageSize) {
return false;
+ }
const void* pResourceData = ::LockResource(::LoadResource(hInst, hResource));
- if (!pResourceData)
+ if (!pResourceData) {
return false;
+ }
m_hBuffer = ::GlobalAlloc(GMEM_MOVEABLE, imageSize);
- if (m_hBuffer)
- {
+ if (m_hBuffer) {
void* pBuffer = ::GlobalLock(m_hBuffer);
- if (pBuffer)
- {
+ if (pBuffer) {
CopyMemory(pBuffer, pResourceData, imageSize);
IStream* pStream = NULL;
- if (::CreateStreamOnHGlobal(m_hBuffer, FALSE, &pStream) == S_OK)
- {
+ if (::CreateStreamOnHGlobal(m_hBuffer, FALSE, &pStream) == S_OK) {
m_pBitmap = Gdiplus::Bitmap::FromStream(pStream);
pStream->Release();
- if (m_pBitmap)
- {
- if (m_pBitmap->GetLastStatus() == Gdiplus::Ok)
+ if (m_pBitmap) {
+ if (m_pBitmap->GetLastStatus() == Gdiplus::Ok) {
return true;
+ }
delete m_pBitmap;
m_pBitmap = NULL;
diff --git a/src/apps/mplayerc/CShockwaveFlash.h b/src/apps/mplayerc/CShockwaveFlash.h
index 0d1b6c6c8..5d722a53f 100644
--- a/src/apps/mplayerc/CShockwaveFlash.h
+++ b/src/apps/mplayerc/CShockwaveFlash.h
@@ -31,429 +31,353 @@ class CShockwaveFlash : public CWnd
protected:
DECLARE_DYNCREATE(CShockwaveFlash)
public:
- CLSID const& GetClsid()
- {
+ 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)
- {
+ 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)
- {
+ BSTR bstrLicKey = NULL) {
return CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID,
pPersist, bStorage, bstrLicKey);
}
-// Attributes
+ // Attributes
public:
-// Operations
+ // Operations
public:
- long get_ReadyState()
- {
+ long get_ReadyState() {
long result;
InvokeHelper(DISPID_READYSTATE, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
return result;
}
- long get_TotalFrames()
- {
+ long get_TotalFrames() {
long result;
InvokeHelper(0x7c, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
return result;
}
- BOOL get_Playing()
- {
+ BOOL get_Playing() {
BOOL result;
InvokeHelper(0x7d, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
return result;
}
- void put_Playing(BOOL newValue)
- {
+ void put_Playing(BOOL newValue) {
static BYTE parms[] = VTS_BOOL ;
InvokeHelper(0x7d, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
}
- long get_Quality()
- {
+ long get_Quality() {
long result;
InvokeHelper(0x69, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
return result;
}
- void put_Quality(long newValue)
- {
+ void put_Quality(long newValue) {
static BYTE parms[] = VTS_I4 ;
InvokeHelper(0x69, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
}
- long get_ScaleMode()
- {
+ long get_ScaleMode() {
long result;
InvokeHelper(0x78, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
return result;
}
- void put_ScaleMode(long newValue)
- {
+ void put_ScaleMode(long newValue) {
static BYTE parms[] = VTS_I4 ;
InvokeHelper(0x78, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
}
- long get_AlignMode()
- {
+ long get_AlignMode() {
long result;
InvokeHelper(0x79, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
return result;
}
- void put_AlignMode(long newValue)
- {
+ void put_AlignMode(long newValue) {
static BYTE parms[] = VTS_I4 ;
InvokeHelper(0x79, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
}
- long get_BackgroundColor()
- {
+ long get_BackgroundColor() {
long result;
InvokeHelper(0x7b, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
return result;
}
- void put_BackgroundColor(long newValue)
- {
+ void put_BackgroundColor(long newValue) {
static BYTE parms[] = VTS_I4 ;
InvokeHelper(0x7b, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
}
- BOOL get_Loop()
- {
+ BOOL get_Loop() {
BOOL result;
InvokeHelper(0x6a, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
return result;
}
- void put_Loop(BOOL newValue)
- {
+ void put_Loop(BOOL newValue) {
static BYTE parms[] = VTS_BOOL ;
InvokeHelper(0x6a, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
}
- CString get_Movie()
- {
+ CString get_Movie() {
CString result;
InvokeHelper(0x66, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
return result;
}
- void put_Movie(LPCTSTR newValue)
- {
+ void put_Movie(LPCTSTR newValue) {
static BYTE parms[] = VTS_BSTR ;
InvokeHelper(0x66, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
}
- long get_FrameNum()
- {
+ long get_FrameNum() {
long result;
InvokeHelper(0x6b, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL);
return result;
}
- void put_FrameNum(long newValue)
- {
+ 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)
- {
+ 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)
- {
+ 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)
- {
+ 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()
- {
+ void Play() {
InvokeHelper(0x70, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
}
- void Stop()
- {
+ void Stop() {
InvokeHelper(0x71, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
}
- void Back()
- {
+ void Back() {
InvokeHelper(0x72, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
}
- void Forward()
- {
+ void Forward() {
InvokeHelper(0x73, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
}
- void Rewind()
- {
+ void Rewind() {
InvokeHelper(0x74, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
}
- void StopPlay()
- {
+ void StopPlay() {
InvokeHelper(0x7e, DISPATCH_METHOD, VT_EMPTY, NULL, NULL);
}
- void GotoFrame(long FrameNum)
- {
+ void GotoFrame(long FrameNum) {
static BYTE parms[] = VTS_I4 ;
InvokeHelper(0x7f, DISPATCH_METHOD, VT_EMPTY, NULL, parms, FrameNum);
}
- long CurrentFrame()
- {
+ long CurrentFrame() {
long result;
InvokeHelper(0x80, DISPATCH_METHOD, VT_I4, (void*)&result, NULL);
return result;
}
- BOOL IsPlaying()
- {
+ BOOL IsPlaying() {
BOOL result;
InvokeHelper(0x81, DISPATCH_METHOD, VT_BOOL, (void*)&result, NULL);
return result;
}
- long PercentLoaded()
- {
+ long PercentLoaded() {
long result;
InvokeHelper(0x82, DISPATCH_METHOD, VT_I4, (void*)&result, NULL);
return result;
}
- BOOL FrameLoaded(long FrameNum)
- {
+ 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 FlashVersion() {
long result;
InvokeHelper(0x84, DISPATCH_METHOD, VT_I4, (void*)&result, NULL);
return result;
}
- CString get_WMode()
- {
+ CString get_WMode() {
CString result;
InvokeHelper(0x85, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
return result;
}
- void put_WMode(LPCTSTR newValue)
- {
+ void put_WMode(LPCTSTR newValue) {
static BYTE parms[] = VTS_BSTR ;
InvokeHelper(0x85, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
}
- CString get_SAlign()
- {
+ CString get_SAlign() {
CString result;
InvokeHelper(0x86, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
return result;
}
- void put_SAlign(LPCTSTR newValue)
- {
+ void put_SAlign(LPCTSTR newValue) {
static BYTE parms[] = VTS_BSTR ;
InvokeHelper(0x86, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
}
- BOOL get_Menu()
- {
+ BOOL get_Menu() {
BOOL result;
InvokeHelper(0x87, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
return result;
}
- void put_Menu(BOOL newValue)
- {
+ void put_Menu(BOOL newValue) {
static BYTE parms[] = VTS_BOOL ;
InvokeHelper(0x87, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
}
- CString get_Base()
- {
+ CString get_Base() {
CString result;
InvokeHelper(0x88, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
return result;
}
- void put_Base(LPCTSTR newValue)
- {
+ void put_Base(LPCTSTR newValue) {
static BYTE parms[] = VTS_BSTR ;
InvokeHelper(0x88, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
}
- CString get_Scale()
- {
+ CString get_Scale() {
CString result;
InvokeHelper(0x89, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
return result;
}
- void put_Scale(LPCTSTR newValue)
- {
+ void put_Scale(LPCTSTR newValue) {
static BYTE parms[] = VTS_BSTR ;
InvokeHelper(0x89, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
}
- BOOL get_DeviceFont()
- {
+ BOOL get_DeviceFont() {
BOOL result;
InvokeHelper(0x8a, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
return result;
}
- void put_DeviceFont(BOOL newValue)
- {
+ void put_DeviceFont(BOOL newValue) {
static BYTE parms[] = VTS_BOOL ;
InvokeHelper(0x8a, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
}
- BOOL get_EmbedMovie()
- {
+ BOOL get_EmbedMovie() {
BOOL result;
InvokeHelper(0x8b, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL);
return result;
}
- void put_EmbedMovie(BOOL newValue)
- {
+ void put_EmbedMovie(BOOL newValue) {
static BYTE parms[] = VTS_BOOL ;
InvokeHelper(0x8b, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
}
- CString get_BGColor()
- {
+ CString get_BGColor() {
CString result;
InvokeHelper(0x8c, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
return result;
}
- void put_BGColor(LPCTSTR newValue)
- {
+ void put_BGColor(LPCTSTR newValue) {
static BYTE parms[] = VTS_BSTR ;
InvokeHelper(0x8c, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
}
- CString get_Quality2()
- {
+ CString get_Quality2() {
CString result;
InvokeHelper(0x8d, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
return result;
}
- void put_Quality2(LPCTSTR newValue)
- {
+ 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)
- {
+ 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)
- {
+ 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)
- {
+ 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 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 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)
- {
+ void TPlay(LPCTSTR target) {
static BYTE parms[] = VTS_BSTR ;
InvokeHelper(0x93, DISPATCH_METHOD, VT_EMPTY, NULL, parms, target);
}
- void TStopPlay(LPCTSTR 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)
- {
+ 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 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)
- {
+ 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 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)
- {
+ 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)
- {
+ 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)
- {
+ 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 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 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 get_SWRemote() {
CString result;
InvokeHelper(0x9f, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
return result;
}
- void put_SWRemote(LPCTSTR newValue)
- {
+ void put_SWRemote(LPCTSTR newValue) {
static BYTE parms[] = VTS_BSTR ;
InvokeHelper(0x9f, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
}
- CString get_FlashVars()
- {
+ CString get_FlashVars() {
CString result;
InvokeHelper(0xaa, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
return result;
}
- void put_FlashVars(LPCTSTR newValue)
- {
+ void put_FlashVars(LPCTSTR newValue) {
static BYTE parms[] = VTS_BSTR ;
InvokeHelper(0xaa, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
}
- CString get_AllowScriptAccess()
- {
+ CString get_AllowScriptAccess() {
CString result;
InvokeHelper(0xab, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
return result;
}
- void put_AllowScriptAccess(LPCTSTR newValue)
- {
+ void put_AllowScriptAccess(LPCTSTR newValue) {
static BYTE parms[] = VTS_BSTR ;
InvokeHelper(0xab, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, newValue);
}
diff --git a/src/apps/mplayerc/Changelog.txt b/src/apps/mplayerc/Changelog.txt
index fd28daf5a..abedbb105 100644
--- a/src/apps/mplayerc/Changelog.txt
+++ b/src/apps/mplayerc/Changelog.txt
@@ -14,7 +14,7 @@ v1.5.xxxx.0 - unreleased
NEW : Added ignore encrypted channels checkbox during DVB scan
NEW : Armenian translation
CHANGED: Updated FFmpeg
- CHANGED: Updated MediaInfoLib to v0.7.38
+ CHANGED: Updated MediaInfoLib to v0.7.39
CHANGED: Updated ZenLib to v0.4.17
CHANGED: Updated Little CMS to v2.1
CHANGED: Updated libpng to v1.4.5
@@ -25,7 +25,6 @@ v1.5.xxxx.0 - unreleased
each time the channel is switched back
CHANGED: Removed DSM Converter (use the legay branch if you need this feature)
CHANGED: Removed RoQ splitter/decoder (same as above)
- FIXED : Ticket #16, [MPEG SPLITTER] Subtitles not shown when playing TS or M2TS-containers
FIXED : Ticket #52, [playlist] shuffle is broken
FIXED : Ticket #78, ESC key cannot be assigned to other actions
FIXED : Ticket #293, giving "remember last window size" a meaning
@@ -34,6 +33,7 @@ v1.5.xxxx.0 - unreleased
folder if the "Remember items" in playlist is disabled
FIXED : Ticket #628, Enable ctrl+A in Player-->Keys page
FIXED : Ticket #647, Weird "keys" listed
+ FIXED : Ticket #650, Non-media entry in playlist halts playback
FIXED : Ticket #651, Make EVR CP stats graph smaller
FIXED : Ticket #652, Escape key on certain form causes form to collapse
FIXED : Ticket #655, Crash with some BBC-HD samples
diff --git a/src/apps/mplayerc/ChildView.cpp b/src/apps/mplayerc/ChildView.cpp
index ee2cd068f..0349125e9 100644
--- a/src/apps/mplayerc/ChildView.cpp
+++ b/src/apps/mplayerc/ChildView.cpp
@@ -45,8 +45,9 @@ CChildView::~CChildView()
BOOL CChildView::PreCreateWindow(CREATESTRUCT& cs)
{
- if(!CWnd::PreCreateWindow(cs))
+ if(!CWnd::PreCreateWindow(cs)) {
return FALSE;
+ }
cs.style &= ~WS_BORDER;
cs.lpszClass = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS,
@@ -57,8 +58,7 @@ BOOL CChildView::PreCreateWindow(CREATESTRUCT& cs)
BOOL CChildView::PreTranslateMessage(MSG* pMsg)
{
- if(pMsg->message >= WM_MOUSEFIRST && pMsg->message <= WM_MYMOUSELAST)
- {
+ if(pMsg->message >= WM_MOUSEFIRST && pMsg->message <= WM_MYMOUSELAST) {
CWnd* pParent = GetParent();
CPoint p(pMsg->lParam);
::MapWindowPoints(pMsg->hwnd, pParent->m_hWnd, &p, 1);
@@ -66,48 +66,43 @@ BOOL CChildView::PreTranslateMessage(MSG* pMsg)
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
+ /*
+ if(fInteractiveVideo)
{
- m_lastlmdowntime = pMsg->time;
- m_lastlmdownpoint = pMsg->pt;
+ 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;
+ }
}
- }
- 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)
- {
+ && fInteractiveVideo) {
+ if(pMsg->message == WM_MOUSEMOVE) {
pParent->PostMessage(pMsg->message, pMsg->wParam, MAKELPARAM(p.x, p.y));
}
- if(fDblClick)
- {
+ 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
- {
+ } else {
pParent->PostMessage(pMsg->message, pMsg->wParam, MAKELPARAM(p.x, p.y));
return TRUE;
}
@@ -132,26 +127,30 @@ void CChildView::LoadLogo()
m_logo.Destroy();
- if(s.fLogoExternal)
+ if(s.fLogoExternal) {
bHaveLogo = SUCCEEDED(m_logo.Load(s.strLogoFileName));
+ }
- if(!bHaveLogo)
- {
+ if(!bHaveLogo) {
s.fLogoExternal = false; // use the built-in logo instead
s.strLogoFileName = ""; // clear logo file name
- if (!m_logo.LoadFromResource(s.nLogoId)) // try the latest selected build-in logo
- m_logo.LoadFromResource(s.nLogoId=DEF_LOGO); // if fail then use the default logo, should never fail
+ if (!m_logo.LoadFromResource(s.nLogoId)) { // try the latest selected build-in logo
+ m_logo.LoadFromResource(s.nLogoId=DEF_LOGO); // if fail then use the default logo, should never fail
+ }
}
- if(m_hWnd) Invalidate();
+ if(m_hWnd) {
+ Invalidate();
+ }
}
CSize CChildView::GetLogoSize() const
{
CSize ret(0,0);
- if(!m_logo.IsNull())
+ if(!m_logo.IsNull()) {
ret.SetSize(m_logo.GetWidth(), m_logo.GetHeight());
+ }
return ret;
}
@@ -192,27 +191,24 @@ BOOL CChildView::OnEraseBkgnd(CDC* pDC)
CAutoLock cAutoLock(&m_csLogo);
- if(((CMainFrame*)GetParentFrame())->IsSomethingLoaded())
- {
+ if(((CMainFrame*)GetParentFrame())->IsSomethingLoaded()) {
pDC->ExcludeClipRect(m_vrect);
- }
- else if(!m_logo.IsNull() /*&& ((CMainFrame*)GetParentFrame())->IsPlaylistEmpty()*/)
- {
+ } else if(!m_logo.IsNull() /*&& ((CMainFrame*)GetParentFrame())->IsPlaylistEmpty()*/) {
BITMAP bm;
GetObject(m_logo, sizeof(bm), &bm);
GetClientRect(r);
int w = min(bm.bmWidth, r.Width());
int h = min(abs(bm.bmHeight), r.Height());
-// int w = min(m_logo.GetWidth(), r.Width());
-// int h = min(m_logo.GetHeight(), r.Height());
+ // int w = min(m_logo.GetWidth(), r.Width());
+ // int h = min(m_logo.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);
m_logo.StretchBlt(*pDC, r, CRect(0,0,bm.bmWidth,abs(bm.bmHeight)));
-// m_logo.Draw(*pDC, r);
+ // m_logo.Draw(*pDC, r);
pDC->SetStretchBltMode(oldmode);
pDC->ExcludeClipRect(r);
@@ -233,29 +229,34 @@ void CChildView::OnSize(UINT nType, int cx, int cy)
BOOL CChildView::OnPlayPlayPauseStop(UINT nID)
{
- if(nID == ID_PLAY_STOP) SetVideoRect();
+ 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);
+ if(i > 0) {
+ osd.Delete(i, osd.GetLength()-i);
+ }
CRect r1;
((CMainFrame*)AfxGetMainWnd())->GetClientRect(&r1);
- if((!r1.Width()) || (!r1.Height())) return FALSE;
+ if((!r1.Width()) || (!r1.Height())) {
+ return FALSE;
+ }
- if(!(((CMainFrame*)AfxGetMainWnd())->m_OpenFile))
+ 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)
- {
+ if(((CMainFrame*)GetParentFrame())->m_fHideCursor) {
SetCursor(NULL);
return TRUE;
}
- if(((CMainFrame*)GetParentFrame())->IsSomethingLoaded() && (nHitTest == HTCLIENT))
- {
+ if(((CMainFrame*)GetParentFrame())->IsSomethingLoaded() && (nHitTest == HTCLIENT)) {
::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_HAND));
return TRUE;
}
@@ -271,10 +272,10 @@ LRESULT CChildView::OnNcHitTest(CPoint point)
AppSettings& s = AfxGetAppSettings();
POSITION pos = s.wmcmds.GetHeadPosition();
while(pos && fLeftMouseBtnUnassigned)
- if(s.wmcmds.GetNext(pos).mouse == wmcmd::LDOWN)
+ if(s.wmcmds.GetNext(pos).mouse == wmcmd::LDOWN) {
fLeftMouseBtnUnassigned = false;
- if(!pFrame->m_fFullScreen && (pFrame->IsCaptionMenuHidden() || fLeftMouseBtnUnassigned))
- {
+ }
+ if(!pFrame->m_fFullScreen && (pFrame->IsCaptionMenuHidden() || fLeftMouseBtnUnassigned)) {
CRect rcClient, rcFrame;
GetWindowRect(&rcFrame);
rcClient = rcFrame;
@@ -284,44 +285,26 @@ LRESULT CChildView::OnNcHitTest(CPoint point)
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)
- {
+ if(rcFrame.PtInRect(point)) {
+ if(point.x > rcClient.right) {
+ if(point.y < rcClient.top) {
nHitTest = HTTOPRIGHT;
- }
- else if(point.y > rcClient.bottom)
- {
+ } else if(point.y > rcClient.bottom) {
nHitTest = HTBOTTOMRIGHT;
- }
- else
- {
+ } else {
nHitTest = HTRIGHT;
}
- }
- else if(point.x < rcClient.left)
- {
- if(point.y < rcClient.top)
- {
+ } else if(point.x < rcClient.left) {
+ if(point.y < rcClient.top) {
nHitTest = HTTOPLEFT;
- }
- else if(point.y > rcClient.bottom)
- {
+ } else if(point.y > rcClient.bottom) {
nHitTest = HTBOTTOMLEFT;
- }
- else
- {
+ } else {
nHitTest = HTLEFT;
}
- }
- else if(point.y < rcClient.top)
- {
+ } else if(point.y < rcClient.top) {
nHitTest = HTTOP;
- }
- else if(point.y > rcClient.bottom)
- {
+ } else if(point.y > rcClient.bottom) {
nHitTest = HTBOTTOM;
}
}
@@ -336,44 +319,40 @@ void CChildView::OnNcLButtonDown(UINT nHitTest, CPoint point)
AppSettings& s = AfxGetAppSettings();
POSITION pos = s.wmcmds.GetHeadPosition();
while(pos && fLeftMouseBtnUnassigned)
- if(s.wmcmds.GetNext(pos).mouse == wmcmd::LDOWN)
+ if(s.wmcmds.GetNext(pos).mouse == wmcmd::LDOWN) {
fLeftMouseBtnUnassigned = false;
- if(!pFrame->m_fFullScreen && (pFrame->IsCaptionMenuHidden() || fLeftMouseBtnUnassigned))
- {
+ }
+ if(!pFrame->m_fFullScreen && (pFrame->IsCaptionMenuHidden() || 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;
+ 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)
- {
+ if(bFlag) {
pFrame->PostMessage(WM_SYSCOMMAND, (SC_SIZE | bFlag), (LPARAM)POINTTOPOINTS(point));
- }
- else
- {
+ } else {
CWnd::OnNcLButtonDown(nHitTest, point);
}
}
diff --git a/src/apps/mplayerc/ChildView.h b/src/apps/mplayerc/ChildView.h
index 05cdf8c24..be8dabe6b 100644
--- a/src/apps/mplayerc/ChildView.h
+++ b/src/apps/mplayerc/ChildView.h
@@ -43,8 +43,7 @@ public:
public:
void SetVideoRect(CRect r = CRect(0,0,0,0));
- CRect GetVideoRect() const
- {
+ CRect GetVideoRect() const {
return(m_vrect);
}
diff --git a/src/apps/mplayerc/ComPropertyPage.cpp b/src/apps/mplayerc/ComPropertyPage.cpp
index 5cbd5bd44..90519a5a3 100644
--- a/src/apps/mplayerc/ComPropertyPage.cpp
+++ b/src/apps/mplayerc/ComPropertyPage.cpp
@@ -75,8 +75,7 @@ BOOL CComPropertyPage::OnSetActive()
SetModified(S_OK == m_pPage->IsPageDirty());
CWnd* pParent = GetParent();
- if(pParent->IsKindOf(RUNTIME_CLASS(CComPropertySheet)))
- {
+ if(pParent->IsKindOf(RUNTIME_CLASS(CComPropertySheet))) {
CComPropertySheet* pSheet = static_cast<CComPropertySheet*>(pParent);
pSheet->OnActivated(this);
}
@@ -101,7 +100,9 @@ END_MESSAGE_MAP()
void CComPropertyPage::OnOK()
{
- if(S_OK == m_pPage->IsPageDirty()) m_pPage->Apply();
+ if(S_OK == m_pPage->IsPageDirty()) {
+ m_pPage->Apply();
+ }
SetModified(FALSE);
CPropertyPage::OnOK();
diff --git a/src/apps/mplayerc/ComPropertyPage.h b/src/apps/mplayerc/ComPropertyPage.h
index e8fa04d64..ba09ab502 100644
--- a/src/apps/mplayerc/ComPropertyPage.h
+++ b/src/apps/mplayerc/ComPropertyPage.h
@@ -35,7 +35,7 @@ public:
CComPropertyPage(IPropertyPage* pPage);
virtual ~CComPropertyPage();
-// Dialog Data
+ // Dialog Data
enum { IDD = IDD_COMPROPERTYPAGE };
protected:
diff --git a/src/apps/mplayerc/ComPropertySheet.cpp b/src/apps/mplayerc/ComPropertySheet.cpp
index b1c6502c5..dc9c47fe8 100644
--- a/src/apps/mplayerc/ComPropertySheet.cpp
+++ b/src/apps/mplayerc/ComPropertySheet.cpp
@@ -38,35 +38,33 @@ public:
CComPropertyPageSite(IComPropertyPageDirty* pPPD) : CUnknown(NAME("CComPropertyPageSite"), NULL), m_pPPD(pPPD) {}
DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv)
- {
+ 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);
+ 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)
- {
+ STDMETHODIMP GetLocaleID(LCID* pLocaleID) {
CheckPointer(pLocaleID, E_POINTER);
*pLocaleID = ::GetUserDefaultLCID();
return S_OK;
}
- STDMETHODIMP GetPageContainer(IUnknown** ppUnk)
- {
+ STDMETHODIMP GetPageContainer(IUnknown** ppUnk) {
return E_NOTIMPL;
}
- STDMETHODIMP TranslateAccelerator(LPMSG pMsg)
- {
+ STDMETHODIMP TranslateAccelerator(LPMSG pMsg) {
return E_NOTIMPL;
}
};
@@ -94,16 +92,20 @@ 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)))
+ if(FAILED(pSPP->GetPages(&caGUID))) {
return(0);
+ }
IUnknown* lpUnk = NULL;
- if(FAILED(pSPP->QueryInterface(&lpUnk)))
+ if(FAILED(pSPP->QueryInterface(&lpUnk))) {
return(0);
+ }
m_spp.AddTail(pSPP);
@@ -111,35 +113,33 @@ int CComPropertySheet::AddPages(ISpecifyPropertyPages* pSPP)
CComQIPtr<IPersist> pPersist = pSPP;
ULONG nPages = 0;
- for(ULONG i = 0; i < caGUID.cElems; i++)
- {
+ for(ULONG i = 0; i < caGUID.cElems; i++) {
CComPtr<IPropertyPage> pPage;
HRESULT hr = E_FAIL;
- if(FAILED(hr) && !pPage && pSPP2)
- {
+ if(FAILED(hr) && !pPage && pSPP2) {
hr = pSPP2->CreatePage(caGUID.pElems[i], &pPage);
}
- if(FAILED(hr) && !pPage)
- {
+ if(FAILED(hr) && !pPage) {
hr = pPage.CoCreateInstance(caGUID.pElems[i]);
}
- if(FAILED(hr) && !pPage && pPersist)
- {
+ if(FAILED(hr) && !pPage && pPersist) {
hr = LoadExternalPropertyPage(pPersist, caGUID.pElems[i], &pPage);
}
- if(SUCCEEDED(hr))
- {
- if(AddPage(pPage, lpUnk))
+ if(SUCCEEDED(hr)) {
+ if(AddPage(pPage, lpUnk)) {
nPages++;
+ }
}
}
- if(caGUID.pElems) CoTaskMemFree(caGUID.pElems);
+ if(caGUID.pElems) {
+ CoTaskMemFree(caGUID.pElems);
+ }
lpUnk->Release();
return(nPages);
@@ -147,7 +147,9 @@ int CComPropertySheet::AddPages(ISpecifyPropertyPages* pSPP)
bool CComPropertySheet::AddPage(IPropertyPage* pPage, IUnknown* pUnk)
{
- if(!pPage || !pUnk) return false;
+ if(!pPage || !pUnk) {
+ return false;
+ }
HRESULT hr;
hr = pPage->SetPageSite(m_pSite);
@@ -165,7 +167,9 @@ bool CComPropertySheet::AddPage(IPropertyPage* pPage, IUnknown* pUnk)
void CComPropertySheet::OnActivated(CPropertyPage* pPage)
{
- if(!pPage) return;
+ if(!pPage) {
+ return;
+ }
CRect bounds(30000,30000,-30000,-30000);
@@ -180,14 +184,14 @@ void CComPropertySheet::OnActivated(CPropertyPage* pPage)
pTC->GetClientRect(tcr);
CSize tws = twr.Size(), tcs = tcr.Size();
- if(CWnd* pChild = pPage->GetWindow(GW_CHILD))
- {
+ 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;
+ for(CWnd* pGrandChild = pChild->GetWindow(GW_CHILD); pGrandChild; pGrandChild = pGrandChild->GetNextWindow()) {
+ if(!(pGrandChild->GetStyle()&WS_VISIBLE)) {
+ continue;
+ }
CRect r;
pGrandChild->GetWindowRect(&r);
@@ -208,10 +212,10 @@ void CComPropertySheet::OnActivated(CPropertyPage* pPage)
CSize diff = r.Size() - tws;
- if(!bounds.IsRectEmpty())
- {
- if(CWnd* pChild = pPage->GetWindow(GW_CHILD))
+ if(!bounds.IsRectEmpty()) {
+ if(CWnd* pChild = pPage->GetWindow(GW_CHILD)) {
pChild->MoveWindow(bounds);
+ }
CRect r = twr;
pTC->AdjustRect(FALSE, r);
ScreenToClient(r);
@@ -219,10 +223,8 @@ void CComPropertySheet::OnActivated(CPropertyPage* pPage)
}
int _afxPropSheetButtons[] = { IDOK, IDCANCEL, ID_APPLY_NOW, IDHELP };
- for(int i = 0; i < countof(_afxPropSheetButtons); i++)
- {
- if(CWnd* pWnd = GetDlgItem(_afxPropSheetButtons[i]))
- {
+ 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()));
@@ -245,8 +247,9 @@ BOOL CComPropertySheet::OnInitDialog()
{
BOOL bResult = (BOOL)Default();//CPropertySheet::OnInitDialog();
- if (!(GetStyle() & WS_CHILD))
+ if (!(GetStyle() & WS_CHILD)) {
CenterWindow();
+ }
return bResult;
}
diff --git a/src/apps/mplayerc/ComPropertySheet.h b/src/apps/mplayerc/ComPropertySheet.h
index 4508a45f8..f96044980 100644
--- a/src/apps/mplayerc/ComPropertySheet.h
+++ b/src/apps/mplayerc/ComPropertySheet.h
@@ -26,8 +26,7 @@
#include "ComPropertyPage.h"
-interface IComPropertyPageDirty
-{
+interface IComPropertyPageDirty {
virtual void OnSetDirty(bool fDirty) = 0;
};
@@ -53,9 +52,10 @@ public:
void OnActivated(CPropertyPage* pPage);
// IComPropertyPageDirty
- void OnSetDirty(bool fDirty)
- {
- if(CPropertyPage* p = GetActivePage()) p->SetModified(fDirty);
+ void OnSetDirty(bool fDirty) {
+ if(CPropertyPage* p = GetActivePage()) {
+ p->SetModified(fDirty);
+ }
}
virtual BOOL OnInitDialog();
diff --git a/src/apps/mplayerc/DVBChannel.cpp b/src/apps/mplayerc/DVBChannel.cpp
index 30f17449e..6a0d8bff4 100644
--- a/src/apps/mplayerc/DVBChannel.cpp
+++ b/src/apps/mplayerc/DVBChannel.cpp
@@ -58,10 +58,12 @@ void CDVBChannel::FromString(CString strValue)
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)
+ if (nVersion > FORMAT_VERSION_0) {
m_bEncrypted = _tstol(strValue.Tokenize(_T("|"), i));
- if (nVersion > FORMAT_VERSION_1)
+ }
+ 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));
@@ -70,20 +72,19 @@ void CDVBChannel::FromString(CString strValue)
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)
+ 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++)
- {
+ 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++)
- {
+ 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));
@@ -114,11 +115,13 @@ CString CDVBChannel::ToString()
m_nDefaultAudio,
m_nSubtitleCount);
- for(int i=0; i<m_nAudioCount; i++)
+ 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++)
+ 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;
}
@@ -132,34 +135,31 @@ void CDVBChannel::SetName(BYTE* Value)
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;
}
} \ No newline at end of file
diff --git a/src/apps/mplayerc/DVBChannel.h b/src/apps/mplayerc/DVBChannel.h
index 25d296b60..7a8937a69 100644
--- a/src/apps/mplayerc/DVBChannel.h
+++ b/src/apps/mplayerc/DVBChannel.h
@@ -30,8 +30,7 @@
#define DVB_MAX_AUDIO 10
#define DVB_MAX_SUBTITLE 10
-typedef enum
-{
+typedef enum {
DVB_MPV = 0x00,
DVB_H264 = 0x01,
DVB_MPA = 0x02,
@@ -47,15 +46,13 @@ typedef enum
} DVB_STREAM_TYPE;
-typedef struct
-{
+typedef struct {
ULONG PID;
DVB_STREAM_TYPE Type;
PES_STREAM_TYPE PesType;
CString Language;
- LCID GetLCID()
- {
+ LCID GetLCID() {
return ISO6392ToLcid(CStringA(Language));
};
} DVBStreamInfo;
@@ -69,147 +66,112 @@ public:
void FromString(CString strValue);
CString ToString();
- LPCTSTR GetName() const
- {
+ LPCTSTR GetName() const {
return m_strName;
};
- ULONG GetFrequency() const
- {
+ ULONG GetFrequency() const {
return m_ulFrequency;
};
- int GetPrefNumber() const
- {
+ int GetPrefNumber() const {
return m_nPrefNumber;
};
- int GetOriginNumber() const
- {
+ int GetOriginNumber() const {
return m_nOriginNumber;
};
- ULONG GetONID() const
- {
+ ULONG GetONID() const {
return m_ulONID;
};
- ULONG GetTSID() const
- {
+ ULONG GetTSID() const {
return m_ulTSID;
};
- ULONG GetSID() const
- {
+ ULONG GetSID() const {
return m_ulSID;
};
- ULONG GetPMT() const
- {
+ ULONG GetPMT() const {
return m_ulPMT;
};
- ULONG GetPCR() const
- {
+ ULONG GetPCR() const {
return m_ulPCR;
};
- ULONG GetVideoPID() const
- {
+ ULONG GetVideoPID() const {
return m_ulVideoPID;
};
- DVB_STREAM_TYPE GetVideoType() const
- {
+ DVB_STREAM_TYPE GetVideoType() const {
return m_nVideoType;
}
- ULONG GetDefaultAudioPID() const
- {
+ ULONG GetDefaultAudioPID() const {
return m_Audios[GetDefaultAudio()].PID;
};
- DVB_STREAM_TYPE GetDefaultAudioType() const
- {
+ DVB_STREAM_TYPE GetDefaultAudioType() const {
return m_Audios[0].Type;
}
- ULONG GetDefaultSubtitlePID() const
- {
+ ULONG GetDefaultSubtitlePID() const {
return m_Subtitles[0].PID; /* TODO : fa*/
};
- int GetAudioCount() const
- {
+ int GetAudioCount() const {
return m_nAudioCount;
};
- int GetDefaultAudio() const
- {
+ int GetDefaultAudio() const {
return m_nDefaultAudio;
};
- int GetSubtitleCount() const
- {
+ int GetSubtitleCount() const {
return m_nSubtitleCount;
};
- DVBStreamInfo* GetAudio(int nIndex)
- {
+ DVBStreamInfo* GetAudio(int nIndex) {
return &m_Audios[nIndex];
};
- DVBStreamInfo* GetSubtitle(int nIndex)
- {
+ DVBStreamInfo* GetSubtitle(int nIndex) {
return &m_Subtitles[nIndex];
};
- bool HasName()
- {
+ bool HasName() {
return !m_strName.IsEmpty();
};
- bool IsEncrypted()
- {
+ bool IsEncrypted() {
return m_bEncrypted;
};
- bool GetNowNextFlag()
- {
+ bool GetNowNextFlag() {
return m_bNowNextFlag;
};
void SetName(BYTE* Value);
- void SetName(LPCTSTR Value)
- {
+ void SetName(LPCTSTR Value) {
m_strName = Value;
};
- void SetFrequency(ULONG Value)
- {
+ void SetFrequency(ULONG Value) {
m_ulFrequency = Value;
};
- void SetPrefNumber(int Value)
- {
+ void SetPrefNumber(int Value) {
m_nPrefNumber = Value;
};
- void SetOriginNumber(int Value)
- {
+ void SetOriginNumber(int Value) {
m_nOriginNumber = m_nPrefNumber = Value;
};
- void SetEncrypted(bool Value)
- {
+ void SetEncrypted(bool Value) {
m_bEncrypted = Value;
};
- void SetNowNextFlag(bool Value)
- {
+ void SetNowNextFlag(bool Value) {
m_bNowNextFlag = Value;
};
- void SetONID(ULONG Value)
- {
+ void SetONID(ULONG Value) {
m_ulONID = Value;
};
- void SetTSID(ULONG Value)
- {
+ void SetTSID(ULONG Value) {
m_ulTSID = Value;
};
- void SetSID(ULONG Value)
- {
+ void SetSID(ULONG Value) {
m_ulSID = Value;
};
- void SetPMT(ULONG Value)
- {
+ void SetPMT(ULONG Value) {
m_ulPMT = Value;
};
- void SetPCR(ULONG Value)
- {
+ void SetPCR(ULONG Value) {
m_ulPCR = Value;
};
- void SetVideoPID(ULONG Value)
- {
+ void SetVideoPID(ULONG Value) {
m_ulVideoPID = Value;
};
- void SetDefaultAudio(int Value)
- {
+ void SetDefaultAudio(int Value) {
m_nDefaultAudio = Value;
}
diff --git a/src/apps/mplayerc/DeinterlacerFilter.cpp b/src/apps/mplayerc/DeinterlacerFilter.cpp
index b199d4e42..a6e531828 100644
--- a/src/apps/mplayerc/DeinterlacerFilter.cpp
+++ b/src/apps/mplayerc/DeinterlacerFilter.cpp
@@ -30,7 +30,9 @@
CDeinterlacerFilter::CDeinterlacerFilter(LPUNKNOWN punk, HRESULT* phr)
: CTransformFilter(NAME("CDeinterlacerFilter"), punk, __uuidof(CDeinterlacerFilter))
{
- if(phr) *phr = S_OK;
+ if(phr) {
+ *phr = S_OK;
+ }
}
HRESULT CDeinterlacerFilter::CheckConnect(PIN_DIRECTION dir, IPin* pPin)
@@ -41,8 +43,9 @@ HRESULT CDeinterlacerFilter::CheckConnect(PIN_DIRECTION dir, IPin* pPin)
HRESULT CDeinterlacerFilter::CheckInputType(const CMediaType* mtIn)
{
BITMAPINFOHEADER bih;
- if(!ExtractBIH(mtIn, &bih) /*|| bih.biHeight <= 0*/ || bih.biHeight <= 288)
+ 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
@@ -60,20 +63,21 @@ HRESULT CDeinterlacerFilter::Transform(IMediaSample* pIn, IMediaSample* pOut)
HRESULT hr;
AM_MEDIA_TYPE* pmt = NULL;
- if(SUCCEEDED(pOut->GetMediaType(&pmt)) && pmt)
- {
+ if(SUCCEEDED(pOut->GetMediaType(&pmt)) && pmt) {
CMediaType mt = *pmt;
m_pOutput->SetMediaType(&mt);
DeleteMediaType(pmt);
}
BYTE* pDataIn = NULL;
- if(FAILED(pIn->GetPointer(&pDataIn)) || !pDataIn)
+ if(FAILED(pIn->GetPointer(&pDataIn)) || !pDataIn) {
return S_FALSE;
+ }
BYTE* pDataOut = NULL;
- if(FAILED(hr = pOut->GetPointer(&pDataOut)) || !pDataOut)
+ if(FAILED(hr = pOut->GetPointer(&pDataOut)) || !pDataOut) {
return hr;
+ }
const CMediaType& mtIn = m_pInput->CurrentMediaType();
const CMediaType& mtOut = m_pOutput->CurrentMediaType();
@@ -91,18 +95,14 @@ HRESULT CDeinterlacerFilter::Transform(IMediaSample* pIn, IMediaSample* pOut)
int pitchIn = bihIn.biWidth*bppIn>>3;
int pitchOut = bihOut.biWidth*bppOut>>3;
BYTE* pDataOut2 = pDataOut;
- if(fFlip)
- {
+ if(fFlip) {
pDataOut2 += pitchOut*(bihIn.biHeight-1);
pitchOut = -pitchOut;
}
- if(mtIn.subtype == MEDIASUBTYPE_YUY2 || mtIn.subtype == MEDIASUBTYPE_UYVY)
- {
+ 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)
- {
+ } 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;
@@ -123,7 +123,9 @@ HRESULT CDeinterlacerFilter::Transform(IMediaSample* pIn, IMediaSample* pOut)
HRESULT CDeinterlacerFilter::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties)
{
- if(m_pInput->IsConnected() == FALSE) return E_UNEXPECTED;
+ if(m_pInput->IsConnected() == FALSE) {
+ return E_UNEXPECTED;
+ }
BITMAPINFOHEADER bih;
ExtractBIH(&m_pOutput->CurrentMediaType(), &bih);
@@ -135,8 +137,9 @@ HRESULT CDeinterlacerFilter::DecideBufferSize(IMemAllocator* pAllocator, ALLOCAT
HRESULT hr;
ALLOCATOR_PROPERTIES Actual;
- if(FAILED(hr = pAllocator->SetProperties(pProperties, &Actual)))
+ if(FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
return hr;
+ }
return pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer
? E_FAIL
@@ -145,9 +148,15 @@ HRESULT CDeinterlacerFilter::DecideBufferSize(IMemAllocator* pAllocator, ALLOCAT
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;
+ 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/apps/mplayerc/EditListEditor.cpp b/src/apps/mplayerc/EditListEditor.cpp
index 8518fefaa..061630170 100644
--- a/src/apps/mplayerc/EditListEditor.cpp
+++ b/src/apps/mplayerc/EditListEditor.cpp
@@ -45,30 +45,36 @@ void CClip::SetOut(LPCTSTR strVal)
void CClip::SetIn (REFERENCE_TIME rtVal)
{
m_rtIn = rtVal;
- if (m_rtIn > m_rtOut) m_rtOut = _I64_MIN;
+ if (m_rtIn > m_rtOut) {
+ m_rtOut = _I64_MIN;
+ }
};
void CClip::SetOut (REFERENCE_TIME rtVal)
{
m_rtOut = rtVal;
- if (m_rtIn > m_rtOut) m_rtIn = _I64_MIN;
+ if (m_rtIn > m_rtOut) {
+ m_rtIn = _I64_MIN;
+ }
};
CString CClip::GetIn()
{
- if (m_rtIn == _I64_MIN)
+ if (m_rtIn == _I64_MIN) {
return _T("");
- else
+ } else {
return ReftimeToString(m_rtIn);
+ }
}
CString CClip::GetOut()
{
- if (m_rtOut == _I64_MIN)
+ if (m_rtOut == _I64_MIN) {
return _T("");
- else
+ } else {
return ReftimeToString(m_rtOut);
+ }
}
@@ -104,8 +110,9 @@ END_MESSAGE_MAP()
BOOL CEditListEditor::Create(CWnd* pParentWnd)
{
- if(!CSizingControlBarG::Create(_T("Edit List Editor"), pParentWnd, ID_VIEW_EDITLISTEDITOR))
+ if(!CSizingControlBarG::Create(_T("Edit List Editor"), pParentWnd, ID_VIEW_EDITLISTEDITOR)) {
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);
@@ -144,8 +151,7 @@ void CEditListEditor::OnSize(UINT nType, int cx, int cy)
void CEditListEditor::ResizeListColumn()
{
- if(::IsWindow(m_list.m_hWnd))
- {
+ if(::IsWindow(m_list.m_hWnd)) {
CRect r;
GetClientRect(r);
r.DeflateRect(2, 2);
@@ -161,35 +167,29 @@ void CEditListEditor::ResizeListColumn()
void CEditListEditor::SaveEditListToFile()
{
- if ((m_bFileOpen || m_EditList.GetCount() >0) && !m_strFileName.IsEmpty())
- {
+ if ((m_bFileOpen || m_EditList.GetCount() >0) && !m_strFileName.IsEmpty()) {
CStdioFile EditListFile;
- if (EditListFile.Open (m_strFileName, CFile::modeCreate|CFile::modeWrite))
- {
+ if (EditListFile.Open (m_strFileName, CFile::modeCreate|CFile::modeWrite)) {
CString strLine;
int nIndex;
CString strUser;
CString strHotFolders;
nIndex = m_cbUsers.GetCurSel();
- if (nIndex >= 0)
- {
+ if (nIndex >= 0) {
m_cbUsers.GetLBText(nIndex, strUser);
}
nIndex = m_cbHotFolders.GetCurSel();
- if (nIndex >= 0)
- {
+ if (nIndex >= 0) {
m_cbHotFolders.GetLBText(nIndex, strHotFolders);
}
POSITION pos = m_EditList.GetHeadPosition();
- for(int i = 0; pos; i++, m_EditList.GetNext(pos))
- {
+ for(int i = 0; pos; i++, m_EditList.GetNext(pos)) {
CClip& CurClip = m_EditList.GetAt(pos);
- if (CurClip.HaveIn() && CurClip.HaveOut())
- {
+ 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);
}
@@ -221,11 +221,9 @@ void CEditListEditor::OpenFile(LPCTSTR lpFileName)
CloseFile();
m_strFileName.Format(_T("%s.edl"), lpFileName);
- if (EditListFile.Open (m_strFileName, CFile::modeRead))
- {
+ if (EditListFile.Open (m_strFileName, CFile::modeRead)) {
m_bFileOpen = true;
- while (EditListFile.ReadString(strLine))
- {
+ while (EditListFile.ReadString(strLine)) {
//int nPos = 0;
CString strIn; // = strLine.Tokenize(_T(" \t"), nPos);
CString strOut; // = strLine.Tokenize(_T(" \t"), nPos);
@@ -234,19 +232,16 @@ void CEditListEditor::OpenFile(LPCTSTR lpFileName)
AfxExtractSubString (strIn, strLine, 0, _T('\t'));
AfxExtractSubString (strOut, strLine, 1, _T('\t'));
AfxExtractSubString (strName, strLine, 2, _T('\t'));
- if (strUser.IsEmpty())
- {
+ if (strUser.IsEmpty()) {
AfxExtractSubString (strUser, strLine, 3, _T('\t'));
SelectCombo(strUser, m_cbUsers);
}
- if (strHotFolders.IsEmpty())
- {
+ if (strHotFolders.IsEmpty()) {
AfxExtractSubString (strHotFolders, strLine, 4, _T('\t'));
SelectCombo(strHotFolders, m_cbHotFolders);
}
- if (!strIn.IsEmpty() && !strOut.IsEmpty())
- {
+ if (!strIn.IsEmpty() && !strOut.IsEmpty()) {
CClip NewClip;
NewClip.SetIn (strIn);
NewClip.SetOut (strOut);
@@ -257,18 +252,15 @@ void CEditListEditor::OpenFile(LPCTSTR lpFileName)
}
EditListFile.Close();
- }
- else
+ } else {
m_bFileOpen = false;
+ }
- if (m_NameList.GetCount() == 0)
- {
+ if (m_NameList.GetCount() == 0) {
CStdioFile NameFile;
CString str;
- if (NameFile.Open (_T("EditListNames.txt"), CFile::modeRead))
- {
- while(NameFile.ReadString(str))
- {
+ if (NameFile.Open (_T("EditListNames.txt"), CFile::modeRead)) {
+ while(NameFile.ReadString(str)) {
m_NameList.Add(str);
}
NameFile.Close();
@@ -278,8 +270,7 @@ void CEditListEditor::OpenFile(LPCTSTR lpFileName)
void CEditListEditor::SetIn (REFERENCE_TIME rtIn)
{
- if (m_CurPos != NULL)
- {
+ if (m_CurPos != NULL) {
CClip& CurClip = m_EditList.GetAt (m_CurPos);
CurClip.SetIn (rtIn);
@@ -289,8 +280,7 @@ void CEditListEditor::SetIn (REFERENCE_TIME rtIn)
void CEditListEditor::SetOut(REFERENCE_TIME rtOut)
{
- if (m_CurPos != NULL)
- {
+ if (m_CurPos != NULL) {
CClip& CurClip = m_EditList.GetAt (m_CurPos);
CurClip.SetOut (rtOut);
@@ -302,14 +292,13 @@ void CEditListEditor::NewClip(REFERENCE_TIME rtVal)
{
CClip NewClip;
- if (m_CurPos != NULL)
- {
+ if (m_CurPos != NULL) {
CClip& CurClip = m_EditList.GetAt (m_CurPos);
- if (CurClip.HaveIn())
- {
- if (!CurClip.HaveOut())
+ if (CurClip.HaveIn()) {
+ if (!CurClip.HaveOut()) {
CurClip.SetOut (rtVal);
+ }
}
}
m_CurPos = InsertClip (m_CurPos, NewClip);
@@ -325,8 +314,7 @@ int CEditListEditor::FindIndex(POSITION pos)
{
int iItem = 0;
POSITION CurPos = m_EditList.GetHeadPosition();
- while (CurPos && CurPos != pos)
- {
+ while (CurPos && CurPos != pos) {
m_EditList.GetNext (CurPos);
iItem++;
}
@@ -338,10 +326,11 @@ POSITION CEditListEditor::InsertClip(POSITION pos, CClip& NewClip)
LVITEM lv;
POSITION NewClipPos;
- if (pos == NULL)
+ if (pos == NULL) {
NewClipPos = m_EditList.AddTail (NewClip);
- else
+ } else {
NewClipPos = m_EditList.InsertAfter (pos, NewClip);
+ }
lv.mask = LVIF_STATE | LVIF_TEXT;
lv.iItem = FindIndex (pos);
@@ -356,14 +345,15 @@ POSITION CEditListEditor::InsertClip(POSITION pos, CClip& NewClip)
void CEditListEditor::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
{
- if(nIDCtl != IDC_EDITLIST) return;
+ if(nIDCtl != IDC_EDITLIST) {
+ return;
+ }
int nItem = lpDrawItemStruct->itemID;
CRect rcItem = lpDrawItemStruct->rcItem;
POSITION pos = m_EditList.FindIndex(nItem);
- if (pos != NULL)
- {
+ if (pos != NULL) {
bool fSelected = (pos == m_CurPos);
UNUSED_ALWAYS(fSelected);
CClip& CurClip = m_EditList.GetAt(pos);
@@ -371,38 +361,35 @@ void CEditListEditor::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
- if(!!m_list.GetItemState(nItem, LVIS_SELECTED))
- {
+ if(!!m_list.GetItemState(nItem, LVIS_SELECTED)) {
FillRect(pDC->m_hDC, rcItem, CBrush(0xf1dacc));
FrameRect(pDC->m_hDC, rcItem, CBrush(0xc56a31));
- }
- else
- {
+ } 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);
+ if(!CurClip.HaveIn() || !CurClip.HaveOut()) {
+ textcolor = RGB(255,0,0);
+ }
- for (int i=0; i<COL_MAX; i++)
- {
+ 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;
+ 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;
}
}
}
@@ -412,8 +399,7 @@ void CEditListEditor::OnLvnItemchanged(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
- if(pNMLV->iItem >= 0)
- {
+ if(pNMLV->iItem >= 0) {
m_CurPos = m_EditList.FindIndex (pNMLV->iItem);
}
}
@@ -424,23 +410,21 @@ void CEditListEditor::OnLvnKeyDown(NMHDR* pNMHDR, LRESULT* pResult)
*pResult = FALSE;
- if(pLVKeyDown->wVKey == VK_DELETE)
- {
+ if(pLVKeyDown->wVKey == VK_DELETE) {
POSITION pos = m_list.GetFirstSelectedItemPosition();
POSITION ClipPos;
int nItem = -1;
- while(pos)
- {
+ while(pos) {
nItem = m_list.GetNextSelectedItem(pos);
ClipPos = m_EditList.FindIndex (nItem);
- if (ClipPos)
- {
+ if (ClipPos) {
m_EditList.RemoveAt (ClipPos);
}
m_list.DeleteItem (nItem);
}
- if (nItem != -1)
+ if (nItem != -1) {
m_list.SetItemState (min (nItem, m_list.GetItemCount()-1), LVIS_SELECTED, LVIS_SELECTED);
+ }
m_list.Invalidate();
}
}
@@ -468,8 +452,7 @@ void CEditListEditor::OnBeginDrag(NMHDR* pNMHDR, LRESULT* pResult)
void CEditListEditor::OnMouseMove(UINT nFlags, CPoint point)
{
- if(m_bDragging)
- {
+ if(m_bDragging) {
m_ptDropPoint = point;
ClientToScreen(&m_ptDropPoint);
@@ -485,15 +468,17 @@ void CEditListEditor::OnMouseMove(UINT nFlags, CPoint point)
int iTopItem = m_list.GetTopIndex();
int iBottomItem = m_list.GetBottomIndex();
- if(iOverItem == iTopItem && iTopItem != 0) // top of list
+ if(iOverItem == iTopItem && iTopItem != 0) { // top of list
SetTimer(1, 100, NULL);
- else
+ } else {
KillTimer(1);
+ }
- if(iOverItem >= iBottomItem && iBottomItem != (m_list.GetItemCount() - 1)) // bottom of list
+ if(iOverItem >= iBottomItem && iBottomItem != (m_list.GetItemCount() - 1)) { // bottom of list
SetTimer(2, 100, NULL);
- else
+ } else {
KillTimer(2);
+ }
}
}
@@ -505,21 +490,21 @@ void CEditListEditor::OnTimer(UINT_PTR nIDEvent)
int iTopItem = m_list.GetTopIndex();
int iBottomItem = iTopItem + m_list.GetCountPerPage() - 1;
- if(m_bDragging)
- {
+ if(m_bDragging) {
m_pDragImage->DragShowNolock(FALSE);
- if(nIDEvent == 1)
- {
+ if(nIDEvent == 1) {
m_list.EnsureVisible(iTopItem - 1, false);
m_list.UpdateWindow();
- if(m_list.GetTopIndex() == 0) KillTimer(1);
- }
- else if(nIDEvent == 2)
- {
+ 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(m_list.GetBottomIndex() == (m_list.GetItemCount() - 1)) {
+ KillTimer(2);
+ }
}
m_pDragImage->DragShowNolock(TRUE);
@@ -530,8 +515,7 @@ void CEditListEditor::OnTimer(UINT_PTR nIDEvent)
void CEditListEditor::OnLButtonUp(UINT nFlags, CPoint point)
{
- if(m_bDragging)
- {
+ if(m_bDragging) {
::ReleaseCapture();
m_bDragging = FALSE;
@@ -547,8 +531,9 @@ void CEditListEditor::OnLButtonUp(UINT nFlags, CPoint point)
CPoint pt(point);
ClientToScreen(&pt);
- if(WindowFromPoint(pt) == &m_list)
+ if(WindowFromPoint(pt) == &m_list) {
DropItemOnList();
+ }
}
ModifyStyle(0, WS_EX_ACCEPTFILES);
@@ -564,8 +549,7 @@ void CEditListEditor::DropItemOnList()
POSITION DragPos = m_EditList.FindIndex (m_nDragIndex);
POSITION DropPos = m_EditList.FindIndex (m_nDropIndex);
- if ((DragPos!=NULL) && (DropPos!=NULL))
- {
+ if ((DragPos!=NULL) && (DropPos!=NULL)) {
CClip& DragClip = m_EditList.GetAt(DragPos);
m_EditList.InsertAfter (DropPos, DragClip);
m_EditList.RemoveAt (DragPos);
@@ -580,11 +564,11 @@ void CEditListEditor::OnBeginlabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
*pResult = FALSE;
- if(pItem->iItem < 0)
+ if(pItem->iItem < 0) {
return;
+ }
- if(pItem->iSubItem == COL_NAME)
- {
+ if(pItem->iSubItem == COL_NAME) {
*pResult = TRUE;
}
}
@@ -596,17 +580,18 @@ void CEditListEditor::OnDolabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
*pResult = FALSE;
- if(pItem->iItem < 0)
+ if(pItem->iItem < 0) {
return;
+ }
- if (m_CurPos != NULL && pItem->iSubItem == COL_NAME)
- {
+ 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++)
+ 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;
@@ -620,16 +605,17 @@ void CEditListEditor::OnEndlabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
*pResult = FALSE;
- if(!m_list.m_fInPlaceDirty)
+ if(!m_list.m_fInPlaceDirty) {
return;
+ }
- if(pItem->iItem < 0)
+ if(pItem->iItem < 0) {
return;
+ }
CString& CurName = m_NameList.GetAt(pItem->lParam);
- if(m_CurPos != NULL && pItem->iSubItem == COL_NAME)
- {
+ if(m_CurPos != NULL && pItem->iSubItem == COL_NAME) {
CClip& CurClip = m_EditList.GetAt (m_CurPos);
CurClip.SetName(CurName);
@@ -641,12 +627,10 @@ int CEditListEditor::FindNameIndex(LPCTSTR strName)
{
int nResult = -1;
- for(int i = 0; i<m_NameList.GetCount(); i++)
- {
+ for(int i = 0; i<m_NameList.GetCount(); i++) {
CString& CurName = m_NameList.GetAt(i);
- if (CurName == strName)
- {
+ if (CurName == strName) {
nResult = i;
break;
}
@@ -659,12 +643,12 @@ void CEditListEditor::FillCombo(LPCTSTR strFileName, CComboBox& Combo, bool bAll
{
CStdioFile NameFile;
CString str;
- if (NameFile.Open (strFileName, CFile::modeRead))
- {
- if (bAllowNull) Combo.AddString(_T(""));
+ if (NameFile.Open (strFileName, CFile::modeRead)) {
+ if (bAllowNull) {
+ Combo.AddString(_T(""));
+ }
- while(NameFile.ReadString(str))
- {
+ while(NameFile.ReadString(str)) {
Combo.AddString(str);
}
NameFile.Close();
@@ -673,12 +657,10 @@ void CEditListEditor::FillCombo(LPCTSTR strFileName, CComboBox& Combo, bool bAll
void CEditListEditor::SelectCombo(LPCTSTR strValue, CComboBox& Combo)
{
- for (int i=0; i<Combo.GetCount(); i++)
- {
+ for (int i=0; i<Combo.GetCount(); i++) {
CString strTemp;
Combo.GetLBText(i, strTemp);
- if (strTemp == strValue)
- {
+ if (strTemp == strValue) {
Combo.SetCurSel(i);
break;
}
diff --git a/src/apps/mplayerc/EditListEditor.h b/src/apps/mplayerc/EditListEditor.h
index de72a9735..717ec70e8 100644
--- a/src/apps/mplayerc/EditListEditor.h
+++ b/src/apps/mplayerc/EditListEditor.h
@@ -35,12 +35,10 @@ public :
CClip();
- bool HaveIn()
- {
+ bool HaveIn() {
return m_rtIn != _I64_MIN;
};
- bool HaveOut()
- {
+ bool HaveOut() {
return m_rtOut != _I64_MIN;
};
@@ -48,15 +46,13 @@ public :
void SetIn (LPCTSTR strVal);
void SetIn (REFERENCE_TIME rtVal);
void SetOut (REFERENCE_TIME rtVal);
- void SetName(LPCTSTR strName)
- {
+ void SetName(LPCTSTR strName) {
m_strName = strName;
};
CString GetIn();
CString GetOut();
- CString GetName() const
- {
+ CString GetName() const {
return m_strName;
};
};
diff --git a/src/apps/mplayerc/FGFilter.cpp b/src/apps/mplayerc/FGFilter.cpp
index 3c44dfa66..1dd22af4c 100644
--- a/src/apps/mplayerc/FGFilter.cpp
+++ b/src/apps/mplayerc/FGFilter.cpp
@@ -62,29 +62,25 @@ void CFGFilter::AddType(const GUID& majortype, const GUID& subtype)
bool CFGFilter::CheckTypes(const CAtlArray<GUID>& types, bool fExactMatch)
{
POSITION pos = m_types.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
const GUID& majortype = m_types.GetNext(pos);
- if(!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)
- {
+ 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)
+ && subtype == types[i+1] && subtype != GUID_NULL) {
return true;
- }
- else
- {
+ }
+ } else {
if((majortype == GUID_NULL || types[i] == GUID_NULL || majortype == types[i])
- && (subtype == GUID_NULL || types[i+1] == GUID_NULL || subtype == types[i+1]))
+ && (subtype == GUID_NULL || types[i+1] == GUID_NULL || subtype == types[i+1])) {
return true;
+ }
}
}
}
@@ -100,34 +96,33 @@ CFGFilterRegistry::CFGFilterRegistry(IMoniker* pMoniker, UINT64 merit)
: CFGFilter(GUID_NULL, L"", merit)
, m_pMoniker(pMoniker)
{
- if(!m_pMoniker) return;
+ if(!m_pMoniker) {
+ return;
+ }
LPOLESTR str = NULL;
- if(FAILED(m_pMoniker->GetDisplayName(0, 0, &str))) return;
+ if(FAILED(m_pMoniker->GetDisplayName(0, 0, &str))) {
+ return;
+ }
m_DisplayName = m_name = str;
CoTaskMemFree(str), str = NULL;
CComPtr<IPropertyBag> pPB;
- if(SUCCEEDED(m_pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB)))
- {
+ if(SUCCEEDED(m_pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB))) {
CComVariant var;
- if(SUCCEEDED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL)))
- {
+ if(SUCCEEDED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL))) {
m_name = var.bstrVal;
var.Clear();
}
- if(SUCCEEDED(pPB->Read(CComBSTR(_T("CLSID")), &var, NULL)))
- {
+ 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)))
- {
+ if(SUCCEEDED(pPB->Read(CComBSTR(_T("FilterData")), &var, NULL))) {
BSTR* pstr;
- if(SUCCEEDED(SafeArrayAccessData(var.parray, (void**)&pstr)))
- {
+ if(SUCCEEDED(SafeArrayAccessData(var.parray, (void**)&pstr))) {
ExtractFilterData((BYTE*)pstr, var.parray->cbElements*(var.parray->rgsabound[0].cElements));
SafeArrayUnaccessData(var.parray);
}
@@ -136,43 +131,43 @@ CFGFilterRegistry::CFGFilterRegistry(IMoniker* pMoniker, UINT64 merit)
}
}
- if(merit != MERIT64_DO_USE) m_merit.val = merit;
+ if(merit != MERIT64_DO_USE) {
+ m_merit.val = merit;
+ }
}
CFGFilterRegistry::CFGFilterRegistry(CStringW DisplayName, UINT64 merit)
: CFGFilter(GUID_NULL, L"", merit)
, m_DisplayName(DisplayName)
{
- if(m_DisplayName.IsEmpty()) return;
+ if(m_DisplayName.IsEmpty()) {
+ return;
+ }
CComPtr<IBindCtx> pBC;
CreateBindCtx(0, &pBC);
ULONG chEaten;
- if(S_OK != MkParseDisplayName(pBC, CComBSTR(m_DisplayName), &chEaten, &m_pMoniker))
+ if(S_OK != MkParseDisplayName(pBC, CComBSTR(m_DisplayName), &chEaten, &m_pMoniker)) {
return;
+ }
CComPtr<IPropertyBag> pPB;
- if(SUCCEEDED(m_pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB)))
- {
+ if(SUCCEEDED(m_pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB))) {
CComVariant var;
- if(SUCCEEDED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL)))
- {
+ if(SUCCEEDED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL))) {
m_name = var.bstrVal;
var.Clear();
}
- if(SUCCEEDED(pPB->Read(CComBSTR(_T("CLSID")), &var, NULL)))
- {
+ 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)))
- {
+ if(SUCCEEDED(pPB->Read(CComBSTR(_T("FilterData")), &var, NULL))) {
BSTR* pstr;
- if(SUCCEEDED(SafeArrayAccessData(var.parray, (void**)&pstr)))
- {
+ if(SUCCEEDED(SafeArrayAccessData(var.parray, (void**)&pstr))) {
ExtractFilterData((BYTE*)pstr, var.parray->cbElements*(var.parray->rgsabound[0].cElements));
SafeArrayUnaccessData(var.parray);
}
@@ -181,26 +176,27 @@ CFGFilterRegistry::CFGFilterRegistry(CStringW DisplayName, UINT64 merit)
}
}
- if(merit != MERIT64_DO_USE) m_merit.val = merit;
+ if(merit != MERIT64_DO_USE) {
+ m_merit.val = merit;
+ }
}
CFGFilterRegistry::CFGFilterRegistry(const CLSID& clsid, UINT64 merit)
: CFGFilter(clsid, L"", merit)
{
- if(m_clsid == GUID_NULL) return;
+ 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))
- {
+ if(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("CLSID\\") + guid, KEY_READ)) {
ULONG nChars = 0;
- if(ERROR_SUCCESS == key.QueryStringValue(NULL, NULL, &nChars))
- {
+ if(ERROR_SUCCESS == key.QueryStringValue(NULL, NULL, &nChars)) {
CString name;
- if(ERROR_SUCCESS == key.QueryStringValue(NULL, name.GetBuffer(nChars), &nChars))
- {
+ if(ERROR_SUCCESS == key.QueryStringValue(NULL, name.GetBuffer(nChars), &nChars)) {
name.ReleaseBuffer(nChars);
m_name = name;
}
@@ -211,48 +207,40 @@ CFGFilterRegistry::CFGFilterRegistry(const CLSID& clsid, UINT64 merit)
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))
- {
+ 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))
- {
+ 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)
+ if(ERROR_SUCCESS == key.QueryStringValue(_T("CLSID"), clsid, &len) && GUIDFromCString(clsid) == m_clsid) {
break;
+ }
key.Close();
}
}
}
- if(key)
- {
+ if(key) {
ULONG nChars = 0;
- if(ERROR_SUCCESS == key.QueryStringValue(_T("FriendlyName"), NULL, &nChars))
- {
+ if(ERROR_SUCCESS == key.QueryStringValue(_T("FriendlyName"), NULL, &nChars)) {
CString name;
- if(ERROR_SUCCESS == key.QueryStringValue(_T("FriendlyName"), name.GetBuffer(nChars), &nChars))
- {
+ 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))
- {
+ if(ERROR_SUCCESS == key.QueryBinaryValue(_T("FilterData"), NULL, &nBytes)) {
CAutoVectorPtr<BYTE> buff;
- if(buff.Allocate(nBytes) && ERROR_SUCCESS == key.QueryBinaryValue(_T("FilterData"), buff, &nBytes))
- {
+ if(buff.Allocate(nBytes) && ERROR_SUCCESS == key.QueryBinaryValue(_T("FilterData"), buff, &nBytes)) {
ExtractFilterData(buff, nBytes);
}
}
@@ -261,7 +249,9 @@ CFGFilterRegistry::CFGFilterRegistry(const CLSID& clsid, UINT64 merit)
}
}
- if(merit != MERIT64_DO_USE) m_merit.val = merit;
+ if(merit != MERIT64_DO_USE) {
+ m_merit.val = merit;
+ }
}
HRESULT CFGFilterRegistry::Create(IBaseFilter** ppBF, CInterfaceList<IUnknown, &IID_IUnknown>& pUnks)
@@ -270,19 +260,16 @@ HRESULT CFGFilterRegistry::Create(IBaseFilter** ppBF, CInterfaceList<IUnknown, &
HRESULT hr = E_FAIL;
- if(m_pMoniker)
- {
- if(SUCCEEDED(hr = m_pMoniker->BindToObject(0, 0, IID_IBaseFilter, (void**)ppBF)))
- {
+ 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)
- {
+ } else if(m_clsid != GUID_NULL) {
CComQIPtr<IBaseFilter> pBF;
- if(FAILED(pBF.CoCreateInstance(m_clsid)))
+ if(FAILED(pBF.CoCreateInstance(m_clsid))) {
return E_FAIL;
+ }
*ppBF = pBF.Detach();
@@ -294,8 +281,7 @@ HRESULT CFGFilterRegistry::Create(IBaseFilter** ppBF, CInterfaceList<IUnknown, &
interface __declspec(uuid("97f7c4d4-547b-4a5f-8332-536430ad2e4d"))
IAMFilterData :
-public IUnknown
-{
+public IUnknown {
STDMETHOD (ParseFilterData) (BYTE* rgbFilterData, ULONG cb, BYTE** prgbRegFilter2) PURE;
STDMETHOD (CreateFilterData) (REGFILTER2* prf2, BYTE** prgbFilterData, ULONG* pcb) PURE;
};
@@ -306,40 +292,36 @@ void CFGFilterRegistry::ExtractFilterData(BYTE* p, UINT len)
BYTE* ptr = NULL;
if(SUCCEEDED(pFD.CoCreateInstance(CLSID_FilterMapper2))
- && SUCCEEDED(pFD->ParseFilterData(p, len, (BYTE**)&ptr)))
- {
+ && 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)
+ 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)
+ 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)
+ } 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)
+ 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);
@@ -348,15 +330,15 @@ void CFGFilterRegistry::ExtractFilterData(BYTE* p, UINT len)
}
CoTaskMemFree(prf);
- }
- else
- {
+ } 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
+ if(*(DWORD*)p != 0x00000002) {
+ return; // only version 2 supported, no samples found for 1
+ }
p += 4;
ChkLen(4)
@@ -368,8 +350,7 @@ void CFGFilterRegistry::ExtractFilterData(BYTE* p, UINT len)
ChkLen(8)
DWORD nPins = *(DWORD*)p;
p += 8;
- while(nPins-- > 0)
- {
+ while(nPins-- > 0) {
ChkLen(1)
BYTE n = *p-0x30;
p++;
@@ -392,8 +373,7 @@ void CFGFilterRegistry::ExtractFilterData(BYTE* p, UINT len)
ChkLen(12)
DWORD nTypes = *(DWORD*)p;
p += 12;
- while(nTypes-- > 0)
- {
+ while(nTypes-- > 0) {
ChkLen(1)
BYTE n = *p-0x30;
p++;
@@ -412,8 +392,7 @@ void CFGFilterRegistry::ExtractFilterData(BYTE* p, UINT len)
ChkLen(8)
if(*(DWORD*)p < (p-base+8) || *(DWORD*)p >= len
- || *(DWORD*)(p+4) < (p-base+8) || *(DWORD*)(p+4) >= len)
- {
+ || *(DWORD*)(p+4) < (p-base+8) || *(DWORD*)(p+4) >= len) {
p += 8;
continue;
}
@@ -421,7 +400,9 @@ void CFGFilterRegistry::ExtractFilterData(BYTE* p, UINT len)
GUID majortype, subtype;
memcpy(&majortype, &base[*(DWORD*)p], sizeof(GUID));
p += 4;
- if(!fOutput) AddType(majortype, subtype);
+ if(!fOutput) {
+ AddType(majortype, subtype);
+ }
}
}
@@ -472,31 +453,23 @@ HRESULT CFGFilterVideoRenderer::Create(IBaseFilter** ppBF, CInterfaceList<IUnkno
|| m_clsid == CLSID_DXRAllocatorPresenter
|| m_clsid == CLSID_madVRAllocatorPresenter
|| m_clsid == CLSID_EVRAllocatorPresenter
- || m_clsid == CLSID_SyncAllocatorPresenter)
- {
+ || 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)))
- {
+ || SUCCEEDED(CreateSyncRenderer(m_clsid, m_hWnd, bFullscreen, &pCAP))) {
CComPtr<IUnknown> pRenderer;
- if(SUCCEEDED(hr = pCAP->CreateRenderer(&pRenderer)))
- {
+ if(SUCCEEDED(hr = pCAP->CreateRenderer(&pRenderer))) {
*ppBF = CComQIPtr<IBaseFilter>(pRenderer).Detach();
pUnks.AddTail(pCAP);
}
}
- }
- else
- {
+ } else {
CComPtr<IBaseFilter> pBF;
- if(SUCCEEDED(pBF.CoCreateInstance(m_clsid)))
- {
- BeginEnumPins(pBF, pEP, pPin)
- {
- if(CComQIPtr<IMixerPinConfig, &IID_IMixerPinConfig> pMPC = pPin)
- {
+ if(SUCCEEDED(pBF.CoCreateInstance(m_clsid))) {
+ BeginEnumPins(pBF, pEP, pPin) {
+ if(CComQIPtr<IMixerPinConfig, &IID_IMixerPinConfig> pMPC = pPin) {
pUnks.AddTail(pMPC);
break;
}
@@ -507,7 +480,9 @@ HRESULT CFGFilterVideoRenderer::Create(IBaseFilter** ppBF, CInterfaceList<IUnkno
}
}
- if(!*ppBF) hr = E_FAIL;
+ if(!*ppBF) {
+ hr = E_FAIL;
+ }
return hr;
}
@@ -527,10 +502,11 @@ CFGFilterList::~CFGFilterList()
void CFGFilterList::RemoveAll()
{
- while(!m_filters.IsEmpty())
- {
+ while(!m_filters.IsEmpty()) {
const filter_t& f = m_filters.RemoveHead();
- if(f.autodelete) delete f.pFGF;
+ if(f.autodelete) {
+ delete f.pFGF;
+ }
}
m_sortedfilters.RemoveAll();
@@ -538,25 +514,25 @@ void CFGFilterList::RemoveAll()
void CFGFilterList::Insert(CFGFilter* pFGF, int group, bool exactmatch, bool autodelete)
{
- if(CFGFilterRegistry* f1r = dynamic_cast<CFGFilterRegistry*>(pFGF))
- {
+ if(CFGFilterRegistry* f1r = dynamic_cast<CFGFilterRegistry*>(pFGF)) {
POSITION pos = m_filters.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
filter_t& f2 = m_filters.GetNext(pos);
- if(group != f2.group) continue;
+ if(group != f2.group) {
+ continue;
+ }
- if(CFGFilterRegistry* f2r = dynamic_cast<CFGFilterRegistry*>(f2.pFGF))
- {
+ 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())
- {
+ || 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;
+ if(autodelete) {
+ delete pFGF;
+ }
return;
}
}
@@ -564,15 +540,15 @@ void CFGFilterList::Insert(CFGFilter* pFGF, int group, bool exactmatch, bool aut
}
POSITION pos = m_filters.GetHeadPosition();
- while(pos)
- {
- if(m_filters.GetNext(pos).pFGF == pFGF)
- {
+ 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;
+ if(autodelete) {
+ delete pFGF;
+ }
return;
}
}
@@ -589,23 +565,24 @@ void CFGFilterList::Insert(CFGFilter* pFGF, int group, bool exactmatch, bool aut
POSITION CFGFilterList::GetHeadPosition()
{
- if(m_sortedfilters.IsEmpty())
- {
+ 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);
+ 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)
+ if(sort[i].pFGF->GetMerit() >= MERIT64_DO_USE) {
m_sortedfilters.AddTail(sort[i].pFGF);
+ }
}
TRACE(_T("FGM: Sorting filters\n"));
POSITION pos = m_sortedfilters.GetHeadPosition();
- while(pos)
- {
+ 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()));
}
@@ -623,26 +600,45 @@ 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->group < fb->group) {
+ return -1;
+ }
+ if(fa->group > fb->group) {
+ return +1;
+ }
- if(fa->pFGF->GetCLSID() == fb->pFGF->GetCLSID())
- {
+ 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(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->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->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;
+ if(fa->index < fb->index) {
+ return -1;
+ }
+ if(fa->index > fb->index) {
+ return +1;
+ }
return 0;
}
diff --git a/src/apps/mplayerc/FGFilter.h b/src/apps/mplayerc/FGFilter.h
index 020c130bb..b87494a4e 100644
--- a/src/apps/mplayerc/FGFilter.h
+++ b/src/apps/mplayerc/FGFilter.h
@@ -37,13 +37,10 @@ class CFGFilter
protected:
CLSID m_clsid;
CStringW m_name;
- struct
- {
- union
- {
+ struct {
+ union {
UINT64 val;
- struct
- {
+ struct {
UINT64 low:16, mid:32, high:16;
};
};
@@ -54,20 +51,16 @@ public:
CFGFilter(const CLSID& clsid, CStringW name = L"", UINT64 merit = MERIT64_DO_USE);
virtual ~CFGFilter() {}
- CLSID GetCLSID() const
- {
+ CLSID GetCLSID() const {
return m_clsid;
}
- CStringW GetName() const
- {
+ CStringW GetName() const {
return m_name;
}
- UINT64 GetMerit() const
- {
+ UINT64 GetMerit() const {
return m_merit.val;
}
- DWORD GetMeritForDirectShow() const
- {
+ DWORD GetMeritForDirectShow() const {
return m_merit.mid;
}
const CAtlList<GUID>& GetTypes() const;
@@ -93,12 +86,10 @@ public:
CFGFilterRegistry(CStringW DisplayName, UINT64 merit = MERIT64_DO_USE);
CFGFilterRegistry(const CLSID& clsid, UINT64 merit = MERIT64_DO_USE);
- CStringW GetDisplayName()
- {
+ CStringW GetDisplayName() {
return m_DisplayName;
}
- IMoniker* GetMoniker()
- {
+ IMoniker* GetMoniker() {
return m_pMoniker;
}
@@ -111,13 +102,14 @@ class CFGFilterInternal : public CFGFilter
public:
CFGFilterInternal(CStringW name = L"", UINT64 merit = MERIT64_DO_USE) : CFGFilter(__uuidof(T), name, merit) {}
- HRESULT Create(IBaseFilter** ppBF, CInterfaceList<IUnknown, &IID_IUnknown>& pUnks)
- {
+ 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;
+ if(FAILED(hr)) {
+ return hr;
+ }
*ppBF = pBF.Detach();
@@ -150,8 +142,7 @@ public:
class CFGFilterList
{
- struct filter_t
- {
+ struct filter_t {
int index;
CFGFilter* pFGF;
int group;
@@ -165,8 +156,7 @@ public:
CFGFilterList();
virtual ~CFGFilterList();
- bool IsEmpty()
- {
+ bool IsEmpty() {
return m_filters.IsEmpty();
}
void RemoveAll();
diff --git a/src/apps/mplayerc/FGManager.cpp b/src/apps/mplayerc/FGManager.cpp
index 8eab59b65..59bcc2260 100644
--- a/src/apps/mplayerc/FGManager.cpp
+++ b/src/apps/mplayerc/FGManager.cpp
@@ -55,9 +55,15 @@ CFGManager::CFGManager(LPCTSTR pName, LPUNKNOWN pUnk)
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();
+ 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();
}
@@ -92,13 +98,15 @@ bool CFGManager::CStreamPath::Compare(const CStreamPath& path)
POSITION pos1 = GetHeadPosition();
POSITION pos2 = path.GetHeadPosition();
- while(pos1 && 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;
@@ -111,16 +119,16 @@ bool CFGManager::CheckBytes(HANDLE hFile, CString chkbytes)
CAtlList<CString> sl;
Explode(chkbytes, sl, ',');
- if(sl.GetCount() < 4)
+ if(sl.GetCount() < 4) {
return false;
+ }
ASSERT(!(sl.GetCount()&3));
LARGE_INTEGER size = {0, 0};
size.LowPart = GetFileSize(hFile, (DWORD*)&size.HighPart);
- while(sl.GetCount() >= 4)
- {
+ while(sl.GetCount() >= 4) {
CString offsetstr = sl.RemoveHead();
CString cbstr = sl.RemoveHead();
CString maskstr = sl.RemoveHead();
@@ -130,28 +138,32 @@ bool CFGManager::CheckBytes(HANDLE hFile, CString chkbytes)
if(offsetstr.IsEmpty() || cbstr.IsEmpty()
|| valstr.IsEmpty() || (valstr.GetLength() & 1)
- || cb*2 != valstr.GetLength())
+ || cb*2 != valstr.GetLength()) {
return false;
+ }
LARGE_INTEGER offset;
offset.QuadPart = _ttoi64(offsetstr);
- if(offset.QuadPart < 0) offset.QuadPart = size.QuadPart - offset.QuadPart;
+ if(offset.QuadPart < 0) {
+ offset.QuadPart = size.QuadPart - offset.QuadPart;
+ }
SetFilePointer(hFile, offset.LowPart, &offset.HighPart, FILE_BEGIN);
// LAME
- while(maskstr.GetLength() < valstr.GetLength())
+ 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++)
- {
+ 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])
+ if(!ReadFile(hFile, &b, 1, &r, NULL) || (b & mask[i]) != val[i]) {
return false;
+ }
}
}
@@ -172,52 +184,43 @@ HRESULT CFGManager::EnumSourceFilters(LPCWSTR lpcwstrFileName, CFGFilterList& fl
HANDLE hFile = INVALID_HANDLE_VALUE;
- if(protocol.GetLength() <= 1 || protocol == L"file")
- {
+ 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)
- {
+ if(hFile == INVALID_HANDLE_VALUE) {
return VFW_E_NOT_FOUND;
}
}
// exceptions first
- if(ext == _T(".dvr-ms") || ext == _T(".wtv")) // doh, this is stupid
- {
+ if(ext == _T(".dvr-ms") || ext == _T(".wtv")) { // doh, this is stupid
fl.Insert(DNew CFGFilterRegistry(CLSID_StreamBufferSource, MERIT64_PREFERRED), 0);
}
TCHAR buff[256], buff2[256];
ULONG len, len2;
- if(hFile == INVALID_HANDLE_VALUE)
- {
+ if(hFile == INVALID_HANDLE_VALUE) {
// internal / protocol
POSITION pos = m_source.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CFGFilter* pFGF = m_source.GetNext(pos);
- if(pFGF->m_protocols.Find(CString(protocol)))
+ if(pFGF->m_protocols.Find(CString(protocol))) {
fl.Insert(pFGF, 0, false, false);
+ }
}
- }
- else
- {
+ } else {
// internal / check bytes
POSITION pos = m_source.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CFGFilter* pFGF = m_source.GetNext(pos);
POSITION pos2 = pFGF->m_chkbytes.GetHeadPosition();
- while(pos2)
- {
- if(CheckBytes(hFile, pFGF->m_chkbytes.GetNext(pos2)))
- {
+ while(pos2) {
+ if(CheckBytes(hFile, pFGF->m_chkbytes.GetNext(pos2))) {
fl.Insert(pFGF, 1, false, false);
break;
}
@@ -225,16 +228,15 @@ HRESULT CFGManager::EnumSourceFilters(LPCWSTR lpcwstrFileName, CFGFilterList& fl
}
}
- if(!ext.IsEmpty())
- {
+ if(!ext.IsEmpty()) {
// internal / file extension
POSITION pos = m_source.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CFGFilter* pFGF = m_source.GetNext(pos);
- if(pFGF->m_extensions.Find(CString(ext)))
+ if(pFGF->m_extensions.Find(CString(ext))) {
fl.Insert(pFGF, 2, false, false);
+ }
}
}
@@ -242,67 +244,62 @@ HRESULT CFGManager::EnumSourceFilters(LPCWSTR lpcwstrFileName, CFGFilterList& fl
// internal / the rest
POSITION pos = m_source.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CFGFilter* pFGF = m_source.GetNext(pos);
- if(pFGF->m_protocols.IsEmpty() && pFGF->m_chkbytes.IsEmpty() && pFGF->m_extensions.IsEmpty())
+ if(pFGF->m_protocols.IsEmpty() && pFGF->m_chkbytes.IsEmpty() && pFGF->m_extensions.IsEmpty()) {
fl.Insert(pFGF, 3, false, false);
+ }
}
}
- if(hFile == INVALID_HANDLE_VALUE)
- {
+ if(hFile == INVALID_HANDLE_VALUE) {
// protocol
CRegKey key;
- if(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, CString(protocol), KEY_READ))
- {
+ if(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, CString(protocol), KEY_READ)) {
CRegKey exts;
- if(ERROR_SUCCESS == exts.Open(key, _T("Extensions"), KEY_READ))
- {
+ if(ERROR_SUCCESS == exts.Open(key, _T("Extensions"), KEY_READ)) {
len = countof(buff);
- if(ERROR_SUCCESS == exts.QueryStringValue(CString(ext), buff, &len))
+ if(ERROR_SUCCESS == exts.QueryStringValue(CString(ext), buff, &len)) {
fl.Insert(DNew CFGFilterRegistry(GUIDFromCString(buff)), 4);
+ }
}
len = countof(buff);
- if(ERROR_SUCCESS == key.QueryStringValue(_T("Source Filter"), buff, &len))
+ if(ERROR_SUCCESS == key.QueryStringValue(_T("Source Filter"), buff, &len)) {
fl.Insert(DNew CFGFilterRegistry(GUIDFromCString(buff)), 5);
+ }
}
fl.Insert(DNew CFGFilterRegistry(CLSID_URLReader), 6);
- }
- else
- {
+ } else {
// check bytes
CRegKey key;
- if(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("Media Type"), KEY_READ))
- {
+ 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))
- {
+ for(DWORD i = 0; ERROR_SUCCESS == key.EnumKey(i, buff, &len, &ft); i++, len = countof(buff)) {
GUID majortype;
- if(FAILED(GUIDFromCString(buff, majortype)))
+ if(FAILED(GUIDFromCString(buff, majortype))) {
continue;
+ }
CRegKey majorkey;
- if(ERROR_SUCCESS == majorkey.Open(key, buff, KEY_READ))
- {
+ 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))
- {
+ for(DWORD j = 0; ERROR_SUCCESS == majorkey.EnumKey(j, buff, &len, &ft); j++, len = countof(buff)) {
GUID subtype;
- if(FAILED(GUIDFromCString(buff, subtype)))
+ if(FAILED(GUIDFromCString(buff, subtype))) {
continue;
+ }
CRegKey subkey;
- if(ERROR_SUCCESS == subkey.Open(majorkey, buff, KEY_READ))
- {
+ if(ERROR_SUCCESS == subkey.Open(majorkey, buff, KEY_READ)) {
len = countof(buff);
- if(ERROR_SUCCESS != subkey.QueryStringValue(_T("Source Filter"), buff, &len))
+ if(ERROR_SUCCESS != subkey.QueryStringValue(_T("Source Filter"), buff, &len)) {
continue;
+ }
GUID clsid = GUIDFromCString(buff);
@@ -310,10 +307,8 @@ HRESULT CFGManager::EnumSourceFilters(LPCWSTR lpcwstrFileName, CFGFilterList& fl
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)))
- {
+ k++, len = countof(buff), len2 = sizeof(buff2)) {
+ if(CheckBytes(hFile, CString(buff))) {
CFGFilter* pFGF = DNew CFGFilterRegistry(clsid);
pFGF->AddType(majortype, subtype);
fl.Insert(pFGF, 9);
@@ -327,29 +322,28 @@ HRESULT CFGManager::EnumSourceFilters(LPCWSTR lpcwstrFileName, CFGFilterList& fl
}
}
- if(!ext.IsEmpty())
- {
+ if(!ext.IsEmpty()) {
// file extension
CRegKey key;
- if(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("Media Type\\Extensions\\") + CString(ext), KEY_READ))
- {
+ 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)
- {
+ 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))
+ 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))
+ if(ERROR_SUCCESS == key.QueryStringValue(_T("Subtype"), buff, &len)) {
subtype = GUIDFromCString(buff);
+ }
CFGFilter* pFGF = DNew CFGFilterRegistry(clsid);
pFGF->AddType(majortype, subtype);
@@ -358,8 +352,7 @@ HRESULT CFGManager::EnumSourceFilters(LPCWSTR lpcwstrFileName, CFGFilterList& fl
}
}
- if(hFile != INVALID_HANDLE_VALUE)
- {
+ if(hFile != INVALID_HANDLE_VALUE) {
CloseHandle(hFile);
}
@@ -383,36 +376,37 @@ HRESULT CFGManager::AddSourceFilter(CFGFilter* pFGF, LPCWSTR lpcwstrFileName, LP
CComPtr<IBaseFilter> pBF;
CInterfaceList<IUnknown, &IID_IUnknown> pUnks;
- if(FAILED(hr = pFGF->Create(&pBF, pUnks)))
+ if(FAILED(hr = pFGF->Create(&pBF, pUnks))) {
return hr;
+ }
CComQIPtr<IFileSourceFilter> pFSF = pBF;
- if(!pFSF) return E_NOINTERFACE;
+ if(!pFSF) {
+ return E_NOINTERFACE;
+ }
- if(FAILED(hr = AddFilter(pBF, lpcwstrFilterName)))
+ 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))
- {
+ 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)))
- {
+ if(FAILED(hr = pFSF->Load(lpcwstrFileName, pmt))) {
RemoveFilter(pBF);
return hr;
}
// doh :P
- BeginEnumMediaTypes(GetFirstPin(pBF, PINDIR_OUTPUT), pEMT, pmt)
- {
+ 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 =
@@ -420,8 +414,7 @@ HRESULT CFGManager::AddSourceFilter(CFGFilter* pFGF, LPCWSTR lpcwstrFileName, LP
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)
- {
+ if(pmt->subtype == guid1 || pmt->subtype == guid2 || pmt->subtype == guid3) {
RemoveFilter(pBF);
pFGF = DNew CFGFilterRegistry(CLSID_NetShowSource);
hr = AddSourceFilter(pFGF, lpcwstrFileName, lpcwstrFilterName, ppBF);
@@ -442,14 +435,17 @@ HRESULT CFGManager::AddSourceFilter(CFGFilter* pFGF, LPCWSTR lpcwstrFileName, LP
STDMETHODIMP CFGManager::AddFilter(IBaseFilter* pFilter, LPCWSTR pName)
{
- if(!m_pUnkInner) return E_UNEXPECTED;
+ if(!m_pUnkInner) {
+ return E_UNEXPECTED;
+ }
CAutoLock cAutoLock(this);
HRESULT hr;
- if(FAILED(hr = CComQIPtr<IFilterGraph2>(m_pUnkInner)->AddFilter(pFilter, pName)))
+ if(FAILED(hr = CComQIPtr<IFilterGraph2>(m_pUnkInner)->AddFilter(pFilter, pName))) {
return hr;
+ }
// TODO
hr = pFilter->JoinFilterGraph(NULL, NULL);
@@ -460,7 +456,9 @@ STDMETHODIMP CFGManager::AddFilter(IBaseFilter* pFilter, LPCWSTR pName)
STDMETHODIMP CFGManager::RemoveFilter(IBaseFilter* pFilter)
{
- if(!m_pUnkInner) return E_UNEXPECTED;
+ if(!m_pUnkInner) {
+ return E_UNEXPECTED;
+ }
CAutoLock cAutoLock(this);
@@ -469,7 +467,9 @@ STDMETHODIMP CFGManager::RemoveFilter(IBaseFilter* 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);
@@ -479,7 +479,9 @@ STDMETHODIMP CFGManager::EnumFilters(IEnumFilters** ppEnum)
STDMETHODIMP CFGManager::FindFilterByName(LPCWSTR pName, IBaseFilter** ppFilter)
{
- if(!m_pUnkInner) return E_UNEXPECTED;
+ if(!m_pUnkInner) {
+ return E_UNEXPECTED;
+ }
CAutoLock cAutoLock(this);
@@ -488,7 +490,9 @@ STDMETHODIMP CFGManager::FindFilterByName(LPCWSTR pName, IBaseFilter** ppFilter)
STDMETHODIMP CFGManager::ConnectDirect(IPin* pPinOut, IPin* pPinIn, const AM_MEDIA_TYPE* pmt)
{
- if(!m_pUnkInner) return E_UNEXPECTED;
+ if(!m_pUnkInner) {
+ return E_UNEXPECTED;
+ }
CAutoLock cAutoLock(this);
@@ -496,10 +500,13 @@ STDMETHODIMP CFGManager::ConnectDirect(IPin* pPinOut, IPin* pPinIn, const AM_MED
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;
+ 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);
@@ -507,7 +514,9 @@ STDMETHODIMP CFGManager::ConnectDirect(IPin* pPinOut, IPin* pPinIn, const AM_MED
STDMETHODIMP CFGManager::Reconnect(IPin* ppin)
{
- if(!m_pUnkInner) return E_UNEXPECTED;
+ if(!m_pUnkInner) {
+ return E_UNEXPECTED;
+ }
CAutoLock cAutoLock(this);
@@ -516,7 +525,9 @@ STDMETHODIMP CFGManager::Reconnect(IPin* ppin)
STDMETHODIMP CFGManager::Disconnect(IPin* ppin)
{
- if(!m_pUnkInner) return E_UNEXPECTED;
+ if(!m_pUnkInner) {
+ return E_UNEXPECTED;
+ }
CAutoLock cAutoLock(this);
@@ -525,7 +536,9 @@ STDMETHODIMP CFGManager::Disconnect(IPin* ppin)
STDMETHODIMP CFGManager::SetDefaultSyncSource()
{
- if(!m_pUnkInner) return E_UNEXPECTED;
+ if(!m_pUnkInner) {
+ return E_UNEXPECTED;
+ }
CAutoLock cAutoLock(this);
@@ -548,30 +561,30 @@ HRESULT CFGManager::Connect(IPin* pPinOut, IPin* pPinIn, bool bContinueRender)
HRESULT hr;
if(S_OK != IsPinDirection(pPinOut, PINDIR_OUTPUT)
- || pPinIn && S_OK != IsPinDirection(pPinIn, PINDIR_INPUT))
+ || pPinIn && S_OK != IsPinDirection(pPinIn, PINDIR_INPUT)) {
return VFW_E_INVALID_DIRECTION;
+ }
if(S_OK == IsPinConnected(pPinOut)
- || pPinIn && S_OK == IsPinConnected(pPinIn))
+ || pPinIn && S_OK == IsPinConnected(pPinIn)) {
return VFW_E_ALREADY_CONNECTED;
+ }
bool fDeadEnd = true;
- if(pPinIn)
- {
+ if(pPinIn) {
// 1. Try a direct connection between the filters, with no intermediate filters
- if(SUCCEEDED(hr = ConnectDirect(pPinOut, pPinIn, NULL)))
+ if(SUCCEEDED(hr = ConnectDirect(pPinOut, pPinIn, NULL))) {
return hr;
- }
- else
- {
+ }
+ } else {
// 1. Use IStreamBuilder
- if(CComQIPtr<IStreamBuilder> pSB = pPinOut)
- {
- if(SUCCEEDED(hr = pSB->Render(pPinOut, this)))
+ if(CComQIPtr<IStreamBuilder> pSB = pPinOut) {
+ if(SUCCEEDED(hr = pSB->Render(pPinOut, this))) {
return hr;
+ }
pSB->Backout(pPinOut, this);
}
@@ -579,23 +592,24 @@ HRESULT CFGManager::Connect(IPin* pPinOut, IPin* pPinIn, bool bContinueRender)
// 2. Try cached filters
- if(CComQIPtr<IGraphConfig> pGC = (IGraphBuilder2*)this)
- {
- BeginEnumCachedFilters(pGC, pEF, pBF)
- {
- if(pPinIn && GetFilterFromPin(pPinIn) == pBF)
+ 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 = ConnectFilterDirect(pPinOut, pBF, NULL))) {
+ if(!IsStreamEnd(pBF)) {
+ fDeadEnd = false;
+ }
- if(SUCCEEDED(hr = ConnectFilter(pBF, pPinIn)))
+ if(SUCCEEDED(hr = ConnectFilter(pBF, pPinIn))) {
return hr;
+ }
}
hr = pGC->AddFilterToCache(pBF);
@@ -608,32 +622,34 @@ HRESULT CFGManager::Connect(IPin* pPinOut, IPin* pPinIn, bool bContinueRender)
{
CInterfaceList<IBaseFilter> pBFs;
- BeginEnumFilters(this, pEF, pBF)
- {
+ BeginEnumFilters(this, pEF, pBF) {
if(pPinIn && GetFilterFromPin(pPinIn) == pBF
- || GetFilterFromPin(pPinOut) == 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}")))
+ && GetCLSID(pBF) == GUIDFromCString(_T("{E30629D2-27E5-11CE-875D-00608CB78066}"))) {
continue;
+ }
pBFs.AddTail(pBF);
}
EndEnumFilters;
POSITION pos = pBFs.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
IBaseFilter* pBF = pBFs.GetNext(pos);
- if(SUCCEEDED(hr = ConnectFilterDirect(pPinOut, pBF, NULL)))
- {
- if(!IsStreamEnd(pBF)) fDeadEnd = false;
+ if(SUCCEEDED(hr = ConnectFilterDirect(pPinOut, pBF, NULL))) {
+ if(!IsStreamEnd(pBF)) {
+ fDeadEnd = false;
+ }
- if(SUCCEEDED(hr = ConnectFilter(pBF, pPinIn)))
+ if(SUCCEEDED(hr = ConnectFilter(pBF, pPinIn))) {
return hr;
+ }
}
EXECUTE_ASSERT(Disconnect(pPinOut));
@@ -649,19 +665,19 @@ HRESULT CFGManager::Connect(IPin* pPinOut, IPin* pPinIn, bool bContinueRender)
ExtractMediaTypes(pPinOut, types);
POSITION pos = m_transform.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CFGFilter* pFGF = m_transform.GetNext(pos);
- if(pFGF->GetMerit() < MERIT64_DO_USE || pFGF->CheckTypes(types, false))
+ 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)
- {
+ while(pos) {
CFGFilter* pFGF = m_override.GetNext(pos);
- if(pFGF->GetMerit() < MERIT64_DO_USE || pFGF->CheckTypes(types, false))
+ if(pFGF->GetMerit() < MERIT64_DO_USE || pFGF->CheckTypes(types, false)) {
fl.Insert(pFGF, 0, pFGF->CheckTypes(types, true), false);
+ }
}
CComPtr<IEnumMoniker> pEM;
@@ -669,29 +685,26 @@ HRESULT CFGManager::Connect(IPin* pPinOut, IPin* pPinIn, bool bContinueRender)
&& 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)
- {
+ !!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));
}
}
pos = fl.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CFGFilter* pFGF = fl.GetNext(pos);
TRACE(_T("FGM: Connecting '%s'\n"), pFGF->GetName());
CComPtr<IBaseFilter> pBF;
CInterfaceList<IUnknown, &IID_IUnknown> pUnks;
- if(FAILED(pFGF->Create(&pBF, pUnks)))
+ if(FAILED(pFGF->Create(&pBF, pUnks))) {
continue;
+ }
- if(FAILED(hr = AddFilter(pBF, pFGF->GetName())))
- {
+ if(FAILED(hr = AddFilter(pBF, pFGF->GetName()))) {
pBF.Release();
continue;
}
@@ -714,51 +727,57 @@ HRESULT CFGManager::Connect(IPin* pPinOut, IPin* pPinIn, bool bContinueRender)
}
}
*/
- if(SUCCEEDED(hr))
- {
- if(!IsStreamEnd(pBF)) fDeadEnd = false;
+ if(SUCCEEDED(hr)) {
+ if(!IsStreamEnd(pBF)) {
+ fDeadEnd = false;
+ }
- if (bContinueRender)
+ if (bContinueRender) {
hr = ConnectFilter(pBF, pPinIn);
+ }
- if(SUCCEEDED(hr))
- {
+ 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))
+ while(pos) {
+ if(CComQIPtr<IMixerPinConfig, &IID_IMixerPinConfig> pMPC = pUnks.GetNext(pos)) {
pMPC->SetAspectRatioMode(AM_ARMODE_STRETCHED);
+ }
}
- if(CComQIPtr<IVMRAspectRatioControl> pARC = pBF)
+ if(CComQIPtr<IVMRAspectRatioControl> pARC = pBF) {
pARC->SetAspectRatioMode(VMR_ARMODE_NONE);
+ }
- if(CComQIPtr<IVMRAspectRatioControl9> pARC = pBF)
+ if(CComQIPtr<IVMRAspectRatioControl9> pARC = pBF) {
pARC->SetAspectRatioMode(VMR_ARMODE_NONE);
+ }
- if(CComQIPtr<IVMRMixerControl9> pMC = pBF)
+ if(CComQIPtr<IVMRMixerControl9> pMC = pBF) {
m_pUnks.AddTail (pMC);
+ }
- if(CComQIPtr<IVMRMixerBitmap9> pMB = pBF)
+ if(CComQIPtr<IVMRMixerBitmap9> pMB = pBF) {
m_pUnks.AddTail (pMB);
+ }
- if(CComQIPtr<IMFGetService, &__uuidof(IMFGetService)> pMFGS = pBF)
- {
+ if(CComQIPtr<IMFGetService, &__uuidof(IMFGetService)> pMFGS = pBF) {
CComPtr<IMFVideoDisplayControl> pMFVDC;
CComPtr<IMFVideoMixerBitmap> pMFMB;
- if (SUCCEEDED (pMFGS->GetService (MR_VIDEO_RENDER_SERVICE, IID_IMFVideoDisplayControl, (void**)&pMFVDC)))
+ 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)))
+ if (SUCCEEDED (pMFGS->GetService (MR_VIDEO_MIXER_SERVICE, IID_IMFVideoMixerBitmap, (void**)&pMFMB))) {
m_pUnks.AddTail (pMFMB);
+ }
-// CComPtr<IMFWorkQueueServices> pMFWQS;
-// pMFGS->GetService (MF_WORKQUEUE_SERVICES, IID_IMFWorkQueueServices, (void**)&pMFWQS);
-// pMFWQS->BeginRegisterPlatformWorkQueueWithMMCSS(
+ // CComPtr<IMFWorkQueueServices> pMFWQS;
+ // pMFGS->GetService (MF_WORKQUEUE_SERVICES, IID_IMFWorkQueueServices, (void**)&pMFWQS);
+ // pMFWQS->BeginRegisterPlatformWorkQueueWithMMCSS(
}
@@ -772,19 +791,20 @@ HRESULT CFGManager::Connect(IPin* pPinOut, IPin* pPinIn, bool bContinueRender)
}
}
- if(fDeadEnd)
- {
+ 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++;
+ BeginEnumMediaTypes(pPinOut, pEM, pmt) {
+ if(pmt->majortype == MEDIATYPE_Stream && pmt->subtype == MEDIASUBTYPE_NULL) {
+ skip++;
+ }
psde->mts.AddTail(CMediaType(*pmt));
}
EndEnumMediaTypes(pmt)
- if(skip < psde->mts.GetCount())
+ if(skip < psde->mts.GetCount()) {
m_deadends.Add(psde);
+ }
}
return pPinIn ? VFW_E_CANNOT_CONNECT : VFW_E_CANNOT_RENDER;
@@ -816,25 +836,25 @@ STDMETHODIMP CFGManager::RenderFile(LPCWSTR lpcwstrFileName, LPCWSTR lpcwstrPlay
*/
CFGFilterList fl;
- if(FAILED(hr = EnumSourceFilters(lpcwstrFileName, fl)))
+ if(FAILED(hr = EnumSourceFilters(lpcwstrFileName, fl))) {
return hr;
+ }
CAutoPtrArray<CStreamDeadEnd> deadends;
hr = VFW_E_CANNOT_RENDER;
POSITION pos = fl.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CComPtr<IBaseFilter> pBF;
- if(SUCCEEDED(hr = AddSourceFilter(fl.GetNext(pos), lpcwstrFileName, lpcwstrFileName, &pBF)))
- {
+ if(SUCCEEDED(hr = AddSourceFilter(fl.GetNext(pos), lpcwstrFileName, lpcwstrFileName, &pBF))) {
m_streampath.RemoveAll();
m_deadends.RemoveAll();
- if(SUCCEEDED(hr = ConnectFilter(pBF, NULL)))
+ if(SUCCEEDED(hr = ConnectFilter(pBF, NULL))) {
return hr;
+ }
NukeDownstream(pBF);
RemoveFilter(pBF);
@@ -855,14 +875,15 @@ STDMETHODIMP CFGManager::AddSourceFilter(LPCWSTR lpcwstrFileName, LPCWSTR lpcwst
HRESULT hr;
CFGFilterList fl;
- if(FAILED(hr = EnumSourceFilters(lpcwstrFileName, 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)))
+ while(pos) {
+ if(SUCCEEDED(hr = AddSourceFilter(fl.GetNext(pos), lpcwstrFileName, lpcwstrFilterName, ppFilter))) {
return hr;
+ }
}
return VFW_E_CANNOT_LOAD_SOURCE_FILTER;
@@ -870,7 +891,9 @@ STDMETHODIMP CFGManager::AddSourceFilter(LPCWSTR lpcwstrFileName, LPCWSTR lpcwst
STDMETHODIMP CFGManager::SetLogFile(DWORD_PTR hFile)
{
- if(!m_pUnkInner) return E_UNEXPECTED;
+ if(!m_pUnkInner) {
+ return E_UNEXPECTED;
+ }
CAutoLock cAutoLock(this);
@@ -879,7 +902,9 @@ STDMETHODIMP CFGManager::SetLogFile(DWORD_PTR hFile)
STDMETHODIMP CFGManager::Abort()
{
- if(!m_pUnkInner) return E_UNEXPECTED;
+ if(!m_pUnkInner) {
+ return E_UNEXPECTED;
+ }
CAutoLock cAutoLock(this);
@@ -888,7 +913,9 @@ STDMETHODIMP CFGManager::Abort()
STDMETHODIMP CFGManager::ShouldOperationContinue()
{
- if(!m_pUnkInner) return E_UNEXPECTED;
+ if(!m_pUnkInner) {
+ return E_UNEXPECTED;
+ }
CAutoLock cAutoLock(this);
@@ -899,7 +926,9 @@ STDMETHODIMP CFGManager::ShouldOperationContinue()
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);
@@ -908,7 +937,9 @@ STDMETHODIMP CFGManager::AddSourceFilterForMoniker(IMoniker* pMoniker, IBindCtx*
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);
@@ -922,32 +953,25 @@ STDMETHODIMP CFGManager::RenderEx(IPin* pPinOut, DWORD dwFlags, DWORD* pvContext
m_streampath.RemoveAll();
m_deadends.RemoveAll();
- if(!pPinOut || dwFlags > AM_RENDEREX_RENDERTOEXISTINGRENDERERS || pvContext)
+ if(!pPinOut || dwFlags > AM_RENDEREX_RENDERTOEXISTINGRENDERERS || pvContext) {
return E_INVALIDARG;
+ }
HRESULT hr;
- if(dwFlags & AM_RENDEREX_RENDERTOEXISTINGRENDERERS)
- {
+ 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)
- {
+ 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)
- {
+ } else {
+ BeginEnumPins(pBF, pEP, pPin) {
CComPtr<IPin> pPinIn;
DWORD size = 1;
- if(SUCCEEDED(pPin->QueryInternalConnections(&pPinIn, &size)) && size == 0)
- {
+ if(SUCCEEDED(pPin->QueryInternalConnections(&pPinIn, &size)) && size == 0) {
pBFs.AddTail(pBF);
break;
}
@@ -957,10 +981,10 @@ STDMETHODIMP CFGManager::RenderEx(IPin* pPinOut, DWORD dwFlags, DWORD* pvContext
}
EndEnumFilters;
- while(!pBFs.IsEmpty())
- {
- if(SUCCEEDED(hr = ConnectFilter(pPinOut, pBFs.RemoveHead())))
+ while(!pBFs.IsEmpty()) {
+ if(SUCCEEDED(hr = ConnectFilter(pPinOut, pBFs.RemoveHead()))) {
return hr;
+ }
}
return VFW_E_CANNOT_RENDER;
@@ -978,8 +1002,9 @@ STDMETHODIMP CFGManager::IsPinDirection(IPin* pPin, PIN_DIRECTION dir1)
CheckPointer(pPin, E_POINTER);
PIN_DIRECTION dir2;
- if(FAILED(pPin->QueryDirection(&dir2)))
+ if(FAILED(pPin->QueryDirection(&dir2))) {
return E_FAIL;
+ }
return dir1 == dir2 ? S_OK : S_FALSE;
}
@@ -1000,26 +1025,25 @@ STDMETHODIMP CFGManager::ConnectFilter(IBaseFilter* pBF, IPin* pPinIn)
CheckPointer(pBF, E_POINTER);
- if(pPinIn && S_OK != IsPinDirection(pPinIn, PINDIR_INPUT))
+ if(pPinIn && S_OK != IsPinDirection(pPinIn, PINDIR_INPUT)) {
return VFW_E_INVALID_DIRECTION;
+ }
int nTotal = 0, nRendered = 0;
- BeginEnumPins(pBF, pEP, pPin)
- {
+ BeginEnumPins(pBF, pEP, pPin) {
if(GetPinName(pPin)[0] != '~'
&& S_OK == IsPinDirection(pPin, PINDIR_OUTPUT)
- && S_OK != IsPinConnected(pPin))
- {
+ && S_OK != IsPinConnected(pPin)) {
m_streampath.Append(pBF, pPin);
HRESULT hr = Connect(pPin, pPinIn);
- if(SUCCEEDED(hr))
- {
+ if(SUCCEEDED(hr)) {
for(int i = m_deadends.GetCount()-1; i >= 0; i--)
- if(m_deadends[i]->Compare(m_streampath))
+ if(m_deadends[i]->Compare(m_streampath)) {
m_deadends.RemoveAt(i);
+ }
nRendered++;
}
@@ -1028,8 +1052,9 @@ STDMETHODIMP CFGManager::ConnectFilter(IBaseFilter* pBF, IPin* pPinIn)
m_streampath.RemoveTail();
- if(SUCCEEDED(hr) && pPinIn)
+ if(SUCCEEDED(hr) && pPinIn) {
return S_OK;
+ }
}
}
EndEnumPins;
@@ -1047,18 +1072,18 @@ STDMETHODIMP CFGManager::ConnectFilter(IPin* pPinOut, IBaseFilter* pBF)
CheckPointer(pPinOut, E_POINTER);
CheckPointer(pBF, E_POINTER);
- if(S_OK != IsPinDirection(pPinOut, PINDIR_OUTPUT))
+ if(S_OK != IsPinDirection(pPinOut, PINDIR_OUTPUT)) {
return VFW_E_INVALID_DIRECTION;
+ }
- BeginEnumPins(pBF, pEP, pPin)
- {
+ BeginEnumPins(pBF, pEP, pPin) {
if(GetPinName(pPin)[0] != '~'
&& S_OK == IsPinDirection(pPin, PINDIR_INPUT)
- && S_OK != IsPinConnected(pPin))
- {
+ && S_OK != IsPinConnected(pPin)) {
HRESULT hr = Connect(pPinOut, pPin);
- if(SUCCEEDED(hr))
+ if(SUCCEEDED(hr)) {
return hr;
+ }
}
}
EndEnumPins;
@@ -1073,18 +1098,18 @@ STDMETHODIMP CFGManager::ConnectFilterDirect(IPin* pPinOut, IBaseFilter* pBF, co
CheckPointer(pPinOut, E_POINTER);
CheckPointer(pBF, E_POINTER);
- if(S_OK != IsPinDirection(pPinOut, PINDIR_OUTPUT))
+ if(S_OK != IsPinDirection(pPinOut, PINDIR_OUTPUT)) {
return VFW_E_INVALID_DIRECTION;
+ }
- BeginEnumPins(pBF, pEP, pPin)
- {
+ BeginEnumPins(pBF, pEP, pPin) {
if(GetPinName(pPin)[0] != '~'
&& S_OK == IsPinDirection(pPin, PINDIR_INPUT)
- && S_OK != IsPinConnected(pPin))
- {
+ && S_OK != IsPinConnected(pPin)) {
HRESULT hr = ConnectDirect(pPinOut, pPin, pmt);
- if(SUCCEEDED(hr))
+ if(SUCCEEDED(hr)) {
return hr;
+ }
}
}
EndEnumPins;
@@ -1096,31 +1121,23 @@ STDMETHODIMP CFGManager::NukeDownstream(IUnknown* pUnk)
{
CAutoLock cAutoLock(this);
- if(CComQIPtr<IBaseFilter> pBF = pUnk)
- {
- BeginEnumPins(pBF, pEP, pPin)
- {
+ if(CComQIPtr<IBaseFilter> pBF = pUnk) {
+ BeginEnumPins(pBF, pEP, pPin) {
NukeDownstream(pPin);
}
EndEnumPins;
- }
- else if(CComQIPtr<IPin> pPin = pUnk)
- {
+ } 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))
- {
+ && SUCCEEDED(pPin->ConnectedTo(&pPinTo)) && pPinTo) {
+ if(CComPtr<IBaseFilter> pBF = GetFilterFromPin(pPinTo)) {
NukeDownstream(pBF);
Disconnect(pPinTo);
Disconnect(pPin);
RemoveFilter(pBF);
}
}
- }
- else
- {
+ } else {
return E_INVALIDARG;
}
@@ -1133,11 +1150,11 @@ STDMETHODIMP CFGManager::FindInterface(REFIID iid, void** ppv, BOOL bRemove)
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);
+ 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;
}
}
@@ -1151,15 +1168,18 @@ STDMETHODIMP CFGManager::AddToROT()
HRESULT hr;
- if(m_dwRegister) return S_FALSE;
+ if(m_dwRegister) {
+ return S_FALSE;
+ }
CComPtr<IRunningObjectTable> pROT;
CComPtr<IMoniker> pMoniker;
WCHAR wsz[256];
swprintf(wsz, L"FilterGraph %08p pid %08x (MPC)", (DWORD_PTR)this, GetCurrentProcessId());
if(SUCCEEDED(hr = GetRunningObjectTable(0, &pROT))
- && SUCCEEDED(hr = CreateItemMoniker(L"!", wsz, &pMoniker)))
+ && SUCCEEDED(hr = CreateItemMoniker(L"!", wsz, &pMoniker))) {
hr = pROT->Register(ROTFLAGS_REGISTRATIONKEEPSALIVE, (IGraphBuilder2*)this, pMoniker, &m_dwRegister);
+ }
return hr;
}
@@ -1170,12 +1190,15 @@ STDMETHODIMP CFGManager::RemoveFromROT()
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)))
+ && SUCCEEDED(hr = pROT->Revoke(m_dwRegister))) {
m_dwRegister = 0;
+ }
return hr;
}
@@ -1193,14 +1216,15 @@ STDMETHODIMP CFGManager::GetDeadEnd(int iIndex, CAtlList<CStringW>& path, CAtlLi
{
CAutoLock cAutoLock(this);
- if(iIndex < 0 || iIndex >= m_deadends.GetCount()) return E_FAIL;
+ if(iIndex < 0 || iIndex >= m_deadends.GetCount()) {
+ return E_FAIL;
+ }
path.RemoveAll();
mts.RemoveAll();
POSITION pos = m_deadends[iIndex]->GetHeadPosition();
- while(pos)
- {
+ while(pos) {
const path_t& p = m_deadends[iIndex]->GetNext(pos);
CStringW str;
@@ -1233,8 +1257,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
// Source filters
#if INTERNAL_SOURCEFILTER_SHOUTCAST
- if(src[SRC_SHOUTCAST])
- {
+ if(src[SRC_SHOUTCAST]) {
pFGF = DNew CFGFilterInternal<CShoutcastSource>();
pFGF->m_protocols.AddTail(_T("http"));
m_source.AddTail(pFGF);
@@ -1251,8 +1274,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
#endif
#if INTERNAL_SOURCEFILTER_AVI
- if(src[SRC_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"));
@@ -1261,8 +1283,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
#endif
#if INTERNAL_SOURCEFILTER_MP4
- if(src[SRC_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
@@ -1276,8 +1297,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
#endif
#if INTERNAL_SOURCEFILTER_FLV
- if(src[SRC_FLV])
- {
+ if(src[SRC_FLV]) {
pFGF = DNew CFGFilterInternal<CFLVSourceFilter>();
pFGF->m_chkbytes.AddTail(_T("0,4,,464C5601")); // FLV (v1)
m_source.AddTail(pFGF);
@@ -1285,8 +1305,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
#endif
#if INTERNAL_SOURCEFILTER_MATROSKA
- if(src[SRC_MATROSKA])
- {
+ if(src[SRC_MATROSKA]) {
pFGF = DNew CFGFilterInternal<CMatroskaSourceFilter>();
pFGF->m_chkbytes.AddTail(_T("0,4,,1A45DFA3"));
m_source.AddTail(pFGF);
@@ -1294,8 +1313,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
#endif
#if INTERNAL_SOURCEFILTER_REALMEDIA
- if(src[SRC_REALMEDIA])
- {
+ if(src[SRC_REALMEDIA]) {
pFGF = DNew CFGFilterInternal<CRealMediaSourceFilter>();
pFGF->m_chkbytes.AddTail(_T("0,4,,2E524D46"));
m_source.AddTail(pFGF);
@@ -1303,8 +1321,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
#endif
#if INTERNAL_SOURCEFILTER_DSM
- if(src[SRC_DSM])
- {
+ if(src[SRC_DSM]) {
pFGF = DNew CFGFilterInternal<CDSMSourceFilter>();
pFGF->m_chkbytes.AddTail(_T("0,4,,44534D53"));
m_source.AddTail(pFGF);
@@ -1312,8 +1329,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
#endif
#if INTERNAL_SOURCEFILTER_FLIC
- if(src[SRC_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"));
@@ -1324,8 +1340,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
#endif
#if INTERNAL_SOURCEFILTER_FLAC
- if(src[SRC_FLAC])
- {
+ if(src[SRC_FLAC]) {
pFGF = DNew CFGFilterInternal<CFlacSource>();
pFGF->m_chkbytes.AddTail(_T("0,4,,664C6143"));
pFGF->m_extensions.AddTail(_T(".flac"));
@@ -1334,8 +1349,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
#endif
#if INTERNAL_SOURCEFILTER_CDDA
- if(src[SRC_CDDA])
- {
+ if(src[SRC_CDDA]) {
pFGF = DNew CFGFilterInternal<CCDDAReader>();
pFGF->m_extensions.AddTail(_T(".cda"));
m_source.AddTail(pFGF);
@@ -1343,8 +1357,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
#endif
#if INTERNAL_SOURCEFILTER_CDXA
- if(src[SRC_CDXA])
- {
+ if(src[SRC_CDXA]) {
pFGF = DNew CFGFilterInternal<CCDXAReader>();
pFGF->m_chkbytes.AddTail(_T("0,4,,52494646,8,4,,43445841"));
m_source.AddTail(pFGF);
@@ -1352,8 +1365,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
#endif
#if INTERNAL_SOURCEFILTER_VTS
- if(src[SRC_VTS])
- {
+ if(src[SRC_VTS]) {
pFGF = DNew CFGFilterInternal<CVTSReader>();
pFGF->m_chkbytes.AddTail(_T("0,12,,445644564944454F2D565453"));
m_source.AddTail(pFGF);
@@ -1361,12 +1373,10 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
#endif
#if INTERNAL_SOURCEFILTER_DVSOURCE
-// TODOX64 : fix DVSource internal filter
+ // TODOX64 : fix DVSource internal filter
#ifndef _WIN64
- __if_exists(CD2VSource)
- {
- if(src[SRC_D2V])
- {
+ __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"));
@@ -1386,8 +1396,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
#endif
#if INTERNAL_SOURCEFILTER_OGG
- if(src[SRC_OGG])
- {
+ if(src[SRC_OGG]) {
pFGF = DNew CFGFilterInternal<COggSourceFilter>();
pFGF->m_chkbytes.AddTail(_T("0,4,,4F676753"));
m_source.AddTail(pFGF);
@@ -1419,8 +1428,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
#endif
#if INTERNAL_SOURCEFILTER_MPEG
- if(src[SRC_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"));
@@ -1435,8 +1443,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
#endif
#if INTERNAL_SOURCEFILTER_DTSAC3
- if(src[SRC_DTSAC3])
- {
+ if(src[SRC_DTSAC3]) {
pFGF = DNew CFGFilterInternal<CDTSAC3Source>();
pFGF->m_chkbytes.AddTail(_T("0,4,,7FFE8001"));
pFGF->m_chkbytes.AddTail(_T("0,2,,0B77"));
@@ -1448,8 +1455,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
#endif
#if INTERNAL_SOURCEFILTER_MPEGAUDIO
- if(src[SRC_MPA])
- {
+ 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"));
@@ -1457,8 +1463,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
}
#endif
- if(AfxGetAppSettings().fUseWMASFReader)
- {
+ if(AfxGetAppSettings().fUseWMASFReader) {
pFGF = DNew CFGFilterRegistry(CLSID_WMAsfReader);
pFGF->m_chkbytes.AddTail(_T("0,4,,3026B275"));
pFGF->m_chkbytes.AddTail(_T("0,4,,D129E2D6"));
@@ -1474,12 +1479,9 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
#endif
#if INTERNAL_SOURCEFILTER_MATROSKA
- if(src[SRC_MATROSKA])
- {
+ if(src[SRC_MATROSKA]) {
pFGF = DNew CFGFilterInternal<CMatroskaSplitterFilter>(L"Matroska Splitter", MERIT64_ABOVE_DSHOW);
- }
- else
- {
+ } else {
pFGF = DNew CFGFilterInternal<CMatroskaSplitterFilter>(L"Matroska Splitter (low merit)", MERIT64_DO_USE);
}
pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_Matroska);
@@ -1488,12 +1490,9 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
#endif
#if INTERNAL_SOURCEFILTER_REALMEDIA
- if(src[SRC_REALMEDIA])
- {
+ if(src[SRC_REALMEDIA]) {
pFGF = DNew CFGFilterInternal<CRealMediaSplitterFilter>(L"RealMedia Splitter", MERIT64_ABOVE_DSHOW);
- }
- else
- {
+ } else {
pFGF = DNew CFGFilterInternal<CRealMediaSplitterFilter>(L"RealMedia Splitter (low merit)", MERIT64_DO_USE);
}
pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_RealMedia);
@@ -1502,12 +1501,9 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
#endif
#if INTERNAL_SOURCEFILTER_AVI
- if(src[SRC_AVI])
- {
+ if(src[SRC_AVI]) {
pFGF = DNew CFGFilterInternal<CAviSplitterFilter>(L"Avi Splitter", MERIT64_ABOVE_DSHOW);
- }
- else
- {
+ } else {
pFGF = DNew CFGFilterInternal<CAviSplitterFilter>(L"Avi Splitter (low merit)", MERIT64_DO_USE);
}
pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_Avi);
@@ -1530,12 +1526,9 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
#endif
#if INTERNAL_SOURCEFILTER_OGG
- if(src[SRC_OGG])
- {
+ if(src[SRC_OGG]) {
pFGF = DNew CFGFilterInternal<COggSplitterFilter>(L"Ogg Splitter", MERIT64_ABOVE_DSHOW);
- }
- else
- {
+ } else {
pFGF = DNew CFGFilterInternal<COggSplitterFilter>(L"Ogg Splitter (low merit)", MERIT64_DO_USE);
}
pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_Ogg);
@@ -1561,12 +1554,9 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
#endif
#if INTERNAL_SOURCEFILTER_MPEG
- if(src[SRC_MPEG])
- {
+ if(src[SRC_MPEG]) {
pFGF = DNew CFGFilterInternal<CMpegSplitterFilter>(L"Mpeg Splitter", MERIT64_ABOVE_DSHOW);
- }
- else
- {
+ } else {
pFGF = DNew CFGFilterInternal<CMpegSplitterFilter>(L"Mpeg Splitter (low merit)", MERIT64_DO_USE);
}
pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_MPEG1System);
@@ -1595,12 +1585,9 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
#endif
#if INTERNAL_SOURCEFILTER_MPEGAUDIO
- if(src[SRC_MPA])
- {
+ if(src[SRC_MPA]) {
pFGF = DNew CFGFilterInternal<CMpaSplitterFilter>(L"Mpa Splitter", MERIT64_ABOVE_DSHOW);
- }
- else
- {
+ } else {
pFGF = DNew CFGFilterInternal<CMpaSplitterFilter>(L"Mpa Splitter (low merit)", MERIT64_DO_USE);
}
pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_MPEG1Audio);
@@ -1609,12 +1596,9 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
#endif
#if INTERNAL_SOURCEFILTER_DSM
- if(src[SRC_DSM])
- {
+ if(src[SRC_DSM]) {
pFGF = DNew CFGFilterInternal<CDSMSplitterFilter>(L"DSM Splitter", MERIT64_ABOVE_DSHOW);
- }
- else
- {
+ } else {
pFGF = DNew CFGFilterInternal<CDSMSplitterFilter>(L"DSM Splitter (low merit)", MERIT64_DO_USE);
}
pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_DirectShowMedia);
@@ -1623,12 +1607,9 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
#endif
#if INTERNAL_SOURCEFILTER_MP4
- if(src[SRC_MP4])
- {
+ if(src[SRC_MP4]) {
pFGF = DNew CFGFilterInternal<CMP4SplitterFilter>(L"MP4 Splitter", MERIT64_ABOVE_DSHOW);
- }
- else
- {
+ } else {
pFGF = DNew CFGFilterInternal<CMP4SplitterFilter>(L"MP4 Splitter (low merit)", MERIT64_DO_USE);
}
pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_MP4);
@@ -1637,12 +1618,9 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
#endif
#if INTERNAL_SOURCEFILTER_FLV
- if(src[SRC_FLV])
- {
+ if(src[SRC_FLV]) {
pFGF = DNew CFGFilterInternal<CFLVSplitterFilter>(L"FLV Splitter", MERIT64_ABOVE_DSHOW);
- }
- else
- {
+ } else {
pFGF = DNew CFGFilterInternal<CFLVSplitterFilter>(L"FLV Splitter (low merit)", MERIT64_DO_USE);
}
pFGF->AddType(MEDIATYPE_Stream, MEDIASUBTYPE_FLV);
@@ -1868,8 +1846,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
#if HAS_FFMPEG_VIDEO_DECODERS | HAS_DXVA_VIDEO_DECODERS
pFGF = DNew CFGFilterInternal<CMPCVideoDecFilter>(_T("MPC Video Decoder"), MERIT64_ABOVE_DSHOW);
#if INTERNAL_DECODER_FLV
- if (ffmpeg_filters[FFM_FLV4])
- {
+ if (ffmpeg_filters[FFM_FLV4]) {
pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_FLV1);
pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_flv1);
pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_FLV4);
@@ -1877,8 +1854,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
}
#endif
#if INTERNAL_DECODER_VP6
- if (ffmpeg_filters[FFM_VP62])
- {
+ if (ffmpeg_filters[FFM_VP62]) {
pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP50);
pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vp50);
pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP60);
@@ -1894,8 +1870,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
}
#endif
#if INTERNAL_DECODER_H264 | INTERNAL_DECODER_H264_DXVA
- if ((ffmpeg_filters[FFM_H264]) || (dxva_filters[TRA_DXVA_H264]))
- {
+ 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);
@@ -1913,8 +1888,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
}
#endif
#if INTERNAL_DECODER_MPEG2_DXVA
- if (dxva_filters[TRA_DXVA_MPEG2])
- {
+ 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);
@@ -1922,15 +1896,13 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
}
#endif
#if INTERNAL_DECODER_VC1 | INTERNAL_DECODER_VC1_DXVA
- if ((ffmpeg_filters[FFM_VC1]) || (dxva_filters[TRA_DXVA_VC1]))
- {
+ 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])
- {
+ if (ffmpeg_filters[FFM_XVID]) {
pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_XVID);
pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_xvid);
pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_XVIX);
@@ -1974,8 +1946,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
}
#endif
#if INTERNAL_DECODER_DIVX
- if (ffmpeg_filters[FFM_DIVX])
- {
+ if (ffmpeg_filters[FFM_DIVX]) {
pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIVX);
pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_divx);
pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DX50);
@@ -1983,8 +1954,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
}
#endif
#if INTERNAL_DECODER_WMV
- if (ffmpeg_filters[FFM_WMV])
- {
+ if (ffmpeg_filters[FFM_WMV]) {
pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_WMV1);
pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_wmv1);
pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_WMV2);
@@ -1994,8 +1964,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
}
#endif
#if INTERNAL_DECODER_MSMPEG4
- if (ffmpeg_filters[FFM_MSMPEG4])
- {
+ if (ffmpeg_filters[FFM_MSMPEG4]) {
pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIV3);
pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_div3);
pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DVX3);
@@ -2027,15 +1996,13 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
}
#endif
#if INTERNAL_DECODER_SVQ
- if (ffmpeg_filters[FFM_SVQ3])
- {
+ 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])
- {
+ if (ffmpeg_filters[FFM_H263]) {
pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_H263);
pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_h263);
pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_S263);
@@ -2043,21 +2010,18 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
}
#endif
#if INTERNAL_DECODER_THEORA
- if (ffmpeg_filters[FFM_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])
- {
+ if (ffmpeg_filters[FFM_AMVV]) {
pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_AMVV);
}
#endif
#if INTERNAL_DECODER_VP8
- if (ffmpeg_filters[FFM_VP8])
- {
+ if (ffmpeg_filters[FFM_VP8]) {
pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP80);
}
#endif
@@ -2067,8 +2031,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
// Low merit MPC Video Decoder
pFGF = DNew CFGFilterInternal<CMPCVideoDecFilter>(_T("MPC Video Decoder (low merit)"), MERIT64_DO_USE);
#if INTERNAL_DECODER_FLV
- if (!(ffmpeg_filters[FFM_FLV4]))
- {
+ if (!(ffmpeg_filters[FFM_FLV4])) {
pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_FLV1);
pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_flv1);
pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_FLV4);
@@ -2076,8 +2039,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
}
#endif
#if INTERNAL_DECODER_VP6
- if (!(ffmpeg_filters[FFM_VP62]))
- {
+ if (!(ffmpeg_filters[FFM_VP62])) {
pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP50);
pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_vp50);
pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP60);
@@ -2093,8 +2055,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
}
#endif
#if INTERNAL_DECODER_H264 | INTERNAL_DECODER_H264_DXVA
- if (!(ffmpeg_filters[FFM_H264]) && !(dxva_filters[TRA_DXVA_H264]))
- {
+ 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);
@@ -2112,8 +2073,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
}
#endif
#if INTERNAL_DECODER_MPEG2_DXVA
- if (!(dxva_filters[TRA_DXVA_MPEG2]))
- {
+ 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);
@@ -2121,15 +2081,13 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
}
#endif
#if INTERNAL_DECODER_VC1 | INTERNAL_DECODER_VC1_DXVA
- if (!(ffmpeg_filters[FFM_VC1]) && !(dxva_filters[TRA_DXVA_VC1]))
- {
+ 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]))
- {
+ if (!(ffmpeg_filters[FFM_XVID])) {
pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_XVID);
pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_xvid);
pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_XVIX);
@@ -2173,8 +2131,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
}
#endif
#if INTERNAL_DECODER_DIVX
- if (!(ffmpeg_filters[FFM_DIVX]))
- {
+ if (!(ffmpeg_filters[FFM_DIVX])) {
pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIVX);
pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_divx);
pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DX50);
@@ -2182,8 +2139,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
}
#endif
#if INTERNAL_DECODER_WMV
- if (!(ffmpeg_filters[FFM_WMV]))
- {
+ if (!(ffmpeg_filters[FFM_WMV])) {
pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_WMV1);
pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_wmv1);
pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_WMV2);
@@ -2193,8 +2149,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
}
#endif
#if INTERNAL_DECODER_MSMPEG4
- if (!(ffmpeg_filters[FFM_MSMPEG4]))
- {
+ if (!(ffmpeg_filters[FFM_MSMPEG4])) {
pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DIV3);
pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_div3);
pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_DVX3);
@@ -2226,35 +2181,30 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
}
#endif
#if INTERNAL_DECODER_SVQ
- if (!(ffmpeg_filters[FFM_SVQ3]))
- {
+ 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]))
- {
+ 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]))
- {
+ 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]))
- {
+ if (!(ffmpeg_filters[FFM_AMVV])) {
pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_AMVV);
}
#endif
#if INTERNAL_DECODER_VP8
- if (!(ffmpeg_filters[FFM_VP8]))
- {
+ if (!(ffmpeg_filters[FFM_VP8])) {
pFGF->AddType(MEDIATYPE_Video, MEDIASUBTYPE_VP80);
}
#endif
@@ -2286,8 +2236,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
CMPCVideoDecFilter::DXVAFilters = (HAS_DXVA_VIDEO_DECODERS) ? s.DXVAFilters : NULL;
CMPCVideoDecFilter::m_ref_frame_count_check_skip = false;
- if((!IsVistaOrAbove()) && ((s.iDSVideoRendererType == VIDRNDT_DS_DEFAULT) || (s.iDSVideoRendererType == VIDRNDT_DS_DXR)))
- {
+ if((!IsVistaOrAbove()) && ((s.iDSVideoRendererType == VIDRNDT_DS_DEFAULT) || (s.iDSVideoRendererType == VIDRNDT_DS_DXR))) {
CMPCVideoDecFilter::m_ref_frame_count_check_skip = true;
}
#endif
@@ -2327,8 +2276,7 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
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)
- {
+ && GetFileVersion(buff) < 0x0001000000030000ui64) {
m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(clsid), MERIT64_DO_NOT_USE));
}
}
@@ -2342,10 +2290,8 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
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)
- {
+ 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) {
m_transform.AddTail(DNew CFGFilterRegistry(GUIDFromCString(_T("{9852A670-F845-491B-9BE6-EBD841B8A613}")), MERIT64_DO_NOT_USE));
}
}
@@ -2355,15 +2301,16 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
WORD merit_low = 1;
POSITION pos = s.m_filters.GetTailPosition();
- while(pos)
- {
+ while(pos) {
FilterOverride* fo = s.m_filters.GetPrev(pos);
- if (!fo->fDisabled && fo->name == _T("Broadcom Video Decoder"))
+ if (!fo->fDisabled && fo->name == _T("Broadcom Video Decoder")) {
bOverrideBroadcom = true;
+ }
- if(fo->fDisabled || fo->type == FilterOverride::EXTERNAL && !CPath(MakeFullPath(fo->path)).FileExists())
+ if(fo->fDisabled || fo->type == FilterOverride::EXTERNAL && !CPath(MakeFullPath(fo->path)).FileExists()) {
continue;
+ }
ULONGLONG merit =
fo->iLoadType == FilterOverride::PREFERRED ? MERIT64_ABOVE_DSHOW :
@@ -2374,25 +2321,20 @@ CFGManagerCustom::CFGManagerCustom(LPCTSTR pName, LPUNKNOWN pUnk)
CFGFilter* pFGF = NULL;
- if(fo->type == FilterOverride::REGISTERED)
- {
+ if(fo->type == FilterOverride::REGISTERED) {
pFGF = DNew CFGFilterRegistry(fo->dispname, merit);
- }
- else if(fo->type == FilterOverride::EXTERNAL)
- {
+ } else if(fo->type == FilterOverride::EXTERNAL) {
pFGF = DNew CFGFilterFile(fo->clsid, fo->path, CStringW(fo->name), merit);
}
- if(pFGF)
- {
+ 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)
- {
+ 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);
@@ -2426,22 +2368,20 @@ STDMETHODIMP CFGManagerCustom::AddFilter(IBaseFilter* pBF, LPCWSTR pName)
HRESULT hr;
- if(FAILED(hr = __super::AddFilter(pBF, pName)))
+ if(FAILED(hr = __super::AddFilter(pBF, pName))) {
return hr;
+ }
AppSettings& s = AfxGetAppSettings();
- if(GetCLSID(pBF) == CLSID_DMOWrapperFilter)
- {
- if(CComQIPtr<IPropertyBag> pPB = pBF)
- {
+ if(GetCLSID(pBF) == CLSID_DMOWrapperFilter) {
+ if(CComQIPtr<IPropertyBag> pPB = pBF) {
CComVariant var(true);
pPB->Write(CComBSTR(L"_HIRESOUTPUT"), &var);
}
}
- if(CComQIPtr<IAudioSwitcherFilter> pASF = pBF)
- {
+ if(CComQIPtr<IAudioSwitcherFilter> pASF = pBF) {
pASF->EnableDownSamplingTo441(s.fDownSampleTo441);
pASF->SetSpeakerConfig(s.fCustomChannelMapping, s.pSpeakerToChannelMap);
pASF->SetAudioTimeShift(s.fAudioTimeShift ? 10000i64*s.iAudioTimeShift : 0);
@@ -2466,17 +2406,14 @@ CFGManagerPlayer::CFGManagerPlayer(LPCTSTR pName, LPUNKNOWN pUnk, HWND hWnd)
AppSettings& s = AfxGetAppSettings();
- if(m_pFM)
- {
+ 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)
- {
+ 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());
}
@@ -2485,24 +2422,20 @@ CFGManagerPlayer::CFGManagerPlayer(LPCTSTR pName, LPUNKNOWN pUnk, HWND hWnd)
m_vrmerit += 0x100;
}
- if(m_pFM)
- {
+ 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)
- {
+ 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)
- {
+ BeginEnumSysDev(CLSID_AudioRendererCategory, pMoniker) {
CFGFilterRegistry f(pMoniker);
m_armerit = max(m_armerit, f.GetMerit());
}
@@ -2513,8 +2446,7 @@ CFGManagerPlayer::CFGManagerPlayer(LPCTSTR pName, LPUNKNOWN pUnk, HWND hWnd)
// Switchers
- if(s.fEnableAudioSwitcher)
- {
+ if(s.fEnableAudioSwitcher) {
pFGF = DNew CFGFilterInternal<CAudioSwitcherFilter>(L"Audio Switcher", m_armerit + 0x100);
pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_NULL);
m_transform.AddTail(pFGF);
@@ -2525,74 +2457,66 @@ CFGManagerPlayer::CFGManagerPlayer(LPCTSTR pName, LPUNKNOWN pUnk, HWND hWnd)
// 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;
+ 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)
- {
+ 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)
- {
+ } 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)
- {
+ } 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!="")
- {
+ } else if(SelAudioRenderer!="") {
pFGF = DNew CFGFilterRegistry(SelAudioRenderer, m_armerit);
pFGF->AddType(MEDIATYPE_Audio, MEDIASUBTYPE_NULL);
m_transform.AddTail(pFGF);
@@ -2603,12 +2527,12 @@ STDMETHODIMP CFGManagerPlayer::ConnectDirect(IPin* pPinOut, IPin* pPinIn, const
{
CAutoLock cAutoLock(this);
- if(GetCLSID(pPinOut) == CLSID_MPEG2Demultiplexer)
- {
+ if(GetCLSID(pPinOut) == CLSID_MPEG2Demultiplexer) {
CComQIPtr<IMediaSeeking> pMS = pPinOut;
REFERENCE_TIME rtDur = 0;
- if(!pMS || FAILED(pMS->GetDuration(&rtDur)) || rtDur <= 0)
+ if(!pMS || FAILED(pMS->GetDuration(&rtDur)) || rtDur <= 0) {
return E_FAIL;
+ }
}
return __super::ConnectDirect(pPinOut, pPinIn, pmt);
@@ -2624,8 +2548,9 @@ CFGManagerDVD::CFGManagerDVD(LPCTSTR pName, LPUNKNOWN pUnk, HWND hWnd)
AppSettings& s = AfxGetAppSettings();
// have to avoid the old video renderer
- if(s.iDSVideoRendererType == VIDRNDT_DS_OLDRENDERER)
+ 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));
@@ -2636,12 +2561,9 @@ CFGManagerDVD::CFGManagerDVD(LPCTSTR pName, LPUNKNOWN pUnk, HWND hWnd)
class CResetDVD : public CDVDSession
{
public:
- CResetDVD(LPCTSTR path)
- {
- if(Open(path))
- {
- if(BeginSession())
- {
+ CResetDVD(LPCTSTR path) {
+ if(Open(path)) {
+ if(BeginSession()) {
Authenticate(); /*GetDiscKey();*/
EndSession();
}
@@ -2657,8 +2579,9 @@ STDMETHODIMP CFGManagerDVD::RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPlayL
HRESULT hr;
CComPtr<IBaseFilter> pBF;
- if(FAILED(hr = AddSourceFilter(lpcwstrFile, lpcwstrFile, &pBF)))
+ if(FAILED(hr = AddSourceFilter(lpcwstrFile, lpcwstrFile, &pBF))) {
return hr;
+ }
return ConnectFilter(pBF, NULL);
}
@@ -2680,14 +2603,16 @@ STDMETHODIMP CFGManagerDVD::AddSourceFilter(LPCWSTR lpcwstrFileName, LPCWSTR lpc
CComPtr<IBaseFilter> pBF;
if(FAILED(hr = pBF.CoCreateInstance(clsid))
- || FAILED(hr = AddFilter(pBF, L"DVD Navigator")))
+ || FAILED(hr = AddFilter(pBF, L"DVD Navigator"))) {
return VFW_E_CANNOT_LOAD_SOURCE_FILTER;
+ }
CComQIPtr<IDvdControl2> pDVDC;
CComQIPtr<IDvdInfo2> pDVDI;
- if(!((pDVDC = pBF) && (pDVDI = pBF)))
+ if(!((pDVDC = pBF) && (pDVDI = pBF))) {
return E_NOINTERFACE;
+ }
WCHAR buff[_MAX_PATH];
ULONG len;
@@ -2695,14 +2620,16 @@ STDMETHODIMP CFGManagerDVD::AddSourceFilter(LPCWSTR lpcwstrFileName, LPCWSTR lpc
&& 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)
+ || FAILED(hr = pDVDI->GetDVDDirectory(buff, countof(buff), &len)) || len == 0) {
return E_INVALIDARG;
+ }
pDVDC->SetOption(DVD_ResetOnStop, FALSE);
pDVDC->SetOption(DVD_HMSF_TimeCodeEvents, TRUE);
- if(clsid == CLSID_DVDNavigator)
+ if(clsid == CLSID_DVDNavigator) {
CResetDVD(CString(buff));
+ }
*ppFilter = pBF.Detach();
diff --git a/src/apps/mplayerc/FGManager.h b/src/apps/mplayerc/FGManager.h
index 017b365df..095ab89f3 100644
--- a/src/apps/mplayerc/FGManager.h
+++ b/src/apps/mplayerc/FGManager.h
@@ -34,8 +34,7 @@ class CFGManager
, public CCritSec
{
public:
- struct path_t
- {
+ struct path_t {
CLSID clsid;
CString filter, pin;
};
diff --git a/src/apps/mplayerc/FGManagerBDA.cpp b/src/apps/mplayerc/FGManagerBDA.cpp
index c491d1385..2d0ee5b81 100644
--- a/src/apps/mplayerc/FGManagerBDA.cpp
+++ b/src/apps/mplayerc/FGManagerBDA.cpp
@@ -43,8 +43,7 @@
/// Format, Video MPEG2
-static const MPEG2VIDEOINFO sMpv_fmt =
-{
+static const MPEG2VIDEOINFO sMpv_fmt = {
{
// hdr
{0,0,720,576}, // rcSource
@@ -69,8 +68,7 @@ static const MPEG2VIDEOINFO sMpv_fmt =
};
/// Media type, Video MPEG2
-static const AM_MEDIA_TYPE mt_Mpv =
-{
+static const AM_MEDIA_TYPE mt_Mpv = {
MEDIATYPE_Video, // majortype
MEDIASUBTYPE_MPEG2_VIDEO, // subtype
FALSE, // bFixedSizeSamples
@@ -85,8 +83,7 @@ static const AM_MEDIA_TYPE mt_Mpv =
#define FCC_h264 MAKEFOURCC('h', '2', '6', '4')
/// Format, Video H264
-static const VIDEOINFOHEADER2 vih2_H264 =
-{
+static const VIDEOINFOHEADER2 vih2_H264 = {
{0,0,0,0}, // rcSource
{0,0,0,0}, // rcTarget
0, // dwBitRate,
@@ -101,8 +98,8 @@ static const VIDEOINFOHEADER2 vih2_H264 =
{
// bmiHeader
sizeof(BITMAPINFOHEADER), // biSize
-// 720, // biWidth
-// 576, // biHeight
+ // 720, // biWidth
+ // 576, // biHeight
1920, // biWidth
1080, // biHeight
0, // biPlanes
@@ -113,8 +110,7 @@ static const VIDEOINFOHEADER2 vih2_H264 =
};
/// Media type, Video H264
-static const AM_MEDIA_TYPE mt_H264 =
-{
+static const AM_MEDIA_TYPE mt_H264 = {
MEDIATYPE_Video, // majortype
MEDIASUBTYPE_H264, // subtype
FALSE, // bFixedSizeSamples
@@ -127,8 +123,7 @@ static const AM_MEDIA_TYPE mt_H264 =
};
/// Format, Audio (common)
-static const WAVEFORMATEX wf_Audio =
-{
+static const WAVEFORMATEX wf_Audio = {
WAVE_FORMAT_PCM, // wFormatTag
2, // nChannels
48000, // nSamplesPerSec
@@ -139,8 +134,7 @@ static const WAVEFORMATEX wf_Audio =
};
/// Media type, Audio MPEG2
-static const AM_MEDIA_TYPE mt_Mpa =
-{
+static const AM_MEDIA_TYPE mt_Mpa = {
MEDIATYPE_Audio, // majortype
MEDIASUBTYPE_MPEG2_AUDIO, // subtype
TRUE, // bFixedSizeSamples
@@ -153,8 +147,7 @@ static const AM_MEDIA_TYPE mt_Mpa =
};
/// Media type, Audio AC3
-static const AM_MEDIA_TYPE mt_Ac3 =
-{
+static const AM_MEDIA_TYPE mt_Ac3 = {
MEDIATYPE_Audio, // majortype
MEDIASUBTYPE_DOLBY_AC3, // subtype
TRUE, // bFixedSizeSamples
@@ -167,8 +160,7 @@ static const AM_MEDIA_TYPE mt_Ac3 =
};
/// Media type, Audio EAC3
-static const AM_MEDIA_TYPE mt_Eac3 =
-{
+static const AM_MEDIA_TYPE mt_Eac3 = {
MEDIATYPE_Audio, // majortype
MEDIASUBTYPE_DOLBY_DDPLUS, // subtype
TRUE, // bFixedSizeSamples
@@ -181,8 +173,7 @@ static const AM_MEDIA_TYPE mt_Eac3 =
};
/// Media type, PSI
-static const AM_MEDIA_TYPE mt_Psi =
-{
+static const AM_MEDIA_TYPE mt_Psi = {
MEDIATYPE_MPEG2_SECTIONS, // majortype
MEDIASUBTYPE_MPEG2DATA, // subtype
TRUE, // bFixedSizeSamples
@@ -195,8 +186,7 @@ static const AM_MEDIA_TYPE mt_Psi =
};
/// Media type, TIF
-static const AM_MEDIA_TYPE mt_Tif =
-{
+static const AM_MEDIA_TYPE mt_Tif = {
MEDIATYPE_MPEG2_SECTIONS, // majortype
MEDIASUBTYPE_DVB_SI, // subtype
TRUE, // bFixedSizeSamples
@@ -209,8 +199,7 @@ static const AM_MEDIA_TYPE mt_Tif =
};
/// Media type, EPG
-static const AM_MEDIA_TYPE mt_Epg =
-{
+static const AM_MEDIA_TYPE mt_Epg = {
MEDIATYPE_MPEG2_SECTIONS, // majortype
MEDIASUBTYPE_DVB_SI, // subtype
TRUE, // bFixedSizeSamples
@@ -223,8 +212,7 @@ static const AM_MEDIA_TYPE mt_Epg =
};
/// Media type, PMT
-static const AM_MEDIA_TYPE mt_Pmt =
-{
+static const AM_MEDIA_TYPE mt_Pmt = {
MEDIATYPE_MPEG2_SECTIONS, // majortype
MEDIASUBTYPE_DVB_SI, // subtype
TRUE, // bFixedSizeSamples
@@ -239,8 +227,7 @@ static const AM_MEDIA_TYPE mt_Pmt =
static const SUBTITLEINFO SubFormat = { 0, "", L"" };
/// Media type, subtitle
-static const AM_MEDIA_TYPE mt_Subtitle =
-{
+static const AM_MEDIA_TYPE mt_Subtitle = {
MEDIATYPE_Subtitle, // majortype
MEDIASUBTYPE_DVB_SUBTITLES, // subtype
FALSE, // bFixedSizeSamples
@@ -271,10 +258,11 @@ CFGManagerBDA::CFGManagerBDA(LPCTSTR pName, LPUNKNOWN pUnk, HWND hWnd)
m_DVBStreams[DVB_EPG] = CDVBStream(L"epg", &mt_Epg);
// Warning : MEDIA_ELEMENTARY_STREAM didn't work for subtitles with Windows XP!
- if (IsVistaOrAbove())
+ if (IsVistaOrAbove()) {
m_DVBStreams[DVB_SUB] = CDVBStream(L"sub", &mt_Subtitle/*, false, MEDIA_TRANSPORT_PAYLOAD*/);
- else
+ } else {
m_DVBStreams[DVB_SUB] = CDVBStream(L"sub", &mt_Subtitle, false, MEDIA_TRANSPORT_PAYLOAD);
+ }
m_nCurVideoType = DVB_MPV;
m_nCurAudioType = DVB_MPA;
@@ -282,11 +270,9 @@ CFGManagerBDA::CFGManagerBDA(LPCTSTR pName, LPUNKNOWN pUnk, HWND hWnd)
// Hack : remove audio switcher !
POSITION pos = m_transform.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CFGFilter* pFGF = m_transform.GetAt(pos);
- if(pFGF->GetCLSID() == __uuidof(CAudioSwitcherFilter))
- {
+ if(pFGF->GetCLSID() == __uuidof(CAudioSwitcherFilter)) {
m_transform.RemoveAt (pos);
delete pFGF;
break;
@@ -306,24 +292,28 @@ CFGManagerBDA::~CFGManagerBDA()
HRESULT CFGManagerBDA::CreateKSFilter(IBaseFilter** ppBF, CLSID KSCategory, CStringW& DisplayName)
{
HRESULT hr = VFW_E_NOT_FOUND;
- BeginEnumSysDev (KSCategory, pMoniker)
- {
+ 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)) )
- {
+ SUCCEEDED (pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL)) ) {
CStringW Name = CStringW(strName);
- if (Name != DisplayName) continue;
+ if (Name != DisplayName) {
+ continue;
+ }
hr = pMoniker->BindToObject(NULL, NULL, IID_IBaseFilter, (void**)ppBF);
- if (SUCCEEDED (hr)) hr = AddFilter (*ppBF, CStringW(var.bstrVal));
+ if (SUCCEEDED (hr)) {
+ hr = AddFilter (*ppBF, CStringW(var.bstrVal));
+ }
break;
}
- if (strName) CoTaskMemFree(strName);
+ if (strName) {
+ CoTaskMemFree(strName);
+ }
}
EndEnumSysDev
@@ -341,23 +331,24 @@ HRESULT CFGManagerBDA::SearchIBDATopology(const CComPtr<IBaseFilter>& pTuner, RE
HRESULT hr = pTop->GetNodeTypes(&NodeTypes, _countof(NodeType), NodeType);
- if (FAILED(hr))
+ if (FAILED(hr)) {
return hr;
+ }
- for (ULONG i = 0; i < NodeTypes; i++)
- {
+ for (ULONG i = 0; i < NodeTypes; i++) {
ULONG nInterfaces;
GUID aInterface[32];
hr = pTop->GetNodeInterfaces(NodeType[i], &nInterfaces, _countof(aInterface), aInterface);
- if (FAILED(hr))
+ if (FAILED(hr)) {
continue;
+ }
- for (ULONG j = 0; j < nInterfaces; j++)
- {
- if (aInterface[j] == iid)
+ for (ULONG j = 0; j < nInterfaces; j++) {
+ if (aInterface[j] == iid) {
return pTop->GetControlNode(0, 1, NodeType[i], &pUnk);
+ }
}
}
@@ -369,32 +360,30 @@ HRESULT CFGManagerBDA::SearchIBDATopology(const CComPtr<IBaseFilter>& pTuner, RE
HRESULT CFGManagerBDA::ConnectFilters(IBaseFilter* pOutFiter, IBaseFilter* pInFilter)
{
HRESULT hr = VFW_E_CANNOT_CONNECT;
- BeginEnumPins(pOutFiter, pEP, pOutPin)
- {
+ BeginEnumPins(pOutFiter, pEP, pOutPin) {
if(S_OK == IsPinDirection(pOutPin, PINDIR_OUTPUT)
- && S_OK != IsPinConnected(pOutPin))
- {
- BeginEnumPins(pInFilter, pEP, pInPin)
- {
+ && S_OK != IsPinConnected(pOutPin)) {
+ BeginEnumPins(pInFilter, pEP, pInPin) {
if(S_OK == IsPinDirection(pInPin, PINDIR_INPUT)
- && S_OK != IsPinConnected(pInPin))
- {
+ && 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;
+ /*#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;
@@ -417,32 +406,27 @@ STDMETHODIMP CFGManagerBDA::RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPlayL
LOG (_T("\nCreating BDA filters..."));
CheckAndLog (CreateKSFilter (&pNetwork, KSCATEGORY_BDA_NETWORK_PROVIDER, s.strBDANetworkProvider), "BDA : Network provider creation");
-// CheckAndLog (CreateKSFilter (&pTuner, KSCATEGORY_BDA_NETWORK_TUNER, s.strBDATuner), "BDA : Network tuner creation");
- if (FAILED(hr = CreateKSFilter (&pTuner, KSCATEGORY_BDA_NETWORK_TUNER, s.strBDATuner)))
- {
+ // CheckAndLog (CreateKSFilter (&pTuner, KSCATEGORY_BDA_NETWORK_TUNER, s.strBDATuner), "BDA : Network tuner creation");
+ if (FAILED(hr = CreateKSFilter (&pTuner, KSCATEGORY_BDA_NETWORK_TUNER, s.strBDATuner))) {
AfxMessageBox(_T("BDA Error: could not create Network tuner. "), 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
- {
-// CheckAndLog (CreateKSFilter (&pReceiver, KSCATEGORY_BDA_RECEIVER_COMPONENT, s.strBDAReceiver), "BDA : Receiver creation");
- if (FAILED(hr = CreateKSFilter (&pReceiver, KSCATEGORY_BDA_RECEIVER_COMPONENT, s.strBDAReceiver)))
- {
+ if (s.strBDATuner.Right(40) != s.strBDAReceiver.Right(40)) { // check if filters are the same
+ // CheckAndLog (CreateKSFilter (&pReceiver, KSCATEGORY_BDA_RECEIVER_COMPONENT, s.strBDAReceiver), "BDA : Receiver creation");
+ if (FAILED(hr = CreateKSFilter (&pReceiver, KSCATEGORY_BDA_RECEIVER_COMPONENT, s.strBDAReceiver))) {
AfxMessageBox(_T("BDA Error: could not create Network receiver."), MB_OK);
TRACE("BDA : Receiver creation"" :0x%08x\n",hr);
return hr;
}
-// CheckAndLog (ConnectFilters (pNetwork, pTuner), "BDA : Network <-> Tuner");
- if (FAILED(hr = ConnectFilters (pNetwork, pTuner)))
- {
+ // CheckAndLog (ConnectFilters (pNetwork, pTuner), "BDA : Network <-> Tuner");
+ if (FAILED(hr = ConnectFilters (pNetwork, pTuner))) {
AfxMessageBox(_T("BDA Error: could not connect Network and Tuner."), MB_OK);
TRACE("BDA : Network <-> Tuner"" :0x%08x\n",hr);
return hr;
}
-// CheckAndLog (ConnectFilters (pTuner, pReceiver), "BDA : Tuner <-> Receiver");
- if (FAILED(hr = ConnectFilters (pTuner, pReceiver)))
- {
+ // CheckAndLog (ConnectFilters (pTuner, pReceiver), "BDA : Tuner <-> Receiver");
+ if (FAILED(hr = ConnectFilters (pTuner, pReceiver))) {
AfxMessageBox(_T("BDA Error: could not connect Tuner and Receiver."), MB_OK);
TRACE("BDA : Tuner <-> Receiver"" :0x%08x\n",hr);
return hr;
@@ -451,35 +435,29 @@ STDMETHODIMP CFGManagerBDA::RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPlayL
CComPtr<IBaseFilter> pMpeg2Demux;
m_pBDAControl = pTuner;
-// CheckAndLog (SearchIBDATopology (pTuner, m_pBDAFreq), "BDA : IBDA_FrequencyFilter topology");
- if (FAILED(hr = SearchIBDATopology (pTuner, m_pBDAFreq)))
- {
+ // CheckAndLog (SearchIBDATopology (pTuner, m_pBDAFreq), "BDA : IBDA_FrequencyFilter topology");
+ 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;
}
-// CheckAndLog (SearchIBDATopology (pTuner, m_pBDAStats), "BDA : IBDA_SignalStatistics topology");
- if (FAILED(hr = SearchIBDATopology (pTuner, m_pBDAStats)))
- {
+ // CheckAndLog (SearchIBDATopology (pTuner, m_pBDAStats), "BDA : IBDA_SignalStatistics topology");
+ 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
-// CheckAndLog (CreateMicrosoftDemux (pReceiver, pMpeg2Demux), "BDA : Microsoft demux creation");
- if (FAILED(hr = CreateMicrosoftDemux (pReceiver, pMpeg2Demux)))
- {
+ // CheckAndLog (CreateMicrosoftDemux (pReceiver, pMpeg2Demux), "BDA : Microsoft demux creation");
+ if (FAILED(hr = CreateMicrosoftDemux (pReceiver, pMpeg2Demux))) {
AfxMessageBox(_T("BDA Error: could not create Demux."), MB_OK);
TRACE("BDA : Microsoft demux creation"" :0x%08x\n",hr);
return hr;
}
- }
- else // if same filters, connect pNetwork to pTuner directly
- {
-// CheckAndLog (ConnectFilters (pNetwork, pTuner), "BDA : Network <-> Tuner/Receiver");
- if (FAILED(hr = ConnectFilters (pNetwork, pTuner)))
- {
+ } else { // if same filters, connect pNetwork to pTuner directly
+ // CheckAndLog (ConnectFilters (pNetwork, pTuner), "BDA : Network <-> Tuner/Receiver");
+ if (FAILED(hr = ConnectFilters (pNetwork, pTuner))) {
AfxMessageBox(_T("BDA Error: could not connect Network <-> Tuner/Receiver."), MB_OK);
TRACE("BDA : Network <-> Tuner/Receiver"" :0x%08x\n",hr);
return hr;
@@ -487,16 +465,14 @@ STDMETHODIMP CFGManagerBDA::RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPlayL
CComPtr<IBaseFilter> pMpeg2Demux;
m_pBDAControl = pTuner;
-// CheckAndLog (SearchIBDATopology (pTuner, m_pBDAFreq), "BDA : IBDA_FrequencyFilter topology");
- if (FAILED(hr = SearchIBDATopology (pTuner, m_pBDAFreq)))
- {
+ // CheckAndLog (SearchIBDATopology (pTuner, m_pBDAFreq), "BDA : IBDA_FrequencyFilter topology");
+ 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;
}
-// CheckAndLog (SearchIBDATopology (pTuner, m_pBDAStats), "BDA : IBDA_SignalStatistics topology");
- if (FAILED(hr = SearchIBDATopology (pTuner, m_pBDAStats)))
- {
+ // CheckAndLog (SearchIBDATopology (pTuner, m_pBDAStats), "BDA : IBDA_SignalStatistics topology");
+ 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;
@@ -504,9 +480,8 @@ STDMETHODIMP CFGManagerBDA::RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPlayL
LOG (_T("Network -> Receiver connected."));
// Create Mpeg2 demux
-// CheckAndLog (CreateMicrosoftDemux (pTuner, pMpeg2Demux), "BDA : Microsoft demux creation");
- if (FAILED(hr = CreateMicrosoftDemux (pTuner, pMpeg2Demux)))
- {
+ // CheckAndLog (CreateMicrosoftDemux (pTuner, pMpeg2Demux), "BDA : Microsoft demux creation");
+ if (FAILED(hr = CreateMicrosoftDemux (pTuner, pMpeg2Demux))) {
AfxMessageBox(_T("BDA Error: could not create Demux."), MB_OK);
TRACE("BDA : Microsoft demux creation"" :0x%08x\n",hr);
return hr;
@@ -515,8 +490,7 @@ STDMETHODIMP CFGManagerBDA::RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPlayL
#ifdef _DEBUG
LOG (_T("\nFilter list:"));
- BeginEnumFilters(this, pEF, pBF)
- {
+ BeginEnumFilters(this, pEF, pBF) {
LOG(GetFilterName(pBF));
}
EndEnumFilters;
@@ -537,12 +511,12 @@ STDMETHODIMP CFGManagerBDA::SetChannel (int nChannelPrefNumber)
AppSettings& s = AfxGetAppSettings();
CDVBChannel* pChannel = s.FindChannelByPref(nChannelPrefNumber);
- if (pChannel != NULL)
- {
+ if (pChannel != NULL) {
hr = SetChannelInternal (pChannel);
- if (SUCCEEDED (hr))
+ if (SUCCEEDED (hr)) {
s.nDVBLastChannel = nChannelPrefNumber;
+ }
}
return hr;
@@ -579,11 +553,11 @@ STDMETHODIMP CFGManagerBDA::Scan(ULONG ulFrequency, HWND hWnd)
Parser.ParseNIT();
POSITION pos = Parser.Channels.GetStartPosition();
- while(pos)
- {
+ while(pos) {
CDVBChannel& Channel = Parser.Channels.GetNextValue(pos);
- if (Channel.HasName())
+ if (Channel.HasName()) {
::SendMessage (hWnd, WM_TUNER_NEW_CHANNEL, 0, (LPARAM)(LPCTSTR)Channel.ToString());
+ }
}
return S_OK;
@@ -611,8 +585,9 @@ STDMETHODIMP CFGManagerBDA::Count(DWORD* pcStreams)
*pcStreams = 0;
- if (pChannel != 0)
+ if (pChannel != 0) {
*pcStreams = pChannel->GetAudioCount() + pChannel->GetSubtitleCount();
+ }
return S_OK;
}
@@ -626,29 +601,24 @@ STDMETHODIMP CFGManagerBDA::Enable(long lIndex, DWORD dwFlags)
CDVBStream* pStream = NULL;
FILTER_STATE nState;
- if (pChannel)
- {
- if (lIndex>=0 && lIndex < pChannel->GetAudioCount())
- {
+ if (pChannel) {
+ if (lIndex>=0 && lIndex < pChannel->GetAudioCount()) {
pStreamInfo = pChannel->GetAudio(lIndex);
pStream = &m_DVBStreams[pStreamInfo->Type];
- if (pStream && pStreamInfo)
- {
+ if (pStream && pStreamInfo) {
nState = GetState();
- if (m_nCurAudioType != pStreamInfo->Type)
+ 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())
- {
+ } else if (lIndex > 0 && lIndex < pChannel->GetAudioCount()+pChannel->GetSubtitleCount()) {
pStreamInfo = pChannel->GetSubtitle(lIndex-pChannel->GetAudioCount());
- if (pStreamInfo)
- {
+ if (pStreamInfo) {
m_DVBStreams[DVB_SUB].Map(pStreamInfo->PID);
hr = S_OK;
}
@@ -667,38 +637,52 @@ STDMETHODIMP CFGManagerBDA::Info(long lIndex, AM_MEDIA_TYPE** ppmt, DWORD* pdwFl
CDVBStream* pStream = NULL;
CDVBStream* pCurrentStream = NULL;
- if (pChannel)
- {
- if (lIndex>=0 && lIndex < pChannel->GetAudioCount())
- {
+ 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())
- {
+ 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 = &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)
- {
+ 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;
+ if(*ppszName == NULL) {
+ return E_OUTOFMEMORY;
+ }
wcscpy_s(*ppszName, str.GetLength()+1, str);
}
@@ -743,35 +727,29 @@ HRESULT CFGManagerBDA::CreateMicrosoftDemux(IBaseFilter* pReceiver, CComPtr<IBas
LOG (_T("Receiver -> Demux connected."));
POSITION pos = m_DVBStreams.GetStartPosition();
- while (pos)
- {
+ 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 (nType != DVB_EPG) { // Hack: DVB_EPG not required
if (!Stream.GetFindExisting() ||
- (pPin = FindPin (pMpeg2Demux, PINDIR_OUTPUT, Stream.GetMediaType())) == NULL)
- {
+ (pPin = FindPin (pMpeg2Demux, PINDIR_OUTPUT, Stream.GetMediaType())) == NULL) {
CheckNoLog (pDemux->CreateOutputPin ((AM_MEDIA_TYPE*)Stream.GetMediaType(), Stream.GetName(), &pPin));
}
-// CheckNoLog (Connect (pPin, NULL, false));
-// Stream.SetPin (pPin);
+ // CheckNoLog (Connect (pPin, NULL, false));
+ // Stream.SetPin (pPin);
// Complete graph for one audio stream and one video stream (using standard graph builder rules)
-// if (nType == m_nCurVideoType || nType == m_nCurAudioType)
-// {
-// Connect (GetFirstDisconnectedPin (Stream.GetFilter(), PINDIR_OUTPUT), NULL);
-// }
- if (nType == m_nCurVideoType || nType == m_nCurAudioType)
- {
+ // if (nType == m_nCurVideoType || nType == m_nCurAudioType)
+ // {
+ // Connect (GetFirstDisconnectedPin (Stream.GetFilter(), PINDIR_OUTPUT), NULL);
+ // }
+ 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
- {
+ } else {
CheckNoLog (Connect (pPin, NULL, false));
Stream.SetPin (pPin);
LOG (_T("Filter connected to Demux for media type %d."),nType);
@@ -792,14 +770,12 @@ HRESULT CFGManagerBDA::SetChannelInternal (CDVBChannel* pChannel)
int nState = GetState();
- if (pChannel->GetVideoPID() != 0)
- {
+ if (pChannel->GetVideoPID() != 0) {
SwitchStream (m_nCurVideoType, pChannel->GetVideoType());
- if (m_fHideWindow)
+ if (m_fHideWindow) {
fRadioToTV = true;
- }
- else
- {
+ }
+ } else {
m_fHideWindow = true;
((CMainFrame*)AfxGetMainWnd())->HideVideoWindow(m_fHideWindow);
}
@@ -807,25 +783,24 @@ HRESULT CFGManagerBDA::SetChannelInternal (CDVBChannel* pChannel)
SwitchStream (m_nCurAudioType, pChannel->GetDefaultAudioType());
CheckNoLog (SetFrequency (pChannel->GetFrequency()));
- if (pChannel->GetVideoPID() != 0)
- {
+ if (pChannel->GetVideoPID() != 0) {
CheckNoLog (m_DVBStreams[m_nCurVideoType].Map (pChannel->GetVideoPID()));
}
CheckNoLog (m_DVBStreams[m_nCurAudioType].Map (pChannel->GetDefaultAudioPID()));
- if (GetState() == State_Stopped)
+ if (GetState() == State_Stopped) {
hr = ChangeState ((FILTER_STATE)nState);
+ }
- if (fRadioToTV)
- {
+ if (fRadioToTV) {
m_fHideWindow = false;
Sleep(1800);
((CMainFrame*)AfxGetMainWnd())->HideVideoWindow(m_fHideWindow);
}
// TODO : remove sub later!
-// CheckNoLog (m_DVBStreams[DVB_SUB].Map (pChannel->GetDefaultSubtitlePID()));
+ // CheckNoLog (m_DVBStreams[DVB_SUB].Map (pChannel->GetDefaultSubtitlePID()));
return hr;
}
@@ -833,16 +808,16 @@ HRESULT CFGManagerBDA::SetChannelInternal (CDVBChannel* pChannel)
HRESULT CFGManagerBDA::SwitchStream (DVB_STREAM_TYPE& nOldType, DVB_STREAM_TYPE nNewType)
{
- if (nNewType != nOldType)
- {
+ if (nNewType != nOldType) {
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)
+ if (GetState() != State_Stopped) {
ChangeState (State_Stopped);
+ }
pOldOut->ConnectedTo(&pInPin);
Disconnect (pOldOut);
Disconnect (pInPin);
@@ -859,8 +834,9 @@ HRESULT CFGManagerBDA::UpdatePSI(PresentFollowing &NowNext)
CDVBChannel* pChannel = s.FindChannelByPref(s.nDVBLastChannel);
CMpeg2DataParser Parser (m_DVBStreams[DVB_PSI].GetFilter());
- if (pChannel->GetNowNextFlag())
+ if (pChannel->GetNowNextFlag()) {
hr = Parser.ParseEIT(pChannel->GetSID(), NowNext);
+ }
return hr;
}
@@ -874,37 +850,34 @@ HRESULT CFGManagerBDA::ChangeState(FILTER_STATE nRequested)
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 (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;
}
- if (SUCCEEDED(hr))
- ((CMainFrame*)AfxGetMainWnd())->SetTimersPlay();
- LOG (_T("IMediaControl play: %d."),hr);
- return hr;
- }
}
}
return hr;
diff --git a/src/apps/mplayerc/FGManagerBDA.h b/src/apps/mplayerc/FGManagerBDA.h
index 1ad9239fc..12804ffb3 100644
--- a/src/apps/mplayerc/FGManagerBDA.h
+++ b/src/apps/mplayerc/FGManagerBDA.h
@@ -34,8 +34,7 @@ class CDVBStream
{
public :
CDVBStream() :
- m_ulMappedPID(0)
- {
+ m_ulMappedPID(0) {
}
CDVBStream(LPWSTR strName, const AM_MEDIA_TYPE * pmt, bool bFindExisting = false, MEDIA_SAMPLE_CONTENT nMsc=MEDIA_ELEMENTARY_STREAM) :
@@ -46,54 +45,45 @@ public :
m_ulMappedPID(0)
{}
- LPWSTR GetName() /*const*/
- {
+ LPWSTR GetName() { /*const*/
return m_Name;
};
- const AM_MEDIA_TYPE* GetMediaType() /*const*/
- {
+ const AM_MEDIA_TYPE* GetMediaType() { /*const*/
return m_pmt;
};
- bool GetFindExisting() const
- {
+ bool GetFindExisting() const {
return m_bFindExisting;
};
- IBaseFilter* GetFilter()
- {
+ IBaseFilter* GetFilter() {
return m_pFilter;
};
- void SetPin(IPin* pPin)
- {
+ void SetPin(IPin* pPin) {
CComPtr<IPin> pPinOut;
PIN_INFO PinInfo;
m_pMap = pPin;
if (m_pMap &&
SUCCEEDED (pPin->ConnectedTo (&pPinOut)) &&
- SUCCEEDED (pPinOut->QueryPinInfo (&PinInfo)))
- {
+ SUCCEEDED (pPinOut->QueryPinInfo (&PinInfo))) {
m_pFilter.Attach (PinInfo.pFilter);
}
}
- HRESULT Map (ULONG ulPID)
- {
+ 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)
- {
+ HRESULT Unmap (ULONG ulPID) {
CheckPointer (m_pMap, E_UNEXPECTED);
m_ulMappedPID = 0;
return m_pMap->UnmapPID (1, &ulPID);
}
- ULONG GetMappedPID() const
- {
+ ULONG GetMappedPID() const {
return m_ulMappedPID;
}
@@ -106,20 +96,16 @@ private :
MEDIA_SAMPLE_CONTENT m_nMsc;
ULONG m_ulMappedPID;
- void ClearMaps()
- {
+ void ClearMaps() {
HRESULT hr;
CComPtr<IEnumPIDMap> pEnumMap;
- if (SUCCEEDED(hr = m_pMap->EnumPIDMap(&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++)
- {
+ 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);
@@ -179,13 +165,11 @@ private :
FILTER_STATE GetState();
template <class ITF>
- HRESULT SearchIBDATopology(const CComPtr<IBaseFilter> & pTuner, CComPtr<ITF> & pItf)
- {
+ HRESULT SearchIBDATopology(const CComPtr<IBaseFilter> & pTuner, CComPtr<ITF> & pItf) {
CComPtr<IUnknown> pUnk;
HRESULT hr = SearchIBDATopology(pTuner, __uuidof(ITF), pUnk);
- if (SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
hr = pUnk.QueryInterface(&pItf);
}
return !pItf ? E_NOINTERFACE : hr;
@@ -193,10 +177,11 @@ private :
HRESULT SearchIBDATopology(const CComPtr<IBaseFilter>& pTuner, REFIID iid, CComPtr<IUnknown>& pUnk);
- void Sleep(unsigned int mseconds)
- {
+ void Sleep(unsigned int mseconds) {
clock_t goal = mseconds + clock();
- while (goal > clock());
+ while (goal > clock()) {
+ ;
+ }
}
};
@@ -207,12 +192,11 @@ static void LOG(LPCTSTR fmt, ...)
{
va_list args;
va_start(args, fmt);
-// int nCount = _vsctprintf(fmt, args) + 1;
+ // 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)
- {
+ if(_tfopen_s(&f, LOG_FILE, _T("at")) == 0) {
fseek(f, 0, 2);
_ftprintf(f, _T("%s\n"), buff);
fclose(f);
diff --git a/src/apps/mplayerc/FakeFilterMapper2.cpp b/src/apps/mplayerc/FakeFilterMapper2.cpp
index 2c9c43bba..daafea342 100644
--- a/src/apps/mplayerc/FakeFilterMapper2.cpp
+++ b/src/apps/mplayerc/FakeFilterMapper2.cpp
@@ -228,34 +228,28 @@ LONG (WINAPI * Real_RegSetValueA)(HKEY a0, LPCSTR a1, DWORD a2, LPCSTR a3, DWORD
HRESULT WINAPI Mine_CoCreateInstance(IN REFCLSID rclsid, IN LPUNKNOWN pUnkOuter,
IN DWORD dwClsContext, IN REFIID riid, OUT LPVOID FAR* ppv)
{
- if(CFilterMapper2::m_pFilterMapper2)
- {
+ if(CFilterMapper2::m_pFilterMapper2) {
CheckPointer(ppv, E_POINTER);
- if(rclsid == CLSID_FilterMapper)
- {
+ if(rclsid == CLSID_FilterMapper) {
ASSERT(0);
return REGDB_E_CLASSNOTREG; // sorry...
}
- if(rclsid == CLSID_FilterMapper2)
- {
- if(pUnkOuter) return CLASS_E_NOAGGREGATION;
+ if(rclsid == CLSID_FilterMapper2) {
+ if(pUnkOuter) {
+ return CLASS_E_NOAGGREGATION;
+ }
- if(riid == __uuidof(IUnknown))
- {
+ if(riid == __uuidof(IUnknown)) {
CFilterMapper2::m_pFilterMapper2->AddRef();
*ppv = (IUnknown*)CFilterMapper2::m_pFilterMapper2;
return S_OK;
- }
- else if(riid == __uuidof(IFilterMapper2))
- {
+ } else if(riid == __uuidof(IFilterMapper2)) {
CFilterMapper2::m_pFilterMapper2->AddRef();
*ppv = (IFilterMapper2*)CFilterMapper2::m_pFilterMapper2;
return S_OK;
- }
- else
- {
+ } else {
return E_NOINTERFACE;
}
}
@@ -273,14 +267,12 @@ HRESULT WINAPI Mine_CoCreateInstance(IN REFCLSID rclsid, IN LPUNKNOWN pUnkOuter,
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?)
- {
+ || 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)))
- {
+ if(SUCCEEDED(hr = Real_CoCreateInstance(rclsid, pUnk, dwClsContext, __uuidof(IUnknown), (void**)&pInner))) {
pMK->SetInner(pInner);
return pUnk->QueryInterface(riid, ppv);
}
@@ -293,24 +285,21 @@ HRESULT WINAPI Mine_CoCreateInstance(IN REFCLSID rclsid, IN LPUNKNOWN pUnkOuter,
LONG WINAPI Mine_RegCloseKey(HKEY a0)
{
- if(CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY)
- {
+ 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)
- {
+ 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)
- {
+ if(CFilterMapper2::m_pFilterMapper2) {
*a2 = FAKEHKEY;
return ERROR_SUCCESS;
}
@@ -318,8 +307,7 @@ LONG WINAPI Mine_RegCreateKeyA(HKEY a0, LPCSTR a1, PHKEY a2)
}
LONG WINAPI Mine_RegCreateKeyW(HKEY a0, LPCWSTR a1, PHKEY a2)
{
- if(CFilterMapper2::m_pFilterMapper2)
- {
+ if(CFilterMapper2::m_pFilterMapper2) {
*a2 = FAKEHKEY;
return ERROR_SUCCESS;
}
@@ -327,8 +315,7 @@ LONG WINAPI Mine_RegCreateKeyW(HKEY a0, LPCWSTR a1, PHKEY 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)
- {
+ if(CFilterMapper2::m_pFilterMapper2) {
*a7 = FAKEHKEY;
return ERROR_SUCCESS;
}
@@ -336,8 +323,7 @@ LONG WINAPI Mine_RegCreateKeyExA(HKEY a0, LPCSTR a1, DWORD a2, LPSTR a3, DWORD a
}
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)
- {
+ if(CFilterMapper2::m_pFilterMapper2) {
*a7 = FAKEHKEY;
return ERROR_SUCCESS;
}
@@ -345,72 +331,63 @@ LONG WINAPI Mine_RegCreateKeyExW(HKEY a0, LPCWSTR a1, DWORD a2, LPWSTR a3, DWORD
}
LONG WINAPI Mine_RegDeleteKeyA(HKEY a0, LPCSTR a1)
{
- if(CFilterMapper2::m_pFilterMapper2 && (a0 == FAKEHKEY || (int)a0 < 0))
- {
+ if(CFilterMapper2::m_pFilterMapper2 && (a0 == FAKEHKEY || (int)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)a0 < 0))
- {
+ if(CFilterMapper2::m_pFilterMapper2 && (a0 == FAKEHKEY || (int)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)a0 < 0))
- {
+ if(CFilterMapper2::m_pFilterMapper2 && (a0 == FAKEHKEY || (int)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)a0 < 0))
- {
+ if(CFilterMapper2::m_pFilterMapper2 && (a0 == FAKEHKEY || (int)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)
- {
+ 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)
- {
+ 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)
- {
+ 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)
- {
+ 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)
- {
+ if(CFilterMapper2::m_pFilterMapper2) {
*a2 = FAKEHKEY;
return ERROR_SUCCESS;
}
@@ -418,8 +395,7 @@ LONG WINAPI Mine_RegOpenKeyA(HKEY a0, LPCSTR a1, PHKEY a2)
}
LONG WINAPI Mine_RegOpenKeyW(HKEY a0, LPCWSTR a1, PHKEY a2)
{
- if(CFilterMapper2::m_pFilterMapper2)
- {
+ if(CFilterMapper2::m_pFilterMapper2) {
*a2 = FAKEHKEY;
return ERROR_SUCCESS;
}
@@ -427,8 +403,7 @@ LONG WINAPI Mine_RegOpenKeyW(HKEY a0, LPCWSTR a1, PHKEY 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)))
- {
+ if(CFilterMapper2::m_pFilterMapper2 && (a3&(KEY_SET_VALUE|KEY_CREATE_SUB_KEY))) {
*a4 = FAKEHKEY;
return ERROR_SUCCESS;
}
@@ -436,8 +411,7 @@ LONG WINAPI Mine_RegOpenKeyExA(HKEY a0, LPCSTR a1, DWORD a2, REGSAM a3, PHKEY 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)))
- {
+ if(CFilterMapper2::m_pFilterMapper2 && (a3&(KEY_SET_VALUE|KEY_CREATE_SUB_KEY))) {
*a4 = FAKEHKEY;
return ERROR_SUCCESS;
}
@@ -445,24 +419,21 @@ LONG WINAPI Mine_RegOpenKeyExW(HKEY a0, LPCWSTR a1, DWORD a2, REGSAM a3, PHKEY a
}
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)
- {
+ 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)
- {
+ 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)
- {
+ if(CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY) {
*a3 = 0;
return ERROR_SUCCESS;
}
@@ -470,8 +441,7 @@ LONG WINAPI Mine_RegQueryValueA(HKEY a0, LPCSTR a1, LPSTR a2, PLONG a3)
}
LONG WINAPI Mine_RegQueryValueW(HKEY a0, LPCWSTR a1, LPWSTR a2, PLONG a3)
{
- if(CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY)
- {
+ if(CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY) {
*a3 = 0;
return ERROR_SUCCESS;
}
@@ -479,8 +449,7 @@ LONG WINAPI Mine_RegQueryValueW(HKEY a0, LPCWSTR a1, LPWSTR a2, PLONG a3)
}
LONG WINAPI Mine_RegQueryValueExA(HKEY a0, LPCSTR a1, LPDWORD a2, LPDWORD a3, LPBYTE a4, LPDWORD a5)
{
- if(CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY)
- {
+ if(CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY) {
*a5 = 0;
return ERROR_SUCCESS;
}
@@ -488,8 +457,7 @@ LONG WINAPI Mine_RegQueryValueExA(HKEY a0, LPCSTR a1, LPDWORD a2, LPDWORD a3, LP
}
LONG WINAPI Mine_RegQueryValueExW(HKEY a0, LPCWSTR a1, LPDWORD a2, LPDWORD a3, LPBYTE a4, LPDWORD a5)
{
- if(CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY)
- {
+ if(CFilterMapper2::m_pFilterMapper2 && a0 == FAKEHKEY) {
*a5 = 0;
return ERROR_SUCCESS;
}
@@ -497,32 +465,28 @@ LONG WINAPI Mine_RegQueryValueExW(HKEY a0, LPCWSTR a1, LPDWORD a2, LPDWORD a3, L
}
LONG WINAPI Mine_RegSetValueA(HKEY a0, LPCSTR a1, DWORD a2, LPCSTR a3, DWORD a4)
{
- if(CFilterMapper2::m_pFilterMapper2 && (a0 == FAKEHKEY || (int)a0 < 0))
- {
+ if(CFilterMapper2::m_pFilterMapper2 && (a0 == FAKEHKEY || (int)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)a0 < 0))
- {
+ if(CFilterMapper2::m_pFilterMapper2 && (a0 == FAKEHKEY || (int)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)a0 < 0))
- {
+ if(CFilterMapper2::m_pFilterMapper2 && (a0 == FAKEHKEY || (int)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)a0 < 0))
- {
+ if(CFilterMapper2::m_pFilterMapper2 && (a0 == FAKEHKEY || (int)a0 < 0)) {
return ERROR_SUCCESS;
}
return Real_RegSetValueExW(a0, a1, a2, a3, a4, a5);
@@ -538,8 +502,7 @@ bool CFilterMapper2::fInitialized = false;
void CFilterMapper2::Init()
{
- if(!fInitialized)
- {
+ if(!fInitialized) {
DetourAttach(&(PVOID&)Real_CoCreateInstance, (PVOID)Mine_CoCreateInstance);
DetourAttach(&(PVOID&)Real_RegCloseKey, (PVOID)Mine_RegCloseKey);
DetourAttach(&(PVOID&)Real_RegFlushKey, (PVOID)Mine_RegFlushKey);
@@ -585,8 +548,7 @@ CFilterMapper2::CFilterMapper2(bool fRefCounted, bool fAllowUnreg, LPUNKNOWN pUn
HRESULT hr = Real_CoCreateInstance(
CLSID_FilterMapper2, (IUnknown*)(INonDelegatingUnknown*)this, CLSCTX_ALL,
__uuidof(IUnknown), (void**)&m_pFM2);
- if(FAILED(hr) || !m_pFM2)
- {
+ if(FAILED(hr) || !m_pFM2) {
ASSERT(0);
return;
}
@@ -595,13 +557,16 @@ CFilterMapper2::CFilterMapper2(bool fRefCounted, bool fAllowUnreg, LPUNKNOWN pUn
CFilterMapper2::~CFilterMapper2()
{
POSITION pos = m_filters.GetHeadPosition();
- while(pos) delete m_filters.GetNext(pos);
+ while(pos) {
+ delete m_filters.GetNext(pos);
+ }
}
STDMETHODIMP CFilterMapper2::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- if(riid == __uuidof(IFilterMapper2))
+ if(riid == __uuidof(IFilterMapper2)) {
return GetInterface((IFilterMapper2*)this, ppv);
+ }
HRESULT hr = m_pFM2 ? m_pFM2->QueryInterface(riid, ppv) : E_NOINTERFACE;
@@ -612,11 +577,9 @@ STDMETHODIMP CFilterMapper2::NonDelegatingQueryInterface(REFIID riid, void** ppv
void CFilterMapper2::Register(CString path)
{
- if(HMODULE h = LoadLibrary(path))
- {
+ if(HMODULE h = LoadLibrary(path)) {
typedef HRESULT (__stdcall * PDllRegisterServer)();
- if(PDllRegisterServer p = (PDllRegisterServer)GetProcAddress(h, "DllRegisterServer"))
- {
+ if(PDllRegisterServer p = (PDllRegisterServer)GetProcAddress(h, "DllRegisterServer")) {
ASSERT(CFilterMapper2::m_pFilterMapper2 == NULL);
CFilterMapper2::m_pFilterMapper2 = this;
@@ -634,12 +597,9 @@ void CFilterMapper2::Register(CString path)
STDMETHODIMP CFilterMapper2::CreateCategory(REFCLSID clsidCategory, DWORD dwCategoryMerit, LPCWSTR Description)
{
- if(!m_path.IsEmpty())
- {
+ if(!m_path.IsEmpty()) {
return S_OK;
- }
- else if(CComQIPtr<IFilterMapper2> pFM2 = m_pFM2)
- {
+ } else if(CComQIPtr<IFilterMapper2> pFM2 = m_pFM2) {
return pFM2->CreateCategory(clsidCategory, dwCategoryMerit, Description);
}
@@ -648,12 +608,9 @@ STDMETHODIMP CFilterMapper2::CreateCategory(REFCLSID clsidCategory, DWORD dwCate
STDMETHODIMP CFilterMapper2::UnregisterFilter(const CLSID* pclsidCategory, const OLECHAR* szInstance, REFCLSID Filter)
{
- if(!m_path.IsEmpty())
- {
+ if(!m_path.IsEmpty()) {
return S_OK;
- }
- else if(CComQIPtr<IFilterMapper2> pFM2 = m_pFM2)
- {
+ } else if(CComQIPtr<IFilterMapper2> pFM2 = m_pFM2) {
return m_fAllowUnreg
? pFM2->UnregisterFilter(pclsidCategory, szInstance, Filter)
: S_OK;
@@ -664,10 +621,8 @@ STDMETHODIMP CFilterMapper2::UnregisterFilter(const CLSID* pclsidCategory, const
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)
- {
+ if(!m_path.IsEmpty()) {
+ if(FilterOverride* f = DNew FilterOverride) {
f->fDisabled = false;
f->type = FilterOverride::EXTERNAL;
f->path = m_path;
@@ -676,31 +631,32 @@ STDMETHODIMP CFilterMapper2::RegisterFilter(REFCLSID clsidFilter, LPCWSTR Name,
f->iLoadType = FilterOverride::MERIT;
f->dwMerit = prf2->dwMerit;
- if(prf2->dwVersion == 1)
- {
- for(ULONG i = 0; i < prf2->cPins; i++)
- {
+ if(prf2->dwVersion == 1) {
+ for(ULONG i = 0; i < prf2->cPins; i++) {
const REGFILTERPINS& rgPin = prf2->rgPins[i];
- if(rgPin.bOutput) continue;
+ if(rgPin.bOutput) {
+ continue;
+ }
- for(UINT i = 0; i < rgPin.nMediaTypes; i++)
- {
- if(!rgPin.lpMediaType[i].clsMajorType || !rgPin.lpMediaType[i].clsMinorType) break;
+ 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++)
- {
+ } 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;
+ 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;
+ 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);
}
@@ -713,9 +669,7 @@ STDMETHODIMP CFilterMapper2::RegisterFilter(REFCLSID clsidFilter, LPCWSTR Name,
}
return S_OK;
- }
- else if(CComQIPtr<IFilterMapper2> pFM2 = m_pFM2)
- {
+ } else if(CComQIPtr<IFilterMapper2> pFM2 = m_pFM2) {
return pFM2->RegisterFilter(clsidFilter, Name, ppMoniker, pclsidCategory, szInstance, prf2);
}
@@ -726,8 +680,7 @@ STDMETHODIMP CFilterMapper2::EnumMatchingFilters(IEnumMoniker** ppEnum, DWORD dw
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)
- {
+ if(CComQIPtr<IFilterMapper2> pFM2 = m_pFM2) {
pFM2->EnumMatchingFilters(ppEnum, dwFlags, bExactMatch, dwMerit,
bInputNeeded, cInputTypes, pInputTypes, pMedIn, pPinCategoryIn, bRender,
bOutputNeeded, cOutputTypes, pOutputTypes, pMedOut, pPinCategoryOut);
diff --git a/src/apps/mplayerc/FakeFilterMapper2.h b/src/apps/mplayerc/FakeFilterMapper2.h
index d68d4b7c1..2d7b39610 100644
--- a/src/apps/mplayerc/FakeFilterMapper2.h
+++ b/src/apps/mplayerc/FakeFilterMapper2.h
@@ -42,12 +42,10 @@ public:
int iLoadType;
DWORD dwMerit;
- FilterOverride()
- {
+ FilterOverride() {
fTemporary = false;
}
- FilterOverride(FilterOverride* f)
- {
+ FilterOverride(FilterOverride* f) {
fDisabled = f->fDisabled;
fTemporary = f->fTemporary;
type = f->type;
@@ -120,8 +118,7 @@ public:
CFilterMapper2(bool fRefCounted, bool fAllowUnreg = false, LPUNKNOWN pUnkOuter = NULL);
virtual ~CFilterMapper2();
- void SetInner(IUnknown* pUnk)
- {
+ void SetInner(IUnknown* pUnk) {
m_pFM2 = pUnk;
}
diff --git a/src/apps/mplayerc/FavoriteAddDlg.cpp b/src/apps/mplayerc/FavoriteAddDlg.cpp
index 013c9d7d5..42fb6a8a7 100644
--- a/src/apps/mplayerc/FavoriteAddDlg.cpp
+++ b/src/apps/mplayerc/FavoriteAddDlg.cpp
@@ -56,16 +56,18 @@ BOOL CFavoriteAddDlg::OnInitDialog()
{
__super::OnInitDialog();
- if ( !m_shortname.IsEmpty() )
+ if ( !m_shortname.IsEmpty() ) {
m_namectrl.AddString( m_shortname );
+ }
- if ( !m_fullname.IsEmpty() )
+ if ( !m_fullname.IsEmpty() ) {
m_namectrl.AddString( m_fullname );
+ }
::CorrectComboListWidth( m_namectrl, GetFont() );
- m_bRememberPos = AfxGetApp()->GetProfileInt(IDS_R_FAVORITES, IDS_RS_FAV_REMEMBERPOS, TRUE);
- m_bRelativeDrive = AfxGetApp()->GetProfileInt(IDS_R_FAVORITES, IDS_RS_FAV_RELATIVEDRIVE, FALSE);
+ m_bRememberPos = AfxGetAppSettings().bFavRememberPos;
+ m_bRelativeDrive = AfxGetAppSettings().bFavRelativeDrive;
UpdateData(FALSE); // Update UI
@@ -95,8 +97,8 @@ void CFavoriteAddDlg::OnOK()
UpdateData(); // Retrieve UI values
// Remember settings
- AfxGetApp()->WriteProfileInt(IDS_R_FAVORITES, IDS_RS_FAV_REMEMBERPOS, m_bRememberPos);
- AfxGetApp()->WriteProfileInt(IDS_R_FAVORITES, IDS_RS_FAV_RELATIVEDRIVE, m_bRelativeDrive);
+ AfxGetAppSettings().bFavRememberPos = m_bRememberPos;
+ AfxGetAppSettings().bFavRelativeDrive = m_bRelativeDrive;
CCmdUIDialog::OnOK();
}
diff --git a/src/apps/mplayerc/FavoriteAddDlg.h b/src/apps/mplayerc/FavoriteAddDlg.h
index 4aa2ea809..619d64ff1 100644
--- a/src/apps/mplayerc/FavoriteAddDlg.h
+++ b/src/apps/mplayerc/FavoriteAddDlg.h
@@ -36,7 +36,7 @@ public:
CFavoriteAddDlg(CString shortname, CString fullname, CWnd* pParent = NULL); // standard constructor
virtual ~CFavoriteAddDlg();
-// Dialog Data
+ // Dialog Data
enum { IDD = IDD_FAVADD };
CComboBox m_namectrl;
diff --git a/src/apps/mplayerc/FavoriteOrganizeDlg.cpp b/src/apps/mplayerc/FavoriteOrganizeDlg.cpp
index da8f07741..ca83c1315 100644
--- a/src/apps/mplayerc/FavoriteOrganizeDlg.cpp
+++ b/src/apps/mplayerc/FavoriteOrganizeDlg.cpp
@@ -42,12 +42,10 @@ void CFavoriteOrganizeDlg::SetupList(bool fSave)
{
int i = m_tab.GetCurSel();
- if(fSave)
- {
+ if(fSave) {
CAtlList<CString> sl;
- for(int j = 0; j < m_list.GetItemCount(); j++)
- {
+ 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));
@@ -56,18 +54,17 @@ void CFavoriteOrganizeDlg::SetupList(bool fSave)
m_sl[i].RemoveAll();
m_sl[i].AddTailList(&sl);
- }
- else
- {
+ } else {
m_list.DeleteAllItems();
POSITION pos = m_sl[i].GetHeadPosition(), tmp;
- while(pos)
- {
+ while(pos) {
tmp = pos;
CString s = m_sl[i].GetNext(pos);
int i = s.Find(';');
- if(i >= 0) s = s.Left(i);
+ if(i >= 0) {
+ s = s.Left(i);
+ }
m_list.SetItemData(m_list.InsertItem(m_list.GetItemCount(), s), (DWORD_PTR)tmp);
}
@@ -113,7 +110,7 @@ BOOL CFavoriteOrganizeDlg::OnInitDialog()
m_tab.InsertItem(0, ResStr(IDS_FAVFILES));
m_tab.InsertItem(1, ResStr(IDS_FAVDVDS));
-// m_tab.InsertItem(2, ResStr(IDS_FAVDEVICES));
+ // m_tab.InsertItem(2, ResStr(IDS_FAVDEVICES));
m_tab.SetCurSel(0);
m_list.InsertColumn(0, _T(""));
@@ -148,20 +145,19 @@ void CFavoriteOrganizeDlg::OnTcnSelchangeTab1(NMHDR* pNMHDR, LRESULT* pResult)
void CFavoriteOrganizeDlg::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
{
- if(nIDCtl != IDC_LIST2) return;
+ if(nIDCtl != IDC_LIST2) {
+ return;
+ }
int nItem = lpDrawItemStruct->itemID;
CRect rcItem = lpDrawItemStruct->rcItem;
CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
- if(!!m_list.GetItemState(nItem, LVIS_SELECTED))
- {
+ if(!!m_list.GetItemState(nItem, LVIS_SELECTED)) {
FillRect(pDC->m_hDC, rcItem, CBrush(0xf1dacc));
FrameRect(pDC->m_hDC, rcItem, CBrush(0xc56a31));
- }
- else
- {
+ } else {
CBrush b;
b.CreateSysColorBrush(COLOR_WINDOW);
FillRect(pDC->m_hDC, rcItem, b);
@@ -175,8 +171,7 @@ void CFavoriteOrganizeDlg::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStr
void CFavoriteOrganizeDlg::OnBnClickedButton1()
{
- if(POSITION pos = m_list.GetFirstSelectedItemPosition())
- {
+ if(POSITION pos = m_list.GetFirstSelectedItemPosition()) {
m_list.SetFocus();
m_list.EditLabel(m_list.GetNextSelectedItem(pos));
}
@@ -185,17 +180,19 @@ void CFavoriteOrganizeDlg::OnBnClickedButton1()
void CFavoriteOrganizeDlg::OnLvnEndlabeleditList2(NMHDR* pNMHDR, LRESULT* pResult)
{
NMLVDISPINFO* pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);
- if(pDispInfo->item.iItem >= 0 && pDispInfo->item.pszText)
+ if(pDispInfo->item.iItem >= 0 && pDispInfo->item.pszText) {
m_list.SetItemText(pDispInfo->item.iItem, 0, pDispInfo->item.pszText);
+ }
*pResult = 0;
}
void CFavoriteOrganizeDlg::OnBnClickedButton2()
{
- if(POSITION pos = m_list.GetFirstSelectedItemPosition())
- {
+ if(POSITION pos = m_list.GetFirstSelectedItemPosition()) {
int nItem = m_list.GetNextSelectedItem(pos);
- if(nItem < 0 || nItem >= m_list.GetItemCount()) return;
+ if(nItem < 0 || nItem >= m_list.GetItemCount()) {
+ return;
+ }
m_list.DeleteItem(nItem);
@@ -208,10 +205,11 @@ void CFavoriteOrganizeDlg::OnBnClickedButton2()
void CFavoriteOrganizeDlg::OnBnClickedButton3()
{
- if(POSITION pos = m_list.GetFirstSelectedItemPosition())
- {
+ if(POSITION pos = m_list.GetFirstSelectedItemPosition()) {
int nItem = m_list.GetNextSelectedItem(pos);
- if(nItem <= 0) return;
+ if(nItem <= 0) {
+ return;
+ }
DWORD_PTR data = m_list.GetItemData(nItem);
CString str = m_list.GetItemText(nItem, 0);
@@ -229,10 +227,11 @@ void CFavoriteOrganizeDlg::OnBnClickedButton3()
void CFavoriteOrganizeDlg::OnBnClickedButton7()
{
- if(POSITION pos = m_list.GetFirstSelectedItemPosition())
- {
+ if(POSITION pos = m_list.GetFirstSelectedItemPosition()) {
int nItem = m_list.GetNextSelectedItem(pos);
- if(nItem < 0 || nItem >= m_list.GetItemCount()-1) return;
+ if(nItem < 0 || nItem >= m_list.GetItemCount()-1) {
+ return;
+ }
DWORD_PTR data = m_list.GetItemData(nItem);
CString str = m_list.GetItemText(nItem, 0);
@@ -270,14 +269,16 @@ void CFavoriteOrganizeDlg::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimi
{
__super::OnActivate(nState, pWndOther, bMinimized);
- if(nState == WA_ACTIVE)
+ 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);
- if(IsWindow(m_list))
+ if(IsWindow(m_list)) {
m_list.SetColumnWidth(0, LVSCW_AUTOSIZE_USEHEADER);
+ }
}
diff --git a/src/apps/mplayerc/FavoriteOrganizeDlg.h b/src/apps/mplayerc/FavoriteOrganizeDlg.h
index e056cdc5c..a4898deac 100644
--- a/src/apps/mplayerc/FavoriteOrganizeDlg.h
+++ b/src/apps/mplayerc/FavoriteOrganizeDlg.h
@@ -32,7 +32,7 @@
class CFavoriteOrganizeDlg : public CResizableDialog
{
-// DECLARE_DYNAMIC(CFavoriteOrganizeDlg)
+ // DECLARE_DYNAMIC(CFavoriteOrganizeDlg)
private:
CAtlList<CString> m_sl[3];
@@ -42,7 +42,7 @@ public:
CFavoriteOrganizeDlg(CWnd* pParent = NULL); // standard constructor
virtual ~CFavoriteOrganizeDlg();
-// Dialog Data
+ // Dialog Data
enum { IDD = IDD_FAVORGANIZE };
CTabCtrl m_tab;
diff --git a/src/apps/mplayerc/FileDropTarget.cpp b/src/apps/mplayerc/FileDropTarget.cpp
index a1e9e8888..0dacf127f 100644
--- a/src/apps/mplayerc/FileDropTarget.cpp
+++ b/src/apps/mplayerc/FileDropTarget.cpp
@@ -61,7 +61,9 @@ DROPEFFECT CFileDropTarget::OnDropEx(CWnd* pWnd, COleDataObject* pDataObject, DR
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)
diff --git a/src/apps/mplayerc/FileDropTarget.h b/src/apps/mplayerc/FileDropTarget.h
index 8021d4915..d94f88304 100644
--- a/src/apps/mplayerc/FileDropTarget.h
+++ b/src/apps/mplayerc/FileDropTarget.h
@@ -31,25 +31,20 @@ class CDropTarget
public:
CDropTarget() {}
- virtual DROPEFFECT OnDragEnter(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point)
- {
+ virtual DROPEFFECT OnDragEnter(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point) {
return DROPEFFECT_NONE;
}
- virtual DROPEFFECT OnDragOver(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point)
- {
+ virtual DROPEFFECT OnDragOver(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point) {
return DROPEFFECT_NONE;
}
- virtual BOOL OnDrop(COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point)
- {
+ virtual BOOL OnDrop(COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoint point) {
return FALSE;
}
- virtual DROPEFFECT OnDropEx(COleDataObject* pDataObject, DROPEFFECT dropDefault, DROPEFFECT dropList, CPoint point)
- {
+ virtual DROPEFFECT OnDropEx(COleDataObject* pDataObject, DROPEFFECT dropDefault, DROPEFFECT dropList, CPoint point) {
return (DROPEFFECT)-1;
}
virtual void OnDragLeave() {}
- virtual DROPEFFECT OnDragScroll(DWORD dwKeyState, CPoint point)
- {
+ virtual DROPEFFECT OnDragScroll(DWORD dwKeyState, CPoint point) {
return DROPEFFECT_NONE;
}
};
@@ -58,7 +53,7 @@ public:
class CFileDropTarget : public COleDropTarget
{
-// DECLARE_DYNAMIC(CFileDropTarget)
+ // DECLARE_DYNAMIC(CFileDropTarget)
private:
CDropTarget* m_pDropTarget;
diff --git a/src/apps/mplayerc/FilterEnum.h b/src/apps/mplayerc/FilterEnum.h
index 2ebf96dca..28da641f1 100644
--- a/src/apps/mplayerc/FilterEnum.h
+++ b/src/apps/mplayerc/FilterEnum.h
@@ -24,16 +24,14 @@
#include "internal_filter_config.h"
-enum
-{
+enum {
SOURCE_FILTER,
DECODER,
DXVA_DECODER,
FFMPEG_DECODER
};
-enum SOURCE_FILTER
-{
+enum SOURCE_FILTER {
#if INTERNAL_SOURCEFILTER_CDDA
SRC_CDDA,
#endif
@@ -98,8 +96,7 @@ enum SOURCE_FILTER
SRC_LAST
};
-enum DECODER
-{
+enum DECODER {
#if INTERNAL_DECODER_MPEG1
TRA_MPEG1,
#endif
@@ -149,8 +146,7 @@ enum DECODER
TRA_LAST
};
-enum DXVA_DECODER
-{
+enum DXVA_DECODER {
#if INTERNAL_DECODER_H264_DXVA
TRA_DXVA_H264,
#endif
@@ -161,7 +157,7 @@ enum DXVA_DECODER
TRA_DXVA_MPEG2,
#endif
TRA_DXVA_LAST,
-// dummy values (needed in FGManager.cpp)
+ // dummy values (needed in FGManager.cpp)
#if !INTERNAL_DECODER_H264_DXVA & INTERNAL_DECODER_H264
TRA_DXVA_H264,
#endif
@@ -170,8 +166,7 @@ enum DXVA_DECODER
#endif
};
-enum FFMPEG_DECODER
-{
+enum FFMPEG_DECODER {
#if INTERNAL_DECODER_H264
FFM_H264,
#endif
@@ -212,7 +207,7 @@ enum FFMPEG_DECODER
FFM_AMVV,
#endif
FFM_LAST,
-// dummy values (needed in FGManager.cpp)
+ // dummy values (needed in FGManager.cpp)
#if !INTERNAL_DECODER_H264 & INTERNAL_DECODER_H264_DXVA
FFM_H264,
#endif
diff --git a/src/apps/mplayerc/FloatEdit.cpp b/src/apps/mplayerc/FloatEdit.cpp
index 4f4ca6326..b3dbedddc 100644
--- a/src/apps/mplayerc/FloatEdit.cpp
+++ b/src/apps/mplayerc/FloatEdit.cpp
@@ -58,20 +58,23 @@ END_MESSAGE_MAP()
void CFloatEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
- if(!(nChar >= '0' && nChar <= '9' || nChar == '.' || nChar == '\b'))
+ if(!(nChar >= '0' && nChar <= '9' || nChar == '.' || nChar == '\b')) {
return;
+ }
CString str;
GetWindowText(str);
- if(nChar == '.' && (str.Find('.') >= 0 || str.IsEmpty()))
+ if(nChar == '.' && (str.Find('.') >= 0 || str.IsEmpty())) {
return;
+ }
int nStartChar, nEndChar;
GetSel(nStartChar, nEndChar);
- if(nChar == '\b' && nStartChar <= 0)
+ if(nChar == '\b' && nStartChar <= 0) {
return;
+ }
CEdit::OnChar(nChar, nRepCnt, nFlags);
}
@@ -86,23 +89,27 @@ END_MESSAGE_MAP()
void CIntEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
- if(!(nChar >= '0' && nChar <= '9' || nChar == '-' || nChar == '\b'))
+ if(!(nChar >= '0' && nChar <= '9' || nChar == '-' || nChar == '\b')) {
return;
+ }
CString str;
GetWindowText(str);
- if(nChar == '-' && !str.IsEmpty() && str[0] == '-')
+ if(nChar == '-' && !str.IsEmpty() && str[0] == '-') {
return;
+ }
int nStartChar, nEndChar;
GetSel(nStartChar, nEndChar);
- if(nChar == '\b' && nStartChar <= 0)
+ if(nChar == '\b' && nStartChar <= 0) {
return;
+ }
- if(nChar == '-' && (nStartChar != 0 || nEndChar != 0))
+ if(nChar == '-' && (nStartChar != 0 || nEndChar != 0)) {
return;
+ }
CEdit::OnChar(nChar, nRepCnt, nFlags);
}
@@ -141,8 +148,9 @@ 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'))
+ || nChar >= '0' && nChar <= '9' || nChar == '\b')) {
return;
+ }
CString str;
GetWindowText(str);
@@ -150,11 +158,13 @@ void CHexEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
int nStartChar, nEndChar;
GetSel(nStartChar, nEndChar);
- if(nChar == '\b' && nStartChar <= 0)
+ if(nChar == '\b' && nStartChar <= 0) {
return;
+ }
- if(nChar != '\b' && nEndChar - nStartChar == 0 && str.GetLength() >= 8)
+ if(nChar != '\b' && nEndChar - nStartChar == 0 && str.GetLength() >= 8) {
return;
+ }
CEdit::OnChar(nChar, nRepCnt, nFlags);
}
diff --git a/src/apps/mplayerc/FullscreenWnd.cpp b/src/apps/mplayerc/FullscreenWnd.cpp
index 2405458d5..7127a4924 100644
--- a/src/apps/mplayerc/FullscreenWnd.cpp
+++ b/src/apps/mplayerc/FullscreenWnd.cpp
@@ -50,43 +50,41 @@ END_MESSAGE_MAP()
LRESULT CFullscreenWnd::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
- switch (message)
- {
- case WM_COMMAND :
- m_pMainFrame->PostMessage(message, wParam, lParam);
- break;
+ 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->PostMessage(pMsg->message, pMsg->wParam, pMsg->lParam);
- break;
+ 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->PostMessage(pMsg->message, pMsg->wParam, pMsg->lParam);
+ break;
}
return CWnd::PreTranslateMessage(pMsg);
@@ -95,8 +93,9 @@ BOOL CFullscreenWnd::PreTranslateMessage(MSG* pMsg)
BOOL CFullscreenWnd::PreCreateWindow(CREATESTRUCT& cs)
{
- if(!CWnd::PreCreateWindow(cs))
+ 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);
@@ -114,18 +113,18 @@ BOOL CFullscreenWnd::OnEraseBkgnd(CDC* pDC)
BOOL CFullscreenWnd::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
- if (m_bCursorVisible)
+ if (m_bCursorVisible) {
::SetCursor(m_hCursor);
- else
+ } else {
::SetCursor(NULL);
+ }
return FALSE;
}
void CFullscreenWnd::ShowCursor(bool bVisible)
{
- if (m_bCursorVisible != bVisible)
- {
+ if (m_bCursorVisible != bVisible) {
m_bCursorVisible = bVisible;
PostMessage (WM_SETCURSOR,0,0);
}
diff --git a/src/apps/mplayerc/GoToDlg.cpp b/src/apps/mplayerc/GoToDlg.cpp
index e403803e7..169f2cc08 100644
--- a/src/apps/mplayerc/GoToDlg.cpp
+++ b/src/apps/mplayerc/GoToDlg.cpp
@@ -38,10 +38,11 @@ CGoToDlg::CGoToDlg(int time, float fps, CWnd* pParent /*=NULL*/)
, m_time(time)
, m_fps(fps)
{
- if(m_fps == 0)
- {
+ if(m_fps == 0) {
CString str = AfxGetApp()->GetProfileString(IDS_R_SETTINGS, _T("fps"), _T("0"));
- if(_stscanf_s(str, _T("%f"), &m_fps) != 1) m_fps = 0;
+ if(_stscanf_s(str, _T("%f"), &m_fps) != 1) {
+ m_fps = 0;
+ }
}
}
@@ -62,36 +63,33 @@ BOOL CGoToDlg::OnInitDialog()
{
CDialog::OnInitDialog();
- if(m_time >= 0)
- {
+ if(m_time >= 0) {
m_timestr.Format(_T("%02d:%02d:%02d.%03d"),
(m_time/(1000*60*60))%60, (m_time/(1000*60))%60, (m_time/1000)%60, m_time%1000);
- if(m_fps > 0)
- {
+ if(m_fps > 0) {
m_framestr.Format(_T("%d, %.3f"), (int)(m_fps*m_time/1000), 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;
+ 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 TRUE;
+ return 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
// EXCEPTION: OCX Property Pages should return FALSE
}
@@ -114,20 +112,17 @@ void CGoToDlg::OnBnClickedOk1()
CAtlRegExp<> re;
REParseError status = re.Parse(_T("{\\z}"), FALSE);
- if(REPARSE_ERROR_OK == status)
- {
+ if(REPARSE_ERROR_OK == status) {
m_timestr += 'A'; // HACK: Without this the while loop below would keep going on X64 on release builds...
CAtlREMatchContext<> mc;
const CAtlREMatchContext<>::RECHAR* s = m_timestr.GetBuffer();
const CAtlREMatchContext<>::RECHAR* e = NULL;
- while(s && re.Match(s, &mc, &e))
- {
+ while(s && re.Match(s, &mc, &e)) {
const CAtlREMatchContext<>::RECHAR* szStart = 0;
const CAtlREMatchContext<>::RECHAR* szEnd = 0;
mc.GetMatch(0, &szStart, &szEnd);
- if(hh != 0 || hh > 59 || mm > 59 || ss > 59)
- {
+ if(hh != 0 || hh > 59 || mm > 59 || ss > 59) {
AfxMessageBox(_T("Error parsing entered time!"));
return;
}
@@ -159,13 +154,11 @@ void CGoToDlg::OnBnClickedOk2()
CAtlRegExp<> re;
REParseError status = re.Parse(_T("{\\z}[^0-9\\.]+{[0-9\\.]+}"), FALSE);
- if(REPARSE_ERROR_OK == status)
- {
+ if(REPARSE_ERROR_OK == status) {
CAtlREMatchContext<> mc;
const CAtlREMatchContext<>::RECHAR* s = m_framestr.GetBuffer();
const CAtlREMatchContext<>::RECHAR* e = NULL;
- if(re.Match(s, &mc, &e))
- {
+ if(re.Match(s, &mc, &e)) {
const CAtlREMatchContext<>::RECHAR* szStart = 0;
const CAtlREMatchContext<>::RECHAR* szEnd = 0;
@@ -173,17 +166,17 @@ void CGoToDlg::OnBnClickedOk2()
frame = _tcstol(szStart, (TCHAR**)&szStart, 10);
mc.GetMatch(1, &szStart, &szEnd);
- if(_stscanf_s(szStart, _T("%f"), &fps) != 1) fps = 0;
- else AfxGetApp()->WriteProfileString(IDS_R_SETTINGS, _T("fps"), szStart);
- }
- else
- {
+ if(_stscanf_s(szStart, _T("%f"), &fps) != 1) {
+ fps = 0;
+ } else {
+ AfxGetApp()->WriteProfileString(IDS_R_SETTINGS, _T("fps"), szStart);
+ }
+ } else {
AfxMessageBox(_T("Error parsing entered text!"));
return;
}
- if(fps == 0)
- {
+ if(fps == 0) {
AfxMessageBox(_T("Error parsing entered frame rate!"));
return;
}
@@ -198,10 +191,12 @@ void CGoToDlg::OnBnClickedOk2()
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;
}
diff --git a/src/apps/mplayerc/GoToDlg.h b/src/apps/mplayerc/GoToDlg.h
index 1b98ca34d..d63b657e1 100644
--- a/src/apps/mplayerc/GoToDlg.h
+++ b/src/apps/mplayerc/GoToDlg.h
@@ -44,7 +44,7 @@ public:
int m_time;
float m_fps;
-// Dialog Data
+ // Dialog Data
enum { IDD = IDD_GOTO_DLG };
protected:
diff --git a/src/apps/mplayerc/IGraphBuilder2.h b/src/apps/mplayerc/IGraphBuilder2.h
index 57c6ae3d7..20633c66e 100644
--- a/src/apps/mplayerc/IGraphBuilder2.h
+++ b/src/apps/mplayerc/IGraphBuilder2.h
@@ -23,8 +23,7 @@
#pragma once
-typedef struct
-{
+typedef struct {
CString cPresent;
CString SummaryDesc;
CString StartTime;
@@ -37,8 +36,7 @@ typedef struct
interface __declspec(uuid("165BE9D6-0929-4363-9BA3-580D735AA0F6"))
IGraphBuilder2 :
-public IFilterGraph2
-{
+public IFilterGraph2 {
STDMETHOD(IsPinDirection) (IPin* pPin, PIN_DIRECTION dir) = 0;
STDMETHOD(IsPinConnected) (IPin* pPin) = 0;
STDMETHOD(ConnectFilter) (IBaseFilter* pBF, IPin* pPinIn) = 0;
@@ -53,8 +51,7 @@ public IFilterGraph2
// private use only
interface __declspec(uuid("43CDA93D-6A4E-4A07-BD3E-49D161073EE7"))
IGraphBuilderDeadEnd :
-public IUnknown
-{
+public IUnknown {
STDMETHOD_(size_t, GetCount)() = 0;
STDMETHOD(GetDeadEnd) (int iIndex, CAtlList<CStringW>& path, CAtlList<CMediaType>& mts) = 0;
};
@@ -63,8 +60,7 @@ public IUnknown
// private use only
interface __declspec(uuid("43CDA93D-6A4E-4A07-BD3E-49D161073EE7"))
IBDATuner :
-public IUnknown
-{
+public IUnknown {
STDMETHOD(SetChannel) (int nChannelPrefNumber) = 0;
STDMETHOD(SetAudio) (int nAudioIndex) = 0;
STDMETHOD(SetFrequency) (ULONG ulFrequency) = 0;
diff --git a/src/apps/mplayerc/ISDb.cpp b/src/apps/mplayerc/ISDb.cpp
index 93083cfb8..f05aa1d8d 100644
--- a/src/apps/mplayerc/ISDb.cpp
+++ b/src/apps/mplayerc/ISDb.cpp
@@ -30,8 +30,9 @@ bool hash(LPCTSTR fn, filehash& fh)
{
CFile f;
CFileException fe;
- if(!f.Open(fn, CFile::modeRead|CFile::osSequentialScan|CFile::shareDenyNone, &fe))
+ if(!f.Open(fn, CFile::modeRead|CFile::osSequentialScan|CFile::shareDenyNone, &fe)) {
return false;
+ }
CPath p(fn);
p.StripPath();
@@ -40,9 +41,13 @@ bool hash(LPCTSTR fn, filehash& fh)
fh.size = f.GetLength();
fh.hash = fh.size;
- for(UINT64 tmp = 0, i = 0; i < 65536/sizeof(tmp) && f.Read(&tmp, sizeof(tmp)); fh.hash += tmp, i++);
+ for(UINT64 tmp = 0, i = 0; i < 65536/sizeof(tmp) && f.Read(&tmp, sizeof(tmp)); fh.hash += 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.hash += tmp, i++);
+ for(UINT64 tmp = 0, i = 0; i < 65536/sizeof(tmp) && f.Read(&tmp, sizeof(tmp)); fh.hash += tmp, i++) {
+ ;
+ }
return true;
}
@@ -52,15 +57,16 @@ void hash(CPlaylist& pl, CList<filehash>& fhs)
fhs.RemoveAll();
POSITION pos = pl.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CString fn = pl.GetNext(pos).m_fns.GetHead();
- if(AfxGetAppSettings().m_Formats.FindExt(CPath(fn).GetExtension().MakeLower(), true))
+ if(AfxGetAppSettings().m_Formats.FindExt(CPath(fn).GetExtension().MakeLower(), true)) {
continue;
+ }
filehash fh;
- if(!hash(fn, fh))
+ if(!hash(fn, fh)) {
continue;
+ }
fhs.AddTail(fh);
}
@@ -74,8 +80,7 @@ CStringA makeargs(CPlaylist& pl)
CAtlList<CStringA> args;
POSITION pos = fhs.GetHeadPosition();
- for(int i = 0; pos; i++)
- {
+ for(int i = 0; pos; i++) {
filehash& fh = fhs.GetNext(pos);
CStringA str;
@@ -94,17 +99,16 @@ bool OpenUrl(CInternetSession& is, CString url, CStringA& str)
{
str.Empty();
- try
- {
+ 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));
+ 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)
- {
+ } catch(CInternetException* ie) {
ie->Delete();
return false;
}
diff --git a/src/apps/mplayerc/ISDb.h b/src/apps/mplayerc/ISDb.h
index fdc6dea56..3173380bc 100644
--- a/src/apps/mplayerc/ISDb.h
+++ b/src/apps/mplayerc/ISDb.h
@@ -30,34 +30,27 @@
#define ISDb_PROTOCOL_VERSION 1
-struct isdb_subtitle
-{
+struct isdb_subtitle {
int id, discs, disc_no;
CStringA name, format, language, iso639_2, nick, email;
- struct isdb_subtitle()
- {
+ struct isdb_subtitle() {
reset();
}
- void reset()
- {
+ void reset() {
id = discs = disc_no = 0;
format = language = nick = email = "";
}
};
-struct isdb_movie
-{
+struct isdb_movie {
CAtlList<CStringA> titles;
CAtlList<isdb_subtitle> subs;
- void reset()
- {
+ void reset() {
titles.RemoveAll();
subs.RemoveAll();
}
- isdb_movie& operator = (const struct isdb_movie& m)
- {
- if(this != &m)
- {
+ isdb_movie& operator = (const struct isdb_movie& m) {
+ if(this != &m) {
titles.RemoveAll();
titles.AddTailList(&m.titles);
subs.RemoveAll();
@@ -67,8 +60,7 @@ struct isdb_movie
}
};
-struct filehash
-{
+struct filehash {
CString name;
UINT64 size, hash;
};
diff --git a/src/apps/mplayerc/Ifo.cpp b/src/apps/mplayerc/Ifo.cpp
index 8072f033b..e0866ad18 100644
--- a/src/apps/mplayerc/Ifo.cpp
+++ b/src/apps/mplayerc/Ifo.cpp
@@ -118,20 +118,17 @@ void CIfo::RemovePgciUOPs (uint8_t *ptr)
ptr += IFO_HDR_LEN;
num = be2me_16(hdr->num);
- for (i=1; i<=num; i++)
- {
+ for (i=1; i<=num; i++) {
lu_sub_t *lu_sub = (lu_sub_t *) ptr;
UNUSED_ALWAYS(lu_sub);
ptr += LU_SUB_LEN;
}
- for (i=0; i<be2me_16(hdr->num); i++)
- {
+ for (i=0; i<be2me_16(hdr->num); i++) {
uint8_t *ptr;
- if (GetMiscPGCI (hdr, i, &ptr) >= 0)
- {
+ if (GetMiscPGCI (hdr, i, &ptr) >= 0) {
pgc_t* pgc = (pgc_t*) ptr;
pgc->prohibited_ops = 0;
}
@@ -140,10 +137,11 @@ void CIfo::RemovePgciUOPs (uint8_t *ptr)
CIfo::pgc_t* CIfo::GetFirstPGC()
{
- if (m_pBuffer)
+ if (m_pBuffer) {
return (pgc_t*) (m_pBuffer + 0x0400);
- else
+ } else {
return NULL;
+ }
}
CIfo::pgc_t* CIfo::GetPGCI(const int title, const ifo_hdr_t* hdr)
@@ -159,8 +157,7 @@ CIfo::pgc_t* CIfo::GetPGCI(const int title, const ifo_hdr_t* hdr)
ptr = (uint8_t *) hdr + be2me_32 (pgci_sub->start);
/* jdw */
- if ( ptr >= ( (uint8_t *) hdr + be2me_32 ( hdr->len )))
- {
+ if ( ptr >= ( (uint8_t *) hdr + be2me_32 ( hdr->len ))) {
return NULL ;
}
/* /jdw */
@@ -171,8 +168,9 @@ CIfo::pgc_t* CIfo::GetPGCI(const int title, const ifo_hdr_t* hdr)
bool CIfo::IsVTS()
{
- if (m_dwSize<12 || (strncmp ((char*)m_pBuffer, "DVDVIDEO-VTS", 12)!=0))
+ if (m_dwSize<12 || (strncmp ((char*)m_pBuffer, "DVDVIDEO-VTS", 12)!=0)) {
return false;
+ }
return true;
}
@@ -180,8 +178,9 @@ bool CIfo::IsVTS()
bool CIfo::IsVMG()
{
- if (m_dwSize<12 || (strncmp ((char*)m_pBuffer, "DVDVIDEO-VMG", 12)!=0))
+ if (m_dwSize<12 || (strncmp ((char*)m_pBuffer, "DVDVIDEO-VMG", 12)!=0)) {
return false;
+ }
return true;
}
@@ -194,20 +193,18 @@ bool CIfo::OpenFile (LPCTSTR strFile)
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)
- {
+ if (hFile != INVALID_HANDLE_VALUE) {
DWORD dwSize = GetFileSize (hFile, NULL);
m_pBuffer = DNew BYTE [dwSize];
ReadFile (hFile, m_pBuffer, dwSize, &m_dwSize, NULL);
CloseHandle (hFile);
- if (IsVTS() && (OFF_VTSM_PGCI_UT(m_pBuffer)!=0))
- {
+ 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))
+ } 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);
}
@@ -219,25 +216,23 @@ bool CIfo::RemoveUOPs()
{
pgc_t* pgc;
- if (m_pPGCI)
- {
+ if (m_pPGCI) {
pgc = GetFirstPGC();
pgc->prohibited_ops = 0;
- for (int i=0; i<be2me_16(m_pPGCI->num); i++)
- {
+ for (int i=0; i<be2me_16(m_pPGCI->num); i++) {
pgc = GetPGCI(i, m_pPGCI);
- if (pgc)
+ if (pgc) {
RemovePgciUOPs ((uint8_t*)pgc);
+ }
}
}
- if (m_pPGCIT)
- {
- for (int i=0; i<be2me_16(m_pPGCIT->num); i++)
- {
+ if (m_pPGCIT) {
+ for (int i=0; i<be2me_16(m_pPGCIT->num); i++) {
pgc = GetPGCI(i, m_pPGCIT);
- if (pgc)
+ if (pgc) {
pgc->prohibited_ops = 0;
+ }
}
}
return true;
@@ -248,14 +243,12 @@ bool CIfo::SaveFile (LPCTSTR strFile)
bool bRet = false;
HANDLE m_hFile;
- if (m_pBuffer)
- {
+ 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)
- {
+ if (m_hFile != INVALID_HANDLE_VALUE) {
DWORD dwSize;
WriteFile (m_hFile, m_pBuffer, m_dwSize, &dwSize, NULL);
CloseHandle(m_hFile);
diff --git a/src/apps/mplayerc/Ifo.h b/src/apps/mplayerc/Ifo.h
index 74787d671..bbd21c442 100644
--- a/src/apps/mplayerc/Ifo.h
+++ b/src/apps/mplayerc/Ifo.h
@@ -44,15 +44,13 @@ public:
private :
- typedef struct
- {
+ 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
- {
+ typedef struct {
uint8_t hour;
uint8_t minute;
uint8_t second;
@@ -62,8 +60,7 @@ private :
typedef uint8_t command_data_t[8];
#define COMMAND_DATA_SIZE 8
- typedef struct // PGC Command Table
- {
+ typedef struct { // PGC Command Table
uint16_t nr_of_pre;
uint16_t nr_of_post;
uint16_t nr_of_cell;
@@ -76,8 +73,7 @@ private :
typedef uint8_t pgc_program_map_t;
- typedef struct // Cell Playback Information
- {
+ 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;
@@ -90,8 +86,7 @@ private :
uint32_t vobu_last_end;
} ifo_pgci_caddr_t;
- typedef struct // Cell Position Information
- {
+ 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
@@ -100,8 +95,7 @@ private :
#ifndef CLUT_T
#define CLUT_T
- typedef struct // CLUT == Color LookUp Table
- {
+ typedef struct { // CLUT == Color LookUp Table
uint8_t foo : 8; // UNKNOWN: 0x00?
uint8_t y : 8;
uint8_t cr : 8;
@@ -109,8 +103,7 @@ private :
} clut_t;
#endif
- typedef struct // Audio Status
- {
+ typedef struct { // Audio Status
#if BYTE_ORDER == BIG_ENDIAN
uint8_t available : 1;
uint8_t link : 7;
@@ -122,8 +115,7 @@ private :
} 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;
@@ -137,8 +129,7 @@ private :
} subp_status_t;
- typedef struct // Program Chain Information
- {
+ typedef struct { // Program Chain Information
uint16_t zero_1;
uint8_t nr_of_programs;
uint8_t nr_of_cells;
@@ -163,15 +154,13 @@ private :
} pgc_t;
#define PGC_SIZE 236
- typedef struct
- {
+ 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,
diff --git a/src/apps/mplayerc/LcdSupport.cpp b/src/apps/mplayerc/LcdSupport.cpp
index 18b8fb3f8..b67d1cb83 100644
--- a/src/apps/mplayerc/LcdSupport.cpp
+++ b/src/apps/mplayerc/LcdSupport.cpp
@@ -43,11 +43,9 @@ void LCD_UpdateThread(void * Control)
struct tm thetime;
_tsetlocale(LC_ALL, _T("")); // set current system locale
- while (ctrl->Thread_Loop)
- {
+ while (ctrl->Thread_Loop) {
EnterCriticalSection(&ctrl->cs);
- if (_time64(&ltime) != otime) // Retrieve the time
- {
+ if (_time64(&ltime) != otime) { // Retrieve the time
otime = ltime;
_localtime64_s(&thetime, &ltime);
@@ -55,11 +53,13 @@ void LCD_UpdateThread(void * Control)
// using %#x is the long date representation,
// appropriate to the current locale
if (wcsftime(str, sizeof(str)/sizeof(wchar_t), _T("%#x"), (const struct tm *)&thetime) &&
- (ltime > ctrl->nThread_tTimeout || ltime < otime)) // message displayed, no update until timeout
+ (ltime > ctrl->nThread_tTimeout || ltime < otime)) { // message displayed, no update until timeout
ctrl->m_Manager.m_Text[0].SetText(str);
+ }
- if (wcsftime(str, sizeof(str)/sizeof(wchar_t), _T("%X"), (const struct tm *)&thetime))
+ if (wcsftime(str, sizeof(str)/sizeof(wchar_t), _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
@@ -157,31 +157,29 @@ HRESULT CLCDMyManager::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;
}
}
@@ -237,8 +235,7 @@ CMPC_Lcd::CMPC_Lcd(void)
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)
- {
+ m_Manager.Initialize() != ERROR_SUCCESS) {
//_tperror(_T("Initialize"));
return;
}
@@ -252,8 +249,7 @@ CMPC_Lcd::CMPC_Lcd(void)
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())
- {
+ if (m_Output.IsOpened()) {
Thread_Loop = true;
SetPlayState(PS_STOP);
hLCD_UpdateThread = (HANDLE) _beginthread(LCD_UpdateThread, 512 /* stack */, (void*) this /* arg */);
@@ -263,8 +259,7 @@ CMPC_Lcd::CMPC_Lcd(void)
/* detach from lcd */
CMPC_Lcd::~CMPC_Lcd(void)
{
- if ( m_Output.IsOpened() )
- {
+ if ( m_Output.IsOpened() ) {
Thread_Loop = false;
WaitForSingleObject( hLCD_UpdateThread, LCD_UPD_TIMER * 2 /* timeout */ );
hLCD_UpdateThread = NULL;
@@ -319,13 +314,15 @@ void CMPC_Lcd::SetMediaPos(__int64 nPos)
/* update status message (displayed for nTimeOut milliseconds) */
void CMPC_Lcd::SetStatusMessage(const _TCHAR * text, int nTimeOut)
{
- if (!m_Output.IsOpened())
+ if (!m_Output.IsOpened()) {
return;
+ }
__time64_t ltime;
_time64(&ltime);
- if ((nTimeOut /= 1000) < 1)
+ if ((nTimeOut /= 1000) < 1) {
nTimeOut = 1;
+ }
EnterCriticalSection(&cs);
nThread_tTimeout = ltime + nTimeOut;
@@ -336,38 +333,38 @@ void CMPC_Lcd::SetStatusMessage(const _TCHAR * text, int nTimeOut)
/* update play state bitmap */
void CMPC_Lcd::SetPlayState(CMPC_Lcd::PlayState ps)
{
- if (!m_Output.IsOpened())
+ 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;
+ 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/apps/mplayerc/LcdSupport.h b/src/apps/mplayerc/LcdSupport.h
index 195e3a174..44ed3d306 100644
--- a/src/apps/mplayerc/LcdSupport.h
+++ b/src/apps/mplayerc/LcdSupport.h
@@ -48,8 +48,7 @@ public:
class CMPC_Lcd
{
public:
- enum PlayState
- {
+ enum PlayState {
PS_PLAY = 0,
PS_PAUSE = 1,
PS_STOP = 2,
diff --git a/src/apps/mplayerc/MainFrm.cpp b/src/apps/mplayerc/MainFrm.cpp
index 483531175..add210dd3 100644
--- a/src/apps/mplayerc/MainFrm.cpp
+++ b/src/apps/mplayerc/MainFrm.cpp
@@ -96,11 +96,11 @@ static UINT s_uTBBC = RegisterWindowMessage(TEXT("TaskbarButtonCreated"));
#include "CGdiPlusBitmap.h"
DWORD last_run = 0;
+UINT flast_nID = 0;
class CSubClock : public CUnknown, public ISubClock
{
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv)
- {
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv) {
return
QI(ISubClock)
CUnknown::NonDelegatingQueryInterface(riid, ppv);
@@ -109,21 +109,18 @@ class CSubClock : public CUnknown, public ISubClock
REFERENCE_TIME m_rt;
public:
- CSubClock() : CUnknown(NAME("CSubClock"), NULL)
- {
+ CSubClock() : CUnknown(NAME("CSubClock"), NULL) {
m_rt = 0;
}
DECLARE_IUNKNOWN;
// ISubClock
- STDMETHODIMP SetTime(REFERENCE_TIME rt)
- {
+ STDMETHODIMP SetTime(REFERENCE_TIME rt) {
m_rt = rt;
return S_OK;
}
- STDMETHODIMP_(REFERENCE_TIME) GetTime()
- {
+ STDMETHODIMP_(REFERENCE_TIME) GetTime() {
return(m_rt);
}
};
@@ -138,7 +135,7 @@ public:
\
if(__fs != State_Stopped) \
SendMessage(WM_COMMAND, ID_PLAY_STOP); \
-
+
#define RestoreMediaState \
if(m_iMediaLoadState == MLS_LOADED) \
@@ -152,7 +149,7 @@ public:
else if(__fs == State_Running) \
SendMessage(WM_COMMAND, ID_PLAY_PLAY); \
} \
-
+
using namespace DSObjects;
/////////////////////////////////////////////////////////////////////////////
@@ -504,7 +501,8 @@ BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
ON_COMMAND(ID_HELP_HOMEPAGE, OnHelpHomepage)
ON_COMMAND(ID_HELP_DOCUMENTATION, OnHelpDocumentation)
- ON_COMMAND(ID_HELP_DONATE, OnHelpDonate)
+ ON_COMMAND(ID_HELP_TOOLBARIMAGES, OnHelpToolbarImages)
+ //ON_COMMAND(ID_HELP_DONATE, OnHelpDonate)
// Open Dir incl. SubDir
ON_COMMAND(ID_FILE_OPENDIRECTORY, OnFileOpendirectory)
@@ -520,73 +518,72 @@ END_MESSAGE_MAP()
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");
@@ -599,7 +596,6 @@ const TCHAR *GetEventString(LONG evCode)
#pragma warning(disable : 4355)
CMainFrame::CMainFrame() :
- m_dwRegister(0),
m_iMediaLoadState(MLS_CLOSED),
m_iPlaybackMode(PM_NONE),
m_iSpeedLevel(0),
@@ -645,14 +641,15 @@ CMainFrame::CMainFrame() :
CMainFrame::~CMainFrame()
{
-// m_owner.DestroyWindow();
+ // m_owner.DestroyWindow();
//delete m_pFullscreenWnd; // double delete see CMainFrame::OnDestroy
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
- if(__super::OnCreate(lpCreateStruct) == -1)
+ if(__super::OnCreate(lpCreateStruct) == -1) {
return -1;
+ }
m_popup.LoadMenu(IDR_POPUP);
m_popupmain.LoadMenu(IDR_POPUPMAIN);
@@ -661,8 +658,7 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
// 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))
- {
+ CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST, NULL)) {
TRACE0("Failed to create view window\n");
return -1;
}
@@ -670,16 +666,19 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
// static bars
BOOL bResult = m_wndStatusBar.Create(this);
- if(bResult)
+ if(bResult) {
bResult = m_wndStatsBar.Create(this);
- if(bResult)
+ }
+ if(bResult) {
bResult = m_wndInfoBar.Create(this);
- if(bResult)
+ }
+ if(bResult) {
bResult = m_wndToolBar.Create(this);
- if(bResult)
+ }
+ if(bResult) {
bResult = m_wndSeekBar.Create(this);
- if(!bResult)
- {
+ }
+ if(!bResult) {
TRACE0("Failed to create all control bars\n");
return -1; // fail to create
}
@@ -750,15 +749,16 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
m_pGraphThread = (CGraphThread*)AfxBeginThread(RUNTIME_CLASS(CGraphThread));
- if(m_pGraphThread)
+ if(m_pGraphThread) {
m_pGraphThread->SetMainFrame(this);
+ }
- if(s.nCmdlnWebServerPort != 0)
- {
- if(s.nCmdlnWebServerPort > 0)
+ if(s.nCmdlnWebServerPort != 0) {
+ if(s.nCmdlnWebServerPort > 0) {
StartWebServer(s.nCmdlnWebServerPort);
- else if(s.fEnableWebServer)
+ } else if(s.fEnableWebServer) {
StartWebServer(s.nWebServerPort);
+ }
}
// Casimir666 : reload Shaders
@@ -768,8 +768,7 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
int curPos= 0;
strRes = strList.Tokenize (_T("|"), curPos);
- while (strRes != _T(""))
- {
+ while (strRes != _T("")) {
m_shaderlabels.AddTail (strRes);
strRes = strList.Tokenize(_T("|"),curPos);
}
@@ -780,8 +779,7 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
int curPos= 0;
strRes = strList.Tokenize (_T("|"), curPos);
- while (strRes != _T(""))
- {
+ while (strRes != _T("")) {
m_shaderlabelsScreenSpace.AddTail (strRes);
strRes = strList.Tokenize(_T("|"),curPos);
}
@@ -812,21 +810,19 @@ void CMainFrame::OnDestroy()
m_fileDropTarget.Revoke();
- if ( m_pGraphThread )
- {
+ if ( m_pGraphThread ) {
CAMEvent e;
m_pGraphThread->PostThreadMessage( CGraphThread::TM_EXIT, 0, (LPARAM)&e );
- if( !e.Wait(5000) )
- {
+ 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() )
+ if ( m_pFullscreenWnd ) {
+ if ( m_pFullscreenWnd->IsWindow() ) {
m_pFullscreenWnd->DestroyWindow();
+ }
delete m_pFullscreenWnd;
}
@@ -842,8 +838,7 @@ void CMainFrame::OnClose()
CString strList = "";
pos = m_shaderlabels.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
strList += m_shaderlabels.GetAt (pos) + "|";
m_dockingbars.GetNext(pos);
}
@@ -854,8 +849,7 @@ void CMainFrame::OnClose()
CString strList = "";
pos = m_shaderlabelsScreenSpace.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
strList += m_shaderlabelsScreenSpace.GetAt (pos) + "|";
m_dockingbars.GetNext(pos);
}
@@ -893,14 +887,11 @@ BOOL CMainFrame::OnDrop(COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoi
BOOL bResult = FALSE;
- if(pDataObject->IsDataAvailable(CF_URL))
- {
+ if(pDataObject->IsDataAvailable(CF_URL)) {
FORMATETC fmt = {CF_URL, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
- if(HGLOBAL hGlobal = pDataObject->GetGlobalData(CF_URL, &fmt))
- {
+ if(HGLOBAL hGlobal = pDataObject->GetGlobalData(CF_URL, &fmt)) {
LPCSTR pText = (LPCSTR)GlobalLock(hGlobal);
- if(AfxIsValidString(pText))
- {
+ if(AfxIsValidString(pText)) {
CStringA url(pText);
SetForegroundWindow();
@@ -908,12 +899,9 @@ BOOL CMainFrame::OnDrop(COleDataObject* pDataObject, DROPEFFECT dropEffect, CPoi
CAtlList<CString> sl;
sl.AddTail(CString(url));
- if(m_wndPlaylistBar.IsWindowVisible())
- {
+ if(m_wndPlaylistBar.IsWindowVisible()) {
m_wndPlaylistBar.Append(sl, true);
- }
- else
- {
+ } else {
m_wndPlaylistBar.Open(sl, true);
OpenCurPlaylistItem();
}
@@ -945,29 +933,32 @@ LPCTSTR CMainFrame::GetRecentFile()
{
CRecentFileList& MRU = AfxGetAppSettings().MRU;
MRU.ReadList();
- for(int i = 0; i < MRU.GetSize(); i++)
- {
- if(!MRU[i].IsEmpty())
+ for(int i = 0; i < MRU.GetSize(); i++) {
+ if(!MRU[i].IsEmpty()) {
return MRU[i].GetString();
+ }
}
return NULL;
}
void CMainFrame::LoadControlBar(CControlBar* pBar, UINT defDockBarID)
{
- if(!pBar) return;
+ if(!pBar) {
+ return;
+ }
CString str;
pBar->GetWindowText(str);
- if(str.IsEmpty()) return;
+ if(str.IsEmpty()) {
+ return;
+ }
CString section = _T("ToolBars\\") + str;
CWinApp* pApp = AfxGetApp();
UINT nID = pApp->GetProfileInt(section, _T("DockState"), defDockBarID);
- if(nID != AFX_IDW_DOCKBAR_FLOAT)
- {
+ if(nID != AFX_IDW_DOCKBAR_FLOAT) {
DockControlBar(pBar, nID);
}
@@ -981,8 +972,7 @@ void CMainFrame::LoadControlBar(CControlBar* pBar, UINT defDockBarID)
? SW_SHOW
: SW_HIDE);
- if(CSizingControlBar* pSCB = dynamic_cast<CSizingControlBar*>(pBar))
- {
+ if(CSizingControlBar* pSCB = dynamic_cast<CSizingControlBar*>(pBar)) {
pSCB->LoadState(section + _T("\\State"));
m_dockingbars.AddTail(pSCB);
}
@@ -996,27 +986,36 @@ void CMainFrame::RestoreFloatingControlBars()
GetWindowRect(r);
POSITION pos = m_dockingbars.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CSizingControlBar* pBar = m_dockingbars.GetNext(pos);
CString str;
pBar->GetWindowText(str);
- if(str.IsEmpty()) return;
+ if(str.IsEmpty()) {
+ return;
+ }
CString section = _T("ToolBars\\") + str;
- if((pBar == &m_wndPlaylistBar) && pApp->GetProfileInt(section, _T("Visible"), FALSE))
+ if((pBar == &m_wndPlaylistBar) && pApp->GetProfileInt(section, _T("Visible"), FALSE)) {
pBar->ShowWindow(SW_SHOW);
+ }
- if(pApp->GetProfileInt(section, _T("DockState"), ~AFX_IDW_DOCKBAR_FLOAT) == AFX_IDW_DOCKBAR_FLOAT)
- {
+ if(pApp->GetProfileInt(section, _T("DockState"), ~AFX_IDW_DOCKBAR_FLOAT) == 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 < m_rcDesktop.left) p.x = m_rcDesktop.left;
- if(p.y < m_rcDesktop.top) p.y = m_rcDesktop.top;
- if(p.x >= m_rcDesktop.right) p.x = m_rcDesktop.right-1;
- if(p.y >= m_rcDesktop.bottom) p.y = m_rcDesktop.bottom-1;
+ if(p.x < m_rcDesktop.left) {
+ p.x = m_rcDesktop.left;
+ }
+ if(p.y < m_rcDesktop.top) {
+ p.y = m_rcDesktop.top;
+ }
+ if(p.x >= m_rcDesktop.right) {
+ p.x = m_rcDesktop.right-1;
+ }
+ if(p.y >= m_rcDesktop.bottom) {
+ p.y = m_rcDesktop.bottom-1;
+ }
FloatControlBar(pBar, p);
}
}
@@ -1027,26 +1026,25 @@ void CMainFrame::SaveControlBars()
CWinApp* pApp = AfxGetApp();
POSITION pos = m_dockingbars.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CSizingControlBar* pBar = m_dockingbars.GetNext(pos);
CString str;
pBar->GetWindowText(str);
- if(str.IsEmpty()) return;
+ if(str.IsEmpty()) {
+ return;
+ }
CString section = _T("ToolBars\\") + str;
pApp->WriteProfileInt(section, _T("Visible"), pBar->IsWindowVisible());
- if(CSizingControlBar* pSCB = dynamic_cast<CSizingControlBar*>(pBar))
- {
+ if(CSizingControlBar* pSCB = dynamic_cast<CSizingControlBar*>(pBar)) {
pSCB->SaveState(section + _T("\\State"));
}
UINT nID = pBar->GetParent()->GetDlgCtrlID();
- if(nID == AFX_IDW_DOCKBAR_FLOAT)
- {
+ if(nID == AFX_IDW_DOCKBAR_FLOAT) {
CRect r;
pBar->GetParent()->GetParent()->GetWindowRect(r);
pApp->WriteProfileInt(section, _T("DockPosX"), r.left);
@@ -1067,41 +1065,39 @@ LRESULT CMainFrame::OnTaskBarRestart(WPARAM, LPARAM)
LRESULT CMainFrame::OnNotifyIcon(WPARAM wParam, LPARAM lParam)
{
- if((UINT)wParam != IDR_MAINFRAME)
+ if((UINT)wParam != IDR_MAINFRAME) {
return -1;
+ }
- switch((UINT)lParam)
- {
- case WM_LBUTTONDOWN:
- ShowWindow(SW_SHOW);
- MoveVideoWindow();
- SetForegroundWindow();
- break;
+ switch((UINT)lParam) {
+ case WM_LBUTTONDOWN:
+ ShowWindow(SW_SHOW);
+ MoveVideoWindow();
+ SetForegroundWindow();
+ break;
- case WM_LBUTTONDBLCLK:
- PostMessage(WM_COMMAND, ID_FILE_OPENMEDIA);
- 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_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;
- }
+ case WM_MOUSEMOVE: {
+ CString str;
+ GetWindowText(str);
+ SetTrayTip(str);
+ break;
+ }
- default:
- break;
+ default:
+ break;
}
return 0;
@@ -1122,10 +1118,8 @@ void CMainFrame::ShowTrayIcon(bool fShow)
tnid.hWnd = m_hWnd;
tnid.uID = IDR_MAINFRAME;
- if(fShow)
- {
- if(!m_fTrayIcon)
- {
+ 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;
@@ -1134,19 +1128,17 @@ void CMainFrame::ShowTrayIcon(bool fShow)
m_fTrayIcon = true;
}
- }
- else
- {
- if(m_fTrayIcon)
- {
+ } else {
+ if(m_fTrayIcon) {
Shell_NotifyIcon(NIM_DELETE, &tnid);
m_fTrayIcon = false;
}
}
- if(bWasVisible)
+ if(bWasVisible) {
ShowWindow(SW_SHOW);
+ }
}
void CMainFrame::SetTrayTip(CString str)
@@ -1162,8 +1154,9 @@ void CMainFrame::SetTrayTip(CString str)
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
- if(!__super::PreCreateWindow(cs))
+ if(!__super::PreCreateWindow(cs)) {
return FALSE;
+ }
cs.dwExStyle &= ~WS_EX_CLIENTEDGE;
@@ -1174,44 +1167,35 @@ BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
{
- if(pMsg->message == WM_KEYDOWN)
- {
+ 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)
- {
+ if(pMsg->wParam == VK_ESCAPE) {
bool fEscapeNotAssigned = true;
AppSettings& s = AfxGetAppSettings();
POSITION pos = s.wmcmds.GetHeadPosition();
while(pos && fEscapeNotAssigned)
- if(s.wmcmds.GetNext(pos).key == VK_ESCAPE)
+ if(s.wmcmds.GetNext(pos).key == VK_ESCAPE) {
fEscapeNotAssigned = false;
+ }
- if(fEscapeNotAssigned)
- {
- if(m_iMediaLoadState == MLS_LOADED && m_fFullScreen)
- {
+ if(fEscapeNotAssigned) {
+ if(m_iMediaLoadState == MLS_LOADED && m_fFullScreen) {
OnViewFullscreen();
PostMessage(WM_COMMAND, ID_PLAY_PAUSE);
return TRUE;
- }
- else if(IsCaptionMenuHidden())
- {
+ } else if(IsCaptionMenuHidden()) {
PostMessage(WM_COMMAND, ID_VIEW_CAPTIONMENU);
return TRUE;
}
}
- }
- else if(pMsg->wParam == VK_LEFT && pAMTuner)
- {
+ } else if(pMsg->wParam == VK_LEFT && pAMTuner) {
PostMessage(WM_COMMAND, ID_NAVIGATE_SKIPBACK);
return TRUE;
- }
- else if(pMsg->wParam == VK_RIGHT && pAMTuner)
- {
+ } else if(pMsg->wParam == VK_RIGHT && pAMTuner) {
PostMessage(WM_COMMAND, ID_NAVIGATE_SKIPFORWARD);
return TRUE;
}
@@ -1256,28 +1240,30 @@ void CMainFrame::OnSetFocus(CWnd* pOldWnd)
SetAlwaysOnTop(AfxGetAppSettings().iOnTop);
// forward focus to the view window
- if(IsWindow(m_wndView.m_hWnd))
+ 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))
+ 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))
+ 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))
+ while(pos) {
+ if(m_dockingbars.GetNext(pos)->OnCmdMsg(nID, nCode, pExtra, pHandlerInfo)) {
return TRUE;
+ }
}
// otherwise, do default handling
@@ -1294,44 +1280,45 @@ void CMainFrame::OnGetMinMaxInfo(MINMAXINFO* lpMMI)
::GetMenuBarInfo(m_hWnd, OBJID_MENU, 0, &mbi);
lpMMI->ptMinTrackSize.x = 0;
- if ( !IsCaptionMenuHidden() )
- {
+ if ( !IsCaptionMenuHidden() ) {
// Calculate menu's horizontal length in pixels
lpMMI->ptMinTrackSize.x = 10;
CRect r;
- for (int i = 0; ::GetMenuItemRect(m_hWnd, mbi.hMenu, i, &r); i++)
+ for (int i = 0; ::GetMenuItemRect(m_hWnd, mbi.hMenu, i, &r); i++) {
lpMMI->ptMinTrackSize.x += r.Width();
+ }
lpMMI->ptMinTrackSize.x = max( m_wndToolBar.GetMinWidth(), lpMMI->ptMinTrackSize.x );
}
- if ( style & WS_THICKFRAME )
+ if ( style & WS_THICKFRAME ) {
lpMMI->ptMinTrackSize.x += GetSystemMetrics( (style & WS_CAPTION) ? SM_CXSIZEFRAME : SM_CXFIXEDFRAME ) * 2;
+ }
lpMMI->ptMinTrackSize.y = 0;
- if ( style & WS_CAPTION )
- {
+ if ( style & WS_CAPTION ) {
lpMMI->ptMinTrackSize.y += GetSystemMetrics( SM_CYCAPTION );
// If we have a caption then we have a menu bar
lpMMI->ptMinTrackSize.y += GetSystemMetrics( SM_CYMENU ); //(mbi.rcBar.bottom - mbi.rcBar.top);
}
- if ( style & WS_THICKFRAME )
+ if ( style & WS_THICKFRAME ) {
lpMMI->ptMinTrackSize.y += GetSystemMetrics( SM_CYSIZEFRAME ) * 2;
+ }
POSITION pos = m_bars.GetHeadPosition();
- while ( pos )
- {
+ while ( pos ) {
CControlBar *pCB = m_bars.GetNext( pos );
- if ( !IsWindow(pCB->m_hWnd) || !pCB->IsVisible() )
+ if ( !IsWindow(pCB->m_hWnd) || !pCB->IsVisible() ) {
continue;
+ }
lpMMI->ptMinTrackSize.y += pCB->CalcFixedLayout(TRUE, TRUE).cy;
}
pos = m_dockingbars.GetHeadPosition();
- while ( pos )
- {
+ 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 ( 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
+ }
}
__super::OnGetMinMaxInfo( lpMMI );
@@ -1346,16 +1333,16 @@ void CMainFrame::OnMove(int x, int y)
WINDOWPLACEMENT wp;
GetWindowPlacement(&wp);
- if(!m_fFirstFSAfterLaunchOnFS && !m_fFullScreen && wp.flags != WPF_RESTORETOMAXIMIZED && wp.showCmd != SW_SHOWMINIMIZED)
+ 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);
- if(AfxGetAppSettings().fSnapToDesktopEdges)
- {
+ if(AfxGetAppSettings().fSnapToDesktopEdges) {
const CPoint threshold(3, 3);
CRect r0 = m_rcDesktop;
@@ -1365,17 +1352,21 @@ void CMainFrame::OnMoving(UINT fwSide, LPRECT pRect)
RECT& wr = *pRect;
CSize ws = CRect(wr).Size();
- if(wr.left < r1.left && wr.left > r2.left)
+ if(wr.left < r1.left && wr.left > r2.left) {
wr.right = (wr.left = r0.left) + ws.cx;
+ }
- if(wr.top < r1.top && wr.top > r2.top)
+ if(wr.top < r1.top && wr.top > r2.top) {
wr.bottom = (wr.top = r0.top) + ws.cy;
+ }
- if(wr.right < r1.right && wr.right > r2.right)
+ if(wr.right < r1.right && wr.right > r2.right) {
wr.left = (wr.right = r0.right) - ws.cx;
+ }
- if(wr.bottom < r1.bottom && wr.bottom > r2.bottom)
+ if(wr.bottom < r1.bottom && wr.bottom > r2.bottom) {
wr.top = (wr.bottom = r0.bottom) - ws.cy;
+ }
}
}
@@ -1385,16 +1376,15 @@ void CMainFrame::OnSize(UINT nType, int cx, int cy)
m_OSD.OnSize (nType, cx, cy);
- if(nType == SIZE_RESTORED && m_fTrayIcon)
- {
+ if(nType == SIZE_RESTORED && m_fTrayIcon) {
ShowWindow(SW_SHOW);
}
- if(!m_fFirstFSAfterLaunchOnFS && IsWindowVisible() && !m_fFullScreen)
- {
+ if(!m_fFirstFSAfterLaunchOnFS && IsWindowVisible() && !m_fFullScreen) {
AppSettings& s = AfxGetAppSettings();
- if(nType != SIZE_MAXIMIZED && nType != SIZE_MINIMIZED)
+ if(nType != SIZE_MAXIMIZED && nType != SIZE_MINIMIZED) {
GetWindowRect(s.rcLastWindowPos);
+ }
s.nLastWindowType = nType;
}
}
@@ -1409,15 +1399,17 @@ void CMainFrame::OnSizing(UINT fwSide, LPRECT pRect)
if(m_iMediaLoadState != MLS_LOADED || m_fFullScreen
|| s.iDefaultVideoSize == DVS_STRETCH
- || (fCtrl == s.fLimitWindowProportions)) // remember that fCtrl is initialized with !!whatever(), same with fLimitWindowProportions
+ || (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)
+ if(!vsize.cx || !vsize.cy) {
return;
+ }
// TODO
{
@@ -1429,37 +1421,37 @@ void CMainFrame::OnSizing(UINT fwSide, LPRECT pRect)
//mbi.cbSize = sizeof(mbi);
//::GetMenuBarInfo(m_hWnd, OBJID_MENU, 0, &mbi);
- if ( style & WS_THICKFRAME )
+ if ( style & WS_THICKFRAME ) {
fsize.cx += GetSystemMetrics( SM_CXSIZEFRAME ) * 2;
+ }
- if ( style & WS_CAPTION )
- {
+ if ( style & WS_CAPTION ) {
fsize.cy += GetSystemMetrics( SM_CYCAPTION );
// If we have a caption then we have a menu bar
fsize.cy += GetSystemMetrics( SM_CYMENU ); //mbi.rcBar.bottom - mbi.rcBar.top;
}
- if ( style & WS_THICKFRAME )
+ if ( style & WS_THICKFRAME ) {
fsize.cy += GetSystemMetrics( SM_CYSIZEFRAME ) * 2;
+ }
POSITION pos = m_bars.GetHeadPosition();
- while ( pos )
- {
+ while ( pos ) {
CControlBar * pCB = m_bars.GetNext( pos );
- if ( IsWindow(pCB->m_hWnd) && pCB->IsVisible() )
+ if ( IsWindow(pCB->m_hWnd) && pCB->IsVisible() ) {
fsize.cy += pCB->CalcFixedLayout(TRUE, TRUE).cy;
+ }
}
pos = m_dockingbars.GetHeadPosition();
- while ( pos )
- {
+ while ( pos ) {
CSizingControlBar *pCB = m_dockingbars.GetNext( pos );
- if ( IsWindow(pCB->m_hWnd) && pCB->IsWindowVisible() && !pCB->IsFloating() )
- {
- if ( pCB->IsHorzDocked() )
+ if ( IsWindow(pCB->m_hWnd) && pCB->IsWindowVisible() && !pCB->IsFloating() ) {
+ if ( pCB->IsHorzDocked() ) {
fsize.cy += pCB->CalcFixedLayout(TRUE, TRUE).cy - 2;
- else if ( pCB->IsVertDocked() )
+ } else if ( pCB->IsVertDocked() ) {
fsize.cx += pCB->CalcFixedLayout(TRUE, FALSE).cx;
+ }
}
}
}
@@ -1474,20 +1466,13 @@ void CMainFrame::OnSizing(UINT fwSide, LPRECT pRect)
wsize += fsize;
- if(fwSide == WMSZ_TOP || fwSide == WMSZ_BOTTOM || !fWider && (fwSide == WMSZ_TOPRIGHT || fwSide == WMSZ_BOTTOMRIGHT))
- {
+ 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))
- {
+ } 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))
- {
+ } else if(!fWider && (fwSide == WMSZ_TOPLEFT || fwSide == WMSZ_BOTTOMLEFT)) {
pRect->left = pRect->right - wsize.cx;
- }
- else if(fWider && (fwSide == WMSZ_TOPLEFT || fwSide == WMSZ_TOPRIGHT))
- {
+ } else if(fWider && (fwSide == WMSZ_TOPLEFT || fwSide == WMSZ_TOPRIGHT)) {
pRect->top = pRect->bottom - wsize.cy;
}
}
@@ -1501,15 +1486,13 @@ void CMainFrame::OnDisplayChange() // untested, not sure if it's working...
*/
GetDesktopWindow()->GetWindowRect(&m_rcDesktop);
- if (m_pFullscreenWnd && m_pFullscreenWnd->IsWindow())
- {
+ 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))
- {
+ if (GetMonitorInfo (hMonitor, &MonitorInfo)) {
CRect MonitorRect = CRect (MonitorInfo.rcMonitor);
m_fullWndSize.cx = MonitorRect.Width();
m_fullWndSize.cy = MonitorRect.Height();
@@ -1528,13 +1511,10 @@ void CMainFrame::OnDisplayChange() // untested, not sure if it's working...
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)))
- {
+ 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)
- {
+ } else if((nID & 0xFFF0) == SC_MINIMIZE && m_fTrayIcon) {
ShowWindow(SW_HIDE);
return;
}
@@ -1550,38 +1530,33 @@ void CMainFrame::OnActivateApp(BOOL bActive, DWORD dwThreadID)
mi.cbSize = sizeof(MONITORINFO);
GetMonitorInfo(MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST), &mi);
- if(!bActive && (mi.dwFlags&MONITORINFOF_PRIMARY) && m_fFullScreen && m_iMediaLoadState == MLS_LOADED)
- {
+ if(!bActive && (mi.dwFlags&MONITORINFOF_PRIMARY) && m_fFullScreen && m_iMediaLoadState == MLS_LOADED) {
bool fExitFullscreen = true;
- if(CWnd* pWnd = GetForegroundWindow())
- {
+ 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(hMonitor1 && hMonitor2 && ((hMonitor1 != hMonitor2) || (monitors.GetCount()>1))) {
+ fExitFullscreen = false;
+ }
CString title;
pWnd->GetWindowText(title);
CString module;
- if(GetVersion()&0x80000000)
- {
+ if(GetVersion()&0x80000000) {
module.ReleaseBufferSetLength(GetWindowModuleFileName(pWnd->m_hWnd, module.GetBuffer(_MAX_PATH), _MAX_PATH));
- }
- else
- {
+ } else {
DWORD pid;
GetWindowThreadProcessId(pWnd->m_hWnd, &pid);
- if(HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid))
- {
+ if(HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid)) {
HMODULE hMod;
DWORD cbNeeded;
- if(EnumProcessModules(hProcess, &hMod, sizeof(hMod), &cbNeeded))
- {
+ if(EnumProcessModules(hProcess, &hMod, sizeof(hMod), &cbNeeded)) {
module.ReleaseBufferSetLength(GetModuleFileNameEx(hProcess, hMod, module.GetBuffer(_MAX_PATH), _MAX_PATH));
}
@@ -1599,7 +1574,9 @@ void CMainFrame::OnActivateApp(BOOL bActive, DWORD dwThreadID)
SendStatusMessage(str, 5000);
}
- if(fExitFullscreen) OnViewFullscreen();
+ if(fExitFullscreen) {
+ OnViewFullscreen();
+ }
}
}
@@ -1611,21 +1588,22 @@ LRESULT CMainFrame::OnAppCommand(WPARAM wParam, 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 )
- {
+ cmd == APPCOMMAND_MEDIA_FAST_FORWARD || cmd == APPCOMMAND_MEDIA_REWIND ) {
AppSettings& s = AfxGetAppSettings();
BOOL fRet = FALSE;
POSITION pos = s.wmcmds.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
wmcmd& wc = s.wmcmds.GetNext(pos);
- if(wc.appcmd == cmd && TRUE == SendMessage(WM_COMMAND, wc.cmd))
+ if(wc.appcmd == cmd && TRUE == SendMessage(WM_COMMAND, wc.cmd)) {
fRet = TRUE;
+ }
}
- if(fRet) return TRUE;
+ if(fRet) {
+ return TRUE;
+ }
}
return Default();
@@ -1637,40 +1615,37 @@ void CMainFrame::OnRawInput(UINT nInputcode, HRAWINPUT hRawInput)
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;
+ 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;
+ break;
}
}
@@ -1679,15 +1654,14 @@ LRESULT CMainFrame::OnHotKey(WPARAM wParam, LPARAM lParam)
AppSettings& s = AfxGetAppSettings();
BOOL fRet = FALSE;
- if (GetActiveWindow() == this || s.fGlobalMedia == TRUE)
- {
+ if (GetActiveWindow() == this || s.fGlobalMedia == TRUE) {
POSITION pos = s.wmcmds.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
wmcmd& wc = s.wmcmds.GetNext(pos);
- if (wc.appcmd == wParam && TRUE == SendMessage(WM_COMMAND, wc.cmd))
+ if (wc.appcmd == wParam && TRUE == SendMessage(WM_COMMAND, wc.cmd)) {
fRet = TRUE;
+ }
}
}
@@ -1699,511 +1673,480 @@ 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));
+ 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;
}
- 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_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;
+ 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;
- }
+ 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;
+ 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_fCapturing)
- {
- if(rtNow > 10000i64*1000*60*60*3)
+ 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_fCapturing)
{
- m_wndCaptureBar.m_capdlg.OnRecord();
+ if(rtNow > 10000i64*1000*60*60*3)
+ {
+ m_wndCaptureBar.m_capdlg.OnRecord();
+ }
}
+ */
}
- */
- }
- 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);
+ 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
- m_pCAP->SetTime(/*rtNow*/m_wndSeekBar.GetPos());
- }
- else
- {
- // Set rtNow to support DVB subtitle
- m_pCAP->SetTime(rtNow);
+ } else {
+ g_bExternalSubtitleTime = false;
}
}
- 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);
+ 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 = _T("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;
+ }
- if(GetPlaybackMode() == PM_CAPTURE && !m_fCapturing)
- {
- CString str = _T("Live");
+ 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());
+ }
- 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);
- m_wndSubresyncBar.SetTime(pos);
+ CRect r;
+ GetWindowRect(r);
+ bool fCursorOutside = !r.PtInRect(p);
- if(m_pCAP && GetMediaState() == State_Paused)
- m_pCAP->Paint(false);
+ CWnd* pWnd = WindowFromPoint(p);
+ if(pWnd && (m_wndView == *pWnd || m_wndView.IsChild(pWnd) || fCursorOutside)) {
+ if(AfxGetAppSettings().nShowBarsWhenFullScreenTimeOut >= 0) {
+ ShowControls(CS_NONE, 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, false);
- }
- }
- break;
- case TIMER_FULLSCREENMOUSEHIDER:
- {
- CPoint p;
- GetCursorPos(&p);
+ case TIMER_FULLSCREENMOUSEHIDER: {
+ CPoint p;
+ GetCursorPos(&p);
- CRect r;
- GetWindowRect(r);
- bool fCursorOutside = !r.PtInRect(p);
+ CRect r;
+ GetWindowRect(r);
+ bool fCursorOutside = !r.PtInRect(p);
- if (m_pFullscreenWnd->IsWindow())
- {
- TRACE ("==> HIDE!\n");
- if (!m_bInOptions)
- m_pFullscreenWnd->ShowCursor(false);
- KillTimer(TIMER_FULLSCREENMOUSEHIDER);
- }
- else
- {
- CWnd* pWnd = WindowFromPoint(p);
- if(pWnd && (m_wndView == *pWnd || m_wndView.IsChild(pWnd) || fCursorOutside))
- {
- m_fHideCursor = true;
- SetCursor(NULL);
+ if (m_pFullscreenWnd->IsWindow()) {
+ TRACE ("==> HIDE!\n");
+ if (!m_bInOptions) {
+ m_pFullscreenWnd->ShowCursor(false);
+ }
+ KillTimer(TIMER_FULLSCREENMOUSEHIDER);
+ } else {
+ CWnd* pWnd = WindowFromPoint(p);
+ if(pWnd && (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)");
- }
+ 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;
+ CString info;
+ int val;
- pQP->get_AvgFrameRate(&val);
- info.Format(_T("%d.%02d %s"), val/100, val%100, rate);
- m_wndStatsBar.SetLine(ResStr(IDS_AG_FRAMERATE), info);
+ pQP->get_AvgFrameRate(&val);
+ 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 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(ResStr(IDS_MAINFRM_6), drawn, dropped);
- m_wndStatsBar.SetLine(ResStr(IDS_AG_FRAMES), info);
+ int drawn, dropped;
+ pQP->get_FramesDrawn(&drawn);
+ pQP->get_FramesDroppedInRenderer(&dropped);
+ info.Format(ResStr(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);
- }
+ pQP->get_Jitter(&val);
+ info.Format(_T("%d ms"), val);
+ m_wndStatsBar.SetLine(_T("Jitter"), info);
+ }
- if(pBI)
- {
- CAtlList<CString> sl;
+ 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);
+ 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());
+ if(!sl.IsEmpty()) {
+ CString str;
+ str.Format(_T("%s (p%d)"), Implode(sl, ' '), pBI->GetPriority());
- m_wndStatsBar.SetLine(ResStr(IDS_AG_BUFFERS), str);
+ m_wndStatsBar.SetLine(ResStr(IDS_AG_BUFFERS), str);
+ }
}
- }
- CInterfaceList<IBitRateInfo> pBRIs;
+ CInterfaceList<IBitRateInfo> pBRIs;
- BeginEnumFilters(pGB, pEF, pBF)
- {
- BeginEnumPins(pBF, pEP, pPin)
- {
- if(CComQIPtr<IBitRateInfo> pBRI = pPin)
- {
- pBRIs.AddTail(pBRI);
+ BeginEnumFilters(pGB, pEF, pBF) {
+ BeginEnumPins(pBF, pEP, pPin) {
+ if(CComQIPtr<IBitRateInfo> pBRI = pPin) {
+ pBRIs.AddTail(pBRI);
+ }
}
- }
- EndEnumPins;
+ EndEnumPins;
- if(!pBRIs.IsEmpty())
- {
- CAtlList<CString> sl;
+ if(!pBRIs.IsEmpty()) {
+ CAtlList<CString> sl;
- POSITION pos = pBRIs.GetHeadPosition();
- for(int i = 0; pos; i++)
- {
- IBitRateInfo* pBRI = pBRIs.GetNext(pos);
+ 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;
+ DWORD cur = pBRI->GetCurrentBitRate() / 1000;
+ DWORD avg = pBRI->GetAverageBitRate() / 1000;
- if(avg == 0) continue;
+ 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);
- }
+ 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)"));
+ if(!sl.IsEmpty()) {
+ m_wndStatsBar.SetLine(_T("Bitrate"), Implode(sl, ' ') + _T(" (avg/cur)"));
+ }
+
+ break;
}
+ }
+ EndEnumFilters;
- break;
+ if(GetPlaybackMode() == PM_FILE) {
+ SetupChapters();
}
- }
- 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(ResStr(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;
+ }
+ }
+ }
- if(GetPlaybackMode() == PM_DVD) // we also use this timer to update the info panel for DVD playback
- {
- ULONG ulAvailable, ulCurrent;
+ m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_LOCATION), Location);
- // Location
+ // Video
- CString Location('-');
+ CString Video('-');
- DVD_PLAYBACK_LOCATION2 loc;
- ULONG ulNumOfVolumes, ulVolume;
- DVD_DISC_SIDE Side;
- ULONG ulNumOfTitles;
- ULONG ulNumOfChapters;
+ DVD_VideoAttributes VATR;
- if(SUCCEEDED(pDVDI->GetCurrentLocation(&loc))
- && SUCCEEDED(pDVDI->GetNumberOfChapters(loc.TitleNum, &ulNumOfChapters))
- && SUCCEEDED(pDVDI->GetDVDVolumeInfo(&ulNumOfVolumes, &ulVolume, &Side, &ulNumOfTitles)))
- {
- Location.Format(ResStr(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;
+ if(SUCCEEDED(pDVDI->GetCurrentAngle(&ulAvailable, &ulCurrent))
+ && SUCCEEDED(pDVDI->GetCurrentVideoAttributes(&VATR))) {
+ Video.Format(ResStr(IDS_MAINFRM_10),
+ ulAvailable, ulCurrent,
+ VATR.ulSourceResolutionX, VATR.ulSourceResolutionY, VATR.ulFrameRate,
+ VATR.ulAspectX, VATR.ulAspectY);
}
- }
-
- m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_LOCATION), Location);
- // Video
+ m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_VIDEO), Video);
- CString Video('-');
+ // Audio
- DVD_VideoAttributes VATR;
-
- if(SUCCEEDED(pDVDI->GetCurrentAngle(&ulAvailable, &ulCurrent))
- && SUCCEEDED(pDVDI->GetCurrentVideoAttributes(&VATR)))
- {
- Video.Format(ResStr(IDS_MAINFRM_10),
- ulAvailable, ulCurrent,
- VATR.ulSourceResolutionX, VATR.ulSourceResolutionY, VATR.ulFrameRate,
- VATR.ulAspectX, VATR.ulAspectY);
- }
+ CString Audio('-');
- m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_VIDEO), Video);
+ DVD_AudioAttributes AATR;
- // Audio
+ if(SUCCEEDED(pDVDI->GetCurrentAudio(&ulAvailable, &ulCurrent))
+ && SUCCEEDED(pDVDI->GetAudioAttributes(ulCurrent, &AATR))) {
+ CString lang;
+ int len = GetLocaleInfo(AATR.Language, LOCALE_SENGLANGUAGE, lang.GetBuffer(64), 64);
+ lang.ReleaseBufferSetLength(max(len-1, 0));
- CString Audio('-');
+ 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;
+ }
- DVD_AudioAttributes AATR;
+ CString format = GetDVDAudioFormatName(AATR);
- if(SUCCEEDED(pDVDI->GetCurrentAudio(&ulAvailable, &ulCurrent))
- && SUCCEEDED(pDVDI->GetAudioAttributes(ulCurrent, &AATR)))
- {
- CString lang;
- int len = GetLocaleInfo(AATR.Language, LOCALE_SENGLANGUAGE, lang.GetBuffer(64), 64);
- lang.ReleaseBufferSetLength(max(len-1, 0));
+ Audio.Format(ResStr(IDS_MAINFRM_11),
+ lang,
+ format,
+ AATR.dwFrequency,
+ AATR.bQuantization,
+ AATR.bNumberOfChannels,
+ (AATR.bNumberOfChannels > 1 ? ResStr(IDS_MAINFRM_13) : ResStr(IDS_MAINFRM_12)));
- 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;
+ m_wndStatusBar.SetStatusBitmap(
+ AATR.bNumberOfChannels == 1 ? IDB_MONO
+ : AATR.bNumberOfChannels >= 2 ? IDB_STEREO
+ : IDB_NOAUDIO);
}
- CString format = GetDVDAudioFormatName(AATR);
-
- Audio.Format(ResStr(IDS_MAINFRM_11),
- lang,
- format,
- AATR.dwFrequency,
- AATR.bQuantization,
- AATR.bNumberOfChannels,
- (AATR.bNumberOfChannels > 1 ? ResStr(IDS_MAINFRM_13) : ResStr(IDS_MAINFRM_12)));
+ m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_AUDIO), Audio);
- m_wndStatusBar.SetStatusBitmap(
- AATR.bNumberOfChannels == 1 ? IDB_MONO
- : AATR.bNumberOfChannels >= 2 ? IDB_STEREO
- : IDB_NOAUDIO);
- }
+ // Subtitles
- m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_AUDIO), Audio);
+ CString Subtitles('-');
- // Subtitles
+ BOOL bIsDisabled;
+ DVD_SubpictureAttributes SATR;
- CString Subtitles('-');
+ 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));
- BOOL bIsDisabled;
- DVD_SubpictureAttributes SATR;
+ 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(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));
+ if(bIsDisabled) {
+ lang = _T("-");
+ }
- 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;
+ Subtitles.Format(_T("%s"),
+ lang);
}
- if(bIsDisabled) lang = _T("-");
-
- Subtitles.Format(_T("%s"),
- lang);
+ m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_SUBTITLES), Subtitles);
}
- 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);
- }
+ 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);
+ 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);
}
- // 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;
+ break;
+ case TIMER_STATUSERASER: {
+ KillTimer(TIMER_STATUSERASER);
+ m_playingmsg.Empty();
+ }
+ break;
}
__super::OnTimer(nIDEvent);
@@ -2217,8 +2160,9 @@ static bool SetShutdownPrivilege()
SetThreadExecutionState (ES_CONTINUOUS);
// Get a token for this process.
- if(!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
+ if(!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) {
return(false);
+ }
// Get the LUID for the shutdown privilege.
@@ -2231,8 +2175,9 @@ static bool SetShutdownPrivilege()
AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES)NULL, 0);
- if(GetLastError() != ERROR_SUCCESS)
+ if(GetLastError() != ERROR_SUCCESS) {
return false;
+ }
return true;
}
@@ -2243,37 +2188,31 @@ bool CMainFrame::DoAfterPlaybackEvent()
bool fExit = false;
- if(s.nCLSwitches&CLSW_CLOSE || s.fExitAfterPlayback)
- {
+ if(s.nCLSwitches&CLSW_CLOSE || s.fExitAfterPlayback) {
fExit = true;
}
- if(s.nCLSwitches&CLSW_STANDBY)
- {
+ if(s.nCLSwitches&CLSW_STANDBY) {
SetShutdownPrivilege();
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)
- {
+ } else if(s.nCLSwitches&CLSW_HIBERNATE) {
SetShutdownPrivilege();
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)
- {
+ } else if(s.nCLSwitches&CLSW_SHUTDOWN) {
SetShutdownPrivilege();
ExitWindowsEx(EWX_SHUTDOWN|EWX_POWEROFF|EWX_FORCEIFHUNG, 0);
fExit = true;
- }
- else if(s.nCLSwitches&CLSW_LOGOFF)
- {
+ } else if(s.nCLSwitches&CLSW_LOGOFF) {
SetShutdownPrivilege();
ExitWindowsEx(EWX_LOGOFF|EWX_FORCEIFHUNG, 0);
fExit = true;
}
- if(!fExit) return false;
+ if(!fExit) {
+ return false;
+ }
SendMessage(WM_COMMAND, ID_FILE_EXIT);
@@ -2287,95 +2226,78 @@ bool CMainFrame::GraphEventComplete( )
{
AppSettings& s = AfxGetAppSettings();
FILE_POSITION* FilePosition = s.CurrentFilePosition();
- if (FilePosition)
- {
+ if (FilePosition) {
FilePosition->llPosition = 0;
QueryPerformanceCounter(&m_LastSaveTime);
- if (s.fKeepHistory && s.fRememberFilePos)
+ if (s.fKeepHistory && s.fRememberFilePos) {
s.SaveCurrentFilePosition();
+ }
}
- if(m_wndPlaylistBar.GetCount() <= 1)
- {
+ if(m_wndPlaylistBar.GetCount() <= 1) {
m_nLoops++;
- if(DoAfterPlaybackEvent())
+ if(DoAfterPlaybackEvent()) {
return false;
+ }
- if(s.fLoopForever || m_nLoops < s.nLoops)
- {
- if(GetMediaState() == State_Stopped)
- {
+ if(s.fLoopForever || m_nLoops < s.nLoops) {
+ if(GetMediaState() == State_Stopped) {
SendMessage(WM_COMMAND, ID_PLAY_PLAY);
- }
- else
- {
+ } else {
LONGLONG pos = 0;
pMS->SetPositions(&pos, AM_SEEKING_AbsolutePositioning, NULL, AM_SEEKING_NoPositioning);
- if(GetMediaState() == State_Paused)
- {
+ if(GetMediaState() == State_Paused) {
SendMessage(WM_COMMAND, ID_PLAY_PLAY);
}
}
- }
- else
- {
+ } else {
int NextMediaExist = 0;
- if (s.fNextInDirAfterPlayback)
- {
+ if (s.fNextInDirAfterPlayback) {
NextMediaExist = SearchInDir(true);
}
- if (!s.fNextInDirAfterPlayback || !(NextMediaExist>1))
- {
- if(s.fRewind)
+ if (!s.fNextInDirAfterPlayback || !(NextMediaExist>1)) {
+ if(s.fRewind) {
SendMessage(WM_COMMAND, ID_PLAY_STOP);
- else
- {
+ } else {
m_fEndOfStream = true;
SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
}
m_OSD.ClearMessage();
- if(m_fFullScreen && s.fExitFullScreenAtTheEnd)
+ if(m_fFullScreen && s.fExitFullScreenAtTheEnd) {
OnViewFullscreen();
+ }
}
- if (s.fNextInDirAfterPlayback && !NextMediaExist)
- {
+ if (s.fNextInDirAfterPlayback && !NextMediaExist) {
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())
+ } else if(m_wndPlaylistBar.GetCount() > 1) {
+ if(m_wndPlaylistBar.IsAtEnd()) {
+ if(DoAfterPlaybackEvent()) {
return false;
+ }
m_nLoops++;
}
- if(s.fLoopForever || m_nLoops < s.nLoops)
- {
+ if(s.fLoopForever || m_nLoops < s.nLoops) {
int nLoops = m_nLoops;
PostMessage(WM_COMMAND, ID_NAVIGATE_SKIPFORWARD);
m_nLoops = nLoops;
- }
- else
- {
- if(m_fFullScreen && s.fExitFullScreenAtTheEnd)
+ } else {
+ if(m_fFullScreen && s.fExitFullScreenAtTheEnd) {
OnViewFullscreen();
+ }
- if(s.fRewind)
- {
+ if(s.fRewind) {
s.nCLSwitches |= CLSW_OPEN; // HACK
PostMessage(WM_COMMAND, ID_NAVIGATE_SKIPFORWARD);
- }
- else
- {
+ } else {
m_fEndOfStream = true;
PostMessage(WM_COMMAND, ID_PLAY_PAUSE);
}
@@ -2395,371 +2317,361 @@ LRESULT CMainFrame::OnGraphNotify(WPARAM wParam, LPARAM lParam)
LONG evCode;
LONG_PTR evParam1, evParam2;
- while(pME && SUCCEEDED(pME->GetEvent(&evCode, &evParam1, &evParam2, 0)))
- {
+ 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));
#endif
CString str;
- if(m_fCustomGraph)
- {
- if(EC_BG_ERROR == evCode)
- {
+ if(m_fCustomGraph) {
+ if(EC_BG_ERROR == evCode) {
str = CString((char*)evParam1);
}
}
- if (!m_fFrameSteppingActive) m_nStepForwardCount = 0;
+ 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);
+ 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;
+ 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(GetPlaybackMode() == PM_FILE) {
+ SetupChapters();
+ } else if(GetPlaybackMode() == PM_DVD) {
+ m_iDVDTitle = (DWORD)evParam1;
- if(m_iDVDDomain == DVD_DOMAIN_Title)
- {
- CString Domain;
- Domain.Format(ResStr(IDS_AG_TITLE), m_iDVDTitle);
- m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_DOMAIN), Domain);
+ if(m_iDVDDomain == DVD_DOMAIN_Title) {
+ CString Domain;
+ Domain.Format(ResStr(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;
+ break;
+ case EC_DVD_DOMAIN_CHANGE: {
+ m_iDVDDomain = (DVD_DOMAIN)evParam1;
- Domain = _T("First Play");
+ CString Domain('-');
- if ( s.fShowDebugInfo )
- m_OSD.DebugMessage(_T("%s"), Domain);
+ switch(m_iDVDDomain) {
+ case DVD_DOMAIN_FirstPlay:
+ ULONGLONG llDVDGuid;
- if (pDVDI && SUCCEEDED (pDVDI->GetDiscID (NULL, &llDVDGuid)))
- {
- if ( s.fShowDebugInfo )
- m_OSD.DebugMessage(_T("DVD Title: %d"), s.lDVDTitle);
+ Domain = _T("First Play");
- 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.fShowDebugInfo ) {
+ m_OSD.DebugMessage(_T("%s"), Domain);
}
- 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);
+ if (pDVDI && SUCCEEDED (pDVDI->GetDiscID (NULL, &llDVDGuid))) {
+ if ( s.fShowDebugInfo ) {
+ m_OSD.DebugMessage(_T("DVD Title: %d"), s.lDVDTitle);
}
- 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);
+ 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);
}
- } // 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);
- }
+ 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.NewDvd (llDVDGuid) && s.fRememberDVDPos)
- {
- // Set last remembered position (if founded...)
- DVD_POSITION* DvdPos = s.CurrentDVDPosition();
+ m_iDVDTitle = s.lDVDTitle;
+ s.lDVDTitle = 0;
+ s.lDVDChapter = 0;
+ } else if (!s.NewDvd (llDVDGuid) && s.fRememberDVDPos) {
+ // 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);
+ 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;
+ {
+ m_iDVDTitle = DvdPos->lTitle;
+ }
+ }
}
- }
+ 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(ResStr(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 = ResStr(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;
}
- 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(ResStr(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 = ResStr(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);
+ 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 );
+ 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;
+ 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);
+ }
- REFERENCE_TIME rtDur = 0;
+ g_bNoDuration = rtDur <= 0;
+ m_wndSeekBar.Enable(rtDur > 0);
+ m_wndSeekBar.SetRange(0, rtDur);
+ m_OSD.SetRange (0, rtDur);
+ m_Lcd.SetMediaRange(0, rtDur);
- DVD_HMSF_TIMECODE tcDur;
- ULONG ulFlags;
- if(SUCCEEDED(pDVDI->GetTotalTitleTime(&tcDur, &ulFlags)))
- rtDur = HMSF2RT(tcDur, fps);
+ REFERENCE_TIME rtNow = HMSF2RT(*((DVD_HMSF_TIMECODE*)&evParam1), 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);
+ // Casimir666 : Save current position in the chapter
+ DVD_POSITION* DvdPos = s.CurrentDVDPosition();
+ if (DvdPos) {
+ memcpy (&DvdPos->Timecode, (void*)&evParam1, sizeof(DVD_HMSF_TIMECODE));
+ }
- REFERENCE_TIME rtNow = HMSF2RT(*((DVD_HMSF_TIMECODE*)&evParam1), fps);
+ m_wndSeekBar.SetPos(rtNow);
+ m_OSD.SetPos(rtNow);
+ m_Lcd.SetMediaPos(rtNow);
- // Casimir666 : Save current position in the chapter
- DVD_POSITION* DvdPos = s.CurrentDVDPosition();
- if (DvdPos)
- memcpy (&DvdPos->Timecode, (void*)&evParam1, sizeof(DVD_HMSF_TIMECODE));
+ if(m_pSubClock) {
+ m_pSubClock->SetTime(rtNow);
+ }
+ }
+ break;
+ case EC_DVD_ERROR: {
+ TRACE(_T("\t%d %d\n"), evParam1, evParam2);
- m_wndSeekBar.SetPos(rtNow);
- m_OSD.SetPos(rtNow);
- m_Lcd.SetMediaPos(rtNow);
+ CString err;
- if(m_pSubClock) m_pSubClock->SetTime(rtNow);
- }
- break;
- case EC_DVD_ERROR:
- {
- TRACE(_T("\t%d %d\n"), evParam1, evParam2);
+ switch(evParam1) {
+ case DVD_ERROR_Unexpected:
+ default:
+ err = ResStr(IDS_MAINFRM_16);
+ break;
+ case DVD_ERROR_CopyProtectFail:
+ err = ResStr(IDS_MAINFRM_17);
+ break;
+ case DVD_ERROR_InvalidDVD1_0Disc:
+ err = ResStr(IDS_MAINFRM_18);
+ break;
+ case DVD_ERROR_InvalidDiscRegion:
+ err = ResStr(IDS_MAINFRM_19);
+ break;
+ case DVD_ERROR_LowParentalLevel:
+ err = ResStr(IDS_MAINFRM_20);
+ break;
+ case DVD_ERROR_MacrovisionFail:
+ err = ResStr(IDS_MAINFRM_21);
+ break;
+ case DVD_ERROR_IncompatibleSystemAndDecoderRegions:
+ err = ResStr(IDS_MAINFRM_22);
+ break;
+ case DVD_ERROR_IncompatibleDiscAndDecoderRegions:
+ err = ResStr(IDS_MAINFRM_23);
+ break;
+ }
- CString err;
+ SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
- switch(evParam1)
- {
- case DVD_ERROR_Unexpected:
- default:
- err = ResStr(IDS_MAINFRM_16);
- break;
- case DVD_ERROR_CopyProtectFail:
- err = ResStr(IDS_MAINFRM_17);
- break;
- case DVD_ERROR_InvalidDVD1_0Disc:
- err = ResStr(IDS_MAINFRM_18);
- break;
- case DVD_ERROR_InvalidDiscRegion:
- err = ResStr(IDS_MAINFRM_19);
- break;
- case DVD_ERROR_LowParentalLevel:
- err = ResStr(IDS_MAINFRM_20);
- break;
- case DVD_ERROR_MacrovisionFail:
- err = ResStr(IDS_MAINFRM_21);
- break;
- case DVD_ERROR_IncompatibleSystemAndDecoderRegions:
- err = ResStr(IDS_MAINFRM_22);
- break;
- case DVD_ERROR_IncompatibleDiscAndDecoderRegions:
- err = ResStr(IDS_MAINFRM_23);
- break;
+ m_closingmsg = err;
}
-
- SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
-
- m_closingmsg = 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(evParam1));
+ 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(evParam1));
- WINDOWPLACEMENT wp;
- wp.length = sizeof(wp);
- GetWindowPlacement(&wp);
+ WINDOWPLACEMENT wp;
+ wp.length = sizeof(wp);
+ GetWindowPlacement(&wp);
- CSize size(evParam1);
- m_fAudioOnly = (size.cx <= 0 || size.cy <= 0);
+ CSize size(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:
- {
- __int64 rtDur = 0;
- pMS->GetDuration(&rtDur);
- m_wndPlaylistBar.SetCurTime(rtDur);
- }
- break;
- case EC_BG_AUDIO_CHANGED:
- if(m_fCustomGraph)
- {
- int nAudioChannels = evParam1;
-
- m_wndStatusBar.SetStatusBitmap(nAudioChannels == 1 ? IDB_MONO
- : nAudioChannels >= 2 ? IDB_STEREO
- : IDB_NOAUDIO);
+ if(s.fRememberZoomLevel
+ && !(m_fFullScreen || wp.showCmd == SW_SHOWMAXIMIZED || wp.showCmd == SW_SHOWMINIMIZED)) {
+ ZoomVideoWindow();
+ } else {
+ MoveVideoWindow();
+ }
}
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;
+ case EC_LENGTH_CHANGED: {
+ __int64 rtDur = 0;
+ pMS->GetDuration(&rtDur);
+ m_wndPlaylistBar.SetCurTime(rtDur);
}
break;
- case EC_DVD_PLAYBACK_RATE_CHANGE:
- if(m_fCustomGraph && s.AutoChangeFullscrRes.bEnabled &&
- m_fFullScreen && m_iDVDDomain == DVD_DOMAIN_Title)
- AutoChangeMonitorMode();
- break;
+ case EC_BG_AUDIO_CHANGED:
+ if(m_fCustomGraph) {
+ int nAudioChannels = 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;
}
}
@@ -2770,19 +2682,22 @@ LRESULT CMainFrame::OnResetDevice( WPARAM wParam, LPARAM lParam )
{
OAFilterState fs = State_Stopped;
pMC->GetState(0, &fs);
- if(fs == State_Running) pMC->Pause();
+ if(fs == State_Running) {
+ pMC->Pause();
+ }
BOOL bResult = false;
- if (m_bOpenedThruThread)
- {
+ if (m_bOpenedThruThread) {
CAMEvent e;
m_pGraphThread->PostThreadMessage(CGraphThread::TM_RESET, (WPARAM)&bResult, (LPARAM)&e);
e.Wait();
- }
- else
+ } else {
ResetDevice();
+ }
- if(fs == State_Running) pMC->Run();
+ if(fs == State_Running) {
+ pMC->Run();
+ }
return S_OK;
}
@@ -2796,22 +2711,17 @@ LRESULT CMainFrame::OnResumeFromState(WPARAM wParam, LPARAM lParam)
{
int iPlaybackMode = (int)wParam;
- if(iPlaybackMode == PM_FILE)
- {
+ if(iPlaybackMode == PM_FILE) {
SeekTo(10000i64*int(lParam));
- }
- else if(iPlaybackMode == PM_DVD)
- {
+ } 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)
- {
+ if(pDVDC) {
+ pDVDC->SetState(pDvdState, DVD_CMD_FLAG_Block, NULL);
+ }
+ } else if(iPlaybackMode == PM_CAPTURE) {
// not implemented
- }
- else
- {
+ } else {
ASSERT(0);
return FALSE;
}
@@ -2824,27 +2734,24 @@ BOOL CMainFrame::OnButton(UINT id, UINT nFlags, CPoint point)
SetFocus();
CRect r;
- if (m_pFullscreenWnd->IsWindow())
- {
+ if (m_pFullscreenWnd->IsWindow()) {
m_pFullscreenWnd->GetClientRect(r);
- }
- else
- {
+ } 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;
AppSettings& s = AfxGetAppSettings();
POSITION pos = s.wmcmds.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
wmcmd& wc = s.wmcmds.GetNext(pos);
- if(wc.mouse == id)
- {
+ if(wc.mouse == id) {
SendMessage(WM_COMMAND, wc.cmd);
ret = true;
}
@@ -2857,40 +2764,37 @@ static bool s_fLDown = false;
void CMainFrame::OnLButtonDown(UINT nFlags, CPoint point)
{
- if (!m_pFullscreenWnd->IsWindow() || !m_OSD.OnLButtonDown (nFlags, point))
- {
+ if (!m_pFullscreenWnd->IsWindow() || !m_OSD.OnLButtonDown (nFlags, point)) {
SetFocus();
bool fClicked = false;
- if(GetPlaybackMode() == PM_DVD)
- {
+ 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)
+ || m_iDVDDomain == DVD_DOMAIN_VideoTitleSetMenu) {
fClicked = true;
+ }
}
- if(!fClicked)
- {
+ if(!fClicked) {
bool fLeftMouseBtnUnassigned = true;
AppSettings& s = AfxGetAppSettings();
POSITION pos = s.wmcmds.GetHeadPosition();
while(pos && fLeftMouseBtnUnassigned)
- if(s.wmcmds.GetNext(pos).mouse == wmcmd::LDOWN)
+ if(s.wmcmds.GetNext(pos).mouse == wmcmd::LDOWN) {
fLeftMouseBtnUnassigned = false;
+ }
- if(!m_fFullScreen && (IsCaptionMenuHidden() || fLeftMouseBtnUnassigned))
- {
+ if(!m_fFullScreen && (IsCaptionMenuHidden() || fLeftMouseBtnUnassigned)) {
PostMessage(WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(point.x, point.y));
- }
- else
- {
+ } else {
s_fLDown = true;
- if(OnButton(wmcmd::LDOWN, nFlags, point))
+ if(OnButton(wmcmd::LDOWN, nFlags, point)) {
return;
+ }
}
}
@@ -2900,61 +2804,67 @@ void CMainFrame::OnLButtonDown(UINT nFlags, CPoint point)
void CMainFrame::OnLButtonUp(UINT nFlags, CPoint point)
{
- if (!m_pFullscreenWnd->IsWindow() || !m_OSD.OnLButtonUp (nFlags, point))
- {
- if(!OnButton(wmcmd::LUP, nFlags, point))
+ if (!m_pFullscreenWnd->IsWindow() || !m_OSD.OnLButtonUp (nFlags, point)) {
+ if(!OnButton(wmcmd::LUP, nFlags, point)) {
__super::OnLButtonUp(nFlags, point);
+ }
}
}
void CMainFrame::OnLButtonDblClk(UINT nFlags, CPoint point)
{
- if(s_fLDown)
- {
+ if(s_fLDown) {
SendMessage(WM_LBUTTONDOWN, nFlags, MAKELPARAM(point.x, point.y));
s_fLDown = false;
}
- if(!OnButton(wmcmd::LDBLCLK, nFlags, point))
+ 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))
+ if(!OnButton(wmcmd::MDOWN, nFlags, point)) {
__super::OnMButtonDown(nFlags, point);
+ }
}
void CMainFrame::OnMButtonUp(UINT nFlags, CPoint point)
{
- if(!OnButton(wmcmd::MUP, 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))
+ if(!OnButton(wmcmd::MDBLCLK, nFlags, point)) {
__super::OnMButtonDblClk(nFlags, point);
+ }
}
void CMainFrame::OnRButtonDown(UINT nFlags, CPoint point)
{
- if(!OnButton(wmcmd::RDOWN, nFlags, point))
+ if(!OnButton(wmcmd::RDOWN, nFlags, point)) {
__super::OnRButtonDown(nFlags, point);
+ }
}
void CMainFrame::OnRButtonUp(UINT nFlags, CPoint point)
{
- if(!OnButton(wmcmd::RUP, nFlags, point))
+ if(!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))
+ if(!OnButton(wmcmd::RDBLCLK, nFlags, point)) {
__super::OnRButtonDblClk(nFlags, point);
+ }
}
LRESULT CMainFrame::OnXButtonDown(WPARAM wParam, LPARAM lParam)
@@ -2995,16 +2905,13 @@ BOOL CMainFrame::OnMouseWheel(UINT nFlags, short zDelta, CPoint point)
void CMainFrame::OnMouseMove(UINT nFlags, CPoint point)
{
// Waffs : ignore mousemoves when entering fullscreen
- if (m_lastMouseMove.x == -1 && m_lastMouseMove.y == -1)
- {
+ 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)
- {
+ if (!m_OSD.OnMouseMove (nFlags, point)) {
+ if(GetPlaybackMode() == PM_DVD) {
CPoint vp = point - m_wndView.GetVideoRect().TopLeft();
pDVDC->SelectAtPosition(vp);
}
@@ -3012,30 +2919,23 @@ void CMainFrame::OnMouseMove(UINT nFlags, CPoint point)
CSize diff = m_lastMouseMove - point;
AppSettings& s = AfxGetAppSettings();
- if (m_pFullscreenWnd->IsWindow() && (abs(diff.cx)+abs(diff.cy)) >= 1)
- {
+ 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))
- {
+ 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)
- {
+ } else if(m_fFullScreen && (abs(diff.cx)+abs(diff.cy)) >= 1) {
int nTimeOut = s.nShowBarsWhenFullScreenTimeOut;
- if(nTimeOut < 0)
- {
+ if(nTimeOut < 0) {
m_fHideCursor = false;
- if(s.fShowBarsWhenFullScreen)
- {
+ if(s.fShowBarsWhenFullScreen) {
ShowControls(s.nCS);
- if (GetPlaybackMode() == PM_CAPTURE && !s.fHideNavigation && s.iDefaultCaptureDevice == 1)
- {
+ if (GetPlaybackMode() == PM_CAPTURE && !s.fHideNavigation && s.iDefaultCaptureDevice == 1) {
m_wndNavigationBar.m_navdlg.UpdateElementList();
m_wndNavigationBar.ShowControls(this, TRUE);
}
@@ -3043,44 +2943,42 @@ void CMainFrame::OnMouseMove(UINT nFlags, CPoint point)
KillTimer(TIMER_FULLSCREENCONTROLBARHIDER);
SetTimer(TIMER_FULLSCREENMOUSEHIDER, 2000, NULL);
- }
- else if(nTimeOut == 0)
- {
+ } else if(nTimeOut == 0) {
CRect r;
GetClientRect(r);
r.top = r.bottom;
POSITION pos = m_bars.GetHeadPosition();
- for(int i = 1; pos; i <<= 1)
- {
+ for(int i = 1; pos; i <<= 1) {
CControlBar* pNext = m_bars.GetNext(pos);
CSize size = pNext->CalcFixedLayout(FALSE, TRUE);
- if(s.nCS&i) r.top -= size.cy;
+ if(s.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))
+ || m_iDVDDomain == DVD_DOMAIN_VideoTitleSetMenu)) {
r.top = r.bottom - 10;
+ }
m_fHideCursor = false;
- if(r.PtInRect(point))
- {
- if(s.fShowBarsWhenFullScreen)
+ if(r.PtInRect(point)) {
+ if(s.fShowBarsWhenFullScreen) {
ShowControls(s.nCS);
- }
- else
- {
- if(s.fShowBarsWhenFullScreen)
+ }
+ } else {
+ if(s.fShowBarsWhenFullScreen) {
ShowControls(CS_NONE, false);
+ }
}
// PM_CAPTURE: Left Navigation panel for switching channels
- if (GetPlaybackMode() == PM_CAPTURE && !s.fHideNavigation && s.iDefaultCaptureDevice == 1)
- {
+ if (GetPlaybackMode() == PM_CAPTURE && !s.fHideNavigation && s.iDefaultCaptureDevice == 1) {
CRect rLeft;
GetClientRect(rLeft);
rLeft.right = rLeft.left;
@@ -3089,28 +2987,24 @@ void CMainFrame::OnMouseMove(UINT nFlags, CPoint point)
m_fHideCursor = false;
- if(rLeft.PtInRect(point))
- {
- if(s.fShowBarsWhenFullScreen)
- {
+ if(rLeft.PtInRect(point)) {
+ if(s.fShowBarsWhenFullScreen) {
m_wndNavigationBar.m_navdlg.UpdateElementList();
m_wndNavigationBar.ShowControls(this, TRUE);
}
- }
- else
- {
- if(s.fShowBarsWhenFullScreen)
+ } else {
+ if(s.fShowBarsWhenFullScreen) {
m_wndNavigationBar.ShowControls(this, FALSE);
+ }
}
}
SetTimer(TIMER_FULLSCREENMOUSEHIDER, 2000, NULL);
- }
- else
- {
+ } else {
m_fHideCursor = false;
- if(s.fShowBarsWhenFullScreen)
+ if(s.fShowBarsWhenFullScreen) {
ShowControls(s.nCS);
+ }
SetTimer(TIMER_FULLSCREENCONTROLBARHIDER, nTimeOut*1000, NULL);
SetTimer(TIMER_FULLSCREENMOUSEHIDER, max(nTimeOut*1000, 2000), NULL);
@@ -3131,16 +3025,11 @@ LRESULT CMainFrame::OnNcHitTest(CPoint point)
void CMainFrame::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
- if(pScrollBar->IsKindOf(RUNTIME_CLASS(CVolumeCtrl)))
- {
+ if(pScrollBar->IsKindOf(RUNTIME_CLASS(CVolumeCtrl))) {
OnPlayVolume(0);
- }
- else if(pScrollBar->IsKindOf(RUNTIME_CLASS(CPlayerSeekBar)) && m_iMediaLoadState == MLS_LOADED)
- {
+ } else if(pScrollBar->IsKindOf(RUNTIME_CLASS(CPlayerSeekBar)) && m_iMediaLoadState == MLS_LOADED) {
SeekTo(m_wndSeekBar.GetPos(), !!(::GetKeyState(VK_SHIFT)&0x8000));
- }
- else if (m_pVideoWnd == m_pVideoWnd)
- {
+ } else if (m_pVideoWnd == m_pVideoWnd) {
SeekTo(m_OSD.GetPos(), !!(::GetKeyState(VK_SHIFT)&0x8000));
}
@@ -3154,26 +3043,22 @@ void CMainFrame::OnInitMenu(CMenu* pMenu)
MENUITEMINFO mii;
mii.cbSize = sizeof(mii);
- for(UINT i = 0, j = pMenu->GetMenuItemCount(); i < j; i++)
- {
+ for(UINT i = 0, j = pMenu->GetMenuItemCount(); i < j; i++) {
CString str;
pMenu->GetMenuString(i, str, MF_BYPOSITION);
CMenu* pSubMenu = NULL;
- if(str == ResStr(IDS_FAVORITES_POPUP))
- {
+ if(str == ResStr(IDS_FAVORITES_POPUP)) {
SetupFavoritesSubMenu();
pSubMenu = &m_favorites;
}
- if(str == ResStr(IDS_RECENT_FILES_POPUP))
- {
+ if(str == ResStr(IDS_RECENT_FILES_POPUP)) {
SetupRecentFilesSubMenu();
pSubMenu = &m_recentfiles;
}
- if(pSubMenu)
- {
+ if(pSubMenu) {
mii.fMask = MIIM_STATE|MIIM_SUBMENU;
mii.fType = MF_POPUP;
mii.hSubMenu = pSubMenu->m_hMenu;
@@ -3212,8 +3097,7 @@ void CMainFrame::OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu)
MENUITEMINFO mii;
mii.cbSize = sizeof(mii);
- for(UINT i = 0, j = pPopupMenu->GetMenuItemCount(); i < j; i++)
- {
+ for(UINT i = 0, j = pPopupMenu->GetMenuItemCount(); i < j; i++) {
CString str;
pPopupMenu->GetMenuString(i, str, MF_BYPOSITION);
@@ -3223,8 +3107,7 @@ void CMainFrame::OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu)
CMenu* pSubMenu = NULL;
UINT id;
- if(transl.Lookup(lookupstr, id))
- {
+ if(transl.Lookup(lookupstr, id)) {
str = ResStr(id);
// pPopupMenu->ModifyMenu(i, MF_BYPOSITION|MF_STRING, 0, str);
MENUITEMINFO mii;
@@ -3234,84 +3117,58 @@ void CMainFrame::OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu)
pPopupMenu->SetMenuItemInfo(i, &mii, TRUE);
}
- if(str == ResStr(IDS_NAVIGATE_POPUP))
- {
+ if(str == ResStr(IDS_NAVIGATE_POPUP)) {
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);
- }
- else if(str == ResStr(IDS_VIDEOFRAME_POPUP)
- || str == ResStr(IDS_PANSCAN_POPUP)
- || str == ResStr(IDS_ASPECTRATIO_POPUP)
- || str == ResStr(IDS_ZOOM_POPUP))
- {
+ } else if(str == ResStr(IDS_VIDEOFRAME_POPUP)
+ || str == ResStr(IDS_PANSCAN_POPUP)
+ || str == ResStr(IDS_ASPECTRATIO_POPUP)
+ || str == ResStr(IDS_ZOOM_POPUP)) {
UINT fState = (m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly)
? MF_ENABLED
: (MF_DISABLED|MF_GRAYED);
pPopupMenu->EnableMenuItem(i, MF_BYPOSITION|fState);
- }
- else if(str == ResStr(IDS_OPENCDROM_POPUP))
- {
+ } else if(str == ResStr(IDS_OPENCDROM_POPUP)) {
SetupOpenCDSubMenu();
pSubMenu = &m_opencds;
- }
- else if(str == ResStr(IDS_FILTERS_POPUP))
- {
+ } else if(str == ResStr(IDS_FILTERS_POPUP)) {
SetupFiltersSubMenu();
pSubMenu = &m_filters;
- }
- else if(str == ResStr(IDS_AUDIO_POPUP))
- {
+ } else if(str == ResStr(IDS_AUDIO_POPUP)) {
SetupAudioSwitcherSubMenu();
pSubMenu = &m_audios;
- }
- else if(str == ResStr(IDS_SUBTITLES_POPUP))
- {
+ } else if(str == ResStr(IDS_SUBTITLES_POPUP)) {
SetupSubtitlesSubMenu();
pSubMenu = &m_subtitles;
- }
- else if(str == ResStr(IDS_AUDIOLANGUAGE_POPUP))
- {
+ } else if(str == ResStr(IDS_AUDIOLANGUAGE_POPUP)) {
SetupNavAudioSubMenu();
pSubMenu = &m_navaudio;
- }
- else if(str == ResStr(IDS_SUBTITLELANGUAGE_POPUP))
- {
+ } else if(str == ResStr(IDS_SUBTITLELANGUAGE_POPUP)) {
SetupNavSubtitleSubMenu();
pSubMenu = &m_navsubtitle;
- }
- else if(str == ResStr(IDS_VIDEOANGLE_POPUP))
- {
+ } else if(str == ResStr(IDS_VIDEOANGLE_POPUP)) {
SetupNavAngleSubMenu();
pSubMenu = &m_navangle;
- }
- else if(str == ResStr(IDS_JUMPTO_POPUP))
- {
+ } else if(str == ResStr(IDS_JUMPTO_POPUP)) {
SetupNavChaptersSubMenu();
pSubMenu = &m_navchapters;
- }
- else if(str == ResStr(IDS_FAVORITES_POPUP))
- {
+ } else if(str == ResStr(IDS_FAVORITES_POPUP)) {
SetupFavoritesSubMenu();
pSubMenu = &m_favorites;
- }
- else if(str == ResStr(IDS_RECENT_FILES_POPUP))
- {
+ } else if(str == ResStr(IDS_RECENT_FILES_POPUP)) {
SetupRecentFilesSubMenu();
pSubMenu = &m_recentfiles;
- }
- else if(str == ResStr(IDS_SHADER_POPUP))
- {
+ } else if(str == ResStr(IDS_SHADER_POPUP)) {
SetupShadersSubMenu();
pSubMenu = &m_shaders;
}
- if(pSubMenu)
- {
+ if(pSubMenu) {
mii.fMask = MIIM_STATE|MIIM_SUBMENU;
mii.fType = MF_POPUP;
mii.hSubMenu = pSubMenu->m_hMenu;
@@ -3322,27 +3179,33 @@ void CMainFrame::OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu)
//
- for(UINT i = 0, j = pPopupMenu->GetMenuItemCount(); i < j; i++)
- {
+ for(UINT i = 0, j = pPopupMenu->GetMenuItemCount(); i < j; 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)
+ || 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);
+ if(k > 0) {
+ str = str.Left(k);
+ }
CString key = CPPageAccelTbl::MakeAccelShortcutLabel(nID);
- if(!key.IsEmpty()) str += _T("\t") + key;
+ if(!key.IsEmpty()) {
+ str += _T("\t") + key;
+ }
- if(key.IsEmpty() && i < 0) continue;
+ if(key.IsEmpty() && i < 0) {
+ continue;
+ }
// BUG(?): this disables menu item update ui calls for some reason...
-// pPopupMenu->ModifyMenu(i, MF_BYPOSITION|MF_STRING, nID, str);
+ // pPopupMenu->ModifyMenu(i, MF_BYPOSITION|MF_STRING, nID, str);
// this works fine
MENUITEMINFO mii;
@@ -3357,40 +3220,33 @@ void CMainFrame::OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu)
bool fPnSPresets = false;
- for(UINT i = 0, j = pPopupMenu->GetMenuItemCount(); i < j; i++)
- {
+ for(UINT i = 0, j = pPopupMenu->GetMenuItemCount(); i < j; i++) {
UINT nID = pPopupMenu->GetMenuItemID(i);
- if(nID >= ID_PANNSCAN_PRESETS_START && nID < ID_PANNSCAN_PRESETS_END)
- {
- do
- {
+ if(nID >= ID_PANNSCAN_PRESETS_START && nID < ID_PANNSCAN_PRESETS_END) {
+ do {
nID = pPopupMenu->GetMenuItemID(i);
pPopupMenu->DeleteMenu(i, MF_BYPOSITION);
j--;
- }
- while(i < j && nID >= ID_PANNSCAN_PRESETS_START && nID < ID_PANNSCAN_PRESETS_END);
+ } while(i < j && nID >= ID_PANNSCAN_PRESETS_START && nID < ID_PANNSCAN_PRESETS_END);
nID = pPopupMenu->GetMenuItemID(i);
}
- if(nID == ID_VIEW_RESET)
- {
+ if(nID == ID_VIEW_RESET) {
fPnSPresets = true;
}
}
- if(fPnSPresets)
- {
+ if(fPnSPresets) {
AppSettings& s = AfxGetAppSettings();
int i = 0, j = s.m_pnspresets.GetCount();
- for(; i < j; i++)
- {
+ 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)
+ // 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);
@@ -3400,11 +3256,14 @@ void CMainFrame::OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu)
BOOL CMainFrame::OnMenu(CMenu* pMenu)
{
- if(!pMenu) return 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)
+ if (IsD3DFullScreenMode() && s.iDSVideoRendererType == VIDRNDT_DS_SYNC) {
return FALSE;
+ }
KillTimer(TIMER_FULLSCREENMOUSEHIDER);
m_fHideCursor = false;
@@ -3418,12 +3277,9 @@ BOOL CMainFrame::OnMenu(CMenu* pMenu)
void CMainFrame::OnMenuPlayerShort()
{
- if(IsCaptionMenuHidden() || m_pFullscreenWnd->IsWindow())
- {
+ if(IsCaptionMenuHidden() || m_pFullscreenWnd->IsWindow()) {
OnMenu(m_popupmain.GetSubMenu(0));
- }
- else
- {
+ } else {
OnMenu(m_popup.GetSubMenu(0));
}
}
@@ -3441,32 +3297,26 @@ void CMainFrame::OnMenuFilters()
void CMainFrame::OnUpdatePlayerStatus(CCmdUI* pCmdUI)
{
- if(m_iMediaLoadState == MLS_LOADING)
- {
+ 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)
- {
+ if((AfxGetAppSettings().fUseWin7TaskBar) && (m_pTaskbarList)) {
+ m_pTaskbarList->SetProgressState(m_hWnd, TBPF_INDETERMINATE);
+ }
+ } else if(m_iMediaLoadState == MLS_LOADED) {
CString msg;
- if(!m_playingmsg.IsEmpty())
- {
+ if(!m_playingmsg.IsEmpty()) {
msg = m_playingmsg;
- }
- else if(m_fCapturing)
- {
+ } else if(m_fCapturing) {
msg = ResStr(IDS_CONTROLS_CAPTURING);
- if(pAMDF)
- {
+ if(pAMDF) {
long lDropped = 0;
pAMDF->GetNumDropped(&lDropped);
long lNotDropped = 0;
pAMDF->GetNumNotDropped(&lNotDropped);
- if((lDropped + lNotDropped) > 0)
- {
+ if((lDropped + lNotDropped) > 0) {
CString str;
str.Format(ResStr(IDS_MAINFRM_37), lDropped + lNotDropped, lDropped);
msg += str;
@@ -3474,24 +3324,22 @@ void CMainFrame::OnUpdatePlayerStatus(CCmdUI* pCmdUI)
}
CComPtr<IPin> pPin;
- if(SUCCEEDED(pCGB->FindPin(m_wndCaptureBar.m_capdlg.m_pDst, PINDIR_INPUT, NULL, NULL, FALSE, 0, &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)
- {
+ 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)
- {
+ if(h != INVALID_HANDLE_VALUE) {
size = ((LONGLONG)findFileData.nFileSizeHigh << 32) | findFileData.nFileSizeLow;
CString str;
- if(size < 1024i64*1024)
+ if(size < 1024i64*1024) {
str.Format(ResStr(IDS_MAINFRM_38), size/1024);
- else //if(size < 1024i64*1024*1024)
+ } else { //if(size < 1024i64*1024*1024)
str.Format(ResStr(IDS_MAINFRM_39), size/1024/1024);
+ }
msg += str;
FindClose(h);
@@ -3501,52 +3349,47 @@ void CMainFrame::OnUpdatePlayerStatus(CCmdUI* pCmdUI)
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))
- {
+ &FreeBytesAvailable, &TotalNumberOfBytes, &TotalNumberOfFreeBytes)) {
CString str;
- if(FreeBytesAvailable.QuadPart < 1024i64*1024)
+ if(FreeBytesAvailable.QuadPart < 1024i64*1024) {
str.Format(ResStr(IDS_MAINFRM_40), FreeBytesAvailable.QuadPart/1024);
- else //if(FreeBytesAvailable.QuadPart < 1024i64*1024*1024)
+ } else { //if(FreeBytesAvailable.QuadPart < 1024i64*1024*1024)
str.Format(ResStr(IDS_MAINFRM_41), FreeBytesAvailable.QuadPart/1024/1024);
+ }
msg += str;
}
- if(m_wndCaptureBar.m_capdlg.m_pMux)
- {
+ 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)
- {
+ if(pMuxMS && SUCCEEDED(pMuxMS->GetCurrentPosition(&pos)) && pos > 0) {
double bytepersec = 10000000.0 * size / pos;
- if(bytepersec > 0)
+ 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)
- {
+ || m_wndCaptureBar.m_capdlg.m_pAudBuffer) {
int nFreeVidBuffers = 0, nFreeAudBuffers = 0;
- if(CComQIPtr<IBufferFilter> pVB = m_wndCaptureBar.m_capdlg.m_pVidBuffer)
+ if(CComQIPtr<IBufferFilter> pVB = m_wndCaptureBar.m_capdlg.m_pVidBuffer) {
nFreeVidBuffers = pVB->GetFreeBuffers();
- if(CComQIPtr<IBufferFilter> pAB = m_wndCaptureBar.m_capdlg.m_pAudBuffer)
+ }
+ if(CComQIPtr<IBufferFilter> pAB = m_wndCaptureBar.m_capdlg.m_pAudBuffer) {
nFreeAudBuffers = pAB->GetFreeBuffers();
+ }
CString str;
str.Format(ResStr(IDS_MAINFRM_42), nFreeVidBuffers, nFreeAudBuffers);
msg += str;
}
}
- }
- else if(m_fBuffering)
- {
- BeginEnumFilters(pGB, pEF, pBF)
- {
- if(CComQIPtr<IAMNetworkStatus, &IID_IAMNetworkStatus> pAMNS = pBF)
- {
+ } 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)
- {
+ if(SUCCEEDED(pAMNS->get_BufferingProgress(&BufferingProgress)) && BufferingProgress > 0) {
msg.Format(ResStr(IDS_CONTROLS_BUFFERING), BufferingProgress);
__int64 start = 0, stop = 0;
@@ -3557,15 +3400,15 @@ void CMainFrame::OnUpdatePlayerStatus(CCmdUI* pCmdUI)
}
}
EndEnumFilters;
- }
- else if(pAMOP)
- {
+ } else if(pAMOP) {
__int64 t = 0, c = 0;
- if(SUCCEEDED(pAMOP->QueryProgress(&t, &c)) && t > 0 && c < t)
+ if(SUCCEEDED(pAMOP->QueryProgress(&t, &c)) && t > 0 && c < t) {
msg.Format(ResStr(IDS_CONTROLS_BUFFERING), c*100/t);
+ }
- if(m_fUpdateInfoBar)
+ if(m_fUpdateInfoBar) {
OpenSetupInfoBar();
+ }
}
OAFilterState fs = GetMediaState();
@@ -3575,21 +3418,19 @@ void CMainFrame::OnUpdatePlayerStatus(CCmdUI* pCmdUI)
(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_PLAYING)))
- {
+ if((!m_fAudioOnly) && (UI_Text == ResStr(IDS_CONTROLS_PLAYING))) {
CString DXVA_Text = GetDXVADecoderDescription();
- if(!(_T("Not using DXVA")==DXVA_Text) || (_T("Unknown")==DXVA_Text))
+ 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)
- {
+ } 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
- {
+ if((AfxGetAppSettings().fUseWin7TaskBar) && (m_pTaskbarList)) {
+ m_pTaskbarList->SetProgressState(m_hWnd, TBPF_INDETERMINATE);
+ }
+ } else {
pCmdUI->SetText(m_closingmsg);
}
}
@@ -3610,16 +3451,17 @@ void CMainFrame::OnFilePostOpenmedia()
pMS->GetDuration(&rtDur);
m_wndPlaylistBar.SetCurTime(rtDur);
- if(GetPlaybackMode() == PM_CAPTURE)
- {
+ if(GetPlaybackMode() == PM_CAPTURE) {
ShowControlBar(&m_wndSubresyncBar, FALSE, TRUE);
-// ShowControlBar(&m_wndPlaylistBar, FALSE, TRUE);
-// ShowControlBar(&m_wndCaptureBar, TRUE, TRUE);
+ // ShowControlBar(&m_wndPlaylistBar, FALSE, TRUE);
+ // ShowControlBar(&m_wndCaptureBar, TRUE, TRUE);
}
m_nCurSubtitle = -1;
m_lSubtitleShift = 0;
- if(m_pCAP) m_pCAP->SetSubtitleDelay(0);
+ if(m_pCAP) {
+ m_pCAP->SetSubtitleDelay(0);
+ }
SetLoadState (MLS_LOADED);
AppSettings& s = AfxGetAppSettings();
@@ -3637,8 +3479,7 @@ void CMainFrame::OnFilePostOpenmedia()
// 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)
- {
+ && GetPlaybackMode() == PM_CAPTURE && s.iDSVideoRendererType == VIDRNDT_DS_MADVR) {
ShowWindow(SW_MAXIMIZE);
wp.showCmd = SW_SHOWMAXIMIZED;
}
@@ -3646,21 +3487,20 @@ void CMainFrame::OnFilePostOpenmedia()
// restore magnification
if(IsWindowVisible() && s.fRememberZoomLevel
- && !(m_fFullScreen || wp.showCmd == SW_SHOWMAXIMIZED || wp.showCmd == SW_SHOWMINIMIZED))
- {
+ && !(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++)
- {
+ 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);
+ if(s.strPnSPreset == label) {
+ OnViewPanNScanPresets(i+ID_PANNSCAN_PRESETS_START);
+ }
}
s.strPnSPreset.Empty();
}
@@ -3676,8 +3516,7 @@ void CMainFrame::OnUpdateFilePostOpenmedia(CCmdUI* pCmdUI)
void CMainFrame::OnFilePostClosemedia()
{
- if (IsD3DFullScreenMode())
- {
+ if (IsD3DFullScreenMode()) {
KillTimer(TIMER_FULLSCREENMOUSEHIDER);
KillTimer(TIMER_FULLSCREENCONTROLBARHIDER);
m_fHideCursor = false;
@@ -3690,17 +3529,16 @@ void CMainFrame::OnFilePostClosemedia()
m_wndStatusBar.Clear();
m_wndStatusBar.ShowTimer(false);
- if (AfxGetAppSettings().fEnableEDLEditor)
+ if (AfxGetAppSettings().fEnableEDLEditor) {
m_wndEditListEditor.CloseFile();
+ }
- if(IsWindow(m_wndSubresyncBar.m_hWnd))
- {
+ if(IsWindow(m_wndSubresyncBar.m_hWnd)) {
ShowControlBar(&m_wndSubresyncBar, FALSE, TRUE);
SetSubtitle(NULL);
}
- if(IsWindow(m_wndCaptureBar.m_hWnd))
- {
+ 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>());
@@ -3735,7 +3573,9 @@ void CMainFrame::OnUpdateFilePostClosemedia(CCmdUI* pCmdUI)
void CMainFrame::OnBossKey()
{
SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
- if(m_fFullScreen) SendMessage(WM_COMMAND, ID_VIEW_FULLSCREEN);
+ if(m_fFullScreen) {
+ SendMessage(WM_COMMAND, ID_VIEW_FULLSCREEN);
+ }
SendMessage(WM_SYSCOMMAND, SC_MINIMIZE, -1);
}
@@ -3743,130 +3583,156 @@ void CMainFrame::OnStreamAudio(UINT nID)
{
nID -= ID_STREAM_AUDIO_NEXT;
- if(m_iMediaLoadState != MLS_LOADED) return;
+ 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
+ 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)
- {
+ 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++)
- {
+ 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)))
+ if(FAILED(pSS->Info(i, &pmt, &dwFlags, &lcid, &dwGroup, &pszName, NULL, NULL))) {
return;
+ }
- if(pmt) DeleteMediaType(pmt);
- if(pszName) CoTaskMemFree(pszName);
+ if(pmt) {
+ DeleteMediaType(pmt);
+ }
+ if(pszName) {
+ CoTaskMemFree(pszName);
+ }
- if(dwFlags&(AMSTREAMSELECTINFO_ENABLED|AMSTREAMSELECTINFO_EXCLUSIVE))
- {
+ 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)))
- {
+ if(SUCCEEDED(pSS->Info(stream_index, &pmt, &dwFlags, &lcid, &dwGroup, &pszName, NULL, NULL))) {
CString strMessage = ResStr(IDS_AUDIO_STREAM);
strMessage.Append(pszName);
m_OSD.DisplayMessage (OSD_TOPLEFT, strMessage);
- if(pmt) DeleteMediaType(pmt);
- if(pszName) CoTaskMemFree(pszName);
+ 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);
}
- 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;
+ if(m_iMediaLoadState != MLS_LOADED) {
+ return;
+ }
int cnt = 0;
POSITION pos = m_pSubStreams.GetHeadPosition();
- while(pos) cnt += m_pSubStreams.GetNext(pos)->GetStreamCount();
+ while(pos) {
+ cnt += m_pSubStreams.GetNext(pos)->GetStreamCount();
+ }
- if(cnt > 1)
- {
+ 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);
}
- 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;
+ if(m_iMediaLoadState != MLS_LOADED) {
+ return;
+ }
int cnt = 0;
POSITION pos = m_pSubStreams.GetHeadPosition();
- while(pos) cnt += m_pSubStreams.GetNext(pos)->GetStreamCount();
+ while(pos) {
+ cnt += m_pSubStreams.GetNext(pos)->GetStreamCount();
+ }
- if(cnt > 0)
- {
- if (m_iSubtitleSel == -1)
+ if(cnt > 0) {
+ if (m_iSubtitleSel == -1) {
m_iSubtitleSel = 0;
- else
+ } else {
m_iSubtitleSel ^= 0x80000000;
+ }
UpdateSubtitle(true);
SetFocus();
AfxGetAppSettings().fEnableSubtitles = !(m_iSubtitleSel & 0x80000000);
- }
- else if(GetPlaybackMode() == PM_DVD)
+ } 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;
+ if(m_iMediaLoadState != MLS_LOADED) {
+ return;
+ }
CComQIPtr<IAMStreamSelect> pSS = FindSourceSelectableFilter();
- if(!pSS) return;
+ if(!pSS) {
+ return;
+ }
CAtlArray<int> snds;
int iSel = -1;
DWORD cStreams = 0;
- if(SUCCEEDED(pSS->Count(&cStreams)) && cStreams > 1)
- {
- for(int i = 0; i < (int)cStreams; i++)
- {
+ 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)))
+ if(FAILED(pSS->Info(i, &pmt, &dwFlags, &lcid, &dwGroup, &pszName, NULL, NULL))) {
return;
+ }
- if(dwGroup == 1)
- {
- if(dwFlags&(AMSTREAMSELECTINFO_ENABLED|AMSTREAMSELECTINFO_EXCLUSIVE))
+ if(dwGroup == 1) {
+ if(dwFlags&(AMSTREAMSELECTINFO_ENABLED|AMSTREAMSELECTINFO_EXCLUSIVE)) {
iSel = snds.GetCount();
+ }
snds.Add(i);
}
- if(pmt) DeleteMediaType(pmt);
- if(pszName) CoTaskMemFree(pszName);
+ if(pmt) {
+ DeleteMediaType(pmt);
+ }
+ if(pszName) {
+ CoTaskMemFree(pszName);
+ }
}
int cnt = snds.GetCount();
- if(cnt > 1 && iSel >= 0)
- {
+ if(cnt > 1 && iSel >= 0) {
int nNewStream = snds[(iSel+(nID==0?1:cnt-1))%cnt];
pSS->Enable(nNewStream, AMSTREAMSELECTENABLE_ENABLE);
@@ -3876,17 +3742,22 @@ void CMainFrame::OnOgmAudio(UINT nID)
DWORD dwGroup = 0;
WCHAR* pszName = NULL;
- if(SUCCEEDED(pSS->Info(nNewStream, &pmt, &dwFlags, &lcid, &dwGroup, &pszName, NULL, 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);
+ if(k>=0) {
+ audio_stream = audio_stream.Right(audio_stream.GetLength() - k - 8);
+ }
strMessage.Format (_T("%s%s"), ResStr(IDS_AUDIO_STREAM), audio_stream);
m_OSD.DisplayMessage (OSD_TOPLEFT, strMessage);
- if(pmt) DeleteMediaType(pmt);
- if(pszName) CoTaskMemFree(pszName);
+ if(pmt) {
+ DeleteMediaType(pmt);
+ }
+ if(pszName) {
+ CoTaskMemFree(pszName);
+ }
}
}
}
@@ -3896,42 +3767,48 @@ void CMainFrame::OnOgmSub(UINT nID)
{
nID -= ID_OGM_SUB_NEXT;
- if(m_iMediaLoadState != MLS_LOADED) return;
+ if(m_iMediaLoadState != MLS_LOADED) {
+ return;
+ }
CComQIPtr<IAMStreamSelect> pSS = FindSourceSelectableFilter();
- if(!pSS) return;
+ if(!pSS) {
+ return;
+ }
CArray<int> subs;
int iSel = -1;
DWORD cStreams = 0;
- if(SUCCEEDED(pSS->Count(&cStreams)) && cStreams > 1)
- {
- for(int i = 0; i < (int)cStreams; i++)
- {
+ 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)))
+ if(FAILED(pSS->Info(i, &pmt, &dwFlags, &lcid, &dwGroup, &pszName, NULL, NULL))) {
return;
+ }
- if(dwGroup == 2)
- {
- if(dwFlags&(AMSTREAMSELECTINFO_ENABLED|AMSTREAMSELECTINFO_EXCLUSIVE))
+ if(dwGroup == 2) {
+ if(dwFlags&(AMSTREAMSELECTINFO_ENABLED|AMSTREAMSELECTINFO_EXCLUSIVE)) {
iSel = subs.GetCount();
+ }
subs.Add(i);
}
- if(pmt) DeleteMediaType(pmt);
- if(pszName) CoTaskMemFree(pszName);
+ if(pmt) {
+ DeleteMediaType(pmt);
+ }
+ if(pszName) {
+ CoTaskMemFree(pszName);
+ }
}
int cnt = subs.GetCount();
- if(cnt > 1 && iSel >= 0)
- {
+ if(cnt > 1 && iSel >= 0) {
int nNewStream = subs[(iSel+(nID==0?1:cnt-1))%cnt];
pSS->Enable(nNewStream, AMSTREAMSELECTENABLE_ENABLE);
@@ -3940,22 +3817,24 @@ void CMainFrame::OnOgmSub(UINT nID)
LCID lcid = 0;
DWORD dwGroup = 0;
WCHAR* pszName = NULL;
- if(SUCCEEDED(pSS->Info(nNewStream, &pmt, &dwFlags, &lcid, &dwGroup, &pszName, NULL, NULL)))
- {
+ if(SUCCEEDED(pSS->Info(nNewStream, &pmt, &dwFlags, &lcid, &dwGroup, &pszName, NULL, NULL))) {
CString lang;
CString strMessage;
- if (lcid == 0)
+ if (lcid == 0) {
lang = pszName;
- else
- {
+ } else {
int len = GetLocaleInfo(lcid, LOCALE_SENGLANGUAGE, lang.GetBuffer(64), 64);
lang.ReleaseBufferSetLength(max(len-1, 0));
}
strMessage.Format (ResStr(IDS_MAINFRM_45), lang, _T(""));
m_OSD.DisplayMessage (OSD_TOPLEFT, strMessage);
- if(pmt) DeleteMediaType(pmt);
- if(pszName) CoTaskMemFree(pszName);
+ if(pmt) {
+ DeleteMediaType(pmt);
+ }
+ if(pszName) {
+ CoTaskMemFree(pszName);
+ }
}
}
}
@@ -3965,16 +3844,19 @@ void CMainFrame::OnDvdAngle(UINT nID)
{
nID -= ID_DVD_ANGLE_NEXT;
- if(m_iMediaLoadState != MLS_LOADED) return;
+ if(m_iMediaLoadState != MLS_LOADED) {
+ return;
+ }
- if(pDVDI && pDVDC)
- {
+ if(pDVDI && pDVDC) {
ULONG ulAnglesAvailable, ulCurrentAngle;
- if(SUCCEEDED(pDVDI->GetCurrentAngle(&ulAnglesAvailable, &ulCurrentAngle)) && ulAnglesAvailable > 1)
- {
+ if(SUCCEEDED(pDVDI->GetCurrentAngle(&ulAnglesAvailable, &ulCurrentAngle)) && ulAnglesAvailable > 1) {
ulCurrentAngle += nID==0 ? 1 : ulAnglesAvailable-1;
- if(ulCurrentAngle > ulAnglesAvailable) ulCurrentAngle = 1;
- else if(ulCurrentAngle < 1) ulCurrentAngle = ulAnglesAvailable;
+ if(ulCurrentAngle > ulAnglesAvailable) {
+ ulCurrentAngle = 1;
+ } else if(ulCurrentAngle < 1) {
+ ulCurrentAngle = ulAnglesAvailable;
+ }
pDVDC->SelectAngle(ulCurrentAngle, DVD_CMD_FLAG_Block, NULL);
}
}
@@ -3985,19 +3867,18 @@ void CMainFrame::OnDvdAudio(UINT nID)
HRESULT hr;
nID -= ID_DVD_AUDIO_NEXT;
- if(m_iMediaLoadState != MLS_LOADED) return;
+ if(m_iMediaLoadState != MLS_LOADED) {
+ return;
+ }
- if(pDVDI && pDVDC)
- {
+ if(pDVDI && pDVDC) {
ULONG nStreamsAvailable, nCurrentStream;
- if(SUCCEEDED(pDVDI->GetCurrentAudio(&nStreamsAvailable, &nCurrentStream)) && nStreamsAvailable > 1)
- {
+ 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)))
- {
+ if (SUCCEEDED(pDVDI->GetAudioAttributes(nNextStream, &AATR))) {
CString lang;
CString strMessage;
int len = GetLocaleInfo(AATR.Language, LOCALE_SENGLANGUAGE, lang.GetBuffer(64), 64);
@@ -4014,36 +3895,33 @@ void CMainFrame::OnDvdSub(UINT nID)
HRESULT hr;
nID -= ID_DVD_SUB_NEXT;
- if(m_iMediaLoadState != MLS_LOADED) return;
+ if(m_iMediaLoadState != MLS_LOADED) {
+ return;
+ }
- if(pDVDI && pDVDC)
- {
+ 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;
+ && ulStreamsAvailable > 1) {
+ // UINT nNextStream = (ulCurrentStream+(nID==0?1:ulStreamsAvailable-1))%ulStreamsAvailable;
int nNextStream;
- if (!bIsDisabled)
+ if (!bIsDisabled) {
nNextStream = ulCurrentStream+ (nID==0?1:-1);
- else
+ } else {
nNextStream = (nID==0?0:ulStreamsAvailable-1);
+ }
- if (!bIsDisabled && ((nNextStream < 0) || (nNextStream >= ulStreamsAvailable)))
- {
+ if (!bIsDisabled && ((nNextStream < 0) || (nNextStream >= ulStreamsAvailable))) {
pDVDC->SetSubpictureState(FALSE, DVD_CMD_FLAG_Block, NULL);
m_OSD.DisplayMessage (OSD_TOPLEFT, ResStr(IDS_MAINFRM_44));
- }
- else
- {
+ } 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)))
- {
+ if(SUCCEEDED(pDVDI->GetSubpictureAttributes(nNextStream, &SATR))) {
CString lang;
CString strMessage;
int len = GetLocaleInfo(SATR.Language, LOCALE_SENGLANGUAGE, lang.GetBuffer(64), 64);
@@ -4058,14 +3936,14 @@ void CMainFrame::OnDvdSub(UINT nID)
void CMainFrame::OnDvdSubOnOff()
{
- if(m_iMediaLoadState != MLS_LOADED) return;
+ if(m_iMediaLoadState != MLS_LOADED) {
+ return;
+ }
- if(pDVDI && pDVDC)
- {
+ if(pDVDI && pDVDC) {
ULONG ulStreamsAvailable, ulCurrentStream;
BOOL bIsDisabled;
- if(SUCCEEDED(pDVDI->GetCurrentSubpicture(&ulStreamsAvailable, &ulCurrentStream, &bIsDisabled)))
- {
+ if(SUCCEEDED(pDVDI->GetCurrentSubpicture(&ulStreamsAvailable, &ulCurrentStream, &bIsDisabled))) {
pDVDC->SetSubpictureState(bIsDisabled, DVD_CMD_FLAG_Block, NULL);
}
}
@@ -4079,7 +3957,9 @@ void CMainFrame::OnDvdSubOnOff()
void CMainFrame::OnFileOpenQuick()
{
- if(m_iMediaLoadState == MLS_LOADING || !IsWindow(m_wndPlaylistBar)) return;
+ if(m_iMediaLoadState == MLS_LOADING || !IsWindow(m_wndPlaylistBar)) {
+ return;
+ }
CString filter;
CAtlArray<CString> mask;
@@ -4087,20 +3967,23 @@ void CMainFrame::OnFileOpenQuick()
COpenFileDlg fd(mask, true, NULL, NULL,
OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_ALLOWMULTISELECT|OFN_ENABLEINCLUDENOTIFY,
filter, GetModalParent());
- if(fd.DoModal() != IDOK) return;
+ if(fd.DoModal() != IDOK) {
+ return;
+ }
CAtlList<CString> fns;
POSITION pos = fd.GetStartPosition();
- while(pos) fns.AddTail(fd.GetNextPathName(pos));
+ while(pos) {
+ fns.AddTail(fd.GetNextPathName(pos));
+ }
bool fMultipleFiles = false;
if(fns.GetCount() > 1
|| fns.GetCount() == 1
&& (fns.GetHead()[fns.GetHead().GetLength()-1] == '\\'
- || fns.GetHead()[fns.GetHead().GetLength()-1] == '*'))
- {
+ || fns.GetHead()[fns.GetHead().GetLength()-1] == '*')) {
fMultipleFiles = true;
}
@@ -4111,8 +3994,7 @@ void CMainFrame::OnFileOpenQuick()
m_wndPlaylistBar.Open(fns, fMultipleFiles);
- if(m_wndPlaylistBar.GetCount() == 1 && m_wndPlaylistBar.IsWindowVisible() && !m_wndPlaylistBar.IsFloating())
- {
+ if(m_wndPlaylistBar.GetCount() == 1 && m_wndPlaylistBar.IsWindowVisible() && !m_wndPlaylistBar.IsFloating()) {
ShowControlBar(&m_wndPlaylistBar, FALSE, TRUE);
}
@@ -4121,29 +4003,30 @@ void CMainFrame::OnFileOpenQuick()
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;
+ }
COpenDlg dlg;
- if(dlg.DoModal() != IDOK || dlg.m_fns.GetCount() == 0) return;
+ if(dlg.DoModal() != IDOK || dlg.m_fns.GetCount() == 0) {
+ return;
+ }
- if(!dlg.m_fAppendPlaylist)
- {
+ if(!dlg.m_fAppendPlaylist) {
SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
}
ShowWindow(SW_SHOW);
SetForegroundWindow();
- if(dlg.m_fAppendPlaylist)
- {
+ if(dlg.m_fAppendPlaylist) {
m_wndPlaylistBar.Append(dlg.m_fns, dlg.m_fMultipleFiles);
return;
}
m_wndPlaylistBar.Open(dlg.m_fns, dlg.m_fMultipleFiles);
- if(m_wndPlaylistBar.GetCount() == 1 && m_wndPlaylistBar.IsWindowVisible() && !m_wndPlaylistBar.IsFloating())
- {
+ if(m_wndPlaylistBar.GetCount() == 1 && m_wndPlaylistBar.IsWindowVisible() && !m_wndPlaylistBar.IsFloating()) {
ShowControlBar(&m_wndPlaylistBar, FALSE, TRUE);
}
@@ -4166,8 +4049,7 @@ BOOL CMainFrame::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCDS)
{
AppSettings& s = AfxGetAppSettings();
- if (s.hMasterWnd)
- {
+ if (s.hMasterWnd) {
ProcessAPICommand(pCDS);
return TRUE;
}
@@ -4177,8 +4059,9 @@ BOOL CMainFrame::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCDS)
return FALSE;
*/
- if(pCDS->dwData != 0x6ABE51 || pCDS->cbData < sizeof(DWORD))
+ if(pCDS->dwData != 0x6ABE51 || pCDS->cbData < sizeof(DWORD)) {
return FALSE;
+ }
DWORD len = *((DWORD*)pCDS->lpData);
TCHAR* pBuff = (TCHAR*)((DWORD*)pCDS->lpData + 1);
@@ -4186,24 +4069,23 @@ BOOL CMainFrame::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCDS)
CAtlList<CString> cmdln;
- while(len-- > 0)
- {
+ while(len-- > 0) {
CString str;
- while(pBuff < pBuffEnd && *pBuff) str += *pBuff++;
+ while(pBuff < pBuffEnd && *pBuff) {
+ str += *pBuff++;
+ }
pBuff++;
cmdln.AddTail(str);
}
s.ParseCommandLine(cmdln);
- if(s.nCLSwitches&CLSW_SLAVE)
- {
+ if(s.nCLSwitches&CLSW_SLAVE) {
SendAPICommand (CMD_CONNECT, L"%d", GetSafeHwnd());
}
POSITION pos = s.slFilters.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CString fullpath = MakeFullPath(s.slFilters.GetNext(pos));
CPath tmp(fullpath);
@@ -4213,42 +4095,36 @@ BOOL CMainFrame::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCDS)
WIN32_FIND_DATA fd = {0};
HANDLE hFind = FindFirstFile(fullpath, &fd);
- if(hFind != INVALID_HANDLE_VALUE)
- {
- do
- {
- if(fd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) continue;
+ 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())
- {
+ 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)
- {
+ while(pos2) {
FilterOverride* f2 = s.m_filters.GetNext(pos2);
- if(f2->type == FilterOverride::EXTERNAL && !f2->path.CompareNoCase(f->path))
- {
+ if(f2->type == FilterOverride::EXTERNAL && !f2->path.CompareNoCase(f->path)) {
fFound = true;
break;
}
}
- if(!fFound)
- {
+ if(!fFound) {
CAutoPtr<FilterOverride> p(f);
s.m_filters.AddHead(p);
}
}
}
- }
- while(FindNextFile(hFind, &fd));
+ } while(FindNextFile(hFind, &fd));
FindClose(hFind);
}
@@ -4256,60 +4132,51 @@ BOOL CMainFrame::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCDS)
bool fSetForegroundWindow = false;
- if((s.nCLSwitches&CLSW_DVD) && !s.slFiles.IsEmpty())
- {
+ if((s.nCLSwitches&CLSW_DVD) && !s.slFiles.IsEmpty()) {
SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
fSetForegroundWindow = true;
CAutoPtr<OpenDVDData> p(DNew OpenDVDData());
- if(p)
- {
+ if(p) {
p->path = s.slFiles.GetHead();
p->subs.AddTailList(&s.slSubs);
}
OpenMedia(p);
- }
- else if(s.nCLSwitches&CLSW_CD)
- {
+ } else if(s.nCLSwitches&CLSW_CD) {
SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
fSetForegroundWindow = true;
CAtlList<CString> sl;
- if(!s.slFiles.IsEmpty())
- {
+ if(!s.slFiles.IsEmpty()) {
GetCDROMType(s.slFiles.GetHead()[0], sl);
- }
- else
- {
+ } 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++)
- {
+ for(TCHAR drive = 'C'; sl.IsEmpty() && drive <= 'Z'; drive++) {
GetCDROMType(drive, sl);
}
}
m_wndPlaylistBar.Open(sl, true);
OpenCurPlaylistItem();
- }
- else if(!s.slFiles.IsEmpty())
- {
+ } else if(!s.slFiles.IsEmpty()) {
bool fMulti = s.slFiles.GetCount() > 1;
CAtlList<CString> sl;
sl.AddTailList(&s.slFiles);
- if(!fMulti) sl.AddTailList(&s.slDubs);
+ if(!fMulti) {
+ sl.AddTailList(&s.slDubs);
+ }
CHdmvClipInfo ClipInfo;
CString strPlaylistFile;
CAtlList<CHdmvClipInfo::PlaylistItem> MainPlaylist;
- if(!fMulti && is_dir(s.slFiles.GetHead() + _T("\\BDMV")) && SUCCEEDED(ClipInfo.FindMainMovie (s.slFiles.GetHead(), strPlaylistFile, MainPlaylist)))
- {
+ if(!fMulti && is_dir(s.slFiles.GetHead() + _T("\\BDMV")) && SUCCEEDED(ClipInfo.FindMainMovie (s.slFiles.GetHead(), strPlaylistFile, MainPlaylist))) {
SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
fSetForegroundWindow = true;
@@ -4317,37 +4184,30 @@ BOOL CMainFrame::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCDS)
CAutoPtr<OpenFileData> p(DNew OpenFileData());
p->fns.AddTail(strPlaylistFile);
OpenMedia(p);
- }
- else if(!fMulti && is_dir(s.slFiles.GetHead() + _T("\\VIDEO_TS")))
- {
+ } else if(!fMulti && is_dir(s.slFiles.GetHead() + _T("\\VIDEO_TS"))) {
SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
fSetForegroundWindow = true;
CAutoPtr<OpenDVDData> p(DNew OpenDVDData());
- if(p)
- {
+ 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;
+ } else {
+ if(last_run && ((GetTickCount()-last_run)<500)) {
+ s.nCLSwitches |= CLSW_ADD;
+ }
last_run = GetTickCount();
- if((s.nCLSwitches&CLSW_ADD) && m_wndPlaylistBar.GetCount() > 0)
- {
+ if((s.nCLSwitches&CLSW_ADD) && m_wndPlaylistBar.GetCount() > 0) {
m_wndPlaylistBar.Append(sl, fMulti, &s.slSubs);
- if(s.nCLSwitches&(CLSW_OPEN|CLSW_PLAY))
- {
+ if(s.nCLSwitches&(CLSW_OPEN|CLSW_PLAY)) {
m_wndPlaylistBar.SetLast();
OpenCurPlaylistItem();
}
- }
- else
- {
+ } else {
SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
fSetForegroundWindow = true;
@@ -4358,14 +4218,13 @@ BOOL CMainFrame::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCDS)
s.rtStart = 0;
}
}
- }
- else
- {
+ } else {
s.nCLSwitches = CLSW_NONE;
}
- if(fSetForegroundWindow && !(s.nCLSwitches&CLSW_NOFOCUS))
+ if(fSetForegroundWindow && !(s.nCLSwitches&CLSW_NOFOCUS)) {
SetForegroundWindow();
+ }
s.nCLSwitches &= ~CLSW_NOFOCUS;
@@ -4374,14 +4233,13 @@ BOOL CMainFrame::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCDS)
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;
+ switch(uMsg) {
+ case BFFM_INITIALIZED:
+ //Initial directory is set here
+ SendMessage(hwnd, BFFM_SETSELECTION, TRUE,(LPARAM)(LPCTSTR)AfxGetAppSettings().strDVDPath);
+ break;
+ default:
+ break;
}
return 0;
}
@@ -4390,7 +4248,9 @@ int CALLBACK BrowseCallbackProc(HWND hwnd,UINT uMsg,LPARAM lp, LPARAM pData)
void CMainFrame::OnFileOpendvd()
{
- if ((m_iMediaLoadState == MLS_LOADING) || m_pFullscreenWnd->IsWindow()) return;
+ if ((m_iMediaLoadState == MLS_LOADING) || m_pFullscreenWnd->IsWindow()) {
+ return;
+ }
/*
SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
@@ -4427,27 +4287,25 @@ void CMainFrame::OnFileOpendvd()
static LPITEMIDLIST iil;
iil = SHBrowseForFolder(&bi);
- if(iil)
- {
+ if(iil) {
CHdmvClipInfo ClipInfo;
CString strPlaylistFile;
CAtlList<CHdmvClipInfo::PlaylistItem> MainPlaylist;
SHGetPathFromIDList(iil, path);
s.strDVDPath = path;
- if (SUCCEEDED (ClipInfo.FindMainMovie (path, strPlaylistFile, MainPlaylist)))
- {
+ if (SUCCEEDED (ClipInfo.FindMainMovie (path, strPlaylistFile, MainPlaylist))) {
m_wndPlaylistBar.Empty();
CAutoPtr<OpenFileData> p(DNew OpenFileData());
p->fns.AddTail(strPlaylistFile);
OpenMedia(p);
- }
- else
- {
+ } else {
CAutoPtr<OpenDVDData> p(DNew OpenDVDData());
p->path = path;
p->path.Replace('/', '\\');
- if(p->path[p->path.GetLength()-1] != '\\') p->path += '\\';
+ if(p->path[p->path.GetLength()-1] != '\\') {
+ p->path += '\\';
+ }
OpenMedia(p);
}
@@ -4458,7 +4316,9 @@ void CMainFrame::OnFileOpendevice()
{
AppSettings& s = AfxGetAppSettings();
- if(m_iMediaLoadState == MLS_LOADING) return;
+ if(m_iMediaLoadState == MLS_LOADING) {
+ return;
+ }
//COpenCapDeviceDlg capdlg;
//if(capdlg.DoModal() != IDOK)
@@ -4472,14 +4332,12 @@ void CMainFrame::OnFileOpendevice()
m_wndPlaylistBar.Empty();
CAutoPtr<OpenDeviceData> p(DNew OpenDeviceData());
- if(p)
- {
+ 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)
- {
+ if (GetPlaybackMode() == PM_CAPTURE && !s.fHideNavigation && m_iMediaLoadState == MLS_LOADED && s.iDefaultCaptureDevice == 1) {
m_wndNavigationBar.m_navdlg.UpdateElementList();
ShowControlBar(&m_wndNavigationBar, !s.fHideNavigation, TRUE);
}
@@ -4490,23 +4348,20 @@ void CMainFrame::OnFileOpenCD(UINT nID)
nID -= ID_FILE_OPEN_CD_START;
nID++;
- for(TCHAR drive = 'C'; drive <= 'Z'; drive++)
- {
+ 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)
- {
+ if(nID == 0) {
SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
SetForegroundWindow();
@@ -4529,8 +4384,7 @@ void CMainFrame::OnDropFiles(HDROP hDropInfo)
{
SetForegroundWindow();
- if(m_wndPlaylistBar.IsWindowVisible())
- {
+ if(m_wndPlaylistBar.IsWindowVisible()) {
m_wndPlaylistBar.OnDropFiles(hDropInfo);
return;
}
@@ -4539,19 +4393,18 @@ void CMainFrame::OnDropFiles(HDROP hDropInfo)
UINT nFiles = ::DragQueryFile(hDropInfo, (UINT)-1, NULL, 0);
- for(UINT iFile = 0; iFile < nFiles; iFile++)
- {
+ for(UINT iFile = 0; iFile < nFiles; iFile++) {
CString fn;
fn.ReleaseBuffer(::DragQueryFile(hDropInfo, iFile, fn.GetBuffer(_MAX_PATH), _MAX_PATH));
sl.AddTail(fn);
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);
}
FindClose(hFind);
@@ -4560,13 +4413,13 @@ void CMainFrame::OnDropFiles(HDROP hDropInfo)
::DragFinish(hDropInfo);
- if(sl.IsEmpty()) return;
+ if(sl.IsEmpty()) {
+ return;
+ }
- if(sl.GetCount() == 1 && m_iMediaLoadState == MLS_LOADED && m_pCAP)
- {
+ if(sl.GetCount() == 1 && m_iMediaLoadState == MLS_LOADED && m_pCAP) {
ISubStream *pSubStream = NULL;
- if(LoadSubtitle(sl.GetHead(), &pSubStream))
- {
+ if(LoadSubtitle(sl.GetHead(), &pSubStream)) {
SetSubtitle(pSubStream); // the subtitle at the insert position according to LoadSubtitle()
CPath p(sl.GetHead());
p.StripPath();
@@ -4583,39 +4436,46 @@ void CMainFrame::OnFileSaveAs()
{
CString ext, in = m_wndPlaylistBar.GetCurFileName(), out = in;
- if(out.Find(_T("://")) < 0)
- {
+ 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
- {
+ 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,
ResStr(IDS_MAINFRM_48), GetModalParent(), 0);
- if(fd.DoModal() != IDOK || !in.CompareNoCase(fd.GetPathName())) return;
+ if(fd.DoModal() != IDOK || !in.CompareNoCase(fd.GetPathName())) {
+ return;
+ }
CPath p(fd.GetPathName());
- if(!ext.IsEmpty()) p.AddExtension(ext);
+ if(!ext.IsEmpty()) {
+ p.AddExtension(ext);
+ }
OAFilterState fs = State_Stopped;
pMC->GetState(0, &fs);
- if(fs == State_Running) pMC->Pause();
+ if(fs == State_Running) {
+ pMC->Pause();
+ }
CSaveDlg dlg(in, p);
dlg.DoModal();
- if(fs == State_Running) pMC->Run();
+ if(fs == State_Running) {
+ pMC->Run();
+ }
}
void CMainFrame::OnUpdateFileSaveAs(CCmdUI* pCmdUI)
{
- if(m_iMediaLoadState != MLS_LOADED || GetPlaybackMode() != PM_FILE)
- {
+ if(m_iMediaLoadState != MLS_LOADED || GetPlaybackMode() != PM_FILE) {
pCmdUI->Enable(FALSE);
return;
}
@@ -4623,14 +4483,12 @@ void CMainFrame::OnUpdateFileSaveAs(CCmdUI* pCmdUI)
CString fn = m_wndPlaylistBar.GetCurFileName();
CString ext = fn.Mid(fn.ReverseFind('.')+1).MakeLower();
- if(fn.Find(_T("://")) >= 0)
- {
+ if(fn.Find(_T("://")) >= 0) {
pCmdUI->Enable(FALSE);
return;
}
- if((GetVersion()&0x80000000) && (ext == _T("cda") || ext == _T("ifo")))
- {
+ if((GetVersion()&0x80000000) && (ext == _T("cda") || ext == _T("ifo"))) {
pCmdUI->Enable(FALSE);
return;
}
@@ -4640,22 +4498,28 @@ void CMainFrame::OnUpdateFileSaveAs(CCmdUI* pCmdUI)
bool CMainFrame::GetDIB(BYTE** ppData, long& size, bool fSilent)
{
- if(!ppData) return false;
+ if(!ppData) {
+ return false;
+ }
*ppData = NULL;
size = 0;
bool fNeedsToPause = !m_pCAP;
- if(fNeedsToPause) fNeedsToPause = !IsVMR7InGraph(pGB);
- if(fNeedsToPause) fNeedsToPause = !IsVMR9InGraph(pGB);
+ if(fNeedsToPause) {
+ fNeedsToPause = !IsVMR7InGraph(pGB);
+ }
+ if(fNeedsToPause) {
+ fNeedsToPause = !IsVMR9InGraph(pGB);
+ }
OAFilterState fs = GetMediaState();
- if(!(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly && (fs == State_Paused || fs == State_Running)))
+ if(!(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly && (fs == State_Paused || fs == State_Running))) {
return false;
+ }
- if(fs == State_Running && fNeedsToPause)
- {
+ if(fs == State_Running && fNeedsToPause) {
pMC->Pause();
GetMediaState(); // wait for completion of the pause command
}
@@ -4663,101 +4527,90 @@ bool CMainFrame::GetDIB(BYTE** ppData, long& size, bool fSilent)
HRESULT hr = S_OK;
CString errmsg;
- do
- {
- if(m_pCAP)
- {
+ do {
+ if(m_pCAP) {
hr = m_pCAP->GetDIB(NULL, (DWORD*)&size);
- if(FAILED(hr))
- {
+ if(FAILED(hr)) {
errmsg.Format(ResStr(IDS_MAINFRM_49), hr);
break;
}
*ppData = DNew BYTE[size];
- if(!(*ppData)) return false;
+ 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))
- {
+ // 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)
- {
+ while(FAILED(hr) && retry < 20) {
hr = m_pCAP->GetDIB(*ppData, (DWORD*)&size);
- if(SUCCEEDED(hr)) break;
+ if(SUCCEEDED(hr)) {
+ break;
+ }
Sleep(1);
retry++;
}
- if(FAILED(hr))
- {
+ if(FAILED(hr)) {
errmsg.Format(ResStr(IDS_MAINFRM_49), hr);
break;
}
}
- }
- else if (m_pMFVDC)
- {
+ } 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)
- {
+ if(FAILED(hr) || dwSize == 0) {
errmsg.Format(ResStr(IDS_MAINFRM_51), hr);
break;
}
size = (long)dwSize+sizeof(BITMAPINFOHEADER);
*ppData = DNew BYTE[size];
- if(!(*ppData)) return false;
+ if(!(*ppData)) {
+ return false;
+ }
memcpy_s (*ppData, size, &bih, sizeof(BITMAPINFOHEADER));
memcpy_s (*ppData+sizeof(BITMAPINFOHEADER), size-sizeof(BITMAPINFOHEADER), pDib, dwSize);
CoTaskMemFree (pDib);
- }
- else
- {
+ } else {
hr = pBV->GetCurrentImage(&size, NULL);
- if(FAILED(hr) || size == 0)
- {
+ if(FAILED(hr) || size == 0) {
errmsg.Format(ResStr(IDS_MAINFRM_51), hr);
break;
}
*ppData = DNew BYTE[size];
- if(!(*ppData)) return false;
+ if(!(*ppData)) {
+ return false;
+ }
hr = pBV->GetCurrentImage(&size, (long*)*ppData);
- if(FAILED(hr))
- {
+ if(FAILED(hr)) {
errmsg.Format(ResStr(IDS_MAINFRM_51), hr);
break;
}
}
- }
- while(0);
+ } while(0);
- if(!fSilent)
- {
- if(!errmsg.IsEmpty())
- {
+ if(!fSilent) {
+ if(!errmsg.IsEmpty()) {
AfxMessageBox(errmsg, MB_OK);
}
}
- if(fs == State_Running && GetMediaState() != State_Running)
- {
+ if(fs == State_Running && GetMediaState() != State_Running) {
pMC->Run();
}
- if(FAILED(hr))
- {
- if(*ppData)
- {
+ if(FAILED(hr)) {
+ if(*ppData) {
ASSERT(0); // huh?
delete [] *ppData;
*ppData = NULL;
@@ -4775,10 +4628,8 @@ void CMainFrame::SaveDIB(LPCTSTR fn, BYTE* pData, long size)
{
CString ext = CString(CPath(fn).GetExtension()).MakeLower();
- if(ext == _T(".bmp"))
- {
- if(FILE* f = _tfopen(fn, _T("wb")))
- {
+ if(ext == _T(".bmp")) {
+ if(FILE* f = _tfopen(fn, _T("wb"))) {
BITMAPINFO* bi = (BITMAPINFO*)pData;
BITMAPFILEHEADER bfh;
@@ -4787,24 +4638,22 @@ void CMainFrame::SaveDIB(LPCTSTR fn, BYTE* pData, long size)
bfh.bfSize = sizeof(bfh) + size;
bfh.bfReserved1 = bfh.bfReserved2 = 0;
- if(bi->bmiHeader.biBitCount <= 8)
- {
- if(bi->bmiHeader.biClrUsed) bfh.bfOffBits += bi->bmiHeader.biClrUsed * sizeof(bi->bmiColors[0]);
- else bfh.bfOffBits += (1 << bi->bmiHeader.biBitCount) * DWORD(sizeof(bi->bmiColors[0]));
+ if(bi->bmiHeader.biBitCount <= 8) {
+ if(bi->bmiHeader.biClrUsed) {
+ bfh.bfOffBits += bi->bmiHeader.biClrUsed * sizeof(bi->bmiColors[0]);
+ } else {
+ bfh.bfOffBits += (1 << bi->bmiHeader.biBitCount) * DWORD(sizeof(bi->bmiColors[0]));
+ }
}
fwrite(&bfh, 1, sizeof(bfh), f);
fwrite(pData, 1, size, f);
fclose(f);
- }
- else
- {
+ } else {
AfxMessageBox(ResStr(IDS_MAINFRM_53), MB_OK);
}
- }
- else if(ext == _T(".png"))
- {
+ } else if(ext == _T(".png")) {
DWORD bmpsize = size;
LPBITMAPINFOHEADER pdib;
LPBITMAPFILEHEADER pbmfh;
@@ -4820,10 +4669,12 @@ void CMainFrame::SaveDIB(LPCTSTR fn, BYTE* pData, long size)
bfh.bfSize = sizeof(bfh) + size;
bfh.bfReserved1 = bfh.bfReserved2 = 0;
- if(bi->bmiHeader.biBitCount <= 8)
- {
- if(bi->bmiHeader.biClrUsed) bfh.bfOffBits += bi->bmiHeader.biClrUsed * sizeof(bi->bmiColors[0]);
- else bfh.bfOffBits += (1 << bi->bmiHeader.biBitCount) * DWORD(sizeof(bi->bmiColors[0]));
+ if(bi->bmiHeader.biBitCount <= 8) {
+ if(bi->bmiHeader.biClrUsed) {
+ bfh.bfOffBits += bi->bmiHeader.biClrUsed * sizeof(bi->bmiColors[0]);
+ } else {
+ bfh.bfOffBits += (1 << bi->bmiHeader.biBitCount) * DWORD(sizeof(bi->bmiColors[0]));
+ }
}
pbmfh = (LPBITMAPFILEHEADER)&bfh;
pbits = &pData[pbmfh->bfOffBits-sizeof(bfh)];
@@ -4834,22 +4685,18 @@ void CMainFrame::SaveDIB(LPCTSTR fn, BYTE* pData, long size)
pngdib_d2p_set_gamma_label(pngdib, 1, PNGDIB_DEFAULT_FILE_GAMMA);
ret = pngdib_d2p_run(pngdib);
pngdib_done(pngdib);
- if(ret)
- {
+ if(ret) {
CString err_str;
err_str.Format(_T("%s\n%s (%d)"), IDS_MAINFRM_53, pngdib_get_error_msg(pngdib), ret);
AfxMessageBox(err_str, MB_OK);
}
- }
- else if(ext == _T(".jpg"))
- {
+ } else if(ext == _T(".jpg")) {
CJpegEncoderFile(fn).Encode(pData);
}
CPath p(fn);
- if(CDC* pDC = m_wndStatusBar.m_status.GetDC())
- {
+ if(CDC* pDC = m_wndStatusBar.m_status.GetDC()) {
CRect r;
m_wndStatusBar.m_status.GetClientRect(r);
p.CompactPath(pDC->m_hDC, r.Width());
@@ -4864,8 +4711,7 @@ void CMainFrame::SaveImage(LPCTSTR fn)
BYTE* pData = NULL;
long size = 0;
- if(GetDIB(&pData, size))
- {
+ if(GetDIB(&pData, size)) {
SaveDIB(fn, pData, size);
delete [] pData;
}
@@ -4873,14 +4719,14 @@ void CMainFrame::SaveImage(LPCTSTR fn)
void CMainFrame::SaveThumbnails(LPCTSTR fn)
{
- if(!pMC || !pMS || GetPlaybackMode() != PM_FILE /*&& GetPlaybackMode() != PM_DVD*/)
+ if(!pMC || !pMS || GetPlaybackMode() != PM_FILE /*&& GetPlaybackMode() != PM_DVD*/) {
return;
+ }
REFERENCE_TIME rtPos = GetPos();
REFERENCE_TIME rtDur = GetDur();
- if(rtDur <= 0)
- {
+ if(rtDur <= 0) {
AfxMessageBox(ResStr(IDS_MAINFRM_54));
return;
}
@@ -4892,35 +4738,31 @@ void CMainFrame::SaveThumbnails(LPCTSTR fn)
CSize video, wh(0, 0), arxy(0, 0);
- if (m_pMFVDC)
- {
+ if (m_pMFVDC) {
m_pMFVDC->GetNativeVideoSize(&wh, &arxy);
- }
- else if(m_pCAP)
- {
+ } else if(m_pCAP) {
wh = m_pCAP->GetVideoSize(false);
arxy = m_pCAP->GetVideoSize(true);
- }
- else
- {
+ } 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)
+ if(pBV2 && SUCCEEDED(pBV2->GetPreferredAspectRatio(&arx, &ary)) && arx > 0 && ary > 0) {
arxy.SetSize(arx, ary);
+ }
}
- if(wh.cx <= 0 || wh.cy <= 0)
- {
+ if(wh.cx <= 0 || wh.cy <= 0) {
AfxMessageBox(ResStr(IDS_MAINFRM_55));
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)))
+ 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);
@@ -4938,8 +4780,7 @@ void CMainFrame::SaveThumbnails(LPCTSTR fn)
int dibsize = sizeof(BITMAPINFOHEADER) + width*height*4;
CAutoVectorPtr<BYTE> dib;
- if(!dib.Allocate(dibsize))
- {
+ if(!dib.Allocate(dibsize)) {
AfxMessageBox(ResStr(IDS_MAINFRM_56));
return;
}
@@ -4966,15 +4807,15 @@ void CMainFrame::SaveThumbnails(LPCTSTR fn)
{
BYTE* p = (BYTE*)spd.bits;
for(int y = 0; y < spd.h; y++, p += spd.pitch)
- for(int x = 0; x < spd.w; x++)
+ 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++)
- {
+ for(int i = 1, pics = cols*rows; i <= pics; i++) {
REFERENCE_TIME rt = rtDur * i / (pics+1);
DVD_HMSF_TIMECODE hmsf = RT2HMSF(rt, 25);
@@ -4985,8 +4826,7 @@ void CMainFrame::SaveThumbnails(LPCTSTR fn)
HRESULT hr = pFS ? pFS->Step(1, NULL) : E_FAIL;
- if(FAILED(hr))
- {
+ if(FAILED(hr)) {
pBA->put_Volume(m_VolumeBeforeFrameStepping);
AfxMessageBox(_T("Cannot frame step, try a different video renderer."));
return;
@@ -4995,13 +4835,13 @@ void CMainFrame::SaveThumbnails(LPCTSTR fn)
HANDLE hGraphEvent = NULL;
pME->GetEventHandle((OAEVENT*)&hGraphEvent);
- while(hGraphEvent && WaitForSingleObject(hGraphEvent, INFINITE) == WAIT_OBJECT_0)
- {
+ while(hGraphEvent && WaitForSingleObject(hGraphEvent, INFINITE) == WAIT_OBJECT_0) {
LONG evCode = 0, evParam1, evParam2;
- while(SUCCEEDED(pME->GetEvent(&evCode, (LONG_PTR*)&evParam1, (LONG_PTR*)&evParam2, 0)))
- {
+ while(SUCCEEDED(pME->GetEvent(&evCode, (LONG_PTR*)&evParam1, (LONG_PTR*)&evParam2, 0))) {
pME->FreeEventParams(evCode, evParam1, evParam2);
- if(EC_STEP_COMPLETE == evCode) hGraphEvent = NULL;
+ if(EC_STEP_COMPLETE == evCode) {
+ hGraphEvent = NULL;
+ }
}
}
@@ -5034,12 +4874,13 @@ void CMainFrame::SaveThumbnails(LPCTSTR fn)
BYTE* pData = NULL;
long size = 0;
- if(!GetDIB(&pData, size)) return;
+ if(!GetDIB(&pData, size)) {
+ return;
+ }
BITMAPINFO* bi = (BITMAPINFO*)pData;
- if(bi->bmiHeader.biBitCount != 32)
- {
+ if(bi->bmiHeader.biBitCount != 32) {
delete [] pData;
CString str;
str.Format(ResStr(IDS_MAINFRM_57), bi->bmiHeader.biBitCount);
@@ -5051,8 +4892,7 @@ void CMainFrame::SaveThumbnails(LPCTSTR fn)
int sh = abs(bi->bmiHeader.biHeight);
int sp = sw*4;
const BYTE* src = pData + sizeof(bi->bmiHeader);
- if(bi->bmiHeader.biHeight >= 0)
- {
+ if(bi->bmiHeader.biHeight >= 0) {
src += sp*(sh-1);
sp = -sp;
}
@@ -5060,8 +4900,7 @@ void CMainFrame::SaveThumbnails(LPCTSTR fn)
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--)
- {
+ 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;
@@ -5069,8 +4908,7 @@ void CMainFrame::SaveThumbnails(LPCTSTR fn)
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--)
- {
+ 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;
@@ -5121,22 +4959,20 @@ void CMainFrame::SaveThumbnails(LPCTSTR fn)
CStringW fs;
WIN32_FIND_DATA wfd;
HANDLE hFind = FindFirstFile(m_wndPlaylistBar.GetCurFileName(), &wfd);
- if(hFind != INVALID_HANDLE_VALUE)
- {
+ if(hFind != INVALID_HANDLE_VALUE) {
FindClose(hFind);
__int64 size = (__int64(wfd.nFileSizeHigh)<<32)|wfd.nFileSizeLow;
- __int64 shortsize = size;
- CStringW measure = _T("B");
- if(shortsize > 10240) shortsize /= 1024, measure = L"KB";
- if(shortsize > 10240) shortsize /= 1024, measure = L"MB";
- if(shortsize > 10240) shortsize /= 1024, measure = L"GB";
- fs.Format(ResStr(IDS_MAINFRM_58), shortsize, measure, size);
+ const int MAX_FILE_SIZE_BUFFER = 65;
+ WCHAR szFileSize[MAX_FILE_SIZE_BUFFER];
+ StrFormatByteSizeW(size, szFileSize, sizeof(szFileSize));
+ fs.Format(ResStr(IDS_MAINFRM_58), szFileSize, size);
}
CStringW ar;
- if(arxy.cx > 0 && arxy.cy > 0 && arxy.cx != wh.cx && arxy.cy != wh.cy)
+ 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(ResStr(IDS_MAINFRM_59),
fn, fs, wh.cx, wh.cy, ar, hmsf.bHours, hmsf.bMinutes, hmsf.bSeconds);
@@ -5163,35 +4999,23 @@ BOOL CMainFrame::IsRendererCompatibleWithSaveImage()
BOOL result = TRUE;
AppSettings& s = AfxGetAppSettings();
- if(m_fRealMediaGraph)
- {
- if(s.iRMVideoRendererType == VIDRNDT_RM_DEFAULT)
- {
+ if(m_fRealMediaGraph) {
+ if(s.iRMVideoRendererType == VIDRNDT_RM_DEFAULT) {
AfxMessageBox(_T("The 'Save Image' and 'Save Thumbnails' functions do not work with the default video renderer for RealMedia.\nSelect one of the DirectX renderers for RealMedia in MPC's output options and reopen the file."));
result = FALSE;
}
- }
- else
- {
- if(m_fQuicktimeGraph)
- {
- if(s.iQTVideoRendererType == VIDRNDT_QT_DEFAULT)
- {
+ } else {
+ if(m_fQuicktimeGraph) {
+ if(s.iQTVideoRendererType == VIDRNDT_QT_DEFAULT) {
AfxMessageBox(_T("The 'Save Image and 'Save Thumbnails' functions do not work with the default video renderer for QuickTime.\nSelect one of the DirectX renderers for QuickTime in MPC's output options and reopen the file."));
result = FALSE;
}
- }
- else
- {
- if(m_fShockwaveGraph)
- {
+ } else {
+ if(m_fShockwaveGraph) {
AfxMessageBox(_T("The 'Save Image' and 'Save Thumbnails' functions do not work for Shockwave files."));
result = FALSE;
- }
- else
- {
- if(s.iDSVideoRendererType == VIDRNDT_DS_OVERLAYMIXER)
- {
+ } else {
+ if(s.iDSVideoRendererType == VIDRNDT_DS_OVERLAYMIXER) {
AfxMessageBox(_T("The 'Save Image' and 'Save Thumbnails' functions do not work with the Overlay Mixer video renderer.\nChange the video renderer in MPC's output options and reopen the file."));
result = FALSE;
}
@@ -5204,8 +5028,7 @@ BOOL CMainFrame::IsRendererCompatibleWithSaveImage()
CString CMainFrame::GetVidPos()
{
CString posstr = _T("");
- if((GetPlaybackMode() == PM_FILE) || (GetPlaybackMode() == PM_DVD))
- {
+ if((GetPlaybackMode() == PM_FILE) || (GetPlaybackMode() == PM_DVD)) {
__int64 start, stop, pos;
m_wndSeekBar.GetRange(start, stop);
pos = m_wndSeekBar.GetPosReal();
@@ -5213,10 +5036,11 @@ CString CMainFrame::GetVidPos()
DVD_HMSF_TIMECODE tcNow = RT2HMSF(pos);
DVD_HMSF_TIMECODE tcDur = RT2HMSF(stop);
- if(tcDur.bHours > 0 || (pos >= stop && tcNow.bHours > 0))
+ if(tcDur.bHours > 0 || (pos >= stop && tcNow.bHours > 0)) {
posstr.Format(_T("%02d.%02d.%02d"), tcNow.bHours, tcNow.bMinutes, tcNow.bSeconds);
- else
+ } else {
posstr.Format(_T("%02d.%02d"), tcNow.bMinutes, tcNow.bSeconds);
+ }
}
return posstr;
@@ -5227,22 +5051,18 @@ void CMainFrame::OnFileSaveImage()
AppSettings& s = AfxGetAppSettings();
/* Check if a compatible renderer is being used */
- if(!IsRendererCompatibleWithSaveImage())
- {
+ if(!IsRendererCompatibleWithSaveImage()) {
return;
}
CPath psrc(s.strSnapShotPath);
CStringW prefix = _T("snapshot");
- if(GetPlaybackMode() == PM_FILE)
- {
+ if(GetPlaybackMode() == PM_FILE) {
CPath path(m_wndPlaylistBar.GetCurFileName());
path.StripPath();
prefix.Format(_T("%s_snapshot_%s"), path, GetVidPos());
- }
- else if(GetPlaybackMode() == PM_DVD)
- {
+ } else if(GetPlaybackMode() == PM_DVD) {
prefix = _T("snapshot_dvd");
prefix.Format(_T("snapshot_dvd_%s"), GetVidPos());
}
@@ -5252,22 +5072,31 @@ void CMainFrame::OnFileSaveImage()
OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_PATHMUSTEXIST,
_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(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.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
- {
+ 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);
+ if(pdst.GetExtension().MakeLower() != s.strSnapShotExt) {
+ pdst.RenameExtension(s.strSnapShotExt);
+ }
CString path = (LPCTSTR)pdst;
pdst.RemoveFileSpec();
s.strSnapShotPath = (LPCTSTR)pdst;
@@ -5280,20 +5109,16 @@ void CMainFrame::OnFileSaveImageAuto()
AppSettings& s = AfxGetAppSettings();
/* Check if a compatible renderer is being used */
- if(!IsRendererCompatibleWithSaveImage())
- {
+ if(!IsRendererCompatibleWithSaveImage()) {
return;
}
CStringW prefix = _T("snapshot");
- if(GetPlaybackMode() == PM_FILE)
- {
+ if(GetPlaybackMode() == PM_FILE) {
CPath path(m_wndPlaylistBar.GetCurFileName());
path.StripPath();
prefix.Format(_T("%s_snapshot_%s"), path, GetVidPos());
- }
- else if(GetPlaybackMode() == PM_DVD)
- {
+ } else if(GetPlaybackMode() == PM_DVD) {
prefix.Format(_T("snapshot_dvd_%s"), GetVidPos());
}
@@ -5313,15 +5138,13 @@ void CMainFrame::OnFileSaveThumbnails()
AppSettings& s = AfxGetAppSettings();
/* Check if a compatible renderer is being used */
- if(!IsRendererCompatibleWithSaveImage())
- {
+ if(!IsRendererCompatibleWithSaveImage()) {
return;
}
CPath psrc(s.strSnapShotPath);
CStringW prefix = _T("thumbs");
- if(GetPlaybackMode() == PM_FILE)
- {
+ if(GetPlaybackMode() == PM_FILE) {
CPath path(m_wndPlaylistBar.GetCurFileName());
path.StripPath();
prefix.Format(_T("%s_thumbs"), path);
@@ -5333,16 +5156,23 @@ void CMainFrame::OnFileSaveThumbnails()
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(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.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
- {
+ 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");
}
@@ -5352,7 +5182,9 @@ void CMainFrame::OnFileSaveThumbnails()
s.iThumbWidth = fd.m_width;
CPath pdst(fd.GetPathName());
- if(pdst.GetExtension().MakeLower() != s.strSnapShotExt) pdst.RenameExtension(s.strSnapShotExt);
+ if(pdst.GetExtension().MakeLower() != s.strSnapShotExt) {
+ pdst.RenameExtension(s.strSnapShotExt);
+ }
CString path = (LPCTSTR)pdst;
pdst.RemoveFileSpec();
s.strSnapShotPath = (LPCTSTR)pdst;
@@ -5379,8 +5211,7 @@ void CMainFrame::OnUpdateFileConvert(CCmdUI* pCmdUI)
void CMainFrame::OnFileLoadsubtitle()
{
- if(!m_pCAP)
- {
+ if(!m_pCAP) {
AfxMessageBox(ResStr(IDS_MAINFRM_60)+
ResStr(IDS_MAINFRM_61)+
ResStr(IDS_MAINFRM_62)+
@@ -5398,11 +5229,14 @@ void CMainFrame::OnFileLoadsubtitle()
OFN_EXPLORER | OFN_ENABLESIZING | OFN_HIDEREADONLY,
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()
+ if(LoadSubtitle(fd.GetPathName(), &pSubStream)) {
+ SetSubtitle(pSubStream); // the subtitle at the insert position according to LoadSubtitle()
+ }
}
void CMainFrame::OnUpdateFileLoadsubtitle(CCmdUI *pCmdUI)
@@ -5415,27 +5249,24 @@ void CMainFrame::OnFileSavesubtitle()
int i = m_iSubtitleSel;
POSITION pos = m_pSubStreams.GetHeadPosition();
- while(pos && i >= 0)
- {
+ while(pos && i >= 0) {
CComPtr<ISubStream> pSubStream = m_pSubStreams.GetNext(pos);
- if(i < pSubStream->GetStreamCount())
- {
+ if(i < pSubStream->GetStreamCount()) {
CLSID clsid;
- if(FAILED(pSubStream->GetClassID(&clsid)))
+ if(FAILED(pSubStream->GetClassID(&clsid))) {
continue;
+ }
OpenMediaData *pOMD = m_wndPlaylistBar.GetCurOMD();
CString suggestedFileName("");
- if(OpenFileData* p = dynamic_cast<OpenFileData*>(pOMD))
- {
+ 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))
- {
+ 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
@@ -5444,16 +5275,13 @@ void CMainFrame::OnFileSavesubtitle()
OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_PATHMUSTEXIST,
_T("VobSub (*.idx, *.sub)|*.idx;*.sub||"), GetModalParent(), 0);
- if(fd.DoModal() == IDOK)
- {
+ if(fd.DoModal() == IDOK) {
CAutoLock cAutoLock(&m_csSubLock);
pVSF->Save(fd.GetPathName());
}
return;
- }
- else if(clsid == __uuidof(CRenderedTextSubtitle))
- {
+ } else if(clsid == __uuidof(CRenderedTextSubtitle)) {
CRenderedTextSubtitle* pRTS = (CRenderedTextSubtitle*)(ISubStream*)pSubStream;
CString filter;
@@ -5469,8 +5297,7 @@ void CMainFrame::OnFileSavesubtitle()
// 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)
- {
+ if(fd.DoModal() == IDOK) {
CAutoLock cAutoLock(&m_csSubLock);
pRTS->SaveAs(fd.GetPathName(), (exttype)(fd.m_ofn.nFilterIndex-1), m_pCAP->GetFPS(), fd.GetEncoding());
}
@@ -5521,8 +5348,7 @@ void CMainFrame::OnFileISDBDownload()
{
AppSettings& s = AfxGetAppSettings();
filehash fh;
- if(!::hash((CString)m_wndPlaylistBar.GetCurFileName(), fh))
- {
+ if(!::hash((CString)m_wndPlaylistBar.GetCurFileName(), fh)) {
MessageBeep((UINT)-1);
return;
}
@@ -5534,13 +5360,11 @@ void CMainFrame::OnFileISDBDownload()
args.Format("player=mpc&name[0]=%s&size[0]=%016I64x&hash[0]=%016I64x",
UrlEncode(CStringA(fh.name)), fh.size, fh.hash);
- try
- {
+ try {
CInternetSession is;
CStringA str;
- if(!OpenUrl(is, CString(url+args), str))
- {
+ if(!OpenUrl(is, CString(url+args), str)) {
AfxMessageBox(_T("Cannot connect to subtitle database site"), MB_OK);
return;
}
@@ -5554,78 +5378,78 @@ void CMainFrame::OnFileISDBDownload()
Explode(str, sl, '\n');
POSITION pos = sl.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
str = sl.GetNext(pos);
CStringA param = str.Left(max(0, str.Find('=')));
CStringA value = str.Mid(str.Find('=')+1);
- if(param == "ticket") ticket = value;
- else if(param == "movie")
- {
+ if(param == "ticket") {
+ ticket = value;
+ } else if(param == "movie") {
m.reset();
Explode(value, m.titles, '|');
- }
- else if(param == "subtitle")
- {
+ } 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")
- {
+ } 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")
- {
+ } else if(param == "" && value == "endmovie") {
movies.AddTail(m);
+ } else if(param == "" && value == "end") {
+ break;
}
- else if(param == "" && value == "end") break;
}
CSubtitleDlDlg dlg(movies, GetModalParent());
- if(IDOK == dlg.DoModal())
- {
- if(dlg.m_fReplaceSubs)
+ if(IDOK == dlg.DoModal()) {
+ if(dlg.m_fReplaceSubs) {
m_pSubStreams.RemoveAll();
+ }
CComPtr<ISubStream> pSubStreamToSet;
POSITION pos = dlg.m_selsubs.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
isdb_subtitle& sub = dlg.m_selsubs.GetNext(pos);
CStringA url = "http://" + s.strISDb + "/dl.php?";
CStringA args;
args.Format("id=%d&ticket=%s", sub.id, UrlEncode(ticket));
- if(OpenUrl(is, CString(url+args), str))
- {
+ if(OpenUrl(is, CString(url+args), str)) {
CAutoPtr<CRenderedTextSubtitle> pRTS(DNew CRenderedTextSubtitle(&m_csSubLock, &s.subdefstyle, s.fUseDefaultSubtitlesStyle));
- if(pRTS && pRTS->Open((BYTE*)(LPCSTR)str, str.GetLength(), DEFAULT_CHARSET, CString(sub.name)) && pRTS->GetStreamCount() > 0)
- {
+ if(pRTS && pRTS->Open((BYTE*)(LPCSTR)str, str.GetLength(), DEFAULT_CHARSET, CString(sub.name)) && pRTS->GetStreamCount() > 0) {
CComPtr<ISubStream> pSubStream = pRTS.Detach();
m_pSubStreams.AddTail(pSubStream);
- if(!pSubStreamToSet) pSubStreamToSet = pSubStream;
+ if(!pSubStreamToSet) {
+ pSubStreamToSet = pSubStream;
+ }
}
}
}
- if(pSubStreamToSet)
+ if(pSubStreamToSet) {
SetSubtitle(pSubStreamToSet);
+ }
}
- }
- catch(CInternetException* ie)
- {
+ } catch(CInternetException* ie) {
ie->Delete();
return;
}
@@ -5685,8 +5509,9 @@ void CMainFrame::OnViewResetStats()
void CMainFrame::OnViewDisplayStatsSC()
{
++AfxGetMyApp()->m_Renderers.m_fDisplayStats;
- if (AfxGetMyApp()->m_Renderers.m_fDisplayStats > 3)
+ if (AfxGetMyApp()->m_Renderers.m_fDisplayStats > 3) {
AfxGetMyApp()->m_Renderers.m_fDisplayStats = 0;
+ }
}
void CMainFrame::OnUpdateViewVSync(CCmdUI* pCmdUI)
@@ -5785,23 +5610,22 @@ void CMainFrame::OnUpdateViewColorManagementInput(CCmdUI* pCmdUI)
pCmdUI->Enable (supported);
- switch (pCmdUI->m_nID)
- {
- case ID_VIEW_COLORMANAGEMENT_INPUT_AUTO:
- pCmdUI->SetCheck(r.m_RenderSettings.iVMR9ColorManagementInput == VIDEO_SYSTEM_UNKNOWN);
- break;
+ switch (pCmdUI->m_nID) {
+ case ID_VIEW_COLORMANAGEMENT_INPUT_AUTO:
+ pCmdUI->SetCheck(r.m_RenderSettings.iVMR9ColorManagementInput == VIDEO_SYSTEM_UNKNOWN);
+ break;
- case ID_VIEW_COLORMANAGEMENT_INPUT_HDTV:
- pCmdUI->SetCheck(r.m_RenderSettings.iVMR9ColorManagementInput == VIDEO_SYSTEM_HDTV);
- break;
+ case ID_VIEW_COLORMANAGEMENT_INPUT_HDTV:
+ pCmdUI->SetCheck(r.m_RenderSettings.iVMR9ColorManagementInput == VIDEO_SYSTEM_HDTV);
+ break;
- case ID_VIEW_COLORMANAGEMENT_INPUT_SDTV_NTSC:
- pCmdUI->SetCheck(r.m_RenderSettings.iVMR9ColorManagementInput == VIDEO_SYSTEM_SDTV_NTSC);
- break;
+ case ID_VIEW_COLORMANAGEMENT_INPUT_SDTV_NTSC:
+ pCmdUI->SetCheck(r.m_RenderSettings.iVMR9ColorManagementInput == VIDEO_SYSTEM_SDTV_NTSC);
+ break;
- case ID_VIEW_COLORMANAGEMENT_INPUT_SDTV_PAL:
- pCmdUI->SetCheck(r.m_RenderSettings.iVMR9ColorManagementInput == VIDEO_SYSTEM_SDTV_PAL);
- break;
+ case ID_VIEW_COLORMANAGEMENT_INPUT_SDTV_PAL:
+ pCmdUI->SetCheck(r.m_RenderSettings.iVMR9ColorManagementInput == VIDEO_SYSTEM_SDTV_PAL);
+ break;
}
}
@@ -5818,19 +5642,18 @@ void CMainFrame::OnUpdateViewColorManagementAmbientLight(CCmdUI* pCmdUI)
pCmdUI->Enable (supported);
- switch (pCmdUI->m_nID)
- {
- case ID_VIEW_COLORMANAGEMENT_AMBIENTLIGHT_BRIGHT:
- pCmdUI->SetCheck(r.m_RenderSettings.iVMR9ColorManagementAmbientLight == AMBIENT_LIGHT_BRIGHT);
- break;
+ switch (pCmdUI->m_nID) {
+ case ID_VIEW_COLORMANAGEMENT_AMBIENTLIGHT_BRIGHT:
+ pCmdUI->SetCheck(r.m_RenderSettings.iVMR9ColorManagementAmbientLight == AMBIENT_LIGHT_BRIGHT);
+ break;
- case ID_VIEW_COLORMANAGEMENT_AMBIENTLIGHT_DIM:
- pCmdUI->SetCheck(r.m_RenderSettings.iVMR9ColorManagementAmbientLight == AMBIENT_LIGHT_DIM);
- break;
+ case ID_VIEW_COLORMANAGEMENT_AMBIENTLIGHT_DIM:
+ pCmdUI->SetCheck(r.m_RenderSettings.iVMR9ColorManagementAmbientLight == AMBIENT_LIGHT_DIM);
+ break;
- case ID_VIEW_COLORMANAGEMENT_AMBIENTLIGHT_DARK:
- pCmdUI->SetCheck(r.m_RenderSettings.iVMR9ColorManagementAmbientLight == AMBIENT_LIGHT_DARK);
- break;
+ case ID_VIEW_COLORMANAGEMENT_AMBIENTLIGHT_DARK:
+ pCmdUI->SetCheck(r.m_RenderSettings.iVMR9ColorManagementAmbientLight == AMBIENT_LIGHT_DARK);
+ break;
}
}
@@ -5847,23 +5670,22 @@ void CMainFrame::OnUpdateViewColorManagementIntent(CCmdUI* pCmdUI)
pCmdUI->Enable (supported);
- switch (pCmdUI->m_nID)
- {
- case ID_VIEW_COLORMANAGEMENT_INTENT_PERCEPTUAL:
- pCmdUI->SetCheck(r.m_RenderSettings.iVMR9ColorManagementIntent == COLOR_RENDERING_INTENT_PERCEPTUAL);
- break;
+ switch (pCmdUI->m_nID) {
+ case ID_VIEW_COLORMANAGEMENT_INTENT_PERCEPTUAL:
+ pCmdUI->SetCheck(r.m_RenderSettings.iVMR9ColorManagementIntent == COLOR_RENDERING_INTENT_PERCEPTUAL);
+ break;
- case ID_VIEW_COLORMANAGEMENT_INTENT_RELATIVECOLORIMETRIC:
- pCmdUI->SetCheck(r.m_RenderSettings.iVMR9ColorManagementIntent == COLOR_RENDERING_INTENT_RELATIVE_COLORIMETRIC);
- break;
+ case ID_VIEW_COLORMANAGEMENT_INTENT_RELATIVECOLORIMETRIC:
+ pCmdUI->SetCheck(r.m_RenderSettings.iVMR9ColorManagementIntent == COLOR_RENDERING_INTENT_RELATIVE_COLORIMETRIC);
+ break;
- case ID_VIEW_COLORMANAGEMENT_INTENT_SATURATION:
- pCmdUI->SetCheck(r.m_RenderSettings.iVMR9ColorManagementIntent == COLOR_RENDERING_INTENT_SATURATION);
- break;
+ case ID_VIEW_COLORMANAGEMENT_INTENT_SATURATION:
+ pCmdUI->SetCheck(r.m_RenderSettings.iVMR9ColorManagementIntent == COLOR_RENDERING_INTENT_SATURATION);
+ break;
- case ID_VIEW_COLORMANAGEMENT_INTENT_ABSOLUTECOLORIMETRIC:
- pCmdUI->SetCheck(r.m_RenderSettings.iVMR9ColorManagementIntent == COLOR_RENDERING_INTENT_ABSOLUTE_COLORIMETRIC);
- break;
+ case ID_VIEW_COLORMANAGEMENT_INTENT_ABSOLUTECOLORIMETRIC:
+ pCmdUI->SetCheck(r.m_RenderSettings.iVMR9ColorManagementIntent == COLOR_RENDERING_INTENT_ABSOLUTE_COLORIMETRIC);
+ break;
}
}
@@ -5877,10 +5699,11 @@ void CMainFrame::OnUpdateViewEVROutputRange(CCmdUI* pCmdUI)
pCmdUI->Enable (supported);
- if (pCmdUI->m_nID == ID_VIEW_EVROUTPUTRANGE_0_255)
+ 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)
+ } else if (pCmdUI->m_nID == ID_VIEW_EVROUTPUTRANGE_16_235) {
pCmdUI->SetCheck(r.m_RenderSettings.iEVROutputRange == 1);
+ }
}
@@ -5894,12 +5717,13 @@ void CMainFrame::OnUpdateViewFlushGPU(CCmdUI* pCmdUI)
pCmdUI->Enable (supported);
- if (pCmdUI->m_nID == ID_VIEW_FLUSHGPU_BEFOREVSYNC)
+ if (pCmdUI->m_nID == ID_VIEW_FLUSHGPU_BEFOREVSYNC) {
pCmdUI->SetCheck(r.m_RenderSettings.iVMRFlushGPUBeforeVSync != 0);
- else if (pCmdUI->m_nID == ID_VIEW_FLUSHGPU_AFTERPRESENT)
+ } 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)
+ } else if (pCmdUI->m_nID == ID_VIEW_FLUSHGPU_WAIT) {
pCmdUI->SetCheck(r.m_RenderSettings.iVMRFlushGPUWait != 0);
+ }
}
@@ -6056,8 +5880,7 @@ void CMainFrame::OnViewSynchronizeVideo()
{
CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
s.m_RenderSettings.bSynchronizeVideo = !s.m_RenderSettings.bSynchronizeVideo;
- if (s.m_RenderSettings.bSynchronizeVideo)
- {
+ if (s.m_RenderSettings.bSynchronizeVideo) {
s.m_RenderSettings.bSynchronizeDisplay = false;
s.m_RenderSettings.bSynchronizeNearest = false;
s.m_RenderSettings.iVMR9VSync = false;
@@ -6075,8 +5898,7 @@ void CMainFrame::OnViewSynchronizeDisplay()
{
CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
s.m_RenderSettings.bSynchronizeDisplay = !s.m_RenderSettings.bSynchronizeDisplay;
- if (s.m_RenderSettings.bSynchronizeDisplay)
- {
+ if (s.m_RenderSettings.bSynchronizeDisplay) {
s.m_RenderSettings.bSynchronizeVideo = false;
s.m_RenderSettings.bSynchronizeNearest = false;
s.m_RenderSettings.iVMR9VSync = false;
@@ -6094,8 +5916,7 @@ void CMainFrame::OnViewSynchronizeNearest()
{
CRenderersSettings& s = AfxGetAppSettings().m_RenderersSettings;
s.m_RenderSettings.bSynchronizeNearest = !s.m_RenderSettings.bSynchronizeNearest;
- if (s.m_RenderSettings.bSynchronizeNearest)
- {
+ if (s.m_RenderSettings.bSynchronizeNearest) {
s.m_RenderSettings.bSynchronizeVideo = false;
s.m_RenderSettings.bSynchronizeDisplay = false;
s.m_RenderSettings.iVMR9VSync = false;
@@ -6384,13 +6205,10 @@ void CMainFrame::OnViewVSyncOffsetIncrease()
AppSettings& s = AfxGetAppSettings();
CRenderersSettings& r = s.m_RenderersSettings;
CString Format;
- if (s.iDSVideoRendererType == VIDRNDT_DS_SYNC)
- {
+ if (s.iDSVideoRendererType == VIDRNDT_DS_SYNC) {
r.m_RenderSettings.fTargetSyncOffset = r.m_RenderSettings.fTargetSyncOffset - 0.5; // Yeah, it should be a "-"
Format.Format(L"Target VSync Offset: %.1f", r.m_RenderSettings.fTargetSyncOffset);
- }
- else
- {
+ } else {
++r.m_RenderSettings.iVMR9VSyncOffset;
Format.Format(L"VSync Offset: %d", r.m_RenderSettings.iVMR9VSyncOffset);
}
@@ -6403,13 +6221,10 @@ void CMainFrame::OnViewVSyncOffsetDecrease()
AppSettings& s = AfxGetAppSettings();
CRenderersSettings& r = s.m_RenderersSettings;
CString Format;
- if (s.iDSVideoRendererType == VIDRNDT_DS_SYNC)
- {
+ if (s.iDSVideoRendererType == VIDRNDT_DS_SYNC) {
r.m_RenderSettings.fTargetSyncOffset = r.m_RenderSettings.fTargetSyncOffset + 0.5;
Format.Format(L"Target VSync Offset: %.1f", r.m_RenderSettings.fTargetSyncOffset);
- }
- else
- {
+ } else {
--r.m_RenderSettings.iVMR9VSyncOffset;
Format.Format(L"VSync Offset: %d", r.m_RenderSettings.iVMR9VSyncOffset);
}
@@ -6427,7 +6242,9 @@ void CMainFrame::OnUpdateViewRemainingTime(CCmdUI* pCmdUI)
void CMainFrame::OnViewRemainingTime()
{
m_bRemainingTime = !m_bRemainingTime;
- if (!m_bRemainingTime) m_OSD.ClearMessage();
+ if (!m_bRemainingTime) {
+ m_OSD.ClearMessage();
+ }
}
void CMainFrame::OnUpdateShaderToggle(CCmdUI* pCmdUI)
@@ -6445,15 +6262,13 @@ void CMainFrame::OnUpdateShaderToggleScreenSpace(CCmdUI* pCmdUI)
void CMainFrame::OnShaderToggle()
{
m_bToggleShader = !m_bToggleShader;
- if (!m_bToggleShader)
- {
+ if (!m_bToggleShader) {
SetShaders();
m_OSD.DisplayMessage (OSD_TOPRIGHT, ResStr(IDS_MAINFRM_65));
- }
- else
- {
- if (m_pCAP)
+ } else {
+ if (m_pCAP) {
m_pCAP->SetPixelShader(NULL, NULL);
+ }
m_OSD.DisplayMessage (OSD_TOPRIGHT, ResStr(IDS_MAINFRM_66));
}
@@ -6462,15 +6277,13 @@ void CMainFrame::OnShaderToggle()
void CMainFrame::OnShaderToggleScreenSpace()
{
m_bToggleShaderScreenSpace = !m_bToggleShaderScreenSpace;
- if (!m_bToggleShaderScreenSpace)
- {
+ if (!m_bToggleShaderScreenSpace) {
SetShaders();
m_OSD.DisplayMessage (OSD_TOPRIGHT, ResStr(IDS_MAINFRM_PPONSCR));
- }
- else
- {
- if (m_pCAP2)
+ } else {
+ if (m_pCAP2) {
m_pCAP2->SetPixelShader2(NULL, NULL, true);
+ }
m_OSD.DisplayMessage (OSD_TOPRIGHT, ResStr(IDS_MAINFRM_PPOFFSCR));
}
@@ -6484,10 +6297,11 @@ void CMainFrame::OnD3DFullscreenToggle()
s.fD3DFullscreen = !s.fD3DFullscreen;
strMsg = s.fD3DFullscreen ? ResStr(IDS_MAINFRM_67) : _T("D3D Fullscreen off");
- if (m_iMediaLoadState == MLS_CLOSED)
+ if (m_iMediaLoadState == MLS_CLOSED) {
m_closingmsg = strMsg;
- else
+ } else {
m_OSD.DisplayMessage (OSD_TOPRIGHT, strMsg);
+ }
}
void CMainFrame::OnFileClosePlaylist()
@@ -6509,8 +6323,9 @@ void CMainFrame::OnViewCaptionmenu()
s.iCaptionMenuMode++;
s.iCaptionMenuMode %= MODE_COUNT; // three states: normal->borderless->frame only->
- if ( m_fFullScreen )
+ if ( m_fFullScreen ) {
return;
+ }
DWORD dwRemove = 0, dwAdd = 0;
HMENU hMenu = NULL;
@@ -6518,26 +6333,25 @@ void CMainFrame::OnViewCaptionmenu()
CRect wr;
GetWindowRect( &wr );
- switch(s.iCaptionMenuMode)
- {
- case MODE_BORDERLESS : // normal -> borderless
- dwRemove = WS_CAPTION | WS_THICKFRAME;
- wr.right -= (GetSystemMetrics( SM_CXSIZEFRAME ) * 2); // "Resize" borders
- wr.bottom -= (GetSystemMetrics( SM_CYSIZEFRAME ) * 2); // "Resize" borders
- wr.bottom -= (GetSystemMetrics( SM_CYCAPTION ) + GetSystemMetrics( SM_CYMENU ));
- break;
+ switch(s.iCaptionMenuMode) {
+ case MODE_BORDERLESS : // normal -> borderless
+ dwRemove = WS_CAPTION | WS_THICKFRAME;
+ wr.right -= (GetSystemMetrics( SM_CXSIZEFRAME ) * 2); // "Resize" borders
+ wr.bottom -= (GetSystemMetrics( SM_CYSIZEFRAME ) * 2); // "Resize" borders
+ wr.bottom -= (GetSystemMetrics( SM_CYCAPTION ) + GetSystemMetrics( SM_CYMENU ));
+ break;
- case MODE_SHOWCAPTIONMENU: // frameonly -> normal
- dwAdd = WS_CAPTION;
- hMenu = m_hMenuDefault;
- wr.bottom += (GetSystemMetrics( SM_CYCAPTION ) + GetSystemMetrics( SM_CYMENU ));
- break;
+ case MODE_SHOWCAPTIONMENU: // frameonly -> normal
+ dwAdd = WS_CAPTION;
+ hMenu = m_hMenuDefault;
+ wr.bottom += (GetSystemMetrics( SM_CYCAPTION ) + GetSystemMetrics( SM_CYMENU ));
+ break;
- case MODE_FRAMEONLY: // borderless -> frameonly
- dwAdd = WS_THICKFRAME;
- wr.right += (GetSystemMetrics( SM_CXSIZEFRAME ) * 2);
- wr.bottom += (GetSystemMetrics( SM_CYSIZEFRAME ) * 2);
- break;
+ case MODE_FRAMEONLY: // borderless -> frameonly
+ dwAdd = WS_THICKFRAME;
+ wr.right += (GetSystemMetrics( SM_CXSIZEFRAME ) * 2);
+ wr.bottom += (GetSystemMetrics( SM_CYSIZEFRAME ) * 2);
+ break;
}
ModifyStyle(dwRemove, dwAdd, SWP_NOZORDER);
@@ -6595,8 +6409,7 @@ void CMainFrame::OnViewEditListEditor()
{
AppSettings& s = AfxGetAppSettings();
- if (s.fEnableEDLEditor || (AfxMessageBox(_T("Do you want to activate EDL editor?"), MB_YESNO) == IDYES))
- {
+ if (s.fEnableEDLEditor || (AfxMessageBox(_T("Do you want to activate EDL editor?"), MB_YESNO) == IDYES)) {
s.fEnableEDLEditor = true;
ShowControlBar(&m_wndEditListEditor, !m_wndEditListEditor.IsWindowVisible(), TRUE);
}
@@ -6604,8 +6417,7 @@ void CMainFrame::OnViewEditListEditor()
void CMainFrame::OnEDLIn()
{
- if(AfxGetAppSettings().fEnableEDLEditor && (m_iMediaLoadState == MLS_LOADED) && (GetPlaybackMode() == PM_FILE))
- {
+ if(AfxGetAppSettings().fEnableEDLEditor && (m_iMediaLoadState == MLS_LOADED) && (GetPlaybackMode() == PM_FILE)) {
REFERENCE_TIME rt;
pMS->GetCurrentPosition(&rt);
@@ -6620,8 +6432,7 @@ void CMainFrame::OnUpdateEDLIn(CCmdUI* pCmdUI)
void CMainFrame::OnEDLOut()
{
- if(AfxGetAppSettings().fEnableEDLEditor && (m_iMediaLoadState == MLS_LOADED) && (GetPlaybackMode() == PM_FILE))
- {
+ if(AfxGetAppSettings().fEnableEDLEditor && (m_iMediaLoadState == MLS_LOADED) && (GetPlaybackMode() == PM_FILE)) {
REFERENCE_TIME rt;
pMS->GetCurrentPosition(&rt);
@@ -6636,8 +6447,7 @@ void CMainFrame::OnUpdateEDLOut(CCmdUI* pCmdUI)
void CMainFrame::OnEDLNewClip()
{
- if(AfxGetAppSettings().fEnableEDLEditor && (m_iMediaLoadState == MLS_LOADED) && (GetPlaybackMode() == PM_FILE))
- {
+ if(AfxGetAppSettings().fEnableEDLEditor && (m_iMediaLoadState == MLS_LOADED) && (GetPlaybackMode() == PM_FILE)) {
REFERENCE_TIME rt;
pMS->GetCurrentPosition(&rt);
@@ -6652,8 +6462,7 @@ void CMainFrame::OnUpdateEDLNewClip(CCmdUI* pCmdUI)
void CMainFrame::OnEDLSave()
{
- if(AfxGetAppSettings().fEnableEDLEditor && (m_iMediaLoadState == MLS_LOADED) && (GetPlaybackMode() == PM_FILE))
- {
+ if(AfxGetAppSettings().fEnableEDLEditor && (m_iMediaLoadState == MLS_LOADED) && (GetPlaybackMode() == PM_FILE)) {
m_wndEditListEditor.Save();
}
}
@@ -6669,8 +6478,9 @@ void CMainFrame::OnViewNavigation()
AppSettings& s = AfxGetAppSettings();
s.fHideNavigation = !s.fHideNavigation;
m_wndNavigationBar.m_navdlg.UpdateElementList();
- if (GetPlaybackMode() == PM_CAPTURE)
+ if (GetPlaybackMode() == PM_CAPTURE) {
ShowControlBar(&m_wndNavigationBar, !s.fHideNavigation, TRUE);
+ }
}
void CMainFrame::OnUpdateViewNavigation(CCmdUI* pCmdUI)
@@ -6703,8 +6513,9 @@ void CMainFrame::OnUpdateViewShaderEditor(CCmdUI* pCmdUI)
void CMainFrame::OnViewMinimal()
{
- while(AfxGetAppSettings().iCaptionMenuMode!=MODE_BORDERLESS)
+ while(AfxGetAppSettings().iCaptionMenuMode!=MODE_BORDERLESS) {
SendMessage(WM_COMMAND, ID_VIEW_CAPTIONMENU);
+ }
ShowControls(CS_NONE);
}
@@ -6714,8 +6525,9 @@ void CMainFrame::OnUpdateViewMinimal(CCmdUI* pCmdUI)
void CMainFrame::OnViewCompact()
{
- while(AfxGetAppSettings().iCaptionMenuMode!=MODE_FRAMEONLY)
+ while(AfxGetAppSettings().iCaptionMenuMode!=MODE_FRAMEONLY) {
SendMessage(WM_COMMAND, ID_VIEW_CAPTIONMENU);
+ }
ShowControls(CS_TOOLBAR);
}
@@ -6725,8 +6537,9 @@ void CMainFrame::OnUpdateViewCompact(CCmdUI* pCmdUI)
void CMainFrame::OnViewNormal()
{
- while(AfxGetAppSettings().iCaptionMenuMode!=MODE_SHOWCAPTIONMENU)
+ while(AfxGetAppSettings().iCaptionMenuMode!=MODE_SHOWCAPTIONMENU) {
SendMessage(WM_COMMAND, ID_VIEW_CAPTIONMENU);
+ }
ShowControls(CS_SEEKBAR|CS_TOOLBAR|CS_STATUSBAR|CS_INFOBAR);
}
@@ -6783,31 +6596,31 @@ void CMainFrame::OnUpdateViewDefaultVideoFrame(CCmdUI* pCmdUI)
void CMainFrame::OnViewSwitchVideoFrame()
{
int vs = AfxGetAppSettings().iDefaultVideoSize;
- if (vs <= DVS_DOUBLE || vs == DVS_FROMOUTSIDE)
+ if (vs <= DVS_DOUBLE || vs == DVS_FROMOUTSIDE) {
vs = DVS_STRETCH;
- else if (vs == DVS_FROMINSIDE)
+ } else if (vs == DVS_FROMINSIDE) {
vs = DVS_ZOOM1;
- else if (vs == DVS_ZOOM2)
+ } else if (vs == DVS_ZOOM2) {
vs = DVS_FROMOUTSIDE;
- else
+ } 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;
+ }
+ 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;
@@ -6841,78 +6654,95 @@ void CMainFrame::OnUpdateViewCompMonDeskARDiff(CCmdUI* pCmdUI)
void CMainFrame::OnViewPanNScan(UINT nID)
{
- if(m_iMediaLoadState != MLS_LOADED) return;
+ 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;
+ 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;
- if(x < 0 && m_ZoomX > 0.2) m_ZoomX /= 1.02;
- if(y > 0 && m_ZoomY < 3) m_ZoomY *= 1.02;
- if(y < 0 && m_ZoomY > 0.2) m_ZoomY /= 1.02;
+ if(x > 0 && m_ZoomX < 3) {
+ m_ZoomX *= 1.02;
+ }
+ if(x < 0 && m_ZoomX > 0.2) {
+ m_ZoomX /= 1.02;
+ }
+ if(y > 0 && m_ZoomY < 3) {
+ m_ZoomY *= 1.02;
+ }
+ 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);
- 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);
- if(dy > 0 && m_PosY < 1) m_PosY = min(m_PosY + 0.005*m_ZoomY, 1);
+ if(dx < 0 && m_PosX > 0) {
+ m_PosX = max(m_PosX - 0.005*m_ZoomX, 0);
+ }
+ 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);
+ }
+ if(dy > 0 && m_PosY < 1) {
+ m_PosY = min(m_PosY + 0.005*m_ZoomY, 1);
+ }
MoveVideoWindow(true);
}
@@ -6924,18 +6754,18 @@ void CMainFrame::OnUpdateViewPanNScan(CCmdUI* pCmdUI)
void CMainFrame::OnViewPanNScanPresets(UINT nID)
{
- if(m_iMediaLoadState != MLS_LOADED) return;
+ if(m_iMediaLoadState != MLS_LOADED) {
+ return;
+ }
AppSettings& s = AfxGetAppSettings();
nID -= ID_PANNSCAN_PRESETS_START;
- if((INT_PTR)nID == s.m_pnspresets.GetCount())
- {
+ if((INT_PTR)nID == s.m_pnspresets.GetCount()) {
CPnSPresetsDlg dlg;
dlg.m_pnspresets.Copy(s.m_pnspresets);
- if(dlg.DoModal() == IDOK)
- {
+ if(dlg.DoModal() == IDOK) {
s.m_pnspresets.Copy(dlg.m_pnspresets);
s.UpdateData(true);
}
@@ -6950,33 +6780,35 @@ void CMainFrame::OnViewPanNScanPresets(UINT nID)
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++)
- {
+ 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;
+ 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;
+ 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;
+ if(j != 5) {
+ return;
+ }
m_PosX = min(max(m_PosX, 0), 1);
m_PosY = min(max(m_PosY, 0), 1);
@@ -6995,32 +6827,33 @@ void CMainFrame::OnUpdateViewPanNScanPresets(CCmdUI* pCmdUI)
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:
+ 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(DegToRad(m_AngleX), DegToRad(m_AngleY), DegToRad(m_AngleZ)));
CString info;
@@ -7043,8 +6876,11 @@ void CMainFrame::OnViewAspectRatio(UINT nID)
ar = s_ar[nID - ID_ASPECTRATIO_START];
CString info;
- if(ar.cx && ar.cy) info.Format(ResStr(IDS_MAINFRM_68), ar.cx, ar.cy);
- else info.Format(ResStr(IDS_MAINFRM_69));
+ if(ar.cx && ar.cy) {
+ info.Format(ResStr(IDS_MAINFRM_68), ar.cx, ar.cy);
+ } else {
+ info.Format(ResStr(IDS_MAINFRM_69));
+ }
SendStatusMessage(info, 3000);
m_OSD.DisplayMessage(OSD_TOPLEFT, info, 3000);
@@ -7064,10 +6900,8 @@ void CMainFrame::OnViewAspectRatioNext()
UINT nID = ID_ASPECTRATIO_START;
- for(int i = 0; i < countof(s_ar); i++)
- {
- if(ar == s_ar[i])
- {
+ for(int i = 0; i < countof(s_ar); i++) {
+ if(ar == s_ar[i]) {
nID += (i + 1) % countof(s_ar);
break;
}
@@ -7079,8 +6913,9 @@ void CMainFrame::OnViewAspectRatioNext()
void CMainFrame::OnViewOntop(UINT nID)
{
nID -= ID_ONTOP_NEVER;
- if(AfxGetAppSettings().iOnTop == (int)nID)
+ if(AfxGetAppSettings().iOnTop == (int)nID) {
nID = !nID;
+ }
SetAlwaysOnTop(nID);
}
@@ -7100,41 +6935,36 @@ void CMainFrame::OnViewOptions()
void CMainFrame::OnPlayPlay()
{
- if(m_iMediaLoadState == MLS_CLOSED)
- {
+ if(m_iMediaLoadState == MLS_CLOSED) {
OpenCurPlaylistItem();
return;
}
- if(m_iMediaLoadState == MLS_LOADED)
- {
- if(GetMediaState() == State_Stopped) m_iSpeedLevel = 0;
+ if(m_iMediaLoadState == MLS_LOADED) {
+ if(GetMediaState() == State_Stopped) {
+ m_iSpeedLevel = 0;
+ }
- if(GetPlaybackMode() == PM_FILE)
- {
+ if(GetPlaybackMode() == PM_FILE) {
m_iSpeedLevel = 0;
- if(m_fEndOfStream) SendMessage(WM_COMMAND, ID_PLAY_STOP);
+ if(m_fEndOfStream) {
+ SendMessage(WM_COMMAND, ID_PLAY_STOP);
+ }
pMS->SetRate (1.0);
pMC->Run();
- }
- else if(GetPlaybackMode() == PM_DVD)
- {
+ } else if(GetPlaybackMode() == PM_DVD) {
double dRate = 1.0;
m_iSpeedLevel = 0;
pDVDC->PlayForwards(dRate, DVD_CMD_FLAG_Block, NULL);
pDVDC->Pause(FALSE);
pMC->Run();
- }
- else if(GetPlaybackMode() == PM_CAPTURE)
- {
+ } 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)
- {
+ if (AfxGetAppSettings().iDefaultCaptureDevice == 1) {
CComQIPtr<IBDATuner> pTun = pGB;
- if (pTun)
- {
+ if (pTun) {
pTun->SetChannel (AfxGetAppSettings().nDVBLastChannel);
DisplayCurrentChannelOSD();
}
@@ -7142,8 +6972,7 @@ void CMainFrame::OnPlayPlay()
}
SetTimersPlay();
- if(m_fFrameSteppingActive) // FIXME
- {
+ if(m_fFrameSteppingActive) { // FIXME
m_fFrameSteppingActive = false;
pBA->put_Volume(m_VolumeBeforeFrameStepping);
}
@@ -7160,20 +6989,14 @@ void CMainFrame::OnPlayPlay()
void CMainFrame::OnPlayPauseI()
{
- if(m_iMediaLoadState == MLS_LOADED)
- {
+ if(m_iMediaLoadState == MLS_LOADED) {
//SetAlwaysOnTop(AfxGetAppSettings().iOnTop);
- if(GetPlaybackMode() == PM_FILE)
- {
+ if(GetPlaybackMode() == PM_FILE) {
pMC->Pause();
- }
- else if(GetPlaybackMode() == PM_DVD)
- {
+ } else if(GetPlaybackMode() == PM_DVD) {
pMC->Pause();
- }
- else if(GetPlaybackMode() == PM_CAPTURE)
- {
+ } else if(GetPlaybackMode() == PM_CAPTURE) {
pMC->Pause();
}
@@ -7190,8 +7013,7 @@ 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)
- {
+ if(queue_ffdshow_support) {
CAutoLock lck(&g_ffdshowReceive);
return OnPlayPauseI();
}
@@ -7202,16 +7024,17 @@ void CMainFrame::OnPlayPause()
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);
+ 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)
- {
+ if(m_iMediaLoadState == MLS_LOADED) {
+ if(GetPlaybackMode() == PM_FILE) {
LONGLONG pos = 0;
pMS->SetPositions(&pos, AM_SEEKING_AbsolutePositioning, NULL, AM_SEEKING_NoPositioning);
pMC->Stop();
@@ -7221,16 +7044,13 @@ void CMainFrame::OnPlayStop()
//
// Note: WMPx may be using some undocumented interface to restart streaming.
- BeginEnumFilters(pGB, pEF, pBF)
- {
+ BeginEnumFilters(pGB, pEF, pBF) {
CComQIPtr<IAMNetworkStatus, &IID_IAMNetworkStatus> pAMNS = pBF;
CComQIPtr<IFileSourceFilter> pFSF = pBF;
- if(pAMNS && pFSF)
- {
+ if(pAMNS && pFSF) {
WCHAR* pFN = NULL;
AM_MEDIA_TYPE mt;
- if(SUCCEEDED(pFSF->GetCurFile(&pFN, &mt)) && pFN && *pFN)
- {
+ if(SUCCEEDED(pFSF->GetCurFile(&pFN, &mt)) && pFN && *pFN) {
pFSF->Load(pFN, NULL);
CoTaskMemFree(pFN);
}
@@ -7238,22 +7058,17 @@ void CMainFrame::OnPlayStop()
}
}
EndEnumFilters;
- }
- else if(GetPlaybackMode() == PM_DVD)
- {
+ } else if(GetPlaybackMode() == PM_DVD) {
pDVDC->SetOption(DVD_ResetOnStop, TRUE);
pMC->Stop();
pDVDC->SetOption(DVD_ResetOnStop, FALSE);
- }
- else if(GetPlaybackMode() == PM_CAPTURE)
- {
+ } else if(GetPlaybackMode() == PM_CAPTURE) {
pMC->Stop();
}
m_iSpeedLevel = 0;
- if(m_fFrameSteppingActive) // FIXME
- {
+ if(m_fFrameSteppingActive) { // FIXME
m_fFrameSteppingActive = false;
pBA->put_Volume(m_VolumeBeforeFrameStepping);
}
@@ -7263,19 +7078,18 @@ void CMainFrame::OnPlayStop()
m_nLoops = 0;
- if(m_hWnd)
- {
+ if(m_hWnd) {
KillTimersStop();
MoveVideoWindow();
- if(m_iMediaLoadState == MLS_LOADED)
- {
+ if(m_iMediaLoadState == MLS_LOADED) {
__int64 start, stop;
m_wndSeekBar.GetRange(start, stop);
GUID tf;
pMS->GetTimeFormat(&tf);
- if (GetPlaybackMode() != PM_CAPTURE)
+ if (GetPlaybackMode() != PM_CAPTURE) {
m_wndStatusBar.SetStatusTimer(m_wndSeekBar.GetPosReal(), stop, !!m_wndSubresyncBar.IsWindowVisible(), &tf);
+ }
SetAlwaysOnTop(AfxGetAppSettings().iOnTop);
}
@@ -7296,26 +7110,28 @@ void CMainFrame::OnUpdatePlayPauseStop(CCmdUI* pCmdUI)
bool fEnable = false;
- if(fs >= 0)
- {
- if(GetPlaybackMode() == PM_FILE || GetPlaybackMode() == PM_CAPTURE)
- {
+ 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)
- {
+ 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;
+ if(fs == State_Stopped && pCmdUI->m_nID == ID_PLAY_PAUSE) {
+ fEnable = false;
+ }
}
- }
- else if (pCmdUI->m_nID == ID_PLAY_PLAY && m_wndPlaylistBar.GetCount() > 0)
+ } else if (pCmdUI->m_nID == ID_PLAY_PLAY && m_wndPlaylistBar.GetCount() > 0) {
fEnable = true;
+ }
pCmdUI->Enable(fEnable);
}
@@ -7324,22 +7140,22 @@ void CMainFrame::OnPlayFramestep(UINT nID)
{
REFERENCE_TIME rt;
- if(pFS && m_fQuicktimeGraph)
- {
- if(GetMediaState() != State_Paused)
+ 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)
- {
- if(GetMediaState() != State_Paused && !queue_ffdshow_support)
+ } else if(pFS && nID == ID_PLAY_FRAMESTEP) {
+ 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)
+ if (m_nStepForwardCount == 0) {
pMS->GetCurrentPosition(&m_rtStepForwardStart);
+ }
m_fFrameSteppingActive = true;
@@ -7347,38 +7163,34 @@ void CMainFrame::OnPlayFramestep(UINT nID)
pBA->put_Volume(-10000);
pFS->Step(1, NULL);
- }
- else if(S_OK == pMS->IsFormatSupported(&TIME_FORMAT_FRAME))
- {
- if(GetMediaState() != State_Paused)
+ } 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--;
+ 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)
+ } 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)
- {
+ BeginEnumFilters(pGB, pEF, pBF) {
+ BeginEnumPins(pBF, pEP, pPin) {
AM_MEDIA_TYPE mt;
pPin->ConnectionMediaType(&mt);
- if(mt.majortype == MEDIATYPE_Video && mt.formattype == FORMAT_VideoInfo)
- {
+ if(mt.majortype == MEDIATYPE_Video && mt.formattype == FORMAT_VideoInfo) {
rtAvgTime = ((VIDEOINFOHEADER*)mt.pbFormat)->AvgTimePerFrame;
- }
- else if(mt.majortype == MEDIATYPE_Video && mt.formattype == FORMAT_VideoInfo2)
- {
+ } else if(mt.majortype == MEDIATYPE_Video && mt.formattype == FORMAT_VideoInfo2) {
rtAvgTime = ((VIDEOINFOHEADER2*)mt.pbFormat)->AvgTimePerFrame;
}
}
@@ -7387,18 +7199,18 @@ void CMainFrame::OnPlayFramestep(UINT nID)
EndEnumFilters;
// Exit of framestep forward : calculate the initial position
- if (m_nStepForwardCount != 0)
- {
+ if (m_nStepForwardCount != 0) {
pFS->CancelStep();
rt = m_rtStepForwardStart + m_nStepForwardCount*rtAvgTime;
m_nStepForwardCount = 0;
- }
- else
+ } else {
pMS->GetCurrentPosition(&rt);
- if(nID == ID_PLAY_FRAMESTEP)
+ }
+ if(nID == ID_PLAY_FRAMESTEP) {
rt += rtAvgTime;
- else if(nID == ID_PLAY_FRAMESTEPCANCEL)
+ } else if(nID == ID_PLAY_FRAMESTEPCANCEL) {
rt -= rtAvgTime;
+ }
pMS->SetPositions(&rt, AM_SEEKING_AbsolutePositioning, NULL, AM_SEEKING_NoPositioning);
}
}
@@ -7410,16 +7222,16 @@ void CMainFrame::OnUpdatePlayFramestep(CCmdUI* pCmdUI)
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))
+ !m_fLiveWM) {
+ if(S_OK == pMS->IsFormatSupported(&TIME_FORMAT_FRAME)) {
fEnable = true;
- else if(pCmdUI->m_nID == ID_PLAY_FRAMESTEP)
+ } 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)
+ } else if(pCmdUI->m_nID == ID_PLAY_FRAMESTEPCANCEL && pFS && pFS->CanStep(0, NULL) == S_OK) {
fEnable = true;
- else if(m_fQuicktimeGraph && pFS)
+ } else if(m_fQuicktimeGraph && pFS) {
fEnable = true;
+ }
}
pCmdUI->Enable(fEnable);
@@ -7438,10 +7250,14 @@ void CMainFrame::OnPlaySeek(UINT nID)
nID == ID_PLAY_SEEKFORWARDLARGE ? +10000i64*s.nJumpDistL :
0;
- if(!dt) return;
+ if(!dt) {
+ return;
+ }
// HACK: the custom graph should support frame based seeking instead
- if(m_fShockwaveGraph) dt /= 10000i64*100;
+ if(m_fShockwaveGraph) {
+ dt /= 10000i64*100;
+ }
SeekTo(m_wndSeekBar.GetPos() + dt);
}
@@ -7464,27 +7280,27 @@ 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);
+ if(j >= 0 && val >= rta[j]) {
+ return(j);
+ }
- while(i < j)
- {
+ while(i < j) {
int mid = (i + j) >> 1;
REFERENCE_TIME midt = rta[mid];
- if(val == midt)
- {
+ if(val == midt) {
ret = mid;
break;
- }
- else if(val < midt)
- {
+ } else if(val < midt) {
ret = -1;
- if(j == mid) mid--;
+ if(j == mid) {
+ mid--;
+ }
j = mid;
- }
- else if(val > midt)
- {
+ } else if(val > midt) {
ret = mid;
- if(i == mid) mid++;
+ if(i == mid) {
+ mid++;
+ }
i = mid;
}
}
@@ -7494,12 +7310,12 @@ static int rangebsearch(REFERENCE_TIME val, CAtlArray<REFERENCE_TIME>& rta)
void CMainFrame::OnPlaySeekKey(UINT nID)
{
- if(m_kfs.GetCount() > 0)
- {
+ if(m_kfs.GetCount() > 0) {
HRESULT hr;
- if(GetMediaState() == State_Stopped)
+ if(GetMediaState() == State_Stopped) {
SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
+ }
REFERENCE_TIME rtCurrent, rtDur;
hr = pMS->GetCurrentPosition(&rtCurrent);
@@ -7507,7 +7323,9 @@ void CMainFrame::OnPlaySeekKey(UINT nID)
int dec = 1;
int i = rangebsearch(rtCurrent, m_kfs);
- if(i > 0) dec = (UINT)max(min(rtCurrent - m_kfs[i-1], 10000000), 0);
+ if(i > 0) {
+ dec = (UINT)max(min(rtCurrent - m_kfs[i-1], 10000000), 0);
+ }
rtCurrent =
nID == ID_PLAY_SEEKKEYBACKWARD ? max(rtCurrent - dec, 0) :
@@ -7515,12 +7333,13 @@ void CMainFrame::OnPlaySeekKey(UINT nID)
i = rangebsearch(rtCurrent, m_kfs);
- if(nID == ID_PLAY_SEEKKEYBACKWARD)
+ if(nID == ID_PLAY_SEEKKEYBACKWARD) {
rtCurrent = m_kfs[max(i, 0)];
- else if(nID == ID_PLAY_SEEKKEYFORWARD && i < m_kfs.GetCount()-1)
+ } else if(nID == ID_PLAY_SEEKKEYFORWARD && i < m_kfs.GetCount()-1) {
rtCurrent = m_kfs[i+1];
- else
+ } 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
@@ -7542,11 +7361,13 @@ void CMainFrame::OnUpdatePlaySeek(CCmdUI* pCmdUI)
OAFilterState fs = GetMediaState();
- if(m_iMediaLoadState == MLS_LOADED && (fs == State_Paused || fs == State_Running))
- {
+ 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(GetPlaybackMode() == PM_DVD && (m_iDVDDomain != DVD_DOMAIN_Title || fs != State_Running)) {
+ fEnable = false;
+ } else if(GetPlaybackMode() == PM_CAPTURE) {
+ fEnable = false;
+ }
}
pCmdUI->Enable(fEnable);
@@ -7554,31 +7375,30 @@ void CMainFrame::OnUpdatePlaySeek(CCmdUI* pCmdUI)
void CMainFrame::OnPlayGoto()
{
- if ((m_iMediaLoadState != MLS_LOADED) || m_pFullscreenWnd->IsWindow())
+ if ((m_iMediaLoadState != MLS_LOADED) || m_pFullscreenWnd->IsWindow()) {
return;
+ }
REFTIME atpf = 0;
- if(FAILED(pBV->get_AvgTimePerFrame(&atpf)) || atpf < 0)
- {
+ if(FAILED(pBV->get_AvgTimePerFrame(&atpf)) || atpf < 0) {
atpf = 0;
- BeginEnumFilters(pGB, pEF, pBF)
- {
- if(atpf > 0) break;
+ BeginEnumFilters(pGB, pEF, pBF) {
+ if(atpf > 0) {
+ break;
+ }
- BeginEnumPins(pBF, pEP, pPin)
- {
- 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)
- {
+ 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)
- {
+ } else if(mt.majortype == MEDIATYPE_Video && mt.formattype == FORMAT_VideoInfo2) {
atpf = (REFTIME)((VIDEOINFOHEADER2*)mt.pbFormat)->AvgTimePerFrame / 10000000i64;
}
}
@@ -7588,7 +7408,9 @@ void CMainFrame::OnPlayGoto()
}
CGoToDlg dlg((int)(m_wndSeekBar.GetPos()/10000), atpf > 0 ? (float)(1.0/atpf) : 0);
- if(IDOK != dlg.DoModal() || dlg.m_time < 0) return;
+ if(IDOK != dlg.DoModal() || dlg.m_time < 0) {
+ return;
+ }
SeekTo(10000i64 * dlg.m_time);
}
@@ -7597,11 +7419,13 @@ void CMainFrame::OnUpdateGoto(CCmdUI* pCmdUI)
{
bool fEnable = false;
- if(m_iMediaLoadState == MLS_LOADED)
- {
+ 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(GetPlaybackMode() == PM_DVD && m_iDVDDomain != DVD_DOMAIN_Title) {
+ fEnable = false;
+ } else if(GetPlaybackMode() == PM_CAPTURE) {
+ fEnable = false;
+ }
}
pCmdUI->Enable(fEnable);
@@ -7609,13 +7433,14 @@ void CMainFrame::OnUpdateGoto(CCmdUI* pCmdUI)
void CMainFrame::OnPlayChangeRate(UINT nID)
{
- if(m_iMediaLoadState != MLS_LOADED)
+ if(m_iMediaLoadState != MLS_LOADED) {
return;
+ }
- if(GetPlaybackMode() == PM_CAPTURE)
- {
- if(GetMediaState() != State_Running)
+ if(GetPlaybackMode() == PM_CAPTURE) {
+ if(GetMediaState() != State_Running) {
SendMessage(WM_COMMAND, ID_PLAY_PLAY);
+ }
long lChannelMin = 0, lChannelMax = 0;
pAMTuner->ChannelMinMax(&lChannelMin, &lChannelMax);
@@ -7625,80 +7450,84 @@ void CMainFrame::OnPlayChangeRate(UINT nID)
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++;
+ // 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;
+ // if(lChannel > lChannelMax) lChannel = lChannelMin;
- if(lChannel < lChannelMin || lChannel > lChannelMax)
+ if(lChannel < lChannelMin || lChannel > lChannelMax) {
break;
+ }
- if(FAILED(pAMTuner->put_Channel(lChannel, AMTUNER_SUBCHAN_DEFAULT, AMTUNER_SUBCHAN_DEFAULT)))
+ 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);
+ } while(FALSE);
/* SUCCEEDED(pAMTuner->SignalPresent(&lSignalStrength))
&& (lSignalStrength != AMTUNER_SIGNALPRESENT || lFreqNew == lFreqOrg));*/
- }
- else
- {
+ } 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;
+ 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)
+ if((iNewSpeedLevel == -4) && (GetPlaybackMode() == PM_FILE)) {
+ if(GetMediaState() != State_Paused) {
SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
+ }
- if(GetMediaState() == State_Paused) hr = S_OK;
- }
- else
- {
+ if(GetMediaState() == State_Paused) {
+ hr = S_OK;
+ }
+ } else {
double dRate = 1.0;
- if(GetMediaState() != State_Running)
+ if(GetMediaState() != State_Running) {
SendMessage(WM_COMMAND, ID_PLAY_PLAY);
+ }
- if(GetPlaybackMode() == PM_FILE)
- {
+ if(GetPlaybackMode() == PM_FILE) {
dRate = pow(2.0, iNewSpeedLevel >= -3 ? iNewSpeedLevel : (-iNewSpeedLevel - 8));
- if(fabs(dRate - 1.0) < 0.01) dRate = 1.0;
+ if(fabs(dRate - 1.0) < 0.01) {
+ dRate = 1.0;
+ }
hr = pMS->SetRate(dRate);
- }
- else if(GetPlaybackMode() == PM_DVD)
- {
+ } else if(GetPlaybackMode() == PM_DVD) {
dRate = pow(2.0, abs(iNewSpeedLevel));
- if(iNewSpeedLevel >= 0)
+ if(iNewSpeedLevel >= 0) {
hr = pDVDC->PlayForwards(dRate, DVD_CMD_FLAG_Block, NULL);
- else
+ } else {
hr = pDVDC->PlayBackwards(dRate, DVD_CMD_FLAG_Block, NULL);
+ }
}
- if(SUCCEEDED(hr))
- {
+ if(SUCCEEDED(hr)) {
CString strMessage;
m_iSpeedLevel = iNewSpeedLevel;
- if (dRate == 1.0)
+ if (dRate == 1.0) {
m_OSD.DisplayMessage (OSD_TOPRIGHT, _T("Play"));
- else
- {
+ } else {
strMessage.Format (_T("%s x %.01f"), (iNewSpeedLevel > 0)?_T(">"):_T("<"), fabs(dRate));
m_OSD.DisplayMessage (OSD_TOPRIGHT, strMessage);
}
@@ -7712,18 +7541,25 @@ void CMainFrame::OnUpdatePlayChangeRate(CCmdUI* pCmdUI)
{
bool fEnable = false;
- if(m_iMediaLoadState == MLS_LOADED)
- {
+ 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;
+ 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);
@@ -7731,25 +7567,25 @@ void CMainFrame::OnUpdatePlayChangeRate(CCmdUI* pCmdUI)
void CMainFrame::OnPlayResetRate()
{
- if(m_iMediaLoadState != MLS_LOADED)
+ if(m_iMediaLoadState != MLS_LOADED) {
return;
+ }
HRESULT hr = E_FAIL;
- if(GetMediaState() != State_Running)
+ if(GetMediaState() != State_Running) {
SendMessage(WM_COMMAND, ID_PLAY_PLAY);
+ }
- if(GetPlaybackMode() == PM_FILE)
- {
+ if(GetPlaybackMode() == PM_FILE) {
hr = pMS->SetRate(1.0);
- }
- else if(GetPlaybackMode() == PM_DVD)
- {
+ } else if(GetPlaybackMode() == PM_DVD) {
hr = pDVDC->PlayForwards(1.0, DVD_CMD_FLAG_Block, NULL);
}
- if(SUCCEEDED(hr))
+ if(SUCCEEDED(hr)) {
m_iSpeedLevel = 0;
+ }
}
void CMainFrame::OnUpdatePlayResetRate(CCmdUI* pCmdUI)
@@ -7760,8 +7596,7 @@ void CMainFrame::OnUpdatePlayResetRate(CCmdUI* pCmdUI)
void CMainFrame::SetAudioDelay(REFERENCE_TIME rtShift)
{
- if(CComQIPtr<IAudioSwitcherFilter> pASF = FindFilter(__uuidof(CAudioSwitcherFilter), pGB))
- {
+ if(CComQIPtr<IAudioSwitcherFilter> pASF = FindFilter(__uuidof(CAudioSwitcherFilter), pGB)) {
pASF->SetAudioTimeShift(rtShift);
CString str;
@@ -7773,8 +7608,7 @@ void CMainFrame::SetAudioDelay(REFERENCE_TIME rtShift)
void CMainFrame::SetSubtitleDelay(int delay_ms)
{
- if(m_pCAP)
- {
+ if(m_pCAP) {
m_pCAP->SetSubtitleDelay(delay_ms);
CString strSubDelay;
@@ -7786,8 +7620,7 @@ void CMainFrame::SetSubtitleDelay(int delay_ms)
void CMainFrame::OnPlayChangeAudDelay(UINT nID)
{
- if(CComQIPtr<IAudioSwitcherFilter> pASF = FindFilter(__uuidof(CAudioSwitcherFilter), pGB))
- {
+ if(CComQIPtr<IAudioSwitcherFilter> pASF = FindFilter(__uuidof(CAudioSwitcherFilter), pGB)) {
REFERENCE_TIME rtShift = pASF->GetAudioTimeShift();
rtShift +=
nID == ID_PLAY_INCAUDDELAY ? 100000 :
@@ -7805,26 +7638,23 @@ void CMainFrame::OnUpdatePlayChangeAudDelay(CCmdUI* pCmdUI)
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];
CComPropertySheet ps(ResStr(IDS_PROPSHEET_PROPERTIES), GetModalParent());
- if(CComQIPtr<ISpecifyPropertyPages> pSPP = pUnk)
- {
+ if(CComQIPtr<ISpecifyPropertyPages> pSPP = pUnk) {
ps.AddPages(pSPP);
}
- if(CComQIPtr<IBaseFilter> pBF = pUnk)
- {
+ if(CComQIPtr<IBaseFilter> pBF = pUnk) {
HRESULT hr;
CComPtr<IPropertyPage> pPP = DNew CInternalPropertyPageTempl<CPinInfoWnd>(NULL, &hr);
ps.AddPage(pPP, pBF);
}
- if(ps.GetPageCount() > 0)
- {
+ if(ps.GetPageCount() > 0) {
ps.DoModal();
OpenSetupStatusBar();
}
@@ -7835,8 +7665,7 @@ void CMainFrame::OnUpdatePlayFilters(CCmdUI* pCmdUI)
pCmdUI->Enable(!m_fCapturing);
}
-enum
-{
+enum {
ID_SHADERS_OFF = ID_SHADERS_START,
ID_SHADERS_COMBINE,
ID_SHADERS_EDIT,
@@ -7849,34 +7678,28 @@ enum
void CMainFrame::OnPlayShaders(UINT nID)
{
- if(nID == ID_SHADERS_EDIT)
- {
+ if(nID == ID_SHADERS_EDIT) {
ShowControlBar(&m_wndShaderEditorBar, TRUE, TRUE);
return;
}
- if(!m_pCAP) return;
+ if(!m_pCAP) {
+ return;
+ }
- if(nID == ID_SHADERS_OFF)
- {
+ if(nID == ID_SHADERS_OFF) {
m_shaderlabels.RemoveAll();
- }
- else if(nID == ID_SHADERS_OFFSCR)
- {
+ } else if(nID == ID_SHADERS_OFFSCR) {
m_shaderlabelsScreenSpace.RemoveAll();
- }
- else if(nID == ID_SHADERS_COMBINE)
- {
- if(IDOK != CShaderCombineDlg(m_shaderlabels, GetModalParent(), false).DoModal())
+ } else if(nID == ID_SHADERS_COMBINE) {
+ if(IDOK != CShaderCombineDlg(m_shaderlabels, GetModalParent(), false).DoModal()) {
return;
- }
- else if(nID == ID_SHADERS_COMBINESCR)
- {
- if(IDOK != CShaderCombineDlg(m_shaderlabelsScreenSpace, GetModalParent(), true).DoModal())
+ }
+ } else if(nID == ID_SHADERS_COMBINESCR) {
+ if(IDOK != CShaderCombineDlg(m_shaderlabelsScreenSpace, GetModalParent(), true).DoModal()) {
return;
- }
- else if(nID >= ID_SHADERS_DYNAMIC)
- {
+ }
+ } else if(nID >= ID_SHADERS_DYNAMIC) {
MENUITEMINFO mii;
memset(&mii, 0, sizeof(mii));
mii.cbSize = sizeof(mii);
@@ -7892,42 +7715,40 @@ void CMainFrame::OnPlayShaders(UINT nID)
void CMainFrame::OnUpdatePlayShaders(CCmdUI* pCmdUI)
{
- if(pCmdUI->m_nID >= ID_SHADERS_START)
- {
- if (pCmdUI->m_nID >= ID_SHADERS_STARTSCR && pCmdUI->m_nID < ID_SHADERS_ENDSCR )
+ if(pCmdUI->m_nID >= ID_SHADERS_START) {
+ if (pCmdUI->m_nID >= ID_SHADERS_STARTSCR && pCmdUI->m_nID < ID_SHADERS_ENDSCR ) {
pCmdUI->Enable(!!m_pCAP2);
- else
+ } else {
pCmdUI->Enable(!!m_pCAP);
+ }
- switch(pCmdUI->m_nID)
- {
- case ID_SHADERS_OFF:
- pCmdUI->SetRadio(m_shaderlabels.IsEmpty());
- break;
- case ID_SHADERS_OFFSCR:
- pCmdUI->SetRadio(m_shaderlabelsScreenSpace.IsEmpty());
- break;
- case ID_SHADERS_COMBINE:
- pCmdUI->SetRadio(m_shaderlabels.GetCount() > 1);
- break;
- case ID_SHADERS_COMBINESCR:
- pCmdUI->SetRadio(m_shaderlabelsScreenSpace.GetCount() > 0);
- break;
- case ID_SHADERS_EDIT:
- pCmdUI->Enable(TRUE);
- break;
- default:
- {
- MENUITEMINFO mii;
- memset(&mii, 0, sizeof(mii));
- mii.cbSize = sizeof(mii);
- mii.fMask = MIIM_DATA;
- m_shaders.GetMenuItemInfo(pCmdUI->m_nID, &mii);
+ switch(pCmdUI->m_nID) {
+ case ID_SHADERS_OFF:
+ pCmdUI->SetRadio(m_shaderlabels.IsEmpty());
+ break;
+ case ID_SHADERS_OFFSCR:
+ pCmdUI->SetRadio(m_shaderlabelsScreenSpace.IsEmpty());
+ break;
+ case ID_SHADERS_COMBINE:
+ pCmdUI->SetRadio(m_shaderlabels.GetCount() > 1);
+ break;
+ case ID_SHADERS_COMBINESCR:
+ pCmdUI->SetRadio(m_shaderlabelsScreenSpace.GetCount() > 0);
+ break;
+ case ID_SHADERS_EDIT:
+ pCmdUI->Enable(TRUE);
+ break;
+ default: {
+ MENUITEMINFO mii;
+ memset(&mii, 0, sizeof(mii));
+ mii.cbSize = sizeof(mii);
+ mii.fMask = MIIM_DATA;
+ m_shaders.GetMenuItemInfo(pCmdUI->m_nID, &mii);
- pCmdUI->SetRadio(m_shaderlabels.GetCount() == 1
- && m_shaderlabels.GetHead() == ((AppSettings::Shader*)mii.dwItemData)->label);
- }
- break;
+ pCmdUI->SetRadio(m_shaderlabels.GetCount() == 1
+ && m_shaderlabels.GetHead() == ((AppSettings::Shader*)mii.dwItemData)->label);
+ }
+ break;
}
}
}
@@ -7937,14 +7758,13 @@ void CMainFrame::OnPlayAudio(UINT 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(!pSS) {
+ pSS = FindFilter(L"{D3CD7858-971A-4838-ACEC-40CA5D529DC8}", pGB);
+ }
- if(i == -1)
- {
+ if(i == -1) {
ShowOptions(CPPageAudioSwitcher::IDD);
- }
- else if(i >= 0 && pSS)
- {
+ } 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);
}
@@ -7956,26 +7776,28 @@ void CMainFrame::OnUpdatePlayAudio(CCmdUI* pCmdUI)
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(!pSS) {
+ pSS = FindFilter(L"{D3CD7858-971A-4838-ACEC-40CA5D529DC8}", pGB);
+ }
/*if(i == -1)
{
// TODO****
}
else*/
- if(i >= 0 && pSS)
- {
+ 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
- {
+ 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);
}
}
@@ -7985,37 +7807,31 @@ 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)
- {
+ if(i == -5) {
// options
ShowOptions(CPPageSubtitles::IDD);
- }
- else if(i == -4)
- {
+ } else if(i == -4) {
// styles
int i = m_iSubtitleSel;
POSITION pos = m_pSubStreams.GetHeadPosition();
- while(pos && i >= 0)
- {
+ while(pos && i >= 0) {
CComPtr<ISubStream> pSubStream = m_pSubStreams.GetNext(pos);
- if(i < pSubStream->GetStreamCount())
- {
+ if(i < pSubStream->GetStreamCount()) {
CLSID clsid;
- if(FAILED(pSubStream->GetClassID(&clsid)))
+ if(FAILED(pSubStream->GetClassID(&clsid))) {
continue;
+ }
- if(clsid == __uuidof(CRenderedTextSubtitle))
- {
+ 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++)
- {
+ for(int i = 0; pos; i++) {
CString key;
STSStyle* val;
pRTS->m_styles.GetNextAssoc(pos, key, val);
@@ -8028,15 +7844,18 @@ void CMainFrame::OnPlaySubtitles(UINT nID)
CString m_style = ResStr(IDS_SUBTITLES_STYLES);
int i = m_style.Find(_T("&"));
- if(i!=-1 ) m_style.Delete(i, 1);
+ if(i!=-1 ) {
+ m_style.Delete(i, 1);
+ }
CPropertySheet dlg(m_style, GetModalParent());
- for(int i = 0; i < (int)pages.GetCount(); i++)
+ 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++)
+ if(dlg.DoModal() == IDOK) {
+ for(int j = 0; j < (int)pages.GetCount(); j++) {
pages[j]->GetStyle(*styles[j]);
+ }
UpdateSubtitle(false, false);
}
@@ -8046,28 +7865,23 @@ void CMainFrame::OnPlaySubtitles(UINT nID)
i -= pSubStream->GetStreamCount();
}
- }
- else if(i == -3)
- {
+ } else if(i == -3) {
// reload
ReloadSubtitle();
- }
- else if(i == -2)
- {
+ } else if(i == -2) {
// enable
- if(m_iSubtitleSel == -1) m_iSubtitleSel = 0;
- else m_iSubtitleSel ^= (1<<31);
+ if(m_iSubtitleSel == -1) {
+ m_iSubtitleSel = 0;
+ } else {
+ m_iSubtitleSel ^= (1<<31);
+ }
UpdateSubtitle();
- }
- else if(i == -1)
- {
+ } else if(i == -1) {
// override default style
// TODO: default subtitles style toggle here
AfxGetAppSettings().fUseDefaultSubtitlesStyle = !AfxGetAppSettings().fUseDefaultSubtitlesStyle;
UpdateSubtitle();
- }
- else if(i >= 0)
- {
+ } else if(i >= 0) {
// this is an actual item from the subtitles list
m_iSubtitleSel = i;
UpdateSubtitle();
@@ -8083,26 +7897,23 @@ void CMainFrame::OnUpdatePlaySubtitles(CCmdUI* pCmdUI)
pCmdUI->Enable(m_pCAP && !m_fAudioOnly);
- if(i == -4)
- {
+ if(i == -4) {
// styles
pCmdUI->Enable(FALSE);
int i = m_iSubtitleSel;
POSITION pos = m_pSubStreams.GetHeadPosition();
- while(pos && i >= 0)
- {
+ while(pos && i >= 0) {
CComPtr<ISubStream> pSubStream = m_pSubStreams.GetNext(pos);
- if(i < pSubStream->GetStreamCount())
- {
+ if(i < pSubStream->GetStreamCount()) {
CLSID clsid;
- if(FAILED(pSubStream->GetClassID(&clsid)))
+ if(FAILED(pSubStream->GetClassID(&clsid))) {
continue;
+ }
- if(clsid == __uuidof(CRenderedTextSubtitle))
- {
+ if(clsid == __uuidof(CRenderedTextSubtitle)) {
pCmdUI->Enable(TRUE);
break;
}
@@ -8110,21 +7921,15 @@ void CMainFrame::OnUpdatePlaySubtitles(CCmdUI* pCmdUI)
i -= pSubStream->GetStreamCount();
}
- }
- else if(i == -2)
- {
+ } else if(i == -2) {
// enabled
pCmdUI->SetCheck(AfxGetAppSettings().fEnableSubtitles);
- }
- else if(i == -1)
- {
+ } 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)
- {
+ } else if(i >= 0) {
pCmdUI->SetRadio(i == abs(m_iSubtitleSel));
}
}
@@ -8134,9 +7939,12 @@ 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)))
+ while(i > 0 && pAMSS == m_ssarray[i-1]) {
+ i--;
+ }
+ if(FAILED(pAMSS->Enable(nID-i, AMSTREAMSELECTENABLE_ENABLE))) {
MessageBeep((UINT)-1);
+ }
OpenSetupStatusBar();
}
@@ -8147,28 +7955,30 @@ void CMainFrame::OnUpdatePlayLanguage(CCmdUI* pCmdUI)
nID -= ID_FILTERSTREAMS_SUBITEM_START;
CComPtr<IAMStreamSelect> pAMSS = m_ssarray[nID];
UINT i = nID;
- while(i > 0 && pAMSS == m_ssarray[i-1]) i--;
+ 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);
+ 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)
- {
+ 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)
- {
+ if(m_wndToolBar.Volume == -10000) {
strVolume.Format(ResStr(IDS_VOLUME_OSD), 0);
- }
- else
- {
+ } else {
strVolume.Format(ResStr(IDS_VOLUME_OSD), m_wndToolBar.m_volctrl.GetPos());
}
m_OSD.DisplayMessage(OSD_TOPLEFT, strVolume);
@@ -8183,26 +7993,24 @@ void CMainFrame::OnPlayVolumeBoost(UINT nID)
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;
+ 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 = (float)i/10;
- if(CComQIPtr<IAudioSwitcherFilter> pASF = FindFilter(__uuidof(CAudioSwitcherFilter), pGB))
- {
+ if(CComQIPtr<IAudioSwitcherFilter> pASF = FindFilter(__uuidof(CAudioSwitcherFilter), pGB)) {
bool fNormalize, fNormalizeRecover;
float boost;
pASF->GetNormalizeBoost(fNormalize, fNormalizeRecover, boost);
@@ -8221,35 +8029,34 @@ void CMainFrame::OnAfterplayback(UINT nID)
s.nCLSwitches &= ~CLSW_AFTERPLAYBACK_MASK;
- switch(nID)
- {
- case ID_AFTERPLAYBACK_NEXT :
- s.fNextInDirAfterPlayback = true;
- s.fExitAfterPlayback = false;
- break;
- case ID_AFTERPLAYBACK_EXIT :
- s.fExitAfterPlayback = true;
- s.fNextInDirAfterPlayback = false;
- break;
- case ID_AFTERPLAYBACK_DONOTHING:
- s.fExitAfterPlayback = false;
- s.fNextInDirAfterPlayback = false;
- break;
- case ID_AFTERPLAYBACK_CLOSE:
- s.nCLSwitches |= CLSW_CLOSE;
- break;
- case ID_AFTERPLAYBACK_STANDBY:
- s.nCLSwitches |= CLSW_STANDBY;
- break;
- case ID_AFTERPLAYBACK_HIBERNATE:
- s.nCLSwitches |= CLSW_HIBERNATE;
- break;
- case ID_AFTERPLAYBACK_SHUTDOWN:
- s.nCLSwitches |= CLSW_SHUTDOWN;
- break;
- case ID_AFTERPLAYBACK_LOGOFF:
- s.nCLSwitches |= CLSW_LOGOFF;
- break;
+ switch(nID) {
+ case ID_AFTERPLAYBACK_NEXT :
+ s.fNextInDirAfterPlayback = true;
+ s.fExitAfterPlayback = false;
+ break;
+ case ID_AFTERPLAYBACK_EXIT :
+ s.fExitAfterPlayback = true;
+ s.fNextInDirAfterPlayback = false;
+ break;
+ case ID_AFTERPLAYBACK_DONOTHING:
+ s.fExitAfterPlayback = false;
+ s.fNextInDirAfterPlayback = false;
+ break;
+ case ID_AFTERPLAYBACK_CLOSE:
+ s.nCLSwitches |= CLSW_CLOSE;
+ break;
+ case ID_AFTERPLAYBACK_STANDBY:
+ s.nCLSwitches |= CLSW_STANDBY;
+ break;
+ case ID_AFTERPLAYBACK_HIBERNATE:
+ s.nCLSwitches |= CLSW_HIBERNATE;
+ break;
+ case ID_AFTERPLAYBACK_SHUTDOWN:
+ s.nCLSwitches |= CLSW_SHUTDOWN;
+ break;
+ case ID_AFTERPLAYBACK_LOGOFF:
+ s.nCLSwitches |= CLSW_LOGOFF;
+ break;
}
}
@@ -8259,32 +8066,31 @@ void CMainFrame::OnUpdateAfterplayback(CCmdUI* pCmdUI)
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_DONOTHING:
- fChecked = (!s.fExitAfterPlayback) && (!s.fNextInDirAfterPlayback);
- break;
+ 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_DONOTHING:
+ fChecked = (!s.fExitAfterPlayback) && (!s.fNextInDirAfterPlayback);
+ break;
}
pCmdUI->SetRadio(fChecked);
@@ -8293,12 +8099,14 @@ void CMainFrame::OnUpdateAfterplayback(CCmdUI* pCmdUI)
// navigate
void CMainFrame::OnNavigateSkip(UINT nID)
{
- if(GetPlaybackMode() == PM_FILE)
- {
- if(GetPlaybackMode() == PM_FILE) SetupChapters();
+ if(GetPlaybackMode() == PM_FILE) {
+ if(GetPlaybackMode() == PM_FILE) {
+ SetupChapters();
+ }
- if(DWORD nChapters = m_pCB->ChapGetCount())
- {
+ flast_nID = nID;
+
+ if(DWORD nChapters = m_pCB->ChapGetCount()) {
REFERENCE_TIME rtCur;
pMS->GetCurrentPosition(&rtCur);
@@ -8306,20 +8114,18 @@ void CMainFrame::OnNavigateSkip(UINT nID)
CComBSTR name;
long i = 0;
- if(nID == ID_NAVIGATE_SKIPBACK)
- {
+ if(nID == ID_NAVIGATE_SKIPBACK) {
rt -= 30000000;
i = m_pCB->ChapLookup(&rt, &name);
- }
- else if(nID == ID_NAVIGATE_SKIPFORWARD)
- {
+ } else if(nID == ID_NAVIGATE_SKIPFORWARD) {
i = m_pCB->ChapLookup(&rt, &name) + 1;
name.Empty();
- if(i < nChapters) m_pCB->ChapGet(i, &rt, &name);
+ if(i < nChapters) {
+ m_pCB->ChapGet(i, &rt, &name);
+ }
}
- if(i >= 0 && i < nChapters)
- {
+ if(i >= 0 && i < nChapters) {
SeekTo(rt);
SendStatusMessage(ResStr(IDS_AG_CHAPTER2) + CString(name), 3000);
@@ -8333,33 +8139,29 @@ void CMainFrame::OnNavigateSkip(UINT nID)
}
- if(m_wndPlaylistBar.GetCount() != 1)
- {
- if(nID == ID_NAVIGATE_SKIPBACK)
+ if(m_wndPlaylistBar.GetCount() != 1) {
+ if(nID == ID_NAVIGATE_SKIPBACK) {
SendMessage(WM_COMMAND, ID_NAVIGATE_SKIPBACKPLITEM);
- else if(nID == ID_NAVIGATE_SKIPFORWARD)
+ } else if(nID == ID_NAVIGATE_SKIPFORWARD) {
SendMessage(WM_COMMAND, ID_NAVIGATE_SKIPFORWARDPLITEM);
- }
- else if ((m_wndPlaylistBar.GetCount() == 1) && !AfxGetAppSettings().fDontUseSearchInFolder)
- {
- if(nID == ID_NAVIGATE_SKIPBACK)
- {
- if (!SearchInDir(false))
- m_OSD.DisplayMessage(OSD_TOPLEFT, ResStr(IDS_FIRST_IN_FOLDER));
}
- else if(nID == ID_NAVIGATE_SKIPFORWARD)
- {
- if (!SearchInDir(true))
+ } else if ((m_wndPlaylistBar.GetCount() == 1) && !AfxGetAppSettings().fDontUseSearchInFolder) {
+ if(nID == ID_NAVIGATE_SKIPBACK) {
+ if (!SearchInDir(false)) {
+ m_OSD.DisplayMessage(OSD_TOPLEFT, ResStr(IDS_FIRST_IN_FOLDER));
+ }
+ } else if(nID == ID_NAVIGATE_SKIPFORWARD) {
+ if (!SearchInDir(true)) {
m_OSD.DisplayMessage(OSD_TOPLEFT, ResStr(IDS_LAST_IN_FOLDER));
+ }
}
}
- }
- else if(GetPlaybackMode() == PM_DVD)
- {
+ } else if(GetPlaybackMode() == PM_DVD) {
m_iSpeedLevel = 0;
- if(GetMediaState() != State_Running)
+ if(GetMediaState() != State_Running) {
SendMessage(WM_COMMAND, ID_PLAY_PLAY);
+ }
ULONG ulNumOfVolumes, ulVolume;
DVD_DISC_SIDE Side;
@@ -8372,42 +8174,34 @@ void CMainFrame::OnNavigateSkip(UINT nID)
ULONG ulNumOfChapters = 0;
pDVDI->GetNumberOfChapters(Location.TitleNum, &ulNumOfChapters);
- if(nID == ID_NAVIGATE_SKIPBACK)
- {
- if(Location.ChapterNum == 1 && Location.TitleNum > 1)
- {
+ 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
- {
+ } else {
ULONG tsec = (Location.TimeCode.bHours * 3600)
+ (Location.TimeCode.bMinutes * 60)
+ (Location.TimeCode.bSeconds);
ULONG diff = 0;
- if ( m_lChapterStartTime != 0xFFFFFFFF && tsec > m_lChapterStartTime )
+ if ( m_lChapterStartTime != 0xFFFFFFFF && tsec > m_lChapterStartTime ) {
diff = tsec - m_lChapterStartTime;
+ }
// Restart the chapter if more than 7 seconds have passed
- if ( diff <= 7 )
+ if ( diff <= 7 ) {
pDVDC->PlayPrevChapter(DVD_CMD_FLAG_Block|DVD_CMD_FLAG_Flush, NULL);
- else
+ } 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)
- {
+ } 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
- {
+ } else {
pDVDC->PlayNextChapter(DVD_CMD_FLAG_Block|DVD_CMD_FLAG_Flush, NULL);
}
}
- if((pDVDI->GetCurrentLocation(&Location) == S_OK))
- {
+ if((pDVDI->GetCurrentLocation(&Location) == S_OK)) {
pDVDI->GetNumberOfChapters(Location.TitleNum, &ulNumOfChapters);
CString m_strTitle;
m_strTitle.Format(IDS_AG_TITLE, Location.TitleNum);
@@ -8418,44 +8212,40 @@ void CMainFrame::OnNavigateSkip(UINT nID)
if(stop>0)
m_strOSD.Format(_T("%02d:%02d:%02d/%s %s, %s: %d/%d"), Location.TimeCode.bHours, Location.TimeCode.bMinutes, Location.TimeCode.bSeconds,
DVDtimeToString(RT2HMSF(stop)), m_strTitle, ResStr(IDS_AG_CHAPTER2), Location.ChapterNum, ulNumOfChapters);
- else
+ else {
m_strOSD.Format(_T("%s, %s: %d/%d"), 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)
- {
+ /*
+ 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)
- {
+ if (pTun) {
int nCurrentChannel;
AppSettings& s = AfxGetAppSettings();
nCurrentChannel = s.nDVBLastChannel;
- if(nID == ID_NAVIGATE_SKIPBACK)
- {
+ if(nID == ID_NAVIGATE_SKIPBACK) {
pTun->SetChannel (nCurrentChannel - 1);
DisplayCurrentChannelOSD();
- if (m_wndNavigationBar.IsVisible())
+ if (m_wndNavigationBar.IsVisible()) {
m_wndNavigationBar.m_navdlg.UpdatePos(nCurrentChannel - 1);
- }
- else if(nID == ID_NAVIGATE_SKIPFORWARD)
- {
+ }
+ } else if(nID == ID_NAVIGATE_SKIPFORWARD) {
pTun->SetChannel (nCurrentChannel + 1);
DisplayCurrentChannelOSD();
- if (m_wndNavigationBar.IsVisible())
+ if (m_wndNavigationBar.IsVisible()) {
m_wndNavigationBar.m_navdlg.UpdatePos(nCurrentChannel + 1);
+ }
}
}
@@ -8467,7 +8257,7 @@ void CMainFrame::OnNavigateSkip(UINT nID)
void CMainFrame::OnUpdateNavigateSkip(CCmdUI* pCmdUI)
{
// moved to the timer callback function, that runs less frequent
-// if(GetPlaybackMode() == PM_FILE) SetupChapters();
+ // if(GetPlaybackMode() == PM_FILE) SetupChapters();
pCmdUI->Enable(m_iMediaLoadState == MLS_LOADED
&& ((GetPlaybackMode() == PM_DVD
@@ -8480,21 +8270,14 @@ void CMainFrame::OnUpdateNavigateSkip(CCmdUI* pCmdUI)
void CMainFrame::OnNavigateSkipPlaylistItem(UINT nID)
{
- if(GetPlaybackMode() == PM_FILE || GetPlaybackMode() == PM_CAPTURE)
- {
- if(m_wndPlaylistBar.GetCount() == 1)
- {
+ if(GetPlaybackMode() == PM_FILE || GetPlaybackMode() == PM_CAPTURE) {
+ if(m_wndPlaylistBar.GetCount() == 1) {
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_SKIPBACKPLITEM)
- {
+ } else {
+ if(nID == ID_NAVIGATE_SKIPBACKPLITEM) {
m_wndPlaylistBar.SetPrev();
- }
- else if(nID == ID_NAVIGATE_SKIPFORWARDPLITEM)
- {
+ } else if(nID == ID_NAVIGATE_SKIPFORWARDPLITEM) {
m_wndPlaylistBar.SetNext();
}
@@ -8513,13 +8296,15 @@ void CMainFrame::OnNavigateMenu(UINT nID)
{
nID -= ID_NAVIGATE_TITLEMENU;
- if(m_iMediaLoadState != MLS_LOADED || GetPlaybackMode() != PM_DVD)
+ if(m_iMediaLoadState != MLS_LOADED || GetPlaybackMode() != PM_DVD) {
return;
+ }
m_iSpeedLevel = 0;
- if(GetMediaState() != State_Running)
+ 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);
}
@@ -8530,8 +8315,7 @@ void CMainFrame::OnUpdateNavigateMenu(CCmdUI* pCmdUI)
ULONG ulUOPs;
if(m_iMediaLoadState != MLS_LOADED || GetPlaybackMode() != PM_DVD
- || FAILED(pDVDI->GetCurrentUOPS(&ulUOPs)))
- {
+ || FAILED(pDVDI->GetCurrentUOPS(&ulUOPs))) {
pCmdUI->Enable(FALSE);
return;
}
@@ -8543,35 +8327,27 @@ void CMainFrame::OnNavigateAudio(UINT nID)
{
nID -= ID_NAVIGATE_AUDIO_SUBITEM_START;
- if(GetPlaybackMode() == PM_FILE || (GetPlaybackMode() == PM_CAPTURE && AfxGetAppSettings().iDefaultCaptureDevice == 1))
- {
+ if(GetPlaybackMode() == PM_FILE || (GetPlaybackMode() == PM_CAPTURE && AfxGetAppSettings().iDefaultCaptureDevice == 1)) {
OnNavStreamSelectSubMenu(nID, 1);
- }
- else if(GetPlaybackMode() == PM_DVD)
- {
+ } 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))
- {
+ if(GetPlaybackMode() == PM_FILE || (GetPlaybackMode() == PM_CAPTURE && AfxGetAppSettings().iDefaultCaptureDevice == 1)) {
OnNavStreamSelectSubMenu(nID - ID_NAVIGATE_SUBP_SUBITEM_START, 2);
- }
- else if(GetPlaybackMode() == PM_DVD)
- {
+ } else if(GetPlaybackMode() == PM_DVD) {
int i = (int)nID - (1 + ID_NAVIGATE_SUBP_SUBITEM_START);
- if(i == -1)
- {
+ if(i == -1) {
ULONG ulStreamsAvailable, ulCurrentStream;
BOOL bIsDisabled;
- if(SUCCEEDED(pDVDI->GetCurrentSubpicture(&ulStreamsAvailable, &ulCurrentStream, &bIsDisabled)))
+ if(SUCCEEDED(pDVDI->GetCurrentSubpicture(&ulStreamsAvailable, &ulCurrentStream, &bIsDisabled))) {
pDVDC->SetSubpictureState(bIsDisabled, DVD_CMD_FLAG_Block, NULL);
- }
- else
- {
+ }
+ } else {
pDVDC->SelectSubpictureStream(i, DVD_CMD_FLAG_Block, NULL);
pDVDC->SetSubpictureState(TRUE, DVD_CMD_FLAG_Block, NULL);
}
@@ -8582,12 +8358,9 @@ void CMainFrame::OnNavigateAngle(UINT nID)
{
nID -= ID_NAVIGATE_ANGLE_SUBITEM_START;
- if(GetPlaybackMode() == PM_FILE)
- {
+ if(GetPlaybackMode() == PM_FILE) {
OnNavStreamSelectSubMenu(nID, 0);
- }
- else if(GetPlaybackMode() == PM_DVD)
- {
+ } else if(GetPlaybackMode() == PM_DVD) {
pDVDC->SelectAngle(nID+1, DVD_CMD_FLAG_Block, NULL);
}
}
@@ -8596,14 +8369,11 @@ void CMainFrame::OnNavigateChapters(UINT nID)
{
nID -= ID_NAVIGATE_CHAP_SUBITEM_START;
- if(GetPlaybackMode() == PM_FILE)
- {
- if((int)nID >= 0 && nID < m_pCB->ChapGetCount())
- {
+ if(GetPlaybackMode() == PM_FILE) {
+ if((int)nID >= 0 && nID < m_pCB->ChapGetCount()) {
REFERENCE_TIME rt;
CComBSTR name;
- if(SUCCEEDED(m_pCB->ChapGet(nID, &rt, &name)))
- {
+ if(SUCCEEDED(m_pCB->ChapGet(nID, &rt, &name))) {
SeekTo(rt);
SendStatusMessage(ResStr(IDS_AG_CHAPTER2) + CString(name), 3000);
@@ -8619,14 +8389,11 @@ void CMainFrame::OnNavigateChapters(UINT nID)
nID -= m_pCB->ChapGetCount();
if((int)nID >= 0 && (int)nID < m_wndPlaylistBar.GetCount()
- && m_wndPlaylistBar.GetSelIdx() != (int)nID)
- {
+ && m_wndPlaylistBar.GetSelIdx() != (int)nID) {
m_wndPlaylistBar.SetSelIdx(nID);
OpenCurPlaylistItem();
}
- }
- else if(GetPlaybackMode() == PM_DVD)
- {
+ } else if(GetPlaybackMode() == PM_DVD) {
ULONG ulNumOfVolumes, ulVolume;
DVD_DISC_SIDE Side;
ULONG ulNumOfTitles = 0;
@@ -8640,23 +8407,18 @@ void CMainFrame::OnNavigateChapters(UINT nID)
nID++;
- if(nID > 0 && nID <= ulNumOfTitles)
- {
+ if(nID > 0 && 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
- {
+ } else {
nID -= ulNumOfTitles;
- if(nID > 0 && nID <= ulNumOfChapters)
- {
+ if(nID > 0 && nID <= ulNumOfChapters) {
pDVDC->PlayChapter(nID, DVD_CMD_FLAG_Block|DVD_CMD_FLAG_Flush, NULL);
}
}
- if((pDVDI->GetCurrentLocation(&Location) == S_OK))
- {
+ if((pDVDI->GetCurrentLocation(&Location) == S_OK)) {
pDVDI->GetNumberOfChapters(Location.TitleNum, &ulNumOfChapters);
CString m_strTitle;
m_strTitle.Format(IDS_AG_TITLE, Location.TitleNum);
@@ -8667,27 +8429,24 @@ void CMainFrame::OnNavigateChapters(UINT nID)
if(stop>0)
m_strOSD.Format(_T("%02d:%02d:%02d/%s %s, %s: %d/%d"), Location.TimeCode.bHours, Location.TimeCode.bMinutes, Location.TimeCode.bSeconds,
DVDtimeToString(RT2HMSF(stop)), m_strTitle, ResStr(IDS_AG_CHAPTER2), Location.ChapterNum, ulNumOfChapters);
- else
+ else {
m_strOSD.Format(_T("%s, %s: %d/%d"), m_strTitle, ResStr(IDS_AG_CHAPTER2), Location.ChapterNum, ulNumOfChapters);
+ }
m_OSD.DisplayMessage(OSD_TOPLEFT, m_strOSD, 3000);
}
- }
- else if(GetPlaybackMode() == PM_CAPTURE)
- {
+ } else if(GetPlaybackMode() == PM_CAPTURE) {
AppSettings& s = AfxGetAppSettings();
- if (s.iDefaultCaptureDevice == 1)
- {
+ if (s.iDefaultCaptureDevice == 1) {
CComQIPtr<IBDATuner> pTun = pGB;
- if (pTun)
- {
- if (s.nDVBLastChannel != nID)
- {
+ if (pTun) {
+ if (s.nDVBLastChannel != nID) {
pTun->SetChannel (nID);
DisplayCurrentChannelOSD();
- if (m_wndNavigationBar.IsVisible())
+ if (m_wndNavigationBar.IsVisible()) {
m_wndNavigationBar.m_navdlg.UpdatePos(nID);
+ }
}
}
}
@@ -8698,39 +8457,39 @@ 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;
+ 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();
}
- else if (GetPlaybackMode() == PM_FILE) OnPlayPlay();
}
void CMainFrame::OnUpdateNavigateMenuItem(CCmdUI* pCmdUI)
@@ -8755,8 +8514,7 @@ void CMainFrame::OnUpdateTunerScan(CCmdUI* pCmdUI)
class CDVDStateStream : public CUnknown, public IStream
{
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv)
- {
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv) {
return
QI(IStream)
CUnknown::NonDelegatingQueryInterface(riid, ppv);
@@ -8765,8 +8523,7 @@ class CDVDStateStream : public CUnknown, public IStream
__int64 m_pos;
public:
- CDVDStateStream() : CUnknown(NAME("CDVDStateStream"), NULL)
- {
+ CDVDStateStream() : CUnknown(NAME("CDVDStateStream"), NULL) {
m_pos = 0;
}
@@ -8775,60 +8532,54 @@ public:
CAtlArray<BYTE> m_data;
// ISequentialStream
- STDMETHODIMP Read(void* pv, ULONG cb, ULONG* pcbRead)
- {
+ STDMETHODIMP Read(void* pv, ULONG cb, ULONG* pcbRead) {
__int64 cbRead = min(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;
+ if(pcbRead) {
+ *pcbRead = (ULONG)cbRead;
+ }
m_pos += cbRead;
return S_OK;
}
- STDMETHODIMP Write(const void* pv, ULONG cb, ULONG* pcbWritten)
- {
+ STDMETHODIMP Write(const void* pv, ULONG cb, ULONG* pcbWritten) {
BYTE* p = (BYTE*)pv;
ULONG cbWritten = (ULONG)-1;
- while(++cbWritten < cb)
+ while(++cbWritten < cb) {
m_data.Add(*p++);
- if(pcbWritten) *pcbWritten = cbWritten;
+ }
+ if(pcbWritten) {
+ *pcbWritten = cbWritten;
+ }
return S_OK;
}
// IStream
- STDMETHODIMP Seek(LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
- {
+ STDMETHODIMP Seek(LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition) {
return E_NOTIMPL;
}
- STDMETHODIMP SetSize(ULARGE_INTEGER libNewSize)
- {
+ STDMETHODIMP SetSize(ULARGE_INTEGER libNewSize) {
return E_NOTIMPL;
}
- STDMETHODIMP CopyTo(IStream* pstm, ULARGE_INTEGER cb, ULARGE_INTEGER* pcbRead, ULARGE_INTEGER* pcbWritten)
- {
+ STDMETHODIMP CopyTo(IStream* pstm, ULARGE_INTEGER cb, ULARGE_INTEGER* pcbRead, ULARGE_INTEGER* pcbWritten) {
return E_NOTIMPL;
}
- STDMETHODIMP Commit(DWORD grfCommitFlags)
- {
+ STDMETHODIMP Commit(DWORD grfCommitFlags) {
return E_NOTIMPL;
}
- STDMETHODIMP Revert()
- {
+ STDMETHODIMP Revert() {
return E_NOTIMPL;
}
- STDMETHODIMP LockRegion(ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
- {
+ STDMETHODIMP LockRegion(ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType) {
return E_NOTIMPL;
}
- STDMETHODIMP UnlockRegion(ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType)
- {
+ STDMETHODIMP UnlockRegion(ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType) {
return E_NOTIMPL;
}
- STDMETHODIMP Stat(STATSTG* pstatstg, DWORD grfStatFlag)
- {
+ STDMETHODIMP Stat(STATSTG* pstatstg, DWORD grfStatFlag) {
return E_NOTIMPL;
}
- STDMETHODIMP Clone(IStream** ppstm)
- {
+ STDMETHODIMP Clone(IStream** ppstm) {
return E_NOTIMPL;
}
};
@@ -8838,19 +8589,25 @@ void CMainFrame::OnFavoritesAdd()
{
AppSettings& s = AfxGetAppSettings();
- if(GetPlaybackMode() == PM_FILE)
- {
+ if(GetPlaybackMode() == PM_FILE) {
CString fn = m_wndPlaylistBar.GetCurFileName();
- if(fn.IsEmpty()) return;
+ if(fn.IsEmpty()) {
+ return;
+ }
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);
+ 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;
+ if(dlg.DoModal() != IDOK) {
+ return;
+ }
// Name
CString str = dlg.m_name;
@@ -8858,8 +8615,9 @@ void CMainFrame::OnFavoritesAdd()
// RememberPos
CString pos(_T("0"));
- if(dlg.m_bRememberPos)
+ if(dlg.m_bRememberPos) {
pos.Format(_T("%I64d"), GetPos());
+ }
str += ';';
str += pos;
@@ -8873,16 +8631,15 @@ void CMainFrame::OnFavoritesAdd()
// Paths
CPlaylistItem pli;
- if(m_wndPlaylistBar.GetCur(pli))
- {
+ if(m_wndPlaylistBar.GetCur(pli)) {
POSITION pos = pli.m_fns.GetHeadPosition();
- while(pos) str += _T(";") + pli.m_fns.GetNext(pos);
+ while(pos) {
+ str += _T(";") + pli.m_fns.GetNext(pos);
+ }
}
s.AddFav(FAV_FILE, str);
- }
- else if(GetPlaybackMode() == PM_DVD)
- {
+ } else if(GetPlaybackMode() == PM_DVD) {
WCHAR path[_MAX_PATH];
ULONG len = 0;
pDVDI->GetDVDDirectory(path, _MAX_PATH, &len);
@@ -8896,7 +8653,9 @@ void CMainFrame::OnFavoritesAdd()
Location.TimeCode.bHours, Location.TimeCode.bMinutes, Location.TimeCode.bSeconds);
CFavoriteAddDlg dlg(fn, desc);
- if(dlg.DoModal() != IDOK) return;
+ if(dlg.DoModal() != IDOK) {
+ return;
+ }
// Name
CString str = dlg.m_name;
@@ -8904,8 +8663,7 @@ void CMainFrame::OnFavoritesAdd()
// RememberPos
CString pos(_T("0"));
- if(dlg.m_bRememberPos)
- {
+ if(dlg.m_bRememberPos) {
CDVDStateStream stream;
stream.AddRef();
@@ -8913,8 +8671,7 @@ void CMainFrame::OnFavoritesAdd()
CComQIPtr<IPersistStream> pPersistStream;
if(SUCCEEDED(pDVDI->GetState(&pStateData))
&& (pPersistStream = pStateData)
- && SUCCEEDED(OleSaveToStream(pPersistStream, (IStream*)&stream)))
- {
+ && SUCCEEDED(OleSaveToStream(pPersistStream, (IStream*)&stream))) {
pos = BinToCString(stream.m_data.GetData(), stream.m_data.GetCount());
}
}
@@ -8927,9 +8684,7 @@ void CMainFrame::OnFavoritesAdd()
str += fn;
s.AddFav(FAV_DVD, str);
- }
- else if(GetPlaybackMode() == PM_CAPTURE)
- {
+ } else if(GetPlaybackMode() == PM_CAPTURE) {
// TODO
}
}
@@ -8944,24 +8699,25 @@ void CMainFrame::OnFavoritesQuickAddFavorite()
{
AppSettings& s = AfxGetAppSettings();
- if(GetPlaybackMode() == PM_FILE)
- {
+ if(GetPlaybackMode() == PM_FILE) {
CString fn = m_wndPlaylistBar.GetCurFileName();
- if(fn.IsEmpty()) return;
+ if(fn.IsEmpty()) {
+ return;
+ }
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);
-
- // TODO: Make this proper code
- BOOL bRememberPos = AfxGetApp()->GetProfileInt(IDS_R_FAVORITES, IDS_RS_FAV_REMEMBERPOS, TRUE);
- BOOL bRelativeDrive = AfxGetApp()->GetProfileInt(IDS_R_FAVORITES, IDS_RS_FAV_RELATIVEDRIVE, FALSE);
+ 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(bRememberPos)
- fn_with_pos.Format(_T("%s_%s"), desc, GetVidPos()); // Add file position (time format) so it will be easier to organize later
+ 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;
@@ -8969,31 +8725,31 @@ void CMainFrame::OnFavoritesQuickAddFavorite()
// RememberPos
CString pos(_T("0"));
- if(bRememberPos)
+ if(s.bFavRememberPos) {
pos.Format(_T("%I64d"), GetPos());
+ }
str += ';';
str += pos;
// RelativeDrive
CString relativeDrive;
- relativeDrive.Format( _T("%d"), bRelativeDrive );
+ relativeDrive.Format( _T("%d"), s.bFavRelativeDrive );
str += ';';
str += relativeDrive;
// Paths
CPlaylistItem pli;
- if(m_wndPlaylistBar.GetCur(pli))
- {
+ if(m_wndPlaylistBar.GetCur(pli)) {
POSITION pos = pli.m_fns.GetHeadPosition();
- while(pos) str += _T(";") + pli.m_fns.GetNext(pos);
+ while(pos) {
+ str += _T(";") + pli.m_fns.GetNext(pos);
+ }
}
s.AddFav(FAV_FILE, str);
- }
- else if(GetPlaybackMode() == PM_DVD)
- {
+ } else if(GetPlaybackMode() == PM_DVD) {
WCHAR path[_MAX_PATH];
ULONG len = 0;
pDVDI->GetDVDDirectory(path, _MAX_PATH, &len);
@@ -9006,17 +8762,13 @@ void CMainFrame::OnFavoritesQuickAddFavorite()
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);
- // TODO: Make this proper code
- BOOL bRememberPos = AfxGetApp()->GetProfileInt(IDS_R_FAVORITES, IDS_RS_FAV_REMEMBERPOS, TRUE);
-
// Name
- CString str = bRememberPos ? desc : fn;
+ CString str = s.bFavRememberPos ? desc : fn;
str.Remove(';');
// RememberPos
CString pos(_T("0"));
- if(bRememberPos)
- {
+ if(s.bFavRememberPos) {
CDVDStateStream stream;
stream.AddRef();
@@ -9024,8 +8776,7 @@ void CMainFrame::OnFavoritesQuickAddFavorite()
CComQIPtr<IPersistStream> pPersistStream;
if(SUCCEEDED(pDVDI->GetState(&pStateData))
&& (pPersistStream = pStateData)
- && SUCCEEDED(OleSaveToStream(pPersistStream, (IStream*)&stream)))
- {
+ && SUCCEEDED(OleSaveToStream(pPersistStream, (IStream*)&stream))) {
pos = BinToCString(stream.m_data.GetData(), stream.m_data.GetCount());
}
}
@@ -9038,9 +8789,7 @@ void CMainFrame::OnFavoritesQuickAddFavorite()
str += fn;
s.AddFav(FAV_DVD, str);
- }
- else if(GetPlaybackMode() == PM_CAPTURE)
- {
+ } else if(GetPlaybackMode() == PM_CAPTURE) {
// TODO
}
}
@@ -9058,13 +8807,18 @@ void CMainFrame::OnUpdateFavoritesOrganize(CCmdUI* pCmdUI)
void CMainFrame::OnRecentFileClear()
{
- if(IDYES != AfxMessageBox(ResStr(IDS_RECENT_FILES_QUESTION), MB_YESNO))
+ if(IDYES != AfxMessageBox(ResStr(IDS_RECENT_FILES_QUESTION), MB_YESNO)) {
return;
+ }
AppSettings& s = AfxGetAppSettings();
- for(int i = 0; i < s.MRU.GetSize(); i++) s.MRU[i] = _T("");
- for(int i = 0; i < s.MRUDub.GetSize(); i++) s.MRUDub[i] = _T("");
+ for(int i = 0; i < s.MRU.GetSize(); i++) {
+ s.MRU[i] = _T("");
+ }
+ for(int i = 0; i < s.MRUDub.GetSize(); i++) {
+ s.MRUDub[i] = _T("");
+ }
s.MRU.WriteList();
s.MRUDub.WriteList();
}
@@ -9081,8 +8835,7 @@ void CMainFrame::OnFavoritesFile(UINT nID)
CAtlList<CString> sl;
AfxGetAppSettings().GetFav(FAV_FILE, sl);
- if(POSITION pos = sl.FindIndex(nID))
- {
+ if(POSITION pos = sl.FindIndex(nID)) {
CAtlList<CString> fns;
REFERENCE_TIME rtStart = 0;
BOOL bRelativeDrive = FALSE;
@@ -9090,18 +8843,21 @@ void CMainFrame::OnFavoritesFile(UINT nID)
int i = 0, j = 0;
for(CString s1 = sl.GetAt(pos), s2 = s1.Tokenize(_T(";"), i);
!s2.IsEmpty();
- s2 = s1.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
+ s2 = s1.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 )
- {
+ 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 );
@@ -9109,21 +8865,17 @@ void CMainFrame::OnFavoritesFile(UINT nID)
CPath exeDrive( exePath );
- if ( exeDrive.StripToRoot() )
- {
+ if ( exeDrive.StripToRoot() ) {
POSITION pos = fns.GetHeadPosition();
- while ( pos != NULL )
- {
+ 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 ?
- {
+ if ( path.StripToRoot() ) {
+ if ( _tcsicmp(exeDrive, path) != 0 ) { // Do we need to replace the drive letter ?
// Replace drive letter
CString newPath( exeDrive );
@@ -9171,8 +8923,7 @@ void CMainFrame::OnFavoritesDVD(UINT nID)
CAtlList<CString> sl;
AfxGetAppSettings().GetFav(FAV_DVD, sl);
- if(POSITION pos = sl.FindIndex(nID))
- {
+ if(POSITION pos = sl.FindIndex(nID)) {
CString fn;
CDVDStateStream stream;
@@ -9181,14 +8932,14 @@ void CMainFrame::OnFavoritesDVD(UINT nID)
int i = 0, j = 0;
for(CString s1 = sl.GetAt(pos), s2 = s1.Tokenize(_T(";"), i);
!s2.IsEmpty();
- s2 = s1.Tokenize(_T(";"), i), j++)
- {
- if(j == 0) ; // desc
- else if(j == 1 && s2 != _T("0")) // state
- {
+ s2 = s1.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
}
- else if(j == 2) fn = s2; // path
}
SendMessage(WM_COMMAND, ID_FILE_CLOSEMEDIA);
@@ -9198,8 +8949,7 @@ void CMainFrame::OnFavoritesDVD(UINT nID)
UNUSED_ALWAYS(hr);
CAutoPtr<OpenDVDData> p(DNew OpenDVDData());
- if(p)
- {
+ if(p) {
p->path = fn;
p->pDvdState = pDvdState;
}
@@ -9236,12 +8986,19 @@ 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);
}
+void CMainFrame::OnHelpToolbarImages()
+{
+ ShellExecute(m_hWnd, _T("open"), _T("http://sourceforge.net/apps/trac/mpc-hc/wiki/Toolbar_images"), NULL, NULL, SW_SHOWDEFAULT);
+}
+/*
void CMainFrame::OnHelpDonate()
{
const TCHAR URL[] = _T("http://sourceforge.net/project/showfiles.php?group_id=170561");
- if(CString(URL).Find(CString(_T("A4N")).MakeReverse()) >= 0)
+ if(CString(URL).Find(CString(_T("A4N")).MakeReverse()) >= 0) {
ShellExecute(m_hWnd, _T("open"), URL, NULL, NULL, SW_SHOWDEFAULT);
+ }
}
+*/
//////////////////////////////////
@@ -9257,17 +9014,13 @@ void CMainFrame::SetDefaultWindowRect(int iMonitor)
AppSettings& s = AfxGetAppSettings();
int w, h, x, y;
- if(s.HasFixedWindowSize())
- {
+ if(s.HasFixedWindowSize()) {
w = s.sizeFixedWindow.cx;
h = s.sizeFixedWindow.cy;
- }
- else if(s.fRememberWindowSize)
- {
+ } else if(s.fRememberWindowSize) {
w = s.rcLastWindowPos.Width();
h = s.rcLastWindowPos.Height();
- }
- else {
+ } else {
CRect r1, r2;
GetClientRect(&r1);
m_wndView.GetClientRect(&r2);
@@ -9276,8 +9029,9 @@ void CMainFrame::SetDefaultWindowRect(int iMonitor)
int _DEFCLIENTW = max(logosize.cx, DEFCLIENTW);
int _DEFCLIENTH = max(logosize.cy, DEFCLIENTH);
- if(GetSystemMetrics(SM_REMOTESESSION))
+ if(GetSystemMetrics(SM_REMOTESESSION)) {
_DEFCLIENTH = 0;
+ }
DWORD style = GetStyle();
@@ -9292,21 +9046,19 @@ void CMainFrame::SetDefaultWindowRect(int iMonitor)
}
}
- if(s.fRememberWindowPos)
- {
+ if(s.fRememberWindowPos) {
x = s.rcLastWindowPos.TopLeft().x;
y = s.rcLastWindowPos.TopLeft().y;
- }
- else
- {
+ } else {
HMONITOR hMonitor = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
- if(iMonitor > 0)
- {
+ if(iMonitor > 0) {
iMonitor--;
CAtlArray<HMONITOR> ml;
EnumDisplayMonitors(NULL, NULL, MonitorEnumProc, (LPARAM)&ml);
- if(iMonitor < ml.GetCount()) hMonitor = ml[iMonitor];
+ if(iMonitor < ml.GetCount()) {
+ hMonitor = ml[iMonitor];
+ }
}
MONITORINFO mi;
@@ -9320,35 +9072,39 @@ void CMainFrame::SetDefaultWindowRect(int iMonitor)
UINT lastWindowType = s.nLastWindowType;
MoveWindow(x, y, w, h);
- if(s.iCaptionMenuMode!=MODE_SHOWCAPTIONMENU)
- {
+ if(s.iCaptionMenuMode!=MODE_SHOWCAPTIONMENU) {
DWORD dwRemove = WS_CAPTION;
- if(s.iCaptionMenuMode == MODE_BORDERLESS) dwRemove |= WS_THICKFRAME;
+ if(s.iCaptionMenuMode == MODE_BORDERLESS) {
+ dwRemove |= WS_THICKFRAME;
+ }
ModifyStyle(dwRemove, 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.fRememberWindowPos) {
+ CenterWindow();
+ }
+
// Waffs : fullscreen command line
- if(!(s.nCLSwitches&CLSW_ADD) && (s.nCLSwitches&CLSW_FULLSCREEN) && !s.slFiles.IsEmpty())
- {
+ if(!(s.nCLSwitches&CLSW_ADD) && (s.nCLSwitches&CLSW_FULLSCREEN) && !s.slFiles.IsEmpty()) {
ToggleFullscreen(true, true);
SetCursor(NULL);
AfxGetAppSettings().nCLSwitches &= ~CLSW_FULLSCREEN;
m_fFirstFSAfterLaunchOnFS = true;
}
- if(s.fRememberWindowSize && s.fRememberWindowPos)
- {
- if(lastWindowType == SIZE_MAXIMIZED)
+ if(s.fRememberWindowSize && s.fRememberWindowPos) {
+ if(lastWindowType == SIZE_MAXIMIZED) {
ShowWindow(SW_MAXIMIZE);
- else if(lastWindowType == SIZE_MINIMIZED)
+ } else if(lastWindowType == SIZE_MINIMIZED) {
ShowWindow(SW_MINIMIZE);
+ }
// Casimir666 : if fullscreen was on, put it on back
- if (!m_fFullScreen && s.fLastFullScreen) ToggleFullscreen(true, true);
+ if (!m_fFullScreen && s.fLastFullScreen) {
+ ToggleFullscreen(true, true);
+ }
}
}
@@ -9359,18 +9115,14 @@ void CMainFrame::RestoreDefaultWindowRect()
WINDOWPLACEMENT wp;
GetWindowPlacement(&wp);
if(!m_fFullScreen && wp.showCmd != SW_SHOWMAXIMIZED && wp.showCmd != SW_SHOWMINIMIZED
-// && (GetExStyle()&WS_EX_APPWINDOW)
- && !s.fRememberWindowSize)
- {
+ // && (GetExStyle()&WS_EX_APPWINDOW)
+ && !s.fRememberWindowSize) {
int x, y, w, h;
- if(s.HasFixedWindowSize())
- {
+ if(s.HasFixedWindowSize()) {
w = s.sizeFixedWindow.cx;
h = s.sizeFixedWindow.cy;
- }
- else
- {
+ } else {
CRect r1, r2;
GetClientRect(&r1);
m_wndView.GetClientRect(&r2);
@@ -9385,20 +9137,16 @@ void CMainFrame::RestoreDefaultWindowRect()
h = _DEFCLIENTH + ((style&WS_THICKFRAME) ? GetSystemMetrics(SM_CYSIZEFRAME)*2 : 0)
+ r1.Height() - r2.Height();
- if(style&WS_CAPTION)
- {
+ if(style&WS_CAPTION) {
h += GetSystemMetrics(SM_CYCAPTION);
h += GetSystemMetrics(SM_CYMENU);
}
}
- if(s.fRememberWindowPos)
- {
+ if(s.fRememberWindowPos) {
x = s.rcLastWindowPos.TopLeft().x;
y = s.rcLastWindowPos.TopLeft().y;
- }
- else
- {
+ } else {
CRect r;
GetWindowRect(r);
@@ -9408,22 +9156,27 @@ void CMainFrame::RestoreDefaultWindowRect()
MoveWindow(x, y, w, h);
- if(!s.fRememberWindowPos) CenterWindow();
+ if(!s.fRememberWindowPos) {
+ CenterWindow();
+ }
}
}
OAFilterState CMainFrame::GetMediaState()
{
OAFilterState ret = -1;
- if(m_iMediaLoadState == MLS_LOADED) pMC->GetState(0, &ret);
+ 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)
+ if (m_wndNavigationBar.IsWindowVisible() && GetPlaybackMode() != PM_CAPTURE) {
ShowControlBar(&m_wndNavigationBar, !m_wndNavigationBar.IsWindowVisible(), TRUE);
+ }
}
CSize CMainFrame::GetVideoSize()
@@ -9432,64 +9185,64 @@ CSize CMainFrame::GetVideoSize()
bool fCompMonDeskARDiff = AfxGetAppSettings().fCompMonDeskARDiff;
CSize ret(0,0);
- if(m_iMediaLoadState != MLS_LOADED || m_fAudioOnly)
+ if(m_iMediaLoadState != MLS_LOADED || m_fAudioOnly) {
return ret;
+ }
CSize wh(0, 0), arxy(0, 0);
- if (m_pMFVDC)
- {
+ if (m_pMFVDC) {
m_pMFVDC->GetNativeVideoSize(&wh, &arxy); // TODO : check AR !!
- }
- else if(m_pCAP)
- {
+ } else if(m_pCAP) {
wh = m_pCAP->GetVideoSize(false);
arxy = m_pCAP->GetVideoSize(fKeepAspectRatio);
- }
- else
- {
+ } 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)
+ if(pBV2 && SUCCEEDED(pBV2->GetPreferredAspectRatio(&arx, &ary)) && arx > 0 && ary > 0) {
arxy.SetSize(arx, ary);
+ }
}
- if(wh.cx <= 0 || wh.cy <= 0)
+ 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)))
+ 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;
+ 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))
- {
+ 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)
- {
+ if(_HORZSIZE > 0 && _VERTSIZE > 0 && _HORZRES > 0 && _VERTRES > 0) {
double a = 1.0*_HORZSIZE/_VERTSIZE;
double b = 1.0*_HORZRES/_VERTRES;
- if(b < a)
+ if(b < a) {
ret.cy = (DWORD)(1.0*ret.cy * a / b);
- else if(a < b)
+ } else if(a < b) {
ret.cx = (DWORD)(1.0*ret.cx * b / a);
+ }
}
::ReleaseDC(0, hDC);
@@ -9514,52 +9267,60 @@ void CMainFrame::ToggleFullscreen(bool fToNearest, bool fSwitchScreenResWhenHasT
CMonitors monitors;
static bool m_PlayListBarVisible = false;
- if(!m_fFullScreen)
- {
+ if(!m_fFullScreen) {
m_PlayListBarVisible = m_wndPlaylistBar.IsVisible();
- if((AfxGetApp()->GetProfileInt(IDS_R_SETTINGS, _T("HidePlaylistFullScreen"), FALSE)) && (m_PlayListBarVisible)) ShowControlBar(&m_wndPlaylistBar, !m_PlayListBarVisible, TRUE);
+ if(s.bHidePlaylistFullScreen && m_PlayListBarVisible) {
+ ShowControlBar(&m_wndPlaylistBar, !m_PlayListBarVisible, TRUE);
+ }
- if(!m_fFirstFSAfterLaunchOnFS) GetWindowRect(&m_lastWindowRect);
- if(s.AutoChangeFullscrRes.bEnabled && fSwitchScreenResWhenHasTo && (GetPlaybackMode() != PM_NONE)) AutoChangeMonitorMode();
+ 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"))
- {
+ if(s.strFullScreenMonitor == _T("Current")) {
hm = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
- }
- else
- {
- for ( int i = 0; i < monitors.GetCount(); i++ )
- {
+ } else {
+ for ( int i = 0; i < monitors.GetCount(); i++ ) {
monitor = monitors.GetMonitor( i );
monitor.GetName(str);
- if((monitor.IsMonitor()) && (s.strFullScreenMonitor == str))
- {
+ if((monitor.IsMonitor()) && (s.strFullScreenMonitor == str)) {
hm = monitor;
break;
}
}
- if(!hm) hm = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
+ 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);
+ if(fToNearest) {
+ r = mi.rcMonitor;
+ } else {
+ GetDesktopWindow()->GetWindowRect(&r);
+ }
hMenu = NULL;
- }
- else
- {
- if(s.AutoChangeFullscrRes.bEnabled && s.AutoChangeFullscrRes.bApplyDefault)
+ } else {
+ if(s.AutoChangeFullscrRes.bEnabled && s.AutoChangeFullscrRes.bApplyDefault) {
SetDispMode(s.AutoChangeFullscrRes.dmFullscreenResOther, s.strFullScreenMonitor);
+ }
dwAdd = (s.iCaptionMenuMode==MODE_BORDERLESS ? 0 : s.iCaptionMenuMode==MODE_FRAMEONLY? WS_THICKFRAME: WS_CAPTION | WS_THICKFRAME);
- if (!m_fFirstFSAfterLaunchOnFS) r = m_lastWindowRect;
+ if (!m_fFirstFSAfterLaunchOnFS) {
+ r = m_lastWindowRect;
+ }
hMenu = (s.iCaptionMenuMode==MODE_SHOWCAPTIONMENU) ? m_hMenuDefault: NULL;
- if(AfxGetApp()->GetProfileInt(IDS_R_SETTINGS, _T("HidePlaylistFullScreen"), FALSE)) ShowControlBar(&m_wndPlaylistBar, m_PlayListBarVisible, TRUE);
+ if(s.bHidePlaylistFullScreen) {
+ ShowControlBar(&m_wndPlaylistBar, m_PlayListBarVisible, TRUE);
+ }
}
m_lastMouseMove.x = m_lastMouseMove.y = -1;
@@ -9578,77 +9339,65 @@ void CMainFrame::ToggleFullscreen(bool fToNearest, bool fSwitchScreenResWhenHasT
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) ? true : false;
- if((m_Change_Monitor) && (!m_bToggleShader))
- {
- if (m_pCAP)
+ 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)
+ if((m_Change_Monitor) && (!m_bToggleShaderScreenSpace)) {
+ if (m_pCAP2) {
m_pCAP2->SetPixelShader2(NULL, NULL, 1);
+ }
}
- }
- else
- {
- if((m_Change_Monitor) && (!m_bToggleShader))
- {
- if (m_pCAP) m_pCAP->SetPixelShader(NULL, NULL);
+ } else {
+ if((m_Change_Monitor) && (!m_bToggleShader)) {
+ if (m_pCAP) {
+ m_pCAP->SetPixelShader(NULL, NULL);
+ }
}
}
- if(m_fFullScreen)
- {
+ if(m_fFullScreen) {
m_fHideCursor = true;
- if(s.fShowBarsWhenFullScreen)
- {
+ if(s.fShowBarsWhenFullScreen) {
int nTimeOut = s.nShowBarsWhenFullScreenTimeOut;
- if(nTimeOut == 0)
- {
+ if(nTimeOut == 0) {
ShowControls(CS_NONE, false);
ShowControlBar(&m_wndNavigationBar, false, TRUE);
- }
- else if(nTimeOut > 0)
- {
+ } else if(nTimeOut > 0) {
SetTimer(TIMER_FULLSCREENCONTROLBARHIDER, nTimeOut*1000, NULL);
SetTimer(TIMER_FULLSCREENMOUSEHIDER, max(nTimeOut*1000, 2000), NULL);
}
- }
- else
- {
+ } else {
ShowControls(CS_NONE, false);
ShowControlBar(&m_wndNavigationBar, false, TRUE);
}
- if(s.fPreventMinimize)
- {
- if(hm != hm_cur) ModifyStyle(WS_MINIMIZEBOX, 0, SWP_NOZORDER);
+ if(s.fPreventMinimize) {
+ if(hm != hm_cur) {
+ ModifyStyle(WS_MINIMIZEBOX, 0, SWP_NOZORDER);
+ }
}
- }
- else
- {
+ } else {
ModifyStyle(0, WS_MINIMIZEBOX, SWP_NOZORDER);
KillTimer(TIMER_FULLSCREENCONTROLBARHIDER);
KillTimer(TIMER_FULLSCREENMOUSEHIDER);
m_fHideCursor = false;
ShowControls(s.nCS);
- if (GetPlaybackMode() == PM_CAPTURE && s.iDefaultCaptureDevice == 1)
+ if (GetPlaybackMode() == PM_CAPTURE && s.iDefaultCaptureDevice == 1) {
ShowControlBar(&m_wndNavigationBar, !s.fHideNavigation, TRUE);
+ }
}
m_fAudioOnly = fAudioOnly;
- if (m_fFirstFSAfterLaunchOnFS) //Play started in Fullscreen
- {
- if(s.fRememberWindowSize || s.fRememberWindowPos)
- {
+ if (m_fFirstFSAfterLaunchOnFS) { //Play started in Fullscreen
+ if(s.fRememberWindowSize || s.fRememberWindowPos) {
r = s.rcLastWindowPos;
- if(!s.fRememberWindowPos)
- {
+ if(!s.fRememberWindowPos) {
hm = MonitorFromPoint( CPoint( 0,0 ), MONITOR_DEFAULTTOPRIMARY );
GetMonitorInfo(hm, &mi);
CRect m_r = mi.rcMonitor;
@@ -9656,42 +9405,36 @@ void CMainFrame::ToggleFullscreen(bool fToNearest, bool fSwitchScreenResWhenHasT
int top = m_r.top + (m_r.Height() - r.Height())/2;
r = CRect(left, top, left + r.Width(), top + r.Height());
}
- if(!s.fRememberWindowSize)
- {
+ 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)
- {
+ if(!s.fRememberWindowSize) {
ZoomVideoWindow();
ShowWindow(SW_SHOW);
}
- }
- else
- {
- if(m_LastWindow_HM != hm_cur)
- {
+ } 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);
+ if(m_LastWindow_HM != hm_cur) {
+ ShowWindow(SW_SHOW);
+ }
}
m_fFirstFSAfterLaunchOnFS = false;
- }
- else
- {
+ } else {
SetWindowPos(NULL, r.left, r.top, r.Width(), r.Height(), SWP_NOZORDER|SWP_NOSENDCHANGING);
}
MoveVideoWindow();
- if((m_Change_Monitor) && (!m_bToggleShader || !m_bToggleShaderScreenSpace)) // Enabled shader ...
- {
+ if((m_Change_Monitor) && (!m_bToggleShader || !m_bToggleShaderScreenSpace)) { // Enabled shader ...
SetShaders();
}
}
@@ -9702,21 +9445,22 @@ void CMainFrame::AutoChangeMonitorMode()
CStringW mf_hmonitor = s.strFullScreenMonitor;
double MediaFPS = 0.0;
- if (GetPlaybackMode() == PM_FILE)
- {
+ 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)
- {
+ 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;
+ || FAILED(pPin->ConnectionMediaType(&mt))) {
+ continue;
+ }
ExtractAvgTimePerFrame (&mt, m_rtTimePerFrame);
- if (m_rtTimePerFrame == 0) m_rtTimePerFrame=1;
+ if (m_rtTimePerFrame == 0) {
+ m_rtTimePerFrame=1;
+ }
}
EndEnumPins;
}
@@ -9724,11 +9468,9 @@ void CMainFrame::AutoChangeMonitorMode()
MediaFPS = 10000000.0 / m_rtTimePerFrame;
}
- if (GetPlaybackMode() == PM_DVD)
- {
+ if (GetPlaybackMode() == PM_DVD) {
DVD_PLAYBACK_LOCATION2 Location;
- if (pDVDI->GetCurrentLocation(&Location) == S_OK)
- {
+ 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
@@ -9736,50 +9478,42 @@ void CMainFrame::AutoChangeMonitorMode()
}
}
- if (IsVistaOrAbove())
- {
- if ((MediaFPS > 23.971) && (MediaFPS < 23.981))
- {
+ if (IsVistaOrAbove()) {
+ if ((MediaFPS > 23.971) && (MediaFPS < 23.981)) {
SetDispMode(s.AutoChangeFullscrRes.dmFullscreenRes23d976Hz, mf_hmonitor);
return;
}
- if ((MediaFPS > 29.965) && (MediaFPS < 29.975))
- {
+ if ((MediaFPS > 29.965) && (MediaFPS < 29.975)) {
SetDispMode(s.AutoChangeFullscrRes.dmFullscreenRes29d97Hz, mf_hmonitor);
return;
}
}
- switch ((int)(MediaFPS + 0.5))
- {
- case 24 :
- SetDispMode(s.AutoChangeFullscrRes.dmFullscreenRes24Hz, mf_hmonitor);
- break;
- case 25 :
- SetDispMode(s.AutoChangeFullscrRes.dmFullscreenRes25Hz, mf_hmonitor);
- break;
- case 30 :
- SetDispMode(s.AutoChangeFullscrRes.dmFullscreenRes30Hz, mf_hmonitor);
- break;
- default:
- SetDispMode(s.AutoChangeFullscrRes.dmFullscreenResOther, mf_hmonitor);
+ switch ((int)(MediaFPS + 0.5)) {
+ case 24 :
+ SetDispMode(s.AutoChangeFullscrRes.dmFullscreenRes24Hz, mf_hmonitor);
+ break;
+ case 25 :
+ SetDispMode(s.AutoChangeFullscrRes.dmFullscreenRes25Hz, mf_hmonitor);
+ break;
+ case 30 :
+ SetDispMode(s.AutoChangeFullscrRes.dmFullscreenRes30Hz, mf_hmonitor);
+ break;
+ default:
+ SetDispMode(s.AutoChangeFullscrRes.dmFullscreenResOther, mf_hmonitor);
}
}
void CMainFrame::MoveVideoWindow(bool fShowStats)
{
- if(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly && IsWindowVisible())
- {
+ if(m_iMediaLoadState == MLS_LOADED && !m_fAudioOnly && IsWindowVisible()) {
CRect wr;
- if (m_pFullscreenWnd->IsWindow())
+ if (m_pFullscreenWnd->IsWindow()) {
m_pFullscreenWnd->GetClientRect(&wr);
- else if(!m_fFullScreen)
- {
+ } else if(!m_fFullScreen) {
m_wndView.GetClientRect(&wr);
- }
- else
- {
+ } else {
GetWindowRect(&wr);
// it's code need for work in fullscreen on secondary monitor;
@@ -9791,8 +9525,7 @@ void CMainFrame::MoveVideoWindow(bool fShowStats)
CRect vr = CRect(0,0,0,0);
OAFilterState fs = GetMediaState();
- if(fs == State_Paused || fs == State_Running || fs == State_Stopped && (m_fShockwaveGraph || m_fQuicktimeGraph))
- {
+ if(fs == State_Paused || fs == State_Running || fs == State_Stopped && (m_fShockwaveGraph || m_fQuicktimeGraph)) {
CSize arxy = GetVideoSize();
dvstype iDefaultVideoSize = (dvstype)AfxGetAppSettings().iDefaultVideoSize;
@@ -9806,33 +9539,31 @@ void CMainFrame::MoveVideoWindow(bool fShowStats)
int w = ws.cx;
int h = ws.cy;
- if(!m_fShockwaveGraph) //&& !m_fQuicktimeGraph)
- {
+ if(!m_fShockwaveGraph) { //&& !m_fQuicktimeGraph)
if(iDefaultVideoSize == DVS_FROMINSIDE || iDefaultVideoSize == DVS_FROMOUTSIDE ||
- iDefaultVideoSize == DVS_ZOOM1 || iDefaultVideoSize == DVS_ZOOM2)
- {
+ iDefaultVideoSize == DVS_ZOOM1 || iDefaultVideoSize == DVS_ZOOM2) {
int dh = ws.cy;
int dw = MulDiv(dh, arxy.cx, arxy.cy);
int i = 0;
- switch(iDefaultVideoSize)
- {
- case DVS_ZOOM1:
- i = 1;
- break;
- case DVS_ZOOM2:
- i = 2;
- break;
- case DVS_FROMOUTSIDE:
- i = 3;
- break;
+ switch(iDefaultVideoSize) {
+ case DVS_ZOOM1:
+ i = 1;
+ break;
+ case DVS_ZOOM2:
+ i = 2;
+ break;
+ case DVS_FROMOUTSIDE:
+ i = 3;
+ break;
}
int minw = dw;
int maxw = dw;
- if(ws.cx < dw)
+ if(ws.cx < dw) {
minw = ws.cx;
- else if(ws.cx > dw)
+ } else if(ws.cx > dw) {
maxw = ws.cx;
+ }
float scale = i / 3.0f;
w = minw + (maxw - minw) * scale;
@@ -9861,32 +9592,28 @@ void CMainFrame::MoveVideoWindow(bool fShowStats)
//wr |= CRect(0,0,0,0);
//vr |= CRect(0,0,0,0);
- if(m_pCAP)
- {
+ if(m_pCAP) {
m_pCAP->SetPosition(wr, vr);
m_pCAP->SetVideoAngle(Vector(DegToRad(m_AngleX), DegToRad(m_AngleY), DegToRad(m_AngleZ)));
- }
- else
- {
+ } else {
HRESULT hr;
hr = pBV->SetDefaultSourcePosition();
hr = pBV->SetDestinationPosition(vr.left, vr.top, vr.Width(), vr.Height());
hr = pVW->SetWindowPosition(wr.left, wr.top, wr.Width(), wr.Height());
- if (m_pMFVDC) m_pMFVDC->SetVideoPosition (NULL, wr);
+ if (m_pMFVDC) {
+ m_pMFVDC->SetVideoPosition (NULL, wr);
+ }
}
m_wndView.SetVideoRect(wr);
- if(fShowStats && vr.Height() > 0)
- {
+ if(fShowStats && vr.Height() > 0) {
CString info;
info.Format(_T("Pos %.2f %.2f, Zoom %.2f %.2f, AR %.2f"), m_PosX, m_PosY, m_ZoomX, m_ZoomY, (float)vr.Width()/vr.Height());
SendStatusMessage(info, 3000);
}
- }
- else
- {
+ } else {
m_wndView.SetVideoRect();
}
@@ -9896,14 +9623,11 @@ void CMainFrame::MoveVideoWindow(bool fShowStats)
void CMainFrame::HideVideoWindow(bool fHide)
{
CRect wr;
- if (m_pFullscreenWnd->IsWindow())
+ if (m_pFullscreenWnd->IsWindow()) {
m_pFullscreenWnd->GetClientRect(&wr);
- else if(!m_fFullScreen)
- {
+ } else if(!m_fFullScreen) {
m_wndView.GetClientRect(&wr);
- }
- else
- {
+ } else {
GetWindowRect(&wr);
// this code is needed to work in fullscreen on secondary monitor
@@ -9913,25 +9637,25 @@ void CMainFrame::HideVideoWindow(bool fHide)
}
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
+ 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)
+ if(m_iMediaLoadState != MLS_LOADED) {
return;
+ }
AppSettings& s = AfxGetAppSettings();
- if(scale <= 0)
- {
+ if(scale <= 0) {
scale =
s.iZoomLevel == 0 ? 0.5 :
s.iZoomLevel == 1 ? 1.0 :
@@ -9940,8 +9664,7 @@ void CMainFrame::ZoomVideoWindow(bool snap, double scale)
1.0;
}
- if(m_fFullScreen)
- {
+ if(m_fFullScreen) {
OnViewFullscreen();
}
@@ -9952,8 +9675,7 @@ void CMainFrame::ZoomVideoWindow(bool snap, double scale)
GetWindowRect(r);
int w = 0, h = 0;
- if(!m_fAudioOnly)
- {
+ if(!m_fAudioOnly) {
CSize arxy = GetVideoSize();
long lWidth = int(arxy.cx * scale + 0.5);
@@ -9973,24 +9695,20 @@ void CMainFrame::ZoomVideoWindow(bool snap, double scale)
+ r1.Height() - r2.Height()
+ lHeight;
- if ( style & WS_CAPTION )
- {
+ if ( style & WS_CAPTION ) {
h += GetSystemMetrics( SM_CYCAPTION );
// If we have a caption then we have a menu bar
h += GetSystemMetrics( SM_CYMENU );
}
- if (GetPlaybackMode() == PM_CAPTURE && !s.fHideNavigation && !m_fFullScreen && !m_wndNavigationBar.IsVisible())
- {
+ 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
- {
+ } else {
w = r.Width(); // mmi.ptMinTrackSize.x;
h = mmi.ptMinTrackSize.y;
}
@@ -10002,8 +9720,7 @@ void CMainFrame::ZoomVideoWindow(bool snap, double scale)
w = min(w, (mi.rcWork.right - mi.rcWork.left));
h = min(h, (mi.rcWork.bottom - mi.rcWork.top));
- if(!s.fRememberWindowPos)
- {
+ if(!s.fRememberWindowPos) {
bool isSnapped = false;
if(snap && s.fSnapToDesktopEdges) { // check if snapped to edges
@@ -10011,22 +9728,17 @@ void CMainFrame::ZoomVideoWindow(bool snap, double scale)
|| (r.right == mi.rcWork.right) || (r.bottom == mi.rcWork.bottom);
}
- if(isSnapped) // prefer left, top snap to right, bottom snap
- {
+ if(isSnapped) { // prefer left, top snap to right, bottom snap
if(r.left == mi.rcWork.left) {}
- else if(r.right == mi.rcWork.right)
- {
+ 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)
- {
+ else if(r.bottom == mi.rcWork.bottom) {
r.top = r.bottom - h;
}
- }
- else // center window
- {
+ } else { // center window
CPoint cp = r.CenterPoint();
r.left = cp.x - w/2;
r.top = cp.y - h/2;
@@ -10036,25 +9748,33 @@ void CMainFrame::ZoomVideoWindow(bool snap, double scale)
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(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())
- {
+ if((m_fFullScreen || !s.HasFixedWindowSize()) && !m_pFullscreenWnd->IsWindow()) {
MoveWindow(r);
}
-// ShowWindow(SW_SHOWNORMAL);
+ // ShowWindow(SW_SHOWNORMAL);
MoveVideoWindow();
}
double CMainFrame::GetZoomAutoFitScale()
{
- if(m_iMediaLoadState != MLS_LOADED || m_fAudioOnly)
+ if(m_iMediaLoadState != MLS_LOADED || m_fAudioOnly) {
return 1.0;
+ }
CSize arxy = GetVideoSize();
@@ -10066,67 +9786,70 @@ double CMainFrame::GetZoomAutoFitScale()
void CMainFrame::RepaintVideo()
{
- if(m_pCAP)
+ if(m_pCAP) {
m_pCAP->Paint(false);
+ }
}
void CMainFrame::SetShaders()
{
- if(!m_pCAP) return;
+ if(!m_pCAP) {
+ return;
+ }
AppSettings& s = AfxGetAppSettings();
CAtlStringMap<const AppSettings::Shader*> s2s;
POSITION pos = s.m_shaders.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
const AppSettings::Shader* pShader = &s.m_shaders.GetNext(pos);
s2s[pShader->label] = pShader;
}
m_pCAP->SetPixelShader(NULL, NULL);
- if (m_pCAP2)
+ if (m_pCAP2) {
m_pCAP2->SetPixelShader2(NULL, NULL, true);
+ }
- for (int i = 0; i < 2; ++i)
- {
- if (i == 0 && m_bToggleShader)
+ for (int i = 0; i < 2; ++i) {
+ if (i == 0 && m_bToggleShader) {
continue;
- if (i == 1 && m_bToggleShaderScreenSpace)
+ }
+ if (i == 1 && m_bToggleShaderScreenSpace) {
continue;
+ }
CAtlList<CString> labels;
CAtlList<CString> *pLabels;
- if (i == 0)
+ if (i == 0) {
pLabels = &m_shaderlabels;
- else
- {
- if (!m_pCAP2)
+ } else {
+ if (!m_pCAP2) {
break;
+ }
pLabels = &m_shaderlabelsScreenSpace;
}
pos = pLabels->GetHeadPosition();
- while(pos)
- {
+ while(pos) {
const AppSettings::Shader* pShader = NULL;
- if(s2s.Lookup(pLabels->GetNext(pos), pShader))
- {
+ if(s2s.Lookup(pLabels->GetNext(pos), pShader)) {
CStringA target = pShader->target;
CStringA srcdata = pShader->srcdata;
HRESULT hr;
- if (i == 0)
+ if (i == 0) {
hr = m_pCAP->SetPixelShader(srcdata, target);
- else
+ } else {
hr = m_pCAP2->SetPixelShader2(srcdata, target, true);
+ }
- if(FAILED(hr))
- {
+ if(FAILED(hr)) {
m_pCAP->SetPixelShader(NULL, NULL);
- if (m_pCAP2)
+ if (m_pCAP2) {
m_pCAP2->SetPixelShader2(NULL, NULL, true);
+ }
SendStatusMessage(ResStr(IDS_MAINFRM_73) + pShader->label, 3000);
return;
}
@@ -10135,8 +9858,7 @@ void CMainFrame::SetShaders()
}
}
- if(m_iMediaLoadState == MLS_LOADED)
- {
+ if(m_iMediaLoadState == MLS_LOADED) {
CString str = Implode(labels, '|');
str.Replace(_T("|"), _T(", "));
SendStatusMessage(ResStr(IDS_AG_SHADER) + str, 3000);
@@ -10146,27 +9868,31 @@ void CMainFrame::SetShaders()
void CMainFrame::UpdateShaders(CString label)
{
- if(!m_pCAP) return;
+ if(!m_pCAP) {
+ return;
+ }
- if(m_shaderlabels.GetCount() <= 1)
+ if(m_shaderlabels.GetCount() <= 1) {
m_shaderlabels.RemoveAll();
+ }
- if(m_shaderlabels.IsEmpty() && !label.IsEmpty())
+ if(m_shaderlabels.IsEmpty() && !label.IsEmpty()) {
m_shaderlabels.AddTail(label);
+ }
bool fUpdate = m_shaderlabels.IsEmpty();
POSITION pos = m_shaderlabels.GetHeadPosition();
- while(pos)
- {
- if(label == m_shaderlabels.GetNext(pos))
- {
+ while(pos) {
+ if(label == m_shaderlabels.GetNext(pos)) {
fUpdate = true;
break;
}
}
- if(fUpdate) SetShaders();
+ if(fUpdate) {
+ SetShaders();
+ }
}
@@ -10179,67 +9905,66 @@ void CMainFrame::SetBalance(int balance)
balance = (int)((log10(1.0*balance)-2)*5000*sign);
balance = max(min(balance, 10000), -10000);
- if(m_iMediaLoadState == MLS_LOADED)
+ if(m_iMediaLoadState == MLS_LOADED) {
pBA->put_Balance(balance);
+ }
}
void CMainFrame::SetupIViAudReg()
{
- if(!AfxGetAppSettings().fAutoSpeakerConf) return;
+ if(!AfxGetAppSettings().fAutoSpeakerConf) {
+ return;
+ }
DWORD spc = 0, defchnum = 0;
- if(AfxGetAppSettings().fAutoSpeakerConf)
- {
+ 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;
+ && 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
- {
+ } else {
defchnum = 2;
}
CRegKey iviaud;
- if(ERROR_SUCCESS == iviaud.Create(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\InterVideo\\Common\\AudioDec")))
- {
+ 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
+ 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);
+ }
}
}
@@ -10250,11 +9975,11 @@ 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++)
- {
+ for(int i=0; i<strFilename.GetLength(); i++) {
WCHAR Char = strFilename[i];
- if (Char<32 || Char>126 || Char==35)
+ if (Char<32 || Char>126 || Char==35) {
return false;
+ }
}
return true;
}
@@ -10274,122 +9999,106 @@ void CMainFrame::OpenCreateGraphObject(OpenMediaData* pOMD)
((s.iDSVideoRendererType == VIDRNDT_DS_VMR9RENDERLESS) ||
(s.iDSVideoRendererType == VIDRNDT_DS_EVR_CUSTOM) ||
(s.iDSVideoRendererType == VIDRNDT_DS_MADVR) ||
- (s.iDSVideoRendererType == VIDRNDT_DS_SYNC)))
- {
+ (s.iDSVideoRendererType == VIDRNDT_DS_SYNC))) {
CreateFullScreenWindow();
m_pVideoWnd = m_pFullscreenWnd;
- }
- else
- {
+ } else {
m_pVideoWnd = &m_wndView;
}
- if(OpenFileData* p = dynamic_cast<OpenFileData*>(pOMD))
- {
+ 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")
- {
+ 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)
- {
+ } 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")
- {
+ } else if(ct == "application/x-shockwave-flash") {
engine = ShockWave;
- }
- else if(ct == "video/quicktime"
- || ct == "application/x-quicktimeplayer")
- {
+ } else if(ct == "video/quicktime"
+ || ct == "application/x-quicktimeplayer") {
engine = QuickTime;
}
HRESULT hr = E_FAIL;
CComPtr<IUnknown> pUnk;
- if(engine == RealMedia)
- {
+ if(engine == RealMedia) {
// TODO : see why Real SDK crash here ...
//if (!IsRealEngineCompatible(p->fns.GetHead()))
// throw ResStr(IDS_REALVIDEO_INCOMPATIBLE);
pUnk = (IUnknown*)(INonDelegatingUnknown*)DNew CRealMediaGraph(m_pVideoWnd->m_hWnd, hr);
- if(!pUnk)
+ if(!pUnk) {
throw ResStr(IDS_AG_OUT_OF_MEMORY);
+ }
- if(SUCCEEDED(hr))
- {
+ if(SUCCEEDED(hr)) {
pGB = CComQIPtr<IGraphBuilder>(pUnk);
- if(pGB)
+ if(pGB) {
m_fRealMediaGraph = true;
+ }
}
- }
- else if(engine == ShockWave)
- {
+ } else if(engine == ShockWave) {
#ifdef _WIN64 // No flash on x64
MessageBox(ResStr(IDS_MAINFRM_76), _T(""), MB_OK);
#else
pUnk = (IUnknown*)(INonDelegatingUnknown*)DNew CShockwaveGraph(m_pVideoWnd->m_hWnd, hr);
- if(!pUnk)
+ if(!pUnk) {
throw ResStr(IDS_AG_OUT_OF_MEMORY);
+ }
- if(SUCCEEDED(hr))
+ if(SUCCEEDED(hr)) {
pGB = CComQIPtr<IGraphBuilder>(pUnk);
- if(FAILED(hr) || !pGB)
+ }
+ if(FAILED(hr) || !pGB) {
throw ResStr(IDS_MAINFRM_77);
+ }
m_fShockwaveGraph = true;
#endif
- }
- else if(engine == QuickTime)
- {
+ } else if(engine == QuickTime) {
#ifdef _WIN64 // TODOX64
// MessageBox (ResStr(IDS_MAINFRM_78), _T(""), MB_OK);
#else
pUnk = (IUnknown*)(INonDelegatingUnknown*)DNew CQuicktimeGraph(m_pVideoWnd->m_hWnd, hr);
- if(!pUnk)
+ if(!pUnk) {
throw ResStr(IDS_AG_OUT_OF_MEMORY);
+ }
- if(SUCCEEDED(hr))
- {
+ if(SUCCEEDED(hr)) {
pGB = CComQIPtr<IGraphBuilder>(pUnk);
- if(pGB)
+ if(pGB) {
m_fQuicktimeGraph = true;
+ }
}
#endif
}
m_fCustomGraph = m_fRealMediaGraph || m_fShockwaveGraph || m_fQuicktimeGraph;
- if(!m_fCustomGraph)
- {
+ if(!m_fCustomGraph) {
pGB = DNew CFGManagerPlayer(_T("CFGManagerPlayer"), NULL, m_pVideoWnd->m_hWnd);
}
- }
- else if(OpenDVDData* p = dynamic_cast<OpenDVDData*>(pOMD))
- {
+ } 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)
+ } else if(OpenDeviceData* p = dynamic_cast<OpenDeviceData*>(pOMD)) {
+ if (s.iDefaultCaptureDevice == 1) {
pGB = DNew CFGManagerBDA(_T("CFGManagerBDA"), NULL, m_pVideoWnd->m_hWnd);
- else
+ } else {
pGB = DNew CFGManagerCapture(_T("CFGManagerCapture"), NULL, m_pVideoWnd->m_hWnd);
+ }
}
- if(!pGB)
- {
+ if(!pGB) {
throw ResStr(IDS_MAINFRM_80);
}
@@ -10405,20 +10114,19 @@ void CMainFrame::OpenCreateGraphObject(OpenMediaData* pOMD)
if(!(pMC && pME && pMS)
|| !(pVW && pBV)
- || !(pBA))
- {
+ || !(pBA)) {
throw _T("Failed to query the needed interfaces for playback");
}
- if(FAILED(pME->SetNotifyWindow((OAHWND)m_hWnd, WM_GRAPHNOTIFY, 0)))
- {
+ if(FAILED(pME->SetNotifyWindow((OAHWND)m_hWnd, WM_GRAPHNOTIFY, 0))) {
throw _T("Could not set target window for graph notification");
}
m_pProv = (IUnknown*)DNew CKeyProvider();
- if(CComQIPtr<IObjectWithSite> pObjectWithSite = pGB)
+ if(CComQIPtr<IObjectWithSite> pObjectWithSite = pGB) {
pObjectWithSite->SetSite(m_pProv);
+ }
m_pCB = DNew CDSMChapterBag(NULL, NULL);
}
@@ -10427,95 +10135,95 @@ CWnd *CMainFrame::GetModalParent()
{
AppSettings& s = AfxGetAppSettings();
CWnd *pParentWnd = this;
- if (m_pFullscreenWnd->IsWindow() && s.m_RenderersSettings.m_RenderSettings.iVMR9FullscreenGUISupport)
+ if (m_pFullscreenWnd->IsWindow() && s.m_RenderersSettings.m_RenderSettings.iVMR9FullscreenGUISupport) {
pParentWnd = m_pFullscreenWnd;
+ }
return pParentWnd;
}
void CMainFrame::OpenFile(OpenFileData* pOFD)
{
- if(pOFD->fns.IsEmpty())
+ if(pOFD->fns.IsEmpty()) {
throw ResStr(IDS_MAINFRM_81);
+ }
AppSettings& s = AfxGetAppSettings();
bool fFirst = true;
POSITION pos = pOFD->fns.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CString fn = pOFD->fns.GetNext(pos);
fn.Trim();
- if(fn.IsEmpty() && !fFirst)
+ if(fn.IsEmpty() && !fFirst) {
break;
+ }
HRESULT hr = pGB->RenderFile(CStringW(fn), NULL);
- if (!s.NewFile (fn) && s.fRememberFilePos)
- {
+ if (!s.NewFile (fn) && s.fRememberFilePos) {
REFERENCE_TIME rtPos = s.CurrentFilePosition()->llPosition;
- if (pMS) pMS->SetPositions (&rtPos, AM_SEEKING_AbsolutePositioning, NULL, AM_SEEKING_NoPositioning);
+ if (pMS) {
+ pMS->SetPositions (&rtPos, AM_SEEKING_AbsolutePositioning, NULL, AM_SEEKING_NoPositioning);
+ }
}
QueryPerformanceCounter(&m_LastSaveTime);
- if(FAILED(hr))
- {
- if(fFirst)
- {
- if(s.fReportFailedPins)
- {
+ if(FAILED(hr)) {
+ if(fFirst) {
+ if(s.fReportFailedPins) {
CComQIPtr<IGraphBuilderDeadEnd> pGBDE = pGB;
- if(pGBDE && pGBDE->GetCount()) CMediaTypesDlg(pGBDE, GetModalParent()).DoModal();
+ if(pGBDE && pGBDE->GetCount()) {
+ CMediaTypesDlg(pGBDE, GetModalParent()).DoModal();
+ }
}
CString err;
- switch(hr)
- {
- case E_ABORT:
- err = ResStr(IDS_MAINFRM_82);
- break;
- case E_FAIL:
- case E_POINTER:
- default:
- err = ResStr(IDS_MAINFRM_83);
- break;
- case E_INVALIDARG:
- err = ResStr(IDS_MAINFRM_84);
- break;
- case E_OUTOFMEMORY:
- err = ResStr(IDS_AG_OUT_OF_MEMORY);
- break;
- case VFW_E_CANNOT_CONNECT:
- err = ResStr(IDS_MAINFRM_86);
- break;
- case VFW_E_CANNOT_LOAD_SOURCE_FILTER:
- err = ResStr(IDS_MAINFRM_87);
- break;
- case VFW_E_CANNOT_RENDER:
- err = ResStr(IDS_MAINFRM_88);
- break;
- case VFW_E_INVALID_FILE_FORMAT:
- err = ResStr(IDS_MAINFRM_89);
- break;
- case VFW_E_NOT_FOUND:
- err = ResStr(IDS_MAINFRM_90);
- break;
- case VFW_E_UNKNOWN_FILE_TYPE:
- err = ResStr(IDS_MAINFRM_91);
- break;
- case VFW_E_UNSUPPORTED_STREAM:
- err = ResStr(IDS_MAINFRM_92);
- break;
+ switch(hr) {
+ case E_ABORT:
+ err = ResStr(IDS_MAINFRM_82);
+ break;
+ case E_FAIL:
+ case E_POINTER:
+ default:
+ err = ResStr(IDS_MAINFRM_83);
+ break;
+ case E_INVALIDARG:
+ err = ResStr(IDS_MAINFRM_84);
+ break;
+ case E_OUTOFMEMORY:
+ err = ResStr(IDS_AG_OUT_OF_MEMORY);
+ break;
+ case VFW_E_CANNOT_CONNECT:
+ err = ResStr(IDS_MAINFRM_86);
+ break;
+ case VFW_E_CANNOT_LOAD_SOURCE_FILTER:
+ err = ResStr(IDS_MAINFRM_87);
+ break;
+ case VFW_E_CANNOT_RENDER:
+ err = ResStr(IDS_MAINFRM_88);
+ break;
+ case VFW_E_INVALID_FILE_FORMAT:
+ err = ResStr(IDS_MAINFRM_89);
+ break;
+ case VFW_E_NOT_FOUND:
+ err = ResStr(IDS_MAINFRM_90);
+ break;
+ case VFW_E_UNKNOWN_FILE_TYPE:
+ err = ResStr(IDS_MAINFRM_91);
+ break;
+ case VFW_E_UNSUPPORTED_STREAM:
+ err = ResStr(IDS_MAINFRM_92);
+ break;
}
throw err;
}
}
- if(s.fKeepHistory)
- {
+ if(s.fKeepHistory) {
CRecentFileList* pMRU = fFirst ? &s.MRU : &s.MRUDub;
pMRU->ReadList();
pMRU->Add(fn);
@@ -10523,44 +10231,50 @@ void CMainFrame::OpenFile(OpenFileData* pOFD)
SHAddToRecentDocs(SHARD_PATH, fn);
}
- if(fFirst)
- {
+ if(fFirst) {
pOFD->title = fn;
}
fFirst = false;
- if(m_fCustomGraph) break;
+ if(m_fCustomGraph) {
+ break;
+ }
}
- if(s.fReportFailedPins)
- {
+ if(s.fReportFailedPins) {
CComQIPtr<IGraphBuilderDeadEnd> pGBDE = pGB;
- if(pGBDE && pGBDE->GetCount()) CMediaTypesDlg(pGBDE, GetModalParent()).DoModal();
+ if(pGBDE && pGBDE->GetCount()) {
+ CMediaTypesDlg(pGBDE, GetModalParent()).DoModal();
+ }
}
- if(!(pAMOP = pGB))
- {
+ if(!(pAMOP = pGB)) {
BeginEnumFilters(pGB, pEF, pBF)
- if(pAMOP = pBF) break;
+ if(pAMOP = pBF) {
+ break;
+ }
EndEnumFilters;
}
- if(FindFilter(__uuidof(CShoutcastSource), pGB))
+ if(FindFilter(__uuidof(CShoutcastSource), pGB)) {
m_fUpdateInfoBar = true;
+ }
SetupChapters();
CComQIPtr<IKeyFrameInfo> pKFI;
BeginEnumFilters(pGB, pEF, pBF)
- if(pKFI = pBF) break;
+ if(pKFI = pBF) {
+ break;
+ }
EndEnumFilters;
UINT nKFs = 0, nKFsTmp = 0;
- if(pKFI && S_OK == pKFI->GetKeyFrameCount(nKFs) && nKFs > 0)
- {
+ if(pKFI && S_OK == pKFI->GetKeyFrameCount(nKFs) && nKFs > 0) {
m_kfs.SetCount(nKFsTmp = nKFs);
- if(S_OK != pKFI->GetKeyFrames(&TIME_FORMAT_MEDIA_TIME, m_kfs.GetData(), nKFsTmp) || nKFsTmp != nKFs)
+ if(S_OK != pKFI->GetKeyFrames(&TIME_FORMAT_MEDIA_TIME, m_kfs.GetData(), nKFsTmp) || nKFsTmp != nKFs) {
m_kfs.RemoveAll();
+ }
}
SetPlaybackMode(PM_FILE);
@@ -10580,43 +10294,45 @@ void CMainFrame::SetupChapters()
POSITION pos;
pos = pBFs.GetHeadPosition();
- while(pos && !m_pCB->ChapGetCount())
- {
+ while(pos && !m_pCB->ChapGetCount()) {
IBaseFilter* pBF = pBFs.GetNext(pos);
CComQIPtr<IDSMChapterBag> pCB = pBF;
- if(!pCB) continue;
+ if(!pCB) {
+ continue;
+ }
- for(DWORD i = 0, cnt = pCB->ChapGetCount(); i < cnt; i++)
- {
+ for(DWORD i = 0, cnt = pCB->ChapGetCount(); i < cnt; i++) {
REFERENCE_TIME rt;
CComBSTR name;
- if(SUCCEEDED(pCB->ChapGet(i, &rt, &name)))
+ if(SUCCEEDED(pCB->ChapGet(i, &rt, &name))) {
m_pCB->ChapAppend(rt, name);
+ }
}
}
pos = pBFs.GetHeadPosition();
- while(pos && !m_pCB->ChapGetCount())
- {
+ while(pos && !m_pCB->ChapGetCount()) {
IBaseFilter* pBF = pBFs.GetNext(pos);
CComQIPtr<IChapterInfo> pCI = pBF;
- if(!pCI) continue;
+ if(!pCI) {
+ continue;
+ }
CHAR iso6391[3];
::GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SISO639LANGNAME, iso6391, 3);
CStringA iso6392 = ISO6391To6392(iso6391);
- if(iso6392.GetLength() < 3) iso6392 = "eng";
+ if(iso6392.GetLength() < 3) {
+ iso6392 = "eng";
+ }
UINT cnt = pCI->GetChapterCount(CHAPTER_ROOT_ID);
- for(UINT i = 1; i <= cnt; i++)
- {
+ for(UINT i = 1; i <= cnt; i++) {
UINT cid = pCI->GetChapterId(CHAPTER_ROOT_ID, i);
ChapterElement ce;
- if(pCI->GetChapterInfo(cid, &ce))
- {
+ if(pCI->GetChapterInfo(cid, &ce)) {
char pl[3] = {iso6392[0], iso6392[1], iso6392[2]};
char cc[] = " ";
CComBSTR name;
@@ -10627,27 +10343,26 @@ void CMainFrame::SetupChapters()
}
pos = pBFs.GetHeadPosition();
- while(pos && !m_pCB->ChapGetCount())
- {
+ while(pos && !m_pCB->ChapGetCount()) {
IBaseFilter* pBF = pBFs.GetNext(pos);
CComQIPtr<IAMExtendedSeeking, &IID_IAMExtendedSeeking> pES = pBF;
- if(!pES) continue;
+ if(!pES) {
+ continue;
+ }
long MarkerCount = 0;
- if(SUCCEEDED(pES->get_MarkerCount(&MarkerCount)))
- {
- for(long i = 1; i <= MarkerCount; i++)
- {
+ if(SUCCEEDED(pES->get_MarkerCount(&MarkerCount))) {
+ for(long i = 1; i <= MarkerCount; i++) {
double MarkerTime = 0;
- if(SUCCEEDED(pES->GetMarkerTime(i, &MarkerTime)))
- {
+ if(SUCCEEDED(pES->GetMarkerTime(i, &MarkerTime))) {
CStringW name;
name.Format(L"Chapter %d", i);
CComBSTR bstr;
- if(S_OK == pES->GetMarkerName(i, &bstr))
+ if(S_OK == pES->GetMarkerName(i, &bstr)) {
name = bstr;
+ }
m_pCB->ChapAppend(REFERENCE_TIME(MarkerTime*10000000), name);
}
@@ -10656,40 +10371,42 @@ void CMainFrame::SetupChapters()
}
pos = pBFs.GetHeadPosition();
- while(pos && !m_pCB->ChapGetCount())
- {
+ while(pos && !m_pCB->ChapGetCount()) {
IBaseFilter* pBF = pBFs.GetNext(pos);
- if(GetCLSID(pBF) != CLSID_OggSplitter)
+ if(GetCLSID(pBF) != CLSID_OggSplitter) {
continue;
+ }
- BeginEnumPins(pBF, pEP, pPin)
- {
- if(m_pCB->ChapGetCount()) break;
+ BeginEnumPins(pBF, pEP, pPin) {
+ if(m_pCB->ChapGetCount()) {
+ break;
+ }
- if(CComQIPtr<IPropertyBag> pPB = pPin)
- {
- for(int i = 1; ; i++)
- {
+ 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))
+ 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, &m, &wc, &s, &wc, &ms))
+ if(7 != swscanf_s(CStringW(var), L"%d%c%d%c%d%c%d", &h, &wc, &m, &wc, &s, &wc, &ms)) {
break;
+ }
CStringW name;
name.Format(L"Chapter %d", i);
var.Clear();
str += L"NAME";
- if(S_OK == pPB->Read(str, &var, NULL))
+ if(S_OK == pPB->Read(str, &var, NULL)) {
name = var;
+ }
m_pCB->ChapAppend(10000i64*(((h*60 + m)*60 + s)*1000 + ms), name);
}
@@ -10707,44 +10424,53 @@ void CMainFrame::OpenDVD(OpenDVDData* pODD)
AppSettings& s = AfxGetAppSettings();
- if(s.fReportFailedPins)
- {
+ if(s.fReportFailedPins) {
CComQIPtr<IGraphBuilderDeadEnd> pGBDE = pGB;
- if(pGBDE && pGBDE->GetCount()) CMediaTypesDlg(pGBDE, GetModalParent()).DoModal();
+ if(pGBDE && pGBDE->GetCount()) {
+ CMediaTypesDlg(pGBDE, GetModalParent()).DoModal();
+ }
}
- BeginEnumFilters(pGB, pEF, pBF)
- {
- if((pDVDC = pBF) && (pDVDI = pBF))
+ BeginEnumFilters(pGB, pEF, pBF) {
+ if((pDVDC = pBF) && (pDVDI = pBF)) {
break;
+ }
}
EndEnumFilters;
- if(hr == E_INVALIDARG)
+ if(hr == E_INVALIDARG) {
throw ResStr(IDS_MAINFRM_93);
- else if(hr == VFW_E_CANNOT_RENDER)
+ } else if(hr == VFW_E_CANNOT_RENDER) {
throw _T("Failed to render all pins of the DVD Navigator filter");
- else if(hr == VFW_S_PARTIAL_RENDER)
+ } else if(hr == VFW_S_PARTIAL_RENDER) {
throw _T("Failed to render some of the pins of the DVD Navigator filter");
- else if(hr == E_NOINTERFACE || !pDVDC || !pDVDI)
+ } else if(hr == E_NOINTERFACE || !pDVDC || !pDVDI) {
throw _T("Failed to query the needed interfaces for DVD playback");
- else if(hr == VFW_E_CANNOT_LOAD_SOURCE_FILTER)
+ } else if(hr == VFW_E_CANNOT_LOAD_SOURCE_FILTER) {
throw ResStr(IDS_MAINFRM_94);
- else if(FAILED(hr))
+ } else if(FAILED(hr)) {
throw ResStr(IDS_AG_FAILED);
+ }
WCHAR buff[_MAX_PATH];
ULONG len = 0;
- if(SUCCEEDED(hr = pDVDI->GetDVDDirectory(buff, countof(buff), &len)))
+ 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);
+ 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;
@@ -10754,8 +10480,7 @@ void CMainFrame::OpenDVD(OpenDVDData* pODD)
HRESULT CMainFrame::OpenBDAGraph()
{
HRESULT hr = pGB->RenderFile (L"",L"");
- if (!FAILED(hr))
- {
+ if (!FAILED(hr)) {
AddTextPassThruFilter();
SetPlaybackMode(PM_CAPTURE);
}
@@ -10769,22 +10494,21 @@ void CMainFrame::OpenCapture(OpenDeviceData* pODD)
m_VidDispName = pODD->DisplayName[0];
- if(!m_VidDispName.IsEmpty())
- {
- if(!CreateFilter(m_VidDispName, &pVidCapTmp, vidfrname))
+ if(!m_VidDispName.IsEmpty()) {
+ if(!CreateFilter(m_VidDispName, &pVidCapTmp, vidfrname)) {
throw ResStr(IDS_MAINFRM_96);
+ }
}
m_AudDispName = pODD->DisplayName[1];
- if(!m_AudDispName.IsEmpty())
- {
- if(!CreateFilter(m_AudDispName, &pAudCapTmp, audfrname))
+ if(!m_AudDispName.IsEmpty()) {
+ if(!CreateFilter(m_AudDispName, &pAudCapTmp, audfrname)) {
throw ResStr(IDS_MAINFRM_96);
+ }
}
- if(!pVidCapTmp && !pAudCapTmp)
- {
+ if(!pVidCapTmp && !pAudCapTmp) {
throw ResStr(IDS_MAINFRM_98);
}
@@ -10792,8 +10516,7 @@ void CMainFrame::OpenCapture(OpenDeviceData* pODD)
pVidCap = NULL;
pAudCap = NULL;
- if(FAILED(pCGB.CoCreateInstance(CLSID_CaptureGraphBuilder2)))
- {
+ if(FAILED(pCGB.CoCreateInstance(CLSID_CaptureGraphBuilder2))) {
throw ResStr(IDS_MAINFRM_99);
}
@@ -10801,49 +10524,47 @@ void CMainFrame::OpenCapture(OpenDeviceData* pODD)
pCGB->SetFiltergraph(pGB);
- if(pVidCapTmp)
- {
- if(FAILED(hr = pGB->AddFilter(pVidCapTmp, vidfrname)))
- {
+ if(pVidCapTmp) {
+ if(FAILED(hr = pGB->AddFilter(pVidCapTmp, vidfrname))) {
throw _T("Can't add video capture filter to the graph");
}
pVidCap = pVidCapTmp;
- if(!pAudCapTmp)
- {
+ 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)))
+ && 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)))
+ && 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)))
- {
+ && FAILED(pCGB->FindInterface(&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Audio, pVidCap, IID_IAMStreamConfig, (void **)&pAMASC))) {
TRACE(_T("Warning: No IAMStreamConfig interface for vidcap"));
- }
- else
- {
+ } else {
pAudCap = pVidCap;
}
- }
- else
- {
- if(FAILED(pCGB->FindInterface(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, pVidCap, IID_IAMStreamConfig, (void **)&pAMVSCCap)))
+ } 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)))
+ 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)))
+ 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)))
+ if(FAILED(pCGB->FindInterface(&LOOK_UPSTREAM_ONLY, NULL, pVidCap, IID_IAMTVTuner, (void**)&pAMTuner))) {
TRACE(_T("Warning: No IAMTVTuner interface was found\n"));
+ }
/*
if(pAMVSCCap)
{
@@ -10861,35 +10582,36 @@ void CMainFrame::OpenCapture(OpenDeviceData* pODD)
*/
// TODO: init pAMXBar
- if(pAMTuner) // load saved channel
- {
+ 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)
- {
+ 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();
+ if(fs == State_Running) {
+ pMC->Pause();
+ }
pAMTuner->put_Channel(vchannel, AMTUNER_SUBCHAN_DEFAULT, AMTUNER_SUBCHAN_DEFAULT);
- if(fs == State_Running) pMC->Run();
+ if(fs == State_Running) {
+ pMC->Run();
+ }
}
}
}
- if(pAudCapTmp)
- {
- if(FAILED(hr = pGB->AddFilter(pAudCapTmp, CStringW(audfrname))))
- {
+ if(pAudCapTmp) {
+ if(FAILED(hr = pGB->AddFilter(pAudCapTmp, CStringW(audfrname)))) {
throw _T("Can't add audio capture filter to the graph");
}
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)))
- {
+ && FAILED(pCGB->FindInterface(&PIN_CATEGORY_PREVIEW, &MEDIATYPE_Audio, pAudCap, IID_IAMStreamConfig, (void **)&pAMASC))) {
TRACE(_T("Warning: No IAMStreamConfig interface for vidcap"));
}
/*
@@ -10913,8 +10635,7 @@ void CMainFrame::OpenCapture(OpenDeviceData* pODD)
*/
}
- if(!(pVidCap || pAudCap))
- {
+ if(!(pVidCap || pAudCap)) {
throw ResStr(IDS_MAINFRM_108);
}
@@ -10925,21 +10646,21 @@ void CMainFrame::OpenCapture(OpenDeviceData* pODD)
void CMainFrame::OpenCustomizeGraph()
{
- if(GetPlaybackMode() == PM_CAPTURE)
+ if(GetPlaybackMode() == PM_CAPTURE) {
return;
+ }
CleanGraph();
- if(GetPlaybackMode() == PM_FILE)
- {
- if(m_pCAP && AfxGetAppSettings().fAutoloadSubtitles)
+ 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)
- {
+ if (r.m_RenderSettings.bSynchronizeVideo && s.iDSVideoRendererType == VIDRNDT_DS_SYNC) {
HRESULT hr;
m_pRefClock = DNew CSyncClockFilter(NULL, &hr);
CStringW name;
@@ -10957,70 +10678,73 @@ void CMainFrame::OpenCustomizeGraph()
m_pRefClock->QueryInterface(IID_ISyncClock, reinterpret_cast<void**>(&m_pSyncClock));
CComQIPtr<ISyncClockAdviser> pAdviser = m_pCAP;
- if (pAdviser)
+ 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;
+ 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;
+ 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)
- {
+ BeginEnumFilters(pGB, pEF, pBF) {
+ if(GetCLSID(pBF) == CLSID_OggSplitter) {
+ if(CComQIPtr<IAMStreamSelect> pSS = pBF) {
LCID idAudio = s.idAudioLang;
- if(!idAudio) idAudio = GetUserDefaultLCID();
+ if(!idAudio) {
+ idAudio = GetUserDefaultLCID();
+ }
LCID idSub = s.idSubtitlesLang;
- if(!idSub) idSub = GetUserDefaultLCID();
+ if(!idSub) {
+ idSub = GetUserDefaultLCID();
+ }
DWORD cnt = 0;
pSS->Count(&cnt);
- for(DWORD i = 0; i < cnt; i++)
- {
+ 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)))
- {
+ 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)))
+ && !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)))
+ && 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);
+ if(pmt) {
+ DeleteMediaType(pmt);
+ }
+ if(pszName) {
+ CoTaskMemFree(pszName);
+ }
}
}
}
@@ -11035,49 +10759,39 @@ void CMainFrame::OpenSetupVideo()
{
m_fAudioOnly = true;
- if (m_pMFVDC) // EVR
- {
+ if (m_pMFVDC) { // EVR
m_fAudioOnly = false;
- }
- else if(m_pCAP)
- {
+ } else if(m_pCAP) {
CSize vs = m_pCAP->GetVideoSize();
m_fAudioOnly = (vs.cx <= 0 || vs.cy <= 0);
- }
- else
- {
+ } else {
{
long w = 0, h = 0;
- if(CComQIPtr<IBasicVideo> pBV = pGB)
- {
+ if(CComQIPtr<IBasicVideo> pBV = pGB) {
pBV->GetVideoSize(&w, &h);
}
- if(w > 0 && h > 0)
- {
+ if(w > 0 && h > 0) {
m_fAudioOnly = false;
}
}
- if(m_fAudioOnly)
- {
- BeginEnumFilters(pGB, pEF, pBF)
- {
+ if(m_fAudioOnly) {
+ BeginEnumFilters(pGB, pEF, pBF) {
long w = 0, h = 0;
- if(CComQIPtr<IVideoWindow> pVW = pBF)
- {
+ if(CComQIPtr<IVideoWindow> pVW = pBF) {
long lVisible;
- if(FAILED(pVW->get_Visible(&lVisible)))
+ if(FAILED(pVW->get_Visible(&lVisible))) {
continue;
+ }
pVW->get_Width(&w);
pVW->get_Height(&h);
}
- if(w > 0 && h > 0)
- {
+ if(w > 0 && h > 0) {
m_fAudioOnly = false;
break;
}
@@ -11086,13 +10800,11 @@ void CMainFrame::OpenSetupVideo()
}
}
- if(m_fShockwaveGraph)
- {
+ if(m_fShockwaveGraph) {
m_fAudioOnly = false;
}
- if(m_pCAP)
- {
+ if(m_pCAP) {
SetShaders();
}
// else
@@ -11103,12 +10815,14 @@ void CMainFrame::OpenSetupVideo()
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
+ 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())
+ if (m_fAudioOnly && m_pFullscreenWnd->IsWindow()) {
m_pFullscreenWnd->DestroyWindow();
+ }
}
void CMainFrame::OpenSetupAudio()
@@ -11132,30 +10846,24 @@ void CMainFrame::OpenSetupToolBar()
*/
void CMainFrame::OpenSetupCaptureBar()
{
- if(GetPlaybackMode() == PM_CAPTURE)
- {
- if(pVidCap && pAMVSCCap)
- {
+ if(GetPlaybackMode() == PM_CAPTURE) {
+ if(pVidCap && pAMVSCCap) {
CComQIPtr<IAMVfwCaptureDialogs> pVfwCD = pVidCap;
- if(!pAMXBar && pVfwCD)
- {
+ if(!pAMXBar && pVfwCD) {
m_wndCaptureBar.m_capdlg.SetupVideoControls(m_VidDispName, pAMVSCCap, pVfwCD);
- }
- else
- {
+ } else {
m_wndCaptureBar.m_capdlg.SetupVideoControls(m_VidDispName, pAMVSCCap, pAMXBar, pAMTuner);
}
}
- if(pAudCap && pAMASC)
- {
+ if(pAudCap && pAMASC) {
CInterfaceArray<IAMAudioInputMixer> pAMAIM;
- BeginEnumPins(pAudCap, pEP, pPin)
- {
- if(CComQIPtr<IAMAudioInputMixer> pAIM = pPin)
+ BeginEnumPins(pAudCap, pEP, pPin) {
+ if(CComQIPtr<IAMAudioInputMixer> pAIM = pPin) {
pAMAIM.Add(pAIM);
+ }
}
EndEnumPins;
@@ -11170,55 +10878,54 @@ void CMainFrame::OpenSetupCaptureBar()
void CMainFrame::OpenSetupInfoBar()
{
- if(GetPlaybackMode() == PM_FILE)
- {
+ if(GetPlaybackMode() == PM_FILE) {
bool fEmpty = true;
- BeginEnumFilters(pGB, pEF, pBF)
- {
- if(CComQIPtr<IAMMediaContent, &IID_IAMMediaContent> pAMMC = pBF)
- {
+ BeginEnumFilters(pGB, pEF, pBF) {
+ if(CComQIPtr<IAMMediaContent, &IID_IAMMediaContent> pAMMC = pBF) {
CComBSTR bstr;
- if(SUCCEEDED(pAMMC->get_Title(&bstr)))
- {
+ if(SUCCEEDED(pAMMC->get_Title(&bstr))) {
m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_TITLE), bstr.m_str);
- if(bstr.Length()) fEmpty = false;
+ if(bstr.Length()) {
+ fEmpty = false;
+ }
}
bstr.Empty();
- if(SUCCEEDED(pAMMC->get_AuthorName(&bstr)))
- {
+ if(SUCCEEDED(pAMMC->get_AuthorName(&bstr))) {
m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_AUTHOR), bstr.m_str);
- if(bstr.Length()) fEmpty = false;
+ if(bstr.Length()) {
+ fEmpty = false;
+ }
}
bstr.Empty();
- if(SUCCEEDED(pAMMC->get_Copyright(&bstr)))
- {
+ if(SUCCEEDED(pAMMC->get_Copyright(&bstr))) {
m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_COPYRIGHT), bstr.m_str);
- if(bstr.Length()) fEmpty = false;
+ if(bstr.Length()) {
+ fEmpty = false;
+ }
}
bstr.Empty();
- if(SUCCEEDED(pAMMC->get_Rating(&bstr)))
- {
+ if(SUCCEEDED(pAMMC->get_Rating(&bstr))) {
m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_RATING), bstr.m_str);
- if(bstr.Length()) fEmpty = false;
+ if(bstr.Length()) {
+ fEmpty = false;
+ }
}
bstr.Empty();
- if(SUCCEEDED(pAMMC->get_Description(&bstr)))
- {
+ if(SUCCEEDED(pAMMC->get_Description(&bstr))) {
m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_DESCRIPTION), bstr.m_str);
- if(bstr.Length()) fEmpty = false;
+ if(bstr.Length()) {
+ fEmpty = false;
+ }
}
bstr.Empty();
- if(!fEmpty)
- {
+ if(!fEmpty) {
RecalcLayout();
break;
}
}
}
EndEnumFilters;
- }
- else if(GetPlaybackMode() == PM_DVD)
- {
+ } else if(GetPlaybackMode() == PM_DVD) {
CString info('-');
m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_DOMAIN), info);
m_wndInfoBar.SetLine(ResStr(IDS_INFOBAR_LOCATION), info);
@@ -11233,10 +10940,8 @@ void CMainFrame::OpenSetupStatsBar()
{
CString info('-');
- BeginEnumFilters(pGB, pEF, pBF)
- {
- if(!pQP && (pQP = pBF))
- {
+ 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);
@@ -11246,8 +10951,7 @@ void CMainFrame::OpenSetupStatsBar()
RecalcLayout();
}
- if(!pBI && (pBI = pBF))
- {
+ if(!pBI && (pBI = pBF)) {
m_wndStatsBar.SetLine(ResStr(IDS_AG_BUFFERS), info);
m_wndStatsBar.SetLine(_T("Bitrate"), info); // FIXME: shouldn't be here
RecalcLayout();
@@ -11262,40 +10966,34 @@ void CMainFrame::OpenSetupStatusBar()
//
- if(!m_fCustomGraph)
- {
+ if(!m_fCustomGraph) {
UINT id = IDB_NOAUDIO;
- BeginEnumFilters(pGB, pEF, pBF)
- {
+ BeginEnumFilters(pGB, pEF, pBF) {
CComQIPtr<IBasicAudio> pBA = pBF;
- if(!pBA) continue;
+ if(!pBA) {
+ continue;
+ }
- BeginEnumPins(pBF, pEP, pPin)
- {
+ BeginEnumPins(pBF, pEP, pPin) {
if(S_OK == pGB->IsPinDirection(pPin, PINDIR_INPUT)
- && S_OK == pGB->IsPinConnected(pPin))
- {
+ && 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;
+ 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)
- {
+ } else if(mt.majortype == MEDIATYPE_Midi) {
id = NULL;
break;
}
@@ -11303,8 +11001,7 @@ void CMainFrame::OpenSetupStatusBar()
}
EndEnumPins;
- if(id != IDB_NOAUDIO)
- {
+ if(id != IDB_NOAUDIO) {
break;
}
}
@@ -11317,18 +11014,13 @@ void CMainFrame::OpenSetupStatusBar()
HICON hIcon = NULL;
- if(GetPlaybackMode() == PM_FILE)
- {
+ 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)
- {
+ } else if(GetPlaybackMode() == PM_DVD) {
hIcon = LoadIcon(_T(".ifo"), true);
- }
- else if(GetPlaybackMode() == PM_DVD)
- {
+ } else if(GetPlaybackMode() == PM_DVD) {
// hIcon = ; // TODO
}
@@ -11343,24 +11035,19 @@ void CMainFrame::OpenSetupWindowTitle(CString fn)
int i = s.iTitleBarTextStyle;
- if(!fn.IsEmpty() && (i == 0 || i == 1))
- {
- if(i == 1)
- {
- if(GetPlaybackMode() == PM_FILE)
- {
+ 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)
- {
+ 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())
- {
+ if(SUCCEEDED(pAMMC->get_Title(&bstr)) && bstr.Length()) {
fn = CString(bstr.m_str);
break;
}
@@ -11368,13 +11055,9 @@ void CMainFrame::OpenSetupWindowTitle(CString fn)
}
EndEnumFilters;
}
- }
- else if(GetPlaybackMode() == PM_DVD)
- {
+ } else if(GetPlaybackMode() == PM_DVD) {
fn = _T("DVD");
- }
- else if(GetPlaybackMode() == PM_CAPTURE)
- {
+ } else if(GetPlaybackMode() == PM_CAPTURE) {
fn = _T("Live");
}
}
@@ -11391,13 +11074,15 @@ void CMainFrame::OpenSetupWindowTitle(CString fn)
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)))
+ if(FAILED(pSS->Info(a, NULL, NULL, NULL, NULL, &pName, NULL, NULL))) {
return false;
+ }
CString nameA(pName);
CoTaskMemFree(pName);
- if(FAILED(pSS->Info(b, NULL, NULL, NULL, NULL, &pName, NULL, NULL)))
+ if(FAILED(pSS->Info(b, NULL, NULL, NULL, NULL, &pName, NULL, NULL))) {
return false;
+ }
CString nameB(pName);
CoTaskMemFree(pName);
@@ -11406,17 +11091,19 @@ bool DoesAudioPrecede(const CComPtr<IAMStreamSelect> &pSS, int a, int b)
CStringW alo = AfxGetAppSettings().strAudiosLanguageOrder;
int tPos = 0;
CStringW lang = alo.Tokenize(_T(",; "), tPos);
- while(tPos != -1 && ia == -1 && ib == -1)
- {
+ while(tPos != -1 && ia == -1 && ib == -1) {
int ll = lang.GetLength();
- if(nameA.Left(ll).CompareNoCase(lang) == 0)
+ if(nameA.Left(ll).CompareNoCase(lang) == 0) {
ia = tPos;
- if(nameB.Left(ll).CompareNoCase(lang) == 0)
+ }
+ if(nameB.Left(ll).CompareNoCase(lang) == 0) {
ib = tPos;
+ }
lang = alo.Tokenize(_T(",; "), tPos);
}
- if(ia != -1 && ib == -1)
+ if(ia != -1 && ib == -1) {
return true;
+ }
return false;
}
@@ -11426,38 +11113,40 @@ void CMainFrame::InsertAudioStream(const CComQIPtr<IAMStreamSelect> &pSS, int i)
{
POSITION pos = m_iAudioStreams.GetHeadPosition();
bool processed = false;
- while(!processed && pos)
- {
+ while(!processed && pos) {
POSITION prevPos = pos;
int j = m_iAudioStreams.GetNext(pos);
- if(DoesAudioPrecede(pSS, i, j))
- {
- if(prevPos == m_iAudioStreams.GetHeadPosition())
+ if(DoesAudioPrecede(pSS, i, j)) {
+ if(prevPos == m_iAudioStreams.GetHeadPosition()) {
m_iAudioStreams.AddHead(i);
- else
+ } else {
m_iAudioStreams.InsertBefore(prevPos, i);
+ }
processed = true;
}
}
- if(!processed)
+ 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();
CComQIPtr<IAMStreamSelect> pSS = FindFilter(__uuidof(CAudioSwitcherFilter), pGB);
- if(!pSS) pSS = FindFilter(L"{D3CD7858-971A-4838-ACEC-40CA5D529DC8}", pGB); // morgan's switcher
+ 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++)
- {
+ if(pSS && SUCCEEDED(pSS->Count(&cStreams)) && cStreams > 0) {
+ for(int i = 0; i < (int)cStreams; i++) {
InsertAudioStream(pSS, i);
}
}
@@ -11467,8 +11156,7 @@ bool CMainFrame::OpenMediaPrivate(CAutoPtr<OpenMediaData> pOMD)
{
AppSettings& s = AfxGetAppSettings();
- if(m_iMediaLoadState != MLS_CLOSED)
- {
+ if(m_iMediaLoadState != MLS_CLOSED) {
ASSERT(0);
return(false);
}
@@ -11476,8 +11164,7 @@ bool CMainFrame::OpenMediaPrivate(CAutoPtr<OpenMediaData> pOMD)
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)
- {
+ if(!pFileData && !pDVDData && !pDeviceData) {
ASSERT(0);
return(false);
}
@@ -11485,12 +11172,10 @@ bool CMainFrame::OpenMediaPrivate(CAutoPtr<OpenMediaData> pOMD)
#ifdef _DEBUG
// Debug trace code - Begin
// Check for bad / buggy auto loading file code
- if ( pFileData )
- {
+ if ( pFileData ) {
POSITION pos = pFileData->fns.GetHeadPosition();
UINT index = 0;
- while ( pos != NULL )
- {
+ 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
@@ -11500,41 +11185,36 @@ bool CMainFrame::OpenMediaPrivate(CAutoPtr<OpenMediaData> pOMD)
// Debug trace code - End
#endif
- if(pFileData)
- {
- if(pFileData->fns.IsEmpty())
+ if(pFileData) {
+ if(pFileData->fns.IsEmpty()) {
return(false);
+ }
CString fn = pFileData->fns.GetHead();
int i = fn.Find(_T(":\\"));
- if(i > 0)
- {
+ 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)
- {
+ if(type == DRIVE_REMOVABLE || type == DRIVE_CDROM && GetCDROMType(drive[0], sl) != CDROM_Audio) {
int ret = IDRETRY;
- while(ret == IDRETRY)
- {
+ while(ret == IDRETRY) {
WIN32_FIND_DATA findFileData;
HANDLE h = FindFirstFile(fn, &findFileData);
- if(h != INVALID_HANDLE_VALUE)
- {
+ if(h != INVALID_HANDLE_VALUE) {
FindClose(h);
ret = IDOK;
- }
- else
- {
+ } else {
CString msg;
msg.Format(ResStr(IDS_MAINFRM_114), fn);
ret = AfxMessageBox(msg, MB_RETRYCANCEL);
}
}
- if(ret != IDOK)
+ if(ret != IDOK) {
return(false);
+ }
}
}
}
@@ -11549,33 +11229,41 @@ bool CMainFrame::OpenMediaPrivate(CAutoPtr<OpenMediaData> pOMD)
m_fUpdateInfoBar = false;
BeginWaitCursor();
- try
- {
+ try {
CComPtr<IVMRMixerBitmap9> pVMB;
CComPtr<IMFVideoMixerBitmap> pMFVMB;
- if(m_fOpeningAborted) throw aborted;
+ if(m_fOpeningAborted) {
+ throw aborted;
+ }
OpenCreateGraphObject(pOMD);
- if(m_fOpeningAborted) throw aborted;
+ if(m_fOpeningAborted) {
+ throw aborted;
+ }
SetupIViAudReg();
- if(m_fOpeningAborted) throw aborted;
+ if(m_fOpeningAborted) {
+ throw aborted;
+ }
- if(pFileData) OpenFile(pFileData);
- else if(pDVDData) OpenDVD(pDVDData);
- else if(pDeviceData)
- {
- if (s.iDefaultCaptureDevice == 1)
- {
+ if(pFileData) {
+ OpenFile(pFileData);
+ } else if(pDVDData) {
+ OpenDVD(pDVDData);
+ } else if(pDeviceData) {
+ if (s.iDefaultCaptureDevice == 1) {
HRESULT hr = OpenBDAGraph();
- if FAILED(hr) throw _T("Could not open capture device.");
- }
- else
+ if FAILED(hr) {
+ throw _T("Could not open capture device.");
+ }
+ } else {
OpenCapture(pDeviceData);
+ }
+ } else {
+ throw _T("Can't open, invalid input parameters");
}
- else throw _T("Can't open, invalid input parameters");
m_pCAP2 = NULL;
m_pCAP = NULL;
@@ -11585,12 +11273,12 @@ bool CMainFrame::OpenMediaPrivate(CAutoPtr<OpenMediaData> pOMD)
pGB->FindInterface(__uuidof(IVMRMixerControl9), (void**)&m_pMC, TRUE);
pGB->FindInterface(__uuidof(IVMRMixerBitmap9), (void**)&pVMB, TRUE);
pGB->FindInterface(__uuidof(IMFVideoMixerBitmap), (void**)&pMFVMB, TRUE);
- if (pVMB && s.fShowOSD)
+ if (pVMB && s.fShowOSD) {
m_OSD.Start (m_pVideoWnd, pVMB);
- else if (pMFVMB && s.fShowOSD)
+ } else if (pMFVMB && s.fShowOSD) {
m_OSD.Start (m_pVideoWnd, pMFVMB);
- if (m_pMC)
- {
+ }
+ if (m_pMC) {
m_pMC->GetProcAmpControlRange (0, (VMR9ProcAmpControlRange*)AfxGetMyApp()->GetColorControl (Brightness));
m_pMC->GetProcAmpControlRange (0, (VMR9ProcAmpControlRange*)AfxGetMyApp()->GetColorControl (Contrast));
m_pMC->GetProcAmpControlRange (0, (VMR9ProcAmpControlRange*)AfxGetMyApp()->GetColorControl (Hue));
@@ -11600,34 +11288,39 @@ bool CMainFrame::OpenMediaPrivate(CAutoPtr<OpenMediaData> pOMD)
// === EVR !
pGB->FindInterface(__uuidof(IMFVideoDisplayControl), (void**)&m_pMFVDC, TRUE);
- if (m_pMFVDC)
- {
+ 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_fOpeningAborted) throw aborted;
+ if(m_fOpeningAborted) {
+ throw aborted;
+ }
OpenCustomizeGraph();
- if(m_fOpeningAborted) throw aborted;
+ if(m_fOpeningAborted) {
+ throw aborted;
+ }
OpenSetupVideo();
- if(m_fOpeningAborted) throw aborted;
+ if(m_fOpeningAborted) {
+ throw aborted;
+ }
OpenSetupAudio();
- if(m_fOpeningAborted) throw aborted;
+ if(m_fOpeningAborted) {
+ throw aborted;
+ }
- if(m_pCAP && (!m_fAudioOnly || m_fRealMediaGraph))
- {
+ if(m_pCAP && (!m_fAudioOnly || m_fRealMediaGraph)) {
int nInternalSubCount = m_pSubStreams.GetCount();
- if(s.fDisableInternalSubtitles && nInternalSubCount > 0)
- {
+ if(s.fDisableInternalSubtitles && nInternalSubCount > 0) {
m_pSubStreams.RemoveAll(); // Needs to be replaced with code that checks for forced subtitles.
// Update the the internal subtitle count
@@ -11635,25 +11328,25 @@ bool CMainFrame::OpenMediaPrivate(CAutoPtr<OpenMediaData> pOMD)
}
POSITION pos = pOMD->subs.GetHeadPosition();
- while(pos) LoadSubtitle(pOMD->subs.GetNext(pos));
+ while(pos) {
+ LoadSubtitle(pOMD->subs.GetNext(pos));
+ }
- if(AfxGetAppSettings().fEnableSubtitles && m_pSubStreams.GetCount() > 0)
- {
+ if(AfxGetAppSettings().fEnableSubtitles && m_pSubStreams.GetCount() > 0) {
CComPtr<ISubStream> pSub = m_pSubStreams.GetHead();
- if(s.fPrioritizeExternalSubtitles && m_pSubStreams.GetCount() > nInternalSubCount)
- {
+ if(s.fPrioritizeExternalSubtitles && m_pSubStreams.GetCount() > nInternalSubCount) {
int nCurrentSubIndex = -1;
POSITION pos = m_pSubStreams.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
pSub = m_pSubStreams.GetNext(pos);
nCurrentSubIndex++;
- if(nCurrentSubIndex == nInternalSubCount)
+ if(nCurrentSubIndex == nInternalSubCount) {
break;
+ }
}
}
@@ -11661,28 +11354,29 @@ bool CMainFrame::OpenMediaPrivate(CAutoPtr<OpenMediaData> pOMD)
}
}
- if(m_fOpeningAborted) throw aborted;
+ if(m_fOpeningAborted) {
+ throw aborted;
+ }
OpenSetupWindowTitle(pOMD->title);
- if (s.fEnableEDLEditor)
+ if (s.fEnableEDLEditor) {
m_wndEditListEditor.OpenFile(pOMD->title);
+ }
- if(pFileData) m_OpenFile = true;
+ if(pFileData) {
+ m_OpenFile = true;
+ }
- if(::GetCurrentThreadId() == AfxGetApp()->m_nThreadID)
- {
+ if(::GetCurrentThreadId() == AfxGetApp()->m_nThreadID) {
OnFilePostOpenmedia();
- }
- else
- {
+ } else {
PostMessage(WM_COMMAND, ID_FILE_POST_OPENMEDIA);
}
while(m_iMediaLoadState != MLS_LOADED
&& m_iMediaLoadState != MLS_CLOSING // FIXME
- )
- {
+ ) {
Sleep(50);
}
@@ -11692,101 +11386,107 @@ bool CMainFrame::OpenMediaPrivate(CAutoPtr<OpenMediaData> pOMD)
PostMessage(WM_COMMAND, ID_PLAY_PAUSE);
- if(!(AfxGetAppSettings().nCLSwitches&CLSW_OPEN) && (AfxGetAppSettings().nLoops > 0))
+ if(!(AfxGetAppSettings().nCLSwitches&CLSW_OPEN) && (AfxGetAppSettings().nLoops > 0)) {
PostMessage(WM_COMMAND, ID_PLAY_PLAY);
+ }
// 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)
+ 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)
- {
+ 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)
- {
+ } catch(LPCTSTR msg) {
err = msg;
- }
- catch(CString msg)
- {
+ } catch(CString msg) {
err = msg;
}
EndWaitCursor();
- if(!err.IsEmpty())
- {
+ if(!err.IsEmpty()) {
CloseMediaPrivate();
m_closingmsg = err;
- if(err != aborted)
- {
- if(pFileData)
+ if(err != aborted) {
+ if(pFileData) {
m_wndPlaylistBar.SetCurValid(false);
- OnNavigateSkip(ID_NAVIGATE_SKIPFORWARD);
+ if(m_wndPlaylistBar.GetCount() > 1) {
+ if(flast_nID == ID_NAVIGATE_SKIPBACK) {
+ m_wndPlaylistBar.SetPrev();
+ } else {
+ m_wndPlaylistBar.SetNext();
+ }
+ OpenCurPlaylistItem();
+ }
+ } else {
+ OnNavigateSkip(ID_NAVIGATE_SKIPFORWARD);
+ }
}
- }
- else
- {
+ } else {
m_wndPlaylistBar.SetCurValid(true);
// Apply command line audio shift
- if (s.rtShift != 0)
- {
+ if (s.rtShift != 0) {
SetAudioDelay (s.rtShift);
s.rtShift = 0;
}
}
- if (AfxGetAppSettings().AutoChangeFullscrRes.bEnabled && m_fFullScreen) AutoChangeMonitorMode();
- if (m_fFullScreen && AfxGetAppSettings().fRememberZoomLevel) m_fFirstFSAfterLaunchOnFS = true;
+ 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
CString m_strOSD = _T("");
- if(pFileData)
- {
+ if(pFileData) {
m_strOSD = m_wndPlaylistBar.GetCurFileName();
- if(m_strOSD != _T(""))
- {
+ if(m_strOSD != _T("")) {
m_strOSD.TrimRight('/');
m_strOSD.Replace('\\', '/');
m_strOSD = m_strOSD.Mid(m_strOSD.ReverseFind('/')+1);
- }
- else
- {
+ } else {
m_strOSD = ResStr(ID_PLAY_PLAY);
int i = m_strOSD.Find(_T("\n"));
- if(i > 0) m_strOSD.Delete(i, m_strOSD.GetLength()-i);
+ if(i > 0) {
+ m_strOSD.Delete(i, m_strOSD.GetLength()-i);
+ }
m_strOSD += _T(" BD");
}
- }
- else if(pDVDData)
- {
+ } else if(pDVDData) {
m_strOSD = ResStr(ID_PLAY_PLAY);
int i = m_strOSD.Find(_T("\n"));
- if(i > 0) m_strOSD.Delete(i, m_strOSD.GetLength()-i);
+ if(i > 0) {
+ m_strOSD.Delete(i, m_strOSD.GetLength()-i);
+ }
m_strOSD += _T(" DVD");
}
- if(m_strOSD != _T("")) m_OSD.DisplayMessage(OSD_TOPLEFT, m_strOSD, 3000);
+ if(m_strOSD != _T("")) {
+ m_OSD.DisplayMessage(OSD_TOPLEFT, m_strOSD, 3000);
+ }
return(err.IsEmpty());
@@ -11811,8 +11511,8 @@ void CMainFrame::CloseMediaPrivate()
m_pCB = NULL;
-// if(pVW) pVW->put_Visible(OAFALSE);
-// if(pVW) pVW->put_MessageDrain((OAHWND)NULL), pVW->put_Owner((OAHWND)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;
@@ -11845,14 +11545,14 @@ void CMainFrame::CloseMediaPrivate()
pBV.Release();
pBA.Release();
- if(pGB)
- {
+ 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;
@@ -11898,43 +11598,45 @@ int CMainFrame::SearchInDir(bool DirForward)
CString mask = dir + _T("*.*");
WIN32_FIND_DATA fd;
HANDLE h = FindFirstFile(mask, &fd);
- if(h != INVALID_HANDLE_VALUE)
- {
- do
- {
- if(fd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) continue;
+ if(h != INVALID_HANDLE_VALUE) {
+ do {
+ if(fd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) {
+ continue;
+ }
CString fn = fd.cFileName;
CString ext = fn.Mid(fn.ReverseFind('.')).MakeLower();
CString path = dir + fd.cFileName;
- if(mf.FindExt(ext) && mf.GetCount() > 0)
- {
+ if(mf.FindExt(ext) && mf.GetCount() > 0) {
fileName f_name;
f_name.fn = path;
f_array.Add(f_name);
}
- }
- while(FindNextFile(h, &fd));
+ } while(FindNextFile(h, &fd));
FindClose(h);
}
- if(f_array.GetCount() == 1) return true;
+ if(f_array.GetCount() == 1) {
+ return true;
+ }
qsort(f_array.GetData(), f_array.GetCount(), sizeof(fileName), compare);
- for(int i = 0; i < f_array.GetCount(); i++)
+ for(int i = 0; i < f_array.GetCount(); i++) {
sl.AddTail(f_array[i].fn);
+ }
POSITION Pos;
Pos = sl.Find(m_LastOpenFile);
- if (DirForward)
- {
- if (Pos == sl.GetTailPosition()) return(false);
+ if (DirForward) {
+ if (Pos == sl.GetTailPosition()) {
+ return(false);
+ }
sl.GetNext(Pos);
- }
- else
- {
- if (Pos == sl.GetHeadPosition()) return(false);
+ } else {
+ if (Pos == sl.GetHeadPosition()) {
+ return(false);
+ }
sl.GetPrev(Pos);
}
Play_sl.AddHead(sl.GetAt(Pos));
@@ -11945,11 +11647,9 @@ int CMainFrame::SearchInDir(bool DirForward)
void CMainFrame::DoTunerScan(TunerScanData* pTSD)
{
- if(GetPlaybackMode() == PM_CAPTURE)
- {
+ if(GetPlaybackMode() == PM_CAPTURE) {
CComQIPtr<IBDATuner> pTun = pGB;
- if (pTun)
- {
+ if (pTun) {
BOOLEAN bPresent;
BOOLEAN bLocked;
LONG lStrength;
@@ -11960,15 +11660,12 @@ void CMainFrame::DoTunerScan(TunerScanData* pTSD)
bool bSucceeded;
m_bStopTunerScan = false;
- for(ULONG ulFrequency = pTSD->FrequencyStart; ulFrequency <= pTSD->FrequencyStop; ulFrequency += pTSD->Bandwidth)
- {
+ for(ULONG ulFrequency = pTSD->FrequencyStart; ulFrequency <= pTSD->FrequencyStop; ulFrequency += pTSD->Bandwidth) {
bSucceeded = false;
- for (int nOffsetPos = 0; nOffsetPos < nOffset && !bSucceeded; nOffsetPos++)
- {
+ for (int nOffsetPos = 0; nOffsetPos < nOffset && !bSucceeded; nOffsetPos++) {
pTun->SetFrequency (ulFrequency + lOffsets[nOffsetPos]);
Sleep (200);
- if (SUCCEEDED (pTun->GetStats (bPresent, bLocked, lStrength, lQuality)) && bPresent)
- {
+ 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;
@@ -11979,7 +11676,9 @@ void CMainFrame::DoTunerScan(TunerScanData* pTSD)
::SendMessage (pTSD->Hwnd, WM_TUNER_SCAN_PROGRESS, nProgress,0);
::SendMessage (pTSD->Hwnd, WM_TUNER_STATS, lStrength, lQuality);
- if (m_bStopTunerScan) break;
+ if (m_bStopTunerScan) {
+ break;
+ }
}
::SendMessage (pTSD->Hwnd, WM_TUNER_SCAN_END, 0, 0);
@@ -11991,32 +11690,30 @@ void CMainFrame::DoTunerScan(TunerScanData* pTSD)
void CMainFrame::SendNowPlayingToMSN()
{
- if(!AfxGetAppSettings().fNotifyMSN)
+ if(!AfxGetAppSettings().fNotifyMSN) {
return;
+ }
CString title, author;
- if(m_iMediaLoadState == MLS_LOADED)
- {
+ if(m_iMediaLoadState == MLS_LOADED) {
m_wndInfoBar.GetLine(ResStr(IDS_INFOBAR_TITLE), title);
m_wndInfoBar.GetLine(ResStr(IDS_INFOBAR_AUTHOR), author);
- if(title.IsEmpty())
- {
+ if(title.IsEmpty()) {
CPlaylistItem pli;
m_wndPlaylistBar.GetCur(pli);
- if(!pli.m_fns.IsEmpty())
- {
+ if(!pli.m_fns.IsEmpty()) {
CString label = !pli.m_label.IsEmpty() ? pli.m_label : pli.m_fns.GetHead();
- if(GetPlaybackMode() == PM_FILE)
- {
+ if(GetPlaybackMode() == PM_FILE) {
CString fn = label;
- if(fn.Find(_T("://")) >= 0)
- {
+ if(fn.Find(_T("://")) >= 0) {
int i = fn.Find('?');
- if(i >= 0) fn = fn.Left(i);
+ if(i >= 0) {
+ fn = fn.Left(i);
+ }
}
CPath path(fn);
path.StripPath();
@@ -12024,14 +11721,10 @@ void CMainFrame::SendNowPlayingToMSN()
path.RemoveExtension();
title = (LPCTSTR)path;
author.Empty();
- }
- else if(GetPlaybackMode() == PM_CAPTURE)
- {
+ } else if(GetPlaybackMode() == PM_CAPTURE) {
title = label != pli.m_fns.GetHead() ? label : _T("Live");
author.Empty();
- }
- else if(GetPlaybackMode() == PM_DVD)
- {
+ } else if(GetPlaybackMode() == PM_DVD) {
title = _T("DVD");
author.Empty();
}
@@ -12045,8 +11738,7 @@ void CMainFrame::SendNowPlayingToMSN()
buff += L"\\0";
buff += author.IsEmpty() ? L"{0}" : L"{0} - {1}";
buff += L"\\0";
- if(!author.IsEmpty())
- {
+ if(!author.IsEmpty()) {
buff += CStringW(author) + L"\\0";
}
buff += CStringW(title) + L"\\0";
@@ -12058,8 +11750,7 @@ void CMainFrame::SendNowPlayingToMSN()
data.cbData = buff.GetLength() * 2 + 2;
HWND hWnd = ::FindWindowEx(NULL, NULL, _T("MsnMsgrUIManager"), NULL);
- while(hWnd)
- {
+ while(hWnd) {
::SendMessage(hWnd, WM_COPYDATA, (WPARAM)NULL, (LPARAM)&data);
hWnd = ::FindWindowEx(NULL, hWnd, _T("MsnMsgrUIManager"), NULL);
}
@@ -12069,28 +11760,29 @@ void CMainFrame::SendNowPlayingToMSN()
void CMainFrame::SendNowPlayingTomIRC()
{
- if(!AfxGetAppSettings().fNotifyGTSdll)
+ if(!AfxGetAppSettings().fNotifyGTSdll) {
return;
+ }
- for(int i = 0; i < 20; i++)
- {
+ for(int i = 0; i < 20; i++) {
HANDLE hFMap = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, 1024, _T("mIRC"));
- if(!hFMap) return;
+ if(!hFMap) {
+ return;
+ }
- if(GetLastError() == ERROR_ALREADY_EXISTS)
- {
+ if(GetLastError() == ERROR_ALREADY_EXISTS) {
CloseHandle(hFMap);
Sleep(50);
continue;
}
- if(LPVOID lpMappingAddress = MapViewOfFile(hFMap, FILE_MAP_WRITE, 0, 0, 0))
- {
+ if(LPVOID lpMappingAddress = MapViewOfFile(hFMap, FILE_MAP_WRITE, 0, 0, 0)) {
LPCSTR cmd = m_fAudioOnly ? "/.timerAUDGTS 1 5 mpcaud" : "/.timerVIDGTS 1 5 mpcvid";
strcpy((char*)lpMappingAddress, cmd);
- if(HWND hWnd = ::FindWindow(_T("mIRC"), NULL))
+ if(HWND hWnd = ::FindWindow(_T("mIRC"), NULL)) {
::SendMessage(hWnd, (WM_USER + 200), (WPARAM)1, (LPARAM)0);
+ }
UnmapViewOfFile(lpMappingAddress);
}
@@ -12107,40 +11799,52 @@ void CMainFrame::SetupOpenCDSubMenu()
{
CMenu* pSub = &m_opencds;
- 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_LOADING) return;
+ if(m_iMediaLoadState == MLS_LOADING) {
+ return;
+ }
- if(AfxGetAppSettings().fHideCDROMsSubMenu) return;
+ if(AfxGetAppSettings().fHideCDROMsSubMenu) {
+ return;
+ }
UINT id = ID_FILE_OPEN_CD_START;
- for(TCHAR drive = 'C'; drive <= 'Z'; drive++)
- {
+ 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;
+ 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())
+ if(!str.IsEmpty()) {
pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, id++, str);
+ }
}
}
@@ -12148,67 +11852,62 @@ void CMainFrame::SetupFiltersSubMenu()
{
CMenu* pSub = &m_filters;
- 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)) {
+ ;
+ }
m_filterpopups.RemoveAll();
m_pparray.RemoveAll();
m_ssarray.RemoveAll();
- if(m_iMediaLoadState == MLS_LOADED)
- {
+ if(m_iMediaLoadState == MLS_LOADED) {
UINT idf = 0;
UINT ids = ID_FILTERS_SUBITEM_START;
UINT idl = ID_FILTERSTREAMS_SUBITEM_START;
- BeginEnumFilters(pGB, pEF, pBF)
- {
+ BeginEnumFilters(pGB, pEF, pBF) {
CString name(GetFilterName(pBF));
- if(name.GetLength() >= 43) name = name.Left(40) + _T("...");
+ if(name.GetLength() >= 43) {
+ name = name.Left(40) + _T("...");
+ }
CLSID clsid = GetCLSID(pBF);
- if(clsid == CLSID_AVIDec)
- {
+ if(clsid == CLSID_AVIDec) {
CComPtr<IPin> pPin = GetFirstPin(pBF);
AM_MEDIA_TYPE mt;
- if(pPin && SUCCEEDED(pPin->ConnectionMediaType(&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;
+ 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)
- {
+ } else if(clsid == CLSID_ACMWrapper) {
CComPtr<IPin> pPin = GetFirstPin(pBF);
AM_MEDIA_TYPE mt;
- if(pPin && SUCCEEDED(pPin->ConnectionMediaType(&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
- {
+ } else if(clsid == __uuidof(CTextPassThruFilter) || clsid == __uuidof(CNullTextRenderer)
+ || clsid == GUIDFromCString(_T("{48025243-2D39-11CE-875D-00608CB78066}"))) { // ISCR
// hide these
continue;
}
@@ -12236,21 +11935,20 @@ void CMainFrame::SetupFiltersSubMenu()
/* }
}
*/
- BeginEnumPins(pBF, pEP, pPin)
- {
+ BeginEnumPins(pBF, pEP, pPin) {
CString name = GetPinName(pPin);
name.Replace(_T("&"), _T("&&"));
- if(pSPP = pPin)
- {
+ if(pSPP = pPin) {
CAUUID caGUID;
caGUID.pElems = NULL;
- if(SUCCEEDED(pSPP->GetPages(&caGUID)) && caGUID.cElems > 0)
- {
+ 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);
+ if(caGUID.pElems) {
+ CoTaskMemFree(caGUID.pElems);
+ }
nPPages++;
}
@@ -12259,8 +11957,7 @@ void CMainFrame::SetupFiltersSubMenu()
EndEnumPins;
CComQIPtr<IAMStreamSelect> pSS = pBF;
- if(pSS)
- {
+ if(pSS) {
DWORD nStreams = 0;
DWORD flags = (DWORD)-1;
DWORD group = (DWORD)-1;
@@ -12271,31 +11968,29 @@ void CMainFrame::SetupFiltersSubMenu()
pSS->Count(&nStreams);
- if(nStreams > 0 && nPPages > 0) pSubSub->AppendMenu(MF_SEPARATOR|MF_ENABLED);
+ 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)
- {
+ 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)
+ if(group != prevgroup && idl > idlstart) {
pSubSub->AppendMenu(MF_SEPARATOR|MF_ENABLED);
+ }
prevgroup = group;
- if(flags & AMSTREAMSELECTINFO_EXCLUSIVE)
- {
- }
- else if(flags & AMSTREAMSELECTINFO_ENABLED)
- {
+ if(flags & AMSTREAMSELECTINFO_EXCLUSIVE) {
+ } else if(flags & AMSTREAMSELECTINFO_ENABLED) {
}
- if(!wname)
- {
+ if(!wname) {
CStringW stream(ResStr(IDS_AG_UNKNOWN_STREAM));
wname = (WCHAR*)CoTaskMemAlloc((stream.GetLength()+3+1)*sizeof(WCHAR));
swprintf(wname, L"%s %d", stream, min(i+1,999));
@@ -12309,19 +12004,17 @@ void CMainFrame::SetupFiltersSubMenu()
CoTaskMemFree(wname);
}
- if(nStreams == 0) pSS.Release();
+ if(nStreams == 0) {
+ pSS.Release();
+ }
}
- if(nPPages == 1 && !pSS)
- {
+ if(nPPages == 1 && !pSS) {
pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, ids, name);
- }
- else
- {
+ } else {
pSub->AppendMenu(MF_BYPOSITION|MF_STRING|MF_DISABLED|MF_GRAYED, idf, name);
- if(nPPages > 0 || pSS)
- {
+ if(nPPages > 0 || pSS) {
MENUITEMINFO mii;
mii.cbSize = sizeof(mii);
mii.fMask = MIIM_STATE|MIIM_SUBMENU;
@@ -12345,31 +12038,33 @@ void CMainFrame::SetupAudioSwitcherSubMenu()
{
CMenu* pSub = &m_audios;
- 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)
- {
+ 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) {
+ pSS = FindFilter(L"{D3CD7858-971A-4838-ACEC-40CA5D529DC8}", pGB);
+ }
- if(pSS)
- {
+ if(pSS) {
DWORD cStreams = 0;
- if(SUCCEEDED(pSS->Count(&cStreams)) && 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++)
- {
+ 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
+ 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("&&"));
@@ -12387,18 +12082,21 @@ void CMainFrame::SetupSubtitlesSubMenu()
{
CMenu* pSub = &m_subtitles;
- 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 || m_fAudioOnly || !m_pCAP)
+ if(m_iMediaLoadState != MLS_LOADED || m_fAudioOnly || !m_pCAP) {
return;
+ }
UINT id = ID_SUBTITLES_SUBITEM_START;
POSITION pos = m_pSubStreams.GetHeadPosition();
- if(pos)
- {
+ 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));
@@ -12409,37 +12107,34 @@ void CMainFrame::SetupSubtitlesSubMenu()
pSub->AppendMenu(MF_SEPARATOR);
}
- while(pos)
- {
+ while(pos) {
CComPtr<ISubStream> pSubStream = m_pSubStreams.GetNext(pos);
- if(!pSubStream) continue;
+ if(!pSubStream) {
+ continue;
+ }
- for(int i = 0, j = pSubStream->GetStreamCount(); i < j; i++)
- {
+ for(int i = 0, j = pSubStream->GetStreamCount(); i < j; i++) {
WCHAR* pName = NULL;
- if(SUCCEEDED(pSubStream->GetStreamInfo(i, &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
- {
+ } 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))
- {
+ if(pos && m_pSubStreams.GetAt(pos)) {
CLSID cur, next;
pSubStream->GetClassID(&cur);
m_pSubStreams.GetAt(pos)->GetClassID(&next);
- if(cur != next)
+ if(cur != next) {
pSub->AppendMenu(MF_SEPARATOR);
+ }
}
}
}
@@ -12448,71 +12143,75 @@ void CMainFrame::SetupNavAudioSubMenu()
{
CMenu* pSub = &m_navaudio;
- 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_AUDIO_SUBITEM_START;
- if(GetPlaybackMode() == PM_FILE || (GetPlaybackMode() == PM_CAPTURE && AfxGetAppSettings().iDefaultCaptureDevice == 1))
- {
+ if(GetPlaybackMode() == PM_FILE || (GetPlaybackMode() == PM_CAPTURE && AfxGetAppSettings().iDefaultCaptureDevice == 1)) {
SetupNavStreamSelectSubMenu(pSub, id, 1);
- }
- else if(GetPlaybackMode() == PM_DVD)
- {
+ } else if(GetPlaybackMode() == PM_DVD) {
ULONG ulStreamsAvailable, ulCurrentStream;
- if(FAILED(pDVDI->GetCurrentAudio(&ulStreamsAvailable, &ulCurrentStream)))
+ if(FAILED(pDVDI->GetCurrentAudio(&ulStreamsAvailable, &ulCurrentStream))) {
return;
+ }
LCID DefLanguage;
DVD_AUDIO_LANG_EXT ext;
- if(FAILED(pDVDI->GetDefaultAudioLanguage(&DefLanguage, &ext)))
+ if(FAILED(pDVDI->GetDefaultAudioLanguage(&DefLanguage, &ext))) {
return;
+ }
- for(ULONG i = 0; i < ulStreamsAvailable; i++)
- {
+ for(ULONG i = 0; i < ulStreamsAvailable; i++) {
LCID Language;
- if(FAILED(pDVDI->GetAudioLanguage(i, &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;
+ if(Language == DefLanguage) {
+ flags |= MF_DEFAULT;
+ }
+ if(i == ulCurrentStream) {
+ flags |= MF_CHECKED;
+ }
CString str(ResStr(IDS_AG_UNKNOWN));
- if(Language)
- {
+ if(Language) {
int len = GetLocaleInfo(Language, LOCALE_SENGLANGUAGE, str.GetBuffer(256), 256);
str.ReleaseBufferSetLength(max(len-1, 0));
}
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;
+ 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())
- {
+ if(!format.IsEmpty()) {
str.Format(ResStr(IDS_MAINFRM_11),
CString(str),
format,
@@ -12534,88 +12233,93 @@ void CMainFrame::SetupNavSubtitleSubMenu()
{
CMenu* pSub = &m_navsubtitle;
- 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_SUBP_SUBITEM_START;
- if(GetPlaybackMode() == PM_FILE || (GetPlaybackMode() == PM_CAPTURE && AfxGetAppSettings().iDefaultCaptureDevice == 1))
- {
+ if(GetPlaybackMode() == PM_FILE || (GetPlaybackMode() == PM_CAPTURE && AfxGetAppSettings().iDefaultCaptureDevice == 1)) {
SetupNavStreamSelectSubMenu(pSub, id, 2);
- }
- else if(GetPlaybackMode() == PM_DVD)
- {
+ } else if(GetPlaybackMode() == PM_DVD) {
ULONG ulStreamsAvailable, ulCurrentStream;
BOOL bIsDisabled;
if(FAILED(pDVDI->GetCurrentSubpicture(&ulStreamsAvailable, &ulCurrentStream, &bIsDisabled))
- || ulStreamsAvailable == 0)
+ || ulStreamsAvailable == 0) {
return;
+ }
LCID DefLanguage;
DVD_SUBPICTURE_LANG_EXT ext;
- if(FAILED(pDVDI->GetDefaultSubpictureLanguage(&DefLanguage, &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++)
- {
+ for(ULONG i = 0; i < ulStreamsAvailable; i++) {
LCID Language;
- if(FAILED(pDVDI->GetSubpictureLanguage(i, &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;
+ if(Language == DefLanguage) {
+ flags |= MF_DEFAULT;
+ }
+ if(i == ulCurrentStream) {
+ flags |= MF_CHECKED;
+ }
CString str(ResStr(IDS_AG_UNKNOWN));
- if(Language)
- {
+ if(Language) {
int len = GetLocaleInfo(Language, LOCALE_SENGLANGUAGE, str.GetBuffer(256), 256);
str.ReleaseBufferSetLength(max(len-1, 0));
}
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;
+ 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;
}
}
@@ -12630,29 +12334,35 @@ void CMainFrame::SetupNavAngleSubMenu()
{
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;
- if(GetPlaybackMode() == PM_FILE)
- {
+ if(GetPlaybackMode() == PM_FILE) {
SetupNavStreamSelectSubMenu(pSub, id, 0);
- }
- else if(GetPlaybackMode() == PM_DVD)
- {
+ } else if(GetPlaybackMode() == PM_DVD) {
ULONG ulStreamsAvailable, ulCurrentStream;
- if(FAILED(pDVDI->GetCurrentAngle(&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++)
- {
+ for(ULONG i = 1; i <= ulStreamsAvailable; i++) {
UINT flags = MF_BYCOMMAND|MF_STRING|MF_ENABLED;
- if(i == ulCurrentStream) flags |= MF_CHECKED;
+ if(i == ulCurrentStream) {
+ flags |= MF_CHECKED;
+ }
CString str;
str.Format(ResStr(IDS_AG_ANGLE), i);
@@ -12666,27 +12376,30 @@ void CMainFrame::SetupNavChaptersSubMenu()
{
CMenu* pSub = &m_navchapters;
- 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)
+ if(m_iMediaLoadState != MLS_LOADED) {
return;
+ }
UINT id = ID_NAVIGATE_CHAP_SUBITEM_START;
- if(GetPlaybackMode() == PM_FILE)
- {
+ if(GetPlaybackMode() == PM_FILE) {
SetupChapters();
REFERENCE_TIME rt = GetPos();
DWORD j = m_pCB->ChapLookup(&rt, NULL);
- for(DWORD i = 0; i < m_pCB->ChapGetCount(); i++, id++)
- {
+ for(DWORD i = 0; i < m_pCB->ChapGetCount(); i++, id++) {
rt = 0;
CComBSTR bstr;
- if(FAILED(m_pCB->ChapGet(i, &rt, &bstr)))
+ if(FAILED(m_pCB->ChapGet(i, &rt, &bstr))) {
continue;
+ }
int s = (int)((rt/10000000)%60);
int m = (int)((rt/10000000/60)%60);
@@ -12700,29 +12413,32 @@ void CMainFrame::SetupNavChaptersSubMenu()
name.Replace(_T("\t"), _T(" "));
UINT flags = MF_BYCOMMAND|MF_STRING|MF_ENABLED;
- if(i == j) flags |= MF_CHECKED;
- if(id != ID_NAVIGATE_CHAP_SUBITEM_START && i == 0) pSub->AppendMenu(MF_SEPARATOR);
+ if(i == j) {
+ flags |= MF_CHECKED;
+ }
+ if(id != ID_NAVIGATE_CHAP_SUBITEM_START && i == 0) {
+ pSub->AppendMenu(MF_SEPARATOR);
+ }
pSub->AppendMenu(flags, id, name + '\t' + time);
}
- if(m_wndPlaylistBar.GetCount() > 1)
- {
+ if(m_wndPlaylistBar.GetCount() > 1) {
POSITION pos = m_wndPlaylistBar.m_pl.GetHeadPosition();
- while(pos)
- {
+ 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())
+ 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)
- {
+ } else if(GetPlaybackMode() == PM_DVD) {
ULONG ulNumOfVolumes, ulVolume;
DVD_DISC_SIDE Side;
ULONG ulNumOfTitles = 0;
@@ -12737,11 +12453,14 @@ void CMainFrame::SetupNavChaptersSubMenu()
ULONG ulUOPs = 0;
pDVDI->GetCurrentUOPS(&ulUOPs);
- for(ULONG i = 1; i <= ulNumOfTitles; i++)
- {
+ 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;
+ if(i == Location.TitleNum) {
+ flags |= MF_CHECKED;
+ }
+ if(ulUOPs&UOP_FLAG_Play_Title) {
+ flags |= MF_DISABLED|MF_GRAYED;
+ }
CString str;
str.Format(ResStr(IDS_AG_TITLE), i);
@@ -12749,31 +12468,34 @@ void CMainFrame::SetupNavChaptersSubMenu()
pSub->AppendMenu(flags, id++, str);
}
- for(ULONG i = 1; i <= ulNumOfChapters; i++)
- {
+ 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;
+ 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(ResStr(IDS_AG_CHAPTER), i);
pSub->AppendMenu(flags, id++, str);
}
- }
- else if(GetPlaybackMode() == PM_CAPTURE && AfxGetAppSettings().iDefaultCaptureDevice == 1)
- {
+ } else if(GetPlaybackMode() == PM_CAPTURE && AfxGetAppSettings().iDefaultCaptureDevice == 1) {
AppSettings& s = AfxGetAppSettings();
POSITION pos = s.m_DVBChannels.GetHeadPosition();
- while (pos)
- {
+ while (pos) {
CDVBChannel& Channel = s.m_DVBChannels.GetNext(pos);
UINT flags = MF_BYCOMMAND|MF_STRING|MF_ENABLED;
- if (Channel.GetPrefNumber() == s.nDVBLastChannel)
+ if (Channel.GetPrefNumber() == s.nDVBLastChannel) {
flags |= MF_CHECKED;
+ }
pSub->AppendMenu(flags, ID_NAVIGATE_CHAP_SUBITEM_START + Channel.GetPrefNumber(), Channel.GetName());
}
}
@@ -12784,9 +12506,15 @@ IBaseFilter* CMainFrame::FindSourceSelectableFilter()
IBaseFilter* pSF = NULL;
pSF = FindFilter(CLSID_OggSplitter, pGB);
- if(!pSF) pSF = FindFilter(L"{55DA30FC-F16B-49fc-BAA5-AE59FC65F82D}", pGB);
- if(!pSF) pSF = FindFilter(__uuidof(CMpegSplitterFilter), pGB);
- if(!pSF) pSF = FindFilter(__uuidof(CMpegSourceFilter), pGB);
+ if(!pSF) {
+ pSF = FindFilter(L"{55DA30FC-F16B-49fc-BAA5-AE59FC65F82D}", pGB);
+ }
+ if(!pSF) {
+ pSF = FindFilter(__uuidof(CMpegSplitterFilter), pGB);
+ }
+ if(!pSF) {
+ pSF = FindFilter(__uuidof(CMpegSourceFilter), pGB);
+ }
return pSF;
}
@@ -12796,63 +12524,71 @@ void CMainFrame::SetupNavStreamSelectSubMenu(CMenu* pSub, UINT id, DWORD dwSelGr
UINT baseid = id;
CComQIPtr<IAMStreamSelect> pSS = FindSourceSelectableFilter();
- if (!pSS) pSS = pGB;
- if(!pSS) return;
+ if (!pSS) {
+ pSS = pGB;
+ }
+ if(!pSS) {
+ return;
+ }
DWORD cStreams;
- if(FAILED(pSS->Count(&cStreams)))
+ if(FAILED(pSS->Count(&cStreams))) {
return;
+ }
DWORD dwPrevGroup = (DWORD)-1;
- for(int i = 0, j = cStreams; i < j; i++)
- {
+ 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)
+ || !pszName) {
continue;
+ }
CString name(pszName);
CString lcname = CString(name).MakeLower();
- if(pszName) CoTaskMemFree(pszName);
+ if(pszName) {
+ CoTaskMemFree(pszName);
+ }
- if(dwGroup != dwSelGroup)
+ if(dwGroup != dwSelGroup) {
continue;
+ }
- if(dwPrevGroup != -1 && dwPrevGroup != dwGroup)
+ if(dwPrevGroup != -1 && dwPrevGroup != dwGroup) {
pSub->AppendMenu(MF_SEPARATOR);
+ }
dwPrevGroup = dwGroup;
CString str;
- if(lcname.Find(_T(" off")) >= 0)
- {
+ if(lcname.Find(_T(" off")) >= 0) {
str = ResStr(IDS_AG_DISABLED);
- }
- else
- {
- if(lcid == 0)
- {
+ } else {
+ if(lcid == 0) {
str.Format(ResStr(IDS_AG_UNKNOWN), id - baseid);
- }
- else
- {
+ } 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(")");
+ 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;
+ if(dwFlags) {
+ flags |= MF_CHECKED;
+ }
str.Replace(_T("&"), _T("&&"));
pSub->AppendMenu(flags, id++, str);
@@ -12862,30 +12598,37 @@ void CMainFrame::SetupNavStreamSelectSubMenu(CMenu* pSub, UINT id, DWORD dwSelGr
void CMainFrame::OnNavStreamSelectSubMenu(UINT id, DWORD dwSelGroup)
{
CComQIPtr<IAMStreamSelect> pSS = FindSourceSelectableFilter();
- if (!pSS) pSS = pGB;
- if(!pSS) return;
+ if (!pSS) {
+ pSS = pGB;
+ }
+ if(!pSS) {
+ return;
+ }
DWORD cStreams;
- if(FAILED(pSS->Count(&cStreams)))
+ if(FAILED(pSS->Count(&cStreams))) {
return;
+ }
- for(int i = 0, j = cStreams; i < j; i++)
- {
+ 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)
+ || !pszName) {
continue;
+ }
- if(pszName) CoTaskMemFree(pszName);
+ if(pszName) {
+ CoTaskMemFree(pszName);
+ }
- if(dwGroup != dwSelGroup)
+ if(dwGroup != dwSelGroup) {
continue;
+ }
- if(id == 0)
- {
+ if(id == 0) {
pSS->Enable(i, AMSTREAMSELECTENABLE_ENABLE);
break;
}
@@ -12898,33 +12641,31 @@ void CMainFrame::SetupRecentFilesSubMenu()
{
CMenu* pSub = &m_recentfiles;
- 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)) {
+ ;
+ }
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())
- {
+ for(int i = 0; i < MRU.GetSize(); i++) {
+ if(!MRU[i].IsEmpty()) {
mru_count++;
break;
}
}
- if(mru_count)
- {
+ 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++)
- {
+ for(int i = 0; i < MRU.GetSize(); i++) {
UINT flags = MF_BYCOMMAND|MF_STRING|MF_ENABLED;
- if(!MRU[i].IsEmpty())
- {
+ if(!MRU[i].IsEmpty()) {
pSub->AppendMenu(flags, id, MRU[i]);
}
id++;
@@ -12935,8 +12676,11 @@ void CMainFrame::SetupFavoritesSubMenu()
{
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();
@@ -12951,8 +12695,7 @@ void CMainFrame::SetupFavoritesSubMenu()
AfxGetAppSettings().GetFav(FAV_FILE, sl);
POSITION pos = sl.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
UINT flags = MF_BYCOMMAND|MF_STRING|MF_ENABLED;
CString str = sl.GetNext(pos);
@@ -12964,40 +12707,38 @@ void CMainFrame::SetupFavoritesSubMenu()
str = sl.RemoveHead();
- if(!sl.IsEmpty())
- {
+ if(!sl.IsEmpty()) {
bool bPositionDataPresent = false;
// pos
REFERENCE_TIME rt = 0;
- if(1 == _stscanf_s(sl.GetHead(), _T("%I64d"), &rt) && rt > 0)
- {
+ if(1 == _stscanf_s(sl.GetHead(), _T("%I64d"), &rt) && rt > 0) {
DVD_HMSF_TIMECODE hmsf = RT2HMSF(rt, 0);
str.Format(_T("%s\t[%02d:%02d:%02d]"), CString(str), hmsf.bHours, hmsf.bMinutes, hmsf.bSeconds);
bPositionDataPresent = true;
}
// relative drive
- if ( sl.GetCount() > 1 ) // Here to prevent crash if old favorites settings are present
- {
+ 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 ( _stscanf_s(sl.GetHead(), _T("%d"), &bRelativeDrive) == 1 ) {
str.Format(_T("%s%s[RD: %s]"), CString(str), bPositionDataPresent ? _T(" ") : _T("\t"), bRelativeDrive ? _T("On") : _T("Off"));
}
}
}
- if(!str.IsEmpty())
+ if(!str.IsEmpty()) {
pSub->AppendMenu(flags, id, str);
+ }
id++;
}
- if(id > ID_FAVORITES_FILE_START)
+ if(id > ID_FAVORITES_FILE_START) {
pSub->InsertMenu(nLastGroupStart, MF_SEPARATOR|MF_ENABLED|MF_BYPOSITION);
+ }
nLastGroupStart = pSub->GetMenuItemCount();
@@ -13006,8 +12747,7 @@ void CMainFrame::SetupFavoritesSubMenu()
s.GetFav(FAV_DVD, sl);
pos = sl.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
UINT flags = MF_BYCOMMAND|MF_STRING|MF_ENABLED;
CString str = sl.GetNext(pos);
@@ -13018,19 +12758,20 @@ void CMainFrame::SetupFavoritesSubMenu()
str = sl.RemoveHead();
- if(!sl.IsEmpty())
- {
+ if(!sl.IsEmpty()) {
// TODO
}
- if(!str.IsEmpty())
+ if(!str.IsEmpty()) {
pSub->AppendMenu(flags, id, str);
+ }
id++;
}
- if(id > ID_FAVORITES_DVD_START)
+ if(id > ID_FAVORITES_DVD_START) {
pSub->InsertMenu(nLastGroupStart, MF_SEPARATOR|MF_ENABLED|MF_BYPOSITION);
+ }
nLastGroupStart = pSub->GetMenuItemCount();
@@ -13039,8 +12780,7 @@ void CMainFrame::SetupFavoritesSubMenu()
s.GetFav(FAV_DEVICE, sl);
pos = sl.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
UINT flags = MF_BYCOMMAND|MF_STRING|MF_ENABLED;
CString str = sl.GetNext(pos);
@@ -13051,8 +12791,9 @@ void CMainFrame::SetupFavoritesSubMenu()
str = sl.RemoveHead();
- if(!str.IsEmpty())
+ if(!str.IsEmpty()) {
pSub->AppendMenu(flags, id, str);
+ }
id++;
}
@@ -13063,14 +12804,16 @@ void CMainFrame::SetupShadersSubMenu()
{
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_OFF, ResStr(IDS_SHADER_OFF));
- if(POSITION pos = AfxGetAppSettings().m_shaders.GetHeadPosition())
- {
+ if(POSITION pos = AfxGetAppSettings().m_shaders.GetHeadPosition()) {
pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, ID_SHADERS_COMBINE, ResStr(IDS_SHADER_COMBINE));
pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, ID_SHADERS_EDIT, ResStr(IDS_SHADER_EDIT));
pSub->AppendMenu(MF_BYCOMMAND|MF_STRING|MF_ENABLED, ID_SHADER_TOGGLE, ResStr(IDS_SHADER_TOGGLE));
@@ -13087,8 +12830,7 @@ void CMainFrame::SetupShadersSubMenu()
mii.cbSize = sizeof(mii);
mii.fMask |= MIIM_DATA;
- while(pos)
- {
+ while(pos) {
const AppSettings::Shader& s = AfxGetAppSettings().m_shaders.GetNext(pos);
CString label = s.label;
label.Replace(_T("&"), _T("&&"));
@@ -13110,30 +12852,35 @@ void CMainFrame::ShowControls(int nCS, bool fSave)
m_pLastBar = NULL;
POSITION pos = m_bars.GetHeadPosition();
- for(int i = 1; pos; i <<= 1)
- {
+ for(int i = 1; pos; i <<= 1) {
CControlBar* pNext = m_bars.GetNext(pos);
ShowControlBar(pNext, !!(nCS&i), TRUE);
- if(nCS&i) m_pLastBar = pNext;
+ if(nCS&i) {
+ m_pLastBar = pNext;
+ }
CSize s = pNext->CalcFixedLayout(FALSE, TRUE);
- if(nCSprev&i) hbefore += s.cy;
- if(nCS&i) hafter += s.cy;
+ if(nCSprev&i) {
+ hbefore += s.cy;
+ }
+ if(nCS&i) {
+ hafter += s.cy;
+ }
}
WINDOWPLACEMENT wp;
wp.length = sizeof(wp);
GetWindowPlacement(&wp);
- if(wp.showCmd != SW_SHOWMAXIMIZED && !m_fFullScreen)
- {
+ if(wp.showCmd != SW_SHOWMAXIMIZED && !m_fFullScreen) {
CRect r;
GetWindowRect(r);
MoveWindow(r.left, r.top, r.Width(), r.Height()+(hafter-hbefore));
}
- if(fSave)
+ if(fSave) {
AfxGetAppSettings().nCS = nCS;
+ }
RecalcLayout();
}
@@ -13142,23 +12889,22 @@ void CMainFrame::SetAlwaysOnTop(int i)
{
AfxGetAppSettings().iOnTop = i;
- if(!m_fFullScreen)
- {
+ if(!m_fFullScreen) {
const CWnd* pInsertAfter = NULL;
- if(i == 0)
+ if(i == 0) {
pInsertAfter = &wndNoTopMost;
- else if(i == 1)
+ } else if(i == 1) {
pInsertAfter = &wndTopMost;
- else // if(i == 2)
+ } else { // if(i == 2)
pInsertAfter = GetMediaState() == State_Running ? &wndTopMost : &wndNoTopMost;
+ }
SetWindowPos(pInsertAfter, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
- }
- else if(!(GetWindowLong(m_hWnd, GWL_EXSTYLE)&WS_EX_TOPMOST))
- {
- if (!AfxGetAppSettings().IsD3DFullscreen())
+ } else if(!(GetWindowLong(m_hWnd, GWL_EXSTYLE)&WS_EX_TOPMOST)) {
+ if (!AfxGetAppSettings().IsD3DFullscreen()) {
SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
+ }
}
}
@@ -13167,13 +12913,15 @@ void CMainFrame::SetAlwaysOnTop(int i)
bool DoesSubPrecede(const CComPtr<ISubStream> &a, const CComPtr<ISubStream> &b)
{
WCHAR *pName;
- if(!SUCCEEDED(a->GetStreamInfo(0, &pName, NULL)))
+ if(!SUCCEEDED(a->GetStreamInfo(0, &pName, NULL))) {
return false;
+ }
CStringW nameA(pName);
CoTaskMemFree(pName);
- if(!SUCCEEDED(b->GetStreamInfo(0, &pName, NULL)))
+ if(!SUCCEEDED(b->GetStreamInfo(0, &pName, NULL))) {
return false;
+ }
CStringW nameB(pName);
CoTaskMemFree(pName);
@@ -13182,17 +12930,19 @@ bool DoesSubPrecede(const CComPtr<ISubStream> &a, const CComPtr<ISubStream> &b)
CStringW slo = AfxGetAppSettings().strSubtitlesLanguageOrder;
int tPos = 0;
CStringW lang = slo.Tokenize(_T(",; "), tPos);
- while(tPos != -1 && ia == -1 && ib == -1)
- {
+ while(tPos != -1 && ia == -1 && ib == -1) {
int ll = lang.GetLength();
- if(nameA.Left(ll).CompareNoCase(lang) == 0)
+ if(nameA.Left(ll).CompareNoCase(lang) == 0) {
ia = tPos;
- if(nameB.Left(ll).CompareNoCase(lang) == 0)
+ }
+ if(nameB.Left(ll).CompareNoCase(lang) == 0) {
ib = tPos;
+ }
lang = slo.Tokenize(_T(",; "), tPos);
}
- if(ia != -1 && ib == -1)
+ if(ia != -1 && ib == -1) {
return true;
+ }
return false;
}
@@ -13202,48 +12952,52 @@ ISubStream *InsertSubStream(CInterfaceList<ISubStream> *subStreams, const CComPt
POSITION pos = subStreams->GetHeadPosition();
POSITION newPos = NULL;
bool processed = false;
- while(!processed && pos)
- {
+ while(!processed && pos) {
POSITION prevPos = pos;
CComPtr<ISubStream> pSubStream = subStreams->GetNext(pos);
- if(DoesSubPrecede(theSubStream, pSubStream))
- {
- if(prevPos == subStreams->GetHeadPosition())
+ if(DoesSubPrecede(theSubStream, pSubStream)) {
+ if(prevPos == subStreams->GetHeadPosition()) {
newPos = subStreams->AddHead(theSubStream);
- else
+ } else {
newPos = subStreams->InsertBefore(prevPos, theSubStream);
+ }
processed = true;
}
}
- if(!processed)
+ if(!processed) {
newPos = subStreams->AddTail(theSubStream);
- if(newPos == NULL)
+ }
+ if(newPos == NULL) {
newPos = subStreams->GetTailPosition();
- if(newPos == NULL)
+ }
+ if(newPos == NULL) {
return NULL;
+ }
return subStreams->GetAt(newPos);
}
void CMainFrame::AddTextPassThruFilter()
{
- BeginEnumFilters(pGB, pEF, pBF)
- {
- if(!IsSplitter(pBF)) continue;
+ BeginEnumFilters(pGB, pEF, pBF) {
+ if(!IsSplitter(pBF)) {
+ continue;
+ }
- BeginEnumPins(pBF, pEP, pPin)
- {
+ 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)
+ || 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)))
+ if(FAILED(pGB->AddFilter(pTPTF, name))) {
continue;
+ }
HRESULT hr;
@@ -13251,10 +13005,9 @@ void CMainFrame::AddTextPassThruFilter()
hr = pPin->Disconnect();
if(FAILED(hr = pGB->ConnectDirect(pPin, GetFirstPin(pTPTF, PINDIR_INPUT), NULL))
- || FAILED(hr = pGB->ConnectDirect(GetFirstPin(pTPTF, PINDIR_OUTPUT), pPinTo, NULL)))
+ || FAILED(hr = pGB->ConnectDirect(GetFirstPin(pTPTF, PINDIR_OUTPUT), pPinTo, NULL))) {
hr = pGB->ConnectDirect(pPin, pPinTo, NULL);
- else
- {
+ } else {
InsertSubStream(&m_pSubStreams, CComQIPtr<ISubStream>(pTPTF));
}
}
@@ -13268,33 +13021,30 @@ 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)
- {
+ 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)
+ if(CString(CPath(fn).GetExtension()).MakeLower() == _T(".idx") && pVSF && pVSF->Open(fn) && pVSF->GetStreamCount() > 0) {
pSubStream = pVSF.Detach();
+ }
}
- if(!pSubStream)
- {
+ if(!pSubStream) {
CAutoPtr<CRenderedTextSubtitle> pRTS(DNew CRenderedTextSubtitle(&m_csSubLock, &AfxGetAppSettings().subdefstyle, AfxGetAppSettings().fUseDefaultSubtitlesStyle));
- if(pRTS && pRTS->Open(fn, DEFAULT_CHARSET) && pRTS->GetStreamCount() > 0)
+ if(pRTS && pRTS->Open(fn, DEFAULT_CHARSET) && pRTS->GetStreamCount() > 0) {
pSubStream = pRTS.Detach();
+ }
}
- }
- catch(CException* e)
- {
+ } catch(CException* e) {
e->Delete();
}
- if(pSubStream)
- {
+ if(pSubStream) {
//m_pSubStreams.AddTail(pSubStream);
ISubStream *r = InsertSubStream(&m_pSubStreams, pSubStream);
- if(actualStream != NULL)
+ if(actualStream != NULL) {
*actualStream = r;
+ }
}
return(!!pSubStream);
@@ -13302,26 +13052,24 @@ bool CMainFrame::LoadSubtitle(CString fn, ISubStream **actualStream)
void CMainFrame::UpdateSubtitle(bool fDisplayMessage, bool fApplyDefStyle)
{
- if(!m_pCAP) return;
+ if(!m_pCAP) {
+ return;
+ }
int i = m_iSubtitleSel;
POSITION pos = m_pSubStreams.GetHeadPosition();
- while(pos && i >= 0)
- {
+ while(pos && i >= 0) {
CComPtr<ISubStream> pSubStream = m_pSubStreams.GetNext(pos);
- if(i < pSubStream->GetStreamCount())
- {
+ if(i < pSubStream->GetStreamCount()) {
CAutoLock cAutoLock(&m_csSubLock);
pSubStream->SetStream(i);
SetSubtitle(pSubStream, fApplyDefStyle);
- if (fDisplayMessage)
- {
+ if (fDisplayMessage) {
WCHAR* pName = NULL;
- if(SUCCEEDED(pSubStream->GetStreamInfo(0, &pName, NULL)))
- {
+ if(SUCCEEDED(pSubStream->GetStreamInfo(0, &pName, NULL))) {
CString strMessage;
strMessage.Format(ResStr(IDS_MAINFRM_45), pName, _T(""));
m_OSD.DisplayMessage (OSD_TOPLEFT, strMessage);
@@ -13333,8 +13081,9 @@ void CMainFrame::UpdateSubtitle(bool fDisplayMessage, bool fApplyDefStyle)
i -= pSubStream->GetStreamCount();
}
- if (fDisplayMessage && m_iSubtitleSel < 0)
+ if (fDisplayMessage && m_iSubtitleSel < 0) {
m_OSD.DisplayMessage (OSD_TOPLEFT, ResStr(IDS_MAINFRM_44));
+ }
m_pCAP->SetSubPicProvider(NULL);
}
@@ -13343,41 +13092,31 @@ void CMainFrame::SetSubtitle(ISubStream* pSubStream, bool fApplyDefStyle)
{
AppSettings& s = AfxGetAppSettings();
- if(pSubStream)
- {
+ if(pSubStream) {
CLSID clsid;
pSubStream->GetClassID(&clsid);
- if(clsid == __uuidof(CVobSubFile))
- {
+ if(clsid == __uuidof(CVobSubFile)) {
CVobSubFile* pVSF = (CVobSubFile*)(ISubStream*)pSubStream;
- if(fApplyDefStyle)
- {
+ if(fApplyDefStyle) {
pVSF->SetAlignment(s.fOverridePlacement, s.nHorPos, s.nVerPos, 1, 1);
}
- }
- else if(clsid == __uuidof(CVobSubStream))
- {
+ } else if(clsid == __uuidof(CVobSubStream)) {
CVobSubStream* pVSS = (CVobSubStream*)(ISubStream*)pSubStream;
- if(fApplyDefStyle)
- {
+ if(fApplyDefStyle) {
pVSS->SetAlignment(s.fOverridePlacement, s.nHorPos, s.nVerPos, 1, 1);
}
- }
- else if(clsid == __uuidof(CRenderedTextSubtitle))
- {
+ } else if(clsid == __uuidof(CRenderedTextSubtitle)) {
CRenderedTextSubtitle* pRTS = (CRenderedTextSubtitle*)(ISubStream*)pSubStream;
STSStyle style;
- if(fApplyDefStyle || pRTS->m_fUsingAutoGeneratedDefaultStyle)
- {
+ if(fApplyDefStyle || pRTS->m_fUsingAutoGeneratedDefaultStyle) {
style = s.subdefstyle;
- if(s.fOverridePlacement)
- {
+ if(s.fOverridePlacement) {
style.scrAlignment = 2;
int w = pRTS->m_dstScreenSize.cx;
int h = pRTS->m_dstScreenSize.cy;
@@ -13391,8 +13130,7 @@ void CMainFrame::SetSubtitle(ISubStream* pSubStream, bool fApplyDefStyle)
UNUSED_ALWAYS(res);
}
- if(pRTS->GetDefaultStyle(style) && style.relativeTo == 2)
- {
+ if(pRTS->GetDefaultStyle(style) && style.relativeTo == 2) {
style.relativeTo = s.subdefstyle.relativeTo;
pRTS->SetDefaultStyle(style);
}
@@ -13403,22 +13141,18 @@ void CMainFrame::SetSubtitle(ISubStream* pSubStream, bool fApplyDefStyle)
}
}
- if(!fApplyDefStyle)
- {
+ if(!fApplyDefStyle) {
m_iSubtitleSel = -1;
- if(pSubStream)
- {
+ if(pSubStream) {
int i = 0;
POSITION pos = m_pSubStreams.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CComPtr<ISubStream> pSubStream2 = m_pSubStreams.GetNext(pos);
- if(pSubStream == pSubStream2)
- {
+ if(pSubStream == pSubStream2) {
m_iSubtitleSel = i + pSubStream2->GetStream();
break;
}
@@ -13431,8 +13165,7 @@ void CMainFrame::SetSubtitle(ISubStream* pSubStream, bool fApplyDefStyle)
m_nSubtitleId = (DWORD_PTR)pSubStream;
- if(m_pCAP)
- {
+ if(m_pCAP) {
m_pCAP->SetSubPicProvider(CComQIPtr<ISubPicProvider>(pSubStream));
m_wndSubresyncBar.SetSubtitle(pSubStream, m_pCAP->GetFPS());
}
@@ -13441,11 +13174,9 @@ void CMainFrame::SetSubtitle(ISubStream* pSubStream, bool fApplyDefStyle)
void CMainFrame::ReplaceSubtitle(ISubStream* pSubStreamOld, ISubStream* pSubStreamNew)
{
POSITION pos = m_pSubStreams.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
POSITION cur = pos;
- if(pSubStreamOld == m_pSubStreams.GetNext(pos))
- {
+ if(pSubStreamOld == m_pSubStreams.GetNext(pos)) {
m_pSubStreams.SetAt(cur, pSubStreamNew);
UpdateSubtitle();
break;
@@ -13455,33 +13186,32 @@ void CMainFrame::ReplaceSubtitle(ISubStream* pSubStreamOld, ISubStream* pSubStre
void CMainFrame::InvalidateSubtitle(DWORD_PTR nSubtitleId, REFERENCE_TIME rtInvalidate)
{
- if(m_pCAP)
- {
- if(nSubtitleId == -1 || nSubtitleId == m_nSubtitleId)
+ 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();
+ while(pos) {
+ m_pSubStreams.GetNext(pos)->Reload();
+ }
UpdateSubtitle();
}
void CMainFrame::SetSubtitleTrackIdx(int index)
{
- if(m_iMediaLoadState == MLS_LOADED)
- {
- if (index < 0)
- {
+ if(m_iMediaLoadState == MLS_LOADED) {
+ if (index < 0) {
m_iSubtitleSel ^= 0x80000000;
- }
- else
- {
+ } else {
POSITION pos = m_pSubStreams.FindIndex(index);
- if(pos)
+ if(pos) {
m_iSubtitleSel = index;
+ }
}
UpdateSubtitle();
AfxGetAppSettings().fEnableSubtitles = !(m_iSubtitleSel & 0x80000000);
@@ -13490,16 +13220,18 @@ void CMainFrame::SetSubtitleTrackIdx(int index)
void CMainFrame::SetAudioTrackIdx(int index)
{
- if(m_iMediaLoadState == MLS_LOADED)
- {
+ 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
+ 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)))
+ if((index >= 0) && (index < ((int)cStreams))) {
pSS->Enable(index, dwFlags);
+ }
}
}
@@ -13519,11 +13251,12 @@ void CMainFrame::SeekTo(REFERENCE_TIME rtPos, bool fSeekToKeyFrame)
{
OAFilterState fs = GetMediaState();
- if(rtPos < 0) rtPos = 0;
+ if(rtPos < 0) {
+ rtPos = 0;
+ }
m_nStepForwardCount = 0;
- if(GetPlaybackMode() != PM_CAPTURE)
- {
+ if(GetPlaybackMode() != PM_CAPTURE) {
__int64 start, stop;
m_wndSeekBar.GetRange(start, stop);
GUID tf;
@@ -13532,38 +13265,34 @@ void CMainFrame::SeekTo(REFERENCE_TIME rtPos, bool fSeekToKeyFrame)
m_OSD.DisplayMessage(OSD_TOPLEFT, m_wndStatusBar.GetStatusTimer(), 1500);
}
- if(GetPlaybackMode() == PM_FILE)
- {
- if(fs == State_Stopped)
+ if(GetPlaybackMode() == PM_FILE) {
+ if(fs == State_Stopped) {
SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
+ }
HRESULT hr;
- if(fSeekToKeyFrame)
- {
- if(!m_kfs.IsEmpty())
- {
+ if(fSeekToKeyFrame) {
+ if(!m_kfs.IsEmpty()) {
int i = rangebsearch(rtPos, m_kfs);
- if(i >= 0 && i < m_kfs.GetCount())
+ if(i >= 0 && i < m_kfs.GetCount()) {
rtPos = m_kfs[i];
+ }
}
}
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)
+ } 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);
-// if(fs != State_Running)
-// SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
- }
- else if(GetPlaybackMode() == PM_CAPTURE)
- {
+ // if(fs != State_Running)
+ // SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
+ } else if(GetPlaybackMode() == PM_CAPTURE) {
TRACE(_T("Warning (CMainFrame::SeekTo): Trying to seek in capture mode"));
}
m_fEndOfStream = false;
@@ -13573,25 +13302,28 @@ void CMainFrame::SeekTo(REFERENCE_TIME rtPos, bool fSeekToKeyFrame)
void CMainFrame::CleanGraph()
{
- if(!pGB) return;
+ if(!pGB) {
+ return;
+ }
- BeginEnumFilters(pGB, pEF, pBF)
- {
+ BeginEnumFilters(pGB, pEF, pBF) {
CComQIPtr<IAMFilterMiscFlags> pAMMF(pBF);
- if(pAMMF && (pAMMF->GetMiscFlags()&AM_FILTER_MISC_FLAGS_IS_SOURCE))
+ 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)
+ if(pBF == pVidCap || pBF == pAudCap) {
continue;
+ }
- if(CComQIPtr<IFileSourceFilter>(pBF))
+ if(CComQIPtr<IFileSourceFilter>(pBF)) {
continue;
+ }
int nIn, nOut, nInC, nOutC;
- if(CountPins(pBF, nIn, nOut, nInC, nOutC) > 0 && (nInC+nOutC) == 0)
- {
+ if(CountPins(pBF, nIn, nOut, nInC, nOutC) > 0 && (nInC+nOutC) == 0) {
TRACE(CStringW(L"Removing: ") + GetFilterName(pBF) + '\n');
pGB->RemoveFilter(pBF);
@@ -13605,10 +13337,8 @@ void CMainFrame::CleanGraph()
static void SetLatency(IBaseFilter* pBF, int cbBuffer)
{
- BeginEnumPins(pBF, pEP, pPin)
- {
- if(CComQIPtr<IAMBufferNegotiation> pAMBN = pPin)
- {
+ BeginEnumPins(pBF, pEP, pPin) {
+ if(CComQIPtr<IAMBufferNegotiation> pAMBN = pPin) {
ALLOCATOR_PROPERTIES ap;
ap.cbAlign = -1; // -1 means no preference.
ap.cbBuffer = cbBuffer;
@@ -13626,35 +13356,38 @@ HRESULT CMainFrame::BuildCapture(IPin* pPin, IBaseFilter* pBF[3], const GUID& ma
IBaseFilter* pEnc = pBF[1];
IBaseFilter* pMux = pBF[2];
- if(!pPin || !pMux) return E_FAIL;
+ if(!pPin || !pMux) {
+ return E_FAIL;
+ }
CString err;
HRESULT hr = S_OK;
CFilterInfo fi;
- if(FAILED(pMux->QueryFilterInfo(&fi)) || !fi.pGraph)
+ if(FAILED(pMux->QueryFilterInfo(&fi)) || !fi.pGraph) {
pGB->AddFilter(pMux, L"Multiplexer");
+ }
CStringW prefix, prefixl;
- if(majortype == MEDIATYPE_Video) prefix = L"Video ";
- else if(majortype == MEDIATYPE_Audio) prefix = L"Audio ";
+ if(majortype == MEDIATYPE_Video) {
+ prefix = L"Video ";
+ } else if(majortype == MEDIATYPE_Audio) {
+ prefix = L"Audio ";
+ }
prefixl = prefix;
prefixl.MakeLower();
- if(pBuff)
- {
+ if(pBuff) {
hr = pGB->AddFilter(pBuff, prefix + L"Buffer");
- if(FAILED(hr))
- {
+ if(FAILED(hr)) {
err = _T("Can't add ") + CString(prefixl) + _T("buffer filter");
AfxMessageBox(err);
return hr;
}
hr = pGB->ConnectFilter(pPin, pBuff);
- if(FAILED(hr))
- {
+ if(FAILED(hr)) {
err = _T("Error connecting the ") + CString(prefixl) + _T("buffer filter");
AfxMessageBox(err);
return(hr);
@@ -13663,19 +13396,16 @@ HRESULT CMainFrame::BuildCapture(IPin* pPin, IBaseFilter* pBF[3], const GUID& ma
pPin = GetFirstPin(pBuff, PINDIR_OUTPUT);
}
- if(pEnc)
- {
+ if(pEnc) {
hr = pGB->AddFilter(pEnc, prefix + L"Encoder");
- if(FAILED(hr))
- {
+ if(FAILED(hr)) {
err = _T("Can't add ") + CString(prefixl) + _T("encoder filter");
AfxMessageBox(err);
return hr;
}
hr = pGB->ConnectFilter(pPin, pEnc);
- if(FAILED(hr))
- {
+ if(FAILED(hr)) {
err = _T("Error connecting the ") + CString(prefixl) + _T("encoder filter");
AfxMessageBox(err);
return(hr);
@@ -13683,13 +13413,10 @@ HRESULT CMainFrame::BuildCapture(IPin* pPin, IBaseFilter* pBF[3], const GUID& ma
pPin = GetFirstPin(pEnc, PINDIR_OUTPUT);
- if(CComQIPtr<IAMStreamConfig> pAMSC = pPin)
- {
- if(pmt->majortype == majortype)
- {
+ if(CComQIPtr<IAMStreamConfig> pAMSC = pPin) {
+ if(pmt->majortype == majortype) {
hr = pAMSC->SetFormat(pmt);
- if(FAILED(hr))
- {
+ if(FAILED(hr)) {
err = _T("Can't set compression format on the ") + CString(prefixl) + _T("encoder filter");
AfxMessageBox(err);
return(hr);
@@ -13699,11 +13426,10 @@ HRESULT CMainFrame::BuildCapture(IPin* pPin, IBaseFilter* pBF[3], const GUID& ma
}
-// if(pMux)
+ // if(pMux)
{
hr = pGB->ConnectFilter(pPin, pMux);
- if(FAILED(hr))
- {
+ if(FAILED(hr)) {
err = _T("Error connecting ") + CString(prefixl) + _T(" to the muliplexer filter");
AfxMessageBox(err);
return(hr);
@@ -13726,12 +13452,10 @@ bool CMainFrame::BuildToCapturePreviewPin(
CComPtr<IPin> pDVAudPin;
- if(pVidCap)
- {
+ 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)))
- {
+ && 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");
@@ -13750,12 +13474,8 @@ bool CMainFrame::BuildToCapturePreviewPin(
pPin = NULL;
hr = pCGB->FindPin(pDVDec, PINDIR_OUTPUT, NULL, &MEDIATYPE_Video, TRUE, 0, &pPin);
- }
- else if(SUCCEEDED(pCGB->FindPin(pVidCap, PINDIR_OUTPUT, &PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, TRUE, 0, &pPin)))
- {
- }
- else
- {
+ } else if(SUCCEEDED(pCGB->FindPin(pVidCap, PINDIR_OUTPUT, &PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, TRUE, 0, &pPin))) {
+ } else {
AfxMessageBox(_T("No video capture pin was found"));
return(false);
}
@@ -13770,18 +13490,12 @@ bool CMainFrame::BuildToCapturePreviewPin(
hr = pSmartTee->FindPin(L"Capture", ppVidCapPin);
}
- if(pAudCap || pDVAudPin)
- {
+ if(pAudCap || pDVAudPin) {
CComPtr<IPin> pPin;
- if(pDVAudPin)
- {
+ if(pDVAudPin) {
pPin = pDVAudPin;
- }
- else if(SUCCEEDED(pCGB->FindPin(pAudCap, PINDIR_OUTPUT, &PIN_CATEGORY_CAPTURE, &MEDIATYPE_Audio, TRUE, 0, &pPin)))
- {
- }
- else
- {
+ } else if(SUCCEEDED(pCGB->FindPin(pAudCap, PINDIR_OUTPUT, &PIN_CATEGORY_CAPTURE, &MEDIATYPE_Audio, TRUE, 0, &pPin))) {
+ } else {
AfxMessageBox(_T("No audio capture pin was found"));
return(false);
}
@@ -13801,7 +13515,9 @@ bool CMainFrame::BuildToCapturePreviewPin(
bool CMainFrame::BuildGraphVideoAudio(int fVPreview, bool fVCapture, int fAPreview, bool fACapture)
{
- if(!pCGB) return(false);
+ if(!pCGB) {
+ return(false);
+ }
SaveMediaState;
@@ -13812,9 +13528,15 @@ bool CMainFrame::BuildGraphVideoAudio(int fVPreview, bool fVCapture, int fAPrevi
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);
+ 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;
@@ -13828,30 +13550,30 @@ bool CMainFrame::BuildGraphVideoAudio(int fVPreview, bool fVCapture, int fAPrevi
bool fFileOutput = (pMux && pDst) || (pAudMux && pAudDst);
bool fCapture = (fVCapture || fACapture);
- if(pAudCap)
- {
+ 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);
+ 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)
+ // if(pVidCap)
{
bool fVidPrev = pVidPrevPin && fVPreview;
bool fVidCap = pVidCapPin && fVCapture && fFileOutput && m_wndCaptureBar.m_capdlg.m_fVidOutput;
- if(fVPreview == 2 && !fVidCap && pVidCapPin)
- {
+ if(fVPreview == 2 && !fVidCap && pVidCapPin) {
pVidPrevPin = pVidCapPin;
pVidCapPin = NULL;
}
- if(fVidPrev)
- {
+ if(fVidPrev) {
m_pCAP = NULL;
m_pCAP2 = NULL;
pGB->Render(pVidPrevPin);
@@ -13859,8 +13581,7 @@ bool CMainFrame::BuildGraphVideoAudio(int fVPreview, bool fVCapture, int fAPrevi
pGB->FindInterface(__uuidof(ISubPicAllocatorPresenter2), (void**)&m_pCAP2, TRUE);
}
- if(fVidCap)
- {
+ if(fVidCap) {
IBaseFilter* pBF[3] = {pVidBuffer, pVidEnc, pMux};
HRESULT hr = BuildCapture(pVidCapPin, pBF, MEDIATYPE_Video, &m_wndCaptureBar.m_capdlg.m_mtcv);
UNUSED_ALWAYS(hr);
@@ -13870,59 +13591,52 @@ bool CMainFrame::BuildGraphVideoAudio(int fVPreview, bool fVCapture, int fAPrevi
pCGB->FindInterface(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, pVidCap, IID_IAMDroppedFrames, (void**)&pAMDF);
}
-// if(pAudCap)
+ // if(pAudCap)
{
bool fAudPrev = pAudPrevPin && fAPreview;
bool fAudCap = pAudCapPin && fACapture && fFileOutput && m_wndCaptureBar.m_capdlg.m_fAudOutput;
- if(fAPreview == 2 && !fAudCap && pAudCapPin)
- {
+ if(fAPreview == 2 && !fAudCap && pAudCapPin) {
pAudPrevPin = pAudCapPin;
pAudCapPin = NULL;
}
- if(fAudPrev)
- {
+ if(fAudPrev) {
pGB->Render(pAudPrevPin);
}
- if(fAudCap)
- {
+ if(fAudCap) {
IBaseFilter* pBF[3] = {pAudBuffer, pAudEnc, pAudMux ? pAudMux : pMux};
HRESULT hr = BuildCapture(pAudCapPin, pBF, MEDIATYPE_Audio, &m_wndCaptureBar.m_capdlg.m_mtca);
UNUSED_ALWAYS(hr);
}
}
- if((pVidCap || pAudCap) && fCapture && fFileOutput)
- {
- if(pMux != pDst)
- {
+ 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)
- {
+ if(CComQIPtr<IConfigAviMux> pCAM = pMux) {
int nIn, nOut, nInC, nOutC;
CountPins(pMux, nIn, nOut, nInC, nOutC);
pCAM->SetMasterStream(nInC-1);
-// pCAM->SetMasterStream(-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)))
+ 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)
- {
+ if(pMux != pAudMux && pAudMux != pAudDst) {
hr = pGB->AddFilter(pAudDst, L"File Writer A");
hr = pGB->ConnectFilter(GetFirstPin(pAudMux, PINDIR_OUTPUT), pAudDst);
}
@@ -13945,16 +13659,20 @@ bool CMainFrame::BuildGraphVideoAudio(int fVPreview, bool fVCapture, int fAPrevi
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;
::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:
+ // hr = CComQIPtr<IAMGraphStreams>(pGB)->SyncUsingStreamOffset(TRUE); // TODO:
BuildGraphVideoAudio(
m_wndCaptureBar.m_capdlg.m_fVidPreview, true,
@@ -13971,9 +13689,13 @@ bool CMainFrame::StartCapture()
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;
@@ -14003,11 +13725,11 @@ void CMainFrame::ShowOptions(int idPage)
CPPageSheet options(ResStr(IDS_OPTIONS_CAPTION), pGB, GetModalParent(), idPage);
m_bInOptions = true;
- if(options.DoModal() == IDOK)
- {
+ if(options.DoModal() == IDOK) {
m_bInOptions = false;
- if(!m_fFullScreen)
+ if(!m_fFullScreen) {
SetAlwaysOnTop(s.iOnTop);
+ }
m_wndView.LoadLogo();
@@ -14020,14 +13742,16 @@ void CMainFrame::ShowOptions(int idPage)
void CMainFrame::StartWebServer(int nPort)
{
- if(!m_pWebServer)
+ if(!m_pWebServer) {
m_pWebServer.Attach(DNew CWebServer(this, nPort));
+ }
}
void CMainFrame::StopWebServer()
{
- if(m_pWebServer)
+ if(m_pWebServer) {
m_pWebServer.Free();
+ }
}
CString CMainFrame::GetStatusMessage()
@@ -14042,7 +13766,9 @@ void CMainFrame::SendStatusMessage(CString msg, int nTimeOut)
KillTimer(TIMER_STATUSERASER);
m_playingmsg.Empty();
- if(nTimeOut <= 0) return;
+ if(nTimeOut <= 0) {
+ return;
+ }
m_playingmsg = msg;
SetTimer(TIMER_STATUSERASER, nTimeOut, NULL);
@@ -14051,21 +13777,27 @@ void CMainFrame::SendStatusMessage(CString msg, int nTimeOut)
void CMainFrame::OpenCurPlaylistItem(REFERENCE_TIME rtStart)
{
- if(m_wndPlaylistBar.GetCount() == 0)
+ if(m_wndPlaylistBar.GetCount() == 0) {
return;
+ }
CPlaylistItem pli;
- if(!m_wndPlaylistBar.GetCur(pli)) m_wndPlaylistBar.SetFirstSelected();
- if(!m_wndPlaylistBar.GetCur(pli)) return;
+ 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);
+ if(p) {
+ OpenMedia(p);
+ }
}
void CMainFrame::AddCurDevToPlaylist()
{
- if(GetPlaybackMode() == PM_CAPTURE)
- {
+ if(GetPlaybackMode() == PM_CAPTURE) {
m_wndPlaylistBar.Append(
m_VidDispName,
m_AudDispName,
@@ -14079,11 +13811,9 @@ void CMainFrame::AddCurDevToPlaylist()
void CMainFrame::OpenMedia(CAutoPtr<OpenMediaData> pOMD)
{
// shortcut
- if(OpenDeviceData* p = dynamic_cast<OpenDeviceData*>(pOMD.m_p))
- {
+ 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_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);
@@ -14093,36 +13823,31 @@ void CMainFrame::OpenMedia(CAutoPtr<OpenMediaData> pOMD)
}
}
- if(m_iMediaLoadState != MLS_CLOSED)
+ if(m_iMediaLoadState != MLS_CLOSED) {
CloseMedia();
+ }
-// m_iMediaLoadState = MLS_LOADING; // HACK: hides the logo
+ // m_iMediaLoadState = MLS_LOADING; // HACK: hides the logo
AppSettings& s = AfxGetAppSettings();
bool fUseThread = m_pGraphThread && AfxGetAppSettings().fEnableWorkerThreadForOpening;
- if(OpenFileData* p = dynamic_cast<OpenFileData*>(pOMD.m_p))
- {
- if(p->fns.GetCount() > 0)
- {
+ 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*/)
+ if (e != DirectShow /*&& e != RealMedia && e != QuickTime*/) {
fUseThread = false;
+ }
}
- }
- else if(OpenDeviceData* p = dynamic_cast<OpenDeviceData*>(pOMD.m_p))
- {
+ } else if(OpenDeviceData* p = dynamic_cast<OpenDeviceData*>(pOMD.m_p)) {
fUseThread = false;
}
- if(fUseThread)
- {
+ if(fUseThread) {
m_pGraphThread->PostThreadMessage(CGraphThread::TM_OPEN, 0, (LPARAM)pOMD.Detach());
m_bOpenedThruThread = true;
- }
- else
- {
+ } else {
OpenMediaPrivate(pOMD);
m_bOpenedThruThread = false;
}
@@ -14130,29 +13855,29 @@ void CMainFrame::OpenMedia(CAutoPtr<OpenMediaData> pOMD)
bool CMainFrame::ResetDevice()
{
- if (m_pCAP)
+ if (m_pCAP) {
return m_pCAP->ResetDevice();
+ }
return true;
}
void CMainFrame::CloseMedia()
{
- if(m_iMediaLoadState == MLS_CLOSING)
- {
+ if(m_iMediaLoadState == MLS_CLOSING) {
TRACE(_T("WARNING: CMainFrame::CloseMedia() called twice or more\n"));
return;
}
int nTimeWaited = 0;
- while(m_iMediaLoadState == MLS_LOADING)
- {
+ 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)
- {
+ if(nTimeWaited > 5*1000 && m_pGraphThread) {
MessageBeep(MB_ICONEXCLAMATION);
TRACE(_T("CRITICAL ERROR: !!! Must kill opener thread !!!"));
TerminateThread(m_pGraphThread->m_hThread, (DWORD)-1);
@@ -14174,29 +13899,28 @@ void CMainFrame::CloseMedia()
OnFilePostClosemedia();
- if(m_pGraphThread && m_bOpenedThruThread)
- {
+ 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
- {
+ } else {
CloseMediaPrivate();
}
UnloadExternalObjects();
- if (m_pFullscreenWnd->IsWindow())
+ if (m_pFullscreenWnd->IsWindow()) {
m_pFullscreenWnd->ShowWindow (SW_HIDE);
+ }
}
void CMainFrame::StartTunerScan(CAutoPtr<TunerScanData> pTSD)
{
- if(m_pGraphThread)
+ if(m_pGraphThread) {
m_pGraphThread->PostThreadMessage(CGraphThread::TM_TUNER_SCAN, 0, (LPARAM)pTSD.Detach());
- else
+ } else {
DoTunerScan(pTSD);
+ }
}
void CMainFrame::StopTunerScan()
@@ -14212,15 +13936,17 @@ void CMainFrame::DisplayCurrentChannelOSD()
int i = osd.Find(_T("\n"));
PresentFollowing NowNext;
- if (pChannel != NULL)
- {
+ if (pChannel != NULL) {
// Get EIT information:
CComQIPtr<IBDATuner> pTun = pGB;
- if (pTun)
+ if (pTun) {
pTun->UpdatePSI(NowNext);
+ }
NowNext.cPresent.Insert(0,_T(" "));
osd = pChannel->GetName()+ NowNext.cPresent;
- if(i > 0) osd.Delete(i, osd.GetLength()-i);
+ if(i > 0) {
+ osd.Delete(i, osd.GetLength()-i);
+ }
m_OSD.DisplayMessage(OSD_TOPLEFT, osd ,3500);
}
}
@@ -14232,16 +13958,18 @@ void CMainFrame::DisplayCurrentChannelInfo()
CString osd;
PresentFollowing NowNext;
- if (pChannel != NULL)
- {
+ if (pChannel != NULL) {
// Get EIT information:
CComQIPtr<IBDATuner> pTun = pGB;
- if (pTun)
+ 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);
+ if(i > 0) {
+ osd.Delete(i, osd.GetLength()-i);
+ }
m_OSD.DisplayMessage(OSD_TOPLEFT, osd ,8000, 12);
}
}
@@ -14276,14 +14004,15 @@ END_MESSAGE_MAP()
void CGraphThread::OnExit(WPARAM wParam, LPARAM lParam)
{
PostQuitMessage(0);
- if(CAMEvent* e = (CAMEvent*)lParam) e->Set();
+ 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)
- {
+ if(m_pMainFrame) {
CAutoPtr<OpenMediaData> pOMD((OpenMediaData*)lParam);
m_pMainFrame->OpenMediaPrivate(pOMD);
}
@@ -14291,25 +14020,31 @@ void CGraphThread::OnOpen(WPARAM wParam, LPARAM lParam)
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)
- {
+ if(m_pMainFrame) {
BOOL* b = (BOOL*)wParam;
BOOL bResult = m_pMainFrame->ResetDevice();
- if (b) *b = bResult;
+ if (b) {
+ *b = bResult;
+ }
+ }
+ if(CAMEvent* e = (CAMEvent*)lParam) {
+ e->Set();
}
- if(CAMEvent* e = (CAMEvent*)lParam) e->Set();
}
void CGraphThread::OnTunerScan(WPARAM wParam, LPARAM lParam)
{
- if(m_pMainFrame)
- {
+ if(m_pMainFrame) {
CAutoPtr<TunerScanData> pTSD((TunerScanData*)lParam);
m_pMainFrame->DoTunerScan(pTSD);
}
@@ -14328,14 +14063,16 @@ void CMainFrame::SetPlayState(MPC_PLAYSTATE 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)
+ if(!m_fAudioOnly) {
SetThreadExecutionState (iState == PS_PLAY ? ES_CONTINUOUS | ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED : ES_CONTINUOUS);
- else
+ } else {
SetThreadExecutionState (iState == PS_PLAY ? ES_CONTINUOUS | ES_SYSTEM_REQUIRED : ES_CONTINUOUS);
+ }
// Set thumbnails button state
UpdateThumbarButton();
@@ -14347,8 +14084,9 @@ bool CMainFrame::CreateFullScreenWindow()
MONITORINFOEX MonitorInfo;
CRect MonitorRect;
- if (m_pFullscreenWnd->IsWindow())
+ if (m_pFullscreenWnd->IsWindow()) {
m_pFullscreenWnd->DestroyWindow();
+ }
ZeroMemory (&MonitorInfo, sizeof(MonitorInfo));
MonitorInfo.cbSize = sizeof(MonitorInfo);
@@ -14359,34 +14097,27 @@ bool CMainFrame::CreateFullScreenWindow()
AppSettings& s = AfxGetAppSettings();
hMonitor = NULL;
- if(!s.iMonitor)
- {
- if(s.strFullScreenMonitor == _T("Current"))
- {
+ if(!s.iMonitor) {
+ if(s.strFullScreenMonitor == _T("Current")) {
hMonitor = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
- }
- else
- {
- for ( int i = 0; i < monitors.GetCount(); i++ )
- {
+ } else {
+ for ( int i = 0; i < monitors.GetCount(); i++ ) {
monitor = monitors.GetMonitor( i );
monitor.GetName(str);
- if((monitor.IsMonitor()) && (s.strFullScreenMonitor == str))
- {
+ if((monitor.IsMonitor()) && (s.strFullScreenMonitor == str)) {
hMonitor = monitor;
break;
}
}
- if(!hMonitor) hMonitor = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
+ if(!hMonitor) {
+ hMonitor = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
+ }
}
- }
- else
- {
+ } else {
hMonitor = MonitorFromWindow (m_hWnd, 0);
}
- if (GetMonitorInfo (hMonitor, &MonitorInfo))
- {
+ if (GetMonitorInfo (hMonitor, &MonitorInfo)) {
MonitorRect = CRect (MonitorInfo.rcMonitor);
// Window creation
DWORD dwStyle = WS_POPUP | WS_VISIBLE ;
@@ -14394,7 +14125,7 @@ bool CMainFrame::CreateFullScreenWindow()
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);
-// SetWindowLong(m_pFullscreenWnd->m_hWnd, GWL_EXSTYLE, WS_EX_TOPMOST); // TODO : still freezing sometimes...
+ // SetWindowLong(m_pFullscreenWnd->m_hWnd, GWL_EXSTYLE, WS_EX_TOPMOST); // TODO : still freezing sometimes...
/*
CRect r;
GetWindowRect(r);
@@ -14422,8 +14153,7 @@ void CMainFrame::SetVMR9ColorControl(float dBrightness, float dContrast, float d
{
VMR9ProcAmpControl ClrControl;
- if(m_pMC && !AfxGetAppSettings().m_RenderersSettings.fVMR9MixerYUV)
- {
+ if(m_pMC && !AfxGetAppSettings().m_RenderersSettings.fVMR9MixerYUV) {
ClrControl.dwSize = sizeof(ClrControl);
ClrControl.dwFlags = ProcAmpControl9_Mask;
ClrControl.Brightness = dBrightness;
@@ -14437,25 +14167,24 @@ void CMainFrame::SetVMR9ColorControl(float dBrightness, float dContrast, float d
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);
+ 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);
}
}
@@ -14466,22 +14195,23 @@ afx_msg void CMainFrame::OnGotoSubtitle(UINT nID)
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)
+ 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)
- {
+ if (m_nCurSubtitle >= 0) {
long lShift = (nID == ID_SHIFT_SUB_DOWN) ? -100 : 100;
CString strSubShift;
- if (m_wndSubresyncBar.ShiftSubtitle (m_nCurSubtitle, lShift, m_rtCurSubPos))
- {
+ 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 (pMS) {
+ pMS->SetPositions (&m_rtCurSubPos, AM_SEEKING_AbsolutePositioning, NULL, AM_SEEKING_NoPositioning);
+ }
}
strSubShift.Format (ResStr(IDS_MAINFRM_138), m_lSubtitleShift);
@@ -14492,10 +14222,8 @@ afx_msg void CMainFrame::OnShiftSubtitle(UINT nID)
afx_msg void CMainFrame::OnSubtitleDelay(UINT nID)
{
- if(m_pCAP)
- {
- if (m_pSubStreams.IsEmpty())
- {
+ if(m_pCAP) {
+ if (m_pSubStreams.IsEmpty()) {
SendStatusMessage(ResStr(IDS_SUBTITLES_ERROR), 3000);
return;
}
@@ -14503,10 +14231,11 @@ afx_msg void CMainFrame::OnSubtitleDelay(UINT nID)
int newDelay;
int oldDelay = m_pCAP->GetSubtitleDelay();
- if(nID == ID_SUB_DELAY_DOWN)
+ if(nID == ID_SUB_DELAY_DOWN) {
newDelay = oldDelay-AfxGetAppSettings().nSubDelayInterval;
- else
+ } else {
newDelay = oldDelay+AfxGetAppSettings().nSubDelayInterval;
+ }
SetSubtitleDelay(newDelay);
}
@@ -14544,7 +14273,7 @@ afx_msg void CMainFrame::OnLanguage(UINT nID)
m_hMenuDefault = DefaultMenu;
DefaultMenu.Detach();
// TODO : destroy old menu ???
-// OldMenu->DestroyMenu();
+ // OldMenu->DestroyMenu();
}
@@ -14554,11 +14283,11 @@ afx_msg void CMainFrame::OnUpdateLanguage(CCmdUI* pCmdUI)
int nLang = pCmdUI->m_nID - ID_LANGUAGE_ENGLISH;
LPCTSTR strSatellite = AfxGetMyApp()->GetSatelliteDll(nLang);
- if (strSatellite)
- {
+ if (strSatellite) {
HMODULE lib = NULL;
- if ((lib = LoadLibrary(strSatellite)) != NULL)
+ if ((lib = LoadLibrary(strSatellite)) != NULL) {
FreeLibrary(lib);
+ }
pCmdUI->Enable(lib != NULL);
}
@@ -14573,107 +14302,107 @@ void CMainFrame::ProcessAPICommand(COPYDATASTRUCT* pCDS)
REFERENCE_TIME rtPos = 0;
long lPos = 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 :
- DVD_HMSF_TIMECODE tcPos;
-
- lPos = _wtol ((LPCWSTR)pCDS->lpData);
- tcPos.bHours = lPos/3600;
- tcPos.bMinutes = (lPos/60) % 60;
- tcPos.bSeconds = lPos%60;
- rtPos = HMSF2RT(tcPos);
- // 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)SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
- SeekTo(rtPos);
- 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);
- }
- 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_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;
+ 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 :
+ DVD_HMSF_TIMECODE tcPos;
+
+ lPos = _wtol ((LPCWSTR)pCDS->lpData);
+ tcPos.bHours = lPos/3600;
+ tcPos.bMinutes = (lPos/60) % 60;
+ tcPos.bSeconds = lPos%60;
+ rtPos = HMSF2RT(tcPos);
+ // 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) {
+ SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
+ }
+ SeekTo(rtPos);
+ 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);
+ }
+ 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_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;
}
}
@@ -14682,8 +14411,7 @@ void CMainFrame::SendAPICommand (MPCAPI_COMMAND nCommand, LPCWSTR fmt, ...)
{
AppSettings& s = AfxGetAppSettings();
- if (s.hMasterWnd)
- {
+ if (s.hMasterWnd) {
COPYDATASTRUCT CDS;
TCHAR buff[800];
@@ -14704,12 +14432,12 @@ void CMainFrame::SendAPICommand (MPCAPI_COMMAND nCommand, LPCWSTR fmt, ...)
void CMainFrame::SendNowPlayingToApi()
{
- if(!AfxGetAppSettings().hMasterWnd)
+ if(!AfxGetAppSettings().hMasterWnd) {
return;
+ }
- if(m_iMediaLoadState == MLS_LOADED)
- {
+ if(m_iMediaLoadState == MLS_LOADED) {
CPlaylistItem pli;
CString title, author, description;
CString label;
@@ -14721,11 +14449,9 @@ void CMainFrame::SendNowPlayingToApi()
m_wndInfoBar.GetLine(ResStr(IDS_INFOBAR_DESCRIPTION), description);
m_wndPlaylistBar.GetCur(pli);
- if(!pli.m_fns.IsEmpty())
- {
+ if(!pli.m_fns.IsEmpty()) {
label = !pli.m_label.IsEmpty() ? pli.m_label : pli.m_fns.GetHead();
- if(GetPlaybackMode() == PM_FILE)
- {
+ if(GetPlaybackMode() == PM_FILE) {
pMS->GetDuration(&rtDur);
DVD_HMSF_TIMECODE tcDur = RT2HMSF(rtDur);
lDuration = tcDur.bHours*60*60 + tcDur.bMinutes*60 + tcDur.bSeconds;
@@ -14775,47 +14501,37 @@ void CMainFrame::SendSubtitleTracksToApi()
CStringW strSubs;
POSITION pos = m_pSubStreams.GetHeadPosition();
- if(m_iMediaLoadState == MLS_LOADED)
- {
- if (pos)
- {
- while(pos)
- {
+ 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++)
- {
+ for(int i = 0, j = pSubStream->GetStreamCount(); i < j; i++) {
WCHAR* pName = NULL;
- if(SUCCEEDED(pSubStream->GetStreamInfo(i, &pName, NULL)))
- {
+ if(SUCCEEDED(pSubStream->GetStreamInfo(i, &pName, NULL))) {
CString name(pName);
- if (!strSubs.IsEmpty())
+ if (!strSubs.IsEmpty()) {
strSubs.Append (L"|");
+ }
name.Replace(L"|", L"\\|");
strSubs.AppendFormat(L"%s", name);
CoTaskMemFree(pName);
}
}
}
- if(AfxGetAppSettings().fEnableSubtitles)
- {
- if(m_iSubtitleSel >= 0)
+ if(AfxGetAppSettings().fEnableSubtitles) {
+ if(m_iSubtitleSel >= 0) {
strSubs.AppendFormat(L"|%i", m_iSubtitleSel);
- else
+ } else {
strSubs.Append(L"|-1");
- }
- else
- {
+ }
+ } else {
strSubs.Append (L"|-1");
}
- }
- else
- {
+ } else {
strSubs.Append (L"-1");
}
- }
- else
- {
+ } else {
strSubs.Append (L"-2");
}
SendAPICommand (CMD_LISTSUBTITLETRACKS, strSubs);
@@ -14826,44 +14542,46 @@ void CMainFrame::SendAudioTracksToApi()
{
CStringW strAudios;
- if(m_iMediaLoadState == MLS_LOADED)
- {
+ 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
+ if(!pSS) {
+ pSS = FindFilter(L"{D3CD7858-971A-4838-ACEC-40CA5D529DC8}", pGB); // morgan's switcher
+ }
DWORD cStreams = 0;
- if(pSS && SUCCEEDED(pSS->Count(&cStreams)))
- {
+ if(pSS && SUCCEEDED(pSS->Count(&cStreams))) {
int currentStream = -1;
- for(int i = 0; i < (int)cStreams; i++)
- {
+ 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)))
+ if(FAILED(pSS->Info(i, &pmt, &dwFlags, &lcid, &dwGroup, &pszName, NULL, NULL))) {
return;
- if(dwFlags == AMSTREAMSELECTINFO_EXCLUSIVE)
+ }
+ if(dwFlags == AMSTREAMSELECTINFO_EXCLUSIVE) {
currentStream = i;
+ }
CString name(pszName);
- if (!strAudios.IsEmpty())
+ if (!strAudios.IsEmpty()) {
strAudios.Append (L"|");
+ }
name.Replace(L"|", L"\\|");
strAudios.AppendFormat(L"%s", name);
- if(pmt) DeleteMediaType(pmt);
- if(pszName) CoTaskMemFree(pszName);
+ if(pmt) {
+ DeleteMediaType(pmt);
+ }
+ if(pszName) {
+ CoTaskMemFree(pszName);
+ }
}
strAudios.AppendFormat(L"|%i", currentStream);
- }
- else
- {
+ } else {
strAudios.Append(L"-1");
}
- }
- else
- {
+ } else {
strAudios.Append(L"-2");
}
SendAPICommand (CMD_LISTAUDIOTRACKS, strAudios);
@@ -14877,43 +14595,41 @@ void CMainFrame::SendPlaylistToApi()
int index;
POSITION pos = m_wndPlaylistBar.m_pl.GetHeadPosition(), pos2;
- while(pos)
- {
+ while(pos) {
CPlaylistItem& pli = m_wndPlaylistBar.m_pl.GetNext(pos);
- if(pli.m_type == CPlaylistItem::file)
- {
+ if(pli.m_type == CPlaylistItem::file) {
pos2 = pli.m_fns.GetHeadPosition();
- while(pos2)
- {
+ while(pos2) {
CString fn = pli.m_fns.GetNext(pos2);
- if (!strPlaylist.IsEmpty())
+ if (!strPlaylist.IsEmpty()) {
strPlaylist.Append (L"|");
+ }
fn.Replace(L"|", L"\\|");
strPlaylist.AppendFormat(L"%s", fn);
}
}
}
index = m_wndPlaylistBar.GetSelIdx();
- if (strPlaylist.IsEmpty())
+ if (strPlaylist.IsEmpty()) {
strPlaylist.Append(L"-1");
- else
+ } else {
strPlaylist.AppendFormat(L"|%i", index);
+ }
SendAPICommand (CMD_PLAYLIST, strPlaylist);
}
void CMainFrame::SendCurrentPositionToApi(bool fNotifySeek)
{
- if(!AfxGetAppSettings().hMasterWnd)
+ if(!AfxGetAppSettings().hMasterWnd) {
return;
+ }
- if(m_iMediaLoadState == MLS_LOADED)
- {
+ if(m_iMediaLoadState == MLS_LOADED) {
long lPosition = 0;
REFERENCE_TIME rtCur;
- if(m_iPlaybackMode == PM_FILE)
- {
+ if(m_iPlaybackMode == PM_FILE) {
pMS->GetCurrentPosition(&rtCur);
DVD_HMSF_TIMECODE tcCur = RT2HMSF(rtCur);
lPosition = tcCur.bHours*60*60 + tcCur.bMinutes*60 + tcCur.bSeconds;
@@ -14933,13 +14649,11 @@ void CMainFrame::ShowOSDCustomMessageApi(MPC_OSDDATA *osdData)
void CMainFrame::JumpOfNSeconds(int nSeconds)
{
- if(m_iMediaLoadState == MLS_LOADED)
- {
+ if(m_iMediaLoadState == MLS_LOADED) {
long lPosition = 0;
REFERENCE_TIME rtCur;
- if(m_iPlaybackMode == PM_FILE)
- {
+ if(m_iPlaybackMode == PM_FILE) {
pMS->GetCurrentPosition(&rtCur);
DVD_HMSF_TIMECODE tcCur = RT2HMSF(rtCur);
lPosition = tcCur.bHours*60*60 + tcCur.bMinutes*60 + tcCur.bSeconds + nSeconds;
@@ -14953,10 +14667,11 @@ void CMainFrame::JumpOfNSeconds(int nSeconds)
// 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);
+ if(!m_fAudioOnly) {
+ SendMessage(WM_COMMAND, ID_PLAY_PAUSE);
+ }
SeekTo(rtCur);
- if(!m_fAudioOnly)
- {
+ 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);
@@ -15068,7 +14783,9 @@ void CMainFrame::JumpOfNSeconds(int nSeconds)
void CMainFrame::OnFileOpendirectory()
{
- if(m_iMediaLoadState == MLS_LOADING || !IsWindow(m_wndPlaylistBar)) return;
+ if(m_iMediaLoadState == MLS_LOADING || !IsWindow(m_wndPlaylistBar)) {
+ return;
+ }
AppSettings& s = AfxGetAppSettings();
@@ -15094,24 +14811,24 @@ void CMainFrame::OnFileOpendirectory()
static LPITEMIDLIST iil;
iil = SHBrowseForFolder(&bi);
- if(iil)
- {
+ if(iil) {
SHGetPathFromIDList(iil, path);
CString _path = path;
_path.Replace('/', '\\');
- if(_path[_path.GetLength()-1] != '\\') _path += '\\';
+ if(_path[_path.GetLength()-1] != '\\') {
+ _path += '\\';
+ }
s.strLastOpenDir = _path;
CAtlList<CString> sl;
sl.AddTail(_path);
- if(COpenDirHelper::m_incl_subdir) COpenDirHelper::RecurseAddDir(_path, &sl);
+ if(COpenDirHelper::m_incl_subdir) {
+ COpenDirHelper::RecurseAddDir(_path, &sl);
+ }
- if(m_wndPlaylistBar.IsWindowVisible())
- {
+ if(m_wndPlaylistBar.IsWindowVisible()) {
m_wndPlaylistBar.Append(sl, true);
- }
- else
- {
+ } else {
m_wndPlaylistBar.Open(sl, true);
OpenCurPlaylistItem();
}
@@ -15122,22 +14839,26 @@ void CMainFrame::OnFileOpendirectory()
HRESULT CMainFrame::CreateThumbnailToolbar()
{
- if(!AfxGetAppSettings().fUseWin7TaskBar) return E_FAIL;
+ if(!AfxGetAppSettings().fUseWin7TaskBar) {
+ return E_FAIL;
+ }
DWORD dwMajor = LOBYTE(LOWORD(GetVersion()));
DWORD dwMinor = HIBYTE(LOWORD(GetVersion()));
- if (!( dwMajor > 6 || ( dwMajor == 6 && dwMinor > 0 ))) return E_FAIL;
+ if (!( dwMajor > 6 || ( dwMajor == 6 && dwMinor > 0 ))) {
+ return E_FAIL;
+ }
- if(m_pTaskbarList) m_pTaskbarList->Release();
+ if(m_pTaskbarList) {
+ m_pTaskbarList->Release();
+ }
HRESULT hr = CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&m_pTaskbarList));
- if (SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
Gdiplus::GdiplusStartupInput gdiplusStartupInput;
Gdiplus::GdiplusStartup(&m_gdiplusToken, &gdiplusStartupInput, NULL);
CGdiPlusBitmapResource* pBitmap = new CGdiPlusBitmapResource;
- if (!pBitmap->Load(_T("W7_TOOLBAR"), _T("PNG"), AfxGetInstanceHandle()))
- {
+ if (!pBitmap->Load(_T("W7_TOOLBAR"), _T("PNG"), AfxGetInstanceHandle())) {
delete pBitmap;
Gdiplus::GdiplusShutdown(m_gdiplusToken);
m_pTaskbarList->Release();
@@ -15152,8 +14873,7 @@ HRESULT CMainFrame::CreateThumbnailToolbar()
HBITMAP hB = 0;
pBitmap->m_pBitmap->GetHBITMAP(co,&hB);
- if (!hB)
- {
+ if (!hB) {
m_pTaskbarList->Release();
delete pBitmap;
Gdiplus::GdiplusShutdown(m_gdiplusToken);
@@ -15163,8 +14883,7 @@ HRESULT CMainFrame::CreateThumbnailToolbar()
// Check dimensions
BITMAP bi = {0};
GetObject((HANDLE)hB,sizeof(bi),&bi);
- if (bi.bmHeight == 0)
- {
+ if (bi.bmHeight == 0) {
DeleteObject(hB);
m_pTaskbarList->Release();
delete pBitmap;
@@ -15180,8 +14899,7 @@ HRESULT CMainFrame::CreateThumbnailToolbar()
hr = m_pTaskbarList->ThumbBarSetImageList(m_hWnd,himl);
DeleteObject(hB);
- if (SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
THUMBBUTTON buttons[5] = {};
// SEEK BACKWARD
@@ -15231,11 +14949,11 @@ HRESULT CMainFrame::CreateThumbnailToolbar()
HRESULT CMainFrame::UpdateThumbarButton()
{
- if ( !m_pTaskbarList )
+ if ( !m_pTaskbarList ) {
return E_FAIL;
+ }
- if ( !AfxGetAppSettings().fUseWin7TaskBar )
- {
+ if ( !AfxGetAppSettings().fUseWin7TaskBar ) {
m_pTaskbarList->SetOverlayIcon( m_hWnd, NULL, L"" );
m_pTaskbarList->SetProgressState( m_hWnd, TBPF_NOPROGRESS );
@@ -15297,20 +15015,16 @@ HRESULT CMainFrame::UpdateThumbarButton()
HICON hIcon = NULL;
- if ( m_iMediaLoadState == MLS_LOADED )
- {
+ if ( m_iMediaLoadState == MLS_LOADED ) {
OAFilterState fs = GetMediaState();
- if ( fs == State_Running )
- {
+ 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 )
- {
+ } else if ( fs == State_Stopped ) {
buttons[0].dwFlags = THBF_DISABLED;
buttons[1].dwFlags = THBF_DISABLED;
buttons[2].dwFlags = THBF_ENABLED;
@@ -15319,9 +15033,7 @@ HRESULT CMainFrame::UpdateThumbarButton()
hIcon = AfxGetApp()->LoadIcon( IDR_TB_STOP );
m_pTaskbarList->SetProgressState( m_hWnd, TBPF_NOPROGRESS );
- }
- else if ( fs == State_Paused )
- {
+ } else if ( fs == State_Paused ) {
buttons[1].dwFlags = THBF_ENABLED;
buttons[2].dwFlags = THBF_ENABLED;
buttons[2].iBitmap = 3;
@@ -15330,16 +15042,16 @@ HRESULT CMainFrame::UpdateThumbarButton()
m_pTaskbarList->SetProgressState( m_hWnd, TBPF_PAUSED );
}
- if ( m_fAudioOnly )
+ if ( m_fAudioOnly ) {
buttons[4].dwFlags = THBF_DISABLED;
+ }
m_pTaskbarList->SetOverlayIcon( m_hWnd, hIcon, L"" );
- if ( hIcon != NULL )
+ if ( hIcon != NULL ) {
DestroyIcon( hIcon );
- }
- else
- {
+ }
+ } else {
buttons[0].dwFlags = THBF_DISABLED;
buttons[1].dwFlags = THBF_DISABLED;
buttons[2].dwFlags = THBF_DISABLED;
@@ -15359,11 +15071,11 @@ HRESULT CMainFrame::UpdateThumbarButton()
HRESULT CMainFrame::UpdateThumbnailClip()
{
- if ( !m_pTaskbarList )
+ if ( !m_pTaskbarList ) {
return E_FAIL;
+ }
- if ( (!AfxGetAppSettings().fUseWin7TaskBar) || (m_iMediaLoadState != MLS_LOADED) || (m_fAudioOnly) || m_fFullScreen )
- {
+ if ( (!AfxGetAppSettings().fUseWin7TaskBar) || (m_iMediaLoadState != MLS_LOADED) || (m_fAudioOnly) || m_fFullScreen ) {
return m_pTaskbarList->SetThumbnailClip( m_hWnd, NULL );
}
@@ -15381,41 +15093,38 @@ HRESULT CMainFrame::UpdateThumbnailClip()
LRESULT CMainFrame::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
- if((message == WM_COMMAND) && (THBN_CLICKED == HIWORD(wParam)))
- {
+ 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;
+ switch(wmId) {
+ case IDTB_BUTTON1:
+ SendMessage(WM_COMMAND, ID_PLAY_STOP);
+ break;
- case IDTB_BUTTON2:
- SendMessage(WM_COMMAND, ID_PLAY_PLAYPAUSE);
- break;
+ case IDTB_BUTTON2:
+ SendMessage(WM_COMMAND, ID_PLAY_PLAYPAUSE);
+ break;
- case IDTB_BUTTON3:
- SendMessage(WM_COMMAND, ID_PLAY_SEEKBACKWARDMED);
- break;
+ case IDTB_BUTTON3:
+ SendMessage(WM_COMMAND, ID_PLAY_SEEKBACKWARDMED);
+ break;
- case IDTB_BUTTON4:
- SendMessage(WM_COMMAND, ID_PLAY_SEEKFORWARDMED);
- break;
+ case IDTB_BUTTON4:
+ SendMessage(WM_COMMAND, ID_PLAY_SEEKFORWARDMED);
+ break;
- case IDTB_BUTTON5:
- WINDOWPLACEMENT wp;
- GetWindowPlacement(&wp);
- if(wp.showCmd == SW_SHOWMINIMIZED)
- {
- SendMessage(WM_SYSCOMMAND, SC_RESTORE, -1);
- }
- SetForegroundWindow();
+ 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;
+ SendMessage(WM_COMMAND, ID_VIEW_FULLSCREEN);
+ break;
- default:
- break;
+ default:
+ break;
}
return 0;
}
@@ -15428,27 +15137,26 @@ UINT CMainFrame::OnPowerBroadcast(UINT nPowerEvent, UINT nEventData)
static BOOL bWasPausedBeforeSuspention;
OAFilterState mediaState;
- switch ( nPowerEvent )
- {
- case PBT_APMSUSPEND: // System is suspending operation.
- TRACE("OnPowerBroadcast - suspending\n"); // For user tracking
+ switch ( nPowerEvent ) {
+ case PBT_APMSUSPEND: // System is suspending operation.
+ TRACE("OnPowerBroadcast - suspending\n"); // For user tracking
- bWasPausedBeforeSuspention = FALSE; // Reset value
+ 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
+ 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;
+ // Resume if we paused before suspension.
+ if ( bWasPausedBeforeSuspention ) {
+ SendMessage( WM_COMMAND, ID_PLAY_PLAY ); // Resume
+ }
+ break;
}
return __super::OnPowerBroadcast(nPowerEvent, nEventData);
diff --git a/src/apps/mplayerc/MainFrm.h b/src/apps/mplayerc/MainFrm.h
index 54988b009..c58619677 100644
--- a/src/apps/mplayerc/MainFrm.h
+++ b/src/apps/mplayerc/MainFrm.h
@@ -79,7 +79,7 @@ enum {PM_NONE, PM_FILE, PM_DVD, PM_CAPTURE};
class OpenMediaData
{
public:
-// OpenMediaData() {}
+ // OpenMediaData() {}
virtual ~OpenMediaData() {} // one virtual funct is needed to enable rtti
CString title;
CAtlList<CString> subs;
@@ -96,7 +96,7 @@ public:
class OpenDVDData : public OpenMediaData
{
public:
-// OpenDVDData() {}
+ // OpenDVDData() {}
CString path;
CComPtr<IDvdState> pDvdState;
};
@@ -104,8 +104,7 @@ public:
class OpenDeviceData : public OpenMediaData
{
public:
- OpenDeviceData()
- {
+ OpenDeviceData() {
vinput = vchannel = ainput = -1;
}
CStringW DisplayName[2];
@@ -133,8 +132,7 @@ class CGraphThread : public CWinThread
public:
CGraphThread() : m_pMainFrame(NULL) {}
- void SetMainFrame(CMainFrame* pMainFrame)
- {
+ void SetMainFrame(CMainFrame* pMainFrame) {
m_pMainFrame = pMainFrame;
}
@@ -173,8 +171,7 @@ interface ISubClock;
class CMainFrame : public CFrameWnd, public CDropTarget
{
- enum
- {
+ enum {
TIMER_STREAMPOSPOLLER = 1,
TIMER_STREAMPOSPOLLER2,
TIMER_FULLSCREENCONTROLBARHIDER,
@@ -189,8 +186,6 @@ class CMainFrame : public CFrameWnd, public CDropTarget
// TODO: wrap these graph objects into a class to make it look cleaner
- DWORD m_dwRegister;
-
CComPtr<IGraphBuilder2> pGB;
CComQIPtr<IMediaControl> pMC;
CComQIPtr<IMediaEventEx> pME;
@@ -342,17 +337,14 @@ public:
void StopWebServer();
CString GetStatusMessage();
- int GetPlaybackMode() const
- {
+ int GetPlaybackMode() const {
return m_iPlaybackMode;
}
void SetPlaybackMode(int iNewStatus);
- bool IsMuted()
- {
+ bool IsMuted() {
return m_wndToolBar.GetVolume() == -10000;
}
- int GetVolume()
- {
+ int GetVolume() {
return m_wndToolBar.m_volctrl.GetPos();
}
@@ -361,7 +353,7 @@ public:
DECLARE_DYNAMIC(CMainFrame)
-// Attributes
+ // Attributes
public:
bool m_fFullScreen;
bool m_fFirstFSAfterLaunchOnFS;
@@ -371,24 +363,19 @@ public:
CComPtr<IBaseFilter> m_pRefClock; // Adjustable reference clock. GothSync
CComPtr<ISyncClock> m_pSyncClock;
- bool IsFrameLessWindow() const
- {
+ bool IsFrameLessWindow() const {
return(m_fFullScreen || AfxGetAppSettings().iCaptionMenuMode==MODE_BORDERLESS);
}
- bool IsCaptionMenuHidden() const
- {
+ bool IsCaptionMenuHidden() const {
return(!m_fFullScreen && AfxGetAppSettings().iCaptionMenuMode!=MODE_SHOWCAPTIONMENU);
}
- bool IsSomethingLoaded() const
- {
+ bool IsSomethingLoaded() const {
return((m_iMediaLoadState == MLS_LOADING || m_iMediaLoadState == MLS_LOADED) && !IsD3DFullScreenMode());
}
- bool IsPlaylistEmpty()
- {
+ bool IsPlaylistEmpty() {
return(m_wndPlaylistBar.GetCount() == 0);
}
- bool IsInteractiveVideo() const
- {
+ bool IsInteractiveVideo() const {
return(AfxGetAppSettings().fIntRealMedia && m_fRealMediaGraph || m_fShockwaveGraph);
}
bool IsD3DFullScreenMode() const;
@@ -410,7 +397,7 @@ protected:
double m_ZoomX, m_ZoomY, m_PosX, m_PosY;
int m_AngleX, m_AngleY, m_AngleZ;
-// Operations
+ // Operations
bool OpenMediaPrivate(CAutoPtr<OpenMediaData> pOMD);
void CloseMediaPrivate();
void DoTunerScan(TunerScanData* pTSD);
@@ -512,7 +499,7 @@ public:
void DisplayCurrentChannelOSD();
void DisplayCurrentChannelInfo();
-// Implementation
+ // Implementation
public:
virtual ~CMainFrame();
#ifdef _DEBUG
@@ -557,7 +544,7 @@ protected: // control bar embedded members
void RestoreFloatingControlBars();
void SaveControlBars();
-// Generated message map functions
+ // Generated message map functions
DECLARE_MESSAGE_MAP()
@@ -882,7 +869,8 @@ public:
afx_msg void OnHelpHomepage();
afx_msg void OnHelpDocumentation();
- afx_msg void OnHelpDonate();
+ afx_msg void OnHelpToolbarImages();
+ //afx_msg void OnHelpDonate();
afx_msg void OnClose();
@@ -917,7 +905,7 @@ public:
LPCTSTR GetDVDAudioFormatName (DVD_AudioAttributes& ATR) const;
void SetAudioDelay(REFERENCE_TIME rtShift);
void SetSubtitleDelay(int delay_ms);
-// void AutoSelectTracks();
+ // void AutoSelectTracks();
bool IsRealEngineCompatible(CString strFilename) const;
void SetTimersPlay();
void KillTimersStop();
diff --git a/src/apps/mplayerc/MediaFormats.cpp b/src/apps/mplayerc/MediaFormats.cpp
index 6dda8e3b4..dce97201f 100644
--- a/src/apps/mplayerc/MediaFormats.cpp
+++ b/src/apps/mplayerc/MediaFormats.cpp
@@ -54,7 +54,9 @@ CMediaFormatCategory::CMediaFormatCategory(
m_label = label;
ExplodeMin(exts, m_exts, ' ');
POSITION pos = m_exts.GetHeadPosition();
- while(pos) m_exts.GetNext(pos).TrimLeft('.');
+ while(pos) {
+ m_exts.GetNext(pos).TrimLeft('.');
+ }
m_backupexts.AddTailList(&m_exts);
m_specreqnote = specreqnote;
@@ -68,12 +70,9 @@ CMediaFormatCategory::~CMediaFormatCategory()
void CMediaFormatCategory::UpdateData(bool fSave)
{
- if(fSave)
- {
+ if(fSave) {
AfxGetApp()->WriteProfileString(_T("FileFormats"), m_label, GetExts(true));
- }
- else
- {
+ } else {
SetExts(AfxGetApp()->GetProfileString(_T("FileFormats"), m_label, GetExts(true)));
}
}
@@ -85,8 +84,7 @@ CMediaFormatCategory::CMediaFormatCategory(const CMediaFormatCategory& mfc)
CMediaFormatCategory& CMediaFormatCategory::operator = (const CMediaFormatCategory& mfc)
{
- if(this != &mfc)
- {
+ if(this != &mfc) {
m_label = mfc.m_label;
m_specreqnote = mfc.m_specreqnote;
m_exts.RemoveAll();
@@ -116,16 +114,15 @@ void CMediaFormatCategory::SetExts(CString exts)
m_exts.RemoveAll();
ExplodeMin(exts, m_exts, ' ');
POSITION pos = m_exts.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
POSITION cur = pos;
CString& ext = m_exts.GetNext(pos);
- if(ext[0] == '\\')
- {
+ if(ext[0] == '\\') {
m_engine = (engine_t)_tcstol(ext.TrimLeft('\\'), NULL, 10);
m_exts.RemoveAt(cur);
+ } else {
+ ext.TrimLeft('.');
}
- else ext.TrimLeft('.');
}
}
@@ -133,7 +130,9 @@ CString CMediaFormatCategory::GetFilter()
{
CString filter;
POSITION pos = m_exts.GetHeadPosition();
- while(pos) filter += _T("*.") + m_exts.GetNext(pos) + _T(";");
+ while(pos) {
+ filter += _T("*.") + m_exts.GetNext(pos) + _T(";");
+ }
filter.TrimRight(_T(";")); // cheap...
return(filter);
}
@@ -141,7 +140,9 @@ CString CMediaFormatCategory::GetFilter()
CString CMediaFormatCategory::GetExts(bool fAppendEngine)
{
CString exts = Implode(m_exts, ' ');
- if(fAppendEngine) exts += CString(_T(" \\")) + (TCHAR)(0x30 + (int)m_engine);
+ if(fAppendEngine) {
+ exts += CString(_T(" \\")) + (TCHAR)(0x30 + (int)m_engine);
+ }
return(exts);
}
@@ -149,9 +150,13 @@ CString CMediaFormatCategory::GetExtsWithPeriod(bool fAppendEngine)
{
CString exts;
POSITION pos = m_exts.GetHeadPosition();
- while(pos) exts += _T(".") + m_exts.GetNext(pos) + _T(" ");
+ while(pos) {
+ exts += _T(".") + m_exts.GetNext(pos) + _T(" ");
+ }
exts.TrimRight(_T(" ")); // cheap...
- if(fAppendEngine) exts += CString(_T(" \\")) + (TCHAR)(0x30 + (int)m_engine);
+ if(fAppendEngine) {
+ exts += CString(_T(" \\")) + (TCHAR)(0x30 + (int)m_engine);
+ }
return(exts);
}
@@ -159,9 +164,13 @@ CString CMediaFormatCategory::GetBackupExtsWithPeriod(bool fAppendEngine)
{
CString exts;
POSITION pos = m_backupexts.GetHeadPosition();
- while(pos) exts += _T(".") + m_backupexts.GetNext(pos) + _T(" ");
+ while(pos) {
+ exts += _T(".") + m_backupexts.GetNext(pos) + _T(" ");
+ }
exts.TrimRight(_T(" ")); // cheap...
- if(fAppendEngine) exts += CString(_T(" \\")) + (TCHAR)(0x30 + (int)m_engine);
+ if(fAppendEngine) {
+ exts += CString(_T(" \\")) + (TCHAR)(0x30 + (int)m_engine);
+ }
return(exts);
}
@@ -179,15 +188,12 @@ CMediaFormats::~CMediaFormats()
void CMediaFormats::UpdateData(bool fSave)
{
- if(fSave)
- {
+ 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
- {
+ } else {
RemoveAll();
#define ADDFMT(f) Add(CMediaFormatCategory##f)
@@ -256,8 +262,9 @@ void CMediaFormats::UpdateData(bool fSave)
m_fRtspFileExtFirst = !!AfxGetApp()->GetProfileInt(_T("FileFormats"), _T("RtspFileExtFirst"), 1);
}
- for(int i = 0; i < GetCount(); i++)
+ for(int i = 0; i < GetCount(); i++) {
GetAt(i).UpdateData(fSave);
+ }
}
engine_t CMediaFormats::GetRtspHandler(bool& fRtspFileExtFirst)
@@ -281,31 +288,33 @@ engine_t CMediaFormats::GetEngine(CString path)
{
path.Trim().MakeLower();
- if(!m_fRtspFileExtFirst && path.Find(_T("rtsp://")) == 0)
+ 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"))
+ 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"))
+ }
+ if(ext == _T(".qt") || ext == _T(".mov")) {
return QuickTime;
+ }
}
- for(int i = 0; i < GetCount(); i++)
- {
+ for(int i = 0; i < GetCount(); i++) {
CMediaFormatCategory& mfc = GetAt(i);
- if(mfc.FindExt(ext))
+ if(mfc.FindExt(ext)) {
return mfc.GetEngineType();
+ }
}
}
- if(m_fRtspFileExtFirst && path.Find(_T("rtsp://")) == 0)
+ if(m_fRtspFileExtFirst && path.Find(_T("rtsp://")) == 0) {
return m_iRtspHandler;
+ }
return DirectShow;
}
@@ -314,13 +323,12 @@ bool CMediaFormats::FindExt(CString ext, bool fAudioOnly)
{
ext.TrimLeft(_T("."));
- if(!ext.IsEmpty())
- {
- for(int i = 0; i < GetCount(); i++)
- {
+ if(!ext.IsEmpty()) {
+ for(int i = 0; i < GetCount(); i++) {
CMediaFormatCategory& mfc = GetAt(i);
- if((!fAudioOnly || mfc.IsAudioOnly()) && mfc.FindExt(ext))
+ if((!fAudioOnly || mfc.IsAudioOnly()) && mfc.FindExt(ext)) {
return(true);
+ }
}
}
@@ -334,8 +342,7 @@ void CMediaFormats::GetFilter(CString& filter, CAtlArray<CString>& mask)
filter += ResStr(IDS_MEDIAFORMATS_34);
mask.Add(_T(""));
- for(int i = 0; i < GetCount(); i++)
- {
+ for(int i = 0; i < GetCount(); i++) {
strTemp = GetAt(i).GetFilter() + _T(";");
mask[0] += strTemp;
filter += strTemp;
@@ -344,8 +351,7 @@ void CMediaFormats::GetFilter(CString& filter, CAtlArray<CString>& mask)
filter.TrimRight(_T(";"));
filter += _T("|");
- for(int i = 0; i < GetCount(); i++)
- {
+ for(int i = 0; i < GetCount(); i++) {
CMediaFormatCategory& mfc = GetAt(i);
filter += mfc.GetLabel() + _T("|" + GetAt(i).GetFilter() + _T("|"));
mask.Add(mfc.GetFilter());
@@ -363,10 +369,11 @@ void CMediaFormats::GetAudioFilter(CString& filter, CAtlArray<CString>& mask)
filter += ResStr(IDS_MEDIAFORMATS_36);
mask.Add(_T(""));
- for(int i = 0; i < GetCount(); i++)
- {
+ for(int i = 0; i < GetCount(); i++) {
CMediaFormatCategory& mfc = GetAt(i);
- if(!mfc.IsAudioOnly() || mfc.GetEngineType() != DirectShow) continue;
+ if(!mfc.IsAudioOnly() || mfc.GetEngineType() != DirectShow) {
+ continue;
+ }
strTemp = GetAt(i).GetFilter() + _T(";");
mask[0] += strTemp;
filter += strTemp;
@@ -376,10 +383,11 @@ void CMediaFormats::GetAudioFilter(CString& filter, CAtlArray<CString>& mask)
filter.TrimRight(_T(";"));
filter += _T("|");
- for(int i = 0; i < GetCount(); i++)
- {
+ for(int i = 0; i < GetCount(); i++) {
CMediaFormatCategory& mfc = GetAt(i);
- if(!mfc.IsAudioOnly() || mfc.GetEngineType() != DirectShow) continue;
+ if(!mfc.IsAudioOnly() || mfc.GetEngineType() != DirectShow) {
+ continue;
+ }
filter += mfc.GetLabel() + _T("|") + GetAt(i).GetFilter() + _T("|");
mask.Add(mfc.GetFilter());
}
diff --git a/src/apps/mplayerc/MediaFormats.h b/src/apps/mplayerc/MediaFormats.h
index 287537d49..2348c03f1 100644
--- a/src/apps/mplayerc/MediaFormats.h
+++ b/src/apps/mplayerc/MediaFormats.h
@@ -54,33 +54,27 @@ public:
void SetExts(CAtlList<CString>& exts);
void SetExts(CString exts);
- bool FindExt(CString ext)
- {
+ bool FindExt(CString ext) {
return m_exts.Find(ext.TrimLeft(_T(".")).MakeLower()) != NULL;
}
- CString GetLabel() const
- {
+ CString GetLabel() const {
return m_label;
}
CString GetFilter();
CString GetExts(bool fAppendEngine = false);
CString GetExtsWithPeriod(bool fAppendEngine = false);
CString GetBackupExtsWithPeriod(bool fAppendEngine = false);
- CString GetSpecReqNote() const
- {
+ CString GetSpecReqNote() const {
return m_specreqnote;
}
- bool IsAudioOnly() const
- {
+ bool IsAudioOnly() const {
return m_fAudioOnly;
}
- engine_t GetEngineType() const
- {
+ engine_t GetEngineType() const {
return m_engine;
}
- void SetEngineType(engine_t e)
- {
+ void SetEngineType(engine_t e) {
m_engine = e;
}
};
diff --git a/src/apps/mplayerc/MediaTypesDlg.cpp b/src/apps/mplayerc/MediaTypesDlg.cpp
index 11559504b..9512ef25f 100644
--- a/src/apps/mplayerc/MediaTypesDlg.cpp
+++ b/src/apps/mplayerc/MediaTypesDlg.cpp
@@ -61,14 +61,20 @@ void CMediaTypesDlg::AddLine(CString 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;
+ 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');
+ while(pos) {
+ AddLine(sl.GetNext(pos) + '\n');
+ }
}
BEGIN_MESSAGE_MAP(CMediaTypesDlg, CResizableDialog)
@@ -85,9 +91,10 @@ BOOL CMediaTypesDlg::OnInitDialog()
CAtlList<CStringW> path;
CAtlList<CMediaType> mts;
- for(int i = 0; S_OK == m_pGBDE->GetDeadEnd(i, path, mts); i++)
- {
- if(!path.GetCount()) continue;
+ 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);
}
@@ -111,24 +118,27 @@ void CMediaTypesDlg::OnCbnSelchangeCombo1()
m_report.SetWindowText(_T(""));
int i = m_pins.GetCurSel();
- if(i < 0) return;
+ if(i < 0) {
+ return;
+ }
CAtlList<CStringW> path;
CAtlList<CMediaType> mts;
- if(FAILED(m_pGBDE->GetDeadEnd(i, path, mts)) || !path.GetCount())
+ if(FAILED(m_pGBDE->GetDeadEnd(i, path, mts)) || !path.GetCount()) {
return;
+ }
POSITION pos = path.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
AddLine(CString(path.GetNext(pos)) + _T("\n"));
- if(!pos) AddLine(_T("\n"));
+ if(!pos) {
+ AddLine(_T("\n"));
+ }
}
pos = mts.GetHeadPosition();
- for(int j = 0; pos; j++)
- {
+ for(int j = 0; pos; j++) {
CString str;
str.Format(_T("Media Type %d:\n"), j);
AddLine(str);
diff --git a/src/apps/mplayerc/MediaTypesDlg.h b/src/apps/mplayerc/MediaTypesDlg.h
index ea343b2ff..1ba83bc2d 100644
--- a/src/apps/mplayerc/MediaTypesDlg.h
+++ b/src/apps/mplayerc/MediaTypesDlg.h
@@ -32,7 +32,7 @@
class CMediaTypesDlg : public CResizableDialog
{
-// DECLARE_DYNAMIC(CMediaTypesDlg)
+ // DECLARE_DYNAMIC(CMediaTypesDlg)
private:
CComPtr<IGraphBuilderDeadEnd> m_pGBDE;
@@ -45,7 +45,7 @@ public:
CMediaTypesDlg(IGraphBuilderDeadEnd* pGBDE, CWnd* pParent = NULL); // standard constructor
virtual ~CMediaTypesDlg();
-// Dialog Data
+ // Dialog Data
enum { IDD = IDD_MEDIATYPES_DLG };
CComboBox m_pins;
CEdit m_report;
diff --git a/src/apps/mplayerc/MiniDump.cpp b/src/apps/mplayerc/MiniDump.cpp
index f52e11747..9f09b9dac 100644
--- a/src/apps/mplayerc/MiniDump.cpp
+++ b/src/apps/mplayerc/MiniDump.cpp
@@ -47,7 +47,7 @@ CMiniDump::CMiniDump()
#ifndef _WIN64
// Enable catching in CRT (http://blog.kalmbachnet.de/?postid=75)
-// PreventSetUnhandledExceptionFilter();
+ // PreventSetUnhandledExceptionFilter();
#endif
#endif
}
@@ -60,12 +60,14 @@ LPTOP_LEVEL_EXCEPTION_FILTER WINAPI MyDummySetUnhandledExceptionFilter( LPTOP_LE
BOOL CMiniDump::PreventSetUnhandledExceptionFilter()
{
HMODULE hKernel32 = LoadLibrary( _T("kernel32.dll") );
- if ( hKernel32 == NULL )
+ if ( hKernel32 == NULL ) {
return FALSE;
+ }
void *pOrgEntry = GetProcAddress( hKernel32, "SetUnhandledExceptionFilter" );
- if ( pOrgEntry == NULL )
+ if ( pOrgEntry == NULL ) {
return FALSE;
+ }
unsigned char newJump[ 100 ];
DWORD dwOrgEntryAddr = (DWORD) pOrgEntry;
@@ -89,34 +91,30 @@ LONG WINAPI CMiniDump::UnhandledExceptionFilter( _EXCEPTION_POINTERS *lpTopLevel
_TCHAR szResult[ 800 ];
_TCHAR szDbgHelpPath[ _MAX_PATH ];
- if ( !m_bMiniDumpEnabled )
+ if ( !m_bMiniDumpEnabled ) {
return 0;
+ }
// firstly see if dbghelp.dll is around and has the function we need
// look next to the EXE first, as the one in System32 might be old
// (e.g. Windows 2000)
- if ( GetModuleFileName(NULL, szDbgHelpPath, _MAX_PATH) )
- {
+ if ( GetModuleFileName(NULL, szDbgHelpPath, _MAX_PATH) ) {
_TCHAR *pSlash = _tcsrchr( szDbgHelpPath, _T('\\') );
- if ( pSlash != NULL )
- {
+ if ( pSlash != NULL ) {
_tcscpy_s( pSlash + 1, _MAX_PATH + szDbgHelpPath - pSlash, _T("DBGHELP.DLL") );
hDll = ::LoadLibrary( szDbgHelpPath );
}
}
- if ( hDll == NULL )
- {
+ if ( hDll == NULL ) {
// load any version we can
hDll = ::LoadLibrary( _T("DBGHELP.DLL") );
}
- if ( hDll != NULL )
- {
+ if ( hDll != NULL ) {
MINIDUMPWRITEDUMP pMiniDumpWriteDump = (MINIDUMPWRITEDUMP)::GetProcAddress( hDll, "MiniDumpWriteDump" );
- if ( pMiniDumpWriteDump != NULL )
- {
+ if ( pMiniDumpWriteDump != NULL ) {
_TCHAR szDumpPath[ _MAX_PATH ];
_TCHAR szVersion[ 40 ];
@@ -129,8 +127,7 @@ LONG WINAPI CMiniDump::UnhandledExceptionFilter( _EXCEPTION_POINTERS *lpTopLevel
HANDLE hFile = ::CreateFile( szDumpPath, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL, NULL );
- if ( hFile != INVALID_HANDLE_VALUE )
- {
+ if ( hFile != INVALID_HANDLE_VALUE ) {
_MINIDUMP_EXCEPTION_INFORMATION ExInfo;
ExInfo.ThreadId = ::GetCurrentThreadId();
@@ -139,28 +136,24 @@ LONG WINAPI CMiniDump::UnhandledExceptionFilter( _EXCEPTION_POINTERS *lpTopLevel
// write the dump
BOOL bOK = pMiniDumpWriteDump( GetCurrentProcess(), GetCurrentProcessId(), hFile, MiniDumpNormal, &ExInfo, NULL, NULL );
- if ( bOK )
- {
+ if ( bOK ) {
_stprintf_s( szResult, countof(szResult), ResStr(IDS_MPC_CRASH), szDumpPath );
retval = EXCEPTION_EXECUTE_HANDLER;
- }
- else
- {
+ } else {
_stprintf_s( szResult, countof(szResult), ResStr(IDS_MPC_MINIDUMP_FAIL), szDumpPath, GetLastError() );
}
::CloseHandle( hFile );
- }
- else
- {
+ } else {
_stprintf_s( szResult, countof(szResult), ResStr(IDS_MPC_MINIDUMP_FAIL), szDumpPath, GetLastError() );
}
}
FreeLibrary( hDll );
}
- if ( szResult )
+ if ( szResult ) {
MessageBox( NULL, szResult, _T("MPC-HC Mini Dump"), MB_OK );
+ }
return retval;
}
diff --git a/src/apps/mplayerc/MiniDump.h b/src/apps/mplayerc/MiniDump.h
index 9d708d0f6..829124693 100644
--- a/src/apps/mplayerc/MiniDump.h
+++ b/src/apps/mplayerc/MiniDump.h
@@ -27,8 +27,7 @@ class CMiniDump
public:
CMiniDump();
- static void Enable()
- {
+ static void Enable() {
m_bMiniDumpEnabled = true;
};
diff --git a/src/apps/mplayerc/Monitors.cpp b/src/apps/mplayerc/Monitors.cpp
index f27771fbe..57c23ea93 100644
--- a/src/apps/mplayerc/Monitors.cpp
+++ b/src/apps/mplayerc/Monitors.cpp
@@ -32,7 +32,7 @@ CMonitors::CMonitors()
{
// WARNING : GetSystemMetrics(SM_CMONITORS) return only visible display monitors, and EnumDisplayMonitors
// enumerate visible and pseudo invisible monitors !!!
-// m_MonitorArray.SetSize( GetMonitorCount() );
+ // m_MonitorArray.SetSize( GetMonitorCount() );
ADDMONITOR addMonitor;
addMonitor.pMonitors = &m_MonitorArray;
@@ -43,8 +43,9 @@ CMonitors::CMonitors()
CMonitors::~CMonitors()
{
- for ( int i = 0; i < m_MonitorArray.GetSize(); i++ )
+ for ( int i = 0; i < m_MonitorArray.GetSize(); i++ ) {
delete m_MonitorArray.GetAt( i );
+ }
}
@@ -81,8 +82,9 @@ CMonitor CMonitors::GetPrimaryMonitor()
// is the given handle a valid monitor handle
BOOL CMonitors::IsMonitor( const HMONITOR hMonitor )
{
- if ( hMonitor == NULL )
+ if ( hMonitor == NULL ) {
return FALSE;
+ }
MATCHMONITOR match;
match.target = hMonitor;
@@ -100,8 +102,7 @@ BOOL CALLBACK CMonitors::FindMatchingMonitorHandle( HMONITOR hMonitor, HDC hdcMo
{
LPMATCHMONITOR pMatch = (LPMATCHMONITOR)dwData;
- if ( hMonitor == pMatch->target )
- {
+ if ( hMonitor == pMatch->target ) {
//found a monitor with the same handle we are looking for
pMatch->foundMatch = TRUE;
return FALSE; //stop enumerating
diff --git a/src/apps/mplayerc/Monitors.h b/src/apps/mplayerc/Monitors.h
index 122afe80e..04654b08e 100644
--- a/src/apps/mplayerc/Monitors.h
+++ b/src/apps/mplayerc/Monitors.h
@@ -38,18 +38,16 @@ public:
#if _MFC_VER >= 0x0700
- int GetCount() const
- {
+ int GetCount() const {
return (int)m_MonitorArray.GetCount();
}
#else
- int GetCount() const
- {
+ int GetCount() const {
return (int)m_MonitorArray.GetSize();
}
#endif
-//static members
+ //static members
static CMonitor GetNearestMonitor( const LPRECT lprc );
static CMonitor GetNearestMonitor( const POINT pt );
static CMonitor GetNearestMonitor( const CWnd* pWnd );
@@ -70,8 +68,7 @@ public:
private:
CObArray m_MonitorArray;
- typedef struct tagMATCHMONITOR
- {
+ typedef struct tagMATCHMONITOR {
HMONITOR target;
BOOL foundMatch;
} MATCHMONITOR, *LPMATCHMONITOR;
@@ -84,8 +81,7 @@ private:
);
- typedef struct tagADDMONITOR
- {
+ typedef struct tagADDMONITOR {
CObArray* pMonitors;
int currentIndex;
} ADDMONITOR, *LPADDMONITOR;
diff --git a/src/apps/mplayerc/MpcApi.h b/src/apps/mplayerc/MpcApi.h
index cea885a42..b858cf9e6 100644
--- a/src/apps/mplayerc/MpcApi.h
+++ b/src/apps/mplayerc/MpcApi.h
@@ -44,8 +44,7 @@
#pragma once
-typedef enum MPC_LOADSTATE
-{
+typedef enum MPC_LOADSTATE {
MLS_CLOSED,
MLS_LOADING,
MLS_LOADED,
@@ -53,8 +52,7 @@ typedef enum MPC_LOADSTATE
};
-typedef enum MPC_PLAYSTATE
-{
+typedef enum MPC_PLAYSTATE {
PS_PLAY = 0,
PS_PAUSE = 1,
PS_STOP = 2,
@@ -62,8 +60,7 @@ typedef enum MPC_PLAYSTATE
};
-struct MPC_OSDDATA
-{
+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
@@ -77,8 +74,7 @@ struct MPC_OSDDATA
//} OSD_MESSAGEPOS;
-typedef enum MPCAPI_COMMAND
-{
+typedef enum MPCAPI_COMMAND {
// ==== Commands from MPC to host
// Send after connection
diff --git a/src/apps/mplayerc/Mpeg2SectionData.cpp b/src/apps/mplayerc/Mpeg2SectionData.cpp
index eebce8fa5..ce90be838 100644
--- a/src/apps/mplayerc/Mpeg2SectionData.cpp
+++ b/src/apps/mplayerc/Mpeg2SectionData.cpp
@@ -55,8 +55,7 @@ CMpeg2DataParser::CMpeg2DataParser(IBaseFilter* pFilter)
CString CMpeg2DataParser::ConvertString (BYTE* pBuffer, int nLength)
{
- static const UINT16 codepages[0x20] =
- {
+ static const UINT16 codepages[0x20] = {
28591, // 00 - ISO 8859-1 Latin I
28595, // 01 - ISO 8859-5 Cyrillic
28596, // 02 - ISO 8859-6 Arabic
@@ -83,15 +82,16 @@ CString CMpeg2DataParser::ConvertString (BYTE* pBuffer, int nLength)
int nDestSize;
CString strResult;
- if (nLength>0 && pBuffer[0]<0x20)
- {
+ if (nLength>0 && pBuffer[0]<0x20) {
cp = codepages[pBuffer[0]];
pBuffer++;
nLength--;
}
nDestSize = MultiByteToWideChar (cp, MB_PRECOMPOSED, (LPCSTR)pBuffer, nLength, NULL, 0);
- if(nDestSize < 0) return strResult;
+ if(nDestSize < 0) {
+ return strResult;
+ }
MultiByteToWideChar (cp, MB_PRECOMPOSED, (LPCSTR)pBuffer, nLength, strResult.GetBuffer(nLength), nDestSize);
strResult.ReleaseBuffer();
@@ -101,22 +101,21 @@ CString CMpeg2DataParser::ConvertString (BYTE* pBuffer, int nLength)
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;
+ 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;
@@ -124,7 +123,9 @@ DVB_STREAM_TYPE CMpeg2DataParser::ConvertToDVBType(PES_STREAM_TYPE nType)
HRESULT CMpeg2DataParser::ParseSIHeader(CGolombBuffer& gb, DVB_SI SIType, WORD& wSectionLength, WORD& wTSID)
{
- if (gb.BitRead(8) != SIType) return ERROR_INVALID_DATA; // table_id
+ 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
@@ -161,8 +162,7 @@ HRESULT CMpeg2DataParser::ParseSDT(ULONG ulFreq)
wONID = gb.BitRead(16); // original_network_id
gb.BitRead(8); // reserved_future_use
- while (gb.GetSize() - gb.GetPos() > 4)
- {
+ while (gb.GetSize() - gb.GetPos() > 4) {
CDVBChannel Channel;
Channel.SetFrequency (ulFreq);
Channel.SetTSID (wTSID);
@@ -175,31 +175,30 @@ HRESULT CMpeg2DataParser::ParseSDT(ULONG ulFreq)
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 = gb.BitRead(8); // service_provider_name_length
- gb.ReadBuffer (DescBuffer, nLength); // service_provider_name
-
- nLength = 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;
+ BeginEnumDescriptors(gb, nType, nLength) {
+ switch (nType) {
+ case DT_SERVICE :
+ gb.BitRead(8); // service_type
+ nLength = gb.BitRead(8); // service_provider_name_length
+ gb.ReadBuffer (DescBuffer, nLength); // service_provider_name
+
+ nLength = 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()))
+ if (!Channels.Lookup(Channel.GetSID())) {
Channels [Channel.GetSID()] = Channel;
+ }
}
return S_OK;
@@ -222,20 +221,17 @@ HRESULT CMpeg2DataParser::ParsePAT()
// program_association_section()
CheckNoLog (ParseSIHeader (gb, SI_PAT, wSectionLength, wTSID));
- while (gb.GetSize() - gb.GetPos() > 4)
- {
+ while (gb.GetSize() - gb.GetPos() > 4) {
WORD program_number;
WORD program_map_PID = 0;
program_number = gb.BitRead(16); // program_number
gb.BitRead(3); // reserved
- if (program_number==0)
- gb.BitRead(13); // network_PID
- else
- {
+ if (program_number==0) {
+ gb.BitRead(13); // network_PID
+ } else {
program_map_PID = gb.BitRead(13); // program_map_PID
- if (Channels.Lookup(program_number))
- {
+ if (Channels.Lookup(program_number)) {
Channels [program_number].SetPMT (program_map_PID);
ParsePMT (Channels [program_number]);
}
@@ -254,7 +250,6 @@ HRESULT CMpeg2DataParser::ParsePMT(CDVBChannel& Channel)
PSECTION data;
WORD wTSID;
WORD wSectionLength;
- int nLimit;
CheckNoLog (m_pData->GetSection (Channel.GetPMT(), SI_PMT, &m_Filter, 5000, &pSectionList));
CheckNoLog (pSectionList->GetSectionData (0, &dwLength, &data));
@@ -267,15 +262,13 @@ HRESULT CMpeg2DataParser::ParsePMT(CDVBChannel& Channel)
gb.BitRead(3); // reserved
Channel.SetPCR (gb.BitRead(13)); // PCR_PID
gb.BitRead(4); // reserved
- BeginEnumDescriptors(gb, nType, nLength) // for (i=0;i<N;i++) {
- {
+ BeginEnumDescriptors(gb, nType, nLength) { // for (i=0;i<N;i++) {
SkipDescriptor (gb, nType, nLength); // descriptor()
}
EndEnumDescriptors
- while (gb.GetSize() - gb.GetPos() > 4)
- {
+ while (gb.GetSize() - gb.GetPos() > 4) {
PES_STREAM_TYPE pes_stream_type;
DVB_STREAM_TYPE dvb_stream_type;
WORD wPID;
@@ -286,37 +279,35 @@ HRESULT CMpeg2DataParser::ParsePMT(CDVBChannel& Channel)
wPID = 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);
+ 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)
+ if ((dvb_stream_type = ConvertToDVBType(pes_stream_type)) != DVB_UNKNOWN) {
Channel.AddStreamInfo (wPID, dvb_stream_type, pes_stream_type, strLanguage);
+ }
}
return S_OK;
@@ -338,8 +329,9 @@ HRESULT CMpeg2DataParser::SetTime(CGolombBuffer& gb, PresentFollowing &NowNext)
tmTime1 = *localtime( &tTime1 );
_tzset();
_get_timezone(&timezone);
- if (_get_daylight(&daylight))
+ if (_get_daylight(&daylight)) {
timezone -= daylight * 3600;
+ }
// Start time:
tmTime1.tm_hour = gb.BitRead(4)*10;
@@ -387,8 +379,7 @@ HRESULT CMpeg2DataParser::ParseEIT(ULONG ulSID, PresentFollowing &NowNext)
CString itemDesc, itemText;
CString text;
- do
- {
+ do {
CheckNoLog (m_pData->GetSection (PID_EIT, SI_EIT_act, NULL, 5000, &pSectionList));
CheckNoLog (pSectionList->GetSectionData (0, &dwLength, &data));
@@ -423,64 +414,59 @@ HRESULT CMpeg2DataParser::ParseEIT(ULONG ulSID, PresentFollowing &NowNext)
NowNext.ExtendedDescriptorsItems.RemoveAll();
NowNext.ExtendedDescriptorsTexts.RemoveAll();
- if ((InfoEvent.ServiceId == ulSID) && (InfoEvent.CurrentNextIndicator == 1) && (InfoEvent.RunninStatus == 4))
- {
+ 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 = gb.BitRead(8); // event_name_length
- gb.ReadBuffer(DescBuffer, nLen);
- NowNext.cPresent = ConvertString(DescBuffer, nLen);
-
- nLen = gb.BitRead(8); // text_length
- gb.ReadBuffer(DescBuffer, nLen);
- NowNext.SummaryDesc = ConvertString(DescBuffer, nLen);
- break;
- case DT_EXTENDED_EVENT:
- descriptorNumber = gb.BitRead(4); // descriptor_number
- gb.BitRead(4); // last_descriptor_number
- gb.BitRead(24); // ISO_639_language_code
-
- nbItems = gb.BitRead(8); // length_of_items
- for (int i=0; i<nbItems; i++)
- {
- nLen = gb.BitRead(8); // item_description_length
- gb.ReadBuffer(DescBuffer, nLen);
- itemDesc = ConvertString(DescBuffer, nLen);
- nLen = gb.BitRead(8); // item_length
+ BeginEnumDescriptors(gb, nType, nLength) {
+ switch (nType) {
+ case DT_SHORT_EVENT:
+ gb.BitRead(24); // ISO_639_language_code
+
+ nLen = gb.BitRead(8); // event_name_length
gb.ReadBuffer(DescBuffer, nLen);
- itemText = ConvertString(DescBuffer, nLen);
- NowNext.ExtendedDescriptorsItems.SetAt(itemDesc, itemText);
- }
+ NowNext.cPresent = ConvertString(DescBuffer, nLen);
- nLen = 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;
+ nLen = gb.BitRead(8); // text_length
+ gb.ReadBuffer(DescBuffer, nLen);
+ NowNext.SummaryDesc = ConvertString(DescBuffer, nLen);
+ break;
+ case DT_EXTENDED_EVENT:
+ descriptorNumber = gb.BitRead(4); // descriptor_number
+ gb.BitRead(4); // last_descriptor_number
+ gb.BitRead(24); // ISO_639_language_code
+
+ nbItems = gb.BitRead(8); // length_of_items
+ for (int i=0; i<nbItems; i++) {
+ nLen = gb.BitRead(8); // item_description_length
+ gb.ReadBuffer(DescBuffer, nLen);
+ itemDesc = ConvertString(DescBuffer, nLen);
+ nLen = gb.BitRead(8); // item_length
+ gb.ReadBuffer(DescBuffer, nLen);
+ itemText = ConvertString(DescBuffer, nLen);
+ NowNext.ExtendedDescriptorsItems.SetAt(itemDesc, itemText);
+ }
+
+ nLen = 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));
+ } while (((InfoEvent.ServiceId != ulSID) || (InfoEvent.CurrentNextIndicator != 1) || (InfoEvent.RunninStatus != 4)) &&
+ (m_Filter.SectionNumber <= 22));
- if (InfoEvent.ServiceId != ulSID)
- {
+ if (InfoEvent.ServiceId != ulSID) {
NowNext.StartTime = _T("");
NowNext.Duration = _T("");
NowNext.cPresent = _T(" Info not available.");
@@ -510,41 +496,35 @@ HRESULT CMpeg2DataParser::ParseNIT()
CheckNoLog (ParseSIHeader (gb, SI_NIT, wSectionLength, wTSID));
gb.BitRead(4); // reserved_future_use
- BeginEnumDescriptors(gb, nType, nLength) // for (i=0;i<N;i++) {
- {
+ 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 = gb.BitRead(12); // network_descriptors_length
- while (gb.GetSize() - gb.GetPos() > 4)
- {
+ while (gb.GetSize() - gb.GetPos() > 4) {
WORD transport_stream_id = gb.BitRead(16); // transport_stream_id
UNUSED_ALWAYS(transport_stream_id);
WORD original_network_id = gb.BitRead(16); // original_network_id
UNUSED_ALWAYS(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 = gb.BitRead (16);
- gb.BitRead(6);
- WORD logical_channel_number = 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());
+ BeginEnumDescriptors (gb, nType, nLength) {
+ switch (nType) {
+ case DT_LOGICAL_CHANNEL :
+ for (int i=0; i<nLength/4; i++) {
+ WORD service_id = gb.BitRead (16);
+ gb.BitRead(6);
+ WORD logical_channel_number = 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;
+ break;
+ default :
+ SkipDescriptor (gb, nType, nLength);
+ break;
}
}
EndEnumDescriptors
diff --git a/src/apps/mplayerc/Mpeg2SectionData.h b/src/apps/mplayerc/Mpeg2SectionData.h
index 55b79673b..23c67084c 100644
--- a/src/apps/mplayerc/Mpeg2SectionData.h
+++ b/src/apps/mplayerc/Mpeg2SectionData.h
@@ -27,8 +27,7 @@
#pragma pack(1)
-typedef struct
-{
+typedef struct {
UINT8 TableID;
WORD SectionSyntaxIndicator : 1;
WORD Reserved1 : 3;
@@ -41,8 +40,7 @@ typedef struct
UINT8 LastSectionNumber;
} SI_HEADER;
-typedef struct
-{
+typedef struct {
UINT8 TableID;
WORD SectionSyntaxIndicator : 1;
WORD Reserved1 : 3;
diff --git a/src/apps/mplayerc/MultiMonitor.cpp b/src/apps/mplayerc/MultiMonitor.cpp
index b29f78b94..8dc6bb127 100644
--- a/src/apps/mplayerc/MultiMonitor.cpp
+++ b/src/apps/mplayerc/MultiMonitor.cpp
@@ -178,10 +178,11 @@ void CMonitor::CenterRectToMonitor( LPRECT lprc, const BOOL UseWorkAreaRect ) co
int h = lprc->bottom - lprc->top;
CRect rect;
- if ( UseWorkAreaRect )
+ if ( UseWorkAreaRect ) {
GetWorkAreaRect( &rect );
- else
+ } else {
GetMonitorRect( &rect );
+ }
lprc->left = rect.left + ( rect.Width() - w ) / 2;
lprc->top = rect.top + ( rect.Height() - h ) / 2;
@@ -207,10 +208,11 @@ void CMonitor::ClipRectToMonitor( LPRECT lprc, const BOOL UseWorkAreaRect ) cons
int h = lprc->bottom - lprc->top;
CRect rect;
- if ( UseWorkAreaRect )
+ if ( UseWorkAreaRect ) {
GetWorkAreaRect( &rect );
- else
+ } 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 ) );
diff --git a/src/apps/mplayerc/MultiMonitor.h b/src/apps/mplayerc/MultiMonitor.h
index b1363494e..282a14e31 100644
--- a/src/apps/mplayerc/MultiMonitor.h
+++ b/src/apps/mplayerc/MultiMonitor.h
@@ -36,12 +36,12 @@
class CMonitor : public CObject
{
public:
-//construction destruction
+ //construction destruction
CMonitor();
CMonitor( const CMonitor& monitor );
virtual ~CMonitor();
-//operations
+ //operations
void Attach( const HMONITOR hMonitor );
HMONITOR Detach();
@@ -51,7 +51,7 @@ public:
HDC CreateDC() const;
-//properties
+ //properties
void GetMonitorRect( LPRECT lprc ) const;
void GetWorkAreaRect( LPRECT lprc ) const;
@@ -66,24 +66,20 @@ public:
BOOL IsPrimaryMonitor() const;
BOOL IsMonitor() const;
-//operators
- operator HMONITOR() const
- {
+ //operators
+ operator HMONITOR() const {
return this == NULL ? NULL : m_hMonitor;
}
- BOOL operator ==( const CMonitor& monitor ) const
- {
+ BOOL operator ==( const CMonitor& monitor ) const {
return m_hMonitor == (HMONITOR)monitor;
}
- BOOL operator !=( const CMonitor& monitor ) const
- {
+ BOOL operator !=( const CMonitor& monitor ) const {
return !( *this == monitor );
}
- CMonitor& operator =( const CMonitor& monitor )
- {
+ CMonitor& operator =( const CMonitor& monitor ) {
m_hMonitor = (HMONITOR)monitor;
return *this;
}
diff --git a/src/apps/mplayerc/OpenCapDeviceDlg.cpp b/src/apps/mplayerc/OpenCapDeviceDlg.cpp
index a3f6410d0..3c1575414 100644
--- a/src/apps/mplayerc/OpenCapDeviceDlg.cpp
+++ b/src/apps/mplayerc/OpenCapDeviceDlg.cpp
@@ -27,44 +27,42 @@
#include "../../DSUtil/DSUtil.h"
-static struct cc_t
-{
+static struct cc_t {
long code;
AnalogVideoStandard standard;
const TCHAR* str;
-} s_countrycodes[] =
-{
+} 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")},
+ /* {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")},
+ /* {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")},
@@ -95,7 +93,7 @@ static struct cc_t
{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")},
+ // {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")},
@@ -165,7 +163,7 @@ static struct cc_t
{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")},
+ // {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")},
@@ -209,7 +207,7 @@ static struct cc_t
{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")},
+ // {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")},
@@ -220,12 +218,12 @@ static struct cc_t
{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")},
+ // {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")},
+ // {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")},
@@ -333,8 +331,7 @@ BOOL COpenCapDeviceDlg::OnInitDialog()
int iSel = vidstr == dummy ? 0 : -1;
- BeginEnumSysDev(CLSID_VideoInputDeviceCategory, pMoniker)
- {
+ BeginEnumSysDev(CLSID_VideoInputDeviceCategory, pMoniker) {
CComPtr<IPropertyBag> pPB;
pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB);
@@ -343,22 +340,23 @@ BOOL COpenCapDeviceDlg::OnInitDialog()
int i = m_vidctrl.AddString(CString(var.bstrVal));
LPOLESTR strName = NULL;
- if(SUCCEEDED(pMoniker->GetDisplayName(NULL, NULL, &strName)))
- {
+ if(SUCCEEDED(pMoniker->GetDisplayName(NULL, NULL, &strName))) {
m_vidnames.Add(CString(strName));
- if(vidstr == CString(strName)) iSel = i;
+ if(vidstr == CString(strName)) {
+ iSel = i;
+ }
CoTaskMemFree(strName);
}
}
EndEnumSysDev
- if(m_vidctrl.GetCount())
+ if(m_vidctrl.GetCount()) {
m_vidctrl.SetCurSel(iSel);
+ }
iSel = audstr == dummy ? 0 : -1;
- BeginEnumSysDev(CLSID_AudioInputDeviceCategory, pMoniker)
- {
+ BeginEnumSysDev(CLSID_AudioInputDeviceCategory, pMoniker) {
CComPtr<IPropertyBag> pPB;
pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB);
@@ -367,10 +365,11 @@ BOOL COpenCapDeviceDlg::OnInitDialog()
int i = m_audctrl.AddString(CString(var.bstrVal));
LPOLESTR strName = NULL;
- if(SUCCEEDED(pMoniker->GetDisplayName(NULL, NULL, &strName)))
- {
+ if(SUCCEEDED(pMoniker->GetDisplayName(NULL, NULL, &strName))) {
m_audnames.Add(CString(strName));
- if(audstr == CString(strName)) iSel = i;
+ if(audstr == CString(strName)) {
+ iSel = i;
+ }
CoTaskMemFree(strName);
}
}
@@ -379,79 +378,80 @@ BOOL COpenCapDeviceDlg::OnInitDialog()
{
int i = m_audctrl.AddString(_T("<Video Capture Device>"));
m_audnames.Add(_T(""));
- if(audstr.IsEmpty()) iSel = i;
+ if(audstr.IsEmpty()) {
+ iSel = i;
+ }
}
- if(m_audctrl.GetCount())
+ if(m_audctrl.GetCount()) {
m_audctrl.SetCurSel(iSel);
+ }
iSel = 0;
- for(int j = 0; j < countof(s_countrycodes); j++)
- {
+ 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;
+ 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;
@@ -459,11 +459,14 @@ BOOL COpenCapDeviceDlg::OnInitDialog()
int i = m_countryctrl.AddString(str);
m_countryctrl.SetItemDataPtr(i, &s_countrycodes[j]);
- if(country == s_countrycodes[j].code) iSel = i;
+ if(country == s_countrycodes[j].code) {
+ iSel = i;
+ }
}
- if(m_countryctrl.GetCount())
+ if(m_countryctrl.GetCount()) {
m_countryctrl.SetCurSel(iSel);
+ }
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
@@ -475,20 +478,17 @@ void COpenCapDeviceDlg::OnBnClickedOk()
AppSettings& s = AfxGetAppSettings();
- if(m_vidctrl.GetCurSel() >= 0)
- {
+ if(m_vidctrl.GetCurSel() >= 0) {
m_vidstr = m_vidnames[m_vidctrl.GetCurSel()];
s.strAnalogVideo = m_vidstr;
}
- if(m_audctrl.GetCurSel() >= 0)
- {
+ if(m_audctrl.GetCurSel() >= 0) {
m_audstr = m_audnames[m_audctrl.GetCurSel()];
s.strAnalogAudio = m_audstr;
}
- if(m_countryctrl.GetCurSel() >= 0)
- {
+ if(m_countryctrl.GetCurSel() >= 0) {
m_country = ((cc_t*)m_countryctrl.GetItemDataPtr(m_countryctrl.GetCurSel()))->code;
s.iAnalogCountry = m_country;
}
diff --git a/src/apps/mplayerc/OpenCapDeviceDlg.h b/src/apps/mplayerc/OpenCapDeviceDlg.h
index 5a16c72e6..3039ac4c2 100644
--- a/src/apps/mplayerc/OpenCapDeviceDlg.h
+++ b/src/apps/mplayerc/OpenCapDeviceDlg.h
@@ -31,7 +31,7 @@
class COpenCapDeviceDlg : public CResizableDialog
{
-// DECLARE_DYNAMIC(COpenCapDeviceDlg)
+ // DECLARE_DYNAMIC(COpenCapDeviceDlg)
private:
CAtlArray<CString> m_vidnames, m_audnames;
@@ -47,7 +47,7 @@ public:
CString m_vidstr, m_audstr;
int m_country;
-// Dialog Data
+ // Dialog Data
enum { IDD = IDD_OPENCAPDEVICE_DLG };
protected:
diff --git a/src/apps/mplayerc/OpenDirHelper.cpp b/src/apps/mplayerc/OpenDirHelper.cpp
index 6b2cc6514..170565e2c 100644
--- a/src/apps/mplayerc/OpenDirHelper.cpp
+++ b/src/apps/mplayerc/OpenDirHelper.cpp
@@ -45,7 +45,9 @@ void COpenDirHelper::SetFont(HWND hwnd,LPTSTR FontName,int FontSize)
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.
+ if(!hfOld && (hfOld!=hf)) {
+ DeleteObject(hfOld); //if the old font is not system font or the same as newfont, release it.
+ }
ReleaseDC(hwnd,hdc);
}
@@ -53,14 +55,10 @@ void COpenDirHelper::SetFont(HWND hwnd,LPTSTR FontName,int FontSize)
// Subclass procedure
LRESULT APIENTRY COpenDirHelper::CheckBoxSubclassProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
- if(uMsg==WM_LBUTTONUP)
- {
- if((SendMessage(hwnd,BM_GETCHECK,0,0))==1)
- {
+ if(uMsg==WM_LBUTTONUP) {
+ if((SendMessage(hwnd,BM_GETCHECK,0,0))==1) {
m_incl_subdir = FALSE;
- }
- else
- {
+ } else {
m_incl_subdir = TRUE;
}
}
@@ -72,8 +70,7 @@ int __stdcall COpenDirHelper::BrowseCallbackProcDIR(HWND hwnd,UINT uMsg,LPARAM
HWND checkbox;
//Initialization callback message
- if(uMsg==BFFM_INITIALIZED)
- {
+ if(uMsg==BFFM_INITIALIZED) {
SendMessage(hwnd, BFFM_SETSELECTION, TRUE, (LPARAM)(LPCTSTR)strLastOpenDir);
RECT ListViewRect;
@@ -120,24 +117,20 @@ 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
- {
+ if(hFind != INVALID_HANDLE_VALUE) {
+ do {
CString f_name = fd.cFileName;
- if((fd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) && (f_name!=_T(".")) && (f_name!=_T("..")))
- {
+ if((fd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) && (f_name!=_T(".")) && (f_name!=_T(".."))) {
CString fullpath = path + f_name;
- if(fullpath[fullpath.GetLength()-1] != '\\') fullpath += '\\';
+ if(fullpath[fullpath.GetLength()-1] != '\\') {
+ fullpath += '\\';
+ }
sl->AddTail(fullpath);
RecurseAddDir(fullpath, sl);
- }
- else
- {
+ } else {
continue;
}
- }
- while(FindNextFile(hFind, &fd));
+ } while(FindNextFile(hFind, &fd));
FindClose(hFind);
}
}
diff --git a/src/apps/mplayerc/OpenDirHelper.h b/src/apps/mplayerc/OpenDirHelper.h
index 9118c3463..f82aa713e 100644
--- a/src/apps/mplayerc/OpenDirHelper.h
+++ b/src/apps/mplayerc/OpenDirHelper.h
@@ -23,7 +23,8 @@
#pragma once
-class COpenDirHelper {
+class COpenDirHelper
+{
public:
static WNDPROC CBProc;
static bool m_incl_subdir;
diff --git a/src/apps/mplayerc/OpenDlg.cpp b/src/apps/mplayerc/OpenDlg.cpp
index 9bce1117f..60c50e3c4 100644
--- a/src/apps/mplayerc/OpenDlg.cpp
+++ b/src/apps/mplayerc/OpenDlg.cpp
@@ -75,19 +75,23 @@ BOOL COpenDlg::OnInitDialog()
MRU.ReadList();
m_mrucombo.ResetContent();
for(int i = 0; i < MRU.GetSize(); i++)
- if(!MRU[i].IsEmpty())
+ if(!MRU[i].IsEmpty()) {
m_mrucombo.AddString(MRU[i]);
+ }
CorrectComboListWidth(m_mrucombo, GetFont());
CRecentFileList& MRUDub = AfxGetAppSettings().MRUDub;
MRUDub.ReadList();
m_mrucombo2.ResetContent();
for(int i = 0; i < MRUDub.GetSize(); i++)
- if(!MRUDub[i].IsEmpty())
+ if(!MRUDub[i].IsEmpty()) {
m_mrucombo2.AddString(MRUDub[i]);
+ }
CorrectComboListWidth(m_mrucombo2, GetFont());
- if(m_mrucombo.GetCount() > 0) m_mrucombo.SetCurSel(0);
+ if(m_mrucombo.GetCount() > 0) {
+ m_mrucombo.SetCurSel(0);
+ }
AddAnchor(m_mrucombo, TOP_LEFT, TOP_RIGHT);
AddAnchor(m_mrucombo2, TOP_LEFT, TOP_RIGHT);
@@ -126,13 +130,14 @@ void COpenDlg::OnBnClickedBrowsebutton()
COpenFileDlg fd(mask, true, NULL, m_path,
OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_ALLOWMULTISELECT|OFN_ENABLEINCLUDENOTIFY,
filter, this);
- if(fd.DoModal() != IDOK) return;
+ if(fd.DoModal() != IDOK) {
+ return;
+ }
m_fns.RemoveAll();
POSITION pos = fd.GetStartPosition();
- while(pos)
- {
+ while(pos) {
/*
CString str = fd.GetNextPathName(pos);
POSITION insertpos = m_fns.GetTailPosition();
@@ -147,8 +152,7 @@ void COpenDlg::OnBnClickedBrowsebutton()
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_fns.GetHead()[m_fns.GetHead().GetLength()-1] == '*')) {
m_fMultipleFiles = true;
EndDialog(IDOK);
return;
@@ -169,7 +173,9 @@ void COpenDlg::OnBnClickedBrowsebutton2()
OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_ENABLEINCLUDENOTIFY,
filter, this);
- if(fd.DoModal() != IDOK) return;
+ if(fd.DoModal() != IDOK) {
+ return;
+ }
m_mrucombo2.SetWindowText(fd.GetPathName());
}
@@ -180,8 +186,9 @@ void COpenDlg::OnBnClickedOk()
m_fns.RemoveAll();
m_fns.AddTail(m_path);
- if(m_mrucombo2.IsWindowEnabled())
+ if(m_mrucombo2.IsWindowEnabled()) {
m_fns.AddTail(m_path2);
+ }
m_fMultipleFiles = false;
diff --git a/src/apps/mplayerc/OpenDlg.h b/src/apps/mplayerc/OpenDlg.h
index b30e8cf4e..c4ccbb91c 100644
--- a/src/apps/mplayerc/OpenDlg.h
+++ b/src/apps/mplayerc/OpenDlg.h
@@ -30,7 +30,7 @@
class COpenDlg : public CResizableDialog
{
-// DECLARE_DYNAMIC(COpenDlg)
+ // DECLARE_DYNAMIC(COpenDlg)
public:
COpenDlg(CWnd* pParent = NULL); // standard constructor
@@ -39,7 +39,7 @@ public:
bool m_fMultipleFiles;
CAtlList<CString> m_fns;
-// Dialog Data
+ // Dialog Data
enum { IDD = IDD_OPEN_DLG };
CComboBox m_mrucombo;
CString m_path;
diff --git a/src/apps/mplayerc/OpenFileDlg.cpp b/src/apps/mplayerc/OpenFileDlg.cpp
index 2d0247995..bb471d95d 100644
--- a/src/apps/mplayerc/OpenFileDlg.cpp
+++ b/src/apps/mplayerc/OpenFileDlg.cpp
@@ -64,13 +64,13 @@ 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)
- {
+ && 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)
+ 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);
@@ -89,7 +89,9 @@ BOOL COpenFileDlg::OnInitDialog()
void COpenFileDlg::OnDestroy()
{
int i = GetPathName().Find(__DUMMY__);
- if(i >= 0) m_pOFN->lpstrFile[i] = m_pOFN->lpstrFile[i+1] = 0;
+ if(i >= 0) {
+ m_pOFN->lpstrFile[i] = m_pOFN->lpstrFile[i+1] = 0;
+ }
CFileDialog::OnDestroy();
}
@@ -100,18 +102,17 @@ BOOL COpenFileDlg::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
OFNOTIFY* pNotify = (OFNOTIFY*)lParam;
// allow message map to override
- if (__super::OnNotify(wParam, lParam, pResult))
- {
+ 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;
+ switch(pNotify->hdr.code) {
+ case CDN_INCLUDEITEM:
+ if(OnIncludeItem((OFNOTIFYEX*)lParam, pResult)) {
+ return TRUE;
+ }
+ break;
}
return FALSE; // not handled
@@ -120,23 +121,23 @@ BOOL COpenFileDlg::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
BOOL COpenFileDlg::OnIncludeItem(OFNOTIFYEX* pOFNEx, LRESULT* pResult)
{
TCHAR buff[_MAX_PATH];
- if(!SHGetPathFromIDList((LPCITEMIDLIST)pOFNEx->pidl, buff))
- {
+ 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(buff, CString(s.cStr));
- break;
- case STRRET_WSTR:
- _tcscpy(buff, CString(s.pOleStr));
- CoTaskMemFree(s.pOleStr);
- break;
- default:
+ if(S_OK != hr) {
return FALSE;
}
+ switch(s.uType) {
+ case STRRET_CSTR:
+ _tcscpy(buff, CString(s.cStr));
+ break;
+ case STRRET_WSTR:
+ _tcscpy(buff, CString(s.pOleStr));
+ CoTaskMemFree(s.pOleStr);
+ break;
+ default:
+ return FALSE;
+ }
}
CString fn(buff);
@@ -147,8 +148,9 @@ BOOL COpenFileDlg::OnIncludeItem(OFNOTIFYEX* pOFNEx, LRESULT* pResult)
return FALSE;
*/
int i = fn.ReverseFind('.'), j = fn.ReverseFind('\\');
- if(i < 0 || i < j)
+ if(i < 0 || i < j) {
return FALSE;
+ }
CString mask = m_mask[pOFNEx->lpOFN->nFilterIndex-1] + _T(";");
CString ext = fn.Mid(i).MakeLower() + _T(";");
diff --git a/src/apps/mplayerc/PPageAccelTbl.cpp b/src/apps/mplayerc/PPageAccelTbl.cpp
index 0c46c930c..e0214fae3 100644
--- a/src/apps/mplayerc/PPageAccelTbl.cpp
+++ b/src/apps/mplayerc/PPageAccelTbl.cpp
@@ -26,14 +26,12 @@
#include "PPageAccelTbl.h"
-struct APP_COMMAND
-{
+struct APP_COMMAND {
UINT appcmd;
LPCTSTR cmdname;
};
-APP_COMMAND g_CommandList[] =
-{
+APP_COMMAND g_CommandList[] = {
{0, _T("")},
{APPCOMMAND_BROWSER_BACKWARD, _T("BROWSER_BACKWARD")},
{APPCOMMAND_BROWSER_FORWARD, _T("BROWSER_FORWARD")},
@@ -134,8 +132,7 @@ 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))
- {
+ && (pMsg->hwnd == m_WinLircEdit.m_hWnd || pMsg->hwnd == m_UIceEdit.m_hWnd)) {
OnApply();
return TRUE;
}
@@ -146,8 +143,7 @@ BOOL CPPageAccelTbl::PreTranslateMessage(MSG* pMsg)
void CPPageAccelTbl::SetupList()
{
- for(int row = 0; row < m_list.GetItemCount(); row++)
- {
+ for(int row = 0; row < m_list.GetItemCount(); row++) {
wmcmd& wc = m_wmcmds.GetAt((POSITION)m_list.GetItemData(row));
CString mod = MakeAccelModLabel(wc.fVirt);
@@ -178,579 +174,583 @@ void CPPageAccelTbl::SetupList()
CString CPPageAccelTbl::MakeAccelModLabel(BYTE fVirt)
{
CString str;
- if(fVirt&FCONTROL)
- {
- if(!str.IsEmpty()) str += _T(" + ");
+ if(fVirt&FCONTROL) {
+ if(!str.IsEmpty()) {
+ str += _T(" + ");
+ }
str += _T("Ctrl");
}
- if(fVirt&FALT)
- {
- if(!str.IsEmpty()) str += _T(" + ");
+ if(fVirt&FALT) {
+ if(!str.IsEmpty()) {
+ str += _T(" + ");
+ }
str += _T("Alt");
}
- if(fVirt&FSHIFT)
- {
- if(!str.IsEmpty()) str += _T(" + ");
+ if(fVirt&FSHIFT) {
+ if(!str.IsEmpty()) {
+ str += _T(" + ");
+ }
str += _T("Shift");
}
- if(str.IsEmpty()) str = ResStr(IDS_AG_NONE);
+ if(str.IsEmpty()) {
+ str = ResStr(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/ms645540
+ // Reference page for Virtual-Key Codes: http://msdn.microsoft.com/en-us/library/ms645540
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;
+ 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);
@@ -760,11 +760,11 @@ CString CPPageAccelTbl::MakeAccelShortcutLabel(UINT id)
{
CList<wmcmd>& wmcmds = AfxGetAppSettings().wmcmds;
POSITION pos = wmcmds.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
ACCEL& a = wmcmds.GetNext(pos);
- if(a.cmd == id)
+ if(a.cmd == id) {
return(MakeAccelShortcutLabel(a));
+ }
}
return(_T(""));
@@ -772,562 +772,562 @@ CString CPPageAccelTbl::MakeAccelShortcutLabel(UINT id)
CString CPPageAccelTbl::MakeAccelShortcutLabel(ACCEL& a)
{
-// Reference page for Virtual-Key Codes: http://msdn.microsoft.com/en-us/library/ms645540
+ // Reference page for Virtual-Key Codes: http://msdn.microsoft.com/en-us/library/ms645540
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("Return");
- 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;
+ 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("Return");
+ 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))
+ if(a.fVirt&(FCONTROL|FALT|FSHIFT)) {
str = MakeAccelModLabel(a.fVirt) + _T(" + ") + str;
+ }
str.Replace(_T(" + "), _T("+"));
@@ -1337,73 +1337,72 @@ CString CPPageAccelTbl::MakeAccelShortcutLabel(ACCEL& a)
CString CPPageAccelTbl::MakeMouseButtonLabel(UINT mouse)
{
CString ret;
- switch(mouse)
- {
- case wmcmd::NONE:
- default:
- ret = ResStr(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;
+ switch(mouse) {
+ case wmcmd::NONE:
+ default:
+ ret = ResStr(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)
+ for (int i=0; i<countof(g_CommandList); i++) {
+ if (g_CommandList[i].appcmd == id) {
return CString(g_CommandList[i].cmdname);
+ }
}
return CString("");
}
@@ -1440,8 +1439,9 @@ static LRESULT CALLBACK ControlProc(HWND control, UINT message, WPARAM wParam, L
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++)
+ for(int i = 0, j = pList->GetItemCount(); i < j; i++) {
pList->SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
+ }
return 0;
}
@@ -1477,7 +1477,9 @@ BOOL CPPageAccelTbl::OnInitDialog()
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);
+ 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_MOD, _T("Modifier"), LVCFMT_LEFT, 40);
m_list.InsertColumn(COL_KEY, ResStr(IDS_AG_KEY), LVCFMT_LEFT, 40);
@@ -1489,8 +1491,7 @@ BOOL CPPageAccelTbl::OnInitDialog()
m_list.InsertColumn(COL_RMREPCNT, _T("RepCnt"), LVCFMT_CENTER, 60);
POSITION pos = m_wmcmds.GetHeadPosition();
- for(int i = 0; pos; i++)
- {
+ 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);
@@ -1524,18 +1525,26 @@ BOOL CPPageAccelTbl::OnApply()
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);
+ for(int i = 0; pos; i++) {
+ pAccel[i] = m_wmcmds.GetNext(pos);
+ }
+ if(s.hAccel) {
+ DestroyAcceleratorTable(s.hAccel);
+ }
s.hAccel = CreateAcceleratorTable(pAccel.GetData(), pAccel.GetCount());
GetParentFrame()->m_hAccelTable = s.hAccel;
s.fWinLirc = !!m_fWinLirc;
s.strWinLircAddr = m_WinLircAddr;
- if(s.fWinLirc) s.WinLircClient.Connect(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);
+ if(s.fUIce) {
+ s.UIceClient.Connect(m_UIceAddr);
+ }
s.fGlobalMedia = !!m_fGlobalMedia;
AfxGetMyApp()->RegisterHotkeys();
@@ -1547,8 +1556,7 @@ void CPPageAccelTbl::OnBnClickedButton1()
{
m_list.SetFocus();
- for(int i = 0, j = m_list.GetItemCount(); i < j; i++)
- {
+ for(int i = 0, j = m_list.GetItemCount(); i < j; i++) {
m_list.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
}
}
@@ -1558,10 +1566,11 @@ void CPPageAccelTbl::OnBnClickedButton2()
m_list.SetFocus();
POSITION pos = m_list.GetFirstSelectedItemPosition();
- if(!pos) return;
+ if(!pos) {
+ return;
+ }
- while(pos)
- {
+ while(pos) {
int ni = m_list.GetNextSelectedItem(pos);
POSITION pi = (POSITION)m_list.GetItemData(ni);
wmcmd& wc = m_wmcmds.GetAt(pi);
@@ -1580,13 +1589,13 @@ void CPPageAccelTbl::OnBeginlabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
*pResult = FALSE;
- if(pItem->iItem < 0)
+ if(pItem->iItem < 0) {
return;
+ }
if(pItem->iSubItem == COL_MOD || pItem->iSubItem == COL_KEY || pItem->iSubItem == COL_TYPE
|| pItem->iSubItem == COL_MOUSE || pItem->iSubItem == COL_APPCMD
- || pItem->iSubItem == COL_RMCMD || pItem->iSubItem == COL_RMREPCNT)
- {
+ || pItem->iSubItem == COL_RMCMD || pItem->iSubItem == COL_RMREPCNT) {
*pResult = TRUE;
}
}
@@ -1598,8 +1607,7 @@ void CPPageAccelTbl::OnDolabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
LV_ITEM* pItem = &pDispInfo->item;
- if(pItem->iItem < 0)
- {
+ if(pItem->iItem < 0) {
*pResult = FALSE;
return;
}
@@ -1612,61 +1620,64 @@ void CPPageAccelTbl::OnDolabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
CAtlList<CString> sl;
int nSel = -1;
- switch(pItem->iSubItem)
- {
- case COL_MOD:
- for(int i = 0; i < countof(s_mods); i++)
- {
- sl.AddTail(MakeAccelModLabel(s_mods[i]));
- if((a.fVirt&~3) == s_mods[i]) nSel = i;
- }
-
- m_list.ShowInPlaceComboBox(pItem->iItem, pItem->iSubItem, sl, nSel);
- break;
- case COL_KEY:
- for(int i = 0; i < 256; i++)
- {
- sl.AddTail(MakeAccelVkeyLabel(i, a.fVirt&FVIRTKEY));
- if(a.key == i) nSel = i;
- }
-
- m_list.ShowInPlaceComboBox(pItem->iItem, pItem->iSubItem, sl, nSel);
- break;
- case COL_TYPE:
- sl.AddTail(_T("VIRTKEY"));
- sl.AddTail(_T("ASCII"));
-
- nSel = !(a.fVirt&FVIRTKEY);
-
- m_list.ShowInPlaceComboBox(pItem->iItem, pItem->iSubItem, sl, nSel);
- 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_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;
+ switch(pItem->iSubItem) {
+ case COL_MOD:
+ for(int i = 0; i < countof(s_mods); i++) {
+ sl.AddTail(MakeAccelModLabel(s_mods[i]));
+ if((a.fVirt&~3) == s_mods[i]) {
+ nSel = i;
+ }
+ }
+
+ m_list.ShowInPlaceComboBox(pItem->iItem, pItem->iSubItem, sl, nSel);
+ break;
+ case COL_KEY:
+ for(int i = 0; i < 256; i++) {
+ sl.AddTail(MakeAccelVkeyLabel(i, a.fVirt&FVIRTKEY));
+ if(a.key == i) {
+ nSel = i;
+ }
+ }
+
+ m_list.ShowInPlaceComboBox(pItem->iItem, pItem->iSubItem, sl, nSel);
+ break;
+ case COL_TYPE:
+ sl.AddTail(_T("VIRTKEY"));
+ sl.AddTail(_T("ASCII"));
+
+ nSel = !(a.fVirt&FVIRTKEY);
+
+ m_list.ShowInPlaceComboBox(pItem->iItem, pItem->iSubItem, sl, nSel);
+ 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_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;
}
}
@@ -1677,79 +1688,74 @@ void CPPageAccelTbl::OnEndlabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
*pResult = FALSE;
- if(!m_list.m_fInPlaceDirty)
+ if(!m_list.m_fInPlaceDirty) {
return;
+ }
- if(pItem->iItem < 0)
+ if(pItem->iItem < 0) {
return;
+ }
wmcmd& wc = m_wmcmds.GetAt((POSITION)m_list.GetItemData(pItem->iItem));
- switch(pItem->iSubItem)
- {
- case COL_MOD:
- if(pItem->lParam >= 0 && pItem->lParam < countof(s_mods))
- {
- wc.fVirt = (wc.fVirt&3) | (s_mods[pItem->lParam]&~3);
- m_list.SetItemText(pItem->iItem, COL_MOD, pItem->pszText);
- *pResult = TRUE;
+ switch(pItem->iSubItem) {
+ case COL_MOD:
+ if(pItem->lParam >= 0 && pItem->lParam < countof(s_mods)) {
+ wc.fVirt = (wc.fVirt&3) | (s_mods[pItem->lParam]&~3);
+ m_list.SetItemText(pItem->iItem, COL_MOD, pItem->pszText);
+ *pResult = TRUE;
+ }
+ break;
+ case COL_KEY: {
+ int i = pItem->lParam;
+ if(i >= 0 && i < 256) {
+ wc.key = (WORD)i;
+ m_list.SetItemText(pItem->iItem, COL_KEY, pItem->pszText);
+ *pResult = TRUE;
+ }
}
break;
- case COL_KEY:
- {
- int i = pItem->lParam;
- if(i >= 0 && i < 256)
- {
- wc.key = (WORD)i;
- m_list.SetItemText(pItem->iItem, COL_KEY, pItem->pszText);
- *pResult = TRUE;
- }
- }
- break;
- case COL_TYPE:
- {
- int i = pItem->lParam;
- if(i >= 0 && i < 2)
- {
- wc.fVirt = (wc.fVirt&~FVIRTKEY) | (i == 0 ? FVIRTKEY : 0);
- m_list.SetItemText(pItem->iItem, COL_KEY, MakeAccelVkeyLabel(wc.key, wc.fVirt&FVIRTKEY));
- m_list.SetItemText(pItem->iItem, COL_TYPE, (wc.fVirt&FVIRTKEY)?_T("VIRTKEY"):_T("ASCII"));
- *pResult = TRUE;
- }
- }
- break;
- case COL_APPCMD:
- {
- int 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;
+ case COL_TYPE: {
+ int i = pItem->lParam;
+ if(i >= 0 && i < 2) {
+ wc.fVirt = (wc.fVirt&~FVIRTKEY) | (i == 0 ? FVIRTKEY : 0);
+ m_list.SetItemText(pItem->iItem, COL_KEY, MakeAccelVkeyLabel(wc.key, wc.fVirt&FVIRTKEY));
+ m_list.SetItemText(pItem->iItem, COL_TYPE, (wc.fVirt&FVIRTKEY)?_T("VIRTKEY"):_T("ASCII"));
+ *pResult = TRUE;
+ }
}
- }
- break;
- case COL_MOUSE:
- wc.mouse = pItem->lParam;
- m_list.SetItemText(pItem->iItem, COL_MOUSE, 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;
+ case COL_APPCMD: {
+ int 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 = pItem->lParam;
+ m_list.SetItemText(pItem->iItem, COL_MOUSE, 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)
+ if(*pResult) {
SetModified();
+ }
}
@@ -1757,8 +1763,7 @@ void CPPageAccelTbl::OnTimer(UINT_PTR nIDEvent)
{
UpdateData();
- if(m_fWinLirc)
- {
+ if(m_fWinLirc) {
CString addr;
m_WinLircEdit.GetWindowText(addr);
AfxGetAppSettings().WinLircClient.Connect(addr);
@@ -1766,8 +1771,7 @@ void CPPageAccelTbl::OnTimer(UINT_PTR nIDEvent)
m_WinLircEdit.Invalidate();
- if(m_fUIce)
- {
+ if(m_fUIce) {
CString addr;
m_UIceEdit.GetWindowText(addr);
AfxGetAppSettings().UIceClient.Connect(addr);
@@ -1786,15 +1790,17 @@ HBRUSH CPPageAccelTbl::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
int status = -1;
- if(*pWnd == m_WinLircEdit)
+ if(*pWnd == m_WinLircEdit) {
status = AfxGetAppSettings().WinLircClient.GetStatus();
- else if(*pWnd == m_UIceEdit)
+ } else if(*pWnd == m_UIceEdit) {
status = AfxGetAppSettings().UIceClient.GetStatus();
+ }
- if(status == 0 || status == 2 && (m_counter&1))
+ if(status == 0 || status == 2 && (m_counter&1)) {
pDC->SetTextColor(0x0000ff);
- else if(status == 1)
+ } else if(status == 1) {
pDC->SetTextColor(0x008000);
+ }
return hbr;
}
diff --git a/src/apps/mplayerc/PPageAccelTbl.h b/src/apps/mplayerc/PPageAccelTbl.h
index 8b1bbb4a5..f6d0b14de 100644
--- a/src/apps/mplayerc/PPageAccelTbl.h
+++ b/src/apps/mplayerc/PPageAccelTbl.h
@@ -55,7 +55,7 @@ public:
enum {APPCOMMAND_LAST=APPCOMMAND_DWM_FLIP3D};
-// Dialog Data
+ // Dialog Data
enum { IDD = IDD_PPAGEACCELTBL };
CPlayerListCtrl m_list;
BOOL m_fWinLirc;
diff --git a/src/apps/mplayerc/PPageAudioSwitcher.cpp b/src/apps/mplayerc/PPageAudioSwitcher.cpp
index d5cac0e9c..c664b916a 100644
--- a/src/apps/mplayerc/PPageAudioSwitcher.cpp
+++ b/src/apps/mplayerc/PPageAudioSwitcher.cpp
@@ -116,14 +116,16 @@ BOOL CPPageAudioSwitcher::OnInitDialog()
m_fCustomChannelMapping = s.fCustomChannelMapping;
memcpy(m_pSpeakerToChannelMap, s.pSpeakerToChannelMap, sizeof(s.pSpeakerToChannelMap));
- if(m_pASF)
+ if(m_pASF) {
m_pASF->GetInputSpeakerConfig(&m_dwChannelMask);
+ }
m_nChannels = s.nSpeakerChannels;
m_nChannelsSpinCtrl.SetRange(1, 18);
- if(m_pASF)
+ if(m_pASF) {
m_nChannels = m_pASF->GetNumberOfInputChannels();
+ }
m_list.InsertColumn(0, _T(""), LVCFMT_LEFT, 100);
m_list.InsertItem(0, _T(""));
@@ -147,14 +149,13 @@ BOOL CPPageAudioSwitcher::OnInitDialog()
m_list.InsertItem(18, ResStr(IDS_TOP_BACK_RIGHT));
m_list.SetColumnWidth(0, LVSCW_AUTOSIZE);
- for(int i = 1; i <= 18; i++)
- {
+ 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_list.SetColumnWidth(i, LVSCW_AUTOSIZE);
+ // m_list.SetColumnWidth(i, m_list.GetColumnWidth(i)*8/10);
}
m_tooltip.Create(GetDlgItem(IDC_SLIDER1));
@@ -182,8 +183,7 @@ BOOL CPPageAudioSwitcher::OnApply()
s.fCustomChannelMapping = !!m_fCustomChannelMapping;
memcpy(s.pSpeakerToChannelMap, m_pSpeakerToChannelMap, sizeof(m_pSpeakerToChannelMap));
- if(m_pASF)
- {
+ if(m_pASF) {
m_pASF->SetSpeakerConfig(s.fCustomChannelMapping, s.pSpeakerToChannelMap);
m_pASF->EnableDownSamplingTo441(s.fDownSampleTo441);
m_pASF->SetAudioTimeShift(s.fAudioTimeShift ? 10000i64*s.iAudioTimeShift : 0);
@@ -199,15 +199,13 @@ void CPPageAudioSwitcher::OnNMClickList1(NMHDR* pNMHDR, LRESULT* pResult)
{
LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)pNMHDR;
- if(lpnmlv->iItem > 0 && lpnmlv->iSubItem > 0 && lpnmlv->iSubItem <= m_nChannels)
- {
+ 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)
- {
+ if(GetKeyState(VK_SHIFT) & 0x8000) {
OnApply();
}
}
@@ -217,8 +215,7 @@ void CPPageAudioSwitcher::OnNMClickList1(NMHDR* pNMHDR, LRESULT* pResult)
void CPPageAudioSwitcher::OnEnChangeEdit1()
{
- if(IsWindow(m_list.m_hWnd))
- {
+ if(IsWindow(m_list.m_hWnd)) {
UpdateData();
m_list.Invalidate();
SetModified();
@@ -229,10 +226,12 @@ void CPPageAudioSwitcher::OnEnChangeEdit1()
void CPPageAudioSwitcher::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
{
- if(nIDCtl != IDC_LIST1) return;
+ if(nIDCtl != IDC_LIST1) {
+ return;
+ }
-// if(lpDrawItemStruct->itemID == 0)
-// UpdateData();
+ // if(lpDrawItemStruct->itemID == 0)
+ // UpdateData();
CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
@@ -247,8 +246,7 @@ void CPPageAudioSwitcher::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStru
CHeaderCtrl* pHeader = m_list.GetHeaderCtrl();
int nColumnCount = pHeader->GetItemCount();
- for(int i = 0; i < nColumnCount; i++)
- {
+ 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);
@@ -258,43 +256,32 @@ void CPPageAudioSwitcher::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStru
CSize s = pDC->GetTextExtent(m_list.GetItemText(lpDrawItemStruct->itemID, i));
- if(i == 0)
- {
+ if(i == 0) {
r.left = rb.left;
- if(lpDrawItemStruct->itemID == 0)
- {
+ if(lpDrawItemStruct->itemID == 0) {
pDC->MoveTo(0, 0);
pDC->LineTo(r.right, r.bottom-1);
- }
- else
- {
+ } 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
- {
+ } else {
pDC->SetTextColor(i > m_nChannels ? 0xe0e0e0 : (!m_list.IsWindowEnabled() ? 0xb0b0b0 : 0));
- if(lpDrawItemStruct->itemID == 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)))
- {
+ } 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)
+ for(int j = 1; j <= (1<<(lpDrawItemStruct->itemID-1)); j <<= 1) {
+ if(m_dwChannelMask & j) {
nBitsSet++;
+ }
}
- if(nBitsSet == i)
- {
+ if(nBitsSet == i) {
COLORREF tmp = pDC->GetTextColor();
pDC->SetTextColor(0xe0e0e0);
@@ -309,8 +296,7 @@ void CPPageAudioSwitcher::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStru
}
}
- if(m_pSpeakerToChannelMap[m_nChannels-1][lpDrawItemStruct->itemID-1] & (1<<(i-1)))
- {
+ 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);
@@ -327,13 +313,13 @@ void CPPageAudioSwitcher::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStru
void CPPageAudioSwitcher::OnUpdateAudioSwitcher(CCmdUI* pCmdUI)
{
-// UpdateData();
+ // UpdateData();
pCmdUI->Enable(IsDlgButtonChecked(IDC_CHECK2)/*m_fEnableAudioSwitcher*/);
}
void CPPageAudioSwitcher::OnUpdateChannelMapping(CCmdUI* pCmdUI)
{
-// UpdateData();
+ // UpdateData();
pCmdUI->Enable(IsDlgButtonChecked(IDC_CHECK2)/*m_fEnableAudioSwitcher*/
&& IsDlgButtonChecked(IDC_CHECK1)/*m_fCustomChannelMapping*/);
}
@@ -351,20 +337,21 @@ BOOL CPPageAudioSwitcher::OnToolTipNotify(UINT id, NMHDR * pNMHDR, LRESULT * pRe
UINT nID = pNMHDR->idFrom;
- if (pNMHDR->code == TTN_NEEDTEXTW && (pTTTW->uFlags & TTF_IDISHWND))
- {
+ if (pNMHDR->code == TTN_NEEDTEXTW && (pTTTW->uFlags & TTF_IDISHWND)) {
nID = ::GetDlgCtrlID((HWND)nID);
}
- if(nID == 0)
+ if(nID == 0) {
return FALSE;
+ }
static CStringW m_strTipTextW;
m_strTipTextW.Format(L"+%.1f dB", m_AudioBoostCtrl.GetPos()/10.0);
- if(pNMHDR->code == TTN_NEEDTEXTW) //?possible check is not needed
+ if(pNMHDR->code == TTN_NEEDTEXTW) { //?possible check is not needed
pTTTW->lpszText = (LPWSTR)(LPCWSTR)m_strTipTextW;
+ }
*pResult = 0;
diff --git a/src/apps/mplayerc/PPageAudioSwitcher.h b/src/apps/mplayerc/PPageAudioSwitcher.h
index 67c24d184..dbc332049 100644
--- a/src/apps/mplayerc/PPageAudioSwitcher.h
+++ b/src/apps/mplayerc/PPageAudioSwitcher.h
@@ -43,7 +43,7 @@ public:
CPPageAudioSwitcher(IFilterGraph* pFG);
virtual ~CPPageAudioSwitcher();
-// Dialog Data
+ // Dialog Data
enum { IDD = IDD_PPAGEAUDIOSWITCHER };
BOOL m_fEnableAudioSwitcher;
diff --git a/src/apps/mplayerc/PPageBase.cpp b/src/apps/mplayerc/PPageBase.cpp
index f3c23a6a9..de49f2931 100644
--- a/src/apps/mplayerc/PPageBase.cpp
+++ b/src/apps/mplayerc/PPageBase.cpp
@@ -49,30 +49,27 @@ void CPPageBase::CreateToolTip()
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))
- {
+ for(CWnd* pChild = GetWindow(GW_CHILD); pChild; pChild = pChild->GetWindow(GW_HWNDNEXT)) {
CString strToolTip;
- if(strToolTip.LoadString(pChild->GetDlgCtrlID()))
+ 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)
- {
+ 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))
- {
+ hWndParent = ::GetParent(hWndParent)) {
msg.hwnd = hWndParent;
}
- if(msg.hwnd)
- {
+ if(msg.hwnd) {
m_wndToolTip.RelayEvent(&msg);
}
}
diff --git a/src/apps/mplayerc/PPageBase.h b/src/apps/mplayerc/PPageBase.h
index 3db4f17c3..b1bc4aaac 100644
--- a/src/apps/mplayerc/PPageBase.h
+++ b/src/apps/mplayerc/PPageBase.h
@@ -37,7 +37,7 @@ public:
CPPageBase(UINT nIDTemplate, UINT nIDCaption = 0);
virtual ~CPPageBase();
-// Dialog Data
+ // Dialog Data
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
diff --git a/src/apps/mplayerc/PPageCapture.cpp b/src/apps/mplayerc/PPageCapture.cpp
index 49feaa013..ad82c2ded 100644
--- a/src/apps/mplayerc/PPageCapture.cpp
+++ b/src/apps/mplayerc/PPageCapture.cpp
@@ -35,13 +35,11 @@
#include "../../DSUtil/DSUtil.h"
-static struct cc_t
-{
+static struct cc_t {
long code;
AnalogVideoStandard standard;
const TCHAR* str;
-} s_countrycodes[] =
-{
+} s_countrycodes[] = {
{1, AnalogVideo_NTSC_M, _T("USA")},
{2, AnalogVideo_NTSC_M, _T("Canada")},
{7, AnalogVideo_SECAM_D, _T("Russia")},
@@ -312,8 +310,7 @@ void CPPageCapture::FindAnalogDevices()
int iSel = 0;
// List video devised
- BeginEnumSysDev(CLSID_VideoInputDeviceCategory, pMoniker)
- {
+ BeginEnumSysDev(CLSID_VideoInputDeviceCategory, pMoniker) {
CComPtr<IPropertyBag> pPB;
pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB);
@@ -322,10 +319,11 @@ void CPPageCapture::FindAnalogDevices()
int i = m_cbAnalogVideo.AddString(CString(var.bstrVal));
LPOLESTR strName = NULL;
- if(SUCCEEDED(pMoniker->GetDisplayName(NULL, NULL, &strName)))
- {
+ if(SUCCEEDED(pMoniker->GetDisplayName(NULL, NULL, &strName))) {
m_vidnames.Add(CString(strName));
- if(s.strAnalogVideo == CString(strName)) iSel = i;
+ if(s.strAnalogVideo == CString(strName)) {
+ iSel = i;
+ }
CoTaskMemFree(strName);
}
}
@@ -334,18 +332,18 @@ void CPPageCapture::FindAnalogDevices()
{
int i = m_cbAnalogAudio.AddString(_T("<Video Capture Device>"));
m_audnames.Add(_T(""));
- if(s.strAnalogAudio.IsEmpty()) iSel = i;
+ if(s.strAnalogAudio.IsEmpty()) {
+ iSel = i;
+ }
}
- if(m_cbAnalogVideo.GetCount())
- {
+ if(m_cbAnalogVideo.GetCount()) {
m_cbAnalogVideo.SetCurSel(iSel);
}
// List audio devised
iSel = 0;
- BeginEnumSysDev(CLSID_AudioInputDeviceCategory, pMoniker)
- {
+ BeginEnumSysDev(CLSID_AudioInputDeviceCategory, pMoniker) {
CComPtr<IPropertyBag> pPB;
pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB);
@@ -354,84 +352,84 @@ void CPPageCapture::FindAnalogDevices()
int i = m_cbAnalogAudio.AddString(CString(var.bstrVal));
LPOLESTR strName = NULL;
- if(SUCCEEDED(pMoniker->GetDisplayName(NULL, NULL, &strName)))
- {
+ if(SUCCEEDED(pMoniker->GetDisplayName(NULL, NULL, &strName))) {
m_audnames.Add(CString(strName));
- if(s.strAnalogAudio == CString(strName)) iSel = i;
+ if(s.strAnalogAudio == CString(strName)) {
+ iSel = i;
+ }
CoTaskMemFree(strName);
}
}
EndEnumSysDev
- if(m_cbAnalogAudio.GetCount())
+ if(m_cbAnalogAudio.GetCount()) {
m_cbAnalogAudio.SetCurSel(iSel);
+ }
// Fill country
iSel = 0;
- for(int j = 0; j < countof(s_countrycodes); j++)
- {
+ 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;
+ 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;
@@ -439,11 +437,14 @@ void CPPageCapture::FindAnalogDevices()
int i = m_cbAnalogCountry.AddString(str);
m_cbAnalogCountry.SetItemDataPtr(i, &s_countrycodes[j]);
- if(s.iAnalogCountry == s_countrycodes[j].code) iSel = i;
+ if(s.iAnalogCountry == s_countrycodes[j].code) {
+ iSel = i;
+ }
}
- if(m_cbAnalogCountry.GetCount())
+ if(m_cbAnalogCountry.GetCount()) {
m_cbAnalogCountry.SetCurSel(iSel);
+ }
}
void CPPageCapture::FindDigitalDevices()
@@ -451,8 +452,7 @@ void CPPageCapture::FindDigitalDevices()
AppSettings& s = AfxGetAppSettings();
int iSel = 0;
- BeginEnumSysDev(KSCATEGORY_BDA_NETWORK_PROVIDER, pMoniker)
- {
+ BeginEnumSysDev(KSCATEGORY_BDA_NETWORK_PROVIDER, pMoniker) {
CComPtr<IPropertyBag> pPB;
pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB);
@@ -461,21 +461,22 @@ void CPPageCapture::FindDigitalDevices()
int i = m_cbDigitalNetworkProvider.AddString(CString(var.bstrVal));
LPOLESTR strName = NULL;
- if(SUCCEEDED(pMoniker->GetDisplayName(NULL, NULL, &strName)))
- {
+ if(SUCCEEDED(pMoniker->GetDisplayName(NULL, NULL, &strName))) {
m_providernames.Add(CString(strName));
- if (s.strBDANetworkProvider == CString(strName)) iSel = i;
+ if (s.strBDANetworkProvider == CString(strName)) {
+ iSel = i;
+ }
CoTaskMemFree(strName);
}
}
EndEnumSysDev
- if(m_cbDigitalNetworkProvider.GetCount())
+ if(m_cbDigitalNetworkProvider.GetCount()) {
m_cbDigitalNetworkProvider.SetCurSel(iSel);
+ }
iSel = 0;
- BeginEnumSysDev(KSCATEGORY_BDA_NETWORK_TUNER, pMoniker)
- {
+ BeginEnumSysDev(KSCATEGORY_BDA_NETWORK_TUNER, pMoniker) {
CComPtr<IPropertyBag> pPB;
pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB);
@@ -484,20 +485,21 @@ void CPPageCapture::FindDigitalDevices()
int i = m_cbDigitalTuner.AddString(CString(var.bstrVal));
LPOLESTR strName = NULL;
- if(SUCCEEDED(pMoniker->GetDisplayName(NULL, NULL, &strName)))
- {
+ if(SUCCEEDED(pMoniker->GetDisplayName(NULL, NULL, &strName))) {
m_tunernames.Add(CString(strName));
- if (s.strBDATuner == CString(strName)) iSel = i;
+ if (s.strBDATuner == CString(strName)) {
+ iSel = i;
+ }
CoTaskMemFree(strName);
}
}
EndEnumSysDev
- if(m_cbDigitalTuner.GetCount())
+ if(m_cbDigitalTuner.GetCount()) {
m_cbDigitalTuner.SetCurSel(iSel);
+ }
iSel = 0;
- BeginEnumSysDev(KSCATEGORY_BDA_RECEIVER_COMPONENT, pMoniker)
- {
+ BeginEnumSysDev(KSCATEGORY_BDA_RECEIVER_COMPONENT, pMoniker) {
CComPtr<IPropertyBag> pPB;
pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB);
@@ -506,16 +508,18 @@ void CPPageCapture::FindDigitalDevices()
int i = m_cbDigitalReceiver.AddString(CString(var.bstrVal));
LPOLESTR strName = NULL;
- if(SUCCEEDED(pMoniker->GetDisplayName(NULL, NULL, &strName)))
- {
+ if(SUCCEEDED(pMoniker->GetDisplayName(NULL, NULL, &strName))) {
m_receivernames.Add(CString(strName));
- if (s.strBDAReceiver == CString(strName)) iSel = i;
+ if (s.strBDAReceiver == CString(strName)) {
+ iSel = i;
+ }
CoTaskMemFree(strName);
}
}
EndEnumSysDev
- if(m_cbDigitalReceiver.GetCount())
+ if(m_cbDigitalReceiver.GetCount()) {
m_cbDigitalReceiver.SetCurSel(iSel);
+ }
}
BOOL CPPageCapture::OnApply()
@@ -526,19 +530,25 @@ BOOL CPPageCapture::OnApply()
s.iDefaultCaptureDevice = m_iDefaultDevice;
- if (m_cbAnalogVideo.GetCurSel()>=0)
+ if (m_cbAnalogVideo.GetCurSel()>=0) {
s.strAnalogVideo = m_vidnames[m_cbAnalogVideo.GetCurSel()];
- if (m_cbAnalogAudio.GetCurSel()>=0)
+ }
+ if (m_cbAnalogAudio.GetCurSel()>=0) {
s.strAnalogAudio = m_audnames[m_cbAnalogAudio.GetCurSel()];
- if (m_cbAnalogCountry.GetCurSel()>=0)
+ }
+ if (m_cbAnalogCountry.GetCurSel()>=0) {
s.iAnalogCountry = ((cc_t*)m_cbAnalogCountry.GetItemDataPtr(m_cbAnalogCountry.GetCurSel()))->code;
+ }
- if (m_cbDigitalNetworkProvider.GetCurSel()>=0)
+ if (m_cbDigitalNetworkProvider.GetCurSel()>=0) {
s.strBDANetworkProvider = m_providernames[m_cbDigitalNetworkProvider.GetCurSel()];
- if (m_cbDigitalTuner.GetCurSel()>=0)
+ }
+ if (m_cbDigitalTuner.GetCurSel()>=0) {
s.strBDATuner = m_tunernames[m_cbDigitalTuner.GetCurSel()];
- if (m_cbDigitalReceiver.GetCurSel()>=0)
+ }
+ if (m_cbDigitalReceiver.GetCurSel()>=0) {
s.strBDAReceiver = m_receivernames[m_cbDigitalReceiver.GetCurSel()];
+ }
return __super::OnApply();
}
diff --git a/src/apps/mplayerc/PPageCapture.h b/src/apps/mplayerc/PPageCapture.h
index e78030b26..ecebdb341 100644
--- a/src/apps/mplayerc/PPageCapture.h
+++ b/src/apps/mplayerc/PPageCapture.h
@@ -38,7 +38,7 @@ public:
CPPageCapture(); // standard constructor
virtual ~CPPageCapture();
-// Dialog Data
+ // Dialog Data
enum { IDD = IDD_PPAGECAPTURE };
protected:
diff --git a/src/apps/mplayerc/PPageCasimir.cpp b/src/apps/mplayerc/PPageCasimir.cpp
index e340cf09f..49760cc1d 100644
--- a/src/apps/mplayerc/PPageCasimir.cpp
+++ b/src/apps/mplayerc/PPageCasimir.cpp
@@ -71,8 +71,7 @@ BOOL CPPageCasimir::OnInitDialog()
CreateToolTip();
ControlRange = AfxGetMyApp()->GetColorControl (Contrast);
- if (ControlRange)
- {
+ if (ControlRange) {
m_dContrast = s.dContrast;
m_SliContrast.EnableWindow (TRUE);
m_SliContrast.SetRange ((int)ControlRange->MinValue*100, (int)ControlRange->MaxValue*100);
@@ -81,8 +80,7 @@ BOOL CPPageCasimir::OnInitDialog()
}
ControlRange = AfxGetMyApp()->GetColorControl (Brightness);
- if (ControlRange)
- {
+ if (ControlRange) {
m_dBrightness = s.dBrightness;
m_SliBrightness.EnableWindow (TRUE);
m_SliBrightness.SetRange ((int)ControlRange->MinValue, (int)ControlRange->MaxValue);
@@ -91,8 +89,7 @@ BOOL CPPageCasimir::OnInitDialog()
}
ControlRange = AfxGetMyApp()->GetColorControl (Hue);
- if (ControlRange)
- {
+ if (ControlRange) {
m_dHue = s.dHue;
m_SliHue.EnableWindow (TRUE);
m_SliHue.SetRange ((int)ControlRange->MinValue, (int)ControlRange->MaxValue);
@@ -101,8 +98,7 @@ BOOL CPPageCasimir::OnInitDialog()
}
ControlRange = AfxGetMyApp()->GetColorControl (Saturation);
- if (ControlRange)
- {
+ if (ControlRange) {
m_dSaturation = s.dSaturation;
m_SliSaturation.EnableWindow (TRUE);
m_SliSaturation.SetRange ((int)ControlRange->MinValue*100, (int)ControlRange->MaxValue*100);
@@ -130,23 +126,16 @@ BOOL CPPageCasimir::OnApply()
void CPPageCasimir::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
- if(*pScrollBar == m_SliContrast)
- {
+ if(*pScrollBar == m_SliContrast) {
UpdateData();
m_dContrast = (float)(m_SliContrast.GetPos()/100.0);
- }
- else if(*pScrollBar == m_SliBrightness)
- {
+ } else if(*pScrollBar == m_SliBrightness) {
UpdateData();
m_dBrightness = (float)m_SliBrightness.GetPos();
- }
- else if(*pScrollBar == m_SliHue)
- {
+ } else if(*pScrollBar == m_SliHue) {
UpdateData();
m_dHue = (float)m_SliHue.GetPos();
- }
- else if(*pScrollBar == m_SliSaturation)
- {
+ } else if(*pScrollBar == m_SliSaturation) {
UpdateData();
m_dSaturation = (float)(m_SliSaturation.GetPos()/100.0);
}
diff --git a/src/apps/mplayerc/PPageCasimir.h b/src/apps/mplayerc/PPageCasimir.h
index d9420c91c..204d03d78 100644
--- a/src/apps/mplayerc/PPageCasimir.h
+++ b/src/apps/mplayerc/PPageCasimir.h
@@ -42,7 +42,7 @@ public:
CPPageCasimir();
virtual ~CPPageCasimir();
-// Dialog Data
+ // Dialog Data
enum { IDD = IDD_PPAGECASIMIR };
protected:
diff --git a/src/apps/mplayerc/PPageDVD.cpp b/src/apps/mplayerc/PPageDVD.cpp
index 823163d45..33adb2695 100644
--- a/src/apps/mplayerc/PPageDVD.cpp
+++ b/src/apps/mplayerc/PPageDVD.cpp
@@ -26,13 +26,11 @@
#include "PPageDVD.h"
-struct
-{
+struct {
LCID lcid;
LPCSTR name;
}
-LCIDNameList[] =
-{
+LCIDNameList[] = {
{0x0000, "Default"},
{0x0436, "Afrikaans"},
{0x041c, "Albanian"},
@@ -212,10 +210,8 @@ void CPPageDVD::UpdateLCIDList()
: m_iDVDLangType == 1 ? m_idAudioLang
: m_idSubtitlesLang;
- for(int i = 0; i < m_lcids.GetCount(); i++)
- {
- if(m_lcids.GetItemData(i) == lcid)
- {
+ for(int i = 0; i < m_lcids.GetCount(); i++) {
+ if(m_lcids.GetItemData(i) == lcid) {
m_lcids.SetCurSel(i);
m_lcids.SetTopIndex(i);
break;
@@ -251,8 +247,7 @@ BOOL CPPageDVD::OnInitDialog()
UpdateData(FALSE);
- for(int i = 0; i < countof(LCIDNameList); i++)
- {
+ for(int i = 0; i < countof(LCIDNameList); i++) {
m_lcids.AddString(CString(LCIDNameList[i].name));
m_lcids.SetItemData(i, LCIDNameList[i].lcid);
}
@@ -294,8 +289,7 @@ void CPPageDVD::OnBnClickedButton1()
bi.iImage = 0;
LPITEMIDLIST iil = SHBrowseForFolder(&bi);
- if(iil)
- {
+ if(iil) {
SHGetPathFromIDList(iil, path);
m_dvdpath = path;
diff --git a/src/apps/mplayerc/PPageDVD.h b/src/apps/mplayerc/PPageDVD.h
index 6579611d5..3a0a4aefd 100644
--- a/src/apps/mplayerc/PPageDVD.h
+++ b/src/apps/mplayerc/PPageDVD.h
@@ -52,7 +52,7 @@ public:
BOOL m_fAutoSpeakerConf;
-// Dialog Data
+ // Dialog Data
enum { IDD = IDD_PPAGEDVD};
protected:
diff --git a/src/apps/mplayerc/PPageExternalFilters.cpp b/src/apps/mplayerc/PPageExternalFilters.cpp
index b088096cc..672037df3 100644
--- a/src/apps/mplayerc/PPageExternalFilters.cpp
+++ b/src/apps/mplayerc/PPageExternalFilters.cpp
@@ -60,7 +60,9 @@ void CPPageExternalFilters::DoDataExchange(CDataExchange* pDX)
void CPPageExternalFilters::StepUp(CCheckListBox& list)
{
int i = list.GetCurSel();
- if(i < 1) return;
+ if(i < 1) {
+ return;
+ }
CString str;
list.GetText(i, str);
@@ -77,7 +79,9 @@ void CPPageExternalFilters::StepUp(CCheckListBox& list)
void CPPageExternalFilters::StepDown(CCheckListBox& list)
{
int i = list.GetCurSel();
- if(i < 0 || i >= list.GetCount()-1) return;
+ if(i < 0 || i >= list.GetCount()-1) {
+ return;
+ }
CString str;
list.GetText(i, str);
@@ -287,22 +291,24 @@ BOOL CPPageExternalFilters::OnInitDialog()
m_pFilters.RemoveAll();
POSITION pos = s.m_filters.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CAutoPtr<FilterOverride> f(DNew FilterOverride(s.m_filters.GetNext(pos)));
CString name(_T("<unknown>"));
- if(f->type == FilterOverride::REGISTERED)
- {
+ 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)
- {
+ 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->fTemporary) {
+ name += _T(" <temporary>");
+ }
+ if(!CPath(MakeFullPath(f->path)).FileExists()) {
+ name += _T(" <not found!>");
+ }
}
int i = m_filters.AddString(name);
@@ -324,10 +330,8 @@ BOOL CPPageExternalFilters::OnApply()
s.m_filters.RemoveAll();
- for(int i = 0; i < m_filters.GetCount(); i++)
- {
- if(POSITION pos = (POSITION)m_filters.GetItemData(i))
- {
+ 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);
@@ -339,12 +343,9 @@ BOOL CPPageExternalFilters::OnApply()
void CPPageExternalFilters::OnUpdateFilter(CCmdUI* pCmdUI)
{
- if(FilterOverride* f = GetCurFilter())
- {
+ if(FilterOverride* f = GetCurFilter()) {
pCmdUI->Enable(!(pCmdUI->m_nID == IDC_RADIO2 && f->type == FilterOverride::EXTERNAL));
- }
- else
- {
+ } else {
pCmdUI->Enable(FALSE);
}
}
@@ -379,27 +380,24 @@ void CPPageExternalFilters::OnUpdateDeleteType(CCmdUI* pCmdUI)
void CPPageExternalFilters::OnAddRegistered()
{
CRegFilterChooserDlg dlg(this);
- if(dlg.DoModal() == IDOK)
- {
- while(!dlg.m_filters.IsEmpty())
- {
- if(FilterOverride* f = dlg.m_filters.RemoveHead())
- {
+ if(dlg.DoModal() == IDOK) {
+ while(!dlg.m_filters.IsEmpty()) {
+ if(FilterOverride* f = dlg.m_filters.RemoveHead()) {
CAutoPtr<FilterOverride> p(f);
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);
- if(dlg.m_filters.IsEmpty())
- {
+ if(dlg.m_filters.IsEmpty()) {
m_filters.SetCurSel(i);
OnLbnSelchangeList1();
}
@@ -413,7 +411,9 @@ void CPPageExternalFilters::OnRemoveFilter()
int i = m_filters.GetCurSel();
m_pFilters.RemoveAt((POSITION)m_filters.GetItemDataPtr(i));
m_filters.DeleteString(i);
- if(i >= m_filters.GetCount()) i--;
+ if(i >= m_filters.GetCount()) {
+ i--;
+ }
m_filters.SetCurSel(i);
OnLbnSelchangeList1();
}
@@ -430,31 +430,28 @@ void CPPageExternalFilters::OnMoveFilterDown()
void CPPageExternalFilters::OnLbnDblclkFilter()
{
- if(FilterOverride* f = GetCurFilter())
- {
+ if(FilterOverride* f = GetCurFilter()) {
CComPtr<IBaseFilter> pBF;
CString name;
- if(f->type == FilterOverride::REGISTERED)
- {
+ if(f->type == FilterOverride::REGISTERED) {
CStringW namew;
- if(CreateFilter(f->dispname, &pBF, namew))
+ if(CreateFilter(f->dispname, &pBF, namew)) {
name = namew;
- }
- else if(f->type == FilterOverride::EXTERNAL)
- {
- if(SUCCEEDED(LoadExternalFilter(f->path, f->clsid, &pBF)))
+ }
+ } else if(f->type == FilterOverride::EXTERNAL) {
+ if(SUCCEEDED(LoadExternalFilter(f->path, f->clsid, &pBF))) {
name = f->name;
+ }
}
- if(CComQIPtr<ISpecifyPropertyPages> pSPP = pBF)
- {
+ if(CComQIPtr<ISpecifyPropertyPages> pSPP = pBF) {
CComPropertySheet ps(name, this);
- if(ps.AddPages(pSPP) > 0)
- {
+ if(ps.AddPages(pSPP) > 0) {
CComPtr<IFilterGraph> pFG;
- if(SUCCEEDED(pFG.CoCreateInstance(CLSID_FilterGraph)))
+ if(SUCCEEDED(pFG.CoCreateInstance(CLSID_FilterGraph))) {
pFG->AddFilter(pBF, L"");
+ }
ps.DoModal();
}
@@ -465,19 +462,18 @@ void CPPageExternalFilters::OnLbnDblclkFilter()
void CPPageExternalFilters::OnAddMajorType()
{
FilterOverride* f = GetCurFilter();
- if(!f) return;
+ if(!f) {
+ return;
+ }
CAtlArray<GUID> guids;
SetupMajorTypes(guids);
CSelectMediaType dlg(guids, MEDIATYPE_NULL, this);
- if(dlg.DoModal() == IDOK)
- {
+ if(dlg.DoModal() == IDOK) {
POSITION pos = f->guids.GetHeadPosition();
- while(pos)
- {
- if(f->guids.GetNext(pos) == dlg.m_guid)
- {
+ while(pos) {
+ if(f->guids.GetNext(pos) == dlg.m_guid) {
AfxMessageBox(_T("Already on the list!"));
return;
}
@@ -502,13 +498,19 @@ void CPPageExternalFilters::OnAddMajorType()
void CPPageExternalFilters::OnAddSubType()
{
FilterOverride* f = GetCurFilter();
- if(!f) return;
+ if(!f) {
+ return;
+ }
HTREEITEM node = m_tree.GetSelectedItem();
- if(!node) return;
+ if(!node) {
+ return;
+ }
HTREEITEM child = m_tree.GetChildItem(node);
- if(!child) return;
+ if(!child) {
+ return;
+ }
POSITION pos = (POSITION)m_tree.GetItemData(child);
GUID major = f->guids.GetAt(pos);
@@ -517,14 +519,11 @@ void CPPageExternalFilters::OnAddSubType()
SetupSubTypes(guids);
CSelectMediaType dlg(guids, MEDIASUBTYPE_NULL, this);
- if(dlg.DoModal() == IDOK)
- {
- for(child = m_tree.GetChildItem(node); child; child = m_tree.GetNextSiblingItem(child))
- {
+ 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)
- {
+ if(f->guids.GetAt(pos) == dlg.m_guid) {
AfxMessageBox(_T("Already on the list!"));
return;
}
@@ -543,17 +542,16 @@ void CPPageExternalFilters::OnAddSubType()
void CPPageExternalFilters::OnDeleteType()
{
- if(FilterOverride* f = GetCurFilter())
- {
+ if(FilterOverride* f = GetCurFilter()) {
HTREEITEM node = m_tree.GetSelectedItem();
- if(!node) return;
+ if(!node) {
+ return;
+ }
POSITION pos = (POSITION)m_tree.GetItemData(node);
- if(pos == NULL)
- {
- for(HTREEITEM child = m_tree.GetChildItem(node); child; child = m_tree.GetNextSiblingItem(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;
@@ -566,9 +564,7 @@ void CPPageExternalFilters::OnDeleteType()
}
m_tree.DeleteItem(node);
- }
- else
- {
+ } else {
HTREEITEM parent = m_tree.GetParentItem(node);
POSITION pos1 = pos;
@@ -578,14 +574,11 @@ void CPPageExternalFilters::OnDeleteType()
m_tree.DeleteItem(node);
- if(!m_tree.ItemHasChildren(parent))
- {
+ 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
- {
+ } else {
f->guids.RemoveAt(pos1);
f->guids.RemoveAt(pos2);
}
@@ -595,8 +588,7 @@ void CPPageExternalFilters::OnDeleteType()
void CPPageExternalFilters::OnResetTypes()
{
- if(FilterOverride* f = GetCurFilter())
- {
+ if(FilterOverride* f = GetCurFilter()) {
f->guids.RemoveAll();
f->guids.AddTailList(&f->backup);
@@ -607,9 +599,10 @@ void CPPageExternalFilters::OnResetTypes()
void CPPageExternalFilters::OnLbnSelchangeList1()
{
- if(FilterOverride* f = GetCurFilter())
- {
- if(m_pLastSelFilter == f) return;
+ if(FilterOverride* f = GetCurFilter()) {
+ if(m_pLastSelFilter == f) {
+ return;
+ }
m_pLastSelFilter = f;
m_iLoadType = f->iLoadType;
@@ -618,14 +611,14 @@ void CPPageExternalFilters::OnLbnSelchangeList1()
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))
+ for(HTREEITEM item = m_tree.GetNextVisibleItem(dummy_item); item; item = m_tree.GetNextVisibleItem(dummy_item)) {
m_tree.DeleteItem(item);
+ }
CMapStringToPtr map;
POSITION pos = f->guids.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
POSITION tmp = pos;
CString major = GetMediaTypeName(f->guids.GetNext(pos));
CString sub = GetMediaTypeName(f->guids.GetNext(pos));
@@ -633,8 +626,11 @@ void CPPageExternalFilters::OnLbnSelchangeList1()
HTREEITEM node = NULL;
void* val = NULL;
- if(map.Lookup(major, val)) node = (HTREEITEM)val;
- else map[major] = node = m_tree.InsertItem(major);
+ 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);
@@ -643,13 +639,12 @@ void CPPageExternalFilters::OnLbnSelchangeList1()
m_tree.DeleteItem(dummy_item);
- for(HTREEITEM item = m_tree.GetFirstVisibleItem(); item; item = m_tree.GetNextVisibleItem(item))
+ 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
- {
+ } else {
m_pLastSelFilter = NULL;
m_iLoadType = FilterOverride::PREFERRED;
@@ -663,18 +658,19 @@ void CPPageExternalFilters::OnLbnSelchangeList1()
void CPPageExternalFilters::OnBnClickedRadio()
{
UpdateData();
- if(FilterOverride* f = GetCurFilter())
+ if(FilterOverride* f = GetCurFilter()) {
f->iLoadType = m_iLoadType;
+ }
}
void CPPageExternalFilters::OnEnChangeEdit1()
{
UpdateData();
- if(FilterOverride* f = GetCurFilter())
- {
+ if(FilterOverride* f = GetCurFilter()) {
DWORD dw;
- if(m_dwMerit.GetDWORD(dw))
+ if(m_dwMerit.GetDWORD(dw)) {
f->dwMerit = dw;
+ }
}
}
@@ -682,23 +678,27 @@ void CPPageExternalFilters::OnNMDblclkTree2(NMHDR *pNMHDR, LRESULT *pResult)
{
*pResult = 0;
- if(FilterOverride* f = GetCurFilter())
- {
+ if(FilterOverride* f = GetCurFilter()) {
HTREEITEM node = m_tree.GetSelectedItem();
- if(!node) return;
+ if(!node) {
+ return;
+ }
POSITION pos = (POSITION)m_tree.GetItemData(node);
- if(!pos) return;
+ if(!pos) {
+ return;
+ }
f->guids.GetNext(pos);
- if(!pos) return;
+ if(!pos) {
+ return;
+ }
CAtlArray<GUID> guids;
SetupSubTypes(guids);
CSelectMediaType dlg(guids, f->guids.GetAt(pos), this);
- if(dlg.DoModal() == IDOK)
- {
+ if(dlg.DoModal() == IDOK) {
f->guids.SetAt(pos, dlg.m_guid);
m_tree.SetItemText(node, GetMediaTypeName(dlg.m_guid));
}
@@ -710,25 +710,21 @@ void CPPageExternalFilters::OnDropFiles(HDROP hDropInfo)
SetActiveWindow();
UINT nFiles = ::DragQueryFile(hDropInfo, (UINT)-1, NULL, 0);
- for(UINT iFile = 0; iFile < nFiles; iFile++)
- {
+ 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())
- {
+ 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())
- {
+ if(fm2.m_filters.IsEmpty()) {
m_filters.SetCurSel(i);
OnLbnSelchangeList1();
}
diff --git a/src/apps/mplayerc/PPageExternalFilters.h b/src/apps/mplayerc/PPageExternalFilters.h
index a627e6111..acd7ee551 100644
--- a/src/apps/mplayerc/PPageExternalFilters.h
+++ b/src/apps/mplayerc/PPageExternalFilters.h
@@ -49,7 +49,7 @@ public:
CPPageExternalFilters();
virtual ~CPPageExternalFilters();
-// Dialog Data
+ // Dialog Data
enum { IDD = IDD_PPAGEEXTERNALFILTERS };
CCheckListBox m_filters;
diff --git a/src/apps/mplayerc/PPageFileInfoClip.cpp b/src/apps/mplayerc/PPageFileInfoClip.cpp
index 62b60d520..357e88a84 100644
--- a/src/apps/mplayerc/PPageFileInfoClip.cpp
+++ b/src/apps/mplayerc/PPageFileInfoClip.cpp
@@ -47,7 +47,9 @@ CPPageFileInfoClip::CPPageFileInfoClip(CString fn, IFilterGraph* pFG)
CPPageFileInfoClip::~CPPageFileInfoClip()
{
- if(m_hIcon) DestroyIcon(m_hIcon);
+ if(m_hIcon) {
+ DestroyIcon(m_hIcon);
+ }
}
void CPPageFileInfoClip::DoDataExchange(CDataExchange* pDX)
@@ -73,17 +75,13 @@ BOOL CPPageFileInfoClip::OnInitDialog()
{
__super::OnInitDialog();
- if(m_fn == _T(""))
- {
- BeginEnumFilters(m_pFG, pEF, pBF)
- {
+ if(m_fn == _T("")) {
+ BeginEnumFilters(m_pFG, pEF, pBF) {
CComQIPtr<IFileSourceFilter> pFSF = pBF;
- if(pFSF)
- {
+ if(pFSF) {
LPOLESTR pFN = NULL;
AM_MEDIA_TYPE mt;
- if(SUCCEEDED(pFSF->GetCurFile(&pFN, &mt)) && pFN && *pFN)
- {
+ if(SUCCEEDED(pFSF->GetCurFile(&pFN, &mt)) && pFN && *pFN) {
m_fn = CStringW(pFN);
CoTaskMemFree(pFN);
}
@@ -94,52 +92,48 @@ BOOL CPPageFileInfoClip::OnInitDialog()
}
m_hIcon = LoadIcon(m_fn, false);
- if(m_hIcon)
+ 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)
- {
+ if(i >= 0 && i < m_fn.GetLength()-1) {
m_location = m_fn.Left(i);
m_fn = m_fn.Mid(i+1);
- if(m_location.GetLength() == 2 && m_location[1] == ':')
+ if(m_location.GetLength() == 2 && m_location[1] == ':') {
m_location += '\\';
+ }
}
bool fEmpty = true;
- BeginEnumFilters(m_pFG, pEF, pBF)
- {
- if(CComQIPtr<IAMMediaContent, &IID_IAMMediaContent> pAMMC = pBF)
- {
+ 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)
- {
+ 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)
- {
+ 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)
- {
+ 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)
- {
+ 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)
- {
+ if(SUCCEEDED(pAMMC->get_Description(&bstr)) && wcslen(bstr.m_str) > 0) {
m_desc.SetWindowText(CString(bstr.m_str));
fEmpty = false;
}
- if(!fEmpty) break;
+ if(!fEmpty) {
+ break;
+ }
}
}
EndEnumFilters;
diff --git a/src/apps/mplayerc/PPageFileInfoClip.h b/src/apps/mplayerc/PPageFileInfoClip.h
index d28c5ff85..29e01cdb4 100644
--- a/src/apps/mplayerc/PPageFileInfoClip.h
+++ b/src/apps/mplayerc/PPageFileInfoClip.h
@@ -40,7 +40,7 @@ public:
CPPageFileInfoClip(CString fn, IFilterGraph* pFG);
virtual ~CPPageFileInfoClip();
-// Dialog Data
+ // Dialog Data
enum { IDD = IDD_FILEPROPCLIP };
CStatic m_icon;
diff --git a/src/apps/mplayerc/PPageFileInfoDetails.cpp b/src/apps/mplayerc/PPageFileInfoDetails.cpp
index 9b339daeb..add9ff348 100644
--- a/src/apps/mplayerc/PPageFileInfoDetails.cpp
+++ b/src/apps/mplayerc/PPageFileInfoDetails.cpp
@@ -50,7 +50,9 @@ CPPageFileInfoDetails::CPPageFileInfoDetails(CString fn, IFilterGraph* pFG, ISub
CPPageFileInfoDetails::~CPPageFileInfoDetails()
{
- if(m_hIcon) DestroyIcon(m_hIcon);
+ if(m_hIcon) {
+ DestroyIcon(m_hIcon);
+ }
}
void CPPageFileInfoDetails::DoDataExchange(CDataExchange* pDX)
@@ -73,11 +75,11 @@ END_MESSAGE_MAP()
static bool GetProperty(IFilterGraph* pFG, LPCOLESTR propName, VARIANT* vt)
{
- BeginEnumFilters(pFG, pEF, pBF)
- {
+ BeginEnumFilters(pFG, pEF, pBF) {
if(CComQIPtr<IPropertyBag> pPB = pBF)
- if(SUCCEEDED(pPB->Read(propName, vt, NULL)))
+ if(SUCCEEDED(pPB->Read(propName, vt, NULL))) {
return true;
+ }
}
EndEnumFilters;
@@ -101,17 +103,13 @@ BOOL CPPageFileInfoDetails::OnInitDialog()
{
__super::OnInitDialog();
- if(m_fn == _T(""))
- {
- BeginEnumFilters(m_pFG, pEF, pBF)
- {
+ if(m_fn == _T("")) {
+ BeginEnumFilters(m_pFG, pEF, pBF) {
CComQIPtr<IFileSourceFilter> pFSF = pBF;
- if(pFSF)
- {
+ if(pFSF) {
LPOLESTR pFN = NULL;
AM_MEDIA_TYPE mt;
- if(SUCCEEDED(pFSF->GetCurFile(&pFN, &mt)) && pFN && *pFN)
- {
+ if(SUCCEEDED(pFSF->GetCurFile(&pFN, &mt)) && pFN && *pFN) {
m_fn = CStringW(pFN);
CoTaskMemFree(pFN);
}
@@ -122,21 +120,22 @@ BOOL CPPageFileInfoDetails::OnInitDialog()
}
CString ext = m_fn.Left(m_fn.Find(_T("://"))+1).TrimRight(':');
- if(ext.IsEmpty() || !ext.CompareNoCase(_T("file")))
+ 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)
+ if(m_hIcon) {
m_icon.SetIcon(m_hIcon);
+ }
- if(!LoadType(ext, m_type))
+ if(!LoadType(ext, m_type)) {
m_type = ResStr(IDS_AG_NOT_KNOWN);
+ }
CComVariant vt;
- if(::GetProperty(m_pFG, L"CurFile.TimeCreated", &vt))
- {
- if(V_VT(&vt) == VT_UI8)
- {
+ if(::GetProperty(m_pFG, L"CurFile.TimeCreated", &vt)) {
+ if(V_VT(&vt) == VT_UI8) {
ULARGE_INTEGER uli;
uli.QuadPart = V_UI8(&vt);
@@ -150,28 +149,23 @@ BOOL CPPageFileInfoDetails::OnInitDialog()
WIN32_FIND_DATA wfd;
HANDLE hFind = FindFirstFile(m_fn, &wfd);
- if(hFind != INVALID_HANDLE_VALUE)
- {
+ if(hFind != INVALID_HANDLE_VALUE) {
FindClose(hFind);
__int64 size = (__int64(wfd.nFileSizeHigh)<<32)|wfd.nFileSizeLow;
- __int64 shortsize = size;
- CString measure = _T("B");
- if(shortsize > 10240) shortsize /= 1024, measure = _T("KB");
- if(shortsize > 10240) shortsize /= 1024, measure = _T("MB");
- if(shortsize > 10240) shortsize /= 1024, measure = _T("GB");
- m_size.Format(_T("%I64d%s (%I64d bytes)"), shortsize, measure, size);
-
- if(m_created.IsEmpty())
- {
+ const int MAX_FILE_SIZE_BUFFER = 65;
+ WCHAR szFileSize[MAX_FILE_SIZE_BUFFER];
+ StrFormatByteSizeW(size, szFileSize, sizeof(szFileSize));
+ 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)
- {
+ if(pMS && SUCCEEDED(pMS->GetDuration(&rtDur)) && rtDur > 0) {
m_time.Format(_T("%02d:%02d:%02d"),
int(rtDur/10000000/60/60),
int((rtDur/10000000/60)%60),
@@ -180,44 +174,32 @@ BOOL CPPageFileInfoDetails::OnInitDialog()
CSize wh(0, 0), arxy(0, 0);
- if(m_pCAP)
- {
+ 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)
+ } 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
- {
+ }
+ } else {
wh.SetSize(0, 0);
}
}
- if(wh.cx == 0 && wh.cy == 0)
- {
- BeginEnumFilters(m_pFG, pEF, pBF)
- {
- if(CComQIPtr<IBasicVideo> pBV = pBF)
- {
+ 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)
+ if(CComQIPtr<IBasicVideo2> pBV2 = pBF) {
pBV2->GetPreferredAspectRatio(&arxy.cx, &arxy.cy);
+ }
break;
- }
- else if(CComQIPtr<IVMRWindowlessControl> pWC = pBF)
- {
+ } else if(CComQIPtr<IVMRWindowlessControl> pWC = pBF) {
pWC->GetNativeVideoSize(&wh.cx, &wh.cy, &arxy.cx, &arxy.cy);
break;
- }
- else if(CComQIPtr<IVMRWindowlessControl9> pWC = pBF)
- {
+ } else if(CComQIPtr<IVMRWindowlessControl9> pWC = pBF) {
pWC->GetNativeVideoSize(&wh.cx, &wh.cy, &arxy.cx, &arxy.cy);
break;
}
@@ -226,15 +208,15 @@ BOOL CPPageFileInfoDetails::OnInitDialog()
}
}
- if(wh.cx > 0 && wh.cy > 0)
- {
+ if(wh.cx > 0 && wh.cy > 0) {
m_res.Format(_T("%d x %d"), wh.cx, wh.cy);
int lnko = LNKO(arxy.cx, arxy.cy);
- if(lnko > 1) arxy.cx /= lnko, arxy.cy /= lnko;
+ if(lnko > 1) {
+ arxy.cx /= lnko, arxy.cy /= lnko;
+ }
- if(arxy.cx > 0 && arxy.cy > 0 && arxy.cx*wh.cy != arxy.cy*wh.cx)
- {
+ 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;
@@ -260,43 +242,38 @@ void CPPageFileInfoDetails::InitEncoding()
{
CAtlList<CString> sl;
- BeginEnumFilters(m_pFG, pEF, pBF)
- {
+ BeginEnumFilters(m_pFG, pEF, pBF) {
CComPtr<IBaseFilter> pUSBF = GetUpStreamFilter(pBF);
- if(GetCLSID(pBF) == CLSID_NetShowSource)
- {
+ if(GetCLSID(pBF) == CLSID_NetShowSource) {
continue;
- }
- else if(GetCLSID(pUSBF) != CLSID_NetShowSource)
- {
- if(IPin* pPin = GetFirstPin(pBF, PINDIR_INPUT))
- {
+ } else if(GetCLSID(pUSBF) != CLSID_NetShowSource) {
+ if(IPin* pPin = GetFirstPin(pBF, PINDIR_INPUT)) {
CMediaType mt;
- if(FAILED(pPin->ConnectionMediaType(&mt)) || mt.majortype != MEDIATYPE_Stream)
+ if(FAILED(pPin->ConnectionMediaType(&mt)) || mt.majortype != MEDIATYPE_Stream) {
continue;
+ }
}
- if(IPin* pPin = GetFirstPin(pBF, PINDIR_OUTPUT))
- {
+ if(IPin* pPin = GetFirstPin(pBF, PINDIR_OUTPUT)) {
CMediaType mt;
- if(SUCCEEDED(pPin->ConnectionMediaType(&mt)) && mt.majortype == MEDIATYPE_Stream)
+ if(SUCCEEDED(pPin->ConnectionMediaType(&mt)) && mt.majortype == MEDIATYPE_Stream) {
continue;
+ }
}
}
- BeginEnumPins(pBF, pEP, pPin)
- {
+ BeginEnumPins(pBF, pEP, pPin) {
CMediaTypeEx mt;
PIN_DIRECTION dir;
if(FAILED(pPin->QueryDirection(&dir)) || dir != PINDIR_OUTPUT
- || FAILED(pPin->ConnectionMediaType(&mt)))
+ || FAILED(pPin->ConnectionMediaType(&mt))) {
continue;
+ }
CString str = mt.ToString();
- if(!str.IsEmpty())
- {
+ if(!str.IsEmpty()) {
sl.AddTail(mt.ToString() + CString(L" [" + GetPinName(pPin) + L"]"));
}
}
diff --git a/src/apps/mplayerc/PPageFileInfoDetails.h b/src/apps/mplayerc/PPageFileInfoDetails.h
index 0b9b419e8..672043620 100644
--- a/src/apps/mplayerc/PPageFileInfoDetails.h
+++ b/src/apps/mplayerc/PPageFileInfoDetails.h
@@ -45,7 +45,7 @@ public:
CPPageFileInfoDetails(CString fn, IFilterGraph* pFG, ISubPicAllocatorPresenter* pCAP);
virtual ~CPPageFileInfoDetails();
-// Dialog Data
+ // Dialog Data
enum { IDD = IDD_FILEPROPDETAILS };
CStatic m_icon;
diff --git a/src/apps/mplayerc/PPageFileInfoRes.cpp b/src/apps/mplayerc/PPageFileInfoRes.cpp
index 9b01bc030..773924b5d 100644
--- a/src/apps/mplayerc/PPageFileInfoRes.cpp
+++ b/src/apps/mplayerc/PPageFileInfoRes.cpp
@@ -39,7 +39,9 @@ CPPageFileInfoRes::CPPageFileInfoRes(CString fn, IFilterGraph* pFG)
CPPageFileInfoRes::~CPPageFileInfoRes()
{
- if(m_hIcon) DestroyIcon(m_hIcon);
+ if(m_hIcon) {
+ DestroyIcon(m_hIcon);
+ }
}
void CPPageFileInfoRes::DoDataExchange(CDataExchange* pDX)
@@ -63,31 +65,29 @@ BOOL CPPageFileInfoRes::OnInitDialog()
__super::OnInitDialog();
m_hIcon = LoadIcon(m_fn, false);
- if(m_hIcon)
+ 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)
+ 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)
- {
+ BeginEnumFilters(m_pFG, pEF, pBF) {
if(CComQIPtr<IDSMResourceBag> pRB = pBF)
- if(pRB && pRB->ResGetCount() > 0)
- {
- for(DWORD i = 0; i < pRB->ResGetCount(); i++)
- {
+ 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)))
- {
+ if(SUCCEEDED(pRB->ResGet(i, &name, &desc, &mime, &pData, &len, NULL))) {
CDSMResource r;
r.name = name;
r.desc = desc;
@@ -114,17 +114,17 @@ BOOL CPPageFileInfoRes::OnInitDialog()
void CPPageFileInfoRes::OnSaveAs()
{
int i = m_list.GetSelectionMark();
- if(i < 0) return;
+ 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,
_T("All files|*.*||"), this, 0);
- if(fd.DoModal() == IDOK)
- {
- if(FILE* f = _tfopen(fd.GetPathName(), _T("wb")))
- {
+ if(fd.DoModal() == IDOK) {
+ if(FILE* f = _tfopen(fd.GetPathName(), _T("wb"))) {
fwrite(r.data.GetData(), 1, r.data.GetCount(), f);
fclose(f);
}
@@ -139,7 +139,9 @@ void CPPageFileInfoRes::OnUpdateSaveAs(CCmdUI* pCmdUI)
void CPPageFileInfoRes::OnNMDblclkList1(NMHDR *pNMHDR, LRESULT *pResult)
{
int i = m_list.GetSelectionMark();
- if(i < 0) return;
+ if(i < 0) {
+ return;
+ }
CDSMResource& r = m_res.GetAt((POSITION)m_list.GetItemData(i));
diff --git a/src/apps/mplayerc/PPageFileInfoRes.h b/src/apps/mplayerc/PPageFileInfoRes.h
index 5882ff16d..f8f9bd4df 100644
--- a/src/apps/mplayerc/PPageFileInfoRes.h
+++ b/src/apps/mplayerc/PPageFileInfoRes.h
@@ -44,7 +44,7 @@ public:
CPPageFileInfoRes(CString fn, IFilterGraph* pFG); // standard constructor
virtual ~CPPageFileInfoRes();
-// Dialog Data
+ // Dialog Data
enum { IDD = IDD_FILEPROPRES };
CStatic m_icon;
diff --git a/src/apps/mplayerc/PPageFileInfoSheet.cpp b/src/apps/mplayerc/PPageFileInfoSheet.cpp
index 655e04196..54179b7f1 100644
--- a/src/apps/mplayerc/PPageFileInfoSheet.cpp
+++ b/src/apps/mplayerc/PPageFileInfoSheet.cpp
@@ -41,11 +41,9 @@ CPPageFileInfoSheet::CPPageFileInfoSheet(CString fn, CMainFrame* pMainFrame, CWn
AddPage(&m_clip);
AddPage(&m_details);
- BeginEnumFilters(pMainFrame->pGB, pEF, pBF)
- {
+ BeginEnumFilters(pMainFrame->pGB, pEF, pBF) {
if(CComQIPtr<IDSMResourceBag> pRB = pBF)
- if(pRB && pRB->ResGetCount() > 0)
- {
+ if(pRB && pRB->ResGetCount() > 0) {
AddPage(&m_res);
break;
}
@@ -75,8 +73,9 @@ BOOL CPPageFileInfoSheet::OnInitDialog()
m_fn.TrimRight('/');
int i = max(m_fn.ReverseFind('\\'), m_fn.ReverseFind('/'));
- if(i >= 0 && i < m_fn.GetLength()-1)
+ 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);
@@ -103,12 +102,10 @@ void CPPageFileInfoSheet::OnSaveAs()
OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_PATHMUSTEXIST,
_T("Text Files (*.txt)|*.txt|All Files (*.*)|*.*||"), NULL);
- if (filedlg.DoModal() == IDOK) // user has chosen a file, so
- {
+ 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))
- {
+ 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/apps/mplayerc/PPageFileMediaInfo.cpp b/src/apps/mplayerc/PPageFileMediaInfo.cpp
index 89621ab55..285109d20 100644
--- a/src/apps/mplayerc/PPageFileMediaInfo.cpp
+++ b/src/apps/mplayerc/PPageFileMediaInfo.cpp
@@ -84,20 +84,20 @@ BOOL CPPageFileMediaInfo::OnInitDialog()
{
__super::OnInitDialog();
- if(!m_pCFont) m_pCFont = DNew CFont;
- if(!m_pCFont) return TRUE;
+ if(!m_pCFont) {
+ m_pCFont = DNew CFont;
+ }
+ if(!m_pCFont) {
+ return TRUE;
+ }
- if(m_fn == _T(""))
- {
- BeginEnumFilters(m_pFG, pEF, pBF)
- {
+ if(m_fn == _T("")) {
+ BeginEnumFilters(m_pFG, pEF, pBF) {
CComQIPtr<IFileSourceFilter> pFSF = pBF;
- if(pFSF)
- {
+ if(pFSF) {
LPOLESTR pFN = NULL;
AM_MEDIA_TYPE mt;
- if(SUCCEEDED(pFSF->GetCurFile(&pFN, &mt)) && pFN && *pFN)
- {
+ if(SUCCEEDED(pFSF->GetCurFile(&pFN, &mt)) && pFN && *pFN) {
m_fn = CStringW(pFN);
CoTaskMemFree(pFN);
}
@@ -119,7 +119,9 @@ BOOL CPPageFileMediaInfo::OnInitDialog()
MI.Option(_T("Complete"));
MI_Text = MI.Inform().c_str();
MI.Close();
- if(!MI_Text.Find(_T("Unable to load"))) MI_Text = _T("");
+ if(!MI_Text.Find(_T("Unable to load"))) {
+ MI_Text = _T("");
+ }
LOGFONT lf;
memset( &lf, 0, sizeof(lf) );
@@ -140,10 +142,11 @@ BOOL CPPageFileMediaInfo::OnInitDialog()
void CPPageFileMediaInfo::OnShowWindow(BOOL bShow, UINT nStatus)
{
__super::OnShowWindow(bShow, nStatus);
- if(bShow)
+ if(bShow) {
GetParent()->GetDlgItem(IDC_BUTTON_MI)->ShowWindow(SW_SHOW);
- else
+ } else {
GetParent()->GetDlgItem(IDC_BUTTON_MI)->ShowWindow(SW_HIDE);
+ }
}
#ifndef USE_MEDIAINFO_STATIC
diff --git a/src/apps/mplayerc/PPageFileMediaInfo.h b/src/apps/mplayerc/PPageFileMediaInfo.h
index 24d522006..b1a63bdb6 100644
--- a/src/apps/mplayerc/PPageFileMediaInfo.h
+++ b/src/apps/mplayerc/PPageFileMediaInfo.h
@@ -37,7 +37,7 @@ public:
CPPageFileMediaInfo(CString fn, IFilterGraph* pFG);
virtual ~CPPageFileMediaInfo();
-// Dialog Data
+ // Dialog Data
enum { IDD = IDD_FILEMEDIAINFO };
CEdit m_mediainfo;
diff --git a/src/apps/mplayerc/PPageFormats.cpp b/src/apps/mplayerc/PPageFormats.cpp
index bf8afc85d..e4cb26116 100644
--- a/src/apps/mplayerc/PPageFormats.cpp
+++ b/src/apps/mplayerc/PPageFormats.cpp
@@ -51,8 +51,7 @@ CPPageFormats::CPPageFormats()
, m_fRtspFileExtFirst(FALSE)
, m_bInsufficientPrivileges(false)
{
- if (m_pAAR == NULL)
- {
+ if (m_pAAR == NULL) {
// Default manager (requiered at least Vista)
HRESULT hr = CoCreateInstance(CLSID_ApplicationAssociationRegistration,
NULL,
@@ -110,8 +109,9 @@ CString CPPageFormats::GetEnqueueCommand()
CString path;
TCHAR buff[_MAX_PATH];
- if(::GetModuleFileName(AfxGetInstanceHandle(), buff, _MAX_PATH) == 0)
+ if(::GetModuleFileName(AfxGetInstanceHandle(), buff, _MAX_PATH) == 0) {
return _T("");
+ }
path = buff;
return _T("\"") + path + _T("\" /add \"%1\"");
@@ -122,8 +122,9 @@ CString CPPageFormats::GetOpenCommand()
CString path;
TCHAR buff[_MAX_PATH];
- if(::GetModuleFileName(AfxGetInstanceHandle(), buff, _MAX_PATH) == 0)
+ if(::GetModuleFileName(AfxGetInstanceHandle(), buff, _MAX_PATH) == 0) {
return _T("");
+ }
path = buff;
return _T("\"") + path + _T("\" \"%1\"");
@@ -135,8 +136,7 @@ bool CPPageFormats::IsRegistered(CString ext)
BOOL bIsDefault = FALSE;
CString strProgID = _T("mplayerc") + ext;
- if (m_pAAR == NULL)
- {
+ if (m_pAAR == NULL) {
// Default manager (requires at least Vista)
hr = CoCreateInstance(CLSID_ApplicationAssociationRegistration,
NULL,
@@ -145,54 +145,51 @@ bool CPPageFormats::IsRegistered(CString ext)
(void**)&m_pAAR);
}
- if (m_pAAR)
- {
+ if (m_pAAR) {
// The Vista way
hr = m_pAAR->QueryAppIsDefault(ext, AT_FILEEXTENSION, AL_EFFECTIVE, g_strRegisteredAppName, &bIsDefault);
- }
- else
- {
+ } else {
// The 2000/XP way
CRegKey key;
TCHAR buff[256];
ULONG len = sizeof(buff)/sizeof(buff[0]);
memset(buff, 0, sizeof(buff));
- if(ERROR_SUCCESS != key.Open(HKEY_CLASSES_ROOT, ext))
+ if(ERROR_SUCCESS != key.Open(HKEY_CLASSES_ROOT, ext)) {
return false;
+ }
- if(ERROR_SUCCESS != key.QueryStringValue(NULL, buff, &len) && !CString(buff).Trim().IsEmpty())
+ if(ERROR_SUCCESS != key.QueryStringValue(NULL, buff, &len) && !CString(buff).Trim().IsEmpty()) {
return false;
+ }
bIsDefault = (buff == strProgID);
}
- if(!f_setContextFiles)
- {
+ if(!f_setContextFiles) {
CRegKey key;
TCHAR buff[_MAX_PATH];
ULONG len = sizeof(buff)/sizeof(buff[0]);
- if(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, strProgID + _T("\\shell\\open"), KEY_READ))
- {
+ 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))
+ 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)
- {
+ if (bIsDefault) {
CRegKey key;
TCHAR buff[_MAX_PATH];
ULONG len = sizeof(buff)/sizeof(buff[0]);
bIsDefault = FALSE;
- if(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, strProgID + _T("\\shell\\open\\command"), KEY_READ))
- {
+ 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))
+ if (ERROR_SUCCESS == key.QueryStringValue(NULL, buff, &len)) {
bIsDefault = (strCommand.CompareNoCase(CString(buff)) == 0);
+ }
}
}
@@ -214,8 +211,9 @@ int FileExists(const TCHAR *fileName)
{
DWORD fileAttr;
fileAttr = ::GetFileAttributes(fileName);
- if (0xFFFFFFFF == fileAttr)
+ if (0xFFFFFFFF == fileAttr) {
return false;
+ }
return true;
}
@@ -226,11 +224,9 @@ int GetIconIndex(CString ext)
int iconindex = -1;
GetIconIndexFunc _getIconIndexFunc;
HINSTANCE mpciconlib = LoadLibrary(_T("mpciconlib.dll"));
- if(mpciconlib)
- {
+ if(mpciconlib) {
_getIconIndexFunc = (GetIconIndexFunc) GetProcAddress(mpciconlib, "get_icon_index");
- if(_getIconIndexFunc)
- {
+ if(_getIconIndexFunc) {
iconindex = _getIconIndexFunc(ext);
}
FreeLibrary(mpciconlib);
@@ -245,10 +241,10 @@ bool CPPageFormats::RegisterExt(CString ext, CString strLabel, bool fRegister)
bool bSetValue;
CString strProgID = _T("mplayerc") + ext;
- if(!fRegister)
- {
- if(fRegister != IsRegistered(ext))
+ if(!fRegister) {
+ if(fRegister != IsRegistered(ext)) {
SetFileAssociation (ext, strProgID, fRegister);
+ }
key.Attach(HKEY_CLASSES_ROOT);
key.RecurseDeleteKey(strProgID);
return(true);
@@ -257,91 +253,108 @@ bool CPPageFormats::RegisterExt(CString ext, CString strLabel, bool fRegister)
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);
+ 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(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
- {
+ 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);
+ if(ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strProgID + _T("\\shell\\open"))) {
+ return(false);
}
- else
- {
- if(ERROR_SUCCESS != key.SetStringValue(NULL, _T(""))) 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_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(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)
- {
+ if(f_setAssociatedWithIcon) {
CString AppIcon = _T("");
TCHAR buff[_MAX_PATH];
CString mpciconlib = GetProgramDir() + _T("\\mpciconlib.dll");
- if(FileExists(mpciconlib))
- {
+ 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))
- {
+ 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)))
- {
+ 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
- {
+ 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))
+ if(fRegister != IsRegistered(ext)) {
SetFileAssociation (ext, strProgID, fRegister);
+ }
return(true);
}
-static struct
-{
+static struct {
LPCSTR verb, cmd;
UINT action;
-} handlers[] =
-{
+} handlers[] = {
{"VideoFiles", " %1", IDS_AUTOPLAY_PLAYVIDEO},
{"MusicFiles", " %1", IDS_AUTOPLAY_PLAYMUSIC},
{"CDAudio", " %1 /cd", IDS_AUTOPLAY_PLAYAUDIOCD},
@@ -351,26 +364,35 @@ static struct
void CPPageFormats::AddAutoPlayToRegistry(autoplay_t ap, bool fRegister)
{
TCHAR buff[_MAX_PATH];
- if(::GetModuleFileName(AfxGetInstanceHandle(), buff, _MAX_PATH) == 0) return;
+ if(::GetModuleFileName(AfxGetInstanceHandle(), buff, _MAX_PATH) == 0) {
+ return;
+ }
CString exe = buff;
int i = (int)ap;
- if(i < 0 || i >= countof(handlers)) return;
+ if(i < 0 || i >= countof(handlers)) {
+ return;
+ }
CRegKey key;
- if(fRegister)
- {
- if(ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, _T("MediaPlayerClassic.Autorun"))) return;
+ 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;
+ 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;
+ 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"));
@@ -379,14 +401,16 @@ void CPPageFormats::AddAutoPlayToRegistry(autoplay_t ap, bool fRegister)
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;
+ 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
- {
+ } else {
if(ERROR_SUCCESS != key.Create(HKEY_LOCAL_MACHINE,
- CString(CStringA("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\AutoplayHandlers\\EventHandlers\\Play") + handlers[i].verb + "OnArrival"))) return;
+ 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();
}
@@ -396,31 +420,43 @@ bool CPPageFormats::IsAutoPlayRegistered(autoplay_t ap)
{
ULONG len;
TCHAR buff[_MAX_PATH];
- if(::GetModuleFileName(AfxGetInstanceHandle(), buff, _MAX_PATH) == 0) return(false);
+ if(::GetModuleFileName(AfxGetInstanceHandle(), buff, _MAX_PATH) == 0) {
+ return(false);
+ }
CString exe = buff;
int i = (int)ap;
- if(i < 0 || i >= countof(handlers)) return(false);
+ 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);
+ KEY_READ)) {
+ return(false);
+ }
len = countof(buff);
if(ERROR_SUCCESS != key.QueryStringValue(
CString(_T("MPCPlay")) + handlers[i].verb + _T("OnArrival"),
- buff, &len)) return(false);
+ 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);
+ KEY_READ)) {
+ return(false);
+ }
len = countof(buff);
- if(ERROR_SUCCESS != key.QueryStringValue(NULL, buff, &len))
+ if(ERROR_SUCCESS != key.QueryStringValue(NULL, buff, &len)) {
return(false);
- if(_tcsnicmp(_T("\"") + exe, buff, exe.GetLength() + 1))
+ }
+ if(_tcsnicmp(_T("\"") + exe, buff, exe.GetLength() + 1)) {
return(false);
+ }
key.Close();
return(true);
@@ -428,7 +464,9 @@ bool CPPageFormats::IsAutoPlayRegistered(autoplay_t ap)
void CPPageFormats::SetListItemState(int nItem)
{
- if(nItem < 0) return;
+ if(nItem < 0) {
+ return;
+ }
CString str = AfxGetAppSettings().m_Formats[(int)m_list.GetItemData(nItem)].GetExtsWithPeriod();
@@ -438,10 +476,13 @@ void CPPageFormats::SetListItemState(int nItem)
int cnt = 0;
POSITION pos = exts.GetHeadPosition();
- while(pos) if(IsRegistered(exts.GetNext(pos))) cnt++;
+ while(pos) if(IsRegistered(exts.GetNext(pos))) {
+ cnt++;
+ }
- if (cnt != 0)
+ if (cnt != 0) {
cnt = (cnt == (int)exts.GetCount() ? 1 : 2);
+ }
SetChecked(nItem, cnt);
}
@@ -477,8 +518,7 @@ BOOL CPPageFormats::OnInitDialog()
CMediaFormats& mf = AfxGetAppSettings().m_Formats;
mf.UpdateData(FALSE);
- for(int i = 0; i < (int)mf.GetCount(); i++)
- {
+ for(int i = 0; i < (int)mf.GetCount(); i++) {
CString label;
label.Format (_T("%s (%s)"), mf[i].GetLabel(), mf[i].GetExts());
@@ -492,7 +532,7 @@ BOOL CPPageFormats::OnInitDialog()
e == ShockWave ? _T("ShockWave") : _T("-"));
}
-// m_list.SetColumnWidth(COL_CATEGORY, LVSCW_AUTOSIZE);
+ // m_list.SetColumnWidth(COL_CATEGORY, LVSCW_AUTOSIZE);
m_list.SetColumnWidth(COL_ENGINE, LVSCW_AUTOSIZE_USEHEADER);
m_list.SetSelectionMark(0);
@@ -509,8 +549,7 @@ BOOL CPPageFormats::OnInitDialog()
f_setContextFiles = 0;
- for(int i = 0; i < m_list.GetItemCount(); i++)
- {
+ for(int i = 0; i < m_list.GetItemCount(); i++) {
SetListItemState(i);
}
m_fContextFiles.SetCheck(f_setContextFiles);
@@ -523,8 +562,7 @@ BOOL CPPageFormats::OnInitDialog()
CreateToolTip();
- if (IsVistaOrAbove() && !IsUserAnAdmin())
- {
+ if (IsVistaOrAbove() && !IsUserAnAdmin()) {
GetDlgItem(IDC_BUTTON1)->ShowWindow (SW_HIDE);
GetDlgItem(IDC_BUTTON3)->ShowWindow (SW_HIDE);
GetDlgItem(IDC_BUTTON4)->ShowWindow (SW_HIDE);
@@ -542,9 +580,9 @@ BOOL CPPageFormats::OnInitDialog()
GetDlgItem(IDC_BUTTON5)->SendMessage (BCM_SETSHIELD, 0, 1);
m_bInsufficientPrivileges = true;
- }
- else
+ } else {
GetDlgItem(IDC_BUTTON5)->ShowWindow (SW_HIDE);
+ }
CRegKey key;
@@ -552,11 +590,11 @@ BOOL CPPageFormats::OnInitDialog()
ULONG len = sizeof(buff)/sizeof(buff[0]);
int fContextDir = 0;
- if(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("Directory\\shell\\mplayerc.play\\command"), KEY_READ))
- {
+ if(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("Directory\\shell\\mplayerc.play\\command"), KEY_READ)) {
CString strCommand = GetOpenCommand();
- if (ERROR_SUCCESS == key.QueryStringValue(NULL, buff, &len))
+ if (ERROR_SUCCESS == key.QueryStringValue(NULL, buff, &len)) {
fContextDir = (strCommand.CompareNoCase(CString(buff)) == 0);
+ }
}
m_fContextDir.SetCheck(fContextDir);
m_fAssociatedWithIcons.SetCheck(s.fAssociatedWithIcons);
@@ -575,8 +613,7 @@ BOOL CPPageFormats::SetFileAssociation(CString strExt, CString strProgID, bool f
ULONG len = sizeof(buff)/sizeof(buff[0]);
memset(buff, 0, sizeof(buff));
- if (m_pAAR == NULL)
- {
+ if (m_pAAR == NULL) {
// Default manager (requiered at least Vista)
HRESULT hr = CoCreateInstance(CLSID_ApplicationAssociationRegistration,
NULL,
@@ -586,21 +623,21 @@ BOOL CPPageFormats::SetFileAssociation(CString strExt, CString strProgID, bool f
UNUSED_ALWAYS(hr);
}
- if (m_pAAR)
- {
+ if (m_pAAR) {
// The Vista way
CString strNewApp;
- if (fRegister)
- {
+ if (fRegister) {
// Create non existing file type
- if(ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strExt)) return(false);
+ 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))
+ 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);
@@ -620,34 +657,35 @@ BOOL CPPageFormats::SetFileAssociation(CString strExt, CString strProgID, bool f
CoTaskMemFree (pszCurrentAssociation);
}
strNewApp = g_strRegisteredAppName;
- }
- else
- {
- if(ERROR_SUCCESS != key.Open(HKEY_CLASSES_ROOT, strProgID))
+ } else {
+ if(ERROR_SUCCESS != key.Open(HKEY_CLASSES_ROOT, strProgID)) {
return(false);
+ }
- if(ERROR_SUCCESS == key.QueryStringValue(g_strOldAssoc, buff, &len))
+ 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
- {
+ } else {
// The 2000/XP way
- if (fRegister)
- {
+ if (fRegister) {
// Set new association
- if(ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strExt))
+ if(ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strExt)) {
return(false);
+ }
len = sizeof(buff)/sizeof(buff[0]);
memset(buff, 0, sizeof(buff));
- if(ERROR_SUCCESS == key.QueryStringValue(NULL, buff, &len) && !CString(buff).Trim().IsEmpty())
+ if(ERROR_SUCCESS == key.QueryStringValue(NULL, buff, &len) && !CString(buff).Trim().IsEmpty()) {
extoldreg = buff;
- if(ERROR_SUCCESS != key.SetStringValue(NULL, strProgID)) return(false);
+ }
+ if(ERROR_SUCCESS != key.SetStringValue(NULL, strProgID)) {
+ return(false);
+ }
// Get current icon for file type
/*
@@ -664,28 +702,30 @@ BOOL CPPageFormats::SetFileAssociation(CString strExt, CString strProgID, bool f
*/
// Save old association
- if(ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strProgID))
+ 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
- {
+ } else {
// Get previous association
len = sizeof(buff)/sizeof(buff[0]);
memset(buff, 0, sizeof(buff));
- if(ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strProgID))
+ if(ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strProgID)) {
return(false);
- if(ERROR_SUCCESS == key.QueryStringValue(g_strOldAssoc, buff, &len) && !CString(buff).Trim().IsEmpty())
+ }
+ 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))
+ if(ERROR_SUCCESS != key.Create(HKEY_CLASSES_ROOT, strExt)) {
return(false);
+ }
key.SetStringValue(NULL, extoldreg);
}
@@ -701,9 +741,10 @@ BOOL CPPageFormats::OnApply()
{
int i = m_list.GetSelectionMark();
- if(i >= 0) i = (int)m_list.GetItemData(i);
- if(i >= 0)
- {
+ 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();
@@ -716,24 +757,22 @@ BOOL CPPageFormats::OnApply()
CString AppIcon = _T("");
TCHAR buff[_MAX_PATH];
- if(::GetModuleFileName(AfxGetInstanceHandle(), buff, _MAX_PATH))
- {
+ if(::GetModuleFileName(AfxGetInstanceHandle(), buff, _MAX_PATH)) {
AppIcon = buff;
AppIcon = "\""+AppIcon+"\"";
AppIcon += _T(",0");
}
- if (m_pAAR)
- {
+ if (m_pAAR) {
// Register MPC for the windows "Default application" manager
CRegKey key;
- if(ERROR_SUCCESS == key.Open(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\RegisteredApplications")))
- {
+ 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))
+ 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);
@@ -745,44 +784,39 @@ BOOL CPPageFormats::OnApply()
f_setContextFiles = m_fContextFiles.GetCheck();
f_setAssociatedWithIcon = m_fAssociatedWithIcons.GetCheck();
- for(int i = 0; i < m_list.GetItemCount(); i++)
- {
+ for(int i = 0; i < m_list.GetItemCount(); i++) {
int iChecked = GetChecked(i);
- if(iChecked == 2) continue;
+ if(iChecked == 2) {
+ continue;
+ }
CAtlList<CString> exts;
Explode(mf[(int)m_list.GetItemData(i)].GetExtsWithPeriod(), exts, ' ');
POSITION pos = exts.GetHeadPosition();
- while(pos)
+ while(pos) {
RegisterExt(exts.GetNext(pos), mf[(int)m_list.GetItemData(i)].GetLabel(), !!iChecked);
+ }
}
CRegKey key;
- if(m_fContextDir.GetCheck())
- {
- if(ERROR_SUCCESS == key.Create(HKEY_CLASSES_ROOT, _T("Directory\\shell\\mplayerc.enqueue")))
- {
+ if(m_fContextDir.GetCheck()) {
+ if(ERROR_SUCCESS == key.Create(HKEY_CLASSES_ROOT, _T("Directory\\shell\\mplayerc.enqueue"))) {
key.SetStringValue(NULL, ResStr(IDS_ADD_TO_PLAYLIST));
}
- if(ERROR_SUCCESS == key.Create(HKEY_CLASSES_ROOT, _T("Directory\\shell\\mplayerc.enqueue\\command")))
- {
+ if(ERROR_SUCCESS == key.Create(HKEY_CLASSES_ROOT, _T("Directory\\shell\\mplayerc.enqueue\\command"))) {
key.SetStringValue(NULL, GetEnqueueCommand());
}
- if(ERROR_SUCCESS == key.Create(HKEY_CLASSES_ROOT, _T("Directory\\shell\\mplayerc.play")))
- {
+ if(ERROR_SUCCESS == key.Create(HKEY_CLASSES_ROOT, _T("Directory\\shell\\mplayerc.play"))) {
key.SetStringValue(NULL, ResStr(IDS_OPEN_WITH_MPC));
}
- if(ERROR_SUCCESS == key.Create(HKEY_CLASSES_ROOT, _T("Directory\\shell\\mplayerc.play\\command")))
- {
+ if(ERROR_SUCCESS == key.Create(HKEY_CLASSES_ROOT, _T("Directory\\shell\\mplayerc.play\\command"))) {
key.SetStringValue(NULL, GetOpenCommand());
}
- }
- else
- {
+ } else {
key.Attach(HKEY_CLASSES_ROOT);
key.RecurseDeleteKey(_T("Directory\\shell\\mplayerc.enqueue"));
key.RecurseDeleteKey(_T("Directory\\shell\\mplayerc.play"));
@@ -810,16 +844,13 @@ void CPPageFormats::OnNMClickList1(NMHDR* pNMHDR, LRESULT* pResult)
{
LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)pNMHDR;
- if(lpnmlv->iItem >= 0 && lpnmlv->iSubItem == COL_CATEGORY)
- {
+ 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)
+ if(r.PtInRect(lpnmlv->ptAction)) {
+ if (m_bInsufficientPrivileges) {
MessageBox (ResStr (IDS_CANNOT_CHANGE_FORMAT));
- else
- {
+ } else {
SetChecked(lpnmlv->iItem, (GetChecked(lpnmlv->iItem)&1) == 0 ? 1 : 0);
SetModified();
}
@@ -834,8 +865,7 @@ void CPPageFormats::OnLvnItemchangedList1(NMHDR *pNMHDR, LRESULT *pResult)
LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
if(pNMLV->iItem >= 0 && pNMLV->iSubItem == COL_CATEGORY
- && (pNMLV->uChanged&LVIF_STATE) && (pNMLV->uNewState&LVIS_SELECTED))
- {
+ && (pNMLV->uChanged&LVIF_STATE) && (pNMLV->uNewState&LVIS_SELECTED)) {
m_exts = AfxGetAppSettings().m_Formats[(int)m_list.GetItemData(pNMLV->iItem)].GetExtsWithPeriod();
UpdateData(FALSE);
}
@@ -850,11 +880,11 @@ void CPPageFormats::OnBeginlabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
*pResult = FALSE;
- if(pItem->iItem < 0)
+ if(pItem->iItem < 0) {
return;
+ }
- if(pItem->iSubItem == COL_ENGINE)
- {
+ if(pItem->iSubItem == COL_ENGINE) {
*pResult = TRUE;
}
}
@@ -866,16 +896,16 @@ void CPPageFormats::OnDolabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
*pResult = FALSE;
- if(pItem->iItem < 0)
+ if(pItem->iItem < 0) {
return;
+ }
CMediaFormatCategory& mfc = AfxGetAppSettings().m_Formats[m_list.GetItemData(pItem->iItem)];
CAtlList<CString> sl;
int nSel = -1;
- if(pItem->iSubItem == COL_ENGINE)
- {
+ if(pItem->iSubItem == COL_ENGINE) {
sl.AddTail(_T("DirectShow"));
sl.AddTail(_T("RealMedia"));
sl.AddTail(_T("QuickTime"));
@@ -896,29 +926,30 @@ void CPPageFormats::OnEndlabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
*pResult = FALSE;
- if(!m_list.m_fInPlaceDirty)
+ if(!m_list.m_fInPlaceDirty) {
return;
+ }
- if(pItem->iItem < 0)
+ if(pItem->iItem < 0) {
return;
+ }
CMediaFormatCategory& mfc = AfxGetAppSettings().m_Formats[m_list.GetItemData(pItem->iItem)];
- if(pItem->iSubItem == COL_ENGINE && pItem->lParam >= 0)
- {
+ 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)
+ if(*pResult) {
SetModified();
+ }
}
void CPPageFormats::OnBnClickedButton1()
{
- for(int i = 0, j = m_list.GetItemCount(); i < j; i++)
- {
+ for(int i = 0, j = m_list.GetItemCount(); i < j; i++) {
SetChecked(i, 1);
}
@@ -934,10 +965,8 @@ 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(ResStr(IDS_AG_PLAYLIST_FILE)))
- {
+ for(int i = 0, j = m_list.GetItemCount(); i < j; i++) {
+ if(!mf[m_list.GetItemData(i)].GetLabel().CompareNoCase(ResStr(IDS_AG_PLAYLIST_FILE))) {
SetChecked(i, 0);
continue;
}
@@ -956,8 +985,7 @@ void CPPageFormats::OnBnClickedButton13()
{
CMediaFormats& mf = AfxGetAppSettings().m_Formats;
- for(int i = 0, j = m_list.GetItemCount(); i < j; i++)
- {
+ for(int i = 0, j = m_list.GetItemCount(); i < j; i++) {
SetChecked(i, mf[(int)m_list.GetItemData(i)].IsAudioOnly()?1:0);
}
@@ -979,14 +1007,17 @@ void CPPageFormats::OnBnVistaModify()
AfxGetMyApp()->RunAsAdministrator (strApp, strCmd, true);
- for(int i = 0; i < m_list.GetItemCount(); i++)
+ for(int i = 0; i < m_list.GetItemCount(); i++) {
SetListItemState(i);
+ }
}
void CPPageFormats::OnBnClickedButton12()
{
int i = m_list.GetSelectionMark();
- if(i < 0) return;
+ if(i < 0) {
+ return;
+ }
i = (int)m_list.GetItemData(i);
CMediaFormats& mf = AfxGetAppSettings().m_Formats;
mf[i].RestoreDefaultExts();
@@ -1001,7 +1032,9 @@ void CPPageFormats::OnBnClickedButton11()
{
UpdateData();
int i = m_list.GetSelectionMark();
- if(i < 0) return;
+ if(i < 0) {
+ return;
+ }
i = (int)m_list.GetItemData(i);
CMediaFormats& mf = AfxGetAppSettings().m_Formats;
mf[i].SetExts(m_exts);
@@ -1015,8 +1048,7 @@ void CPPageFormats::OnBnClickedButton11()
void CPPageFormats::OnUpdateButtonDefault(CCmdUI* pCmdUI)
{
int i = m_list.GetSelectionMark();
- if(i < 0)
- {
+ if(i < 0) {
pCmdUI->Enable(FALSE);
return;
}
@@ -1033,8 +1065,7 @@ void CPPageFormats::OnUpdateButtonDefault(CCmdUI* pCmdUI)
void CPPageFormats::OnUpdateButtonSet(CCmdUI* pCmdUI)
{
int i = m_list.GetSelectionMark();
- if(i < 0)
- {
+ if(i < 0) {
pCmdUI->Enable(FALSE);
return;
}
diff --git a/src/apps/mplayerc/PPageFormats.h b/src/apps/mplayerc/PPageFormats.h
index 2e51b1302..10438a33c 100644
--- a/src/apps/mplayerc/PPageFormats.h
+++ b/src/apps/mplayerc/PPageFormats.h
@@ -69,7 +69,7 @@ public:
int m_iRtspHandler;
BOOL m_fRtspFileExtFirst;
-// Dialog Data
+ // Dialog Data
enum { IDD = IDD_PPAGEFORMATS };
protected:
diff --git a/src/apps/mplayerc/PPageFullscreen.cpp b/src/apps/mplayerc/PPageFullscreen.cpp
index b74adf5b8..7f30215d3 100644
--- a/src/apps/mplayerc/PPageFullscreen.cpp
+++ b/src/apps/mplayerc/PPageFullscreen.cpp
@@ -110,18 +110,15 @@ BOOL CPPageFullscreen::OnInitDialog()
m_iMonitorTypeCtrl.AddString(ResStr(IDS_FULLSCREENMONITOR_CURRENT));
m_MonitorDisplayNames.Add(_T("Current"));
- if(m_f_hmonitor == _T("Current"))
- {
+ if(m_f_hmonitor == _T("Current")) {
m_iMonitorType = m_iMonitorTypeCtrl.GetCount()-1;
}
- for ( int i = 0; i < monitors.GetCount(); i++ )
- {
+ for ( int i = 0; i < monitors.GetCount(); i++ ) {
monitor = monitors.GetMonitor( i );
monitor.GetName(str);
- if(monitor.IsMonitor())
- {
+ if(monitor.IsMonitor()) {
DISPLAY_DEVICE displayDevice;
ZeroMemory(&displayDevice, sizeof(displayDevice));
displayDevice.cb = sizeof(displayDevice);
@@ -130,19 +127,15 @@ BOOL CPPageFullscreen::OnInitDialog()
m_iMonitorTypeCtrl.AddString(str+_T(" - ")+displayDevice.DeviceString);
m_MonitorDisplayNames.Add(str);
- if(m_f_hmonitor == str && m_iMonitorType == 0)
- {
+ if(m_f_hmonitor == str && m_iMonitorType == 0) {
m_iMonitorType = m_iMonitorTypeCtrl.GetCount()-1;
}
}
}
- if(m_iMonitorTypeCtrl.GetCount() > 2)
- {
+ if(m_iMonitorTypeCtrl.GetCount() > 2) {
GetDlgItem(IDC_COMBO1)->EnableWindow(TRUE);
- }
- else
- {
+ } else {
m_iMonitorType = 0;
GetDlgItem(IDC_COMBO1)->EnableWindow(FALSE);
}
@@ -167,20 +160,25 @@ BOOL CPPageFullscreen::OnApply()
int iSel_29 = m_dispmode29d97combo.GetCurSel();
m_AutoChangeFullscrRes.bEnabled = !!m_fSetFullscreenRes;
- if (m_AutoChangeFullscrRes.bEnabled)
- {
- if(iSel_24 >= 0 && iSel_24 < m_dms.GetCount())
+ if (m_AutoChangeFullscrRes.bEnabled) {
+ if(iSel_24 >= 0 && iSel_24 < m_dms.GetCount()) {
m_AutoChangeFullscrRes.dmFullscreenRes24Hz = m_dms[m_dispmode24combo.GetCurSel()];
- if(iSel_25 >= 0 && iSel_25 < m_dms.GetCount())
+ }
+ if(iSel_25 >= 0 && iSel_25 < m_dms.GetCount()) {
m_AutoChangeFullscrRes.dmFullscreenRes25Hz = m_dms[m_dispmode25combo.GetCurSel()];
- if(iSel_30 >= 0 && iSel_30 < m_dms.GetCount())
+ }
+ if(iSel_30 >= 0 && iSel_30 < m_dms.GetCount()) {
m_AutoChangeFullscrRes.dmFullscreenRes30Hz = m_dms[m_dispmode30combo.GetCurSel()];
- if(iSel_Other >= 0 && iSel_Other < m_dms.GetCount())
+ }
+ if(iSel_Other >= 0 && iSel_Other < m_dms.GetCount()) {
m_AutoChangeFullscrRes.dmFullscreenResOther = m_dms[m_dispmodeOthercombo.GetCurSel()];
- if(iSel_23 >= 0 && iSel_23 < m_dms.GetCount())
+ }
+ if(iSel_23 >= 0 && iSel_23 < m_dms.GetCount()) {
m_AutoChangeFullscrRes.dmFullscreenRes23d976Hz = m_dms[m_dispmode23d976combo.GetCurSel()];
- if(iSel_29 >= 0 && iSel_29 < m_dms.GetCount())
+ }
+ if(iSel_29 >= 0 && iSel_29 < m_dms.GetCount()) {
m_AutoChangeFullscrRes.dmFullscreenRes29d97Hz = m_dms[m_dispmode29d97combo.GetCurSel()];
+ }
}
m_AutoChangeFullscrRes.bApplyDefault = m_fSetDefault;
s.AutoChangeFullscrRes = m_AutoChangeFullscrRes;
@@ -239,7 +237,9 @@ void CPPageFullscreen::OnUpdateFullScrCombo()
{
CMonitors monitors;
m_f_hmonitor = m_MonitorDisplayNames[m_iMonitorTypeCtrl.GetCurSel()];
- if(AfxGetAppSettings().strFullScreenMonitor != m_f_hmonitor) m_AutoChangeFullscrRes.bEnabled = false;
+ if(AfxGetAppSettings().strFullScreenMonitor != m_f_hmonitor) {
+ m_AutoChangeFullscrRes.bEnabled = false;
+ }
ModesUpdate();
SetModified();
}
@@ -263,8 +263,7 @@ void CPPageFullscreen::ModesUpdate()
dmtoset23 = m_AutoChangeFullscrRes.dmFullscreenRes23d976Hz,
dmtoset29 = m_AutoChangeFullscrRes.dmFullscreenRes29d97Hz;
- if(!m_AutoChangeFullscrRes.bEnabled)
- {
+ if(!m_AutoChangeFullscrRes.bEnabled) {
GetCurDispMode(dmtoset24, m_f_hmonitor);
dmtoset29 = dmtoset23 = dmtosetOther = dmtoset30 = dmtoset25 = dmtoset24;
}
@@ -278,20 +277,31 @@ void CPPageFullscreen::ModesUpdate()
ComboBox_ResetContent(m_dispmode29d97combo);
m_dms.RemoveAll();
- for(int i = 0, j = 0, ModeExist = true; ; i++)
- {
+ for(int i = 0, j = 0, ModeExist = true; ; i++) {
ModeExist = GetDispMode(i, dm, m_f_hmonitor);
- if (!ModeExist) break;
- if(dm.bpp <= 8) continue;
+ if (!ModeExist) {
+ break;
+ }
+ if(dm.bpp <= 8) {
+ continue;
+ }
//skip doubles (check previous only)
if (j>0 && (dm.bpp == m_dms[j-1].bpp && dm.dmDisplayFlags == m_dms[j-1].dmDisplayFlags
&& dm.freq == m_dms[j-1].freq && dm.fValid == m_dms[j-1].fValid
- && dm.size == m_dms[j-1].size)) continue;
+ && dm.size == m_dms[j-1].size)) {
+ continue;
+ }
m_dms.Add(dm);
str.Format(_T("%dx%d %dbpp %d") + ResStr(IDS_HZ), dm.size.cx, dm.size.cy, dm.bpp, dm.freq);
- if (dm.dmDisplayFlags == DM_INTERLACED) str+=_T(" ")+ ResStr(IDS_INTERLACED);
- if (dm.freq == 23) str+=_T(" (23.976)");
- if (dm.freq == 59) str+=_T(" (NTSC)");
+ if (dm.dmDisplayFlags == DM_INTERLACED) {
+ str+=_T(" ")+ ResStr(IDS_INTERLACED);
+ }
+ if (dm.freq == 23) {
+ str+=_T(" (23.976)");
+ }
+ if (dm.freq == 59) {
+ str+=_T(" (NTSC)");
+ }
m_dispmode24combo.AddString(str);
m_dispmode25combo.AddString(str);
@@ -301,17 +311,29 @@ void CPPageFullscreen::ModesUpdate()
m_dispmode29d97combo.AddString(str);
if(iSel_24 < 0 && dmtoset24.fValid && dm.size == dmtoset24.size
- && dm.bpp == dmtoset24.bpp && dm.freq == dmtoset24.freq) iSel_24 = j;
+ && dm.bpp == dmtoset24.bpp && dm.freq == dmtoset24.freq) {
+ iSel_24 = j;
+ }
if(iSel_25 < 0 && dmtoset25.fValid && dm.size == dmtoset25.size
- && dm.bpp == dmtoset25.bpp && dm.freq == dmtoset25.freq) iSel_25 = j;
+ && dm.bpp == dmtoset25.bpp && dm.freq == dmtoset25.freq) {
+ iSel_25 = j;
+ }
if(iSel_30 < 0 && dmtoset30.fValid && dm.size == dmtoset30.size
- && dm.bpp == dmtoset30.bpp && dm.freq == dmtoset30.freq) iSel_30 = j;
+ && dm.bpp == dmtoset30.bpp && dm.freq == dmtoset30.freq) {
+ iSel_30 = j;
+ }
if(iSel_Other < 0 && dmtosetOther.fValid && dm.size == dmtosetOther.size
- && dm.bpp == dmtosetOther.bpp && dm.freq == dmtosetOther.freq) iSel_Other = j;
+ && dm.bpp == dmtosetOther.bpp && dm.freq == dmtosetOther.freq) {
+ iSel_Other = j;
+ }
if(iSel_23 < 0 && dmtoset23.fValid && dm.size == dmtoset23.size
- && dm.bpp == dmtoset23.bpp && dm.freq == dmtoset23.freq) iSel_23 = j;
+ && dm.bpp == dmtoset23.bpp && dm.freq == dmtoset23.freq) {
+ iSel_23 = j;
+ }
if(iSel_29 < 0 && dmtoset29.fValid && dm.size == dmtoset29.size
- && dm.bpp == dmtoset29.bpp && dm.freq == dmtoset29.freq) iSel_29 = j;
+ && dm.bpp == dmtoset29.bpp && dm.freq == dmtoset29.freq) {
+ iSel_29 = j;
+ }
j++;
}
m_dispmode24combo.SetCurSel(iSel_24);
diff --git a/src/apps/mplayerc/PPageFullscreen.h b/src/apps/mplayerc/PPageFullscreen.h
index 8edc45c9d..7710db0fa 100644
--- a/src/apps/mplayerc/PPageFullscreen.h
+++ b/src/apps/mplayerc/PPageFullscreen.h
@@ -31,7 +31,7 @@ class CPPageFullscreen : public CPPageBase
{
DECLARE_DYNAMIC(CPPageFullscreen)
-// private:
+ // private:
CAtlArray<dispmode> m_dms;
CStringArray m_MonitorDisplayNames;
@@ -60,7 +60,7 @@ public:
CSpinButtonCtrl m_nTimeOutCtrl;
BOOL m_fRestoreResAfterExit;
-// Dialog Data
+ // Dialog Data
enum { IDD = IDD_PPAGEFULLSCREEN };
protected:
diff --git a/src/apps/mplayerc/PPageInternalFilters.cpp b/src/apps/mplayerc/PPageInternalFilters.cpp
index 827d7384b..e58390ea3 100644
--- a/src/apps/mplayerc/PPageInternalFilters.cpp
+++ b/src/apps/mplayerc/PPageInternalFilters.cpp
@@ -29,16 +29,14 @@
#include "internal_filter_config.h"
-static struct filter_t
-{
+static struct filter_t {
LPCTSTR label;
int type;
int flag;
UINT nHintID;
CUnknown* (WINAPI * CreateInstance)(LPUNKNOWN lpunk, HRESULT* phr);
}
-s_filters[] =
-{
+s_filters[] = {
#if INTERNAL_SOURCEFILTER_AVI
{_T("AVI"), SOURCE_FILTER, SRC_AVI, IDS_SRC_AVI, NULL},
#endif
@@ -216,7 +214,9 @@ INT_PTR CPPageInternalFiltersListBox::OnToolHitTest(CPoint point, TOOLINFO* pTI)
{
BOOL b = FALSE;
int row = ItemFromPoint(point, b);
- if(row < 0) return -1;
+ if(row < 0) {
+ return -1;
+ }
CRect r;
GetItemRect(row, r);
@@ -239,7 +239,9 @@ BOOL CPPageInternalFiltersListBox::OnToolTipNotify(UINT id, NMHDR* pNMHDR, LRESU
TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR;
filter_t* f = (filter_t*)GetItemDataPtr(pNMHDR->idFrom);
- if(f->nHintID == 0) return FALSE;
+ if(f->nHintID == 0) {
+ return FALSE;
+ }
::SendMessage(pNMHDR->hwndFrom, TTM_SETMAXTIPWIDTH, 0, (LPARAM)(INT)1000);
@@ -247,8 +249,9 @@ BOOL CPPageInternalFiltersListBox::OnToolTipNotify(UINT id, NMHDR* pNMHDR, LRESU
m_strTipTextW = CString(MAKEINTRESOURCE(f->nHintID));
- if(pNMHDR->code == TTN_NEEDTEXTW) //?possible check is not needed
+ if(pNMHDR->code == TTN_NEEDTEXTW) { //?possible check is not needed
pTTTW->lpszText = (LPWSTR)(LPCWSTR)m_strTipTextW;
+ }
*pResult = 0;
@@ -261,10 +264,8 @@ void CPPageInternalFiltersListBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
CFont* pOldFont = NULL;
- if((lpDrawItemStruct->itemData != 0) && ((filter_t*)lpDrawItemStruct->itemData)->CreateInstance)
- {
- if(!(HFONT)m_bold)
- {
+ if((lpDrawItemStruct->itemData != 0) && ((filter_t*)lpDrawItemStruct->itemData)->CreateInstance) {
+ if(!(HFONT)m_bold) {
CFont* pFont = pDC->GetCurrentFont();
LOGFONT lf;
@@ -274,16 +275,14 @@ void CPPageInternalFiltersListBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
m_bold.CreateFontIndirect(&lf);
}
- if((HFONT)m_bold)
- {
+ if((HFONT)m_bold) {
pOldFont = pDC->SelectObject(&m_bold);
}
}
__super::DrawItem(lpDrawItemStruct);
- if(pOldFont)
- {
+ if(pOldFont) {
pDC->SelectObject(pOldFont);
}
}
@@ -295,8 +294,7 @@ void CPPageInternalFiltersListBox::OnRButtonDown(UINT nFlags, CPoint point)
CMenu m;
m.CreatePopupMenu();
- enum
- {
+ enum {
ENABLEALL=1,
DISABLEALL,
ENABLEFFDSHOW,
@@ -307,8 +305,7 @@ void CPPageInternalFiltersListBox::OnRButtonDown(UINT nFlags, CPoint point)
m.AppendMenu(MF_STRING|MF_ENABLED, ENABLEALL, ResStr(IDS_ENABLE_ALL_FILTERS));
m.AppendMenu(MF_STRING|MF_ENABLED, DISABLEALL, ResStr(IDS_DISABLE_ALL_FILTERS));
- if (m_n == 1)
- {
+ if (m_n == 1) {
m.AppendMenu(MF_SEPARATOR);
m.AppendMenu(MF_STRING|MF_ENABLED, ENABLEFFDSHOW, ResStr(IDS_ENABLE_FFMPEG_FILTERS));
m.AppendMenu(MF_STRING|MF_ENABLED, DISABLEFFDSHOW, ResStr(IDS_DISABLE_FFMPEG_FILTERS));
@@ -322,52 +319,56 @@ void CPPageInternalFiltersListBox::OnRButtonDown(UINT nFlags, CPoint point)
UINT id = m.TrackPopupMenu(TPM_LEFTBUTTON|TPM_RETURNCMD, p.x, p.y, this);
- if (id == 0)
+ if (id == 0) {
return;
+ }
int Index = 0;
- for(int i = 0; i < countof(s_filters); i++)
- {
- switch(s_filters[i].type)
- {
- case 0: // source filter
- if (m_n == 1)
- continue;
- break;
- case 1: // decoder
- case 2: // dxva decoder
- case 3: // ffmpeg decoder
- if (m_n == 0)
+ for(int i = 0; i < countof(s_filters); i++) {
+ switch(s_filters[i].type) {
+ case 0: // source filter
+ if (m_n == 1) {
+ continue;
+ }
+ break;
+ case 1: // decoder
+ case 2: // dxva decoder
+ case 3: // ffmpeg decoder
+ if (m_n == 0) {
+ continue;
+ }
+ break;
+ default:
continue;
- break;
- default:
- continue;
}
- switch(id)
- {
- case ENABLEALL:
- SetCheck(Index, TRUE);
- break;
- case DISABLEALL:
- SetCheck(Index, FALSE);
- break;
- case ENABLEFFDSHOW:
- if(s_filters[i].type == 3)
- SetCheck(Index, TRUE);
- break;
- case DISABLEFFDSHOW:
- if(s_filters[i].type == 3)
- SetCheck(Index, FALSE);
- break;
- case ENABLEDXVA:
- if(s_filters[i].type == 2)
+ switch(id) {
+ case ENABLEALL:
SetCheck(Index, TRUE);
- break;
- case DISABLEDXVA:
- if(s_filters[i].type == 2)
+ break;
+ case DISABLEALL:
SetCheck(Index, FALSE);
- break;
+ break;
+ case ENABLEFFDSHOW:
+ if(s_filters[i].type == 3) {
+ SetCheck(Index, TRUE);
+ }
+ break;
+ case DISABLEFFDSHOW:
+ if(s_filters[i].type == 3) {
+ SetCheck(Index, FALSE);
+ }
+ break;
+ case ENABLEDXVA:
+ if(s_filters[i].type == 2) {
+ SetCheck(Index, TRUE);
+ }
+ break;
+ case DISABLEDXVA:
+ if(s_filters[i].type == 2) {
+ SetCheck(Index, FALSE);
+ }
+ break;
}
Index++;
}
@@ -408,35 +409,32 @@ BOOL CPPageInternalFilters::OnInitDialog()
AppSettings& s = AfxGetAppSettings();
- for(int i = 0; i < countof(s_filters)-1; i++)
- {
+ for(int i = 0; i < countof(s_filters)-1; i++) {
CCheckListBox* l;
bool checked;
- switch(s_filters[i].type)
- {
- case SOURCE_FILTER: // source filter
- l = &m_listSrc;
- checked = s.SrcFilters[s_filters[i].flag];
- break;
- case DECODER: // decoder
- l = &m_listTra;
- checked = s.TraFilters[s_filters[i].flag];
- break;
- case DXVA_DECODER: // dxva decoder
- l = &m_listTra;
- checked = s.DXVAFilters[s_filters[i].flag];
- break;
- case FFMPEG_DECODER: // ffmpeg decoder
- l = &m_listTra;
- checked = s.FFmpegFilters[s_filters[i].flag];
- break;
- default:
- l = NULL;
+ switch(s_filters[i].type) {
+ case SOURCE_FILTER: // source filter
+ l = &m_listSrc;
+ checked = s.SrcFilters[s_filters[i].flag];
+ break;
+ case DECODER: // decoder
+ l = &m_listTra;
+ checked = s.TraFilters[s_filters[i].flag];
+ break;
+ case DXVA_DECODER: // dxva decoder
+ l = &m_listTra;
+ checked = s.DXVAFilters[s_filters[i].flag];
+ break;
+ case FFMPEG_DECODER: // ffmpeg decoder
+ l = &m_listTra;
+ checked = s.FFmpegFilters[s_filters[i].flag];
+ break;
+ default:
+ l = NULL;
}
- if (l)
- {
+ if (l) {
int Index = l->AddString(s_filters[i].label);
l->SetCheck(Index, checked);
l->SetItemDataPtr(Index, &s_filters[i]);
@@ -456,26 +454,23 @@ BOOL CPPageInternalFilters::OnApply()
AppSettings& s = AfxGetAppSettings();
CPPageInternalFiltersListBox* list = &m_listSrc;
- for (int l=0; l<2; l++)
- {
- for(int i = 0; i < list->GetCount(); i++)
- {
+ 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;
+ 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;
@@ -487,21 +482,25 @@ BOOL CPPageInternalFilters::OnApply()
void CPPageInternalFilters::ShowPPage(CPPageInternalFiltersListBox& l)
{
int i = l.GetCurSel();
- if(i < 0) return;
+ if(i < 0) {
+ return;
+ }
filter_t* f = (filter_t*)l.GetItemDataPtr(i);
- if(!f || !f->CreateInstance) return;
+ if(!f || !f->CreateInstance) {
+ return;
+ }
HRESULT hr;
CUnknown* pObj = f->CreateInstance(NULL, &hr);
- if(!pObj) return;
+ if(!pObj) {
+ return;
+ }
CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)pObj;
- if(SUCCEEDED(hr))
- {
- if(CComQIPtr<ISpecifyPropertyPages> pSPP = pUnk)
- {
+ if(SUCCEEDED(hr)) {
+ if(CComQIPtr<ISpecifyPropertyPages> pSPP = pUnk) {
CComPropertySheet ps(ResStr(IDS_PROPSHEET_PROPERTIES), this);
ps.AddPages(pSPP);
ps.DoModal();
diff --git a/src/apps/mplayerc/PPageInternalFilters.h b/src/apps/mplayerc/PPageInternalFilters.h
index abe3d54a0..429aa4057 100644
--- a/src/apps/mplayerc/PPageInternalFilters.h
+++ b/src/apps/mplayerc/PPageInternalFilters.h
@@ -59,7 +59,7 @@ public:
CPPageInternalFilters();
virtual ~CPPageInternalFilters();
-// Dialog Data
+ // Dialog Data
enum { IDD = IDD_PPAGEINTERNALFILTERS };
CPPageInternalFiltersListBox m_listSrc;
CPPageInternalFiltersListBox m_listTra;
diff --git a/src/apps/mplayerc/PPageLogo.cpp b/src/apps/mplayerc/PPageLogo.cpp
index e8f03102c..e7821089d 100644
--- a/src/apps/mplayerc/PPageLogo.cpp
+++ b/src/apps/mplayerc/PPageLogo.cpp
@@ -78,17 +78,18 @@ BOOL CPPageLogo::OnInitDialog()
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)
- {
+ 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) OnBnClickedRadio1();
- else OnBnClickedRadio2();
+ if(!m_intext) {
+ OnBnClickedRadio1();
+ } else {
+ OnBnClickedRadio2();
+ }
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
@@ -145,15 +146,16 @@ void CPPageLogo::OnDeltaposSpin1(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
- if(pNMUpDown->iDelta < 0)
- {
+ if(pNMUpDown->iDelta < 0) {
m_logoids.GetNext(m_logoidpos);
- if(!m_logoidpos) m_logoidpos = m_logoids.GetHeadPosition();
- }
- else
- {
+ if(!m_logoidpos) {
+ m_logoidpos = m_logoids.GetHeadPosition();
+ }
+ } else {
m_logoids.GetPrev(m_logoidpos);
- if(!m_logoidpos) m_logoidpos = m_logoids.GetTailPosition();
+ if(!m_logoidpos) {
+ m_logoidpos = m_logoids.GetTailPosition();
+ }
}
GetDataFromRes();
@@ -170,8 +172,7 @@ void CPPageLogo::OnBnClickedButton2()
_T("Images (*.bmp;*.gif;*.jpg;*.png)|*.bmp;*.gif;*.jpg;*.png|All files (*.*)|*.*||"),
this, 0);
- if(dlg.DoModal() == IDOK)
- {
+ if(dlg.DoModal() == IDOK) {
m_logofn = dlg.GetPathName();
UpdateData(FALSE);
OnBnClickedRadio2();
@@ -184,10 +185,11 @@ void CPPageLogo::GetDataFromRes()
m_logobm.Destroy();
UINT id = m_logoids.GetAt(m_logoidpos);
- if(IDF_LOGO0 != id)
- {
+ if(IDF_LOGO0 != id) {
m_logobm.LoadFromResource(id);
- if(!m_author.LoadString(id)) m_author = ResStr(IDS_LOGO_AUTHOR);
+ if(!m_author.LoadString(id)) {
+ m_author = ResStr(IDS_LOGO_AUTHOR);
+ }
}
m_logopreview.SetBitmap(m_logobm);
}
diff --git a/src/apps/mplayerc/PPageLogo.h b/src/apps/mplayerc/PPageLogo.h
index 7dc37ece8..461be1a25 100644
--- a/src/apps/mplayerc/PPageLogo.h
+++ b/src/apps/mplayerc/PPageLogo.h
@@ -42,7 +42,7 @@ public:
CPPageLogo();
virtual ~CPPageLogo();
-// Dialog Data
+ // Dialog Data
enum { IDD = IDD_PPAGELOGO };
int m_intext;
CString m_logofn;
diff --git a/src/apps/mplayerc/PPageOutput.cpp b/src/apps/mplayerc/PPageOutput.cpp
index b5548c0ef..be8da7d88 100644
--- a/src/apps/mplayerc/PPageOutput.cpp
+++ b/src/apps/mplayerc/PPageOutput.cpp
@@ -39,7 +39,7 @@ CPPageOutput::CPPageOutput()
, m_iQTVideoRendererType(0)
, m_iAPSurfaceUsage(0)
, m_iAudioRendererType(0)
-// , m_fVMRSyncFix(FALSE)
+ // , m_fVMRSyncFix(FALSE)
, m_iDX9Resizer(0)
, m_fVMR9MixerMode(FALSE)
, m_fVMR9MixerYUV(FALSE)
@@ -62,11 +62,11 @@ void CPPageOutput::DoDataExchange(CDataExchange* 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_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_Check(pDX, IDC_CHECK1, m_fVMRSyncFix);
+ // DDX_Check(pDX, IDC_CHECK1, m_fVMRSyncFix);
DDX_CBIndex(pDX, IDC_DX9RESIZER_COMBO, m_iDX9Resizer);
DDX_Check(pDX, IDC_DSVMR9LOADMIXER, m_fVMR9MixerMode);
DDX_Check(pDX, IDC_DSVMR9YUVMIXER, m_fVMR9MixerYUV);
@@ -91,8 +91,7 @@ END_MESSAGE_MAP()
void CPPageOutput::DisableRadioButton(UINT nID, UINT nDefID)
{
- if(IsDlgButtonChecked(nID))
- {
+ if(IsDlgButtonChecked(nID)) {
CheckDlgButton(nID, BST_UNCHECKED);
CheckDlgButton(nDefID, BST_CHECKED);
}
@@ -115,7 +114,7 @@ BOOL CPPageOutput::OnInitDialog()
m_iRMVideoRendererType = s.iRMVideoRendererType;
m_iQTVideoRendererType = s.iQTVideoRendererType;
m_iAPSurfaceUsage = renderersSettings.iAPSurfaceUsage;
-// m_fVMRSyncFix = renderersSettings.fVMRSyncFix;
+ // m_fVMRSyncFix = renderersSettings.fVMRSyncFix;
m_iDX9Resizer = renderersSettings.iDX9Resizer;
m_fVMR9MixerMode = renderersSettings.fVMR9MixerMode;
m_fVMR9MixerYUV = renderersSettings.fVMR9MixerYUV;
@@ -131,11 +130,11 @@ BOOL CPPageOutput::OnInitDialog()
int i=2;
CString Cbstr;
- BeginEnumSysDev(CLSID_AudioRendererCategory, pMoniker)
- {
+ BeginEnumSysDev(CLSID_AudioRendererCategory, pMoniker) {
LPOLESTR olestr = NULL;
- if(FAILED(pMoniker->GetDisplayName(0, 0, &olestr)))
+ if(FAILED(pMoniker->GetDisplayName(0, 0, &olestr))) {
continue;
+ }
CStringW str(olestr);
CoTaskMemFree(olestr);
@@ -143,33 +142,27 @@ BOOL CPPageOutput::OnInitDialog()
m_AudioRendererDisplayNames.Add(CString(str));
CComPtr<IPropertyBag> pPB;
- if(SUCCEEDED(pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&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)))
- {
+ if(SUCCEEDED(pPB->Read(CComBSTR(_T("FilterData")), &var, NULL))) {
BSTR* pbstr;
- if(SUCCEEDED(SafeArrayAccessData(var.parray, (void**)&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
- {
+ } else {
Cbstr.Format(_T("%d: %s"), i, CString(str));
}
m_iAudioRendererTypeCtrl.AddString(Cbstr);
- if(s.strAudioRendererDisplayName == str && m_iAudioRendererType == 0)
- {
+ if(s.strAudioRendererDisplayName == str && m_iAudioRendererType == 0) {
m_iAudioRendererType = m_iAudioRendererTypeCtrl.GetCount()-1;
}
i++;
@@ -179,28 +172,30 @@ BOOL CPPageOutput::OnInitDialog()
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)
+ 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)
+ 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)
+ if(s.strAudioRendererDisplayName == AUDRNDT_MPC && m_iAudioRendererType == 0) {
m_iAudioRendererType = m_iAudioRendererTypeCtrl.GetCount()-1;
+ }
CorrectComboListWidth(m_iAudioRendererTypeCtrl, GetFont());
//
IDirect3D9* pD3D = Direct3DCreate9(D3D_SDK_VERSION);
- if (pD3D)
- {
+ if (pD3D) {
TCHAR strGUID[50];
CString cstrGUID;
CString d3ddevice_str = _T("");
@@ -208,31 +203,28 @@ BOOL CPPageOutput::OnInitDialog()
D3DADAPTER_IDENTIFIER9 adapterIdentifier;
- for(UINT adp = 0, num_adp = pD3D->GetAdapterCount(); adp < num_adp; ++adp)
- {
- if (pD3D->GetAdapterIdentifier(adp, 0, &adapterIdentifier) == S_OK)
- {
+ 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)
- {
+ if (::StringFromGUID2(adapterIdentifier.DeviceIdentifier, strGUID, 50) > 0) {
cstrGUID = strGUID;
}
- if((cstrGUID != _T("")))
- {
+ 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;
+ for(i = 0; (!m_find) && (i < m_D3D9GUIDNames.GetCount()); i++) {
+ if(m_D3D9GUIDNames.GetAt(i) == cstrGUID) {
+ m_find = true;
+ }
}
- if(!m_find)
- {
+ if(!m_find) {
m_iD3D9RenderDeviceCtrl.AddString(d3ddevice_str);
m_D3D9GUIDNames.Add(cstrGUID);
- if (renderersSettings.D3D9RenderDevice == cstrGUID)
+ if (renderersSettings.D3D9RenderDevice == cstrGUID) {
m_iD3D9RenderDevice = m_iD3D9RenderDeviceCtrl.GetCount()-1;
+ }
}
}
}
@@ -244,40 +236,34 @@ BOOL CPPageOutput::OnInitDialog()
UpdateData(FALSE);
- if(!IsCLSIDRegistered(CLSID_VideoMixingRenderer))
- {
+ if(!IsCLSIDRegistered(CLSID_VideoMixingRenderer)) {
DisableRadioButton(IDC_DSVMR7WIN, IDC_DSSYSDEF);
DisableRadioButton(IDC_DSVMR7REN, IDC_DSSYSDEF);
}
- if(!IsCLSIDRegistered(CLSID_VideoMixingRenderer9))
- {
+ 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))
- {
+ 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))
- {
+ if(!IsCLSIDRegistered(CLSID_DXR)) {
DisableRadioButton(IDC_DSDXR, IDC_DSSYSDEF);
}
- if(!IsCLSIDRegistered(CLSID_madVR))
- {
+ if(!IsCLSIDRegistered(CLSID_madVR)) {
DisableRadioButton(IDC_DSMADVR, IDC_DSSYSDEF);
}
// YUV mixing is not compatible with Vista
- if (IsVistaOrAbove())
- {
+ if (IsVistaOrAbove()) {
GetDlgItem(IDC_DSVMR9YUVMIXER)->ShowWindow (SW_HIDE);
}
@@ -287,23 +273,20 @@ BOOL CPPageOutput::OnInitDialog()
GetDlgItem(IDC_D3D9DEVICE)->EnableWindow(TRUE);
GetDlgItem(IDC_D3D9DEVICE_COMBO)->EnableWindow(TRUE);
- if((m_iDSVideoRendererType == 6 || m_iDSVideoRendererType == 11) && (m_iD3D9RenderDeviceCtrl.GetCount() > 1))
- {
+ 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)
- {
+ if(m_iD3D9RenderDevice != -1) {
CheckDlgButton(IDC_D3D9DEVICE, BST_CHECKED);
GetDlgItem(IDC_D3D9DEVICE_COMBO)->EnableWindow(TRUE);
}
- }
- else
- {
+ } else {
GetDlgItem(IDC_D3D9DEVICE)->EnableWindow(FALSE);
GetDlgItem(IDC_D3D9DEVICE_COMBO)->EnableWindow(FALSE);
- if(m_iD3D9RenderDevice == -1)
+ if(m_iD3D9RenderDevice == -1) {
CheckDlgButton(IDC_D3D9DEVICE, BST_UNCHECKED);
+ }
}
UpdateData(TRUE);
@@ -324,7 +307,7 @@ BOOL CPPageOutput::OnApply()
s.iRMVideoRendererType = m_iRMVideoRendererType;
s.iQTVideoRendererType = m_iQTVideoRendererType;
renderersSettings.iAPSurfaceUsage = m_iAPSurfaceUsage;
-// renderersSettings.fVMRSyncFix = !!m_fVMRSyncFix;
+ // renderersSettings.fVMRSyncFix = !!m_fVMRSyncFix;
renderersSettings.iDX9Resizer = m_iDX9Resizer;
renderersSettings.fVMR9MixerMode = !!m_fVMR9MixerMode;
renderersSettings.fVMR9MixerYUV = !!m_fVMR9MixerYUV;
@@ -334,14 +317,13 @@ BOOL CPPageOutput::OnApply()
renderersSettings.fResetDevice = !!m_fResetDevice;
- if (!m_iEvrBuffers.IsEmpty())
- {
+ if (!m_iEvrBuffers.IsEmpty()) {
int Temp = 5;
swscanf(m_iEvrBuffers.GetBuffer(), L"%d", &Temp);
renderersSettings.iEvrBuffers = Temp;
- }
- else
+ } else {
renderersSettings.iEvrBuffers = 5;
+ }
renderersSettings.D3D9RenderDevice = m_fD3D9RenderDevice ? m_D3D9GUIDNames[m_iD3D9RenderDevice] : _T("");
@@ -366,63 +348,59 @@ void CPPageOutput::OnDSRendererChange(UINT nIDbutton)
GetDlgItem(IDC_DSVMR9YUVMIXER)->EnableWindow(FALSE);
GetDlgItem(IDC_DSVMR9ALTERNATIVEVSYNC)->EnableWindow(FALSE);
GetDlgItem(IDC_RESETDEVICE)->EnableWindow(FALSE);
-// GetDlgItem(IDC_CHECK1)->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));
- }
+ 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_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);
+ 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));
+ }
- // Force 3D surface with EVR Custom
- if (nIDbutton - IDC_DSSYSDEF == 11)
- {
+ 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);
- }
- 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;
+ break;
}
SetModified();
@@ -432,8 +410,7 @@ void CPPageOutput::OnFullscreenCheck()
{
UpdateData();
if (m_fD3DFullscreen &&
- (MessageBox(ResStr(IDS_D3DFS_WARNING), NULL, MB_YESNO) == IDNO))
- {
+ (MessageBox(ResStr(IDS_D3DFS_WARNING), NULL, MB_YESNO) == IDNO)) {
m_fD3DFullscreen = false;
UpdateData(FALSE);
}
diff --git a/src/apps/mplayerc/PPageOutput.h b/src/apps/mplayerc/PPageOutput.h
index 635450e2c..45336afdf 100644
--- a/src/apps/mplayerc/PPageOutput.h
+++ b/src/apps/mplayerc/PPageOutput.h
@@ -44,7 +44,7 @@ public:
CPPageOutput();
virtual ~CPPageOutput();
-// Dialog Data
+ // Dialog Data
enum { IDD = IDD_PPAGEOUTPUT };
int m_iDSVideoRendererType;
int m_iRMVideoRendererType;
@@ -52,7 +52,7 @@ public:
int m_iAPSurfaceUsage;
int m_iAudioRendererType;
CComboBox m_iAudioRendererTypeCtrl;
-// BOOL m_fVMRSyncFix;
+ // BOOL m_fVMRSyncFix;
int m_iDX9Resizer;
BOOL m_fVMR9MixerMode;
BOOL m_fVMR9MixerYUV;
diff --git a/src/apps/mplayerc/PPagePlayback.cpp b/src/apps/mplayerc/PPagePlayback.cpp
index 485a5e6eb..4c2615256 100644
--- a/src/apps/mplayerc/PPagePlayback.cpp
+++ b/src/apps/mplayerc/PPagePlayback.cpp
@@ -144,8 +144,7 @@ BOOL CPPagePlayback::OnApply()
LRESULT CPPagePlayback::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
- if(message == WM_HSCROLL || message == WM_VSCROLL)
- {
+ if(message == WM_HSCROLL || message == WM_VSCROLL) {
SetModified();
}
@@ -154,13 +153,10 @@ LRESULT CPPagePlayback::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam
void CPPagePlayback::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
- if(*pScrollBar == m_volumectrl)
- {
+ if(*pScrollBar == m_volumectrl) {
UpdateData();
((CMainFrame*)GetParentFrame())->m_wndToolBar.Volume = m_nVolume; // nice shortcut...
- }
- else if(*pScrollBar == m_balancectrl)
- {
+ } else if(*pScrollBar == m_balancectrl) {
UpdateData();
((CMainFrame*)GetParentFrame())->SetBalance(m_nBalance-100); // see prev note...
}
@@ -197,8 +193,9 @@ BOOL CPPagePlayback::OnSetActive()
BOOL CPPagePlayback::OnKillActive()
{
AppSettings& s = AfxGetAppSettings();
- if(s.fRememberZoomLevel)
+ if(s.fRememberZoomLevel) {
s.fRememberWindowSize = false;
+ }
return __super::OnKillActive();
} \ No newline at end of file
diff --git a/src/apps/mplayerc/PPagePlayback.h b/src/apps/mplayerc/PPagePlayback.h
index 4232d3140..46a23322c 100644
--- a/src/apps/mplayerc/PPagePlayback.h
+++ b/src/apps/mplayerc/PPagePlayback.h
@@ -56,7 +56,7 @@ public:
CString m_subtitlesLanguageOrder;
CString m_audiosLanguageOrder;
-// Dialog Data
+ // Dialog Data
enum { IDD = IDD_PPAGEPLAYBACK };
protected:
diff --git a/src/apps/mplayerc/PPagePlayer.cpp b/src/apps/mplayerc/PPagePlayer.cpp
index 344e106e5..021a75152 100644
--- a/src/apps/mplayerc/PPagePlayer.cpp
+++ b/src/apps/mplayerc/PPagePlayer.cpp
@@ -139,10 +139,13 @@ BOOL CPPagePlayer::OnApply()
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);
+ 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();
}
@@ -161,8 +164,11 @@ void CPPagePlayer::OnBnClickedCheck8()
{
UpdateData();
- if(m_fUseIni) ((CMPlayerCApp*)AfxGetApp())->StoreSettingsToIni();
- else ((CMPlayerCApp*)AfxGetApp())->StoreSettingsToRegistry();
+ if(m_fUseIni) {
+ ((CMPlayerCApp*)AfxGetApp())->StoreSettingsToIni();
+ } else {
+ ((CMPlayerCApp*)AfxGetApp())->StoreSettingsToRegistry();
+ }
SetModified();
}
@@ -193,8 +199,9 @@ BOOL CPPagePlayer::OnSetActive()
BOOL CPPagePlayer::OnKillActive()
{
AppSettings& s = AfxGetAppSettings();
- if(s.fRememberWindowSize)
+ if(s.fRememberWindowSize) {
s.fRememberZoomLevel = false;
+ }
return __super::OnKillActive();
} \ No newline at end of file
diff --git a/src/apps/mplayerc/PPagePlayer.h b/src/apps/mplayerc/PPagePlayer.h
index 475060b8e..8bfaf6ef1 100644
--- a/src/apps/mplayerc/PPagePlayer.h
+++ b/src/apps/mplayerc/PPagePlayer.h
@@ -53,7 +53,7 @@ public:
BOOL m_fRememberDVDPos;
BOOL m_fRememberFilePos;
-// Dialog Data
+ // Dialog Data
enum { IDD = IDD_PPAGEPLAYER };
protected:
diff --git a/src/apps/mplayerc/PPageSheet.cpp b/src/apps/mplayerc/PPageSheet.cpp
index 39d565941..38ed358a0 100644
--- a/src/apps/mplayerc/PPageSheet.cpp
+++ b/src/apps/mplayerc/PPageSheet.cpp
@@ -62,14 +62,12 @@ CPPageSheet::CPPageSheet(LPCTSTR pszCaption, IFilterGraph* pFG, CWnd* pParentWnd
SetTreeViewMode(TRUE, TRUE, FALSE);
- if(!idPage)
+ if(!idPage) {
idPage = AfxGetAppSettings().nLastUsedPage;
- if(idPage)
- {
- for(int i = 0; i < GetPageCount(); i++)
- {
- if(GetPage(i)->m_pPSP->pszTemplate == MAKEINTRESOURCE(idPage))
- {
+ }
+ if(idPage) {
+ for(int i = 0; i < GetPageCount(); i++) {
+ if(GetPage(i)->m_pPSP->pszTemplate == MAKEINTRESOURCE(idPage)) {
SetActivePage(i);
break;
}
@@ -94,14 +92,15 @@ BOOL CPPageSheet::OnInitDialog()
{
BOOL bResult = __super::OnInitDialog();
- if(CTreeCtrl* pTree = GetPageTreeControl())
- {
- for(HTREEITEM node = pTree->GetRootItem(); node; node = pTree->GetNextSiblingItem(node))
+ if(CTreeCtrl* pTree = GetPageTreeControl()) {
+ for(HTREEITEM node = pTree->GetRootItem(); node; node = pTree->GetNextSiblingItem(node)) {
pTree->Expand(node, TVE_EXPAND);
+ }
}
- if (m_bLockPage)
+ if (m_bLockPage) {
GetPageTreeControl()->EnableWindow (FALSE);
+ }
return bResult;
}
@@ -132,7 +131,7 @@ END_MESSAGE_MAP()
BOOL CTreePropSheetTreeCtrl::PreCreateWindow(CREATESTRUCT& cs)
{
cs.dwExStyle |= WS_EX_CLIENTEDGE;
-// cs.style &= ~TVS_LINESATROOT;
+ // cs.style &= ~TVS_LINESATROOT;
return __super::PreCreateWindow(cs);
}
diff --git a/src/apps/mplayerc/PPageSheet.h b/src/apps/mplayerc/PPageSheet.h
index f8b4c78df..48a01edf0 100644
--- a/src/apps/mplayerc/PPageSheet.h
+++ b/src/apps/mplayerc/PPageSheet.h
@@ -95,8 +95,7 @@ public:
virtual ~CPPageSheet();
afx_msg void OnContextMenu(CWnd *pWnd, CPoint point);
- void LockPage()
- {
+ void LockPage() {
m_bLockPage = true;
};
protected:
diff --git a/src/apps/mplayerc/PPageSubMisc.cpp b/src/apps/mplayerc/PPageSubMisc.cpp
index 329c0afa4..605a80cbe 100644
--- a/src/apps/mplayerc/PPageSubMisc.cpp
+++ b/src/apps/mplayerc/PPageSubMisc.cpp
@@ -65,8 +65,9 @@ BOOL CPPageSubMisc::OnInitDialog()
m_ISDb = s.strISDb;
m_ISDbCombo.AddString(m_ISDb);
- if(m_ISDb.CompareNoCase(_T("www.opensubtitles.org/isdb")))
+ if(m_ISDb.CompareNoCase(_T("www.opensubtitles.org/isdb"))) {
m_ISDbCombo.AddString(_T("www.opensubtitles.org/isdb"));
+ }
UpdateData(FALSE);
@@ -116,16 +117,11 @@ void CPPageSubMisc::OnBnClickedButton2()
ver.Format(_T("ISDb v%d"), ISDb_PROTOCOL_VERSION);
CWebTextFile wtf;
- if(wtf.Open(_T("http://") + ISDb + _T("/test.php")) && wtf.ReadString(str) && str == ver)
- {
+ if(wtf.Open(_T("http://") + ISDb + _T("/test.php")) && wtf.ReadString(str) && str == ver) {
msg = ResStr(IDS_PPSDB_URLCORRECT);
- }
- else if(str.Find(_T("ISDb v")) == 0)
- {
+ } else if(str.Find(_T("ISDb v")) == 0) {
msg = ResStr(IDS_PPSDB_PROTOCOLERR);
- }
- else
- {
+ } else {
msg = ResStr(IDS_PPSDB_BADURL);
}
diff --git a/src/apps/mplayerc/PPageSubMisc.h b/src/apps/mplayerc/PPageSubMisc.h
index af10f6238..fedcf77c1 100644
--- a/src/apps/mplayerc/PPageSubMisc.h
+++ b/src/apps/mplayerc/PPageSubMisc.h
@@ -34,7 +34,7 @@ public:
CPPageSubMisc();
virtual ~CPPageSubMisc();
-// Dialog Data
+ // Dialog Data
enum { IDD = IDD_PPAGESUBMISC };
BOOL m_fPrioritizeExternalSubtitles;
BOOL m_fDisableInternalSubtitles;
diff --git a/src/apps/mplayerc/PPageSubStyle.cpp b/src/apps/mplayerc/PPageSubStyle.cpp
index ef216bfd3..52ba434de 100644
--- a/src/apps/mplayerc/PPageSubStyle.cpp
+++ b/src/apps/mplayerc/PPageSubStyle.cpp
@@ -74,8 +74,7 @@ void CPPageSubStyle::AskColor(int i)
{
CColorDialog dlg(m_stss.colors[i]);
dlg.m_cc.Flags |= CC_FULLOPEN;
- if(dlg.DoModal() == IDOK)
- {
+ if(dlg.DoModal() == IDOK) {
m_stss.colors[i] = dlg.m_cc.rgbResult;
m_color[i].Invalidate();
}
@@ -147,19 +146,22 @@ BOOL CPPageSubStyle::OnInitDialog()
m_font.SetWindowText(m_stss.fontName);
m_iCharset = -1;
- for(int i = 0; i < CharSetLen; i++)
- {
+ 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;
+ 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;
+ 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;
@@ -181,8 +183,7 @@ BOOL CPPageSubStyle::OnInitDialog()
m_marginbottomspin.SetRange32(-10000, 10000);
m_relativeTo = m_stss.relativeTo;
- for(int i = 0; i < 4; i++)
- {
+ 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);
@@ -202,7 +203,9 @@ BOOL CPPageSubStyle::OnApply()
{
UpdateData();
- if(m_iCharset >= 0) m_stss.charSet = m_charset.GetItemData(m_iCharset);
+ 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;
@@ -216,16 +219,17 @@ BOOL CPPageSubStyle::OnApply()
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];
+ for(int i = 0; i < 4; i++) {
+ m_stss.alpha[i] = 255-m_alpha[i];
+ }
- if(m_fUseDefaultStyle)
- {
+ if(m_fUseDefaultStyle) {
STSStyle& stss = AfxGetAppSettings().subdefstyle;
- if(!(stss == m_stss))
- {
+ if(!(stss == m_stss)) {
stss = m_stss;
- if(CMainFrame* pFrame = dynamic_cast<CMainFrame*>(AfxGetMainWnd()))
+ if(CMainFrame* pFrame = dynamic_cast<CMainFrame*>(AfxGetMainWnd())) {
pFrame->UpdateSubtitle(false, true);
+ }
}
}
@@ -238,16 +242,15 @@ void CPPageSubStyle::OnBnClickedButton1()
lf <<= m_stss;
CFontDialog dlg(&lf, CF_SCREENFONTS|CF_INITTOLOGFONTSTRUCT|CF_FORCEFONTEXIST|CF_SCALABLEONLY|CF_EFFECTS);
- if(dlg.DoModal() == IDOK)
- {
+ if(dlg.DoModal() == IDOK) {
CString str(lf.lfFaceName);
- if(str.GetLength() > 16) str = str.Left(14) + _T("...");
+ 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)
- {
+ for(int i = 0, j = m_charset.GetCount(); i < j; i++) {
+ if(m_charset.GetItemData(i) == lf.lfCharSet) {
m_charset.SetCurSel(i);
break;
}
@@ -284,19 +287,24 @@ void CPPageSubStyle::OnBnClickedCheck1()
UpdateData();
int avg = 0;
- for(int i = 0; i < 4; i++) avg += m_alphasliders[i].GetPos();
+ 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);
+ 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)
- {
+ if(m_linkalphasliders && pScrollBar) {
int pos = ((CSliderCtrl*)pScrollBar)->GetPos();
- for(int i = 0; i < 4; i++) m_alphasliders[i].SetPos(pos);
+ for(int i = 0; i < 4; i++) {
+ m_alphasliders[i].SetPos(pos);
+ }
}
SetModified();
diff --git a/src/apps/mplayerc/PPageSubStyle.h b/src/apps/mplayerc/PPageSubStyle.h
index e436e8e89..a606254c9 100644
--- a/src/apps/mplayerc/PPageSubStyle.h
+++ b/src/apps/mplayerc/PPageSubStyle.h
@@ -29,7 +29,7 @@
class CColorStatic : public CStatic
{
-// DECLARE_DYNAMIC(CColorStatic)
+ // DECLARE_DYNAMIC(CColorStatic)
COLORREF* m_pColor;
@@ -37,16 +37,14 @@ public:
CColorStatic(CWnd* pParent = NULL) : m_pColor(NULL) {}
virtual ~CColorStatic() {}
- void SetColorPtr(COLORREF* pColor)
- {
+ void SetColorPtr(COLORREF* pColor) {
m_pColor = pColor;
}
-// DECLARE_MESSAGE_MAP()
+ // DECLARE_MESSAGE_MAP()
protected:
- virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
- {
+ virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) {
CRect r;
GetClientRect(r);
CDC::FromHandle(lpDrawItemStruct->hDC)->FillSolidRect(r, m_pColor ? *m_pColor : ::GetSysColor(COLOR_BTNFACE));
@@ -71,12 +69,11 @@ public:
virtual ~CPPageSubStyle();
void InitStyle(CString title, STSStyle& stss);
- void GetStyle(STSStyle& stss)
- {
+ void GetStyle(STSStyle& stss) {
stss = m_stss;
}
-// Dialog Data
+ // Dialog Data
enum { IDD = IDD_PPAGESUBSTYLE };
CButton m_font;
int m_iCharset;
diff --git a/src/apps/mplayerc/PPageSubtitles.cpp b/src/apps/mplayerc/PPageSubtitles.cpp
index f504a1e8c..7b35285ac 100644
--- a/src/apps/mplayerc/PPageSubtitles.cpp
+++ b/src/apps/mplayerc/PPageSubtitles.cpp
@@ -82,42 +82,40 @@ 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;
+ 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;
+ 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;
}
@@ -173,8 +171,7 @@ BOOL CPPageSubtitles::OnApply()
|| 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.m_RenderersSettings.fSPCAllowAnimationWhenBuffering != !!m_fSPCAllowAnimationWhenBuffering) {
s.fOverridePlacement = !!m_fOverridePlacement;
s.nHorPos = m_nHorPos;
s.nVerPos = m_nVerPos;
@@ -184,8 +181,9 @@ BOOL CPPageSubtitles::OnApply()
s.m_RenderersSettings.fSPCPow2Tex = !!m_fSPCPow2Tex;
s.m_RenderersSettings.fSPCAllowAnimationWhenBuffering = !!m_fSPCAllowAnimationWhenBuffering;
- if(CMainFrame* pFrame = (CMainFrame*)GetParentFrame())
+ if(CMainFrame* pFrame = (CMainFrame*)GetParentFrame()) {
pFrame->UpdateSubtitle(true);
+ }
}
return __super::OnApply();
@@ -201,8 +199,9 @@ void CPPageSubtitles::OnUpdatePosOverride(CCmdUI* pCmdUI)
void CPPageSubtitles::OnSubDelayInterval()
{
// If incorrect number, revert modifications
- if (!UpdateData())
+ if (!UpdateData()) {
UpdateData(FALSE);
+ }
SetModified();
}
diff --git a/src/apps/mplayerc/PPageSubtitles.h b/src/apps/mplayerc/PPageSubtitles.h
index 6767fde79..dc3722942 100644
--- a/src/apps/mplayerc/PPageSubtitles.h
+++ b/src/apps/mplayerc/PPageSubtitles.h
@@ -50,7 +50,7 @@ public:
BOOL m_fSPCAllowAnimationWhenBuffering;
int m_nSubDelayInterval;
-// Dialog Data
+ // Dialog Data
enum { IDD = IDD_PPAGESUBTITLES };
protected:
diff --git a/src/apps/mplayerc/PPageSync.cpp b/src/apps/mplayerc/PPageSync.cpp
index 3289de72c..fbafbec23 100644
--- a/src/apps/mplayerc/PPageSync.cpp
+++ b/src/apps/mplayerc/PPageSync.cpp
@@ -62,14 +62,11 @@ BOOL CPPageSync::OnInitDialog()
AppSettings& s = AfxGetAppSettings();
CMainFrame * pFrame;
pFrame = (CMainFrame *)(AfxGetApp()->m_pMainWnd);
- if ((s.iDSVideoRendererType == VIDRNDT_DS_SYNC) && (pFrame->GetPlaybackMode() == PM_NONE))
- {
+ 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
- {
+ } else {
GetDlgItem(IDC_SYNCVIDEO)->EnableWindow(FALSE);
GetDlgItem(IDC_SYNCDISPLAY)->EnableWindow(FALSE);
GetDlgItem(IDC_SYNCNEAREST)->EnableWindow(FALSE);
@@ -96,14 +93,11 @@ BOOL CPPageSync::OnSetActive()
AppSettings& s = AfxGetAppSettings();
CMainFrame * pFrame;
pFrame = (CMainFrame *)(AfxGetApp()->m_pMainWnd);
- if ((s.iDSVideoRendererType == VIDRNDT_DS_SYNC) && (pFrame->GetPlaybackMode() == PM_NONE))
- {
+ 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
- {
+ } else {
GetDlgItem(IDC_SYNCVIDEO)->EnableWindow(FALSE);
GetDlgItem(IDC_SYNCDISPLAY)->EnableWindow(FALSE);
GetDlgItem(IDC_SYNCNEAREST)->EnableWindow(FALSE);
@@ -151,8 +145,7 @@ END_MESSAGE_MAP()
void CPPageSync::OnBnClickedSyncVideo()
{
m_bSynchronizeVideo = !m_bSynchronizeVideo;
- if (m_bSynchronizeVideo)
- {
+ if (m_bSynchronizeVideo) {
m_bSynchronizeDisplay = FALSE;
m_bSynchronizeNearest = FALSE;
}
@@ -162,8 +155,7 @@ void CPPageSync::OnBnClickedSyncVideo()
void CPPageSync::OnBnClickedSyncDisplay()
{
m_bSynchronizeDisplay = !m_bSynchronizeDisplay;
- if (m_bSynchronizeDisplay)
- {
+ if (m_bSynchronizeDisplay) {
m_bSynchronizeVideo = FALSE;
m_bSynchronizeNearest = FALSE;
}
@@ -173,8 +165,7 @@ void CPPageSync::OnBnClickedSyncDisplay()
void CPPageSync::OnBnClickedSyncNearest()
{
m_bSynchronizeNearest = !m_bSynchronizeNearest;
- if (m_bSynchronizeNearest)
- {
+ if (m_bSynchronizeNearest) {
m_bSynchronizeVideo = FALSE;
m_bSynchronizeDisplay = FALSE;
}
diff --git a/src/apps/mplayerc/PPageTweaks.cpp b/src/apps/mplayerc/PPageTweaks.cpp
index 4c79b9aab..30af86770 100644
--- a/src/apps/mplayerc/PPageTweaks.cpp
+++ b/src/apps/mplayerc/PPageTweaks.cpp
@@ -76,7 +76,9 @@ void CPPageTweaks::DoDataExchange(CDataExchange* pDX)
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);
+ if(FontType == TRUETYPE_FONTTYPE) {
+ fntl->Add(lf->elfFullName);
+ }
return true;
}
@@ -111,23 +113,26 @@ BOOL CPPageTweaks::OnInitDialog()
CAtlArray<CString> fntl;
EnumFontFamilies(dc, NULL,(FONTENUMPROC)EnumFontProc, (LPARAM)&fntl);
DeleteDC(dc);
- for (int i=0; i< fntl.GetCount(); i++)
- {
- if (i>0 && fntl[i-1] == fntl[i]) continue;
+ for (int i=0; i< fntl.GetCount(); i++) {
+ if (i>0 && fntl[i-1] == fntl[i]) {
+ continue;
+ }
m_FontType.AddString(fntl[i]);
}
- for (int i=0; i< m_FontType.GetCount(); i++)
- {
+ for (int i=0; i< m_FontType.GetCount(); i++) {
m_FontType.GetLBText(i,str);
- if (m_OSD_Font == str) iSel=i;
+ if (m_OSD_Font == str) {
+ iSel=i;
+ }
}
m_FontType.SetCurSel(iSel);
- for (int i=10; i<26; i++)
- {
+ for (int i=10; i<26; i++) {
str.Format(_T("%d"), i);
m_FontSize.AddString(str);
- if (m_OSD_Size == i) iSel=i;
+ if (m_OSD_Size == i) {
+ iSel=i;
+ }
}
m_FontSize.SetCurSel(iSel-10);
@@ -158,7 +163,9 @@ BOOL CPPageTweaks::OnApply()
m_FontType.GetLBText(m_FontType.GetCurSel(),s.strOSDFont);
CMainFrame* pFrame = ((CMainFrame*)GetParentFrame());
- if(m_fUseWin7TaskBar) pFrame->CreateThumbnailToolbar();
+ if(m_fUseWin7TaskBar) {
+ pFrame->CreateThumbnailToolbar();
+ }
pFrame->UpdateThumbarButton();
return __super::OnApply();
diff --git a/src/apps/mplayerc/PPageTweaks.h b/src/apps/mplayerc/PPageTweaks.h
index 239f234ca..21f919183 100644
--- a/src/apps/mplayerc/PPageTweaks.h
+++ b/src/apps/mplayerc/PPageTweaks.h
@@ -44,7 +44,7 @@ public:
BOOL m_fUseWMASFReader;
CButton m_fUseWMASFReaderCtrl;
-// Dialog Data
+ // Dialog Data
enum { IDD = IDD_PPAGETWEAKS };
int m_nJumpDistS;
int m_nJumpDistM;
diff --git a/src/apps/mplayerc/PPageWebServer.cpp b/src/apps/mplayerc/PPageWebServer.cpp
index 0b3ba27bf..3586c5f6b 100644
--- a/src/apps/mplayerc/PPageWebServer.cpp
+++ b/src/apps/mplayerc/PPageWebServer.cpp
@@ -67,18 +67,14 @@ void CPPageWebServer::DoDataExchange(CDataExchange* pDX)
BOOL CPPageWebServer::PreTranslateMessage(MSG* pMsg)
{
- if(pMsg->message == WM_LBUTTONDOWN && pMsg->hwnd == m_launch.m_hWnd)
- {
+ 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)
- {
+ if(CMainFrame* pWnd = (CMainFrame*)AfxGetMainWnd()) {
+ if(m_fEnableWebServer) {
+ if(s.nWebServerPort != m_nWebServerPort) {
AfxMessageBox(_T("Press apply first, before testing the new settings!"), MB_OK);
return TRUE;
}
@@ -121,7 +117,9 @@ BOOL CPPageWebServer::OnApply()
AppSettings& s = AfxGetAppSettings();
CString NewWebRoot = m_WebRoot;
- if(!m_fWebRoot) NewWebRoot = _T("*") + NewWebRoot;
+ if(!m_fWebRoot) {
+ NewWebRoot = _T("*") + NewWebRoot;
+ }
bool fRestart = s.nWebServerPort != m_nWebServerPort
|| s.strWebRoot != NewWebRoot || s.strWebServerCGI != m_WebServerCGI;
@@ -135,15 +133,13 @@ BOOL CPPageWebServer::OnApply()
s.strWebDefIndex = m_WebDefIndex;
s.strWebServerCGI = m_WebServerCGI;
- if(CMainFrame* pWnd = (CMainFrame*)AfxGetMainWnd())
- {
- if(m_fEnableWebServer)
- {
- if(fRestart) pWnd->StopWebServer();
+ if(CMainFrame* pWnd = (CMainFrame*)AfxGetMainWnd()) {
+ if(m_fEnableWebServer) {
+ if(fRestart) {
+ pWnd->StopWebServer();
+ }
pWnd->StartWebServer(m_nWebServerPort);
- }
- else
- {
+ } else {
pWnd->StopWebServer();
}
}
@@ -174,8 +170,9 @@ CString CPPageWebServer::GetCurWebRoot()
static int __stdcall BrowseCtrlCallback(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData)
{
- if(uMsg == BFFM_INITIALIZED && lpData)
+ if(uMsg == BFFM_INITIALIZED && lpData) {
::SendMessage(hwnd, BFFM_SETSELECTION, TRUE, lpData);
+ }
return 0;
}
@@ -194,8 +191,7 @@ bool CPPageWebServer::PickDir(CString& dir)
bi.iImage = 0;
LPITEMIDLIST iil = SHBrowseForFolder(&bi);
- if(iil)
- {
+ if(iil) {
SHGetPathFromIDList(iil, buff);
dir = buff;
return true;
@@ -229,11 +225,11 @@ void CPPageWebServer::OnEnChangeEdit1()
void CPPageWebServer::OnBnClickedButton1()
{
CString dir = GetCurWebRoot();
- if(PickDir(dir))
- {
+ if(PickDir(dir)) {
CPath path;
- if(path.RelativePathTo(GetMPCDir(), FILE_ATTRIBUTE_DIRECTORY, dir, FILE_ATTRIBUTE_DIRECTORY))
+ if(path.RelativePathTo(GetMPCDir(), FILE_ATTRIBUTE_DIRECTORY, dir, FILE_ATTRIBUTE_DIRECTORY)) {
dir = (LPCTSTR)path;
+ }
m_WebRoot = dir;
UpdateData(FALSE);
}
@@ -242,8 +238,7 @@ void CPPageWebServer::OnBnClickedButton1()
void CPPageWebServer::OnBnClickedButton2()
{
CString dir;
- if(PickDir(dir))
- {
+ if(PickDir(dir)) {
dir += _T("\\");
CWebServer::Deploy(dir);
}
diff --git a/src/apps/mplayerc/PPageWebServer.h b/src/apps/mplayerc/PPageWebServer.h
index 80271add5..88494b209 100644
--- a/src/apps/mplayerc/PPageWebServer.h
+++ b/src/apps/mplayerc/PPageWebServer.h
@@ -43,7 +43,7 @@ public:
CPPageWebServer();
virtual ~CPPageWebServer();
-// Dialog Data
+ // Dialog Data
enum { IDD = IDD_PPAGEWEBSERVER };
BOOL m_fEnableWebServer;
int m_nWebServerPort;
diff --git a/src/apps/mplayerc/PlayerCaptureBar.cpp b/src/apps/mplayerc/PlayerCaptureBar.cpp
index be5c1feab..07b3301f7 100644
--- a/src/apps/mplayerc/PlayerCaptureBar.cpp
+++ b/src/apps/mplayerc/PlayerCaptureBar.cpp
@@ -40,8 +40,9 @@ CPlayerCaptureBar::~CPlayerCaptureBar()
BOOL CPlayerCaptureBar::Create(CWnd* pParentWnd)
{
- if(!baseCPlayerCaptureBar::Create(_T("Capture Settings"), pParentWnd, ID_VIEW_CAPTURE))
+ if(!baseCPlayerCaptureBar::Create(_T("Capture Settings"), pParentWnd, ID_VIEW_CAPTURE)) {
return FALSE;
+ }
m_capdlg.Create(this);
m_capdlg.ShowWindow(SW_SHOWNORMAL);
@@ -59,10 +60,10 @@ BOOL CPlayerCaptureBar::Create(CWnd* pParentWnd)
BOOL CPlayerCaptureBar::PreTranslateMessage(MSG* pMsg)
{
- if(IsWindow(pMsg->hwnd) && IsVisible() && pMsg->message >= WM_KEYFIRST && pMsg->message <= WM_KEYLAST)
- {
- if(IsDialogMessage(pMsg))
+ if(IsWindow(pMsg->hwnd) && IsVisible() && pMsg->message >= WM_KEYFIRST && pMsg->message <= WM_KEYLAST) {
+ if(IsDialogMessage(pMsg)) {
return TRUE;
+ }
}
return __super::PreTranslateMessage(pMsg);
diff --git a/src/apps/mplayerc/PlayerCaptureDialog.cpp b/src/apps/mplayerc/PlayerCaptureDialog.cpp
index 1082cc71e..768741ded 100644
--- a/src/apps/mplayerc/PlayerCaptureDialog.cpp
+++ b/src/apps/mplayerc/PlayerCaptureDialog.cpp
@@ -36,19 +36,21 @@ static bool LoadMediaType(CStringW DisplayName, AM_MEDIA_TYPE** ppmt)
{
bool fRet = false;
- if(!ppmt) return(fRet);
+ if(!ppmt) {
+ return(fRet);
+ }
*ppmt = (AM_MEDIA_TYPE*)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
- if(!*ppmt) return(fRet);
+ 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) )
- {
+ if(AfxGetApp()->GetProfileBinary(IDS_RS_CAPTURE _T("\\") + CString(DisplayName), _T("MediaType"), &pData, &len)) {
+ if ( len != sizeof(AM_MEDIA_TYPE) ) {
delete [] pData;
return(fRet);
}
@@ -60,10 +62,8 @@ static bool LoadMediaType(CStringW DisplayName, AM_MEDIA_TYPE** ppmt)
fRet = true;
- if(AfxGetApp()->GetProfileBinary(IDS_RS_CAPTURE _T("\\") + CString(DisplayName), _T("Format"), &pData, &len))
- {
- if ( !len )
- {
+ if(AfxGetApp()->GetProfileBinary(IDS_RS_CAPTURE _T("\\") + CString(DisplayName), _T("Format"), &pData, &len)) {
+ if ( !len ) {
delete [] pData;
return(fRet);
}
@@ -80,7 +80,9 @@ static bool LoadMediaType(CStringW DisplayName, AM_MEDIA_TYPE** ppmt)
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);
@@ -89,23 +91,28 @@ static void SaveMediaType(CStringW DisplayName, AM_MEDIA_TYPE* pmt)
static void LoadDefaultCodec(CAtlArray<Codec>& codecs, CComboBox& box, const GUID& cat)
{
int len = box.GetCount();
- if(len >= 0) box.SetCurSel(0);
+ if(len >= 0) {
+ box.SetCurSel(0);
+ }
- if(cat == GUID_NULL) return;
+ if(cat == GUID_NULL) {
+ return;
+ }
CString DisplayName = AfxGetApp()->GetProfileString(IDS_RS_CAPTURE _T("\\") + CStringFromGUID(cat), _T("DisplayName"));
- for(int i = 0; i < len; i++)
- {
+ for(int i = 0; i < len; i++) {
int iSel = box.GetItemData(i);
- if(iSel < 0) continue;
+ if(iSel < 0) {
+ continue;
+ }
Codec& c = codecs[iSel];
- if(DisplayName == c.DisplayName)
- {
+ if(DisplayName == c.DisplayName) {
box.SetCurSel(i);
- if(!c.pBF)
+ if(!c.pBF) {
c.pMoniker->BindToObject(NULL, NULL, __uuidof(IBaseFilter), (void**)&c.pBF);
+ }
break;
}
}
@@ -113,16 +120,22 @@ static void LoadDefaultCodec(CAtlArray<Codec>& codecs, CComboBox& box, const GUI
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);
AfxGetApp()->WriteProfileString(IDS_RS_CAPTURE _T("\\") + guid, NULL, NULL);
int iSel = box.GetCurSel();
- if(iSel < 0) return;
+ if(iSel < 0) {
+ return;
+ }
iSel = box.GetItemData(iSel);
- if(iSel < 0) return;
+ if(iSel < 0) {
+ return;
+ }
Codec& codec = codecs[iSel];
@@ -133,7 +146,9 @@ static void SetupDefaultCaps(AM_MEDIA_TYPE* pmt, VIDEO_STREAM_CONFIG_CAPS& caps)
{
memset(&caps, 0, sizeof(caps));
- if(!pmt) return;
+ if(!pmt) {
+ return;
+ }
VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->pbFormat;
UNUSED_ALWAYS(vih);
@@ -166,7 +181,9 @@ static void SetupDefaultCaps(AM_MEDIA_TYPE* pmt, AUDIO_STREAM_CONFIG_CAPS& caps)
{
memset(&caps, 0, sizeof(caps));
- if(!pmt) return;
+ if(!pmt) {
+ return;
+ }
WAVEFORMATEX* wfe = (WAVEFORMATEX*)pmt->pbFormat;
@@ -188,39 +205,38 @@ static void SetupMediaTypes(IAMStreamConfig* pAMSC, CFormatArray<T>& tfa, CCombo
type.EnableWindow(FALSE);
dim.EnableWindow(FALSE);
- if(!pAMSC) return;
+ 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++)
- {
+ && 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)))
- {
+ if(SUCCEEDED(pAMSC->GetStreamCaps(i, &pmt, (BYTE*)&caps))) {
tfa.AddFormat(pmt, caps);
}
}
- if(iSize == sizeof(VIDEO_STREAM_CONFIG_CAPS))
- {
- for(int i = 0, cnt = tfa.GetCount(); i < cnt; i++)
- {
- if(tfa[i]->GetCount() != 1) continue;
+ if(iSize == sizeof(VIDEO_STREAM_CONFIG_CAPS)) {
+ for(int 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)
+ && pfe->mt.formattype != FORMAT_VideoInfo2) {
continue;
+ }
- static SIZE presets[] =
- {
+ static SIZE presets[] = {
{160, 120}, {192, 144},
{320, 240}, {384, 288},
{480, 240}, {512, 288},
@@ -239,8 +255,7 @@ static void SetupMediaTypes(IAMStreamConfig* pAMSC, CFormatArray<T>& tfa, CCombo
BITMAPINFOHEADER bihCur;
ExtractBIH(&pfe->mt, &bihCur);
- for(int j = 0; j < countof(presets); j++)
- {
+ for(int j = 0; j < countof(presets); j++) {
if(presets[j].cx == bihCur.biWidth
&& presets[j].cy == abs(bihCur.biHeight)
|| presets[j].cx < pcaps->MinOutputSize.cx
@@ -248,15 +263,17 @@ static void SetupMediaTypes(IAMStreamConfig* pAMSC, CFormatArray<T>& tfa, CCombo
|| presets[j].cy < pcaps->MinOutputSize.cy
|| presets[j].cy > pcaps->MaxOutputSize.cy
|| presets[j].cx % pcaps->OutputGranularityX
- || presets[j].cy % pcaps->OutputGranularityY)
+ || presets[j].cy % pcaps->OutputGranularityY) {
continue;
+ }
CMediaType mt = pfe->mt;
- if(mt.formattype == FORMAT_VideoInfo)
- {
+ if(mt.formattype == FORMAT_VideoInfo) {
VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)mt.pbFormat;
- if(!vih->bmiHeader.biHeight) vih->bmiHeader.biHeight = 1;
+ 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;
@@ -265,8 +282,7 @@ static void SetupMediaTypes(IAMStreamConfig* pAMSC, CFormatArray<T>& tfa, CCombo
CopyMediaType(pmt, &mt);
tfa.AddFormat(pmt, pcaps, sizeof(*pcaps));
- if(presets[j].cx*3 != presets[j].cy*4)
- {
+ 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];
@@ -284,11 +300,11 @@ static void SetupMediaTypes(IAMStreamConfig* pAMSC, CFormatArray<T>& tfa, CCombo
CopyMediaType(pmt, &mt);
tfa.AddFormat(pmt, pcaps, sizeof(*pcaps));
}
- }
- else if(mt.formattype == FORMAT_VideoInfo2)
- {
+ } else if(mt.formattype == FORMAT_VideoInfo2) {
VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*)mt.pbFormat;
- if(!vih2->bmiHeader.biHeight) vih2->bmiHeader.biHeight = 1;
+ 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;
@@ -304,26 +320,23 @@ static void SetupMediaTypes(IAMStreamConfig* pAMSC, CFormatArray<T>& tfa, CCombo
}
}
- if(tfa.GetCount() == 0)
- {
- if(pcurmt && (pcurmt->majortype == MEDIATYPE_Video || pcurmt->majortype == MEDIATYPE_Audio))
- {
+ 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
- {
+ } else {
mt.majortype = GUID_NULL;
- if(pcurmt) DeleteMediaType(pcurmt);
+ if(pcurmt) {
+ DeleteMediaType(pcurmt);
+ }
return;
}
}
- for(int i = 0; i < (int)tfa.GetCount(); i++)
- {
+ for(int i = 0; i < (int)tfa.GetCount(); i++) {
CFormat<T>* pf = tfa[i];
int j = type.AddString(pf->name);
type.SetItemData(j, (DWORD_PTR)pf);
@@ -332,39 +345,44 @@ static void SetupMediaTypes(IAMStreamConfig* pAMSC, CFormatArray<T>& tfa, CCombo
CFormat<T>* pf = NULL;
CFormatElem<T>* pfe = NULL;
- if(!pcurmt)
- {
+ 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);
+ } else if(!tfa.FindFormat(pcurmt, NULL, &pf, &pfe) && !tfa.FindFormat(pcurmt, &pf)) {
+ if(pcurmt) {
+ DeleteMediaType(pcurmt);
+ }
return;
}
- for(int i = 0; i < (int)pf->GetCount(); i++)
- {
+ for(int i = 0; i < (int)pf->GetCount(); 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);
+ 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);
+ // if(iDim < 0 && dim.GetCount()) dim.SetCurSel(iDim = 0);
CorrectComboListWidth(type, type.GetParent()->GetFont());
CorrectComboListWidth(dim, dim.GetParent()->GetFont());
- if(iDim >= 0) mt = ((CFormatElem<T>*)dim.GetItemData(iDim))->mt;
- else if(pcurmt) mt = *pcurmt;
+ 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);
+ if(pcurmt) {
+ DeleteMediaType(pcurmt);
+ }
}
template<class T>
@@ -377,12 +395,13 @@ static bool SetupDimension(CFormatArray<T>& tfa, CComboBox& type, CComboBox& dim
dim.EnableWindow(FALSE);
int iSel = type.GetCurSel();
- if(iSel < 0) return(false);
+ if(iSel < 0) {
+ return(false);
+ }
CFormat<T>* pf = (CFormat<T>*)type.GetItemData(iSel);
- for(int i = 0; i < (int)pf->GetCount(); i++)
- {
+ 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);
}
@@ -403,8 +422,7 @@ static void InitCodecList(CAtlArray<Codec>& codecs, CComboBox& box, const GUID&
box.SetItemData(box.AddString(_T("Uncompressed")), (DWORD_PTR)-1);
- BeginEnumSysDev(cat, pMoniker)
- {
+ BeginEnumSysDev(cat, pMoniker) {
Codec c;
c.pMoniker = pMoniker;
@@ -416,8 +434,9 @@ static void InitCodecList(CAtlArray<Codec>& codecs, CComboBox& box, const GUID&
c.pBF = pBF;
*/
LPOLESTR strName = NULL;
- if(FAILED(pMoniker->GetDisplayName(NULL, NULL, &strName)))
+ if(FAILED(pMoniker->GetDisplayName(NULL, NULL, &strName))) {
continue;
+ }
c.DisplayName = strName;
CoTaskMemFree(strName);
@@ -426,18 +445,20 @@ static void InitCodecList(CAtlArray<Codec>& codecs, CComboBox& box, const GUID&
pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB);
CComVariant var;
- if(FAILED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL)))
+ if(FAILED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL))) {
continue;
+ }
c.FriendlyName = var.bstrVal;
CStringW str = CStringW(c.DisplayName).MakeLower();
- if(str.Find(L"@device:dmo:") == 0)
+ if(str.Find(L"@device:dmo:") == 0) {
c.FriendlyName = _T("(DMO) ") + c.FriendlyName;
- else if(str.Find(L"@device:sw:") == 0)
+ } else if(str.Find(L"@device:sw:") == 0) {
c.FriendlyName = _T("(DS) ") + c.FriendlyName;
- else if(str.Find(L"@device:cm:") == 0)
+ } else if(str.Find(L"@device:cm:") == 0) {
c.FriendlyName = _T("(VfW) ") + c.FriendlyName;
+ }
box.SetItemData(
box.AddString(c.FriendlyName),
@@ -455,24 +476,25 @@ static void InitCodecList(CAtlArray<Codec>& codecs, CComboBox& box, const GUID&
static int ShowPPage(CAtlArray<Codec>& codecs, CComboBox& box, HWND hWnd = NULL)
{
int iSel = box.GetCurSel();
- if(iSel < 0) return(-1);
+ if(iSel < 0) {
+ return(-1);
+ }
iSel = box.GetItemData(iSel);
- if(iSel < 0) return(-1);
+ if(iSel < 0) {
+ return(-1);
+ }
Codec& c = codecs[iSel];
- if(!c.pBF)
- {
+ if(!c.pBF) {
c.pMoniker->BindToObject(NULL, NULL, __uuidof(IBaseFilter), (void**)&c.pBF);
}
- if(CComQIPtr<ISpecifyPropertyPages> pSPP = c.pBF)
- {
+ if(CComQIPtr<ISpecifyPropertyPages> pSPP = c.pBF) {
CAUUID caGUID;
caGUID.pElems = NULL;
- if(SUCCEEDED(pSPP->GetPages(&caGUID)))
- {
+ if(SUCCEEDED(pSPP->GetPages(&caGUID))) {
IUnknown* lpUnk = NULL;
pSPP.QueryInterface(&lpUnk);
OleCreatePropertyFrame(
@@ -482,13 +504,14 @@ static int ShowPPage(CAtlArray<Codec>& codecs, CComboBox& box, HWND hWnd = NULL)
0, 0, NULL);
lpUnk->Release();
- if(caGUID.pElems) CoTaskMemFree(caGUID.pElems);
+ if(caGUID.pElems) {
+ CoTaskMemFree(caGUID.pElems);
+ }
}
- }
- else if(CComQIPtr<IAMVfwCompressDialogs> pAMVfWCD = c.pBF)
- {
- if(pAMVfWCD->ShowDialog(VfwCompressDialog_QueryConfig, NULL) == S_OK)
+ } else if(CComQIPtr<IAMVfwCompressDialogs> pAMVfWCD = c.pBF) {
+ if(pAMVfWCD->ShowDialog(VfwCompressDialog_QueryConfig, NULL) == S_OK) {
pAMVfWCD->ShowDialog(VfwCompressDialog_Config, hWnd);
+ }
}
return(iSel);
@@ -522,8 +545,9 @@ CPlayerCaptureDialog::~CPlayerCaptureDialog()
BOOL CPlayerCaptureDialog::Create(CWnd* pParent)
{
- if(!__super::Create(IDD, pParent))
+ if(!__super::Create(IDD, pParent)) {
return FALSE;
+ }
EmptyVideo();
EmptyAudio();
@@ -571,13 +595,10 @@ void CPlayerCaptureDialog::DoDataExchange(CDataExchange* pDX)
BOOL CPlayerCaptureDialog::PreTranslateMessage(MSG* pMsg)
{
- if(pMsg->message == WM_KEYDOWN)
- {
- if(pMsg->wParam == VK_RETURN)
- {
+ if(pMsg->message == WM_KEYDOWN) {
+ if(pMsg->wParam == VK_RETURN) {
CWnd* pFocused = GetFocus();
- if(pFocused && pFocused->m_hWnd == m_vidfpsedit.m_hWnd)
- {
+ if(pFocused && pFocused->m_hWnd == m_vidfpsedit.m_hWnd) {
UpdateGraph();
}
}
@@ -591,8 +612,7 @@ void CPlayerCaptureDialog::EmptyVideo()
{
// first save channel from previous session
- if(m_pAMTuner && !m_VidDisplayName.IsEmpty())
- {
+ 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);
@@ -606,8 +626,7 @@ void CPlayerCaptureDialog::EmptyVideo()
m_pAMTuner = NULL;
m_pAMVSC = NULL;
- if(IsWindow(m_hWnd))
- {
+ if(IsWindow(m_hWnd)) {
m_vidinput.ResetContent();
m_vidinput.EnableWindow(FALSE);
m_vidtype.ResetContent();
@@ -632,8 +651,7 @@ void CPlayerCaptureDialog::EmptyAudio()
m_pAMASC = NULL;
m_pAMAIM.RemoveAll();
- if(IsWindow(m_hWnd))
- {
+ if(IsWindow(m_hWnd)) {
m_audinput.ResetContent();
m_audinput.EnableWindow(FALSE);
m_audtype.ResetContent();
@@ -652,11 +670,12 @@ void CPlayerCaptureDialog::UpdateMediaTypes()
CString fps;
m_vidfpsedit.GetWindowText(fps);
- if(!fps.IsEmpty())
- {
+ if(!fps.IsEmpty()) {
float ffps;
_stscanf_s(fps, _T("%f"), &ffps);
- if(ffps > 0) m_vidfps = ffps;
+ if(ffps > 0) {
+ m_vidfps = ffps;
+ }
}
// video
@@ -666,33 +685,28 @@ void CPlayerCaptureDialog::UpdateMediaTypes()
VIDEO_STREAM_CONFIG_CAPS* pcaps = NULL;
int i = m_viddimension.GetCurSel();
- if(i >= 0)
- {
+ 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)
- {
+ } else if(m_pAMVSC) {
m_pAMVSC->GetFormat(&pmt);
}
- if(pmt)
- {
- if(m_vidfps > 0)
- {
+ if(pmt) {
+ if(m_vidfps > 0) {
REFERENCE_TIME atpf = (REFERENCE_TIME)(10000000.0 / m_vidfps);
- if(pcaps)
- {
+ 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);
+ // atpf = min(max(atpf, pcaps->MinFrameInterval), pcaps->MaxFrameInterval);
}
- if(pmt->formattype == FORMAT_VideoInfo)
+ if(pmt->formattype == FORMAT_VideoInfo) {
((VIDEOINFOHEADER*)pmt->pbFormat)->AvgTimePerFrame = atpf;
- else if(pmt->formattype == FORMAT_VideoInfo2)
+ } else if(pmt->formattype == FORMAT_VideoInfo2) {
((VIDEOINFOHEADER2*)pmt->pbFormat)->AvgTimePerFrame = atpf;
+ }
}
BITMAPINFOHEADER* bih = (pmt->formattype == FORMAT_VideoInfo)
@@ -718,18 +732,14 @@ void CPlayerCaptureDialog::UpdateMediaTypes()
AM_MEDIA_TYPE* pmt = NULL;
int i = m_auddimension.GetCurSel();
- if(i >= 0)
- {
+ if(i >= 0) {
pmt = (AM_MEDIA_TYPE*)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
CopyMediaType(pmt, &((CAudFormatElem*)m_auddimension.GetItemData(i))->mt);
- }
- else if(m_pAMASC)
- {
+ } else if(m_pAMASC) {
m_pAMASC->GetFormat(&pmt);
}
- if(pmt)
- {
+ if(pmt) {
SaveMediaType(m_AudDisplayName, pmt);
m_mta = *pmt;
@@ -741,16 +751,24 @@ void CPlayerCaptureDialog::UpdateMediaTypes()
void CPlayerCaptureDialog::UpdateUserDefinableControls()
{
int iSel = m_viddimension.GetCurSel();
- if(iSel < 0) return;
+ if(iSel < 0) {
+ return;
+ }
CVidFormatElem* pvfe = (CVidFormatElem*)m_viddimension.GetItemData(iSel);
- if(!pvfe) return;
+ if(!pvfe) {
+ return;
+ }
- if(!m_pAMVSC) return;
+ if(!m_pAMVSC) {
+ return;
+ }
AM_MEDIA_TYPE* pmt = NULL;
m_pAMVSC->GetFormat(&pmt);
- if(!pmt) return;
+ if(!pmt) {
+ return;
+ }
BITMAPINFOHEADER* bih = (pmt->formattype == FORMAT_VideoInfo)
? &((VIDEOINFOHEADER*)pmt->pbFormat)->bmiHeader
@@ -758,7 +776,9 @@ void CPlayerCaptureDialog::UpdateUserDefinableControls()
? &((VIDEOINFOHEADER2*)pmt->pbFormat)->bmiHeader
: NULL;
- if(!bih) return;
+ if(!bih) {
+ return;
+ }
UDACCEL ua[3] = {{0,0},{2,0},{4,0}};
@@ -794,37 +814,41 @@ void CPlayerCaptureDialog::UpdateUserDefinableControls()
void CPlayerCaptureDialog::UpdateVideoCodec()
{
int iSel = m_vidcodec.GetCurSel();
- if(iSel >= 0) iSel = m_vidcodec.GetItemData(iSel);
+ 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;
-// CString DisplayName = iSel < 0 ? _T("") : CString(m_pVidEncArray[iSel].DisplayName.m_str);
+ // 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);
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);
+ 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;
-// CString DisplayName = iSel < 0 ? _T("") : CString(m_pAudEncArray[iSel].DisplayName.m_str);
+ // 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);
SaveDefaultCodec(m_pAudEncArray, m_audcodec, CLSID_AudioCompressorCategory);
-// SaveMediaType(DisplayName, &m_mtca);
+ // SaveMediaType(DisplayName, &m_mtca);
}
void CPlayerCaptureDialog::UpdateMuxer()
@@ -836,13 +860,21 @@ void CPlayerCaptureDialog::UpdateMuxer()
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_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);
+ if(m_fSepAudio) {
+ m_pAudMux = DNew CWavDestFilter(NULL, &hr);
+ }
}
void CPlayerCaptureDialog::UpdateOutputControls()
@@ -858,7 +890,7 @@ void CPlayerCaptureDialog::UpdateGraph()
{
UpdateMediaTypes();
-// UpdateMuxer();
+ // UpdateMuxer();
((CMainFrame*)AfxGetMainWnd())->BuildGraphVideoAudio(m_fVidPreview, false, m_fAudPreview, false);
@@ -867,28 +899,26 @@ void CPlayerCaptureDialog::UpdateGraph()
void CPlayerCaptureDialog::EnableControls(CWnd* pWnd, bool fEnable)
{
- if(fEnable)
- {
- for(CWnd* pChild = pWnd->GetWindow(GW_CHILD); pChild; pChild = pChild->GetNextWindow())
- {
+ if(fEnable) {
+ for(CWnd* pChild = pWnd->GetWindow(GW_CHILD); pChild; pChild = pChild->GetNextWindow()) {
BOOL fEnabled;
- if(m_wndenabledmap.Lookup(pChild->m_hWnd, fEnabled))
+ if(m_wndenabledmap.Lookup(pChild->m_hWnd, fEnabled)) {
pChild->EnableWindow(fEnabled);
+ }
EnableControls(pChild, fEnable);
}
- if(pWnd->m_hWnd == m_hWnd)
+ if(pWnd->m_hWnd == m_hWnd) {
m_wndenabledmap.RemoveAll();
+ }
m_recordbtn.SetWindowText(_T("Record"));
- }
- else
- {
- if(pWnd->m_hWnd == m_hWnd)
+ } else {
+ if(pWnd->m_hWnd == m_hWnd) {
m_wndenabledmap.RemoveAll();
+ }
- for(CWnd* pChild = pWnd->GetWindow(GW_CHILD); pChild; pChild = pChild->GetNextWindow())
- {
+ for(CWnd* pChild = pWnd->GetWindow(GW_CHILD); pChild; pChild = pChild->GetNextWindow()) {
m_wndenabledmap[pChild->m_hWnd] = pChild->IsWindowEnabled();
pChild->EnableWindow(FALSE);
EnableControls(pChild, fEnable);
@@ -907,68 +937,66 @@ void CPlayerCaptureDialog::SetupVideoControls(
// crossbar
- if(m_pAMXB = pAMXB)
- {
+ if(m_pAMXB = pAMXB) {
long OutputPinCount, InputPinCount;
- if(SUCCEEDED(pAMXB->get_PinCounts(&OutputPinCount, &InputPinCount)))
- {
- for(int i = 0; i < InputPinCount; i++)
- {
+ 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)))
+ if(FAILED(pAMXB->get_CrossbarPinInfo(TRUE, i, &PinIndexRelated, &PhysicalType))) {
continue;
+ }
- if(PhysicalType >= PhysConn_Audio_Tuner)
+ 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;
+ 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);
@@ -976,22 +1004,16 @@ void CPlayerCaptureDialog::SetupVideoControls(
}
}
- if(m_vidinput.GetCount() > 0)
- {
+ 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++)
- {
+ 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)
- {
+ 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;
@@ -1005,20 +1027,17 @@ void CPlayerCaptureDialog::SetupVideoControls(
// tuner
- if(m_pAMTuner = pAMTuner)
- {
+ if(m_pAMTuner = pAMTuner) {
// TODO:...
}
// streamconfig
- if(m_pAMVSC = pAMSC)
- {
+ if(m_pAMVSC = pAMSC) {
m_VidDisplayName = DisplayName;
AM_MEDIA_TYPE* pmt;
- if(LoadMediaType(DisplayName, &pmt))
- {
+ if(LoadMediaType(DisplayName, &pmt)) {
pAMSC->SetFormat(pmt);
DeleteMediaType(pmt);
}
@@ -1026,8 +1045,7 @@ void CPlayerCaptureDialog::SetupVideoControls(
SetupMediaTypes(pAMSC, m_vfa, m_vidtype, m_viddimension, m_mtv);
}
- if(m_vidtype.GetCount() > 0)
- {
+ if(m_vidtype.GetCount() > 0) {
m_vidfpsedit.EnableWindow(TRUE);
m_vidhor.EnableWindow(TRUE);
m_vidver.EnableWindow(TRUE);
@@ -1054,17 +1072,18 @@ void CPlayerCaptureDialog::SetupVideoControls(
{
EmptyVideo();
- if(m_pAMVfwCD = pAMVfwCD)
- {
- if(S_OK == m_pAMVfwCD->HasDialog(VfwCaptureDialog_Source))
+ 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))
+ }
+ 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))
+ }
+ 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)
- {
+ if(m_vidinput.GetCount() > 0) {
m_vidinput.EnableWindow(TRUE);
m_vidinput.SetCurSel(0);
}
@@ -1072,13 +1091,11 @@ void CPlayerCaptureDialog::SetupVideoControls(
// streamconfig
- if(m_pAMVSC = pAMSC)
- {
+ if(m_pAMVSC = pAMSC) {
m_VidDisplayName = DisplayName;
AM_MEDIA_TYPE* pmt;
- if(LoadMediaType(DisplayName, &pmt))
- {
+ if(LoadMediaType(DisplayName, &pmt)) {
pAMSC->SetFormat(pmt);
DeleteMediaType(pmt);
}
@@ -1086,8 +1103,7 @@ void CPlayerCaptureDialog::SetupVideoControls(
SetupMediaTypes(pAMSC, m_vfa, m_vidtype, m_viddimension, m_mtv);
}
- if(m_vidtype.GetCount() > 0)
- {
+ if(m_vidtype.GetCount() > 0) {
m_vidfpsedit.EnableWindow(TRUE);
m_vidhor.EnableWindow(TRUE);
m_vidver.EnableWindow(TRUE);
@@ -1116,28 +1132,24 @@ void CPlayerCaptureDialog::SetupAudioControls(
// input selection
- if(pAMAIM.GetCount() > 0)
- {
+ if(pAMAIM.GetCount() > 0) {
m_pAMAIM.Copy(pAMAIM);
int iSel = -1;
- for(int i = 0; i < (int)m_pAMAIM.GetCount(); i++)
- {
+ for(int i = 0; i < (int)m_pAMAIM.GetCount(); i++) {
CComQIPtr<IPin> pPin = m_pAMAIM[i];
m_audinput.SetItemData(m_audinput.AddString(CString(GetPinName(pPin))), (DWORD_PTR)i);
BOOL fEnable;
- if(SUCCEEDED(m_pAMAIM[i]->get_Enable(&fEnable)) && 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) == (DWORD_PTR)iSel)
- {
+ if(m_audinput.GetCount() > 0) {
+ for(int i = 0; i < m_audinput.GetCount(); i++) {
+ if(m_audinput.GetItemData(i) == (DWORD_PTR)iSel) {
m_audinput.SetCurSel(i);
break;
}
@@ -1149,13 +1161,11 @@ void CPlayerCaptureDialog::SetupAudioControls(
// stream config
- if(m_pAMASC = pAMSC)
- {
+ if(m_pAMASC = pAMSC) {
m_AudDisplayName = DisplayName;
AM_MEDIA_TYPE* pmt;
- if(LoadMediaType(DisplayName, &pmt))
- {
+ if(LoadMediaType(DisplayName, &pmt)) {
pAMSC->SetFormat(pmt);
DeleteMediaType(pmt);
}
@@ -1163,7 +1173,7 @@ void CPlayerCaptureDialog::SetupAudioControls(
SetupMediaTypes(pAMSC, m_afa, m_audtype, m_auddimension, m_mta);
}
-// if(m_audtype.GetCount() > 0)
+ // if(m_audtype.GetCount() > 0)
{
m_audoutput.EnableWindow(TRUE);
m_audpreview.EnableWindow(TRUE);
@@ -1179,9 +1189,13 @@ void CPlayerCaptureDialog::SetupAudioControls(
bool CPlayerCaptureDialog::IsTunerActive()
{
int iSel = m_vidinput.GetCurSel();
- if(iSel < 0) return(false);
+ if(iSel < 0) {
+ return(false);
+ }
iSel = m_vidinput.GetItemData(iSel);
- if(iSel < 0) return(false);
+ if(iSel < 0) {
+ return(false);
+ }
long PinIndexRelated, PhysicalType;
return(m_pAMXB
@@ -1191,12 +1205,12 @@ bool CPlayerCaptureDialog::IsTunerActive()
bool CPlayerCaptureDialog::SetVideoInput(int input)
{
- if(!m_pAMXB || input < 0) 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)
- {
+ for(int i = 0; i < m_vidinput.GetCount(); i++) {
+ if(m_vidinput.GetItemData(i) == (DWORD_PTR)input) {
m_vidinput.SetCurSel(i);
OnVideoInput();
return true;
@@ -1208,19 +1222,21 @@ bool CPlayerCaptureDialog::SetVideoInput(int input)
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));
}
bool CPlayerCaptureDialog::SetAudioInput(int input)
{
- if(input < 0) return false;
+ if(input < 0) {
+ return false;
+ }
- for(int i = 0; i < m_audinput.GetCount(); i++)
- {
- if(m_audinput.GetItemData(i) == (DWORD_PTR)input)
- {
+ for(int i = 0; i < m_audinput.GetCount(); i++) {
+ if(m_audinput.GetItemData(i) == (DWORD_PTR)input) {
m_audinput.SetCurSel(i);
OnAudioInput();
return true;
@@ -1233,7 +1249,9 @@ bool CPlayerCaptureDialog::SetAudioInput(int input)
int CPlayerCaptureDialog::GetVideoInput()
{
int i = m_vidinput.GetCurSel();
- if(i < 0) return -1;
+ if(i < 0) {
+ return -1;
+ }
return m_vidinput.GetItemData(i);
}
@@ -1246,7 +1264,9 @@ int CPlayerCaptureDialog::GetVideoChannel()
int CPlayerCaptureDialog::GetAudioInput()
{
int i = m_audinput.GetCurSel();
- if(i < 0) return -1;
+ if(i < 0) {
+ return -1;
+ }
return m_audinput.GetItemData(i);
}
@@ -1308,7 +1328,7 @@ BOOL CPlayerCaptureDialog::OnInitDialog()
m_muxctrl.AddString(_T("Matroska"));
m_muxctrl.AddString(_T("DirectShow Media"));
-// UpdateMuxer();
+ // UpdateMuxer();
UpdateData(FALSE);
@@ -1336,73 +1356,75 @@ void CPlayerCaptureDialog::OnDestroy()
void CPlayerCaptureDialog::OnVideoInput()
{
int iSel = m_vidinput.GetCurSel();
- if(iSel < 0) return;
+ if(iSel < 0) {
+ return;
+ }
iSel = m_vidinput.GetItemData(iSel);
- if(iSel < 0) return;
+ if(iSel < 0) {
+ return;
+ }
- if(m_pAMXB)
- {
+ if(m_pAMXB) {
long PinIndexRelated, PhysicalType;
- if(FAILED(m_pAMXB->get_CrossbarPinInfo(TRUE, iSel, &PinIndexRelated, &PhysicalType)))
+ if(FAILED(m_pAMXB->get_CrossbarPinInfo(TRUE, iSel, &PinIndexRelated, &PhysicalType))) {
return;
+ }
long OutputPinCount, InputPinCount;
- if(FAILED(m_pAMXB->get_PinCounts(&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))
- {
+ 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))
- {
+ 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))
- {
+ } 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)
- {
+ 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)
+ if(VFW_E_CANNOT_CONNECT == hr) {
UpdateGraph();
+ }
}
}
}
void CPlayerCaptureDialog::OnVideoType()
{
- if(SetupDimension(m_vfa, m_vidtype, m_viddimension))
+ if(SetupDimension(m_vfa, m_vidtype, m_viddimension)) {
OnVideoDimension();
+ }
}
void CPlayerCaptureDialog::OnVideoDimension()
{
int iSel = m_viddimension.GetCurSel();
- if(iSel < 0) return;
+ if(iSel < 0) {
+ return;
+ }
CVidFormatElem* pvfe = (CVidFormatElem*)m_viddimension.GetItemData(iSel);
- if(!pvfe) return;
+ if(!pvfe) {
+ return;
+ }
BITMAPINFOHEADER* bih = (pvfe->mt.formattype == FORMAT_VideoInfo)
? &((VIDEOINFOHEADER*)pvfe->mt.pbFormat)->bmiHeader
@@ -1430,16 +1452,16 @@ void CPlayerCaptureDialog::OnAudioInput()
{
int iSel = m_audinput.GetCurSel();
- for(int i = 0; i < (int)m_pAMAIM.GetCount(); i++)
- {
+ 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))
+ if(SetupDimension(m_afa, m_audtype, m_auddimension)) {
OnAudioDimension();
+ }
}
void CPlayerCaptureDialog::OnAudioDimension()
@@ -1460,15 +1482,15 @@ void CPlayerCaptureDialog::OnVideoCodec()
void CPlayerCaptureDialog::OnVideoCodecType()
{
- if(SetupDimension(m_vcfa, m_vidcodectype, m_vidcodecdimension))
+ if(SetupDimension(m_vcfa, m_vidcodectype, m_vidcodecdimension)) {
OnVideoCodecDimension();
+ }
}
void CPlayerCaptureDialog::OnVideoCodecDimension()
{
int i = m_vidcodecdimension.GetCurSel();
- if(i >= 0)
- {
+ 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
@@ -1490,15 +1512,15 @@ void CPlayerCaptureDialog::OnAudioCodec()
void CPlayerCaptureDialog::OnAudioCodecType()
{
- if(SetupDimension(m_acfa, m_audcodectype, m_audcodecdimension))
+ if(SetupDimension(m_acfa, m_audcodectype, m_audcodecdimension)) {
OnAudioCodecDimension();
+ }
}
void CPlayerCaptureDialog::OnAudioCodecDimension()
{
int i = m_audcodecdimension.GetCurSel();
- if(i >= 0)
- {
+ 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
@@ -1518,21 +1540,28 @@ void CPlayerCaptureDialog::OnOpenFile()
OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
_T("Media files (*.avi,*.ogm,*.mkv,*.dsm)|*.avi;*.ogm;*.mkv;*.dsm|"), this, 0);
- if(fd.DoModal() == IDOK)
- {
+ 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");
+ 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;
@@ -1548,19 +1577,17 @@ void CPlayerCaptureDialog::OnRecord()
UpdateData();
CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd();
- if(!pFrame) return;
+ if(!pFrame) {
+ return;
+ }
- if(!pFrame->m_fCapturing)
- {
+ if(!pFrame->m_fCapturing) {
UpdateMuxer();
CComQIPtr<IFileSinkFilter2> pFSF = m_pMux;
- if(pFSF)
- {
+ if(pFSF) {
m_pDst = m_pMux;
- }
- else
- {
+ } else {
m_pDst = NULL;
m_pDst.CoCreateInstance(CLSID_FileWriter);
pFSF = m_pDst;
@@ -1568,24 +1595,19 @@ void CPlayerCaptureDialog::OnRecord()
if(!pFSF
|| FAILED(pFSF->SetFileName(CStringW(m_file), NULL))
- || FAILED(pFSF->SetMode(AM_FILE_OVERWRITE)))
- {
+ || FAILED(pFSF->SetMode(AM_FILE_OVERWRITE))) {
AfxMessageBox(_T("Error initializing the output file"));
return;
}
CString audfn = m_file.Left(m_file.ReverseFind('.')+1);
- if(m_fSepAudio && m_fAudOutput && m_pAudMux && !audfn.IsEmpty())
- {
+ if(m_fSepAudio && m_fAudOutput && m_pAudMux && !audfn.IsEmpty()) {
audfn += _T("wav");
CComQIPtr<IFileSinkFilter2> pFSF = m_pAudMux;
- if(pFSF)
- {
+ if(pFSF) {
m_pAudDst = m_pAudMux;
- }
- else
- {
+ } else {
m_pAudDst = NULL;
m_pAudDst.CoCreateInstance(CLSID_FileWriter);
pFSF = m_pAudDst;
@@ -1593,23 +1615,20 @@ void CPlayerCaptureDialog::OnRecord()
if(!pFSF
|| FAILED(pFSF->SetFileName(CStringW(audfn), NULL))
- || FAILED(pFSF->SetMode(AM_FILE_OVERWRITE)))
- {
+ || FAILED(pFSF->SetMode(AM_FILE_OVERWRITE))) {
AfxMessageBox(_T("Error initializing the audio output file"));
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)
- {
+ 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)
- {
+ if(CComQIPtr<IBufferFilter> pAB = m_pAudBuffer) {
pAB->SetBuffers(m_nAudBuffers);
pAB->SetPriority(THREAD_PRIORITY_ABOVE_NORMAL);
}
@@ -1619,9 +1638,7 @@ void CPlayerCaptureDialog::OnRecord()
pFrame->StartCapture();
SetTimer(1, 100, NULL);
- }
- else
- {
+ } else {
KillTimer(1);
pFrame->StopCapture();
@@ -1657,14 +1674,11 @@ void CPlayerCaptureDialog::OnEnChangeEdit12()
void CPlayerCaptureDialog::OnTimer(UINT_PTR nIDEvent)
{
- if(nIDEvent == 1)
- {
- if(((CMainFrame*)AfxGetMainWnd())->m_fCapturing)
- {
+ 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)
- {
+ && FreeBytesAvailable.QuadPart < 1024i64*1024*10) {
OnRecord();
}
}
@@ -1681,7 +1695,7 @@ void CPlayerCaptureDialog::OnBnClickedVidAudPreview()
void CPlayerCaptureDialog::OnBnClickedCheck7()
{
-// UpdateMuxer();
+ // UpdateMuxer();
}
void CPlayerCaptureDialog::OnCbnSelchangeCombo14()
@@ -1690,14 +1704,15 @@ void CPlayerCaptureDialog::OnCbnSelchangeCombo14()
CString ext = m_file.Mid(m_file.ReverseFind('.')+1).MakeLower();
- if(m_muxtype == 0 && ext != _T("avi"))
+ 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"))
+ } 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"))
+ } 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"))
+ } else if(m_muxtype == 3 && ext != _T("dsm")) {
m_file = m_file.Left(m_file.GetLength()-4) + _T(".dsm");
+ }
UpdateData(FALSE);
diff --git a/src/apps/mplayerc/PlayerCaptureDialog.h b/src/apps/mplayerc/PlayerCaptureDialog.h
index 81abf677d..046953cf8 100644
--- a/src/apps/mplayerc/PlayerCaptureDialog.h
+++ b/src/apps/mplayerc/PlayerCaptureDialog.h
@@ -44,8 +44,7 @@ class CFormat : public CAutoPtrArray<CFormatElem<T> >
{
public:
CString name;
- CFormat(CString name = _T(""))
- {
+ CFormat(CString name = _T("")) {
this->name = name;
}
virtual ~CFormat() {}
@@ -57,16 +56,14 @@ class CFormatArray : public CAutoPtrArray<CFormat<T> >
public:
virtual ~CFormatArray() {}
- CFormat<T>* Find(CString name, bool fCreate = false)
- {
- for(int i = 0; i < (int)GetCount(); i++)
- {
- if(GetAt(i)->name == name)
+ CFormat<T>* Find(CString name, bool fCreate = false) {
+ for(int i = 0; i < (int)GetCount(); i++) {
+ if(GetAt(i)->name == name) {
return(GetAt(i));
+ }
}
- if(fCreate)
- {
+ if(fCreate) {
CAutoPtr<CFormat<T> > pf(DNew CFormat<T>(name));
CFormat<T>* tmp = pf;
Add(pf);
@@ -76,19 +73,19 @@ public:
return(NULL);
}
- bool FindFormat(AM_MEDIA_TYPE* pmt, CFormat<T>** ppf)
- {
- if(!pmt) return(false);
+ bool FindFormat(AM_MEDIA_TYPE* pmt, CFormat<T>** ppf) {
+ if(!pmt) {
+ return(false);
+ }
- for(int i = 0; i < (int)GetCount(); i++)
- {
+ for(int i = 0; i < (int)GetCount(); i++) {
CFormat<T>* pf = GetAt(i);
- for(int j = 0; j < (int)pf->GetCount(); j++)
- {
+ for(int j = 0; j < (int)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;
+ if(!pmt || (pfe->mt.majortype == pmt->majortype && pfe->mt.subtype == pmt->subtype)) {
+ if(ppf) {
+ *ppf = pf;
+ }
return(true);
}
}
@@ -97,20 +94,22 @@ public:
return(false);
}
- bool FindFormat(AM_MEDIA_TYPE* pmt, T* pcaps, CFormat<T>** ppf, CFormatElem<T>** ppfe)
- {
- if(!pmt && !pcaps) return(false);
+ bool FindFormat(AM_MEDIA_TYPE* pmt, T* pcaps, CFormat<T>** ppf, CFormatElem<T>** ppfe) {
+ if(!pmt && !pcaps) {
+ return(false);
+ }
- for(int i = 0; i < (int)GetCount(); i++)
- {
+ for(int i = 0; i < (int)GetCount(); i++) {
CFormat<T>* pf = GetAt(i);
- for(int j = 0; j < (int)pf->GetCount(); j++)
- {
+ for(int j = 0; j < (int)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;
+ if((!pmt || pfe->mt == *pmt) && (!pcaps || !memcmp(pcaps, &pfe->caps, sizeof(T)))) {
+ if(ppf) {
+ *ppf = pf;
+ }
+ if(ppfe) {
+ *ppfe = pfe;
+ }
return(true);
}
}
@@ -119,20 +118,19 @@ public:
return(false);
}
- bool AddFormat(AM_MEDIA_TYPE* pmt, T caps)
- {
- if(!pmt) return(false);
+ bool AddFormat(AM_MEDIA_TYPE* pmt, T caps) {
+ if(!pmt) {
+ return(false);
+ }
- if(FindFormat(pmt, NULL, NULL, NULL))
- {
+ if(FindFormat(pmt, NULL, NULL, NULL)) {
DeleteMediaType(pmt);
return(false);
}
-// if(pmt->formattype == FORMAT_VideoInfo2) {DeleteMediaType(pmt); return(false);} // TODO
+ // if(pmt->formattype == FORMAT_VideoInfo2) {DeleteMediaType(pmt); return(false);} // TODO
CFormat<T>* pf = Find(MakeFormatName(pmt), true);
- if(!pf)
- {
+ if(!pf) {
DeleteMediaType(pmt);
return(false);
}
@@ -145,9 +143,10 @@ public:
return(true);
}
- bool AddFormat(AM_MEDIA_TYPE* pmt, void* pcaps, int size)
- {
- if(!pcaps) return false;
+ bool AddFormat(AM_MEDIA_TYPE* pmt, void* pcaps, int size) {
+ if(!pcaps) {
+ return false;
+ }
ASSERT(size == sizeof(T));
return AddFormat(pmt, *(T*)pcaps);
}
@@ -162,11 +161,12 @@ typedef CFormat<VIDEO_STREAM_CONFIG_CAPS> CVidFormat;
class CVidFormatArray : public CFormatArray<VIDEO_STREAM_CONFIG_CAPS>
{
public:
- CString MakeFormatName(AM_MEDIA_TYPE* pmt)
- {
+ CString MakeFormatName(AM_MEDIA_TYPE* pmt) {
CString str(_T("Default"));
- if(!pmt) return(str);
+ if(!pmt) {
+ return(str);
+ }
BITMAPINFOHEADER* bih = (pmt->formattype == FORMAT_VideoInfo)
? &((VIDEOINFOHEADER*)pmt->pbFormat)->bmiHeader
@@ -174,16 +174,14 @@ public:
? &((VIDEOINFOHEADER2*)pmt->pbFormat)->bmiHeader
: NULL;
- if(!bih)
- {
+ 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)
- {
+ 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));
@@ -192,41 +190,41 @@ public:
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;
+ 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 MakeDimensionName(CVidFormatElem* pfe) {
CString str(_T("Default"));
- if(!pfe) return(str);
+ if(!pfe) {
+ return(str);
+ }
BITMAPINFOHEADER* bih = (pfe->mt.formattype == FORMAT_VideoInfo)
? &((VIDEOINFOHEADER*)pfe->mt.pbFormat)->bmiHeader
@@ -234,12 +232,13 @@ public:
? &((VIDEOINFOHEADER2*)pfe->mt.pbFormat)->bmiHeader
: NULL;
- if(bih == NULL) return(str);
+ 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)
- {
+ 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);
@@ -256,54 +255,55 @@ typedef CFormat<AUDIO_STREAM_CONFIG_CAPS> CAudFormat;
class CAudFormatArray : public CFormatArray<AUDIO_STREAM_CONFIG_CAPS>
{
public:
- CString MakeFormatName(AM_MEDIA_TYPE* pmt)
- {
+ CString MakeFormatName(AM_MEDIA_TYPE* pmt) {
CString str(_T("Unknown"));
- if(!pmt) return(str);
+ if(!pmt) {
+ return(str);
+ }
WAVEFORMATEX* wfe = (pmt->formattype == FORMAT_WaveFormatEx)
? (WAVEFORMATEX*)pmt->pbFormat
: NULL;
- if(!wfe)
- {
+ 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)
- {
+ 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;
+ 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 MakeDimensionName(CAudFormatElem* pfe) {
CString str(_T("Unknown"));
- if(!pfe) return(str);
+ if(!pfe) {
+ return(str);
+ }
WAVEFORMATEX* wfe = (pfe->mt.formattype == FORMAT_WaveFormatEx)
? (WAVEFORMATEX*)pfe->mt.pbFormat
: NULL;
- if(!wfe) return(str);
+ if(!wfe) {
+ return(str);
+ }
str.Empty();
CString str2;
@@ -314,18 +314,17 @@ public:
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;
+ 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);
@@ -337,8 +336,7 @@ public:
//
-typedef struct
-{
+typedef struct {
CComPtr<IMoniker> pMoniker;
CComPtr<IBaseFilter> pBF;
CString FriendlyName;
@@ -398,7 +396,7 @@ public:
BOOL Create(CWnd* pParent = NULL);
-// Dialog Data
+ // Dialog Data
enum { IDD = IDD_CAPTURE_DLG };
CComboBox m_vidinput;
diff --git a/src/apps/mplayerc/PlayerInfoBar.cpp b/src/apps/mplayerc/PlayerInfoBar.cpp
index 66d9d80c2..db31eb165 100644
--- a/src/apps/mplayerc/PlayerInfoBar.cpp
+++ b/src/apps/mplayerc/PlayerInfoBar.cpp
@@ -40,20 +40,19 @@ CPlayerInfoBar::~CPlayerInfoBar()
void CPlayerInfoBar::SetLine(CString label, CString info)
{
- if(info.IsEmpty())
- {
+ if(info.IsEmpty()) {
RemoveLine(label);
return;
}
- for(size_t idx = 0; idx < m_label.GetCount(); idx++)
- {
+ for(size_t idx = 0; idx < m_label.GetCount(); idx++) {
CString tmp;
m_label[idx]->GetWindowText(tmp);
- if(label == tmp)
- {
+ if(label == tmp) {
m_info[idx]->GetWindowText(tmp);
- if(info != tmp) m_info[idx]->SetWindowText(info);
+ if(info != tmp) {
+ m_info[idx]->SetWindowText(info);
+ }
return;
}
}
@@ -73,12 +72,10 @@ void CPlayerInfoBar::GetLine(CString label, CString& info)
{
info.Empty();
- for(size_t idx = 0; idx < m_label.GetCount(); idx++)
- {
+ for(size_t idx = 0; idx < m_label.GetCount(); idx++) {
CString tmp;
m_label[idx]->GetWindowText(tmp);
- if(label == tmp)
- {
+ if(label == tmp) {
m_info[idx]->GetWindowText(tmp);
info = tmp;
return;
@@ -88,12 +85,10 @@ void CPlayerInfoBar::GetLine(CString label, CString& info)
void CPlayerInfoBar::RemoveLine(CString label)
{
- for(size_t i = 0; i < m_label.GetCount(); i++)
- {
+ for(size_t i = 0; i < m_label.GetCount(); i++) {
CString tmp;
m_label[i]->GetWindowText(tmp);
- if(label == tmp)
- {
+ if(label == tmp) {
m_label.RemoveAt(i);
m_info.RemoveAt(i);
break;
@@ -118,8 +113,9 @@ BOOL CPlayerInfoBar::Create(CWnd* pParentWnd)
BOOL CPlayerInfoBar::PreCreateWindow(CREATESTRUCT& cs)
{
- if(!CDialogBar::PreCreateWindow(cs))
+ if(!CDialogBar::PreCreateWindow(cs)) {
return FALSE;
+ }
m_dwStyle &= ~CBRS_BORDER_TOP;
m_dwStyle &= ~CBRS_BORDER_BOTTOM;
@@ -142,8 +138,7 @@ void CPlayerInfoBar::Relayout()
int w = m_nFirstColWidth, h = 17, y = 2;
- for(size_t i = 0; i < m_label.GetCount(); i++)
- {
+ for(size_t i = 0; i < m_label.GetCount(); i++) {
CDC* pDC = m_label[i]->GetDC();
CString str;
m_label[i]->GetWindowText(str);
@@ -151,8 +146,7 @@ void CPlayerInfoBar::Relayout()
m_label[i]->ReleaseDC(pDC);
}
- for(size_t i = 0; i < m_label.GetCount(); i++, y += h)
- {
+ 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);
}
@@ -170,8 +164,7 @@ END_MESSAGE_MAP()
BOOL CPlayerInfoBar::OnEraseBkgnd(CDC* pDC)
{
- for(CWnd* pChild = GetWindow(GW_CHILD); pChild; pChild = pChild->GetNextWindow())
- {
+ for(CWnd* pChild = GetWindow(GW_CHILD); pChild; pChild = pChild->GetNextWindow()) {
CRect r;
pChild->GetClientRect(&r);
pChild->MapWindowPoints(this, &r);
@@ -183,11 +176,13 @@ BOOL CPlayerInfoBar::OnEraseBkgnd(CDC* pDC)
CMainFrame* pFrame = ((CMainFrame*)GetParentFrame());
- if(pFrame->m_pLastBar != this || pFrame->m_fFullScreen)
+ if(pFrame->m_pLastBar != this || pFrame->m_fFullScreen) {
r.InflateRect(0, 0, 0, 1);
+ }
- if(pFrame->m_fFullScreen)
+ if(pFrame->m_fFullScreen) {
r.InflateRect(1, 0, 1, 0);
+ }
pDC->Draw3dRect(&r, GetSysColor(COLOR_3DSHADOW), GetSysColor(COLOR_3DHILIGHT));
@@ -210,8 +205,7 @@ void CPlayerInfoBar::OnSize(UINT nType, int cx, int cy)
void CPlayerInfoBar::OnLButtonDown(UINT nFlags, CPoint point)
{
CMainFrame* pFrame = ((CMainFrame*)GetParentFrame());
- if(!pFrame->m_fFullScreen)
- {
+ if(!pFrame->m_fFullScreen) {
MapWindowPoints(pFrame, &point, 1);
pFrame->PostMessage(WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM(point.x, point.y));
}
diff --git a/src/apps/mplayerc/PlayerListCtrl.cpp b/src/apps/mplayerc/PlayerListCtrl.cpp
index 6e93c2d38..c1c6fdce7 100644
--- a/src/apps/mplayerc/PlayerListCtrl.cpp
+++ b/src/apps/mplayerc/PlayerListCtrl.cpp
@@ -54,13 +54,11 @@ END_MESSAGE_MAP()
BOOL CInPlaceEdit::PreTranslateMessage(MSG* pMsg)
{
- if(pMsg->message == WM_KEYDOWN)
- {
+ if(pMsg->message == WM_KEYDOWN) {
if(pMsg->wParam == VK_RETURN
|| pMsg->wParam == VK_DELETE
|| pMsg->wParam == VK_ESCAPE
- || GetKeyState(VK_CONTROL))
- {
+ || GetKeyState(VK_CONTROL)) {
::TranslateMessage(pMsg);
::DispatchMessage(pMsg);
return TRUE; // DO NOT process further
@@ -101,9 +99,10 @@ void CInPlaceEdit::OnNcDestroy()
void CInPlaceEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
- if(nChar == VK_ESCAPE || nChar == VK_RETURN)
- {
- if(nChar == VK_ESCAPE) m_bESC = TRUE;
+ if(nChar == VK_ESCAPE || nChar == VK_RETURN) {
+ if(nChar == VK_ESCAPE) {
+ m_bESC = TRUE;
+ }
GetParent()->SetFocus();
return;
}
@@ -113,8 +112,9 @@ void CInPlaceEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
int CInPlaceEdit::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
- if(CEdit::OnCreate(lpCreateStruct) == -1)
+ if(CEdit::OnCreate(lpCreateStruct) == -1) {
return -1;
+ }
// Set the proper font
CFont* font = GetParent()->GetFont();
@@ -157,15 +157,17 @@ END_MESSAGE_MAP()
int CInPlaceComboBox::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
- if (CComboBox::OnCreate(lpCreateStruct) == -1)
+ if (CComboBox::OnCreate(lpCreateStruct) == -1) {
return -1;
+ }
// Set the proper font
CFont* font = GetParent()->GetFont();
SetFont(font);
- for(POSITION pos = m_lstItems.GetHeadPosition(); pos != NULL;)
+ for(POSITION pos = m_lstItems.GetHeadPosition(); pos != NULL;) {
AddString((LPCTSTR)(m_lstItems.GetNext(pos)));
+ }
SetFocus();
SetCurSel(m_nSel);
@@ -174,11 +176,9 @@ int CInPlaceComboBox::OnCreate(LPCREATESTRUCT lpCreateStruct)
BOOL CInPlaceComboBox::PreTranslateMessage(MSG* pMsg)
{
- if(pMsg->message == WM_KEYDOWN)
- {
+ if(pMsg->message == WM_KEYDOWN) {
if(pMsg->wParam == VK_RETURN
- || pMsg->wParam == VK_ESCAPE)
- {
+ || pMsg->wParam == VK_ESCAPE) {
::TranslateMessage(pMsg);
::DispatchMessage(pMsg);
return TRUE; // DO NOT process further
@@ -212,9 +212,10 @@ void CInPlaceComboBox::OnKillFocus(CWnd* pNewWnd)
void CInPlaceComboBox::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
- if(nChar == VK_ESCAPE || nChar == VK_RETURN)
- {
- if(nChar == VK_ESCAPE) m_bESC = TRUE;
+ if(nChar == VK_ESCAPE || nChar == VK_RETURN) {
+ if(nChar == VK_ESCAPE) {
+ m_bESC = TRUE;
+ }
GetParent()->SetFocus();
return;
}
@@ -264,15 +265,15 @@ END_MESSAGE_MAP()
int CInPlaceListBox::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
- if(CListBox::OnCreate(lpCreateStruct) == -1)
+ 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;)
- {
+ for(POSITION pos = m_lstItems.GetHeadPosition(); pos != NULL;) {
AddString( (LPCTSTR) (m_lstItems.GetNext( pos )) );
}
SetCurSel( m_nSel );
@@ -282,11 +283,9 @@ int CInPlaceListBox::OnCreate(LPCREATESTRUCT lpCreateStruct)
BOOL CInPlaceListBox::PreTranslateMessage(MSG* pMsg)
{
- if(pMsg->message == WM_KEYDOWN)
- {
+ if(pMsg->message == WM_KEYDOWN) {
if(pMsg->wParam == VK_RETURN
- || pMsg->wParam == VK_ESCAPE)
- {
+ || pMsg->wParam == VK_ESCAPE) {
::TranslateMessage(pMsg);
::DispatchMessage(pMsg);
return TRUE; // DO NOT process further
@@ -320,9 +319,10 @@ void CInPlaceListBox::OnKillFocus(CWnd* pNewWnd)
void CInPlaceListBox::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
- if(nChar == VK_ESCAPE || nChar == VK_RETURN)
- {
- if(nChar == VK_ESCAPE) m_bESC = TRUE;
+ if(nChar == VK_ESCAPE || nChar == VK_RETURN) {
+ if(nChar == VK_ESCAPE) {
+ m_bESC = TRUE;
+ }
GetParent()->SetFocus();
return;
}
@@ -361,29 +361,30 @@ void CPlayerListCtrl::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);
- if((GetWindowLong(m_hWnd, GWL_STYLE) & LVS_TYPEMASK) != LVS_REPORT)
+ if((GetWindowLong(m_hWnd, GWL_STYLE) & LVS_TYPEMASK) != LVS_REPORT) {
return row;
+ }
int nColumnCount = ((CHeaderCtrl*)GetDlgItem(0))->GetItemCount();
- for(int top = GetTopIndex(), bottom = GetBottomIndex(); top <= bottom; top++)
- {
+ 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++)
- {
+ 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;
+ if(point.x >= r.left && point.x <= (r.left + colwidth)) {
+ if(col) {
+ *col = colnum;
+ }
return top;
}
@@ -402,17 +403,15 @@ int CPlayerListCtrl::GetBottomIndex() const
int nBottomIndex = GetTopIndex() + GetCountPerPage() - 1;
- if(nBottomIndex >= GetItemCount())
- {
+ if(nBottomIndex >= GetItemCount()) {
nBottomIndex = GetItemCount() - 1;
- }
- else if(nBottomIndex < GetItemCount())
- {
+ } else if(nBottomIndex < GetItemCount()) {
CRect br;
GetItemRect(nBottomIndex, br, LVIR_BOUNDS);
- if(br.bottom < r.bottom)
+ if(br.bottom < r.bottom) {
nBottomIndex++;
+ }
}
return(nBottomIndex);
@@ -420,8 +419,9 @@ int CPlayerListCtrl::GetBottomIndex() const
CImageList* CPlayerListCtrl::CreateDragImageEx(LPPOINT lpPoint)
{
- if(GetSelectedCount() <= 0)
+ if(GetSelectedCount() <= 0) {
return NULL;
+ }
CRect cSingleRect, cCompleteRect(0, 0, 0, 0);
GetClientRect(cSingleRect);
@@ -433,16 +433,19 @@ CImageList* CPlayerListCtrl::CreateDragImageEx(LPPOINT lpPoint)
// Determine the size of the drag image (limited for
// rows visible and Client width)
- while((nIndex = GetNextItem(nIndex, LVNI_SELECTED)) != -1 && nIndex <= nBottomIndex)
- {
+ 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;
+ if(cSingleRect.left < 0) {
+ cSingleRect.left = 0;
+ }
+ if(cSingleRect.right > nWidth) {
+ cSingleRect.right = nWidth;
+ }
cCompleteRect |= cSingleRect;
}
@@ -454,11 +457,13 @@ CImageList* CPlayerListCtrl::CreateDragImageEx(LPPOINT lpPoint)
CDC cMemDC;
CBitmap cBitmap;
- if(!cMemDC.CreateCompatibleDC(&cDc))
+ if(!cMemDC.CreateCompatibleDC(&cDc)) {
return NULL;
+ }
- if(!cBitmap.CreateCompatibleBitmap(&cDc, cCompleteRect.Width(), cCompleteRect.Height()))
+ if(!cBitmap.CreateCompatibleBitmap(&cDc, cCompleteRect.Width(), cCompleteRect.Height())) {
return NULL;
+ }
CBitmap* pOldMemDCBitmap = cMemDC.SelectObject(&cBitmap);
// Here green is used as mask color
@@ -466,13 +471,11 @@ CImageList* CPlayerListCtrl::CreateDragImageEx(LPPOINT lpPoint)
// Paint each DragImage in the DC
nIndex = GetTopIndex() - 1;
- while((nIndex = GetNextItem(nIndex, LVNI_SELECTED)) != -1 && nIndex <= nBottomIndex)
- {
+ while((nIndex = GetNextItem(nIndex, LVNI_SELECTED)) != -1 && nIndex <= nBottomIndex) {
CPoint pt;
CImageList* pSingleImageList = CreateDragImage(nIndex, &pt);
- if(pSingleImageList)
- {
+ if(pSingleImageList) {
GetItemRect(nIndex, cSingleRect, LVIR_BOUNDS);
pSingleImageList->Draw(&cMemDC,
@@ -504,8 +507,7 @@ CImageList* CPlayerListCtrl::CreateDragImageEx(LPPOINT lpPoint)
// Find the offset of the current mouse cursor to the image list
// this we can use in BeginDrag()
//
- if(lpPoint)
- {
+ if(lpPoint) {
lpPoint->x = cCompleteRect.left;
lpPoint->y = cCompleteRect.top;
}
@@ -515,20 +517,25 @@ CImageList* CPlayerListCtrl::CreateDragImageEx(LPPOINT lpPoint)
bool CPlayerListCtrl::PrepareInPlaceControl(int nRow, int nCol, CRect& rect)
{
- if(!EnsureVisible(nRow, TRUE)) return(false);
+ if(!EnsureVisible(nRow, TRUE)) {
+ return(false);
+ }
int nColumnCount = ((CHeaderCtrl*)GetDlgItem(0))->GetItemCount();
- if(nCol >= nColumnCount || GetColumnWidth(nCol) < 5) return(false);
+ if(nCol >= nColumnCount || GetColumnWidth(nCol) < 5) {
+ return(false);
+ }
int offset = 0;
- for(int i = 0; i < nCol; i++) offset += GetColumnWidth(i);
+ 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)
- {
+ if(offset + rect.left < 0 || offset + rect.left > rcClient.right) {
CSize size(offset + rect.left, 0);
Scroll(size);
rect.left -= size.cx;
@@ -536,12 +543,13 @@ bool CPlayerListCtrl::PrepareInPlaceControl(int nRow, int nCol, CRect& rect)
rect.left += offset;
rect.right = rect.left + GetColumnWidth(nCol);
- if(rect.right > rcClient.right) rect.right = rcClient.right;
+ if(rect.right > rcClient.right) {
+ rect.right = rcClient.right;
+ }
rect.DeflateRect(1, 0, 0, 1);
- if(nCol == 0)
- {
+ if(nCol == 0) {
CRect r;
GetItemRect(nRow, r, LVIR_LABEL);
rect.left = r.left-1;
@@ -553,8 +561,9 @@ bool CPlayerListCtrl::PrepareInPlaceControl(int nRow, int nCol, CRect& rect)
CEdit* CPlayerListCtrl::ShowInPlaceEdit(int nItem, int nCol)
{
CRect rect;
- if(!PrepareInPlaceControl(nItem, nCol, rect))
+ if(!PrepareInPlaceControl(nItem, nCol, rect)) {
return(NULL);
+ }
DWORD dwStyle = /*WS_BORDER|*/WS_CHILD|WS_VISIBLE|ES_AUTOHSCROLL;
@@ -576,8 +585,9 @@ CEdit* CPlayerListCtrl::ShowInPlaceEdit(int nItem, int nCol)
CComboBox* CPlayerListCtrl::ShowInPlaceComboBox(int nItem, int nCol, CAtlList<CString>& lstItems, int nSel, bool bShowDropDown)
{
CRect rect;
- if(!PrepareInPlaceControl(nItem, nCol, 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*/;
@@ -587,10 +597,13 @@ CComboBox* CPlayerListCtrl::ShowInPlaceComboBox(int nItem, int nCol, CAtlList<CS
CorrectComboListWidth(*pComboBox, GetFont());
int width = GetColumnWidth(nCol);
- if(pComboBox->GetDroppedWidth() < width)
+ if(pComboBox->GetDroppedWidth() < width) {
pComboBox->SetDroppedWidth(width);
+ }
- if (bShowDropDown) pComboBox->ShowDropDown();
+ if (bShowDropDown) {
+ pComboBox->ShowDropDown();
+ }
m_fInPlaceDirty = false;
@@ -600,8 +613,9 @@ CComboBox* CPlayerListCtrl::ShowInPlaceComboBox(int nItem, int nCol, CAtlList<CS
CListBox* CPlayerListCtrl::ShowInPlaceListBox(int nItem, int nCol, CAtlList<CString>& lstItems, int nSel)
{
CRect rect;
- if(!PrepareInPlaceControl(nItem, nCol, 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);
@@ -617,10 +631,11 @@ CListBox* CPlayerListCtrl::ShowInPlaceListBox(int nItem, int nCol, CAtlList<CStr
pDC->SelectObject(pWndFont);
int width = GetColumnWidth(nCol);
POSITION pos = lstItems.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
int w = pDC->GetTextExtent(lstItems.GetNext(pos)).cx + 16;
- if(width < w) width = w;
+ if(width < w) {
+ width = w;
+ }
}
ReleaseDC(pDC);
@@ -660,19 +675,25 @@ END_MESSAGE_MAP()
void CPlayerListCtrl::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
- if(GetFocus() != this) SetFocus();
+ if(GetFocus() != this) {
+ SetFocus();
+ }
CListCtrl::OnVScroll(nSBCode, nPos, pScrollBar);
}
void CPlayerListCtrl::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
- if(GetFocus() != this) SetFocus();
+ if(GetFocus() != this) {
+ SetFocus();
+ }
CListCtrl::OnHScroll(nSBCode, nPos, pScrollBar);
}
BOOL CPlayerListCtrl::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
{
- if(GetFocus() != this) SetFocus();
+ if(GetFocus() != this) {
+ SetFocus();
+ }
return CListCtrl::OnMouseWheel(nFlags, zDelta, pt);
}
@@ -680,18 +701,17 @@ void CPlayerListCtrl::OnLButtonDown(UINT nFlags, CPoint point)
{
CListCtrl::OnLButtonDown(nFlags, point);
- if(GetFocus() != this) SetFocus();
+ if(GetFocus() != this) {
+ SetFocus();
+ }
KillTimer(1);
int m_nItemClickedNow, m_nSubItemClickedNow;
- if((m_nItemClickedNow = HitTestEx(point, &m_nSubItemClickedNow)) < 0)
- {
+ if((m_nItemClickedNow = HitTestEx(point, &m_nSubItemClickedNow)) < 0) {
m_nItemClicked = -1;
- }
- else if(m_nItemClicked == m_nItemClickedNow /*&& m_nSubItemClicked == m_nSubItemClickedNow*/)
- {
+ } else if(m_nItemClicked == m_nItemClickedNow /*&& m_nSubItemClicked == m_nSubItemClickedNow*/) {
m_nSubItemClicked = m_nSubItemClickedNow;
LV_DISPINFO dispinfo;
@@ -701,21 +721,15 @@ void CPlayerListCtrl::OnLButtonDown(UINT nFlags, CPoint point)
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)
- {
+ if(GetParent()->SendMessage(WM_NOTIFY, GetDlgCtrlID(), (LPARAM)&dispinfo)) {
+ if(m_tStartEditingDelay > 0) {
SetTimer(1, m_tStartEditingDelay, NULL);
- }
- else
- {
+ } else {
dispinfo.hdr.code = LVN_DOLABELEDIT;
GetParent()->SendMessage(WM_NOTIFY, GetDlgCtrlID(), (LPARAM)&dispinfo);
}
}
- }
- else
- {
+ } else {
m_nItemClicked = m_nItemClickedNow;
m_nSubItemClicked = m_nSubItemClickedNow;
@@ -725,13 +739,11 @@ void CPlayerListCtrl::OnLButtonDown(UINT nFlags, CPoint point)
void CPlayerListCtrl::OnTimer(UINT_PTR nIDEvent)
{
- if(nIDEvent == 1)
- {
+ if(nIDEvent == 1) {
KillTimer(1);
UINT flag = LVIS_FOCUSED;
- if((GetItemState(m_nItemClicked, flag) & flag) == flag && m_nSubItemClicked >= 0)
- {
+ if((GetItemState(m_nItemClicked, flag) & flag) == flag && m_nSubItemClicked >= 0) {
LV_DISPINFO dispinfo;
dispinfo.hdr.hwndFrom = m_hWnd;
dispinfo.hdr.idFrom = GetDlgCtrlID();
@@ -810,7 +822,7 @@ BOOL CPlayerListCtrl::OnHdnItemchanging(UINT id, NMHDR* pNMHDR, LRESULT* pResult
{
LPNMHEADER phdr = reinterpret_cast<LPNMHEADER>(pNMHDR);
UNUSED_ALWAYS(phdr);
-// SetFocus();
+ // SetFocus();
*pResult = 0;
return FALSE;
}
@@ -819,8 +831,9 @@ INT_PTR CPlayerListCtrl::OnToolHitTest(CPoint point, TOOLINFO* pTI) const
{
int col;
int row = HitTestEx(point, &col);
- if(row == -1)
+ if(row == -1) {
return -1;
+ }
CHeaderCtrl* pHeader = (CHeaderCtrl*)GetDlgItem(0);
int nColumnCount = pHeader->GetItemCount();
@@ -828,12 +841,10 @@ INT_PTR CPlayerListCtrl::OnToolHitTest(CPoint point, TOOLINFO* pTI) const
CRect rect;
GetItemRect(row, &rect, LVIR_BOUNDS);
- for(int colnum = 0; colnum < nColumnCount; colnum++)
- {
+ for(int colnum = 0; colnum < nColumnCount; colnum++) {
int colwidth = GetColumnWidth(colnum);
- if(colnum == col)
- {
+ if(colnum == col) {
rect.right = rect.left + colwidth;
break;
}
@@ -855,17 +866,18 @@ BOOL CPlayerListCtrl::OnToolTipNotify(UINT id, NMHDR* pNMHDR, LRESULT* pResult)
UINT nID = pNMHDR->idFrom;
- if (pNMHDR->code == TTN_NEEDTEXTW && (pTTTW->uFlags & TTF_IDISHWND))
- {
+ if (pNMHDR->code == TTN_NEEDTEXTW && (pTTTW->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
+ }
- if(pNMHDR->code == TTN_NEEDTEXTW) //?possible check is not needed
+ if(pNMHDR->code == TTN_NEEDTEXTW) { //?possible check is not needed
pTTTW->lParam = (LPARAM)m_hWnd;
+ }
*pResult = 0;
diff --git a/src/apps/mplayerc/PlayerNavigationBar.cpp b/src/apps/mplayerc/PlayerNavigationBar.cpp
index 921b61fc4..c8e1710a0 100644
--- a/src/apps/mplayerc/PlayerNavigationBar.cpp
+++ b/src/apps/mplayerc/PlayerNavigationBar.cpp
@@ -40,8 +40,9 @@ CPlayerNavigationBar::~CPlayerNavigationBar()
BOOL CPlayerNavigationBar::Create(CWnd* pParentWnd)
{
- if(!baseCPlayerNavigationBar::Create(_T("Navigation bar"), pParentWnd, ID_VIEW_NAVIGATION))
+ if(!baseCPlayerNavigationBar::Create(_T("Navigation bar"), pParentWnd, ID_VIEW_NAVIGATION)) {
return FALSE;
+ }
m_pParent = pParentWnd;
m_navdlg.Create(this);
@@ -60,10 +61,10 @@ BOOL CPlayerNavigationBar::Create(CWnd* pParentWnd)
BOOL CPlayerNavigationBar::PreTranslateMessage(MSG* pMsg)
{
- if(IsWindow(pMsg->hwnd) && IsVisible() && pMsg->message >= WM_KEYFIRST && pMsg->message <= WM_KEYLAST)
- {
- if(IsDialogMessage(pMsg))
+ if(IsWindow(pMsg->hwnd) && IsVisible() && pMsg->message >= WM_KEYFIRST && pMsg->message <= WM_KEYLAST) {
+ if(IsDialogMessage(pMsg)) {
return TRUE;
+ }
}
return __super::PreTranslateMessage(pMsg);
@@ -80,8 +81,7 @@ void CPlayerNavigationBar::OnSize(UINT nType, int cx, int cy)
{
__super::OnSize(nType, cx, cy);
- if(::IsWindow(m_navdlg.m_hWnd))
- {
+ if(::IsWindow(m_navdlg.m_hWnd)) {
CRect r;
GetClientRect(r);
m_navdlg.MoveWindow(r);
@@ -113,8 +113,9 @@ void CPlayerNavigationBar::OnNcLButtonUp(UINT nHitTest, CPoint point)
{
__super::OnNcLButtonUp(nHitTest, point);
- if (nHitTest == HTCLOSE)
+ if (nHitTest == HTCLOSE) {
AfxGetAppSettings().fHideNavigation = true;
+ }
}
diff --git a/src/apps/mplayerc/PlayerNavigationDialog.cpp b/src/apps/mplayerc/PlayerNavigationDialog.cpp
index 6e4a84c73..9e731371b 100644
--- a/src/apps/mplayerc/PlayerNavigationDialog.cpp
+++ b/src/apps/mplayerc/PlayerNavigationDialog.cpp
@@ -43,8 +43,9 @@ CPlayerNavigationDialog::~CPlayerNavigationDialog()
BOOL CPlayerNavigationDialog::Create(CWnd* pParent)
{
- if(!__super::Create(IDD, pParent))
+ if(!__super::Create(IDD, pParent)) {
return FALSE;
+ }
m_pParent = pParent;
return TRUE;
}
@@ -62,13 +63,12 @@ void CPlayerNavigationDialog::DoDataExchange(CDataExchange* pDX)
BOOL CPlayerNavigationDialog::PreTranslateMessage(MSG* pMsg)
{
- if(pMsg->message == WM_KEYDOWN)
- {
- if(pMsg->wParam == VK_RETURN)
- {
+ if(pMsg->message == WM_KEYDOWN) {
+ if(pMsg->wParam == VK_RETURN) {
CWnd* pFocused = GetFocus();
- if (pFocused && pFocused->m_hWnd == m_ChannelList.m_hWnd)
+ if (pFocused && pFocused->m_hWnd == m_ChannelList.m_hWnd) {
return TRUE;
+ }
}
}
return __super::PreTranslateMessage(pMsg);
@@ -119,15 +119,12 @@ void CPlayerNavigationDialog::SetupAudioSwitcherSubMenu(CDVBChannel* pChannel)
int nCurrentChannel;
AppSettings& s = AfxGetAppSettings();
- if (!pChannel)
- {
+ if (!pChannel) {
nCurrentChannel = s.nDVBLastChannel;
POSITION pos = s.m_DVBChannels.GetHeadPosition();
- while (pos && !bFound)
- {
+ while (pos && !bFound) {
pChannel = &s.m_DVBChannels.GetNext(pos);
- if (nCurrentChannel == pChannel->GetPrefNumber())
- {
+ if (nCurrentChannel == pChannel->GetPrefNumber()) {
bFound = TRUE;
break;
}
@@ -136,8 +133,7 @@ void CPlayerNavigationDialog::SetupAudioSwitcherSubMenu(CDVBChannel* pChannel)
m_ButtonInfo.EnableWindow(pChannel->GetNowNextFlag());
m_ComboAudio.ResetContent();
- for (int i=0; i < pChannel->GetAudioCount(); i++)
- {
+ 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;
@@ -154,24 +150,21 @@ void CPlayerNavigationDialog::UpdateElementList()
int nCurrentChannel;
AppSettings& s = AfxGetAppSettings();
- if (s.iDefaultCaptureDevice == 1)
- {
+ if (s.iDefaultCaptureDevice == 1) {
m_ChannelList.ResetContent();
nCurrentChannel = s.nDVBLastChannel;
POSITION pos = s.m_DVBChannels.GetHeadPosition();
- while (pos)
- {
+ while (pos) {
CDVBChannel& Channel = s.m_DVBChannels.GetNext(pos);
if ((m_bTVStations && (Channel.GetVideoPID() != 0)) ||
- (!m_bTVStations && (Channel.GetAudioCount() > 0)) && (Channel.GetVideoPID() == 0))
- {
+ (!m_bTVStations && (Channel.GetAudioCount() > 0)) && (Channel.GetVideoPID() == 0)) {
nItem = m_ChannelList.AddString (Channel.GetName());
- if (nItem < MAX_CHANNELS_ALLOWED)
+ if (nItem < MAX_CHANNELS_ALLOWED) {
p_nItems [nItem] = Channel.GetPrefNumber();
- if (nCurrentChannel == Channel.GetPrefNumber())
- {
+ }
+ if (nCurrentChannel == Channel.GetPrefNumber()) {
m_ChannelList.SetCurSel(nItem);
SetupAudioSwitcherSubMenu(&Channel);
}
@@ -183,10 +176,8 @@ void CPlayerNavigationDialog::UpdateElementList()
void CPlayerNavigationDialog::UpdatePos(int nID)
{
- for (int i=0; i < MAX_CHANNELS_ALLOWED; i++)
- {
- if (p_nItems [i] == nID)
- {
+ for (int i=0; i < MAX_CHANNELS_ALLOWED; i++) {
+ if (p_nItems [i] == nID) {
m_ChannelList.SetCurSel(i);
break;
}
@@ -231,8 +222,9 @@ void CPlayerNavigationDialog::OnTvRadioStations()
{
m_bTVStations = !m_bTVStations;
UpdateElementList();
- if (m_bTVStations)
+ if (m_bTVStations) {
m_ButtonFilterStations.SetWindowText(ResStr(IDS_DVB_TVNAV_SEERADIO));
- else
+ } else {
m_ButtonFilterStations.SetWindowText(ResStr(IDS_DVB_TVNAV_SEETV));
+ }
}
diff --git a/src/apps/mplayerc/PlayerNavigationDialog.h b/src/apps/mplayerc/PlayerNavigationDialog.h
index 119db4377..7bea5ac9c 100644
--- a/src/apps/mplayerc/PlayerNavigationDialog.h
+++ b/src/apps/mplayerc/PlayerNavigationDialog.h
@@ -47,7 +47,7 @@ public:
DVBStreamInfo m_audios[DVB_MAX_AUDIO];
bool m_bTVStations;
-// Dialog Data
+ // Dialog Data
enum { IDD = IDD_NAVIGATION_DLG };
CListBox m_ChannelList;
@@ -56,7 +56,7 @@ public:
CButton m_ButtonScan;
CButton m_ButtonFilterStations;
CWnd* m_pParent;
-// CMenu m_subtitles, m_audios;
+ // CMenu m_subtitles, m_audios;
protected:
diff --git a/src/apps/mplayerc/PlayerPlaylistBar.cpp b/src/apps/mplayerc/PlayerPlaylistBar.cpp
index ab37cf40e..c39793a97 100644
--- a/src/apps/mplayerc/PlayerPlaylistBar.cpp
+++ b/src/apps/mplayerc/PlayerPlaylistBar.cpp
@@ -47,8 +47,9 @@ CPlayerPlaylistBar::~CPlayerPlaylistBar()
BOOL CPlayerPlaylistBar::Create(CWnd* pParentWnd)
{
- if(!CSizingControlBarG::Create(_T("Playlist"), pParentWnd, ID_VIEW_PLAYLIST))
+ if(!CSizingControlBarG::Create(_T("Playlist"), pParentWnd, ID_VIEW_PLAYLIST)) {
return FALSE;
+ }
m_list.CreateEx(
WS_EX_DLGMODALFRAME|WS_EX_CLIENTEDGE,
@@ -78,8 +79,9 @@ BOOL CPlayerPlaylistBar::Create(CWnd* pParentWnd)
BOOL CPlayerPlaylistBar::PreCreateWindow(CREATESTRUCT& cs)
{
- if(!CSizingControlBarG::PreCreateWindow(cs))
+ if(!CSizingControlBarG::PreCreateWindow(cs)) {
return FALSE;
+ }
cs.dwExStyle |= WS_EX_ACCEPTFILES;
@@ -88,16 +90,15 @@ BOOL CPlayerPlaylistBar::PreCreateWindow(CREATESTRUCT& cs)
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)
- {
+ 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))
+ if(IsDialogMessage(pMsg)) {
return TRUE;
+ }
}
return CSizingControlBarG::PreTranslateMessage(pMsg);
@@ -115,19 +116,20 @@ void CPlayerPlaylistBar::AddItem(CAtlList<CString>& fns, CAtlList<CString>* subs
CPlaylistItem pli;
POSITION pos = fns.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CString fn = fns.GetNext(pos);
- if(!fn.Trim().IsEmpty()) pli.m_fns.AddTail(fn);
+ if(!fn.Trim().IsEmpty()) {
+ pli.m_fns.AddTail(fn);
+ }
}
- if(subs)
- {
+ if(subs) {
POSITION pos = subs->GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CString fn = subs->GetNext(pos);
- if(!fn.Trim().IsEmpty()) pli.m_subs.AddTail(fn);
+ if(!fn.Trim().IsEmpty()) {
+ pli.m_subs.AddTail(fn);
+ }
}
}
@@ -138,8 +140,9 @@ void CPlayerPlaylistBar::AddItem(CAtlList<CString>& fns, CAtlList<CString>* subs
static bool SearchFiles(CString mask, CAtlList<CString>& sl)
{
- if(mask.Find(_T("://")) >= 0)
+ if(mask.Find(_T("://")) >= 0) {
return(false);
+ }
mask.Trim();
sl.RemoveAll();
@@ -149,46 +152,42 @@ static bool SearchFiles(CString mask, CAtlList<CString>& sl)
WIN32_FILE_ATTRIBUTE_DATA fad;
bool fFilterKnownExts = (GetFileAttributesEx(mask, GetFileExInfoStandard, &fad)
&& (fad.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY));
- if (fFilterKnownExts)
+ if (fFilterKnownExts) {
mask = CString(mask).TrimRight(_T("\\/")) + _T("\\*.*");
+ }
{
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;
+ 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;
- if(!fFilterKnownExts || mf.FindExt(ext))
- {
- for(int i = 0; i < mf.GetCount(); i++)
- {
+ if(!fFilterKnownExts || mf.FindExt(ext)) {
+ for(int 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(ResStr(IDS_AG_PLAYLIST_FILE)) != 0))
- {
+ if((mfc.FindExt(ext)) && (mf[i].GetLabel().CompareNoCase(ResStr(IDS_AG_PLAYLIST_FILE)) != 0)) {
sl.AddTail(path);
break;
}
}
}
- }
- while(FindNextFile(h, &fd));
+ } while(FindNextFile(h, &fd));
FindClose(h);
- if(sl.GetCount() == 0 && mask.Find(_T(":\\")) == 1)
- {
+ if(sl.GetCount() == 0 && mask.Find(_T(":\\")) == 1) {
GetCDROMType(mask[0], sl);
}
}
@@ -215,15 +214,15 @@ void CPlayerPlaylistBar::ResolveLinkFiles( CAtlList<CString> &fns )
CComQIPtr<IPersistFile> pPF = pSL;
POSITION pos = fns.GetHeadPosition();
- while(pSL && pPF && pos)
- {
+ 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)))
+ || FAILED(pSL->GetPath(buff, countof(buff), NULL, 0))) {
continue;
+ }
fn = buff;
}
@@ -231,35 +230,38 @@ void CPlayerPlaylistBar::ResolveLinkFiles( CAtlList<CString> &fns )
void CPlayerPlaylistBar::ParsePlayList(CAtlList<CString>& fns, CAtlList<CString>* subs)
{
- if(fns.IsEmpty()) return;
+ if(fns.IsEmpty()) {
+ return;
+ }
ResolveLinkFiles(fns);
CAtlList<CString> sl;
- if(SearchFiles(fns.GetHead(), sl))
- {
- if(sl.GetCount() > 1) subs = NULL;
+ if(SearchFiles(fns.GetHead(), sl)) {
+ if(sl.GetCount() > 1) {
+ subs = NULL;
+ }
POSITION pos = sl.GetHeadPosition();
- while(pos) ParsePlayList(sl.GetNext(pos), subs);
+ while(pos) {
+ ParsePlayList(sl.GetNext(pos), subs);
+ }
return;
}
CAtlList<CString> redir;
CStringA ct = GetContentType(fns.GetHead(), &redir);
- if(!redir.IsEmpty())
- {
+ if(!redir.IsEmpty()) {
POSITION pos = redir.GetHeadPosition();
- while(pos) ParsePlayList(sl.GetNext(pos), subs);
+ while(pos) {
+ ParsePlayList(sl.GetNext(pos), subs);
+ }
return;
}
- if(ct == "application/x-mpc-playlist")
- {
+ if(ct == "application/x-mpc-playlist") {
ParseMPCPlayList(fns.GetHead());
return;
- }
- else if(ct == "application/x-bdmv-playlist")
- {
+ } else if(ct == "application/x-bdmv-playlist") {
ParseBDMVPlayList(fns.GetHead());
return;
}
@@ -274,7 +276,9 @@ static int s_int_comp(const void* i1, const void* i2)
static CString CombinePath(CPath p, CString fn)
{
- if(fn.Find(':') >= 0 || fn.Find(_T("\\")) == 0) return fn;
+ if(fn.Find(':') >= 0 || fn.Find(_T("\\")) == 0) {
+ return fn;
+ }
p.Append(CPath(fn));
return (LPCTSTR)p;
}
@@ -289,8 +293,7 @@ bool CPlayerPlaylistBar::ParseBDMVPlayList(CString fn)
Path.RemoveFileSpec();
Path.RemoveFileSpec();
- if (SUCCEEDED (ClipInfo.FindMainMovie (Path + L"\\", strPlaylistFile, MainPlaylist)))
- {
+ if (SUCCEEDED (ClipInfo.FindMainMovie (Path + L"\\", strPlaylistFile, MainPlaylist))) {
CAtlList<CString> strFiles;
strFiles.AddHead (strPlaylistFile);
Append(strFiles, MainPlaylist.GetCount()>1, NULL);
@@ -306,62 +309,65 @@ bool CPlayerPlaylistBar::ParseMPCPlayList(CString fn)
CAtlArray<int> idx;
CWebTextFile f;
- if(!f.Open(fn) || !f.ReadString(str) || str != _T("MPCPLAYLIST"))
+ if(!f.Open(fn) || !f.ReadString(str) || str != _T("MPCPLAYLIST")) {
return false;
+ }
- if(f.GetEncoding() == CTextFile::ASCII)
+ if(f.GetEncoding() == CTextFile::ASCII) {
f.SetEncoding(CTextFile::ANSI);
+ }
CPath base(fn);
base.RemoveFileSpec();
- while(f.ReadString(str))
- {
+ while(f.ReadString(str)) {
CAtlList<CString> sl;
Explode(str, sl, ',', 3);
- if(sl.GetCount() != 3) continue;
+ if(sl.GetCount() != 3) {
+ continue;
+ }
- if(int i = _ttoi(sl.RemoveHead()))
- {
+ if(int i = _ttoi(sl.RemoveHead())) {
CString key = sl.RemoveHead();
CString value = sl.RemoveHead();
- if(key == _T("type"))
- {
+ 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"))
- {
+ } 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"))
- {
+ } 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(""));
+ } 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(""));
+ } 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);
}
- 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(int i = 0; i < idx.GetCount(); i++)
+ for(int i = 0; i < idx.GetCount(); i++) {
m_pl.AddTail(pli[idx[i]]);
+ }
return pli.GetCount() > 0;
}
@@ -369,14 +375,14 @@ bool CPlayerPlaylistBar::ParseMPCPlayList(CString fn)
bool CPlayerPlaylistBar::SaveMPCPlayList(CString fn, CTextFile::enc e, bool fRemovePath)
{
CTextFile f;
- if(!f.Save(fn, e))
+ if(!f.Save(fn, e)) {
return false;
+ }
f.WriteString(_T("MPCPLAYLIST\n"));
POSITION pos = m_pl.GetHeadPosition(), pos2;
- for(int i = 1; pos; i++)
- {
+ for(int i = 1; pos; i++) {
CPlaylistItem& pli = m_pl.GetNext(pos);
CString idx;
@@ -386,17 +392,15 @@ bool CPlayerPlaylistBar::SaveMPCPlayList(CString fn, CTextFile::enc e, bool fRem
str.Format(_T("%d,type,%d"), i, pli.m_type);
f.WriteString(str + _T("\n"));
- if(!pli.m_label.IsEmpty())
+ if(!pli.m_label.IsEmpty()) {
f.WriteString(idx + _T(",label,") + pli.m_label + _T("\n"));
+ }
- if(pli.m_type == CPlaylistItem::file)
- {
+ if(pli.m_type == CPlaylistItem::file) {
pos2 = pli.m_fns.GetHeadPosition();
- while(pos2)
- {
+ while(pos2) {
CString fn = pli.m_fns.GetNext(pos2);
- if(fRemovePath)
- {
+ if(fRemovePath) {
CPath p(fn);
p.StripPath();
fn = (LPCTSTR)p;
@@ -405,20 +409,16 @@ bool CPlayerPlaylistBar::SaveMPCPlayList(CString fn, CTextFile::enc e, bool fRem
}
pos2 = pli.m_subs.GetHeadPosition();
- while(pos2)
- {
+ while(pos2) {
CString fn = pli.m_subs.GetNext(pos2);
- if(fRemovePath)
- {
+ 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)
- {
+ } 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);
@@ -457,14 +457,13 @@ void CPlayerPlaylistBar::Open(CAtlList<CString>& fns, bool fMulti, CAtlList<CStr
void CPlayerPlaylistBar::Append(CAtlList<CString>& fns, bool fMulti, CAtlList<CString>* subs)
{
- if(fMulti)
- {
+ if(fMulti) {
ASSERT(subs == NULL || subs->GetCount() == 0);
POSITION pos = fns.GetHeadPosition();
- while(pos) ParsePlayList(fns.GetNext(pos), NULL);
- }
- else
- {
+ while(pos) {
+ ParsePlayList(fns.GetNext(pos), NULL);
+ }
+ } else {
ParsePlayList(fns, subs);
}
@@ -490,8 +489,12 @@ void CPlayerPlaylistBar::Append(CStringW vdn, CStringW adn, int vinput, int vcha
CAtlList<CStringW> sl;
CStringW vfn = GetFriendlyName(vdn);
CStringW afn = GetFriendlyName(adn);
- if(!vfn.IsEmpty()) sl.AddTail(vfn);
- if(!afn.IsEmpty()) sl.AddTail(afn);
+ 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);
@@ -506,8 +509,7 @@ void CPlayerPlaylistBar::SetupList()
m_list.DeleteAllItems();
POSITION pos = m_pl.GetHeadPosition();
- for(int i = 0; pos; i++)
- {
+ 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));
@@ -518,8 +520,7 @@ void CPlayerPlaylistBar::SetupList()
void CPlayerPlaylistBar::UpdateList()
{
POSITION pos = m_pl.GetHeadPosition();
- for(int i = 0, j = m_list.GetItemCount(); pos && i < j; i++)
- {
+ 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));
@@ -531,7 +532,9 @@ void CPlayerPlaylistBar::UpdateList()
void CPlayerPlaylistBar::EnsureVisible(POSITION pos)
{
int i = FindItem(m_pl.GetPos());
- if(i < 0) return;
+ if(i < 0) {
+ return;
+ }
m_list.EnsureVisible(i, TRUE);
m_list.Invalidate();
}
@@ -539,14 +542,17 @@ void CPlayerPlaylistBar::EnsureVisible(POSITION pos)
int CPlayerPlaylistBar::FindItem(POSITION pos)
{
for(int i = 0; i < m_list.GetItemCount(); i++)
- if((POSITION)m_list.GetItemData(i) == pos)
+ if((POSITION)m_list.GetItemData(i) == pos) {
return(i);
+ }
return(-1);
}
POSITION CPlayerPlaylistBar::FindPos(int i)
{
- if(i < 0) return(NULL);
+ if(i < 0) {
+ return(NULL);
+ }
return((POSITION)m_list.GetItemData(i));
}
@@ -572,14 +578,18 @@ bool CPlayerPlaylistBar::IsAtEnd()
bool CPlayerPlaylistBar::GetCur(CPlaylistItem& pli)
{
- if(!m_pl.GetPos()) return(false);
+ if(!m_pl.GetPos()) {
+ return(false);
+ }
pli = m_pl.GetAt(m_pl.GetPos());
return(true);
}
CPlaylistItem* CPlayerPlaylistBar::GetCur()
{
- if(!m_pl.GetPos()) return NULL;
+ if(!m_pl.GetPos()) {
+ return NULL;
+ }
return &m_pl.GetAt(m_pl.GetPos());
}
@@ -587,15 +597,18 @@ CString CPlayerPlaylistBar::GetCurFileName()
{
CString fn;
CPlaylistItem* pli = GetCur();
- if(pli && !pli->m_fns.IsEmpty())
+ if(pli && !pli->m_fns.IsEmpty()) {
fn = pli->m_fns.GetHead();
+ }
return(fn);
}
void CPlayerPlaylistBar::SetNext()
{
POSITION pos = m_pl.GetPos(), org = pos;
- while(m_pl.GetNextWrap(pos).m_fInvalid && pos != org);
+ while(m_pl.GetNextWrap(pos).m_fInvalid && pos != org) {
+ ;
+ }
UpdateList();
m_pl.SetPos(pos);
EnsureVisible(pos);
@@ -604,7 +617,9 @@ void CPlayerPlaylistBar::SetNext()
void CPlayerPlaylistBar::SetPrev()
{
POSITION pos = m_pl.GetPos(), org = pos;
- while(m_pl.GetPrevWrap(pos).m_fInvalid && pos != org);
+ while(m_pl.GetPrevWrap(pos).m_fInvalid && pos != org) {
+ ;
+ }
m_pl.SetPos(pos);
EnsureVisible(pos);
}
@@ -612,13 +627,14 @@ void CPlayerPlaylistBar::SetPrev()
void CPlayerPlaylistBar::SetFirstSelected()
{
POSITION pos = m_list.GetFirstSelectedItemPosition();
- if(pos)
+ if(pos) {
pos = FindPos(m_list.GetNextSelectedItem(pos));
- else
- {
+ } else {
pos = m_pl.GetTailPosition();
POSITION org = pos;
- while(m_pl.GetNextWrap(pos).m_fInvalid && pos != org);
+ while(m_pl.GetNextWrap(pos).m_fInvalid && pos != org) {
+ ;
+ }
}
UpdateList();
m_pl.SetPos(pos);
@@ -628,7 +644,9 @@ void CPlayerPlaylistBar::SetFirstSelected()
void CPlayerPlaylistBar::SetFirst()
{
POSITION pos = m_pl.GetTailPosition(), org = pos;
- while(m_pl.GetNextWrap(pos).m_fInvalid && pos != org);
+ while(m_pl.GetNextWrap(pos).m_fInvalid && pos != org) {
+ ;
+ }
UpdateList();
m_pl.SetPos(pos);
EnsureVisible(pos);
@@ -637,7 +655,9 @@ void CPlayerPlaylistBar::SetFirst()
void CPlayerPlaylistBar::SetLast()
{
POSITION pos = m_pl.GetHeadPosition(), org = pos;
- while(m_pl.GetPrevWrap(pos).m_fInvalid && pos != org);
+ while(m_pl.GetPrevWrap(pos).m_fInvalid && pos != org) {
+ ;
+ }
m_pl.SetPos(pos);
EnsureVisible(pos);
}
@@ -645,11 +665,9 @@ void CPlayerPlaylistBar::SetLast()
void CPlayerPlaylistBar::SetCurValid(bool fValid)
{
POSITION pos = m_pl.GetPos();
- if(pos)
- {
+ if(pos) {
m_pl.GetAt(pos).m_fInvalid = !fValid;
- if(!fValid)
- {
+ if(!fValid) {
int i = FindItem(pos);
m_list.RedrawItems(i, i);
}
@@ -659,8 +677,7 @@ void CPlayerPlaylistBar::SetCurValid(bool fValid)
void CPlayerPlaylistBar::SetCurTime(REFERENCE_TIME rt)
{
POSITION pos = m_pl.GetPos();
- if(pos)
- {
+ if(pos) {
CPlaylistItem& pli = m_pl.GetAt(pos);
pli.m_duration = rt;
m_list.SetItemText(FindItem(pos), COL_TIME, pli.GetLabel(1));
@@ -670,41 +687,36 @@ void CPlayerPlaylistBar::SetCurTime(REFERENCE_TIME rt)
OpenMediaData* CPlayerPlaylistBar::GetCurOMD(REFERENCE_TIME rtStart)
{
CPlaylistItem* pli = GetCur();
- if(pli == NULL)
+ 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())
- {
+ || 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())
- {
+ 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++)
+ 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())
- {
+ } else {
+ if(OpenFileData* p = DNew OpenFileData()) {
p->fns.AddTailList(&pli->m_fns);
p->subs.AddTailList(&pli->m_subs);
p->rtStart = rtStart;
@@ -717,14 +729,13 @@ OpenMediaData* CPlayerPlaylistBar::GetCurOMD(REFERENCE_TIME rtStart)
bool CPlayerPlaylistBar::SelectFileInPlaylist(LPCTSTR filename)
{
- if (!filename)
+ if (!filename) {
return false;
+ }
POSITION pos = m_pl.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CPlaylistItem& pli = m_pl.GetAt(pos);
- if (pli.FindFile(filename))
- {
+ if (pli.FindFile(filename)) {
m_pl.SetPos(pos);
EnsureVisible(pos);
return true;
@@ -738,20 +749,16 @@ void CPlayerPlaylistBar::LoadPlaylist(LPCTSTR filename)
{
CString base;
- if(AfxGetMyApp()->GetAppSavePath(base))
- {
+ if(AfxGetMyApp()->GetAppSavePath(base)) {
CPath p;
p.Combine(base, _T("default.mpcpl"));
if(p.FileExists()) {
- if(AfxGetApp()->GetProfileInt(IDS_R_SETTINGS, _T("RememberPlaylistItems"), TRUE))
- {
+ if(AfxGetAppSettings().bRememberPlaylistItems) {
ParseMPCPlayList(p);
Refresh();
SelectFileInPlaylist(filename);
- }
- else
- {
+ } else {
::DeleteFile(p);
}
}
@@ -766,15 +773,14 @@ void CPlayerPlaylistBar::SavePlaylist()
CPath p;
p.Combine(base, _T("default.mpcpl"));
- if(AfxGetApp()->GetProfileInt(IDS_R_SETTINGS, _T("RememberPlaylistItems"), TRUE))
- {
+ if(AfxGetAppSettings().bRememberPlaylistItems) {
// Only create this folder when needed
- if(!::PathFileExists(base))
+ if(!::PathFileExists(base)) {
::CreateDirectory(base, NULL);
+ }
SaveMPCPlayList(p, CTextFile::UTF8, false);
- }
- else if(p.FileExists()) {
+ } else if(p.FileExists()) {
::DeleteFile(p);
}
}
@@ -784,7 +790,7 @@ 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_NOTIFY(NM_CUSTOMDRAW, IDC_PLAYLIST, OnCustomdrawList)
ON_WM_DRAWITEM()
ON_COMMAND_EX(ID_FILE_CLOSEPLAYLIST, OnFileClosePlaylist)
ON_COMMAND_EX(ID_PLAY_PLAY, OnPlayPlay)
@@ -803,8 +809,7 @@ END_MESSAGE_MAP()
void CPlayerPlaylistBar::ResizeListColumn()
{
- if(::IsWindow(m_list.m_hWnd))
- {
+ if(::IsWindow(m_list.m_hWnd)) {
CRect r;
GetClientRect(r);
r.DeflateRect(2, 2);
@@ -831,15 +836,17 @@ void CPlayerPlaylistBar::OnLvnKeyDown(NMHDR* pNMHDR, LRESULT* pResult)
CList<int> items;
POSITION pos = m_list.GetFirstSelectedItemPosition();
- while(pos) items.AddHead(m_list.GetNextSelectedItem(pos));
+ while(pos) {
+ items.AddHead(m_list.GetNextSelectedItem(pos));
+ }
- if(pLVKeyDown->wVKey == VK_DELETE && items.GetCount() > 0)
- {
+ if(pLVKeyDown->wVKey == VK_DELETE && items.GetCount() > 0) {
pos = items.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
int i = items.GetNext(pos);
- if(m_pl.RemoveAt(FindPos(i))) ((CMainFrame*)AfxGetMainWnd())->CloseMedia();
+ if(m_pl.RemoveAt(FindPos(i))) {
+ ((CMainFrame*)AfxGetMainWnd())->CloseMedia();
+ }
m_list.DeleteItem(i);
}
@@ -851,9 +858,7 @@ void CPlayerPlaylistBar::OnLvnKeyDown(NMHDR* pNMHDR, LRESULT* pResult)
ResizeListColumn();
*pResult = TRUE;
- }
- else if(pLVKeyDown->wVKey == VK_SPACE && items.GetCount() == 1)
- {
+ } else if(pLVKeyDown->wVKey == VK_SPACE && items.GetCount() == 1) {
m_pl.SetPos(FindPos(items.GetHead()));
((CMainFrame*)AfxGetMainWnd())->OpenCurPlaylistItem();
@@ -866,11 +871,12 @@ void CPlayerPlaylistBar::OnNMDblclkList(NMHDR* pNMHDR, LRESULT* pResult)
{
LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)pNMHDR;
- if(lpnmlv->iItem >= 0 && lpnmlv->iSubItem >= 0)
- {
+ if(lpnmlv->iItem >= 0 && lpnmlv->iSubItem >= 0) {
AppSettings& s = AfxGetAppSettings();
FILE_POSITION* FilePosition = s.CurrentFilePosition();
- if (FilePosition) FilePosition->llPosition = 0;
+ if (FilePosition) {
+ FilePosition->llPosition = 0;
+ }
m_pl.SetPos(FindPos(lpnmlv->iItem));
m_list.Invalidate();
@@ -923,7 +929,9 @@ void CPlayerPlaylistBar::OnCustomdrawList(NMHDR* pNMHDR, LRESULT* pResult)
void CPlayerPlaylistBar::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct)
{
- if(nIDCtl != IDC_PLAYLIST) return;
+ if(nIDCtl != IDC_PLAYLIST) {
+ return;
+ }
int nItem = lpDrawItemStruct->itemID;
CRect rcItem = lpDrawItemStruct->rcItem;
@@ -933,27 +941,24 @@ void CPlayerPlaylistBar::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruc
CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
- if(!!m_list.GetItemState(nItem, LVIS_SELECTED))
- {
+ if(!!m_list.GetItemState(nItem, LVIS_SELECTED)) {
FillRect(pDC->m_hDC, rcItem, CBrush(0xf1dacc));
FrameRect(pDC->m_hDC, rcItem, CBrush(0xc56a31));
- }
- else
- {
+ } else {
FillRect(pDC->m_hDC, rcItem, CBrush(GetSysColor(COLOR_WINDOW)));
}
COLORREF textcolor = fSelected?0xff:0;
- if(pli.m_fInvalid) textcolor |= 0xA0A0A0;
+ 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)
- {
+ if(time.GetLength() > 0) {
timesize = pDC->GetTextExtent(time);
- if((3+timesize.cx+3) < rcItem.Width()/2)
- {
+ 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);
@@ -965,14 +970,12 @@ void CPlayerPlaylistBar::OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruc
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)
- {
+ 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)
- {
+ if(file.GetLength() > 3) {
pDC->SetTextColor(textcolor);
pDC->TextOut(rcItem.left+3, (rcItem.top+rcItem.bottom-filesize.cy)/2, file);
}
@@ -997,8 +1000,7 @@ void CPlayerPlaylistBar::OnDropFiles(HDROP hDropInfo)
CAtlList<CString> sl;
UINT nFiles = ::DragQueryFile(hDropInfo, (UINT)-1, NULL, 0);
- for(UINT iFile = 0; iFile < nFiles; iFile++)
- {
+ for(UINT iFile = 0; iFile < nFiles; iFile++) {
TCHAR szFileName[_MAX_PATH];
::DragQueryFile(hDropInfo, iFile, szFileName, _MAX_PATH);
sl.AddTail(szFileName);
@@ -1030,8 +1032,7 @@ void CPlayerPlaylistBar::OnBeginDrag(NMHDR* pNMHDR, LRESULT* pResult)
void CPlayerPlaylistBar::OnMouseMove(UINT nFlags, CPoint point)
{
- if(m_bDragging)
- {
+ if(m_bDragging) {
m_ptDropPoint = point;
ClientToScreen(&m_ptDropPoint);
@@ -1047,15 +1048,17 @@ void CPlayerPlaylistBar::OnMouseMove(UINT nFlags, CPoint point)
int iTopItem = m_list.GetTopIndex();
int iBottomItem = m_list.GetBottomIndex();
- if(iOverItem == iTopItem && iTopItem != 0) // top of list
+ if(iOverItem == iTopItem && iTopItem != 0) { // top of list
SetTimer(1, 100, NULL);
- else
+ } else {
KillTimer(1);
+ }
- if(iOverItem >= iBottomItem && iBottomItem != (m_list.GetItemCount() - 1)) // bottom of list
+ if(iOverItem >= iBottomItem && iBottomItem != (m_list.GetItemCount() - 1)) { // bottom of list
SetTimer(2, 100, NULL);
- else
+ } else {
KillTimer(2);
+ }
}
}
@@ -1067,21 +1070,21 @@ void CPlayerPlaylistBar::OnTimer(UINT_PTR nIDEvent)
int iTopItem = m_list.GetTopIndex();
int iBottomItem = iTopItem + m_list.GetCountPerPage() - 1;
- if(m_bDragging)
- {
+ if(m_bDragging) {
m_pDragImage->DragShowNolock(FALSE);
- if(nIDEvent == 1)
- {
+ if(nIDEvent == 1) {
m_list.EnsureVisible(iTopItem - 1, false);
m_list.UpdateWindow();
- if(m_list.GetTopIndex() == 0) KillTimer(1);
- }
- else if(nIDEvent == 2)
- {
+ 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(m_list.GetBottomIndex() == (m_list.GetItemCount() - 1)) {
+ KillTimer(2);
+ }
}
m_pDragImage->DragShowNolock(TRUE);
@@ -1092,8 +1095,7 @@ void CPlayerPlaylistBar::OnTimer(UINT_PTR nIDEvent)
void CPlayerPlaylistBar::OnLButtonUp(UINT nFlags, CPoint point)
{
- if(m_bDragging)
- {
+ if(m_bDragging) {
::ReleaseCapture();
m_bDragging = FALSE;
@@ -1109,8 +1111,9 @@ void CPlayerPlaylistBar::OnLButtonUp(UINT nFlags, CPoint point)
CPoint pt(point);
ClientToScreen(&pt);
- if(WindowFromPoint(pt) == &m_list)
+ if(WindowFromPoint(pt) == &m_list) {
DropItemOnList();
+ }
}
ModifyStyle(0, WS_EX_ACCEPTFILES);
@@ -1133,7 +1136,9 @@ void CPlayerPlaylistBar::DropItemOnList()
lvi.cchTextMax = _MAX_PATH;
m_list.GetItem(&lvi);
- if(m_nDropIndex < 0) m_nDropIndex = m_list.GetItemCount();
+ if(m_nDropIndex < 0) {
+ m_nDropIndex = m_list.GetItemCount();
+ }
lvi.iItem = m_nDropIndex;
m_list.InsertItem(&lvi);
@@ -1142,9 +1147,10 @@ void CPlayerPlaylistBar::DropItemOnList()
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++)
- {
+ if(m_nDropIndex < m_nDragIndex) {
+ m_nDragIndex++;
+ }
+ for(int col=1; col < nColumnCount; col++) {
_tcscpy(lvi.pszText, (LPCTSTR)(m_list.GetItemText(m_nDragIndex, col)));
lvi.iSubItem = col;
m_list.SetItem(&lvi);
@@ -1154,20 +1160,22 @@ void CPlayerPlaylistBar::DropItemOnList()
CList<CPlaylistItem> tmp;
UINT id = (UINT)-1;
- for(int i = 0; i < m_list.GetItemCount(); i++)
- {
+ 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;
+ if(pos == m_pl.GetPos()) {
+ id = pli.m_id;
+ }
}
m_pl.RemoveAll();
POSITION pos = tmp.GetHeadPosition();
- for(int i = 0; pos; i++)
- {
+ 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());
+ if(pli.m_id == id) {
+ m_pl.SetPos(m_pl.GetTailPosition());
+ }
m_list.SetItemData(i, (DWORD_PTR)m_pl.GetTailPosition());
}
@@ -1178,47 +1186,52 @@ BOOL CPlayerPlaylistBar::OnToolTipNotify(UINT id, NMHDR* pNMHDR, LRESULT* pResul
{
TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR;
- if (pNMHDR->code == TTN_NEEDTEXTW && (HWND)pTTTW->lParam != m_list.m_hWnd)
+ if (pNMHDR->code == TTN_NEEDTEXTW && (HWND)pTTTW->lParam != m_list.m_hWnd) {
return FALSE;
+ }
int row = ((pNMHDR->idFrom-1) >> 10) & 0x3fffff;
int col = (pNMHDR->idFrom-1) & 0x3ff;
- if(row < 0 || row >= m_pl.GetCount())
+ if(row < 0 || row >= m_pl.GetCount()) {
return FALSE;
+ }
CPlaylistItem& pli = m_pl.GetAt(FindPos(row));
CString strTipText;
- if(col == COL_NAME)
- {
+ if(col == COL_NAME) {
POSITION pos = pli.m_fns.GetHeadPosition();
- while(pos) strTipText += _T("\n") + pli.m_fns.GetNext(pos);
+ while(pos) {
+ strTipText += _T("\n") + pli.m_fns.GetNext(pos);
+ }
strTipText.Trim();
- if(pli.m_type == CPlaylistItem::device)
- {
+ if(pli.m_type == CPlaylistItem::device) {
CString str;
str.Format(_T("Video Input %d"), pli.m_vinput);
- if(pli.m_vinput >= 0) strTipText += _T("\n") + str;
+ if(pli.m_vinput >= 0) {
+ strTipText += _T("\n") + str;
+ }
str.Format(_T("Video Channel %d"), pli.m_vchannel);
- if(pli.m_vchannel >= 0) strTipText += _T("\n") + str;
+ if(pli.m_vchannel >= 0) {
+ strTipText += _T("\n") + str;
+ }
str.Format(_T("Audio Input %d"), pli.m_ainput);
- if(pli.m_ainput >= 0) strTipText += _T("\n") + str;
+ if(pli.m_ainput >= 0) {
+ strTipText += _T("\n") + str;
+ }
}
::SendMessage(pNMHDR->hwndFrom, TTM_SETMAXTIPWIDTH, 0, (LPARAM)(INT)1000);
- }
- else if(col == COL_TIME)
- {
+ } else if(col == COL_TIME) {
return FALSE;
}
static CStringW m_strTipTextW;
- if(pNMHDR->code == TTN_NEEDTEXTW) //?possible check is not needed
- {
+ if(pNMHDR->code == TTN_NEEDTEXTW) { //?possible check is not needed
m_strTipTextW = strTipText;
pTTTW->lpszText = (LPWSTR)(LPCWSTR)m_strTipTextW;
}
@@ -1236,21 +1249,24 @@ void CPlayerPlaylistBar::OnContextMenu(CWnd* /*pWnd*/, CPoint p)
m_list.SubItemHitTest(&lvhti);
POSITION pos = FindPos(lvhti.iItem);
-// bool fSelected = (pos == m_pl.GetPos());
+ // bool fSelected = (pos == m_pl.GetPos());
bool fOnItem = !!(lvhti.flags&LVHT_ONITEM);
CMenu m;
m.CreatePopupMenu();
- enum
- {
+ enum {
M_OPEN=1, M_ADD, M_REMOVE, 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));
+ 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|(!fOnItem?(MF_DISABLED|MF_GRAYED):MF_ENABLED), M_CLIPBOARD, ResStr(IDS_PLAYLIST_COPYTOCLIPBOARD));
@@ -1261,232 +1277,224 @@ void CPlayerPlaylistBar::OnContextMenu(CWnd* /*pWnd*/, CPoint p)
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|(AfxGetApp()->GetProfileInt(IDS_R_SETTINGS, _T("ShufflePlaylistItems"), FALSE)?MF_CHECKED:0), M_SHUFFLE, ResStr(IDS_PLAYLIST_SHUFFLE));
- m.AppendMenu(MF_STRING|MF_ENABLED|(AfxGetApp()->GetProfileInt(IDS_R_SETTINGS, _T("RememberPlaylistItems"), TRUE)?MF_CHECKED:0), M_REMEMBERPLAYLIST, ResStr(IDS_PLAYLIST_REMEBERITEMS));
+ m.AppendMenu(MF_STRING|MF_ENABLED|(s.bShufflePlaylistItems)?MF_CHECKED:0, M_SHUFFLE, ResStr(IDS_PLAYLIST_SHUFFLE));
+ m.AppendMenu(MF_STRING|MF_ENABLED|(s.bRememberPlaylistItems)?MF_CHECKED:0, M_REMEMBERPLAYLIST, ResStr(IDS_PLAYLIST_REMEBERITEMS));
m.AppendMenu(MF_SEPARATOR);
- m.AppendMenu(MF_STRING|MF_ENABLED|(AfxGetApp()->GetProfileInt(IDS_R_SETTINGS, _T("HidePlaylistFullScreen"), FALSE)?MF_CHECKED:0), M_HIDEFULLSCREEN, ResStr(IDS_PLAYLIST_HIDEFS));
+ m.AppendMenu(MF_STRING|MF_ENABLED|(s.bHidePlaylistFullScreen)?MF_CHECKED:0, 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_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;
+ 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_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();
- 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, str);
- GlobalUnlock(h);
+ if(HGLOBAL h = GlobalAlloc(GMEM_MOVEABLE, (str.GetLength()+1)*sizeof(TCHAR))) {
+ if(TCHAR* s = (TCHAR*)GlobalLock(h)) {
+ _tcscpy(s, str);
+ GlobalUnlock(h);
#ifdef UNICODE
- SetClipboardData(CF_UNICODETEXT, h);
+ SetClipboardData(CF_UNICODETEXT, h);
#else
- SetClipboardData(CF_TEXT, h);
+ SetClipboardData(CF_TEXT, h);
#endif
+ }
}
+ CloseClipboard();
}
- 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;
+ 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);
- CTextFile::enc encoding = (CTextFile::enc)fd.GetEncoding();
- if(encoding == CTextFile::ASCII) encoding = CTextFile::ANSI;
-
- int idx = fd.m_pOFN->nFilterIndex;
+ if(fd.DoModal() != IDOK) {
+ break;
+ }
- CPath path(fd.GetPathName());
+ CTextFile::enc encoding = (CTextFile::enc)fd.GetEncoding();
+ if(encoding == CTextFile::ASCII) {
+ encoding = CTextFile::ANSI;
+ }
- 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;
- }
+ 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;
+ bool fRemovePath = true;
- CPath p(path);
- p.RemoveFileSpec();
- CString base = (LPCTSTR)p;
+ CPath p(path);
+ p.RemoveFileSpec();
+ CString base = (LPCTSTR)p;
- pos = m_pl.GetHeadPosition();
- while(pos && fRemovePath)
- {
- CPlaylistItem& pli = m_pl.GetNext(pos);
+ pos = m_pl.GetHeadPosition();
+ while(pos && fRemovePath) {
+ CPlaylistItem& pli = m_pl.GetNext(pos);
- if(pli.m_type != CPlaylistItem::file) fRemovePath = false;
- else
- {
- POSITION 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);
+ 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;
- }
+ 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);
+ 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;
+ 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 == 1) {
+ SaveMPCPlayList(path, encoding, fRemovePath);
+ break;
+ }
- if (idx == 2)
- {
- f.WriteString(_T("[playlist]\n"));
- }
- else if (idx == 4)
- {
- f.WriteString(_T("<ASX version = \"3.0\">\n"));
- }
+ CTextFile f;
+ if(!f.Save(path, encoding)) {
+ break;
+ }
- pos = m_pl.GetHeadPosition();
- CString str;
- int i;
- for(i = 0; pos; i++)
- {
- CPlaylistItem& pli = m_pl.GetNext(pos);
+ if (idx == 2) {
+ f.WriteString(_T("[playlist]\n"));
+ } else if (idx == 4) {
+ f.WriteString(_T("<ASX version = \"3.0\">\n"));
+ }
- if(pli.m_type != CPlaylistItem::file)
- continue;
+ pos = m_pl.GetHeadPosition();
+ CString str;
+ int i;
+ for(i = 0; pos; i++) {
+ CPlaylistItem& pli = m_pl.GetNext(pos);
- CString fn = pli.m_fns.GetHead();
+ if(pli.m_type != CPlaylistItem::file) {
+ continue;
+ }
-/*
- if(fRemovePath)
- {
- CPath p(path);
- p.StripPath();
- fn = (LPCTSTR)p;
+ 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);
}
-*/
- 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;
+ 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"));
}
- 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:
- AfxGetApp()->WriteProfileInt(IDS_R_SETTINGS, _T("RememberPlaylistItems"),
- !AfxGetApp()->GetProfileInt(IDS_R_SETTINGS, _T("RememberPlaylistItems"), TRUE));
- break;
- case M_SHUFFLE:
- AfxGetApp()->WriteProfileInt(IDS_R_SETTINGS, _T("ShufflePlaylistItems"),
- !AfxGetApp()->GetProfileInt(IDS_R_SETTINGS, _T("ShufflePlaylistItems"), FALSE));
- break;
- case M_HIDEFULLSCREEN:
- AfxGetApp()->WriteProfileInt(IDS_R_SETTINGS, _T("HidePlaylistFullScreen"),
- !AfxGetApp()->GetProfileInt(IDS_R_SETTINGS, _T("HidePlaylistFullScreen"), FALSE));
- break;
- default:
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;
}
}
@@ -1494,8 +1502,7 @@ void CPlayerPlaylistBar::OnLvnEndlabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
{
NMLVDISPINFO* pDispInfo = reinterpret_cast<NMLVDISPINFO*>(pNMHDR);
- if(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);
diff --git a/src/apps/mplayerc/PlayerPlaylistBar.h b/src/apps/mplayerc/PlayerPlaylistBar.h
index a2eb40f62..56480eeb4 100644
--- a/src/apps/mplayerc/PlayerPlaylistBar.h
+++ b/src/apps/mplayerc/PlayerPlaylistBar.h
@@ -117,7 +117,7 @@ public:
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 OnCustomdrawList(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct);
afx_msg BOOL OnFileClosePlaylist(UINT nID);
afx_msg BOOL OnPlayPlay(UINT nID);
diff --git a/src/apps/mplayerc/PlayerSeekBar.cpp b/src/apps/mplayerc/PlayerSeekBar.cpp
index 93ca04c90..416307963 100644
--- a/src/apps/mplayerc/PlayerSeekBar.cpp
+++ b/src/apps/mplayerc/PlayerSeekBar.cpp
@@ -43,16 +43,18 @@ CPlayerSeekBar::~CPlayerSeekBar()
BOOL CPlayerSeekBar::Create(CWnd* pParentWnd)
{
- if(!CDialogBar::Create(pParentWnd, IDD_PLAYERSEEKBAR, WS_CHILD|WS_VISIBLE|CBRS_ALIGN_BOTTOM, IDD_PLAYERSEEKBAR))
+ if(!CDialogBar::Create(pParentWnd, IDD_PLAYERSEEKBAR, WS_CHILD|WS_VISIBLE|CBRS_ALIGN_BOTTOM, IDD_PLAYERSEEKBAR)) {
return FALSE;
+ }
return TRUE;
}
BOOL CPlayerSeekBar::PreCreateWindow(CREATESTRUCT& cs)
{
- if(!CDialogBar::PreCreateWindow(cs))
+ if(!CDialogBar::PreCreateWindow(cs)) {
return FALSE;
+ }
m_dwStyle &= ~CBRS_BORDER_TOP;
m_dwStyle &= ~CBRS_BORDER_BOTTOM;
@@ -75,10 +77,14 @@ void CPlayerSeekBar::GetRange(__int64& start, __int64& stop)
void CPlayerSeekBar::SetRange(__int64 start, __int64 stop)
{
- if(start > stop) start ^= stop, stop ^= start, start ^= 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(m_pos < m_start || m_pos >= m_stop) {
+ SetPos(m_start);
+ }
}
__int64 CPlayerSeekBar::GetPos()
@@ -94,27 +100,31 @@ __int64 CPlayerSeekBar::GetPosReal()
void CPlayerSeekBar::SetPos(__int64 pos)
{
CWnd* w = GetCapture();
- if(w && w->m_hWnd == m_hWnd) return;
+ if(w && w->m_hWnd == m_hWnd) {
+ return;
+ }
SetPosInternal(pos);
}
void CPlayerSeekBar::SetPosInternal(__int64 pos)
{
- if(m_pos == pos) return;
+ 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)
- {
+ if(before != after) {
InvalidateRect(before | after);
CMainFrame* pFrame = ((CMainFrame*)GetParentFrame());
- if((AfxGetAppSettings().fUseWin7TaskBar)&&(pFrame->m_pTaskbarList))
+ if((AfxGetAppSettings().fUseWin7TaskBar)&&(pFrame->m_pTaskbarList)) {
pFrame->m_pTaskbarList->SetProgressValue ( pFrame->m_hWnd, pos, m_stop );
+ }
}
}
@@ -129,7 +139,7 @@ CRect CPlayerSeekBar::GetChannelRect()
CRect CPlayerSeekBar::GetThumbRect()
{
-// bool fEnabled = m_fEnabled || m_start >= m_stop;
+ // bool fEnabled = m_fEnabled || m_start >= m_stop;
CRect r = GetChannelRect();
@@ -156,15 +166,19 @@ void CPlayerSeekBar::MoveThumb(CPoint point)
{
CRect r = GetChannelRect();
- if(r.left >= r.right) return;
+ if(r.left >= r.right) {
+ return;
+ }
- if(point.x < r.left) SetPos(m_start);
- else if(point.x >= r.right) SetPos(m_stop);
- else
- {
+ if(point.x < r.left) {
+ SetPos(m_start);
+ } else if(point.x >= r.right) {
+ SetPos(m_stop);
+ } else {
__int64 w = r.right - r.left;
- if(m_start < m_stop)
+ if(m_start < m_stop) {
SetPosInternal(m_start + ((m_stop - m_start) * (point.x - r.left) + (w/2)) / w);
+ }
}
}
@@ -215,8 +229,7 @@ void CPlayerSeekBar::OnPaint()
r.DeflateRect(1, 1, 0, 0);
dc.Draw3dRect(&r, shadow, bkg);
- if(fEnabled)
- {
+ if(fEnabled) {
r.DeflateRect(1, 1, 1, 2);
CPen white(PS_INSIDEFRAME, 1, white);
CPen* old = dc.SelectObject(&white);
@@ -272,8 +285,7 @@ void CPlayerSeekBar::OnSize(UINT nType, int cx, int cy)
void CPlayerSeekBar::OnLButtonDown(UINT nFlags, CPoint point)
{
- if(m_fEnabled && (GetChannelRect() | GetThumbRect()).PtInRect(point))
- {
+ if(m_fEnabled && (GetChannelRect() | GetThumbRect()).PtInRect(point)) {
SetCapture();
MoveThumb(point);
GetParent()->PostMessage(WM_HSCROLL, MAKEWPARAM((short)m_pos, SB_THUMBPOSITION), (LPARAM)m_hWnd);
@@ -292,8 +304,7 @@ void CPlayerSeekBar::OnLButtonUp(UINT nFlags, CPoint point)
void CPlayerSeekBar::OnMouseMove(UINT nFlags, CPoint point)
{
CWnd* w = GetCapture();
- if(w && w->m_hWnd == m_hWnd && (nFlags & MK_LBUTTON))
- {
+ 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);
}
diff --git a/src/apps/mplayerc/PlayerSeekBar.h b/src/apps/mplayerc/PlayerSeekBar.h
index c59463b45..260198b8d 100644
--- a/src/apps/mplayerc/PlayerSeekBar.h
+++ b/src/apps/mplayerc/PlayerSeekBar.h
@@ -52,14 +52,14 @@ public:
void SetPos(__int64 pos);
-// Overrides
+ // Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CPlayerSeekBar)
virtual BOOL Create(CWnd* pParentWnd);
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
//}}AFX_VIRTUAL
-// Generated message map functions
+ // Generated message map functions
protected:
//{{AFX_MSG(CPlayerSeekBar)
afx_msg void OnPaint();
diff --git a/src/apps/mplayerc/PlayerShaderEditorBar.cpp b/src/apps/mplayerc/PlayerShaderEditorBar.cpp
index 53b0a0b01..79d2c397e 100644
--- a/src/apps/mplayerc/PlayerShaderEditorBar.cpp
+++ b/src/apps/mplayerc/PlayerShaderEditorBar.cpp
@@ -38,8 +38,9 @@ CPlayerShaderEditorBar::~CPlayerShaderEditorBar()
BOOL CPlayerShaderEditorBar::Create(CWnd* pParentWnd)
{
- if(!__super::Create(_T("Shader Editor"), pParentWnd, ID_VIEW_SHADEREDITOR))
+ if(!__super::Create(_T("Shader Editor"), pParentWnd, ID_VIEW_SHADEREDITOR)) {
return FALSE;
+ }
m_dlg.Create(this);
m_dlg.ShowWindow(SW_SHOWNORMAL);
@@ -56,16 +57,15 @@ BOOL CPlayerShaderEditorBar::Create(CWnd* pParentWnd)
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)
- {
+ 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))
+ if(IsDialogMessage(pMsg)) {
return TRUE;
+ }
}
return __super::PreTranslateMessage(pMsg);
@@ -81,8 +81,7 @@ void CPlayerShaderEditorBar::OnSize(UINT nType, int cx, int cy)
{
__super::OnSize(nType, cx, cy);
- if(::IsWindow(m_dlg.m_hWnd))
- {
+ if(::IsWindow(m_dlg.m_hWnd)) {
CRect r;
GetClientRect(r);
m_dlg.MoveWindow(r);
diff --git a/src/apps/mplayerc/PlayerStatusBar.cpp b/src/apps/mplayerc/PlayerStatusBar.cpp
index 45926481e..6370d21f1 100644
--- a/src/apps/mplayerc/PlayerStatusBar.cpp
+++ b/src/apps/mplayerc/PlayerStatusBar.cpp
@@ -42,7 +42,9 @@ CPlayerStatusBar::CPlayerStatusBar()
CPlayerStatusBar::~CPlayerStatusBar()
{
- if(m_hIcon) DestroyIcon(m_hIcon);
+ if(m_hIcon) {
+ DestroyIcon(m_hIcon);
+ }
}
BOOL CPlayerStatusBar::Create(CWnd* pParentWnd)
@@ -52,8 +54,9 @@ BOOL CPlayerStatusBar::Create(CWnd* pParentWnd)
BOOL CPlayerStatusBar::PreCreateWindow(CREATESTRUCT& cs)
{
- if(!CDialogBar::PreCreateWindow(cs))
+ if(!CDialogBar::PreCreateWindow(cs)) {
return FALSE;
+ }
m_dwStyle &= ~CBRS_BORDER_TOP;
m_dwStyle &= ~CBRS_BORDER_BOTTOM;
@@ -63,8 +66,9 @@ BOOL CPlayerStatusBar::PreCreateWindow(CREATESTRUCT& cs)
int CPlayerStatusBar::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
- if(CDialogBar::OnCreate(lpCreateStruct) == -1)
+ if(CDialogBar::OnCreate(lpCreateStruct) == -1) {
return -1;
+ }
CRect r;
r.SetRectEmpty();
@@ -89,7 +93,9 @@ void CPlayerStatusBar::Relayout()
{
BITMAP bm;
memset(&bm, 0, sizeof(bm));
- if(m_bm.m_hObject) m_bm.GetBitmap(&bm);
+ if(m_bm.m_hObject) {
+ m_bm.GetBitmap(&bm);
+ }
CRect r, r2;
GetClientRect(r);
@@ -99,8 +105,7 @@ void CPlayerStatusBar::Relayout()
CString str;
m_time.GetWindowText(str);
- if(CDC* pDC = m_time.GetDC())
- {
+ if(CDC* pDC = m_time.GetDC()) {
CFont* pOld = pDC->SelectObject(&m_time.GetFont());
div = r.right - pDC->GetTextExtent(str).cx;
pDC->SelectObject(pOld);
@@ -134,10 +139,16 @@ void CPlayerStatusBar::Clear()
void CPlayerStatusBar::SetStatusBitmap(UINT id)
{
- if(m_bmid == id) return;
+ if(m_bmid == id) {
+ return;
+ }
- if(m_bm.m_hObject) m_bm.DeleteObject();
- if(id) m_bm.LoadBitmap(id);
+ if(m_bm.m_hObject) {
+ m_bm.DeleteObject();
+ }
+ if(id) {
+ m_bm.LoadBitmap(id);
+ }
m_bmid = id;
Relayout();
@@ -145,9 +156,13 @@ void CPlayerStatusBar::SetStatusBitmap(UINT id)
void CPlayerStatusBar::SetStatusTypeIcon(HICON hIcon)
{
- if(m_hIcon == hIcon) return;
+ if(m_hIcon == hIcon) {
+ return;
+ }
- if(m_hIcon) DestroyIcon(m_hIcon);
+ if(m_hIcon) {
+ DestroyIcon(m_hIcon);
+ }
m_type.SetIcon(m_hIcon = hIcon);
Relayout();
@@ -172,7 +187,9 @@ void CPlayerStatusBar::SetStatusTimer(CString str)
{
CString tmp;
m_time.GetWindowText(tmp);
- if(tmp == str) return;
+ if(tmp == str) {
+ return;
+ }
str.Trim();
m_time.SetWindowText(str);
@@ -188,32 +205,30 @@ void CPlayerStatusBar::SetStatusTimer(REFERENCE_TIME rtNow, REFERENCE_TIME rtDur
CString str;
CString posstr, durstr;
- if(*pTimeFormat == TIME_FORMAT_MEDIA_TIME)
- {
+ if(*pTimeFormat == TIME_FORMAT_MEDIA_TIME) {
DVD_HMSF_TIMECODE tcNow = RT2HMSF(rtNow);
DVD_HMSF_TIMECODE tcDur = RT2HMSF(rtDur);
- if(tcDur.bHours > 0 || (rtNow >= rtDur && tcNow.bHours > 0))
+ if(tcDur.bHours > 0 || (rtNow >= rtDur && tcNow.bHours > 0)) {
posstr.Format(_T("%02d:%02d:%02d"), tcNow.bHours, tcNow.bMinutes, tcNow.bSeconds);
- else
+ } else {
posstr.Format(_T("%02d:%02d"), tcNow.bMinutes, tcNow.bSeconds);
+ }
- if(tcDur.bHours > 0)
+ if(tcDur.bHours > 0) {
durstr.Format(_T("%02d:%02d:%02d"), tcDur.bHours, tcDur.bMinutes, tcDur.bSeconds);
- else
+ } else {
durstr.Format(_T("%02d:%02d"), tcDur.bMinutes, tcDur.bSeconds);
+ }
- if(fHighPrecision)
- {
+ if(fHighPrecision) {
str.Format(_T("%s.%03d"), posstr, (rtNow/10000)%1000);
posstr = str;
str.Format(_T("%s.%03d"), durstr, (rtDur/10000)%1000);
durstr = str;
str.Empty();
}
- }
- else if(*pTimeFormat == TIME_FORMAT_FRAME)
- {
+ } else if(*pTimeFormat == TIME_FORMAT_FRAME) {
posstr.Format(_T("%I64d"), rtNow);
durstr.Format(_T("%I64d"), rtDur);
}
@@ -246,9 +261,10 @@ 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);
@@ -261,11 +277,13 @@ BOOL CPlayerStatusBar::OnEraseBkgnd(CDC* pDC)
CMainFrame* pFrame = ((CMainFrame*)GetParentFrame());
- if(pFrame->m_pLastBar != this || pFrame->m_fFullScreen)
+ if(pFrame->m_pLastBar != this || pFrame->m_fFullScreen) {
r.InflateRect(0, 0, 0, 1);
+ }
- if(pFrame->m_fFullScreen)
+ if(pFrame->m_fFullScreen) {
r.InflateRect(1, 0, 1, 0);
+ }
pDC->Draw3dRect(&r, GetSysColor(COLOR_3DSHADOW), GetSysColor(COLOR_3DHILIGHT));
@@ -282,8 +300,7 @@ void CPlayerStatusBar::OnPaint()
CRect r;
- if(m_bm.m_hObject)
- {
+ if(m_bm.m_hObject) {
BITMAP bm;
m_bm.GetBitmap(&bm);
CDC memdc;
@@ -320,15 +337,14 @@ void CPlayerStatusBar::OnLButtonDown(UINT nFlags, CPoint point)
wp.length = sizeof(wp);
pFrame->GetWindowPlacement(&wp);
- if(!pFrame->m_fFullScreen && wp.showCmd != SW_SHOWMAXIMIZED)
- {
+ if(!pFrame->m_fFullScreen && wp.showCmd != SW_SHOWMAXIMIZED) {
CRect r;
GetClientRect(r);
CPoint p = point;
MapWindowPoints(pFrame, &point, 1);
pFrame->PostMessage(WM_NCLBUTTONDOWN,
-// (p.x+p.y >= r.Width()) ? HTBOTTOMRIGHT : HTCAPTION,
+ // (p.x+p.y >= r.Width()) ? HTBOTTOMRIGHT : HTCAPTION,
(p.x >= r.Width()-r.Height() && !pFrame->IsCaptionMenuHidden()) ? HTBOTTOMRIGHT :
HTCAPTION,
MAKELPARAM(point.x, point.y));
@@ -343,16 +359,14 @@ BOOL CPlayerStatusBar::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
wp.length = sizeof(wp);
pFrame->GetWindowPlacement(&wp);
- if(!pFrame->m_fFullScreen && wp.showCmd != SW_SHOWMAXIMIZED)
- {
+ if(!pFrame->m_fFullScreen && wp.showCmd != SW_SHOWMAXIMIZED) {
CRect r;
GetClientRect(r);
CPoint p;
GetCursorPos(&p);
ScreenToClient(&p);
-// if(p.x+p.y >= r.Width())
- if(p.x >= r.Width()-r.Height() && !pFrame->IsCaptionMenuHidden())
- {
+ // if(p.x+p.y >= r.Width())
+ if(p.x >= r.Width()-r.Height() && !pFrame->IsCaptionMenuHidden()) {
SetCursor(LoadCursor(NULL, IDC_SIZENWSE));
return TRUE;
}
@@ -365,8 +379,7 @@ HBRUSH CPlayerStatusBar::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialogBar::OnCtlColor(pDC, pWnd, nCtlColor);
- if(*pWnd == m_type)
- {
+ if(*pWnd == m_type) {
hbr = GetStockBrush(BLACK_BRUSH);
}
diff --git a/src/apps/mplayerc/PlayerStatusBar.h b/src/apps/mplayerc/PlayerStatusBar.h
index c4fa89a34..bf1783a73 100644
--- a/src/apps/mplayerc/PlayerStatusBar.h
+++ b/src/apps/mplayerc/PlayerStatusBar.h
@@ -55,7 +55,7 @@ public:
CString GetStatusTimer();
void ShowTimer(bool fShow);
-// Overrides
+ // Overrides
virtual BOOL Create(CWnd* pParentWnd);
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
diff --git a/src/apps/mplayerc/PlayerSubresyncBar.cpp b/src/apps/mplayerc/PlayerSubresyncBar.cpp
index 94412fc94..77d3ee306 100644
--- a/src/apps/mplayerc/PlayerSubresyncBar.cpp
+++ b/src/apps/mplayerc/PlayerSubresyncBar.cpp
@@ -43,8 +43,9 @@ CPlayerSubresyncBar::~CPlayerSubresyncBar()
BOOL CPlayerSubresyncBar::Create(CWnd* pParentWnd, CCritSec* pSubLock)
{
- if(!CSizingControlBarG::Create(_T("Subresync"), pParentWnd, ID_VIEW_SUBRESYNC))
+ if(!CSizingControlBarG::Create(_T("Subresync"), pParentWnd, ID_VIEW_SUBRESYNC)) {
return FALSE;
+ }
m_pSubLock = pSubLock;
@@ -60,24 +61,24 @@ BOOL CPlayerSubresyncBar::Create(CWnd* pParentWnd, CCritSec* pSubLock)
BOOL CPlayerSubresyncBar::PreCreateWindow(CREATESTRUCT& cs)
{
- if(!CSizingControlBarG::PreCreateWindow(cs))
+ if(!CSizingControlBarG::PreCreateWindow(cs)) {
return FALSE;
+ }
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)
- {
+ 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))
+ if(IsShortCut(pMsg) || IsDialogMessage(pMsg)) {
return TRUE;
+ }
}
return CSizingControlBarG::PreTranslateMessage(pMsg);
@@ -89,12 +90,13 @@ void CPlayerSubresyncBar::SetTime(__int64 rt)
int curSegment;
- if(!m_sts.SearchSubs((int)(rt/10000), 25, &curSegment))
- {
+ if(!m_sts.SearchSubs((int)(rt/10000), 25, &curSegment)) {
curSegment = -1;
}
- if(m_lastSegment != curSegment) m_list.Invalidate();
+ if(m_lastSegment != curSegment) {
+ m_list.Invalidate();
+ }
m_lastSegment = curSegment;
}
@@ -108,13 +110,14 @@ void CPlayerSubresyncBar::SetSubtitle(ISubStream* pSubStream, double fps)
ResetSubtitle();
- if(!m_pSubStream) return;
+ if(!m_pSubStream) {
+ return;
+ }
CLSID clsid;
m_pSubStream->GetClassID(&clsid);
- if(clsid == __uuidof(CVobSubFile))
- {
+ if(clsid == __uuidof(CVobSubFile)) {
CVobSubFile* pVSF = (CVobSubFile*)(ISubStream*)m_pSubStream;
m_mode = VOBSUB;
@@ -122,8 +125,7 @@ void CPlayerSubresyncBar::SetSubtitle(ISubStream* pSubStream, double fps)
_ASSERT(pVSF->m_iLang >= 0);
CAtlArray<CVobSubFile::SubPos>& sp = pVSF->m_langs[pVSF->m_iLang].subpos;
- for(int i = 0, j = sp.GetCount(); i < j; i++)
- {
+ for(int i = 0, j = sp.GetCount(); i < j; i++) {
CString str;
str.Format(_T("%d,%d,%d,%d"), sp[i].vobid, sp[i].cellid, sp[i].fForced, i);
m_sts.Add(TToW(str), false, (int)sp[i].start, (int)sp[i].stop);
@@ -133,7 +135,9 @@ void CPlayerSubresyncBar::SetSubtitle(ISubStream* pSubStream, double fps)
pVSF->m_fOnlyShowForcedSubs = false;
- for(int i = 0, j = m_list.GetHeaderCtrl()->GetItemCount(); i < j; i++) m_list.DeleteColumn(0);
+ for(int i = 0, j = m_list.GetHeaderCtrl()->GetItemCount(); i < j; i++) {
+ m_list.DeleteColumn(0);
+ }
m_list.InsertColumn(COL_START, _T("Time"), LVCFMT_LEFT, 80);
m_list.InsertColumn(COL_END, _T("End"), LVCFMT_LEFT, 80);
m_list.InsertColumn(COL_PREVSTART, _T("Preview"), LVCFMT_LEFT, 80);
@@ -141,9 +145,7 @@ void CPlayerSubresyncBar::SetSubtitle(ISubStream* pSubStream, double fps)
m_list.InsertColumn(COL_VOBID, _T("Vob ID"), LVCFMT_CENTER, 60);
m_list.InsertColumn(COL_CELLID, _T("Cell ID"), LVCFMT_CENTER, 60);
m_list.InsertColumn(COL_FORCED, _T("Forced"), LVCFMT_CENTER, 60);
- }
- else if(clsid == __uuidof(CRenderedTextSubtitle))
- {
+ } else if(clsid == __uuidof(CRenderedTextSubtitle)) {
CRenderedTextSubtitle* pRTS = (CRenderedTextSubtitle*)(ISubStream*)m_pSubStream;
m_mode = TEXTSUB;
@@ -153,8 +155,7 @@ void CPlayerSubresyncBar::SetSubtitle(ISubStream* pSubStream, double fps)
m_sts.Sort(true); /*!!m_fUnlink*/
#ifndef UNICODE
- if(!m_sts.IsEntryUnicode(0))
- {
+ if(!m_sts.IsEntryUnicode(0)) {
CFont* f = m_list.GetFont();
LOGFONT lf;
f->GetLogFont(&lf);
@@ -164,8 +165,9 @@ void CPlayerSubresyncBar::SetSubtitle(ISubStream* pSubStream, double fps)
m_list.SetFont(&m_font);
}
#endif
- for(int i = 0, j = m_list.GetHeaderCtrl()->GetItemCount(); i < j; i++)
+ for(int i = 0, j = m_list.GetHeaderCtrl()->GetItemCount(); i < j; i++) {
m_list.DeleteColumn(0);
+ }
m_list.InsertColumn(COL_START, _T("Time"), LVCFMT_LEFT, 90);
m_list.InsertColumn(COL_END, _T("End"), LVCFMT_LEFT, 4);
m_list.InsertColumn(COL_PREVSTART, _T("Preview"), LVCFMT_LEFT, 80);
@@ -182,8 +184,7 @@ void CPlayerSubresyncBar::SetSubtitle(ISubStream* pSubStream, double fps)
m_subtimes.SetCount(m_sts.GetCount());
- for(int i = 0, j = m_sts.GetCount(); i < j; i++)
- {
+ for(int 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;
}
@@ -195,14 +196,12 @@ void CPlayerSubresyncBar::ResetSubtitle()
{
m_list.DeleteAllItems();
- if(m_mode == VOBSUB || m_mode == TEXTSUB)
- {
+ if(m_mode == VOBSUB || m_mode == TEXTSUB) {
TCHAR buff[32];
int prevstart = INT_MIN;
- for(int i = 0, j = m_sts.GetCount(); i < j; i++)
- {
+ 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, 0, false);
@@ -210,8 +209,9 @@ void CPlayerSubresyncBar::ResetSubtitle()
FormatTime(i, buff, 0, true);
m_list.SetItemText(i, COL_END, buff);
- if(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);
@@ -229,13 +229,14 @@ void CPlayerSubresyncBar::ResetSubtitle()
void CPlayerSubresyncBar::SaveSubtitle()
{
CMainFrame* pFrame = ((CMainFrame*)AfxGetMainWnd());
- if(!pFrame) return;
+ if(!pFrame) {
+ return;
+ }
CLSID clsid;
m_pSubStream->GetClassID(&clsid);
- if(clsid == __uuidof(CVobSubFile) && m_mode == VOBSUB)
- {
+ if(clsid == __uuidof(CVobSubFile) && m_mode == VOBSUB) {
CVobSubFile* pVSF = (CVobSubFile*)(ISubStream*)m_pSubStream;
CAutoLock cAutoLock(m_pSubLock);
@@ -243,30 +244,26 @@ void CPlayerSubresyncBar::SaveSubtitle()
_ASSERT(pVSF->m_iLang >= 0);
CAtlArray<CVobSubFile::SubPos>& sp = pVSF->m_langs[pVSF->m_iLang].subpos;
- for(int i = 0, j = sp.GetCount(); i < j; i++)
- {
+ for(int i = 0, j = sp.GetCount(); i < j; i++) {
sp[i].fValid = false;
}
- for(int i = 0, j = m_sts.GetCount(); i < j; i++)
- {
+ for(int i = 0, j = m_sts.GetCount(); i < j; i++) {
int vobid, cellid, forced, spnum, c;
- if(_stscanf(m_sts.GetStr(i), _T("%d%c%d%c%d%c%d"), &vobid, &c, &cellid, &c, &forced, &c, &spnum) != 7) continue;
+ if(_stscanf(m_sts.GetStr(i), _T("%d%c%d%c%d%c%d"), &vobid, &c, &cellid, &c, &forced, &c, &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)
- {
+ } else if(clsid == __uuidof(CRenderedTextSubtitle) && m_mode == TEXTSUB) {
CRenderedTextSubtitle* pRTS = (CRenderedTextSubtitle*)(ISubStream*)m_pSubStream;
CAutoLock cAutoLock(m_pSubLock);
pRTS->Copy(m_sts);
- }
- else
- {
+ } else {
return;
}
@@ -275,58 +272,47 @@ void CPlayerSubresyncBar::SaveSubtitle()
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++)
- {
+ 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
- {
+ } else {
CAtlArray<int> schk;
- for(int i = 0, j = m_sts.GetCount(); i < j;)
- {
+ for(int i = 0, j = m_sts.GetCount(); i < j;) {
schk.RemoveAll();
int start = i, end;
- for(end = i; end < j; end++)
- {
+ for(end = i; end < j; end++) {
int data = (int)m_list.GetItemData(end);
- if((data&TSEP) && end > i) break;
- if(data&(TSMOD|TSADJ))
+ if((data&TSEP) && end > i) {
+ break;
+ }
+ if(data&(TSMOD|TSADJ)) {
schk.Add(end);
+ }
}
- if(schk.GetCount() == 0)
- {
- for(; start < end; start++)
- {
+ 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)
- {
+ } else if(schk.GetCount() == 1) {
int k = schk[0];
int dt = m_subtimes[k].newstart - m_subtimes[k].orgstart;
- for(; start < end; start++)
- {
+ 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)
- {
+ } else if(schk.GetCount() >= 2) {
int i0 = 0;
int i1 = 0;
int ti0 = 0;
@@ -334,18 +320,16 @@ void CPlayerSubresyncBar::UpdatePreview()
double m = 0;
int k, l;
- for(k = 0, l = schk.GetCount()-1; k < l; k++)
- {
+ 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)
+ if (ds == 0) {
SetSTS0(start, i1, ti0);
- else
- {
+ } else {
m = double(m_subtimes[i1].newstart - m_subtimes[i0].newstart) / ds;
SetSTS1(start, i1, ti0, m, i0);
}
@@ -353,10 +337,11 @@ void CPlayerSubresyncBar::UpdatePreview()
}
ASSERT(k > 0);
- if (ds == 0)
+ if (ds == 0) {
SetSTS0(start, end, ti0);
- else
+ } else {
SetSTS1(start, end, ti0, m, i0);
+ }
}
i = end;
@@ -365,8 +350,7 @@ void CPlayerSubresyncBar::UpdatePreview()
m_sts.CreateSegments();
- for(int i = 0, j = m_sts.GetCount(); i < j; i++)
- {
+ for(int i = 0, j = m_sts.GetCount(); i < j; i++) {
TCHAR buff[32];
FormatTime(i, buff, 2, false);
m_list.SetItemText(i, COL_PREVSTART, buff);
@@ -374,8 +358,7 @@ void CPlayerSubresyncBar::UpdatePreview()
m_list.SetItemText(i, COL_PREVEND, buff);
}
- if(IsWindowVisible())
- {
+ if(IsWindowVisible()) {
SaveSubtitle();
}
}
@@ -383,33 +366,32 @@ void CPlayerSubresyncBar::UpdatePreview()
void CPlayerSubresyncBar::SetSTS0( int &start, int end, int ti0 )
{
- for(; start < end; start++)
- {
+ for(; start < end; start++) {
m_sts[start].start = ti0;
int endpos;
- if (m_list.GetItemData(start)&TEMOD)
+ if (m_list.GetItemData(start)&TEMOD) {
endpos = m_subtimes[start].newend;
- else
+ } 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 )
{
- for(; start < end; start++)
- {
+ 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)
+ if (m_list.GetItemData(start)&TEMOD) {
endpos = m_subtimes[start].newend;
- else
- {
+ } else {
int diff = m_subtimes[start].orgend - m_subtimes[start].orgstart;
- if (m_mode == VOBSUB)
+ if (m_mode == VOBSUB) {
endpos = m_sts[start].start + diff;
- else
+ } else {
endpos = m_sts[start].start + int(diff*m);
+ }
}
m_sts[start].end = endpos;
}
@@ -419,10 +401,8 @@ void CPlayerSubresyncBar::UpdateStrings()
{
CString str;
- if(m_mode == TEXTSUB)
- {
- for(int i = 0, j = m_sts.GetCount(); i < j; i++)
- {
+ if(m_mode == TEXTSUB) {
+ for(int i = 0, j = m_sts.GetCount(); i < j; i++) {
STSStyle stss;
m_sts.GetStyle(i, stss);
@@ -437,18 +417,23 @@ void CPlayerSubresyncBar::UpdateStrings()
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++)
- {
+ } else if(m_mode == VOBSUB) {
+ for(int i = 0, j = m_sts.GetCount(); i < j; i++) {
int vobid, cellid, forced, c;
- if(_stscanf(m_sts.GetStr(i), _T("%d%c%d%c%d"), &vobid, &c, &cellid, &c, &forced) != 5) continue;
- if(vobid < 0) str = _T("-");
- else str.Format(_T("%d"), vobid);
+ if(_stscanf(m_sts.GetStr(i), _T("%d%c%d%c%d"), &vobid, &c, &cellid, &c, &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);
+ 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);
@@ -458,8 +443,7 @@ void CPlayerSubresyncBar::UpdateStrings()
void CPlayerSubresyncBar::GetCheck(int iItem, bool& fStartMod, bool& fEndMod, bool& fStartAdj, bool& fEndAdj)
{
- if(0 <= iItem && iItem < m_sts.GetCount())
- {
+ if(0 <= iItem && iItem < m_sts.GetCount()) {
int nCheck = (int)m_list.GetItemData(iItem);
fStartMod = !!(nCheck&TSMOD);
fEndMod = !!(nCheck&TEMOD);
@@ -470,16 +454,21 @@ void CPlayerSubresyncBar::GetCheck(int iItem, bool& fStartMod, bool& fEndMod, bo
void CPlayerSubresyncBar::SetCheck(int iItem, bool fStart, bool fEnd)
{
- if(0 <= iItem && iItem < m_sts.GetCount())
- {
+ if(0 <= iItem && 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;
+ 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);
@@ -500,13 +489,16 @@ bool CPlayerSubresyncBar::ModStart(int iItem, int t, bool fReset)
SubTime& st = m_subtimes[iItem];
-// if(fStartMod || fStartAdj || st.orgstart != t || fReset)
+ // 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);
+ 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);
}
@@ -523,13 +515,16 @@ bool CPlayerSubresyncBar::ModEnd(int iItem, int t, bool fReset)
SubTime& st = m_subtimes[iItem];
-// if(fEndMod || fEndAdj || st.orgend != t || fReset)
+ // 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);
+ 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);
}
@@ -575,8 +570,7 @@ void CPlayerSubresyncBar::OnSize(UINT nType, int cx, int cy)
{
CSizingControlBarG::OnSize(nType, cx, cy);
- if(::IsWindow(m_list.m_hWnd))
- {
+ if(::IsWindow(m_list.m_hWnd)) {
CRect r;
GetClientRect(r);
r.DeflateRect(2, 2);
@@ -590,7 +584,9 @@ static bool ParseTime(CString str, int& ret, bool fWarn = true)
TCHAR c;
str.Trim();
- if(str.GetLength() > 0 && str[0] == '-') sign = -1;
+ if(str.GetLength() > 0 && str[0] == '-') {
+ sign = -1;
+ }
int n = _stscanf(str, _T("%d%c%d%c%d%c%d"), &h, &c, &m, &c, &s, &c, &ms);
@@ -600,13 +596,14 @@ static bool ParseTime(CString str, int& ret, bool fWarn = true)
&& 0 <= h && h < 24
&& 0 <= m && m < 60
&& 0 <= s && s < 60
- && 0 <= ms && ms < 1000)
- {
+ && 0 <= ms && ms < 1000) {
ret = sign*(h*60*60*1000+m*60*1000+s*1000+ms);
return(true);
}
- if(fWarn) AfxMessageBox(_T("The correct time format is [-]hh:mm:ss.ms\n(e.g. 01:23:45.678)"));
+ if(fWarn) {
+ AfxMessageBox(_T("The correct time format is [-]hh:mm:ss.ms\n(e.g. 01:23:45.678)"));
+ }
return(false);
}
@@ -617,18 +614,14 @@ void CPlayerSubresyncBar::OnBeginlabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
*pResult = FALSE;
- if(pItem->iItem >= 0)
- {
+ 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_mode == TEXTSUB) {
*pResult = TRUE;
- }
- else if((pItem->iSubItem == COL_START)
- && m_mode == VOBSUB)
- {
+ } else if((pItem->iSubItem == COL_START)
+ && m_mode == VOBSUB) {
*pResult = TRUE;
}
}
@@ -641,19 +634,15 @@ void CPlayerSubresyncBar::OnDolabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
*pResult = FALSE;
- if(pItem->iItem >= 0)
- {
+ 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_mode == TEXTSUB) {
m_list.ShowInPlaceEdit(pItem->iItem, pItem->iSubItem);
*pResult = TRUE;
- }
- else if((pItem->iSubItem == COL_START)
- && m_mode == VOBSUB)
- {
+ } else if((pItem->iSubItem == COL_START)
+ && m_mode == VOBSUB) {
m_list.ShowInPlaceEdit(pItem->iItem, pItem->iSubItem);
*pResult = TRUE;
}
@@ -667,115 +656,100 @@ void CPlayerSubresyncBar::OnEndlabeleditList(NMHDR* pNMHDR, LRESULT* pResult)
*pResult = FALSE;
- if(!m_list.m_fInPlaceDirty)
+ 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)
- {
+ 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 = ModEnd(pItem->iItem, t);
+ if(ParseTime(pItem->pszText, t)) {
+ fNeedsUpdate = ModStart(pItem->iItem, t);
*pResult = TRUE;
}
}
break;
- case COL_TEXT:
- if(m_mode == TEXTSUB)
- {
- CString str = m_sts.GetStr(pItem->iItem, true);
+ case COL_END:
+ if(m_mode == TEXTSUB) {
+ int t;
+ if(ParseTime(pItem->pszText, t)) {
+ fNeedsUpdate = ModEnd(pItem->iItem, t);
- 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));
+ *pResult = TRUE;
+ }
}
- }
- break;
- case COL_STYLE:
- if(m_mode == TEXTSUB)
- {
- CString str(pItem->pszText);
- str.Trim();
+ break;
+ case COL_TEXT:
+ if(m_mode == TEXTSUB) {
+ CString str = m_sts.GetStr(pItem->iItem, true);
- if(!str.IsEmpty() && m_sts[pItem->iItem].style != str)
- {
- fNeedsUpdate = 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(!m_sts.m_styles.Lookup(str))
- m_sts.AddStyle(str, DNew STSStyle());
+ if(!str.IsEmpty() && m_sts[pItem->iItem].style != str) {
+ fNeedsUpdate = true;
- m_sts[pItem->iItem].style = str;
+ if(!m_sts.m_styles.Lookup(str)) {
+ m_sts.AddStyle(str, DNew STSStyle());
+ }
- m_list.SetItemText(pItem->iItem, pItem->iSubItem, pItem->pszText);
+ 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_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_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;
+ 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;
+ break;
}
}
- if(fNeedsUpdate)
- {
+ if(fNeedsUpdate) {
UpdatePreview();
}
}
@@ -789,10 +763,8 @@ void CPlayerSubresyncBar::OnRclickList(NMHDR* pNMHDR, LRESULT* pResult)
{
LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)pNMHDR;
- if(lpnmlv->iItem >= 0 && lpnmlv->iSubItem >= 0)
- {
- enum
- {
+ if(lpnmlv->iItem >= 0 && lpnmlv->iSubItem >= 0) {
+ enum {
TOGSEP=1,
DUPITEM, DELITEM,
RESETS, SETOS, SETCS, RESETE, SETOE, SETCE,
@@ -810,134 +782,123 @@ void CPlayerSubresyncBar::OnRclickList(NMHDR* pNMHDR, LRESULT* pResult)
CMenu m;
m.CreatePopupMenu();
- if(m_mode == VOBSUB || m_mode == TEXTSUB)
- {
+ 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));
+ 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);
+ 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"));
}
-
- if(id > STYLEFIRST && m_list.GetSelectedCount() == 1)
- {
+ break;
+ case COL_END:
+ if(m_mode == TEXTSUB) {
m.AppendMenu(MF_SEPARATOR);
- m.AppendMenu(MF_STRING|MF_ENABLED, STYLEEDIT, ResStr(IDS_SUBRESYNC_EDIT));
+ 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_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;
+ break;
+ case COL_STYLE:
+ if(m_mode == TEXTSUB) {
+ m.AppendMenu(MF_SEPARATOR);
- for(int i = 0, j = m_sts.GetCount(); i < j; i++)
- actormap[m_sts[i].actor] = NULL;
+ int id = STYLEFIRST;
- actormap.RemoveKey(_T(""));
+ 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(actormap.GetCount() > 0)
- {
+ 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;
- int id = ACTORFIRST;
+ for(int i = 0, j = m_sts.GetCount(); i < j; i++) {
+ actormap[m_sts[i].actor] = NULL;
+ }
- POSITION pos = actormap.GetStartPosition();
- while(pos && id <= ACTORLAST)
- {
- CString key;
- void* val;
- actormap.GetNextAssoc(pos, key, val);
+ actormap.RemoveKey(_T(""));
- actors.Add(key);
+ if(actormap.GetCount() > 0) {
+ m.AppendMenu(MF_SEPARATOR);
- m.AppendMenu(MF_STRING|MF_ENABLED, id++, key);
+ 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;
+ break;
+ case COL_EFFECT:
+ if(m_mode == TEXTSUB) {
+ CMapStringToPtr effectmap;
- for(int i = 0, j = m_sts.GetCount(); i < j; i++)
- effectmap[m_sts[i].effect] = NULL;
+ for(int i = 0, j = m_sts.GetCount(); i < j; i++) {
+ effectmap[m_sts[i].effect] = NULL;
+ }
- effectmap.RemoveKey(_T(""));
+ effectmap.RemoveKey(_T(""));
- if(effectmap.GetCount() > 0)
- {
- m.AppendMenu(MF_SEPARATOR);
+ if(effectmap.GetCount() > 0) {
+ m.AppendMenu(MF_SEPARATOR);
- int id = EFFECTFIRST;
+ int id = EFFECTFIRST;
- POSITION pos = effectmap.GetStartPosition();
- while(pos && id <= EFFECTLAST)
- {
- CString key;
- void* val;
- effectmap.GetNextAssoc(pos, key, val);
+ POSITION pos = effectmap.GetStartPosition();
+ while(pos && id <= EFFECTLAST) {
+ CString key;
+ void* val;
+ effectmap.GetNextAssoc(pos, key, val);
- effects.Add(key);
+ effects.Add(key);
- m.AppendMenu(MF_STRING|MF_ENABLED, id++, key);
+ m.AppendMenu(MF_STRING|MF_ENABLED, id++, key);
+ }
}
}
- }
- break;
+ break;
}
CPoint p = lpnmlv->ptAction;
@@ -948,197 +909,193 @@ void CPlayerSubresyncBar::OnRclickList(NMHDR* pNMHDR, LRESULT* pResult)
bool fNeedsUpdate = false;
POSITION pos = m_list.GetFirstSelectedItemPosition();
- while(pos)
- {
+ 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);
+ 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));
+ }
- for(int i = 0; i < items.GetCount(); i++)
- {
- iItem = items[i];
+ qsort(items.GetData(), items.GetCount(), sizeof(UINT), uintcomp);
- STSEntry stse = m_sts[iItem];
- m_sts.InsertAt(iItem+1, stse);
+ for(int i = 0; i < items.GetCount(); i++) {
+ iItem = items[i];
- SubTime st = m_subtimes[iItem];
- m_subtimes.InsertAt(iItem+1, st);
+ STSEntry stse = m_sts[iItem];
+ m_sts.InsertAt(iItem+1, stse);
- CHeaderCtrl* pHeader = (CHeaderCtrl*)m_list.GetDlgItem(0);
- int nColumnCount = pHeader->GetItemCount();
+ SubTime st = m_subtimes[iItem];
+ m_subtimes.InsertAt(iItem+1, st);
- CStringArray sa;
- sa.SetSize(nColumnCount);
- for(int col = 0; col < nColumnCount; col++)
- sa[col] = m_list.GetItemText(iItem, col);
+ CHeaderCtrl* pHeader = (CHeaderCtrl*)m_list.GetDlgItem(0);
+ int nColumnCount = pHeader->GetItemCount();
- DWORD 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]);
- }
- }
+ CStringArray sa;
+ sa.SetSize(nColumnCount);
+ for(int col = 0; col < nColumnCount; col++) {
+ sa[col] = m_list.GetItemText(iItem, 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 i = 0; i < items.GetCount(); i++)
- {
- iItem = items[i];
- m_sts.RemoveAt(iItem);
- m_subtimes.RemoveAt(iItem);
- m_list.DeleteItem(iItem);
+ DWORD 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]);
+ }
+ }
}
- 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;
+ case DELITEM: {
+ CUIntArray items;
+ pos = m_list.GetFirstSelectedItemPosition();
+ while(pos) {
+ items.Add(m_list.GetNextSelectedItem(pos));
+ }
- 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);
+ qsort(items.GetData(), items.GetCount(), sizeof(UINT), uintcomp);
- CAutoPtr<CPPageSubStyle> page(DNew CPPageSubStyle());
- page->InitStyle(key, *val);
- pages.Add(page);
- styles.Add(val);
+ for(int i = 0; i < items.GetCount(); i++) {
+ iItem = items[i];
+ m_sts.RemoveAt(iItem);
+ m_subtimes.RemoveAt(iItem);
+ m_list.DeleteItem(iItem);
+ }
- if(stss == val)
- iSelPage = i;
+ iItem = items[items.GetCount()-1];
+ if(iItem >= m_list.GetItemCount()) {
+ iItem = m_list.GetItemCount()-1;
}
- CPropertySheet dlg(_T("Styles..."), this, iSelPage);
- 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++)
- {
- stss = styles[j];
- pages[j]->GetStyle(*stss);
-
- for(int 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);
- }
+ 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(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++) {
+ stss = styles[j];
+ pages[j]->GetStyle(*stss);
+
+ for(int 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);
}
- }
- 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;
+ break;
}
}
- if(fNeedsUpdate)
- {
+ if(fNeedsUpdate) {
UpdatePreview();
}
}
@@ -1150,13 +1107,12 @@ void CPlayerSubresyncBar::OnNMDblclkList(NMHDR* pNMHDR, LRESULT* pResult)
{
LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)pNMHDR;
- if(lpnmlv->iItem >= 0 && lpnmlv->iSubItem >= 0 && (m_mode == VOBSUB || m_mode == TEXTSUB))
- {
- if(CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd())
- {
+ if(lpnmlv->iItem >= 0 && lpnmlv->iSubItem >= 0 && (m_mode == VOBSUB || m_mode == TEXTSUB)) {
+ if(CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd()) {
int t = 0;
- if(!ParseTime(m_list.GetItemText(lpnmlv->iItem, lpnmlv->iSubItem), t, false))
+ if(!ParseTime(m_list.GetItemText(lpnmlv->iItem, lpnmlv->iSubItem), t, false)) {
t = m_sts[lpnmlv->iItem].start;
+ }
REFERENCE_TIME rt =
lpnmlv->iSubItem == COL_START ? ((REFERENCE_TIME)t*10000) :
@@ -1189,71 +1145,55 @@ void CPlayerSubresyncBar::OnCustomdrawList(NMHDR* pNMHDR, LRESULT* pResult)
*pResult = CDRF_DODEFAULT;
- if(CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage)
- {
+ 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++;
+ 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)
- {
+ } 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)
- {
+ } 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)
- {
+ && m_mode == TEXTSUB) {
clrText = 0;
- }
- else if((pLVCD->iSubItem == COL_START)
- && m_mode == VOBSUB)
- {
+ } else if((pLVCD->iSubItem == COL_START)
+ && m_mode == VOBSUB) {
clrText = 0;
- }
- else
- {
+ } else {
clrText = 0x606060;
}
clrTextBk = 0xffffff;
-// if(m_totalGroups > 0)
+ // 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)
- {
+ 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(pLVCD->nmcd.dwItemSpec);
- if((nCheck&1) && (pLVCD->iSubItem == COL_START || pLVCD->iSubItem == COL_PREVSTART))
- {
+ 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))
- {
+ } 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))
- {
+ 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))
- {
+ } else if((nCheck&8) && (/*pLVCD->iSubItem == COL_END ||*/ pLVCD->iSubItem == COL_PREVEND)) {
clrTextBk = 0xffeedd;
}
@@ -1261,13 +1201,9 @@ void CPlayerSubresyncBar::OnCustomdrawList(NMHDR* pNMHDR, LRESULT* pResult)
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)
- {
+ } 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;
@@ -1301,8 +1237,7 @@ void CPlayerSubresyncBar::OnCustomdrawList(NMHDR* pNMHDR, LRESULT* pResult)
// Get the column offset
int offset = rcItem.left;
- for(int i = 0; i < nColumnCount; i++)
- {
+ for(int i = 0; i < nColumnCount; i++) {
offset += m_list.GetColumnWidth(i);
pDC->MoveTo(CPoint(offset, rcItem.top));
pDC->LineTo(CPoint(offset, rcItem.bottom));
@@ -1313,62 +1248,55 @@ void CPlayerSubresyncBar::OnCustomdrawList(NMHDR* pNMHDR, LRESULT* pResult)
*pResult = CDRF_SKIPDEFAULT;
}
- }
- else if(CDDS_POSTPAINT == pLVCD->nmcd.dwDrawStage)
- {
+ } 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)
- {
+ 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)
- {
+ 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;
+ 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)
- {
+ 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);
@@ -1389,22 +1317,18 @@ int CPlayerSubresyncBar::FindNearestSub(__int64& rtPos, bool bForward)
{
long lCurTime = rtPos / 10000 + (bForward ? 1 : -1);
- if (m_subtimes.GetCount() == 0)
- {
+ if (m_subtimes.GetCount() == 0) {
rtPos = max (0, rtPos + (bForward ? 1 : -1) * 50000000);
return -2;
}
- if (lCurTime < m_subtimes[0].newstart)
- {
+ 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))
- {
+ 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;
}
@@ -1418,10 +1342,8 @@ 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 (int i= nItem; i<m_sts.GetCount(); i++)
- {
+ if ((nItem == 0) || (m_subtimes[nItem-1].newend < m_subtimes[nItem].newstart + lValue)) {
+ for (int i= nItem; i<m_sts.GetCount(); i++) {
m_subtimes[i].newstart += lValue;
m_subtimes[i].newend += lValue;
m_subtimes[i].orgstart += lValue;
diff --git a/src/apps/mplayerc/PlayerSubresyncBar.h b/src/apps/mplayerc/PlayerSubresyncBar.h
index 050c50ff0..1369c9824 100644
--- a/src/apps/mplayerc/PlayerSubresyncBar.h
+++ b/src/apps/mplayerc/PlayerSubresyncBar.h
@@ -46,8 +46,7 @@ private:
int m_lastSegment;
__int64 m_rt;
- enum
- {
+ 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
@@ -59,13 +58,12 @@ private:
bool m_fUnlink;
- typedef struct
- {
+ typedef struct {
int orgstart, newstart, orgend, newend;
} SubTime;
CAtlArray<SubTime> m_subtimes;
-// CRenderedTextSubtitle m_sts;
+ // CRenderedTextSubtitle m_sts;
CSimpleTextSubtitle m_sts;
int GetStartTime(int iItem), GetEndTime(int iItem);
diff --git a/src/apps/mplayerc/PlayerToolBar.cpp b/src/apps/mplayerc/PlayerToolBar.cpp
index 4c6ba5a90..651df397a 100644
--- a/src/apps/mplayerc/PlayerToolBar.cpp
+++ b/src/apps/mplayerc/PlayerToolBar.cpp
@@ -47,10 +47,12 @@ BOOL CPlayerToolBar::Create(CWnd* pParentWnd)
{
if(!__super::CreateEx(pParentWnd,
TBSTYLE_FLAT|TBSTYLE_TRANSPARENT|TBSTYLE_AUTOSIZE,
- WS_CHILD|WS_VISIBLE|CBRS_ALIGN_BOTTOM|CBRS_TOOLTIPS, CRect(2,2,0,3)))
+ WS_CHILD|WS_VISIBLE|CBRS_ALIGN_BOTTOM|CBRS_TOOLTIPS, CRect(2,2,0,3))) {
return FALSE;
- if(!LoadToolBar(IDB_PLAYERTOOLBAR))
+ }
+ if(!LoadToolBar(IDB_PLAYERTOOLBAR)) {
return FALSE;
+ }
GetToolBarCtrl().SetExtendedStyle(TBSTYLE_EX_DRAWDDARROWS);
@@ -60,8 +62,7 @@ BOOL CPlayerToolBar::Create(CWnd* pParentWnd)
SetMute(AfxGetAppSettings().fMute);
- UINT styles[] =
- {
+ UINT styles[] = {
TBBS_CHECKGROUP, TBBS_CHECKGROUP, TBBS_CHECKGROUP,
TBBS_SEPARATOR,
TBBS_BUTTON, TBBS_BUTTON, TBBS_BUTTON, TBBS_BUTTON,
@@ -73,17 +74,18 @@ BOOL CPlayerToolBar::Create(CWnd* pParentWnd)
/*TBBS_SEPARATOR,*/
};
- for(int i = 0; i < countof(styles); i++)
+ for(int i = 0; i < countof(styles); i++) {
SetButtonStyle(i, styles[i]|TBBS_DISABLED);
+ }
m_volctrl.Create(this);
- if(AfxGetAppSettings().fDisableXPToolbars)
- {
- if(HMODULE h = LoadLibrary(_T("uxtheme.dll")))
- {
+ if(AfxGetAppSettings().fDisableXPToolbars) {
+ if(HMODULE h = LoadLibrary(_T("uxtheme.dll"))) {
SetWindowThemeFunct f = (SetWindowThemeFunct)GetProcAddress(h, "SetWindowTheme");
- if(f) f(m_hWnd, L" ", L" ");
+ if(f) {
+ f(m_hWnd, L" ", L" ");
+ }
FreeLibrary(h);
}
}
@@ -91,14 +93,12 @@ BOOL CPlayerToolBar::Create(CWnd* pParentWnd)
// quick and dirty code from foxx1337; will leak, but don't care yet
m_nButtonHeight = 16; // hardcoded from MainFrm.cpp - DEFCLIENTW; min width should be 9 * button width + 60 + 91
HBITMAP hBmp = static_cast<HBITMAP>(::LoadImage(NULL, _T("toolbar.bmp"), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION));
- if(NULL != hBmp)
- {
+ if(NULL != hBmp) {
CBitmap *bmp = new CBitmap();
bmp->Attach(hBmp);
BITMAP bitmapBmp;
bmp->GetBitmap(&bitmapBmp);
- if(bitmapBmp.bmWidth == bitmapBmp.bmHeight * 15)
- {
+ if(bitmapBmp.bmWidth == bitmapBmp.bmHeight * 15) {
// the manual specifies that sizeButton should be sizeImage inflated by (7, 6)
SetSizes(CSize(bitmapBmp.bmHeight + 7, bitmapBmp.bmHeight + 6), CSize(bitmapBmp.bmHeight, bitmapBmp.bmHeight));
@@ -110,13 +110,10 @@ BOOL CPlayerToolBar::Create(CWnd* pParentWnd)
GetDIBits(dc, hBmp, 0, 0, NULL, reinterpret_cast<BITMAPINFO*>(&bih), DIB_RGB_COLORS);
int fileDepth = bih.biBitCount;
CImageList *imageList = new CImageList();
- if(32 == fileDepth)
- {
+ if(32 == fileDepth) {
imageList->Create(bitmapBmp.bmHeight, bitmapBmp.bmHeight, ILC_COLOR32 | ILC_MASK, 1, 0);
imageList->Add(bmp, static_cast<CBitmap*>(0)); // alpha is the mask
- }
- else
- {
+ } else {
imageList->Create(bitmapBmp.bmHeight, bitmapBmp.bmHeight, ILC_COLOR24 | ILC_MASK, 1, 0);
imageList->Add(bmp, RGB(255, 0, 255));
}
@@ -132,19 +129,22 @@ BOOL CPlayerToolBar::Create(CWnd* pParentWnd)
BOOL CPlayerToolBar::PreCreateWindow(CREATESTRUCT& cs)
{
- if(!__super::PreCreateWindow(cs))
+ if(!__super::PreCreateWindow(cs)) {
return FALSE;
+ }
m_dwStyle &= ~CBRS_BORDER_TOP;
m_dwStyle &= ~CBRS_BORDER_BOTTOM;
-// m_dwStyle |= CBRS_SIZE_FIXED;
+ // m_dwStyle |= CBRS_SIZE_FIXED;
return TRUE;
}
void CPlayerToolBar::ArrangeControls()
{
- if(!::IsWindow(m_volctrl.m_hWnd)) return;
+ if(!::IsWindow(m_volctrl.m_hWnd)) {
+ return;
+ }
CRect r;
GetClientRect(&r);
@@ -203,10 +203,10 @@ int CPlayerToolBar::GetMinWidth()
void CPlayerToolBar::SetVolume(int volume)
{
-/*
- volume = (int)pow(10, ((double)volume)/5000+2);
- volume = max(min(volume, 100), 1);
-*/
+ /*
+ volume = (int)pow(10, ((double)volume)/5000+2);
+ volume = max(min(volume, 100), 1);
+ */
m_volctrl.SetPosInternal(volume);
}
@@ -227,8 +227,9 @@ END_MESSAGE_MAP()
void CPlayerToolBar::OnPaint()
{
- if(m_bDelayedButtonLayout)
+ if(m_bDelayedButtonLayout) {
Layout();
+ }
CPaintDC dc(this); // device context for painting
@@ -301,12 +302,12 @@ void CPlayerToolBar::OnMouseMove(UINT nFlags, CPoint point)
{
int i = getHitButtonIdx(point);
- if((i==-1) || (GetButtonStyle(i)&(TBBS_SEPARATOR|TBBS_DISABLED)))
+ if((i==-1) || (GetButtonStyle(i)&(TBBS_SEPARATOR|TBBS_DISABLED))) {
;
- else
- {
- if((i>11) || ((i<10) && ((CMainFrame*)GetParentFrame())->IsSomethingLoaded()))
+ } else {
+ if((i>11) || ((i<10) && ((CMainFrame*)GetParentFrame())->IsSomethingLoaded())) {
::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_HAND));
+ }
}
__super::OnMouseMove(nFlags, point);
}
@@ -316,18 +317,15 @@ 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)
- {
+ 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>11) || ((i<10) && pFrame->IsSomethingLoaded()))
+ } else {
+ if((i>11) || ((i<10) && pFrame->IsSomethingLoaded())) {
::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_HAND));
+ }
__super::OnLButtonDown(nFlags, point);
}
@@ -338,12 +336,10 @@ 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;
- for(int i = 0, j = GetToolBarCtrl().GetButtonCount(); i < j; i++)
- {
+ for(int i = 0, j = GetToolBarCtrl().GetButtonCount(); i < j; i++) {
GetItemRect(i, r);
- if(r.PtInRect(point))
- {
+ if(r.PtInRect(point)) {
hit = i;
break;
}
diff --git a/src/apps/mplayerc/PlayerToolBar.h b/src/apps/mplayerc/PlayerToolBar.h
index 0a41ae84c..755256ae5 100644
--- a/src/apps/mplayerc/PlayerToolBar.h
+++ b/src/apps/mplayerc/PlayerToolBar.h
@@ -51,14 +51,14 @@ public:
CVolumeCtrl m_volctrl;
-// Overrides
+ // Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CPlayerToolBar)
virtual BOOL Create(CWnd* pParentWnd);
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
//}}AFX_VIRTUAL
-// Generated message map functions
+ // Generated message map functions
protected:
//{{AFX_MSG(CPlayerToolBar)
afx_msg void OnPaint();
diff --git a/src/apps/mplayerc/Playlist.cpp b/src/apps/mplayerc/Playlist.cpp
index c83b1acb4..e6fc13e1e 100644
--- a/src/apps/mplayerc/Playlist.cpp
+++ b/src/apps/mplayerc/Playlist.cpp
@@ -76,10 +76,10 @@ CPlaylistItem& CPlaylistItem::operator = (const CPlaylistItem& pli)
POSITION CPlaylistItem::FindFile(LPCTSTR path)
{
POSITION pos = m_fns.GetHeadPosition();
- while(pos)
- {
- if (m_fns.GetAt(pos).CompareNoCase(path) == 0)
+ while(pos) {
+ if (m_fns.GetAt(pos).CompareNoCase(path) == 0) {
return pos;
+ }
m_fns.GetNext(pos);
}
return(NULL);
@@ -97,21 +97,21 @@ 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(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)
- {
+ if(m_type == file) {
REFERENCE_TIME rt = m_duration;
- if(rt > 0)
- {
+ if(rt > 0) {
rt /= 10000000;
int ss = int(rt%60);
rt /= 60;
@@ -121,9 +121,7 @@ CString CPlaylistItem::GetLabel(int i)
str.Format(_T("%02d:%02d:%02d"), hh, mm, ss);
}
- }
- else if(m_type == device)
- {
+ } else if(m_type == device) {
// TODO
}
@@ -136,51 +134,49 @@ 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;
+ while(pos && !fFound) {
+ if(!sl.GetNext(pos).CompareNoCase(fn)) {
+ fFound = true;
+ }
}
return(fFound);
}
void CPlaylistItem::AutoLoadFiles()
{
- if(m_fns.IsEmpty()) return;
+ if(m_fns.IsEmpty()) {
+ return;
+ }
CString fn = m_fns.GetHead();
- if(AfxGetAppSettings().fAutoloadAudio && fn.Find(_T("://")) < 0)
- {
+ if(AfxGetAppSettings().fAutoloadAudio && fn.Find(_T("://")) < 0) {
int i = fn.ReverseFind('.');
- if(i > 0)
- {
+ if(i > 0) {
CMediaFormats& mf = AfxGetAppSettings().m_Formats;
CString ext = fn.Mid(i+1).MakeLower();
- if(!mf.FindExt(ext, true))
- {
+ 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;
+ 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))
- {
+ && mf.FindExt(ext2, true) && mf.IsUsingEngine(fullpath, DirectShow)) {
m_fns.AddTail(fullpath);
}
- }
- while(FindNextFile(hFind, &fd));
+ } while(FindNextFile(hFind, &fd));
FindClose(hFind);
}
@@ -188,15 +184,13 @@ void CPlaylistItem::AutoLoadFiles()
}
}
- if(AfxGetAppSettings().fAutoloadSubtitles)
- {
+ if(AfxGetAppSettings().fAutoloadSubtitles) {
CString& pathList = AfxGetAppSettings().strSubtitlePaths;
CAtlArray<CString> paths;
int pos = 0;
- do
- {
+ do {
CString path = pathList.Tokenize(_T(";"), pos);
paths.Add(path);
} while(pos != -1);
@@ -206,17 +200,19 @@ void CPlaylistItem::AutoLoadFiles()
int l = fn.GetLength(), l2 = l;
l2 = dir.ReverseFind('.');
l = dir.ReverseFind('/') + 1;
- if(l2 < l) l2 = l;
+ if(l2 < l) {
+ l2 = l;
+ }
CString title = dir.Mid(l, l2-l);
paths.Add(title.GetString());
CAtlArray<SubFile> ret;
GetSubFileNames(fn, paths, ret);
- for(int i = 0; i < ret.GetCount(); i++)
- {
- if(!FindFileInList(m_subs, ret[i].fn))
+ for(int i = 0; i < ret.GetCount(); i++) {
+ if(!FindFileInList(m_subs, ret[i].fn)) {
m_subs.AddTail(ret[i].fn);
+ }
}
}
}
@@ -242,11 +238,9 @@ void CPlaylist::RemoveAll()
bool CPlaylist::RemoveAt(POSITION pos)
{
- if(pos)
- {
+ if(pos) {
__super::RemoveAt(pos);
- if(m_pos == pos)
- {
+ if(m_pos == pos) {
m_pos = NULL;
return(true);
}
@@ -255,8 +249,7 @@ bool CPlaylist::RemoveAt(POSITION pos)
return(false);
}
-typedef struct
-{
+typedef struct {
UINT n;
POSITION pos;
} plsort_t;
@@ -268,8 +261,7 @@ static int compare(const void* arg1, const void* arg2)
return a1 > a2 ? 1 : a1 < a2 ? -1 : 0;
}
-typedef struct
-{
+typedef struct {
LPCTSTR str;
POSITION pos;
} plsort2_t;
@@ -284,14 +276,16 @@ void CPlaylist::SortById()
CAtlArray<plsort_t> a;
a.SetCount(GetCount());
POSITION pos = GetHeadPosition();
- for(int i = 0; pos; i++, GetNext(pos))
+ 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(int i = 0; i < a.GetCount(); i++)
- {
+ for(int 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();
+ if(m_pos == a[i].pos) {
+ m_pos = GetTailPosition();
+ }
}
}
@@ -300,18 +294,18 @@ void CPlaylist::SortByName()
CAtlArray<plsort2_t> a;
a.SetCount(GetCount());
POSITION pos = GetHeadPosition();
- for(int i = 0; pos; i++, GetNext(pos))
- {
+ 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(int i = 0; i < a.GetCount(); i++)
- {
+ for(int 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();
+ if(m_pos == a[i].pos) {
+ m_pos = GetTailPosition();
+ }
}
}
@@ -320,14 +314,16 @@ void CPlaylist::SortByPath()
CAtlArray<plsort2_t> a;
a.SetCount(GetCount());
POSITION pos = GetHeadPosition();
- for(int i = 0; pos; i++, GetNext(pos))
+ 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(int i = 0; i < a.GetCount(); i++)
- {
+ for(int 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();
+ if(m_pos == a[i].pos) {
+ m_pos = GetTailPosition();
+ }
}
}
@@ -337,16 +333,17 @@ void CPlaylist::Randomize()
a.SetCount(GetCount());
srand((unsigned int)time(NULL));
POSITION pos = GetHeadPosition();
- for(int i = 0; pos; i++, GetNext(pos))
+ 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(int i = 0; i < a.GetCount(); i++)
- {
+ for(int i = 0; i < a.GetCount(); i++) {
AddTail(GetAt(a[i].pos));
__super::RemoveAt(a[i].pos);
- if(m_pos == a[i].pos)
+ if(m_pos == a[i].pos) {
m_pos = GetTailPosition();
+ }
}
}
@@ -374,8 +371,9 @@ POSITION CPlaylist::Shuffle()
a.SetCount(count = GetCount());
POSITION pos = GetHeadPosition();
- for(INT_PTR i = 0; pos; i++, GetNext(pos))
- a[i].pos = pos; // initialize position array
+ 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));
@@ -392,14 +390,13 @@ POSITION CPlaylist::Shuffle()
CPlaylistItem& CPlaylist::GetNextWrap(POSITION& pos)
{
- if(AfxGetApp()->GetProfileInt(IDS_R_SETTINGS, _T("ShufflePlaylistItems"), FALSE) && GetCount() > 2)
- {
+ if(AfxGetAppSettings().bShufflePlaylistItems && GetCount() > 2) {
pos = Shuffle();
- }
- else
- {
+ } else {
GetNext(pos);
- if(!pos) pos = GetHeadPosition();
+ if(!pos) {
+ pos = GetHeadPosition();
+ }
}
return(GetAt(pos));
@@ -408,6 +405,8 @@ CPlaylistItem& CPlaylist::GetNextWrap(POSITION& pos)
CPlaylistItem& CPlaylist::GetPrevWrap(POSITION& pos)
{
GetPrev(pos);
- if(!pos) pos = GetTailPosition();
+ if(!pos) {
+ pos = GetTailPosition();
+ }
return(GetAt(pos));
}
diff --git a/src/apps/mplayerc/PnSPresetsDlg.cpp b/src/apps/mplayerc/PnSPresetsDlg.cpp
index eb8689020..17ee7423e 100644
--- a/src/apps/mplayerc/PnSPresetsDlg.cpp
+++ b/src/apps/mplayerc/PnSPresetsDlg.cpp
@@ -54,16 +54,14 @@ BOOL CPnSPresetsDlg::OnInitDialog()
{
__super::OnInitDialog();
- for(int i = 0, j = m_pnspresets.GetCount(); i < j; i++)
- {
+ for(int 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);
- if(i == 0)
- {
+ if(i == 0) {
m_list.SetCurSel(0);
OnLbnSelchangeList1();
}
@@ -78,33 +76,30 @@ void CPnSPresetsDlg::StringToParams(CString str, CString& label, double& PosX, d
{
int i = 0, j = 0;
- for(CString token = str.Tokenize(_T(","), i); !token.IsEmpty(); token = str.Tokenize(_T(","), i), j++)
- {
- if(j == 0)
- {
+ for(CString token = str.Tokenize(_T(","), i); !token.IsEmpty(); token = str.Tokenize(_T(","), i), j++) {
+ if(j == 0) {
label = token;
- }
- else
- {
+ } 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;
+ 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;
}
}
}
@@ -136,17 +131,14 @@ END_MESSAGE_MAP()
void CPnSPresetsDlg::OnLbnSelchangeList1()
{
int i = m_list.GetCurSel();
- if(i >= 0 && i < m_pnspresets.GetCount())
- {
+ 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
- {
+ } else {
m_label.Empty();
m_PosX.SetWindowText(_T(""));
m_PosY.SetWindowText(_T(""));
@@ -168,7 +160,9 @@ void CPnSPresetsDlg::OnUpdateButton2(CCmdUI* pCmdUI)
{
CString str;
int len = m_list.GetCount();
- if(len > 0) m_list.GetText(len-1, str);
+ if(len > 0) {
+ m_list.GetText(len-1, str);
+ }
pCmdUI->Enable(str != _T("New"));
}
@@ -177,7 +171,9 @@ void CPnSPresetsDlg::OnBnClickedButton6() // del
int i = m_list.GetCurSel();
m_list.DeleteString(i);
m_pnspresets.RemoveAt(i);
- if(i == m_list.GetCount()) i--;
+ if(i == m_list.GetCount()) {
+ i--;
+ }
m_list.SetCurSel(i);
OnLbnSelchangeList1();
}
@@ -251,8 +247,9 @@ void CPnSPresetsDlg::OnUpdateButton1(CCmdUI* pCmdUI)
void CPnSPresetsDlg::OnOK()
{
- if(m_list.GetCurSel() >= 0)
+ if(m_list.GetCurSel() >= 0) {
OnBnClickedButton1();
+ }
__super::OnOK();
}
diff --git a/src/apps/mplayerc/PnSPresetsDlg.h b/src/apps/mplayerc/PnSPresetsDlg.h
index f4308b09c..bb21a8a1f 100644
--- a/src/apps/mplayerc/PnSPresetsDlg.h
+++ b/src/apps/mplayerc/PnSPresetsDlg.h
@@ -42,7 +42,7 @@ public:
CStringArray m_pnspresets;
-// Dialog Data
+ // Dialog Data
enum { IDD = IDD_PNSPRESET_DLG };
CFloatEdit m_PosX;
CFloatEdit m_PosY;
diff --git a/src/apps/mplayerc/QuicktimeGraph.cpp b/src/apps/mplayerc/QuicktimeGraph.cpp
index dff3cac43..740041cb5 100644
--- a/src/apps/mplayerc/QuicktimeGraph.cpp
+++ b/src/apps/mplayerc/QuicktimeGraph.cpp
@@ -50,40 +50,35 @@ CQuicktimeGraph::CQuicktimeGraph(HWND hWndParent, HRESULT& hr)
AppSettings& s = AfxGetAppSettings();
- if(s.iQTVideoRendererType == VIDRNDT_QT_DX7)
- {
- if(SUCCEEDED(CreateAP7(CLSID_QT7AllocatorPresenter, hWndParent, &m_pQTAP)))
+ if(s.iQTVideoRendererType == VIDRNDT_QT_DX7) {
+ if(SUCCEEDED(CreateAP7(CLSID_QT7AllocatorPresenter, hWndParent, &m_pQTAP))) {
dwStyle &= ~WS_VISIBLE;
- }
- else if(s.iQTVideoRendererType == VIDRNDT_QT_DX9)
- {
+ }
+ } 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)))
+ if(SUCCEEDED(CreateAP9(CLSID_QT9AllocatorPresenter, hWndParent, bFullscreen, &m_pQTAP))) {
dwStyle &= ~WS_VISIBLE;
+ }
}
m_fQtInitialized = false;
- if(InitializeQTML(0) != 0)
- {
+ if(InitializeQTML(0) != 0) {
hr = E_FAIL;
return;
}
- if(EnterMovies() != 0)
- {
+ 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))
- {
+ 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))
- {
+ if(!m_wndDestFrame.Create(NULL, NULL, dwStyle, CRect(0, 0, 0, 0), &m_wndWindowFrame, 0)) {
hr = E_FAIL;
return;
}
@@ -94,8 +89,7 @@ CQuicktimeGraph::~CQuicktimeGraph()
m_wndDestFrame.DestroyWindow();
m_wndWindowFrame.DestroyWindow();
- if(m_fQtInitialized)
- {
+ if(m_fQtInitialized) {
ExitMovies();
TerminateQTML();
}
@@ -116,21 +110,17 @@ STDMETHODIMP CQuicktimeGraph::RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPla
{
bool fRet = m_wndDestFrame.OpenMovie(CString(lpcwstrFile));
- if(fRet)
- {
- for(int i = 1, cnt = GetMovieTrackCount(m_wndDestFrame.theMovie); i <= cnt; i++)
- {
+ 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)
- {
+ if(aTrackType == SoundMediaType) {
SampleDescriptionHandle aDesc = (SampleDescriptionHandle)NewHandle(sizeof(aDesc));
GetMediaSampleDescription(aMedia, 1, aDesc);
- if(GetMoviesError() == noErr)
- {
+ if(GetMoviesError() == noErr) {
SoundDescription& desc = **(SoundDescriptionHandle)aDesc;
NotifyEvent(EC_BG_AUDIO_CHANGED, desc.numChannels, 0);
i = cnt;
@@ -172,10 +162,14 @@ STDMETHODIMP CQuicktimeGraph::GetDuration(LONGLONG* pDuration)
*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;
+ if(ts == 0) {
+ return E_FAIL;
+ }
*pDuration = 10000i64*GetMovieDuration(m_wndDestFrame.theMovie)/ts*1000;
@@ -187,10 +181,14 @@ STDMETHODIMP CQuicktimeGraph::GetCurrentPosition(LONGLONG* pCurrent)
*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;
+ if(ts == 0) {
+ return E_FAIL;
+ }
TimeRecord tr;
*pCurrent = 10000i64*GetMovieTime(m_wndDestFrame.theMovie, &tr)/ts*1000;
@@ -201,17 +199,22 @@ STDMETHODIMP CQuicktimeGraph::SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFl
{
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;
+ if(ts == 0) {
+ return E_FAIL;
+ }
SetMovieTimeValue(m_wndDestFrame.theMovie, (TimeValue)(*pCurrent*ts/1000/10000i64));
- if(!m_wndDestFrame.theMC)
- {
+ if(!m_wndDestFrame.theMC) {
UpdateMovie(m_wndDestFrame.theMovie);
MoviesTask(m_wndDestFrame.theMovie, 0L);
}
@@ -232,8 +235,9 @@ STDMETHODIMP CQuicktimeGraph::GetRate(double* pdRate)
// IVideoWindow
STDMETHODIMP CQuicktimeGraph::SetWindowPosition(long Left, long Top, long Width, long Height)
{
- if(IsWindow(m_wndWindowFrame.m_hWnd))
+ if(IsWindow(m_wndWindowFrame.m_hWnd)) {
m_wndWindowFrame.MoveWindow(Left, Top, Width, Height);
+ }
return S_OK;
}
@@ -241,12 +245,10 @@ STDMETHODIMP CQuicktimeGraph::SetWindowPosition(long Left, long Top, long Width,
// IBasicVideo
STDMETHODIMP CQuicktimeGraph::SetDestinationPosition(long Left, long Top, long Width, long Height)// {return E_NOTIMPL;}
{
- if(!m_pQTAP && IsWindow(m_wndDestFrame.m_hWnd))
- {
+ if(!m_pQTAP && IsWindow(m_wndDestFrame.m_hWnd)) {
m_wndDestFrame.MoveWindow(Left, Top, Width, Height);
- if(m_wndDestFrame.theMC)
- {
+ if(m_wndDestFrame.theMC) {
Rect bounds = {0,0,(short)Height,(short)Width};
MCPositionController(m_wndDestFrame.theMC, &bounds, NULL, mcTopLeftMovie|mcScaleMovieToFit);
}
@@ -256,7 +258,9 @@ STDMETHODIMP CQuicktimeGraph::SetDestinationPosition(long Left, long Top, long W
}
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;
@@ -267,8 +271,7 @@ STDMETHODIMP CQuicktimeGraph::GetVideoSize(long* pWidth, long* pHeight)
// IBasicAudio
STDMETHODIMP CQuicktimeGraph::put_Volume(long lVolume)
{
- if(m_wndDestFrame.theMovie)
- {
+ if(m_wndDestFrame.theMovie) {
lVolume = (lVolume == -10000) ? 0 : (int)pow(10.0, (double)lVolume/4152.41 + 2.41);
SetMovieVolume(m_wndDestFrame.theMovie, (short)max(min(lVolume, 256), 0));
return S_OK;
@@ -280,8 +283,7 @@ STDMETHODIMP CQuicktimeGraph::get_Volume(long* plVolume)
{
CheckPointer(plVolume, E_POINTER);
- if(m_wndDestFrame.theMovie)
- {
+ if(m_wndDestFrame.theMovie) {
long lVolume = (long)GetMovieVolume(m_wndDestFrame.theMovie);
*plVolume = (int)((log10(1.0*lVolume)-2.41)*4152.41);
*plVolume = max(min(*plVolume, 0), -10000);
@@ -294,9 +296,15 @@ STDMETHODIMP CQuicktimeGraph::get_Volume(long* plVolume)
// 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;
+ if(pStepObject) {
+ return E_INVALIDARG;
+ }
+ if(dwFrames == 0) {
+ return S_OK;
+ }
+ if(!m_wndDestFrame.theMovie) {
+ return E_UNEXPECTED;
+ }
// w/o m_wndDestFrame.theMC
@@ -304,21 +312,25 @@ STDMETHODIMP CQuicktimeGraph::Step(DWORD dwFrames, IUnknown* pStepObject)
TimeValue myCurrTime = GetMovieTime(m_wndDestFrame.theMovie, NULL);
Fixed theRate = (int)dwFrames > 0 ? 0x00010000 : 0xffff0000;
- for(int nSteps = abs((int)dwFrames); nSteps > 0; nSteps--)
- {
+ 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;
+ if(GetMoviesError() != noErr) {
+ return E_FAIL;
+ }
myCurrTime = myNextTime;
}
- if(myCurrTime >= 0 && myCurrTime < GetMovieDuration(m_wndDestFrame.theMovie))
- {
+ if(myCurrTime >= 0 && myCurrTime < GetMovieDuration(m_wndDestFrame.theMovie)) {
SetMovieTimeValue(m_wndDestFrame.theMovie, myCurrTime);
- if(GetMoviesError() != noErr) return E_FAIL;
+ 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;
+ if(GetMoviesError() != noErr) {
+ return E_FAIL;
+ }
MoviesTask(m_wndDestFrame.theMovie, 0L);
}
@@ -367,8 +379,9 @@ CQuicktimeWindow::CQuicktimeWindow(CQuicktimeGraph* pGraph)
void CQuicktimeWindow::ProcessMovieEvent(unsigned int message, unsigned int wParam, long lParam)
{
if(message >= WM_MOUSEFIRST && message <= WM_MOUSELAST
- || message >= WM_KEYFIRST && message <= WM_KEYLAST)
+ || message >= WM_KEYFIRST && message <= WM_KEYLAST) {
return;
+ }
// Convert the Windows event to a QTML event
MSG theMsg;
@@ -392,14 +405,11 @@ void CQuicktimeWindow::ProcessMovieEvent(unsigned int message, unsigned int wPar
LRESULT CQuicktimeWindow::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
- if(message == WM_ERASEBKGND)
- {
+ if(message == WM_ERASEBKGND) {
LRESULT theResult = __super::WindowProc(message, wParam, lParam);
ProcessMovieEvent(message, wParam, lParam);
return theResult;
- }
- else
- {
+ } else {
ProcessMovieEvent(message, wParam, lParam);
return __super::WindowProc(message, wParam, lParam);
}
@@ -408,13 +418,16 @@ LRESULT CQuicktimeWindow::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
OSErr CQuicktimeWindow::MyMovieDrawingCompleteProc(Movie theMovie, long refCon)
{
CQuicktimeWindow* pQW = (CQuicktimeWindow*)refCon;
- if(!pQW) return noErr;
+ if(!pQW) {
+ return noErr;
+ }
CQuicktimeGraph* pGraph = pQW->m_pGraph;
- if(!pGraph) return noErr;
+ if(!pGraph) {
+ return noErr;
+ }
- if(CComQIPtr<IQTVideoSurface> pQTVS = (IUnknown*)(INonDelegatingUnknown*)pGraph)
- {
+ if(CComQIPtr<IQTVideoSurface> pQTVS = (IUnknown*)(INonDelegatingUnknown*)pGraph) {
BITMAP bm;
pQW->m_bm.GetObject(sizeof(bm), &bm);
bm.bmWidth = pQW->m_size.cx;
@@ -435,19 +448,18 @@ bool CQuicktimeWindow::OpenMovie(CString fn)
CComQIPtr<IQTVideoSurface> pQTVS = (IUnknown*)(INonDelegatingUnknown*)m_pGraph;
- if(!pQTVS)
- {
+ if(!pQTVS) {
// Set the port
SetGWorld((CGrafPtr)GetHWNDPort(m_hWnd), NULL);
}
- if(fn.Find(_T("://")) > 0)
- {
+ if(fn.Find(_T("://")) > 0) {
Handle myHandle = NULL;
Size mySize = fn.GetLength()+1;
myHandle = NewHandleClear(mySize);
- if(!myHandle)
+ if(!myHandle) {
return(false);
+ }
BlockMove((LPSTR)(LPCSTR)CStringA(fn), *myHandle, mySize);
@@ -455,12 +467,13 @@ bool CQuicktimeWindow::OpenMovie(CString fn)
DisposeHandle(myHandle);
- if(err != noErr) return(false);
- }
- else
- {
- if(!(fn.GetLength() > 0 && fn.GetLength() < 255))
+ if(err != noErr) {
+ return(false);
+ }
+ } else {
+ if(!(fn.GetLength() > 0 && fn.GetLength() < 255)) {
return(false);
+ }
CHAR buff[_MAX_PATH] = {0, 0};
#ifdef UNICODE
@@ -477,12 +490,13 @@ bool CQuicktimeWindow::OpenMovie(CString fn)
// Open the movie file
short movieResFile;
OSErr err = OpenMovieFile(&sfFile, &movieResFile, fsRdPerm);
- if(err == noErr)
- {
+ if(err == noErr) {
err = NewMovieFromFile(&theMovie, movieResFile, 0, 0, newMovieActive, 0);
CloseMovieFile(movieResFile);
}
- if(err != noErr) return(false);
+ if(err != noErr) {
+ return(false);
+ }
}
Rect rect;
@@ -494,23 +508,18 @@ bool CQuicktimeWindow::OpenMovie(CString fn)
Rect nrect;
GetMovieNaturalBoundsRect(theMovie, &nrect);
- if(!pQTVS)
- {
+ if(!pQTVS) {
theMC = NewMovieController(theMovie, &rect, mcTopLeftMovie|mcNotVisible);
- }
- else if(m_size.cx > 0 && m_size.cy > 0)
- {
+ } else if(m_size.cx > 0 && m_size.cy > 0) {
SetMovieDrawingCompleteProc(theMovie,
movieDrawingCallWhenChanged,//|movieDrawingCallAlways,
MyMovieDrawingCompleteProc, (long)this);
- if(CDC* pDC = GetDC())
- {
+ if(CDC* pDC = GetDC()) {
m_dc.CreateCompatibleDC(pDC);
ReleaseDC(pDC);
- struct
- {
+ struct {
BITMAPINFOHEADER bmiHeader;
long bmiColors[256];
} bmi;
@@ -550,22 +559,29 @@ bool CQuicktimeWindow::OpenMovie(CString fn)
void CQuicktimeWindow::CloseMovie()
{
- if(theMC) DisposeMovieController(theMC), theMC = NULL;
- if(theMovie) DisposeMovie(theMovie), theMovie = NULL;
+ 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;
+ if(m_offscreenGWorld) {
+ DisposeGWorld(m_offscreenGWorld), m_offscreenGWorld = NULL;
+ }
m_dc.DeleteDC();
m_bm.DeleteObject();
}
void CQuicktimeWindow::Run()
{
- if(theMovie)
- {
+ if(theMovie) {
StartMovie(theMovie);
- if(!m_idEndPoller) m_idEndPoller = SetTimer(1, 10, NULL); // 10ms -> 100fps max
+ if(!m_idEndPoller) {
+ m_idEndPoller = SetTimer(1, 10, NULL); // 10ms -> 100fps max
+ }
}
m_fs = State_Running;
@@ -573,10 +589,11 @@ void CQuicktimeWindow::Run()
void CQuicktimeWindow::Pause()
{
- if(theMovie)
- {
+ if(theMovie) {
StopMovie(theMovie);
- if(m_idEndPoller) KillTimer(m_idEndPoller), m_idEndPoller = 0;
+ if(m_idEndPoller) {
+ KillTimer(m_idEndPoller), m_idEndPoller = 0;
+ }
}
m_fs = State_Paused;
@@ -584,11 +601,12 @@ void CQuicktimeWindow::Pause()
void CQuicktimeWindow::Stop()
{
- if(theMovie)
- {
+ if(theMovie) {
StopMovie(theMovie);
GoToBeginningOfMovie(theMovie);
- if(m_idEndPoller) KillTimer(m_idEndPoller), m_idEndPoller = 0;
+ if(m_idEndPoller) {
+ KillTimer(m_idEndPoller), m_idEndPoller = 0;
+ }
}
m_fs = State_Stopped;
@@ -608,13 +626,13 @@ END_MESSAGE_MAP()
int CQuicktimeWindow::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
- if(__super::OnCreate(lpCreateStruct) == -1)
+ if(__super::OnCreate(lpCreateStruct) == -1) {
return -1;
+ }
CComQIPtr<IQTVideoSurface> pQTVS = (IUnknown*)(INonDelegatingUnknown*)m_pGraph;
- if(!pQTVS)
- {
+ if(!pQTVS) {
// Create GrafPort <-> HWND association
CreatePortAssociation(m_hWnd, NULL, 0);
}
@@ -631,12 +649,12 @@ void CQuicktimeWindow::OnDestroy()
CComQIPtr<IQTVideoSurface> pQTVS = (IUnknown*)(INonDelegatingUnknown*)m_pGraph;
- if(!pQTVS)
- {
+ if(!pQTVS) {
// Destroy the view's GrafPort <-> HWND association
if(m_hWnd)
- if(CGrafPtr windowPort = (CGrafPtr)GetHWNDPort(m_hWnd))
+ if(CGrafPtr windowPort = (CGrafPtr)GetHWNDPort(m_hWnd)) {
DestroyPortAssociation(windowPort);
+ }
}
}
@@ -647,15 +665,11 @@ BOOL CQuicktimeWindow::OnEraseBkgnd(CDC* pDC)
void CQuicktimeWindow::OnTimer(UINT_PTR nIDEvent)
{
- if(nIDEvent == m_idEndPoller && theMovie)
- {
- if(IsMovieDone(theMovie))
- {
+ if(nIDEvent == m_idEndPoller && theMovie) {
+ if(IsMovieDone(theMovie)) {
Pause();
m_pGraph->NotifyEvent(EC_COMPLETE);
- }
- else if(CComQIPtr<IQTVideoSurface> pQTVS = (IUnknown*)(INonDelegatingUnknown*)m_pGraph)
- {
+ } else if(CComQIPtr<IQTVideoSurface> pQTVS = (IUnknown*)(INonDelegatingUnknown*)m_pGraph) {
MoviesTask(theMovie, 0);
/*
long duration = 0, scale = 1000;
diff --git a/src/apps/mplayerc/QuicktimeGraph.h b/src/apps/mplayerc/QuicktimeGraph.h
index 8cf9517be..412fe3a30 100644
--- a/src/apps/mplayerc/QuicktimeGraph.h
+++ b/src/apps/mplayerc/QuicktimeGraph.h
@@ -30,98 +30,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/apps/mplayerc/RealMediaGraph.cpp b/src/apps/mplayerc/RealMediaGraph.cpp
index dab8c9773..f67479313 100644
--- a/src/apps/mplayerc/RealMediaGraph.cpp
+++ b/src/apps/mplayerc/RealMediaGraph.cpp
@@ -62,86 +62,98 @@ bool CRealMediaPlayer::Init()
CRegKey key;
- if(ERROR_SUCCESS != key.Open(HKEY_CLASSES_ROOT, prefs + _T("\\DT_Common"), KEY_READ))
+ if(ERROR_SUCCESS != key.Open(HKEY_CLASSES_ROOT, prefs + _T("\\DT_Common"), KEY_READ)) {
return(false);
+ }
TCHAR buff[_MAX_PATH];
ULONG len = sizeof(buff)/sizeof(buff[0]);
- if(ERROR_SUCCESS != key.QueryStringValue(NULL, buff, &len))
+ if(ERROR_SUCCESS != key.QueryStringValue(NULL, buff, &len)) {
return(false);
+ }
key.Close();
m_hRealMediaCore = LoadLibrary(CString(buff) + _T("pnen3260.dll"));
- if(!m_hRealMediaCore)
+ 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)
+ if(!m_fpCreateEngine || !m_fpCloseEngine || !m_fpSetDLLAccessPath) {
return(false);
+ }
- if(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, prefs, KEY_READ))
- {
+ if(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, prefs, KEY_READ)) {
CString dllpaths;
len = sizeof(buff)/sizeof(buff[0]);
- for(int i = 0; ERROR_SUCCESS == key.EnumKey(i, buff, &len); i++,len = sizeof(buff)/sizeof(buff[0]))
- {
+ for(int i = 0; ERROR_SUCCESS == key.EnumKey(i, buff, &len); i++,len = sizeof(buff)/sizeof(buff[0])) {
CRegKey key2;
TCHAR buff2[_MAX_PATH];
ULONG len2 = sizeof(buff2)/sizeof(buff2[0]);
if(ERROR_SUCCESS != key2.Open(HKEY_CLASSES_ROOT, prefs + _T("\\") + buff, KEY_READ)
- || ERROR_SUCCESS != key2.QueryStringValue(NULL, buff2, &len2))
+ || ERROR_SUCCESS != key2.QueryStringValue(NULL, buff2, &len2)) {
continue;
+ }
dllpaths += CString(buff) + '=' + buff2 + '|';
}
key.Close();
- if(!dllpaths.IsEmpty())
- {
+ if(!dllpaths.IsEmpty()) {
char* s = DNew char[dllpaths.GetLength()+1];
strcpy(s, CStringA(dllpaths));
- for(int i = 0, j = strlen(s); i < j; i++)
- {
- if(s[i] == '|') s[i] = '\0';
+ for(int 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))
+ if(PNR_OK != m_fpCreateEngine(&m_pEngine)) {
return(false);
+ }
- if(PNR_OK != m_pEngine->CreatePlayer(*&m_pPlayer))
+ if(PNR_OK != m_pEngine->CreatePlayer(*&m_pPlayer)) {
return(false);
+ }
- if(!(m_pSiteManager = m_pPlayer) || !(m_pCommonClassFactory = m_pPlayer))
+ 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->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
+ 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(pErrorSinkControl) {
+ pErrorSinkControl->AddErrorSink(static_cast<IRMAErrorSink*>(this), PNLOG_EMERG, PNLOG_INFO);
+ }
- if(PNR_OK != m_pPlayer->AddAdviseSink(static_cast<IRMAClientAdviseSink*>(this)))
+ if(PNR_OK != m_pPlayer->AddAdviseSink(static_cast<IRMAClientAdviseSink*>(this))) {
return(false);
+ }
- if(PNR_OK != m_pPlayer->SetClientContext((IUnknown*)(INonDelegatingUnknown*)(this)))
+ if(PNR_OK != m_pPlayer->SetClientContext((IUnknown*)(INonDelegatingUnknown*)(this))) {
return(false);
+ }
// TODO
/*
@@ -175,12 +187,13 @@ bool CRealMediaPlayer::Init()
void CRealMediaPlayer::Deinit()
{
- if(m_pPlayer)
- {
+ if(m_pPlayer) {
m_pPlayer->Stop();
CComQIPtr<IRMAErrorSinkControl, &IID_IRMAErrorSinkControl> pErrorSinkControl = m_pPlayer;
- if(pErrorSinkControl) pErrorSinkControl->RemoveErrorSink(static_cast<IRMAErrorSink*>(this));
+ if(pErrorSinkControl) {
+ pErrorSinkControl->RemoveErrorSink(static_cast<IRMAErrorSink*>(this));
+ }
m_pPlayer->RemoveAdviseSink(static_cast<IRMAClientAdviseSink*>(this));
@@ -196,14 +209,12 @@ void CRealMediaPlayer::Deinit()
m_pPlayer = NULL;
}
- if(m_pEngine)
- {
+ if(m_pEngine) {
m_fpCloseEngine(m_pEngine);
m_pEngine.Detach();
}
- if(m_hRealMediaCore)
- {
+ if(m_hRealMediaCore) {
FreeLibrary(m_hRealMediaCore);
m_hRealMediaCore = NULL;
}
@@ -227,11 +238,11 @@ char* AllocateErrorMessage(const char* msg)
{
char* errmsg = NULL;
int len = strlen(msg);
- if(len > 0)
- {
+ if(len > 0) {
errmsg = (char*)CoTaskMemAlloc(len+1);
- if (errmsg)
+ if (errmsg) {
strcpy(errmsg, msg);
+ }
}
return errmsg;
}
@@ -241,20 +252,16 @@ STDMETHODIMP CRealMediaPlayer::ErrorOccurred(const UINT8 unSeverity, const UINT3
{
char* errmsg = NULL;
- if(unSeverity < 5)
- {
- if(CComQIPtr<IRMAErrorMessages, &IID_IRMAErrorMessages> pErrorMessages = m_pPlayer)
- {
+ if(unSeverity < 5) {
+ if(CComQIPtr<IRMAErrorMessages, &IID_IRMAErrorMessages> pErrorMessages = m_pPlayer) {
CComPtr<IRMABuffer> pBuffer = pErrorMessages->GetErrorText(ulRMACode);
- if(pBuffer)
- {
+ if(pBuffer) {
char* buff = (char*)pBuffer->GetBuffer();
errmsg = AllocateErrorMessage(buff);
}
}
- if(!errmsg)
- {
+ if(!errmsg) {
errmsg = AllocateErrorMessage("RealMedia error");
TRACE("RealMedia error\n");
}
@@ -299,8 +306,9 @@ STDMETHODIMP CRealMediaPlayer::OnStop()
{
m_nCurrent = 0;
m_State = State_Stopped;
- if(m_UserState != State_Stopped)
+ if(m_UserState != State_Stopped) {
m_pRMG->NotifyEvent(EC_COMPLETE);
+ }
return PNR_OK;
}
STDMETHODIMP CRealMediaPlayer::OnPause(UINT32 ulTime)
@@ -328,8 +336,7 @@ STDMETHODIMP CRealMediaPlayer::HandleAuthenticationRequest(IRMAAuthenticationMan
{
CAuthDlg dlg;
- if(dlg.DoModal() == IDOK)
- {
+ if(dlg.DoModal() == IDOK) {
pResponse->AuthenticationRequestDone(
PNR_OK, CStringA(dlg.m_username), CStringA(dlg.m_password));
return PNR_OK;
@@ -341,39 +348,42 @@ STDMETHODIMP CRealMediaPlayer::HandleAuthenticationRequest(IRMAAuthenticationMan
// 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;
- if(!CreateSite(&m_pTheSite))
+ if(!CreateSite(&m_pTheSite)) {
return E_FAIL;
+ }
ULONG refc = ((IRMASite*)m_pTheSite)->AddRef();
refc = ((IRMASite*)m_pTheSite)->Release();
- if(!(m_pTheSite2 = m_pTheSite))
+ if(!(m_pTheSite2 = m_pTheSite)) {
return E_NOINTERFACE;
+ }
CComQIPtr<IRMAValues, &IID_IRMAValues> pSiteProps = m_pTheSite;
- if(!pSiteProps)
+ if(!pSiteProps) {
return E_NOINTERFACE;
+ }
IRMABuffer* pValue;
// no idea what these supposed to do... but they were in the example
hr = pProps->GetPropertyCString("playto", pValue);
- if(PNR_OK == hr)
- {
+ if(PNR_OK == hr) {
pSiteProps->SetPropertyCString("channel", pValue);
pValue->Release();
- }
- else
- {
+ } else {
hr = pProps->GetPropertyCString("name", pValue);
- if(PNR_OK == hr)
- {
+ if(PNR_OK == hr) {
pSiteProps->SetPropertyCString("LayoutGroup", pValue);
pValue->Release();
}
@@ -382,8 +392,9 @@ STDMETHODIMP CRealMediaPlayer::SitesNeeded(UINT32 uRequestID, IRMAValues* pProps
m_pTheSite2->AddPassiveSiteWatcher(static_cast<IRMAPassiveSiteWatcher*>(this));
hr = m_pSiteManager->AddSite(m_pTheSite);
- if(PNR_OK != hr)
+ if(PNR_OK != hr) {
return hr;
+ }
m_CreatedSites[uRequestID] = m_pTheSite;
@@ -393,8 +404,9 @@ STDMETHODIMP CRealMediaPlayer::SitesNeeded(UINT32 uRequestID, IRMAValues* pProps
STDMETHODIMP CRealMediaPlayer::SitesNotNeeded(UINT32 uRequestID)
{
IRMASite* pSite;
- if(!m_CreatedSites.Lookup(uRequestID, pSite))
+ if(!m_CreatedSites.Lookup(uRequestID, pSite)) {
return PNR_INVALID_PARAMETER;
+ }
m_CreatedSites.RemoveKey(uRequestID);
@@ -415,8 +427,7 @@ STDMETHODIMP CRealMediaPlayer::BeginChangeLayout()
}
STDMETHODIMP CRealMediaPlayer::DoneChangeLayout()
{
- if(m_fVideoSizeChanged)
- {
+ if(m_fVideoSizeChanged) {
m_pRMG->NotifyEvent(EC_VIDEO_SIZE_CHANGED, MAKELPARAM(m_VideoSize.cx, m_VideoSize.cy), 0);
m_fVideoSizeChanged = false;
}
@@ -431,8 +442,7 @@ STDMETHODIMP CRealMediaPlayer::PositionChanged(PNxPoint* pos)
}
STDMETHODIMP CRealMediaPlayer::SizeChanged(PNxSize* size)
{
- if(m_VideoSize.cx == 0 || m_VideoSize.cy == 0)
- {
+ if(m_VideoSize.cx == 0 || m_VideoSize.cy == 0) {
m_fVideoSizeChanged = true;
m_VideoSize.cx = size->cx;
m_VideoSize.cy = size->cy;
@@ -459,12 +469,14 @@ CRealMediaPlayerWindowed::CRealMediaPlayerWindowed(HWND hWndParent, CRealMediaGr
: CRealMediaPlayer(hWndParent, pRMG)
{
if(!m_wndWindowFrame.CreateEx(WS_EX_NOPARENTNOTIFY, NULL, NULL, WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|WS_VISIBLE,
- CRect(0, 0, 0, 0), CWnd::FromHandle(m_hWndParent), 0, NULL))
+ 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))
+ CRect(0, 0, 0, 0), &m_wndWindowFrame, 0, NULL)) {
return;
+ }
}
CRealMediaPlayerWindowed::~CRealMediaPlayerWindowed()
@@ -475,17 +487,18 @@ CRealMediaPlayerWindowed::~CRealMediaPlayerWindowed()
void CRealMediaPlayerWindowed::SetWindowRect(CRect r)
{
- if(IsWindow(m_wndWindowFrame.m_hWnd))
+ if(IsWindow(m_wndWindowFrame.m_hWnd)) {
m_wndWindowFrame.MoveWindow(r);
+ }
}
void CRealMediaPlayerWindowed::SetDestRect(CRect r)
{
- if(IsWindow(m_wndDestFrame.m_hWnd))
+ if(IsWindow(m_wndDestFrame.m_hWnd)) {
m_wndDestFrame.MoveWindow(r);
+ }
- if(m_pTheSite)
- {
+ if(m_pTheSite) {
PNxSize s = {r.Width(), r.Height()};
m_pTheSite->SetSize(s);
}
@@ -493,17 +506,22 @@ void CRealMediaPlayerWindowed::SetDestRect(CRect r)
bool CRealMediaPlayerWindowed::CreateSite(IRMASite** ppSite)
{
- if(!ppSite)
+ if(!ppSite) {
return(false);
+ }
CComPtr<IRMASiteWindowed> pSiteWindowed;
- if(PNR_OK != m_pCommonClassFactory->CreateInstance(CLSID_IRMASiteWindowed, (void**)&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))
+ 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);
@@ -511,8 +529,9 @@ bool CRealMediaPlayerWindowed::CreateSite(IRMASite** ppSite)
void CRealMediaPlayerWindowed::DestroySite(IRMASite* pSite)
{
- if(CComQIPtr<IRMASiteWindowed, &IID_IRMASiteWindowed> pRMASiteWindowed = pSite)
+ if(CComQIPtr<IRMASiteWindowed, &IID_IRMASiteWindowed> pRMASiteWindowed = pSite) {
pRMASiteWindowed->Destroy();
+ }
}
//
// CRealMediaPlayerWindowless
@@ -524,17 +543,18 @@ CRealMediaPlayerWindowless::CRealMediaPlayerWindowless(HWND hWndParent, CRealMed
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;
+ 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;
}
}
@@ -553,8 +573,9 @@ STDMETHODIMP CRealMediaPlayerWindowless::NonDelegatingQueryInterface(REFIID riid
bool CRealMediaPlayerWindowless::CreateSite(IRMASite** ppSite)
{
- if(!ppSite || !m_pRMAP)
+ if(!ppSite || !m_pRMAP) {
return(false);
+ }
HRESULT hr = S_OK;
@@ -562,8 +583,9 @@ bool CRealMediaPlayerWindowless::CreateSite(IRMASite** ppSite)
CComPtr<IRMASiteWindowless> pSiteWindowless;
pSiteWindowless = (IRMASiteWindowless*)(pWMWlS = DNew CRealMediaWindowlessSite(hr, m_pPlayer, NULL, NULL));
- if(FAILED(hr))
+ if(FAILED(hr)) {
return(false);
+ }
pWMWlS->SetBltService(CComQIPtr<IRMAVideoSurface, &IID_IRMAVideoSurface>(m_pRMAP));
@@ -577,8 +599,7 @@ void CRealMediaPlayerWindowless::DestroySite(IRMASite* pSite)
STDMETHODIMP CRealMediaPlayerWindowless::SizeChanged(PNxSize* size)
{
- if(CComQIPtr<IRMAVideoSurface, &IID_IRMAVideoSurface> pRMAVS = m_pRMAP)
- {
+ if(CComQIPtr<IRMAVideoSurface, &IID_IRMAVideoSurface> pRMAVS = m_pRMAP) {
RMABitmapInfoHeader BitmapInfo;
memset(&BitmapInfo, 0, sizeof(BitmapInfo));
BitmapInfo.biWidth = size->cx;
@@ -601,14 +622,12 @@ CRealMediaGraph::CRealMediaGraph(HWND hWndParent, HRESULT& hr)
? (CRealMediaPlayer*)DNew CRealMediaPlayerWindowed(hWndParent, this)
: (CRealMediaPlayer*)DNew CRealMediaPlayerWindowless(hWndParent, this);
- if(!m_pRMP)
- {
+ if(!m_pRMP) {
hr = E_OUTOFMEMORY;
return;
}
- if(!m_pRMP->Init())
- {
+ if(!m_pRMP->Init()) {
delete m_pRMP, m_pRMP = NULL;
hr = E_FAIL;
return;
@@ -619,8 +638,7 @@ CRealMediaGraph::CRealMediaGraph(HWND hWndParent, HRESULT& hr)
CRealMediaGraph::~CRealMediaGraph()
{
- if(m_pRMP)
- {
+ if(m_pRMP) {
m_pRMP->Deinit();
m_pRMP->Release();
m_pRMP = NULL;
@@ -645,14 +663,17 @@ STDMETHODIMP CRealMediaGraph::RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPla
WideCharToMultiByte(GetACP(), 0, lpcwstrFile, -1, buff, _MAX_PATH, 0, 0);
CStringA fn(buff);
- if(fn.Find("://") < 0) fn = "file://" + fn;
+ if(fn.Find("://") < 0) {
+ fn = "file://" + fn;
+ }
m_pRMP->m_unPercentComplete = 100;
ClearMessageQueue();
- if(PNR_OK != m_pRMP->m_pPlayer->OpenURL(fn))
+ if(PNR_OK != m_pRMP->m_pPlayer->OpenURL(fn)) {
return E_FAIL;
+ }
m_pRMP->m_pPlayer->Pause()/*Stop()*/; // please, don't start just yet
@@ -662,8 +683,9 @@ STDMETHODIMP CRealMediaGraph::RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPla
// IMediaControl
STDMETHODIMP CRealMediaGraph::Run()
{
- if(m_pRMP->m_pPlayer->IsDone())
+ 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;
@@ -701,8 +723,9 @@ STDMETHODIMP CRealMediaGraph::SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFl
// IVideoWindow
STDMETHODIMP CRealMediaGraph::SetWindowPosition(long Left, long Top, long Width, long Height)
{
- if(m_pRMP)
+ if(m_pRMP) {
m_pRMP->SetWindowRect(CRect(CPoint(Left, Top), CSize(Width, Height)));
+ }
return S_OK;
}
@@ -715,7 +738,9 @@ STDMETHODIMP CRealMediaGraph::SetDestinationPosition(long Left, long Top, long W
}
STDMETHODIMP CRealMediaGraph::GetVideoSize(long* pWidth, long* pHeight)
{
- if(!pWidth || !pHeight) return E_POINTER;
+ if(!pWidth || !pHeight) {
+ return E_POINTER;
+ }
*pWidth = m_pRMP->GetVideoSize().cx;
*pHeight = m_pRMP->GetVideoSize().cy;
return S_OK;
@@ -724,7 +749,9 @@ STDMETHODIMP CRealMediaGraph::GetVideoSize(long* pWidth, long* pHeight)
// 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 : (int)pow(10.0, ((double)lVolume)/5000+2);
volume = max(min(volume, 100), 0);
@@ -733,7 +760,9 @@ STDMETHODIMP CRealMediaGraph::put_Volume(long lVolume)
}
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);
diff --git a/src/apps/mplayerc/RealMediaGraph.h b/src/apps/mplayerc/RealMediaGraph.h
index db7bbf332..e097dd478 100644
--- a/src/apps/mplayerc/RealMediaGraph.h
+++ b/src/apps/mplayerc/RealMediaGraph.h
@@ -49,186 +49,185 @@
namespace DSObjects
{
-class CRealMediaGraph;
+ class CRealMediaGraph;
-class CRealMediaPlayer
- : public CUnknown
- , public IRMAErrorSink
- , public IRMAClientAdviseSink
- , public IRMAAuthenticationManager
- , public IRMASiteSupplier
- , public IRMAPassiveSiteWatcher
- , public IRMAAudioHook
+ 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();
+ 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;
+ class CRealMediaPlayerWindowless
+ : public CRealMediaPlayer
+ {
+ CComPtr<ISubPicAllocatorPresenter> m_pRMAP;
-public:
- CRealMediaPlayerWindowless(HWND hWndParent, CRealMediaGraph* pRMG);
- virtual ~CRealMediaPlayerWindowless();
+ public:
+ CRealMediaPlayerWindowless(HWND hWndParent, CRealMediaGraph* pRMG);
+ virtual ~CRealMediaPlayerWindowless();
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- bool CreateSite(IRMASite** pSite);
- void DestroySite(IRMASite* pSite);
+ bool CreateSite(IRMASite** pSite);
+ void DestroySite(IRMASite* pSite);
- STDMETHODIMP SizeChanged(PNxSize* size);
-};
+ STDMETHODIMP SizeChanged(PNxSize* size);
+ };
-class CRealMediaGraph : public CBaseGraph
-{
- CRealMediaPlayer* m_pRMP; // TODO: access m_pRMP through a private interface
+ class CRealMediaGraph : public CBaseGraph
+ {
+ CRealMediaPlayer* m_pRMP; // TODO: access m_pRMP through a private interface
- CStringW m_fn;
+ CStringW m_fn;
-public:
- CRealMediaGraph(HWND hWndParent, HRESULT& hr); // in windowless mode IVideoWindow::* will return E_NOTIMPL, use ISubPicAllocatorPresenter instead
- virtual ~CRealMediaGraph();
+ 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);
+ 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);
+ // 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);
+ // 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);
- // IAMOpenProgress
- STDMETHODIMP QueryProgress(LONGLONG* pllTotal, LONGLONG* pllCurrent);
+ // IAMOpenProgress
+ STDMETHODIMP QueryProgress(LONGLONG* pllTotal, LONGLONG* pllCurrent);
- // IGraphEngine
- STDMETHODIMP_(engine_t) GetEngine();
-};
+ // IGraphEngine
+ STDMETHODIMP_(engine_t) GetEngine();
+ };
}
diff --git a/src/apps/mplayerc/RealMediaWindowlessSite.cpp b/src/apps/mplayerc/RealMediaWindowlessSite.cpp
index 8950253d6..7fe4085bb 100644
--- a/src/apps/mplayerc/RealMediaWindowlessSite.cpp
+++ b/src/apps/mplayerc/RealMediaWindowlessSite.cpp
@@ -49,14 +49,12 @@ void DSObjects::ExtractRects(REGION* pRegion)
pRegion->extents.right = lpRgnData->rdh.rcBound.right;
pRegion->extents.bottom = lpRgnData->rdh.rcBound.bottom;
- if(lpRgnData->rdh.nCount)
- {
+ if(lpRgnData->rdh.nCount) {
pRegion->rects = DNew PNxRect[lpRgnData->rdh.nCount];
// now extract the information.
- for(int j = 0; j < (int) lpRgnData->rdh.nCount; j++)
- {
+ 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;
@@ -125,8 +123,7 @@ CRealMediaWindowlessSite::CRealMediaWindowlessSite(HRESULT& hr, IUnknown* pConte
hr = S_OK;
- if(!m_pContext || !m_pCCF)
- {
+ if(!m_pContext || !m_pCCF) {
hr = E_POINTER;
return;
}
@@ -137,7 +134,9 @@ CRealMediaWindowlessSite::CRealMediaWindowlessSite(HRESULT& hr, IUnknown* pConte
CRealMediaWindowlessSite::~CRealMediaWindowlessSite()
{
POSITION pos = m_pChildren.GetHeadPosition();
- while(pos) DestroyChild(m_pChildren.GetNext(pos));
+ while(pos) {
+ DestroyChild(m_pChildren.GetNext(pos));
+ }
RMADestroyRegion(m_pRegion);
RMADestroyRegion(m_pRegionWithoutChildren);
@@ -161,8 +160,9 @@ void CRealMediaWindowlessSite::GetTopLeft(PNxPoint* pPoint)
pPoint->x += m_position.x;
pPoint->y += m_position.y;
- if(m_pParentSite)
+ if(m_pParentSite) {
m_pParentSite->GetTopLeft(pPoint);
+ }
}
REGION* CRealMediaWindowlessSite::GetRegion()
@@ -174,8 +174,11 @@ REGION* CRealMediaWindowlessSite::GetRegion()
void CRealMediaWindowlessSite::RecomputeRegion()
{
- if(m_pParentSite) m_pParentSite->RecomputeRegion();
- else InternalRecomputeRegion();
+ if(m_pParentSite) {
+ m_pParentSite->RecomputeRegion();
+ } else {
+ InternalRecomputeRegion();
+ }
}
void CRealMediaWindowlessSite::InternalRecomputeRegion()
@@ -183,10 +186,11 @@ void CRealMediaWindowlessSite::InternalRecomputeRegion()
ComputeRegion();
POSITION pos = m_pChildren.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CRealMediaWindowlessSite* pSite = (CRealMediaWindowlessSite*)(IRMASite*)m_pChildren.GetNext(pos);
- if(pSite) pSite->InternalRecomputeRegion();
+ if(pSite) {
+ pSite->InternalRecomputeRegion();
+ }
}
}
@@ -194,40 +198,33 @@ void CRealMediaWindowlessSite::ComputeRegion()
{
REGION* pTempRegion = NULL;
- if(m_pRegion)
- {
+ if(m_pRegion) {
pTempRegion = RMACreateRegion();
RMAUnionRegion(pTempRegion, m_pRegion, pTempRegion);
RMADestroyRegion(m_pRegion);
}
- if(m_pRegionWithoutChildren)
- {
+ if(m_pRegionWithoutChildren) {
RMADestroyRegion(m_pRegionWithoutChildren);
}
PNxPoint topleft = {0,0};
GetTopLeft(&topleft);
- if(IsSiteVisible())
- {
+ if(IsSiteVisible()) {
m_pRegionWithoutChildren = RMACreateRectRegion(topleft.x, topleft.y, topleft.x + m_size.cx, topleft.y + m_size.cy);
- if(m_pParentSite)
- {
+ if(m_pParentSite) {
RMAIntersectRegion(m_pRegionWithoutChildren, m_pParentSite->m_pRegionWithoutChildren, m_pRegionWithoutChildren);
POSITION pos = m_pParentSite->m_pChildren.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CRealMediaWindowlessSite* pSiblingSite = (CRealMediaWindowlessSite*)(IRMASite*)m_pParentSite->m_pChildren.GetNext(pos);
- if(pSiblingSite != this)
- {
+ if(pSiblingSite != this) {
INT32 zOrder;
pSiblingSite->GetZOrder(zOrder);
- if(zOrder > m_lZOrder && pSiblingSite->IsSiteVisible())
- {
+ if(zOrder > m_lZOrder && pSiblingSite->IsSiteVisible()) {
pSiblingSite->SubtractSite(m_pRegionWithoutChildren);
}
}
@@ -238,20 +235,18 @@ void CRealMediaWindowlessSite::ComputeRegion()
RMAUnionRegion(m_pRegion, m_pRegionWithoutChildren, m_pRegion);
POSITION pos = m_pChildren.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CRealMediaWindowlessSite* pChildSite = (CRealMediaWindowlessSite*)(IRMASite*)m_pChildren.GetNext(pos);
- if(pChildSite->IsSiteVisible()) pChildSite->SubtractSite(m_pRegion);
+ if(pChildSite->IsSiteVisible()) {
+ pChildSite->SubtractSite(m_pRegion);
+ }
}
- }
- else
- {
+ } else {
m_pRegionWithoutChildren = RMACreateRectRegion(0,0,0,0);
m_pRegion = RMACreateRectRegion(0,0,0,0);
}
- if(pTempRegion && !RMAEqualRegion(m_pRegion, pTempRegion))
- {
+ if(pTempRegion && !RMAEqualRegion(m_pRegion, pTempRegion)) {
ForceRedraw();
}
@@ -273,32 +268,23 @@ void CRealMediaWindowlessSite::SubtractSite(REGION* pRegion)
void CRealMediaWindowlessSite::UpdateZOrder(CRealMediaWindowlessSite* pUpdatedChildSite, INT32 lOldZOrder, INT32 lNewZOrder)
{
POSITION pos = m_pChildren.GetHeadPosition();
- while(pos)
- {
+ 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)
- {
+ if(pSite != pUpdatedChildSite) {
+ if(lOldZOrder < lNewZOrder) {
+ if(lItsOldZOrder >= lOldZOrder && lItsOldZOrder < lNewZOrder) {
pSite->SetInternalZOrder(lItsOldZOrder-1);
}
- }
- else
- {
- if(lItsOldZOrder >= lNewZOrder && lItsOldZOrder < lOldZOrder)
- {
+ } else {
+ if(lItsOldZOrder >= lNewZOrder && lItsOldZOrder < lOldZOrder) {
pSite->SetInternalZOrder(lItsOldZOrder+1);
}
}
- }
- else
- {
+ } else {
pSite->SetInternalZOrder(lNewZOrder);
}
}
@@ -327,13 +313,17 @@ STDMETHODIMP CRealMediaWindowlessSite::AttachUser(IRMASiteUser* /*IN*/ pUser)
{
HRESULT hr = PNR_FAIL;
- if(m_pUser) return PNR_UNEXPECTED;
+ if(m_pUser) {
+ return PNR_UNEXPECTED;
+ }
- if(CComQIPtr<IRMASite, &IID_IRMASite> pOuterSite = GetOwner())
+ if(CComQIPtr<IRMASite, &IID_IRMASite> pOuterSite = GetOwner()) {
hr = pUser->AttachSite(pOuterSite);
+ }
- if(PNR_OK == hr)
+ if(PNR_OK == hr) {
m_pUser = pUser;
+ }
return hr;
}
@@ -342,12 +332,15 @@ STDMETHODIMP CRealMediaWindowlessSite::DetachUser()
{
HRESULT hr = PNR_OK;
- if(!m_pUser) return PNR_UNEXPECTED;
+ if(!m_pUser) {
+ return PNR_UNEXPECTED;
+ }
hr = m_pUser->DetachSite();
- if(PNR_OK == hr)
+ if(PNR_OK == hr) {
m_pUser = NULL;
+ }
return hr;
}
@@ -356,7 +349,9 @@ STDMETHODIMP CRealMediaWindowlessSite::GetUser(REF(IRMASiteUser*) /*OUT*/ pUser)
{
HRESULT hr = PNR_OK;
- if(!m_pUser) return PNR_UNEXPECTED;
+ if(!m_pUser) {
+ return PNR_UNEXPECTED;
+ }
(pUser = m_pUser)->AddRef();
@@ -370,8 +365,9 @@ STDMETHODIMP CRealMediaWindowlessSite::CreateChild(REF(IRMASite*) /*OUT*/ pChild
CComPtr<IRMASite> pSite =
(IRMASite*)DNew CRealMediaWindowlessSite(hr, m_pContext, this);
- if(FAILED(hr) || !pSite)
+ if(FAILED(hr) || !pSite) {
return E_FAIL;
+ }
pChildSite = pSite.Detach();
@@ -382,8 +378,7 @@ STDMETHODIMP CRealMediaWindowlessSite::CreateChild(REF(IRMASite*) /*OUT*/ pChild
STDMETHODIMP CRealMediaWindowlessSite::DestroyChild(IRMASite* /*IN*/ pChildSite)
{
- if(POSITION pos = m_pChildren.Find(pChildSite))
- {
+ if(POSITION pos = m_pChildren.Find(pChildSite)) {
m_pChildren.RemoveAt(pos);
return PNR_OK;
}
@@ -393,17 +388,22 @@ STDMETHODIMP CRealMediaWindowlessSite::DestroyChild(IRMASite* /*IN*/ pChildSite)
STDMETHODIMP CRealMediaWindowlessSite::AttachWatcher(IRMASiteWatcher* /*IN*/ pWatcher)
{
- if(m_pWatcher) return PNR_UNEXPECTED;
+ if(m_pWatcher) {
+ return PNR_UNEXPECTED;
+ }
- if(m_pWatcher = pWatcher)
+ if(m_pWatcher = pWatcher) {
m_pWatcher->AttachSite((IRMASite*)this);
+ }
return PNR_OK;
}
STDMETHODIMP CRealMediaWindowlessSite::DetachWatcher()
{
- if(!m_pWatcher) return PNR_UNEXPECTED;
+ if(!m_pWatcher) {
+ return PNR_UNEXPECTED;
+ }
m_pWatcher->DetachSite();
m_pWatcher = NULL;
@@ -415,17 +415,17 @@ STDMETHODIMP CRealMediaWindowlessSite::SetPosition(PNxPoint position)
{
HRESULT hr = PNR_OK;
- if(m_pWatcher)
- {
+ if(m_pWatcher) {
hr = m_pWatcher->ChangingPosition(m_position, position);
}
- if(PNR_OK == hr)
- {
+ if(PNR_OK == hr) {
m_position = position;
POSITION pos = m_pPassiveWatchers.GetHeadPosition();
- while(pos) m_pPassiveWatchers.GetNext(pos)->PositionChanged(&position);
+ while(pos) {
+ m_pPassiveWatchers.GetNext(pos)->PositionChanged(&position);
+ }
RecomputeRegion();
}
@@ -443,17 +443,17 @@ STDMETHODIMP CRealMediaWindowlessSite::SetSize(PNxSize size)
{
HRESULT hr = PNR_OK;
- if(m_pWatcher)
- {
+ if(m_pWatcher) {
hr = m_pWatcher->ChangingSize(m_size, size);
}
- if(PNR_OK == hr && size.cx != 0 && size.cy != 0)
- {
+ 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);
+ while(pos) {
+ m_pPassiveWatchers.GetNext(pos)->SizeChanged(&size);
+ }
RecomputeRegion();
}
@@ -482,8 +482,7 @@ STDMETHODIMP CRealMediaWindowlessSite::DamageRegion(PNxRegion region)
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)
- {
+ if(!m_fInRedraw && m_fDamaged && m_fIsVisible) {
m_fInRedraw = TRUE;
PNxEvent event = {RMA_SURFACE_UPDATE, NULL, (IRMAVideoSurface*)this, NULL, 0, 0};
@@ -513,19 +512,25 @@ STDMETHODIMP CRealMediaWindowlessSite::ShowSite(BOOL bShow)
STDMETHODIMP_(BOOL) CRealMediaWindowlessSite::IsSiteVisible()
{
BOOL fIsVisible = m_fIsVisible;
- if(m_pParentSite) fIsVisible = fIsVisible && m_pParentSite->IsSiteVisible();
+ 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())
+ if(lZOrder == -1 || lZOrder >= (INT32)m_pParentSite->GetNumberOfChildSites()) {
lZOrder = m_pParentSite->GetNumberOfChildSites() - 1;
+ }
- if(m_lZOrder != lZOrder)
+ if(m_lZOrder != lZOrder) {
m_pParentSite->UpdateZOrder(this, m_lZOrder, lZOrder);
+ }
m_lZOrder = lZOrder;
@@ -534,14 +539,18 @@ STDMETHODIMP CRealMediaWindowlessSite::SetZOrder(INT32 lZOrder)
STDMETHODIMP CRealMediaWindowlessSite::GetZOrder(REF(INT32) lZOrder)
{
- if(!m_pParentSite) return PNR_UNEXPECTED;
+ if(!m_pParentSite) {
+ return PNR_UNEXPECTED;
+ }
lZOrder = m_lZOrder;
return PNR_OK;
}
STDMETHODIMP CRealMediaWindowlessSite::MoveSiteToTop()
{
- if(!m_pParentSite) return PNR_UNEXPECTED;
+ if(!m_pParentSite) {
+ return PNR_UNEXPECTED;
+ }
return PNR_NOTIMPL;
}
@@ -564,8 +573,7 @@ STDMETHODIMP CRealMediaWindowlessSite::AddPassiveSiteWatcher(IRMAPassiveSiteWatc
STDMETHODIMP CRealMediaWindowlessSite::RemovePassiveSiteWatcher(IRMAPassiveSiteWatcher* pWatcher)
{
- if(POSITION pos = m_pPassiveWatchers.Find(pWatcher))
- {
+ if(POSITION pos = m_pPassiveWatchers.Find(pWatcher)) {
m_pPassiveWatchers.RemoveAt(pos);
return PNR_OK;
}
@@ -594,14 +602,10 @@ bool CRealMediaWindowlessSite::GetBltService(IRMAVideoSurface** ppBltService)
{
bool fRet = false;
- if(ppBltService)
- {
- if(m_pParentSite)
- {
+ if(ppBltService) {
+ if(m_pParentSite) {
fRet = m_pParentSite->GetBltService(ppBltService);
- }
- else if(m_pBltService)
- {
+ } else if(m_pBltService) {
(*ppBltService = m_pBltService)->AddRef();
fRet = true;
}
@@ -625,8 +629,7 @@ STDMETHODIMP CRealMediaWindowlessSite::Blt(UCHAR* /*IN*/ pImageData, RMABitmapIn
STDMETHODIMP CRealMediaWindowlessSite::BeginOptimizedBlt(RMABitmapInfoHeader* /*IN*/ pBitmapInfo)
{
- if(memcmp(&m_bitmapInfo, pBitmapInfo, sizeof(RMABitmapInfoHeader)))
- {
+ if(memcmp(&m_bitmapInfo, pBitmapInfo, sizeof(RMABitmapInfoHeader))) {
memcpy(&m_bitmapInfo, pBitmapInfo, sizeof(RMABitmapInfoHeader));
// format of image has changed somehow.
@@ -655,8 +658,9 @@ STDMETHODIMP CRealMediaWindowlessSite::OptimizedBlt(UCHAR* /*IN*/ pImageBits, RE
REGION* pRegion = GetRegion();
- if(!pBltService || !pRegion)
+ if(!pBltService || !pRegion) {
return PNR_UNEXPECTED;
+ }
PNxPoint origin;
memset(&origin, 0, sizeof(PNxPoint));
@@ -667,8 +671,7 @@ STDMETHODIMP CRealMediaWindowlessSite::OptimizedBlt(UCHAR* /*IN*/ pImageBits, RE
adjustedDestRect.right = rDestRect.right + origin.x;
adjustedDestRect.bottom = rDestRect.bottom + origin.y;
- for(int i = 0; i < pRegion->numRects; i++)
- {
+ for(int i = 0; i < pRegion->numRects; i++) {
PNxRect* pRect = pRegion->rects+i;
// intersect the dest rect with the rect from the
@@ -708,8 +711,9 @@ STDMETHODIMP CRealMediaWindowlessSite::GetPreferredFormat(REF(RMA_COMPRESSION_TY
{
CComPtr<IRMAVideoSurface> pBltService;
GetBltService(&pBltService);
- if(!pBltService)
+ if(!pBltService) {
return PNR_UNEXPECTED;
+ }
return pBltService->GetPreferredFormat(ulType);
}
diff --git a/src/apps/mplayerc/RealMediaWindowlessSite.h b/src/apps/mplayerc/RealMediaWindowlessSite.h
index e508b7b30..38b4261f8 100644
--- a/src/apps/mplayerc/RealMediaWindowlessSite.h
+++ b/src/apps/mplayerc/RealMediaWindowlessSite.h
@@ -45,176 +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);
-};
-
-//
-// 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;
+ 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);
- CComPtr<IRMASiteUser> m_pUser;
+ protected:
+ CComPtr<IUnknown> m_pContext;
+ CRealMediaWindowlessSite* m_pSiteWindowless;
+ RMABitmapInfoHeader m_bitmapInfo;
+ RMABitmapInfoHeader m_lastBitmapInfo;
- CRealMediaWindowlessSite* m_pParentSite;
- CInterfaceList<IRMASite, &IID_IRMASite> m_pChildren;
+ public:
+ CRealMediaVideoSurface(IUnknown* pContext, CRealMediaWindowlessSite* pSiteWindowless);
+ virtual ~CRealMediaVideoSurface();
- CComPtr<IRMASiteWatcher> m_pWatcher;
- CInterfaceList<IRMAPassiveSiteWatcher, &IID_IRMAPassiveSiteWatcher> m_pPassiveWatchers;
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- PNxSize m_size;
- PNxPoint m_position;
- bool m_fDamaged, m_fInRedraw, m_fIsVisible;
- INT32 m_lZOrder;
+ // 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
//
- REGION* m_pRegion;
- REGION* m_pRegionWithoutChildren;
+ 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 RecomputeRegion();
+ void InternalRecomputeRegion();
+ void ComputeRegion();
+ void SubtractSite(REGION* pRegion);
- void UpdateZOrder(CRealMediaWindowlessSite* pUpdatedChildSite, INT32 lOldZOrder, INT32 lNewZOrder);
- void SetInternalZOrder(INT32 lZOrder);
+ 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();
+ public:
+ CRealMediaWindowlessSite(HRESULT& hr, IUnknown* pContext, CRealMediaWindowlessSite* pParentSite = NULL, IUnknown* pUnkOuter = NULL);
+ virtual ~CRealMediaWindowlessSite();
- DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- void GetTopLeft(PNxPoint* pPoint);
- REGION* GetRegion();
+ 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/apps/mplayerc/RegFilterChooserDlg.cpp b/src/apps/mplayerc/RegFilterChooserDlg.cpp
index 28cf69f22..39bffd8d0 100644
--- a/src/apps/mplayerc/RegFilterChooserDlg.cpp
+++ b/src/apps/mplayerc/RegFilterChooserDlg.cpp
@@ -40,7 +40,9 @@ CRegFilterChooserDlg::CRegFilterChooserDlg(CWnd* pParent /*=NULL*/)
CRegFilterChooserDlg::~CRegFilterChooserDlg()
{
POSITION pos = m_filters.GetHeadPosition();
- while(pos) delete m_filters.GetNext(pos);
+ while(pos) {
+ delete m_filters.GetNext(pos);
+ }
}
void CRegFilterChooserDlg::DoDataExchange(CDataExchange* pDX)
@@ -52,11 +54,9 @@ void CRegFilterChooserDlg::DoDataExchange(CDataExchange* pDX)
void CRegFilterChooserDlg::AddToList(IMoniker* pMoniker)
{
CComPtr<IPropertyBag> pPB;
- if(SUCCEEDED(pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB)))
- {
+ if(SUCCEEDED(pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB))) {
CComVariant var;
- if(SUCCEEDED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL)))
- {
+ 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));
@@ -81,20 +81,17 @@ BOOL CRegFilterChooserDlg::OnInitDialog()
{
__super::OnInitDialog();
- BeginEnumSysDev(CLSID_LegacyAmFilterCategory, pMoniker)
- {
+ BeginEnumSysDev(CLSID_LegacyAmFilterCategory, pMoniker) {
AddToList(pMoniker);
}
EndEnumSysDev
- BeginEnumSysDev(DMOCATEGORY_VIDEO_EFFECT, pMoniker)
- {
+ BeginEnumSysDev(DMOCATEGORY_VIDEO_EFFECT, pMoniker) {
AddToList(pMoniker);
}
EndEnumSysDev
- BeginEnumSysDev(DMOCATEGORY_AUDIO_EFFECT, pMoniker)
- {
+ BeginEnumSysDev(DMOCATEGORY_AUDIO_EFFECT, pMoniker) {
AddToList(pMoniker);
}
EndEnumSysDev
@@ -125,10 +122,13 @@ 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)
- {
+ 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;
@@ -151,8 +151,7 @@ void CRegFilterChooserDlg::OnBnClickedButton1()
OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY,
_T("DirectShow Filters (*.dll,*.ax)|*.dll;*.ax|"), this, 0);
- if(dlg.DoModal() == IDOK)
- {
+ if(dlg.DoModal() == IDOK) {
CFilterMapper2 fm2(false);
fm2.Register(dlg.GetPathName());
m_filters.AddTail(&fm2.m_filters);
@@ -164,8 +163,7 @@ void CRegFilterChooserDlg::OnBnClickedButton1()
void CRegFilterChooserDlg::OnNMDblclkList2(NMHDR *pNMHDR, LRESULT *pResult)
{
- if(m_list.GetFirstSelectedItemPosition())
- {
+ if(m_list.GetFirstSelectedItemPosition()) {
OnBnClickedOk();
}
diff --git a/src/apps/mplayerc/RegFilterChooserDlg.h b/src/apps/mplayerc/RegFilterChooserDlg.h
index 6128c8a16..20433e806 100644
--- a/src/apps/mplayerc/RegFilterChooserDlg.h
+++ b/src/apps/mplayerc/RegFilterChooserDlg.h
@@ -30,7 +30,7 @@
class CRegFilterChooserDlg : public CResizableDialog
{
-// DECLARE_DYNAMIC(CRegFilterChooserDlg)
+ // DECLARE_DYNAMIC(CRegFilterChooserDlg)
CInterfaceList<IMoniker> m_monikers;
void AddToList(IMoniker* pMoniker);
@@ -41,7 +41,7 @@ public:
CList<FilterOverride*> m_filters;
-// Dialog Data
+ // Dialog Data
enum { IDD = IDD_ADDREGFILTER };
CListCtrl m_list;
diff --git a/src/apps/mplayerc/SaveDlg.cpp b/src/apps/mplayerc/SaveDlg.cpp
index 5c5541008..7e0c909a4 100644
--- a/src/apps/mplayerc/SaveDlg.cpp
+++ b/src/apps/mplayerc/SaveDlg.cpp
@@ -68,16 +68,19 @@ BOOL CSaveDlg::OnInitDialog()
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);
+ 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);
if(FAILED(pGB.CoCreateInstance(CLSID_FilterGraph)) || !(pMC = pGB) || !(pME = pGB) || !(pMS = pGB)
- || FAILED(pME->SetNotifyWindow((OAHWND)m_hWnd, WM_GRAPHNOTIFY, 0)))
- {
+ || FAILED(pME->SetNotifyWindow((OAHWND)m_hWnd, WM_GRAPHNOTIFY, 0))) {
m_report.SetWindowText(_T("Error"));
return FALSE;
}
@@ -88,34 +91,32 @@ BOOL CSaveDlg::OnInitDialog()
CComPtr<IFileSourceFilter> pReader;
#if INTERNAL_SOURCEFILTER_CDDA
- if(!pReader && m_in.Mid(m_in.ReverseFind('.')+1).MakeLower() == _T("cda"))
- {
+ 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)))
+ if(FAILED(hr) || !(pReader = pUnk) || FAILED(pReader->Load(fnw, NULL))) {
pReader.Release();
+ }
}
#endif
#if INTERNAL_SOURCEFILTER_CDXA
- if(!pReader)
- {
+ if(!pReader) {
hr = S_OK;
CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)DNew CCDXAReader(NULL, &hr);
- if(FAILED(hr) || !(pReader = pUnk) || FAILED(pReader->Load(fnw, NULL)))
+ if(FAILED(hr) || !(pReader = pUnk) || FAILED(pReader->Load(fnw, NULL))) {
pReader.Release();
+ }
}
#endif
#if INTERNAL_SOURCEFILTER_VTS
- if(!pReader /*&& ext == _T("ifo")*/)
- {
+ 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)))
+ if(FAILED(hr) || !(pReader = pUnk) || FAILED(pReader->Load(fnw, NULL))) {
pReader.Release();
- else
- {
+ } else {
CPath pout(m_out);
pout.RenameExtension(_T(".ifo"));
CopyFile(m_in, pout, FALSE);
@@ -123,25 +124,22 @@ BOOL CSaveDlg::OnInitDialog()
}
#endif
- if(!pReader)
- {
+ if(!pReader) {
hr = S_OK;
CComPtr<IUnknown> pUnk;
pUnk.CoCreateInstance(CLSID_AsyncReader);
- if(FAILED(hr) || !(pReader = pUnk) || FAILED(pReader->Load(fnw, NULL)))
+ if(FAILED(hr) || !(pReader = pUnk) || FAILED(pReader->Load(fnw, NULL))) {
pReader.Release();
+ }
}
- if(!pReader)
- {
+ 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
- {
+ 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)))
- {
+ if(FAILED(hr) || !(pReader = pUnk) || FAILED(hr = pReader->Load(fnw, NULL))) {
pReader.Release();
pGB->RemoveFilter(pSrc);
}
@@ -149,15 +147,13 @@ BOOL CSaveDlg::OnInitDialog()
}
CComQIPtr<IBaseFilter> pSrc = pReader;
- if(FAILED(pGB->AddFilter(pSrc, fnw)))
- {
+ 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")))
- {
+ if(FAILED(pGB->AddFilter(pMid, L"StreamDriveThru"))) {
m_report.SetWindowText(_T("Error"));
return FALSE;
}
@@ -167,8 +163,7 @@ BOOL CSaveDlg::OnInitDialog()
CComQIPtr<IFileSinkFilter2> pFSF = pDst;
pFSF->SetFileName(CStringW(m_out), NULL);
pFSF->SetMode(AM_FILE_OVERWRITE);
- if(FAILED(pGB->AddFilter(pDst, L"File Writer")))
- {
+ if(FAILED(pGB->AddFilter(pDst, L"File Writer"))) {
m_report.SetWindowText(_T("Error"));
return FALSE;
}
@@ -193,7 +188,9 @@ BOOL CSaveDlg::OnInitDialog()
void CSaveDlg::OnBnClickedCancel()
{
- if(pMC) pMC->Stop();
+ if(pMC) {
+ pMC->Stop();
+ }
OnCancel();
}
@@ -201,17 +198,13 @@ void CSaveDlg::OnBnClickedCancel()
LRESULT CSaveDlg::OnGraphNotify(WPARAM wParam, LPARAM lParam)
{
LONG evCode, evParam1, evParam2;
- while(pME && SUCCEEDED(pME->GetEvent(&evCode, (LONG_PTR*)&evParam1, (LONG_PTR*)&evParam2, 0)))
- {
+ while(pME && SUCCEEDED(pME->GetEvent(&evCode, (LONG_PTR*)&evParam1, (LONG_PTR*)&evParam2, 0))) {
HRESULT hr = pME->FreeEventParams(evCode, evParam1, evParam2);
UNUSED_ALWAYS(hr);
- if(EC_COMPLETE == evCode)
- {
+ if(EC_COMPLETE == evCode) {
EndDialog(IDOK);
- }
- else if(EC_ERRORABORT == evCode)
- {
+ } else if(EC_ERRORABORT == evCode) {
TRACE(_T("CSaveDlg::OnGraphNotify / EC_ERRORABORT, hr = %08x\n"), (HRESULT)evParam1);
m_report.SetWindowText(_T("Copying unexpectedly terminated!"));
}
@@ -222,10 +215,8 @@ LRESULT CSaveDlg::OnGraphNotify(WPARAM wParam, LPARAM lParam)
void CSaveDlg::OnTimer(UINT_PTR nIDEvent)
{
- if(nIDEvent == m_nIDTimerEvent && pGB)
- {
- if(pMS)
- {
+ if(nIDEvent == m_nIDTimerEvent && pGB) {
+ if(pMS) {
CString str;
REFERENCE_TIME pos = 0, dur = 0;
pMS->GetCurrentPosition(&pos);
diff --git a/src/apps/mplayerc/SaveDlg.h b/src/apps/mplayerc/SaveDlg.h
index a27536ae0..247f198d5 100644
--- a/src/apps/mplayerc/SaveDlg.h
+++ b/src/apps/mplayerc/SaveDlg.h
@@ -45,7 +45,7 @@ public:
CSaveDlg(CString in, CString out, CWnd* pParent = NULL); // standard constructor
virtual ~CSaveDlg();
-// Dialog Data
+ // Dialog Data
enum { IDD = IDD_SAVE_DLG };
CAnimateCtrl m_anim;
CProgressCtrl m_progress;
diff --git a/src/apps/mplayerc/SaveTextFileDialog.cpp b/src/apps/mplayerc/SaveTextFileDialog.cpp
index bde35c6dd..791de60f8 100644
--- a/src/apps/mplayerc/SaveTextFileDialog.cpp
+++ b/src/apps/mplayerc/SaveTextFileDialog.cpp
@@ -38,12 +38,9 @@ CSaveTextFileDialog::CSaveTextFileDialog(
lpszFilter, pParentWnd, 0, FALSE),
m_e(e)
{
- if(m_ofn.lStructSize == sizeof(OPENFILENAME))
- {
+ if(m_ofn.lStructSize == sizeof(OPENFILENAME)) {
SetTemplate(0, IDD_SAVETEXTFILEDIALOGTEMPL);
- }
- else /*if(m_ofn.lStructSize == OPENFILENAME_SIZE_VERSION_400)*/
- {
+ } else { /*if(m_ofn.lStructSize == OPENFILENAME_SIZE_VERSION_400)*/
SetTemplate(0, IDD_SAVETEXTFILEDIALOGTEMPL_400);
}
}
@@ -67,21 +64,20 @@ BOOL CSaveTextFileDialog::OnInitDialog()
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
diff --git a/src/apps/mplayerc/SaveTextFileDialog.h b/src/apps/mplayerc/SaveTextFileDialog.h
index 1c0325bcc..29ad8b56c 100644
--- a/src/apps/mplayerc/SaveTextFileDialog.h
+++ b/src/apps/mplayerc/SaveTextFileDialog.h
@@ -44,8 +44,7 @@ public:
CComboBox m_encoding;
- CTextFile::enc GetEncoding()
- {
+ CTextFile::enc GetEncoding() {
return(m_e);
}
diff --git a/src/apps/mplayerc/SaveThumbnailsDialog.cpp b/src/apps/mplayerc/SaveThumbnailsDialog.cpp
index 62ff7356d..8634ebd04 100644
--- a/src/apps/mplayerc/SaveThumbnailsDialog.cpp
+++ b/src/apps/mplayerc/SaveThumbnailsDialog.cpp
@@ -38,12 +38,9 @@ CSaveThumbnailsDialog::CSaveThumbnailsDialog(
lpszFilter, pParentWnd, 0, FALSE),
m_rows(rows), m_cols(cols), m_width(width)
{
- if(m_ofn.lStructSize == sizeof(OPENFILENAME))
- {
+ if(m_ofn.lStructSize == sizeof(OPENFILENAME)) {
SetTemplate(0, IDD_SAVETHUMBSDIALOGTEMPL);
- }
- else /*if(m_ofn.lStructSize == OPENFILENAME_SIZE_VERSION_400)*/
- {
+ } else { /*if(m_ofn.lStructSize == OPENFILENAME_SIZE_VERSION_400)*/
SetTemplate(0, IDD_SAVETHUMBSDIALOGTEMPL_400);
}
}
diff --git a/src/apps/mplayerc/SelectMediaType.cpp b/src/apps/mplayerc/SelectMediaType.cpp
index 192dc1d1f..fe4de822c 100644
--- a/src/apps/mplayerc/SelectMediaType.cpp
+++ b/src/apps/mplayerc/SelectMediaType.cpp
@@ -61,8 +61,7 @@ BOOL CSelectMediaType::OnInitDialog()
{
CCmdUIDialog::OnInitDialog();
- for(int i = 0; i < m_guids.GetCount(); i++)
- {
+ for(int i = 0; i < m_guids.GetCount(); i++) {
m_guidsctrl.AddString(GetMediaTypeName(m_guids[i]));
}
@@ -74,8 +73,7 @@ void CSelectMediaType::OnCbnEditchangeCombo1()
{
UpdateData();
int i = m_guidsctrl.FindStringExact(0, m_guidstr);
- if(i >= 0)
- {
+ if(i >= 0) {
DWORD sel = m_guidsctrl.GetEditSel();
m_guidsctrl.SetCurSel(i);
m_guidsctrl.SetEditSel(sel,sel);
diff --git a/src/apps/mplayerc/SelectMediaType.h b/src/apps/mplayerc/SelectMediaType.h
index f87e38e6e..3b64b6e7e 100644
--- a/src/apps/mplayerc/SelectMediaType.h
+++ b/src/apps/mplayerc/SelectMediaType.h
@@ -41,7 +41,7 @@ public:
GUID m_guid;
-// Dialog Data
+ // Dialog Data
enum { IDD = IDD_SELECTMEDIATYPE };
CString m_guidstr;
CComboBox m_guidsctrl;
diff --git a/src/apps/mplayerc/ShaderAutoCompleteDlg.cpp b/src/apps/mplayerc/ShaderAutoCompleteDlg.cpp
index d8565597a..b0b9eb9e9 100644
--- a/src/apps/mplayerc/ShaderAutoCompleteDlg.cpp
+++ b/src/apps/mplayerc/ShaderAutoCompleteDlg.cpp
@@ -170,15 +170,18 @@ void CShaderAutoCompleteDlg::OnLbnSelchangeList1()
::SendMessage(m_hToolTipWnd, TTM_TRACKACTIVATE, FALSE, (LPARAM)&m_ti);
int i = m_list.GetCurSel();
- if(i < 0) return;
+ if(i < 0) {
+ return;
+ }
- if(POSITION pos = (POSITION)m_list.GetItemData(i))
- {
+ 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;
+ if(sl.GetCount() != 2) {
+ return;
+ }
_tcscpy(m_ti.lpszText, sl.RemoveTail());
CRect r;
GetWindowRect(r);
@@ -192,8 +195,7 @@ void CShaderAutoCompleteDlg::OnShowWindow(BOOL bShow, UINT nStatus)
{
CResizableDialog::OnShowWindow(bShow, nStatus);
- if(!bShow)
- {
+ if(!bShow) {
::SendMessage(m_hToolTipWnd, TTM_TRACKACTIVATE, FALSE, (LPARAM)&m_ti);
}
}
diff --git a/src/apps/mplayerc/ShaderAutoCompleteDlg.h b/src/apps/mplayerc/ShaderAutoCompleteDlg.h
index 14eda44e1..392572e81 100644
--- a/src/apps/mplayerc/ShaderAutoCompleteDlg.h
+++ b/src/apps/mplayerc/ShaderAutoCompleteDlg.h
@@ -40,7 +40,7 @@ public:
CMap<CString, LPCTSTR, CString, CString> m_inst;
-// Dialog Data
+ // Dialog Data
enum { IDD = IDD_SHADERAUTOCOMPLETE_DLG };
protected:
diff --git a/src/apps/mplayerc/ShaderCombineDlg.cpp b/src/apps/mplayerc/ShaderCombineDlg.cpp
index 02f684e61..550c5379d 100644
--- a/src/apps/mplayerc/ShaderCombineDlg.cpp
+++ b/src/apps/mplayerc/ShaderCombineDlg.cpp
@@ -71,20 +71,29 @@ BOOL CShaderCombineDlg::OnInitDialog()
AppSettings& s = AfxGetAppSettings();
CString str;
- if (m_bScreenSpace)
+ if (m_bScreenSpace) {
str = s.strShadercombineScreenSpace.Trim();
- else
+ } else {
str = s.strShadercombine.Trim();
+ }
CAtlList<CString> sl;
- if(!str.IsEmpty()) Explode(str, sl, '|');
+ if(!str.IsEmpty()) {
+ Explode(str, sl, '|');
+ }
POSITION pos = sl.GetHeadPosition();
- while(pos) m_list.AddString(sl.GetNext(pos));
+ while(pos) {
+ m_list.AddString(sl.GetNext(pos));
+ }
pos = s.m_shaders.GetHeadPosition();
- while(pos) m_combo.AddString(s.m_shaders.GetNext(pos).label);
- if(m_combo.GetCount()) m_combo.SetCurSel(0);
+ while(pos) {
+ m_combo.AddString(s.m_shaders.GetNext(pos).label);
+ }
+ if(m_combo.GetCount()) {
+ m_combo.SetCurSel(0);
+ }
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
@@ -96,18 +105,18 @@ void CShaderCombineDlg::OnOK()
CAtlList<CString> sl;
- for(int i = 0, j = m_list.GetCount(); i < j; i++)
- {
+ for(int i = 0, j = m_list.GetCount(); i < j; i++) {
CString label;
m_list.GetText(i, label);
sl.AddTail(label);
m_labels.AddTail(label);
}
- if (m_bScreenSpace)
+ if (m_bScreenSpace) {
AfxGetAppSettings().strShadercombineScreenSpace = Implode(sl, '|');
- else
+ } else {
AfxGetAppSettings().strShadercombine = Implode(sl, '|');
+ }
__super::OnOK();
}
@@ -115,7 +124,9 @@ void CShaderCombineDlg::OnOK()
void CShaderCombineDlg::OnBnClickedButton12()
{
int i = m_combo.GetCurSel();
- if(i < 0) return;
+ if(i < 0) {
+ return;
+ }
CString label;
m_combo.GetLBText(i, label);
@@ -125,17 +136,25 @@ void CShaderCombineDlg::OnBnClickedButton12()
void CShaderCombineDlg::OnBnClickedButton13()
{
int i = m_list.GetCurSel();
- if(i < 0) return;
+ if(i < 0) {
+ return;
+ }
m_list.DeleteString(i);
- if(i == m_list.GetCount()) i--;
- if(i >= 0) m_list.SetCurSel(i);
+ if(i == m_list.GetCount()) {
+ i--;
+ }
+ if(i >= 0) {
+ m_list.SetCurSel(i);
+ }
}
void CShaderCombineDlg::OnBnClickedButton1()
{
int i = m_list.GetCurSel();
- if(i < 1) return;
+ if(i < 1) {
+ return;
+ }
CString label;
m_list.GetText(i, label);
@@ -148,12 +167,17 @@ void CShaderCombineDlg::OnBnClickedButton1()
void CShaderCombineDlg::OnBnClickedButton11()
{
int i = m_list.GetCurSel();
- if(i < 0 || i >= m_list.GetCount()-1) return;
+ if(i < 0 || i >= m_list.GetCount()-1) {
+ return;
+ }
CString label;
m_list.GetText(i, label);
m_list.DeleteString(i);
- if(++i == m_list.GetCount()) m_list.AddString(label);
- else m_list.InsertString(i, label);
+ if(++i == m_list.GetCount()) {
+ m_list.AddString(label);
+ } else {
+ m_list.InsertString(i, label);
+ }
m_list.SetCurSel(i);
}
diff --git a/src/apps/mplayerc/ShaderCombineDlg.h b/src/apps/mplayerc/ShaderCombineDlg.h
index c91c985de..90cab7fc3 100644
--- a/src/apps/mplayerc/ShaderCombineDlg.h
+++ b/src/apps/mplayerc/ShaderCombineDlg.h
@@ -37,7 +37,7 @@ public:
CShaderCombineDlg(CAtlList<CString>& labels, CWnd* pParent, bool bScreenSpace); // standard constructor
virtual ~CShaderCombineDlg();
-// Dialog Data
+ // Dialog Data
enum { IDD = IDD_SHADERCOMBINE_DLG };
protected:
diff --git a/src/apps/mplayerc/ShaderEditorDlg.cpp b/src/apps/mplayerc/ShaderEditorDlg.cpp
index ecdd68253..d1111e0ef 100644
--- a/src/apps/mplayerc/ShaderEditorDlg.cpp
+++ b/src/apps/mplayerc/ShaderEditorDlg.cpp
@@ -39,10 +39,10 @@ END_MESSAGE_MAP()
HBRUSH CShaderLabelComboBox::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
- if(nCtlColor == CTLCOLOR_EDIT)
- {
- if(m_edit.GetSafeHwnd() == NULL)
+ if(nCtlColor == CTLCOLOR_EDIT) {
+ if(m_edit.GetSafeHwnd() == NULL) {
m_edit.SubclassWindow(pWnd->GetSafeHwnd());
+ }
}
return __super::OnCtlColor(pDC, pWnd, nCtlColor);
@@ -50,8 +50,9 @@ HBRUSH CShaderLabelComboBox::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
void CShaderLabelComboBox::OnDestroy()
{
- if(m_edit.GetSafeHwnd() != NULL)
+ if(m_edit.GetSafeHwnd() != NULL) {
m_edit.UnsubclassWindow();
+ }
__super::OnDestroy();
}
@@ -77,35 +78,32 @@ BOOL CShaderEdit::PreTranslateMessage(MSG* pMsg)
&& 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))
- {
+ || pMsg->wParam == VK_RETURN || pMsg->wParam == VK_ESCAPE)) {
int i = m_acdlg.m_list.GetCurSel();
- if(pMsg->wParam == VK_RETURN && i >= 0)
- {
+ 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);
+ 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)))
+ while(nStartChar > 0 && _istalnum(text.GetAt(nStartChar-1))) {
nStartChar--;
+ }
SetSel(nStartChar, nEndChar);
ReplaceSel(str, TRUE);
- }
- else if(pMsg->wParam == VK_ESCAPE)
- {
+ } else if(pMsg->wParam == VK_ESCAPE) {
m_acdlg.ShowWindow(SW_HIDE);
return GetParent()->PreTranslateMessage(pMsg);
- }
- else
- {
+ } else {
m_acdlg.m_list.SendMessage(pMsg->message, pMsg->wParam, pMsg->lParam);
}
@@ -123,8 +121,7 @@ END_MESSAGE_MAP()
void CShaderEdit::OnUpdate()
{
- if(m_nIDEvent == (UINT_PTR)-1)
- {
+ if(m_nIDEvent == (UINT_PTR)-1) {
m_nIDEvent = SetTimer(1, 100, NULL);
}
@@ -132,15 +129,14 @@ void CShaderEdit::OnUpdate()
int nStartChar = 0, nEndChar = -1;
GetSel(nStartChar, nEndChar);
- if(nStartChar == nEndChar)
- {
+ if(nStartChar == nEndChar) {
GetWindowText(text);
- while(nStartChar > 0 && _istalnum(text.GetAt(nStartChar-1)))
+ while(nStartChar > 0 && _istalnum(text.GetAt(nStartChar-1))) {
nStartChar--;
+ }
}
- if(nStartChar < nEndChar)
- {
+ if(nStartChar < nEndChar) {
text = text.Mid(nStartChar, nEndChar - nStartChar);
text.TrimRight('(');
text.MakeLower();
@@ -149,16 +145,16 @@ void CShaderEdit::OnUpdate()
CString key, value;
POSITION pos = m_acdlg.m_inst.GetStartPosition();
- while(pos)
- {
+ while(pos) {
POSITION cur = pos;
m_acdlg.m_inst.GetNextAssoc(pos, key, value);
- if(key.Find(text) == 0)
- {
+ if(key.Find(text) == 0) {
CAtlList<CString> sl;
Explode(value, sl, '|', 2);
- if(sl.GetCount() != 2) continue;
+ if(sl.GetCount() != 2) {
+ continue;
+ }
CString name = sl.RemoveHead();
CString description = sl.RemoveHead();
int i = m_acdlg.m_list.AddString(name);
@@ -166,8 +162,7 @@ void CShaderEdit::OnUpdate()
}
}
- if(m_acdlg.m_list.GetCount() > 0)
- {
+ if(m_acdlg.m_list.GetCount() > 0) {
int lineheight = GetLineHeight();
CPoint p = PosFromChar(nStartChar);
@@ -200,12 +195,12 @@ void CShaderEdit::OnKillFocus(CWnd* pNewWnd)
void CShaderEdit::OnTimer(UINT_PTR nIDEvent)
{
- if(m_nIDEvent == nIDEvent)
- {
+ if(m_nIDEvent == nIDEvent) {
int nStartChar = 0, nEndChar = -1;
GetSel(nStartChar, nEndChar);
- if(nStartChar != nEndChar || m_nEndChar != nEndChar)
+ if(nStartChar != nEndChar || m_nEndChar != nEndChar) {
m_acdlg.ShowWindow(SW_HIDE);
+ }
}
__super::OnTimer(nIDEvent);
@@ -228,8 +223,9 @@ CShaderEditorDlg::~CShaderEditorDlg()
BOOL CShaderEditorDlg::Create(CWnd* pParent)
{
- if(!__super::Create(IDD, pParent))
+ if(!__super::Create(IDD, pParent)) {
return FALSE;
+ }
AddAnchor(IDC_COMBO1, TOP_LEFT, TOP_RIGHT);
AddAnchor(IDC_COMBO2, TOP_RIGHT);
@@ -241,10 +237,6 @@ BOOL CShaderEditorDlg::Create(CWnd* pParent)
SetMinTrackSize(CSize(250, 40));
- m_targets.AddString(_T("ps_1_1"));
- m_targets.AddString(_T("ps_1_2"));
- m_targets.AddString(_T("ps_1_3"));
- m_targets.AddString(_T("ps_1_4"));
m_targets.AddString(_T("ps_2_0"));
m_targets.AddString(_T("ps_2_a"));
m_targets.AddString(_T("ps_2_sw"));
@@ -252,8 +244,7 @@ BOOL CShaderEditorDlg::Create(CWnd* pParent)
m_targets.AddString(_T("ps_3_sw"));
POSITION pos = AfxGetAppSettings().m_shaders.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
const AppSettings::Shader& s = AfxGetAppSettings().m_shaders.GetNext(pos);
m_labels.SetItemDataPtr(m_labels.AddString(s.label), (void*)&s);
}
@@ -302,22 +293,19 @@ END_MESSAGE_MAP()
BOOL CShaderEditorDlg::PreTranslateMessage(MSG* pMsg)
{
if(pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN
- && pMsg->hwnd == m_labels.m_edit.GetSafeHwnd())
- {
+ && 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())
- {
+ } 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"));
+ if(nStartChar == nEndChar) {
+ m_srcdata.ReplaceSel(_T("\t"));
+ }
return TRUE;
- }
- else if(pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_ESCAPE)
- {
+ } else if(pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_ESCAPE) {
return GetParent()->PreTranslateMessage(pMsg);
}
@@ -328,13 +316,14 @@ void CShaderEditorDlg::OnCbnSelchangeCombo1()
{
int i = m_labels.GetCurSel();
- if(i < 0)
- {
+ 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"));
@@ -364,21 +353,24 @@ void CShaderEditorDlg::OnCbnSelchangeCombo1()
void CShaderEditorDlg::OnBnClickedButton2()
{
- if(!m_pShader) return;
+ if(!m_pShader) {
+ return;
+ }
- if(IDYES != AfxMessageBox(ResStr(IDS_SHADEREDITORDLG_0), MB_YESNO))
+ if(IDYES != AfxMessageBox(ResStr(IDS_SHADEREDITORDLG_0), MB_YESNO)) {
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))
- {
+ 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);
+ if(i >= 0) {
+ m_labels.DeleteString(i);
+ }
m_labels.SetWindowText(_T(""));
m_targets.SetWindowText(_T(""));
m_srcdata.SetWindowText(_T(""));
@@ -391,8 +383,7 @@ void CShaderEditorDlg::OnBnClickedButton2()
void CShaderEditorDlg::OnTimer(UINT_PTR nIDEvent)
{
- if(nIDEvent == m_nIDEventShader && IsWindowVisible() && m_pShader)
- {
+ if(nIDEvent == m_nIDEventShader && IsWindowVisible() && m_pShader) {
CString srcdata;
m_srcdata.GetWindowText(srcdata);
srcdata.Replace(_T("\r"), _T(""));
@@ -402,20 +393,20 @@ void CShaderEditorDlg::OnTimer(UINT_PTR nIDEvent)
m_targets.GetWindowText(target);
target.Trim();
- if(!srcdata.IsEmpty() && !target.IsEmpty() && (m_pShader->srcdata != srcdata || m_pShader->target != target))
- {
+ if(!srcdata.IsEmpty() && !target.IsEmpty() && (m_pShader->srcdata != srcdata || m_pShader->target != target)) {
KillTimer(m_nIDEventShader);
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);
- if(SUCCEEDED(hr))
- {
+ if(SUCCEEDED(hr)) {
errmsg = _T("D3DXCompileShader succeeded\n");
errmsg += _T("\n");
errmsg += disasm;
@@ -438,8 +429,7 @@ void CShaderEditorDlg::OnTimer(UINT_PTR nIDEvent)
void CShaderEditorDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
- if(HitTestSplitter(point))
- {
+ if(HitTestSplitter(point)) {
m_fSplitterGrabbed = true;
SetCapture();
}
@@ -449,8 +439,7 @@ void CShaderEditorDlg::OnLButtonDown(UINT nFlags, CPoint point)
void CShaderEditorDlg::OnLButtonUp(UINT nFlags, CPoint point)
{
- if(m_fSplitterGrabbed)
- {
+ if(m_fSplitterGrabbed) {
ReleaseCapture();
m_fSplitterGrabbed = false;
}
@@ -460,8 +449,7 @@ void CShaderEditorDlg::OnLButtonUp(UINT nFlags, CPoint point)
void CShaderEditorDlg::OnMouseMove(UINT nFlags, CPoint point)
{
- if(m_fSplitterGrabbed)
- {
+ if(m_fSplitterGrabbed) {
CRect r, rs, ro;
GetClientRect(&r);
m_srcdata.GetWindowRect(&rs);
@@ -493,8 +481,7 @@ BOOL CShaderEditorDlg::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
CPoint p;
GetCursorPos(&p);
ScreenToClient(&p);
- if(HitTestSplitter(p))
- {
+ if(HitTestSplitter(p)) {
::SetCursor(AfxGetApp()->LoadStandardCursor(IDC_SIZENS));
return TRUE;
}
diff --git a/src/apps/mplayerc/ShaderEditorDlg.h b/src/apps/mplayerc/ShaderEditorDlg.h
index 41fdbe0a2..2775a4097 100644
--- a/src/apps/mplayerc/ShaderEditorDlg.h
+++ b/src/apps/mplayerc/ShaderEditorDlg.h
@@ -79,7 +79,7 @@ public:
BOOL Create(CWnd* pParent = NULL);
-// Dialog Data
+ // Dialog Data
enum { IDD = IDD_SHADEREDITOR_DLG };
CShaderLabelComboBox m_labels;
CComboBox m_targets;
diff --git a/src/apps/mplayerc/ShockwaveGraph.cpp b/src/apps/mplayerc/ShockwaveGraph.cpp
index 938c4c782..a8e8632fd 100644
--- a/src/apps/mplayerc/ShockwaveGraph.cpp
+++ b/src/apps/mplayerc/ShockwaveGraph.cpp
@@ -34,15 +34,13 @@ CShockwaveGraph::CShockwaveGraph(HWND hParent, HRESULT& hr)
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))
- {
+ 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))
- {
+ CRect(0, 0, 0, 0), &m_wndWindowFrame, 0)) {
hr = E_FAIL;
return;
}
@@ -58,12 +56,9 @@ CShockwaveGraph::~CShockwaveGraph()
// IGraphBuilder
STDMETHODIMP CShockwaveGraph::RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPlayList)
{
- try
- {
+ try {
m_wndDestFrame.LoadMovie(0, CString(lpcwstrFile));
- }
- catch(CException* e)
- {
+ } catch(CException* e) {
e->Delete();
return E_FAIL;
}
@@ -73,32 +68,30 @@ STDMETHODIMP CShockwaveGraph::RenderFile(LPCWSTR lpcwstrFile, LPCWSTR lpcwstrPla
// IMediaControl
STDMETHODIMP CShockwaveGraph::Run()
{
- try
- {
+ 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)
- {
+ 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();
+ // m_wndDestFrame.EnableWindow();
return S_OK;
}
STDMETHODIMP CShockwaveGraph::Pause()
{
- try
- {
- if(m_fs == State_Running) m_wndDestFrame.Stop();
- }
- catch(CException* e)
- {
+ try {
+ if(m_fs == State_Running) {
+ m_wndDestFrame.Stop();
+ }
+ } catch(CException* e) {
e->Delete();
return E_FAIL;
}
@@ -107,12 +100,9 @@ STDMETHODIMP CShockwaveGraph::Pause()
}
STDMETHODIMP CShockwaveGraph::Stop()
{
- try
- {
+ try {
m_wndDestFrame.Stop();
- }
- catch(CException* e)
- {
+ } catch(CException* e) {
e->Delete();
return E_FAIL;
}
@@ -123,16 +113,16 @@ 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;
+ 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)
- {
+ } catch(CException* e) {
e->Delete();
return E_FAIL;
}
@@ -153,12 +143,11 @@ 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)
- {
+ try {
+ if(m_wndDestFrame.get_ReadyState() >= READYSTATE_COMPLETE) {
+ *pDuration = m_wndDestFrame.get_TotalFrames();
+ }
+ } catch(CException* e) {
e->Delete();
return E_FAIL;
}
@@ -168,12 +157,11 @@ 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)
- {
+ try {
+ if(m_wndDestFrame.get_ReadyState() >= READYSTATE_COMPLETE) {
+ *pCurrent = m_wndDestFrame.get_FrameNum();
+ }
+ } catch(CException* e) {
e->Delete();
return E_FAIL;
}
@@ -181,14 +169,14 @@ STDMETHODIMP CShockwaveGraph::GetCurrentPosition(LONGLONG* pCurrent)
}
STDMETHODIMP CShockwaveGraph::SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags)
{
- if(dwCurrentFlags&AM_SEEKING_AbsolutePositioning)
- {
+ if(dwCurrentFlags&AM_SEEKING_AbsolutePositioning) {
m_wndDestFrame.put_FrameNum(*pCurrent);
- if(m_fs == State_Running && !m_wndDestFrame.IsPlaying())
+ if(m_fs == State_Running && !m_wndDestFrame.IsPlaying()) {
m_wndDestFrame.Play();
- else if((m_fs == State_Paused || m_fs == State_Stopped) && m_wndDestFrame.IsPlaying())
+ } 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
@@ -201,8 +189,9 @@ STDMETHODIMP CShockwaveGraph::SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFl
// IVideoWindow
STDMETHODIMP CShockwaveGraph::put_Visible(long Visible)
{
- if(IsWindow(m_wndDestFrame.m_hWnd))
+ 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,8 +200,9 @@ 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))
+ if(IsWindow(m_wndWindowFrame.m_hWnd)) {
m_wndWindowFrame.MoveWindow(Left, Top, Width, Height);
+ }
return S_OK;
}
@@ -220,24 +210,24 @@ STDMETHODIMP CShockwaveGraph::SetWindowPosition(long Left, long Top, long Width,
// IBasicVideo
STDMETHODIMP CShockwaveGraph::SetDestinationPosition(long Left, long Top, long Width, long Height)// {return E_NOTIMPL;}
{
- if(IsWindow(m_wndDestFrame.m_hWnd))
+ if(IsWindow(m_wndDestFrame.m_hWnd)) {
m_wndDestFrame.MoveWindow(Left, Top, Width, Height);
+ }
return S_OK;
}
STDMETHODIMP CShockwaveGraph::GetVideoSize(long* pWidth, long* pHeight)
{
- if(!pWidth || !pHeight) return E_POINTER;
+ if(!pWidth || !pHeight) {
+ return E_POINTER;
+ }
CRect r;
m_wndWindowFrame.GetWindowRect(r);
- if(!r.IsRectEmpty())
- {
+ if(!r.IsRectEmpty()) {
*pWidth = r.Width();
*pHeight = r.Height();
- }
- else
- {
+ } else {
// no call exists to determine these...
*pWidth = 384;//m_wndDestFrame.get_;
*pHeight = 288;
diff --git a/src/apps/mplayerc/ShockwaveGraph.h b/src/apps/mplayerc/ShockwaveGraph.h
index 4cfabc639..276c87347 100644
--- a/src/apps/mplayerc/ShockwaveGraph.h
+++ b/src/apps/mplayerc/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/apps/mplayerc/StaticLink.cpp b/src/apps/mplayerc/StaticLink.cpp
index 5601ce9bc..75a802c58 100644
--- a/src/apps/mplayerc/StaticLink.cpp
+++ b/src/apps/mplayerc/StaticLink.cpp
@@ -75,12 +75,10 @@ HBRUSH CStaticLink::CtlColor(CDC* pDC, UINT nCtlColor)
DWORD dwStyle = GetStyle();
HBRUSH hbr = NULL;
- if ((dwStyle & 0xFF) <= SS_RIGHT)
- {
+ if ((dwStyle & 0xFF) <= SS_RIGHT) {
// this is a text control: set up font and colors
- if (!(HFONT)m_font)
- {
+ if (!(HFONT)m_font) {
// first time init: create font
LOGFONT lf;
GetFont()->GetObject(sizeof(lf), &lf);
@@ -104,25 +102,22 @@ HBRUSH CStaticLink::CtlColor(CDC* pDC, UINT nCtlColor)
//
void CStaticLink::OnLButtonDown(UINT nFlags, CPoint point)
{
- if (m_link.IsEmpty())
- {
+ 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())
+ 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)h > 32) // success!
- {
+ if ((UINT)h > 32) { // success!
m_color = g_colorVisited; // change color
Invalidate(); // repaint
- }
- else
- {
+ } else {
MessageBeep(0); // unable to execute file!
TRACE(_T("*** WARNING: CStaticLink: unable to navigate link %s\n"),
(LPCTSTR)m_link);
@@ -137,18 +132,15 @@ void CStaticLink::OnLButtonDown(UINT nFlags, CPoint point)
//
BOOL CStaticLink::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
{
- if (g_hCursorLink == NULL)
- {
+ if (g_hCursorLink == NULL) {
static BOOL bTriedOnce = FALSE;
- if (!bTriedOnce)
- {
+ if (!bTriedOnce) {
CString windir;
GetWindowsDirectory(windir.GetBuffer(_MAX_PATH), _MAX_PATH);
windir.ReleaseBuffer();
windir += _T("\\winhlp32.exe");
HMODULE hModule = LoadLibrary(windir);
- if (hModule)
- {
+ if (hModule) {
g_hCursorLink =
CopyCursor(::LoadCursor(hModule, MAKEINTRESOURCE(106)));
}
@@ -156,8 +148,7 @@ BOOL CStaticLink::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
bTriedOnce = TRUE;
}
}
- if (g_hCursorLink)
- {
+ if (g_hCursorLink) {
::SetCursor(g_hCursorLink);
return TRUE;
}
@@ -174,6 +165,7 @@ BOOL CStaticLink::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
//
void CStaticLink::PostNcDestroy()
{
- if (m_bDeleteOnDestroy)
+ if (m_bDeleteOnDestroy) {
delete this;
+ }
}
diff --git a/src/apps/mplayerc/StaticLink.h b/src/apps/mplayerc/StaticLink.h
index a887b890f..d02195eb6 100644
--- a/src/apps/mplayerc/StaticLink.h
+++ b/src/apps/mplayerc/StaticLink.h
@@ -30,17 +30,14 @@ class CHyperlink : public CString
public:
CHyperlink(LPCTSTR lpLink = NULL) : CString(lpLink) { }
~CHyperlink() { }
- const CHyperlink& operator=(LPCTSTR lpsz)
- {
+ const CHyperlink& operator=(LPCTSTR lpsz) {
CString::operator=(lpsz);
return *this;
}
- operator LPCTSTR()
- {
+ operator LPCTSTR() {
return CString::operator LPCTSTR();
}
- /*virtual*/ HINSTANCE Navigate()
- {
+ /*virtual*/ HINSTANCE Navigate() {
return IsEmpty() ? NULL :
ShellExecute(0, _T("open"), *this, 0, 0, SW_SHOWNORMAL);
}
diff --git a/src/apps/mplayerc/StatusLabel.cpp b/src/apps/mplayerc/StatusLabel.cpp
index 8cf0ae84a..2129107af 100644
--- a/src/apps/mplayerc/StatusLabel.cpp
+++ b/src/apps/mplayerc/StatusLabel.cpp
@@ -74,8 +74,7 @@ void CStatusLabel::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
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)
- {
+ while(size.cx > r.Width()-3 && str.GetLength() > 3) {
str = str.Left(str.GetLength()-4) + _T("...");
size = dc.GetTextExtent(str);
}
diff --git a/src/apps/mplayerc/StatusLabel.h b/src/apps/mplayerc/StatusLabel.h
index 4de3714f7..15e77e117 100644
--- a/src/apps/mplayerc/StatusLabel.h
+++ b/src/apps/mplayerc/StatusLabel.h
@@ -37,8 +37,7 @@ public:
CStatusLabel(bool fRightAlign, bool fAddEllipses);
virtual ~CStatusLabel();
- CFont& GetFont()
- {
+ CFont& GetFont() {
return m_font;
}
diff --git a/src/apps/mplayerc/SubtitleDlDlg.cpp b/src/apps/mplayerc/SubtitleDlDlg.cpp
index 115951cd8..8f63b8296 100644
--- a/src/apps/mplayerc/SubtitleDlDlg.cpp
+++ b/src/apps/mplayerc/SubtitleDlDlg.cpp
@@ -101,8 +101,7 @@ BOOL CSubtitleDlDlg::OnInitDialog()
int i = 0;
POSITION pos = m_movies.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
isdb_movie& m = m_movies.GetNext(pos);
CStringA titlesA = Implode(m.titles, '|');
@@ -110,8 +109,7 @@ BOOL CSubtitleDlDlg::OnInitDialog()
CString titles = UTF8To16(titlesA);
POSITION pos2 = m.subs.GetHeadPosition();
- while(pos2)
- {
+ while(pos2) {
isdb_subtitle& s = m.subs.GetNext(pos2);
CString name = UTF8To16(s.name);
CString language = s.language;
@@ -138,8 +136,9 @@ BOOL CSubtitleDlDlg::OnInitDialog()
void CSubtitleDlDlg::OnOK()
{
for(int i = 0; i < m_list.GetItemCount(); i++)
- if(GetChecked(i))
+ if(GetChecked(i)) {
m_selsubs.AddTail(*(isdb_subtitle*)m_list.GetItemData(i));
+ }
m_fReplaceSubs = IsDlgButtonChecked(IDC_CHECK1) == BST_CHECKED;
@@ -150,12 +149,10 @@ void CSubtitleDlDlg::OnNMClickList1(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)pNMHDR;
- if(lpnmlv->iItem >= 0)
- {
+ if(lpnmlv->iItem >= 0) {
CRect r;
m_list.GetItemRect(lpnmlv->iItem, r, LVIR_ICON);
- if(r.PtInRect(lpnmlv->ptAction))
- {
+ if(r.PtInRect(lpnmlv->ptAction)) {
SetChecked(lpnmlv->iItem, (GetChecked(lpnmlv->iItem)&1) == 0 ? 1 : 0);
}
}
@@ -166,8 +163,9 @@ void CSubtitleDlDlg::OnNMClickList1(NMHDR *pNMHDR, LRESULT *pResult)
void CSubtitleDlDlg::OnUpdateOk(CCmdUI* pCmdUI)
{
bool fEnable = false;
- for(int i = 0; !fEnable && i < m_list.GetItemCount(); i++)
+ for(int i = 0; !fEnable && i < m_list.GetItemCount(); i++) {
fEnable = !!GetChecked(i);
+ }
pCmdUI->Enable(fEnable);
}
diff --git a/src/apps/mplayerc/SubtitleDlDlg.h b/src/apps/mplayerc/SubtitleDlDlg.h
index 606111d52..075bb8985 100644
--- a/src/apps/mplayerc/SubtitleDlDlg.h
+++ b/src/apps/mplayerc/SubtitleDlDlg.h
@@ -31,7 +31,7 @@
class CSubtitleDlDlg : public CResizableDialog
{
-// DECLARE_DYNAMIC(CSubtitleDlDlg)
+ // DECLARE_DYNAMIC(CSubtitleDlDlg)
private:
CList<isdb_movie> m_movies;
@@ -49,7 +49,7 @@ public:
bool m_fReplaceSubs;
CList<isdb_subtitle> m_selsubs;
-// Dialog Data
+ // Dialog Data
enum { IDD = IDD_SUBTITLEDL_DLG };
CListCtrl m_list;
diff --git a/src/apps/mplayerc/TextPassThruFilter.cpp b/src/apps/mplayerc/TextPassThruFilter.cpp
index a334392d3..b9ef84e86 100644
--- a/src/apps/mplayerc/TextPassThruFilter.cpp
+++ b/src/apps/mplayerc/TextPassThruFilter.cpp
@@ -41,22 +41,20 @@ class CTextPassThruInputPin : public CSubtitleInputPin
CComPtr<ISubStream> m_pSubStreamOld;
protected:
- void AddSubStream(ISubStream* pSubStream)
- {
- if(m_pSubStreamOld)
- {
- if(pSubStream) m_pTPTFilter->m_pMainFrame->ReplaceSubtitle(m_pSubStreamOld, pSubStream);
+ void AddSubStream(ISubStream* pSubStream) {
+ if(m_pSubStreamOld) {
+ if(pSubStream) {
+ m_pTPTFilter->m_pMainFrame->ReplaceSubtitle(m_pSubStreamOld, pSubStream);
+ }
m_pSubStreamOld = NULL;
}
}
- void RemoveSubStream(ISubStream* pSubStream)
- {
+ void RemoveSubStream(ISubStream* pSubStream) {
m_pSubStreamOld = pSubStream;
}
- void InvalidateSubtitle(REFERENCE_TIME rtStart, ISubStream* pSubStream)
- {
+ void InvalidateSubtitle(REFERENCE_TIME rtStart, ISubStream* pSubStream) {
m_pTPTFilter->m_pMainFrame->InvalidateSubtitle((DWORD_PTR)pSubStream, rtStart);
}
@@ -85,8 +83,7 @@ public:
HRESULT CheckMediaType(const CMediaType* mtOut);
HRESULT DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties);
HRESULT GetMediaType(int iPosition, CMediaType* pmt);
- STDMETHODIMP Notify(IBaseFilter* pSender, Quality q)
- {
+ STDMETHODIMP Notify(IBaseFilter* pSender, Quality q) {
return S_OK;
}
};
@@ -102,42 +99,54 @@ CTextPassThruInputPin::CTextPassThruInputPin(CTextPassThruFilter* pTPTFilter, CC
STDMETHODIMP CTextPassThruInputPin::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
{
HRESULT hr = __super::NewSegment(tStart, tStop, dRate);
- if(FAILED(hr)) return hr;
+ 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;
+ if(FAILED(hr)) {
+ return hr;
+ }
return m_pTPTFilter->m_pOutput->Deliver(pSample);
}
STDMETHODIMP CTextPassThruInputPin::EndOfStream()
{
HRESULT hr = __super::EndOfStream();
- if(FAILED(hr)) return hr;
+ if(FAILED(hr)) {
+ return hr;
+ }
return m_pTPTFilter->m_pOutput->DeliverEndOfStream();
}
STDMETHODIMP CTextPassThruInputPin::BeginFlush()
{
HRESULT hr = __super::BeginFlush();
- if(FAILED(hr)) return hr;
+ if(FAILED(hr)) {
+ return hr;
+ }
return m_pTPTFilter->m_pOutput->DeliverBeginFlush();
}
STDMETHODIMP CTextPassThruInputPin::EndFlush()
{
HRESULT hr = __super::EndFlush();
- if(FAILED(hr)) return hr;
+ 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;
+ if(FAILED(hr) || !m_pTPTFilter->m_pOutput->IsConnected()) {
+ return hr;
+ }
return m_pTPTFilter->ReconnectPin(m_pTPTFilter->m_pOutput, &m_mt);
}
@@ -159,19 +168,23 @@ HRESULT CTextPassThruOutputPin::CheckMediaType(const CMediaType* mtOut)
HRESULT CTextPassThruOutputPin::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties)
{
- if(m_pTPTFilter->m_pInput->IsConnected() == FALSE)
+ if(m_pTPTFilter->m_pInput->IsConnected() == FALSE) {
return E_UNEXPECTED;
+ }
CComPtr<IMemAllocator> pAllocatorIn;
m_pTPTFilter->m_pInput->GetAllocator(&pAllocatorIn);
- if(!pAllocatorIn) return E_UNEXPECTED;
+ if(!pAllocatorIn) {
+ return E_UNEXPECTED;
+ }
pAllocatorIn->GetProperties(pProperties);
HRESULT hr;
ALLOCATOR_PROPERTIES Actual;
- if(FAILED(hr = pAllocator->SetProperties(pProperties, &Actual)))
+ if(FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
return hr;
+ }
return(pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer
? E_FAIL
@@ -180,11 +193,16 @@ HRESULT CTextPassThruOutputPin::DecideBufferSize(IMemAllocator* pAllocator, ALLO
HRESULT CTextPassThruOutputPin::GetMediaType(int iPosition, CMediaType* pmt)
{
- if(m_pTPTFilter->m_pInput->IsConnected() == FALSE)
+ 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);
@@ -214,10 +232,8 @@ CTextPassThruFilter::~CTextPassThruFilter()
STDMETHODIMP CTextPassThruFilter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- if(m_pInput && riid == __uuidof(ISubStream))
- {
- if(CComPtr<ISubStream> pSubStream = m_pInput->GetSubStream())
- {
+ if(m_pInput && riid == __uuidof(ISubStream)) {
+ if(CComPtr<ISubStream> pSubStream = m_pInput->GetSubStream()) {
*ppv = pSubStream.Detach();
return S_OK;
}
@@ -233,7 +249,10 @@ int CTextPassThruFilter::GetPinCount()
CBasePin* CTextPassThruFilter::GetPin(int n)
{
- 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;
}
diff --git a/src/apps/mplayerc/TunerScanDlg.cpp b/src/apps/mplayerc/TunerScanDlg.cpp
index a70a9ca91..24c19617c 100644
--- a/src/apps/mplayerc/TunerScanDlg.cpp
+++ b/src/apps/mplayerc/TunerScanDlg.cpp
@@ -29,8 +29,7 @@
#include "TunerScanDlg.h"
#include "DVBChannel.h"
-enum TSC_COLUMN
-{
+enum TSC_COLUMN {
TSCC_NUMBER,
TSCC_NAME,
TSCC_FREQUENCY,
@@ -119,8 +118,7 @@ void CTunerScanDlg::OnBnClickedSave()
AppSettings& s = AfxGetAppSettings();
s.m_DVBChannels.RemoveAll();
- for (int i=0; i <m_ChannelList.GetItemCount(); i++)
- {
+ for (int i=0; i <m_ChannelList.GetItemCount(); i++) {
CDVBChannel Channel;
Channel.FromString (m_ChannelList.GetItemText (i, TSCC_CHANNEL));
Channel.SetPrefNumber(i);
@@ -132,8 +130,7 @@ void CTunerScanDlg::OnBnClickedSave()
void CTunerScanDlg::OnBnClickedStart()
{
- if (!m_bInProgress)
- {
+ if (!m_bInProgress) {
UpdateData(true);
CAutoPtr<TunerScanData> pTSD (DNew TunerScanData);
pTSD->Hwnd = m_hWnd;
@@ -147,15 +144,16 @@ void CTunerScanDlg::OnBnClickedStart()
((CMainFrame*)AfxGetMainWnd())->StartTunerScan (pTSD);
SetProgress (true);
- }
- else
+ } else {
((CMainFrame*)AfxGetMainWnd())->StopTunerScan();
+ }
}
void CTunerScanDlg::OnBnClickedCancel()
{
- if (m_bInProgress)
+ if (m_bInProgress) {
((CMainFrame*)AfxGetMainWnd())->StopTunerScan();
+ }
OnCancel();
}
@@ -194,20 +192,18 @@ LRESULT CTunerScanDlg::OnNewChannel(WPARAM wParam, LPARAM lParam)
int nChannelNumber;
Channel.FromString ((LPCTSTR) lParam);
- if (!m_bIgnoreEncryptedChannels || !Channel.IsEncrypted())
- {
- if (Channel.GetOriginNumber() != 0) // LCN is available
- {
+ if (!m_bIgnoreEncryptedChannels || !Channel.IsEncrypted()) {
+ 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 (m_ChannelList.GetItemData(nItem) > nChannelNumber)
+ for (nItem=0; nItem<m_ChannelList.GetItemCount(); nItem++) {
+ if (m_ChannelList.GetItemData(nItem) > nChannelNumber) {
break;
+ }
}
- }
- else
+ } else {
nChannelNumber = nItem = m_ChannelList.GetItemCount();
+ }
strTemp.Format(_T("%d"), nChannelNumber);
nItem = m_ChannelList.InsertItem (nItem, strTemp);
@@ -231,13 +227,10 @@ LRESULT CTunerScanDlg::OnNewChannel(WPARAM wParam, LPARAM lParam)
void CTunerScanDlg::SetProgress (bool bState)
{
- if (bState)
- {
+ if (bState) {
m_btnStart.SetWindowTextW(_T("Stop"));
m_btnSave.EnableWindow(FALSE);
- }
- else
- {
+ } else {
m_btnStart.SetWindowTextW(_T("Start"));
m_Progress.SetPos (0);
m_btnSave.EnableWindow(TRUE);
diff --git a/src/apps/mplayerc/TunerScanDlg.h b/src/apps/mplayerc/TunerScanDlg.h
index ac00b0deb..106a2f4c5 100644
--- a/src/apps/mplayerc/TunerScanDlg.h
+++ b/src/apps/mplayerc/TunerScanDlg.h
@@ -35,7 +35,7 @@ public:
CTunerScanDlg(CWnd* pParent = NULL); // standard constructor
virtual ~CTunerScanDlg();
-// Dialog Data
+ // Dialog Data
enum { IDD = IDD_TUNER_SCAN };
protected:
diff --git a/src/apps/mplayerc/VMROSD.cpp b/src/apps/mplayerc/VMROSD.cpp
index 5d803a3f7..8339dc57a 100644
--- a/src/apps/mplayerc/VMROSD.cpp
+++ b/src/apps/mplayerc/VMROSD.cpp
@@ -66,10 +66,8 @@ CVMROSD::~CVMROSD(void)
void CVMROSD::OnSize(UINT nType, int cx, int cy)
{
- if (m_pWnd && (m_pVMB || m_pMFVMB))
- {
- if (m_bSeekBarVisible)
- {
+ if (m_pWnd && (m_pVMB || m_pMFVMB)) {
+ if (m_bSeekBarVisible) {
m_bCursorMoving = false;
m_bSeekBarVisible = false;
Invalidate();
@@ -90,8 +88,7 @@ void CVMROSD::UpdateBitmap()
m_MemDC.DeleteDC();
memset(&m_BitmapInfo, 0, sizeof(m_BitmapInfo));
- if (m_MemDC.CreateCompatibleDC (&dc))
- {
+ if (m_MemDC.CreateCompatibleDC (&dc)) {
BITMAPINFO bmi = {0};
HBITMAP hbmpRender;
@@ -106,11 +103,9 @@ void CVMROSD::UpdateBitmap()
hbmpRender = CreateDIBSection( m_MemDC, &bmi, DIB_RGB_COLORS, NULL, NULL, NULL );
m_MemDC.SelectObject (hbmpRender);
- if (::GetObject(hbmpRender, sizeof(BITMAP), &m_BitmapInfo) != 0)
- {
+ if (::GetObject(hbmpRender, sizeof(BITMAP), &m_BitmapInfo) != 0) {
// Configure the VMR's bitmap structure
- if (m_pVMB)
- {
+ if (m_pVMB) {
ZeroMemory(&m_VMR9AlphaBitmap, sizeof(m_VMR9AlphaBitmap) );
m_VMR9AlphaBitmap.dwFlags = VMRBITMAP_HDC | VMRBITMAP_SRCCOLORKEY;
m_VMR9AlphaBitmap.hdc = m_MemDC;
@@ -121,9 +116,7 @@ void CVMROSD::UpdateBitmap()
m_VMR9AlphaBitmap.rDest.bottom = 1.0;
m_VMR9AlphaBitmap.fAlpha = 1.0;
m_VMR9AlphaBitmap.clrSrcKey = m_Color[OSD_TRANSPARENT];
- }
- else if (m_pMFVMB)
- {
+ } else if (m_pMFVMB) {
ZeroMemory(&m_MFVideoAlphaBitmap, sizeof(m_MFVideoAlphaBitmap) );
m_MFVideoAlphaBitmap.params.dwFlags = MFVideoAlphaBitmap_SrcColorKey;
m_MFVideoAlphaBitmap.params.clrSrcKey = m_Color[OSD_TRANSPARENT];
@@ -137,8 +130,9 @@ void CVMROSD::UpdateBitmap()
m_MemDC.SetBkMode(TRANSPARENT);
}
- if(m_MainFont.GetSafeHandle())
+ if(m_MainFont.GetSafeHandle()) {
m_MemDC.SelectObject(m_MainFont);
+ }
DeleteObject(hbmpRender);
}
@@ -165,15 +159,18 @@ void CVMROSD::Start (CWnd* pWnd, IMFVideoMixerBitmap* pMFVMB)
void CVMROSD::Stop()
{
- if(m_pVMB) m_pVMB.Release();
- if(m_pMFVMB) m_pMFVMB.Release();
+ if(m_pVMB) {
+ m_pVMB.Release();
+ }
+ if(m_pMFVMB) {
+ m_pMFVMB.Release();
+ }
m_pWnd = NULL;
}
void CVMROSD::CalcRect()
{
- if (m_pWnd)
- {
+ if (m_pWnd) {
m_pWnd->GetClientRect(&m_rectWnd);
m_rectSeekBar.left = m_rectWnd.left + 10;
@@ -190,15 +187,17 @@ void CVMROSD::CalcRect()
void CVMROSD::DrawRect(CRect* rect, CBrush* pBrush, CPen* pPen)
{
- if (pPen)
+ if (pPen) {
m_MemDC.SelectObject (pPen);
- else
+ } else {
m_MemDC.SelectStockObject(NULL_PEN);
+ }
- if (pBrush)
+ if (pBrush) {
m_MemDC.SelectObject (pBrush);
- else
+ } else {
m_MemDC.SelectStockObject(HOLLOW_BRUSH);
+ }
m_MemDC.Rectangle (rect);
}
@@ -210,10 +209,11 @@ void CVMROSD::DrawSlider(CRect* rect, __int64 llMin, __int64 llMax, __int64 llPo
m_rectBar.top = rect->top + (rect->Height() - SLIDER_BAR_HEIGHT) / 2;
m_rectBar.bottom = m_rectBar.top + SLIDER_BAR_HEIGHT;
- if (llMax == llMin)
+ if (llMax == llMin) {
m_rectCursor.left = m_rectBar.left;
- else
+ } 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;
@@ -226,29 +226,27 @@ void CVMROSD::DrawSlider(CRect* rect, __int64 llMin, __int64 llMax, __int64 llPo
void CVMROSD::DrawMessage()
{
- if (m_BitmapInfo.bmWidth*m_BitmapInfo.bmHeight*(m_BitmapInfo.bmBitsPixel/8) == 0)
+ if (m_BitmapInfo.bmWidth*m_BitmapInfo.bmHeight*(m_BitmapInfo.bmBitsPixel/8) == 0) {
return;
- if (m_nMessagePos != OSD_NOMESSAGE)
- {
+ }
+ 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;
+ 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))
- {
+ if(rectText.right > (m_rectWnd.right - 20)) {
m_strMessage = _T(" ") + m_strMessage;
uFormat = uFormat|DT_END_ELLIPSIS;
}
@@ -258,18 +256,17 @@ void CVMROSD::DrawMessage()
void CVMROSD::DrawDebug()
{
- if ( !m_debugMessages.IsEmpty() )
- {
+ if ( !m_debugMessages.IsEmpty() ) {
CString msg, tmp;
POSITION pos;
pos = m_debugMessages.GetHeadPosition();
msg.Format(_T("%s"), m_debugMessages.GetNext(pos));
- while(pos)
- {
+ while(pos) {
tmp = m_debugMessages.GetNext(pos);
- if ( !tmp.IsEmpty() )
+ if ( !tmp.IsEmpty() ) {
msg.AppendFormat(_T("\r\n%s"), tmp);
+ }
}
CRect rectText(0,0,0,0);
@@ -291,21 +288,21 @@ void CVMROSD::DrawDebug()
void CVMROSD::Invalidate()
{
CAutoLock Lock(&m_Lock);
- if (m_BitmapInfo.bmWidth*m_BitmapInfo.bmHeight*(m_BitmapInfo.bmBitsPixel/8) == 0)
+ 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);
+ if (m_bSeekBarVisible) {
+ DrawSlider(&m_rectSeekBar, m_llSeekMin, m_llSeekMax, m_llSeekPos);
+ }
DrawMessage();
DrawDebug();
- if (m_pVMB)
- {
+ if (m_pVMB) {
m_VMR9AlphaBitmap.dwFlags &= ~VMRBITMAP_DISABLE;
m_pVMB->SetAlphaBitmap(&m_VMR9AlphaBitmap);
- }
- else if (m_pMFVMB)
- {
+ } else if (m_pMFVMB) {
m_pMFVMB->SetAlphaBitmap (&m_MFVideoAlphaBitmap);
}
}
@@ -316,39 +313,33 @@ void CVMROSD::UpdateSeekBarPos(CPoint point)
m_llSeekPos = max (m_llSeekPos, m_llSeekMin);
m_llSeekPos = min (m_llSeekPos, m_llSeekMax);
- if (m_pWnd)
+ 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)
- {
+ if (m_pVMB || m_pMFVMB) {
+ if (m_bCursorMoving) {
UpdateSeekBarPos(point);
Invalidate();
- }
- else if (!m_bSeekBarVisible && AfxGetAppSettings().IsD3DFullscreen() && m_rectSeekBar.PtInRect(point))
- {
+ } else if (!m_bSeekBarVisible && AfxGetAppSettings().IsD3DFullscreen() && m_rectSeekBar.PtInRect(point)) {
m_bSeekBarVisible = true;
Invalidate();
- }
- else if (m_bSeekBarVisible && !m_rectSeekBar.PtInRect(point))
- {
+ } else if (m_bSeekBarVisible && !m_rectSeekBar.PtInRect(point)) {
m_bSeekBarVisible = false;
// Add new timer for removing any messages
- if (m_pWnd)
- {
+ if (m_pWnd) {
KillTimer(m_pWnd->m_hWnd, (long)this);
SetTimer(m_pWnd->m_hWnd, (long)this, 1000, (TIMERPROC)TimerFunc);
}
Invalidate();
- }
- else
+ } else {
bRet = false;
+ }
}
return bRet;
@@ -357,15 +348,11 @@ bool CVMROSD::OnMouseMove(UINT nFlags, CPoint point)
bool CVMROSD::OnLButtonDown(UINT nFlags, CPoint point)
{
bool bRet = false;
- if (m_pVMB || m_pMFVMB)
- {
- if (m_rectCursor.PtInRect (point))
- {
+ if (m_pVMB || m_pMFVMB) {
+ if (m_rectCursor.PtInRect (point)) {
m_bCursorMoving = true;
bRet = true;
- }
- else if (m_rectSeekBar.PtInRect(point))
- {
+ } else if (m_rectSeekBar.PtInRect(point)) {
bRet = true;
UpdateSeekBarPos(point);
Invalidate();
@@ -379,8 +366,7 @@ bool CVMROSD::OnLButtonUp(UINT nFlags, CPoint point)
{
bool bRet = false;
- if (m_pVMB || m_pMFVMB)
- {
+ if (m_pVMB || m_pMFVMB) {
m_bCursorMoving = false;
bRet = (m_rectCursor.PtInRect (point) || m_rectSeekBar.PtInRect(point));
@@ -413,8 +399,7 @@ void CVMROSD::GetRange(__int64& start, __int64& stop)
void CVMROSD::TimerFunc(HWND hWnd, UINT nMsg, UINT nIDEvent, DWORD dwTime)
{
CVMROSD* pVMROSD = (CVMROSD*) nIDEvent;
- if (pVMROSD)
- {
+ if (pVMROSD) {
pVMROSD->ClearMessage();
}
KillTimer(hWnd, nIDEvent);
@@ -423,61 +408,65 @@ void CVMROSD::TimerFunc(HWND hWnd, UINT nMsg, UINT nIDEvent, DWORD dwTime)
void CVMROSD::ClearMessage()
{
CAutoLock Lock(&m_Lock);
- if (m_bSeekBarVisible)
+ if (m_bSeekBarVisible) {
return;
- if (m_pVMB)
- {
+ }
+ if (m_pVMB) {
DWORD dwBackup = (m_VMR9AlphaBitmap.dwFlags | VMRBITMAP_DISABLE);
m_VMR9AlphaBitmap.dwFlags = VMRBITMAP_DISABLE;
m_nMessagePos = OSD_NOMESSAGE;
m_pVMB->SetAlphaBitmap(&m_VMR9AlphaBitmap);
m_VMR9AlphaBitmap.dwFlags = dwBackup;
- }
- else if (m_pMFVMB)
- {
+ } else if (m_pMFVMB) {
m_pMFVMB->ClearAlphaBitmap();
}
}
void CVMROSD::DisplayMessage (OSD_MESSAGEPOS nPos, LPCTSTR strMsg, int nDuration, int FontSize, CString OSD_Font)
{
- if (m_pVMB || m_pMFVMB)
- {
- if ( nPos != OSD_DEBUG )
- {
+ if (m_pVMB || m_pMFVMB) {
+ if ( nPos != OSD_DEBUG ) {
m_nMessagePos = nPos;
m_strMessage = strMsg;
- }
- else
- {
+ } else {
m_debugMessages.AddTail(strMsg);
- if ( m_debugMessages.GetCount() > 20 )
+ 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 (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())
+ 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)
- {
+ if (m_pWnd) {
KillTimer(m_pWnd->m_hWnd, (long)this);
- if (nDuration != -1) SetTimer(m_pWnd->m_hWnd, (long)this, nDuration, (TIMERPROC)TimerFunc);
+ if (nDuration != -1) {
+ SetTimer(m_pWnd->m_hWnd, (long)this, nDuration, (TIMERPROC)TimerFunc);
+ }
}
Invalidate();
}
diff --git a/src/apps/mplayerc/VMROSD.h b/src/apps/mplayerc/VMROSD.h
index a2f538a8d..802187ce4 100644
--- a/src/apps/mplayerc/VMROSD.h
+++ b/src/apps/mplayerc/VMROSD.h
@@ -28,8 +28,7 @@
#include <evr9.h>
-typedef enum
-{
+typedef enum {
OSD_TRANSPARENT,
OSD_BACKGROUND,
OSD_BORDER,
@@ -40,8 +39,7 @@ typedef enum
OSD_LAST
} OSD_COLORS;
-typedef enum
-{
+typedef enum {
OSD_NOMESSAGE,
OSD_TOPLEFT,
OSD_TOPRIGHT,
diff --git a/src/apps/mplayerc/VolumeCtrl.cpp b/src/apps/mplayerc/VolumeCtrl.cpp
index 3b0a7d293..2a0580522 100644
--- a/src/apps/mplayerc/VolumeCtrl.cpp
+++ b/src/apps/mplayerc/VolumeCtrl.cpp
@@ -39,8 +39,9 @@ CVolumeCtrl::~CVolumeCtrl()
bool CVolumeCtrl::Create(CWnd* pParentWnd)
{
- if(!CSliderCtrl::Create(WS_CHILD|WS_VISIBLE|TBS_NOTICKS|TBS_HORZ, CRect(0,0,0,0), pParentWnd, IDC_SLIDER1))
+ if(!CSliderCtrl::Create(WS_CHILD|WS_VISIBLE|TBS_NOTICKS|TBS_HORZ, CRect(0,0,0,0), pParentWnd, IDC_SLIDER1)) {
return(false);
+ }
SetRange(1, 100);
SetPosInternal(AfxGetAppSettings().nVolume);
@@ -84,57 +85,53 @@ void CVolumeCtrl::OnNMCustomdraw(NMHDR* pNMHDR, LRESULT* pResult)
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;
+ 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;
@@ -147,7 +144,9 @@ void CVolumeCtrl::OnLButtonDown(UINT nFlags, CPoint point)
CRect r;
GetChannelRect(&r);
- if(r.left >= r.right) return;
+ if(r.left >= r.right) {
+ return;
+ }
int start, stop;
GetRange(start, stop);
@@ -155,13 +154,15 @@ void CVolumeCtrl::OnLButtonDown(UINT nFlags, CPoint point)
r.left += 3;
r.right -= 4;
- if(point.x < r.left) SetPos(start);
- else if(point.x >= r.right) SetPos(stop);
- else
- {
+ 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)
+ if(start < stop) {
SetPosInternal(start + ((stop - start) * (point.x - r.left) + (w/2)) / w);
+ }
}
CSliderCtrl::OnLButtonDown(nFlags, point);
@@ -179,8 +180,9 @@ void CVolumeCtrl::HScroll(UINT nSBCode, UINT nPos)
AfxGetAppSettings().nVolume = GetPos();
CFrameWnd* pFrame = GetParentFrame();
- if(pFrame && pFrame != GetParent())
+ if(pFrame && pFrame != GetParent()) {
pFrame->PostMessage(WM_HSCROLL, MAKEWPARAM((short)nPos, nSBCode), (LPARAM)m_hWnd);
+ }
}
BOOL CVolumeCtrl::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
diff --git a/src/apps/mplayerc/WebClientSocket.cpp b/src/apps/mplayerc/WebClientSocket.cpp
index 3a609ccc6..01eff705b 100644
--- a/src/apps/mplayerc/WebClientSocket.cpp
+++ b/src/apps/mplayerc/WebClientSocket.cpp
@@ -42,9 +42,10 @@ CWebClientSocket::~CWebClientSocket()
bool CWebClientSocket::SetCookie(CString name, CString value, __time64_t expire, CString path, CString domain)
{
- if(name.IsEmpty()) return(false);
- if(value.IsEmpty())
- {
+ if(name.IsEmpty()) {
+ return(false);
+ }
+ if(value.IsEmpty()) {
m_cookie.RemoveKey(name);
return true;
}
@@ -54,8 +55,7 @@ bool CWebClientSocket::SetCookie(CString name, CString value, __time64_t expire,
m_cookieattribs[name].path = path;
m_cookieattribs[name].domain = domain;
- if(expire >= 0)
- {
+ if(expire >= 0) {
CTime t(expire);
SYSTEMTIME st;
t.GetAsSystemTime(st);
@@ -84,9 +84,10 @@ void CWebClientSocket::Clear()
void CWebClientSocket::Header()
{
- if(m_cmd.IsEmpty())
- {
- if(m_hdr.IsEmpty()) return;
+ if(m_cmd.IsEmpty()) {
+ if(m_hdr.IsEmpty()) {
+ return;
+ }
CAtlList<CString> lines;
Explode(m_hdr, lines, '\n');
@@ -100,29 +101,26 @@ void CWebClientSocket::Header()
ASSERT(sl.GetCount() == 0);
POSITION pos = lines.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
Explode(lines.GetNext(pos), sl, ':', 2);
- if(sl.GetCount() == 2)
+ if(sl.GetCount() == 2) {
m_hdrlines[sl.GetHead().MakeLower()] = sl.GetTail();
+ }
}
}
// remember new cookies
POSITION pos = m_hdrlines.GetStartPosition();
- while(pos)
- {
+ while(pos) {
CString key, value;
m_hdrlines.GetNextAssoc(pos, key, value);
- if(key == _T("cookie"))
- {
+ if(key == _T("cookie")) {
CAtlList<CString> sl;
Explode(value, sl, ';');
POSITION pos2 = sl.GetHeadPosition();
- while(pos2)
- {
+ while(pos2) {
CAtlList<CString> sl2;
Explode(sl.GetNext(pos2), sl2, '=', 2);
m_cookie[sl2.GetHead()] = sl2.GetCount() == 2 ? sl2.GetTail() : _T("");
@@ -132,24 +130,19 @@ void CWebClientSocket::Header()
// start new session
- if(!m_cookie.Lookup(_T("MPCSESSIONID"), m_sessid))
- {
+ 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
- {
+ } else {
// TODO: load session
}
CStringA reshdr, resbody;
- if(m_cmd == _T("POST"))
- {
+ if(m_cmd == _T("POST")) {
CString str;
- if(m_hdrlines.Lookup(_T("content-length"), str))
- {
+ if(m_hdrlines.Lookup(_T("content-length"), str)) {
int len = _tcstol(str, NULL, 10);
str.Empty();
@@ -158,20 +151,18 @@ void CWebClientSocket::Header()
int timeout = 1000;
- do
- {
- for(; len > 0 && (err = Receive(&c, 1)) > 0; len--)
- {
+ do {
+ for(; len > 0 && (err = Receive(&c, 1)) > 0; len--) {
m_data += c;
- if(c == '\r') continue;
+ if(c == '\r') {
+ continue;
+ }
str += c;
- if(c == '\n' || len == 1)
- {
+ if(c == '\n' || len == 1) {
CAtlList<CString> sl;
Explode(AToT(UrlDecode(TToA(str))), sl, '&'); // FIXME
POSITION pos = sl.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CAtlList<CString> sl2;
Explode(sl.GetNext(pos), sl2, '=', 2);
m_post[sl2.GetHead().MakeLower()] = sl2.GetCount() == 2 ? sl2.GetTail() : _T("");
@@ -180,10 +171,10 @@ void CWebClientSocket::Header()
}
}
- if(err == SOCKET_ERROR)
+ if(err == SOCKET_ERROR) {
Sleep(1);
- }
- while(err == SOCKET_ERROR && GetLastError() == WSAEWOULDBLOCK
+ }
+ } 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
@@ -192,23 +183,20 @@ void CWebClientSocket::Header()
}
}
- if(m_cmd == _T("GET") || m_cmd == _T("HEAD") || m_cmd == _T("POST"))
- {
+ 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())
- {
+ 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)
- {
+ while(pos) {
CAtlList<CString> sl2;
Explode(AToT(UrlDecode(TToA(sl.GetNext(pos)))), sl2, '=', 2);
// Explode(sl.GetNext(pos), sl2, '=', 2);
@@ -221,51 +209,49 @@ void CWebClientSocket::Header()
CString key, value;
POSITION pos;
pos = m_get.GetStartPosition();
- while(pos)
- {
+ while(pos) {
m_get.GetNextAssoc(pos, key, value);
m_request[key] = value;
}
pos = m_post.GetStartPosition();
- while(pos)
- {
+ while(pos) {
m_post.GetNextAssoc(pos, key, value);
m_request[key] = value;
}
pos = m_cookie.GetStartPosition();
- while(pos)
- {
+ while(pos) {
m_cookie.GetNextAssoc(pos, key, value);
m_request[key] = value;
}
}
m_pWebServer->OnRequest(this, reshdr, resbody);
- }
- else
- {
+ } else {
reshdr = "HTTP/1.0 400 Bad Request\r\n";
}
- if(!reshdr.IsEmpty())
- {
+ if(!reshdr.IsEmpty()) {
// cookies
{
POSITION pos = m_cookie.GetStartPosition();
- while(pos)
- {
+ while(pos) {
CString key, value;
m_cookie.GetNextAssoc(pos, key, value);
reshdr += "Set-Cookie: " + key + "=" + value;
POSITION pos2 = m_cookieattribs.GetStartPosition();
- while(pos2)
- {
+ 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;
+ 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";
}
@@ -278,8 +264,7 @@ void CWebClientSocket::Header()
Send(reshdr, reshdr.GetLength());
- if(m_cmd != _T("HEAD") && reshdr.Find("HTTP/1.0 200 OK") == 0 && !resbody.IsEmpty())
- {
+ if(m_cmd != _T("HEAD") && reshdr.Find("HTTP/1.0 200 OK") == 0 && !resbody.IsEmpty()) {
Send(resbody, resbody.GetLength());
}
@@ -298,17 +283,17 @@ void CWebClientSocket::Header()
void CWebClientSocket::OnReceive(int nErrorCode)
{
- if(nErrorCode == 0)
- {
+ if(nErrorCode == 0) {
char c;
- while(Receive(&c, 1) > 0)
- {
- if(c == '\r') continue;
- else m_hdr += 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')
- {
+ if(len >= 2 && m_hdr[len-2] == '\n' && m_hdr[len-1] == '\n') {
Header();
return;
}
@@ -330,40 +315,34 @@ void CWebClientSocket::OnClose(int nErrorCode)
bool CWebClientSocket::OnCommand(CStringA& hdr, CStringA& body, CStringA& mime)
{
CString arg;
- if(m_request.Lookup(_T("wm_command"), 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))
- {
+ 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(arg, _T("%d%c%d%c%d%c%d"), &h, &c, &m, &c, &s, &c, &ms) >= 5)
- {
+ if(_stscanf(arg, _T("%d%c%d%c%d%c%d"), &h, &c, &m, &c, &s, &c, &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)
+ 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))
- {
+ } else if(arg == CMD_SETPOS && m_request.Lookup(_T("percent"), arg)) {
float percent = 0;
- if(_stscanf_s(arg, _T("%f"), &percent) == 1)
+ 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))
- {
+ }
+ } 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, 1), 100);
m_pMainFrame->OnPlayVolume(0);
@@ -372,8 +351,9 @@ bool CWebClientSocket::OnCommand(CStringA& hdr, CStringA& body, CStringA& mime)
}
CString ref;
- if(!m_hdrlines.Lookup(_T("referer"), ref))
+ if(!m_hdrlines.Lookup(_T("referer"), ref)) {
return true;
+ }
hdr =
"HTTP/1.0 302 Found\r\n"
@@ -390,8 +370,7 @@ bool CWebClientSocket::OnIndex(CStringA& hdr, CStringA& body, CStringA& mime)
AppSettings& s = AfxGetAppSettings();
POSITION pos = s.wmcmds.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
wmcmd& wc = s.wmcmds.GetNext(pos);
CStringA str;
str.Format("%d", wc.cmd);
@@ -409,19 +388,18 @@ 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)
+ if(GetDriveType(drive) != DRIVE_NO_ROOT_DIR) {
rootdrives.AddTail(CStringA(drive) + '\\');
+ }
// process GET
CString path;
CFileStatus fs;
- if(m_get.Lookup(_T("path"), path))
- {
+ if(m_get.Lookup(_T("path"), path)) {
path = WToT(UTF8To16(TToA(path)));
- if(CFileGetStatus(path, fs) && !(fs.m_attribute&CFile::directory))
- {
+ 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;
@@ -429,28 +407,26 @@ bool CWebClientSocket::OnBrowser(CStringA& hdr, CStringA& body, CStringA& mime)
cmdln.AddTail(path);
CString focus;
- if(m_get.Lookup(_T("focus"), focus) && !focus.CompareNoCase(_T("no")))
+ if(m_get.Lookup(_T("focus"), focus) && !focus.CompareNoCase(_T("no"))) {
cmdln.AddTail(_T("/nofocus"));
+ }
int len = 0;
POSITION pos = cmdln.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CString& str = cmdln.GetNext(pos);
len += (str.GetLength()+1)*sizeof(TCHAR);
}
CAutoVectorPtr<BYTE> buff;
- if(buff.Allocate(4+len))
- {
+ if(buff.Allocate(4+len)) {
BYTE* p = buff;
*(DWORD*)p = cmdln.GetCount();
p += sizeof(DWORD);
POSITION pos = cmdln.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CString& str = cmdln.GetNext(pos);
len = (str.GetLength()+1)*sizeof(TCHAR);
memcpy(p, (LPCTSTR)str, len);
@@ -468,25 +444,22 @@ bool CWebClientSocket::OnBrowser(CStringA& hdr, CStringA& body, CStringA& mime)
p.RemoveFileSpec();
path = (LPCTSTR)p;
}
- }
- else
- {
+ } else {
path = m_pMainFrame->m_wndPlaylistBar.GetCurFileName();
- if(CFileGetStatus(path, fs) && !(fs.m_attribute&CFile::directory))
- {
+ if(CFileGetStatus(path, fs) && !(fs.m_attribute&CFile::directory)) {
CPath p(path);
p.RemoveFileSpec();
path = (LPCTSTR)p;
}
}
- if(path.Find(_T("://")) >= 0)
+ if(path.Find(_T("://")) >= 0) {
path.Empty();
+ }
if(CFileGetStatus(path, fs) && (fs.m_attribute&CFile::directory)
- || path.Find(_T("\\")) == 0) // FIXME
- {
+ || path.Find(_T("\\")) == 0) { // FIXME
CPath p(path);
p.Canonicalize();
p.MakePretty();
@@ -496,11 +469,9 @@ bool CWebClientSocket::OnBrowser(CStringA& hdr, CStringA& body, CStringA& mime)
CStringA files;
- if(path.IsEmpty())
- {
+ if(path.IsEmpty()) {
POSITION pos = rootdrives.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CStringA& drive = rootdrives.GetNext(pos);
files += "<tr class=\"dir\">\r\n";
@@ -513,13 +484,10 @@ bool CWebClientSocket::OnBrowser(CStringA& hdr, CStringA& body, CStringA& mime)
}
path = "Root";
- }
- else
- {
+ } else {
CString parent;
- if(path.GetLength() > 3)
- {
+ if(path.GetLength() > 3) {
CPath p(path + "..");
p.Canonicalize();
p.AddBackslash();
@@ -537,12 +505,11 @@ bool CWebClientSocket::OnBrowser(CStringA& hdr, CStringA& body, CStringA& mime)
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] == '.')
+ if(hFind != INVALID_HANDLE_VALUE) {
+ do {
+ if(!(fd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) || fd.cFileName[0] == '.') {
continue;
+ }
CString fullpath = path + fd.cFileName;
@@ -553,23 +520,23 @@ bool CWebClientSocket::OnBrowser(CStringA& hdr, CStringA& body, CStringA& mime)
"<td class=\"dirsize\">&nbsp</td>\r\n"
"<td class=\"dirdate\"><nobr>" + CStringA(CTime(fd.ftLastWriteTime).Format(_T("%Y.%m.%d %H:%M"))) + "</nobr></td>";
files += "</tr>\r\n";
- }
- while(FindNextFile(hFind, &fd));
+ } while(FindNextFile(hFind, &fd));
FindClose(hFind);
}
hFind = FindFirstFile(path + "*.*", &fd);
- if(hFind != INVALID_HANDLE_VALUE)
- {
- do
- {
- if(fd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)
+ 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++;
+ if (ext != NULL) {
+ ext++;
+ }
CStringA size;
size.Format("%I64dK", ((UINT64)fd.nFileSizeHigh<<22)|(fd.nFileSizeLow>>10));
@@ -577,18 +544,18 @@ bool CWebClientSocket::OnBrowser(CStringA& hdr, CStringA& body, CStringA& mime)
CString type(_T("&nbsp"));
LoadType(fullpath, type);
- if (ext != NULL)
+ if (ext != NULL) {
files += "<tr class=\"" + UTF8(ext) + "\">\r\n";
- else
+ } 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\"><nobr>" + UTF8(type) + "</nobr></td>"
"<td class=\"filesize\" align=\"right\"><nobr>" + size + "</nobr></td>\r\n"
"<td class=\"filedate\"><nobr>" + CStringA(CTime(fd.ftLastWriteTime).Format(_T("%Y.%m.%d %H:%M"))) + "</nobr></td>";
files += "</tr>\r\n";
- }
- while(FindNextFile(hFind, &fd));
+ } while(FindNextFile(hFind, &fd));
FindClose(hFind);
}
@@ -607,8 +574,7 @@ bool CWebClientSocket::OnControls(CStringA& hdr, CStringA& body, CStringA& mime)
CString path = m_pMainFrame->m_wndPlaylistBar.GetCurFileName();
CString dir;
- if(!path.IsEmpty())
- {
+ if(!path.IsEmpty()) {
CPath p(path);
p.RemoveFileSpec();
dir = (LPCTSTR)p;
@@ -618,20 +584,19 @@ bool CWebClientSocket::OnControls(CStringA& hdr, CStringA& body, CStringA& mime)
CString state;
state.Format(_T("%d"), fs);
CString statestring;
- switch(fs)
- {
- case State_Stopped:
- statestring = ResStr(IDS_CONTROLS_STOPPED);
- break;
- case State_Paused:
- statestring = ResStr(IDS_CONTROLS_PAUSED);
- break;
- case State_Running:
- statestring = ResStr(IDS_CONTROLS_PLAYING);
- break;
- default:
- statestring = _T("n/a");
- break;
+ switch(fs) {
+ case State_Stopped:
+ statestring = ResStr(IDS_CONTROLS_STOPPED);
+ break;
+ case State_Paused:
+ statestring = ResStr(IDS_CONTROLS_PAUSED);
+ break;
+ case State_Running:
+ statestring = ResStr(IDS_CONTROLS_PLAYING);
+ break;
+ default:
+ statestring = _T("n/a");
+ break;
}
int pos = (int)(m_pMainFrame->GetPos()/10000);
@@ -642,8 +607,8 @@ bool CWebClientSocket::OnControls(CStringA& hdr, CStringA& body, CStringA& mime)
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.%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
@@ -693,20 +658,19 @@ bool CWebClientSocket::OnStatus(CStringA& hdr, CStringA& body, CStringA& mime)
CString status;// = m_pMainFrame->GetStatusMessage();
OAFilterState fs = m_pMainFrame->GetMediaState();
- switch (fs)
- {
- case State_Stopped:
- status = ResStr(IDS_CONTROLS_STOPPED);
- break;
- case State_Paused:
- status = ResStr(IDS_CONTROLS_PAUSED);
- break;
- case State_Running:
- status = ResStr(IDS_CONTROLS_PLAYING);
- break;
- default:
- status = _T("n/a");
- break;
+ switch (fs) {
+ case State_Stopped:
+ status = ResStr(IDS_CONTROLS_STOPPED);
+ break;
+ case State_Paused:
+ status = ResStr(IDS_CONTROLS_PAUSED);
+ break;
+ case State_Running:
+ status = ResStr(IDS_CONTROLS_PLAYING);
+ break;
+ default:
+ status = _T("n/a");
+ break;
}
int pos = (int)(m_pMainFrame->GetPos()/10000);
@@ -751,10 +715,8 @@ bool CWebClientSocket::OnSnapShotJpeg(CStringA& hdr, CStringA& body, CStringA& m
BYTE* pData = NULL;
long size = 0;
CAtlArray<BYTE> jpeg;
- if(m_pMainFrame->GetDIB(&pData, size, true))
- {
- if(CJpegEncoderMem().Encode(pData, jpeg))
- {
+ if(m_pMainFrame->GetDIB(&pData, size, true)) {
+ if(CJpegEncoderMem().Encode(pData, jpeg)) {
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"
@@ -775,18 +737,21 @@ bool CWebClientSocket::OnSnapShotJpeg(CStringA& hdr, CStringA& body, CStringA& m
bool CWebClientSocket::OnConvRes(CStringA& hdr, CStringA& body, CStringA& mime)
{
CString id;
- if(!m_get.Lookup(_T("id"), id))
+ if(!m_get.Lookup(_T("id"), id)) {
return false;
+ }
DWORD key = 0;
- if(1 != _stscanf_s(id, _T("%x"), &key) || key == 0)
+ if(1 != _stscanf_s(id, _T("%x"), &key) || key == 0) {
return false;
+ }
CAutoLock cAutoLock(&CDSMResource::m_csResources);
CDSMResource* res = NULL;
- if(!CDSMResource::m_resources.Lookup(key, res) || !res)
+ if(!CDSMResource::m_resources.Lookup(key, res) || !res) {
return false;
+ }
body = CStringA((const char*)res->data.GetData(), res->data.GetCount());
mime = CString(res->mime);
diff --git a/src/apps/mplayerc/WebClientSocket.h b/src/apps/mplayerc/WebClientSocket.h
index 15ab6a4c3..041aa2492 100644
--- a/src/apps/mplayerc/WebClientSocket.h
+++ b/src/apps/mplayerc/WebClientSocket.h
@@ -32,8 +32,7 @@ class CWebClientSocket : public CAsyncSocket
CString m_hdr;
- struct cookie_attribs
- {
+ struct cookie_attribs {
CString path, expire, domain;
};
CAtlStringMap<cookie_attribs> m_cookieattribs;
diff --git a/src/apps/mplayerc/WebServer.cpp b/src/apps/mplayerc/WebServer.cpp
index 3859340ec..aeac3fad8 100644
--- a/src/apps/mplayerc/WebServer.cpp
+++ b/src/apps/mplayerc/WebServer.cpp
@@ -39,8 +39,7 @@ CWebServer::CWebServer(CMainFrame* pMainFrame, int nPort)
: m_pMainFrame(pMainFrame)
, m_nPort(nPort)
{
- if(m_internalpages.IsEmpty())
- {
+ if(m_internalpages.IsEmpty()) {
m_internalpages[_T("/")] = &CWebClientSocket::OnIndex;
m_internalpages[_T("/index.html")] = &CWebClientSocket::OnIndex;
m_internalpages[_T("/browser.html")] = &CWebClientSocket::OnBrowser;
@@ -53,8 +52,7 @@ CWebServer::CWebServer(CMainFrame* pMainFrame, int nPort)
m_internalpages[_T("/convres.html")] = &CWebClientSocket::OnConvRes;
}
- if(m_downloads.IsEmpty())
- {
+ if(m_downloads.IsEmpty()) {
m_downloads[_T("/default.css")] = IDF_DEFAULT_CSS;
m_downloads[_T("/vbg.gif")] = IDF_VBR_GIF;
m_downloads[_T("/vbs.gif")] = IDF_VBS_GIF;
@@ -92,18 +90,17 @@ CWebServer::CWebServer(CMainFrame* pMainFrame, int nPort)
CRegKey key;
CString str(_T("MIME\\Database\\Content Type"));
- if(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, str, KEY_READ))
- {
+ 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))
- {
+ 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))
+ && ERROR_SUCCESS == mime.QueryStringValue(_T("Extension"), ext, &len)) {
m_mimes[CStringA(ext).MakeLower()] = CStringA(buff).MakeLower();
+ }
}
}
@@ -124,20 +121,26 @@ CWebServer::CWebServer(CMainFrame* pMainFrame, int nPort)
WebRoot.Replace('/', '\\');
WebRoot.Trim();
CPath p(WebRoot);
- if(WebRoot.Find(_T(":\\")) < 0 && WebRoot.Find(_T("\\\\")) < 0) m_webroot.Append(WebRoot);
- else m_webroot = p;
+ 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();
+ if(!m_webroot.IsDirectory()) {
+ m_webroot = CPath();
+ }
CAtlList<CString> sl;
Explode(AfxGetAppSettings().strWebServerCGI, sl, ';');
POSITION pos = sl.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CAtlList<CString> sl2;
CString ext = Explode(sl.GetNext(pos), sl2, '=', 2);
- if(sl2.GetCount() < 2) continue;
+ if(sl2.GetCount() < 2) {
+ continue;
+ }
m_cgi[ext] = sl2.GetTail();
}
@@ -147,11 +150,11 @@ CWebServer::CWebServer(CMainFrame* pMainFrame, int nPort)
CWebServer::~CWebServer()
{
- if(m_hThread != NULL)
- {
+ if(m_hThread != NULL) {
PostThreadMessage(m_ThreadId, WM_QUIT, 0, 0);
- if (WaitForSingleObject(m_hThread, 10000) == WAIT_TIMEOUT)
+ if (WaitForSingleObject(m_hThread, 10000) == WAIT_TIMEOUT) {
TerminateThread (m_hThread, 0xDEAD);
+ }
EXECUTE_ASSERT(CloseHandle(m_hThread));
}
}
@@ -163,14 +166,14 @@ DWORD WINAPI CWebServer::StaticThreadProc(LPVOID lpParam)
DWORD CWebServer::ThreadProc()
{
- if(!AfxSocketInit(NULL))
+ if(!AfxSocketInit(NULL)) {
return (DWORD)-1;
+ }
CWebServerSocket s(this, m_nPort);
MSG msg;
- while((int)GetMessage(&msg, NULL, 0, 0) > 0)
- {
+ while((int)GetMessage(&msg, NULL, 0, 0) > 0) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
@@ -180,8 +183,7 @@ DWORD CWebServer::ThreadProc()
static void PutFileContents(LPCTSTR fn, const CStringA& data)
{
- if(FILE* f = _tfopen(fn, _T("wb")))
- {
+ if(FILE* f = _tfopen(fn, _T("wb"))) {
fwrite((LPCSTR)data, 1, data.GetLength(), f);
fclose(f);
}
@@ -190,27 +192,36 @@ static void PutFileContents(LPCTSTR fn, const CStringA& data)
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_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_404, data, RT_HTML)) PutFileContents(dir + _T("404.html"), data);
- if(LoadResource(IDR_HTML_PLAYER, data, RT_HTML)) PutFileContents(dir + _T("player.html"), data);
+ if(LoadResource(IDR_HTML_INDEX, data, RT_HTML)) {
+ PutFileContents(dir + _T("index.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_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)
- {
+ while(pos) {
CString fn;
UINT id;
m_downloads.GetNextAssoc(pos, fn, id);
- if(LoadResource(id, data, _T("FILE")))
+ if(LoadResource(id, data, _T("FILE"))) {
PutFileContents(dir + fn, data);
+ }
}
}
bool CWebServer::ToLocalPath(CString& path, CString& redir)
{
- if(!path.IsEmpty() && m_webroot.IsDirectory())
- {
+ if(!path.IsEmpty() && m_webroot.IsDirectory()) {
CString str = path;
str.Replace('/', '\\');
str.TrimLeft('\\');
@@ -219,29 +230,27 @@ bool CWebServer::ToLocalPath(CString& path, CString& redir)
p.Combine(m_webroot, str);
p.Canonicalize();
- if(p.IsDirectory())
- {
+ if(p.IsDirectory()) {
CAtlList<CString> sl;
Explode(AfxGetAppSettings().strWebDefIndex, sl, ';');
POSITION pos = sl.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
str = sl.GetNext(pos);
CPath p2 = p;
p2.Append(str);
- if(p2.FileExists())
- {
+ if(p2.FileExists()) {
p = p2;
redir = path;
- if(redir.GetAt(redir.GetLength()-1) != '/') redir += '/';
+ if(redir.GetAt(redir.GetLength()-1) != '/') {
+ redir += '/';
+ }
redir += str;
break;
}
}
}
- if(_tcslen(p) > _tcslen(m_webroot) && p.FileExists())
- {
+ if(_tcslen(p) > _tcslen(m_webroot) && p.FileExists()) {
path = (LPCTSTR)p;
return true;
}
@@ -253,10 +262,8 @@ bool CWebServer::ToLocalPath(CString& path, CString& redir)
bool CWebServer::LoadPage(UINT resid, CStringA& str, CString path)
{
CString redir;
- if(ToLocalPath(path, redir))
- {
- if(FILE* f = _tfopen(path, _T("rb")))
- {
+ if(ToLocalPath(path, redir)) {
+ if(FILE* f = _tfopen(path, _T("rb"))) {
fseek(f, 0, 2);
char* buff = str.GetBufferSetLength(ftell(f));
fseek(f, 0, 0);
@@ -272,12 +279,10 @@ bool CWebServer::LoadPage(UINT resid, CStringA& str, CString path)
void CWebServer::OnAccept(CWebServerSocket* pServer)
{
CAutoPtr<CWebClientSocket> p(DNew CWebClientSocket(this, m_pMainFrame));
- if(pServer->Accept(*p))
- {
+ if(pServer->Accept(*p)) {
CString name;
UINT port;
- if(AfxGetAppSettings().fWebServerLocalhostOnly && p->GetPeerName(name, port) && name != _T("127.0.0.1"))
- {
+ if(AfxGetAppSettings().fWebServerLocalhostOnly && p->GetPeerName(name, port) && name != _T("127.0.0.1")) {
p->Close();
return;
}
@@ -289,11 +294,9 @@ void CWebServer::OnAccept(CWebServerSocket* pServer)
void CWebServer::OnClose(CWebClientSocket* pClient)
{
POSITION pos = m_clients.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
POSITION cur = pos;
- if(m_clients.GetNext(pos) == pClient)
- {
+ if(m_clients.GetNext(pos) == pClient) {
m_clients.RemoveAt(cur);
break;
}
@@ -305,38 +308,37 @@ void CWebServer::OnRequest(CWebClientSocket* pClient, CStringA& hdr, CStringA& b
CPath p(pClient->m_path);
CStringA ext = p.GetExtension().MakeLower();
CStringA mime;
- if(ext.IsEmpty()) mime = "text/html";
- else m_mimes.Lookup(ext, 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())
- {
+ if(!fHandled && m_webroot.IsDirectory()) {
CStringA tmphdr;
fHandled = fCGI = CallCGI(pClient, tmphdr, body, mime);
- if(fHandled)
- {
+ if(fHandled) {
tmphdr.Replace("\r\n", "\n");
CAtlList<CStringA> hdrlines;
ExplodeMin(tmphdr, hdrlines, '\n');
POSITION pos = hdrlines.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
POSITION cur = pos;
CAtlList<CStringA> sl;
CStringA key = Explode(hdrlines.GetNext(pos), sl, ':', 2);
- if(sl.GetCount() < 2) continue;
+ if(sl.GetCount() < 2) {
+ continue;
+ }
key.Trim().MakeLower();
- if(key == "content-type")
- {
+ if(key == "content-type") {
mime = sl.GetTail().Trim();
hdrlines.RemoveAt(cur);
- }
- else if(key == "content-length")
- {
+ } else if(key == "content-length") {
hdrlines.RemoveAt(cur);
}
}
@@ -347,15 +349,17 @@ void CWebServer::OnRequest(CWebClientSocket* pClient, CStringA& hdr, CStringA& b
}
RequestHandler rh = NULL;
- if(!fHandled && m_internalpages.Lookup(pClient->m_path, rh) && (pClient->*rh)(hdr, body, mime))
- {
- if(mime.IsEmpty()) mime = "text/html";
+ 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 = '/';
+ || pClient->m_post.Lookup(_T("redir"), redir)) {
+ if(redir.IsEmpty()) {
+ redir = '/';
+ }
hdr =
"HTTP/1.0 302 Found\r\n"
@@ -366,44 +370,40 @@ void CWebServer::OnRequest(CWebClientSocket* pClient, CStringA& hdr, CStringA& b
fHandled = true;
}
- if(!fHandled && m_webroot.IsDirectory())
- {
+ 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";
+ 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)
- {
+ 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)
- {
+ 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)
- {
+ if(AfxGetAppSettings().fWebServerPrintDebugInfo) {
debug += "<hr>\r\n";
CString key, value;
POSITION pos;
pos = pClient->m_hdrlines.GetStartPosition();
- while(pos)
- {
+ while(pos) {
pClient->m_hdrlines.GetNextAssoc(pos, key, value);
debug += "HEADER[" + key + "] = " + value + "<br>\r\n";
}
@@ -411,26 +411,22 @@ void CWebServer::OnRequest(CWebClientSocket* pClient, CStringA& hdr, CStringA& b
debug += "path: " + pClient->m_path + "<br>\r\n";
debug += "ver: " + pClient->m_ver + "<br>\r\n";
pos = pClient->m_get.GetStartPosition();
- while(pos)
- {
+ while(pos) {
pClient->m_get.GetNextAssoc(pos, key, value);
debug += "GET[" + key + "] = " + value + "<br>\r\n";
}
pos = pClient->m_post.GetStartPosition();
- while(pos)
- {
+ while(pos) {
pClient->m_post.GetNextAssoc(pos, key, value);
debug += "POST[" + key + "] = " + value + "<br>\r\n";
}
pos = pClient->m_cookie.GetStartPosition();
- while(pos)
- {
+ while(pos) {
pClient->m_cookie.GetNextAssoc(pos, key, value);
debug += "COOKIE[" + key + "] = " + value + "<br>\r\n";
}
pos = pClient->m_request.GetStartPosition();
- while(pos)
- {
+ while(pos) {
pClient->m_request.GetNextAssoc(pos, key, value);
debug += "REQUEST[" + key + "] = " + value + "<br>\r\n";
}
@@ -450,31 +446,33 @@ void CWebServer::OnRequest(CWebClientSocket* pClient, CStringA& hdr, CStringA& b
// gzip
if(AfxGetAppSettings().fWebServerUseCompression && hdr.Find("Content-Encoding:") < 0)
- do
- {
+ 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;
+ if(!sl.Find(_T("gzip"))) {
+ break;
+ }
CHAR path[_MAX_PATH], fn[_MAX_PATH];
- if(!GetTempPathA(_MAX_PATH, path) || !GetTempFileNameA(path, "mpc_gz", 0, fn))
+ 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);
+ if(!gf || gzwrite(gf, (LPVOID)(LPCSTR)body, body.GetLength()) != body.GetLength()) {
+ if(gf) {
+ gzclose(gf);
+ }
DeleteFileA(fn);
break;
}
gzclose(gf);
FILE* f = fopen(fn, "rb");
- if(!f)
- {
+ if(!f) {
DeleteFileA(fn);
break;
}
@@ -487,8 +485,7 @@ void CWebServer::OnRequest(CWebClientSocket* pClient, CStringA& hdr, CStringA& b
DeleteFileA(fn);
hdr += "Content-Encoding: gzip\r\n";
- }
- while(0);
+ } while(0);
CStringA content;
content.Format(
@@ -501,22 +498,26 @@ void CWebServer::OnRequest(CWebClientSocket* pClient, CStringA& hdr, CStringA& b
static DWORD WINAPI KillCGI(LPVOID lParam)
{
HANDLE hProcess = (HANDLE)lParam;
- if(WaitForSingleObject(hProcess, 30000) == WAIT_TIMEOUT)
+ 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;
+ 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())
+ if(!m_cgi.Lookup(ext, cgi) || !CPath(cgi).FileExists()) {
return false;
+ }
HANDLE hProcess = GetCurrentProcess();
HANDLE hChildStdinRd, hChildStdinWr, hChildStdinWrDup = NULL;
@@ -527,15 +528,13 @@ bool CWebServer::CallCGI(CWebClientSocket* pClient, CStringA& hdr, CStringA& bod
saAttr.nLength = sizeof(saAttr);
saAttr.bInheritHandle = TRUE;
- if(CreatePipe(&hChildStdoutRd, &hChildStdoutWr, &saAttr, 0))
- {
+ if(CreatePipe(&hChildStdoutRd, &hChildStdoutWr, &saAttr, 0)) {
BOOL fSuccess = DuplicateHandle(hProcess, hChildStdoutRd, hProcess, &hChildStdoutRdDup, 0, FALSE, DUPLICATE_SAME_ACCESS);
UNUSED_ALWAYS(fSuccess);
CloseHandle(hChildStdoutRd);
}
- if(CreatePipe(&hChildStdinRd, &hChildStdinWr, &saAttr, 0))
- {
+ if(CreatePipe(&hChildStdinRd, &hChildStdinWr, &saAttr, 0)) {
BOOL fSuccess = DuplicateHandle(hProcess, hChildStdinWr, hProcess, &hChildStdinWrDup, 0, FALSE, DUPLICATE_SAME_ACCESS);
UNUSED_ALWAYS(fSuccess);
CloseHandle(hChildStdinWr);
@@ -556,14 +555,14 @@ bool CWebServer::CallCGI(CWebClientSocket* pClient, CStringA& hdr, CStringA& bod
CStringA envstr;
LPVOID lpvEnv = GetEnvironmentStrings();
- if(lpvEnv)
- {
+ if(lpvEnv) {
CString str;
CAtlList<CString> env;
for(LPTSTR lpszVariable = (LPTSTR)lpvEnv; *lpszVariable; lpszVariable += _tcslen(lpszVariable)+1)
- if(lpszVariable != (LPTSTR)lpvEnv)
+ if(lpszVariable != (LPTSTR)lpvEnv) {
env.AddTail(lpszVariable);
+ }
env.AddTail(_T("GATEWAY_INTERFACE=CGI/1.1"));
env.AddTail(_T("SERVER_SOFTWARE=Media Player Classic/6.4.x.y"));
@@ -574,14 +573,15 @@ bool CWebServer::CallCGI(CWebClientSocket* pClient, CStringA& hdr, CStringA& bod
env.AddTail(_T("SCRIPT_NAME=") + redir);
env.AddTail(_T("QUERY_STRING=") + pClient->m_query);
- if(pClient->m_hdrlines.Lookup(_T("content-type"), str))
+ if(pClient->m_hdrlines.Lookup(_T("content-type"), str)) {
env.AddTail(_T("CONTENT_TYPE=") + str);
- if(pClient->m_hdrlines.Lookup(_T("content-length"), str))
+ }
+ if(pClient->m_hdrlines.Lookup(_T("content-length"), str)) {
env.AddTail(_T("CONTENT_LENGTH=") + str);
+ }
POSITION pos = pClient->m_hdrlines.GetStartPosition();
- while(pos)
- {
+ while(pos) {
CString key = pClient->m_hdrlines.GetKeyAt(pos);
CString value = pClient->m_hdrlines.GetNextValue(pos);
key.Replace(_T("-"), _T("_"));
@@ -592,16 +592,14 @@ bool CWebServer::CallCGI(CWebClientSocket* pClient, CStringA& hdr, CStringA& bod
CString name;
UINT port;
- if(pClient->GetPeerName(name, 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))
- {
+ if(pClient->GetSockName(name, port)) {
str.Format(_T("%d"), port);
env.AddTail(_T("SERVER_NAME=")+name);
env.AddTail(_T("SERVER_PORT=")+str);
@@ -622,8 +620,7 @@ bool CWebServer::CallCGI(CWebClientSocket* pClient, CStringA& hdr, CStringA& bod
if(CreateProcess(
NULL, cmdln, NULL, NULL, TRUE, 0,
envstr.GetLength() ? (LPVOID)(LPCSTR)envstr : NULL,
- dir, &siStartInfo, &piProcInfo))
- {
+ dir, &siStartInfo, &piProcInfo)) {
DWORD ThreadId;
CreateThread(NULL, 0, KillCGI, (LPVOID)piProcInfo.hProcess, 0, &ThreadId);
@@ -632,8 +629,9 @@ bool CWebServer::CallCGI(CWebClientSocket* pClient, CStringA& hdr, CStringA& bod
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))
+ if(!WriteFile(hChildStdinWrDup, (LPCSTR)pClient->m_data + i, min(len - i, BUFFSIZE), &dwWritten, NULL)) {
break;
+ }
CloseHandle(hChildStdinWrDup);
CloseHandle(hChildStdoutWr);
@@ -641,15 +639,13 @@ bool CWebServer::CallCGI(CWebClientSocket* pClient, CStringA& hdr, CStringA& bod
body.Empty();
CStringA buff;
- while(i == len && ReadFile(hChildStdoutRdDup, buff.GetBuffer(BUFFSIZE), BUFFSIZE, &dwRead, NULL) && dwRead)
- {
+ 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)
- {
+ if(hdrend >= 0) {
hdr = body.Left(hdrend+2);
body = body.Mid(hdrend+4);
}
@@ -659,9 +655,7 @@ bool CWebServer::CallCGI(CWebClientSocket* pClient, CStringA& hdr, CStringA& bod
CloseHandle(piProcInfo.hProcess);
CloseHandle(piProcInfo.hThread);
- }
- else
- {
+ } else {
body = _T("CGI Error");
}
diff --git a/src/apps/mplayerc/WebServerSocket.cpp b/src/apps/mplayerc/WebServerSocket.cpp
index 726f1681d..4810aa6c5 100644
--- a/src/apps/mplayerc/WebServerSocket.cpp
+++ b/src/apps/mplayerc/WebServerSocket.cpp
@@ -38,8 +38,9 @@ CWebServerSocket::~CWebServerSocket()
void CWebServerSocket::OnAccept(int nErrorCode)
{
- if(nErrorCode == 0 && m_pWebServer)
+ if(nErrorCode == 0 && m_pWebServer) {
m_pWebServer->OnAccept(this);
+ }
__super::OnAccept(nErrorCode);
}
diff --git a/src/apps/mplayerc/jpeg.cpp b/src/apps/mplayerc/jpeg.cpp
index fa5cfe321..bcb32c098 100644
--- a/src/apps/mplayerc/jpeg.cpp
+++ b/src/apps/mplayerc/jpeg.cpp
@@ -29,17 +29,20 @@
bool CJpegEncoder::PutBit(int b, int n)
{
- if(n > 24 || n <= 0) return(false);
+ if(n > 24 || n <= 0) {
+ return(false);
+ }
m_bbuff <<= n;
m_bbuff |= b & ((1 << n) - 1);
m_bwidth += n;
- while(m_bwidth >= 8)
- {
+ while(m_bwidth >= 8) {
BYTE c = (BYTE)(m_bbuff >> (m_bwidth - 8));
PutByte(c);
- if(c == 0xff) PutByte(0);
+ if(c == 0xff) {
+ PutByte(0);
+ }
m_bwidth -= 8;
}
@@ -48,11 +51,12 @@ bool CJpegEncoder::PutBit(int b, int n)
void CJpegEncoder::Flush()
{
- if(m_bwidth > 0)
- {
+ if(m_bwidth > 0) {
BYTE c = m_bbuff << (8 - m_bwidth);
PutByte(c);
- if(c == 0xff) PutByte(0);
+ if(c == 0xff) {
+ PutByte(0);
+ }
}
m_bbuff = m_bwidth = 0;
@@ -62,11 +66,17 @@ void CJpegEncoder::Flush()
int CJpegEncoder::GetBitWidth(short q)
{
- if(q == 0) return(0);
- if(q < 0) q = -q;
+ if(q == 0) {
+ return(0);
+ }
+ if(q < 0) {
+ q = -q;
+ }
int width = 15;
- for(; !(q&0x4000); q <<= 1, width--);
+ for(; !(q&0x4000); q <<= 1, width--) {
+ ;
+ }
return(width);
}
@@ -87,8 +97,7 @@ void CJpegEncoder::WriteDQT()
PutByte(size>>8);
PutByte(size&0xff);
- for(int c = 0; c < 2; c++)
- {
+ for(int c = 0; c < 2; c++) {
PutByte(c);
PutBytes(quanttbl[c], 64);
}
@@ -136,11 +145,15 @@ void CJpegEncoder::WriteDHT()
PutByte(0x00); // tbl class (DC) | tbl id
PutBytes(DCVLC_NumByLength[0], 16);
- for(int i = 0; i < 12; i++) PutByte(i);
+ for(int i = 0; i < 12; i++) {
+ PutByte(i);
+ }
PutByte(0x01); // tbl class (DC) | tbl id
PutBytes(DCVLC_NumByLength[1], 16);
- for(int i = 0; i < 12; i++) PutByte(i);
+ for(int i = 0; i < 12; i++) {
+ PutByte(i);
+ }
PutByte(0x10); // tbl class (AC) | tbl id
PutBytes(ACVLC_NumByLength[0], 16);
@@ -186,29 +199,26 @@ void CJpegEncoder::WriteSOS()
for(int v = 0; v < 8; v++)
for(int u = 0; u < 8; u++)
for(int j = 0; j < 8; j++)
- for(int i = 0; i < 8; i++)
+ for(int i = 0; i < 8; i++) {
cosuv[v][u][j][i] = (float)(cos((2*i+1)*u*PI/16) * cos((2*j+1)*v*PI/16));
+ }
int prevDC[3] = {0, 0, 0};
- for(int y = 0; y < m_h; y += 8)
- {
+ for(int y = 0; y < m_h; y += 8) {
int jj = min(m_h - y, 8);
- for(int x = 0; x < m_w; x += 8)
- {
+ for(int x = 0; x < m_w; x += 8) {
int ii = min(m_w - x, 8);
- for(int c = 0; c < ColorComponents; c++)
- {
+ for(int c = 0; c < ColorComponents; c++) {
int cc = !!c;
int ACs = 0;
static short block[64];
- for(int zigzag = 0; zigzag < 64; zigzag++)
- {
+ for(int zigzag = 0; zigzag < 64; zigzag++) {
BYTE u = zigzagU[zigzag];
BYTE v = zigzagV[zigzag];
@@ -218,11 +228,11 @@ void CJpegEncoder::WriteSOS()
for(int i = 0; i < ii; i++)
F += (signed char)m_p[((y+j)*m_w + (x+i))*4 + c] * cosuv[v][u][j][i];
*/
- for(int j = 0; j < jj; j++)
- {
+ for(int j = 0; j < jj; j++) {
signed char* p = (signed char*)&m_p[((y+j)*m_w + x)*4 + c];
- for(int i = 0; i < ii; i++, p += 4)
+ for(int i = 0; i < ii; i++, p += 4) {
F += *p * cosuv[v][u][j][i];
+ }
}
float cu = !u ? invsq2 : 1.0f;
@@ -237,37 +247,40 @@ void CJpegEncoder::WriteSOS()
int size = GetBitWidth(DC);
PutBit(DCVLC[cc][size], DCVLC_Size[cc][size]);
- if(DC < 0) DC = DC - 1;
+ if(DC < 0) {
+ DC = DC - 1;
+ }
PutBit(DC, size);
int j;
- for(j = 64; j > 1 && !block[j-1]; j--);
+ for(j = 64; j > 1 && !block[j-1]; j--) {
+ ;
+ }
- for(int i = 1; i < j; i++)
- {
+ for(int i = 1; i < j; i++) {
short AC = block[i];
- if(AC == 0)
- {
- if(++ACs == 16)
- {
+ if(AC == 0) {
+ if(++ACs == 16) {
PutBit(ACVLC[cc][15][0], ACVLC_Size[cc][15][0]);
ACs = 0;
}
- }
- else
- {
+ } else {
int size = GetBitWidth(AC);
PutBit(ACVLC[cc][ACs][size], ACVLC_Size[cc][ACs][size]);
- if(AC < 0) AC--;
+ if(AC < 0) {
+ AC--;
+ }
PutBit(AC, size);
ACs = 0;
}
}
- if(j < 64) PutBit(ACVLC[cc][0][0], ACVLC_Size[cc][0][0]);
+ if(j < 64) {
+ PutBit(ACVLC[cc][0][0], ACVLC_Size[cc][0][0]);
+ }
}
}
}
@@ -295,18 +308,21 @@ bool CJpegEncoder::Encode(const BYTE* dib)
int bpp = bi->bmiHeader.biBitCount;
- if(bpp != 16 && bpp != 24 && bpp != 32) // 16 & 24 not tested!!! there may be some alignment problems when the row size is not 4*something in bytes
+ if(bpp != 16 && bpp != 24 && bpp != 32) { // 16 & 24 not tested!!! there may be some alignment problems when the row size is not 4*something in bytes
return false;
+ }
m_w = bi->bmiHeader.biWidth;
m_h = abs(bi->bmiHeader.biHeight);
m_p = DNew BYTE[m_w*m_h*4];
const BYTE* src = dib + sizeof(bi->bmiHeader);
- if(bi->bmiHeader.biBitCount <= 8)
- {
- if(bi->bmiHeader.biClrUsed) src += bi->bmiHeader.biClrUsed * sizeof(bi->bmiColors[0]);
- else src += (1 << bi->bmiHeader.biBitCount) * DWORD(sizeof(bi->bmiColors[0]));
+ if(bi->bmiHeader.biBitCount <= 8) {
+ if(bi->bmiHeader.biClrUsed) {
+ src += bi->bmiHeader.biClrUsed * sizeof(bi->bmiColors[0]);
+ } else {
+ src += (1 << bi->bmiHeader.biBitCount) * DWORD(sizeof(bi->bmiColors[0]));
+ }
}
int srcpitch = m_w*(bpp>>3);
@@ -318,8 +334,7 @@ bool CJpegEncoder::Encode(const BYTE* dib)
(BYTE*)src + srcpitch*(m_h-1), -srcpitch, bpp);
BYTE* p = m_p;
- for(BYTE* e = p + m_h*dstpitch; p < e; p += 4)
- {
+ for(BYTE* e = p + m_h*dstpitch; p < e; p += 4) {
int r = p[2], g = p[1], b = p[0];
p[0] = (BYTE)min(max(0.2990*r+0.5870*g+0.1140*b, 0), 255) - 128;
@@ -327,11 +342,11 @@ bool CJpegEncoder::Encode(const BYTE* dib)
p[2] = (BYTE)min(max(0.5000*r-0.4187*g-0.0813*b + 128, 0), 255) - 128;
}
- if(quanttbl[0][0] == 16)
- {
+ if(quanttbl[0][0] == 16) {
for(int i = 0; i < countof(quanttbl); i++)
- for(int j = 0; j < countof(quanttbl[0]); j++)
- quanttbl[i][j] >>= 2; // the default quantization table contains a little too large values
+ for(int j = 0; j < countof(quanttbl[0]); j++) {
+ quanttbl[i][j] >>= 2; // the default quantization table contains a little too large values
+ }
}
WriteSOI();
@@ -367,8 +382,9 @@ bool CJpegEncoderFile::PutBytes(const void* pData, size_t len)
bool CJpegEncoderFile::Encode(const BYTE* dib)
{
m_file = _tfopen(m_fn, _T("wb"));
- if(!m_file)
+ if(!m_file) {
return false;
+ }
bool ret = __super::Encode(dib);
fclose(m_file);
m_file = NULL;
diff --git a/src/apps/mplayerc/jpeg_tables.h b/src/apps/mplayerc/jpeg_tables.h
index f7b208c72..e93974720 100644
--- a/src/apps/mplayerc/jpeg_tables.h
+++ b/src/apps/mplayerc/jpeg_tables.h
@@ -25,8 +25,7 @@
/* Tables */
-static unsigned char quanttbl[2][64] =
-{
+static unsigned char quanttbl[2][64] = {
{
16,
11, 12,
@@ -63,8 +62,7 @@ static unsigned char quanttbl[2][64] =
}
};
-static unsigned char zigzagU[64] =
-{
+static unsigned char zigzagU[64] = {
0,
1, 0,
0, 1, 2,
@@ -82,8 +80,7 @@ static unsigned char zigzagU[64] =
7,
};
-static unsigned char zigzagV[64] =
-{
+static unsigned char zigzagV[64] = {
0,
0, 1,
2, 1, 0,
@@ -101,26 +98,22 @@ static unsigned char zigzagV[64] =
7,
};
-static unsigned short DCVLC[2][12] =
-{
+static unsigned short DCVLC[2][12] = {
{0, 2, 3, 4, 5, 6, 14, 30, 62, 126, 254, 510},
{0, 1, 2, 6, 14, 30, 62, 126, 254, 510, 1022, 2046}
};
-static unsigned char DCVLC_Size[2][12] =
-{
+static unsigned char DCVLC_Size[2][12] = {
{2, 3, 3, 3, 3, 3, 4, 5, 6, 7, 8, 9},
{2, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}
};
-static unsigned char DCVLC_NumByLength[2][16] =
-{
+static unsigned char DCVLC_NumByLength[2][16] = {
{0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0},
{0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0}
};
-static unsigned short ACVLC[2][16][11] =
-{
+static unsigned short ACVLC[2][16][11] = {
{
{10, 0, 1, 4, 11, 26, 120, 248, 1014, 65410, 65410},
{0, 12, 27, 121, 502, 2038, 65412, 65413, 65414, 65415, 65416},
@@ -159,8 +152,7 @@ static unsigned short ACVLC[2][16][11] =
}
};
-static unsigned char ACVLC_Size[2][16][11] =
-{
+static unsigned char ACVLC_Size[2][16][11] = {
{
{4, 2, 2, 3, 4, 5, 7, 8, 10, 16, 16},
{0, 4, 5, 7, 9, 11, 16, 16, 16, 16, 16},
@@ -199,14 +191,12 @@ static unsigned char ACVLC_Size[2][16][11] =
}
};
-static unsigned char ACVLC_NumByLength[2][16] =
-{
+static unsigned char ACVLC_NumByLength[2][16] = {
{0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 125},
{0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 119}
};
-static unsigned char ACVLC_Data[2][162] =
-{
+static unsigned char ACVLC_Data[2][162] = {
{
0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12,
0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07,
diff --git a/src/apps/mplayerc/libpng.c b/src/apps/mplayerc/libpng.c
index ad2c6cca7..56058d407 100644
--- a/src/apps/mplayerc/libpng.c
+++ b/src/apps/mplayerc/libpng.c
@@ -30,7 +30,9 @@
static void read_data_fn(png_structp png_ptr, png_bytep data, png_size_t length)
{
struct png_t* png = (struct png_t*)png_get_progressive_ptr(png_ptr);
- if(png->pos + length > png->size) png_error(png_ptr, "Read Error");
+ if(png->pos + length > png->size) {
+ png_error(png_ptr, "Read Error");
+ }
memcpy(data, &png->data[png->pos], length);
png->pos += length;
}
@@ -45,34 +47,33 @@ unsigned char* DecompressPNG(struct png_t* png, int* w, int* h)
unsigned char* row;
unsigned int x, y, c;
- if(png_sig_cmp(png->data, 0, 8) != 0)
+ if(png_sig_cmp(png->data, 0, 8) != 0) {
return NULL;
+ }
png->pos = 8;
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
// (png_voidp)user_error_ptr, user_error_fn, user_warning_fn);
- if(!png_ptr)
+ if(!png_ptr) {
return NULL;
+ }
png_set_read_fn(png_ptr, (png_voidp)png, read_data_fn);
info_ptr = png_create_info_struct(png_ptr);
- if(!info_ptr)
- {
+ if(!info_ptr) {
png_destroy_read_struct(&png_ptr, (png_infopp)NULL, (png_infopp)NULL);
return NULL;
}
end_info = png_create_info_struct(png_ptr);
- if(!end_info)
- {
+ if(!end_info) {
png_destroy_read_struct(&png_ptr, &info_ptr, (png_infopp)NULL);
return NULL;
}
- if(setjmp(png_jmpbuf(png_ptr)))
- {
+ if(setjmp(png_jmpbuf(png_ptr))) {
png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
return NULL;
}
@@ -88,8 +89,7 @@ unsigned char* DecompressPNG(struct png_t* png, int* w, int* h)
PNG_TRANSFORM_BGR,
NULL);
- if(png_get_channels(png_ptr, info_ptr) != 3)
- {
+ if(png_get_channels(png_ptr, info_ptr) != 3) {
png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
return NULL;
}
@@ -99,14 +99,11 @@ unsigned char* DecompressPNG(struct png_t* png, int* w, int* h)
*w = info_ptr->width;
*h = info_ptr->height;
- for(y = 0; y < info_ptr->height; y++)
- {
+ for(y = 0; y < info_ptr->height; y++) {
row = &pic[y * info_ptr->width * 4];
- for(x = 0; x < info_ptr->width*3; row += 4)
- {
- for(c = 0; c < 3; c++)
- {
+ for(x = 0; x < info_ptr->width*3; row += 4) {
+ for(c = 0; c < 3; c++) {
row[c] = info_ptr->row_pointers[y][x++];
}
}
diff --git a/src/apps/mplayerc/libpng.h b/src/apps/mplayerc/libpng.h
index bd306944e..7a5cf8aaa 100644
--- a/src/apps/mplayerc/libpng.h
+++ b/src/apps/mplayerc/libpng.h
@@ -23,8 +23,7 @@
#pragma once
-struct png_t
-{
+struct png_t {
unsigned char* data;
unsigned int size, pos;
};
@@ -39,23 +38,20 @@ extern "C" unsigned char* DecompressPNG(struct png_t* png, int* w, int* h);
class CMPCPngImage : public CImage
{
public:
- bool LoadFromResource(UINT id)
- {
+ bool LoadFromResource(UINT id) {
bool ret = false;
CStringA str;
- if(LoadResource(id, str, _T("FILE")))
- {
+ if(LoadResource(id, str, _T("FILE"))) {
struct png_t png;
png.data = (unsigned char*)(LPCSTR)str;
png.size = str.GetLength();
int w, h;
- if(BYTE* p = DecompressPNG(&png, &w, &h))
- {
- if(Create(w, -h, 32))
- {
- for(int y = 0; y < h; y++)
+ if(BYTE* p = DecompressPNG(&png, &w, &h)) {
+ if(Create(w, -h, 32)) {
+ for(int y = 0; y < h; y++) {
memcpy(GetPixelAddress(0, y), &p[w*4*y], w*4);
+ }
ret = true;
}
diff --git a/src/apps/mplayerc/mpciconlib/mpciconlib.cpp b/src/apps/mplayerc/mpciconlib/mpciconlib.cpp
index 211621592..e43b4ec63 100644
--- a/src/apps/mplayerc/mpciconlib/mpciconlib.cpp
+++ b/src/apps/mplayerc/mpciconlib/mpciconlib.cpp
@@ -10,108 +10,211 @@ int get_icon_index(CString ext)
{
int iconindex = -1;
- if(ext.CompareNoCase(_T(".3g2")) == 0) iconindex = IDI_MP4_ICON;
- else if(ext.CompareNoCase(_T(".3gp")) == 0) iconindex = IDI_MP4_ICON;
- else if(ext.CompareNoCase(_T(".3gp2")) == 0) iconindex = IDI_MP4_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_DVDA_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_OTHER_ICON;
- else if(ext.CompareNoCase(_T(".amv")) == 0) iconindex = IDI_OTHER_ICON;
- else if(ext.CompareNoCase(_T(".ape")) == 0) iconindex = IDI_NONE;
- else if(ext.CompareNoCase(_T(".asf")) == 0) iconindex = IDI_WMV_ICON;
- else if(ext.CompareNoCase(_T(".asx")) == 0) iconindex = IDI_PLC_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(".bik")) == 0) iconindex = IDI_BIK_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(".divx")) == 0) iconindex = IDI_AVI_ICON;
- else if(ext.CompareNoCase(_T(".drc")) == 0) iconindex = IDI_DRC_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_DVDA_ICON;
- else if(ext.CompareNoCase(_T(".evo")) == 0) iconindex = IDI_MPG_ICON;
- else if(ext.CompareNoCase(_T(".flac")) == 0) iconindex = IDI_FLAC_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(".iflv")) == 0) iconindex = IDI_FLV_ICON;
- else if(ext.CompareNoCase(_T(".f4v")) == 0) iconindex = IDI_FLV_ICON;
- else if(ext.CompareNoCase(_T(".hdmov")) == 0) iconindex = IDI_MP4_ICON;
- else if(ext.CompareNoCase(_T(".ifo")) == 0) iconindex = IDI_DVDF_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_MPG_ICON;
- else if(ext.CompareNoCase(_T(".m2a")) == 0) iconindex = IDI_MPA_ICON;
- else if(ext.CompareNoCase(_T(".m2t")) == 0) iconindex = IDI_MPG_ICON;
- else if(ext.CompareNoCase(_T(".m2ts")) == 0) iconindex = IDI_MPG_ICON;
- else if(ext.CompareNoCase(_T(".m2v")) == 0) iconindex = IDI_MPG_ICON;
- else if(ext.CompareNoCase(_T(".m3u")) == 0) iconindex = IDI_PLC_ICON;
- else if(ext.CompareNoCase(_T(".bdmv")) == 0) iconindex = IDI_PLC_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_MID_ICON;
- else if(ext.CompareNoCase(_T(".midi")) == 0) iconindex = IDI_MID_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_MPC_ICON;
- else if(ext.CompareNoCase(_T(".mp2v")) == 0) iconindex = IDI_MPG_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(".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_PLC_ICON;
- else if(ext.CompareNoCase(_T(".mpe")) == 0) iconindex = IDI_MPG_ICON;
- else if(ext.CompareNoCase(_T(".mpeg")) == 0) iconindex = IDI_MPG_ICON;
- else if(ext.CompareNoCase(_T(".mpg")) == 0) iconindex = IDI_MPG_ICON;
- else if(ext.CompareNoCase(_T(".mpv2")) == 0) iconindex = IDI_MPG_ICON;
- else if(ext.CompareNoCase(_T(".mts")) == 0) iconindex = IDI_MPG_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_PLC_ICON;
- else if(ext.CompareNoCase(_T(".pva")) == 0) iconindex = IDI_MPG_ICON;
- else if(ext.CompareNoCase(_T(".pss")) == 0) iconindex = IDI_MPG_ICON;
- else if(ext.CompareNoCase(_T(".qt")) == 0) iconindex = IDI_MOV_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(".ratdvd")) == 0) iconindex = IDI_RATDVD_ICON;
- else if(ext.CompareNoCase(_T(".rm")) == 0) iconindex = IDI_RM_ICON;
- else if(ext.CompareNoCase(_T(".rmi")) == 0) iconindex = IDI_MID_ICON;
- else if(ext.CompareNoCase(_T(".rmm")) == 0) iconindex = IDI_RM_ICON;
- else if(ext.CompareNoCase(_T(".rmvb")) == 0) iconindex = IDI_RM_ICON;
- else if(ext.CompareNoCase(_T(".roq")) == 0) iconindex = IDI_ROQ_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_RM_ICON;
- else if(ext.CompareNoCase(_T(".smil")) == 0) iconindex = IDI_RM_ICON;
- else if(ext.CompareNoCase(_T(".smk")) == 0) iconindex = IDI_OTHER_ICON;
- else if(ext.CompareNoCase(_T(".snd")) == 0) iconindex = IDI_AU_ICON;
- else if(ext.CompareNoCase(_T(".tp")) == 0) iconindex = IDI_MPG_ICON;
- else if(ext.CompareNoCase(_T(".tpr")) == 0) iconindex = IDI_MPG_ICON;
- else if(ext.CompareNoCase(_T(".ts")) == 0) iconindex = IDI_MPG_ICON;
- else if(ext.CompareNoCase(_T(".vob")) == 0) iconindex = IDI_DVDF_ICON;
- else if(ext.CompareNoCase(_T(".vp6")) == 0) iconindex = IDI_OTHER_ICON;
- else if(ext.CompareNoCase(_T(".wav")) == 0) iconindex = IDI_WAV_ICON;
- else if(ext.CompareNoCase(_T(".wax")) == 0) iconindex = IDI_PLC_ICON;
- else if(ext.CompareNoCase(_T(".webm")) == 0) iconindex = IDI_OTHER_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_PLC_ICON;
- else if(ext.CompareNoCase(_T(".wv")) == 0) iconindex = IDI_NONE;
- else if(ext.CompareNoCase(_T(".wvx")) == 0) iconindex = IDI_PLC_ICON;
+ if(ext.CompareNoCase(_T(".3g2")) == 0) {
+ iconindex = IDI_MP4_ICON;
+ } else if(ext.CompareNoCase(_T(".3gp")) == 0) {
+ iconindex = IDI_MP4_ICON;
+ } else if(ext.CompareNoCase(_T(".3gp2")) == 0) {
+ iconindex = IDI_MP4_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_DVDA_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_OTHER_ICON;
+ } else if(ext.CompareNoCase(_T(".amv")) == 0) {
+ iconindex = IDI_OTHER_ICON;
+ } else if(ext.CompareNoCase(_T(".ape")) == 0) {
+ iconindex = IDI_NONE;
+ } else if(ext.CompareNoCase(_T(".asf")) == 0) {
+ iconindex = IDI_WMV_ICON;
+ } else if(ext.CompareNoCase(_T(".asx")) == 0) {
+ iconindex = IDI_PLC_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(".bik")) == 0) {
+ iconindex = IDI_BIK_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(".divx")) == 0) {
+ iconindex = IDI_AVI_ICON;
+ } else if(ext.CompareNoCase(_T(".drc")) == 0) {
+ iconindex = IDI_DRC_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_DVDA_ICON;
+ } else if(ext.CompareNoCase(_T(".evo")) == 0) {
+ iconindex = IDI_MPG_ICON;
+ } else if(ext.CompareNoCase(_T(".flac")) == 0) {
+ iconindex = IDI_FLAC_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(".iflv")) == 0) {
+ iconindex = IDI_FLV_ICON;
+ } else if(ext.CompareNoCase(_T(".f4v")) == 0) {
+ iconindex = IDI_FLV_ICON;
+ } else if(ext.CompareNoCase(_T(".hdmov")) == 0) {
+ iconindex = IDI_MP4_ICON;
+ } else if(ext.CompareNoCase(_T(".ifo")) == 0) {
+ iconindex = IDI_DVDF_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_MPG_ICON;
+ } else if(ext.CompareNoCase(_T(".m2a")) == 0) {
+ iconindex = IDI_MPA_ICON;
+ } else if(ext.CompareNoCase(_T(".m2t")) == 0) {
+ iconindex = IDI_MPG_ICON;
+ } else if(ext.CompareNoCase(_T(".m2ts")) == 0) {
+ iconindex = IDI_MPG_ICON;
+ } else if(ext.CompareNoCase(_T(".m2v")) == 0) {
+ iconindex = IDI_MPG_ICON;
+ } else if(ext.CompareNoCase(_T(".m3u")) == 0) {
+ iconindex = IDI_PLC_ICON;
+ } else if(ext.CompareNoCase(_T(".bdmv")) == 0) {
+ iconindex = IDI_PLC_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_MID_ICON;
+ } else if(ext.CompareNoCase(_T(".midi")) == 0) {
+ iconindex = IDI_MID_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_MPC_ICON;
+ } else if(ext.CompareNoCase(_T(".mp2v")) == 0) {
+ iconindex = IDI_MPG_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(".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_PLC_ICON;
+ } else if(ext.CompareNoCase(_T(".mpe")) == 0) {
+ iconindex = IDI_MPG_ICON;
+ } else if(ext.CompareNoCase(_T(".mpeg")) == 0) {
+ iconindex = IDI_MPG_ICON;
+ } else if(ext.CompareNoCase(_T(".mpg")) == 0) {
+ iconindex = IDI_MPG_ICON;
+ } else if(ext.CompareNoCase(_T(".mpv2")) == 0) {
+ iconindex = IDI_MPG_ICON;
+ } else if(ext.CompareNoCase(_T(".mts")) == 0) {
+ iconindex = IDI_MPG_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_PLC_ICON;
+ } else if(ext.CompareNoCase(_T(".pva")) == 0) {
+ iconindex = IDI_MPG_ICON;
+ } else if(ext.CompareNoCase(_T(".pss")) == 0) {
+ iconindex = IDI_MPG_ICON;
+ } else if(ext.CompareNoCase(_T(".qt")) == 0) {
+ iconindex = IDI_MOV_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(".ratdvd")) == 0) {
+ iconindex = IDI_RATDVD_ICON;
+ } else if(ext.CompareNoCase(_T(".rm")) == 0) {
+ iconindex = IDI_RM_ICON;
+ } else if(ext.CompareNoCase(_T(".rmi")) == 0) {
+ iconindex = IDI_MID_ICON;
+ } else if(ext.CompareNoCase(_T(".rmm")) == 0) {
+ iconindex = IDI_RM_ICON;
+ } else if(ext.CompareNoCase(_T(".rmvb")) == 0) {
+ iconindex = IDI_RM_ICON;
+ } else if(ext.CompareNoCase(_T(".roq")) == 0) {
+ iconindex = IDI_ROQ_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_RM_ICON;
+ } else if(ext.CompareNoCase(_T(".smil")) == 0) {
+ iconindex = IDI_RM_ICON;
+ } else if(ext.CompareNoCase(_T(".smk")) == 0) {
+ iconindex = IDI_OTHER_ICON;
+ } else if(ext.CompareNoCase(_T(".snd")) == 0) {
+ iconindex = IDI_AU_ICON;
+ } else if(ext.CompareNoCase(_T(".tp")) == 0) {
+ iconindex = IDI_MPG_ICON;
+ } else if(ext.CompareNoCase(_T(".tpr")) == 0) {
+ iconindex = IDI_MPG_ICON;
+ } else if(ext.CompareNoCase(_T(".ts")) == 0) {
+ iconindex = IDI_MPG_ICON;
+ } else if(ext.CompareNoCase(_T(".vob")) == 0) {
+ iconindex = IDI_DVDF_ICON;
+ } else if(ext.CompareNoCase(_T(".vp6")) == 0) {
+ iconindex = IDI_OTHER_ICON;
+ } else if(ext.CompareNoCase(_T(".wav")) == 0) {
+ iconindex = IDI_WAV_ICON;
+ } else if(ext.CompareNoCase(_T(".wax")) == 0) {
+ iconindex = IDI_PLC_ICON;
+ } else if(ext.CompareNoCase(_T(".webm")) == 0) {
+ iconindex = IDI_OTHER_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_PLC_ICON;
+ } else if(ext.CompareNoCase(_T(".wv")) == 0) {
+ iconindex = IDI_NONE;
+ } else if(ext.CompareNoCase(_T(".wvx")) == 0) {
+ iconindex = IDI_PLC_ICON;
+ }
return iconindex;
}
diff --git a/src/apps/mplayerc/mpcresources/mplayerc.br.rc b/src/apps/mplayerc/mpcresources/mplayerc.br.rc
index e02bd8561..6dcd8b53c 100644
--- a/src/apps/mplayerc/mpcresources/mplayerc.br.rc
+++ b/src/apps/mplayerc/mpcresources/mplayerc.br.rc
Binary files differ
diff --git a/src/apps/mplayerc/mpcresources/mplayerc.by.rc b/src/apps/mplayerc/mpcresources/mplayerc.by.rc
index 6050e8e8d..4ef9ea2ef 100644
--- a/src/apps/mplayerc/mpcresources/mplayerc.by.rc
+++ b/src/apps/mplayerc/mpcresources/mplayerc.by.rc
Binary files differ
diff --git a/src/apps/mplayerc/mpcresources/mplayerc.ca.rc b/src/apps/mplayerc/mpcresources/mplayerc.ca.rc
index 4481b3a5a..fba9e9a25 100644
--- a/src/apps/mplayerc/mpcresources/mplayerc.ca.rc
+++ b/src/apps/mplayerc/mpcresources/mplayerc.ca.rc
Binary files differ
diff --git a/src/apps/mplayerc/mpcresources/mplayerc.cz.rc b/src/apps/mplayerc/mpcresources/mplayerc.cz.rc
index a7d69f849..b44010b2f 100644
--- a/src/apps/mplayerc/mpcresources/mplayerc.cz.rc
+++ b/src/apps/mplayerc/mpcresources/mplayerc.cz.rc
Binary files differ
diff --git a/src/apps/mplayerc/mpcresources/mplayerc.de.rc b/src/apps/mplayerc/mpcresources/mplayerc.de.rc
index 7dbae82b5..2a4d88ec0 100644
--- a/src/apps/mplayerc/mpcresources/mplayerc.de.rc
+++ b/src/apps/mplayerc/mpcresources/mplayerc.de.rc
Binary files differ
diff --git a/src/apps/mplayerc/mpcresources/mplayerc.es.rc b/src/apps/mplayerc/mpcresources/mplayerc.es.rc
index 3a5b798c1..3c25ff74a 100644
--- a/src/apps/mplayerc/mpcresources/mplayerc.es.rc
+++ b/src/apps/mplayerc/mpcresources/mplayerc.es.rc
Binary files differ
diff --git a/src/apps/mplayerc/mpcresources/mplayerc.fr.rc b/src/apps/mplayerc/mpcresources/mplayerc.fr.rc
index 9dc01bc85..7bcc1961d 100644
--- a/src/apps/mplayerc/mpcresources/mplayerc.fr.rc
+++ b/src/apps/mplayerc/mpcresources/mplayerc.fr.rc
Binary files differ
diff --git a/src/apps/mplayerc/mpcresources/mplayerc.hu.rc b/src/apps/mplayerc/mpcresources/mplayerc.hu.rc
index 82bb306b3..28c093616 100644
--- a/src/apps/mplayerc/mpcresources/mplayerc.hu.rc
+++ b/src/apps/mplayerc/mpcresources/mplayerc.hu.rc
Binary files differ
diff --git a/src/apps/mplayerc/mpcresources/mplayerc.hy.rc b/src/apps/mplayerc/mpcresources/mplayerc.hy.rc
index bd1eaf40f..d41499ee5 100644
--- a/src/apps/mplayerc/mpcresources/mplayerc.hy.rc
+++ b/src/apps/mplayerc/mpcresources/mplayerc.hy.rc
Binary files differ
diff --git a/src/apps/mplayerc/mpcresources/mplayerc.it.rc b/src/apps/mplayerc/mpcresources/mplayerc.it.rc
index 738af85be..f5a7f525a 100644
--- a/src/apps/mplayerc/mpcresources/mplayerc.it.rc
+++ b/src/apps/mplayerc/mpcresources/mplayerc.it.rc
Binary files differ
diff --git a/src/apps/mplayerc/mpcresources/mplayerc.ja.rc b/src/apps/mplayerc/mpcresources/mplayerc.ja.rc
index 3e4ce2a88..2a13bea3b 100644
--- a/src/apps/mplayerc/mpcresources/mplayerc.ja.rc
+++ b/src/apps/mplayerc/mpcresources/mplayerc.ja.rc
Binary files differ
diff --git a/src/apps/mplayerc/mpcresources/mplayerc.kr.rc b/src/apps/mplayerc/mpcresources/mplayerc.kr.rc
index eabad830a..d5699d22f 100644
--- a/src/apps/mplayerc/mpcresources/mplayerc.kr.rc
+++ b/src/apps/mplayerc/mpcresources/mplayerc.kr.rc
Binary files differ
diff --git a/src/apps/mplayerc/mpcresources/mplayerc.nl.rc b/src/apps/mplayerc/mpcresources/mplayerc.nl.rc
index b8a97b08c..faa94ff7a 100644
--- a/src/apps/mplayerc/mpcresources/mplayerc.nl.rc
+++ b/src/apps/mplayerc/mpcresources/mplayerc.nl.rc
Binary files differ
diff --git a/src/apps/mplayerc/mpcresources/mplayerc.pl.rc b/src/apps/mplayerc/mpcresources/mplayerc.pl.rc
index caf03fe82..4194e3468 100644
--- a/src/apps/mplayerc/mpcresources/mplayerc.pl.rc
+++ b/src/apps/mplayerc/mpcresources/mplayerc.pl.rc
Binary files differ
diff --git a/src/apps/mplayerc/mpcresources/mplayerc.ru.rc b/src/apps/mplayerc/mpcresources/mplayerc.ru.rc
index bb1f15882..3fab85890 100644
--- a/src/apps/mplayerc/mpcresources/mplayerc.ru.rc
+++ b/src/apps/mplayerc/mpcresources/mplayerc.ru.rc
Binary files differ
diff --git a/src/apps/mplayerc/mpcresources/mplayerc.sc.rc b/src/apps/mplayerc/mpcresources/mplayerc.sc.rc
index ce47e2981..8cfeb466c 100644
--- a/src/apps/mplayerc/mpcresources/mplayerc.sc.rc
+++ b/src/apps/mplayerc/mpcresources/mplayerc.sc.rc
Binary files differ
diff --git a/src/apps/mplayerc/mpcresources/mplayerc.sk.rc b/src/apps/mplayerc/mpcresources/mplayerc.sk.rc
index 114c297e8..528ab501e 100644
--- a/src/apps/mplayerc/mpcresources/mplayerc.sk.rc
+++ b/src/apps/mplayerc/mpcresources/mplayerc.sk.rc
Binary files differ
diff --git a/src/apps/mplayerc/mpcresources/mplayerc.sv.rc b/src/apps/mplayerc/mpcresources/mplayerc.sv.rc
index 593ef753f..13b9d7df4 100644
--- a/src/apps/mplayerc/mpcresources/mplayerc.sv.rc
+++ b/src/apps/mplayerc/mpcresources/mplayerc.sv.rc
Binary files differ
diff --git a/src/apps/mplayerc/mpcresources/mplayerc.tc.rc b/src/apps/mplayerc/mpcresources/mplayerc.tc.rc
index 76db6cd0d..5e97d8f31 100644
--- a/src/apps/mplayerc/mpcresources/mplayerc.tc.rc
+++ b/src/apps/mplayerc/mpcresources/mplayerc.tc.rc
Binary files differ
diff --git a/src/apps/mplayerc/mpcresources/mplayerc.tr.rc b/src/apps/mplayerc/mpcresources/mplayerc.tr.rc
index 4133e238a..6abb17419 100644
--- a/src/apps/mplayerc/mpcresources/mplayerc.tr.rc
+++ b/src/apps/mplayerc/mpcresources/mplayerc.tr.rc
Binary files differ
diff --git a/src/apps/mplayerc/mpcresources/mplayerc.ua.rc b/src/apps/mplayerc/mpcresources/mplayerc.ua.rc
index a500f6555..87f1d014a 100644
--- a/src/apps/mplayerc/mpcresources/mplayerc.ua.rc
+++ b/src/apps/mplayerc/mpcresources/mplayerc.ua.rc
Binary files differ
diff --git a/src/apps/mplayerc/mpcresources/text/mplayerc.br.rc.txt b/src/apps/mplayerc/mpcresources/text/mplayerc.br.rc.txt
index 24861809a..b405835b0 100644
--- a/src/apps/mplayerc/mpcresources/text/mplayerc.br.rc.txt
+++ b/src/apps/mplayerc/mpcresources/text/mplayerc.br.rc.txt
Binary files differ
diff --git a/src/apps/mplayerc/mpcresources/text/mplayerc.by.rc.txt b/src/apps/mplayerc/mpcresources/text/mplayerc.by.rc.txt
index 276eaa822..56cf6a987 100644
--- a/src/apps/mplayerc/mpcresources/text/mplayerc.by.rc.txt
+++ b/src/apps/mplayerc/mpcresources/text/mplayerc.by.rc.txt
Binary files differ
diff --git a/src/apps/mplayerc/mpcresources/text/mplayerc.ca.rc.txt b/src/apps/mplayerc/mpcresources/text/mplayerc.ca.rc.txt
index 22ca32d8a..9867fe469 100644
--- a/src/apps/mplayerc/mpcresources/text/mplayerc.ca.rc.txt
+++ b/src/apps/mplayerc/mpcresources/text/mplayerc.ca.rc.txt
Binary files differ
diff --git a/src/apps/mplayerc/mpcresources/text/mplayerc.cz.rc.txt b/src/apps/mplayerc/mpcresources/text/mplayerc.cz.rc.txt
index f494c7bab..88862b620 100644
--- a/src/apps/mplayerc/mpcresources/text/mplayerc.cz.rc.txt
+++ b/src/apps/mplayerc/mpcresources/text/mplayerc.cz.rc.txt
Binary files differ
diff --git a/src/apps/mplayerc/mpcresources/text/mplayerc.de.rc.txt b/src/apps/mplayerc/mpcresources/text/mplayerc.de.rc.txt
index 233f71075..c5668eeb8 100644
--- a/src/apps/mplayerc/mpcresources/text/mplayerc.de.rc.txt
+++ b/src/apps/mplayerc/mpcresources/text/mplayerc.de.rc.txt
Binary files differ
diff --git a/src/apps/mplayerc/mpcresources/text/mplayerc.es.rc.txt b/src/apps/mplayerc/mpcresources/text/mplayerc.es.rc.txt
index cc20fccf1..1269478dd 100644
--- a/src/apps/mplayerc/mpcresources/text/mplayerc.es.rc.txt
+++ b/src/apps/mplayerc/mpcresources/text/mplayerc.es.rc.txt
Binary files differ
diff --git a/src/apps/mplayerc/mpcresources/text/mplayerc.fr.rc.txt b/src/apps/mplayerc/mpcresources/text/mplayerc.fr.rc.txt
index 268c65a50..141323f14 100644
--- a/src/apps/mplayerc/mpcresources/text/mplayerc.fr.rc.txt
+++ b/src/apps/mplayerc/mpcresources/text/mplayerc.fr.rc.txt
Binary files differ
diff --git a/src/apps/mplayerc/mpcresources/text/mplayerc.hu.rc.txt b/src/apps/mplayerc/mpcresources/text/mplayerc.hu.rc.txt
index 840fef29d..baa452da0 100644
--- a/src/apps/mplayerc/mpcresources/text/mplayerc.hu.rc.txt
+++ b/src/apps/mplayerc/mpcresources/text/mplayerc.hu.rc.txt
Binary files differ
diff --git a/src/apps/mplayerc/mpcresources/text/mplayerc.hy.rc.txt b/src/apps/mplayerc/mpcresources/text/mplayerc.hy.rc.txt
index 770591daf..13d0e59f9 100644
--- a/src/apps/mplayerc/mpcresources/text/mplayerc.hy.rc.txt
+++ b/src/apps/mplayerc/mpcresources/text/mplayerc.hy.rc.txt
Binary files differ
diff --git a/src/apps/mplayerc/mpcresources/text/mplayerc.it.rc.txt b/src/apps/mplayerc/mpcresources/text/mplayerc.it.rc.txt
index 3de296d14..44fb76f8d 100644
--- a/src/apps/mplayerc/mpcresources/text/mplayerc.it.rc.txt
+++ b/src/apps/mplayerc/mpcresources/text/mplayerc.it.rc.txt
Binary files differ
diff --git a/src/apps/mplayerc/mpcresources/text/mplayerc.ja.rc.txt b/src/apps/mplayerc/mpcresources/text/mplayerc.ja.rc.txt
index 7ad5ee57a..101047d85 100644
--- a/src/apps/mplayerc/mpcresources/text/mplayerc.ja.rc.txt
+++ b/src/apps/mplayerc/mpcresources/text/mplayerc.ja.rc.txt
Binary files differ
diff --git a/src/apps/mplayerc/mpcresources/text/mplayerc.kr.rc.txt b/src/apps/mplayerc/mpcresources/text/mplayerc.kr.rc.txt
index b6d310bda..f9be8f232 100644
--- a/src/apps/mplayerc/mpcresources/text/mplayerc.kr.rc.txt
+++ b/src/apps/mplayerc/mpcresources/text/mplayerc.kr.rc.txt
Binary files differ
diff --git a/src/apps/mplayerc/mpcresources/text/mplayerc.nl.rc.txt b/src/apps/mplayerc/mpcresources/text/mplayerc.nl.rc.txt
index d8fc5241c..d1016e041 100644
--- a/src/apps/mplayerc/mpcresources/text/mplayerc.nl.rc.txt
+++ b/src/apps/mplayerc/mpcresources/text/mplayerc.nl.rc.txt
Binary files differ
diff --git a/src/apps/mplayerc/mpcresources/text/mplayerc.pl.rc.txt b/src/apps/mplayerc/mpcresources/text/mplayerc.pl.rc.txt
index 42122eff9..d020f1526 100644
--- a/src/apps/mplayerc/mpcresources/text/mplayerc.pl.rc.txt
+++ b/src/apps/mplayerc/mpcresources/text/mplayerc.pl.rc.txt
Binary files differ
diff --git a/src/apps/mplayerc/mpcresources/text/mplayerc.ru.rc.txt b/src/apps/mplayerc/mpcresources/text/mplayerc.ru.rc.txt
index 5effbec0d..c9b4a0b6c 100644
--- a/src/apps/mplayerc/mpcresources/text/mplayerc.ru.rc.txt
+++ b/src/apps/mplayerc/mpcresources/text/mplayerc.ru.rc.txt
Binary files differ
diff --git a/src/apps/mplayerc/mpcresources/text/mplayerc.sc.rc.txt b/src/apps/mplayerc/mpcresources/text/mplayerc.sc.rc.txt
index 294cca8c2..a19da1bad 100644
--- a/src/apps/mplayerc/mpcresources/text/mplayerc.sc.rc.txt
+++ b/src/apps/mplayerc/mpcresources/text/mplayerc.sc.rc.txt
Binary files differ
diff --git a/src/apps/mplayerc/mpcresources/text/mplayerc.sk.rc.txt b/src/apps/mplayerc/mpcresources/text/mplayerc.sk.rc.txt
index 1e7c9ea75..accd43310 100644
--- a/src/apps/mplayerc/mpcresources/text/mplayerc.sk.rc.txt
+++ b/src/apps/mplayerc/mpcresources/text/mplayerc.sk.rc.txt
Binary files differ
diff --git a/src/apps/mplayerc/mpcresources/text/mplayerc.sv.rc.txt b/src/apps/mplayerc/mpcresources/text/mplayerc.sv.rc.txt
index d2973b69f..7176cfedf 100644
--- a/src/apps/mplayerc/mpcresources/text/mplayerc.sv.rc.txt
+++ b/src/apps/mplayerc/mpcresources/text/mplayerc.sv.rc.txt
Binary files differ
diff --git a/src/apps/mplayerc/mpcresources/text/mplayerc.tc.rc.txt b/src/apps/mplayerc/mpcresources/text/mplayerc.tc.rc.txt
index d9c1db171..c51e00b42 100644
--- a/src/apps/mplayerc/mpcresources/text/mplayerc.tc.rc.txt
+++ b/src/apps/mplayerc/mpcresources/text/mplayerc.tc.rc.txt
Binary files differ
diff --git a/src/apps/mplayerc/mpcresources/text/mplayerc.tr.rc.txt b/src/apps/mplayerc/mpcresources/text/mplayerc.tr.rc.txt
index 43e73f8f2..8a8a35c60 100644
--- a/src/apps/mplayerc/mpcresources/text/mplayerc.tr.rc.txt
+++ b/src/apps/mplayerc/mpcresources/text/mplayerc.tr.rc.txt
Binary files differ
diff --git a/src/apps/mplayerc/mpcresources/text/mplayerc.ua.rc.txt b/src/apps/mplayerc/mpcresources/text/mplayerc.ua.rc.txt
index 962c7700a..4a7792afa 100644
--- a/src/apps/mplayerc/mpcresources/text/mplayerc.ua.rc.txt
+++ b/src/apps/mplayerc/mpcresources/text/mplayerc.ua.rc.txt
Binary files differ
diff --git a/src/apps/mplayerc/mplayerc.cpp b/src/apps/mplayerc/mplayerc.cpp
index 5d1539688..dbdab48c1 100644
--- a/src/apps/mplayerc/mplayerc.cpp
+++ b/src/apps/mplayerc/mplayerc.cpp
@@ -40,19 +40,22 @@ extern "C" {
void CorrectComboListWidth(CComboBox& box, CFont* pWndFont)
{
int cnt = box.GetCount();
- if(cnt <= 0) return;
+ if(cnt <= 0) {
+ return;
+ }
CDC* pDC = box.GetDC();
pDC->SelectObject(pWndFont);
int maxw = box.GetDroppedWidth();
- for(int i = 0; i < cnt; i++)
- {
+ for(int i = 0; i < cnt; i++) {
CString str;
box.GetLBText(i, str);
int w = pDC->GetTextExtent(str).cx + 22;
- if(maxw < w) maxw = w;
+ if(maxw < w) {
+ maxw = w;
+ }
}
box.ReleaseDC(pDC);
@@ -62,60 +65,68 @@ void CorrectComboListWidth(CComboBox& box, CFont* pWndFont)
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")))
+ if(ext.IsEmpty() || !ext.CompareNoCase(_T("file"))) {
ext = _T(".") + fn.Mid(fn.ReverseFind('.')+1);
+ }
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))
+ 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))
+ if(!ext.CompareNoCase(_T(".cda"))) {
+ if(HICON hIcon = (HICON)LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_AUDIOCD), IMAGE_ICON, size.cx, size.cy, 0)) {
return(hIcon);
+ }
}
- do
- {
+ do {
CRegKey key;
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))
+ 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 = sizeof(buff)/sizeof(buff[0]);
memset(buff, 0, sizeof(buff));
- if(ERROR_SUCCESS != key.QueryStringValue(NULL, buff, &len) || (ext = buff).Trim().IsEmpty())
+ 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))
+ if(ERROR_SUCCESS != key.Open(HKEY_CLASSES_ROOT, ext + _T("\\DefaultIcon"), KEY_READ)) {
break;
+ }
}
CString icon;
len = sizeof(buff)/sizeof(buff[0]);
memset(buff, 0, sizeof(buff));
- if(ERROR_SUCCESS != key.QueryStringValue(NULL, buff, &len) || (icon = buff).Trim().IsEmpty())
+ if(ERROR_SUCCESS != key.QueryStringValue(NULL, buff, &len) || (icon = buff).Trim().IsEmpty()) {
break;
+ }
int i = icon.ReverseFind(',');
- if(i < 0) break;
+ if(i < 0) {
+ break;
+ }
int id = 0;
- if(_stscanf_s(icon.Mid(i+1), _T("%d"), &id) != 1)
+ if(_stscanf_s(icon.Mid(i+1), _T("%d"), &id) != 1) {
break;
+ }
icon = icon.Left(i);
@@ -124,9 +135,10 @@ HICON LoadIcon(CString fn, bool fSmall)
? ExtractIconEx(icon, id, NULL, &hIcon, 1)
: ExtractIconEx(icon, id, &hIcon, NULL, 1);
UNUSED_ALWAYS(cnt);
- if(hIcon) return hIcon;
- }
- while(0);
+ if(hIcon) {
+ return hIcon;
+ }
+ } while(0);
return((HICON)LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_UNKNOWN), IMAGE_ICON, size.cx, size.cy, 0));
}
@@ -138,35 +150,43 @@ bool LoadType(CString fn, CString& type)
TCHAR buff[256];
ULONG len;
- 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")))
+ if(ext.IsEmpty() || !ext.CompareNoCase(_T("file"))) {
ext = _T(".") + fn.Mid(fn.ReverseFind('.')+1);
+ }
CString tmp = _T("");
CString mplayerc_ext = _T("mplayerc") + ext;
- if(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, mplayerc_ext))
+ if(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, mplayerc_ext)) {
tmp = mplayerc_ext;
+ }
- if((tmp == _T("")) && (ERROR_SUCCESS != key.Open(HKEY_CLASSES_ROOT, ext)))
+ if((tmp == _T("")) && (ERROR_SUCCESS != key.Open(HKEY_CLASSES_ROOT, ext))) {
return(false);
+ }
- if(tmp == _T("")) tmp = ext;
+ if(tmp == _T("")) {
+ tmp = ext;
+ }
- while(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, tmp))
- {
+ while(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, tmp)) {
len = sizeof(buff)/sizeof(buff[0]);
memset(buff, 0, sizeof(buff));
- if(ERROR_SUCCESS != key.QueryStringValue(NULL, buff, &len))
+ if(ERROR_SUCCESS != key.QueryStringValue(NULL, buff, &len)) {
break;
+ }
CString str(buff);
str.Trim();
- if(str.IsEmpty() || str == tmp)
+ if(str.IsEmpty() || str == tmp) {
break;
+ }
tmp = str;
}
@@ -180,11 +200,17 @@ bool LoadResource(UINT resid, CStringA& str, LPCTSTR restype)
{
str.Empty();
HRSRC hrsrc = FindResource(AfxGetApp()->m_hInstance, MAKEINTRESOURCE(resid), restype);
- if(!hrsrc) return(false);
+ if(!hrsrc) {
+ return(false);
+ }
HGLOBAL hGlobal = LoadResource(AfxGetApp()->m_hInstance, hrsrc);
- if(!hGlobal) return(false);
+ if(!hGlobal) {
+ return(false);
+ }
DWORD size = SizeofResource(AfxGetApp()->m_hInstance, hrsrc);
- if(!size) return(false);
+ if(!size) {
+ return(false);
+ }
memcpy(str.GetBufferSetLength(size), LockResource(hGlobal), size);
return(true);
}
@@ -199,7 +225,7 @@ class CAboutDlg : public CDialog
public:
CAboutDlg();
-// Dialog Data
+ // Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
@@ -210,15 +236,14 @@ protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
-// Implementation
+ // Implementation
protected:
//{{AFX_MSG(CAboutDlg)
// No message handlers
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
public:
- virtual BOOL OnInitDialog()
- {
+ virtual BOOL OnInitDialog() {
USES_CONVERSION;
UpdateData();
@@ -240,7 +265,11 @@ public:
#endif
#elif defined(_MSC_VER)
#if (_MSC_VER == 1600)
- m_MPCCompiler = _T("MSVC 2010");
+ #if (_MSC_FULL_VER >= 160031118)
+ m_MPCCompiler = _T("MSVC 2010 SP1");
+ #else
+ m_MPCCompiler = _T("MSVC 2010");
+ #endif
#elif (_MSC_VER == 1500)
#if (_MSC_FULL_VER >= 150030729)
m_MPCCompiler = _T("MSVC 2008 SP1");
@@ -349,10 +378,11 @@ void CMPlayerCApp::ShowCmdlnSwitches() const
{
CString s;
- if(m_s.nCLSwitches&CLSW_UNRECOGNIZEDSWITCH)
- {
+ if(m_s.nCLSwitches&CLSW_UNRECOGNIZEDSWITCH) {
CAtlList<CString> sl;
- for(int i = 0; i < __argc; i++) sl.AddTail(__targv[i]);
+ for(int i = 0; i < __argc; i++) {
+ sl.AddTail(__targv[i]);
+ }
s += ResStr(IDS_UNKNOWN_SWITCH) + Implode(sl, ' ') + _T("\n\n");
}
@@ -371,12 +401,12 @@ 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);
-*/
+ /*
+ 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);
@@ -438,24 +468,22 @@ bool CMPlayerCApp::GetAppSavePath(CString& path)
{
path.Empty();
- if(IsIniValid()) // If settings ini file found, store stuff in the same folder as the exe file
- {
+ 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 = path.Left(path.ReverseFind('\\'));
- }
- else
- {
+ } else {
CRegKey key;
- if(ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders"), KEY_READ))
- {
+ 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("AppData"), path.GetBuffer(_MAX_PATH), &len))
+ if(ERROR_SUCCESS == key.QueryStringValue(_T("AppData"), path.GetBuffer(_MAX_PATH), &len)) {
path.ReleaseBufferSetLength(len);
+ }
}
- if(path.IsEmpty())
+ if(path.IsEmpty()) {
return(false);
+ }
CPath p;
p.Combine(path, _T("Media Player Classic"));
@@ -469,17 +497,17 @@ bool CMPlayerCApp::GetAppSavePath(CString& path)
void CMPlayerCApp::PreProcessCommandLine()
{
m_cmdln.RemoveAll();
- for(int i = 1; i < __argc; i++)
- {
+ for(int i = 1; i < __argc; i++) {
CString str = CString(__targv[i]).Trim(_T(" \""));
- if(str[0] != '/' && str[0] != '-' && str.Find(_T(":")) < 0)
- {
+ if(str[0] != '/' && str[0] != '-' && str.Find(_T(":")) < 0) {
LPTSTR p = NULL;
CString str2;
str2.ReleaseBuffer(GetFullPathName(str, _MAX_PATH, str2.GetBuffer(_MAX_PATH), &p));
CFileStatus fs;
- if(!str2.IsEmpty() && CFileGetStatus(str2, fs)) str = str2;
+ if(!str2.IsEmpty() && CFileGetStatus(str2, fs)) {
+ str = str2;
+ }
}
m_cmdln.AddTail(str);
@@ -488,17 +516,21 @@ void CMPlayerCApp::PreProcessCommandLine()
void CMPlayerCApp::SendCommandLine(HWND hWnd)
{
- if(m_cmdln.IsEmpty())
+ if(m_cmdln.IsEmpty()) {
return;
+ }
int bufflen = sizeof(DWORD);
POSITION pos = m_cmdln.GetHeadPosition();
- while(pos) bufflen += (m_cmdln.GetNext(pos).GetLength()+1)*sizeof(TCHAR);
+ while(pos) {
+ bufflen += (m_cmdln.GetNext(pos).GetLength()+1)*sizeof(TCHAR);
+ }
CAutoVectorPtr<BYTE> buff;
- if(!buff.Allocate(bufflen))
+ if(!buff.Allocate(bufflen)) {
return;
+ }
BYTE* p = buff;
@@ -506,8 +538,7 @@ void CMPlayerCApp::SendCommandLine(HWND hWnd)
p += sizeof(DWORD);
pos = m_cmdln.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CString s = m_cmdln.GetNext(pos);
int len = (s.GetLength()+1)*sizeof(TCHAR);
memcpy(p, s, len);
@@ -604,8 +635,7 @@ NTSTATUS WINAPI Mine_NtQueryInformationProcess(HANDLE ProcessHandle, PROCESSINFO
nRet = Real_NtQueryInformationProcess(ProcessHandle, ProcessInformationClass, ProcessInformation, ProcessInformationLength, ReturnLength);
- if (ProcessInformationClass == ProcessBasicInformation)
- {
+ if (ProcessInformationClass == ProcessBasicInformation) {
PROCESS_BASIC_INFORMATION* pbi = (PROCESS_BASIC_INFORMATION*)ProcessInformation;
PEB_NT* pPEB;
PEB_NT PEB;
@@ -614,9 +644,7 @@ NTSTATUS WINAPI Mine_NtQueryInformationProcess(HANDLE ProcessHandle, PROCESSINFO
ReadProcessMemory(ProcessHandle, pPEB, &PEB, sizeof(PEB), NULL);
PEB.BeingDebugged = 0;
WriteProcessMemory(ProcessHandle, pPEB, &PEB, sizeof(PEB), NULL);
- }
- else if (ProcessInformationClass == 7) // ProcessDebugPort
- {
+ } else if (ProcessInformationClass == 7) { // ProcessDebugPort
BOOL* pDebugPort = (BOOL*)ProcessInformation;
*pDebugPort = FALSE;
}
@@ -626,24 +654,18 @@ NTSTATUS WINAPI Mine_NtQueryInformationProcess(HANDLE ProcessHandle, PROCESSINFO
LONG WINAPI Mine_ChangeDisplaySettingsEx(LONG ret, DWORD dwFlags, LPVOID lParam)
{
- if(dwFlags&CDS_VIDEOPARAMETERS)
- {
+ 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)
- {
+ && (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)
- {
+ && 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)
- {
+ } else if(vp->dwCommand == VP_COMMAND_SET) {
TRACE(_T("Ooops, as I already told ya, no need for any macrovision bs here"));
return 0;
}
@@ -686,15 +708,16 @@ BOOL CreateFakeVideoTS(LPCWSTR strIFOPath, LPWSTR strFakeFile, size_t nFakeFileS
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);
if (Ifo.OpenFile (strIFOPath) &&
Ifo.RemoveUOPs() &&
- Ifo.SaveFile (strFakeFile))
- {
+ Ifo.SaveFile (strFakeFile)) {
bRet = TRUE;
}
@@ -709,16 +732,15 @@ HANDLE WINAPI Mine_CreateFileW(LPCWSTR p1, DWORD p2, DWORD p3, LPSECURITY_ATTRIB
p3 |= FILE_SHARE_WRITE;
- if (nLen>=4 && _wcsicmp (p1 + nLen-4, L".ifo") == 0)
- {
- if (CreateFakeVideoTS(p1, strFakeFile, countof(strFakeFile)))
- {
+ 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)
+ if (hFile == INVALID_HANDLE_VALUE) {
hFile = Real_CreateFileW(p1, p2, p3, p4, p5, p6, p7);
+ }
return hFile;
}
@@ -726,8 +748,9 @@ HANDLE WINAPI Mine_CreateFileW(LPCWSTR p1, DWORD p2, DWORD p3, LPSECURITY_ATTRIB
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
+ if(fdwDetails == (MIXER_OBJECTF_HMIXER|MIXER_SETCONTROLDETAILSF_VALUE)) {
+ return MMSYSERR_NOERROR; // don't touch the mixer, kthx
+ }
return Real_mixerSetControlDetails(hmxobj, pmxcd, fdwDetails);
}
@@ -736,8 +759,7 @@ BOOL WINAPI Mine_DeviceIoControl(HANDLE hDevice, DWORD dwIoControlCode, LPVOID l
BOOL ret = Real_DeviceIoControl(hDevice, dwIoControlCode, lpInBuffer, nInBufferSize, lpOutBuffer, nOutBufferSize, lpBytesReturned, lpOverlapped);
if(IOCTL_DVD_GET_REGION == dwIoControlCode && lpOutBuffer
- && lpBytesReturned && *lpBytesReturned == sizeof(DVD_REGION))
- {
+ && lpBytesReturned && *lpBytesReturned == sizeof(DVD_REGION)) {
DVD_REGION* pDVDRegion = (DVD_REGION*)lpOutBuffer;
pDVDRegion->SystemRegion = ~pDVDRegion->RegionData;
}
@@ -754,12 +776,11 @@ BOOL WINAPI Mine_DeviceIoControl(HANDLE hDevice, DWORD dwIoControlCode, LPVOID l
class ssftest
{
public:
- ssftest()
- {
+ ssftest() {
Sleep(10000);
MessageBeep((UINT)-1);
-// 8; //
+ // 8; //
SubPicDesc spd;
spd.w = 640;
spd.h = 480;
@@ -782,8 +803,7 @@ public:
s.Render(spd, 10000i64*i, 25, bbox);
}
*/
- try
- {
+ try {
ssf::CRenderer s(&csLock);
s.Open(_T("../../Subtitles/libssf/demo/demo.ssf"));
@@ -796,9 +816,7 @@ public:
bbox.SetRectEmpty();
s.Render(spd, 10000i64*i, 25, bbox);
}
- }
- catch(ssf::Exception& e)
- {
+ } catch(ssf::Exception& e) {
UNREFERENCED_PARAMETER(e);
TRACE(_T("%s\n"), e.ToString());
ASSERT(0);
@@ -811,9 +829,12 @@ public:
};
#endif
-BOOL SetHeapOptions() {
+BOOL SetHeapOptions()
+{
HMODULE hLib = LoadLibrary(L"kernel32.dll");
- if (hLib == NULL) return FALSE;
+ if (hLib == NULL) {
+ return FALSE;
+ }
typedef BOOL (WINAPI *HSI)
(HANDLE, HEAP_INFORMATION_CLASS ,PVOID, SIZE_T);
@@ -830,7 +851,9 @@ BOOL SetHeapOptions() {
BOOL fRet = (pHsi)(NULL,HeapEnableTerminationOnCorruption,NULL,0)
? TRUE
: FALSE;
- if (hLib) FreeLibrary(hLib);
+ if (hLib) {
+ FreeLibrary(hLib);
+ }
return fRet;
}
@@ -846,23 +869,19 @@ BOOL CMPlayerCApp::InitInstance()
#ifdef GOTHTRACE
// Used for tracing when debugger can't be used, e.g. when using some commercial decoders
// Print traces usint _tprintf()
- if (AllocConsole())
- {
+ 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
+ } else {
AfxMessageBox(_T("Could not create console"));
+ }
#endif
- if(SetHeapOptions())
- {
+ if(SetHeapOptions()) {
TRACE(_T("Terminate on corruption enabled\n"));
- }
- else
- {
+ } else {
CString heap_err;
heap_err.Format(_T("Terminate on corruption error = %d\n"), GetLastError());
TRACE(heap_err);
@@ -883,12 +902,12 @@ BOOL CMPlayerCApp::InitInstance()
HMODULE hNTDLL = LoadLibrary (_T("ntdll.dll"));
UNUSED_ALWAYS(hNTDLL);
#ifndef _DEBUG // Disable NtQueryInformationProcess in debug (prevent VS debugger to stop on crash address)
- if (hNTDLL)
- {
+ if (hNTDLL) {
Real_NtQueryInformationProcess = (FUNC_NTQUERYINFORMATIONPROCESS)GetProcAddress (hNTDLL, "NtQueryInformationProcess");
- if (Real_NtQueryInformationProcess)
+ if (Real_NtQueryInformationProcess) {
DetourAttach(&(PVOID&)Real_NtQueryInformationProcess, (PVOID)Mine_NtQueryInformationProcess);
+ }
}
#endif
@@ -898,8 +917,7 @@ BOOL CMPlayerCApp::InitInstance()
ASSERT (lError == NOERROR);
HRESULT hr;
- if(FAILED(hr = OleInitialize(0)))
- {
+ if(FAILED(hr = OleInitialize(0))) {
AfxMessageBox(_T("OleInitialize failed!"));
return FALSE;
}
@@ -915,57 +933,52 @@ BOOL CMPlayerCApp::InitInstance()
wndcls.lpszMenuName = NULL;
wndcls.lpszClassName = MPC_WND_CLASS_NAME;
- if(!AfxRegisterClass(&wndcls))
- {
+ if(!AfxRegisterClass(&wndcls)) {
AfxMessageBox(_T("MainFrm class registration failed!"));
return FALSE;
}
- if(!AfxSocketInit(NULL))
- {
+ if(!AfxSocketInit(NULL)) {
AfxMessageBox(_T("AfxSocketInit failed!"));
return FALSE;
}
PreProcessCommandLine();
- if(IsIniValid())
+ if(IsIniValid()) {
StoreSettingsToIni();
- else
+ } else {
StoreSettingsToRegistry();
+ }
m_s.ParseCommandLine(m_cmdln);
- if(m_s.nCLSwitches&(CLSW_HELP|CLSW_UNRECOGNIZEDSWITCH))
- {
+ if(m_s.nCLSwitches&(CLSW_HELP|CLSW_UNRECOGNIZEDSWITCH)) {
m_s.UpdateData(false);
ShowCmdlnSwitches();
return FALSE;
}
- if((m_s.nCLSwitches&CLSW_CLOSE) && m_s.slFiles.IsEmpty())
- {
+ if((m_s.nCLSwitches&CLSW_CLOSE) && m_s.slFiles.IsEmpty()) {
return FALSE;
}
m_s.UpdateData(false);
- if((m_s.nCLSwitches&CLSW_REGEXTVID) || (m_s.nCLSwitches&CLSW_REGEXTAUD))
- {
+ if((m_s.nCLSwitches&CLSW_REGEXTVID) || (m_s.nCLSwitches&CLSW_REGEXTAUD)) {
CMediaFormats& mf = m_s.m_Formats;
- for(int i = 0; i < (int)mf.GetCount(); i++)
- {
- if(!mf[i].GetLabel().CompareNoCase(ResStr(IDS_AG_PLAYLIST_FILE))) continue;
+ for(int i = 0; i < (int)mf.GetCount(); i++) {
+ if(!mf[i].GetLabel().CompareNoCase(ResStr(IDS_AG_PLAYLIST_FILE))) {
+ continue;
+ }
bool fAudioOnly = 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) && !fAudioOnly) || ((m_s.nCLSwitches&CLSW_REGEXTAUD) && fAudioOnly))
- {
+ for(CString ext = str.Tokenize(_T(" "), j); !ext.IsEmpty(); ext = str.Tokenize(_T(" "), j)) {
+ if(((m_s.nCLSwitches&CLSW_REGEXTVID) && !fAudioOnly) || ((m_s.nCLSwitches&CLSW_REGEXTAUD) && fAudioOnly)) {
CPPageFormats::RegisterExt(ext, mf[i].GetLabel(), true);
}
}
@@ -975,16 +988,13 @@ BOOL CMPlayerCApp::InitInstance()
return FALSE;
}
- if((m_s.nCLSwitches&CLSW_UNREGEXT))
- {
+ if((m_s.nCLSwitches&CLSW_UNREGEXT)) {
CMediaFormats& mf = m_s.m_Formats;
- for(int i = 0; i < (int)mf.GetCount(); i++)
- {
+ for(int i = 0; i < (int)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))
- {
+ for(CString ext = str.Tokenize(_T(" "), j); !ext.IsEmpty(); ext = str.Tokenize(_T(" "), j)) {
CPPageFormats::RegisterExt(ext, mf[i].GetLabel(), false);
}
}
@@ -994,20 +1004,17 @@ BOOL CMPlayerCApp::InitInstance()
}
// Enable to open options with administrator privilege (for Vista UAC)
- if (m_s.nCLSwitches & CLSW_ADMINOPTION)
- {
- switch (m_s.iAdminOption)
- {
- case CPPageFormats::IDD :
- {
- CPPageSheet options(ResStr(IDS_OPTIONS_CAPTION), NULL, NULL, m_s.iAdminOption);
- options.LockPage();
- options.DoModal();
- }
- break;
+ if (m_s.nCLSwitches & CLSW_ADMINOPTION) {
+ 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);
+ default :
+ ASSERT (FALSE);
}
return FALSE;
}
@@ -1016,21 +1023,19 @@ BOOL CMPlayerCApp::InitInstance()
if(GetLastError() == ERROR_ALREADY_EXISTS
&& (!(m_s.fAllowMultipleInst || (m_s.nCLSwitches&CLSW_NEW) || m_cmdln.IsEmpty())
- || (m_s.nCLSwitches&CLSW_ADD)))
- {
+ || (m_s.nCLSwitches&CLSW_ADD))) {
int wait_count = 0;
HWND hWnd = ::FindWindow(MPC_WND_CLASS_NAME, NULL);
- while(!hWnd && (wait_count++<200))
- {
+ while(!hWnd && (wait_count++<200)) {
Sleep(100);
hWnd = ::FindWindow(MPC_WND_CLASS_NAME, NULL);
}
- if(hWnd && (wait_count<200))
- {
+ if(hWnd && (wait_count<200)) {
SetForegroundWindow(hWnd);
- if(!(m_s.nCLSwitches&CLSW_MINIMIZED) && IsIconic(hWnd))
+ if(!(m_s.nCLSwitches&CLSW_MINIMIZED) && IsIconic(hWnd)) {
ShowWindow(hWnd, SW_RESTORE);
+ }
SendCommandLine(hWnd);
@@ -1040,15 +1045,13 @@ BOOL CMPlayerCApp::InitInstance()
AfxGetMyApp()->m_AudioRendererDisplayName_CL = _T("");
- if(!__super::InitInstance())
- {
+ 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")))
- {
+ 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();
@@ -1059,8 +1062,7 @@ BOOL CMPlayerCApp::InitInstance()
CMainFrame* pFrame = DNew CMainFrame;
m_pMainWnd = pFrame;
- if ( !pFrame->LoadFrame(IDR_MAINFRAME, WS_OVERLAPPEDWINDOW|FWS_ADDTOTITLE, NULL, NULL) )
- {
+ if ( !pFrame->LoadFrame(IDR_MAINFRAME, WS_OVERLAPPEDWINDOW|FWS_ADDTOTITLE, NULL, NULL) ) {
AfxMessageBox(_T("CMainFrame::LoadFrame failed!"));
return FALSE;
}
@@ -1072,9 +1074,13 @@ BOOL CMPlayerCApp::InitInstance()
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);
+ 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);
+ if(m_s.fUIce) {
+ m_s.UIceClient.Connect(m_s.strUIceAddr);
+ }
SendCommandLine(m_pMainWnd->m_hWnd);
RegisterHotkeys();
@@ -1092,14 +1098,11 @@ UINT CMPlayerCApp::GetRemoteControlCodeMicrosoft(UINT nInputcode, HRAWINPUT hRaw
// Support for MCE remote control
GetRawInputData(hRawInput, RID_INPUT, NULL, &dwSize, sizeof(RAWINPUTHEADER));
- if (dwSize > 0)
- {
+ if (dwSize > 0) {
pRawBuffer = DNew BYTE[dwSize];
- if (GetRawInputData(hRawInput, RID_INPUT, pRawBuffer, &dwSize, sizeof(RAWINPUTHEADER)) != -1)
- {
+ if (GetRawInputData(hRawInput, RID_INPUT, pRawBuffer, &dwSize, sizeof(RAWINPUTHEADER)) != -1) {
RAWINPUT* raw = (RAWINPUT*) pRawBuffer;
- if(raw->header.dwType == RIM_TYPEHID)
- {
+ if(raw->header.dwType == RIM_TYPEHID) {
nMceCmd = 0x10000 + (raw->data.hid.bRawData[1] | raw->data.hid.bRawData[2] << 8);
}
}
@@ -1116,49 +1119,45 @@ UINT CMPlayerCApp::GetRemoteControlCodeSRM7500(UINT nInputcode, HRAWINPUT hRawIn
UINT nMceCmd = 0;
GetRawInputData(hRawInput, RID_INPUT, NULL, &dwSize, sizeof(RAWINPUTHEADER));
- if (dwSize > 21)
- {
+ if (dwSize > 21) {
pRawBuffer = DNew BYTE[dwSize];
- if (GetRawInputData(hRawInput, RID_INPUT, pRawBuffer, &dwSize, sizeof(RAWINPUTHEADER)) != -1)
- {
+ 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)
- {
+ 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;
+ 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;
}
}
}
@@ -1173,8 +1172,7 @@ void CMPlayerCApp::RegisterHotkeys()
RAWINPUTDEVICELIST InputDeviceList[50];
UINT nInputDeviceCount = countof(InputDeviceList);
RID_DEVICE_INFO DevInfo;
- RAWINPUTDEVICE MCEInputDevice[] =
- {
+ RAWINPUTDEVICE MCEInputDevice[] = {
// usUsagePage usUsage dwFlags hwndTarget
{ 0xFFBC, 0x88, 0, NULL},
{ 0x000C, 0x01, 0, NULL},
@@ -1182,18 +1180,16 @@ void CMPlayerCApp::RegisterHotkeys()
};
// Register MCE Remote Control raw input
- for (int i=0; i<countof(MCEInputDevice); i++)
+ for (int i=0; i<countof(MCEInputDevice); i++) {
MCEInputDevice[i].hwndTarget = m_pMainWnd->m_hWnd;
+ }
nInputDeviceCount = GetRawInputDeviceList (InputDeviceList, &nInputDeviceCount, sizeof(RAWINPUTDEVICELIST));
- for (int i=0; i<nInputDeviceCount; i++)
- {
+ for (int i=0; i<nInputDeviceCount; i++) {
UINT nTemp = sizeof(DevInfo);
- if (GetRawInputDeviceInfo (InputDeviceList[i].hDevice, RIDI_DEVICEINFO, &DevInfo, &nTemp)>0)
- {
+ 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)
- {
+ 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;
@@ -1205,74 +1201,71 @@ void CMPlayerCApp::RegisterHotkeys()
RegisterRawInputDevices (MCEInputDevice, countof(MCEInputDevice), sizeof(RAWINPUTDEVICE));
- if (m_s.fGlobalMedia)
- {
+ if (m_s.fGlobalMedia) {
POSITION pos = m_s.wmcmds.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
wmcmd& wc = m_s.wmcmds.GetNext(pos);
- if (wc.appcmd != 0)
+ if (wc.appcmd != 0) {
RegisterHotKey(m_pMainWnd->m_hWnd, wc.appcmd, 0, GetVKFromAppCommand (wc.appcmd));
+ }
}
}
}
void CMPlayerCApp::UnregisterHotkeys()
{
- if (m_s.fGlobalMedia)
- {
+ if (m_s.fGlobalMedia) {
POSITION pos = m_s.wmcmds.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
wmcmd& wc = m_s.wmcmds.GetNext(pos);
- if (wc.appcmd != 0)
+ 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;
+ 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;
@@ -1321,14 +1314,12 @@ void CRemoteCtrlClient::Connect(CString addr)
{
CAutoLock cAutoLock(&m_csLock);
- if(m_nStatus == CONNECTING && m_addr == addr)
- {
+ 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)
- {
+ if(m_nStatus == CONNECTED && m_addr == addr) {
TRACE(_T("CRemoteCtrlClient (Connect): already connected to %s\n"), addr);
return;
}
@@ -1362,8 +1353,7 @@ void CRemoteCtrlClient::OnClose(int nErrorCode)
{
CAutoLock cAutoLock(&m_csLock);
- if(m_hSocket != INVALID_SOCKET && m_nStatus == CONNECTED)
- {
+ if(m_hSocket != INVALID_SOCKET && m_nStatus == CONNECTED) {
TRACE(_T("CRemoteCtrlClient (OnClose): connection lost\n"));
}
@@ -1374,11 +1364,15 @@ void CRemoteCtrlClient::OnClose(int 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;
+ if(ret <= 0) {
+ return;
+ }
str.ReleaseBuffer(ret);
TRACE(_T("CRemoteCtrlClient (OnReceive): %s\n"), CString(str));
@@ -1391,20 +1385,20 @@ void CRemoteCtrlClient::OnReceive(int nErrorCode)
void CRemoteCtrlClient::ExecuteCommand(CStringA cmd, int repcnt)
{
cmd.Trim();
- if(cmd.IsEmpty()) return;
+ if(cmd.IsEmpty()) {
+ return;
+ }
cmd.Replace(' ', '_');
CAppSettings& s = AfxGetAppSettings();
POSITION pos = s.wmcmds.GetHeadPosition();
- while(pos)
- {
+ 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)))
- {
+ && (!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);
@@ -1426,12 +1420,12 @@ void CWinLircClient::OnCommand(CStringA str)
int i = 0, j = 0, repcnt = 0;
for(CStringA token = str.Tokenize(" ", i);
!token.IsEmpty();
- token = str.Tokenize(" ", i), j++)
- {
- if(j == 1)
+ token = str.Tokenize(" ", i), j++) {
+ if(j == 1) {
repcnt = strtol(token, NULL, 16);
- else if(j == 2)
+ } else if(j == 2) {
ExecuteCommand(token, repcnt);
+ }
}
}
@@ -1449,12 +1443,12 @@ void CUIceClient::OnCommand(CStringA str)
int i = 0, j = 0;
for(CStringA token = str.Tokenize("|", i);
!token.IsEmpty();
- token = str.Tokenize("|", i), j++)
- {
- if(j == 0)
+ token = str.Tokenize("|", i), j++) {
+ if(j == 0) {
cmd = token;
- else if(j == 1)
+ } else if(j == 1) {
ExecuteCommand(cmd, strtol(token, NULL, 16));
+ }
}
}
@@ -1468,16 +1462,14 @@ void GetCurDispMode(dispmode& dm, CString& DisplayName)
{
HDC hDC;
CString DisplayName1 = DisplayName;
- if ((DisplayName == _T("Current")) || (DisplayName == _T("")))
- {
+ 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)
- {
+ if(hDC) {
dm.fValid = true;
dm.size = CSize(GetDeviceCaps(hDC, HORZRES), GetDeviceCaps(hDC, VERTRES));
dm.bpp = GetDeviceCaps(hDC, BITSPIXEL);
@@ -1491,15 +1483,15 @@ bool GetDispMode(int i, dispmode& dm, CString& DisplayName)
DEVMODE devmode;
CString DisplayName1 = DisplayName;
devmode.dmSize = sizeof(DEVMODE);
- if ((DisplayName == _T("Current")) || (DisplayName == _T("")))
- {
+ if ((DisplayName == _T("Current")) || (DisplayName == _T(""))) {
CMonitor monitor;
CMonitors monitors;
monitor = monitors.GetNearestMonitor(AfxGetApp()->m_pMainWnd);
monitor.GetName(DisplayName1);
}
- if(!EnumDisplaySettings(DisplayName1, i, &devmode))
+ if(!EnumDisplaySettings(DisplayName1, i, &devmode)) {
return(false);
+ }
dm.fValid = true;
dm.size = CSize(devmode.dmPelsWidth, devmode.dmPelsHeight);
dm.bpp = devmode.dmBitsPerPel;
@@ -1512,9 +1504,13 @@ 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.size == dm1.size) && (dm.bpp == dm1.bpp) && (dm.freq == dm1.freq)) {
+ return;
+ }
- if(!dm.fValid) return;
+ if(!dm.fValid) {
+ return;
+ }
DEVMODE dmScreenSettings;
memset(&dmScreenSettings, 0, sizeof(dmScreenSettings));
dmScreenSettings.dmSize = sizeof(dmScreenSettings);
@@ -1525,17 +1521,17 @@ void SetDispMode(dispmode& dm, CString& DisplayName)
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("")))
- {
+ if ((DisplayName == _T("Current")) || (DisplayName == _T(""))) {
CMonitor monitor;
CMonitors monitors;
monitor = monitors.GetNearestMonitor(AfxGetApp()->m_pMainWnd);
monitor.GetName(DisplayName1);
}
- if(AfxGetAppSettings().fRestoreResAfterExit)
+ if(AfxGetAppSettings().fRestoreResAfterExit) {
ChangeDisplaySettingsEx(DisplayName1, &dmScreenSettings, NULL, CDS_FULLSCREEN, NULL);
- else
+ } else {
ChangeDisplaySettingsEx(DisplayName1, &dmScreenSettings, NULL, NULL, NULL);
+ }
}
void SetAudioRenderer(int AudioDevNo)
@@ -1545,11 +1541,11 @@ void SetAudioRenderer(int AudioDevNo)
m_AudioRendererDisplayNames.Add(_T(""));
int i=2;
- BeginEnumSysDev(CLSID_AudioRendererCategory, pMoniker)
- {
+ BeginEnumSysDev(CLSID_AudioRendererCategory, pMoniker) {
LPOLESTR olestr = NULL;
- if(FAILED(pMoniker->GetDisplayName(0, 0, &olestr)))
+ if(FAILED(pMoniker->GetDisplayName(0, 0, &olestr))) {
continue;
+ }
CStringW str(olestr);
CoTaskMemFree(olestr);
m_AudioRendererDisplayNames.Add(CString(str));
@@ -1561,8 +1557,9 @@ void SetAudioRenderer(int AudioDevNo)
m_AudioRendererDisplayNames.Add(AUDRNDT_NULL_UNCOMP);
m_AudioRendererDisplayNames.Add(AUDRNDT_MPC);
i+=3;
- if (AudioDevNo>=1 && AudioDevNo<=i)
+ if (AudioDevNo>=1 && AudioDevNo<=i) {
AfxGetMyApp()->m_AudioRendererDisplayName_CL = m_AudioRendererDisplayNames[AudioDevNo-1];
+ }
}
void SetHandCursor(HWND m_hWnd, UINT nID)
@@ -1581,15 +1578,13 @@ typedef CAtlREMatchContext<CAtlRECharTraits> CAtlREMatchContextT;
bool FindRedir(CUrl& src, CString ct, CString& body, CAtlList<CString>& urls, CAutoPtrList<CAtlRegExpT>& res)
{
POSITION pos = res.GetHeadPosition();
- while(pos)
- {
+ 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)
- {
+ for(; s && re->Match(s, &mc, &e); s = e) {
const CAtlREMatchContextT::RECHAR* szStart = 0;
const CAtlREMatchContextT::RECHAR* szEnd = 0;
mc.GetMatch(0, &szStart, &szEnd);
@@ -1598,18 +1593,17 @@ bool FindRedir(CUrl& src, CString ct, CString& body, CAtlList<CString>& urls, CA
url.Format(_T("%.*s"), szEnd - szStart, szStart);
url.Trim();
- if(url.CompareNoCase(_T("asf path")) == 0) continue;
+ 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()))
- {
+ || _tcsicmp(src.GetUrlPath(), dst.GetUrlPath())) {
urls.AddTail(url);
- }
- else
- {
+ } else {
// recursive
urls.RemoveAll();
break;
@@ -1625,20 +1619,20 @@ bool FindRedir(CString& fn, CString ct, CAtlList<CString>& fns, CAutoPtrList<CAt
CString body;
CTextFile f(CTextFile::ANSI);
- if(f.Open(fn)) for(CString tmp; f.ReadString(tmp); body += tmp + '\n');
+ if(f.Open(fn)) for(CString tmp; f.ReadString(tmp); body += tmp + '\n') {
+ ;
+ }
CString dir = fn.Left(max(fn.ReverseFind('/'), fn.ReverseFind('\\'))+1); // "ReverseFindOneOf"
POSITION pos = res.GetHeadPosition();
- while(pos)
- {
+ 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)
- {
+ for(; s && re->Match(s, &mc, &e); s = e) {
const CAtlREMatchContextT::RECHAR* szStart = 0;
const CAtlREMatchContextT::RECHAR* szEnd = 0;
mc.GetMatch(0, &szStart, &szEnd);
@@ -1647,18 +1641,22 @@ bool FindRedir(CString& fn, CString ct, CAtlList<CString>& fns, CAutoPtrList<CAt
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)
- {
+ 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))
+ if(!fn2.CompareNoCase(fn)) {
continue;
+ }
fns.AddTail(fn2);
}
@@ -1672,18 +1670,20 @@ CStringA GetContentType(CString fn, CAtlList<CString>* redir)
CUrl url;
CString ct, body;
- if(fn.Find(_T("://")) >= 0)
- {
+ if(fn.Find(_T("://")) >= 0) {
url.CrackUrl(fn);
- if(_tcsicmp(url.GetSchemeName(), _T("pnm")) == 0)
+ if(_tcsicmp(url.GetSchemeName(), _T("pnm")) == 0) {
return "audio/x-pn-realaudio";
+ }
- if(_tcsicmp(url.GetSchemeName(), _T("mms")) == 0)
+ if(_tcsicmp(url.GetSchemeName(), _T("mms")) == 0) {
return "video/x-ms-asf";
+ }
- if(_tcsicmp(url.GetSchemeName(), _T("http")) != 0)
+ if(_tcsicmp(url.GetSchemeName(), _T("http")) != 0) {
return "";
+ }
DWORD ProxyEnable = 0;
CString ProxyServer;
@@ -1693,21 +1693,17 @@ CStringA GetContentType(CString fn, CAtlList<CString>* redir)
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))
- {
+ && ERROR_SUCCESS == key.QueryStringValue(_T("ProxyServer"), ProxyServer.GetBufferSetLength(256), &len)) {
ProxyServer.ReleaseBufferSetLength(len);
CAtlList<CString> sl;
ProxyServer = Explode(ProxyServer, sl, ';');
- if(sl.GetCount() > 1)
- {
+ if(sl.GetCount() > 1) {
POSITION pos = sl.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CAtlList<CString> sl2;
if(!Explode(sl.GetNext(pos), sl2, '=', 2).CompareNoCase(_T("http"))
- && sl2.GetCount() == 2)
- {
+ && sl2.GetCount() == 2) {
ProxyServer = sl2.GetTail();
break;
}
@@ -1715,19 +1711,22 @@ CStringA GetContentType(CString fn, CAtlList<CString>* redir)
}
ProxyServer = Explode(ProxyServer, sl, ':');
- if(sl.GetCount() > 1) ProxyPort = _tcstol(sl.GetTail(), NULL, 10);
+ 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()))
- {
+ ProxyEnable ? ProxyPort : url.GetPortNumber())) {
CStringA host = CStringA(url.GetHostName());
CStringA path = CStringA(url.GetUrlPath()) + CStringA(url.GetExtraInfo());
- if(ProxyEnable) path = "http://" + host + path;
+ if(ProxyEnable) {
+ path = "http://" + host + path;
+ }
CStringA hdr;
hdr.Format(
@@ -1737,89 +1736,100 @@ CStringA GetContentType(CString fn, CAtlList<CString>* redir)
"Accept: */*\r\n"
"\r\n", path, host);
-// MessageBox(NULL, CString(hdr), _T("Sending..."), MB_OK);
+ // MessageBox(NULL, CString(hdr), _T("Sending..."), MB_OK);
- if(s.Send((LPCSTR)hdr, hdr.GetLength()) < hdr.GetLength()) return "";
+ if(s.Send((LPCSTR)hdr, hdr.GetLength()) < hdr.GetLength()) {
+ return "";
+ }
hdr.Empty();
- while(1)
- {
+ while(1) {
CStringA str;
str.ReleaseBuffer(s.Receive(str.GetBuffer(256), 256)); // SOCKET_ERROR == -1, also suitable for ReleaseBuffer
- if(str.IsEmpty()) break;
+ if(str.IsEmpty()) {
+ break;
+ }
hdr += str;
int hdrend = hdr.Find("\r\n\r\n");
- if(hdrend >= 0)
- {
+ if(hdrend >= 0) {
body = hdr.Mid(hdrend+4);
hdr = hdr.Left(hdrend);
break;
}
}
-// MessageBox(NULL, CString(hdr), _T("Received..."), MB_OK);
+ // MessageBox(NULL, CString(hdr), _T("Received..."), MB_OK);
CAtlList<CStringA> sl;
Explode(hdr, sl, '\n');
POSITION pos = sl.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CStringA& hdrline = sl.GetNext(pos);
CAtlList<CStringA> sl2;
Explode(hdrline, sl2, ':', 2);
CStringA field = sl2.RemoveHead().MakeLower();
- if(field == "location" && !sl2.IsEmpty())
+ if(field == "location" && !sl2.IsEmpty()) {
return GetContentType(CString(sl2.GetHead()), redir);
- if(field == "content-type" && !sl2.IsEmpty())
+ }
+ if(field == "content-type" && !sl2.IsEmpty()) {
ct = sl2.GetHead();
+ }
}
- while(body.GetLength() < 256)
- {
+ 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;
+ if(str.IsEmpty()) {
+ break;
+ }
body += str;
}
- if(body.GetLength() >= 8)
- {
+ if(body.GetLength() >= 8) {
CStringA str = TToA(body);
- if(!strncmp((LPCSTR)str, ".ra", 3))
+ if(!strncmp((LPCSTR)str, ".ra", 3)) {
return "audio/x-pn-realaudio";
- if(!strncmp((LPCSTR)str, ".RMF", 4))
+ }
+ if(!strncmp((LPCSTR)str, ".RMF", 4)) {
return "audio/x-pn-realaudio";
- if(*(DWORD*)(LPCSTR)str == 0x75b22630)
+ }
+ if(*(DWORD*)(LPCSTR)str == 0x75b22630) {
return "video/x-ms-wmv";
- if(!strncmp((LPCSTR)str+4, "moov", 4))
+ }
+ 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...
- {
+ 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;
+ if(str.IsEmpty()) {
+ break;
+ }
body += str;
}
}
}
- }
- else if(!fn.IsEmpty())
- {
+ } 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")) 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");
-
- if(FILE* f = _tfopen(fn, _T("rb")))
- {
+ 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")) {
+ 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");
+ }
+
+ if(FILE* f = _tfopen(fn, _T("rb"))) {
CStringA str;
str.ReleaseBufferSetLength(fread(str.GetBuffer(10240), 1, 10240, f));
body = AToT(str);
@@ -1827,59 +1837,59 @@ CStringA GetContentType(CString fn, CAtlList<CString>* redir)
}
}
- if(body.GetLength() >= 4) // here only those which cannot be opened through dshow
- {
+ if(body.GetLength() >= 4) { // here only those which cannot be opened through dshow
CStringA str = TToA(body);
- if(!strncmp((LPCSTR)str, ".ra", 3))
+ if(!strncmp((LPCSTR)str, ".ra", 3)) {
return "audio/x-pn-realaudio";
- if(!strncmp((LPCSTR)str, "FWS", 3))
+ }
+ if(!strncmp((LPCSTR)str, "FWS", 3)) {
return "application/x-shockwave-flash";
+ }
}
- if(redir && !ct.IsEmpty())
- {
+ if(redir && !ct.IsEmpty()) {
CAutoPtrList<CAtlRegExpT> res;
CAutoPtr<CAtlRegExpT> re;
- if(ct == _T("video/x-ms-asf"))
- {
+ if(ct == _T("video/x-ms-asf")) {
// ...://..."/>
re.Attach(DNew CAtlRegExpT());
- if(re && REPARSE_ERROR_OK == re->Parse(_T("{[a-zA-Z]+://[^\n\">]*}"), FALSE))
+ 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))
+ 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"))
- {
+ }
+ } 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))
+ if(re && REPARSE_ERROR_OK == re->Parse(_T("file\\z\\b*=\\b*[\"]*{[^\n\"]+}"), FALSE)) {
res.AddTail(re);
- }
- else if(ct == _T("audio/x-mpegurl"))
- {
+ }
+ } else if(ct == _T("audio/x-mpegurl")) {
// #comment
// ...
re.Attach(DNew CAtlRegExp<>());
- if(re && REPARSE_ERROR_OK == re->Parse(_T("{[^#][^\n]+}"), FALSE))
+ if(re && REPARSE_ERROR_OK == re->Parse(_T("{[^#][^\n]+}"), FALSE)) {
res.AddTail(re);
- }
- else if(ct == _T("audio/x-pn-realaudio"))
- {
+ }
+ } else if(ct == _T("audio/x-pn-realaudio")) {
// rtsp://...
re.Attach(DNew CAtlRegExp<>());
- if(re && REPARSE_ERROR_OK == re->Parse(_T("{rtsp://[^\n]+}"), FALSE))
+ 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);
+ if(!body.IsEmpty()) {
+ if(fn.Find(_T("://")) >= 0) {
+ FindRedir(url, ct, body, *redir, res);
+ } else {
+ FindRedir(fn, ct, *redir, res);
+ }
}
}
@@ -1888,16 +1898,15 @@ CStringA GetContentType(CString fn, CAtlList<CString>* redir)
COLORPROPERTY_RANGE* CMPlayerCApp::GetColorControl(ControlType nFlag)
{
- switch (nFlag)
- {
- case Brightness :
- return &m_ColorControl[0];
- case Contrast :
- return &m_ColorControl[1];
- case Hue :
- return &m_ColorControl[2];
- case Saturation :
- return &m_ColorControl[3];
+ switch (nFlag) {
+ case Brightness :
+ return &m_ColorControl[0];
+ case Contrast :
+ return &m_ColorControl[1];
+ case Hue :
+ return &m_ColorControl[2];
+ case Saturation :
+ return &m_ColorControl[3];
}
return NULL;
}
@@ -1905,102 +1914,100 @@ COLORPROPERTY_RANGE* CMPlayerCApp::GetColorControl(ControlType nFlag)
LPCTSTR CMPlayerCApp::GetSatelliteDll(int nLanguage)
{
- switch (nLanguage)
- {
- case 1: // French
- return _T("mpcresources.fr.dll");
- case 2: // German
- return _T("mpcresources.de.dll");
- case 3: // Russian
- return _T("mpcresources.ru.dll");
- case 4: // Turkish
- return _T("mpcresources.tr.dll");
- case 5: // Czech
- return _T("mpcresources.cz.dll");
- case 6: // Spanish
- return _T("mpcresources.es.dll");
- case 7: // Hungarian
- return _T("mpcresources.hu.dll");
- case 8: // Korean
- return _T("mpcresources.kr.dll");
- case 9: // Polish
- return _T("mpcresources.pl.dll");
- case 10: // Ukrainian
- return _T("mpcresources.ua.dll");
- case 11: // Italian
- return _T("mpcresources.it.dll");
- case 12 : // Slovak
- return _T("mpcresources.sk.dll");
- case 13 : // Chinese (Simplified)
- return _T("mpcresources.sc.dll");
- case 14 : // Chinese (Traditional)
- return _T("mpcresources.tc.dll");
- case 15 : // Belarusian
- return _T("mpcresources.by.dll");
- case 16 : // Swedish
- return _T("mpcresources.sv.dll");
- case 17 : // Portuguese (Brasil)
- return _T("mpcresources.br.dll");
- case 18 : // Dutch
- return _T("mpcresources.nl.dll");
- case 19 : // Catalan
- return _T("mpcresources.ca.dll");
- case 20 : // Japanese
- return _T("mpcresources.ja.dll");
- case 21 : // Armenian
- return _T("mpcresources.hy.dll");
+ switch (nLanguage) {
+ case 1: // French
+ return _T("mpcresources.fr.dll");
+ case 2: // German
+ return _T("mpcresources.de.dll");
+ case 3: // Russian
+ return _T("mpcresources.ru.dll");
+ case 4: // Turkish
+ return _T("mpcresources.tr.dll");
+ case 5: // Czech
+ return _T("mpcresources.cz.dll");
+ case 6: // Spanish
+ return _T("mpcresources.es.dll");
+ case 7: // Hungarian
+ return _T("mpcresources.hu.dll");
+ case 8: // Korean
+ return _T("mpcresources.kr.dll");
+ case 9: // Polish
+ return _T("mpcresources.pl.dll");
+ case 10: // Ukrainian
+ return _T("mpcresources.ua.dll");
+ case 11: // Italian
+ return _T("mpcresources.it.dll");
+ case 12 : // Slovak
+ return _T("mpcresources.sk.dll");
+ case 13 : // Chinese (Simplified)
+ return _T("mpcresources.sc.dll");
+ case 14 : // Chinese (Traditional)
+ return _T("mpcresources.tc.dll");
+ case 15 : // Belarusian
+ return _T("mpcresources.by.dll");
+ case 16 : // Swedish
+ return _T("mpcresources.sv.dll");
+ case 17 : // Portuguese (Brasil)
+ return _T("mpcresources.br.dll");
+ case 18 : // Dutch
+ return _T("mpcresources.nl.dll");
+ case 19 : // Catalan
+ return _T("mpcresources.ca.dll");
+ case 20 : // Japanese
+ return _T("mpcresources.ja.dll");
+ case 21 : // Armenian
+ return _T("mpcresources.hy.dll");
}
return NULL;
}
int CMPlayerCApp::GetDefLanguage()
{
- switch (GetUserDefaultUILanguage())
- {
- case 1036: // French
- return 1;
- case 1031: // German
- return 2;
- case 1049: // Russian
- return 3;
- case 1055: // Turkish
- return 4;
- case 1029: // Czech
- return 5;
- case 1034: // Spanish
- return 6;
- case 1038: // Hungarian
- return 7;
- case 1042: // Korean
- return 8;
- case 1045: // Polish
- return 9;
- case 1058: // Ukrainian
- return 10;
- case 1040: // Italian
- return 11;
- case 1051 : // Slovak
- return 12;
- case 2052 : // Chinese (simplified)
- return 13;
- case 3076 : // Chinese (traditional)
- return 14;
- case 1059 : // Belarusian
- return 15;
- case 1053 : // Swedish
- return 16;
- case 1046 : // Portuguese (brasil)
- return 17;
- case 1043 : // Dutch
- return 18;
- case 1027 : // Catalan
- return 19;
- case 1041 : // Japanese
- return 20;
- case 1067 : // Armenian
- return 21;
- default:
- return 0;
+ switch (GetUserDefaultUILanguage()) {
+ case 1036: // French
+ return 1;
+ case 1031: // German
+ return 2;
+ case 1049: // Russian
+ return 3;
+ case 1055: // Turkish
+ return 4;
+ case 1029: // Czech
+ return 5;
+ case 1034: // Spanish
+ return 6;
+ case 1038: // Hungarian
+ return 7;
+ case 1042: // Korean
+ return 8;
+ case 1045: // Polish
+ return 9;
+ case 1058: // Ukrainian
+ return 10;
+ case 1040: // Italian
+ return 11;
+ case 1051 : // Slovak
+ return 12;
+ case 2052 : // Chinese (simplified)
+ return 13;
+ case 3076 : // Chinese (traditional)
+ return 14;
+ case 1059 : // Belarusian
+ return 15;
+ case 1053 : // Swedish
+ return 16;
+ case 1046 : // Portuguese (brasil)
+ return 17;
+ case 1043 : // Dutch
+ return 18;
+ case 1027 : // Catalan
+ return 19;
+ case 1041 : // Japanese
+ return 20;
+ case 1067 : // Armenian
+ return 21;
+ default:
+ return 0;
}
}
@@ -2011,13 +2018,11 @@ void CMPlayerCApp::SetLanguage (int nLanguage)
LPCTSTR strSatellite;
strSatellite = GetSatelliteDll( nLanguage );
- if ( strSatellite )
- {
+ if ( strSatellite ) {
CFileVersionInfo Version;
CString strSatVersion;
- if ( Version.Create(strSatellite) )
- {
+ if ( Version.Create(strSatellite) ) {
strSatVersion = Version.GetFileVersionEx();
CString needVersion = L"";
@@ -2026,13 +2031,10 @@ void CMPlayerCApp::SetLanguage (int nLanguage)
needVersion += MAKE_STR(MPC_VERSION_MINOR);
needVersion += L".0.0";
- if ( strSatVersion == needVersion )
- {
+ if ( strSatVersion == needVersion ) {
hMod = LoadLibrary( strSatellite );
s.iLanguage = nLanguage;
- }
- else
- {
+ } else {
// 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_OK);
@@ -2040,13 +2042,11 @@ void CMPlayerCApp::SetLanguage (int nLanguage)
}
}
- if ( hMod == NULL )
- {
+ if ( hMod == NULL ) {
hMod = AfxGetApp()->m_hInstance;
s.iLanguage = 0;
}
- if (AfxGetResourceHandle() != AfxGetApp()->m_hInstance)
- {
+ if (AfxGetResourceHandle() != AfxGetApp()->m_hInstance) {
FreeLibrary(AfxGetResourceHandle());
}
AfxSetResourceHandle( hMod );
@@ -2056,8 +2056,7 @@ bool CMPlayerCApp::IsVSFilterInstalled()
{
bool result = false;
CRegKey key;
- if(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("CLSID\\{083863F1-70DE-11d0-BD40-00A0C911CE86}\\Instance\\{9852A670-F845-491B-9BE6-EBD841B8A613}"), KEY_READ))
- {
+ if(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("CLSID\\{083863F1-70DE-11d0-BD40-00A0C911CE86}\\Instance\\{9852A670-F845-491B-9BE6-EBD841B8A613}"), KEY_READ)) {
result = true;
}
@@ -2068,8 +2067,7 @@ bool CMPlayerCApp::HasEVR()
{
bool result = false;
CRegKey key;
- if(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("CLSID\\{083863F1-70DE-11d0-BD40-00A0C911CE86}\\Instance\\{FA10746C-9B63-4B6C-BC49-FC300EA5F256}"), KEY_READ))
- {
+ if(ERROR_SUCCESS == key.Open(HKEY_CLASSES_ROOT, _T("CLSID\\{083863F1-70DE-11d0-BD40-00A0C911CE86}\\Instance\\{FA10746C-9B63-4B6C-BC49-FC300EA5F256}"), KEY_READ)) {
result = true;
}
@@ -2087,8 +2085,7 @@ HRESULT CMPlayerCApp::GetElevationType(TOKEN_ELEVATION_TYPE* ptet )
if ( !::OpenProcessToken(
::GetCurrentProcess(),
TOKEN_QUERY,
- &hToken ) )
- {
+ &hToken ) ) {
ASSERT( FALSE );
return hResult;
}
@@ -2100,12 +2097,9 @@ HRESULT CMPlayerCApp::GetElevationType(TOKEN_ELEVATION_TYPE* ptet )
TokenElevationType,
ptet,
sizeof( *ptet ),
- &dwReturnLength ) )
- {
+ &dwReturnLength ) ) {
ASSERT( FALSE );
- }
- else
- {
+ } else {
ASSERT( dwReturnLength == sizeof( *ptet ) );
hResult = S_OK;
}
@@ -2128,8 +2122,9 @@ void CMPlayerCApp::RunAsAdministrator(LPCTSTR strCommand, LPCTSTR strArgs, bool
ShellExecuteEx(&execinfo);
- if (bWaitProcess)
+ if (bWaitProcess) {
WaitForSingleObject(execinfo.hProcess, INFINITE);
+ }
}
void CAboutDlg::OnHomepage(NMHDR *pNMHDR, LRESULT *pResult)
diff --git a/src/apps/mplayerc/mplayerc.h b/src/apps/mplayerc/mplayerc.h
index e3c91ba27..26ceec131 100644
--- a/src/apps/mplayerc/mplayerc.h
+++ b/src/apps/mplayerc/mplayerc.h
@@ -38,8 +38,7 @@
//define the default logo we use
#define DEF_LOGO IDF_LOGO3
-enum
-{
+enum {
WM_GRAPHNOTIFY = WM_RESET_DEVICE+1,
WM_RESUMEFROMSTATE,
WM_TUNER_SCAN_PROGRESS,
@@ -62,16 +61,14 @@ extern "C" BOOL IsVistaOrAbove();
/////////////////////////////////////////////////////////////////////////////
// Casimir666
//
-typedef enum
-{
+typedef enum {
Brightness = 0x1,
Contrast = 0x2,
Hue = 0x4,
Saturation = 0x8,
} ControlType;
-typedef struct // _VMR9ProcAmpControlRange
-{
+typedef struct { // _VMR9ProcAmpControlRange
DWORD dwSize;
DWORD dwProperty;
float MinValue;
@@ -141,7 +138,7 @@ public:
void RegisterHotkeys();
void UnregisterHotkeys();
-// Overrides
+ // Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMPlayerCApp)
public:
@@ -149,7 +146,7 @@ public:
virtual int ExitInstance();
//}}AFX_VIRTUAL
-// Implementation
+ // Implementation
public:
DECLARE_MESSAGE_MAP()
diff --git a/src/apps/mplayerc/mplayerc.rc b/src/apps/mplayerc/mplayerc.rc
index e6571c0bf..d3cd20ade 100644
--- a/src/apps/mplayerc/mplayerc.rc
+++ b/src/apps/mplayerc/mplayerc.rc
Binary files differ
diff --git a/src/apps/mplayerc/resource.h b/src/apps/mplayerc/resource.h
index 599d0b830..2e7d8c12e 100644
--- a/src/apps/mplayerc/resource.h
+++ b/src/apps/mplayerc/resource.h
Binary files differ
diff --git a/src/filters/FilterApp.cpp b/src/filters/FilterApp.cpp
index 8ca000fdc..059fcda74 100644
--- a/src/filters/FilterApp.cpp
+++ b/src/filters/FilterApp.cpp
@@ -32,8 +32,9 @@ CFilterApp::CFilterApp()
BOOL CFilterApp::InitInstance()
{
- if(!__super::InitInstance())
+ if(!__super::InitInstance()) {
return FALSE;
+ }
SetRegistryKey(_T("Gabest"));
diff --git a/src/filters/InternalPropertyPage.cpp b/src/filters/InternalPropertyPage.cpp
index daeb0b339..9694d1b4c 100644
--- a/src/filters/InternalPropertyPage.cpp
+++ b/src/filters/InternalPropertyPage.cpp
@@ -37,17 +37,19 @@ CInternalPropertyPageWnd::CInternalPropertyPageWnd()
BOOL CInternalPropertyPageWnd::Create(IPropertyPageSite* pPageSite, LPCRECT pRect, CWnd* pParentWnd)
{
- if(!pPageSite || !pRect) return FALSE;
+ if(!pPageSite || !pRect) {
+ return FALSE;
+ }
m_pPageSite = pPageSite;
- if(!m_font.m_hObject)
- {
+ 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))
+ if(!AfxGetPropSheetFont(face, height, FALSE)) {
return FALSE;
+ }
LOGFONT lf;
memset(&lf, 0, sizeof(lf));
@@ -57,16 +59,17 @@ BOOL CInternalPropertyPageWnd::Create(IPropertyPageSite* pPageSite, LPCRECT pRec
::ReleaseDC(0, hDC);
lf.lfWeight = FW_NORMAL;
lf.lfCharSet = DEFAULT_CHARSET;
- if(!m_font.CreateFontIndirect(&lf))
+ if(!m_font.CreateFontIndirect(&lf)) {
return FALSE;
+ }
lf.lfHeight -= -1;
_tcscpy(lf.lfFaceName, _T("Lucida Console"));
- if(!m_monospacefont.CreateFontIndirect(&lf))
- {
+ if(!m_monospacefont.CreateFontIndirect(&lf)) {
_tcscpy(lf.lfFaceName, _T("Courier New"));
- if(!m_monospacefont.CreateFontIndirect(&lf))
+ if(!m_monospacefont.CreateFontIndirect(&lf)) {
return FALSE;
+ }
}
hDC = ::GetDC(0);
@@ -80,8 +83,9 @@ BOOL CInternalPropertyPageWnd::Create(IPropertyPageSite* pPageSite, LPCRECT pRec
}
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))
+ if(!CreateEx(0, wc, _T("CInternalPropertyPageWnd"), WS_CHILDWINDOW, *pRect, pParentWnd, 0)) {
return FALSE;
+ }
SetFont(&m_font);
@@ -90,8 +94,7 @@ BOOL CInternalPropertyPageWnd::Create(IPropertyPageSite* pPageSite, LPCRECT pRec
BOOL CInternalPropertyPageWnd::OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
- if(message == WM_COMMAND || message == WM_HSCROLL || message == WM_VSCROLL)
- {
+ if(message == WM_COMMAND || message == WM_HSCROLL || message == WM_VSCROLL) {
SetDirty(true);
}
@@ -109,13 +112,14 @@ CInternalPropertyPage::CInternalPropertyPage(LPUNKNOWN lpunk, HRESULT* phr)
: 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) {
if(m_pWnd->m_hWnd) {
ASSERT(0);
m_pWnd->DestroyWindow();
@@ -138,8 +142,9 @@ STDMETHODIMP CInternalPropertyPage::SetPageSite(IPropertyPageSite* pPageSite)
{
CAutoLock cAutoLock(this);
- if(pPageSite && m_pPageSite || !pPageSite && !m_pPageSite)
+ if(pPageSite && m_pPageSite || !pPageSite && !m_pPageSite) {
return E_UNEXPECTED;
+ }
m_pPageSite = pPageSite;
@@ -154,14 +159,15 @@ STDMETHODIMP CInternalPropertyPage::Activate(HWND hwndParent, LPCRECT pRect, BOO
CheckPointer(pRect, E_POINTER);
- if(!m_pWnd || m_pWnd->m_hWnd || m_pUnks.IsEmpty())
+ if(!m_pWnd || m_pWnd->m_hWnd || m_pUnks.IsEmpty()) {
return E_UNEXPECTED;
+ }
- if(!m_pWnd->Create(m_pPageSite, pRect, CWnd::FromHandle(hwndParent)))
+ if(!m_pWnd->Create(m_pPageSite, pRect, CWnd::FromHandle(hwndParent))) {
return E_OUTOFMEMORY;
+ }
- if(!m_pWnd->OnActivate())
- {
+ if(!m_pWnd->OnActivate()) {
m_pWnd->DestroyWindow();
return E_FAIL;
}
@@ -178,8 +184,9 @@ STDMETHODIMP CInternalPropertyPage::Deactivate()
CAutoLock cAutoLock(this);
- if(!m_pWnd || !m_pWnd->m_hWnd)
+ if(!m_pWnd || !m_pWnd->m_hWnd) {
return E_UNEXPECTED;
+ }
m_pWnd->OnDeactivate();
@@ -197,7 +204,9 @@ STDMETHODIMP CInternalPropertyPage::GetPageInfo(PROPPAGEINFO* pPageInfo)
LPOLESTR pszTitle;
HRESULT hr = AMGetWideString(CStringW(GetWindowTitle()), &pszTitle);
- if(FAILED(hr)) return hr;
+ if(FAILED(hr)) {
+ return hr;
+ }
pPageInfo->cb = sizeof(PROPPAGEINFO);
pPageInfo->pszTitle = pszTitle;
@@ -213,32 +222,31 @@ STDMETHODIMP CInternalPropertyPage::SetObjects(ULONG cObjects, LPUNKNOWN* ppUnk)
{
CAutoLock cAutoLock(this);
- if(cObjects && m_pWnd || !cObjects && !m_pWnd)
+ if(cObjects && m_pWnd || !cObjects && !m_pWnd) {
return E_UNEXPECTED;
+ }
m_pUnks.RemoveAll();
- if(cObjects > 0)
- {
+ if(cObjects > 0) {
CheckPointer(ppUnk, E_POINTER);
- for(ULONG i = 0; i < cObjects; i++)
+ for(ULONG i = 0; i < cObjects; i++) {
m_pUnks.AddTail(ppUnk[i]);
+ }
m_pWnd = GetWindow();
- if(!m_pWnd)
+ if(!m_pWnd) {
return E_OUTOFMEMORY;
+ }
- if(!m_pWnd->OnConnect(m_pUnks))
- {
+ if(!m_pWnd->OnConnect(m_pUnks)) {
delete m_pWnd;
m_pWnd = NULL;
return E_FAIL;
}
- }
- else
- {
+ } else {
m_pWnd->OnDisconnect();
m_pWnd->DestroyWindow();
@@ -255,10 +263,13 @@ STDMETHODIMP CInternalPropertyPage::Show(UINT nCmdShow)
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))
+ if((nCmdShow != SW_SHOW) && (nCmdShow != SW_SHOWNORMAL) && (nCmdShow != SW_HIDE)) {
return E_INVALIDARG;
+ }
m_pWnd->ShowWindow(nCmdShow);
m_pWnd->Invalidate();
@@ -274,7 +285,9 @@ STDMETHODIMP CInternalPropertyPage::Move(LPCRECT pRect)
CheckPointer(pRect, E_POINTER);
- if(!m_pWnd) return E_UNEXPECTED;
+ if(!m_pWnd) {
+ return E_UNEXPECTED;
+ }
m_pWnd->MoveWindow(pRect, TRUE);
@@ -294,11 +307,13 @@ STDMETHODIMP CInternalPropertyPage::Apply()
CAutoLock cAutoLock(this);
- if(!m_pWnd || m_pUnks.IsEmpty() || !m_pPageSite)
+ if(!m_pWnd || m_pUnks.IsEmpty() || !m_pPageSite) {
return E_UNEXPECTED;
+ }
- if(m_pWnd->GetDirty() && m_pWnd->OnApply())
+ if(m_pWnd->GetDirty() && m_pWnd->OnApply()) {
m_pWnd->SetDirty(false);
+ }
return S_OK;
}
diff --git a/src/filters/InternalPropertyPage.h b/src/filters/InternalPropertyPage.h
index 013db1f97..6b293be6b 100644
--- a/src/filters/InternalPropertyPage.h
+++ b/src/filters/InternalPropertyPage.h
@@ -27,8 +27,7 @@
interface __declspec(uuid("03481710-D73E-4674-839F-03EDE2D60ED8"))
ISpecifyPropertyPages2 :
-public ISpecifyPropertyPages
-{
+public ISpecifyPropertyPages {
STDMETHOD (CreatePage) (const GUID& guid, IPropertyPage** ppPage) = 0;
};
@@ -48,7 +47,9 @@ public:
void SetDirty(bool fDirty = true) {
m_fDirty = fDirty;
- if(fDirty && m_pPageSite) m_pPageSite->OnStatusChange(PROPPAGESTATUS_DIRTY);
+ if(fDirty && m_pPageSite) {
+ m_pPageSite->OnStatusChange(PROPPAGESTATUS_DIRTY);
+ }
}
bool GetDirty() {
return m_fDirty;
@@ -110,24 +111,20 @@ public:
template<class WndClass>
class CInternalPropertyPageTempl : public CInternalPropertyPage
{
- virtual CInternalPropertyPageWnd* GetWindow()
- {
+ virtual CInternalPropertyPageWnd* GetWindow() {
return DNew WndClass();
}
- virtual LPCTSTR GetWindowTitle()
- {
+ virtual LPCTSTR GetWindowTitle() {
return WndClass::GetWindowTitle();
}
- virtual CSize GetWindowSize()
- {
+ virtual CSize GetWindowSize() {
return WndClass::GetWindowSize();
}
public:
CInternalPropertyPageTempl(LPUNKNOWN lpunk, HRESULT* phr)
- : CInternalPropertyPage(lpunk, phr)
- {
+ : CInternalPropertyPage(lpunk, phr) {
}
};
diff --git a/src/filters/PinInfoWnd.cpp b/src/filters/PinInfoWnd.cpp
index 9c652e448..0668f80ad 100644
--- a/src/filters/PinInfoWnd.cpp
+++ b/src/filters/PinInfoWnd.cpp
@@ -40,9 +40,13 @@ bool CPinInfoWnd::OnConnect(const CInterfaceList<IUnknown, &IID_IUnknown>& pUnks
m_pBF.Release();
POSITION pos = pUnks.GetHeadPosition();
- while(pos && !(m_pBF = pUnks.GetNext(pos)));
+ while(pos && !(m_pBF = pUnks.GetNext(pos))) {
+ ;
+ }
- if(!m_pBF) return false;
+ if(!m_pBF) {
+ return false;
+ }
return true;
}
@@ -56,16 +60,17 @@ 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)==VK_ESCAPE) {
+ return 0; // just ignore ESCAPE in edit control
+ }
if ((LOWORD(wParam)== 'A' || LOWORD(wParam) == 'a')
- &&(GetKeyState(VK_CONTROL) < 0)) {
+ &&(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
}
@@ -77,15 +82,21 @@ bool CPinInfoWnd::OnActivate()
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)
- {
+ BeginEnumPins(m_pBF, pEP, pPin) {
CPinInfo pi;
- if(FAILED(pPin->QueryPinInfo(&pi))) continue;
+ if(FAILED(pPin->QueryPinInfo(&pi))) {
+ continue;
+ }
CString str = CString(pi.achName);
- if(!str.Find(_T("Apple"))) str.Delete(0,1);
+ 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] ");
+ 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
@@ -98,8 +109,9 @@ bool CPinInfoWnd::OnActivate()
OnCbnSelchangeCombo1();
- for(CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow())
+ for(CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow()) {
pWnd->SetFont(&m_font, FALSE);
+ }
m_info_edit.SetFont(&m_monospacefont);
@@ -117,8 +129,7 @@ bool CPinInfoWnd::OnApply()
{
OnDeactivate();
- if(m_pBF)
- {
+ if(m_pBF) {
}
return true;
@@ -141,34 +152,35 @@ void CPinInfoWnd::OnCbnSelchangeCombo1()
m_info_edit.SetWindowText(_T(""));
int i = m_pin_combo.GetCurSel();
- if(i < 0) return;
+ if(i < 0) {
+ return;
+ }
CComPtr<IPin> pPin = (IPin*)m_pin_combo.GetItemDataPtr(i);
- if(!pPin) return;
+ if(!pPin) {
+ return;
+ }
CString str;
PIN_INFO PinInfo;
- if (SUCCEEDED (pPin->QueryPinInfo(&PinInfo)))
- {
+ if (SUCCEEDED (pPin->QueryPinInfo(&PinInfo))) {
CString strName;
CLSID FilterClsid;
FILTER_INFO FilterInfo;
- if (SUCCEEDED (PinInfo.pFilter->QueryFilterInfo (&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))
- {
+ 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
+ } else {
strName = FilterInfo.achName;
+ }
str.Format (_T("Filter : %s - CLSID : %s\n\n"), strName, CStringFromGUID(FilterClsid));
AddLine(str);
FilterInfo.pGraph->Release();
@@ -179,8 +191,7 @@ void CPinInfoWnd::OnCbnSelchangeCombo1()
CMediaTypeEx cmt;
CComPtr<IPin> pPinTo;
- if(SUCCEEDED(pPin->ConnectedTo(&pPinTo)) && 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))),
@@ -190,38 +201,35 @@ void CPinInfoWnd::OnCbnSelchangeCombo1()
AddLine(_T("- Connection media type:\n\n"));
- if(SUCCEEDED(pPin->ConnectionMediaType(&cmt)))
- {
+ if(SUCCEEDED(pPin->ConnectionMediaType(&cmt))) {
CAtlList<CString> sl;
cmt.Dump(sl);
POSITION pos = sl.GetHeadPosition();
- while(pos) AddLine(sl.GetNext(pos) + '\n');
+ while(pos) {
+ AddLine(sl.GetNext(pos) + '\n');
+ }
}
- }
- else
- {
+ } else {
str = _T("- Not connected\n\n");
}
int iMT = 0;
- BeginEnumMediaTypes(pPin, pEMT, pmt)
- {
+ 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)
- {
+ if(cmt.majortype != GUID_NULL && mt == cmt) {
AddLine(_T("Set as the current media type\n\n"));
- }
- else
- {
+ } else {
CAtlList<CString> sl;
mt.Dump(sl);
POSITION pos = sl.GetHeadPosition();
- while(pos) AddLine(sl.GetNext(pos) + '\n');
+ while(pos) {
+ AddLine(sl.GetNext(pos) + '\n');
+ }
}
}
EndEnumMediaTypes(pmt)
diff --git a/src/filters/PinInfoWnd.h b/src/filters/PinInfoWnd.h
index 520e0ec66..6ab567ca5 100644
--- a/src/filters/PinInfoWnd.h
+++ b/src/filters/PinInfoWnd.h
@@ -31,8 +31,7 @@ class __declspec(uuid("A1EB391C-6089-4A87-9988-BE50872317D4"))
{
CComQIPtr<IBaseFilter> m_pBF;
- enum
- {
+ enum {
IDC_PP_COMBO1 = 10000,
IDC_PP_EDIT1,
};
diff --git a/src/filters/muxer/BaseMuxer/BaseMuxer.cpp b/src/filters/muxer/BaseMuxer/BaseMuxer.cpp
index fb596eaaa..4bcc3f90c 100644
--- a/src/filters/muxer/BaseMuxer/BaseMuxer.cpp
+++ b/src/filters/muxer/BaseMuxer/BaseMuxer.cpp
@@ -30,7 +30,9 @@ CBaseMuxerFilter::CBaseMuxerFilter(LPUNKNOWN pUnk, HRESULT* phr, const CLSID& cl
: CBaseFilter(NAME("CBaseMuxerFilter"), pUnk, this, clsid)
, m_rtCurrent(0)
{
- if(phr) *phr = S_OK;
+ if(phr) {
+ *phr = S_OK;
+ }
m_pOutput.Attach(DNew CBaseMuxerOutputPin(L"Output", this, this, phr));
AddInput();
}
@@ -60,10 +62,11 @@ STDMETHODIMP CBaseMuxerFilter::NonDelegatingQueryInterface(REFIID riid, void** p
void CBaseMuxerFilter::AddInput()
{
POSITION pos = m_pInputs.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CBasePin* pPin = m_pInputs.GetNext(pos);
- if(!pPin->IsConnected()) return;
+ if(!pPin->IsConnected()) {
+ return;
+ }
}
CStringW name;
@@ -117,81 +120,77 @@ DWORD CBaseMuxerFilter::ThreadProc()
POSITION pos;
- while(1)
- {
+ while(1) {
DWORD cmd = GetRequest();
- switch(cmd)
- {
- default:
- case CMD_EXIT:
- CAMThread::m_hThread = NULL;
- Reply(S_OK);
- return 0;
-
- 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);
+ switch(cmd) {
+ default:
+ case CMD_EXIT:
+ CAMThread::m_hThread = NULL;
+ Reply(S_OK);
+ return 0;
+
+ 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);
+ }
}
- }
- 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;
}
}
@@ -205,19 +204,20 @@ void CBaseMuxerFilter::MuxHeaderInternal()
{
TRACE(_T("MuxHeader\n"));
- if(CComQIPtr<IBitStream> pBitStream = m_pOutput->GetBitStream())
+ if(CComQIPtr<IBitStream> pBitStream = m_pOutput->GetBitStream()) {
MuxHeader(pBitStream);
+ }
MuxHeader();
//
POSITION pos = m_pPins.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
if(CBaseMuxerInputPin* pInput = m_pPins.GetNext(pos))
- if(CBaseMuxerRawOutputPin* pOutput = dynamic_cast<CBaseMuxerRawOutputPin*>(pInput->GetRelatedPin()))
+ if(CBaseMuxerRawOutputPin* pOutput = dynamic_cast<CBaseMuxerRawOutputPin*>(pInput->GetRelatedPin())) {
pOutput->MuxHeader(pInput->CurrentMediaType());
+ }
}
}
@@ -231,33 +231,36 @@ void CBaseMuxerFilter::MuxPacketInternal(const MuxerPacket* pPacket)
!!(pPacket->flags & MuxerPacket::bogus),
pPacket->rtStart/10000, pPacket->rtStop/10000);
- if(CComQIPtr<IBitStream> pBitStream = m_pOutput->GetBitStream())
+ if(CComQIPtr<IBitStream> pBitStream = m_pOutput->GetBitStream()) {
MuxPacket(pBitStream, pPacket);
+ }
MuxPacket(pPacket);
if(CBaseMuxerInputPin* pInput = pPacket->pPin)
- if(CBaseMuxerRawOutputPin* pOutput = dynamic_cast<CBaseMuxerRawOutputPin*>(pInput->GetRelatedPin()))
+ if(CBaseMuxerRawOutputPin* pOutput = dynamic_cast<CBaseMuxerRawOutputPin*>(pInput->GetRelatedPin())) {
pOutput->MuxPacket(pInput->CurrentMediaType(), pPacket);
+ }
}
void CBaseMuxerFilter::MuxFooterInternal()
{
TRACE(_T("MuxFooter\n"));
- if(CComQIPtr<IBitStream> pBitStream = m_pOutput->GetBitStream())
+ if(CComQIPtr<IBitStream> pBitStream = m_pOutput->GetBitStream()) {
MuxFooter(pBitStream);
+ }
MuxFooter();
//
POSITION pos = m_pPins.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
if(CBaseMuxerInputPin* pInput = m_pPins.GetNext(pos))
- if(CBaseMuxerRawOutputPin* pOutput = dynamic_cast<CBaseMuxerRawOutputPin*>(pInput->GetRelatedPin()))
+ if(CBaseMuxerRawOutputPin* pOutput = dynamic_cast<CBaseMuxerRawOutputPin*>(pInput->GetRelatedPin())) {
pOutput->MuxFooter(pInput->CurrentMediaType());
+ }
}
}
@@ -268,24 +271,23 @@ CAutoPtr<MuxerPacket> CBaseMuxerFilter::GetPacket()
int i = int(m_pActivePins.GetCount());
POSITION pos = m_pActivePins.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CBaseMuxerInputPin* pPin = m_pActivePins.GetNext(pos);
CAutoLock cAutoLock(&pPin->m_csQueue);
- if(!pPin->m_queue.GetCount()) continue;
+ if(!pPin->m_queue.GetCount()) {
+ continue;
+ }
MuxerPacket* p = pPin->m_queue.GetHead();
- if(p->IsBogus() || !p->IsTimeValid() || p->IsEOS())
- {
+ if(p->IsBogus() || !p->IsTimeValid() || p->IsEOS()) {
pPinMin = pPin;
i = 0;
break;
}
- if(p->rtStart < rtMin)
- {
+ if(p->rtStart < rtMin) {
rtMin = p->rtStart;
pPinMin = pPin;
}
@@ -295,14 +297,13 @@ CAutoPtr<MuxerPacket> CBaseMuxerFilter::GetPacket()
CAutoPtr<MuxerPacket> pPacket;
- if(pPinMin && i == 0)
- {
+ if(pPinMin && i == 0) {
pPacket = pPinMin->PopPacket();
- }
- else
- {
+ } else {
pos = m_pActivePins.GetHeadPosition();
- while(pos) m_pActivePins.GetNext(pos)->m_evAcceptPacket.Set();
+ while(pos) {
+ m_pActivePins.GetNext(pos)->m_evAcceptPacket.Set();
+ }
}
return pPacket;
@@ -319,25 +320,24 @@ CBasePin* CBaseMuxerFilter::GetPin(int n)
{
CAutoLock cAutoLock(this);
- if(n >= 0 && n < (int)m_pInputs.GetCount())
- {
- if(POSITION pos = m_pInputs.FindIndex(n))
+ 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());
- if(n == 0 && m_pOutput)
- {
+ if(n == 0 && m_pOutput) {
return m_pOutput;
}
n--;
- if(n >= 0 && n < (int)m_pRawOutputs.GetCount())
- {
- if(POSITION pos = m_pRawOutputs.FindIndex(n))
+ 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());
@@ -350,7 +350,9 @@ STDMETHODIMP CBaseMuxerFilter::Stop()
CAutoLock cAutoLock(this);
HRESULT hr = __super::Stop();
- if(FAILED(hr)) return hr;
+ if(FAILED(hr)) {
+ return hr;
+ }
CallWorker(CMD_EXIT);
@@ -364,10 +366,11 @@ STDMETHODIMP CBaseMuxerFilter::Pause()
FILTER_STATE fs = m_State;
HRESULT hr = __super::Pause();
- if(FAILED(hr)) return hr;
+ if(FAILED(hr)) {
+ return hr;
+ }
- if(fs == State_Stopped && m_pOutput)
- {
+ if(fs == State_Stopped && m_pOutput) {
CAMThread::Create();
CallWorker(CMD_RUN);
}
@@ -380,7 +383,9 @@ STDMETHODIMP CBaseMuxerFilter::Run(REFERENCE_TIME tStart)
CAutoLock cAutoLock(this);
HRESULT hr = __super::Run(tStart);
- if(FAILED(hr)) return hr;
+ if(FAILED(hr)) {
+ return hr;
+ }
return hr;
}
@@ -394,25 +399,32 @@ STDMETHODIMP CBaseMuxerFilter::GetCapabilities(DWORD* pCapabilities)
STDMETHODIMP CBaseMuxerFilter::CheckCapabilities(DWORD* pCapabilities)
{
CheckPointer(pCapabilities, E_POINTER);
- if(*pCapabilities == 0) return S_OK;
+ 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) {
+STDMETHODIMP CBaseMuxerFilter::IsFormatSupported(const GUID* pFormat)
+{
return !pFormat ? E_POINTER : *pFormat == TIME_FORMAT_MEDIA_TIME ? S_OK : S_FALSE;
}
-STDMETHODIMP CBaseMuxerFilter::QueryPreferredFormat(GUID* pFormat) {
+STDMETHODIMP CBaseMuxerFilter::QueryPreferredFormat(GUID* pFormat)
+{
return GetTimeFormat(pFormat);
}
-STDMETHODIMP CBaseMuxerFilter::GetTimeFormat(GUID* pFormat) {
+STDMETHODIMP CBaseMuxerFilter::GetTimeFormat(GUID* pFormat)
+{
return pFormat ? *pFormat = TIME_FORMAT_MEDIA_TIME, S_OK : E_POINTER;
}
-STDMETHODIMP CBaseMuxerFilter::IsUsingTimeFormat(const GUID* pFormat) {
+STDMETHODIMP CBaseMuxerFilter::IsUsingTimeFormat(const GUID* pFormat)
+{
return IsFormatSupported(pFormat);
}
-STDMETHODIMP CBaseMuxerFilter::SetTimeFormat(const GUID* pFormat) {
+STDMETHODIMP CBaseMuxerFilter::SetTimeFormat(const GUID* pFormat)
+{
return S_OK == IsFormatSupported(pFormat) ? S_OK : E_INVALIDARG;
}
STDMETHODIMP CBaseMuxerFilter::GetDuration(LONGLONG* pDuration)
@@ -422,11 +434,14 @@ STDMETHODIMP CBaseMuxerFilter::GetDuration(LONGLONG* pDuration)
POSITION pos = m_pInputs.GetHeadPosition();
while(pos) {
REFERENCE_TIME rt = m_pInputs.GetNext(pos)->GetDuration();
- if(rt > *pDuration) *pDuration = rt;
+ if(rt > *pDuration) {
+ *pDuration = rt;
+ }
}
return S_OK;
}
-STDMETHODIMP CBaseMuxerFilter::GetStopPosition(LONGLONG* pStop) {
+STDMETHODIMP CBaseMuxerFilter::GetStopPosition(LONGLONG* pStop)
+{
return E_NOTIMPL;
}
STDMETHODIMP CBaseMuxerFilter::GetCurrentPosition(LONGLONG* pCurrent)
@@ -435,22 +450,25 @@ STDMETHODIMP CBaseMuxerFilter::GetCurrentPosition(LONGLONG* pCurrent)
*pCurrent = m_rtCurrent;
return S_OK;
}
-STDMETHODIMP CBaseMuxerFilter::ConvertTimeFormat(LONGLONG* pTarget, const GUID* pTargetFormat, LONGLONG Source, const GUID* pSourceFormat) {
+STDMETHODIMP CBaseMuxerFilter::ConvertTimeFormat(LONGLONG* pTarget, const GUID* pTargetFormat, LONGLONG Source, const GUID* pSourceFormat)
+{
return E_NOTIMPL;
}
STDMETHODIMP CBaseMuxerFilter::SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags)
{
FILTER_STATE fs;
- if(SUCCEEDED(GetState(0, &fs)) && fs == State_Stopped)
- {
+ if(SUCCEEDED(GetState(0, &fs)) && fs == State_Stopped) {
POSITION pos = m_pInputs.GetHeadPosition();
- while(pos)
- {
+ 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(!pMS) {
+ pMS = GetFilterFromPin(pPin->GetConnected());
+ }
+ if(pMS) {
+ pMS->SetPositions(pCurrent, dwCurrentFlags, pStop, dwStopFlags);
+ }
}
return S_OK;
@@ -458,18 +476,23 @@ STDMETHODIMP CBaseMuxerFilter::SetPositions(LONGLONG* pCurrent, DWORD dwCurrentF
return VFW_E_WRONG_STATE;
}
-STDMETHODIMP CBaseMuxerFilter::GetPositions(LONGLONG* pCurrent, LONGLONG* pStop) {
+STDMETHODIMP CBaseMuxerFilter::GetPositions(LONGLONG* pCurrent, LONGLONG* pStop)
+{
return E_NOTIMPL;
}
-STDMETHODIMP CBaseMuxerFilter::GetAvailable(LONGLONG* pEarliest, LONGLONG* pLatest) {
+STDMETHODIMP CBaseMuxerFilter::GetAvailable(LONGLONG* pEarliest, LONGLONG* pLatest)
+{
return E_NOTIMPL;
}
-STDMETHODIMP CBaseMuxerFilter::SetRate(double dRate) {
+STDMETHODIMP CBaseMuxerFilter::SetRate(double dRate)
+{
return E_NOTIMPL;
}
-STDMETHODIMP CBaseMuxerFilter::GetRate(double* pdRate) {
+STDMETHODIMP CBaseMuxerFilter::GetRate(double* pdRate)
+{
return E_NOTIMPL;
}
-STDMETHODIMP CBaseMuxerFilter::GetPreroll(LONGLONG* pllPreroll) {
+STDMETHODIMP CBaseMuxerFilter::GetPreroll(LONGLONG* pllPreroll)
+{
return E_NOTIMPL;
}
diff --git a/src/filters/muxer/BaseMuxer/BaseMuxerInputPin.cpp b/src/filters/muxer/BaseMuxer/BaseMuxerInputPin.cpp
index abfb8923e..e100bfe81 100644
--- a/src/filters/muxer/BaseMuxer/BaseMuxerInputPin.cpp
+++ b/src/filters/muxer/BaseMuxer/BaseMuxerInputPin.cpp
@@ -68,17 +68,21 @@ void CBaseMuxerInputPin::PushPacket(CAutoPtr<MuxerPacket> pPacket)
for(int i = 0; m_pFilter->IsActive() && !m_bFlushing
&& !m_evAcceptPacket.Wait(1)
&& i < 1000;
- i++);
+ i++) {
+ ;
+ }
- if(!m_pFilter->IsActive() || m_bFlushing)
+ if(!m_pFilter->IsActive() || m_bFlushing) {
return;
+ }
CAutoLock cAutoLock(&m_csQueue);
m_queue.AddTail(pPacket);
- if(m_queue.GetCount() >= MAXQUEUESIZE)
+ if(m_queue.GetCount() >= MAXQUEUESIZE) {
m_evAcceptPacket.Reset();
+ }
}
CAutoPtr<MuxerPacket> CBaseMuxerInputPin::PopPacket()
@@ -87,46 +91,48 @@ CAutoPtr<MuxerPacket> CBaseMuxerInputPin::PopPacket()
CAutoLock cAutoLock(&m_csQueue);
- if(m_queue.GetCount())
+ if(m_queue.GetCount()) {
pPacket = m_queue.RemoveHead();
+ }
- if(m_queue.GetCount() < MAXQUEUESIZE)
+ if(m_queue.GetCount() < MAXQUEUESIZE) {
m_evAcceptPacket.Set();
+ }
return pPacket;
}
HRESULT CBaseMuxerInputPin::CheckMediaType(const CMediaType* pmt)
{
- if(pmt->formattype == FORMAT_WaveFormatEx)
- {
+ 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)
- {
+ || 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;
+ || 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;
+ if(FAILED(hr)) {
+ return hr;
+ }
RemoveAll();
@@ -138,36 +144,37 @@ HRESULT CBaseMuxerInputPin::BreakConnect()
HRESULT CBaseMuxerInputPin::CompleteConnect(IPin* pReceivePin)
{
HRESULT hr = __super::CompleteConnect(pReceivePin);
- if(FAILED(hr)) return hr;
+ if(FAILED(hr)) {
+ return hr;
+ }
// duration
m_rtDuration = 0;
CComQIPtr<IMediaSeeking> pMS;
- if((pMS = GetFilterFromPin(pReceivePin)) || (pMS = pReceivePin))
+ 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)
- {
+ 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++)
- {
+ 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)))
+ if(FAILED(pPB->GetPropertyInfo(iProperty, 1, &PropBag, &cPropertiesReturned))) {
continue;
+ }
HRESULT hr;
CComVariant var;
- if(SUCCEEDED(pPB->Read(1, &PropBag, NULL, &var, &hr)) && SUCCEEDED(hr))
+ if(SUCCEEDED(pPB->Read(1, &PropBag, NULL, &var, &hr)) && SUCCEEDED(hr)) {
SetProperty(PropBag.pstrName, &var);
+ }
CoTaskMemFree(PropBag.pstrName);
}
@@ -208,47 +215,44 @@ STDMETHODIMP CBaseMuxerInputPin::Receive(IMediaSample* pSample)
CAutoLock cAutoLock(&m_csReceive);
HRESULT hr = __super::Receive(pSample);
- if(FAILED(hr)) return hr;
+ if(FAILED(hr)) {
+ return hr;
+ }
CAutoPtr<MuxerPacket> pPacket(DNew MuxerPacket(this));
long len = pSample->GetActualDataLength();
BYTE* pData = NULL;
- if(FAILED(pSample->GetPointer(&pData)) || !pData)
+ if(FAILED(pSample->GetPointer(&pData)) || !pData) {
return S_OK;
+ }
pPacket->pData.SetCount(len);
memcpy(pPacket->pData.GetData(), pData, len);
- if(S_OK == pSample->IsSyncPoint() || m_mt.majortype == MEDIATYPE_Audio && !m_mt.bTemporalCompression)
- {
+ 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))
- {
+ if(S_OK == pSample->GetTime(&pPacket->rtStart, &pPacket->rtStop)) {
pPacket->flags |= MuxerPacket::timevalid;
pPacket->rtStart += m_tStart;
pPacket->rtStop += m_tStart;
- if((pPacket->flags & MuxerPacket::syncpoint) && pPacket->rtStart < m_rtMaxStart)
- {
+ 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)
- {
+ } else if(pPacket->flags & MuxerPacket::syncpoint) {
pPacket->flags &= ~MuxerPacket::syncpoint;
pPacket->flags |= MuxerPacket::bogus;
}
- if(S_OK == pSample->IsDiscontinuity())
- {
+ if(S_OK == pSample->IsDiscontinuity()) {
pPacket->flags |= MuxerPacket::discontinuity;
}
@@ -264,7 +268,9 @@ STDMETHODIMP CBaseMuxerInputPin::EndOfStream()
CAutoLock cAutoLock(&m_csReceive);
HRESULT hr = __super::EndOfStream();
- if(FAILED(hr)) return hr;
+ if(FAILED(hr)) {
+ return hr;
+ }
ASSERT(!m_fEOS);
diff --git a/src/filters/muxer/BaseMuxer/BaseMuxerInputPin.h b/src/filters/muxer/BaseMuxer/BaseMuxerInputPin.h
index 1ae51ae1d..788c00b03 100644
--- a/src/filters/muxer/BaseMuxer/BaseMuxerInputPin.h
+++ b/src/filters/muxer/BaseMuxer/BaseMuxerInputPin.h
@@ -26,8 +26,7 @@
class CBaseMuxerInputPin;
-struct MuxerPacket
-{
+struct MuxerPacket {
CBaseMuxerInputPin* pPin;
REFERENCE_TIME rtStart, rtStop;
CAtlArray<BYTE> pData;
diff --git a/src/filters/muxer/BaseMuxer/BaseMuxerOutputPin.cpp b/src/filters/muxer/BaseMuxer/BaseMuxerOutputPin.cpp
index 108549d91..45d32cd11 100644
--- a/src/filters/muxer/BaseMuxer/BaseMuxerOutputPin.cpp
+++ b/src/filters/muxer/BaseMuxer/BaseMuxerOutputPin.cpp
@@ -40,10 +40,8 @@ CBaseMuxerOutputPin::CBaseMuxerOutputPin(LPCWSTR pName, CBaseFilter* pFilter, CC
IBitStream* CBaseMuxerOutputPin::GetBitStream()
{
- if(!m_pBitStream)
- {
- if(CComQIPtr<IStream> pStream = GetConnected())
- {
+ if(!m_pBitStream) {
+ if(CComQIPtr<IStream> pStream = GetConnected()) {
m_pBitStream = DNew CBitStream(pStream, true);
}
}
@@ -69,9 +67,13 @@ HRESULT CBaseMuxerOutputPin::DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_P
pProperties->cbBuffer = 1;
ALLOCATOR_PROPERTIES Actual;
- if(FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) return hr;
+ if(FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) {
+ return hr;
+ }
- if(Actual.cbBuffer < pProperties->cbBuffer) return E_FAIL;
+ if(Actual.cbBuffer < pProperties->cbBuffer) {
+ return E_FAIL;
+ }
ASSERT(Actual.cBuffers == pProperties->cBuffers);
return NOERROR;
@@ -88,8 +90,12 @@ 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;
+ if(iPosition < 0) {
+ return E_INVALIDARG;
+ }
+ if(iPosition > 0) {
+ return VFW_S_NO_MORE_ITEMS;
+ }
pmt->ResetFormatBuffer();
pmt->InitMediaType();
@@ -133,59 +139,50 @@ STDMETHODIMP CBaseMuxerRawOutputPin::NonDelegatingQueryInterface(REFIID riid, vo
void CBaseMuxerRawOutputPin::MuxHeader(const CMediaType& mt)
{
CComQIPtr<IBitStream> pBitStream = GetBitStream();
- if(!pBitStream) return;
+ if(!pBitStream) {
+ return;
+ }
const BYTE utf8bom[3] = {0xef, 0xbb, 0xbf};
- if((mt.subtype == FOURCCMap('1CVA') || mt.subtype == FOURCCMap('1cva')) && mt.formattype == FORMAT_MPEG2_VIDEO)
- {
+ 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)
- {
+ 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)
- {
+ } 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)
- {
+ } 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)
+ 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)
+ if(str.Find("[Events]") < 0) {
pBitStream->StrWrite("\n\n[Events]\n", true);
- }
- else if(mt.subtype == MEDIASUBTYPE_SSF)
- {
+ }
+ } else if(mt.subtype == MEDIASUBTYPE_SSF) {
DWORD dwOffset = ((SUBTITLEINFO*)mt.pbFormat)->dwOffset;
try {
m_ssf.Parse(ssf::MemoryInputStream(mt.pbFormat + dwOffset, mt.cbFormat - dwOffset, false, false));
- }
- catch(ssf::Exception&) {}
- }
- else if(mt.subtype == MEDIASUBTYPE_VOBSUB)
- {
+ } catch(ssf::Exception&) {}
+ } 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)
- {
+ } 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);
@@ -202,34 +199,46 @@ void CBaseMuxerRawOutputPin::MuxHeader(const CMediaType& mt)
void CBaseMuxerRawOutputPin::MuxPacket(const CMediaType& mt, const MuxerPacket* pPacket)
{
CComQIPtr<IBitStream> pBitStream = GetBitStream();
- if(!pBitStream) return;
+ 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)
- {
+ 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;
+ 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)
- {
+ if(wfe->cbSize >= 2) {
BYTE* p = (BYTE*)(wfe+1);
profile = (p[0]>>3)-1;
srate_idx = ((p[0]&7)<<1)|((p[1]&0x80)>>7);
@@ -246,27 +255,22 @@ void CBaseMuxerRawOutputPin::MuxPacket(const CMediaType& mt, const MuxerPacket*
hdr[6] = 0xfc;
pBitStream->ByteWrite(hdr, sizeof(hdr));
- }
- else if((mt.subtype == FOURCCMap('1CVA') || mt.subtype == FOURCCMap('1cva')) && mt.formattype == FORMAT_MPEG2_VIDEO)
- {
+ } 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)
- {
+ 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)
- {
+ if(i == 0) {
p = pData;
i = DataSize;
- while(i >= 4)
- {
+ while(i >= 4) {
DWORD len = (p[0]<<24)|(p[1]<<16)|(p[2]<<8)|p[3];
pBitStream->BitWrite(0x00000001, 32);
@@ -287,12 +291,12 @@ void CBaseMuxerRawOutputPin::MuxPacket(const CMediaType& mt, const MuxerPacket*
return;
}
- }
- else if(mt.subtype == MEDIASUBTYPE_UTF8 || mt.majortype == MEDIATYPE_Text)
- {
+ } else if(mt.subtype == MEDIASUBTYPE_UTF8 || mt.majortype == MEDIATYPE_Text) {
CStringA str((char*)pData, DataSize);
str.Trim();
- if(str.IsEmpty()) return;
+ if(str.IsEmpty()) {
+ return;
+ }
DVD_HMSF_TIMECODE start = RT2HMSF(pPacket->rtStart, 25);
DVD_HMSF_TIMECODE stop = RT2HMSF(pPacket->rtStop, 25);
@@ -306,12 +310,12 @@ void CBaseMuxerRawOutputPin::MuxPacket(const CMediaType& mt, const MuxerPacket*
pBitStream->StrWrite(str, true);
return;
- }
- else if(mt.subtype == MEDIASUBTYPE_SSA || mt.subtype == MEDIASUBTYPE_ASS || mt.subtype == MEDIASUBTYPE_ASS2)
- {
+ } 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;
+ if(str.IsEmpty()) {
+ return;
+ }
DVD_HMSF_TIMECODE start = RT2HMSF(pPacket->rtStart, 25);
DVD_HMSF_TIMECODE stop = RT2HMSF(pPacket->rtStop, 25);
@@ -320,7 +324,9 @@ void CBaseMuxerRawOutputPin::MuxPacket(const CMediaType& mt, const MuxerPacket*
CAtlList<CStringA> sl;
Explode(str, sl, ',', fields);
- if(sl.GetCount() < fields) return;
+ if(sl.GetCount() < fields) {
+ return;
+ }
CStringA readorder = sl.RemoveHead(); // TODO
CStringA layer = sl.RemoveHead();
@@ -329,11 +335,15 @@ void CBaseMuxerRawOutputPin::MuxPacket(const CMediaType& mt, const MuxerPacket*
CStringA left = sl.RemoveHead();
CStringA right = sl.RemoveHead();
CStringA top = sl.RemoveHead();
- if(fields == 10) top += ',' + sl.RemoveHead(); // bottom
+ if(fields == 10) {
+ top += ',' + sl.RemoveHead(); // bottom
+ }
CStringA effect = sl.RemoveHead();
str = sl.RemoveHead();
- if(mt.subtype == MEDIASUBTYPE_SSA) layer = "Marked=0";
+ 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,
@@ -345,20 +355,15 @@ void CBaseMuxerRawOutputPin::MuxPacket(const CMediaType& mt, const MuxerPacket*
pBitStream->StrWrite(str, true);
return;
- }
- else if(mt.subtype == MEDIASUBTYPE_SSF)
- {
+ } else if(mt.subtype == MEDIASUBTYPE_SSF) {
float start = (float)pPacket->rtStart / 10000000;
float stop = (float)pPacket->rtStop / 10000000;
m_ssf.Append(ssf::WCharInputStream(UTF8To16(CStringA((char*)pData, DataSize))), start, stop, true);
return;
- }
- else if(mt.subtype == MEDIASUBTYPE_VOBSUB)
- {
+ } else if(mt.subtype == MEDIASUBTYPE_VOBSUB) {
bool fTimeValid = pPacket->IsTimeValid();
- if(fTimeValid)
- {
+ if(fTimeValid) {
idx_t i;
i.rt = pPacket->rtStart;
i.fp = pBitStream->GetPos();
@@ -367,8 +372,7 @@ void CBaseMuxerRawOutputPin::MuxPacket(const CMediaType& mt, const MuxerPacket*
int DataSizeLeft = DataSize;
- while(DataSizeLeft > 0)
- {
+ while(DataSizeLeft > 0) {
int BytesAvail = 0x7ec - (fTimeValid ? 9 : 4);
int Size = min(BytesAvail, DataSizeLeft);
int Padding = 0x800 - Size - 20 - (fTimeValid ? 9 : 4);
@@ -378,13 +382,10 @@ void CBaseMuxerRawOutputPin::MuxPacket(const CMediaType& mt, const MuxerPacket*
pBitStream->BitWrite(0x000003f8, 32);
pBitStream->BitWrite(0x000001bd, 32);
- if(fTimeValid)
- {
+ if(fTimeValid) {
pBitStream->BitWrite(Size+9, 16);
pBitStream->BitWrite(0x8180052100010001ui64, 64);
- }
- else
- {
+ } else {
pBitStream->BitWrite(Size+4, 16);
pBitStream->BitWrite(0x810000, 24);
}
@@ -396,28 +397,28 @@ void CBaseMuxerRawOutputPin::MuxPacket(const CMediaType& mt, const MuxerPacket*
pData += Size;
DataSizeLeft -= Size;
- if(Padding > 0)
- {
+ if(Padding > 0) {
Padding -= 6;
ASSERT(Padding >= 0);
pBitStream->BitWrite(0x000001be, 32);
pBitStream->BitWrite(Padding, 16);
- while(Padding-- > 0) pBitStream->BitWrite(0xff, 8);
+ while(Padding-- > 0) {
+ pBitStream->BitWrite(0xff, 8);
+ }
}
fTimeValid = false;
}
return;
- }
- else if(mt.subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO)
- {
+ } 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--)
+ for(int j = bps-1; j >= 0; j--) {
pBitStream->BitWrite(pData[i+j], 8);
+ }
return;
}
@@ -429,15 +430,16 @@ void CBaseMuxerRawOutputPin::MuxPacket(const CMediaType& mt, const MuxerPacket*
void CBaseMuxerRawOutputPin::MuxFooter(const CMediaType& mt)
{
CComQIPtr<IBitStream> pBitStream = GetBitStream();
- if(!pBitStream) return;
+ 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)
- {
+ || 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);
@@ -450,30 +452,22 @@ void CBaseMuxerRawOutputPin::MuxFooter(const CMediaType& mt)
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_SSF)
- {
+ } else if(mt.subtype == MEDIASUBTYPE_SSF) {
ssf::WCharOutputStream s;
try {
m_ssf.Dump(s);
- }
- catch(ssf::Exception&) {}
+ } catch(ssf::Exception&) {}
CStringA str = UTF16To8(s.GetString());
pBitStream->StrWrite(str, true);
- }
- else if(mt.subtype == MEDIASUBTYPE_VOBSUB)
- {
- if(CComQIPtr<IFileSinkFilter> pFSF = GetFilterFromPin(GetConnected()))
- {
+ } else if(mt.subtype == MEDIASUBTYPE_VOBSUB) {
+ if(CComQIPtr<IFileSinkFilter> pFSF = GetFilterFromPin(GetConnected())) {
WCHAR* fn = NULL;
- if(SUCCEEDED(pFSF->GetCurFile(&fn, NULL)))
- {
+ if(SUCCEEDED(pFSF->GetCurFile(&fn, NULL))) {
CPathW p(fn);
p.RenameExtension(L".idx");
CoTaskMemFree(fn);
- if(FILE* f = _tfopen(CString((LPCWSTR)p), _T("w")))
- {
+ if(FILE* f = _tfopen(CString((LPCWSTR)p), _T("w"))) {
SUBTITLEINFO* si = (SUBTITLEINFO*)mt.Format();
_ftprintf(f, _T("%s\n"), _T("# VobSub index file, v7 (do not modify this line!)"));
@@ -481,15 +475,18 @@ void CBaseMuxerRawOutputPin::MuxFooter(const CMediaType& mt)
fwrite(mt.Format() + si->dwOffset, mt.FormatLength() - si->dwOffset, 1, f);
CString iso6391 = ISO6392To6391(si->IsoLang);
- if(iso6391.IsEmpty()) iso6391 = _T("--");
+ if(iso6391.IsEmpty()) {
+ iso6391 = _T("--");
+ }
_ftprintf(f, _T("\nlangidx: 0\n\nid: %s, index: 0\n"), iso6391);
CString alt = CString(CStringW(si->TrackName));
- if(!alt.IsEmpty()) _ftprintf(f, _T("alt: %s\n"), alt);
+ if(!alt.IsEmpty()) {
+ _ftprintf(f, _T("alt: %s\n"), alt);
+ }
POSITION pos = m_idx.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
const idx_t& i = m_idx.GetNext(pos);
DVD_HMSF_TIMECODE start = RT2HMSF(i.rt, 25);
_ftprintf(f, _T("timestamp: %02d:%02d:%02d:%03d, filepos: %09I64x\n"),
diff --git a/src/filters/muxer/BaseMuxer/BaseMuxerRelatedPin.h b/src/filters/muxer/BaseMuxer/BaseMuxerRelatedPin.h
index 3d911ccdd..d86985190 100644
--- a/src/filters/muxer/BaseMuxer/BaseMuxerRelatedPin.h
+++ b/src/filters/muxer/BaseMuxer/BaseMuxerRelatedPin.h
@@ -23,8 +23,7 @@
interface __declspec(uuid("EE6F2741-7DB4-4AAD-A3CB-545208EE4C0A"))
IBaseMuxerRelatedPin :
-public IUnknown
-{
+public IUnknown {
STDMETHOD(SetRelatedPin) (CBasePin* pPin) = 0;
STDMETHOD_(CBasePin*, GetRelatedPin) () = 0;
};
diff --git a/src/filters/muxer/BaseMuxer/BitStream.cpp b/src/filters/muxer/BaseMuxer/BitStream.cpp
index d18fc53fa..355cc19ff 100644
--- a/src/filters/muxer/BaseMuxer/BitStream.cpp
+++ b/src/filters/muxer/BaseMuxer/BitStream.cpp
@@ -87,13 +87,14 @@ STDMETHODIMP CBitStream::ByteWrite(const void* pData, int len)
BitFlush();
- if(len > 0)
- {
+ if(len > 0) {
ULONG cbWritten = 0;
hr = m_pStream->Write(pData, len, &cbWritten);
ASSERT(SUCCEEDED(hr));
- if(m_fThrowError && FAILED(hr)) throw hr;
+ if(m_fThrowError && FAILED(hr)) {
+ throw hr;
+ }
}
return hr;
@@ -114,14 +115,15 @@ STDMETHODIMP CBitStream::BitWrite(UINT64 data, int len)
m_bitbuff |= data & ((1ui64 << len) - 1);
m_bitlen += len;
- while(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;
+ if(m_fThrowError && FAILED(hr)) {
+ throw E_FAIL;
+ }
}
return hr;
@@ -131,15 +133,16 @@ STDMETHODIMP CBitStream::BitFlush()
{
HRESULT hr = S_OK;
- if(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;
+ if(m_fThrowError && FAILED(hr)) {
+ throw E_FAIL;
+ }
}
return hr;
@@ -149,8 +152,7 @@ STDMETHODIMP CBitStream::StrWrite(LPCSTR pData, BOOL bFixNewLine)
{
CStringA str = pData;
- if(bFixNewLine)
- {
+ if(bFixNewLine) {
str.Replace("\r", "");
str.Replace("\n", "\r\n");
}
diff --git a/src/filters/muxer/BaseMuxer/BitStream.h b/src/filters/muxer/BaseMuxer/BitStream.h
index 02ffbe2ce..e2f186da2 100644
--- a/src/filters/muxer/BaseMuxer/BitStream.h
+++ b/src/filters/muxer/BaseMuxer/BitStream.h
@@ -23,8 +23,7 @@
interface __declspec(uuid("30AB78C7-5259-4594-AEFE-9C0FC2F08A5E"))
IBitStream :
-public IUnknown
-{
+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;
diff --git a/src/filters/muxer/DSMMuxer/DSMMuxer.cpp b/src/filters/muxer/DSMMuxer/DSMMuxer.cpp
index 17fce671d..b3059b577 100644
--- a/src/filters/muxer/DSMMuxer/DSMMuxer.cpp
+++ b/src/filters/muxer/DSMMuxer/DSMMuxer.cpp
@@ -30,24 +30,20 @@
#ifdef REGISTER_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
{&MEDIATYPE_Stream, &MEDIASUBTYPE_DirectShowMedia}
};
-const AMOVIESETUP_PIN sudpPins[] =
-{
+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}
};
-const AMOVIESETUP_FILTER sudFilter[] =
-{
+const AMOVIESETUP_FILTER sudFilter[] = {
{&__uuidof(CDSMMuxerFilter), L"MPC - DSM Muxer", MERIT_DO_NOT_USE, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory}
};
-CFactoryTemplate g_Templates[] =
-{
+CFactoryTemplate g_Templates[] = {
{sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CDSMMuxerFilter>, NULL, &sudFilter[0]}
};
@@ -69,14 +65,17 @@ CFilterApp theApp;
#endif
-template<typename T> static T myabs(T n) {
+template<typename T> static T myabs(T 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--;
+ while(i >= min && ((BYTE*)&data)[i] == 0) {
+ i--;
+ }
return ++i;
}
@@ -89,7 +88,9 @@ CDSMMuxerFilter::CDSMMuxerFilter(LPUNKNOWN pUnk, HRESULT* phr, bool fAutoChap, b
, m_fAutoChap(fAutoChap)
, m_fAutoRes(fAutoRes)
{
- if(phr) *phr = S_OK;
+ if(phr) {
+ *phr = S_OK;
+ }
}
CDSMMuxerFilter::~CDSMMuxerFilter()
@@ -123,18 +124,18 @@ void CDSMMuxerFilter::MuxFileInfo(IBitStream* pBS)
int len = 1;
CSimpleMap<CStringA, CStringA> si;
- for(int i = 0; i < GetSize(); i++)
- {
+ for(int i = 0; i < GetSize(); i++) {
CStringA key = CStringA(CString(GetKeyAt(i))), value = UTF16To8(GetValueAt(i));
- if(key.GetLength() != 4) continue;
+ 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++)
- {
+ 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);
@@ -147,20 +148,19 @@ void CDSMMuxerFilter::MuxStreamInfo(IBitStream* pBS, CBaseMuxerInputPin* pPin)
int len = 1;
CSimpleMap<CStringA, CStringA> si;
- for(int i = 0; i < pPin->GetSize(); i++)
- {
+ 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;
+ if(key.GetLength() != 4) {
+ continue;
+ }
si.Add(key, value);
len += 4 + value.GetLength() + 1;
}
- if(len > 1)
- {
+ if(len > 1) {
MuxPacketHeader(pBS, DSMP_STREAMINFO, len);
pBS->BitWrite(pPin->GetID(), 8);
- for(int i = 0; i < si.GetSize(); i++)
- {
+ 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);
@@ -186,8 +186,7 @@ void CDSMMuxerFilter::MuxHeader(IBitStream* pBS)
MuxFileInfo(pBS);
POSITION pos = m_pPins.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CBaseMuxerInputPin* pPin = m_pPins.GetNext(pos);
const CMediaType& mt = pPin->CurrentMediaType();
@@ -214,19 +213,19 @@ void CDSMMuxerFilter::MuxHeader(IBitStream* pBS)
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)
- {
+ 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(pPB && !pRBs.Find(pPB)) {
+ pRBs.AddTail(pPB);
+ }
}
- if(m_fAutoChap)
- {
- if(!pCB || pCB->ChapGetCount() == 0) pCB = GetFilterFromPin(pPin);
+ if(m_fAutoChap) {
+ if(!pCB || pCB->ChapGetCount() == 0) {
+ pCB = GetFilterFromPin(pPin);
+ }
}
}
}
@@ -234,17 +233,14 @@ void CDSMMuxerFilter::MuxHeader(IBitStream* pBS)
// resources
pos = pRBs.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
IDSMResourceBag* pRB = pRBs.GetNext(pos);
- for(DWORD i = 0, j = pRB->ResGetCount(); i < j; i++)
- {
+ 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)))
- {
+ 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);
@@ -270,20 +266,17 @@ void CDSMMuxerFilter::MuxHeader(IBitStream* pBS)
// chapters
- if(pCB)
- {
+ if(pCB) {
CAtlList<CDSMChapter> chapters;
REFERENCE_TIME rtPrev = 0;
int len = 0;
pCB->ChapSort();
- for(DWORD i = 0; i < pCB->ChapGetCount(); i++)
- {
+ for(DWORD i = 0; i < pCB->ChapGetCount(); i++) {
CDSMChapter c;
CComBSTR name;
- if(SUCCEEDED(pCB->ChapGet(i, &c.rt, &name)))
- {
+ if(SUCCEEDED(pCB->ChapGet(i, &c.rt, &name))) {
REFERENCE_TIME rtDiff = c.rt - rtPrev;
rtPrev = c.rt;
c.rt = rtDiff;
@@ -293,13 +286,11 @@ void CDSMMuxerFilter::MuxHeader(IBitStream* pBS)
}
}
- if(chapters.GetCount())
- {
+ if(chapters.GetCount()) {
MuxPacketHeader(pBS, DSMP_CHAPTERS, len);
pos = chapters.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CDSMChapter& c = chapters.GetNext(pos);
CStringA name = UTF16To8(c.name);
int irt = GetByteLength(myabs(c.rt));
@@ -315,18 +306,19 @@ void CDSMMuxerFilter::MuxHeader(IBitStream* pBS)
void CDSMMuxerFilter::MuxPacket(IBitStream* pBS, const MuxerPacket* pPacket)
{
- if(pPacket->IsEOS())
+ if(pPacket->IsEOS()) {
return;
+ }
- if(pPacket->pPin->CurrentMediaType().majortype == MEDIATYPE_Text)
- {
+ 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())
+ if(str.IsEmpty()) {
return;
+ }
}
ASSERT(!pPacket->IsSyncPoint() || pPacket->IsTimeValid());
@@ -334,8 +326,7 @@ void CDSMMuxerFilter::MuxPacket(IBitStream* pBS, const MuxerPacket* pPacket)
REFERENCE_TIME rtTimeStamp = _I64_MIN, rtDuration = 0;
int iTimeStamp = 0, iDuration = 0;
- if(pPacket->IsTimeValid())
- {
+ if(pPacket->IsTimeValid()) {
rtTimeStamp = pPacket->rtStart;
rtDuration = max(pPacket->rtStop - pPacket->rtStart, 0);
@@ -371,8 +362,7 @@ void CDSMMuxerFilter::MuxFooter(IBitStream* pBS)
UINT64 fpPrev = 0, fp;
POSITION pos = m_isps.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
IndexedSyncPoint& isp = m_isps.GetNext(pos);
TRACE(_T("sp[%d]: %I64d %I64x\n"), isp.id, isp.rt, isp.fp);
@@ -392,8 +382,7 @@ void CDSMMuxerFilter::MuxFooter(IBitStream* pBS)
MuxPacketHeader(pBS, DSMP_SYNCPOINTS, len);
pos = isps.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
IndexedSyncPoint& isp = isps.GetNext(pos);
int irt = GetByteLength(myabs(isp.rt));
@@ -416,8 +405,9 @@ void CDSMMuxerFilter::IndexSyncPoint(const MuxerPacket* p, __int64 fp)
// 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())
+ if(fp < 0 || !p || !p->IsTimeValid() || !p->IsSyncPoint()) {
return;
+ }
ASSERT(p->rtStart >= m_rtPrevSyncPoint);
m_rtPrevSyncPoint = p->rtStart;
@@ -433,8 +423,7 @@ void CDSMMuxerFilter::IndexSyncPoint(const MuxerPacket* p, __int64 fp)
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
- {
+ 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;
@@ -445,12 +434,12 @@ void CDSMMuxerFilter::IndexSyncPoint(const MuxerPacket* p, __int64 fp)
}
POSITION pos = m_sps.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
POSITION cur = pos;
SyncPoint& sp2 = m_sps.GetNext(pos);
- if(sp2.id == sp.id && sp2.rtStop <= sp.rtStop || sp2.rtStop <= sp.rtStart)
+ if(sp2.id == sp.id && sp2.rtStop <= sp.rtStop || sp2.rtStop <= sp.rtStart) {
m_sps.RemoveAt(cur);
+ }
}
m_sps.AddTail(sp);
diff --git a/src/filters/muxer/MatroskaMuxer/MatroskaFile.cpp b/src/filters/muxer/MatroskaMuxer/MatroskaFile.cpp
index d1af9a3e4..14660e5b9 100644
--- a/src/filters/muxer/MatroskaMuxer/MatroskaFile.cpp
+++ b/src/filters/muxer/MatroskaMuxer/MatroskaFile.cpp
@@ -27,8 +27,9 @@ using namespace MatroskaWriter;
static void bswap(BYTE* s, int len)
{
- for(BYTE* d = s + len-1; s < d; s++, d--)
+ for(BYTE* d = s + len-1; s < d; s++, d--) {
*s ^= *d, *d ^= *s, *s ^= *d;
+ }
}
//
@@ -65,17 +66,23 @@ HRESULT CID::HeaderWrite(IStream* pStream)
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);
+ 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);
@@ -83,17 +90,23 @@ HRESULT CBinary::Write(IStream* pStream)
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);
+ 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);
@@ -101,17 +114,23 @@ HRESULT CANSI::Write(IStream* pStream)
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);
+ 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);
@@ -121,18 +140,24 @@ HRESULT CUTF8::Write(IStream* pStream)
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);
+ 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;
@@ -142,32 +167,33 @@ HRESULT CSimpleVar<T, BASE>::Write(IStream* pStream)
MatroskaWriter::QWORD CUInt::Size(bool fWithHeader)
{
- if(!m_fSet) return 0;
+ if(!m_fSet) {
+ return 0;
+ }
MatroskaWriter::QWORD len = 0;
- if(m_val == 0)
- {
+ if(m_val == 0) {
len++;
- }
- else
- {
- for(int i = 8; i > 0; i--)
- {
- if(((0xffi64<<((i-1)*8))&m_val))
- {
+ } else {
+ for(int i = 8; i > 0; i--) {
+ if(((0xffi64<<((i-1)*8))&m_val)) {
len += i;
break;
}
}
}
- if(fWithHeader) len += HeaderSize(len);
+ 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));
@@ -179,35 +205,37 @@ HRESULT CUInt::Write(IStream* pStream)
MatroskaWriter::QWORD CInt::Size(bool fWithHeader)
{
- if(!m_fSet) return 0;
+ if(!m_fSet) {
+ return 0;
+ }
MatroskaWriter::QWORD len = 0;
- if(m_val == 0)
- {
+ if(m_val == 0) {
len++;
- }
- else
- {
+ } else {
UINT64 val = m_val >= 0 ? m_val : -m_val;
- for(int i = 8; i > 0; i--)
- {
- if(((0xffi64<<((i-1)*8))&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))))
+ if(m_val < 0 && !(m_val&(0x80<<(i-1)))) {
len++;
+ }
break;
}
}
}
- if(fWithHeader) len += HeaderSize(len);
+ 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));
@@ -219,14 +247,13 @@ HRESULT CInt::Write(IStream* pStream)
MatroskaWriter::QWORD CLength::Size(bool fWithHeader)
{
- if(m_len == 0x00FFFFFFFFFFFFFFi64)
+ 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))
- {
+ 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;
}
@@ -267,7 +294,9 @@ MatroskaWriter::QWORD EBML::Size(bool fWithHeader)
len += DocType.Size();
len += DocTypeVersion.Size();
len += DocTypeReadVersion.Size();
- if(fWithHeader) len += HeaderSize(len);
+ if(fWithHeader) {
+ len += HeaderSize(len);
+ }
return len;
}
@@ -316,7 +345,9 @@ MatroskaWriter::QWORD Info::Size(bool fWithHeader)
len += Title.Size();
len += MuxingApp.Size();
len += WritingApp.Size();
- if(fWithHeader) len += HeaderSize(len);
+ if(fWithHeader) {
+ len += HeaderSize(len);
+ }
return len;
}
@@ -346,11 +377,11 @@ Segment::Segment(DWORD id)
MatroskaWriter::QWORD Segment::Size(bool fWithHeader)
{
return 0x00FFFFFFFFFFFFFFi64;
-/*
- MatroskaWriter::QWORD len = 0;
- if(fWithHeader) len += HeaderSize(len);
- return len;
-*/
+ /*
+ MatroskaWriter::QWORD len = 0;
+ if(fWithHeader) len += HeaderSize(len);
+ return len;
+ */
}
HRESULT Segment::Write(IStream* pStream)
@@ -368,7 +399,9 @@ MatroskaWriter::QWORD Track::Size(bool fWithHeader)
{
MatroskaWriter::QWORD len = 0;
len += TrackEntries.Size();
- if(fWithHeader) len += HeaderSize(len);
+ if(fWithHeader) {
+ len += HeaderSize(len);
+ }
return len;
}
@@ -428,9 +461,15 @@ MatroskaWriter::QWORD TrackEntry::Size(bool fWithHeader)
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);
+ if(DescType == TypeVideo) {
+ len += v.Size();
+ }
+ if(DescType == TypeAudio) {
+ len += a.Size();
+ }
+ if(fWithHeader) {
+ len += HeaderSize(len);
+ }
return len;
}
@@ -456,8 +495,12 @@ HRESULT TrackEntry::Write(IStream* pStream)
CodecDecodeAll.Write(pStream);
TrackOverlay.Write(pStream);
DefaultDuration.Write(pStream);
- if(DescType == TypeVideo) v.Write(pStream);
- if(DescType == TypeAudio) a.Write(pStream);
+ if(DescType == TypeVideo) {
+ v.Write(pStream);
+ }
+ if(DescType == TypeAudio) {
+ a.Write(pStream);
+ }
return S_OK;
}
@@ -491,7 +534,9 @@ MatroskaWriter::QWORD Video::Size(bool fWithHeader)
len += ColourSpace.Size();
len += GammaValue.Size();
len += FramePerSec.Size();
- if(fWithHeader) len += HeaderSize(len);
+ if(fWithHeader) {
+ len += HeaderSize(len);
+ }
return len;
}
@@ -530,7 +575,9 @@ MatroskaWriter::QWORD Audio::Size(bool fWithHeader)
len += Channels.Size();
len += ChannelPositions.Size();
len += BitDepth.Size();
- if(fWithHeader) len += HeaderSize(len);
+ if(fWithHeader) {
+ len += HeaderSize(len);
+ }
return len;
}
@@ -560,7 +607,9 @@ MatroskaWriter::QWORD Cluster::Size(bool fWithHeader)
len += Position.Size();
len += PrevSize.Size();
len += BlockGroups.Size();
- if(fWithHeader) len += HeaderSize(len);
+ if(fWithHeader) {
+ len += HeaderSize(len);
+ }
return len;
}
@@ -593,7 +642,9 @@ MatroskaWriter::QWORD BlockGroup::Size(bool fWithHeader)
len += ReferenceVirtual.Size();
len += CodecState.Size();
len += Block.Size();
- if(fWithHeader) len += HeaderSize(len);
+ if(fWithHeader) {
+ len += HeaderSize(len);
+ }
return len;
}
@@ -619,23 +670,24 @@ MatroskaWriter::QWORD CBlock::Size(bool fWithHeader)
{
MatroskaWriter::QWORD len = 0;
len += TrackNumber.Size() + 2 + 1; // TrackNumber + TimeCode + Lacing
- if(BlockData.GetCount() > 1)
- {
+ if(BlockData.GetCount() > 1) {
len += 1; // nBlockData
POSITION pos = BlockData.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CBinary* b = BlockData.GetNext(pos);
- if(pos) len += b->GetCount()/255 + 1;
+ if(pos) {
+ len += b->GetCount()/255 + 1;
+ }
}
}
POSITION pos = BlockData.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CBinary* b = BlockData.GetNext(pos);
len += b->GetCount();
}
- if(fWithHeader) len += HeaderSize(len);
+ if(fWithHeader) {
+ len += HeaderSize(len);
+ }
return len;
}
@@ -648,20 +700,18 @@ HRESULT CBlock::Write(IStream* pStream)
pStream->Write(&t, 2, NULL);
BYTE Lacing = 0;
BYTE n = BlockData.GetCount();
- if(n > 1) Lacing |= 2;
+ if(n > 1) {
+ Lacing |= 2;
+ }
pStream->Write(&Lacing, 1, NULL);
- if(n > 1)
- {
+ if(n > 1) {
pStream->Write(&n, 1, NULL);
POSITION pos = BlockData.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CBinary* b = BlockData.GetNext(pos);
- if(pos)
- {
+ if(pos) {
int len = b->GetCount();
- while(len >= 0)
- {
+ while(len >= 0) {
n = min(len, 255);
pStream->Write(&n, 1, NULL);
len -= 255;
@@ -670,8 +720,7 @@ HRESULT CBlock::Write(IStream* pStream)
}
}
POSITION pos = BlockData.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CBinary* b = BlockData.GetNext(pos);
pStream->Write(b->GetData(), b->GetCount(), NULL);
}
@@ -687,7 +736,9 @@ MatroskaWriter::QWORD Cue::Size(bool fWithHeader)
{
MatroskaWriter::QWORD len = 0;
len += CuePoints.Size();
- if(fWithHeader) len += HeaderSize(len);
+ if(fWithHeader) {
+ len += HeaderSize(len);
+ }
return len;
}
@@ -709,7 +760,9 @@ MatroskaWriter::QWORD CuePoint::Size(bool fWithHeader)
MatroskaWriter::QWORD len = 0;
len += CueTime.Size();
len += CueTrackPositions.Size();
- if(fWithHeader) len += HeaderSize(len);
+ if(fWithHeader) {
+ len += HeaderSize(len);
+ }
return len;
}
@@ -737,8 +790,10 @@ MatroskaWriter::QWORD CueTrackPosition::Size(bool fWithHeader)
len += CueClusterPosition.Size();
len += CueBlockNumber.Size();
len += CueCodecState.Size();
-// len += CueReferences.Size();
- if(fWithHeader) len += HeaderSize(len);
+ // len += CueReferences.Size();
+ if(fWithHeader) {
+ len += HeaderSize(len);
+ }
return len;
}
@@ -749,7 +804,7 @@ HRESULT CueTrackPosition::Write(IStream* pStream)
CueClusterPosition.Write(pStream);
CueBlockNumber.Write(pStream);
CueCodecState.Write(pStream);
-// CueReferences.Write(pStream);
+ // CueReferences.Write(pStream);
return S_OK;
}
@@ -762,7 +817,9 @@ MatroskaWriter::QWORD Seek::Size(bool fWithHeader)
{
MatroskaWriter::QWORD len = 0;
len += SeekHeads.Size();
- if(fWithHeader) len += HeaderSize(len);
+ if(fWithHeader) {
+ len += HeaderSize(len);
+ }
return len;
}
@@ -783,7 +840,9 @@ MatroskaWriter::QWORD SeekID::Size(bool fWithHeader)
{
MatroskaWriter::QWORD len = 0;
len += m_id.Size();
- if(fWithHeader) len += HeaderSize(len);
+ if(fWithHeader) {
+ len += HeaderSize(len);
+ }
return len;
}
@@ -805,7 +864,9 @@ MatroskaWriter::QWORD SeekHead::Size(bool fWithHeader)
MatroskaWriter::QWORD len = 0;
len += ID.Size();
len += Position.Size();
- if(fWithHeader) len += HeaderSize(len);
+ if(fWithHeader) {
+ len += HeaderSize(len);
+ }
return len;
}
@@ -825,15 +886,17 @@ Tags::Tags(DWORD id)
MatroskaWriter::QWORD Tags::Size(bool fWithHeader)
{
MatroskaWriter::QWORD len = 0;
-// len += .Size();
- if(fWithHeader) len += HeaderSize(len);
+ // len += .Size();
+ if(fWithHeader) {
+ len += HeaderSize(len);
+ }
return len;
}
HRESULT Tags::Write(IStream* pStream)
{
HeaderWrite(pStream);
-// .Write(pStream);
+ // .Write(pStream);
return S_OK;
}
@@ -847,7 +910,9 @@ MatroskaWriter::QWORD Void::Size(bool fWithHeader)
{
MatroskaWriter::QWORD len = 0;
len += m_len;
- if(fWithHeader) len += HeaderSize(len);
+ if(fWithHeader) {
+ len += HeaderSize(len);
+ }
return len;
}
@@ -856,7 +921,8 @@ 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))
+ 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 feb94cd6c..477d9c990 100644
--- a/src/filters/muxer/MatroskaMuxer/MatroskaFile.h
+++ b/src/filters/muxer/MatroskaMuxer/MatroskaFile.h
@@ -26,393 +26,395 @@
namespace MatroskaWriter
{
-typedef unsigned __int64 QWORD;
+ 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((char*)GetData(), 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 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((char*)GetData(), 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 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 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 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) {}
-};
+ 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)
+ template<class T>
+ class CNode : public CAutoPtrList<T>
{
- QWORD len = 0;
- POSITION pos = GetHeadPosition();
- while(pos) len += GetNext(pos)->Size(fWithHeader);
- return len;
- }
- HRESULT Write(IStream* pStream)
+ 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
{
- 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;
+ 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);
-};
+ 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;
+ 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);
-};
+ 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;
+ 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);
-};
+ CueTrackPosition(DWORD id = 0xB7);
+ QWORD Size(bool fWithHeader = true);
+ HRESULT Write(IStream* pStream);
+ };
-class CuePoint : public CID
-{
-public:
- CUInt CueTime;
- CNode<CueTrackPosition> CueTrackPositions;
+ class CuePoint : public CID
+ {
+ public:
+ CUInt CueTime;
+ CNode<CueTrackPosition> CueTrackPositions;
- CuePoint(DWORD id = 0xBB);
- QWORD Size(bool fWithHeader = true);
- HRESULT Write(IStream* pStream);
-};
+ CuePoint(DWORD id = 0xBB);
+ QWORD Size(bool fWithHeader = true);
+ HRESULT Write(IStream* pStream);
+ };
-class Cue : public CID
-{
-public:
- CNode<CuePoint> CuePoints;
+ class Cue : public CID
+ {
+ public:
+ CNode<CuePoint> CuePoints;
- Cue(DWORD id = 0x1C53BB6B);
- QWORD Size(bool fWithHeader = true);
- HRESULT Write(IStream* pStream);
-};
+ 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;
+ 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);
-};
+ SeekHead(DWORD id = 0x4DBB);
+ QWORD Size(bool fWithHeader = true);
+ HRESULT Write(IStream* pStream);
+ };
-class Seek : public CID
-{
-public:
- CNode<SeekHead> SeekHeads;
+ class Seek : public CID
+ {
+ public:
+ CNode<SeekHead> SeekHeads;
- Seek(DWORD id = 0x114D9B74);
- QWORD Size(bool fWithHeader = true);
- HRESULT Write(IStream* pStream);
-};
+ 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 Segment : public CID
+ {
+ public:
+ Segment(DWORD id = 0x18538067);
+ QWORD Size(bool fWithHeader = true);
+ HRESULT Write(IStream* pStream);
+ };
-class Tags : public CID
-{
-public:
- // TODO
+ class Tags : public CID
+ {
+ public:
+ // TODO
- Tags(DWORD id = 0x1254C367);
- QWORD Size(bool fWithHeader = true);
- HRESULT Write(IStream* pStream);
-};
+ 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);
-};
+ 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 68d3b89d2..d79d30b04 100644
--- a/src/filters/muxer/MatroskaMuxer/MatroskaMuxer.cpp
+++ b/src/filters/muxer/MatroskaMuxer/MatroskaMuxer.cpp
@@ -31,24 +31,20 @@ using namespace MatroskaWriter;
#ifdef REGISTER_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
{&MEDIATYPE_Stream, &MEDIASUBTYPE_Matroska}
};
-const AMOVIESETUP_PIN sudpPins[] =
-{
+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}
};
-const AMOVIESETUP_FILTER sudFilter[] =
-{
+const AMOVIESETUP_FILTER sudFilter[] = {
{&__uuidof(CMatroskaMuxerFilter), L"MPC - Matroska Muxer", MERIT_DO_NOT_USE, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory}
};
-CFactoryTemplate g_Templates[] =
-{
+CFactoryTemplate g_Templates[] = {
{sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CMatroskaMuxerFilter>, NULL, &sudFilter[0]}
};
@@ -79,7 +75,9 @@ CMatroskaMuxerFilter::CMatroskaMuxerFilter(LPUNKNOWN pUnk, HRESULT* phr)
, 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));
@@ -100,7 +98,7 @@ STDMETHODIMP CMatroskaMuxerFilter::NonDelegatingQueryInterface(REFIID riid, void
*ppv = NULL;
return
-// QI(IAMFilterMiscFlags)
+ // QI(IAMFilterMiscFlags)
QI(IMediaSeeking)
QI(IMatroskaMuxer)
__super::NonDelegatingQueryInterface(riid, ppv);
@@ -111,11 +109,11 @@ UINT CMatroskaMuxerFilter::GetTrackNumber(CBasePin* pPin)
UINT nTrackNumber = 0;
POSITION pos = m_pInputs.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
nTrackNumber++;
- if(m_pInputs.GetNext(pos) == pPin)
+ if(m_pInputs.GetNext(pos) == pPin) {
return nTrackNumber;
+ }
}
return 0;
@@ -124,10 +122,11 @@ UINT CMatroskaMuxerFilter::GetTrackNumber(CBasePin* pPin)
void CMatroskaMuxerFilter::AddInput()
{
POSITION pos = m_pInputs.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CBasePin* pPin = m_pInputs.GetNext(pos);
- if(!pPin->IsConnected()) return;
+ if(!pPin->IsConnected()) {
+ return;
+ }
}
CStringW name;
@@ -147,14 +146,13 @@ CBasePin* CMatroskaMuxerFilter::GetPin(int n)
{
CAutoLock cAutoLock(this);
- if(n >= 0 && n < (int)m_pInputs.GetCount())
- {
- if(POSITION pos = m_pInputs.FindIndex(n))
+ 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)
- {
+ if(n == m_pInputs.GetCount() && m_pOutput) {
return m_pOutput;
}
@@ -167,8 +165,9 @@ STDMETHODIMP CMatroskaMuxerFilter::Stop()
HRESULT hr;
- if(FAILED(hr = __super::Stop()))
+ if(FAILED(hr = __super::Stop())) {
return hr;
+ }
CallWorker(CMD_EXIT);
@@ -183,11 +182,11 @@ STDMETHODIMP CMatroskaMuxerFilter::Pause()
HRESULT hr;
- if(FAILED(hr = __super::Pause()))
+ if(FAILED(hr = __super::Pause())) {
return hr;
+ }
- if(fs == State_Stopped && m_pOutput)
- {
+ if(fs == State_Stopped && m_pOutput) {
CAMThread::Create();
CallWorker(CMD_RUN);
}
@@ -201,8 +200,9 @@ STDMETHODIMP CMatroskaMuxerFilter::Run(REFERENCE_TIME tStart)
HRESULT hr;
- if(FAILED(hr = __super::Run(tStart)))
+ if(FAILED(hr = __super::Run(tStart))) {
return hr;
+ }
return hr;
}
@@ -225,25 +225,32 @@ STDMETHODIMP CMatroskaMuxerFilter::GetCapabilities(DWORD* pCapabilities)
STDMETHODIMP CMatroskaMuxerFilter::CheckCapabilities(DWORD* pCapabilities)
{
CheckPointer(pCapabilities, E_POINTER);
- if(*pCapabilities == 0) return S_OK;
+ 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) {
+STDMETHODIMP CMatroskaMuxerFilter::IsFormatSupported(const GUID* pFormat)
+{
return !pFormat ? E_POINTER : *pFormat == TIME_FORMAT_MEDIA_TIME ? S_OK : S_FALSE;
}
-STDMETHODIMP CMatroskaMuxerFilter::QueryPreferredFormat(GUID* pFormat) {
+STDMETHODIMP CMatroskaMuxerFilter::QueryPreferredFormat(GUID* pFormat)
+{
return GetTimeFormat(pFormat);
}
-STDMETHODIMP CMatroskaMuxerFilter::GetTimeFormat(GUID* pFormat) {
+STDMETHODIMP CMatroskaMuxerFilter::GetTimeFormat(GUID* pFormat)
+{
return pFormat ? *pFormat = TIME_FORMAT_MEDIA_TIME, S_OK : E_POINTER;
}
-STDMETHODIMP CMatroskaMuxerFilter::IsUsingTimeFormat(const GUID* pFormat) {
+STDMETHODIMP CMatroskaMuxerFilter::IsUsingTimeFormat(const GUID* pFormat)
+{
return IsFormatSupported(pFormat);
}
-STDMETHODIMP CMatroskaMuxerFilter::SetTimeFormat(const GUID* pFormat) {
+STDMETHODIMP CMatroskaMuxerFilter::SetTimeFormat(const GUID* pFormat)
+{
return S_OK == IsFormatSupported(pFormat) ? S_OK : E_INVALIDARG;
}
STDMETHODIMP CMatroskaMuxerFilter::GetDuration(LONGLONG* pDuration)
@@ -253,11 +260,14 @@ STDMETHODIMP CMatroskaMuxerFilter::GetDuration(LONGLONG* pDuration)
POSITION pos = m_pInputs.GetHeadPosition();
while(pos) {
REFERENCE_TIME rt = m_pInputs.GetNext(pos)->m_rtDur;
- if(rt > *pDuration) *pDuration = rt;
+ if(rt > *pDuration) {
+ *pDuration = rt;
+ }
}
return S_OK;
}
-STDMETHODIMP CMatroskaMuxerFilter::GetStopPosition(LONGLONG* pStop) {
+STDMETHODIMP CMatroskaMuxerFilter::GetStopPosition(LONGLONG* pStop)
+{
return E_NOTIMPL;
}
STDMETHODIMP CMatroskaMuxerFilter::GetCurrentPosition(LONGLONG* pCurrent)
@@ -266,25 +276,32 @@ STDMETHODIMP CMatroskaMuxerFilter::GetCurrentPosition(LONGLONG* pCurrent)
*pCurrent = m_rtCurrent;
return S_OK;
}
-STDMETHODIMP CMatroskaMuxerFilter::ConvertTimeFormat(LONGLONG* pTarget, const GUID* pTargetFormat, LONGLONG Source, const GUID* pSourceFormat) {
+STDMETHODIMP CMatroskaMuxerFilter::ConvertTimeFormat(LONGLONG* pTarget, const GUID* pTargetFormat, LONGLONG Source, const GUID* pSourceFormat)
+{
return E_NOTIMPL;
}
-STDMETHODIMP CMatroskaMuxerFilter::SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags) {
+STDMETHODIMP CMatroskaMuxerFilter::SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags)
+{
return E_NOTIMPL;
}
-STDMETHODIMP CMatroskaMuxerFilter::GetPositions(LONGLONG* pCurrent, LONGLONG* pStop) {
+STDMETHODIMP CMatroskaMuxerFilter::GetPositions(LONGLONG* pCurrent, LONGLONG* pStop)
+{
return E_NOTIMPL;
}
-STDMETHODIMP CMatroskaMuxerFilter::GetAvailable(LONGLONG* pEarliest, LONGLONG* pLatest) {
+STDMETHODIMP CMatroskaMuxerFilter::GetAvailable(LONGLONG* pEarliest, LONGLONG* pLatest)
+{
return E_NOTIMPL;
}
-STDMETHODIMP CMatroskaMuxerFilter::SetRate(double dRate) {
+STDMETHODIMP CMatroskaMuxerFilter::SetRate(double dRate)
+{
return E_NOTIMPL;
}
-STDMETHODIMP CMatroskaMuxerFilter::GetRate(double* pdRate) {
+STDMETHODIMP CMatroskaMuxerFilter::GetRate(double* pdRate)
+{
return E_NOTIMPL;
}
-STDMETHODIMP CMatroskaMuxerFilter::GetPreroll(LONGLONG* pllPreroll) {
+STDMETHODIMP CMatroskaMuxerFilter::GetPreroll(LONGLONG* pllPreroll)
+{
return E_NOTIMPL;
}
@@ -320,14 +337,16 @@ DWORD CMatroskaMuxerFilter::ThreadProc()
{
CComQIPtr<IStream> pStream;
- if(!m_pOutput || !(pStream = m_pOutput->GetConnected()))
- {
- while(1)
- {
+ if(!m_pOutput || !(pStream = m_pOutput->GetConnected())) {
+ while(1) {
DWORD cmd = GetRequest();
- if(cmd == CMD_EXIT) CAMThread::m_hThread = NULL;
+ if(cmd == CMD_EXIT) {
+ CAMThread::m_hThread = NULL;
+ }
Reply(S_OK);
- if(cmd == CMD_EXIT) return 0;
+ if(cmd == CMD_EXIT) {
+ return 0;
+ }
}
}
@@ -350,8 +369,11 @@ DWORD CMatroskaMuxerFilter::ThreadProc()
// 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)
+ 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);
@@ -421,257 +443,239 @@ DWORD CMatroskaMuxerFilter::ThreadProc()
CAtlList<CMatroskaMuxerInputPin*> pActivePins;
POSITION pos = m_pInputs.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CMatroskaMuxerInputPin* pPin = m_pInputs.GetNext(pos);
- if(pPin->IsConnected()) pActivePins.AddTail(pPin);
+ if(pPin->IsConnected()) {
+ pActivePins.AddTail(pPin);
+ }
}
- while(1)
- {
+ while(1) {
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;
+ 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;
+ }
- while(!CheckRequest(NULL))
- {
- if(m_State == State_Paused)
- {
- Sleep(10);
- continue;
- }
+ int nPinsGotSomething = 0, nPinsNeeded = 0;
+ CMatroskaMuxerInputPin* pPin = NULL;
+ REFERENCE_TIME rtMin = _I64_MAX;
- int nPinsGotSomething = 0, nPinsNeeded = 0;
- CMatroskaMuxerInputPin* pPin = NULL;
- REFERENCE_TIME rtMin = _I64_MAX;
+ pos = pActivePins.GetHeadPosition();
+ while(pos) {
+ CMatroskaMuxerInputPin* pTmp = pActivePins.GetNext(pos);
- pos = pActivePins.GetHeadPosition();
- while(pos)
- {
- CMatroskaMuxerInputPin* pTmp = pActivePins.GetNext(pos);
+ CAutoLock cAutoLock(&pTmp->m_csQueue);
- CAutoLock cAutoLock(&pTmp->m_csQueue);
+ if(pTmp->m_blocks.GetCount() == 0 && pTmp->m_fEndOfStreamReceived) {
+ pActivePins.RemoveAt(pActivePins.Find(pTmp));
+ continue;
+ }
- if(pTmp->m_blocks.GetCount() == 0 && pTmp->m_fEndOfStreamReceived)
- {
- pActivePins.RemoveAt(pActivePins.Find(pTmp));
- continue;
- }
+ if(pTmp->GetTrackEntry()->TrackType != TrackEntry::TypeSubtitle) {
+ nPinsNeeded++;
+ }
- 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)
- {
- 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(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);
+ if(pActivePins.GetCount() == 0) {
+ break;
+ }
- CAutoPtr<TrackEntry> pTE(DNew TrackEntry());
- *pTE = *pPin->GetTrackEntry();
- if(TrackNumber == 0 && pTE->TrackType == TrackEntry::TypeVideo)
- TrackNumber = pTE->TrackNumber;
- pT->TrackEntries.AddTail(pTE);
+ if(!pPin || nPinsNeeded > nPinsGotSomething || !pPin && nPinsGotSomething == 0) {
+ Sleep(1);
+ continue;
}
- Tracks.AddTail(pT);
- Tracks.Write(pStream);
- if(TrackNumber == 0) TrackNumber = 1;
+ 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);
- fTracksWritten = true;
- }
+ if(TrackNumber == 0) {
+ TrackNumber = 1;
+ }
- ASSERT(pPin);
+ fTracksWritten = true;
+ }
- CAutoPtr<BlockGroup> b;
+ ASSERT(pPin);
- {
- CAutoLock cAutoLock(&pPin->m_csQueue);
- b = pPin->m_blocks.RemoveHead();
- }
+ CAutoPtr<BlockGroup> b;
- if(b)
- {
- if(fFirstBlock)
{
- if(b->Block.TimeCode < 0 && m_fNegative || b->Block.TimeCode > 0 && m_fPositive)
- firstTimeCode = b->Block.TimeCode;
- fFirstBlock = false;
+ CAutoLock cAutoLock(&pPin->m_csQueue);
+ b = pPin->m_blocks.RemoveHead();
}
- 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;
- }
+ if(b) {
+ if(fFirstBlock) {
+ if(b->Block.TimeCode < 0 && m_fNegative || b->Block.TimeCode > 0 && m_fPositive) {
+ firstTimeCode = b->Block.TimeCode;
+ }
+ fFirstBlock = false;
+ }
- 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
+ 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;
}
- c.TimeCode.Set(c.TimeCode + MAXCLUSTERTIME);
- c.BlockGroups.RemoveAll();
- nBlocksInCueTrack = 0;
- }
+ 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);
- if(b->Block.TrackNumber == TrackNumber)
- {
- nBlocksInCueTrack++;
- }
+ c.Write(pStream); // TODO: write blocks
+ }
- 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;
+ c.TimeCode.Set(c.TimeCode + MAXCLUSTERTIME);
+ c.BlockGroups.RemoveAll();
+ nBlocksInCueTrack = 0;
}
- }
- info.Duration.Set(max(info.Duration, (float)b->Block.TimeCodeStop));
+ if(b->Block.TrackNumber == TrackNumber) {
+ nBlocksInCueTrack++;
+ }
- m_rtCurrent = b->Block.TimeCode*10000;
+ 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;
+ }
+ }
- b->Block.TimeCode -= c.TimeCode;
- c.BlockGroups.AddTail(b);
- }
- }
+ info.Duration.Set(max(info.Duration, (float)b->Block.TimeCodeStop));
- if(!c.BlockGroups.IsEmpty())
- {
- sh.Attach(DNew SeekHead());
- sh->ID.Set(c.GetID()/*0x1F43B675*/);
- sh->Position.Set(GetStreamPosition(pStream) - segpos);
- seek.SeekHeads.AddTail(sh);
+ m_rtCurrent = b->Block.TimeCode*10000;
- c.Write(pStream);
- }
+ b->Block.TimeCode -= c.TimeCode;
+ c.BlockGroups.AddTail(b);
+ }
+ }
- if(!cue.CuePoints.IsEmpty())
- {
- sh.Attach(DNew SeekHead());
- sh->ID.Set(cue.GetID()/*0x1C53BB6B*/);
- sh->Position.Set(GetStreamPosition(pStream) - segpos);
- seek.SeekHeads.AddTail(sh);
+ if(!c.BlockGroups.IsEmpty()) {
+ sh.Attach(DNew SeekHead());
+ sh->ID.Set(c.GetID()/*0x1F43B675*/);
+ sh->Position.Set(GetStreamPosition(pStream) - segpos);
+ seek.SeekHeads.AddTail(sh);
- cue.Write(pStream);
- }
+ c.Write(pStream);
+ }
- {
- Tags tags;
+ if(!cue.CuePoints.IsEmpty()) {
+ sh.Attach(DNew SeekHead());
+ sh->ID.Set(cue.GetID()/*0x1C53BB6B*/);
+ sh->Position.Set(GetStreamPosition(pStream) - segpos);
+ seek.SeekHeads.AddTail(sh);
- sh.Attach(DNew SeekHead());
- sh->ID.Set(tags.GetID());
- sh->Position.Set(GetStreamPosition(pStream) - segpos);
- seek.SeekHeads.AddTail(sh);
+ cue.Write(pStream);
+ }
- tags.Write(pStream);
- }
+ {
+ Tags tags;
- SetStreamPosition(pStream, voidpos);
- int len = (int)(voidlen - seek.Size());
- ASSERT(len >= 0 && len != 1);
- seek.Write(pStream);
+ sh.Attach(DNew SeekHead());
+ sh->ID.Set(tags.GetID());
+ sh->Position.Set(GetStreamPosition(pStream) - segpos);
+ seek.SeekHeads.AddTail(sh);
- 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;
+ 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);
- }
+ if(abs(m_rtCurrent - (REFERENCE_TIME)info.Duration*10000) > 10000000i64) {
+ info.Duration.Set(m_rtCurrent / 10000 + 1);
+ }
- SetStreamPosition(pStream, infopos);
- info.Write(pStream);
+ SetStreamPosition(pStream, infopos);
+ info.Write(pStream);
- // TODO: write some tags
+ // TODO: write some tags
- m_pOutput->DeliverEndOfStream();
+ m_pOutput->DeliverEndOfStream();
- break;
+ break;
}
}
@@ -708,31 +712,32 @@ STDMETHODIMP CMatroskaMuxerInputPin::NonDelegatingQueryInterface(REFIID riid, vo
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;
+ || 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;
- if(FAILED(hr = __super::BreakConnect()))
+ if(FAILED(hr = __super::BreakConnect())) {
return hr;
+ }
m_pTE.Free();
@@ -743,13 +748,15 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin)
{
HRESULT hr;
- if(FAILED(hr = __super::CompleteConnect(pPin)))
+ if(FAILED(hr = __super::CompleteConnect(pPin))) {
return hr;
+ }
m_rtDur = 0;
CComQIPtr<IMediaSeeking> pMS;
- if((pMS = GetFilterFromPin(pPin)) || (pMS = pPin))
+ if((pMS = GetFilterFromPin(pPin)) || (pMS = pPin)) {
pMS->GetDuration(&m_rtDur);
+ }
m_pTE.Free();
m_pTE.Attach(DNew TrackEntry());
@@ -761,22 +768,18 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin)
hr = E_FAIL;
- if(m_mt.majortype == MEDIATYPE_Video)
- {
+ 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_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)
- {
+ if(m_mt.formattype == FORMAT_VideoInfo) {
VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)m_mt.pbFormat;
- if(m_mt.cbFormat > sizeof(VIDEOINFOHEADER))
- {
+ 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());
}
@@ -784,14 +787,12 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin)
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)
+ if(vih->AvgTimePerFrame > 0) {
m_pTE->v.FramePerSec.Set((float)(10000000.0 / vih->AvgTimePerFrame));
- }
- else if(m_mt.formattype == FORMAT_VideoInfo2)
- {
+ }
+ } else if(m_mt.formattype == FORMAT_VideoInfo2) {
VIDEOINFOHEADER2* vih = (VIDEOINFOHEADER2*)m_mt.pbFormat;
- if(m_mt.cbFormat > sizeof(VIDEOINFOHEADER2))
- {
+ 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());
}
@@ -799,21 +800,18 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin)
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)
+ 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
- {
+ } else {
ASSERT(0);
return hr;
}
hr = S_OK;
- }
- else if(m_mt.formattype == FORMAT_VideoInfo)
- {
+ } else if(m_mt.formattype == FORMAT_VideoInfo) {
m_pTE->CodecID.Set("V_MS/VFW/FOURCC");
VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)m_mt.pbFormat;
@@ -823,13 +821,12 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin)
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)
+ if(vih->AvgTimePerFrame > 0) {
m_pTE->v.FramePerSec.Set((float)(10000000.0 / vih->AvgTimePerFrame));
+ }
hr = S_OK;
- }
- else if(m_mt.formattype == FORMAT_VideoInfo2)
- {
+ } else if(m_mt.formattype == FORMAT_VideoInfo2) {
m_pTE->CodecID.Set("V_MS/VFW/FOURCC");
VIDEOINFOHEADER2* vih = (VIDEOINFOHEADER2*)m_mt.pbFormat;
@@ -841,13 +838,12 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin)
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)
+ if(vih->AvgTimePerFrame > 0) {
m_pTE->v.FramePerSec.Set((float)(10000000.0 / vih->AvgTimePerFrame));
+ }
hr = S_OK;
- }
- else if(m_mt.formattype == FORMAT_DiracVideoInfo)
- {
+ } else if(m_mt.formattype == FORMAT_DiracVideoInfo) {
m_pTE->CodecID.Set("V_DIRAC");
DIRACINFOHEADER* vih = (DIRACINFOHEADER*)m_mt.pbFormat;
@@ -859,8 +855,9 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin)
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)
+ if(vih->hdr.AvgTimePerFrame > 0) {
m_pTE->v.FramePerSec.Set((float)(10000000.0 / vih->hdr.AvgTimePerFrame));
+ }
hr = S_OK;
}
@@ -898,15 +895,12 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin)
hr = S_OK;
}
*/
- }
- else if(m_mt.majortype == MEDIATYPE_Audio)
- {
+ } 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*)m_mt.pbFormat)->wFormatTag == WAVE_FORMAT_AAC
+ && m_mt.cbFormat >= sizeof(WAVEFORMATEX)+2) {
WAVEFORMATEX* wfe = (WAVEFORMATEX*)m_mt.pbFormat;
BYTE* p = (BYTE*)(wfe+1);
@@ -918,8 +912,7 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin)
int exttype = 0;
int rate2 = rate1;
- if(wfe->cbSize >= 5)
- {
+ if(wfe->cbSize >= 5) {
profile = 4;
exttype = (p[2]<<3)|(p[3]>>5);
@@ -928,31 +921,29 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin)
ASSERT((p[4]>>7) == 1);
rate2 = ((p[4]>>3)&15);
- if(rate2 < rate1)
- {
+ 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;
+ 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);
@@ -963,10 +954,8 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin)
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)
- {
+ } 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;
@@ -976,10 +965,8 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin)
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)
- {
+ } 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;
@@ -989,10 +976,8 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin)
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)
- {
+ } 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;
@@ -1001,37 +986,33 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin)
m_pTE->a.Channels.Set(wfe->nChannels);
m_pTE->a.BitDepth.Set(wfe->wBitsPerSample);
- if(wfe->cbSize)
- {
+ 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))
- {
+ } 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));
+ (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());
+ 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);
@@ -1039,10 +1020,8 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin)
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)
- {
+ } 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;
@@ -1052,9 +1031,7 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin)
m_pTE->a.BitDepth.Set(wfe->wBitsPerSample);
hr = S_OK;
- }
- else if(m_mt.formattype == FORMAT_WaveFormatEx)
- {
+ } else if(m_mt.formattype == FORMAT_WaveFormatEx) {
m_pTE->CodecID.Set("A_MS/ACM");
WAVEFORMATEX* wfe = (WAVEFORMATEX*)m_mt.pbFormat;
@@ -1066,9 +1043,7 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin)
m_pTE->a.BitDepth.Set(wfe->wBitsPerSample);
hr = S_OK;
- }
- else if(m_mt.formattype == FORMAT_VorbisFormat)
- {
+ } else if(m_mt.formattype == FORMAT_VorbisFormat) {
m_pTE->CodecID.Set("A_VORBIS");
VORBISFORMAT* pvf = (VORBISFORMAT*)m_mt.pbFormat;
@@ -1079,9 +1054,7 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin)
// m_pTE->CodecPrivate will be filled later
hr = S_OK;
- }
- else if(m_mt.formattype == FORMAT_VorbisFormat2)
- {
+ } else if(m_mt.formattype == FORMAT_VorbisFormat2) {
m_pTE->CodecID.Set("A_VORBIS");
VORBISFORMAT2* pvf2 = (VORBISFORMAT2*)m_mt.pbFormat;
@@ -1091,8 +1064,12 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin)
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];
+ 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);
@@ -1100,8 +1077,9 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin)
*dst++ = 2;
for(int i = 0; i < 2; i++)
- for(int len = pvf2->HeaderSize[i]; len >= 0; len -= 255)
+ for(int len = pvf2->HeaderSize[i]; len >= 0; len -= 255) {
*dst++ = min(len, 255);
+ }
memcpy(dst, src, pvf2->HeaderSize[0]);
dst += pvf2->HeaderSize[0];
@@ -1118,19 +1096,14 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin)
hr = S_OK;
}
- }
- else if(m_mt.majortype == MEDIATYPE_Text)
- {
+ } else if(m_mt.majortype == MEDIATYPE_Text) {
m_pTE->TrackType.Set(TrackEntry::TypeSubtitle);
- if(m_mt.formattype == FORMAT_None)
- {
+ if(m_mt.formattype == FORMAT_None) {
m_pTE->CodecID.Set("S_TEXT/ASCII");
hr = S_OK;
}
- }
- else if(m_mt.majortype == MEDIATYPE_Subtitle)
- {
+ } else if(m_mt.majortype == MEDIATYPE_Subtitle) {
m_pTE->TrackType.Set(TrackEntry::TypeSubtitle);
m_pTE->CodecID.Set(
@@ -1141,21 +1114,18 @@ HRESULT CMatroskaMuxerInputPin::CompleteConnect(IPin* pPin)
m_mt.subtype == MEDIASUBTYPE_VOBSUB ? "S_VOBSUB" :
"");
- if(!m_pTE->CodecID.IsEmpty())
- {
+ if(!m_pTE->CodecID.IsEmpty()) {
hr = S_OK;
SUBTITLEINFO* psi = (SUBTITLEINFO*)m_mt.pbFormat;
- if(psi->dwOffset)
- {
+ 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)
- {
+ if(S_OK == hr) {
(static_cast<CMatroskaMuxerFilter*>(m_pFilter))->AddInput();
}
@@ -1204,23 +1174,26 @@ STDMETHODIMP CMatroskaMuxerInputPin::Receive(IMediaSample* pSample)
CAutoLock cAutoLock(&m_csReceive);
- while(m_fActive)
- {
+ while(m_fActive) {
{
CAutoLock cAutoLock2(&m_csQueue);
- if(m_blocks.GetCount() < MAXBLOCKS)
+ if(m_blocks.GetCount() < MAXBLOCKS) {
break;
+ }
}
Sleep(1);
}
- if(!m_fActive) return S_FALSE;
+ if(!m_fActive) {
+ return S_FALSE;
+ }
HRESULT hr;
- if(FAILED(hr = __super::Receive(pSample)))
+ if(FAILED(hr = __super::Receive(pSample))) {
return hr;
+ }
BYTE* pData = NULL;
pSample->GetPointer(&pData);
@@ -1230,15 +1203,14 @@ STDMETHODIMP CMatroskaMuxerInputPin::Receive(IMediaSample* pSample)
REFERENCE_TIME rtStart = -1, rtStop = -1;
hr = pSample->GetTime(&rtStart, &rtStop);
- if(FAILED(hr) || rtStart == -1 || rtStop == -1)
- {
+ 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;
+ // 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"),
@@ -1249,29 +1221,31 @@ STDMETHODIMP CMatroskaMuxerInputPin::Receive(IMediaSample* pSample)
pSample->IsPreroll() == S_OK ? 1 : 0,
pSample->IsSyncPoint() == S_OK ? 1 : 0);
- if(m_mt.subtype == MEDIASUBTYPE_Vorbis && m_pVorbisHdrs.GetCount() < 3)
- {
+ 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)
- {
+ if(m_pVorbisHdrs.GetCount() == 3) {
int len = 1;
- for(int i = 0; i < 2; i++) len += m_pVorbisHdrs[i]->GetCount()/255 + 1;
- for(int i = 0; i < 3; i++) len += m_pVorbisHdrs[i]->GetCount();
+ for(int i = 0; i < 2; i++) {
+ len += m_pVorbisHdrs[i]->GetCount()/255 + 1;
+ }
+ for(int i = 0; i < 3; i++) {
+ len += m_pVorbisHdrs[i]->GetCount();
+ }
m_pTE->CodecPrivate.SetCount(len);
BYTE* dst = m_pTE->CodecPrivate.GetData();
*dst++ = 2;
for(int i = 0; i < 2; i++)
- for(int len = m_pVorbisHdrs[i]->GetCount(); len >= 0; len -= 255)
+ for(int len = m_pVorbisHdrs[i]->GetCount(); len >= 0; len -= 255) {
*dst++ = min(len, 255);
+ }
- for(int i = 0; i < 3; i++)
- {
+ for(int i = 0; i < 3; i++) {
memcpy(dst, m_pVorbisHdrs[i]->GetData(), m_pVorbisHdrs[i]->GetCount());
dst += m_pVorbisHdrs[i]->GetCount();
}
@@ -1281,21 +1255,21 @@ STDMETHODIMP CMatroskaMuxerInputPin::Receive(IMediaSample* pSample)
}
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
+ && (((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*/)
- {
+ /*
+ // 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);
@@ -1306,8 +1280,7 @@ STDMETHODIMP CMatroskaMuxerInputPin::Receive(IMediaSample* pSample)
b->Block.TimeCode = (rtStart + 5000) / 10000;
b->Block.TimeCodeStop = (rtStop + 5000) / 10000;
- if(m_pTE->TrackType == TrackEntry::TypeSubtitle)
- {
+ if(m_pTE->TrackType == TrackEntry::TypeSubtitle) {
b->BlockDuration.Set((rtStop - rtStart + 5000) / 10000);
}
@@ -1329,8 +1302,9 @@ STDMETHODIMP CMatroskaMuxerInputPin::EndOfStream()
{
HRESULT hr;
- if(FAILED(hr = __super::EndOfStream()))
+ if(FAILED(hr = __super::EndOfStream())) {
return hr;
+ }
CAutoLock cAutoLock(&m_csQueue);
@@ -1371,9 +1345,13 @@ HRESULT CMatroskaMuxerOutputPin::DecideBufferSize(IMemAllocator* pAlloc, ALLOCAT
pProperties->cbBuffer = 1;
ALLOCATOR_PROPERTIES Actual;
- if(FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) return hr;
+ if(FAILED(hr = pAlloc->SetProperties(pProperties, &Actual))) {
+ return hr;
+ }
- if(Actual.cbBuffer < pProperties->cbBuffer) return E_FAIL;
+ if(Actual.cbBuffer < pProperties->cbBuffer) {
+ return E_FAIL;
+ }
ASSERT(Actual.cBuffers == pProperties->cBuffers);
return NOERROR;
@@ -1390,8 +1368,12 @@ 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;
+ if(iPosition < 0) {
+ return E_INVALIDARG;
+ }
+ if(iPosition > 0) {
+ return VFW_S_NO_MORE_ITEMS;
+ }
pmt->ResetFormatBuffer();
pmt->InitMediaType();
diff --git a/src/filters/muxer/MatroskaMuxer/MatroskaMuxer.h b/src/filters/muxer/MatroskaMuxer/MatroskaMuxer.h
index 4a29b8bb5..4c8eddbd4 100644
--- a/src/filters/muxer/MatroskaMuxer/MatroskaMuxer.h
+++ b/src/filters/muxer/MatroskaMuxer/MatroskaMuxer.h
@@ -87,8 +87,7 @@ public:
interface __declspec(uuid("38E2D43D-915D-493C-B373-888DB16EE3DC"))
IMatroskaMuxer :
-public IUnknown
-{
+public IUnknown {
STDMETHOD (CorrectTimeOffset) (bool fNegative, bool fPositive) = 0;
// TODO: chapters
};
diff --git a/src/filters/muxer/WavDest/WavDest.cpp b/src/filters/muxer/WavDest/WavDest.cpp
index 9cd6e2833..05d68a2a5 100644
--- a/src/filters/muxer/WavDest/WavDest.cpp
+++ b/src/filters/muxer/WavDest/WavDest.cpp
@@ -27,29 +27,24 @@
#ifdef REGISTER_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
{&MEDIATYPE_Audio, &MEDIASUBTYPE_WAVE},
};
-const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
{&MEDIATYPE_Stream, &MEDIASUBTYPE_WAVE},
};
-const AMOVIESETUP_PIN sudpPins[] =
-{
+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}
};
-const AMOVIESETUP_FILTER sudFilter[] =
-{
+const AMOVIESETUP_FILTER sudFilter[] = {
{&__uuidof(CWavDestFilter), L"MPC - WavDest", MERIT_DO_NOT_USE, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory}
};
-CFactoryTemplate g_Templates[] =
-{
+CFactoryTemplate g_Templates[] = {
{L"WavDest", &__uuidof(CWavDestFilter), CreateInstance<CWavDestFilter>, NULL, &sudFilter[0]}
};
@@ -78,26 +73,25 @@ CFilterApp theApp;
CWavDestFilter::CWavDestFilter(LPUNKNOWN pUnk, HRESULT* phr)
: 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
- {
+ 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
- {
+ 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;
}
@@ -119,8 +113,9 @@ HRESULT CWavDestFilter::Receive(IMediaSample* pSample)
HRESULT hr = CTransformFilter::Receive(pSample);
// don't update the count if Deliver() downstream fails.
- if(hr != S_OK)
+ if(hr != S_OK) {
m_cbWavData = cbOld;
+ }
return hr;
}
@@ -130,14 +125,16 @@ HRESULT CWavDestFilter::Transform(IMediaSample* pIn, IMediaSample* pOut)
REFERENCE_TIME rtStart, rtEnd;
HRESULT hr = Copy(pIn, pOut);
- if(FAILED(hr))
+ if(FAILED(hr)) {
return hr;
+ }
// Prepare it for writing
LONG lActual = pOut->GetActualDataLength();
- if(m_cbWavData + m_cbHeader + lActual < m_cbWavData + m_cbHeader ) // overflow
+ if(m_cbWavData + m_cbHeader + lActual < m_cbWavData + m_cbHeader ) { // overflow
return E_FAIL;
+ }
rtStart = m_cbWavData + m_cbHeader;
rtEnd = rtStart + lActual;
@@ -166,12 +163,14 @@ HRESULT CWavDestFilter::Copy(IMediaSample* pSource, IMediaSample* pDest) const
// Copy the sample times
REFERENCE_TIME TimeStart, TimeEnd;
- if(NOERROR == pSource->GetTime(&TimeStart, &TimeEnd))
+ if(NOERROR == pSource->GetTime(&TimeStart, &TimeEnd)) {
pDest->SetTime(&TimeStart, &TimeEnd);
+ }
LONGLONG MediaStart, MediaEnd;
- if(pSource->GetMediaTime(&MediaStart, &MediaEnd) == NOERROR)
+ if(pSource->GetMediaTime(&MediaStart, &MediaEnd) == NOERROR) {
pDest->SetMediaTime(&MediaStart, &MediaEnd);
+ }
// Copy the media type
AM_MEDIA_TYPE* pMediaType;
@@ -195,8 +194,7 @@ HRESULT CWavDestFilter::GetMediaType(int iPosition, CMediaType* pMediaType)
{
ASSERT(iPosition == 0 || iPosition == 1);
- if(iPosition == 0)
- {
+ if(iPosition == 0) {
pMediaType->SetType(&MEDIATYPE_Stream);
pMediaType->SetSubtype(&MEDIASUBTYPE_WAVE);
return S_OK;
@@ -207,8 +205,9 @@ HRESULT CWavDestFilter::GetMediaType(int iPosition, CMediaType* pMediaType)
HRESULT CWavDestFilter::DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIES* pProperties)
{
- if(m_pInput->IsConnected() == FALSE)
+ if(m_pInput->IsConnected() == FALSE) {
return E_UNEXPECTED;
+ }
ASSERT(pAlloc);
ASSERT(pProperties);
@@ -221,26 +220,23 @@ HRESULT CWavDestFilter::DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPER
CComPtr<IMemAllocator> pInAlloc;
ALLOCATOR_PROPERTIES InProps;
if(SUCCEEDED(hr = m_pInput->GetAllocator(&pInAlloc))
- && SUCCEEDED(hr = pInAlloc->GetProperties(&InProps)))
- {
+ && SUCCEEDED(hr = pInAlloc->GetProperties(&InProps))) {
pProperties->cbBuffer = InProps.cbBuffer;
- }
- else
- {
+ } else {
return hr;
}
ASSERT(pProperties->cbBuffer);
ALLOCATOR_PROPERTIES Actual;
- if(FAILED(hr = pAlloc->SetProperties(pProperties,&Actual)))
+ if(FAILED(hr = pAlloc->SetProperties(pProperties,&Actual))) {
return hr;
+ }
ASSERT(Actual.cBuffers == 1);
if(pProperties->cBuffers > Actual.cBuffers
- || pProperties->cbBuffer > Actual.cbBuffer)
- {
+ || pProperties->cbBuffer > Actual.cbBuffer) {
return E_FAIL;
}
@@ -271,17 +267,18 @@ HRESULT CWavDestFilter::StartStreaming()
HRESULT CWavDestFilter::StopStreaming()
{
IStream* pStream;
- if (m_pOutput->IsConnected() == FALSE)
+ if (m_pOutput->IsConnected() == FALSE) {
return E_FAIL;
+ }
IPin* pDwnstrmInputPin = m_pOutput->GetConnected();
- if (!pDwnstrmInputPin)
+ if (!pDwnstrmInputPin) {
return E_FAIL;
+ }
HRESULT hr = ((IMemInputPin *) pDwnstrmInputPin)->QueryInterface(IID_IStream, (void **)&pStream);
- if(SUCCEEDED(hr))
- {
+ if(SUCCEEDED(hr)) {
BYTE *pb = (BYTE *)_alloca(m_cbHeader);
RIFFLIST *pRiffWave = (RIFFLIST *)pb;
@@ -324,8 +321,9 @@ STDMETHODIMP CWavDestOutputPin::EnumMediaTypes(IEnumMediaTypes** ppEnum)
HRESULT CWavDestOutputPin::CheckMediaType(const CMediaType* pmt)
{
- if(pmt->majortype == MEDIATYPE_Stream && pmt->subtype == MEDIASUBTYPE_WAVE)
+ if(pmt->majortype == MEDIATYPE_Stream && pmt->subtype == MEDIASUBTYPE_WAVE) {
return S_OK;
- else
+ } else {
return S_FALSE;
+ }
}
diff --git a/src/filters/parser/AviSplitter/AviFile.cpp b/src/filters/parser/AviSplitter/AviFile.cpp
index 8e98d906b..96958a710 100644
--- a/src/filters/parser/AviSplitter/AviFile.cpp
+++ b/src/filters/parser/AviSplitter/AviFile.cpp
@@ -8,7 +8,9 @@
CAviFile::CAviFile(IAsyncReader* pAsyncReader, HRESULT& hr)
: CBaseSplitterFile(pAsyncReader, hr)
{
- if(FAILED(hr)) return;
+ if(FAILED(hr)) {
+ return;
+ }
m_isamv = false;
hr = Init();
}
@@ -17,38 +19,43 @@ 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 ')))
+ 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());
UNUSED_ALWAYS(hr);
- if(m_movis.GetCount() == 0) // FAILED(hr) is allowed as long as there was a movi chunk found
+ 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)
+ if(m_avih.dwStreams == 0 && m_strms.GetCount() > 0) {
m_avih.dwStreams = m_strms.GetCount();
+ }
- if(m_avih.dwStreams != m_strms.GetCount())
+ if(m_avih.dwStreams != m_strms.GetCount()) {
return E_FAIL;
+ }
- for(int i = 0; i < (int)m_avih.dwStreams; i++)
- {
+ for(int i = 0; i < (int)m_avih.dwStreams; i++) {
strm_t* s = m_strms[i];
- if(s->strh.fccType != FCC('auds')) continue;
+ 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)
- {
+ 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())))
+ if (!m_isamv && (FAILED(BuildIndex()))) {
EmptyIndex();
+ }
return S_OK;
}
@@ -60,26 +67,24 @@ HRESULT CAviFile::BuildAMVIndex()
ULONG 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;
+ 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);
+ Seek(GetPos() + ulSize);
}
TRACE ("Video packet : %d Audio packet :%d\n", m_strms[0]->cs.GetCount(), m_strms[1]->cs.GetCount());
@@ -93,177 +98,188 @@ HRESULT CAviFile::Parse(DWORD parentid, __int64 end)
CAutoPtr<strm_t> strm;
- while(S_OK == hr && GetPos() < end)
- {
+ while(S_OK == hr && GetPos() < end) {
UINT64 pos = GetPos();
DWORD id = 0, size;
- if(S_OK != Read(id) || id == 0)
+ 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))
+ if(id == FCC('RIFF') || id == FCC('LIST')) {
+ if(S_OK != Read(size) || S_OK != Read(id)) {
return E_FAIL;
+ }
- if (m_isamv) size = end - GetPos() - 8; // No size set in AVM : guess end of file...
+ if (m_isamv) {
+ size = end - 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));
+ 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'))
- {
+ if(id == FCC('movi')) {
m_movis.AddTail(pos);
- if (m_isamv) BuildAMVIndex();
- }
- else
- {
+ if (m_isamv) {
+ BuildAMVIndex();
+ }
+ } else {
hr = Parse(id, pos + size);
}
- }
- else
- {
- if(S_OK != Read(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.”
- {
+ 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;
+ 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);
+ 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);
}
- 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)];
+ 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);
+ }
}
- CATCH (CMemoryException, e)
- {
- pSuperIndex = NULL;
+ break;
+ case FCC('dmlh'):
+ if(S_OK != Read(m_dmlh)) {
+ return E_FAIL;
}
- 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('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;
- 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;
+ 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;
@@ -272,7 +288,9 @@ HRESULT CAviFile::Parse(DWORD parentid, __int64 end)
Seek(pos + size);
}
- if(strm) m_strms.Add(strm);
+ if(strm) {
+ m_strms.Add(strm);
+ }
return hr;
}
@@ -281,14 +299,15 @@ REFERENCE_TIME CAviFile::GetTotalTime()
{
REFERENCE_TIME t = 0/*10i64*m_avih.dwMicroSecPerFrame*m_avih.dwTotalFrames*/;
- for(int i = 0; i < (int)m_avih.dwStreams; i++)
- {
+ for(int i = 0; i < (int)m_avih.dwStreams; i++) {
strm_t* s = m_strms[i];
REFERENCE_TIME t2 = s->GetRefTime(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);
}
@@ -299,63 +318,56 @@ HRESULT CAviFile::BuildIndex()
DWORD nSuperIndexes = 0;
- for(int i = 0; i < (int)m_avih.dwStreams; i++)
- {
+ for(int i = 0; i < (int)m_avih.dwStreams; i++) {
strm_t* s = m_strms[i];
- if(s->indx && s->indx->nEntriesInUse > 0) nSuperIndexes++;
+ if(s->indx && s->indx->nEntriesInUse > 0) {
+ nSuperIndexes++;
+ }
}
- if(nSuperIndexes == m_avih.dwStreams)
- {
- for(int i = 0; i < (int)m_avih.dwStreams; i++)
- {
+ if(nSuperIndexes == m_avih.dwStreams) {
+ for(int i = 0; i < (int)m_avih.dwStreams; i++) {
strm_t* s = m_strms[i];
AVISUPERINDEX* idx = (AVISUPERINDEX*)s->indx;
DWORD nEntriesInUse = 0;
- for(int j = 0; j < (int)idx->nEntriesInUse; j++)
- {
+ for(int j = 0; j < (int)idx->nEntriesInUse; j++) {
Seek(idx->aIndex[j].qwOffset);
AVISTDINDEX stdidx;
- if(S_OK != ByteRead((BYTE*)&stdidx, FIELD_OFFSET(AVISTDINDEX, aIndex)))
- {
+ 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(int j = 0; j < (int)idx->nEntriesInUse; j++)
- {
+ for(int j = 0; j < (int)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))
- {
+ if(!p || S_OK != ByteRead((BYTE*)(AVISTDINDEX*)p, idx->aIndex[j].dwSize)) {
EmptyIndex();
return E_FAIL;
}
- for(int k = 0; k < (int)p->nEntriesInUse; k++)
- {
+ for(int k = 0; k < (int)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].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)
- {
+ if(m_idx1) {
s->cs[frame].filepos -= 8;
s->cs[frame].fChunkHdr = true;
}
@@ -367,23 +379,20 @@ HRESULT CAviFile::BuildIndex()
s->totalsize = size;
}
- }
- else if(AVIOLDINDEX* idx = m_idx1)
- {
+ } else if(AVIOLDINDEX* idx = m_idx1) {
int len = idx->cb/sizeof(idx->aIndex[0]);
UINT64 offset = m_movis.GetHead() + 8;
- for(int i = 0; i < (int)m_avih.dwStreams; i++)
- {
+ for(int i = 0; i < (int)m_avih.dwStreams; i++) {
strm_t* s = m_strms[i];
int nFrames = 0;
- for(int j = 0; j < len; j++)
- {
- if(TRACKNUM(idx->aIndex[j].dwChunkId) == i)
+ for(int j = 0; j < len; j++) {
+ if(TRACKNUM(idx->aIndex[j].dwChunkId) == i) {
nFrames++;
+ }
}
s->cs.SetCount(nFrames);
@@ -391,19 +400,15 @@ HRESULT CAviFile::BuildIndex()
DWORD frame = 0;
UINT64 size = 0;
- for(int j = 0; j < len; j++)
- {
+ for(int j = 0; j < len; j++) {
DWORD TrackNumber = TRACKNUM(idx->aIndex[j].dwChunkId);
- if(TrackNumber == i)
- {
- if(j == 0 && idx->aIndex[j].dwOffset > offset)
- {
+ if(TrackNumber == i) {
+ if(j == 0 && idx->aIndex[j].dwOffset > offset) {
DWORD id;
Seek(offset + idx->aIndex[j].dwOffset);
Read(id);
- if(id != idx->aIndex[j].dwChunkId)
- {
+ if(id != idx->aIndex[j].dwChunkId) {
TRACE(_T("WARNING: CAviFile::Init() detected absolute chunk addressing in \'idx1\'"));
offset = 0;
}
@@ -411,9 +416,9 @@ HRESULT CAviFile::BuildIndex()
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].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;
@@ -427,16 +432,16 @@ HRESULT CAviFile::BuildIndex()
}
m_idx1.Free();
- for(int i = 0; i < (int)m_avih.dwStreams; i++)
+ for(int i = 0; i < (int)m_avih.dwStreams; i++) {
m_strms[i]->indx.Free();
+ }
return S_OK;
}
void CAviFile::EmptyIndex()
{
- for(int i = 0; i < (int)m_avih.dwStreams; i++)
- {
+ for(int i = 0; i < (int)m_avih.dwStreams; i++) {
strm_t* s = m_strms[i];
s->cs.RemoveAll();
s->totalsize = 0;
@@ -445,14 +450,16 @@ void CAviFile::EmptyIndex()
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
+ if(m_strms.GetCount() < 2) {
return(true);
-*/
- for(int i = 0; i < (int)m_avih.dwStreams; i++)
+ }
+ /*
+ if(m_avih.dwFlags&AVIF_ISINTERLEAVED) // not reliable, nandub can write f*cked up files and still sets it
+ return(true);
+ */
+ for(int i = 0; i < (int)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];
@@ -462,30 +469,34 @@ bool CAviFile::IsInterleaved(bool fKeepInfo)
int end = 0;
- while(1)
- {
+ while(1) {
UINT64 fpmin = _I64_MAX;
DWORD n = (DWORD)-1;
- for(int i = 0; i < (int)m_avih.dwStreams; i++)
- {
+ for(int i = 0; i < (int)m_avih.dwStreams; i++) {
int 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(curchunk >= cs.GetCount()) {
+ continue;
+ }
+ UINT64 fp = cs[curchunk].filepos;
+ if(fp < fpmin) {
+ fpmin = fp;
+ n = i;
+ }
+ }
+ if(n == -1) {
+ break;
}
- if(n == -1) break;
strm_t* s = m_strms[n];
DWORD& curchunk = curchunks[n];
UINT64& cursize = cursizes[n];
- if(!s->IsRawSubtitleStream())
- {
+ 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.t = (DWORD)(s->GetRefTime(curchunk, cursize)/10000);
cs2.n = end++;
}
@@ -499,24 +510,30 @@ bool CAviFile::IsInterleaved(bool fKeepInfo)
bool fInterleaved = true;
- while(fInterleaved)
- {
+ while(fInterleaved) {
strm_t::chunk2 cs2min = {LONG_MAX, LONG_MAX};
int n = -1;
- for(int i = 0; i < (int)m_avih.dwStreams; i++)
- {
+ for(int i = 0; i < (int)m_avih.dwStreams; i++) {
int curchunk = curchunks[i];
- if(curchunk >= m_strms[i]->cs2.GetCount()) continue;
+ 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(cs2.t < cs2min.t) {
+ cs2min = cs2;
+ n = i;
+ }
+ }
+ if(n == -1) {
+ break;
}
- if(n == -1) break;
curchunks[n]++;
- if(cs2last.t >= 0 && abs((int)cs2min.n - (int)cs2last.n) >= 1000)
+ if(cs2last.t >= 0 && abs((int)cs2min.n - (int)cs2last.n) >= 1000) {
fInterleaved = false;
+ }
cs2last = cs2min;
}
@@ -524,11 +541,11 @@ bool CAviFile::IsInterleaved(bool fKeepInfo)
delete [] curchunks;
delete [] cursizes;
- if(fInterleaved && !fKeepInfo)
- {
+ if(fInterleaved && !fKeepInfo) {
// this is not needed anymore, let's save a little memory then
- for(int i = 0; i < (int)m_avih.dwStreams; i++)
+ for(int i = 0; i < (int)m_avih.dwStreams; i++) {
m_strms[i]->cs2.RemoveAll();
+ }
}
return(fInterleaved);
@@ -538,8 +555,7 @@ REFERENCE_TIME CAviFile::strm_t::GetRefTime(DWORD frame, UINT64 size)
{
float dframe = frame;
- if(strh.fccType == FCC('auds'))
- {
+ if(strh.fccType == FCC('auds')) {
WAVEFORMATEX* wfe = (WAVEFORMATEX*)strf.GetData();
dframe = wfe->nBlockAlign ? 1.0f * size / wfe->nBlockAlign : 0;
@@ -556,27 +572,24 @@ int CAviFile::strm_t::GetFrame(REFERENCE_TIME rt)
float rate_per_scale = strh.dwScale ? 1.0f * strh.dwRate / strh.dwScale : 0;
- if(strh.fccType == FCC('auds'))
- {
+ if(strh.fccType == FCC('auds')) {
WAVEFORMATEX* wfe = (WAVEFORMATEX*)strf.GetData();
__int64 size = (__int64)(rate_per_scale * wfe->nBlockAlign * rt / 10000000 + 0.5f);
- for(frame = 0; frame < cs.GetCount(); frame++)
- {
- if(cs[frame].size > size)
- {
+ for(frame = 0; frame < cs.GetCount(); frame++) {
+ if(cs[frame].size > size) {
frame--;
break;
}
}
- }
- else
- {
+ } else {
frame = (int)(rate_per_scale * rt / 10000000 + 0.5f);
}
- if(frame >= cs.GetCount()) frame = cs.GetCount()-1;
+ if(frame >= cs.GetCount()) {
+ frame = cs.GetCount()-1;
+ }
return frame;
}
@@ -584,14 +597,17 @@ int CAviFile::strm_t::GetFrame(REFERENCE_TIME rt)
int CAviFile::strm_t::GetKeyFrame(REFERENCE_TIME rt)
{
int i = GetFrame(rt);
- for(; i > 0; i--) {if(cs[i].fKeyFrame) break;}
+ for(; i > 0; i--) {
+ if(cs[i].fKeyFrame) {
+ break;
+ }
+ }
return(i);
}
DWORD CAviFile::strm_t::GetChunkSize(DWORD size)
{
- if(strh.fccType == FCC('auds'))
- {
+ 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
}
diff --git a/src/filters/parser/AviSplitter/AviFile.h b/src/filters/parser/AviSplitter/AviFile.h
index dfc851426..ed35fd958 100644
--- a/src/filters/parser/AviSplitter/AviFile.h
+++ b/src/filters/parser/AviSplitter/AviFile.h
@@ -14,23 +14,27 @@ public:
//using CBaseSplitterFile::Read;
template<typename T>
- HRESULT Read(T& var, int offset = 0)
- {
+ 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
- {
+ 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;};
+ 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);
@@ -41,7 +45,10 @@ public:
bool IsRawSubtitleStream();
// tmp
- struct chunk2 {DWORD t; DWORD n;};
+ struct chunk2 {
+ DWORD t;
+ DWORD n;
+ };
CAtlArray<chunk2> cs2;
};
CAutoPtrArray<strm_t> m_strms;
@@ -50,7 +57,7 @@ public:
CAtlList<UINT64> m_movis;
bool m_isamv;
-
+
REFERENCE_TIME GetTotalTime();
HRESULT BuildIndex();
void EmptyIndex();
diff --git a/src/filters/parser/AviSplitter/AviReportWnd.cpp b/src/filters/parser/AviSplitter/AviReportWnd.cpp
index f9489f566..18b2dc44f 100644
--- a/src/filters/parser/AviSplitter/AviReportWnd.cpp
+++ b/src/filters/parser/AviSplitter/AviReportWnd.cpp
@@ -15,10 +15,11 @@ bool CAviReportWnd::DoModal(CAviFile* pAF, bool fHideChecked, bool fShowWarningT
m_nChunks = 0;
m_rtDur = 0;
- for(int i = 0; i < (int)pAF->m_avih.dwStreams; i++)
- {
+ for(int i = 0; i < (int)pAF->m_avih.dwStreams; i++) {
int cnt = pAF->m_strms[i]->cs2.GetCount();
- if(cnt <= 0) continue;
+ 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);
@@ -29,9 +30,9 @@ bool CAviReportWnd::DoModal(CAviFile* pAF, bool fHideChecked, bool fShowWarningT
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);
+ 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);
@@ -76,14 +77,11 @@ bool CAviReportWnd::DoModal(CAviFile* pAF, bool fHideChecked, bool fShowWarningT
//
- if(!fShowWarningText)
- {
+ if(!fShowWarningText) {
m_message.ShowWindow(SW_HIDE);
m_checkbox.ShowWindow(SW_HIDE);
r = cr;
- }
- else
- {
+ } else {
r.SetRect(cr.left, r.bottom + 10, cr.right, cr.bottom);
}
@@ -124,8 +122,7 @@ void CAviReportWnd::OnMouseMove(UINT nFlags, CPoint p)
r.bottom -= GRAPHFOOTER;
r2.top = r.bottom;
- if(r.PtInRect(p))
- {
+ if(r.PtInRect(p)) {
SetCapture();
int x = p.x - r.left;
@@ -146,20 +143,18 @@ void CAviReportWnd::OnMouseMove(UINT nFlags, CPoint p)
CString str;
str.Format(_T("%s (%d - %d:%02d:%02d.%03d)"), TITLE, chunk, h, m, s, ms);
SetWindowText(str);
- }
- else if(r2.PtInRect(p))
- {
+ } 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!");
+ if(dist >= 1000) {
+ str += _T(" - over the limit!");
+ }
str += ")";
SetWindowText(str);
- }
- else if(GetCapture() == this)
- {
+ } else if(GetCapture() == this) {
SetWindowText(TITLE);
ReleaseCapture();
@@ -176,8 +171,9 @@ 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))
+ if(!CreateEx(WS_EX_CLIENTEDGE, _T("STATIC"), _T(""), WS_CHILD|WS_VISIBLE, r, pParentWnd, 0)) {
return(false);
+ }
GetClientRect(r);
int w = r.Width();
@@ -189,14 +185,26 @@ bool CAviPlotterWnd::Create(CAviFile* pAF, CRect r, CWnd* pParentWnd)
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);}
+ 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);
}
@@ -208,7 +216,7 @@ bool CAviPlotterWnd::Create(CAviFile* pAF, CRect r, CWnd* pParentWnd)
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.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);
@@ -224,8 +232,7 @@ bool CAviPlotterWnd::Create(CAviFile* pAF, CRect r, CWnd* pParentWnd)
COLORREF clr[] = {0x0000ff,0xff0000,0x40ffff,0xff40ff,0xffff40,0xffffff};
- for(int i = 0, y = 40, dy = m_dc.GetTextExtent(_T("Stream N")).cy + 1; i < (int)pAF->m_avih.dwStreams; i++, y += dy)
- {
+ for(int i = 0, y = 40, dy = m_dc.GetTextExtent(_T("Stream N")).cy + 1; i < (int)pAF->m_avih.dwStreams; i++, y += dy) {
m_dc.SetTextColor(clr[i%pAF->m_avih.dwStreams]);
m_dc.SetBkMode(TRANSPARENT);
CString str;
@@ -235,26 +242,28 @@ bool CAviPlotterWnd::Create(CAviFile* pAF, CRect r, CWnd* pParentWnd)
DWORD nmax = 0, tmax = 0;
- for(int i = 0; i < (int)pAF->m_avih.dwStreams; i++)
- {
+ for(int i = 0; i < (int)pAF->m_avih.dwStreams; i++) {
int cnt = pAF->m_strms[i]->cs2.GetCount();
- if(cnt <= 0) continue;
+ 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)
- {
+ if(nmax > 0 && tmax > 0) {
CAtlArray<CPen> pen;
pen.SetCount(pAF->m_avih.dwStreams);
- for(int i = 0; i < pen.GetCount(); i++)
+ for(int i = 0; i < pen.GetCount(); i++) {
pen[i].CreatePen(PS_SOLID, 2, clr[i]);
+ }
CAtlArray<CPoint> pp;
pp.SetCount(pAF->m_avih.dwStreams);
- for(int i = 0; i < pen.GetCount(); i++)
+ for(int i = 0; i < pen.GetCount(); i++) {
pp[i].SetPoint(-1, -1);
+ }
m_chunkdist.SetCount(w);
memset(m_chunkdist.GetData(), 0, sizeof(int)*w);
@@ -264,39 +273,45 @@ bool CAviPlotterWnd::Create(CAviFile* pAF, CRect r, CWnd* pParentWnd)
CAviFile::strm_t::chunk2 cs2last = {(DWORD)-1, 0};
- while(1)
- {
+ while(1) {
CAviFile::strm_t::chunk2 cs2min = {LONG_MAX, LONG_MAX};
int n = -1;
- for(int i = 0; i < (int)pAF->m_avih.dwStreams; i++)
- {
+ for(int i = 0; i < (int)pAF->m_avih.dwStreams; i++) {
int curchunk = curchunks[i];
- if(curchunk >= pAF->m_strms[i]->cs2.GetCount()) continue;
+ 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(cs2.t < cs2min.t) {
+ cs2min = cs2;
+ n = i;
+ }
+ }
+ if(n == -1) {
+ break;
}
- 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)
- {
+ 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);}
+ 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 >= 0 /*&& dist >= 1000*/)
- {
- if(p.x >= 0 && p.x < w)
- {
+ if(cs2last.t >= 0 /*&& dist >= 1000*/) {
+ if(p.x >= 0 && p.x < w) {
m_chunkdist[p.x] = max(m_chunkdist[p.x], dist);
}
}
@@ -308,8 +323,7 @@ bool CAviPlotterWnd::Create(CAviFile* pAF, CRect r, CWnd* pParentWnd)
CPen red(PS_SOLID, 1, 0x0000ff);
CPen green(PS_SOLID, 1, 0x00ff00);
- for(int x = 0; x < w; x++)
- {
+ 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);
diff --git a/src/filters/parser/AviSplitter/AviReportWnd.h b/src/filters/parser/AviSplitter/AviReportWnd.h
index cd5c3b331..c68e6f618 100644
--- a/src/filters/parser/AviSplitter/AviReportWnd.h
+++ b/src/filters/parser/AviSplitter/AviReportWnd.h
@@ -16,7 +16,9 @@ public:
CAviPlotterWnd();
bool Create(CAviFile* pAF, CRect r, CWnd* pParentWnd);
- int GetChunkDist(int x) {return x >= 0 && x < m_chunkdist.GetCount() ? m_chunkdist[x] : 0;}
+ int GetChunkDist(int x) {
+ return x >= 0 && x < m_chunkdist.GetCount() ? m_chunkdist[x] : 0;
+ }
DECLARE_MESSAGE_MAP()
afx_msg void OnPaint();
diff --git a/src/filters/parser/AviSplitter/AviSplitter.cpp b/src/filters/parser/AviSplitter/AviSplitter.cpp
index 3f1e5a0c7..da1093520 100644
--- a/src/filters/parser/AviSplitter/AviSplitter.cpp
+++ b/src/filters/parser/AviSplitter/AviSplitter.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -27,26 +27,22 @@
#ifdef REGISTER_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
{&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}
+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}
};
-const AMOVIESETUP_FILTER sudFilter[] =
-{
+const AMOVIESETUP_FILTER sudFilter[] = {
{&__uuidof(CAviSplitterFilter), L"MPC - Avi Splitter", MERIT_NORMAL+1, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
{&__uuidof(CAviSourceFilter), L"MPC - Avi Source", MERIT_NORMAL+1, 0, NULL, CLSID_LegacyAmFilterCategory},
};
-CFactoryTemplate g_Templates[] =
-{
+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]},
};
@@ -61,9 +57,9 @@ STDAPI DllRegisterServer()
chkbytes.AddTail(_T("0,4,,52494646,8,4,,414D5620")); // 'RIFF' ... 'AMV '
RegisterSourceFilter(
- CLSID_AsyncReader,
- MEDIASUBTYPE_Avi,
- chkbytes,
+ CLSID_AsyncReader,
+ MEDIASUBTYPE_Avi,
+ chkbytes,
_T(".avi"), _T(".divx"), _T(".vp6"), _T(".amv"), NULL);
return AMovieDllRegisterServer2(TRUE);
@@ -71,7 +67,7 @@ STDAPI DllRegisterServer()
STDAPI DllUnregisterServer()
{
-// UnRegisterSourceFilter(MEDIASUBTYPE_Avi);
+ // UnRegisterSourceFilter(MEDIASUBTYPE_Avi);
return AMovieDllRegisterServer2(FALSE);
}
@@ -83,21 +79,20 @@ class CAviSplitterApp : public CWinApp
public:
CAviSplitterApp() {}
- BOOL InitInstance()
- {
- if(!__super::InitInstance()) return FALSE;
+ BOOL InitInstance() {
+ if(!__super::InitInstance()) {
+ return FALSE;
+ }
DllEntryPoint(m_hInstance, DLL_PROCESS_ATTACH, 0);
return TRUE;
}
- BOOL ExitInstance()
- {
+ BOOL ExitInstance() {
DllEntryPoint(m_hInstance, DLL_PROCESS_DETACH, 0);
return __super::ExitInstance();
}
- void SetDefaultRegistryKey()
- {
+ void SetDefaultRegistryKey() {
SetRegistryKey(_T("Gabest"));
}
@@ -127,7 +122,7 @@ STDMETHODIMP CAviSplitterFilter::NonDelegatingQueryInterface(REFIID riid, void**
*ppv = NULL;
- return
+ return
__super::NonDelegatingQueryInterface(riid, ppv);
}
@@ -141,29 +136,34 @@ HRESULT CAviSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
m_tFrame.Free();
m_pFile.Attach(DNew CAviFile(pAsyncReader, hr));
- if(!m_pFile) return E_OUTOFMEMORY;
+ if(!m_pFile) {
+ return E_OUTOFMEMORY;
+ }
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());
#endif
bool fHideWarning = !!AfxGetApp()->GetProfileInt(_T("Settings"), _T("HideAviSplitterWarning"), 0);
- if(!fHideWarning && !dynamic_cast<CAviSourceFilter*>(this) || fShiftDown)
- {
+ 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(fShowWarningText) {
+ hr = E_FAIL;
+ }
}
- if(FAILED(hr)) {m_pFile.Free(); return hr;}
+ if(FAILED(hr)) {
+ m_pFile.Free();
+ return hr;
+ }
m_rtNewStart = m_rtCurrent = 0;
m_rtNewStop = m_rtStop = m_rtDuration = m_pFile->GetTotalTime();
@@ -171,22 +171,23 @@ HRESULT CAviSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
bool fHasIndex = false;
for(DWORD i = 0; !fHasIndex && i < m_pFile->m_strms.GetCount(); i++)
- if(m_pFile->m_strms[i]->cs.GetCount() > 0)
+ if(m_pFile->m_strms[i]->cs.GetCount() > 0) {
fHasIndex = true;
+ }
- for(DWORD i = 0; i < m_pFile->m_strms.GetCount(); i++)
- {
+ for(DWORD 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;
+ if(fHasIndex && s->cs.GetCount() == 0) {
+ continue;
+ }
CMediaType mt;
CAtlArray<CMediaType> mts;
-
+
CStringW name, label;
- if(s->strh.fccType == FCC('vids'))
- {
+ if(s->strh.fccType == FCC('vids')) {
label = L"Video";
ASSERT(s->strf.GetCount() >= sizeof(BITMAPINFOHEADER));
@@ -199,10 +200,13 @@ HRESULT CAviSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
VIDEOINFOHEADER* pvih = (VIDEOINFOHEADER*)mt.AllocFormatBuffer(sizeof(VIDEOINFOHEADER) + 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 = 10000000i64 * s->strh.dwScale / s->strh.dwRate;
- switch(pbmi->biCompression)
- {
- case BI_RGB: case BI_BITFIELDS: mt.subtype =
+ if(s->strh.dwRate > 0) {
+ pvih->AvgTimePerFrame = 10000000i64 * s->strh.dwScale / s->strh.dwRate;
+ }
+ 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 :
@@ -210,77 +214,78 @@ HRESULT CAviSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
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;
+ break;
+ // case BI_RLE8: mt.subtype = MEDIASUBTYPE_RGB8; break;
+ // case BI_RLE4: mt.subtype = MEDIASUBTYPE_RGB4; break;
}
- if(s->cs.GetCount() && pvih->AvgTimePerFrame > 0)
- {
+ if(s->cs.GetCount() && pvih->AvgTimePerFrame > 0) {
__int64 size = 0;
- for(int i = 0; i < s->cs.GetCount(); i++)
+ for(int i = 0; i < s->cs.GetCount(); i++) {
size += s->cs[i].orgsize;
+ }
pvih->dwBitRate = size*8 / s->cs.GetCount() * 10000000i64 / pvih->AvgTimePerFrame;
}
- mt.SetSampleSize(s->strh.dwSuggestedBufferSize > 0
- ? s->strh.dwSuggestedBufferSize*3/2
- : (pvih->bmiHeader.biWidth*pvih->bmiHeader.biHeight*4));
+ 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'))
- {
+ } 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));
+ || s->strf.GetCount() == sizeof(PCMWAVEFORMAT));
- WAVEFORMATEX* pwfe = (WAVEFORMATEX*)s->strf.GetData();
+ WAVEFORMATEX* pwfe = (WAVEFORMATEX*)s->strf.GetData();
- if(pwfe->nBlockAlign == 0) continue;
+ if(pwfe->nBlockAlign == 0) {
+ continue;
+ }
mt.majortype = MEDIATYPE_Audio;
- if (m_pFile->m_isamv)
+ if (m_pFile->m_isamv) {
mt.subtype = FOURCCMap(MAKEFOURCC('A','M','V','A'));
- else
+ } else {
mt.subtype = FOURCCMap(pwfe->wFormatTag);
+ }
mt.formattype = FORMAT_WaveFormatEx;
mt.SetFormat(s->strf.GetData(), max(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));
+ 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'))
- {
+ } 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));
+ mt.SetSampleSize(s->strh.dwSuggestedBufferSize > 0
+ ? s->strh.dwSuggestedBufferSize*3/2
+ : (1024*1024));
mts.Add(mt);
- }
- else if(s->strh.fccType == FCC('txts'))
- {
+ } 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));
+ mt.SetSampleSize(s->strh.dwSuggestedBufferSize > 0
+ ? s->strh.dwSuggestedBufferSize*3/2
+ : (1024*1024));
mts.Add(mt);
- }
- else if(s->strh.fccType == FCC('iavs'))
- {
+ } else if(s->strh.fccType == FCC('iavs')) {
label = L"Interleaved";
ASSERT(s->strh.fccHandler == FCC('dvsd'));
@@ -289,25 +294,25 @@ HRESULT CAviSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
mt.subtype = FOURCCMap(s->strh.fccHandler);
mt.formattype = FORMAT_DvInfo;
mt.SetFormat(s->strf.GetData(), max(s->strf.GetCount(), sizeof(DVINFO)));
- mt.SetSampleSize(s->strh.dwSuggestedBufferSize > 0
- ? s->strh.dwSuggestedBufferSize*3/2
- : (1024*1024));
+ mt.SetSampleSize(s->strh.dwSuggestedBufferSize > 0
+ ? s->strh.dwSuggestedBufferSize*3/2
+ : (1024*1024));
mts.Add(mt);
}
- if(mts.IsEmpty())
- {
+ 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 %d", label , i);
- else
- name.Format(L"%s %d %s", label , i , CStringW(s->strn) );
+ //If you know why, please emailto: tomasen@gmail.com
+ if(s->strn.IsEmpty()) {
+ name.Format(L"%s %d", label, i);
+ } else {
+ name.Format(L"%s (%s %d)", CStringW(s->strn), label, i);
+ }
HRESULT hr;
@@ -316,18 +321,24 @@ HRESULT CAviSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
}
POSITION pos = m_pFile->m_info.GetStartPosition();
- while(pos)
- {
+ 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;
+ 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;
}
}
@@ -340,20 +351,21 @@ bool CAviSplitterFilter::DemuxInit()
{
SetThreadName((DWORD)-1, "CAviSplitterFilter");
- if(!m_pFile) return(false);
+ if(!m_pFile) {
+ return(false);
+ }
// reindex if needed
bool fReIndex = false;
- for(int i = 0; i < (int)m_pFile->m_avih.dwStreams && !fReIndex; i++)
- {
- if(m_pFile->m_strms[i]->cs.GetCount() == 0 && GetOutputPin(i))
+ for(int i = 0; i < (int)m_pFile->m_avih.dwStreams && !fReIndex; i++) {
+ if(m_pFile->m_strms[i]->cs.GetCount() == 0 && GetOutputPin(i)) {
fReIndex = true;
+ }
}
- if(fReIndex)
- {
+ if(fReIndex) {
m_pFile->EmptyIndex();
m_fAbort = false;
@@ -365,9 +377,11 @@ bool CAviSplitterFilter::DemuxInit()
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);
+ ReIndex(m_pFile->GetLength(), pSize);
- if(m_fAbort) m_pFile->EmptyIndex();
+ if(m_fAbort) {
+ m_pFile->EmptyIndex();
+ }
m_fAbort = false;
m_nOpenProgress = 100;
@@ -380,40 +394,38 @@ HRESULT CAviSplitterFilter::ReIndex(__int64 end, UINT64* pSize)
{
HRESULT hr = S_OK;
- while(S_OK == hr && m_pFile->GetPos() < end && SUCCEEDED(hr) && !m_fAbort)
- {
+ 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)
+ 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))
+ 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;
- if(id == FCC('AVI ') || id == FCC('AVIX') || id == FCC('movi') || id == FCC('rec '))
+ 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))
+ }
+ } else {
+ if(S_OK != m_pFile->Read(size)) {
return E_FAIL;
+ }
DWORD TrackNumber = TRACKNUM(id);
- if(TrackNumber < m_pFile->m_strms.GetCount())
- {
+ if(TrackNumber < m_pFile->m_strms.GetCount()) {
CAviFile::strm_t* s = m_pFile->m_strms[TrackNumber];
WORD type = TRACKTYPE(id);
if(type == 'db' || type == 'dc' || /*type == 'pc' ||*/ type == 'wb'
- || type == 'iv' || type == '__' || type == 'xx')
- {
+ || type == 'iv' || type == '__' || type == 'xx') {
CAviFile::strm_t::chunk c;
c.filepos = pos;
c.size = pSize[TrackNumber];
@@ -437,10 +449,12 @@ HRESULT CAviSplitterFilter::ReIndex(__int64 end, UINT64* pSize)
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);
+ if(CheckRequest(&cmd)) {
+ if(cmd == CMD_EXIT) {
+ m_fAbort = true;
+ } else {
+ Reply(S_OK);
+ }
}
}
@@ -454,30 +468,26 @@ void CAviSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
DbgLog((LOG_TRACE, 0, _T("Seek: %I64d"), rt/10000));
- if(rt > 0)
- {
+ if(rt > 0) {
UINT64 minfp = _I64_MAX;
- for(int j = 0; j < (int)m_pFile->m_strms.GetCount(); j++)
- {
+ for(int j = 0; j < (int)m_pFile->m_strms.GetCount(); j++) {
CAviFile::strm_t* s = m_pFile->m_strms[j];
int f = s->GetKeyFrame(rt);
UINT64 fp = f >= 0 ? s->cs[f].filepos : m_pFile->GetLength();
- if(!s->IsRawSubtitleStream())
+ if(!s->IsRawSubtitleStream()) {
minfp = min(minfp, fp);
+ }
}
- for(int j = 0; j < (int)m_pFile->m_strms.GetCount(); j++)
- {
+ for(int j = 0; j < (int)m_pFile->m_strms.GetCount(); j++) {
CAviFile::strm_t* s = m_pFile->m_strms[j];
- for(int i = 0; i < s->cs.GetCount(); i++)
- {
+ for(int i = 0; i < s->cs.GetCount(); i++) {
CAviFile::strm_t::chunk& c = s->cs[i];
- if(c.filepos >= minfp)
- {
+ if(c.filepos >= minfp) {
m_tFrame[j] = i;
break;
}
@@ -498,66 +508,62 @@ bool CAviSplitterFilter::DemuxLoop()
fDiscontinuity.SetCount(nTracks);
memset(fDiscontinuity.GetData(), 0, nTracks*sizeof(bool));
- while(SUCCEEDED(hr) && !CheckRequest(NULL))
- {
+ while(SUCCEEDED(hr) && !CheckRequest(NULL)) {
int minTrack = nTracks;
UINT64 minFilePos = _I64_MAX;
- for(int i = 0; i < nTracks; i++)
- {
+ for(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;
+ if(f >= (DWORD)s->cs.GetCount()) {
+ continue;
+ }
bool fUrgent = s->IsRawSubtitleStream();
- if(fUrgent || s->cs[f].filepos < minFilePos)
- {
+ if(fUrgent || s->cs[f].filepos < minFilePos) {
minTrack = i;
minFilePos = s->cs[f].filepos;
}
- if(fUrgent) break;
+ if(fUrgent) {
+ break;
+ }
}
- if(minTrack == nTracks)
+ if(minTrack == nTracks) {
break;
+ }
DWORD& f = m_tFrame[minTrack];
- do
- {
+ 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)
- {
+ 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))
- {
+ || 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;
+ ? s->cs[f+1].size - s->cs[f].size
+ : s->totalsize - s->cs[f].size;
- if(expectedsize != s->GetChunkSize(size))
- {
+ if(expectedsize != s->GetChunkSize(size)) {
fDiscontinuity[minTrack] = true;
// ASSERT(0);
break;
}
- }
- else
- {
+ } else {
size = s->cs[f].orgsize;
}
@@ -568,22 +574,22 @@ bool CAviSplitterFilter::DemuxLoop()
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;
-/*
- 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));
-*/
+ if(S_OK != (hr = m_pFile->ByteRead(p->GetData(), p->GetCount()))) {
+ return(true); // break;
+ }
+ /*
+ 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));
+ */
hr = DeliverPacket(p);
fDiscontinuity[minTrack] = false;
- }
- while(0);
+ } while(0);
f++;
}
@@ -598,13 +604,10 @@ STDMETHODIMP CAviSplitterFilter::GetDuration(LONGLONG* pDuration)
CheckPointer(pDuration, E_POINTER);
CheckPointer(m_pFile, VFW_E_NOT_CONNECTED);
- if(m_timeformat == TIME_FORMAT_FRAME)
- {
- for(int i = 0; i < (int)m_pFile->m_strms.GetCount(); i++)
- {
+ if(m_timeformat == TIME_FORMAT_FRAME) {
+ for(int i = 0; i < (int)m_pFile->m_strms.GetCount(); i++) {
CAviFile::strm_t* s = m_pFile->m_strms[i];
- if(s->strh.fccType == FCC('vids'))
- {
+ if(s->strh.fccType == FCC('vids')) {
*pDuration = s->cs.GetCount();
return S_OK;
}
@@ -622,7 +625,9 @@ STDMETHODIMP CAviSplitterFilter::IsFormatSupported(const GUID* pFormat)
{
CheckPointer(pFormat, E_POINTER);
HRESULT hr = __super::IsFormatSupported(pFormat);
- if(S_OK == hr) return hr;
+ if(S_OK == hr) {
+ return hr;
+ }
return *pFormat == TIME_FORMAT_FRAME ? S_OK : S_FALSE;
}
@@ -642,7 +647,9 @@ STDMETHODIMP CAviSplitterFilter::IsUsingTimeFormat(const GUID* pFormat)
STDMETHODIMP CAviSplitterFilter::SetTimeFormat(const GUID* pFormat)
{
CheckPointer(pFormat, E_POINTER);
- if(S_OK != IsFormatSupported(pFormat)) return E_FAIL;
+ if(S_OK != IsFormatSupported(pFormat)) {
+ return E_FAIL;
+ }
m_timeformat = *pFormat;
return S_OK;
}
@@ -650,10 +657,16 @@ STDMETHODIMP CAviSplitterFilter::SetTimeFormat(const GUID* pFormat)
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;
+ 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;
+ if(FAILED(ConvertTimeFormat(pStop, &TIME_FORMAT_FRAME, rt, &TIME_FORMAT_MEDIA_TIME))) {
+ return E_FAIL;
+ }
return S_OK;
}
@@ -663,101 +676,119 @@ STDMETHODIMP CAviSplitterFilter::ConvertTimeFormat(LONGLONG* pTarget, const GUID
const GUID& SourceFormat = pSourceFormat ? *pSourceFormat : m_timeformat;
const GUID& TargetFormat = pTargetFormat ? *pTargetFormat : m_timeformat;
-
- if(TargetFormat == SourceFormat)
- {
- *pTarget = Source;
+
+ if(TargetFormat == SourceFormat) {
+ *pTarget = Source;
return S_OK;
- }
- else if(TargetFormat == TIME_FORMAT_FRAME && SourceFormat == TIME_FORMAT_MEDIA_TIME)
- {
- for(int i = 0; i < (int)m_pFile->m_strms.GetCount(); i++)
- {
+ } else if(TargetFormat == TIME_FORMAT_FRAME && SourceFormat == TIME_FORMAT_MEDIA_TIME) {
+ for(int i = 0; i < (int)m_pFile->m_strms.GetCount(); i++) {
CAviFile::strm_t* s = m_pFile->m_strms[i];
- if(s->strh.fccType == FCC('vids'))
- {
+ 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(int i = 0; i < (int)m_pFile->m_strms.GetCount(); i++)
- {
+ } else if(TargetFormat == TIME_FORMAT_MEDIA_TIME && SourceFormat == TIME_FORMAT_FRAME) {
+ for(int i = 0; i < (int)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 >= s->cs.GetCount()) return E_FAIL;
+ if(s->strh.fccType == FCC('vids')) {
+ if(Source < 0 || Source >= s->cs.GetCount()) {
+ return E_FAIL;
+ }
CAviFile::strm_t::chunk& c = s->cs[(int)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)
+ 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(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;
+ 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)
+ 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)
+ || (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;
+ REFERENCE_TIME
+ rtCurrent = m_rtCurrent,
+ rtStop = m_rtStop;
if((dwCurrentFlags&AM_SEEKING_PositioningBitsMask)
- && FAILED(ConvertTimeFormat(&rtCurrent, &TIME_FORMAT_FRAME, rtCurrent, &TIME_FORMAT_MEDIA_TIME)))
+ && 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)))
+ && 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;
- }
+ 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;
- }
+ 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;
+ && 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;
+ && pStop)
+ if(FAILED(ConvertTimeFormat(pStop, &TIME_FORMAT_MEDIA_TIME, rtStop, &TIME_FORMAT_FRAME))) {
+ return E_FAIL;
+ }
return __super::SetPositionsInternal(id, pCurrent, dwCurrentFlags, pStop, dwStopFlags);
}
@@ -766,25 +797,30 @@ HRESULT CAviSplitterFilter::SetPositionsInternal(void* id, LONGLONG* pCurrent, D
STDMETHODIMP CAviSplitterFilter::GetKeyFrameCount(UINT& nKFs)
{
- if(!m_pFile) return E_UNEXPECTED;
+ if(!m_pFile) {
+ return E_UNEXPECTED;
+ }
HRESULT hr = S_OK;
nKFs = 0;
- for(int i = 0; i < (int)m_pFile->m_strms.GetCount(); i++)
- {
+ for(int i = 0; i < (int)m_pFile->m_strms.GetCount(); i++) {
CAviFile::strm_t* s = m_pFile->m_strms[i];
- if(s->strh.fccType != FCC('vids')) continue;
+ if(s->strh.fccType != FCC('vids')) {
+ continue;
+ }
- for(int j = 0; j < s->cs.GetCount(); j++)
- {
+ for(int j = 0; j < s->cs.GetCount(); j++) {
CAviFile::strm_t::chunk& c = s->cs[j];
- if(c.fKeyFrame) nKFs++;
+ if(c.fKeyFrame) {
+ nKFs++;
+ }
}
- if(nKFs == s->cs.GetCount())
+ if(nKFs == s->cs.GetCount()) {
hr = S_FALSE;
+ }
break;
}
@@ -797,22 +833,27 @@ STDMETHODIMP CAviSplitterFilter::GetKeyFrames(const GUID* pFormat, REFERENCE_TIM
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;
+ if(!m_pFile) {
+ return E_UNEXPECTED;
+ }
+ if(*pFormat != TIME_FORMAT_MEDIA_TIME && *pFormat != TIME_FORMAT_FRAME) {
+ return E_INVALIDARG;
+ }
UINT nKFsTmp = 0;
- for(int i = 0; i < (int)m_pFile->m_strms.GetCount(); i++)
- {
+ for(int i = 0; i < (int)m_pFile->m_strms.GetCount(); i++) {
CAviFile::strm_t* s = m_pFile->m_strms[i];
- if(s->strh.fccType != FCC('vids')) continue;
+ if(s->strh.fccType != FCC('vids')) {
+ continue;
+ }
bool fConvertToRefTime = !!(*pFormat == TIME_FORMAT_MEDIA_TIME);
- for(int j = 0; j < s->cs.GetCount() && nKFsTmp < nKFs; j++)
- {
- if(s->cs[j].fKeyFrame)
+ for(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;
+ }
}
break;
@@ -847,16 +888,15 @@ 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'))))
- {
+ 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)
+ if(clsid == CLSID_VideoMixingRenderer || clsid == CLSID_OverlayMixer) {
return E_FAIL;
+ }
}
mt.InitMediaType();
diff --git a/src/filters/parser/AviSplitter/AviSplitter.h b/src/filters/parser/AviSplitter/AviSplitter.h
index e022cc0c9..c414c5175 100644
--- a/src/filters/parser/AviSplitter/AviSplitter.h
+++ b/src/filters/parser/AviSplitter/AviSplitter.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -36,7 +36,7 @@ public:
};
class __declspec(uuid("9736D831-9D6C-4E72-B6E7-560EF9181001"))
-CAviSplitterFilter : public CBaseSplitterFilter
+ CAviSplitterFilter : public CBaseSplitterFilter
{
CAutoVectorPtr<DWORD> m_tFrame;
@@ -54,7 +54,7 @@ public:
CAviSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr);
DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
// IMediaSeeking
@@ -79,7 +79,7 @@ public:
};
class __declspec(uuid("CEA8DEFF-0AF7-4DB9-9A38-FB3C3AEFC0DE"))
-CAviSourceFilter : public CAviSplitterFilter
+ CAviSourceFilter : public CAviSplitterFilter
{
public:
CAviSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
diff --git a/src/filters/parser/AviSplitter/stdafx.cpp b/src/filters/parser/AviSplitter/stdafx.cpp
index 13934d005..bea3f980a 100644
--- a/src/filters/parser/AviSplitter/stdafx.cpp
+++ b/src/filters/parser/AviSplitter/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/parser/AviSplitter/stdafx.h b/src/filters/parser/AviSplitter/stdafx.h
index 7e2652f5d..37bcea3a7 100644
--- a/src/filters/parser/AviSplitter/stdafx.h
+++ b/src/filters/parser/AviSplitter/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/parser/BaseSplitter/AsyncReader.cpp b/src/filters/parser/BaseSplitter/AsyncReader.cpp
index deb21fd1d..cfe36e69a 100644
--- a/src/filters/parser/BaseSplitter/AsyncReader.cpp
+++ b/src/filters/parser/BaseSplitter/AsyncReader.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -30,30 +30,34 @@
// CAsyncFileReader
//
-CAsyncFileReader::CAsyncFileReader(CString fn, HRESULT& hr)
+CAsyncFileReader::CAsyncFileReader(CString fn, HRESULT& hr)
: 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();
+ if(SUCCEEDED(hr)) {
+ m_len = GetLength();
+ }
}
-CAsyncFileReader::CAsyncFileReader(CAtlList<CHdmvClipInfo::PlaylistItem>& Items, HRESULT& hr)
+CAsyncFileReader::CAsyncFileReader(CAtlList<CHdmvClipInfo::PlaylistItem>& Items, HRESULT& hr)
: 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();
+ if(SUCCEEDED(hr)) {
+ m_len = GetLength();
+ }
}
STDMETHODIMP CAsyncFileReader::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
CheckPointer(ppv, E_POINTER);
- return
+ return
QI(IAsyncReader)
QI(ISyncReader)
QI(IFileHandle)
@@ -64,36 +68,46 @@ STDMETHODIMP CAsyncFileReader::NonDelegatingQueryInterface(REFIID riid, void** p
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)
+ 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)
- {
+ } 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();}
+ 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);
+ } while(m_hBreakEvent && WaitForSingleObject(m_hBreakEvent, 0) == WAIT_TIMEOUT);
return E_FAIL;
}
@@ -101,8 +115,12 @@ STDMETHODIMP CAsyncFileReader::SyncRead(LONGLONG llPosition, LONG lLength, BYTE*
STDMETHODIMP CAsyncFileReader::Length(LONGLONG* pTotal, LONGLONG* pAvailable)
{
LONGLONG len = m_len >= 0 ? m_len : GetLength();
- if(pTotal) *pTotal = len;
- if(pAvailable) *pAvailable = len;
+ if(pTotal) {
+ *pTotal = len;
+ }
+ if(pAvailable) {
+ *pAvailable = len;
+ }
return S_OK;
}
@@ -122,15 +140,18 @@ STDMETHODIMP_(LPCTSTR) CAsyncFileReader::GetFileName()
// CAsyncUrlReader
//
-CAsyncUrlReader::CAsyncUrlReader(CString url, HRESULT& hr)
+CAsyncUrlReader::CAsyncUrlReader(CString url, HRESULT& hr)
: CAsyncFileReader(url, hr)
{
- if(SUCCEEDED(hr)) return;
+ if(SUCCEEDED(hr)) {
+ return;
+ }
m_url = url;
- if(CAMThread::Create())
+ 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
@@ -138,11 +159,11 @@ CAsyncUrlReader::CAsyncUrlReader(CString url, HRESULT& hr)
CAsyncUrlReader::~CAsyncUrlReader()
{
- if(ThreadExists())
+ if(ThreadExists()) {
CallWorker(CMD_EXIT);
+ }
- if(!m_fn.IsEmpty())
- {
+ if(!m_fn.IsEmpty()) {
CMultiFiles::Close();
DeleteFile(m_fn);
}
@@ -152,7 +173,9 @@ CAsyncUrlReader::~CAsyncUrlReader()
STDMETHODIMP CAsyncUrlReader::Length(LONGLONG* pTotal, LONGLONG* pAvailable)
{
- if(pTotal) *pTotal = 0;
+ if(pTotal) {
+ *pTotal = 0;
+ }
return __super::Length(NULL, pAvailable);
}
@@ -163,41 +186,41 @@ DWORD CAsyncUrlReader::ThreadProc()
AfxSocketInit(NULL);
DWORD cmd = GetRequest();
- if(cmd != CMD_INIT) {Reply((DWORD)E_FAIL); return (DWORD)-1;}
+ if(cmd != CMD_INIT) {
+ Reply((DWORD)E_FAIL);
+ return (DWORD)-1;
+ }
- try
- {
+ 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))
- {
+ && 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);
+ if(len > 0) {
+ fout.Write(buff, len);
+ }
Reply(S_OK);
- while(!CheckRequest(&cmd))
- {
+ while(!CheckRequest(&cmd)) {
int len = fin->Read(buff, sizeof(buff));
- if(len > 0) fout.Write(buff, len);
+ if(len > 0) {
+ fout.Write(buff, len);
+ }
}
- }
- else
- {
+ } 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)
- {
+ } catch(CInternetException* ie) {
ie->Delete();
Reply((DWORD)E_FAIL);
}
diff --git a/src/filters/parser/BaseSplitter/AsyncReader.h b/src/filters/parser/BaseSplitter/AsyncReader.h
index 64c4e9113..f649ac102 100644
--- a/src/filters/parser/BaseSplitter/AsyncReader.h
+++ b/src/filters/parser/BaseSplitter/AsyncReader.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -24,8 +24,8 @@
#include "MultiFiles.h"
interface __declspec(uuid("6DDB4EE7-45A0-4459-A508-BD77B32C91B2"))
-ISyncReader : public IUnknown
-{
+ISyncReader :
+public IUnknown {
STDMETHOD_(void, SetBreakEvent) (HANDLE hBreakEvent) = 0;
STDMETHOD_(bool, HasErrors) () = 0;
STDMETHOD_(void, ClearErrors) () = 0;
@@ -33,8 +33,8 @@ ISyncReader : public IUnknown
};
interface __declspec(uuid("7D55F67A-826E-40B9-8A7D-3DF0CBBD272D"))
-IFileHandle : public IUnknown
-{
+IFileHandle :
+public IUnknown {
STDMETHOD_(HANDLE, GetFileHandle)() = 0;
STDMETHOD_(LPCTSTR, GetFileName)() = 0;
};
@@ -55,21 +55,41 @@ public:
// 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 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;}
+ 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;};
+ 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
@@ -84,7 +104,7 @@ class CAsyncUrlReader : public CAsyncFileReader, protected CAMThread
protected:
enum {CMD_EXIT, CMD_INIT};
- DWORD ThreadProc();
+ DWORD ThreadProc();
public:
CAsyncUrlReader(CString url, HRESULT& hr);
diff --git a/src/filters/parser/BaseSplitter/BaseSplitter.cpp b/src/filters/parser/BaseSplitter/BaseSplitter.cpp
index 173442b29..c23a2cd8a 100644
--- a/src/filters/parser/BaseSplitter/BaseSplitter.cpp
+++ b/src/filters/parser/BaseSplitter/BaseSplitter.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -45,15 +45,13 @@ void CPacketQueue::Add(CAutoPtr<Packet> p)
{
CAutoLock cAutoLock(this);
- if(p)
- {
+ 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();
+ && p->rtStart == Packet::INVALID_TIME
+ && !IsEmpty() && GetTail()->rtStart != Packet::INVALID_TIME) {
+ Packet* tail = GetTail();
int oldsize = tail->GetCount();
int newsize = tail->GetCount() + p->GetCount();
tail->SetCount(newsize, max(1024, newsize)); // doubles the reserved buffer size
@@ -73,7 +71,9 @@ CAutoPtr<Packet> CPacketQueue::Remove()
CAutoLock cAutoLock(this);
ASSERT(__super::GetCount() > 0);
CAutoPtr<Packet> p = RemoveHead();
- if(p) m_size -= p->GetDataSize();
+ if(p) {
+ m_size -= p->GetDataSize();
+ }
return p;
}
@@ -86,13 +86,13 @@ void CPacketQueue::RemoveAll()
int CPacketQueue::GetCount()
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
return __super::GetCount();
}
int CPacketQueue::GetSize()
{
- CAutoLock cAutoLock(this);
+ CAutoLock cAutoLock(this);
return m_size;
}
@@ -122,25 +122,26 @@ STDMETHODIMP CBaseSplitterInputPin::NonDelegatingQueryInterface(REFIID riid, voi
{
CheckPointer(ppv, E_POINTER);
- return
+ return
__super::NonDelegatingQueryInterface(riid, ppv);
}
HRESULT CBaseSplitterInputPin::CheckMediaType(const CMediaType* pmt)
{
return S_OK;
-/*
- return pmt->majortype == MEDIATYPE_Stream
- ? S_OK
- : E_INVALIDARG;
-*/
+ /*
+ return pmt->majortype == MEDIATYPE_Stream
+ ? S_OK
+ : E_INVALIDARG;
+ */
}
HRESULT CBaseSplitterInputPin::CheckConnect(IPin* pPin)
{
HRESULT hr;
- if(FAILED(hr = __super::CheckConnect(pPin)))
+ if(FAILED(hr = __super::CheckConnect(pPin))) {
return hr;
+ }
return CComQIPtr<IAsyncReader>(pPin) ? S_OK : E_NOINTERFACE;
}
@@ -149,11 +150,13 @@ HRESULT CBaseSplitterInputPin::BreakConnect()
{
HRESULT hr;
- if(FAILED(hr = __super::BreakConnect()))
+ if(FAILED(hr = __super::BreakConnect())) {
return hr;
+ }
- if(FAILED(hr = (static_cast<CBaseSplitterFilter*>(m_pFilter))->BreakConnect(PINDIR_INPUT, this)))
+ if(FAILED(hr = (static_cast<CBaseSplitterFilter*>(m_pFilter))->BreakConnect(PINDIR_INPUT, this))) {
return hr;
+ }
m_pAsyncReader.Release();
@@ -164,15 +167,17 @@ HRESULT CBaseSplitterInputPin::CompleteConnect(IPin* pPin)
{
HRESULT hr;
- if(FAILED(hr = __super::CompleteConnect(pPin)))
+ if(FAILED(hr = __super::CompleteConnect(pPin))) {
return hr;
+ }
CheckPointer(pPin, E_POINTER);
m_pAsyncReader = pPin;
CheckPointer(m_pAsyncReader, E_NOINTERFACE);
- if(FAILED(hr = (static_cast<CBaseSplitterFilter*>(m_pFilter))->CompleteConnect(PINDIR_INPUT, this)))
+ if(FAILED(hr = (static_cast<CBaseSplitterFilter*>(m_pFilter))->CompleteConnect(PINDIR_INPUT, this))) {
return hr;
+ }
return S_OK;
}
@@ -222,8 +227,8 @@ STDMETHODIMP CBaseSplitterOutputPin::NonDelegatingQueryInterface(REFIID riid, vo
{
CheckPointer(ppv, E_POINTER);
- return
-// riid == __uuidof(IMediaSeeking) ? m_pFilter->QueryInterface(riid, ppv) :
+ return
+ // riid == __uuidof(IMediaSeeking) ? m_pFilter->QueryInterface(riid, ppv) :
QI(IMediaSeeking)
QI(IPropertyBag)
QI(IPropertyBag2)
@@ -235,7 +240,9 @@ STDMETHODIMP CBaseSplitterOutputPin::NonDelegatingQueryInterface(REFIID riid, vo
HRESULT CBaseSplitterOutputPin::SetName(LPCWSTR pName)
{
CheckPointer(pName, E_POINTER);
- if(m_pName) delete [] m_pName;
+ if(m_pName) {
+ delete [] m_pName;
+ }
m_pName = DNew WCHAR[wcslen(pName)+1];
CheckPointer(m_pName, E_OUTOFMEMORY);
wcscpy(m_pName, pName);
@@ -244,35 +251,38 @@ HRESULT CBaseSplitterOutputPin::SetName(LPCWSTR pName)
HRESULT CBaseSplitterOutputPin::DecideBufferSize(IMemAllocator* pAlloc, ALLOCATOR_PROPERTIES* pProperties)
{
- ASSERT(pAlloc);
- ASSERT(pProperties);
+ ASSERT(pAlloc);
+ ASSERT(pProperties);
- HRESULT hr = NOERROR;
+ HRESULT hr = NOERROR;
pProperties->cBuffers = m_nBuffers;
pProperties->cbBuffer = max(m_mt.lSampleSize, 1);
- if(m_mt.subtype == MEDIASUBTYPE_Vorbis && m_mt.formattype == FORMAT_VorbisFormat)
- {
+ 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(int i = 0; i < m_mts.GetCount(); i++)
- {
- if(*pmt == m_mts[i])
+ for(int i = 0; i < m_mts.GetCount(); i++) {
+ if(*pmt == m_mts[i]) {
return S_OK;
+ }
}
return E_INVALIDARG;
@@ -280,10 +290,14 @@ HRESULT CBaseSplitterOutputPin::CheckMediaType(const CMediaType* pmt)
HRESULT CBaseSplitterOutputPin::GetMediaType(int iPosition, CMediaType* pmt)
{
- CAutoLock cAutoLock(m_pLock);
+ CAutoLock cAutoLock(m_pLock);
- if(iPosition < 0) return E_INVALIDARG;
- if(iPosition >= m_mts.GetCount()) return VFW_S_NO_MORE_ITEMS;
+ if(iPosition < 0) {
+ return E_INVALIDARG;
+ }
+ if(iPosition >= m_mts.GetCount()) {
+ return VFW_S_NO_MORE_ITEMS;
+ }
*pmt = m_mts[iPosition];
@@ -299,20 +313,22 @@ STDMETHODIMP CBaseSplitterOutputPin::Notify(IBaseFilter* pSender, Quality q)
HRESULT CBaseSplitterOutputPin::Active()
{
- CAutoLock cAutoLock(m_pLock);
+ CAutoLock cAutoLock(m_pLock);
- if(m_Connected)
+ if(m_Connected) {
Create();
+ }
return __super::Active();
}
HRESULT CBaseSplitterOutputPin::Inactive()
{
- CAutoLock cAutoLock(m_pLock);
+ CAutoLock cAutoLock(m_pLock);
- if(ThreadExists())
+ if(ThreadExists()) {
CallWorker(CMD_EXIT);
+ }
return __super::Inactive();
}
@@ -325,13 +341,17 @@ HRESULT CBaseSplitterOutputPin::DeliverBeginFlush()
m_hrDeliver = S_FALSE;
m_queue.RemoveAll();
HRESULT hr = IsConnected() ? GetConnected()->BeginFlush() : S_OK;
- if(S_OK != hr) m_eEndFlush.Set();
+ if(S_OK != hr) {
+ m_eEndFlush.Set();
+ }
return(hr);
}
HRESULT CBaseSplitterOutputPin::DeliverEndFlush()
{
- if(!ThreadExists()) return S_FALSE;
+ if(!ThreadExists()) {
+ return S_FALSE;
+ }
HRESULT hr = IsConnected() ? GetConnected()->EndFlush() : S_OK;
m_hrDeliver = S_OK;
m_fFlushing = false;
@@ -343,11 +363,17 @@ HRESULT CBaseSplitterOutputPin::DeliverEndFlush()
HRESULT CBaseSplitterOutputPin::DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
{
m_brs.rtLastDeliverTime = Packet::INVALID_TIME;
- if(m_fFlushing) return S_FALSE;
+ if(m_fFlushing) {
+ return S_FALSE;
+ }
m_rtStart = tStart;
- if(!ThreadExists()) return S_FALSE;
+ if(!ThreadExists()) {
+ return S_FALSE;
+ }
HRESULT hr = __super::DeliverNewSegment(tStart, tStop, dRate);
- if(S_OK != hr) return hr;
+ if(S_OK != hr) {
+ return hr;
+ }
MakeISCRHappy();
return hr;
}
@@ -369,15 +395,19 @@ HRESULT CBaseSplitterOutputPin::QueueEndOfStream()
HRESULT CBaseSplitterOutputPin::QueuePacket(CAutoPtr<Packet> p)
{
- if(!ThreadExists()) return S_FALSE;
+ if(!ThreadExists()) {
+ return S_FALSE;
+ }
- while(S_OK == m_hrDeliver
- && (!(static_cast<CBaseSplitterFilter*>(m_pFilter))->IsAnyPinDrying()
- || m_queue.GetSize() > MAXPACKETSIZE*100))
+ while(S_OK == m_hrDeliver
+ && (!(static_cast<CBaseSplitterFilter*>(m_pFilter))->IsAnyPinDrying()
+ || m_queue.GetSize() > MAXPACKETSIZE*100)) {
Sleep(1);
+ }
- if(S_OK != m_hrDeliver)
+ if(S_OK != m_hrDeliver) {
return m_hrDeliver;
+ }
m_queue.Add(p);
@@ -387,25 +417,24 @@ HRESULT CBaseSplitterOutputPin::QueuePacket(CAutoPtr<Packet> p)
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;
+ || 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
- {
+ do {
CComPtr<IPin> pPinTo;
CComQIPtr<IStreamSwitcherInputPin> pSSIP;
- if(S_OK == pPin->ConnectedTo(&pPinTo) && (pSSIP = pPinTo) && !pSSIP->IsActive())
+ if(S_OK == pPin->ConnectedTo(&pPinTo) && (pSSIP = pPinTo) && !pSSIP->IsActive()) {
return(false);
+ }
pPin = GetFirstPin(GetFilterFromPin(pPinTo), PINDIR_OUTPUT);
- }
- while(pPin);
+ } while(pPin);
return(true);
}
@@ -417,13 +446,11 @@ DWORD CBaseSplitterOutputPin::ThreadProc()
m_fFlushing = m_fFlushed = false;
m_eEndFlush.Set();
- while(1)
- {
+ while(1) {
Sleep(1);
DWORD cmd;
- if(CheckRequest(&cmd))
- {
+ if(CheckRequest(&cmd)) {
m_hThread = NULL;
cmd = GetRequest();
Reply(S_OK);
@@ -432,39 +459,36 @@ DWORD CBaseSplitterOutputPin::ThreadProc()
}
int cnt = 0;
- do
- {
+ do {
CAutoPtr<Packet> p;
{
CAutoLock cAutoLock(&m_queue);
- if((cnt = m_queue.GetCount()) > 0)
+ if((cnt = m_queue.GetCount()) > 0) {
p = m_queue.Remove();
+ }
}
- if(S_OK == m_hrDeliver && cnt > 0)
- {
+ 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();
+ 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
- {
+ 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);
+ } while(--cnt > 0);
}
}
@@ -474,23 +498,19 @@ HRESULT CBaseSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p)
INT_PTR nBytes = p->GetCount();
- if(nBytes == 0)
- {
+ if(nBytes == 0) {
return S_OK;
}
m_brs.nBytesSinceLastDeliverTime += nBytes;
- if(p->rtStart != Packet::INVALID_TIME)
- {
- if(m_brs.rtLastDeliverTime == Packet::INVALID_TIME)
- {
+ 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)
- {
+ if(m_brs.rtLastDeliverTime + 10000000 < p->rtStart) {
REFERENCE_TIME rtDiff = p->rtStart - m_brs.rtLastDeliverTime;
double secs, bits;
@@ -508,80 +528,106 @@ HRESULT CBaseSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p)
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);
-*/
+ /*
+ 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)))
- {
+ 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
- {
+ do {
CComPtr<IMediaSample> pSample;
- if(S_OK != (hr = GetDeliveryBuffer(&pSample, NULL, NULL, 0))) break;
+ if(S_OK != (hr = GetDeliveryBuffer(&pSample, NULL, NULL, 0))) {
+ break;
+ }
- if(nBytes > pSample->GetSize())
- {
+ if(nBytes > pSample->GetSize()) {
pSample.Release();
ALLOCATOR_PROPERTIES props, actual;
- if(S_OK != (hr = m_pAllocator->GetProperties(&props))) break;
+ 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(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(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)
- {
+ if(p->pmt) {
pSample->SetMediaType(p->pmt);
p->bDiscontinuity = true;
- CAutoLock cAutoLock(m_pLock);
+ CAutoLock cAutoLock(m_pLock);
m_mts.RemoveAll();
m_mts.Add(*p->pmt);
}
bool fTimeValid = p->rtStart != Packet::INVALID_TIME;
-/*
-//if(p->TrackNumber == 1)
-//if(p->rtStart != Packet::INVALID_TIME)
-TRACE(_T("[%d]: d%d s%d p%d, b=%d, %I64d-%I64d \n"),
- p->TrackNumber,
- p->bDiscontinuity, p->bSyncPoint, fTimeValid && p->rtStart < 0,
- nBytes, p->rtStart, p->rtStop);
-*/
+ /*
+ //if(p->TrackNumber == 1)
+ //if(p->rtStart != Packet::INVALID_TIME)
+ TRACE(_T("[%d]: d%d s%d p%d, b=%d, %I64d-%I64d \n"),
+ p->TrackNumber,
+ p->bDiscontinuity, p->bSyncPoint, fTimeValid && p->rtStart < 0,
+ nBytes, p->rtStart, p->rtStop);
+ */
ASSERT(!p->bSyncPoint || fTimeValid);
BYTE* pData = NULL;
- if(S_OK != (hr = pSample->GetPointer(&pData)) || !pData) break;
+ 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);
+ 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;
}
@@ -589,17 +635,16 @@ TRACE(_T("[%d]: d%d s%d p%d, b=%d, %I64d-%I64d \n"),
void CBaseSplitterOutputPin::MakeISCRHappy()
{
CComPtr<IPin> pPinTo = this, pTmp;
- while(pPinTo && SUCCEEDED(pPinTo->ConnectedTo(&pTmp)) && (pPinTo = pTmp))
- {
+ while(pPinTo && SUCCEEDED(pPinTo->ConnectedTo(&pTmp)) && (pPinTo = pTmp)) {
pTmp = NULL;
CComPtr<IBaseFilter> pBF = GetFilterFromPin(pPinTo);
- if(GetCLSID(pBF) == GUIDFromCString(_T("{48025243-2D39-11CE-875D-00608CB78066}"))) // ISCR
- {
+ 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->rtStart = -1;
+ p->rtStop = 0;
p->bSyncPoint = FALSE;
p->SetData(" ", 2);
QueuePacket(p);
@@ -705,7 +750,9 @@ CBaseSplitterFilter::CBaseSplitterFilter(LPCTSTR pName, LPUNKNOWN pUnk, HRESULT*
, m_rtLastStop(_I64_MIN)
, m_priority(THREAD_PRIORITY_NORMAL)
{
- if(phr) *phr = S_OK;
+ if(phr) {
+ *phr = S_OK;
+ }
m_pInput.Attach(DNew CBaseSplitterInputPin(NAME("CBaseSplitterInputPin"), this, this, phr));
}
@@ -724,10 +771,11 @@ STDMETHODIMP CBaseSplitterFilter::NonDelegatingQueryInterface(REFIID riid, void*
*ppv = NULL;
- if(m_pInput && riid == __uuidof(IFileSourceFilter))
+ if(m_pInput && riid == __uuidof(IFileSourceFilter)) {
return E_NOINTERFACE;
+ }
- return
+ return
QI(IFileSourceFilter)
QI(IMediaSeeking)
QI(IAMOpenProgress)
@@ -747,7 +795,7 @@ CBaseSplitterOutputPin* CBaseSplitterFilter::GetOutputPin(DWORD TrackNum)
{
CAutoLock cAutoLock(&m_csPinMap);
- CBaseSplitterOutputPin* pPin = NULL;
+ CBaseSplitterOutputPin* pPin = NULL;
m_pPinMap.Lookup(TrackNum, pPin);
return pPin;
}
@@ -757,12 +805,13 @@ DWORD CBaseSplitterFilter::GetOutputTrackNum(CBaseSplitterOutputPin* pPin)
CAutoLock cAutoLock(&m_csPinMap);
POSITION pos = m_pPinMap.GetStartPosition();
- while(pos)
- {
+ while(pos) {
DWORD TrackNum;
CBaseSplitterOutputPin* pPinTmp;
m_pPinMap.GetNextAssoc(pos, TrackNum, pPinTmp);
- if(pPinTmp == pPin) return TrackNum;
+ if(pPinTmp == pPin) {
+ return TrackNum;
+ }
}
return (DWORD)-1;
@@ -773,19 +822,17 @@ HRESULT CBaseSplitterFilter::RenameOutputPin(DWORD TrackNumSrc, DWORD TrackNumDs
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))
+ 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;
- if(pmt)
- {
+ if(pmt) {
CAutoLock cAutoLock(&m_csmtnew);
m_mtnew[TrackNumDst] = *pmt;
}
@@ -800,7 +847,9 @@ HRESULT CBaseSplitterFilter::AddOutputPin(DWORD TrackNum, CAutoPtr<CBaseSplitter
{
CAutoLock cAutoLock(&m_csPinMap);
- if(!pPin) return E_INVALIDARG;
+ if(!pPin) {
+ return E_INVALIDARG;
+ }
m_pPinMap[TrackNum] = pPin;
m_pOutputs.AddTail(pPin);
return S_OK;
@@ -813,12 +862,15 @@ HRESULT CBaseSplitterFilter::DeleteOutputs()
m_pRetiredOutputs.RemoveAll();
CAutoLock cAutoLockF(this);
- if(m_State != State_Stopped) return VFW_E_NOT_STOPPED;
+ if(m_State != State_Stopped) {
+ return VFW_E_NOT_STOPPED;
+ }
- while(m_pOutputs.GetCount())
- {
+ while(m_pOutputs.GetCount()) {
CAutoPtr<CBaseSplitterOutputPin> pPin = m_pOutputs.RemoveHead();
- if(IPin* pPinTo = pPin->GetConnected()) pPinTo->Disconnect();
+ 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);
@@ -845,40 +897,45 @@ void CBaseSplitterFilter::DeliverBeginFlush()
{
m_fFlushing = true;
POSITION pos = m_pOutputs.GetHeadPosition();
- while(pos) m_pOutputs.GetNext(pos)->DeliverBeginFlush();
+ while(pos) {
+ m_pOutputs.GetNext(pos)->DeliverBeginFlush();
+ }
}
void CBaseSplitterFilter::DeliverEndFlush()
{
POSITION pos = m_pOutputs.GetHeadPosition();
- while(pos) m_pOutputs.GetNext(pos)->DeliverEndFlush();
+ while(pos) {
+ m_pOutputs.GetNext(pos)->DeliverEndFlush();
+ }
m_fFlushing = false;
m_eEndFlush.Set();
}
DWORD CBaseSplitterFilter::ThreadProc()
{
- if(m_pSyncReader)
+ if(m_pSyncReader) {
m_pSyncReader->SetBreakEvent(GetRequestHandle());
+ }
- if(!DemuxInit())
- {
- while(1)
- {
+ if(!DemuxInit()) {
+ while(1) {
DWORD cmd = GetRequest();
- if(cmd == CMD_EXIT) CAMThread::m_hThread = NULL;
+ if(cmd == CMD_EXIT) {
+ CAMThread::m_hThread = NULL;
+ }
Reply(S_OK);
- if(cmd == CMD_EXIT) return 0;
+ if(cmd == CMD_EXIT) {
+ return 0;
+ }
}
}
m_eEndFlush.Set();
m_fFlushing = false;
- for(DWORD cmd = (DWORD)-1; ; cmd = GetRequest())
- {
- if(cmd == CMD_EXIT)
- {
+ for(DWORD cmd = (DWORD)-1; ; cmd = GetRequest()) {
+ if(cmd == CMD_EXIT) {
m_hThread = NULL;
Reply(S_OK);
return 0;
@@ -891,30 +948,31 @@ DWORD CBaseSplitterFilter::ThreadProc()
DemuxSeek(m_rtStart);
- if(cmd != (DWORD)-1)
+ if(cmd != (DWORD)-1) {
Reply(S_OK);
+ }
m_eEndFlush.Wait();
m_pActivePins.RemoveAll();
POSITION pos = m_pOutputs.GetHeadPosition();
- while(pos && !m_fFlushing)
- {
+ while(pos && !m_fFlushing) {
CBaseSplitterOutputPin* pPin = m_pOutputs.GetNext(pos);
- if(pPin->IsConnected() && pPin->IsActive())
- {
+ 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))
+ while(pos && !CheckRequest(&cmd)) {
m_pActivePins.GetNext(pos)->QueueEndOfStream();
+ }
}
ASSERT(0); // we should only exit via CMD_EXIT
@@ -928,11 +986,11 @@ HRESULT CBaseSplitterFilter::DeliverPacket(CAutoPtr<Packet> p)
HRESULT hr = S_FALSE;
CBaseSplitterOutputPin* pPin = GetOutputPin(p->TrackNumber);
- if(!pPin || !pPin->IsConnected() || !m_pActivePins.Find(pPin))
+ if(!pPin || !pPin->IsConnected() || !m_pActivePins.Find(pPin)) {
return S_FALSE;
+ }
- if(p->rtStart != Packet::INVALID_TIME)
- {
+ if(p->rtStart != Packet::INVALID_TIME) {
m_rtCurrent = p->rtStart;
p->rtStart -= m_rtStart;
@@ -945,42 +1003,44 @@ HRESULT CBaseSplitterFilter::DeliverPacket(CAutoPtr<Packet> p)
CAutoLock cAutoLock(&m_csmtnew);
CMediaType mt;
- if(m_mtnew.Lookup(p->TrackNumber, mt))
- {
+ if(m_mtnew.Lookup(p->TrackNumber, mt)) {
p->pmt = CreateMediaType(&mt);
m_mtnew.RemoveKey(p->TrackNumber);
}
}
- if(!m_bDiscontinuitySent.Find(p->TrackNumber))
+ if(!m_bDiscontinuitySent.Find(p->TrackNumber)) {
p->bDiscontinuity = TRUE;
+ }
DWORD TrackNumber = p->TrackNumber;
BOOL bDiscontinuity = p->bDiscontinuity;
-/*
-//if(p->TrackNumber == 1)
-//if(p->rtStart != Packet::INVALID_TIME)
-TRACE(_T("[%d]: d%d s%d p%d, b=%d, %I64d-%I64d \n"),
- p->TrackNumber,
- p->bDiscontinuity, p->bSyncPoint, p->rtStart != Packet::INVALID_TIME && p->rtStart < 0,
- p->GetCount(), p->rtStart, p->rtStop);
-*/
+ /*
+ //if(p->TrackNumber == 1)
+ //if(p->rtStart != Packet::INVALID_TIME)
+ TRACE(_T("[%d]: d%d s%d p%d, b=%d, %I64d-%I64d \n"),
+ p->TrackNumber,
+ p->bDiscontinuity, p->bSyncPoint, p->rtStart != Packet::INVALID_TIME && p->rtStart < 0,
+ p->GetCount(), p->rtStart, p->rtStop);
+ */
hr = pPin->QueuePacket(p);
- if(S_OK != hr)
- {
- if(POSITION pos = m_pActivePins.Find(pPin))
+ 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
+ if(!m_pActivePins.IsEmpty()) { // only die when all pins are down
hr = S_OK;
+ }
return hr;
}
- if(bDiscontinuity)
+ if(bDiscontinuity) {
m_bDiscontinuitySent.AddTail(TrackNumber);
+ }
return hr;
}
@@ -990,19 +1050,18 @@ bool CBaseSplitterFilter::IsAnyPinDrying()
int totalcount = 0, totalsize = 0;
POSITION pos = m_pActivePins.GetHeadPosition();
- while(pos)
- {
+ 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))
- {
+ 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);
+ while(pos) {
+ m_pOutputs.GetNext(pos)->SetThreadPriority(THREAD_PRIORITY_BELOW_NORMAL);
+ }
m_priority = THREAD_PRIORITY_BELOW_NORMAL;
}
return(true);
@@ -1011,16 +1070,18 @@ bool CBaseSplitterFilter::IsAnyPinDrying()
totalsize += size;
}
- if(m_priority != THREAD_PRIORITY_NORMAL && (totalcount > MAXPACKETS*2/3 || totalsize > MAXPACKETSIZE*2/3))
- {
-// SetThreadPriority(m_hThread, m_priority = THREAD_PRIORITY_NORMAL);
+ if(m_priority != THREAD_PRIORITY_NORMAL && (totalcount > MAXPACKETS*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);
+ while(pos) {
+ m_pOutputs.GetNext(pos)->SetThreadPriority(THREAD_PRIORITY_NORMAL);
+ }
m_priority = THREAD_PRIORITY_NORMAL;
}
- if(totalcount < MAXPACKETS && totalsize < MAXPACKETSIZE)
+ if(totalcount < MAXPACKETS && totalsize < MAXPACKETSIZE) {
return(true);
+ }
return(false);
}
@@ -1029,15 +1090,10 @@ HRESULT CBaseSplitterFilter::BreakConnect(PIN_DIRECTION dir, CBasePin* pPin)
{
CheckPointer(pPin, E_POINTER);
- if(dir == PINDIR_INPUT)
- {
+ if(dir == PINDIR_INPUT) {
DeleteOutputs();
- }
- else if(dir == PINDIR_OUTPUT)
- {
- }
- else
- {
+ } else if(dir == PINDIR_OUTPUT) {
+ } else {
return E_UNEXPECTED;
}
@@ -1048,28 +1104,24 @@ HRESULT CBaseSplitterFilter::CompleteConnect(PIN_DIRECTION dir, CBasePin* pPin)
{
CheckPointer(pPin, E_POINTER);
- if(dir == PINDIR_INPUT)
- {
+ if(dir == PINDIR_INPUT) {
CBaseSplitterInputPin* pIn = static_cast<CBaseSplitterInputPin*>(pPin);
HRESULT hr;
CComPtr<IAsyncReader> pAsyncReader;
if(FAILED(hr = pIn->GetAsyncReader(&pAsyncReader))
- || FAILED(hr = DeleteOutputs())
- || FAILED(hr = CreateOutputs(pAsyncReader)))
+ || FAILED(hr = DeleteOutputs())
+ || FAILED(hr = CreateOutputs(pAsyncReader))) {
return hr;
+ }
ChapSort();
m_pSyncReader = pAsyncReader;
- }
- else if(dir == PINDIR_OUTPUT)
- {
+ } else if(dir == PINDIR_OUTPUT) {
m_pRetiredOutputs.RemoveAll();
- }
- else
- {
+ } else {
return E_UNEXPECTED;
}
@@ -1083,16 +1135,15 @@ int CBaseSplitterFilter::GetPinCount()
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))
+ 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)
- {
+ if(n == (int)m_pOutputs.GetCount() && m_pInput) {
return m_pInput;
}
@@ -1108,8 +1159,9 @@ STDMETHODIMP CBaseSplitterFilter::Stop()
DeliverEndFlush();
HRESULT hr;
- if(FAILED(hr = __super::Stop()))
+ if(FAILED(hr = __super::Stop())) {
return hr;
+ }
return S_OK;
}
@@ -1121,11 +1173,11 @@ STDMETHODIMP CBaseSplitterFilter::Pause()
FILTER_STATE fs = m_State;
HRESULT hr;
- if(FAILED(hr = __super::Pause()))
+ if(FAILED(hr = __super::Pause())) {
return hr;
+ }
- if(fs == State_Stopped)
- {
+ if(fs == State_Stopped) {
Create();
}
@@ -1137,8 +1189,9 @@ STDMETHODIMP CBaseSplitterFilter::Run(REFERENCE_TIME tStart)
CAutoLock cAutoLock(this);
HRESULT hr;
- if(FAILED(hr = __super::Run(tStart)))
+ if(FAILED(hr = __super::Run(tStart))) {
return hr;
+ }
return S_OK;
}
@@ -1153,14 +1206,14 @@ STDMETHODIMP CBaseSplitterFilter::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYP
HRESULT hr = E_FAIL;
CComPtr<IAsyncReader> pAsyncReader;
CAtlList<CHdmvClipInfo::PlaylistItem> Items;
- if (BuildPlaylist (pszFileName, Items))
+ if (BuildPlaylist (pszFileName, Items)) {
pAsyncReader = (IAsyncReader*)DNew CAsyncFileReader(Items, hr);
- else
+ } else {
pAsyncReader = (IAsyncReader*)DNew CAsyncFileReader(CString(pszFileName), hr);
+ }
if(FAILED(hr)
- || FAILED(hr = DeleteOutputs())
- || FAILED(hr = CreateOutputs(pAsyncReader)))
- {
+ || FAILED(hr = DeleteOutputs())
+ || FAILED(hr = CreateOutputs(pAsyncReader))) {
m_fn = "";
return hr;
}
@@ -1176,8 +1229,9 @@ STDMETHODIMP CBaseSplitterFilter::GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TY
{
CheckPointer(ppszFileName, E_POINTER);
*ppszFileName = (LPOLESTR)CoTaskMemAlloc((m_fn.GetLength()+1)*sizeof(WCHAR));
- if(!(*ppszFileName))
+ if(!(*ppszFileName)) {
return E_OUTOFMEMORY;
+ }
wcscpy(*ppszFileName, m_fn);
return S_OK;
}
@@ -1192,87 +1246,150 @@ LPCTSTR CBaseSplitterFilter::GetPartFilename(IAsyncReader* pAsyncReader)
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;
+ if(*pCapabilities == 0) {
+ return S_OK;
+ }
DWORD caps;
GetCapabilities(&caps);
- if((caps&*pCapabilities) == 0) return E_FAIL;
- if(caps == *pCapabilities) return S_OK;
+ 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;}
-STDMETHODIMP CBaseSplitterFilter::QueryPreferredFormat(GUID* pFormat) {return GetTimeFormat(pFormat);}
-STDMETHODIMP CBaseSplitterFilter::GetTimeFormat(GUID* pFormat) {return pFormat ? *pFormat = TIME_FORMAT_MEDIA_TIME, S_OK : E_POINTER;}
-STDMETHODIMP CBaseSplitterFilter::IsUsingTimeFormat(const GUID* pFormat) {return IsFormatSupported(pFormat);}
-STDMETHODIMP CBaseSplitterFilter::SetTimeFormat(const GUID* pFormat) {return S_OK == IsFormatSupported(pFormat) ? S_OK : E_INVALIDARG;}
-STDMETHODIMP CBaseSplitterFilter::GetDuration(LONGLONG* pDuration) {CheckPointer(pDuration, E_POINTER); *pDuration = m_rtDuration; return S_OK;}
-STDMETHODIMP CBaseSplitterFilter::GetStopPosition(LONGLONG* pStop) {return GetDuration(pStop);}
-STDMETHODIMP CBaseSplitterFilter::GetCurrentPosition(LONGLONG* pCurrent) {return E_NOTIMPL;}
-STDMETHODIMP CBaseSplitterFilter::ConvertTimeFormat(LONGLONG* pTarget, const GUID* pTargetFormat, LONGLONG Source, const GUID* pSourceFormat) {return E_NOTIMPL;}
+STDMETHODIMP CBaseSplitterFilter::IsFormatSupported(const GUID* pFormat)
+{
+ return !pFormat ? E_POINTER : *pFormat == TIME_FORMAT_MEDIA_TIME ? S_OK : S_FALSE;
+}
+STDMETHODIMP CBaseSplitterFilter::QueryPreferredFormat(GUID* pFormat)
+{
+ return GetTimeFormat(pFormat);
+}
+STDMETHODIMP CBaseSplitterFilter::GetTimeFormat(GUID* pFormat)
+{
+ return pFormat ? *pFormat = TIME_FORMAT_MEDIA_TIME, S_OK : E_POINTER;
+}
+STDMETHODIMP CBaseSplitterFilter::IsUsingTimeFormat(const GUID* pFormat)
+{
+ return IsFormatSupported(pFormat);
+}
+STDMETHODIMP CBaseSplitterFilter::SetTimeFormat(const GUID* pFormat)
+{
+ return S_OK == IsFormatSupported(pFormat) ? S_OK : E_INVALIDARG;
+}
+STDMETHODIMP CBaseSplitterFilter::GetDuration(LONGLONG* pDuration)
+{
+ CheckPointer(pDuration, E_POINTER);
+ *pDuration = m_rtDuration;
+ return S_OK;
+}
+STDMETHODIMP CBaseSplitterFilter::GetStopPosition(LONGLONG* pStop)
+{
+ return GetDuration(pStop);
+}
+STDMETHODIMP CBaseSplitterFilter::GetCurrentPosition(LONGLONG* pCurrent)
+{
+ return E_NOTIMPL;
+}
+STDMETHODIMP CBaseSplitterFilter::ConvertTimeFormat(LONGLONG* pTarget, const GUID* pTargetFormat, LONGLONG Source, const GUID* pSourceFormat)
+{
+ return E_NOTIMPL;
+}
STDMETHODIMP CBaseSplitterFilter::SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD 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;
+ if(pCurrent) {
+ *pCurrent = m_rtCurrent;
+ }
+ if(pStop) {
+ *pStop = m_rtStop;
+ }
return S_OK;
}
STDMETHODIMP CBaseSplitterFilter::GetAvailable(LONGLONG* pEarliest, LONGLONG* pLatest)
{
- if(pEarliest) *pEarliest = 0;
+ if(pEarliest) {
+ *pEarliest = 0;
+ }
return GetDuration(pLatest);
}
-STDMETHODIMP CBaseSplitterFilter::SetRate(double dRate) {return dRate > 0 ? m_dRate = dRate, S_OK : E_INVALIDARG;}
-STDMETHODIMP CBaseSplitterFilter::GetRate(double* pdRate) {return pdRate ? *pdRate = m_dRate, S_OK : E_POINTER;}
-STDMETHODIMP CBaseSplitterFilter::GetPreroll(LONGLONG* pllPreroll) {return pllPreroll ? *pllPreroll = 0, S_OK : E_POINTER;}
+STDMETHODIMP CBaseSplitterFilter::SetRate(double dRate)
+{
+ return dRate > 0 ? m_dRate = dRate, S_OK : E_INVALIDARG;
+}
+STDMETHODIMP CBaseSplitterFilter::GetRate(double* pdRate)
+{
+ return pdRate ? *pdRate = m_dRate, S_OK : E_POINTER;
+}
+STDMETHODIMP CBaseSplitterFilter::GetPreroll(LONGLONG* pllPreroll)
+{
+ 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)
+ || (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;
+ 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;
- }
+ 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;
- }
+ 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)
+ if(m_rtCurrent == rtCurrent && m_rtStop == rtStop) {
return S_OK;
+ }
- if(m_rtLastStart == rtCurrent && m_rtLastStop == rtStop && !m_LastSeekers.Find(id))
- {
+ if(m_rtLastStart == rtCurrent && m_rtLastStop == rtStop && !m_LastSeekers.Find(id)) {
m_LastSeekers.AddTail(id);
return S_OK;
}
@@ -1282,19 +1399,18 @@ HRESULT CBaseSplitterFilter::SetPositionsInternal(void* id, LONGLONG* pCurrent,
m_LastSeekers.RemoveAll();
m_LastSeekers.AddTail(id);
-DbgLog((LOG_TRACE, 0, _T("Seek Started %I64d"), rtCurrent));
+ DbgLog((LOG_TRACE, 0, _T("Seek Started %I64d"), rtCurrent));
m_rtNewStart = m_rtCurrent = rtCurrent;
m_rtNewStop = rtStop;
- if(ThreadExists())
- {
+ if(ThreadExists()) {
DeliverBeginFlush();
CallWorker(CMD_SEEK);
DeliverEndFlush();
}
-DbgLog((LOG_TRACE, 0, _T("Seek Ended")));
+ DbgLog((LOG_TRACE, 0, _T("Seek Ended")));
return S_OK;
}
@@ -1351,7 +1467,9 @@ STDMETHODIMP CBaseSplitterFilter::get_ExSeekCapabilities(long* pExCapabilities)
{
CheckPointer(pExCapabilities, E_POINTER);
*pExCapabilities = AM_EXSEEK_CANSEEK;
- if(ChapGetCount()) *pExCapabilities |= AM_EXSEEK_MARKERSEEK;
+ if(ChapGetCount()) {
+ *pExCapabilities |= AM_EXSEEK_MARKERSEEK;
+ }
return S_OK;
}
@@ -1367,7 +1485,9 @@ 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;
+ if(i < 0) {
+ return E_FAIL;
+ }
*pCurrentMarker = i+1;
return S_OK;
}
@@ -1376,7 +1496,9 @@ STDMETHODIMP CBaseSplitterFilter::GetMarkerTime(long MarkerNum, double* pMarkerT
{
CheckPointer(pMarkerTime, E_POINTER);
REFERENCE_TIME rt;
- if(FAILED(ChapGet((int)MarkerNum-1, &rt))) return E_FAIL;
+ if(FAILED(ChapGet((int)MarkerNum-1, &rt))) {
+ return E_FAIL;
+ }
*pMarkerTime = (double)rt / 10000000;
return S_OK;
}
@@ -1411,8 +1533,7 @@ STDMETHODIMP CBaseSplitterFilter::GetStatus(int i, int& samples, int& size)
{
CAutoLock cAutoLock(m_pLock);
- if(POSITION pos = m_pOutputs.FindIndex(i))
- {
+ if(POSITION pos = m_pOutputs.FindIndex(i)) {
CBaseSplitterOutputPin* pPin = m_pOutputs.GetAt(pos);
samples = pPin->QueueCount();
size = pPin->QueueSize();
@@ -1424,5 +1545,5 @@ STDMETHODIMP CBaseSplitterFilter::GetStatus(int i, int& samples, int& size)
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 656fafa81..e030187c1 100644
--- a/src/filters/parser/BaseSplitter/BaseSplitter.h
+++ b/src/filters/parser/BaseSplitter/BaseSplitter.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -40,13 +40,25 @@ public:
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 GetCount();}
- void SetData(const void* ptr, DWORD len) {SetCount(len); memcpy(GetData(), ptr, len);}
+ Packet() {
+ pmt = NULL;
+ bDiscontinuity = bAppendable = FALSE;
+ }
+ virtual ~Packet() {
+ if(pmt) {
+ DeleteMediaType(pmt);
+ }
+ }
+ virtual int GetDataSize() {
+ return GetCount();
+ }
+ void SetData(const void* ptr, DWORD len) {
+ SetCount(len);
+ memcpy(GetData(), ptr, len);
+ }
};
-class CPacketQueue
+class CPacketQueue
: public CCritSec
, protected CAutoPtrList<Packet>
{
@@ -62,7 +74,7 @@ public:
class CBaseSplitterFilter;
-class CBaseSplitterInputPin
+class CBaseSplitterInputPin
: public CBasePin
{
protected:
@@ -75,19 +87,19 @@ public:
HRESULT GetAsyncReader(IAsyncReader** ppAsyncReader);
DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- HRESULT CheckMediaType(const CMediaType* pmt);
+ HRESULT CheckMediaType(const CMediaType* pmt);
- HRESULT CheckConnect(IPin* pPin);
- HRESULT BreakConnect();
+ HRESULT CheckConnect(IPin* pPin);
+ HRESULT BreakConnect();
HRESULT CompleteConnect(IPin* pPin);
STDMETHODIMP BeginFlush();
STDMETHODIMP EndFlush();
};
-class CBaseSplitterOutputPin
+class CBaseSplitterOutputPin
: public CBaseOutputPin
, public IDSMPropertyBagImpl
, protected CAMThread
@@ -107,18 +119,17 @@ private:
CAMEvent m_eEndFlush;
enum {CMD_EXIT};
- DWORD ThreadProc();
+ DWORD ThreadProc();
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);
+ HRESULT GetDeliveryBuffer(IMediaSample** ppSample, REFERENCE_TIME* pStartTime, REFERENCE_TIME* pEndTime, DWORD dwFlags);
+ HRESULT Deliver(IMediaSample* pSample);
// bitrate stats
- struct
- {
+ struct {
UINT64 nTotalBytesDelivered;
REFERENCE_TIME rtTotalTimeDelivered;
UINT64 nBytesSinceLastDeliverTime;
@@ -160,32 +171,41 @@ public:
virtual ~CBaseSplitterOutputPin();
DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
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);
// 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 Inactive();
- HRESULT DeliverBeginFlush();
+ HRESULT DeliverBeginFlush();
HRESULT DeliverEndFlush();
- HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
+ HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
int QueueCount();
int QueueSize();
- HRESULT QueueEndOfStream();
+ HRESULT QueueEndOfStream();
HRESULT QueuePacket(CAutoPtr<Packet> p);
// returns true for everything which (the lack of) would not block other streams (subtitle streams, basically)
@@ -196,11 +216,15 @@ public:
// 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
+class CBaseSplitterFilter
: public CBaseFilter
, public CCritSec
, public IDSMPropertyBagImpl
@@ -262,20 +286,22 @@ protected:
protected:
enum {CMD_EXIT, CMD_SEEK};
- DWORD ThreadProc();
+ 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 BuildPlaylist(LPCTSTR pszFileName, CAtlList<CHdmvClipInfo::PlaylistItem>& Items) {
+ return false;
+ };
public:
CBaseSplitterFilter(LPCTSTR pName, LPUNKNOWN pUnk, HRESULT* phr, const CLSID& clsid);
virtual ~CBaseSplitterFilter();
DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
bool IsAnyPinDrying();
@@ -330,10 +356,18 @@ public:
// 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;}
+ 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
@@ -342,14 +376,30 @@ public:
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;}
+ 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
@@ -358,8 +408,12 @@ public:
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;}
+ STDMETHODIMP put_PlaybackSpeed(double Speed) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP get_PlaybackSpeed(double* pSpeed) {
+ return E_NOTIMPL;
+ }
// IKeyFrameInfo
diff --git a/src/filters/parser/BaseSplitter/BaseSplitterFile.cpp b/src/filters/parser/BaseSplitter/BaseSplitterFile.cpp
index 483c3c7a2..36521c465 100644
--- a/src/filters/parser/BaseSplitter/BaseSplitterFile.cpp
+++ b/src/filters/parser/BaseSplitter/BaseSplitterFile.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -35,7 +35,10 @@ CBaseSplitterFile::CBaseSplitterFile(IAsyncReader* pAsyncReader, HRESULT& hr, in
, 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);
@@ -44,15 +47,13 @@ CBaseSplitterFile::CBaseSplitterFile(IAsyncReader* pAsyncReader, HRESULT& hr, in
m_fRandomAccess = total > 0 && total == available;
m_len = total;
- if(FAILED(hr) || fRandomAccess && !m_fRandomAccess || !fStreaming && m_fStreaming || m_len < 0)
- {
+ if(FAILED(hr) || fRandomAccess && !m_fRandomAccess || !fStreaming && m_fStreaming || m_len < 0) {
hr = E_FAIL;
return;
}
- if(!SetCacheSize(cachelen))
- {
- hr = E_OUTOFMEMORY;
+ if(!SetCacheSize(cachelen)) {
+ hr = E_OUTOFMEMORY;
return;
}
@@ -64,7 +65,9 @@ bool CBaseSplitterFile::SetCacheSize(int cachelen)
m_pCache.Free();
m_cachetotal = 0;
m_pCache.Allocate((size_t)cachelen);
- if(!m_pCache) return false;
+ if(!m_pCache) {
+ return false;
+ }
m_cachetotal = cachelen;
m_cachelen = 0;
return true;
@@ -84,12 +87,9 @@ __int64 CBaseSplitterFile::GetAvailable()
__int64 CBaseSplitterFile::GetLength(bool fUpdate)
{
- if(m_fStreaming)
- {
+ if(m_fStreaming) {
m_len = GetAvailable();
- }
- else if(fUpdate)
- {
+ } else if(fUpdate) {
LONGLONG total = 0, available;
m_pAsyncReader->Length(&total, &available);
m_len = total;
@@ -111,15 +111,16 @@ HRESULT CBaseSplitterFile::Read(BYTE* pData, __int64 len)
HRESULT hr = S_OK;
- if(!m_fRandomAccess)
- {
+ if(!m_fRandomAccess) {
LONGLONG total = 0, available = -1;
m_pAsyncReader->Length(&total, &available);
- if(total == available) {m_fRandomAccess = true; OnComplete();}
+ if(total == available) {
+ m_fRandomAccess = true;
+ OnComplete();
+ }
}
- if(m_cachetotal == 0 || !m_pCache)
- {
+ if(m_cachetotal == 0 || !m_pCache) {
hr = m_pAsyncReader->SyncRead(m_pos, (long)len, pData);
m_pos += len;
return hr;
@@ -127,8 +128,7 @@ HRESULT CBaseSplitterFile::Read(BYTE* pData, __int64 len)
BYTE* pCache = m_pCache;
- if(m_cachepos <= m_pos && m_pos < m_cachepos + m_cachelen)
- {
+ 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);
@@ -138,25 +138,29 @@ HRESULT CBaseSplitterFile::Read(BYTE* pData, __int64 len)
pData += minlen;
}
- while(len > m_cachetotal)
- {
+ while(len > m_cachetotal) {
hr = m_pAsyncReader->SyncRead(m_pos, (long)m_cachetotal, pData);
- if(S_OK != hr) return hr;
+ if(S_OK != hr) {
+ return hr;
+ }
len -= m_cachetotal;
m_pos += m_cachetotal;
pData += m_cachetotal;
}
- while(len > 0)
- {
+ 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;
+ if(minlen <= 0) {
+ return S_FALSE;
+ }
hr = m_pAsyncReader->SyncRead(m_pos, (long)maxlen, pCache);
- if(S_OK != hr) return hr;
+ if(S_OK != hr) {
+ return hr;
+ }
m_cachepos = m_pos;
m_cachelen = maxlen;
@@ -175,10 +179,11 @@ UINT64 CBaseSplitterFile::BitRead(int nBits, bool fPeek)
{
ASSERT(nBits >= 0 && nBits <= 64);
- while(m_bitlen < nBits)
- {
+ while(m_bitlen < nBits) {
m_bitbuff <<= 8;
- if(S_OK != Read((BYTE*)&m_bitbuff, 1)) {return 0;} // EOF? // ASSERT(0);
+ if(S_OK != Read((BYTE*)&m_bitbuff, 1)) {
+ return 0; // EOF? // ASSERT(0);
+ }
m_bitlen += 8;
}
@@ -186,8 +191,7 @@ UINT64 CBaseSplitterFile::BitRead(int nBits, bool fPeek)
UINT64 ret = (m_bitbuff >> bitlen) & ((1ui64 << nBits) - 1);
- if(!fPeek)
- {
+ if(!fPeek) {
m_bitbuff &= ((1ui64 << bitlen) - 1);
m_bitlen = bitlen;
}
@@ -207,14 +211,16 @@ void CBaseSplitterFile::BitFlush()
HRESULT CBaseSplitterFile::ByteRead(BYTE* pData, __int64 len)
{
- Seek(GetPos());
+ Seek(GetPos());
return Read(pData, len);
}
UINT64 CBaseSplitterFile::UExpGolombRead()
{
int n = -1;
- for(BYTE b = 0; !b; n++) b = BitRead(1);
+ for(BYTE b = 0; !b; n++) {
+ b = BitRead(1);
+ }
return (1ui64 << n) - 1 + BitRead(n);
}
@@ -228,14 +234,14 @@ HRESULT CBaseSplitterFile::HasMoreData(__int64 len, DWORD ms)
{
__int64 available = GetLength() - GetPos();
- if(!m_fStreaming)
- {
+ if(!m_fStreaming) {
return available < 1 ? E_FAIL : S_OK;
}
- if(available < len)
- {
- if(ms > 0) Sleep(ms);
+ if(available < len) {
+ if(ms > 0) {
+ Sleep(ms);
+ }
return S_FALSE;
}
diff --git a/src/filters/parser/BaseSplitter/BaseSplitterFile.h b/src/filters/parser/BaseSplitter/BaseSplitterFile.h
index 8b61961e1..279471748 100644
--- a/src/filters/parser/BaseSplitter/BaseSplitterFile.h
+++ b/src/filters/parser/BaseSplitter/BaseSplitterFile.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -51,7 +51,9 @@ public:
__int64 GetPos();
__int64 GetAvailable();
__int64 GetLength(bool fUpdate = false);
- __int64 GetRemaining() {return max(0, GetLength() - GetPos());}
+ __int64 GetRemaining() {
+ return max(0, GetLength() - GetPos());
+ }
virtual void Seek(__int64 pos);
UINT64 UExpGolombRead();
@@ -61,8 +63,12 @@ public:
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);
};
diff --git a/src/filters/parser/BaseSplitter/BaseSplitterFileEx.cpp b/src/filters/parser/BaseSplitter/BaseSplitterFileEx.cpp
index 85e259fc3..3a0df88ee 100644
--- a/src/filters/parser/BaseSplitter/BaseSplitterFileEx.cpp
+++ b/src/filters/parser/BaseSplitter/BaseSplitterFileEx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -50,12 +50,12 @@ bool CBaseSplitterFileEx::NextMpegStartCode(BYTE& code, __int64 len)
{
BitByteAlign();
DWORD dw = (DWORD)-1;
- do
- {
- if(len-- == 0 || !GetRemaining()) return(false);
+ do {
+ if(len-- == 0 || !GetRemaining()) {
+ return(false);
+ }
dw = (dw << 8) | (BYTE)BitRead(8);
- }
- while((dw&0xffffff00) != 0x00000100);
+ } while((dw&0xffffff00) != 0x00000100);
code = (BYTE)(dw&0xff);
return(true);
}
@@ -70,36 +70,44 @@ bool CBaseSplitterFileEx::Read(pshdr& h)
BYTE b = (BYTE)BitRead(8, true);
- if((b&0xf1) == 0x21)
- {
+ 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.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;
+ 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
- {
+ while(stuffing-- > 0) {
+ EXECUTE_ASSERT(BitRead(8) == 0xff);
+ }
+ } else {
return(false);
}
@@ -112,19 +120,21 @@ bool CBaseSplitterFileEx::Read(pssyshdr& h)
{
memset(&h, 0, sizeof(h));
- WORD len = (WORD)BitRead(16); MARKER;
- h.rate_bound = (DWORD)BitRead(22); MARKER;
+ 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.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
- {
+ for(len -= 6; len > 3; len -= 3) { // TODO: also store these, somewhere, if needed
UINT64 stream_id = BitRead(8);
UNUSED_ALWAYS(stream_id);
EXECUTE_ASSERT(BitRead(2) == 3);
@@ -139,42 +149,42 @@ bool CBaseSplitterFileEx::Read(peshdr& h, BYTE code)
{
memset(&h, 0, sizeof(h));
- if(!(code >= 0xbd && code < 0xf0 || code == 0xfd)) // 0xfd => blu-ray (.m2ts)
+ if(!(code >= 0xbd && code < 0xf0 || code == 0xfd)) { // 0xfd => blu-ray (.m2ts)
return(false);
+ }
h.len = (WORD)BitRead(16);
- if(code == 0xbe || code == 0xbf)
+ 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--;
+ 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)
- {
+ if(h.type == mpeg1) {
BYTE b = (BYTE)BitRead(2);
- if(b == 1)
- {
+ if(b == 1) {
h.std_buff_size = (BitRead(1)?1024:128)*BitRead(13);
- if(h.len) h.len -= 2;
+ if(h.len) {
+ h.len -= 2;
+ }
b = (BYTE)BitRead(2);
}
- if(b == 0)
- {
+ if(b == 0) {
h.fpts = (BYTE)BitRead(1);
h.fdts = (BYTE)BitRead(1);
}
- }
- else if(h.type == mpeg2)
- {
+ } else if(h.type == mpeg2) {
EXECUTE_ASSERT(BitRead(2) == mpeg2);
h.scrambling = (BYTE)BitRead(2);
h.priority = (BYTE)BitRead(1);
@@ -190,17 +200,15 @@ bool CBaseSplitterFileEx::Read(peshdr& h, BYTE code)
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);
+ } else {
+ if(h.len) while(h.len-- > 0) {
+ BitRead(8);
+ }
return(false);
}
- if(h.fpts)
- {
- if(h.type == mpeg2)
- {
+ if(h.fpts) {
+ if(h.type == mpeg2) {
// Temporary(dirty) fix - needs more testing
//BYTE b = (BYTE)BitRead(4);
//if(!(h.fdts && b == 3 || !h.fdts && b == 2)) {ASSERT(0); return(false);}
@@ -208,57 +216,73 @@ bool CBaseSplitterFileEx::Read(peshdr& h, BYTE code)
}
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 |= 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(h.fdts) {
// Temporary(dirty) fix - needs more testing
//if((BYTE)BitRead(4) != 1) {ASSERT(0); return(false);}
BitRead(4);
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 |= 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.type == mpeg1) {
+ if(!h.fpts && !h.fdts && BitRead(4) != 0xf) {
+ /*ASSERT(0);*/ return(false);
+ }
- if(h.len)
- {
+ if(h.len) {
h.len--;
- if(h.pts) h.len -= 4;
- if(h.dts) h.len -= 5;
+ if(h.pts) {
+ h.len -= 4;
+ }
+ if(h.dts) {
+ h.len -= 5;
+ }
}
}
- if(h.type == mpeg2)
- {
- if(h.len) h.len -= 3+h.hdrlen;
+ 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;
- while(left-- > 0) BitRead(8);
-/*
- // mpeg2 stuffing (ff ff .. , max 32x)
- while(BitRead(8, true) == 0xff) {BitRead(8); if(h.len) h.len--;}
- Seek(GetPos()); // put last peeked byte back for Read()
-
- // FIXME: this doesn't seems to be here,
- // infact there can be ff's as part of the data
- // right at the beginning of the packet, which
- // we should not skip...
-*/
+ if(h.fpts) {
+ left -= 5;
+ }
+ if(h.fdts) {
+ left -= 5;
+ }
+ while(left-- > 0) {
+ BitRead(8);
+ }
+ /*
+ // mpeg2 stuffing (ff ff .. , max 32x)
+ while(BitRead(8, true) == 0xff) {BitRead(8); if(h.len) h.len--;}
+ Seek(GetPos()); // put last peeked byte back for Read()
+
+ // FIXME: this doesn't seems to be here,
+ // infact there can be ff's as part of the data
+ // right at the beginning of the packet, which
+ // we should not skip...
+ */
}
return(true);
@@ -270,40 +294,43 @@ bool CBaseSplitterFileEx::Read(seqhdr& h, int len, CMediaType* pmt)
BYTE id = 0;
- while(GetPos() < endpos && id != 0xb3)
- {
- if(!NextMpegStartCode(id, len))
+ while(GetPos() < endpos && id != 0xb3) {
+ if(!NextMpegStartCode(id, len)) {
return(false);
+ }
}
- if(id != 0xb3)
+ 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};
+ 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.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++)
+ 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++)
+ for(int i = 0; i < countof(h.niqm); i++) {
h.niqm[i] = (BYTE)BitRead(8);
+ }
__int64 shlen = GetPos() - shpos;
- static float ar[] =
- {
+ 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
};
@@ -315,8 +342,7 @@ bool CBaseSplitterFileEx::Read(seqhdr& h, int len, CMediaType* pmt)
__int64 shextpos = 0, shextlen = 0;
- if(NextMpegStartCode(id, 8) && id == 0xb5) // sequence header ext
- {
+ if(NextMpegStartCode(id, 8) && id == 0xb5) { // sequence header ext
shextpos = GetPos() - 4;
h.startcodeid = BitRead(4);
@@ -327,14 +353,17 @@ bool CBaseSplitterFileEx::Read(seqhdr& h, int len, CMediaType* pmt)
h.chroma = BitRead(2);
h.width |= (BitRead(2)<<12);
h.height |= (BitRead(2)<<12);
- h.bitrate |= (BitRead(12)<<18); MARKER;
+ 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}};
+ 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;
@@ -346,15 +375,22 @@ bool CBaseSplitterFileEx::Read(seqhdr& h, int len, CMediaType* pmt)
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;
+ while(a) {
+ DWORD tmp = a;
+ a = b % tmp;
+ b = tmp;
+ }
+ if(b) {
+ h.arx /= b, h.ary /= b;
+ }
- if(!pmt) return(true);
+ if(!pmt) {
+ return(true);
+ }
pmt->majortype = MEDIATYPE_Video;
- if(type == mpeg1)
- {
+ if(type == mpeg1) {
pmt->subtype = MEDIASUBTYPE_MPEG1Payload;
pmt->formattype = FORMAT_MPEGVideo;
int len = FIELD_OFFSET(MPEG1VIDEOINFO, bSequenceHeader) + shlen + shextlen;
@@ -370,13 +406,13 @@ bool CBaseSplitterFileEx::Read(seqhdr& h, int len, CMediaType* pmt)
vi->cbSequenceHeader = shlen + shextlen;
Seek(shpos);
ByteRead((BYTE*)&vi->bSequenceHeader[0], shlen);
- if(shextpos && shextlen) Seek(shextpos);
+ if(shextpos && shextlen) {
+ Seek(shextpos);
+ }
ByteRead((BYTE*)&vi->bSequenceHeader[0] + shlen, shextlen);
pmt->SetFormat((BYTE*)vi, len);
delete [] vi;
- }
- else if(type == mpeg2)
- {
+ } else if(type == mpeg2) {
pmt->subtype = MEDIASUBTYPE_MPEG2_VIDEO;
pmt->formattype = FORMAT_MPEG2_VIDEO;
int len = FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) + shlen + shextlen;
@@ -394,13 +430,13 @@ bool CBaseSplitterFileEx::Read(seqhdr& h, int len, CMediaType* pmt)
vi->cbSequenceHeader = shlen + shextlen;
Seek(shpos);
ByteRead((BYTE*)&vi->dwSequenceHeader[0], shlen);
- if(shextpos && shextlen) Seek(shextpos);
+ if(shextpos && shextlen) {
+ Seek(shextpos);
+ }
ByteRead((BYTE*)&vi->dwSequenceHeader[0] + shlen, shextlen);
pmt->SetFormat((BYTE*)vi, len);
delete [] vi;
- }
- else
- {
+ } else {
return(false);
}
@@ -413,11 +449,13 @@ bool CBaseSplitterFileEx::Read(mpahdr& h, int len, bool fAllowV25, CMediaType* p
int syncbits = fAllowV25 ? 11 : 12;
- for(; len >= 4 && BitRead(syncbits, true) != (1<<syncbits) - 1; len--)
+ for(; len >= 4 && BitRead(syncbits, true) != (1<<syncbits) - 1; len--) {
BitRead(8);
+ }
- if(len < 4)
+ if(len < 4) {
return(false);
+ }
h.sync = BitRead(11);
h.version = BitRead(2);
@@ -433,22 +471,22 @@ bool CBaseSplitterFileEx::Read(mpahdr& h, int len, bool fAllowV25, CMediaType* p
h.original = BitRead(1);
h.emphasis = BitRead(2);
- if(h.version == 1 || h.layer == 0 || h.freq == 3 || h.bitrate == 15 || h.emphasis == 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.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)
+ && (h.bitrate >= 11 && h.bitrate <= 14) && h.channels == 3) {
return(false);
+ }
}
h.layer = 4 - h.layer;
//
- static int brtbl[][5] =
- {
+ static int brtbl[][5] = {
{0,0,0,0,0},
{32,32,32,32,8},
{64,48,40,48,16},
@@ -469,7 +507,9 @@ bool CBaseSplitterFileEx::Read(mpahdr& h, int len, bool fAllowV25, CMediaType* p
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);
+ if(bitrate == 0) {
+ return(false);
+ }
static int freq[][4] = {{11025,0,22050,44100},{12000,0,24000,48000},{8000,0,16000,32000}};
@@ -477,42 +517,51 @@ bool CBaseSplitterFileEx::Read(mpahdr& h, int len, bool fAllowV25, CMediaType* p
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;
+ ? (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);
+ if(!pmt) {
+ return(true);
+ }
- /*int*/ len = h.layer == 3
- ? sizeof(WAVEFORMATEX/*MPEGLAYER3WAVEFORMAT*/) // no need to overcomplicate this...
- : sizeof(MPEG1WAVEFORMAT);
+ /*int*/ len = h.layer == 3
+ ? sizeof(WAVEFORMATEX/*MPEGLAYER3WAVEFORMAT*/) // no need to overcomplicate this...
+ : sizeof(MPEG1WAVEFORMAT);
WAVEFORMATEX* wfe = (WAVEFORMATEX*)DNew BYTE[len];
memset(wfe, 0, len);
wfe->cbSize = len - sizeof(WAVEFORMATEX);
- if(h.layer == 3)
- {
+ 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
- {
+ /* 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;
+ 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;
}
@@ -536,11 +585,13 @@ bool CBaseSplitterFileEx::Read(aachdr& h, int len, CMediaType* pmt)
{
memset(&h, 0, sizeof(h));
- for(; len >= 7 && BitRead(12, true) != 0xfff; len--)
+ for(; len >= 7 && BitRead(12, true) != 0xfff; len--) {
BitRead(8);
+ }
- if(len < 7)
+ if(len < 7) {
return(false);
+ }
h.sync = BitRead(12);
h.version = BitRead(1);
@@ -559,17 +610,22 @@ bool CBaseSplitterFileEx::Read(aachdr& h, int len, CMediaType* pmt)
h.adts_buffer_fullness = BitRead(11);
h.no_raw_data_blocks_in_frame = BitRead(2);
- if(h.fcrc == 0) h.crc = BitRead(16);
+ if(h.fcrc == 0) {
+ h.crc = BitRead(16);
+ }
- if(h.layer != 0 || h.freq >= 12 || h.aac_frame_length <= (h.fcrc == 0 ? 9 : 7))
+ if(h.layer != 0 || h.freq >= 12 || h.aac_frame_length <= (h.fcrc == 0 ? 9 : 7)) {
return(false);
+ }
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};
+ 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);
+ if(!pmt) {
+ return(true);
+ }
WAVEFORMATEX* wfe = (WAVEFORMATEX*)DNew BYTE[sizeof(WAVEFORMATEX)+5];
memset(wfe, 0, sizeof(WAVEFORMATEX)+5);
@@ -597,33 +653,45 @@ bool CBaseSplitterFileEx::Read(ac3hdr& h, int len, CMediaType* pmt)
memset(&h, 0, sizeof(h));
- for(; len >= 7 && BitRead(16, true) != 0x0b77; len--)
+ for(; len >= 7 && BitRead(16, true) != 0x0b77; len--) {
BitRead(8);
+ }
- if(len < 7)
+ if(len < 7) {
return(false);
+ }
h.sync = (WORD)BitRead(16);
- if(h.sync != 0x0B77)
+ 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)
+ if(h.bsid > 16) {
return(false);
+ }
if(h.bsid <= 10) {
/* Normal AC-3 */
- if(h.fscod == 3)
+ if(h.fscod == 3) {
return(false);
- if(h.frmsizecod > 37)
+ }
+ 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);
+ 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 {
@@ -632,22 +700,22 @@ bool CBaseSplitterFileEx::Read(ac3hdr& h, int len, CMediaType* pmt)
Seek(pos);
h.frame_type = BitRead(2);
h.substreamid = BitRead(3);
- if(h.frame_type || h.substreamid)
+ if(h.frame_type || h.substreamid) {
return(false);
+ }
h.frame_size = (BitRead(11) + 1) << 1;
- if(h.frame_size < 7)
+ if(h.frame_size < 7) {
return(false);
+ }
h.sr_code = BitRead(2);
- if(h.sr_code == 3)
- {
+ if(h.sr_code == 3) {
int sr_code2 = BitRead(2);
- if(sr_code2 == 3)
+ if(sr_code2 == 3) {
return(false);
+ }
h.sample_rate = freq[sr_code2] / 2;
h.sr_shift = 1;
- }
- else
- {
+ } else {
static int eac3_blocks[4] = {1, 2, 3, 6};
h.num_blocks = eac3_blocks[BitRead(2)];
h.sample_rate = freq[h.sr_code];
@@ -657,34 +725,34 @@ bool CBaseSplitterFileEx::Read(ac3hdr& h, int len, CMediaType* pmt)
h.lfeon = BitRead(1);
}
- if(!pmt) return(true);
+ 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(h.bsid <= 10)
- {
+ if(h.bsid <= 10) {
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
- {
+ } 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)
+ if(e_ac3) {
pmt->subtype = MEDIASUBTYPE_DOLBY_DDPLUS;
- else
+ } else {
pmt->subtype = MEDIASUBTYPE_DOLBY_AC3;
+ }
pmt->formattype = FORMAT_WaveFormatEx;
pmt->SetFormat((BYTE*)&wfe, sizeof(wfe));
@@ -695,11 +763,13 @@ bool CBaseSplitterFileEx::Read(dtshdr& h, int len, CMediaType* pmt)
{
memset(&h, 0, sizeof(h));
- for(; len >= 10 && BitRead(32, true) != 0x7ffe8001; len--)
+ for(; len >= 10 && BitRead(32, true) != 0x7ffe8001; len--) {
BitRead(8);
+ }
- if(len < 10)
+ if(len < 10) {
return(false);
+ }
h.sync = (DWORD)BitRead(32);
h.frametype = BitRead(1);
@@ -711,19 +781,21 @@ bool CBaseSplitterFileEx::Read(dtshdr& h, int len, CMediaType* pmt)
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);
+ 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);
+ if(!pmt) {
+ return(true);
+ }
WAVEFORMATEX wfe;
memset(&wfe, 0, sizeof(wfe));
@@ -731,18 +803,17 @@ bool CBaseSplitterFileEx::Read(dtshdr& h, int len, CMediaType* pmt)
static int channels[] = {1, 2, 2, 2, 2, 3, 3, 4, 4, 5, 6, 6, 6, 7, 8, 8};
- if(h.amode < countof(channels))
- {
+ if(h.amode < countof(channels)) {
wfe.nChannels = channels[h.amode];
- if (h.lfe > 0)
+ 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[] =
- {
+ static int rate[] = {
32000,56000,64000,96000,112000,128000,192000,224000,
256000,320000,384000,448000,512000,576000,640000,754500,
960000,1024000,1152000,1280000,1344000,1408000,1411200,1472000,
@@ -769,12 +840,15 @@ bool CBaseSplitterFileEx::Read(hdmvlpcmhdr& h, CMediaType* pmt)
h.samplerate = BitRead(4);
h.bitpersample = BitRead(2);
- if (h.channels==0 || h.channels==2 ||
- (h.samplerate != 1 && h.samplerate!= 4 && h.samplerate!= 5) ||
- h.bitpersample<0 || h.bitpersample>3)
+ 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;
@@ -814,10 +888,13 @@ bool CBaseSplitterFileEx::Read(lpcmhdr& h, CMediaType* pmt)
h.channels = BitRead(3);
h.drc = (BYTE)BitRead(8);
- if(h.quantwordlen == 3 || h.reserved1 || h.reserved2)
+ if(h.quantwordlen == 3 || h.reserved1 || h.reserved2) {
return(false);
+ }
- if(!pmt) return(true);
+ if(!pmt) {
+ return(true);
+ }
WAVEFORMATEX wfe;
memset(&wfe, 0, sizeof(wfe));
@@ -825,17 +902,16 @@ bool CBaseSplitterFileEx::Read(lpcmhdr& h, CMediaType* pmt)
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;
+ 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;
@@ -854,7 +930,9 @@ bool CBaseSplitterFileEx::Read(dvdspuhdr& h, CMediaType* pmt)
{
memset(&h, 0, sizeof(h));
- if(!pmt) return(true);
+ if(!pmt) {
+ return(true);
+ }
pmt->majortype = MEDIATYPE_Video;
pmt->subtype = MEDIASUBTYPE_DVD_SUBPICTURE;
@@ -867,15 +945,16 @@ bool CBaseSplitterFileEx::Read(hdmvsubhdr& h, CMediaType* pmt, const char* langu
{
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;
SUBTITLEINFO* psi = (SUBTITLEINFO*)pmt->AllocFormatBuffer(sizeof(SUBTITLEINFO));
- if (psi)
- {
+ if (psi) {
memset(psi, 0, pmt->FormatLength());
strcpy(psi->IsoLang, language_code ? language_code : "eng");
}
@@ -887,7 +966,9 @@ bool CBaseSplitterFileEx::Read(svcdspuhdr& h, CMediaType* pmt)
{
memset(&h, 0, sizeof(h));
- if(!pmt) return(true);
+ if(!pmt) {
+ return(true);
+ }
pmt->majortype = MEDIATYPE_Video;
pmt->subtype = MEDIASUBTYPE_SVCD_SUBPICTURE;
@@ -900,7 +981,9 @@ bool CBaseSplitterFileEx::Read(cvdspuhdr& h, CMediaType* pmt)
{
memset(&h, 0, sizeof(h));
- if(!pmt) return(true);
+ if(!pmt) {
+ return(true);
+ }
pmt->majortype = MEDIATYPE_Video;
pmt->subtype = MEDIASUBTYPE_CVD_SUBPICTURE;
@@ -913,26 +996,23 @@ bool CBaseSplitterFileEx::Read(ps2audhdr& h, CMediaType* pmt)
{
memset(&h, 0, sizeof(h));
- if(BitRead(16, true) != 'SS')
+ if(BitRead(16, true) != 'SS') {
return(false);
+ }
__int64 pos = GetPos();
- while(BitRead(16, true) == 'SS')
- {
+ while(BitRead(16, true) == 'SS') {
DWORD tag = (DWORD)BitRead(32, true);
DWORD size = 0;
-
- if(tag == 'SShd')
- {
+
+ if(tag == 'SShd') {
BitRead(32);
ByteRead((BYTE*)&size, sizeof(size));
ASSERT(size == 0x18);
Seek(GetPos());
ByteRead((BYTE*)&h, sizeof(h));
- }
- else if(tag == 'SSbd')
- {
+ } else if(tag == 'SSbd') {
BitRead(32);
ByteRead((BYTE*)&size, sizeof(size));
break;
@@ -941,11 +1021,13 @@ bool CBaseSplitterFileEx::Read(ps2audhdr& h, CMediaType* pmt)
Seek(pos);
- if(!pmt) return(true);
+ if(!pmt) {
+ return(true);
+ }
WAVEFORMATEXPS2 wfe;
- wfe.wFormatTag =
- h.unk1 == 0x01 ? WAVE_FORMAT_PS2_PCM :
+ wfe.wFormatTag =
+ h.unk1 == 0x01 ? WAVE_FORMAT_PS2_PCM :
h.unk1 == 0x10 ? WAVE_FORMAT_PS2_ADPCM :
WAVE_FORMAT_UNKNOWN;
wfe.nChannels = (WORD)h.channels;
@@ -967,7 +1049,9 @@ bool CBaseSplitterFileEx::Read(ps2subhdr& h, CMediaType* pmt)
{
memset(&h, 0, sizeof(h));
- if(!pmt) return(true);
+ if(!pmt) {
+ return(true);
+ }
pmt->majortype = MEDIATYPE_Subtitle;
pmt->subtype = MEDIASUBTYPE_PS2_SUB;
@@ -982,19 +1066,22 @@ bool CBaseSplitterFileEx::Read(trhdr& h, bool fSync)
BitByteAlign();
- if(m_tslen == 0)
- {
+ if(m_tslen == 0) {
__int64 pos = GetPos();
- for(int i = 0; i < 192; i++)
- {
- if(BitRead(8, true) == 0x47)
- {
+ for(int i = 0; i < 192; i++) {
+ if(BitRead(8, true) == 0x47) {
__int64 pos = GetPos();
Seek(pos + 188);
- if(BitRead(8, true) == 0x47) {m_tslen = 188; break;} // TS stream
+ if(BitRead(8, true) == 0x47) {
+ m_tslen = 188; // TS stream
+ break;
+ }
Seek(pos + 192);
- if(BitRead(8, true) == 0x47) {m_tslen = 192; break;} // M2TS stream
+ if(BitRead(8, true) == 0x47) {
+ m_tslen = 192; // M2TS stream
+ break;
+ }
}
BitRead(8);
@@ -1002,32 +1089,35 @@ bool CBaseSplitterFileEx::Read(trhdr& h, bool fSync)
Seek(pos);
- if(m_tslen == 0)
- {
+ 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;
+ 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;}
+ if(BitRead(8, true) == 0x47) {
+ Seek(GetPos()-m_tslen);
+ break;
+ }
}
BitRead(8);
- if(i == m_tslen-1)
+ if(i == m_tslen-1) {
return(false);
+ }
}
}
- if(BitRead(8, true) != 0x47)
+ if(BitRead(8, true) != 0x47) {
return(false);
+ }
h.next = GetPos() + m_tslen;
@@ -1043,12 +1133,10 @@ bool CBaseSplitterFileEx::Read(trhdr& h, bool fSync)
h.bytes = 188 - 4;
- if(h.adapfield)
- {
+ if(h.adapfield) {
h.length = (BYTE)BitRead(8);
- if(h.length > 0)
- {
+ if(h.length > 0) {
h.discontinuity = BitRead(1);
h.randomaccess = BitRead(1);
h.priority = BitRead(1);
@@ -1060,8 +1148,7 @@ bool CBaseSplitterFileEx::Read(trhdr& h, bool fSync)
int i = 1;
- if(h.fPCR)
- {
+ if(h.fPCR) {
h.PCR = BitRead(33);
BitRead(6);
UINT64 PCRExt = BitRead(9);
@@ -1071,13 +1158,17 @@ bool CBaseSplitterFileEx::Read(trhdr& h, bool fSync)
ASSERT(i <= h.length);
- for(; i < h.length; i++)
+ for(; i < h.length; i++) {
BitRead(8);
+ }
}
h.bytes -= h.length+1;
- if(h.bytes < 0) {ASSERT(0); return false;}
+ if(h.bytes < 0) {
+ ASSERT(0);
+ return false;
+ }
}
return true;
@@ -1086,7 +1177,9 @@ bool CBaseSplitterFileEx::Read(trhdr& h, bool fSync)
bool CBaseSplitterFileEx::Read(trsechdr& h)
{
BYTE pointer_field = BitRead(8);
- while(pointer_field-- > 0) BitRead(8);
+ while(pointer_field-- > 0) {
+ BitRead(8);
+ }
h.table_id = BitRead(8);
h.section_syntax_indicator = BitRead(1);
h.zero = BitRead(1);
@@ -1107,18 +1200,18 @@ bool CBaseSplitterFileEx::Read(pvahdr& h, bool fSync)
BitByteAlign();
- if(fSync)
- {
- for(int i = 0; i < 65536; i++)
- {
- if((BitRead(64, true)&0xfffffc00ffe00000i64) == 0x4156000055000000i64)
+ if(fSync) {
+ for(int i = 0; i < 65536; i++) {
+ if((BitRead(64, true)&0xfffffc00ffe00000i64) == 0x4156000055000000i64) {
break;
+ }
BitRead(8);
}
}
- if((BitRead(64, true)&0xfffffc00ffe00000i64) != 0x4156000055000000i64)
+ if((BitRead(64, true)&0xfffffc00ffe00000i64) != 0x4156000055000000i64) {
return(false);
+ }
h.sync = (WORD)BitRead(16);
h.streamid = (BYTE)BitRead(8);
@@ -1130,24 +1223,28 @@ bool CBaseSplitterFileEx::Read(pvahdr& h, bool fSync)
h.prebytes = BitRead(2);
h.length = (WORD)BitRead(16);
- if(h.length > 6136)
+ if(h.length > 6136) {
return(false);
+ }
__int64 pos = GetPos();
- if(h.streamid == 1 && h.fpts)
- {
+ 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))
- {
+ } else if(h.streamid == 2 && (h.fpts || (BitRead(32, true)&0xffffffe0) == 0x000001c0)) {
BYTE b;
- if(!NextMpegStartCode(b, 4)) return(false);
+ if(!NextMpegStartCode(b, 4)) {
+ return(false);
+ }
peshdr h2;
- if(!Read(h2, b)) return(false);
+ 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;
+ if(h.fpts) {
+ h.pts = h2.pts;
+ }
}
BitRead(8*h.prebytes);
@@ -1159,26 +1256,27 @@ bool CBaseSplitterFileEx::Read(pvahdr& h, bool fSync)
void CBaseSplitterFileEx::RemoveMpegEscapeCode(BYTE* dst, BYTE* src, int length)
-{
- int si=0;
+{
+ 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++];
- }
+ 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)
@@ -1187,10 +1285,8 @@ bool CBaseSplitterFileEx::Read(avchdr& h, int len, CMediaType* pmt)
DWORD dwStartCode;
- while(GetPos() < endpos+4 /*&& BitRead(32, true) == 0x00000001*/ && (!h.spslen || !h.ppslen))
- {
- if (BitRead(32, true) != 0x00000001)
- {
+ while(GetPos() < endpos+4 /*&& BitRead(32, true) == 0x00000001*/ && (!h.spslen || !h.ppslen)) {
+ if (BitRead(32, true) != 0x00000001) {
BitRead(8);
continue;
}
@@ -1198,9 +1294,8 @@ bool CBaseSplitterFileEx::Read(avchdr& h, int len, CMediaType* pmt)
BitRead(32);
BYTE id = BitRead(8);
-
- if((id&0x9f) == 0x07 && (id&0x60) != 0)
- {
+
+ if((id&0x9f) == 0x07 && (id&0x60) != 0) {
#if 1
BYTE SPSTemp[MAX_SPS];
BYTE SPSBuff[MAX_SPS];
@@ -1221,10 +1316,8 @@ bool CBaseSplitterFileEx::Read(avchdr& h, int len, CMediaType* pmt)
gb.UExpGolombRead(); // seq_parameter_set_id
- if(h.profile >= 100) // high profile
- {
- if(gb.UExpGolombRead() == 3) // chroma_format_idc
- {
+ if(h.profile >= 100) { // high profile
+ if(gb.UExpGolombRead() == 3) { // chroma_format_idc
gb.BitRead(1); // residue_transform_flag
}
@@ -1236,26 +1329,25 @@ bool CBaseSplitterFileEx::Read(avchdr& h, int len, CMediaType* pmt)
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)
+ 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)
- {
+ if(pic_order_cnt_type == 0) {
gb.UExpGolombRead(); // log2_max_pic_order_cnt_lsb_minus4
- }
- else if(pic_order_cnt_type == 1)
- {
+ } 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();
- for(int i = 0; i < num_ref_frames_in_pic_order_cnt_cycle; i++)
- gb.SExpGolombRead(); // offset_for_ref_frame[i]
+ for(int i = 0; i < num_ref_frames_in_pic_order_cnt_cycle; i++) {
+ gb.SExpGolombRead(); // offset_for_ref_frame[i]
+ }
}
gb.UExpGolombRead(); // num_ref_frames
@@ -1268,75 +1360,66 @@ bool CBaseSplitterFileEx::Read(avchdr& h, int len, CMediaType* pmt)
h.width = (pic_width_in_mbs_minus1 + 1) * 16;
h.height = (2 - frame_mbs_only_flag) * (pic_height_in_map_units_minus1 + 1) * 16;
- if (h.height == 1088) h.height = 1080; // Prevent blur lines
+ if (h.height == 1088) {
+ h.height = 1080; // Prevent blur lines
+ }
- if (!frame_mbs_only_flag)
- gb.BitRead(1); // mb_adaptive_frame_field_flag
+ if (!frame_mbs_only_flag) {
+ gb.BitRead(1); // mb_adaptive_frame_field_flag
+ }
gb.BitRead(1); // direct_8x8_inference_flag
- if (gb.BitRead(1)) // frame_cropping_flag
- {
+ if (gb.BitRead(1)) { // frame_cropping_flag
gb.UExpGolombRead(); // frame_cropping_rect_left_offset
gb.UExpGolombRead(); // frame_cropping_rect_right_offset
gb.UExpGolombRead(); // frame_cropping_rect_top_offset
gb.UExpGolombRead(); // frame_cropping_rect_bottom_offset
}
-
- if (gb.BitRead(1)) // vui_parameters_present_flag
- {
- if (gb.BitRead(1)) // aspect_ratio_info_present_flag
- {
- if (255==(BYTE)gb.BitRead(8)) // aspect_ratio_idc)
- {
+
+ if (gb.BitRead(1)) { // vui_parameters_present_flag
+ if (gb.BitRead(1)) { // aspect_ratio_info_present_flag
+ if (255==(BYTE)gb.BitRead(8)) { // aspect_ratio_idc)
gb.BitRead(16); // sar_width
gb.BitRead(16); // sar_height
}
}
- if (gb.BitRead(1)) // overscan_info_present_flag
- {
+ if (gb.BitRead(1)) { // overscan_info_present_flag
gb.BitRead(1); // overscan_appropriate_flag
}
- if (gb.BitRead(1)) // video_signal_type_present_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
- {
+ 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
- {
+ 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
- {
+ if (gb.BitRead(1)) { // timing_info_present_flag
num_units_in_tick = gb.BitRead(32);
time_scale = gb.BitRead(32);
fixed_frame_rate_flag = gb.BitRead(1);
// Trick for weird parameters (10x to Madshi)!
- 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))
- {
+ 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
- {
+ } 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)
+ if (time_scale) {
h.AvgTimePerFrame = (10000000I64*num_units_in_tick)/time_scale;
+ }
}
}
@@ -1354,10 +1437,8 @@ bool CBaseSplitterFileEx::Read(avchdr& h, int len, CMediaType* pmt)
UExpGolombRead(); // seq_parameter_set_id
- if(h.profile >= 100) // high profile
- {
- if(UExpGolombRead() == 3) // chroma_format_idc
- {
+ if(h.profile >= 100) { // high profile
+ if(UExpGolombRead() == 3) { // chroma_format_idc
BitRead(1); // residue_transform_flag
}
@@ -1369,26 +1450,25 @@ bool CBaseSplitterFileEx::Read(avchdr& h, int len, CMediaType* pmt)
if(BitRead(1)) // seq_scaling_matrix_present_flag
for(int i = 0; i < 8; i++)
if(BitRead(1)) // seq_scaling_list_present_flag
- for(int j = 0, size = i < 6 ? 16 : 64, next = 8; j < size && next != 0; ++j)
+ for(int j = 0, size = i < 6 ? 16 : 64, next = 8; j < size && next != 0; ++j) {
next = (next + SExpGolombRead() + 256) & 255;
+ }
}
UExpGolombRead(); // log2_max_frame_num_minus4
UINT64 pic_order_cnt_type = UExpGolombRead();
- if(pic_order_cnt_type == 0)
- {
+ if(pic_order_cnt_type == 0) {
UExpGolombRead(); // log2_max_pic_order_cnt_lsb_minus4
- }
- else if(pic_order_cnt_type == 1)
- {
+ } else if(pic_order_cnt_type == 1) {
BitRead(1); // delta_pic_order_always_zero_flag
SExpGolombRead(); // offset_for_non_ref_pic
SExpGolombRead(); // offset_for_top_to_bottom_field
UINT64 num_ref_frames_in_pic_order_cnt_cycle = UExpGolombRead();
- for(int i = 0; i < num_ref_frames_in_pic_order_cnt_cycle; i++)
- SExpGolombRead(); // offset_for_ref_frame[i]
+ for(int i = 0; i < num_ref_frames_in_pic_order_cnt_cycle; i++) {
+ SExpGolombRead(); // offset_for_ref_frame[i]
+ }
}
UExpGolombRead(); // num_ref_frames
@@ -1401,119 +1481,112 @@ bool CBaseSplitterFileEx::Read(avchdr& h, int len, CMediaType* pmt)
h.width = (pic_width_in_mbs_minus1 + 1) * 16;
h.height = (2 - frame_mbs_only_flag) * (pic_height_in_map_units_minus1 + 1) * 16;
- if (h.height == 1088) h.height = 1080; // Prevent blur lines
+ if (h.height == 1088) {
+ h.height = 1080; // Prevent blur lines
+ }
- if (!frame_mbs_only_flag)
- BitRead(1); // mb_adaptive_frame_field_flag
+ if (!frame_mbs_only_flag) {
+ BitRead(1); // mb_adaptive_frame_field_flag
+ }
BitRead(1); // direct_8x8_inference_flag
- if (BitRead(1)) // frame_cropping_flag
- {
+ if (BitRead(1)) { // frame_cropping_flag
UExpGolombRead(); // frame_cropping_rect_left_offset
UExpGolombRead(); // frame_cropping_rect_right_offset
UExpGolombRead(); // frame_cropping_rect_top_offset
UExpGolombRead(); // frame_cropping_rect_bottom_offset
}
-
- if (BitRead(1)) // vui_parameters_present_flag
- {
- if (BitRead(1)) // aspect_ratio_info_present_flag
- {
- if (255==(BYTE)BitRead(8)) // aspect_ratio_idc)
- {
+
+ if (BitRead(1)) { // vui_parameters_present_flag
+ if (BitRead(1)) { // aspect_ratio_info_present_flag
+ if (255==(BYTE)BitRead(8)) { // aspect_ratio_idc)
BitRead(16); // sar_width
BitRead(16); // sar_height
}
}
- if (BitRead(1)) // overscan_info_present_flag
- {
+ if (BitRead(1)) { // overscan_info_present_flag
BitRead(1); // overscan_appropriate_flag
}
- if (BitRead(1)) // video_signal_type_present_flag
- {
+ if (BitRead(1)) { // video_signal_type_present_flag
BitRead(3); // video_format
BitRead(1); // video_full_range_flag
- if(BitRead(1)) // colour_description_present_flag
- {
+ if(BitRead(1)) { // colour_description_present_flag
BitRead(8); // colour_primaries
BitRead(8); // transfer_characteristics
BitRead(8); // matrix_coefficients
}
}
- if(BitRead(1)) // chroma_location_info_present_flag
- {
+ if(BitRead(1)) { // chroma_location_info_present_flag
UExpGolombRead(); // chroma_sample_loc_type_top_field
UExpGolombRead(); // chroma_sample_loc_type_bottom_field
}
- if (BitRead(1)) // timing_info_present_flag
- {
+ if (BitRead(1)) { // timing_info_present_flag
num_units_in_tick = BitRead(32);
time_scale = BitRead(32);
fixed_frame_rate_flag = BitRead(1);
// Trick for weird parameters (10x to Madshi)!
- 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))
- {
+ 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
- {
+ } 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)
+ if (time_scale) {
h.AvgTimePerFrame = (10000000I64*num_units_in_tick)/time_scale;
+ }
}
}
#endif
- }
- else if((id&0x9f) == 0x08 && (id&0x60) != 0)
- {
+ } else if((id&0x9f) == 0x08 && (id&0x60) != 0) {
h.ppspos = pos;
}
BitByteAlign();
dwStartCode = BitRead(32, true);
- while(GetPos() < endpos+4 && (dwStartCode != 0x00000001) && (dwStartCode & 0xFFFFFF00) != 0x00000100)
- {
+ while(GetPos() < endpos+4 && (dwStartCode != 0x00000001) && (dwStartCode & 0xFFFFFF00) != 0x00000100) {
BitRead(8);
dwStartCode = BitRead(32, true);
}
- if(h.spspos != 0 && h.spslen == 0)
+ if(h.spspos != 0 && h.spslen == 0) {
h.spslen = GetPos() - h.spspos;
- else if(h.ppspos != 0 && h.ppslen == 0)
+ } else if(h.ppspos != 0 && h.ppslen == 0) {
h.ppslen = GetPos() - h.ppspos;
+ }
}
- if(!h.spspos || !h.spslen || !h.ppspos || !h.ppslen)
+ if(!h.spspos || !h.spslen || !h.ppspos || !h.ppslen) {
return(false);
-
+ }
+
if(!h.AvgTimePerFrame || !(
- (h.level == 10) || (h.level == 11) || (h.level == 12) || (h.level == 13) ||
- (h.level == 20) || (h.level == 21) || (h.level == 22) ||
- (h.level == 30) || (h.level == 31) || (h.level == 32) ||
- (h.level == 40) || (h.level == 41) || (h.level == 42) ||
- (h.level == 50) || (h.level == 51)))
+ (h.level == 10) || (h.level == 11) || (h.level == 12) || (h.level == 13) ||
+ (h.level == 20) || (h.level == 21) || (h.level == 22) ||
+ (h.level == 30) || (h.level == 31) || (h.level == 32) ||
+ (h.level == 40) || (h.level == 41) || (h.level == 42) ||
+ (h.level == 50) || (h.level == 51))) {
return(false);
+ }
- if(!pmt) return(true);
+ if(!pmt) {
+ return(true);
+ }
{
int extra = 2+h.spslen-4 + 2+h.ppslen-4;
pmt->majortype = MEDIATYPE_Video;
pmt->subtype = FOURCCMap('1CVA');
-//pmt->subtype = MEDIASUBTYPE_H264; // TODO : put MEDIASUBTYPE_H264 to support Windows 7 decoder !
+ //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];
@@ -1555,8 +1628,7 @@ bool CBaseSplitterFileEx::Read(vc1hdr& h, int len, CMediaType* pmt)
__int64 extrapos = 0, extralen = 0;
int nFrameRateNum = 0, nFrameRateDen = 1;
- if (GetPos() < endpos+4 && BitRead(32, true) == 0x0000010F)
- {
+ if (GetPos() < endpos+4 && BitRead(32, true) == 0x0000010F) {
extrapos = GetPos();
BitRead(32);
@@ -1564,7 +1636,9 @@ bool CBaseSplitterFileEx::Read(vc1hdr& h, int len, CMediaType* pmt)
h.profile = BitRead(2);
// Check if advanced profile
- if (h.profile != 3) return(false);
+ if (h.profile != 3) {
+ return(false);
+ }
h.level = BitRead (3);
h.chromaformat = BitRead (2);
@@ -1584,41 +1658,36 @@ bool CBaseSplitterFileEx::Read(vc1hdr& h, int len, CMediaType* pmt)
h.finterpflag = BitRead (1);
BitRead (1); // reserved
h.psf = BitRead (1);
- if(BitRead (1))
- {
+ if(BitRead (1)) {
int ar = 0;
h.ArX = BitRead (14) + 1;
h.ArY = BitRead (14) + 1;
- if(BitRead (1))
+ if(BitRead (1)) {
ar = BitRead (4);
- // TODO : next is not the true A/R!
- if(ar && ar < 14)
- {
-// h.ArX = ff_vc1_pixel_aspect[ar].num;
-// h.ArY = ff_vc1_pixel_aspect[ar].den;
}
- else if(ar == 15)
- {
+ // TODO : next is not the true A/R!
+ if(ar && ar < 14) {
+ // h.ArX = ff_vc1_pixel_aspect[ar].num;
+ // h.ArY = ff_vc1_pixel_aspect[ar].den;
+ } else if(ar == 15) {
/*h.ArX =*/ BitRead (8);
- /*h.ArY =*/ BitRead (8);
+ /*h.ArY =*/
+ BitRead (8);
}
// Read framerate
const int ff_vc1_fps_nr[5] = { 24, 25, 30, 50, 60 },
- ff_vc1_fps_dr[2] = { 1000, 1001 };
+ ff_vc1_fps_dr[2] = { 1000, 1001 };
- if(BitRead (1))
- {
- if(BitRead (1))
- {
+ if(BitRead (1)) {
+ if(BitRead (1)) {
nFrameRateNum = 32;
nFrameRateDen = BitRead (16) + 1;
} else {
int nr, dr;
nr = BitRead (8);
dr = BitRead (4);
- if(nr && nr < 8 && dr && dr < 3)
- {
+ if(nr && nr < 8 && dr && dr < 3) {
nFrameRateNum = ff_vc1_fps_dr[dr - 1];
nFrameRateDen = ff_vc1_fps_nr[nr - 1] * 1000;
}
@@ -1631,17 +1700,19 @@ bool CBaseSplitterFileEx::Read(vc1hdr& h, int len, CMediaType* pmt)
extralen = 0;
long parse = 0;
- while (GetPos() < endpos+4 && ((parse == 0x0000010E) || (parse & 0xFFFFFF00) != 0x00000100))
- {
+ while (GetPos() < endpos+4 && ((parse == 0x0000010E) || (parse & 0xFFFFFF00) != 0x00000100)) {
parse = (parse<<8) | BitRead(8);
extralen++;
}
}
- if(!extrapos || !extralen)
+ if(!extrapos || !extralen) {
return(false);
+ }
- if(!pmt) return(true);
+ if(!pmt) {
+ return(true);
+ }
{
//pmt->majortype = MEDIATYPE_Video;
@@ -1695,8 +1766,7 @@ bool CBaseSplitterFileEx::Read(vc1hdr& h, int len, CMediaType* pmt)
bool CBaseSplitterFileEx::Read(dvbsub& h, int len, CMediaType* pmt)
{
- if ((BitRead(32, true) & 0xFFFFFF00) == 0x20000f00)
- {
+ if ((BitRead(32, true) & 0xFFFFFF00) == 0x20000f00) {
static const SUBTITLEINFO SubFormat = { 0, "", L"" };
pmt->majortype = MEDIATYPE_Subtitle;
diff --git a/src/filters/parser/BaseSplitter/BaseSplitterFileEx.h b/src/filters/parser/BaseSplitter/BaseSplitterFileEx.h
index 0d55a9366..942cfa4bc 100644
--- a/src/filters/parser/BaseSplitter/BaseSplitterFileEx.h
+++ b/src/filters/parser/BaseSplitter/BaseSplitterFileEx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -42,22 +42,19 @@ public:
enum mpeg_t {mpegunk, mpeg1, mpeg2};
- struct pshdr
- {
+ struct pshdr {
mpeg_t type;
UINT64 scr, bitrate;
};
- struct pssyshdr
- {
+ 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
- {
+ struct peshdr {
WORD len;
BYTE type:2, fpts:1, fdts:1;
@@ -71,7 +68,9 @@ public:
BYTE escr:1, esrate:1, dsmtrickmode:1, morecopyright:1, crc:1, extension:1;
BYTE hdrlen;
- struct peshdr() {memset(this, 0, sizeof(*this));}
+ struct peshdr() {
+ memset(this, 0, sizeof(*this));
+ }
};
class seqhdr
@@ -116,7 +115,7 @@ public:
WORD copyright:1;
WORD original:1;
WORD emphasis:2;
-
+
int nSamplesPerSec, FrameSize, nBytesPerSec;
REFERENCE_TIME rtDuration;
};
@@ -232,7 +231,7 @@ public:
public:
// nothing ;)
};
-
+
class svcdspuhdr
{
public:
@@ -264,8 +263,7 @@ public:
// nothing ;)
};
- struct trhdr
- {
+ struct trhdr {
BYTE sync; // 0x47
BYTE error:1;
BYTE payloadstart:1;
@@ -292,8 +290,7 @@ public:
__int64 next;
};
- struct trsechdr
- {
+ struct trsechdr {
BYTE table_id;
WORD section_syntax_indicator:1;
WORD zero:1;
@@ -309,8 +306,7 @@ public:
// http://www.technotrend.de/download/av_format_v1.pdf
- struct pvahdr
- {
+ struct pvahdr {
WORD sync; // 'VA'
BYTE streamid; // 1 - video, 2 - audio
BYTE counter;
@@ -323,16 +319,14 @@ public:
REFERENCE_TIME pts;
};
- struct avchdr
- {
+ struct avchdr {
BYTE profile, level;
unsigned int width, height;
__int64 spspos, spslen;
__int64 ppspos, ppslen;
__int64 AvgTimePerFrame;
- avchdr()
- {
+ avchdr() {
spspos = 0;
spslen = 0;
ppspos = 0;
@@ -341,8 +335,7 @@ public:
}
};
- struct vc1hdr
- {
+ struct vc1hdr {
BYTE profile;
BYTE level;
BYTE chromaformat;
@@ -359,8 +352,7 @@ public:
unsigned int width, height;
};
- struct dvbsub
- {
+ struct dvbsub {
};
#pragma pack(pop)
diff --git a/src/filters/parser/BaseSplitter/MultiFiles.cpp b/src/filters/parser/BaseSplitter/MultiFiles.cpp
index beb3a2e84..853fca54c 100644
--- a/src/filters/parser/BaseSplitter/MultiFiles.cpp
+++ b/src/filters/parser/BaseSplitter/MultiFiles.cpp
@@ -28,10 +28,10 @@
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)
{
}
@@ -59,11 +59,12 @@ BOOL CMultiFiles::OpenFiles(CAtlList<CHdmvClipInfo::PlaylistItem>& files, UINT n
REFERENCE_TIME rtDur = 0;
Reset();
- while(pos)
- {
+ while(pos) {
CHdmvClipInfo::PlaylistItem& s = files.GetNext(pos);
m_strFiles.Add(s.m_strFileName);
- if (!OpenPart(nPos)) return false;
+ if (!OpenPart(nPos)) {
+ return false;
+ }
llSize.QuadPart = 0;
GetFileSizeEx (m_hFile, &llSize);
@@ -74,8 +75,10 @@ BOOL CMultiFiles::OpenFiles(CAtlList<CHdmvClipInfo::PlaylistItem>& files, UINT n
nPos++;
}
- if (files.GetCount() > 1) ClosePart();
-
+ if (files.GetCount() > 1) {
+ ClosePart();
+ }
+
return TRUE;
}
@@ -85,21 +88,17 @@ ULONGLONG CMultiFiles::Seek(LONGLONG lOff, UINT nFrom)
LARGE_INTEGER llNewPos;
LARGE_INTEGER llOff;
- if (m_strFiles.GetCount() == 1)
- {
+ if (m_strFiles.GetCount() == 1) {
llOff.QuadPart = lOff;
SetFilePointerEx (m_hFile, llOff, &llNewPos, nFrom);
return llNewPos.QuadPart;
- }
- else
- {
+ } else {
LONGLONG lAbsolutePos = GetAbsolutePosition(lOff, nFrom);
int nNewPart = 0;
ULONGLONG llSum = 0;
- while (m_FilesSize[nNewPart]+llSum <= lAbsolutePos)
- {
+ while (m_FilesSize[nNewPart]+llSum <= lAbsolutePos) {
llSum += m_FilesSize[nNewPart];
nNewPart++;
}
@@ -117,42 +116,39 @@ 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
+ 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)
- {
+ if (m_strFiles.GetCount() == 1) {
LARGE_INTEGER llSize;
GetFileSizeEx (m_hFile, &llSize);
return llSize.QuadPart;
- }
- else
+ } else {
return m_llTotalLength;
+ }
}
UINT CMultiFiles::Read(void* lpBuf, UINT nCount)
{
DWORD dwRead;
- do
- {
- if (!ReadFile(m_hFile, lpBuf, nCount, &dwRead, NULL))
+ do {
+ if (!ReadFile(m_hFile, lpBuf, nCount, &dwRead, NULL)) {
break;
-
- if (dwRead != nCount && m_nCurPart < m_strFiles.GetCount()-1)
- {
+ }
+
+ if (dwRead != nCount && m_nCurPart < m_strFiles.GetCount()-1) {
OpenPart (m_nCurPart+1);
lpBuf = (void*)((BYTE*)lpBuf + dwRead);
nCount -= dwRead;
@@ -174,10 +170,9 @@ CMultiFiles::~CMultiFiles()
BOOL CMultiFiles::OpenPart(int nPart)
{
- if (m_nCurPart == nPart)
+ if (m_nCurPart == nPart) {
return TRUE;
- else
- {
+ } else {
CString fn;
ClosePart();
@@ -185,10 +180,11 @@ BOOL CMultiFiles::OpenPart(int nPart)
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)
- {
+ if (m_hFile != INVALID_HANDLE_VALUE) {
m_nCurPart = nPart;
- if (m_pCurrentPTSOffset != NULL) *m_pCurrentPTSOffset = m_rtPtsOffsets[nPart];
+ if (m_pCurrentPTSOffset != NULL) {
+ *m_pCurrentPTSOffset = m_rtPtsOffsets[nPart];
+ }
}
return (m_hFile != INVALID_HANDLE_VALUE);
@@ -198,8 +194,7 @@ BOOL CMultiFiles::OpenPart(int nPart)
void CMultiFiles::ClosePart()
{
- if (m_hFile != INVALID_HANDLE_VALUE)
- {
+ 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 b07862a0a..dbb700fed 100644
--- a/src/filters/parser/BaseSplitter/MultiFiles.h
+++ b/src/filters/parser/BaseSplitter/MultiFiles.h
@@ -31,7 +31,7 @@ class CMultiFiles : public CObject
DECLARE_DYNAMIC(CMultiFiles)
public:
-// Flag values
+ // Flag values
enum OpenFlags {
modeRead = (int) 0x00000,
modeWrite = (int) 0x00001,
@@ -50,7 +50,7 @@ public:
osWriteThrough = (int) 0x20000,
osRandomAccess = (int) 0x40000,
osSequentialScan = (int) 0x80000,
- };
+ };
enum Attribute {
normal = 0x00,
@@ -60,16 +60,16 @@ public:
volume = 0x08,
directory = 0x10,
archive = 0x20
- };
+ };
enum SeekPosition { begin = 0x0, current = 0x1, end = 0x2 };
-// Constructors
+ // Constructors
CMultiFiles();
CString m_strFileName;
-// Operations
+ // Operations
virtual BOOL Open(LPCTSTR lpszFileName, UINT nOpenFlags);
virtual BOOL OpenFiles(CAtlList<CHdmvClipInfo::PlaylistItem>& files, UINT nOpenFlags);
@@ -80,7 +80,7 @@ public:
virtual UINT Read(void* lpBuf, UINT nCount);
virtual void Close();
-// Implementation
+ // Implementation
public:
virtual ~CMultiFiles();
diff --git a/src/filters/parser/BaseSplitter/stdafx.cpp b/src/filters/parser/BaseSplitter/stdafx.cpp
index 13934d005..bea3f980a 100644
--- a/src/filters/parser/BaseSplitter/stdafx.cpp
+++ b/src/filters/parser/BaseSplitter/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/parser/BaseSplitter/stdafx.h b/src/filters/parser/BaseSplitter/stdafx.h
index 4811c9499..eb1a0a29e 100644
--- a/src/filters/parser/BaseSplitter/stdafx.h
+++ b/src/filters/parser/BaseSplitter/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/parser/DSMSplitter/DSMSplitter.cpp b/src/filters/parser/DSMSplitter/DSMSplitter.cpp
index 3b562b417..eaac42a0a 100644
--- a/src/filters/parser/DSMSplitter/DSMSplitter.cpp
+++ b/src/filters/parser/DSMSplitter/DSMSplitter.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -28,26 +28,22 @@
#ifdef REGISTER_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
{&MEDIATYPE_Stream, &MEDIASUBTYPE_DirectShowMedia},
{&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
};
-const AMOVIESETUP_PIN sudpPins[] =
-{
+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}
};
-const AMOVIESETUP_FILTER sudFilter[] =
-{
+const AMOVIESETUP_FILTER sudFilter[] = {
{&__uuidof(CDSMSplitterFilter), L"MPC - DSM Splitter", MERIT_NORMAL, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
{&__uuidof(CDSMSourceFilter), L"MPC - DSM Source", MERIT_NORMAL, 0, NULL, CLSID_LegacyAmFilterCategory},
};
-CFactoryTemplate g_Templates[] =
-{
+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]},
};
@@ -61,8 +57,8 @@ STDAPI DllRegisterServer()
str.Format(CString(str), DSMSW);
RegisterSourceFilter(
- CLSID_AsyncReader,
- MEDIASUBTYPE_DirectShowMedia,
+ CLSID_AsyncReader,
+ MEDIASUBTYPE_DirectShowMedia,
str, NULL);
return AMovieDllRegisterServer2(TRUE);
@@ -94,7 +90,10 @@ CDSMSplitterFilter::~CDSMSplitterFilter()
{
}
-static int compare_id(const void* id1, const void* id2) {return (int)*(BYTE*)id1 - (int)*(BYTE*)id2;}
+static int compare_id(const void* id1, const void* id2)
+{
+ return (int)*(BYTE*)id1 - (int)*(BYTE*)id2;
+}
HRESULT CDSMSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
{
@@ -104,8 +103,13 @@ HRESULT CDSMSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
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;}
+ 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;
@@ -113,8 +117,7 @@ HRESULT CDSMSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
CAtlArray<BYTE> ids;
POSITION pos = m_pFile->m_mts.GetStartPosition();
- while(pos)
- {
+ while(pos) {
BYTE id;
CMediaType mt;
m_pFile->m_mts.GetNextAssoc(pos, id, mt);
@@ -123,8 +126,7 @@ HRESULT CDSMSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
qsort(ids.GetData(), ids.GetCount(), sizeof(BYTE), compare_id);
- for(int i = 0; i < ids.GetCount(); i++)
- {
+ for(int i = 0; i < ids.GetCount(); i++) {
BYTE id = ids[i];
CMediaType& mt = m_pFile->m_mts[id];
@@ -135,24 +137,32 @@ HRESULT CDSMSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
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;
+ 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(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;
+ if(!name.IsEmpty() || !lang.IsEmpty()) {
+ if(!name.IsEmpty()) {
+ if(!lang.IsEmpty()) {
+ name += L" (" + lang + L")";
+ }
+ } else if(!lang.IsEmpty()) {
+ name = lang;
+ }
pPinOut->SetName(name);
}
@@ -160,18 +170,18 @@ HRESULT CDSMSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
}
pos = m_pFile->m_fim.GetStartPosition();
- while(pos)
- {
- CStringA key; CStringW value;
+ while(pos) {
+ CStringA key;
+ CStringW value;
m_pFile->m_fim.GetNextAssoc(pos, key, value);
SetProperty(CStringW(key), value);
}
- for(int i = 0; i < m_resources.GetCount(); i++)
- {
+ for(int i = 0; i < m_resources.GetCount(); i++) {
const CDSMResource& r = m_resources[i];
- if(r.mime == "application/x-truetype-font")
+ if(r.mime == "application/x-truetype-font") {
m_fontinst.InstallFont(r.data);
+ }
}
return m_pOutputs.GetCount() > 0 ? S_OK : E_FAIL;
@@ -192,23 +202,20 @@ bool CDSMSplitterFilter::DemuxLoop()
{
HRESULT hr = S_OK;
- while(SUCCEEDED(hr) && !CheckRequest(NULL) && m_pFile->GetRemaining())
- {
+ while(SUCCEEDED(hr) && !CheckRequest(NULL) && m_pFile->GetRemaining()) {
dsmp_t type;
UINT64 len;
- if(!m_pFile->Sync(type, len))
+ if(!m_pFile->Sync(type, len)) {
continue;
+ }
__int64 pos = m_pFile->GetPos();
- if(type == DSMP_SAMPLE)
- {
+ if(type == DSMP_SAMPLE) {
CAutoPtr<Packet> p(DNew Packet());
- if(m_pFile->Read(len, p))
- {
- if(p->rtStart != Packet::INVALID_TIME)
- {
+ if(m_pFile->Read(len, p)) {
+ if(p->rtStart != Packet::INVALID_TIME) {
p->rtStart -= m_pFile->m_rtFirst;
p->rtStop -= m_pFile->m_rtFirst;
}
@@ -238,11 +245,14 @@ STDMETHODIMP CDSMSplitterFilter::GetKeyFrames(const GUID* pFormat, REFERENCE_TIM
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++)
+ for(nKFs = 0; nKFs < m_pFile->m_sps.GetCount(); nKFs++) {
pKFs[nKFs] = m_pFile->m_sps[nKFs].rt;
+ }
return S_OK;
}
diff --git a/src/filters/parser/DSMSplitter/DSMSplitter.h b/src/filters/parser/DSMSplitter/DSMSplitter.h
index ef57df9a3..616d84b0d 100644
--- a/src/filters/parser/DSMSplitter/DSMSplitter.h
+++ b/src/filters/parser/DSMSplitter/DSMSplitter.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -27,7 +27,7 @@
#include "../BaseSplitter/BaseSplitter.h"
class __declspec(uuid("0912B4DD-A30A-4568-B590-7179EBB420EC"))
-CDSMSplitterFilter : public CBaseSplitterFilter
+ CDSMSplitterFilter : public CBaseSplitterFilter
{
protected:
CAutoPtr<CDSMSplitterFile> m_pFile;
@@ -48,7 +48,7 @@ public:
};
class __declspec(uuid("803E8280-F3CE-4201-982C-8CD8FB512004"))
-CDSMSourceFilter : public CDSMSplitterFilter
+ CDSMSourceFilter : public CDSMSplitterFilter
{
public:
CDSMSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
diff --git a/src/filters/parser/DSMSplitter/DSMSplitterFile.cpp b/src/filters/parser/DSMSplitter/DSMSplitterFile.cpp
index cb58bd929..b46bc4cd2 100644
--- a/src/filters/parser/DSMSplitter/DSMSplitterFile.cpp
+++ b/src/filters/parser/DSMSplitter/DSMSplitterFile.cpp
@@ -3,12 +3,14 @@
#include "../../../DSUtil/DSUtil.h"
#include <moreuuids.h>
-CDSMSplitterFile::CDSMSplitterFile(IAsyncReader* pReader, HRESULT& hr, IDSMResourceBagImpl& res, IDSMChapterBagImpl& chap)
+CDSMSplitterFile::CDSMSplitterFile(IAsyncReader* pReader, HRESULT& hr, IDSMResourceBagImpl& res, IDSMChapterBagImpl& chap)
: 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);
}
@@ -17,8 +19,9 @@ HRESULT CDSMSplitterFile::Init(IDSMResourceBagImpl& res, IDSMChapterBagImpl& cha
{
Seek(0);
- if(BitRead(DSMSW_SIZE<<3) != DSMSW || BitRead(5) != DSMP_FILEINFO)
+ if(BitRead(DSMSW_SIZE<<3) != DSMSW || BitRead(5) != DSMP_FILEINFO) {
return E_FAIL;
+ }
Seek(0);
@@ -35,68 +38,72 @@ HRESULT CDSMSplitterFile::Init(IDSMResourceBagImpl& res, IDSMChapterBagImpl& cha
// examine the beginning of the file ...
- while(Sync(type, len, 0))
- {
+ while(Sync(type, len, 0)) {
__int64 pos = GetPos();
- if(type == DSMP_MEDIATYPE)
- {
+ if(type == DSMP_MEDIATYPE) {
BYTE id;
CMediaType mt;
- if(Read(len, id, mt)) m_mts[id] = mt;
- }
- else if(type == DSMP_SAMPLE)
- {
+ 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)
- {
+ 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);
}
- 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)
+ if(type != DSMP_SAMPLE) {
return E_FAIL;
+ }
- // ... and the end
+ // ... 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();
+ 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);
+ }
- 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;
- }
+ Seek(pos + len);
}
- 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)
- {
+ if(m_rtFirst < 0) {
m_rtDuration += m_rtFirst;
m_rtFirst = 0;
}
@@ -116,10 +123,10 @@ bool CDSMSplitterFile::Sync(UINT64& syncpos, dsmp_t& type, UINT64& len, __int64
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)
+ 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);
@@ -140,14 +147,20 @@ bool CDSMSplitterFile::Read(__int64 len, BYTE& id, CMediaType& mt)
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();
+ 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;
+ if(!p) {
+ return false;
+ }
p->TrackNumber = (DWORD)BitRead(8);
p->bSyncPoint = (BOOL)BitRead(1);
@@ -155,21 +168,17 @@ bool CDSMSplitterFile::Read(__int64 len, Packet* p, bool fData)
int iTimeStamp = (int)BitRead(3);
int iDuration = (int)BitRead(3);
- if(fSign && !iTimeStamp)
- {
+ if(fSign && !iTimeStamp) {
ASSERT(!iDuration);
p->rtStart = Packet::INVALID_TIME;
p->rtStop = Packet::INVALID_TIME + 1;
- }
- else
- {
+ } 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));
+ if(fData) {
+ p->SetCount((INT_PTR)len - (2 + iTimeStamp + iDuration));
ByteRead(p->GetData(), p->GetCount());
}
@@ -181,8 +190,7 @@ bool CDSMSplitterFile::Read(__int64 len, CAtlArray<SyncPoint>& sps)
SyncPoint sp = {0, 0};
sps.RemoveAll();
- while(len > 0)
- {
+ while(len > 0) {
bool fSign = !!BitRead(1);
int iTimeStamp = (int)BitRead(3);
int iFilePos = (int)BitRead(3);
@@ -195,8 +203,7 @@ bool CDSMSplitterFile::Read(__int64 len, CAtlArray<SyncPoint>& sps)
len -= 1 + iTimeStamp + iFilePos;
}
- if(len != 0)
- {
+ if(len != 0) {
sps.RemoveAll();
return false;
}
@@ -208,8 +215,7 @@ bool CDSMSplitterFile::Read(__int64 len, CAtlArray<SyncPoint>& sps)
bool CDSMSplitterFile::Read(__int64 len, CStreamInfoMap& im)
{
- while(len >= 5)
- {
+ while(len >= 5) {
CStringA key;
ByteRead((BYTE*)key.GetBufferSetLength(4), 4);
len -= 4;
@@ -231,7 +237,9 @@ bool CDSMSplitterFile::Read(__int64 len, IDSMResourceBagImpl& res)
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(len);
ByteRead(r.data.GetData(), r.data.GetCount());
@@ -245,8 +253,7 @@ bool CDSMSplitterFile::Read(__int64 len, IDSMChapterBagImpl& chap)
{
CDSMChapter c(0, L"");
- while(len > 0)
- {
+ while(len > 0) {
bool fSign = !!BitRead(1);
int iTimeStamp = (int)BitRead(3);
BitRead(4); // reserved
@@ -269,21 +276,23 @@ __int64 CDSMSplitterFile::Read(__int64 len, CStringW& str)
char c;
CStringA s;
__int64 i = 0;
- while(i++ < len && (c = (char)BitRead(8)) != 0) s += c;
+ 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)
- {
+ if(/*!m_sps.IsEmpty()*/ m_sps.GetCount() > 1) {
int i = range_bsearch(m_sps, m_rtFirst + rt);
return i >= 0 ? m_sps[i].fp : 0;
}
- if(m_rtDuration <= 0 || rt <= m_rtFirst)
+ if(m_rtDuration <= 0 || rt <= m_rtFirst) {
return 0;
+ }
// ok, do the hard way then
@@ -294,25 +303,25 @@ __int64 CDSMSplitterFile::FindSyncPoint(REFERENCE_TIME rt)
__int64 minpos = 0, maxpos = GetLength();
- for(int i = 0; i < 10 && (maxpos - minpos) >= 1024*1024; i++)
- {
+ for(int i = 0; i < 10 && (maxpos - minpos) >= 1024*1024; i++) {
Seek((minpos + maxpos) / 2);
- while(GetPos() < maxpos)
- {
- if(!Sync(syncpos, type, len))
+ while(GetPos() < maxpos) {
+ if(!Sync(syncpos, type, len)) {
continue;
+ }
__int64 pos = GetPos();
- if(type == DSMP_SAMPLE)
- {
+ if(type == DSMP_SAMPLE) {
Packet p;
- if(Read(len, &p, false) && p.rtStart != Packet::INVALID_TIME)
- {
+ 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;
+ if(dt >= 0) {
+ maxpos = max((__int64)syncpos - 65536, minpos);
+ } else {
+ minpos = syncpos;
+ }
break;
}
}
@@ -325,20 +334,21 @@ __int64 CDSMSplitterFile::FindSyncPoint(REFERENCE_TIME rt)
Seek(minpos);
- while(GetRemaining())
- {
- if(!Sync(syncpos, type, len))
+ while(GetRemaining()) {
+ if(!Sync(syncpos, type, len)) {
continue;
+ }
__int64 pos = GetPos();
- if(type == DSMP_SAMPLE)
- {
+ if(type == DSMP_SAMPLE) {
Packet p;
- if(Read(len, &p, false) && p.rtStart != Packet::INVALID_TIME)
- {
+ 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;}
+ if(dt >= 0) {
+ maxpos = (__int64)syncpos;
+ break;
+ }
}
}
@@ -351,40 +361,35 @@ __int64 CDSMSplitterFile::FindSyncPoint(REFERENCE_TIME rt)
{
POSITION pos = m_mts.GetStartPosition();
- while(pos)
- {
+ while(pos) {
BYTE id;
CMediaType mt;
m_mts.GetNextAssoc(pos, id, mt);
- if(mt.majortype != MEDIATYPE_Text && mt.majortype != MEDIATYPE_Subtitle)
+ if(mt.majortype != MEDIATYPE_Text && mt.majortype != MEDIATYPE_Subtitle) {
ids[id] = 0;
+ }
}
}
__int64 ret = maxpos;
- while(maxpos > 0 && !ids.IsEmpty())
- {
+ while(maxpos > 0 && !ids.IsEmpty()) {
minpos = max(0, maxpos - 65536);
Seek(minpos);
- while(Sync(syncpos, type, len) && GetPos() < maxpos)
- {
+ while(Sync(syncpos, type, len) && GetPos() < maxpos) {
UINT64 pos = GetPos();
- if(type == DSMP_SAMPLE)
- {
+ if(type == DSMP_SAMPLE) {
Packet p;
- if(Read(len, &p, false) && p.rtStart != Packet::INVALID_TIME && p.bSyncPoint)
- {
+ if(Read(len, &p, false) && p.rtStart != Packet::INVALID_TIME && p.bSyncPoint) {
BYTE id = (BYTE)p.TrackNumber, tmp;
- if(ids.Lookup(id, tmp))
- {
+ if(ids.Lookup(id, tmp)) {
ids.RemoveKey((BYTE)p.TrackNumber);
ret = min(ret, (__int64)syncpos);
}
- }
+ }
}
Seek(pos + len);
diff --git a/src/filters/parser/DSMSplitter/DSMSplitterFile.h b/src/filters/parser/DSMSplitter/DSMSplitterFile.h
index 7c350db2f..b61e5e1b7 100644
--- a/src/filters/parser/DSMSplitter/DSMSplitterFile.h
+++ b/src/filters/parser/DSMSplitter/DSMSplitterFile.h
@@ -14,7 +14,10 @@ public:
CAtlMap<BYTE, CMediaType> m_mts;
REFERENCE_TIME m_rtFirst, m_rtDuration;
- struct SyncPoint {REFERENCE_TIME rt; __int64 fp;};
+ struct SyncPoint {
+ REFERENCE_TIME rt;
+ __int64 fp;
+ };
CAtlArray<SyncPoint> m_sps;
typedef CAtlMap<CStringA, CStringW, CStringElementTraits<CStringA>, CStringElementTraits<CStringW> > CStreamInfoMap;
@@ -30,6 +33,6 @@ public:
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/DSMSplitter/stdafx.cpp b/src/filters/parser/DSMSplitter/stdafx.cpp
index 13934d005..bea3f980a 100644
--- a/src/filters/parser/DSMSplitter/stdafx.cpp
+++ b/src/filters/parser/DSMSplitter/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/parser/DSMSplitter/stdafx.h b/src/filters/parser/DSMSplitter/stdafx.h
index cdc946aa0..9b252ac14 100644
--- a/src/filters/parser/DSMSplitter/stdafx.h
+++ b/src/filters/parser/DSMSplitter/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/parser/DiracSplitter/DiracSplitter.cpp b/src/filters/parser/DiracSplitter/DiracSplitter.cpp
index 1d5a483dc..815de3f8e 100644
--- a/src/filters/parser/DiracSplitter/DiracSplitter.cpp
+++ b/src/filters/parser/DiracSplitter/DiracSplitter.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2004 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -27,66 +27,59 @@
#ifdef REGISTER_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
-{
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_Dirac},
- {&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL}
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
+ {&MEDIATYPE_Stream, &MEDIASUBTYPE_Dirac},
+ {&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}
+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}
};
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn2[] =
-{
- {&MEDIATYPE_Video, &MEDIASUBTYPE_DiracVideo},
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn2[] = {
+ {&MEDIATYPE_Video, &MEDIASUBTYPE_DiracVideo},
};
-const AMOVIESETUP_MEDIATYPE sudPinTypesOut2[] =
-{
- {&MEDIATYPE_Video, &MEDIASUBTYPE_NULL},
+const AMOVIESETUP_MEDIATYPE sudPinTypesOut2[] = {
+ {&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}
+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}
};
-const AMOVIESETUP_FILTER sudFilter[] =
-{
- {&__uuidof(CDiracSplitterFilter), L"MPC - Dirac Splitter", MERIT_NORMAL, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
- {&__uuidof(CDiracSourceFilter), L"MPC - Dirac Source", MERIT_NORMAL, 0, NULL, CLSID_LegacyAmFilterCategory},
- {&__uuidof(CDiracVideoDecoder), L"MPC - Dirac Video Decoder", MERIT_UNLIKELY, countof(sudpPins2), sudpPins2, CLSID_LegacyAmFilterCategory},
+const AMOVIESETUP_FILTER sudFilter[] = {
+ {&__uuidof(CDiracSplitterFilter), L"MPC - Dirac Splitter", MERIT_NORMAL, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
+ {&__uuidof(CDiracSourceFilter), L"MPC - Dirac Source", MERIT_NORMAL, 0, NULL, CLSID_LegacyAmFilterCategory},
+ {&__uuidof(CDiracVideoDecoder), L"MPC - Dirac Video Decoder", MERIT_UNLIKELY, countof(sudpPins2), sudpPins2, CLSID_LegacyAmFilterCategory},
};
-CFactoryTemplate g_Templates[] =
-{
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CDiracSplitterFilter>, NULL, &sudFilter[0]},
- {sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CDiracSourceFilter>, NULL, &sudFilter[1]},
- {sudFilter[2].strName, sudFilter[2].clsID, CreateInstance<CDiracVideoDecoder>, NULL, &sudFilter[2]},
+CFactoryTemplate g_Templates[] = {
+ {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CDiracSplitterFilter>, NULL, &sudFilter[0]},
+ {sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CDiracSourceFilter>, NULL, &sudFilter[1]},
+ {sudFilter[2].strName, sudFilter[2].clsID, CreateInstance<CDiracVideoDecoder>, NULL, &sudFilter[2]},
};
int g_cTemplates = countof(g_Templates);
STDAPI DllRegisterServer()
{
- RegisterSourceFilter(
- CLSID_AsyncReader,
- MEDIASUBTYPE_Dirac,
- _T("0,8,,4B572D4449524143"), // KW-DIRAC
- _T(".drc"), NULL);
+ RegisterSourceFilter(
+ CLSID_AsyncReader,
+ MEDIASUBTYPE_Dirac,
+ _T("0,8,,4B572D4449524143"), // KW-DIRAC
+ _T(".drc"), NULL);
- return AMovieDllRegisterServer2(TRUE);
+ return AMovieDllRegisterServer2(TRUE);
}
STDAPI DllUnregisterServer()
{
- UnRegisterSourceFilter(MEDIASUBTYPE_Dirac);
+ UnRegisterSourceFilter(MEDIASUBTYPE_Dirac);
- return AMovieDllRegisterServer2(FALSE);
+ return AMovieDllRegisterServer2(FALSE);
}
#include "../../FilterApp.h"
@@ -99,134 +92,144 @@ CFilterApp theApp;
//
CDiracSplitterFilter::CDiracSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CBaseSplitterFilter(NAME("CDiracSplitterFilter"), pUnk, phr, __uuidof(this))
+ : CBaseSplitterFilter(NAME("CDiracSplitterFilter"), pUnk, phr, __uuidof(this))
{
}
STDMETHODIMP CDiracSplitterFilter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- return
- __super::NonDelegatingQueryInterface(riid, ppv);
+ return
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
HRESULT CDiracSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
{
- CheckPointer(pAsyncReader, E_POINTER);
+ CheckPointer(pAsyncReader, E_POINTER);
- HRESULT hr = E_FAIL;
+ HRESULT hr = E_FAIL;
- m_pFile.Free();
+ m_pFile.Free();
- m_pFile.Attach(DNew CDiracSplitterFile(pAsyncReader, hr));
- if(!m_pFile) return E_OUTOFMEMORY;
- if(FAILED(hr)) {m_pFile.Free(); return hr;}
+ m_pFile.Attach(DNew CDiracSplitterFile(pAsyncReader, hr));
+ if(!m_pFile) {
+ return E_OUTOFMEMORY;
+ }
+ if(FAILED(hr)) {
+ m_pFile.Free();
+ return hr;
+ }
- CAtlArray<CMediaType> mts;
- mts.Add(m_pFile->GetMediaType());
+ CAtlArray<CMediaType> mts;
+ mts.Add(m_pFile->GetMediaType());
- CAutoPtr<CBaseSplitterOutputPin> pPinOut(DNew CBaseSplitterOutputPin(mts, L"Video", this, this, &hr));
- AddOutputPin(0, pPinOut);
+ CAutoPtr<CBaseSplitterOutputPin> pPinOut(DNew CBaseSplitterOutputPin(mts, L"Video", this, this, &hr));
+ AddOutputPin(0, pPinOut);
- m_rtNewStart = m_rtCurrent = 0;
- m_rtNewStop = m_rtStop = m_rtDuration = m_pFile->GetDuration();
+ m_rtNewStart = m_rtCurrent = 0;
+ m_rtNewStop = m_rtStop = m_rtDuration = m_pFile->GetDuration();
- return m_pOutputs.GetCount() > 0 ? S_OK : E_FAIL;
+ return m_pOutputs.GetCount() > 0 ? S_OK : E_FAIL;
}
bool CDiracSplitterFilter::DemuxInit()
{
SetThreadName((DWORD)-1, "CDiracSplitterFilter");
- if(!m_pFile) return(false);
+ if(!m_pFile) {
+ return(false);
+ }
- // TODO
+ // TODO
- return(true);
+ return(true);
}
void CDiracSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
{
- REFERENCE_TIME rtPreroll = 0; //10000000;
+ REFERENCE_TIME rtPreroll = 0; //10000000;
- if(rt <= rtPreroll || m_rtDuration <= 0)
- {
- //m_pFile->Seek(8);
- m_pFile->Seek(0);
- }
- else
- {
- // TODO
+ if(rt <= rtPreroll || m_rtDuration <= 0) {
+ //m_pFile->Seek(8);
+ m_pFile->Seek(0);
+ } else {
+ // TODO
- __int64 len = m_pFile->GetLength();
- __int64 seekpos = (__int64)(1.0*rt/m_rtDuration*len);
+ __int64 len = m_pFile->GetLength();
+ __int64 seekpos = (__int64)(1.0*rt/m_rtDuration*len);
- m_pFile->Seek(seekpos);
- seekpos = 0;
+ m_pFile->Seek(seekpos);
+ seekpos = 0;
- REFERENCE_TIME rtmax = rt - rtPreroll;
- REFERENCE_TIME rtmin = rtmax - 5000000;
+ REFERENCE_TIME rtmax = rt - rtPreroll;
+ REFERENCE_TIME rtmin = rtmax - 5000000;
- REFERENCE_TIME pdt = _I64_MIN;
+ REFERENCE_TIME pdt = _I64_MIN;
- BYTE code;
- for(int j = 0; j < 10; j++)
- {
- while(m_pFile->Next(code) && code != AU_START_CODE);
- if(code != AU_START_CODE) {m_pFile->Seek(seekpos >>= 1); continue;}
+ BYTE code;
+ for(int j = 0; j < 10; j++) {
+ while(m_pFile->Next(code) && code != AU_START_CODE) {
+ ;
+ }
+ if(code != AU_START_CODE) {
+ m_pFile->Seek(seekpos >>= 1);
+ continue;
+ }
- __int64 pos = m_pFile->GetPos() - 5;
+ __int64 pos = m_pFile->GetPos() - 5;
- REFERENCE_TIME rt = ((DIRACINFOHEADER*)m_pFile->GetMediaType().Format())->hdr.AvgTimePerFrame * m_pFile->UnsignedGolombDecode();
- REFERENCE_TIME dt = rt - rtmax;
- if(dt > 0 && dt == pdt) dt = 10000000i64;
+ REFERENCE_TIME rt = ((DIRACINFOHEADER*)m_pFile->GetMediaType().Format())->hdr.AvgTimePerFrame * m_pFile->UnsignedGolombDecode();
+ REFERENCE_TIME dt = rt - rtmax;
+ if(dt > 0 && dt == pdt) {
+ dt = 10000000i64;
+ }
- if(rtmin <= rt && rt <= rtmax || pdt > 0 && dt < 0)
- {
- seekpos = pos;
- break;
- }
+ if(rtmin <= rt && rt <= rtmax || pdt > 0 && dt < 0) {
+ seekpos = pos;
+ break;
+ }
- m_pFile->Seek(pos - (__int64)(1.0*dt/m_rtDuration*len));
+ m_pFile->Seek(pos - (__int64)(1.0*dt/m_rtDuration*len));
- pdt = dt;
- }
+ pdt = dt;
+ }
- m_pFile->Seek(seekpos);
- }
+ m_pFile->Seek(seekpos);
+ }
}
bool CDiracSplitterFilter::DemuxLoop()
{
- HRESULT hr = S_OK;
- REFERENCE_TIME rtAvgTimePerFrame = ((DIRACINFOHEADER*)m_pFile->GetMediaType().Format())->hdr.AvgTimePerFrame;
-
- BYTE code;
- while(SUCCEEDED(hr) && !CheckRequest(NULL))
- {
- int size = 0, fnum = 0;
- const BYTE* pBuff = m_pFile->NextBlock(code, size, fnum);
- if(!pBuff || size < 5) break;
-
- if(isFrameStartCode(code))
- {
- CAutoPtr<Packet> p(DNew Packet());
- p->SetCount(size);
- memcpy(p->GetData(), pBuff, size);
-
- p->TrackNumber = 0;
- p->rtStart = rtAvgTimePerFrame*fnum;
- p->rtStop = p->rtStart + rtAvgTimePerFrame;
- p->bSyncPoint = code == AU_START_CODE;
-
- hr = DeliverPacket(p);
- }
-
- if(code == SEQ_END_CODE)
- break;
- }
-
- return(true);
+ HRESULT hr = S_OK;
+ REFERENCE_TIME rtAvgTimePerFrame = ((DIRACINFOHEADER*)m_pFile->GetMediaType().Format())->hdr.AvgTimePerFrame;
+
+ BYTE code;
+ while(SUCCEEDED(hr) && !CheckRequest(NULL)) {
+ int size = 0, fnum = 0;
+ const BYTE* pBuff = m_pFile->NextBlock(code, size, fnum);
+ if(!pBuff || size < 5) {
+ break;
+ }
+
+ if(isFrameStartCode(code)) {
+ CAutoPtr<Packet> p(DNew Packet());
+ p->SetCount(size);
+ memcpy(p->GetData(), pBuff, size);
+
+ p->TrackNumber = 0;
+ p->rtStart = rtAvgTimePerFrame*fnum;
+ p->rtStop = p->rtStart + rtAvgTimePerFrame;
+ p->bSyncPoint = code == AU_START_CODE;
+
+ hr = DeliverPacket(p);
+ }
+
+ if(code == SEQ_END_CODE) {
+ break;
+ }
+ }
+
+ return(true);
}
//
@@ -234,10 +237,10 @@ bool CDiracSplitterFilter::DemuxLoop()
//
CDiracSourceFilter::CDiracSourceFilter(LPUNKNOWN pUnk, HRESULT* phr)
- : CDiracSplitterFilter(pUnk, phr)
+ : CDiracSplitterFilter(pUnk, phr)
{
- m_clsid = __uuidof(this);
- m_pInput.Free();
+ m_clsid = __uuidof(this);
+ m_pInput.Free();
}
//
@@ -245,365 +248,382 @@ CDiracSourceFilter::CDiracSourceFilter(LPUNKNOWN pUnk, HRESULT* phr)
//
CDiracVideoDecoder::CDiracVideoDecoder(LPUNKNOWN lpunk, HRESULT* phr)
- : CTransformFilter(NAME("CDiracVideoDecoder"), lpunk, __uuidof(this))
+ : CTransformFilter(NAME("CDiracVideoDecoder"), lpunk, __uuidof(this))
{
- if(phr) *phr = S_OK;
+ if(phr) {
+ *phr = S_OK;
+ }
- m_decoder = NULL;
- m_pYUV[0] = NULL;
+ m_decoder = NULL;
+ m_pYUV[0] = NULL;
}
CDiracVideoDecoder::~CDiracVideoDecoder()
{
- delete [] m_pYUV[0];
+ delete [] m_pYUV[0];
}
void CDiracVideoDecoder::InitDecoder()
{
- FreeDecoder();
+ FreeDecoder();
- dirac_decoder_t* decoder = dirac_decoder_init(0);
+ dirac_decoder_t* decoder = dirac_decoder_init(0);
- DIRACINFOHEADER* dvih = (DIRACINFOHEADER*)m_pInput->CurrentMediaType().Format();
- dirac_buffer(decoder, (BYTE*)&dvih->dwSequenceHeader[0], (BYTE*)&dvih->dwSequenceHeader[0] + dvih->cbSequenceHeader);
+ DIRACINFOHEADER* dvih = (DIRACINFOHEADER*)m_pInput->CurrentMediaType().Format();
+ dirac_buffer(decoder, (BYTE*)&dvih->dwSequenceHeader[0], (BYTE*)&dvih->dwSequenceHeader[0] + dvih->cbSequenceHeader);
- m_decoder = decoder;
+ m_decoder = decoder;
}
void CDiracVideoDecoder::FreeDecoder()
{
- if(m_decoder)
- {
- dirac_decoder_close((dirac_decoder_t*)m_decoder);
- m_decoder = NULL;
- delete [] m_pYUV[0]; m_pYUV[0] = NULL;
- }
+ if(m_decoder) {
+ dirac_decoder_close((dirac_decoder_t*)m_decoder);
+ m_decoder = NULL;
+ delete [] m_pYUV[0];
+ m_pYUV[0] = NULL;
+ }
}
HRESULT CDiracVideoDecoder::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;
-
- long len = pIn->GetActualDataLength();
- if(len <= 0) return S_OK; // nothing to do
-
- if(pIn->IsDiscontinuity() == S_OK)
- InitDecoder();
-
- dirac_decoder_t* decoder = (dirac_decoder_t*)m_decoder;
-
- hr = S_OK;
- while(SUCCEEDED(hr))
- {
- switch(dirac_parse(decoder))
- {
- case STATE_BUFFER:
- if(len == 0) return S_OK;
- dirac_buffer(decoder, pDataIn, pDataIn + len);
- len = 0;
- break;
-
- case STATE_SEQUENCE:
- TRACE(_T("STATE_SEQUENCE\n"));
-
- {
- DIRACINFOHEADER* dvih = (DIRACINFOHEADER*)m_pInput->CurrentMediaType().Format();
- if(dvih->hdr.bmiHeader.biWidth != decoder->src_params.width
- || dvih->hdr.bmiHeader.biHeight != decoder->src_params.height)
- return E_FAIL; // hmm
- }
-
- if(!m_pYUV[0])
- {
- int w = decoder->src_params.width;
- int h = decoder->src_params.height;
- int wc = decoder->src_params.chroma_width;
- int hc = decoder->src_params.chroma_height;
- delete [] m_pYUV[0]; m_pYUV[0] = NULL;
- m_pYUV[0] = DNew BYTE[w*h + wc*hc*2 + w/2*h/2];
- m_pYUV[1] = m_pYUV[0] + w*h;
- m_pYUV[2] = m_pYUV[1] + wc*hc;
- m_pYUV[3] = m_pYUV[2] + wc*hc;
- memset(m_pYUV[3], 0x80, w/2*h/2);
- m_rtAvgTimePerFrame = 10000000i64 * decoder->src_params.frame_rate.denominator / decoder->src_params.frame_rate.numerator;
- dirac_set_buf(decoder, m_pYUV, NULL);
- }
-
- break;
-
- case STATE_SEQUENCE_END:
- TRACE(_T("STATE_SEQUENCE_END\n"));
- break;
-
- case STATE_INVALID:
- TRACE(_T("STATE_INVALID\n"));
- return E_FAIL; // TODO: can we recover from this state?
- // break;
-
- default:
- TRACE(_T("unknown state\n"));
- continue;
- }
- }
-
- return hr;
+ 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;
+ }
+
+ long len = pIn->GetActualDataLength();
+ if(len <= 0) {
+ return S_OK; // nothing to do
+ }
+
+ if(pIn->IsDiscontinuity() == S_OK) {
+ InitDecoder();
+ }
+
+ dirac_decoder_t* decoder = (dirac_decoder_t*)m_decoder;
+
+ hr = S_OK;
+ while(SUCCEEDED(hr)) {
+ switch(dirac_parse(decoder)) {
+ case STATE_BUFFER:
+ if(len == 0) {
+ return S_OK;
+ }
+ dirac_buffer(decoder, pDataIn, pDataIn + len);
+ len = 0;
+ break;
+
+ case STATE_SEQUENCE:
+ TRACE(_T("STATE_SEQUENCE\n"));
+
+ {
+ DIRACINFOHEADER* dvih = (DIRACINFOHEADER*)m_pInput->CurrentMediaType().Format();
+ if(dvih->hdr.bmiHeader.biWidth != decoder->src_params.width
+ || dvih->hdr.bmiHeader.biHeight != decoder->src_params.height) {
+ return E_FAIL; // hmm
+ }
+ }
+
+ if(!m_pYUV[0]) {
+ int w = decoder->src_params.width;
+ int h = decoder->src_params.height;
+ int wc = decoder->src_params.chroma_width;
+ int hc = decoder->src_params.chroma_height;
+ delete [] m_pYUV[0];
+ m_pYUV[0] = NULL;
+ m_pYUV[0] = DNew BYTE[w*h + wc*hc*2 + w/2*h/2];
+ m_pYUV[1] = m_pYUV[0] + w*h;
+ m_pYUV[2] = m_pYUV[1] + wc*hc;
+ m_pYUV[3] = m_pYUV[2] + wc*hc;
+ memset(m_pYUV[3], 0x80, w/2*h/2);
+ m_rtAvgTimePerFrame = 10000000i64 * decoder->src_params.frame_rate.denominator / decoder->src_params.frame_rate.numerator;
+ dirac_set_buf(decoder, m_pYUV, NULL);
+ }
+
+ break;
+
+ case STATE_SEQUENCE_END:
+ TRACE(_T("STATE_SEQUENCE_END\n"));
+ break;
+
+ case STATE_INVALID:
+ TRACE(_T("STATE_INVALID\n"));
+ return E_FAIL; // TODO: can we recover from this state?
+ // break;
+
+ default:
+ TRACE(_T("unknown state\n"));
+ continue;
+ }
+ }
+
+ return hr;
}
HRESULT CDiracVideoDecoder::Deliver(IMediaSample* pIn, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop)
{
- CheckPointer(pIn, E_POINTER);
+ CheckPointer(pIn, E_POINTER);
- HRESULT hr;
+ HRESULT hr;
- if(pIn->IsPreroll() == S_OK || rtStart < 0)
- return S_OK;
+ if(pIn->IsPreroll() == S_OK || rtStart < 0) {
+ return S_OK;
+ }
- CComPtr<IMediaSample> pOut;
- BYTE* pDataOut = NULL;
- if(FAILED(hr = m_pOutput->GetDeliveryBuffer(&pOut, NULL, NULL, 0))
- || FAILED(hr = pOut->GetPointer(&pDataOut)))
- return hr;
+ 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);
- }
+ AM_MEDIA_TYPE* pmt;
+ if(SUCCEEDED(pOut->GetMediaType(&pmt)) && pmt) {
+ CMediaType mt(*pmt);
+ m_pOutput->SetMediaType(&mt);
+ DeleteMediaType(pmt);
+ }
- TRACE(_T("CDiracVideoDecoder::Deliver(%I64d, %I64d)\n"), rtStart, rtStop);
+ TRACE(_T("CDiracVideoDecoder::Deliver(%I64d, %I64d)\n"), rtStart, rtStop);
- pOut->SetTime(&rtStart, &rtStop);
- pOut->SetMediaTime(NULL, NULL);
+ pOut->SetTime(&rtStart, &rtStop);
+ pOut->SetMediaTime(NULL, NULL);
- pOut->SetDiscontinuity(pIn->IsDiscontinuity() == S_OK);
- pOut->SetSyncPoint(TRUE);
+ pOut->SetDiscontinuity(pIn->IsDiscontinuity() == S_OK);
+ pOut->SetSyncPoint(TRUE);
- if(GetCLSID(m_pOutput->GetConnected()) == CLSID_OverlayMixer)
- pOut->SetDiscontinuity(TRUE);
+ if(GetCLSID(m_pOutput->GetConnected()) == CLSID_OverlayMixer) {
+ pOut->SetDiscontinuity(TRUE);
+ }
- Copy(pDataOut);
+ Copy(pDataOut);
- return m_pOutput->Deliver(pOut);
+ return m_pOutput->Deliver(pOut);
}
void CDiracVideoDecoder::Copy(BYTE* pOut)
{
- // FIXME: modes other than I420 and Y-only
-
- BITMAPINFOHEADER bihOut;
- ExtractBIH(&m_pOutput->CurrentMediaType(), &bihOut);
-
- dirac_decoder_t* decoder = (dirac_decoder_t*)m_decoder;
-
- int w = decoder->src_params.width;
- int h = decoder->src_params.height;
- int wc = decoder->src_params.chroma_width;
- int hc = decoder->src_params.chroma_height;
-
- int pitchIn = w;
-
- BYTE* pY = m_pYUV[0];
- BYTE* pU = w/2 == wc && h/2 == hc ? m_pYUV[1] : m_pYUV[3]; // FIXME
- BYTE* pV = w/2 == wc && h/2 == hc ? m_pYUV[2] : m_pYUV[3]; // FIXME
-
- if(bihOut.biCompression == '2YUY')
- {
- BitBltFromI420ToYUY2(w, h, pOut, bihOut.biWidth*2, pY, pU, pV, pitchIn);
- }
- else if(bihOut.biCompression == 'I420' || bihOut.biCompression == 'VUYI')
- {
- BitBltFromI420ToI420(w, h, pOut, pOut + bihOut.biWidth*h, pOut + bihOut.biWidth*h*5/4, bihOut.biWidth, pY, pU, pV, pitchIn);
- }
- else if(bihOut.biCompression == '21VY')
- {
- BitBltFromI420ToI420(w, h, pOut, pOut + bihOut.biWidth*h*5/4, pOut + bihOut.biWidth*h, bihOut.biWidth, pY, pU, pV, pitchIn);
- }
- else if(bihOut.biCompression == BI_RGB || bihOut.biCompression == BI_BITFIELDS)
- {
- int pitchOut = bihOut.biWidth*bihOut.biBitCount>>3;
-
- if(bihOut.biHeight > 0)
- {
- pOut += pitchOut*(h-1);
- pitchOut = -pitchOut;
- }
-
- if(!BitBltFromI420ToRGB(w, h, pOut, pitchOut, bihOut.biBitCount, pY, pU, pV, pitchIn))
- {
- for(DWORD y = 0; y < h; y++, pOut += pitchOut)
- memset(pOut, 0, pitchOut);
- }
- }
+ // FIXME: modes other than I420 and Y-only
+
+ BITMAPINFOHEADER bihOut;
+ ExtractBIH(&m_pOutput->CurrentMediaType(), &bihOut);
+
+ dirac_decoder_t* decoder = (dirac_decoder_t*)m_decoder;
+
+ int w = decoder->src_params.width;
+ int h = decoder->src_params.height;
+ int wc = decoder->src_params.chroma_width;
+ int hc = decoder->src_params.chroma_height;
+
+ int pitchIn = w;
+
+ BYTE* pY = m_pYUV[0];
+ BYTE* pU = w/2 == wc && h/2 == hc ? m_pYUV[1] : m_pYUV[3]; // FIXME
+ BYTE* pV = w/2 == wc && h/2 == hc ? m_pYUV[2] : m_pYUV[3]; // FIXME
+
+ if(bihOut.biCompression == '2YUY') {
+ BitBltFromI420ToYUY2(w, h, pOut, bihOut.biWidth*2, pY, pU, pV, pitchIn);
+ } else if(bihOut.biCompression == 'I420' || bihOut.biCompression == 'VUYI') {
+ BitBltFromI420ToI420(w, h, pOut, pOut + bihOut.biWidth*h, pOut + bihOut.biWidth*h*5/4, bihOut.biWidth, pY, pU, pV, pitchIn);
+ } else if(bihOut.biCompression == '21VY') {
+ BitBltFromI420ToI420(w, h, pOut, pOut + bihOut.biWidth*h*5/4, pOut + bihOut.biWidth*h, bihOut.biWidth, pY, pU, pV, pitchIn);
+ } else if(bihOut.biCompression == BI_RGB || bihOut.biCompression == BI_BITFIELDS) {
+ int pitchOut = bihOut.biWidth*bihOut.biBitCount>>3;
+
+ if(bihOut.biHeight > 0) {
+ pOut += pitchOut*(h-1);
+ pitchOut = -pitchOut;
+ }
+
+ if(!BitBltFromI420ToRGB(w, h, pOut, pitchOut, bihOut.biBitCount, pY, pU, pV, pitchIn)) {
+ for(DWORD y = 0; y < h; y++, pOut += pitchOut) {
+ memset(pOut, 0, pitchOut);
+ }
+ }
+ }
}
HRESULT CDiracVideoDecoder::CheckInputType(const CMediaType* mtIn)
{
- DIRACINFOHEADER* dvih = (DIRACINFOHEADER*)mtIn->Format();
+ DIRACINFOHEADER* dvih = (DIRACINFOHEADER*)mtIn->Format();
- if(mtIn->majortype != MEDIATYPE_Video
- || mtIn->subtype != MEDIASUBTYPE_DiracVideo
- || mtIn->formattype != FORMAT_DiracVideoInfo
- || (dvih->hdr.bmiHeader.biWidth&1) || (dvih->hdr.bmiHeader.biHeight&1))
- return VFW_E_TYPE_NOT_ACCEPTED;
+ if(mtIn->majortype != MEDIATYPE_Video
+ || mtIn->subtype != MEDIASUBTYPE_DiracVideo
+ || mtIn->formattype != FORMAT_DiracVideoInfo
+ || (dvih->hdr.bmiHeader.biWidth&1) || (dvih->hdr.bmiHeader.biHeight&1)) {
+ return VFW_E_TYPE_NOT_ACCEPTED;
+ }
- return S_OK;
+ return S_OK;
}
HRESULT CDiracVideoDecoder::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 mtIn->majortype == MEDIATYPE_Video && mtIn->subtype == MEDIASUBTYPE_DiracVideo
- && mtOut->majortype == MEDIATYPE_Video && (mtOut->subtype == MEDIASUBTYPE_YUY2
- || mtOut->subtype == MEDIASUBTYPE_YV12
- || mtOut->subtype == MEDIASUBTYPE_I420
- || mtOut->subtype == MEDIASUBTYPE_IYUV
- || mtOut->subtype == MEDIASUBTYPE_ARGB32
- || mtOut->subtype == MEDIASUBTYPE_RGB32
- || mtOut->subtype == MEDIASUBTYPE_RGB24
- || mtOut->subtype == MEDIASUBTYPE_RGB565
- || mtOut->subtype == MEDIASUBTYPE_RGB555)
- ? S_OK
- : VFW_E_TYPE_NOT_ACCEPTED;
+ 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 mtIn->majortype == MEDIATYPE_Video && mtIn->subtype == MEDIASUBTYPE_DiracVideo
+ && mtOut->majortype == MEDIATYPE_Video && (mtOut->subtype == MEDIASUBTYPE_YUY2
+ || mtOut->subtype == MEDIASUBTYPE_YV12
+ || mtOut->subtype == MEDIASUBTYPE_I420
+ || mtOut->subtype == MEDIASUBTYPE_IYUV
+ || mtOut->subtype == MEDIASUBTYPE_ARGB32
+ || mtOut->subtype == MEDIASUBTYPE_RGB32
+ || mtOut->subtype == MEDIASUBTYPE_RGB24
+ || mtOut->subtype == MEDIASUBTYPE_RGB565
+ || mtOut->subtype == MEDIASUBTYPE_RGB555)
+ ? S_OK
+ : VFW_E_TYPE_NOT_ACCEPTED;
}
HRESULT CDiracVideoDecoder::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 CDiracVideoDecoder::GetMediaType(int iPosition, CMediaType* pmt)
{
- if(m_pInput->IsConnected() == FALSE) return E_UNEXPECTED;
-
- struct {const GUID* subtype; WORD biPlanes, biBitCount; DWORD biCompression;} fmts[] =
- {
- {&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},
- };
-
- if(m_pInput->CurrentMediaType().formattype == FORMAT_VideoInfo)
- iPosition = iPosition*2 + 1;
-
- if(iPosition < 0) return E_INVALIDARG;
- if(iPosition >= 2*countof(fmts)) return VFW_S_NO_MORE_ITEMS;
-
- BITMAPINFOHEADER bih;
- ExtractBIH(&m_pInput->CurrentMediaType(), &bih);
-
- pmt->majortype = MEDIATYPE_Video;
- pmt->subtype = *fmts[iPosition/2].subtype;
-
- BITMAPINFOHEADER bihOut;
- memset(&bihOut, 0, sizeof(bihOut));
- bihOut.biSize = sizeof(bihOut);
- bihOut.biWidth = bih.biWidth;
- bihOut.biHeight = bih.biHeight;
- bihOut.biPlanes = fmts[iPosition/2].biPlanes;
- bihOut.biBitCount = fmts[iPosition/2].biBitCount;
- bihOut.biCompression = fmts[iPosition/2].biCompression;
- bihOut.biSizeImage = bih.biWidth*bih.biHeight*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;
-
- if(m_pInput->CurrentMediaType().formattype == FORMAT_VideoInfo2)
- {
- vih->bmiHeader.biWidth = ((VIDEOINFOHEADER2*)m_pInput->CurrentMediaType().Format())->dwPictAspectRatioX;
- vih->bmiHeader.biHeight = ((VIDEOINFOHEADER2*)m_pInput->CurrentMediaType().Format())->dwPictAspectRatioY;
- vih->bmiHeader.biSizeImage = vih->bmiHeader.biWidth*vih->bmiHeader.biHeight*vih->bmiHeader.biBitCount>>3;
- }
- }
- else
- {
- pmt->formattype = FORMAT_VideoInfo2;
- VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*)pmt->AllocFormatBuffer(sizeof(VIDEOINFOHEADER2));
- memset(vih2, 0, sizeof(VIDEOINFOHEADER2));
- vih2->bmiHeader = bihOut;
- vih2->dwPictAspectRatioX = ((VIDEOINFOHEADER2*)m_pInput->CurrentMediaType().Format())->dwPictAspectRatioX;
- vih2->dwPictAspectRatioY = ((VIDEOINFOHEADER2*)m_pInput->CurrentMediaType().Format())->dwPictAspectRatioY;
- }
-
- CorrectMediaType(pmt);
-
- return S_OK;
+ if(m_pInput->IsConnected() == FALSE) {
+ return E_UNEXPECTED;
+ }
+
+ struct {
+ const GUID* subtype;
+ WORD biPlanes, biBitCount;
+ DWORD biCompression;
+ } fmts[] = {
+ {&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},
+ };
+
+ if(m_pInput->CurrentMediaType().formattype == FORMAT_VideoInfo) {
+ iPosition = iPosition*2 + 1;
+ }
+
+ if(iPosition < 0) {
+ return E_INVALIDARG;
+ }
+ if(iPosition >= 2*countof(fmts)) {
+ return VFW_S_NO_MORE_ITEMS;
+ }
+
+ BITMAPINFOHEADER bih;
+ ExtractBIH(&m_pInput->CurrentMediaType(), &bih);
+
+ pmt->majortype = MEDIATYPE_Video;
+ pmt->subtype = *fmts[iPosition/2].subtype;
+
+ BITMAPINFOHEADER bihOut;
+ memset(&bihOut, 0, sizeof(bihOut));
+ bihOut.biSize = sizeof(bihOut);
+ bihOut.biWidth = bih.biWidth;
+ bihOut.biHeight = bih.biHeight;
+ bihOut.biPlanes = fmts[iPosition/2].biPlanes;
+ bihOut.biBitCount = fmts[iPosition/2].biBitCount;
+ bihOut.biCompression = fmts[iPosition/2].biCompression;
+ bihOut.biSizeImage = bih.biWidth*bih.biHeight*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;
+
+ if(m_pInput->CurrentMediaType().formattype == FORMAT_VideoInfo2) {
+ vih->bmiHeader.biWidth = ((VIDEOINFOHEADER2*)m_pInput->CurrentMediaType().Format())->dwPictAspectRatioX;
+ vih->bmiHeader.biHeight = ((VIDEOINFOHEADER2*)m_pInput->CurrentMediaType().Format())->dwPictAspectRatioY;
+ vih->bmiHeader.biSizeImage = vih->bmiHeader.biWidth*vih->bmiHeader.biHeight*vih->bmiHeader.biBitCount>>3;
+ }
+ } else {
+ pmt->formattype = FORMAT_VideoInfo2;
+ VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*)pmt->AllocFormatBuffer(sizeof(VIDEOINFOHEADER2));
+ memset(vih2, 0, sizeof(VIDEOINFOHEADER2));
+ vih2->bmiHeader = bihOut;
+ vih2->dwPictAspectRatioX = ((VIDEOINFOHEADER2*)m_pInput->CurrentMediaType().Format())->dwPictAspectRatioX;
+ vih2->dwPictAspectRatioY = ((VIDEOINFOHEADER2*)m_pInput->CurrentMediaType().Format())->dwPictAspectRatioY;
+ }
+
+ CorrectMediaType(pmt);
+
+ return S_OK;
}
HRESULT CDiracVideoDecoder::StartStreaming()
{
- InitDecoder();
- return __super::StartStreaming();
+ InitDecoder();
+ return __super::StartStreaming();
}
HRESULT CDiracVideoDecoder::StopStreaming()
{
- FreeDecoder();
- return __super::StopStreaming();
+ FreeDecoder();
+ return __super::StopStreaming();
}
HRESULT CDiracVideoDecoder::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
{
- CAutoLock cAutoLock(&m_csReceive);
+ CAutoLock cAutoLock(&m_csReceive);
- m_fDropFrames = false;
- m_tStart = tStart;
+ m_fDropFrames = false;
+ m_tStart = tStart;
- return __super::NewSegment(tStart, tStop, dRate);
+ return __super::NewSegment(tStart, tStop, dRate);
}
HRESULT CDiracVideoDecoder::AlterQuality(Quality q)
{
- if(q.Late > 500*10000i64) m_fDropFrames = true;
- if(q.Late <= 0) m_fDropFrames = false;
- return E_NOTIMPL;
+ if(q.Late > 500*10000i64) {
+ m_fDropFrames = true;
+ }
+ if(q.Late <= 0) {
+ m_fDropFrames = false;
+ }
+ return E_NOTIMPL;
}
diff --git a/src/filters/parser/DiracSplitter/DiracSplitter.h b/src/filters/parser/DiracSplitter/DiracSplitter.h
index d11f1db82..0a083edb0 100644
--- a/src/filters/parser/DiracSplitter/DiracSplitter.h
+++ b/src/filters/parser/DiracSplitter/DiracSplitter.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -25,7 +25,7 @@
#include "DiracSplitterFile.h"
class __declspec(uuid("5899CFB9-948F-4869-A999-5544ECB38BA5"))
-CDiracSplitterFilter : public CBaseSplitterFilter
+ CDiracSplitterFilter : public CBaseSplitterFilter
{
protected:
CAutoPtr<CDiracSplitterFile> m_pFile;
@@ -43,14 +43,14 @@ public:
};
class __declspec(uuid("09E7F58E-71A1-419D-B0A0-E524AE1454A9"))
-CDiracSourceFilter : public CDiracSplitterFilter
+ CDiracSourceFilter : public CDiracSplitterFilter
{
public:
CDiracSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
};
class __declspec(uuid("F78CF248-180E-4713-B107-B13F7B5C31E1"))
-CDiracVideoDecoder : public CTransformFilter
+ CDiracVideoDecoder : public CTransformFilter
{
void* m_decoder; // dirac_decoder_t*
void InitDecoder(), FreeDecoder();
diff --git a/src/filters/parser/DiracSplitter/DiracSplitterFile.cpp b/src/filters/parser/DiracSplitter/DiracSplitterFile.cpp
index 5833ae0b1..5eda6ad73 100644
--- a/src/filters/parser/DiracSplitter/DiracSplitterFile.cpp
+++ b/src/filters/parser/DiracSplitter/DiracSplitterFile.cpp
@@ -6,159 +6,171 @@
#include <moreuuids.h>
CDiracSplitterFile::CDiracSplitterFile(IAsyncReader* pAsyncReader, HRESULT& hr)
- : CBaseSplitterFile(pAsyncReader, hr)
- , m_rtDuration(0)
+ : CBaseSplitterFile(pAsyncReader, hr)
+ , m_rtDuration(0)
{
- if(SUCCEEDED(hr)) hr = Init();
- m_pBuff.SetSize(1024, 1024);
+ if(SUCCEEDED(hr)) {
+ hr = Init();
+ }
+ m_pBuff.SetSize(1024, 1024);
}
HRESULT CDiracSplitterFile::Init()
{
- HRESULT hr = E_FAIL;
-
- Seek(0);
-
- // Dirac streams are no longer preceded with KW-DIRAC
- //UINT64 hdr;
- //if(FAILED(Read((BYTE*)&hdr, sizeof(hdr))) || hdr != 0x43415249442D574Bui64) // KW-DIRAC
- //return E_FAIL;
-
- dirac_decoder_t* decoder = dirac_decoder_init(0);
-
- __int64 limit = min(GetLength(), 2048);
-
- while(GetPos() < limit)
- {
- BYTE b;
- if(!Next(b)) {ASSERT(0); break;}
-
- if(b == AU_START_CODE)
- {
- __int64 pos = GetPos() - 13; //Parse info size = 13
- if(!Next(b)) {ASSERT(0); break;}
- __int64 len = GetPos() - pos;
- Seek(pos);
-
- m_mt.majortype = MEDIATYPE_Video;
- m_mt.subtype = MEDIASUBTYPE_DiracVideo;
- m_mt.formattype = FORMAT_DiracVideoInfo;
- m_mt.SetSampleSize(1);
-
- DIRACINFOHEADER* dvih = (DIRACINFOHEADER*)m_mt.AllocFormatBuffer(FIELD_OFFSET(DIRACINFOHEADER, dwSequenceHeader) + len);
- memset(m_mt.Format(), 0, m_mt.FormatLength());
-
- dvih->cbSequenceHeader = len;
- ByteRead((BYTE*)&dvih->dwSequenceHeader[0], len);
-
- dirac_buffer(decoder, (BYTE*)&dvih->dwSequenceHeader[0], (BYTE*)&dvih->dwSequenceHeader[0] + len);
- DecoderState dec_state = dirac_parse(decoder);
- if(dec_state != STATE_SEQUENCE) {ASSERT(0); break;}
-
- if(decoder->src_params.frame_rate.denominator)
- dvih->hdr.AvgTimePerFrame = 10000000i64 * decoder->src_params.frame_rate.denominator / decoder->src_params.frame_rate.numerator;
- dvih->hdr.bmiHeader.biSize = sizeof(dvih->hdr.bmiHeader);
- dvih->hdr.bmiHeader.biWidth = decoder->src_params.width;
- dvih->hdr.bmiHeader.biHeight = decoder->src_params.height;
- dvih->hdr.bmiHeader.biCompression = m_mt.subtype.Data1;
- dvih->hdr.dwInterlaceFlags = 0;
- if(decoder->src_params.source_sampling) dvih->hdr.dwInterlaceFlags |= AMINTERLACE_IsInterlaced;
- if(decoder->src_params.topfieldfirst) dvih->hdr.dwInterlaceFlags |= AMINTERLACE_Field1First;
- dvih->hdr.dwPictAspectRatioX = dvih->hdr.bmiHeader.biWidth;
- dvih->hdr.dwPictAspectRatioY = dvih->hdr.bmiHeader.biHeight;
-
- m_rtDuration = 0;// dvih->hdr.AvgTimePerFrame * decoder->src_params.num_frames; // WTF
-
- hr = S_OK;
- // TESTING
- //ASSERT(0);
- break;
- }
- }
-
- dirac_decoder_close(decoder);
-
- return hr;
+ HRESULT hr = E_FAIL;
+
+ Seek(0);
+
+ // Dirac streams are no longer preceded with KW-DIRAC
+ //UINT64 hdr;
+ //if(FAILED(Read((BYTE*)&hdr, sizeof(hdr))) || hdr != 0x43415249442D574Bui64) // KW-DIRAC
+ //return E_FAIL;
+
+ dirac_decoder_t* decoder = dirac_decoder_init(0);
+
+ __int64 limit = min(GetLength(), 2048);
+
+ while(GetPos() < limit) {
+ BYTE b;
+ if(!Next(b)) {
+ ASSERT(0);
+ break;
+ }
+
+ if(b == AU_START_CODE) {
+ __int64 pos = GetPos() - 13; //Parse info size = 13
+ if(!Next(b)) {
+ ASSERT(0);
+ break;
+ }
+ __int64 len = GetPos() - pos;
+ Seek(pos);
+
+ m_mt.majortype = MEDIATYPE_Video;
+ m_mt.subtype = MEDIASUBTYPE_DiracVideo;
+ m_mt.formattype = FORMAT_DiracVideoInfo;
+ m_mt.SetSampleSize(1);
+
+ DIRACINFOHEADER* dvih = (DIRACINFOHEADER*)m_mt.AllocFormatBuffer(FIELD_OFFSET(DIRACINFOHEADER, dwSequenceHeader) + len);
+ memset(m_mt.Format(), 0, m_mt.FormatLength());
+
+ dvih->cbSequenceHeader = len;
+ ByteRead((BYTE*)&dvih->dwSequenceHeader[0], len);
+
+ dirac_buffer(decoder, (BYTE*)&dvih->dwSequenceHeader[0], (BYTE*)&dvih->dwSequenceHeader[0] + len);
+ DecoderState dec_state = dirac_parse(decoder);
+ if(dec_state != STATE_SEQUENCE) {
+ ASSERT(0);
+ break;
+ }
+
+ if(decoder->src_params.frame_rate.denominator) {
+ dvih->hdr.AvgTimePerFrame = 10000000i64 * decoder->src_params.frame_rate.denominator / decoder->src_params.frame_rate.numerator;
+ }
+ dvih->hdr.bmiHeader.biSize = sizeof(dvih->hdr.bmiHeader);
+ dvih->hdr.bmiHeader.biWidth = decoder->src_params.width;
+ dvih->hdr.bmiHeader.biHeight = decoder->src_params.height;
+ dvih->hdr.bmiHeader.biCompression = m_mt.subtype.Data1;
+ dvih->hdr.dwInterlaceFlags = 0;
+ if(decoder->src_params.source_sampling) {
+ dvih->hdr.dwInterlaceFlags |= AMINTERLACE_IsInterlaced;
+ }
+ if(decoder->src_params.topfieldfirst) {
+ dvih->hdr.dwInterlaceFlags |= AMINTERLACE_Field1First;
+ }
+ dvih->hdr.dwPictAspectRatioX = dvih->hdr.bmiHeader.biWidth;
+ dvih->hdr.dwPictAspectRatioY = dvih->hdr.bmiHeader.biHeight;
+
+ m_rtDuration = 0;// dvih->hdr.AvgTimePerFrame * decoder->src_params.num_frames; // WTF
+
+ hr = S_OK;
+ // TESTING
+ //ASSERT(0);
+ break;
+ }
+ }
+
+ dirac_decoder_close(decoder);
+
+ return hr;
}
UINT64 CDiracSplitterFile::UnsignedGolombDecode()
-{
- int M = 0;
- while(M < 64 && !BitRead(1))
- M++;
+{
+ int M = 0;
+ while(M < 64 && !BitRead(1)) {
+ M++;
+ }
- UINT64 info = 0;
- for(int i = 0; i < M; i++)
- info |= BitRead(1) << i;
+ UINT64 info = 0;
+ for(int i = 0; i < M; i++) {
+ info |= BitRead(1) << i;
+ }
- return (1ui64<<M)-1 + info;
+ return (1ui64<<M)-1 + info;
}
bool CDiracSplitterFile::Next(BYTE& code, __int64 len)
{
- BitByteAlign();
- UINT64 qw = (UINT64)-1;
- do
- {
- if(len-- == 0 || GetPos() >= GetLength()) return(false);
- qw = (qw << 8) | (BYTE)BitRead(8);
- }
- while((qw&0xffffffff00) != ((UINT64)START_CODE_PREFIX<<8));
- int size_bytes = 0;
- // Read in the 6 bytes of next and previous parse unit offsets.
- while (size_bytes < 6)
- {
- if(len-- == 0 || GetPos() >= GetLength()) return(false);
- BitRead(8);
- size_bytes++;
- }
- code = (BYTE)(qw & 0xff);
- return(true);
+ BitByteAlign();
+ UINT64 qw = (UINT64)-1;
+ do {
+ if(len-- == 0 || GetPos() >= GetLength()) {
+ return(false);
+ }
+ qw = (qw << 8) | (BYTE)BitRead(8);
+ } while((qw&0xffffffff00) != ((UINT64)START_CODE_PREFIX<<8));
+ int size_bytes = 0;
+ // Read in the 6 bytes of next and previous parse unit offsets.
+ while (size_bytes < 6) {
+ if(len-- == 0 || GetPos() >= GetLength()) {
+ return(false);
+ }
+ BitRead(8);
+ size_bytes++;
+ }
+ code = (BYTE)(qw & 0xff);
+ return(true);
}
const BYTE* CDiracSplitterFile::NextBlock(BYTE& code, int& size, int& fnum)
{
- BYTE* pBuff = m_pBuff.GetData();
- size = 0;
-
- // TODO: make sure we are at a start code right now
-
- while(GetPos() < GetLength())
- {
- if(GetPos() <= GetLength() - 5)
- {
- UINT64 qw = BitRead(40, true);
-
- if(size == 0)
- {
- if((qw & 0xffffffff00) == ((UINT64)START_CODE_PREFIX<<8) )
- code = (BYTE)(qw & 0xff);
-
- if(isFrameStartCode(code))
- {
- __int64 pos = GetPos();
- Seek(pos + 5);
- //fnum = (int)UnsignedGolombDecode();
- ByteRead((BYTE*)&fnum, sizeof(fnum));
- Seek(pos);
- }
- }
- else
- {
- if((qw & 0xffffffff00) == ((UINT64)START_CODE_PREFIX<<8))
- break;
- }
- }
-
- if(size >= m_pBuff.GetSize())
- {
- int newsize = max(1024, size*2);
- m_pBuff.SetSize(newsize, newsize);
- pBuff = m_pBuff.GetData();
- }
-
- pBuff[size++] = (BYTE)BitRead(8);
- }
-
- return pBuff;
+ BYTE* pBuff = m_pBuff.GetData();
+ size = 0;
+
+ // TODO: make sure we are at a start code right now
+
+ while(GetPos() < GetLength()) {
+ if(GetPos() <= GetLength() - 5) {
+ UINT64 qw = BitRead(40, true);
+
+ if(size == 0) {
+ if((qw & 0xffffffff00) == ((UINT64)START_CODE_PREFIX<<8) ) {
+ code = (BYTE)(qw & 0xff);
+ }
+
+ if(isFrameStartCode(code)) {
+ __int64 pos = GetPos();
+ Seek(pos + 5);
+ //fnum = (int)UnsignedGolombDecode();
+ ByteRead((BYTE*)&fnum, sizeof(fnum));
+ Seek(pos);
+ }
+ } else {
+ if((qw & 0xffffffff00) == ((UINT64)START_CODE_PREFIX<<8)) {
+ break;
+ }
+ }
+ }
+
+ if(size >= m_pBuff.GetSize()) {
+ int newsize = max(1024, size*2);
+ m_pBuff.SetSize(newsize, newsize);
+ pBuff = m_pBuff.GetData();
+ }
+
+ pBuff[size++] = (BYTE)BitRead(8);
+ }
+
+ return pBuff;
}
diff --git a/src/filters/parser/DiracSplitter/DiracSplitterFile.h b/src/filters/parser/DiracSplitter/DiracSplitterFile.h
index cc2ec185a..113d653e9 100644
--- a/src/filters/parser/DiracSplitter/DiracSplitterFile.h
+++ b/src/filters/parser/DiracSplitter/DiracSplitterFile.h
@@ -16,12 +16,16 @@ class CDiracSplitterFile : public CBaseSplitterFile
public:
CDiracSplitterFile(IAsyncReader* pAsyncReader, HRESULT& hr);
-// using CBaseSplitterFile::Read;
+ // using CBaseSplitterFile::Read;
bool Next(BYTE& code, __int64 len = -1);
const BYTE* NextBlock(BYTE& code, int& size, int& fnum);
UINT64 UnsignedGolombDecode();
- const CMediaType& GetMediaType() {return m_mt;}
- REFERENCE_TIME GetDuration() {return m_rtDuration;}
+ const CMediaType& GetMediaType() {
+ return m_mt;
+ }
+ REFERENCE_TIME GetDuration() {
+ return m_rtDuration;
+ }
};
diff --git a/src/filters/parser/DiracSplitter/stdafx.cpp b/src/filters/parser/DiracSplitter/stdafx.cpp
index 13934d005..bea3f980a 100644
--- a/src/filters/parser/DiracSplitter/stdafx.cpp
+++ b/src/filters/parser/DiracSplitter/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/parser/DiracSplitter/stdafx.h b/src/filters/parser/DiracSplitter/stdafx.h
index b0322e83d..80f199e99 100644
--- a/src/filters/parser/DiracSplitter/stdafx.h
+++ b/src/filters/parser/DiracSplitter/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -55,17 +55,17 @@ using namespace dirac;
// === Imported from Dirac library
#define isFrameStartCode(c) ((c) == 0x00 || (c) == 0x0C || (c) == 0x08 || (c) == 0x0D || (c) == 0x0E || (c) == 0x09 || (c) == 0x0A || (c) == 0x10)
- const unsigned int START_CODE_PREFIX = 0x42424344; //BBCD
- const unsigned int START_CODE_PREFIX_BYTE0 =
- (START_CODE_PREFIX >> 24) & 0xFF;
- const unsigned int START_CODE_PREFIX_BYTE1 =
- (START_CODE_PREFIX >> 16) & 0xFF;
- const unsigned int START_CODE_PREFIX_BYTE2 =
- (START_CODE_PREFIX >> 8) & 0xFF;
- const unsigned int START_CODE_PREFIX_BYTE3 =
- START_CODE_PREFIX & 0xFF;
+const unsigned int START_CODE_PREFIX = 0x42424344; //BBCD
+const unsigned int START_CODE_PREFIX_BYTE0 =
+ (START_CODE_PREFIX >> 24) & 0xFF;
+const unsigned int START_CODE_PREFIX_BYTE1 =
+ (START_CODE_PREFIX >> 16) & 0xFF;
+const unsigned int START_CODE_PREFIX_BYTE2 =
+ (START_CODE_PREFIX >> 8) & 0xFF;
+const unsigned int START_CODE_PREFIX_BYTE3 =
+ START_CODE_PREFIX & 0xFF;
- //! Access unit start code
- const unsigned char AU_START_CODE = 0x00;
- //! Sequence end code
- const unsigned char SEQ_END_CODE = 0x10;
+//! Access unit start code
+const unsigned char AU_START_CODE = 0x00;
+//! Sequence end code
+const unsigned char SEQ_END_CODE = 0x10;
diff --git a/src/filters/parser/FLVSplitter/FLVSplitter.cpp b/src/filters/parser/FLVSplitter/FLVSplitter.cpp
index e7495dc5a..9dfd01bb6 100644
--- a/src/filters/parser/FLVSplitter/FLVSplitter.cpp
+++ b/src/filters/parser/FLVSplitter/FLVSplitter.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -28,31 +28,26 @@
#ifdef REGISTER_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
{&MEDIATYPE_Stream, &MEDIASUBTYPE_FLV},
{&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
};
-const AMOVIESETUP_PIN sudpPins[] =
-{
+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}
};
-const AMOVIESETUP_MEDIATYPE sudPinTypesOut2[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesOut2[] = {
{&MEDIATYPE_Video, &MEDIASUBTYPE_NULL},
};
-const AMOVIESETUP_FILTER sudFilter[] =
-{
+const AMOVIESETUP_FILTER sudFilter[] = {
{&__uuidof(CFLVSplitterFilter), L"MPC - FLV Splitter (Gabest)", MERIT_NORMAL, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
{&__uuidof(CFLVSourceFilter), L"MPC - FLV Source (Gabest)", MERIT_NORMAL, 0, NULL, CLSID_LegacyAmFilterCategory},
};
-CFactoryTemplate g_Templates[] =
-{
+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]},
};
@@ -92,8 +87,9 @@ CFLVSplitterFilter::CFLVSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr)
bool CFLVSplitterFilter::ReadTag(Tag& t)
{
- if(m_pFile->GetRemaining() < 15)
+ if(m_pFile->GetRemaining() < 15) {
return false;
+ }
t.PreviousTagSize = (UINT32)m_pFile->BitRead(32);
t.TagType = (BYTE)m_pFile->BitRead(8);
@@ -107,8 +103,9 @@ bool CFLVSplitterFilter::ReadTag(Tag& t)
bool CFLVSplitterFilter::ReadTag(AudioTag& at)
{
- if(!m_pFile->GetRemaining())
+ if(!m_pFile->GetRemaining()) {
return false;
+ }
at.SoundFormat = (BYTE)m_pFile->BitRead(4);
at.SoundRate = (BYTE)m_pFile->BitRead(2);
@@ -120,8 +117,9 @@ bool CFLVSplitterFilter::ReadTag(AudioTag& at)
bool CFLVSplitterFilter::ReadTag(VideoTag& vt)
{
- if(!m_pFile->GetRemaining())
+ if(!m_pFile->GetRemaining()) {
return false;
+ }
vt.FrameType = (BYTE)m_pFile->BitRead(4);
vt.CodecID = (BYTE)m_pFile->BitRead(4);
@@ -132,8 +130,9 @@ bool CFLVSplitterFilter::ReadTag(VideoTag& vt)
#ifndef NOVIDEOTWEAK
bool CFLVSplitterFilter::ReadTag(VideoTweak& vt)
{
- if(!m_pFile->GetRemaining())
+ if(!m_pFile->GetRemaining()) {
return false;
+ }
vt.x = (BYTE)m_pFile->BitRead(4);
vt.y = (BYTE)m_pFile->BitRead(4);
@@ -146,13 +145,16 @@ bool CFLVSplitterFilter::Sync(__int64& pos)
{
m_pFile->Seek(pos);
- while(m_pFile->GetRemaining() >= 15)
- {
+ while(m_pFile->GetRemaining() >= 15) {
__int64 limit = m_pFile->GetRemaining();
while (true) {
BYTE b = m_pFile->BitRead(8);
- if (b == 8 || b == 9) break;
- if (--limit < 15) return false;
+ if (b == 8 || b == 9) {
+ break;
+ }
+ if (--limit < 15) {
+ return false;
+ }
}
pos = m_pFile->GetPos() - 5;
@@ -164,16 +166,14 @@ bool CFLVSplitterFilter::Sync(__int64& pos)
if(next == m_pFile->GetLength() - 4) {
m_pFile->Seek(pos);
return true;
- }
- else if (next <= m_pFile->GetLength() - 19) {
+ } else if (next <= m_pFile->GetLength() - 19) {
m_pFile->Seek(next);
Tag nt;
if (ReadTag(nt) && (nt.TagType == 8 || nt.TagType == 9 || nt.TagType == 18)) {
if ((nt.PreviousTagSize == ct.DataSize + 11) ||
- (m_IgnorePrevSizes &&
- nt.TimeStamp >= ct.TimeStamp &&
- nt.TimeStamp - ct.TimeStamp <= 1000))
- {
+ (m_IgnorePrevSizes &&
+ nt.TimeStamp >= ct.TimeStamp &&
+ nt.TimeStamp - ct.TimeStamp <= 1000)) {
m_pFile->Seek(pos);
return true;
}
@@ -195,14 +195,20 @@ HRESULT CFLVSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
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;}
+ 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)
+ 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);
@@ -222,8 +228,7 @@ HRESULT CFLVSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
m_pFile->Seek(m_DataOffset);
- for(int i = 0; ReadTag(t) && (fTypeFlagsVideo || fTypeFlagsAudio) && i < 100; i++)
- {
+ for(int i = 0; ReadTag(t) && (fTypeFlagsVideo || fTypeFlagsAudio) && i < 100; i++) {
UINT64 next = m_pFile->GetPos() + t.DataSize;
CStringW name;
@@ -237,14 +242,12 @@ HRESULT CFLVSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
}
prevTagSize = t.DataSize + 11;
- if(t.TagType == 8 && t.DataSize != 0 && fTypeFlagsAudio)
- {
+ if(t.TagType == 8 && t.DataSize != 0 && fTypeFlagsAudio) {
UNREFERENCED_PARAMETER(at);
AudioTag at;
name = L"Audio";
- if(ReadTag(at))
- {
+ if(ReadTag(at)) {
int dataSize = t.DataSize - 1;
fTypeFlagsAudio = false;
@@ -256,83 +259,84 @@ HRESULT CFLVSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
wfe->nSamplesPerSec = 44100*(1<<at.SoundRate)/8;
wfe->wBitsPerSample = 8*(at.SoundSize+1);
wfe->nChannels = 1*(at.SoundType+1);
-
- switch(at.SoundFormat)
- {
- case 0: // FLV_CODECID_PCM_BE
- mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_PCM);
- break;
- case 1: // FLV_CODECID_ADPCM
- mt.subtype = FOURCCMap(MAKEFOURCC('A','S','W','F'));
- break;
- case 2: // FLV_CODECID_MP3
- mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_MP3);
-
- {
- CBaseSplitterFileEx::mpahdr h;
- CMediaType mt2;
- if(m_pFile->Read(h, 4, false, &mt2))
- mt = mt2;
- }
- break;
- case 3 : // FLV_CODECID_PCM_LE
- // ToDo
- break;
- case 4 : // unknown
- break;
- case 5 : // FLV_CODECID_NELLYMOSER_8HZ_MONO
- mt.subtype = FOURCCMap(MAKEFOURCC('N','E','L','L'));
- wfe->nSamplesPerSec = 8000;
- break;
- case 6 : // FLV_CODECID_NELLYMOSER
- mt.subtype = FOURCCMap(MAKEFOURCC('N','E','L','L'));
- break;
- case 10: { // FLV_CODECID_AAC
- if (dataSize < 1 || m_pFile->BitRead(8) != 0) { // packet type 0 == aac header
- fTypeFlagsAudio = true;
+
+ switch(at.SoundFormat) {
+ case 0: // FLV_CODECID_PCM_BE
+ mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_PCM);
+ break;
+ case 1: // FLV_CODECID_ADPCM
+ mt.subtype = FOURCCMap(MAKEFOURCC('A','S','W','F'));
+ break;
+ case 2: // FLV_CODECID_MP3
+ mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_MP3);
+
+ {
+ CBaseSplitterFileEx::mpahdr h;
+ CMediaType mt2;
+ if(m_pFile->Read(h, 4, false, &mt2)) {
+ mt = mt2;
+ }
+ }
+ break;
+ case 3 : // FLV_CODECID_PCM_LE
+ // ToDo
break;
+ case 4 : // unknown
+ break;
+ case 5 : // FLV_CODECID_NELLYMOSER_8HZ_MONO
+ mt.subtype = FOURCCMap(MAKEFOURCC('N','E','L','L'));
+ wfe->nSamplesPerSec = 8000;
+ break;
+ case 6 : // FLV_CODECID_NELLYMOSER
+ mt.subtype = FOURCCMap(MAKEFOURCC('N','E','L','L'));
+ break;
+ case 10: { // FLV_CODECID_AAC
+ if (dataSize < 1 || m_pFile->BitRead(8) != 0) { // packet type 0 == aac header
+ fTypeFlagsAudio = true;
+ break;
+ }
+
+ 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 = m_pFile->BitRead(4);
+ int iChannels = 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);
}
- 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 = m_pFile->BitRead(4);
- int iChannels = 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 == 9 && t.DataSize != 0 && fTypeFlagsVideo)
- {
+ } else if(t.TagType == 9 && t.DataSize != 0 && fTypeFlagsVideo) {
UNREFERENCED_PARAMETER(vt);
VideoTag vt;
- if(ReadTag(vt) && vt.FrameType == 1)
- {
+ if(ReadTag(vt) && vt.FrameType == 1) {
int dataSize = t.DataSize - 1;
fTypeFlagsVideo = false;
@@ -347,188 +351,202 @@ HRESULT CFLVSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
int w, h, arx, ary;
- switch(vt.CodecID)
- {
- case 2: // 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;
- }
+ switch(vt.CodecID) {
+ case 2: // H.263
+ if(m_pFile->BitRead(17) != 1) {
+ break;
+ }
- if(!vih->bmiHeader.biWidth || !vih->bmiHeader.biHeight) 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;
+ }
- mt.subtype = FOURCCMap(vih->bmiHeader.biCompression = '1VLF');
+ if(!vih->bmiHeader.biWidth || !vih->bmiHeader.biHeight) {
+ break;
+ }
- break;
+ mt.subtype = FOURCCMap(vih->bmiHeader.biCompression = '1VLF');
- case 5: // VP6 with alpha
- m_pFile->BitRead(24);
- case 4: { // VP6
- #ifdef NOVIDEOTWEAK
- m_pFile->BitRead(8);
- #else
- 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 = m_pFile->BitRead(2);
- m_pFile->BitRead(1);
- if (fSeparatedCoeff || !filterHeader) {
- m_pFile->BitRead(16);
- }
- h = m_pFile->BitRead(8) * 16;
- w = m_pFile->BitRead(8) * 16;
-
- ary = m_pFile->BitRead(8) * 16;
- arx = m_pFile->BitRead(8) * 16;
+ case 5: // VP6 with alpha
+ m_pFile->BitRead(24);
+ case 4: { // VP6
+#ifdef NOVIDEOTWEAK
+ m_pFile->BitRead(8);
+#else
+ VideoTweak fudge;
+ ReadTag(fudge);
+#endif
- 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;
- }
+ 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 = m_pFile->BitRead(2);
+ m_pFile->BitRead(1);
+ if (fSeparatedCoeff || !filterHeader) {
+ m_pFile->BitRead(16);
+ }
- 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);
- #endif
+ h = m_pFile->BitRead(8) * 16;
+ w = m_pFile->BitRead(8) * 16;
- mt.subtype = FOURCCMap(bih->biCompression = '4VLF');
+ ary = m_pFile->BitRead(8) * 16;
+ arx = m_pFile->BitRead(8) * 16;
- break;
- }
- case 7: { // 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);
+ 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;
+ }
- m_pFile->Seek(headerOffset + 9);
+ 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);
+#endif
- 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
+ mt.subtype = FOURCCMap(bih->biCompression = '4VLF');
- 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
- if(vih->dwProfile >= 100) { // high profile
- if(m_pFile->UExpGolombRead() == 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]
+ break;
}
- 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);
- vih->hdr.bmiHeader.biWidth = vih->hdr.dwPictAspectRatioX = (LONG)((pic_width_in_mbs_minus1 + 1) * 16);
- vih->hdr.bmiHeader.biHeight = vih->hdr.dwPictAspectRatioY = (LONG)((2 - frame_mbs_only_flag) * (pic_height_in_map_units_minus1 + 1) * 16);
-
- 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;
+ case 7: { // 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
+ if(vih->dwProfile >= 100) { // high profile
+ if(m_pFile->UExpGolombRead() == 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);
+ vih->hdr.bmiHeader.biWidth = vih->hdr.dwPictAspectRatioX = (LONG)((pic_width_in_mbs_minus1 + 1) * 16);
+ vih->hdr.bmiHeader.biHeight = vih->hdr.dwPictAspectRatioY = (LONG)((2 - frame_mbs_only_flag) * (pic_height_in_map_units_minus1 + 1) * 16);
+
+ 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;
}
- 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;
+ delete[] headerData;
- mt.subtype = FOURCCMap(vih->hdr.bmiHeader.biCompression = '1CVA');
+ mt.subtype = FOURCCMap(vih->hdr.bmiHeader.biCompression = '1CVA');
- break;
- }
- default:
- fTypeFlagsVideo = true;
+ break;
+ }
+ default:
+ fTypeFlagsVideo = true;
}
}
}
-
- if(mt.subtype != GUID_NULL)
- {
+
+ if(mt.subtype != GUID_NULL) {
CAtlArray<CMediaType> mts;
mts.Add(mt);
CAutoPtr<CBaseSplitterOutputPin> pPinOut(DNew CBaseSplitterOutputPin(mts, name, this, this, &hr));
@@ -538,23 +556,19 @@ HRESULT CFLVSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
m_pFile->Seek(next);
}
- if(m_pFile->IsRandomAccess())
- {
+ if(m_pFile->IsRandomAccess()) {
__int64 pos = max(m_DataOffset, m_pFile->GetLength() - 256 * 1024);
- if(Sync(pos))
- {
+ if(Sync(pos)) {
Tag t;
AudioTag at;
VideoTag vt;
- while(ReadTag(t))
- {
+ while(ReadTag(t)) {
UINT64 next = m_pFile->GetPos() + t.DataSize;
- if(t.TagType == 8 && ReadTag(at) || t.TagType == 9 && ReadTag(vt))
- {
- m_rtDuration = max(m_rtDuration, 10000i64 * t.TimeStamp);
+ if(t.TagType == 8 && ReadTag(at) || t.TagType == 9 && ReadTag(vt)) {
+ m_rtDuration = max(m_rtDuration, 10000i64 * t.TimeStamp);
}
m_pFile->Seek(next);
@@ -577,11 +591,9 @@ void CFLVSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
{
if(!m_rtDuration || rt <= 0) {
m_pFile->Seek(m_DataOffset);
- }
- else if (!m_IgnorePrevSizes) {
+ } else if (!m_IgnorePrevSizes) {
NormalSeek(rt);
- }
- else {
+ } else {
AlternateSeek(rt);
}
}
@@ -593,8 +605,7 @@ void CFLVSplitterFilter::NormalSeek(REFERENCE_TIME rt)
__int64 pos = m_DataOffset + 1.0 * rt / m_rtDuration * (m_pFile->GetLength() - m_DataOffset);
- if(!Sync(pos))
- {
+ if(!Sync(pos)) {
ASSERT(0);
m_pFile->Seek(m_DataOffset);
return;
@@ -604,10 +615,8 @@ void CFLVSplitterFilter::NormalSeek(REFERENCE_TIME rt)
AudioTag at;
VideoTag vt;
- while(ReadTag(t))
- {
- if(10000i64 * t.TimeStamp >= rt)
- {
+ while(ReadTag(t)) {
+ if(10000i64 * t.TimeStamp >= rt) {
m_pFile->Seek(m_pFile->GetPos() - 15);
break;
}
@@ -615,18 +624,13 @@ void CFLVSplitterFilter::NormalSeek(REFERENCE_TIME rt)
m_pFile->Seek(m_pFile->GetPos() + t.DataSize);
}
- while(m_pFile->GetPos() >= m_DataOffset && (fAudio || fVideo) && ReadTag(t))
- {
+ 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 == 8 && ReadTag(at))
- {
+ if(10000i64 * t.TimeStamp <= rt) {
+ if(t.TagType == 8 && ReadTag(at)) {
fAudio = false;
- }
- else if(t.TagType == 9 && ReadTag(vt) && vt.FrameType == 1)
- {
+ } else if(t.TagType == 9 && ReadTag(vt) && vt.FrameType == 1) {
fVideo = false;
}
}
@@ -634,8 +638,7 @@ void CFLVSplitterFilter::NormalSeek(REFERENCE_TIME rt)
m_pFile->Seek(prev);
}
- if(fAudio || fVideo)
- {
+ if(fAudio || fVideo) {
ASSERT(0);
m_pFile->Seek(m_DataOffset);
}
@@ -668,9 +671,10 @@ void CFLVSplitterFilter::AlternateSeek(REFERENCE_TIME rt)
if (hasAudio && t.TagType == 8 && ReadTag(at)) {
foundAudio = true;
- if (!hasVideo) bestPos = cur;
- }
- else if (hasVideo && t.TagType == 9 && ReadTag(vt) && vt.FrameType == 1) {
+ if (!hasVideo) {
+ bestPos = cur;
+ }
+ } else if (hasVideo && t.TagType == 9 && ReadTag(vt) && vt.FrameType == 1) {
foundVideo = true;
bestPos = cur;
}
@@ -684,8 +688,7 @@ void CFLVSplitterFilter::AlternateSeek(REFERENCE_TIME rt)
m_pFile->Seek(m_DataOffset);
return;
}
- }
- else {
+ } else {
m_pFile->Seek(bestPos);
return;
}
@@ -702,35 +705,44 @@ bool CFLVSplitterFilter::DemuxLoop()
AudioTag at;
VideoTag vt;
- while(SUCCEEDED(hr) && !CheckRequest(NULL) && m_pFile->GetRemaining())
- {
- if(!ReadTag(t)) break;
+ 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 == 8 && ReadTag(at) || t.TagType == 9 && ReadTag(vt)))
- {
+ if((t.DataSize > 0) && (t.TagType == 8 && ReadTag(at) || t.TagType == 9 && ReadTag(vt))) {
UINT32 tsOffset = 0;
- if(t.TagType == 9)
- {
- if(vt.FrameType == 5) goto NextTag; // video info/command frame
- if(vt.CodecID == 4) m_pFile->BitRead(8);
- else if(vt.CodecID == 5) m_pFile->BitRead(32);
- else if(vt.CodecID == 7) {
- if (m_pFile->BitRead(8) != 1) goto NextTag;
+ if(t.TagType == 9) {
+ if(vt.FrameType == 5) {
+ goto NextTag; // video info/command frame
+ }
+ if(vt.CodecID == 4) {
+ m_pFile->BitRead(8);
+ } else if(vt.CodecID == 5) {
+ m_pFile->BitRead(32);
+ } else if(vt.CodecID == 7) {
+ if (m_pFile->BitRead(8) != 1) {
+ goto NextTag;
+ }
// Tag timestamps specify decode time, this is the display time offset
tsOffset = m_pFile->BitRead(24);
tsOffset = (tsOffset + 0xff800000) ^ 0xff800000; // sign extension
}
}
if(t.TagType == 8 && at.SoundFormat == 10) {
- if (m_pFile->BitRead(8) != 1) goto NextTag;
+ if (m_pFile->BitRead(8) != 1) {
+ goto NextTag;
+ }
}
__int64 dataSize = next - m_pFile->GetPos();
- if (dataSize <= 0) goto NextTag;
+ if (dataSize <= 0) {
+ goto NextTag;
+ }
p.Attach(DNew Packet());
p->TrackNumber = t.TagType;
- p->rtStart = 10000i64 * (t.TimeStamp + tsOffset);
+ p->rtStart = 10000i64 * (t.TimeStamp + tsOffset);
p->rtStop = p->rtStart + 1;
p->bSyncPoint = t.TagType == 9 ? vt.FrameType == 1 : true;
p->SetCount(dataSize);
diff --git a/src/filters/parser/FLVSplitter/FLVSplitter.h b/src/filters/parser/FLVSplitter/FLVSplitter.h
index 4899ef8cc..3e1690384 100644
--- a/src/filters/parser/FLVSplitter/FLVSplitter.h
+++ b/src/filters/parser/FLVSplitter/FLVSplitter.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -25,23 +25,21 @@
#include "../BaseSplitter/BaseSplitter.h"
class __declspec(uuid("47E792CF-0BBE-4F7A-859C-194B0768650A"))
-CFLVSplitterFilter : public CBaseSplitterFilter
+ CFLVSplitterFilter : public CBaseSplitterFilter
{
UINT32 m_DataOffset;
bool m_IgnorePrevSizes;
bool Sync(__int64& pos);
- struct VideoTweak
- {
+ struct VideoTweak {
BYTE x;
BYTE y;
};
bool ReadTag(VideoTweak& t);
-
- struct Tag
- {
+
+ struct Tag {
UINT32 PreviousTagSize;
BYTE TagType;
UINT32 DataSize;
@@ -51,8 +49,7 @@ CFLVSplitterFilter : public CBaseSplitterFilter
bool ReadTag(Tag& t);
- struct AudioTag
- {
+ struct AudioTag {
BYTE SoundFormat;
BYTE SoundRate;
BYTE SoundSize;
@@ -61,8 +58,7 @@ CFLVSplitterFilter : public CBaseSplitterFilter
bool ReadTag(AudioTag& at);
- struct VideoTag
- {
+ struct VideoTag {
BYTE FrameType;
BYTE CodecID;
};
@@ -85,7 +81,7 @@ public:
};
class __declspec(uuid("C9ECE7B3-1D8E-41F5-9F24-B255DF16C087"))
-CFLVSourceFilter : public CFLVSplitterFilter
+ CFLVSourceFilter : public CFLVSplitterFilter
{
public:
CFLVSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
diff --git a/src/filters/parser/FLVSplitter/stdafx.cpp b/src/filters/parser/FLVSplitter/stdafx.cpp
index 13934d005..bea3f980a 100644
--- a/src/filters/parser/FLVSplitter/stdafx.cpp
+++ b/src/filters/parser/FLVSplitter/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/parser/FLVSplitter/stdafx.h b/src/filters/parser/FLVSplitter/stdafx.h
index cdc946aa0..9b252ac14 100644
--- a/src/filters/parser/FLVSplitter/stdafx.h
+++ b/src/filters/parser/FLVSplitter/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/parser/MP4Splitter/AP4/Core/Ap4Atom.h b/src/filters/parser/MP4Splitter/AP4/Core/Ap4Atom.h
index a0d849bb0..69339653d 100644
--- a/src/filters/parser/MP4Splitter/AP4/Core/Ap4Atom.h
+++ b/src/filters/parser/MP4Splitter/AP4/Core/Ap4Atom.h
@@ -244,6 +244,7 @@ const AP4_Atom::Type AP4_ATOM_TYPE_CVID = AP4_ATOM_TYPE('c','v','i','d');
const AP4_Atom::Type AP4_ATOM_TYPE_SVQ1 = AP4_ATOM_TYPE('S','V','Q','1');
const AP4_Atom::Type AP4_ATOM_TYPE_SVQ2 = AP4_ATOM_TYPE('S','V','Q','2');
const AP4_Atom::Type AP4_ATOM_TYPE_SVQ3 = AP4_ATOM_TYPE('S','V','Q','3');
+const AP4_Atom::Type AP4_ATOM_TYPE_H261 = AP4_ATOM_TYPE('h','2','6','1');
const AP4_Atom::Type AP4_ATOM_TYPE_H263 = AP4_ATOM_TYPE('h','2','6','3');
const AP4_Atom::Type AP4_ATOM_TYPE_S263 = AP4_ATOM_TYPE('s','2','6','3');
const AP4_Atom::Type AP4_ATOM_TYPE_SAMR = AP4_ATOM_TYPE('s','a','m','r');
@@ -251,6 +252,7 @@ const AP4_Atom::Type AP4_ATOM_TYPE__MP3 = AP4_ATOM_TYPE('.','m','p','3');
const AP4_Atom::Type AP4_ATOM_TYPE_IMA4 = AP4_ATOM_TYPE('i','m','a','4');
const AP4_Atom::Type AP4_ATOM_TYPE_QDMC = AP4_ATOM_TYPE('Q','D','M','C');
const AP4_Atom::Type AP4_ATOM_TYPE_QDM2 = AP4_ATOM_TYPE('Q','D','M','2');
+//PCM Audio
const AP4_Atom::Type AP4_ATOM_TYPE_NONE = AP4_ATOM_TYPE('N','O','N','E');
const AP4_Atom::Type AP4_ATOM_TYPE_TWOS = AP4_ATOM_TYPE('t','w','o','s');
const AP4_Atom::Type AP4_ATOM_TYPE_SOWT = AP4_ATOM_TYPE('s','o','w','t');
@@ -258,6 +260,7 @@ const AP4_Atom::Type AP4_ATOM_TYPE_IN24 = AP4_ATOM_TYPE('i','n','2','4');
const AP4_Atom::Type AP4_ATOM_TYPE_IN32 = AP4_ATOM_TYPE('i','n','3','2');
const AP4_Atom::Type AP4_ATOM_TYPE_FL32 = AP4_ATOM_TYPE('f','l','3','2');
const AP4_Atom::Type AP4_ATOM_TYPE_FL64 = AP4_ATOM_TYPE('f','l','6','4');
+//
const AP4_Atom::Type AP4_ATOM_TYPE_CHPL = AP4_ATOM_TYPE('c','h','p','l');
const AP4_Atom::Type AP4_ATOM_TYPE_NAM = AP4_ATOM_TYPE(169,'n','a','m');
const AP4_Atom::Type AP4_ATOM_TYPE_ART = AP4_ATOM_TYPE(169,'A','R','T');
@@ -286,15 +289,22 @@ const AP4_Atom::Type AP4_ATOM_TYPE_PNG = AP4_ATOM_TYPE('p','n','g',' ');
const AP4_Atom::Type AP4_ATOM_TYPE_ALAW = AP4_ATOM_TYPE('a','l','a','w');
const AP4_Atom::Type AP4_ATOM_TYPE_ULAW = AP4_ATOM_TYPE('u','l','a','w');
const AP4_Atom::Type AP4_ATOM_TYPE_RLE = AP4_ATOM_TYPE('r','l','e',' ');
+//Motion-JPEG
const AP4_Atom::Type AP4_ATOM_TYPE_MJPA = AP4_ATOM_TYPE('m','j','p','a');
const AP4_Atom::Type AP4_ATOM_TYPE_MJPB = AP4_ATOM_TYPE('m','j','p','b');
const AP4_Atom::Type AP4_ATOM_TYPE_MJPG = AP4_ATOM_TYPE('M','J','P','G');
+const AP4_Atom::Type AP4_ATOM_TYPE_DMB1 = AP4_ATOM_TYPE('d','m','b','1');
+//
const AP4_Atom::Type AP4_ATOM_TYPE_RPZA = AP4_ATOM_TYPE('r','p','z','a');
const AP4_Atom::Type AP4_ATOM_TYPE_DVC = AP4_ATOM_TYPE('d','v','c',' ');
const AP4_Atom::Type AP4_ATOM_TYPE_DIV3 = AP4_ATOM_TYPE('D','I','V','3');
+const AP4_Atom::Type AP4_ATOM_TYPE_DIVX = AP4_ATOM_TYPE('d','i','v','x');
const AP4_Atom::Type AP4_ATOM_TYPE_8BPS = AP4_ATOM_TYPE('8','B','P','S');
const AP4_Atom::Type AP4_ATOM_TYPE_3IV1 = AP4_ATOM_TYPE('3','I','V','1');
const AP4_Atom::Type AP4_ATOM_TYPE_3IV2 = AP4_ATOM_TYPE('3','I','V','2');
+const AP4_Atom::Type AP4_ATOM_TYPE_IV32 = AP4_ATOM_TYPE('I','V','3','2');
+const AP4_Atom::Type AP4_ATOM_TYPE_VP31 = AP4_ATOM_TYPE('V','P','3','1');
+const AP4_Atom::Type AP4_ATOM_TYPE_YV12 = AP4_ATOM_TYPE('y','v','1','2');
/*----------------------------------------------------------------------
| AP4_AtomListInspector
+---------------------------------------------------------------------*/
diff --git a/src/filters/parser/MP4Splitter/AP4/Core/Ap4AtomFactory.cpp b/src/filters/parser/MP4Splitter/AP4/Core/Ap4AtomFactory.cpp
index 2caeb96a2..794d3139b 100644
--- a/src/filters/parser/MP4Splitter/AP4/Core/Ap4AtomFactory.cpp
+++ b/src/filters/parser/MP4Splitter/AP4/Core/Ap4AtomFactory.cpp
@@ -392,6 +392,7 @@ AP4_AtomFactory::CreateAtomFromStream(AP4_ByteStream& stream,
case AP4_ATOM_TYPE_SVQ1:
case AP4_ATOM_TYPE_SVQ2:
case AP4_ATOM_TYPE_SVQ3:
+ case AP4_ATOM_TYPE_H261:
case AP4_ATOM_TYPE_H263:
case AP4_ATOM_TYPE_S263:
case AP4_ATOM_TYPE_JPEG:
@@ -400,12 +401,17 @@ AP4_AtomFactory::CreateAtomFromStream(AP4_ByteStream& stream,
case AP4_ATOM_TYPE_MJPA:
case AP4_ATOM_TYPE_MJPB:
case AP4_ATOM_TYPE_MJPG:
+ case AP4_ATOM_TYPE_DMB1:
case AP4_ATOM_TYPE_RPZA:
case AP4_ATOM_TYPE_DVC:
case AP4_ATOM_TYPE_DIV3:
+ case AP4_ATOM_TYPE_DIVX:
case AP4_ATOM_TYPE_8BPS:
case AP4_ATOM_TYPE_3IV1:
case AP4_ATOM_TYPE_3IV2:
+ case AP4_ATOM_TYPE_IV32:
+ case AP4_ATOM_TYPE_VP31:
+ case AP4_ATOM_TYPE_YV12:
atom = DNew AP4_VisualSampleEntry(type, size, stream, *this);
break;
diff --git a/src/filters/parser/MP4Splitter/Ap4AsyncReaderStream.cpp b/src/filters/parser/MP4Splitter/Ap4AsyncReaderStream.cpp
index 1f0240054..496efa659 100644
--- a/src/filters/parser/MP4Splitter/Ap4AsyncReaderStream.cpp
+++ b/src/filters/parser/MP4Splitter/Ap4AsyncReaderStream.cpp
@@ -1,7 +1,7 @@
#include "stdafx.h"
#include "Ap4AsyncReaderStream.h"
-AP4_AsyncReaderStream::AP4_AsyncReaderStream(CBaseSplitterFile* pFile)
+AP4_AsyncReaderStream::AP4_AsyncReaderStream(CBaseSplitterFile* pFile)
: m_refs(1)
, m_pFile(pFile)
{
@@ -15,45 +15,50 @@ AP4_AsyncReaderStream::~AP4_AsyncReaderStream()
void AP4_AsyncReaderStream::AddReference()
{
- ASSERT(m_refs > 0);
+ 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();
- if(bytesAvail < bytesToRead)
- {
- if(bytesRead) *bytesRead = bytesAvail;
+ if(bytesAvail < bytesToRead) {
+ if(bytesRead) {
+ *bytesRead = bytesAvail;
+ }
bytesToRead = bytesAvail;
}
- if(bytesAvail == 0)
- {
+ if(bytesAvail == 0) {
return AP4_ERROR_EOS;
}
- if(FAILED(m_pFile->ByteRead((BYTE*)buffer, bytesToRead)))
- {
- if(bytesRead) *bytesRead = 0;
+ 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;
}
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)
diff --git a/src/filters/parser/MP4Splitter/MP4Splitter.cpp b/src/filters/parser/MP4Splitter/MP4Splitter.cpp
index b395e590a..d0d641aec 100644
--- a/src/filters/parser/MP4Splitter/MP4Splitter.cpp
+++ b/src/filters/parser/MP4Splitter/MP4Splitter.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -39,28 +39,24 @@
#ifdef REGISTER_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
{&MEDIATYPE_Stream, &MEDIASUBTYPE_MP4},
{&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
};
-const AMOVIESETUP_PIN sudpPins[] =
-{
+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}
};
-const AMOVIESETUP_FILTER sudFilter[] =
-{
+const AMOVIESETUP_FILTER sudFilter[] = {
{&__uuidof(CMP4SplitterFilter), L"MPC - MP4 Splitter", MERIT_NORMAL, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
{&__uuidof(CMP4SourceFilter), L"MPC - MP4 Source", 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(CMPEG4VideoSourceFilter), L"MPC - MPEG4 Video Source", MERIT_NORMAL, 0, NULL, CLSID_LegacyAmFilterCategory},
};
-CFactoryTemplate g_Templates[] =
-{
+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]},
@@ -127,32 +123,37 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
m_pFile.Free();
m_pFile.Attach(DNew CMP4SplitterFile(pAsyncReader, hr));
- if(!m_pFile) return E_OUTOFMEMORY;
- if(FAILED(hr)) {m_pFile.Free(); return 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;
m_framesize.SetSize(640, 480);
- if(AP4_Movie* movie = (AP4_Movie*)m_pFile->GetMovie())
- {
+ if(AP4_Movie* movie = (AP4_Movie*)m_pFile->GetMovie()) {
for(AP4_List<AP4_Track>::Item* item = movie->GetTracks().FirstItem();
- item;
- item = item->GetNext())
- {
+ 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)
+ 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;
+ }
AP4_Sample sample;
- if(!AP4_SUCCEEDED(track->GetSample(0, sample)) || sample.GetDescriptionIndex() == 0xFFFFFFFF)
+ if(!AP4_SUCCEEDED(track->GetSample(0, sample)) || sample.GetDescriptionIndex() == 0xFFFFFFFF) {
continue;
+ }
CStringW TrackName = UTF8To16(track->GetTrackName().c_str());
CStringA TrackLanguage = track->GetTrackLanguage().c_str();
@@ -167,25 +168,22 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
AP4_DataBuffer empty;
- if(AP4_SampleDescription* desc = track->GetSampleDescription(sample.GetDescriptionIndex()))
- {
+ if(AP4_SampleDescription* desc = track->GetSampleDescription(sample.GetDescriptionIndex())) {
AP4_MpegSampleDescription* mpeg_desc = NULL;
- if(desc->GetType() == AP4_SampleDescription::TYPE_MPEG)
- {
+ if(desc->GetType() == AP4_SampleDescription::TYPE_MPEG) {
mpeg_desc = dynamic_cast<AP4_MpegSampleDescription*>(desc);
- }
- else if(desc->GetType() == AP4_SampleDescription::TYPE_ISMACRYP)
- {
+ } else if(desc->GetType() == AP4_SampleDescription::TYPE_ISMACRYP) {
AP4_IsmaCrypSampleDescription* isma_desc = dynamic_cast<AP4_IsmaCrypSampleDescription*>(desc);
mpeg_desc = isma_desc->GetOriginalSampleDescription();
}
- if(AP4_MpegVideoSampleDescription* video_desc =
- dynamic_cast<AP4_MpegVideoSampleDescription*>(mpeg_desc))
- {
+ if(AP4_MpegVideoSampleDescription* video_desc =
+ dynamic_cast<AP4_MpegVideoSampleDescription*>(mpeg_desc)) {
const AP4_DataBuffer* di = video_desc->GetDecoderInfo();
- if(!di) di = &empty;
+ if(!di) {
+ di = &empty;
+ }
mt.majortype = MEDIATYPE_Video;
mt.formattype = FORMAT_VideoInfo;
@@ -197,68 +195,68 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
vih->bmiHeader.biHeight = (LONG)video_desc->GetHeight();
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* vih = (MPEG2VIDEOINFO*)mt.AllocFormatBuffer(FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) + di->GetDataSize());
- memset(vih, 0, mt.FormatLength());
- vih->hdr.bmiHeader.biSize = sizeof(vih->hdr.bmiHeader);
- vih->hdr.bmiHeader.biWidth = (LONG)video_desc->GetWidth();
- vih->hdr.bmiHeader.biHeight = (LONG)video_desc->GetHeight();
- vih->hdr.bmiHeader.biCompression = 'v4pm';
- vih->hdr.bmiHeader.biPlanes = 1;
- vih->hdr.bmiHeader.biBitCount = 24;
- vih->hdr.dwPictAspectRatioX = vih->hdr.bmiHeader.biWidth;
- vih->hdr.dwPictAspectRatioY = vih->hdr.bmiHeader.biHeight;
- vih->cbSequenceHeader = di->GetDataSize();
- memcpy(vih->dwSequenceHeader, di->GetData(), di->GetDataSize());
- mts.Add(mt);
- mt.subtype = FOURCCMap(vih->hdr.bmiHeader.biCompression = 'V4PM');
- mts.Add(mt);
- }
- 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;
+ switch(video_desc->GetObjectTypeId()) {
+ case AP4_MPEG4_VISUAL_OTI:
+ mt.subtype = FOURCCMap('v4pm');
+ mt.formattype = FORMAT_MPEG2Video;
+ {
+ MPEG2VIDEOINFO* vih = (MPEG2VIDEOINFO*)mt.AllocFormatBuffer(FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader) + di->GetDataSize());
+ memset(vih, 0, mt.FormatLength());
+ vih->hdr.bmiHeader.biSize = sizeof(vih->hdr.bmiHeader);
+ vih->hdr.bmiHeader.biWidth = (LONG)video_desc->GetWidth();
+ vih->hdr.bmiHeader.biHeight = (LONG)video_desc->GetHeight();
+ vih->hdr.bmiHeader.biCompression = 'v4pm';
+ vih->hdr.bmiHeader.biPlanes = 1;
+ vih->hdr.bmiHeader.biBitCount = 24;
+ vih->hdr.dwPictAspectRatioX = vih->hdr.bmiHeader.biWidth;
+ vih->hdr.dwPictAspectRatioY = vih->hdr.bmiHeader.biHeight;
+ vih->cbSequenceHeader = di->GetDataSize();
+ memcpy(vih->dwSequenceHeader, di->GetData(), di->GetDataSize());
+ mts.Add(mt);
+ mt.subtype = FOURCCMap(vih->hdr.bmiHeader.biCompression = 'V4PM');
+ mts.Add(mt);
+ }
+ 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)
- {
+ 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))
- {
+ } else if(AP4_MpegAudioSampleDescription* audio_desc =
+ dynamic_cast<AP4_MpegAudioSampleDescription*>(mpeg_desc)) {
const AP4_DataBuffer* di = audio_desc->GetDecoderInfo();
- if(!di) di = &empty;
+ if(!di) {
+ di = &empty;
+ }
mt.majortype = MEDIATYPE_Audio;
mt.formattype = FORMAT_WaveFormatEx;
@@ -274,103 +272,96 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
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: // ???
- mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_AAC);
- if(wfe->cbSize >= 2) wfe->nChannels = (((BYTE*)(wfe+1))[1]>>3) & 0xf;
- 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;
+ 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: // ???
+ mt.subtype = FOURCCMap(wfe->wFormatTag = WAVE_FORMAT_AAC);
+ if(wfe->cbSize >= 2) {
+ wfe->nChannels = (((BYTE*)(wfe+1))[1]>>3) & 0xf;
+ }
+ 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;
}
- if(mt.subtype == GUID_NULL)
- {
+ 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))
- {
+ } 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;
- }
+ if(!di) {
+ di = &empty;
+ }
- 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);
- }
+ 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;
+ }
- 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;
+ 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)
- {
+ 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
- {
+ } 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))
- {
+ || dynamic_cast<AP4_Tx3gSampleEntry*>(sample_entry)) {
mt.majortype = MEDIATYPE_Subtitle;
mt.subtype = MEDIASUBTYPE_ASS2;
mt.formattype = FORMAT_SubtitleInfo;
@@ -384,7 +375,7 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
"[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.cx,
m_framesize.cy);
SUBTITLEINFO* si = (SUBTITLEINFO*)mt.AllocFormatBuffer(sizeof(SUBTITLEINFO) + hdr.GetLength());
memset(si, 0, mt.FormatLength());
@@ -395,14 +386,13 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
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)))
- {
+ } 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))) {
const AP4_DataBuffer* di = avcC->GetDecoderInfo();
- if(!di) di = &empty;
+ if(!di) {
+ di = &empty;
+ }
const AP4_Byte* data = di->GetData();
AP4_Size size = di->GetDataSize();
@@ -421,8 +411,9 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
vih->hdr.bmiHeader.biBitCount = 24;
vih->hdr.dwPictAspectRatioX = vih->hdr.bmiHeader.biWidth;
vih->hdr.dwPictAspectRatioY = vih->hdr.bmiHeader.biHeight;
- if (item->GetData()->GetSampleCount() > 1)
+ if (item->GetData()->GetSampleCount() > 1) {
vih->hdr.AvgTimePerFrame = item->GetData()->GetDurationMs()*10000 / (item->GetData()->GetSampleCount()-1);
+ }
vih->dwProfile = data[1];
vih->dwLevel = data[3];
vih->dwFlags = (data[4] & 3) + 1;
@@ -435,14 +426,15 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
BYTE* src_end = (BYTE*)data + size;
BYTE* dst_end = (BYTE*)vih->dwSequenceHeader + size;
- for(int i = 0; i < 2; i++)
- {
- for(int n = *src++ & 0x1f; n > 0; n--)
- {
+ 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;}
+ if(src + len > src_end || dst + len > dst_end) {
+ ASSERT(0);
+ break;
+ }
memcpy(dst, src, len);
- src += len;
+ src += len;
dst += len;
vih->cbSequenceHeader += len;
}
@@ -453,44 +445,33 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
mt.subtype = FOURCCMap(vih->hdr.bmiHeader.biCompression = '1CVA');
mts.Add(mt);
}
- }
- else if(AP4_StsdAtom* stsd = dynamic_cast<AP4_StsdAtom*>(
- track->GetTrakAtom()->FindChild("mdia/minf/stbl/stsd")))
- {
+ } 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())
- {
+ 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;
- if((type & 0xffff0000) == AP4_ATOM_TYPE('m', 's', 0, 0))
- {
+ if((type & 0xffff0000) == AP4_ATOM_TYPE('m', 's', 0, 0)) {
fourcc = type & 0xffff;
- }
- else if(type == AP4_ATOM_TYPE__MP3)
- {
+ } else if(type == AP4_ATOM_TYPE__MP3) {
fourcc = 0x0055;
- }
- else if((type == AP4_ATOM_TYPE__AC3) || (type == AP4_ATOM_TYPE_SAC3))
- {
+ } else if((type == AP4_ATOM_TYPE__AC3) || (type == AP4_ATOM_TYPE_SAC3)) {
fourcc = 0x2000;
- }
- else
- {
- fourcc =
+ } else {
+ fourcc =
((type >> 24) & 0x000000ff) |
((type >> 8) & 0x0000ff00) |
((type << 8) & 0x00ff0000) |
((type << 24) & 0xff000000);
}
- if(AP4_VisualSampleEntry* vse = dynamic_cast<AP4_VisualSampleEntry*>(atom))
- {
+ if(AP4_VisualSampleEntry* vse = dynamic_cast<AP4_VisualSampleEntry*>(atom)) {
mt.majortype = MEDIATYPE_Video;
mt.subtype = FOURCCMap(fourcc);
mt.formattype = FORMAT_VideoInfo;
@@ -511,8 +492,7 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
strlwr((char*)&buff);
AP4_Atom::Type typelwr = *(AP4_Atom::Type*)buff;
- if(typelwr != fourcc)
- {
+ if(typelwr != fourcc) {
mt.subtype = FOURCCMap(vih->bmiHeader.biCompression = typelwr);
mts.Add(mt);
}
@@ -520,28 +500,27 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
strupr((char*)&buff);
AP4_Atom::Type typeupr = *(AP4_Atom::Type*)buff;
- if(typeupr != fourcc)
- {
+ if(typeupr != fourcc) {
mt.subtype = FOURCCMap(vih->bmiHeader.biCompression = typeupr);
mts.Add(mt);
}
break;
- }
- else if(AP4_AudioSampleEntry* ase = dynamic_cast<AP4_AudioSampleEntry*>(atom))
- {
- if (ase->IsLittleEndian()==1)
- {
+ } else if(AP4_AudioSampleEntry* ase = dynamic_cast<AP4_AudioSampleEntry*>(atom)) {
+ if (ase->IsLittleEndian()==1) {
if (type==AP4_ATOM_TYPE_IN24 || type==AP4_ATOM_TYPE_IN32 ||
- type==AP4_ATOM_TYPE_FL32 || type==AP4_ATOM_TYPE_FL64)
- fourcc = type; //reverse fourcc
+ type==AP4_ATOM_TYPE_FL32 || type==AP4_ATOM_TYPE_FL64) {
+ fourcc = type; //reverse fourcc
+ }
}
mt.majortype = MEDIATYPE_Audio;
mt.subtype = FOURCCMap(fourcc);
mt.formattype = FORMAT_WaveFormatEx;
wfe = (WAVEFORMATEX*)mt.AllocFormatBuffer(sizeof(WAVEFORMATEX) + db.GetDataSize());
memset(wfe, 0, mt.FormatLength());
- if(!(fourcc & 0xffff0000)) wfe->wFormatTag = (WORD)fourcc;
+ if(!(fourcc & 0xffff0000)) {
+ wfe->wFormatTag = (WORD)fourcc;
+ }
wfe->nSamplesPerSec = ase->GetSampleRate();
wfe->nChannels = ase->GetChannelCount();
wfe->wBitsPerSample = ase->GetSampleSize();
@@ -551,37 +530,39 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
memcpy(wfe+1, db.GetData(), db.GetDataSize());
mts.Add(mt);
break;
- }else{
+ } else {
TRACE(_T("Unknow MP4 Steam %x") , fourcc);
}
}
}
- if(mts.IsEmpty()) continue;
+ if(mts.IsEmpty()) {
+ continue;
+ }
REFERENCE_TIME rtDuration = 10000i64 * track->GetDurationMs();
- if(m_rtDuration < rtDuration) m_rtDuration = rtDuration;
+ if(m_rtDuration < rtDuration) {
+ m_rtDuration = rtDuration;
+ }
DWORD id = track->GetId();
CStringW name, lang;
name.Format(L"Output %d", id);
- if(!TrackName.IsEmpty())
- {
+ if(!TrackName.IsEmpty()) {
name = TrackName;
}
- if(!TrackLanguage.IsEmpty())
- {
- if(TrackLanguage != L"und") name += " (" + TrackLanguage + ")";
+ if(!TrackLanguage.IsEmpty()) {
+ if(TrackLanguage != L"und") {
+ name += " (" + TrackLanguage + ")";
+ }
}
- for(int i = 0, j = mts.GetCount(); i < j; i++)
- {
+ for(int i = 0, j = mts.GetCount(); i < j; i++) {
BITMAPINFOHEADER bih;
- if(ExtractBIH(&mts[i], &bih))
- {
+ if(ExtractBIH(&mts[i], &bih)) {
m_framesize.cx = bih.biWidth;
m_framesize.cy = abs(bih.biHeight);
}
@@ -589,15 +570,18 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
CAutoPtr<CBaseSplitterOutputPin> pPinOut(DNew CBaseSplitterOutputPin(mts, name, this, this, &hr));
- if(!TrackName.IsEmpty()) pPinOut->SetProperty(L"NAME", TrackName);
- if(!TrackLanguage.IsEmpty()) pPinOut->SetProperty(L"LANG", CStringW(TrackLanguage));
+ 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)
- {
+ if(mts.GetCount() == 1 && mts[0].subtype == MEDIASUBTYPE_ASS2) {
LPCWSTR postfix = L" (plain text)";
mts[0].subtype = MEDIASUBTYPE_UTF8;
@@ -609,19 +593,21 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
CAutoPtr<CBaseSplitterOutputPin> pPinOut(DNew CBaseSplitterOutputPin(mts, name + postfix, this, this, &hr));
- if(!TrackName.IsEmpty()) pPinOut->SetProperty(L"NAME", TrackName + postfix);
- if(!TrackLanguage.IsEmpty()) pPinOut->SetProperty(L"LANG", CStringW(TrackLanguage));
+ 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")))
- {
+ 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++)
- {
+ 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
}
@@ -629,64 +615,88 @@ HRESULT CMP4SplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
ChapSort();
}
- if(AP4_ContainerAtom* ilst = dynamic_cast<AP4_ContainerAtom*>(movie->GetMoovAtom()->FindChild("udta/meta/ilst")))
- {
+ 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)))
- {
+ 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)
- {
+ 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);
+ if(n > 0 && n < 100) {
+ track.Format(L"%02d", n);
+ } else if(n >= 100) {
+ track.Format(L"%d", n);
+ }
}
- }
- else
- {
+ } 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;
+ 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;
+ 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(!artist.IsEmpty()) {
+ SetProperty(L"AUTH", artist);
+ } else if(!writer.IsEmpty()) {
+ SetProperty(L"AUTH", writer);
+ }
- if(!appl.IsEmpty()) SetProperty(L"APPL", appl);
+ if(!appl.IsEmpty()) {
+ SetProperty(L"APPL", appl);
+ }
- if(!desc.IsEmpty()) SetProperty(L"DESC", desc);
+ if(!desc.IsEmpty()) {
+ SetProperty(L"DESC", desc);
+ }
}
}
@@ -702,8 +712,7 @@ bool CMP4SplitterFilter::DemuxInit()
AP4_Movie* movie = (AP4_Movie*)m_pFile->GetMovie();
POSITION pos = m_trackpos.GetStartPosition();
- while(pos)
- {
+ while(pos) {
CAtlMap<DWORD, trackpos>::CPair* pPair = m_trackpos.GetNext(pos);
pPair->m_value.index = 0;
@@ -712,8 +721,9 @@ bool CMP4SplitterFilter::DemuxInit()
AP4_Track* track = movie->GetTrack(pPair->m_key);
AP4_Sample sample;
- if(AP4_SUCCEEDED(track->GetSample(0, sample)))
+ if(AP4_SUCCEEDED(track->GetSample(0, sample))) {
pPair->m_value.ts = sample.GetCts();
+ }
}
return true;
@@ -726,42 +736,48 @@ void CMP4SplitterFilter::DemuxSeek(REFERENCE_TIME rt)
AP4_Movie* movie = (AP4_Movie*)m_pFile->GetMovie();
POSITION pos = m_trackpos.GetStartPosition();
- while(pos)
- {
+ while(pos) {
CAtlMap<DWORD, trackpos>::CPair* pPair = m_trackpos.GetNext(pos);
AP4_Track* track = movie->GetTrack(pPair->m_key);
- if(AP4_FAILED(track->GetSampleIndexForTimeStampMs(ts, pPair->m_value.index)))
+ if(AP4_FAILED(track->GetSampleIndexForTimeStampMs(ts, pPair->m_value.index))) {
pPair->m_value.index = 0;
+ }
AP4_Sample sample;
- if(AP4_SUCCEEDED(track->GetSample(pPair->m_value.index, 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)
- {
+ 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() && stss->m_Entries[i]-1 <= pPair->m_value.index);
- if(i > 0) i--;
+ while(++i < stss->m_Entries.ItemCount() && stss->m_Entries[i]-1 <= pPair->m_value.index) {
+ ;
+ }
+ if(i > 0) {
+ i--;
+ }
pPair->m_value.index = stss->m_Entries[i]-1;
}
}
}
}
-struct SSACharacter {CString pre, post; WCHAR c;};
+struct SSACharacter {
+ CString pre, post;
+ WCHAR c;
+};
static CStringW ConvertTX3GToSSA(
- CStringW str,
- const AP4_Tx3gSampleEntry::AP4_Tx3gDescription& desc,
+ CStringW str,
+ const AP4_Tx3gSampleEntry::AP4_Tx3gDescription& desc,
CStringW font,
- const AP4_Byte* mods,
- int size,
+ const AP4_Byte* mods,
+ int size,
CSize framesize,
CPoint translation,
int durationms,
@@ -770,7 +786,9 @@ static CStringW ConvertTX3GToSSA(
int str_len = str.GetLength();
SSACharacter* chars = DNew SSACharacter[str_len];
- for(int i = 0; i < str_len; i++) chars[i].c = str[i];
+ for(int i = 0; i < str_len; i++) {
+ chars[i].c = str[i];
+ }
str.Empty();
//
@@ -780,21 +798,35 @@ static CStringW ConvertTX3GToSSA(
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;
+ 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));
+ 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;
@@ -809,42 +841,49 @@ static CStringW ConvertTX3GToSSA(
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);
+ 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;
+ 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(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)
- {
+ if(start < end) {
CStringW s;
s.Format(L"{\\1c%02x%02x%02x\\1a%02x}", color[2], color[1], color[0], 255 - color[3]);
@@ -856,24 +895,23 @@ static CStringW ConvertTX3GToSSA(
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[start].pre += s;
chars[end-1].post += font_flags;
}
}
- }
- else if(tag == 'hclr')
- {
+ } 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;
+ } 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)
- {
+ if(start < end) {
CStringW s;
s.Format(L"{\\3c%02x%02x%02x\\3a%02x}", hclr[2], hclr[1], hclr[0], 255 - hclr[3]);
@@ -883,20 +921,20 @@ static CStringW ConvertTX3GToSSA(
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;
+ } 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)
- {
+ if(start < end) {
// cheap...
- for(int i = 0, alpha = 255; i < durationms; i += 750, alpha = 255 - alpha)
- {
+ 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;
@@ -904,29 +942,34 @@ static CStringW ConvertTX3GToSSA(
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;
+ } 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)
- {
+ if(start < end) {
CStringW s;
s.Format(L"{\\kt%d\\kf%d}", start_time/10, (end_time - start_time)/10);
@@ -945,8 +988,7 @@ static CStringW ConvertTX3GToSSA(
// continous karaoke
- if(desc.DisplayFlags & 0x800)
- {
+ if(desc.DisplayFlags & 0x800) {
CStringW s;
s.Format(L"{\\1c%02x%02x%02x\\1a%02x}", hclr[2], hclr[1], hclr[0], 255 - hclr[3]);
@@ -954,22 +996,17 @@ static CStringW ConvertTX3GToSSA(
int breaks = 0;
- for(int i = 0, j = 0; i <= str_len; i++)
- {
- if(chars[i].c == '\n' /*|| chars[i].c == ' '*/)
- {
+ for(int i = 0, j = 0; i <= str_len; i++) {
+ if(chars[i].c == '\n' /*|| chars[i].c == ' '*/) {
breaks++;
}
}
- if(str_len > 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 == ' '*/)
- {
+ 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;
@@ -980,11 +1017,12 @@ static CStringW ConvertTX3GToSSA(
//
- for(int i = 0; i < str_len; i++)
- {
+ for(int i = 0; i < str_len; i++) {
str += chars[i].pre;
str += chars[i].c;
- if(desc.DisplayFlags & 0x20000) str += L"\\N";
+ if(desc.DisplayFlags & 0x20000) {
+ str += L"\\N";
+ }
str += chars[i].post;
}
@@ -992,20 +1030,28 @@ static CStringW ConvertTX3GToSSA(
//
- if(rbox.IsRectEmpty()) rbox.SetRect(0, 0, framesize.cx, framesize.cy);
+ 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;}
+ 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);
+ 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);
//
@@ -1018,31 +1064,32 @@ bool CMP4SplitterFilter::DemuxLoop()
AP4_Movie* movie = (AP4_Movie*)m_pFile->GetMovie();
- while(SUCCEEDED(hr) && !CheckRequest(NULL))
- {
+ while(SUCCEEDED(hr) && !CheckRequest(NULL)) {
CAtlMap<DWORD, trackpos>::CPair* pPairNext = NULL;
REFERENCE_TIME rtNext = 0;
POSITION pos = m_trackpos.GetStartPosition();
- while(pos)
- {
+ 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;
+ 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))
- {
+ if(pPair->m_value.index < track->GetSampleCount() && (!pPairNext || rt < rtNext)) {
pPairNext = pPair;
rtNext = rt;
}
}
- if(!pPairNext) break;
+ if(!pPairNext) {
+ break;
+ }
AP4_Track* track = movie->GetTrack(pPairNext->m_key);
@@ -1051,8 +1098,7 @@ bool CMP4SplitterFilter::DemuxLoop()
AP4_Sample sample;
AP4_DataBuffer data;
- if(pPin && pPin->IsConnected() && AP4_SUCCEEDED(track->ReadSample(pPairNext->m_value.index, sample, 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());
@@ -1063,29 +1109,26 @@ bool CMP4SplitterFilter::DemuxLoop()
// 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)
- {
+ if(AP4_StssAtom* stss = dynamic_cast<AP4_StssAtom*>(track->GetTrakAtom()->FindChild("mdia/minf/stbl/stss"))) {
+ if(stss->m_Entries.ItemCount() > 0) {
p->bSyncPoint = FALSE;
AP4_Cardinal i = -1;
while(++i < stss->m_Entries.ItemCount())
- if(stss->m_Entries[i]-1 == pPairNext->m_value.index)
+ if(stss->m_Entries[i]-1 == pPairNext->m_value.index) {
p->bSyncPoint = TRUE;
+ }
}
}
//
- if(track->GetType() == AP4_Track::TYPE_AUDIO && data.GetDataSize() == 1)
- {
+ if(track->GetType() == AP4_Track::TYPE_AUDIO && data.GetDataSize() == 1) {
WAVEFORMATEX* wfe = (WAVEFORMATEX*)mt.Format();
int nBlockAlign = 1200;
- if(wfe->nBlockAlign > 1)
- {
+ if(wfe->nBlockAlign > 1) {
nBlockAlign = wfe->nBlockAlign;
pPairNext->m_value.index -= pPairNext->m_value.index % wfe->nBlockAlign;
}
@@ -1094,109 +1137,102 @@ bool CMP4SplitterFilter::DemuxLoop()
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)))
- {
+ while(AP4_SUCCEEDED(track->ReadSample(pPairNext->m_value.index, sample, data))) {
AP4_Size size = data.GetDataSize();
const AP4_Byte* ptr = data.GetData();
- for(int i = 0; i < size; i++) p->Add(ptr[i]);
+ for(int i = 0; i < size; i++) {
+ p->Add(ptr[i]);
+ }
- if(fFirst) {p->rtStart = p->rtStop = (REFERENCE_TIME)(10000000.0 / track->GetMediaTimeScale() * sample.GetCts()); fFirst = false;}
+ if(fFirst) {
+ p->rtStart = p->rtStop = (REFERENCE_TIME)(10000000.0 / track->GetMediaTimeScale() * sample.GetCts());
+ fFirst = false;
+ }
p->rtStop += (REFERENCE_TIME)(10000000.0 / track->GetMediaTimeScale() * sample.GetDuration());
- if(pPairNext->m_value.index+1 >= track->GetSampleCount() || p->GetCount() >= nBlockAlign)
+ if(pPairNext->m_value.index+1 >= track->GetSampleCount() || p->GetCount() >= nBlockAlign) {
break;
+ }
pPairNext->m_value.index++;
}
- }
- else if(track->GetType() == AP4_Track::TYPE_TEXT)
- {
+ } 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)
- {
+ if(avail > 2) {
AP4_UI16 size = (ptr[0] << 8) | ptr[1];
- if(size <= avail-2)
- {
+ if(size <= avail-2) {
CStringA str;
- if(size >= 2 && ptr[2] == 0xfe && ptr[3] == 0xff)
- {
+ 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));
+ for(int i = 0; i < wstr.GetLength(); i++) {
+ wstr.SetAt(i, ((WORD)wstr[i] >> 8) | ((WORD)wstr[i] << 8));
+ }
str = UTF16To8(wstr);
- }
- else
- {
+ } else {
str = CStringA((LPCSTR)&ptr[2], size);
}
CStringA dlgln = str;
- if(mt.subtype == MEDIASUBTYPE_ASS2)
- {
+ 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)))
- {
+ 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
- {
+ 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))
- {
+ 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))
- {
+ } 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)))
- {
+ 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)))
+ 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);
+ 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])
- {
+ 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],
+ "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.left, rbox.top,
rbox.right, rbox.top,
rbox.right, rbox.bottom,
rbox.left, rbox.bottom);
@@ -1212,8 +1248,7 @@ bool CMP4SplitterFilter::DemuxLoop()
}
}
- if(!dlgln_bkg.IsEmpty())
- {
+ if(!dlgln_bkg.IsEmpty()) {
CAutoPtr<Packet> p2(DNew Packet());
p2->TrackNumber = p->TrackNumber;
p2->rtStart = p->rtStart;
@@ -1223,8 +1258,7 @@ bool CMP4SplitterFilter::DemuxLoop()
hr = DeliverPacket(p2);
}
- if(!dlgln_plaintext.IsEmpty())
- {
+ if(!dlgln_plaintext.IsEmpty()) {
CAutoPtr<Packet> p2(DNew Packet());
p2->TrackNumber = p->TrackNumber ^ 0x80402010;
p2->rtStart = p->rtStart;
@@ -1233,9 +1267,7 @@ bool CMP4SplitterFilter::DemuxLoop()
p2->SetData((LPCSTR)dlgln_plaintext, dlgln_plaintext.GetLength());
hr = DeliverPacket(p2);
}
- }
- else
- {
+ } else {
p->SetData(data.GetData(), data.GetDataSize());
}
@@ -1244,8 +1276,9 @@ bool CMP4SplitterFilter::DemuxLoop()
{
AP4_Sample sample;
- if(AP4_SUCCEEDED(track->GetSample(++pPairNext->m_value.index, sample)))
+ if(AP4_SUCCEEDED(track->GetSample(++pPairNext->m_value.index, sample))) {
pPairNext->m_value.ts = sample.GetCts();
+ }
}
}
@@ -1259,22 +1292,23 @@ STDMETHODIMP CMP4SplitterFilter::GetKeyFrameCount(UINT& nKFs)
{
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();
POSITION pos = m_trackpos.GetStartPosition();
- while(pos)
- {
+ while(pos) {
CAtlMap<DWORD, trackpos>::CPair* pPair = m_trackpos.GetNext(pos);
AP4_Track* track = movie->GetTrack(pPair->m_key);
- if(track->GetType() != AP4_Track::TYPE_VIDEO)
+ if(track->GetType() != AP4_Track::TYPE_VIDEO) {
continue;
+ }
- if(AP4_StssAtom* stss = dynamic_cast<AP4_StssAtom*>(track->GetTrakAtom()->FindChild("mdia/minf/stbl/stss")))
- {
+ if(AP4_StssAtom* stss = dynamic_cast<AP4_StssAtom*>(track->GetTrakAtom()->FindChild("mdia/minf/stbl/stss"))) {
nKFs = stss->m_Entries.ItemCount();
return S_OK;
}
@@ -1289,31 +1323,34 @@ STDMETHODIMP CMP4SplitterFilter::GetKeyFrames(const GUID* pFormat, REFERENCE_TIM
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();
POSITION pos = m_trackpos.GetStartPosition();
- while(pos)
- {
+ while(pos) {
CAtlMap<DWORD, trackpos>::CPair* pPair = m_trackpos.GetNext(pos);
AP4_Track* track = movie->GetTrack(pPair->m_key);
- if(track->GetType() != AP4_Track::TYPE_VIDEO)
+ if(track->GetType() != AP4_Track::TYPE_VIDEO) {
continue;
+ }
- if(AP4_StssAtom* stss = dynamic_cast<AP4_StssAtom*>(track->GetTrakAtom()->FindChild("mdia/minf/stbl/stss")))
- {
+ if(AP4_StssAtom* stss = dynamic_cast<AP4_StssAtom*>(track->GetTrakAtom()->FindChild("mdia/minf/stbl/stss"))) {
nKFs = 0;
- for(AP4_Cardinal i = 0; i < stss->m_Entries.ItemCount(); i++)
- {
+ for(AP4_Cardinal i = 0; i < stss->m_Entries.ItemCount(); i++) {
AP4_Sample sample;
- if(AP4_SUCCEEDED(track->GetSample(stss->m_Entries[i]-1, sample)))
+ if(AP4_SUCCEEDED(track->GetSample(stss->m_Entries[i]-1, sample))) {
pKFs[nKFs++] = 10000000i64 * sample.GetCts() / track->GetMediaTimeScale();
+ }
}
return S_OK;
@@ -1347,8 +1384,9 @@ void CMPEG4VideoSplitterFilter::SkipUserData()
{
m_pFile->BitByteAlign();
while(m_pFile->BitRead(32, true) == 0x000001b2)
- while(m_pFile->BitRead(24, true) != 0x000001)
+ while(m_pFile->BitRead(24, true) != 0x000001) {
m_pFile->BitRead(8);
+ }
}
HRESULT CMPEG4VideoSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
@@ -1359,8 +1397,13 @@ HRESULT CMPEG4VideoSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
m_pFile.Free();
m_pFile.Attach(DNew CBaseSplitterFileEx(pAsyncReader, hr));
- if(!m_pFile) return E_OUTOFMEMORY;
- if(FAILED(hr)) {m_pFile.Free(); return 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;
@@ -1373,36 +1416,31 @@ HRESULT CMPEG4VideoSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
BYTE pary = 1;
REFERENCE_TIME atpf = 400000;
- if(m_pFile->BitRead(24, true) != 0x000001)
+ if(m_pFile->BitRead(24, true) != 0x000001) {
return E_FAIL;
+ }
BYTE id;
- while(m_pFile->NextMpegStartCode(id, 1024 - m_pFile->GetPos()))
- {
- if(id == 0xb5)
- {
+ 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)
- {
+ 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)
- {
+
+ if(visual_object_type == 1 || visual_object_type == 2) {
BYTE video_signal_type = (BYTE)m_pFile->BitRead(1);
-
- if(video_signal_type)
- {
+
+ 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)
- {
+ 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);
@@ -1412,111 +1450,147 @@ HRESULT CMPEG4VideoSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
SkipUserData();
- if(visual_object_type == 1)
- {
- if(m_pFile->BitRead(24) != 0x000001)
+ 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)
+ if(video_object_start_code < 0x00 || video_object_start_code > 0x1f) {
break;
+ }
- if(m_pFile->BitRead(24) != 0x000001)
+ 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)
+ 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
+ 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)
- {
+ 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;
+ 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)
- {
+ 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)
- {
+ if(vbv_parameters) {
WORD first_half_bit_rate = (WORD)m_pFile->BitRead(15);
- if(!m_pFile->BitRead(1)) break;
+ if(!m_pFile->BitRead(1)) {
+ break;
+ }
WORD latter_half_bit_rate = (WORD)m_pFile->BitRead(15);
- if(!m_pFile->BitRead(1)) break;
+ if(!m_pFile->BitRead(1)) {
+ break;
+ }
WORD first_half_vbv_buffer_size = (WORD)m_pFile->BitRead(15);
- if(!m_pFile->BitRead(1)) break;
+ 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;
+ if(!m_pFile->BitRead(1)) {
+ break;
+ }
WORD latter_half_vbv_occupancy = (WORD)m_pFile->BitRead(15);
- if(!m_pFile->BitRead(1)) break;
+ 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)
- {
+ 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;
+ if(!m_pFile->BitRead(1)) {
+ break;
+ }
WORD vop_time_increment_resolution = (WORD)m_pFile->BitRead(16);
- if(!m_pFile->BitRead(1)) break;
+ if(!m_pFile->BitRead(1)) {
+ break;
+ }
BYTE fixed_vop_rate = (BYTE)m_pFile->BitRead(1);
- if(fixed_vop_rate)
- {
+ if(fixed_vop_rate) {
int bits = 0;
- for(WORD i = vop_time_increment_resolution; i; i /= 2)
+ 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)
- {
+ 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;
+ 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;
+ if(!m_pFile->BitRead(1)) {
+ break;
+ }
height = (WORD)m_pFile->BitRead(13);
- if(!m_pFile->BitRead(1)) break;
+ if(!m_pFile->BitRead(1)) {
+ break;
+ }
}
BYTE interlaced = (BYTE)m_pFile->BitRead(1);
@@ -1525,15 +1599,14 @@ HRESULT CMPEG4VideoSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
// ...
}
}
- }
- else if(id == 0xb6)
- {
- m_seqhdrsize = m_pFile->GetPos() - 4;
+ } else if(id == 0xb6) {
+ m_seqhdrsize = m_pFile->GetPos() - 4;
}
}
- if(!width || !height)
+ if(!width || !height) {
return E_FAIL;
+ }
CAtlArray<CMediaType> mts;
@@ -1592,28 +1665,26 @@ bool CMPEG4VideoSplitterFilter::DemuxLoop()
DWORD sync = ~0;
- while(SUCCEEDED(hr) && !CheckRequest(NULL) && m_pFile->GetRemaining())
- {
- for(int i = 0; i < 65536; i++) // don't call CheckRequest so often
- {
+ 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))
- {
+ if(p && !p->IsEmpty() && (m_pFile->BitRead(32, true) == 0x000001b6 || eof)) {
hr = DeliverPacket(p);
}
- if(eof) break;
+ if(eof) {
+ break;
+ }
- if(!p)
- {
+ if(!p) {
p.Attach(DNew Packet());
p->SetCount(0, 1024);
p->TrackNumber = 0;
- p->rtStart = rt;
+ p->rtStart = rt;
p->rtStop = rt + atpf;
p->bSyncPoint = FALSE;
- rt += atpf;
+ rt += atpf;
// rt = Packet::INVALID_TIME;
}
diff --git a/src/filters/parser/MP4Splitter/MP4Splitter.h b/src/filters/parser/MP4Splitter/MP4Splitter.h
index 62d4e9c30..49f7b243a 100644
--- a/src/filters/parser/MP4Splitter/MP4Splitter.h
+++ b/src/filters/parser/MP4Splitter/MP4Splitter.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -27,9 +27,12 @@
#include "../BaseSplitter/BaseSplitter.h"
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;};
+ struct trackpos {
+ DWORD /*AP4_Ordinal*/ index;
+ unsigned __int64 /*AP4_TimeStamp*/ ts;
+ };
CAtlMap<DWORD, trackpos> m_trackpos;
CSize m_framesize;
@@ -52,7 +55,7 @@ public:
};
class __declspec(uuid("3CCC052E-BDEE-408a-BEA7-90914EF2964B"))
-CMP4SourceFilter : public CMP4SplitterFilter
+ CMP4SourceFilter : public CMP4SplitterFilter
{
public:
CMP4SourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
@@ -61,7 +64,7 @@ public:
// for raw mpeg4 elementary streams:
class __declspec(uuid("D3D9D58B-45B5-48AB-B199-B8C40560AEC7"))
-CMPEG4VideoSplitterFilter : public CBaseSplitterFilter
+ CMPEG4VideoSplitterFilter : public CBaseSplitterFilter
{
__int64 m_seqhdrsize;
int NextStartCode();
@@ -80,7 +83,7 @@ public:
};
class __declspec(uuid("E2B98EEA-EE55-4E9B-A8C1-6E5288DF785A"))
-CMPEG4VideoSourceFilter : public CMPEG4VideoSplitterFilter
+ CMPEG4VideoSourceFilter : public CMPEG4VideoSplitterFilter
{
public:
CMPEG4VideoSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
diff --git a/src/filters/parser/MP4Splitter/MP4SplitterFile.cpp b/src/filters/parser/MP4Splitter/MP4SplitterFile.cpp
index c28950291..88ce5ebfa 100644
--- a/src/filters/parser/MP4Splitter/MP4SplitterFile.cpp
+++ b/src/filters/parser/MP4Splitter/MP4SplitterFile.cpp
@@ -2,11 +2,13 @@
#include "MP4SplitterFile.h"
#include "Ap4AsyncReaderStream.h"
-CMP4SplitterFile::CMP4SplitterFile(IAsyncReader* pReader, HRESULT& hr)
+CMP4SplitterFile::CMP4SplitterFile(IAsyncReader* pReader, HRESULT& hr)
: CBaseSplitterFileEx(pReader, hr, DEFAULT_CACHE_LENGTH, false)
, m_pAp4File(NULL)
{
- if(FAILED(hr)) return;
+ if(FAILED(hr)) {
+ return;
+ }
hr = Init();
}
@@ -31,7 +33,7 @@ HRESULT CMP4SplitterFile::Init()
AP4_ByteStream* stream = DNew AP4_AsyncReaderStream(this);
m_pAp4File = DNew AP4_File(*stream);
-
+
AP4_Movie* movie = ((AP4_File*)m_pAp4File)->GetMovie();
stream->Release();
diff --git a/src/filters/parser/MP4Splitter/stdafx.cpp b/src/filters/parser/MP4Splitter/stdafx.cpp
index 13934d005..bea3f980a 100644
--- a/src/filters/parser/MP4Splitter/stdafx.cpp
+++ b/src/filters/parser/MP4Splitter/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/parser/MP4Splitter/stdafx.h b/src/filters/parser/MP4Splitter/stdafx.h
index cdc946aa0..9b252ac14 100644
--- a/src/filters/parser/MP4Splitter/stdafx.h
+++ b/src/filters/parser/MP4Splitter/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/parser/MatroskaSplitter/MatroskaFile.cpp b/src/filters/parser/MatroskaSplitter/MatroskaFile.cpp
index e498af087..8fc4b7afa 100644
--- a/src/filters/parser/MatroskaSplitter/MatroskaFile.cpp
+++ b/src/filters/parser/MatroskaSplitter/MatroskaFile.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -25,15 +25,14 @@
#include "../../../thirdparty/zlib/zlib.h"
#define DOCTYPE _T("matroska")
-#define DOCTYPE_WEBM _T("webm")
+#define DOCTYPE_WEBM _T("webm")
#define DOCTYPEVERSION 2
static void LOG(LPCTSTR fmt, ...)
{
va_list args;
va_start(args, fmt);
- if(FILE* f = _tfopen(_T("c:\\matroskasplitterlog.txt"), _T("at")))
- {
+ if(FILE* f = _tfopen(_T("c:\\matroskasplitterlog.txt"), _T("at"))) {
fseek(f, 0, 2);
_vftprintf(f, fmt, args);
fclose(f);
@@ -53,46 +52,50 @@ using namespace MatroskaReader;
{ \
switch(pMN->m_id) \
{ \
-
+
#define EndChunk \
} \
} \
while(pMN->Next()); \
\
return S_OK; \
-
+
static void bswap(BYTE* s, int len)
{
- for(BYTE* d = s + len-1; s < d; s++, d--)
+ for(BYTE* d = s + len-1; s < d; s++, d--) {
*s ^= *d, *d ^= *s, *s ^= *d;
+ }
}
//
// CMatroskaFile
//
-CMatroskaFile::CMatroskaFile(IAsyncReader* pAsyncReader, HRESULT& hr)
+CMatroskaFile::CMatroskaFile(IAsyncReader* pAsyncReader, HRESULT& hr)
: CBaseSplitterFile(pAsyncReader, hr, DEFAULT_CACHE_LENGTH, false)
, m_rtOffset(0)
{
- if(FAILED(hr)) return;
+ if(FAILED(hr)) {
+ return;
+ }
hr = Init();
}
HRESULT CMatroskaFile::Init()
{
DWORD dw;
- if(FAILED(Read(dw)) || dw != 0x1A45DFA3)
+ if(FAILED(Read(dw)) || dw != 0x1A45DFA3) {
return E_FAIL;
+ }
CMatroskaNode Root(this);
- if(FAILED(Parse(&Root)))
+ if(FAILED(Parse(&Root))) {
return E_FAIL;
+ }
CAutoPtr<CMatroskaNode> pSegment, pCluster;
if((pSegment = Root.Child(0x18538067))
- && (pCluster = pSegment->Child(0x1F43B675)))
- {
+ && (pCluster = pSegment->Child(0x1F43B675))) {
Cluster c0;
c0.ParseTimeCode(pCluster);
m_rtOffset = m_segment.GetRefTime(c0.TimeCode);
@@ -105,19 +108,26 @@ template <class T>
HRESULT CMatroskaFile::Read(T& var)
{
HRESULT hr = ByteRead((BYTE*)&var, sizeof(var));
- if(S_OK == hr) bswap((BYTE*)&var, sizeof(var));
+ if(S_OK == hr) {
+ bswap((BYTE*)&var, sizeof(var));
+ }
return hr;
}
HRESULT CMatroskaFile::Parse(CMatroskaNode* pMN0)
{
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;
- case 0x18538067: if(m_segment.SegmentInfo.SegmentUID.IsEmpty()) m_segment.ParseMinimal(pMN); break;
+case 0x1A45DFA3:
+ 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
}
@@ -126,13 +136,27 @@ HRESULT CMatroskaFile::Parse(CMatroskaNode* pMN0)
HRESULT EBML::Parse(CMatroskaNode* pMN0)
{
BeginChunk
- case 0x4286: EBMLVersion.Parse(pMN); break;
- case 0x42F7: EBMLReadVersion.Parse(pMN); break;
- case 0x42F2: EBMLMaxIDLength.Parse(pMN); break;
- case 0x42F3: EBMLMaxSizeLength.Parse(pMN); break;
- case 0x4282: DocType.Parse(pMN); break;
- case 0x4287: DocTypeVersion.Parse(pMN); break;
- case 0x4285: DocTypeReadVersion.Parse(pMN); break;
+case 0x4286:
+ EBMLVersion.Parse(pMN);
+ break;
+case 0x42F7:
+ EBMLReadVersion.Parse(pMN);
+ break;
+case 0x42F2:
+ EBMLMaxIDLength.Parse(pMN);
+ break;
+case 0x42F3:
+ EBMLMaxSizeLength.Parse(pMN);
+ break;
+case 0x4282:
+ DocType.Parse(pMN);
+ break;
+case 0x4287:
+ DocTypeVersion.Parse(pMN);
+ break;
+case 0x4285:
+ DocTypeReadVersion.Parse(pMN);
+ break;
EndChunk
}
@@ -141,14 +165,28 @@ HRESULT Segment::Parse(CMatroskaNode* pMN0)
pos = pMN0->GetPos();
BeginChunk
- case 0x1549A966: SegmentInfo.Parse(pMN); break;
- case 0x114D9B74: MetaSeekInfo.Parse(pMN); break;
- case 0x1654AE6B: Tracks.Parse(pMN); break;
- case 0x1F43B675: Clusters.Parse(pMN); break;
- case 0x1C53BB6B: Cues.Parse(pMN); break;
- case 0x1941A469: Attachments.Parse(pMN); break;
- case 0x1043A770: Chapters.Parse(pMN); break;
-// case 0x1254C367: Tags.Parse(pMN); break;
+case 0x1549A966:
+ SegmentInfo.Parse(pMN);
+ break;
+case 0x114D9B74:
+ MetaSeekInfo.Parse(pMN);
+ break;
+case 0x1654AE6B:
+ Tracks.Parse(pMN);
+ break;
+case 0x1F43B675:
+ Clusters.Parse(pMN);
+ break;
+case 0x1C53BB6B:
+ Cues.Parse(pMN);
+ break;
+case 0x1941A469:
+ Attachments.Parse(pMN);
+ break;
+case 0x1043A770:
+ Chapters.Parse(pMN);
+ break;
+ // case 0x1254C367: Tags.Parse(pMN); break;
EndChunk
}
@@ -160,53 +198,65 @@ HRESULT Segment::ParseMinimal(CMatroskaNode* pMN0)
len = pMN0->m_len;
CAutoPtr<CMatroskaNode> pMN = pMN0->Child();
- if(!pMN) return S_FALSE;
+ if(!pMN) {
+ return S_FALSE;
+ }
int n = 0;
- do
- {
- switch(pMN->m_id)
- {
- case 0x1549A966: SegmentInfo.Parse(pMN); n++; break;
- case 0x114D9B74: MetaSeekInfo.Parse(pMN); n++; break;
- case 0x1654AE6B: Tracks.Parse(pMN); n++; break;
- case 0x1C53BB6B: Cues.Parse(pMN); break;
+ do {
+ switch(pMN->m_id) {
+ case 0x1549A966:
+ SegmentInfo.Parse(pMN);
+ n++;
+ break;
+ case 0x114D9B74:
+ MetaSeekInfo.Parse(pMN);
+ n++;
+ break;
+ case 0x1654AE6B:
+ Tracks.Parse(pMN);
+ n++;
+ break;
+ case 0x1C53BB6B:
+ Cues.Parse(pMN);
+ break;
}
- }
- while(n < 3 && pMN->Next());
+ } while(n < 3 && pMN->Next());
- if(!pMN->IsRandomAccess())
- {
+ if(!pMN->IsRandomAccess()) {
return S_OK;
}
- while(MatroskaReader::QWORD pos = pMN->FindPos(0x114D9B74, pMN->GetPos()))
- {
+ while(MatroskaReader::QWORD pos = pMN->FindPos(0x114D9B74, pMN->GetPos())) {
pMN->SeekTo(pos);
pMN->Parse();
- if(pMN->m_id != 0x114D9B74) {ASSERT(0); break;}
+ if(pMN->m_id != 0x114D9B74) {
+ ASSERT(0);
+ break;
+ }
MetaSeekInfo.Parse(pMN);
}
- if(n == 3)
- {
- if(Cues.IsEmpty() && (pMN = pMN0->Child(0x1C53BB6B, false)))
- {
- do {Cues.Parse(pMN);}
- while(pMN->Next(true));
+ if(n == 3) {
+ 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(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));
+ if(Attachments.IsEmpty() && (pMN = pMN0->Child(0x1941A469, false))) {
+ do {
+ Attachments.Parse(pMN); /*BIG UGLY HACK:*/
+ break;
+ } while (pMN->Next(true));
}
}
@@ -218,43 +268,44 @@ UINT64 Segment::GetMasterTrack()
UINT64 TrackNumber = 0, AltTrackNumber = 0;
POSITION pos1 = Tracks.GetHeadPosition();
- while(pos1 && TrackNumber == 0)
- {
+ while(pos1 && TrackNumber == 0) {
Track* pT = Tracks.GetNext(pos1);
-
+
POSITION pos2 = pT->TrackEntries.GetHeadPosition();
- while(pos2 && TrackNumber == 0)
- {
+ while(pos2 && TrackNumber == 0) {
TrackEntry* pTE = pT->TrackEntries.GetNext(pos2);
- if(pTE->TrackType == TrackEntry::TypeVideo)
- {
+ if(pTE->TrackType == TrackEntry::TypeVideo) {
TrackNumber = pTE->TrackNumber;
break;
- }
- else if(pTE->TrackType == TrackEntry::TypeAudio && AltTrackNumber == 0)
- {
+ } 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;
}
ChapterAtom* ChapterAtom::FindChapterAtom(UINT64 id)
{
- if(ChapterUID == id)
+ if(ChapterUID == id) {
return(this);
+ }
POSITION pos = ChapterAtoms.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
ChapterAtom* ca = ChapterAtoms.GetNext(pos)->FindChapterAtom(id);
- if(ca) return ca;
+ if(ca) {
+ return ca;
+ }
}
return(NULL);
@@ -263,17 +314,14 @@ ChapterAtom* ChapterAtom::FindChapterAtom(UINT64 id)
ChapterAtom* Segment::FindChapterAtom(UINT64 id, int nEditionEntry)
{
POSITION pos1 = Chapters.GetHeadPosition();
- while(pos1)
- {
+ while(pos1) {
Chapter* c = Chapters.GetNext(pos1);
POSITION pos2 = c->EditionEntries.GetHeadPosition();
- while(pos2)
- {
+ while(pos2) {
EditionEntry* ee = c->EditionEntries.GetNext(pos2);
- if(nEditionEntry-- == 0)
- {
+ if(nEditionEntry-- == 0) {
return id == 0 ? ee : ee->FindChapterAtom(id);
}
}
@@ -285,70 +333,155 @@ ChapterAtom* Segment::FindChapterAtom(UINT64 id, int nEditionEntry)
HRESULT Info::Parse(CMatroskaNode* pMN0)
{
BeginChunk
- case 0x73A4: SegmentUID.Parse(pMN); break;
- case 0x7384: SegmentFilename.Parse(pMN); break;
- case 0x3CB923: PrevUID.Parse(pMN); break;
- case 0x3C83AB: PrevFilename.Parse(pMN); break;
- case 0x3EB923: NextUID.Parse(pMN); break;
- case 0x3E83BB: NextFilename.Parse(pMN); break;
- case 0x2AD7B1: TimeCodeScale.Parse(pMN); break;
- case 0x4489: Duration.Parse(pMN); break;
- case 0x4461: DateUTC.Parse(pMN); break;
- case 0x7BA9: Title.Parse(pMN); break;
- case 0x4D80: MuxingApp.Parse(pMN); break;
- case 0x5741: WritingApp.Parse(pMN); break;
+case 0x73A4:
+ SegmentUID.Parse(pMN);
+ break;
+case 0x7384:
+ SegmentFilename.Parse(pMN);
+ break;
+case 0x3CB923:
+ PrevUID.Parse(pMN);
+ break;
+case 0x3C83AB:
+ PrevFilename.Parse(pMN);
+ break;
+case 0x3EB923:
+ NextUID.Parse(pMN);
+ break;
+case 0x3E83BB:
+ NextFilename.Parse(pMN);
+ break;
+case 0x2AD7B1:
+ TimeCodeScale.Parse(pMN);
+ break;
+case 0x4489:
+ Duration.Parse(pMN);
+ break;
+case 0x4461:
+ DateUTC.Parse(pMN);
+ break;
+case 0x7BA9:
+ Title.Parse(pMN);
+ break;
+case 0x4D80:
+ MuxingApp.Parse(pMN);
+ break;
+case 0x5741:
+ WritingApp.Parse(pMN);
+ break;
EndChunk
}
HRESULT Seek::Parse(CMatroskaNode* pMN0)
{
BeginChunk
- case 0x4DBB: SeekHeads.Parse(pMN); break;
+case 0x4DBB:
+ SeekHeads.Parse(pMN);
+ break;
EndChunk
}
HRESULT SeekHead::Parse(CMatroskaNode* pMN0)
{
BeginChunk
- case 0x53AB: SeekID.Parse(pMN); break;
- case 0x53AC: SeekPosition.Parse(pMN); break;
+case 0x53AB:
+ SeekID.Parse(pMN);
+ break;
+case 0x53AC:
+ SeekPosition.Parse(pMN);
+ break;
EndChunk
}
HRESULT Track::Parse(CMatroskaNode* pMN0)
{
BeginChunk
- case 0xAE: TrackEntries.Parse(pMN); break;
+case 0xAE:
+ TrackEntries.Parse(pMN);
+ break;
EndChunk
}
HRESULT TrackEntry::Parse(CMatroskaNode* pMN0)
{
BeginChunk
- case 0xD7: TrackNumber.Parse(pMN); break;
- case 0x73C5: TrackUID.Parse(pMN); break;
- case 0x83: TrackType.Parse(pMN); break;
- case 0xB9: FlagEnabled.Parse(pMN); break;
- case 0x88: FlagDefault.Parse(pMN); break;
- case 0x9C: FlagLacing.Parse(pMN); break;
- case 0x55AA: FlagForced.Parse(pMN); break;
- case 0x6DE7: MinCache.Parse(pMN); break;
- case 0x6DF8: MaxCache.Parse(pMN); break;
- case 0x536E: Name.Parse(pMN); break;
- case 0x22B59C: Language.Parse(pMN); break;
- case 0x86: CodecID.Parse(pMN); break;
- case 0x63A2: CodecPrivate.Parse(pMN); break;
- case 0x258688: CodecName.Parse(pMN); break;
- case 0x3A9697: CodecSettings.Parse(pMN); break;
- case 0x3B4040: CodecInfoURL.Parse(pMN); break;
- case 0x26B240: CodecDownloadURL.Parse(pMN); break;
- case 0xAA: CodecDecodeAll.Parse(pMN); break;
- case 0x6FAB: TrackOverlay.Parse(pMN); break;
- case 0x23E383: case 0x2383E3: DefaultDuration.Parse(pMN); break;
- case 0x23314F: TrackTimecodeScale.Parse(pMN); break;
- case 0xE0: if(S_OK == v.Parse(pMN)) DescType |= DescVideo; break;
- case 0xE1: if(S_OK == a.Parse(pMN)) DescType |= DescAudio; break;
- case 0x6D80: ces.Parse(pMN); break;
+case 0xD7:
+ TrackNumber.Parse(pMN);
+ break;
+case 0x73C5:
+ TrackUID.Parse(pMN);
+ break;
+case 0x83:
+ TrackType.Parse(pMN);
+ break;
+case 0xB9:
+ FlagEnabled.Parse(pMN);
+ break;
+case 0x88:
+ FlagDefault.Parse(pMN);
+ break;
+case 0x9C:
+ FlagLacing.Parse(pMN);
+ break;
+case 0x55AA:
+ FlagForced.Parse(pMN);
+ break;
+case 0x6DE7:
+ MinCache.Parse(pMN);
+ break;
+case 0x6DF8:
+ MaxCache.Parse(pMN);
+ break;
+case 0x536E:
+ Name.Parse(pMN);
+ break;
+case 0x22B59C:
+ Language.Parse(pMN);
+ break;
+case 0x86:
+ CodecID.Parse(pMN);
+ break;
+case 0x63A2:
+ CodecPrivate.Parse(pMN);
+ break;
+case 0x258688:
+ CodecName.Parse(pMN);
+ break;
+case 0x3A9697:
+ CodecSettings.Parse(pMN);
+ break;
+case 0x3B4040:
+ CodecInfoURL.Parse(pMN);
+ break;
+case 0x26B240:
+ CodecDownloadURL.Parse(pMN);
+ break;
+case 0xAA:
+ CodecDecodeAll.Parse(pMN);
+ break;
+case 0x6FAB:
+ TrackOverlay.Parse(pMN);
+ break;
+case 0x23E383:
+case 0x2383E3:
+ DefaultDuration.Parse(pMN);
+ break;
+case 0x23314F:
+ TrackTimecodeScale.Parse(pMN);
+ break;
+case 0xE0:
+ if(S_OK == v.Parse(pMN)) {
+ DescType |= DescVideo;
+ }
+ break;
+case 0xE1:
+ if(S_OK == a.Parse(pMN)) {
+ DescType |= DescAudio;
+ }
+ break;
+case 0x6D80:
+ ces.Parse(pMN);
+ break;
EndChunk
}
@@ -358,32 +491,34 @@ static int cesort(const void* a, const void* b)
UINT64 ce2 = (static_cast<ContentEncoding*>(const_cast<void *>(b)))->ContentEncodingOrder;
return (int)ce1 - (int)ce2;
-//return static_cast<int>(ce1) - static_cast<int>(ce2);
+ //return static_cast<int>(ce1) - static_cast<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));
+ while(pos) {
+ cearray.Add(ces.ce.GetNext(pos));
+ }
qsort(cearray.GetData(), cearray.GetCount(), sizeof(ContentEncoding*), cesort);
- for(int i = cearray.GetCount()-1; i >= 0; i--)
- {
+ for(int i = cearray.GetCount()-1; i >= 0; i--) {
ContentEncoding* ce = cearray[i];
- if(!(ce->ContentEncodingScope & Scope))
+ if(!(ce->ContentEncodingScope & Scope)) {
continue;
+ }
- if(ce->ContentEncodingType == ContentEncoding::Compression)
- {
- if(!data.Decompress(ce->cc))
+ if(ce->ContentEncodingType == ContentEncoding::Compression) {
+ if(!data.Decompress(ce->cc)) {
return(false);
- }
- else if(ce->ContentEncodingType == ContentEncoding::Encryption)
- {
+ }
+ } else if(ce->ContentEncodingType == ContentEncoding::Encryption) {
// TODO
return(false);
}
@@ -395,102 +530,200 @@ bool TrackEntry::Expand(CBinary& data, UINT64 Scope)
HRESULT Video::Parse(CMatroskaNode* pMN0)
{
BeginChunk
- case 0x9A: FlagInterlaced.Parse(pMN); break;
- case 0x53B8: StereoMode.Parse(pMN); break;
- case 0xB0: PixelWidth.Parse(pMN);
- if (!DisplayWidth) DisplayWidth.Set(PixelWidth); break;
- case 0xBA: PixelHeight.Parse(pMN);
- if (!DisplayHeight) DisplayHeight.Set(PixelHeight); break;
- case 0x54B0: DisplayWidth.Parse(pMN); break;
- case 0x54BA: DisplayHeight.Parse(pMN); break;
- case 0x54B2: DisplayUnit.Parse(pMN); break;
- case 0x54B3: AspectRatioType.Parse(pMN); break;
- case 0x2EB524: ColourSpace.Parse(pMN); break;
- case 0x2FB523: GammaValue.Parse(pMN); break;
- case 0x2383E3: FramePerSec.Parse(pMN); break;
+case 0x9A:
+ FlagInterlaced.Parse(pMN);
+ break;
+case 0x53B8:
+ StereoMode.Parse(pMN);
+ break;
+case 0xB0:
+ PixelWidth.Parse(pMN);
+ if (!DisplayWidth) {
+ DisplayWidth.Set(PixelWidth);
+ }
+ break;
+case 0xBA:
+ PixelHeight.Parse(pMN);
+ if (!DisplayHeight) {
+ DisplayHeight.Set(PixelHeight);
+ }
+ break;
+case 0x54B0:
+ DisplayWidth.Parse(pMN);
+ break;
+case 0x54BA:
+ DisplayHeight.Parse(pMN);
+ break;
+case 0x54B2:
+ DisplayUnit.Parse(pMN);
+ break;
+case 0x54B3:
+ AspectRatioType.Parse(pMN);
+ break;
+case 0x2EB524:
+ ColourSpace.Parse(pMN);
+ break;
+case 0x2FB523:
+ GammaValue.Parse(pMN);
+ break;
+case 0x2383E3:
+ FramePerSec.Parse(pMN);
+ break;
EndChunk
}
HRESULT Audio::Parse(CMatroskaNode* pMN0)
{
BeginChunk
- case 0xB5: SamplingFrequency.Parse(pMN);
- if (!OutputSamplingFrequency) OutputSamplingFrequency.Set(SamplingFrequency); break;
- case 0x78B5: OutputSamplingFrequency.Parse(pMN); break;
- case 0x9F: Channels.Parse(pMN); break;
- case 0x7D7B: ChannelPositions.Parse(pMN); break;
- case 0x6264: BitDepth.Parse(pMN); break;
+case 0xB5:
+ SamplingFrequency.Parse(pMN);
+ if (!OutputSamplingFrequency) {
+ OutputSamplingFrequency.Set(SamplingFrequency);
+ }
+ break;
+case 0x78B5:
+ OutputSamplingFrequency.Parse(pMN);
+ break;
+case 0x9F:
+ Channels.Parse(pMN);
+ break;
+case 0x7D7B:
+ ChannelPositions.Parse(pMN);
+ break;
+case 0x6264:
+ BitDepth.Parse(pMN);
+ break;
EndChunk
}
HRESULT ContentEncodings::Parse(CMatroskaNode* pMN0)
{
BeginChunk
- case 0x6240: ce.Parse(pMN); break;
+case 0x6240:
+ ce.Parse(pMN);
+ break;
EndChunk
}
HRESULT ContentEncoding::Parse(CMatroskaNode* pMN0)
{
BeginChunk
- case 0x5031: ContentEncodingOrder.Parse(pMN); break;
- case 0x5032: ContentEncodingScope.Parse(pMN); break;
- case 0x5033: ContentEncodingType.Parse(pMN); break;
- case 0x5034: cc.Parse(pMN); break;
- case 0x5035: ce.Parse(pMN); break;
+case 0x5031:
+ ContentEncodingOrder.Parse(pMN);
+ break;
+case 0x5032:
+ ContentEncodingScope.Parse(pMN);
+ break;
+case 0x5033:
+ ContentEncodingType.Parse(pMN);
+ break;
+case 0x5034:
+ cc.Parse(pMN);
+ break;
+case 0x5035:
+ ce.Parse(pMN);
+ break;
EndChunk
}
HRESULT ContentCompression::Parse(CMatroskaNode* pMN0)
{
BeginChunk
- case 0x4254: ContentCompAlgo.Parse(pMN); break;
- case 0x4255: ContentCompSettings.Parse(pMN); break;
+case 0x4254:
+ ContentCompAlgo.Parse(pMN);
+ break;
+case 0x4255:
+ ContentCompSettings.Parse(pMN);
+ break;
EndChunk
}
HRESULT ContentEncryption::Parse(CMatroskaNode* pMN0)
{
BeginChunk
- case 0x47e1: ContentEncAlgo.Parse(pMN); break;
- case 0x47e2: ContentEncKeyID.Parse(pMN); break;
- case 0x47e3: ContentSignature.Parse(pMN); break;
- case 0x47e4: ContentSigKeyID.Parse(pMN); break;
- case 0x47e5: ContentSigAlgo.Parse(pMN); break;
- case 0x47e6: ContentSigHashAlgo.Parse(pMN); break;
+case 0x47e1:
+ ContentEncAlgo.Parse(pMN);
+ break;
+case 0x47e2:
+ ContentEncKeyID.Parse(pMN);
+ break;
+case 0x47e3:
+ ContentSignature.Parse(pMN);
+ break;
+case 0x47e4:
+ ContentSigKeyID.Parse(pMN);
+ break;
+case 0x47e5:
+ ContentSigAlgo.Parse(pMN);
+ break;
+case 0x47e6:
+ ContentSigHashAlgo.Parse(pMN);
+ break;
EndChunk
}
HRESULT Cluster::Parse(CMatroskaNode* pMN0)
{
BeginChunk
- case 0xE7: TimeCode.Parse(pMN); break;
- case 0xA7: Position.Parse(pMN); break;
- case 0xAB: PrevSize.Parse(pMN); break;
- case 0xA0: BlockGroups.Parse(pMN, true); break;
- case 0xA3: SimpleBlocks.Parse(pMN, true); break;
+case 0xE7:
+ TimeCode.Parse(pMN);
+ break;
+case 0xA7:
+ Position.Parse(pMN);
+ break;
+case 0xAB:
+ PrevSize.Parse(pMN);
+ break;
+case 0xA0:
+ BlockGroups.Parse(pMN, true);
+ break;
+case 0xA3:
+ SimpleBlocks.Parse(pMN, true);
+ break;
EndChunk
}
HRESULT Cluster::ParseTimeCode(CMatroskaNode* pMN0)
{
BeginChunk
- case 0xE7: TimeCode.Parse(pMN); return S_OK;
+case 0xE7:
+ TimeCode.Parse(pMN);
+ return S_OK;
EndChunk
}
HRESULT BlockGroup::Parse(CMatroskaNode* pMN0, bool fFull)
{
BeginChunk
- case 0xA1: Block.Parse(pMN, fFull); break;
- case 0xA2: /* TODO: multiple virt blocks? */; break;
- case 0x9B: BlockDuration.Parse(pMN); break;
- case 0xFA: ReferencePriority.Parse(pMN); break;
- case 0xFB: ReferenceBlock.Parse(pMN); break;
- case 0xFD: ReferenceVirtual.Parse(pMN); break;
- case 0xA4: CodecState.Parse(pMN); break;
- case 0xE8: TimeSlices.Parse(pMN); break;
- case 0x75A1: if(fFull) ba.Parse(pMN); break;
+case 0xA1:
+ Block.Parse(pMN, fFull);
+ break;
+case 0xA2: /* TODO: multiple virt blocks? */
+ ;
+ break;
+case 0x9B:
+ BlockDuration.Parse(pMN);
+ break;
+case 0xFA:
+ ReferencePriority.Parse(pMN);
+ break;
+case 0xFB:
+ ReferenceBlock.Parse(pMN);
+ break;
+case 0xFD:
+ ReferenceVirtual.Parse(pMN);
+ break;
+case 0xA4:
+ CodecState.Parse(pMN);
+ break;
+case 0xE8:
+ TimeSlices.Parse(pMN);
+ break;
+case 0x75A1:
+ if(fFull) {
+ ba.Parse(pMN);
+ }
+ break;
EndChunk
}
@@ -498,71 +731,75 @@ HRESULT SimpleBlock::Parse(CMatroskaNode* pMN, bool fFull)
{
pMN->SeekTo(pMN->m_start);
- TrackNumber.Parse(pMN);
- CShort s; s.Parse(pMN); TimeCode.Set(s);
+ TrackNumber.Parse(pMN);
+ CShort s;
+ s.Parse(pMN);
+ TimeCode.Set(s);
Lacing.Parse(pMN);
-
- if(!fFull) return S_OK;
+
+ 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;
+ 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)
- {
+ while(pos) {
MatroskaReader::QWORD len = lens.GetNext(pos);
CAutoPtr<CBinary> p(DNew CBinary());
p->SetCount((INT_PTR)len);
@@ -576,119 +813,191 @@ HRESULT SimpleBlock::Parse(CMatroskaNode* pMN, bool fFull)
HRESULT BlockAdditions::Parse(CMatroskaNode* pMN0)
{
BeginChunk
- case 0xA6: bm.Parse(pMN); break;
+case 0xA6:
+ bm.Parse(pMN);
+ break;
EndChunk
}
HRESULT BlockMore::Parse(CMatroskaNode* pMN0)
{
BeginChunk
- case 0xEE: BlockAddID.Parse(pMN); break;
- case 0xA5: BlockAdditional.Parse(pMN); break;
+case 0xEE:
+ BlockAddID.Parse(pMN);
+ break;
+case 0xA5:
+ BlockAdditional.Parse(pMN);
+ break;
EndChunk
}
HRESULT TimeSlice::Parse(CMatroskaNode* pMN0)
{
BeginChunk
- case 0xCC: LaceNumber.Parse(pMN); break;
- case 0xCD: FrameNumber.Parse(pMN); break;
- case 0xCE: Delay.Parse(pMN); break;
- case 0xCF: Duration.Parse(pMN); break;
+case 0xCC:
+ LaceNumber.Parse(pMN);
+ break;
+case 0xCD:
+ FrameNumber.Parse(pMN);
+ break;
+case 0xCE:
+ Delay.Parse(pMN);
+ break;
+case 0xCF:
+ Duration.Parse(pMN);
+ break;
EndChunk
}
HRESULT Cue::Parse(CMatroskaNode* pMN0)
{
BeginChunk
- case 0xBB: CuePoints.Parse(pMN); break;
+case 0xBB:
+ CuePoints.Parse(pMN);
+ break;
EndChunk
}
HRESULT CuePoint::Parse(CMatroskaNode* pMN0)
{
BeginChunk
- case 0xB3: CueTime.Parse(pMN); break;
- case 0xB7: CueTrackPositions.Parse(pMN); break;
+case 0xB3:
+ CueTime.Parse(pMN);
+ break;
+case 0xB7:
+ CueTrackPositions.Parse(pMN);
+ break;
EndChunk
}
HRESULT CueTrackPosition::Parse(CMatroskaNode* pMN0)
{
BeginChunk
- case 0xF7: CueTrack.Parse(pMN); break;
- case 0xF1: CueClusterPosition.Parse(pMN); break;
- case 0x5387: CueBlockNumber.Parse(pMN); break;
- case 0xEA: CueCodecState.Parse(pMN); break;
- case 0xDB: CueReferences.Parse(pMN); break;
+case 0xF7:
+ CueTrack.Parse(pMN);
+ break;
+case 0xF1:
+ CueClusterPosition.Parse(pMN);
+ break;
+case 0x5387:
+ CueBlockNumber.Parse(pMN);
+ break;
+case 0xEA:
+ CueCodecState.Parse(pMN);
+ break;
+case 0xDB:
+ CueReferences.Parse(pMN);
+ break;
EndChunk
}
HRESULT CueReference::Parse(CMatroskaNode* pMN0)
{
BeginChunk
- case 0x96: CueRefTime.Parse(pMN); break;
- case 0x97: CueRefCluster.Parse(pMN); break;
- case 0x535F: CueRefNumber.Parse(pMN); break;
- case 0xEB: CueRefCodecState.Parse(pMN); break;
+case 0x96:
+ CueRefTime.Parse(pMN);
+ break;
+case 0x97:
+ CueRefCluster.Parse(pMN);
+ break;
+case 0x535F:
+ CueRefNumber.Parse(pMN);
+ break;
+case 0xEB:
+ CueRefCodecState.Parse(pMN);
+ break;
EndChunk
}
HRESULT Attachment::Parse(CMatroskaNode* pMN0)
{
BeginChunk
- case 0x61A7: AttachedFiles.Parse(pMN); break;
+case 0x61A7:
+ AttachedFiles.Parse(pMN);
+ break;
EndChunk
}
HRESULT AttachedFile::Parse(CMatroskaNode* pMN0)
{
BeginChunk
- case 0x467E: FileDescription.Parse(pMN); break;
- case 0x466E: FileName.Parse(pMN); break;
- case 0x4660: FileMimeType.Parse(pMN); break;
- case 0x465C: // binary
- FileDataLen = (INT_PTR)pMN->m_len;
- FileDataPos = pMN->m_start;
- break;
- case 0x46AE: FileUID.Parse(pMN); break;
+case 0x467E:
+ FileDescription.Parse(pMN);
+ break;
+case 0x466E:
+ FileName.Parse(pMN);
+ break;
+case 0x4660:
+ FileMimeType.Parse(pMN);
+ break;
+case 0x465C: // binary
+ FileDataLen = (INT_PTR)pMN->m_len;
+ FileDataPos = pMN->m_start;
+ break;
+case 0x46AE:
+ FileUID.Parse(pMN);
+ break;
EndChunk
}
HRESULT Chapter::Parse(CMatroskaNode* pMN0)
{
BeginChunk
- case 0x45B9: EditionEntries.Parse(pMN); break;
+case 0x45B9:
+ EditionEntries.Parse(pMN);
+ break;
EndChunk
}
HRESULT EditionEntry::Parse(CMatroskaNode* pMN0)
{
BeginChunk
- case 0xB6: ChapterAtoms.Parse(pMN); break;
+case 0xB6:
+ ChapterAtoms.Parse(pMN);
+ break;
EndChunk
}
HRESULT ChapterAtom::Parse(CMatroskaNode* pMN0)
{
BeginChunk
- case 0x73C4: ChapterUID.Parse(pMN); break;
- case 0x91: ChapterTimeStart.Parse(pMN); break;
- case 0x92: ChapterTimeEnd.Parse(pMN); break;
-// case 0x8F: // TODO
- case 0x80: ChapterDisplays.Parse(pMN); break;
- case 0xB6: ChapterAtoms.Parse(pMN); break;
- case 0x98: ChapterFlagHidden.Parse(pMN); break;
- case 0x4598: ChapterFlagEnabled.Parse(pMN); break;
+case 0x73C4:
+ ChapterUID.Parse(pMN);
+ break;
+case 0x91:
+ ChapterTimeStart.Parse(pMN);
+ break;
+case 0x92:
+ ChapterTimeEnd.Parse(pMN);
+ break;
+ // case 0x8F: // TODO
+case 0x80:
+ ChapterDisplays.Parse(pMN);
+ break;
+case 0xB6:
+ ChapterAtoms.Parse(pMN);
+ break;
+case 0x98:
+ ChapterFlagHidden.Parse(pMN);
+ break;
+case 0x4598:
+ ChapterFlagEnabled.Parse(pMN);
+ break;
EndChunk
}
HRESULT ChapterDisplay::Parse(CMatroskaNode* pMN0)
{
BeginChunk
- case 0x85: ChapString.Parse(pMN); break;
- case 0x437C: ChapLanguage.Parse(pMN); break;
- case 0x437E: ChapCountry.Parse(pMN); break;
+case 0x85:
+ ChapString.Parse(pMN);
+ break;
+case 0x437C:
+ ChapLanguage.Parse(pMN);
+ break;
+case 0x437E:
+ ChapCountry.Parse(pMN);
+ break;
EndChunk
}
@@ -703,8 +1012,7 @@ HRESULT CBinary::Parse(CMatroskaNode* pMN)
bool CBinary::Compress(ContentCompression& cc)
{
- if(cc.ContentCompAlgo == ContentCompression::ZLIB)
- {
+ if(cc.ContentCompAlgo == ContentCompression::ZLIB) {
int res;
z_stream c_stream;
@@ -712,26 +1020,24 @@ bool CBinary::Compress(ContentCompression& cc)
c_stream.zfree = (free_func)0;
c_stream.opaque = (voidpf)0;
- if(Z_OK != (res = deflateInit(&c_stream, 9)))
+ if(Z_OK != (res = deflateInit(&c_stream, 9))) {
return(false);
+ }
c_stream.next_in = GetData();
c_stream.avail_in = GetCount();
BYTE* dst = NULL;
int n = 0;
- do
- {
+ 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)
- {
+ 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);
+ } while(0 == c_stream.avail_out && Z_STREAM_END != res);
deflateEnd(&c_stream);
@@ -748,8 +1054,7 @@ bool CBinary::Compress(ContentCompression& cc)
bool CBinary::Decompress(ContentCompression& cc)
{
- if(cc.ContentCompAlgo == ContentCompression::ZLIB)
- {
+ if(cc.ContentCompAlgo == ContentCompression::ZLIB) {
int res;
z_stream d_stream;
@@ -757,26 +1062,24 @@ bool CBinary::Decompress(ContentCompression& cc)
d_stream.zfree = (free_func)0;
d_stream.opaque = (voidpf)0;
- if(Z_OK != (res = inflateInit(&d_stream)))
+ if(Z_OK != (res = inflateInit(&d_stream))) {
return(false);
+ }
d_stream.next_in = GetData();
d_stream.avail_in = GetCount();
BYTE* dst = NULL;
int n = 0;
- do
- {
+ 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)
- {
+ 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);
+ } while(0 == d_stream.avail_out && 0 != d_stream.avail_in && Z_STREAM_END != res);
inflateEnd(&d_stream);
@@ -786,9 +1089,7 @@ bool CBinary::Decompress(ContentCompression& cc)
free(dst);
return(true);
- }
- else if(cc.ContentCompAlgo == ContentCompression::HDRSTRIP)
- {
+ } else if(cc.ContentCompAlgo == ContentCompression::HDRSTRIP) {
InsertArrayAt(0, &cc.ContentCompSettings);
}
@@ -801,8 +1102,9 @@ HRESULT CANSI::Parse(CMatroskaNode* pMN)
MatroskaReader::QWORD len = pMN->m_len;
CHAR c;
- while(len-- > 0 && SUCCEEDED(pMN->Read(c)))
+ while(len-- > 0 && SUCCEEDED(pMN->Read(c))) {
*this += c;
+ }
return(len == -1 ? S_OK : E_FAIL);
}
@@ -811,8 +1113,9 @@ 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))
+ 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;
@@ -821,11 +1124,12 @@ HRESULT CUTF8::Parse(CMatroskaNode* pMN)
HRESULT CUInt::Parse(CMatroskaNode* pMN)
{
m_val = 0;
- for(int i = 0; i < (int)pMN->m_len; i++)
- {
+ 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;
+ if(FAILED(hr)) {
+ return hr;
+ }
}
m_fValid = true;
return S_OK;
@@ -834,10 +1138,11 @@ HRESULT CUInt::Parse(CMatroskaNode* pMN)
HRESULT CInt::Parse(CMatroskaNode* pMN)
{
m_val = 0;
- for(int i = 0; i < (int)pMN->m_len; i++)
- {
+ for(int i = 0; i < (int)pMN->m_len; i++) {
HRESULT hr = pMN->Read(*((BYTE*)&m_val+7-i));
- if(FAILED(hr)) return hr;
+ if(FAILED(hr)) {
+ return hr;
+ }
}
m_val >>= (8-pMN->m_len)*8;
m_fValid = true;
@@ -849,16 +1154,16 @@ HRESULT CFloat::Parse(CMatroskaNode* pMN)
HRESULT hr = E_FAIL;
m_val = 0;
- if(pMN->m_len == 4)
- {
+ 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))
+ if(SUCCEEDED(hr)) {
m_fValid = true;
+ }
return hr;
}
@@ -877,21 +1182,34 @@ HRESULT CID::Parse(CMatroskaNode* pMN)
BYTE b = 0;
HRESULT hr = pMN->Read(b);
- if(FAILED(hr)) return hr;
+ 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;
+ 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)
- {
+ while(nMoreBytes-- > 0) {
m_val <<= 8;
hr = pMN->Read(*(BYTE*)&m_val);
- if(FAILED(hr)) return hr;
+ if(FAILED(hr)) {
+ return hr;
+ }
}
m_fValid = true;
@@ -905,39 +1223,60 @@ HRESULT CLength::Parse(CMatroskaNode* pMN)
BYTE b = 0;
HRESULT hr = pMN->Read(b);
- if(FAILED(hr)) return hr;
+ if(FAILED(hr)) {
+ return hr;
+ }
int nMoreBytes = 0, nMoreBytesTmp = 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;
+ }
nMoreBytesTmp = nMoreBytes;
MatroskaReader::QWORD UnknownSize = (1i64<<(7*(nMoreBytes+1)))-1;
- while(nMoreBytes-- > 0)
- {
+ while(nMoreBytes-- > 0) {
m_val <<= 8;
hr = pMN->Read(*(BYTE*)&m_val);
- if(FAILED(hr)) return hr;
+ if(FAILED(hr)) {
+ return hr;
+ }
}
- if(m_val == UnknownSize)
- {
+ 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)
+ if(m_fSigned) {
m_val -= (UnknownSize >> 1);
+ }
m_fValid = true;
@@ -996,7 +1335,9 @@ HRESULT CNode<T>::Parse(CMatroskaNode* pMN)
{
CAutoPtr<T> p(DNew T());
HRESULT hr = E_OUTOFMEMORY;
- if(!p || FAILED(hr = p->Parse(pMN))) return hr;
+ if(!p || FAILED(hr = p->Parse(pMN))) {
+ return hr;
+ }
AddTail(p);
return S_OK;
}
@@ -1005,7 +1346,9 @@ 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;
+ if(!p || FAILED(hr = p->Parse(pMN, fFull))) {
+ return hr;
+ }
AddTail(p);
return S_OK;
}
@@ -1014,7 +1357,9 @@ 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;
+ if(!p || FAILED(hr = p->Parse(pMN, fFull))) {
+ return hr;
+ }
AddTail(p);
return S_OK;
}
@@ -1027,7 +1372,7 @@ CMatroskaNode::CMatroskaNode(CMatroskaFile* pMF)
{
ASSERT(m_pMF);
m_start = m_filepos = 0;
- m_len.Set(m_pMF ? m_pMF->GetLength() : 0);
+ m_len.Set(m_pMF ? m_pMF->GetLength() : 0);
}
CMatroskaNode::CMatroskaNode(CMatroskaNode* pParent)
@@ -1040,40 +1385,46 @@ CMatroskaNode::CMatroskaNode(CMatroskaNode* pParent)
HRESULT CMatroskaNode::Parse()
{
m_filepos = GetPos();
- if(FAILED(m_id.Parse(this)) || FAILED(m_len.Parse(this)))
+ 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>();
+ if(m_len == 0) {
+ return CAutoPtr<CMatroskaNode>();
+ }
SeekTo(m_start);
CAutoPtr<CMatroskaNode> pMN(DNew CMatroskaNode(this));
- if(id && !pMN->Find(id, fSearch)) pMN.Free();
+ if(id && !pMN->Find(id, fSearch)) {
+ pMN.Free();
+ }
return pMN;
}
bool CMatroskaNode::Next(bool fSame)
{
- if(!m_pParent)
+ if(!m_pParent) {
return(false);
+ }
CID id = m_id;
- while(m_start+m_len < m_pParent->m_start+m_pParent->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())
+ if(FAILED(Parse())) {
+ if(!Resync()) {
return(false);
+ }
}
- if(!fSame || m_id == id)
+ if(!fSame || m_id == id) {
return(true);
+ }
}
return(false);
@@ -1081,45 +1432,58 @@ bool CMatroskaNode::Next(bool fSame)
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)
- {
+ if(pos) {
SeekTo(pos);
Parse();
- }
- else if(fSearch)
- {
- while(m_id != id && Next());
+ } else if(fSearch) {
+ while(m_id != id && Next()) {
+ ;
+ }
}
return(m_id == id);
}
-void CMatroskaNode::SeekTo(MatroskaReader::QWORD pos) {m_pMF->Seek(pos);}
-MatroskaReader::QWORD CMatroskaNode::GetPos() {return m_pMF->GetPos();}
-MatroskaReader::QWORD CMatroskaNode::GetLength() {return m_pMF->GetLength();}
-template <class T>
-HRESULT CMatroskaNode::Read(T& var) {return m_pMF->Read(var);}
-HRESULT CMatroskaNode::Read(BYTE* pData, MatroskaReader::QWORD len) {return m_pMF->ByteRead(pData, len);}
+void CMatroskaNode::SeekTo(MatroskaReader::QWORD pos)
+{
+ m_pMF->Seek(pos);
+}
+MatroskaReader::QWORD CMatroskaNode::GetPos()
+{
+ return m_pMF->GetPos();
+}
+MatroskaReader::QWORD CMatroskaNode::GetLength()
+{
+ return m_pMF->GetLength();
+}
+template <class T>
+HRESULT CMatroskaNode::Read(T& var)
+{
+ return m_pMF->Read(var);
+}
+HRESULT CMatroskaNode::Read(BYTE* pData, MatroskaReader::QWORD len)
+{
+ return m_pMF->ByteRead(pData, len);
+}
MatroskaReader::QWORD CMatroskaNode::FindPos(DWORD id, MatroskaReader::QWORD start)
{
Segment& sm = m_pMF->m_segment;
POSITION pos = sm.MetaSeekInfo.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
Seek* s = sm.MetaSeekInfo.GetNext(pos);
POSITION pos2 = s->SeekHeads.GetHeadPosition();
- while(pos2)
- {
+ while(pos2) {
SeekHead* sh = s->SeekHeads.GetNext(pos2);
- if(sh->SeekID == id && sh->SeekPosition+sm.pos >= start)
+ if(sh->SeekID == id && sh->SeekPosition+sm.pos >= start) {
return sh->SeekPosition+sm.pos;
+ }
}
}
@@ -1140,30 +1504,34 @@ CAutoPtr<CMatroskaNode> CMatroskaNode::Copy()
CAutoPtr<CMatroskaNode> CMatroskaNode::GetFirstBlock()
{
CAutoPtr<CMatroskaNode> pNode = Child();
- do {if(pNode->m_id == 0xA0 || pNode->m_id == 0xA3) return pNode;}
- while(pNode->Next());
+ do {
+ if(pNode->m_id == 0xA0 || pNode->m_id == 0xA3) {
+ return pNode;
+ }
+ } while(pNode->Next());
return CAutoPtr<CMatroskaNode>();
}
bool CMatroskaNode::NextBlock()
{
- if(!m_pParent)
+ if(!m_pParent) {
return(false);
+ }
CID id = m_id;
- while(m_start+m_len < m_pParent->m_start+m_pParent->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())
+ if(FAILED(Parse())) {
+ if(!Resync()) {
return(false);
+ }
}
- if(m_id == 0xA0 || m_id == 0xA3)
+ if(m_id == 0xA0 || m_id == 0xA3) {
return(true);
+ }
}
return(false);
@@ -1171,34 +1539,32 @@ bool CMatroskaNode::NextBlock()
bool CMatroskaNode::Resync()
{
- if(m_pParent->m_id == 0x18538067) /*segment?*/
- {
+ if(m_pParent->m_id == 0x18538067) { /*segment?*/
SeekTo(m_filepos);
- for(BYTE b = 0; S_OK == Read(b); b = 0)
- {
- if((b&0xf0) != 0x10)
+ for(BYTE b = 0; S_OK == Read(b); b = 0) {
+ if((b&0xf0) != 0x10) {
continue;
+ }
- DWORD dw = b;
+ 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;
+ 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;
}
}
}
diff --git a/src/filters/parser/MatroskaSplitter/MatroskaFile.h b/src/filters/parser/MatroskaSplitter/MatroskaFile.h
index 183fca217..67c1a9b2c 100644
--- a/src/filters/parser/MatroskaSplitter/MatroskaFile.h
+++ b/src/filters/parser/MatroskaSplitter/MatroskaFile.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -31,8 +31,16 @@ namespace MatroskaReader
typedef unsigned __int64 QWORD;
- class CANSI : public CStringA {public: HRESULT Parse(CMatroskaNode* pMN);};
- class CUTF8 : public CStringW {public: HRESULT Parse(CMatroskaNode* pMN);};
+ 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
@@ -42,36 +50,86 @@ namespace MatroskaReader
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;}
+ 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 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 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(), GetCount());}
+ CBinary& operator = (const CBinary& b) {
+ Copy(b);
+ return(*this);
+ }
+ CStringA ToString() {
+ return CStringA((LPCSTR)GetData(), 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 CNode : public CAutoPtrList<T>
+ {
+ public:
+ HRESULT Parse(CMatroskaNode* pMN);
+ };
class EBML
{
@@ -84,321 +142,378 @@ namespace MatroskaReader
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 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(rand());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 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 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(rand());
+ 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
{
@@ -419,7 +534,9 @@ namespace MatroskaReader
UINT64 GetMasterTrack();
- REFERENCE_TIME GetRefTime(INT64 t) const {return t*(REFERENCE_TIME)(SegmentInfo.TimeCodeScale)/100;}
+ REFERENCE_TIME GetRefTime(INT64 t) const {
+ return t*(REFERENCE_TIME)(SegmentInfo.TimeCodeScale)/100;
+ }
ChapterAtom* FindChapterAtom(UINT64 id, int nEditionEntry = 0);
};
@@ -459,7 +576,9 @@ namespace MatroskaReader
CMatroskaNode(CMatroskaFile* pMF); // creates the root
CMatroskaNode(CMatroskaNode* pParent);
- CMatroskaNode* Parent() {return m_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);
@@ -472,10 +591,12 @@ namespace MatroskaReader
HRESULT Read(BYTE* pData, QWORD len);
CAutoPtr<CMatroskaNode> Copy();
-
+
CAutoPtr<CMatroskaNode> GetFirstBlock();
bool NextBlock();
- bool IsRandomAccess() {return m_pMF->IsRandomAccess();}
+ bool IsRandomAccess() {
+ return m_pMF->IsRandomAccess();
+ }
};
}
diff --git a/src/filters/parser/MatroskaSplitter/MatroskaSplitter.cpp b/src/filters/parser/MatroskaSplitter/MatroskaSplitter.cpp
index f9ded756e..78f1b6080 100644
--- a/src/filters/parser/MatroskaSplitter/MatroskaSplitter.cpp
+++ b/src/filters/parser/MatroskaSplitter/MatroskaSplitter.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -31,26 +31,22 @@ using namespace MatroskaReader;
#ifdef REGISTER_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
{&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}
+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}
};
-const AMOVIESETUP_FILTER sudFilter[] =
-{
+const AMOVIESETUP_FILTER sudFilter[] = {
{&__uuidof(CMatroskaSplitterFilter), L"MPC - Matroska Splitter", MERIT_NORMAL, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
{&__uuidof(CMatroskaSourceFilter), L"MPC - Matroska Source", MERIT_NORMAL, 0, NULL, CLSID_LegacyAmFilterCategory},
};
-CFactoryTemplate g_Templates[] =
-{
+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]},
};
@@ -60,9 +56,9 @@ int g_cTemplates = countof(g_Templates);
STDAPI DllRegisterServer()
{
RegisterSourceFilter(
- __uuidof(CMatroskaSourceFilter),
- MEDIASUBTYPE_Matroska,
- _T("0,4,,1A45DFA3"),
+ __uuidof(CMatroskaSourceFilter),
+ MEDIASUBTYPE_Matroska,
+ _T("0,4,,1A45DFA3"),
_T(".mkv"), _T(".mka"), _T(".mks"), NULL);
return AMovieDllRegisterServer2(TRUE);
@@ -98,7 +94,7 @@ STDMETHODIMP CMatroskaSplitterFilter::NonDelegatingQueryInterface(REFIID riid, v
{
CheckPointer(ppv, E_POINTER);
- return
+ return
QI(ITrackInfo)
__super::NonDelegatingQueryInterface(riid, ppv);
}
@@ -119,8 +115,13 @@ HRESULT CMatroskaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
CAtlArray<TrackEntry*> pinOutTE;
m_pFile.Attach(DNew CMatroskaFile(pAsyncReader, hr));
- if(!m_pFile) return E_OUTOFMEMORY;
- if(FAILED(hr)) {m_pFile.Free(); return 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;
@@ -128,19 +129,18 @@ HRESULT CMatroskaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
int iVideo = 1, iAudio = 1, iSubtitle = 1;
POSITION pos = m_pFile->m_segment.Tracks.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
Track* pT = m_pFile->m_segment.Tracks.GetNext(pos);
POSITION pos2 = pT->TrackEntries.GetHeadPosition();
- while(pos2)
- {
+ while(pos2) {
TrackEntry* pTE = pT->TrackEntries.GetNext(pos2);
bool isSub = false;
- if(!pTE->Expand(pTE->CodecPrivate, ContentEncoding::TracksPrivateData))
+ if(!pTE->Expand(pTE->CodecPrivate, ContentEncoding::TracksPrivateData)) {
continue;
+ }
CStringA CodecID = pTE->CodecID.ToString();
@@ -152,82 +152,83 @@ HRESULT CMatroskaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
mt.SetSampleSize(1);
- if(pTE->TrackType == TrackEntry::TypeVideo)
- {
+ if(pTE->TrackType == TrackEntry::TypeVideo) {
Name.Format(L"Video %d", iVideo++);
mt.majortype = MEDIATYPE_Video;
- if(CodecID == "V_MS/VFW/FOURCC")
- {
+ 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;
+ 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;
}
mts.Add(mt);
- }
- else if(CodecID == "V_UNCOMPRESSED")
- {
- }
- else if(CodecID.Find("V_MPEG4/ISO/AVC") == 0 && pTE->CodecPrivate.GetCount() >= 6)
- {
+ } 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(int i = 0, j = pTE->CodecPrivate.GetCount(); i < j; i++)
- avcC.push_back(pTE->CodecPrivate[i]);
+ std::vector<BYTE> avcC;
+ for(int i = 0, j = pTE->CodecPrivate.GetCount(); i < j; i++) {
+ avcC.push_back(pTE->CodecPrivate[i]);
+ }
- std::vector<BYTE> sh;
+ std::vector<BYTE> sh;
- unsigned jj = 6;
+ 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;
- }
+ 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;
- }
+ 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;
+ goto avcsuccess;
avcfail:
- continue;
+ continue;
avcsuccess:
CAtlArray<BYTE> data;
@@ -251,9 +252,7 @@ avcsuccess:
memcpy(pSequenceHeader, data.GetData(), data.GetCount());
pm2vi->cbSequenceHeader = data.GetCount();
mts.Add(mt);
- }
- else if(CodecID.Find("V_MPEG4/") == 0)
- {
+ } 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());
@@ -268,9 +267,7 @@ avcsuccess:
memcpy(pSequenceHeader, pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
pm2vi->cbSequenceHeader = pTE->CodecPrivate.GetCount();
mts.Add(mt);
- }
- else if(CodecID.Find("V_REAL/RV") == 0)
- {
+ } 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());
@@ -281,9 +278,7 @@ avcsuccess:
pvih->bmiHeader.biHeight = (LONG)pTE->v.PixelHeight;
pvih->bmiHeader.biCompression = mt.subtype.Data1;
mts.Add(mt);
- }
- else if(CodecID == "V_DIRAC")
- {
+ } 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());
@@ -299,19 +294,16 @@ avcsuccess:
dvih->cbSequenceHeader = pTE->CodecPrivate.GetCount();
mts.Add(mt);
- }
- else if(CodecID == "V_MPEG2")
- {
+ } else if(CodecID == "V_MPEG2") {
BYTE* seqhdr = pTE->CodecPrivate.GetData();
DWORD len = pTE->CodecPrivate.GetCount();
int w = pTE->v.PixelWidth;
int h = pTE->v.PixelHeight;
- if(MakeMPEG2MediaType(mt, seqhdr, len, w, h))
+ if(MakeMPEG2MediaType(mt, seqhdr, len, w, h)) {
mts.Add(mt);
- }
- else if(CodecID == "V_THEORA")
- {
+ }
+ } else if(CodecID == "V_THEORA") {
BYTE* thdr = pTE->CodecPrivate.GetData() + 3;
mt.majortype = MEDIATYPE_Video;
@@ -327,7 +319,9 @@ avcsuccess:
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);
+ 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;
@@ -336,58 +330,51 @@ avcsuccess:
memcpy (&vih->dwSequenceHeader, pTE->CodecPrivate.GetData(), vih->cbSequenceHeader);
mts.Add(mt);
- }
- 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;
- mts.Add(mt);
- }
-/*
- else if(CodecID == "V_DSHOW/MPEG1VIDEO") // V_MPEG1
- {
- mt.majortype = MEDIATYPE_Video;
- mt.subtype = MEDIASUBTYPE_MPEG1Payload;
- mt.formattype = FORMAT_MPEGVideo;
- MPEG1VIDEOINFO* pm1vi = (MPEG1VIDEOINFO*)mt.AllocFormatBuffer(pTE->CodecPrivate.GetCount());
- memcpy(pm1vi, pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
- mt.SetSampleSize(pm1vi->hdr.bmiHeader.biWidth*pm1vi->hdr.bmiHeader.biHeight*4);
+ } 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;
mts.Add(mt);
}
-*/
+ /*
+ else if(CodecID == "V_DSHOW/MPEG1VIDEO") // V_MPEG1
+ {
+ mt.majortype = MEDIATYPE_Video;
+ mt.subtype = MEDIASUBTYPE_MPEG1Payload;
+ mt.formattype = FORMAT_MPEGVideo;
+ MPEG1VIDEOINFO* pm1vi = (MPEG1VIDEOINFO*)mt.AllocFormatBuffer(pTE->CodecPrivate.GetCount());
+ memcpy(pm1vi, pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
+ mt.SetSampleSize(pm1vi->hdr.bmiHeader.biWidth*pm1vi->hdr.bmiHeader.biHeight*4);
+ mts.Add(mt);
+ }
+ */
REFERENCE_TIME AvgTimePerFrame = 0;
- if(pTE->v.FramePerSec > 0)
+ if(pTE->v.FramePerSec > 0) {
AvgTimePerFrame = (REFERENCE_TIME)(10000000i64 / pTE->v.FramePerSec);
- else if(pTE->DefaultDuration > 0)
+ } else if(pTE->DefaultDuration > 0) {
AvgTimePerFrame = (REFERENCE_TIME)pTE->DefaultDuration / 100;
+ }
- if(AvgTimePerFrame)
- {
- for(int i = 0; i < mts.GetCount(); i++)
- {
+ if(AvgTimePerFrame) {
+ for(int 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_VideoInfo2
+ || mts[i].formattype == FORMAT_MPEG2Video) {
((VIDEOINFOHEADER*)mts[i].Format())->AvgTimePerFrame = AvgTimePerFrame;
}
}
}
- if(pTE->v.DisplayWidth != 0 && pTE->v.DisplayHeight != 0)
- {
- for(int i = 0; i < mts.GetCount(); i++)
- {
- if(mts[i].formattype == FORMAT_VideoInfo)
- {
+ if(pTE->v.DisplayWidth != 0 && pTE->v.DisplayHeight != 0) {
+ for(int i = 0; i < mts.GetCount(); i++) {
+ if(mts[i].formattype == FORMAT_VideoInfo) {
DWORD vih1 = FIELD_OFFSET(VIDEOINFOHEADER, bmiHeader);
DWORD vih2 = FIELD_OFFSET(VIDEOINFOHEADER2, bmiHeader);
DWORD bmi = mts[i].FormatLength() - FIELD_OFFSET(VIDEOINFOHEADER, bmiHeader);
@@ -399,17 +386,13 @@ avcsuccess:
((VIDEOINFOHEADER2*)mt.Format())->dwPictAspectRatioX = (DWORD)pTE->v.DisplayWidth;
((VIDEOINFOHEADER2*)mt.Format())->dwPictAspectRatioY = (DWORD)pTE->v.DisplayHeight;
mts.InsertAt(i++, mt);
- }
- else if(mts[i].formattype == FORMAT_MPEG2Video)
- {
+ } else if(mts[i].formattype == FORMAT_MPEG2Video) {
((MPEG2VIDEOINFO*)mts[i].Format())->hdr.dwPictAspectRatioX = (DWORD)pTE->v.DisplayWidth;
((MPEG2VIDEOINFO*)mts[i].Format())->hdr.dwPictAspectRatioY = (DWORD)pTE->v.DisplayHeight;
}
}
}
- }
- else if(pTE->TrackType == TrackEntry::TypeAudio)
- {
+ } else if(pTE->TrackType == TrackEntry::TypeAudio) {
Name.Format(L"Audio %d", iAudio++);
mt.majortype = MEDIATYPE_Audio;
@@ -425,8 +408,7 @@ avcsuccess:
static CAtlMap<CStringA, int, CStringElementTraits<CStringA> > id2ft;
- if(id2ft.IsEmpty())
- {
+ if(id2ft.IsEmpty()) {
id2ft["A_MPEG/L3"] = WAVE_FORMAT_MP3;
id2ft["A_MPEG/L2"] = WAVE_FORMAT_MPEG;
id2ft["A_MPEG/L1"] = WAVE_FORMAT_MPEG;
@@ -444,10 +426,8 @@ avcsuccess:
}
int wFormatTag;
- if(id2ft.Lookup(CodecID, wFormatTag))
- {
- if(wFormatTag < 0)
- {
+ if(id2ft.Lookup(CodecID, wFormatTag)) {
+ if(wFormatTag < 0) {
wFormatTag = -wFormatTag;
wfe->cbSize = pTE->CodecPrivate.GetCount();
wfe = (WAVEFORMATEX*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEX) + pTE->CodecPrivate.GetCount());
@@ -457,32 +437,30 @@ avcsuccess:
mt.subtype = FOURCCMap(wfe->wFormatTag = wFormatTag);
mts.Add(mt);
- if(wFormatTag == WAVE_FORMAT_FLAC)
- {
+ if(wFormatTag == WAVE_FORMAT_FLAC) {
mt.subtype = MEDIASUBTYPE_FLAC_FRAMED;
mts.InsertAt(0, mt);
}
- }
- else if(CodecID == "A_VORBIS")
- {
+ } else if(CodecID == "A_VORBIS") {
BYTE* p = pTE->CodecPrivate.GetData();
CAtlArray<int> sizes;
- for(BYTE n = *p++; n > 0; n--)
- {
+ for(BYTE n = *p++; n > 0; n--) {
int size = 0;
- do {size += *p;} while(*p++ == 0xff);
+ do {
+ size += *p;
+ } while(*p++ == 0xff);
sizes.Add(size);
}
int totalsize = 0;
- for(int i = 0; i < sizes.GetCount(); i++)
+ for(int i = 0; i < sizes.GetCount(); i++) {
totalsize += sizes[i];
+ }
sizes.Add(pTE->CodecPrivate.GetCount() - (p - pTE->CodecPrivate.GetData()) - totalsize);
totalsize += sizes[sizes.GetCount()-1];
- if(sizes.GetCount() == 3)
- {
+ if(sizes.GetCount() == 3) {
mt.subtype = MEDIASUBTYPE_Vorbis2;
mt.formattype = FORMAT_VorbisFormat2;
VORBISFORMAT2* pvf2 = (VORBISFORMAT2*)mt.AllocFormatBuffer(sizeof(VORBISFORMAT2) + totalsize);
@@ -491,8 +469,9 @@ avcsuccess:
pvf2->SamplesPerSec = (DWORD)pTE->a.SamplingFrequency;
pvf2->BitsPerSample = (DWORD)pTE->a.BitDepth;
BYTE* p2 = mt.Format() + sizeof(VORBISFORMAT2);
- for(int i = 0; i < sizes.GetCount(); p += sizes[i], p2 += sizes[i], i++)
+ for(int i = 0; i < sizes.GetCount(); p += sizes[i], p2 += sizes[i], i++) {
memcpy(p2, p, pvf2->HeaderSize[i] = sizes[i]);
+ }
mts.Add(mt);
}
@@ -505,44 +484,44 @@ avcsuccess:
vf->nSamplesPerSec = (DWORD)pTE->a.SamplingFrequency;
vf->nMinBitsPerSec = vf->nMaxBitsPerSec = vf->nAvgBitsPerSec = (DWORD)-1;
mts.Add(mt);
- }
- else if(CodecID == "A_MS/ACM")
- {
+ } else if(CodecID == "A_MS/ACM") {
wfe = (WAVEFORMATEX*)mt.AllocFormatBuffer(pTE->CodecPrivate.GetCount());
memcpy(wfe, (WAVEFORMATEX*)pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
mt.subtype = FOURCCMap(wfe->wFormatTag);
mts.Add(mt);
- }
- else if(CodecID.Find("A_AAC/") == 0)
- {
+ } 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;
+ 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, pTE->a.Channels);
mts.Add(mt);
- if(profile < 0)
- {
+ 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)
- {
+ } 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 = pTE->CodecPrivate.GetCount();
@@ -551,25 +530,22 @@ avcsuccess:
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(pTE->TrackType == TrackEntry::TypeSubtitle)
- {
- if(iSubtitle == 1) InstallFonts();
+ } else if(pTE->TrackType == TrackEntry::TypeSubtitle) {
+ if(iSubtitle == 1) {
+ InstallFonts();
+ }
Name.Format(L"Subtitle %d", iSubtitle++);
mt.SetSampleSize(1);
- if(CodecID == "S_TEXT/ASCII")
- {
+ if(CodecID == "S_TEXT/ASCII") {
mt.majortype = MEDIATYPE_Text;
mt.subtype = MEDIASUBTYPE_NULL;
mt.formattype = FORMAT_None;
mts.Add(mt);
isSub = true;
- }
- else
- {
+ } else {
mt.majortype = MEDIATYPE_Subtitle;
mt.formattype = FORMAT_SubtitleInfo;
SUBTITLEINFO* psi = (SUBTITLEINFO*)mt.AllocFormatBuffer(sizeof(SUBTITLEINFO) + pTE->CodecPrivate.GetCount());
@@ -578,7 +554,7 @@ avcsuccess:
wcsncpy(psi->TrackName, pTE->Name, countof(psi->TrackName)-1);
memcpy(mt.pbFormat + (psi->dwOffset = sizeof(SUBTITLEINFO)), pTE->CodecPrivate.GetData(), pTE->CodecPrivate.GetCount());
- mt.subtype =
+ 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 :
@@ -595,22 +571,25 @@ avcsuccess:
}
}
- if(mts.IsEmpty())
- {
+ 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")");
+ + (pTE->Name.IsEmpty() ? L"" : L", " + pTE->Name)
+ + (L" (" + Name + L")");
HRESULT hr;
CAutoPtr<CBaseSplitterOutputPin> pPinOut(DNew CMatroskaSplitterOutputPin((int)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(!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((int)pTE->MinCache, pTE->DefaultDuration/100, mts, Name, this, this, &hr),1);
pinOutTE.InsertAt((iVideo+iAudio-3),pTE,1);
@@ -627,20 +606,18 @@ avcsuccess:
CAutoPtr<CBaseSplitterOutputPin> pPinOut;
pPinOut.Attach(pinOut[i]);
TrackEntry* pTE = pinOutTE[i];
-
- if (pTE != NULL)
- {
+
+ 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())
- {
+ if(m_pFile->IsRandomAccess()) {
m_rtDuration = (REFERENCE_TIME)(info.Duration * info.TimeCodeScale / 100);
}
@@ -666,32 +643,32 @@ avcsuccess:
{
POSITION pos = m_pFile->m_segment.Attachments.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
Attachment* pA = m_pFile->m_segment.Attachments.GetNext(pos);
POSITION pos = pA->AttachedFiles.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
AttachedFile* pF = pA->AttachedFiles.GetNext(pos);
CAtlArray<BYTE> pData;
pData.SetCount(pF->FileDataLen);
m_pFile->Seek(pF->FileDataPos);
- if(SUCCEEDED(m_pFile->ByteRead(pData.GetData(), pData.GetCount())))
+ if(SUCCEEDED(m_pFile->ByteRead(pData.GetData(), pData.GetCount()))) {
ResAppend(pF->FileName, pF->FileDescription, CStringW(pF->FileMimeType), pData.GetData(), pData.GetCount());
+ }
}
}
}
// chapters
- if(ChapterAtom* caroot = m_pFile->m_segment.FindChapterAtom(0))
- {
+ 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";
+ if(ChapLanguage.GetLength() < 3) {
+ ChapLanguage = "eng";
+ }
SetupChapters(ChapLanguage, caroot);
}
@@ -703,36 +680,38 @@ void CMatroskaSplitterFilter::SetupChapters(LPCSTR lng, ChapterAtom* parent, int
{
CStringW tabs('+', level);
- if(!tabs.IsEmpty()) tabs += ' ';
+ if(!tabs.IsEmpty()) {
+ tabs += ' ';
+ }
POSITION pos = parent->ChapterAtoms.GetHeadPosition();
- while(pos)
- {
+ 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)
- {
+ if(ca) {
CStringW name, first;
POSITION pos = ca->ChapterDisplays.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
ChapterDisplay* cd = ca->ChapterDisplays.GetNext(pos);
- if(first.IsEmpty()) first = cd->ChapString;
- if(cd->ChapLanguage == lng) name = cd->ChapString;
+ 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())
- {
+ if(!ca->ChapterAtoms.IsEmpty()) {
SetupChapters(lng, ca, level+1);
}
- }
+ }
}
}
@@ -740,25 +719,22 @@ void CMatroskaSplitterFilter::SetupChapters(LPCSTR lng, ChapterAtom* parent, int
void CMatroskaSplitterFilter::InstallFonts()
{
POSITION pos = m_pFile->m_segment.Attachments.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
Attachment* pA = m_pFile->m_segment.Attachments.GetNext(pos);
POSITION p2 = pA->AttachedFiles.GetHeadPosition();
- while(p2)
- {
+ while(p2) {
AttachedFile* pF = pA->AttachedFiles.GetNext(p2);
- if(pF->FileMimeType == "application/x-truetype-font")
- {
+ if(pF->FileMimeType == "application/x-truetype-font") {
// assume this is a font resource
- if(BYTE* pData = DNew BYTE[(UINT)pF->FileDataLen])
- {
+ if(BYTE* pData = DNew BYTE[(UINT)pF->FileDataLen]) {
m_pFile->Seek(pF->FileDataPos);
- if(SUCCEEDED(m_pFile->ByteRead(pData, pF->FileDataLen)))
+ if(SUCCEEDED(m_pFile->ByteRead(pData, pF->FileDataLen))) {
m_fontinst.InstallFont(pData, (UINT)pF->FileDataLen);
+ }
delete [] pData;
}
@@ -772,28 +748,28 @@ void CMatroskaSplitterFilter::SendVorbisHeaderSample()
HRESULT hr;
POSITION pos = m_pTrackEntryMap.GetStartPosition();
- while(pos)
- {
+ while(pos) {
DWORD TrackNumber = 0;
TrackEntry* pTE = NULL;
m_pTrackEntryMap.GetNextAssoc(pos, TrackNumber, pTE);
CBaseSplitterOutputPin* pPin = GetOutputPin(TrackNumber);
- if(!(pTE && pPin && pPin->IsConnected()))
+ if(!(pTE && pPin && pPin->IsConnected())) {
continue;
+ }
if(pTE->CodecID.ToString() == "A_VORBIS" && pPin->CurrentMediaType().subtype == MEDIASUBTYPE_Vorbis
- && pTE->CodecPrivate.GetCount() > 0)
- {
+ && pTE->CodecPrivate.GetCount() > 0) {
BYTE* ptr = pTE->CodecPrivate.GetData();
CAtlList<int> sizes;
long last = 0;
- for(BYTE n = *ptr++; n > 0; n--)
- {
+ for(BYTE n = *ptr++; n > 0; n--) {
int size = 0;
- do {size += *ptr;} while(*ptr++ == 0xff);
+ do {
+ size += *ptr;
+ } while(*ptr++ == 0xff);
sizes.AddTail(size);
last += size;
}
@@ -802,23 +778,24 @@ void CMatroskaSplitterFilter::SendVorbisHeaderSample()
hr = S_OK;
POSITION pos = sizes.GetHeadPosition();
- while(pos && SUCCEEDED(hr))
- {
+ 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->rtStart = 0;
+ p->rtStop = 1;
p->bSyncPoint = FALSE;
-
+
p->SetData(ptr, len);
ptr += len;
-
+
hr = DeliverPacket(p);
}
- if(FAILED(hr))
+ if(FAILED(hr)) {
TRACE(_T("ERROR: Vorbis initialization failed for stream %I64d\n"), TrackNumber);
+ }
}
}
}
@@ -829,14 +806,14 @@ bool CMatroskaSplitterFilter::DemuxInit()
CMatroskaNode Root(m_pFile);
if(!m_pFile
- || !(m_pSegment = Root.Child(0x18538067))
- || !(m_pCluster = m_pSegment->Child(0x1F43B675)))
+ || !(m_pSegment = Root.Child(0x18538067))
+ || !(m_pCluster = m_pSegment->Child(0x1F43B675))) {
return(false);
+ }
// reindex if needed
- if(m_pFile->IsRandomAccess() && m_pFile->m_segment.Cues.GetCount() == 0)
- {
+ if(m_pFile->IsRandomAccess() && m_pFile->m_segment.Cues.GetCount() == 0) {
m_nOpenProgress = 0;
m_pFile->m_segment.SegmentInfo.Duration.Set(0);
@@ -844,8 +821,7 @@ bool CMatroskaSplitterFilter::DemuxInit()
CAutoPtr<Cue> pCue(DNew Cue());
- do
- {
+ do {
Cluster c;
c.ParseTimeCode(m_pCluster);
@@ -862,17 +838,20 @@ bool CMatroskaSplitterFilter::DemuxInit()
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);
+ if(CheckRequest(&cmd)) {
+ if(cmd == CMD_EXIT) {
+ m_fAbort = true;
+ } else {
+ Reply(S_OK);
+ }
}
- }
- while(!m_fAbort && m_pCluster->Next(true));
+ } while(!m_fAbort && m_pCluster->Next(true));
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;
}
@@ -888,8 +867,7 @@ void CMatroskaSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
m_pCluster = m_pSegment->Child(0x1F43B675);
m_pBlock.Free();
- if(rt > 0)
- {
+ if(rt > 0) {
rt += m_pFile->m_rtOffset;
MatroskaReader::QWORD lastCueClusterPosition = (MatroskaReader::QWORD)-1;
@@ -899,28 +877,28 @@ void CMatroskaSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
UINT64 TrackNumber = s.GetMasterTrack();
POSITION pos1 = s.Cues.GetHeadPosition();
- while(pos1)
- {
+ while(pos1) {
Cue* pCue = s.Cues.GetNext(pos1);
POSITION pos2 = pCue->CuePoints.GetTailPosition();
- while(pos2)
- {
+ while(pos2) {
CuePoint* pCuePoint = pCue->CuePoints.GetPrev(pos2);
- if(rt < s.GetRefTime(pCuePoint->CueTime))
+ if(rt < s.GetRefTime(pCuePoint->CueTime)) {
continue;
+ }
POSITION pos3 = pCuePoint->CueTrackPositions.GetHeadPosition();
- while(pos3)
- {
+ while(pos3) {
CueTrackPosition* pCueTrackPositions = pCuePoint->CueTrackPositions.GetNext(pos3);
- if(TrackNumber != pCueTrackPositions->CueTrack)
+ if(TrackNumber != pCueTrackPositions->CueTrack) {
continue;
+ }
- if(lastCueClusterPosition == pCueTrackPositions->CueClusterPosition)
+ if(lastCueClusterPosition == pCueTrackPositions->CueClusterPosition) {
continue;
+ }
lastCueClusterPosition = pCueTrackPositions->CueClusterPosition;
@@ -928,68 +906,60 @@ void CMatroskaSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
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
-*/
+ /*
+ 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())
- {
+ if(CAutoPtr<CMatroskaNode> pBlock = m_pCluster->GetFirstBlock()) {
bool fPassedCueTime = false;
- do
- {
+ do {
CBlockGroupNode bgn;
- if(pBlock->m_id == 0xA0)
- {
+ if(pBlock->m_id == 0xA0) {
bgn.Parse(pBlock, true);
- }
- else if(pBlock->m_id == 0xA3)
- {
+ } 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
+ if(!(bg->Block.Lacing & 0x80)) {
+ bg->ReferenceBlock.Set(0); // not a kf
+ }
bgn.AddTail(bg);
}
POSITION pos4 = bgn.GetHeadPosition();
- while(!fPassedCueTime && pos4)
- {
+ 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
- {
+ || 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())
- {
+ } else if(bg->Block.TrackNumber == pCueTrackPositions->CueTrack && !bg->ReferenceBlock.IsValid()) {
fFoundKeyFrame = true;
m_pBlock = pBlock->Copy();
}
}
- }
- while(!fPassedCueTime && pBlock->NextBlock());
+ } while(!fPassedCueTime && pBlock->NextBlock());
}
}
- if(fFoundKeyFrame)
+ if(fFoundKeyFrame) {
pos1 = pos2 = pos3 = NULL;
+ }
}
}
}
- if(!m_pBlock)
- {
+ if(!m_pBlock) {
m_pCluster = m_pSegment->Child(0x1F43B675);
}
}
@@ -998,35 +968,35 @@ void CMatroskaSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
bool CMatroskaSplitterFilter::DemuxLoop()
{
HRESULT hr = S_OK;
-
+
SendVorbisHeaderSample(); // HACK: init vorbis decoder with the headers
- do
- {
+ do {
Cluster c;
c.ParseTimeCode(m_pCluster);
- if(!m_pBlock) m_pBlock = m_pCluster->GetFirstBlock();
- if(!m_pBlock) continue;
+ if(!m_pBlock) {
+ m_pBlock = m_pCluster->GetFirstBlock();
+ }
+ if(!m_pBlock) {
+ continue;
+ }
- do
- {
+ do {
CBlockGroupNode bgn;
- if(m_pBlock->m_id == 0xA0)
- {
+ if(m_pBlock->m_id == 0xA0) {
bgn.Parse(m_pBlock, true);
- }
- else if(m_pBlock->m_id == 0xA3)
- {
+ } 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
+ if(!(bg->Block.Lacing & 0x80)) {
+ bg->ReferenceBlock.Set(0); // not a kf
+ }
bgn.AddTail(bg);
}
- while(bgn.GetCount() && SUCCEEDED(hr))
- {
+ while(bgn.GetCount() && SUCCEEDED(hr)) {
CAutoPtr<MatroskaPacket> p(DNew MatroskaPacket());
p->bg = bgn.RemoveHead();
@@ -1034,22 +1004,22 @@ bool CMatroskaSplitterFilter::DemuxLoop()
p->TrackNumber = (DWORD)p->bg->Block.TrackNumber;
TrackEntry* pTE = NULL;
-
- if (!m_pTrackEntryMap.Lookup (p->TrackNumber, pTE) || !pTE) continue;
+
+ 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())
- {
+ 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)
- {
+ while(pos) {
CBinary* pb = p->bg->Block.BlockData.GetNext(pos);
pTE->Expand(*pb, ContentEncoding::AllFrameContents);
}
@@ -1060,13 +1030,11 @@ bool CMatroskaSplitterFilter::DemuxLoop()
hr = DeliverPacket(p);
}
- }
- while(m_pBlock->NextBlock() && SUCCEEDED(hr) && !CheckRequest(NULL));
+ } while(m_pBlock->NextBlock() && SUCCEEDED(hr) && !CheckRequest(NULL));
m_pBlock.Free();
- }
- while(m_pFile->GetPos() < m_pFile->m_segment.pos + m_pFile->m_segment.len
- && m_pCluster->Next(true) && SUCCEEDED(hr) && !CheckRequest(NULL));
+ } while(m_pFile->GetPos() < m_pFile->m_segment.pos + m_pFile->m_segment.len
+ && m_pCluster->Next(true) && SUCCEEDED(hr) && !CheckRequest(NULL));
m_pCluster.Free();
@@ -1077,14 +1045,18 @@ bool CMatroskaSplitterFilter::DemuxLoop()
STDMETHODIMP CMatroskaSplitterFilter::GetKeyFrameCount(UINT& nKFs)
{
- if(!m_pFile) return E_UNEXPECTED;
+ if(!m_pFile) {
+ return E_UNEXPECTED;
+ }
HRESULT hr = S_OK;
nKFs = 0;
POSITION pos = m_pFile->m_segment.Cues.GetHeadPosition();
- while(pos) nKFs += m_pFile->m_segment.Cues.GetNext(pos)->CuePoints.GetCount();
+ while(pos) {
+ nKFs += m_pFile->m_segment.Cues.GetNext(pos)->CuePoints.GetCount();
+ }
return hr;
}
@@ -1094,19 +1066,23 @@ STDMETHODIMP CMatroskaSplitterFilter::GetKeyFrames(const GUID* pFormat, REFERENC
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;
POSITION pos1 = m_pFile->m_segment.Cues.GetHeadPosition();
- while(pos1 && nKFsTmp < nKFs)
- {
+ while(pos1 && nKFsTmp < nKFs) {
Cue* pCue = m_pFile->m_segment.Cues.GetNext(pos1);
POSITION pos2 = pCue->CuePoints.GetHeadPosition();
- while(pos2 && nKFsTmp < nKFs)
+ while(pos2 && nKFsTmp < nKFs) {
pKFs[nKFsTmp++] = m_pFile->m_segment.GetRefTime(pCue->CuePoints.GetNext(pos2)->CueTime);
+ }
}
nKFs = nKFsTmp;
@@ -1130,8 +1106,8 @@ CMatroskaSourceFilter::CMatroskaSourceFilter(LPUNKNOWN pUnk, HRESULT* phr)
//
CMatroskaSplitterOutputPin::CMatroskaSplitterOutputPin(
- int nMinCache, REFERENCE_TIME rtDefaultDuration,
- CAtlArray<CMediaType>& mts, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr)
+ 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)
{
@@ -1160,22 +1136,23 @@ HRESULT CMatroskaSplitterOutputPin::DeliverEndOfStream()
// send out the last remaining packets from the queue
- while(m_rob.GetCount())
- {
+ while(m_rob.GetCount()) {
MatroskaPacket* mp = m_rob.RemoveHead();
- if(m_rob.GetCount() && !mp->bg->BlockDuration.IsValid())
+ if(m_rob.GetCount() && !mp->bg->BlockDuration.IsValid()) {
mp->rtStop = m_rob.GetHead()->rtStart;
- else if(m_rob.GetCount() == 0 && m_rtDefaultDuration > 0)
+ } 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())
- {
+ while(m_packets.GetCount()) {
HRESULT hr = DeliverBlock(m_packets.RemoveHead());
- if(hr != S_OK) return hr;
+ if(hr != S_OK) {
+ return hr;
+ }
}
return __super::DeliverEndOfStream();
@@ -1184,7 +1161,9 @@ HRESULT CMatroskaSplitterOutputPin::DeliverEndOfStream()
HRESULT CMatroskaSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p)
{
MatroskaPacket* mp = dynamic_cast<MatroskaPacket*>(p.m_p);
- if(!mp) return __super::DeliverPacket(p);
+ if(!mp) {
+ return __super::DeliverPacket(p);
+ }
// don't try to understand what's happening here, it's magic
@@ -1196,50 +1175,52 @@ HRESULT CMatroskaSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p)
m_packets.AddTail(p2);
POSITION pos = m_rob.GetTailPosition();
- for(int i = m_nMinCache-1; i > 0 && pos && mp->bg->ReferencePriority < m_rob.GetAt(pos)->bg->ReferencePriority; i--)
+ 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);
+ if(!pos) {
+ m_rob.AddHead(mp);
+ } else {
+ m_rob.InsertAfter(pos, mp);
+ }
mp = NULL;
- if(m_rob.GetCount() == m_nMinCache+1)
- {
+ 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())
- {
+ 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);
-*/
+ 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
- {
+ } else {
mp1->rtStop = mp2->rtStart;
}
}
}
- while(m_packets.GetCount())
- {
+ while(m_packets.GetCount()) {
mp = m_packets.GetHead();
- if(!mp->bg->BlockDuration.IsValid()) break;
-
+ 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;
+ if(hr != S_OK) {
+ return hr;
+ }
}
return S_OK;
@@ -1249,26 +1230,24 @@ HRESULT CMatroskaSplitterOutputPin::DeliverBlock(MatroskaPacket* p)
{
HRESULT hr = S_FALSE;
- if(m_tos.GetCount())
- {
+ if(m_tos.GetCount()) {
timeoverride to = m_tos.RemoveHead();
-// if(p->TrackNumber == 2)
- TRACE(_T("(track=%d) %I64d, %I64d -> %I64d, %I64d (buffcnt=%d)\n"),
- p->TrackNumber, p->rtStart, p->rtStop, to.rtStart, to.rtStop,
- QueueCount());
-/**/
+ // if(p->TrackNumber == 2)
+ TRACE(_T("(track=%d) %I64d, %I64d -> %I64d, %I64d (buffcnt=%d)\n"),
+ p->TrackNumber, p->rtStart, p->rtStop, to.rtStart, to.rtStop,
+ QueueCount());
+ /**/
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;
+
+ 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)
- {
+ while(pos) {
CAutoPtr<Packet> tmp(DNew Packet());
tmp->TrackNumber = p->TrackNumber;
tmp->bDiscontinuity = p->bDiscontinuity;
@@ -1276,7 +1255,9 @@ HRESULT CMatroskaSplitterOutputPin::DeliverBlock(MatroskaPacket* p)
tmp->rtStart = rtStart;
tmp->rtStop = rtStop;
tmp->Copy(*p->bg->Block.BlockData.GetNext(pos));
- if(S_OK != (hr = DeliverPacket(tmp))) break;
+ if(S_OK != (hr = DeliverPacket(tmp))) {
+ break;
+ }
rtStart += rtDelta;
rtStop += rtDelta;
@@ -1285,11 +1266,9 @@ HRESULT CMatroskaSplitterOutputPin::DeliverBlock(MatroskaPacket* p)
p->bDiscontinuity = false;
}
- if(m_mt.subtype == FOURCCMap(WAVE_FORMAT_WAVPACK4))
- {
+ if(m_mt.subtype == FOURCCMap(WAVE_FORMAT_WAVPACK4)) {
POSITION pos = p->bg->ba.bm.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
const BlockMore* bm = p->bg->ba.bm.GetNext(pos);
CAutoPtr<Packet> tmp(DNew Packet());
tmp->TrackNumber = p->TrackNumber;
@@ -1298,7 +1277,9 @@ HRESULT CMatroskaSplitterOutputPin::DeliverBlock(MatroskaPacket* p)
tmp->rtStart = p->rtStart;
tmp->rtStop = p->rtStop;
tmp->Copy(bm->BlockAdditional);
- if(S_OK != (hr = DeliverPacket(tmp))) break;
+ if(S_OK != (hr = DeliverPacket(tmp))) {
+ break;
+ }
}
}
@@ -1309,28 +1290,31 @@ HRESULT CMatroskaSplitterOutputPin::DeliverBlock(MatroskaPacket* p)
TrackEntry* CMatroskaSplitterFilter::GetTrackEntryAt(UINT aTrackIdx)
{
- if(aTrackIdx < 0 || aTrackIdx >= m_pOrderedTrackArray.GetCount())
- return NULL;
+ if(aTrackIdx < 0 || aTrackIdx >= m_pOrderedTrackArray.GetCount()) {
+ return NULL;
+ }
return m_pOrderedTrackArray[aTrackIdx];
}
STDMETHODIMP_(UINT) CMatroskaSplitterFilter::GetTrackCount()
-{
+{
return m_pTrackEntryMap.GetCount();
}
STDMETHODIMP_(BOOL) CMatroskaSplitterFilter::GetTrackInfo(UINT aTrackIdx, struct TrackElement* pStructureToFill)
{
TrackEntry* pTE = GetTrackEntryAt(aTrackIdx);
- if(pTE == NULL)
+ if(pTE == NULL) {
return FALSE;
+ }
pStructureToFill->FlagDefault = !!pTE->FlagDefault;
pStructureToFill->FlagForced = !!pTE->FlagForced;
pStructureToFill->FlagLacing = !!pTE->FlagLacing;
strncpy(pStructureToFill->Language, pTE->Language, 3);
- if(pStructureToFill->Language[0] == '\0')
+ if(pStructureToFill->Language[0] == '\0') {
strncpy(pStructureToFill->Language, "eng", 3);
+ }
pStructureToFill->Language[3] = '\0';
pStructureToFill->MaxCache = (UINT)pTE->MaxCache;
pStructureToFill->MinCache = (UINT)pTE->MinCache;
@@ -1341,15 +1325,15 @@ STDMETHODIMP_(BOOL) CMatroskaSplitterFilter::GetTrackInfo(UINT aTrackIdx, struct
STDMETHODIMP_(BOOL) CMatroskaSplitterFilter::GetTrackExtendedInfo(UINT aTrackIdx, void* pStructureToFill)
{
TrackEntry* pTE = GetTrackEntryAt(aTrackIdx);
- if(pTE == NULL)
+ if(pTE == NULL) {
return FALSE;
+ }
- if(pTE->TrackType == TrackEntry::TypeVideo)
- {
+ if(pTE->TrackType == TrackEntry::TypeVideo) {
TrackExtendedInfoVideo* pTEIV = (TrackExtendedInfoVideo*)pStructureToFill;
- pTEIV->AspectRatioType = (BYTE)pTE->v.AspectRatioType;
+ pTEIV->AspectRatioType = (BYTE)pTE->v.AspectRatioType;
pTEIV->DisplayUnit = (BYTE)pTE->v.DisplayUnit;
- pTEIV->DisplayWidth = (UINT)pTE->v.DisplayWidth;
+ pTEIV->DisplayWidth = (UINT)pTE->v.DisplayWidth;
pTEIV->DisplayHeight = (UINT)pTE->v.DisplayHeight;
pTEIV->Interlaced = !!pTE->v.FlagInterlaced;
pTEIV->PixelWidth = (UINT)pTE->v.PixelWidth;
@@ -1363,46 +1347,51 @@ STDMETHODIMP_(BOOL) CMatroskaSplitterFilter::GetTrackExtendedInfo(UINT aTrackIdx
} else {
return FALSE;
}
-
+
return TRUE;
}
STDMETHODIMP_(BSTR) CMatroskaSplitterFilter::GetTrackName(UINT aTrackIdx)
{
TrackEntry* pTE = GetTrackEntryAt(aTrackIdx);
- if(pTE == NULL)
+ if(pTE == NULL) {
return NULL;
+ }
return pTE->Name.AllocSysString();
}
STDMETHODIMP_(BSTR) CMatroskaSplitterFilter::GetTrackCodecID(UINT aTrackIdx)
{
TrackEntry* pTE = GetTrackEntryAt(aTrackIdx);
- if(pTE == NULL)
+ if(pTE == NULL) {
return NULL;
+ }
return pTE->CodecID.ToString().AllocSysString();
}
STDMETHODIMP_(BSTR) CMatroskaSplitterFilter::GetTrackCodecName(UINT aTrackIdx)
{
TrackEntry* pTE = GetTrackEntryAt(aTrackIdx);
- if(pTE == NULL)
+ if(pTE == NULL) {
return NULL;
+ }
return pTE->CodecName.AllocSysString();
}
STDMETHODIMP_(BSTR) CMatroskaSplitterFilter::GetTrackCodecInfoURL(UINT aTrackIdx)
{
TrackEntry* pTE = GetTrackEntryAt(aTrackIdx);
- if(pTE == NULL)
+ if(pTE == NULL) {
return NULL;
+ }
return pTE->CodecInfoURL.AllocSysString();
}
STDMETHODIMP_(BSTR) CMatroskaSplitterFilter::GetTrackCodecDownloadURL(UINT aTrackIdx)
{
TrackEntry* pTE = GetTrackEntryAt(aTrackIdx);
- if(pTE == NULL)
+ 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 ae47a7d83..a81b6d45a 100644
--- a/src/filters/parser/MatroskaSplitter/MatroskaSplitter.h
+++ b/src/filters/parser/MatroskaSplitter/MatroskaSplitter.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -30,11 +30,12 @@
class MatroskaPacket : public Packet
{
protected:
- int GetDataSize()
- {
+ int GetDataSize() {
int size = 0;
POSITION pos = bg->Block.BlockData.GetHeadPosition();
- while(pos) {size += bg->Block.BlockData.GetNext(pos)->GetCount();}
+ while(pos) {
+ size += bg->Block.BlockData.GetNext(pos)->GetCount();
+ }
return size;
}
public:
@@ -52,7 +53,9 @@ class CMatroskaSplitterOutputPin : public CBaseSplitterOutputPin
CAutoPtrList<MatroskaPacket> m_packets;
CAtlList<MatroskaPacket*> m_rob;
- typedef struct {REFERENCE_TIME rtStart, rtStop;} timeoverride;
+ typedef struct {
+ REFERENCE_TIME rtStart, rtStop;
+ } timeoverride;
CAtlList<timeoverride> m_tos;
protected:
@@ -60,7 +63,7 @@ protected:
public:
CMatroskaSplitterOutputPin(
- int nMinCache, REFERENCE_TIME rtDefaultDuration,
+ int nMinCache, REFERENCE_TIME rtDefaultDuration,
CAtlArray<CMediaType>& mts, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
virtual ~CMatroskaSplitterOutputPin();
@@ -69,7 +72,7 @@ public:
};
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();
@@ -83,7 +86,7 @@ protected:
CAtlMap<DWORD, MatroskaReader::TrackEntry*> m_pTrackEntryMap;
CAtlArray<MatroskaReader::TrackEntry* > m_pOrderedTrackArray;
- MatroskaReader::TrackEntry* GetTrackEntryAt(UINT aTrackIdx);
+ MatroskaReader::TrackEntry* GetTrackEntryAt(UINT aTrackIdx);
bool DemuxInit();
void DemuxSeek(REFERENCE_TIME rt);
@@ -94,7 +97,7 @@ public:
virtual ~CMatroskaSplitterFilter();
DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
// IKeyFrameInfo
@@ -104,7 +107,7 @@ public:
// ITrackInfo
STDMETHODIMP_(UINT) GetTrackCount();
- STDMETHODIMP_(BOOL) GetTrackInfo(UINT aTrackIdx, struct TrackElement* pStructureToFill);
+ 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);
@@ -114,7 +117,7 @@ public:
};
class __declspec(uuid("0A68C3B5-9164-4a54-AFAF-995B2FF0E0D4"))
-CMatroskaSourceFilter : public CMatroskaSplitterFilter
+ CMatroskaSourceFilter : public CMatroskaSplitterFilter
{
public:
CMatroskaSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
diff --git a/src/filters/parser/MatroskaSplitter/stdafx.cpp b/src/filters/parser/MatroskaSplitter/stdafx.cpp
index 13934d005..bea3f980a 100644
--- a/src/filters/parser/MatroskaSplitter/stdafx.cpp
+++ b/src/filters/parser/MatroskaSplitter/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/parser/MatroskaSplitter/stdafx.h b/src/filters/parser/MatroskaSplitter/stdafx.h
index 7e2652f5d..37bcea3a7 100644
--- a/src/filters/parser/MatroskaSplitter/stdafx.h
+++ b/src/filters/parser/MatroskaSplitter/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/parser/MpaSplitter/MpaSplitter.cpp b/src/filters/parser/MpaSplitter/MpaSplitter.cpp
index fef3f7d1a..11f7322c9 100644
--- a/src/filters/parser/MpaSplitter/MpaSplitter.cpp
+++ b/src/filters/parser/MpaSplitter/MpaSplitter.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -27,26 +27,22 @@
#ifdef REGISTER_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
{&MEDIATYPE_Stream, &MEDIASUBTYPE_MPEG1Audio},
{&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL}
};
-const AMOVIESETUP_PIN sudpPins[] =
-{
+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}
};
-const AMOVIESETUP_FILTER sudFilter[] =
-{
+const AMOVIESETUP_FILTER sudFilter[] = {
{&__uuidof(CMpaSplitterFilter), L"MPC - Mpa Splitter", MERIT_NORMAL+1, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
{&__uuidof(CMpaSourceFilter), L"MPC - Mpa Source", MERIT_NORMAL+1, 0, NULL, CLSID_LegacyAmFilterCategory},
};
-CFactoryTemplate g_Templates[] =
-{
+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]},
};
@@ -85,9 +81,9 @@ CMpaSplitterFilter::CMpaSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr)
STDMETHODIMP CMpaSplitterFilter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- return
+ return
__super::NonDelegatingQueryInterface(riid, ppv);
}
@@ -100,8 +96,13 @@ HRESULT CMpaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
m_pFile.Free();
m_pFile.Attach(DNew CMpaSplitterFile(pAsyncReader, hr));
- if(!m_pFile) return E_OUTOFMEMORY;
- if(FAILED(hr)) {m_pFile.Free(); return hr;}
+ if(!m_pFile) {
+ return E_OUTOFMEMORY;
+ }
+ if(FAILED(hr)) {
+ m_pFile.Free();
+ return hr;
+ }
CAtlArray<CMediaType> mts;
mts.Add(m_pFile->GetMediaType());
@@ -113,12 +114,24 @@ HRESULT CMpaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
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);
+ 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;
}
@@ -136,7 +149,9 @@ STDMETHODIMP CMpaSplitterFilter::GetDuration(LONGLONG* pDuration)
bool CMpaSplitterFilter::DemuxInit()
{
SetThreadName((DWORD)-1, "CMpaSplitterFilter");
- if(!m_pFile) return(false);
+ if(!m_pFile) {
+ return(false);
+ }
// TODO
@@ -148,13 +163,10 @@ void CMpaSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
__int64 startpos = m_pFile->GetStartPos();
__int64 endpos = m_pFile->GetEndPos();
- if(rt <= 0 || m_pFile->GetDuration() <= 0)
- {
+ if(rt <= 0 || m_pFile->GetDuration() <= 0) {
m_pFile->Seek(startpos);
m_rtStart = 0;
- }
- else
- {
+ } else {
m_pFile->Seek(startpos + (__int64)((1.0 * rt / m_pFile->GetDuration()) * (endpos - startpos)));
m_rtStart = rt;
}
@@ -168,9 +180,11 @@ bool CMpaSplitterFilter::DemuxLoop()
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);
diff --git a/src/filters/parser/MpaSplitter/MpaSplitter.h b/src/filters/parser/MpaSplitter/MpaSplitter.h
index cae3c8b9a..064a91d36 100644
--- a/src/filters/parser/MpaSplitter/MpaSplitter.h
+++ b/src/filters/parser/MpaSplitter/MpaSplitter.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -25,7 +25,7 @@
#include "MpaSplitterFile.h"
class __declspec(uuid("0E9D4BF7-CBCB-46C7-BD80-4EF223A3DC2B"))
-CMpaSplitterFilter : public CBaseSplitterFilter
+ CMpaSplitterFilter : public CBaseSplitterFilter
{
REFERENCE_TIME m_rtStart;
@@ -43,11 +43,11 @@ public:
CMpaSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr);
DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
};
class __declspec(uuid("59A0DB73-0287-4C9A-9D3C-8CFF39F8E5DB"))
-CMpaSourceFilter : public CMpaSplitterFilter
+ CMpaSourceFilter : public CMpaSplitterFilter
{
public:
CMpaSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
diff --git a/src/filters/parser/MpaSplitter/MpaSplitterFile.cpp b/src/filters/parser/MpaSplitter/MpaSplitterFile.cpp
index fc5f8399c..d26b70bb7 100644
--- a/src/filters/parser/MpaSplitter/MpaSplitterFile.cpp
+++ b/src/filters/parser/MpaSplitter/MpaSplitterFile.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -28,43 +28,42 @@
//
-static const LPCTSTR s_genre[] =
-{
+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("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("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("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("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("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("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("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("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("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("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"),
};
@@ -79,7 +78,9 @@ CMpaSplitterFile::CMpaSplitterFile(IAsyncReader* pAsyncReader, HRESULT& hr)
, m_endpos(0)
, m_totalbps(0)
{
- if(SUCCEEDED(hr)) hr = Init();
+ if(SUCCEEDED(hr)) {
+ hr = Init();
+ }
}
HRESULT CMpaSplitterFile::Init()
@@ -89,19 +90,18 @@ HRESULT CMpaSplitterFile::Init()
Seek(0);
- if(BitRead(24, true) == 0x000001)
+ if(BitRead(24, true) == 0x000001) {
return E_FAIL;
+ }
- if(m_endpos > 128 && IsRandomAccess())
- {
+ if(m_endpos > 128 && IsRandomAccess()) {
Seek(m_endpos - 128);
- if(BitRead(24) == 'TAG')
- {
+ if(BitRead(24) == 'TAG') {
m_endpos -= 128;
CStringA str;
-
+
// title
ByteRead((BYTE*)str.GetBufferSetLength(30), 30);
m_tags['TIT2'] = CStringW(str).Trim();
@@ -120,17 +120,19 @@ HRESULT CMpaSplitterFile::Init()
// comment
ByteRead((BYTE*)str.GetBufferSetLength(30), 30);
- m_tags['COMM'] = CStringW(str).Trim();
+ 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]);
+ 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))
+ if(genre < countof(s_genre)) {
m_tags['TCON'] = CStringW(s_genre[genre]);
+ }
}
}
@@ -138,8 +140,7 @@ HRESULT CMpaSplitterFile::Init()
bool MP3_find = false;
- while(BitRead(24, true) == 'ID3')
- {
+ while(BitRead(24, true) == 'ID3') {
MP3_find = true;
BitRead(24);
@@ -151,25 +152,31 @@ HRESULT CMpaSplitterFile::Init()
BYTE flags = (BYTE)BitRead(8);
UNUSED_ALWAYS(flags);
DWORD size = 0;
- if(BitRead(1) != 0) return E_FAIL;
+ if(BitRead(1) != 0) {
+ return E_FAIL;
+ }
size |= BitRead(7) << 21;
- if(BitRead(1) != 0) return E_FAIL;
+ if(BitRead(1) != 0) {
+ return E_FAIL;
+ }
size |= BitRead(7) << 14;
- if(BitRead(1) != 0) return E_FAIL;
+ if(BitRead(1) != 0) {
+ return E_FAIL;
+ }
size |= BitRead(7) << 7;
- if(BitRead(1) != 0) return E_FAIL;
+ if(BitRead(1) != 0) {
+ return E_FAIL;
+ }
size |= BitRead(7);
m_startpos = GetPos() + size;
// TODO: read extended header
- if(major <= 4)
- {
+ if(major <= 4) {
__int64 pos = GetPos();
- while(pos < m_startpos)
- {
+ while(pos < m_startpos) {
Seek(pos);
DWORD tag = (DWORD)BitRead(32);
@@ -183,16 +190,16 @@ HRESULT CMpaSplitterFile::Init()
pos += 4+4+2+size;
- if(!size || pos >= m_startpos)
+ if(!size || pos >= m_startpos) {
break;
+ }
if(tag == 'TIT2'
- || tag == 'TPE1'
- || tag == 'TALB'
- || tag == 'TYER'
- || tag == 'COMM'
- || tag == 'TRCK')
- {
+ || tag == 'TPE1'
+ || tag == 'TALB'
+ || tag == 'TYER'
+ || tag == 'COMM'
+ || tag == 'TRCK') {
BYTE encoding = (BYTE)BitRead(8);
size--;
@@ -201,45 +208,41 @@ HRESULT CMpaSplitterFile::Init()
CStringA str;
CStringW wstr;
- if(encoding > 0 && size >= 2 && bom == 0xfffe)
- {
- BitRead(16);
+ 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)
- {
+ } 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));
+ 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
- {
+ } 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++)
+ for(int i = 0; i < (1<<20) && m_startpos < m_endpos && BitRead(8, true) == 0; i++) {
BitRead(8), m_startpos++;
+ }
}
__int64 searchlen;
__int64 startpos;
__int64 syncpos;
- if(MP3_find)
- {
+ if(MP3_find) {
__int64 startpos_mp3 = m_startpos;
- while (m_mode == none)
- {
+ while (m_mode == none) {
searchlen = min(m_endpos - startpos_mp3, 0x200);
Seek(startpos_mp3);
@@ -247,45 +250,48 @@ HRESULT CMpaSplitterFile::Init()
syncpos = startpos_mp3 + searchlen;
// Check for a valid MPA header
- if(Read(m_mpahdr, searchlen, true, &m_mt))
- {
+ 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))
+ if(!Sync(4)) {
m_mode = none;
- else
+ } else {
break;
+ }
}
// If we have enough room to search for a valid header, then skip ahead and try again
- if (m_endpos - syncpos >= 8)
+ if (m_endpos - syncpos >= 8) {
startpos_mp3 = syncpos;
- else
+ } else {
break;
+ }
}
}
searchlen = min(m_endpos - m_startpos, m_startpos > 0 ? 0x200 : 7);
Seek(m_startpos);
- if(m_mode == none && Read(m_aachdr, searchlen, &m_mt))
- {
+ 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(!Sync(9)) {
+ m_mode = none;
+ }
}
- if(m_mode == none)
+ if(m_mode == none) {
return E_FAIL;
+ }
m_startpos = startpos;
@@ -293,12 +299,13 @@ HRESULT CMpaSplitterFile::Init()
REFERENCE_TIME rtFrameDur, rtPrevDur = -1;
clock_t start = clock();
int i = 0;
- while(Sync(FrameSize, rtFrameDur) && (clock() - start) < CLOCKS_PER_SEC)
- {
+ 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;
+ if(i == 10) {
+ break;
+ }
rtPrevDur = m_rtDuration;
}
@@ -316,18 +323,14 @@ bool CMpaSplitterFile::Sync(int& FrameSize, REFERENCE_TIME& rtDuration, int limi
{
__int64 endpos = min(m_endpos, GetPos() + limit);
- if(m_mode == mpa)
- {
- while(GetPos() <= endpos - 4)
- {
+ if(m_mode == mpa) {
+ while(GetPos() <= endpos - 4) {
mpahdr h;
- if(Read(h, endpos - GetPos(), true))
- {
+ if(Read(h, endpos - GetPos(), true)) {
if (m_mpahdr.version == h.version
- && m_mpahdr.layer == h.layer
- && m_mpahdr.channels == h.channels)
- {
+ && m_mpahdr.layer == h.layer
+ && m_mpahdr.channels == h.channels) {
Seek(GetPos() - 4);
AdjustDuration(h.nBytesPerSec);
@@ -336,23 +339,18 @@ bool CMpaSplitterFile::Sync(int& FrameSize, REFERENCE_TIME& rtDuration, int limi
return true;
}
- }
- else
+ } else {
break;
+ }
}
- }
- else if(m_mode == mp4a)
- {
- while(GetPos() <= endpos - 9)
- {
+ } else if(m_mode == mp4a) {
+ while(GetPos() <= endpos - 9) {
aachdr h;
- if(Read(h, endpos - GetPos()))
- {
+ if(Read(h, endpos - GetPos())) {
if (m_aachdr.version == h.version
- && m_aachdr.layer == h.layer
- && m_aachdr.channels == h.channels)
- {
+ && 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));
@@ -362,9 +360,9 @@ bool CMpaSplitterFile::Sync(int& FrameSize, REFERENCE_TIME& rtDuration, int limi
return true;
}
- }
- else
+ } else {
break;
+ }
}
}
@@ -376,10 +374,11 @@ void CMpaSplitterFile::AdjustDuration(int nBytesPerSec)
ASSERT(nBytesPerSec);
int rValue;
- if(!m_pos2bps.Lookup(GetPos(), rValue))
- {
+ if(!m_pos2bps.Lookup(GetPos(), rValue)) {
m_totalbps += nBytesPerSec;
- if(!m_totalbps) return;
+ 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 2bd3a9a40..2c95f4af7 100644
--- a/src/filters/parser/MpaSplitter/MpaSplitterFile.h
+++ b/src/filters/parser/MpaSplitter/MpaSplitterFile.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -45,11 +45,19 @@ public:
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);
diff --git a/src/filters/parser/MpaSplitter/stdafx.cpp b/src/filters/parser/MpaSplitter/stdafx.cpp
index 13934d005..bea3f980a 100644
--- a/src/filters/parser/MpaSplitter/stdafx.cpp
+++ b/src/filters/parser/MpaSplitter/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/parser/MpaSplitter/stdafx.h b/src/filters/parser/MpaSplitter/stdafx.h
index 7fbf4d9ac..114712db9 100644
--- a/src/filters/parser/MpaSplitter/stdafx.h
+++ b/src/filters/parser/MpaSplitter/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/parser/MpegSplitter/MpegSplitter.cpp b/src/filters/parser/MpegSplitter/MpegSplitter.cpp
index 879a773de..9a29a446e 100644
--- a/src/filters/parser/MpegSplitter/MpegSplitter.cpp
+++ b/src/filters/parser/MpegSplitter/MpegSplitter.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* (C) 2003-2006 Gabest
* (C) 2006-2010 see AUTHORS
* http://www.gabest.org
@@ -7,12 +7,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -31,30 +31,26 @@
#ifdef REGISTER_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
{&MEDIATYPE_Stream, &MEDIASUBTYPE_MPEG1System},
-// {&MEDIATYPE_Stream, &MEDIASUBTYPE_MPEG1VideoCD}, // cdxa filter should take care of this
+ // {&MEDIATYPE_Stream, &MEDIASUBTYPE_MPEG1VideoCD}, // cdxa filter should take care of this
{&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},
+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},
};
-const AMOVIESETUP_FILTER sudFilter[] =
-{
+const AMOVIESETUP_FILTER sudFilter[] = {
{&__uuidof(CMpegSplitterFilter), L"MPC - Mpeg Splitter (Gabest)", MERIT_NORMAL+1, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
{&__uuidof(CMpegSourceFilter), L"MPC - Mpeg Source (Gabest)", MERIT_UNLIKELY, 0, NULL, CLSID_LegacyAmFilterCategory},
};
-CFactoryTemplate g_Templates[] =
-{
+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]},
};
@@ -73,15 +69,15 @@ STDAPI DllRegisterServer()
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);
+ RegisterSourceFilter(CLSID_AsyncReader, MEDIASUBTYPE_MPEG2_TRANSPORT, chkbytes, NULL);
return AMovieDllRegisterServer2(TRUE);
}
STDAPI DllUnregisterServer()
{
-// UnRegisterSourceFilter(MEDIASUBTYPE_MPEG1System);
-// UnRegisterSourceFilter(MEDIASUBTYPE_MPEG2_PROGRAM);
+ // UnRegisterSourceFilter(MEDIASUBTYPE_MPEG1System);
+ // UnRegisterSourceFilter(MEDIASUBTYPE_MPEG2_PROGRAM);
return AMovieDllRegisterServer2(FALSE);
}
@@ -104,19 +100,21 @@ static int GetHighestBitSet32(unsigned long _Value)
{
unsigned long Ret;
unsigned char bNonZero = _BitScanReverse(&Ret, _Value);
- if (bNonZero)
+ if (bNonZero) {
return Ret;
- else
+ } else {
return -1;
+ }
}
CString FormatBitrate(double _Bitrate)
{
CString Temp;
- if (_Bitrate > 20000000) // More than 2 mbit
+ if (_Bitrate > 20000000) { // More than 2 mbit
Temp.Format(L"%.2f mbit/s", double(_Bitrate)/1000000.0);
- else
+ } else {
Temp.Format(L"%.1f kbit/s", double(_Bitrate)/1000.0);
+ }
return Temp;
}
@@ -138,55 +136,49 @@ CString GetMediaTypeDesc(const CMediaType *_pMediaType, const CHdmvClipInfo::Str
{
const WCHAR *pPresentationDesc = NULL;
- if (pClipInfo)
+ if (pClipInfo) {
pPresentationDesc = StreamTypeToName(pClipInfo->m_Type);
- else
+ } else {
pPresentationDesc = StreamTypeToName((PES_STREAM_TYPE)_PresentationType);
+ }
CString MajorType;
CAtlList<CString> Infos;
- if (_pMediaType->majortype == MEDIATYPE_Video)
- {
+ if (_pMediaType->majortype == MEDIATYPE_Video) {
MajorType = "Video";
- if (pClipInfo)
- {
+ if (pClipInfo) {
CString name = ISO6392ToLanguage(pClipInfo->m_LanguageCode);
- if (!name.IsEmpty())
+ if (!name.IsEmpty()) {
Infos.AddTail(name);
+ }
}
const VIDEOINFOHEADER *pVideoInfo = NULL;
const VIDEOINFOHEADER2 *pVideoInfo2 = NULL;
- if (_pMediaType->formattype == FORMAT_MPEGVideo)
- {
+ 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)
- {
+ } else if (_pMediaType->formattype == FORMAT_MPEG2_VIDEO) {
const MPEG2VIDEOINFO *pInfo = GetFormatHelper(pInfo, _pMediaType);
pVideoInfo2 = &pInfo->hdr;
bool bIsAVC = false;
- if (pInfo->hdr.bmiHeader.biCompression == '1CVA')
- {
+ if (pInfo->hdr.bmiHeader.biCompression == '1CVA') {
bIsAVC = true;
Infos.AddTail(L"AVC (H.264)");
- }
- else if (pInfo->hdr.bmiHeader.biCompression == 0)
+ } else if (pInfo->hdr.bmiHeader.biCompression == 0) {
Infos.AddTail(L"MPEG2");
- else
- {
+ } else {
WCHAR Temp[5];
memset(Temp, 0, sizeof(Temp));
Temp[0] = (pInfo->hdr.bmiHeader.biCompression >> 0) & 0xFF;
@@ -196,70 +188,96 @@ CString GetMediaTypeDesc(const CMediaType *_pMediaType, const CHdmvClipInfo::Str
Infos.AddTail(Temp);
}
- switch (pInfo->dwProfile)
- {
- case AM_MPEG2Profile_Simple: Infos.AddTail(L"Simple Profile"); break;
- case AM_MPEG2Profile_Main: Infos.AddTail(L"Main Profile"); break;
- case AM_MPEG2Profile_SNRScalable: Infos.AddTail(L"SNR Scalable Profile"); break;
- case AM_MPEG2Profile_SpatiallyScalable: Infos.AddTail(L"Spatially Scalable Profile"); break;
- case AM_MPEG2Profile_High: Infos.AddTail(L"High Profile"); break;
- default:
- 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 122: Infos.AddTail(L"High 4:2:2 Profile"); break;
- case 244: Infos.AddTail(L"High 4:4:4 Profile"); break;
-
- default: Infos.AddTail(FormatString(L"Profile %d", pInfo->dwProfile)); break;
+ switch (pInfo->dwProfile) {
+ case AM_MPEG2Profile_Simple:
+ Infos.AddTail(L"Simple Profile");
+ break;
+ case AM_MPEG2Profile_Main:
+ Infos.AddTail(L"Main Profile");
+ break;
+ case AM_MPEG2Profile_SNRScalable:
+ Infos.AddTail(L"SNR Scalable Profile");
+ break;
+ case AM_MPEG2Profile_SpatiallyScalable:
+ Infos.AddTail(L"Spatially Scalable Profile");
+ break;
+ case AM_MPEG2Profile_High:
+ Infos.AddTail(L"High Profile");
+ break;
+ default:
+ 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 122:
+ Infos.AddTail(L"High 4:2:2 Profile");
+ break;
+ case 244:
+ Infos.AddTail(L"High 4:4:4 Profile");
+ break;
+
+ default:
+ Infos.AddTail(FormatString(L"Profile %d", pInfo->dwProfile));
+ break;
+ }
+ } else {
+ Infos.AddTail(FormatString(L"Profile %d", pInfo->dwProfile));
}
}
- else
- Infos.AddTail(FormatString(L"Profile %d", pInfo->dwProfile));
- }
- break;
+ break;
}
- switch (pInfo->dwLevel)
- {
- case AM_MPEG2Level_Low: Infos.AddTail(L"Low Level"); break;
- case AM_MPEG2Level_Main: Infos.AddTail(L"Main Level"); break;
- case AM_MPEG2Level_High1440: Infos.AddTail(L"High1440 Level"); break;
- case AM_MPEG2Level_High: Infos.AddTail(L"High Level"); break;
- default:
- 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));
- }
- break;
+ switch (pInfo->dwLevel) {
+ case AM_MPEG2Level_Low:
+ Infos.AddTail(L"Low Level");
+ break;
+ case AM_MPEG2Level_Main:
+ Infos.AddTail(L"Main Level");
+ break;
+ case AM_MPEG2Level_High1440:
+ Infos.AddTail(L"High1440 Level");
+ break;
+ case AM_MPEG2Level_High:
+ Infos.AddTail(L"High Level");
+ break;
+ default:
+ 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));
+ }
+ }
+ break;
}
- }
- else if (_pMediaType->formattype == FORMAT_VIDEOINFO2)
- {
+ } 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')
- {
+ if (CodecType == '1CVW') {
bIsVC1 = true;
Infos.AddTail(L"VC-1");
- }
- else if (CodecType)
- {
+ } else if (CodecType) {
WCHAR Temp[5];
memset(Temp, 0, sizeof(Temp));
Temp[0] = (CodecType >> 0) & 0xFF;
@@ -268,109 +286,91 @@ CString GetMediaTypeDesc(const CMediaType *_pMediaType, const CHdmvClipInfo::Str
Temp[3] = (CodecType >> 24) & 0xFF;
Infos.AddTail(Temp);
}
- }
- else if (_pMediaType->subtype == MEDIASUBTYPE_DVD_SUBPICTURE)
- {
+ } else if (_pMediaType->subtype == MEDIASUBTYPE_DVD_SUBPICTURE) {
Infos.AddTail(L"DVD Sub Picture");
- }
- else if (_pMediaType->subtype == MEDIASUBTYPE_SVCD_SUBPICTURE)
- {
+ } else if (_pMediaType->subtype == MEDIASUBTYPE_SVCD_SUBPICTURE) {
Infos.AddTail(L"SVCD Sub Picture");
- }
- else if (_pMediaType->subtype == MEDIASUBTYPE_CVD_SUBPICTURE)
- {
+ } else if (_pMediaType->subtype == MEDIASUBTYPE_CVD_SUBPICTURE) {
Infos.AddTail(L"CVD Sub Picture");
}
- if (pVideoInfo2)
- {
- if (pVideoInfo2->bmiHeader.biWidth && pVideoInfo2->bmiHeader.biHeight)
+ if (pVideoInfo2) {
+ if (pVideoInfo2->bmiHeader.biWidth && pVideoInfo2->bmiHeader.biHeight) {
Infos.AddTail(FormatString(L"%dx%d", pVideoInfo2->bmiHeader.biWidth, pVideoInfo2->bmiHeader.biHeight));
- if (pVideoInfo2->AvgTimePerFrame)
+ }
+ if (pVideoInfo2->AvgTimePerFrame) {
Infos.AddTail(FormatString(L"%.3f fps", 10000000.0/double(pVideoInfo2->AvgTimePerFrame)));
- if (pVideoInfo2->dwBitRate)
+ }
+ if (pVideoInfo2->dwBitRate) {
Infos.AddTail(FormatBitrate(pVideoInfo2->dwBitRate));
- }
- else if (pVideoInfo)
- {
- if (pVideoInfo->bmiHeader.biWidth && pVideoInfo->bmiHeader.biHeight)
+ }
+ } 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)
+ }
+ if (pVideoInfo->AvgTimePerFrame) {
Infos.AddTail(FormatString(L"%.3f fps", 10000000.0/double(pVideoInfo->AvgTimePerFrame)));
- if (pVideoInfo->dwBitRate)
+ }
+ if (pVideoInfo->dwBitRate) {
Infos.AddTail(FormatBitrate(pVideoInfo->dwBitRate));
+ }
}
-
- }
- else if (_pMediaType->majortype == MEDIATYPE_Audio)
- {
+
+ } else if (_pMediaType->majortype == MEDIATYPE_Audio) {
MajorType = "Audio";
- if (pClipInfo)
- {
+ if (pClipInfo) {
CString name = ISO6392ToLanguage(pClipInfo->m_LanguageCode);
- if (!name.IsEmpty())
+ if (!name.IsEmpty()) {
Infos.AddTail(name);
+ }
}
- if (_pMediaType->formattype == FORMAT_WaveFormatEx)
- {
+ if (_pMediaType->formattype == FORMAT_WaveFormatEx) {
const WAVEFORMATEX *pInfo = GetFormatHelper(pInfo, _pMediaType);
- if (_pMediaType->subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO)
- {
+ if (_pMediaType->subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO) {
Infos.AddTail(L"DVD LPCM");
- }
- else if (_pMediaType->subtype == MEDIASUBTYPE_HDMV_LPCM_AUDIO)
- {
+ } else if (_pMediaType->subtype == MEDIASUBTYPE_HDMV_LPCM_AUDIO) {
const WAVEFORMATEX_HDMV_LPCM *pInfoHDMV = GetFormatHelper(pInfoHDMV, _pMediaType);
UNUSED_ALWAYS(pInfoHDMV);
Infos.AddTail(L"HDMV LPCM");
}
- if (_pMediaType->subtype == MEDIASUBTYPE_DOLBY_DDPLUS)
- {
+ if (_pMediaType->subtype == MEDIASUBTYPE_DOLBY_DDPLUS) {
Infos.AddTail(L"Dolby Digital Plus");
- }
- else
- {
- switch (pInfo->wFormatTag)
- {
- case WAVE_FORMAT_PS2_PCM:
- {
+ } else {
+ switch (pInfo->wFormatTag) {
+ case WAVE_FORMAT_PS2_PCM: {
Infos.AddTail(L"PS2 PCM");
}
break;
- case WAVE_FORMAT_PS2_ADPCM:
- {
+ case WAVE_FORMAT_PS2_ADPCM: {
Infos.AddTail(L"PS2 ADPCM");
}
break;
- case WAVE_FORMAT_DVD_DTS:
- {
- if (pPresentationDesc)
+ case WAVE_FORMAT_DVD_DTS: {
+ if (pPresentationDesc) {
Infos.AddTail(pPresentationDesc);
- else
+ } else {
Infos.AddTail(L"DTS");
+ }
}
break;
- case WAVE_FORMAT_DOLBY_AC3:
- {
- if (pPresentationDesc)
+ case WAVE_FORMAT_DOLBY_AC3: {
+ if (pPresentationDesc) {
Infos.AddTail(pPresentationDesc);
- else
+ } else {
Infos.AddTail(L"Dolby Digital");
+ }
}
break;
- case WAVE_FORMAT_AAC:
- {
+ case WAVE_FORMAT_AAC: {
Infos.AddTail(L"AAC");
}
break;
- case WAVE_FORMAT_MP3:
- {
+ case WAVE_FORMAT_MP3: {
Infos.AddTail(L"MP3");
}
break;
- case WAVE_FORMAT_MPEG:
- {
+ case WAVE_FORMAT_MPEG: {
const MPEG1WAVEFORMAT* pInfoMPEG1 = GetFormatHelper(pInfoMPEG1, _pMediaType);
int layer = GetHighestBitSet32(pInfoMPEG1->fwHeadLayer) + 1;
@@ -380,59 +380,57 @@ CString GetMediaTypeDesc(const CMediaType *_pMediaType, const CHdmvClipInfo::Str
}
}
- 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;
+ 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)
+ } else if (pInfo->nSamplesPerSec) {
Infos.AddTail(FormatString(L"%.1f kHz", double(pInfo->nSamplesPerSec)/1000.0));
- if (pInfo->nChannels)
+ }
+ if (pInfo->nChannels) {
Infos.AddTail(FormatString(L"%d chn", pInfo->nChannels));
- if (pInfo->wBitsPerSample)
+ }
+ if (pInfo->wBitsPerSample) {
Infos.AddTail(FormatString(L"%d bit", pInfo->wBitsPerSample));
- if (pInfo->nAvgBytesPerSec)
+ }
+ if (pInfo->nAvgBytesPerSec) {
Infos.AddTail(FormatBitrate(pInfo->nAvgBytesPerSec * 8));
+ }
}
- }
- else if (_pMediaType->majortype == MEDIATYPE_Subtitle)
- {
+ } else if (_pMediaType->majortype == MEDIATYPE_Subtitle) {
MajorType = "Subtitle";
- if (pPresentationDesc)
+ if (pPresentationDesc) {
Infos.AddTail(pPresentationDesc);
+ }
- if (_pMediaType->cbFormat == sizeof(SUBTITLEINFO))
- {
+ if (_pMediaType->cbFormat == sizeof(SUBTITLEINFO)) {
const SUBTITLEINFO *pInfo = GetFormatHelper(pInfo, _pMediaType);
CString name = ISO6392ToLanguage(pInfo->IsoLang);
- if (pInfo->TrackName[0])
+ if (pInfo->TrackName[0]) {
Infos.AddHead(pInfo->TrackName);
- if (!name.IsEmpty())
+ }
+ if (!name.IsEmpty()) {
Infos.AddHead(name);
- }
- else
- {
- if (pClipInfo)
- {
+ }
+ } else {
+ if (pClipInfo) {
CString name = ISO6392ToLanguage(pClipInfo->m_LanguageCode);
- if (!name.IsEmpty())
+ if (!name.IsEmpty()) {
Infos.AddHead(name);
+ }
}
}
}
- if (!Infos.IsEmpty())
- {
+ if (!Infos.IsEmpty()) {
CString Ret;
Ret += MajorType;
@@ -440,14 +438,14 @@ CString GetMediaTypeDesc(const CMediaType *_pMediaType, const CHdmvClipInfo::Str
bool bFirst = true;
- for(POSITION pos = Infos.GetHeadPosition(); pos; Infos.GetNext(pos))
- {
+ for(POSITION pos = Infos.GetHeadPosition(); pos; Infos.GetNext(pos)) {
CString& String = Infos.GetAt(pos);
- if (bFirst)
+ if (bFirst) {
Ret += String;
- else
+ } else {
Ret += L", " + String;
+ }
bFirst = false;
}
@@ -470,9 +468,9 @@ CMpegSplitterFilter::CMpegSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr, const CLS
STDMETHODIMP CMpegSplitterFilter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- return
+ return
QI(IAMStreamSelect)
__super::NonDelegatingQueryInterface(riid, ppv);
}
@@ -481,32 +479,30 @@ STDMETHODIMP CMpegSplitterFilter::GetClassID(CLSID* pClsID)
{
CheckPointer (pClsID, E_POINTER);
- if (m_pPipoBimbo)
- {
+ if (m_pPipoBimbo) {
memcpy (pClsID, &CLSID_WMAsfReader, sizeof (GUID));
return S_OK;
- }
- else
+ } else {
return __super::GetClassID(pClsID);
+ }
}
void CMpegSplitterFilter::ReadClipInfo(LPCOLESTR pszFileName)
{
- if (wcslen (pszFileName) > 0)
- {
+ 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)
- {
+
+ if (_wsplitpath_s (pszFileName, Drive, countof(Drive), Dir, countof(Dir), Filename, countof(Filename), Ext, countof(Ext)) == 0) {
CString strClipInfo;
- if (Drive[0])
+ if (Drive[0]) {
strClipInfo.Format (_T("%s\\%s\\..\\CLIPINF\\%s.clpi"), Drive, Dir, Filename);
- else
+ } else {
strClipInfo.Format (_T("%s\\..\\CLIPINF\\%s.clpi"), Dir, Filename);
+ }
m_ClipInfo.ReadInfo (strClipInfo);
}
@@ -516,7 +512,7 @@ void CMpegSplitterFilter::ReadClipInfo(LPCOLESTR pszFileName)
STDMETHODIMP CMpegSplitterFilter::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt)
{
HRESULT hr;
-
+
return __super::Load (pszFileName, pmt);
}
@@ -526,22 +522,21 @@ HRESULT CMpegSplitterFilter::DemuxNextPacket(REFERENCE_TIME rtStartOffset)
HRESULT hr;
BYTE b;
- if(m_pFile->m_type == CMpegSplitterFile::ps || m_pFile->m_type == CMpegSplitterFile::es)
- {
- if(!m_pFile->NextMpegStartCode(b))
+ if(m_pFile->m_type == CMpegSplitterFile::ps || m_pFile->m_type == CMpegSplitterFile::es) {
+ if(!m_pFile->NextMpegStartCode(b)) {
return S_FALSE;
+ }
- if(b == 0xba) // program stream header
- {
+ if(b == 0xba) { // program stream header
CMpegSplitterFile::pshdr h;
- if(!m_pFile->Read(h))
+ if(!m_pFile->Read(h)) {
return S_FALSE;
- }
- else if(b == 0xbb) // program stream system header
- {
+ }
+ } else if(b == 0xbb) { // program stream system header
CMpegSplitterFile::pssyshdr h;
- if(!m_pFile->Read(h))
+ if(!m_pFile->Read(h)) {
return S_FALSE;
+ }
}
#if (EVO_SUPPORT == 0)
else if(b >= 0xbd && b < 0xf0) // pes packet
@@ -551,10 +546,11 @@ HRESULT CMpegSplitterFilter::DemuxNextPacket(REFERENCE_TIME rtStartOffset)
{
CMpegSplitterFile::peshdr h;
- if(!m_pFile->Read(h, b) || !h.len) return S_FALSE;
+ if(!m_pFile->Read(h, b) || !h.len) {
+ return S_FALSE;
+ }
- if(h.type == CMpegSplitterFile::mpeg2 && h.scrambling)
- {
+ if(h.type == CMpegSplitterFile::mpeg2 && h.scrambling) {
ASSERT(0);
return E_FAIL;
}
@@ -563,8 +559,7 @@ HRESULT CMpegSplitterFilter::DemuxNextPacket(REFERENCE_TIME rtStartOffset)
DWORD TrackNumber = m_pFile->AddStream(0, b, h.len);
- if(GetOutputPin(TrackNumber))
- {
+ if(GetOutputPin(TrackNumber)) {
CAutoPtr<Packet> p(DNew Packet());
p->TrackNumber = TrackNumber;
@@ -580,52 +575,46 @@ HRESULT CMpegSplitterFilter::DemuxNextPacket(REFERENCE_TIME rtStartOffset)
}
m_pFile->Seek(pos + h.len);
}
- }
- else if(m_pFile->m_type == CMpegSplitterFile::ts)
- {
+ } else if(m_pFile->m_type == CMpegSplitterFile::ts) {
CMpegSplitterFile::trhdr h;
- if(!m_pFile->Read(h))
+ if(!m_pFile->Read(h)) {
return S_FALSE;
+ }
__int64 pos = m_pFile->GetPos();
- if(h.payload && h.payloadstart)
+ if(h.payload && h.payloadstart) {
m_pFile->UpdatePrograms(h);
+ }
- if(h.payload && h.pid >= 16 && h.pid < 0x1fff && !h.scrambling)
- {
+ if(h.payload && h.pid >= 16 && h.pid < 0x1fff && !h.scrambling) {
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)
- {
+ 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, h.bytes - (DWORD)(m_pFile->GetPos() - pos));
}
- if(GetOutputPin(TrackNumber))
- {
+ if(GetOutputPin(TrackNumber)) {
CAutoPtr<Packet> p(DNew Packet());
p->TrackNumber = TrackNumber;
p->bSyncPoint = !!h2.fpts;
p->bAppendable = !h2.fpts;
- if (h.fPCR)
- {
+ if (h.fPCR) {
CRefTime rtNow;
StreamTime(rtNow);
TRACE ("Now=%S PCR=%S\n", ReftimeToString(rtNow.m_time), ReftimeToString(h.PCR));
}
- if (h2.fpts && h.pid == 241)
- {
+ if (h2.fpts && h.pid == 241) {
TRACE ("Sub=%S\n", ReftimeToString(h2.pts - rtStartOffset));
}
@@ -641,19 +630,17 @@ HRESULT CMpegSplitterFilter::DemuxNextPacket(REFERENCE_TIME rtStartOffset)
}
m_pFile->Seek(h.next);
- }
- else if(m_pFile->m_type == CMpegSplitterFile::pva)
- {
+ } else if(m_pFile->m_type == CMpegSplitterFile::pva) {
CMpegSplitterFile::pvahdr h;
- if(!m_pFile->Read(h))
+ if(!m_pFile->Read(h)) {
return S_FALSE;
+ }
DWORD TrackNumber = h.streamid;
__int64 pos = m_pFile->GetPos();
- if(GetOutputPin(TrackNumber))
- {
+ if(GetOutputPin(TrackNumber)) {
CAutoPtr<Packet> p(DNew Packet());
p->TrackNumber = TrackNumber;
@@ -686,22 +673,20 @@ HRESULT CMpegSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
ReadClipInfo (GetPartFilename(pAsyncReader));
m_pFile.Attach(DNew CMpegSplitterFile(pAsyncReader, hr, m_ClipInfo.IsHdmv(), m_ClipInfo));
- if(!m_pFile) return E_OUTOFMEMORY;
+ if(!m_pFile) {
+ return E_OUTOFMEMORY;
+ }
- if(FAILED(hr))
- {
+ if(FAILED(hr)) {
m_pFile.Free();
return hr;
}
// Create
- if (m_ClipInfo.IsHdmv())
- {
- for (int i=0; i<m_ClipInfo.GetStreamNumber(); i++)
- {
+ if (m_ClipInfo.IsHdmv()) {
+ for (int i=0; i<m_ClipInfo.GetStreamNumber(); i++) {
CHdmvClipInfo::Stream* stream = m_ClipInfo.GetStreamByIndex (i);
- if (stream->m_Type == PRESENTATION_GRAPHICS_STREAM)
- {
+ if (stream->m_Type == PRESENTATION_GRAPHICS_STREAM) {
m_pFile->AddHdmvPGStream (stream->m_PID, stream->m_LanguageCode);
}
}
@@ -710,24 +695,19 @@ HRESULT CMpegSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
m_rtNewStart = m_rtCurrent = 0;
m_rtNewStop = m_rtStop = m_rtDuration = 0;
- for(int i = 0; i < countof(m_pFile->m_streams); i++)
- {
+ for(int i = 0; i < countof(m_pFile->m_streams); i++) {
POSITION pos = m_pFile->m_streams[i].GetHeadPosition();
- while(pos)
- {
+ 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)
- {
+ if (i == CMpegSplitterFile::subpic && s.pid == NO_SUBTITLE_PID) {
str = _T("No subtitles");
- }
- else
- {
+ } else {
int iProgram;
const CHdmvClipInfo::Stream *pClipInfo;
const CMpegSplitterFile::program * pProgram = m_pFile->FindProgram(s.pid, iProgram, pClipInfo);
@@ -737,28 +717,28 @@ HRESULT CMpegSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
CString FormatDesc = GetMediaTypeDesc(&s.mt, pClipInfo, StreamType);
- 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
+ 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));
- if (i == CMpegSplitterFile::subpic)
+ if (i == CMpegSplitterFile::subpic) {
(static_cast<CMpegSplitterOutputPin*>(pPinOut.m_p))->SetMaxShift (_I64_MAX);
- if(S_OK == AddOutputPin(s, pPinOut))
+ }
+ if(S_OK == AddOutputPin(s, pPinOut)) {
break;
+ }
}
}
- if(m_rtPlaylistDuration)
- {
+ if(m_rtPlaylistDuration) {
m_rtNewStop = m_rtStop = m_rtDuration = m_rtPlaylistDuration;
- }
- else if(m_pFile->IsRandomAccess() && m_pFile->m_rate)
- {
+ } else if(m_pFile->IsRandomAccess() && m_pFile->m_rate) {
m_rtNewStop = m_rtStop = m_rtDuration = 10000000i64 * m_pFile->GetLength() / m_pFile->m_rate;
}
@@ -768,7 +748,9 @@ HRESULT CMpegSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
bool CMpegSplitterFilter::DemuxInit()
{
SetThreadName((DWORD)-1, "CMpegSplitterFilter");
- if(!m_pFile) return(false);
+ if(!m_pFile) {
+ return(false);
+ }
m_rtStartOffset = 0;
@@ -779,27 +761,22 @@ void CMpegSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
{
CAtlList<CMpegSplitterFile::stream>* pMasterStream = m_pFile->GetMasterStream();
- if(!pMasterStream)
- {
+ if(!pMasterStream) {
ASSERT(0);
return;
}
- if(m_pFile->IsStreaming())
- {
+ 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)
- {
+
+ if(rt <= rtPreroll || m_rtDuration <= 0) {
m_pFile->Seek(0);
- }
- else
- {
+ } else {
__int64 len = m_pFile->GetLength();
__int64 seekpos = (__int64)(1.0*rt/m_rtDuration*len);
__int64 minseekpos = _I64_MAX;
@@ -808,50 +785,46 @@ void CMpegSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
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);
+ 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);
+ CBaseSplitterOutputPin* pPin = GetOutputPin(TrackNum);
+ if(pPin && pPin->IsConnected()) {
+ m_pFile->Seek(seekpos);
- REFERENCE_TIME pdt = _I64_MIN;
+ REFERENCE_TIME pdt = _I64_MIN;
- for(int j = 0; j < 10; j++)
- {
- REFERENCE_TIME rt = m_pFile->NextPTS(TrackNum);
+ for(int j = 0; j < 10; j++) {
+ REFERENCE_TIME rt = m_pFile->NextPTS(TrackNum);
- if(rt < 0) break;
+ if(rt < 0) {
+ break;
+ }
- REFERENCE_TIME dt = rt - rtmax;
- if(dt > 0 && dt == pdt) dt = 10000000i64;
+ REFERENCE_TIME dt = rt - rtmax;
+ if(dt > 0 && dt == pdt) {
+ dt = 10000000i64;
+ }
- if(rtmin <= rt && rt <= rtmax || pdt > 0 && dt < 0)
- {
- minseekpos = min(minseekpos, m_pFile->GetPos());
- break;
- }
+ if(rtmin <= rt && rt <= rtmax || pdt > 0 && dt < 0) {
+ minseekpos = min(minseekpos, m_pFile->GetPos());
+ break;
+ }
+
+ m_pFile->Seek(m_pFile->GetPos() - (__int64)(1.0*dt/m_rtDuration*len));
- m_pFile->Seek(m_pFile->GetPos() - (__int64)(1.0*dt/m_rtDuration*len));
-
- pdt = dt;
+ //pdt = dt;
+ }
}
}
}
- }
- if(minseekpos != _I64_MAX)
- {
+ if(minseekpos != _I64_MAX) {
seekpos = minseekpos;
- }
- else
- {
+ } else {
// this file is probably screwed up, try plan B, seek simply by bitrate
rt -= rtPreroll;
@@ -869,11 +842,11 @@ bool CMpegSplitterFilter::DemuxLoop()
REFERENCE_TIME rtStartOffset = m_rtStartOffset ? m_rtStartOffset : m_pFile->m_rtMin;
HRESULT hr = S_OK;
- while(SUCCEEDED(hr) && !CheckRequest(NULL))
- {
+ while(SUCCEEDED(hr) && !CheckRequest(NULL)) {
if((hr = m_pFile->HasMoreData(1024*500)) == S_OK)
- if((hr = DemuxNextPacket(rtStartOffset)) == S_FALSE)
+ if((hr = DemuxNextPacket(rtStartOffset)) == S_FALSE) {
Sleep(1);
+ }
}
return(true);
@@ -893,63 +866,67 @@ STDMETHODIMP CMpegSplitterFilter::Count(DWORD* pcStreams)
*pcStreams = 0;
- for(int i = 0; i < countof(m_pFile->m_streams); i++)
+ for(int i = 0; i < countof(m_pFile->m_streams); i++) {
(*pcStreams) += m_pFile->m_streams[i].GetCount();
+ }
return S_OK;
}
STDMETHODIMP CMpegSplitterFilter::Enable(long lIndex, DWORD dwFlags)
{
- if(!(dwFlags & AMSTREAMSELECTENABLE_ENABLE))
+ if(!(dwFlags & AMSTREAMSELECTENABLE_ENABLE)) {
return E_NOTIMPL;
+ }
- for(int i = 0, j = 0; i < countof(m_pFile->m_streams); i++)
- {
+ 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)
- {
+
+ if(lIndex >= j && lIndex < j+cnt) {
lIndex -= j;
POSITION pos = m_pFile->m_streams[i].FindIndex(lIndex);
- if(!pos) return E_UNEXPECTED;
+ if(!pos) {
+ return E_UNEXPECTED;
+ }
CMpegSplitterFile::stream& to = m_pFile->m_streams[i].GetAt(pos);
pos = m_pFile->m_streams[i].GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CMpegSplitterFile::stream& from = m_pFile->m_streams[i].GetNext(pos);
- if(!GetOutputPin(from)) continue;
+ if(!GetOutputPin(from)) {
+ continue;
+ }
HRESULT hr;
- if(FAILED(hr = RenameOutputPin(from, to, &to.mt)))
+ if(FAILED(hr = RenameOutputPin(from, to, &to.mt))) {
return hr;
+ }
// 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;
+ 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)
- {
+ while(pos) {
CMpegSplitterFile::stream& from = m_pFile->m_streams[k].GetNext(pos);
- if(!GetOutputPin(from)) continue;
+ 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)
+ 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;
}
}
@@ -969,67 +946,52 @@ STDMETHODIMP CMpegSplitterFilter::Enable(long lIndex, DWORD dwFlags)
LONGLONG GetMediaTypeQuality(const CMediaType *_pMediaType, int _PresentationFormat)
{
- if (_pMediaType->formattype == FORMAT_WaveFormatEx)
- {
+ 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)
- {
+ if (_pMediaType->subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO) {
TypePriority = 12;
- }
- else
- {
- if (_PresentationFormat == AUDIO_STREAM_DTS_HD_MASTER_AUDIO)
+ } 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)
+ } else if (_PresentationFormat == AUDIO_STREAM_DTS_HD) {
TypePriority = 11;
- else if (_PresentationFormat == AUDIO_STREAM_AC3_TRUE_HD)
+ } else if (_PresentationFormat == AUDIO_STREAM_AC3_TRUE_HD) {
TypePriority = 12;
- else if (_PresentationFormat == AUDIO_STREAM_AC3_PLUS)
+ } else if (_PresentationFormat == AUDIO_STREAM_AC3_PLUS) {
TypePriority = 10;
- else
- {
- switch (pInfo->wFormatTag)
- {
- case WAVE_FORMAT_PS2_PCM:
- {
+ } else {
+ switch (pInfo->wFormatTag) {
+ case WAVE_FORMAT_PS2_PCM: {
TypePriority = 12;
}
break;
- case WAVE_FORMAT_PS2_ADPCM:
- {
+ case WAVE_FORMAT_PS2_ADPCM: {
TypePriority = 4;
}
break;
- case WAVE_FORMAT_DVD_DTS:
- {
+ case WAVE_FORMAT_DVD_DTS: {
TypePriority = 9;
}
break;
- case WAVE_FORMAT_DOLBY_AC3:
- {
+ case WAVE_FORMAT_DOLBY_AC3: {
TypePriority = 8;
}
break;
- case WAVE_FORMAT_AAC:
- {
+ case WAVE_FORMAT_AAC: {
TypePriority = 7;
}
break;
- case WAVE_FORMAT_MP3:
- {
+ case WAVE_FORMAT_MP3: {
TypePriority = 6;
}
break;
- case WAVE_FORMAT_MPEG:
- {
+ case WAVE_FORMAT_MPEG: {
TypePriority = 5;
}
break;
@@ -1053,8 +1015,7 @@ LONGLONG GetMediaTypeQuality(const CMediaType *_pMediaType, int _PresentationFor
bool CMpegSplitterFile::stream::operator < (const stream &_Other) const
{
- if (mt.majortype == MEDIATYPE_Audio && _Other.mt.majortype == MEDIATYPE_Audio)
- {
+ 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);
@@ -1063,18 +1024,22 @@ bool CMpegSplitterFile::stream::operator < (const stream &_Other) const
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)
+
+ if (mt.formattype == FORMAT_WaveFormatEx && _Other.mt.formattype != FORMAT_WaveFormatEx) {
return true;
- if (mt.formattype != FORMAT_WaveFormatEx && _Other.mt.formattype == FORMAT_WaveFormatEx)
+ }
+ 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)
+ if (Quality0 > Quality1) {
return true;
- if (Quality0 < Quality1)
+ }
+ if (Quality0 < Quality1) {
return false;
+ }
}
DWORD DefaultFirst = *this;
DWORD DefaultSecond = _Other;
@@ -1083,41 +1048,49 @@ bool CMpegSplitterFile::stream::operator < (const stream &_Other) const
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++)
- {
+ 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)
- {
+
+ if(lIndex >= j && lIndex < j+cnt) {
lIndex -= j;
-
+
POSITION pos = m_pFile->m_streams[i].FindIndex(lIndex);
- if(!pos) return E_UNEXPECTED;
+ 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(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)
- {
+ if(ppszName) {
CStringW name = CMpegSplitterFile::CStreamList::ToString(i);
CStringW str;
- if (i == CMpegSplitterFile::subpic && s.pid == NO_SUBTITLE_PID)
- {
+ if (i == CMpegSplitterFile::subpic && s.pid == NO_SUBTITLE_PID) {
str = _T("No subtitles");
*plcid = (LCID)LCID_NOSUBTITLES;
- }
- else
- {
+ } else {
int iProgram;
const CHdmvClipInfo::Stream *pClipInfo;
const CMpegSplitterFile::program * pProgram = m_pFile->FindProgram(s.pid, iProgram, pClipInfo);
@@ -1127,16 +1100,19 @@ STDMETHODIMP CMpegSplitterFilter::Info(long lIndex, AM_MEDIA_TYPE** ppmt, DWORD*
CString FormatDesc = GetMediaTypeDesc(&s.mt, pClipInfo, StreamType);
- 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
+ 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;
+ if(*ppszName == NULL) {
+ return E_OUTOFMEMORY;
+ }
wcscpy_s(*ppszName, str.GetLength()+1, str);
}
@@ -1200,14 +1176,14 @@ HRESULT CMpegSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p)
{
CAutoLock cAutoLock(this);
- if(p->rtStart != Packet::INVALID_TIME)
- {
+ 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;
+ if(_abs64(rt - m_rtPrev) > m_rtMaxShift) {
+ m_rtOffset += m_rtPrev - rt;
+ }
p->rtStart += m_rtOffset;
p->rtStop += m_rtOffset;
@@ -1215,60 +1191,57 @@ HRESULT CMpegSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p)
m_rtPrev = p->rtStart;
}
-
- if (p->pmt)
- {
- if (*((CMediaType *)p->pmt) != m_mt)
+
+ 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))
+ 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)
- {
+ if(!m_p) {
BYTE* base = p->GetData();
BYTE* s = base;
BYTE* e = s + p->GetCount();
- for(; s < e; s++)
- {
- if(*s != 0xff) continue;
+ for(; s < e; s++) {
+ if(*s != 0xff) {
+ continue;
+ }
- if(s == e-1 || (s[1]&0xf6) == 0xf0)
- {
+ if(s == e-1 || (s[1]&0xf6) == 0xf0) {
memmove(base, s, e - s);
p->SetCount(e - s);
m_p = p;
break;
}
}
- }
- else
- {
+ } else {
m_p->Append(*p);
}
- while(m_p && m_p->GetCount() > 9)
- {
+ 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;
+ s += 7;
+ len -= 7;
+ if(crc) {
+ s += 2, len -= 2;
+ }
- if(e - s < len)
- {
+ if(e - s < len) {
break;
}
- if(len <= 0 || e - s >= len + 2 && (s[len] != 0xff || (s[len+1]&0xf6) != 0xf0))
- {
+ if(len <= 0 || e - s >= len + 2 && (s[len] != 0xff || (s[len+1]&0xf6) != 0xf0)) {
m_p.Free();
break;
}
@@ -1285,7 +1258,8 @@ HRESULT CMpegSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p)
p2->rtStop = m_p->rtStop;
m_p->rtStop = Packet::INVALID_TIME;
- p2->pmt = m_p->pmt; m_p->pmt = NULL;
+ p2->pmt = m_p->pmt;
+ m_p->pmt = NULL;
p2->SetData(s, len);
s += len;
@@ -1293,26 +1267,32 @@ HRESULT CMpegSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p)
m_p->SetCount(e - s);
HRESULT hr = __super::DeliverPacket(p2);
- if(hr != S_OK) return hr;
+ 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);
-
+ 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')) // just like aac, this has to be starting nalus, more can be packed together
- {
- if(!m_p)
- {
+ } else if(m_mt.subtype == FOURCCMap('1CVA') || m_mt.subtype == FOURCCMap('1cva')) { // 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;
@@ -1333,15 +1313,20 @@ HRESULT CMpegSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p)
BYTE* start = m_p->GetData();
BYTE* end = start + m_p->GetCount();
- while(start <= end-4 && *(DWORD*)start != 0x01000000) start++;
+ while(start <= end-4 && *(DWORD*)start != 0x01000000) {
+ start++;
+ }
- while(start <= end-4)
- {
+ while(start <= end-4) {
BYTE* next = start+1;
- while(next <= end-4 && *(DWORD*)next != 0x01000000) next++;
+ while(next <= end-4 && *(DWORD*)next != 0x01000000) {
+ next++;
+ }
- if(next >= end-4) break;
+ if(next >= end-4) {
+ break;
+ }
int size = next - start;
@@ -1350,24 +1335,24 @@ HRESULT CMpegSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p)
CAutoPtr<Packet> p2;
- while (Nalu.ReadNext())
- {
- DWORD dwNalLength =
+ 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)
+
+ if (p2 == NULL) {
p2 = p3;
- else
+ } else {
p2->Append(*p3);
+ }
}
p2->TrackNumber = m_p->TrackNumber;
@@ -1377,74 +1362,72 @@ HRESULT CMpegSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p)
p2->bSyncPoint = m_p->bSyncPoint;
m_p->bSyncPoint = FALSE;
- p2->rtStart = m_p->rtStart; 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->pmt = m_p->pmt;
+ m_p->pmt = NULL;
m_pl.AddTail(p2);
- if(p->rtStart != Packet::INVALID_TIME)
- {
+ if(p->rtStart != Packet::INVALID_TIME) {
m_p->rtStart = p->rtStart;
m_p->rtStop = p->rtStop;
p->rtStart = Packet::INVALID_TIME;
}
- if(p->bDiscontinuity)
- {
+ if(p->bDiscontinuity) {
m_p->bDiscontinuity = p->bDiscontinuity;
p->bDiscontinuity = FALSE;
}
- if(p->bSyncPoint)
- {
+ if(p->bSyncPoint) {
m_p->bSyncPoint = p->bSyncPoint;
p->bSyncPoint = FALSE;
}
- if(m_p->pmt)
+ if(m_p->pmt) {
DeleteMediaType(m_p->pmt);
-
+ }
+
m_p->pmt = p->pmt;
p->pmt = NULL;
start = next;
}
- if(start > m_p->GetData())
- {
+ if(start > m_p->GetData()) {
m_p->RemoveAt(0, start - m_p->GetData());
}
- for(POSITION pos = m_pl.GetHeadPosition(); pos; m_pl.GetNext(pos))
- {
- if(pos == m_pl.GetHeadPosition())
+ 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 = true;
+ }
- if((pData[4]&0x1f) == 0x09 || !m_fHasAccessUnitDelimiters && pPacket->rtStart != Packet::INVALID_TIME)
- {
+ if((pData[4]&0x1f) == 0x09 || !m_fHasAccessUnitDelimiters && pPacket->rtStart != Packet::INVALID_TIME) {
p = m_pl.RemoveHead();
- while(pos != m_pl.GetHeadPosition())
- {
+ 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;
+ if(hr != S_OK) {
+ return hr;
+ }
}
}
return S_OK;
- }
- else if(m_mt.subtype == FOURCCMap('1CVW') || m_mt.subtype == FOURCCMap('1cvw')) // just like aac, this has to be starting nalus, more can be packed together
- {
- if(!m_p)
- {
+ } else if(m_mt.subtype == FOURCCMap('1CVW') || m_mt.subtype == FOURCCMap('1cvw')) { // 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;
@@ -1466,35 +1449,34 @@ HRESULT CMpegSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p)
BYTE* end = start + m_p->GetCount();
bool bSeqFound = false;
- while(start <= end-4)
- {
- if (*(DWORD*)start == 0x0D010000)
- {
+ while(start <= end-4) {
+ if (*(DWORD*)start == 0x0D010000) {
bSeqFound = true;
break;
- }
- else if (*(DWORD*)start == 0x0F010000)
+ } else if (*(DWORD*)start == 0x0F010000) {
break;
+ }
start++;
}
- while(start <= end-4)
- {
+ while(start <= end-4) {
BYTE* next = start+1;
- while(next <= end-4)
- {
- if (*(DWORD*)next == 0x0D010000)
- {
- if (bSeqFound) break;
+ while(next <= end-4) {
+ if (*(DWORD*)next == 0x0D010000) {
+ if (bSeqFound) {
+ break;
+ }
bSeqFound = true;
- }
- else if (*(DWORD*)next == 0x0F010000)
+ } else if (*(DWORD*)next == 0x0F010000) {
break;
+ }
next++;
}
- if(next >= end-4) break;
+ if(next >= end-4) {
+ break;
+ }
int size = next - start - 4;
UNUSED_ALWAYS(size);
@@ -1519,27 +1501,27 @@ HRESULT CMpegSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p)
p2->SetData(start, next - start);
HRESULT hr = __super::DeliverPacket(p2);
- if(hr != S_OK) return hr;
+ if(hr != S_OK) {
+ return hr;
+ }
- if(p->rtStart != Packet::INVALID_TIME)
- {
- m_p->rtStart = p->rtStart;
+ 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)
- {
+ if(p->bDiscontinuity) {
m_p->bDiscontinuity = p->bDiscontinuity;
p->bDiscontinuity = FALSE;
}
- if(p->bSyncPoint)
- {
+ if(p->bSyncPoint) {
m_p->bSyncPoint = p->bSyncPoint;
p->bSyncPoint = FALSE;
}
- if(m_p->pmt)
+ if(m_p->pmt) {
DeleteMediaType(m_p->pmt);
-
+ }
+
m_p->pmt = p->pmt;
p->pmt = NULL;
@@ -1547,60 +1529,58 @@ HRESULT CMpegSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p)
bSeqFound = (*(DWORD*)start == 0x0D010000);
}
- if(start > m_p->GetData())
- {
+ 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)))
- {
+ else if (m_bFilterDTSMA && ((m_mt.subtype == MEDIASUBTYPE_DTS || m_mt.subtype == MEDIASUBTYPE_WAVE_DTS))) {
BYTE* start = p->GetData();
BYTE* end = start + p->GetCount();
- if (end - start < 4 && !p->pmt)
- return S_OK; // Should be invalid packet
+ if (end - start < 4 && !p->pmt) {
+ return S_OK; // Should be invalid packet
+ }
BYTE* hdr = start;
int Type;
- // 16 bits big endian bitstream
- if (hdr[0] == 0x7f && hdr[1] == 0xfe &&
- hdr[2] == 0x80 && hdr[3] == 0x01)
+ // 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)
+ // 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)
+ // 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)
+ // 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;
- }
- }
- else if (m_mt.subtype == MEDIASUBTYPE_HDMV_LPCM_AUDIO)
- {
+ // no sync
+ else if (!p->pmt) {
+ return S_OK;
+ }
+ } else if (m_mt.subtype == MEDIASUBTYPE_HDMV_LPCM_AUDIO) {
BYTE* start = p->GetData();
p->SetData(start + 4, p->GetCount() - 4);
- }
- else
- {
+ } else {
m_p.Free();
m_pl.RemoveAll();
}
@@ -1615,15 +1595,15 @@ STDMETHODIMP CMpegSplitterOutputPin::Connect(IPin* pReceivePin, const AM_MEDIA_T
PIN_INFO PinInfo;
GUID FilterClsid;
- if (SUCCEEDED (pReceivePin->QueryPinInfo (&PinInfo)))
- {
- if (SUCCEEDED (PinInfo.pFilter->GetClassID(&FilterClsid)))
- {
- if (FilterClsid == CLSID_DMOWrapperFilter)
+ 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)
+ else if (FilterClsid == CLSID_AC3Filter) {
m_bFilterDTSMA = true;
+ }
}
PinInfo.pFilter->Release();
}
diff --git a/src/filters/parser/MpegSplitter/MpegSplitter.h b/src/filters/parser/MpegSplitter/MpegSplitter.h
index a5155fa8c..abceb4cd9 100644
--- a/src/filters/parser/MpegSplitter/MpegSplitter.h
+++ b/src/filters/parser/MpegSplitter/MpegSplitter.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -25,7 +25,7 @@
#include "MpegSplitterFile.h"
class __declspec(uuid("DC257063-045F-4BE2-BD5B-E12279C464F0"))
-CMpegSplitterFilter : public CBaseSplitterFilter, public IAMStreamSelect
+ CMpegSplitterFilter : public CBaseSplitterFilter, public IAMStreamSelect
{
REFERENCE_TIME m_rtStartOffset;
bool m_pPipoBimbo;
@@ -47,22 +47,24 @@ protected:
public:
CMpegSplitterFilter(LPUNKNOWN pUnk, HRESULT* phr, const CLSID& clsid = __uuidof(CMpegSplitterFilter));
- void SetPipo(bool bPipo) { m_pPipoBimbo = bPipo; };
+ void SetPipo(bool bPipo) {
+ m_pPipoBimbo = bPipo;
+ };
DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
STDMETHODIMP GetClassID(CLSID* pClsID);
STDMETHODIMP Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt);
// 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);
};
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));
@@ -85,5 +87,7 @@ public:
CMpegSplitterOutputPin(CAtlArray<CMediaType>& mts, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
virtual ~CMpegSplitterOutputPin();
STDMETHODIMP Connect(IPin* pReceivePin, const AM_MEDIA_TYPE* pmt);
- void SetMaxShift(REFERENCE_TIME rtMaxShift) { m_rtMaxShift = rtMaxShift; };
+ 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 5200baec4..5624d1a2b 100644
--- a/src/filters/parser/MpegSplitter/MpegSplitterFile.cpp
+++ b/src/filters/parser/MpegSplitter/MpegSplitterFile.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -39,10 +39,12 @@ CMpegSplitterFile::CMpegSplitterFile(IAsyncReader* pAsyncReader, HRESULT& hr, bo
, m_ClipInfo(ClipInfo)
{
- if(SUCCEEDED(hr)) hr = Init();
+ if(SUCCEEDED(hr)) {
+ hr = Init(pAsyncReader);
+ }
}
-HRESULT CMpegSplitterFile::Init()
+HRESULT CMpegSplitterFile::Init(IAsyncReader* pAsyncReader)
{
HRESULT hr;
@@ -52,104 +54,109 @@ HRESULT CMpegSplitterFile::Init()
Seek(0);
- if(m_type == us)
- {
- if(BitRead(32, true) == 'TFrc') Seek(0x67c);
+ if(m_type == 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 = ts;
+ for(trhdr h; cnt < limit && Read(h); cnt++) {
+ Seek(h.next);
+ }
+ if(cnt >= limit) {
+ m_type = ts;
+ }
}
Seek(0);
- if(m_type == us)
- {
+ if(m_type == us) {
int cnt = 0, limit = 4;
- for(pvahdr h; cnt < limit && Read(h); cnt++) Seek(GetPos() + h.length);
- if(cnt >= limit) m_type = pva;
+ for(pvahdr h; cnt < limit && Read(h); cnt++) {
+ Seek(GetPos() + h.length);
+ }
+ if(cnt >= limit) {
+ m_type = pva;
+ }
}
Seek(0);
- if(m_type == us)
- {
+ if(m_type == us) {
BYTE b;
- for(int i = 0; (i < 4 || GetPos() < 65536) && m_type == us && NextMpegStartCode(b); i++)
- {
- if(b == 0xba)
- {
+ for(int i = 0; (i < 4 || GetPos() < 65536) && m_type == us && NextMpegStartCode(b); i++) {
+ if(b == 0xba) {
pshdr h;
- if(Read(h))
- {
+ if(Read(h)) {
m_type = 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
- {
+ } 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)
+ if(Read(h, b) && BitRead(24, true) == 0x000001) {
m_type = es;
+ }
}
}
}
Seek(0);
- if(m_type == us)
+ if(m_type == us) {
return E_FAIL;
+ }
// min/max pts & bitrate
m_rtMin = m_posMin = _I64_MAX;
m_rtMax = m_posMax = 0;
- if(IsRandomAccess() || IsStreaming())
- {
- if(IsStreaming())
- {
- for(int i = 0; i < 20 || i < 50 && S_OK != HasMoreData(1024*100, 100); i++);
+ 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++)
+ for(int i = 0, j = 5; i <= j; i++) {
fps.AddTail(i*GetLength()/j);
+ }
- for(__int64 pfp = 0; fps.GetCount(); )
- {
+ 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 ? 5*MEGABYTE : MEGABYTE/8);
- if(FAILED(hr = SearchStreams(fp, nfp)))
+ if(FAILED(hr = SearchStreams(fp, nfp, pAsyncReader))) {
return hr;
+ }
pfp = nfp;
}
- }
- else
- {
- if(FAILED(hr = SearchStreams(0, MEGABYTE/8)))
+ } else {
+ if(FAILED(hr = SearchStreams(0, MEGABYTE/8, pAsyncReader))) {
return hr;
+ }
}
- if(m_posMax - m_posMin <= 0 || m_rtMax - m_rtMin <= 0)
+ if(m_posMax - m_posMin <= 0 || m_rtMax - m_rtMin <= 0) {
return E_FAIL;
+ }
int indicated_rate = m_rate;
int detected_rate = int(10000000i64 * (m_posMax - m_posMin) / (m_rtMax - m_rtMin));
// 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)
+ 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...
+ } else {
+ ; // TODO: in this case disable seeking, or try doing something less drastical...
+ }
- if(m_streams[video].GetCount())
- {
- if (!m_bIsHdmv && m_streams[subpic].GetCount())
- {
+ if(m_streams[video].GetCount()) {
+ if (!m_bIsHdmv && m_streams[subpic].GetCount()) {
#ifndef DEBUG
stream s;
s.mt.majortype = m_streams[subpic].GetHead().mt.majortype;
@@ -157,11 +164,9 @@ HRESULT CMpegSplitterFile::Init()
s.mt.formattype = m_streams[subpic].GetHead().mt.formattype;
m_streams[subpic].Insert(s, this);
#endif
- }
- else
- {
+ } else {
// Add fake stream for "No subtitle"
- //AddHdmvPGStream (NO_SUBTITLE_PID, "---");
+ AddHdmvPGStream (NO_SUBTITLE_PID, "---");
}
}
@@ -170,19 +175,20 @@ HRESULT CMpegSplitterFile::Init()
return S_OK;
}
-void CMpegSplitterFile::OnComplete()
+void CMpegSplitterFile::OnComplete(IAsyncReader* pAsyncReader)
{
__int64 pos = GetPos();
- if(SUCCEEDED(SearchStreams(GetLength() - 500*1024, GetLength())))
- {
+ if(SUCCEEDED(SearchStreams(GetLength() - 500*1024, GetLength(), pAsyncReader))) {
int indicated_rate = m_rate;
int detected_rate = int(m_rtMax > m_rtMin ? 10000000i64 * (m_posMax - m_posMin) / (m_rtMax - m_rtMin) : 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)
+ 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...
+ } else {
+ ; // TODO: in this case disable seeking, or try doing something less drastical...
+ }
}
Seek(pos);
@@ -195,12 +201,9 @@ REFERENCE_TIME CMpegSplitterFile::NextPTS(DWORD TrackNum)
BYTE b;
- while(GetRemaining())
- {
- if(m_type == ps || m_type == es)
- {
- if(!NextMpegStartCode(b)) // continue;
- {
+ while(GetRemaining()) {
+ if(m_type == ps || m_type == es) {
+ if(!NextMpegStartCode(b)) { // continue;
ASSERT(0);
break;
}
@@ -214,12 +217,13 @@ REFERENCE_TIME CMpegSplitterFile::NextPTS(DWORD TrackNum)
#endif
{
peshdr h;
- if(!Read(h, b) || !h.len) continue;
+ if(!Read(h, b) || !h.len) {
+ continue;
+ }
__int64 pos = GetPos();
- if(h.fpts && AddStream(0, b, h.len) == TrackNum)
- {
+ if(h.fpts && AddStream(0, b, h.len) == TrackNum) {
ASSERT(h.pts >= m_rtMin && h.pts <= m_rtMax);
rt = h.pts;
break;
@@ -227,21 +231,18 @@ REFERENCE_TIME CMpegSplitterFile::NextPTS(DWORD TrackNum)
Seek(pos + h.len);
}
- }
- else if(m_type == ts)
- {
+ } else if(m_type == ts) {
trhdr h;
- if(!Read(h)) continue;
+ if(!Read(h)) {
+ continue;
+ }
rtpos = GetPos()-4;
- if(h.payload && h.payloadstart && ISVALIDPID(h.pid))
- {
+ 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, DWORD(h.bytes - (GetPos() - rtpos)) == TrackNum))
- {
+ if(NextMpegStartCode(b, 4) && Read(h2, b)) { // pes packet
+ if(h2.fpts && AddStream(h.pid, b, DWORD(h.bytes - (GetPos() - rtpos)) == TrackNum)) {
ASSERT(h2.pts >= m_rtMin && h2.pts <= m_rtMax);
rt = h2.pts;
break;
@@ -250,48 +251,52 @@ REFERENCE_TIME CMpegSplitterFile::NextPTS(DWORD TrackNum)
}
Seek(h.next);
- }
- else if(m_type == pva)
- {
+ } else if(m_type == pva) {
pvahdr h;
- if(!Read(h)) continue;
+ if(!Read(h)) {
+ continue;
+ }
- if(h.fpts)
- {
+ if(h.fpts) {
rt = h.pts;
break;
}
}
}
- if(rtpos >= 0) Seek(rtpos);
- if(rt >= 0) rt -= m_rtMin;
+ if(rtpos >= 0) {
+ Seek(rtpos);
+ }
+ if(rt >= 0) {
+ rt -= m_rtMin;
+ }
return rt;
}
-HRESULT CMpegSplitterFile::SearchStreams(__int64 start, __int64 stop)
+HRESULT CMpegSplitterFile::SearchStreams(__int64 start, __int64 stop, IAsyncReader* pAsyncReader)
{
Seek(start);
stop = min(stop, GetLength());
- while(GetPos() < stop)
- {
+ while(GetPos() < stop) {
BYTE b;
- if(m_type == ps || m_type == es)
- {
- if(!NextMpegStartCode(b)) continue;
+ if(m_type == ps || m_type == es) {
+ if(!NextMpegStartCode(b)) {
+ continue;
+ }
- if(b == 0xba) // program stream header
- {
+ if(b == 0xba) { // program stream header
pshdr h;
- if(!Read(h)) continue;
- }
- else if(b == 0xbb) // program stream system header
- {
+ if(!Read(h)) {
+ continue;
+ }
+ } else if(b == 0xbb) { // program stream system header
pssyshdr h;
- if(!Read(h)) continue;
+ if(!Read(h)) {
+ continue;
+ }
}
#if (EVO_SUPPORT == 0)
else if(b >= 0xbd && b < 0xf0) // pes packet
@@ -300,80 +305,103 @@ HRESULT CMpegSplitterFile::SearchStreams(__int64 start, __int64 stop)
#endif
{
peshdr h;
- if(!Read(h, b)) continue;
+ if(!Read(h, b)) {
+ continue;
+ }
- if(h.type == mpeg2 && h.scrambling) {ASSERT(0); return E_FAIL;}
+ 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();}
- if(m_rtMin < h.pts && m_rtMax < h.pts) {m_rtMax = h.pts; m_posMax = GetPos();}
+ 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();
AddStream(0, b, h.len);
- if(h.len) Seek(pos + h.len);
+ if(h.len) {
+ Seek(pos + h.len);
+ }
}
- }
- else if(m_type == ts)
- {
+ } else if(m_type == ts) {
trhdr h;
- if(!Read(h)) continue;
+ if(!Read(h)) {
+ continue;
+ }
__int64 pos = GetPos();
- if(h.payload && h.payloadstart)
+ if(h.payload && h.payloadstart) {
UpdatePrograms(h);
-
- if(h.payload && ISVALIDPID(h.pid))
- {
+ }
+
+ 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)
- {
+ 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)
- {
- if(m_rtMin == _I64_MAX)
- {
+ if(h2.fpts) {
+ if(m_rtMin == _I64_MAX) {
m_rtMin = h2.pts;
m_posMin = GetPos();
+ //TRACE ("m_rtMin(SearchStreams)=%S\n", ReftimeToString(m_rtMin));
}
-
- if(m_rtMin < h2.pts && m_rtMax < h2.pts)
- {
+
+ if(m_rtMin < h2.pts && m_rtMax < h2.pts) {
m_rtMax = h2.pts;
m_posMax = GetPos();
+ // 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 (int 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));
+ }
+ }
+ }
+ //TRACE ("m_rtMax(SearchStreams)=%S\n", ReftimeToString(m_rtMax));
}
}
- }
- else
+ } else {
b = 0;
+ }
AddStream(h.pid, b, DWORD(h.bytes - (GetPos() - pos)));
}
Seek(h.next);
- }
- else if(m_type == pva)
- {
+ } else if(m_type == pva) {
pvahdr h;
- if(!Read(h)) continue;
+ if(!Read(h)) {
+ continue;
+ }
- if(h.fpts)
- {
- if(m_rtMin == _I64_MAX)
- {
+ if(h.fpts) {
+ if(m_rtMin == _I64_MAX) {
m_rtMin = h.pts;
m_posMin = GetPos();
}
- if(m_rtMin < h.pts && m_rtMax < h.pts)
- {
+ if(m_rtMin < h.pts && m_rtMax < h.pts) {
m_rtMax = h.pts;
m_posMax = GetPos();
}
@@ -381,13 +409,15 @@ HRESULT CMpegSplitterFile::SearchStreams(__int64 start, __int64 stop)
__int64 pos = GetPos();
- if(h.streamid == 1)
+ if(h.streamid == 1) {
AddStream(h.streamid, 0xe0, h.length);
- else if(h.streamid == 2)
+ } else if(h.streamid == 2) {
AddStream(h.streamid, 0xc0, h.length);
+ }
- if(h.length)
+ if(h.length) {
Seek(pos + h.length);
+ }
}
}
@@ -396,10 +426,12 @@ HRESULT CMpegSplitterFile::SearchStreams(__int64 start, __int64 stop)
DWORD CMpegSplitterFile::AddStream(WORD pid, BYTE pesid, DWORD len)
{
- if(pid)
- {
- if(pesid) m_pid2pes[pid] = pesid;
- else m_pid2pes.Lookup(pid, pesid);
+ if(pid) {
+ if(pesid) {
+ m_pid2pes[pid] = pesid;
+ } else {
+ m_pid2pes.Lookup(pid, pesid);
+ }
}
stream s;
@@ -408,113 +440,102 @@ DWORD CMpegSplitterFile::AddStream(WORD pid, BYTE pesid, DWORD len)
int type = unknown;
- if(pesid >= 0xe0 && pesid < 0xf0) // mpeg video
- {
+ if(pesid >= 0xe0 && pesid < 0xf0) { // mpeg video
__int64 pos = GetPos();
- if(type == unknown)
- {
+ if(type == unknown) {
CMpegSplitterFile::seqhdr h;
- if(!m_streams[video].Find(s) && Read(h, len, &s.mt))
+ if(!m_streams[video].Find(s) && Read(h, len, &s.mt)) {
type = video;
+ }
}
Seek(pos);
- if(type == unknown)
- {
-// CMpegSplitterFile::avchdr h; <= PPS and SPS can be present on differents packets !
- if(!m_streams[video].Find(s) && Read(avch, len, &s.mt))
+ if(type == unknown) {
+ // CMpegSplitterFile::avchdr h; <= PPS and SPS can be present on differents packets !
+ if(!m_streams[video].Find(s) && Read(avch, len, &s.mt)) {
type = video;
+ }
}
- }
- else if(pesid >= 0xc0 && pesid < 0xe0) // mpeg audio
- {
+ } else if(pesid >= 0xc0 && pesid < 0xe0) { // mpeg audio
__int64 pos = GetPos();
- if(type == unknown)
- {
+ if(type == unknown) {
CMpegSplitterFile::mpahdr h;
- if(!m_streams[audio].Find(s) && Read(h, len, false, &s.mt))
+ if(!m_streams[audio].Find(s) && Read(h, len, false, &s.mt)) {
type = audio;
+ }
}
Seek(pos);
- if(type == unknown)
- {
+ if(type == unknown) {
CMpegSplitterFile::aachdr h;
- if(!m_streams[audio].Find(s) && Read(h, len, &s.mt))
+ if(!m_streams[audio].Find(s) && Read(h, len, &s.mt)) {
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))
- {
+ } else if(pesid == 0xbd || pesid == 0xfd) { // private stream 1
+ if(s.pid) {
+ if(!m_streams[audio].Find(s) && !m_streams[video].Find(s)) {
__int64 pos = GetPos();
// AC3
- if(type == unknown)
- {
+ if(type == unknown) {
CMpegSplitterFile::ac3hdr h;
- if(Read(h, len, &s.mt))
+ if(Read(h, len, &s.mt)) {
type = audio;
+ }
}
// DTS
Seek(pos);
- if(type == unknown)
- {
+ if(type == unknown) {
CMpegSplitterFile::dtshdr h;
- if(Read(h, len, &s.mt))
+ if(Read(h, len, &s.mt)) {
type = audio;
+ }
}
// VC1
- Seek(pos);
- if(type == unknown)
- {
+ Seek(pos);
+ if(type == unknown) {
CMpegSplitterFile::vc1hdr h;
- if(!m_streams[video].Find(s) && Read(h, len, &s.mt))
+ if(!m_streams[video].Find(s) && Read(h, len, &s.mt)) {
type = video;
+ }
}
// DVB subtitles
- Seek(pos);
- if(type == unknown)
- {
+ Seek(pos);
+ if(type == unknown) {
CMpegSplitterFile::dvbsub h;
- if(!m_streams[video].Find(s) && Read(h, len, &s.mt))
+ 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))
- {
+ if((type == unknown) && (pProgram != NULL)) {
PES_STREAM_TYPE StreamType = INVALID;
-
+
Seek(pos);
StreamType = pProgram->streams[iProgram].type;
- switch (StreamType)
- {
- case AUDIO_STREAM_LPCM :
- {
+ switch (StreamType) {
+ case AUDIO_STREAM_LPCM : {
CMpegSplitterFile::hdmvlpcmhdr h;
- if(!m_streams[audio].Find(s) && Read(h, &s.mt))
+ if(!m_streams[audio].Find(s) && Read(h, &s.mt)) {
type = audio;
+ }
}
break;
- case PRESENTATION_GRAPHICS_STREAM :
- {
+ case PRESENTATION_GRAPHICS_STREAM : {
CMpegSplitterFile::hdmvsubhdr h;
- if(!m_streams[subpic].Find(s) && Read(h, &s.mt, pClipInfo ? pClipInfo->m_LanguageCode : NULL))
- {
+ if(!m_streams[subpic].Find(s) && Read(h, &s.mt, pClipInfo ? pClipInfo->m_LanguageCode : NULL)) {
m_bIsHdmv = true;
type = subpic;
}
@@ -525,129 +546,110 @@ DWORD CMpegSplitterFile::AddStream(WORD pid, BYTE pesid, DWORD len)
}
}
#if (EVO_SUPPORT != 0)
- else if (pesid == 0xfd) // TODO EVO SUPPORT
- {
+ else if (pesid == 0xfd) { // TODO EVO SUPPORT
CMpegSplitterFile::vc1hdr h;
- if(!m_streams[video].Find(s) && Read(h, len, &s.mt))
+ if(!m_streams[video].Find(s) && Read(h, len, &s.mt)) {
type = video;
+ }
}
#endif
- else
- {
+ 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
- {
+ 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))
+ if(!m_streams[audio].Find(s) && Read(h, len, &s.mt)) {
type = audio;
- }
- else if(b >= 0x88 && b < 0x90 || dw == 0x7ffe8001) // dts
- {
+ }
+ } 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))
+ if(!m_streams[audio].Find(s) && Read(h, len, &s.mt)) {
type = audio;
- }
- else if(b >= 0xa0 && b < 0xa8) // lpcm
- {
+ }
+ } else if(b >= 0xa0 && b < 0xa8) { // lpcm
s.ps1id = (b >= 0xa0 && b < 0xa8) ? (BYTE)(BitRead(32) >> 24) : 0xa0;
-
+
CMpegSplitterFile::lpcmhdr h;
- if(Read(h, &s.mt) && !m_streams[audio].Find(s)) // note the reversed order, the header should be stripped always even if it's not a new stream
+ if(Read(h, &s.mt) && !m_streams[audio].Find(s)) { // note the reversed order, the header should be stripped always even if it's not a new stream
type = audio;
- }
- else if(b >= 0x20 && b < 0x40) // DVD subpic
- {
+ }
+ } 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))
+ if(!m_streams[subpic].Find(s) && Read(h, &s.mt)) {
type = subpic;
- }
- else if(b >= 0x70 && b < 0x80) // SVCD 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))
+ if(!m_streams[subpic].Find(s) && Read(h, &s.mt)) {
type = subpic;
- }
- else if(b >= 0x00 && b < 0x10) // CVD 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))
+ if(!m_streams[subpic].Find(s) && Read(h, &s.mt)) {
type = subpic;
- }
- else if(w == 0xffa0 || w == 0xffa1) // ps2-mpg audio
- {
+ }
+ } 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))
+ if(!m_streams[audio].Find(s) && Read(h, &s.mt)) {
type = audio;
- }
- else if(w == 0xff90) // ps2-mpg ac3 or subtitles
- {
+ }
+ } 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)
- {
+ if(w == 0x0b77) {
CMpegSplitterFile::ac3hdr h;
- if(!m_streams[audio].Find(s) && Read(h, len, &s.mt))
+ if(!m_streams[audio].Find(s) && Read(h, len, &s.mt)) {
type = audio;
- }
- else if(w == 0x0000) // usually zero...
- {
+ }
+ } else if(w == 0x0000) { // usually zero...
CMpegSplitterFile::ps2subhdr h;
- if(!m_streams[subpic].Find(s) && Read(h, &s.mt))
+ if(!m_streams[subpic].Find(s) && Read(h, &s.mt)) {
type = subpic;
+ }
}
}
#if (EVO_SUPPORT != 0)
- else if(b >= 0xc0 && b < 0xc8) // dolby digital +
- {
+ else if(b >= 0xc0 && b < 0xc8) { // dolby digital +
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)
- {
+ if(w == 0x0b77) {
CMpegSplitterFile::ac3hdr h;
- if(!m_streams[audio].Find(s) && Read(h, len, &s.mt))
+ if(!m_streams[audio].Find(s) && Read(h, len, &s.mt)) {
type = audio;
+ }
}
}
#endif
}
- }
- else if(pesid == 0xbe) // padding
- {
- }
- else if(pesid == 0xbf) // private stream 2
- {
+ } 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))
- {
+ if(type != unknown && !m_streams[type].Find(s)) {
+ if(s.pid) {
+ for(int i = 0; i < unknown; i++) {
+ if(m_streams[i].Find(s)) {
/*ASSERT(0);*/
return s;
}
@@ -669,8 +671,7 @@ void CMpegSplitterFile::AddHdmvPGStream(WORD pid, const char* language_code)
s.pesid = 0xbd;
CMpegSplitterFile::hdmvsubhdr h;
- if(!m_streams[subpic].Find(s) && Read(h, &s.mt, language_code))
- {
+ if(!m_streams[subpic].Find(s) && Read(h, &s.mt, language_code)) {
m_streams[subpic].Insert(s, this);
}
}
@@ -690,46 +691,37 @@ void CMpegSplitterFile::UpdatePrograms(const trhdr& h)
{
CAutoLock cAutoLock(&m_csProps);
- if(h.pid == 0)
- {
+ if(h.pid == 0) {
trsechdr h2;
- if(Read(h2) && h2.table_id == 0)
- {
+ 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--)
- {
+ for(int i = len/4; i > 0; i--) {
WORD program_number = (WORD)BitRead(16);
BYTE reserved = (BYTE)BitRead(3);
WORD pid = (WORD)BitRead(13);
UNUSED_ALWAYS(reserved);
- if(program_number != 0)
- {
+ if(program_number != 0) {
m_programs[pid].program_number = program_number;
newprograms[program_number] = true;
}
}
POSITION pos = m_programs.GetStartPosition();
- while(pos)
- {
+ while(pos) {
const CAtlMap<WORD, program>::CPair* pPair = m_programs.GetNext(pos);
- if(!newprograms.Lookup(pPair->m_value.program_number))
- {
+ 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))
- {
+ } else if(CAtlMap<WORD, program>::CPair* pPair = m_programs.Lookup(h.pid)) {
trsechdr h2;
- if(Read(h2) && h2.table_id == 2)
- {
+ if(Read(h2) && h2.table_id == 2) {
memset(pPair->m_value.streams, 0, sizeof(pPair->m_value.streams));
int len = h2.section_length;
@@ -745,11 +737,11 @@ void CMpegSplitterFile::UpdatePrograms(const trhdr& h)
len -= 4+program_info_length;
- while(program_info_length-- > 0)
+ while(program_info_length-- > 0) {
BitRead(8);
+ }
- for(int i = 0; i < countof(pPair->m_value.streams) && len >= 5; i++)
- {
+ for(int i = 0; i < countof(pPair->m_value.streams) && len >= 5; i++) {
BYTE stream_type = (BYTE)BitRead(8);
BYTE nreserved1 = (BYTE)BitRead(3);
WORD pid = (WORD)BitRead(13);
@@ -760,8 +752,9 @@ void CMpegSplitterFile::UpdatePrograms(const trhdr& h)
len -= 5+ES_info_length;
- while(ES_info_length-- > 0)
+ while(ES_info_length-- > 0) {
BitRead(8);
+ }
pPair->m_value.streams[i].pid = pid;
pPair->m_value.streams[i].type = (PES_STREAM_TYPE)stream_type;
@@ -789,14 +782,11 @@ const CMpegSplitterFile::program* CMpegSplitterFile::FindProgram(WORD pid, int &
POSITION pos = m_programs.GetStartPosition();
- while(pos)
- {
+ while(pos) {
program* p = &m_programs.GetNextValue(pos);
- for(int i = 0; i < countof(p->streams); i++)
- {
- if(p->streams[i].pid == pid)
- {
+ for(int i = 0; i < countof(p->streams); i++) {
+ if(p->streams[i].pid == pid) {
iStream = i;
return p;
}
diff --git a/src/filters/parser/MpegSplitter/MpegSplitterFile.h b/src/filters/parser/MpegSplitter/MpegSplitterFile.h
index 1e52ea697..62c2caf05 100644
--- a/src/filters/parser/MpegSplitter/MpegSplitterFile.h
+++ b/src/filters/parser/MpegSplitter/MpegSplitterFile.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -35,9 +35,9 @@ class CMpegSplitterFile : public CBaseSplitterFileEx
bool m_bIsHdmv;
- HRESULT Init();
+ HRESULT Init(IAsyncReader* pAsyncReader);
- void OnComplete();
+ void OnComplete(IAsyncReader* pAsyncReader);
public:
CHdmvClipInfo &m_ClipInfo;
@@ -53,16 +53,21 @@ public:
__int64 m_posMin, m_posMax;
int m_rate; // byte/sec
- struct stream
- {
+ 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;}
+ 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, unknown};
@@ -70,33 +75,33 @@ public:
class CStreamList : public CAtlList<stream>
{
public:
- void Insert(stream& s, CMpegSplitterFile *_pFile)
- {
+ void Insert(stream& s, CMpegSplitterFile *_pFile) {
s.m_pFile = _pFile;
- for(POSITION pos = GetHeadPosition(); pos; GetNext(pos))
- {
+ for(POSITION pos = GetHeadPosition(); pos; GetNext(pos)) {
stream& s2 = GetAt(pos);
- if(s < s2) {InsertBefore(pos, s); return;}
+ if(s < s2) {
+ InsertBefore(pos, s);
+ return;
+ }
}
AddTail(s);
}
- static CStringW ToString(int type)
- {
- return
- type == video ? L"Video" :
- type == audio ? L"Audio" :
- type == subpic ? L"Subtitle" :
+ static CStringW ToString(int type) {
+ return
+ type == video ? L"Video" :
+ type == audio ? L"Audio" :
+ type == subpic ? L"Subtitle" :
L"Unknown";
}
- const stream* FindStream(int pid)
- {
- for(POSITION pos = GetHeadPosition(); pos; GetNext(pos))
- {
+ const stream* FindStream(int pid) {
+ for(POSITION pos = GetHeadPosition(); pos; GetNext(pos)) {
const stream& s = GetAt(pos);
- if(s.pid == pid) return &s;
+ if(s.pid == pid) {
+ return &s;
+ }
}
return NULL;
@@ -104,23 +109,25 @@ public:
} m_streams[unknown];
- HRESULT SearchStreams(__int64 start, __int64 stop);
+ HRESULT SearchStreams(__int64 start, __int64 stop, IAsyncReader* pAsyncReader);
DWORD AddStream(WORD pid, BYTE pesid, DWORD len);
void AddHdmvPGStream(WORD pid, const char* language_code);
CAtlList<stream>* GetMasterStream();
- bool IsHdmv() { return m_bIsHdmv; };
+ bool IsHdmv() {
+ return m_bIsHdmv;
+ };
- struct program
- {
+ struct program {
WORD program_number;
- struct stream
- {
+ struct stream {
WORD pid;
PES_STREAM_TYPE type;
};
stream streams[64];
- struct program() {memset(this, 0, sizeof(*this));}
+ struct program() {
+ memset(this, 0, sizeof(*this));
+ }
};
CAtlMap<WORD, program> m_programs;
@@ -128,5 +135,5 @@ public:
void UpdatePrograms(const trhdr& h);
const program* FindProgram(WORD pid, int &iStream, const CHdmvClipInfo::Stream * &_pClipInfo);
-
+
};
diff --git a/src/filters/parser/MpegSplitter/stdafx.cpp b/src/filters/parser/MpegSplitter/stdafx.cpp
index 13934d005..bea3f980a 100644
--- a/src/filters/parser/MpegSplitter/stdafx.cpp
+++ b/src/filters/parser/MpegSplitter/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/parser/MpegSplitter/stdafx.h b/src/filters/parser/MpegSplitter/stdafx.h
index a72e6f179..5560c6425 100644
--- a/src/filters/parser/MpegSplitter/stdafx.h
+++ b/src/filters/parser/MpegSplitter/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/parser/NutSplitter/NutFile.cpp b/src/filters/parser/NutSplitter/NutFile.cpp
index dc72f1de8..9a5eae7ed 100644
--- a/src/filters/parser/NutSplitter/NutFile.cpp
+++ b/src/filters/parser/NutSplitter/NutFile.cpp
@@ -4,7 +4,9 @@
CNutFile::CNutFile(IAsyncReader* pAsyncReader, HRESULT& hr)
: CBaseSplitterFile(pAsyncReader, hr)
{
- if(FAILED(hr)) return;
+ if(FAILED(hr)) {
+ return;
+ }
hr = Init();
}
@@ -12,58 +14,52 @@ HRESULT CNutFile::Init()
{
Seek(0);
- if(BitRead(64) != NUTM)
+ if(BitRead(64) != NUTM) {
return E_FAIL;
+ }
m_streams.RemoveAll();
Seek(0);
- while(GetRemaining())
- {
+ while(GetRemaining()) {
frame_header fh;
fh.checksum_flag = 1;
UINT64 id = 0;
if(BitRead(1, true) == 0
- || (id = BitRead(64)) == NUTK)
+ || (id = BitRead(64)) == NUTK) {
break;
+ }
packet_header ph;
Read(ph);
- if(id == NUTM)
- {
+ if(id == NUTM) {
Read(m_mh);
- }
- else if(id == NUTS)
- {
+ } else if(id == NUTS) {
CAutoPtr<stream_header> sh(DNew stream_header());
Read(*sh);
- if(sh->stream_class == SC_VIDEO) Read(sh->vsh);
- else if(sh->stream_class == SC_AUDIO) Read(sh->ash);
+ if(sh->stream_class == SC_VIDEO) {
+ Read(sh->vsh);
+ } else if(sh->stream_class == SC_AUDIO) {
+ Read(sh->ash);
+ }
// else if(sh->stream_class == SC_SUBTITLE) ; // nothing to do
m_streams.AddTail(sh);
- }
- else if(id == NUTX)
- {
+ } else if(id == NUTX) {
index_header ih;
Read(ih);
- }
- else if(id == NUTI)
- {
+ } else if(id == NUTI) {
info_header ih;
Read(ih);
- }
- else if(id == 0) // frame
- {
+ } else if(id == 0) { // frame
ASSERT(0);
break;
}
- if(fh.checksum_flag)
- {
+ if(fh.checksum_flag) {
Seek(ph.pos + ph.fptr - 4);
ph.checksum = (UINT32)BitRead(32);
}
@@ -80,8 +76,10 @@ void CNutFile::Read(vint& vi)
{
vi = 0;
bool more;
- do {more = !!BitRead(1); vi = (vi << 7) | BitRead(7);}
- while(more);
+ do {
+ more = !!BitRead(1);
+ vi = (vi << 7) | BitRead(7);
+ } while(more);
}
void CNutFile::Read(svint& svi)
@@ -89,8 +87,11 @@ void CNutFile::Read(svint& svi)
vint vi;
Read(vi);
vi++;
- if(vi&1) svi = -((svint)vi>>1);
- else svi = ((svint)vi>>1);
+ if(vi&1) {
+ svi = -((svint)vi>>1);
+ } else {
+ svi = ((svint)vi>>1);
+ }
}
void CNutFile::Read(binary& b)
@@ -98,7 +99,9 @@ void CNutFile::Read(binary& b)
vint len;
Read(len);
b.SetCount((INT_PTR)len);
- for(BYTE* buff = b.GetData(); len-- > 0; *buff++ = (BYTE)BitRead(8));
+ for(BYTE* buff = b.GetData(); len-- > 0; *buff++ = (BYTE)BitRead(8)) {
+ ;
+ }
}
void CNutFile::Read(packet_header& ph)
@@ -118,21 +121,22 @@ void CNutFile::Read(stream_header& sh)
{
Read(sh.stream_id);
Read(sh.stream_class);
- Read(sh.fourcc);
- Read(sh.average_bitrate);
- Read(sh.language_code);
- Read(sh.time_base_nom);
- Read(sh.time_base_denom);
- Read(sh.msb_timestamp_shift);
- Read(sh.shuffle_type);
- sh.fixed_fps = BitRead(1);
- sh.index_flag = BitRead(1);
- sh.reserved = BitRead(6);
- while(1)
- {
+ Read(sh.fourcc);
+ Read(sh.average_bitrate);
+ Read(sh.language_code);
+ Read(sh.time_base_nom);
+ Read(sh.time_base_denom);
+ Read(sh.msb_timestamp_shift);
+ Read(sh.shuffle_type);
+ sh.fixed_fps = BitRead(1);
+ sh.index_flag = BitRead(1);
+ sh.reserved = BitRead(6);
+ while(1) {
CAutoPtr<codec_specific> p(DNew codec_specific());
Read(p->type);
- if(p->type == 0) break;
+ if(p->type == 0) {
+ break;
+ }
Read(p->data);
sh.cs.AddTail(p);
}
@@ -160,8 +164,7 @@ void CNutFile::Read(index_header& ih)
vint len;
Read(len);
ih.ie.SetCount((INT_PTR)len);
- for(index_entry* p = ih.ie.GetData(); len-- > 0;)
- {
+ for(index_entry* p = ih.ie.GetData(); len-- > 0;) {
Read(p->timestamp);
Read(p->position);
}
@@ -170,22 +173,22 @@ void CNutFile::Read(index_header& ih)
void CNutFile::Read(info_header& ih)
{
// TODO
-/*
- for(;;){
- id v
- if(id==0) break
- name= info_table[id][0]
- type= info_table[id][1]
- if(type==NULL)
- type b
- if(name==NULL)
- name b
- if(type=="v")
- value v
- else if(type=="s")
- value s
- else
- value b
- }
-*/
+ /*
+ for(;;){
+ id v
+ if(id==0) break
+ name= info_table[id][0]
+ type= info_table[id][1]
+ if(type==NULL)
+ type b
+ if(name==NULL)
+ name b
+ if(type=="v")
+ value v
+ else if(type=="s")
+ value s
+ else
+ value b
+ }
+ */
}
diff --git a/src/filters/parser/NutSplitter/NutFile.h b/src/filters/parser/NutSplitter/NutFile.h
index ab2a0a7e1..2221daa0d 100644
--- a/src/filters/parser/NutSplitter/NutFile.h
+++ b/src/filters/parser/NutSplitter/NutFile.h
@@ -15,40 +15,34 @@ public:
typedef CAtlArray<BYTE> binary;
typedef CAtlArray<BYTE> string;
- struct packet_header
- {
+ struct packet_header {
__int64 pos;
vint fptr, bptr;
UINT32 checksum;
};
- struct main_header
- {
+ struct main_header {
vint version;
vint stream_count;
};
- struct codec_specific
- {
+ struct codec_specific {
vint type;
binary data;
};
- struct video_stream_header
- {
+ struct video_stream_header {
vint width, height;
vint sample_width, sample_height;
vint colorspace_type;
};
- struct audio_stream_header
- {
+ struct audio_stream_header {
vint samplerate_mul;
vint channel_count;
};
- struct stream_header
- {
+ struct stream_header {
vint stream_id;
vint stream_class;
string fourcc;
@@ -62,12 +56,14 @@ public:
int index_flag:1;
int reserved:6;
CAutoPtrList<codec_specific> cs;
- union {video_stream_header vsh; audio_stream_header ash;};
+ union {
+ video_stream_header vsh;
+ audio_stream_header ash;
+ };
vint msb_timestamp;
};
- struct frame_header
- {
+ struct frame_header {
BYTE zero_bit:1;
BYTE priority:2;
BYTE checksum_flag:1;
@@ -76,31 +72,28 @@ public:
BYTE reserved:1;
};
- struct index_entry
- {
+ struct index_entry {
vint timestamp;
vint position;
};
- struct index_header
- {
- vint stream_id;
+ struct index_header {
+ vint stream_id;
CAtlArray<index_entry> ie;
};
- struct info_header
- {
+ struct info_header {
// TODO
vint dummy;
};
#pragma pack(pop)
- #define NUTM 0xF9526A624E55544Dui64
- #define NUTS 0xD667773F4E555453ui64
- #define NUTK 0xCB8630874E55544Bui64
- #define NUTX 0xEBFCDE0E4E555458ui64
- #define NUTI 0xA37B64354E555449ui64
+#define NUTM 0xF9526A624E55544Dui64
+#define NUTS 0xD667773F4E555453ui64
+#define NUTK 0xCB8630874E55544Bui64
+#define NUTX 0xEBFCDE0E4E555458ui64
+#define NUTI 0xA37B64354E555449ui64
enum {SC_VIDEO = 0, SC_AUDIO = 32, SC_SUBTITLE = 64};
diff --git a/src/filters/parser/NutSplitter/NutSplitter.cpp b/src/filters/parser/NutSplitter/NutSplitter.cpp
index 3edb5a328..5e86c76d2 100644
--- a/src/filters/parser/NutSplitter/NutSplitter.cpp
+++ b/src/filters/parser/NutSplitter/NutSplitter.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -26,26 +26,22 @@
#ifdef REGISTER_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
{&MEDIATYPE_Stream, &MEDIASUBTYPE_Nut},
{&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}
+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}
};
-const AMOVIESETUP_FILTER sudFilter[] =
-{
+const AMOVIESETUP_FILTER sudFilter[] = {
{&__uuidof(CNutSplitterFilter), L"MPC - Nut Splitter", MERIT_NORMAL+1, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
{&__uuidof(CNutSourceFilter), L"MPC - Nut Source", MERIT_NORMAL+1, 0, NULL, CLSID_LegacyAmFilterCategory},
};
-CFactoryTemplate g_Templates[] =
-{
+CFactoryTemplate g_Templates[] = {
{sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CNutSplitterFilter>, NULL, &sudFilter[0]},
{sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CNutSourceFilter>, NULL, &sudFilter[1]},
};
@@ -90,8 +86,13 @@ HRESULT CNutSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
m_pFile.Free();
m_pFile.Attach(DNew CNutFile(pAsyncReader, hr));
- if(!m_pFile) return E_OUTOFMEMORY;
- if(FAILED(hr)) {m_pFile.Free(); return 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;
@@ -99,15 +100,13 @@ HRESULT CNutSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
// pins
POSITION pos = m_pFile->m_streams.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CNutFile::stream_header* sh = m_pFile->m_streams.GetNext(pos);
CAtlArray<CMediaType> mts;
CMediaType mt;
- if(sh->stream_class == CNutFile::SC_VIDEO)
- {
+ if(sh->stream_class == CNutFile::SC_VIDEO) {
CNutFile::video_stream_header& vsh = sh->vsh;
mt.majortype = MEDIATYPE_Video;
@@ -126,8 +125,7 @@ HRESULT CNutSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
mts.Add(mt);
- if(vsh.sample_width && vsh.sample_height)
- {
+ if(vsh.sample_width && vsh.sample_height) {
VIDEOINFOHEADER2 vih2;
memset(&vih2, 0, sizeof(vih2));
vih2.dwBitRate = vih.dwBitRate;
@@ -139,20 +137,15 @@ HRESULT CNutSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
mts.InsertAt(0, mt);
}
- }
- else if(sh->stream_class == CNutFile::SC_AUDIO)
- {
+ } else if(sh->stream_class == CNutFile::SC_AUDIO) {
CNutFile::audio_stream_header& ash = sh->ash;
UNUSED_ALWAYS(ash);
// TODO
- }
- else if(sh->stream_class == CNutFile::SC_SUBTITLE)
- {
+ } else if(sh->stream_class == CNutFile::SC_SUBTITLE) {
// TODO
}
- if(mts.GetCount() > 0)
- {
+ if(mts.GetCount() > 0) {
CAutoPtr<CBaseSplitterOutputPin> pPinOut(DNew CBaseSplitterOutputPin(mts, L"Video", this, this, &hr));
AddOutputPin((DWORD)sh->stream_id, pPinOut);
}
@@ -167,7 +160,9 @@ HRESULT CNutSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
bool CNutSplitterFilter::DemuxInit()
{
SetThreadName((DWORD)-1, "CNutSplitterFilter");
- if(!m_pFile) return(false);
+ if(!m_pFile) {
+ return(false);
+ }
m_pFile->Seek(0);
return(true);
}
@@ -175,14 +170,13 @@ bool CNutSplitterFilter::DemuxInit()
void CNutSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
{
POSITION pos = m_pFile->m_streams.GetHeadPosition();
- while(pos) m_pFile->m_streams.GetNext(pos)->msb_timestamp = 0;
+ while(pos) {
+ m_pFile->m_streams.GetNext(pos)->msb_timestamp = 0;
+ }
- if(rt <= 0)
- {
+ if(rt <= 0) {
m_pFile->Seek(0);
- }
- else
- {
+ } else {
m_pFile->Seek(0);
// TODO
}
@@ -192,26 +186,21 @@ bool CNutSplitterFilter::DemuxLoop()
{
bool fKeyFrame = false;
- while(!CheckRequest(NULL) && m_pFile->GetRemaining())
- {
+ while(!CheckRequest(NULL) && m_pFile->GetRemaining()) {
CNutFile::frame_header fh;
fh.checksum_flag = 1;
UINT64 id = 0;
- if(m_pFile->BitRead(1, true) == 0)
- {
+ if(m_pFile->BitRead(1, true) == 0) {
fh.zero_bit = m_pFile->BitRead(1);
fh.priority = m_pFile->BitRead(2);
- fh.checksum_flag = m_pFile->BitRead(1);
+ fh.checksum_flag = m_pFile->BitRead(1);
fh.msb_timestamp_flag = m_pFile->BitRead(1);
fh.subpacket_type = m_pFile->BitRead(2);
fh.reserved = m_pFile->BitRead(1);
- }
- else
- {
- if((id = m_pFile->BitRead(64)) == NUTK)
- {
+ } else {
+ if((id = m_pFile->BitRead(64)) == NUTK) {
fKeyFrame = true;
continue;
}
@@ -220,95 +209,95 @@ bool CNutSplitterFilter::DemuxLoop()
CNutFile::packet_header ph;
m_pFile->Read(ph);
- if(id == 0)
- {
+ if(id == 0) {
CNutFile::vint stream_id;
m_pFile->Read(stream_id);
CNutFile::stream_header* sh = NULL;
POSITION pos = m_pFile->m_streams.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CNutFile::stream_header* tmp = m_pFile->m_streams.GetNext(pos);
- if(tmp->stream_id == stream_id) {sh = tmp; break;}
+ if(tmp->stream_id == stream_id) {
+ sh = tmp;
+ break;
+ }
}
- if(sh)
- {
- if(fh.msb_timestamp_flag)
+ if(sh) {
+ if(fh.msb_timestamp_flag) {
m_pFile->Read(sh->msb_timestamp);
+ }
CNutFile::svint lsb_timestamp = 0;
m_pFile->Read(lsb_timestamp);
-TRACE(_T("[%I64d]: %I64d:%I64d\n"), stream_id, sh->msb_timestamp, lsb_timestamp);
+ TRACE(_T("[%I64d]: %I64d:%I64d\n"), stream_id, sh->msb_timestamp, lsb_timestamp);
CAutoPtr<Packet> p(DNew Packet());
p->TrackNumber = (DWORD)stream_id;
p->bSyncPoint = fKeyFrame;
- p->rtStart = 10000i64 * ((sh->msb_timestamp << sh->msb_timestamp_shift) + lsb_timestamp)
- * sh->time_base_nom / sh->time_base_denom;
+ p->rtStart = 10000i64 * ((sh->msb_timestamp << sh->msb_timestamp_shift) + lsb_timestamp)
+ * sh->time_base_nom / sh->time_base_denom;
p->rtStop = p->rtStart+1;
fKeyFrame = false;
CNutFile::vint len = ph.fptr - (m_pFile->GetPos() - ph.pos);
- if(fh.checksum_flag) len -= 4;
+ if(fh.checksum_flag) {
+ len -= 4;
+ }
- if(fh.subpacket_type == 1)
- {
+ if(fh.subpacket_type == 1) {
p->SetCount(len);
m_pFile->ByteRead(p->GetData(), p->GetCount());
- if(FAILED(DeliverPacket(p)))
+ if(FAILED(DeliverPacket(p))) {
break;
- }
- else
- {
- // TODO
-/*
- vint subpacket_count;
- Read(subpacket_count);
-
- if(fh.subpacket_type & 1)
- {
- CArray<vint> keyframe_run;
- keyframe_run.SetSize(subpacket_count);
- for(int i = 0; i < subpacket_count; i++)
- Read(keyframe_run[i]);
}
-
- CArray<vint> timestamp_diff;
- timestamp_diff.SetSize(subpacket_count);
- CArray<vint> timestamp_diff_run;
- timestamp_diff_run.SetSize(subpacket_count);
- for(int i = 0; i < subpacket_count; i++)
- {
- Read(timestamp_diff[i]);
- if(timestamp_diff[i] & 1)
- Read(timestamp_diff_run[i]);
- }
-
- if(fh.subpacket_type & 2)
- {
- CArray<string> subpacket_size_diff;
- for(int i = 0; i < subpacket_count-1; i++)
- {
- Read(subpacket_size_diff[i]);
- }
- }
-
- for(int i = 0; i < subpacket_count; i++)
- {
- }
-*/
+ } else {
+ // TODO
+ /*
+ vint subpacket_count;
+ Read(subpacket_count);
+
+ if(fh.subpacket_type & 1)
+ {
+ CArray<vint> keyframe_run;
+ keyframe_run.SetSize(subpacket_count);
+ for(int i = 0; i < subpacket_count; i++)
+ Read(keyframe_run[i]);
+ }
+
+ CArray<vint> timestamp_diff;
+ timestamp_diff.SetSize(subpacket_count);
+ CArray<vint> timestamp_diff_run;
+ timestamp_diff_run.SetSize(subpacket_count);
+ for(int i = 0; i < subpacket_count; i++)
+ {
+ Read(timestamp_diff[i]);
+ if(timestamp_diff[i] & 1)
+ Read(timestamp_diff_run[i]);
+ }
+
+ if(fh.subpacket_type & 2)
+ {
+ CArray<string> subpacket_size_diff;
+ for(int i = 0; i < subpacket_count-1; i++)
+ {
+ Read(subpacket_size_diff[i]);
+ }
+ }
+
+ for(int i = 0; i < subpacket_count; i++)
+ {
+ }
+ */
}
}
}
- if(fh.checksum_flag)
- {
+ if(fh.checksum_flag) {
m_pFile->Seek(ph.pos + ph.fptr - 4);
ph.checksum = (UINT32)m_pFile->BitRead(32);
}
diff --git a/src/filters/parser/NutSplitter/NutSplitter.h b/src/filters/parser/NutSplitter/NutSplitter.h
index 5d447d3d8..82e820905 100644
--- a/src/filters/parser/NutSplitter/NutSplitter.h
+++ b/src/filters/parser/NutSplitter/NutSplitter.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,15 +6,15 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
@@ -25,11 +25,11 @@
#include "NutFile.h"
// {5EB7173E-AA71-4a54-BDD1-1CA57D20405F}
-DEFINE_GUID(MEDIASUBTYPE_Nut,
-0x5eb7173e, 0xaa71, 0x4a54, 0xbd, 0xd1, 0x1c, 0xa5, 0x7d, 0x20, 0x40, 0x5f);
+DEFINE_GUID(MEDIASUBTYPE_Nut,
+ 0x5eb7173e, 0xaa71, 0x4a54, 0xbd, 0xd1, 0x1c, 0xa5, 0x7d, 0x20, 0x40, 0x5f);
class __declspec(uuid("90514D6A-76B7-4405-88A8-B4B1EF6061C6"))
-CNutSplitterFilter : public CBaseSplitterFilter
+ CNutSplitterFilter : public CBaseSplitterFilter
{
CAutoPtr<CNutFile> m_pFile;
@@ -48,7 +48,7 @@ public:
};
class __declspec(uuid("918B5A9F-DFED-4532-83A9-9B16D83ED73F"))
-CNutSourceFilter : public CNutSplitterFilter
+ CNutSourceFilter : public CNutSplitterFilter
{
public:
CNutSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
diff --git a/src/filters/parser/NutSplitter/stdafx.cpp b/src/filters/parser/NutSplitter/stdafx.cpp
index 13934d005..bea3f980a 100644
--- a/src/filters/parser/NutSplitter/stdafx.cpp
+++ b/src/filters/parser/NutSplitter/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/parser/NutSplitter/stdafx.h b/src/filters/parser/NutSplitter/stdafx.h
index dcc6b12a6..8f287fec1 100644
--- a/src/filters/parser/NutSplitter/stdafx.h
+++ b/src/filters/parser/NutSplitter/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/parser/OggSplitter/OggFile.cpp b/src/filters/parser/OggSplitter/OggFile.cpp
index e8a3a6d1f..d90237a22 100644
--- a/src/filters/parser/OggSplitter/OggFile.cpp
+++ b/src/filters/parser/OggSplitter/OggFile.cpp
@@ -4,14 +4,18 @@
COggFile::COggFile(IAsyncReader* pAsyncReader, HRESULT& hr)
: CBaseSplitterFile(pAsyncReader, hr, DEFAULT_CACHE_LENGTH, false)
{
- if(FAILED(hr)) return;
+ if(FAILED(hr)) {
+ return;
+ }
hr = Init();
}
HRESULT COggFile::Init()
{
Seek(0);
- if(!Sync()) return E_FAIL;
+ if(!Sync()) {
+ return E_FAIL;
+ }
return S_OK;
}
@@ -22,12 +26,10 @@ bool COggFile::Sync(HANDLE hBreak)
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')
- {
+ 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);
}
@@ -49,26 +51,30 @@ bool COggFile::Read(OggPage& page, bool fFull, HANDLE hBreak)
page.m_lens.RemoveAll();
page.SetCount(0);
- if(!Read(page.m_hdr, hBreak))
+ 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++)
- {
+ for(BYTE i = 0; i < page.m_hdr.number_page_segments; i++) {
BYTE b;
- if(S_OK != ByteRead(&b, 1)) return(false);
+ if(S_OK != ByteRead(&b, 1)) {
+ return(false);
+ }
packetlen += b;
- if(1/*b < 0xff*/) {page.m_lens.AddTail(packetlen); pagelen += packetlen; packetlen = 0;}
+ if(1/*b < 0xff*/) {
+ page.m_lens.AddTail(packetlen);
+ pagelen += packetlen;
+ packetlen = 0;
+ }
}
- if(fFull)
- {
+ if(fFull) {
page.SetCount(pagelen);
- if(S_OK != ByteRead(page.GetData(), page.GetCount()))
+ if(S_OK != ByteRead(page.GetData(), page.GetCount())) {
return(false);
- }
- else
- {
+ }
+ } else {
Seek(GetPos() + pagelen);
page.m_lens.RemoveAll();
}
diff --git a/src/filters/parser/OggSplitter/OggFile.h b/src/filters/parser/OggSplitter/OggFile.h
index f37f01c0c..204013ddc 100644
--- a/src/filters/parser/OggSplitter/OggFile.h
+++ b/src/filters/parser/OggSplitter/OggFile.h
@@ -4,11 +4,11 @@
#pragma pack(push, 1)
-struct OggPageHeader
-{
+struct OggPageHeader {
DWORD capture_pattern;
BYTE stream_structure_version;
- BYTE header_type_flag; enum {continued=1, first=2, last=4};
+ BYTE header_type_flag;
+ enum {continued=1, first=2, last=4};
__int64 granule_position;
DWORD bitstream_serial_number;
DWORD page_sequence_number;
@@ -16,8 +16,7 @@ struct OggPageHeader
BYTE number_page_segments;
};
-struct OggVorbisIdHeader
-{
+struct OggVorbisIdHeader {
DWORD vorbis_version;
BYTE audio_channels;
DWORD audio_sample_rate;
@@ -29,27 +28,27 @@ struct OggVorbisIdHeader
BYTE framing_flag;
};
-struct OggVideoHeader
-{
+struct OggVideoHeader {
DWORD w, h;
};
-struct OggAudioHeader
-{
+struct OggAudioHeader {
WORD nChannels, nBlockAlign;
DWORD nAvgBytesPerSec;
};
-struct OggStreamHeader
-{
+struct OggStreamHeader {
char streamtype[8], subtype[4];
DWORD size;
__int64 time_unit, samples_per_unit;
DWORD default_len;
- DWORD buffersize;
+ DWORD buffersize;
WORD bps;
WORD alignmentfix1;
- union {OggVideoHeader v; OggAudioHeader a;};
+ union {
+ OggVideoHeader v;
+ OggAudioHeader a;
+ };
DWORD alignmentfix2;
};
#pragma pack(pop)
@@ -59,7 +58,9 @@ class OggPage : public CAtlArray<BYTE>
public:
OggPageHeader m_hdr;
CAtlList<int> m_lens;
- OggPage() {memset(&m_hdr, 0, sizeof(m_hdr));}
+ OggPage() {
+ memset(&m_hdr, 0, sizeof(m_hdr));
+ }
};
class COggFile : public CBaseSplitterFile
diff --git a/src/filters/parser/OggSplitter/OggSplitter.cpp b/src/filters/parser/OggSplitter/OggSplitter.cpp
index fa348c31f..7a341b12b 100644
--- a/src/filters/parser/OggSplitter/OggSplitter.cpp
+++ b/src/filters/parser/OggSplitter/OggSplitter.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -38,25 +38,21 @@
#ifdef REGISTER_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
{&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}
+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}
};
-const AMOVIESETUP_FILTER sudFilter[] =
-{
+const AMOVIESETUP_FILTER sudFilter[] = {
{&__uuidof(COggSplitterFilter), L"MPC - Ogg Splitter", MERIT_NORMAL+1, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
{&__uuidof(COggSourceFilter), L"MPC - Ogg Source", MERIT_NORMAL+1, 0, NULL, CLSID_LegacyAmFilterCategory},
};
-CFactoryTemplate g_Templates[] =
-{
+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]},
};
@@ -66,8 +62,8 @@ int g_cTemplates = countof(g_Templates);
STDAPI DllRegisterServer()
{
RegisterSourceFilter(
- CLSID_AsyncReader,
- MEDIASUBTYPE_Ogg,
+ CLSID_AsyncReader,
+ MEDIASUBTYPE_Ogg,
_T("0,4,,4F676753"), // OggS
_T(".ogg"), _T(".ogm"), NULL);
@@ -96,35 +92,42 @@ class bitstream
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)
- {
+ 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 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)
- {
+ 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
- {
+ 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;
+ 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;
}
- while(cnt > 0) {ret |= (*p++&((1<<min(cnt,8))-1)) << off; off += 8; cnt -= 8;}
return ret;
}
- unsigned int getbits(int cnt)
- {
+ unsigned int getbits(int cnt) {
unsigned int ret = showbits(cnt);
m_pos += cnt;
return ret;
@@ -153,8 +156,13 @@ HRESULT COggSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
m_pFile.Free();
m_pFile.Attach(DNew COggFile(pAsyncReader, hr));
- if(!m_pFile) return E_OUTOFMEMORY;
- if(FAILED(hr)) {m_pFile.Free(); return 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;
@@ -163,12 +171,10 @@ HRESULT COggSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
m_pFile->Seek(0);
OggPage page;
- for(int i = 0, nWaitForMore = 0; m_pFile->Read(page); i++)
- {
+ for(int i = 0, nWaitForMore = 0; m_pFile->Read(page); i++) {
BYTE* p = page.GetData();
- if(!(page.m_hdr.header_type_flag & OggPageHeader::continued))
- {
+ if(!(page.m_hdr.header_type_flag & OggPageHeader::continued)) {
BYTE type = *p++;
CStringW name;
@@ -176,110 +182,90 @@ HRESULT COggSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
HRESULT hr;
- if(type >= 0x80 && type <= 0x82 && !memcmp(p, "theora", 6))
- {
- if(type == 0x80)
- {
+ 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))
- {
+ } else if(type == 1 && (page.m_hdr.header_type_flag & OggPageHeader::first)) {
CAutoPtr<CBaseSplitterOutputPin> pPinOut;
- if(!memcmp(p, "vorbis", 6))
- {
+ 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))
- {
+ } 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))
- {
+ } 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))
- {
+ } 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))
- {
+ } 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)))
- {
+ } 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
- {
+ } 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)
- {
+ } else if (*(long*)(p-1) == 0x43614C66) {
//bFlac = true;
//nWaitForMore++;
- if (m_pFile->Read(page))
- {
+ 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)
- {
+ } else if(!(type&1) && nWaitForMore == 0) {
break;
}
}
- if(COggTheoraOutputPin* p = dynamic_cast<COggTheoraOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number)))
- {
+ if(COggTheoraOutputPin* p = dynamic_cast<COggTheoraOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number))) {
p->UnpackInitPage(page);
- if(p->IsInitialized()) nWaitForMore--;
+ if(p->IsInitialized()) {
+ nWaitForMore--;
+ }
}
- if(COggVorbisOutputPin* p = dynamic_cast<COggVorbisOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number)))
- {
+ if(COggVorbisOutputPin* p = dynamic_cast<COggVorbisOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number))) {
p->UnpackInitPage(page);
- if(p->IsInitialized()) nWaitForMore--;
+ if(p->IsInitialized()) {
+ nWaitForMore--;
+ }
}
}
- if(m_pOutputs.IsEmpty())
+ if(m_pOutputs.IsEmpty()) {
return E_FAIL;
+ }
- if(m_pFile->IsRandomAccess())
- {
+ if(m_pFile->IsRandomAccess()) {
m_pFile->Seek(max(m_pFile->GetLength()-65536, 0));
OggPage page;
- while(m_pFile->Read(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;
+ 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);
}
@@ -298,20 +284,19 @@ HRESULT COggSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
tagmap[L"DESCRIPTION"] = L"DESC";
POSITION pos2 = tagmap.GetStartPosition();
- while(pos2)
- {
+ while(pos2) {
CStringW oggtag, dsmtag;
tagmap.GetNextAssoc(pos2, oggtag, dsmtag);
POSITION pos = m_pOutputs.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
COggSplitterOutputPin* pOggPin = dynamic_cast<COggSplitterOutputPin*>((CBaseOutputPin*)m_pOutputs.GetNext(pos));
- if(!pOggPin) continue;
+ if(!pOggPin) {
+ continue;
+ }
CStringW value = pOggPin->GetComment(oggtag);
- if(!value.IsEmpty())
- {
+ if(!value.IsEmpty()) {
SetProperty(dsmtag, value);
break;
}
@@ -319,23 +304,29 @@ HRESULT COggSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
}
POSITION pos = m_pOutputs.GetHeadPosition();
- while(pos && !ChapGetCount())
- {
+ while(pos && !ChapGetCount()) {
COggSplitterOutputPin* pOggPin = dynamic_cast<COggSplitterOutputPin*>((CBaseOutputPin*)m_pOutputs.GetNext(pos));
- if(!pOggPin) continue;
+ if(!pOggPin) {
+ continue;
+ }
- for(int i = 1; pOggPin; i++)
- {
- CStringW key;
+ for(int i = 1; pOggPin; i++) {
+ CStringW key;
key.Format(L"CHAPTER%02d", i);
CStringW time = pOggPin->GetComment(key);
- if(time.IsEmpty()) break;
+ if(time.IsEmpty()) {
+ break;
+ }
key.Format(L"CHAPTER%02dNAME", i);
CStringW name = pOggPin->GetComment(key);
- if(name.IsEmpty()) name.Format(L"Chapter %d", i);
+ if(name.IsEmpty()) {
+ name.Format(L"Chapter %d", i);
+ }
int h, m, s, ms;
WCHAR c;
- if(7 != swscanf(time, L"%d%c%d%c%d%c%d", &h, &c, &m, &c, &s, &c, &ms)) break;
+ if(7 != swscanf(time, L"%d%c%d%c%d%c%d", &h, &c, &m, &c, &s, &c, &ms)) {
+ break;
+ }
REFERENCE_TIME rt = ((((REFERENCE_TIME)h*60+m)*60+s)*1000+ms)*10000;
ChapAppend(rt, name);
}
@@ -348,19 +339,18 @@ HRESULT COggSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
bool COggSplitterFilter::DemuxInit()
{
SetThreadName((DWORD)-1, "COggSplitterFilter");
- if(!m_pFile) return(false);
+ if(!m_pFile) {
+ return(false);
+ }
return(true);
}
void COggSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
{
- if(rt <= 0 )
- {
+ if(rt <= 0 ) {
m_pFile->Seek(0);
- }
- else if(m_rtDuration > 0)
- {
+ } else if(m_rtDuration > 0) {
// oh, the horror...
__int64 len = m_pFile->GetLength();
@@ -369,19 +359,22 @@ void COggSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
REFERENCE_TIME rtMinDiff = _I64_MAX;
- while(1)
- {
+ while(1) {
__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;
+ 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;}
+ if(!pOggPin) {
+ ASSERT(0);
+ continue;
+ }
rtPos = pOggPin->GetRefTime(page.m_hdr.granule_position);
endpos = m_pFile->GetPos();
@@ -391,12 +384,10 @@ void COggSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
__int64 rtDiff = rtPos - rt;
- if(rtDiff < 0)
- {
+ if(rtDiff < 0) {
rtDiff = -rtDiff;
- if(rtDiff < 1000000 || rtDiff >= rtMinDiff)
- {
+ if(rtDiff < 1000000 || rtDiff >= rtMinDiff) {
m_pFile->Seek(startpos);
break;
}
@@ -406,23 +397,20 @@ void COggSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
__int64 newpos = startpos;
- if(rtPos < rt && rtPos < m_rtDuration)
- {
+ 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)
- {
+ 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)
- {
+ if(newpos >= startpos) {
+ newpos = startpos - 1024;
+ }
+ } else if(rtPos == rt) {
m_pFile->Seek(startpos);
break;
- }
- else
- {
+ } else {
ASSERT(0);
m_pFile->Seek(0);
break;
@@ -436,55 +424,51 @@ void COggSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
m_pFile->Seek(startpos);
POSITION pos = m_pOutputs.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
COggSplitterOutputPin* pPin = dynamic_cast<COggSplitterOutputPin*>(static_cast<CBaseSplitterOutputPin*>(m_pOutputs.GetNext(pos)));
- if(!dynamic_cast<COggVideoOutputPin*>(pPin) && !dynamic_cast<COggTheoraOutputPin*>(pPin))
+ if(!dynamic_cast<COggVideoOutputPin*>(pPin) && !dynamic_cast<COggTheoraOutputPin*>(pPin)) {
continue;
+ }
bool fKeyFrameFound = false, fSkipKeyFrame = true;
__int64 endpos = _I64_MAX;
- while(!(fKeyFrameFound && !fSkipKeyFrame) && startpos > 0)
- {
+ 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)
+ 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)))
+ if(pPin != dynamic_cast<COggSplitterOutputPin*>(GetOutputPin(page.m_hdr.bitstream_serial_number))) {
continue;
+ }
- if(pPin->GetRefTime(page.m_hdr.granule_position) > rt)
+ if(pPin->GetRefTime(page.m_hdr.granule_position) > rt) {
break;
+ }
- if(!fKeyFrameFound)
- {
+ if(!fKeyFrameFound) {
pPin->UnpackPage(page);
CAutoPtr<OggPacket> p;
- while(p = pPin->GetPacket())
- {
- if(p->bSyncPoint)
- {
+ while(p = pPin->GetPacket()) {
+ if(p->bSyncPoint) {
fKeyFrameFound = true;
fSkipKeyFrame = p->fSkip;
}
}
- if(fKeyFrameFound) break;
- }
- else
- {
+ if(fKeyFrameFound) {
+ break;
+ }
+ } else {
pPin->UnpackPage(page);
CAutoPtr<OggPacket> p;
- while(p = pPin->GetPacket())
- {
- if(!p->fSkip)
- {
+ while(p = pPin->GetPacket()) {
+ if(!p->fSkip) {
fSkipKeyFrame = false;
break;
}
@@ -492,7 +476,10 @@ void COggSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
}
}
- if(!(fKeyFrameFound && !fSkipKeyFrame)) {endpos = startpos; startpos = max(startpos - 10*65536, 0);}
+ if(!(fKeyFrameFound && !fSkipKeyFrame)) {
+ endpos = startpos;
+ startpos = max(startpos - 10*65536, 0);
+ }
m_pFile->Seek(startpos);
}
@@ -504,24 +491,25 @@ void COggSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
fKeyFrameFound = false;
OggPage page;
- while(!fKeyFrameFound && m_pFile->Read(page))
- {
- if(page.m_hdr.granule_position == -1) continue;
+ 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)))
+ 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)
+ if(rtPos > rt) {
break;
+ }
pPin->UnpackPage(page);
CAutoPtr<OggPacket> p;
- while(p = pPin->GetPacket())
- {
- if(p->bSyncPoint)
- {
+ while(p = pPin->GetPacket()) {
+ if(p->bSyncPoint) {
fKeyFrameFound = true;
break;
}
@@ -543,17 +531,24 @@ bool COggSplitterFilter::DemuxLoop()
HRESULT hr = S_OK;
OggPage page;
- while(SUCCEEDED(hr) && !CheckRequest(NULL) && m_pFile->Read(page, true, GetRequestHandle()))
- {
+ 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;}
+ 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)
+ while(!CheckRequest(NULL) && SUCCEEDED(hr) && (p = pOggPin->GetPacket())) {
+ if(!p->fSkip) {
hr = DeliverPacket(p);
+ }
}
}
@@ -585,34 +580,27 @@ 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; )
- {
+ for(int n = bs.getbits(32); n-- > 0; ) {
CStringA str;
- for(int len = bs.getbits(32); len-- > 0; )
+ for(int len = bs.getbits(32); len-- > 0; ) {
str += (CHAR)bs.getbits(8);
+ }
CAtlList<CStringA> sl;
Explode(str, sl, '=', 2);
- if(sl.GetCount() == 2)
- {
+ if(sl.GetCount() == 2) {
CAutoPtr<CComment> p(DNew CComment(UTF8To16(sl.GetHead()), UTF8To16(sl.GetTail())));
- if(p->m_key == L"LANGUAGE")
- {
+ 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())
- {
+ if(p->m_value.GetLength() == 3 && !lang.IsEmpty()) {
SetName(CStringW(lang));
SetProperty(L"LANG", p->m_value);
- }
- else if(!iso6392.IsEmpty())
- {
+ } else if(!iso6392.IsEmpty()) {
SetName(p->m_value);
SetProperty(L"LANG", CStringW(iso6392));
- }
- else
- {
+ } else {
SetName(p->m_value);
SetProperty(L"NAME", p->m_value);
}
@@ -629,10 +617,11 @@ CStringW COggSplitterOutputPin::GetComment(CStringW key)
key.MakeUpper();
CAtlList<CStringW> sl;
POSITION pos = m_pComments.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CComment* p = m_pComments.GetNext(pos);
- if(key == p->m_key) sl.AddTail(p->m_value);
+ if(key == p->m_key) {
+ sl.AddTail(p->m_value);
+ }
}
return Implode(sl, ';');
}
@@ -649,87 +638,88 @@ void COggSplitterOutputPin::ResetState(DWORD seqnum)
HRESULT COggSplitterOutputPin::UnpackPage(OggPage& page)
{
- if(m_lastseqnum != page.m_hdr.page_sequence_number-1)
- {
+ if(m_lastseqnum != page.m_hdr.page_sequence_number-1) {
ResetState(page.m_hdr.page_sequence_number);
return S_FALSE; // FIXME
- }
- else
- {
+ } 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();
+ 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();
+ 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))
- {
+ 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(len < 255 || pos == page.m_lens.GetTailPosition()) {
+ if(first == pos && (page.m_hdr.header_type_flag & OggPageHeader::continued)) {
+ // ASSERT(m_lastpacket);
- if(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);
+ if(len < 255) {
+ m_packets.AddTail(m_lastpacket);
+ }
}
- }
- else
- {
+ } else {
CAutoPtr<OggPacket> p(DNew OggPacket());
- if(last == pos && page.m_hdr.granule_position != -1)
- {
+ if(last == pos && page.m_hdr.granule_position != -1) {
p->bDiscontinuity = m_fSkip;
-REFERENCE_TIME rtLast = m_rtLast;
+ 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
+ // 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(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)
- {
+ 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
- {
+ if(len < 255) {
+ m_packets.AddTail(p);
+ } else {
+ m_lastpacket = p;
+ }
+ } else {
ASSERT(0);
}
}
@@ -746,7 +736,9 @@ CAutoPtr<OggPacket> COggSplitterOutputPin::GetPacket()
{
CAutoPtr<OggPacket> p;
CAutoLock csAutoLock(&m_csPackets);
- if(m_packets.GetCount()) p = m_packets.RemoveHead();
+ if(m_packets.GetCount()) {
+ p = m_packets.RemoveHead();
+ }
return p;
}
@@ -807,17 +799,16 @@ HRESULT COggVorbisOutputPin::UnpackInitPage(OggPage& page)
{
HRESULT hr = __super::UnpackPage(page);
- while(m_packets.GetCount())
- {
+ while(m_packets.GetCount()) {
Packet* p = m_packets.GetHead();
- if(p->GetCount() >= 6 && p->GetAt(0) == 0x05)
- {
+ 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++)
- {
+ 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);
@@ -826,8 +817,7 @@ HRESULT COggVorbisOutputPin::UnpackInitPage(OggPage& page)
unsigned int blockflag = bs.getbits(-1);
UNUSED_ALWAYS(mapping);
- if(transformtype != 0 || windowtype != 0)
- {
+ if(transformtype != 0 || windowtype != 0) {
ASSERT(modes == cnt);
break;
}
@@ -837,14 +827,13 @@ HRESULT COggVorbisOutputPin::UnpackInitPage(OggPage& page)
}
int cnt = m_initpackets.GetCount();
- if(cnt <= 3)
- {
+ if(cnt <= 3) {
ASSERT(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,
+ m_mts[0].ReallocFormatBuffer(len + p->GetCount()) + len,
p->GetData(), p->GetCount());
}
@@ -862,15 +851,18 @@ REFERENCE_TIME COggVorbisOutputPin::GetRefTime(__int64 granule_position)
HRESULT COggVorbisOutputPin::UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, int len)
{
- if(len > 0 && m_blockflags.GetCount())
- {
+ if(len > 0 && m_blockflags.GetCount()) {
bitstream bs(pData, len);
- if(bs.getbits(1) == 0)
- {
+ if(bs.getbits(1) == 0) {
int x = m_blockflags.GetCount()-1, n = 0;
- while(x) {n++; x >>= 1;}
+ 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);
+ if(m_lastblocksize) {
+ m_rtLast += GetRefTime((m_lastblocksize + blocksize) >> 2);
+ }
m_lastblocksize = blocksize;
}
}
@@ -885,8 +877,9 @@ HRESULT COggVorbisOutputPin::UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, i
HRESULT COggVorbisOutputPin::DeliverPacket(CAutoPtr<OggPacket> p)
{
- if(p->GetCount() > 0 && (p->GetAt(0)&1))
+ if(p->GetCount() > 0 && (p->GetAt(0)&1)) {
return S_OK;
+ }
return __super::DeliverPacket(p);
}
@@ -897,11 +890,9 @@ HRESULT COggVorbisOutputPin::DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_
m_lastblocksize = 0;
- if(m_mt.subtype == MEDIASUBTYPE_Vorbis)
- {
+ if(m_mt.subtype == MEDIASUBTYPE_Vorbis) {
POSITION pos = m_initpackets.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
Packet* pi = m_initpackets.GetNext(pos);
CAutoPtr<OggPacket> p(DNew OggPacket());
p->TrackNumber = pi->TrackNumber;
@@ -926,9 +917,10 @@ COggFlacOutputPin::COggFlacOutputPin(BYTE* h, int nCount, LPCWSTR pName, CBaseFi
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;
+ if (Buffer.BitRead(7) != 0) { // Should be a STREAMINFO block
+ if(phr) {
+ *phr = VFW_E_INVALID_FILE_FORMAT;
+ }
return;
}
@@ -941,7 +933,7 @@ COggFlacOutputPin::COggFlacOutputPin(BYTE* h, int nCount, LPCWSTR pName, CBaseFi
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;
+ m_nAvgBytesPerSec = (m_nChannels * (m_wBitsPerSample >> 3)) * m_nSamplesPerSec;
CMediaType mt;
@@ -971,8 +963,7 @@ REFERENCE_TIME COggFlacOutputPin::GetRefTime(__int64 granule_position)
HRESULT COggFlacOutputPin::UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, int len)
{
- if (pData[0] != 0xFF || (pData[1] & 0xFE) != 0xF8)
- {
+ if (pData[0] != 0xFF || (pData[1] & 0xFE) != 0xF8) {
return S_FALSE;
}
@@ -986,8 +977,9 @@ HRESULT COggFlacOutputPin::UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, int
HRESULT COggFlacOutputPin::DeliverPacket(CAutoPtr<OggPacket> p)
{
- if(p->GetCount() > 0 && (p->GetAt(0)&1))
+ if(p->GetCount() > 0 && (p->GetAt(0)&1)) {
return S_OK;
+ }
return __super::DeliverPacket(p);
}
@@ -998,11 +990,9 @@ HRESULT COggFlacOutputPin::DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TI
m_lastblocksize = 0;
- if(m_mt.subtype == MEDIASUBTYPE_FLAC_FRAMED)
- {
+ if(m_mt.subtype == MEDIASUBTYPE_FLAC_FRAMED) {
POSITION pos = m_initpackets.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
Packet* pi = m_initpackets.GetNext(pos);
CAutoPtr<OggPacket> p(DNew OggPacket());
p->TrackNumber = pi->TrackNumber;
@@ -1026,20 +1016,18 @@ COggDirectShowOutputPin::COggDirectShowOutputPin(AM_MEDIA_TYPE* pmt, LPCWSTR pNa
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...
+ 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;
- if(m_mt.majortype == MEDIATYPE_Video)
- {
+ if(m_mt.majortype == MEDIATYPE_Video) {
rt = granule_position * ((VIDEOINFOHEADER*)m_mt.Format())->AvgTimePerFrame;
- }
- else if(m_mt.majortype == MEDIATYPE_Audio)
- {
+ } else if(m_mt.majortype == MEDIATYPE_Audio) {
rt = granule_position; // ((WAVEFORMATEX*)m_mt.Format())-> // TODO
}
@@ -1052,15 +1040,18 @@ HRESULT COggDirectShowOutputPin::UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pDat
BYTE hdr = pData[i++];
- if(!(hdr&1))
- {
+ 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++)
+ 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;
@@ -1096,14 +1087,17 @@ HRESULT COggStreamOutputPin::UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, i
BYTE hdr = pData[i++];
- if(!(hdr&1))
- {
+ if(!(hdr&1)) {
BYTE nLenBytes = (hdr>>6)|((hdr&2)<<1);
__int64 Length = 0;
- for(int j = 0; j < nLenBytes; j++)
+ 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;
@@ -1124,7 +1118,7 @@ COggVideoOutputPin::COggVideoOutputPin(OggStreamHeader* h, LPCWSTR pName, CBaseF
: COggStreamOutputPin(h, pName, pFilter, pLock, phr)
{
int extra = (int)h->size - sizeof(OggStreamHeader);
- extra = max(extra, 0);
+ extra = max(extra, 0);
CMediaType mt;
mt.majortype = MEDIATYPE_Video;
@@ -1138,19 +1132,24 @@ COggVideoOutputPin::COggVideoOutputPin(OggStreamHeader* h, LPCWSTR pName, CBaseF
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;
+ 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);
@@ -1164,7 +1163,7 @@ COggAudioOutputPin::COggAudioOutputPin(OggStreamHeader* h, LPCWSTR pName, CBaseF
: COggStreamOutputPin(h, pName, pFilter, pLock, phr)
{
int extra = (int)h->size - sizeof(OggStreamHeader);
- extra = max(extra, 0);
+ extra = max(extra, 0);
CMediaType mt;
mt.majortype = MEDIATYPE_Audio;
@@ -1218,18 +1217,19 @@ COggTheoraOutputPin::COggTheoraOutputPin(BYTE* p, LPCWSTR pName, CBaseFilter* pF
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)
- {
+ 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 ?
+
+ if (m_KfgShift == 0) {
+ m_KfgShift = 6; // Is it really default value ?
+ }
mt.bFixedSizeSamples = 0;
m_mts.Add(mt);
@@ -1239,17 +1239,16 @@ HRESULT COggTheoraOutputPin::UnpackInitPage(OggPage& page)
{
HRESULT hr = __super::UnpackPage(page);
- while(m_packets.GetCount())
- {
+ 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);
+ 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;
@@ -1262,15 +1261,15 @@ HRESULT COggTheoraOutputPin::UnpackInitPage(OggPage& page)
REFERENCE_TIME COggTheoraOutputPin::GetRefTime(__int64 granule_position)
{
- LONGLONG iframe;
- LONGLONG pframe;
+ 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.*/
+ 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;
@@ -1284,8 +1283,9 @@ HRESULT COggTheoraOutputPin::UnpackPacket(CAutoPtr<OggPacket>& p, BYTE* pData, i
p->rtStop = m_rtLast+1;
p->SetData(pData, len);
- if(!(*pData & 0x80) && m_mt.majortype == MEDIATYPE_Video)
+ if(!(*pData & 0x80) && m_mt.majortype == MEDIATYPE_Video) {
p->rtStop = p->rtStart + ((MPEG2VIDEOINFO*)m_mt.Format())->hdr.AvgTimePerFrame;
+ }
return S_OK;
}
diff --git a/src/filters/parser/OggSplitter/OggSplitter.h b/src/filters/parser/OggSplitter/OggSplitter.h
index 5790ccad0..3d7ae5975 100644
--- a/src/filters/parser/OggSplitter/OggSplitter.h
+++ b/src/filters/parser/OggSplitter/OggSplitter.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -29,7 +29,9 @@
class OggPacket : public Packet
{
public:
- OggPacket() {fSkip = false;}
+ OggPacket() {
+ fSkip = false;
+ }
bool fSkip;
};
@@ -37,9 +39,11 @@ 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();}
+ public:
+ CStringW m_key, m_value;
+ CComment(CStringW key, CStringW value) : m_key(key), m_value(value) {
+ m_key.MakeUpper();
+ }
};
CAutoPtrList<CComment> m_pComments;
@@ -64,9 +68,9 @@ public:
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 DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
};
class COggVorbisOutputPin : public COggSplitterOutputPin
@@ -81,13 +85,15 @@ class COggVorbisOutputPin : public COggSplitterOutputPin
virtual REFERENCE_TIME GetRefTime(__int64 granule_position);
HRESULT DeliverPacket(CAutoPtr<OggPacket> p);
- HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
+ HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
public:
COggVorbisOutputPin(OggVorbisIdHeader* h, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
HRESULT UnpackInitPage(OggPage& page);
- bool IsInitialized() {return m_initpackets.GetCount() >= 3;}
+ bool IsInitialized() {
+ return m_initpackets.GetCount() >= 3;
+ }
};
class COggFlacOutputPin : public COggSplitterOutputPin
@@ -106,12 +112,14 @@ class COggFlacOutputPin : public COggSplitterOutputPin
virtual REFERENCE_TIME GetRefTime(__int64 granule_position);
HRESULT DeliverPacket(CAutoPtr<OggPacket> p);
- HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
+ HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
public:
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
@@ -169,11 +177,13 @@ public:
COggTheoraOutputPin(BYTE* p, LPCWSTR pName, CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
HRESULT UnpackInitPage(OggPage& page);
- bool IsInitialized() {return m_initpackets.GetCount() >= 3;}
+ 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;
@@ -189,7 +199,7 @@ public:
};
class __declspec(uuid("6D3688CE-3E9D-42F4-92CA-8A11119D25CD"))
-COggSourceFilter : public COggSplitterFilter
+ COggSourceFilter : public COggSplitterFilter
{
public:
COggSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
diff --git a/src/filters/parser/OggSplitter/stdafx.cpp b/src/filters/parser/OggSplitter/stdafx.cpp
index 13934d005..bea3f980a 100644
--- a/src/filters/parser/OggSplitter/stdafx.cpp
+++ b/src/filters/parser/OggSplitter/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/parser/OggSplitter/stdafx.h b/src/filters/parser/OggSplitter/stdafx.h
index 01aef1f91..f8e9cd301 100644
--- a/src/filters/parser/OggSplitter/stdafx.h
+++ b/src/filters/parser/OggSplitter/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/parser/RealMediaSplitter/RealMediaSplitter.cpp b/src/filters/parser/RealMediaSplitter/RealMediaSplitter.cpp
index a3da7019f..50b9c752b 100644
--- a/src/filters/parser/RealMediaSplitter/RealMediaSplitter.cpp
+++ b/src/filters/parser/RealMediaSplitter/RealMediaSplitter.cpp
@@ -38,8 +38,9 @@ template<typename T>
static void bswap(T& var)
{
BYTE* s = (BYTE*)&var;
- for(BYTE* d = s + sizeof(var)-1; s < d; s++, d--)
+ for(BYTE* d = s + sizeof(var)-1; s < d; s++, d--) {
*s ^= *d, *d ^= *s, *s ^= *d;
+ }
}
void rvinfo::bswap()
@@ -86,38 +87,32 @@ using namespace RMFF;
#ifdef REGISTER_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
{&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
};
-const AMOVIESETUP_PIN sudpPins[] =
-{
+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}
};
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn2[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn2[] = {
{&MEDIATYPE_Video, &MEDIASUBTYPE_RV20},
{&MEDIATYPE_Video, &MEDIASUBTYPE_RV30},
{&MEDIATYPE_Video, &MEDIASUBTYPE_RV40},
{&MEDIATYPE_Video, &MEDIASUBTYPE_RV41},
};
-const AMOVIESETUP_MEDIATYPE sudPinTypesOut2[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesOut2[] = {
{&MEDIATYPE_Video, &MEDIASUBTYPE_NULL},
};
-const AMOVIESETUP_PIN sudpPins2[] =
-{
+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}
};
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn3[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn3[] = {
{&MEDIATYPE_Audio, &MEDIASUBTYPE_14_4},
{&MEDIATYPE_Audio, &MEDIASUBTYPE_28_8},
{&MEDIATYPE_Audio, &MEDIASUBTYPE_ATRC},
@@ -129,27 +124,23 @@ const AMOVIESETUP_MEDIATYPE sudPinTypesIn3[] =
{&MEDIATYPE_Audio, &MEDIASUBTYPE_RACP},
};
-const AMOVIESETUP_MEDIATYPE sudPinTypesOut3[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesOut3[] = {
{&MEDIATYPE_Audio, &MEDIASUBTYPE_PCM},
};
-const AMOVIESETUP_PIN sudpPins3[] =
-{
+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}
};
-const AMOVIESETUP_FILTER sudFilter[] =
-{
+const AMOVIESETUP_FILTER sudFilter[] = {
{&__uuidof(CRealMediaSplitterFilter), L"MPC - RealMedia Splitter", MERIT_NORMAL, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
{&__uuidof(CRealMediaSourceFilter), L"MPC - RealMedia Source", 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[] =
-{
+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]},
@@ -197,8 +188,9 @@ HRESULT CRealMediaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
{
DWORD dw;
- if(FAILED(pAsyncReader->SyncRead(0, 4, (BYTE*)&dw)) || dw != 'FMR.')
+ if(FAILED(pAsyncReader->SyncRead(0, 4, (BYTE*)&dw)) || dw != 'FMR.') {
return E_FAIL;
+ }
}
HRESULT hr = E_FAIL;
@@ -206,7 +198,9 @@ HRESULT CRealMediaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
m_pFile.Free();
m_pFile.Attach(DNew CRMFile(pAsyncReader, hr));
- if(!m_pFile) return E_OUTOFMEMORY;
+ if(!m_pFile) {
+ return E_OUTOFMEMORY;
+ }
if(FAILED(hr)) {
m_pFile.Free();
return hr;
@@ -218,21 +212,21 @@ HRESULT CRealMediaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
m_rtStop = 10000i64*m_pFile->m_p.tDuration;
POSITION pos = m_pFile->m_mps.GetHeadPosition();
- while(pos)
- {
+ 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")";
+ 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")
- {
+ if(pmp->mime == "video/x-pn-realvideo") {
mt.majortype = MEDIATYPE_Video;
mt.formattype = FORMAT_VideoInfo;
@@ -247,7 +241,9 @@ HRESULT CRealMediaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
ASSERT(rvi.fcc1 == 'ODIV');
mt.subtype = FOURCCMap(rvi.fcc2);
- if(rvi.fps > 0x10000) pvih->AvgTimePerFrame = REFERENCE_TIME(10000000i64 / ((float)rvi.fps/0x10000));
+ 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;
@@ -259,8 +255,7 @@ HRESULT CRealMediaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
mts.Add(mt);
- if(pmp->width > 0 && pmp->height > 0)
- {
+ 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());
@@ -274,9 +269,7 @@ HRESULT CRealMediaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
mts.InsertAt(0, mt);
}
- }
- else if(pmp->mime == "audio/x-pn-realaudio")
- {
+ } else if(pmp->mime == "audio/x-pn-realaudio") {
mt.majortype = MEDIATYPE_Audio;
mt.formattype = FORMAT_WaveFormatEx;
mt.bTemporalCompression = 1;
@@ -294,10 +287,10 @@ HRESULT CRealMediaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
fccstr[4] = 0;
BYTE* fmt = pmp->typeSpecData.GetData();
- for(int i = 0; i < pmp->typeSpecData.GetCount()-4; i++, fmt++)
- {
- if(fmt[0] == '.' || fmt[1] == 'r' || fmt[2] == 'a')
+ for(int i = 0; i < pmp->typeSpecData.GetCount()-4; i++, fmt++) {
+ if(fmt[0] == '.' || fmt[1] == 'r' || fmt[2] == 'a') {
break;
+ }
}
rainfo rai = *(rainfo*)fmt;
@@ -305,8 +298,7 @@ HRESULT CRealMediaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
BYTE* extra = NULL;
- if(rai.version2 == 4)
- {
+ if(rai.version2 == 4) {
rainfo4 rai4 = *(rainfo4*)fmt;
rai4.bswap();
pwfe->nChannels = rai4.channels;
@@ -318,12 +310,11 @@ HRESULT CRealMediaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
p += len;
len = *p++;
ASSERT(len == 4);
- if(len == 4)
+ if(len == 4) {
fcc = MAKEFOURCC(p[0],p[1],p[2],p[3]);
+ }
extra = p + len + 3;
- }
- else if(rai.version2 == 5)
- {
+ } else if(rai.version2 == 5) {
rainfo5 rai5 = *(rainfo5*)fmt;
rai5.bswap();
pwfe->nChannels = rai5.channels;
@@ -332,9 +323,7 @@ HRESULT CRealMediaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
pwfe->nBlockAlign = rai5.frame_size;
fcc = rai5.fourcc3;
extra = fmt + sizeof(rainfo5) + 4;
- }
- else
- {
+ } else {
continue;
}
@@ -344,69 +333,59 @@ HRESULT CRealMediaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
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;
+ 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)
- {
+ if(pwfe->wFormatTag) {
mts.Add(mt);
- if(fcc == 'DNET')
- {
+ if(fcc == 'DNET') {
mt.subtype = FOURCCMap(pwfe->wFormatTag = WAVE_FORMAT_DOLBY_AC3);
mts.InsertAt(0, mt);
- }
- else if(fcc == 'RAAC' || fcc == 'RACP')
- {
+ } 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)
- {
+ if(*extra == 2) {
extra++;
extralen--;
WAVEFORMATEX* pwfe = (WAVEFORMATEX*)mt.ReallocFormatBuffer(sizeof(WAVEFORMATEX) + extralen);
pwfe->cbSize = extralen;
memcpy(pwfe + 1, extra, extralen);
- }
- else
- {
+ } 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")
- {
+ } else if(pmp->mime == "logical-fileinfo") {
CAtlMap<CStringA, CStringA, CStringElementTraits<CStringA> > lfi;
CStringA key, value;
@@ -418,21 +397,21 @@ HRESULT CRealMediaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
bswap(cnt);
p += 4;
- if(cnt > 0xffff) // different format?
- {
+ if(cnt > 0xffff) { // different format?
p += 2;
cnt = p <= end-4 ? *(DWORD*)p : 0;
bswap(cnt);
p += 4;
}
- while(p < end-4 && cnt-- > 0)
- {
+ while(p < end-4 && cnt-- > 0) {
BYTE* base = p;
DWORD len = *(DWORD*)p;
bswap(len);
p += 4;
- if(base + len > end) break;
+ if(base + len > end) {
+ break;
+ }
p++;
WORD keylen = *(WORD*)p;
@@ -455,22 +434,22 @@ HRESULT CRealMediaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
}
POSITION pos = lfi.GetStartPosition();
- while(pos)
- {
+ 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)
- {
+ && (n = strtol(key.Mid(7), NULL, 10)) > 0) {
int h, m, s, ms;
char c;
- if(7 != sscanf(value, "%d%c%d%c%d%c%d", &h, &c, &m, &c, &s, &c, &ms))
+ if(7 != sscanf(value, "%d%c%d%c%d%c%d", &h, &c, &m, &c, &s, &c, &ms)) {
continue;
+ }
key.Format("CHAPTER%02dNAME", n);
- if(!lfi.Lookup(key, value) || value.IsEmpty())
+ if(!lfi.Lookup(key, value) || value.IsEmpty()) {
value.Format("Chapter %d", n);
+ }
ChapAppend(
((((REFERENCE_TIME)h*60+m)*60+s)*1000+ms)*10000,
@@ -479,8 +458,7 @@ HRESULT CRealMediaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
}
}
- if(mts.IsEmpty())
- {
+ if(mts.IsEmpty()) {
TRACE(_T("Unsupported RealMedia stream (%d): %s\n"), pmp->stream, CString(pmp->mime));
continue;
}
@@ -488,21 +466,22 @@ HRESULT CRealMediaSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
HRESULT hr;
CAutoPtr<CBaseSplitterOutputPin> pPinOut(DNew CRealMediaSplitterOutputPin(mts, name, this, this, &hr));
- if(SUCCEEDED(AddOutputPin((DWORD)pmp->stream, pPinOut)))
- {
- if(!m_rtStop)
+ 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++)
- {
+ 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")";
+ if(!s.name.IsEmpty()) {
+ name += L" (" + CStringW(CString(s.name)) + L")";
+ }
CMediaType mt;
mt.SetSampleSize(1);
@@ -531,12 +510,13 @@ bool CRealMediaSplitterFilter::DemuxInit()
{
SetThreadName((DWORD)-1, "CRealMediaSplitterFilter");
- if(!m_pFile) return(false);
+ if(!m_pFile) {
+ return(false);
+ }
// reindex if needed
- if(m_pFile->m_irs.GetCount() == 0)
- {
+ if(m_pFile->m_irs.GetCount() == 0) {
m_nOpenProgress = 0;
m_rtDuration = 0;
@@ -546,26 +526,24 @@ bool CRealMediaSplitterFilter::DemuxInit()
UINT32 nPacket = 0;
POSITION pos = m_pFile->m_dcs.GetHeadPosition();
- while(pos && !m_fAbort)
- {
+ while(pos && !m_fAbort) {
DataChunk* pdc = m_pFile->m_dcs.GetNext(pos);
m_pFile->Seek(pdc->pos);
- for(UINT32 i = 0; i < pdc->nPackets && !m_fAbort; i++, nPacket++)
- {
+ for(UINT32 i = 0; i < pdc->nPackets && !m_fAbort; i++, nPacket++) {
UINT64 filepos = m_pFile->GetPos();
HRESULT hr;
MediaPacketHeader mph;
- if(S_OK != (hr = m_pFile->Read(mph, false)))
+ if(S_OK != (hr = m_pFile->Read(mph, false))) {
break;
+ }
m_rtDuration = max((__int64)(10000i64*mph.tStart), m_rtDuration);
- if(mph.stream == stream && (mph.flags&MediaPacketHeader::PN_KEYFRAME_FLAG) && tLastStart != mph.tStart)
- {
+ 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;
@@ -578,17 +556,21 @@ bool CRealMediaSplitterFilter::DemuxInit()
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);
+ if(CheckRequest(&cmd)) {
+ if(cmd == CMD_EXIT) {
+ m_fAbort = true;
+ } else {
+ Reply(S_OK);
+ }
}
}
}
m_nOpenProgress = 100;
- if(m_fAbort) m_pFile->m_irs.RemoveAll();
+ if(m_fAbort) {
+ m_pFile->m_irs.RemoveAll();
+ }
m_fAbort = false;
}
@@ -602,83 +584,74 @@ bool CRealMediaSplitterFilter::DemuxInit()
void CRealMediaSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
{
- if(rt <= 0)
- {
+ if(rt <= 0) {
m_seekpos = m_pFile->m_dcs.GetHeadPosition();
m_seekpacket = 0;
m_seekfilepos = m_pFile->m_dcs.GetHead()->pos;
- }
- else
- {
+ } else {
m_seekpos = NULL;
POSITION pos = m_pFile->m_irs.GetTailPosition();
- while(pos && !m_seekpos)
- {
+ while(pos && !m_seekpos) {
IndexRecord* pir = m_pFile->m_irs.GetPrev(pos);
- if(pir->tStart <= rt/10000)
- {
+ if(pir->tStart <= rt/10000) {
m_seekpacket = pir->packet;
pos = m_pFile->m_dcs.GetTailPosition();
- while(pos && !m_seekpos)
- {
+ while(pos && !m_seekpos) {
POSITION tmp = pos;
DataChunk* pdc = m_pFile->m_dcs.GetPrev(pos);
- if(pdc->pos <= pir->ptrFilePos)
- {
+ if(pdc->pos <= pir->ptrFilePos) {
m_seekpos = tmp;
m_seekfilepos = pir->ptrFilePos;
POSITION pos = m_pFile->m_dcs.GetHeadPosition();
- while(pos != m_seekpos)
- {
+ 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)
+ {
+ 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)
- {
+ if(!m_seekpos) {
m_seekpos = m_pFile->m_dcs.GetHeadPosition();
m_seekpacket = 0;
m_seekfilepos = m_pFile->m_dcs.GetAt(m_seekpos)->pos;
@@ -692,8 +665,7 @@ bool CRealMediaSplitterFilter::DemuxLoop()
POSITION pos;
pos = m_pFile->m_subs.GetHeadPosition();
- for(DWORD stream = 0; pos && SUCCEEDED(hr) && !CheckRequest(NULL); stream++)
- {
+ for(DWORD stream = 0; pos && SUCCEEDED(hr) && !CheckRequest(NULL); stream++) {
CRMFile::subtitle& s = m_pFile->m_subs.GetNext(pos);
CAutoPtr<Packet> p(DNew Packet);
@@ -727,17 +699,16 @@ bool CRealMediaSplitterFilter::DemuxLoop()
}
pos = m_seekpos;
- while(pos && SUCCEEDED(hr) && !CheckRequest(NULL))
- {
+ 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++)
- {
+ for(UINT32 i = m_seekpacket; i < pdc->nPackets && SUCCEEDED(hr) && !CheckRequest(NULL); i++) {
MediaPacketHeader mph;
- if(S_OK != (hr = m_pFile->Read(mph)))
+ if(S_OK != (hr = m_pFile->Read(mph))) {
break;
+ }
CAutoPtr<Packet> p(DNew Packet);
p->TrackNumber = mph.stream;
@@ -759,7 +730,9 @@ bool CRealMediaSplitterFilter::DemuxLoop()
STDMETHODIMP CRealMediaSplitterFilter::GetKeyFrameCount(UINT& nKFs)
{
- if(!m_pFile) return E_UNEXPECTED;
+ if(!m_pFile) {
+ return E_UNEXPECTED;
+ }
nKFs = m_pFile->m_irs.GetCount();
return S_OK;
}
@@ -769,13 +742,18 @@ STDMETHODIMP CRealMediaSplitterFilter::GetKeyFrames(const GUID* pFormat, REFEREN
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;
POSITION pos = m_pFile->m_irs.GetHeadPosition();
- for(int i = 0; pos && nKFsTmp < nKFs; i++)
+ for(int i = 0; pos && nKFsTmp < nKFs; i++) {
pKFs[nKFsTmp++] = 10000i64*m_pFile->m_irs.GetNext(pos)->tStart;
+ }
nKFs = nKFsTmp;
return S_OK;
@@ -808,8 +786,7 @@ HRESULT CRealMediaSplitterOutputPin::DeliverSegments()
{
HRESULT hr;
- if(m_segments.GetCount() == 0)
- {
+ if(m_segments.GetCount() == 0) {
m_segments.Clear();
return S_OK;
}
@@ -824,8 +801,7 @@ HRESULT CRealMediaSplitterOutputPin::DeliverSegments()
DWORD len = 0, total = 0;
POSITION pos = m_segments.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
segment* s = m_segments.GetNext(pos);
len = max(len, s->offset + s->data.GetCount());
total += s->data.GetCount();
@@ -839,18 +815,14 @@ HRESULT CRealMediaSplitterOutputPin::DeliverSegments()
*pData++ = m_segments.fMerged ? 0 : m_segments.GetCount()-1;
- if(m_segments.fMerged)
- {
+ if(m_segments.fMerged) {
*((DWORD*)pData) = 1;
pData += 4;
*((DWORD*)pData) = 0;
pData += 4;
- }
- else
- {
+ } else {
pos = m_segments.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
*((DWORD*)pData) = 1;
pData += 4;
*((DWORD*)pData) = m_segments.GetNext(pos)->offset;
@@ -859,8 +831,7 @@ HRESULT CRealMediaSplitterOutputPin::DeliverSegments()
}
pos = m_segments.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
segment* s = m_segments.GetNext(pos);
memcpy(pData + s->offset, s->data.GetData(), s->data.GetCount());
}
@@ -878,74 +849,77 @@ HRESULT CRealMediaSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p)
ASSERT(p->rtStart < p->rtStop);
- if(m_mt.subtype == MEDIASUBTYPE_WAVE_DOLBY_AC3)
- {
+ if(m_mt.subtype == MEDIASUBTYPE_WAVE_DOLBY_AC3) {
WORD* s = (WORD*)p->GetData();
WORD* e = s + p->GetCount()/2;
- while(s < e) bswap(*s++);
+ 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)
- {
+ || 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()))
+ if(m_segments.rtStart != p->rtStart) {
+ if(S_OK != (hr = DeliverSegments())) {
return hr;
+ }
}
- if(!m_segments.fDiscontinuity && p->bDiscontinuity)
+ if(!m_segments.fDiscontinuity && p->bDiscontinuity) {
m_segments.fDiscontinuity = true;
+ }
m_segments.fSyncPoint = !!p->bSyncPoint;
m_segments.rtStart = p->rtStart;
- while(pIn - pInOrg < len)
- {
+ while(pIn - pInOrg < len) {
BYTE hdr = *pIn++, subseq = 0, seqnum = 0;
DWORD packetlen = 0, packetoffset = 0;
- if((hdr&0xc0) == 0x40)
- {
+ if((hdr&0xc0) == 0x40) {
pIn++;
packetlen = len - (pIn - pInOrg);
- }
- else
- {
- if((hdr&0x40) == 0)
+ } else {
+ if((hdr&0x40) == 0) {
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&0x8000) {
+ m_segments.fMerged = true;
+ }
if((packetlen&0x4000) == 0) {
GetWORD(packetlen);
packetlen &= 0x3fffffff;
+ } else {
+ packetlen &= 0x3fff;
}
- else packetlen &= 0x3fff;
GetWORD(packetoffset);
if((packetoffset&0x4000) == 0) {
GetWORD(packetoffset);
packetoffset &= 0x3fffffff;
+ } else {
+ packetoffset &= 0x3fff;
}
- else packetoffset &= 0x3fff;
#undef GetWORD
- if((hdr&0xc0) == 0xc0)
+ if((hdr&0xc0) == 0xc0) {
m_segments.rtStart = 10000i64*packetoffset - m_rtStart, packetoffset = 0;
- else if((hdr&0xc0) == 0x80)
+ } else if((hdr&0xc0) == 0x80) {
packetoffset = packetlen - packetoffset;
+ }
seqnum = *pIn++;
}
@@ -960,16 +934,14 @@ HRESULT CRealMediaSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p)
pIn += len2;
- if((hdr&0x80) || packetoffset+len2 >= packetlen)
- {
- if(S_OK != (hr = DeliverSegments()))
+ 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)
- {
+ } 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;
@@ -977,8 +949,7 @@ HRESULT CRealMediaSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p)
int remaining = p->GetCount()-2;
int expected = *(ptr-1)>>4;
- while(total < remaining)
- {
+ while(total < remaining) {
int size = (ptr[0]<<8)|(ptr[1]);
sizes.AddTail(size);
total += size;
@@ -996,8 +967,7 @@ HRESULT CRealMediaSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p)
BOOL bDiscontinuity = p->bDiscontinuity;
POSITION pos = sizes.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
WORD size = sizes.GetNext(pos);
CAutoPtr<Packet> p(DNew Packet);
@@ -1008,12 +978,11 @@ HRESULT CRealMediaSplitterOutputPin::DeliverPacket(CAutoPtr<Packet> p)
p->SetData(ptr, size);
ptr += size;
bDiscontinuity = false;
- if(S_OK != (hr = __super::DeliverPacket(p)))
+ if(S_OK != (hr = __super::DeliverPacket(p))) {
break;
+ }
}
- }
- else
- {
+ } else {
hr = __super::DeliverPacket(p);
}
@@ -1038,7 +1007,9 @@ CRealMediaSourceFilter::CRealMediaSourceFilter(LPUNKNOWN pUnk, HRESULT* phr)
CRMFile::CRMFile(IAsyncReader* pAsyncReader, HRESULT& hr)
: CBaseSplitterFile(pAsyncReader, hr)
{
- if(FAILED(hr)) return;
+ if(FAILED(hr)) {
+ return;
+ }
hr = Init();
}
@@ -1056,8 +1027,9 @@ HRESULT CRMFile::Read(ChunkHdr& hdr)
HRESULT hr;
if(S_OK != (hr = Read(hdr.object_id))
|| S_OK != (hr = Read(hdr.size))
- || S_OK != (hr = Read(hdr.object_version)))
+ || S_OK != (hr = Read(hdr.object_version))) {
return hr;
+ }
return S_OK;
}
@@ -1069,16 +1041,21 @@ HRESULT CRMFile::Read(MediaPacketHeader& mph, bool fFull)
HRESULT hr;
UINT16 object_version;
- if(S_OK != (hr = Read(object_version))) return hr;
- if(object_version != 0 && object_version != 1) return S_OK;
+ 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)))
+ || S_OK != (hr = Read(flags))) {
return hr;
+ }
mph.flags = (MediaPacketHeader::flag_t)flags;
LONG len = mph.len;
@@ -1088,14 +1065,12 @@ HRESULT CRMFile::Read(MediaPacketHeader& mph, bool fFull)
ASSERT(len >= 0);
len = max(len, 0);
- if(fFull)
- {
+ if(fFull) {
mph.pData.SetCount(len);
- if(mph.len > 0 && S_OK != (hr = ByteRead(mph.pData.GetData(), len)))
+ if(mph.len > 0 && S_OK != (hr = ByteRead(mph.pData.GetData(), len))) {
return hr;
- }
- else
- {
+ }
+ } else {
Seek(GetPos() + len);
}
@@ -1112,143 +1087,230 @@ HRESULT CRMFile::Init()
HRESULT hr;
ChunkHdr hdr;
- while(GetRemaining() && S_OK == (hr = Read(hdr)))
- {
+ while(GetRemaining() && S_OK == (hr = Read(hdr))) {
__int64 pos = GetPos() - sizeof(hdr);
- if(fFirstChunk && hdr.object_id != '.RMF')
+ if(fFirstChunk && hdr.object_id != '.RMF') {
return E_FAIL;
+ }
fFirstChunk = false;
- if(pos + hdr.size > GetLength() && hdr.object_id != 'DATA') // truncated?
+ if(pos + hdr.size > GetLength() && hdr.object_id != 'DATA') { // truncated?
break;
+ }
- if(hdr.object_id == 0x2E7261FD) // '.ra+0xFD'
+ 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;
+ 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;
}
- 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);
+ 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;
}
- 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);
+ 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;
}
- 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')
- {
+ if(hdr.object_id == 'CONT' && BitRead(32, true) == 'DATA') {
hdr.size = GetPos() - pos;
}
@@ -1257,8 +1319,9 @@ HRESULT CRMFile::Init()
|| GetPos() == pos + sizeof(hdr));
pos += hdr.size;
- if(pos > GetPos())
+ if(pos > GetPos()) {
Seek(pos);
+ }
}
return S_OK;
@@ -1272,8 +1335,7 @@ unsigned int GetBits2(int n, unsigned char*& p, unsigned int& bit_offset, unsign
bit_offset += n;
bit_buffer <<= n;
- if(bit_offset > (32-16))
- {
+ if(bit_offset > (32-16)) {
p += bit_offset >> 3;
bit_offset &= 7;
bit_buffer = (unsigned int)p[0] << 24;
@@ -1303,32 +1365,25 @@ void GetDimensions(unsigned char* p, unsigned int* wi, unsigned int* hi)
GetBits(13);
w = cw[GetBits(3)];
- if(w == 0)
- {
- do
- {
+ if(w == 0) {
+ do {
c = GetBits(8);
w += (c << 2);
- }
- while(c == 255);
+ } while(c == 255);
}
c = GetBits(3);
h = ch1[c];
- if(h == 0)
- {
+ if(h == 0) {
c = ((c << 1) | GetBits(1)) & 3;
h = ch2[c];
- if(h == 0)
- {
- do
- {
+ if(h == 0) {
+ do {
c = GetBits(8);
h += (c << 2);
- }
- while(c == 255);
+ } while(c == 255);
}
}
@@ -1355,53 +1410,49 @@ void GetDimensions_X10(unsigned char* p, unsigned int* wi, unsigned int* hi,
*top_field_first = false;
*repeat_field = false;
c = GetBits(1);
- if (c)
- {
+ if (c) {
c = GetBits(1);
- if (c)
+ if (c) {
*interlaced = true;
+ }
c = GetBits(1);
- if (c)
+ if (c) {
*top_field_first = true;
+ }
c = GetBits(1);
- if (c)
+ if (c) {
*repeat_field = true;
+ }
c = GetBits(1);
c = GetBits(1);
- if (c)
+ if (c) {
GetBits(2);
+ }
}
GetBits(16);
w = cw[GetBits(3)];
- if(w == 0)
- {
- do
- {
+ if(w == 0) {
+ do {
c = GetBits(8);
w += (c << 2);
- }
- while(c == 255);
+ } while(c == 255);
}
c = GetBits(3);
h = ch1[c];
- if(h == 0)
- {
+ if(h == 0) {
c = ((c << 1) | GetBits(1)) & 3;
h = ch2[c];
- if(h == 0)
- {
- do
- {
+ if(h == 0) {
+ do {
c = GetBits(8);
h += (c << 2);
- }
- while(c == 255);
+ } while(c == 255);
}
}
@@ -1412,27 +1463,26 @@ void GetDimensions_X10(unsigned char* p, unsigned int* wi, unsigned int* hi,
void CRMFile::GetDimensions()
{
POSITION pos = m_mps.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
UINT64 filepos = GetPos();
MediaProperies* pmp = m_mps.GetNext(pos);
- if(pmp->mime == "video/x-pn-realvideo")
- {
+ 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')
+ if(rvi.fcc2 != '04VR' && rvi.fcc2 != '14VR') {
continue;
+ }
MediaPacketHeader mph;
- while(S_OK == Read(mph))
- {
+ while(S_OK == Read(mph)) {
if(mph.stream != pmp->stream || mph.len == 0
- || !(mph.flags&MediaPacketHeader::PN_KEYFRAME_FLAG))
+ || !(mph.flags&MediaPacketHeader::PN_KEYFRAME_FLAG)) {
continue;
+ }
BYTE* p = mph.pData.GetData();
BYTE* p0 = p;
@@ -1441,13 +1491,12 @@ void CRMFile::GetDimensions()
BYTE hdr = *p++;
DWORD packetlen = 0, packetoffset = 0;
- if((hdr&0xc0) == 0x40)
- {
+ if((hdr&0xc0) == 0x40) {
packetlen = len - (++p - p0);
- }
- else
- {
- if((hdr&0x40) == 0) p++;
+ } else {
+ if((hdr&0x40) == 0) {
+ p++;
+ }
#define GetWORD(var) \
var = (var<<8)|(*p++); \
@@ -1457,34 +1506,42 @@ void CRMFile::GetDimensions()
if((packetlen&0x4000) == 0) {
GetWORD(packetlen);
packetlen &= 0x3fffffff;
+ } else {
+ packetlen &= 0x3fff;
}
- else packetlen &= 0x3fff;
GetWORD(packetoffset);
if((packetoffset&0x4000) == 0) {
GetWORD(packetoffset);
packetoffset &= 0x3fffffff;
+ } else {
+ packetoffset &= 0x3fff;
}
- 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++;
}
len = min(len - (p - p0), packetlen - packetoffset);
- if(len > 0)
- {
+ 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.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)
+ if(rvi.w == pmp->width && rvi.h == pmp->height) {
pmp->width = pmp->height = 0;
+ }
break;
}
@@ -1500,18 +1557,19 @@ int CRMFile::GetMasterStream()
int s1 = -1, s2 = -1;
POSITION pos = m_mps.GetHeadPosition();
- while(pos)
- {
+ 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;
}
- else if(pmp->mime == "audio/x-pn-realaudio" && s2 == -1) s2 = pmp->stream;
}
- if(s1 == -1)
+ if(s1 == -1) {
s1 = s2;
+ }
return s1;
}
@@ -1533,7 +1591,9 @@ CRealVideoDecoder::CRealVideoDecoder(LPUNKNOWN lpunk, HRESULT* phr)
CRealVideoDecoder::~CRealVideoDecoder()
{
- if(m_hDrvDll) FreeLibrary(m_hDrvDll);
+ if(m_hDrvDll) {
+ FreeLibrary(m_hDrvDll);
+ }
}
HRESULT CRealVideoDecoder::InitRV(const CMediaType* pmt)
@@ -1553,17 +1613,18 @@ HRESULT CRealVideoDecoder::InitRV(const CMediaType* pmt)
{11, rvi.w, rvi.h, 0, 0, rvi.type1, 1, rvi.type2};
#pragma pack(pop)
- if(FAILED(hr = RVInit(&i, &m_dwCookie)))
+ if(FAILED(hr = RVInit(&i, &m_dwCookie))) {
return hr;
+ }
- if(rvi.fcc2 <= '03VR' && rvi.type2 >= 0x20200002)
- {
+ 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++)
+ for(int i = 2; i < nWidthHeight*2; i++) {
pWH[i] = rvi.morewh[i-2]*4;
+ }
#pragma pack(push, 1)
struct {
UINT32 data1;
@@ -1581,8 +1642,7 @@ HRESULT CRealVideoDecoder::InitRV(const CMediaType* pmt)
void CRealVideoDecoder::FreeRV()
{
- if(m_dwCookie)
- {
+ if(m_dwCookie) {
RVFree(m_dwCookie);
m_dwCookie = 0;
}
@@ -1595,11 +1655,14 @@ HRESULT CRealVideoDecoder::Transform(IMediaSample* pIn)
HRESULT hr;
BYTE* pDataIn = NULL;
- if(FAILED(hr = pIn->GetPointer(&pDataIn)))
+ if(FAILED(hr = pIn->GetPointer(&pDataIn))) {
return hr;
+ }
long len = pIn->GetActualDataLength();
- if(len <= 0) return S_OK; // nothing to do
+ if(len <= 0) {
+ return S_OK; // nothing to do
+ }
REFERENCE_TIME rtStart, rtStop;
pIn->GetTime(&rtStart, &rtStop);
@@ -1623,8 +1686,7 @@ HRESULT CRealVideoDecoder::Transform(IMediaSample* pIn)
pDataIn += offset;
- if(m_fDropFrames && m_timestamp+1 == transform_in.timestamp)
- {
+ if(m_fDropFrames && m_timestamp+1 == transform_in.timestamp) {
m_timestamp = transform_in.timestamp;
return S_OK;
}
@@ -1635,36 +1697,29 @@ HRESULT CRealVideoDecoder::Transform(IMediaSample* pIn)
::GetDimensions_X10(pDataIn, &tmp1, &tmp2, &interlaced, &tmp3, &tmp4);
int size = tmp1*tmp2;
- if( m_lastBuffSizeDim < size )
- {
+ if( m_lastBuffSizeDim < size ) {
_aligned_free(m_pI420);
_aligned_free(m_pI420Tmp);
m_lastBuffSizeDim = size;
ATLTRACE("resize out put buff %d" ,size);
- if ( m_pI420 = static_cast<BYTE*>(_aligned_malloc(size*3/2, 16)))
- {
+ if ( m_pI420 = static_cast<BYTE*>(_aligned_malloc(size*3/2, 16))) {
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
- {
+ } else {
ATLTRACE(" m_pI420.Allocate fail %d" ,size*3/2);
return S_OK;
}
- if( m_pI420Tmp = static_cast<BYTE*>(_aligned_malloc(size*3/2, 16)))
- {
+ if( m_pI420Tmp = static_cast<BYTE*>(_aligned_malloc(size*3/2, 16))) {
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
- {
+ } else {
ATLTRACE(" m_pI420Tmp.Allocate fail %d" ,size*3/2);
return S_OK;
}
@@ -1674,27 +1729,27 @@ HRESULT CRealVideoDecoder::Transform(IMediaSample* pIn)
m_timestamp = transform_in.timestamp;
- if(FAILED(hr))
- {
+ 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;
+ // return hr;
}
- if(pIn->IsPreroll() == S_OK || rtStart < 0 || !(transform_out.unk1&1))
+ 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)))
+ || FAILED(hr = pOut->GetPointer(&pDataOut))) {
return hr;
+ }
BYTE* pI420[3] = {m_pI420, m_pI420Tmp, NULL};
- if(interlaced)
- {
+ 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);
@@ -1702,12 +1757,12 @@ HRESULT CRealVideoDecoder::Transform(IMediaSample* pIn)
pI420[2] = pI420[1], pI420[1] = pI420[0], pI420[0] = pI420[2];
}
- if(transform_out.w != m_w || transform_out.h != m_h)
- {
+ 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)
+ 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;
@@ -1719,7 +1774,7 @@ HRESULT CRealVideoDecoder::Transform(IMediaSample* pIn)
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));
+ rtStart, rtStop, pOut->IsDiscontinuity() == S_OK, pOut->IsSyncPoint() == S_OK));
return m_pOutput->Deliver(pOut);
}
@@ -1729,22 +1784,23 @@ void CRealVideoDecoder::Resize(BYTE* pIn, DWORD wi, DWORD hi, BYTE* pOut, DWORD
int si = wi*hi, so = wo*ho;
ASSERT(((si*so)&3) == 0);
- if(wi < wo)
- {
+ 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;
+ 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)
- {
+ } 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;
+ 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);
@@ -1754,23 +1810,23 @@ void CRealVideoDecoder::Resize(BYTE* pIn, DWORD wi, DWORD hi, BYTE* pOut, DWORD
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)
- {
+ if(hi == ho) {
memcpy(pOut, pIn, wo*ho);
- }
- else
- {
- for(DWORD x = 0; x < wo; x++, pIn++, pOut++)
+ } else {
+ for(DWORD x = 0; x < wo; x++, pIn++, pOut++) {
ResizeRow(pIn, hi, wo, pOut, ho, wo);
+ }
}
}
@@ -1778,10 +1834,9 @@ void CRealVideoDecoder::ResizeRow(BYTE* pIn, DWORD wi, DWORD dpi, BYTE* pOut, DW
{
ASSERT(wi < wo);
- if(dpo == 1)
- {
+ 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];
+ // pOut[i] = pIn[j>>16];
{
BYTE* p = &pIn[j>>16];
DWORD jf = j&0xffff;
@@ -1789,11 +1844,9 @@ void CRealVideoDecoder::ResizeRow(BYTE* pIn, DWORD wi, DWORD dpi, BYTE* pOut, DW
}
*pOut = pIn[wi-1];
- }
- else
- {
+ } else {
for(DWORD i = 0, j = 0, dj = (wi<<16)/wo; i < wo-1; i++, pOut += dpo, j += dj)
-// *pOut = pIn[dpi*(j>>16)];
+ // *pOut = pIn[dpi*(j>>16)];
{
BYTE* p = &pIn[dpi*(j>>16)];
DWORD jf = j&0xffff;
@@ -1807,22 +1860,22 @@ void CRealVideoDecoder::ResizeRow(BYTE* pIn, DWORD wi, DWORD dpi, BYTE* pOut, DW
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)
+ || 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)
- {
+ if(mtIn->formattype == FORMAT_VideoInfo2) {
VIDEOINFOHEADER2* vih2 = (VIDEOINFOHEADER2*)mtIn->Format();
if(vih2->dwPictAspectRatioX < vih2->bmiHeader.biWidth
- || vih2->dwPictAspectRatioY < vih2->bmiHeader.biHeight)
+ || vih2->dwPictAspectRatioY < vih2->bmiHeader.biHeight) {
return VFW_E_TYPE_NOT_ACCEPTED;
+ }
}
- if(!m_pInput->IsConnected())
- {
+ if(!m_pInput->IsConnected()) {
if(m_hDrvDll) {
FreeLibrary(m_hDrvDll);
m_hDrvDll = NULL;
@@ -1833,65 +1886,88 @@ HRESULT CRealVideoDecoder::CheckInputType(const CMediaType* mtIn)
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");
+ 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)
- {
+ && ERROR_SUCCESS == key.QueryStringValue(NULL, buff, &len) && _tcslen(buff) > 0) {
oldpath = buff;
TCHAR c = oldpath[oldpath.GetLength()-1];
- if(c != '\\' && c != '/') oldpath += '\\';
+ 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)
- {
+ && ERROR_SUCCESS == key.QueryStringValue(NULL, buff, &len) && _tcslen(buff) > 0) {
newpath = buff;
TCHAR c = newpath[newpath.GetLength()-1];
- if(c != '\\' && c != '/') newpath += '\\';
+ if(c != '\\' && c != '/') {
+ newpath += '\\';
+ }
key.Close();
}
- if(!newpath.IsEmpty()) paths.AddTail(newpath + newdll);
- if(!oldpath.IsEmpty()) paths.AddTail(oldpath + newdll);
+ 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);
+ 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));
+ if (pos) {
+ m_hDrvDll = LoadLibrary(paths.GetNext(pos));
+ }
} while(pos && !m_hDrvDll);
- if(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(!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)
+ || !RVFree || !RVHiveMessage
+ || !RVInit || !RVTransform) {
return VFW_E_TYPE_NOT_ACCEPTED;
+ }
- if(FAILED(InitRV(mtIn)))
+ if(FAILED(InitRV(mtIn))) {
return VFW_E_TYPE_NOT_ACCEPTED;
+ }
}
return S_OK;
@@ -1899,12 +1975,12 @@ HRESULT CRealVideoDecoder::CheckInputType(const CMediaType* mtIn)
HRESULT CRealVideoDecoder::CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut)
{
- if(m_pOutput && m_pOutput->IsConnected())
- {
+ if(m_pOutput && m_pOutput->IsConnected()) {
BITMAPINFOHEADER bih1, bih2;
if(ExtractBIH(mtOut, &bih1) && ExtractBIH(&m_pOutput->CurrentMediaType(), &bih2)
- && abs(bih1.biHeight) != abs(bih2.biHeight))
+ && abs(bih1.biHeight) != abs(bih2.biHeight)) {
return VFW_E_TYPE_NOT_ACCEPTED;
+ }
}
return __super::CheckTransform(mtIn, mtOut);
@@ -1913,8 +1989,9 @@ HRESULT CRealVideoDecoder::CheckTransform(const CMediaType* mtIn, const CMediaTy
HRESULT CRealVideoDecoder::StartStreaming()
{
const CMediaType& mt = m_pInput->CurrentMediaType();
- if(FAILED(InitRV(&mt)))
+ if(FAILED(InitRV(&mt))) {
return E_FAIL;
+ }
int size = m_w*m_h;
m_lastBuffSizeDim = size;
@@ -1954,9 +2031,13 @@ HRESULT CRealVideoDecoder::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tSto
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);
+ 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;
}
@@ -1971,13 +2052,17 @@ CRealAudioDecoder::CRealAudioDecoder(LPUNKNOWN lpunk, HRESULT* phr)
, 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)
@@ -1987,8 +2072,9 @@ HRESULT CRealAudioDecoder::InitRA(const CMediaType* pmt)
HRESULT hr;
if(RAOpenCodec2 && FAILED(hr = RAOpenCodec2(&m_dwCookie, m_dllpath))
- || RAOpenCodec && FAILED(hr = RAOpenCodec(&m_dwCookie)))
+ || RAOpenCodec && FAILED(hr = RAOpenCodec(&m_dwCookie))) {
return VFW_E_TYPE_NOT_ACCEPTED;
+ }
WAVEFORMATEX* pwfe = (WAVEFORMATEX*)pmt->Format();
@@ -2002,7 +2088,9 @@ HRESULT CRealAudioDecoder::InitRA(const CMediaType* pmt)
}
WORD wBitsPerSample = pwfe->wBitsPerSample;
- if(!wBitsPerSample) wBitsPerSample = 16;
+ if(!wBitsPerSample) {
+ wBitsPerSample = 16;
+ }
#pragma pack(push, 1)
struct {
@@ -2010,33 +2098,31 @@ HRESULT CRealAudioDecoder::InitRA(const CMediaType* pmt)
WORD bpsample, channels, quality;
DWORD bpframe, packetsize, extralen;
void* extra;
- } initdata =
- { pwfe->nSamplesPerSec, wBitsPerSample, pwfe->nChannels, 100,
+ } initdata = {
+ pwfe->nSamplesPerSec, wBitsPerSample, pwfe->nChannels, 100,
0, 0, 0, NULL
};
#pragma pack(pop)
CAutoVectorPtr<BYTE> pBuff;
- if(pmt->subtype == MEDIASUBTYPE_AAC)
- {
+ 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
+ } 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')
+ 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;
@@ -2044,26 +2130,23 @@ HRESULT CRealAudioDecoder::InitRA(const CMediaType* pmt)
BYTE* p;
- if(m_rai.version2 == 4)
- {
+ 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)
- {
+ } else if(m_rai.version2 == 5) {
p = (BYTE*)((rainfo5*)fmt+1);
- }
- else
- {
+ } else {
return VFW_E_TYPE_NOT_ACCEPTED;
}
p += 3;
- if(m_rai.version2 == 5) p++;
+ if(m_rai.version2 == 5) {
+ p++;
+ }
initdata.bpframe = m_rai.sub_packet_size;
initdata.packetsize = m_rai.coded_frame_size;
@@ -2071,22 +2154,24 @@ HRESULT CRealAudioDecoder::InitRA(const CMediaType* pmt)
initdata.extra = p + 4;
}
- if(FAILED(hr = RAInitDecoder(m_dwCookie, &initdata)))
+ if(FAILED(hr = RAInitDecoder(m_dwCookie, &initdata))) {
return VFW_E_TYPE_NOT_ACCEPTED;
+ }
- if(RASetPwd)
+ if(RASetPwd) {
RASetPwd(m_dwCookie, "Ardubancel Quazanga");
+ }
- if(RASetFlavor && FAILED(hr = RASetFlavor(m_dwCookie, m_rai.flavor)))
+ 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)
- {
+ if(m_dwCookie) {
RAFreeDecoder(m_dwCookie);
RACloseCodec(m_dwCookie);
m_dwCookie = 0;
@@ -2100,26 +2185,30 @@ HRESULT CRealAudioDecoder::Receive(IMediaSample* pIn)
HRESULT hr;
AM_SAMPLE2_PROPERTIES* const pProps = m_pInput->SampleProps();
- if(pProps->dwStreamId != AM_STREAM_MEDIA)
+ if(pProps->dwStreamId != AM_STREAM_MEDIA) {
return m_pOutput->Deliver(pIn);
+ }
BYTE* pDataIn = NULL;
- if(FAILED(hr = pIn->GetPointer(&pDataIn))) return hr;
+ if(FAILED(hr = pIn->GetPointer(&pDataIn))) {
+ return hr;
+ }
BYTE* pDataInOrg = pDataIn;
UNUSED_ALWAYS(pDataInOrg);
long len = pIn->GetActualDataLength();
- if(len <= 0) return S_OK;
+ 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(pIn->IsPreroll() == S_OK || rtStart < 0)
+ return S_OK;
+ */
- if(S_OK == pIn->IsSyncPoint())
- {
+ if(S_OK == pIn->IsSyncPoint()) {
m_bufflen = 0;
m_rtBuffStart = rtStart;
m_fBuffDiscontinuity = pIn->IsDiscontinuity() == S_OK;
@@ -2134,21 +2223,17 @@ HRESULT CRealAudioDecoder::Receive(IMediaSample* pIn)
if(m_pInput->CurrentMediaType().subtype == MEDIASUBTYPE_RAAC
|| m_pInput->CurrentMediaType().subtype == MEDIASUBTYPE_RACP
- || m_pInput->CurrentMediaType().subtype == MEDIASUBTYPE_AAC)
- {
+ || m_pInput->CurrentMediaType().subtype == MEDIASUBTYPE_AAC) {
src = pDataIn;
dst = pDataIn + len;
w = len;
- }
- else
- {
+ } else {
memcpy(&m_buff[m_bufflen], pDataIn, len);
m_bufflen += len;
len = w*h;
- if(m_bufflen >= len)
- {
+ if(m_bufflen >= len) {
ASSERT(m_bufflen == len);
src = m_buff;
@@ -2156,12 +2241,9 @@ HRESULT CRealAudioDecoder::Receive(IMediaSample* pIn)
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++)
- {
+ || 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;
@@ -2170,9 +2252,7 @@ HRESULT CRealAudioDecoder::Receive(IMediaSample* pIn)
src = m_buff + len;
dst = m_buff + len*2;
- }
- else if(m_pInput->CurrentMediaType().subtype == MEDIASUBTYPE_SIPR)
- {
+ } 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]= {
@@ -2191,10 +2271,16 @@ HRESULT CRealAudioDecoder::Receive(IMediaSample* pIn)
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;
+ 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;
}
@@ -2207,17 +2293,16 @@ HRESULT CRealAudioDecoder::Receive(IMediaSample* pIn)
rtStart = m_rtBuffStart;
- for(; src < dst; src += w)
- {
+ 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)))
+ || FAILED(hr = pOut->GetPointer(&pDataOut))) {
return hr;
+ }
AM_MEDIA_TYPE* pmt;
- if(SUCCEEDED(pOut->GetMediaType(&pmt)) && pmt)
- {
+ if(SUCCEEDED(pOut->GetMediaType(&pmt)) && pmt) {
CMediaType mt(*pmt);
m_pOutput->SetMediaType(&mt);
DeleteMediaType(pmt);
@@ -2225,11 +2310,10 @@ HRESULT CRealAudioDecoder::Receive(IMediaSample* pIn)
hr = RADecode(m_dwCookie, src, w, pDataOut, &len, -1);
- if(FAILED(hr))
- {
+ if(FAILED(hr)) {
TRACE(_T("RA returned an error code!!!\n"));
continue;
-// return hr;
+ // return hr;
}
WAVEFORMATEX* pwfe = (WAVEFORMATEX*)m_pOutput->CurrentMediaType().Format();
@@ -2247,8 +2331,9 @@ HRESULT CRealAudioDecoder::Receive(IMediaSample* pIn)
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)))
+ if(rtStart >= 0 && S_OK != (hr = m_pOutput->Deliver(pOut))) {
return hr;
+ }
rtStart = rtStop;
}
@@ -2269,11 +2354,11 @@ HRESULT CRealAudioDecoder::CheckInputType(const CMediaType* mtIn)
&& mtIn->subtype != MEDIASUBTYPE_SIPR
&& mtIn->subtype != MEDIASUBTYPE_RAAC
&& mtIn->subtype != MEDIASUBTYPE_RACP
- && mtIn->subtype != MEDIASUBTYPE_AAC)
+ && mtIn->subtype != MEDIASUBTYPE_AAC) {
return VFW_E_TYPE_NOT_ACCEPTED;
+ }
- if(!m_pInput->IsConnected())
- {
+ if(!m_pInput->IsConnected()) {
if(m_hDrvDll) {
FreeLibrary(m_hDrvDll);
m_hDrvDll = NULL;
@@ -2282,8 +2367,7 @@ HRESULT CRealAudioDecoder::CheckInputType(const CMediaType* mtIn)
CAtlList<CString> paths;
CString olddll, newdll, oldpath, newpath;
- TCHAR fourcc[5] =
- {
+ TCHAR fourcc[5] = {
(TCHAR)((mtIn->subtype.Data1>>0)&0xff),
(TCHAR)((mtIn->subtype.Data1>>8)&0xff),
(TCHAR)((mtIn->subtype.Data1>>16)&0xff),
@@ -2291,8 +2375,9 @@ HRESULT CRealAudioDecoder::CheckInputType(const CMediaType* mtIn)
0
};
- if(!_tcscmp(_T("RACP"), fourcc) || !_tcscmp(_T("\xff"), fourcc))
+ if(!_tcscmp(_T("RACP"), fourcc) || !_tcscmp(_T("\xff"), fourcc)) {
_tcscpy(fourcc, _T("RAAC"));
+ }
olddll.Format(_T("%s3260.dll"), fourcc);
newdll.Format(_T("%s.dll"), fourcc);
@@ -2301,37 +2386,48 @@ HRESULT CRealAudioDecoder::CheckInputType(const CMediaType* mtIn)
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)
- {
+ && ERROR_SUCCESS == key.QueryStringValue(NULL, buff, &len) && _tcslen(buff) > 0) {
oldpath = buff;
TCHAR c = oldpath[oldpath.GetLength()-1];
- if(c != '\\' && c != '/') oldpath += '\\';
+ 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)
- {
+ && ERROR_SUCCESS == key.QueryStringValue(NULL, buff, &len) && _tcslen(buff) > 0) {
newpath = buff;
TCHAR c = newpath[newpath.GetLength()-1];
- if(c != '\\' && c != '/') newpath += '\\';
+ if(c != '\\' && c != '/') {
+ newpath += '\\';
+ }
key.Close();
}
- if(!newpath.IsEmpty()) paths.AddTail(newpath + newdll);
- if(!oldpath.IsEmpty()) paths.AddTail(oldpath + newdll);
+ 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);
+ 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));
+ if (pos) {
+ m_hDrvDll = LoadLibrary(paths.GetNext(pos));
+ }
} while(pos && !m_hDrvDll);
- if(m_hDrvDll)
- {
+ if(m_hDrvDll) {
RACloseCodec = (PCloseCodec)GetProcAddress(m_hDrvDll, "RACloseCodec");
RADecode = (PDecode)GetProcAddress(m_hDrvDll, "RADecode");
RAFlush = (PFlush)GetProcAddress(m_hDrvDll, "RAFlush");
@@ -2347,23 +2443,25 @@ HRESULT CRealAudioDecoder::CheckInputType(const CMediaType* mtIn)
if(!m_hDrvDll || !RACloseCodec || !RADecode /*|| !RAFlush*/
|| !RAFreeDecoder || !RAGetFlavorProperty || !RAInitDecoder
- || !(RAOpenCodec || RAOpenCodec2) /*|| !RASetFlavor*/)
+ || !(RAOpenCodec || RAOpenCodec2) /*|| !RASetFlavor*/) {
return VFW_E_TYPE_NOT_ACCEPTED;
+ }
- if(m_hDrvDll)
- {
+ 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)
+ if(RASetDLLAccessPath) {
RASetDLLAccessPath("DT_Codecs=" + m_dllpath);
+ }
}
- if(FAILED(InitRA(mtIn)))
+ if(FAILED(InitRA(mtIn))) {
return VFW_E_TYPE_NOT_ACCEPTED;
+ }
}
return S_OK;
@@ -2387,16 +2485,22 @@ HRESULT CRealAudioDecoder::CheckTransform(const CMediaType* mtIn, const CMediaTy
HRESULT CRealAudioDecoder::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;
+ if(!pAllocatorIn) {
+ return E_UNEXPECTED;
+ }
WAVEFORMATEX* pwfe = (WAVEFORMATEX*)m_pOutput->CurrentMediaType().Format();
WORD wBitsPerSample = pwfe->wBitsPerSample;
- if(!wBitsPerSample) wBitsPerSample = 16;
+ if(!wBitsPerSample) {
+ wBitsPerSample = 16;
+ }
// ok, maybe this is too much...
pProperties->cBuffers = 8;
@@ -2406,8 +2510,9 @@ HRESULT CRealAudioDecoder::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR
HRESULT hr;
ALLOCATOR_PROPERTIES Actual;
- if(FAILED(hr = pAllocator->SetProperties(pProperties, &Actual)))
+ if(FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
return hr;
+ }
return(pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer
? E_FAIL
@@ -2416,26 +2521,32 @@ HRESULT CRealAudioDecoder::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR
HRESULT CRealAudioDecoder::GetMediaType(int iPosition, CMediaType* pmt)
{
- if(m_pInput->IsConnected() == FALSE) return E_UNEXPECTED;
+ 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(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;
+ 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[] =
- {
+ if(iPosition == 0 && pwfe->nChannels > 2 && pwfe->nChannels <= 6) {
+ static DWORD chmask[] = {
KSAUDIO_SPEAKER_DIRECTOUT,
KSAUDIO_SPEAKER_MONO,
KSAUDIO_SPEAKER_STEREO,
diff --git a/src/filters/parser/RealMediaSplitter/RealMediaSplitter.h b/src/filters/parser/RealMediaSplitter/RealMediaSplitter.h
index b97121801..89f2e0b59 100644
--- a/src/filters/parser/RealMediaSplitter/RealMediaSplitter.h
+++ b/src/filters/parser/RealMediaSplitter/RealMediaSplitter.h
@@ -30,64 +30,60 @@
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
-{
+struct rvinfo {
DWORD dwSize, fcc1, fcc2;
WORD w, h, bpp;
DWORD unk1, fps, type1, type2;
@@ -95,8 +91,7 @@ struct rvinfo
void bswap();
};
-struct rainfo
-{
+struct rainfo {
DWORD fourcc1; // '.', 'r', 'a', 0xfd
WORD version1; // 4 or 5
WORD unknown1; // 00 000
@@ -116,8 +111,7 @@ struct rainfo
void bswap();
};
-struct rainfo4 : rainfo
-{
+struct rainfo4 : rainfo {
WORD sample_rate;
WORD unknown8; // 0
WORD sample_size;
@@ -125,8 +119,7 @@ struct rainfo4 : rainfo
void bswap();
};
-struct rainfo5 : rainfo
-{
+struct rainfo5 : rainfo {
BYTE unknown7[6]; // 0, srate, 0
WORD sample_rate;
WORD unknown8; // 0
@@ -181,8 +174,7 @@ private:
public:
REFERENCE_TIME rtStart;
bool fDiscontinuity, fSyncPoint, fMerged;
- void Clear()
- {
+ void Clear() {
CAutoLock cAutoLock(this);
rtStart = 0;
fDiscontinuity = fSyncPoint = fMerged = false;
diff --git a/src/filters/parser/RoQSplitter/RoQSplitter.cpp b/src/filters/parser/RoQSplitter/RoQSplitter.cpp
index 71c7c4e8d..d87c8a3d6 100644
--- a/src/filters/parser/RoQSplitter/RoQSplitter.cpp
+++ b/src/filters/parser/RoQSplitter/RoQSplitter.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -26,64 +26,54 @@
#ifdef REGISTER_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
{&MEDIATYPE_Stream, &MEDIASUBTYPE_RoQ},
{&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}
+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}
};
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn2[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn2[] = {
{&MEDIATYPE_Video, &MEDIASUBTYPE_RoQV},
};
-const AMOVIESETUP_MEDIATYPE sudPinTypesOut2[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesOut2[] = {
{&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}
+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}
};
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn3[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn3[] = {
{&MEDIATYPE_Audio, &MEDIASUBTYPE_RoQA},
};
-const AMOVIESETUP_MEDIATYPE sudPinTypesOut3[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesOut3[] = {
{&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}
+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}
};
-const AMOVIESETUP_FILTER sudFilter[] =
-{
+const AMOVIESETUP_FILTER sudFilter[] = {
{&__uuidof(CRoQSplitterFilter), L"MPC - RoQ Splitter", MERIT_NORMAL+1, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
{&__uuidof(CRoQSourceFilter), L"MPC - RoQ Source", MERIT_NORMAL+1, 0, NULL, CLSID_LegacyAmFilterCategory},
{&__uuidof(CRoQVideoDecoder), L"MPC - RoQ Video Decoder", MERIT_NORMAL, countof(sudpPins2), sudpPins2, CLSID_LegacyAmFilterCategory},
{&__uuidof(CRoQAudioDecoder), L"MPC - RoQ Audio Decoder", MERIT_NORMAL, countof(sudpPins3), sudpPins3, CLSID_LegacyAmFilterCategory},
};
-CFactoryTemplate g_Templates[] =
-{
+CFactoryTemplate g_Templates[] = {
{sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CRoQSplitterFilter>, NULL, &sudFilter[0]},
{sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CRoQSourceFilter>, NULL, &sudFilter[1]},
- {sudFilter[2].strName, sudFilter[2].clsID, CreateInstance<CRoQVideoDecoder>, NULL, &sudFilter[2]},
- {sudFilter[3].strName, sudFilter[3].clsID, CreateInstance<CRoQAudioDecoder>, NULL, &sudFilter[3]},
+ {sudFilter[2].strName, sudFilter[2].clsID, CreateInstance<CRoQVideoDecoder>, NULL, &sudFilter[2]},
+ {sudFilter[3].strName, sudFilter[3].clsID, CreateInstance<CRoQAudioDecoder>, NULL, &sudFilter[3]},
};
int g_cTemplates = countof(g_Templates);
@@ -127,7 +117,9 @@ HRESULT CRoQSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
UINT64 hdr = 0, hdrchk = 0x001effffffff1084;
m_pAsyncReader->SyncRead(0, 8, (BYTE*)&hdr);
- if(hdr != hdrchk) return E_FAIL;
+ if(hdr != hdrchk) {
+ return E_FAIL;
+ }
//
@@ -152,19 +144,15 @@ HRESULT CRoQSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
UINT64 pos = 8;
- while(S_OK == m_pAsyncReader->SyncRead(pos, sizeof(rc), (BYTE*)&rc))
- {
+ while(S_OK == m_pAsyncReader->SyncRead(pos, sizeof(rc), (BYTE*)&rc)) {
pos += sizeof(rc);
- if(rc.id == 0x1001)
- {
- if(S_OK != m_pAsyncReader->SyncRead(pos, sizeof(ri), (BYTE*)&ri) || ri.w == 0 || ri.h == 0)
+ if(rc.id == 0x1001) {
+ if(S_OK != m_pAsyncReader->SyncRead(pos, sizeof(ri), (BYTE*)&ri) || ri.w == 0 || ri.h == 0) {
break;
- }
- else if(rc.id == 0x1002 || rc.id == 0x1011)
- {
- if(!iHasVideo && ri.w > 0 && ri.h > 0)
- {
+ }
+ } else if(rc.id == 0x1002 || rc.id == 0x1011) {
+ if(!iHasVideo && ri.w > 0 && ri.h > 0) {
mts.RemoveAll();
mt.InitMediaType();
@@ -187,8 +175,7 @@ HRESULT CRoQSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
AddOutputPin(0, pPinOut);
}
- if(rc.id == 0x1002)
- {
+ if(rc.id == 0x1002) {
iHasVideo++;
index i;
@@ -197,11 +184,8 @@ HRESULT CRoQSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
i.fp = pos - sizeof(rc);
m_index.AddTail(i);
}
- }
- else if(rc.id == 0x1020 || rc.id == 0x1021)
- {
- if(!iHasAudio)
- {
+ } else if(rc.id == 0x1020 || rc.id == 0x1021) {
+ if(!iHasAudio) {
mts.RemoveAll();
mt.InitMediaType();
@@ -247,20 +231,21 @@ bool CRoQSplitterFilter::DemuxInit()
void CRoQSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
{
- if(rt <= 0)
- {
+ if(rt <= 0) {
m_indexpos = m_index.GetHeadPosition();
- }
- else
- {
+ } else {
m_indexpos = m_index.GetTailPosition();
- while(m_indexpos && m_index.GetPrev(m_indexpos).rtv > rt);
+ while(m_indexpos && m_index.GetPrev(m_indexpos).rtv > rt) {
+ ;
+ }
}
}
bool CRoQSplitterFilter::DemuxLoop()
{
- if(!m_indexpos) return(true);
+ if(!m_indexpos) {
+ return(true);
+ }
index& i = m_index.GetAt(m_indexpos);
@@ -272,30 +257,26 @@ bool CRoQSplitterFilter::DemuxLoop()
roq_chunk rc;
while(S_OK == (hr = m_pAsyncReader->SyncRead(pos, sizeof(rc), (BYTE*)&rc))
- && !CheckRequest(NULL))
- {
+ && !CheckRequest(NULL)) {
pos += sizeof(rc);
CAutoPtr<Packet> p(DNew Packet());
- if(rc.id == 0x1002 || rc.id == 0x1011 || rc.id == 0x1020 || rc.id == 0x1021)
- {
+ if(rc.id == 0x1002 || rc.id == 0x1011 || rc.id == 0x1020 || rc.id == 0x1021) {
p->SetCount(sizeof(rc) + rc.size);
memcpy(p->GetData(), &rc, sizeof(rc));
- if(S_OK != (hr = m_pAsyncReader->SyncRead(pos, rc.size, p->GetData() + sizeof(rc))))
+ if(S_OK != (hr = m_pAsyncReader->SyncRead(pos, rc.size, p->GetData() + sizeof(rc)))) {
break;
+ }
}
- if(rc.id == 0x1002 || rc.id == 0x1011)
- {
+ if(rc.id == 0x1002 || rc.id == 0x1011) {
p->TrackNumber = 0;
p->bSyncPoint = rtVideo == 0;
p->rtStart = rtVideo;
p->rtStop = rtVideo += (rc.id == 0x1011 ? 10000000i64/30 : 0);
TRACE(_T("v: %I64d - %I64d (%d)\n"), p->rtStart/10000, p->rtStop/10000, p->GetCount());
- }
- else if(rc.id == 0x1020 || rc.id == 0x1021)
- {
+ } else if(rc.id == 0x1020 || rc.id == 0x1021) {
int nChannels = (rc.id&1)+1;
p->TrackNumber = 1;
@@ -305,8 +286,7 @@ bool CRoQSplitterFilter::DemuxLoop()
TRACE(_T("a: %I64d - %I64d (%d)\n"), p->rtStart/10000, p->rtStop/10000, p->GetCount());
}
- if(rc.id == 0x1002 || rc.id == 0x1011 || rc.id == 0x1020 || rc.id == 0x1021)
- {
+ if(rc.id == 0x1002 || rc.id == 0x1011 || rc.id == 0x1020 || rc.id == 0x1021) {
hr = DeliverPacket(p);
}
@@ -334,7 +314,9 @@ CRoQSourceFilter::CRoQSourceFilter(LPUNKNOWN pUnk, HRESULT* phr)
CRoQVideoDecoder::CRoQVideoDecoder(LPUNKNOWN lpunk, HRESULT* phr)
: CTransformFilter(NAME("CRoQVideoDecoder"), lpunk, __uuidof(this))
{
- if(phr) *phr = S_OK;
+ if(phr) {
+ *phr = S_OK;
+ }
}
CRoQVideoDecoder::~CRoQVideoDecoder()
@@ -366,9 +348,13 @@ void CRoQVideoDecoder::apply_vector_4x4(int x, int y, roq_cell* cell)
row_inc = m_pitch - 4;
c_row_inc = (m_pitch/2) - 2;
- *yptr++ = y0 = cell->y0; *uptr++ = u = cell->u; *vptr++ = v = cell->v;
+ *yptr++ = y0 = cell->y0;
+ *uptr++ = u = cell->u;
+ *vptr++ = v = cell->v;
*yptr++ = y0;
- *yptr++ = y1 = cell->y1; *uptr++ = u; *vptr++ = v;
+ *yptr++ = y1 = cell->y1;
+ *uptr++ = u;
+ *vptr++ = v;
*yptr++ = y1;
yptr += row_inc;
@@ -378,11 +364,17 @@ void CRoQVideoDecoder::apply_vector_4x4(int x, int y, roq_cell* cell)
*yptr++ = y1;
*yptr++ = y1;
- yptr += row_inc; uptr += c_row_inc; vptr += c_row_inc;
+ yptr += row_inc;
+ uptr += c_row_inc;
+ vptr += c_row_inc;
- *yptr++ = y0 = cell->y2; *uptr++ = u; *vptr++ = v;
+ *yptr++ = y0 = cell->y2;
+ *uptr++ = u;
+ *vptr++ = v;
*yptr++ = y0;
- *yptr++ = y1 = cell->y3; *uptr++ = u; *vptr++ = v;
+ *yptr++ = y1 = cell->y3;
+ *uptr++ = u;
+ *vptr++ = v;
*yptr++ = y1;
yptr += row_inc;
@@ -403,8 +395,7 @@ void CRoQVideoDecoder::apply_motion_4x4(int x, int y, unsigned char mv, char mea
pa = m_y[0] + (y * m_pitch) + x;
pb = m_y[1] + (my * m_pitch) + mx;
- for(i = 0; i < 4; i++)
- {
+ for(i = 0; i < 4; i++) {
pa[0] = pb[0];
pa[1] = pb[1];
pa[2] = pb[2];
@@ -415,8 +406,7 @@ void CRoQVideoDecoder::apply_motion_4x4(int x, int y, unsigned char mv, char mea
pa = m_u[0] + (y/2) * (m_pitch/2) + x/2;
pb = m_u[1] + (my/2) * (m_pitch/2) + (mx + 1)/2;
- for(i = 0; i < 2; i++)
- {
+ for(i = 0; i < 2; i++) {
pa[0] = pb[0];
pa[1] = pb[1];
pa += m_pitch/2;
@@ -425,8 +415,7 @@ void CRoQVideoDecoder::apply_motion_4x4(int x, int y, unsigned char mv, char mea
pa = m_v[0] + (y/2) * (m_pitch/2) + x/2;
pb = m_v[1] + (my/2) * (m_pitch/2) + (mx + 1)/2;
- for(i = 0; i < 2; i++)
- {
+ for(i = 0; i < 2; i++) {
pa[0] = pb[0];
pa[1] = pb[1];
pa += m_pitch/2;
@@ -444,8 +433,7 @@ void CRoQVideoDecoder::apply_motion_8x8(int x, int y, unsigned char mv, char mea
pa = m_y[0] + (y * m_pitch) + x;
pb = m_y[1] + (my * m_pitch) + mx;
- for(i = 0; i < 8; i++)
- {
+ for(i = 0; i < 8; i++) {
pa[0] = pb[0];
pa[1] = pb[1];
pa[2] = pb[2];
@@ -460,8 +448,7 @@ void CRoQVideoDecoder::apply_motion_8x8(int x, int y, unsigned char mv, char mea
pa = m_u[0] + (y/2) * (m_pitch/2) + x/2;
pb = m_u[1] + (my/2) * (m_pitch/2) + (mx + 1)/2;
- for(i = 0; i < 4; i++)
- {
+ for(i = 0; i < 4; i++) {
pa[0] = pb[0];
pa[1] = pb[1];
pa[2] = pb[2];
@@ -472,8 +459,7 @@ void CRoQVideoDecoder::apply_motion_8x8(int x, int y, unsigned char mv, char mea
pa = m_v[0] + (y/2) * (m_pitch/2) + x/2;
pb = m_v[1] + (my/2) * (m_pitch/2) + (mx + 1)/2;
- for(i = 0; i < 4; i++)
- {
+ for(i = 0; i < 4; i++) {
pa[0] = pb[0];
pa[1] = pb[1];
pa[2] = pb[2];
@@ -509,28 +495,33 @@ HRESULT CRoQVideoDecoder::Transform(IMediaSample* pIn, IMediaSample* pOut)
HRESULT hr;
AM_MEDIA_TYPE* pmt;
- if(SUCCEEDED(pOut->GetMediaType(&pmt)) && pmt)
- {
+ if(SUCCEEDED(pOut->GetMediaType(&pmt)) && pmt) {
CMediaType mt(*pmt);
m_pOutput->SetMediaType(&mt);
DeleteMediaType(pmt);
}
BYTE* pDataIn = NULL;
- if(FAILED(hr = pIn->GetPointer(&pDataIn))) return hr;
+ if(FAILED(hr = pIn->GetPointer(&pDataIn))) {
+ return hr;
+ }
long len = pIn->GetActualDataLength();
- if(len <= 0) return S_OK; // nothing to do
+ if(len <= 0) {
+ return S_OK; // nothing to do
+ }
REFERENCE_TIME rtStart = 0, rtStop = 0;
pIn->GetTime(&rtStart, &rtStop);
- if(pIn->IsPreroll() == S_OK || rtStart < 0)
+ if(pIn->IsPreroll() == S_OK || rtStart < 0) {
return S_OK;
+ }
BYTE* pDataOut = NULL;
- if(FAILED(hr = pOut->GetPointer(&pDataOut)))
+ if(FAILED(hr = pOut->GetPointer(&pDataOut))) {
return hr;
+ }
BITMAPINFOHEADER bih;
ExtractBIH(&m_pInput->CurrentMediaType(), &bih);
@@ -543,39 +534,37 @@ HRESULT CRoQVideoDecoder::Transform(IMediaSample* pIn, IMediaSample* pOut)
pDataIn += sizeof(roq_chunk);
- if(rc->id == 0x1002)
- {
+ if(rc->id == 0x1002) {
DWORD nv1 = rc->arg>>8;
- if(nv1 == 0) nv1 = 256;
+ if(nv1 == 0) {
+ nv1 = 256;
+ }
DWORD nv2 = rc->arg&0xff;
- if(nv2 == 0 && nv1 * 6 < rc->size) nv2 = 256;
+ if(nv2 == 0 && nv1 * 6 < rc->size) {
+ nv2 = 256;
+ }
memcpy(m_cells, pDataIn, sizeof(m_cells[0])*nv1);
pDataIn += sizeof(m_cells[0])*nv1;
for(int i = 0; i < (int)nv2; i++)
- for(int j = 0; j < 4; j++)
+ for(int j = 0; j < 4; j++) {
m_qcells[i].idx[j] = &m_cells[*pDataIn++];
+ }
return S_FALSE;
- }
- else if(rc->id == 0x1011)
- {
+ } else if(rc->id == 0x1011) {
int bpos = 0, xpos = 0, ypos = 0;
int vqflg = 0, vqflg_pos = -1, vqid;
roq_qcell* qcell = NULL;
BYTE* buf = pDataIn;
- while(bpos < (int)rc->size && ypos < h)
- {
- for(int yp = ypos; yp < ypos + 16; yp += 8)
- {
- for(int xp = xpos; xp < xpos + 16; xp += 8)
- {
- if(vqflg_pos < 0)
- {
+ while(bpos < (int)rc->size && ypos < h) {
+ for(int yp = ypos; yp < ypos + 16; yp += 8) {
+ for(int xp = xpos; xp < xpos + 16; xp += 8) {
+ if(vqflg_pos < 0) {
vqflg = buf[bpos++];
vqflg |= buf[bpos++]<<8;
vqflg_pos = 7;
@@ -584,87 +573,92 @@ HRESULT CRoQVideoDecoder::Transform(IMediaSample* pIn, IMediaSample* pOut)
vqid = (vqflg >> (vqflg_pos * 2)) & 3;
vqflg_pos--;
- switch(vqid)
- {
- case 0:
- break;
- case 1:
- apply_motion_8x8(xp, yp, buf[bpos++], rc->arg >> 8, rc->arg & 0xff);
- break;
- case 2:
- qcell = m_qcells + buf[bpos++];
- apply_vector_4x4(xp, yp, qcell->idx[0]);
- apply_vector_4x4(xp+4, yp, qcell->idx[1]);
- apply_vector_4x4(xp, yp+4, qcell->idx[2]);
- apply_vector_4x4(xp+4, yp+4, qcell->idx[3]);
- break;
- case 3:
- for(int k = 0; k < 4; k++)
- {
- int x = xp, y = yp;
- if(k&1) x += 4;
- if(k&2) y += 4;
-
- if(vqflg_pos < 0)
- {
- vqflg = buf[bpos++];
- vqflg |= buf[bpos++]<<8;
- vqflg_pos = 7;
- }
-
- vqid = (vqflg >> (vqflg_pos * 2)) & 3;
- vqflg_pos--;
-
- switch(vqid)
- {
- case 0:
- break;
- case 1:
- apply_motion_4x4(x, y, buf[bpos++], rc->arg >> 8, rc->arg & 0xff);
- break;
- case 2:
- qcell = m_qcells + buf[bpos++];
- apply_vector_2x2(x, y, qcell->idx[0]);
- apply_vector_2x2(x+2, y, qcell->idx[1]);
- apply_vector_2x2(x, y+2, qcell->idx[2]);
- apply_vector_2x2(x+2, y+2, qcell->idx[3]);
- break;
- case 3:
- apply_vector_2x2(x, y, &m_cells[buf[bpos++]]);
- apply_vector_2x2(x+2, y, &m_cells[buf[bpos++]]);
- apply_vector_2x2(x, y+2, &m_cells[buf[bpos++]]);
- apply_vector_2x2(x+2, y+2, &m_cells[buf[bpos++]]);
- break;
+ switch(vqid) {
+ case 0:
+ break;
+ case 1:
+ apply_motion_8x8(xp, yp, buf[bpos++], rc->arg >> 8, rc->arg & 0xff);
+ break;
+ case 2:
+ qcell = m_qcells + buf[bpos++];
+ apply_vector_4x4(xp, yp, qcell->idx[0]);
+ apply_vector_4x4(xp+4, yp, qcell->idx[1]);
+ apply_vector_4x4(xp, yp+4, qcell->idx[2]);
+ apply_vector_4x4(xp+4, yp+4, qcell->idx[3]);
+ break;
+ case 3:
+ for(int k = 0; k < 4; k++) {
+ int x = xp, y = yp;
+ if(k&1) {
+ x += 4;
+ }
+ if(k&2) {
+ y += 4;
+ }
+
+ if(vqflg_pos < 0) {
+ vqflg = buf[bpos++];
+ vqflg |= buf[bpos++]<<8;
+ vqflg_pos = 7;
+ }
+
+ vqid = (vqflg >> (vqflg_pos * 2)) & 3;
+ vqflg_pos--;
+
+ switch(vqid) {
+ case 0:
+ break;
+ case 1:
+ apply_motion_4x4(x, y, buf[bpos++], rc->arg >> 8, rc->arg & 0xff);
+ break;
+ case 2:
+ qcell = m_qcells + buf[bpos++];
+ apply_vector_2x2(x, y, qcell->idx[0]);
+ apply_vector_2x2(x+2, y, qcell->idx[1]);
+ apply_vector_2x2(x, y+2, qcell->idx[2]);
+ apply_vector_2x2(x+2, y+2, qcell->idx[3]);
+ break;
+ case 3:
+ apply_vector_2x2(x, y, &m_cells[buf[bpos++]]);
+ apply_vector_2x2(x+2, y, &m_cells[buf[bpos++]]);
+ apply_vector_2x2(x, y+2, &m_cells[buf[bpos++]]);
+ apply_vector_2x2(x+2, y+2, &m_cells[buf[bpos++]]);
+ break;
+ }
}
- }
- break;
+ break;
}
}
}
xpos += 16;
- if(xpos >= w) {xpos -= w; ypos += 16;}
+ if(xpos >= w) {
+ xpos -= w;
+ ypos += 16;
+ }
}
- if(m_rtStart+rtStart == 0)
- {
+ if(m_rtStart+rtStart == 0) {
memcpy(m_y[1], m_y[0], w*h*3/2);
- }
- else
- {
+ } else {
BYTE* tmp;
- tmp = m_y[0]; m_y[0] = m_y[1]; m_y[1] = tmp;
- tmp = m_u[0]; m_u[0] = m_u[1]; m_u[1] = tmp;
- tmp = m_v[0]; m_v[0] = m_v[1]; m_v[1] = tmp;
+ tmp = m_y[0];
+ m_y[0] = m_y[1];
+ m_y[1] = tmp;
+ tmp = m_u[0];
+ m_u[0] = m_u[1];
+ m_u[1] = tmp;
+ tmp = m_v[0];
+ m_v[0] = m_v[1];
+ m_v[1] = tmp;
}
- }
- else
- {
+ } else {
return E_UNEXPECTED;
}
- if(rtStart < 0)
+ if(rtStart < 0) {
return S_FALSE;
+ }
Copy(pDataOut, m_y[1], w, h);
@@ -683,32 +677,24 @@ void CRoQVideoDecoder::Copy(BYTE* pOut, BYTE* pIn, DWORD w, DWORD h)
BYTE* pInU = pIn + pitchIn*h;
BYTE* pInV = pInU + pitchInUV*h/2;
- if(bihOut.biCompression == '2YUY')
- {
+ if(bihOut.biCompression == '2YUY') {
BitBltFromI420ToYUY2(w, h, pOut, bihOut.biWidth*2, pIn, pInU, pInV, pitchIn);
- }
- else if(bihOut.biCompression == 'I420' || bihOut.biCompression == 'VUYI')
- {
+ } else if(bihOut.biCompression == 'I420' || bihOut.biCompression == 'VUYI') {
BitBltFromI420ToI420(w, h, pOut, pOut + bihOut.biWidth*h, pOut + bihOut.biWidth*h*5/4, bihOut.biWidth, pIn, pInU, pInV, pitchIn);
- }
- else if(bihOut.biCompression == '21VY')
- {
+ } else if(bihOut.biCompression == '21VY') {
BitBltFromI420ToI420(w, h, pOut, pOut + bihOut.biWidth*h*5/4, pOut + bihOut.biWidth*h, bihOut.biWidth, pIn, pInU, pInV, pitchIn);
- }
- else if(bihOut.biCompression == BI_RGB || bihOut.biCompression == BI_BITFIELDS)
- {
+ } else if(bihOut.biCompression == BI_RGB || bihOut.biCompression == BI_BITFIELDS) {
int pitchOut = bihOut.biWidth*bihOut.biBitCount>>3;
- if(bihOut.biHeight > 0)
- {
+ if(bihOut.biHeight > 0) {
pOut += pitchOut*(h-1);
pitchOut = -pitchOut;
}
- if(!BitBltFromI420ToRGB(w, h, pOut, pitchOut, bihOut.biBitCount, pIn, pInU, pInV, pitchIn))
- {
- for(DWORD y = 0; y < h; y++, pIn += pitchIn, pOut += pitchOut)
+ if(!BitBltFromI420ToRGB(w, h, pOut, pitchOut, bihOut.biBitCount, pIn, pInU, pInV, pitchIn)) {
+ for(DWORD y = 0; y < h; y++, pIn += pitchIn, pOut += pitchOut) {
memset(pOut, 0, pitchOut);
+ }
}
}
}
@@ -716,37 +702,39 @@ void CRoQVideoDecoder::Copy(BYTE* pOut, BYTE* pIn, DWORD w, DWORD h)
HRESULT CRoQVideoDecoder::CheckInputType(const CMediaType* mtIn)
{
return mtIn->majortype == MEDIATYPE_Video && mtIn->subtype == MEDIASUBTYPE_RoQV
- ? S_OK
- : VFW_E_TYPE_NOT_ACCEPTED;
+ ? S_OK
+ : VFW_E_TYPE_NOT_ACCEPTED;
}
HRESULT CRoQVideoDecoder::CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut)
{
- if(m_pOutput && m_pOutput->IsConnected())
- {
+ if(m_pOutput && m_pOutput->IsConnected()) {
BITMAPINFOHEADER bih1, bih2;
if(ExtractBIH(mtOut, &bih1) && ExtractBIH(&m_pOutput->CurrentMediaType(), &bih2)
- && abs(bih1.biHeight) != abs(bih2.biHeight))
+ && abs(bih1.biHeight) != abs(bih2.biHeight)) {
return VFW_E_TYPE_NOT_ACCEPTED;
+ }
}
return SUCCEEDED(CheckInputType(mtIn))
- && mtOut->majortype == MEDIATYPE_Video && (mtOut->subtype == MEDIASUBTYPE_YUY2
- || mtOut->subtype == MEDIASUBTYPE_YV12
- || mtOut->subtype == MEDIASUBTYPE_I420
- || mtOut->subtype == MEDIASUBTYPE_IYUV
- || mtOut->subtype == MEDIASUBTYPE_ARGB32
- || mtOut->subtype == MEDIASUBTYPE_RGB32
- || mtOut->subtype == MEDIASUBTYPE_RGB24
- || mtOut->subtype == MEDIASUBTYPE_RGB565
- || mtOut->subtype == MEDIASUBTYPE_RGB555)
- ? S_OK
- : VFW_E_TYPE_NOT_ACCEPTED;
+ && mtOut->majortype == MEDIATYPE_Video && (mtOut->subtype == MEDIASUBTYPE_YUY2
+ || mtOut->subtype == MEDIASUBTYPE_YV12
+ || mtOut->subtype == MEDIASUBTYPE_I420
+ || mtOut->subtype == MEDIASUBTYPE_IYUV
+ || mtOut->subtype == MEDIASUBTYPE_ARGB32
+ || mtOut->subtype == MEDIASUBTYPE_RGB32
+ || mtOut->subtype == MEDIASUBTYPE_RGB24
+ || mtOut->subtype == MEDIASUBTYPE_RGB565
+ || mtOut->subtype == MEDIASUBTYPE_RGB555)
+ ? S_OK
+ : VFW_E_TYPE_NOT_ACCEPTED;
}
HRESULT CRoQVideoDecoder::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties)
{
- if(m_pInput->IsConnected() == FALSE) return E_UNEXPECTED;
+ if(m_pInput->IsConnected() == FALSE) {
+ return E_UNEXPECTED;
+ }
BITMAPINFOHEADER bih;
ExtractBIH(&m_pOutput->CurrentMediaType(), &bih);
@@ -758,20 +746,26 @@ HRESULT CRoQVideoDecoder::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_
HRESULT hr;
ALLOCATOR_PROPERTIES Actual;
- if(FAILED(hr = pAllocator->SetProperties(pProperties, &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 CRoQVideoDecoder::GetMediaType(int iPosition, CMediaType* pmt)
{
- if(m_pInput->IsConnected() == FALSE) return E_UNEXPECTED;
+ if(m_pInput->IsConnected() == FALSE) {
+ return E_UNEXPECTED;
+ }
- struct {const GUID* subtype; WORD biPlanes, biBitCount; DWORD biCompression;} fmts[] =
- {
+ struct {
+ const GUID* subtype;
+ WORD biPlanes, biBitCount;
+ DWORD biCompression;
+ } fmts[] = {
{&MEDIASUBTYPE_YV12, 3, 12, '21VY'},
{&MEDIASUBTYPE_I420, 3, 12, '024I'},
{&MEDIASUBTYPE_IYUV, 3, 12, 'VUYI'},
@@ -788,8 +782,12 @@ HRESULT CRoQVideoDecoder::GetMediaType(int iPosition, CMediaType* pmt)
{&MEDIASUBTYPE_RGB555, 1, 16, BI_BITFIELDS},
};
- if(iPosition < 0) return E_INVALIDARG;
- if(iPosition >= countof(fmts)) return VFW_S_NO_MORE_ITEMS;
+ if(iPosition < 0) {
+ return E_INVALIDARG;
+ }
+ if(iPosition >= countof(fmts)) {
+ return VFW_S_NO_MORE_ITEMS;
+ }
BITMAPINFOHEADER bih;
ExtractBIH(&m_pInput->CurrentMediaType(), &bih);
@@ -838,8 +836,10 @@ HRESULT CRoQVideoDecoder::StartStreaming()
HRESULT CRoQVideoDecoder::StopStreaming()
{
- delete [] m_y[0]; m_y[0] = NULL;
- delete [] m_y[1]; m_y[1] = NULL;
+ delete [] m_y[0];
+ m_y[0] = NULL;
+ delete [] m_y[1];
+ m_y[1] = NULL;
return __super::StopStreaming();
}
@@ -851,7 +851,9 @@ HRESULT CRoQVideoDecoder::StopStreaming()
CRoQAudioDecoder::CRoQAudioDecoder(LPUNKNOWN lpunk, HRESULT* phr)
: CTransformFilter(NAME("CRoQAudioDecoder"), lpunk, __uuidof(this))
{
- if(phr) *phr = S_OK;
+ if(phr) {
+ *phr = S_OK;
+ }
}
CRoQAudioDecoder::~CRoQAudioDecoder()
@@ -863,8 +865,7 @@ HRESULT CRoQAudioDecoder::Transform(IMediaSample* pIn, IMediaSample* pOut)
HRESULT hr;
AM_MEDIA_TYPE* pmt;
- if(SUCCEEDED(pOut->GetMediaType(&pmt)) && pmt)
- {
+ if(SUCCEEDED(pOut->GetMediaType(&pmt)) && pmt) {
CMediaType mt(*pmt);
m_pOutput->SetMediaType(&mt);
DeleteMediaType(pmt);
@@ -874,68 +875,74 @@ HRESULT CRoQAudioDecoder::Transform(IMediaSample* pIn, IMediaSample* pOut)
UNUSED_ALWAYS(pwfe);
BYTE* pDataIn = NULL;
- if(FAILED(hr = pIn->GetPointer(&pDataIn)))
+ if(FAILED(hr = pIn->GetPointer(&pDataIn))) {
return hr;
+ }
long len = pIn->GetActualDataLength();
- if(len <= 0) return S_OK;
+ if(len <= 0) {
+ return S_OK;
+ }
REFERENCE_TIME rtStart, rtStop;
pIn->GetTime(&rtStart, &rtStop);
- if(pIn->IsPreroll() == S_OK || rtStart < 0)
+ if(pIn->IsPreroll() == S_OK || rtStart < 0) {
return S_OK;
+ }
BYTE* pDataOut = NULL;
- if(FAILED(hr = pOut->GetPointer(&pDataOut)))
+ if(FAILED(hr = pOut->GetPointer(&pDataOut))) {
return hr;
+ }
long size = pOut->GetSize();
- if(size <= 0)
+ if(size <= 0) {
return E_FAIL;
+ }
roq_chunk* rc = (roq_chunk*)pDataIn;
WAVEFORMATEX* wfe = (WAVEFORMATEX*)m_pOutput->CurrentMediaType().Format();
- if(wfe->nChannels == 1)
- {
+ if(wfe->nChannels == 1) {
int mono = (short)rc->arg;
unsigned char* src = pDataIn + sizeof(roq_chunk);
short* dst = (short*)pDataOut;
- for(int i = sizeof(roq_chunk); i < len; i++, src++, dst++)
- {
+ for(int i = sizeof(roq_chunk); i < len; i++, src++, dst++) {
short diff = (*src&0x7f)*(*src&0x7f);
- if(*src&0x80) diff = -diff;
+ if(*src&0x80) {
+ diff = -diff;
+ }
mono += diff;
*dst = (short)mono;
}
- }
- else if(wfe->nChannels == 2)
- {
+ } else if(wfe->nChannels == 2) {
int left = (char)(rc->arg>>8)<<8;
int right = (char)(rc->arg)<<8;
unsigned char* src = pDataIn + sizeof(roq_chunk);
short* dst = (short*)pDataOut;
- for(int i = sizeof(roq_chunk); i < len; i+=2, src++, dst++)
- {
+ for(int i = sizeof(roq_chunk); i < len; i+=2, src++, dst++) {
short diff = (*src&0x7f)*(*src&0x7f);
- if(*src&0x80) diff = -diff;
+ if(*src&0x80) {
+ diff = -diff;
+ }
ASSERT((int)left + diff <= SHRT_MAX && (int)left + diff >= SHRT_MIN);
left += diff;
*dst = (short)left;
- src++; dst++;
+ src++;
+ dst++;
diff = (*src&0x7f)*(*src&0x7f);
- if(*src&0x80) diff = -diff;
+ if(*src&0x80) {
+ diff = -diff;
+ }
ASSERT((int)right + diff <= SHRT_MAX && (int)right + diff >= SHRT_MIN);
right += diff;
*dst = (short)right;
}
- }
- else
- {
+ } else {
return E_UNEXPECTED;
}
@@ -949,25 +956,29 @@ HRESULT CRoQAudioDecoder::Transform(IMediaSample* pIn, IMediaSample* pOut)
HRESULT CRoQAudioDecoder::CheckInputType(const CMediaType* mtIn)
{
return mtIn->majortype == MEDIATYPE_Audio && mtIn->subtype == MEDIASUBTYPE_RoQA
- ? S_OK
- : VFW_E_TYPE_NOT_ACCEPTED;
+ ? S_OK
+ : VFW_E_TYPE_NOT_ACCEPTED;
}
HRESULT CRoQAudioDecoder::CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut)
{
return SUCCEEDED(CheckInputType(mtIn))
- && mtOut->majortype == MEDIATYPE_Audio && mtOut->subtype == MEDIASUBTYPE_PCM
- ? S_OK
- : VFW_E_TYPE_NOT_ACCEPTED;
+ && mtOut->majortype == MEDIATYPE_Audio && mtOut->subtype == MEDIASUBTYPE_PCM
+ ? S_OK
+ : VFW_E_TYPE_NOT_ACCEPTED;
}
HRESULT CRoQAudioDecoder::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;
+ if(!pAllocatorIn) {
+ return E_UNEXPECTED;
+ }
WAVEFORMATEX* wfe = (WAVEFORMATEX*)m_pOutput->CurrentMediaType().Format();
@@ -979,20 +990,27 @@ HRESULT CRoQAudioDecoder::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_
HRESULT hr;
ALLOCATOR_PROPERTIES Actual;
- if(FAILED(hr = pAllocator->SetProperties(pProperties, &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 CRoQAudioDecoder::GetMediaType(int iPosition, CMediaType* pmt)
{
- if(m_pInput->IsConnected() == FALSE) return E_UNEXPECTED;
+ if(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;
+ }
*pmt = m_pInput->CurrentMediaType();
pmt->subtype = MEDIASUBTYPE_PCM;
diff --git a/src/filters/parser/RoQSplitter/RoQSplitter.h b/src/filters/parser/RoQSplitter/RoQSplitter.h
index e8b57a0ae..88e43dfc2 100644
--- a/src/filters/parser/RoQSplitter/RoQSplitter.h
+++ b/src/filters/parser/RoQSplitter/RoQSplitter.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -24,30 +24,39 @@
#include "../BaseSplitter/BaseSplitter.h"
// {48B93619-A959-45d9-B5FD-E12A67A96CF1}
-DEFINE_GUID(MEDIASUBTYPE_RoQ,
-0x48b93619, 0xa959, 0x45d9, 0xb5, 0xfd, 0xe1, 0x2a, 0x67, 0xa9, 0x6c, 0xf1);
+DEFINE_GUID(MEDIASUBTYPE_RoQ,
+ 0x48b93619, 0xa959, 0x45d9, 0xb5, 0xfd, 0xe1, 0x2a, 0x67, 0xa9, 0x6c, 0xf1);
// 56516F52-0000-0010-8000-00AA00389B71 'RoQV' == MEDIASUBTYPE_RoQV
DEFINE_GUID(MEDIASUBTYPE_RoQV,
-0x56516F52, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
+ 0x56516F52, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
#define WAVE_FORMAT_RoQA 0x41516F52
// 41516F52-0000-0010-8000-00AA00389B71 'RoQA' == MEDIASUBTYPE_RoQA
DEFINE_GUID(MEDIASUBTYPE_RoQA,
-WAVE_FORMAT_RoQA, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
+ WAVE_FORMAT_RoQA, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
#pragma pack(push, 1)
-struct roq_chunk {WORD id; DWORD size; WORD arg;};
-struct roq_info {WORD w, h, unk1, unk2;};
+struct roq_chunk {
+ WORD id;
+ DWORD size;
+ WORD arg;
+};
+struct roq_info {
+ WORD w, h, unk1, unk2;
+};
#pragma pack(pop)
class __declspec(uuid("C73DF7C1-21F2-44C7-A430-D35FB9BB298F"))
-CRoQSplitterFilter : public CBaseSplitterFilter
+ CRoQSplitterFilter : public CBaseSplitterFilter
{
CComPtr<IAsyncReader> m_pAsyncReader;
- struct index {REFERENCE_TIME rtv, rta; __int64 fp;};
+ struct index {
+ REFERENCE_TIME rtv, rta;
+ __int64 fp;
+ };
CAtlList<index> m_index;
POSITION m_indexpos;
@@ -63,14 +72,14 @@ public:
};
class __declspec(uuid("02B8E5C2-4E1F-45D3-9A8E-B8F1EDE6DE09"))
-CRoQSourceFilter : public CRoQSplitterFilter
+ CRoQSourceFilter : public CRoQSplitterFilter
{
public:
CRoQSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
};
class __declspec(uuid("FBEFC5EC-ABA0-4E6C-ACA3-D05FDFEFB853"))
-CRoQVideoDecoder : public CTransformFilter
+ CRoQVideoDecoder : public CTransformFilter
{
CCritSec m_csReceive;
@@ -83,10 +92,14 @@ CRoQVideoDecoder : public CTransformFilter
void Copy(BYTE* pOut, BYTE* pIn, DWORD w, DWORD h);
- #pragma pack(push, 1)
- struct roq_cell {BYTE y0, y1, y2, y3, u, v;} m_cells[256];
- struct roq_qcell {roq_cell* idx[4];} m_qcells[256];
- #pragma pack(pop)
+#pragma pack(push, 1)
+ struct roq_cell {
+ BYTE y0, y1, y2, y3, u, v;
+ } m_cells[256];
+ struct roq_qcell {
+ roq_cell* idx[4];
+ } m_qcells[256];
+#pragma pack(pop)
void apply_vector_2x2(int x, int y, roq_cell* cell);
void apply_vector_4x4(int x, int y, roq_cell* cell);
void apply_motion_4x4(int x, int y, unsigned char mv, char mean_x, char mean_y);
@@ -96,7 +109,7 @@ public:
CRoQVideoDecoder(LPUNKNOWN lpunk, HRESULT* phr);
virtual ~CRoQVideoDecoder();
- HRESULT NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
+ HRESULT NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
HRESULT Transform(IMediaSample* pIn, IMediaSample* pOut);
HRESULT CheckInputType(const CMediaType* mtIn);
@@ -109,7 +122,7 @@ public:
};
class __declspec(uuid("226FAF85-E358-4502-8C98-F4224BE76953"))
-CRoQAudioDecoder : public CTransformFilter
+ CRoQAudioDecoder : public CTransformFilter
{
public:
CRoQAudioDecoder(LPUNKNOWN lpunk, HRESULT* phr);
diff --git a/src/filters/parser/RoQSplitter/stdafx.cpp b/src/filters/parser/RoQSplitter/stdafx.cpp
index 13934d005..bea3f980a 100644
--- a/src/filters/parser/RoQSplitter/stdafx.cpp
+++ b/src/filters/parser/RoQSplitter/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/parser/RoQSplitter/stdafx.h b/src/filters/parser/RoQSplitter/stdafx.h
index 0ddde4f7d..bf58d6fb9 100644
--- a/src/filters/parser/RoQSplitter/stdafx.h
+++ b/src/filters/parser/RoQSplitter/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/parser/SSFSplitter/SSFSplitter.cpp b/src/filters/parser/SSFSplitter/SSFSplitter.cpp
index 917e35cc0..e581a8a62 100644
--- a/src/filters/parser/SSFSplitter/SSFSplitter.cpp
+++ b/src/filters/parser/SSFSplitter/SSFSplitter.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -26,26 +26,22 @@
#ifdef REGISTER_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
{&MEDIATYPE_Stream, &MEDIASUBTYPE_SSF},
{&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}
+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}
};
-const AMOVIESETUP_FILTER sudFilter[] =
-{
+const AMOVIESETUP_FILTER sudFilter[] = {
{&__uuidof(CSSFSplitterFilter), L"MPC - SSF Splitter", MERIT_NORMAL, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
{&__uuidof(CSSFSourceFilter), L"MPC - SSF Source", MERIT_NORMAL, 0, NULL, CLSID_LegacyAmFilterCategory},
};
-CFactoryTemplate g_Templates[] =
-{
+CFactoryTemplate g_Templates[] = {
{sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CSSFSplitterFilter>, NULL, &sudFilter[0]},
{sudFilter[1].strName, sudFilter[1].clsID, CreateInstance<CSSFSourceFilter>, NULL, &sudFilter[1]},
};
@@ -79,16 +75,18 @@ namespace ssf
CBaseSplitterFile* m_pFile;
public:
- InputStreamBSF(CBaseSplitterFile* pFile)
- : m_pFile(pFile)
- {
+ InputStreamBSF(CBaseSplitterFile* pFile)
+ : m_pFile(pFile) {
ASSERT(m_pFile);
}
- int InputStreamBSF::NextByte()
- {
- if(!m_pFile) ThrowError(_T("m_pFile is NULL"));
- if(!m_pFile->GetRemaining()) return EOS;
+ int InputStreamBSF::NextByte() {
+ if(!m_pFile) {
+ ThrowError(_T("m_pFile is NULL"));
+ }
+ if(!m_pFile->GetRemaining()) {
+ return EOS;
+ }
return (int)m_pFile->BitRead(8);
}
};
@@ -98,8 +96,12 @@ int CSSFSplitterFilter::SegmentItemEx::Compare(const void* a, const void* b)
{
const SegmentItemEx* si1 = (const SegmentItemEx*)a;
const SegmentItemEx* si2 = (const SegmentItemEx*)b;
- if(si1->start < si2->start) return -1;
- if(si2->start < si1->start) return +1;
+ if(si1->start < si2->start) {
+ return -1;
+ }
+ if(si2->start < si1->start) {
+ return +1;
+ }
return 0;
}
@@ -120,33 +122,36 @@ HRESULT CSSFSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
m_pFile.Free();
m_pFile.Attach(DNew CBaseSplitterFile(pAsyncReader, hr));
- if(!m_pFile) return E_OUTOFMEMORY;
- if(FAILED(hr)) {m_pFile.Free(); return hr;}
+ if(!m_pFile) {
+ return E_OUTOFMEMORY;
+ }
+ if(FAILED(hr)) {
+ m_pFile.Free();
+ return hr;
+ }
+
+ try {
+ m_ssf.Parse(ssf::InputStreamBSF(m_pFile));
+ } catch(ssf::Exception&) {
+ return E_FAIL;
+ }
- try {m_ssf.Parse(ssf::InputStreamBSF(m_pFile));}
- catch(ssf::Exception&) {return E_FAIL;}
-
//
m_rtNewStart = m_rtCurrent = 0;
m_rtNewStop = m_rtStop = m_rtDuration = 0;
- if(ssf::Reference* pRootRef = m_ssf.GetRootRef())
- {
+ if(ssf::Reference* pRootRef = m_ssf.GetRootRef()) {
ssf::WCharOutputStream s;
ssf::StringMapW<float> offset;
POSITION pos = pRootRef->m_nodes.GetHeadPosition();
- while(pos)
- {
- if(ssf::Definition* pDef = dynamic_cast<ssf::Definition*>(pRootRef->m_nodes.GetNext(pos)))
- {
- try
- {
+ while(pos) {
+ if(ssf::Definition* pDef = dynamic_cast<ssf::Definition*>(pRootRef->m_nodes.GetNext(pos))) {
+ try {
ssf::Definition::Time time;
- if(pDef->m_type == L"subtitle" && pDef->GetAsTime(time, offset) && (*pDef)[L"@"].IsValue())
- {
+ if(pDef->m_type == L"subtitle" && pDef->GetAsTime(time, offset) && (*pDef)[L"@"].IsValue()) {
SegmentItemEx si;
si.pDef = pDef;
si.start = time.start.value;
@@ -157,12 +162,10 @@ HRESULT CSSFSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
continue;
}
- }
- catch(ssf::Exception&)
- {
+ } catch(ssf::Exception&) {
}
- pDef->Dump(s);
+ pDef->Dump(s);
}
}
@@ -178,7 +181,9 @@ HRESULT CSSFSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
memset(si, 0, sizeof(*si));
si->dwOffset = sizeof(*si);
BYTE* p = (BYTE*)(si+1);
- p[0] = 0xef; p[1] = 0xbb; p[2] = 0xbf;
+ p[0] = 0xef;
+ p[1] = 0xbb;
+ p[2] = 0xbf;
memcpy(&p[3], (LPCSTR)hdr, hdr.GetLength());
mts.Add(mt);
@@ -188,13 +193,16 @@ HRESULT CSSFSplitterFilter::CreateOutputs(IAsyncReader* pAsyncReader)
CAtlArray<SegmentItemEx> subs;
subs.SetCount(m_subs.GetCount());
pos = m_subs.GetHeadPosition();
- for(size_t i = 0; pos; i++) subs.SetAt(i, m_subs.GetNext(pos));
+ for(size_t i = 0; pos; i++) {
+ subs.SetAt(i, m_subs.GetNext(pos));
+ }
qsort(subs.GetData(), subs.GetCount(), sizeof(SegmentItemEx), SegmentItemEx::Compare);
m_subs.RemoveAll();
- for(size_t i = 0; i < subs.GetCount(); i++) m_subs.AddTail(subs[i]);
+ for(size_t i = 0; i < subs.GetCount(); i++) {
+ m_subs.AddTail(subs[i]);
+ }
- if(!m_ssf.m_segments.IsEmpty())
- {
+ if(!m_ssf.m_segments.IsEmpty()) {
m_rtNewStop = m_rtStop = m_rtDuration = 10000000i64*m_ssf.m_segments.GetTail().m_stop;
}
}
@@ -210,11 +218,8 @@ bool CSSFSplitterFilter::DemuxInit()
void CSSFSplitterFilter::DemuxSeek(REFERENCE_TIME rt)
{
- if(rt <= 0)
- {
- }
- else
- {
+ if(rt <= 0) {
+ } else {
// TODO
}
}
@@ -225,8 +230,7 @@ bool CSSFSplitterFilter::DemuxLoop()
POSITION pos = m_subs.GetHeadPosition();
- while(pos && SUCCEEDED(hr) && !CheckRequest(NULL))
- {
+ while(pos && SUCCEEDED(hr) && !CheckRequest(NULL)) {
SegmentItemEx& si = m_subs.GetNext(pos);
ssf::WCharOutputStream s;
diff --git a/src/filters/parser/SSFSplitter/SSFSplitter.h b/src/filters/parser/SSFSplitter/SSFSplitter.h
index 35f95c507..de76e1211 100644
--- a/src/filters/parser/SSFSplitter/SSFSplitter.h
+++ b/src/filters/parser/SSFSplitter/SSFSplitter.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -25,14 +25,13 @@
#include "../../../Subtitles/libssf/SubtitleFile.h"
class __declspec(uuid("95C3F9F6-1E05-4C34-8122-504476EACB51"))
-CSSFSplitterFilter : public CBaseSplitterFilter
+ CSSFSplitterFilter : public CBaseSplitterFilter
{
CAutoPtr<CBaseSplitterFile> m_pFile;
ssf::SubtitleFile m_ssf;
- struct SegmentItemEx : public ssf::SubtitleFile::SegmentItem
- {
+ struct SegmentItemEx : public ssf::SubtitleFile::SegmentItem {
static int Compare(const void* a, const void* b);
};
@@ -50,7 +49,7 @@ public:
};
class __declspec(uuid("57F46A2A-6DC9-4A9F-B5FA-DFDD62B8BAFB"))
-CSSFSourceFilter : public CSSFSplitterFilter
+ CSSFSourceFilter : public CSSFSplitterFilter
{
public:
CSSFSourceFilter(LPUNKNOWN pUnk, HRESULT* phr);
diff --git a/src/filters/parser/SSFSplitter/stdafx.cpp b/src/filters/parser/SSFSplitter/stdafx.cpp
index 13934d005..bea3f980a 100644
--- a/src/filters/parser/SSFSplitter/stdafx.cpp
+++ b/src/filters/parser/SSFSplitter/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/parser/SSFSplitter/stdafx.h b/src/filters/parser/SSFSplitter/stdafx.h
index 55763f8a3..432a74d80 100644
--- a/src/filters/parser/SSFSplitter/stdafx.h
+++ b/src/filters/parser/SSFSplitter/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/parser/StreamDriveThru/StreamDriveThru.cpp b/src/filters/parser/StreamDriveThru/StreamDriveThru.cpp
index f4003196c..3ca6b5489 100644
--- a/src/filters/parser/StreamDriveThru/StreamDriveThru.cpp
+++ b/src/filters/parser/StreamDriveThru/StreamDriveThru.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -25,29 +25,24 @@
#ifdef REGISTER_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
{&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
};
-const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
{&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}
+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}
};
-const AMOVIESETUP_FILTER sudFilter[] =
-{
+const AMOVIESETUP_FILTER sudFilter[] = {
{&__uuidof(CStreamDriveThruFilter), L"MPC - StreamDriveThru", MERIT_DO_NOT_USE, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory}
};
-CFactoryTemplate g_Templates[] =
-{
+CFactoryTemplate g_Templates[] = {
{sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CStreamDriveThruFilter>, NULL, &sudFilter[0]}
};
@@ -77,7 +72,9 @@ CStreamDriveThruFilter::CStreamDriveThruFilter(LPUNKNOWN pUnk, HRESULT* phr)
: 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);
@@ -100,7 +97,7 @@ STDMETHODIMP CStreamDriveThruFilter::NonDelegatingQueryInterface(REFIID riid, vo
{
CheckPointer(ppv, E_POINTER);
- return
+ return
QI(IMediaSeeking)
__super::NonDelegatingQueryInterface(riid, ppv);
}
@@ -109,107 +106,98 @@ STDMETHODIMP CStreamDriveThruFilter::NonDelegatingQueryInterface(REFIID riid, vo
DWORD CStreamDriveThruFilter::ThreadProc()
{
- while(1)
- {
+ while(1) {
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);
+ 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;
}
- }
-
- 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;
- }
+ LARGE_INTEGER li = {0};
+ ULARGE_INTEGER uli = {0};
- ULONG written = 0;
- if(FAILED(pStream->Write(buff, (ULONG)size, &written)) || (ULONG)size != written)
- {
- cmd = CMD_STOP;
- break;
- }
+ if(FAILED(pStream->Seek(li, STREAM_SEEK_SET, NULL))
+ || FAILED(pStream->SetSize(uli))) {
+ break;
+ }
- m_position += size;
+ 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);
+ }
}
- if(cmd == CMD_PAUSE)
- {
- Reply(S_OK); // reply to CMD_PAUSE
+ m_position = 0;
+ BYTE buff[PACKETSIZE];
- while(!CheckRequest(&cmd))
- Sleep(50);
+ do {
+ while(!CheckRequest(&cmd)) {
+ CAutoLock csAutoLock(&m_csLock);
- Reply(S_OK); // reply to something
- }
- }
- while(cmd == CMD_RUN);
+ 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;
+ }
- uli.QuadPart = m_position;
- pStream->SetSize(uli);
+ ULONG written = 0;
+ if(FAILED(pStream->Write(buff, (ULONG)size, &written)) || (ULONG)size != written) {
+ cmd = CMD_STOP;
+ break;
+ }
- if(CComPtr<IPin> pPin = m_pOutput->GetConnected())
- pPin->EndOfStream();
- }
- while(false);
+ 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;
+ break;
}
}
@@ -223,20 +211,24 @@ int CStreamDriveThruFilter::GetPinCount()
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;
-
- if(FAILED(hr = __super::Stop()))
+
+ if(FAILED(hr = __super::Stop())) {
return hr;
+ }
CallWorker(CMD_STOP);
@@ -246,9 +238,10 @@ STDMETHODIMP CStreamDriveThruFilter::Stop()
STDMETHODIMP CStreamDriveThruFilter::Pause()
{
HRESULT hr;
-
- if(FAILED(hr = __super::Pause()))
+
+ if(FAILED(hr = __super::Pause())) {
return hr;
+ }
CallWorker(CMD_PAUSE);
@@ -258,9 +251,10 @@ STDMETHODIMP CStreamDriveThruFilter::Pause()
STDMETHODIMP CStreamDriveThruFilter::Run(REFERENCE_TIME tStart)
{
HRESULT hr;
-
- if(FAILED(hr = __super::Run(tStart)))
+
+ if(FAILED(hr = __super::Run(tStart))) {
return hr;
+ }
CallWorker(CMD_RUN);
@@ -277,7 +271,9 @@ STDMETHODIMP CStreamDriveThruFilter::CheckCapabilities(DWORD* pCapabilities)
{
CheckPointer(pCapabilities, E_POINTER);
- if(*pCapabilities == 0) return S_OK;
+ if(*pCapabilities == 0) {
+ return S_OK;
+ }
DWORD caps;
GetCapabilities(&caps);
@@ -311,11 +307,9 @@ STDMETHODIMP CStreamDriveThruFilter::GetDuration(LONGLONG* pDuration)
CheckPointer(pDuration, E_POINTER);
CheckPointer(m_pInput, VFW_E_NOT_CONNECTED);
- if(CComQIPtr<IAsyncReader> pAsyncReader = m_pInput->GetConnected())
- {
+ if(CComQIPtr<IAsyncReader> pAsyncReader = m_pInput->GetConnected()) {
LONGLONG total, available;
- if(SUCCEEDED(pAsyncReader->Length(&total, &available)))
- {
+ if(SUCCEEDED(pAsyncReader->Length(&total, &available))) {
*pDuration = total;
return S_OK;
}
@@ -331,12 +325,30 @@ STDMETHODIMP CStreamDriveThruFilter::GetCurrentPosition(LONGLONG* pCurrent)
{
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;}
-STDMETHODIMP CStreamDriveThruFilter::SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags) {return E_NOTIMPL;}
-STDMETHODIMP CStreamDriveThruFilter::GetPositions(LONGLONG* pCurrent, LONGLONG* pStop) {return E_NOTIMPL;}
-STDMETHODIMP CStreamDriveThruFilter::GetAvailable(LONGLONG* pEarliest, LONGLONG* pLatest) {return E_NOTIMPL;}
-STDMETHODIMP CStreamDriveThruFilter::SetRate(double dRate) {return E_NOTIMPL;}
-STDMETHODIMP CStreamDriveThruFilter::GetRate(double* pdRate) {return E_NOTIMPL;}
+STDMETHODIMP CStreamDriveThruFilter::ConvertTimeFormat(LONGLONG* pTarget, const GUID* pTargetFormat, LONGLONG Source, const GUID* pSourceFormat)
+{
+ return E_NOTIMPL;
+}
+STDMETHODIMP CStreamDriveThruFilter::SetPositions(LONGLONG* pCurrent, DWORD dwCurrentFlags, LONGLONG* pStop, DWORD dwStopFlags)
+{
+ return E_NOTIMPL;
+}
+STDMETHODIMP CStreamDriveThruFilter::GetPositions(LONGLONG* pCurrent, LONGLONG* pStop)
+{
+ return E_NOTIMPL;
+}
+STDMETHODIMP CStreamDriveThruFilter::GetAvailable(LONGLONG* pEarliest, LONGLONG* pLatest)
+{
+ return E_NOTIMPL;
+}
+STDMETHODIMP CStreamDriveThruFilter::SetRate(double dRate)
+{
+ return E_NOTIMPL;
+}
+STDMETHODIMP CStreamDriveThruFilter::GetRate(double* pdRate)
+{
+ return E_NOTIMPL;
+}
STDMETHODIMP CStreamDriveThruFilter::GetPreroll(LONGLONG* pllPreroll)
{
return pllPreroll ? *pllPreroll = 0, S_OK : E_POINTER;
@@ -372,26 +384,28 @@ STDMETHODIMP CStreamDriveThruInputPin::NonDelegatingQueryInterface(REFIID riid,
{
CheckPointer(ppv, E_POINTER);
- return
+ return
__super::NonDelegatingQueryInterface(riid, ppv);
}
HRESULT CStreamDriveThruInputPin::CheckMediaType(const CMediaType* pmt)
{
return pmt->majortype == MEDIATYPE_Stream
- ? S_OK
- : E_INVALIDARG;
+ ? S_OK
+ : E_INVALIDARG;
}
HRESULT CStreamDriveThruInputPin::CheckConnect(IPin* pPin)
{
HRESULT hr;
- if(FAILED(hr = __super::CheckConnect(pPin)))
+ if(FAILED(hr = __super::CheckConnect(pPin))) {
return hr;
+ }
- if(!CComQIPtr<IAsyncReader>(pPin))
+ if(!CComQIPtr<IAsyncReader>(pPin)) {
return E_NOINTERFACE;
+ }
return S_OK;
}
@@ -400,8 +414,9 @@ HRESULT CStreamDriveThruInputPin::BreakConnect()
{
HRESULT hr;
- if(FAILED(hr = __super::BreakConnect()))
+ if(FAILED(hr = __super::BreakConnect())) {
return hr;
+ }
m_pAsyncReader.Release();
@@ -412,8 +427,9 @@ HRESULT CStreamDriveThruInputPin::CompleteConnect(IPin* pPin)
{
HRESULT hr;
- if(FAILED(hr = __super::CompleteConnect(pPin)))
+ if(FAILED(hr = __super::CompleteConnect(pPin))) {
return hr;
+ }
CheckPointer(pPin, E_POINTER);
m_pAsyncReader = pPin;
@@ -462,42 +478,50 @@ STDMETHODIMP CStreamDriveThruOutputPin::NonDelegatingQueryInterface(REFIID riid,
{
CheckPointer(ppv, E_POINTER);
- return
+ 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;
- 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;
+ ? 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;
@@ -511,11 +535,13 @@ HRESULT CStreamDriveThruOutputPin::CheckConnect(IPin* pPin)
{
HRESULT hr;
- if(FAILED(hr = __super::CheckConnect(pPin)))
+ if(FAILED(hr = __super::CheckConnect(pPin))) {
return hr;
+ }
- if(!CComQIPtr<IStream>(pPin))
+ if(!CComQIPtr<IStream>(pPin)) {
return E_NOINTERFACE;
+ }
return S_OK;
}
@@ -524,8 +550,9 @@ HRESULT CStreamDriveThruOutputPin::BreakConnect()
{
HRESULT hr;
- if(FAILED(hr = __super::BreakConnect()))
+ if(FAILED(hr = __super::BreakConnect())) {
return hr;
+ }
m_pStream.Release();
@@ -536,8 +563,9 @@ HRESULT CStreamDriveThruOutputPin::CompleteConnect(IPin* pPin)
{
HRESULT hr;
- if(FAILED(hr = __super::CompleteConnect(pPin)))
+ if(FAILED(hr = __super::CompleteConnect(pPin))) {
return hr;
+ }
CheckPointer(pPin, E_POINTER);
m_pStream = pPin;
diff --git a/src/filters/parser/StreamDriveThru/StreamDriveThru.h b/src/filters/parser/StreamDriveThru/StreamDriveThru.h
index d55b7aeca..62bd97bcd 100644
--- a/src/filters/parser/StreamDriveThru/StreamDriveThru.h
+++ b/src/filters/parser/StreamDriveThru/StreamDriveThru.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -36,12 +36,12 @@ public:
HRESULT GetAsyncReader(IAsyncReader** ppAsyncReader);
DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- HRESULT CheckMediaType(const CMediaType* pmt);
+ HRESULT CheckMediaType(const CMediaType* pmt);
- HRESULT CheckConnect(IPin* pPin);
- HRESULT BreakConnect();
+ HRESULT CheckConnect(IPin* pPin);
+ HRESULT BreakConnect();
HRESULT CompleteConnect(IPin* pPin);
STDMETHODIMP BeginFlush();
@@ -59,16 +59,16 @@ public:
HRESULT GetStream(IStream** ppStream);
DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ 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();
@@ -77,7 +77,7 @@ public:
};
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;
@@ -86,7 +86,7 @@ CStreamDriveThruFilter : public CBaseFilter, protected CAMThread, public IMediaS
protected:
enum {CMD_EXIT, CMD_STOP, CMD_PAUSE, CMD_RUN};
- DWORD ThreadProc();
+ DWORD ThreadProc();
LONGLONG m_position;
@@ -95,7 +95,7 @@ public:
virtual ~CStreamDriveThruFilter();
DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
int GetPinCount();
CBasePin* GetPin(int n);
diff --git a/src/filters/parser/StreamDriveThru/stdafx.cpp b/src/filters/parser/StreamDriveThru/stdafx.cpp
index 13934d005..bea3f980a 100644
--- a/src/filters/parser/StreamDriveThru/stdafx.cpp
+++ b/src/filters/parser/StreamDriveThru/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/parser/StreamDriveThru/stdafx.h b/src/filters/parser/StreamDriveThru/stdafx.h
index b55bcba79..a8c9e282b 100644
--- a/src/filters/parser/StreamDriveThru/stdafx.h
+++ b/src/filters/parser/StreamDriveThru/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/reader/CDDAReader/CDDAReader.cpp b/src/filters/reader/CDDAReader/CDDAReader.cpp
index bc74ac8a5..d0515786b 100644
--- a/src/filters/reader/CDDAReader/CDDAReader.cpp
+++ b/src/filters/reader/CDDAReader/CDDAReader.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -29,23 +29,19 @@
#ifdef REGISTER_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
{&MEDIATYPE_Stream, &MEDIASUBTYPE_WAVE},
};
-const AMOVIESETUP_PIN sudOpPin[] =
-{
+const AMOVIESETUP_PIN sudOpPin[] = {
{L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesOut), sudPinTypesOut},
};
-const AMOVIESETUP_FILTER sudFilter[] =
-{
+const AMOVIESETUP_FILTER sudFilter[] = {
{&__uuidof(CCDDAReader), L"MPC - CDDA Reader", MERIT_NORMAL, countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory}
};
-CFactoryTemplate g_Templates[] =
-{
+CFactoryTemplate g_Templates[] = {
{sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CCDDAReader>, NULL, &sudFilter[0]}
};
@@ -53,22 +49,21 @@ int g_cTemplates = countof(g_Templates);
STDAPI DllRegisterServer()
{
- if(GetVersion()&0x80000000)
- {
+ if(GetVersion()&0x80000000) {
::MessageBox(NULL, _T("Sorry, this will only run on Windows NT based operating system."), _T("CDDA Reader"), MB_OK);
return E_NOTIMPL;
}
SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{54A35221-2C8D-4a31-A5DF-6D809847E393}"),
+ _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("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("Media Type\\Extensions"), _T(".cda"),
_T("Source Filter"), _T("{54A35221-2C8D-4a31-A5DF-6D809847E393}"));
return AMovieDllRegisterServer2(TRUE);
@@ -95,11 +90,14 @@ CFilterApp theApp;
CCDDAReader::CCDDAReader(IUnknown* pUnk, HRESULT* phr)
: CAsyncReader(NAME("CCDDAReader"), pUnk, &m_stream, phr, __uuidof(this))
{
- if(phr) *phr = S_OK;
+ if(phr) {
+ *phr = S_OK;
+ }
- if(GetVersion()&0x80000000)
- {
- if(phr) *phr = E_NOTIMPL;
+ if(GetVersion()&0x80000000) {
+ if(phr) {
+ *phr = E_NOTIMPL;
+ }
return;
}
}
@@ -110,9 +108,9 @@ CCDDAReader::~CCDDAReader()
STDMETHODIMP CCDDAReader::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- return
+ return
QI(IFileSourceFilter)
QI2(IAMMediaContent)
__super::NonDelegatingQueryInterface(riid, ppv);
@@ -120,10 +118,11 @@ STDMETHODIMP CCDDAReader::NonDelegatingQueryInterface(REFIID riid, void** ppv)
// IFileSourceFilter
-STDMETHODIMP CCDDAReader::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt)
+STDMETHODIMP CCDDAReader::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt)
{
- if(!m_stream.Load(pszFileName))
+ if(!m_stream.Load(pszFileName)) {
return E_FAIL;
+ }
m_fn = pszFileName;
@@ -140,8 +139,9 @@ STDMETHODIMP CCDDAReader::GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt)
CheckPointer(ppszFileName, E_POINTER);
*ppszFileName = (LPOLESTR)CoTaskMemAlloc((m_fn.GetLength()+1)*sizeof(WCHAR));
- if(!(*ppszFileName))
+ if(!(*ppszFileName)) {
return E_OUTOFMEMORY;
+ }
wcscpy(*ppszFileName, m_fn);
@@ -150,16 +150,30 @@ STDMETHODIMP CCDDAReader::GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt)
// IAMMediaContent
-STDMETHODIMP CCDDAReader::GetTypeInfoCount(UINT* pctinfo) {return E_NOTIMPL;}
-STDMETHODIMP CCDDAReader::GetTypeInfo(UINT itinfo, LCID lcid, ITypeInfo** pptinfo) {return E_NOTIMPL;}
-STDMETHODIMP CCDDAReader::GetIDsOfNames(REFIID riid, OLECHAR** rgszNames, UINT cNames, LCID lcid, DISPID* rgdispid) {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;}
+STDMETHODIMP CCDDAReader::GetTypeInfoCount(UINT* pctinfo)
+{
+ return E_NOTIMPL;
+}
+STDMETHODIMP CCDDAReader::GetTypeInfo(UINT itinfo, LCID lcid, ITypeInfo** pptinfo)
+{
+ return E_NOTIMPL;
+}
+STDMETHODIMP CCDDAReader::GetIDsOfNames(REFIID riid, OLECHAR** rgszNames, UINT cNames, LCID lcid, DISPID* rgdispid)
+{
+ 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;
+}
STDMETHODIMP CCDDAReader::get_AuthorName(BSTR* pbstrAuthorName)
{
CheckPointer(pbstrAuthorName, E_POINTER);
CString str = m_stream.m_trackArtist;
- if(str.IsEmpty()) str = m_stream.m_discArtist;
+ if(str.IsEmpty()) {
+ str = m_stream.m_discArtist;
+ }
*pbstrAuthorName = str.AllocSysString();
return S_OK;
}
@@ -168,22 +182,57 @@ STDMETHODIMP CCDDAReader::get_Title(BSTR* pbstrTitle)
{
CheckPointer(pbstrTitle, E_POINTER);
CString str = m_stream.m_trackTitle;
- if(str.IsEmpty()) str = m_stream.m_discTitle;
+ if(str.IsEmpty()) {
+ str = m_stream.m_discTitle;
+ }
*pbstrTitle = str.AllocSysString();
return S_OK;
}
-STDMETHODIMP CCDDAReader::get_Rating(BSTR* pbstrRating) {return E_NOTIMPL;}
-STDMETHODIMP CCDDAReader::get_Description(BSTR* pbstrDescription) {return E_NOTIMPL;}
-STDMETHODIMP CCDDAReader::get_Copyright(BSTR* pbstrCopyright) {return E_NOTIMPL;}
-STDMETHODIMP CCDDAReader::get_BaseURL(BSTR* pbstrBaseURL) {return E_NOTIMPL;}
-STDMETHODIMP CCDDAReader::get_LogoURL(BSTR* pbstrLogoURL) {return E_NOTIMPL;}
-STDMETHODIMP CCDDAReader::get_LogoIconURL(BSTR* pbstrLogoURL) {return E_NOTIMPL;}
-STDMETHODIMP CCDDAReader::get_WatermarkURL(BSTR* pbstrWatermarkURL) {return E_NOTIMPL;}
-STDMETHODIMP CCDDAReader::get_MoreInfoURL(BSTR* pbstrMoreInfoURL) {return E_NOTIMPL;}
-STDMETHODIMP CCDDAReader::get_MoreInfoBannerImage(BSTR* pbstrMoreInfoBannerImage) {return E_NOTIMPL;}
-STDMETHODIMP CCDDAReader::get_MoreInfoBannerURL(BSTR* pbstrMoreInfoBannerURL) {return E_NOTIMPL;}
-STDMETHODIMP CCDDAReader::get_MoreInfoText(BSTR* pbstrMoreInfoText) {return E_NOTIMPL;}
+STDMETHODIMP CCDDAReader::get_Rating(BSTR* pbstrRating)
+{
+ return E_NOTIMPL;
+}
+STDMETHODIMP CCDDAReader::get_Description(BSTR* pbstrDescription)
+{
+ return E_NOTIMPL;
+}
+STDMETHODIMP CCDDAReader::get_Copyright(BSTR* pbstrCopyright)
+{
+ return E_NOTIMPL;
+}
+STDMETHODIMP CCDDAReader::get_BaseURL(BSTR* pbstrBaseURL)
+{
+ return E_NOTIMPL;
+}
+STDMETHODIMP CCDDAReader::get_LogoURL(BSTR* pbstrLogoURL)
+{
+ return E_NOTIMPL;
+}
+STDMETHODIMP CCDDAReader::get_LogoIconURL(BSTR* pbstrLogoURL)
+{
+ return E_NOTIMPL;
+}
+STDMETHODIMP CCDDAReader::get_WatermarkURL(BSTR* pbstrWatermarkURL)
+{
+ return E_NOTIMPL;
+}
+STDMETHODIMP CCDDAReader::get_MoreInfoURL(BSTR* pbstrMoreInfoURL)
+{
+ return E_NOTIMPL;
+}
+STDMETHODIMP CCDDAReader::get_MoreInfoBannerImage(BSTR* pbstrMoreInfoBannerImage)
+{
+ return E_NOTIMPL;
+}
+STDMETHODIMP CCDDAReader::get_MoreInfoBannerURL(BSTR* pbstrMoreInfoBannerURL)
+{
+ return E_NOTIMPL;
+}
+STDMETHODIMP CCDDAReader::get_MoreInfoText(BSTR* pbstrMoreInfoText)
+{
+ return E_NOTIMPL;
+}
// CCDDAStream
@@ -212,8 +261,7 @@ CCDDAStream::CCDDAStream()
CCDDAStream::~CCDDAStream()
{
- if(m_hDrive != INVALID_HANDLE_VALUE)
- {
+ if(m_hDrive != INVALID_HANDLE_VALUE) {
CloseHandle(m_hDrive);
m_hDrive = INVALID_HANDLE_VALUE;
}
@@ -225,31 +273,32 @@ bool CCDDAStream::Load(const WCHAR* fnw)
int iDriveLetter = path.Find(_T(":\\"))-1;
int iTrackIndex = CString(path).MakeLower().Find(_T(".cda"))-1;
- if(iDriveLetter < 0 || iTrackIndex <= iDriveLetter)
+ 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(path.Mid(iTrackIndex), _T("%d"), &iTrackIndex))
+ while(iTrackIndex > 0 && _istdigit(path[iTrackIndex-1])) {
+ iTrackIndex--;
+ }
+ if(1 != _stscanf(path.Mid(iTrackIndex), _T("%d"), &iTrackIndex)) {
return(false);
+ }
- if(m_hDrive != INVALID_HANDLE_VALUE)
- {
+ 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)
- {
+ 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))
- {
+ || !(m_TOC.FirstTrack <= iTrackIndex && iTrackIndex <= m_TOC.LastTrack)) {
CloseHandle(m_hDrive);
m_hDrive = INVALID_HANDLE_VALUE;
return(false);
@@ -257,15 +306,15 @@ bool CCDDAStream::Load(const WCHAR* fnw)
// 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))
- {
+ 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)
+ 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);
@@ -275,16 +324,16 @@ bool CCDDAStream::Load(const WCHAR* fnw)
m_header.riff.hdr.chunkSize = (long)(m_llLength + sizeof(m_header) - 8);
m_header.data.hdr.chunkSize = (long)(m_llLength);
- do
- {
+ 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))
+ 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);
@@ -292,50 +341,48 @@ bool CCDDAStream::Load(const WCHAR* fnw)
pCDTextData.Allocate(size);
memset(pCDTextData, 0, size);
- if(!DeviceIoControl(m_hDrive, IOCTL_CDROM_READ_TOC_EX, &TOCEx, sizeof(TOCEx), pCDTextData, size, &BytesReturned, 0))
+ 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);
+ 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)
+ 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));
+ 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("");
+ ? (!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)
+ if((pDesc->PackType -= 0x80) >= 0x10) {
continue;
+ }
- if(pDesc->CharacterPosition == 0)
- {
+ if(pDesc->CharacterPosition == 0) {
str[pDesc->PackType][pDesc->TrackNumber] = text;
- }
- else if(pDesc->CharacterPosition <= 0xf)
- {
- if(pDesc->CharacterPosition < 0xf && last.GetLength() > 0)
- {
+ } else if(pDesc->CharacterPosition <= 0xf) {
+ if(pDesc->CharacterPosition < 0xf && last.GetLength() > 0) {
str[pDesc->PackType][pDesc->TrackNumber] = last + text;
- }
- else
- {
+ } else {
str[pDesc->PackType][pDesc->TrackNumber] += text;
}
}
@@ -347,16 +394,17 @@ bool CCDDAStream::Load(const WCHAR* fnw)
m_trackTitle = str[0][iTrackIndex];
m_discArtist = str[1][0];
m_trackArtist = str[1][iTrackIndex];
- }
- while(0);
-
+ } while(0);
+
return(true);
}
HRESULT CCDDAStream::SetPointer(LONGLONG llPos)
{
- if(llPos < 0 || llPos > m_llLength) return S_FALSE;
+ if(llPos < 0 || llPos > m_llLength) {
+ return S_FALSE;
+ }
m_llPosition = llPos;
return S_OK;
}
@@ -371,8 +419,7 @@ HRESULT CCDDAStream::Read(PBYTE pbBuffer, DWORD dwBytesToRead, BOOL bAlign, LPDW
LONGLONG pos = m_llPosition;
size_t len = (size_t)dwBytesToRead;
- if(pos < sizeof(m_header) && len > 0)
- {
+ 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;
@@ -382,8 +429,7 @@ HRESULT CCDDAStream::Read(PBYTE pbBuffer, DWORD dwBytesToRead, BOOL bAlign, LPDW
pos -= sizeof(m_header);
- while(pos >= 0 && pos < m_llLength && len > 0)
- {
+ while(pos >= 0 && pos < m_llLength && len > 0) {
RAW_READ_INFO rawreadinfo;
rawreadinfo.SectorCount = 1;
rawreadinfo.TrackMode = CDDA;
@@ -394,10 +440,10 @@ HRESULT CCDDAStream::Read(PBYTE pbBuffer, DWORD dwBytesToRead, BOOL bAlign, LPDW
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);
+ m_hDrive, IOCTL_CDROM_RAW_READ,
+ &rawreadinfo, sizeof(rawreadinfo),
+ buff, RAW_SECTOR_SIZE,
+ &BytesReturned, 0);
UNUSED_ALWAYS(b);
size_t l = (size_t)min(min(len, RAW_SECTOR_SIZE - offset), m_llLength - pos);
@@ -408,7 +454,9 @@ HRESULT CCDDAStream::Read(PBYTE pbBuffer, DWORD dwBytesToRead, BOOL bAlign, LPDW
len -= l;
}
- if(pdwBytesRead) *pdwBytesRead = pbBuffer - pbBufferOrg;
+ if(pdwBytesRead) {
+ *pdwBytesRead = pbBuffer - pbBufferOrg;
+ }
m_llPosition += pbBuffer - pbBufferOrg;
return S_OK;
@@ -417,22 +465,24 @@ HRESULT CCDDAStream::Read(PBYTE pbBuffer, DWORD dwBytesToRead, BOOL bAlign, LPDW
LONGLONG CCDDAStream::Size(LONGLONG* pSizeAvailable)
{
LONGLONG size = sizeof(m_header) + m_llLength;
- if(pSizeAvailable) *pSizeAvailable = size;
- return size;
+ 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 cccee0987..f491b38ce 100644
--- a/src/filters/reader/CDDAReader/CDDAReader.h
+++ b/src/filters/reader/CDDAReader/CDDAReader.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -28,24 +28,39 @@
#include "../AsyncReader/asyncio.h"
#include "../AsyncReader/asyncrdr.h"
-typedef struct {UINT chunkID; long chunkSize;} ChunkHeader;
+typedef struct {
+ UINT chunkID;
+ long chunkSize;
+} ChunkHeader;
-#define RIFFID 'FFIR'
-#define WAVEID 'EVAW'
-typedef struct {ChunkHeader hdr; UINT WAVE;} RIFFChunk;
+#define RIFFID 'FFIR'
+#define WAVEID 'EVAW'
+typedef struct {
+ ChunkHeader hdr;
+ UINT WAVE;
+} RIFFChunk;
-#define FormatID ' tmf'
-typedef struct {ChunkHeader hdr; PCMWAVEFORMAT pcm;} FormatChunk;
+#define FormatID ' tmf'
+typedef struct {
+ ChunkHeader hdr;
+ PCMWAVEFORMAT pcm;
+} FormatChunk;
#define DataID 'atad'
-typedef struct {ChunkHeader hdr;} DataChunk;
+typedef struct {
+ ChunkHeader hdr;
+} DataChunk;
-typedef struct {RIFFChunk riff; FormatChunk frm; DataChunk data;} WAVEChunck;
+typedef struct {
+ RIFFChunk riff;
+ FormatChunk frm;
+ DataChunk data;
+} WAVEChunck;
class CCDDAStream : public CAsyncStream
{
private:
- CCritSec m_csLock;
+ CCritSec m_csLock;
LONGLONG m_llPosition, m_llLength;
@@ -65,29 +80,29 @@ public:
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();
+ 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
+ CCDDAReader
: public CAsyncReader
, public IFileSourceFilter
, public IAMMediaContent
{
- CCDDAStream m_stream;
+ CCDDAStream m_stream;
CStringW m_fn;
public:
- CCDDAReader(IUnknown* pUnk, HRESULT* phr);
+ CCDDAReader(IUnknown* pUnk, HRESULT* phr);
~CCDDAReader();
DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
// IFileSourceFilter
@@ -96,23 +111,23 @@ public:
// IAMMediaContent
- STDMETHODIMP GetTypeInfoCount(UINT* pctinfo);
+ 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);
+ 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/CDDAReader/stdafx.cpp b/src/filters/reader/CDDAReader/stdafx.cpp
index 13934d005..bea3f980a 100644
--- a/src/filters/reader/CDDAReader/stdafx.cpp
+++ b/src/filters/reader/CDDAReader/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/reader/CDDAReader/stdafx.h b/src/filters/reader/CDDAReader/stdafx.h
index 62d50a36b..d1c3768d8 100644
--- a/src/filters/reader/CDDAReader/stdafx.h
+++ b/src/filters/reader/CDDAReader/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/reader/CDXAReader/CDXAReader.cpp b/src/filters/reader/CDXAReader/CDXAReader.cpp
index aa17fe3d6..099c56d45 100644
--- a/src/filters/reader/CDXAReader/CDXAReader.cpp
+++ b/src/filters/reader/CDXAReader/CDXAReader.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -28,8 +28,7 @@
/////////
-static DWORD EDC_crctable[256] =
-{
+static DWORD EDC_crctable[256] = {
0x00000000l, 0x90910101l, 0x91210201l, 0x01b00300l,
0x92410401l, 0x02d00500l, 0x03600600l, 0x93f10701l,
0x94810801l, 0x04100900l, 0x05a00a00l, 0x95310b01l,
@@ -101,9 +100,10 @@ static DWORD build_edc(const void* in, unsigned from, unsigned upto)
const BYTE* p = (BYTE*)in + from;
DWORD result = 0;
- for(; from < upto; from++)
+ for(; from < upto; from++) {
result = EDC_crctable[(result ^ *p++) & 0xffL] ^ (result >> 8);
-
+ }
+
return result;
}
@@ -111,23 +111,19 @@ static DWORD build_edc(const void* in, unsigned from, unsigned upto)
#ifdef REGISTER_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
{&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL}
};
-const AMOVIESETUP_PIN sudOpPin[] =
-{
+const AMOVIESETUP_PIN sudOpPin[] = {
{L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesOut), sudPinTypesOut}
};
-const AMOVIESETUP_FILTER sudFilter[] =
-{
+const AMOVIESETUP_FILTER sudFilter[] = {
{&__uuidof(CCDXAReader), L"MPC - CDXA Reader", MERIT_NORMAL, countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory}
};
-CFactoryTemplate g_Templates[] =
-{
+CFactoryTemplate g_Templates[] = {
{sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CCDXAReader>, NULL, &sudFilter[0]}
};
@@ -136,11 +132,11 @@ int g_cTemplates = countof(g_Templates);
STDAPI DllRegisterServer()
{
SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{D367878E-F3B8-4235-A968-F378EF1B9A44}"),
+ _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("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);
@@ -166,7 +162,9 @@ CFilterApp theApp;
CCDXAReader::CCDXAReader(IUnknown* pUnk, HRESULT* phr)
: CAsyncReader(NAME("CCDXAReader"), pUnk, &m_stream, phr, __uuidof(this))
{
- if(phr) *phr = S_OK;
+ if(phr) {
+ *phr = S_OK;
+ }
}
CCDXAReader::~CCDXAReader()
@@ -175,18 +173,19 @@ CCDXAReader::~CCDXAReader()
STDMETHODIMP CCDXAReader::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- return
+ 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;
- if(!m_stream.Load(pszFileName))
+ if(!m_stream.Load(pszFileName)) {
return E_FAIL;
+ }
m_fn = pszFileName;
@@ -199,11 +198,14 @@ STDMETHODIMP CCDXAReader::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE *pmt)
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))
+ if(!(*ppszFileName)) {
return E_OUTOFMEMORY;
+ }
wcscpy(*ppszFileName, m_fn);
@@ -215,7 +217,7 @@ STDMETHODIMP CCDXAReader::GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt)
CCDXAStream::CCDXAStream()
{
m_subtype = MEDIASUBTYPE_NULL;
-
+
m_hFile = INVALID_HANDLE_VALUE;
m_llPosition = m_llLength = 0;
@@ -225,8 +227,7 @@ CCDXAStream::CCDXAStream()
CCDXAStream::~CCDXAStream()
{
- if(m_hFile != INVALID_HANDLE_VALUE)
- {
+ if(m_hFile != INVALID_HANDLE_VALUE) {
CloseHandle(m_hFile);
m_hFile = INVALID_HANDLE_VALUE;
}
@@ -234,25 +235,22 @@ CCDXAStream::~CCDXAStream()
bool CCDXAStream::Load(const WCHAR* fnw)
{
- if(m_hFile != INVALID_HANDLE_VALUE)
- {
+ 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)
- {
+ 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))
- {
+ || *((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);
@@ -263,8 +261,7 @@ bool CCDXAStream::Load(const WCHAR* fnw)
m_llLength = int((size.QuadPart - RIFFCDXA_HEADER_SIZE) / RAW_SECTOR_SIZE) * RAW_DATA_SIZE;
- if(!LookForMediaSubType())
- {
+ if(!LookForMediaSubType()) {
m_llPosition = m_llLength = 0;
CloseHandle(m_hFile);
m_hFile = INVALID_HANDLE_VALUE;
@@ -290,13 +287,11 @@ HRESULT CCDXAStream::Read(PBYTE pbBuffer, DWORD dwBytesToRead, BOOL bAlign, LPDW
PBYTE pbBufferOrg = pbBuffer;
LONGLONG pos = m_llPosition;
- while(pos >= 0 && pos < m_llLength && dwBytesToRead > 0)
- {
+ 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)
- {
+ if(m_nBufferedSector != (int)sector) {
LARGE_INTEGER FilePointer;
FilePointer.QuadPart = RIFFCDXA_HEADER_SIZE + sector*RAW_SECTOR_SIZE;
SetFilePointer(m_hFile, (LONG)FilePointer.LowPart, (PLONG)&FilePointer.HighPart, FILE_BEGIN);
@@ -306,18 +301,20 @@ HRESULT CCDXAStream::Read(PBYTE pbBuffer, DWORD dwBytesToRead, BOOL bAlign, LPDW
DWORD NumberOfBytesRead = 0;
int nRetries = 3;
- while(nRetries--)
- {
+ while(nRetries--) {
NumberOfBytesRead = 0;
if(!ReadFile(m_hFile, m_sector, RAW_SECTOR_SIZE, &NumberOfBytesRead, NULL)
- || NumberOfBytesRead != RAW_SECTOR_SIZE)
+ || NumberOfBytesRead != RAW_SECTOR_SIZE) {
break;
+ }
- if(*(DWORD*)&m_sector[RAW_SECTOR_SIZE-4] == 0) // no CRC? it happens...
+ 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)
+ 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);
}
@@ -333,33 +330,39 @@ HRESULT CCDXAStream::Read(PBYTE pbBuffer, DWORD dwBytesToRead, BOOL bAlign, LPDW
dwBytesToRead -= l;
}
- if(pdwBytesRead) *pdwBytesRead = 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;
}
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();
}
//
@@ -373,22 +376,21 @@ bool CCDXAStream::LookForMediaSubType()
m_llPosition = 0;
for(int iSectorsRead = 0;
- Read(buff, RAW_DATA_SIZE, 1, NULL) == S_OK && iSectorsRead < 1000;
- iSectorsRead++)
- {
- if(*((DWORD*)&buff[0]) == 0xba010000)
- {
+ 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;
+ 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')
- {
+ } else if(*((DWORD*)&buff[0]) == 'SggO') {
m_llPosition = 0;
m_llLength -= iSectorsRead*RAW_DATA_SIZE;
m_nFirstSector = iSectorsRead;
@@ -396,9 +398,7 @@ bool CCDXAStream::LookForMediaSubType()
m_subtype = MEDIASUBTYPE_Ogg;
return(true);
- }
- else if(*((DWORD*)&buff[0]) == 0xA3DF451A)
- {
+ } else if(*((DWORD*)&buff[0]) == 0xA3DF451A) {
m_llPosition = 0;
m_llLength -= iSectorsRead*RAW_DATA_SIZE;
m_nFirstSector = iSectorsRead;
@@ -406,9 +406,7 @@ bool CCDXAStream::LookForMediaSubType()
m_subtype = MEDIASUBTYPE_Matroska;
return(true);
- }
- else if(*((DWORD*)&buff[0]) == 'FMR.')
- {
+ } else if(*((DWORD*)&buff[0]) == 'FMR.') {
m_llPosition = 0;
m_llLength -= iSectorsRead*RAW_DATA_SIZE;
m_nFirstSector = iSectorsRead;
@@ -416,26 +414,22 @@ bool CCDXAStream::LookForMediaSubType()
m_subtype = MEDIASUBTYPE_RealMedia;
return(true);
- }
- else if(*((DWORD*)&buff[0]) == 'FFIR' && *((DWORD*)&buff[8]) == ' IVA')
- {
+ } 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')
- {
+ } 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);
}
}
@@ -444,25 +438,24 @@ bool CCDXAStream::LookForMediaSubType()
CRegKey majorkey;
CString majortype = _T("\\Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}");
- if(ERROR_SUCCESS == majorkey.Open(HKEY_CLASSES_ROOT, majortype, KEY_READ))
- {
+ 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)
- {
+ 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))
+ if(ERROR_SUCCESS != subkey.Open(HKEY_CLASSES_ROOT, majortype + _T("\\") + subtype, KEY_READ)) {
continue;
+ }
- for(int j = 0; true; j++)
- {
+ for(int j = 0; true; j++) {
TCHAR number[10];
_stprintf(number, _T("%d"), j);
TCHAR pattern[256+1];
ULONG len = 256;
- if(ERROR_SUCCESS != subkey.QueryStringValue(number, pattern, &len))
+ if(ERROR_SUCCESS != subkey.QueryStringValue(number, pattern, &len)) {
break;
+ }
CString p = pattern;
p += ',';
@@ -473,59 +466,66 @@ bool CCDXAStream::LookForMediaSubType()
int nMatches = 0, nTries = 0;
- for(int k = 0, l; nTries >= 0 && (l = p.Find(',', k)) >= 0; k = l+1, nTries++)
- {
+ 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;
+ 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(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))
- {
+ || S_OK == SetPointer(m_llLength + offset)) {
CAutoVectorPtr<BYTE> pData;
- if(pData.Allocate(cb))
- {
+ if(pData.Allocate(cb)) {
DWORD BytesRead = 0;
- if(S_OK == Read(pData, cb, 1, &BytesRead) && cb == BytesRead)
- {
- if(mask.GetCount() < cb)
- {
+ if(S_OK == Read(pData, cb, 1, &BytesRead) && cb == BytesRead) {
+ if(mask.GetCount() < cb) {
int i = mask.GetCount();
mask.SetCount(cb);
- for(; i < cb; i++) mask[i] = 0xff;
+ for(; i < cb; i++) {
+ mask[i] = 0xff;
+ }
}
- for(int i = 0; i < cb; i++)
+ for(int i = 0; i < cb; i++) {
pData[i] &= (BYTE)mask[i];
+ }
- if(memcmp(pData, val.GetData(), cb) == 0)
+ if(memcmp(pData, val.GetData(), cb) == 0) {
nMatches++;
+ }
}
}
}
- offset = 0; cb = 0;
- mask.RemoveAll(); val.RemoveAll();
+ offset = 0;
+ cb = 0;
+ mask.RemoveAll();
+ val.RemoveAll();
}
}
}
- if(nMatches > 0 && nMatches*4 == nTries)
- {
+ if(nMatches > 0 && nMatches*4 == nTries) {
m_subtype = GUIDFromCString(subtype);
return S_OK;
}
diff --git a/src/filters/reader/CDXAReader/CDXAReader.h b/src/filters/reader/CDXAReader/CDXAReader.h
index f923b9429..74dd1a2c2 100644
--- a/src/filters/reader/CDXAReader/CDXAReader.h
+++ b/src/filters/reader/CDXAReader/CDXAReader.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -28,8 +28,7 @@
class CCDXAStream : public CAsyncStream
{
private:
- enum
- {
+ enum {
RIFFCDXA_HEADER_SIZE = 44, // usually...
RAW_SYNC_SIZE = 12, // 00 FF .. FF 00
RAW_HEADER_SIZE = 4,
@@ -39,7 +38,7 @@ private:
RAW_SECTOR_SIZE = 2352
};
- CCritSec m_csLock;
+ CCritSec m_csLock;
HANDLE m_hFile;
LONGLONG m_llPosition, m_llLength;
@@ -56,18 +55,18 @@ public:
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();
+ 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;
};
class __declspec(uuid("D367878E-F3B8-4235-A968-F378EF1B9A44"))
-CCDXAReader
+ CCDXAReader
: public CAsyncReader
, public IFileSourceFilter
{
@@ -75,11 +74,11 @@ CCDXAReader
CStringW m_fn;
public:
- CCDXAReader(IUnknown* pUnk, HRESULT* phr);
+ 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);
diff --git a/src/filters/reader/CDXAReader/stdafx.cpp b/src/filters/reader/CDXAReader/stdafx.cpp
index 13934d005..bea3f980a 100644
--- a/src/filters/reader/CDXAReader/stdafx.cpp
+++ b/src/filters/reader/CDXAReader/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/reader/CDXAReader/stdafx.h b/src/filters/reader/CDXAReader/stdafx.h
index 62d50a36b..d1c3768d8 100644
--- a/src/filters/reader/CDXAReader/stdafx.h
+++ b/src/filters/reader/CDXAReader/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/reader/UDPReader/UDPReader.cpp b/src/filters/reader/UDPReader/UDPReader.cpp
index d1fc5e25d..1fe035f6a 100644
--- a/src/filters/reader/UDPReader/UDPReader.cpp
+++ b/src/filters/reader/UDPReader/UDPReader.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -25,23 +25,19 @@
#ifdef REGISTER_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
{&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},
};
-const AMOVIESETUP_PIN sudOpPin[] =
-{
+const AMOVIESETUP_PIN sudOpPin[] = {
{L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesOut), sudPinTypesOut}
};
-const AMOVIESETUP_FILTER sudFilter[] =
-{
+const AMOVIESETUP_FILTER sudFilter[] = {
{&__uuidof(CUDPReader), L"MPC - UDP Reader", MERIT_NORMAL, countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory}
};
-CFactoryTemplate g_Templates[] =
-{
+CFactoryTemplate g_Templates[] = {
{sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CUDPReader>, NULL, &sudFilter[0]}
};
@@ -78,7 +74,9 @@ CFilterApp theApp;
CUDPReader::CUDPReader(IUnknown* pUnk, HRESULT* phr)
: CAsyncReader(NAME("CUDPReader"), pUnk, &m_stream, phr, __uuidof(this))
{
- if(phr) *phr = S_OK;
+ if(phr) {
+ *phr = S_OK;
+ }
}
CUDPReader::~CUDPReader()
@@ -87,19 +85,20 @@ CUDPReader::~CUDPReader()
STDMETHODIMP CUDPReader::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- return
+ return
QI(IFileSourceFilter)
__super::NonDelegatingQueryInterface(riid, ppv);
}
// IFileSourceFilter
-STDMETHODIMP CUDPReader::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt)
+STDMETHODIMP CUDPReader::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt)
{
- if(!m_stream.Load(pszFileName))
+ if(!m_stream.Load(pszFileName)) {
return E_FAIL;
+ }
m_fn = pszFileName;
@@ -113,11 +112,14 @@ STDMETHODIMP CUDPReader::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt)
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))
+ if(!(*ppszFileName)) {
return E_OUTOFMEMORY;
+ }
wcscpy(*ppszFileName, m_fn);
@@ -140,13 +142,17 @@ CUDPStream::~CUDPStream()
void CUDPStream::Clear()
{
- if(m_socket !=INVALID_SOCKET) {closesocket(m_socket); m_socket = INVALID_SOCKET;}
- if(CAMThread::ThreadExists())
- {
+ 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();
+ while(!m_packets.IsEmpty()) {
+ delete m_packets.RemoveHead();
+ }
m_pos = m_len = 0;
m_drop = false;
}
@@ -155,22 +161,20 @@ void CUDPStream::Append(BYTE* buff, int len)
{
CAutoLock cAutoLock(&m_csLock);
- if(m_packets.GetCount() > 1)
- {
+ 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))
- {
+ 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)
- {
+ } else if(m_drop && size <= BUFF_SIZE_FIRST) {
m_drop = false;
TRACE(_T("DROP OFF\n"));
}
-
- if(m_drop) return;
+
+ if(m_drop) {
+ return;
+ }
}
m_packets.AddTail(DNew packet_t(buff, m_len, m_len + len));
@@ -184,14 +188,16 @@ bool CUDPStream::Load(const WCHAR* fnw)
CStringW url = CStringW(fnw);
#ifdef DEBUG
-// url = L"udp://:1234/";
-// url = L"udp://239.255.255.250:1234/{e436eb8e-524f-11ce-9f53-0020af0ba770}";
-// url = L"udp://239.255.255.19:2345/";
+ // url = L"udp://:1234/";
+ // url = L"udp://239.255.255.250:1234/{e436eb8e-524f-11ce-9f53-0020af0ba770}";
+ // url = L"udp://239.255.255.19:2345/";
#endif
CAtlList<CStringW> sl;
Explode(url, sl, ':');
- if(sl.GetCount() != 3) return false;
+ if(sl.GetCount() != 3) {
+ return false;
+ }
CStringW protocol = sl.RemoveHead();
// if(protocol != L"udp") return false;
@@ -199,22 +205,25 @@ bool CUDPStream::Load(const WCHAR* fnw)
m_ip = CString(sl.RemoveHead()).TrimLeft('/');
int port = _wtoi(Explode(sl.RemoveHead(), sl, '/', 2));
- if(port < 0 || port > 0xffff) return false;
+ 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)))
- {
+ if(FAILED(CAMThread::CallWorker(CMD_RUN))) {
Clear();
return false;
}
clock_t start = clock();
- while(clock() - start < 3000 && m_len < 1000000)
+ while(clock() - start < 3000 && m_len < 1000000) {
Sleep(100);
+ }
return true;
}
@@ -224,9 +233,8 @@ HRESULT CUDPStream::SetPointer(LONGLONG llPos)
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)
- {
+ || !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;
}
@@ -243,25 +251,19 @@ HRESULT CUDPStream::Read(PBYTE pbBuffer, DWORD dwBytesToRead, BOOL bAlign, LPDWO
DWORD len = dwBytesToRead;
BYTE* ptr = pbBuffer;
- while(len > 0 && !m_packets.IsEmpty())
- {
+ while(len > 0 && !m_packets.IsEmpty()) {
POSITION pos = m_packets.GetHeadPosition();
- while(pos && len > 0)
- {
+ while(pos && len > 0) {
packet_t* p = m_packets.GetNext(pos);
- if(p->m_start <= m_pos && m_pos < p->m_end)
- {
+ if(p->m_start <= m_pos && m_pos < p->m_end) {
int size;
- if(m_pos < p->m_start)
- {
+ if(m_pos < p->m_start) {
ASSERT(0);
size = min(len, p->m_start - m_pos);
memset(ptr, 0, size);
- }
- else
- {
+ } else {
size = min(len, p->m_end - m_pos);
memcpy(ptr, &p->m_buff[m_pos - p->m_start], size);
}
@@ -272,17 +274,18 @@ HRESULT CUDPStream::Read(PBYTE pbBuffer, DWORD dwBytesToRead, BOOL bAlign, LPDWO
len -= size;
}
- if(p->m_end <= m_pos - 2048 && BUFF_SIZE_FIRST <= m_pos)
- {
- while(m_packets.GetHeadPosition() != pos)
+ if(p->m_end <= m_pos - 2048 && BUFF_SIZE_FIRST <= m_pos) {
+ while(m_packets.GetHeadPosition() != pos) {
delete m_packets.RemoveHead();
+ }
}
}
}
- if(pdwBytesRead)
+ if(pdwBytesRead) {
*pdwBytesRead = ptr - pbBuffer;
+ }
return S_OK;
}
@@ -290,23 +293,25 @@ HRESULT CUDPStream::Read(PBYTE pbBuffer, DWORD dwBytesToRead, BOOL bAlign, LPDWO
LONGLONG CUDPStream::Size(LONGLONG* pSizeAvailable)
{
CAutoLock cAutoLock(&m_csLock);
- if(pSizeAvailable) *pSizeAvailable = m_len;
+ 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()
@@ -320,32 +325,30 @@ DWORD CUDPStream::ThreadProc()
addr.sin_addr.s_addr = htonl(INADDR_ANY);
addr.sin_port = htons((u_short)m_port);
- ip_mreq imr;
+ 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);
-*/
+ 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)
- {
+ 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)
- {
+ 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)))
- {
+ 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();
+ if(ret < 0) {
+ ret = ::WSAGetLastError();
+ }
ret = ret;
}
}
@@ -354,91 +357,96 @@ DWORD CUDPStream::ThreadProc()
#ifdef _DEBUG
FILE* dump = NULL;
-// dump = _tfopen(_T("c:\\udp.ts"), _T("wb"));
+ // dump = _tfopen(_T("c:\\udp.ts"), _T("wb"));
FILE* log = NULL;
-// log = _tfopen(_T("c:\\udp.txt"), _T("wt"));
+ // log = _tfopen(_T("c:\\udp.txt"), _T("wt"));
#endif
- while(1)
- {
+ while(1) {
DWORD cmd = GetRequest();
- switch(cmd)
- {
- default:
- case CMD_EXIT:
- if(m_socket!=INVALID_SOCKET) {closesocket(m_socket); m_socket = INVALID_SOCKET;}
- WSACleanup();
+ 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);
+ 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;
- }
+ char buff[65536*2];
+ int buffsize = 0;
- int fromlen = sizeof(addr);
- int len = recvfrom(m_socket, &buff[buffsize], 65536, 0, (SOCKADDR*)&addr, &fromlen);
- if(len <= 0) {Sleep(1); continue;}
+ 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(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(log, _T("%04d %2d DUP\n"), pid, counter);
+ }
}
- }
#endif
- buffsize += len;
-
- if(buffsize >= 65536 || m_len == 0)
- {
+ buffsize += len;
+
+ if(buffsize >= 65536 || m_len == 0) {
#ifdef _DEBUG
- if(dump)
- {
- fwrite(buff, buffsize, 1, dump);
- }
+ 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;
- DWORD counter = buff[i+3]&0xf;
- if(pid2counter[pid] != ((counter-1+16)&15))
- _ftprintf(log, _T("%04x %2d -> %2d\n"), pid, pid2counter[pid], counter);
- pid2counter[pid] = counter;
+ 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;
+ DWORD counter = buff[i+3]&0xf;
+ if(pid2counter[pid] != ((counter-1+16)&15)) {
+ _ftprintf(log, _T("%04x %2d -> %2d\n"), pid, pid2counter[pid], counter);
+ }
+ pid2counter[pid] = counter;
+ }
}
- }
#endif
- Append((BYTE*)buff, buffsize);
- buffsize = 0;
+ Append((BYTE*)buff, buffsize);
+ buffsize = 0;
+ }
}
}
- }
- break;
+ break;
}
}
@@ -446,7 +454,7 @@ DWORD CUDPStream::ThreadProc()
return (DWORD)-1;
}
-CUDPStream::packet_t::packet_t(BYTE* p, __int64 start, __int64 end)
+CUDPStream::packet_t::packet_t(BYTE* p, __int64 start, __int64 end)
: m_start(start)
, m_end(end)
{
diff --git a/src/filters/reader/UDPReader/UDPReader.h b/src/filters/reader/UDPReader/UDPReader.h
index 42f778e34..41cd86f03 100644
--- a/src/filters/reader/UDPReader/UDPReader.h
+++ b/src/filters/reader/UDPReader/UDPReader.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -28,15 +28,17 @@
class CUDPStream : public CAsyncStream, public CAMThread
{
private:
- CCritSec m_csLock;
+ CCritSec m_csLock;
class packet_t
{
public:
- BYTE* m_buff;
+ BYTE* m_buff;
__int64 m_start, m_end;
packet_t(BYTE* p, __int64 start, __int64 end);
- virtual ~packet_t() {delete [] m_buff;}
+ virtual ~packet_t() {
+ delete [] m_buff;
+ }
};
int m_port;
@@ -58,18 +60,20 @@ public:
virtual ~CUDPStream();
bool Load(const WCHAR* fnw);
- const GUID& GetSubType() {return m_subtype;}
+ 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();
+ 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
+ CUDPReader
: public CAsyncReader
, public IFileSourceFilter
{
@@ -77,11 +81,11 @@ CUDPReader
CStringW m_fn;
public:
- CUDPReader(IUnknown* pUnk, HRESULT* phr);
+ 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);
diff --git a/src/filters/reader/UDPReader/stdafx.cpp b/src/filters/reader/UDPReader/stdafx.cpp
index 13934d005..bea3f980a 100644
--- a/src/filters/reader/UDPReader/stdafx.cpp
+++ b/src/filters/reader/UDPReader/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/reader/UDPReader/stdafx.h b/src/filters/reader/UDPReader/stdafx.h
index e39f2d6f1..934cd148d 100644
--- a/src/filters/reader/UDPReader/stdafx.h
+++ b/src/filters/reader/UDPReader/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/reader/VTSReader/VTSReader.cpp b/src/filters/reader/VTSReader/VTSReader.cpp
index 9fb53e679..424cc1b90 100644
--- a/src/filters/reader/VTSReader/VTSReader.cpp
+++ b/src/filters/reader/VTSReader/VTSReader.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -26,23 +26,19 @@
#ifdef REGISTER_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
{&MEDIATYPE_Stream, &MEDIASUBTYPE_MPEG2_PROGRAM},
};
-const AMOVIESETUP_PIN sudOpPin[] =
-{
+const AMOVIESETUP_PIN sudOpPin[] = {
{L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesOut), sudPinTypesOut}
};
-const AMOVIESETUP_FILTER sudFilter[] =
-{
+const AMOVIESETUP_FILTER sudFilter[] = {
{&__uuidof(CVTSReader), L"MPC - VTS Reader", MERIT_NORMAL, countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory}
};
-CFactoryTemplate g_Templates[] =
-{
+CFactoryTemplate g_Templates[] = {
{sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CVTSReader>, NULL, &sudFilter[0]}
};
@@ -50,15 +46,16 @@ int g_cTemplates = countof(g_Templates);
STDAPI DllRegisterServer()
{
- if(GetVersion()&0x80000000)
+ if(GetVersion()&0x80000000) {
return E_NOTIMPL;
+ }
SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{773EAEDE-D5EE-4fce-9C8F-C4F53D0A2F73}"),
+ _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("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);
@@ -84,11 +81,14 @@ CFilterApp theApp;
CVTSReader::CVTSReader(IUnknown* pUnk, HRESULT* phr)
: CAsyncReader(NAME("CVTSReader"), pUnk, &m_stream, phr, __uuidof(this))
{
- if(phr) *phr = S_OK;
+ if(phr) {
+ *phr = S_OK;
+ }
- if(GetVersion()&0x80000000)
- {
- if(phr) *phr = E_NOTIMPL;
+ if(GetVersion()&0x80000000) {
+ if(phr) {
+ *phr = E_NOTIMPL;
+ }
return;
}
}
@@ -99,19 +99,20 @@ CVTSReader::~CVTSReader()
STDMETHODIMP CVTSReader::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- return
+ return
QI(IFileSourceFilter)
__super::NonDelegatingQueryInterface(riid, ppv);
}
// IFileSourceFilter
-STDMETHODIMP CVTSReader::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt)
+STDMETHODIMP CVTSReader::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt)
{
- if(!m_stream.Load(pszFileName))
+ if(!m_stream.Load(pszFileName)) {
return E_FAIL;
+ }
m_fn = pszFileName;
@@ -125,11 +126,14 @@ STDMETHODIMP CVTSReader::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt)
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))
+ if(!(*ppszFileName)) {
return E_OUTOFMEMORY;
+ }
wcscpy(*ppszFileName, m_fn);
@@ -168,11 +172,11 @@ HRESULT CVTSStream::Read(PBYTE pbBuffer, DWORD dwBytesToRead, BOOL bAlign, LPDWO
DWORD len = dwBytesToRead;
BYTE* ptr = pbBuffer;
- while(len > 0)
- {
+ while(len > 0) {
BYTE buff[2048];
- if(!m_vob->Read(buff))
+ if(!m_vob->Read(buff)) {
break;
+ }
int size = min(2048 - m_off, min(len, 2048));
@@ -180,15 +184,17 @@ HRESULT CVTSStream::Read(PBYTE pbBuffer, DWORD dwBytesToRead, BOOL bAlign, LPDWO
m_off = (m_off + size)&2047;
- if(m_off > 0)
+ if(m_off > 0) {
m_vob->Seek(m_vob->GetPosition()-1);
+ }
ptr += size;
len -= size;
}
- if(pdwBytesRead)
+ if(pdwBytesRead) {
*pdwBytesRead = ptr - pbBuffer;
+ }
return S_OK;
}
@@ -196,22 +202,24 @@ HRESULT CVTSStream::Read(PBYTE pbBuffer, DWORD dwBytesToRead, BOOL bAlign, LPDWO
LONGLONG CVTSStream::Size(LONGLONG* pSizeAvailable)
{
LONGLONG len = 2048i64*m_vob->GetLength();
- if(pSizeAvailable) *pSizeAvailable = len;
+ 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();
}
diff --git a/src/filters/reader/VTSReader/VTSReader.h b/src/filters/reader/VTSReader/VTSReader.h
index 4326f43aa..bbd963cab 100644
--- a/src/filters/reader/VTSReader/VTSReader.h
+++ b/src/filters/reader/VTSReader/VTSReader.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -30,7 +30,7 @@ class CVobFile;
class CVTSStream : public CAsyncStream
{
private:
- CCritSec m_csLock;
+ CCritSec m_csLock;
CAutoPtr<CVobFile> m_vob;
int m_off;
@@ -41,16 +41,16 @@ public:
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();
+ 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("773EAEDE-D5EE-4fce-9C8F-C4F53D0A2F73"))
-CVTSReader
+ CVTSReader
: public CAsyncReader
, public IFileSourceFilter
{
@@ -58,11 +58,11 @@ CVTSReader
CStringW m_fn;
public:
- CVTSReader(IUnknown* pUnk, HRESULT* phr);
+ CVTSReader(IUnknown* pUnk, HRESULT* phr);
~CVTSReader();
- 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);
diff --git a/src/filters/reader/VTSReader/stdafx.cpp b/src/filters/reader/VTSReader/stdafx.cpp
index 13934d005..bea3f980a 100644
--- a/src/filters/reader/VTSReader/stdafx.cpp
+++ b/src/filters/reader/VTSReader/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/reader/VTSReader/stdafx.h b/src/filters/reader/VTSReader/stdafx.h
index 6188a0bd8..d8d4e35e7 100644
--- a/src/filters/reader/VTSReader/stdafx.h
+++ b/src/filters/reader/VTSReader/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/renderer/MpcAudioRenderer/IMpcAudioRendererFilter.h b/src/filters/renderer/MpcAudioRenderer/IMpcAudioRendererFilter.h
index e4f46fa9b..96bba78b3 100644
--- a/src/filters/renderer/MpcAudioRenderer/IMpcAudioRendererFilter.h
+++ b/src/filters/renderer/MpcAudioRenderer/IMpcAudioRendererFilter.h
@@ -26,12 +26,13 @@
interface __declspec(uuid("495D2C66-D430-439b-9DEE-40F9B7929BBA"))
IMpcAudioRendererFilter :
-public IUnknown
-{
+public IUnknown {
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;
};
diff --git a/src/filters/renderer/MpcAudioRenderer/MpcAudioRenderer.cpp b/src/filters/renderer/MpcAudioRenderer/MpcAudioRenderer.cpp
index 208c8b9db..4399e77fe 100644
--- a/src/filters/renderer/MpcAudioRenderer/MpcAudioRenderer.cpp
+++ b/src/filters/renderer/MpcAudioRenderer/MpcAudioRenderer.cpp
@@ -32,7 +32,6 @@
#include "MpcAudioRenderer.h"
-
// === Compatibility with Windows SDK v6.0A (define in KSMedia.h in Windows 7 SDK or later)
#ifndef STATIC_KSDATAFORMAT_SUBTYPE_IEC61937_DOLBY_DIGITAL
@@ -65,23 +64,19 @@ DEFINE_GUIDSTRUCT("0000000b-0cea-0010-8000-00aa00389b71", KSDATAFORMAT_SUBTYPE_I
#ifdef REGISTER_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
{&GUID_NULL},
};
-const AMOVIESETUP_PIN sudpPins[] =
-{
+const AMOVIESETUP_PIN sudpPins[] = {
{L"Input", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesIn), sudPinTypesIn},
};
-const AMOVIESETUP_FILTER sudFilter[] =
-{
+const AMOVIESETUP_FILTER sudFilter[] = {
{&__uuidof(CMpcAudioRenderer), L"MPC - Audio Renderer", 0x40000001, countof(sudpPins), sudpPins,CLSID_AudioRendererCategory},
};
-CFactoryTemplate g_Templates[] =
-{
+CFactoryTemplate g_Templates[] = {
{sudFilter[0].strName, &__uuidof(CMpcAudioRenderer), CreateInstance<CMpcAudioRenderer>, NULL, &sudFilter[0]},
{L"CMpcAudioRendererPropertyPage", &__uuidof(CMpcAudioRendererSettingsWnd), CreateInstance<CInternalPropertyPageTempl<CMpcAudioRendererSettingsWnd> >},
};
@@ -104,6 +99,27 @@ CFilterApp theApp;
#endif
+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 )
+{
+ 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), NAME("MPC - Audio Renderer"), punk, phr)
, m_pDSBuffer (NULL )
@@ -119,6 +135,7 @@ CMpcAudioRenderer::CMpcAudioRenderer(LPUNKNOWN punk, HRESULT *phr)
, pRenderClient (NULL )
, m_useWASAPI (true )
, m_bMuteFastForward(false)
+ , m_csSound_Device (_T(""))
, nFramesInBuffer (0 )
, hnsPeriod (0 )
, hTask (NULL )
@@ -131,30 +148,40 @@ CMpcAudioRenderer::CMpcAudioRenderer(LPUNKNOWN punk, HRESULT *phr)
HMODULE hLib;
CRegKey key;
- if(ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPC Audio Renderer"), KEY_READ))
- {
+ 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;
+ if(ERROR_SUCCESS == key.QueryDWORDValue(_T("UseWasapi"), dw)) {
+ m_useWASAPI = dw;
+ }
+ if(ERROR_SUCCESS == key.QueryDWORDValue(_T("MuteFastForward"), dw)) {
+ m_bMuteFastForward = dw;
+ }
+ len = sizeof(buff)/sizeof(buff[0]);
+ memset(buff, 0, sizeof(buff));
+ if(ERROR_SUCCESS == key.QueryStringValue(_T("SoundDevice"), buff, &len)) {
+ m_csSound_Device = CString(buff);
+ }
}
m_useWASAPIAfterRestart = m_useWASAPI;
// Load Vista specifics DLLs
hLib = LoadLibrary (L"AVRT.dll");
- if (hLib != NULL)
- {
+ if (hLib != NULL) {
pfAvSetMmThreadCharacteristicsW = (PTR_AvSetMmThreadCharacteristicsW) GetProcAddress (hLib, "AvSetMmThreadCharacteristicsW");
pfAvRevertMmThreadCharacteristics = (PTR_AvRevertMmThreadCharacteristics) GetProcAddress (hLib, "AvRevertMmThreadCharacteristics");
+ } else {
+ m_useWASAPI = false; // Wasapi not available below Vista
}
- else
- m_useWASAPI = false; // Wasapi not available below Vista
- TRACE(_T("CMpcAudioRenderer constructor"));
- if (!m_useWASAPI)
- {
+ TRACE(_T("CMpcAudioRenderer constructor\n"));
+ if (!m_useWASAPI) {
+ DirectSoundEnumerate((LPDSENUMCALLBACK)DSEnumProc2, (VOID*)&m_csSound_Device);
m_pSoundTouch = new soundtouch::SoundTouch();
- *phr = DirectSoundCreate8 (NULL, &m_pDS, NULL);
+ *phr = DirectSoundCreate8 (&lpSoundGUID, &m_pDS, NULL);
}
}
@@ -171,20 +198,17 @@ CMpcAudioRenderer::~CMpcAudioRenderer()
SAFE_RELEASE (pAudioClient);
SAFE_RELEASE (pMMDevice);
- if (m_pReferenceClock)
- {
+ if (m_pReferenceClock) {
SetSyncSource(NULL);
SAFE_RELEASE (m_pReferenceClock);
}
- if (m_pWaveFileFormat)
- {
+ if (m_pWaveFileFormat) {
BYTE *p = (BYTE *)m_pWaveFileFormat;
SAFE_DELETE_ARRAY(p);
}
- if (hTask != NULL && pfAvRevertMmThreadCharacteristics != NULL)
- {
+ if (hTask != NULL && pfAvRevertMmThreadCharacteristics != NULL) {
pfAvRevertMmThreadCharacteristics(hTask);
}
}
@@ -198,42 +222,39 @@ HRESULT CMpcAudioRenderer::CheckInputType(const CMediaType *pmt)
HRESULT CMpcAudioRenderer::CheckMediaType(const CMediaType *pmt)
{
HRESULT hr = S_OK;
- if (pmt == NULL) return E_INVALIDARG;
- TRACE(_T("CMpcAudioRenderer::CheckMediaType"));
+ 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 (pwfx == NULL) {
+ return VFW_E_TYPE_NOT_ACCEPTED;
+ }
if ((pmt->majortype != MEDIATYPE_Audio ) ||
- (pmt->formattype != FORMAT_WaveFormatEx ))
- {
- TRACE(_T("CMpcAudioRenderer::CheckMediaType Not supported"));
+ (pmt->formattype != FORMAT_WaveFormatEx )) {
+ TRACE(_T("CMpcAudioRenderer::CheckMediaType Not supported\n"));
return VFW_E_TYPE_NOT_ACCEPTED;
}
- if(m_useWASAPI)
- {
+ if(m_useWASAPI) {
hr=CheckAudioClient((WAVEFORMATEX *)NULL);
- if (FAILED(hr))
- {
- TRACE(_T("CMpcAudioRenderer::CheckMediaType Error on check audio client"));
+ 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"));
+ 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"));
+ 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"));
- }
- else if (pwfx->wFormatTag != WAVE_FORMAT_PCM)
- {
+ 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;
@@ -241,8 +262,9 @@ HRESULT CMpcAudioRenderer::CheckMediaType(const CMediaType *pmt)
void CMpcAudioRenderer::OnReceiveFirstSample(IMediaSample *pMediaSample)
{
- if (!m_useWASAPI)
+ if (!m_useWASAPI) {
ClearBuffer();
+ }
}
BOOL CMpcAudioRenderer::ScheduleSample(IMediaSample *pMediaSample)
@@ -251,35 +273,39 @@ BOOL CMpcAudioRenderer::ScheduleSample(IMediaSample *pMediaSample)
REFERENCE_TIME EndSample;
// Is someone pulling our leg
- if (pMediaSample == NULL) return FALSE;
+ 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 (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)
- {
+ if (hr == S_OK) {
EXECUTE_ASSERT(SetEvent((HANDLE) m_RenderEvent));
return TRUE;
}
- if (m_dRate <= 1.1)
- {
+ 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
+ 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
@@ -291,37 +317,27 @@ BOOL CMpcAudioRenderer::ScheduleSample(IMediaSample *pMediaSample)
HRESULT CMpcAudioRenderer::DoRenderSample(IMediaSample *pMediaSample)
{
- if (m_useWASAPI)
+ if (m_useWASAPI) {
return DoRenderSampleWasapi(pMediaSample);
- else
+ } else {
return DoRenderSampleDirectSound(pMediaSample);
+ }
}
STDMETHODIMP CMpcAudioRenderer::NonDelegatingQueryInterface(REFIID riid, void **ppv)
{
- if (riid == IID_IReferenceClock)
- {
+ if (riid == IID_IReferenceClock) {
return GetReferenceClockInterface(riid, ppv);
- }
- else if (riid == IID_IDispatch)
- {
+ } else if (riid == IID_IDispatch) {
return GetInterface(static_cast<IDispatch*>(this), ppv);
- }
- else if (riid == IID_IBasicAudio)
- {
+ } else if (riid == IID_IBasicAudio) {
return GetInterface(static_cast<IBasicAudio*>(this), ppv);
- }
- else if (riid == __uuidof(ISpecifyPropertyPages))
- {
+ } else if (riid == __uuidof(ISpecifyPropertyPages)) {
return GetInterface(static_cast<ISpecifyPropertyPages*>(this), ppv);
- }
- else if (riid == __uuidof(ISpecifyPropertyPages2))
- {
+ } else if (riid == __uuidof(ISpecifyPropertyPages2)) {
return GetInterface(static_cast<ISpecifyPropertyPages2*>(this), ppv);
- }
- else if (riid == __uuidof(IMpcAudioRendererFilter))
- {
+ } else if (riid == __uuidof(IMpcAudioRendererFilter)) {
return GetInterface(static_cast<IMpcAudioRendererFilter*>(this), ppv);
}
@@ -330,42 +346,40 @@ STDMETHODIMP CMpcAudioRenderer::NonDelegatingQueryInterface(REFIID riid, void **
HRESULT CMpcAudioRenderer::SetMediaType(const CMediaType *pmt)
{
- if (! pmt) return E_POINTER;
+ if (! pmt) {
+ return E_POINTER;
+ }
int size = 0;
- TRACE(_T("CMpcAudioRenderer::SetMediaType"));
+ TRACE(_T("CMpcAudioRenderer::SetMediaType\n"));
- if (m_useWASAPI)
- {
+ if (m_useWASAPI) {
// New media type set but render client already initialized => reset it
- if (pRenderClient!=NULL)
- {
+ if (pRenderClient!=NULL) {
WAVEFORMATEX *pNewWf = (WAVEFORMATEX *) pmt->Format();
- TRACE(_T("CMpcAudioRenderer::SetMediaType Render client already initialized. Reinitialization..."));
+ TRACE(_T("CMpcAudioRenderer::SetMediaType Render client already initialized. Reinitialization...\n"));
CheckAudioClient(pNewWf);
}
}
- if (m_pWaveFileFormat)
- {
+ if (m_pWaveFileFormat) {
BYTE *p = (BYTE *)m_pWaveFileFormat;
SAFE_DELETE_ARRAY(p);
}
m_pWaveFileFormat=NULL;
WAVEFORMATEX *pwf = (WAVEFORMATEX *) pmt->Format();
- if (pwf!=NULL)
- {
+ if (pwf!=NULL) {
size = sizeof(WAVEFORMATEX) + pwf->cbSize;
m_pWaveFileFormat = (WAVEFORMATEX *)new BYTE[size];
- if (! m_pWaveFileFormat)
+ if (! m_pWaveFileFormat) {
return E_OUTOFMEMORY;
+ }
memcpy(m_pWaveFileFormat, pwf, size);
- if (!m_useWASAPI && m_pSoundTouch && (pwf->nChannels <= 2))
- {
+ if (!m_useWASAPI && m_pSoundTouch && (pwf->nChannels <= 2)) {
m_pSoundTouch->setSampleRate (pwf->nSamplesPerSec);
m_pSoundTouch->setChannels (pwf->nChannels);
m_pSoundTouch->setTempoChange (0);
@@ -379,18 +393,27 @@ HRESULT CMpcAudioRenderer::SetMediaType(const CMediaType *pmt)
HRESULT CMpcAudioRenderer::CompleteConnect(IPin *pReceivePin)
{
HRESULT hr = S_OK;
- TRACE(_T("CMpcAudioRenderer::CompleteConnect"));
+ TRACE(_T("CMpcAudioRenderer::CompleteConnect\n"));
- if (!m_useWASAPI && ! m_pDS) return E_FAIL;
+ if (!m_useWASAPI && ! m_pDS) {
+ return E_FAIL;
+ }
- if (SUCCEEDED(hr)) hr = CBaseRenderer::CompleteConnect(pReceivePin);
- if (SUCCEEDED(hr)) hr = InitCoopLevel();
+ if (SUCCEEDED(hr)) {
+ hr = CBaseRenderer::CompleteConnect(pReceivePin);
+ }
+ if (SUCCEEDED(hr)) {
+ hr = InitCoopLevel();
+ }
- if (!m_useWASAPI)
- {
- if (SUCCEEDED(hr)) hr = CreateDSBuffer();
+ if (!m_useWASAPI) {
+ if (SUCCEEDED(hr)) {
+ hr = CreateDSBuffer();
+ }
+ }
+ if (SUCCEEDED(hr)) {
+ TRACE(_T("CMpcAudioRenderer::CompleteConnect Success\n"));
}
- if (SUCCEEDED(hr)) TRACE(_T("CMpcAudioRenderer::CompleteConnect Success"));
return hr;
}
@@ -398,14 +421,14 @@ STDMETHODIMP CMpcAudioRenderer::Run(REFERENCE_TIME tStart)
{
HRESULT hr;
- if (m_State == State_Running) return NOERROR;
+ if (m_State == State_Running) {
+ return NOERROR;
+ }
- if (m_useWASAPI)
- {
+ if (m_useWASAPI) {
hr=CheckAudioClient(m_pWaveFileFormat);
- if (FAILED(hr))
- {
- TRACE(_T("CMpcAudioRenderer::Run Error on check audio client"));
+ 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
@@ -415,32 +438,28 @@ STDMETHODIMP CMpcAudioRenderer::Run(REFERENCE_TIME tStart)
TRACE(_T("CMpcAudioRenderer::Run Start error"));
return hr;
}*/
- }
- else
- {
+ } else {
if (m_pDSBuffer &&
- m_pPosition &&
- m_pWaveFileFormat &&
- SUCCEEDED(m_pPosition->GetRate(&m_dRate)))
- {
- if (m_dRate < 1.0)
- {
+ 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;
+ 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);
+ }
+ }
}
- 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();
@@ -452,7 +471,9 @@ STDMETHODIMP CMpcAudioRenderer::Run(REFERENCE_TIME tStart)
STDMETHODIMP CMpcAudioRenderer::Stop()
{
- if (m_pDSBuffer) m_pDSBuffer->Stop();
+ if (m_pDSBuffer) {
+ m_pDSBuffer->Stop();
+ }
isAudioClientStarted=false;
return CBaseRenderer::Stop();
@@ -461,8 +482,12 @@ STDMETHODIMP CMpcAudioRenderer::Stop()
STDMETHODIMP CMpcAudioRenderer::Pause()
{
- if (m_pDSBuffer) m_pDSBuffer->Stop();
- if (pAudioClient && isAudioClientStarted) pAudioClient->Stop();
+ if (m_pDSBuffer) {
+ m_pDSBuffer->Stop();
+ }
+ if (pAudioClient && isAudioClientStarted) {
+ pAudioClient->Stop();
+ }
isAudioClientStarted=false;
return CBaseRenderer::Pause();
@@ -493,32 +518,36 @@ STDMETHODIMP CMpcAudioRenderer::Invoke(DISPID dispidMember, REFIID riid, LCID lc
STDMETHODIMP CMpcAudioRenderer::put_Volume(long lVolume)
{
m_lVolume = lVolume;
- if (!m_useWASAPI && m_pDSBuffer)
+ if (!m_useWASAPI && m_pDSBuffer) {
return m_pDSBuffer->SetVolume(lVolume);
+ }
return S_OK;
}
STDMETHODIMP CMpcAudioRenderer::get_Volume(long *plVolume)
{
- if (!m_useWASAPI && m_pDSBuffer)
+ if (!m_useWASAPI && m_pDSBuffer) {
return m_pDSBuffer->GetVolume(plVolume);
+ }
return S_OK;
}
STDMETHODIMP CMpcAudioRenderer::put_Balance(long lBalance)
{
- if (!m_useWASAPI && m_pDSBuffer)
+ if (!m_useWASAPI && m_pDSBuffer) {
return m_pDSBuffer->SetPan(lBalance);
+ }
return S_OK;
}
STDMETHODIMP CMpcAudioRenderer::get_Balance(long *plBalance)
{
- if (!m_useWASAPI && m_pDSBuffer)
+ if (!m_useWASAPI && m_pDSBuffer) {
return m_pDSBuffer->GetPan(plBalance);
+ }
return S_OK;
}
@@ -540,12 +569,13 @@ STDMETHODIMP CMpcAudioRenderer::CreatePage(const GUID& guid, IPropertyPage** ppP
{
CheckPointer(ppPage, E_POINTER);
- if(*ppPage != NULL) return E_INVALIDARG;
+ if(*ppPage != NULL) {
+ return E_INVALIDARG;
+ }
HRESULT hr;
- if(guid == __uuidof(CMpcAudioRendererSettingsWnd))
- {
+ if(guid == __uuidof(CMpcAudioRendererSettingsWnd)) {
(*ppPage = DNew CInternalPropertyPageTempl<CMpcAudioRendererSettingsWnd>(NULL, &hr))->AddRef();
}
@@ -556,10 +586,10 @@ STDMETHODIMP CMpcAudioRenderer::CreatePage(const GUID& guid, IPropertyPage** ppP
STDMETHODIMP CMpcAudioRenderer::Apply()
{
CRegKey key;
- if(ERROR_SUCCESS == key.Create(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPC Audio Renderer")))
- {
+ 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);
}
return S_OK;
@@ -589,22 +619,35 @@ STDMETHODIMP_(BOOL) CMpcAudioRenderer::GetMuteFastForward()
return m_bMuteFastForward;
}
+STDMETHODIMP CMpcAudioRenderer::SetSoundDevice(CString nValue)
+{
+ CAutoLock cAutoLock(&m_csProps);
+ m_csSound_Device = nValue;
+ return S_OK;
+}
+STDMETHODIMP_(CString) CMpcAudioRenderer::GetSoundDevice()
+{
+ CAutoLock cAutoLock(&m_csProps);
+ return m_csSound_Device;
+}
+
HRESULT CMpcAudioRenderer::GetReferenceClockInterface(REFIID riid, void **ppv)
{
HRESULT hr = S_OK;
- if (m_pReferenceClock)
+ if (m_pReferenceClock) {
return m_pReferenceClock->NonDelegatingQueryInterface(riid, ppv);
+ }
m_pReferenceClock = new CBaseReferenceClock (NAME("Mpc Audio Clock"), NULL, &hr);
- if (! m_pReferenceClock)
+ if (! m_pReferenceClock) {
return E_OUTOFMEMORY;
+ }
m_pReferenceClock->AddRef();
hr = SetSyncSource(m_pReferenceClock);
- if (FAILED(hr))
- {
+ if (FAILED(hr)) {
SetSyncSource(NULL);
return hr;
}
@@ -616,9 +659,13 @@ HRESULT CMpcAudioRenderer::GetReferenceClockInterface(REFIID riid, void **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;
@@ -631,7 +678,9 @@ HRESULT CMpcAudioRenderer::EndOfStream(void)
HRESULT CMpcAudioRenderer::CreateDSBuffer()
{
- if (! m_pWaveFileFormat) return E_POINTER;
+ if (! m_pWaveFileFormat) {
+ return E_POINTER;
+ }
HRESULT hr = S_OK;
LPDIRECTSOUNDBUFFER pDSBPrimary = NULL;
@@ -647,8 +696,7 @@ HRESULT CMpcAudioRenderer::CreateDSBuffer()
dsbd.dwFlags = DSBCAPS_PRIMARYBUFFER;
dsbd.dwBufferBytes = 0;
dsbd.lpwfxFormat = NULL;
- if (SUCCEEDED (hr = m_pDS->CreateSoundBuffer( &dsbd, &pDSBPrimary, NULL )))
- {
+ if (SUCCEEDED (hr = m_pDS->CreateSoundBuffer( &dsbd, &pDSBPrimary, NULL ))) {
hr = pDSBPrimary->SetFormat(m_pWaveFileFormat);
ATLASSERT(SUCCEEDED(hr));
SAFE_RELEASE (pDSBPrimary);
@@ -670,13 +718,11 @@ HRESULT CMpcAudioRenderer::CreateDSBuffer()
hr = m_pDS->CreateSoundBuffer (&cDSBufferDesc, &m_pDSBuffer, NULL);
m_nDSBufSize = 0;
- if (SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
bufferCaps.dwSize = sizeof(bufferCaps);
hr = m_pDSBuffer->GetCaps(&bufferCaps);
}
- if (SUCCEEDED (hr))
- {
+ if (SUCCEEDED (hr)) {
m_nDSBufSize = bufferCaps.dwBufferBytes;
hr = ClearBuffer();
m_pDSBuffer->SetFrequency ((long)(m_pWaveFileFormat->nSamplesPerSec * m_dRate));
@@ -693,14 +739,12 @@ HRESULT CMpcAudioRenderer::ClearBuffer()
VOID* pDSLockedBuffer = NULL;
DWORD dwDSLockedSize = 0;
- if (m_pDSBuffer)
- {
+ 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))
- {
+ if (SUCCEEDED (hr)) {
memset (pDSLockedBuffer, 0, dwDSLockedSize);
hr = m_pDSBuffer->Unlock (pDSLockedBuffer, dwDSLockedSize, NULL, NULL);
}
@@ -717,32 +761,29 @@ HRESULT CMpcAudioRenderer::InitCoopLevel()
CComBSTR bstrCaption;
hr = m_pGraph->QueryInterface (__uuidof(IVideoWindow), (void**) &pVideoWindow);
- if (SUCCEEDED (hr))
- {
+ if (SUCCEEDED (hr)) {
pVideoWindow->get_Owner((OAHWND*)&hWnd);
SAFE_RELEASE (pVideoWindow);
}
- if (!hWnd)
- {
+ if (!hWnd) {
hWnd = GetTopWindow(NULL);
}
ATLASSERT(hWnd != NULL);
- if (!m_useWASAPI)
+ if (!m_useWASAPI) {
hr = m_pDS->SetCooperativeLevel(hWnd, DSSCL_PRIORITY);
- else if (hTask == NULL)
- {
+ } 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)
- {
+ if (pfAvSetMmThreadCharacteristicsW) {
hTask = pfAvSetMmThreadCharacteristicsW(TEXT("Pro Audio"), &taskIndex);
- TRACE(_T("CMpcAudioRenderer::InitCoopLevel Putting thread in higher priority for Wasapi mode (lowest latency)"));
+ TRACE(_T("CMpcAudioRenderer::InitCoopLevel Putting thread in higher priority for Wasapi mode (lowest latency)\n"));
hr=GetLastError();
- if (hTask == NULL)
+ if (hTask == NULL) {
return hr;
+ }
}
}
@@ -759,19 +800,20 @@ HRESULT CMpcAudioRenderer::DoRenderSampleDirectSound(IMediaSample *pMediaSample)
hr = m_pDSBuffer->GetStatus(&dwStatus);
- if (SUCCEEDED(hr) && (dwStatus & DSBSTATUS_BUFFERLOST))
+ if (SUCCEEDED(hr) && (dwStatus & DSBSTATUS_BUFFERLOST)) {
hr = m_pDSBuffer->Restore();
+ }
- if ((SUCCEEDED(hr)) && ((dwStatus & DSBSTATUS_PLAYING) != DSBSTATUS_PLAYING))
- {
+ 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)) {
+ hr = m_pDSBuffer->GetCurrentPosition(&dwPlayCursor, &dwWriteCursor);
+ }
- if (SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
if ( ( (dwPlayCursor < dwWriteCursor) &&
(
((m_dwDSWriteOff >= dwPlayCursor) && (m_dwDSWriteOff <= dwWriteCursor))
@@ -783,25 +825,27 @@ HRESULT CMpcAudioRenderer::DoRenderSampleDirectSound(IMediaSample *pMediaSample)
( (dwWriteCursor < dwPlayCursor) &&
(
(m_dwDSWriteOff >= dwPlayCursor) || (m_dwDSWriteOff < dwWriteCursor)
- ) ) )
- {
+ ) ) ) {
m_dwDSWriteOff = dwWriteCursor;
}
- if (m_dwDSWriteOff >= (DWORD)m_nDSBufSize)
- {
+ if (m_dwDSWriteOff >= (DWORD)m_nDSBufSize) {
m_dwDSWriteOff = 0;
}
}
- if (SUCCEEDED(hr)) hr = WriteSampleToDSBuffer(pMediaSample, NULL);
+ if (SUCCEEDED(hr)) {
+ hr = WriteSampleToDSBuffer(pMediaSample, NULL);
+ }
return hr;
}
HRESULT CMpcAudioRenderer::WriteSampleToDSBuffer(IMediaSample *pMediaSample, bool *looped)
{
- if (! m_pDSBuffer) return E_POINTER;
+ if (! m_pDSBuffer) {
+ return E_POINTER;
+ }
REFERENCE_TIME rtStart = 0;
REFERENCE_TIME rtStop = 0;
@@ -814,8 +858,7 @@ HRESULT CMpcAudioRenderer::WriteSampleToDSBuffer(IMediaSample *pMediaSample, boo
hr = pMediaSample->GetPointer(&pMediaBuffer);
- if (m_dRate > 1.0)
- {
+ 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;
@@ -823,8 +866,7 @@ HRESULT CMpcAudioRenderer::WriteSampleToDSBuffer(IMediaSample *pMediaSample, boo
pMediaSample->GetTime (&rtStart, &rtStop);
- if (rtStart < 0)
- {
+ if (rtStart < 0) {
DWORD dwPercent = (DWORD) ((-rtStart * 100) / (rtStop - rtStart));
DWORD dwRemove = (lSize*dwPercent/100);
@@ -833,18 +875,16 @@ HRESULT CMpcAudioRenderer::WriteSampleToDSBuffer(IMediaSample *pMediaSample, boo
lSize -= dwRemove;
}
- if (SUCCEEDED (hr))
+ 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)
- {
+ }
+ if (SUCCEEDED (hr)) {
+ if (pDSLockedBuffers [0] != NULL) {
memcpy(pDSLockedBuffers[0], pMediaBuffer, dwDSLockedSize[0]);
m_dwDSWriteOff += dwDSLockedSize[0];
}
- if (pDSLockedBuffers [1] != NULL)
- {
+ if (pDSLockedBuffers [1] != NULL) {
memcpy(pDSLockedBuffers[1], &pMediaBuffer[dwDSLockedSize[0]], dwDSLockedSize[1]);
m_dwDSWriteOff = dwDSLockedSize[1];
loop = true;
@@ -854,7 +894,9 @@ HRESULT CMpcAudioRenderer::WriteSampleToDSBuffer(IMediaSample *pMediaSample, boo
ATLASSERT (dwDSLockedSize [0] + dwDSLockedSize [1] == (DWORD)lSize);
}
- if (SUCCEEDED(hr) && looped) *looped = loop;
+ if (SUCCEEDED(hr) && looped) {
+ *looped = loop;
+ }
return hr;
}
@@ -877,16 +919,15 @@ HRESULT CMpcAudioRenderer::DoRenderSampleWasapi(IMediaSample *pMediaSample)
pMediaSample->GetTime (&rtStart, &rtStop);
AM_MEDIA_TYPE *pmt;
- if (SUCCEEDED(pMediaSample->GetMediaType(&pmt)) && pmt!=NULL)
- {
+ if (SUCCEEDED(pMediaSample->GetMediaType(&pmt)) && pmt!=NULL) {
CMediaType mt(*pmt);
- if ((WAVEFORMATEXTENSIBLE*)mt.Format() != NULL)
+ if ((WAVEFORMATEXTENSIBLE*)mt.Format() != NULL) {
hr=CheckAudioClient(&(((WAVEFORMATEXTENSIBLE*)mt.Format())->Format));
- else
+ } else {
hr=CheckAudioClient((WAVEFORMATEX*)mt.Format());
- if (FAILED(hr))
- {
- TRACE(_T("CMpcAudioRenderer::DoRenderSampleWasapi Error while checking audio client with input media type"));
+ }
+ if (FAILED(hr)) {
+ TRACE(_T("CMpcAudioRenderer::DoRenderSampleWasapi Error while checking audio client with input media type\n"));
return hr;
}
DeleteMediaType(pmt);
@@ -895,7 +936,9 @@ HRESULT CMpcAudioRenderer::DoRenderSampleWasapi(IMediaSample *pMediaSample)
// Initialization
hr = pMediaSample->GetPointer(&pMediaBuffer);
- if (FAILED (hr)) return hr;
+ if (FAILED (hr)) {
+ return hr;
+ }
pInputBufferPointer=&pMediaBuffer[0];
pInputBufferEnd=&pMediaBuffer[0]+lSize;
@@ -905,15 +948,13 @@ HRESULT CMpcAudioRenderer::DoRenderSampleWasapi(IMediaSample *pMediaSample)
// Sleep for half the buffer duration since last buffer feed
DWORD currentTime=GetTickCount();
- if (lastBufferTime!=0 && hnsActualDuration!= 0 && lastBufferTime<currentTime && (currentTime-lastBufferTime)<hnsActualDuration)
- {
+ 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)
- {
+ while (pInputBufferPointer < pInputBufferEnd) {
UINT32 numFramesPadding=0;
pAudioClient->GetCurrentPadding(&numFramesPadding);
UINT32 numFramesAvailable = nFramesInBuffer - numFramesPadding;
@@ -921,46 +962,40 @@ HRESULT CMpcAudioRenderer::DoRenderSampleWasapi(IMediaSample *pMediaSample)
UINT32 nAvailableBytes=numFramesAvailable*frameSize;
UINT32 nBytesToWrite=nAvailableBytes;
// More room than enough in the output buffer
- if (nAvailableBytes > pInputBufferEnd - pInputBufferPointer)
- {
+ if (nAvailableBytes > 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)"),nFramesInBuffer,hr);
+ 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)
- {
+ if (pData != NULL) {
memcpy(&pData[0], pInputBufferPointer, nBytesToWrite);
pInputBufferPointer += nBytesToWrite;
+ } else {
+ TRACE(_T("CMpcAudioRenderer::DoRenderSampleWasapi Output buffer is NULL\n"));
}
- else
- TRACE(_T("CMpcAudioRenderer::DoRenderSampleWasapi Output buffer is NULL"));
hr = pRenderClient->ReleaseBuffer(numFramesAvailable, 0); // no flags
- if (FAILED (hr))
- {
- TRACE(_T("CMpcAudioRenderer::DoRenderSampleWasapi ReleaseBuffer failed with size %ld (error %lx)"),nFramesInBuffer,hr);
+ 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"));
+ if (!isAudioClientStarted) {
+ TRACE(_T("CMpcAudioRenderer::DoRenderSampleWasapi Starting audio client\n"));
pAudioClient->Start();
isAudioClientStarted=true;
}
- if (pInputBufferPointer >= pInputBufferEnd)
- {
+ if (pInputBufferPointer >= pInputBufferEnd) {
lastBufferTime=GetTickCount();
// This is the duration of the filled buffer
hnsActualDuration=(double)REFTIMES_PER_SEC * numFramesAvailable / m_pWaveFileFormat->nSamplesPerSec;
@@ -982,152 +1017,261 @@ HRESULT CMpcAudioRenderer::CheckAudioClient(WAVEFORMATEX *pWaveFormatEx)
{
HRESULT hr = S_OK;
CAutoLock cAutoLock(&m_csCheck);
- TRACE(_T("CMpcAudioRenderer::CheckAudioClient"));
- if (pMMDevice == NULL) hr=GetDefaultAudioDevice(&pMMDevice);
+ 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;
+ 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);
+ 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))
- {
+ if (CheckFormatChanged(pWaveFormatEx, &pNewWaveFormatEx)) {
// Format has changed, audio client has to be reinitialized
- TRACE(_T("CMpcAudioRenderer::CheckAudioClient Format changed, reinitialize the audio client"));
- if (m_pWaveFileFormat)
- {
+ 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();
+ 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"));
+ 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"));
- }
- else
+ } 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);
+ if (SUCCEEDED (hr)) {
+ hr=InitAudioClient(pWaveFormatEx, pAudioClient, &pRenderClient);
+ }
return hr;
}
-/* Retrieves the default audio device from the Core Audio API
-To be used for WASAPI mode
-TODO : choose a device in the renderer configuration dialogs
-*/
-HRESULT CMpcAudioRenderer::GetDefaultAudioDevice(IMMDevice **ppMMDevice)
+HRESULT CMpcAudioRenderer::GetAvailableAudioDevices(IMMDeviceCollection **ppMMDevices)
{
- HRESULT hr;
- CComPtr<IMMDeviceEnumerator> enumerator;
- TRACE(_T("CMpcAudioRenderer::GetDefaultAudioDevice"));
+ 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;
+}
- hr = enumerator.CoCreateInstance(__uuidof(MMDeviceEnumerator));
- hr = enumerator->GetDefaultAudioEndpoint(eRender, eConsole,
- ppMMDevice);
- return hr;
+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;
}
bool CMpcAudioRenderer::CheckFormatChanged(WAVEFORMATEX *pWaveFormatEx, WAVEFORMATEX **ppNewWaveFormatEx)
{
bool formatChanged=false;
- if (m_pWaveFileFormat==NULL)
+ 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
+ } 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;
+ if (!formatChanged) {
+ return false;
+ }
int size = sizeof(WAVEFORMATEX) + pWaveFormatEx->cbSize; // Always true, even for WAVEFORMATEXTENSIBLE and WAVEFORMATEXTENSIBLE_IEC61937
*ppNewWaveFormatEx = (WAVEFORMATEX *)new BYTE[size];
- if (! *ppNewWaveFormatEx)
+ if (! *ppNewWaveFormatEx) {
return false;
+ }
memcpy(*ppNewWaveFormatEx, pWaveFormatEx, size);
return true;
}
HRESULT CMpcAudioRenderer::GetBufferSize(WAVEFORMATEX *pWaveFormatEx, REFERENCE_TIME *pHnsBufferPeriod)
{
- if (pWaveFormatEx==NULL) return S_OK;
- if (pWaveFormatEx->cbSize <22) //WAVEFORMATEX
+ 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)
+ if (wfext->SubFormat==KSDATAFORMAT_SUBTYPE_IEC61937_DOLBY_MLP) {
bufferSize=61440;
- else if (wfext->SubFormat==KSDATAFORMAT_SUBTYPE_IEC61937_DTS_HD)
+ } else if (wfext->SubFormat==KSDATAFORMAT_SUBTYPE_IEC61937_DTS_HD) {
bufferSize=32768;
- else if (wfext->SubFormat==KSDATAFORMAT_SUBTYPE_IEC61937_DOLBY_DIGITAL_PLUS)
+ } else if (wfext->SubFormat==KSDATAFORMAT_SUBTYPE_IEC61937_DOLBY_DIGITAL_PLUS) {
bufferSize=24576;
- else if (wfext->Format.wFormatTag==WAVE_FORMAT_DOLBY_AC3_SPDIF)
+ } else if (wfext->Format.wFormatTag==WAVE_FORMAT_DOLBY_AC3_SPDIF) {
bufferSize=6144;
- else return S_OK;
+ } 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"),*pHnsBufferPeriod,bufferSize);
+ 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)
{
- TRACE(_T("CMpcAudioRenderer::InitAudioClient"));
+ 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)"), hr);
- else
- TRACE(_T("CMpcAudioRenderer::InitAudioClient format supported"));
+ 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)"), hr);
+ 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 (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"));
+ TRACE(_T("CMpcAudioRenderer::InitAudioClient Buffer size not aligned. Realigning\n"));
// get the buffer size, which will be aligned
hr = pAudioClient->GetBufferSize(&nFramesInBuffer);
@@ -1146,28 +1290,34 @@ HRESULT CMpcAudioRenderer::InitAudioClient(WAVEFORMATEX *pWaveFormatEx, IAudioCl
+ 0.5 // rounding
);
- if (SUCCEEDED (hr)) hr=CreateAudioClient(pMMDevice, &pAudioClient);
+ 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"));
+ 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);
+ if (SUCCEEDED (hr)) {
+ hr = pAudioClient->GetBufferSize(&nFramesInBuffer);
+ }
// calculate the new period
- if (SUCCEEDED (hr)) hr = pAudioClient->GetService(__uuidof(IAudioRenderClient), (void**)(ppRenderClient));
+ if (SUCCEEDED (hr)) {
+ hr = pAudioClient->GetService(__uuidof(IAudioRenderClient), (void**)(ppRenderClient));
+ }
- if (FAILED (hr))
- TRACE(_T("CMpcAudioRenderer::InitAudioClient service initialization failed (0x%08x)"), hr);
- else
- TRACE(_T("CMpcAudioRenderer::InitAudioClient service initialization success"));
+ 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;
}
@@ -1178,26 +1328,27 @@ HRESULT CMpcAudioRenderer::CreateAudioClient(IMMDevice *pMMDevice, IAudioClient
HRESULT hr = S_OK;
hnsPeriod = 0;
- TRACE(_T("CMpcAudioRenderer::CreateAudioClient"));
+ TRACE(_T("CMpcAudioRenderer::CreateAudioClient\n"));
- if (*ppAudioClient)
- {
- if (isAudioClientStarted) (*ppAudioClient)->Stop();
+ if (*ppAudioClient) {
+ if (isAudioClientStarted) {
+ (*ppAudioClient)->Stop();
+ }
SAFE_RELEASE(*ppAudioClient);
isAudioClientStarted=false;
}
- if (pMMDevice==NULL)
- {
- TRACE(_T("CMpcAudioRenderer::CreateAudioClient failed, device not loaded"));
+ 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)"), hr);
- else
- TRACE(_T("CMpcAudioRenderer::CreateAudioClient success"));
+ 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 414dc1df9..4b515f4de 100644
--- a/src/filters/renderer/MpcAudioRenderer/MpcAudioRenderer.h
+++ b/src/filters/renderer/MpcAudioRenderer/MpcAudioRenderer.h
@@ -31,6 +31,7 @@
#include <Avrt.h>
#include <audioclient.h>
#include <Endpointvolume.h>
+#include <Functiondiscoverykeys_devpkey.h>
#include "MpcAudioRendererSettingsWnd.h"
#include "SoundTouch/Include/SoundTouch.h"
@@ -45,9 +46,9 @@
class __declspec(uuid("601D2A2B-9CDE-40bd-8650-0485E3522727"))
CMpcAudioRenderer : public CBaseRenderer
- , public IBasicAudio
- , public ISpecifyPropertyPages2
- , public IMpcAudioRendererFilter
+ , public IBasicAudio
+ , public ISpecifyPropertyPages2
+ , public IMpcAudioRendererFilter
{
public:
CMpcAudioRenderer(LPUNKNOWN punk, HRESULT *phr);
@@ -97,8 +98,10 @@ public:
STDMETHODIMP_(BOOL) GetWasapiMode();
STDMETHODIMP SetMuteFastForward(BOOL nValue);
STDMETHODIMP_(BOOL) GetMuteFastForward();
+ STDMETHODIMP SetSoundDevice(CString nValue);
+ STDMETHODIMP_(CString) GetSoundDevice();
-// CMpcAudioRenderer
+ // CMpcAudioRenderer
private:
HRESULT DoRenderSampleDirectSound(IMediaSample *pMediaSample);
@@ -120,8 +123,9 @@ private:
soundtouch::SoundTouch* m_pSoundTouch;
CCritSec m_csProps;
-// CMpcAudioRenderer WASAPI methods
- HRESULT GetDefaultAudioDevice(IMMDevice **ppMMDevice);
+ // 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);
@@ -130,10 +134,11 @@ private:
HRESULT GetBufferSize(WAVEFORMATEX *pWaveFormatEx, REFERENCE_TIME *pHnsBufferPeriod);
-// WASAPI variables
+ // WASAPI variables
bool m_useWASAPI;
bool m_useWASAPIAfterRestart;
bool m_bMuteFastForward;
+ CString m_csSound_Device;
IMMDevice *pMMDevice;
IAudioClient *pAudioClient;
IAudioRenderClient *pRenderClient;
diff --git a/src/filters/renderer/MpcAudioRenderer/MpcAudioRendererSettingsWnd.cpp b/src/filters/renderer/MpcAudioRenderer/MpcAudioRendererSettingsWnd.cpp
index d934e278f..3459330ed 100644
--- a/src/filters/renderer/MpcAudioRenderer/MpcAudioRendererSettingsWnd.cpp
+++ b/src/filters/renderer/MpcAudioRenderer/MpcAudioRendererSettingsWnd.cpp
@@ -33,12 +33,10 @@
#define LEFT_SPACING 25
#define VERTICAL_SPACING 25
-
CMpcAudioRendererSettingsWnd::CMpcAudioRendererSettingsWnd(void)
{
}
-
bool CMpcAudioRendererSettingsWnd::OnConnect(const CInterfaceList<IUnknown, &IID_IUnknown>& pUnks)
{
ASSERT(!m_pMAR);
@@ -46,9 +44,13 @@ bool CMpcAudioRendererSettingsWnd::OnConnect(const CInterfaceList<IUnknown, &IID
m_pMAR.Release();
POSITION pos = pUnks.GetHeadPosition();
- while(pos && !(m_pMAR = pUnks.GetNext(pos)));
+ while(pos && !(m_pMAR = pUnks.GetNext(pos))) {
+ ;
+ }
- if(!m_pMAR) return false;
+ if(!m_pMAR) {
+ return false;
+ }
return true;
}
@@ -58,23 +60,61 @@ void CMpcAudioRendererSettingsWnd::OnDisconnect()
m_pMAR.Release();
}
+bool CALLBACK DSEnumProc(LPGUID lpGUID,
+ 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);
+}
+
bool CMpcAudioRendererSettingsWnd::OnActivate()
{
int nPosY = 10;
- GUID* DxvaGui = NULL;
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, 315, nPosY+15), this, IDC_PP_WASAPI_MODE);
+ 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, 315, nPosY+15), this, IDC_PP_MUTE_FAST_FORWARD);
+ 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)*/_T("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) 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())
+ for(CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow()) {
pWnd->SetFont(&m_font, FALSE);
+ }
return true;
}
@@ -87,10 +127,15 @@ bool CMpcAudioRendererSettingsWnd::OnApply()
{
OnDeactivate();
- if(m_pMAR)
- {
+ 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();
}
diff --git a/src/filters/renderer/MpcAudioRenderer/MpcAudioRendererSettingsWnd.h b/src/filters/renderer/MpcAudioRenderer/MpcAudioRendererSettingsWnd.h
index c643adca3..bfc95bfc9 100644
--- a/src/filters/renderer/MpcAudioRenderer/MpcAudioRendererSettingsWnd.h
+++ b/src/filters/renderer/MpcAudioRenderer/MpcAudioRendererSettingsWnd.h
@@ -38,10 +38,13 @@ private :
CButton m_cbWasapiMode;
CButton m_cbMuteFastForward;
- enum
- {
+ CStatic m_txtSoundDevice;
+ CComboBox m_cbSoundDevice;
+
+ enum {
IDC_PP_WASAPI_MODE = 10000,
IDC_PP_MUTE_FAST_FORWARD,
+ IDC_PP_SOUND_DEVICE,
};
public:
@@ -54,6 +57,8 @@ public:
void OnDeactivate();
bool OnApply();
+ HRESULT GetAvailableAudioDevices();
+
static LPCTSTR GetWindowTitle() {
return _T("Settings");
}
diff --git a/src/filters/renderer/MpcAudioRenderer/resource.h b/src/filters/renderer/MpcAudioRenderer/resource.h
index 09a3cb7a5..63bead336 100644
--- a/src/filters/renderer/MpcAudioRenderer/resource.h
+++ b/src/filters/renderer/MpcAudioRenderer/resource.h
@@ -19,6 +19,7 @@
#define IDS_MPA_DYNRANGE 33156
#define IDS_ARS_WASAPI_MODE 33436
#define IDS_ARS_MUTE_FAST_FORWARD 33437
+#define IDS_ARS_SOUND_DEVICE 33438
// Next default values for new objects
//
diff --git a/src/filters/renderer/MpcAudioRenderer/stdafx.h b/src/filters/renderer/MpcAudioRenderer/stdafx.h
index 3ea8c1855..964d7222c 100644
--- a/src/filters/renderer/MpcAudioRenderer/stdafx.h
+++ b/src/filters/renderer/MpcAudioRenderer/stdafx.h
@@ -35,4 +35,4 @@
#include <afxwin.h> // MFC core and standard components
#include <streams.h>
#include <dvdmedia.h>
-
+#include <dsound.h>
diff --git a/src/filters/renderer/SyncClock/Interfaces.h b/src/filters/renderer/SyncClock/Interfaces.h
index a4bff0b25..d7be17e73 100644
--- a/src/filters/renderer/SyncClock/Interfaces.h
+++ b/src/filters/renderer/SyncClock/Interfaces.h
@@ -3,8 +3,8 @@
const IID IID_ISyncClock = {0xa62888fb, 0x8e37, 0x44d2, {0x88, 0x50, 0xb3, 0xe3, 0xf2, 0xc1, 0x16, 0x9f}};
MIDL_INTERFACE("A62888FB-8E37-44d2-8850-B3E3F2C1169F")
-ISyncClock: public IUnknown
-{
+ISyncClock:
+public IUnknown {
public:
virtual HRESULT STDMETHODCALLTYPE AdjustClock(DOUBLE adjustment) = 0;
virtual HRESULT STDMETHODCALLTYPE SetBias(DOUBLE bias) = 0;
diff --git a/src/filters/renderer/SyncClock/SyncClock.cpp b/src/filters/renderer/SyncClock/SyncClock.cpp
index 51743b592..fcd760db8 100644
--- a/src/filters/renderer/SyncClock/SyncClock.cpp
+++ b/src/filters/renderer/SyncClock/SyncClock.cpp
@@ -8,13 +8,11 @@
#ifdef REGISTER_FILTER
-const AMOVIESETUP_FILTER sudFilter[] =
-{
+const AMOVIESETUP_FILTER sudFilter[] = {
{&__uuidof(CSyncClockFilter), L"SyncClock", MERIT_NORMAL, 0, NULL, CLSID_LegacyAmFilterCategory}
};
-CFactoryTemplate g_Templates[] =
-{
+CFactoryTemplate g_Templates[] = {
{sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CSyncClockFilter>, NULL, &sudFilter[0]}
};
@@ -22,12 +20,12 @@ 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"
@@ -37,8 +35,8 @@ CFilterApp theApp;
#endif
CSyncClockFilter::CSyncClockFilter(LPUNKNOWN pUnk, HRESULT *phr)
- : CBaseFilter(NAME("SyncClock"), NULL, &m_Lock, CLSID_NULL)
- , m_Clock(static_cast<IBaseFilter*>(this), phr)
+ : CBaseFilter(NAME("SyncClock"), NULL, &m_Lock, CLSID_NULL)
+ , m_Clock(static_cast<IBaseFilter*>(this), phr)
{
}
@@ -73,49 +71,43 @@ STDMETHODIMP CSyncClockFilter::GetStartTime(REFERENCE_TIME *startTime)
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)
{
- 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)
+ : CBaseReferenceClock(NAME("SyncClock"), pUnk, phr)
+ , m_pCurrentRefClock(0), m_pPrevRefClock(0)
{
QueryPerformanceFrequency((LARGE_INTEGER*)&m_llPerfFrequency);
- m_rtPrivateTime = GetTicks100ns();
- m_rtPrevTime = m_rtPrivateTime;
+ 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();
@@ -125,14 +117,13 @@ REFERENCE_TIME CSyncClock::GetPrivateTime()
delta = (REFERENCE_TIME)((DOUBLE)delta * adjustment * bias);
m_rtPrivateTime = m_rtPrivateTime + delta;
- return m_rtPrivateTime;
+ return m_rtPrivateTime;
}
REFERENCE_TIME CSyncClock::GetTicks100ns()
{
LONGLONG i64Ticks100ns;
- if (m_llPerfFrequency != 0)
- {
+ if (m_llPerfFrequency != 0) {
QueryPerformanceCounter((LARGE_INTEGER*)&i64Ticks100ns);
i64Ticks100ns = LONGLONG((double(i64Ticks100ns) * 10000000) / double(m_llPerfFrequency) + 0.5);
return (REFERENCE_TIME)i64Ticks100ns;
diff --git a/src/filters/renderer/SyncClock/SyncClock.h b/src/filters/renderer/SyncClock/SyncClock.h
index 110a318f8..fdb90420e 100644
--- a/src/filters/renderer/SyncClock/SyncClock.h
+++ b/src/filters/renderer/SyncClock/SyncClock.h
@@ -8,37 +8,36 @@ 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()
- {
+ 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;
+ REFERENCE_TIME m_rtPrivateTime;
LONGLONG m_llPerfFrequency;
REFERENCE_TIME m_rtPrevTime;
- CCritSec m_csClock;
- IReferenceClock * m_pCurrentRefClock;
- IReferenceClock * m_pPrevRefClock;
+ 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);
+ CSyncClockFilter(LPUNKNOWN pUnk, HRESULT *phr);
virtual ~CSyncClockFilter();
DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface( REFIID riid, void ** ppv);
+ STDMETHODIMP NonDelegatingQueryInterface( REFIID riid, void ** ppv);
// ISyncClock
STDMETHODIMP AdjustClock(DOUBLE adjustment);
@@ -46,12 +45,12 @@ public:
STDMETHODIMP GetBias(DOUBLE *bias);
STDMETHODIMP GetStartTime(REFERENCE_TIME *startTime);
- // CBaseFilter methods
- int CSyncClockFilter::GetPinCount();
- CBasePin *CSyncClockFilter::GetPin(int iPin);
+ // CBaseFilter methods
+ int CSyncClockFilter::GetPinCount();
+ CBasePin *CSyncClockFilter::GetPin(int iPin);
private:
- CSyncClock m_Clock;
- CCritSec m_Lock;
+ CSyncClock m_Clock;
+ CCritSec m_Lock;
};
diff --git a/src/filters/renderer/SyncClock/stdafx.cpp b/src/filters/renderer/SyncClock/stdafx.cpp
index 8905f2db5..0385cc615 100644
--- a/src/filters/renderer/SyncClock/stdafx.cpp
+++ b/src/filters/renderer/SyncClock/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,15 +6,15 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
diff --git a/src/filters/renderer/SyncClock/stdafx.h b/src/filters/renderer/SyncClock/stdafx.h
index c35359c38..a9f666228 100644
--- a/src/filters/renderer/SyncClock/stdafx.h
+++ b/src/filters/renderer/SyncClock/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,15 +6,15 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
diff --git a/src/filters/renderer/VideoRenderers/AllocatorCommon.cpp b/src/filters/renderer/VideoRenderers/AllocatorCommon.cpp
index fc63325bf..47b2e6ec1 100644
--- a/src/filters/renderer/VideoRenderers/AllocatorCommon.cpp
+++ b/src/filters/renderer/VideoRenderers/AllocatorCommon.cpp
@@ -35,7 +35,9 @@
bool IsVMR9InGraph(IFilterGraph* pFG)
{
BeginEnumFilters(pFG, pEF, pBF)
- if(CComQIPtr<IVMRWindowlessControl9>(pBF)) return(true);
+ if(CComQIPtr<IVMRWindowlessControl9>(pBF)) {
+ return(true);
+ }
EndEnumFilters
return(false);
}
@@ -56,25 +58,24 @@ HRESULT CreateAP9(const CLSID& clsid, HWND hWnd, bool bFullscreen, ISubPicAlloca
|| clsid == CLSID_RM9AllocatorPresenter && !(*ppAP = DNew CRM9AllocatorPresenter(hWnd, bFullscreen, hr, Error))
|| clsid == CLSID_QT9AllocatorPresenter && !(*ppAP = DNew CQT9AllocatorPresenter(hWnd, bFullscreen, hr, Error))
|| clsid == CLSID_DXRAllocatorPresenter && !(*ppAP = DNew CDXRAllocatorPresenter(hWnd, hr, Error))
- || clsid == CLSID_madVRAllocatorPresenter && !(*ppAP = DNew CmadVRAllocatorPresenter(hWnd, bFullscreen, hr, Error)))
+ || clsid == CLSID_madVRAllocatorPresenter && !(*ppAP = DNew CmadVRAllocatorPresenter(hWnd, bFullscreen, hr, Error))) {
return E_OUTOFMEMORY;
+ }
- if(*ppAP == NULL)
+ if(*ppAP == NULL) {
return E_FAIL;
+ }
(*ppAP)->AddRef();
- if(FAILED(hr))
- {
+ 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())
- {
+ } else if (!Error.IsEmpty()) {
MessageBox(hWnd, Error, L"Warning creating DX9 allocation presenter", MB_OK|MB_ICONWARNING);
}
@@ -84,22 +85,18 @@ HRESULT CreateAP9(const CLSID& clsid, HWND hWnd, bool bFullscreen, ISubPicAlloca
HRESULT CreateEVR(const CLSID& clsid, HWND hWnd, bool bFullscreen, ISubPicAllocatorPresenter** ppAP)
{
HRESULT hr = E_FAIL;
- if (clsid == CLSID_EVRAllocatorPresenter)
- {
+ if (clsid == CLSID_EVRAllocatorPresenter) {
CString Error;
*ppAP = DNew DSObjects::CEVRAllocatorPresenter(hWnd, bFullscreen, hr, Error);
(*ppAP)->AddRef();
- if(FAILED(hr))
- {
+ 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())
- {
+ } else if (!Error.IsEmpty()) {
MessageBox(hWnd, Error, L"Warning creating EVR Custom renderer", MB_OK|MB_ICONWARNING);
}
}
@@ -110,75 +107,73 @@ HRESULT CreateEVR(const CLSID& clsid, HWND hWnd, bool bFullscreen, ISubPicAlloca
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))
- {
+ _Module, _Error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpMsgBuf, 0, NULL)) {
errmsg = (LPCTSTR)lpMsgBuf;
LocalFree(lpMsgBuf);
}
@@ -189,134 +184,133 @@ CString GetWindowsErrorMessage(HRESULT _Error, HMODULE _Module)
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";
+ 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 6a57a06f8..fd0ea9091 100644
--- a/src/filters/renderer/VideoRenderers/AllocatorCommon.h
+++ b/src/filters/renderer/VideoRenderers/AllocatorCommon.h
@@ -70,8 +70,7 @@ DEFINE_GUID(IID_IVMRffdshow9,
MIDL_INTERFACE("A273C7F6-25D4-46b0-B2C8-4F7FADC44E37")
IVMRffdshow9 :
-public IUnknown
-{
+public IUnknown {
public:
virtual STDMETHODIMP support_ffdshow(void) = 0;
};
diff --git a/src/filters/renderer/VideoRenderers/AllocatorCommon7.cpp b/src/filters/renderer/VideoRenderers/AllocatorCommon7.cpp
index eac9d6ad3..5ccb89a19 100644
--- a/src/filters/renderer/VideoRenderers/AllocatorCommon7.cpp
+++ b/src/filters/renderer/VideoRenderers/AllocatorCommon7.cpp
@@ -35,7 +35,9 @@
bool IsVMR7InGraph(IFilterGraph* pFG)
{
BeginEnumFilters(pFG, pEF, pBF)
- if(CComQIPtr<IVMRWindowlessControl>(pBF)) return(true);
+ if(CComQIPtr<IVMRWindowlessControl>(pBF)) {
+ return(true);
+ }
EndEnumFilters
return(false);
}
@@ -53,16 +55,17 @@ HRESULT CreateAP7(const CLSID& clsid, HWND hWnd, ISubPicAllocatorPresenter** ppA
HRESULT hr = S_OK;
if(clsid == CLSID_VMR7AllocatorPresenter && !(*ppAP = DNew CVMR7AllocatorPresenter(hWnd, hr))
|| clsid == CLSID_RM7AllocatorPresenter && !(*ppAP = DNew CRM7AllocatorPresenter(hWnd, hr))
- || clsid == CLSID_QT7AllocatorPresenter && !(*ppAP = DNew CQT7AllocatorPresenter(hWnd, hr)))
+ || clsid == CLSID_QT7AllocatorPresenter && !(*ppAP = DNew CQT7AllocatorPresenter(hWnd, hr))) {
return E_OUTOFMEMORY;
+ }
- if(*ppAP == NULL)
+ if(*ppAP == NULL) {
return E_FAIL;
+ }
(*ppAP)->AddRef();
- if(FAILED(hr))
- {
+ if(FAILED(hr)) {
(*ppAP)->Release();
*ppAP = NULL;
}
diff --git a/src/filters/renderer/VideoRenderers/D3DFont.cpp b/src/filters/renderer/VideoRenderers/D3DFont.cpp
index 49c5293b8..46d9fdbc7 100644
--- a/src/filters/renderer/VideoRenderers/D3DFont.cpp
+++ b/src/filters/renderer/VideoRenderers/D3DFont.cpp
@@ -39,14 +39,12 @@
//-----------------------------------------------------------------------------
#define MAX_NUM_VERTICES 50*6
-struct FONT2DVERTEX
-{
+struct FONT2DVERTEX {
D3DXVECTOR4 p;
DWORD color;
FLOAT tu, tv;
};
-struct FONT3DVERTEX
-{
+struct FONT3DVERTEX {
D3DXVECTOR3 p;
D3DXVECTOR3 n;
FLOAT tu, tv;
@@ -136,8 +134,9 @@ HRESULT CD3DFont::CreateGDIFont( HDC hDC, HFONT* pFont )
CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY,
VARIABLE_PITCH, m_strFontName );
- if( *pFont == NULL )
+ if( *pFont == NULL ) {
return E_FAIL;
+ }
return S_OK;
}
@@ -157,8 +156,9 @@ HRESULT CD3DFont::PaintAlphabet( HDC hDC, BOOL bMeasureOnly )
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 ) )
+ 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
@@ -166,27 +166,27 @@ HRESULT CD3DFont::PaintAlphabet( HDC hDC, BOOL bMeasureOnly )
DWORD y = 0;
// For each character, draw text on the DC and advance the current position
- for( char c = 32; c < 127; c++ )
- {
+ for( char c = 32; c < 127; c++ ) {
str[0] = c;
- if( 0 == GetTextExtentPoint32( hDC, str, 1, &size ) )
+ if( 0 == GetTextExtentPoint32( hDC, str, 1, &size ) ) {
return E_FAIL;
+ }
- if( (DWORD)(x + size.cx + m_dwSpacing) > m_dwTexWidth )
- {
+ 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 )
+ if( y + size.cy > m_dwTexHeight ) {
return D3DERR_MOREDATA;
+ }
- if( !bMeasureOnly )
- {
+ if( !bMeasureOnly ) {
// Perform the actual drawing
- if( 0 == ExtTextOut( hDC, x+0, y+0, ETO_OPAQUE, NULL, str, 1, NULL ) )
+ 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;
@@ -229,55 +229,55 @@ HRESULT CD3DFont::InitDeviceObjects( LPDIRECT3DDEVICE9 pd3dDevice )
SetMapMode( hDC, MM_TEXT );
hr = CreateGDIFont( hDC, &hFont );
- if( FAILED(hr) )
+ 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 ) ) )
- {
+ while( D3DERR_MOREDATA == ( hr = PaintAlphabet( hDC, true ) ) ) {
m_dwTexWidth *= 2;
m_dwTexHeight *= 2;
}
- if( FAILED(hr) )
+ 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 )
- {
+ 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
- {
+ do {
// If we've already tried fitting the new text, the scale is still
// too large. Reduce and try again.
- if( !bFirstRun)
+ 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) )
+ if( FAILED(hr) ) {
goto LCleanReturn;
+ }
hFontOld = (HFONT) SelectObject( hDC, hFont );
bFirstRun = false;
- }
- while( D3DERR_MOREDATA == ( hr = PaintAlphabet( hDC, true ) ) );
+ } while( D3DERR_MOREDATA == ( hr = PaintAlphabet( hDC, true ) ) );
}
@@ -285,8 +285,9 @@ HRESULT CD3DFont::InitDeviceObjects( LPDIRECT3DDEVICE9 pd3dDevice )
hr = m_pd3dDevice->CreateTexture( m_dwTexWidth, m_dwTexHeight, 1,
0, D3DFMT_A4R4G4B4,
D3DPOOL_MANAGED, &m_pTexture, NULL );
- if( FAILED(hr) )
+ if( FAILED(hr) ) {
goto LCleanReturn;
+ }
// Prepare to create a bitmap
DWORD* pBitmapBits;
@@ -312,8 +313,9 @@ HRESULT CD3DFont::InitDeviceObjects( LPDIRECT3DDEVICE9 pd3dDevice )
// Paint the alphabet onto the selected bitmap
hr = PaintAlphabet( hDC, false );
- if( FAILED(hr) )
+ if( FAILED(hr) ) {
goto LCleanReturn;
+ }
// Lock the surface and write the alpha values for the set pixels
D3DLOCKED_RECT d3dlr;
@@ -324,18 +326,13 @@ HRESULT CD3DFont::InitDeviceObjects( LPDIRECT3DDEVICE9 pd3dDevice )
BYTE bAlpha; // 4-bit measure of pixel intensity
DWORD x, y;
- for( y=0; y < m_dwTexHeight; y++ )
- {
+ for( y=0; y < m_dwTexHeight; y++ ) {
pDst16 = (WORD*)pDstRow;
- for( x=0; x < m_dwTexWidth; x++ )
- {
+ for( x=0; x < m_dwTexWidth; x++ ) {
bAlpha = (BYTE)((pBitmapBits[m_dwTexWidth*y + x] & 0xff) >> 4);
- if (bAlpha > 0)
- {
+ if (bAlpha > 0) {
*pDst16++ = (WORD) ((bAlpha << 12) | 0x0fff);
- }
- else
- {
+ } else {
*pDst16++ = 0x0000;
}
}
@@ -346,8 +343,9 @@ HRESULT CD3DFont::InitDeviceObjects( LPDIRECT3DDEVICE9 pd3dDevice )
// Done updating texture, so clean up used objects
LCleanReturn:
- if( m_pTexture )
+ if( m_pTexture ) {
m_pTexture->UnlockRect(0);
+ }
SelectObject( hDC, hbmOld );
SelectObject( hDC, hFontOld );
@@ -373,28 +371,24 @@ HRESULT CD3DFont::RestoreDeviceObjects()
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 ) ) )
- {
+ D3DPOOL_DEFAULT, &m_pVB, NULL ) ) ) {
return hr;
}
bool bSupportsAlphaBlend = true;
LPDIRECT3D9 pd3d9 = NULL;
- if( SUCCEEDED( m_pd3dDevice->GetDirect3D( &pd3d9 ) ) )
- {
+ 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 ) ) )
- {
+ 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 ) ) )
- {
+ Desc.Format ) ) ) {
bSupportsAlphaBlend = false;
}
SAFE_RELEASE( pSurf );
@@ -403,24 +397,21 @@ HRESULT CD3DFont::RestoreDeviceObjects()
}
// Create the state blocks for rendering text
- for( UINT which=0; which<2; which++ )
- {
+ for( UINT which=0; which<2; which++ ) {
m_pd3dDevice->BeginStateBlock();
m_pd3dDevice->SetTexture( 0, m_pTexture );
- if ( D3DFONT_ZENABLE & m_dwFontFlags )
+ if ( D3DFONT_ZENABLE & m_dwFontFlags ) {
m_pd3dDevice->SetRenderState( D3DRS_ZENABLE, TRUE );
- else
+ } else {
m_pd3dDevice->SetRenderState( D3DRS_ZENABLE, FALSE );
+ }
- if( bSupportsAlphaBlend )
- {
+ if( bSupportsAlphaBlend ) {
m_pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
m_pd3dDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );
m_pd3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );
- }
- else
- {
+ } else {
m_pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE );
}
m_pd3dDevice->SetRenderState( D3DRS_ALPHATESTENABLE, TRUE );
@@ -451,10 +442,11 @@ HRESULT CD3DFont::RestoreDeviceObjects()
m_pd3dDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_POINT );
m_pd3dDevice->SetSamplerState( 0, D3DSAMP_MIPFILTER, D3DTEXF_NONE );
- if( which==0 )
+ if( which==0 ) {
m_pd3dDevice->EndStateBlock( &m_pStateBlockSaved );
- else
+ } else {
m_pd3dDevice->EndStateBlock( &m_pStateBlockDrawText );
+ }
}
return S_OK;
@@ -500,34 +492,35 @@ HRESULT CD3DFont::DeleteDeviceObjects()
//-----------------------------------------------------------------------------
HRESULT CD3DFont::GetTextExtent( const TCHAR* strText, SIZE* pSize )
{
- if( NULL==strText || NULL==pSize )
+ 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;
- while( *strText )
- {
+ while( *strText ) {
TCHAR c = *strText++;
- if( c == _T('\n') )
- {
+ if( c == _T('\n') ) {
fRowWidth = 0.0f;
fHeight += fRowHeight;
}
- if( (c-32) < 0 || (c-32) >= 128-32 )
+ if( (c-32) < 0 || (c-32) >= 128-32 ) {
continue;
+ }
FLOAT tx1 = m_fTexCoords[c-32][0];
FLOAT tx2 = m_fTexCoords[c-32][2];
fRowWidth += (tx2-tx1)*m_dwTexWidth - 2*m_dwSpacing;
- if( fRowWidth > fWidth )
+ if( fRowWidth > fWidth ) {
fWidth = fRowWidth;
+ }
}
pSize->cx = (int)fWidth;
@@ -551,8 +544,9 @@ HRESULT CD3DFont::DrawTextScaled( FLOAT x, FLOAT y, FLOAT z,
FLOAT fXScale, FLOAT fYScale, DWORD dwColor,
const TCHAR* strText, DWORD dwFlags )
{
- if( m_pd3dDevice == NULL )
+ if( m_pd3dDevice == NULL ) {
return E_FAIL;
+ }
// Set up renderstate
m_pStateBlockSaved->Capture();
@@ -562,8 +556,7 @@ HRESULT CD3DFont::DrawTextScaled( FLOAT x, FLOAT y, FLOAT z,
m_pd3dDevice->SetStreamSource( 0, m_pVB, 0, sizeof(FONT2DVERTEX) );
// Set filter states
- if( dwFlags & D3DFONT_FILTERED )
- {
+ if( dwFlags & D3DFONT_FILTERED ) {
m_pd3dDevice->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
m_pd3dDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
}
@@ -573,19 +566,19 @@ HRESULT CD3DFont::DrawTextScaled( FLOAT x, FLOAT y, FLOAT z,
FLOAT fLineHeight = ( m_fTexCoords[0][3] - m_fTexCoords[0][1] ) * m_dwTexHeight;
// Center the text block in the viewport
- if( dwFlags & D3DFONT_CENTERED_X )
- {
+ if( dwFlags & D3DFONT_CENTERED_X ) {
const TCHAR* strTextTmp = strText;
float xFinal = 0.0f;
- while( *strTextTmp )
- {
+ while( *strTextTmp ) {
TCHAR c = *strTextTmp++;
- if( c == _T('\n') )
- break; // Isn't supported.
- if( (c-32) < 0 || (c-32) >= 128-32 )
+ 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];
@@ -599,8 +592,7 @@ HRESULT CD3DFont::DrawTextScaled( FLOAT x, FLOAT y, FLOAT z,
x = -xFinal/vp.Width;
}
- if( dwFlags & D3DFONT_CENTERED_Y )
- {
+ if( dwFlags & D3DFONT_CENTERED_Y ) {
y = -fLineHeight/vp.Height;
}
@@ -618,18 +610,17 @@ HRESULT CD3DFont::DrawTextScaled( FLOAT x, FLOAT y, FLOAT z,
DWORD dwNumTriangles = 0L;
m_pVB->Lock( 0, 0, (void**)&pVertices, D3DLOCK_DISCARD );
- while( *strText )
- {
+ while( *strText ) {
TCHAR c = *strText++;
- if( c == _T('\n') )
- {
+ if( c == _T('\n') ) {
sx = fStartX;
sy += fYScale*vp.Height;
}
- if( (c-32) < 0 || (c-32) >= 128-32 )
+ if( (c-32) < 0 || (c-32) >= 128-32 ) {
continue;
+ }
FLOAT tx1 = m_fTexCoords[c-32][0];
FLOAT ty1 = m_fTexCoords[c-32][1];
@@ -642,8 +633,7 @@ HRESULT CD3DFont::DrawTextScaled( FLOAT x, FLOAT y, FLOAT z,
w *= (fXScale*vp.Height)/fLineHeight;
h *= (fYScale*vp.Height)/fLineHeight;
- if( c != _T(' ') )
- {
+ 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 );
@@ -652,8 +642,7 @@ HRESULT CD3DFont::DrawTextScaled( FLOAT x, FLOAT y, FLOAT z,
*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) )
- {
+ if( dwNumTriangles*3 > (MAX_NUM_VERTICES-6) ) {
// Unlock, render, and relock the vertex buffer
m_pVB->Unlock();
m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, dwNumTriangles );
@@ -667,8 +656,9 @@ HRESULT CD3DFont::DrawTextScaled( FLOAT x, FLOAT y, FLOAT z,
// Unlock and render the vertex buffer
m_pVB->Unlock();
- if( dwNumTriangles > 0 )
+ if( dwNumTriangles > 0 ) {
m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, dwNumTriangles );
+ }
// Restore the modified renderstates
m_pStateBlockSaved->Apply();
@@ -686,8 +676,9 @@ HRESULT CD3DFont::DrawTextScaled( FLOAT x, FLOAT y, FLOAT z,
HRESULT CD3DFont::DrawText( FLOAT sx, FLOAT sy, DWORD dwColor,
const TCHAR* strText, DWORD dwFlags )
{
- if( m_pd3dDevice == NULL )
+ if( m_pd3dDevice == NULL ) {
return E_FAIL;
+ }
// Setup renderstate
m_pStateBlockSaved->Capture();
@@ -697,28 +688,27 @@ HRESULT CD3DFont::DrawText( FLOAT sx, FLOAT sy, DWORD dwColor,
m_pd3dDevice->SetStreamSource( 0, m_pVB, 0, sizeof(FONT2DVERTEX) );
// Set filter states
- if( dwFlags & D3DFONT_FILTERED )
- {
+ 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 )
- {
+ if( dwFlags & D3DFONT_CENTERED_X ) {
D3DVIEWPORT9 vp;
m_pd3dDevice->GetViewport( &vp );
const TCHAR* strTextTmp = strText;
float xFinal = 0.0f;
- while( *strTextTmp )
- {
+ while( *strTextTmp ) {
TCHAR c = *strTextTmp++;
- if( c == _T('\n') )
- break; // Isn't supported.
- if( (c-32) < 0 || (c-32) >= 128-32 )
+ 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];
@@ -730,8 +720,7 @@ HRESULT CD3DFont::DrawText( FLOAT sx, FLOAT sy, DWORD dwColor,
sx = (vp.Width-xFinal)/2.0f;
}
- if( dwFlags & D3DFONT_CENTERED_Y )
- {
+ if( dwFlags & D3DFONT_CENTERED_Y ) {
D3DVIEWPORT9 vp;
m_pd3dDevice->GetViewport( &vp );
float fLineHeight = ((m_fTexCoords[0][3]-m_fTexCoords[0][1])*m_dwTexHeight);
@@ -747,18 +736,17 @@ HRESULT CD3DFont::DrawText( FLOAT sx, FLOAT sy, DWORD dwColor,
DWORD dwNumTriangles = 0;
m_pVB->Lock( 0, 0, (void**)&pVertices, D3DLOCK_DISCARD );
- while( *strText )
- {
+ while( *strText ) {
TCHAR c = *strText++;
- if( c == _T('\n') )
- {
+ 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 )
+ if( (c-32) < 0 || (c-32) >= 128-32 ) {
continue;
+ }
FLOAT tx1 = m_fTexCoords[c-32][0];
FLOAT ty1 = m_fTexCoords[c-32][1];
@@ -768,8 +756,7 @@ HRESULT CD3DFont::DrawText( FLOAT sx, FLOAT sy, DWORD dwColor,
FLOAT w = (tx2-tx1) * m_dwTexWidth / m_fTextScale;
FLOAT h = (ty2-ty1) * m_dwTexHeight / m_fTextScale;
- if( c != _T(' ') )
- {
+ 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 );
@@ -778,8 +765,7 @@ HRESULT CD3DFont::DrawText( FLOAT sx, FLOAT sy, DWORD dwColor,
*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) )
- {
+ if( dwNumTriangles*3 > (MAX_NUM_VERTICES-6) ) {
// Unlock, render, and relock the vertex buffer
m_pVB->Unlock();
m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, dwNumTriangles );
@@ -794,8 +780,9 @@ HRESULT CD3DFont::DrawText( FLOAT sx, FLOAT sy, DWORD dwColor,
// Unlock and render the vertex buffer
m_pVB->Unlock();
- if( dwNumTriangles > 0 )
+ if( dwNumTriangles > 0 ) {
m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, dwNumTriangles );
+ }
// Restore the modified renderstates
m_pStateBlockSaved->Apply();
@@ -812,8 +799,9 @@ HRESULT CD3DFont::DrawText( FLOAT sx, FLOAT sy, DWORD dwColor,
//-----------------------------------------------------------------------------
HRESULT CD3DFont::Render3DText( const TCHAR* strText, DWORD dwFlags )
{
- if( m_pd3dDevice == NULL )
+ if( m_pd3dDevice == NULL ) {
return E_FAIL;
+ }
// Setup renderstate
m_pStateBlockSaved->Capture();
@@ -823,8 +811,7 @@ HRESULT CD3DFont::Render3DText( const TCHAR* strText, DWORD dwFlags )
m_pd3dDevice->SetStreamSource( 0, m_pVB, 0, sizeof(FONT3DVERTEX) );
// Set filter states
- if( dwFlags & D3DFONT_FILTERED )
- {
+ if( dwFlags & D3DFONT_FILTERED ) {
m_pd3dDevice->SetSamplerState( 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
m_pd3dDevice->SetSamplerState( 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
}
@@ -834,22 +821,21 @@ HRESULT CD3DFont::Render3DText( const TCHAR* strText, DWORD dwFlags )
FLOAT y = 0.0f;
// Center the text block at the origin (not the viewport)
- if( dwFlags & D3DFONT_CENTERED_X )
- {
+ if( dwFlags & D3DFONT_CENTERED_X ) {
SIZE sz;
GetTextExtent( strText, &sz );
x = -(((FLOAT)sz.cx)/10.0f)/2.0f;
}
- if( dwFlags & D3DFONT_CENTERED_Y )
- {
+ 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 )
+ if( dwFlags & D3DFONT_TWOSIDED ) {
m_pd3dDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE );
+ }
// Adjust for character spacing
x -= m_dwSpacing / 10.0f;
@@ -861,16 +847,15 @@ HRESULT CD3DFont::Render3DText( const TCHAR* strText, DWORD dwFlags )
DWORD dwNumTriangles = 0L;
m_pVB->Lock( 0, 0, (void**)&pVertices, D3DLOCK_DISCARD );
- while( (c = *strText++) != 0 )
- {
- if( c == '\n' )
- {
+ 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 )
+ if( (c-32) < 0 || (c-32) >= 128-32 ) {
continue;
+ }
FLOAT tx1 = m_fTexCoords[c-32][0];
FLOAT ty1 = m_fTexCoords[c-32][1];
@@ -880,8 +865,7 @@ HRESULT CD3DFont::Render3DText( const TCHAR* strText, DWORD dwFlags )
FLOAT w = (tx2-tx1) * m_dwTexWidth / ( 10.0f * m_fTextScale );
FLOAT h = (ty2-ty1) * m_dwTexHeight / ( 10.0f * m_fTextScale );
- if( c != _T(' ') )
- {
+ 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 );
@@ -890,8 +874,7 @@ HRESULT CD3DFont::Render3DText( const TCHAR* strText, DWORD dwFlags )
*pVertices++ = InitFont3DVertex( D3DXVECTOR3(x+0,y+h,0), D3DXVECTOR3(0,0,-1), tx1, ty1 );
dwNumTriangles += 2;
- if( dwNumTriangles*3 > (MAX_NUM_VERTICES-6) )
- {
+ if( dwNumTriangles*3 > (MAX_NUM_VERTICES-6) ) {
// Unlock, render, and relock the vertex buffer
m_pVB->Unlock();
m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, dwNumTriangles );
@@ -905,8 +888,9 @@ HRESULT CD3DFont::Render3DText( const TCHAR* strText, DWORD dwFlags )
// Unlock and render the vertex buffer
m_pVB->Unlock();
- if( dwNumTriangles > 0 )
+ if( dwNumTriangles > 0 ) {
m_pd3dDevice->DrawPrimitive( D3DPT_TRIANGLELIST, 0, dwNumTriangles );
+ }
// Restore the modified renderstates
m_pStateBlockSaved->Apply();
diff --git a/src/filters/renderer/VideoRenderers/DX7AllocatorPresenter.cpp b/src/filters/renderer/VideoRenderers/DX7AllocatorPresenter.cpp
index a57bdcca6..c3fed705f 100644
--- a/src/filters/renderer/VideoRenderers/DX7AllocatorPresenter.cpp
+++ b/src/filters/renderer/VideoRenderers/DX7AllocatorPresenter.cpp
@@ -34,37 +34,35 @@ using namespace DSObjects;
static HRESULT TextureBlt(IDirect3DDevice7* pD3DDev, IDirectDrawSurface7* pTexture, Vector dst[4], CRect src)
{
- if(!pTexture)
+ if(!pTexture) {
return E_POINTER;
+ }
ASSERT(pD3DDev);
HRESULT hr;
- do
- {
+ do {
DDSURFACEDESC2 ddsd;
INITDDSTRUCT(ddsd);
- if(FAILED(hr = pTexture->GetSurfaceDesc(&ddsd)))
+ if(FAILED(hr = pTexture->GetSurfaceDesc(&ddsd))) {
break;
+ }
float w = (float)ddsd.dwWidth;
float h = (float)ddsd.dwHeight;
- struct
- {
+ struct {
float x, y, z, rhw;
float tu, tv;
}
- pVertices[] =
- {
+ 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++)
- {
+ for(int i = 0; i < countof(pVertices); i++) {
pVertices[i].x -= 0.5;
pVertices[i].y -= 0.5;
}
@@ -84,8 +82,9 @@ static HRESULT TextureBlt(IDirect3DDevice7* pD3DDev, IDirectDrawSurface7* pTextu
//
- if(FAILED(hr = pD3DDev->BeginScene()))
+ if(FAILED(hr = pD3DDev->BeginScene())) {
break;
+ }
hr = pD3DDev->DrawPrimitive(D3DPT_TRIANGLESTRIP,
D3DFVF_XYZRHW | D3DFVF_TEX1,
@@ -97,8 +96,7 @@ static HRESULT TextureBlt(IDirect3DDevice7* pD3DDev, IDirectDrawSurface7* pTextu
pD3DDev->SetTexture(0, NULL);
return S_OK;
- }
- while(0);
+ } while(0);
return E_FAIL;
}
@@ -114,32 +112,34 @@ CDX7AllocatorPresenter::CDX7AllocatorPresenter(HWND hWnd, HRESULT& hr)
: CSubPicAllocatorPresenterImpl(hWnd, hr, NULL)
, m_ScreenSize(0, 0)
{
- if(FAILED(hr)) return;
+ 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)
- {
+ 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)))
+ || FAILED(hr = m_pDD->SetCooperativeLevel(AfxGetMainWnd()->GetSafeHwnd(), DDSCL_NORMAL))) {
return;
+ }
- if(!(m_pD3D = m_pDD))
- {
+ if(!(m_pD3D = m_pDD)) {
hr = E_NOINTERFACE;
return;
}
hr = CreateDevice();
- if (FAILED(hr))
- {
+ if (FAILED(hr)) {
TRACE("CreateDevice failed: 0x%08x\n", (LONG)hr);
}
}
@@ -154,8 +154,9 @@ HRESULT CDX7AllocatorPresenter::CreateDevice()
DDSURFACEDESC2 ddsd;
INITDDSTRUCT(ddsd);
if(FAILED(m_pDD->GetDisplayMode(&ddsd)) ||
- ddsd.ddpfPixelFormat.dwRGBBitCount <= 8)
+ ddsd.ddpfPixelFormat.dwRGBBitCount <= 8) {
return DDERR_INVALIDMODE;
+ }
m_ScreenSize.SetSize(ddsd.dwWidth, ddsd.dwHeight);
@@ -166,12 +167,14 @@ HRESULT CDX7AllocatorPresenter::CreateDevice()
INITDDSTRUCT(ddsd);
ddsd.dwFlags = DDSD_CAPS;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
- if(FAILED(hr = m_pDD->CreateSurface(&ddsd, &m_pPrimary, NULL)))
+ if(FAILED(hr = m_pDD->CreateSurface(&ddsd, &m_pPrimary, NULL))) {
return hr;
+ }
CComPtr<IDirectDrawClipper> pcClipper;
- if(FAILED(hr = m_pDD->CreateClipper(0, &pcClipper, NULL)))
+ if(FAILED(hr = m_pDD->CreateClipper(0, &pcClipper, NULL))) {
return hr;
+ }
pcClipper->SetHWnd(0, m_hWnd);
m_pPrimary->SetClipper(pcClipper);
@@ -182,12 +185,14 @@ HRESULT CDX7AllocatorPresenter::CreateDevice()
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)))
+ if(FAILED(hr = m_pDD->CreateSurface(&ddsd, &m_pBackBuffer, NULL))) {
return hr;
+ }
pcClipper = NULL;
- if(FAILED(hr = m_pDD->CreateClipper(0, &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);
@@ -197,69 +202,72 @@ HRESULT CDX7AllocatorPresenter::CreateDevice()
// 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)
+ 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);
+ 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);
+ 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;
}
- else
- {
+
+ if(m_pAllocator) {
+ m_pAllocator->ChangeDevice(m_pD3DDev);
+ } else {
m_pAllocator = DNew CDX7SubPicAllocator(m_pD3DDev, size, GetRenderersSettings().fSPCPow2Tex);
- if(!m_pAllocator || FAILED(hr))
+ 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))
+ if(!m_pSubPicQueue || FAILED(hr)) {
return E_FAIL;
+ }
- if(pSubPicProvider) m_pSubPicQueue->SetSubPicProvider(pSubPicProvider);
+ if(pSubPicProvider) {
+ m_pSubPicQueue->SetSubPicProvider(pSubPicProvider);
+ }
return S_OK;
}
@@ -286,23 +294,20 @@ HRESULT CDX7AllocatorPresenter::AllocSurfaces()
ddsd.ddpfPixelFormat.dwGBitMask = 0x0000FF00;
ddsd.ddpfPixelFormat.dwBBitMask = 0x000000FF;
- if(s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE2D || s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D)
- {
+ 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;
+ // ddsd.ddpfPixelFormat.dwFlags |= DDPF_ALPHAPIXELS;
+ // ddsd.ddpfPixelFormat.dwRGBAlphaBitMask = 0xFF000000;
}
HRESULT hr = m_pDD->CreateSurface(&ddsd, &m_pVideoSurface, NULL);
- if(FAILED(hr))
- {
+ 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)
- {
+ && ddsd2.ddpfPixelFormat.dwRGBBitCount == 16) {
ddsd.ddpfPixelFormat.dwRGBBitCount = 16;
ddsd.ddpfPixelFormat.dwRBitMask = 0x0000F800;
ddsd.ddpfPixelFormat.dwGBitMask = 0x000007E0;
@@ -310,12 +315,14 @@ HRESULT CDX7AllocatorPresenter::AllocSurfaces()
hr = m_pDD->CreateSurface(&ddsd, &m_pVideoSurface, NULL);
}
- if(FAILED(hr))
+ if(FAILED(hr)) {
return hr;
+ }
}
- if(s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D)
+ if(s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D) {
m_pVideoTexture = m_pVideoSurface;
+ }
DDBLTFX fx;
INITDDSTRUCT(fx);
@@ -342,8 +349,7 @@ STDMETHODIMP CDX7AllocatorPresenter::CreateRenderer(IUnknown** ppRenderer)
STDMETHODIMP_(bool) CDX7AllocatorPresenter::Paint(bool fAll)
{
- if (m_bPendingResetDevice)
- {
+ if (m_bPendingResetDevice) {
SendResetRequest();
return false;
}
@@ -352,8 +358,9 @@ STDMETHODIMP_(bool) CDX7AllocatorPresenter::Paint(bool fAll)
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)
+ || !m_pPrimary || !m_pBackBuffer || !m_pVideoSurface) {
return(false);
+ }
HRESULT hr;
@@ -364,8 +371,7 @@ STDMETHODIMP_(bool) CDX7AllocatorPresenter::Paint(bool fAll)
CRect rDstPri(m_WindowRect);
MapWindowRect(m_hWnd, HWND_DESKTOP, &rDstPri);
- if(fAll)
- {
+ if(fAll) {
// clear the backbuffer
CRect rl(0, 0, rDstVid.left, rSrcPri.bottom);
@@ -380,16 +386,12 @@ STDMETHODIMP_(bool) CDX7AllocatorPresenter::Paint(bool fAll)
// paint the video on the backbuffer
- if(!rDstVid.IsRectEmpty())
- {
- if(m_pVideoTexture)
- {
+ if(!rDstVid.IsRectEmpty()) {
+ if(m_pVideoTexture) {
Vector v[4];
Transform(rDstVid, v);
hr = TextureBlt(m_pD3DDev, m_pVideoTexture, v, rSrcVid);
- }
- else
- {
+ } else {
hr = m_pBackBuffer->Blt(rDstVid, m_pVideoSurface, rSrcVid, DDBLT_WAIT, NULL);
}
}
@@ -407,8 +409,7 @@ STDMETHODIMP_(bool) CDX7AllocatorPresenter::Paint(bool fAll)
hr = m_pPrimary->Blt(rDstPri, m_pBackBuffer, rSrcPri, DDBLT_WAIT, NULL);
- if(hr == DDERR_SURFACELOST)
- {
+ if(hr == DDERR_SURFACELOST) {
m_bPendingResetDevice = true;
SendResetRequest();
return false;
@@ -419,8 +420,7 @@ STDMETHODIMP_(bool) CDX7AllocatorPresenter::Paint(bool fAll)
void CDX7AllocatorPresenter::SendResetRequest()
{
- if (!m_bDeviceResetRequested)
- {
+ if (!m_bDeviceResetRequested) {
m_bDeviceResetRequested = true;
AfxGetApp()->m_pMainWnd->PostMessage(WM_RESET_DEVICE);
}
@@ -430,8 +430,7 @@ STDMETHODIMP_(bool) CDX7AllocatorPresenter::ResetDevice()
{
HRESULT hr;
DeleteSurfaces();
- if(FAILED(hr = CreateDevice()) || FAILED(hr = AllocSurfaces()))
- {
+ if(FAILED(hr = CreateDevice()) || FAILED(hr = AllocSurfaces())) {
//DDERR_UNSUPPORTEDMODE - 0x8876024e
TRACE("ResetDevice failed: 0x%08x\n", (LONG)hr);
m_bDeviceResetRequested = false;
@@ -451,24 +450,26 @@ STDMETHODIMP CDX7AllocatorPresenter::GetDIB(BYTE* lpDib, DWORD* size)
DDSURFACEDESC2 ddsd;
INITDDSTRUCT(ddsd);
- if(FAILED(m_pVideoSurface->GetSurfaceDesc(&ddsd)))
+ if(FAILED(m_pVideoSurface->GetSurfaceDesc(&ddsd))) {
return E_FAIL;
+ }
- if(ddsd.ddpfPixelFormat.dwRGBBitCount != 16 && ddsd.ddpfPixelFormat.dwRGBBitCount != 32)
+ if(ddsd.ddpfPixelFormat.dwRGBBitCount != 16 && ddsd.ddpfPixelFormat.dwRGBBitCount != 32) {
return E_FAIL;
+ }
DWORD required = sizeof(BITMAPINFOHEADER) + (ddsd.dwWidth*ddsd.dwHeight*32>>3);
- if(!lpDib)
- {
+ if(!lpDib) {
*size = required;
return S_OK;
}
- if(*size < required) return E_OUTOFMEMORY;
+ 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)))
- {
+ if(FAILED(hr = m_pVideoSurface->Lock(NULL, &ddsd, DDLOCK_WAIT|DDLOCK_SURFACEMEMORYPTR|DDLOCK_READONLY|DDLOCK_NOSYSLOCK, NULL))) {
// TODO
return hr;
}
diff --git a/src/filters/renderer/VideoRenderers/DX7AllocatorPresenter.h b/src/filters/renderer/VideoRenderers/DX7AllocatorPresenter.h
index d2afff38f..a98438695 100644
--- a/src/filters/renderer/VideoRenderers/DX7AllocatorPresenter.h
+++ b/src/filters/renderer/VideoRenderers/DX7AllocatorPresenter.h
@@ -31,35 +31,35 @@
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();
-};
+ // ISubPicAllocatorPresenter
+ STDMETHODIMP CreateRenderer(IUnknown** ppRenderer);
+ STDMETHODIMP_(bool) Paint(bool fAll);
+ STDMETHODIMP GetDIB(BYTE* lpDib, DWORD* size);
+ STDMETHODIMP_(bool) ResetDevice();
+ };
}
diff --git a/src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.cpp b/src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.cpp
index e8eaee177..8844f2bb5 100644
--- a/src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.cpp
+++ b/src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.cpp
@@ -73,8 +73,7 @@ CDX9AllocatorPresenter::CDX9AllocatorPresenter(HWND hWnd, bool bFullscreen, HRES
{
HINSTANCE hDll;
- if(FAILED(hr))
- {
+ if(FAILED(hr)) {
_Error += L"ISubPicAllocatorPresenterImpl failed\n";
return;
}
@@ -84,15 +83,12 @@ CDX9AllocatorPresenter::CDX9AllocatorPresenter(HWND hWnd, bool bFullscreen, HRES
m_pD3DXCreateFont = NULL;
m_pD3DXCreateSprite = NULL;
hDll = GetRenderersData()->GetD3X9Dll();
- if(hDll)
- {
+ 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
- {
+ } else {
_Error += L"The installed DirectX End-User Runtime is outdated. Please download and install the ";
_Error += DIRECTX_SDK_DATE;
_Error += L" release or newer in order for MPC-HC to function properly.\n";
@@ -101,8 +97,7 @@ CDX9AllocatorPresenter::CDX9AllocatorPresenter(HWND hWnd, bool bFullscreen, HRES
m_pDwmIsCompositionEnabled = NULL;
m_pDwmEnableComposition = NULL;
m_hDWMAPI = LoadLibrary(L"dwmapi.dll");
- if (m_hDWMAPI)
- {
+ if (m_hDWMAPI) {
(FARPROC &)m_pDwmIsCompositionEnabled = GetProcAddress(m_hDWMAPI, "DwmIsCompositionEnabled");
(FARPROC &)m_pDwmEnableComposition = GetProcAddress(m_hDWMAPI, "DwmEnableComposition");
}
@@ -110,24 +105,25 @@ CDX9AllocatorPresenter::CDX9AllocatorPresenter(HWND hWnd, bool bFullscreen, HRES
m_pDirect3DCreate9Ex = NULL;
m_hD3D9 = LoadLibrary(L"d3d9.dll");
#ifndef DISABLE_USING_D3D9EX
- if (m_hD3D9)
+ if (m_hD3D9) {
(FARPROC &)m_pDirect3DCreate9Ex = GetProcAddress(m_hD3D9, "Direct3DCreate9Ex");
+ }
#endif
- if (m_pDirect3DCreate9Ex)
- {
+ if (m_pDirect3DCreate9Ex) {
m_pDirect3DCreate9Ex(D3D_SDK_VERSION, &m_pD3DEx);
- if(!m_pD3DEx)
+ if(!m_pD3DEx) {
m_pDirect3DCreate9Ex(D3D9b_SDK_VERSION, &m_pD3DEx);
+ }
}
- if(!m_pD3DEx)
- {
+ if(!m_pD3DEx) {
m_pD3D.Attach(Direct3DCreate9(D3D_SDK_VERSION));
- if(!m_pD3D)
+ if(!m_pD3D) {
m_pD3D.Attach(Direct3DCreate9(D3D9b_SDK_VERSION));
- }
- else
+ }
+ } else {
m_pD3D = m_pD3DEx;
+ }
m_DetectedFrameRate = 0.0;
m_DetectedFrameTime = 0.0;
@@ -147,14 +143,12 @@ CDX9AllocatorPresenter::CDX9AllocatorPresenter(HWND hWnd, bool bFullscreen, HRES
m_DetectedRefreshRate = 0;
CRenderersSettings& s = GetRenderersSettings();
- if (s.m_RenderSettings.iVMRDisableDesktopComposition)
- {
+ if (s.m_RenderSettings.iVMRDisableDesktopComposition) {
m_bDesktopCompositionDisabled = true;
- if (m_pDwmEnableComposition)
+ if (m_pDwmEnableComposition) {
m_pDwmEnableComposition(0);
- }
- else
- {
+ }
+ } else {
m_bDesktopCompositionDisabled = false;
}
@@ -174,11 +168,11 @@ CDX9AllocatorPresenter::CDX9AllocatorPresenter(HWND hWnd, bool bFullscreen, HRES
CDX9AllocatorPresenter::~CDX9AllocatorPresenter()
{
- if (m_bDesktopCompositionDisabled)
- {
+ if (m_bDesktopCompositionDisabled) {
m_bDesktopCompositionDisabled = false;
- if (m_pDwmEnableComposition)
+ if (m_pDwmEnableComposition) {
m_pDwmEnableComposition(1);
+ }
}
StopWorkerThreads();
@@ -191,13 +185,11 @@ CDX9AllocatorPresenter::~CDX9AllocatorPresenter()
m_pD3D = NULL;
m_pD3DEx = NULL;
- if (m_hDWMAPI)
- {
+ if (m_hDWMAPI) {
FreeLibrary(m_hDWMAPI);
m_hDWMAPI = NULL;
}
- if (m_hD3D9)
- {
+ if (m_hD3D9) {
FreeLibrary(m_hD3D9);
m_hD3D9 = NULL;
}
@@ -210,42 +202,37 @@ class CRandom31
{
public:
- CRandom31()
- {
+ CRandom31() {
m_Seed = 12164;
}
- void f_SetSeed(int32 _Seed)
- {
+ void f_SetSeed(int32 _Seed) {
m_Seed = _Seed;
}
- int32 f_GetSeed()
- {
+ int32 f_GetSeed() {
return m_Seed;
}
/*
Park and Miller's psuedo-random number generator.
*/
int32 m_Seed;
- int32 f_Get()
- {
+ 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)
+ if (m_Seed < 0) {
m_Seed += M;
+ }
return m_Seed;
}
- static int32 fs_Max()
- {
+ static int32 fs_Max() {
return 2147483646;
}
- double f_GetFloat()
- {
+ double f_GetFloat() {
return double(f_Get()) * (1.0 / double(fs_Max()));
}
};
@@ -256,8 +243,7 @@ private:
class CHistoryEntry
{
public:
- CHistoryEntry()
- {
+ CHistoryEntry() {
m_Time = 0;
m_ScanLine = -1;
}
@@ -268,8 +254,7 @@ private:
class CSolution
{
public:
- CSolution()
- {
+ CSolution() {
m_ScanLines = 1000;
m_ScanLinesPerSecond = m_ScanLines * 100;
}
@@ -277,47 +262,46 @@ private:
double m_ScanLinesPerSecond;
double m_SqrSum;
- void f_Mutate(double _Amount, CRandom31 &_Random, int _MinScans)
- {
+ void f_Mutate(double _Amount, CRandom31 &_Random, int _MinScans) {
int ToDo = _Random.f_Get() % 10;
- if (ToDo == 0)
+ if (ToDo == 0) {
m_ScanLines = m_ScanLines / 2;
- else if (ToDo == 1)
+ } 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)
+ if (ToDo == 2) {
m_ScanLinesPerSecond /= (_Random.f_Get() % 4) + 1;
- else if (ToDo == 3)
+ } 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)
- {
+ 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)
- {
+ 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)
+ if (pFirst->m_SqrSum < pSecond->m_SqrSum) {
return -1;
- else if (pFirst->m_SqrSum > pSecond->m_SqrSum)
+ } else if (pFirst->m_SqrSum > pSecond->m_SqrSum) {
return 1;
+ }
return 0;
}
};
- enum
- {
+ enum {
ENumHistory = 128
};
@@ -328,19 +312,19 @@ private:
CRandom31 m_Random;
- double fp_GetSquareSum(double _ScansPerSecond, double _ScanLines)
- {
+ double fp_GetSquareSum(double _ScansPerSecond, double _ScanLines) {
double SquareSum = 0;
int nHistory = min(m_nHistory, ENumHistory);
int iHistory = m_iHistory - nHistory;
- if (iHistory < 0)
+ if (iHistory < 0) {
iHistory += ENumHistory;
- for (int i = 1; i < nHistory; ++i)
- {
+ }
+ for (int i = 1; i < nHistory; ++i) {
int iHistory0 = iHistory + i - 1;
int iHistory1 = iHistory + i;
- if (iHistory0 < 0)
+ if (iHistory0 < 0) {
iHistory0 += ENumHistory;
+ }
iHistory0 = iHistory0 % ENumHistory;
iHistory1 = iHistory1 % ENumHistory;
ASSERT(m_History[iHistory0].m_Time != 0);
@@ -359,31 +343,26 @@ private:
int m_nHistory;
public:
- CVSyncEstimation()
- {
+ CVSyncEstimation() {
m_iHistory = 0;
m_nHistory = 0;
}
- void f_AddSample(int _ScanLine, LONGLONG _Time)
- {
+ 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)
- {
+ 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)
- {
+ if (m_nHistory > 10) {
+ for (int l = 0; l < 5; ++l) {
const int nSol = 3+5+5+3;
CSolution Solutions[nSol];
@@ -393,31 +372,35 @@ public:
Solutions[2].m_ScanLinesPerSecond = _ScreenSizeY * _WindowsRefreshRate;
int iStart = 3;
- for (int i = iStart; i < iStart + 5; ++i)
+ 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)
+ 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)
+ for (int i = iStart; i < iStart + 3; ++i) {
Solutions[2].f_SpawnInto(Solutions[i], m_Random, _ScreenSizeY);
+ }
int Start = 2;
- if (l == 0)
+ if (l == 0) {
Start = 0;
- for (int i = Start; i < nSol; ++i)
+ }
+ 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)
+ 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
- {
+ } else {
m_OldSolutions[0].m_ScanLines = _ScreenSizeY;
m_OldSolutions[1].m_ScanLines = _ScreenSizeY;
}
@@ -449,152 +432,140 @@ void CDX9AllocatorPresenter::VSyncThread()
CRenderersData *pApp = GetRenderersData();
CRenderersSettings& s = GetRenderersSettings();
- while (!bQuit)
- {
+ 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)
- {
+ 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;
- UNUSED_ALWAYS(StartScanLine);
- int LastPos = ScanLine;
- UNUSED_ALWAYS(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;
- }
+ 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
- double ScanLineTime = ScanLineSeconds / nScanLines;
+ VSyncPos += MinRange + WaitRange;
- 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];
+ VSyncPos = VSyncPos % m_ScreenSize.cy;
+ if (VSyncPos < 0) {
+ VSyncPos += m_ScreenSize.cy;
}
- if (nPos)
- {
- Average /= double(nPos);
- AverageScanline /= double(nPos);
+ int ScanLine = 0;
+ int StartScanLine = ScanLine;
+ UNUSED_ALWAYS(StartScanLine);
+ int LastPos = ScanLine;
+ UNUSED_ALWAYS(LastPos);
+ ScanLine = (VSyncPos + 1) % m_ScreenSize.cy;
+ if (ScanLine < 0) {
+ ScanLine += m_ScreenSize.cy;
}
- else
- {
- Average = 0;
- AverageScanline = 0;
+ int ScanLineMiddle = ScanLine + m_ScreenSize.cy/2;
+ ScanLineMiddle = ScanLineMiddle % m_ScreenSize.cy;
+ if (ScanLineMiddle < 0) {
+ ScanLineMiddle += m_ScreenSize.cy;
}
- double ThisValue = Average;
+ 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;
- 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;
+ int iPos = m_DetectedRefreshRatePos % 100;
+ m_ldDetectedScanlineRateList[iPos] = ScanLineTime;
+ if (m_DetectedScanlineTime && ScanlineStart != ScanlineEnd) {
+ int Diff = ScanlineEnd - ScanlineStart;
+ nSeconds -= double(Diff) * m_DetectedScanlineTime;
}
- 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;
+ 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];
}
- ModerateFloat(m_DetectedScanlineTime, AverageScanline, m_DetectedScanlineTimePrim, 1.5);
- if (m_DetectedScanlineTime > 0.0)
- m_DetectedScanlinesPerFrame = m_DetectedRefreshTime / m_DetectedScanlineTime;
- else
- m_DetectedScanlinesPerFrame = 0;
+
+ 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;
+ }
+ 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);
}
- //TRACE("Refresh: %f\n", RefreshRate);
+ } else {
+ m_DetectedRefreshRate = 0.0;
+ m_DetectedScanlinesPerFrame = 0.0;
}
}
- else
- {
- m_DetectedRefreshRate = 0.0;
- m_DetectedScanlinesPerFrame = 0.0;
- }
- }
- break;
+ break;
}
}
timeEndPeriod (dwResolution);
-// if (pfAvRevertMmThreadCharacteristics) pfAvRevertMmThreadCharacteristics (hAvrt);
+ // if (pfAvRevertMmThreadCharacteristics) pfAvRevertMmThreadCharacteristics (hAvrt);
}
@@ -610,30 +581,25 @@ void CDX9AllocatorPresenter::StartWorkerThreads()
{
DWORD dwThreadId;
- if ( m_bIsEVR )
- {
+ if ( m_bIsEVR ) {
m_hEvtQuit = CreateEvent( NULL, TRUE, FALSE, NULL );
- if ( m_hEvtQuit != NULL ) // Don't create a thread with no stop switch
- {
+ 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 )
+ if ( m_hVSyncThread != NULL ) {
SetThreadPriority( m_hVSyncThread, THREAD_PRIORITY_HIGHEST );
+ }
}
}
}
void CDX9AllocatorPresenter::StopWorkerThreads()
{
- if ( m_bIsEVR )
- {
- if ( m_hEvtQuit != NULL )
- {
+ if ( m_bIsEVR ) {
+ if ( m_hEvtQuit != NULL ) {
SetEvent( m_hEvtQuit );
- if ( m_hVSyncThread != NULL )
- {
- if ( WaitForSingleObject(m_hVSyncThread, 10000) == WAIT_TIMEOUT )
- {
+ if ( m_hVSyncThread != NULL ) {
+ if ( WaitForSingleObject(m_hVSyncThread, 10000) == WAIT_TIMEOUT ) {
ASSERT(FALSE);
TerminateThread( m_hVSyncThread, 0xDEAD );
}
@@ -659,34 +625,27 @@ bool CDX9AllocatorPresenter::SettingsNeedResetDevice()
bRet = bRet || New.fVMR9AlterativeVSync != Current.fVMR9AlterativeVSync;
bRet = bRet || New.iVMR9VSyncAccurate != Current.iVMR9VSyncAccurate;
- if (m_bIsFullscreen)
- {
+ if (m_bIsFullscreen) {
bRet = bRet || New.iVMR9FullscreenGUISupport != Current.iVMR9FullscreenGUISupport;
- }
- else
- {
- if (Current.iVMRDisableDesktopComposition)
- {
- if (!m_bDesktopCompositionDisabled)
- {
+ } else {
+ if (Current.iVMRDisableDesktopComposition) {
+ if (!m_bDesktopCompositionDisabled) {
m_bDesktopCompositionDisabled = true;
- if (m_pDwmEnableComposition)
+ if (m_pDwmEnableComposition) {
m_pDwmEnableComposition(0);
+ }
}
- }
- else
- {
- if (m_bDesktopCompositionDisabled)
- {
+ } else {
+ if (m_bDesktopCompositionDisabled) {
m_bDesktopCompositionDisabled = false;
- if (m_pDwmEnableComposition)
+ if (m_pDwmEnableComposition) {
m_pDwmEnableComposition(1);
+ }
}
}
}
- if (m_bIsEVR)
- {
+ if (m_bIsEVR) {
bRet = bRet || New.iEVRHighColorResolution != Current.iEVRHighColorResolution;
bRet = bRet || New.iEVRForceInputHighColorResolution != Current.iEVRForceInputHighColorResolution;
}
@@ -746,8 +705,7 @@ HRESULT CDX9AllocatorPresenter::CreateDevice(CString &_Error)
CleanupRenderingEngine();
- if(!m_pD3D)
- {
+ if(!m_pD3D) {
_Error += L"Failed to create D3D9\n";
return E_UNEXPECTED;
}
@@ -790,17 +748,15 @@ HRESULT CDX9AllocatorPresenter::CreateDevice(CString &_Error)
*/
-//#define ENABLE_DDRAWSYNC
+ //#define ENABLE_DDRAWSYNC
#ifdef ENABLE_DDRAWSYNC
hr = DirectDrawCreate(NULL, &m_pDirectDraw, NULL) ;
- if (hr == S_OK)
- {
+ if (hr == S_OK) {
hr = m_pDirectDraw->SetCooperativeLevel(m_hWnd, DDSCL_NORMAL) ;
}
#endif
- if (!SetCurrentDisplayMode())
- {
+ if (!SetCurrentDisplayMode()) {
_Error += L"GetAdapterDisplayMode failed\n";
return E_UNEXPECTED;
}
@@ -809,43 +765,41 @@ HRESULT CDX9AllocatorPresenter::CreateDevice(CString &_Error)
ZeroMemory(&pp, sizeof(pp));
BOOL bCompositionEnabled = false;
- if (m_pDwmIsCompositionEnabled)
+ if (m_pDwmIsCompositionEnabled) {
m_pDwmIsCompositionEnabled(&bCompositionEnabled);
+ }
m_bCompositionEnabled = bCompositionEnabled != 0;
m_bAlternativeVSync = s.m_RenderSettings.fVMR9AlterativeVSync;
m_bHighColorResolution = s.m_RenderSettings.iEVRHighColorResolution && m_bIsEVR;
- if (m_bIsFullscreen)
- {
+ if (m_bIsFullscreen) {
pp.Windowed = false;
pp.BackBufferWidth = m_ScreenSize.cx;
pp.BackBufferHeight = m_ScreenSize.cy;
pp.hDeviceWindow = m_hWnd;
- if(m_bAlternativeVSync)
- {
+ if(m_bAlternativeVSync) {
pp.BackBufferCount = 3;
pp.SwapEffect = D3DSWAPEFFECT_DISCARD; // Ne pas mettre D3DSWAPEFFECT_COPY car cela entraine une desynchro audio sur les MKV ! // Copy needed for sync now? FLIP only stutters.
pp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
- }
- else
- {
+ } else {
pp.BackBufferCount = 3;
pp.SwapEffect = D3DSWAPEFFECT_DISCARD; // Ne pas mettre D3DSWAPEFFECT_COPY car cela entraine une desynchro audio sur les MKV ! // Copy needed for sync now? FLIP only stutters.
pp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
}
pp.Flags = D3DPRESENTFLAG_VIDEO;
- if (s.m_RenderSettings.iVMR9FullscreenGUISupport && !m_bHighColorResolution)
+ if (s.m_RenderSettings.iVMR9FullscreenGUISupport && !m_bHighColorResolution) {
pp.Flags |= D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;
- if (m_bHighColorResolution)
+ }
+ if (m_bHighColorResolution) {
pp.BackBufferFormat = D3DFMT_A2R10G10B10;
- else
+ } else {
pp.BackBufferFormat = m_DisplayType;
+ }
m_D3DDevExError = L"No m_pD3DEx";
- if (m_pD3DEx)
- {
+ if (m_pD3DEx) {
D3DDISPLAYMODEEX DisplayMode;
ZeroMemory(&DisplayMode, sizeof(DisplayMode));
DisplayMode.Size = sizeof(DisplayMode);
@@ -861,35 +815,29 @@ HRESULT CDX9AllocatorPresenter::CreateDevice(CString &_Error)
&pp, &DisplayMode, &m_pD3DDevEx);
m_D3DDevExError = GetWindowsErrorMessage(hr, m_hD3D9);
- if (m_pD3DDevEx)
- {
+ if (m_pD3DDevEx) {
m_pD3DDev = m_pD3DDevEx;
m_BackbufferType = pp.BackBufferFormat;
m_DisplayType = DisplayMode.Format;
}
}
- if (!m_pD3DDev)
- {
+ if (!m_pD3DDev) {
m_CurrentAdapter = GetAdapter(m_pD3D, true);
hr = m_pD3D->CreateDevice(
m_CurrentAdapter, D3DDEVTYPE_HAL, m_hWnd,
GetVertexProcessing() | D3DCREATE_FPU_PRESERVE | D3DCREATE_MULTITHREADED, //D3DCREATE_MANAGED
&pp, &m_pD3DDev);
- if (m_pD3DDev)
- {
+ if (m_pD3DDev) {
m_BackbufferType = pp.BackBufferFormat;
}
}
- if (m_pD3DDev && s.m_RenderSettings.iVMR9FullscreenGUISupport && !m_bHighColorResolution)
- {
+ if (m_pD3DDev && s.m_RenderSettings.iVMR9FullscreenGUISupport && !m_bHighColorResolution) {
m_pD3DDev->SetDialogBoxMode(true);
//if (m_pD3DDev->SetDialogBoxMode(true) != S_OK)
// ExitProcess(0);
}
- }
- else
- {
+ } else {
pp.Windowed = TRUE;
pp.hDeviceWindow = m_hWnd;
pp.SwapEffect = D3DSWAPEFFECT_COPY;
@@ -898,36 +846,30 @@ HRESULT CDX9AllocatorPresenter::CreateDevice(CString &_Error)
pp.BackBufferWidth = m_ScreenSize.cx;
pp.BackBufferHeight = m_ScreenSize.cy;
m_BackbufferType = m_DisplayType;
- if (m_bHighColorResolution)
- {
+ if (m_bHighColorResolution) {
m_BackbufferType = D3DFMT_A2R10G10B10;
pp.BackBufferFormat = D3DFMT_A2R10G10B10;
}
- if (bCompositionEnabled || m_bAlternativeVSync)
- {
+ if (bCompositionEnabled || m_bAlternativeVSync) {
// Desktop composition takes care of the VSYNC
pp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
- }
- else
- {
+ } else {
pp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
}
-// if(m_fVMRSyncFix = GetRenderersData()->m_s.fVMRSyncFix)
-// pp.Flags |= D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;
+ // if(m_fVMRSyncFix = GetRenderersData()->m_s.fVMRSyncFix)
+ // pp.Flags |= D3DPRESENTFLAG_LOCKABLE_BACKBUFFER;
m_CurrentAdapter = GetAdapter(m_pD3D, true);
- if (m_pD3DEx)
- {
+ if (m_pD3DEx) {
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)
+ if (m_pD3DDevEx) {
m_pD3DDev = m_pD3DDevEx;
- }
- else
- {
+ }
+ } else {
hr = m_pD3D->CreateDevice(
m_CurrentAdapter, D3DDEVTYPE_HAL, m_hWnd,
GetVertexProcessing() | D3DCREATE_FPU_PRESERVE | D3DCREATE_MULTITHREADED, //D3DCREATE_MANAGED
@@ -935,13 +877,11 @@ HRESULT CDX9AllocatorPresenter::CreateDevice(CString &_Error)
}
}
- while(hr == D3DERR_DEVICELOST)
- {
+ while(hr == D3DERR_DEVICELOST) {
TRACE("D3DERR_DEVICELOST. Trying to Reset.\n");
hr = m_pD3DDev->TestCooperativeLevel();
}
- if (hr == D3DERR_DEVICENOTRESET)
- {
+ if (hr == D3DERR_DEVICENOTRESET) {
TRACE("D3DERR_DEVICENOTRESET\n");
hr = m_pD3DDev->Reset(&pp);
}
@@ -951,13 +891,11 @@ HRESULT CDX9AllocatorPresenter::CreateDevice(CString &_Error)
m_MainThreadId = GetCurrentThreadId();
- if (m_pD3DDevEx)
- {
+ if (m_pD3DDevEx) {
m_pD3DDevEx->SetGPUThreadPriority(7);
}
- if(FAILED(hr))
- {
+ if(FAILED(hr)) {
_Error += L"CreateDevice failed\n";
return hr;
@@ -974,53 +912,50 @@ HRESULT CDX9AllocatorPresenter::CreateDevice(CString &_Error)
m_bForceInputHighColorResolution = s.m_RenderSettings.iEVRForceInputHighColorResolution && m_bIsEVR && renderersData->m_b10bitSupport;
CComPtr<ISubPicProvider> pSubPicProvider;
- if(m_pSubPicQueue) m_pSubPicQueue->GetSubPicProvider(&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);
+ 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;
}
- else
- {
+
+ if(m_pAllocator) {
+ m_pAllocator->ChangeDevice(m_pD3DDev);
+ } else {
m_pAllocator = DNew CDX9SubPicAllocator(m_pD3DDev, size, GetRenderersSettings().fSPCPow2Tex);
- if(!m_pAllocator)
- {
+ if(!m_pAllocator) {
_Error += L"CDX9SubPicAllocator failed\n";
return E_FAIL;
@@ -1031,18 +966,18 @@ HRESULT CDX9AllocatorPresenter::CreateDevice(CString &_Error)
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))
- {
+ if(!m_pSubPicQueue || FAILED(hr)) {
_Error += L"m_pSubPicQueue failed\n";
return E_FAIL;
}
- if(pSubPicProvider) m_pSubPicQueue->SetSubPicProvider(pSubPicProvider);
+ if(pSubPicProvider) {
+ m_pSubPicQueue->SetSubPicProvider(pSubPicProvider);
+ }
m_pFont = NULL;
- if (m_pD3DXCreateFont)
- {
+ if (m_pD3DXCreateFont) {
int MinSize = 1600;
int CurrentSize = min(m_ScreenSize.cx, MinSize);
double Scale = double(CurrentSize) / double(MinSize);
@@ -1064,15 +999,15 @@ HRESULT CDX9AllocatorPresenter::CreateDevice(CString &_Error)
m_pSprite = NULL;
- if (m_pD3DXCreateSprite)
- {
+ if (m_pD3DXCreateSprite) {
m_pD3DXCreateSprite( m_pD3DDev, // D3D device
&m_pSprite);
}
m_pLine = NULL;
- if (m_pD3DXCreateLine)
+ if (m_pD3DXCreateLine) {
m_pD3DXCreateLine (m_pD3DDev, &m_pLine);
+ }
m_LastAdapterCheck = GetRenderersData()->GetPerfCounter();
@@ -1101,8 +1036,9 @@ bool CDX9AllocatorPresenter::SetCurrentDisplayMode()
{
D3DDISPLAYMODE d3ddm;
ZeroMemory(&d3ddm, sizeof(d3ddm));
- if(FAILED(m_pD3D->GetAdapterDisplayMode(m_CurrentAdapter, &d3ddm)))
+ if(FAILED(m_pD3D->GetAdapterDisplayMode(m_CurrentAdapter, &d3ddm))) {
return false;
+ }
m_RefreshRate = d3ddm.RefreshRate;
m_ScreenSize.SetSize(d3ddm.Width, d3ddm.Height);
m_DisplayType = d3ddm.Format;
@@ -1111,22 +1047,19 @@ bool CDX9AllocatorPresenter::SetCurrentDisplayMode()
UINT CDX9AllocatorPresenter::GetAdapter(IDirect3D9* pD3D, bool bCreateDevice)
{
- if(m_hWnd == NULL || pD3D == NULL)
+ if(m_hWnd == NULL || pD3D == NULL) {
return D3DADAPTER_DEFAULT;
+ }
CRenderersSettings& s = GetRenderersSettings();
- if(bCreateDevice && (pD3D->GetAdapterCount()>1) && (s.D3D9RenderDevice != _T("")))
- {
+ if(bCreateDevice && (pD3D->GetAdapterCount()>1) && (s.D3D9RenderDevice != _T(""))) {
TCHAR strGUID[50];
D3DADAPTER_IDENTIFIER9 adapterIdentifier;
m_D3D9Device = _T("");
- 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))
- {
+ 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;
return adp;
}
@@ -1135,18 +1068,18 @@ UINT CDX9AllocatorPresenter::GetAdapter(IDirect3D9* pD3D, bool bCreateDevice)
}
HMONITOR hMonitor = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
- if(hMonitor == NULL) return D3DADAPTER_DEFAULT;
+ if(hMonitor == NULL) {
+ return D3DADAPTER_DEFAULT;
+ }
- for(UINT adp = 0, num_adp = pD3D->GetAdapterCount(); adp < num_adp; ++adp)
- {
+ for(UINT adp = 0, num_adp = pD3D->GetAdapterCount(); adp < num_adp; ++adp) {
HMONITOR hAdpMon = pD3D->GetAdapterMonitor(adp);
- if(hAdpMon == hMonitor)
- {
- if(bCreateDevice)
- {
+ if(hAdpMon == hMonitor) {
+ if(bCreateDevice) {
D3DADAPTER_IDENTIFIER9 adapterIdentifier;
- if (pD3D->GetAdapterIdentifier(adp, 0, &adapterIdentifier) == S_OK)
+ if (pD3D->GetAdapterIdentifier(adp, 0, &adapterIdentifier) == S_OK) {
m_D3D9Device = adapterIdentifier.Description;
+ }
}
return adp;
}
@@ -1161,12 +1094,12 @@ DWORD CDX9AllocatorPresenter::GetVertexProcessing()
D3DCAPS9 caps;
hr = m_pD3D->GetDeviceCaps(m_CurrentAdapter, D3DDEVTYPE_HAL, &caps);
- if (FAILED(hr))
+ if (FAILED(hr)) {
return D3DCREATE_SOFTWARE_VERTEXPROCESSING;
+ }
if ((caps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) == 0 ||
- caps.VertexShaderVersion < D3DVS_VERSION(2, 0))
- {
+ caps.VertexShaderVersion < D3DVS_VERSION(2, 0)) {
return D3DCREATE_SOFTWARE_VERTEXPROCESSING;
}
@@ -1184,8 +1117,7 @@ void CDX9AllocatorPresenter::CalculateJitter(LONGLONG PerfCounter)
{
// Calculate the jitter!
LONGLONG llPerf = PerfCounter;
- if ((m_rtTimePerFrame != 0) && (labs ((long)(llPerf - m_llLastPerf)) < m_rtTimePerFrame*3) )
- {
+ 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;
@@ -1195,8 +1127,7 @@ void CDX9AllocatorPresenter::CalculateJitter(LONGLONG PerfCounter)
// Calculate the real FPS
LONGLONG llJitterSum = 0;
LONGLONG llJitterSumAvg = 0;
- for (int i=0; i<NB_JITTER; i++)
- {
+ for (int i=0; i<NB_JITTER; i++) {
LONGLONG Jitter = m_pllJitter[i];
llJitterSum += Jitter;
llJitterSumAvg += Jitter;
@@ -1204,8 +1135,7 @@ void CDX9AllocatorPresenter::CalculateJitter(LONGLONG PerfCounter)
double FrameTimeMean = double(llJitterSumAvg)/NB_JITTER;
m_fJitterMean = FrameTimeMean;
double DeviationSum = 0;
- for (int i=0; i<NB_JITTER; i++)
- {
+ for (int i=0; i<NB_JITTER; i++) {
LONGLONG DevInt = m_pllJitter[i] - FrameTimeMean;
double Deviation = DevInt;
DeviationSum += Deviation*Deviation;
@@ -1225,53 +1155,54 @@ void CDX9AllocatorPresenter::CalculateJitter(LONGLONG PerfCounter)
bool CDX9AllocatorPresenter::GetVBlank(int &_ScanLine, int &_bInVBlank, bool _bMeasureTime)
{
LONGLONG llPerf = 0;
- if (_bMeasureTime)
+ if (_bMeasureTime) {
llPerf = GetRenderersData()->GetPerfCounter();
+ }
int ScanLine = 0;
_ScanLine = 0;
_bInVBlank = 0;
- if (m_bPendingResetDevice)
+ if (m_bPendingResetDevice) {
return false;
- if (m_pDirectDraw)
- {
+ }
+ if (m_pDirectDraw) {
DWORD ScanLineGet = 0;
m_pDirectDraw->GetScanLine(&ScanLineGet);
BOOL InVBlank;
- if (m_pDirectDraw->GetVerticalBlankStatus (&InVBlank) != S_OK)
+ if (m_pDirectDraw->GetVerticalBlankStatus (&InVBlank) != S_OK) {
return false;
+ }
ScanLine = ScanLineGet;
_bInVBlank = InVBlank;
- if (InVBlank)
+ if (InVBlank) {
ScanLine = 0;
- }
- else
- {
+ }
+ } else {
D3DRASTER_STATUS RasterStatus;
- if (m_pD3DDev->GetRasterStatus(0, &RasterStatus) != S_OK)
+ if (m_pD3DDev->GetRasterStatus(0, &RasterStatus) != S_OK) {
return false;
+ }
ScanLine = RasterStatus.ScanLine;
_bInVBlank = RasterStatus.InVBlank;
}
- if (_bMeasureTime)
- {
+ if (_bMeasureTime) {
m_VBlankMax = max(m_VBlankMax, ScanLine);
- if (ScanLine != 0 && !_bInVBlank)
+ if (ScanLine != 0 && !_bInVBlank) {
m_VBlankMinCalc = min(m_VBlankMinCalc, ScanLine);
+ }
m_VBlankMin = m_VBlankMax - m_ScreenSize.cy;
}
- if (_bInVBlank)
+ if (_bInVBlank) {
_ScanLine = 0;
- else if (m_VBlankMin != 300000)
+ } else if (m_VBlankMin != 300000) {
_ScanLine = ScanLine - m_VBlankMin;
- else
+ } else {
_ScanLine = ScanLine;
+ }
- if (_bMeasureTime)
- {
+ if (_bMeasureTime) {
LONGLONG Time = GetRenderersData()->GetPerfCounter() - llPerf;
- if (Time > 5000000) // 0.5 sec
- {
+ if (Time > 5000000) { // 0.5 sec
TRACE("GetVBlank too long (%f sec)\n", Time / 10000000.0);
}
m_RasterStatusWaitTimeMaxCalc = max(m_RasterStatusWaitTimeMaxCalc, Time);
@@ -1282,71 +1213,67 @@ bool CDX9AllocatorPresenter::GetVBlank(int &_ScanLine, int &_bInVBlank, bool _bM
bool CDX9AllocatorPresenter::WaitForVBlankRange(int &_RasterStart, int _RasterSize, bool _bWaitIfInside, bool _bNeedAccurate, bool _bMeasure, bool &_bTakenLock)
{
- if (_bMeasure)
+ if (_bMeasure) {
m_RasterStatusWaitTimeMaxCalc = 0;
+ }
bool bWaited = false;
int ScanLine = 0;
int InVBlank = 0;
LONGLONG llPerf = 0;
- if (_bMeasure)
+ if (_bMeasure) {
llPerf = GetRenderersData()->GetPerfCounter();
+ }
GetVBlank(ScanLine, InVBlank, _bMeasure);
- if (_bMeasure)
+ if (_bMeasure) {
m_VBlankStartWait = ScanLine;
+ }
static bool bOneWait = true;
- if (bOneWait && _bMeasure)
- {
+ 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;
- while (1)
- {
- if (!GetVBlank(ScanLine, InVBlank, _bMeasure))
+ while (1) {
+ if (!GetVBlank(ScanLine, InVBlank, _bMeasure)) {
break;
+ }
- if (InVBlank && nInVBlank == 0)
- {
+ if (InVBlank && nInVBlank == 0) {
nInVBlank = 1;
- }
- else if (!InVBlank && nInVBlank == 1)
- {
+ } else if (!InVBlank && nInVBlank == 1) {
nInVBlank = 2;
- }
- else if (InVBlank && nInVBlank == 2)
- {
+ } else if (InVBlank && nInVBlank == 2) {
nInVBlank = 3;
- }
- else if (!InVBlank && nInVBlank == 3)
- {
+ } else if (!InVBlank && nInVBlank == 3) {
break;
}
}
}
- if (_bWaitIfInside)
- {
+ if (_bWaitIfInside) {
int ScanLineDiff = long(ScanLine) - _RasterStart;
- if (ScanLineDiff > m_ScreenSize.cy / 2)
+ if (ScanLineDiff > m_ScreenSize.cy / 2) {
ScanLineDiff -= m_ScreenSize.cy;
- else if (ScanLineDiff < -m_ScreenSize.cy / 2)
+ } else if (ScanLineDiff < -m_ScreenSize.cy / 2) {
ScanLineDiff += m_ScreenSize.cy;
+ }
- if (ScanLineDiff >= 0 && ScanLineDiff <= _RasterSize)
- {
+ 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;
- while (1)
- {
- if (!GetVBlank(ScanLine, InVBlank, _bMeasure))
+ while (1) {
+ if (!GetVBlank(ScanLine, InVBlank, _bMeasure)) {
break;
+ }
int ScanLineDiff = long(ScanLine) - _RasterStart;
- if (ScanLineDiff > m_ScreenSize.cy / 2)
+ if (ScanLineDiff > m_ScreenSize.cy / 2) {
ScanLineDiff -= m_ScreenSize.cy;
- else if (ScanLineDiff < -m_ScreenSize.cy / 2)
+ } else if (ScanLineDiff < -m_ScreenSize.cy / 2) {
ScanLineDiff += m_ScreenSize.cy;
- if (!(ScanLineDiff >= 0 && ScanLineDiff <= _RasterSize) || (LastLineDiff < 0 && ScanLineDiff > 0))
+ }
+ if (!(ScanLineDiff >= 0 && ScanLineDiff <= _RasterSize) || (LastLineDiff < 0 && ScanLineDiff > 0)) {
break;
+ }
LastLineDiff = ScanLineDiff;
Sleep(1); // Just sleep
}
@@ -1357,66 +1284,72 @@ bool CDX9AllocatorPresenter::WaitForVBlankRange(int &_RasterStart, int _RasterSi
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)
+ 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)
+ if (D3DDevLockStart < 0) {
D3DDevLockStart += m_ScreenSize.cy;
+ }
int ScanLineDiff = ScanLine - _RasterStart;
- if (ScanLineDiff > m_ScreenSize.cy / 2)
+ if (ScanLineDiff > m_ScreenSize.cy / 2) {
ScanLineDiff -= m_ScreenSize.cy;
- else if (ScanLineDiff < -m_ScreenSize.cy / 2)
+ } 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)
+ if (ScanLineDiffSleep > m_ScreenSize.cy / 2) {
ScanLineDiffSleep -= m_ScreenSize.cy;
- else if (ScanLineDiffSleep < -m_ScreenSize.cy / 2)
+ } 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)
+ if (ScanLineDiffLock > m_ScreenSize.cy / 2) {
ScanLineDiffLock -= m_ScreenSize.cy;
- else if (ScanLineDiffLock < -m_ScreenSize.cy / 2)
+ } else if (ScanLineDiffLock < -m_ScreenSize.cy / 2) {
ScanLineDiffLock += m_ScreenSize.cy;
+ }
int LastLineDiffLock = ScanLineDiffLock;
LONGLONG llPerfLock = 0;
- while (1)
- {
- if (!GetVBlank(ScanLine, InVBlank, _bMeasure))
+ while (1) {
+ if (!GetVBlank(ScanLine, InVBlank, _bMeasure)) {
break;
+ }
int ScanLineDiff = long(ScanLine) - _RasterStart;
- if (ScanLineDiff > m_ScreenSize.cy / 2)
+ if (ScanLineDiff > m_ScreenSize.cy / 2) {
ScanLineDiff -= m_ScreenSize.cy;
- else if (ScanLineDiff < -m_ScreenSize.cy / 2)
+ } else if (ScanLineDiff < -m_ScreenSize.cy / 2) {
ScanLineDiff += m_ScreenSize.cy;
- if ((ScanLineDiff >= 0 && ScanLineDiff <= _RasterSize) || (LastLineDiff < 0 && ScanLineDiff > 0))
+ }
+ 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)
+ if (ScanLineDiffLock > m_ScreenSize.cy / 2) {
ScanLineDiffLock -= m_ScreenSize.cy;
- else if (ScanLineDiffLock < -m_ScreenSize.cy / 2)
+ } else if (ScanLineDiffLock < -m_ScreenSize.cy / 2) {
ScanLineDiffLock += m_ScreenSize.cy;
+ }
- if (((ScanLineDiffLock >= 0 && ScanLineDiffLock <= D3DDevLockRange) || (LastLineDiffLock < 0 && ScanLineDiffLock > 0)))
- {
- if (!_bTakenLock && _bMeasure)
- {
+ if (((ScanLineDiffLock >= 0 && ScanLineDiffLock <= D3DDevLockRange) || (LastLineDiffLock < 0 && ScanLineDiffLock > 0))) {
+ if (!_bTakenLock && _bMeasure) {
_bTakenLock = true;
llPerfLock = GetRenderersData()->GetPerfCounter();
LockD3DDevice();
@@ -1426,30 +1359,28 @@ bool CDX9AllocatorPresenter::WaitForVBlankRange(int &_RasterStart, int _RasterSi
int ScanLineDiffSleep = long(ScanLine) - NoSleepStart;
- if (ScanLineDiffSleep > m_ScreenSize.cy / 2)
+ if (ScanLineDiffSleep > m_ScreenSize.cy / 2) {
ScanLineDiffSleep -= m_ScreenSize.cy;
- else if (ScanLineDiffSleep < -m_ScreenSize.cy / 2)
+ } else if (ScanLineDiffSleep < -m_ScreenSize.cy / 2) {
ScanLineDiffSleep += m_ScreenSize.cy;
+ }
- if (!((ScanLineDiffSleep >= 0 && ScanLineDiffSleep <= NoSleepRange) || (LastLineDiffSleep < 0 && ScanLineDiffSleep > 0)) || !_bNeedAccurate)
- {
+ 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)
- {
+ if (_bMeasure) {
m_VBlankEndWait = ScanLine;
m_VBlankWaitTime = GetRenderersData()->GetPerfCounter() - llPerf;
- if (_bTakenLock)
- {
+ if (_bTakenLock) {
m_VBlankLockTime = GetRenderersData()->GetPerfCounter() - llPerfLock;
- }
- else
+ } else {
m_VBlankLockTime = 0;
+ }
m_RasterStatusWaitTime = m_RasterStatusWaitTimeMaxCalc;
m_RasterStatusWaitTimeMin = min(m_RasterStatusWaitTimeMin, m_RasterStatusWaitTime);
@@ -1465,21 +1396,15 @@ int CDX9AllocatorPresenter::GetVBlackPos()
BOOL bCompositionEnabled = m_bCompositionEnabled;
int WaitRange = max(m_ScreenSize.cy / 40, 5);
- if (!bCompositionEnabled)
- {
- if (m_bAlternativeVSync)
- {
+ if (!bCompositionEnabled) {
+ if (m_bAlternativeVSync) {
return s.m_RenderSettings.iVMR9VSyncOffset;
- }
- else
- {
+ } 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
- {
+ } else {
int WaitFor = m_ScreenSize.cy / 2;
return WaitFor;
}
@@ -1489,8 +1414,7 @@ int CDX9AllocatorPresenter::GetVBlackPos()
bool CDX9AllocatorPresenter::WaitForVBlank(bool &_Waited, bool &_bTakenLock)
{
CRenderersSettings& s = GetRenderersSettings();
- if (!s.m_RenderSettings.iVMR9VSync)
- {
+ if (!s.m_RenderSettings.iVMR9VSync) {
_Waited = true;
m_VBlankWaitTime = 0;
m_VBlankLockTime = 0;
@@ -1498,27 +1422,21 @@ bool CDX9AllocatorPresenter::WaitForVBlank(bool &_Waited, bool &_bTakenLock)
m_VBlankStartWait = 0;
return true;
}
-// _Waited = true;
-// return false;
+ // _Waited = true;
+ // return false;
BOOL bCompositionEnabled = m_bCompositionEnabled;
int WaitFor = GetVBlackPos();
- if (!bCompositionEnabled)
- {
- if (m_bAlternativeVSync)
- {
+ if (!bCompositionEnabled) {
+ if (m_bAlternativeVSync) {
_Waited = WaitForVBlankRange(WaitFor, 0, false, true, true, _bTakenLock);
return false;
- }
- else
- {
+ } else {
_Waited = WaitForVBlankRange(WaitFor, 0, false, s.m_RenderSettings.iVMR9VSyncAccurate, true, _bTakenLock);
return true;
}
- }
- else
- {
+ } 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);
@@ -1530,20 +1448,20 @@ void CDX9AllocatorPresenter::UpdateAlphaBitmap()
{
m_VMR9AlphaBitmapData.Free();
- if ((m_VMR9AlphaBitmap.dwFlags & VMRBITMAP_DISABLE) == 0)
- {
+ if ((m_VMR9AlphaBitmap.dwFlags & VMRBITMAP_DISABLE) == 0) {
HBITMAP hBitmap = (HBITMAP)GetCurrentObject (m_VMR9AlphaBitmap.hdc, OBJ_BITMAP);
- if (!hBitmap)
+ if (!hBitmap) {
return;
+ }
DIBSECTION info = {0};
- if (!::GetObject(hBitmap, sizeof( DIBSECTION ), &info ))
+ 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))
- {
+ if (m_VMR9AlphaBitmapData.Allocate(info.dsBm.bmWidthBytes * info.dsBm.bmHeight)) {
memcpy((BYTE *)m_VMR9AlphaBitmapData, info.dsBm.bmBits, info.dsBm.bmWidthBytes * info.dsBm.bmHeight);
}
}
@@ -1551,23 +1469,19 @@ void CDX9AllocatorPresenter::UpdateAlphaBitmap()
STDMETHODIMP_(bool) CDX9AllocatorPresenter::Paint(bool fAll)
{
- if (m_bPendingResetDevice)
- {
+ if (m_bPendingResetDevice) {
SendResetRequest();
return false;
}
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))))
- {
+ if (TryEnterCriticalSection (&(CRITICAL_SECTION &)(*((CCritSec *)this)))) {
LeaveCriticalSection((&(CRITICAL_SECTION &)(*((CCritSec *)this))));
- }
- else
- {
+ } else {
__debugbreak();
}
#endif
@@ -1579,13 +1493,11 @@ STDMETHODIMP_(bool) CDX9AllocatorPresenter::Paint(bool fAll)
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_pVideoSurface) {
+ if (m_OrderedPaint) {
--m_OrderedPaint;
- else
- {
-// TRACE("UNORDERED PAINT!!!!!!\n");
+ } else {
+ // TRACE("UNORDERED PAINT!!!!!!\n");
}
@@ -1614,18 +1526,15 @@ STDMETHODIMP_(bool) CDX9AllocatorPresenter::Paint(bool fAll)
// Render the current video frame
hr = RenderVideo(pBackBuffer, rSrcVid, rDstVid);
- if (FAILED(hr))
- {
- if (m_RenderingPath == RENDERING_PATH_STRETCHRECT)
- {
+ 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)
+ if (m_OrderedPaint) {
--m_OrderedPaint;
- else
- {
-// TRACE("UNORDERED PAINT!!!!!!\n");
+ } else {
+ // TRACE("UNORDERED PAINT!!!!!!\n");
}
return false;
@@ -1636,21 +1545,17 @@ STDMETHODIMP_(bool) CDX9AllocatorPresenter::Paint(bool fAll)
AlphaBltSubPic(rSrcPri.Size());
// Casimir666 : show OSD
- if (m_VMR9AlphaBitmap.dwFlags & VMRBITMAP_UPDATE)
- {
+ 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_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)))
- {
+ D3DPOOL_DEFAULT, &m_pOSDTexture, NULL)) ) {
+ if (SUCCEEDED (hr = m_pOSDTexture->GetSurfaceLevel(0, &m_pOSDSurface))) {
hr = m_pD3DXLoadSurfaceFromMemory (m_pOSDSurface,
NULL,
NULL,
@@ -1662,8 +1567,7 @@ STDMETHODIMP_(bool) CDX9AllocatorPresenter::Paint(bool fAll)
D3DX_FILTER_NONE,
m_VMR9AlphaBitmap.clrSrcKey);
}
- if (FAILED (hr))
- {
+ if (FAILED (hr)) {
m_pOSDTexture = NULL;
m_pOSDSurface = NULL;
}
@@ -1673,8 +1577,9 @@ STDMETHODIMP_(bool) CDX9AllocatorPresenter::Paint(bool fAll)
}
- if (pApp->m_fDisplayStats)
+ if (pApp->m_fDisplayStats) {
DrawStats();
+ }
{
CString Temp;
@@ -1683,7 +1588,9 @@ STDMETHODIMP_(bool) CDX9AllocatorPresenter::Paint(bool fAll)
//TRACE("%ws\n", Temp.GetString());
}
- if (m_pOSDTexture) AlphaBlt(rSrcPri, rDstPri, m_pOSDTexture);
+ if (m_pOSDTexture) {
+ AlphaBlt(rSrcPri, rDstPri, m_pOSDTexture);
+ }
m_pD3DDev->EndScene();
@@ -1692,47 +1599,48 @@ STDMETHODIMP_(bool) CDX9AllocatorPresenter::Paint(bool fAll)
bool bDoVSyncInPresent = (!bCompositionEnabled && !m_bAlternativeVSync) || !s.m_RenderSettings.iVMR9VSync;
LONGLONG PresentWaitTime = 0;
-/*
- if(fAll && m_fVMRSyncFix && bDoVSyncInPresent)
- {
- LONGLONG llPerf = pApp->GetPerfCounter();
- D3DLOCKED_RECT lr;
- if(SUCCEEDED(pBackBuffer->LockRect(&lr, NULL, 0)))
- pBackBuffer->UnlockRect();
- PresentWaitTime = pApp->GetPerfCounter() - llPerf;
- }
-*/
+ /*
+ if(fAll && m_fVMRSyncFix && bDoVSyncInPresent)
+ {
+ LONGLONG llPerf = pApp->GetPerfCounter();
+ D3DLOCKED_RECT lr;
+ if(SUCCEEDED(pBackBuffer->LockRect(&lr, NULL, 0)))
+ pBackBuffer->UnlockRect();
+ PresentWaitTime = pApp->GetPerfCounter() - llPerf;
+ }
+ */
CComPtr<IDirect3DQuery9> pEventQuery;
m_pD3DDev->CreateQuery(D3DQUERYTYPE_EVENT, &pEventQuery);
- if (pEventQuery)
+ if (pEventQuery) {
pEventQuery->Issue(D3DISSUE_END);
+ }
- if (s.m_RenderSettings.iVMRFlushGPUBeforeVSync && pEventQuery)
- {
+ 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)
+ 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 (pApp->GetPerfCounter() - FlushStartTime > 500000) {
+ break; // timeout after 50 ms
+ }
}
- if (s.m_RenderSettings.iVMRFlushGPUWait)
+ if (s.m_RenderSettings.iVMRFlushGPUWait) {
m_WaitForGPUTime = pApp->GetPerfCounter() - llPerf;
- else
+ } else {
m_WaitForGPUTime = 0;
- }
- else
+ }
+ } else {
m_WaitForGPUTime = 0;
+ }
- if (fAll)
- {
+ if (fAll) {
m_PaintTime = (GetRenderersData()->GetPerfCounter() - StartPaint);
m_PaintTimeMin = min(m_PaintTimeMin, m_PaintTime);
m_PaintTimeMax = max(m_PaintTimeMax, m_PaintTime);
@@ -1740,17 +1648,16 @@ STDMETHODIMP_(bool) CDX9AllocatorPresenter::Paint(bool fAll)
bool bWaited = false;
bool bTakenLock = false;
- if (fAll)
- {
+ if (fAll) {
// Only sync to refresh when redrawing all
bool bTest = WaitForVBlank(bWaited, bTakenLock);
ASSERT(bTest == bDoVSyncInPresent);
- if (!bDoVSyncInPresent)
- {
+ if (!bDoVSyncInPresent) {
LONGLONG Time = pApp->GetPerfCounter();
OnVBlankFinished(fAll, Time);
- if (!m_bIsEVR || m_OrderedPaint)
+ if (!m_bIsEVR || m_OrderedPaint) {
CalculateJitter(Time);
+ }
}
}
@@ -1762,35 +1669,35 @@ STDMETHODIMP_(bool) CDX9AllocatorPresenter::Paint(bool fAll)
m_pD3DDev->CreateQuery(D3DQUERYTYPE_EVENT, &pEventQuery);
LONGLONG llPerf = pApp->GetPerfCounter();
- if (m_pD3DDevEx)
- {
- if (m_bIsFullscreen)
+ if (m_pD3DDevEx) {
+ if (m_bIsFullscreen) {
hr = m_pD3DDevEx->PresentEx(NULL, NULL, NULL, NULL, NULL);
- else
+ } else {
hr = m_pD3DDevEx->PresentEx(rSrcPri, rDstPri, NULL, NULL, NULL);
- }
- else
- {
- if (m_bIsFullscreen)
+ }
+ } else {
+ if (m_bIsFullscreen) {
hr = m_pD3DDev->Present(NULL, NULL, NULL, NULL);
- else
+ } else {
hr = m_pD3DDev->Present(rSrcPri, rDstPri, NULL, NULL);
+ }
}
// Issue an End event
- if (pEventQuery)
+ if (pEventQuery) {
pEventQuery->Issue(D3DISSUE_END);
+ }
BOOL Data;
- if (s.m_RenderSettings.iVMRFlushGPUAfterPresent && pEventQuery)
- {
+ 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)
+ 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
+ }
+ if (pApp->GetPerfCounter() - FlushStartTime > 500000) {
+ break; // timeout after 50 ms
+ }
}
}
@@ -1798,43 +1705,39 @@ STDMETHODIMP_(bool) CDX9AllocatorPresenter::Paint(bool fAll)
int bInVBlank;
GetVBlank(ScanLine, bInVBlank, false);
- if (fAll && (!m_bIsEVR || m_OrderedPaint))
- {
+ if (fAll && (!m_bIsEVR || m_OrderedPaint)) {
m_VBlankEndPresent = ScanLine;
}
- while (ScanLine == 0 || bInVBlank)
- {
+ while (ScanLine == 0 || bInVBlank) {
GetVBlank(ScanLine, bInVBlank, false);
}
m_VBlankStartMeasureTime = pApp->GetPerfCounter();
m_VBlankStartMeasure = ScanLine;
- if (fAll && bDoVSyncInPresent)
- {
+ if (fAll && bDoVSyncInPresent) {
m_PresentWaitTime = (pApp->GetPerfCounter() - llPerf) + PresentWaitTime;
m_PresentWaitTimeMin = min(m_PresentWaitTimeMin, m_PresentWaitTime);
m_PresentWaitTimeMax = max(m_PresentWaitTimeMax, m_PresentWaitTime);
- }
- else
- {
+ } else {
m_PresentWaitTime = 0;
m_PresentWaitTimeMin = min(m_PresentWaitTimeMin, m_PresentWaitTime);
m_PresentWaitTimeMax = max(m_PresentWaitTimeMax, m_PresentWaitTime);
}
}
- if (bDoVSyncInPresent)
- {
+ if (bDoVSyncInPresent) {
LONGLONG Time = pApp->GetPerfCounter();
- if (!m_bIsEVR || m_OrderedPaint)
+ if (!m_bIsEVR || m_OrderedPaint) {
CalculateJitter(Time);
+ }
OnVBlankFinished(fAll, Time);
}
- if (bTakenLock)
+ if (bTakenLock) {
UnlockD3DDevice();
+ }
/*if (!bWaited)
{
@@ -1849,12 +1752,10 @@ STDMETHODIMP_(bool) CDX9AllocatorPresenter::Paint(bool fAll)
}
}*/
- if (!m_bPendingResetDevice)
- {
+ if (!m_bPendingResetDevice) {
bool fResetDevice = false;
- if(hr == D3DERR_DEVICELOST && m_pD3DDev->TestCooperativeLevel() == D3DERR_DEVICENOTRESET)
- {
+ if(hr == D3DERR_DEVICELOST && m_pD3DDev->TestCooperativeLevel() == D3DERR_DEVICENOTRESET) {
TRACE("Reset Device: D3D Device Lost\n");
fResetDevice = true;
}
@@ -1865,66 +1766,55 @@ STDMETHODIMP_(bool) CDX9AllocatorPresenter::Paint(bool fAll)
// fResetDevice = true;
//}
- if (SettingsNeedResetDevice())
- {
+ if (SettingsNeedResetDevice()) {
TRACE("Reset Device: settings changed\n");
fResetDevice = true;
}
bCompositionEnabled = false;
- if (m_pDwmIsCompositionEnabled)
+ if (m_pDwmIsCompositionEnabled) {
m_pDwmIsCompositionEnabled(&bCompositionEnabled);
- if ((bCompositionEnabled != 0) != m_bCompositionEnabled)
- {
- if (m_bIsFullscreen)
- {
+ }
+ if ((bCompositionEnabled != 0) != m_bCompositionEnabled) {
+ if (m_bIsFullscreen) {
m_bCompositionEnabled = (bCompositionEnabled != 0);
- }
- else
- {
+ } else {
TRACE("Reset Device: DWM composition changed\n");
fResetDevice = true;
}
}
- if(s.fResetDevice)
- {
+ if(s.fResetDevice) {
LONGLONG time = GetRenderersData()->GetPerfCounter();
- if (time > m_LastAdapterCheck + 20000000) // check every 2 sec.
- {
+ if (time > m_LastAdapterCheck + 20000000) { // check every 2 sec.
m_LastAdapterCheck = time;
#ifdef _DEBUG
D3DDEVICE_CREATION_PARAMETERS Parameters;
- if(SUCCEEDED(m_pD3DDev->GetCreationParameters(&Parameters)))
- {
+ if(SUCCEEDED(m_pD3DDev->GetCreationParameters(&Parameters))) {
ASSERT(Parameters.AdapterOrdinal == m_CurrentAdapter);
}
#endif
- if(m_CurrentAdapter != GetAdapter(m_pD3D))
- {
+ if(m_CurrentAdapter != GetAdapter(m_pD3D)) {
TRACE("Reset Device: D3D adapter changed\n");
fResetDevice = true;
}
#ifdef _DEBUG
- else
- {
+ else {
ASSERT(m_pD3D->GetAdapterMonitor(m_CurrentAdapter) == m_pD3D->GetAdapterMonitor(GetAdapter(m_pD3D)));
}
#endif
}
}
- if(fResetDevice)
- {
+ if(fResetDevice) {
m_bPendingResetDevice = true;
SendResetRequest();
}
}
- if (m_OrderedPaint)
+ if (m_OrderedPaint) {
--m_OrderedPaint;
- else
- {
+ } else {
//if (m_bIsEVR)
// TRACE("UNORDERED PAINT!!!!!!\n");
}
@@ -1933,24 +1823,25 @@ STDMETHODIMP_(bool) CDX9AllocatorPresenter::Paint(bool fAll)
double CDX9AllocatorPresenter::GetFrameTime()
{
- if (m_DetectedLock)
+ if (m_DetectedLock) {
return m_DetectedFrameTime;
+ }
return m_rtTimePerFrame / 10000000.0;
}
double CDX9AllocatorPresenter::GetFrameRate()
{
- if (m_DetectedLock)
+ if (m_DetectedLock) {
return m_DetectedFrameRate;
+ }
return 10000000.0 / m_rtTimePerFrame;
}
void CDX9AllocatorPresenter::SendResetRequest()
{
- if (!m_bDeviceResetRequested)
- {
+ if (!m_bDeviceResetRequested) {
m_bDeviceResetRequested = true;
AfxGetApp()->m_pMainWnd->PostMessage(WM_RESET_DEVICE);
}
@@ -1966,8 +1857,7 @@ STDMETHODIMP_(bool) CDX9AllocatorPresenter::ResetDevice()
CString Error;
// TODO: Report error messages here
- if(FAILED(hr = CreateDevice(Error)) || FAILED(hr = AllocSurfaces()))
- {
+ if(FAILED(hr = CreateDevice(Error)) || FAILED(hr = AllocSurfaces())) {
// TODO: We should probably pause player
#ifdef _DEBUG
Error += GetWindowsErrorMessage(hr, NULL);
@@ -1985,40 +1875,50 @@ STDMETHODIMP_(bool) CDX9AllocatorPresenter::ResetDevice()
void CDX9AllocatorPresenter::DrawText(const RECT &rc, const CString &strText, int _Priority)
{
- if (_Priority < 1)
+ 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)
+ if (Quality == 1) {
OffsetRect (&Rect2 , 2, 2);
- else
+ } else {
OffsetRect (&Rect2 , -1, -1);
- if (Quality > 0)
+ }
+ if (Quality > 0) {
m_pFont->DrawText( m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
+ }
OffsetRect (&Rect2 , 1, 0);
- if (Quality > 3)
+ if (Quality > 3) {
m_pFont->DrawText( m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
+ }
OffsetRect (&Rect2 , 1, 0);
- if (Quality > 2)
+ if (Quality > 2) {
m_pFont->DrawText( m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
+ }
OffsetRect (&Rect2 , 0, 1);
- if (Quality > 3)
+ if (Quality > 3) {
m_pFont->DrawText( m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
+ }
OffsetRect (&Rect2 , 0, 1);
- if (Quality > 1)
+ if (Quality > 1) {
m_pFont->DrawText( m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
+ }
OffsetRect (&Rect2 , -1, 0);
- if (Quality > 3)
+ if (Quality > 3) {
m_pFont->DrawText( m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
+ }
OffsetRect (&Rect2 , -1, 0);
- if (Quality > 2)
+ if (Quality > 2) {
m_pFont->DrawText( m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
+ }
OffsetRect (&Rect2 , 0, -1);
- if (Quality > 3)
+ 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);
}
@@ -2028,17 +1928,16 @@ 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;
+ switch (pApp->m_fDisplayStats) {
+ case 1:
+ bDetailedStats = 2;
+ break;
+ case 2:
+ bDetailedStats = 1;
+ break;
+ case 3:
+ bDetailedStats = 0;
+ break;
}
LONGLONG llMaxJitter = m_MaxJitter;
@@ -2046,77 +1945,92 @@ void CDX9AllocatorPresenter::DrawStats()
LONGLONG llMaxSyncOffset = m_MaxSyncOffset;
LONGLONG llMinSyncOffset = m_MinSyncOffset;
RECT rc = {40, 40, 0, 0 };
- if (m_pFont && m_pSprite)
- {
+ if (m_pFont && m_pSprite) {
m_pSprite->Begin(D3DXSPRITE_ALPHABLEND);
CString strText;
int TextHeight = 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)
+ // 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) {
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
+ } 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 (%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 (bDetailedStats > 1)
- {
+ if (bDetailedStats > 1) {
strText.Format(L"Settings : ");
- if (m_bIsEVR)
+ if (m_bIsEVR) {
strText += "EVR ";
- else
+ } else {
strText += "VMR9 ";
+ }
- if (m_bIsFullscreen)
+ if (m_bIsFullscreen) {
strText += "FS ";
- if (s.m_RenderSettings.iVMR9FullscreenGUISupport)
+ }
+ if (s.m_RenderSettings.iVMR9FullscreenGUISupport) {
strText += "FSGui ";
+ }
- if (s.m_RenderSettings.iVMRDisableDesktopComposition)
+ if (s.m_RenderSettings.iVMRDisableDesktopComposition) {
strText += "DisDC ";
+ }
- if (m_bColorManagement)
+ if (m_bColorManagement) {
strText += "ColorMan ";
+ }
- if (s.m_RenderSettings.iVMRFlushGPUBeforeVSync)
+ if (s.m_RenderSettings.iVMRFlushGPUBeforeVSync) {
strText += "GPUFlushBV ";
- if (s.m_RenderSettings.iVMRFlushGPUAfterPresent)
+ }
+ if (s.m_RenderSettings.iVMRFlushGPUAfterPresent) {
strText += "GPUFlushAP ";
+ }
- if (s.m_RenderSettings.iVMRFlushGPUWait)
+ if (s.m_RenderSettings.iVMRFlushGPUWait) {
strText += "GPUFlushWt ";
+ }
- if (s.m_RenderSettings.iVMR9VSync)
+ if (s.m_RenderSettings.iVMR9VSync) {
strText += "VS ";
- if (s.m_RenderSettings.fVMR9AlterativeVSync)
+ }
+ if (s.m_RenderSettings.fVMR9AlterativeVSync) {
strText += "AltVS ";
- if (s.m_RenderSettings.iVMR9VSyncAccurate)
+ }
+ if (s.m_RenderSettings.iVMR9VSyncAccurate) {
strText += "AccVS ";
- if (s.m_RenderSettings.iVMR9VSyncOffset)
+ }
+ if (s.m_RenderSettings.iVMR9VSyncOffset) {
strText.AppendFormat(L"VSOfst(%d)", s.m_RenderSettings.iVMR9VSyncOffset);
+ }
- if (m_bFullFloatingPointProcessing)
+ if (m_bFullFloatingPointProcessing) {
strText += "FullFP ";
+ }
- if (m_bIsEVR)
- {
- if (m_bHighColorResolution)
+ if (m_bIsEVR) {
+ if (m_bHighColorResolution) {
strText += "10bitOut ";
- if (m_bForceInputHighColorResolution)
+ }
+ if (m_bForceInputHighColorResolution) {
strText += "For10bitIn ";
- if (s.m_RenderSettings.iEVREnableFrameTimeCorrection)
+ }
+ if (s.m_RenderSettings.iEVREnableFrameTimeCorrection) {
strText += "FTC ";
- if (s.m_RenderSettings.iEVROutputRange == 0)
+ }
+ if (s.m_RenderSettings.iEVROutputRange == 0) {
strText += "0-255 ";
- else if (s.m_RenderSettings.iEVROutputRange == 1)
+ } else if (s.m_RenderSettings.iEVROutputRange == 1) {
strText += "16-235 ";
+ }
}
@@ -2125,39 +2039,35 @@ void CDX9AllocatorPresenter::DrawStats()
}
- if (bDetailedStats > 1)
- {
+ 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)
- {
+ 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)
+ 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
+ } else {
strText.Format(L"Sync offset : Mode = %d", m_VSyncMode);
+ }
DrawText(rc, strText, 1);
OffsetRect (&rc, 0, TextHeight);
}
- if (bDetailedStats > 1)
- {
+ 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)
- {
+ if (m_pAllocator && bDetailedStats > 1) {
CDX9SubPicAllocator *pAlloc = (CDX9SubPicAllocator *)m_pAllocator.p;
int nFree = 0;
int nAlloc = 0;
@@ -2165,13 +2075,14 @@ void CDX9AllocatorPresenter::DrawStats()
REFERENCE_TIME QueueNow = 0;
REFERENCE_TIME QueueStart = 0;
REFERENCE_TIME QueueEnd = 0;
- if (m_pSubPicQueue)
- {
+ if (m_pSubPicQueue) {
m_pSubPicQueue->GetStats(nSubPic, QueueNow, QueueStart, QueueEnd);
- if (QueueStart)
+ if (QueueStart) {
QueueStart -= QueueNow;
- if (QueueEnd)
+ }
+ 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));
@@ -2179,19 +2090,18 @@ void CDX9AllocatorPresenter::DrawStats()
OffsetRect (&rc, 0, TextHeight);
}
- if (bDetailedStats > 1)
- {
- if (m_VBlankEndPresent == -100000)
+ 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
+ } 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)
+ }
+ } else {
+ if (m_VBlankEndPresent == -100000) {
strText.Format(L"VBlank Wait : Start %4d End %4d", m_VBlankStartWait, m_VBlankEndWait);
- else
+ } 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);
@@ -2200,64 +2110,59 @@ void CDX9AllocatorPresenter::DrawStats()
bool bDoVSyncInPresent = (!bCompositionEnabled && !m_bAlternativeVSync) || !s.m_RenderSettings.iVMR9VSync;
- if (bDetailedStats > 1 && bDoVSyncInPresent)
- {
+ 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)
+ 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
+ } 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)
+ }
+ } 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
+ } 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)
- {
+ 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)
+ 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
+ } else {
strText.Format(L"Buffering : VMR9Surfaces %3d VMR9Surface %3d", m_nVMR9Surfaces, m_iVMR9Surface);
- }
- else
+ }
+ } else {
strText.Format(L"Buffered : %3d", m_nUsedBuffer);
+ }
DrawText(rc, strText, 1);
OffsetRect (&rc, 0, TextHeight);
- if (bDetailedStats > 1)
- {
+ 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])
- {
+ if (m_pVideoTexture[0] || m_pVideoSurface[0]) {
D3DSURFACE_DESC desc;
- if (m_pVideoTexture[0])
+ if (m_pVideoTexture[0]) {
m_pVideoTexture[0]->GetLevelDesc(0, &desc);
- else if (m_pVideoSurface[0])
+ } else if (m_pVideoSurface[0]) {
m_pVideoSurface[0]->GetDesc(&desc);
+ }
- if (desc.Width != (UINT)m_NativeVideoSize.cx || desc.Height != (UINT)m_NativeVideoSize.cy)
- {
+ 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);
@@ -2269,8 +2174,7 @@ void CDX9AllocatorPresenter::DrawStats()
DrawText(rc, strText, 1);
OffsetRect (&rc, 0, TextHeight);
- if(m_D3D9Device != _T(""))
- {
+ if(m_D3D9Device != _T("")) {
strText = "Render device: " + m_D3D9Device;
DrawText(rc, strText, 1);
OffsetRect (&rc, 0, TextHeight);
@@ -2280,10 +2184,8 @@ void CDX9AllocatorPresenter::DrawStats()
DrawText(rc, strText, 1);
OffsetRect (&rc, 0, TextHeight);
- for (int i=0; i<6; i++)
- {
- if (m_strStatsMsg[i][0])
- {
+ for (int i=0; i<6; i++) {
+ if (m_strStatsMsg[i][0]) {
DrawText(rc, m_strStatsMsg[i], 1);
OffsetRect (&rc, 0, TextHeight);
}
@@ -2293,8 +2195,7 @@ void CDX9AllocatorPresenter::DrawStats()
OffsetRect(&rc, 0, TextHeight); // Extra "line feed"
}
- if (m_pLine && bDetailedStats)
- {
+ if (m_pLine && bDetailedStats) {
D3DXVECTOR2 Points[NB_JITTER];
int nIndex;
@@ -2310,44 +2211,43 @@ void CDX9AllocatorPresenter::DrawStats()
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.2); // Width
+ // m_pLine->SetAntialias(1);
m_pLine->SetWidth(2.5); // Width
m_pLine->SetAntialias(1);
-// m_pLine->SetGLLines(1);
+ // m_pLine->SetGLLines(1);
m_pLine->Begin();
- for (int i=10; i<250*ScaleY; i+= 10*ScaleY)
- {
+ 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;
+ 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++)
- {
+ if (m_rtTimePerFrame) {
+ for (int i=0; i<NB_JITTER; i++) {
nIndex = (m_nNextJitter+1+i) % NB_JITTER;
- if (nIndex < 0)
+ 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++)
- {
+ if (m_bSyncStatsAvailable) {
+ for (int i=0; i<NB_JITTER; i++) {
nIndex = (m_nNextSyncOffset+1+i) % NB_JITTER;
- if (nIndex < 0)
+ 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));
}
@@ -2372,23 +2272,24 @@ STDMETHODIMP CDX9AllocatorPresenter::GetDIB(BYTE* lpDib, DWORD* size)
m_pVideoSurface[m_nCurSurface]->GetDesc(&desc);
DWORD required = sizeof(BITMAPINFOHEADER) + (desc.Width * desc.Height * 32 >> 3);
- if(!lpDib)
- {
+ if(!lpDib) {
*size = required;
return S_OK;
}
- if(*size < required) return E_OUTOFMEMORY;
+ 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)))
- {
+ 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)))
+ || FAILED(hr = pSurface->LockRect(&r, NULL, D3DLOCK_READONLY))) {
return hr;
+ }
}
BITMAPINFOHEADER* bih = (BITMAPINFOHEADER*)lpDib;
diff --git a/src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.h b/src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.h
index c91bc9118..6d8bd84a3 100644
--- a/src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.h
+++ b/src/filters/renderer/VideoRenderers/DX9AllocatorPresenter.h
@@ -35,269 +35,265 @@ extern bool g_bExternalSubtitleTime;
namespace DSObjects
{
-class CDX9AllocatorPresenter
- : public CDX9RenderingEngine
-{
-public:
- CCritSec m_VMR9AlphaBitmapLock;
- void UpdateAlphaBitmap();
-protected:
- UINT m_RefreshRate;
-
-// bool m_fVMRSyncFix;
- 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;
+ class CDX9AllocatorPresenter
+ : public CDX9RenderingEngine
+ {
+ public:
+ CCritSec m_VMR9AlphaBitmapLock;
+ void UpdateAlphaBitmap();
+ protected:
+ UINT m_RefreshRate;
+
+ // bool m_fVMRSyncFix;
+ 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);
+ }
+ }
+ }
+ }
- HRESULT (__stdcall * m_pDirect3DCreate9Ex)(UINT SDKVersion, IDirect3D9Ex**);
- HMODULE m_hD3D9;
+ void UnlockD3DDevice() {
+ if (m_pD3DDev) {
+ _RTL_CRITICAL_SECTION *pCritSec = (_RTL_CRITICAL_SECTION *)((size_t)m_pD3DDev.p + sizeof(size_t));
- CCritSec m_RenderLock;
- CComPtr<IDirectDraw> m_pDirectDraw;
+ 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);
+ }
+ }
+ }
+ }
- 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);
+ 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(D3DFORMAT Format = D3DFMT_A8R8G8B8);
+ 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 GetAdapter = false);
+ 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* 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 DrawStats();
+ virtual void OnResetDevice() {};
+ void SendResetRequest();
+
+ double GetFrameTime();
+ double GetFrameRate();
+
+
+ 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_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;
+
+ bool SetCurrentDisplayMode();
+
+ double GetRefreshRate() {
+ if (m_DetectedRefreshRate) {
+ return m_DetectedRefreshRate;
}
+ return m_RefreshRate;
}
- }
- 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);
+ LONG GetScanLines() {
+ if (m_DetectedRefreshRate) {
+ return m_DetectedScanlinesPerFrame;
}
+ return m_ScreenSize.cy;
}
- }
-
- 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(D3DFORMAT Format = D3DFMT_A8R8G8B8);
- 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 GetAdapter = false);
- 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* 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 DrawStats();
- virtual void OnResetDevice() {};
- void SendResetRequest();
-
- double GetFrameTime();
- double GetFrameRate();
-
-
- 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_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;
-
- bool SetCurrentDisplayMode();
-
- double GetRefreshRate()
- {
- if (m_DetectedRefreshRate)
- return m_DetectedRefreshRate;
- return m_RefreshRate;
- }
- LONG GetScanLines()
- {
- if (m_DetectedRefreshRate)
- return 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;
-
- 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;
-
-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();
-};
+ 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;
+
+ 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;
+
+ 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();
+ };
}
diff --git a/src/filters/renderer/VideoRenderers/DX9RenderingEngine.cpp b/src/filters/renderer/VideoRenderers/DX9RenderingEngine.cpp
index 7dfabc7f5..7c34f1703 100644
--- a/src/filters/renderer/VideoRenderers/DX9RenderingEngine.cpp
+++ b/src/filters/renderer/VideoRenderers/DX9RenderingEngine.cpp
@@ -29,17 +29,14 @@
#pragma pack(push, 1)
template<int texcoords>
-struct MYD3DVERTEX
-{
+struct MYD3DVERTEX {
float x, y, z, rhw;
- struct
- {
+ struct {
float u, v;
} t[texcoords];
};
template<>
-struct MYD3DVERTEX<0>
-{
+struct MYD3DVERTEX<0> {
float x, y, z, rhw;
DWORD Diffuse;
};
@@ -50,19 +47,16 @@ static void AdjustQuad(MYD3DVERTEX<texcoords>* v, double dx, double dy)
{
double offset = 0.5;
- for(int i = 0; i < 4; i++)
- {
+ 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++)
- {
+ for(int j = 0; j < max(texcoords-1, 1); j++) {
v[i].t[j].u -= offset*dx;
v[i].t[j].v -= offset*dy;
}
- if(texcoords > 1)
- {
+ if(texcoords > 1) {
v[i].t[texcoords-1].u -= offset;
v[i].t[texcoords-1].v -= offset;
}
@@ -72,39 +66,39 @@ static void AdjustQuad(MYD3DVERTEX<texcoords>* v, double dx, double dy)
template<int texcoords>
static HRESULT TextureBlt(IDirect3DDevice9* pD3DDev, MYD3DVERTEX<texcoords> v[4], D3DTEXTUREFILTERTYPE filter = D3DTEXF_LINEAR)
{
- if(!pD3DDev)
+ 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;
+ 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;
@@ -118,8 +112,7 @@ static HRESULT TextureBlt(IDirect3DDevice9* pD3DDev, MYD3DVERTEX<texcoords> v[4]
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++)
- {
+ 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, filter);
@@ -140,8 +133,7 @@ static HRESULT TextureBlt(IDirect3DDevice9* pD3DDev, MYD3DVERTEX<texcoords> v[4]
//
- for(int i = 0; i < texcoords; i++)
- {
+ for(int i = 0; i < texcoords; i++) {
pD3DDev->SetTexture(i, NULL);
}
@@ -162,8 +154,7 @@ CDX9RenderingEngine::CDX9RenderingEngine(HWND hWnd, HRESULT& hr, CString *_pErro
HINSTANCE hDll = GetRenderersData()->GetD3X9Dll();
m_bD3DX = hDll != NULL;
- if (m_bD3DX)
- {
+ if (m_bD3DX) {
(FARPROC&)m_pD3DXFloat32To16Array = GetProcAddress(hDll, "D3DXFloat32To16Array");
}
}
@@ -176,8 +167,9 @@ void CDX9RenderingEngine::InitRenderingEngine()
// Detect supported StrechRect filter
m_StretchRectFilter = D3DTEXF_NONE;
if((m_Caps.StretchRectFilterCaps&D3DPTFILTERCAPS_MINFLINEAR)
- && (m_Caps.StretchRectFilterCaps&D3DPTFILTERCAPS_MAGFLINEAR))
+ && (m_Caps.StretchRectFilterCaps&D3DPTFILTERCAPS_MAGFLINEAR)) {
m_StretchRectFilter = D3DTEXF_LINEAR;
+ }
// Detect FP16 support
renderersData->m_bFP16Support = true;
@@ -218,26 +210,24 @@ void CDX9RenderingEngine::CleanupRenderingEngine()
{
m_pPSC.Free();
- for (int i = 0; i < 4; i++)
+ for (int i = 0; i < 4; i++) {
m_pResizerPixelShaders[i] = NULL;
+ }
CleanupFinalPass();
POSITION pos = m_pCustomScreenSpacePixelShaders.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CExternalPixelShader &Shader = m_pCustomScreenSpacePixelShaders.GetNext(pos);
Shader.m_pPixelShader = NULL;
}
pos = m_pCustomPixelShaders.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CExternalPixelShader &Shader = m_pCustomPixelShaders.GetNext(pos);
Shader.m_pPixelShader = NULL;
}
- for (int i = 0; i < 2; i++)
- {
+ for (int i = 0; i < 2; i++) {
m_pTemporaryVideoTextures[i] = NULL;
m_pTemporaryScreenSpaceTextures[i] = NULL;
}
@@ -252,48 +242,46 @@ HRESULT CDX9RenderingEngine::CreateVideoSurfaces(D3DFORMAT format)
FreeVideoSurfaces();
// Free previously allocated temporary video textures, because the native video size might have been changed!
- for (int i = 0; i < 2; i++)
+ for (int i = 0; i < 2; i++) {
m_pTemporaryVideoTextures[i] = NULL;
+ }
m_SurfaceType = format;
- if (settings.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE2D || settings.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D)
- {
+ 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++)
- {
+ 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)))
+ D3DPOOL_DEFAULT, &m_pVideoTexture[i], NULL))) {
return hr;
+ }
- if (FAILED(hr = m_pVideoTexture[i]->GetSurfaceLevel(0, &m_pVideoSurface[i])))
+ if (FAILED(hr = m_pVideoTexture[i]->GetSurfaceLevel(0, &m_pVideoSurface[i]))) {
return hr;
+ }
}
- if (settings.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE2D)
- {
+ if (settings.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE2D) {
m_RenderingPath = RENDERING_PATH_STRETCHRECT;
- for (int i = 0; i < m_nNbDXSurface; i++)
+ for (int i = 0; i < m_nNbDXSurface; i++) {
m_pVideoTexture[i] = NULL;
- }
- else
- {
+ }
+ } else {
m_RenderingPath = RENDERING_PATH_DRAW;
}
- }
- else
- {
+ } else {
m_RenderingPath = RENDERING_PATH_STRETCHRECT;
if (FAILED(hr = m_pD3DDev->CreateOffscreenPlainSurface(
m_NativeVideoSize.cx, m_NativeVideoSize.cy,
format,
- D3DPOOL_DEFAULT, &m_pVideoSurface[m_nCurSurface], NULL)))
+ D3DPOOL_DEFAULT, &m_pVideoSurface[m_nCurSurface], NULL))) {
return hr;
+ }
}
hr = m_pD3DDev->ColorFill(m_pVideoSurface[m_nCurSurface], NULL, 0);
@@ -303,8 +291,7 @@ HRESULT CDX9RenderingEngine::CreateVideoSurfaces(D3DFORMAT format)
void CDX9RenderingEngine::FreeVideoSurfaces()
{
- for (int i = 0; i < m_nNbDXSurface; i++)
- {
+ for (int i = 0; i < m_nNbDXSurface; i++) {
m_pVideoTexture[i] = NULL;
m_pVideoSurface[i] = NULL;
}
@@ -312,13 +299,15 @@ void CDX9RenderingEngine::FreeVideoSurfaces()
HRESULT CDX9RenderingEngine::RenderVideo(IDirect3DSurface9* pRenderTarget, const CRect& srcRect, const CRect& destRect)
{
- if (destRect.IsRectEmpty())
+ if (destRect.IsRectEmpty()) {
return S_OK;
+ }
- if (m_RenderingPath == RENDERING_PATH_DRAW)
+ if (m_RenderingPath == RENDERING_PATH_DRAW) {
return RenderVideoDrawPath(pRenderTarget, srcRect, destRect);
- else
+ } else {
return RenderVideoStretchRectPath(pRenderTarget, srcRect, destRect);
+ }
}
HRESULT CDX9RenderingEngine::RenderVideoDrawPath(IDirect3DSurface9* pRenderTarget, const CRect& srcRect, const CRect& destRect)
@@ -326,8 +315,9 @@ HRESULT CDX9RenderingEngine::RenderVideoDrawPath(IDirect3DSurface9* pRenderTarge
HRESULT hr;
// Return if the video texture is not initialized
- if (m_pVideoTexture[m_nCurSurface] == 0)
+ if (m_pVideoTexture[m_nCurSurface] == 0) {
return S_OK;
+ }
CRenderersSettings& settings = GetRenderersSettings();
@@ -340,31 +330,31 @@ HRESULT CDX9RenderingEngine::RenderVideoDrawPath(IDirect3DSurface9* pRenderTarge
int screenSpacePassCount = 0;
DWORD iDX9Resizer = settings.iDX9Resizer;
- if (m_bD3DX)
- {
+ if (m_bD3DX) {
// Final pass. Must be initialized first!
hr = InitFinalPass();
- if (SUCCEEDED(hr))
+ if (SUCCEEDED(hr)) {
bFinalPass = m_bFinalPass;
- else
+ } else {
bFinalPass = false;
+ }
- if (bFinalPass)
+ 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;
+ 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);
@@ -374,18 +364,18 @@ HRESULT CDX9RenderingEngine::RenderVideoDrawPath(IDirect3DSurface9* pRenderTarge
// Custom screen space pixel shaders
bCustomScreenSpacePixelShaders = !m_pCustomScreenSpacePixelShaders.IsEmpty();
- if (bCustomScreenSpacePixelShaders)
+ if (bCustomScreenSpacePixelShaders) {
screenSpacePassCount += m_pCustomScreenSpacePixelShaders.GetCount();
+ }
// Custom pixel shaders
bCustomPixelShaders = !m_pCustomPixelShaders.IsEmpty();
hr = InitTemporaryVideoTextures(min(m_pCustomPixelShaders.GetCount(), 2));
- if (FAILED(hr))
+ if (FAILED(hr)) {
bCustomPixelShaders = false;
- }
- else
- {
+ }
+ } else {
bCustomPixelShaders = false;
bResizerShaders = false;
bCustomScreenSpacePixelShaders = false;
@@ -393,8 +383,7 @@ HRESULT CDX9RenderingEngine::RenderVideoDrawPath(IDirect3DSurface9* pRenderTarge
}
hr = InitScreenSpacePipeline(screenSpacePassCount, pRenderTarget);
- if (FAILED(hr))
- {
+ if (FAILED(hr)) {
bCustomScreenSpacePixelShaders = false;
bFinalPass = false;
}
@@ -402,30 +391,29 @@ HRESULT CDX9RenderingEngine::RenderVideoDrawPath(IDirect3DSurface9* pRenderTarge
// Apply the custom pixel shaders if there are any. Result: pVideoTexture
CComPtr<IDirect3DTexture9> pVideoTexture = m_pVideoTexture[m_nCurSurface];
- if (bCustomPixelShaders)
- {
+ 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(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);
- float fConstData[][4] =
- {
+ 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();
- float fConstData[][4] =
- {
+ 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},
};
@@ -438,24 +426,21 @@ HRESULT CDX9RenderingEngine::RenderVideoDrawPath(IDirect3DSurface9* pRenderTarge
bool first = true;
POSITION pos = m_pCustomPixelShaders.GetHeadPosition();
- while(pos)
- {
+ 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)
+ if (!Shader.m_pPixelShader) {
Shader.Compile(m_pPSC);
+ }
hr = m_pD3DDev->SetPixelShader(Shader.m_pPixelShader);
- if (first)
- {
+ if (first) {
TextureCopy(m_pVideoTexture[m_nCurSurface]);
first = false;
- }
- else
- {
+ } else {
TextureCopy(m_pTemporaryVideoTextures[src]);
}
@@ -471,40 +456,36 @@ HRESULT CDX9RenderingEngine::RenderVideoDrawPath(IDirect3DSurface9* pRenderTarge
hr = BeginScreenSpacePass();
- if (m_ScreenSpacePassCount > 0)
+ 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)
- {
+ 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)
- {
+ } else if (iDX9Resizer == 2) {
hr = TextureResizeBilinear(pVideoTexture, dst, srcRect);
- }
- else if (iDX9Resizer >= 3)
- {
+ } else if (iDX9Resizer >= 3) {
hr = TextureResizeBicubic1pass(pVideoTexture, dst, srcRect);
}
+ } else {
+ hr = TextureResize(pVideoTexture, dst, D3DTEXF_POINT, srcRect);
}
- else hr = TextureResize(pVideoTexture, dst, D3DTEXF_POINT, srcRect);
// Apply the custom screen size pixel shaders
- if (bCustomScreenSpacePixelShaders)
- {
+ 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)
+ 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 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},
};
@@ -512,21 +493,20 @@ HRESULT CDX9RenderingEngine::RenderVideoDrawPath(IDirect3DSurface9* pRenderTarge
hr = m_pD3DDev->SetPixelShaderConstantF(0, (float*)fConstData, countof(fConstData));
POSITION pos = m_pCustomScreenSpacePixelShaders.GetHeadPosition();
- while (pos)
- {
+ while (pos) {
BeginScreenSpacePass();
CExternalPixelShader &Shader = m_pCustomScreenSpacePixelShaders.GetNext(pos);
- if (!Shader.m_pPixelShader)
+ if (!Shader.m_pPixelShader) {
Shader.Compile(m_pPSC);
+ }
hr = m_pD3DDev->SetPixelShader(Shader.m_pPixelShader);
TextureCopy(m_pTemporaryScreenSpaceTextures[m_ScreenSpacePassSrc]);
}
}
// Final pass
- if (bFinalPass)
- {
+ if (bFinalPass) {
hr = BeginScreenSpacePass();
hr = FinalPass(m_pTemporaryScreenSpaceTextures[m_ScreenSpacePassSrc]);
}
@@ -541,8 +521,9 @@ HRESULT CDX9RenderingEngine::RenderVideoStretchRectPath(IDirect3DSurface9* pRend
HRESULT hr;
// Return if the render target or the video surface is not initialized
- if (pRenderTarget == 0 || m_pVideoSurface[m_nCurSurface] == 0)
+ if (pRenderTarget == 0 || m_pVideoSurface[m_nCurSurface] == 0) {
return S_OK;
+ }
CRect rSrcVid(srcRect);
CRect rDstVid(destRect);
@@ -562,32 +543,28 @@ HRESULT CDX9RenderingEngine::InitTemporaryVideoTextures(int count)
{
HRESULT hr = S_OK;
- for (int i = 0; i < count; i++)
- {
- if (m_pTemporaryVideoTextures[i] == NULL)
- {
+ for (int i = 0; i < count; i++) {
+ if (m_pTemporaryVideoTextures[i] == NULL) {
D3DFORMAT format;
- if (m_bFullFloatingPointProcessing)
- {
+ if (m_bFullFloatingPointProcessing) {
format = D3DFMT_A16B16G16R16F;
- }
- else
- {
- if (m_bHighColorResolution || m_bForceInputHighColorResolution)
+ } else {
+ if (m_bHighColorResolution || m_bForceInputHighColorResolution) {
format = D3DFMT_A2R10G10B10;
- else
+ } else {
format = D3DFMT_A8R8G8B8;
+ }
}
hr = m_pD3DDev->CreateTexture(
m_NativeVideoSize.cx, m_NativeVideoSize.cy, 1, D3DUSAGE_RENDERTARGET, format,
D3DPOOL_DEFAULT, &m_pTemporaryVideoTextures[i], NULL);
- if (FAILED(hr))
- {
+ if (FAILED(hr)) {
// Free all textures
- for (int j = 0; j < 2; j++)
+ for (int j = 0; j < 2; j++) {
m_pTemporaryVideoTextures[j] = NULL;
+ }
return hr;
}
@@ -595,8 +572,9 @@ HRESULT CDX9RenderingEngine::InitTemporaryVideoTextures(int count)
}
// Free unnecessary textures
- for (int i = count; i < 2; i++)
+ for (int i = count; i < 2; i++) {
m_pTemporaryVideoTextures[i] = NULL;
+ }
return hr;
}
@@ -611,8 +589,9 @@ HRESULT CDX9RenderingEngine::InitScreenSpacePipeline(int passCount, IDirect3DSur
HRESULT hr = InitTemporaryScreenSpaceTextures(min(passCount - 1, 2));
// If the initialized have failed, disable the pipeline
- if (FAILED(hr))
+ if (FAILED(hr)) {
m_ScreenSpacePassCount = 1;
+ }
return hr;
}
@@ -621,35 +600,31 @@ HRESULT CDX9RenderingEngine::InitTemporaryScreenSpaceTextures(int count)
{
HRESULT hr = S_OK;
- for (int i = 0; i < count; i++)
- {
- if (m_pTemporaryScreenSpaceTextures[i] == NULL)
- {
+ 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));
+ min(max(m_ScreenSize.cy, m_NativeVideoSize.cy), (int)m_Caps.MaxTextureHeight));
D3DFORMAT format;
- if (m_bFullFloatingPointProcessing)
- {
+ if (m_bFullFloatingPointProcessing) {
format = D3DFMT_A16B16G16R16F;
- }
- else
- {
- if (m_bHighColorResolution || m_bForceInputHighColorResolution)
+ } else {
+ if (m_bHighColorResolution || m_bForceInputHighColorResolution) {
format = D3DFMT_A2R10G10B10;
- else
+ } else {
format = D3DFMT_A8R8G8B8;
+ }
}
hr = m_pD3DDev->CreateTexture(
m_TemporaryScreenSpaceTextureSize.cx, m_TemporaryScreenSpaceTextureSize.cy, 1, D3DUSAGE_RENDERTARGET, format,
D3DPOOL_DEFAULT, &m_pTemporaryScreenSpaceTextures[i], NULL);
- if (FAILED(hr))
- {
+ if (FAILED(hr)) {
// Free all textures
- for (int j = 0; j < 2; j++)
+ for (int j = 0; j < 2; j++) {
m_pTemporaryScreenSpaceTextures[j] = NULL;
+ }
return hr;
}
@@ -657,8 +632,9 @@ HRESULT CDX9RenderingEngine::InitTemporaryScreenSpaceTextures(int count)
}
// Free unnecessary textures
- for (int i = count; i < 2; i++)
+ for (int i = count; i < 2; i++) {
m_pTemporaryScreenSpaceTextures[i] = NULL;
+ }
return hr;
}
@@ -670,16 +646,14 @@ HRESULT CDX9RenderingEngine::BeginScreenSpacePass()
swap(m_ScreenSpacePassSrc, m_ScreenSpacePassDest);
--m_ScreenSpacePassCount;
- if (m_ScreenSpacePassCount > 0)
- {
+ if (m_ScreenSpacePassCount > 0) {
CComPtr<IDirect3DSurface9> pTemporarySurface;
hr = m_pTemporaryScreenSpaceTextures[m_ScreenSpacePassDest]->GetSurfaceLevel(0, &pTemporarySurface);
- if (SUCCEEDED(hr))
+ if (SUCCEEDED(hr)) {
hr = m_pD3DDev->SetRenderTarget(0, pTemporarySurface);
- }
- else
- {
+ }
+ } else {
hr = m_pD3DDev->SetRenderTarget(0, m_pRenderTarget);
}
@@ -693,40 +667,43 @@ HRESULT CDX9RenderingEngine::InitResizers(float bicubicA)
// 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])
+ if (bicubicA) {
+ for (int i = 0; i < 4; i++) {
+ if (!m_pResizerPixelShaders[i]) {
bInitRequired = true;
+ }
}
- if (m_BicubicA != bicubicA)
+ if (m_BicubicA != bicubicA) {
bInitRequired = true;
- }
- else
- {
- if (!m_pResizerPixelShaders[0])
+ }
+ } else {
+ if (!m_pResizerPixelShaders[0]) {
bInitRequired = true;
+ }
}
- if (!bInitRequired)
+ if (!bInitRequired) {
return S_OK;
+ }
// Initialize the resizer pixel shaders
m_BicubicA = bicubicA;
- for (int i = 0; i < countof(m_pResizerPixelShaders); i++)
+ for (int i = 0; i < countof(m_pResizerPixelShaders); i++) {
m_pResizerPixelShaders[i] = NULL;
+ }
- if (m_Caps.PixelShaderVersion < D3DPS_VERSION(2, 0))
+ 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")))
+ if (!LoadResource(IDF_SHADER_RESIZER, str, _T("FILE"))) {
return E_FAIL;
+ }
CStringA A;
A.Format("(%f)", bicubicA);
@@ -736,13 +713,11 @@ HRESULT CDX9RenderingEngine::InitResizers(float bicubicA)
ASSERT(countof(pEntries) == countof(m_pResizerPixelShaders));
- for (int i = 0; i < countof(pEntries); i++)
- {
+ 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))
- {
+ if (FAILED(hr)) {
TRACE("%ws", ErrorMessage.GetString());
ASSERT (0);
return hr;
@@ -777,8 +752,9 @@ HRESULT CDX9RenderingEngine::TextureResize(IDirect3DTexture9* pTexture, Vector d
HRESULT hr;
D3DSURFACE_DESC desc;
- if (!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc)))
+ if (!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc))) {
return E_FAIL;
+ }
float w = (float)desc.Width;
float h = (float)desc.Height;
@@ -786,8 +762,7 @@ HRESULT CDX9RenderingEngine::TextureResize(IDirect3DTexture9* pTexture, Vector d
float dx2 = 1.0/w;
float dy2 = 1.0/h;
- MYD3DVERTEX<1> v[] =
- {
+ 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},
@@ -808,8 +783,9 @@ HRESULT CDX9RenderingEngine::TextureResizeBilinear(IDirect3DTexture9* pTexture,
HRESULT hr;
D3DSURFACE_DESC desc;
- if (!pTexture || FAILED(pTexture->GetLevelDesc(0, &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;
@@ -819,8 +795,7 @@ HRESULT CDX9RenderingEngine::TextureResizeBilinear(IDirect3DTexture9* pTexture,
const float ty0 = srcRect.top;
const float ty1 = srcRect.bottom;
- MYD3DVERTEX<1> v[] =
- {
+ 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},
@@ -846,8 +821,9 @@ HRESULT CDX9RenderingEngine::TextureResizeBicubic1pass(IDirect3DTexture9* pTextu
HRESULT hr;
D3DSURFACE_DESC desc;
- if (!pTexture || FAILED(pTexture->GetLevelDesc(0, &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;
@@ -857,8 +833,7 @@ HRESULT CDX9RenderingEngine::TextureResizeBicubic1pass(IDirect3DTexture9* pTextu
const float ty0 = srcRect.top;
const float ty1 = srcRect.bottom;
- MYD3DVERTEX<1> v[] =
- {
+ 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},
@@ -1015,31 +990,30 @@ HRESULT CDX9RenderingEngine::InitFinalPass()
bool bInitRequired = false;
if ((m_bFullFloatingPointProcessing != bFullFloatingPointProcessing) ||
- (m_bColorManagement != bColorManagement))
- {
+ (m_bColorManagement != bColorManagement)) {
bInitRequired = true;
}
- if (m_bColorManagement && bColorManagement)
- {
+ if (m_bColorManagement && bColorManagement) {
if ((m_InputVideoSystem != inputVideoSystem) ||
- (m_RenderingIntent != renderingIntent) ||
- (m_AmbientLight != ambientLight))
- {
+ (m_RenderingIntent != renderingIntent) ||
+ (m_AmbientLight != ambientLight)) {
bInitRequired = true;
}
}
- if (!bInitRequired)
+ if (!bInitRequired) {
return S_OK;
+ }
// Cleanup
CleanupFinalPass();
// Check whether the final pass is supported by the hardware
m_bFinalPass = data->m_bFP16Support;
- if (!m_bFinalPass)
+ if (!m_bFinalPass) {
return S_OK;
+ }
// Update the settings
m_bFullFloatingPointProcessing = bFullFloatingPointProcessing;
@@ -1052,8 +1026,9 @@ HRESULT CDX9RenderingEngine::InitFinalPass()
m_bFinalPass = bFullFloatingPointProcessing || bColorManagement ||
(m_bForceInputHighColorResolution && !m_bHighColorResolution);
- if (!m_bFinalPass)
+ if (!m_bFinalPass) {
return S_OK;
+ }
// Create the dither texture
hr = m_pD3DDev->CreateTexture(DITHER_MATRIX_SIZE, DITHER_MATRIX_SIZE,
@@ -1064,54 +1039,47 @@ HRESULT CDX9RenderingEngine::InitFinalPass()
&m_pDitherTexture,
NULL);
- if (FAILED(hr))
- {
+ if (FAILED(hr)) {
CleanupFinalPass();
return hr;
}
D3DLOCKED_RECT lockedRect;
hr = m_pDitherTexture->LockRect(0, &lockedRect, NULL, D3DLOCK_DISCARD);
- if (FAILED(hr))
- {
+ if (FAILED(hr)) {
CleanupFinalPass();
return hr;
}
char* outputRowIterator = static_cast<char*>(lockedRect.pBits);
- for (int y = 0; y < DITHER_MATRIX_SIZE; y++)
- {
+ 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++)
+ 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))
- {
+ if (FAILED(hr)) {
CleanupFinalPass();
return hr;
}
// Initialize the color management if necessary
- if (bColorManagement)
- {
+ if (bColorManagement) {
// Get the ICC profile path
TCHAR* iccProfilePath = 0;
HDC hDC = GetDC(m_hWnd);
- if (hDC != NULL)
- {
+ if (hDC != NULL) {
DWORD icmProfilePathSize = 0;
GetICMProfile(hDC, &icmProfilePathSize, NULL);
iccProfilePath = new TCHAR[icmProfilePathSize];
- if (!GetICMProfile(hDC, &icmProfilePathSize, iccProfilePath))
- {
+ if (!GetICMProfile(hDC, &icmProfilePathSize, iccProfilePath)) {
delete[] iccProfilePath;
iccProfilePath = 0;
}
@@ -1131,8 +1099,7 @@ HRESULT CDX9RenderingEngine::InitFinalPass()
&m_pLut3DTexture,
NULL);
- if (FAILED(hr))
- {
+ if (FAILED(hr)) {
delete[] iccProfilePath;
CleanupFinalPass();
return hr;
@@ -1141,8 +1108,7 @@ HRESULT CDX9RenderingEngine::InitFinalPass()
float* lut3DFloat32 = new float[m_Lut3DEntryCount * 3];
hr = CreateIccProfileLut(iccProfilePath, lut3DFloat32);
delete[] iccProfilePath;
- if (FAILED(hr))
- {
+ if (FAILED(hr)) {
delete[] lut3DFloat32;
CleanupFinalPass();
return hr;
@@ -1158,8 +1124,7 @@ HRESULT CDX9RenderingEngine::InitFinalPass()
D3DLOCKED_BOX lockedBox;
hr = m_pLut3DTexture->LockBox(0, &lockedBox, NULL, D3DLOCK_DISCARD);
- if (FAILED(hr))
- {
+ if (FAILED(hr)) {
delete[] lut3DFloat16;
CleanupFinalPass();
return hr;
@@ -1167,19 +1132,17 @@ HRESULT CDX9RenderingEngine::InitFinalPass()
D3DXFLOAT16* lut3DFloat16Iterator = lut3DFloat16;
char* outputSliceIterator = static_cast<char*>(lockedBox.pBits);
- for (int b = 0; b < m_Lut3DSize; b++)
- {
+ for (int b = 0; b < m_Lut3DSize; b++) {
char* outputRowIterator = outputSliceIterator;
- for (int g = 0; g < m_Lut3DSize; g++)
- {
+ for (int g = 0; g < m_Lut3DSize; g++) {
D3DXFLOAT16* outputIterator = reinterpret_cast<D3DXFLOAT16*>(outputRowIterator);
- for (int r = 0; r < m_Lut3DSize; r++)
- {
+ for (int r = 0; r < m_Lut3DSize; r++) {
// R, G, B
- for (int i = 0; i < 3; i++)
+ for (int i = 0; i < 3; i++) {
*outputIterator++ = *lut3DFloat16Iterator++;
+ }
// A
*outputIterator++ = oneFloat16;
@@ -1193,16 +1156,14 @@ HRESULT CDX9RenderingEngine::InitFinalPass()
hr = m_pLut3DTexture->UnlockBox(0);
delete[] lut3DFloat16;
- if (FAILED(hr))
- {
+ if (FAILED(hr)) {
CleanupFinalPass();
return hr;
}
}
// Compile the final pixel shader
- if (m_Caps.PixelShaderVersion < D3DPS_VERSION(2, 0))
- {
+ if (m_Caps.PixelShaderVersion < D3DPS_VERSION(2, 0)) {
CleanupFinalPass();
return E_FAIL;
}
@@ -1210,17 +1171,17 @@ HRESULT CDX9RenderingEngine::InitFinalPass()
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")))
- {
+ if (!LoadResource(IDF_SHADER_FINAL, shaderSourceCode, _T("FILE"))) {
CleanupFinalPass();
return E_FAIL;
}
int quantization;
- if (m_bHighColorResolution && (m_DisplayType == D3DFMT_A2R10G10B10 || m_DisplayType == D3DFMT_A2B10G10R10))
- quantization = 1023; // 10-bit
- else
- quantization = 255; // 8-bit
+ if (m_bHighColorResolution && (m_DisplayType == D3DFMT_A2R10G10B10 || m_DisplayType == D3DFMT_A2B10G10R10)) {
+ quantization = 1023; // 10-bit
+ } else {
+ quantization = 255; // 8-bit
+ }
CStringA quantizationString;
quantizationString.Format("%d.0f", quantization);
@@ -1230,8 +1191,7 @@ HRESULT CDX9RenderingEngine::InitFinalPass()
lut3DEnabledString.Format("%d", static_cast<int>(bColorManagement));
shaderSourceCode.Replace("_LUT3D_ENABLED_VALUE_", lut3DEnabledString);
- if (bColorManagement)
- {
+ if (bColorManagement) {
CStringA lut3DSizeString;
lut3DSizeString.Format("%d.0f", m_Lut3DSize);
shaderSourceCode.Replace("_LUT3D_SIZE_VALUE_", lut3DSizeString);
@@ -1240,8 +1200,7 @@ HRESULT CDX9RenderingEngine::InitFinalPass()
CString ErrorMessage;
CString DissAssembly;
hr = m_pPSC->CompileShader(shaderSourceCode, "main", pProfile, 0, &m_pFinalPixelShader, &DissAssembly, &ErrorMessage);
- if (FAILED(hr))
- {
+ if (FAILED(hr)) {
TRACE("%ws", ErrorMessage.GetString());
ASSERT (0);
CleanupFinalPass();
@@ -1264,74 +1223,69 @@ HRESULT CDX9RenderingEngine::CreateIccProfileLut(TCHAR* profilePath, float* lut3
// Get the input video system
VideoSystem videoSystem;
- if (m_InputVideoSystem == VIDEO_SYSTEM_UNKNOWN)
- {
+ 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])
+ 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])
+ 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
- {
+ } else {
videoSystem = m_InputVideoSystem;
}
// Get the gamma
double gamma;
- switch (m_AmbientLight)
- {
- case AMBIENT_LIGHT_BRIGHT:
- gamma = 2.2;
- break;
+ switch (m_AmbientLight) {
+ case AMBIENT_LIGHT_BRIGHT:
+ gamma = 2.2;
+ break;
- case AMBIENT_LIGHT_DIM:
- gamma = 2.35;
- break;
+ case AMBIENT_LIGHT_DIM:
+ gamma = 2.35;
+ break;
- case AMBIENT_LIGHT_DARK:
- gamma = 2.4;
- break;
+ case AMBIENT_LIGHT_DARK:
+ gamma = 2.4;
+ break;
- default:
- return E_FAIL;
+ default:
+ return E_FAIL;
}
// Get the rendering intent
cmsUInt32Number intent;
- switch (m_RenderingIntent)
- {
- case COLOR_RENDERING_INTENT_PERCEPTUAL:
- intent = INTENT_PERCEPTUAL;
- break;
+ 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_RELATIVE_COLORIMETRIC:
+ intent = INTENT_RELATIVE_COLORIMETRIC;
+ break;
- case COLOR_RENDERING_INTENT_SATURATION:
- intent = INTENT_SATURATION;
- break;
+ case COLOR_RENDERING_INTENT_SATURATION:
+ intent = INTENT_SATURATION;
+ break;
- case COLOR_RENDERING_INTENT_ABSOLUTE_COLORIMETRIC:
- intent = INTENT_ABSOLUTE_COLORIMETRIC;
- break;
+ case COLOR_RENDERING_INTENT_ABSOLUTE_COLORIMETRIC:
+ intent = INTENT_ABSOLUTE_COLORIMETRIC;
+ break;
- default:
- return E_FAIL;
+ default:
+ return E_FAIL;
}
// Set the input white point. It's D65 in all cases.
@@ -1344,40 +1298,39 @@ HRESULT CDX9RenderingEngine::CreateIccProfileLut(TCHAR* profilePath, float* lut3
// 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;
+ 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;
@@ -1389,39 +1342,37 @@ HRESULT CDX9RenderingEngine::CreateIccProfileLut(TCHAR* profilePath, float* lut3
cmsToneCurve* transferFunction = cmsBuildGamma(0, gamma);
cmsToneCurve* transferFunctionRGB[3];
- for (int i = 0; i < 3; i++)
+ 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)
+ 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)
- {
+ if (profilePath != 0) {
+ if (_wfopen_s(&outputProfileStream, T2W(profilePath), L"rb") != 0) {
cmsCloseProfile(hInputProfile);
return E_FAIL;
}
hOutputProfile = cmsOpenProfileFromStream(outputProfileStream, "r");
- }
- else
- {
+ } else {
hOutputProfile = cmsCreate_sRGBProfile();
}
- if (hOutputProfile == NULL)
- {
- if (profilePath != 0)
+ if (hOutputProfile == NULL) {
+ if (profilePath != 0) {
fclose(outputProfileStream);
+ }
cmsCloseProfile(hInputProfile);
return E_FAIL;
@@ -1432,13 +1383,15 @@ HRESULT CDX9RenderingEngine::CreateIccProfileLut(TCHAR* profilePath, float* lut3
cmsCloseProfile(hOutputProfile);
- if (profilePath != 0)
+ if (profilePath != 0) {
fclose(outputProfileStream);
+ }
cmsCloseProfile(hInputProfile);
- if (hTransform == NULL)
+ if (hTransform == NULL) {
return E_FAIL;
+ }
// Create the 3D LUT input
unsigned short* lut3DOutput = new unsigned short[m_Lut3DEntryCount * 3];
@@ -1446,12 +1399,9 @@ HRESULT CDX9RenderingEngine::CreateIccProfileLut(TCHAR* profilePath, float* lut3
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++)
- {
+ 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);
@@ -1463,8 +1413,9 @@ HRESULT CDX9RenderingEngine::CreateIccProfileLut(TCHAR* profilePath, float* lut3
cmsDoTransform(hTransform, lut3DInput, lut3DOutput, m_Lut3DEntryCount);
// Convert the output to floating point
- for (int i = 0; i < m_Lut3DEntryCount * 3; i++)
+ for (int i = 0; i < m_Lut3DEntryCount * 3; i++) {
lut3D[i] = static_cast<float>(lut3DOutput[i]) * (1.0f / 65535.0f);
+ }
// Cleanup
delete[] lut3DOutput;
@@ -1479,22 +1430,21 @@ HRESULT CDX9RenderingEngine::FinalPass(IDirect3DTexture9* pTexture)
HRESULT hr;
D3DSURFACE_DESC desc;
- if (!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc)))
+ if (!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc))) {
return E_FAIL;
+ }
float w = (float)desc.Width;
float h = (float)desc.Height;
- MYD3DVERTEX<1> v[] =
- {
+ 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++)
- {
+ for(int i = 0; i < countof(v); i++) {
v[i].x -= 0.5;
v[i].y -= 0.5;
}
@@ -1514,8 +1464,7 @@ HRESULT CDX9RenderingEngine::FinalPass(IDirect3DTexture9* pTexture)
hr = m_pD3DDev->SetTexture(1, m_pDitherTexture);
- if (m_bColorManagement)
- {
+ 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_LINEAR);
@@ -1535,8 +1484,9 @@ HRESULT CDX9RenderingEngine::FinalPass(IDirect3DTexture9* pTexture)
hr = m_pD3DDev->SetTexture(1, NULL);
- if (m_bColorManagement)
+ if (m_bColorManagement) {
hr = m_pD3DDev->SetTexture(2, NULL);
+ }
return hr;
}
@@ -1546,22 +1496,21 @@ HRESULT CDX9RenderingEngine::TextureCopy(IDirect3DTexture9* pTexture)
HRESULT hr;
D3DSURFACE_DESC desc;
- if (!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc)))
+ if (!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc))) {
return E_FAIL;
+ }
float w = (float)desc.Width;
float h = (float)desc.Height;
- MYD3DVERTEX<1> v[] =
- {
+ 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++)
- {
+ for (int i = 0; i < countof(v); i++) {
v[i].x -= 0.5;
v[i].y -= 0.5;
}
@@ -1575,38 +1524,34 @@ bool CDX9RenderingEngine::ClipToSurface(IDirect3DSurface9* pSurface, CRect& s, C
{
D3DSURFACE_DESC d3dsd;
ZeroMemory(&d3dsd, sizeof(d3dsd));
- if (FAILED(pSurface->GetDesc(&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)
- {
+ || sw <= 0 || sh <= 0 || dw <= 0 || dh <= 0) {
s.SetRectEmpty();
d.SetRectEmpty();
return(true);
}
- if (d.right > w)
- {
+ if (d.right > w) {
s.right -= (d.right-w)*sw/dw;
d.right = w;
}
- if (d.bottom > h)
- {
+ if (d.bottom > h) {
s.bottom -= (d.bottom-h)*sh/dh;
d.bottom = h;
}
- if (d.left < 0)
- {
+ if (d.left < 0) {
s.left += (0-d.left)*sw/dw;
d.left = 0;
}
- if (d.top < 0)
- {
+ if (d.top < 0) {
s.top += (0-d.top)*sh/dh;
d.top = 0;
}
@@ -1616,20 +1561,19 @@ bool CDX9RenderingEngine::ClipToSurface(IDirect3DSurface9* pSurface, CRect& s, C
HRESULT CDX9RenderingEngine::DrawRect(DWORD _Color, DWORD _Alpha, const CRect &_Rect)
{
- if (!m_pD3DDev)
+ if (!m_pD3DDev) {
return E_POINTER;
+ }
DWORD Color = D3DCOLOR_ARGB(_Alpha, GetRValue(_Color), GetGValue(_Color), GetBValue(_Color));
- MYD3DVERTEX<0> v[] =
- {
+ 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++)
- {
+ for (int i = 0; i < countof(v); i++) {
v[i].x -= 0.5;
v[i].y -= 0.5;
}
@@ -1661,8 +1605,9 @@ HRESULT CDX9RenderingEngine::DrawRect(DWORD _Color, DWORD _Alpha, const CRect &_
HRESULT CDX9RenderingEngine::AlphaBlt(RECT* pSrc, RECT* pDst, IDirect3DTexture9* pTexture)
{
- if(!pSrc || !pDst)
+ if(!pSrc || !pDst) {
return E_POINTER;
+ }
CRect src(*pSrc), dst(*pDst);
@@ -1670,19 +1615,18 @@ HRESULT CDX9RenderingEngine::AlphaBlt(RECT* pSrc, RECT* pDst, IDirect3DTexture9*
D3DSURFACE_DESC d3dsd;
ZeroMemory(&d3dsd, sizeof(d3dsd));
- if(FAILED(pTexture->GetLevelDesc(0, &d3dsd)) /*|| d3dsd.Type != D3DRTYPE_TEXTURE*/)
+ if(FAILED(pTexture->GetLevelDesc(0, &d3dsd)) /*|| d3dsd.Type != D3DRTYPE_TEXTURE*/) {
return E_FAIL;
+ }
float w = (float)d3dsd.Width;
float h = (float)d3dsd.Height;
- struct
- {
+ struct {
float x, y, z, rhw;
float tu, tv;
}
- pVertices[] =
- {
+ 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},
@@ -1753,20 +1697,21 @@ HRESULT CDX9RenderingEngine::AlphaBlt(RECT* pSrc, RECT* pDst, IDirect3DTexture9*
HRESULT CDX9RenderingEngine::SetCustomPixelShader(LPCSTR pSrcData, LPCSTR pTarget, bool bScreenSpace)
{
CAtlList<CExternalPixelShader> *pPixelShaders;
- if (bScreenSpace)
+ if (bScreenSpace) {
pPixelShaders = &m_pCustomScreenSpacePixelShaders;
- else
+ } else {
pPixelShaders = &m_pCustomPixelShaders;
+ }
- if (!pSrcData && !pTarget)
- {
+ if (!pSrcData && !pTarget) {
pPixelShaders->RemoveAll();
m_pD3DDev->SetPixelShader(NULL);
return S_OK;
}
- if (!pSrcData || !pTarget)
+ if (!pSrcData || !pTarget) {
return E_INVALIDARG;
+ }
CExternalPixelShader Shader;
Shader.m_SourceData = pSrcData;
@@ -1775,8 +1720,9 @@ HRESULT CDX9RenderingEngine::SetCustomPixelShader(LPCSTR pSrcData, LPCSTR pTarge
CComPtr<IDirect3DPixelShader9> pPixelShader;
HRESULT hr = Shader.Compile(m_pPSC);
- if (FAILED(hr))
+ if (FAILED(hr)) {
return hr;
+ }
pPixelShaders->AddTail(Shader);
diff --git a/src/filters/renderer/VideoRenderers/DX9RenderingEngine.h b/src/filters/renderer/VideoRenderers/DX9RenderingEngine.h
index d2afd3cf4..f90a03a81 100644
--- a/src/filters/renderer/VideoRenderers/DX9RenderingEngine.h
+++ b/src/filters/renderer/VideoRenderers/DX9RenderingEngine.h
@@ -32,152 +32,151 @@
namespace DSObjects
{
-class CDX9RenderingEngine
- : public CSubPicAllocatorPresenterImpl
-{
-protected:
- enum RenderingPath
+ class CDX9RenderingEngine
+ : public CSubPicAllocatorPresenterImpl
{
- RENDERING_PATH_STRETCHRECT,
- RENDERING_PATH_DRAW,
- };
+ protected:
+ enum RenderingPath {
+ RENDERING_PATH_STRETCHRECT,
+ RENDERING_PATH_DRAW,
+ };
- static const int MAX_VIDEO_SURFACES = 60;
+ 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
+ // 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;
+ 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];
+ // 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_bColorManagement;
+ bool m_bFullFloatingPointProcessing;
+ bool m_bColorManagement;
- CDX9RenderingEngine(HWND hWnd, HRESULT& hr, CString *_pError);
+ CDX9RenderingEngine(HWND hWnd, HRESULT& hr, CString *_pError);
- void InitRenderingEngine();
- void CleanupRenderingEngine();
+ void InitRenderingEngine();
+ void CleanupRenderingEngine();
- HRESULT CreateVideoSurfaces(D3DFORMAT format);
- void FreeVideoSurfaces();
+ HRESULT CreateVideoSurfaces(D3DFORMAT format);
+ void FreeVideoSurfaces();
- HRESULT RenderVideo(IDirect3DSurface9* pRenderTarget, const CRect& srcRect, const CRect& destRect);
+ 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 DrawRect(DWORD _Color, DWORD _Alpha, const CRect &_Rect);
+ HRESULT AlphaBlt(RECT* pSrc, RECT* pDst, IDirect3DTexture9* pTexture);
- HRESULT SetCustomPixelShader(LPCSTR pSrcData, LPCSTR pTarget, bool bScreenSpace);
+ 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)
+ private:
+ class CExternalPixelShader
{
- HRESULT hr = pCompiler->CompileShader(m_SourceData, "main", m_SourceTarget, 0, &m_pPixelShader);
- if(FAILED(hr))
- return hr;
-
- return S_OK;
- }
+ 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);
};
- // 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);
-};
-
}
diff --git a/src/filters/renderer/VideoRenderers/DXRAllocatorPresenter.cpp b/src/filters/renderer/VideoRenderers/DXRAllocatorPresenter.cpp
index f106c0e36..20e4dbb18 100644
--- a/src/filters/renderer/VideoRenderers/DXRAllocatorPresenter.cpp
+++ b/src/filters/renderer/VideoRenderers/DXRAllocatorPresenter.cpp
@@ -37,8 +37,7 @@ CDXRAllocatorPresenter::CDXRAllocatorPresenter(HWND hWnd, HRESULT& hr, CString &
: CSubPicAllocatorPresenterImpl(hWnd, hr, &_Error)
, m_ScreenSize(0, 0)
{
- if(FAILED(hr))
- {
+ if(FAILED(hr)) {
_Error += L"ISubPicAllocatorPresenterImpl failed\n";
return;
}
@@ -48,8 +47,7 @@ CDXRAllocatorPresenter::CDXRAllocatorPresenter(HWND hWnd, HRESULT& hr, CString &
CDXRAllocatorPresenter::~CDXRAllocatorPresenter()
{
- if(m_pSRCB)
- {
+ if(m_pSRCB) {
// nasty, but we have to let it know about our death somehow
((CSubRenderCallback*)(ISubRenderCallback*)m_pSRCB)->SetDXRAP(NULL);
}
@@ -75,10 +73,10 @@ STDMETHODIMP CDXRAllocatorPresenter::NonDelegatingQueryInterface(REFIID riid, vo
return GetInterface((IVMRWindowlessControl*)this, ppv);
*/
- if(riid != IID_IUnknown && m_pDXR)
- {
- if(SUCCEEDED(m_pDXR->QueryInterface(riid, ppv)))
+ if(riid != IID_IUnknown && m_pDXR) {
+ if(SUCCEEDED(m_pDXR->QueryInterface(riid, ppv))) {
return S_OK;
+ }
}
return __super::NonDelegatingQueryInterface(riid, ppv);
@@ -89,50 +87,47 @@ 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);
+ 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;
}
- else
- {
+
+ if(m_pAllocator) {
+ m_pAllocator->ChangeDevice(pD3DDev);
+ } else {
m_pAllocator = DNew CDX9SubPicAllocator(pD3DDev, size, GetRenderersSettings().fSPCPow2Tex);
- if(!m_pAllocator)
+ if(!m_pAllocator) {
return E_FAIL;
+ }
}
HRESULT hr = S_OK;
@@ -140,10 +135,13 @@ HRESULT CDXRAllocatorPresenter::SetDevice(IDirect3DDevice9* pD3DDev)
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))
+ if(!m_pSubPicQueue || FAILED(hr)) {
return E_FAIL;
+ }
- if(m_SubPicProvider) m_pSubPicQueue->SetSubPicProvider(m_SubPicProvider);
+ if(m_SubPicProvider) {
+ m_pSubPicQueue->SetSubPicProvider(m_SubPicProvider);
+ }
return S_OK;
}
@@ -154,7 +152,9 @@ HRESULT CDXRAllocatorPresenter::Render(
{
__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);
+ if(atpf > 0 && m_pSubPicQueue) {
+ m_pSubPicQueue->SetFPS(10000000.0 / atpf);
+ }
AlphaBltSubPic(CSize(width, height));
return S_OK;
}
@@ -165,20 +165,22 @@ STDMETHODIMP CDXRAllocatorPresenter::CreateRenderer(IUnknown** ppRenderer)
{
CheckPointer(ppRenderer, E_POINTER);
- if(m_pDXR) return E_UNEXPECTED;
+ if(m_pDXR) {
+ return E_UNEXPECTED;
+ }
m_pDXR.CoCreateInstance(CLSID_DXR, GetOwner());
- if(!m_pDXR) return E_FAIL;
+ if(!m_pDXR) {
+ return E_FAIL;
+ }
CComQIPtr<ISubRender> pSR = m_pDXR;
- if(!pSR)
- {
+ if(!pSR) {
m_pDXR = NULL;
return E_FAIL;
}
m_pSRCB = DNew CSubRenderCallback(this);
- if(FAILED(pSR->SetCallback(m_pSRCB)))
- {
+ if(FAILED(pSR->SetCallback(m_pSRCB))) {
m_pDXR = NULL;
return E_FAIL;
}
@@ -187,22 +189,21 @@ STDMETHODIMP CDXRAllocatorPresenter::CreateRenderer(IUnknown** ppRenderer)
MONITORINFO mi;
mi.cbSize = sizeof(MONITORINFO);
- if (GetMonitorInfo(MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST), &mi))
+ 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)
- {
+ 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)
- {
+ if(CComQIPtr<IVideoWindow> pVW = m_pDXR) {
pVW->SetWindowPosition(w.left, w.top, w.right - w.left, w.bottom - w.top);
}
}
@@ -211,15 +212,14 @@ STDMETHODIMP_(SIZE) CDXRAllocatorPresenter::GetVideoSize(bool fCorrectAR)
{
SIZE size = {0, 0};
- if(!fCorrectAR)
- {
- if(CComQIPtr<IBasicVideo> pBV = m_pDXR)
+ if(!fCorrectAR) {
+ if(CComQIPtr<IBasicVideo> pBV = m_pDXR) {
pBV->GetVideoSize(&size.cx, &size.cy);
- }
- else
- {
- if(CComQIPtr<IBasicVideo2> pBV2 = m_pDXR)
+ }
+ } else {
+ if(CComQIPtr<IBasicVideo2> pBV2 = m_pDXR) {
pBV2->GetPreferredAspectRatio(&size.cx, &size.cy);
+ }
}
return size;
@@ -233,8 +233,9 @@ STDMETHODIMP_(bool) CDXRAllocatorPresenter::Paint(bool fAll)
STDMETHODIMP CDXRAllocatorPresenter::GetDIB(BYTE* lpDib, DWORD* size)
{
HRESULT hr = E_NOTIMPL;
- if(CComQIPtr<IBasicVideo> pBV = m_pDXR)
+ if(CComQIPtr<IBasicVideo> pBV = m_pDXR) {
hr = pBV->GetCurrentImage((long*)size, (long*)lpDib);
+ }
return hr;
}
diff --git a/src/filters/renderer/VideoRenderers/DXRAllocatorPresenter.h b/src/filters/renderer/VideoRenderers/DXRAllocatorPresenter.h
index f5c79c9d0..65d5e263e 100644
--- a/src/filters/renderer/VideoRenderers/DXRAllocatorPresenter.h
+++ b/src/filters/renderer/VideoRenderers/DXRAllocatorPresenter.h
@@ -28,79 +28,73 @@
namespace DSObjects
{
-class CDXRAllocatorPresenter
- : public CSubPicAllocatorPresenterImpl
-{
- class CSubRenderCallback : public CUnknown, public ISubRenderCallback, public CCritSec
+ class CDXRAllocatorPresenter
+ : public CSubPicAllocatorPresenterImpl
{
- CDXRAllocatorPresenter* m_pDXRAP;
+ 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:
- CSubRenderCallback(CDXRAllocatorPresenter* pDXRAP)
- : CUnknown(_T("CSubRender"), NULL)
- , m_pDXRAP(pDXRAP)
- {
- }
+ CDXRAllocatorPresenter(HWND hWnd, HRESULT& hr, CString &_Error);
+ virtual ~CDXRAllocatorPresenter();
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;
- }
+ 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);
};
-
- 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 d7455a168..c6dd1c75d 100644
--- a/src/filters/renderer/VideoRenderers/Dither.cpp
+++ b/src/filters/renderer/VideoRenderers/Dither.cpp
@@ -23,8 +23,7 @@
#include "Dither.h"
// Dither matrix in 16-bit floating point format
-const unsigned short DITHER_MATRIX[DITHER_MATRIX_SIZE][DITHER_MATRIX_SIZE] =
-{
+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,
diff --git a/src/filters/renderer/VideoRenderers/EVRAllocatorPresenter.cpp b/src/filters/renderer/VideoRenderers/EVRAllocatorPresenter.cpp
index 631fa05ca..58f143ca3 100644
--- a/src/filters/renderer/VideoRenderers/EVRAllocatorPresenter.cpp
+++ b/src/filters/renderer/VideoRenderers/EVRAllocatorPresenter.cpp
@@ -30,11 +30,10 @@
#if (0) // Set to 1 to activate EVR traces
#define TRACE_EVR TRACE
#else
-#define TRACE_EVR
+#define TRACE_EVR __noop
#endif
-typedef enum
-{
+typedef enum {
MSG_MIXERIN,
MSG_MIXEROUT
} EVR_STATS_MSG;
@@ -69,186 +68,190 @@ MFVideoArea MakeArea(float x, float y, DWORD width, DWORD height)
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:
+ public:
- // IBaseFilter
- virtual HRESULT STDMETHODCALLTYPE EnumPins(__out IEnumPins **ppEnum)
- {
- CComPtr<IBaseFilter> pEVRBase;
- if (m_pEVR)
- m_pEVR->QueryInterface(&pEVRBase);
- if (pEVRBase)
- return pEVRBase->EnumPins(ppEnum);
- return E_NOTIMPL;
- }
+ // IBaseFilter
+ virtual HRESULT STDMETHODCALLTYPE EnumPins(__out IEnumPins **ppEnum) {
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR) {
+ m_pEVR->QueryInterface(&pEVRBase);
+ }
+ if (pEVRBase) {
+ return pEVRBase->EnumPins(ppEnum);
+ }
+ return E_NOTIMPL;
+ }
- virtual HRESULT STDMETHODCALLTYPE 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;
- }
+ virtual HRESULT STDMETHODCALLTYPE 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;
+ }
- virtual HRESULT STDMETHODCALLTYPE QueryFilterInfo(__out FILTER_INFO *pInfo)
- {
- CComPtr<IBaseFilter> pEVRBase;
- if (m_pEVR)
- m_pEVR->QueryInterface(&pEVRBase);
- if (pEVRBase)
- return pEVRBase->QueryFilterInfo(pInfo);
- return E_NOTIMPL;
- }
+ virtual HRESULT STDMETHODCALLTYPE QueryFilterInfo(__out FILTER_INFO *pInfo) {
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR) {
+ m_pEVR->QueryInterface(&pEVRBase);
+ }
+ if (pEVRBase) {
+ return pEVRBase->QueryFilterInfo(pInfo);
+ }
+ return E_NOTIMPL;
+ }
- virtual HRESULT STDMETHODCALLTYPE 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;
- }
+ virtual HRESULT STDMETHODCALLTYPE 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;
+ }
- virtual HRESULT STDMETHODCALLTYPE QueryVendorInfo(__out LPWSTR *pVendorInfo)
- {
- CComPtr<IBaseFilter> pEVRBase;
- if (m_pEVR)
- m_pEVR->QueryInterface(&pEVRBase);
- if (pEVRBase)
- return pEVRBase->QueryVendorInfo(pVendorInfo);
- return E_NOTIMPL;
- }
+ virtual HRESULT STDMETHODCALLTYPE QueryVendorInfo(__out LPWSTR *pVendorInfo) {
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR) {
+ m_pEVR->QueryInterface(&pEVRBase);
+ }
+ if (pEVRBase) {
+ return pEVRBase->QueryVendorInfo(pVendorInfo);
+ }
+ return E_NOTIMPL;
+ }
- virtual HRESULT STDMETHODCALLTYPE Stop( void)
- {
- CComPtr<IBaseFilter> pEVRBase;
- if (m_pEVR)
- m_pEVR->QueryInterface(&pEVRBase);
- if (pEVRBase)
- return pEVRBase->Stop();
- return E_NOTIMPL;
- }
+ virtual HRESULT STDMETHODCALLTYPE Stop( void) {
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR) {
+ m_pEVR->QueryInterface(&pEVRBase);
+ }
+ if (pEVRBase) {
+ return pEVRBase->Stop();
+ }
+ return E_NOTIMPL;
+ }
- virtual HRESULT STDMETHODCALLTYPE Pause( void)
- {
- CComPtr<IBaseFilter> pEVRBase;
- if (m_pEVR)
- m_pEVR->QueryInterface(&pEVRBase);
- if (pEVRBase)
- return pEVRBase->Pause();
- return E_NOTIMPL;
- }
+ virtual HRESULT STDMETHODCALLTYPE Pause( void) {
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR) {
+ m_pEVR->QueryInterface(&pEVRBase);
+ }
+ if (pEVRBase) {
+ return pEVRBase->Pause();
+ }
+ return E_NOTIMPL;
+ }
- virtual HRESULT STDMETHODCALLTYPE Run( REFERENCE_TIME tStart)
- {
- CComPtr<IBaseFilter> pEVRBase;
- if (m_pEVR)
- m_pEVR->QueryInterface(&pEVRBase);
- if (pEVRBase)
- return pEVRBase->Run(tStart);
- return E_NOTIMPL;
- }
+ virtual HRESULT STDMETHODCALLTYPE Run( REFERENCE_TIME tStart) {
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR) {
+ m_pEVR->QueryInterface(&pEVRBase);
+ }
+ if (pEVRBase) {
+ return pEVRBase->Run(tStart);
+ }
+ return E_NOTIMPL;
+ }
- virtual HRESULT STDMETHODCALLTYPE GetState( DWORD dwMilliSecsTimeout, __out FILTER_STATE *State);
+ virtual HRESULT STDMETHODCALLTYPE GetState( DWORD dwMilliSecsTimeout, __out FILTER_STATE *State);
- virtual HRESULT STDMETHODCALLTYPE SetSyncSource(__in_opt IReferenceClock *pClock)
- {
- CComPtr<IBaseFilter> pEVRBase;
- if (m_pEVR)
- m_pEVR->QueryInterface(&pEVRBase);
- if (pEVRBase)
- return pEVRBase->SetSyncSource(pClock);
- return E_NOTIMPL;
- }
+ virtual HRESULT STDMETHODCALLTYPE SetSyncSource(__in_opt IReferenceClock *pClock) {
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR) {
+ m_pEVR->QueryInterface(&pEVRBase);
+ }
+ if (pEVRBase) {
+ return pEVRBase->SetSyncSource(pClock);
+ }
+ return E_NOTIMPL;
+ }
- virtual HRESULT STDMETHODCALLTYPE 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;
- }
+ virtual HRESULT STDMETHODCALLTYPE 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;
+ }
- virtual HRESULT STDMETHODCALLTYPE GetClassID(__RPC__out CLSID *pClassID)
- {
- CComPtr<IBaseFilter> pEVRBase;
- if (m_pEVR)
- m_pEVR->QueryInterface(&pEVRBase);
- if (pEVRBase)
- return pEVRBase->GetClassID(pClassID);
- return E_NOTIMPL;
- }
+ virtual HRESULT STDMETHODCALLTYPE GetClassID(__RPC__out CLSID *pClassID) {
+ CComPtr<IBaseFilter> pEVRBase;
+ if (m_pEVR) {
+ m_pEVR->QueryInterface(&pEVRBase);
+ }
+ if (pEVRBase) {
+ return pEVRBase->GetClassID(pClassID);
+ }
+ return E_NOTIMPL;
+ }
- 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(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);
+ }
- // 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);
+ // 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);
+ };
}
using namespace DSObjects;
@@ -256,13 +259,16 @@ using namespace DSObjects;
HRESULT STDMETHODCALLTYPE COuterEVR::GetState( DWORD dwMilliSecsTimeout, __out FILTER_STATE *State)
{
HRESULT ReturnValue;
- if (m_pAllocatorPresenter->GetState(dwMilliSecsTimeout, State, ReturnValue))
+ if (m_pAllocatorPresenter->GetState(dwMilliSecsTimeout, State, ReturnValue)) {
return ReturnValue;
+ }
CComPtr<IBaseFilter> pEVRBase;
- if (m_pEVR)
+ if (m_pEVR) {
m_pEVR->QueryInterface(&pEVRBase);
- if (pEVRBase)
+ }
+ if (pEVRBase) {
return pEVRBase->GetState(dwMilliSecsTimeout, State);
+ }
return E_NOTIMPL;
}
@@ -315,8 +321,7 @@ CEVRAllocatorPresenter::CEVRAllocatorPresenter(HWND hWnd, bool bFullscreen, HRES
m_ModeratedTimeLast = -1;
m_ModeratedClockLast = -1;
- if (FAILED (hr))
- {
+ if (FAILED (hr)) {
_Error += L"DX9AllocatorPresenter failed\n";
return;
}
@@ -331,16 +336,19 @@ CEVRAllocatorPresenter::CEVRAllocatorPresenter(HWND hWnd, bool bFullscreen, HRES
pfMFCreateVideoSampleFromSurface = hLib ? (PTR_MFCreateVideoSampleFromSurface) GetProcAddress (hLib, "MFCreateVideoSampleFromSurface") : NULL;
pfMFCreateVideoMediaType = hLib ? (PTR_MFCreateVideoMediaType) GetProcAddress (hLib, "MFCreateVideoMediaType") : NULL;
- if (!pfDXVA2CreateDirect3DDeviceManager9 || !pfMFCreateDXSurfaceBuffer || !pfMFCreateVideoSampleFromSurface || !pfMFCreateVideoMediaType)
- {
- if (!pfDXVA2CreateDirect3DDeviceManager9)
+ if (!pfDXVA2CreateDirect3DDeviceManager9 || !pfMFCreateDXSurfaceBuffer || !pfMFCreateVideoSampleFromSurface || !pfMFCreateVideoMediaType) {
+ if (!pfDXVA2CreateDirect3DDeviceManager9) {
_Error += L"Could not find DXVA2CreateDirect3DDeviceManager9 (dxva2.dll)\n";
- if (!pfMFCreateDXSurfaceBuffer)
+ }
+ if (!pfMFCreateDXSurfaceBuffer) {
_Error += L"Could not find MFCreateDXSurfaceBuffer (evr.dll)\n";
- if (!pfMFCreateVideoSampleFromSurface)
+ }
+ if (!pfMFCreateVideoSampleFromSurface) {
_Error += L"Could not find MFCreateVideoSampleFromSurface (evr.dll)\n";
- if (!pfMFCreateVideoMediaType)
+ }
+ if (!pfMFCreateVideoMediaType) {
_Error += L"Could not find MFCreateVideoMediaType (evr.dll)\n";
+ }
hr = E_FAIL;
return;
}
@@ -352,8 +360,7 @@ CEVRAllocatorPresenter::CEVRAllocatorPresenter(HWND hWnd, bool bFullscreen, HRES
(FARPROC &)pMFInitMediaTypeFromAMMediaType = GetProcAddress(hLib, "MFInitMediaTypeFromAMMediaType");
(FARPROC &)pMFInitAMMediaTypeFromMFMediaType = GetProcAddress(hLib, "MFInitAMMediaTypeFromMFMediaType");
- if (!pMFCreateMediaType || !pMFInitMediaTypeFromAMMediaType || !pMFInitAMMediaTypeFromMFMediaType)
- {
+ if (!pMFCreateMediaType || !pMFInitMediaTypeFromAMMediaType || !pMFInitAMMediaTypeFromMFMediaType) {
hr = E_FAIL;
return;
}
@@ -367,22 +374,19 @@ CEVRAllocatorPresenter::CEVRAllocatorPresenter(HWND hWnd, bool bFullscreen, HRES
// Init DXVA manager
hr = pfDXVA2CreateDirect3DDeviceManager9(&m_nResetToken, &m_pD3DManager);
- if (SUCCEEDED (hr))
- {
+ if (SUCCEEDED (hr)) {
hr = m_pD3DManager->ResetDevice(m_pD3DDev, m_nResetToken);
- if (!SUCCEEDED (hr))
- {
+ if (!SUCCEEDED (hr)) {
_Error += L"m_pD3DManager->ResetDevice failed\n";
}
- }
- else
+ } 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)))
- {
+ SUCCEEDED (m_pD3DManager->GetVideoService (hDevice, __uuidof(IDirectXVideoDecoderService), (void**)&pDecoderService))) {
TRACE_EVR ("EVR: DXVA2 : device handle = 0x%08x", hDevice);
HookDirectXVideoDecoderService (pDecoderService);
@@ -391,10 +395,11 @@ CEVRAllocatorPresenter::CEVRAllocatorPresenter(HWND hWnd, bool bFullscreen, HRES
// Bufferize frame only with 3D texture!
- if (s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D)
+ if (s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D) {
m_nNbDXSurface = max (min (s.iEvrBuffers, MAX_VIDEO_SURFACES), 4);
- else
+ } else {
m_nNbDXSurface = 1;
+ }
ResetStats();
m_nRenderState = Shutdown;
@@ -442,12 +447,9 @@ void CEVRAllocatorPresenter::ResetStats()
HRESULT CEVRAllocatorPresenter::CheckShutdown() const
{
- if (m_nRenderState == Shutdown)
- {
+ if (m_nRenderState == Shutdown) {
return MF_E_SHUTDOWN;
- }
- else
- {
+ } else {
return S_OK;
}
}
@@ -457,8 +459,7 @@ void CEVRAllocatorPresenter::StartWorkerThreads()
{
DWORD dwThreadId;
- if (m_nRenderState == Shutdown)
- {
+ if (m_nRenderState == Shutdown) {
m_hEvtQuit = CreateEvent (NULL, TRUE, FALSE, NULL);
m_hEvtFlush = CreateEvent (NULL, TRUE, FALSE, NULL);
@@ -474,27 +475,32 @@ void CEVRAllocatorPresenter::StartWorkerThreads()
void CEVRAllocatorPresenter::StopWorkerThreads()
{
- if (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))
- {
+ 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))
- {
+ 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);
+ 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;
@@ -514,8 +520,7 @@ STDMETHODIMP CEVRAllocatorPresenter::CreateRenderer(IUnknown** ppRenderer)
HRESULT hr = E_FAIL;
- do
- {
+ do {
CMacrovisionKicker* pMK = DNew CMacrovisionKicker(NAME("CMacrovisionKicker"), NULL);
CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)pMK;
@@ -525,7 +530,9 @@ STDMETHODIMP CEVRAllocatorPresenter::CreateRenderer(IUnknown** ppRenderer)
pMK->SetInner((IUnknown*)(INonDelegatingUnknown*)pOuterEVR);
CComQIPtr<IBaseFilter> pBF = pUnk;
- if (FAILED (hr)) break;
+ if (FAILED (hr)) {
+ break;
+ }
// Set EVR custom presenter
CComPtr<IMFVideoPresenter> pVP;
@@ -534,8 +541,12 @@ STDMETHODIMP CEVRAllocatorPresenter::CreateRenderer(IUnknown** ppRenderer)
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);
@@ -547,13 +558,13 @@ STDMETHODIMP CEVRAllocatorPresenter::CreateRenderer(IUnknown** ppRenderer)
m_fUseInternalTimer = false;
#endif
- if(FAILED(hr))
+ if(FAILED(hr)) {
*ppRenderer = NULL;
- else
+ } else {
*ppRenderer = pBF.Detach();
+ }
- }
- while (0);
+ } while (0);
return hr;
}
@@ -566,31 +577,33 @@ STDMETHODIMP_(bool) CEVRAllocatorPresenter::Paint(bool fAll)
STDMETHODIMP CEVRAllocatorPresenter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
HRESULT hr;
- if(riid == __uuidof(IMFClockStateSink))
+ if(riid == __uuidof(IMFClockStateSink)) {
hr = GetInterface((IMFClockStateSink*)this, ppv);
- else if(riid == __uuidof(IMFVideoPresenter))
+ } else if(riid == __uuidof(IMFVideoPresenter)) {
hr = GetInterface((IMFVideoPresenter*)this, ppv);
- else if(riid == __uuidof(IMFTopologyServiceLookupClient))
+ } else if(riid == __uuidof(IMFTopologyServiceLookupClient)) {
hr = GetInterface((IMFTopologyServiceLookupClient*)this, ppv);
- else if(riid == __uuidof(IMFVideoDeviceID))
+ } else if(riid == __uuidof(IMFVideoDeviceID)) {
hr = GetInterface((IMFVideoDeviceID*)this, ppv);
- else if(riid == __uuidof(IMFGetService))
+ } else if(riid == __uuidof(IMFGetService)) {
hr = GetInterface((IMFGetService*)this, ppv);
- else if(riid == __uuidof(IMFAsyncCallback))
+ } else if(riid == __uuidof(IMFAsyncCallback)) {
hr = GetInterface((IMFAsyncCallback*)this, ppv);
- else if(riid == __uuidof(IMFVideoDisplayControl))
+ } else if(riid == __uuidof(IMFVideoDisplayControl)) {
hr = GetInterface((IMFVideoDisplayControl*)this, ppv);
- else if(riid == __uuidof(IEVRTrustedVideoPlugin))
+ } else if(riid == __uuidof(IEVRTrustedVideoPlugin)) {
hr = GetInterface((IEVRTrustedVideoPlugin*)this, ppv);
- else if(riid == IID_IQualProp)
+ } else if(riid == IID_IQualProp) {
hr = GetInterface((IQualProp*)this, ppv);
- else if(riid == __uuidof(IMFRateSupport))
+ } else if(riid == __uuidof(IMFRateSupport)) {
hr = GetInterface((IMFRateSupport*)this, ppv);
- else if(riid == __uuidof(IDirect3DDeviceManager9))
-// hr = GetInterface((IDirect3DDeviceManager9*)this, ppv);
+ } else if(riid == __uuidof(IDirect3DDeviceManager9))
+ // hr = GetInterface((IDirect3DDeviceManager9*)this, ppv);
+ {
hr = m_pD3DManager->QueryInterface (__uuidof(IDirect3DDeviceManager9), (void**) ppv);
- else
+ } else {
hr = __super::NonDelegatingQueryInterface(riid, ppv);
+ }
return hr;
}
@@ -621,8 +634,9 @@ STDMETHODIMP CEVRAllocatorPresenter::OnClockStop(MFTIME hnsSystemTime)
STDMETHODIMP CEVRAllocatorPresenter::OnClockPause(MFTIME hnsSystemTime)
{
TRACE_EVR ("EVR: OnClockPause hnsSystemTime = %I64d\n", hnsSystemTime);
- if (!m_bSignaledStarvation)
+ if (!m_bSignaledStarvation) {
m_nRenderState = Paused;
+ }
m_ModeratedTimeLast = -1;
m_ModeratedClockLast = -1;
return S_OK;
@@ -652,11 +666,9 @@ bool CEVRAllocatorPresenter::GetState( DWORD dwMilliSecsTimeout, FILTER_STATE *S
{
CAutoLock lock(&m_SampleQueueLock);
- if (m_bSignaledStarvation)
- {
+ if (m_bSignaledStarvation) {
int nSamples = max(m_nNbDXSurface / 2, 1);
- if ((m_ScheduledSamples.GetCount() < nSamples || m_LastSampleOffset < -m_rtTimePerFrame*2) && !g_bNoDuration)
- {
+ if ((m_ScheduledSamples.GetCount() < nSamples || m_LastSampleOffset < -m_rtTimePerFrame*2) && !g_bNoDuration) {
*State = (FILTER_STATE)Paused;
_ReturnValue = VFW_S_STATE_INTERMEDIATE;
return true;
@@ -721,8 +733,9 @@ STDMETHODIMP CEVRAllocatorPresenter::GetFastestRate(MFRATE_DIRECTION eDirection,
fMaxRate = GetMaxRate(fThin);
// For reverse playback, swap the sign.
- if (eDirection == MFRATE_REVERSE)
+ if (eDirection == MFRATE_REVERSE) {
fMaxRate = -fMaxRate;
+ }
*pflRate = fMaxRate;
@@ -746,23 +759,22 @@ STDMETHODIMP CEVRAllocatorPresenter::IsRateSupported(BOOL fThin, float flRate, f
// Find the maximum forward rate.
fMaxRate = GetMaxRate(fThin);
- if (fabsf(flRate) > fMaxRate)
- {
+ 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)
- {
+ if (flRate < 0) {
// For reverse playback, swap the sign.
fNearestRate = -fNearestRate;
}
}
// Return the nearest supported rate if the caller requested it.
- if (pflNearestSupportedRate != NULL)
+ if (pflNearestSupportedRate != NULL) {
*pflNearestSupportedRate = fNearestRate;
+ }
return hr;
}
@@ -774,8 +786,7 @@ float CEVRAllocatorPresenter::GetMaxRate(BOOL bThin)
UINT32 fpsNumerator = 0, fpsDenominator = 0;
UINT MonitorRateHz = 0;
- if (!bThin && (m_pMediaType != NULL))
- {
+ if (!bThin && (m_pMediaType != NULL)) {
// Non-thinned: Use the frame rate and monitor refresh rate.
// Frame rate:
@@ -785,8 +796,7 @@ float CEVRAllocatorPresenter::GetMaxRate(BOOL bThin)
// Monitor refresh rate:
MonitorRateHz = m_RefreshRate; // D3DDISPLAYMODE
- if (fpsDenominator && fpsNumerator && MonitorRateHz)
- {
+ if (fpsDenominator && fpsNumerator && MonitorRateHz) {
// Max Rate = Refresh Rate / Frame Rate
fMaxRate = (float)MulDiv(
MonitorRateHz, fpsDenominator, fpsNumerator);
@@ -797,15 +807,13 @@ float CEVRAllocatorPresenter::GetMaxRate(BOOL bThin)
void CEVRAllocatorPresenter::CompleteFrameStep(bool bCancel)
{
- if (m_nStepCount > 0)
- {
- if (bCancel || (m_nStepCount == 1))
- {
+ if (m_nStepCount > 0) {
+ if (bCancel || (m_nStepCount == 1)) {
m_pSink->Notify(EC_STEP_COMPLETE, bCancel ? TRUE : FALSE, 0);
m_nStepCount = 0;
- }
- else
+ } else {
m_nStepCount--;
+ }
}
}
@@ -814,59 +822,61 @@ STDMETHODIMP CEVRAllocatorPresenter::ProcessMessage(MFVP_MESSAGE_TYPE eMessage,
{
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 = ulParam;
- hr = S_OK;
- break;
-
- default :
- ASSERT (FALSE);
- break;
+ 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 = ulParam;
+ hr = S_OK;
+ break;
+
+ default :
+ ASSERT (FALSE);
+ break;
}
return hr;
}
@@ -880,34 +890,36 @@ HRESULT CEVRAllocatorPresenter::IsMediaTypeSupported(IMFMediaType* pMixerType)
GUID MajorType;
hr = pMixerType->GetMajorType(&MajorType);
- if (SUCCEEDED(hr))
- {
- if (MajorType != MFMediaType_Video)
+ if (SUCCEEDED(hr)) {
+ if (MajorType != MFMediaType_Video) {
hr = MF_E_INVALIDMEDIATYPE;
+ }
}
// We support only progressive formats
MFVideoInterlaceMode InterlaceMode;
- if (SUCCEEDED(hr))
+ if (SUCCEEDED(hr)) {
hr = pMixerType->GetUINT32(MF_MT_INTERLACE_MODE, (UINT32*)&InterlaceMode);
+ }
- if (SUCCEEDED(hr))
- {
- if (InterlaceMode != MFVideoInterlace_Progressive)
+ if (SUCCEEDED(hr)) {
+ if (InterlaceMode != MFVideoInterlace_Progressive) {
hr = MF_E_INVALIDMEDIATYPE;
+ }
}
// Check whether we support the surface format
int Merit;
- if (SUCCEEDED(hr))
+ if (SUCCEEDED(hr)) {
hr = GetMediaTypeMerit(pMixerType, &Merit);
+ }
- if (SUCCEEDED(hr))
- {
- if (Merit == 0)
+ if (SUCCEEDED(hr)) {
+ if (Merit == 0) {
hr = MF_E_INVALIDMEDIATYPE;
+ }
}
return hr;
@@ -926,30 +938,25 @@ HRESULT CEVRAllocatorPresenter::CreateProposedOutputType(IMFMediaType* pMixerTyp
VideoFormat = (MFVIDEOFORMAT*)pAMMedia->pbFormat;
hr = pfMFCreateVideoMediaType (VideoFormat, &m_pMediaType);
- if (0)
- {
+ 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;
+ 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;
}
}
}
@@ -957,8 +964,7 @@ HRESULT CEVRAllocatorPresenter::CreateProposedOutputType(IMFMediaType* pMixerTyp
m_AspectRatio.cx = VideoFormat->videoInfo.PixelAspectRatio.Numerator;
m_AspectRatio.cy = VideoFormat->videoInfo.PixelAspectRatio.Denominator;
- if (SUCCEEDED (hr))
- {
+ if (SUCCEEDED (hr)) {
i64Size.HighPart = VideoFormat->videoInfo.dwWidth;
i64Size.LowPart = VideoFormat->videoInfo.dwHeight;
m_pMediaType->SetUINT64 (MF_MT_FRAME_SIZE, i64Size.QuadPart);
@@ -968,19 +974,21 @@ HRESULT CEVRAllocatorPresenter::CreateProposedOutputType(IMFMediaType* pMixerTyp
CRenderersSettings& s = GetRenderersSettings();
#if 1
- if (s.m_RenderSettings.iEVROutputRange == 1)
+ if (s.m_RenderSettings.iEVROutputRange == 1) {
m_pMediaType->SetUINT32 (MF_MT_VIDEO_NOMINAL_RANGE, MFNominalRange_16_235);
- else
+ } 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)
+ if (s.iEVROutputRange == 1) {
m_pMediaType->SetUINT32 (MF_MT_YUV_MATRIX, MFVideoTransferMatrix_BT601);
- else
+ } else {
m_pMediaType->SetUINT32 (MF_MT_YUV_MATRIX, MFVideoTransferMatrix_BT709);
+ }
#endif
@@ -1000,20 +1008,17 @@ HRESULT CEVRAllocatorPresenter::CreateProposedOutputType(IMFMediaType* pMixerTyp
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)
- {
+ 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)
+ for (i = 2; i < MinNum+1; ++i) {
+ if (m_AspectRatio.cx%i == 0 && m_AspectRatio.cy%i ==0) {
break;
+ }
}
- if (i != MinNum + 1)
- {
+ if (i != MinNum + 1) {
m_AspectRatio.cx = m_AspectRatio.cx / i;
m_AspectRatio.cy = m_AspectRatio.cy / i;
bDoneSomething = true;
@@ -1037,8 +1042,7 @@ HRESULT CEVRAllocatorPresenter::SetMediaType(IMFMediaType* pType)
CheckHR (pType->GetRepresentation(FORMAT_VideoInfo2, (void**)&pAMMedia));
hr = InitializeDevice (pType);
- if (SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
strTemp = GetMediaTypeName (pAMMedia->subtype);
strTemp.Replace (L"MEDIASUBTYPE_", L"");
m_strStatsMsg[MSG_MIXEROUT].Format (L"Mixer output : %s", strTemp);
@@ -1051,17 +1055,20 @@ HRESULT CEVRAllocatorPresenter::SetMediaType(IMFMediaType* pType)
HRESULT CEVRAllocatorPresenter::GetMediaTypeFourCC(IMFMediaType* pType, DWORD* pFourCC)
{
- if (pFourCC == NULL)
+ if (pFourCC == NULL) {
return E_POINTER;
+ }
HRESULT hr = S_OK;
GUID guidSubType = GUID_NULL;
- if (SUCCEEDED(hr))
+ if (SUCCEEDED(hr)) {
hr = pType->GetGUID(MF_MT_SUBTYPE, &guidSubType);
+ }
- if (SUCCEEDED(hr))
+ if (SUCCEEDED(hr)) {
*pFourCC = guidSubType.Data1;
+ }
return hr;
}
@@ -1071,62 +1078,66 @@ HRESULT CEVRAllocatorPresenter::GetMediaTypeMerit(IMFMediaType* pType, int* pMer
D3DFORMAT Format;
HRESULT hr = GetMediaTypeFourCC(pType, (DWORD*)&Format);
- if (SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
// We only support RGB mixer output surface formats
- switch (Format)
- {
- case D3DFMT_A2R10G10B10:
- if (m_bHighColorResolution || m_bForceInputHighColorResolution || m_bFullFloatingPointProcessing)
- *pMerit = 950;
- else
- *pMerit = 650;
+ switch (Format) {
+ case D3DFMT_A2R10G10B10:
+ if (m_bHighColorResolution || m_bForceInputHighColorResolution || m_bFullFloatingPointProcessing) {
+ *pMerit = 950;
+ } else {
+ *pMerit = 650;
+ }
- break;
+ break;
- case D3DFMT_A2B10G10R10:
- if (m_bHighColorResolution || m_bForceInputHighColorResolution || m_bFullFloatingPointProcessing)
- *pMerit = 900;
- else
- *pMerit = 600;
+ case D3DFMT_A2B10G10R10:
+ if (m_bHighColorResolution || m_bForceInputHighColorResolution || m_bFullFloatingPointProcessing) {
+ *pMerit = 900;
+ } else {
+ *pMerit = 600;
+ }
- break;
+ break;
- case D3DFMT_X8R8G8B8:
- if (m_bForceInputHighColorResolution)
- *pMerit = 800;
- else
- *pMerit = 850;
+ case D3DFMT_X8R8G8B8:
+ if (m_bForceInputHighColorResolution) {
+ *pMerit = 800;
+ } else {
+ *pMerit = 850;
+ }
- break;
+ break;
- case D3DFMT_A8R8G8B8:
- if (m_bForceInputHighColorResolution)
- *pMerit = 850;
- else
- *pMerit = 800;
+ case D3DFMT_A8R8G8B8:
+ if (m_bForceInputHighColorResolution) {
+ *pMerit = 850;
+ } else {
+ *pMerit = 800;
+ }
- break;
+ break;
- case D3DFMT_X8B8G8R8:
- if (m_bForceInputHighColorResolution)
- *pMerit = 700;
- else
- *pMerit = 750;
+ case D3DFMT_X8B8G8R8:
+ if (m_bForceInputHighColorResolution) {
+ *pMerit = 700;
+ } else {
+ *pMerit = 750;
+ }
- break;
+ break;
- case D3DFMT_A8B8G8R8:
- if (m_bForceInputHighColorResolution)
- *pMerit = 750;
- else
- *pMerit = 700;
- break;
+ case D3DFMT_A8B8G8R8:
+ if (m_bForceInputHighColorResolution) {
+ *pMerit = 750;
+ } else {
+ *pMerit = 700;
+ }
+ break;
- default:
- // Unsupported format
- *pMerit = 0;
- break;
+ default:
+ // Unsupported format
+ *pMerit = 0;
+ break;
}
}
@@ -1149,8 +1160,7 @@ HRESULT CEVRAllocatorPresenter::RenegotiateMediaType()
CComPtr<IMFMediaType> pMixerType;
CComPtr<IMFMediaType> pType;
- if (!m_pMixer)
- {
+ if (!m_pMixer) {
return MF_E_INVALIDREQUEST;
}
@@ -1158,50 +1168,49 @@ HRESULT CEVRAllocatorPresenter::RenegotiateMediaType()
// Loop through all of the mixer's proposed output types.
DWORD iTypeIndex = 0;
- while ((hr != MF_E_NO_MORE_TYPES))
- {
+ 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))
- {
+ if (FAILED(hr)) {
break;
}
// Step 2. Check if we support this media type.
- if (SUCCEEDED(hr))
+ if (SUCCEEDED(hr)) {
hr = IsMediaTypeSupported(pMixerType);
+ }
- if (SUCCEEDED(hr))
+ if (SUCCEEDED(hr)) {
hr = CreateProposedOutputType(pMixerType, &pType);
+ }
// Step 4. Check if the mixer will accept this media type.
- if (SUCCEEDED(hr))
+ if (SUCCEEDED(hr)) {
hr = m_pMixer->SetOutputType(0, pType, MFT_SET_TYPE_TEST_ONLY);
+ }
int Merit;
- if (SUCCEEDED(hr))
+ if (SUCCEEDED(hr)) {
hr = GetMediaTypeMerit(pType, &Merit);
+ }
- if (SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
int nTypes = ValidMixerTypes.GetCount();
int iInsertPos = 0;
- for (int i = 0; i < nTypes; ++i)
- {
+ for (int i = 0; i < nTypes; ++i) {
int ThisMerit;
GetMediaTypeMerit(ValidMixerTypes[i], &ThisMerit);
- if (Merit > ThisMerit)
- {
+ if (Merit > ThisMerit) {
iInsertPos = i;
break;
- }
- else
+ } else {
iInsertPos = i+1;
+ }
}
ValidMixerTypes.InsertAt(iInsertPos, pType);
@@ -1210,15 +1219,13 @@ HRESULT CEVRAllocatorPresenter::RenegotiateMediaType()
int nValidTypes = ValidMixerTypes.GetCount();
- for (int i = 0; i < nValidTypes; ++i)
- {
+ for (int 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 (int i = 0; i < nValidTypes; ++i)
- {
+ for (int i = 0; i < nValidTypes; ++i) {
// Step 3. Adjust the mixer's type to match our requirements.
pType = ValidMixerTypes[i];
@@ -1229,17 +1236,15 @@ HRESULT CEVRAllocatorPresenter::RenegotiateMediaType()
hr = SetMediaType(pType);
// Step 6. Set output media type on mixer.
- if (SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
hr = m_pMixer->SetOutputType(0, pType, 0);
// If something went wrong, clear the media type.
- if (FAILED(hr))
- {
+ if (FAILED(hr)) {
SetMediaType(NULL);
- }
- else
+ } else {
break;
+ }
}
}
@@ -1262,12 +1267,10 @@ bool CEVRAllocatorPresenter::GetImageFromMixer()
bool bDoneSomething = false;
- while (SUCCEEDED(hr))
- {
+ while (SUCCEEDED(hr)) {
CComPtr<IMFSample> pSample;
- if (FAILED (GetFreeSample (&pSample)))
- {
+ if (FAILED (GetFreeSample (&pSample))) {
m_bWaitingSample = true;
break;
}
@@ -1282,14 +1285,12 @@ bool CEVRAllocatorPresenter::GetImageFromMixer()
llClockAfter = GetRenderersData()->GetPerfCounter();
}
- if (hr == MF_E_TRANSFORM_NEED_MORE_INPUT)
- {
+ if (hr == MF_E_TRANSFORM_NEED_MORE_INPUT) {
MoveToFreeList (pSample, false);
break;
}
- if (m_pSink)
- {
+ 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);
@@ -1299,8 +1300,7 @@ bool CEVRAllocatorPresenter::GetImageFromMixer()
REFERENCE_TIME nsDuration;
pSample->GetSampleDuration (&nsDuration);
- if (GetRenderersData()->m_fTearingTest)
- {
+ if (GetRenderersData()->m_fTearingTest) {
RECT rcTearing;
rcTearing.left = m_nTearingPos;
@@ -1320,8 +1320,9 @@ bool CEVRAllocatorPresenter::GetImageFromMixer()
MoveToScheduledList (pSample, false);
bDoneSomething = true;
- if (m_rtTimePerFrame == 0)
+ if (m_rtTimePerFrame == 0) {
break;
+ }
}
return bDoneSomething;
@@ -1337,8 +1338,9 @@ STDMETHODIMP CEVRAllocatorPresenter::GetCurrentMediaType(__deref_out IMFVideoMe
CheckPointer (ppMediaType, E_POINTER);
CheckHR (CheckShutdown());
- if (m_pMediaType == NULL)
+ if (m_pMediaType == NULL) {
CheckHR(MF_E_NOT_INITIALIZED);
+ }
CheckHR(m_pMediaType->QueryInterface( __uuidof(IMFVideoMediaType), (void**)&ppMediaType));
@@ -1393,10 +1395,11 @@ STDMETHODIMP CEVRAllocatorPresenter::GetService (/* [in] */ __RPC__in REFGUID gu
/* [in] */ __RPC__in REFIID riid,
/* [iid_is][out] */ __RPC__deref_out_opt LPVOID *ppvObject)
{
- if (guidService == MR_VIDEO_RENDER_SERVICE)
+ if (guidService == MR_VIDEO_RENDER_SERVICE) {
return NonDelegatingQueryInterface (riid, ppvObject);
- else if (guidService == MR_VIDEO_ACCELERATION_SERVICE)
+ } else if (guidService == MR_VIDEO_ACCELERATION_SERVICE) {
return m_pD3DManager->QueryInterface (__uuidof(IDirect3DDeviceManager9), (void**) ppvObject);
+ }
return E_NOINTERFACE;
}
@@ -1417,13 +1420,11 @@ STDMETHODIMP CEVRAllocatorPresenter::Invoke ( /* [in] */ __RPC__in_opt IMFAsyn
// IMFVideoDisplayControl
STDMETHODIMP CEVRAllocatorPresenter::GetNativeVideoSize(SIZE *pszVideo, SIZE *pszARVideo)
{
- if (pszVideo)
- {
+ if (pszVideo) {
pszVideo->cx = m_NativeVideoSize.cx;
pszVideo->cy = m_NativeVideoSize.cy;
}
- if (pszARVideo)
- {
+ if (pszARVideo) {
pszARVideo->cx = m_NativeVideoSize.cx * m_AspectRatio.cx;
pszARVideo->cy = m_NativeVideoSize.cy * m_AspectRatio.cy;
}
@@ -1431,19 +1432,16 @@ STDMETHODIMP CEVRAllocatorPresenter::GetNativeVideoSize(SIZE *pszVideo, SIZE *ps
}
STDMETHODIMP CEVRAllocatorPresenter::GetIdealVideoSize(SIZE *pszMin, SIZE *pszMax)
{
- if (pszMin)
- {
+ if (pszMin) {
pszMin->cx = 1;
pszMin->cy = 1;
}
- if (pszMax)
- {
+ if (pszMax) {
D3DDISPLAYMODE d3ddm;
ZeroMemory(&d3ddm, sizeof(d3ddm));
- if(SUCCEEDED(m_pD3D->GetAdapterDisplayMode(GetAdapter(m_pD3D), &d3ddm)))
- {
+ if(SUCCEEDED(m_pD3D->GetAdapterDisplayMode(GetAdapter(m_pD3D), &d3ddm))) {
pszMax->cx = d3ddm.Width;
pszMax->cy = d3ddm.Height;
}
@@ -1458,16 +1456,16 @@ STDMETHODIMP CEVRAllocatorPresenter::SetVideoPosition(const MFVideoNormalizedRec
STDMETHODIMP CEVRAllocatorPresenter::GetVideoPosition(MFVideoNormalizedRect *pnrcSource, LPRECT prcDest)
{
// Always all source rectangle ?
- if (pnrcSource)
- {
+ 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;
}
@@ -1485,7 +1483,7 @@ STDMETHODIMP CEVRAllocatorPresenter::GetAspectRatioMode(DWORD *pdwAspectRatioMod
STDMETHODIMP CEVRAllocatorPresenter::SetVideoWindow(HWND hwndVideo)
{
ASSERT (m_hWnd == hwndVideo); // What if not ??
-// m_hWnd = hwndVideo;
+ // m_hWnd = hwndVideo;
return S_OK;
}
STDMETHODIMP CEVRAllocatorPresenter::GetVideoWindow(HWND *phwndVideo)
@@ -1596,15 +1594,12 @@ STDMETHODIMP CEVRAllocatorPresenter::GetVideoService(HANDLE hDevice, REFIID riid
{
HRESULT hr = m_pD3DManager->GetVideoService(hDevice, riid, ppService);
- if (riid == __uuidof(IDirectXVideoDecoderService))
- {
+ if (riid == __uuidof(IDirectXVideoDecoderService)) {
UINT nNbDecoder = 5;
GUID* pDecoderGuid;
IDirectXVideoDecoderService* pDXVAVideoDecoder = (IDirectXVideoDecoderService*) *ppService;
pDXVAVideoDecoder->GetDecoderDeviceGuids (&nNbDecoder, &pDecoderGuid);
- }
- else if (riid == __uuidof(IDirectXVideoProcessorService))
- {
+ } else if (riid == __uuidof(IDirectXVideoProcessorService)) {
IDirectXVideoProcessorService* pDXVAProcessor = (IDirectXVideoProcessorService*) *ppService;
UNUSED_ALWAYS(pDXVAProcessor);
}
@@ -1618,10 +1613,18 @@ STDMETHODIMP CEVRAllocatorPresenter::GetNativeVideoSize(LONG* lpWidth, LONG* lpH
// 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;
+ 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;
}
@@ -1642,30 +1645,27 @@ STDMETHODIMP CEVRAllocatorPresenter::InitializeDevice(IMFMediaType* pMediaType)
hr = MFGetAttributeSize(pMediaType, MF_MT_FRAME_SIZE, &Width, &Height);
D3DFORMAT Format;
- if (SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
m_NativeVideoSize = CSize(Width, Height);
hr = GetMediaTypeFourCC(pMediaType, (DWORD*)&Format);
}
- if (SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
if (m_bForceInputHighColorResolution)
// May crash or not work correctly!
+ {
hr = AllocSurfaces(D3DFMT_A2R10G10B10);
- else
+ } else {
hr = AllocSurfaces(Format);
+ }
}
- if (SUCCEEDED(hr))
- {
- for(int i = 0; i < m_nNbDXSurface; i++)
- {
+ if (SUCCEEDED(hr)) {
+ for(int i = 0; i < m_nNbDXSurface; i++) {
CComPtr<IMFSample> pMFSample;
hr = pfMFCreateVideoSampleFromSurface (m_pVideoSurface[i], &pMFSample);
- if (SUCCEEDED (hr))
- {
+ if (SUCCEEDED (hr)) {
pMFSample->SetUINT32 (GUID_SURFACE_INDEX, i);
m_FreeSamples.AddTail (pMFSample);
}
@@ -1697,8 +1697,7 @@ DWORD WINAPI CEVRAllocatorPresenter::PresentThread(LPVOID lpParam)
void CEVRAllocatorPresenter::CheckWaitingSampleFromMixer()
{
- if (m_bWaitingSample)
- {
+ if (m_bWaitingSample) {
m_bWaitingSample = false;
//GetImageFromMixer(); // Do this in processing thread instead
}
@@ -1707,16 +1706,17 @@ void CEVRAllocatorPresenter::CheckWaitingSampleFromMixer()
bool ExtractInterlaced(const AM_MEDIA_TYPE* pmt)
{
- if (pmt->formattype==FORMAT_VideoInfo)
+ if (pmt->formattype==FORMAT_VideoInfo) {
return false;
- else if (pmt->formattype==FORMAT_VideoInfo2)
+ } else if (pmt->formattype==FORMAT_VideoInfo2) {
return (((VIDEOINFOHEADER2*)pmt->pbFormat)->dwInterlaceFlags & AMINTERLACE_IsInterlaced) != 0;
- else if (pmt->formattype==FORMAT_MPEGVideo)
+ } else if (pmt->formattype==FORMAT_MPEGVideo) {
return false;
- else if (pmt->formattype==FORMAT_MPEG2Video)
+ } else if (pmt->formattype==FORMAT_MPEG2Video) {
return (((MPEG2VIDEOINFO*)pmt->pbFormat)->hdr.dwInterlaceFlags & AMINTERLACE_IsInterlaced) != 0;
- else
+ } else {
return false;
+ }
}
@@ -1731,68 +1731,63 @@ void CEVRAllocatorPresenter::GetMixerThread()
//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*/);
+ // 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)
- {
+ while (!bQuit) {
DWORD dwObject = WaitForMultipleObjects (countof(hEvts), hEvts, FALSE, 1);
- switch (dwObject)
- {
- case WAIT_OBJECT_0 :
- bQuit = true;
- break;
- case WAIT_TIMEOUT :
- {
- 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)) )
+ switch (dwObject) {
+ case WAIT_OBJECT_0 :
+ bQuit = true;
+ break;
+ case WAIT_TIMEOUT : {
+ bool bDoneSomething = false;
{
- ExtractAvgTimePerFrame (&mt, m_rtTimePerFrame);
+ CAutoLock AutoLock(&m_ImageProcessingLock);
+ bDoneSomething = GetImageFromMixer();
+ }
+ if (m_rtTimePerFrame == 0 && bDoneSomething) {
+ //CAutoLock lock(this);
+ //CAutoLock lock2(&m_ImageProcessingLock);
+ //CAutoLock cRenderLock(&m_RenderLock);
- m_bInterlaced = ExtractInterlaced(&mt);
+ // 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);
- }
- // If framerate not set by Video Decoder choose 23.97...
- if (m_rtTimePerFrame == 0)
- m_rtTimePerFrame = 417166;
+ m_bInterlaced = ExtractInterlaced(&mt);
+
+ }
+ // 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);
+ }
- // Update internal subtitle clock
- if(m_fUseInternalTimer && m_pSubPicQueue)
- {
- m_fps = (float)(10000000.0 / m_rtTimePerFrame);
- m_pSubPicQueue->SetFPS(m_fps);
}
}
-
- }
- break;
+ break;
}
}
timeEndPeriod (dwResolution);
-// if (pfAvRevertMmThreadCharacteristics) pfAvRevertMmThreadCharacteristics (hAvrt);
+ // if (pfAvRevertMmThreadCharacteristics) pfAvRevertMmThreadCharacteristics (hAvrt);
}
void ModerateFloat(double& Value, double Target, double& ValuePrim, double ChangeSpeed)
@@ -1812,20 +1807,19 @@ LONGLONG CEVRAllocatorPresenter::GetClockTime(LONGLONG PerformanceCounter)
MFCLOCK_STATE State;
m_pClock->GetState(0, &State);
- if (!(Characteristics & MFCLOCK_CHARACTERISTICS_FLAG_FREQUENCY_10MHZ))
- {
+ 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
+ if (m_pClock->GetProperties(&Props) == S_OK) {
+ llClockTime = (llClockTime * 10000000) / Props.qwClockFrequency; // Make 10 MHz
+ }
}
LONGLONG llPerf = PerformanceCounter;
-// return llClockTime + (llPerf - nsCurrentTime);
+ // return llClockTime + (llPerf - nsCurrentTime);
double Target = llClockTime + (llPerf - nsCurrentTime) * m_ModeratedTimeSpeed;
bool bReset = false;
- if (m_ModeratedTimeLast < 0 || State != m_LastClockState || m_ModeratedClockLast < 0)
- {
+ if (m_ModeratedTimeLast < 0 || State != m_LastClockState || m_ModeratedClockLast < 0) {
bReset = true;
m_ModeratedTimeLast = llPerf;
m_ModeratedClockLast = llClockTime;
@@ -1842,46 +1836,43 @@ LONGLONG CEVRAllocatorPresenter::GetClockTime(LONGLONG PerformanceCounter)
#if 1
- if (bReset)
- {
+ 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 (TimeChange)
- {
+ if (TimeChange) {
int Pos = m_ClockTimeChangeHistoryPos % 100;
int nHistory = min(m_ClockTimeChangeHistoryPos, 100);
++m_ClockTimeChangeHistoryPos;
- if (nHistory > 50)
- {
+ if (nHistory > 50) {
int iLastPos = (Pos - (nHistory)) % 100;
- if (iLastPos < 0)
+ 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)
+ if (ClockSpeedTarget > m_ModeratedTimeSpeed) {
+ if (ClockSpeedTarget / m_ModeratedTimeSpeed > 0.1) {
ChangeSpeed = 0.1;
- else
+ } else {
ChangeSpeed = 0.01;
- }
- else
- {
- if (m_ModeratedTimeSpeed / ClockSpeedTarget > 0.1)
+ }
+ } else {
+ if (m_ModeratedTimeSpeed / ClockSpeedTarget > 0.1) {
ChangeSpeed = 0.1;
- else
+ } else {
ChangeSpeed = 0.01;
+ }
}
ModerateFloat(m_ModeratedTimeSpeed, ClockSpeedTarget, m_ModeratedTimeSpeedPrim, ChangeSpeed);
-// m_ModeratedTimeSpeed = TimeChange / ClockChange;
+ // m_ModeratedTimeSpeed = TimeChange / ClockChange;
}
m_TimeChangeHistory[Pos] = llPerf;
m_ClockChangeHistory[Pos] = llClockTime;
@@ -1893,31 +1884,24 @@ LONGLONG CEVRAllocatorPresenter::GetClockTime(LONGLONG PerformanceCounter)
double Diff = Target - EstimateTime;
// > 5 ms just set it
- if ((fabs(Diff) > 50000.0 || bReset))
- {
+ 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)
- {
+ // 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
- {
+ } else {
EstimateTime = m_ModeratedTime + TimeChange * m_ModeratedTimeSpeed;
Diff = Target - EstimateTime;
m_ClockDiffCalc = Diff;
m_ClockDiffPrim = 0;
}
- }
- else
- {
+ } else {
m_ModeratedTimeSpeed = 0.0;
m_ModeratedTimeSpeedPrim = 0.0;
m_ClockDiffCalc = 0;
@@ -1938,8 +1922,7 @@ LONGLONG CEVRAllocatorPresenter::GetClockTime(LONGLONG PerformanceCounter)
int nModerate = 0;
double Change = 0;
- while (m_ModeratedTimer < llPerf - ModerateTime)
- {
+ while (m_ModeratedTimer < llPerf - ModerateTime) {
m_ModeratedTimer += ModerateTime;
m_ModeratedTime += double(ModerateTime) * m_ModeratedTimeSpeed;
@@ -1950,9 +1933,9 @@ LONGLONG CEVRAllocatorPresenter::GetClockTime(LONGLONG PerformanceCounter)
double TimeSpeedTarget;
double AbsDiff = fabs(Diff);
TimeSpeedTarget = 1.0 - (Diff / 1000000.0);
-// TimeSpeedTarget = m_ModeratedTimeSpeed - (Diff / 100000000000.0);
+ // TimeSpeedTarget = m_ModeratedTimeSpeed - (Diff / 100000000000.0);
//if (AbsDiff > 20000.0)
-// TimeSpeedTarget = 1.0 - (Diff / 1000000.0);
+ // TimeSpeedTarget = 1.0 - (Diff / 1000000.0);
/*else if (AbsDiff > 5000.0)
TimeSpeedTarget = 1.0 - (Diff / 100000000.0);
else
@@ -1963,8 +1946,9 @@ LONGLONG CEVRAllocatorPresenter::GetClockTime(LONGLONG PerformanceCounter)
++nModerate;
Change += m_ModeratedTimeSpeed - StartMod;
}
- if (nModerate)
+ if (nModerate) {
m_ModeratedTimeSpeedDiff = Change / nModerate;
+ }
double Ret = m_ModeratedTime + double(llPerf - m_ModeratedTimer) * m_ModeratedTimeSpeed;
double Diff = Target - Ret;
@@ -1983,44 +1967,45 @@ LONGLONG CEVRAllocatorPresenter::GetClockTime(LONGLONG PerformanceCounter)
void CEVRAllocatorPresenter::OnVBlankFinished(bool fAll, LONGLONG PerformanceCounter)
{
- if (!m_pCurrentDisplaydSample || !m_OrderedPaint || !fAll)
+ if (!m_pCurrentDisplaydSample || !m_OrderedPaint || !fAll) {
return;
+ }
LONGLONG llClockTime;
LONGLONG nsSampleTime;
LONGLONG SampleDuration = 0;
- if (!m_bSignaledStarvation)
- {
+ if (!m_bSignaledStarvation) {
llClockTime = GetClockTime(PerformanceCounter);
m_StarvationClock = llClockTime;
- }
- else
- {
+ } else {
llClockTime = m_StarvationClock;
}
- if (FAILED(m_pCurrentDisplaydSample->GetSampleDuration(&SampleDuration)))
+ if (FAILED(m_pCurrentDisplaydSample->GetSampleDuration(&SampleDuration))) {
SampleDuration = 0;
+ }
- if (FAILED(m_pCurrentDisplaydSample->GetSampleTime(&nsSampleTime)))
+ if (FAILED(m_pCurrentDisplaydSample->GetSampleTime(&nsSampleTime))) {
nsSampleTime = llClockTime;
+ }
LONGLONG TimePerFrame = m_rtTimePerFrame;
- if (!TimePerFrame)
+ if (!TimePerFrame) {
return;
- if (SampleDuration > 1)
+ }
+ 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));
+ // 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++)
- {
+ for (int i=0; i<NB_JITTER; i++) {
LONGLONG Offset = m_pllSyncOffset[i];
AvrageSum += Offset;
m_MaxSyncOffset = max(m_MaxSyncOffset, Offset);
@@ -2028,8 +2013,7 @@ void CEVRAllocatorPresenter::OnVBlankFinished(bool fAll, LONGLONG PerformanceCou
}
double MeanOffset = double(AvrageSum)/NB_JITTER;
double DeviationSum = 0;
- for (int i=0; i<NB_JITTER; i++)
- {
+ for (int i=0; i<NB_JITTER; i++) {
double Deviation = double(m_pllSyncOffset[i]) - MeanOffset;
DeviationSum += Deviation*Deviation;
}
@@ -2053,13 +2037,11 @@ STDMETHODIMP_(bool) CEVRAllocatorPresenter::ResetDevice()
bool bResult = __super::ResetDevice();
- for(int i = 0; i < m_nNbDXSurface; i++)
- {
+ for(int i = 0; i < m_nNbDXSurface; i++) {
CComPtr<IMFSample> pMFSample;
HRESULT hr = pfMFCreateVideoSampleFromSurface (m_pVideoSurface[i], &pMFSample);
- if (SUCCEEDED (hr))
- {
+ if (SUCCEEDED (hr)) {
pMFSample->SetUINT32 (GUID_SURFACE_INDEX, i);
m_FreeSamples.AddTail (pMFSample);
}
@@ -2082,12 +2064,12 @@ void CEVRAllocatorPresenter::RenderThread()
// Tell Vista Multimedia Class Scheduler we are a playback thretad (increase priority)
HANDLE hAvrt = 0;
- if (pfAvSetMmThreadCharacteristicsW)
- {
+ if (pfAvSetMmThreadCharacteristicsW) {
DWORD dwTaskIndex = 0;
hAvrt = pfAvSetMmThreadCharacteristicsW (L"Playback", &dwTaskIndex);
- if (pfAvSetMmThreadPriority)
+ if (pfAvSetMmThreadPriority) {
pfAvSetMmThreadPriority (hAvrt, AVRT_PRIORITY_HIGH /*AVRT_PRIORITY_CRITICAL*/);
+ }
}
timeGetDevCaps(&tc, sizeof(TIMECAPS));
@@ -2096,353 +2078,328 @@ void CEVRAllocatorPresenter::RenderThread()
CRenderersSettings& s = GetRenderersSettings();
int NextSleepTime = 1;
- while (!bQuit)
- {
+ while (!bQuit) {
LONGLONG llPerf = GetRenderersData()->GetPerfCounter();
UNUSED_ALWAYS(llPerf);
- if (!s.m_RenderSettings.iVMR9VSyncAccurate && NextSleepTime == 0)
+ 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)
+ // if (NextSleepTime)
+ // TRACE_EVR("EVR: Sleep: %7.3f\n", double(GetRenderersData()->GetPerfCounter()-llPerf) / 10000.0);
+ if (NextSleepTime > 1) {
NextSleepTime = 0;
- else if (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)
- {
+ }
+ switch (dwObject) {
+ case WAIT_OBJECT_0 :
+ bQuit = true;
+ break;
+ case WAIT_OBJECT_0 + 1 :
+ // Flush pending samples!
FlushSamples();
- RenegotiateMediaType();
- m_bPendingRenegotiate = false;
- }
- if (m_bPendingResetDevice)
- SendResetRequest();
+ m_bEvtFlush = false;
+ ResetEvent(m_hEvtFlush);
+ TRACE_EVR ("EVR: Flush done!\n");
+ break;
- // Discard timer events if playback stop
-// if ((dwObject == WAIT_OBJECT_0 + 3) && (m_nRenderState != Started)) continue;
+ case WAIT_TIMEOUT :
-// TRACE_EVR ("EVR: RenderThread ==>> Waiting buffer\n");
+ if (m_LastSetOutputRange != -1 && m_LastSetOutputRange != s.m_RenderSettings.iEVROutputRange || m_bPendingRenegotiate) {
+ FlushSamples();
+ RenegotiateMediaType();
+ m_bPendingRenegotiate = false;
+ }
+ if (m_bPendingResetDevice) {
+ SendResetRequest();
+ }
-// if (WaitForMultipleObjects (countof(hEvtsBuff), hEvtsBuff, FALSE, INFINITE) == WAIT_OBJECT_0+2)
- {
- CComPtr<IMFSample> pMFSample;
- LONGLONG llPerf = GetRenderersData()->GetPerfCounter();
- UNUSED_ALWAYS(llPerf);
- int nSamplesLeft = 0;
- if (SUCCEEDED (GetScheduledSample(&pMFSample, nSamplesLeft)))
- {
-// pMFSample->GetUINT32 (GUID_SURFACE_INDEX, (UINT32*)&m_nCurSurface);
- m_pCurrentDisplaydSample = pMFSample;
+ // Discard timer events if playback stop
+ // if ((dwObject == WAIT_OBJECT_0 + 3) && (m_nRenderState != Started)) continue;
- 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 ==>> Waiting buffer\n");
-// TRACE_EVR ("EVR: RenderThread ==>> Presenting surface %d (%I64d)\n", m_nCurSurface, nsSampleTime);
+ // if (WaitForMultipleObjects (countof(hEvtsBuff), hEvtsBuff, FALSE, INFINITE) == WAIT_OBJECT_0+2)
+ {
+ CComPtr<IMFSample> pMFSample;
+ LONGLONG llPerf = GetRenderersData()->GetPerfCounter();
+ UNUSED_ALWAYS(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);
- bool bStepForward = false;
+ // TRACE_EVR ("EVR: RenderThread ==>> Presenting surface %d (%I64d)\n", m_nCurSurface, nsSampleTime);
- 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;
- }
+ bool bStepForward = false;
- if (!bValidSampleTime)
- {
- // Just play as fast as possible
+ 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)
+ if (!g_bExternalSubtitleTime) {
__super::SetTime (g_tSegmentStart + nsSampleTime);
- Paint(true);
- }
- else
- {
- LONGLONG TimePerFrame = GetFrameTime() * 10000000.0;
- LONGLONG DrawTime = (m_PaintTime) * 0.9 - 20000.0; // 2 ms offset
- //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);
+ 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 (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 = TimeUntilVSync * 10000000.0;
- VSyncTime = DetectedRefreshTime * 10000000.0;
-
- LONGLONG ClockTimeAtNextVSync = llClockTime + (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.0;
- else
- MinMargin = 15000.0 + min(m_DetectedFrameTimeStdDev, 20000.0);
- LONGLONG TimePerFrameMargin = min(double(TimePerFrame)*0.11, max(double(TimePerFrame)*0.02, MinMargin));
- 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++;
+ if (!bValidSampleTime) {
+ // Just play as fast as possible
bStepForward = true;
- ++m_nDroppedUpdate;
- NextSleepTime = 0;
-// VSyncOffset0 = (-SyncOffset) - VSyncTime;
- //VSyncOffset0 = (-SyncOffset) - VSyncTime + TimePerFrameMargin1;
- //m_LastPredictedSync = VSyncOffset0;
- bDoVSyncCorrection = false;
- }
- else if (SyncOffset < TimePerFrameMargin1)
- {
-
- if (bVSyncCorrection)
+ pMFSample->GetUINT32(GUID_SURFACE_INDEX, (UINT32 *)&m_nCurSurface);
+ ++m_OrderedPaint;
+ if (!g_bExternalSubtitleTime) {
+ __super::SetTime (g_tSegmentStart + nsSampleTime);
+ }
+ Paint(true);
+ } else {
+ LONGLONG TimePerFrame = GetFrameTime() * 10000000.0;
+ LONGLONG DrawTime = (m_PaintTime) * 0.9 - 20000.0; // 2 ms offset
+ //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;
{
-// VSyncOffset0 = -SyncOffset;
- VSyncOffset0 = -SyncOffset;
- bDoVSyncCorrection = true;
+ CAutoLock Lock(&m_RefreshRateLock);
+ DetectedRefreshTime = m_DetectedRefreshTime;
+ DetectedRefreshRatePos = m_DetectedRefreshRatePos;
+ DetectedScanlinesPerFrame = m_DetectedScanlinesPerFrame;
+ DetectedScanlineTime = m_DetectedScanlineTime;
}
- // 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 (DetectedRefreshRatePos < 20 || !DetectedRefreshTime || !DetectedScanlinesPerFrame) {
+ DetectedRefreshTime = 1.0/m_RefreshRate;
+ DetectedScanlinesPerFrame = m_ScreenSize.cy;
+ DetectedScanlineTime = DetectedRefreshTime / double(m_ScreenSize.cy);
+ }
- ++m_OrderedPaint;
+ 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 = TimeUntilVSync * 10000000.0;
+ VSyncTime = DetectedRefreshTime * 10000000.0;
- if (!g_bExternalSubtitleTime)
- __super::SetTime (g_tSegmentStart + nsSampleTime);
- Paint(true);
- //m_pSink->Notify(EC_SCRUB_TIME, LODWORD(nsSampleTime), HIDWORD(nsSampleTime));
+ LONGLONG ClockTimeAtNextVSync = llClockTime + (TimeUntilVSync * 10000000.0) * m_ModeratedTimeSpeed;
- NextSleepTime = 0;
- m_pcFramesDrawn++;
- }
- else
- {
- if (TimeToNextVSync >= 0 && SyncOffset > 0)
- {
- NextSleepTime = ((TimeToNextVSync)/10000) - 2;
+ SyncOffset = (nsSampleTime - ClockTimeAtNextVSync);
+
+ // if (SyncOffset < 0)
+ // TRACE_EVR("EVR: SyncOffset(%d): %I64d %I64d %I64d\n", m_nCurSurface, SyncOffset, TimePerFrame, VSyncTime);
+ } else {
+ SyncOffset = (nsSampleTime - llClockTime);
}
- else
- NextSleepTime = ((SyncOffset)/10000) - 2;
- if (NextSleepTime > TimePerFrame)
- NextSleepTime = 1;
+ //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;
+ }
- if (NextSleepTime < 0)
- NextSleepTime = 0;
- NextSleepTime = 1;
- //TRACE_EVR ("EVR: Delay\n");
- }
+ LONGLONG MinMargin;
+ if (m_FrameTimeCorrection && 0) {
+ MinMargin = 15000.0;
+ } else {
+ MinMargin = 15000.0 + min(m_DetectedFrameTimeStdDev, 20000.0);
+ }
+ LONGLONG TimePerFrameMargin = min(double(TimePerFrame)*0.11, max(double(TimePerFrame)*0.02, MinMargin));
+ LONGLONG TimePerFrameMargin0 = TimePerFrameMargin/2;
+ LONGLONG TimePerFrameMargin1 = 0;
- if (bDoVSyncCorrection)
- {
- //LONGLONG VSyncOffset0 = (((SyncOffset) % VSyncTime) + VSyncTime) % VSyncTime;
- LONGLONG Margin = TimePerFrameMargin;
+ if (m_DetectedLock && TimePerFrame < VSyncTime) {
+ VSyncTime = TimePerFrame;
+ }
- 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);
+ if (m_VSyncMode == 1) {
+ TimePerFrameMargin1 = -TimePerFrameMargin;
+ } else if (m_VSyncMode == 2) {
+ TimePerFrameMargin1 = TimePerFrameMargin;
}
- m_VSyncOffsetHistory[m_VSyncOffsetHistoryPos] = VSyncOffset0;
- m_VSyncOffsetHistoryPos = (m_VSyncOffsetHistoryPos + 1) % 5;
+ 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;
+ VSyncOffset0 = -SyncOffset;
+ bDoVSyncCorrection = true;
+ }
-// LONGLONG VSyncTime2 = VSyncTime2 + (VSyncOffsetMax - VSyncOffsetMin);
- //VSyncOffsetMin; = (((VSyncOffsetMin) % VSyncTime) + VSyncTime) % VSyncTime;
- //VSyncOffsetMax = (((VSyncOffsetMax) % VSyncTime) + VSyncTime) % VSyncTime;
+ // 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;
-// TRACE_EVR("EVR: SyncOffset(%d, %d): %8I64d %8I64d %8I64d %8I64d\n", m_nCurSurface, m_VSyncMode,VSyncOffset0, VSyncOffsetMin, VSyncOffsetMax, VSyncOffsetMax - VSyncOffsetMin);
+ ++m_OrderedPaint;
- if (m_VSyncMode == 0)
- {
- // 23.976 in 60 Hz
- if (VSyncOffset0 < Margin && VSyncOffsetMax > (VSyncTime - Margin))
- {
- m_VSyncMode = 2;
+ if (!g_bExternalSubtitleTime) {
+ __super::SetTime (g_tSegmentStart + nsSampleTime);
}
- else if (VSyncOffset0 > (VSyncTime - Margin) && VSyncOffsetMin < Margin)
- {
- m_VSyncMode = 1;
+ Paint(true);
+ //m_pSink->Notify(EC_SCRUB_TIME, LODWORD(nsSampleTime), HIDWORD(nsSampleTime));
+
+ NextSleepTime = 0;
+ m_pcFramesDrawn++;
+ } else {
+ if (TimeToNextVSync >= 0 && SyncOffset > 0) {
+ NextSleepTime = ((TimeToNextVSync)/10000) - 2;
+ } else {
+ NextSleepTime = ((SyncOffset)/10000) - 2;
}
- }
- else if (m_VSyncMode == 2)
- {
- if (VSyncOffsetMin > (Margin))
- {
- m_VSyncMode = 0;
+
+ if (NextSleepTime > TimePerFrame) {
+ NextSleepTime = 1;
+ }
+
+ if (NextSleepTime < 0) {
+ NextSleepTime = 0;
}
+ NextSleepTime = 1;
+ //TRACE_EVR ("EVR: Delay\n");
}
- else if (m_VSyncMode == 1)
- {
- if (VSyncOffsetMax < (VSyncTime - Margin))
- {
- m_VSyncMode = 0;
+
+ 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;
+ 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();
}
- //GetImageFromMixer();
- }
-// else
-// {
-// TRACE_EVR ("EVR: RenderThread ==>> Flush before rendering frame!\n");
-// }
+ // else
+ // {
+ // TRACE_EVR ("EVR: RenderThread ==>> Flush before rendering frame!\n");
+ // }
- break;
+ break;
}
}
timeEndPeriod (dwResolution);
- if (pfAvRevertMmThreadCharacteristics) pfAvRevertMmThreadCharacteristics (hAvrt);
+ if (pfAvRevertMmThreadCharacteristics) {
+ pfAvRevertMmThreadCharacteristics (hAvrt);
+ }
}
void CEVRAllocatorPresenter::OnResetDevice()
@@ -2453,8 +2410,9 @@ void CEVRAllocatorPresenter::OnResetDevice()
hr = m_pD3DManager->ResetDevice(m_pD3DDev, m_nResetToken);
// Not necessary, but Microsoft documentation say Presenter should send this message...
- if (m_pSink)
+ if (m_pSink) {
m_pSink->Notify (EC_DISPLAY_CHANGED, 0, 0);
+ }
}
void CEVRAllocatorPresenter::RemoveAllSamples()
@@ -2474,13 +2432,12 @@ HRESULT CEVRAllocatorPresenter::GetFreeSample(IMFSample** ppSample)
CAutoLock lock(&m_SampleQueueLock);
HRESULT hr = S_OK;
- if (m_FreeSamples.GetCount() > 1) // <= Cannot use first free buffer (can be currently displayed)
- {
+ if (m_FreeSamples.GetCount() > 1) { // <= Cannot use first free buffer (can be currently displayed)
InterlockedIncrement (&m_nUsedBuffer);
*ppSample = m_FreeSamples.RemoveHead().Detach();
- }
- else
+ } else {
hr = MF_E_SAMPLEALLOCATOR_EMPTY;
+ }
return hr;
}
@@ -2492,13 +2449,12 @@ HRESULT CEVRAllocatorPresenter::GetScheduledSample(IMFSample** ppSample, int &_C
HRESULT hr = S_OK;
_Count = m_ScheduledSamples.GetCount();
- if (_Count > 0)
- {
+ if (_Count > 0) {
*ppSample = m_ScheduledSamples.RemoveHead().Detach();
--_Count;
- }
- else
+ } else {
hr = MF_E_SAMPLEALLOCATOR_EMPTY;
+ }
return hr;
}
@@ -2508,23 +2464,22 @@ void CEVRAllocatorPresenter::MoveToFreeList(IMFSample* pSample, bool bTail)
{
CAutoLock lock(&m_SampleQueueLock);
InterlockedDecrement (&m_nUsedBuffer);
- if (m_bPendingMediaFinished && m_nUsedBuffer == 0)
- {
+ if (m_bPendingMediaFinished && m_nUsedBuffer == 0) {
m_bPendingMediaFinished = false;
m_pSink->Notify (EC_COMPLETE, 0, 0);
}
- if (bTail)
+ if (bTail) {
m_FreeSamples.AddTail (pSample);
- else
+ } else {
m_FreeSamples.AddHead(pSample);
+ }
}
void CEVRAllocatorPresenter::MoveToScheduledList(IMFSample* pSample, bool _bSorted)
{
- if (_bSorted)
- {
+ if (_bSorted) {
CAutoLock lock(&m_SampleQueueLock);
// Insert sorted
/* POSITION Iterator = m_ScheduledSamples.GetHeadPosition();
@@ -2546,18 +2501,17 @@ void CEVRAllocatorPresenter::MoveToScheduledList(IMFSample* pSample, bool _bSort
}*/
m_ScheduledSamples.AddHead(pSample);
- }
- else
- {
+ } else {
CAutoLock lock(&m_SampleQueueLock);
CRenderersSettings& s = GetRenderersSettings();
double ForceFPS = 0.0;
-// double ForceFPS = 59.94;
-// double ForceFPS = 23.976;
- if (ForceFPS != 0.0)
+ // double ForceFPS = 59.94;
+ // double ForceFPS = 23.976;
+ if (ForceFPS != 0.0) {
m_rtTimePerFrame = 10000000.0 / ForceFPS;
+ }
LONGLONG Duration = m_rtTimePerFrame;
UNUSED_ALWAYS(Duration);
LONGLONG PrevTime = m_LastScheduledUncorrectedSampleTime;
@@ -2571,33 +2525,33 @@ void CEVRAllocatorPresenter::MoveToScheduledList(IMFSample* pSample, bool _bSort
LONGLONG Diff2 = PrevTime - m_LastScheduledSampleTimeFP*10000000.0;
LONGLONG Diff = Time - PrevTime;
- if (PrevTime == -1)
+ if (PrevTime == -1) {
Diff = 0;
- if (Diff < 0)
+ }
+ if (Diff < 0) {
Diff = -Diff;
- if (Diff2 < 0)
+ }
+ if (Diff2 < 0) {
Diff2 = -Diff2;
- if (Diff < m_rtTimePerFrame*8 && m_rtTimePerFrame && Diff2 < m_rtTimePerFrame*8) // Detect seeking
- {
+ }
+ 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)
+ if (PrevTime == -1) {
Diff = 0;
+ }
m_DetectedFrameTimeHistory[iPos] = Diff;
- if (m_DetectedFrameTimePos >= 10)
- {
+ if (m_DetectedFrameTimePos >= 10) {
int nFrames = min(m_DetectedFrameTimePos, 60);
LONGLONG DectedSum = 0;
- for (int i = 0; i < nFrames; ++i)
- {
+ 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)
- {
+ for (int i = 0; i < nFrames; ++i) {
double Deviation = m_DetectedFrameTimeHistory[i] - Average;
DeviationSum += Deviation*Deviation;
}
@@ -2613,10 +2567,8 @@ void CEVRAllocatorPresenter::MoveToScheduledList(IMFSample* pSample, bool _bSort
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 = sizeof(AllowedValues) / sizeof(AllowedValues[0]);
- for (int i = 0; i < nAllowed; ++i)
- {
- if (fabs(1.0 - DetectedRate / AllowedValues[i]) < AllowedError)
- {
+ for (int i = 0; i < nAllowed; ++i) {
+ if (fabs(1.0 - DetectedRate / AllowedValues[i]) < AllowedError) {
DetectedRate = AllowedValues[i];
break;
}
@@ -2630,22 +2582,18 @@ void CEVRAllocatorPresenter::MoveToScheduledList(IMFSample* pSample, bool _bSort
int m_Int;
- CAutoInt()
- {
+ CAutoInt() {
m_Int = 0;
}
- CAutoInt(int _Other)
- {
+ CAutoInt(int _Other) {
m_Int = _Other;
}
- operator int () const
- {
+ operator int () const {
return m_Int;
}
- CAutoInt &operator ++ ()
- {
+ CAutoInt &operator ++ () {
++m_Int;
return *this;
}
@@ -2654,37 +2602,31 @@ void CEVRAllocatorPresenter::MoveToScheduledList(IMFSample* pSample, bool _bSort
CMap<double, double, CAutoInt, CAutoInt> Map;
- for (int i = 0; i < 500; ++i)
- {
+ for (int i = 0; i < 500; ++i) {
++Map[m_DetectedFrameTimeHistoryHistory[i]];
}
POSITION Pos = Map.GetStartPosition();
double BestVal = 0.0;
int BestNum = 5;
- while (Pos)
- {
+ while (Pos) {
double Key;
CAutoInt Value;
Map.GetNextAssoc(Pos, Key, Value);
- if (Value.m_Int > BestNum && Key != 0.0)
- {
+ 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])
- {
+ for (int i = 0; i < nAllowed; ++i) {
+ if (BestVal == AllowedValues[i]) {
m_DetectedLock = true;
break;
}
}
- if (BestVal != 0.0)
- {
+ if (BestVal != 0.0) {
m_DetectedFrameRate = BestVal;
m_DetectedFrameTime = 1.0 / BestVal;
}
@@ -2692,18 +2634,17 @@ void CEVRAllocatorPresenter::MoveToScheduledList(IMFSample* pSample, bool _bSort
LONGLONG PredictedNext = PrevTime + m_rtTimePerFrame;
LONGLONG PredictedDiff = PredictedNext - Time;
- if (PredictedDiff < 0)
+ if (PredictedDiff < 0) {
PredictedDiff = -PredictedDiff;
+ }
if (m_DetectedFrameTime != 0.0
//&& PredictedDiff > 15000
- && m_DetectedLock && s.m_RenderSettings.iEVREnableFrameTimeCorrection)
- {
+ && 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
- {
+ if (fabs(PredictedTime - CurrentTime) > 0.0015) { // 1.5 ms wrong, lets correct
CurrentTime = PredictedTime;
Time = CurrentTime * 10000000.0;
pSample->SetSampleTime(Time);
@@ -2712,15 +2653,12 @@ void CEVRAllocatorPresenter::MoveToScheduledList(IMFSample* pSample, bool _bSort
m_FrameTimeCorrection = 30;
}
m_LastScheduledSampleTimeFP = CurrentTime;
- }
- else
+ } else {
m_LastScheduledSampleTimeFP = Time / 10000000.0;
- }
- else
- {
+ }
+ } else {
m_LastScheduledSampleTimeFP = Time / 10000000.0;
- if (Diff > m_rtTimePerFrame*8)
- {
+ if (Diff > m_rtTimePerFrame*8) {
// Seek
m_bSignaledStarvation = false;
m_DetectedFrameTimePos = 0;
@@ -2728,19 +2666,19 @@ void CEVRAllocatorPresenter::MoveToScheduledList(IMFSample* pSample, bool _bSort
}
}
-// TRACE_EVR("EVR: Time: %f %f %f\n", Time / 10000000.0, SetDuration / 10000000.0, m_DetectedFrameRate);
- if (!m_bCorrectedFrameTime && m_FrameTimeCorrection)
+ // 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)
+ 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)
- {
+ 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);
@@ -2749,8 +2687,7 @@ void CEVRAllocatorPresenter::MoveToScheduledList(IMFSample* pSample, bool _bSort
TRACE_EVR("EVR: Corrected invalid sample time\n");
}
}
- if (Time+Duration*10 < m_LastScheduledSampleTime)
- {
+ if (Time+Duration*10 < m_LastScheduledSampleTime) {
// Flush when repeating movie
FlushSamplesInternal();
}
@@ -2760,8 +2697,7 @@ void CEVRAllocatorPresenter::MoveToScheduledList(IMFSample* pSample, bool _bSort
static LONGLONG LastDuration = 0;
LONGLONG SetDuration = m_rtTimePerFrame;
pSample->GetSampleDuration(&SetDuration);
- if (SetDuration != LastDuration)
- {
+ if (SetDuration != LastDuration) {
TRACE_EVR("EVR: Old duration: %I64d New duration: %I64d\n", LastDuration, SetDuration);
}
LastDuration = SetDuration;
@@ -2786,8 +2722,7 @@ void CEVRAllocatorPresenter::FlushSamples()
void CEVRAllocatorPresenter::FlushSamplesInternal()
{
- while (m_ScheduledSamples.GetCount() > 0)
- {
+ while (m_ScheduledSamples.GetCount() > 0) {
CComPtr<IMFSample> pMFSample;
pMFSample = m_ScheduledSamples.RemoveHead();
diff --git a/src/filters/renderer/VideoRenderers/EVRAllocatorPresenter.h b/src/filters/renderer/VideoRenderers/EVRAllocatorPresenter.h
index c10634f2b..56d67639c 100644
--- a/src/filters/renderer/VideoRenderers/EVRAllocatorPresenter.h
+++ b/src/filters/renderer/VideoRenderers/EVRAllocatorPresenter.h
@@ -28,255 +28,254 @@
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();
-
- // IMFClockStateSink
- STDMETHODIMP OnClockStart(/* [in] */ MFTIME hnsSystemTime, /* [in] */ LONGLONG llClockStartOffset);
- STDMETHODIMP STDMETHODCALLTYPE OnClockStop(/* [in] */ MFTIME hnsSystemTime);
- STDMETHODIMP STDMETHODCALLTYPE OnClockPause(/* [in] */ MFTIME hnsSystemTime);
- STDMETHODIMP STDMETHODCALLTYPE OnClockRestart(/* [in] */ MFTIME hnsSystemTime);
- STDMETHODIMP STDMETHODCALLTYPE 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
+ // 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...)
+ */
{
- 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;
+ 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();
+
+ // IMFClockStateSink
+ STDMETHODIMP OnClockStart(/* [in] */ MFTIME hnsSystemTime, /* [in] */ LONGLONG llClockStartOffset);
+ STDMETHODIMP STDMETHODCALLTYPE OnClockStop(/* [in] */ MFTIME hnsSystemTime);
+ STDMETHODIMP STDMETHODCALLTYPE OnClockPause(/* [in] */ MFTIME hnsSystemTime);
+ STDMETHODIMP STDMETHODCALLTYPE OnClockRestart(/* [in] */ MFTIME hnsSystemTime);
+ STDMETHODIMP STDMETHODCALLTYPE 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 c7a8caaed..e1420fd6e 100644
--- a/src/filters/renderer/VideoRenderers/IPinHook.cpp
+++ b/src/filters/renderer/VideoRenderers/IPinHook.cpp
@@ -79,14 +79,12 @@ const DXVA2_DECODER DXVA2Decoder[] =
};
*/
-typedef struct
-{
+typedef struct {
const int Format;
const LPCTSTR Description;
} D3DFORMAT_TYPE;
-const D3DFORMAT_TYPE D3DFormatType[] =
-{
+const D3DFORMAT_TYPE D3DFormatType[] = {
{ D3DFMT_UNKNOWN , _T("D3DFMT_UNKNOWN ") },
{ D3DFMT_R8G8B8 , _T("D3DFMT_R8G8B8 ") },
{ D3DFMT_A8R8G8B8 , _T("D3DFMT_A8R8G8B8 ") },
@@ -156,10 +154,10 @@ LPCTSTR GetDXVAVersion()
LPCTSTR FindD3DFormat(const D3DFORMAT Format)
{
- for (int i=0; i<countof(D3DFormatType); i++)
- {
- if (Format == D3DFormatType[i].Format)
+ for (int i=0; i<countof(D3DFormatType); i++) {
+ if (Format == D3DFormatType[i].Format) {
return D3DFormatType[i].Description;
+ }
}
return D3DFormatType[0].Description;
@@ -179,8 +177,9 @@ static HRESULT ( STDMETHODCALLTYPE *ReceiveOrg )( IMemInputPinC * This, IMediaSa
static HRESULT STDMETHODCALLTYPE ReceiveMineI(IMemInputPinC * This, IMediaSample *pSample)
{
REFERENCE_TIME rtStart, rtStop;
- if(pSample && SUCCEEDED(pSample->GetTime(&rtStart, &rtStop)))
+ if(pSample && SUCCEEDED(pSample->GetTime(&rtStart, &rtStop))) {
g_tSampleStart = rtStart;
+ }
return ReceiveOrg(This, pSample);
}
@@ -188,8 +187,7 @@ static HRESULT STDMETHODCALLTYPE ReceiveMine(IMemInputPinC * This, IMediaSample
{
// Support ffdshow queueing.
// To avoid black out on pause, we have to lock g_ffdshowReceive to synchronize with CMainFrame::OnPlayPause.
- if(queue_ffdshow_support)
- {
+ if(queue_ffdshow_support) {
CAutoLock lck(&g_ffdshowReceive);
return ReceiveMineI(This,pSample);
}
@@ -203,16 +201,17 @@ void UnhookNewSegmentAndReceive()
DWORD flOldProtect = 0;
// Casimir666 : unhook previous VTables
- if (g_pPinCVtbl && g_pMemInputPinCVtbl)
- {
+ if (g_pPinCVtbl && g_pMemInputPinCVtbl) {
res = VirtualProtect(g_pPinCVtbl, sizeof(IPinCVtbl), PAGE_WRITECOPY, &flOldProtect);
- if (g_pPinCVtbl->NewSegment == NewSegmentMine)
+ 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)
+ if (g_pMemInputPinCVtbl->Receive == ReceiveMine) {
g_pMemInputPinCVtbl->Receive = ReceiveOrg;
+ }
res = VirtualProtect(g_pMemInputPinCVtbl, sizeof(IMemInputPinCVtbl), flOldProtect, &flOldProtect);
g_pPinCVtbl = NULL;
@@ -224,8 +223,9 @@ void UnhookNewSegmentAndReceive()
bool HookNewSegmentAndReceive(IPinC* pPinC, IMemInputPinC* pMemInputPinC)
{
- if(!pPinC || !pMemInputPinC || (GetVersion()&0x80000000))
+ if(!pPinC || !pMemInputPinC || (GetVersion()&0x80000000)) {
return false;
+ }
g_tSegmentStart = 0;
g_tSampleStart = 0;
@@ -237,13 +237,17 @@ bool HookNewSegmentAndReceive(IPinC* pPinC, IMemInputPinC* pMemInputPinC)
// 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;
+ if(NewSegmentOrg == NULL) {
+ NewSegmentOrg = pPinC->lpVtbl->NewSegment;
+ }
pPinC->lpVtbl->NewSegment = NewSegmentMine;
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;
+ if(ReceiveOrg == NULL) {
+ ReceiveOrg = pMemInputPinC->lpVtbl->Receive;
+ }
pMemInputPinC->lpVtbl->Receive = ReceiveMine;
res = VirtualProtect(pMemInputPinC->lpVtbl, sizeof(IMemInputPinCVtbl), flOldProtect, &flOldProtect);
@@ -278,12 +282,10 @@ 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])
- {
+ if(TCHAR* buff = DNew TCHAR[nCount]) {
FILE* f;
_vstprintf_s(buff, nCount, fmt, args);
- if(_tfopen_s(&f, FileName, _T("at")) == 0)
- {
+ if(_tfopen_s(&f, FileName, _T("at")) == 0) {
fseek(f, 0, 2);
_ftprintf(f, _T("%s\n"), buff);
fclose(f);
@@ -298,12 +300,11 @@ static void LOG(LPCTSTR fmt, ...)
{
va_list args;
va_start(args, fmt);
-// int nCount = _vsctprintf(fmt, args) + 1;
+ // 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)
- {
+ if(_tfopen_s(&f, LOG_FILE, _T("at")) == 0) {
fseek(f, 0, 2);
_ftprintf(f, _T("%s\n"), buff);
fclose(f);
@@ -313,8 +314,7 @@ static void LOG(LPCTSTR fmt, ...)
}
static void LOGPF(LPCTSTR prefix, const DDPIXELFORMAT* p, int n)
{
- for(int i = 0; i < n; i++)
- {
+ 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);
@@ -328,8 +328,7 @@ static void LOGPF(LPCTSTR prefix, const DDPIXELFORMAT* p, int n)
static void LOGUDI(LPCTSTR prefix, const AMVAUncompDataInfo* p, int n)
{
- for(int i = 0; i < n; i++)
- {
+ 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);
@@ -346,8 +345,7 @@ static void LogDXVA_PicParams_H264 (DXVA_PicParams_H264* pPic)
int i;
static bool bFirstParam = true;
- if (bFirstParam)
- {
+ if (bFirstParam) {
LOG_TOFILE (_T("picture.log"), _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],") \
@@ -367,8 +365,8 @@ static void LogDXVA_PicParams_H264 (DXVA_PicParams_H264* pPic)
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.AssociatedFlag);
+ // strRes.AppendFormat(_T("%d,"), pPic->CurrPic.bPicEntry);
strRes.AppendFormat(_T("%d,"), pPic->CurrPic.Index7Bits);
@@ -380,18 +378,18 @@ static void LogDXVA_PicParams_H264 (DXVA_PicParams_H264* pPic)
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);
+ 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++)
+ 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->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 */
@@ -404,10 +402,11 @@ static void LogDXVA_PicParams_H264 (DXVA_PicParams_H264* pPic)
strRes.AppendFormat(_T("%d,"), pPic->num_ref_idx_l1_active_minus1);
strRes.AppendFormat(_T("%d,"), pPic->Reserved8BitsA);
- for (int i=0; i<16; i++)
+ 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->FrameNumList[16]);
strRes.AppendFormat(_T("%d,"), pPic->UsedForReferenceFlags);
strRes.AppendFormat(_T("%d,"), pPic->NonExistingFrameFlags);
strRes.AppendFormat(_T("%d,"), pPic->frame_num);
@@ -431,16 +430,16 @@ static void LogDXVA_PicParams_H264 (DXVA_PicParams_H264* pPic)
//for (int i=0; i<810; i++)
// strRes.AppendFormat(_T("%d,"), pPic->SliceGroupMap[i]);
-// strRes.AppendFormat(_T("%d,"), pPic->SliceGroupMap[810]);
+ // 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;
-//}
+ //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;
@@ -458,16 +457,14 @@ static void LogH264SliceShort (DXVA_Slice_H264_Short* pSlice, int nCount)
CString strRes;
static bool bFirstSlice = true;
- if (bFirstSlice)
- {
+ if (bFirstSlice) {
strRes = _T("nCnt, BSNALunitDataLocation, SliceBytesInBuffer, wBadSliceChopping");
LOG_TOFILE (_T("sliceshort.log"), strRes);
strRes = "";
bFirstSlice = false;
}
- for (int i=0; i<nCount; i++)
- {
+ 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);
@@ -483,8 +480,7 @@ static void LogSliceInfo (DXVA_SliceInfo* pSlice, int nCount)
CString strRes;
static bool bFirstSlice = true;
- if (bFirstSlice)
- {
+ if (bFirstSlice) {
strRes = _T("nCnt, wHorizontalPosition, wVerticalPosition, dwSliceBitsInBuffer,dwSliceDataLocation, bStartCodeBitOffset, bReservedBits, wMBbitOffset, wNumberMBsInSlice, wQuantizerScaleCode, wBadSliceChopping");
LOG_TOFILE (_T("sliceshort.log"), strRes);
@@ -492,8 +488,7 @@ static void LogSliceInfo (DXVA_SliceInfo* pSlice, int nCount)
bFirstSlice = false;
}
- for (int i=0; i<nCount; i++)
- {
+ 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);
@@ -516,32 +511,25 @@ static void LogH264SliceLong (DXVA_Slice_H264_Long* pSlice, int nCount)
static bool bFirstSlice = true;
CString strRes;
- if (bFirstSlice)
- {
+ 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++)
- {
+ 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++)
- {
+ 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);
}
}
@@ -554,8 +542,7 @@ static void LogH264SliceLong (DXVA_Slice_H264_Long* pSlice, int nCount)
}
bFirstSlice = false;
- for (int i=0; i<nCount; i++)
- {
+ 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);
@@ -584,24 +571,18 @@ static void LogH264SliceLong (DXVA_Slice_H264_Long* pSlice, int nCount)
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++)
- {
+ 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++)
- {
+ 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]);
}
}
@@ -618,8 +599,9 @@ static void LogDXVA_PictureParameters (DXVA_PictureParameters* pPic)
static bool bFirstPictureParam = true;
CString strRes;
- if (bFirstPictureParam)
+ if (bFirstPictureParam) {
LOG_TOFILE (_T("picture.log"), _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"),
@@ -668,27 +650,28 @@ void LogDXVA_Bitstream(BYTE* pBuffer, int nSize)
CString strRes;
static bool bFirstBitstream = true;
- if (bFirstBitstream)
+ if (bFirstBitstream) {
LOG_TOFILE (_T("bitstream.log"), _T("Size,Start, Stop"));
+ }
bFirstBitstream = false;
strRes.Format (_T("%d, -"), nSize);
- for (int i=0; i<20; i++)
- {
- if (i < nSize)
+ for (int i=0; i<20; i++) {
+ if (i < nSize) {
strRes.AppendFormat (_T(" %02x"), pBuffer[i]);
- else
+ } else {
strRes.Append(_T(" --"));
+ }
}
strRes.Append (_T(", -"), nSize);
- for (int i=0; i<20; i++)
- {
- if (nSize-i >= 0)
+ for (int i=0; i<20; i++) {
+ if (nSize-i >= 0) {
strRes.AppendFormat (_T(" %02x"), pBuffer[i]);
- else
+ } else {
strRes.Append(_T(" --"));
+ }
}
LOG_TOFILE (_T("bitstream.log"), strRes);
@@ -710,8 +693,7 @@ static HRESULT STDMETHODCALLTYPE GetVideoAcceleratorGUIDsMine(IAMVideoAccelerato
{
LOG(_T("\nGetVideoAcceleratorGUIDs"));
- if(pdwNumGuidsSupported)
- {
+ if(pdwNumGuidsSupported) {
LOG(_T("[in] *pdwNumGuidsSupported = %d"), *pdwNumGuidsSupported);
}
@@ -719,14 +701,11 @@ static HRESULT STDMETHODCALLTYPE GetVideoAcceleratorGUIDsMine(IAMVideoAccelerato
LOG(_T("hr = %08x"), hr);
- if(pdwNumGuidsSupported)
- {
+ if(pdwNumGuidsSupported) {
LOG(_T("[out] *pdwNumGuidsSupported = %d"), *pdwNumGuidsSupported);
- if(pGuidsSupported)
- {
- for(DWORD i = 0; i < *pdwNumGuidsSupported; i++)
- {
+ if(pGuidsSupported) {
+ for(DWORD i = 0; i < *pdwNumGuidsSupported; i++) {
LOG(_T("[out] pGuidsSupported[%d] = %s"), i, CStringFromGUID(pGuidsSupported[i]));
}
}
@@ -739,13 +718,11 @@ static HRESULT STDMETHODCALLTYPE GetUncompFormatsSupportedMine(IAMVideoAccelerat
{
LOG(_T("\nGetUncompFormatsSupported"));
- if(pGuid)
- {
+ if(pGuid) {
LOG(_T("[in] *pGuid = %s"), CStringFromGUID(*pGuid));
}
- if(pdwNumFormatsSupported)
- {
+ if(pdwNumFormatsSupported) {
LOG(_T("[in] *pdwNumFormatsSupported = %d"), *pdwNumFormatsSupported);
}
@@ -753,12 +730,10 @@ static HRESULT STDMETHODCALLTYPE GetUncompFormatsSupportedMine(IAMVideoAccelerat
LOG(_T("hr = %08x"), hr);
- if(pdwNumFormatsSupported)
- {
+ if(pdwNumFormatsSupported) {
LOG(_T("[out] *pdwNumFormatsSupported = %d"), *pdwNumFormatsSupported);
- if(pFormatsSupported)
- {
+ if(pFormatsSupported) {
LOGPF(_T("[out] pFormatsSupported"), pFormatsSupported, *pdwNumFormatsSupported);
}
}
@@ -781,14 +756,12 @@ static HRESULT STDMETHODCALLTYPE GetCompBufferInfoMine(IAMVideoAcceleratorC * Th
{
LOG(_T("\nGetCompBufferInfo"));
- if(pGuid)
- {
+ if(pGuid) {
g_guidDXVADecoder = *pGuid;
g_nDXVAVersion = 1;
LOG(_T("[in] *pGuid = %s"), CStringFromGUID(*pGuid));
- if(pdwNumTypesCompBuffers)
- {
+ if(pdwNumTypesCompBuffers) {
LOG(_T("[in] *pdwNumTypesCompBuffers = %d"), *pdwNumTypesCompBuffers);
}
}
@@ -825,16 +798,14 @@ static HRESULT STDMETHODCALLTYPE BeginFrameMine(IAMVideoAcceleratorC * This, con
{
LOG(_T("\nBeginFrame"));
- if(amvaBeginFrameInfo)
- {
+ 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))
- {
+ if(amvaBeginFrameInfo && (amvaBeginFrameInfo->dwSizeInputData == 4)) {
LOG(_T("[in] amvaBeginFrameInfo->pInputData => dwDestSurfaceIndex = %ld "),
((DWORD*)amvaBeginFrameInfo->pInputData)[0]);
}
@@ -851,8 +822,7 @@ static HRESULT STDMETHODCALLTYPE EndFrameMine(IAMVideoAcceleratorC * This, const
{
LOG(_T("\nEndFrame"));
- if(pEndFrameInfo)
- {
+ if(pEndFrameInfo) {
LOG(_T("[in] pEndFrameInfo->dwSizeMiscData = %08x"), pEndFrameInfo->dwSizeMiscData);
LOG(_T("[in] pEndFrameInfo->pMiscData = %08x"), pEndFrameInfo->pMiscData);
@@ -912,14 +882,11 @@ static HRESULT STDMETHODCALLTYPE ExecuteMine(IAMVideoAcceleratorC* This, DWORD d
#ifdef _DEBUG
LOG(_T("\nExecute"));
LOG(_T("[in] dwFunction = %08x"), dwFunction);
- if(lpPrivateInputData)
- {
- if (dwFunction == 0x01000000)
- {
+ if(lpPrivateInputData) {
+ if (dwFunction == 0x01000000) {
DXVA_BufferDescription* pBuffDesc = (DXVA_BufferDescription*)lpPrivateInputData;
- for (DWORD i=0; i<dwNumBuffers; i++)
- {
+ 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);
@@ -932,9 +899,7 @@ static HRESULT STDMETHODCALLTYPE ExecuteMine(IAMVideoAcceleratorC* This, DWORD d
LOG(_T(" pBuffDesc->dwNumMBsInBuffer = %d"), pBuffDesc[i].dwNumMBsInBuffer);
LOG(_T(" pBuffDesc->dwReservedBits = %d"), pBuffDesc[i].dwReservedBits);
}
- }
- else if ((dwFunction == 0xfffff101) || (dwFunction == 0xfffff501))
- {
+ } 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);
@@ -953,8 +918,7 @@ static HRESULT STDMETHODCALLTYPE ExecuteMine(IAMVideoAcceleratorC* This, DWORD d
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
+ } else
LOG(_T("[in] lpPrivateInputData = %02x %02x %02x %02x ..."),
((BYTE*)lpPrivateInputData)[0],
((BYTE*)lpPrivateInputData)[1],
@@ -965,10 +929,8 @@ static HRESULT STDMETHODCALLTYPE ExecuteMine(IAMVideoAcceleratorC* This, DWORD d
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++)
- {
+ 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);
@@ -978,27 +940,21 @@ static HRESULT STDMETHODCALLTYPE ExecuteMine(IAMVideoAcceleratorC* This, DWORD d
}
- 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)
+ 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)
+ } else if (g_guidDXVADecoder == DXVA2_ModeVC1_D) {
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++)
- {
+ }
+ } 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)
- {
+ } else if (pamvaBufferInfo[i].dwTypeIndex == DXVA_BITSTREAM_DATA_BUFFER) {
LogDXVA_Bitstream(g_ppBuffer[pamvaBufferInfo[i].dwTypeIndex], pamvaBufferInfo[i].dwDataSize);
#if defined(LOG_BITSTREAM) && defined(_DEBUG)
@@ -1006,8 +962,7 @@ static HRESULT STDMETHODCALLTYPE ExecuteMine(IAMVideoAcceleratorC* This, DWORD d
static int nNb = 1;
sprintf (strFile, "BitStream%d.bin", nNb++);
FILE* hFile = fopen (strFile, "wb");
- if (hFile)
- {
+ if (hFile) {
fwrite (g_ppBuffer[pamvaBufferInfo[i].dwTypeIndex],
1,
pamvaBufferInfo[i].dwDataSize,
@@ -1023,8 +978,7 @@ static HRESULT STDMETHODCALLTYPE ExecuteMine(IAMVideoAcceleratorC* This, DWORD d
LOG(_T("hr = %08x"), hr);
- if(lpPrivateOutputData && (dwFunction == 0x01000000))
- {
+ if(lpPrivateOutputData && (dwFunction == 0x01000000)) {
LOG(_T("[out] *lpPrivateOutputData : Result = %08x"), ((DWORD*)lpPrivateOutputData)[0]);
}
@@ -1060,18 +1014,42 @@ void HookAMVideoAccelerator(IAMVideoAcceleratorC* pAMVideoAcceleratorC)
g_guidDXVADecoder = GUID_NULL;
g_nDXVAVersion = 0;
- if(GetVideoAcceleratorGUIDsOrg == NULL) GetVideoAcceleratorGUIDsOrg = pAMVideoAcceleratorC->lpVtbl->GetVideoAcceleratorGUIDs;
- if(GetUncompFormatsSupportedOrg == NULL) GetUncompFormatsSupportedOrg = pAMVideoAcceleratorC->lpVtbl->GetUncompFormatsSupported;
- if(GetInternalMemInfoOrg == NULL) GetInternalMemInfoOrg = pAMVideoAcceleratorC->lpVtbl->GetInternalMemInfo;
- if(GetCompBufferInfoOrg == NULL) GetCompBufferInfoOrg = pAMVideoAcceleratorC->lpVtbl->GetCompBufferInfo;
- 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;
+ if(GetVideoAcceleratorGUIDsOrg == NULL) {
+ GetVideoAcceleratorGUIDsOrg = pAMVideoAcceleratorC->lpVtbl->GetVideoAcceleratorGUIDs;
+ }
+ if(GetUncompFormatsSupportedOrg == NULL) {
+ GetUncompFormatsSupportedOrg = pAMVideoAcceleratorC->lpVtbl->GetUncompFormatsSupported;
+ }
+ if(GetInternalMemInfoOrg == NULL) {
+ GetInternalMemInfoOrg = pAMVideoAcceleratorC->lpVtbl->GetInternalMemInfo;
+ }
+ if(GetCompBufferInfoOrg == NULL) {
+ GetCompBufferInfoOrg = pAMVideoAcceleratorC->lpVtbl->GetCompBufferInfo;
+ }
+ 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;
@@ -1125,81 +1103,70 @@ private :
UINT m_ppBufferLen[MAX_BUFFER_TYPE];
public :
- CFakeDirectXVideoDecoder(LPUNKNOWN pUnk, IDirectXVideoDecoder* pDec) : CUnknown(_T("Fake DXVA2 Dec"), pUnk)
- {
+ CFakeDirectXVideoDecoder(LPUNKNOWN pUnk, IDirectXVideoDecoder* pDec) : CUnknown(_T("Fake DXVA2 Dec"), pUnk) {
m_pDec.Attach (pDec);
memset (m_ppBuffer, 0, sizeof(m_ppBuffer));
}
- ~CFakeDirectXVideoDecoder()
- {
+ ~CFakeDirectXVideoDecoder() {
LOG(_T("CFakeDirectXVideoDecoder destroyed !\n"));
}
DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv)
- {
- if(riid == __uuidof(IDirectXVideoDecoder))
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv) {
+ if(riid == __uuidof(IDirectXVideoDecoder)) {
return GetInterface((IDirectXVideoDecoder*)this, ppv);
- else
+ } else {
return __super::NonDelegatingQueryInterface(riid, ppv);
+ }
}
- virtual HRESULT STDMETHODCALLTYPE GetVideoDecoderService(IDirectXVideoDecoderService **ppService)
- {
+ 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)
- {
+ 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)
- {
+ virtual HRESULT STDMETHODCALLTYPE GetBuffer(UINT BufferType, void **ppBuffer, UINT *pBufferSize) {
HRESULT hr = m_pDec->GetBuffer(BufferType, ppBuffer, pBufferSize);
- if (BufferType < MAX_BUFFER_TYPE)
- {
+ if (BufferType < MAX_BUFFER_TYPE) {
m_ppBuffer[BufferType] = (BYTE*)*ppBuffer;
m_ppBufferLen[BufferType] = *pBufferSize;
}
-// LOG(_T("IDirectXVideoDecoder::GetBuffer Type = %d, hr = %08x"), BufferType, hr);
+ // LOG(_T("IDirectXVideoDecoder::GetBuffer Type = %d, hr = %08x"), BufferType, hr);
return hr;
}
- virtual HRESULT STDMETHODCALLTYPE ReleaseBuffer(UINT BufferType)
- {
+ virtual HRESULT STDMETHODCALLTYPE ReleaseBuffer(UINT BufferType) {
HRESULT hr = m_pDec->ReleaseBuffer (BufferType);
-// LOG(_T("IDirectXVideoDecoder::ReleaseBuffer Type = %d, hr = %08x"), BufferType, hr);
+ // LOG(_T("IDirectXVideoDecoder::ReleaseBuffer Type = %d, hr = %08x"), BufferType, hr);
return hr;
}
- virtual HRESULT STDMETHODCALLTYPE BeginFrame(IDirect3DSurface9 *pRenderTarget, void *pvPVPData)
- {
+ 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)
- {
+ 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)
- {
- for (DWORD i=0; i<pExecuteParams->NumCompBuffers; i++)
- {
+ virtual HRESULT STDMETHODCALLTYPE Execute(const DXVA2_DecodeExecuteParams *pExecuteParams) {
+ for (DWORD i=0; i<pExecuteParams->NumCompBuffers; i++) {
CString strBuffer;
LogDecodeBufferDesc (&pExecuteParams->pCompressedBuffers[i]);
@@ -1214,35 +1181,27 @@ public :
LOG (strBuffer);*/
- if (pExecuteParams->pCompressedBuffers[i].CompressedBufferType == DXVA2_PictureParametersBufferType)
- {
- if (g_guidDXVADecoder == DXVA2_ModeH264_E || g_guidDXVADecoder == DXVA_Intel_H264_ClearVideo)
+ 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)
+ } else if (g_guidDXVADecoder == DXVA2_ModeVC1_D || g_guidDXVADecoder == DXVA2_ModeMPEG2_VLD) {
LogDXVA_PictureParameters((DXVA_PictureParameters*)m_ppBuffer[pExecuteParams->pCompressedBuffers[i].CompressedBufferType]);
+ }
}
#if defined(_DEBUG)
- 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)
- {
+ 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)
- {
+ } 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_ModeMPEG2_VLD)
- {
- if (pExecuteParams->pCompressedBuffers[i].CompressedBufferType == DXVA2_SliceControlBufferType)
- {
+ } else if (g_guidDXVADecoder == DXVA2_ModeMPEG2_VLD) {
+ 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));
}
@@ -1250,14 +1209,12 @@ public :
#endif
#if defined(LOG_MATRIX) && defined(_DEBUG)
- if (pExecuteParams->pCompressedBuffers[i].CompressedBufferType == DXVA2_InverseQuantizationMatrixBufferType)
- {
+ if (pExecuteParams->pCompressedBuffers[i].CompressedBufferType == DXVA2_InverseQuantizationMatrixBufferType) {
char strFile[_MAX_PATH];
static int nNb = 1;
sprintf (strFile, "Matrix%d.bin", nNb++);
FILE* hFile = fopen (strFile, "wb");
- if (hFile)
- {
+ if (hFile) {
fwrite (m_ppBuffer[pExecuteParams->pCompressedBuffers[i].CompressedBufferType],
1,
pExecuteParams->pCompressedBuffers[i].DataSize,
@@ -1268,16 +1225,14 @@ public :
#endif
#if defined(_DEBUG)
- if (pExecuteParams->pCompressedBuffers[i].CompressedBufferType == DXVA2_BitStreamDateBufferType)
- {
+ if (pExecuteParams->pCompressedBuffers[i].CompressedBufferType == DXVA2_BitStreamDateBufferType) {
LogDXVA_Bitstream(m_ppBuffer[pExecuteParams->pCompressedBuffers[i].CompressedBufferType], pExecuteParams->pCompressedBuffers[i].DataSize);
#if defined(LOG_BITSTREAM)
char strFile[_MAX_PATH];
static int nNb = 1;
sprintf (strFile, "BitStream%d.bin", nNb++);
FILE* hFile = fopen (strFile, "wb");
- if (hFile)
- {
+ if (hFile) {
fwrite (m_ppBuffer[pExecuteParams->pCompressedBuffers[i].CompressedBufferType],
1,
pExecuteParams->pCompressedBuffers[i].DataSize,
@@ -1298,16 +1253,16 @@ public :
pExecuteParams->pExtensionData->PrivateInputDataSize,
pExecuteParams->pExtensionData->PrivateOutputDataSize,
hr);
- else
+ else {
LOG(_T("IDirectXVideoDecoder::Execute %d buffer, hr = %08x"), pExecuteParams->NumCompBuffers, hr);
+ }
return hr;
}
};
interface IDirectXVideoDecoderServiceC;
-struct IDirectXVideoDecoderServiceCVtbl
-{
+struct IDirectXVideoDecoderServiceCVtbl {
BEGIN_INTERFACE
HRESULT ( STDMETHODCALLTYPE *QueryInterface )( IDirectXVideoDecoderServiceC* pThis, /* [in] */ REFIID riid, /* [iid_is][out] */ void **ppvObject );
ULONG ( STDMETHODCALLTYPE *AddRef )(IDirectXVideoDecoderServiceC* pThis);
@@ -1345,8 +1300,7 @@ struct IDirectXVideoDecoderServiceCVtbl
END_INTERFACE
};
-interface IDirectXVideoDecoderServiceC
-{
+interface IDirectXVideoDecoderServiceC {
CONST_VTBL struct IDirectXVideoDecoderServiceCVtbl *lpVtbl;
};
@@ -1399,11 +1353,9 @@ static void LogVideoCardCaps(IDirectXVideoDecoderService* pDecoderService)
GUID* pDecoderGuids = NULL;
hr = pDecoderService->GetDecoderDeviceGuids(&cDecoderGuids, &pDecoderGuids);
- if (SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
// Look for the decoder GUIDs we want.
- for (UINT iGuid = 0; iGuid < cDecoderGuids; iGuid++)
- {
+ for (UINT iGuid = 0; iGuid < cDecoderGuids; iGuid++) {
LOG (_T("=== New mode : %s"), GetDXVAMode (&pDecoderGuids[iGuid]));
// Find a configuration that we support.
@@ -1415,11 +1367,9 @@ static void LogVideoCardCaps(IDirectXVideoDecoderService* pDecoderService)
hr = pDecoderService->GetDecoderRenderTargets(pDecoderGuids[iGuid], &cFormats, &pFormats);
- if (SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
// Look for a format that matches our output format.
- for (UINT iFormat = 0; iFormat < cFormats; iFormat++)
- {
+ 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));
@@ -1430,12 +1380,10 @@ static void LogVideoCardCaps(IDirectXVideoDecoderService* pDecoderService)
// Get the available configurations.
hr = pDecoderService->GetDecoderConfigurations(pDecoderGuids[iGuid], &m_VideoDesc, NULL, &cConfigurations, &pConfig);
- if (SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
// Find a supported configuration.
- for (UINT iConfig = 0; iConfig < cConfigurations; iConfig++)
- {
+ for (UINT iConfig = 0; iConfig < cConfigurations; iConfig++) {
LogDXVA2Config (&pConfig[iConfig]);
}
@@ -1459,8 +1407,8 @@ static HRESULT STDMETHODCALLTYPE CreateVideoDecoderMine(
__in UINT NumRenderTargets,
__deref_out IDirectXVideoDecoder** ppDecode)
{
-// DebugBreak();
-// ((DXVA2_VideoDesc*)pVideoDesc)->Format = (D3DFORMAT)0x3231564E;
+ // DebugBreak();
+ // ((DXVA2_VideoDesc*)pVideoDesc)->Format = (D3DFORMAT)0x3231564E;
g_guidDXVADecoder = Guid;
g_nDXVAVersion = 2;
@@ -1473,22 +1421,21 @@ static HRESULT STDMETHODCALLTYPE CreateVideoDecoderMine(
HRESULT hr = CreateVideoDecoderOrg(pThis, Guid, pVideoDesc, pConfig, ppDecoderRenderTargets, NumRenderTargets, ppDecode);
- if (FAILED (hr))
+ if (FAILED (hr)) {
g_guidDXVADecoder = GUID_NULL;
- else
- {
+ } else {
#ifdef _DEBUG
if ((Guid == DXVA2_ModeH264_E) ||
(Guid == DXVA2_ModeVC1_D) ||
(Guid == DXVA_Intel_H264_ClearVideo) ||
- (Guid == DXVA2_ModeMPEG2_VLD))
- {
+ (Guid == DXVA2_ModeMPEG2_VLD)) {
*ppDecode = DNew CFakeDirectXVideoDecoder (NULL, *ppDecode);
(*ppDecode)->AddRef();
}
- for (DWORD i=0; i<NumRenderTargets; i++)
+ for (DWORD i=0; i<NumRenderTargets; i++) {
LOG(_T(" - Surf %d : %08x"), i, ppDecoderRenderTargets[i]);
+ }
#endif
}
@@ -1519,7 +1466,7 @@ static HRESULT STDMETHODCALLTYPE GetDecoderConfigurationsMine (IDirectXVideoDeco
HRESULT hr = GetDecoderConfigurationsOrg(pThis, Guid, pVideoDesc, pReserved, pCount, ppConfigs);
// Force LongSlice decoding !
-// memcpy (&(*ppConfigs)[1], &(*ppConfigs)[0], sizeof(DXVA2_ConfigPictureDecode));
+ // memcpy (&(*ppConfigs)[1], &(*ppConfigs)[0], sizeof(DXVA2_ConfigPictureDecode));
return hr;
}
@@ -1532,15 +1479,16 @@ void HookDirectXVideoDecoderService(void* pIDirectXVideoDecoderService)
DWORD flOldProtect = 0;
// Casimir666 : unhook previous VTables
- if (g_pIDirectXVideoDecoderServiceCVtbl)
- {
+ if (g_pIDirectXVideoDecoderServiceCVtbl) {
res = VirtualProtect(g_pIDirectXVideoDecoderServiceCVtbl, sizeof(g_pIDirectXVideoDecoderServiceCVtbl), PAGE_WRITECOPY, &flOldProtect);
- if (g_pIDirectXVideoDecoderServiceCVtbl->CreateVideoDecoder == CreateVideoDecoderMine)
+ if (g_pIDirectXVideoDecoderServiceCVtbl->CreateVideoDecoder == CreateVideoDecoderMine) {
g_pIDirectXVideoDecoderServiceCVtbl->CreateVideoDecoder = CreateVideoDecoderOrg;
+ }
#ifdef _DEBUG
- if (g_pIDirectXVideoDecoderServiceCVtbl->GetDecoderConfigurations == GetDecoderConfigurationsMine)
+ if (g_pIDirectXVideoDecoderServiceCVtbl->GetDecoderConfigurations == GetDecoderConfigurationsMine) {
g_pIDirectXVideoDecoderServiceCVtbl->GetDecoderConfigurations = GetDecoderConfigurationsOrg;
+ }
//if (g_pIDirectXVideoDecoderServiceCVtbl->GetDecoderDeviceGuids == GetDecoderDeviceGuidsMine)
// g_pIDirectXVideoDecoderServiceCVtbl->GetDecoderDeviceGuids = GetDecoderDeviceGuidsOrg;
@@ -1562,8 +1510,7 @@ void HookDirectXVideoDecoderService(void* pIDirectXVideoDecoderService)
::DeleteFile (_T("slicelong.log"));
#endif
- if (pIDirectXVideoDecoderService)
- {
+ if (pIDirectXVideoDecoderService) {
res = VirtualProtect(pIDirectXVideoDecoderServiceC->lpVtbl, sizeof(IDirectXVideoDecoderServiceCVtbl), PAGE_WRITECOPY, &flOldProtect);
CreateVideoDecoderOrg = pIDirectXVideoDecoderServiceC->lpVtbl->CreateVideoDecoder;
diff --git a/src/filters/renderer/VideoRenderers/IPinHook.h b/src/filters/renderer/VideoRenderers/IPinHook.h
index fb919f57e..406a4efcb 100644
--- a/src/filters/renderer/VideoRenderers/IPinHook.h
+++ b/src/filters/renderer/VideoRenderers/IPinHook.h
@@ -25,8 +25,7 @@
interface IPinC;
-typedef struct IPinCVtbl
-{
+typedef struct IPinCVtbl {
BEGIN_INTERFACE
HRESULT ( STDMETHODCALLTYPE *QueryInterface )( IPinC * This, /* [in] */ REFIID riid, /* [iid_is][out] */ void **ppvObject );
ULONG ( STDMETHODCALLTYPE *AddRef )( IPinC * This );
@@ -49,15 +48,13 @@ typedef struct IPinCVtbl
END_INTERFACE
} IPinCVtbl;
-interface IPinC
-{
+interface IPinC {
CONST_VTBL struct IPinCVtbl *lpVtbl;
};
interface IMemInputPinC;
-typedef struct IMemInputPinCVtbl
-{
+typedef struct IMemInputPinCVtbl {
BEGIN_INTERFACE
HRESULT ( STDMETHODCALLTYPE *QueryInterface )( IPinC * This, /* [in] */ REFIID riid, /* [iid_is][out] */ void **ppvObject );
ULONG ( STDMETHODCALLTYPE *AddRef )( IPinC * This );
@@ -71,8 +68,7 @@ typedef struct IMemInputPinCVtbl
END_INTERFACE
} IMemInputPinCVtbl;
-interface IMemInputPinC
-{
+interface IMemInputPinC {
CONST_VTBL struct IMemInputPinCVtbl *lpVtbl;
};
@@ -86,8 +82,7 @@ extern REFERENCE_TIME g_tSegmentStart, g_tSampleStart, g_rtTimePerFrame;
interface IAMVideoAcceleratorC;
-typedef struct IAMVideoAcceleratorCVtbl
-{
+typedef struct IAMVideoAcceleratorCVtbl {
BEGIN_INTERFACE
HRESULT ( STDMETHODCALLTYPE *QueryInterface )(
@@ -175,8 +170,7 @@ typedef struct IAMVideoAcceleratorCVtbl
END_INTERFACE
} IAMVideoAcceleratorCVtbl;
-interface IAMVideoAcceleratorC
-{
+interface IAMVideoAcceleratorC {
CONST_VTBL struct IAMVideoAcceleratorCVtbl *lpVtbl;
};
diff --git a/src/filters/renderer/VideoRenderers/IQTVideoSurface.h b/src/filters/renderer/VideoRenderers/IQTVideoSurface.h
index aeb2b8ad8..e6a186ce8 100644
--- a/src/filters/renderer/VideoRenderers/IQTVideoSurface.h
+++ b/src/filters/renderer/VideoRenderers/IQTVideoSurface.h
@@ -29,8 +29,7 @@
interface __declspec(uuid("A6AE36F7-A6F2-4157-AF54-6599857E4E20"))
IQTVideoSurface :
-public IUnknown
-{
+public IUnknown {
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 68bf107b5..4fd82c1f4 100644
--- a/src/filters/renderer/VideoRenderers/MacrovisionKicker.cpp
+++ b/src/filters/renderer/VideoRenderers/MacrovisionKicker.cpp
@@ -45,10 +45,12 @@ void CMacrovisionKicker::SetInner(IUnknown* pUnk)
STDMETHODIMP CMacrovisionKicker::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- if(riid == __uuidof(IUnknown))
+ if(riid == __uuidof(IUnknown)) {
return __super::NonDelegatingQueryInterface(riid, ppv);
- if(riid == __uuidof(IKsPropertySet) && CComQIPtr<IKsPropertySet>(m_pInner))
+ }
+ if(riid == __uuidof(IKsPropertySet) && CComQIPtr<IKsPropertySet>(m_pInner)) {
return GetInterface((IKsPropertySet*)this, ppv);
+ }
HRESULT hr = m_pInner ? m_pInner->QueryInterface(riid, ppv) : E_NOINTERFACE;
@@ -59,11 +61,9 @@ STDMETHODIMP CMacrovisionKicker::NonDelegatingQueryInterface(REFIID riid, void**
STDMETHODIMP CMacrovisionKicker::Set(REFGUID PropSet, ULONG Id, LPVOID pInstanceData, ULONG InstanceLength, LPVOID pPropertyData, ULONG DataLength)
{
- if(CComQIPtr<IKsPropertySet> pKsPS = m_pInner)
- {
+ if(CComQIPtr<IKsPropertySet> pKsPS = m_pInner) {
if(PropSet == AM_KSPROPSETID_CopyProt && Id == AM_PROPERTY_COPY_MACROVISION
- /*&& DataLength == 4 && *(DWORD*)pPropertyData*/)
- {
+ /*&& DataLength == 4 && *(DWORD*)pPropertyData*/) {
TRACE(_T("Oops, no-no-no, no macrovision please\n"));
return S_OK;
}
@@ -76,8 +76,7 @@ STDMETHODIMP CMacrovisionKicker::Set(REFGUID PropSet, ULONG Id, LPVOID pInstance
STDMETHODIMP CMacrovisionKicker::Get(REFGUID PropSet, ULONG Id, LPVOID pInstanceData, ULONG InstanceLength, LPVOID pPropertyData, ULONG DataLength, ULONG* pBytesReturned)
{
- if(CComQIPtr<IKsPropertySet> pKsPS = m_pInner)
- {
+ if(CComQIPtr<IKsPropertySet> pKsPS = m_pInner) {
return pKsPS->Get(PropSet, Id, pInstanceData, InstanceLength, pPropertyData, DataLength, pBytesReturned);
}
@@ -86,8 +85,7 @@ STDMETHODIMP CMacrovisionKicker::Get(REFGUID PropSet, ULONG Id, LPVOID pInstance
STDMETHODIMP CMacrovisionKicker::QuerySupported(REFGUID PropSet, ULONG Id, ULONG* pTypeSupport)
{
- if(CComQIPtr<IKsPropertySet> pKsPS = m_pInner)
- {
+ if(CComQIPtr<IKsPropertySet> pKsPS = m_pInner) {
return pKsPS->QuerySupported(PropSet, Id, pTypeSupport);
}
diff --git a/src/filters/renderer/VideoRenderers/PixelShaderCompiler.cpp b/src/filters/renderer/VideoRenderers/PixelShaderCompiler.cpp
index 97b02fe56..b8813b4ea 100644
--- a/src/filters/renderer/VideoRenderers/PixelShaderCompiler.cpp
+++ b/src/filters/renderer/VideoRenderers/PixelShaderCompiler.cpp
@@ -35,20 +35,15 @@ CPixelShaderCompiler::CPixelShaderCompiler(IDirect3DDevice9* pD3DDev, bool fStay
HINSTANCE hDll;
hDll = GetRenderersData()->GetD3X9Dll();
- if(hDll)
- {
+ if(hDll) {
m_pD3DXCompileShader = (D3DXCompileShaderPtr)GetProcAddress(hDll, "D3DXCompileShader");
m_pD3DXDisassembleShader = (D3DXDisassembleShaderPtr)GetProcAddress(hDll, "D3DXDisassembleShader");
}
- if(!fStaySilent)
- {
- if(!hDll)
- {
+ if(!fStaySilent) {
+ if(!hDll) {
AfxMessageBox(ResStr(IDS_PIXELSHADERCOMPILER_0), MB_OK);
- }
- else if(!m_pD3DXCompileShader || !m_pD3DXDisassembleShader)
- {
+ } else if(!m_pD3DXCompileShader || !m_pD3DXDisassembleShader) {
AfxMessageBox(ResStr(IDS_PIXELSHADERCOMPILER_1), MB_OK);
}
}
@@ -67,22 +62,20 @@ HRESULT CPixelShaderCompiler::CompileShader(
CString* disasm,
CString* errmsg)
{
- if(!m_pD3DXCompileShader || !m_pD3DXDisassembleShader)
+ if(!m_pD3DXCompileShader || !m_pD3DXDisassembleShader) {
return E_FAIL;
+ }
HRESULT hr;
CComPtr<ID3DXBuffer> pShader, pDisAsm, pErrorMsgs;
hr = m_pD3DXCompileShader(pSrcData, strlen(pSrcData), NULL, NULL, pFunctionName, pProfile, Flags, &pShader, &pErrorMsgs, NULL);
- if(FAILED(hr))
- {
- if(errmsg)
- {
+ if(FAILED(hr)) {
+ if(errmsg) {
CStringA msg = "Unexpected compiler error";
- if(pErrorMsgs)
- {
+ if(pErrorMsgs) {
int len = pErrorMsgs->GetBufferSize();
memcpy(msg.GetBufferSetLength(len), pErrorMsgs->GetBufferPointer(), len);
}
@@ -93,17 +86,21 @@ HRESULT CPixelShaderCompiler::CompileShader(
return hr;
}
- if(ppPixelShader)
- {
- if(!m_pD3DDev) return E_FAIL;
+ if(ppPixelShader) {
+ if(!m_pD3DDev) {
+ return E_FAIL;
+ }
hr = m_pD3DDev->CreatePixelShader((DWORD*)pShader->GetBufferPointer(), ppPixelShader);
- if(FAILED(hr)) return hr;
+ if(FAILED(hr)) {
+ return hr;
+ }
}
- if(disasm)
- {
+ if(disasm) {
hr = m_pD3DXDisassembleShader((DWORD*)pShader->GetBufferPointer(), FALSE, NULL, &pDisAsm);
- if(SUCCEEDED(hr) && pDisAsm) *disasm = CStringA((const char*)pDisAsm->GetBufferPointer());
+ if(SUCCEEDED(hr) && pDisAsm) {
+ *disasm = CStringA((const char*)pDisAsm->GetBufferPointer());
+ }
}
return S_OK;
diff --git a/src/filters/renderer/VideoRenderers/QT7AllocatorPresenter.cpp b/src/filters/renderer/VideoRenderers/QT7AllocatorPresenter.cpp
index dc2e562d3..de1099997 100644
--- a/src/filters/renderer/VideoRenderers/QT7AllocatorPresenter.cpp
+++ b/src/filters/renderer/VideoRenderers/QT7AllocatorPresenter.cpp
@@ -65,7 +65,9 @@ HRESULT CQT7AllocatorPresenter::AllocSurfaces()
ddsd.ddpfPixelFormat.dwBBitMask = 0x000000FF;
HRESULT hr = m_pDD->CreateSurface(&ddsd, &m_pVideoSurfaceOff, NULL);
- if(FAILED(hr)) return E_FAIL;
+ if(FAILED(hr)) {
+ return E_FAIL;
+ }
DDBLTFX fx;
INITDDSTRUCT(fx);
@@ -95,33 +97,34 @@ STDMETHODIMP CQT7AllocatorPresenter::BeginBlt(const BITMAP& bm)
m_NativeVideoSize = m_AspectRatio = CSize(bm.bmWidth, abs(bm.bmHeight));
HRESULT hr;
- if(FAILED(hr = AllocSurfaces()))
+ if(FAILED(hr = AllocSurfaces())) {
return hr;
+ }
return S_OK;
}
STDMETHODIMP CQT7AllocatorPresenter::DoBlt(const BITMAP& bm)
{
- if(!m_pVideoSurface || !m_pVideoSurfaceOff)
+ if(!m_pVideoSurface || !m_pVideoSurfaceOff) {
return E_FAIL;
+ }
bool fOk = false;
DDSURFACEDESC2 ddsd;
INITDDSTRUCT(ddsd);
- if(FAILED(m_pVideoSurfaceOff->GetSurfaceDesc(&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)
- {
+ 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)))
- {
+ 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,
@@ -131,16 +134,14 @@ STDMETHODIMP CQT7AllocatorPresenter::DoBlt(const BITMAP& bm)
}
}
- if(!fOk)
- {
+ 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)))
- {
+ if(SUCCEEDED(m_pVideoSurfaceOff->GetDC(&hDC))) {
CString str;
str.Format(_T("Sorry, this format is not supported"));
diff --git a/src/filters/renderer/VideoRenderers/QT7AllocatorPresenter.h b/src/filters/renderer/VideoRenderers/QT7AllocatorPresenter.h
index fba500aaf..27c7bd9b9 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 b3ff0f058..ff6fe0f8f 100644
--- a/src/filters/renderer/VideoRenderers/QT9AllocatorPresenter.cpp
+++ b/src/filters/renderer/VideoRenderers/QT9AllocatorPresenter.cpp
@@ -51,8 +51,9 @@ HRESULT CQT9AllocatorPresenter::AllocSurfaces()
if(FAILED(hr = m_pD3DDev->CreateOffscreenPlainSurface(
m_NativeVideoSize.cx, m_NativeVideoSize.cy, D3DFMT_X8R8G8B8,
- D3DPOOL_DEFAULT, &m_pVideoSurfaceOff, NULL)))
+ D3DPOOL_DEFAULT, &m_pVideoSurfaceOff, NULL))) {
return hr;
+ }
return __super::AllocSurfaces();
}
@@ -72,21 +73,25 @@ STDMETHODIMP CQT9AllocatorPresenter::BeginBlt(const BITMAP& bm)
CAutoLock cRenderLock(&m_RenderLock);
DeleteSurfaces();
m_NativeVideoSize = m_AspectRatio = CSize(bm.bmWidth, abs(bm.bmHeight));
- if(FAILED(AllocSurfaces())) return E_FAIL;
+ if(FAILED(AllocSurfaces())) {
+ return E_FAIL;
+ }
return S_OK;
}
STDMETHODIMP CQT9AllocatorPresenter::DoBlt(const BITMAP& bm)
{
- if(!m_pVideoSurface || !m_pVideoSurfaceOff)
+ if(!m_pVideoSurface || !m_pVideoSurfaceOff) {
return E_FAIL;
+ }
bool fOk = false;
D3DSURFACE_DESC d3dsd;
ZeroMemory(&d3dsd, sizeof(d3dsd));
- if(FAILED(m_pVideoSurfaceOff->GetDesc(&d3dsd)))
+ if(FAILED(m_pVideoSurfaceOff->GetDesc(&d3dsd))) {
return E_FAIL;
+ }
UINT w = (UINT)bm.bmWidth;
UINT h = abs(bm.bmHeight);
@@ -95,11 +100,9 @@ STDMETHODIMP CQT9AllocatorPresenter::DoBlt(const BITMAP& bm)
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)
- {
+ if((bpp == 16 || bpp == 24 || bpp == 32) && w == d3dsd.Width && h == d3dsd.Height) {
D3DLOCKED_RECT r;
- if(SUCCEEDED(m_pVideoSurfaceOff->LockRect(&r, NULL, 0)))
- {
+ if(SUCCEEDED(m_pVideoSurfaceOff->LockRect(&r, NULL, 0))) {
BitBltFromRGBToRGB(
w, h,
(BYTE*)r.pBits, r.Pitch, dbpp,
@@ -109,13 +112,11 @@ STDMETHODIMP CQT9AllocatorPresenter::DoBlt(const BITMAP& bm)
}
}
- if(!fOk)
- {
+ if(!fOk) {
m_pD3DDev->ColorFill(m_pVideoSurfaceOff, NULL, 0);
HDC hDC;
- if(SUCCEEDED(m_pVideoSurfaceOff->GetDC(&hDC)))
- {
+ if(SUCCEEDED(m_pVideoSurfaceOff->GetDC(&hDC))) {
CString str;
str.Format(_T("Sorry, this color format is not supported"));
diff --git a/src/filters/renderer/VideoRenderers/QT9AllocatorPresenter.h b/src/filters/renderer/VideoRenderers/QT9AllocatorPresenter.h
index 8fca8b2bc..033a2260f 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 c441d5331..6833d6510 100644
--- a/src/filters/renderer/VideoRenderers/RM7AllocatorPresenter.cpp
+++ b/src/filters/renderer/VideoRenderers/RM7AllocatorPresenter.cpp
@@ -68,7 +68,9 @@ HRESULT CRM7AllocatorPresenter::AllocSurfaces()
ddsd.ddpfPixelFormat.dwBBitMask = 0x000000FF;
HRESULT hr = m_pDD->CreateSurface(&ddsd, &m_pVideoSurfaceOff, NULL);
- if(FAILED(hr)) return E_FAIL;
+ if(FAILED(hr)) {
+ return E_FAIL;
+ }
INITDDSTRUCT(fx);
fx.dwFillColor = 0;
@@ -86,11 +88,11 @@ HRESULT CRM7AllocatorPresenter::AllocSurfaces()
hr = m_pDD->CreateSurface(&ddsd, &m_pVideoSurfaceYUY2, NULL);
- if(FAILED(m_pVideoSurfaceOff->Blt(NULL, m_pVideoSurfaceYUY2, NULL, DDBLT_WAIT, NULL)))
+ if(FAILED(m_pVideoSurfaceOff->Blt(NULL, m_pVideoSurfaceYUY2, NULL, DDBLT_WAIT, NULL))) {
m_pVideoSurfaceYUY2 = NULL;
+ }
- if(m_pVideoSurfaceYUY2)
- {
+ if(m_pVideoSurfaceYUY2) {
INITDDSTRUCT(fx);
fx.dwFillColor = 0x80108010;
m_pVideoSurfaceYUY2->Blt(NULL, NULL, NULL, DDBLT_WAIT|DDBLT_COLORFILL, &fx);
@@ -113,20 +115,21 @@ void CRM7AllocatorPresenter::DeleteSurfaces()
STDMETHODIMP CRM7AllocatorPresenter::Blt(UCHAR* pImageData, RMABitmapInfoHeader* pBitmapInfo, REF(PNxRect) inDestRect, REF(PNxRect) inSrcRect)
{
- if(!m_pVideoSurface || !m_pVideoSurfaceOff)
+ 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())
+ if(src.Width() > dst.Width() || src.Height() > dst.Height()) {
return E_FAIL;
+ }
DDSURFACEDESC2 ddsd;
- if(pBitmapInfo->biCompression == '024I')
- {
+ if(pBitmapInfo->biCompression == '024I') {
DWORD pitch = pBitmapInfo->biWidth;
DWORD size = pitch*abs(pBitmapInfo->biHeight);
@@ -134,29 +137,22 @@ STDMETHODIMP CRM7AllocatorPresenter::Blt(UCHAR* pImageData, RMABitmapInfoHeader*
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)
- {
+ if(m_pVideoSurfaceYUY2) {
INITDDSTRUCT(ddsd);
- if(SUCCEEDED(m_pVideoSurfaceYUY2->Lock(src2, &ddsd, DDLOCK_WAIT|DDLOCK_SURFACEMEMORYPTR|DDLOCK_WRITEONLY, NULL)))
- {
+ 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
- {
+ } else {
INITDDSTRUCT(ddsd);
- if(SUCCEEDED(m_pVideoSurfaceOff->Lock(src2, &ddsd, DDLOCK_WAIT|DDLOCK_SURFACEMEMORYPTR|DDLOCK_WRITEONLY, NULL)))
- {
+ 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')
- {
+ } else if(pBitmapInfo->biCompression == '2YUY') {
DWORD w = pBitmapInfo->biWidth;
DWORD h = abs(pBitmapInfo->biHeight);
DWORD pitch = pBitmapInfo->biWidth*2;
@@ -165,30 +161,23 @@ STDMETHODIMP CRM7AllocatorPresenter::Blt(UCHAR* pImageData, RMABitmapInfoHeader*
BYTE* yvyu = pImageData + src.top*pitch + src.left*2;
- if(m_pVideoSurfaceYUY2)
- {
+ if(m_pVideoSurfaceYUY2) {
INITDDSTRUCT(ddsd);
- if(SUCCEEDED(m_pVideoSurfaceYUY2->Lock(src2, &ddsd, DDLOCK_WAIT|DDLOCK_SURFACEMEMORYPTR|DDLOCK_WRITEONLY, NULL)))
- {
+ 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
- {
+ } else {
INITDDSTRUCT(ddsd);
- if(SUCCEEDED(m_pVideoSurfaceOff->Lock(src2, &ddsd, DDLOCK_WAIT|DDLOCK_SURFACEMEMORYPTR|DDLOCK_WRITEONLY, NULL)))
- {
+ 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')
- {
+ } 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;
@@ -198,11 +187,9 @@ STDMETHODIMP CRM7AllocatorPresenter::Blt(UCHAR* pImageData, RMABitmapInfoHeader*
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)))
- {
+ if(SUCCEEDED(m_pVideoSurfaceOff->Lock(src2, &ddsd, DDLOCK_WAIT|DDLOCK_SURFACEMEMORYPTR|DDLOCK_WRITEONLY, NULL))) {
BYTE* lpSurface = (BYTE*)ddsd.lpSurface;
- if(pBitmapInfo->biHeight > 0)
- {
+ if(pBitmapInfo->biHeight > 0) {
lpSurface += ddsd.lPitch*(src.Height()-1);
ddsd.lPitch = -ddsd.lPitch;
}
@@ -212,16 +199,14 @@ STDMETHODIMP CRM7AllocatorPresenter::Blt(UCHAR* pImageData, RMABitmapInfoHeader*
}
}
- if(!fRGB && !fYUY2)
- {
+ 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)))
- {
+ if(SUCCEEDED(m_pVideoSurfaceOff->GetDC(&hDC))) {
CString str;
str.Format(_T("Sorry, this format is not supported"));
@@ -238,10 +223,12 @@ STDMETHODIMP CRM7AllocatorPresenter::Blt(UCHAR* pImageData, RMABitmapInfoHeader*
HRESULT hr;
- if(fRGB)
+ if(fRGB) {
hr = m_pVideoSurface->Blt(dst, m_pVideoSurfaceOff, src2, DDBLT_WAIT, NULL);
- if(fYUY2)
+ }
+ if(fYUY2) {
hr = m_pVideoSurface->Blt(dst, m_pVideoSurfaceYUY2, src2, DDBLT_WAIT, NULL);
+ }
Paint(true);
@@ -253,7 +240,9 @@ STDMETHODIMP CRM7AllocatorPresenter::BeginOptimizedBlt(RMABitmapInfoHeader* pBit
CAutoLock cAutoLock(this);
DeleteSurfaces();
m_NativeVideoSize = m_AspectRatio = CSize(pBitmapInfo->biWidth, abs(pBitmapInfo->biHeight));
- if(FAILED(AllocSurfaces())) return E_FAIL;
+ if(FAILED(AllocSurfaces())) {
+ return E_FAIL;
+ }
return PNR_NOTIMPL;
}
diff --git a/src/filters/renderer/VideoRenderers/RM7AllocatorPresenter.h b/src/filters/renderer/VideoRenderers/RM7AllocatorPresenter.h
index 6eb927351..3676e4448 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 c965a0284..eb344cdc5 100644
--- a/src/filters/renderer/VideoRenderers/RM9AllocatorPresenter.cpp
+++ b/src/filters/renderer/VideoRenderers/RM9AllocatorPresenter.cpp
@@ -55,18 +55,19 @@ HRESULT CRM9AllocatorPresenter::AllocSurfaces()
if(FAILED(hr = m_pD3DDev->CreateOffscreenPlainSurface(
m_NativeVideoSize.cx, m_NativeVideoSize.cy, D3DFMT_X8R8G8B8,
- D3DPOOL_DEFAULT, &m_pVideoSurfaceOff, NULL)))
+ D3DPOOL_DEFAULT, &m_pVideoSurfaceOff, NULL))) {
return hr;
+ }
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)))
+ D3DPOOL_DEFAULT, &m_pVideoSurfaceYUY2, NULL))) {
m_pVideoSurfaceYUY2 = NULL;
+ }
- if(m_pVideoSurfaceYUY2)
- {
+ if(m_pVideoSurfaceYUY2) {
m_pD3DDev->ColorFill(m_pVideoSurfaceOff, NULL, 0x80108010);
}
@@ -86,27 +87,29 @@ void CRM9AllocatorPresenter::DeleteSurfaces()
STDMETHODIMP CRM9AllocatorPresenter::Blt(UCHAR* pImageData, RMABitmapInfoHeader* pBitmapInfo, REF(PNxRect) inDestRect, REF(PNxRect) inSrcRect)
{
- if(!m_pVideoSurface || !m_pVideoSurfaceOff)
+ 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())
+ 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)))
+ 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')
- {
+ if(pBitmapInfo->biCompression == '024I') {
DWORD pitch = pBitmapInfo->biWidth;
DWORD size = pitch*abs(pBitmapInfo->biHeight);
@@ -114,29 +117,22 @@ STDMETHODIMP CRM9AllocatorPresenter::Blt(UCHAR* pImageData, RMABitmapInfoHeader*
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)
- {
+ if(m_pVideoSurfaceYUY2) {
D3DLOCKED_RECT r;
- if(SUCCEEDED(m_pVideoSurfaceYUY2->LockRect(&r, src2, 0)))
- {
+ 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
- {
+ } else {
D3DLOCKED_RECT r;
- if(SUCCEEDED(m_pVideoSurfaceOff->LockRect(&r, src2, 0)))
- {
+ 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')
- {
+ } else if(pBitmapInfo->biCompression == '2YUY') {
DWORD w = pBitmapInfo->biWidth;
DWORD h = abs(pBitmapInfo->biHeight);
DWORD pitch = pBitmapInfo->biWidth*2;
@@ -145,30 +141,23 @@ STDMETHODIMP CRM9AllocatorPresenter::Blt(UCHAR* pImageData, RMABitmapInfoHeader*
BYTE* yvyu = pImageData + src.top*pitch + src.left*2;
- if(m_pVideoSurfaceYUY2)
- {
+ if(m_pVideoSurfaceYUY2) {
D3DLOCKED_RECT r;
- if(SUCCEEDED(m_pVideoSurfaceYUY2->LockRect(&r, src2, 0)))
- {
+ 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
- {
+ } else {
D3DLOCKED_RECT r;
- if(SUCCEEDED(m_pVideoSurfaceOff->LockRect(&r, src2, 0)))
- {
+ 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')
- {
+ } 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;
@@ -178,11 +167,9 @@ STDMETHODIMP CRM9AllocatorPresenter::Blt(UCHAR* pImageData, RMABitmapInfoHeader*
BYTE* rgb = pImageData + src.top*pitch + src.left*(pBitmapInfo->biBitCount>>3);
D3DLOCKED_RECT r;
- if(SUCCEEDED(m_pVideoSurfaceOff->LockRect(&r, src2, 0)))
- {
+ if(SUCCEEDED(m_pVideoSurfaceOff->LockRect(&r, src2, 0))) {
BYTE* pBits = (BYTE*)r.pBits;
- if(pBitmapInfo->biHeight > 0)
- {
+ if(pBitmapInfo->biHeight > 0) {
pBits += r.Pitch*(src.Height()-1);
r.Pitch = -r.Pitch;
}
@@ -192,13 +179,11 @@ STDMETHODIMP CRM9AllocatorPresenter::Blt(UCHAR* pImageData, RMABitmapInfoHeader*
}
}
- if(!fRGB && !fYUY2)
- {
+ if(!fRGB && !fYUY2) {
m_pD3DDev->ColorFill(m_pVideoSurfaceOff, NULL, 0);
HDC hDC;
- if(SUCCEEDED(m_pVideoSurfaceOff->GetDC(&hDC)))
- {
+ if(SUCCEEDED(m_pVideoSurfaceOff->GetDC(&hDC))) {
CString str;
str.Format(_T("Sorry, this format is not supported"));
@@ -214,10 +199,12 @@ STDMETHODIMP CRM9AllocatorPresenter::Blt(UCHAR* pImageData, RMABitmapInfoHeader*
HRESULT hr;
- if(fRGB)
+ if(fRGB) {
hr = m_pD3DDev->StretchRect(m_pVideoSurfaceOff, src2, m_pVideoSurface[m_nCurSurface], dst, D3DTEXF_NONE);
- if(fYUY2)
+ }
+ if(fYUY2) {
hr = m_pD3DDev->StretchRect(m_pVideoSurfaceYUY2, src2, m_pVideoSurface[m_nCurSurface], dst, D3DTEXF_NONE);
+ }
Paint(true);
@@ -230,7 +217,9 @@ STDMETHODIMP CRM9AllocatorPresenter::BeginOptimizedBlt(RMABitmapInfoHeader* pBit
CAutoLock cRenderLock(&m_RenderLock);
DeleteSurfaces();
m_NativeVideoSize = m_AspectRatio = CSize(pBitmapInfo->biWidth, abs(pBitmapInfo->biHeight));
- if(FAILED(AllocSurfaces())) return E_FAIL;
+ if(FAILED(AllocSurfaces())) {
+ return E_FAIL;
+ }
return PNR_NOTIMPL;
}
diff --git a/src/filters/renderer/VideoRenderers/RM9AllocatorPresenter.h b/src/filters/renderer/VideoRenderers/RM9AllocatorPresenter.h
index b42429c57..77b9ac2dc 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 274a60fc1..b7267e574 100644
--- a/src/filters/renderer/VideoRenderers/RenderersSettings.cpp
+++ b/src/filters/renderer/VideoRenderers/RenderersSettings.cpp
@@ -119,13 +119,10 @@ LONGLONG CRenderersData::GetPerfCounter()
LARGE_INTEGER llPerfFrequency;
QueryPerformanceFrequency (&llPerfFrequency);
- if (llPerfFrequency.QuadPart != 0)
- {
+ if (llPerfFrequency.QuadPart != 0) {
QueryPerformanceCounter (&i64Ticks100ns);
return llMulDiv (i64Ticks100ns.QuadPart, 10000000, llPerfFrequency.QuadPart, 0);
- }
- else
- {
+ } else {
// ms to 100ns units
return timeGetTime() * 10000;
}
@@ -133,45 +130,18 @@ LONGLONG CRenderersData::GetPerfCounter()
HINSTANCE CRenderersData::GetD3X9Dll()
{
- if (m_hD3DX9Dll == NULL)
- {
- int min_ver = D3DX_SDK_VERSION;
- int max_ver = D3DX_SDK_VERSION;
+#if D3DX_SDK_VERSION < 42
+#error DirectX SDK August 2009 (v42) or newer is required to build MPC
+#endif
+ if (m_hD3DX9Dll == NULL) {
m_nDXSdkRelease = 0;
- if(D3DX_SDK_VERSION >= 42)
- {
- // August 2009 SDK (v42) is not compatible with older versions
- min_ver = 42;
- }
- else
- {
- if(D3DX_SDK_VERSION > 33)
- {
- // versions between 34 and 41 have no known compatibility issues
- min_ver = 34;
- }
- else
- {
- // The minimum version that supports the functionality required by MPC is 24
- min_ver = 24;
-
- if(D3DX_SDK_VERSION == 33)
- {
- // The April 2007 SDK (v33) should not be used (crash sometimes during shader compilation)
- max_ver = 32;
- }
- }
- }
-
// load latest compatible version of the DLL that is available
- for (int i=max_ver; i>=min_ver; i--)
- {
+ for (int i=D3DX_SDK_VERSION; i>=42; i--) {
m_strD3DX9Version.Format(_T("d3dx9_%d.dll"), i);
m_hD3DX9Dll = LoadLibrary (m_strD3DX9Version);
- if (m_hD3DX9Dll)
- {
+ if (m_hD3DX9Dll) {
m_nDXSdkRelease = i;
break;
}
diff --git a/src/filters/renderer/VideoRenderers/RenderersSettings.h b/src/filters/renderer/VideoRenderers/RenderersSettings.h
index 75dde7747..e5b19f015 100644
--- a/src/filters/renderer/VideoRenderers/RenderersSettings.h
+++ b/src/filters/renderer/VideoRenderers/RenderersSettings.h
@@ -23,52 +23,45 @@
#pragma once
-enum
-{
+enum {
WM_REARRANGERENDERLESS = WM_APP+1,
WM_RESET_DEVICE,
};
#define WM_MYMOUSELAST WM_XBUTTONDBLCLK
-enum
-{
+enum {
VIDRNDT_RM_DEFAULT,
VIDRNDT_RM_DX7,
VIDRNDT_RM_DX9,
};
-enum
-{
+enum {
VIDRNDT_QT_DEFAULT,
VIDRNDT_QT_DX7,
VIDRNDT_QT_DX9,
};
-enum
-{
+enum {
VIDRNDT_AP_SURFACE,
VIDRNDT_AP_TEXTURE2D,
VIDRNDT_AP_TEXTURE3D,
};
-enum VideoSystem
-{
+enum VideoSystem {
VIDEO_SYSTEM_UNKNOWN,
VIDEO_SYSTEM_HDTV,
VIDEO_SYSTEM_SDTV_NTSC,
VIDEO_SYSTEM_SDTV_PAL,
};
-enum AmbientLight
-{
+enum AmbientLight {
AMBIENT_LIGHT_BRIGHT,
AMBIENT_LIGHT_DIM,
AMBIENT_LIGHT_DARK,
};
-enum ColorRenderingIntent
-{
+enum ColorRenderingIntent {
COLOR_RENDERING_INTENT_PERCEPTUAL,
COLOR_RENDERING_INTENT_RELATIVE_COLORIMETRIC,
COLOR_RENDERING_INTENT_SATURATION,
@@ -84,8 +77,7 @@ public:
class CRendererSettingsShared
{
public:
- CRendererSettingsShared()
- {
+ CRendererSettingsShared() {
SetDefault();
}
bool fVMR9AlterativeVSync;
@@ -124,8 +116,7 @@ public:
bool iEVREnableFrameTimeCorrection;
int iEVROutputRange;
- CRendererSettingsEVR()
- {
+ CRendererSettingsEVR() {
SetDefault();
}
void SetDefault();
@@ -171,8 +162,7 @@ public:
LONGLONG GetPerfCounter();
HINSTANCE GetD3X9Dll();
- int GetDXSdkRelease()
- {
+ int GetDXSdkRelease() {
return m_nDXSdkRelease;
};
};
diff --git a/src/filters/renderer/VideoRenderers/SyncAllocatorPresenter.h b/src/filters/renderer/VideoRenderers/SyncAllocatorPresenter.h
index f1c52707b..62ff11e70 100644
--- a/src/filters/renderer/VideoRenderers/SyncAllocatorPresenter.h
+++ b/src/filters/renderer/VideoRenderers/SyncAllocatorPresenter.h
@@ -28,8 +28,7 @@ DEFINE_GUID(CLSID_SyncAllocatorPresenter, 0xf9f62627, 0xe3ef, 0x4a2e, 0xb6, 0xc9
interface __declspec(uuid("F891C2A9-1DFF-45e0-9129-30C0990C5A9F"))
ISyncClockAdviser :
-public IUnknown
-{
+public IUnknown {
STDMETHOD (AdviseSyncClock)(ISyncClock* sC) PURE;
};
diff --git a/src/filters/renderer/VideoRenderers/SyncRenderer.cpp b/src/filters/renderer/VideoRenderers/SyncRenderer.cpp
index 7d6a09d31..9a1a35eab 100644
--- a/src/filters/renderer/VideoRenderers/SyncRenderer.cpp
+++ b/src/filters/renderer/VideoRenderers/SyncRenderer.cpp
@@ -94,8 +94,7 @@ CBaseAP::CBaseAP(HWND hWnd, bool bFullscreen, HRESULT& hr, CString &_Error):
m_llEstVBlankTime(0),
m_CurrentAdapter(0)
{
- if(FAILED(hr))
- {
+ if(FAILED(hr)) {
_Error += L"ISubPicAllocatorPresenterImpl failed\n";
return;
}
@@ -106,15 +105,12 @@ CBaseAP::CBaseAP(HWND hWnd, bool bFullscreen, HRESULT& hr, CString &_Error):
m_pD3DXCreateFont = NULL;
m_pD3DXCreateSprite = NULL;
hDll = GetRenderersData()->GetD3X9Dll();
- if(hDll)
- {
+ 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
- {
+ } else {
_Error += L"The installed DirectX End-User Runtime is outdated. Please download and install the ";
_Error += DIRECTX_SDK_DATE;
_Error += L" release or newer in order for MPC-HC to function properly.\n";
@@ -123,8 +119,7 @@ CBaseAP::CBaseAP(HWND hWnd, bool bFullscreen, HRESULT& hr, CString &_Error):
m_pDwmIsCompositionEnabled = NULL;
m_pDwmEnableComposition = NULL;
m_hDWMAPI = LoadLibrary(L"dwmapi.dll");
- if (m_hDWMAPI)
- {
+ if (m_hDWMAPI) {
(FARPROC &)m_pDwmIsCompositionEnabled = GetProcAddress(m_hDWMAPI, "DwmIsCompositionEnabled");
(FARPROC &)m_pDwmEnableComposition = GetProcAddress(m_hDWMAPI, "DwmEnableComposition");
}
@@ -132,42 +127,39 @@ CBaseAP::CBaseAP(HWND hWnd, bool bFullscreen, HRESULT& hr, CString &_Error):
m_pDirect3DCreate9Ex = NULL;
m_hD3D9 = LoadLibrary(L"d3d9.dll");
#ifndef DISABLE_USING_D3D9EX
- if (m_hD3D9)
+ if (m_hD3D9) {
(FARPROC &)m_pDirect3DCreate9Ex = GetProcAddress(m_hD3D9, "Direct3DCreate9Ex");
+ }
#endif
- if (m_pDirect3DCreate9Ex)
- {
+ if (m_pDirect3DCreate9Ex) {
_tprintf(_T("m_pDirect3DCreate9Ex\n"));
m_pDirect3DCreate9Ex(D3D_SDK_VERSION, &m_pD3DEx);
- if(!m_pD3DEx)
- {
+ if(!m_pD3DEx) {
m_pDirect3DCreate9Ex(D3D9b_SDK_VERSION, &m_pD3DEx);
}
}
- if(!m_pD3DEx)
- {
+ if(!m_pD3DEx) {
m_pD3D.Attach(Direct3DCreate9(D3D_SDK_VERSION));
- if(!m_pD3D)
- {
+ if(!m_pD3D) {
m_pD3D.Attach(Direct3DCreate9(D3D9b_SDK_VERSION));
}
- if(m_pD3D)
+ if(m_pD3D) {
_tprintf(_T("m_pDirect3DCreate9\n"));
- }
- else
+ }
+ } else {
m_pD3D = m_pD3DEx;
+ }
ZeroMemory(&m_VMR9AlphaBitmap, sizeof(m_VMR9AlphaBitmap));
CRenderersSettings& s = GetRenderersSettings();
- if (s.m_RenderSettings.iVMRDisableDesktopComposition)
- {
+ if (s.m_RenderSettings.iVMRDisableDesktopComposition) {
m_bDesktopCompositionDisabled = true;
- if (m_pDwmEnableComposition) m_pDwmEnableComposition(0);
- }
- else
- {
+ if (m_pDwmEnableComposition) {
+ m_pDwmEnableComposition(0);
+ }
+ } else {
m_bDesktopCompositionDisabled = false;
}
@@ -179,11 +171,11 @@ CBaseAP::CBaseAP(HWND hWnd, bool bFullscreen, HRESULT& hr, CString &_Error):
CBaseAP::~CBaseAP()
{
- if (m_bDesktopCompositionDisabled)
- {
+ if (m_bDesktopCompositionDisabled) {
m_bDesktopCompositionDisabled = false;
- if (m_pDwmEnableComposition)
+ if (m_pDwmEnableComposition) {
m_pDwmEnableComposition(1);
+ }
}
m_pFont = NULL;
@@ -193,19 +185,16 @@ CBaseAP::~CBaseAP()
m_pPSC.Free();
m_pD3D = NULL;
m_pD3DEx = NULL;
- if (m_hDWMAPI)
- {
+ if (m_hDWMAPI) {
FreeLibrary(m_hDWMAPI);
m_hDWMAPI = NULL;
}
- if (m_hD3D9)
- {
+ if (m_hD3D9) {
FreeLibrary(m_hD3D9);
m_hD3D9 = NULL;
}
m_pAudioStats = NULL;
- if (m_pGenlock)
- {
+ if (m_pGenlock) {
delete m_pGenlock;
m_pGenlock = NULL;
}
@@ -216,19 +205,16 @@ void CBaseAP::AdjustQuad(MYD3DVERTEX<texcoords>* v, double dx, double dy)
{
double offset = 0.5;
- for(int i = 0; i < 4; i++)
- {
+ 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++)
- {
+ for(int j = 0; j < max(texcoords-1, 1); j++) {
v[i].t[j].u -= offset*dx;
v[i].t[j].v -= offset*dy;
}
- if(texcoords > 1)
- {
+ if(texcoords > 1) {
v[i].t[texcoords-1].u -= offset;
v[i].t[texcoords-1].v -= offset;
}
@@ -238,37 +224,38 @@ void CBaseAP::AdjustQuad(MYD3DVERTEX<texcoords>* v, double dx, double dy)
template<int texcoords>
HRESULT CBaseAP::TextureBlt(IDirect3DDevice9* pD3DDev, MYD3DVERTEX<texcoords> v[4], D3DTEXTUREFILTERTYPE filter = D3DTEXF_LINEAR)
{
- if(!pD3DDev) return E_POINTER;
+ 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;
+ 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;
@@ -281,8 +268,7 @@ HRESULT CBaseAP::TextureBlt(IDirect3DDevice9* pD3DDev, MYD3DVERTEX<texcoords> v[
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++)
- {
+ 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, filter);
@@ -298,8 +284,7 @@ HRESULT CBaseAP::TextureBlt(IDirect3DDevice9* pD3DDev, MYD3DVERTEX<texcoords> v[
v[3] = tmp;
hr = pD3DDev->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, v, sizeof(v[0]));
- for(int i = 0; i < texcoords; i++)
- {
+ for(int i = 0; i < texcoords; i++) {
pD3DDev->SetTexture(i, NULL);
}
@@ -308,7 +293,9 @@ HRESULT CBaseAP::TextureBlt(IDirect3DDevice9* pD3DDev, MYD3DVERTEX<texcoords> v[
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);
@@ -371,24 +358,20 @@ bool CBaseAP::SettingsNeedResetDevice()
CRenderersSettings::CRendererSettingsEVR & Current = m_LastRendererSettings;
bool bRet = false;
- if (!m_bIsFullscreen)
- {
- if (Current.iVMRDisableDesktopComposition)
- {
- if (!m_bDesktopCompositionDisabled)
- {
+ if (!m_bIsFullscreen) {
+ if (Current.iVMRDisableDesktopComposition) {
+ if (!m_bDesktopCompositionDisabled) {
m_bDesktopCompositionDisabled = true;
- if (m_pDwmEnableComposition)
+ if (m_pDwmEnableComposition) {
m_pDwmEnableComposition(0);
+ }
}
- }
- else
- {
- if (m_bDesktopCompositionDisabled)
- {
+ } else {
+ if (m_bDesktopCompositionDisabled) {
m_bDesktopCompositionDisabled = false;
- if (m_pDwmEnableComposition)
+ if (m_pDwmEnableComposition) {
m_pDwmEnableComposition(1);
+ }
}
}
}
@@ -418,20 +401,17 @@ HRESULT CBaseAP::CreateDXDevice(CString &_Error)
m_pResizerPixelShader[3] = 0;
POSITION pos = m_pPixelShadersScreenSpace.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CExternalPixelShader &Shader = m_pPixelShadersScreenSpace.GetNext(pos);
Shader.m_pPixelShader = NULL;
}
pos = m_pPixelShaders.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CExternalPixelShader &Shader = m_pPixelShaders.GetNext(pos);
Shader.m_pPixelShader = NULL;
}
- if(!m_pD3D)
- {
+ if(!m_pD3D) {
_Error += L"Failed to create Direct3D device\n";
return E_UNEXPECTED;
}
@@ -439,15 +419,13 @@ HRESULT CBaseAP::CreateDXDevice(CString &_Error)
D3DDISPLAYMODE d3ddm;
ZeroMemory(&d3ddm, sizeof(d3ddm));
m_CurrentAdapter = GetAdapter(m_pD3D);
- if(FAILED(m_pD3D->GetAdapterDisplayMode(m_CurrentAdapter, &d3ddm)))
- {
+ 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)
- {
+ 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;
}
@@ -458,12 +436,13 @@ HRESULT CBaseAP::CreateDXDevice(CString &_Error)
m_pGenlock->SetDisplayResolution(d3ddm.Width, d3ddm.Height);
BOOL bCompositionEnabled = false;
- if (m_pDwmIsCompositionEnabled) m_pDwmIsCompositionEnabled(&bCompositionEnabled);
+ if (m_pDwmIsCompositionEnabled) {
+ m_pDwmIsCompositionEnabled(&bCompositionEnabled);
+ }
m_bCompositionEnabled = bCompositionEnabled != 0;
ZeroMemory(&pp, sizeof(pp));
- if (m_bIsFullscreen) // Exclusive mode fullscreen
- {
+ if (m_bIsFullscreen) { // Exclusive mode fullscreen
pp.Windowed = FALSE;
pp.BackBufferWidth = d3ddm.Width;
pp.BackBufferHeight = d3ddm.Height;
@@ -474,22 +453,20 @@ HRESULT CBaseAP::CreateDXDevice(CString &_Error)
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)))
- {
+ if (m_bHighColorResolution) {
+ if(FAILED(m_pD3D->CheckDeviceType(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, d3ddm.Format, D3DFMT_A2R10G10B10, false))) {
m_strStatsMsg[MSG_ERROR].Format (L"10 bit RGB is not supported by this graphics device in this resolution.");
m_bHighColorResolution = false;
}
}
- if (m_bHighColorResolution)
+ if (m_bHighColorResolution) {
pp.BackBufferFormat = D3DFMT_A2R10G10B10;
- else
+ } else {
pp.BackBufferFormat = d3ddm.Format;
+ }
- if (m_pD3DEx)
- {
+ if (m_pD3DEx) {
D3DDISPLAYMODEEX DisplayMode;
ZeroMemory(&DisplayMode, sizeof(DisplayMode));
DisplayMode.Size = sizeof(DisplayMode);
@@ -499,36 +476,28 @@ HRESULT CBaseAP::CreateDXDevice(CString &_Error)
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))
- {
+ 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)
- {
+ 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))
- {
+ } 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;
}
_tprintf(_T("Created full-screen device\n"));
- if (m_pD3DDev)
- {
+ if (m_pD3DDev) {
m_BackbufferType = pp.BackBufferFormat;
m_DisplayType = d3ddm.Format;
}
}
- }
- else // Windowed
- {
+ } else { // Windowed
pp.Windowed = TRUE;
pp.hDeviceWindow = m_hWnd;
pp.SwapEffect = D3DSWAPEFFECT_COPY;
@@ -539,46 +508,37 @@ HRESULT CBaseAP::CreateDXDevice(CString &_Error)
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)))
- {
+ if (m_bHighColorResolution) {
+ if(FAILED(m_pD3D->CheckDeviceType(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, d3ddm.Format, D3DFMT_A2R10G10B10, false))) {
m_strStatsMsg[MSG_ERROR].Format (L"10 bit RGB is not supported by this graphics device in this resolution.");
m_bHighColorResolution = false;
}
}
- if (m_bHighColorResolution)
- {
+ if (m_bHighColorResolution) {
m_BackbufferType = D3DFMT_A2R10G10B10;
pp.BackBufferFormat = D3DFMT_A2R10G10B10;
}
- if (bCompositionEnabled)
- {
+ if (bCompositionEnabled) {
// Desktop composition presents the whole desktop
pp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
- }
- else
- {
+ } else {
pp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
}
- if (m_pD3DEx)
- {
+ 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))
- {
+ 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 (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))
- {
+ D3DCREATE_HARDWARE_VERTEXPROCESSING|D3DCREATE_FPU_PRESERVE|D3DCREATE_MULTITHREADED,
+ &pp, &m_pD3DDev)) {
_Error += GetWindowsErrorMessage(hr, m_hD3D9);
return hr;
}
@@ -586,13 +546,11 @@ HRESULT CBaseAP::CreateDXDevice(CString &_Error)
}
}
- while(hr == D3DERR_DEVICELOST)
- {
+ while(hr == D3DERR_DEVICELOST) {
TRACE("D3DERR_DEVICELOST. Trying to Reset.\n");
hr = m_pD3DDev->TestCooperativeLevel();
}
- if (hr == D3DERR_DEVICENOTRESET)
- {
+ if (hr == D3DERR_DEVICENOTRESET) {
TRACE("D3DERR_DEVICENOTRESET\n");
hr = m_pD3DDev->Reset(&pp);
}
@@ -600,64 +558,59 @@ HRESULT CBaseAP::CreateDXDevice(CString &_Error)
TRACE("CreateDevice: %d\n", (LONG)hr);
ASSERT (SUCCEEDED (hr));
- if (m_pD3DDevEx)
- {
+ 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)
+ 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);
+ 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;
}
- else
- {
+
+ if(m_pAllocator) {
+ m_pAllocator->ChangeDevice(m_pD3DDev);
+ } else {
m_pAllocator = DNew CDX9SubPicAllocator(m_pD3DDev, size, GetRenderersSettings().fSPCPow2Tex);
- if(!m_pAllocator)
- {
+ if(!m_pAllocator) {
_Error += L"CDX9SubPicAllocator failed\n";
return E_FAIL;
}
@@ -666,8 +619,7 @@ HRESULT CBaseAP::CreateDXDevice(CString &_Error)
hr = S_OK;
CComPtr<ISubPicProvider> pSubPicProvider;
- if(m_pSubPicQueue)
- {
+ if(m_pSubPicQueue) {
_tprintf(_T("m_pSubPicQueue != NULL\n"));
m_pSubPicQueue->GetSubPicProvider(&pSubPicProvider);
}
@@ -676,16 +628,16 @@ HRESULT CBaseAP::CreateDXDevice(CString &_Error)
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))
- {
+ if(!m_pSubPicQueue || FAILED(hr)) {
_Error += L"m_pSubPicQueue failed\n";
return E_FAIL;
}
- if(pSubPicProvider) m_pSubPicQueue->SetSubPicProvider(pSubPicProvider);
+ if(pSubPicProvider) {
+ m_pSubPicQueue->SetSubPicProvider(pSubPicProvider);
+ }
- if (m_pD3DXCreateFont)
- {
+ if (m_pD3DXCreateFont) {
int MinSize = 1600;
int CurrentSize = min(m_ScreenSize.cx, MinSize);
double Scale = double(CurrentSize) / double(MinSize);
@@ -693,8 +645,12 @@ HRESULT CBaseAP::CreateDXDevice(CString &_Error)
m_pD3DXCreateFont(m_pD3DDev, -24.0*Scale, -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);
+ 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;
}
@@ -706,7 +662,9 @@ HRESULT CBaseAP::ResetDXDevice(CString &_Error)
HRESULT hr = E_FAIL;
hr = m_pD3DDev->TestCooperativeLevel();
- if ((hr != D3DERR_DEVICENOTRESET) && (hr != D3D_OK)) return hr;
+ if ((hr != D3DERR_DEVICENOTRESET) && (hr != D3D_OK)) {
+ return hr;
+ }
CComPtr<IEnumPins> rendererInputEnum;
vector<CComPtr<IPin>> decoderOutput;
@@ -716,30 +674,26 @@ HRESULT CBaseAP::ResetDXDevice(CString &_Error)
bool disconnected = FALSE;
// Disconnect all pins to release video memory resources
- if (m_pD3DDev)
- {
+ if (m_pD3DDev) {
ZeroMemory(&filterInfo, sizeof(filterInfo));
m_pOuterEVR->QueryFilterInfo(&filterInfo); // This addref's the pGraph member
- if (SUCCEEDED(m_pOuterEVR->EnumPins(&rendererInputEnum)))
- {
+ 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
- {
+ while (hr = rendererInputEnum->Next(1, &input.p, 0), hr == S_OK) { // Must have .p here
_tprintf(_T("Pin found\n"));
input->ConnectedTo(&output.p);
- if (output != NULL)
- {
+ if (output != NULL) {
rendererInput.push_back(input);
decoderOutput.push_back(output);
}
input.Release();
output.Release();
}
+ } else {
+ return hr;
}
- else return hr;
- for (DWORD i = 0; i < decoderOutput.size(); i++)
- {
+ for (DWORD i = 0; i < decoderOutput.size(); i++) {
_tprintf(_T("Disconnecting pin\n"));
filterInfo.pGraph->Disconnect(decoderOutput.at(i).p);
filterInfo.pGraph->Disconnect(rendererInput.at(i).p);
@@ -761,22 +715,19 @@ HRESULT CBaseAP::ResetDXDevice(CString &_Error)
m_pResizerPixelShader[3] = 0;
POSITION pos = m_pPixelShadersScreenSpace.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CExternalPixelShader &Shader = m_pPixelShadersScreenSpace.GetNext(pos);
Shader.m_pPixelShader = NULL;
}
pos = m_pPixelShaders.GetHeadPosition();
- while(pos)
- {
+ 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)))
- {
+ if(FAILED(m_pD3D->GetAdapterDisplayMode(GetAdapter(m_pD3D), &d3ddm))) {
_Error += L"Can not retrieve display mode data\n";
return E_UNEXPECTED;
}
@@ -790,20 +741,21 @@ HRESULT CBaseAP::ResetDXDevice(CString &_Error)
ZeroMemory(&pp, sizeof(pp));
BOOL bCompositionEnabled = false;
- if (m_pDwmIsCompositionEnabled) m_pDwmIsCompositionEnabled(&bCompositionEnabled);
+ if (m_pDwmIsCompositionEnabled) {
+ m_pDwmIsCompositionEnabled(&bCompositionEnabled);
+ }
m_bCompositionEnabled = bCompositionEnabled != 0;
m_bHighColorResolution = s.m_RenderSettings.iEVRHighColorResolution;
- if (m_bIsFullscreen) // Exclusive mode fullscreen
- {
+ if (m_bIsFullscreen) { // Exclusive mode fullscreen
pp.BackBufferWidth = d3ddm.Width;
pp.BackBufferHeight = d3ddm.Height;
- if (m_bHighColorResolution)
+ if (m_bHighColorResolution) {
pp.BackBufferFormat = D3DFMT_A2R10G10B10;
- else
+ } else {
pp.BackBufferFormat = d3ddm.Format;
- if(FAILED(m_pD3DEx->CheckDeviceType(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, pp.BackBufferFormat, pp.BackBufferFormat, false)))
- {
+ }
+ 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;
}
@@ -811,89 +763,66 @@ HRESULT CBaseAP::ResetDXDevice(CString &_Error)
D3DDISPLAYMODEEX DisplayMode;
ZeroMemory(&DisplayMode, sizeof(DisplayMode));
DisplayMode.Size = sizeof(DisplayMode);
- if (m_pD3DDevEx)
- {
+ 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))
- {
+ if FAILED(m_pD3DDevEx->Reset(&pp)) {
_Error += GetWindowsErrorMessage(hr, m_hD3D9);
return hr;
}
- }
- else if (m_pD3DDev)
- {
- if FAILED(m_pD3DDev->Reset(&pp))
- {
+ } else if (m_pD3DDev) {
+ if FAILED(m_pD3DDev->Reset(&pp)) {
_Error += GetWindowsErrorMessage(hr, m_hD3D9);
return hr;
}
- }
- else
- {
+ } else {
_Error += L"No device.\n";
return hr;
}
m_BackbufferType = pp.BackBufferFormat;
m_DisplayType = d3ddm.Format;
- }
- else // Windowed
- {
+ } else { // Windowed
pp.BackBufferWidth = d3ddm.Width;
pp.BackBufferHeight = d3ddm.Height;
m_BackbufferType = d3ddm.Format;
m_DisplayType = d3ddm.Format;
- if (m_bHighColorResolution)
- {
+ 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)))
- {
+ 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)
- {
+ if (bCompositionEnabled) {
// Desktop composition presents the whole desktop
pp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
- }
- else
- {
+ } else {
pp.PresentationInterval = D3DPRESENT_INTERVAL_ONE;
}
if (m_pD3DDevEx)
- if FAILED(m_pD3DDevEx->Reset(&pp))
- {
+ if FAILED(m_pD3DDevEx->Reset(&pp)) {
_Error += GetWindowsErrorMessage(hr, m_hD3D9);
return hr;
- }
- else if (m_pD3DDev)
- if FAILED(m_pD3DDevEx->Reset(&pp))
- {
+ } else if (m_pD3DDev)
+ if FAILED(m_pD3DDevEx->Reset(&pp)) {
_Error += GetWindowsErrorMessage(hr, m_hD3D9);
return hr;
- }
- else
- {
+ } 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)))
- {
+ 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)
- {
+ if (filterInfo.pGraph != NULL) {
filterInfo.pGraph->Release();
}
}
@@ -902,58 +831,56 @@ HRESULT CBaseAP::ResetDXDevice(CString &_Error)
m_filter = D3DTEXF_NONE;
if((m_caps.StretchRectFilterCaps&D3DPTFILTERCAPS_MINFLINEAR)
- && (m_caps.StretchRectFilterCaps&D3DPTFILTERCAPS_MAGFLINEAR))
+ && (m_caps.StretchRectFilterCaps&D3DPTFILTERCAPS_MAGFLINEAR)) {
m_filter = D3DTEXF_LINEAR;
+ }
m_bicubicA = 0;
CComPtr<ISubPicProvider> pSubPicProvider;
- if(m_pSubPicQueue) m_pSubPicQueue->GetSubPicProvider(&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);
+ 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;
}
- else
- {
+
+ if(m_pAllocator) {
+ m_pAllocator->ChangeDevice(m_pD3DDev);
+ } else {
m_pAllocator = DNew CDX9SubPicAllocator(m_pD3DDev, size, GetRenderersSettings().fSPCPow2Tex);
- if(!m_pAllocator)
- {
+ if(!m_pAllocator) {
_Error += L"CDX9SubPicAllocator failed\n";
return E_FAIL;
@@ -964,18 +891,18 @@ HRESULT CBaseAP::ResetDXDevice(CString &_Error)
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))
- {
+ if(!m_pSubPicQueue || FAILED(hr)) {
_Error += L"m_pSubPicQueue failed\n";
return E_FAIL;
}
- if(pSubPicProvider) m_pSubPicQueue->SetSubPicProvider(pSubPicProvider);
+ if(pSubPicProvider) {
+ m_pSubPicQueue->SetSubPicProvider(pSubPicProvider);
+ }
m_pFont = NULL;
- if (m_pD3DXCreateFont)
- {
+ if (m_pD3DXCreateFont) {
int MinSize = 1600;
int CurrentSize = min(m_ScreenSize.cx, MinSize);
double Scale = double(CurrentSize) / double(MinSize);
@@ -984,9 +911,13 @@ HRESULT CBaseAP::ResetDXDevice(CString &_Error)
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);
+ if (m_pD3DXCreateSprite) {
+ m_pD3DXCreateSprite(m_pD3DDev, &m_pSprite);
+ }
m_pLine = NULL;
- if (m_pD3DXCreateLine) m_pD3DXCreateLine (m_pD3DDev, &m_pLine);
+ if (m_pD3DXCreateLine) {
+ m_pD3DXCreateLine (m_pD3DDev, &m_pLine);
+ }
return S_OK;
}
@@ -997,8 +928,7 @@ HRESULT CBaseAP::AllocSurfaces(D3DFORMAT Format)
CRenderersSettings& s = GetRenderersSettings();
- for(int i = 0; i < m_nDXSurface+2; i++)
- {
+ for(int i = 0; i < m_nDXSurface+2; i++) {
m_pVideoTexture[i] = NULL;
m_pVideoSurface[i] = NULL;
}
@@ -1008,31 +938,28 @@ HRESULT CBaseAP::AllocSurfaces(D3DFORMAT Format)
m_SurfaceType = Format;
HRESULT hr;
- if(s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE2D || s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D)
- {
+ 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++)
- {
+ 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)))
+ 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])))
+ 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++)
- {
+ 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)))
+ } 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);
@@ -1044,8 +971,7 @@ void CBaseAP::DeleteSurfaces()
CAutoLock cAutoLock(this);
CAutoLock cRenderLock(&m_allocatorLock);
- for(int i = 0; i < m_nDXSurface+2; i++)
- {
+ for(int i = 0; i < m_nDXSurface+2; i++) {
m_pVideoTexture[i] = NULL;
m_pVideoSurface[i] = NULL;
}
@@ -1053,15 +979,20 @@ void CBaseAP::DeleteSurfaces()
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;
+ if(hMonitor == NULL) {
+ return D3DADAPTER_DEFAULT;
+ }
- for(UINT adp = 0, num_adp = pD3D->GetAdapterCount(); adp < num_adp; ++adp)
- {
+ for(UINT adp = 0, num_adp = pD3D->GetAdapterCount(); adp < num_adp; ++adp) {
HMONITOR hAdpMon = pD3D->GetAdapterMonitor(adp);
- if(hAdpMon == hMonitor) return adp;
+ if(hAdpMon == hMonitor) {
+ return adp;
+ }
}
return D3DADAPTER_DEFAULT;
}
@@ -1077,37 +1008,33 @@ bool CBaseAP::ClipToSurface(IDirect3DSurface9* pSurface, CRect& s, CRect& d)
{
D3DSURFACE_DESC d3dsd;
ZeroMemory(&d3dsd, sizeof(d3dsd));
- if(FAILED(pSurface->GetDesc(&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)
- {
+ || sw <= 0 || sh <= 0 || dw <= 0 || dh <= 0) {
s.SetRectEmpty();
d.SetRectEmpty();
return(true);
}
- if(d.right > w)
- {
+ if(d.right > w) {
s.right -= (d.right-w)*sw/dw;
d.right = w;
}
- if(d.bottom > h)
- {
+ if(d.bottom > h) {
s.bottom -= (d.bottom-h)*sh/dh;
d.bottom = h;
}
- if(d.left < 0)
- {
+ if(d.left < 0) {
s.left += (0-d.left)*sw/dw;
d.left = 0;
}
- if(d.top < 0)
- {
+ if(d.top < 0) {
s.top += (0-d.top)*sh/dh;
d.top = 0;
}
@@ -1117,57 +1044,65 @@ bool CBaseAP::ClipToSurface(IDirect3DSurface9* pSurface, CRect& s, CRect& d)
HRESULT CBaseAP::InitResizers(float bicubicA, bool bNeedScreenSizeTexture)
{
HRESULT hr;
- do
- {
- if (bicubicA)
- {
- if (!m_pResizerPixelShader[0])
+ do {
+ if (bicubicA) {
+ if (!m_pResizerPixelShader[0]) {
break;
- if (!m_pResizerPixelShader[1])
+ }
+ if (!m_pResizerPixelShader[1]) {
break;
- if (!m_pResizerPixelShader[2])
+ }
+ if (!m_pResizerPixelShader[2]) {
break;
- if (!m_pResizerPixelShader[3])
+ }
+ if (!m_pResizerPixelShader[3]) {
break;
- if (m_bicubicA != bicubicA)
+ }
+ if (m_bicubicA != bicubicA) {
break;
- if (!m_pScreenSizeTemporaryTexture[0])
+ }
+ if (!m_pScreenSizeTemporaryTexture[0]) {
break;
- if (bNeedScreenSizeTexture)
- {
- if (!m_pScreenSizeTemporaryTexture[1])
+ }
+ if (bNeedScreenSizeTexture) {
+ if (!m_pScreenSizeTemporaryTexture[1]) {
break;
+ }
}
- }
- else
- {
- if (!m_pResizerPixelShader[0])
+ } else {
+ if (!m_pResizerPixelShader[0]) {
break;
- if (bNeedScreenSizeTexture)
- {
- if (!m_pScreenSizeTemporaryTexture[0])
+ }
+ if (bNeedScreenSizeTexture) {
+ if (!m_pScreenSizeTemporaryTexture[0]) {
break;
- if (!m_pScreenSizeTemporaryTexture[1])
+ }
+ if (!m_pScreenSizeTemporaryTexture[1]) {
break;
+ }
}
}
return S_OK;
- }
- while (0);
+ } while (0);
m_bicubicA = bicubicA;
m_pScreenSizeTemporaryTexture[0] = NULL;
m_pScreenSizeTemporaryTexture[1] = NULL;
- for(int i = 0; i < countof(m_pResizerPixelShader); i++)
+ for(int i = 0; i < countof(m_pResizerPixelShader); i++) {
m_pResizerPixelShader[i] = NULL;
+ }
- if(m_caps.PixelShaderVersion < D3DPS_VERSION(2, 0)) return E_FAIL;
+ 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;
+ if(!LoadResource(IDF_SHADER_RESIZER, str, _T("FILE"))) {
+ return E_FAIL;
+ }
CStringA A;
A.Format("(%f)", bicubicA);
@@ -1176,34 +1111,28 @@ HRESULT CBaseAP::InitResizers(float bicubicA, bool bNeedScreenSizeTexture)
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++)
- {
+ 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))
- {
+ if(FAILED(hr)) {
TRACE("%ws", ErrorMessage.GetString());
ASSERT (0);
return hr;
}
}
- if(m_bicubicA || bNeedScreenSizeTexture)
- {
+ 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)))
- {
+ D3DPOOL_DEFAULT, &m_pScreenSizeTemporaryTexture[0], NULL))) {
ASSERT(0);
m_pScreenSizeTemporaryTexture[0] = NULL; // will do 1 pass then
}
}
- if(m_bicubicA || bNeedScreenSizeTexture)
- {
+ 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)))
- {
+ D3DPOOL_DEFAULT, &m_pScreenSizeTemporaryTexture[1], NULL))) {
ASSERT(0);
m_pScreenSizeTemporaryTexture[1] = NULL; // will do 1 pass then
}
@@ -1216,20 +1145,19 @@ HRESULT CBaseAP::TextureCopy(IDirect3DTexture9* pTexture)
HRESULT hr;
D3DSURFACE_DESC desc;
- if(!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc)))
+ if(!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc))) {
return E_FAIL;
+ }
float w = (float)desc.Width;
float h = (float)desc.Height;
- MYD3DVERTEX<1> v[] =
- {
+ 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++)
- {
+ for(int i = 0; i < countof(v); i++) {
v[i].x -= 0.5;
v[i].y -= 0.5;
}
@@ -1240,15 +1168,13 @@ HRESULT CBaseAP::TextureCopy(IDirect3DTexture9* pTexture)
HRESULT CBaseAP::DrawRect(DWORD _Color, DWORD _Alpha, const CRect &_Rect)
{
DWORD Color = D3DCOLOR_ARGB(_Alpha, GetRValue(_Color), GetGValue(_Color), GetBValue(_Color));
- MYD3DVERTEX<0> v[] =
- {
+ 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++)
- {
+ for(int i = 0; i < countof(v); i++) {
v[i].x -= 0.5;
v[i].y -= 0.5;
}
@@ -1260,8 +1186,9 @@ HRESULT CBaseAP::TextureResize(IDirect3DTexture9* pTexture, Vector dst[4], D3DTE
HRESULT hr;
D3DSURFACE_DESC desc;
- if(!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc)))
+ if(!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc))) {
return E_FAIL;
+ }
float w = (float)desc.Width;
float h = (float)desc.Height;
@@ -1269,8 +1196,7 @@ HRESULT CBaseAP::TextureResize(IDirect3DTexture9* pTexture, Vector dst[4], D3DTE
float dx2 = 1.0/w;
float dy2 = 1.0/h;
- MYD3DVERTEX<1> v[] =
- {
+ 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},
@@ -1288,8 +1214,9 @@ HRESULT CBaseAP::TextureResizeBilinear(IDirect3DTexture9* pTexture, Vector dst[4
HRESULT hr;
D3DSURFACE_DESC desc;
- if(!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc)))
+ if(!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc))) {
return E_FAIL;
+ }
float w = (float)desc.Width;
float h = (float)desc.Height;
@@ -1299,8 +1226,7 @@ HRESULT CBaseAP::TextureResizeBilinear(IDirect3DTexture9* pTexture, Vector dst[4
float ty0 = SrcRect.top;
float ty1 = SrcRect.bottom;
- MYD3DVERTEX<1> v[] =
- {
+ 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},
@@ -1321,8 +1247,9 @@ HRESULT CBaseAP::TextureResizeBicubic1pass(IDirect3DTexture9* pTexture, Vector d
HRESULT hr;
D3DSURFACE_DESC desc;
- if(!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc)))
+ if(!pTexture || FAILED(pTexture->GetLevelDesc(0, &desc))) {
return E_FAIL;
+ }
double w = (double)desc.Width;
double h = (double)desc.Height;
@@ -1332,8 +1259,7 @@ HRESULT CBaseAP::TextureResizeBicubic1pass(IDirect3DTexture9* pTexture, Vector d
float ty0 = SrcRect.top;
float ty1 = SrcRect.bottom;
- MYD3DVERTEX<1> v[] =
- {
+ 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},
@@ -1436,30 +1362,29 @@ HRESULT CBaseAP::TextureResizeBicubic2pass(IDirect3DTexture9* pTexture, Vector d
HRESULT CBaseAP::AlphaBlt(RECT* pSrc, RECT* pDst, IDirect3DTexture9* pTexture)
{
- if(!pSrc || !pDst)
+ if(!pSrc || !pDst) {
return E_POINTER;
+ }
CRect src(*pSrc), dst(*pDst);
HRESULT hr;
- do
- {
+ do {
D3DSURFACE_DESC d3dsd;
ZeroMemory(&d3dsd, sizeof(d3dsd));
- if(FAILED(pTexture->GetLevelDesc(0, &d3dsd)) /*|| d3dsd.Type != D3DRTYPE_TEXTURE*/)
+ if(FAILED(pTexture->GetLevelDesc(0, &d3dsd)) /*|| d3dsd.Type != D3DRTYPE_TEXTURE*/) {
break;
+ }
float w = (float)d3dsd.Width;
float h = (float)d3dsd.Height;
- struct
- {
+ struct {
float x, y, z, rhw;
float tu, tv;
}
- pVertices[] =
- {
+ 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},
@@ -1503,8 +1428,7 @@ HRESULT CBaseAP::AlphaBlt(RECT* pSrc, RECT* pDst, IDirect3DTexture9* pTexture)
m_pD3DDev->SetRenderState(D3DRS_DESTBLEND, db);
return S_OK;
- }
- while(0);
+ } while(0);
return E_FAIL;
}
@@ -1515,13 +1439,13 @@ void CBaseAP::SyncStats(LONGLONG syncTime)
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))
+ if (abs(syncDeviation) > (GetDisplayCycle() / 2)) {
m_uSyncGlitches++;
+ }
LONGLONG llJitterSum = 0;
LONGLONG llJitterSumAvg = 0;
- for (int i=0; i<NB_JITTER; i++)
- {
+ for (int i=0; i<NB_JITTER; i++) {
LONGLONG Jitter = m_pllJitter[i];
llJitterSum += Jitter;
llJitterSumAvg += Jitter;
@@ -1529,8 +1453,7 @@ void CBaseAP::SyncStats(LONGLONG syncTime)
m_fJitterMean = double(llJitterSumAvg) / NB_JITTER;
double DeviationSum = 0;
- for (int i=0; i<NB_JITTER; i++)
- {
+ for (int i=0; i<NB_JITTER; i++) {
LONGLONG DevInt = m_pllJitter[i] - m_fJitterMean;
double Deviation = DevInt;
DeviationSum += Deviation*Deviation;
@@ -1550,8 +1473,7 @@ void CBaseAP::SyncOffsetStats(LONGLONG syncOffset)
m_pllSyncOffset[m_nNextSyncOffset] = syncOffset;
LONGLONG AvrageSum = 0;
- for (int i=0; i<NB_JITTER; i++)
- {
+ for (int i=0; i<NB_JITTER; i++) {
LONGLONG Offset = m_pllSyncOffset[i];
AvrageSum += Offset;
m_MaxSyncOffset = max(m_MaxSyncOffset, Offset);
@@ -1559,8 +1481,7 @@ void CBaseAP::SyncOffsetStats(LONGLONG syncOffset)
}
double MeanOffset = double(AvrageSum)/NB_JITTER;
double DeviationSum = 0;
- for (int i=0; i<NB_JITTER; i++)
- {
+ for (int i=0; i<NB_JITTER; i++) {
double Deviation = double(m_pllSyncOffset[i]) - MeanOffset;
DeviationSum += Deviation*Deviation;
}
@@ -1574,20 +1495,20 @@ void CBaseAP::UpdateAlphaBitmap()
{
m_VMR9AlphaBitmapData.Free();
- if ((m_VMR9AlphaBitmap.dwFlags & VMRBITMAP_DISABLE) == 0)
- {
+ if ((m_VMR9AlphaBitmap.dwFlags & VMRBITMAP_DISABLE) == 0) {
HBITMAP hBitmap = (HBITMAP)GetCurrentObject (m_VMR9AlphaBitmap.hdc, OBJ_BITMAP);
- if (!hBitmap)
+ if (!hBitmap) {
return;
+ }
DIBSECTION info = {0};
- if (!::GetObject(hBitmap, sizeof( DIBSECTION ), &info ))
+ 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))
- {
+ if (m_VMR9AlphaBitmapData.Allocate(info.dsBm.bmWidthBytes * info.dsBm.bmHeight)) {
memcpy((BYTE *)m_VMR9AlphaBitmapData, info.dsBm.bmBits, info.dsBm.bmWidthBytes * info.dsBm.bmHeight);
}
}
@@ -1596,8 +1517,7 @@ void CBaseAP::UpdateAlphaBitmap()
// Present a sample (frame) using DirectX.
STDMETHODIMP_(bool) CBaseAP::Paint(bool fAll)
{
- if (m_bPendingResetDevice)
- {
+ if (m_bPendingResetDevice) {
SendResetRequest();
return false;
}
@@ -1617,7 +1537,9 @@ STDMETHODIMP_(bool) CBaseAP::Paint(bool fAll)
// 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);
+ 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)
@@ -1625,8 +1547,7 @@ STDMETHODIMP_(bool) CBaseAP::Paint(bool fAll)
if(m_WindowRect.right <= m_WindowRect.left || m_WindowRect.bottom <= m_WindowRect.top
|| m_NativeVideoSize.cx <= 0 || m_NativeVideoSize.cy <= 0
- || !m_pVideoSurface)
- {
+ || !m_pVideoSurface) {
return(false);
}
@@ -1641,29 +1562,27 @@ STDMETHODIMP_(bool) CBaseAP::Paint(bool fAll)
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])
- {
+ 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())
- {
+ 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)
+ 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 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},
};
@@ -1674,19 +1593,21 @@ STDMETHODIMP_(bool) CBaseAP::Paint(bool fAll)
hr = m_pD3DDev->GetRenderTarget(0, &pRT);
POSITION pos = m_pPixelShaders.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
pVideoTexture = m_pVideoTexture[dst];
hr = m_pD3DDev->SetRenderTarget(0, m_pVideoSurface[dst]);
CExternalPixelShader &Shader = m_pPixelShaders.GetNext(pos);
- if (!Shader.m_pPixelShader)
+ 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;
+ if(++dst >= m_nDXSurface+2) {
+ dst = m_nDXSurface;
+ }
}
hr = m_pD3DDev->SetRenderTarget(0, pRT);
@@ -1700,73 +1621,68 @@ STDMETHODIMP_(bool) CBaseAP::Paint(bool fAll)
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;
+ 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])
+ if (!m_pScreenSizeTemporaryTexture[0] || !m_pScreenSizeTemporaryTexture[1]) {
bScreenSpacePixelShaders = false;
+ }
- if (bScreenSpacePixelShaders)
- {
+ if (bScreenSpacePixelShaders) {
CComPtr<IDirect3DSurface9> pRT;
hr = m_pScreenSizeTemporaryTexture[1]->GetSurfaceLevel(0, &pRT);
- if (hr != S_OK)
+ if (hr != S_OK) {
bScreenSpacePixelShaders = false;
- if (bScreenSpacePixelShaders)
- {
+ }
+ if (bScreenSpacePixelShaders) {
hr = m_pD3DDev->SetRenderTarget(0, pRT);
- if (hr != S_OK)
+ 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)
- {
+ 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)
- {
+ } else if(iDX9Resizer == 2) {
hr = TextureResizeBilinear(pVideoTexture, dst, rSrcVid);
- }
- else if(iDX9Resizer >= 3)
- {
+ } else if(iDX9Resizer >= 3) {
hr = TextureResizeBicubic2pass(pVideoTexture, dst, rSrcVid);
}
+ } else {
+ hr = TextureResize(pVideoTexture, dst, D3DTEXF_POINT, rSrcVid);
}
- else hr = TextureResize(pVideoTexture, dst, D3DTEXF_POINT, rSrcVid);
- if (bScreenSpacePixelShaders)
- {
+ 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)
+ 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 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},
};
@@ -1776,22 +1692,19 @@ STDMETHODIMP_(bool) CBaseAP::Paint(bool fAll)
int src = 1, dst = 0;
POSITION pos = m_pPixelShadersScreenSpace.GetHeadPosition();
- while(pos)
- {
- if (m_pPixelShadersScreenSpace.GetTailPosition() == pos)
- {
+ while(pos) {
+ if (m_pPixelShadersScreenSpace.GetTailPosition() == pos) {
m_pD3DDev->SetRenderTarget(0, pBackBuffer);
- }
- else
- {
+ } 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)
+ if (!Shader.m_pPixelShader) {
Shader.Compile(m_pPSC);
+ }
hr = m_pD3DDev->SetPixelShader(Shader.m_pPixelShader);
TextureCopy(m_pScreenSizeTemporaryTexture[src]);
@@ -1800,11 +1713,8 @@ STDMETHODIMP_(bool) CBaseAP::Paint(bool fAll)
hr = m_pD3DDev->SetPixelShader(NULL);
}
- }
- else
- {
- if(pBackBuffer)
- {
+ } else {
+ if(pBackBuffer) {
ClipToSurface(pBackBuffer, rSrcVid, rDstVid);
// rSrcVid has to be aligned on mod2 for yuy2->rgb conversion with StretchRect
rSrcVid.left &= ~1;
@@ -1812,31 +1722,28 @@ STDMETHODIMP_(bool) CBaseAP::Paint(bool fAll)
rSrcVid.top &= ~1;
rSrcVid.bottom &= ~1;
hr = m_pD3DDev->StretchRect(m_pVideoSurface[m_nCurSurface], rSrcVid, pBackBuffer, rDstVid, m_filter);
- if(FAILED(hr)) return false;
+ if(FAILED(hr)) {
+ return false;
+ }
}
}
}
AlphaBltSubPic(rSrcPri.Size());
- if (m_VMR9AlphaBitmap.dwFlags & VMRBITMAP_UPDATE)
- {
+ 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_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)))
- {
+ 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))
- {
+ if (FAILED (hr)) {
m_pOSDTexture = NULL;
m_pOSDSurface = NULL;
}
@@ -1844,111 +1751,123 @@ STDMETHODIMP_(bool) CBaseAP::Paint(bool fAll)
}
m_VMR9AlphaBitmap.dwFlags ^= VMRBITMAP_UPDATE;
}
- if (pApp->m_fDisplayStats) DrawStats();
- if (m_pOSDTexture) AlphaBlt(rSrcPri, rDstPri, m_pOSDTexture);
+ if (pApp->m_fDisplayStats) {
+ DrawStats();
+ }
+ if (m_pOSDTexture) {
+ AlphaBlt(rSrcPri, rDstPri, m_pOSDTexture);
+ }
m_pD3DDev->EndScene();
- if (m_pD3DDevEx)
- {
- if (m_bIsFullscreen)
+ if (m_pD3DDevEx) {
+ if (m_bIsFullscreen) {
hr = m_pD3DDevEx->PresentEx(NULL, NULL, NULL, NULL, NULL);
- else
+ } else {
hr = m_pD3DDevEx->PresentEx(rSrcPri, rDstPri, NULL, NULL, NULL);
- }
- else
- {
- if (m_bIsFullscreen)
+ }
+ } else {
+ if (m_bIsFullscreen) {
hr = m_pD3DDev->Present(NULL, NULL, NULL, NULL);
- else
+ } else {
hr = m_pD3DDev->Present(rSrcPri, rDstPri, NULL, NULL);
+ }
+ }
+ if(FAILED(hr)) {
+ _tprintf(_T("Device lost or something\n"));
}
- if(FAILED(hr)) _tprintf(_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
+ 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
+ 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 (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
+ 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;
+ 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
+ if (abs(m_dCycleDifference) < 0.05) { // If less than 5% speed difference
m_bSnapToVSync = true;
- else
+ } else {
m_bSnapToVSync = false;
+ }
// Check how well audio is matching rate (if at all)
DWORD tmp;
- if (m_pAudioStats != NULL)
- {
+ 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)
- {
+ 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)
+ if(hr == D3DERR_DEVICELOST && m_pD3DDev->TestCooperativeLevel() == D3DERR_DEVICENOTRESET || hr == S_PRESENT_MODE_CHANGED) {
fResetDevice = true;
- if (SettingsNeedResetDevice())
+ }
+ if (SettingsNeedResetDevice()) {
fResetDevice = true;
+ }
BOOL bCompositionEnabled = false;
- if (m_pDwmIsCompositionEnabled) m_pDwmIsCompositionEnabled(&bCompositionEnabled);
- if ((bCompositionEnabled != 0) != m_bCompositionEnabled)
- {
- if (m_bIsFullscreen)
- {
+ if (m_pDwmIsCompositionEnabled) {
+ m_pDwmIsCompositionEnabled(&bCompositionEnabled);
+ }
+ if ((bCompositionEnabled != 0) != m_bCompositionEnabled) {
+ if (m_bIsFullscreen) {
m_bCompositionEnabled = (bCompositionEnabled != 0);
- }
- else
+ } else {
fResetDevice = true;
+ }
}
- if(s.fResetDevice)
- {
+ if(s.fResetDevice) {
LONGLONG time = GetRenderersData()->GetPerfCounter();
- if (time > m_LastAdapterCheck + 20000000) // check every 2 sec.
- {
+ if (time > m_LastAdapterCheck + 20000000) { // check every 2 sec.
m_LastAdapterCheck = time;
#ifdef _DEBUG
D3DDEVICE_CREATION_PARAMETERS Parameters;
- if(SUCCEEDED(m_pD3DDev->GetCreationParameters(&Parameters)))
- {
+ if(SUCCEEDED(m_pD3DDev->GetCreationParameters(&Parameters))) {
ASSERT(Parameters.AdapterOrdinal == m_CurrentAdapter);
}
#endif
- if(m_CurrentAdapter != GetAdapter(m_pD3D))
- {
+ if(m_CurrentAdapter != GetAdapter(m_pD3D)) {
fResetDevice = true;
}
#ifdef _DEBUG
- else
- {
+ else {
ASSERT(m_pD3D->GetAdapterMonitor(m_CurrentAdapter) == m_pD3D->GetAdapterMonitor(GetAdapter(m_pD3D)));
}
#endif
}
}
- if(fResetDevice)
- {
+ if(fResetDevice) {
m_bPendingResetDevice = true;
SendResetRequest();
}
@@ -1957,8 +1876,7 @@ STDMETHODIMP_(bool) CBaseAP::Paint(bool fAll)
void CBaseAP::SendResetRequest()
{
- if (!m_bDeviceResetRequested)
- {
+ if (!m_bDeviceResetRequested) {
m_bDeviceResetRequested = true;
AfxGetApp()->m_pMainWnd->PostMessage(WM_RESET_DEVICE);
}
@@ -1969,8 +1887,7 @@ STDMETHODIMP_(bool) CBaseAP::ResetDevice()
DeleteSurfaces();
HRESULT hr;
CString Error;
- if(FAILED(hr = CreateDXDevice(Error)) || FAILED(hr = AllocSurfaces()))
- {
+ if(FAILED(hr = CreateDXDevice(Error)) || FAILED(hr = AllocSurfaces())) {
m_bDeviceResetRequested = false;
return false;
}
@@ -1984,39 +1901,50 @@ STDMETHODIMP_(bool) CBaseAP::ResetDevice()
void CBaseAP::DrawText(const RECT &rc, const CString &strText, int _Priority)
{
- if (_Priority < 1) return;
+ 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)
+ if (Quality == 1) {
OffsetRect(&Rect2 , 2, 2);
- else
+ } else {
OffsetRect(&Rect2 , -1, -1);
- if (Quality > 0)
+ }
+ if (Quality > 0) {
m_pFont->DrawText(m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
+ }
OffsetRect (&Rect2 , 1, 0);
- if (Quality > 3)
+ if (Quality > 3) {
m_pFont->DrawText(m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
+ }
OffsetRect (&Rect2 , 1, 0);
- if (Quality > 2)
+ if (Quality > 2) {
m_pFont->DrawText(m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
+ }
OffsetRect (&Rect2 , 0, 1);
- if (Quality > 3)
+ if (Quality > 3) {
m_pFont->DrawText(m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
+ }
OffsetRect (&Rect2 , 0, 1);
- if (Quality > 1)
+ if (Quality > 1) {
m_pFont->DrawText(m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
+ }
OffsetRect (&Rect2 , -1, 0);
- if (Quality > 3)
+ if (Quality > 3) {
m_pFont->DrawText( m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
+ }
OffsetRect (&Rect2 , -1, 0);
- if (Quality > 2)
+ if (Quality > 2) {
m_pFont->DrawText(m_pSprite, strText, -1, &Rect2, DT_NOCLIP, Color0);
+ }
OffsetRect (&Rect2 , 0, -1);
- if (Quality > 3)
+ 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);
}
@@ -2030,8 +1958,7 @@ void CBaseAP::DrawStats()
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)
- {
+ if (m_pFont && m_pSprite) {
m_pSprite->Begin(D3DXSPRITE_ALPHABLEND);
CString strText;
int TextHeight = 25.0*m_TextScale + 0.5;
@@ -2040,8 +1967,7 @@ void CBaseAP::DrawStats()
DrawText(rc, strText, 1);
OffsetRect(&rc, 0, TextHeight);
- if (pApp->m_fDisplayStats == 1)
- {
+ if (pApp->m_fDisplayStats == 1) {
strText.Format(L"Frame cycle: %.3f ms [%.3f ms, %.3f ms] | Frame rate: %.3f fps", m_dFrameCycle, m_pGenlock->minFrameCycle, m_pGenlock->maxFrameCycle, m_fps);
DrawText(rc, strText, 1);
OffsetRect(&rc, 0, TextHeight);
@@ -2062,32 +1988,27 @@ void CBaseAP::DrawStats()
DrawText(rc, strText, 1);
OffsetRect(&rc, 0, TextHeight);
- if (m_pGenlock->powerstripTimingExists)
- {
+ if (m_pGenlock->powerstripTimingExists) {
strText.Format(L"Display cycle from Powerstrip: %.3f ms | Display refresh rate from Powerstrip: %.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)
- {
+ if ((m_caps.Caps & D3DCAPS_READ_SCANLINE) == 0) {
strText.Format(L"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)
- {
+ if (m_pD3DDevEx) {
CComPtr<IDirect3DSwapChain9> pSC;
HRESULT hr = m_pD3DDevEx->GetSwapChain(0, &pSC);
CComQIPtr<IDirect3DSwapChain9Ex> pSCEx = pSC;
- if (pSCEx)
- {
+ if (pSCEx) {
D3DPRESENTSTATS stats;
hr = pSCEx->GetPresentStats(&stats);
- if (SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
strText.Format(L"Graphics device present stats:");
DrawText(rc, strText, 1);
OffsetRect(&rc, 0, TextHeight);
@@ -2104,9 +2025,7 @@ void CBaseAP::DrawStats()
stats.SyncQPCTime.QuadPart / Freq.QuadPart, stats.SyncGPUTime.QuadPart / Freq.QuadPart);
DrawText(rc, strText, 1);
OffsetRect(&rc, 0, TextHeight);
- }
- else
- {
+ } else {
strText.Format(L"Graphics device does not support present stats");
DrawText(rc, strText, 1);
OffsetRect(&rc, 0, TextHeight);
@@ -2123,16 +2042,12 @@ void CBaseAP::DrawStats()
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())
- {
+ if (s.m_RenderSettings.bSynchronizeDisplay || s.m_RenderSettings.bSynchronizeVideo) {
+ if (s.m_RenderSettings.bSynchronizeDisplay && !m_pGenlock->PowerstripRunning()) {
strText.Format(L"PowerStrip is not running. No display sync is possible.");
DrawText(rc, strText, 1);
OffsetRect(&rc, 0, TextHeight);
- }
- else
- {
+ } else {
strText.Format(L"Sync adjustment: %d | # of adjustments: %d", m_pGenlock->adjDelta, (m_pGenlock->clockAdjustmentsMade + m_pGenlock->displayAdjustmentsMade) / 2);
DrawText(rc, strText, 1);
OffsetRect(&rc, 0, TextHeight);
@@ -2144,8 +2059,7 @@ void CBaseAP::DrawStats()
DrawText(rc, strText, 1);
OffsetRect(&rc, 0, TextHeight);
- if (pApp->m_fDisplayStats < 3)
- {
+ if (pApp->m_fDisplayStats < 3) {
strText.Format(L"# of sync glitches: %d", m_uSyncGlitches);
DrawText(rc, strText, 1);
OffsetRect(&rc, 0, TextHeight);
@@ -2155,10 +2069,8 @@ void CBaseAP::DrawStats()
OffsetRect(&rc, 0, TextHeight);
}
- if (pApp->m_fDisplayStats == 1)
- {
- if (m_pAudioStats && s.m_RenderSettings.bSynchronizeVideo)
- {
+ 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);
@@ -2167,8 +2079,7 @@ void CBaseAP::DrawStats()
strText.Format(L"Sample waiting time: %d ms", m_lNextSampleWait);
DrawText(rc, strText, 1);
OffsetRect(&rc, 0, TextHeight);
- if (s.m_RenderSettings.bSynchronizeNearest)
- {
+ if (s.m_RenderSettings.bSynchronizeNearest) {
strText.Format(L"Sample paint time correction: %2d ms | Hysteresis: %d", m_lShiftToNearest, m_llHysteresis /10000);
DrawText(rc, strText, 1);
OffsetRect(&rc, 0, TextHeight);
@@ -2180,22 +2091,29 @@ void CBaseAP::DrawStats()
strText.Format(L"Settings: ");
- if (m_bIsFullscreen)
+ if (m_bIsFullscreen) {
strText += "D3DFS ";
- if (s.m_RenderSettings.iVMRDisableDesktopComposition)
+ }
+ if (s.m_RenderSettings.iVMRDisableDesktopComposition) {
strText += "DisDC ";
- if (s.m_RenderSettings.bSynchronizeVideo)
+ }
+ if (s.m_RenderSettings.bSynchronizeVideo) {
strText += "SyncVideo ";
- if (s.m_RenderSettings.bSynchronizeDisplay)
+ }
+ if (s.m_RenderSettings.bSynchronizeDisplay) {
strText += "SyncDisplay ";
- if (s.m_RenderSettings.bSynchronizeNearest)
+ }
+ if (s.m_RenderSettings.bSynchronizeNearest) {
strText += "SyncNearest ";
- if (m_bHighColorResolution)
+ }
+ if (m_bHighColorResolution) {
strText += "10 bit ";
- if (s.m_RenderSettings.iEVROutputRange == 0)
+ }
+ if (s.m_RenderSettings.iEVROutputRange == 0) {
strText += "0-255 ";
- else if (s.m_RenderSettings.iEVROutputRange == 1)
+ } else if (s.m_RenderSettings.iEVROutputRange == 1) {
strText += "16-235 ";
+ }
DrawText(rc, strText, 1);
OffsetRect(&rc, 0, TextHeight);
@@ -2208,10 +2126,8 @@ void CBaseAP::DrawStats()
DrawText(rc, strText, 1);
OffsetRect(&rc, 0, TextHeight);
- for (int i=0; i<6; i++)
- {
- if (m_strStatsMsg[i][0])
- {
+ for (int i=0; i<6; i++) {
+ if (m_strStatsMsg[i][0]) {
DrawText(rc, m_strStatsMsg[i], 1);
OffsetRect(&rc, 0, TextHeight);
}
@@ -2221,8 +2137,7 @@ void CBaseAP::DrawStats()
m_pSprite->End();
}
- if (m_pLine && (pApp->m_fDisplayStats < 3))
- {
+ if (m_pLine && (pApp->m_fDisplayStats < 3)) {
D3DXVECTOR2 Points[NB_JITTER];
int nIndex;
@@ -2237,8 +2152,7 @@ void CBaseAP::DrawStats()
m_pLine->SetAntialias(1);
m_pLine->Begin();
- for (int i = 0; i <= DrawHeight; i += 5)
- {
+ 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));
@@ -2246,8 +2160,7 @@ void CBaseAP::DrawStats()
m_pLine->Draw(Points, 2, D3DCOLOR_XRGB(100, 100, 255));
}
- for (int i = 0; i < DrawWidth; i += 125) // Every 25:th sample
- {
+ 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);
@@ -2255,24 +2168,23 @@ void CBaseAP::DrawStats()
m_pLine->Draw(Points, 2, D3DCOLOR_XRGB(100, 100, 255));
}
- for (int i = 0; i < NB_JITTER; i++)
- {
+ for (int i = 0; i < NB_JITTER; i++) {
nIndex = (m_nNextJitter + 1 + i) % NB_JITTER;
- if (nIndex < 0)
+ 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++)
- {
+ 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)
+ if (nIndex < 0) {
nIndex += NB_JITTER;
+ }
Points[i].x = (FLOAT)(StartX + (i * 5));
Points[i].y = (FLOAT)(StartY + ((m_pllSyncOffset[nIndex]) / 2000 + 125));
}
@@ -2284,14 +2196,20 @@ void CBaseAP::DrawStats()
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()
@@ -2299,16 +2217,13 @@ double CBaseAP::GetCycleDifference()
double dBaseDisplayCycle = GetDisplayCycle();
UINT i;
double minDiff = 1.0;
- if (dBaseDisplayCycle == 0.0 || m_dFrameCycle == 0.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
- {
+ } 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))
- {
+ if (abs(diff) < abs(minDiff)) {
minDiff = diff;
m_dOptimumDisplayCycle = dDisplayCycle;
}
@@ -2319,13 +2234,16 @@ double CBaseAP::GetCycleDifference()
void CBaseAP::EstimateRefreshTimings()
{
- if (m_pD3DDev)
- {
+ 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);
+ 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;
@@ -2334,32 +2252,35 @@ void CBaseAP::EstimateRefreshTimings()
UINT endLine = 0;
UINT line = 0;
bool done = false;
- while (!done) // Estimate time for one scan line
- {
+ while (!done) { // Estimate time for one scan line
m_pD3DDev->GetRasterStatus(0, &rasterStatus);
line = rasterStatus.ScanLine;
time = pApp->GetPerfCounter();
- if (line > 0)
- {
+ if (line > 0) {
endLine = line;
endTime = time;
- }
- else
+ } 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);
+ 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++)
- {
+ 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);
+ 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();
@@ -2369,16 +2290,17 @@ void CBaseAP::EstimateRefreshTimings()
bool CBaseAP::ExtractInterlaced(const AM_MEDIA_TYPE* pmt)
{
- if (pmt->formattype==FORMAT_VideoInfo)
+ if (pmt->formattype==FORMAT_VideoInfo) {
return false;
- else if (pmt->formattype==FORMAT_VideoInfo2)
+ } else if (pmt->formattype==FORMAT_VideoInfo2) {
return (((VIDEOINFOHEADER2*)pmt->pbFormat)->dwInterlaceFlags & AMINTERLACE_IsInterlaced) != 0;
- else if (pmt->formattype==FORMAT_MPEGVideo)
+ } else if (pmt->formattype==FORMAT_MPEGVideo) {
return false;
- else if (pmt->formattype==FORMAT_MPEG2Video)
+ } else if (pmt->formattype==FORMAT_MPEG2Video) {
return (((MPEG2VIDEOINFO*)pmt->pbFormat)->hdr.dwInterlaceFlags & AMINTERLACE_IsInterlaced) != 0;
- else
+ } else {
return false;
+ }
}
STDMETHODIMP CBaseAP::GetDIB(BYTE* lpDib, DWORD* size)
@@ -2392,23 +2314,24 @@ STDMETHODIMP CBaseAP::GetDIB(BYTE* lpDib, DWORD* size)
m_pVideoSurface[m_nCurSurface]->GetDesc(&desc);
DWORD required = sizeof(BITMAPINFOHEADER) + (desc.Width * desc.Height * 32 >> 3);
- if(!lpDib)
- {
+ if(!lpDib) {
*size = required;
return S_OK;
}
- if(*size < required) return E_OUTOFMEMORY;
+ 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)))
- {
+ 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)))
+ || FAILED(hr = pSurface->LockRect(&r, NULL, D3DLOCK_READONLY))) {
return hr;
+ }
}
BITMAPINFOHEADER* bih = (BITMAPINFOHEADER*)lpDib;
@@ -2440,20 +2363,21 @@ STDMETHODIMP CBaseAP::SetPixelShader2(LPCSTR pSrcData, LPCSTR pTarget, bool bScr
CAutoLock cRenderLock(&m_allocatorLock);
CAtlList<CExternalPixelShader> *pPixelShaders;
- if (bScreenSpace)
+ if (bScreenSpace) {
pPixelShaders = &m_pPixelShadersScreenSpace;
- else
+ } else {
pPixelShaders = &m_pPixelShaders;
+ }
- if(!pSrcData && !pTarget)
- {
+ if(!pSrcData && !pTarget) {
pPixelShaders->RemoveAll();
m_pD3DDev->SetPixelShader(NULL);
return S_OK;
}
- if(!pSrcData || !pTarget)
+ if(!pSrcData || !pTarget) {
return E_INVALIDARG;
+ }
CExternalPixelShader Shader;
Shader.m_SourceData = pSrcData;
@@ -2462,8 +2386,9 @@ STDMETHODIMP CBaseAP::SetPixelShader2(LPCSTR pSrcData, LPCSTR pTarget, bool bScr
CComPtr<IDirect3DPixelShader9> pPixelShader;
HRESULT hr = Shader.Compile(m_pPSC);
- if(FAILED(hr))
+ if(FAILED(hr)) {
return hr;
+ }
pPixelShaders->AddTail(Shader);
Paint(true);
@@ -2485,8 +2410,7 @@ CSyncAP::CSyncAP(HWND hWnd, bool bFullscreen, HRESULT& hr, CString &_Error): CBa
m_bEvtQuit = 0;
m_bEvtFlush = 0;
- if (FAILED (hr))
- {
+ if (FAILED (hr)) {
_Error += L"SyncAP failed\n";
return;
}
@@ -2501,16 +2425,19 @@ CSyncAP::CSyncAP(HWND hWnd, bool bFullscreen, HRESULT& hr, CString &_Error): CBa
pfMFCreateVideoSampleFromSurface = hLib ? (PTR_MFCreateVideoSampleFromSurface)GetProcAddress (hLib, "MFCreateVideoSampleFromSurface") : NULL;
pfMFCreateVideoMediaType = hLib ? (PTR_MFCreateVideoMediaType)GetProcAddress (hLib, "MFCreateVideoMediaType") : NULL;
- if (!pfDXVA2CreateDirect3DDeviceManager9 || !pfMFCreateDXSurfaceBuffer || !pfMFCreateVideoSampleFromSurface || !pfMFCreateVideoMediaType)
- {
- if (!pfDXVA2CreateDirect3DDeviceManager9)
+ if (!pfDXVA2CreateDirect3DDeviceManager9 || !pfMFCreateDXSurfaceBuffer || !pfMFCreateVideoSampleFromSurface || !pfMFCreateVideoMediaType) {
+ if (!pfDXVA2CreateDirect3DDeviceManager9) {
_Error += L"Could not find DXVA2CreateDirect3DDeviceManager9 (dxva2.dll)\n";
- if (!pfMFCreateDXSurfaceBuffer)
+ }
+ if (!pfMFCreateDXSurfaceBuffer) {
_Error += L"Could not find MFCreateDXSurfaceBuffer (evr.dll)\n";
- if (!pfMFCreateVideoSampleFromSurface)
+ }
+ if (!pfMFCreateVideoSampleFromSurface) {
_Error += L"Could not find MFCreateVideoSampleFromSurface (evr.dll)\n";
- if (!pfMFCreateVideoMediaType)
+ }
+ if (!pfMFCreateVideoMediaType) {
_Error += L"Could not find MFCreateVideoMediaType (evr.dll)\n";
+ }
hr = E_FAIL;
return;
}
@@ -2523,31 +2450,29 @@ CSyncAP::CSyncAP(HWND hWnd, bool bFullscreen, HRESULT& hr, CString &_Error): CBa
// Init DXVA manager
hr = pfDXVA2CreateDirect3DDeviceManager9(&m_nResetToken, &m_pD3DManager);
- if (SUCCEEDED (hr))
- {
+ if (SUCCEEDED (hr)) {
hr = m_pD3DManager->ResetDevice(m_pD3DDev, m_nResetToken);
- if (!SUCCEEDED (hr))
- {
+ if (!SUCCEEDED (hr)) {
_Error += L"m_pD3DManager->ResetDevice failed\n";
}
- }
- else
+ } 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)))
- {
+ 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)
+ if (s.iAPSurfaceUsage == VIDRNDT_AP_TEXTURE3D) {
m_nDXSurface = max(min (s.iEvrBuffers, MAX_PICTURE_SLOTS-2), 4);
- else
+ } else {
m_nDXSurface = 1;
+ }
m_nRenderState = Shutdown;
m_bStepping = false;
@@ -2575,15 +2500,17 @@ CSyncAP::~CSyncAP(void)
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)
- {
+ 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);
@@ -2597,30 +2524,37 @@ void CSyncAP::StartWorkerThreads()
void CSyncAP::StopWorkerThreads()
{
- if (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))
- {
+ 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))
- {
+ 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_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);
+ 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;
@@ -2635,8 +2569,7 @@ STDMETHODIMP CSyncAP::CreateRenderer(IUnknown** ppRenderer)
*ppRenderer = NULL;
HRESULT hr = E_FAIL;
- do
- {
+ do {
CMacrovisionKicker* pMK = DNew CMacrovisionKicker(NAME("CMacrovisionKicker"), NULL);
CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)pMK;
@@ -2646,7 +2579,9 @@ STDMETHODIMP CSyncAP::CreateRenderer(IUnknown** ppRenderer)
pMK->SetInner((IUnknown*)(INonDelegatingUnknown*)pOuterEVR);
CComQIPtr<IBaseFilter> pBF = pUnk;
- if (FAILED(hr)) break;
+ if (FAILED(hr)) {
+ break;
+ }
// Set EVR custom presenter
CComPtr<IMFVideoPresenter> pVP;
@@ -2655,19 +2590,23 @@ STDMETHODIMP CSyncAP::CreateRenderer(IUnknown** ppRenderer)
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;
m_bUseInternalTimer = HookNewSegmentAndReceive((IPinC*)(IPin*)pPin, (IMemInputPinC*)(IMemInputPin*)pMemInputPin);
- if(FAILED(hr))
+ if(FAILED(hr)) {
*ppRenderer = NULL;
- else
+ } else {
*ppRenderer = pBF.Detach();
- }
- while (0);
+ }
+ } while (0);
return hr;
}
@@ -2680,32 +2619,33 @@ STDMETHODIMP_(bool) CSyncAP::Paint(bool fAll)
STDMETHODIMP CSyncAP::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
HRESULT hr;
- if(riid == __uuidof(IMFClockStateSink))
+ if(riid == __uuidof(IMFClockStateSink)) {
hr = GetInterface((IMFClockStateSink*)this, ppv);
- else if(riid == __uuidof(IMFVideoPresenter))
+ } else if(riid == __uuidof(IMFVideoPresenter)) {
hr = GetInterface((IMFVideoPresenter*)this, ppv);
- else if(riid == __uuidof(IMFTopologyServiceLookupClient))
+ } else if(riid == __uuidof(IMFTopologyServiceLookupClient)) {
hr = GetInterface((IMFTopologyServiceLookupClient*)this, ppv);
- else if(riid == __uuidof(IMFVideoDeviceID))
+ } else if(riid == __uuidof(IMFVideoDeviceID)) {
hr = GetInterface((IMFVideoDeviceID*)this, ppv);
- else if(riid == __uuidof(IMFGetService))
+ } else if(riid == __uuidof(IMFGetService)) {
hr = GetInterface((IMFGetService*)this, ppv);
- else if(riid == __uuidof(IMFAsyncCallback))
+ } else if(riid == __uuidof(IMFAsyncCallback)) {
hr = GetInterface((IMFAsyncCallback*)this, ppv);
- else if(riid == __uuidof(IMFVideoDisplayControl))
+ } else if(riid == __uuidof(IMFVideoDisplayControl)) {
hr = GetInterface((IMFVideoDisplayControl*)this, ppv);
- else if(riid == __uuidof(IEVRTrustedVideoPlugin))
+ } else if(riid == __uuidof(IEVRTrustedVideoPlugin)) {
hr = GetInterface((IEVRTrustedVideoPlugin*)this, ppv);
- else if(riid == IID_IQualProp)
+ } else if(riid == IID_IQualProp) {
hr = GetInterface((IQualProp*)this, ppv);
- else if(riid == __uuidof(IMFRateSupport))
+ } else if(riid == __uuidof(IMFRateSupport)) {
hr = GetInterface((IMFRateSupport*)this, ppv);
- else if(riid == __uuidof(IDirect3DDeviceManager9))
+ } else if(riid == __uuidof(IDirect3DDeviceManager9)) {
hr = m_pD3DManager->QueryInterface (__uuidof(IDirect3DDeviceManager9), (void**) ppv);
- else if(riid == __uuidof(ISyncClockAdviser))
+ } else if(riid == __uuidof(ISyncClockAdviser)) {
hr = GetInterface((ISyncClockAdviser*)this, ppv);
- else
+ } else {
hr = __super::NonDelegatingQueryInterface(riid, ppv);
+ }
return hr;
}
@@ -2744,20 +2684,19 @@ STDMETHODIMP CSyncAP::OnClockSetRate(MFTIME hnsSystemTime, float flRate)
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;
+ 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;
@@ -2816,8 +2755,9 @@ STDMETHODIMP CSyncAP::GetFastestRate(MFRATE_DIRECTION eDirection, BOOL fThin, fl
fMaxRate = GetMaxRate(fThin);
// For reverse playback, swap the sign.
- if (eDirection == MFRATE_REVERSE)
+ if (eDirection == MFRATE_REVERSE) {
fMaxRate = -fMaxRate;
+ }
*pflRate = fMaxRate;
return hr;
@@ -2838,21 +2778,21 @@ STDMETHODIMP CSyncAP::IsRateSupported(BOOL fThin, float flRate, float *pflNeares
// Find the maximum forward rate.
fMaxRate = GetMaxRate(fThin);
- if (fabsf(flRate) > fMaxRate)
- {
+ 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)
- {
+ 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;
+ if (pflNearestSupportedRate != NULL) {
+ *pflNearestSupportedRate = fNearestRate;
+ }
return hr;
}
@@ -2862,8 +2802,7 @@ float CSyncAP::GetMaxRate(BOOL bThin)
UINT32 fpsNumerator = 0, fpsDenominator = 0;
UINT MonitorRateHz = 0;
- if (!bThin && (m_pMediaType != NULL))
- {
+ if (!bThin && (m_pMediaType != NULL)) {
// Non-thinned: Use the frame rate and monitor refresh rate.
// Frame rate:
@@ -2873,8 +2812,7 @@ float CSyncAP::GetMaxRate(BOOL bThin)
// Monitor refresh rate:
MonitorRateHz = m_uD3DRefreshRate; // D3DDISPLAYMODE
- if (fpsDenominator && fpsNumerator && MonitorRateHz)
- {
+ if (fpsDenominator && fpsNumerator && MonitorRateHz) {
// Max Rate = Refresh Rate / Frame Rate
fMaxRate = (float)MulDiv(MonitorRateHz, fpsDenominator, fpsNumerator);
}
@@ -2884,15 +2822,13 @@ float CSyncAP::GetMaxRate(BOOL bThin)
void CSyncAP::CompleteFrameStep(bool bCancel)
{
- if (m_nStepCount > 0)
- {
- if (bCancel || (m_nStepCount == 1))
- {
+ if (m_nStepCount > 0) {
+ if (bCancel || (m_nStepCount == 1)) {
m_pSink->Notify(EC_STEP_COMPLETE, bCancel ? TRUE : FALSE, 0);
m_nStepCount = 0;
- }
- else
+ } else {
m_nStepCount--;
+ }
}
}
@@ -2901,51 +2837,54 @@ STDMETHODIMP CSyncAP::ProcessMessage(MFVP_MESSAGE_TYPE eMessage, ULONG_PTR ulPar
{
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;
+ switch (eMessage) {
+ case MFVP_MESSAGE_BEGINSTREAMING:
+ hr = BeginStreaming();
+ m_llHysteresis = 0;
+ m_lShiftToNearest = 0;
+ m_bStepping = false;
+ break;
- case MFVP_MESSAGE_INVALIDATEMEDIATYPE:
- m_bPendingRenegotiate = true;
- while (*((volatile bool *)&m_bPendingRenegotiate)) Sleep(1);
- break;
+ case MFVP_MESSAGE_CANCELSTEP:
+ m_bStepping = false;
+ CompleteFrameStep(true);
+ break;
- case MFVP_MESSAGE_PROCESSINPUTNOTIFY:
- 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_STEP:
- m_nStepCount = ulParam;
- m_bStepping = true;
- break;
+ case MFVP_MESSAGE_INVALIDATEMEDIATYPE:
+ m_bPendingRenegotiate = true;
+ while (*((volatile bool *)&m_bPendingRenegotiate)) {
+ Sleep(1);
+ }
+ break;
+
+ case MFVP_MESSAGE_PROCESSINPUTNOTIFY:
+ break;
- default :
- ASSERT(FALSE);
- break;
+ case MFVP_MESSAGE_STEP:
+ m_nStepCount = ulParam;
+ m_bStepping = true;
+ break;
+
+ default :
+ ASSERT(FALSE);
+ break;
}
return hr;
}
@@ -2959,7 +2898,9 @@ HRESULT CSyncAP::IsMediaTypeSupported(IMFMediaType* pMixerType)
CheckHR (pMixerType->GetRepresentation(FORMAT_VideoInfo2, (void**)&pAMMedia));
CheckHR (pMixerType->GetUINT32 (MF_MT_INTERLACE_MODE, &nInterlaceMode));
- if ( (pAMMedia->majortype != MEDIATYPE_Video)) hr = MF_E_INVALIDMEDIATYPE;
+ if ( (pAMMedia->majortype != MEDIATYPE_Video)) {
+ hr = MF_E_INVALIDMEDIATYPE;
+ }
pMixerType->FreeRepresentation(FORMAT_VideoInfo2, (void*)pAMMedia);
return hr;
}
@@ -2979,18 +2920,18 @@ HRESULT CSyncAP::CreateProposedOutputType(IMFMediaType* pMixerType, IMFMediaType
m_AspectRatio.cx = VideoFormat->videoInfo.PixelAspectRatio.Numerator;
m_AspectRatio.cy = VideoFormat->videoInfo.PixelAspectRatio.Denominator;
- if (SUCCEEDED (hr))
- {
+ 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)
+ if (s.m_RenderSettings.iEVROutputRange == 1) {
m_pMediaType->SetUINT32(MF_MT_VIDEO_NOMINAL_RANGE, MFNominalRange_16_235);
- else
+ } else {
m_pMediaType->SetUINT32(MF_MT_VIDEO_NOMINAL_RANGE, MFNominalRange_0_255);
+ }
m_LastSetOutputRange = s.m_RenderSettings.iEVROutputRange;
i64Size.HighPart = m_AspectRatio.cx;
@@ -3006,20 +2947,17 @@ HRESULT CSyncAP::CreateProposedOutputType(IMFMediaType* pMixerType, IMFMediaType
bool bDoneSomething = true;
- if(m_AspectRatio.cx >= 1 && m_AspectRatio.cy >= 1)
- {
- while (bDoneSomething)
- {
+ 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)
+ for (i = 2; i < MinNum+1; ++i) {
+ if (m_AspectRatio.cx%i == 0 && m_AspectRatio.cy%i ==0) {
break;
+ }
}
- if (i != MinNum + 1)
- {
+ if (i != MinNum + 1) {
m_AspectRatio.cx = m_AspectRatio.cx / i;
m_AspectRatio.cy = m_AspectRatio.cy / i;
bDoneSomething = true;
@@ -3043,8 +2981,7 @@ HRESULT CSyncAP::SetMediaType(IMFMediaType* pType)
CheckHR(pType->GetRepresentation(FORMAT_VideoInfo2, (void**)&pAMMedia));
hr = InitializeDevice(pAMMedia);
- if (SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
strTemp = GetMediaTypeName(pAMMedia->subtype);
strTemp.Replace(L"MEDIASUBTYPE_", L"");
m_strStatsMsg[MSG_MIXEROUT].Format (L"Mixer output: %s", strTemp);
@@ -3055,8 +2992,7 @@ HRESULT CSyncAP::SetMediaType(IMFMediaType* pType)
return hr;
}
-typedef struct
-{
+typedef struct {
const int Format;
const LPCTSTR Description;
} D3DFORMAT_TYPE;
@@ -3071,30 +3007,29 @@ LONGLONG CSyncAP::GetMediaTypeMerit(IMFMediaType *pMediaType)
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;
+ 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;
@@ -3107,72 +3042,68 @@ HRESULT CSyncAP::RenegotiateMediaType()
CComPtr<IMFMediaType> pMixerType;
CComPtr<IMFMediaType> pType;
- if (!m_pMixer) return MF_E_INVALIDREQUEST;
+ 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))
- {
+ 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))
- {
+ if (FAILED(hr)) {
break;
}
// Step 2. Check if we support this media type.
- if (SUCCEEDED(hr))
+ if (SUCCEEDED(hr)) {
hr = IsMediaTypeSupported(pMixerType);
- if (SUCCEEDED(hr))
+ }
+ if (SUCCEEDED(hr)) {
hr = CreateProposedOutputType(pMixerType, &pType);
+ }
// Step 4. Check if the mixer will accept this media type.
- if (SUCCEEDED(hr))
+ if (SUCCEEDED(hr)) {
hr = m_pMixer->SetOutputType(0, pType, MFT_SET_TYPE_TEST_ONLY);
- if (SUCCEEDED(hr))
- {
+ }
+ if (SUCCEEDED(hr)) {
LONGLONG Merit = GetMediaTypeMerit(pType);
int nTypes = ValidMixerTypes.GetCount();
int iInsertPos = 0;
- for (int i = 0; i < nTypes; ++i)
- {
+ for (int i = 0; i < nTypes; ++i) {
LONGLONG ThisMerit = GetMediaTypeMerit(ValidMixerTypes[i]);
- if (Merit > ThisMerit)
- {
+ if (Merit > ThisMerit) {
iInsertPos = i;
break;
- }
- else
+ } else {
iInsertPos = i+1;
+ }
}
ValidMixerTypes.InsertAt(iInsertPos, pType);
}
}
int nValidTypes = ValidMixerTypes.GetCount();
- for (int i = 0; i < nValidTypes; ++i)
- {
+ for (int i = 0; i < nValidTypes; ++i) {
pType = ValidMixerTypes[i];
}
- for (int i = 0; i < nValidTypes; ++i)
- {
+ for (int i = 0; i < nValidTypes; ++i) {
pType = ValidMixerTypes[i];
hr = SetMediaType(pType);
- if (SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
hr = m_pMixer->SetOutputType(0, pType, 0);
// If something went wrong, clear the media type.
- if (FAILED(hr))
- {
+ if (FAILED(hr)) {
SetMediaType(NULL);
- }
- else
+ } else {
break;
+ }
}
}
@@ -3193,12 +3124,10 @@ bool CSyncAP::GetSampleFromMixer()
UINT dwSurface;
bool newSample = false;
- while(SUCCEEDED(hr)) // Get as many frames as there are and that we have samples for
- {
+ 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
- {
+ if (FAILED(GetFreeSample(&pSample))) { // All samples are taken for the moment. Better luck next time
break;
}
@@ -3211,21 +3140,18 @@ bool CSyncAP::GetSampleFromMixer()
llClockAfter = GetRenderersData()->GetPerfCounter();
}
- if (hr == MF_E_TRANSFORM_NEED_MORE_INPUT) // There are no samples left in the mixer
- {
+ if (hr == MF_E_TRANSFORM_NEED_MORE_INPUT) { // There are no samples left in the mixer
MoveToFreeList(pSample, false);
break;
}
- if (m_pSink)
- {
+ if (m_pSink) {
llMixerLatency = llClockAfter - llClockBefore;
m_pSink->Notify (EC_PROCESSING_LATENCY, (LONG_PTR)&llMixerLatency, 0);
}
newSample = true;
- if (GetRenderersData()->m_fTearingTest)
- {
+ if (GetRenderersData()->m_fTearingTest) {
RECT rcTearing;
rcTearing.left = m_nTearingPos;
@@ -3251,8 +3177,9 @@ STDMETHODIMP CSyncAP::GetCurrentMediaType(__deref_out IMFVideoMediaType **ppMed
CheckPointer(ppMediaType, E_POINTER);
CheckHR(CheckShutdown());
- if (m_pMediaType == NULL)
+ if (m_pMediaType == NULL) {
CheckHR(MF_E_NOT_INITIALIZED);
+ }
CheckHR(m_pMediaType->QueryInterface(__uuidof(IMFVideoMediaType), (void**)&ppMediaType));
return hr;
@@ -3290,10 +3217,11 @@ STDMETHODIMP CSyncAP::GetDeviceID( __out IID *pDeviceID)
// IMFGetService
STDMETHODIMP CSyncAP::GetService( __RPC__in REFGUID guidService, __RPC__in REFIID riid, __RPC__deref_out_opt LPVOID *ppvObject)
{
- if (guidService == MR_VIDEO_RENDER_SERVICE)
+ if (guidService == MR_VIDEO_RENDER_SERVICE) {
return NonDelegatingQueryInterface (riid, ppvObject);
- else if (guidService == MR_VIDEO_ACCELERATION_SERVICE)
+ } else if (guidService == MR_VIDEO_ACCELERATION_SERVICE) {
return m_pD3DManager->QueryInterface (__uuidof(IDirect3DDeviceManager9), (void**) ppvObject);
+ }
return E_NOINTERFACE;
}
@@ -3313,13 +3241,11 @@ STDMETHODIMP CSyncAP::Invoke( __RPC__in_opt IMFAsyncResult *pAsyncResult)
// IMFVideoDisplayControl
STDMETHODIMP CSyncAP::GetNativeVideoSize(SIZE *pszVideo, SIZE *pszARVideo)
{
- if (pszVideo)
- {
+ if (pszVideo) {
pszVideo->cx = m_NativeVideoSize.cx;
pszVideo->cy = m_NativeVideoSize.cy;
}
- if (pszARVideo)
- {
+ if (pszARVideo) {
pszARVideo->cx = m_NativeVideoSize.cx * m_AspectRatio.cx;
pszARVideo->cy = m_NativeVideoSize.cy * m_AspectRatio.cy;
}
@@ -3328,19 +3254,16 @@ STDMETHODIMP CSyncAP::GetNativeVideoSize(SIZE *pszVideo, SIZE *pszARVideo)
STDMETHODIMP CSyncAP::GetIdealVideoSize(SIZE *pszMin, SIZE *pszMax)
{
- if (pszMin)
- {
+ if (pszMin) {
pszMin->cx = 1;
pszMin->cy = 1;
}
- if (pszMax)
- {
+ if (pszMax) {
D3DDISPLAYMODE d3ddm;
ZeroMemory(&d3ddm, sizeof(d3ddm));
- if(SUCCEEDED(m_pD3D->GetAdapterDisplayMode(GetAdapter(m_pD3D), &d3ddm)))
- {
+ if(SUCCEEDED(m_pD3D->GetAdapterDisplayMode(GetAdapter(m_pD3D), &d3ddm))) {
pszMax->cx = d3ddm.Width;
pszMax->cy = d3ddm.Height;
}
@@ -3353,15 +3276,15 @@ STDMETHODIMP CSyncAP::SetVideoPosition(const MFVideoNormalizedRect *pnrcSource,
}
STDMETHODIMP CSyncAP::GetVideoPosition(MFVideoNormalizedRect *pnrcSource, LPRECT prcDest)
{
- if (pnrcSource)
- {
+ 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;
}
STDMETHODIMP CSyncAP::SetAspectRatioMode(DWORD dwAspectRatioMode)
@@ -3495,15 +3418,12 @@ STDMETHODIMP CSyncAP::GetVideoService(HANDLE hDevice, REFIID riid, void **ppServ
{
HRESULT hr = m_pD3DManager->GetVideoService(hDevice, riid, ppService);
- if (riid == __uuidof(IDirectXVideoDecoderService))
- {
+ if (riid == __uuidof(IDirectXVideoDecoderService)) {
UINT nNbDecoder = 5;
GUID* pDecoderGuid;
IDirectXVideoDecoderService* pDXVAVideoDecoder = (IDirectXVideoDecoderService*) *ppService;
pDXVAVideoDecoder->GetDecoderDeviceGuids (&nNbDecoder, &pDecoderGuid);
- }
- else if (riid == __uuidof(IDirectXVideoProcessorService))
- {
+ } else if (riid == __uuidof(IDirectXVideoProcessorService)) {
IDirectXVideoProcessorService* pDXVAProcessor = (IDirectXVideoProcessorService*) *ppService;
UNUSED_ALWAYS(pDXVAProcessor);
}
@@ -3516,10 +3436,18 @@ STDMETHODIMP CSyncAP::GetNativeVideoSize(LONG* lpWidth, LONG* lpHeight, LONG* lp
// 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;
+ 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;
}
@@ -3538,17 +3466,16 @@ STDMETHODIMP CSyncAP::InitializeDevice(AM_MEDIA_TYPE* pMediaType)
int h = abs(vih2->bmiHeader.biHeight);
m_NativeVideoSize = CSize(w, h);
- if (m_bHighColorResolution)
+ if (m_bHighColorResolution) {
hr = AllocSurfaces(D3DFMT_A2R10G10B10);
- else
+ } else {
hr = AllocSurfaces(D3DFMT_X8R8G8B8);
+ }
- for(int i = 0; i < m_nDXSurface; i++)
- {
+ for(int i = 0; i < m_nDXSurface; i++) {
CComPtr<IMFSample> pMFSample;
hr = pfMFCreateVideoSampleFromSurface(m_pVideoSurface[i], &pMFSample);
- if (SUCCEEDED (hr))
- {
+ if (SUCCEEDED (hr)) {
pMFSample->SetUINT32(GUID_SURFACE_INDEX, i);
m_FreeSamples.AddTail (pMFSample);
}
@@ -3577,27 +3504,23 @@ void CSyncAP::MixerThread()
dwResolution = min(max(tc.wPeriodMin, 0), tc.wPeriodMax);
dwUser = timeBeginPeriod(dwResolution);
- while (!bQuit)
- {
+ 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);
+ 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;
+ break;
}
}
timeEndPeriod (dwResolution);
@@ -3627,11 +3550,12 @@ void CSyncAP::RenderThread()
// Tell Vista Multimedia Class Scheduler we are doing threaded playback (increase priority)
HANDLE hAvrt = 0;
- if (pfAvSetMmThreadCharacteristicsW)
- {
+ if (pfAvSetMmThreadCharacteristicsW) {
DWORD dwTaskIndex = 0;
hAvrt = pfAvSetMmThreadCharacteristicsW (L"Playback", &dwTaskIndex);
- if (pfAvSetMmThreadPriority) pfAvSetMmThreadPriority (hAvrt, AVRT_PRIORITY_HIGH);
+ if (pfAvSetMmThreadPriority) {
+ pfAvSetMmThreadPriority (hAvrt, AVRT_PRIORITY_HIGH);
+ }
}
// Set timer resolution
@@ -3640,8 +3564,7 @@ void CSyncAP::RenderThread()
dwUser = timeBeginPeriod(dwResolution);
pNewSample = NULL;
- while (!bQuit)
- {
+ while (!bQuit) {
m_lNextSampleWait = 1; // Default value for running this loop
nSamplesLeft = 0;
bool stepForward = false;
@@ -3652,47 +3575,38 @@ void CSyncAP::RenderThread()
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
- {
+ 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)
- {
+ 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.
- {
+ } 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
- {
+ } 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)
- {
+ 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
- {
+ } 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
+ 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
+ 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
- {
+ 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);
@@ -3702,8 +3616,7 @@ void CSyncAP::RenderThread()
// 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))
- {
+ if (m_lShiftToNearest > (lDisplayCycle + 1)) {
SetEvent(m_hEvtSkip);
m_bEvtSkip = true;
}
@@ -3711,36 +3624,36 @@ void CSyncAP::RenderThread()
// 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_bSnapToVSync) {
- if ((m_lShiftToNearestPrev - m_lShiftToNearest) > lDisplayCycle2) // If a step down in the m_lShiftToNearest function. Display slower than video.
- {
+ 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
- {
+ } 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
}
- 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_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.
- {
+ if (m_lNextSampleWait < 0) { // Skip late or duplicate sample.
SetEvent(m_hEvtSkip);
m_bEvtSkip = true;
}
- if (m_lNextSampleWait > 1000)
- {
+ 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).
}
}
@@ -3749,86 +3662,86 @@ void CSyncAP::RenderThread()
}
// 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;
+ switch (dwObject) {
+ case WAIT_OBJECT_0: // Quit
+ bQuit = 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);
+ case WAIT_OBJECT_0 + 1: // Flush
+ if (pNewSample) {
+ MoveToFreeList(pNewSample, true);
+ }
pNewSample = NULL;
FlushSamples();
- RenegotiateMediaType();
- m_bPendingRenegotiate = false;
- }
+ m_bEvtFlush = false;
+ ResetEvent(m_hEvtFlush);
+ m_bPrerolled = false;
+ m_lShiftToNearest = 0;
+ stepForward = true;
+ break;
- if (m_bPendingResetDevice)
- {
- if (pNewSample)
- MoveToFreeList(pNewSample, true);
- pNewSample = NULL;
- SendResetRequest();
- }
- else if (m_nStepCount < 0)
- {
- m_nStepCount = 0;
+ 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;
- }
- 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;
+ 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)
- {
+ if (pNewSample && stepForward) {
MoveToFreeList(pNewSample, true);
pNewSample = NULL;
}
} // while
- if (pNewSample)
- {
+ if (pNewSample) {
MoveToFreeList(pNewSample, true);
pNewSample = NULL;
}
timeEndPeriod (dwResolution);
- if (pfAvRevertMmThreadCharacteristics) pfAvRevertMmThreadCharacteristics(hAvrt);
+ if (pfAvRevertMmThreadCharacteristics) {
+ pfAvRevertMmThreadCharacteristics(hAvrt);
+ }
}
STDMETHODIMP_(bool) CSyncAP::ResetDevice()
@@ -3840,12 +3753,10 @@ STDMETHODIMP_(bool) CSyncAP::ResetDevice()
bool bResult = __super::ResetDevice();
- for(int i = 0; i < m_nDXSurface; i++)
- {
+ for(int i = 0; i < m_nDXSurface; i++) {
CComPtr<IMFSample> pMFSample;
HRESULT hr = pfMFCreateVideoSampleFromSurface (m_pVideoSurface[i], &pMFSample);
- if (SUCCEEDED (hr))
- {
+ if (SUCCEEDED (hr)) {
pMFSample->SetUINT32(GUID_SURFACE_INDEX, i);
m_FreeSamples.AddTail(pMFSample);
}
@@ -3859,9 +3770,13 @@ 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);
+ 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);
+ if (m_pSink) {
+ m_pSink->Notify(EC_VIDEO_SIZE_CHANGED, MAKELPARAM(videoSize.cx, videoSize.cy), 0);
+ }
}
void CSyncAP::RemoveAllSamples()
@@ -3878,13 +3793,12 @@ HRESULT CSyncAP::GetFreeSample(IMFSample** ppSample)
CAutoLock lock(&m_SampleQueueLock);
HRESULT hr = S_OK;
- if (m_FreeSamples.GetCount() > 1) // Cannot use first free buffer (can be currently displayed)
- {
+ if (m_FreeSamples.GetCount() > 1) { // Cannot use first free buffer (can be currently displayed)
InterlockedIncrement(&m_nUsedBuffer);
*ppSample = m_FreeSamples.RemoveHead().Detach();
- }
- else
+ } else {
hr = MF_E_SAMPLEALLOCATOR_EMPTY;
+ }
return hr;
}
@@ -3895,13 +3809,12 @@ HRESULT CSyncAP::GetScheduledSample(IMFSample** ppSample, int &_Count)
HRESULT hr = S_OK;
_Count = m_ScheduledSamples.GetCount();
- if (_Count > 0)
- {
+ if (_Count > 0) {
*ppSample = m_ScheduledSamples.RemoveHead().Detach();
--_Count;
- }
- else
+ } else {
hr = MF_E_SAMPLEALLOCATOR_EMPTY;
+ }
return hr;
}
@@ -3910,26 +3823,23 @@ void CSyncAP::MoveToFreeList(IMFSample* pSample, bool bTail)
{
CAutoLock lock(&m_SampleQueueLock);
InterlockedDecrement(&m_nUsedBuffer);
- if (m_bPendingMediaFinished && m_nUsedBuffer == 0)
- {
+ if (m_bPendingMediaFinished && m_nUsedBuffer == 0) {
m_bPendingMediaFinished = false;
m_pSink->Notify(EC_COMPLETE, 0, 0);
}
- if (bTail)
+ if (bTail) {
m_FreeSamples.AddTail(pSample);
- else
+ } else {
m_FreeSamples.AddHead(pSample);
+ }
}
void CSyncAP::MoveToScheduledList(IMFSample* pSample, bool _bSorted)
{
- if (_bSorted)
- {
+ if (_bSorted) {
CAutoLock lock(&m_SampleQueueLock);
m_ScheduledSamples.AddHead(pSample);
- }
- else
- {
+ } else {
CAutoLock lock(&m_SampleQueueLock);
m_ScheduledSamples.AddTail(pSample);
}
@@ -3945,8 +3855,7 @@ void CSyncAP::FlushSamples()
void CSyncAP::FlushSamplesInternal()
{
m_bPrerolled = false;
- while (m_ScheduledSamples.GetCount() > 0)
- {
+ while (m_ScheduledSamples.GetCount() > 0) {
CComPtr<IMFSample> pMFSample;
pMFSample = m_ScheduledSamples.RemoveHead();
MoveToFreeList(pMFSample, true);
@@ -3970,42 +3879,41 @@ HRESULT CSyncAP::BeginStreaming()
pEVR->QueryFilterInfo(&filterInfo); // This addref's the pGraph member
BeginEnumFilters(filterInfo.pGraph, pEF, pBF)
- if(CComQIPtr<IAMAudioRendererStats> pAS = pBF)
- {
+ if(CComQIPtr<IAMAudioRendererStats> pAS = pBF) {
m_pAudioStats = pAS;
};
EndEnumFilters
pEVR->GetSyncSource(&m_pRefClock);
- if (filterInfo.pGraph) filterInfo.pGraph->Release();
+ 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
+ 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)
- {
+ if (clsid == CLSID_SyncAllocatorPresenter) {
CString Error;
*ppAP = DNew CSyncAP(hWnd, bFullscreen, hr, Error);
(*ppAP)->AddRef();
- if(FAILED(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())
- {
+ } else if (!Error.IsEmpty()) {
MessageBox(hWnd, Error, L"Warning creating EVR Sync", MB_OK|MB_ICONWARNING);
}
}
@@ -4027,120 +3935,144 @@ HRESULT STDMETHODCALLTYPE CSyncRenderer::GetState(DWORD dwMilliSecsTimeout, __ou
{
HRESULT ReturnValue;
CComPtr<IBaseFilter> pEVRBase;
- if (m_pEVR)
+ if (m_pEVR) {
m_pEVR->QueryInterface(&pEVRBase);
- if (pEVRBase)
+ }
+ if (pEVRBase) {
return pEVRBase->GetState(dwMilliSecsTimeout, State);
+ }
return E_NOTIMPL;
}
STDMETHODIMP CSyncRenderer::EnumPins(__out IEnumPins **ppEnum)
{
CComPtr<IBaseFilter> pEVRBase;
- if (m_pEVR)
+ if (m_pEVR) {
m_pEVR->QueryInterface(&pEVRBase);
- if (pEVRBase)
+ }
+ if (pEVRBase) {
return pEVRBase->EnumPins(ppEnum);
+ }
return E_NOTIMPL;
}
STDMETHODIMP CSyncRenderer::FindPin(LPCWSTR Id, __out IPin **ppPin)
{
CComPtr<IBaseFilter> pEVRBase;
- if (m_pEVR)
+ if (m_pEVR) {
m_pEVR->QueryInterface(&pEVRBase);
- if (pEVRBase)
+ }
+ if (pEVRBase) {
return pEVRBase->FindPin(Id, ppPin);
+ }
return E_NOTIMPL;
}
STDMETHODIMP CSyncRenderer::QueryFilterInfo(__out FILTER_INFO *pInfo)
{
CComPtr<IBaseFilter> pEVRBase;
- if (m_pEVR)
+ if (m_pEVR) {
m_pEVR->QueryInterface(&pEVRBase);
- if (pEVRBase)
+ }
+ if (pEVRBase) {
return pEVRBase->QueryFilterInfo(pInfo);
+ }
return E_NOTIMPL;
}
STDMETHODIMP CSyncRenderer::JoinFilterGraph(__in_opt IFilterGraph *pGraph, __in_opt LPCWSTR pName)
{
CComPtr<IBaseFilter> pEVRBase;
- if (m_pEVR)
+ if (m_pEVR) {
m_pEVR->QueryInterface(&pEVRBase);
- if (pEVRBase)
+ }
+ if (pEVRBase) {
return pEVRBase->JoinFilterGraph(pGraph, pName);
+ }
return E_NOTIMPL;
}
STDMETHODIMP CSyncRenderer::QueryVendorInfo(__out LPWSTR *pVendorInfo)
{
CComPtr<IBaseFilter> pEVRBase;
- if (m_pEVR)
+ if (m_pEVR) {
m_pEVR->QueryInterface(&pEVRBase);
- if (pEVRBase)
+ }
+ if (pEVRBase) {
return pEVRBase->QueryVendorInfo(pVendorInfo);
+ }
return E_NOTIMPL;
}
STDMETHODIMP CSyncRenderer::Stop( void)
{
CComPtr<IBaseFilter> pEVRBase;
- if (m_pEVR)
+ if (m_pEVR) {
m_pEVR->QueryInterface(&pEVRBase);
- if (pEVRBase)
+ }
+ if (pEVRBase) {
return pEVRBase->Stop();
+ }
return E_NOTIMPL;
}
STDMETHODIMP CSyncRenderer::Pause(void)
{
CComPtr<IBaseFilter> pEVRBase;
- if (m_pEVR)
+ if (m_pEVR) {
m_pEVR->QueryInterface(&pEVRBase);
- if (pEVRBase)
+ }
+ if (pEVRBase) {
return pEVRBase->Pause();
+ }
return E_NOTIMPL;
}
STDMETHODIMP CSyncRenderer::Run(REFERENCE_TIME tStart)
{
CComPtr<IBaseFilter> pEVRBase;
- if (m_pEVR)
+ if (m_pEVR) {
m_pEVR->QueryInterface(&pEVRBase);
- if (pEVRBase)
+ }
+ if (pEVRBase) {
return pEVRBase->Run(tStart);
+ }
return E_NOTIMPL;
}
STDMETHODIMP CSyncRenderer::SetSyncSource(__in_opt IReferenceClock *pClock)
{
CComPtr<IBaseFilter> pEVRBase;
- if (m_pEVR)
+ if (m_pEVR) {
m_pEVR->QueryInterface(&pEVRBase);
- if (pEVRBase)
+ }
+ if (pEVRBase) {
return pEVRBase->SetSyncSource(pClock);
+ }
return E_NOTIMPL;
}
STDMETHODIMP CSyncRenderer::GetSyncSource(__deref_out_opt IReferenceClock **pClock)
{
CComPtr<IBaseFilter> pEVRBase;
- if (m_pEVR)
+ if (m_pEVR) {
m_pEVR->QueryInterface(&pEVRBase);
- if (pEVRBase)
+ }
+ if (pEVRBase) {
return pEVRBase->GetSyncSource(pClock);
+ }
return E_NOTIMPL;
}
STDMETHODIMP CSyncRenderer::GetClassID(__RPC__out CLSID *pClassID)
{
CComPtr<IBaseFilter> pEVRBase;
- if (m_pEVR)
+ if (m_pEVR) {
m_pEVR->QueryInterface(&pEVRBase);
- if (pEVRBase)
+ }
+ if (pEVRBase) {
return pEVRBase->GetClassID(pClassID);
+ }
return E_NOTIMPL;
}
@@ -4182,32 +4114,29 @@ STDMETHODIMP CSyncRenderer::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
HRESULT hr;
- if(riid == __uuidof(IVMRMixerBitmap9))
+ if(riid == __uuidof(IVMRMixerBitmap9)) {
return GetInterface((IVMRMixerBitmap9*)this, ppv);
+ }
- if (riid == __uuidof(IBaseFilter))
- {
+ if (riid == __uuidof(IBaseFilter)) {
return GetInterface((IBaseFilter*)this, ppv);
}
- if (riid == __uuidof(IMediaFilter))
- {
+ if (riid == __uuidof(IMediaFilter)) {
return GetInterface((IMediaFilter*)this, ppv);
}
- if (riid == __uuidof(IPersist))
- {
+ if (riid == __uuidof(IPersist)) {
return GetInterface((IPersist*)this, ppv);
}
- if (riid == __uuidof(IBaseFilter))
- {
+ 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.
+ 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);
}
@@ -4239,13 +4168,11 @@ CGenlock::CGenlock(DOUBLE target, DOUBLE limit, INT lineD, INT colD, DOUBLE cloc
CGenlock::~CGenlock()
{
ResetTiming();
- if(syncOffsetFifo != NULL)
- {
+ if(syncOffsetFifo != NULL) {
delete syncOffsetFifo;
syncOffsetFifo = NULL;
}
- if(frameCycleFifo != NULL)
- {
+ if(frameCycleFifo != NULL) {
delete frameCycleFifo;
frameCycleFifo = NULL;
}
@@ -4255,8 +4182,11 @@ CGenlock::~CGenlock()
BOOL CGenlock::PowerstripRunning()
{
psWnd = FindWindow(_T("TPShidden"), NULL);
- if (!psWnd) return FALSE; // Powerstrip is not running
- else return TRUE;
+ if (!psWnd) {
+ return FALSE; // Powerstrip is not running
+ } else {
+ return TRUE;
+ }
}
// Get the display timing parameters through PowerStrip (if running).
@@ -4271,15 +4201,15 @@ HRESULT CGenlock::GetTiming()
TCHAR tmpStr[MAX_LOADSTRING];
CAutoLock lock(&csGenlockLock);
- if (!PowerstripRunning()) return E_FAIL;
+ 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] != ',' && savedTiming[i] != '\0')
- {
+ while (params < TIMING_PARAM_CNT) {
+ while (savedTiming[i] != ',' && savedTiming[i] != '\0') {
tmpStr[j++] = savedTiming[i];
tmpStr[j] = '\0';
i++;
@@ -4357,10 +4287,11 @@ HRESULT CGenlock::ResetTiming()
LRESULT ret;
CAutoLock lock(&csGenlockLock);
- if (!PowerstripRunning()) return E_FAIL;
+ if (!PowerstripRunning()) {
+ return E_FAIL;
+ }
- if (displayAdjustmentsMade > 0)
- {
+ if (displayAdjustmentsMade > 0) {
setTiming = GlobalAddAtom(cruise);
lParam = setTiming;
ret = SendMessage(psWnd, UM_SETCUSTOMTIMINGFAST, wParam, lParam);
@@ -4375,8 +4306,11 @@ HRESULT CGenlock::ResetTiming()
HRESULT CGenlock::ResetClock()
{
adjDelta = 0;
- if (syncClock == NULL) return E_FAIL;
- else return syncClock->AdjustClock(1.0);
+ if (syncClock == NULL) {
+ return E_FAIL;
+ } else {
+ return syncClock->AdjustClock(1.0);
+ }
}
HRESULT CGenlock::SetTargetSyncOffset(DOUBLE targetD)
@@ -4414,8 +4348,12 @@ HRESULT CGenlock::SetDisplayResolution(UINT columns, UINT lines)
HRESULT CGenlock::AdviseSyncClock(ISyncClock* sC)
{
- if (!sC) return E_FAIL;
- if (syncClock) syncClock = NULL; // Release any outstanding references if this is called repeatedly
+ if (!sC) {
+ return E_FAIL;
+ }
+ if (syncClock) {
+ syncClock = NULL; // Release any outstanding references if this is called repeatedly
+ }
syncClock = sC;
return S_OK;
}
@@ -4460,7 +4398,9 @@ HRESULT CGenlock::ControlDisplay(double syncOffset, double frameCycle)
minFrameCycle = min(minFrameCycle, frameCycle);
maxFrameCycle = max(maxFrameCycle, frameCycle);
- if (!PowerstripRunning() || !powerstripTimingExists) return E_FAIL;
+ 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.
@@ -4472,11 +4412,9 @@ HRESULT CGenlock::ControlDisplay(double syncOffset, double frameCycle)
SendMessage(psWnd, UM_SETCUSTOMTIMINGFAST, wParam, lParam);
GlobalDeleteAtom(setTiming);
displayAdjustmentsMade++;
- }
- else
+ } else
// Slow down display refresh rate by adding pixels to the image.
- if ((syncOffsetAvg < lowSyncOffset) && (adjDelta != -1))
- {
+ if ((syncOffsetAvg < lowSyncOffset) && (adjDelta != -1)) {
adjDelta = -1;
curDisplayFreq = displayFreqSlower;
setTiming = GlobalAddAtom(slower);
@@ -4484,11 +4422,9 @@ HRESULT CGenlock::ControlDisplay(double syncOffset, double frameCycle)
SendMessage(psWnd, UM_SETCUSTOMTIMINGFAST, wParam, lParam);
GlobalDeleteAtom(setTiming);
displayAdjustmentsMade++;
- }
- else
+ } else
// Cruise.
- if ((syncOffsetAvg < targetSyncOffset) && (adjDelta == 1))
- {
+ if ((syncOffsetAvg < targetSyncOffset) && (adjDelta == 1)) {
adjDelta = 0;
curDisplayFreq = displayFreqCruise;
setTiming = GlobalAddAtom(cruise);
@@ -4496,9 +4432,7 @@ HRESULT CGenlock::ControlDisplay(double syncOffset, double frameCycle)
SendMessage(psWnd, UM_SETCUSTOMTIMINGFAST, wParam, lParam);
GlobalDeleteAtom(setTiming);
displayAdjustmentsMade++;
- }
- else if ((syncOffsetAvg > targetSyncOffset) && (adjDelta == -1))
- {
+ } else if ((syncOffsetAvg > targetSyncOffset) && (adjDelta == -1)) {
adjDelta = 0;
curDisplayFreq = displayFreqCruise;
setTiming = GlobalAddAtom(cruise);
@@ -4526,7 +4460,9 @@ HRESULT CGenlock::ControlClock(double syncOffset, double frameCycle)
minFrameCycle = min(minFrameCycle, frameCycle);
maxFrameCycle = max(maxFrameCycle, frameCycle);
- if (!syncClock) return E_FAIL;
+ 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.
@@ -4534,25 +4470,19 @@ HRESULT CGenlock::ControlClock(double syncOffset, double frameCycle)
adjDelta = 1;
syncClock->AdjustClock(1.0 - cycleDelta); // Makes the clock move slower by providing smaller increments
clockAdjustmentsMade++;
- }
- else
+ } else
// Speed up video stream.
- if ((syncOffsetAvg < lowSyncOffset) && (adjDelta != -1))
- {
+ if ((syncOffsetAvg < lowSyncOffset) && (adjDelta != -1)) {
adjDelta = -1;
syncClock->AdjustClock(1.0 + cycleDelta);
clockAdjustmentsMade++;
- }
- else
+ } else
// Cruise.
- if ((syncOffsetAvg < targetSyncOffset) && (adjDelta == 1))
- {
+ if ((syncOffsetAvg < targetSyncOffset) && (adjDelta == 1)) {
adjDelta = 0;
syncClock->AdjustClock(1.0);
clockAdjustmentsMade++;
- }
- else if ((syncOffsetAvg > targetSyncOffset) && (adjDelta == -1))
- {
+ } else if ((syncOffsetAvg > targetSyncOffset) && (adjDelta == -1)) {
adjDelta = 0;
syncClock->AdjustClock(1.0);
clockAdjustmentsMade++;
diff --git a/src/filters/renderer/VideoRenderers/SyncRenderer.h b/src/filters/renderer/VideoRenderers/SyncRenderer.h
index ec19f8dbb..8e9f87c79 100644
--- a/src/filters/renderer/VideoRenderers/SyncRenderer.h
+++ b/src/filters/renderer/VideoRenderers/SyncRenderer.h
@@ -76,615 +76,609 @@ 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;
+ 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
+ // Base allocator-presenter
+ class CBaseAP:
+ public CSubPicAllocatorPresenterImpl
{
- public:
- CComPtr<IDirect3DPixelShader9> m_pPixelShader;
- CStringA m_SourceData;
- CStringA m_SourceTarget;
- HRESULT Compile(CPixelShaderCompiler *pCompiler)
+ 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
{
- HRESULT hr = pCompiler->CompileShader(m_SourceData, "main", m_SourceTarget, 0, &m_pPixelShader);
- if(FAILED(hr)) return hr;
- return S_OK;
- }
+ 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();
};
- 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();
+ 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
- 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();
-};
-
-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 STDMETHODCALLTYPE OnClockStop(MFTIME hnsSystemTime);
+ STDMETHODIMP STDMETHODCALLTYPE OnClockPause(MFTIME hnsSystemTime);
+ STDMETHODIMP STDMETHODCALLTYPE OnClockRestart(MFTIME hnsSystemTime);
+ STDMETHODIMP STDMETHODCALLTYPE 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;
-{
-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 STDMETHODCALLTYPE OnClockStop(MFTIME hnsSystemTime);
- STDMETHODIMP STDMETHODCALLTYPE OnClockPause(MFTIME hnsSystemTime);
- STDMETHODIMP STDMETHODCALLTYPE OnClockRestart(MFTIME hnsSystemTime);
- STDMETHODIMP STDMETHODCALLTYPE 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
+ 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
{
- 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
+ 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:
- MovingAverage(INT size):
- fifoSize(size),
- oldestSample(0),
- sum(0)
+ class MovingAverage
{
- if (fifoSize > MAX_FIFO_SIZE)
- {
- fifoSize = MAX_FIFO_SIZE;
+ 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;
+ }
}
- for (INT i = 0; i < MAX_FIFO_SIZE; i++)
- fifo[i] = 0;
- }
- ~MovingAverage()
- {
- }
+ ~MovingAverage() {
+ }
- double Average(double sample)
- {
- sum = sum + sample - fifo[oldestSample];
- fifo[oldestSample] = sample;
- oldestSample++;
- if (oldestSample == fifoSize)
- oldestSample = 0;
- return sum / fifoSize;
- }
+ 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:
- INT fifoSize;
- double fifo[MAX_FIFO_SIZE];
- INT oldestSample;
- double sum;
+ 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;
};
-
- 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 b8afdadd3..8a503e17d 100644
--- a/src/filters/renderer/VideoRenderers/VMR7AllocatorPresenter.cpp
+++ b/src/filters/renderer/VideoRenderers/VMR7AllocatorPresenter.cpp
@@ -42,11 +42,11 @@ CVMR7AllocatorPresenter::CVMR7AllocatorPresenter(HWND hWnd, HRESULT& hr)
: CDX7AllocatorPresenter(hWnd, hr)
, m_fUseInternalTimer(false)
{
- if(FAILED(hr))
+ if(FAILED(hr)) {
return;
+ }
- if(FAILED(hr = m_pSA.CoCreateInstance(CLSID_AllocPresenter)))
- {
+ if(FAILED(hr = m_pSA.CoCreateInstance(CLSID_AllocPresenter))) {
hr = E_FAIL;
return;
}
@@ -66,13 +66,15 @@ STDMETHODIMP CVMR7AllocatorPresenter::NonDelegatingQueryInterface(REFIID riid, v
HRESULT CVMR7AllocatorPresenter::CreateDevice()
{
HRESULT hr = __super::CreateDevice();
- if(FAILED(hr)) return hr;
+ if(FAILED(hr)) {
+ return hr;
+ }
- if(m_pIVMRSurfAllocNotify)
- {
+ if(m_pIVMRSurfAllocNotify) {
HMONITOR hMonitor = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
- if(FAILED(hr = m_pIVMRSurfAllocNotify->ChangeDDrawDevice(m_pDD, hMonitor)))
- return hr; //return(false);
+ if(FAILED(hr = m_pIVMRSurfAllocNotify->ChangeDDrawDevice(m_pDD, hMonitor))) {
+ return hr; //return(false);
+ }
}
return hr;
@@ -97,27 +99,31 @@ STDMETHODIMP CVMR7AllocatorPresenter::CreateRenderer(IUnknown** ppRenderer)
HRESULT hr;
- do
- {
+ do {
CComPtr<IBaseFilter> pBF;
- if(FAILED(hr = pBF.CoCreateInstance(CLSID_VideoMixingRenderer)))
+ if(FAILED(hr = pBF.CoCreateInstance(CLSID_VideoMixingRenderer))) {
break;
+ }
CComQIPtr<IVMRFilterConfig> pConfig = pBF;
- if(!pConfig)
+ if(!pConfig) {
break;
+ }
- if(FAILED(hr = pConfig->SetRenderingMode(VMRMode_Renderless)))
+ if(FAILED(hr = pConfig->SetRenderingMode(VMRMode_Renderless))) {
break;
+ }
CComQIPtr<IVMRSurfaceAllocatorNotify> pSAN = pBF;
- if(!pSAN)
+ if(!pSAN) {
break;
+ }
if(FAILED(hr = pSAN->AdviseSurfaceAllocator(MY_USER_ID, static_cast<IVMRSurfaceAllocator*>(this)))
- || FAILED(hr = AdviseNotify(pSAN)))
+ || FAILED(hr = AdviseNotify(pSAN))) {
break;
+ }
CComPtr<IPin> pPin = GetFirstPin(pBF);
CComQIPtr<IMemInputPin> pMemInputPin = pPin;
@@ -126,8 +132,7 @@ STDMETHODIMP CVMR7AllocatorPresenter::CreateRenderer(IUnknown** ppRenderer)
*ppRenderer = (IUnknown*)pBF.Detach();
return S_OK;
- }
- while(0);
+ } while(0);
return E_FAIL;
}
@@ -135,18 +140,20 @@ STDMETHODIMP CVMR7AllocatorPresenter::CreateRenderer(IUnknown** ppRenderer)
STDMETHODIMP_(void) CVMR7AllocatorPresenter::SetTime(REFERENCE_TIME rtNow)
{
__super::SetTime(rtNow);
-// m_fUseInternalTimer = false;
+ // m_fUseInternalTimer = false;
}
// IVMRSurfaceAllocator
STDMETHODIMP CVMR7AllocatorPresenter::AllocateSurface(DWORD_PTR dwUserID, VMRALLOCATIONINFO* lpAllocInfo, DWORD* lpdwBuffer, LPDIRECTDRAWSURFACE7* lplpSurface)
{
- if(!lpAllocInfo || !lpdwBuffer || !lplpSurface)
+ if(!lpAllocInfo || !lpdwBuffer || !lplpSurface) {
return E_POINTER;
+ }
- if(!m_pIVMRSurfAllocNotify)
+ if(!m_pIVMRSurfAllocNotify) {
return E_FAIL;
+ }
HRESULT hr;
@@ -157,24 +164,28 @@ STDMETHODIMP CVMR7AllocatorPresenter::AllocateSurface(DWORD_PTR dwUserID, VMRALL
// then that might stall for about 30 seconds because of some unknown buggy code
// behind <ddraw surface>->Release()
- if(lpAllocInfo->lpHdr->biBitCount < 16)
+ if(lpAllocInfo->lpHdr->biBitCount < 16) {
return E_FAIL;
+ }
hr = m_pSA->AllocateSurface(dwUserID, lpAllocInfo, lpdwBuffer, lplpSurface);
- if(FAILED(hr))
+ 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(arx > 0 && ary > 0) {
+ m_AspectRatio.SetSize(arx, ary);
+ }
- if(FAILED(hr = AllocSurfaces()))
+ if(FAILED(hr = AllocSurfaces())) {
return hr;
+ }
// test if the colorspace is acceptable
- if(FAILED(hr = m_pVideoSurface->Blt(NULL, *lplpSurface, NULL, DDBLT_WAIT, NULL)))
- {
+ if(FAILED(hr = m_pVideoSurface->Blt(NULL, *lplpSurface, NULL, DDBLT_WAIT, NULL))) {
DeleteSurfaces();
return hr;
}
@@ -197,8 +208,9 @@ STDMETHODIMP CVMR7AllocatorPresenter::PrepareSurface(DWORD_PTR dwUserID, IDirect
{
SetThreadName((DWORD)-1, "CVMR7AllocatorPresenter");
- if(!lpSurface)
+ 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
@@ -217,8 +229,9 @@ STDMETHODIMP CVMR7AllocatorPresenter::AdviseNotify(IVMRSurfaceAllocatorNotify* l
HRESULT hr;
HMONITOR hMonitor = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
- if(FAILED(hr = m_pIVMRSurfAllocNotify->SetDDrawDevice(m_pDD, hMonitor)))
+ if(FAILED(hr = m_pIVMRSurfAllocNotify->SetDDrawDevice(m_pDD, hMonitor))) {
return hr;
+ }
return m_pSA->AdviseNotify(lpIVMRSurfAllocNotify);
}
@@ -227,8 +240,7 @@ STDMETHODIMP CVMR7AllocatorPresenter::AdviseNotify(IVMRSurfaceAllocatorNotify* l
STDMETHODIMP CVMR7AllocatorPresenter::StartPresenting(DWORD_PTR dwUserID)
{
- if (!m_bPendingResetDevice)
- {
+ if (!m_bPendingResetDevice) {
ASSERT(m_pD3DDev);
}
@@ -244,25 +256,24 @@ STDMETHODIMP CVMR7AllocatorPresenter::StopPresenting(DWORD_PTR dwUserID)
STDMETHODIMP CVMR7AllocatorPresenter::PresentImage(DWORD_PTR dwUserID, VMRPRESENTATIONINFO* lpPresInfo)
{
- if(!lpPresInfo || !lpPresInfo->lpSurf)
+ if(!lpPresInfo || !lpPresInfo->lpSurf) {
return E_POINTER;
+ }
CAutoLock cAutoLock(this);
- if (!m_bPendingResetDevice)
+ if (!m_bPendingResetDevice) {
m_pVideoSurface->Blt(NULL, lpPresInfo->lpSurf, NULL, DDBLT_WAIT, NULL);
+ }
- if(lpPresInfo->rtEnd > lpPresInfo->rtStart)
- {
+ if(lpPresInfo->rtEnd > lpPresInfo->rtStart) {
REFERENCE_TIME rtTimePerFrame = lpPresInfo->rtEnd - lpPresInfo->rtStart;
m_fps = 10000000.0 / rtTimePerFrame;
- if(m_pSubPicQueue)
- {
+ if(m_pSubPicQueue) {
m_pSubPicQueue->SetFPS(m_fps);
- if(m_fUseInternalTimer && !g_bExternalSubtitleTime)
- {
+ if(m_fUseInternalTimer && !g_bExternalSubtitleTime) {
__super::SetTime(g_tSegmentStart + g_tSampleStart);
}
}
@@ -270,9 +281,10 @@ STDMETHODIMP CVMR7AllocatorPresenter::PresentImage(DWORD_PTR dwUserID, VMRPRESEN
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())
- {
+ 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);
}
@@ -293,10 +305,18 @@ STDMETHODIMP CVMR7AllocatorPresenter::GetNativeVideoSize(LONG* lpWidth, LONG* lp
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;
+ if(lpWidth) {
+ *lpWidth = vs.cx;
+ }
+ if(lpHeight) {
+ *lpHeight = vs.cy;
+ }
+ if(lpARWidth) {
+ *lpARWidth = ar.cx;
+ }
+ if(lpARHeight) {
+ *lpARHeight = ar.cy;
+ }
return S_OK;
}
@@ -324,7 +344,9 @@ STDMETHODIMP CVMR7AllocatorPresenter::GetVideoPosition(LPRECT lpSRCRect, LPRECT
STDMETHODIMP CVMR7AllocatorPresenter::GetAspectRatioMode(DWORD* lpAspectRatioMode)
{
- if(lpAspectRatioMode) *lpAspectRatioMode = AM_ARMODE_STRETCHED;
+ if(lpAspectRatioMode) {
+ *lpAspectRatioMode = AM_ARMODE_STRETCHED;
+ }
return S_OK;
}
@@ -355,7 +377,9 @@ STDMETHODIMP CVMR7AllocatorPresenter::SetBorderColor(COLORREF Clr)
STDMETHODIMP CVMR7AllocatorPresenter::GetBorderColor(COLORREF* lpClr)
{
- if(lpClr) *lpClr = 0;
+ if(lpClr) {
+ *lpClr = 0;
+ }
return S_OK;
}
diff --git a/src/filters/renderer/VideoRenderers/VMR7AllocatorPresenter.h b/src/filters/renderer/VideoRenderers/VMR7AllocatorPresenter.h
index c3b1708d1..04d8eca6b 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 33f780b1c..4b0691b52 100644
--- a/src/filters/renderer/VideoRenderers/VMR9AllocatorPresenter.cpp
+++ b/src/filters/renderer/VideoRenderers/VMR9AllocatorPresenter.cpp
@@ -29,544 +29,442 @@
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:
+
+ 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;
+ }
-public:
+ ~COuterVMR9() {
+ m_pVMR = NULL;
+ }
- 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;
- }
+ DECLARE_IUNKNOWN;
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv) {
+ HRESULT hr;
- ~COuterVMR9()
- {
- m_pVMR = NULL;
- }
+ // Casimir666 : in renderless mode, do the inlaying in place of VMR
+ if(riid == __uuidof(IVMRMixerBitmap9)) {
+ return GetInterface((IVMRMixerBitmap9*)this, ppv);
+ }
- 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);
-
- 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) {
+ if(CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR) {
+ return pWC9->GetNativeVideoSize(lpWidth, lpHeight, lpARWidth, lpARHeight);
+ }
- STDMETHODIMP 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 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)
- {
- if(CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR)
- {
- return pWC9->GetVideoPosition(lpSRCRect, 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) {
+ if(CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR) {
+ return pWC9->GetVideoPosition(lpSRCRect, lpDSTRect);
+ }
- return E_NOTIMPL;
- }
- STDMETHODIMP GetAspectRatioMode(DWORD* lpAspectRatioMode)
- {
- if(CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR)
- {
- *lpAspectRatioMode = VMR_ARMODE_NONE;
- return S_OK;
+ return E_NOTIMPL;
}
+ STDMETHODIMP GetAspectRatioMode(DWORD* lpAspectRatioMode) {
+ if(CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR) {
+ *lpAspectRatioMode = VMR_ARMODE_NONE;
+ return S_OK;
+ }
- 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;
- }
+ 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)
- {
- if(CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR)
- {
- CRect s, d;
- HRESULT hr = pWC9->GetVideoPosition(&s, &d);
- *pWidth = d.Width();
- return hr;
+ // 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) {
+ if(CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR) {
+ CRect s, d;
+ HRESULT hr = pWC9->GetVideoPosition(&s, &d);
+ *pWidth = d.Width();
+ return hr;
+ }
- return E_NOTIMPL;
- }
- 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)
- {
- if(CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR)
- {
- CRect s, d;
- HRESULT hr = pWC9->GetVideoPosition(&s, &d);
- *pHeight = d.Height();
- return hr;
+ return E_NOTIMPL;
+ }
+ 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) {
+ if(CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR) {
+ CRect s, d;
+ HRESULT hr = pWC9->GetVideoPosition(&s, &d);
+ *pHeight = d.Height();
+ return hr;
+ }
- 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;
- }
+ 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)
- {
- // 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;
+ // IBasicVideo2
+ STDMETHODIMP get_AvgTimePerFrame(REFTIME* pAvgTimePerFrame) {
+ return E_NOTIMPL;
}
- return E_NOTIMPL;
- */
- }
- 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)
- {
- if(CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR)
- {
+ 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) {
+ // 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 = d.left;
- *pTop = d.top;
- *pWidth = d.Width();
- *pHeight = d.Height();
+ *pLeft = s.left;
+ *pTop = s.top;
+ *pWidth = s.Width();
+ *pHeight = s.Height();
return hr;
+ }
+ return E_NOTIMPL;
+ */
}
-
- return E_NOTIMPL;
- }
- STDMETHODIMP SetDefaultDestinationPosition()
- {
- return E_NOTIMPL;
- }
- STDMETHODIMP 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;
+ 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) {
+ 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;
- }
- // IVMRffdshow9
- STDMETHODIMP support_ffdshow()
- {
- queue_ffdshow_support = true;
- return S_OK;
- }
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP SetDefaultDestinationPosition() {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP 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;
+ }
- 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;
- }
+ return E_NOTIMPL;
+ }
+ // IVMRffdshow9
+ STDMETHODIMP support_ffdshow() {
+ queue_ffdshow_support = true;
+ return S_OK;
+ }
- STDMETHODIMP GetPreferredAspectRatio(long* plAspectX, long* plAspectY)
- {
- if(CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR)
- {
- LONG w, h;
- return pWC9->GetNativeVideoSize(&w, &h, plAspectX, plAspectY);
+ 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;
}
- return E_NOTIMPL;
- }
+ STDMETHODIMP GetPreferredAspectRatio(long* plAspectX, long* plAspectY) {
+ if(CComQIPtr<IVMRWindowlessControl9> pWC9 = m_pVMR) {
+ LONG w, h;
+ return pWC9->GetNativeVideoSize(&w, &h, plAspectX, plAspectY);
+ }
- // IVMRMixerBitmap9
- STDMETHODIMP GetAlphaBitmapParameters(VMR9AlphaBitmap* pBmpParms)
- {
- CheckPointer(pBmpParms, E_POINTER);
- CAutoLock BitMapLock(&m_pAllocatorPresenter->m_VMR9AlphaBitmapLock);
- memcpy (pBmpParms, m_pVMR9AlphaBitmap, sizeof(VMR9AlphaBitmap));
- return S_OK;
- }
+ return E_NOTIMPL;
+ }
- STDMETHODIMP 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;
- }
+ // IVMRMixerBitmap9
+ STDMETHODIMP GetAlphaBitmapParameters(VMR9AlphaBitmap* pBmpParms) {
+ CheckPointer(pBmpParms, E_POINTER);
+ CAutoLock BitMapLock(&m_pAllocatorPresenter->m_VMR9AlphaBitmapLock);
+ memcpy (pBmpParms, m_pVMR9AlphaBitmap, sizeof(VMR9AlphaBitmap));
+ return S_OK;
+ }
- STDMETHODIMP 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 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 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;
+ }
+ };
}
using namespace DSObjects;
@@ -598,14 +496,13 @@ STDMETHODIMP CVMR9AllocatorPresenter::NonDelegatingQueryInterface(REFIID riid, v
HRESULT CVMR9AllocatorPresenter::CreateDevice(CString &_Error)
{
HRESULT hr = __super::CreateDevice(_Error);
- if(FAILED(hr))
+ if(FAILED(hr)) {
return hr;
+ }
- if(m_pIVMRSurfAllocNotify)
- {
+ if(m_pIVMRSurfAllocNotify) {
HMONITOR hMonitor = m_pD3D->GetAdapterMonitor(m_CurrentAdapter);
- if(FAILED(hr = m_pIVMRSurfAllocNotify->ChangeD3DDevice(m_pD3DDev, hMonitor)))
- {
+ if(FAILED(hr = m_pIVMRSurfAllocNotify->ChangeD3DDevice(m_pD3DDev, hMonitor))) {
_Error += L"m_pIVMRSurfAllocNotify->ChangeD3DDevice failed";
return hr; //return(false);
}
@@ -632,8 +529,7 @@ STDMETHODIMP CVMR9AllocatorPresenter::CreateRenderer(IUnknown** ppRenderer)
HRESULT hr;
- do
- {
+ do {
CMacrovisionKicker* pMK = DNew CMacrovisionKicker(NAME("CMacrovisionKicker"), NULL);
CComPtr<IUnknown> pUnk = (IUnknown*)(INonDelegatingUnknown*)pMK;
@@ -647,30 +543,30 @@ STDMETHODIMP CVMR9AllocatorPresenter::CreateRenderer(IUnknown** ppRenderer)
CComQIPtr<IMemInputPin> pMemInputPin = pPin;
m_fUseInternalTimer = HookNewSegmentAndReceive((IPinC*)(IPin*)pPin, (IMemInputPinC*)(IMemInputPin*)pMemInputPin);
- if(CComQIPtr<IAMVideoAccelerator> pAMVA = pPin)
+ if(CComQIPtr<IAMVideoAccelerator> pAMVA = pPin) {
HookAMVideoAccelerator((IAMVideoAcceleratorC*)(IAMVideoAccelerator*)pAMVA);
+ }
CComQIPtr<IVMRFilterConfig9> pConfig = pBF;
- if(!pConfig)
+ if(!pConfig) {
break;
+ }
CRenderersSettings& s = GetRenderersSettings();
- if(s.fVMR9MixerMode)
- {
- if(FAILED(hr = pConfig->SetNumberOfStreams(1)))
+ if(s.fVMR9MixerMode) {
+ if(FAILED(hr = pConfig->SetNumberOfStreams(1))) {
break;
+ }
- if(CComQIPtr<IVMRMixerControl9> pMC = pBF)
- {
+ 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 && !IsVistaOrAbove())
- {
+ if(s.fVMR9MixerYUV && !IsVistaOrAbove()) {
dwPrefs &= ~MixerPref9_RenderTargetMask;
dwPrefs |= MixerPref9_RenderTargetYUV;
}
@@ -678,22 +574,24 @@ STDMETHODIMP CVMR9AllocatorPresenter::CreateRenderer(IUnknown** ppRenderer)
}
}
- if(FAILED(hr = pConfig->SetRenderingMode(VMR9Mode_Renderless)))
+ if(FAILED(hr = pConfig->SetRenderingMode(VMR9Mode_Renderless))) {
break;
+ }
CComQIPtr<IVMRSurfaceAllocatorNotify9> pSAN = pBF;
- if(!pSAN)
+ if(!pSAN) {
break;
+ }
if(FAILED(hr = pSAN->AdviseSurfaceAllocator(MY_USER_ID, static_cast<IVMRSurfaceAllocator9*>(this)))
- || FAILED(hr = AdviseNotify(pSAN)))
+ || FAILED(hr = AdviseNotify(pSAN))) {
break;
+ }
*ppRenderer = (IUnknown*)pBF.Detach();
return S_OK;
- }
- while(0);
+ } while(0);
return E_FAIL;
}
@@ -711,27 +609,29 @@ STDMETHODIMP CVMR9AllocatorPresenter::InitializeDevice(DWORD_PTR dwUserID, VMR9A
CAutoLock lock(this);
CAutoLock cRenderLock(&m_RenderLock);
- if(!lpAllocInfo || !lpNumBuffers)
+ if(!lpAllocInfo || !lpNumBuffers) {
return E_POINTER;
+ }
- if(!m_pIVMRSurfAllocNotify)
+ if(!m_pIVMRSurfAllocNotify) {
return E_FAIL;
+ }
if((GetAsyncKeyState(VK_CONTROL)&0x80000000))
- if(lpAllocInfo->Format == '21VY' || lpAllocInfo->Format == '024I')
+ if(lpAllocInfo->Format == '21VY' || lpAllocInfo->Format == '024I') {
return E_FAIL;
+ }
DeleteSurfaces();
int nOriginal = *lpNumBuffers;
- if (*lpNumBuffers == 1)
- {
+ if (*lpNumBuffers == 1) {
*lpNumBuffers = 4;
m_nVMR9Surfaces = 4;
- }
- else
+ } else {
m_nVMR9Surfaces = 0;
+ }
m_pSurfaces.SetCount(*lpNumBuffers);
int w = lpAllocInfo->dwWidth;
@@ -739,11 +639,14 @@ STDMETHODIMP CVMR9AllocatorPresenter::InitializeDevice(DWORD_PTR dwUserID, VMR9A
HRESULT hr;
- if(lpAllocInfo->dwFlags & VMR9AllocFlag_3DRenderTarget)
+ if(lpAllocInfo->dwFlags & VMR9AllocFlag_3DRenderTarget) {
lpAllocInfo->dwFlags |= VMR9AllocFlag_TextureSurface;
+ }
hr = m_pIVMRSurfAllocNotify->AllocateSurfaceHelper(lpAllocInfo, lpNumBuffers, &m_pSurfaces[0]);
- if(FAILED(hr)) return hr;
+ if(FAILED(hr)) {
+ return hr;
+ }
m_pSurfaces.SetCount(*lpNumBuffers);
@@ -752,23 +655,21 @@ STDMETHODIMP CVMR9AllocatorPresenter::InitializeDevice(DWORD_PTR dwUserID, VMR9A
CSize VideoSize = GetVisibleVideoSize();
int arx = lpAllocInfo->szAspectRatio.cx;
int ary = lpAllocInfo->szAspectRatio.cy;
- if(arx > 0 && ary > 0)
- {
+ if(arx > 0 && ary > 0) {
arx = arx / ((float) m_NativeVideoSize.cx / VideoSize.cx);
ary = ary / ((float) m_NativeVideoSize.cy / VideoSize.cy);
m_AspectRatio.SetSize(arx, ary);
- }
- else
+ } else {
m_AspectRatio = VideoSize;
+ }
- if(FAILED(hr = AllocSurfaces()))
+ if(FAILED(hr = AllocSurfaces())) {
return hr;
+ }
- if(!(lpAllocInfo->dwFlags & VMR9AllocFlag_TextureSurface))
- {
+ 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)))
- {
+ if(FAILED(hr = m_pD3DDev->StretchRect(m_pSurfaces[0], NULL, m_pVideoSurface[m_nCurSurface], NULL, D3DTEXF_NONE))) {
DeleteSurfaces();
return E_FAIL;
}
@@ -776,8 +677,9 @@ STDMETHODIMP CVMR9AllocatorPresenter::InitializeDevice(DWORD_PTR dwUserID, VMR9A
hr = m_pD3DDev->ColorFill(m_pVideoSurface[m_nCurSurface], NULL, 0);
- if (m_nVMR9Surfaces && m_nVMR9Surfaces != (int)*lpNumBuffers)
+ if (m_nVMR9Surfaces && m_nVMR9Surfaces != (int)*lpNumBuffers) {
m_nVMR9Surfaces = *lpNumBuffers;
+ }
*lpNumBuffers = min(nOriginal, *lpNumBuffers);
m_iVMR9Surface = 0;
@@ -791,22 +693,21 @@ STDMETHODIMP CVMR9AllocatorPresenter::TerminateDevice(DWORD_PTR dwUserID)
STDMETHODIMP CVMR9AllocatorPresenter::GetSurface(DWORD_PTR dwUserID, DWORD SurfaceIndex, DWORD SurfaceFlags, IDirect3DSurface9** lplpSurface)
{
- if(!lplpSurface)
+ if(!lplpSurface) {
return E_POINTER;
+ }
- if(SurfaceIndex >= m_pSurfaces.GetCount())
+ if(SurfaceIndex >= m_pSurfaces.GetCount()) {
return E_FAIL;
+ }
CAutoLock cRenderLock(&m_RenderLock);
- if (m_nVMR9Surfaces)
- {
+ if (m_nVMR9Surfaces) {
++m_iVMR9Surface;
m_iVMR9Surface = m_iVMR9Surface % m_nVMR9Surfaces;
(*lplpSurface = m_pSurfaces[m_iVMR9Surface + SurfaceIndex])->AddRef();
- }
- else
- {
+ } else {
m_iVMR9Surface = SurfaceIndex;
(*lplpSurface = m_pSurfaces[SurfaceIndex])->AddRef();
}
@@ -823,8 +724,9 @@ STDMETHODIMP CVMR9AllocatorPresenter::AdviseNotify(IVMRSurfaceAllocatorNotify9*
HRESULT hr;
HMONITOR hMonitor = m_pD3D->GetAdapterMonitor(GetAdapter(m_pD3D));
- if(FAILED(hr = m_pIVMRSurfAllocNotify->SetD3DDevice(m_pD3DDev, hMonitor)))
+ if(FAILED(hr = m_pIVMRSurfAllocNotify->SetD3DDevice(m_pD3DDev, hMonitor))) {
return hr;
+ }
return S_OK;
}
@@ -833,8 +735,7 @@ STDMETHODIMP CVMR9AllocatorPresenter::AdviseNotify(IVMRSurfaceAllocatorNotify9*
STDMETHODIMP CVMR9AllocatorPresenter::StartPresenting(DWORD_PTR dwUserID)
{
- if (!m_bPendingResetDevice)
- {
+ if (!m_bPendingResetDevice) {
ASSERT(m_pD3DDev);
}
@@ -855,8 +756,7 @@ STDMETHODIMP CVMR9AllocatorPresenter::PresentImage(DWORD_PTR dwUserID, VMR9Prese
SetThreadName((DWORD)-1, "CVMR9AllocatorPresenter");
CheckPointer(m_pIVMRSurfAllocNotify, E_UNEXPECTED);
- if (m_rtTimePerFrame == 0 || m_bNeedCheckSample)
- {
+ if (m_rtTimePerFrame == 0 || m_bNeedCheckSample) {
m_bNeedCheckSample = false;
CComPtr<IBaseFilter> pVMR9;
CComPtr<IPin> pPin;
@@ -864,74 +764,74 @@ STDMETHODIMP CVMR9AllocatorPresenter::PresentImage(DWORD_PTR dwUserID, VMR9Prese
if (SUCCEEDED (m_pIVMRSurfAllocNotify->QueryInterface (__uuidof(IBaseFilter), (void**)&pVMR9)) &&
SUCCEEDED (pVMR9->FindPin(L"VMR Input0", &pPin)) &&
- SUCCEEDED (pPin->ConnectionMediaType(&mt)) )
- {
+ 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)
- {
+ 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)
+ 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)
+ } 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)
+ 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)
+ } 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)
- {
+ }
+ } else if (mt.formattype==FORMAT_VideoInfo2 || mt.formattype==FORMAT_MPEG2Video) {
VIDEOINFOHEADER2 *vh = (VIDEOINFOHEADER2*)mt.pbFormat;
- if (vh->dwPictAspectRatioX && vh->dwPictAspectRatioY)
+ 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)
+ 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)
+ } 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)
+ 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)
+ } else if (vh->rcSource.bottom - vh->rcSource.top > 0) {
NativeVideoSize.cy = vh->rcSource.bottom - vh->rcSource.top;
+ }
}
- if (m_NativeVideoSize != NativeVideoSize || m_AspectRatio != AspectRatio)
- {
+ 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;
+ if (m_rtTimePerFrame == 0) {
+ m_rtTimePerFrame = 417166;
+ }
m_fps = 10000000.0 / m_rtTimePerFrame;
}
HRESULT hr;
- if(!lpPresInfo || !lpPresInfo->lpSurf)
+ if(!lpPresInfo || !lpPresInfo->lpSurf) {
return E_POINTER;
+ }
CAutoLock cAutoLock(this);
CAutoLock cRenderLock(&m_RenderLock);
- if(lpPresInfo->rtEnd > lpPresInfo->rtStart)
- {
- if(m_pSubPicQueue)
- {
+ if(lpPresInfo->rtEnd > lpPresInfo->rtStart) {
+ if(m_pSubPicQueue) {
m_pSubPicQueue->SetFPS(m_fps);
- if(m_fUseInternalTimer && !g_bExternalSubtitleTime)
- {
+ if(m_fUseInternalTimer && !g_bExternalSubtitleTime) {
__super::SetTime(g_tSegmentStart + g_tSampleStart);
}
}
@@ -940,37 +840,31 @@ STDMETHODIMP CVMR9AllocatorPresenter::PresentImage(DWORD_PTR dwUserID, VMR9Prese
CSize VideoSize = GetVisibleVideoSize();
int arx = lpPresInfo->szAspectRatio.cx;
int ary = lpPresInfo->szAspectRatio.cy;
- if(arx > 0 && ary > 0)
- {
+ if(arx > 0 && ary > 0) {
arx = arx / ((float) m_NativeVideoSize.cx / VideoSize.cx);
ary = ary / ((float) m_NativeVideoSize.cy / VideoSize.cy);
VideoSize.cx = VideoSize.cy*arx/ary;
}
- if(VideoSize != GetVideoSize())
- {
+ if(VideoSize != GetVideoSize()) {
m_AspectRatio.SetSize(arx, ary);
AfxGetApp()->m_pMainWnd->PostMessage(WM_REARRANGERENDERLESS);
}
- if (!m_bPendingResetDevice)
- {
+ if (!m_bPendingResetDevice) {
CComPtr<IDirect3DTexture9> pTexture;
lpPresInfo->lpSurf->GetContainer(IID_IDirect3DTexture9, (void**)&pTexture);
- if(pTexture)
- {
+ if(pTexture) {
m_pVideoSurface[m_nCurSurface] = lpPresInfo->lpSurf;
- if(m_pVideoTexture[m_nCurSurface])
+ if(m_pVideoTexture[m_nCurSurface]) {
m_pVideoTexture[m_nCurSurface] = pTexture;
- }
- else
- {
+ }
+ } else {
hr = m_pD3DDev->StretchRect(lpPresInfo->lpSurf, NULL, m_pVideoSurface[m_nCurSurface], NULL, D3DTEXF_NONE);
}
// Tear test bars
- if (GetRenderersData()->m_fTearingTest)
- {
+ if (GetRenderersData()->m_fTearingTest) {
RECT rcTearing;
rcTearing.left = m_nTearingPos;
@@ -1000,10 +894,18 @@ 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;
+ 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)
@@ -1026,7 +928,9 @@ STDMETHODIMP CVMR9AllocatorPresenter::GetVideoPosition(LPRECT lpSRCRect, LPRECT
}
STDMETHODIMP CVMR9AllocatorPresenter::GetAspectRatioMode(DWORD* lpAspectRatioMode)
{
- if(lpAspectRatioMode) *lpAspectRatioMode = AM_ARMODE_STRETCHED;
+ if(lpAspectRatioMode) {
+ *lpAspectRatioMode = AM_ARMODE_STRETCHED;
+ }
return S_OK;
}
STDMETHODIMP CVMR9AllocatorPresenter::SetAspectRatioMode(DWORD AspectRatioMode)
@@ -1055,6 +959,8 @@ STDMETHODIMP CVMR9AllocatorPresenter::SetBorderColor(COLORREF Clr)
}
STDMETHODIMP CVMR9AllocatorPresenter::GetBorderColor(COLORREF* lpClr)
{
- if(lpClr) *lpClr = 0;
+ if(lpClr) {
+ *lpClr = 0;
+ }
return S_OK;
}
diff --git a/src/filters/renderer/VideoRenderers/VMR9AllocatorPresenter.h b/src/filters/renderer/VideoRenderers/VMR9AllocatorPresenter.h
index 95fed2830..0ef6cf3ed 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 4169317fb..dd49f718a 100644
--- a/src/filters/renderer/VideoRenderers/madVRAllocatorPresenter.cpp
+++ b/src/filters/renderer/VideoRenderers/madVRAllocatorPresenter.cpp
@@ -32,8 +32,7 @@ using namespace DSObjects;
interface __declspec(uuid("51FA8F61-1444-4597-996E-7495405753E6"))
IMadVRFullscreen :
-public IUnknown
-{
+public IUnknown {
STDMETHOD(ActivateFullscreenMode)(void) = 0;
};
@@ -46,8 +45,7 @@ CmadVRAllocatorPresenter::CmadVRAllocatorPresenter(HWND hWnd, bool bFullscreen,
, m_ScreenSize(0, 0)
, m_bIsFullscreen(bFullscreen)
{
- if(FAILED(hr))
- {
+ if(FAILED(hr)) {
_Error += L"ISubPicAllocatorPresenterImpl failed\n";
return;
}
@@ -57,8 +55,7 @@ CmadVRAllocatorPresenter::CmadVRAllocatorPresenter(HWND hWnd, bool bFullscreen,
CmadVRAllocatorPresenter::~CmadVRAllocatorPresenter()
{
- if(m_pSRCB)
- {
+ if(m_pSRCB) {
// nasty, but we have to let it know about our death somehow
((CSubRenderCallback*)(ISubRenderCallback*)m_pSRCB)->SetDXRAP(NULL);
}
@@ -84,10 +81,10 @@ STDMETHODIMP CmadVRAllocatorPresenter::NonDelegatingQueryInterface(REFIID riid,
return GetInterface((IVMRWindowlessControl*)this, ppv);
*/
- if(riid != IID_IUnknown && m_pDXR)
- {
- if(SUCCEEDED(m_pDXR->QueryInterface(riid, ppv)))
+ if(riid != IID_IUnknown && m_pDXR) {
+ if(SUCCEEDED(m_pDXR->QueryInterface(riid, ppv))) {
return S_OK;
+ }
}
return __super::NonDelegatingQueryInterface(riid, ppv);
@@ -98,50 +95,47 @@ HRESULT CmadVRAllocatorPresenter::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;
+ 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)
- {
+ if(m_pAllocator) {
m_pAllocator->ChangeDevice(pD3DDev);
- }
- else
- {
+ } else {
m_pAllocator = DNew CDX9SubPicAllocator(pD3DDev, size, GetRenderersSettings().fSPCPow2Tex);
- if(!m_pAllocator)
+ if(!m_pAllocator) {
return E_FAIL;
+ }
}
HRESULT hr = S_OK;
@@ -149,10 +143,13 @@ HRESULT CmadVRAllocatorPresenter::SetDevice(IDirect3DDevice9* pD3DDev)
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))
+ if(!m_pSubPicQueue || FAILED(hr)) {
return E_FAIL;
+ }
- if(m_SubPicProvider) m_pSubPicQueue->SetSubPicProvider(m_SubPicProvider);
+ if(m_SubPicProvider) {
+ m_pSubPicQueue->SetSubPicProvider(m_SubPicProvider);
+ }
return S_OK;
}
@@ -163,7 +160,9 @@ HRESULT CmadVRAllocatorPresenter::Render(
{
__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);
+ if(atpf > 0 && m_pSubPicQueue) {
+ m_pSubPicQueue->SetFPS(10000000.0 / atpf);
+ }
AlphaBltSubPic(CSize(width, height));
return S_OK;
}
@@ -174,27 +173,29 @@ STDMETHODIMP CmadVRAllocatorPresenter::CreateRenderer(IUnknown** ppRenderer)
{
CheckPointer(ppRenderer, E_POINTER);
- if(m_pDXR) return E_UNEXPECTED;
+ if(m_pDXR) {
+ return E_UNEXPECTED;
+ }
m_pDXR.CoCreateInstance(CLSID_madVR, GetOwner());
- if(!m_pDXR) return E_FAIL;
+ if(!m_pDXR) {
+ return E_FAIL;
+ }
- if (m_bIsFullscreen)
- {
+ if (m_bIsFullscreen) {
CComQIPtr<IMadVRFullscreen> pVRF = m_pDXR;
- if (pVRF != NULL)
+ if (pVRF != NULL) {
pVRF->ActivateFullscreenMode();
+ }
}
CComQIPtr<ISubRender> pSR = m_pDXR;
- if(!pSR)
- {
+ if(!pSR) {
m_pDXR = NULL;
return E_FAIL;
}
m_pSRCB = DNew CSubRenderCallback(this);
- if(FAILED(pSR->SetCallback(m_pSRCB)))
- {
+ if(FAILED(pSR->SetCallback(m_pSRCB))) {
m_pDXR = NULL;
return E_FAIL;
}
@@ -203,22 +204,21 @@ STDMETHODIMP CmadVRAllocatorPresenter::CreateRenderer(IUnknown** ppRenderer)
MONITORINFO mi;
mi.cbSize = sizeof(MONITORINFO);
- if (GetMonitorInfo(MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST), &mi))
+ 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)
- {
+ 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)
- {
+ if(CComQIPtr<IVideoWindow> pVW = m_pDXR) {
pVW->SetWindowPosition(w.left, w.top, w.right - w.left, w.bottom - w.top);
}
}
@@ -227,15 +227,14 @@ STDMETHODIMP_(SIZE) CmadVRAllocatorPresenter::GetVideoSize(bool fCorrectAR)
{
SIZE size = {0, 0};
- if(!fCorrectAR)
- {
- if(CComQIPtr<IBasicVideo> pBV = m_pDXR)
+ if(!fCorrectAR) {
+ if(CComQIPtr<IBasicVideo> pBV = m_pDXR) {
pBV->GetVideoSize(&size.cx, &size.cy);
- }
- else
- {
- if(CComQIPtr<IBasicVideo2> pBV2 = m_pDXR)
+ }
+ } else {
+ if(CComQIPtr<IBasicVideo2> pBV2 = m_pDXR) {
pBV2->GetPreferredAspectRatio(&size.cx, &size.cy);
+ }
}
return size;
@@ -249,8 +248,9 @@ STDMETHODIMP_(bool) CmadVRAllocatorPresenter::Paint(bool fAll)
STDMETHODIMP CmadVRAllocatorPresenter::GetDIB(BYTE* lpDib, DWORD* size)
{
HRESULT hr = E_NOTIMPL;
- if(CComQIPtr<IBasicVideo> pBV = m_pDXR)
+ if(CComQIPtr<IBasicVideo> pBV = m_pDXR) {
hr = pBV->GetCurrentImage((long*)size, (long*)lpDib);
+ }
return hr;
}
diff --git a/src/filters/renderer/VideoRenderers/madVRAllocatorPresenter.h b/src/filters/renderer/VideoRenderers/madVRAllocatorPresenter.h
index 540974c98..a8c763324 100644
--- a/src/filters/renderer/VideoRenderers/madVRAllocatorPresenter.h
+++ b/src/filters/renderer/VideoRenderers/madVRAllocatorPresenter.h
@@ -28,80 +28,74 @@
namespace DSObjects
{
-class CmadVRAllocatorPresenter
- : public CSubPicAllocatorPresenterImpl
-{
- class CSubRenderCallback : public CUnknown, public ISubRenderCallback, public CCritSec
+ class CmadVRAllocatorPresenter
+ : public CSubPicAllocatorPresenterImpl
{
- CmadVRAllocatorPresenter* m_pDXRAP;
+ class CSubRenderCallback : public CUnknown, public ISubRenderCallback, 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)
+ __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<ISubRenderCallback> m_pSRCB;
+ CSize m_ScreenSize;
+ bool m_bIsFullscreen;
public:
- CSubRenderCallback(CmadVRAllocatorPresenter* pDXRAP)
- : CUnknown(_T("CSubRender"), NULL)
- , m_pDXRAP(pDXRAP)
- {
- }
+ CmadVRAllocatorPresenter(HWND hWnd, bool bFullscreen, HRESULT& hr, CString &_Error);
+ virtual ~CmadVRAllocatorPresenter();
DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv)
- {
- return
- QI(ISubRenderCallback)
- __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;
- }
+ 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);
};
-
- CComPtr<IUnknown> m_pDXR;
- CComPtr<ISubRenderCallback> m_pSRCB;
- CSize m_ScreenSize;
- bool m_bIsFullscreen;
-
-public:
- CmadVRAllocatorPresenter(HWND hWnd, bool bFullscreen, 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/source/BaseSource/BaseSource.cpp b/src/filters/source/BaseSource/BaseSource.cpp
index 3c42d2732..1c26cb6ba 100644
--- a/src/filters/source/BaseSource/BaseSource.cpp
+++ b/src/filters/source/BaseSource/BaseSource.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -31,7 +31,7 @@
// CBaseStream
//
-CBaseStream::CBaseStream(TCHAR* name, CSource* pParent, HRESULT* phr)
+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)
@@ -50,21 +50,20 @@ CBaseStream::~CBaseStream()
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);
+ : CSourceStream::NonDelegatingQueryInterface(riid, ppv);
}
void CBaseStream::UpdateFromSeek()
{
- if(ThreadExists())
- {
+ 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;
DeliverBeginFlush();
@@ -73,7 +72,7 @@ void CBaseStream::UpdateFromSeek()
// complete the flush
DeliverEndFlush();
- m_bFlushing = FALSE;
+ m_bFlushing = FALSE;
// restart
Run();
@@ -82,8 +81,9 @@ void CBaseStream::UpdateFromSeek()
HRESULT CBaseStream::SetRate(double dRate)
{
- if(dRate <= 0)
+ if(dRate <= 0) {
return E_INVALIDARG;
+ }
{
CAutoLock lock(CSourceSeeking::m_pLock);
@@ -97,45 +97,46 @@ HRESULT CBaseStream::SetRate(double dRate)
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);
+ {
+ 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)
+ {
+ 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)
@@ -145,36 +146,39 @@ HRESULT CBaseStream::FillBuffer(IMediaSample* pSample)
{
CAutoLock cAutoLockShared(&m_cSharedState);
- if(m_rtPosition >= m_rtStop)
+ if(m_rtPosition >= m_rtStop) {
return S_FALSE;
+ }
BYTE* pOut = NULL;
- if(FAILED(hr = pSample->GetPointer(&pOut)) || !pOut)
+ if(FAILED(hr = pSample->GetPointer(&pOut)) || !pOut) {
return S_FALSE;
+ }
int nFrame = m_rtPosition / m_AvgTimePerFrame; // (int)(1.0 * m_rtPosition / m_AvgTimePerFrame + 0.5);
long len = pSample->GetSize();
hr = FillBuffer(pSample, nFrame, pOut, len);
- if(hr != S_OK) return hr;
+ if(hr != S_OK) {
+ return hr;
+ }
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);
+ // 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);
- if(m_bDiscontinuity)
- {
+ if(m_bDiscontinuity) {
pSample->SetDiscontinuity(TRUE);
m_bDiscontinuity = FALSE;
}
diff --git a/src/filters/source/BaseSource/BaseSource.h b/src/filters/source/BaseSource/BaseSource.h
index b305defdc..fea572b3c 100644
--- a/src/filters/source/BaseSource/BaseSource.h
+++ b/src/filters/source/BaseSource/BaseSource.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -34,17 +34,17 @@ protected:
public:
CBaseSource(TCHAR* name, LPUNKNOWN lpunk, HRESULT* phr, const CLSID& clsid)
- : CSource(name, lpunk, clsid)
- {
- if(phr) *phr = S_OK;
+ : CSource(name, lpunk, clsid) {
+ if(phr) {
+ *phr = S_OK;
+ }
}
DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv)
- {
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv) {
CheckPointer(ppv, E_POINTER);
- return
+ return
QI(IFileSourceFilter)
QI(IAMFilterMiscFlags)
__super::NonDelegatingQueryInterface(riid, ppv);
@@ -52,33 +52,37 @@ public:
// IFileSourceFilter
- STDMETHODIMP Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt)
- {
+ 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)
+ if(GetPinCount() > 0) {
return VFW_E_ALREADY_CONNECTED;
+ }
HRESULT hr = S_OK;
- if(!(DNew TStream(pszFileName, this, &hr)))
+ if(!(DNew TStream(pszFileName, this, &hr))) {
return E_OUTOFMEMORY;
+ }
- if(FAILED(hr))
+ if(FAILED(hr)) {
return hr;
+ }
m_fn = pszFileName;
return S_OK;
}
- STDMETHODIMP GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt)
- {
+ STDMETHODIMP GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt) {
size_t nCount;
- if(!ppszFileName) return E_POINTER;
-
+ if(!ppszFileName) {
+ return E_POINTER;
+ }
+
nCount = m_fn.GetLength()+1;
*ppszFileName = (LPOLESTR)CoTaskMemAlloc(nCount*sizeof(WCHAR));
- if(!(*ppszFileName))
+ if(!(*ppszFileName)) {
return E_OUTOFMEMORY;
+ }
wcscpy_s(*ppszFileName, nCount, m_fn);
@@ -87,13 +91,12 @@ public:
// IAMFilterMiscFlags
- STDMETHODIMP_(ULONG) GetMiscFlags()
- {
+ STDMETHODIMP_(ULONG) GetMiscFlags() {
return AM_FILTER_MISC_FLAGS_IS_SOURCE;
}
};
-class CBaseStream
+class CBaseStream
: public CSourceStream
, public CSourceSeeking
{
@@ -113,18 +116,20 @@ private:
STDMETHODIMP SetRate(double dRate);
HRESULT ChangeStart();
- HRESULT ChangeStop();
- HRESULT ChangeRate() {return S_OK;}
+ HRESULT ChangeStop();
+ HRESULT ChangeRate() {
+ return S_OK;
+ }
public:
- CBaseStream(TCHAR* name, CSource* pParent, HRESULT* phr);
+ 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);
};
diff --git a/src/filters/source/BaseSource/stdafx.cpp b/src/filters/source/BaseSource/stdafx.cpp
index 13934d005..bea3f980a 100644
--- a/src/filters/source/BaseSource/stdafx.cpp
+++ b/src/filters/source/BaseSource/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/source/BaseSource/stdafx.h b/src/filters/source/BaseSource/stdafx.h
index 4811c9499..eb1a0a29e 100644
--- a/src/filters/source/BaseSource/stdafx.h
+++ b/src/filters/source/BaseSource/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/source/D2VSource/D2VSource.cpp b/src/filters/source/D2VSource/D2VSource.cpp
index 1745e381d..ec59fad28 100644
--- a/src/filters/source/D2VSource/D2VSource.cpp
+++ b/src/filters/source/D2VSource/D2VSource.cpp
@@ -1,16 +1,16 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
*
* 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, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -24,23 +24,19 @@
#ifdef REGISTER_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
{&MEDIATYPE_Video, &MEDIASUBTYPE_YUY2}
};
-const AMOVIESETUP_PIN sudOpPin[] =
-{
+const AMOVIESETUP_PIN sudOpPin[] = {
{L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesOut), sudPinTypesOut}
};
-const AMOVIESETUP_FILTER sudFilter[] =
-{
+const AMOVIESETUP_FILTER sudFilter[] = {
{&__uuidof(CD2VSource), L"MPC - D2VSource", MERIT_NORMAL, countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory}
};
-CFactoryTemplate g_Templates[] =
-{
+CFactoryTemplate g_Templates[] = {
{sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CD2VSource>, NULL, &sudFilter[0]}
};
@@ -49,15 +45,15 @@ int g_cTemplates = countof(g_Templates);
STDAPI DllRegisterServer()
{
SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{47CE0591-C4D5-4b41-BED7-28F59AD76228}"),
+ _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("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("Media Type\\Extensions"), _T(".d2v"),
_T("Source Filter"), _T("{47CE0591-C4D5-4b41-BED7-28F59AD76228}"));
return AMovieDllRegisterServer2(TRUE);
@@ -84,7 +80,9 @@ CFilterApp theApp;
CD2VSource::CD2VSource(LPUNKNOWN lpunk, HRESULT* phr)
: CBaseSource<CD2VStream>(NAME("CD2VSource"), lpunk, phr, __uuidof(this))
{
- if(phr) *phr = S_OK;
+ if(phr) {
+ *phr = S_OK;
+ }
}
CD2VSource::~CD2VSource()
@@ -95,35 +93,40 @@ CD2VSource::~CD2VSource()
// CD2VStream
//
-CD2VStream::CD2VStream(const WCHAR* fn, CSource* pParent, HRESULT* phr)
+CD2VStream::CD2VStream(const WCHAR* fn, CSource* pParent, HRESULT* phr)
: 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;
+ if(!m_pDecoder) {
+ if(phr) {
+ *phr = E_OUTOFMEMORY;
+ }
return;
}
- if(!m_pDecoder->Open(CString(fn), CMPEG2Dec::YUY2))
- {
- if(phr) *phr = E_FAIL;
+ 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;
+ 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;
+ if(phr) {
+ *phr = m_rtDuration > 0 ? S_OK : E_FAIL;
+ }
}
CD2VStream::~CD2VStream()
@@ -133,37 +136,42 @@ CD2VStream::~CD2VStream()
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))
+ if(!GetDim(w, h, bpp)) {
return E_FAIL;
+ }
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)
+ if(!m_pDecoder) {
return S_FALSE;
+ }
AM_MEDIA_TYPE* pmt;
- if(SUCCEEDED(pSample->GetMediaType(&pmt)) && pmt)
- {
+ if(SUCCEEDED(pSample->GetMediaType(&pmt)) && pmt) {
CMediaType mt(*pmt);
SetMediaType(&mt);
@@ -171,8 +179,9 @@ HRESULT CD2VStream::FillBuffer(IMediaSample* pSample, int nFrame, BYTE* pOut, lo
}
int w, h, bpp;
- if(!GetDim(w, h, bpp))
+ if(!GetDim(w, h, bpp)) {
return S_FALSE;
+ }
BYTE* pIn = m_pFrameBuffer;
@@ -183,10 +192,9 @@ HRESULT CD2VStream::FillBuffer(IMediaSample* pSample, int nFrame, BYTE* pOut, lo
m_pDecoder->Decode(pIn, (unsigned long)(nFrame), pitchIn);
- for(int y = 0, p = min(pitchIn, pitchOut);
- y < h;
- y++, pIn += pitchIn, pOut += pitchOut)
- {
+ for(int y = 0, p = min(pitchIn, pitchOut);
+ y < h;
+ y++, pIn += pitchIn, pOut += pitchOut) {
memcpy(pOut, pIn, p);
}
@@ -197,15 +205,19 @@ HRESULT CD2VStream::FillBuffer(IMediaSample* pSample, int nFrame, BYTE* pOut, lo
HRESULT CD2VStream::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_YUY2);
- pmt->SetFormatType(&FORMAT_VideoInfo);
- pmt->SetTemporalCompression(FALSE);
+ 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));
@@ -220,17 +232,17 @@ HRESULT CD2VStream::GetMediaType(int iPosition, CMediaType* pmt)
pmt->SetSampleSize(vih->bmiHeader.biSizeImage);
- return NOERROR;
+ return NOERROR;
}
HRESULT CD2VStream::SetMediaType(const CMediaType* pmt)
{
- if(m_pDecoder)
- {
- if(pmt->subtype == MEDIASUBTYPE_YUY2)
+ if(m_pDecoder) {
+ if(pmt->subtype == MEDIASUBTYPE_YUY2) {
m_pDecoder->m_dstFormat = CMPEG2Dec::YUY2;
- else
+ } else {
return E_FAIL;
+ }
}
return CSourceStream::SetMediaType(pmt);
@@ -239,20 +251,19 @@ HRESULT CD2VStream::SetMediaType(const CMediaType* pmt)
HRESULT CD2VStream::CheckMediaType(const CMediaType* pmt)
{
return pmt->majortype == MEDIATYPE_Video
- && pmt->subtype == MEDIASUBTYPE_YUY2
- && pmt->formattype == FORMAT_VideoInfo
- ? S_OK
- : E_INVALIDARG;
+ && 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)
- {
+ 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;
@@ -262,20 +273,15 @@ STDMETHODIMP CD2VStream::Notify(IBaseFilter* pSender, Quality q)
bool CD2VStream::GetDim(int& w, int& h, int& bpp)
{
- if(m_mt.formattype == FORMAT_VideoInfo)
- {
+ 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)
- {
+ } 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
- {
+ } else {
return(false);
}
diff --git a/src/filters/source/D2VSource/D2VSource.h b/src/filters/source/D2VSource/D2VSource.h
index d36f05956..6d38f3936 100644
--- a/src/filters/source/D2VSource/D2VSource.h
+++ b/src/filters/source/D2VSource/D2VSource.h
@@ -1,16 +1,16 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
*
* 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, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -24,7 +24,7 @@
class CD2VStream;
class __declspec(uuid("47CE0591-C4D5-4b41-BED7-28F59AD76228"))
-CD2VSource : public CBaseSource<CD2VStream>
+ CD2VSource : public CBaseSource<CD2VStream>
{
public:
CD2VSource(LPUNKNOWN lpunk, HRESULT* phr);
@@ -42,15 +42,15 @@ private:
bool GetDim(int& w, int& h, int& bpp);
public:
- CD2VStream(const WCHAR* fn, CSource* pParent, HRESULT* phr);
+ 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);
};
diff --git a/src/filters/source/DTSAC3Source/DTSAC3Source.cpp b/src/filters/source/DTSAC3Source/DTSAC3Source.cpp
index ea2c58ba2..98e61db08 100644
--- a/src/filters/source/DTSAC3Source/DTSAC3Source.cpp
+++ b/src/filters/source/DTSAC3Source/DTSAC3Source.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -30,21 +30,18 @@
#ifdef REGISTER_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] =
-{
+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},
};
-const AMOVIESETUP_PIN sudOpPin[] =
-{
+const AMOVIESETUP_PIN sudOpPin[] = {
{L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesOut), sudPinTypesOut}
};
-const AMOVIESETUP_FILTER sudFilter[] =
-{
+const AMOVIESETUP_FILTER sudFilter[] = {
#ifdef DDPLUS_ONLY
{&__uuidof(CDTSAC3Source), L"MPC - DD+ Source", MERIT_NORMAL, countof(sudOpPin), sudOpPin}
#else
@@ -52,8 +49,7 @@ const AMOVIESETUP_FILTER sudFilter[] =
#endif
};
-CFactoryTemplate g_Templates[] =
-{
+CFactoryTemplate g_Templates[] = {
{sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CDTSAC3Source>, NULL, &sudFilter[0]}
};
@@ -62,36 +58,36 @@ int g_cTemplates = countof(g_Templates);
STDAPI DllRegisterServer()
{
SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"),
+ _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"),
_T("0"), _T("0,4,,7FFE8001"));
SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"),
+ _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"),
_T("1"), _T("0,2,,0B77"));
SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"),
+ _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"),
_T("2"), _T("0,2,,770B"));
SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"),
+ _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"),
_T("Source Filter"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"));
#ifndef DDPLUS_ONLY
SetRegKeyValue(
- _T("Media Type\\Extensions"), _T(".dts"),
+ _T("Media Type\\Extensions"), _T(".dts"),
_T("Source Filter"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"));
SetRegKeyValue(
- _T("Media Type\\Extensions"), _T(".ac3"),
+ _T("Media Type\\Extensions"), _T(".ac3"),
_T("Source Filter"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"));
#endif
SetRegKeyValue(
- _T("Media Type\\Extensions"), _T(".ddp"),
+ _T("Media Type\\Extensions"), _T(".ddp"),
_T("Source Filter"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"));
SetRegKeyValue(
- _T("Media Type\\Extensions"), _T(".ec3"),
+ _T("Media Type\\Extensions"), _T(".ec3"),
_T("Source Filter"), _T("{B4A7BE85-551D-4594-BDC7-832B09185041}"));
return AMovieDllRegisterServer2(TRUE);
@@ -131,7 +127,7 @@ CDTSAC3Source::~CDTSAC3Source()
// CDTSAC3Stream
-CDTSAC3Stream::CDTSAC3Stream(const WCHAR* wfn, CSource* pParent, HRESULT* phr)
+CDTSAC3Stream::CDTSAC3Stream(const WCHAR* wfn, CSource* pParent, HRESULT* phr)
: CBaseStream(NAME("CDTSAC3Stream"), pParent, phr)
, m_nFileOffset(0)
{
@@ -143,25 +139,28 @@ CDTSAC3Stream::CDTSAC3Stream(const WCHAR* wfn, CSource* pParent, HRESULT* phr)
CString fn(wfn);
- if(!m_file.Open(fn, CFile::modeRead|CFile::shareDenyNone))
- {
- if(phr) *phr = E_FAIL;
+ if(!m_file.Open(fn, CFile::modeRead|CFile::shareDenyNone)) {
+ if(phr) {
+ *phr = E_FAIL;
+ }
return;
}
DWORD id = 0;
if(m_file.Read(&id, sizeof(id)) != sizeof(id)
- || id != 0x0180FE7F && (WORD)id != 0x0b77 && (WORD)id != 0x770b)
- {
- if(phr) *phr = E_FAIL;
+ || id != 0x0180FE7F && (WORD)id != 0x0b77 && (WORD)id != 0x770b) {
+ if(phr) {
+ *phr = E_FAIL;
+ }
return;
}
- if(id == 0x0180FE7F)
- {
+ if(id == 0x0180FE7F) {
#ifdef DDPLUS_ONLY
-//Temporary patch to disable DTS source
- if(phr) *phr = E_FAIL;
+ //Temporary patch to disable DTS source
+ if(phr) {
+ *phr = E_FAIL;
+ }
return;
#endif
BYTE buff[8];
@@ -181,8 +180,7 @@ CDTSAC3Stream::CDTSAC3Stream(const WCHAR* wfn, CSource* pParent, HRESULT* phr)
UNUSED_ALWAYS(npcmsampleblocks);
UNUSED_ALWAYS(audiochannelarrangement);
- int freqtbl[] =
- {
+ int freqtbl[] = {
0,8000,16000,32000,
0,0,
11025,22050,44100,
@@ -191,8 +189,7 @@ CDTSAC3Stream::CDTSAC3Stream(const WCHAR* wfn, CSource* pParent, HRESULT* phr)
0,0
};
- int bitratetbl[] =
- {
+ int bitratetbl[] = {
32000,56000,64000,96000,112000,128000,192000,224000,
256000,320000,384000,448000,512000,576000,640000,754500,
960000,1024000,1152000,1280000,1344000,1408000,1411200,1472000,
@@ -203,50 +200,50 @@ CDTSAC3Stream::CDTSAC3Stream(const WCHAR* wfn, CSource* pParent, HRESULT* phr)
m_nSamplesPerSec = freqtbl[freq];
m_nAvgBytesPerSec = (bitratetbl[transbitrate] + 4) / 8;
-// m_nBytesPerFrame = m_nAvgBytesPerSec*10.656063618290258449304174950298/1000 + 0.5;
+ // m_nBytesPerFrame = m_nAvgBytesPerSec*10.656063618290258449304174950298/1000 + 0.5;
m_nBytesPerFrame = framebytes*DTS_MAGIC_NUMBER;
- if (framebytes == 2012)
- {
+ if (framebytes == 2012) {
// DTS and DTS-HD tracks from HD DVD and Blu-Ray sources have framesizes of 2012 bytes
// but if we handle them mathematically "correctly", audio sync will slowly drift away
// we have to handle them as if they had 2013 bytes
m_AvgTimePerFrame = 10000000i64 * (2013*DTS_MAGIC_NUMBER) * 8 / bitratetbl[transbitrate];
- }
- else
+ } else {
m_AvgTimePerFrame = 10000000i64 * m_nBytesPerFrame * 8 / bitratetbl[transbitrate];
+ }
m_subtype = MEDIASUBTYPE_DTS;
m_wFormatTag = WAVE_FORMAT_DVD_DTS;
m_streamid = 0x88;
- }
- else
- {
+ } else {
BYTE info, info1, bsid;
- if((BYTE)id == 0x77) m_file.Seek(1, CFile::current); // LE
+ if((BYTE)id == 0x77) {
+ m_file.Seek(1, CFile::current); // LE
+ }
m_file.Read(&info, 1);
m_file.Read(&info1, 1);
bsid = (info1>>3);
- if(bsid>=0 && bsid<=8) //AC3
- {
+ if(bsid>=0 && bsid<=8) { //AC3
#ifdef DDPLUS_ONLY
-//Temporary patch to disable AC3 source
- if(phr) *phr = E_FAIL;
+ //Temporary patch to disable AC3 source
+ if(phr) {
+ *phr = E_FAIL;
+ }
return;
#endif
BYTE freq = info>>6;
BYTE bitrate = info&0x3f;
- if(bitrate >= 38)
- {
- if(phr) *phr = E_FAIL;
+ if(bitrate >= 38) {
+ if(phr) {
+ *phr = E_FAIL;
+ }
return;
}
int freqtbl[] = {48000,44100,32000,48000};
- int bitratetbl[] =
- {
+ int bitratetbl[] = {
32000,32000,40000,40000,48000,48000,56000,56000,64000,64000,
80000,80000,96000,96000,112000,112000,128000,128000,160000,160000,
192000,192000,224000,224000,256000,256000,320000,320000,384000,384000,
@@ -259,18 +256,15 @@ CDTSAC3Stream::CDTSAC3Stream(const WCHAR* wfn, CSource* pParent, HRESULT* phr)
m_nAvgBytesPerSec = (bitratetbl[bitrate] + 4) / 8;
m_nBytesPerFrame = m_nAvgBytesPerSec*32/1000*AC3_MAGIC_NUMBER;
m_AvgTimePerFrame = 10000000i64 * m_nBytesPerFrame * 8 / bitratetbl[bitrate];
-
+
m_subtype = MEDIASUBTYPE_DOLBY_AC3;
m_wFormatTag = WAVE_FORMAT_DOLBY_AC3;
m_streamid = 0x80;
- }
- else if(bsid>=11 && bsid <=16) //DD+
- {
+ } else if(bsid>=11 && bsid <=16) { //DD+
BYTE fscod = info>>6;
BYTE numblkscod = (info&0x30)>>4;
- if(fscod == 3)
- {
+ if(fscod == 3) {
fscod = numblkscod+3;
numblkscod = 3;
}
@@ -284,10 +278,10 @@ CDTSAC3Stream::CDTSAC3Stream(const WCHAR* wfn, CSource* pParent, HRESULT* phr)
m_subtype = MEDIASUBTYPE_DOLBY_AC3;
m_wFormatTag = WAVE_FORMAT_DOLBY_AC3;
m_streamid = 0xC0;
- }
- else
- {
- if(phr) *phr = E_FAIL;
+ } else {
+ if(phr) {
+ *phr = E_FAIL;
+ }
return;
}
@@ -303,21 +297,25 @@ 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_nBytesPerFrame+35;
- 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)
@@ -328,10 +326,8 @@ HRESULT CDTSAC3Stream::FillBuffer(IMediaSample* pSample, int nFrame, BYTE* pOut,
const GUID* subtype = &m_mt.subtype;
UNUSED_ALWAYS(subtype);
- if(*majortype == MEDIATYPE_DVD_ENCRYPTED_PACK)
- {
- BYTE PESHeader[] =
- {
+ if(*majortype == MEDIATYPE_DVD_ENCRYPTED_PACK) {
+ 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)
@@ -343,10 +339,8 @@ HRESULT CDTSAC3Stream::FillBuffer(IMediaSample* pSample, int nFrame, BYTE* pOut,
majortype = &MEDIATYPE_MPEG2_PES;
}
- if(*majortype == MEDIATYPE_MPEG2_PES)
- {
- BYTE Private1Header[] =
- {
+ if(*majortype == MEDIATYPE_MPEG2_PES) {
+ BYTE Private1Header[] = {
0x00,0x00,0x01,0xBD, // private stream 1 id
(m_nBytesPerFrame+15)>>8,(m_nBytesPerFrame+15)&255, // packet length
0x81,0x80, // marker, original, PTS - flags
@@ -363,10 +357,11 @@ HRESULT CDTSAC3Stream::FillBuffer(IMediaSample* pSample, int nFrame, BYTE* pOut,
majortype = &MEDIATYPE_Audio;
}
- if(*majortype == MEDIATYPE_Audio)
- {
+ if(*majortype == MEDIATYPE_Audio) {
m_file.Seek(m_nFileOffset + nFrame*m_nBytesPerFrame, CFile::begin);
- if(m_file.Read(pOut, m_nBytesPerFrame) < m_nBytesPerFrame) return S_FALSE;
+ if(m_file.Read(pOut, m_nBytesPerFrame) < m_nBytesPerFrame) {
+ return S_FALSE;
+ }
pOut += m_nBytesPerFrame;
}
@@ -378,43 +373,42 @@ HRESULT CDTSAC3Stream::FillBuffer(IMediaSample* pSample, int nFrame, BYTE* pOut,
bool CDTSAC3Stream::CheckDTS(const CMediaType* pmt)
{
return (pmt->majortype == MEDIATYPE_Audio
- || pmt->majortype == MEDIATYPE_MPEG2_PES
+ || pmt->majortype == MEDIATYPE_MPEG2_PES
|| pmt->majortype == MEDIATYPE_DVD_ENCRYPTED_PACK)
- && pmt->subtype == MEDIASUBTYPE_DTS;
-// return pmt->majortype == MEDIATYPE_Audio && pmt->subtype == MEDIASUBTYPE_DTS;
+ && pmt->subtype == MEDIASUBTYPE_DTS;
+ // return pmt->majortype == MEDIATYPE_Audio && pmt->subtype == MEDIASUBTYPE_DTS;
}
bool CDTSAC3Stream::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;
+ && 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->majortype == MEDIATYPE_MPEG2_PES
+ || pmt->majortype == MEDIATYPE_MPEG2_PES
|| pmt->majortype == MEDIATYPE_DVD_ENCRYPTED_PACK)
- && pmt->subtype == MEDIASUBTYPE_DOLBY_AC3;
-// return pmt->majortype == MEDIATYPE_Audio && pmt->subtype == MEDIASUBTYPE_DOLBY_AC3;
+ && pmt->subtype == MEDIASUBTYPE_DOLBY_AC3;
+ // return pmt->majortype == MEDIATYPE_Audio && pmt->subtype == MEDIASUBTYPE_DOLBY_AC3;
}
bool CDTSAC3Stream::CheckWAVEAC3(const CMediaType* pmt)
{
return pmt->majortype == MEDIATYPE_Audio
- && pmt->subtype == MEDIASUBTYPE_DOLBY_AC3
- && pmt->formattype == FORMAT_WaveFormatEx
- && ((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag == WAVE_FORMAT_DOLBY_AC3;
+ && pmt->subtype == MEDIASUBTYPE_DOLBY_AC3
+ && pmt->formattype == FORMAT_WaveFormatEx
+ && ((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag == WAVE_FORMAT_DOLBY_AC3;
}
HRESULT CDTSAC3Stream::GetMediaType(int iPosition, CMediaType* pmt)
{
- CAutoLock cAutoLock(m_pFilter->pStateLock());
+ CAutoLock cAutoLock(m_pFilter->pStateLock());
- if(iPosition >= 0 && iPosition < 5)
- {
+ if(iPosition >= 0 && iPosition < 5) {
pmt->subtype = m_subtype;
pmt->formattype = FORMAT_WaveFormatEx;
WAVEFORMATEX* wfe = (WAVEFORMATEX*)pmt->AllocFormatBuffer(sizeof(WAVEFORMATEX));
@@ -425,29 +419,26 @@ HRESULT CDTSAC3Stream::GetMediaType(int iPosition, CMediaType* pmt)
wfe->nAvgBytesPerSec = m_nAvgBytesPerSec;
wfe->nChannels = 6;
- switch(iPosition)
- {
- case 0:
- pmt->majortype = MEDIATYPE_Audio;
- break;
- case 1:
- pmt->ResetFormatBuffer();
- pmt->formattype = FORMAT_None;
- case 2:
- pmt->majortype = MEDIATYPE_MPEG2_PES;
- break;
- case 3:
- pmt->ResetFormatBuffer();
- pmt->formattype = FORMAT_None;
- case 4:
- pmt->majortype = MEDIATYPE_DVD_ENCRYPTED_PACK;
- break;
- default:
- return E_INVALIDARG;
+ switch(iPosition) {
+ case 0:
+ pmt->majortype = MEDIATYPE_Audio;
+ break;
+ case 1:
+ pmt->ResetFormatBuffer();
+ pmt->formattype = FORMAT_None;
+ case 2:
+ pmt->majortype = MEDIATYPE_MPEG2_PES;
+ break;
+ case 3:
+ pmt->ResetFormatBuffer();
+ pmt->formattype = FORMAT_None;
+ case 4:
+ pmt->majortype = MEDIATYPE_DVD_ENCRYPTED_PACK;
+ break;
+ default:
+ return E_INVALIDARG;
}
- }
- else if(iPosition == 5)
- {
+ } else if(iPosition == 5) {
pmt->majortype = MEDIATYPE_Audio;
pmt->subtype = FOURCCMap(m_wFormatTag);
pmt->formattype = FORMAT_WaveFormatEx;
@@ -459,13 +450,11 @@ HRESULT CDTSAC3Stream::GetMediaType(int iPosition, CMediaType* pmt)
wfe->nAvgBytesPerSec = m_nAvgBytesPerSec;
wfe->nChannels = 2;
wfe->nBlockAlign = 1;
- }
- else
- {
+ } else {
return VFW_S_NO_MORE_ITEMS;
}
- pmt->SetTemporalCompression(FALSE);
+ pmt->SetTemporalCompression(FALSE);
return S_OK;
}
@@ -473,7 +462,7 @@ HRESULT CDTSAC3Stream::GetMediaType(int iPosition, CMediaType* pmt)
HRESULT CDTSAC3Stream::CheckMediaType(const CMediaType* pmt)
{
return CheckDTS(pmt) || CheckWAVEDTS(pmt)
- || CheckAC3(pmt) || CheckWAVEAC3(pmt)
- ? S_OK
- : E_INVALIDARG;
+ || CheckAC3(pmt) || CheckWAVEAC3(pmt)
+ ? S_OK
+ : E_INVALIDARG;
}
diff --git a/src/filters/source/DTSAC3Source/DTSAC3Source.h b/src/filters/source/DTSAC3Source/DTSAC3Source.h
index 5f0b1a976..75593e8f4 100644
--- a/src/filters/source/DTSAC3Source/DTSAC3Source.h
+++ b/src/filters/source/DTSAC3Source/DTSAC3Source.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -27,7 +27,7 @@
class CDTSAC3Stream;
class __declspec(uuid("B4A7BE85-551D-4594-BDC7-832B09185041"))
-CDTSAC3Source : public CBaseSource<CDTSAC3Stream>
+ CDTSAC3Source : public CBaseSource<CDTSAC3Stream>
{
public:
CDTSAC3Source(LPUNKNOWN lpunk, HRESULT* phr);
@@ -48,12 +48,12 @@ class CDTSAC3Stream : public CBaseStream
bool CheckWAVEAC3(const CMediaType* pmt);
public:
- CDTSAC3Stream(const WCHAR* wfn, CSource* pParent, HRESULT* phr);
+ 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 CheckMediaType(const CMediaType* pMediaType);
+ HRESULT GetMediaType(int iPosition, CMediaType* pmt);
};
diff --git a/src/filters/source/DTSAC3Source/stdafx.cpp b/src/filters/source/DTSAC3Source/stdafx.cpp
index 13934d005..bea3f980a 100644
--- a/src/filters/source/DTSAC3Source/stdafx.cpp
+++ b/src/filters/source/DTSAC3Source/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/source/DTSAC3Source/stdafx.h b/src/filters/source/DTSAC3Source/stdafx.h
index 62d50a36b..d1c3768d8 100644
--- a/src/filters/source/DTSAC3Source/stdafx.h
+++ b/src/filters/source/DTSAC3Source/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/source/FLICSource/FLICSource.cpp b/src/filters/source/FLICSource/FLICSource.cpp
index 696103f59..16e92a992 100644
--- a/src/filters/source/FLICSource/FLICSource.cpp
+++ b/src/filters/source/FLICSource/FLICSource.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -25,23 +25,19 @@
#ifdef REGISTER_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
{&MEDIATYPE_Video, &MEDIASUBTYPE_RGB32},
};
-const AMOVIESETUP_PIN sudOpPin[] =
-{
+const AMOVIESETUP_PIN sudOpPin[] = {
{L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesOut), sudPinTypesOut}
};
-const AMOVIESETUP_FILTER sudFilter[] =
-{
+const AMOVIESETUP_FILTER sudFilter[] = {
{&__uuidof(CFLICSource), L"MPC - FLICSource", MERIT_NORMAL, countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory}
};
-CFactoryTemplate g_Templates[] =
-{
+CFactoryTemplate g_Templates[] = {
{sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CFLICSource>, NULL, &sudFilter[0]}
};
@@ -50,23 +46,23 @@ 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"));
+ _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("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("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("Media Type\\Extensions"), _T(".fli"),
_T("Source Filter"), _T("{17DB5CF6-39BB-4d5b-B0AA-BEBA44673AD4}"));
SetRegKeyValue(
- _T("Media Type\\Extensions"), _T(".flc"),
+ _T("Media Type\\Extensions"), _T(".flc"),
_T("Source Filter"), _T("{17DB5CF6-39BB-4d5b-B0AA-BEBA44673AD4}"));
return AMovieDllRegisterServer2(TRUE);
@@ -102,9 +98,9 @@ CFLICSource::~CFLICSource()
STDMETHODIMP CFLICSource::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- return
+ return
QI(IFileSourceFilter)
QI(IAMFilterMiscFlags)
__super::NonDelegatingQueryInterface(riid, ppv);
@@ -112,17 +108,20 @@ STDMETHODIMP CFLICSource::NonDelegatingQueryInterface(REFIID riid, void** ppv)
// IFileSourceFilter
-STDMETHODIMP CFLICSource::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt)
+STDMETHODIMP CFLICSource::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt)
{
- if(GetPinCount() > 0)
+ if(GetPinCount() > 0) {
return VFW_E_ALREADY_CONNECTED;
+ }
HRESULT hr = S_OK;
- if(!(DNew CFLICStream(pszFileName, this, &hr)))
+ if(!(DNew CFLICStream(pszFileName, this, &hr))) {
return E_OUTOFMEMORY;
+ }
- if(FAILED(hr))
+ if(FAILED(hr)) {
return hr;
+ }
m_fn = pszFileName;
@@ -131,11 +130,14 @@ STDMETHODIMP CFLICSource::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt)
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))
+ if(!(*ppszFileName)) {
return E_OUTOFMEMORY;
+ }
wcscpy(*ppszFileName, m_fn);
@@ -151,7 +153,7 @@ ULONG CFLICSource::GetMiscFlags()
// CFLICStream
-CFLICStream::CFLICStream(const WCHAR* wfn, CFLICSource* pParent, HRESULT* phr)
+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)
@@ -160,98 +162,106 @@ CFLICStream::CFLICStream(const WCHAR* wfn, CFLICSource* pParent, HRESULT* phr)
CString fn(wfn);
- if(!m_flic.Open(fn, CFile::modeRead|CFile::shareDenyNone))
- {
- if(phr) *phr = E_FAIL;
+ 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.id != 0xaf11 && m_hdr.id != 0xaf12)
- || m_hdr.bpp != 8)
- {
- if(phr) *phr = E_FAIL;
+ || (m_hdr.id != 0xaf11 && m_hdr.id != 0xaf12)
+ || m_hdr.bpp != 8) {
+ if(phr) {
+ *phr = E_FAIL;
+ }
return;
}
m_AvgTimePerFrame = (m_hdr.id == 0xaf11)
- ? 10000000i64 * max(m_hdr.ticks, 1) / 70
- : 10000000i64 * max(m_hdr.ticks, 1) / 1000;
+ ? 10000000i64 * max(m_hdr.ticks, 1) / 70
+ : 10000000i64 * max(m_hdr.ticks, 1) / 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.id != 0xf100)
+ if(m_flic.Read(&fp, sizeof(fp)) != sizeof(fp) || fp.id != 0xf100) {
m_flic.Seek(pos, CFile::begin);
- else
+ } else {
m_flic.Seek(pos + fp.size, CFile::begin);
+ }
}
- do
- {
+ do {
FLIC_FRAME_ENTRY ffe;
- if(m_flic.Read(&ffe.hdr, sizeof(ffe.hdr)) != sizeof(ffe.hdr) || ffe.hdr.id != 0xf1fa)
+ if(m_flic.Read(&ffe.hdr, sizeof(ffe.hdr)) != sizeof(ffe.hdr) || ffe.hdr.id != 0xf1fa) {
break;
+ }
ffe.pos = m_flic.GetPosition();
ffe.fKeyframe = (m_frames.GetCount() == 0);
int chunk = 0;
- while(chunk < ffe.hdr.chunks)
- {
+ while(chunk < ffe.hdr.chunks) {
FLIC_CHUNK fc;
- if(m_flic.Read(&fc, sizeof(fc)) != sizeof(fc))
+ if(m_flic.Read(&fc, sizeof(fc)) != sizeof(fc)) {
break;
-/*
- switch(fc.type)
- {
- case FLIC_COLOR: _colorchunk(); break;
- case FLIC_256_COLOR: _color256chunk(); break;
- case FLIC_BRUN: _brunchunk(); break;
- case FLIC_LC: _lcchunk(); break;
- case FLIC_DELTA: _deltachunk(); break;
- case FLIC_BLACK: _blackchunk(); break;
- case FLIC_COPY: _copychunk(); break;
- case FLIC_MINI: break;
- default: break;
}
-*/
- ffe.fKeyframe =
+ /*
+ switch(fc.type)
+ {
+ case FLIC_COLOR: _colorchunk(); break;
+ case FLIC_256_COLOR: _color256chunk(); break;
+ case FLIC_BRUN: _brunchunk(); break;
+ case FLIC_LC: _lcchunk(); break;
+ case FLIC_DELTA: _deltachunk(); break;
+ case FLIC_BLACK: _blackchunk(); break;
+ case FLIC_COPY: _copychunk(); break;
+ case FLIC_MINI: break;
+ default: break;
+ }
+ */
+ ffe.fKeyframe =
(/*fc.type == FLIC_256_COLOR
|| fc.type == FLIC_64_COLOR
- ||*/ fc.type == FLIC_BRUN
- || fc.type == FLIC_BLACK
- || fc.type == FLIC_COPY);
+ ||*/ fc.type == FLIC_BRUN
+ || fc.type == FLIC_BLACK
+ || fc.type == FLIC_COPY);
ULONGLONG pos = m_flic.GetPosition() + fc.size - sizeof(fc);
- if(m_flic.Seek(pos, CFile::begin) != pos)
+ if(m_flic.Seek(pos, CFile::begin) != pos) {
break;
+ }
chunk++;
}
- if(chunk < ffe.hdr.chunks)
+ if(chunk < ffe.hdr.chunks) {
break;
+ }
ULONGLONG pos = ffe.pos + ffe.hdr.size - sizeof(ffe.hdr);
- if(m_flic.Seek(pos, CFile::begin) != pos)
+ if(m_flic.Seek(pos, CFile::begin) != pos) {
break;
+ }
m_frames.Add(ffe);
- }
- while(1);
+ } while(1);
m_nLastFrameNum = -1;
memset(m_pPalette, 0, sizeof(m_pPalette));
m_nBufferSize = m_hdr.x*m_hdr.y*32>>3;
- if(!m_pFrameBuffer.Allocate(m_nBufferSize))
- {
- if(phr) *phr = E_OUTOFMEMORY;
+ if(!m_pFrameBuffer.Allocate(m_nBufferSize)) {
+ if(phr) {
+ *phr = E_OUTOFMEMORY;
+ }
return;
}
m_rtDuration = m_rtStop = m_AvgTimePerFrame*m_frames.GetCount();
- if(phr) *phr = m_rtDuration > 0 ? S_OK : E_FAIL;
+ if(phr) {
+ *phr = m_rtDuration > 0 ? S_OK : E_FAIL;
+ }
}
CFLICStream::~CFLICStream()
@@ -261,21 +271,20 @@ CFLICStream::~CFLICStream()
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);
+ : CSourceStream::NonDelegatingQueryInterface(riid, ppv);
}
void CFLICStream::UpdateFromSeek()
{
- if(ThreadExists())
- {
+ 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;
DeliverBeginFlush();
@@ -284,7 +293,7 @@ void CFLICStream::UpdateFromSeek()
// complete the flush
DeliverEndFlush();
- m_bFlushing = FALSE;
+ m_bFlushing = FALSE;
// restart
Run();
@@ -293,8 +302,9 @@ void CFLICStream::UpdateFromSeek()
HRESULT CFLICStream::SetRate(double dRate)
{
- if(dRate <= 0)
+ if(dRate <= 0) {
return E_INVALIDARG;
+ }
{
CAutoLock lock(CSourceSeeking::m_pLock);
@@ -308,65 +318,70 @@ HRESULT CFLICStream::SetRate(double dRate)
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);
+ {
+ 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)
+ {
+ 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;
- 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)
@@ -376,17 +391,18 @@ HRESULT CFLICStream::FillBuffer(IMediaSample* pSample)
{
CAutoLock cAutoLockShared(&m_cSharedState);
- if(m_rtPosition >= m_rtStop)
+ if(m_rtPosition >= m_rtStop) {
return S_FALSE;
+ }
BYTE* pDataIn = m_pFrameBuffer;
BYTE* pDataOut = NULL;
- if(!pDataIn || FAILED(hr = pSample->GetPointer(&pDataOut)) || !pDataOut)
+ if(!pDataIn || FAILED(hr = pSample->GetPointer(&pDataOut)) || !pDataOut) {
return S_FALSE;
+ }
AM_MEDIA_TYPE* pmt;
- if(SUCCEEDED(pSample->GetMediaType(&pmt)) && pmt)
- {
+ if(SUCCEEDED(pSample->GetMediaType(&pmt)) && pmt) {
CMediaType mt(*pmt);
SetMediaType(&mt);
@@ -394,20 +410,15 @@ HRESULT CFLICStream::FillBuffer(IMediaSample* pSample)
}
int w, h, bpp;
- if(m_mt.formattype == FORMAT_VideoInfo)
- {
+ 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)
- {
+ } 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
- {
+ } else {
return S_FALSE;
}
@@ -419,36 +430,37 @@ HRESULT CFLICStream::FillBuffer(IMediaSample* pSample)
{
SeekToNearestKeyFrame(nFrame);
- while(m_nLastFrameNum < nFrame && !m_bFlushing)
+ while(m_nLastFrameNum < nFrame && !m_bFlushing) {
ExtractFrame(++m_nLastFrameNum);
+ }
- for(int y = 0, p = min(pitchIn, pitchOut);
- y < h;
- y++, pDataIn += pitchIn, pDataOut += pitchOut)
- {
+ 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++];
+ while(src < end) {
+ *dst++ = m_pPalette[*src++];
+ }
}
}
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);
+ // 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);
- if(m_bDiscontinuity)
- {
+ if(m_bDiscontinuity) {
pSample->SetDiscontinuity(TRUE);
m_bDiscontinuity = FALSE;
}
@@ -458,15 +470,19 @@ HRESULT CFLICStream::FillBuffer(IMediaSample* pSample)
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));
@@ -481,7 +497,7 @@ HRESULT CFLICStream::GetMediaType(int iPosition, CMediaType* pmt)
pmt->SetSampleSize(vih->bmiHeader.biSizeImage);
- return NOERROR;
+ return NOERROR;
}
HRESULT CFLICStream::CheckConnect(IPin* pPin)
@@ -492,8 +508,10 @@ HRESULT CFLICStream::CheckConnect(IPin* pPin)
HRESULT CFLICStream::CheckMediaType(const CMediaType* pmt)
{
if(pmt->majortype == MEDIATYPE_Video
- && pmt->subtype == MEDIASUBTYPE_RGB32
- && pmt->formattype == FORMAT_VideoInfo) return S_OK;
+ && pmt->subtype == MEDIASUBTYPE_RGB32
+ && pmt->formattype == FORMAT_VideoInfo) {
+ return S_OK;
+ }
return E_INVALIDARG;
}
@@ -507,17 +525,19 @@ STDMETHODIMP CFLICStream::Notify(IBaseFilter* pSender, Quality q)
void CFLICStream::SeekToNearestKeyFrame(int nFrame)
{
- if(m_nLastFrameNum == nFrame)
+ if(m_nLastFrameNum == nFrame) {
return;
+ }
- if(m_nLastFrameNum > nFrame)
+ if(m_nLastFrameNum > nFrame) {
m_nLastFrameNum = -1;
+ }
- for(int i = m_nLastFrameNum+1, j = min(m_frames.GetCount(), nFrame); i < j; i++)
- {
+ for(int i = m_nLastFrameNum+1, j = min(m_frames.GetCount(), nFrame); i < j; i++) {
FLIC_FRAME_ENTRY& ffe = m_frames[i];
- if(ffe.fKeyframe)
+ if(ffe.fKeyframe) {
m_nLastFrameNum = i-1;
+ }
}
}
@@ -531,35 +551,55 @@ void CFLICStream::ExtractFrame(int nFrame)
m_flic.Seek(ffe.pos, CFile::begin);
int chunk = 0;
- while(chunk < ffe.hdr.chunks)
- {
+ while(chunk < ffe.hdr.chunks) {
FLIC_CHUNK fc;
- if(m_flic.Read(&fc, sizeof(fc)) != sizeof(fc))
+ if(m_flic.Read(&fc, sizeof(fc)) != sizeof(fc)) {
break;
+ }
ULONGLONG next = m_flic.GetPosition() + fc.size - sizeof(fc);
- 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;
+ 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;
}
- if(m_flic.Seek(next, CFile::begin) != next)
+ if(m_flic.Seek(next, CFile::begin) != next) {
break;
+ }
chunk++;
}
- if(chunk < ffe.hdr.chunks)
+ if(chunk < ffe.hdr.chunks) {
ASSERT(0);
+ }
ffe.fKeyframe = (fNewPalette && fNewFrame);
}
@@ -583,8 +623,7 @@ bool CFLICStream::_colorchunk(bool f64)
WORD packets;
m_flic.Read(&packets, sizeof(packets));
- while(packets--)
- {
+ while(packets--) {
BYTE skip2;
m_flic.Read(&skip2, sizeof(skip2));
skip += skip2;
@@ -593,15 +632,14 @@ bool CFLICStream::_colorchunk(bool f64)
m_flic.Read(&count, sizeof(count));
int len = (count == 0 ? (256-skip) : count);
- while(len-- > 0)
- {
+ 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);
+ m_pPalette[skip++] = f64
+ ? ((r << 18)&0xff0000) | ((g << 10)&0xff00) | ((b << 2)&0xff)
+ : ((r << 16)&0xff0000) | ((g << 8)&0xff00) | ((b << 0)&0xff);
nColorsUpdated++;
}
}
@@ -614,27 +652,22 @@ void CFLICStream::_brunchunk()
BYTE* tmp = m_pFrameBuffer;
int lines = m_hdr.y;
- while(lines--)
- {
+ while(lines--) {
BYTE packets;
m_flic.Read(&packets, sizeof(packets));
-
+
BYTE* ptr = tmp;
- while(ptr < tmp + m_hdr.x)
- {
+ while(ptr < tmp + m_hdr.x) {
signed char count;
m_flic.Read(&count, sizeof(count));
- if(count >= 0)
- {
+ if(count >= 0) {
BYTE c;
m_flic.Read(&c, sizeof(c));
memset(ptr, c, count);
ptr += count;
- }
- else
- {
+ } else {
m_flic.Read(ptr, -count);
ptr += -count;
}
@@ -654,15 +687,13 @@ void CFLICStream::_lcchunk()
WORD lines;
m_flic.Read(&lines, sizeof(lines));
- while(lines--)
- {
+ while(lines--) {
BYTE* ptr = tmp;
BYTE packets;
m_flic.Read(&packets, sizeof(packets));
- while(packets--)
- {
+ while(packets--) {
BYTE skip;
m_flic.Read(&skip, sizeof(skip));
@@ -671,13 +702,10 @@ void CFLICStream::_lcchunk()
signed char count;
m_flic.Read(&count, sizeof(count));
- if(count >= 0)
- {
+ if(count >= 0) {
m_flic.Read(ptr, count);
ptr += count;
- }
- else
- {
+ } else {
BYTE c;
m_flic.Read(&c, sizeof(c));
memset(ptr, c, -count);
@@ -696,31 +724,23 @@ void CFLICStream::_deltachunk()
WORD lines;
m_flic.Read(&lines, sizeof(lines));
- while(lines--)
- {
+ while(lines--) {
signed short packets;
m_flic.Read(&packets, sizeof(packets));
- if(packets < 0)
- {
- if(packets&0x4000)
- {
+ if(packets < 0) {
+ if(packets&0x4000) {
tmp += -packets * m_hdr.x;
lines++;
- }
- else
- {
+ } else {
signed char count;
m_flic.Read(&count, sizeof(count));
tmp[m_hdr.x-1] = (BYTE)packets;
}
- }
- else
- {
+ } else {
BYTE* ptr = tmp;
- while(packets--)
- {
+ while(packets--) {
BYTE skip;
m_flic.Read(&skip, sizeof(skip));
@@ -729,22 +749,19 @@ void CFLICStream::_deltachunk()
signed char count;
m_flic.Read(&count, sizeof(count));
- if(count >= 0)
- {
+ 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)
+ if ((count << 1) + (long)(ptr - m_pFrameBuffer) < m_nBufferSize) {
m_flic.Read(ptr, count << 1);
- else
+ } else {
ASSERT(FALSE);
+ }
ptr += count << 1;
- }
- else
- {
+ } else {
WORD c;
m_flic.Read(&c, sizeof(c));
count = -count;
- while(count-- > 0)
- {
+ while(count-- > 0) {
*ptr++ = c>>8;
*ptr++ = c&0xff;
}
diff --git a/src/filters/source/FLICSource/FLICSource.h b/src/filters/source/FLICSource/FLICSource.h
index 5038fb0a6..6df23ec7e 100644
--- a/src/filters/source/FLICSource/FLICSource.h
+++ b/src/filters/source/FLICSource/FLICSource.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -24,8 +24,7 @@
#include <atlcoll.h>
#pragma pack(push, 1)
-enum
-{
+enum {
FLIC_256_COLOR = 4,
FLIC_DELTA = 7,
FLIC_64_COLOR = 11,
@@ -35,9 +34,8 @@ enum
FLIC_COPY = 16,
FLIC_MINI = 18
};
-
-struct FLIC
-{
+
+struct FLIC {
DWORD size;
WORD id; // 0xaf11 or 0xaf12
WORD frames, x, y, bpp;
@@ -46,38 +44,34 @@ struct FLIC
BYTE reserved[102];
};
-struct FLIC_PREFIX
-{
+struct FLIC_PREFIX {
DWORD size;
WORD id; // 0xf100
WORD chunks;
BYTE reserved[8];
};
-struct FLIC_FRAME
-{
+struct FLIC_FRAME {
DWORD size;
WORD id; // 0xf1fa
WORD chunks;
BYTE reserved[8];
};
-struct FLIC_CHUNK
-{
+struct FLIC_CHUNK {
DWORD size;
WORD type;
};
#pragma pack(pop)
-struct FLIC_FRAME_ENTRY
-{
+struct FLIC_FRAME_ENTRY {
__int64 pos;
bool fKeyframe;
FLIC_FRAME hdr;
};
class __declspec(uuid("17DB5CF6-39BB-4d5b-B0AA-BEBA44673AD4"))
-CFLICSource
+ CFLICSource
: public CSource
, public IFileSourceFilter
, public IAMFilterMiscFlags
@@ -89,7 +83,7 @@ public:
virtual ~CFLICSource();
DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
// IFileSourceFilter
STDMETHODIMP Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt);
@@ -99,7 +93,7 @@ public:
STDMETHODIMP_(ULONG) GetMiscFlags();
};
-class CFLICStream
+class CFLICStream
: public CSourceStream
, public CSourceSeeking
{
@@ -121,8 +115,10 @@ class CFLICStream
STDMETHODIMP SetRate(double dRate);
HRESULT ChangeStart();
- HRESULT ChangeStop();
- HRESULT ChangeRate() {return S_OK;}
+ HRESULT ChangeStop();
+ HRESULT ChangeRate() {
+ return S_OK;
+ }
private:
int m_nLastFrameNum;
@@ -140,17 +136,17 @@ private:
void _deltachunk();
public:
- CFLICStream(const WCHAR* wfn, CFLICSource* pParent, HRESULT* phr);
+ 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 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 CheckMediaType(const CMediaType* pMediaType);
+ HRESULT GetMediaType(int iPosition, CMediaType* pmt);
+
STDMETHODIMP Notify(IBaseFilter* pSender, Quality q);
};
diff --git a/src/filters/source/FLICSource/stdafx.cpp b/src/filters/source/FLICSource/stdafx.cpp
index 13934d005..bea3f980a 100644
--- a/src/filters/source/FLICSource/stdafx.cpp
+++ b/src/filters/source/FLICSource/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/source/FLICSource/stdafx.h b/src/filters/source/FLICSource/stdafx.h
index 62d50a36b..d1c3768d8 100644
--- a/src/filters/source/FLICSource/stdafx.h
+++ b/src/filters/source/FLICSource/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/source/FlacSource/FlacSource.cpp b/src/filters/source/FlacSource/FlacSource.cpp
index ab887a244..ea18dabc2 100644
--- a/src/filters/source/FlacSource/FlacSource.cpp
+++ b/src/filters/source/FlacSource/FlacSource.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -33,23 +33,19 @@
#ifdef REGISTER_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
{&MEDIATYPE_Audio, &MEDIASUBTYPE_FLAC_FRAMED}
};
-const AMOVIESETUP_PIN sudOpPin[] =
-{
+const AMOVIESETUP_PIN sudOpPin[] = {
{L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesOut), sudPinTypesOut}
};
-const AMOVIESETUP_FILTER sudFilter[] =
-{
+const AMOVIESETUP_FILTER sudFilter[] = {
{&__uuidof(CFlacSource), L"MPC - Flac Source", MERIT_NORMAL, countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory}
};
-CFactoryTemplate g_Templates[] =
-{
+CFactoryTemplate g_Templates[] = {
{sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CFlacSource>, NULL, &sudFilter[0]}
};
@@ -58,15 +54,15 @@ int g_cTemplates = countof(g_Templates);
STDAPI DllRegisterServer()
{
SetRegKeyValue(
- _T("Media Type\\{e436eb83-524f-11ce-9f53-0020af0ba770}"), _T("{1930D8FF-4739-4e42-9199-3B2EDEAA3BF2}"),
+ _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("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("Media Type\\Extensions"), _T(".flac"),
_T("Source Filter"), _T("{1930D8FF-4739-4e42-9199-3B2EDEAA3BF2}"));
return AMovieDllRegisterServer2(TRUE);
@@ -113,7 +109,7 @@ CFlacSource::~CFlacSource()
// CFlacStream
-CFlacStream::CFlacStream(const WCHAR* wfn, CSource* pParent, HRESULT* phr)
+CFlacStream::CFlacStream(const WCHAR* wfn, CSource* pParent, HRESULT* phr)
: CBaseStream(NAME("CFlacStream"), pParent, phr)
, m_bIsEOF (false)
{
@@ -122,42 +118,44 @@ CFlacStream::CFlacStream(const WCHAR* wfn, CSource* pParent, HRESULT* phr)
CFileException ex;
HRESULT hr = E_FAIL;
- do
- {
- if(!m_file.Open(fn, CFile::modeRead|CFile::shareDenyNone, &ex))
- {
+ 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))
- {
+ 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))
+ !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;
+ if(phr) {
+ *phr = hr;
+ }
}
CFlacStream::~CFlacStream()
@@ -167,21 +165,25 @@ CFlacStream::~CFlacStream()
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;
- 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)
@@ -189,22 +191,24 @@ HRESULT CFlacStream::FillBuffer(IMediaSample* pSample, int nFrame, BYTE* pOut, l
FLAC__uint64 llCurPos;
FLAC__uint64 llNextPos;
- if (m_bDiscontinuity)
- {
+ 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_skip_single_frame (_DECODER_);
- if (m_bIsEOF)
+ if (m_bIsEOF) {
return S_FALSE;
+ }
FLAC__stream_decoder_get_decode_position(_DECODER_, &llNextPos);
FLAC__uint64 llCurFile = m_file.GetPosition();
len = llNextPos - llCurPos;
ASSERT (len > 0);
- if (len <= 0) return S_FALSE;
+ if (len <= 0) {
+ return S_FALSE;
+ }
m_file.Seek (llCurPos, CFile::begin);
m_file.Read (pOut, len);
@@ -219,10 +223,9 @@ HRESULT CFlacStream::FillBuffer(IMediaSample* pSample, int nFrame, BYTE* pOut, l
HRESULT CFlacStream::GetMediaType(int iPosition, CMediaType* pmt)
{
- CAutoLock cAutoLock(m_pFilter->pStateLock());
+ CAutoLock cAutoLock(m_pFilter->pStateLock());
- if(iPosition == 0)
- {
+ if(iPosition == 0) {
pmt->majortype = MEDIATYPE_Audio;
pmt->subtype = MEDIASUBTYPE_FLAC_FRAMED;
pmt->formattype = FORMAT_WaveFormatEx;
@@ -235,13 +238,11 @@ HRESULT CFlacStream::GetMediaType(int iPosition, CMediaType* pmt)
wfe->nChannels = m_nChannels;
wfe->nBlockAlign = 1;
wfe->wBitsPerSample = m_wBitsPerSample;
- }
- else
- {
+ } else {
return VFW_S_NO_MORE_ITEMS;
}
- pmt->SetTemporalCompression(FALSE);
+ pmt->SetTemporalCompression(FALSE);
return S_OK;
}
@@ -249,12 +250,13 @@ HRESULT CFlacStream::GetMediaType(int iPosition, CMediaType* pmt)
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)
+ && pmt->subtype == MEDIASUBTYPE_FLAC_FRAMED
+ && pmt->formattype == FORMAT_WaveFormatEx
+ && ((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag == WAVE_FORMAT_FLAC) {
return S_OK;
- else
+ } else {
return E_INVALIDARG;
+ }
}
@@ -267,7 +269,7 @@ void CFlacStream::UpdateFromMetadata (void* pBuffer)
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;
+ m_nAvgBytesPerSec = (m_nChannels * (m_wBitsPerSample >> 3)) * m_nSamplesPerSec;
// === Init members from base classes
GetFileSizeEx (m_file.m_hFile, (LARGE_INTEGER*)&m_llFileSize);
@@ -282,9 +284,9 @@ FLAC__StreamDecoderReadStatus StreamDecoderRead(const FLAC__StreamDecoder *decod
CFlacStream* pThis = static_cast<CFlacStream*> (client_data);
UINT nRead;
- nRead = pThis->GetFile()->Read (buffer, *bytes);
- pThis->m_bIsEOF = (nRead != *bytes);
- *bytes = nRead;
+ nRead = pThis->GetFile()->Read (buffer, *bytes);
+ pThis->m_bIsEOF = (nRead != *bytes);
+ *bytes = nRead;
return (*bytes == 0) ? FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM : FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
}
@@ -292,7 +294,7 @@ FLAC__StreamDecoderReadStatus StreamDecoderRead(const FLAC__StreamDecoder *decod
FLAC__StreamDecoderSeekStatus StreamDecoderSeek(const FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *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;
@@ -310,10 +312,9 @@ FLAC__StreamDecoderLengthStatus StreamDecoderLength(const FLAC__StreamDecoder *d
CFlacStream* pThis = static_cast<CFlacStream*> (client_data);
CFile* pFile = pThis->GetFile();
- if (pFile == NULL)
+ if (pFile == NULL) {
return FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED;
- else
- {
+ } else {
*stream_length = pFile->GetLength();
return FLAC__STREAM_DECODER_LENGTH_STATUS_OK;
}
@@ -344,6 +345,7 @@ void StreamDecoderMetadata(const FLAC__StreamDecoder *decoder, const FLAC__Strea
{
CFlacStream* pThis = static_cast<CFlacStream*> (client_data);
- if (pThis)
+ if (pThis) {
pThis->UpdateFromMetadata ((void*)metadata);
+ }
}
diff --git a/src/filters/source/FlacSource/FlacSource.h b/src/filters/source/FlacSource/FlacSource.h
index 9b486bd77..06add98e1 100644
--- a/src/filters/source/FlacSource/FlacSource.h
+++ b/src/filters/source/FlacSource/FlacSource.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -27,7 +27,7 @@
class CFlacStream;
class __declspec(uuid("1930D8FF-4739-4e42-9199-3B2EDEAA3BF2"))
-CFlacSource : public CBaseSource<CFlacStream>
+ CFlacSource : public CBaseSource<CFlacStream>
{
public:
CFlacSource(LPUNKNOWN lpunk, HRESULT* phr);
@@ -50,20 +50,22 @@ class CFlacStream : public CBaseStream
int m_nAvgBytesPerSec;
ULONGLONG m_llOffset; // Position of first frame in file
- ULONGLONG m_llFileSize; // Size of the file
+ ULONGLONG m_llFileSize; // Size of the file
public:
- CFlacStream(const WCHAR* wfn, CSource* pParent, HRESULT* phr);
+ 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 CheckMediaType(const CMediaType* pMediaType);
+ HRESULT GetMediaType(int iPosition, CMediaType* pmt);
void UpdateFromMetadata (void* pBuffer);
- inline CFile* GetFile() { return &m_file; };
+ inline CFile* GetFile() {
+ return &m_file;
+ };
bool m_bIsEOF;
};
diff --git a/src/filters/source/FlacSource/stdafx.cpp b/src/filters/source/FlacSource/stdafx.cpp
index 13934d005..bea3f980a 100644
--- a/src/filters/source/FlacSource/stdafx.cpp
+++ b/src/filters/source/FlacSource/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/source/FlacSource/stdafx.h b/src/filters/source/FlacSource/stdafx.h
index 62d50a36b..d1c3768d8 100644
--- a/src/filters/source/FlacSource/stdafx.h
+++ b/src/filters/source/FlacSource/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/source/ShoutcastSource/ShoutcastSource.cpp b/src/filters/source/ShoutcastSource/ShoutcastSource.cpp
index 5e5654e66..13a9ca345 100644
--- a/src/filters/source/ShoutcastSource/ShoutcastSource.cpp
+++ b/src/filters/source/ShoutcastSource/ShoutcastSource.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -31,25 +31,21 @@
#define AVGBUFFERLENGTH 30000000i64
#define MAXBUFFERLENGTH 100000000i64
-static const DWORD s_bitrate[2][16] =
-{
+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}
};
-static const DWORD s_freq[4][4] =
-{
+static const DWORD s_freq[4][4] = {
{11025,12000,8000,0},
{0,0,0,0},
{22050,24000,16000,0},
{44100,48000,32000,0}
};
-static const BYTE s_channels[4] =
-{
+static const BYTE s_channels[4] = {
2,2,2,1 // stereo, joint stereo, dual, mono
};
-typedef struct
-{
+typedef struct {
WORD sync;
BYTE version;
BYTE layer;
@@ -58,11 +54,11 @@ typedef struct
BYTE channels;
DWORD framesize;
- bool ExtractHeader(CSocket& socket)
- {
+ bool ExtractHeader(CSocket& socket) {
BYTE buff[4];
- if(4 != socket.Receive(buff, 4, MSG_PEEK))
+ if(4 != socket.Receive(buff, 4, MSG_PEEK)) {
return(false);
+ }
sync = (buff[0]<<4)|(buff[1]>>4)|1;
version = (buff[1]>>3)&3;
@@ -79,23 +75,19 @@ typedef struct
#ifdef REGISTER_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
{&MEDIATYPE_Audio, &MEDIASUBTYPE_MP3},
};
-const AMOVIESETUP_PIN sudOpPin[] =
-{
+const AMOVIESETUP_PIN sudOpPin[] = {
{L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesOut), sudPinTypesOut}
};
-const AMOVIESETUP_FILTER sudFilter[] =
-{
+const AMOVIESETUP_FILTER sudFilter[] = {
{&__uuidof(CShoutcastSource), L"MPC - ShoutcastSource", MERIT_NORMAL, countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory}
};
-CFactoryTemplate g_Templates[] =
-{
+CFactoryTemplate g_Templates[] = {
{sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CShoutcastSource>, NULL, &sudFilter[0]}
};
@@ -116,18 +108,18 @@ 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!"));
+ BOOL InitInstance() {
+ if(!__super::InitInstance()) {
return FALSE;
}
-*/
- if(!AfxSocketInit(NULL))
- {
+ /*
+ if(!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
+ {
+ AfxMessageBox(_T("AfxWinInit failed!"));
+ return FALSE;
+ }
+ */
+ if(!AfxSocketInit(NULL)) {
AfxMessageBox(_T("AfxSocketInit failed!"));
return FALSE;
}
@@ -158,9 +150,9 @@ CShoutcastSource::~CShoutcastSource()
STDMETHODIMP CShoutcastSource::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- return
+ return
QI(IFileSourceFilter)
QI(IAMFilterMiscFlags)
QI(IAMOpenProgress)
@@ -170,15 +162,17 @@ STDMETHODIMP CShoutcastSource::NonDelegatingQueryInterface(REFIID riid, void** p
// IFileSourceFilter
-STDMETHODIMP CShoutcastSource::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt)
+STDMETHODIMP CShoutcastSource::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt)
{
- if(GetPinCount() > 0)
+ if(GetPinCount() > 0) {
return VFW_E_ALREADY_CONNECTED;
+ }
HRESULT hr = E_OUTOFMEMORY;
- if(!(DNew CShoutcastStream(pszFileName, this, &hr)) || FAILED(hr))
+ if(!(DNew CShoutcastStream(pszFileName, this, &hr)) || FAILED(hr)) {
return hr;
+ }
m_fn = pszFileName;
@@ -187,11 +181,14 @@ STDMETHODIMP CShoutcastSource::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE*
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))
+ if(!(*ppszFileName)) {
return E_OUTOFMEMORY;
+ }
wcscpy(*ppszFileName, m_fn);
@@ -209,10 +206,13 @@ ULONG CShoutcastSource::GetMiscFlags()
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();
+ if(m_iPins == 1) {
+ if(pllTotal) {
+ *pllTotal = 100;
+ }
+ if(pllCurrent) {
+ *pllCurrent = (static_cast<CShoutcastStream*>(m_paStreams[0]))->GetBufferFullness();
+ }
return S_OK;
}
@@ -230,8 +230,7 @@ STDMETHODIMP CShoutcastSource::get_Title(BSTR* pbstrTitle)
{
CheckPointer(pbstrTitle, E_POINTER);
- if(m_iPins == 1)
- {
+ if(m_iPins == 1) {
*pbstrTitle = (static_cast<CShoutcastStream*>(m_paStreams[0]))->GetTitle().AllocSysString();
return S_OK;
}
@@ -250,40 +249,41 @@ CShoutcastStream::CShoutcastStream(const WCHAR* wfn, CShoutcastSource* pParent,
*phr = S_OK;
CString fn(wfn);
- if(fn.Find(_T("://")) < 0) fn = _T("http://") + fn;
+ if(fn.Find(_T("://")) < 0) {
+ fn = _T("http://") + fn;
+ }
#if defined(REGISTER_FILTER) && defined(DEBUG)
-//fn = _T("http://localhost:8000/");
-//fn = _T("http://64.236.34.141/stream/1005");
-//fn = _T("http://218.145.30.106:11000"); // 128kbps korean
-//fn = _T("http://65.206.46.110:8020"); // 96kbps
-//fn = _T("http://64.236.34.72:80/stream/1003");
-fn = _T("http://64.236.34.72:80/stream/1011");
-//fn = _T("http://218.145.30.106:11000");
-//fn = _T("http://radio.sluchaj.com:8000/radio.ogg"); // ogg
-// http://www.oddsock.org/icecast2yp/ // more ogg via icecast2
+ //fn = _T("http://localhost:8000/");
+ //fn = _T("http://64.236.34.141/stream/1005");
+ //fn = _T("http://218.145.30.106:11000"); // 128kbps korean
+ //fn = _T("http://65.206.46.110:8020"); // 96kbps
+ //fn = _T("http://64.236.34.72:80/stream/1003");
+ fn = _T("http://64.236.34.72:80/stream/1011");
+ //fn = _T("http://218.145.30.106:11000");
+ //fn = _T("http://radio.sluchaj.com:8000/radio.ogg"); // ogg
+ // http://www.oddsock.org/icecast2yp/ // more ogg via icecast2
#endif
- if(!m_url.CrackUrl(fn))
- {
+ if(!m_url.CrackUrl(fn)) {
*phr = E_FAIL;
return;
}
- if(m_url.GetUrlPathLength() == 0)
+ if(m_url.GetUrlPathLength() == 0) {
m_url.SetUrlPath(_T("/"));
+ }
- if(m_url.GetPortNumber() == ATL_URL_INVALID_PORT_NUMBER)
+ 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)
- {
+ if(m_url.GetScheme() != ATL_URL_SCHEME_HTTP) {
*phr = E_FAIL;
return;
}
- if(!m_socket.Create() || !m_socket.Connect(m_url))
- {
+ if(!m_socket.Create() || !m_socket.Connect(m_url)) {
*phr = E_FAIL;
return;
}
@@ -304,8 +304,12 @@ void CShoutcastStream::EmptyBuffer()
LONGLONG CShoutcastStream::GetBufferFullness()
{
CAutoLock cAutoLock(&m_queue);
- if(!m_fBuffering) return 100;
- if(m_queue.IsEmpty()) return 0;
+ 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));
}
@@ -318,21 +322,25 @@ CString CShoutcastStream::GetTitle()
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;
- 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)
@@ -340,31 +348,33 @@ HRESULT CShoutcastStream::FillBuffer(IMediaSample* pSample)
HRESULT hr;
BYTE* pData = NULL;
- if(FAILED(hr = pSample->GetPointer(&pData)) || !pData)
+ if(FAILED(hr = pSample->GetPointer(&pData)) || !pData) {
return S_FALSE;
+ }
- do
- {
+ 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
+ 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;
- while(1)
- {
- if(fExitThread) // playback stopped?
+ while(1) {
+ 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
+ if(!m_queue.IsEmpty() && m_queue.GetHead().rtStart < m_queue.GetTail().rtStart - AVGBUFFERLENGTH) {
+ break; // this is enough
+ }
}
pSample->SetDiscontinuity(TRUE);
@@ -376,14 +386,12 @@ HRESULT CShoutcastStream::FillBuffer(IMediaSample* pSample)
TRACE(_T("END BUFFERING\n"));
m_fBuffering = false;
- }
- while(false);
+ } while(false);
{
CAutoLock cAutoLock(&m_queue);
ASSERT(!m_queue.IsEmpty());
- if(!m_queue.IsEmpty())
- {
+ if(!m_queue.IsEmpty()) {
mp3frame f = m_queue.RemoveHead();
DWORD len = min(pSample->GetSize(), f.len);
memcpy(pData, f.pData, len);
@@ -400,14 +408,18 @@ HRESULT CShoutcastStream::FillBuffer(IMediaSample* pSample)
HRESULT CShoutcastStream::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_Audio);
- pmt->SetSubtype(&MEDIASUBTYPE_MP3);
- pmt->SetFormatType(&FORMAT_WaveFormatEx);
+ pmt->SetType(&MEDIATYPE_Audio);
+ pmt->SetSubtype(&MEDIASUBTYPE_MP3);
+ pmt->SetFormatType(&FORMAT_WaveFormatEx);
WAVEFORMATEX* wfe = (WAVEFORMATEX*)pmt->AllocFormatBuffer(sizeof(WAVEFORMATEX));
memset(wfe, 0, sizeof(WAVEFORMATEX));
@@ -418,14 +430,16 @@ HRESULT CShoutcastStream::GetMediaType(int iPosition, CMediaType* pmt)
wfe->nBlockAlign = 1;
wfe->wBitsPerSample = 0;
- return NOERROR;
+ return NOERROR;
}
HRESULT CShoutcastStream::CheckMediaType(const CMediaType* pmt)
{
if(pmt->majortype == MEDIATYPE_Audio
- && pmt->subtype == MEDIASUBTYPE_MP3
- && pmt->formattype == FORMAT_WaveFormatEx) return S_OK;
+ && pmt->subtype == MEDIASUBTYPE_MP3
+ && pmt->formattype == FORMAT_WaveFormatEx) {
+ return S_OK;
+ }
return E_INVALIDARG;
}
@@ -445,26 +459,28 @@ UINT CShoutcastStream::SocketThreadProc()
CAutoVectorPtr<BYTE> pData;
if(!m_socket.Create() || !m_socket.Connect(m_url)
- || !pData.Allocate(max(m_socket.m_metaint, MAXFRAMESIZE)))
- {
- m_socket.Close();
+ || !pData.Allocate(max(m_socket.m_metaint, MAXFRAMESIZE))) {
+ m_socket.Close();
return 1;
}
REFERENCE_TIME m_rtSampleTime = 0;
-
- while(!fExitThread)
- {
+
+ while(!fExitThread) {
int len = MAXFRAMESIZE;
len = m_socket.Receive(pData, len);
- if(len <= 0) break;
+ 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;
+ if(f.title.IsEmpty()) {
+ f.title = m_socket.m_url;
+ }
CAutoLock cAutoLock(&m_queue);
m_queue.AddTail(f);
@@ -481,7 +497,9 @@ HRESULT CShoutcastStream::OnThreadCreate()
fExitThread = true;
m_hSocketThread = AfxBeginThread(::SocketThreadProc, this)->m_hThread;
- while(fExitThread) Sleep(10);
+ while(fExitThread) {
+ Sleep(10);
+ }
return NOERROR;
}
@@ -489,7 +507,7 @@ HRESULT CShoutcastStream::OnThreadCreate()
HRESULT CShoutcastStream::OnThreadDestroy()
{
EmptyBuffer();
-
+
fExitThread = true;
m_socket.CancelBlockingCall();
WaitForSingleObject(m_hSocketThread, (DWORD)-1);
@@ -507,81 +525,84 @@ HRESULT CShoutcastStream::Inactive()
int CShoutcastStream::CShoutcastSocket::Receive(void* lpBuf, int nBufLen, int nFlags)
{
- if(nFlags&MSG_PEEK)
+ if(nFlags&MSG_PEEK) {
return __super::Receive(lpBuf, nBufLen, nFlags);
+ }
- if(m_metaint > 0 && m_nBytesRead + nBufLen > m_metaint)
+ 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(len <= 0) {
+ return len;
+ }
- if((m_nBytesRead += len) == m_metaint)
- {
+ 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))
- {
+ 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)
- {
+ if(i >= 0) {
i += title.GetLength();
int j = str.Find('\'', i);
- if(j > i) m_title = str.Mid(i, j - i);
- }
- else
- {
+ if(j > i) {
+ m_title = str.Mid(i, j - i);
+ }
+ } else {
TRACE(_T("!!!!!!!!!Missing StreamTitle!!!!!!!!!\n"));
}
i = str.Find(url);
- if(i >= 0)
- {
+ if(i >= 0) {
i += url.GetLength();
int j = str.Find('\'', i);
- if(j > i) m_url = str.Mid(i, j - i);
+ if(j > i) {
+ m_url = str.Mid(i, j - i);
+ }
}
}
- }
- else if(m_metaint > 0)
- {
+ } 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))
+ 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)
+ 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);
+ TRACE(_T("found possible length byte: %d, skipping %d bytes\n"), *p, 1 + *p*16);
p += 1 + *p*16;
len = (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);
+ 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;
+ if(len <= 0) {
+ return len;
+ }
}
-
- m_nBytesRead = len;
+
+ m_nBytesRead = len;
memcpy(lpBuf, p, len);
break;
@@ -596,8 +617,9 @@ TRACE(_T("nothing to return, reading a bit more in\n"));
bool CShoutcastStream::CShoutcastSocket::Connect(CUrl& url)
{
- if(!__super::Connect(url.GetHostName(), url.GetPortNumber()))
+ if(!__super::Connect(url.GetHostName(), url.GetPortNumber())) {
return(false);
+ }
CStringA str;
str.Format(
@@ -613,8 +635,7 @@ bool CShoutcastStream::CShoutcastSocket::Connect(CUrl& url)
bool fTryAgain = false;
int metaint = 0;
- do
- {
+ do {
int len = Send((BYTE*)(LPCSTR)str, str.GetLength());
UNUSED_ALWAYS(len);
@@ -624,21 +645,22 @@ bool CShoutcastStream::CShoutcastSocket::Connect(CUrl& url)
str.Empty();
BYTE cur = 0, prev = 0;
- while(Receive(&cur, 1) == 1 && cur && !(cur == '\n' && prev == '\n'))
- {
- if(cur == '\r')
+ while(Receive(&cur, 1) == 1 && cur && !(cur == '\n' && prev == '\n')) {
+ if(cur == '\r') {
continue;
+ }
- if(cur == '\n')
- {
+ if(cur == '\n') {
str.MakeLower();
- if(str.Find("icy 200 ok") >= 0) fOK = true;
- else if(1 == sscanf(str, "icy-br:%d", &m_bitrate)) m_bitrate *= 1000;
- else if(1 == sscanf(str, "icy-metaint:%d", &metaint)) metaint = metaint;
+ if(str.Find("icy 200 ok") >= 0) {
+ fOK = true;
+ } else if(1 == sscanf(str, "icy-br:%d", &m_bitrate)) {
+ m_bitrate *= 1000;
+ } else if(1 == sscanf(str, "icy-metaint:%d", &metaint)) {
+ metaint = metaint;
+ }
str.Empty();
- }
- else
- {
+ } else {
str += cur;
}
@@ -646,8 +668,7 @@ bool CShoutcastStream::CShoutcastSocket::Connect(CUrl& url)
cur = 0;
}
- if(!fOK && GetLastError() == WSAECONNRESET && !fTryAgain)
- {
+ if(!fOK && GetLastError() == WSAECONNRESET && !fTryAgain) {
str.Format(
"GET %s HTTP/1.0\r\n"
"Icy-MetaData:1\r\n"
@@ -657,15 +678,15 @@ bool CShoutcastStream::CShoutcastSocket::Connect(CUrl& url)
"\r\n", CStringA(url.GetUrlPath()), CStringA(url.GetHostName()));
fTryAgain = true;
- }
- else
- {
+ } else {
fTryAgain = false;
}
- }
- while(fTryAgain);
+ } while(fTryAgain);
- if(!fOK || m_bitrate == 0) {Close(); return(false);}
+ if(!fOK || m_bitrate == 0) {
+ Close();
+ return(false);
+ }
m_metaint = metaint;
m_nBytesRead = 0;
@@ -679,12 +700,12 @@ bool CShoutcastStream::CShoutcastSocket::FindSync()
m_channels = (DWORD)-1;
BYTE b;
- for(int i = MAXFRAMESIZE; i > 0; i--, Receive(&b, 1))
- {
+ 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;
+ 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);
diff --git a/src/filters/source/ShoutcastSource/ShoutcastSource.h b/src/filters/source/ShoutcastSource/ShoutcastSource.h
index 2c6a9e752..3e873955c 100644
--- a/src/filters/source/ShoutcastSource/ShoutcastSource.h
+++ b/src/filters/source/ShoutcastSource/ShoutcastSource.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -28,7 +28,7 @@
#include <qnetwork.h>
class __declspec(uuid("68F540E9-766F-44d2-AB07-E26CC6D27A79"))
-CShoutcastSource
+ CShoutcastSource
: public CSource
, public IFileSourceFilter
, public IAMFilterMiscFlags
@@ -42,7 +42,7 @@ public:
virtual ~CShoutcastSource();
DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
// IFileSourceFilter
STDMETHODIMP Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt);
@@ -52,27 +52,59 @@ public:
STDMETHODIMP_(ULONG) GetMiscFlags();
// IAMOpenProgress
- STDMETHODIMP QueryProgress(LONGLONG* pllTotal, LONGLONG* pllCurrent);
- STDMETHODIMP AbortOperation();
+ 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 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;}
+ 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;
+ }
};
class CShoutcastStream : public CSourceStream
@@ -84,13 +116,19 @@ class CShoutcastStream : public CSourceStream
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)
- {
+ 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;
@@ -109,7 +147,9 @@ class CShoutcastStream : public CSourceStream
DWORD m_nBytesRead;
public:
- CShoutcastSocket() {m_metaint = m_bitrate = m_freq = m_channels = 0;}
+ 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;
@@ -126,7 +166,7 @@ class CShoutcastStream : public CSourceStream
CString m_title;
public:
- CShoutcastStream(const WCHAR* wfn, CShoutcastSource* pParent, HRESULT* phr);
+ CShoutcastStream(const WCHAR* wfn, CShoutcastSource* pParent, HRESULT* phr);
virtual ~CShoutcastStream();
bool fExitThread;
@@ -136,15 +176,17 @@ public:
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 OnThreadCreate();
+ HRESULT OnThreadDestroy();
HRESULT Inactive();
- HRESULT Pause();
+ HRESULT Pause();
};
diff --git a/src/filters/source/ShoutcastSource/stdafx.cpp b/src/filters/source/ShoutcastSource/stdafx.cpp
index 13934d005..bea3f980a 100644
--- a/src/filters/source/ShoutcastSource/stdafx.cpp
+++ b/src/filters/source/ShoutcastSource/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/source/ShoutcastSource/stdafx.h b/src/filters/source/ShoutcastSource/stdafx.h
index 62d50a36b..d1c3768d8 100644
--- a/src/filters/source/ShoutcastSource/stdafx.h
+++ b/src/filters/source/ShoutcastSource/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/source/SubtitleSource/SubtitleSource.cpp b/src/filters/source/SubtitleSource/SubtitleSource.cpp
index b470268a9..8bd54eb70 100644
--- a/src/filters/source/SubtitleSource/SubtitleSource.cpp
+++ b/src/filters/source/SubtitleSource/SubtitleSource.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -32,20 +32,17 @@ static int _ATPF = 400000;
#ifdef REGISTER_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
{&MEDIATYPE_Subtitle, &MEDIASUBTYPE_NULL},
{&MEDIATYPE_Text, &MEDIASUBTYPE_NULL},
{&MEDIATYPE_Video, &MEDIASUBTYPE_RGB32},
};
-const AMOVIESETUP_PIN sudOpPin[] =
-{
+const AMOVIESETUP_PIN sudOpPin[] = {
{L"Output", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, NULL, countof(sudPinTypesOut), sudPinTypesOut},
};
-const AMOVIESETUP_FILTER sudFilter[] =
-{
+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},
@@ -55,13 +52,12 @@ const AMOVIESETUP_FILTER sudFilter[] =
{&__uuidof(CSubtitleSourceARGB), L"MPC - SubtitleSource (ARGB)", MERIT_NORMAL, countof(sudOpPin), sudOpPin, CLSID_LegacyAmFilterCategory},
};
-CFactoryTemplate g_Templates[] =
-{
+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[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]},
};
@@ -70,37 +66,37 @@ 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);
-*/
+ SetRegKeyValue(
+ _T("Media Type\\Extensions"), _T(".usf"),
+ _T("Source Filter"), clsid);
+ */
return AMovieDllRegisterServer2(TRUE);
}
@@ -113,7 +109,7 @@ STDAPI DllUnregisterServer()
DeleteRegKey(_T("Media Type\\Extensions"), _T(".ass"));
DeleteRegKey(_T("Media Type\\Extensions"), _T(".xss"));
DeleteRegKey(_T("Media Type\\Extensions"), _T(".usf"));
-/**/
+ /**/
return AMovieDllRegisterServer2(FALSE);
}
@@ -122,14 +118,17 @@ STDAPI DllUnregisterServer()
class CSubtitleSourceApp : public CFilterApp
{
public:
- BOOL InitInstance()
- {
- if(!__super::InitInstance()) return FALSE;
+ 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;
+ if(_ATPF <= 0) {
+ _ATPF = 400000;
+ }
WriteProfileInt(_T("SubtitleSource"), _T("w"), _WIDTH);
WriteProfileInt(_T("SubtitleSource"), _T("h"), _HEIGHT);
WriteProfileInt(_T("SubtitleSource"), _T("atpf"), _ATPF);
@@ -157,9 +156,9 @@ CSubtitleSource::~CSubtitleSource()
STDMETHODIMP CSubtitleSource::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
+ CheckPointer(ppv, E_POINTER);
- return
+ return
QI(IFileSourceFilter)
QI(IAMFilterMiscFlags)
__super::NonDelegatingQueryInterface(riid, ppv);
@@ -167,17 +166,20 @@ STDMETHODIMP CSubtitleSource::NonDelegatingQueryInterface(REFIID riid, void** pp
// IFileSourceFilter
-STDMETHODIMP CSubtitleSource::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt)
+STDMETHODIMP CSubtitleSource::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt)
{
- if(GetPinCount() > 0)
+ if(GetPinCount() > 0) {
return VFW_E_ALREADY_CONNECTED;
+ }
HRESULT hr = S_OK;
- if(!(DNew CSubtitleStream(pszFileName, this, &hr)))
+ if(!(DNew CSubtitleStream(pszFileName, this, &hr))) {
return E_OUTOFMEMORY;
+ }
- if(FAILED(hr))
+ if(FAILED(hr)) {
return hr;
+ }
m_fn = pszFileName;
@@ -186,10 +188,13 @@ STDMETHODIMP CSubtitleSource::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* p
STDMETHODIMP CSubtitleSource::GetCurFile(LPOLESTR* ppszFileName, AM_MEDIA_TYPE* pmt)
{
- if(!ppszFileName) return E_POINTER;
-
- if(!(*ppszFileName = (LPOLESTR)CoTaskMemAlloc((m_fn.GetLength()+1)*sizeof(WCHAR))))
+ if(!ppszFileName) {
+ return E_POINTER;
+ }
+
+ if(!(*ppszFileName = (LPOLESTR)CoTaskMemAlloc((m_fn.GetLength()+1)*sizeof(WCHAR)))) {
return E_OUTOFMEMORY;
+ }
wcscpy(*ppszFileName, m_fn);
@@ -207,7 +212,7 @@ ULONG CSubtitleSource::GetMiscFlags()
// CSubtitleStream
//
-CSubtitleStream::CSubtitleStream(const WCHAR* wfn, CSubtitleSource* pParent, HRESULT* phr)
+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)
@@ -218,9 +223,10 @@ CSubtitleStream::CSubtitleStream(const WCHAR* wfn, CSubtitleSource* pParent, HRE
CString fn(wfn);
- if(!m_rts.Open(fn, DEFAULT_CHARSET))
- {
- if(phr) *phr = E_FAIL;
+ if(!m_rts.Open(fn, DEFAULT_CHARSET)) {
+ if(phr) {
+ *phr = E_FAIL;
+ }
return;
}
@@ -229,12 +235,15 @@ CSubtitleStream::CSubtitleStream(const WCHAR* wfn, CSubtitleSource* pParent, HRE
m_rts.Sort();
m_rtDuration = 0;
- for(int i = 0, cnt = m_rts.GetCount(); i < cnt; i++)
+ for(int i = 0, cnt = m_rts.GetCount(); i < cnt; i++) {
m_rtDuration = max(m_rtDuration, 10000i64*m_rts[i].end);
+ }
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()
@@ -244,21 +253,20 @@ CSubtitleStream::~CSubtitleStream()
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);
+ : CSourceStream::NonDelegatingQueryInterface(riid, ppv);
}
void CSubtitleStream::UpdateFromSeek()
{
- if(ThreadExists())
- {
+ 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;
DeliverBeginFlush();
@@ -267,7 +275,7 @@ void CSubtitleStream::UpdateFromSeek()
// complete the flush
DeliverEndFlush();
- m_bFlushing = FALSE;
+ m_bFlushing = FALSE;
// restart
Run();
@@ -276,8 +284,9 @@ void CSubtitleStream::UpdateFromSeek()
HRESULT CSubtitleStream::SetRate(double dRate)
{
- if(dRate <= 0)
+ if(dRate <= 0) {
return E_INVALIDARG;
+ }
{
CAutoLock lock(CSourceSeeking::m_pLock);
@@ -291,106 +300,107 @@ HRESULT CSubtitleStream::SetRate(double dRate)
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);
+ {
+ 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++;
- }
-*/ }
+ /*
+ 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();
+ UpdateFromSeek();
- return S_OK;
+ 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)
- {
+ if(m_mt.majortype == MEDIATYPE_Video && m_mt.subtype == MEDIASUBTYPE_ARGB32) {
m_nPosition = m_rtStart/_ATPF;
- }
- else if(m_mt.majortype == MEDIATYPE_Video && m_mt.subtype == MEDIASUBTYPE_RGB32)
- {
+ } 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/_ATPF, &m_nPosition, &m_nSegments))
+ if(!m_rts.SearchSubs((int)(m_rtStart/10000), 10000000/_ATPF, &m_nPosition, &m_nSegments)) {
m_nPosition = m_nSegments;
- }
- else
- {
+ }
+ } 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_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)
- {
+ if(m_mt.majortype == MEDIATYPE_Video) {
pProperties->cBuffers = 2;
pProperties->cbBuffer = ((VIDEOINFOHEADER*)m_mt.pbFormat)->bmiHeader.biSizeImage;
- }
- else
- {
+ } 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)
@@ -401,12 +411,12 @@ HRESULT CSubtitleStream::FillBuffer(IMediaSample* pSample)
CAutoLock cAutoLockShared(&m_cSharedState);
BYTE* pData = NULL;
- if(FAILED(hr = pSample->GetPointer(&pData)) || !pData)
+ if(FAILED(hr = pSample->GetPointer(&pData)) || !pData) {
return S_FALSE;
+ }
AM_MEDIA_TYPE* pmt;
- if(SUCCEEDED(pSample->GetMediaType(&pmt)) && pmt)
- {
+ if(SUCCEEDED(pSample->GetMediaType(&pmt)) && pmt) {
CMediaType mt(*pmt);
SetMediaType(&mt);
DeleteMediaType(pmt);
@@ -415,12 +425,12 @@ HRESULT CSubtitleStream::FillBuffer(IMediaSample* pSample)
int len = 0;
REFERENCE_TIME rtStart, rtStop;
- if(m_mt.majortype == MEDIATYPE_Video && m_mt.subtype == MEDIASUBTYPE_ARGB32)
- {
+ 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)
+ if(m_rtStart+rtStart >= m_rtDuration) {
return S_FALSE;
+ }
BITMAPINFOHEADER& bmi = ((VIDEOINFOHEADER*)m_mt.pbFormat)->bmiHeader;
@@ -433,23 +443,24 @@ HRESULT CSubtitleStream::FillBuffer(IMediaSample* pSample)
len = spd.h*spd.pitch;
- for(int y = 0; y < spd.h; y++)
+ 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++)
- {
+ for(int y = 0; y < spd.h; y++) {
DWORD* p = (DWORD*)(pData + spd.pitch*y);
- for(int x = 0; x < spd.w; x++, p++)
+ 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)
- {
+ } 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;
+ if(!stss) {
+ return S_FALSE;
+ }
BITMAPINFOHEADER& bmi = ((VIDEOINFOHEADER*)m_mt.pbFormat)->bmiHeader;
@@ -462,13 +473,15 @@ HRESULT CSubtitleStream::FillBuffer(IMediaSample* pSample)
len = spd.h*spd.pitch;
- for(int y = 0; y < spd.h; y++)
- {
+ for(int y = 0; y < spd.h; y++) {
DWORD c1 = 0xff606060, c2 = 0xffa0a0a0;
- if(y&32) c1 ^= c2, c2 ^= c1, c1 ^= c2;
+ 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)
+ 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;
@@ -476,40 +489,33 @@ HRESULT CSubtitleStream::FillBuffer(IMediaSample* pSample)
rtStart = (REFERENCE_TIME)((10000i64*stss->start - m_rtStart) / m_dRateSeeking);
rtStop = (REFERENCE_TIME)((10000i64*stss->end - m_rtStart) / m_dRateSeeking);
- }
- else
- {
- if(m_nPosition >= m_rts.GetCount())
+ } else {
+ if(m_nPosition >= m_rts.GetCount()) {
return S_FALSE;
+ }
STSEntry& stse = m_rts[m_nPosition];
- if(stse.start >= m_rtStop/10000)
+ if(stse.start >= m_rtStop/10000) {
return S_FALSE;
+ }
- if(m_mt.majortype == MEDIATYPE_Subtitle && m_mt.subtype == MEDIASUBTYPE_UTF8)
- {
+ 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))
- {
+ } 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));
+ 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)
- {
+ } 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
- {
+ } else {
return S_FALSE;
}
@@ -525,8 +531,7 @@ HRESULT CSubtitleStream::FillBuffer(IMediaSample* pSample)
pSample->SetSyncPoint(TRUE);
- if(m_bDiscontinuity)
- {
+ if(m_bDiscontinuity) {
pSample->SetDiscontinuity(TRUE);
m_bDiscontinuity = FALSE;
}
@@ -541,17 +546,16 @@ HRESULT CSubtitleStream::GetMediaType(CMediaType* 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)
@@ -570,7 +574,7 @@ CSubtitleSourceASCII::CSubtitleSourceASCII(LPUNKNOWN lpunk, HRESULT* phr)
HRESULT CSubtitleSourceASCII::GetMediaType(CMediaType* pmt)
{
- CAutoLock cAutoLock(pStateLock());
+ CAutoLock cAutoLock(pStateLock());
pmt->InitMediaType();
pmt->SetType(&MEDIATYPE_Text);
@@ -578,7 +582,7 @@ HRESULT CSubtitleSourceASCII::GetMediaType(CMediaType* pmt)
pmt->SetFormatType(&FORMAT_None);
pmt->ResetFormatBuffer();
- return NOERROR;
+ return NOERROR;
}
//
@@ -592,7 +596,7 @@ CSubtitleSourceUTF8::CSubtitleSourceUTF8(LPUNKNOWN lpunk, HRESULT* phr)
HRESULT CSubtitleSourceUTF8::GetMediaType(CMediaType* pmt)
{
- CAutoLock cAutoLock(pStateLock());
+ CAutoLock cAutoLock(pStateLock());
pmt->InitMediaType();
pmt->SetType(&MEDIATYPE_Subtitle);
@@ -602,7 +606,7 @@ HRESULT CSubtitleSourceUTF8::GetMediaType(CMediaType* pmt)
memset(psi, 0, pmt->FormatLength());
strcpy(psi->IsoLang, "eng");
- return NOERROR;
+ return NOERROR;
}
//
@@ -616,7 +620,7 @@ CSubtitleSourceSSA::CSubtitleSourceSSA(LPUNKNOWN lpunk, HRESULT* phr)
HRESULT CSubtitleSourceSSA::GetMediaType(CMediaType* pmt)
{
- CAutoLock cAutoLock(pStateLock());
+ CAutoLock cAutoLock(pStateLock());
pmt->InitMediaType();
pmt->SetType(&MEDIATYPE_Subtitle);
@@ -629,15 +633,17 @@ HRESULT CSubtitleSourceSSA::GetMediaType(CMediaType* pmt)
CFile f;
TCHAR path[_MAX_PATH], fn[_MAX_PATH];
- if(!GetTempPath(MAX_PATH, path) || !GetTempFileName(path, _T("mpc_sts"), 0, fn))
+ if(!GetTempPath(MAX_PATH, path) || !GetTempFileName(path, _T("mpc_sts"), 0, fn)) {
return E_FAIL;
+ }
_tremove(fn);
_tcscat(fn, _T(".ssa"));
- if(!sts.SaveAs(fn, EXTSSA, -1, CTextFile::UTF8) || !f.Open(fn, CFile::modeRead))
+ 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);
@@ -651,7 +657,7 @@ HRESULT CSubtitleSourceSSA::GetMediaType(CMediaType* pmt)
_tremove(fn);
- return NOERROR;
+ return NOERROR;
}
//
@@ -665,7 +671,7 @@ CSubtitleSourceASS::CSubtitleSourceASS(LPUNKNOWN lpunk, HRESULT* phr)
HRESULT CSubtitleSourceASS::GetMediaType(CMediaType* pmt)
{
- CAutoLock cAutoLock(pStateLock());
+ CAutoLock cAutoLock(pStateLock());
pmt->InitMediaType();
pmt->SetType(&MEDIATYPE_Subtitle);
@@ -678,15 +684,17 @@ HRESULT CSubtitleSourceASS::GetMediaType(CMediaType* pmt)
CFile f;
TCHAR path[_MAX_PATH], fn[_MAX_PATH];
- if(!GetTempPath(MAX_PATH, path) || !GetTempFileName(path, _T("mpc_sts"), 0, fn))
+ if(!GetTempPath(MAX_PATH, path) || !GetTempFileName(path, _T("mpc_sts"), 0, fn)) {
return E_FAIL;
+ }
_tremove(fn);
_tcscat(fn, _T(".ass"));
- if(!sts.SaveAs(fn, EXTASS, -1, CTextFile::UTF8) || !f.Open(fn, CFile::modeRead))
+ if(!sts.SaveAs(fn, EXTASS, -1, CTextFile::UTF8) || !f.Open(fn, CFile::modeRead)) {
return E_FAIL;
+ }
int len = (int)f.GetLength();
@@ -699,7 +707,7 @@ HRESULT CSubtitleSourceASS::GetMediaType(CMediaType* pmt)
_tremove(fn);
- return NOERROR;
+ return NOERROR;
}
//
@@ -713,7 +721,7 @@ CSubtitleSourceUSF::CSubtitleSourceUSF(LPUNKNOWN lpunk, HRESULT* phr)
HRESULT CSubtitleSourceUSF::GetMediaType(CMediaType* pmt)
{
- CAutoLock cAutoLock(pStateLock());
+ CAutoLock cAutoLock(pStateLock());
pmt->InitMediaType();
pmt->SetType(&MEDIATYPE_Subtitle);
@@ -724,7 +732,7 @@ HRESULT CSubtitleSourceUSF::GetMediaType(CMediaType* pmt)
strcpy(psi->IsoLang, "eng");
// TODO: ...
- return NOERROR;
+ return NOERROR;
}
//
@@ -738,7 +746,7 @@ CSubtitleSourcePreview::CSubtitleSourcePreview(LPUNKNOWN lpunk, HRESULT* phr)
HRESULT CSubtitleSourcePreview::GetMediaType(CMediaType* pmt)
{
- CAutoLock cAutoLock(pStateLock());
+ CAutoLock cAutoLock(pStateLock());
pmt->InitMediaType();
pmt->SetType(&MEDIATYPE_Video);
@@ -754,7 +762,7 @@ HRESULT CSubtitleSourcePreview::GetMediaType(CMediaType* pmt)
pvih->bmiHeader.biPlanes = 1;
pvih->bmiHeader.biSizeImage = pvih->bmiHeader.biWidth*abs(pvih->bmiHeader.biHeight)*pvih->bmiHeader.biBitCount>>3;
- return NOERROR;
+ return NOERROR;
}
//
@@ -768,7 +776,7 @@ CSubtitleSourceARGB::CSubtitleSourceARGB(LPUNKNOWN lpunk, HRESULT* phr)
HRESULT CSubtitleSourceARGB::GetMediaType(CMediaType* pmt)
{
- CAutoLock cAutoLock(pStateLock());
+ CAutoLock cAutoLock(pStateLock());
pmt->InitMediaType();
pmt->SetType(&MEDIATYPE_Video);
@@ -785,5 +793,5 @@ HRESULT CSubtitleSourceARGB::GetMediaType(CMediaType* pmt)
pvih->bmiHeader.biPlanes = 1;
pvih->bmiHeader.biSizeImage = pvih->bmiHeader.biWidth*abs(pvih->bmiHeader.biHeight)*pvih->bmiHeader.biBitCount>>3;
- return NOERROR;
+ return NOERROR;
}
diff --git a/src/filters/source/SubtitleSource/SubtitleSource.h b/src/filters/source/SubtitleSource/SubtitleSource.h
index 459db7b6a..071a13e4a 100644
--- a/src/filters/source/SubtitleSource/SubtitleSource.h
+++ b/src/filters/source/SubtitleSource/SubtitleSource.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -37,7 +37,7 @@ public:
virtual ~CSubtitleSource();
DECLARE_IUNKNOWN;
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
// IFileSourceFilter
STDMETHODIMP Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE* pmt);
@@ -46,10 +46,10 @@ public:
// IAMFilterMiscFlags
STDMETHODIMP_(ULONG) GetMiscFlags();
- virtual HRESULT GetMediaType(CMediaType* pmt) = 0;
+ virtual HRESULT GetMediaType(CMediaType* pmt) = 0;
};
-class CSubtitleStream
+class CSubtitleStream
: public CSourceStream
, public CSourceSeeking
{
@@ -66,28 +66,30 @@ class CSubtitleStream
STDMETHODIMP SetRate(double dRate);
HRESULT ChangeStart();
- HRESULT ChangeStop();
- HRESULT ChangeRate() {return S_OK;}
+ HRESULT ChangeStop();
+ HRESULT ChangeRate() {
+ return S_OK;
+ }
protected:
CRenderedTextSubtitle m_rts;
public:
- CSubtitleStream(const WCHAR* wfn, CSubtitleSource* pParent, HRESULT* phr);
+ 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 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);
};
class __declspec(uuid("E44CA3B5-A0FF-41A0-AF16-42429B1095EA"))
-CSubtitleSourceASCII : public CSubtitleSource
+ CSubtitleSourceASCII : public CSubtitleSource
{
public:
CSubtitleSourceASCII(LPUNKNOWN lpunk, HRESULT* phr);
@@ -96,7 +98,7 @@ public:
};
class __declspec(uuid("87864E0F-7073-4E39-B802-143DE0ED4964"))
-CSubtitleSourceUTF8 : public CSubtitleSource
+ CSubtitleSourceUTF8 : public CSubtitleSource
{
public:
CSubtitleSourceUTF8(LPUNKNOWN lpunk, HRESULT* phr);
@@ -105,7 +107,7 @@ public:
};
class __declspec(uuid("18316B1A-5877-4CC4-85FD-EDE65CD489EC"))
-CSubtitleSourceSSA : public CSubtitleSource
+ CSubtitleSourceSSA : public CSubtitleSource
{
public:
CSubtitleSourceSSA(LPUNKNOWN lpunk, HRESULT* phr);
@@ -114,7 +116,7 @@ public:
};
class __declspec(uuid("416782BC-1D87-48C0-8F65-F113A5CB8E15"))
-CSubtitleSourceASS : public CSubtitleSource
+ CSubtitleSourceASS : public CSubtitleSource
{
public:
CSubtitleSourceASS(LPUNKNOWN lpunk, HRESULT* phr);
@@ -123,7 +125,7 @@ public:
};
class __declspec(uuid("D7215AFC-DFE6-483B-9AF3-6BBECFF14CF4"))
-CSubtitleSourceUSF : public CSubtitleSource
+ CSubtitleSourceUSF : public CSubtitleSource
{
public:
CSubtitleSourceUSF(LPUNKNOWN lpunk, HRESULT* phr);
@@ -132,7 +134,7 @@ public:
};
class __declspec(uuid("932E75D4-BBD4-4A0F-9071-6728FBDC4C98"))
-CSubtitleSourcePreview : public CSubtitleSource
+ CSubtitleSourcePreview : public CSubtitleSource
{
public:
CSubtitleSourcePreview(LPUNKNOWN lpunk, HRESULT* phr);
@@ -141,7 +143,7 @@ public:
};
class __declspec(uuid("CF0D7280-527D-415E-BA02-56017484D73E"))
-CSubtitleSourceARGB : public CSubtitleSource
+ CSubtitleSourceARGB : public CSubtitleSource
{
public:
CSubtitleSourceARGB(LPUNKNOWN lpunk, HRESULT* phr);
diff --git a/src/filters/source/SubtitleSource/stdafx.cpp b/src/filters/source/SubtitleSource/stdafx.cpp
index 13934d005..bea3f980a 100644
--- a/src/filters/source/SubtitleSource/stdafx.cpp
+++ b/src/filters/source/SubtitleSource/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/source/SubtitleSource/stdafx.h b/src/filters/source/SubtitleSource/stdafx.h
index 62d50a36b..d1c3768d8 100644
--- a/src/filters/source/SubtitleSource/stdafx.h
+++ b/src/filters/source/SubtitleSource/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/switcher/AudioSwitcher/Audio.cpp b/src/filters/switcher/AudioSwitcher/Audio.cpp
index 055c01668..a163816c1 100644
--- a/src/filters/switcher/AudioSwitcher/Audio.cpp
+++ b/src/filters/switcher/AudioSwitcher/Audio.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -24,7 +24,8 @@
#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;
@@ -36,7 +37,8 @@ static long audio_pointsample_8(void *dst, void *src, long accum, long samp_frac
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;
@@ -48,7 +50,8 @@ static long audio_pointsample_16(void *dst, void *src, long accum, long samp_fra
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;
@@ -60,7 +63,8 @@ static long audio_pointsample_32(void *dst, void *src, long accum, long samp_fra
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;
@@ -77,12 +81,13 @@ static long audio_downsample_mono8(void *dst, void *src, long *filter_bank, int
sum += *fb_ptr++ * (int)*s_ptr++;
} while(--w);
- if (sum < 0)
+ if (sum < 0) {
*d++ = 0;
- else if (sum > 0x3fffff)
+ } else if (sum > 0x3fffff) {
*d++ = 0xff;
- else
+ } else {
*d++ = ((sum + 0x2000)>>14);
+ }
accum += samp_frac;
} while(--cnt);
@@ -90,7 +95,8 @@ static long audio_downsample_mono8(void *dst, void *src, long *filter_bank, int
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;
@@ -107,12 +113,13 @@ static long audio_downsample_mono16(void *dst, void *src, long *filter_bank, int
sum += *fb_ptr++ * (int)*s_ptr++;
} while(--w);
- if (sum < -0x20000000)
+ if (sum < -0x20000000) {
*d++ = -0x8000;
- else if (sum > 0x1fffffff)
+ } else if (sum > 0x1fffffff) {
*d++ = 0x7fff;
- else
+ } else {
*d++ = ((sum + 0x2000)>>14);
+ }
accum += samp_frac;
} while(--cnt);
@@ -121,11 +128,13 @@ static long audio_downsample_mono16(void *dst, void *src, long *filter_bank, int
}
-static int permute_index(int a, int b) {
+static int permute_index(int a, int 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;
@@ -140,29 +149,32 @@ static void make_downsample_filter(long *filter_bank, int filter_width, long sam
int y = 0;
double d = i / filtwidth_frac;
- if (d<1.0)
+ 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)]
+ = y;
}
// 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++)
+ 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++)
+ 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)
@@ -171,22 +183,17 @@ AudioStreamResampler::AudioStreamResampler(int bps, long org_rate, long new_rate
this->bps = bps;
- if(bps == 1)
- {
+ if(bps == 1) {
ptsampleRout = audio_pointsample_8;
dnsampleRout = audio_downsample_mono8;
- }
- else if(bps >= 2)
- {
+ } else if(bps >= 2) {
ptsampleRout = audio_pointsample_16;
dnsampleRout = audio_downsample_mono16;
- }
- else
- {
+ } else {
return;
}
-// org_rate > new_rate!
+ // org_rate > new_rate!
samp_frac = MulDiv(org_rate, 0x80000, new_rate);
holdover = 0;
@@ -196,17 +203,14 @@ AudioStreamResampler::AudioStreamResampler(int bps, long org_rate, long new_rate
// If this is a high-quality downsample, allocate memory for the filter bank
- if(fHighQuality)
- {
- if(samp_frac>0x80000)
- {
+ if(fHighQuality) {
+ if(samp_frac>0x80000) {
// HQ downsample: allocate filter bank
filter_width = ((samp_frac + 0x7ffff)>>19)<<1 <<1;
filter_bank = DNew long[filter_width * 256];
- if(!filter_bank)
- {
+ if(!filter_bank) {
filter_width = 1;
return;
}
@@ -236,8 +240,7 @@ long AudioStreamResampler::Downsample(void* input, long samplesin, void* output,
//
// We need (n/2) points to the left and (n/2-1) points to the right.
- while(samplesin > 0 && samplesout > 0)
- {
+ while(samplesin > 0 && samplesout > 0) {
long srcSamples, dstSamples;
int nhold;
@@ -251,13 +254,16 @@ long AudioStreamResampler::Downsample(void* input, long samplesin, void* output,
// Don't exceed the buffer (BUFFER_SIZE - holdover).
- if(srcSamples > BUFFER_SIZE - holdover)
+ if(srcSamples > BUFFER_SIZE - holdover) {
srcSamples = BUFFER_SIZE - holdover;
+ }
// Read into buffer.
srcSamples = min(srcSamples, samplesin);
- if(!srcSamples) break;
+ if(!srcSamples) {
+ break;
+ }
memcpy((char*)cbuffer + holdover*bps, (char*)input, srcSamples*bps);
input = (void *)((char *)input + srcSamples*bps);
@@ -269,15 +275,16 @@ long AudioStreamResampler::Downsample(void* input, long samplesin, void* output,
dstSamples = (((__int64)(srcSamples+holdover-filter_width)<<19) + 0x7ffff - accum) / samp_frac + 1;
- if(dstSamples > samplesout)
+ if(dstSamples > samplesout) {
dstSamples = samplesout;
+ }
- if(dstSamples >= 1)
- {
- if(filter_bank)
+ if(dstSamples >= 1) {
+ if(filter_bank) {
accum = dnsampleRout(output, cbuffer, filter_bank, filter_width, accum, samp_frac, dstSamples);
- else
+ } else {
accum = ptsampleRout(output, cbuffer, accum, samp_frac, dstSamples);
+ }
output = (void *)((char *)output + bps * dstSamples);
lActualSamples += dstSamples;
@@ -297,16 +304,17 @@ long AudioStreamResampler::Downsample(void* input, long samplesin, void* output,
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
+ } else {
holdover = 0;
+ }
-// _ASSERT(accum>=0);
+ // _ASSERT(accum>=0);
}
int Bytes = lActualSamples * bps;
diff --git a/src/filters/switcher/AudioSwitcher/Audio.h b/src/filters/switcher/AudioSwitcher/Audio.h
index df032796f..5cb098ed0 100644
--- a/src/filters/switcher/AudioSwitcher/Audio.h
+++ b/src/filters/switcher/AudioSwitcher/Audio.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -29,7 +29,7 @@
typedef long (*AudioPointSampler)(void *, void *, long, long, long);
typedef long (*AudioDownSampler)(void *, void *, long *, int, long, long, long);
-class AudioStreamResampler
+class AudioStreamResampler
{
private:
AudioPointSampler ptsampleRout;
diff --git a/src/filters/switcher/AudioSwitcher/AudioSwitcher.cpp b/src/filters/switcher/AudioSwitcher/AudioSwitcher.cpp
index d49e6f4c2..db50246d1 100644
--- a/src/filters/switcher/AudioSwitcher/AudioSwitcher.cpp
+++ b/src/filters/switcher/AudioSwitcher/AudioSwitcher.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -37,30 +37,25 @@
#ifdef REGISTER_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
{&MEDIATYPE_Audio, &MEDIASUBTYPE_NULL}
};
-const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
{&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}
+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}
};
-const AMOVIESETUP_FILTER sudFilter[] =
-{
+const AMOVIESETUP_FILTER sudFilter[] = {
{&__uuidof(CAudioSwitcherFilter), L"MPC - AudioSwitcher", MERIT_DO_NOT_USE, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory}
};
-CFactoryTemplate g_Templates[] =
-{
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CAudioSwitcherFilter>, NULL, &sudFilter[0]}
+CFactoryTemplate g_Templates[] = {
+ {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CAudioSwitcherFilter>, NULL, &sudFilter[0]}
};
int g_cTemplates = countof(g_Templates);
@@ -99,10 +94,12 @@ CAudioSwitcherFilter::CAudioSwitcherFilter(LPUNKNOWN lpunk, HRESULT* phr)
{
memset(m_pSpeakerToChannelMap, 0, sizeof(m_pSpeakerToChannelMap));
- if(phr)
- {
- if(FAILED(*phr)) return;
- else *phr = S_OK;
+ if(phr) {
+ if(FAILED(*phr)) {
+ return;
+ } else {
+ *phr = S_OK;
+ }
}
}
@@ -116,9 +113,10 @@ STDMETHODIMP CAudioSwitcherFilter::NonDelegatingQueryInterface(REFIID riid, void
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
+ && ((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
@@ -130,38 +128,37 @@ HRESULT CAudioSwitcherFilter::CheckMediaType(const CMediaType* pmt)
|| ((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;
+ ? S_OK
+ : VFW_E_TYPE_NOT_ACCEPTED;
}
-template<class T, class U, int Umin, int Umax>
+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;
- for(int i = 0, j = ch; i < j; i++)
- {
- if(mask & (1<<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;
}
-template<>
+template<>
__forceinline void mix<int, INT64, (-1<<24), (+1<<24)-1>(DWORD mask, int ch, int bps, BYTE* src, BYTE* dst)
{
INT64 sum = 0;
- for(int i = 0, j = ch; i < j; i++)
- {
- if(mask & (1<<i))
- {
+ 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;
@@ -173,31 +170,30 @@ __forceinline void mix<int, INT64, (-1<<24), (+1<<24)-1>(DWORD mask, int ch, int
memcpy(dst, (BYTE*)&sum, 3);
}
-template<class T, class U, int Umin, int Umax>
+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))
- {
+ if(mask & (1<<0)) {
sum += *(T*)&src[bps*0];
}
- if(mask & (1<<1))
- {
+ if(mask & (1<<1)) {
sum += *(T*)&src[bps*1];
}
- if(mask & (1<<2))
- {
+ if(mask & (1<<2)) {
sum += *(T*)&src[bps*2];
}
- if(mask & (1<<3))
- {
+ if(mask & (1<<3)) {
sum += *(T*)&src[bps*3];
}
- 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;
}
@@ -205,11 +201,17 @@ __forceinline void mix4(DWORD mask, BYTE* src, BYTE* dst)
template<class T>
T clamp(double s, T smin, T smax)
{
- if(s < -1) s = -1;
- else if(s > 1) s = 1;
+ 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;
+ if(t < smin) {
+ t = smin;
+ } else if(t > smax) {
+ t = smax;
+ }
return t;
}
@@ -217,8 +219,9 @@ HRESULT CAudioSwitcherFilter::Transform(IMediaSample* pIn, IMediaSample* pOut)
{
CStreamSwitcherInputPin* pInPin = GetInputPin();
CStreamSwitcherOutputPin* pOutPin = GetOutputPin();
- if(!pInPin || !pOutPin)
+ if(!pInPin || !pOutPin) {
return __super::Transform(pIn, pOut);
+ }
WAVEFORMATEX* wfe = (WAVEFORMATEX*)pInPin->CurrentMediaType().pbFormat;
WAVEFORMATEX* wfeout = (WAVEFORMATEX*)pOutPin->CurrentMediaType().pbFormat;
@@ -230,17 +233,14 @@ HRESULT CAudioSwitcherFilter::Transform(IMediaSample* pIn, IMediaSample* pOut)
int lenout = (UINT64)len * wfeout->nSamplesPerSec / wfe->nSamplesPerSec;
REFERENCE_TIME rtStart, rtStop;
- if(SUCCEEDED(pIn->GetTime(&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
- {
+ } else {
pOut->SetTime(&m_rtNextStart, &m_rtNextStop);
}
@@ -249,34 +249,41 @@ HRESULT CAudioSwitcherFilter::Transform(IMediaSample* pIn, IMediaSample* pOut)
m_rtNextStart += rtDur;
m_rtNextStop += rtDur;
- if(pIn->IsDiscontinuity() == S_OK)
- {
+ 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);
+ 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(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;
+ 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(len == 0) {
+ pOut->SetActualDataLength(0);
+ return S_OK;
+ }
- if(m_fCustomChannelMapping)
- {
+ 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++)
- {
+ 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;
@@ -285,147 +292,144 @@ HRESULT CAudioSwitcherFilter::Transform(IMediaSample* pIn, IMediaSample* pOut)
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)
- {
+ 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)
- {
+ } 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)
- {
+ } 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)
- {
+ } else if(fPCM && wfe->wBitsPerSample == 24) {
+ for(int k = 0; k < len; k++, src += srcstep, dst += dststep) {
mix<int, INT64, (-1<<24), (+1<<24)-1>(mask, channels, bps, src, dst);
}
- }
- else if(fPCM && wfe->wBitsPerSample == 32)
- {
- for(int k = 0; k < len; k++, src += srcstep, dst += dststep)
- {
+ } 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)
- {
+ } 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)
- {
+ } 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
- {
+ } else {
BYTE* pDataOut = NULL;
HRESULT hr;
- if(FAILED(hr = pOut->GetPointer(&pDataOut)) || !pDataOut) return hr;
+ if(FAILED(hr = pOut->GetPointer(&pDataOut)) || !pDataOut) {
+ return hr;
+ }
memset(pDataOut, 0, pOut->GetSize());
}
- }
- else
- {
+ } else {
HRESULT hr;
- if(S_OK != (hr = __super::Transform(pIn, pOut)))
+ 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++)
- {
+ && 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++)
+ 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++)
+ 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)
- {
+ 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];
+ 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++)
- {
+ 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;
+ 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_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)
- {
+ if(m_boost_mul > 1) {
sample_mul *= m_boost_mul;
}
- for(int i = 0; i < samples; i++)
- {
+ 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);
+ 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;
@@ -441,41 +445,39 @@ CMediaType CAudioSwitcherFilter::CreateNewOutputMediaType(CMediaType mt, long& c
{
CStreamSwitcherInputPin* pInPin = GetInputPin();
CStreamSwitcherOutputPin* pOutPin = GetOutputPin();
- if(!pInPin || !pOutPin || ((WAVEFORMATEX*)mt.pbFormat)->wFormatTag == WAVE_FORMAT_DOLBY_AC3_SPDIF)
+ 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)
- {
+ 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)
- {
+ 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)
- {
+ 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 =
+ 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(int i = 0; i < m_chs[wfe->nChannels-1].GetCount(); i++)
+ for(int 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;
@@ -485,10 +487,8 @@ CMediaType CAudioSwitcherFilter::CreateNewOutputMediaType(CMediaType mt, long& c
WAVEFORMATEX* wfeout = (WAVEFORMATEX*)mt.pbFormat;
- if(m_fDownSampleTo441)
- {
- if(wfeout->nSamplesPerSec > 44100 && wfeout->wBitsPerSample <= 16)
- {
+ if(m_fDownSampleTo441) {
+ if(wfeout->nSamplesPerSec > 44100 && wfeout->wBitsPerSample <= 16) {
wfeout->nSamplesPerSec = 44100;
wfeout->nAvgBytesPerSec = wfeout->nBlockAlign*wfeout->nSamplesPerSec;
}
@@ -499,8 +499,8 @@ CMediaType CAudioSwitcherFilter::CreateNewOutputMediaType(CMediaType mt, long& c
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);
+ // mt.lSampleSize = (ULONG)max(mt.lSampleSize, wfe->nAvgBytesPerSec * rtLen / 10000000i64);
+ // mt.lSampleSize = (mt.lSampleSize + (wfe->nBlockAlign-1)) & ~(wfe->nBlockAlign-1);
return mt;
}
@@ -511,8 +511,7 @@ void CAudioSwitcherFilter::OnNewOutputMediaType(const CMediaType& mtIn, const CM
const WAVEFORMATEX* wfeout = (WAVEFORMATEX*)mtOut.pbFormat;
m_pResamplers.RemoveAll();
- for(int i = 0; i < wfeout->nChannels; i++)
- {
+ 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);
@@ -540,24 +539,23 @@ HRESULT CAudioSwitcherFilter::DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE
STDMETHODIMP CAudioSwitcherFilter::GetInputSpeakerConfig(DWORD* pdwChannelMask)
{
- if(!pdwChannelMask)
+ if(!pdwChannelMask) {
return E_POINTER;
+ }
*pdwChannelMask = 0;
CStreamSwitcherInputPin* pInPin = GetInputPin();
- if(!pInPin || !pInPin->IsConnected())
+ if(!pInPin || !pInPin->IsConnected()) {
return E_UNEXPECTED;
+ }
WAVEFORMATEX* wfe = (WAVEFORMATEX*)pInPin->CurrentMediaType().pbFormat;
- if(wfe->wFormatTag == WAVE_FORMAT_EXTENSIBLE)
- {
+ if(wfe->wFormatTag == WAVE_FORMAT_EXTENSIBLE) {
WAVEFORMATEXTENSIBLE* wfex = (WAVEFORMATEXTENSIBLE*)wfe;
*pdwChannelMask = wfex->dwChannelMask;
- }
- else
- {
+ } else {
*pdwChannelMask = 0/*wfe->nChannels == 1 ? 4 : wfe->nChannels == 2 ? 3 : 0*/;
}
@@ -566,7 +564,9 @@ STDMETHODIMP CAudioSwitcherFilter::GetInputSpeakerConfig(DWORD* pdwChannelMask)
STDMETHODIMP CAudioSwitcherFilter::GetSpeakerConfig(bool* pfCustomChannelMapping, DWORD pSpeakerToChannelMap[18][18])
{
- if(pfCustomChannelMapping) *pfCustomChannelMapping = m_fCustomChannelMapping;
+ if(pfCustomChannelMapping) {
+ *pfCustomChannelMapping = m_fCustomChannelMapping;
+ }
memcpy(pSpeakerToChannelMap, m_pSpeakerToChannelMap, sizeof(m_pSpeakerToChannelMap));
return S_OK;
@@ -575,10 +575,9 @@ STDMETHODIMP CAudioSwitcherFilter::GetSpeakerConfig(bool* pfCustomChannelMapping
STDMETHODIMP CAudioSwitcherFilter::SetSpeakerConfig(bool fCustomChannelMapping, DWORD pSpeakerToChannelMap[18][18])
{
if(m_State == State_Stopped || m_fCustomChannelMapping != fCustomChannelMapping
- || memcmp(m_pSpeakerToChannelMap, pSpeakerToChannelMap, sizeof(m_pSpeakerToChannelMap)))
- {
+ || memcmp(m_pSpeakerToChannelMap, pSpeakerToChannelMap, sizeof(m_pSpeakerToChannelMap))) {
PauseGraph;
-
+
CStreamSwitcherInputPin* pInput = GetInputPin();
SelectInput(NULL);
@@ -607,8 +606,7 @@ STDMETHODIMP_(bool) CAudioSwitcherFilter::IsDownSamplingTo441Enabled()
STDMETHODIMP CAudioSwitcherFilter::EnableDownSamplingTo441(bool fEnable)
{
- if(m_fDownSampleTo441 != fEnable)
- {
+ if(m_fDownSampleTo441 != fEnable) {
PauseGraph;
m_fDownSampleTo441 = fEnable;
ResumeGraph;
@@ -638,7 +636,9 @@ STDMETHODIMP CAudioSwitcherFilter::GetNormalizeBoost(bool& fNormalize, bool& fNo
STDMETHODIMP CAudioSwitcherFilter::SetNormalizeBoost(bool fNormalize, bool fNormalizeRecover, float boost_dB)
{
- if(m_fNormalize != fNormalize) m_sample_max = 0.1f;
+ if(m_fNormalize != fNormalize) {
+ m_sample_max = 0.1f;
+ }
m_fNormalize = fNormalize;
m_fNormalizeRecover = fNormalizeRecover;
m_boost_mul = pow(10.0f, boost_dB/20);
@@ -650,6 +650,8 @@ STDMETHODIMP CAudioSwitcherFilter::SetNormalizeBoost(bool fNormalize, bool fNorm
STDMETHODIMP CAudioSwitcherFilter::Enable(long lIndex, DWORD dwFlags)
{
HRESULT hr = __super::Enable(lIndex, dwFlags);
- if(S_OK == hr) m_sample_max = 0.1f;
+ 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 8f2779149..b54037d06 100644
--- a/src/filters/switcher/AudioSwitcher/AudioSwitcher.h
+++ b/src/filters/switcher/AudioSwitcher/AudioSwitcher.h
@@ -21,12 +21,12 @@
#include "StreamSwitcher.h"
interface __declspec(uuid("CEDB2890-53AE-4231-91A3-B0AAFCD1DBDE"))
-IAudioSwitcherFilter : public IUnknown
-{
+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(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;
@@ -38,9 +38,11 @@ IAudioSwitcherFilter : public IUnknown
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;
+ typedef struct {
+ DWORD Speaker, Channel;
+ } ChMap;
CAtlArray<ChMap> m_chs[18];
bool m_fCustomChannelMapping;
@@ -58,7 +60,7 @@ public:
CAudioSwitcherFilter(LPUNKNOWN lpunk, HRESULT* phr);
DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
HRESULT CheckMediaType(const CMediaType* pmt);
HRESULT Transform(IMediaSample* pIn, IMediaSample* pOut);
@@ -70,9 +72,9 @@ public:
// 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 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();
diff --git a/src/filters/switcher/AudioSwitcher/StreamSwitcher.cpp b/src/filters/switcher/AudioSwitcher/StreamSwitcher.cpp
index 7a75a2768..8b62ada0a 100644
--- a/src/filters/switcher/AudioSwitcher/StreamSwitcher.cpp
+++ b/src/filters/switcher/AudioSwitcher/StreamSwitcher.cpp
@@ -45,10 +45,10 @@ CStreamSwitcherPassThru::CStreamSwitcherPassThru(LPUNKNOWN pUnk, HRESULT* phr, C
STDMETHODIMP CStreamSwitcherPassThru::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
- CheckPointer(ppv, E_POINTER);
- *ppv = NULL;
+ CheckPointer(ppv, E_POINTER);
+ *ppv = NULL;
- return
+ return
QI(IMediaSeeking)
CMediaPosition::NonDelegatingQueryInterface(riid, ppv);
}
@@ -56,17 +56,19 @@ STDMETHODIMP CStreamSwitcherPassThru::NonDelegatingQueryInterface(REFIID riid, v
template<class T>
HRESULT GetPeer(CStreamSwitcherFilter* pFilter, T** ppT)
{
- *ppT = NULL;
+ *ppT = NULL;
CBasePin* pPin = pFilter->GetInputPin();
- if(!pPin) return E_NOTIMPL;
+ if(!pPin) {
+ return E_NOTIMPL;
+ }
- CComPtr<IPin> pConnected;
- if(FAILED(pPin->ConnectedTo(&pConnected)))
+ CComPtr<IPin> pConnected;
+ if(FAILED(pPin->ConnectedTo(&pConnected))) {
return E_NOTIMPL;
+ }
- if(CComQIPtr<T> pT = pConnected)
- {
+ if(CComQIPtr<T> pT = pConnected) {
*ppT = pT.Detach();
return S_OK;
}
@@ -78,12 +80,12 @@ HRESULT GetPeer(CStreamSwitcherFilter* pFilter, T** ppT)
CComPtr<IMediaSeeking> pMS; \
if(FAILED(GetPeer(m_pFilter, &pMS))) return E_NOTIMPL; \
return pMS->##call; \
-
+
#define CallPeer(call) \
CComPtr<IMediaPosition> pMP; \
if(FAILED(GetPeer(m_pFilter, &pMP))) return E_NOTIMPL; \
return pMP->##call; \
-
+
#define CallPeerSeekingAll(call) \
HRESULT hr = E_NOTIMPL; \
POSITION pos = m_pFilter->m_pInputs.GetHeadPosition(); \
@@ -101,7 +103,7 @@ HRESULT GetPeer(CStreamSwitcherFilter* pFilter, T** ppT)
} \
} \
return hr; \
-
+
#define CallPeerAll(call) \
HRESULT hr = E_NOTIMPL; \
POSITION pos = m_pFilter->m_pInputs.GetHeadPosition(); \
@@ -119,71 +121,131 @@ HRESULT GetPeer(CStreamSwitcherFilter* pFilter, T** ppT)
} \
} \
return hr; \
-
+
// IMediaSeeking
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)
- {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));}
-STDMETHODIMP CStreamSwitcherPassThru::CanSeekBackward(LONG* pCanSeekBackward)
- {CallPeer(CanSeekBackward(pCanSeekBackward));}
+{
+ CallPeer(CanSeekForward(pCanSeekForward));
+}
+STDMETHODIMP CStreamSwitcherPassThru::CanSeekBackward(LONG* pCanSeekBackward)
+{
+ CallPeer(CanSeekBackward(pCanSeekBackward));
+}
//
// CStreamSwitcherAllocator
@@ -201,7 +263,7 @@ CStreamSwitcherAllocator::CStreamSwitcherAllocator(CStreamSwitcherInputPin* pPin
#ifdef DEBUG
CStreamSwitcherAllocator::~CStreamSwitcherAllocator()
{
- ASSERT(m_bCommitted == FALSE);
+ ASSERT(m_bCommitted == FALSE);
}
#endif
@@ -216,49 +278,59 @@ STDMETHODIMP_(ULONG) CStreamSwitcherAllocator::NonDelegatingRelease()
}
STDMETHODIMP CStreamSwitcherAllocator::GetBuffer(
- IMediaSample** ppBuffer,
- REFERENCE_TIME* pStartTime, REFERENCE_TIME* pEndTime,
+ 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)
+ 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())
+ if(!pOut || !pOut->CurrentAllocator()) {
return hr;
+ }
ALLOCATOR_PROPERTIES Properties, Actual;
- if(FAILED(pOut->CurrentAllocator()->GetProperties(&Actual)))
+ if(FAILED(pOut->CurrentAllocator()->GetProperties(&Actual))) {
return hr;
- if(FAILED(GetProperties(&Properties)))
+ }
+ if(FAILED(GetProperties(&Properties))) {
return hr;
+ }
- if(!m_bCommitted || Properties.cbBuffer < Actual.cbBuffer)
- {
+ 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;
+ 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;
+ if(Actual.cbBuffer < Properties.cbBuffer) {
+ return hr;
+ }
}
}
hr = CMemAllocator::GetBuffer(ppBuffer, pStartTime, pEndTime, dwFlags);
- if(m_fMediaTypeChanged && SUCCEEDED(hr))
- {
+ if(m_fMediaTypeChanged && SUCCEEDED(hr)) {
(*ppBuffer)->SetMediaType(&m_mt);
m_fMediaTypeChanged = false;
}
@@ -278,7 +350,7 @@ void CStreamSwitcherAllocator::NotifyMediaType(const CMediaType& mt)
//
CStreamSwitcherInputPin::CStreamSwitcherInputPin(CStreamSwitcherFilter* pFilter, HRESULT* phr, LPCWSTR pName)
- : CBaseInputPin(NAME("CStreamSwitcherInputPin"), pFilter, &pFilter->m_csState, phr, pName)
+ : CBaseInputPin(NAME("CStreamSwitcherInputPin"), pFilter, &pFilter->m_csState, phr, pName)
, m_Allocator(this, phr)
, m_bSampleSkipped(FALSE)
, m_bQualityChanged(FALSE)
@@ -291,7 +363,7 @@ CStreamSwitcherInputPin::CStreamSwitcherInputPin(CStreamSwitcherFilter* pFilter,
}
class __declspec(uuid("138130AF-A79B-45D5-B4AA-87697457BA87"))
-NeroAudioDecoder {};
+ NeroAudioDecoder {};
STDMETHODIMP CStreamSwitcherInputPin::NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
@@ -310,7 +382,9 @@ STDMETHODIMP CStreamSwitcherInputPin::DynamicQueryAccept(const AM_MEDIA_TYPE* pm
STDMETHODIMP CStreamSwitcherInputPin::NotifyEndOfStream(HANDLE hNotifyEvent)
{
- if(m_hNotifyEvent) SetEvent(m_hNotifyEvent);
+ if(m_hNotifyEvent) {
+ SetEvent(m_hNotifyEvent);
+ }
m_hNotifyEvent = hNotifyEvent;
return S_OK;
}
@@ -335,7 +409,7 @@ STDMETHODIMP_(bool) CStreamSwitcherInputPin::IsActive()
return(this == (static_cast<CStreamSwitcherFilter*>(m_pFilter))->GetInputPin());
}
-//
+//
HRESULT CStreamSwitcherInputPin::QueryAcceptDownstream(const AM_MEDIA_TYPE* pmt)
{
@@ -343,12 +417,12 @@ HRESULT CStreamSwitcherInputPin::QueryAcceptDownstream(const AM_MEDIA_TYPE* pmt)
CStreamSwitcherOutputPin* pOut = (static_cast<CStreamSwitcherFilter*>(m_pFilter))->GetOutputPin();
- if(pOut && pOut->IsConnected())
- {
- if(CComPtr<IPinConnection> pPC = pOut->CurrentPinConnection())
- {
+ if(pOut && pOut->IsConnected()) {
+ if(CComPtr<IPinConnection> pPC = pOut->CurrentPinConnection()) {
hr = pPC->DynamicQueryAccept(pmt);
- if(hr == S_OK) return S_OK;
+ if(hr == S_OK) {
+ return S_OK;
+ }
}
hr = pOut->GetConnected()->QueryAccept(pmt);
@@ -359,71 +433,78 @@ HRESULT CStreamSwitcherInputPin::QueryAcceptDownstream(const AM_MEDIA_TYPE* pmt)
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)
+ if(!pInSample || !ppOutSample) {
return E_POINTER;
+ }
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;
- if(!(m_SampleProps.dwSampleFlags & AM_SAMPLE_SPLICEPOINT))
+ 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);
+ , m_SampleProps.dwSampleFlags & AM_SAMPLE_TIMEVALID ? &m_SampleProps.tStart : NULL
+ , m_SampleProps.dwSampleFlags & AM_SAMPLE_STOPVALID ? &m_SampleProps.tStop : NULL
+ , dwFlags);
- if(FAILED(hr))
+ if(FAILED(hr)) {
return hr;
+ }
- if(!pOutSample)
+ if(!pOutSample) {
return E_FAIL;
+ }
- if(CComQIPtr<IMediaSample2> pOutSample2 = pOutSample)
- {
- AM_SAMPLE2_PROPERTIES OutProps;
+ 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.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)
+ 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)
+ }
+ } else {
+ if(m_SampleProps.dwSampleFlags & AM_SAMPLE_TIMEVALID) {
pOutSample->SetTime(&m_SampleProps.tStart, &m_SampleProps.tStop);
+ }
- if(m_SampleProps.dwSampleFlags & AM_SAMPLE_SPLICEPOINT)
+ if(m_SampleProps.dwSampleFlags & AM_SAMPLE_SPLICEPOINT) {
pOutSample->SetSyncPoint(TRUE);
+ }
- if(m_SampleProps.dwSampleFlags & AM_SAMPLE_DATADISCONTINUITY)
- {
+ if(m_SampleProps.dwSampleFlags & AM_SAMPLE_DATADISCONTINUITY) {
pOutSample->SetDiscontinuity(TRUE);
- m_bSampleSkipped = FALSE;
- }
+ m_bSampleSkipped = FALSE;
+ }
LONGLONG MediaStart, MediaEnd;
- if(pInSample->GetMediaTime(&MediaStart, &MediaEnd) == NOERROR)
+ if(pInSample->GetMediaTime(&MediaStart, &MediaEnd) == NOERROR) {
pOutSample->SetMediaTime(&MediaStart, &MediaEnd);
- }
+ }
+ }
*ppOutSample = pOutSample.Detach();
@@ -437,21 +518,23 @@ HRESULT CStreamSwitcherInputPin::CheckMediaType(const CMediaType* pmt)
return (static_cast<CStreamSwitcherFilter*>(m_pFilter))->CheckMediaType(pmt);
}
-// virtual
+// 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;
+ if(FAILED(hr)) {
+ return hr;
+ }
- (static_cast<CStreamSwitcherFilter*>(m_pFilter))->CompleteConnect(PINDIR_INPUT, this, pReceivePin);
+ (static_cast<CStreamSwitcherFilter*>(m_pFilter))->CompleteConnect(PINDIR_INPUT, this, pReceivePin);
m_fCanBlock = false;
bool fForkedSomewhere = false;
@@ -459,49 +542,52 @@ HRESULT CStreamSwitcherInputPin::CompleteConnect(IPin* pReceivePin)
CStringW fileName;
CStringW pinName;
- IPin* pPin = (IPin*)this;
+ IPin* pPin = (IPin*)this;
IBaseFilter* pBF = (IBaseFilter*)m_pFilter;
pPin = GetUpStreamPin(pBF, pPin);
- if (pPin)
+ if (pPin) {
pBF = GetFilterFromPin(pPin);
- while(pPin && pBF)
- {
- if(IsSplitter(pBF))
- {
+ }
+ while(pPin && pBF) {
+ if(IsSplitter(pBF)) {
pinName = GetPinName(pPin);
}
CLSID clsid = GetCLSID(pBF);
- if(clsid == CLSID_AviSplitter || clsid == CLSID_OggSplitter)
+ 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)
- {
+ if(CComQIPtr<IFileSourceFilter> pFSF = pBF) {
WCHAR* pszName = NULL;
AM_MEDIA_TYPE mt;
- if(SUCCEEDED(pFSF->GetCurFile(&pszName, &mt)) && pszName)
- {
+ 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;
+ 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" ";
+ if(!pinName.IsEmpty()) {
+ fileName = pinName + L" ";
+ }
WCHAR* pName = DNew WCHAR[fileName.GetLength()+1];
- if(pName)
- {
+ if(pName) {
wcscpy(pName, fileName);
- if(m_pName) delete [] m_pName;
+ if(m_pName) {
+ delete [] m_pName;
+ }
m_pName = pName;
}
}
@@ -512,12 +598,14 @@ HRESULT CStreamSwitcherInputPin::CompleteConnect(IPin* pReceivePin)
pPin = GetFirstPin(pBF);
pPin = GetUpStreamPin(pBF, pPin);
- if (pPin)
+ if (pPin) {
pBF = GetFilterFromPin(pPin);
+ }
}
- if(!fForkedSomewhere)
+ if(!fForkedSomewhere) {
m_fCanBlock = true;
+ }
m_hNotifyEvent = NULL;
@@ -543,7 +631,9 @@ HRESULT CStreamSwitcherInputPin::Inactive()
STDMETHODIMP CStreamSwitcherInputPin::QueryAccept(const AM_MEDIA_TYPE* pmt)
{
HRESULT hr = __super::QueryAccept(pmt);
- if(S_OK != hr) return hr;
+ if(S_OK != hr) {
+ return hr;
+ }
return QueryAcceptDownstream(pmt);
}
@@ -551,39 +641,43 @@ STDMETHODIMP CStreamSwitcherInputPin::QueryAccept(const AM_MEDIA_TYPE* pmt)
STDMETHODIMP CStreamSwitcherInputPin::ReceiveConnection(IPin* pConnector, const AM_MEDIA_TYPE* pmt)
{
// FIXME: this locked up once
-// CAutoLock cAutoLock(&((CStreamSwitcherFilter*)m_pFilter)->m_csReceive);
+ // CAutoLock cAutoLock(&((CStreamSwitcherFilter*)m_pFilter)->m_csReceive);
HRESULT hr;
- if(S_OK != (hr = QueryAcceptDownstream(pmt)))
+ 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)
+ if(m_Connected) {
m_Connected->Release(), m_Connected = NULL;
+ }
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;
+ if(FAILED(hr)) {
+ return hr;
+ }
m_bUsingOwnAllocator = (pAllocator == (IMemAllocator*)&m_Allocator);
@@ -592,18 +686,20 @@ STDMETHODIMP CStreamSwitcherInputPin::NotifyAllocator(IMemAllocator* pAllocator,
STDMETHODIMP CStreamSwitcherInputPin::BeginFlush()
{
- CAutoLock cAutoLock(&(static_cast<CStreamSwitcherFilter*>(m_pFilter))->m_csState);
+ CAutoLock cAutoLock(&(static_cast<CStreamSwitcherFilter*>(m_pFilter))->m_csState);
HRESULT hr;
CStreamSwitcherFilter* pSSF = static_cast<CStreamSwitcherFilter*>(m_pFilter);
CStreamSwitcherOutputPin* pOut = pSSF->GetOutputPin();
- if(!IsConnected() || !pOut || !pOut->IsConnected())
+ if(!IsConnected() || !pOut || !pOut->IsConnected()) {
return VFW_E_NOT_CONNECTED;
+ }
- if(FAILED(hr = __super::BeginFlush()))
+ if(FAILED(hr = __super::BeginFlush())) {
return hr;
+ }
return IsActive() ? pSSF->DeliverBeginFlush() : Block(false), S_OK;
}
@@ -617,27 +713,29 @@ STDMETHODIMP CStreamSwitcherInputPin::EndFlush()
CStreamSwitcherFilter* pSSF = static_cast<CStreamSwitcherFilter*>(m_pFilter);
CStreamSwitcherOutputPin* pOut = pSSF->GetOutputPin();
- if(!IsConnected() || !pOut || !pOut->IsConnected())
+ if(!IsConnected() || !pOut || !pOut->IsConnected()) {
return VFW_E_NOT_CONNECTED;
+ }
- if(FAILED(hr = __super::EndFlush()))
+ if(FAILED(hr = __super::EndFlush())) {
return hr;
+ }
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);
CStreamSwitcherOutputPin* pOut = pSSF->GetOutputPin();
- if(!IsConnected() || !pOut || !pOut->IsConnected())
+ if(!IsConnected() || !pOut || !pOut->IsConnected()) {
return VFW_E_NOT_CONNECTED;
+ }
- if(m_hNotifyEvent)
- {
+ if(m_hNotifyEvent) {
SetEvent(m_hNotifyEvent), m_hNotifyEvent = NULL;
return S_OK;
}
@@ -650,45 +748,46 @@ STDMETHODIMP CStreamSwitcherInputPin::EndOfStream()
STDMETHODIMP CStreamSwitcherInputPin::Receive(IMediaSample* pSample)
{
AM_MEDIA_TYPE* pmt = NULL;
- if(SUCCEEDED(pSample->GetMediaType(&pmt)) && pmt)
- {
+ 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
+ // 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)
+ if(m_fCanBlock) {
m_evBlock.Wait();
+ }
#endif
- if(!IsActive())
- {
+ if(!IsActive()) {
#ifdef BLOCKSTREAM
- if(m_fCanBlock)
+ if(m_fCanBlock) {
return S_FALSE;
+ }
#endif
TRACE(_T("&^$#@ : a stupid fix for this stupid problem\n"));
-//Sleep(32);
+ //Sleep(32);
return E_FAIL; // a stupid fix for this stupid problem
}
- CAutoLock cAutoLock(&m_csReceive);
+ 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(S_OK != hr) {
+ return hr;
+ }
- if(m_SampleProps.dwStreamId != AM_STREAM_MEDIA)
- {
+ if(m_SampleProps.dwStreamId != AM_STREAM_MEDIA) {
return pOut->Deliver(pSample);
}
@@ -699,8 +798,7 @@ STDMETHODIMP CStreamSwitcherInputPin::Receive(IMediaSample* pSample)
hr = pOut->CurrentAllocator()->GetProperties(&actual);
REFERENCE_TIME rtStart = 0, rtStop = 0;
- if(S_OK == pSample->GetTime(&rtStart, &rtStop))
- {
+ if(S_OK == pSample->GetTime(&rtStart, &rtStop)) {
//
}
@@ -711,35 +809,34 @@ STDMETHODIMP CStreamSwitcherInputPin::Receive(IMediaSample* pSample)
bool fTypeChanged = false;
- if(mtOut != pOut->CurrentMediaType() || cbBuffer > actual.cbBuffer)
- {
+ 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(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)
+ 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)
- {
+ || actual.cbPrefix != props.cbPrefix
+ || actual.cBuffers < props.cBuffers
+ || actual.cbBuffer < props.cbBuffer) {
hr = pOut->DeliverBeginFlush();
hr = pOut->DeliverEndFlush();
hr = pOut->CurrentAllocator()->Decommit();
@@ -749,20 +846,19 @@ STDMETHODIMP CStreamSwitcherInputPin::Receive(IMediaSample* pSample)
}
CComPtr<IMediaSample> pOutSample;
- if(FAILED(InitializeOutputSample(pSample, &pOutSample)))
+ if(FAILED(InitializeOutputSample(pSample, &pOutSample))) {
return E_FAIL;
+ }
pmt = NULL;
- if(SUCCEEDED(pOutSample->GetMediaType(&pmt)) && pmt)
- {
+ if(SUCCEEDED(pOutSample->GetMediaType(&pmt)) && pmt) {
const CMediaType mt(*pmt);
DeleteMediaType(pmt), pmt = NULL;
// TODO
ASSERT(0);
}
- if(fTypeChanged)
- {
+ if(fTypeChanged) {
pOut->SetMediaType(&mtOut);
(static_cast<CStreamSwitcherFilter*>(m_pFilter))->OnNewOutputMediaType(m_mt, mtOut);
pOutSample->SetMediaType(&mtOut);
@@ -774,25 +870,21 @@ STDMETHODIMP CStreamSwitcherInputPin::Receive(IMediaSample* pSample)
//
- if(S_OK == hr)
- {
+ if(S_OK == hr) {
hr = pOut->Deliver(pOutSample);
- m_bSampleSkipped = FALSE;
-/*
- if(FAILED(hr))
- {
- ASSERT(0);
- }
-*/
- }
- else if(S_FALSE == hr)
- {
+ m_bSampleSkipped = FALSE;
+ /*
+ if(FAILED(hr))
+ {
+ ASSERT(0);
+ }
+ */
+ } else if(S_FALSE == hr) {
hr = S_OK;
pOutSample = NULL;
m_bSampleSkipped = TRUE;
-
- if(!m_bQualityChanged)
- {
+
+ if(!m_bQualityChanged) {
m_pFilter->NotifyEvent(EC_QUALITY_CHANGE, 0, 0);
m_bQualityChanged = TRUE;
}
@@ -803,16 +895,18 @@ STDMETHODIMP CStreamSwitcherInputPin::Receive(IMediaSample* pSample)
STDMETHODIMP CStreamSwitcherInputPin::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
{
- if(!IsConnected())
+ if(!IsConnected()) {
return S_OK;
+ }
CAutoLock cAutoLock(&m_csReceive);
CStreamSwitcherFilter* pSSF = static_cast<CStreamSwitcherFilter*>(m_pFilter);
CStreamSwitcherOutputPin* pOut = pSSF->GetOutputPin();
- if(!pOut || !pOut->IsConnected())
+ if(!pOut || !pOut->IsConnected()) {
return VFW_E_NOT_CONNECTED;
+ }
return pSSF->DeliverNewSegment(tStart, tStop, dRate);
}
@@ -824,35 +918,37 @@ STDMETHODIMP CStreamSwitcherInputPin::NewSegment(REFERENCE_TIME tStart, REFERENC
CStreamSwitcherOutputPin::CStreamSwitcherOutputPin(CStreamSwitcherFilter* pFilter, HRESULT* phr)
: CBaseOutputPin(NAME("CStreamSwitcherOutputPin"), pFilter, &pFilter->m_csState, phr, L"Out")
{
-// m_bCanReconnectWhenActive = TRUE;
+ // m_bCanReconnectWhenActive = TRUE;
}
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)
- {
+ 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));
+ 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 m_pStreamSwitcherPassThru->QueryInterface(riid, ppv);
}
-*/
+ /*
+ else if(riid == IID_IStreamBuilder)
+ {
+ return GetInterface((IStreamBuilder*)this, ppv);
+ }
+ */
return CBaseOutputPin::NonDelegatingQueryInterface(riid, ppv);
}
@@ -862,15 +958,12 @@ HRESULT CStreamSwitcherOutputPin::QueryAcceptUpstream(const AM_MEDIA_TYPE* pmt)
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)))
+ 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
- {
+ }
+ } else {
return E_FAIL;
}
}
@@ -883,44 +976,51 @@ HRESULT CStreamSwitcherOutputPin::QueryAcceptUpstream(const AM_MEDIA_TYPE* pmt)
HRESULT CStreamSwitcherOutputPin::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties)
{
CStreamSwitcherInputPin* pIn = (static_cast<CStreamSwitcherFilter*>(m_pFilter))->GetInputPin();
- if(!pIn || !pIn->IsConnected()) return E_UNEXPECTED;
+ if(!pIn || !pIn->IsConnected()) {
+ return E_UNEXPECTED;
+ }
CComPtr<IMemAllocator> pAllocatorIn;
pIn->GetAllocator(&pAllocatorIn);
- if(!pAllocatorIn) return E_UNEXPECTED;
+ if(!pAllocatorIn) {
+ return E_UNEXPECTED;
+ }
HRESULT hr;
- if(FAILED(hr = pAllocatorIn->GetProperties(pProperties)))
+ if(FAILED(hr = pAllocatorIn->GetProperties(pProperties))) {
return hr;
+ }
- if(pProperties->cBuffers < 8 && pIn->CurrentMediaType().majortype == MEDIATYPE_Audio)
+ if(pProperties->cBuffers < 8 && pIn->CurrentMediaType().majortype == MEDIATYPE_Audio) {
pProperties->cBuffers = 8;
+ }
ALLOCATOR_PROPERTIES Actual;
- if(FAILED(hr = pAllocator->SetProperties(pProperties, &Actual)))
+ if(FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
return hr;
+ }
return(pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer
- ? E_FAIL
- : NOERROR);
+ ? E_FAIL
+ : NOERROR);
}
// virtual
class __declspec(uuid("AEFA5024-215A-4FC7-97A4-1043C86FD0B8"))
-MatrixMixer {};
+ MatrixMixer {};
HRESULT CStreamSwitcherOutputPin::CheckConnect(IPin* pPin)
{
CComPtr<IBaseFilter> pBF = GetFilterFromPin(pPin);
- return
+ return
IsAudioWaveRenderer(pBF) || GetCLSID(pBF) == __uuidof(MatrixMixer)
- ? __super::CheckConnect(pPin)
+ ? __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()
@@ -943,27 +1043,32 @@ HRESULT CStreamSwitcherOutputPin::CheckMediaType(const CMediaType* pmt)
HRESULT CStreamSwitcherOutputPin::GetMediaType(int iPosition, CMediaType* pmt)
{
CStreamSwitcherInputPin* pIn = (static_cast<CStreamSwitcherFilter*>(m_pFilter))->GetInputPin();
- if(!pIn || !pIn->IsConnected()) return E_UNEXPECTED;
+ if(!pIn || !pIn->IsConnected()) {
+ return E_UNEXPECTED;
+ }
CComPtr<IEnumMediaTypes> pEM;
- if(FAILED(pIn->GetConnected()->EnumMediaTypes(&pEM)))
+ if(FAILED(pIn->GetConnected()->EnumMediaTypes(&pEM))) {
return VFW_S_NO_MORE_ITEMS;
+ }
- if(iPosition > 0 && FAILED(pEM->Skip(iPosition)))
+ 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)
+ 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;
+ /*
+ if(iPosition < 0) return E_INVALIDARG;
+ if(iPosition > 0) return VFW_S_NO_MORE_ITEMS;
- CopyMediaType(pmt, &pIn->CurrentMediaType());
-*/
+ CopyMediaType(pmt, &pIn->CurrentMediaType());
+ */
return S_OK;
}
@@ -972,7 +1077,9 @@ HRESULT CStreamSwitcherOutputPin::GetMediaType(int iPosition, CMediaType* pmt)
STDMETHODIMP CStreamSwitcherOutputPin::QueryAccept(const AM_MEDIA_TYPE* pmt)
{
HRESULT hr = __super::QueryAccept(pmt);
- if(S_OK != hr) return hr;
+ if(S_OK != hr) {
+ return hr;
+ }
return QueryAcceptUpstream(pmt);
}
@@ -982,8 +1089,10 @@ STDMETHODIMP CStreamSwitcherOutputPin::QueryAccept(const AM_MEDIA_TYPE* pmt)
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);
+ if(!pIn || !pIn->IsConnected()) {
+ return VFW_E_NOT_CONNECTED;
+ }
+ return pIn->PassNotify(q);
}
// IStreamBuilder
@@ -992,13 +1101,11 @@ STDMETHODIMP CStreamSwitcherOutputPin::Render(IPin* ppinOut, IGraphBuilder* pGra
{
CComPtr<IBaseFilter> pBF;
pBF.CoCreateInstance(CLSID_DSoundRender);
- if(!pBF || FAILED(pGraph->AddFilter(pBF, L"Default DirectSound Device")))
- {
+ if(!pBF || FAILED(pGraph->AddFilter(pBF, L"Default DirectSound Device"))) {
return E_FAIL;
}
- if(FAILED(pGraph->ConnectDirect(ppinOut, GetFirstDisconnectedPin(pBF, PINDIR_INPUT), NULL)))
- {
+ if(FAILED(pGraph->ConnectDirect(ppinOut, GetFirstDisconnectedPin(pBF, PINDIR_INPUT), NULL))) {
pGraph->RemoveFilter(pBF);
return E_FAIL;
}
@@ -1015,36 +1122,42 @@ STDMETHODIMP CStreamSwitcherOutputPin::Backout(IPin* ppinOut, IGraphBuilder* pGr
// CStreamSwitcherFilter
//
-CStreamSwitcherFilter::CStreamSwitcherFilter(LPUNKNOWN lpunk, HRESULT* phr, const CLSID& clsid)
+CStreamSwitcherFilter::CStreamSwitcherFilter(LPUNKNOWN lpunk, HRESULT* phr, const CLSID& clsid)
: CBaseFilter(NAME("CStreamSwitcherFilter"), lpunk, &m_csState, clsid)
{
- if(phr) *phr = S_OK;
+ if(phr) {
+ *phr = S_OK;
+ }
HRESULT hr = S_OK;
- do
- {
+ do {
CAutoPtr<CStreamSwitcherInputPin> pInput;
CAutoPtr<CStreamSwitcherOutputPin> pOutput;
hr = S_OK;
- pInput.Attach(DNew CStreamSwitcherInputPin(this, &hr, L"Channel 1"));
- if(!pInput || FAILED(hr)) break;
+ 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;
+ if(!pOutput || FAILED(hr)) {
+ break;
+ }
CAutoLock cAutoLock(&m_csPins);
-
+
m_pInputs.AddHead(m_pInput = pInput.Detach());
m_pOutput = pOutput.Detach();
return;
- }
- while(false);
+ } while(false);
- if(phr) *phr = E_FAIL;
+ if(phr) {
+ *phr = E_FAIL;
+ }
}
CStreamSwitcherFilter::~CStreamSwitcherFilter()
@@ -1052,7 +1165,9 @@ CStreamSwitcherFilter::~CStreamSwitcherFilter()
CAutoLock cAutoLock(&m_csPins);
POSITION pos = m_pInputs.GetHeadPosition();
- while(pos) delete m_pInputs.GetNext(pos);
+ while(pos) {
+ delete m_pInputs.GetNext(pos);
+ }
m_pInputs.RemoveAll();
m_pInput = NULL;
@@ -1080,9 +1195,13 @@ CBasePin* CStreamSwitcherFilter::GetPin(int n)
{
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()
@@ -1092,10 +1211,10 @@ int CStreamSwitcherFilter::GetConnectedInputPinCount()
int nConnected = 0;
POSITION pos = m_pInputs.GetHeadPosition();
- while(pos)
- {
- if(m_pInputs.GetNext(pos)->IsConnected())
+ while(pos) {
+ if(m_pInputs.GetNext(pos)->IsConnected()) {
nConnected++;
+ }
}
return(nConnected);
@@ -1103,15 +1222,14 @@ int CStreamSwitcherFilter::GetConnectedInputPinCount()
CStreamSwitcherInputPin* CStreamSwitcherFilter::GetConnectedInputPin(int n)
{
- if(n >= 0)
- {
+ if(n >= 0) {
POSITION pos = m_pInputs.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CStreamSwitcherInputPin* pPin = m_pInputs.GetNext(pos);
- if(pPin->IsConnected())
- {
- if(n == 0) return(pPin);
+ if(pPin->IsConnected()) {
+ if(n == 0) {
+ return(pPin);
+ }
n--;
}
}
@@ -1134,26 +1252,22 @@ CStreamSwitcherOutputPin* CStreamSwitcherFilter::GetOutputPin()
HRESULT CStreamSwitcherFilter::CompleteConnect(PIN_DIRECTION dir, CBasePin* pPin, IPin* pReceivePin)
{
- if(dir == PINDIR_INPUT)
- {
+ if(dir == PINDIR_INPUT) {
CAutoLock cAutoLock(&m_csPins);
int nConnected = GetConnectedInputPinCount();
- if(nConnected == 1)
- {
+ if(nConnected == 1) {
m_pInput = static_cast<CStreamSwitcherInputPin*>(pPin);
}
- if((size_t)nConnected == m_pInputs.GetCount())
- {
+ 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))
- {
+ if(!pPin || FAILED(hr)) {
delete pPin;
return E_FAIL;
}
@@ -1173,8 +1287,7 @@ void CStreamSwitcherFilter::SelectInput(CStreamSwitcherInputPin* pInput)
// release blocked GetBuffer in our own allocator & block all Receive
POSITION pos = m_pInputs.GetHeadPosition();
- while(pos)
- {
+ 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
@@ -1182,13 +1295,14 @@ void CStreamSwitcherFilter::SelectInput(CStreamSwitcherInputPin* pInput)
}
// this will let waiting GetBuffer() calls go on inside our Receive()
- if(m_pOutput)
- {
+ if(m_pOutput) {
m_pOutput->DeliverBeginFlush();
m_pOutput->DeliverEndFlush();
}
- if(!pInput) return;
+ if(!pInput) {
+ return;
+ }
// set new input
m_pInput = pInput;
@@ -1205,13 +1319,19 @@ HRESULT CStreamSwitcherFilter::Transform(IMediaSample* pIn, IMediaSample* pOut)
BYTE* pDataOut = NULL;
HRESULT hr;
- if(FAILED(hr = pIn->GetPointer(&pDataIn))) return hr;
- if(FAILED(hr = pOut->GetPointer(&pDataOut))) return 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();
- 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));
@@ -1248,7 +1368,9 @@ HRESULT CStreamSwitcherFilter::DeliverNewSegment(REFERENCE_TIME tStart, REFERENC
STDMETHODIMP CStreamSwitcherFilter::Count(DWORD* pcStreams)
{
- if(!pcStreams) return E_POINTER;
+ if(!pcStreams) {
+ return E_POINTER;
+ }
CAutoLock cAutoLock(&m_csPins);
@@ -1262,45 +1384,56 @@ STDMETHODIMP CStreamSwitcherFilter::Info(long lIndex, AM_MEDIA_TYPE** ppmt, DWOR
CAutoLock cAutoLock(&m_csPins);
CBasePin* pPin = GetConnectedInputPin(lIndex);
- if(!pPin) return E_INVALIDARG;
+ if(!pPin) {
+ return E_INVALIDARG;
+ }
- if(ppmt)
+ if(ppmt) {
*ppmt = CreateMediaType(&m_pOutput->CurrentMediaType());
+ }
- if(pdwFlags)
+ if(pdwFlags) {
*pdwFlags = (m_pInput == pPin) ? AMSTREAMSELECTINFO_EXCLUSIVE : 0;
+ }
- if(plcid)
+ if(plcid) {
*plcid = 0;
+ }
- if(pdwGroup)
+ if(pdwGroup) {
*pdwGroup = 0;
+ }
- if(ppszName)
- {
+ if(ppszName) {
*ppszName = (WCHAR*)CoTaskMemAlloc((wcslen(pPin->Name())+1)*sizeof(WCHAR));
- if(*ppszName)
+ if(*ppszName) {
wcscpy(*ppszName, pPin->Name());
+ }
}
- if(ppObject)
+ if(ppObject) {
*ppObject = NULL;
+ }
- if(ppUnk)
+ if(ppUnk) {
*ppUnk = NULL;
+ }
return S_OK;
}
STDMETHODIMP CStreamSwitcherFilter::Enable(long lIndex, DWORD dwFlags)
{
- if(dwFlags != AMSTREAMSELECTENABLE_ENABLE)
+ if(dwFlags != AMSTREAMSELECTENABLE_ENABLE) {
return E_NOTIMPL;
+ }
PauseGraph;
CStreamSwitcherInputPin* pNewInput = GetConnectedInputPin(lIndex);
- if(!pNewInput) return E_INVALIDARG;
+ if(!pNewInput) {
+ return E_INVALIDARG;
+ }
SelectInput(pNewInput);
diff --git a/src/filters/switcher/AudioSwitcher/StreamSwitcher.h b/src/filters/switcher/AudioSwitcher/StreamSwitcher.h
index be5a6fc32..714524b64 100644
--- a/src/filters/switcher/AudioSwitcher/StreamSwitcher.h
+++ b/src/filters/switcher/AudioSwitcher/StreamSwitcher.h
@@ -32,14 +32,14 @@
CComQIPtr<IMediaSeeking> _pMS((IUnknown*)(INonDelegatingUnknown*)m_pGraph); \
LONGLONG _rtNow = 0; \
if(_pMS) _hr = _pMS->GetCurrentPosition(&_rtNow); \
-
+
#define ResumeGraph \
if(SUCCEEDED(_hr) && _pMS && _fs != State_Stopped) \
_hr = _pMS->SetPositions(&_rtNow, AM_SEEKING_AbsolutePositioning, NULL, AM_SEEKING_NoPositioning); \
\
if(_fs == State_Running && _pMS) \
_pMC->Run(); \
-
+
class CStreamSwitcherFilter;
class CStreamSwitcherPassThru : public IMediaSeeking, public CMediaPosition
@@ -48,42 +48,42 @@ protected:
CStreamSwitcherFilter* m_pFilter;
public:
- CStreamSwitcherPassThru(LPUNKNOWN, HRESULT* phr, CStreamSwitcherFilter* pFilter);
+ 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);
+ 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;
@@ -91,9 +91,9 @@ class CStreamSwitcherInputPin;
class CStreamSwitcherAllocator : public CMemAllocator
{
protected:
- CStreamSwitcherInputPin* m_pPin;
+ CStreamSwitcherInputPin* m_pPin;
- CMediaType m_mt;
+ CMediaType m_mt;
bool m_fMediaTypeChanged;
public:
@@ -106,16 +106,16 @@ public:
STDMETHODIMP_(ULONG) NonDelegatingRelease();
STDMETHODIMP GetBuffer(
- IMediaSample** ppBuffer,
- REFERENCE_TIME* pStartTime, REFERENCE_TIME* pEndTime,
+ IMediaSample** ppBuffer,
+ REFERENCE_TIME* pStartTime, REFERENCE_TIME* pEndTime,
DWORD dwFlags);
void NotifyMediaType(const CMediaType& mt);
};
interface __declspec(uuid("DA395FA3-4A3E-4D85-805E-0BEFF53D4BCD"))
-IStreamSwitcherInputPin : public IUnknown
-{
+IStreamSwitcherInputPin :
+public IUnknown {
STDMETHOD_(bool, IsActive)() = 0;
};
@@ -141,15 +141,21 @@ class CStreamSwitcherInputPin : public CBaseInputPin, public IPinConnection, pub
HANDLE m_hNotifyEvent;
public:
- CStreamSwitcherInputPin(CStreamSwitcherFilter* pFilter, HRESULT* phr, LPCWSTR pName);
+ CStreamSwitcherInputPin(CStreamSwitcherFilter* pFilter, HRESULT* phr, LPCWSTR pName);
DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
- CMediaType& CurrentMediaType() {return m_mt;}
- IMemAllocator* CurrentAllocator() {return m_pAllocator;}
+ CMediaType& CurrentMediaType() {
+ return m_mt;
+ }
+ IMemAllocator* CurrentAllocator() {
+ return m_pAllocator;
+ }
- bool IsUsingOwnAllocator() {return m_bUsingOwnAllocator == TRUE;}
+ bool IsUsingOwnAllocator() {
+ return m_bUsingOwnAllocator == TRUE;
+ }
void Block(bool fBlock);
@@ -168,11 +174,11 @@ public:
STDMETHODIMP GetAllocator(IMemAllocator** ppAllocator);
STDMETHODIMP NotifyAllocator(IMemAllocator* pAllocator, BOOL bReadOnly);
STDMETHODIMP BeginFlush();
- STDMETHODIMP EndFlush();
+ STDMETHODIMP EndFlush();
STDMETHODIMP EndOfStream();
// IMemInputPin
- STDMETHODIMP Receive(IMediaSample* pSample);
+ STDMETHODIMP Receive(IMediaSample* pSample);
STDMETHODIMP NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
// IPinConnection
@@ -193,14 +199,20 @@ class CStreamSwitcherOutputPin : public CBaseOutputPin, public IStreamBuilder
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);
-
- CMediaType& CurrentMediaType() {return m_mt;}
- IMemAllocator* CurrentAllocator() {return m_pAllocator;}
- IPinConnection* CurrentPinConnection() {return m_pPinConnection;}
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+
+ CMediaType& CurrentMediaType() {
+ return m_mt;
+ }
+ IMemAllocator* CurrentAllocator() {
+ return m_pAllocator;
+ }
+ IPinConnection* CurrentPinConnection() {
+ return m_pPinConnection;
+ }
// pure virtual
HRESULT DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties);
@@ -246,7 +258,7 @@ public:
virtual ~CStreamSwitcherFilter();
DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
int GetPinCount();
CBasePin* GetPin(int n);
@@ -257,7 +269,9 @@ public:
CStreamSwitcherOutputPin* GetOutputPin();
bool m_fResetOutputMediaType;
- void ResetOutputMediaType() {m_fResetOutputMediaType = true;}
+ void ResetOutputMediaType() {
+ m_fResetOutputMediaType = true;
+ }
// override these
virtual HRESULT CheckMediaType(const CMediaType* pmt) = 0;
@@ -266,14 +280,14 @@ public:
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);
+ 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);
+ 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/switcher/AudioSwitcher/stdafx.cpp b/src/filters/switcher/AudioSwitcher/stdafx.cpp
index 13934d005..bea3f980a 100644
--- a/src/filters/switcher/AudioSwitcher/stdafx.cpp
+++ b/src/filters/switcher/AudioSwitcher/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/switcher/AudioSwitcher/stdafx.h b/src/filters/switcher/AudioSwitcher/stdafx.h
index 62d50a36b..d1c3768d8 100644
--- a/src/filters/switcher/AudioSwitcher/stdafx.h
+++ b/src/filters/switcher/AudioSwitcher/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/transform/AVI2AC3Filter/AVI2AC3Filter.cpp b/src/filters/transform/AVI2AC3Filter/AVI2AC3Filter.cpp
index 412e860c6..24394dd83 100644
--- a/src/filters/transform/AVI2AC3Filter/AVI2AC3Filter.cpp
+++ b/src/filters/transform/AVI2AC3Filter/AVI2AC3Filter.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -29,31 +29,26 @@
#ifdef REGISTER_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
{&MEDIATYPE_Audio, &MEDIASUBTYPE_WAVE_DOLBY_AC3},
{&MEDIATYPE_Audio, &MEDIASUBTYPE_WAVE_DTS},
};
-const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
{&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}
+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}
};
-const AMOVIESETUP_FILTER sudFilter[] =
-{
+const AMOVIESETUP_FILTER sudFilter[] = {
{&__uuidof(CAVI2AC3Filter), L"MPC - AVI<->AC3/DTS", MERIT_NORMAL, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory}
};
-CFactoryTemplate g_Templates[] =
-{
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CAVI2AC3Filter>, NULL, &sudFilter[0]}
+CFactoryTemplate g_Templates[] = {
+ {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CAVI2AC3Filter>, NULL, &sudFilter[0]}
};
int g_cTemplates = countof(g_Templates);
@@ -79,9 +74,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()
@@ -93,77 +90,76 @@ HRESULT CAVI2AC3Filter::Transform(IMediaSample* pSample, IMediaSample* pOutSampl
HRESULT hr;
BYTE* pIn = NULL;
- if(FAILED(hr = pSample->GetPointer(&pIn))) return hr;
+ if(FAILED(hr = pSample->GetPointer(&pIn))) {
+ return hr;
+ }
BYTE* pInOrg = pIn;
long len = pSample->GetActualDataLength();
- if(len <= 0) return S_FALSE;
+ if(len <= 0) {
+ return S_FALSE;
+ }
BYTE* pOut = NULL;
- if(FAILED(hr = pOutSample->GetPointer(&pOut))) return hr;
+ 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)
- {
+ && (CheckWAVEAC3(&m_pOutput->CurrentMediaType()) || CheckWAVEDTS(&m_pOutput->CurrentMediaType()))) {
+ if(*(DWORD*)pIn == 0xBA010000) {
pIn += 14;
}
- if(*(DWORD*)pIn == 0xBD010000)
- {
+ if(*(DWORD*)pIn == 0xBD010000) {
pIn += 8 + 1 + pIn[8] + 1 + 3;
}
len -= (pInOrg - pIn);
- if(size < len) return E_FAIL;
+ 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())))
- {
+ } 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
- {
+ || 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)
- {
+ while(pos < len) {
int curlen = min(len - pos, 2013);
pos += 2013;
CComPtr<IMediaSample> pOutSample;
hr = InitializeOutputSample(pSample, &pOutSample);
- if(fDiscontinuity)
- {
- if(fHasTime)
- {
+ if(fDiscontinuity) {
+ if(fHasTime) {
rtStop = rtStart + (rtStop - rtStart) * curlen / len;
pOutSample->SetTime(&rtStart, &rtStop);
}
fDiscontinuity = false;
- }
- else
- {
+ } else {
pOutSample->SetTime(NULL, NULL);
pOutSample->SetDiscontinuity(FALSE);
}
BYTE* pOut = NULL;
- if(FAILED(hr = pOutSample->GetPointer(&pOut))) return hr;
+ if(FAILED(hr = pOutSample->GetPointer(&pOut))) {
+ return hr;
+ }
BYTE* pOutOrg = pOut;
int size = pOutSample->GetSize();
@@ -171,12 +167,12 @@ HRESULT CAVI2AC3Filter::Transform(IMediaSample* pSample, IMediaSample* pOutSampl
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;
+ if(*majortype == MEDIATYPE_DVD_ENCRYPTED_PACK) {
+ if(size < curlen + 32 + 3) {
+ return E_FAIL;
+ }
- BYTE PESHeader[] =
- {
+ 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)
@@ -188,12 +184,12 @@ HRESULT CAVI2AC3Filter::Transform(IMediaSample* pSample, IMediaSample* pOutSampl
majortype = &MEDIATYPE_MPEG2_PES;
}
- if(*majortype == MEDIATYPE_MPEG2_PES)
- {
- if(size < curlen + 20 + 3) return E_FAIL;
+ if(*majortype == MEDIATYPE_MPEG2_PES) {
+ if(size < curlen + 20 + 3) {
+ return E_FAIL;
+ }
- BYTE Private1Header[] =
- {
+ BYTE Private1Header[] = {
0x00,0x00,0x01,0xBD, // private stream 1 id
0x07,0xEC, // packet length (TODO: modify it later)
0x81,0x80, // marker, original, PTS - flags
@@ -209,30 +205,22 @@ HRESULT CAVI2AC3Filter::Transform(IMediaSample* pSample, IMediaSample* pOutSampl
Private1Header[4] = (packetlen>>8)&0xff;
Private1Header[5] = packetlen&0xff;
- if(*subtype == MEDIASUBTYPE_DTS)
- {
+ if(*subtype == MEDIASUBTYPE_DTS) {
Private1Header[17] += 8;
}
- if(*subtype == MEDIASUBTYPE_DOLBY_AC3)
- {
- for(int i = 0; i < curlen; i++)
- {
- if(*(DWORD*)&pIn[i] == 0x770B)
- {
+ 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)
- {
+ } 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;
@@ -247,9 +235,10 @@ HRESULT CAVI2AC3Filter::Transform(IMediaSample* pSample, IMediaSample* pOutSampl
majortype = &MEDIATYPE_Audio;
}
- if(*majortype == MEDIATYPE_Audio)
- {
- if(size < curlen) return E_FAIL;
+ if(*majortype == MEDIATYPE_Audio) {
+ if(size < curlen) {
+ return E_FAIL;
+ }
memcpy(pOut, pIn, curlen);
pIn += curlen;
pOut += curlen;
@@ -261,18 +250,16 @@ HRESULT CAVI2AC3Filter::Transform(IMediaSample* pSample, IMediaSample* pOutSampl
}
return S_FALSE;
- }
- else // phew, we can do the easier way
- {
+ } 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;
+ if(*majortype == MEDIATYPE_DVD_ENCRYPTED_PACK) {
+ if(size < len + 32 + 3) {
+ return E_FAIL;
+ }
- BYTE PESHeader[] =
- {
+ 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)
@@ -284,12 +271,12 @@ HRESULT CAVI2AC3Filter::Transform(IMediaSample* pSample, IMediaSample* pOutSampl
majortype = &MEDIATYPE_MPEG2_PES;
}
- if(*majortype == MEDIATYPE_MPEG2_PES)
- {
- if(size < len + 20 + 3) return E_FAIL;
+ if(*majortype == MEDIATYPE_MPEG2_PES) {
+ if(size < len + 20 + 3) {
+ return E_FAIL;
+ }
- BYTE Private1Header[] =
- {
+ BYTE Private1Header[] = {
0x00,0x00,0x01,0xBD, // private stream 1 id
0x07,0xEC, // packet length (TODO: modify it later)
0x81,0x80, // marker, original, PTS - flags
@@ -305,8 +292,7 @@ HRESULT CAVI2AC3Filter::Transform(IMediaSample* pSample, IMediaSample* pOutSampl
Private1Header[4] = (packetlen>>8)&0xff;
Private1Header[5] = packetlen&0xff;
- if(*subtype == MEDIASUBTYPE_DTS)
- {
+ if(*subtype == MEDIASUBTYPE_DTS) {
Private1Header[17] += 8;
}
@@ -316,18 +302,17 @@ HRESULT CAVI2AC3Filter::Transform(IMediaSample* pSample, IMediaSample* pOutSampl
majortype = &MEDIATYPE_Audio;
}
- if(*majortype == MEDIATYPE_Audio)
- {
- if(size < len) return E_FAIL;
+ if(*majortype == MEDIATYPE_Audio) {
+ if(size < len) {
+ return E_FAIL;
+ }
memcpy(pOut, pIn, len);
pIn += len;
pOut += len;
}
}
- }
- else
- {
+ } else {
return E_FAIL;
}
@@ -339,33 +324,33 @@ HRESULT CAVI2AC3Filter::Transform(IMediaSample* pSample, IMediaSample* pOutSampl
bool CAVI2AC3Filter::CheckAC3(const CMediaType* pmt)
{
return (pmt->majortype == MEDIATYPE_Audio
- || pmt->majortype == MEDIATYPE_MPEG2_PES
+ || pmt->majortype == MEDIATYPE_MPEG2_PES
|| pmt->majortype == MEDIATYPE_DVD_ENCRYPTED_PACK)
- && pmt->subtype == MEDIASUBTYPE_DOLBY_AC3;
+ && pmt->subtype == MEDIASUBTYPE_DOLBY_AC3;
}
bool CAVI2AC3Filter::CheckDTS(const CMediaType* pmt)
{
return (pmt->majortype == MEDIATYPE_Audio
- || pmt->majortype == MEDIATYPE_MPEG2_PES
+ || pmt->majortype == MEDIATYPE_MPEG2_PES
|| pmt->majortype == MEDIATYPE_DVD_ENCRYPTED_PACK)
- && pmt->subtype == MEDIASUBTYPE_DTS;
+ && 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;
+ && 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;
+ && pmt->subtype == MEDIASUBTYPE_WAVE_DTS
+ && pmt->formattype == FORMAT_WaveFormatEx
+ && ((WAVEFORMATEX*)pmt->pbFormat)->wFormatTag == WAVE_FORMAT_DVD_DTS;
}
HRESULT CAVI2AC3Filter::CheckInputType(const CMediaType* mtIn)
@@ -373,28 +358,32 @@ HRESULT CAVI2AC3Filter::CheckInputType(const CMediaType* mtIn)
bool fWaveFormatEx = !!(mtIn->formattype == FORMAT_WaveFormatEx);
return CheckAC3(mtIn) && fWaveFormatEx || CheckDTS(mtIn) && fWaveFormatEx
- || CheckWAVEAC3(mtIn) || CheckWAVEDTS(mtIn)
- ? S_OK
- : VFW_E_TYPE_NOT_ACCEPTED;
+ || 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;
+ || 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;
+ if(m_pInput->IsConnected() == FALSE) {
+ return E_UNEXPECTED;
+ }
CComPtr<IMemAllocator> pAllocatorIn;
m_pInput->GetAllocator(&pAllocatorIn);
- if(!pAllocatorIn) return E_UNEXPECTED;
+ if(!pAllocatorIn) {
+ return E_UNEXPECTED;
+ }
pAllocatorIn->GetProperties(pProperties);
@@ -405,26 +394,32 @@ HRESULT CAVI2AC3Filter::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PR
HRESULT hr;
ALLOCATOR_PROPERTIES Actual;
- if(FAILED(hr = pAllocator->SetProperties(pProperties, &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 CAVI2AC3Filter::GetMediaType(int iPosition, CMediaType* pMediaType)
{
- if(m_pInput->IsConnected() == FALSE) return E_UNEXPECTED;
+ if(m_pInput->IsConnected() == FALSE) {
+ return E_UNEXPECTED;
+ }
const GUID& majortype = m_pInput->CurrentMediaType().majortype;
const GUID& subtype = m_pInput->CurrentMediaType().subtype;
UNUSED_ALWAYS(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;
+
+ 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;
@@ -438,44 +433,38 @@ HRESULT CAVI2AC3Filter::GetMediaType(int iPosition, CMediaType* pMediaType)
wfe->nChannels = 2;
wfe->nBlockAlign = 1;
- if(subtype == MEDIASUBTYPE_DOLBY_AC3)
- {
+ if(subtype == MEDIASUBTYPE_DOLBY_AC3) {
pMediaType->subtype = MEDIASUBTYPE_WAVE_DOLBY_AC3;
wfe->wFormatTag = WAVE_FORMAT_DOLBY_AC3;
- }
- else if(subtype == MEDIASUBTYPE_DTS)
- {
+ } else if(subtype == MEDIASUBTYPE_DTS) {
pMediaType->subtype = MEDIASUBTYPE_WAVE_DTS;
wfe->wFormatTag = WAVE_FORMAT_DVD_DTS;
+ } else {
+ return E_INVALIDARG;
}
- else
- {
+ } else if(CheckWAVEAC3(&m_pInput->CurrentMediaType()) || CheckWAVEDTS(&m_pInput->CurrentMediaType())) {
+ if(iPosition < 0) {
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(iPosition > 4) {
+ return VFW_S_NO_MORE_ITEMS;
+ }
- if(subtype == MEDIASUBTYPE_WAVE_DOLBY_AC3)
- {
+ 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
+ // 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)
- {
+ } else if(subtype == MEDIASUBTYPE_WAVE_DTS) {
pMediaType->subtype = MEDIASUBTYPE_DTS;
pMediaType->formattype = FORMAT_WaveFormatEx;
@@ -486,35 +475,30 @@ HRESULT CAVI2AC3Filter::GetMediaType(int iPosition, CMediaType* pMediaType)
wfe->wFormatTag = WAVE_FORMAT_PCM;
wfe->nSamplesPerSec = 48000;
wfe->nChannels = 6;
- }
- else
- {
+ } 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;
+ 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
- {
+ } else {
return VFW_S_NO_MORE_ITEMS;
}
diff --git a/src/filters/transform/AVI2AC3Filter/AVI2AC3Filter.h b/src/filters/transform/AVI2AC3Filter/AVI2AC3Filter.h
index c199bfa90..f178ef616 100644
--- a/src/filters/transform/AVI2AC3Filter/AVI2AC3Filter.h
+++ b/src/filters/transform/AVI2AC3Filter/AVI2AC3Filter.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -32,14 +32,13 @@
*/
-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
+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
} DOLBYAC3WAVEFORMAT;
//
@@ -47,7 +46,7 @@ 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);
diff --git a/src/filters/transform/AVI2AC3Filter/stdafx.cpp b/src/filters/transform/AVI2AC3Filter/stdafx.cpp
index 2d8565418..9508867df 100644
--- a/src/filters/transform/AVI2AC3Filter/stdafx.cpp
+++ b/src/filters/transform/AVI2AC3Filter/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/transform/AVI2AC3Filter/stdafx.h b/src/filters/transform/AVI2AC3Filter/stdafx.h
index 62d50a36b..d1c3768d8 100644
--- a/src/filters/transform/AVI2AC3Filter/stdafx.h
+++ b/src/filters/transform/AVI2AC3Filter/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/transform/BaseVideoFilter/BaseVideoFilter.cpp b/src/filters/transform/BaseVideoFilter/BaseVideoFilter.cpp
index a75457d82..e4d902bac 100644
--- a/src/filters/transform/BaseVideoFilter/BaseVideoFilter.cpp
+++ b/src/filters/transform/BaseVideoFilter/BaseVideoFilter.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -33,19 +33,30 @@
//
bool f_need_set_aspect;
-CBaseVideoFilter::CBaseVideoFilter(TCHAR* pName, LPUNKNOWN lpunk, HRESULT* phr, REFCLSID clsid, long cBuffers)
+CBaseVideoFilter::CBaseVideoFilter(TCHAR* pName, LPUNKNOWN lpunk, HRESULT* phr, REFCLSID clsid, long cBuffers)
: CTransformFilter(pName, lpunk, clsid)
, m_cBuffers(cBuffers)
{
- if(phr) *phr = S_OK;
+ 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;
+ 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;}
+ 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;
@@ -73,10 +84,11 @@ int CBaseVideoFilter::GetPinCount()
CBasePin* CBaseVideoFilter::GetPin(int n)
{
- switch(n)
- {
- case 0: return m_pInput;
- case 1: return m_pOutput;
+ switch(n) {
+ case 0:
+ return m_pInput;
+ case 1:
+ return m_pOutput;
}
return NULL;
}
@@ -92,20 +104,21 @@ HRESULT CBaseVideoFilter::Receive(IMediaSample* pIn)
HRESULT hr;
- AM_SAMPLE2_PROPERTIES* const pProps = m_pInput->SampleProps();
- if(pProps->dwStreamId != AM_STREAM_MEDIA)
+ 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)
- {
+ if(SUCCEEDED(pIn->GetMediaType(&pmt)) && pmt) {
CMediaType mt(*pmt);
m_pInput->SetMediaType(&mt);
DeleteMediaType(pmt);
}
- if(FAILED(hr = Transform(pIn)))
+ if(FAILED(hr = Transform(pIn))) {
return hr;
+ }
return S_OK;
}
@@ -116,15 +129,16 @@ HRESULT CBaseVideoFilter::GetDeliveryBuffer(int w, int h, IMediaSample** ppOut)
HRESULT hr;
- if(FAILED(hr = ReconnectOutput(w, h)))
+ if(FAILED(hr = ReconnectOutput(w, h))) {
return hr;
+ }
- if(FAILED(hr = m_pOutput->GetDeliveryBuffer(ppOut, NULL, NULL, 0)))
+ if(FAILED(hr = m_pOutput->GetDeliveryBuffer(ppOut, NULL, NULL, 0))) {
return hr;
+ }
AM_MEDIA_TYPE* pmt;
- if(SUCCEEDED((*ppOut)->GetMediaType(&pmt)) && pmt)
- {
+ if(SUCCEEDED((*ppOut)->GetMediaType(&pmt)) && pmt) {
CMediaType mt = *pmt;
m_pOutput->SetMediaType(&mt);
DeleteMediaType(pmt);
@@ -135,8 +149,9 @@ HRESULT CBaseVideoFilter::GetDeliveryBuffer(int w, int h, IMediaSample** ppOut)
// 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)
+ if(GetCLSID(m_pOutput->GetConnected()) == CLSID_OverlayMixer) {
(*ppOut)->SetDiscontinuity(TRUE);
+ }
return S_OK;
}
@@ -146,12 +161,10 @@ HRESULT CBaseVideoFilter::ReconnectOutput(int w, int h, bool bSendSample, int re
CMediaType& mt = m_pOutput->CurrentMediaType();
bool m_update_aspect = false;
- if(f_need_set_aspect)
- {
+ 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)
- {
+ if(arxout != m_arx || aryout != m_ary) {
CString debug_s;
debug_s.Format(_T("\nCBaseVideoFilter::ReconnectOutput; wout = %d, hout = %d, current = %dx%d, set = %dx%d\n"), wout, hout, arxout, aryout, m_arx, m_ary);
TRACE(debug_s);
@@ -163,8 +176,7 @@ HRESULT CBaseVideoFilter::ReconnectOutput(int w, int h, bool bSendSample, int re
int h_org = m_h;
bool fForceReconnection = false;
- if(w != m_w || h != m_h)
- {
+ if(w != m_w || h != m_h) {
fForceReconnection = true;
m_w = w;
m_h = h;
@@ -172,52 +184,39 @@ HRESULT CBaseVideoFilter::ReconnectOutput(int w, int h, bool bSendSample, int re
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)
- {
+ 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)
- {
+ if(mt.formattype == FORMAT_VideoInfo) {
VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)mt.Format();
- if (realWidth != -1 && realHeight != -1)
- {
+ if (realWidth != -1 && realHeight != -1) {
SetRect(&vih->rcSource, 0, 0, realWidth, realHeight);
SetRect(&vih->rcTarget, 0, 0, realWidth, realHeight);
- }
- else
- {
+ } 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)
- {
+ } else if(mt.formattype == FORMAT_VideoInfo2) {
VIDEOINFOHEADER2* vih = (VIDEOINFOHEADER2*)mt.Format();
- if (realWidth != -1 && realHeight != -1)
- {
+ if (realWidth != -1 && realHeight != -1) {
SetRect(&vih->rcSource, 0, 0, realWidth, realHeight);
SetRect(&vih->rcTarget, 0, 0, realWidth, realHeight);
- }
- else
- {
+ } 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
- {
+ } else {
return E_FAIL; //should never be here? prevent null pointer refs for bmi
}
@@ -229,27 +228,19 @@ HRESULT CBaseVideoFilter::ReconnectOutput(int w, int h, bool bSendSample, int re
ASSERT(SUCCEEDED(hr)); // should better not fail, after all "mt" is the current media type, just with a different resolution
HRESULT hr1 = 0, hr2 = 0;
CComPtr<IMediaSample> pOut;
- if(SUCCEEDED(hr1 = m_pOutput->GetConnected()->ReceiveConnection(m_pOutput, &mt)))
- {
- if (bSendSample)
- {
- if (SUCCEEDED(hr2 = m_pOutput->GetDeliveryBuffer(&pOut, NULL, NULL, 0)))
- {
+ if(SUCCEEDED(hr1 = m_pOutput->GetConnected()->ReceiveConnection(m_pOutput, &mt))) {
+ if (bSendSample) {
+ if (SUCCEEDED(hr2 = m_pOutput->GetDeliveryBuffer(&pOut, NULL, NULL, 0))) {
AM_MEDIA_TYPE* pmt;
- if(SUCCEEDED(pOut->GetMediaType(&pmt)) && 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...
- {
+ } else { // stupid overlay mixer won't let us know the new pitch...
long size = pOut->GetSize();
bmi->biWidth = size / bmi->biHeight * 8 / bmi->biBitCount;
}
- }
- else
- {
+ } else {
m_w = w_org;
m_h = h_org;
return E_FAIL;
@@ -285,20 +276,19 @@ HRESULT CBaseVideoFilter::CopyBuffer(BYTE* pOut, BYTE** ppIn, int w, int h, int
int pitchOut = 0;
- if(bihOut.biCompression == BI_RGB || bihOut.biCompression == BI_BITFIELDS)
- {
+ if(bihOut.biCompression == BI_RGB || bihOut.biCompression == BI_BITFIELDS) {
pitchOut = bihOut.biWidth*bihOut.biBitCount>>3;
- if(bihOut.biHeight > 0)
- {
+ if(bihOut.biHeight > 0) {
pOut += pitchOut*(h-1);
pitchOut = -pitchOut;
- if(h < 0) h = -h;
+ if(h < 0) {
+ h = -h;
+ }
}
}
- if(h < 0)
- {
+ if(h < 0) {
h = -h;
ppIn[0] += pitchIn*(h-1);
ppIn[1] += (pitchIn>>1)*((h>>1)-1);
@@ -306,79 +296,70 @@ HRESULT CBaseVideoFilter::CopyBuffer(BYTE* pOut, BYTE** ppIn, int w, int h, int
pitchIn = -pitchIn;
}
- if(subtype == MEDIASUBTYPE_I420 || subtype == MEDIASUBTYPE_IYUV || subtype == MEDIASUBTYPE_YV12)
- {
+ 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;}
+ 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;}
+ if(bihOut.biCompression == '21VY') {
+ BYTE* tmp = pOutU;
+ pOutU = pOutV;
+ pOutV = tmp;
+ }
ASSERT(w <= abs(pitchIn));
- if(bihOut.biCompression == '2YUY')
- {
- if (!fInterlaced)
+ if(bihOut.biCompression == '2YUY') {
+ if (!fInterlaced) {
BitBltFromI420ToYUY2(w, h, pOut, bihOut.biWidth*2, pIn, pInU, pInV, pitchIn);
- else
+ } else {
BitBltFromI420ToYUY2Interlaced(w, h, pOut, bihOut.biWidth*2, pIn, pInU, pInV, pitchIn);
- }
- else if(bihOut.biCompression == '024I' || bihOut.biCompression == 'VUYI' || bihOut.biCompression == '21VY')
- {
+ }
+ } 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(DWORD y = 0; y < h; y++, pOut += pitchOut)
+ } else if(bihOut.biCompression == BI_RGB || bihOut.biCompression == BI_BITFIELDS) {
+ if(!BitBltFromI420ToRGB(w, h, pOut, pitchOut, bihOut.biBitCount, pIn, pInU, pInV, pitchIn)) {
+ for(DWORD y = 0; y < h; y++, pOut += pitchOut) {
memset(pOut, 0, pitchOut);
+ }
}
}
- }
- else if(subtype == MEDIASUBTYPE_YUY2)
- {
- if(bihOut.biCompression == '2YUY')
- {
+ } 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(DWORD y = 0; y < h; y++, pOut += pitchOut)
+ } else if(bihOut.biCompression == BI_RGB || bihOut.biCompression == BI_BITFIELDS) {
+ if(!BitBltFromYUY2ToRGB(w, h, pOut, pitchOut, bihOut.biBitCount, ppIn[0], pitchIn)) {
+ for(DWORD 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 =
+ } 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')
- {
+ 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(DWORD y = 0; y < h; y++, pOut += pitchOut)
+ } else if(bihOut.biCompression == BI_RGB || bihOut.biCompression == BI_BITFIELDS) {
+ if(!BitBltFromRGBToRGB(w, h, pOut, pitchOut, bihOut.biBitCount, ppIn[0], pitchIn, sbpp)) {
+ for(DWORD y = 0; y < h; y++, pOut += pitchOut) {
memset(pOut, 0, pitchOut);
+ }
}
}
- }
- else
- {
+ } else {
return VFW_E_TYPE_NOT_ACCEPTED;
}
@@ -390,63 +371,62 @@ 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;
+ 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)
+ 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(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)
+ && 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))
- {
+ }
+ } 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)
+ && 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))
- {
+ }
+ } 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)
+ && mtOut->subtype != MEDIASUBTYPE_RGB32
+ && mtOut->subtype != MEDIASUBTYPE_RGB24
+ && mtOut->subtype != MEDIASUBTYPE_RGB565) {
return VFW_E_TYPE_NOT_ACCEPTED;
+ }
}
return S_OK;
@@ -456,15 +436,17 @@ 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;
+ && 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;
+ if(m_pInput->IsConnected() == FALSE) {
+ return E_UNEXPECTED;
+ }
BITMAPINFOHEADER bih;
ExtractBIH(&m_pOutput->CurrentMediaType(), &bih);
@@ -479,17 +461,17 @@ HRESULT CBaseVideoFilter::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_
HRESULT hr;
ALLOCATOR_PROPERTIES Actual;
- if(FAILED(hr = pAllocator->SetProperties(pProperties, &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;
}
-VIDEO_OUTPUT_FORMATS DefaultFormats[] =
-{
+VIDEO_OUTPUT_FORMATS DefaultFormats[] = {
{&MEDIASUBTYPE_YV12, 3, 12, '21VY'},
{&MEDIASUBTYPE_I420, 3, 12, '024I'},
{&MEDIASUBTYPE_IYUV, 3, 12, 'VUYI'},
@@ -518,7 +500,9 @@ HRESULT CBaseVideoFilter::GetMediaType(int iPosition, CMediaType* pmt)
VIDEO_OUTPUT_FORMATS* fmts;
int nFormatCount;
- if(m_pInput->IsConnected() == FALSE) return E_UNEXPECTED;
+ if(m_pInput->IsConnected() == FALSE) {
+ return E_UNEXPECTED;
+ }
// this will make sure we won't connect to the old renderer in dvd mode
@@ -527,16 +511,22 @@ HRESULT CBaseVideoFilter::GetMediaType(int iPosition, CMediaType* pmt)
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;
+ for(; !fFoundDVDNavigator && (pBF = GetUpStreamFilter(pBF, pPin)); pPin = GetFirstPin(pBF)) {
+ fFoundDVDNavigator = GetCLSID(pBF) == CLSID_DVDNavigator;
+ }
- if(fFoundDVDNavigator || m_pInput->CurrentMediaType().formattype == FORMAT_VideoInfo2)
+ 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;
+ 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;
@@ -556,24 +546,23 @@ HRESULT CBaseVideoFilter::GetMediaType(int iPosition, CMediaType* pmt)
bihOut.biCompression = fmts[iPosition/2].biCompression;
bihOut.biSizeImage = w*h*bihOut.biBitCount>>3;
- if(iPosition&1)
- {
+ 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
- {
+ } 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;
+ if(IsVideoInterlaced()) {
+ vih->dwInterlaceFlags = AMINTERLACE_IsInterlaced | AMINTERLACE_DisplayModeBobOrWeave;
+ }
}
CMediaType& mt = m_pInput->CurrentMediaType();
@@ -590,29 +579,27 @@ HRESULT CBaseVideoFilter::GetMediaType(int iPosition, CMediaType* pmt)
VIDEOINFOHEADER* vih = (VIDEOINFOHEADER*)pmt->Format();
VIDEOINFOHEADER* vihInput = (VIDEOINFOHEADER*)pmtInput.Format();
- if (vih && vihInput && (vihInput->rcSource.right != 0) && (vihInput->rcSource.bottom != 0))
- {
+ if (vih && vihInput && (vihInput->rcSource.right != 0) && (vihInput->rcSource.bottom != 0)) {
vih->rcSource = vihInput->rcSource;
vih->rcTarget = vihInput->rcTarget;
- }
- else
- {
+ } else {
vih->rcSource.right = vih->rcTarget.right = m_win;
vih->rcSource.bottom = vih->rcTarget.bottom = m_hin;
}
- if (RealWidth != -1 && vih->rcSource.right > RealWidth)
+ if (RealWidth != -1 && vih->rcSource.right > RealWidth) {
vih->rcSource.right = RealWidth;
- if (RealHeight != -1 && vih->rcSource.bottom > RealHeight)
+ }
+ if (RealHeight != -1 && vih->rcSource.bottom > RealHeight) {
vih->rcSource.bottom = RealHeight;
+ }
return S_OK;
}
HRESULT CBaseVideoFilter::SetMediaType(PIN_DIRECTION dir, const CMediaType* pmt)
{
- if(dir == PINDIR_INPUT)
- {
+ 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;
@@ -629,14 +616,13 @@ HRESULT CBaseVideoFilter::SetMediaType(PIN_DIRECTION dir, const CMediaType* pmt)
a = b % tmp;
b = tmp;
}
- if(b) m_arx /= b, m_ary /= b;
- }
- else if(dir == PINDIR_OUTPUT)
- {
+ 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)
- {
+ if(m_w == wout && m_h == hout && m_arx == arxout && m_ary == aryout) {
m_wout = wout;
m_hout = hout;
m_arxout = arxout;
@@ -650,11 +636,13 @@ HRESULT CBaseVideoFilter::SetMediaType(PIN_DIRECTION dir, const CMediaType* pmt)
//
// CBaseVideoInputAllocator
//
-
+
CBaseVideoInputAllocator::CBaseVideoInputAllocator(HRESULT* phr)
: CMemAllocator(NAME("CBaseVideoInputAllocator"), NULL, phr)
{
- if(phr) *phr = S_OK;
+ if(phr) {
+ *phr = S_OK;
+ }
}
void CBaseVideoInputAllocator::SetMediaType(const CMediaType& mt)
@@ -664,13 +652,13 @@ void CBaseVideoInputAllocator::SetMediaType(const CMediaType& 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);
- if(SUCCEEDED(hr) && m_mt.majortype != GUID_NULL)
- {
+ if(SUCCEEDED(hr) && m_mt.majortype != GUID_NULL) {
(*ppBuffer)->SetMediaType(&m_mt);
m_mt.majortype = GUID_NULL;
}
@@ -682,7 +670,7 @@ STDMETHODIMP CBaseVideoInputAllocator::GetBuffer(IMediaSample** ppBuffer, REFERE
// CBaseVideoInputPin
//
-CBaseVideoInputPin::CBaseVideoInputPin(TCHAR* pObjectName, CBaseVideoFilter* pFilter, HRESULT* phr, LPCWSTR pName)
+CBaseVideoInputPin::CBaseVideoInputPin(TCHAR* pObjectName, CBaseVideoFilter* pFilter, HRESULT* phr, LPCWSTR pName)
: CTransformInputPin(pObjectName, pFilter, phr, pName)
, m_pAllocator(NULL)
{
@@ -695,54 +683,57 @@ CBaseVideoInputPin::~CBaseVideoInputPin()
STDMETHODIMP CBaseVideoInputPin::GetAllocator(IMemAllocator** ppAllocator)
{
- CheckPointer(ppAllocator, E_POINTER);
+ CheckPointer(ppAllocator, E_POINTER);
- if(m_pAllocator == NULL)
- {
+ if(m_pAllocator == NULL) {
HRESULT hr = S_OK;
- m_pAllocator = DNew CBaseVideoInputAllocator(&hr);
- m_pAllocator->AddRef();
- }
+ 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);
- if(m_Connected)
- {
+ if(m_Connected) {
CMediaType mt(*pmt);
- if(FAILED(CheckMediaType(&mt)))
+ if(FAILED(CheckMediaType(&mt))) {
return VFW_E_TYPE_NOT_ACCEPTED;
+ }
ALLOCATOR_PROPERTIES props, actual;
CComPtr<IMemAllocator> pMemAllocator;
if(FAILED(GetAllocator(&pMemAllocator))
- || FAILED(pMemAllocator->Decommit())
- || FAILED(pMemAllocator->GetProperties(&props)))
+ || FAILED(pMemAllocator->Decommit())
+ || FAILED(pMemAllocator->GetProperties(&props))) {
return E_FAIL;
+ }
BITMAPINFOHEADER bih;
- if(ExtractBIH(pmt, &bih) && bih.biSizeImage)
+ if(ExtractBIH(pmt, &bih) && bih.biSizeImage) {
props.cbBuffer = bih.biSizeImage;
+ }
if(FAILED(pMemAllocator->SetProperties(&props, &actual))
- || FAILED(pMemAllocator->Commit())
- || props.cbBuffer != actual.cbBuffer)
+ || FAILED(pMemAllocator->Commit())
+ || props.cbBuffer != actual.cbBuffer) {
return E_FAIL;
+ }
- if(m_pAllocator)
+ if(m_pAllocator) {
m_pAllocator->SetMediaType(mt);
+ }
return SetMediaType(&mt) == S_OK
- ? S_OK
- : VFW_E_TYPE_NOT_ACCEPTED;
+ ? S_OK
+ : VFW_E_TYPE_NOT_ACCEPTED;
}
return __super::ReceiveConnection(pConnector, pmt);
@@ -759,10 +750,11 @@ CBaseVideoOutputPin::CBaseVideoOutputPin(TCHAR* pObjectName, CBaseVideoFilter* p
HRESULT CBaseVideoOutputPin::CheckMediaType(const CMediaType* mtOut)
{
- if(IsConnected())
- {
+ if(IsConnected()) {
HRESULT hr = (static_cast<CBaseVideoFilter*>(m_pFilter))->CheckOutputType(*mtOut);
- if(FAILED(hr)) return hr;
+ 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 37ffdc049..cc5eccbb2 100644
--- a/src/filters/transform/BaseVideoFilter/BaseVideoFilter.h
+++ b/src/filters/transform/BaseVideoFilter/BaseVideoFilter.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -22,8 +22,7 @@
#pragma once
-typedef struct
-{
+typedef struct {
const GUID* subtype;
WORD biPlanes;
WORD biBitCount;
@@ -33,7 +32,7 @@ typedef struct
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;
@@ -52,7 +51,9 @@ protected:
virtual void GetOutputSize(int& w, int& h, int& arx, int& ary, int &RealWidth, int &RealHeight) {}
virtual HRESULT Transform(IMediaSample* pIn) = 0;
- virtual bool IsVideoInterlaced() {return false;}
+ virtual bool IsVideoInterlaced() {
+ return false;
+ }
virtual void GetOutputFormats (int& nNumber, VIDEO_OUTPUT_FORMATS** ppFormats);
public:
@@ -63,11 +64,11 @@ public:
int GetPinCount();
CBasePin* GetPin(int n);
- HRESULT CheckInputType(const CMediaType* mtIn);
+ 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 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);
@@ -100,5 +101,5 @@ class CBaseVideoOutputPin : public CTransformOutputPin
public:
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/BaseVideoFilter/stdafx.cpp b/src/filters/transform/BaseVideoFilter/stdafx.cpp
index 13934d005..bea3f980a 100644
--- a/src/filters/transform/BaseVideoFilter/stdafx.cpp
+++ b/src/filters/transform/BaseVideoFilter/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/transform/BaseVideoFilter/stdafx.h b/src/filters/transform/BaseVideoFilter/stdafx.h
index e0d4538b1..79bb9cc0d 100644
--- a/src/filters/transform/BaseVideoFilter/stdafx.h
+++ b/src/filters/transform/BaseVideoFilter/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/transform/BufferFilter/BufferFilter.cpp b/src/filters/transform/BufferFilter/BufferFilter.cpp
index e79e3b2a8..51f021b8a 100644
--- a/src/filters/transform/BufferFilter/BufferFilter.cpp
+++ b/src/filters/transform/BufferFilter/BufferFilter.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -25,29 +25,24 @@
#ifdef REGISTER_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
{&MEDIATYPE_NULL, &MEDIASUBTYPE_NULL},
};
-const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
{&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}
+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}
};
-const AMOVIESETUP_FILTER sudFilter[] =
-{
+const AMOVIESETUP_FILTER sudFilter[] = {
{&__uuidof(CBufferFilter), L"MPC - Buffer Filter", MERIT_DO_NOT_USE, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory}
};
-CFactoryTemplate g_Templates[] =
-{
+CFactoryTemplate g_Templates[] = {
{sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CBufferFilter>, NULL, &sudFilter[0]}
};
@@ -73,25 +68,34 @@ CFilterApp theApp;
// CBufferFilter
//
-CBufferFilter::CBufferFilter(LPUNKNOWN lpunk, HRESULT* phr)
+CBufferFilter::CBufferFilter(LPUNKNOWN lpunk, HRESULT* phr)
: CTransformFilter(NAME("CBufferFilter"), lpunk, __uuidof(this))
, m_nSamplesToBuffer(2)
{
HRESULT hr = S_OK;
- do
- {
+ do {
m_pInput = DNew CTransformInputPin(NAME("Transform input pin"), this, &hr, L"In");
- if(!m_pInput) hr = E_OUTOFMEMORY;
- if(FAILED(hr)) break;
+ 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(!m_pOutput) {
+ hr = E_OUTOFMEMORY;
+ }
+ if(FAILED(hr)) {
+ delete m_pInput, m_pInput = NULL;
+ break;
+ }
+ } while(false);
- if(phr) *phr = hr;
+ if(phr) {
+ *phr = hr;
+ }
}
CBufferFilter::~CBufferFilter()
@@ -109,11 +113,13 @@ STDMETHODIMP CBufferFilter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
STDMETHODIMP CBufferFilter::SetBuffers(int nBuffers)
{
- if(!m_pOutput)
+ if(!m_pOutput) {
return E_FAIL;
+ }
- if(m_pOutput->IsConnected()) // TODO: allow "on-the-fly" changes
+ if(m_pOutput->IsConnected()) { // TODO: allow "on-the-fly" changes
return VFW_E_ALREADY_CONNECTED;
+ }
m_nSamplesToBuffer = nBuffers;
@@ -143,8 +149,9 @@ 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)
+ if(pProps->dwStreamId != AM_STREAM_MEDIA) {
return m_pOutput->Deliver(pSample);
+ }
HRESULT hr;
ASSERT(pSample);
@@ -155,8 +162,9 @@ HRESULT CBufferFilter::Receive(IMediaSample* pSample)
// Set up the output sample
hr = InitializeOutputSample(pSample, &pOutSample);
- if(FAILED(hr))
+ if(FAILED(hr)) {
return hr;
+ }
// Start timing the transform (if PERF is defined)
MSR_START(m_idTransform);
@@ -170,16 +178,14 @@ HRESULT CBufferFilter::Receive(IMediaSample* pSample)
if(FAILED(hr)) {
DbgLog((LOG_TRACE,1,TEXT("Error from transform")));
- }
- else {
+ } 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 {
+ } 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
@@ -218,10 +224,12 @@ HRESULT CBufferFilter::Transform(IMediaSample* pIn, IMediaSample* pOut)
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));
-
+
pOut->SetActualDataLength(min(len, size));
return S_OK;
@@ -239,11 +247,15 @@ HRESULT CBufferFilter::CheckTransform(const CMediaType* mtIn, const CMediaType*
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;
+ if(!pAllocatorIn) {
+ return E_UNEXPECTED;
+ }
pAllocatorIn->GetProperties(pProperties);
@@ -251,21 +263,28 @@ HRESULT CBufferFilter::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PRO
HRESULT hr;
ALLOCATOR_PROPERTIES Actual;
- if(FAILED(hr = pAllocator->SetProperties(pProperties, &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;
+ if(iPosition < 0) {
+ return E_INVALIDARG;
+ }
+ if(iPosition > 0) {
+ return VFW_S_NO_MORE_ITEMS;
+ }
CopyMediaType(pMediaType, &m_pInput->CurrentMediaType());
@@ -275,10 +294,10 @@ HRESULT CBufferFilter::GetMediaType(int iPosition, CMediaType* pMediaType)
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)
+ if(m_pInput && pPin && pPin->m_pOutputQueue) {
+ while(!m_pInput->IsFlushing() && pPin->m_pOutputQueue->GetQueueCount() > 0) {
Sleep(50);
+ }
}
return __super::StopStreaming();
@@ -297,15 +316,15 @@ HRESULT CBufferFilterOutputPin::Active()
{
CAutoLock lock_it(m_pLock);
- if(m_Connected && !m_pOutputQueue)
- {
+ if(m_Connected && !m_pOutputQueue) {
HRESULT hr = NOERROR;
m_pOutputQueue.Attach(DNew CBufferFilterOutputQueue(m_Connected, &hr));
- if(!m_pOutputQueue) hr = E_OUTOFMEMORY;
+ if(!m_pOutputQueue) {
+ hr = E_OUTOFMEMORY;
+ }
- if(FAILED(hr))
- {
+ if(FAILED(hr)) {
m_pOutputQueue.Free();
return hr;
}
@@ -323,7 +342,9 @@ HRESULT CBufferFilterOutputPin::Inactive()
HRESULT CBufferFilterOutputPin::Deliver(IMediaSample* pMediaSample)
{
- if(!m_pOutputQueue) return NOERROR;
+ if(!m_pOutputQueue) {
+ return NOERROR;
+ }
pMediaSample->AddRef();
return m_pOutputQueue->Receive(pMediaSample);
}
@@ -332,7 +353,7 @@ HRESULT CBufferFilterOutputPin::Deliver(IMediaSample* pMediaSample)
if(!m_pOutputQueue) return NOERROR; \
m_pOutputQueue->##call; \
return NOERROR; \
-
+
HRESULT CBufferFilterOutputPin::DeliverEndOfStream()
{
CallQueue(EOS());
diff --git a/src/filters/transform/BufferFilter/BufferFilter.h b/src/filters/transform/BufferFilter/BufferFilter.h
index 7bba2767f..f95bb02bb 100644
--- a/src/filters/transform/BufferFilter/BufferFilter.h
+++ b/src/filters/transform/BufferFilter/BufferFilter.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -24,8 +24,8 @@
#include <atlbase.h>
interface __declspec(uuid("63EF0035-3FFE-4c41-9230-4346E028BE20"))
-IBufferFilter : public IUnknown
-{
+IBufferFilter :
+public IUnknown {
STDMETHOD(SetBuffers) (int nBuffers) = 0;
STDMETHOD_(int, GetBuffers) () = 0;
STDMETHOD_(int, GetFreeBuffers) () = 0;
@@ -33,7 +33,7 @@ IBufferFilter : public IUnknown
};
class __declspec(uuid("DA2B3D77-2F29-4fd2-AC99-DEE4A8A13BF0"))
-CBufferFilter : public CTransformFilter, public IBufferFilter
+ CBufferFilter : public CTransformFilter, public IBufferFilter
{
int m_nSamplesToBuffer;
@@ -42,7 +42,7 @@ public:
virtual ~CBufferFilter();
DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
// IBufferFilter
STDMETHODIMP SetBuffers(int nBuffers);
@@ -52,10 +52,10 @@ public:
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 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();
};
@@ -65,22 +65,19 @@ class CBufferFilterOutputPin : public CTransformOutputPin
{
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)
- {
+ 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()
- {
+ int GetQueueCount() {
return m_List ? m_List->GetCount() : -1;
}
- bool SetPriority(DWORD dwPriority)
- {
+ bool SetPriority(DWORD dwPriority) {
return m_hThread ? !!::SetThreadPriority(m_hThread, dwPriority) : false;
}
};
@@ -91,11 +88,11 @@ public:
CAutoPtr<CBufferFilterOutputQueue> m_pOutputQueue;
HRESULT Active();
- HRESULT Inactive();
+ HRESULT Inactive();
HRESULT Deliver(IMediaSample* pMediaSample);
- HRESULT DeliverEndOfStream();
- HRESULT DeliverBeginFlush();
+ HRESULT DeliverEndOfStream();
+ HRESULT DeliverBeginFlush();
HRESULT DeliverEndFlush();
- HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
+ HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
};
diff --git a/src/filters/transform/BufferFilter/stdafx.cpp b/src/filters/transform/BufferFilter/stdafx.cpp
index 13934d005..bea3f980a 100644
--- a/src/filters/transform/BufferFilter/stdafx.cpp
+++ b/src/filters/transform/BufferFilter/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/transform/BufferFilter/stdafx.h b/src/filters/transform/BufferFilter/stdafx.h
index 62d50a36b..d1c3768d8 100644
--- a/src/filters/transform/BufferFilter/stdafx.h
+++ b/src/filters/transform/BufferFilter/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/transform/DeCSSFilter/DeCSSFilter.cpp b/src/filters/transform/DeCSSFilter/DeCSSFilter.cpp
index 0ee407ed1..511d32613 100644
--- a/src/filters/transform/DeCSSFilter/DeCSSFilter.cpp
+++ b/src/filters/transform/DeCSSFilter/DeCSSFilter.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -27,31 +27,26 @@
#ifdef REGISTER_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
{&MEDIATYPE_DVD_ENCRYPTED_PACK, &MEDIASUBTYPE_NULL},
};
-const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
{&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}
+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}
};
-const AMOVIESETUP_FILTER sudFilter[] =
-{
+const AMOVIESETUP_FILTER sudFilter[] = {
{&__uuidof(CDeCSSFilter), L"MPC - DeCSSFilter", MERIT_DO_NOT_USE, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
};
-CFactoryTemplate g_Templates[] =
-{
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CDeCSSFilter>, NULL, &sudFilter[0]},
+CFactoryTemplate g_Templates[] = {
+ {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CDeCSSFilter>, NULL, &sudFilter[0]},
};
int g_cTemplates = countof(g_Templates);
@@ -79,44 +74,54 @@ CFilterApp theApp;
class CKsPSInputPin : public CDeCSSInputPin
{
public:
- CKsPSInputPin(TCHAR* pObjectName, CTransformFilter* pFilter, HRESULT* phr, LPWSTR pName)
- : CDeCSSInputPin(pObjectName, pFilter, phr, pName)
- {
+ 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())
+ 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())
+ 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())
+ 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)
+CDeCSSFilter::CDeCSSFilter(LPUNKNOWN lpunk, HRESULT* phr)
: CTransformFilter(NAME("CDeCSSFilter"), lpunk, __uuidof(this))
{
- if(phr) *phr = S_OK;
+ 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;
+ 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(!m_pOutput) {
+ *phr = E_OUTOFMEMORY;
+ }
+ if(FAILED(*phr)) {
+ delete m_pInput, m_pInput = NULL;
+ return;
+ }
}
CDeCSSFilter::~CDeCSSFilter()
@@ -126,8 +131,7 @@ CDeCSSFilter::~CDeCSSFilter()
HRESULT CDeCSSFilter::Transform(IMediaSample* pIn, IMediaSample* pOut)
{
AM_MEDIA_TYPE* pmt;
- if(SUCCEEDED(pIn->GetMediaType(&pmt)) && pmt)
- {
+ if(SUCCEEDED(pIn->GetMediaType(&pmt)) && pmt) {
CMediaType mt = *pmt;
m_pInput->SetMediaType(&mt);
mt.majortype = m_pOutput->CurrentMediaType().majortype;
@@ -145,30 +149,38 @@ HRESULT CDeCSSFilter::Transform(IMediaSample* pIn, IMediaSample* pOut)
long len = pIn->GetActualDataLength();
long size = pOut->GetSize();
- if(len == 0 || pDataIn == NULL) // format changes do not carry any data
- {
+ 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(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(len <= 0) return S_FALSE;
- if(*(DWORD*)pDataIn == 0xBB010000)
- {
- len -= 4; pDataIn += 4;
+ if(*(DWORD*)pDataIn == 0xBB010000) {
+ len -= 4;
+ pDataIn += 4;
int hdrlen = ((pDataIn[0]<<8)|pDataIn[1]) + 2;
- len -= hdrlen; pDataIn += hdrlen;
+ len -= hdrlen;
+ pDataIn += hdrlen;
+ }
+ if(len <= 0) {
+ return S_FALSE;
}
- if(len <= 0) return S_FALSE;
}
- 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));
pOut->SetActualDataLength(min(len, size));
@@ -179,21 +191,23 @@ HRESULT CDeCSSFilter::Transform(IMediaSample* pIn, IMediaSample* pOut)
HRESULT CDeCSSFilter::CheckInputType(const CMediaType* mtIn)
{
return mtIn->majortype == MEDIATYPE_DVD_ENCRYPTED_PACK
- ? S_OK
- : VFW_E_TYPE_NOT_ACCEPTED;
+ ? 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;
+ && 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;
+ if(m_pInput->IsConnected() == FALSE) {
+ return E_UNEXPECTED;
+ }
pProperties->cbAlign = 1;
pProperties->cBuffers = 1;
@@ -202,24 +216,35 @@ HRESULT CDeCSSFilter::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROP
HRESULT hr;
ALLOCATOR_PROPERTIES Actual;
- if(FAILED(hr = pAllocator->SetProperties(pProperties, &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 CDeCSSFilter::GetMediaType(int iPosition, CMediaType* pmt)
{
- if(m_pInput->IsConnected() == FALSE) return E_UNEXPECTED;
+ if(m_pInput->IsConnected() == FALSE) {
+ return E_UNEXPECTED;
+ }
- if(iPosition < 0) return E_INVALIDARG;
- if(iPosition > 1) return VFW_S_NO_MORE_ITEMS;
+ 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;
+ 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 37c1aa0d0..58fbf1f2d 100644
--- a/src/filters/transform/DeCSSFilter/DeCSSFilter.h
+++ b/src/filters/transform/DeCSSFilter/DeCSSFilter.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -22,7 +22,7 @@
#pragma once
class __declspec(uuid("7B3BD419-FE03-4820-BE94-A22A4F844895"))
-CDeCSSFilter : public CTransformFilter
+ CDeCSSFilter : public CTransformFilter
{
friend class CKsPSInputPin;
@@ -30,10 +30,10 @@ public:
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/DeCSSFilter/stdafx.cpp b/src/filters/transform/DeCSSFilter/stdafx.cpp
index 13934d005..bea3f980a 100644
--- a/src/filters/transform/DeCSSFilter/stdafx.cpp
+++ b/src/filters/transform/DeCSSFilter/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/transform/DeCSSFilter/stdafx.h b/src/filters/transform/DeCSSFilter/stdafx.h
index 62d50a36b..d1c3768d8 100644
--- a/src/filters/transform/DeCSSFilter/stdafx.h
+++ b/src/filters/transform/DeCSSFilter/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/transform/MPCVideoDec/CpuId.cpp b/src/filters/transform/MPCVideoDec/CpuId.cpp
index 4473d34bc..136041176 100644
--- a/src/filters/transform/MPCVideoDec/CpuId.cpp
+++ b/src/filters/transform/MPCVideoDec/CpuId.cpp
@@ -45,7 +45,7 @@ unsigned nHighestFeature;
unsigned nHighestFeatureEx;
int nBuff[4];
char szMan[13];
-char szFeatures[256];
+//char szFeatures[256];
// Get CPU manufacturer and highest CPUID
__cpuid(nBuff, 0);
@@ -91,7 +91,7 @@ char szFeatures[256];
// Get CPU features
m_nCPUFeatures = 0;
- szFeatures[0] = 0;
+ //szFeatures[0] = 0;
if(nHighestFeature >= 1)
{
__cpuid(nBuff, 1);
diff --git a/src/filters/transform/MPCVideoDec/DXVADecoder.cpp b/src/filters/transform/MPCVideoDec/DXVADecoder.cpp
index 771fbc212..374080e74 100644
--- a/src/filters/transform/MPCVideoDec/DXVADecoder.cpp
+++ b/src/filters/transform/MPCVideoDec/DXVADecoder.cpp
@@ -98,8 +98,9 @@ void CDXVADecoder::AllocExecuteParams (int nSize)
{
m_ExecuteParams.pCompressedBuffers = DNew DXVA2_DecodeBufferDesc[nSize];
- for (int i=0; i<nSize; i++)
+ for (int i=0; i<nSize; i++) {
memset (&m_ExecuteParams.pCompressedBuffers[i], 0, sizeof(DXVA2_DecodeBufferDesc));
+ }
}
void CDXVADecoder::SetExtraData (BYTE* pDataIn, UINT nSize)
@@ -117,8 +118,7 @@ void CDXVADecoder::CopyBitstream(BYTE* pDXVABuffer, BYTE* pBuffer, UINT& nSize)
void CDXVADecoder::Flush()
{
TRACE ("CDXVADecoder::Flush\n");
- for (int i=0; i<m_nPicEntryNumber; i++)
- {
+ for (int i=0; i<m_nPicEntryNumber; i++) {
m_pPictureStore[i].bRefPicture = false;
m_pPictureStore[i].bInUse = false;
m_pPictureStore[i].bDisplayed = false;
@@ -139,8 +139,7 @@ HRESULT CDXVADecoder::ConfigureDXVA1()
HRESULT hr = S_FALSE;
DXVA_ConfigPictureDecode ConfigRequested;
- if (m_pAMVideoAccelerator)
- {
+ if (m_pAMVideoAccelerator) {
memset (&ConfigRequested, 0, sizeof(ConfigRequested));
ConfigRequested.guidConfigBitstreamEncryption = DXVA_NoEncrypt;
ConfigRequested.guidConfigMBcontrolEncryption = DXVA_NoEncrypt;
@@ -167,13 +166,12 @@ HRESULT CDXVADecoder::ConfigureDXVA1()
m_DXVA2Config.ConfigSpecificIDCT = m_DXVA1Config.bConfigSpecificIDCT;
m_DXVA2Config.Config4GroupedCoefs = m_DXVA1Config.bConfig4GroupedCoefs;
- if (SUCCEEDED (hr))
- {
+ 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);
+ // ASSERT (ConfigRequested.bConfigBitstreamRaw == 2);
AMVAUncompDataInfo DataInfo;
DWORD dwNum = COMP_BUFFER_COUNT;
@@ -190,14 +188,15 @@ CDXVADecoder* CDXVADecoder::CreateDecoder (CMPCVideoDecFilter* pFilter, IAMVideo
{
CDXVADecoder* pDecoder = NULL;
- if ((*guidDecoder == DXVA2_ModeH264_E) || (*guidDecoder == DXVA2_ModeH264_F) || (*guidDecoder == DXVA_Intel_H264_ClearVideo))
+ 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 || *guidDecoder == DXVA_Intel_VC1_ClearVideo)
+ } else if (*guidDecoder == DXVA2_ModeVC1_D || *guidDecoder == DXVA_Intel_VC1_ClearVideo) {
pDecoder = DNew CDXVADecoderVC1 (pFilter, pAMVideoAccelerator, VC1_VLD, nPicEntryNumber);
- else if (*guidDecoder == DXVA2_ModeMPEG2_VLD)
+ } else if (*guidDecoder == DXVA2_ModeMPEG2_VLD) {
pDecoder = DNew CDXVADecoderMpeg2 (pFilter, pAMVideoAccelerator, MPEG2_VLD, nPicEntryNumber);
- else
- ASSERT (FALSE); // Unknown decoder !!
+ } else {
+ ASSERT (FALSE); // Unknown decoder !!
+ }
return pDecoder;
}
@@ -207,14 +206,15 @@ CDXVADecoder* CDXVADecoder::CreateDecoder (CMPCVideoDecFilter* pFilter, IDirectX
{
CDXVADecoder* pDecoder = NULL;
- if ((*guidDecoder == DXVA2_ModeH264_E) || (*guidDecoder == DXVA2_ModeH264_F) || (*guidDecoder == DXVA_Intel_H264_ClearVideo))
+ 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 || *guidDecoder == DXVA_Intel_VC1_ClearVideo)
+ } else if (*guidDecoder == DXVA2_ModeVC1_D || *guidDecoder == DXVA_Intel_VC1_ClearVideo) {
pDecoder = DNew CDXVADecoderVC1 (pFilter, pDirectXVideoDec, VC1_VLD, nPicEntryNumber, pDXVA2Config);
- else if (*guidDecoder == DXVA2_ModeMPEG2_VLD)
+ } else if (*guidDecoder == DXVA2_ModeMPEG2_VLD) {
pDecoder = DNew CDXVADecoderMpeg2 (pFilter, pDirectXVideoDec, MPEG2_VLD, nPicEntryNumber, pDXVA2Config);
- else
- ASSERT (FALSE); // Unknown decoder !!
+ } else {
+ ASSERT (FALSE); // Unknown decoder !!
+ }
return pDecoder;
}
@@ -230,60 +230,61 @@ HRESULT CDXVADecoder::AddExecuteBuffer (DWORD CompressedBufferType, UINT nSize,
//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;
+ switch (m_nEngine) {
+ case ENGINE_DXVA1 :
+ DWORD dwTypeIndex;
+ LONG lStride;
+ dwTypeIndex = GetDXVA1CompressedType (CompressedBufferType);
- case ENGINE_DXVA2 :
- UINT nDXVASize;
- hr = m_pDirectXVideoDec->GetBuffer (CompressedBufferType, (void**)&pDXVABuffer, &nDXVASize);
- ASSERT (nSize <= nDXVASize);
+ // 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) && (nSize <= nDXVASize))
- {
- if (CompressedBufferType == DXVA2_BitStreamDateBufferType)
- CopyBitstream (pDXVABuffer, (BYTE*)pBuffer, nSize);
- else
- memcpy (pDXVABuffer, (BYTE*)pBuffer, nSize);
+ 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;
- 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++;
+ 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;
+ }
+ break;
+ default :
+ ASSERT (FALSE);
+ break;
+ }
+ if (pRealSize) {
+ *pRealSize = nSize;
}
- if (pRealSize) *pRealSize = nSize;
return hr;
}
@@ -295,15 +296,13 @@ HRESULT CDXVADecoder::GetDeliveryBuffer(REFERENCE_TIME rtStart, REFERENCE_TIME r
CComPtr<IMediaSample> pNewSample;
// Change aspect ratio for DXVA2
- if (m_nEngine == ENGINE_DXVA2)
- {
+ if (m_nEngine == ENGINE_DXVA2) {
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))
- {
+ if (SUCCEEDED (hr)) {
pNewSample->SetTime(&rtStart, &rtStop);
pNewSample->SetMediaTime(NULL, NULL);
*ppSampleToDeliver = pNewSample.Detach();
@@ -315,43 +314,40 @@ HRESULT CDXVADecoder::Execute()
{
HRESULT hr = E_INVALIDARG;
- switch (m_nEngine)
- {
- case ENGINE_DXVA1 :
- DWORD dwFunction;
- HRESULT hr2;
+ 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);
+ // 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));
+ 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));
- }
+ 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;
+ m_dwNumBuffersInfo = 0;
+ break;
- case ENGINE_DXVA2 :
+ case ENGINE_DXVA2 :
- for (DWORD i=0; i<m_ExecuteParams.NumCompBuffers; i++)
- {
- hr2 = m_pDirectXVideoDec->ReleaseBuffer (m_ExecuteParams.pCompressedBuffers[i].CompressedBufferType);
- ASSERT (SUCCEEDED (hr2));
- }
+ 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;
+ hr = m_pDirectXVideoDec->Execute(&m_ExecuteParams);
+ m_ExecuteParams.NumCompBuffers = 0;
+ break;
+ default :
+ ASSERT (FALSE);
+ break;
}
return hr;
@@ -364,24 +360,23 @@ HRESULT CDXVADecoder::QueryStatus(PVOID LPDXVAStatus, UINT nSize)
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;
+ 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;
@@ -389,21 +384,19 @@ HRESULT CDXVADecoder::QueryStatus(PVOID LPDXVAStatus, UINT nSize)
DWORD CDXVADecoder::GetDXVA1CompressedType (DWORD dwDXVA2CompressedType)
{
- if (dwDXVA2CompressedType <= DXVA2_BitStreamDateBufferType)
+ 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;
+ } 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;
}
}
}
@@ -425,47 +418,47 @@ HRESULT CDXVADecoder::BeginFrame(int nSurfaceIndex, IMediaSample* pSampleToDeliv
HRESULT hr = E_INVALIDARG;
int nTry = 0;
- for (int i=0; i<20; i++)
- {
- switch (m_nEngine)
- {
- case ENGINE_DXVA1 :
- AMVABeginFrameInfo BeginFrameInfo;
+ 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;
+ BeginFrameInfo.dwDestSurfaceIndex = nSurfaceIndex;
+ BeginFrameInfo.dwSizeInputData = sizeof(nSurfaceIndex);
+ BeginFrameInfo.pInputData = &nSurfaceIndex;
+ BeginFrameInfo.dwSizeOutputData = 0;
+ BeginFrameInfo.pOutputData = NULL;
- DO_DXVA_PENDING_LOOP (m_pAMVideoAccelerator->BeginFrame(&BeginFrameInfo));
+ DO_DXVA_PENDING_LOOP (m_pAMVideoAccelerator->BeginFrame(&BeginFrameInfo));
- ASSERT (SUCCEEDED (hr));
- // TRACE ("BeginFrame %d\n",nSurfaceIndex);
- if (SUCCEEDED (hr))
- hr = FindFreeDXVA1Buffer ((DWORD)-1, m_dwBufferIndex);
- break;
+ ASSERT (SUCCEEDED (hr));
+ // TRACE ("BeginFrame %d\n",nSurfaceIndex);
+ 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));
+ 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;
+ default :
+ ASSERT (FALSE);
+ break;
}
// For slow accelerator wait a little...
- if (SUCCEEDED (hr)) break;
+ if (SUCCEEDED (hr)) {
+ break;
+ }
Sleep(1);
}
@@ -478,24 +471,23 @@ 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);
-// TRACE ("EndFrame %d\n",nSurfaceIndex);
- ASSERT (SUCCEEDED (hr));
- break;
-
- case ENGINE_DXVA2 :
- hr = m_pDirectXVideoDec->EndFrame(NULL);
- break;
- default :
- ASSERT (FALSE);
- break;
+ switch (m_nEngine) {
+ case ENGINE_DXVA1 :
+ AMVAEndFrameInfo EndFrameInfo;
+
+ EndFrameInfo.dwSizeMiscData = sizeof (dwDummy); // TODO : usefull ??
+ EndFrameInfo.pMiscData = &dwDummy;
+ hr = m_pAMVideoAccelerator->EndFrame(&EndFrameInfo);
+ // TRACE ("EndFrame %d\n",nSurfaceIndex);
+ ASSERT (SUCCEEDED (hr));
+ break;
+
+ case ENGINE_DXVA2 :
+ hr = m_pDirectXVideoDec->EndFrame(NULL);
+ break;
+ default :
+ ASSERT (FALSE);
+ break;
}
return hr;
@@ -506,8 +498,7 @@ bool CDXVADecoder::AddToStore (int nSurfaceIndex, IMediaSample* pSample, bool bR
REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, bool bIsField,
FF_FIELD_TYPE nFieldType, FF_SLICE_TYPE nSliceType, int nCodecSpecific)
{
- if (bIsField && (m_nFieldSurface == -1))
- {
+ if (bIsField && (m_nFieldSurface == -1)) {
m_nFieldSurface = nSurfaceIndex;
m_pFieldSample = pSample;
m_pPictureStore[nSurfaceIndex].n1FieldType = nFieldType;
@@ -515,9 +506,7 @@ bool CDXVADecoder::AddToStore (int nSurfaceIndex, IMediaSample* pSample, bool bR
m_pPictureStore[nSurfaceIndex].rtStop = rtStop;
m_pPictureStore[nSurfaceIndex].nCodecSpecific = nCodecSpecific;
return false;
- }
- else
- {
+ } 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);
@@ -529,8 +518,7 @@ bool CDXVADecoder::AddToStore (int nSurfaceIndex, IMediaSample* pSample, bool bR
m_pPictureStore[nSurfaceIndex].pSample = pSample;
m_pPictureStore[nSurfaceIndex].nSliceType = nSliceType;
- if (!bIsField)
- {
+ if (!bIsField) {
m_pPictureStore[nSurfaceIndex].rtStart = rtStart;
m_pPictureStore[nSurfaceIndex].rtStop = rtStop;
m_pPictureStore[nSurfaceIndex].n1FieldType = nFieldType;
@@ -555,8 +543,9 @@ void CDXVADecoder::RemoveRefFrame (int nSurfaceIndex)
ASSERT ((nSurfaceIndex < m_nPicEntryNumber) && m_pPictureStore[nSurfaceIndex].bInUse);
m_pPictureStore[nSurfaceIndex].bRefPicture = false;
- if (m_pPictureStore[nSurfaceIndex].bDisplayed)
+ if (m_pPictureStore[nSurfaceIndex].bDisplayed) {
FreePictureSlot (nSurfaceIndex);
+ }
}
@@ -566,14 +555,11 @@ int CDXVADecoder::FindOldestFrame()
int nPos = -1;
// TODO : find better solution...
- if (m_nWaitingPics > m_nMaxWaiting)
- {
- for (int i=0; i<m_nPicEntryNumber; i++)
- {
+ 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))
- {
+ m_pPictureStore[i].bInUse &&
+ (m_pPictureStore[i].rtStart < rtMin)) {
rtMin = m_pPictureStore[i].rtStart;
nPos = i;
}
@@ -584,36 +570,33 @@ int CDXVADecoder::FindOldestFrame()
void CDXVADecoder::SetTypeSpecificFlags(PICTURE_STORE* pPicture, IMediaSample* pMS)
{
- if(CComQIPtr<IMediaSample2> pMS2 = pMS)
- {
+ if(CComQIPtr<IMediaSample2> pMS2 = pMS) {
AM_SAMPLE2_PROPERTIES props;
- if(SUCCEEDED(pMS2->GetProperties(sizeof(props), (BYTE*)&props)))
- {
+ if(SUCCEEDED(pMS2->GetProperties(sizeof(props), (BYTE*)&props))) {
props.dwTypeSpecificFlags &= ~0x7f;
- if(pPicture->n1FieldType == PICT_FRAME)
+ if(pPicture->n1FieldType == PICT_FRAME) {
props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_WEAVE;
- else
- {
- if(pPicture->n1FieldType == PICT_TOP_FIELD)
+ } else {
+ if(pPicture->n1FieldType == PICT_TOP_FIELD) {
props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_FIELD1FIRST;
+ }
//if(m_fb.flags & PIC_FLAG_REPEAT_FIRST_FIELD)
// props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_REPEAT_FIELD;
}
- 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;
+ 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);
@@ -630,24 +613,23 @@ HRESULT CDXVADecoder::DisplayNextFrame()
int nPicIndex;
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 (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;
}
@@ -665,8 +647,9 @@ HRESULT CDXVADecoder::DisplayNextFrame()
}
m_pPictureStore[nPicIndex].bDisplayed = true;
- if (!m_pPictureStore[nPicIndex].bRefPicture)
+ if (!m_pPictureStore[nPicIndex].bRefPicture) {
FreePictureSlot (nPicIndex);
+ }
}
return hr;
@@ -678,48 +661,42 @@ HRESULT CDXVADecoder::GetFreeSurfaceIndex(int& nSurfaceIndex, IMediaSample** ppS
int nPos = -1;
DWORD dwMinDisplay = MAXDWORD;
- if (m_nFieldSurface != -1)
- {
+ 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;
+ 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;
- }
+ 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 !!!
-// TRACE ("==> Try get buffer...\n");
- if (SUCCEEDED (hr = GetDeliveryBuffer(rtStart, rtStop, &pNewSample)))
- {
- pMPCDXVA2Sample = pNewSample;
- nSurfaceIndex = pMPCDXVA2Sample ? pMPCDXVA2Sample->GetDXSurfaceId() : 0;
- *ppSampleToDeliver = pNewSample.Detach();
-// TRACE ("GetFreeSurfaceIndex : %d\n", nSurfaceIndex);
- }
- break;
+ // Ho ho...
+ ASSERT (FALSE);
+ Flush();
+ break;
+ case ENGINE_DXVA2 :
+ CComPtr<IMediaSample> pNewSample;
+ CComQIPtr<IMPCDXVA2Sample> pMPCDXVA2Sample;
+ // TODO : test IDirect3DDeviceManager9::TestDevice !!!
+ // TRACE ("==> Try get buffer...\n");
+ if (SUCCEEDED (hr = GetDeliveryBuffer(rtStart, rtStop, &pNewSample))) {
+ pMPCDXVA2Sample = pNewSample;
+ nSurfaceIndex = pMPCDXVA2Sample ? pMPCDXVA2Sample->GetDXSurfaceId() : 0;
+ *ppSampleToDeliver = pNewSample.Detach();
+ // TRACE ("GetFreeSurfaceIndex : %d\n", nSurfaceIndex);
+ }
+ break;
}
return hr;
@@ -728,7 +705,7 @@ HRESULT CDXVADecoder::GetFreeSurfaceIndex(int& nSurfaceIndex, IMediaSample** ppS
void CDXVADecoder::FreePictureSlot (int nSurfaceIndex)
{
-// TRACE ("Free : %d\n", nSurfaceIndex);
+ // TRACE ("Free : %d\n", nSurfaceIndex);
m_pPictureStore[nSurfaceIndex].dwDisplayCount = m_dwDisplayCount++;
m_pPictureStore[nSurfaceIndex].bInUse = false;
m_pPictureStore[nSurfaceIndex].bDisplayed = false;
@@ -740,12 +717,11 @@ void CDXVADecoder::FreePictureSlot (int nSurfaceIndex)
BYTE CDXVADecoder::GetConfigResidDiffAccelerator()
{
- switch (m_nEngine)
- {
- case ENGINE_DXVA1 :
- return m_DXVA1Config.bConfigResidDiffAccelerator;
- case ENGINE_DXVA2 :
- return m_DXVA2Config.ConfigResidDiffAccelerator;
+ switch (m_nEngine) {
+ case ENGINE_DXVA1 :
+ return m_DXVA1Config.bConfigResidDiffAccelerator;
+ case ENGINE_DXVA2 :
+ return m_DXVA2Config.ConfigResidDiffAccelerator;
}
return 0;
}
@@ -753,12 +729,11 @@ BYTE CDXVADecoder::GetConfigResidDiffAccelerator()
BYTE CDXVADecoder::GetConfigIntraResidUnsigned()
{
- switch (m_nEngine)
- {
- case ENGINE_DXVA1 :
- return m_DXVA1Config.bConfigIntraResidUnsigned;
- case ENGINE_DXVA2 :
- return m_DXVA2Config.ConfigIntraResidUnsigned;
+ switch (m_nEngine) {
+ case ENGINE_DXVA1 :
+ return m_DXVA1Config.bConfigIntraResidUnsigned;
+ case ENGINE_DXVA2 :
+ return m_DXVA2Config.ConfigIntraResidUnsigned;
}
return 0;
}
diff --git a/src/filters/transform/MPCVideoDec/DXVADecoder.h b/src/filters/transform/MPCVideoDec/DXVADecoder.h
index a8c92154b..6c776454e 100644
--- a/src/filters/transform/MPCVideoDec/DXVADecoder.h
+++ b/src/filters/transform/MPCVideoDec/DXVADecoder.h
@@ -26,28 +26,24 @@
#include <dxva2api.h>
#include <videoacc.h>
-typedef enum
-{
+typedef enum {
ENGINE_DXVA1,
ENGINE_DXVA2
} DXVA_ENGINE;
-typedef enum
-{
+typedef enum {
H264_VLD,
VC1_VLD,
MPEG2_VLD
} DXVAMode;
-typedef enum
-{
+typedef enum {
PICT_TOP_FIELD = 1,
PICT_BOTTOM_FIELD = 2,
PICT_FRAME = 3
} FF_FIELD_TYPE;
-typedef enum
-{
+typedef enum {
I_TYPE = 1, ///< Intra
P_TYPE = 2, ///< Predicted
B_TYPE = 3, ///< Bi-dir predicted
@@ -57,8 +53,7 @@ typedef enum
BI_TYPE = 7
} FF_SLICE_TYPE;
-typedef struct
-{
+typedef struct {
bool bRefPicture; // True if reference picture
bool bInUse; // Slot in use
bool bDisplayed; // True if picture have been presented
diff --git a/src/filters/transform/MPCVideoDec/DXVADecoderH264.cpp b/src/filters/transform/MPCVideoDec/DXVADecoderH264.cpp
index 612168526..e2e8cee4e 100644
--- a/src/filters/transform/MPCVideoDec/DXVADecoderH264.cpp
+++ b/src/filters/transform/MPCVideoDec/DXVADecoderH264.cpp
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * (C) 2006-2010 see AUTHORS
+ * (C) 2006-2011 see AUTHORS
*
* This file is part of mplayerc.
*
@@ -60,18 +60,18 @@ void CDXVADecoderH264::Init()
memset (&m_pSliceShort, 0, sizeof (DXVA_Slice_H264_Short)*MAX_SLICES);
m_DXVAPicParams.MbsConsecutiveFlag = 1;
- if(m_pFilter->GetPCIVendor() == PCIV_Intel)
+ if(m_pFilter->GetPCIVendor() == PCIV_Intel) {
m_DXVAPicParams.Reserved16Bits = 0x534c;
- else
+ } 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++)
- {
+ 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;
@@ -81,13 +81,12 @@ void CDXVADecoderH264::Init()
m_nNALLength = 4;
m_nMaxSlices = 0;
- switch (GetMode())
- {
- case H264_VLD :
- AllocExecuteParams (3);
- break;
- default :
- ASSERT(FALSE);
+ switch (GetMode()) {
+ case H264_VLD :
+ AllocExecuteParams (3);
+ break;
+ default :
+ ASSERT(FALSE);
}
}
@@ -103,67 +102,62 @@ void CDXVADecoderH264::CopyBitstream(BYTE* pDXVABuffer, BYTE* pBuffer, UINT& nSi
#if 0
// Test to place Nal on multiple of 128 bytes (seems to be not necessary)
- if(!m_bUseLongSlice)
- {
- while (Nalu.ReadNext())
- {
- switch (Nalu.GetType())
- {
- case NALU_TYPE_SLICE:
- case NALU_TYPE_IDR:
- // For AVC1, put startcode 0x000001
- pDXVABuffer[0]=pDXVABuffer[1]=0;
- pDXVABuffer[2]=1;
-
- // Copy NALU
- memcpy (pDXVABuffer+3, Nalu.GetDataBuffer(), Nalu.GetDataLength());
-
- // Complete with zero padding (buffer size should be a multiple of 128)
- nDummy = 128 - ((Nalu.GetDataLength()+3) %128);
- pDXVABuffer += Nalu.GetDataLength() + 3;
- memset (pDXVABuffer, 0, nDummy);
- pDXVABuffer += nDummy;
-
- // Update slice control buffer
- nDxvaNalLength = Nalu.GetDataLength()+3+nDummy;
- m_pSliceShort[nSlices].BSNALunitDataLocation = nSize;
- m_pSliceShort[nSlices].SliceBytesInBuffer = nDxvaNalLength;
-
- nSize += nDxvaNalLength;
- nSlices++;
- break;
+ if(!m_bUseLongSlice) {
+ while (Nalu.ReadNext()) {
+ switch (Nalu.GetType()) {
+ case NALU_TYPE_SLICE:
+ case NALU_TYPE_IDR:
+ // For AVC1, put startcode 0x000001
+ pDXVABuffer[0]=pDXVABuffer[1]=0;
+ pDXVABuffer[2]=1;
+
+ // Copy NALU
+ memcpy (pDXVABuffer+3, Nalu.GetDataBuffer(), Nalu.GetDataLength());
+
+ // Complete with zero padding (buffer size should be a multiple of 128)
+ nDummy = 128 - ((Nalu.GetDataLength()+3) %128);
+ pDXVABuffer += Nalu.GetDataLength() + 3;
+ memset (pDXVABuffer, 0, nDummy);
+ pDXVABuffer += nDummy;
+
+ // Update slice control buffer
+ nDxvaNalLength = Nalu.GetDataLength()+3+nDummy;
+ m_pSliceShort[nSlices].BSNALunitDataLocation = nSize;
+ m_pSliceShort[nSlices].SliceBytesInBuffer = nDxvaNalLength;
+
+ nSize += nDxvaNalLength;
+ nSlices++;
+ break;
}
}
- }
- else
+ } else
#endif
{
- 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)
+ 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;
+
+ // Copy NALU
+ memcpy (pDXVABuffer+3, Nalu.GetDataBuffer(), Nalu.GetDataLength());
+
+ // Update slice control buffer
+ nDxvaNalLength = Nalu.GetDataLength()+3;
+ m_pSliceShort[nSlices].BSNALunitDataLocation = nSize;
+ m_pSliceShort[nSlices].SliceBytesInBuffer = nDxvaNalLength;
+
+ nSize += nDxvaNalLength;
+ pDXVABuffer += nDxvaNalLength;
+ nSlices++;
break;
-
- // For AVC1, put startcode 0x000001
- pDXVABuffer[0]=pDXVABuffer[1]=0;
- pDXVABuffer[2]=1;
-
- // Copy NALU
- memcpy (pDXVABuffer+3, Nalu.GetDataBuffer(), Nalu.GetDataLength());
-
- // Update slice control buffer
- nDxvaNalLength = Nalu.GetDataLength()+3;
- m_pSliceShort[nSlices].BSNALunitDataLocation = nSize;
- m_pSliceShort[nSlices].SliceBytesInBuffer = nDxvaNalLength;
-
- nSize += nDxvaNalLength;
- pDXVABuffer += nDxvaNalLength;
- nSlices++;
- break;
}
}
@@ -204,39 +198,43 @@ HRESULT CDXVADecoderH264::DecodeFrame (BYTE* pDataIn, UINT nSize, REFERENCE_TIME
Nalu.SetBuffer (pDataIn, nSize, m_nNALLength);
FFH264DecodeBuffer (m_pFilter->GetAVCtx(), pDataIn, nSize, &nFramePOC, &nOutPOC, &rtOutStart);
- 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;
+ 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;
}
}
- if (nSlices == 0) return S_FALSE;
+ if (nSlices == 0) {
+ 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())))
+ if (FAILED (FFH264BuildPicParams (&m_DXVAPicParams, &m_DXVAScalingMatrix, &nFieldType, &nSliceType, m_pFilter->GetAVCtx(), m_pFilter->GetPCIVendor()))) {
return S_FALSE;
+ }
// Wait I frame after a flush
- if (m_bFlushed && !m_DXVAPicParams.IntraPicFlag)
+ if (m_bFlushed && !m_DXVAPicParams.IntraPicFlag) {
return S_FALSE;
+ }
CHECK_HR (GetFreeSurfaceIndex (nSurfaceIndex, &pSampleToDeliver, rtStart, rtStop));
@@ -246,7 +244,7 @@ HRESULT CDXVADecoderH264::DecodeFrame (BYTE* pDataIn, UINT nSize, REFERENCE_TIME
m_DXVAPicParams.StatusReportFeedbackNumber++;
-// TRACE("CDXVADecoderH264 : Decode frame %u\n", m_DXVAPicParams.StatusReportFeedbackNumber);
+ // TRACE("CDXVADecoderH264 : Decode frame %u\n", m_DXVAPicParams.StatusReportFeedbackNumber);
// Send picture parameters
CHECK_HR (AddExecuteBuffer (DXVA2_PictureParametersBufferType, sizeof(m_DXVAPicParams), &m_DXVAPicParams));
@@ -255,12 +253,9 @@ HRESULT CDXVADecoderH264::DecodeFrame (BYTE* pDataIn, UINT nSize, REFERENCE_TIME
// Add bitstream, slice control and quantization matrix
CHECK_HR (AddExecuteBuffer (DXVA2_BitStreamDateBufferType, nSize, pDataIn, &nSize));
- if (m_bUseLongSlice)
- {
+ if (m_bUseLongSlice) {
CHECK_HR(AddExecuteBuffer(DXVA2_SliceControlBufferType, sizeof(DXVA_Slice_H264_Long)*nSlices, m_pSliceLong));
- }
- else
- {
+ } else {
CHECK_HR (AddExecuteBuffer (DXVA2_SliceControlBufferType, sizeof (DXVA_Slice_H264_Short)*nSlices, m_pSliceShort));
}
@@ -272,7 +267,7 @@ HRESULT CDXVADecoderH264::DecodeFrame (BYTE* pDataIn, UINT nSize, REFERENCE_TIME
CHECK_HR (EndFrame(nSurfaceIndex));
#ifdef _DEBUG
-// DisplayStatus();
+ // DisplayStatus();
#endif
bool bAdded = AddToStore (nSurfaceIndex, pSampleToDeliver, m_DXVAPicParams.RefPicFlag, rtStart, rtStop,
@@ -282,12 +277,10 @@ HRESULT CDXVADecoderH264::DecodeFrame (BYTE* pDataIn, UINT nSize, REFERENCE_TIME
FFH264UpdateRefFramesList (&m_DXVAPicParams, m_pFilter->GetAVCtx());
ClearUnusedRefFrames();
- if (bAdded)
- {
+ if (bAdded) {
hr = DisplayNextFrame();
- if (nOutPOC != INT_MIN)
- {
+ if (nOutPOC != INT_MIN) {
m_nOutPOC = nOutPOC;
m_rtOutStart = rtOutStart;
}
@@ -299,10 +292,8 @@ HRESULT CDXVADecoderH264::DecodeFrame (BYTE* pDataIn, UINT nSize, REFERENCE_TIME
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)
- {
+ 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;
@@ -313,11 +304,11 @@ void CDXVADecoderH264::RemoveUndisplayedFrame(int nPOC)
void CDXVADecoderH264::ClearUnusedRefFrames()
{
// Remove old reference frames (not anymore a short or long ref frame)
- for (int i=0; i<m_nPicEntryNumber; i++)
- {
+ for (int i=0; i<m_nPicEntryNumber; i++) {
if (m_pPictureStore[i].bRefPicture && m_pPictureStore[i].bDisplayed)
- if (!FFH264IsRefFrameInUse (i, m_pFilter->GetAVCtx()))
+ if (!FFH264IsRefFrameInUse (i, m_pFilter->GetAVCtx())) {
RemoveRefFrame (i);
+ }
}
}
@@ -332,12 +323,8 @@ void CDXVADecoderH264::SetExtraData (BYTE* pDataIn, UINT nSize)
void CDXVADecoderH264::ClearRefFramesList()
{
- int i;
-
- for (int i=0; i<m_nPicEntryNumber; i++)
- {
- if (m_pPictureStore[i].bInUse)
- {
+ for (int i=0; i<m_nPicEntryNumber; i++) {
+ if (m_pPictureStore[i].bInUse) {
m_pPictureStore[i].bDisplayed = true;
RemoveRefFrame (i);
}
@@ -369,28 +356,23 @@ 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)
- {
+ 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) {
nPos = i;
rtPos = m_pPictureStore[i].rtStart;
}
}
}
- if (nPos != -1)
- {
- if (m_rtOutStart == _I64_MIN)
- {
+ if (nPos != -1) {
+ if (m_rtOutStart == _I64_MIN) {
// If start time not set (no PTS for example), guess presentation time!
m_rtOutStart = m_rtLastFrameDisplayed;
}
m_pPictureStore[nPos].rtStart = m_rtOutStart;
- m_pPictureStore[nPos].rtStop = m_rtOutStart + m_pFilter->GetAvrTimePerFrame();
- m_rtLastFrameDisplayed = m_rtOutStart + m_pFilter->GetAvrTimePerFrame();
+ m_pPictureStore[nPos].rtStop = m_rtOutStart + m_pFilter->GetAvrTimePerFrame() / m_pFilter->GetRate();
+ m_rtLastFrameDisplayed = m_pPictureStore[nPos].rtStop;
m_pFilter->ReorderBFrames (m_pPictureStore[nPos].rtStart, m_pPictureStore[nPos].rtStop);
}
diff --git a/src/filters/transform/MPCVideoDec/DXVADecoderMpeg2.cpp b/src/filters/transform/MPCVideoDec/DXVADecoderMpeg2.cpp
index 3012ae884..af5e4d9a6 100644
--- a/src/filters/transform/MPCVideoDec/DXVADecoderMpeg2.cpp
+++ b/src/filters/transform/MPCVideoDec/DXVADecoderMpeg2.cpp
@@ -67,13 +67,12 @@ void CDXVADecoderMpeg2::Init()
m_wRefPictureIndex[1] = NO_REF_FRAME;
m_nSliceCount = 0;
- switch (GetMode())
- {
- case MPEG2_VLD :
- AllocExecuteParams (4);
- break;
- default :
- ASSERT(FALSE);
+ switch (GetMode()) {
+ case MPEG2_VLD :
+ AllocExecuteParams (4);
+ break;
+ default :
+ ASSERT(FALSE);
}
}
@@ -90,12 +89,12 @@ HRESULT CDXVADecoderMpeg2::DecodeFrame (BYTE* pDataIn, UINT nSize, REFERENCE_TIM
m_pFilter->GetFrame(), &m_nNextCodecIndex, &nFieldType, &nSliceType, pDataIn, nSize);
// Wait I frame after a flush
- if (m_bFlushed && ! m_PictureParams.bPicIntra)
+ if (m_bFlushed && ! m_PictureParams.bPicIntra) {
return S_FALSE;
+ }
hr = GetFreeSurfaceIndex (nSurfaceIndex, &pSampleToDeliver, rtStart, rtStop);
- if (FAILED (hr))
- {
+ if (FAILED (hr)) {
ASSERT (hr == VFW_E_NOT_COMMITTED); // Normal when stop playing
return hr;
}
@@ -134,9 +133,10 @@ void CDXVADecoderMpeg2::UpdatePictureParams(int nSurfaceIndex)
m_PictureParams.wDecodedPictureIndex = nSurfaceIndex;
// Manage reference picture list
- if (!m_PictureParams.bPicBackwardPrediction)
- {
- if (m_wRefPictureIndex[0] != NO_REF_FRAME) RemoveRefFrame (m_wRefPictureIndex[0]);
+ 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;
}
@@ -144,34 +144,37 @@ void CDXVADecoderMpeg2::UpdatePictureParams(int nSurfaceIndex)
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)
+ if (cpd->ConfigResidDiffHost == 0 || m_PictureParams.bBPPminus1 > 7) {
m_PictureParams.bPicSpatialResid8 = 0;
- else
- {
+ } 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
+ } 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)
+ 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)
- {
+ 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),
+ 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),
+ }
}
}
@@ -184,12 +187,13 @@ void CDXVADecoderMpeg2::SetExtraData (BYTE* pDataIn, UINT nSize)
void CDXVADecoderMpeg2::CopyBitstream(BYTE* pDXVABuffer, BYTE* pBuffer, UINT& nSize)
{
- while (*((DWORD*)pBuffer) != 0x01010000)
- {
+ while (*((DWORD*)pBuffer) != 0x01010000) {
pBuffer++;
nSize--;
- if (nSize <= 0) return;
+ if (nSize <= 0) {
+ return;
+ }
}
memcpy (pDXVABuffer, pBuffer, nSize);
@@ -200,8 +204,12 @@ void CDXVADecoderMpeg2::Flush()
{
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;
@@ -214,19 +222,18 @@ int CDXVADecoderMpeg2::FindOldestFrame()
{
int nPos = -1;
- for (int i=0; i<m_nPicEntryNumber; i++)
- {
+ for (int i=0; i<m_nPicEntryNumber; i++) {
if (!m_pPictureStore[i].bDisplayed &&
- m_pPictureStore[i].bInUse &&
- (m_pPictureStore[i].nCodecSpecific == m_nNextCodecIndex))
- {
+ m_pPictureStore[i].bInUse &&
+ (m_pPictureStore[i].nCodecSpecific == m_nNextCodecIndex)) {
m_nNextCodecIndex = INT_MIN;
nPos = i;
}
}
- if (nPos != -1)
+ if (nPos != -1) {
m_pFilter->UpdateFrameTime(m_pPictureStore[nPos].rtStart, m_pPictureStore[nPos].rtStop);
+ }
return nPos;
}
diff --git a/src/filters/transform/MPCVideoDec/DXVADecoderVC1.cpp b/src/filters/transform/MPCVideoDec/DXVADecoderVC1.cpp
index 2d55d0e84..212d18b6c 100644
--- a/src/filters/transform/MPCVideoDec/DXVADecoderVC1.cpp
+++ b/src/filters/transform/MPCVideoDec/DXVADecoderVC1.cpp
@@ -72,13 +72,12 @@ void CDXVADecoderVC1::Init()
m_wRefPictureIndex[0] = NO_REF_FRAME;
m_wRefPictureIndex[1] = NO_REF_FRAME;
- switch (GetMode())
- {
- case VC1_VLD :
- AllocExecuteParams (3);
- break;
- default :
- ASSERT(FALSE);
+ switch (GetMode()) {
+ case VC1_VLD :
+ AllocExecuteParams (3);
+ break;
+ default :
+ ASSERT(FALSE);
}
}
@@ -92,16 +91,17 @@ HRESULT CDXVADecoderVC1::DecodeFrame (BYTE* pDataIn, UINT nSize, REFERENCE_TIME
int nSliceType;
FFVC1UpdatePictureParam (&m_PictureParams, m_pFilter->GetAVCtx(), &nFieldType, &nSliceType, pDataIn, nSize);
- if (FFIsSkipped (m_pFilter->GetAVCtx()))
+ if (FFIsSkipped (m_pFilter->GetAVCtx())) {
return S_OK;
+ }
// Wait I frame after a flush
- if (m_bFlushed && ! m_PictureParams.bPicIntra)
+ if (m_bFlushed && ! m_PictureParams.bPicIntra) {
return S_FALSE;
+ }
hr = GetFreeSurfaceIndex (nSurfaceIndex, &pSampleToDeliver, rtStart, rtStop);
- if (FAILED (hr))
- {
+ if (FAILED (hr)) {
ASSERT (hr == VFW_E_NOT_COMMITTED); // Normal when stop playing
return hr;
}
@@ -114,9 +114,10 @@ HRESULT CDXVADecoderVC1::DecodeFrame (BYTE* pDataIn, UINT nSize, REFERENCE_TIME
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]);
+ 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;
}
@@ -133,7 +134,7 @@ HRESULT CDXVADecoderVC1::DecodeFrame (BYTE* pDataIn, UINT nSize, REFERENCE_TIME
// Send picture params to accelerator
m_PictureParams.wDecodedPictureIndex = nSurfaceIndex;
CHECK_HR (AddExecuteBuffer (DXVA2_PictureParametersBufferType, sizeof(m_PictureParams), &m_PictureParams));
-// CHECK_HR (Execute());
+ // CHECK_HR (Execute());
// Send bitstream to accelerator
@@ -152,20 +153,16 @@ HRESULT CDXVADecoderVC1::DecodeFrame (BYTE* pDataIn, UINT nSize, REFERENCE_TIME
#endif
// Re-order B frames
- if (m_pFilter->IsReorderBFrame())
- {
- if (m_PictureParams.bPicBackwardPrediction == 1)
- {
+ if (m_pFilter->IsReorderBFrame()) {
+ if (m_PictureParams.bPicBackwardPrediction == 1) {
SwapRT (rtStart, m_rtStartDelayed);
SwapRT (rtStop, m_rtStopDelayed);
- }
- else
- {
+ } else {
// Save I or P reference time (swap later)
- if (!m_bFlushed)
- {
- if (m_nDelayedSurfaceIndex != -1)
+ 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);
@@ -209,8 +206,8 @@ void CDXVADecoderVC1::SetExtraData (BYTE* pDataIn, UINT nSize)
// iWMV9 - i9IRU - iOHIT - iINSO - iWMVA - 0 - 0 - 0 | Section 3.2.5
m_PictureParams.bBidirectionalAveragingMode = (1 << 7) |
- (GetConfigIntraResidUnsigned() <<6) | // i9IRU
- (GetConfigResidDiffAccelerator() <<5); // iOHIT
+ (GetConfigIntraResidUnsigned() <<6) | // i9IRU
+ (GetConfigResidDiffAccelerator() <<5); // iOHIT
}
@@ -218,29 +215,20 @@ BYTE* CDXVADecoderVC1::FindNextStartCode(BYTE* pBuffer, UINT nSize, UINT& nPacke
{
BYTE* pStart = pBuffer;
BYTE bCode = 0;
- for (int i=0; i<nSize-4; i++)
- {
- if ( ((*((DWORD*)(pBuffer+i)) & 0x00FFFFFF) == 0x00010000) || (i >= nSize-5) )
- {
- if (bCode == 0)
- {
+ for (int 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))
- {
+ if ((nSize == 5) && (bCode == 0x0D)) {
nPacketSize = nSize;
return pBuffer;
}
- }
- else
- {
- if (bCode == 0x0D)
- {
+ } else {
+ if (bCode == 0x0D) {
// Start code found!
nPacketSize = i - (pStart - pBuffer) + (i >= nSize-5 ? 5 : 1);
return pStart;
- }
- else
- {
+ } else {
// Other stuff, ignore it
pStart = pBuffer + i;
bCode = pBuffer[i+3];
@@ -257,8 +245,7 @@ void CDXVADecoderVC1::CopyBitstream(BYTE* pDXVABuffer, BYTE* pBuffer, UINT& nSiz
{
int nDummy;
- if ( (*((DWORD*)pBuffer) & 0x00FFFFFF) != 0x00010000)
- {
+ if ( (*((DWORD*)pBuffer) & 0x00FFFFFF) != 0x00010000) {
// Some splitter have remove startcode (Haali)
pDXVABuffer[0]=pDXVABuffer[1]=0;
pDXVABuffer[2]=1;
@@ -267,15 +254,12 @@ void CDXVADecoderVC1::CopyBitstream(BYTE* pDXVABuffer, BYTE* pBuffer, UINT& nSiz
// Copy bitstream buffer, with zero padding (buffer is rounded to multiple of 128)
memcpy (pDXVABuffer, (BYTE*)pBuffer, nSize);
nSize +=4;
- }
- else
- {
+ } else {
BYTE* pStart;
UINT nPacketSize;
pStart = FindNextStartCode (pBuffer, nSize, nPacketSize);
- if (pStart)
- {
+ if (pStart) {
// Startcode already present
memcpy (pDXVABuffer, (BYTE*)pStart, nPacketSize);
nSize = nPacketSize;
@@ -295,8 +279,12 @@ void CDXVADecoderVC1::Flush()
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;
@@ -311,8 +299,7 @@ HRESULT CDXVADecoderVC1::DisplayStatus()
memset (&Status, 0, sizeof(Status));
- if (SUCCEEDED (hr = CDXVADecoder::QueryStatus(&Status, sizeof(Status))))
- {
+ if (SUCCEEDED (hr = CDXVADecoder::QueryStatus(&Status, sizeof(Status)))) {
Status.StatusReportFeedbackNumber = 0x00FF & Status.StatusReportFeedbackNumber;
TRACE_VC1 ("CDXVADecoderVC1 : Status for the frame %u : bBufType = %u, bStatus = %u, wNumMbsAffected = %u\n",
diff --git a/src/filters/transform/MPCVideoDec/DXVADecoderVC1.h b/src/filters/transform/MPCVideoDec/DXVADecoderVC1.h
index d08a6ffea..6c2e1873c 100644
--- a/src/filters/transform/MPCVideoDec/DXVADecoderVC1.h
+++ b/src/filters/transform/MPCVideoDec/DXVADecoderVC1.h
@@ -39,38 +39,33 @@ public:
virtual void CopyBitstream (BYTE* pDXVABuffer, BYTE* pBuffer, UINT& nSize);
virtual void Flush();
- typedef enum
- {
+ typedef enum {
VC1_PS_TOP_FIELD = 1,
VC1_PS_BOTTOM_FIELD = 2,
VC1_PS_PROGRESSIVE = 3
};
- typedef enum
- {
+ typedef enum {
VC1_CHROMA_420 = 1,
VC1_CHROMA_422 = 2,
VC1_CHROMA_444 = 3
} VC1_CHROMA_FORMAT;
- typedef enum
- {
+ 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,
};
- typedef enum
- {
+ 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
- {
+ typedef enum { // Values for bPicDeblockConfined when bConfigBitstreamRaw = 1
VC1_EXTENDED_DMV = 0x0001,
VC1_PSF = 0x0002,
VC1_REFPICFLAG = 0x0004,
@@ -81,8 +76,7 @@ public:
VC1_POSTPROCFLAG = 0x0080
} VC1_DEBLOCK_CONFINED;
- typedef enum // Values for bPicSpatialResid8
- {
+ typedef enum { // Values for bPicSpatialResid8
VC1_VSTRANSFORM = 0x0001,
VC1_DQUANT = 0x0002,
VC1_EXTENDED_MV = 0x0004,
diff --git a/src/filters/transform/MPCVideoDec/FfmpegContext.c b/src/filters/transform/MPCVideoDec/FfmpegContext.c
index 596f0973d..08566ca83 100644
--- a/src/filters/transform/MPCVideoDec/FfmpegContext.c
+++ b/src/filters/transform/MPCVideoDec/FfmpegContext.c
@@ -42,15 +42,15 @@ int av_h264_decode_frame(struct AVCodecContext* avctx, int* nOutPOC, int64_t* rt
int av_vc1_decode_frame(AVCodecContext *avctx, uint8_t *buf, int buf_size);
void av_init_packet(AVPacket *pkt);
-const byte ZZ_SCAN[16] =
-{ 0, 1, 4, 8, 5, 2, 3, 6, 9, 12, 13, 10, 7, 11, 14, 15
+const byte ZZ_SCAN[16] = {
+ 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
+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
};
// FIXME : remove duplicate declaration with ffmpeg ??
@@ -75,16 +75,16 @@ BOOL IsVistaOrAbove()
static BOOL result = FALSE;
OSVERSIONINFO osver;
- if (!checked)
- {
+ if (!checked) {
checked = TRUE;
osver.dwOSVersionInfoSize = sizeof( OSVERSIONINFO );
if (GetVersionEx( &osver ) &&
- osver.dwPlatformId == VER_PLATFORM_WIN32_NT &&
- (osver.dwMajorVersion >= 6 ) )
+ osver.dwPlatformId == VER_PLATFORM_WIN32_NT &&
+ (osver.dwMajorVersion >= 6 ) ) {
result = TRUE;
+ }
}
return result;
@@ -103,16 +103,15 @@ 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;
+ 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;
}
@@ -120,38 +119,29 @@ inline MpegEncContext* GetMpegEncContext(struct AVCodecContext* pAVCtx)
void FFH264DecodeBuffer (struct AVCodecContext* pAVCtx, BYTE* pBuffer, UINT nSize, int* pFramePOC, int* pOutPOC, REFERENCE_TIME* pOutrtStart)
{
- if (pBuffer != NULL)
- {
+ if (pBuffer != NULL) {
H264Context* h = (H264Context*) pAVCtx->priv_data;
av_h264_decode_frame (pAVCtx, pOutPOC, pOutrtStart, pBuffer, nSize);
- if (h->s.current_picture_ptr != NULL && pFramePOC) *pFramePOC = h->s.current_picture_ptr->field_poc[0];
+ if (h->s.current_picture_ptr != NULL && pFramePOC) {
+ *pFramePOC = h->s.current_picture_ptr->field_poc[0];
+ }
}
}
// 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)
- {
+ if (HIWORD(VideoDriverVersion.HighPart) > A) {
return TRUE;
- }
- else if (HIWORD(VideoDriverVersion.HighPart) == A)
- {
- if (LOWORD(VideoDriverVersion.HighPart) > B)
- {
+ } else if (HIWORD(VideoDriverVersion.HighPart) == A) {
+ if (LOWORD(VideoDriverVersion.HighPart) > B) {
return TRUE;
- }
- else if (LOWORD(VideoDriverVersion.HighPart) == B)
- {
- if (HIWORD(VideoDriverVersion.LowPart) > C)
- {
+ } else if (LOWORD(VideoDriverVersion.HighPart) == B) {
+ if (HIWORD(VideoDriverVersion.LowPart) > C) {
return TRUE;
- }
- else if (HIWORD(VideoDriverVersion.LowPart) == C)
- {
- if (LOWORD(VideoDriverVersion.LowPart) >= D)
- {
+ } else if (HIWORD(VideoDriverVersion.LowPart) == C) {
+ if (LOWORD(VideoDriverVersion.LowPart) >= D) {
return TRUE;
}
}
@@ -173,61 +163,45 @@ int FFH264CheckCompatibility(int nWidth, int nHeight, struct AVCodecContext* pAV
int max_ref_frames = 0;
int max_ref_frames_dpb41 = min(11, 8388608/(nWidth * nHeight) );
- if (pBuffer != NULL)
- {
+ 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)
- {
+ if (cur_sps != NULL) {
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)
- {
+ 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 (IsVistaOrAbove())
- {
- if (DriverVersionCheck(VideoDriverVersion, 7, 15, 11, 7800))
- {
+ if (IsVistaOrAbove()) {
+ 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
- {
+ } else {
max_ref_frames = 11;
}
}
- }
- else
- {
- if (DriverVersionCheck(VideoDriverVersion, 6, 14, 11, 7800))
- {
+ } 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)
- {
+ } else if (nPCIVendor == PCIV_S3_Graphics) {
no_level51_support = 0;
- }
- else if (nPCIVendor == PCIV_ATI)
- {
+ } else if (nPCIVendor == PCIV_ATI) {
// HD4xxx and HD5xxx ATI cards support level 5.1 since drivers v8.14.1.6105 (Catalyst 10.4)
- if((nPCIDevice >> 8 == 0x68) || (nPCIDevice >> 8 == 0x94))
- {
- if (DriverVersionCheck(VideoDriverVersion, 8, 14, 1, 6105))
- {
+ if((nPCIDevice >> 8 == 0x68) || (nPCIDevice >> 8 == 0x94)) {
+ if (DriverVersionCheck(VideoDriverVersion, 8, 14, 1, 6105)) {
no_level51_support = 0;
max_ref_frames = 16;
}
@@ -235,8 +209,7 @@ int FFH264CheckCompatibility(int nWidth, int nHeight, struct AVCodecContext* pAV
}
// Check maximum allowed number reference frames
- if (cur_sps->ref_frame_count > max_ref_frames)
- {
+ if (cur_sps->ref_frame_count > max_ref_frames) {
too_much_ref_frames = 1;
}
}
@@ -249,37 +222,38 @@ void CopyScalingMatrix(DXVA_Qmatrix_H264* pDest, DXVA_Qmatrix_H264* pSource, int
{
int i,j;
- switch (nPCIVendor)
- {
- case PCIV_ATI :
- // The ATI way
- memcpy (pDest, pSource, sizeof (DXVA_Qmatrix_H264));
- break;
-
- default :
- // The nVidia way (and other manufacturers compliant with specifications....)
- for (i=0; i<6; i++)
- for (j=0; j<16; j++)
- pDest->bScalingLists4x4[i][j] = pSource->bScalingLists4x4[i][ZZ_SCAN[j]];
-
- for (i=0; i<2; i++)
- for (j=0; j<64; j++)
- pDest->bScalingLists8x8[i][j] = pSource->bScalingLists8x8[i][ZZ_SCAN8[j]];
- break;
+ switch (nPCIVendor) {
+ case PCIV_ATI :
+ // The ATI way
+ memcpy (pDest, pSource, sizeof (DXVA_Qmatrix_H264));
+ break;
+
+ default :
+ // The nVidia way (and other manufacturers compliant with specifications....)
+ for (i=0; i<6; i++)
+ for (j=0; j<16; j++) {
+ pDest->bScalingLists4x4[i][j] = pSource->bScalingLists4x4[i][ZZ_SCAN[j]];
+ }
+
+ for (i=0; i<2; i++)
+ for (j=0; j<64; j++) {
+ pDest->bScalingLists8x8[i][j] = pSource->bScalingLists8x8[i][ZZ_SCAN8[j]];
+ }
+ break;
}
}
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)
+ 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;
@@ -299,34 +273,33 @@ HRESULT FFH264BuildPicParams (DXVA_PicParams_H264* pDXVAPicParams, DXVA_Qmatrix_
cur_sps = &h->sps;
cur_pps = &h->pps;
- if (cur_sps && cur_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;
+ 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;
+ 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;
@@ -346,16 +319,16 @@ HRESULT FFH264BuildPicParams (DXVA_PicParams_H264* pDXVAPicParams, DXVA_Qmatrix_
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->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->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->SliceGroupMap
+ // pDXVAPicParams->SliceGroupMap
pDXVAPicParams->log2_max_frame_num_minus4 = cur_sps->log2_max_frame_num - 4; // log2_max_frame_num_minus4;
@@ -378,25 +351,19 @@ HRESULT FFH264BuildPicParams (DXVA_PicParams_H264* pDXVAPicParams, DXVA_Qmatrix_
pDXVAPicParams->pic_init_qp_minus26 = cur_pps->init_qp - 26;
pDXVAPicParams->pic_init_qs_minus26 = cur_pps->init_qs - 26;
- if (field_pic_flag)
- {
+ if (field_pic_flag) {
pDXVAPicParams->CurrPic.AssociatedFlag = (h->s.picture_structure == PICT_BOTTOM_FIELD);
- if (pDXVAPicParams->CurrPic.AssociatedFlag)
- {
+ if (pDXVAPicParams->CurrPic.AssociatedFlag) {
// Bottom field
pDXVAPicParams->CurrFieldOrderCnt[0] = 0;
pDXVAPicParams->CurrFieldOrderCnt[1] = h->poc_lsb + h->poc_msb;
- }
- else
- {
+ } else {
// Top field
pDXVAPicParams->CurrFieldOrderCnt[0] = h->poc_lsb + h->poc_msb;
pDXVAPicParams->CurrFieldOrderCnt[1] = 0;
}
- }
- else
- {
+ } else {
pDXVAPicParams->CurrPic.AssociatedFlag = 0;
pDXVAPicParams->CurrFieldOrderCnt[0] = h->poc_lsb + h->poc_msb;
pDXVAPicParams->CurrFieldOrderCnt[1] = h->poc_lsb + h->poc_msb;
@@ -416,8 +383,9 @@ void FFH264SetCurrentPicture (int nIndex, DXVA_PicParams_H264* pDXVAPicParams, s
pDXVAPicParams->CurrPic.Index7Bits = nIndex;
- if (h->s.current_picture_ptr)
+ if (h->s.current_picture_ptr) {
h->s.current_picture_ptr->opaque = (void*)nIndex;
+ }
}
@@ -429,51 +397,40 @@ void FFH264UpdateRefFramesList (DXVA_PicParams_H264* pDXVAPicParams, struct AVCo
Picture* pic;
UCHAR AssociatedFlag;
- for(i=0; i<16; i++)
- {
- if (i < h->short_ref_count)
- {
+ for(i=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 if (i >= h->short_ref_count && i < h->long_ref_count)
- {
+ } else if (i >= h->short_ref_count && i < h->long_ref_count) {
// Long list reference frames
pic = h->short_ref[h->short_ref_count + h->long_ref_count - i - 1];
AssociatedFlag = 1;
- }
- else
+ } else {
pic = NULL;
+ }
- if (pic != NULL)
- {
+ if (pic != NULL) {
pDXVAPicParams->FrameNumList[i] = pic->long_ref ? pic->pic_id : pic->frame_num;
- if (pic->field_poc[0] != INT_MAX)
- {
+ if (pic->field_poc[0] != INT_MAX) {
pDXVAPicParams->FieldOrderCntList[i][0] = pic->field_poc [0];
nUsedForReferenceFlags |= 1<<(i*2);
- }
- else
+ } else {
pDXVAPicParams->FieldOrderCntList[i][0] = 0;
+ }
- if (pic->field_poc[1] != INT_MAX)
- {
+ if (pic->field_poc[1] != INT_MAX) {
pDXVAPicParams->FieldOrderCntList[i][1] = pic->field_poc [1];
nUsedForReferenceFlags |= 2<<(i*2);
- }
- else
- {
+ } else {
pDXVAPicParams->FieldOrderCntList[i][1] = 0;
}
pDXVAPicParams->RefFrameList[i].AssociatedFlag = AssociatedFlag;
pDXVAPicParams->RefFrameList[i].Index7Bits = (UCHAR)pic->opaque;
- }
- else
- {
+ } else {
pDXVAPicParams->FrameNumList[i] = 0;
pDXVAPicParams->FieldOrderCntList[i][0] = 0;
pDXVAPicParams->FieldOrderCntList[i][1] = 0;
@@ -490,16 +447,16 @@ 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]->opaque == nFrameNum)
+ for (i=0; i<h->short_ref_count; i++) {
+ if ((int)h->short_ref[i]->opaque == nFrameNum) {
return TRUE;
+ }
}
- for (i=0; i<h->long_ref_count; i++)
- {
- if ((int)h->long_ref[i]->opaque == nFrameNum)
+ for (i=0; i<h->long_ref_count; i++) {
+ if ((int)h->long_ref[i]->opaque == nFrameNum) {
return TRUE;
+ }
}
return FALSE;
@@ -513,8 +470,8 @@ void FF264UpdateRefFrameSliceLong(DXVA_PicParams_H264* pDXVAPicParams, DXVA_Slic
HRESULT hr = E_FAIL;
unsigned int i;
- for(i=0; i<32; i++)
- { pSlice->RefPicList[0][i].AssociatedFlag = 1;
+ for(i=0; i<32; i++) {
+ pSlice->RefPicList[0][i].AssociatedFlag = 1;
pSlice->RefPicList[0][i].bPicEntry = 255;
pSlice->RefPicList[0][i].Index7Bits = 127;
pSlice->RefPicList[1][i].AssociatedFlag = 1;
@@ -522,56 +479,54 @@ void FF264UpdateRefFrameSliceLong(DXVA_PicParams_H264* pDXVAPicParams, DXVA_Slic
pSlice->RefPicList[1][i].Index7Bits = 127;
}
- if(h->slice_type != FF_I_TYPE && h->slice_type != FF_SI_TYPE)
- {
+ if(h->slice_type != FF_I_TYPE && h->slice_type != FF_SI_TYPE) {
if(h->ref_count[0] > 0) {
for(i=0; i < h->ref_count[0]; i++) {
pSlice->RefPicList[0][i].Index7Bits = FFH264FindRefFrameIndex (h->ref_list[0][i].frame_num, pDXVAPicParams);
pSlice->RefPicList[0][i].AssociatedFlag = 0;
if((h->s.picture_structure != PICT_FRAME)) {
if((h->sei_pic_struct == SEI_PIC_STRUCT_BOTTOM_FIELD) ||
- (h->sei_pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM) ||
- (h->sei_pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM_TOP)) {
+ (h->sei_pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM) ||
+ (h->sei_pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM_TOP)) {
pSlice->RefPicList[0][i].AssociatedFlag = 1;
}
}
}
}
- }
- else
+ } else {
pSlice->num_ref_idx_l0_active_minus1 = 0;
+ }
- if(h->slice_type == FF_B_TYPE || h->slice_type == FF_S_TYPE || h->slice_type == FF_BI_TYPE)
- {
+ if(h->slice_type == FF_B_TYPE || h->slice_type == FF_S_TYPE || h->slice_type == FF_BI_TYPE) {
if(h->ref_count[1] > 0) {
for(i=0; i < h->ref_count[1]; i++) {
pSlice->RefPicList[1][i].Index7Bits = FFH264FindRefFrameIndex (h->ref_list[1][i].frame_num, pDXVAPicParams);
pSlice->RefPicList[1][i].AssociatedFlag = 0;
if((h->s.picture_structure != PICT_FRAME)) {
if((h->sei_pic_struct == SEI_PIC_STRUCT_BOTTOM_FIELD) ||
- (h->sei_pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM) ||
- (h->sei_pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM_TOP)) {
+ (h->sei_pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM) ||
+ (h->sei_pic_struct == SEI_PIC_STRUCT_TOP_BOTTOM_TOP)) {
pSlice->RefPicList[1][i].AssociatedFlag = 1;
}
}
}
}
- }
- else
+ } else {
pSlice->num_ref_idx_l1_active_minus1 = 0;
+ }
- if(h->slice_type == FF_I_TYPE || h->slice_type == FF_SI_TYPE)
- {
- for(i = 0; i<16; i++)
+ if(h->slice_type == FF_I_TYPE || h->slice_type == FF_SI_TYPE) {
+ for(i = 0; i<16; i++) {
pSlice->RefPicList[0][i].bPicEntry = 0xff;
+ }
}
if(h->slice_type == FF_P_TYPE || h->slice_type == FF_I_TYPE ||
- h->slice_type ==FF_SP_TYPE || h->slice_type == FF_SI_TYPE)
- {
- for(i = 0; i < 16; i++)
- pSlice->RefPicList[1][i].bPicEntry = 0xff;
+ h->slice_type ==FF_SP_TYPE || h->slice_type == FF_SI_TYPE) {
+ for(i = 0; i < 16; i++) {
+ pSlice->RefPicList[1][i].bPicEntry = 0xff;
+ }
}
}
@@ -585,16 +540,16 @@ HRESULT FFVC1UpdatePictureParam (DXVA_PictureParameters* pPicParams, struct AVCo
{
VC1Context* vc1 = (VC1Context*) pAVCtx->priv_data;
- if (pBuffer)
- {
+ if (pBuffer) {
av_vc1_decode_frame (pAVCtx, pBuffer, nSize);
}
// WARNING : vc1->interlace is not reliable (always set for progressive video on HD-DVD material)
- if (vc1->fcm == 0)
+ if (vc1->fcm == 0) {
*nFieldType = PICT_FRAME;
- else // fcm : 2 or 3 frame or field interlaced
+ } else { // fcm : 2 or 3 frame or field interlaced
*nFieldType = (vc1->tff ? PICT_TOP_FIELD : PICT_BOTTOM_FIELD);
+ }
pPicParams->bPicIntra = (vc1->s.pict_type == FF_I_TYPE);
pPicParams->bPicBackwardPrediction = (vc1->s.pict_type == FF_B_TYPE);
@@ -602,8 +557,8 @@ HRESULT FFVC1UpdatePictureParam (DXVA_PictureParameters* pPicParams, struct AVCo
// 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
+ ((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) |
@@ -637,9 +592,9 @@ HRESULT FFVC1UpdatePictureParam (DXVA_PictureParameters* pPicParams, struct AVCo
// TODO : not finish...
pPicParams->bMVprecisionAndChromaRelation = ((vc1->mv_mode == MV_PMODE_1MV_HPEL_BILIN) << 3) | // 0 for non-bilinear luma motion, 1 for bilinear
- (1 << 2) | // 0 for WMV8, 1 for WMV9 motion
- (0 << 1) | // 1 for WMV8 quarter sample luma motion
- (0); // 0 for quarter sample chroma motion, 1 for half sample chroma
+ (1 << 2) | // 0 for WMV8, 1 for WMV9 motion
+ (0 << 1) | // 1 for WMV8 quarter sample luma motion
+ (0); // 0 for quarter sample chroma motion, 1 for half sample chroma
// Cf §7.1.1.25 in VC1 specification, §3.2.14.3 in DXVA spec
pPicParams->bRcontrol = vc1->rnd;
@@ -660,11 +615,10 @@ HRESULT FFMpeg2DecodeFrame (DXVA_PictureParameters* pPicParams, DXVA_QmatrixData
int got_picture = 0;
Mpeg1Context* s1 = (Mpeg1Context*)pAVCtx->priv_data;
MpegEncContext* s = (MpegEncContext*)&s1->mpeg_enc_ctx;
- AVPacket avpkt;
+ AVPacket avpkt;
- if (pBuffer)
- {
- av_init_packet(&avpkt);
+ if (pBuffer) {
+ av_init_packet(&avpkt);
avpkt.data = pBuffer;
avpkt.size = nSize;
// HACK for CorePNG to decode as normal PNG by default
@@ -718,13 +672,13 @@ HRESULT FFMpeg2DecodeFrame (DXVA_PictureParameters* pPicParams, DXVA_QmatrixData
// 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]);
+ (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);
+ (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);
// TODO : could be interesting to parameter concealment method?
// pPicParams->bBitstreamConcealmentNeed;
@@ -734,16 +688,16 @@ HRESULT FFMpeg2DecodeFrame (DXVA_PictureParameters* pPicParams, DXVA_QmatrixData
pQMatrixData->bNewQmatrix[1] = 1;
pQMatrixData->bNewQmatrix[2] = 1;
pQMatrixData->bNewQmatrix[3] = 1;
- for (i=0; i<64; i++) // intra Y, inter Y, intra chroma, inter chroma
- {
+ for (i=0; i<64; i++) { // intra Y, inter Y, intra chroma, inter chroma
pQMatrixData->Qmatrix[0][i] = s->intra_matrix[ZZ_SCAN8[i]];
pQMatrixData->Qmatrix[1][i] = s->inter_matrix[ZZ_SCAN8[i]];
pQMatrixData->Qmatrix[2][i] = s->chroma_intra_matrix[ZZ_SCAN8[i]];
pQMatrixData->Qmatrix[3][i] = s->chroma_inter_matrix[ZZ_SCAN8[i]];
}
- if (got_picture)
+ if (got_picture) {
*nNextCodecIndex = pFrame->coded_picture_number;
+ }
return S_OK;
}
@@ -764,18 +718,16 @@ int FFIsSkipped(struct AVCodecContext* pAVCtx)
int FFIsInterlaced(struct AVCodecContext* pAVCtx, int nHeight)
{
- if (pAVCtx->codec_id == CODEC_ID_H264)
- {
+ if (pAVCtx->codec_id == CODEC_ID_H264) {
H264Context* h = (H264Context*) pAVCtx->priv_data;
SPS* cur_sps = h->sps_buffers[0];
- if (cur_sps && !cur_sps->frame_mbs_only_flag)
+ if (cur_sps && !cur_sps->frame_mbs_only_flag) {
return 1;
- else
+ } else {
return 0;
- }
- else if (pAVCtx->codec_id == CODEC_ID_VC1)
- {
+ }
+ } else if (pAVCtx->codec_id == CODEC_ID_VC1) {
VC1Context* vc1 = (VC1Context*) pAVCtx->priv_data;
return vc1->interlace;
}
@@ -785,25 +737,24 @@ int FFIsInterlaced(struct AVCodecContext* pAVCtx, int nHeight)
void FFSetThreadNumber(struct AVCodecContext* pAVCtx, int nThreadCount)
{
- if (pAVCtx->thread_count > 1)
- {
+ if (pAVCtx->thread_count > 1) {
avcodec_thread_free (pAVCtx);
pAVCtx->thread_count = 1;
}
- if (nThreadCount > 1)
+ if (nThreadCount > 1) {
avcodec_thread_init(pAVCtx, nThreadCount);
+ }
}
BOOL FFSoftwareCheckCompatibility(struct AVCodecContext* pAVCtx)
{
- if (pAVCtx->codec_id == CODEC_ID_VC1)
- {
+ if (pAVCtx->codec_id == CODEC_ID_VC1) {
VC1Context* vc1 = (VC1Context*) pAVCtx->priv_data;
return !vc1->interlace;
- }
- else
+ } else {
return TRUE;
+ }
}
diff --git a/src/filters/transform/MPCVideoDec/FfmpegContext.h b/src/filters/transform/MPCVideoDec/FfmpegContext.h
index 958b9a16d..1477d329b 100644
--- a/src/filters/transform/MPCVideoDec/FfmpegContext.h
+++ b/src/filters/transform/MPCVideoDec/FfmpegContext.h
@@ -27,8 +27,7 @@
struct AVCodecContext;
struct AVFrame;
-enum PCI_Vendors
-{
+enum PCI_Vendors {
PCIV_ATI = 0x1002,
PCIV_nVidia = 0x10DE,
PCIV_Intel = 0x8086,
diff --git a/src/filters/transform/MPCVideoDec/H264QuantizationMatrix.h b/src/filters/transform/MPCVideoDec/H264QuantizationMatrix.h
index b05941919..011363214 100644
--- a/src/filters/transform/MPCVideoDec/H264QuantizationMatrix.h
+++ b/src/filters/transform/MPCVideoDec/H264QuantizationMatrix.h
@@ -22,8 +22,7 @@
#pragma once
-typedef enum
-{
+typedef enum {
Flat16,
JVTMatrix,
QMatrix,
@@ -31,59 +30,64 @@ typedef enum
} QMatrixH264Type;
-const byte ZZ_SCAN[16] =
-{ 0, 1, 4, 8, 5, 2, 3, 6, 9, 12, 13, 10, 7, 11, 14, 15
+const byte ZZ_SCAN[16] = {
+ 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
+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
};
-const DXVA_Qmatrix_H264 g_QMatrixH264[] =
-{
+const DXVA_Qmatrix_H264 g_QMatrixH264[] = {
// 1) #flat 16
{
{
// INTRA4X4_LUMA =
- { 16,16,16,16,
+ {
+ 16,16,16,16,
16,16,16,16,
16,16,16,16,
16,16,16,16
},
// INTRA4X4_CHROMAU =
- { 16,16,16,16,
+ {
+ 16,16,16,16,
16,16,16,16,
16,16,16,16,
16,16,16,16
},
// INTRA4X4_CHROMAV =
- { 16,16,16,16,
+ {
+ 16,16,16,16,
16,16,16,16,
16,16,16,16,
16,16,16,16
},
// INTER4X4_LUMA =
- { 16,16,16,16,
+ {
+ 16,16,16,16,
16,16,16,16,
16,16,16,16,
16,16,16,16
},
// INTER4X4_CHROMAU =
- { 16,16,16,16,
+ {
+ 16,16,16,16,
16,16,16,16,
16,16,16,16,
16,16,16,16
},
// INTER4X4_CHROMAV =
- { 16,16,16,16,
+ {
+ 16,16,16,16,
16,16,16,16,
16,16,16,16,
16,16,16,16
@@ -91,7 +95,8 @@ const DXVA_Qmatrix_H264 g_QMatrixH264[] =
},
{
// INTRA8X8_LUMA =
- { 16,16,16,16,16,16,16,16,
+ {
+ 16,16,16,16,16,16,16,16,
16,16,16,16,16,16,16,16,
16,16,16,16,16,16,16,16,
16,16,16,16,16,16,16,16,
@@ -102,7 +107,8 @@ const DXVA_Qmatrix_H264 g_QMatrixH264[] =
},
// INTER8X8_LUMA =
- { 16,16,16,16,16,16,16,16,
+ {
+ 16,16,16,16,16,16,16,16,
16,16,16,16,16,16,16,16,
16,16,16,16,16,16,16,16,
16,16,16,16,16,16,16,16,
@@ -117,42 +123,48 @@ const DXVA_Qmatrix_H264 g_QMatrixH264[] =
{
{
// INTRA4X4_LUMA
- { 6,13,20,28,
+ {
+ 6,13,20,28,
13,20,28,32,
20,28,32,37,
28,32,37,42
},
// INTRA4X4_CHROMAU
- { 6,13,20,28,
+ {
+ 6,13,20,28,
13,20,28,32,
20,28,32,37,
28,32,37,42
},
// INTRA4X4_CHROMAV
- { 6,13,20,28,
+ {
+ 6,13,20,28,
13,20,28,32,
20,28,32,37,
28,32,37,42
},
// INTER4X4_LUMA
- { 10,14,20,24,
+ {
+ 10,14,20,24,
14,20,24,27,
20,24,27,30,
24,27,30,34
},
// INTER4X4_CHROMAU
- { 10,14,20,24,
+ {
+ 10,14,20,24,
14,20,24,27,
20,24,27,30,
24,27,30,34
},
// INTER4X4_CHROMAV
- { 10,14,20,24,
+ {
+ 10,14,20,24,
14,20,24,27,
20,24,27,30,
24,27,30,34
@@ -160,7 +172,8 @@ const DXVA_Qmatrix_H264 g_QMatrixH264[] =
},
{
// INTRA8X8_LUMA
- { 6,10,13,16,18,23,25,27,
+ {
+ 6,10,13,16,18,23,25,27,
10,11,16,18,23,25,27,29,
13,16,18,23,25,27,29,31,
16,18,23,25,27,29,31,33,
@@ -171,7 +184,8 @@ const DXVA_Qmatrix_H264 g_QMatrixH264[] =
},
// INTER8X8_LUMA
- { 9,13,15,17,19,21,22,24,
+ {
+ 9,13,15,17,19,21,22,24,
13,13,17,19,21,22,24,25,
15,17,19,21,22,24,25,27,
17,19,21,22,24,25,27,28,
@@ -187,42 +201,48 @@ const DXVA_Qmatrix_H264 g_QMatrixH264[] =
{
{
// INTRA4X4_LUMA =
- { 6,12,19,26,
+ {
+ 6,12,19,26,
12,19,26,31,
19,26,31,35,
26,31,35,39
},
// INTRA4X4_CHROMAU =
- { 6,12,19,26,
+ {
+ 6,12,19,26,
12,19,26,31,
19,26,31,35,
26,31,35,39
},
// INTRA4X4_CHROMAV =
- { 6,12,19,26,
+ {
+ 6,12,19,26,
12,19,26,31,
19,26,31,35,
26,31,35,39
},
// INTER4X4_LUMA =
- { 9,13,18,21,
+ {
+ 9,13,18,21,
13,18,21,24,
18,21,24,27,
21,24,27,30
},
// INTER4X4_CHROMAU =
- { 9,13,18,21,
+ {
+ 9,13,18,21,
13,18,21,24,
18,21,24,27,
21,24,27,30
},
// INTER4X4_CHROMAV =
- { 9,13,18,21,
+ {
+ 9,13,18,21,
13,18,21,24,
18,21,24,27,
21,24,27,30
@@ -230,7 +250,8 @@ const DXVA_Qmatrix_H264 g_QMatrixH264[] =
},
{
// INTRA8X8_LUMA =
- { 6,10,13,16,19,24,26,28,
+ {
+ 6,10,13,16,19,24,26,28,
10,12,16,19,24,26,28,31,
13,16,19,24,26,28,31,33,
16,19,24,26,28,31,33,35,
@@ -241,7 +262,8 @@ const DXVA_Qmatrix_H264 g_QMatrixH264[] =
},
// INTER8X8_LUMA =
- { 9,12,14,16,18,19,21,22,
+ {
+ 9,12,14,16,18,19,21,22,
12,13,16,18,19,21,22,24,
14,16,18,19,21,22,24,25,
16,18,19,21,22,24,25,27,
@@ -257,42 +279,48 @@ const DXVA_Qmatrix_H264 g_QMatrixH264[] =
{
{
// INTRA4X4_LUMA =
- { 7,16,22,24,
+ {
+ 7,16,22,24,
16,22,24,28,
18,22,27,33,
22,24,32,47
},
// INTRA4X4_CHROMAU =
- { 7,16,22,24,
+ {
+ 7,16,22,24,
16,22,24,28,
18,22,27,33,
22,24,32,47
},
// INTRA4X4_CHROMAV =
- { 7,16,22,24,
+ {
+ 7,16,22,24,
16,22,24,28,
18,22,27,33,
22,24,32,47
},
// INTER4X4_LUMA =
- { 13,15,17,18,
+ {
+ 13,15,17,18,
15,17,18,20,
17,18,21,22,
18,20,22,25
},
// INTER4X4_CHROMAU =
- { 13,15,17,18,
+ {
+ 13,15,17,18,
15,17,18,20,
17,18,21,22,
18,20,22,25
},
// INTER4X4_CHROMAV =
- { 13,15,17,18,
+ {
+ 13,15,17,18,
15,17,18,20,
17,18,21,22,
18,20,22,25
@@ -300,7 +328,8 @@ const DXVA_Qmatrix_H264 g_QMatrixH264[] =
},
{
// INTRA8X8_LUMA =
- { 7,13,16,18,22,22,24,28,
+ {
+ 7,13,16,18,22,22,24,28,
13,13,18,20,22,24,28,31,
16,18,22,22,24,28,28,32,
18,18,22,22,24,28,31,33,
@@ -311,7 +340,8 @@ const DXVA_Qmatrix_H264 g_QMatrixH264[] =
},
// INTER8X8_LUMA =
- { 13,14,15,16,17,17,18,19,
+ {
+ 13,14,15,16,17,17,18,19,
14,15,16,17,17,18,19,20,
15,16,17,17,18,19,20,21,
16,17,17,18,19,20,21,22,
diff --git a/src/filters/transform/MPCVideoDec/IMPCVideoDecFilter.h b/src/filters/transform/MPCVideoDec/IMPCVideoDecFilter.h
index 45b204c33..dfd8ad5ec 100644
--- a/src/filters/transform/MPCVideoDec/IMPCVideoDecFilter.h
+++ b/src/filters/transform/MPCVideoDec/IMPCVideoDecFilter.h
@@ -24,8 +24,7 @@
#pragma once
// Internal codec list (use to enable/disable codec in standalone mode)
-typedef enum
-{
+typedef enum {
MPCVD_H264 = 1,
MPCVD_VC1 = MPCVD_H264<<1,
MPCVD_XVID = MPCVD_VC1<<1,
@@ -45,8 +44,7 @@ typedef enum
interface __declspec(uuid("CDC3B5B3-A8B0-4c70-A805-9FC80CDEF262"))
IMPCVideoDecFilter :
-public IUnknown
-{
+public IUnknown {
STDMETHOD(Apply()) = 0;
STDMETHOD(SetThreadNumber(int nValue)) = 0;
diff --git a/src/filters/transform/MPCVideoDec/MPCAudioDecFilter.cpp b/src/filters/transform/MPCVideoDec/MPCAudioDecFilter.cpp
deleted file mode 100644
index ce310b302..000000000
--- a/src/filters/transform/MPCVideoDec/MPCAudioDecFilter.cpp
+++ /dev/null
@@ -1,380 +0,0 @@
-/*
- * $Id$
- *
- * (C) 2006-2007 see AUTHORS
- *
- * This file is part of mplayerc.
- *
- * Mplayerc 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 3 of the License, or
- * (at your option) any later version.
- *
- * Mplayerc 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, see <http://www.gnu.org/licenses/>.
- *
- */
-
-
-#include "stdafx.h"
-#include <math.h>
-#include <atlbase.h>
-#include <mmreg.h>
-
-#include "PODtypes.h"
-#include "avcodec.h"
-
-#include "MPCAudioDecFilter.h"
-
-#include "../../../DSUtil/DSUtil.h"
-
-#include <initguid.h>
-#include <moreuuids.h>
-
-
-typedef struct
-{
- const CLSID* clsMinorType;
- const enum CodecID nFFCodec;
- const int fourcc;
-} FFMPEG_CODECS;
-
-
-const FFMPEG_CODECS ffCodecs[] =
-{
- // AMVA
- { &MEDIASUBTYPE_IMA_AMV, CODEC_ID_ADPCM_IMA_AMV, MAKEFOURCC('A','M','V','A') },
-};
-
-const AMOVIESETUP_MEDIATYPE CMPCAudioDecFilter::sudPinTypesIn[] =
-{
- { &MEDIATYPE_Audio, &MEDIASUBTYPE_IMA_AMV },
-};
-const int CMPCAudioDecFilter::sudPinTypesInCount = countof(CMPCAudioDecFilter::sudPinTypesIn);
-
-
-const AMOVIESETUP_MEDIATYPE CMPCAudioDecFilter::sudPinTypesOut[] =
-{
- {&MEDIATYPE_Audio, &MEDIASUBTYPE_PCM}
-};
-const int CMPCAudioDecFilter::sudPinTypesOutCount = countof(CMPCAudioDecFilter::sudPinTypesOut);
-
-
-CMPCAudioDecFilter::CMPCAudioDecFilter(LPUNKNOWN lpunk, HRESULT* phr)
- : CTransformFilter(NAME("CMPCAudioDecFilter"), lpunk, __uuidof(this))
-{
- if(!(m_pInput = new CTransformInputPin(NAME("CAudioDecInputPin"), this, phr, L"In"))) *phr = E_OUTOFMEMORY;
- if(FAILED(*phr)) return;
-
- if(!(m_pOutput = new CTransformOutputPin(NAME("CAudioDecOutputPin"), this, phr, L"Out"))) *phr = E_OUTOFMEMORY;
- if(FAILED(*phr)) {
- delete m_pInput, m_pInput = NULL;
- return;
- }
-
- m_iSampleFormat = SAMPLE_FMT_S16;
-
- m_pAVCodec = NULL;
- m_pAVCtx = NULL;
- m_pFrame = NULL;
- m_nCodecNb = -1;
-
- avcodec_init();
- avcodec_register_all();
- av_log_set_callback(LogLibAVCodec);
-
-}
-
-CMPCAudioDecFilter::~CMPCAudioDecFilter(void)
-{
- Cleanup();
-}
-
-void CMPCAudioDecFilter::Cleanup()
-{
- if (m_pAVCtx)
- {
- avcodec_thread_free (m_pAVCtx);
- av_free(m_pAVCtx);
- }
- if (m_pFrame) av_free(m_pFrame);
-
- m_pAVCodec = NULL;
- m_pAVCtx = NULL;
- m_pFrame = NULL;
- m_nCodecNb = -1;
-}
-
-void CMPCAudioDecFilter::LogLibAVCodec(void* par,int level,const char *fmt,va_list valist)
-{
-#ifdef _DEBUG
- //AVCodecContext* m_pAVCtx = (AVCodecContext*) par;
-
- //char Msg [500];
- //snprintf (Msg, sizeof(Msg), fmt, valist);
- //TRACE("AVLIB : %s", Msg);
-#endif
-}
-
-STDMETHODIMP CMPCAudioDecFilter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
-{
- return
-// QI(IMPCVideoDecFilter)
-// QI(ISpecifyPropertyPages)
-// QI(ISpecifyPropertyPages2)
- __super::NonDelegatingQueryInterface(riid, ppv);
-}
-
-HRESULT CMPCAudioDecFilter::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;
-}
-
-HRESULT CMPCAudioDecFilter::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties)
-{
- return S_OK;
-}
-
-HRESULT CMPCAudioDecFilter::CheckInputType(const CMediaType* mtIn)
-{
- for (int i=0; i<sizeof(sudPinTypesIn)/sizeof(AMOVIESETUP_MEDIATYPE); i++)
- {
- if ((mtIn->majortype == *sudPinTypesIn[i].clsMajorType) &&
- (mtIn->subtype == *sudPinTypesIn[i].clsMinorType))
- return S_OK;
- }
-
- return VFW_E_TYPE_NOT_ACCEPTED;
-}
-
-HRESULT CMPCAudioDecFilter::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(GetSpeakerConfig(ac3) < 0 && (subtype == MEDIASUBTYPE_DOLBY_AC3 || subtype == MEDIASUBTYPE_WAVE_DOLBY_AC3)
- //|| GetSpeakerConfig(dts) < 0 && (subtype == MEDIASUBTYPE_DTS || subtype == MEDIASUBTYPE_WAVE_DTS))
- //{
- // *pmt = CreateMediaTypeSPDIF();
- //}
- //else if(subtype == MEDIASUBTYPE_Vorbis2)
- //{
- // *pmt = CreateMediaType(GetSampleFormat(), m_vorbis.vi.rate, m_vorbis.vi.channels);
- //}
- //else
- //{
- *pmt = CreateMediaType(GetSampleFormat(), wfe->nSamplesPerSec, min(2, wfe->nChannels));
- //}
-
- return S_OK;
-}
-
-HRESULT CMPCAudioDecFilter::SetMediaType(PIN_DIRECTION direction,const CMediaType *pmt)
-{
- return __super::SetMediaType(direction, pmt);
-}
-
-HRESULT CMPCAudioDecFilter::CompleteConnect(PIN_DIRECTION direction, IPin* pReceivePin)
-{
- int nNewCodec;
-
- if (direction == PINDIR_OUTPUT)
- {
- CMediaType& mt = m_pInput->CurrentMediaType();
- nNewCodec = FindCodec(&mt);
- if ((direction == PINDIR_OUTPUT) && (nNewCodec != -1) && (nNewCodec != m_nCodecNb))
- {
- WAVEFORMATEX* wfex = (WAVEFORMATEX*) mt.pbFormat;
- Cleanup();
-
- m_nCodecNb = nNewCodec;
- m_pInput->CurrentMediaType();
-
- m_pAVCodec = avcodec_find_decoder(ffCodecs[nNewCodec].nFFCodec);
- CheckPointer (m_pAVCodec, VFW_E_UNSUPPORTED_AUDIO);
-
- m_pAVCtx = avcodec_alloc_context();
- CheckPointer (m_pAVCtx, E_POINTER);
-
- m_pAVCtx->sample_rate = wfex->nSamplesPerSec;
- m_pAVCtx->channels = wfex->nChannels;
-
- m_pAVCtx->bit_rate = wfex->nAvgBytesPerSec*8;
- m_pAVCtx->bits_per_coded_sample = wfex->wBitsPerSample;
- m_pAVCtx->block_align = wfex->nBlockAlign;
-
- /*if (codecId==CODEC_ID_FLAC && extradata.size>=4 && *(FOURCC*)extradata.data==mmioFOURCC('f','L','a','C')) // HACK
- {
- avctx->extradata=extradata.data+8;
- avctx->extradata_size=34;
- }
- else if (codecId==CODEC_ID_COOK && mt.formattype==FORMAT_WaveFormatEx && mt.pbFormat)
- {
- avctx->extradata=mt.pbFormat+sizeof(WAVEFORMATEX);
- avctx->extradata_size=mt.cbFormat-sizeof(WAVEFORMATEX);
- for (;avctx->extradata_size;avctx->extradata=(uint8_t*)avctx->extradata+1,avctx->extradata_size--)
- if (memcmp(avctx->extradata,"cook",4)==0)
- {
- avctx->extradata=(uint8_t*)avctx->extradata+12;
- avctx->extradata_size-=12;
- break;
- }
- }
- else
- {
- avctx->extradata=extradata.data;
- avctx->extradata_size=(int)extradata.size;
- }
- if (codecId==CODEC_ID_VORBIS && mt.formattype==FORMAT_VorbisFormat2)
- {
- const VORBISFORMAT2 *vf2=(const VORBISFORMAT2*)mt.pbFormat;
- avctx->vorbis_header_size[0]=vf2->HeaderSize[0];
- avctx->vorbis_header_size[1]=vf2->HeaderSize[1];
- avctx->vorbis_header_size[2]=vf2->HeaderSize[2];
- }
- if (libavcodec->avcodec_open(avctx,avcodec)<0) return false;
- codecinited=true;
- switch (avctx->sample_fmt)
- {
- case SAMPLE_FMT_S16:fmt.sf=TsampleFormat::SF_PCM16;break;
- case SAMPLE_FMT_FLT:fmt.sf=TsampleFormat::SF_FLOAT32;break;
- }
- */
-
- if (avcodec_open(m_pAVCtx, m_pAVCodec)<0)
- return VFW_E_INVALIDMEDIATYPE;
- }
- }
-
- return __super::CompleteConnect (direction, pReceivePin);
-}
-
-HRESULT CMPCAudioDecFilter::Transform(IMediaSample* pIn)
-{
- HRESULT hr = S_OK;
- //BYTE* pDataIn = NULL;
- //UINT nSize;
- //int got_picture;
- //REFERENCE_TIME rtStart = _I64_MIN, rtStop = _I64_MIN;
-
- //if(FAILED(hr = pIn->GetPointer(&pDataIn)))
- // return hr;
-
- //nSize = pIn->GetActualDataLength();
- //hr = pIn->GetTime(&rtStart, &rtStop);
-
- ////FILE* File = fopen ("e:\\temp\\h264.bin", "wb");
- ////fwrite (pDataIn, nSize, 1, File);
- ////fclose (File);
-
- //int used_bytes;
-
- //m_pAVCtx->parserRtStart=&rtStart;
- //
- //while (nSize > 0)
- //{
- // used_bytes = avcodec_decode_video (m_pAVCtx, m_pFrame, &got_picture, pDataIn, nSize);
- // if (!got_picture || !m_pFrame->data[0]) return S_FALSE;
-
- // if(pIn->IsPreroll() == S_OK || rtStart < 0)
- // return S_OK;
-
- // CComPtr<IMediaSample> pOut;
- // BYTE* pDataOut = NULL;
- // if(FAILED(hr = GetDeliveryBuffer(m_pAVCtx->width, m_pAVCtx->height, &pOut)) || FAILED(hr = pOut->GetPointer(&pDataOut)))
- // return hr;
-
- // TRACE ("CMPCAudioDecFilter::Transform %I64d - %I64d\n", rtStart, rtStop);
-
- // //rtStart = m_pFrame->rtStart;
- // //rtStop = m_pFrame->rtStart + 1;
-
- // pOut->SetTime(&rtStart, &rtStop);
- // pOut->SetDiscontinuity(pIn->IsDiscontinuity() == S_OK);
-
- // CopyBuffer(pDataOut, m_pFrame->data, m_pAVCtx->width, m_pAVCtx->height, m_pFrame->linesize[0], MEDIASUBTYPE_I420, false);
-
- // hr = m_pOutput->Deliver(pOut);
-
- // nSize -= used_bytes;
- // pDataIn += used_bytes;
- //}
-
- return hr;
-}
-
-int CMPCAudioDecFilter::FindCodec(const CMediaType* mtIn)
-{
- for (int i=0; i<countof(ffCodecs); i++)
- if (mtIn->subtype == *ffCodecs[i].clsMinorType)
- return i;
-
- return -1;
-}
-
-STDMETHODIMP_(SampleFormat) CMPCAudioDecFilter::GetSampleFormat()
-{
-// CAutoLock cAutoLock(&m_csProps);
- return m_iSampleFormat;
-}
-
-CMediaType CMPCAudioDecFilter::CreateMediaType(SampleFormat sf, DWORD nSamplesPerSec, WORD nChannels, DWORD dwChannelMask)
-{
- CMediaType mt;
-
- mt.majortype = MEDIATYPE_Audio;
- mt.subtype = sf == SAMPLE_FMT_FLT ? 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 SAMPLE_FMT_S16:
- wfe->wBitsPerSample = 16;
- break;
- case SAMPLE_FMT_S32:
- case SAMPLE_FMT_FLT:
- wfe->wBitsPerSample = 32;
- break;
- }
- wfe->nBlockAlign = wfe->nChannels*wfe->wBitsPerSample/8;
- wfe->nAvgBytesPerSec = wfe->nSamplesPerSec*wfe->nBlockAlign;
-
- // FIXME: 32 bit only seems to work with WAVE_FORMAT_EXTENSIBLE
- if(dwChannelMask == 0 && (sf == SAMPLE_FMT_S32))
- 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;
-}
diff --git a/src/filters/transform/MPCVideoDec/MPCAudioDecFilter.h b/src/filters/transform/MPCVideoDec/MPCAudioDecFilter.h
deleted file mode 100644
index 938870ae1..000000000
--- a/src/filters/transform/MPCVideoDec/MPCAudioDecFilter.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * $Id$
- *
- * (C) 2006-2007 see AUTHORS
- *
- * This file is part of mplayerc.
- *
- * Mplayerc 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 3 of the License, or
- * (at your option) any later version.
- *
- * Mplayerc 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, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#pragma once
-
-enum SampleFormat;
-
-class __declspec(uuid("BF67339B-465E-4c5a-AE2D-DC4EE17EA272"))
- CMPCAudioDecFilter
- : public CTransformFilter
-{
-public:
-
- const static AMOVIESETUP_MEDIATYPE sudPinTypesIn[];
- const static int sudPinTypesInCount;
- const static AMOVIESETUP_MEDIATYPE sudPinTypesOut[];
- const static int sudPinTypesOutCount;
-
- CMPCAudioDecFilter(LPUNKNOWN lpunk, HRESULT* phr);
- virtual ~CMPCAudioDecFilter();
-
- DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
-
- HRESULT SetMediaType(PIN_DIRECTION direction,const CMediaType *pmt);
- HRESULT CheckInputType(const CMediaType* mtIn);
- HRESULT Transform(IMediaSample* pIn);
-
- HRESULT GetMediaType(int iPosition, CMediaType* pmt);
- HRESULT CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut);
- HRESULT DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties);
-
-// HRESULT DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties);
- HRESULT CMPCAudioDecFilter::CompleteConnect(PIN_DIRECTION direction, IPin* pReceivePin);
-
- STDMETHODIMP_(SampleFormat) GetSampleFormat();
- CMediaType CreateMediaType(SampleFormat sf, DWORD nSamplesPerSec, WORD nChannels, DWORD dwChannelMask = 0);
-
-protected :
- SampleFormat m_iSampleFormat;
-
- AVCodec* m_pAVCodec;
- AVCodecContext* m_pAVCtx;
- AVFrame* m_pFrame;
- int m_nCodecNb;
-
- int FindCodec(const CMediaType* mtIn);
- void Cleanup();
-
- static void LogLibAVCodec(void* par,int level,const char *fmt,va_list valist);
-};
diff --git a/src/filters/transform/MPCVideoDec/MPCFfmpegDec.cpp b/src/filters/transform/MPCVideoDec/MPCFfmpegDec.cpp
index 41ab0c7af..bbfd7beee 100644
--- a/src/filters/transform/MPCVideoDec/MPCFfmpegDec.cpp
+++ b/src/filters/transform/MPCVideoDec/MPCFfmpegDec.cpp
@@ -29,21 +29,18 @@
// Workaround: graphedit crashes when a filter exposes more than 115 input MediaTypes!
-const AMOVIESETUP_PIN sudpPinsVideoDec[] =
-{
+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}
};
-const AMOVIESETUP_FILTER sudFilters[] =
-{
+const AMOVIESETUP_FILTER sudFilters[] = {
{&__uuidof(CMPCVideoDecFilter), L"MPC - Video decoder", /*MERIT_DO_NOT_USE*/0x40000001, countof(sudpPinsVideoDec), sudpPinsVideoDec, CLSID_LegacyAmFilterCategory}
};
-CFactoryTemplate g_Templates[] =
-{
+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> >},
diff --git a/src/filters/transform/MPCVideoDec/MPCVideoDecFilter.cpp b/src/filters/transform/MPCVideoDec/MPCVideoDecFilter.cpp
index 1832b7802..4770a480d 100644
--- a/src/filters/transform/MPCVideoDec/MPCVideoDecFilter.cpp
+++ b/src/filters/transform/MPCVideoDec/MPCVideoDecFilter.cpp
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * (C) 2006-2010 see AUTHORS
+ * (C) 2006-2011 see AUTHORS
*
* This file is part of mplayerc.
*
@@ -52,35 +52,34 @@ extern "C"
#define ROUND_FRAMERATE(var,FrameRate) if (labs ((long)(var - FrameRate)) < FrameRate*1/100) var = FrameRate;
-typedef struct
-{
+typedef struct {
const int PicEntryNumber;
const UINT PreferedConfigBitstream;
const GUID* Decoder[MAX_SUPPORTED_MODE];
const WORD RestrictedMode[MAX_SUPPORTED_MODE];
} DXVA_PARAMS;
-typedef struct
-{
+typedef struct {
const CLSID* clsMinorType;
const enum CodecID nFFCodec;
const int fourcc;
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;
+ 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;
-typedef enum
-{
+typedef enum {
ffYCbCr_RGB_coeff_ITUR_BT601 = 0,
ffYCbCr_RGB_coeff_ITUR_BT709 = 1,
ffYCbCr_RGB_coeff_SMPTE240M = 2,
@@ -105,8 +104,7 @@ struct TYCbCr2RGB_coeffs {
int cspOptionsBlackCutoff,
int cspOptionsChromaCutoff,
double cspOptionsRGB_WhiteLevel,
- double cspOptionsRGB_BlackLevel)
- {
+ double cspOptionsRGB_BlackLevel) {
if (cspOptionsIturBt == ffYCbCr_RGB_coeff_ITUR_BT601) {
Kr = 0.299;
Kg = 0.587;
@@ -139,8 +137,7 @@ struct TYCbCr2RGB_coeffs {
// DXVA modes supported for Mpeg2
-DXVA_PARAMS DXVA_Mpeg2 =
-{
+DXVA_PARAMS DXVA_Mpeg2 = {
9, // PicEntryNumber
1, // PreferedConfigBitstream
{ &DXVA2_ModeMPEG2_VLD, &GUID_NULL },
@@ -148,16 +145,14 @@ DXVA_PARAMS DXVA_Mpeg2 =
};
// DXVA modes supported for H264
-DXVA_PARAMS DXVA_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_VISTA =
-{
+DXVA_PARAMS DXVA_H264_VISTA = {
22, // PicEntryNumber
2, // PreferedConfigBitstream
{ &DXVA2_ModeH264_E, &DXVA2_ModeH264_F, &DXVA_Intel_H264_ClearVideo, &GUID_NULL },
@@ -165,16 +160,14 @@ DXVA_PARAMS DXVA_H264_VISTA =
};
// DXVA modes supported for VC1
-DXVA_PARAMS DXVA_VC1 =
-{
+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, MAKEFOURCC('F','L','V','1'), NULL },
@@ -348,8 +341,7 @@ FFMPEG_CODECS ffCodecs[] =
};
/* Important: the order should be exactly the same as in ffCodecs[] */
-const AMOVIESETUP_MEDIATYPE CMPCVideoDecFilter::sudPinTypesIn[] =
-{
+const AMOVIESETUP_MEDIATYPE CMPCVideoDecFilter::sudPinTypesIn[] = {
#if HAS_FFMPEG_VIDEO_DECODERS
// Flash video
{ &MEDIATYPE_Video, &MEDIASUBTYPE_FLV1 },
@@ -530,8 +522,7 @@ bool* CMPCVideoDecFilter::FFmpegFilters = NULL;
bool* CMPCVideoDecFilter::DXVAFilters = NULL;
bool CMPCVideoDecFilter::m_ref_frame_count_check_skip = false;
-const AMOVIESETUP_MEDIATYPE CMPCVideoDecFilter::sudPinTypesOut[] =
-{
+const AMOVIESETUP_MEDIATYPE CMPCVideoDecFilter::sudPinTypesOut[] = {
{&MEDIATYPE_Video, &MEDIASUBTYPE_NV12},
{&MEDIATYPE_Video, &MEDIASUBTYPE_NV24}
};
@@ -545,8 +536,7 @@ BOOL CALLBACK EnumFindProcessWnd (HWND hwnd, LPARAM lParam)
GetWindowThreadProcessId (hwnd, &procid);
GetClassName (hwnd, WindowClass, countof(WindowClass));
- if (procid == GetCurrentProcessId() && _tcscmp (WindowClass, _T("MediaPlayerClassicW")) == 0)
- {
+ if (procid == GetCurrentProcessId() && _tcscmp (WindowClass, _T("MediaPlayerClassicW")) == 0) {
HWND* pWnd = (HWND*) lParam;
*pWnd = hwnd;
return FALSE;
@@ -559,20 +549,25 @@ CMPCVideoDecFilter::CMPCVideoDecFilter(LPUNKNOWN lpunk, HRESULT* phr)
{
HWND hWnd = NULL;
- if(IsVistaOrAbove())
- {
- for (int i=0; i<countof(ffCodecs); i++)
- {
- if(ffCodecs[i].nFFCodec == CODEC_ID_H264)
+ if(IsVistaOrAbove()) {
+ 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(phr) {
+ *phr = S_OK;
+ }
- if (m_pOutput) delete m_pOutput;
+ if (m_pOutput) {
+ delete m_pOutput;
+ }
m_pOutput = DNew CVideoDecOutputPin(NAME("CVideoDecOutputPin"), this, phr, L"Output");
- if(!m_pOutput) *phr = E_OUTOFMEMORY;
+ if(!m_pOutput) {
+ *phr = E_OUTOFMEMORY;
+ }
m_pCpuId = DNew CCpuId();
m_pAVCodec = NULL;
@@ -618,20 +613,37 @@ CMPCVideoDecFilter::CMPCVideoDecFilter(LPUNKNOWN lpunk, HRESULT* phr)
m_sar.SetSize(1,1);
CRegKey key;
- if(ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPC Video Decoder"), KEY_READ))
- {
+ if(ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPC Video Decoder"), KEY_READ)) {
DWORD dw;
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("ThreadNumber"), dw)) m_nThreadNumber = dw;
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("DiscardMode"), dw)) m_nDiscardMode = 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;
- 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("ThreadNumber"), dw)) {
+ m_nThreadNumber = dw;
+ }
+ if(ERROR_SUCCESS == key.QueryDWORDValue(_T("DiscardMode"), dw)) {
+ m_nDiscardMode = 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;
+ }
+ 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(m_nDXVACheckCompatibility > 3) m_nDXVACheckCompatibility = 1; // skip level check by default
+ 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;
@@ -649,23 +661,28 @@ CMPCVideoDecFilter::CMPCVideoDecFilter(LPUNKNOWN lpunk, HRESULT* phr)
int nCodecs = countof(ffCodecs);
int nPinTypes = countof(sudPinTypesIn);
ASSERT (nCodecs == nPinTypes);
- for (int i=0; i<nPinTypes; i++)
+ for (int i=0; i<nPinTypes; i++) {
ASSERT (ffCodecs[i].clsMinorType == sudPinTypesIn[i].clsMinorType);
+ }
#endif
}
UINT CMPCVideoDecFilter::GetAdapter(IDirect3D9* pD3D, HWND hWnd)
{
- if(hWnd == NULL || pD3D == NULL)
+ if(hWnd == NULL || pD3D == NULL) {
return D3DADAPTER_DEFAULT;
+ }
HMONITOR hMonitor = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST);
- if(hMonitor == NULL) return D3DADAPTER_DEFAULT;
+ if(hMonitor == NULL) {
+ return D3DADAPTER_DEFAULT;
+ }
- for(UINT adp = 0, num_adp = pD3D->GetAdapterCount(); adp < num_adp; ++adp)
- {
+ for(UINT adp = 0, num_adp = pD3D->GetAdapterCount(); adp < num_adp; ++adp) {
HMONITOR hAdpMon = pD3D->GetAdapterMonitor(adp);
- if(hAdpMon == hMonitor) return adp;
+ if(hAdpMon == hMonitor) {
+ return adp;
+ }
}
return D3DADAPTER_DEFAULT;
@@ -680,11 +697,9 @@ void CMPCVideoDecFilter::DetectVideoCard(HWND hWnd)
m_VideoDriverVersion.LowPart = 0;
pD3D9 = Direct3DCreate9(D3D_SDK_VERSION);
- if (pD3D9)
- {
+ if (pD3D9) {
D3DADAPTER_IDENTIFIER9 adapterIdentifier;
- if (pD3D9->GetAdapterIdentifier(GetAdapter(pD3D9, hWnd), 0, &adapterIdentifier) == S_OK)
- {
+ if (pD3D9->GetAdapterIdentifier(GetAdapter(pD3D9, hWnd), 0, &adapterIdentifier) == S_OK) {
m_nPCIVendor = adapterIdentifier.VendorId;
m_nPCIDevice = adapterIdentifier.DeviceId;
m_VideoDriverVersion = adapterIdentifier.DriverVersion;
@@ -712,15 +727,12 @@ bool CMPCVideoDecFilter::IsVideoInterlaced()
void CMPCVideoDecFilter::UpdateFrameTime (REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop)
{
- if (rtStart == _I64_MIN)
- {
+ if (rtStart == _I64_MIN) {
// If reference time has not been set by splitter, extrapolate start time
// from last known start time already delivered
rtStart = m_rtLastStart + m_rtAvrTimePerFrame*m_nCountEstimated;
m_nCountEstimated++;
- }
- else
- {
+ } else {
// Known start time, set as new reference
m_rtLastStart = rtStart;
m_nCountEstimated = 1;
@@ -738,13 +750,10 @@ void CMPCVideoDecFilter::GetOutputSize(int& w, int& h, int& arx, int& ary, int &
w = PictWidthRounded();
h = PictHeightRounded();
#else
- if (m_nDXVAMode == MODE_SOFTWARE)
- {
+ if (m_nDXVAMode == MODE_SOFTWARE) {
w = m_nWidth;
h = m_nHeight;
- }
- else
- {
+ } else {
// DXVA surface are multiple of 16 pixels!
w = PictWidthRounded();
h = PictHeightRounded();
@@ -778,111 +787,105 @@ int CMPCVideoDecFilter::PictHeightRounded()
int CMPCVideoDecFilter::FindCodec(const CMediaType* mtIn)
{
for (int i=0; i<countof(ffCodecs); i++)
- if (mtIn->subtype == *ffCodecs[i].clsMinorType)
- {
+ if (mtIn->subtype == *ffCodecs[i].clsMinorType) {
#ifndef REGISTER_FILTER
- switch (ffCodecs[i].nFFCodec)
- {
- case CODEC_ID_H264 :
- #if INTERNAL_DECODER_H264_DXVA
- m_bUseDXVA = DXVAFilters && DXVAFilters[TRA_DXVA_H264];
- #else
- m_bUseDXVA = false;
- #endif
- #if INTERNAL_DECODER_H264
- m_bUseFFmpeg = FFmpegFilters && FFmpegFilters[FFM_H264];
- #else
- m_bUseFFmpeg = false;
- #endif
- break;
- case CODEC_ID_VC1 :
- #if INTERNAL_DECODER_VC1_DXVA
- m_bUseDXVA = DXVAFilters && DXVAFilters[TRA_DXVA_VC1];
- #else
- m_bUseDXVA = false;
- #endif
- #if INTERNAL_DECODER_VC1
- m_bUseFFmpeg = FFmpegFilters && FFmpegFilters[FFM_VC1];
- #else
- m_bUseFFmpeg = false;
- #endif
- break;
- case CODEC_ID_MPEG2VIDEO :
- #if INTERNAL_DECODER_MPEG2_DXVA
- m_bUseDXVA = true;
- #endif
- m_bUseFFmpeg = false; // No Mpeg2 software support with ffmpeg!
- break;
- default :
- m_bUseDXVA = false;
+ switch (ffCodecs[i].nFFCodec) {
+ case CODEC_ID_H264 :
+#if INTERNAL_DECODER_H264_DXVA
+ m_bUseDXVA = DXVAFilters && DXVAFilters[TRA_DXVA_H264];
+#else
+ m_bUseDXVA = false;
+#endif
+#if INTERNAL_DECODER_H264
+ m_bUseFFmpeg = FFmpegFilters && FFmpegFilters[FFM_H264];
+#else
+ m_bUseFFmpeg = false;
+#endif
+ break;
+ case CODEC_ID_VC1 :
+#if INTERNAL_DECODER_VC1_DXVA
+ m_bUseDXVA = DXVAFilters && DXVAFilters[TRA_DXVA_VC1];
+#else
+ m_bUseDXVA = false;
+#endif
+#if INTERNAL_DECODER_VC1
+ m_bUseFFmpeg = FFmpegFilters && FFmpegFilters[FFM_VC1];
+#else
+ m_bUseFFmpeg = false;
+#endif
+ break;
+ case CODEC_ID_MPEG2VIDEO :
+#if INTERNAL_DECODER_MPEG2_DXVA
+ m_bUseDXVA = true;
+#endif
+ m_bUseFFmpeg = false; // No Mpeg2 software support with ffmpeg!
+ break;
+ default :
+ m_bUseDXVA = false;
}
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_XVID) ||
- (*ffCodecs[i].clsMinorType == MEDIASUBTYPE_xvid) ||
- (*ffCodecs[i].clsMinorType == MEDIASUBTYPE_XVIX) ||
- (*ffCodecs[i].clsMinorType == MEDIASUBTYPE_xvix) )
- {
- bCodecActivated = (m_nActiveCodecs & MPCVD_XVID) != 0;
- }
- else if ((*ffCodecs[i].clsMinorType == MEDIASUBTYPE_DX50) ||
- (*ffCodecs[i].clsMinorType == MEDIASUBTYPE_dx50) ||
- (*ffCodecs[i].clsMinorType == MEDIASUBTYPE_DIVX) ||
- (*ffCodecs[i].clsMinorType == MEDIASUBTYPE_divx) )
- {
- bCodecActivated = (m_nActiveCodecs & MPCVD_DIVX) != 0;
- }
- break;
- case CODEC_ID_WMV1 :
- case CODEC_ID_WMV2 :
- case CODEC_ID_WMV3 :
- bCodecActivated = (m_nActiveCodecs & MPCVD_WMV) != 0;
- 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_VP5 :
- case CODEC_ID_VP6 :
- case CODEC_ID_VP6A :
- bCodecActivated = (m_nActiveCodecs & MPCVD_VP6) != 0;
- break;
- case CODEC_ID_VP8 :
- bCodecActivated = (m_nActiveCodecs & MPCVD_VP8) != 0;
- break;
+ 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_XVID) ||
+ (*ffCodecs[i].clsMinorType == MEDIASUBTYPE_xvid) ||
+ (*ffCodecs[i].clsMinorType == MEDIASUBTYPE_XVIX) ||
+ (*ffCodecs[i].clsMinorType == MEDIASUBTYPE_xvix) ) {
+ bCodecActivated = (m_nActiveCodecs & MPCVD_XVID) != 0;
+ } else if ((*ffCodecs[i].clsMinorType == MEDIASUBTYPE_DX50) ||
+ (*ffCodecs[i].clsMinorType == MEDIASUBTYPE_dx50) ||
+ (*ffCodecs[i].clsMinorType == MEDIASUBTYPE_DIVX) ||
+ (*ffCodecs[i].clsMinorType == MEDIASUBTYPE_divx) ) {
+ bCodecActivated = (m_nActiveCodecs & MPCVD_DIVX) != 0;
+ }
+ break;
+ case CODEC_ID_WMV1 :
+ case CODEC_ID_WMV2 :
+ case CODEC_ID_WMV3 :
+ bCodecActivated = (m_nActiveCodecs & MPCVD_WMV) != 0;
+ 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_VP5 :
+ case CODEC_ID_VP6 :
+ case CODEC_ID_VP6A :
+ bCodecActivated = (m_nActiveCodecs & MPCVD_VP6) != 0;
+ break;
+ case CODEC_ID_VP8 :
+ bCodecActivated = (m_nActiveCodecs & MPCVD_VP8) != 0;
+ break;
}
return (bCodecActivated ? i : -1);
#endif
@@ -896,26 +899,38 @@ void CMPCVideoDecFilter::Cleanup()
SAFE_DELETE (m_pDXVADecoder);
// Release FFMpeg
- if (m_pAVCtx)
- {
- if (m_pAVCtx->intra_matrix) free(m_pAVCtx->intra_matrix);
- if (m_pAVCtx->inter_matrix) free(m_pAVCtx->inter_matrix);
- if (m_pAVCtx->extradata) free((unsigned char*)m_pAVCtx->extradata);
- if (m_pFFBuffer) free(m_pFFBuffer);
+ if (m_pAVCtx) {
+ if (m_pAVCtx->intra_matrix) {
+ free(m_pAVCtx->intra_matrix);
+ }
+ if (m_pAVCtx->inter_matrix) {
+ free(m_pAVCtx->inter_matrix);
+ }
+ if (m_pAVCtx->extradata) {
+ free((unsigned char*)m_pAVCtx->extradata);
+ }
+ if (m_pFFBuffer) {
+ free(m_pFFBuffer);
+ }
- if (m_pAVCtx->slice_offset) av_free(m_pAVCtx->slice_offset);
- if (m_pAVCtx->codec) avcodec_close(m_pAVCtx);
+ if (m_pAVCtx->slice_offset) {
+ av_free(m_pAVCtx->slice_offset);
+ }
+ if (m_pAVCtx->codec) {
+ avcodec_close(m_pAVCtx);
+ }
// Free thread resource if necessary
FFSetThreadNumber (m_pAVCtx, 0);
av_free(m_pAVCtx);
}
- if (m_pFrame) av_free(m_pFrame);
+ if (m_pFrame) {
+ av_free(m_pFrame);
+ }
#if HAS_FFMPEG_VIDEO_DECODERS
- if (m_pSwsContext)
- {
+ if (m_pSwsContext) {
sws_freeContext(m_pSwsContext);
m_pSwsContext = NULL;
}
@@ -932,8 +947,7 @@ void CMPCVideoDecFilter::Cleanup()
SAFE_DELETE_ARRAY (m_pVideoOutputFormat);
// Release DXVA ressources
- if (m_hDevice != INVALID_HANDLE_VALUE)
- {
+ if (m_hDevice != INVALID_HANDLE_VALUE) {
m_pDeviceManager->CloseDeviceHandle(m_hDevice);
m_hDevice = INVALID_HANDLE_VALUE;
}
@@ -946,16 +960,15 @@ void CMPCVideoDecFilter::Cleanup()
void CMPCVideoDecFilter::CalcAvgTimePerFrame()
{
CMediaType &mt = m_pInput->CurrentMediaType();
- if (mt.formattype==FORMAT_VideoInfo)
+ if (mt.formattype==FORMAT_VideoInfo) {
m_rtAvrTimePerFrame = ((VIDEOINFOHEADER*)mt.pbFormat)->AvgTimePerFrame;
- else if (mt.formattype==FORMAT_VideoInfo2)
+ } else if (mt.formattype==FORMAT_VideoInfo2) {
m_rtAvrTimePerFrame = ((VIDEOINFOHEADER2*)mt.pbFormat)->AvgTimePerFrame;
- else if (mt.formattype==FORMAT_MPEGVideo)
+ } else if (mt.formattype==FORMAT_MPEGVideo) {
m_rtAvrTimePerFrame = ((MPEG1VIDEOINFO*)mt.pbFormat)->hdr.AvgTimePerFrame;
- else if (mt.formattype==FORMAT_MPEG2Video)
+ } else if (mt.formattype==FORMAT_MPEG2Video) {
m_rtAvrTimePerFrame = ((MPEG2VIDEOINFO*)mt.pbFormat)->hdr.AvgTimePerFrame;
- else
- {
+ } else {
ASSERT (FALSE);
m_rtAvrTimePerFrame = 1;
}
@@ -975,7 +988,7 @@ void CMPCVideoDecFilter::LogLibAVCodec(void* par,int level,const char *fmt,va_li
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;
+ // pic->rtStart = m_rtStart;
}
STDMETHODIMP CMPCVideoDecFilter::NonDelegatingQueryInterface(REFIID riid, void** ppv)
@@ -992,11 +1005,11 @@ STDMETHODIMP CMPCVideoDecFilter::NonDelegatingQueryInterface(REFIID riid, void**
HRESULT CMPCVideoDecFilter::CheckInputType(const CMediaType* mtIn)
{
- for (int i=0; i<sizeof(sudPinTypesIn)/sizeof(AMOVIESETUP_MEDIATYPE); i++)
- {
+ for (int i=0; i<sizeof(sudPinTypesIn)/sizeof(AMOVIESETUP_MEDIATYPE); i++) {
if ((mtIn->majortype == *sudPinTypesIn[i].clsMajorType) &&
- (mtIn->subtype == *sudPinTypesIn[i].clsMinorType))
+ (mtIn->subtype == *sudPinTypesIn[i].clsMinorType)) {
return S_OK;
+ }
}
return VFW_E_TYPE_NOT_ACCEPTED;
@@ -1013,13 +1026,13 @@ HRESULT CMPCVideoDecFilter::SetMediaType(PIN_DIRECTION direction,const CMediaTyp
{
int nNewCodec;
- if (direction == PINDIR_INPUT)
- {
+ if (direction == PINDIR_INPUT) {
nNewCodec = FindCodec(pmt);
- if (nNewCodec == -1) return VFW_E_TYPE_NOT_ACCEPTED;
+ if (nNewCodec == -1) {
+ return VFW_E_TYPE_NOT_ACCEPTED;
+ }
- if (nNewCodec != m_nCodecNb)
- {
+ if (nNewCodec != m_nCodecNb) {
m_nCodecNb = nNewCodec;
m_bReorderBFrame = true;
@@ -1029,45 +1042,36 @@ HRESULT CMPCVideoDecFilter::SetMediaType(PIN_DIRECTION direction,const CMediaTyp
m_pAVCtx = avcodec_alloc_context();
CheckPointer (m_pAVCtx, E_POINTER);
- if ((m_nThreadNumber > 1) && IsMultiThreadSupported (ffCodecs[m_nCodecNb].nFFCodec))
+ if ((m_nThreadNumber > 1) && IsMultiThreadSupported (ffCodecs[m_nCodecNb].nFFCodec)) {
FFSetThreadNumber(m_pAVCtx, m_nThreadNumber);
+ }
m_pFrame = avcodec_alloc_frame();
CheckPointer (m_pFrame, E_POINTER);
- if(pmt->formattype == FORMAT_VideoInfo)
- {
+ 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;
- }
- else if(pmt->formattype == FORMAT_VideoInfo2)
- {
+ } 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;
- }
- else if(pmt->formattype == FORMAT_MPEGVideo)
- {
+ } 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;
- }
- else if(pmt->formattype == FORMAT_MPEG2Video)
- {
+ } 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;
- if (mpg2v->hdr.bmiHeader.biCompression == NULL)
- {
+ 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')))
- {
+ } 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 = false;
}
@@ -1087,9 +1091,9 @@ HRESULT CMPCVideoDecFilter::SetMediaType(PIN_DIRECTION direction,const CMediaTyp
m_pAVCtx->postgain = 1.0f;
m_pAVCtx->debug_mv = 0;
- #ifdef _DEBUG
+#ifdef _DEBUG
//m_pAVCtx->debug = FF_DEBUG_PICT_INFO | FF_DEBUG_STARTCODE | FF_DEBUG_PTS;
- #endif
+#endif
m_pAVCtx->opaque = this;
m_pAVCtx->get_buffer = get_buffer;
@@ -1098,53 +1102,52 @@ HRESULT CMPCVideoDecFilter::SetMediaType(PIN_DIRECTION direction,const CMediaTyp
ConnectTo (m_pAVCtx);
CalcAvgTimePerFrame();
- if (avcodec_open(m_pAVCtx, m_pAVCodec)<0)
+ if (avcodec_open(m_pAVCtx, m_pAVCodec)<0) {
return VFW_E_INVALIDMEDIATYPE;
+ }
- switch (ffCodecs[m_nCodecNb].nFFCodec)
- {
- case CODEC_ID_H264 :
- if((m_nDXVA_SD) && (PictWidthRounded() < 1280))
- {
- m_bDXVACompatible = false;
- }
- else
- {
- if(m_nDXVACheckCompatibility != 3)
- {
- // non-zero value indicates that an incompatibility was detected
- int nCompat = FFH264CheckCompatibility (PictWidthRounded(), PictHeightRounded(), m_pAVCtx, (BYTE*)m_pAVCtx->extradata, m_pAVCtx->extradata_size, m_nPCIVendor, m_nPCIDevice, m_VideoDriverVersion);
-
- if(nCompat > 0)
- {
- switch(m_nDXVACheckCompatibility)
- {
- case 0 :
- // full check
- m_bDXVACompatible = false;
- break;
- case 1 :
- // skip level check
- if(nCompat != DXVA_UNSUPPORTED_LEVEL) m_bDXVACompatible = false;
- break;
- case 2 :
- // skip reference frame check
- if(nCompat != DXVA_TOO_MANY_REF_FRAMES) m_bDXVACompatible = false;
- break;
+ switch (ffCodecs[m_nCodecNb].nFFCodec) {
+ case CODEC_ID_H264 :
+ if((m_nDXVA_SD) && (PictWidthRounded() < 1280)) {
+ m_bDXVACompatible = false;
+ } else {
+ if(m_nDXVACheckCompatibility != 3) {
+ // non-zero value indicates that an incompatibility was detected
+ int nCompat = FFH264CheckCompatibility (PictWidthRounded(), PictHeightRounded(), m_pAVCtx, (BYTE*)m_pAVCtx->extradata, m_pAVCtx->extradata_size, m_nPCIVendor, m_nPCIDevice, m_VideoDriverVersion);
+
+ if(nCompat > 0) {
+ switch(m_nDXVACheckCompatibility) {
+ case 0 :
+ // full check
+ m_bDXVACompatible = false;
+ break;
+ case 1 :
+ // skip level check
+ if(nCompat != DXVA_UNSUPPORTED_LEVEL) {
+ m_bDXVACompatible = false;
+ }
+ break;
+ case 2 :
+ // skip reference frame check
+ if(nCompat != DXVA_TOO_MANY_REF_FRAMES) {
+ m_bDXVACompatible = false;
+ }
+ break;
+ }
}
}
}
- }
- break;
- case CODEC_ID_MPEG2VIDEO :
- // DSP is disable for DXVA decoding (to keep default idct_permutation)
- m_pAVCtx->dsp_mask ^= AV_CPU_FLAG_FORCE;
- break;
+ break;
+ case CODEC_ID_MPEG2VIDEO :
+ // DSP is disable for DXVA decoding (to keep default idct_permutation)
+ m_pAVCtx->dsp_mask ^= AV_CPU_FLAG_FORCE;
+ break;
}
// Force single thread for DXVA !
- if (IsDXVASupported())
+ if (IsDXVASupported()) {
FFSetThreadNumber(m_pAVCtx, 1);
+ }
BuildDXVAOutputFormat();
}
@@ -1154,16 +1157,14 @@ HRESULT CMPCVideoDecFilter::SetMediaType(PIN_DIRECTION direction,const CMediaTyp
}
-VIDEO_OUTPUT_FORMATS DXVAFormats[] =
-{
+VIDEO_OUTPUT_FORMATS DXVAFormats[] = {
{&MEDIASUBTYPE_NV12, 1, 12, 'avxd'}, // DXVA2
{&MEDIASUBTYPE_NV12, 1, 12, 'AVXD'},
{&MEDIASUBTYPE_NV12, 1, 12, 'AVxD'},
{&MEDIASUBTYPE_NV12, 1, 12, 'AvXD'}
};
-VIDEO_OUTPUT_FORMATS SoftwareFormats[] =
-{
+VIDEO_OUTPUT_FORMATS SoftwareFormats[] = {
{&MEDIASUBTYPE_YV12, 3, 12, '21VY'},
{&MEDIASUBTYPE_YUY2, 1, 16, '2YUY'}, // Software
{&MEDIASUBTYPE_I420, 3, 12, '024I'},
@@ -1200,11 +1201,9 @@ void CMPCVideoDecFilter::BuildDXVAOutputFormat()
m_pVideoOutputFormat = DNew VIDEO_OUTPUT_FORMATS[m_nVideoOutputCount];
- if (IsDXVASupported())
- {
+ if (IsDXVASupported()) {
// Dynamic DXVA media types for DXVA1
- for (nPos=0; nPos<ffCodecs[m_nCodecNb].DXVAModeCount(); nPos++)
- {
+ 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;
@@ -1217,17 +1216,19 @@ void CMPCVideoDecFilter::BuildDXVAOutputFormat()
}
// Software rendering
- if (m_bUseFFmpeg)
+ if (m_bUseFFmpeg) {
memcpy (&m_pVideoOutputFormat[nPos], SoftwareFormats, sizeof(SoftwareFormats));
+ }
}
int CMPCVideoDecFilter::GetPicEntryNumber()
{
- if (IsDXVASupported())
+ if (IsDXVASupported()) {
return ffCodecs[m_nCodecNb].DXVAModes->PicEntryNumber;
- else
+ } else {
return 0;
+ }
}
@@ -1244,44 +1245,32 @@ void CMPCVideoDecFilter::AllocExtradata(AVCodecContext* pAVCtx, const CMediaType
const BYTE* data = NULL;
unsigned int size = 0;
- if (pmt->formattype==FORMAT_VideoInfo)
- {
+ if (pmt->formattype==FORMAT_VideoInfo) {
size = pmt->cbFormat-sizeof(VIDEOINFOHEADER);
data = size?pmt->pbFormat+sizeof(VIDEOINFOHEADER):NULL;
- }
- else if (pmt->formattype==FORMAT_VideoInfo2)
- {
+ } else if (pmt->formattype==FORMAT_VideoInfo2) {
size = pmt->cbFormat-sizeof(VIDEOINFOHEADER2);
data = size?pmt->pbFormat+sizeof(VIDEOINFOHEADER2):NULL;
- }
- else if (pmt->formattype==FORMAT_MPEGVideo)
- {
+ } else if (pmt->formattype==FORMAT_MPEGVideo) {
MPEG1VIDEOINFO* mpeg1info = (MPEG1VIDEOINFO*)pmt->pbFormat;
- if (mpeg1info->cbSequenceHeader)
- {
+ if (mpeg1info->cbSequenceHeader) {
size = mpeg1info->cbSequenceHeader;
data = mpeg1info->bSequenceHeader;
}
- }
- else if (pmt->formattype==FORMAT_MPEG2Video)
- {
+ } else if (pmt->formattype==FORMAT_MPEG2Video) {
MPEG2VIDEOINFO* mpeg2info = (MPEG2VIDEOINFO*)pmt->pbFormat;
- if (mpeg2info->cbSequenceHeader)
- {
+ if (mpeg2info->cbSequenceHeader) {
size = mpeg2info->cbSequenceHeader;
data = (const uint8_t*)mpeg2info->dwSequenceHeader;
}
- }
- else if (pmt->formattype==FORMAT_VorbisFormat2)
- {
+ } else if (pmt->formattype==FORMAT_VorbisFormat2) {
const VORBISFORMAT2 *vf2=(const VORBISFORMAT2*)pmt->pbFormat;
UNUSED_ALWAYS(vf2);
size=pmt->cbFormat-sizeof(VORBISFORMAT2);
data=size?pmt->pbFormat+sizeof(VORBISFORMAT2):NULL;
}
- if (size)
- {
+ if (size) {
pAVCtx->extradata_size = size;
pAVCtx->extradata = (const unsigned char*)calloc(1,size+FF_INPUT_BUFFER_PADDING_SIZE);
memcpy((void*)pAVCtx->extradata, data, size);
@@ -1293,31 +1282,31 @@ HRESULT CMPCVideoDecFilter::CompleteConnect(PIN_DIRECTION direction, IPin* pRece
{
LOG(_T("CMPCVideoDecFilter::CompleteConnect"));
- if (direction==PINDIR_INPUT && m_pOutput->IsConnected())
- {
+ if (direction==PINDIR_INPUT && m_pOutput->IsConnected()) {
ReconnectOutput (m_nWidth, m_nHeight);
- }
- else if (direction==PINDIR_OUTPUT)
- {
- if (IsDXVASupported())
- {
- if (m_nDXVAMode == MODE_DXVA1)
+ } else if (direction==PINDIR_OUTPUT) {
+ if (IsDXVASupported()) {
+ if (m_nDXVAMode == MODE_DXVA1) {
m_pDXVADecoder->ConfigureDXVA1();
- else if (SUCCEEDED (ConfigureDXVA2 (pReceivePin)) && SUCCEEDED (SetEVRForDXVA2 (pReceivePin)) )
+ } else if (SUCCEEDED (ConfigureDXVA2 (pReceivePin)) && SUCCEEDED (SetEVRForDXVA2 (pReceivePin)) ) {
m_nDXVAMode = MODE_DXVA2;
+ }
}
- if (m_nDXVAMode == MODE_SOFTWARE && !FFSoftwareCheckCompatibility(m_pAVCtx))
+ if (m_nDXVAMode == MODE_SOFTWARE && !FFSoftwareCheckCompatibility(m_pAVCtx)) {
return VFW_E_INVALIDMEDIATYPE;
+ }
CLSID ClsidSourceFilter = GetCLSID(m_pInput->GetConnected());
- if((ClsidSourceFilter == __uuidof(CMpegSourceFilter)) || (ClsidSourceFilter == __uuidof(CMpegSplitterFilter)))
+ if((ClsidSourceFilter == __uuidof(CMpegSourceFilter)) || (ClsidSourceFilter == __uuidof(CMpegSplitterFilter))) {
m_bReorderBFrame = false;
+ }
}
// Cannot use YUY2 if horizontal or vertical resolution is not even
if ( ((m_pOutput->CurrentMediaType().subtype == MEDIASUBTYPE_NV12) && (m_nDXVAMode == MODE_SOFTWARE)) ||
- ((m_pOutput->CurrentMediaType().subtype == MEDIASUBTYPE_YUY2) && (m_pAVCtx->width&1 || m_pAVCtx->height&1)) )
+ ((m_pOutput->CurrentMediaType().subtype == MEDIASUBTYPE_YUY2) && (m_pAVCtx->width&1 || m_pAVCtx->height&1)) ) {
return VFW_E_INVALIDMEDIATYPE;
+ }
return __super::CompleteConnect (direction, pReceivePin);
}
@@ -1325,24 +1314,26 @@ HRESULT CMPCVideoDecFilter::CompleteConnect(PIN_DIRECTION direction, IPin* pRece
HRESULT CMPCVideoDecFilter::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties)
{
- if (UseDXVA2())
- {
+ 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();
- if(FAILED(hr = pAllocator->SetProperties(pProperties, &Actual)))
+ if(FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
return hr;
+ }
return pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer
? E_FAIL
: NOERROR;
- }
- else
+ } else {
return __super::DecideBufferSize (pAllocator, pProperties);
+ }
}
@@ -1353,22 +1344,24 @@ HRESULT CMPCVideoDecFilter::NewSegment(REFERENCE_TIME rtStart, REFERENCE_TIME rt
memset (&m_BFrames, 0, sizeof(m_BFrames));
m_rtLastStart = 0;
m_nCountEstimated = 0;
+ m_dRate = dRate;
ResetBuffer();
- if (m_pAVCtx)
+ if (m_pAVCtx) {
avcodec_flush_buffers (m_pAVCtx);
+ }
- if (m_pDXVADecoder)
+ if (m_pDXVADecoder) {
m_pDXVADecoder->Flush();
+ }
return __super::NewSegment (rtStart, rtStop, dRate);
}
HRESULT CMPCVideoDecFilter::BreakConnect(PIN_DIRECTION dir)
{
- if (dir == PINDIR_INPUT)
- {
+ if (dir == PINDIR_INPUT) {
Cleanup();
}
@@ -1377,34 +1370,31 @@ HRESULT CMPCVideoDecFilter::BreakConnect(PIN_DIRECTION dir)
void CMPCVideoDecFilter::SetTypeSpecificFlags(IMediaSample* pMS)
{
- if(CComQIPtr<IMediaSample2> pMS2 = pMS)
- {
+ if(CComQIPtr<IMediaSample2> pMS2 = pMS) {
AM_SAMPLE2_PROPERTIES props;
- if(SUCCEEDED(pMS2->GetProperties(sizeof(props), (BYTE*)&props)))
- {
+ if(SUCCEEDED(pMS2->GetProperties(sizeof(props), (BYTE*)&props))) {
props.dwTypeSpecificFlags &= ~0x7f;
- if(!m_pFrame->interlaced_frame)
+ if(!m_pFrame->interlaced_frame) {
props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_WEAVE;
- else
- {
- if(m_pFrame->top_field_first)
+ } else {
+ if(m_pFrame->top_field_first) {
props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_FIELD1FIRST;
+ }
}
- switch (m_pFrame->pict_type)
- {
- case FF_I_TYPE :
- case FF_SI_TYPE :
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_I_SAMPLE;
- break;
- case FF_P_TYPE :
- case FF_SP_TYPE :
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_P_SAMPLE;
- break;
- default :
- props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_B_SAMPLE;
- break;
+ switch (m_pFrame->pict_type) {
+ case FF_I_TYPE :
+ case FF_SI_TYPE :
+ props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_I_SAMPLE;
+ break;
+ case FF_P_TYPE :
+ case FF_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);
@@ -1415,11 +1405,12 @@ void CMPCVideoDecFilter::SetTypeSpecificFlags(IMediaSample* pMS)
#if HAS_FFMPEG_VIDEO_DECODERS
int CMPCVideoDecFilter::GetCspFromMediaType(GUID& subtype)
{
- if (subtype == MEDIASUBTYPE_I420 || subtype == MEDIASUBTYPE_IYUV || subtype == MEDIASUBTYPE_YV12)
+ if (subtype == MEDIASUBTYPE_I420 || subtype == MEDIASUBTYPE_IYUV || subtype == MEDIASUBTYPE_YV12) {
return FF_CSP_420P|FF_CSP_FLAGS_YUV_ADJ;
- else if (subtype == MEDIASUBTYPE_YUY2)
+ } else if (subtype == MEDIASUBTYPE_YUY2) {
return FF_CSP_YUY2;
-// else if (subtype == MEDIASUBTYPE_ARGB32 || subtype == MEDIASUBTYPE_RGB32 || subtype == MEDIASUBTYPE_RGB24 || subtype == MEDIASUBTYPE_RGB565)
+ }
+ // else if (subtype == MEDIASUBTYPE_ARGB32 || subtype == MEDIASUBTYPE_RGB32 || subtype == MEDIASUBTYPE_RGB24 || subtype == MEDIASUBTYPE_RGB565)
ASSERT (FALSE);
return FF_CSP_NULL;
@@ -1428,15 +1419,18 @@ int CMPCVideoDecFilter::GetCspFromMediaType(GUID& subtype)
void CMPCVideoDecFilter::InitSwscale()
{
- if (m_pSwsContext == NULL)
- {
+ if (m_pSwsContext == NULL) {
TYCbCr2RGB_coeffs coeffs(ffYCbCr_RGB_coeff_ITUR_BT601,0, 235, 16, 255.0, 0.0);
int32_t swscaleTable[7];
SwsParams params;
memset(&params,0,sizeof(params));
- if (m_pAVCtx->dsp_mask & CCpuId::MPC_MM_MMX) params.cpu |= SWS_CPU_CAPS_MMX|SWS_CPU_CAPS_MMX2;
- if (m_pAVCtx->dsp_mask & CCpuId::MPC_MM_3DNOW) params.cpu |= SWS_CPU_CAPS_3DNOW;
+ if (m_pAVCtx->dsp_mask & CCpuId::MPC_MM_MMX) {
+ params.cpu |= SWS_CPU_CAPS_MMX|SWS_CPU_CAPS_MMX2;
+ }
+ if (m_pAVCtx->dsp_mask & CCpuId::MPC_MM_3DNOW) {
+ params.cpu |= SWS_CPU_CAPS_3DNOW;
+ }
params.methodLuma.method=params.methodChroma.method=SWS_POINT;
@@ -1487,10 +1481,8 @@ HRESULT CMPCVideoDecFilter::SoftwareDecode(IMediaSample* pIn, BYTE* pDataIn, int
AVPacket avpkt;
av_init_packet(&avpkt);
- while (nSize > 0)
- {
- if (nSize+FF_INPUT_BUFFER_PADDING_SIZE > m_nFFBufferSize)
- {
+ while (nSize > 0) {
+ if (nSize+FF_INPUT_BUFFER_PADDING_SIZE > m_nFFBufferSize) {
m_nFFBufferSize = nSize+FF_INPUT_BUFFER_PADDING_SIZE;
m_pFFBuffer = (BYTE*)realloc(m_pFFBuffer, m_nFFBufferSize);
}
@@ -1509,15 +1501,20 @@ HRESULT CMPCVideoDecFilter::SoftwareDecode(IMediaSample* pIn, BYTE* pDataIn, int
avpkt.flags = AV_PKT_FLAG_KEY;
used_bytes = avcodec_decode_video2 (m_pAVCtx, m_pFrame, &got_picture, &avpkt);
- if (!got_picture || !m_pFrame->data[0]) return S_OK;
- if(pIn->IsPreroll() == S_OK || rtStart < 0) return S_OK;
+ if (!got_picture || !m_pFrame->data[0]) {
+ return S_OK;
+ }
+ if(pIn->IsPreroll() == S_OK || rtStart < 0) {
+ return S_OK;
+ }
CComPtr<IMediaSample> pOut;
BYTE* pDataOut = NULL;
UpdateAspectRatio();
- if(FAILED(hr = GetDeliveryBuffer(m_pAVCtx->width, m_pAVCtx->height, &pOut)) || FAILED(hr = pOut->GetPointer(&pDataOut)))
+ if(FAILED(hr = GetDeliveryBuffer(m_pAVCtx->width, m_pAVCtx->height, &pOut)) || FAILED(hr = pOut->GetPointer(&pDataOut))) {
return hr;
+ }
rtStart = m_pFrame->reordered_opaque;
rtStop = m_pFrame->reordered_opaque + m_rtAvrTimePerFrame;
@@ -1527,34 +1524,37 @@ HRESULT CMPCVideoDecFilter::SoftwareDecode(IMediaSample* pIn, BYTE* pDataIn, int
pOut->SetMediaTime(NULL, NULL);
#if HAS_FFMPEG_VIDEO_DECODERS
- if (m_pSwsContext == NULL) InitSwscale();
+ if (m_pSwsContext == NULL) {
+ InitSwscale();
+ }
// TODO : quick and dirty patch to fix convertion to YUY2 with swscale
- if (m_nOutCsp == FF_CSP_YUY2)
+ if (m_nOutCsp == FF_CSP_YUY2) {
CopyBuffer(pDataOut, m_pFrame->data, m_pAVCtx->width, m_pAVCtx->height, m_pFrame->linesize[0], MEDIASUBTYPE_I420, false);
+ }
- else if (m_pSwsContext != NULL)
- {
+ else if (m_pSwsContext != NULL) {
uint8_t* dst[4];
stride_t srcStride[4];
stride_t dstStride[4];
const TcspInfo *outcspInfo=csp_getInfo(m_nOutCsp);
- for (int i=0; i<4; i++)
- {
+ for (int i=0; i<4; i++) {
srcStride[i]=(stride_t)m_pFrame->linesize[i];
dstStride[i]=m_pOutSize.cx>>outcspInfo->shiftX[i];
- if (i==0)
+ if (i==0) {
dst[i]=pDataOut;
- else
+ } else {
dst[i]=dst[i-1]+dstStride[i-1]*(m_pOutSize.cy>>outcspInfo->shiftY[i-1]);
+ }
}
int nTempCsp = m_nOutCsp;
- if(outcspInfo->id==FF_CSP_420P)
+ if(outcspInfo->id==FF_CSP_420P) {
csp_yuv_adj_to_plane(nTempCsp,outcspInfo,odd2even(m_pOutSize.cy),(unsigned char**)dst,dstStride);
- else
+ } else {
csp_yuv_adj_to_plane(nTempCsp,outcspInfo,m_pAVCtx->height,(unsigned char**)dst,dstStride);
+ }
sws_scale_ordered (m_pSwsContext, m_pFrame->data, srcStride, 0, m_pAVCtx->height, dst, dstStride);
}
@@ -1667,24 +1667,17 @@ bool CMPCVideoDecFilter::FindPicture(int nIndex, int nStartCode)
{
DWORD dw = 0;
- for (int i=0; i<m_nFFBufferPos-nIndex; i++)
- {
+ 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 (i >= 4) {
+ if (m_nFFPicEnd == INT_MIN) {
if ( (dw & 0xffffff00) == 0x00000100 &&
- (dw & 0x000000FF) == (DWORD)nStartCode )
- {
+ (dw & 0x000000FF) == (DWORD)nStartCode ) {
m_nFFPicEnd = i+nIndex-3;
}
- }
- else
- {
+ } else {
if ( (dw & 0xffffff00) == 0x00000100 &&
- ( (dw & 0x000000FF) == (DWORD)nStartCode || (dw & 0x000000FF) == 0xB3 ))
- {
+ ( (dw & 0x000000FF) == (DWORD)nStartCode || (dw & 0x000000FF) == 0xB3 )) {
m_nFFPicEnd = i+nIndex-3;
return true;
}
@@ -1702,8 +1695,7 @@ void CMPCVideoDecFilter::ResetBuffer()
m_nFFBufferPos = 0;
m_nFFPicEnd = INT_MIN;
- for (int i=0; i<MAX_BUFF_TIME; i++)
- {
+ 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;
@@ -1712,10 +1704,8 @@ void CMPCVideoDecFilter::ResetBuffer()
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)
- {
+ 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;
@@ -1730,10 +1720,8 @@ void CMPCVideoDecFilter::PopBufferTime(int nPos)
int i = 0;
// Shift buffer time list
- while (i<MAX_BUFF_TIME && m_FFBufferTime[i].nBuffPos!=INT_MIN)
- {
- if (m_FFBufferTime[i].nBuffPos >= nPos)
- {
+ 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;
@@ -1743,8 +1731,7 @@ void CMPCVideoDecFilter::PopBufferTime(int nPos)
}
// Free unused slots
- for (i=nDestPos; i<MAX_BUFF_TIME; i++)
- {
+ 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;
@@ -1753,11 +1740,11 @@ void CMPCVideoDecFilter::PopBufferTime(int nPos)
bool CMPCVideoDecFilter::AppendBuffer (BYTE* pDataIn, int nSize, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop)
{
- if (rtStart != _I64_MIN)
+ if (rtStart != _I64_MIN) {
PushBufferTime (m_nFFBufferPos, rtStart, rtStop);
+ }
- if (m_nFFBufferPos+nSize+FF_INPUT_BUFFER_PADDING_SIZE > 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*)realloc(m_pFFBuffer, m_nFFBufferSize);
}
@@ -1792,8 +1779,9 @@ HRESULT CMPCVideoDecFilter::Transform(IMediaSample* pIn)
REFERENCE_TIME rtStart = _I64_MIN;
REFERENCE_TIME rtStop = _I64_MIN;
- if(FAILED(hr = pIn->GetPointer(&pDataIn)))
+ if(FAILED(hr = pIn->GetPointer(&pDataIn))) {
return hr;
+ }
nSize = pIn->GetActualDataLength();
pIn->GetTime(&rtStart, &rtStop);
@@ -1818,23 +1806,23 @@ HRESULT CMPCVideoDecFilter::Transform(IMediaSample* pIn)
// m_nCountEstimated++;
// rtStart = rtStop = m_rtLastStart + m_nCountEstimated*m_rtAvrTimePerFrame;
//}
- if (rtStop <= rtStart && rtStop != _I64_MIN)
- rtStop = rtStart + m_rtAvrTimePerFrame;
+ if (rtStop <= rtStart && rtStop != _I64_MIN) {
+ rtStop = rtStart + m_rtAvrTimePerFrame / m_dRate;
+ }
m_pAVCtx->reordered_opaque = rtStart;
m_pAVCtx->reordered_opaque2 = rtStop;
- if (m_pAVCtx->has_b_frames)
- {
+ if (m_pAVCtx->has_b_frames) {
m_BFrames[m_nPosB].rtStart = rtStart;
m_BFrames[m_nPosB].rtStop = rtStop;
m_nPosB = 1-m_nPosB;
}
-// m_rtStart = rtStart;
+ // m_rtStart = rtStart;
-// DumpBuffer (pDataIn, nSize);
-// TRACE ("Receive : %10I64d - %10I64d (%10I64d) Size=%d\n", rtStart, rtStop, rtStop - rtStart, nSize);
+ // DumpBuffer (pDataIn, nSize);
+ // TRACE ("Receive : %10I64d - %10I64d (%10I64d) Size=%d\n", rtStart, rtStop, rtStop - rtStart, nSize);
//char strMsg[300];
//FILE* hFile = fopen ("d:\\receive.txt", "at");
@@ -1847,49 +1835,42 @@ HRESULT CMPCVideoDecFilter::Transform(IMediaSample* pIn)
//fwrite (pDataIn, nSize, 1, hFile);
//fclose (hFile);
- switch (m_nDXVAMode)
- {
- case MODE_SOFTWARE :
- hr = SoftwareDecode (pIn, pDataIn, nSize, rtStart, rtStop);
- break;
- 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();
- }
+ switch (m_nDXVAMode) {
+ case MODE_SOFTWARE :
+ hr = SoftwareDecode (pIn, pDataIn, nSize, rtStart, rtStop);
+ break;
+ 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;
+ 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;
+ 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
- rtStart = rtStop = _I64_MIN;
- hr = m_pDXVADecoder->DecodeFrame (m_pFFBuffer, m_nFFPicEnd, rtStart, rtStop);
- ShrinkBuffer();
+ } else {
+ hr = m_pDXVADecoder->DecodeFrame (pDataIn, nSize, rtStart, rtStop);
}
- }
- else
- {
- hr = m_pDXVADecoder->DecodeFrame (pDataIn, nSize, rtStart, rtStop);
- }
- break;
- default :
- ASSERT (FALSE);
- hr = E_UNEXPECTED;
+ break;
+ default :
+ ASSERT (FALSE);
+ hr = E_UNEXPECTED;
}
return hr;
@@ -1898,15 +1879,15 @@ HRESULT CMPCVideoDecFilter::Transform(IMediaSample* pIn)
void CMPCVideoDecFilter::UpdateAspectRatio()
{
- if(((m_nARMode) && (m_pAVCtx)) && ((m_pAVCtx->sample_aspect_ratio.num>0) && (m_pAVCtx->sample_aspect_ratio.den>0)))
- {
+ 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)
- {
+ 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;
+ if(lnko > 1) {
+ aspect.cx /= lnko, aspect.cy /= lnko;
+ }
SetAspect(aspect);
}
}
@@ -1915,8 +1896,7 @@ void CMPCVideoDecFilter::UpdateAspectRatio()
void CMPCVideoDecFilter::ReorderBFrames(REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop)
{
// Re-order B-frames if needed
- if (m_pAVCtx->has_b_frames && m_bReorderBFrame)
- {
+ if (m_pAVCtx->has_b_frames && m_bReorderBFrame) {
rtStart = m_BFrames [m_nPosB].rtStart;
rtStop = m_BFrames [m_nPosB].rtStop;
}
@@ -1933,14 +1913,13 @@ void CMPCVideoDecFilter::FillInVideoDescription(DXVA2_VideoDesc *pDesc)
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)
+ 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)
+ } else if (*ffCodecs[m_nCodecNb].DXVAModes->Decoder[i] == mode) {
return true;
+ }
}
}
@@ -1959,9 +1938,9 @@ BOOL CMPCVideoDecFilter::IsSupportedDecoderConfig(const D3DFORMAT nD3DFormat, co
}
HRESULT CMPCVideoDecFilter::FindDXVA2DecoderConfiguration(IDirectXVideoDecoderService *pDecoderService,
- const GUID& guidDecoder,
- DXVA2_ConfigPictureDecode *pSelectedConfig,
- BOOL *pbFoundDXVA2Configuration)
+ const GUID& guidDecoder,
+ DXVA2_ConfigPictureDecode *pSelectedConfig,
+ BOOL *pbFoundDXVA2Configuration)
{
HRESULT hr = S_OK;
UINT cFormats = 0;
@@ -1975,11 +1954,9 @@ HRESULT CMPCVideoDecFilter::FindDXVA2DecoderConfiguration(IDirectXVideoDecoderSe
hr = pDecoderService->GetDecoderRenderTargets(guidDecoder, &cFormats, &pFormats);
LOG (_T("GetDecoderRenderTargets => %d"), cFormats);
- if (SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
// Look for a format that matches our output format.
- for (UINT iFormat = 0; iFormat < cFormats; iFormat++)
- {
+ 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.
@@ -1989,24 +1966,22 @@ HRESULT CMPCVideoDecFilter::FindDXVA2DecoderConfiguration(IDirectXVideoDecoderSe
// Get the available configurations.
hr = pDecoderService->GetDecoderConfigurations(guidDecoder, &m_VideoDesc, NULL, &cConfigurations, &pConfig);
- if (FAILED(hr))
- {
+ if (FAILED(hr)) {
continue;
}
// Find a supported configuration.
- for (UINT iConfig = 0; iConfig < cConfigurations; iConfig++)
- {
- if (IsSupportedDecoderConfig(pFormats[iFormat], pConfig[iConfig], bIsPrefered))
- {
+ for (UINT iConfig = 0; iConfig < cConfigurations; iConfig++) {
+ if (IsSupportedDecoderConfig(pFormats[iFormat], pConfig[iConfig], bIsPrefered)) {
// This configuration is good.
- if (bIsPrefered || !*pbFoundDXVA2Configuration)
- {
+ if (bIsPrefered || !*pbFoundDXVA2Configuration) {
*pbFoundDXVA2Configuration = TRUE;
*pSelectedConfig = pConfig[iConfig];
}
- if (bIsPrefered) break;
+ if (bIsPrefered) {
+ break;
+ }
}
}
@@ -2041,70 +2016,65 @@ HRESULT CMPCVideoDecFilter::ConfigureDXVA2(IPin *pPin)
hr = pPin->QueryInterface(__uuidof(IMFGetService), (void**)&pGetService);
// Get the Direct3D device manager.
- if (SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
hr = pGetService->GetService(
- MR_VIDEO_ACCELERATION_SERVICE,
- __uuidof(IDirect3DDeviceManager9),
- (void**)&pDeviceManager);
+ MR_VIDEO_ACCELERATION_SERVICE,
+ __uuidof(IDirect3DDeviceManager9),
+ (void**)&pDeviceManager);
}
// Open a new device handle.
- if (SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
hr = pDeviceManager->OpenDeviceHandle(&hDevice);
}
// Get the video decoder service.
- if (SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
hr = pDeviceManager->GetVideoService(
- hDevice,
- __uuidof(IDirectXVideoDecoderService),
- (void**)&pDecoderService);
+ hDevice,
+ __uuidof(IDirectXVideoDecoderService),
+ (void**)&pDecoderService);
}
// Get the decoder GUIDs.
- if (SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
hr = pDecoderService->GetDecoderDeviceGuids(&cDecoderGuids, &pDecoderGuids);
}
- if (SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
// Look for the decoder GUIDs we want.
- for (UINT iGuid = 0; iGuid < cDecoderGuids; iGuid++)
- {
+ for (UINT iGuid = 0; iGuid < cDecoderGuids; iGuid++) {
// Do we support this mode?
- if (!IsSupportedDecoderMode(pDecoderGuids[iGuid]))
- {
+ if (!IsSupportedDecoderMode(pDecoderGuids[iGuid])) {
continue;
}
// Find a configuration that we support.
hr = FindDXVA2DecoderConfiguration(pDecoderService, pDecoderGuids[iGuid], &config, &bFoundDXVA2Configuration);
- if (FAILED(hr))
- {
+ if (FAILED(hr)) {
break;
}
- if (bFoundDXVA2Configuration)
- {
+ // Patch for the Sandy Bridge (prevent crash on Mode_E, fixme later)
+ if (m_nPCIVendor == PCIV_Intel && guidDecoder == DXVA2_ModeH264_E)
+ continue;
+
+ if (bFoundDXVA2Configuration) {
// Found a good configuration. Save the GUID.
guidDecoder = pDecoderGuids[iGuid];
}
}
}
- if (pDecoderGuids) CoTaskMemFree(pDecoderGuids);
- if (!bFoundDXVA2Configuration)
- {
+ if (pDecoderGuids) {
+ CoTaskMemFree(pDecoderGuids);
+ }
+ if (!bFoundDXVA2Configuration) {
hr = E_FAIL; // Unable to find a configuration.
}
- if (SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
// Store the things we will need later.
m_pDeviceManager = pDeviceManager;
m_pDecoderService = pDecoderService;
@@ -2114,10 +2084,8 @@ HRESULT CMPCVideoDecFilter::ConfigureDXVA2(IPin *pPin)
m_hDevice = hDevice;
}
- if (FAILED(hr))
- {
- if (hDevice != INVALID_HANDLE_VALUE)
- {
+ if (FAILED(hr)) {
+ if (hDevice != INVALID_HANDLE_VALUE) {
pDeviceManager->CloseDeviceHandle(hDevice);
}
}
@@ -2138,37 +2106,32 @@ HRESULT CMPCVideoDecFilter::SetEVRForDXVA2(IPin *pPin)
hr = pPin->QueryInterface(__uuidof(IMFGetService), (void**)&pGetService);
// Get the IDirectXVideoMemoryConfiguration interface.
- if (SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
hr = pGetService->GetService(
- MR_VIDEO_ACCELERATION_SERVICE,
- __uuidof(IDirectXVideoMemoryConfiguration),
- (void**)&pVideoConfig);
+ MR_VIDEO_ACCELERATION_SERVICE,
+ __uuidof(IDirectXVideoMemoryConfiguration),
+ (void**)&pVideoConfig);
- if (SUCCEEDED (pGetService->GetService(MR_VIDEO_RENDER_SERVICE, __uuidof(IMFVideoDisplayControl), (void**)&pVdc)))
- {
+ if (SUCCEEDED (pGetService->GetService(MR_VIDEO_RENDER_SERVICE, __uuidof(IMFVideoDisplayControl), (void**)&pVdc))) {
HWND hWnd;
- if (SUCCEEDED (pVdc->GetVideoWindow(&hWnd)))
- {
+ if (SUCCEEDED (pVdc->GetVideoWindow(&hWnd))) {
DetectVideoCard(hWnd);
}
}
}
// Notify the EVR.
- if (SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
DXVA2_SurfaceType surfaceType;
- for (DWORD iTypeIndex = 0; ; iTypeIndex++)
- {
+ for (DWORD iTypeIndex = 0; ; iTypeIndex++) {
hr = pVideoConfig->GetAvailableSurfaceTypeByIndex(iTypeIndex, &surfaceType);
- if (FAILED(hr))
+ if (FAILED(hr)) {
break;
+ }
- if (surfaceType == DXVA2_SurfaceType_DecoderRenderTarget)
- {
+ if (surfaceType == DXVA2_SurfaceType_DecoderRenderTarget) {
hr = pVideoConfig->SetSurfaceType(DXVA2_SurfaceType_DecoderRenderTarget);
break;
}
@@ -2186,17 +2149,19 @@ HRESULT CMPCVideoDecFilter::CreateDXVA2Decoder(UINT nNumRenderTargets, IDirect3D
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);
+ pDecoderRenderTargets, nNumRenderTargets, &pDirectXVideoDec);
- if (SUCCEEDED (hr))
- {
- if (!m_pDXVADecoder)
- {
+ 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 (m_pDXVADecoder) {
+ m_pDXVADecoder->SetExtraData ((BYTE*)m_pAVCtx->extradata, m_pAVCtx->extradata_size);
+ }
}
m_pDXVADecoder->SetDirectXVideoDec (pDirectXVideoDec);
@@ -2214,18 +2179,14 @@ HRESULT CMPCVideoDecFilter::FindDXVA1DecoderConfiguration(IAMVideoAccelerator* p
pAMVideoAccelerator->GetUncompFormatsSupported (guidDecoder, &dwFormats, NULL);
- if (dwFormats > 0)
- {
+ 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))
- {
+ 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'))
- {
+ 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;
@@ -2242,11 +2203,11 @@ HRESULT CMPCVideoDecFilter::FindDXVA1DecoderConfiguration(IAMVideoAccelerator* p
HRESULT CMPCVideoDecFilter::CheckDXVA1Decoder(const GUID *pGuid)
{
- if (m_nCodecNb != -1)
- {
+ if (m_nCodecNb != -1) {
for (int i=0; i<MAX_SUPPORTED_MODE; i++)
- if (*ffCodecs[m_nCodecNb].DXVAModes->Decoder[i] == *pGuid)
+ if (*ffCodecs[m_nCodecNb].DXVAModes->Decoder[i] == *pGuid) {
return S_OK;
+ }
}
return E_INVALIDARG;
@@ -2260,11 +2221,11 @@ void CMPCVideoDecFilter::SetDXVA1Params(const GUID* pGuid, DDPIXELFORMAT* pPixel
WORD CMPCVideoDecFilter::GetDXVA1RestrictedMode()
{
- if (m_nCodecNb != -1)
- {
+ if (m_nCodecNb != -1) {
for (int i=0; i<MAX_SUPPORTED_MODE; i++)
- if (*ffCodecs[m_nCodecNb].DXVAModes->Decoder[i] == m_DXVADecoderGUID)
+ if (*ffCodecs[m_nCodecNb].DXVAModes->Decoder[i] == m_DXVADecoderGUID) {
return ffCodecs[m_nCodecNb].DXVAModes->RestrictedMode [i];
+ }
}
return DXVA_RESTRICTED_MODE_UNRESTRICTED;
@@ -2272,16 +2233,21 @@ WORD CMPCVideoDecFilter::GetDXVA1RestrictedMode()
HRESULT CMPCVideoDecFilter::CreateDXVA1Decoder(IAMVideoAccelerator* pAMVideoAccelerator, const GUID* pDecoderGuid, DWORD dwSurfaceCount)
{
- if (m_pDXVADecoder && m_DXVADecoderGUID == *pDecoderGuid)
+ 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);
+ if (m_pDXVADecoder) {
+ m_pDXVADecoder->SetExtraData ((BYTE*)m_pAVCtx->extradata, m_pAVCtx->extradata_size);
+ }
return S_OK;
}
@@ -2302,7 +2268,9 @@ STDMETHODIMP CMPCVideoDecFilter::GetPages(CAUUID* pPages)
pPages->pElems = (GUID*)CoTaskMemAlloc(sizeof(GUID) * pPages->cElems);
pPages->pElems[0] = __uuidof(CMPCVideoDecSettingsWnd);
- if (pPages->cElems>1) pPages->pElems[1] = __uuidof(CMPCVideoDecCodecWnd);
+ if (pPages->cElems>1) {
+ pPages->pElems[1] = __uuidof(CMPCVideoDecCodecWnd);
+ }
return S_OK;
}
@@ -2311,16 +2279,15 @@ STDMETHODIMP CMPCVideoDecFilter::CreatePage(const GUID& guid, IPropertyPage** pp
{
CheckPointer(ppPage, E_POINTER);
- if(*ppPage != NULL) return E_INVALIDARG;
+ if(*ppPage != NULL) {
+ return E_INVALIDARG;
+ }
HRESULT hr;
- if(guid == __uuidof(CMPCVideoDecSettingsWnd))
- {
+ if(guid == __uuidof(CMPCVideoDecSettingsWnd)) {
(*ppPage = DNew CInternalPropertyPageTempl<CMPCVideoDecSettingsWnd>(NULL, &hr))->AddRef();
- }
- else if(guid == __uuidof(CMPCVideoDecCodecWnd))
- {
+ } else if(guid == __uuidof(CMPCVideoDecCodecWnd)) {
(*ppPage = DNew CInternalPropertyPageTempl<CMPCVideoDecCodecWnd>(NULL, &hr))->AddRef();
}
@@ -2332,8 +2299,7 @@ STDMETHODIMP CMPCVideoDecFilter::CreatePage(const GUID& guid, IPropertyPage** pp
STDMETHODIMP CMPCVideoDecFilter::Apply()
{
CRegKey key;
- if(ERROR_SUCCESS == key.Create(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPC Video Decoder")))
- {
+ 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);
@@ -2392,10 +2358,11 @@ STDMETHODIMP_(int) CMPCVideoDecFilter::GetIDCTAlgo()
}
STDMETHODIMP_(GUID*) CMPCVideoDecFilter::GetDXVADecoderGuid()
{
- if (m_pGraph == NULL)
+ if (m_pGraph == NULL) {
return NULL;
- else
+ } else {
return &m_DXVADecoderGUID;
+ }
}
STDMETHODIMP CMPCVideoDecFilter::SetActiveCodecs(MPC_VIDEO_CODEC nValue)
{
diff --git a/src/filters/transform/MPCVideoDec/MPCVideoDecFilter.h b/src/filters/transform/MPCVideoDec/MPCVideoDecFilter.h
index 7800a0e16..19ec260a5 100644
--- a/src/filters/transform/MPCVideoDec/MPCVideoDecFilter.h
+++ b/src/filters/transform/MPCVideoDec/MPCVideoDecFilter.h
@@ -1,7 +1,7 @@
/*
* $Id$
*
- * (C) 2006-2010 see AUTHORS
+ * (C) 2006-2011 see AUTHORS
*
* This file is part of mplayerc.
*
@@ -44,22 +44,19 @@ class CCpuId;
#define MAX_BUFF_TIME 20
-typedef enum
-{
+typedef enum {
MODE_SOFTWARE,
MODE_DXVA1,
MODE_DXVA2
} DXVA_MODE;
-typedef struct
-{
+typedef struct {
REFERENCE_TIME rtStart;
REFERENCE_TIME rtStop;
} B_FRAME;
-typedef struct
-{
+typedef struct {
REFERENCE_TIME rtStart;
REFERENCE_TIME rtStop;
int nBuffPos;
@@ -117,6 +114,7 @@ protected:
REFERENCE_TIME m_rtLastStart; // rtStart for last delivered frame
int m_nCountEstimated; // Number of rtStart estimated since last rtStart received
+ double m_dRate;
bool m_bUseDXVA;
bool m_bUseFFmpeg;
@@ -162,8 +160,8 @@ protected:
void SetTypeSpecificFlags(IMediaSample* pMS);
HRESULT SoftwareDecode(IMediaSample* pIn, BYTE* pDataIn, int nSize, REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop);
-//void FindStartCodeVC1 (BYTE** pDataIn, int& nSize);
-//void FindStartCodeH264 (BYTE** pDataIn, int& nSize);
+ //void FindStartCodeVC1 (BYTE** pDataIn, int& nSize);
+ //void FindStartCodeH264 (BYTE** pDataIn, int& nSize);
bool AppendBuffer (BYTE* pDataIn, int nSize, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop);
bool FindPicture(int nIndex, int nStartCode);
void ShrinkBuffer();
@@ -190,7 +188,9 @@ public:
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;}
+ CTransformOutputPin* GetOutputPin() {
+ return m_pOutput;
+ }
void UpdateFrameTime (REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop);
// === Overriden DirectShow functions
@@ -241,19 +241,38 @@ public:
int PictHeight();
int PictWidthRounded();
int PictHeightRounded();
- inline bool UseDXVA2() {return (m_nDXVAMode == MODE_DXVA2);};
- void FlushDXVADecoder() {if (m_pDXVADecoder) m_pDXVADecoder->Flush();}
- inline AVCodecContext* GetAVCtx() {return m_pAVCtx;};
- inline AVFrame* GetFrame() {return m_pFrame;}
+ inline bool UseDXVA2() {
+ return (m_nDXVAMode == MODE_DXVA2);
+ };
+ void FlushDXVADecoder() {
+ if (m_pDXVADecoder) {
+ m_pDXVADecoder->Flush();
+ }
+ }
+ inline AVCodecContext* GetAVCtx() {
+ return m_pAVCtx;
+ };
+ inline AVFrame* GetFrame() {
+ return m_pFrame;
+ }
bool IsDXVASupported();
- inline bool IsReorderBFrame() { return m_bReorderBFrame;};
- inline int GetPCIVendor() {return m_nPCIVendor;};
- inline REFERENCE_TIME GetAvrTimePerFrame() {return m_rtAvrTimePerFrame;};
+ inline bool IsReorderBFrame() {
+ return m_bReorderBFrame;
+ };
+ inline int GetPCIVendor() {
+ return m_nPCIVendor;
+ };
+ inline REFERENCE_TIME GetAvrTimePerFrame() {
+ return m_rtAvrTimePerFrame;
+ };
+ inline double GetRate() { return m_dRate; };
void UpdateAspectRatio();
void ReorderBFrames(REFERENCE_TIME& rtStart, REFERENCE_TIME& rtStop);
// === DXVA1 functions
- DDPIXELFORMAT* GetPixelFormat() {return &m_PixelFormat;}
+ 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);
@@ -263,12 +282,14 @@ public:
// === DXVA2 functions
void FillInVideoDescription(DXVA2_VideoDesc *pDesc);
- DXVA2_ConfigPictureDecode* GetDXVA2Config() {return &m_DXVA2Config;};
+ 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);
+ 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 81b74bbf7..11f7d613a 100644
--- a/src/filters/transform/MPCVideoDec/MPCVideoDecSettingsWnd.cpp
+++ b/src/filters/transform/MPCVideoDec/MPCVideoDecSettingsWnd.cpp
@@ -37,20 +37,21 @@
// CMPCVideoDecSettingsWnd
//
-int g_AVDiscard[] =
-{
+int g_AVDiscard[] = {
-16, ///< AVDISCARD_NONE discard nothing
- 0, ///< AVDISCARD_DEFAULT discard useless packets like 0 size packets in avi
- 8, ///< AVDISCARD_NONREF discard all non reference
- 16, ///< AVDISCARD_BIDIR discard all bidirectional frames
- 32, ///< AVDISCARD_NONKEY discard all frames except keyframes
- 48, ///< AVDISCARD_ALL discard all
+ 0, ///< AVDISCARD_DEFAULT discard useless packets like 0 size packets in avi
+ 8, ///< AVDISCARD_NONREF discard all non reference
+ 16, ///< AVDISCARD_BIDIR discard all bidirectional frames
+ 32, ///< AVDISCARD_NONKEY discard all frames except keyframes
+ 48, ///< AVDISCARD_ALL discard all
};
int FindDiscardIndex(int nValue)
{
for (int i=0; i<countof (g_AVDiscard); i++)
- if (g_AVDiscard[i] == nValue) return i;
+ if (g_AVDiscard[i] == nValue) {
+ return i;
+ }
return 1;
}
@@ -66,9 +67,13 @@ bool CMPCVideoDecSettingsWnd::OnConnect(const CInterfaceList<IUnknown, &IID_IUnk
m_pMDF.Release();
POSITION pos = pUnks.GetHeadPosition();
- while(pos && !(m_pMDF = pUnks.GetNext(pos)));
+ while(pos && !(m_pMDF = pUnks.GetNext(pos))) {
+ ;
+ }
- if(!m_pMDF) return false;
+ if(!m_pMDF) {
+ return false;
+ }
return true;
}
@@ -86,7 +91,7 @@ bool CMPCVideoDecSettingsWnd::OnActivate()
#if HAS_FFMPEG_VIDEO_DECODERS
m_grpFFMpeg.Create (ResStr (IDS_VDF_FFSETTINGS), WS_VISIBLE|WS_CHILD | BS_GROUPBOX, CRect (10, nPosY, 350, nPosY+150), this, (UINT)IDC_STATIC);
- #if INTERNAL_DECODER_H264
+#if INTERNAL_DECODER_H264
// Decoding threads
nPosY += VERTICAL_SPACING;
@@ -101,9 +106,9 @@ bool CMPCVideoDecSettingsWnd::OnActivate()
m_cbThreadNumber.AddString (_T("7"));
m_cbThreadNumber.AddString (_T("8"));
- #endif /* INTERNAL_DECODER_H264 */
+#endif /* INTERNAL_DECODER_H264 */
- #if INTERNAL_DECODER_H264
+#if INTERNAL_DECODER_H264
// H264 deblocking mode
nPosY += VERTICAL_SPACING;
@@ -116,7 +121,7 @@ bool CMPCVideoDecSettingsWnd::OnActivate()
m_cbDiscardMode.AddString (ResStr (IDS_VDF_DBLK_NONKFRM));
m_cbDiscardMode.AddString (ResStr (IDS_VDF_DBLK_ALL));
- #endif /* INTERNAL_DECODER_H264 */
+#endif /* INTERNAL_DECODER_H264 */
// Error recognition
nPosY += VERTICAL_SPACING;
@@ -172,27 +177,24 @@ bool CMPCVideoDecSettingsWnd::OnActivate()
DxvaGui = m_pMDF->GetDXVADecoderGuid();
- if (DxvaGui != NULL)
- {
+ if (DxvaGui != NULL) {
CString DXVAMode = GetDXVAMode (DxvaGui);
m_edtDXVAMode.SetWindowText (DXVAMode);
- }
- else
- {
+ } else {
m_txtDXVAMode.ShowWindow (SW_HIDE);
m_edtDXVAMode.ShowWindow (SW_HIDE);
}
- for(CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow())
+ for(CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow()) {
pWnd->SetFont(&m_font, FALSE);
+ }
- if (m_pMDF)
- {
+ if (m_pMDF) {
#if HAS_FFMPEG_VIDEO_DECODERS
- #if INTERNAL_DECODER_H264
+#if INTERNAL_DECODER_H264
m_cbThreadNumber.SetCurSel (m_pMDF->GetThreadNumber() - 1);
m_cbDiscardMode.SetCurSel (FindDiscardIndex (m_pMDF->GetDiscardMode()));
- #endif
+#endif
m_cbErrorRecognition.SetCurSel (m_pMDF->GetErrorRecognition()-1);
m_cbIDCTAlgo.SetCurSel (m_pMDF->GetIDCTAlgo());
@@ -214,13 +216,12 @@ bool CMPCVideoDecSettingsWnd::OnApply()
{
OnDeactivate();
- if(m_pMDF && m_cbDXVACompatibilityCheck.m_hWnd)
- {
+ if(m_pMDF && m_cbDXVACompatibilityCheck.m_hWnd) {
#if HAS_FFMPEG_VIDEO_DECODERS
- #if INTERNAL_DECODER_H264
+#if INTERNAL_DECODER_H264
m_pMDF->SetThreadNumber (m_cbThreadNumber.GetCurSel() + 1);
m_pMDF->SetDiscardMode (g_AVDiscard[m_cbDiscardMode.GetCurSel()]);
- #endif /* INTERNAL_DECODER_H264 */
+#endif /* INTERNAL_DECODER_H264 */
m_pMDF->SetErrorRecognition (m_cbErrorRecognition.GetCurSel()+1);
m_pMDF->SetIDCTAlgo (m_cbIDCTAlgo.GetCurSel());
@@ -257,9 +258,13 @@ bool CMPCVideoDecCodecWnd::OnConnect(const CInterfaceList<IUnknown, &IID_IUnknow
m_pMDF.Release();
POSITION pos = pUnks.GetHeadPosition();
- while(pos && !(m_pMDF = pUnks.GetNext(pos)));
+ while(pos && !(m_pMDF = pUnks.GetNext(pos))) {
+ ;
+ }
- if(!m_pMDF) return false;
+ if(!m_pMDF) {
+ return false;
+ }
return true;
}
@@ -320,8 +325,9 @@ bool CMPCVideoDecCodecWnd::OnActivate()
m_lstCodecs.SetCheck (nPos++, (nActiveCodecs & MPCVD_THEORA) != 0);
#endif
- for(CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow())
+ for(CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow()) {
pWnd->SetFont(&m_font, FALSE);
+ }
return true;
}
@@ -334,35 +340,64 @@ bool CMPCVideoDecCodecWnd::OnApply()
{
OnDeactivate();
- if(m_pMDF)
- {
+ 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_H264
- if (m_lstCodecs.GetCheck (nPos++)) nActiveCodecs |= MPCVD_H264;
+ if (m_lstCodecs.GetCheck (nPos++)) {
+ nActiveCodecs |= MPCVD_H264;
+ }
#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_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_VP6;
- 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_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_VP6;
+ }
+ 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;
+ }
#endif
m_pMDF->SetActiveCodecs ((MPC_VIDEO_CODEC)nActiveCodecs);
diff --git a/src/filters/transform/MPCVideoDec/MPCVideoDecSettingsWnd.h b/src/filters/transform/MPCVideoDec/MPCVideoDecSettingsWnd.h
index 289b206b9..a6b372002 100644
--- a/src/filters/transform/MPCVideoDec/MPCVideoDecSettingsWnd.h
+++ b/src/filters/transform/MPCVideoDec/MPCVideoDecSettingsWnd.h
@@ -54,8 +54,7 @@ class __declspec(uuid("D5AA0389-D274-48e1-BF50-ACB05A56DDE0"))
CButton m_cbDXVA_SD;
- enum
- {
+ enum {
IDC_PP_THREAD_NUMBER = 10000,
IDC_PP_ENABLE_DEBLOCKING,
IDC_PP_DISCARD_MODE,
diff --git a/src/filters/transform/MPCVideoDec/TlibavcodecExt.cpp b/src/filters/transform/MPCVideoDec/TlibavcodecExt.cpp
index af7c78397..2ea37a49b 100644
--- a/src/filters/transform/MPCVideoDec/TlibavcodecExt.cpp
+++ b/src/filters/transform/MPCVideoDec/TlibavcodecExt.cpp
@@ -40,15 +40,17 @@ void TlibavcodecExt::ConnectTo(AVCodecContext *pAVCtx)
int TlibavcodecExt::get_buffer(AVCodecContext *c, AVFrame *pic)
{
int ret=c->opaque->ff_avcodec_default_get_buffer(c,pic);
- if (ret==0)
+ if (ret==0) {
c->opaque->OnGetBuffer(pic);
+ }
return ret;
}
int TlibavcodecExt::reget_buffer(AVCodecContext *c, AVFrame *pic)
{
int ret=c->opaque->ff_avcodec_default_reget_buffer(c,pic);
- if (ret==0)
+ if (ret==0) {
c->opaque->OnRegetBuffer(pic);
+ }
return ret;
}
void TlibavcodecExt::release_buffer(AVCodecContext *c, AVFrame *pic)
diff --git a/src/filters/transform/MPCVideoDec/TlibavcodecExt.h b/src/filters/transform/MPCVideoDec/TlibavcodecExt.h
index 7e7d5c051..37b7ccf8e 100644
--- a/src/filters/transform/MPCVideoDec/TlibavcodecExt.h
+++ b/src/filters/transform/MPCVideoDec/TlibavcodecExt.h
@@ -36,8 +36,7 @@ typedef void (*FUNC_AV_DEFAULT_RELEASE_BUFFER)(AVCodecContext *s, AVFrame *pic
typedef int (*FUNC_AV_DEFAULT_REGET_BUFFER)(AVCodecContext *s, AVFrame *pic);
-struct TlibavcodecExt
-{
+struct TlibavcodecExt {
protected:
static int get_buffer(AVCodecContext *s, AVFrame *pic);
static void release_buffer(AVCodecContext *s, AVFrame *pic);
diff --git a/src/filters/transform/MPCVideoDec/VideoDecDXVAAllocator.cpp b/src/filters/transform/MPCVideoDec/VideoDecDXVAAllocator.cpp
index 4cfcc495a..1d8579612 100644
--- a/src/filters/transform/MPCVideoDec/VideoDecDXVAAllocator.cpp
+++ b/src/filters/transform/MPCVideoDec/VideoDecDXVAAllocator.cpp
@@ -40,16 +40,12 @@ STDMETHODIMP CDXVA2Sample::QueryInterface(REFIID riid, __deref_out void **ppv)
CheckPointer(ppv,E_POINTER);
ValidateReadWritePtr(ppv,sizeof(PVOID));
- if (riid == __uuidof(IMFGetService))
- {
+ if (riid == __uuidof(IMFGetService)) {
return GetInterface((IMFGetService*) this, ppv);
}
- if (riid == __uuidof(IMPCDXVA2Sample))
- {
+ if (riid == __uuidof(IMPCDXVA2Sample)) {
return GetInterface((IMPCDXVA2Sample*) this, ppv);
- }
- else
- {
+ } else {
return CMediaSample::QueryInterface(riid, ppv);
}
}
@@ -70,16 +66,11 @@ STDMETHODIMP_(ULONG) CDXVA2Sample::Release()
// IMFGetService::GetService
STDMETHODIMP CDXVA2Sample::GetService(REFGUID guidService, REFIID riid, LPVOID *ppv)
{
- if (guidService != MR_BUFFER_SERVICE)
- {
+ if (guidService != MR_BUFFER_SERVICE) {
return MF_E_UNSUPPORTED_SERVICE;
- }
- else if (m_pSurface == NULL)
- {
+ } else if (m_pSurface == NULL) {
return E_NOINTERFACE;
- }
- else
- {
+ } else {
return m_pSurface->QueryInterface(riid, ppv);
}
}
@@ -131,8 +122,7 @@ HRESULT CVideoDecDXVAAllocator::Alloc()
hr = __super::Alloc();
- if (SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
// Free the old resources.
Free();
@@ -140,20 +130,16 @@ HRESULT CVideoDecDXVAAllocator::Alloc()
// Allocate a new array of pointers.
m_ppRTSurfaceArray = DNew IDirect3DSurface9*[m_lCount];
- if (m_ppRTSurfaceArray == NULL)
- {
+ if (m_ppRTSurfaceArray == NULL) {
hr = E_OUTOFMEMORY;
- }
- else
- {
+ } else {
ZeroMemory(m_ppRTSurfaceArray, sizeof(IDirect3DSurface9*) * m_lCount);
}
}
// Allocate the surfaces.
D3DFORMAT m_dwFormat = m_pVideoDecFilter->m_VideoDesc.Format;
- if (SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
hr = pDXVA2Service->CreateSurface(
m_pVideoDecFilter->PictWidthRounded(),
m_pVideoDecFilter->PictHeightRounded(),
@@ -167,19 +153,15 @@ HRESULT CVideoDecDXVAAllocator::Alloc()
);
}
- if (SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
// Important : create samples in reverse order !
- for (m_lAllocated = m_lCount-1; m_lAllocated >= 0; m_lAllocated--)
- {
+ for (m_lAllocated = m_lCount-1; m_lAllocated >= 0; m_lAllocated--) {
CDXVA2Sample *pSample = DNew CDXVA2Sample(this, &hr);
- if (pSample == NULL)
- {
+ if (pSample == NULL) {
hr = E_OUTOFMEMORY;
break;
}
- if (FAILED(hr))
- {
+ if (FAILED(hr)) {
break;
}
// Assign the Direct3D surface pointer and the index.
@@ -190,11 +172,12 @@ HRESULT CVideoDecDXVAAllocator::Alloc()
}
hr = m_pVideoDecFilter->CreateDXVA2Decoder (m_lCount, m_ppRTSurfaceArray);
- if (FAILED (hr)) Free();
+ if (FAILED (hr)) {
+ Free();
+ }
}
- if (SUCCEEDED(hr))
- {
+ if (SUCCEEDED(hr)) {
m_bChanged = FALSE;
}
return hr;
@@ -205,22 +188,19 @@ void CVideoDecDXVAAllocator::Free()
CMediaSample *pSample = NULL;
m_pVideoDecFilter->FlushDXVADecoder();
-// m_FreeSurface.RemoveAll();
- do
- {
+ // m_FreeSurface.RemoveAll();
+ do {
pSample = m_lFree.RemoveHead();
- if (pSample)
- {
+ if (pSample) {
delete pSample;
}
} while (pSample);
- if (m_ppRTSurfaceArray)
- {
- for (long i = 0; i < m_nSurfaceArrayCount; i++)
- {
- if (m_ppRTSurfaceArray[i] != NULL)
+ if (m_ppRTSurfaceArray) {
+ for (long i = 0; i < m_nSurfaceArrayCount; i++) {
+ if (m_ppRTSurfaceArray[i] != NULL) {
m_ppRTSurfaceArray[i]->Release();
+ }
}
delete [] m_ppRTSurfaceArray;
diff --git a/src/filters/transform/MPCVideoDec/VideoDecDXVAAllocator.h b/src/filters/transform/MPCVideoDec/VideoDecDXVAAllocator.h
index 0f20d4383..7b3206112 100644
--- a/src/filters/transform/MPCVideoDec/VideoDecDXVAAllocator.h
+++ b/src/filters/transform/MPCVideoDec/VideoDecDXVAAllocator.h
@@ -33,8 +33,7 @@ class CVideoDecDXVAAllocator;
interface __declspec(uuid("AE7EC2A2-1913-4a80-8DD6-DF1497ABA494"))
IMPCDXVA2Sample :
-public IUnknown
-{
+public IUnknown {
STDMETHOD_(int, GetDXSurfaceId()) = 0;
};
@@ -80,13 +79,13 @@ public:
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:
diff --git a/src/filters/transform/MPCVideoDec/VideoDecOutputPin.cpp b/src/filters/transform/MPCVideoDec/VideoDecOutputPin.cpp
index 06dbbbd4e..4fcc513dd 100644
--- a/src/filters/transform/MPCVideoDec/VideoDecOutputPin.cpp
+++ b/src/filters/transform/MPCVideoDec/VideoDecOutputPin.cpp
@@ -44,24 +44,21 @@ CVideoDecOutputPin::~CVideoDecOutputPin(void)
HRESULT CVideoDecOutputPin::InitAllocator(IMemAllocator **ppAlloc)
{
TRACE("CVideoDecOutputPin::InitAllocator");
- if (m_pVideoDecFilter->UseDXVA2())
- {
+ if (m_pVideoDecFilter->UseDXVA2()) {
HRESULT hr = S_FALSE;
m_pDXVA2Allocator = DNew CVideoDecDXVAAllocator(m_pVideoDecFilter, &hr);
- if (!m_pDXVA2Allocator)
- {
+ if (!m_pDXVA2Allocator) {
return E_OUTOFMEMORY;
}
- if (FAILED(hr))
- {
+ if (FAILED(hr)) {
delete m_pDXVA2Allocator;
return hr;
}
// Return the IMemAllocator interface.
return m_pDXVA2Allocator->QueryInterface(__uuidof(IMemAllocator), (void **)ppAlloc);
- }
- else
+ } else {
return __super::InitAllocator(ppAlloc);
+ }
}
STDMETHODIMP CVideoDecOutputPin::NonDelegatingQueryInterface(REFIID riid, void** ppv)
@@ -77,18 +74,15 @@ STDMETHODIMP CVideoDecOutputPin::GetUncompSurfacesInfo(const GUID *pGuid, LPAMVA
{
HRESULT hr = E_INVALIDARG;
- if (SUCCEEDED (m_pVideoDecFilter->CheckDXVA1Decoder (pGuid)))
- {
+ if (SUCCEEDED (m_pVideoDecFilter->CheckDXVA1Decoder (pGuid))) {
CComQIPtr<IAMVideoAccelerator> pAMVideoAccelerator = GetConnected();
- if (pAMVideoAccelerator)
- {
+ if (pAMVideoAccelerator) {
pUncompBufferInfo->dwMaxNumSurfaces = m_pVideoDecFilter->GetPicEntryNumber();
pUncompBufferInfo->dwMinNumSurfaces = m_pVideoDecFilter->GetPicEntryNumber();
hr = m_pVideoDecFilter->FindDXVA1DecoderConfiguration (pAMVideoAccelerator, pGuid, &pUncompBufferInfo->ddUncompPixelFormat);
- if (SUCCEEDED (hr))
- {
+ if (SUCCEEDED (hr)) {
memcpy (&m_ddUncompPixelFormat, &pUncompBufferInfo->ddUncompPixelFormat, sizeof(DDPIXELFORMAT));
m_GuidDecoderDXVA1 = *pGuid;
}
@@ -112,19 +106,16 @@ STDMETHODIMP CVideoDecOutputPin::GetCreateVideoAcceleratorData(const GUID *pGuid
CComQIPtr<IAMVideoAccelerator> pAMVideoAccelerator = GetConnected();
DXVA_ConnectMode* pConnectMode;
- if (pAMVideoAccelerator)
- {
+ 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))
- {
+ if (SUCCEEDED (hr)) {
hr = m_pVideoDecFilter->CreateDXVA1Decoder (pAMVideoAccelerator, pGuid, m_dwDXVA1SurfaceCount);
- if (SUCCEEDED (hr))
- {
+ if (SUCCEEDED (hr)) {
m_pVideoDecFilter->SetDXVA1Params (&m_GuidDecoderDXVA1, &m_ddUncompPixelFormat);
pConnectMode = (DXVA_ConnectMode*)CoTaskMemAlloc (sizeof(DXVA_ConnectMode));
diff --git a/src/filters/transform/MPCVideoDec/ffImgfmt.cpp b/src/filters/transform/MPCVideoDec/ffImgfmt.cpp
index 026a08fc9..b6b217898 100644
--- a/src/filters/transform/MPCVideoDec/ffImgfmt.cpp
+++ b/src/filters/transform/MPCVideoDec/ffImgfmt.cpp
@@ -24,955 +24,912 @@
#include <moreuuids.h>
#include "char_t.h"
-const TcspInfo cspInfos[]=
-{
- {
- FF_CSP_420P,_l("YV12"),
- 1,12, //Bpp
- 3, //numplanes
- {0,1,1,0}, //shiftX
- {0,1,1,0}, //shiftY
- {0,128,128,0}, //black,
- FOURCC_YV12, FOURCC_YV12, &MEDIASUBTYPE_YV12
- },
- {
- FF_CSP_422P,_l("422P"),
- 1,18, //Bpp
- 3, //numplanes
- {0,1,1,0}, //shiftX
- {0,0,0,0}, //shiftY
- {0,128,128,0}, //black
- FOURCC_422P, FOURCC_422P, &MEDIASUBTYPE_422P
- },
- {
- FF_CSP_444P,_l("444P"),
- 1,24, //Bpp
- 3, //numplanes
- {0,0,0,0}, //shiftX
- {0,0,0,0}, //shiftY
- {0,128,128,0}, //black
- FOURCC_444P, FOURCC_444P, &MEDIASUBTYPE_444P
- },
- {
- FF_CSP_411P,_l("411P"),
- 1,17, //Bpp
- 3, //numplanes
- {0,2,2,0}, //shiftX
- {0,0,0,0}, //shiftY
- {0,128,128,0}, //black
- FOURCC_411P, FOURCC_411P, &MEDIASUBTYPE_411P
- },
- {
- FF_CSP_410P,_l("410P"),
- 1,10, //Bpp
- 3, //numplanes
- {0,2,2,0}, //shiftX
- {0,2,2,0}, //shiftY
- {0,128,128,0}, //black
- FOURCC_410P, FOURCC_410P, &MEDIASUBTYPE_410P
- },
+const TcspInfo cspInfos[]= {
+ {
+ FF_CSP_420P,_l("YV12"),
+ 1,12, //Bpp
+ 3, //numplanes
+ {0,1,1,0}, //shiftX
+ {0,1,1,0}, //shiftY
+ {0,128,128,0}, //black,
+ FOURCC_YV12, FOURCC_YV12, &MEDIASUBTYPE_YV12
+ },
+ {
+ FF_CSP_422P,_l("422P"),
+ 1,18, //Bpp
+ 3, //numplanes
+ {0,1,1,0}, //shiftX
+ {0,0,0,0}, //shiftY
+ {0,128,128,0}, //black
+ FOURCC_422P, FOURCC_422P, &MEDIASUBTYPE_422P
+ },
+ {
+ FF_CSP_444P,_l("444P"),
+ 1,24, //Bpp
+ 3, //numplanes
+ {0,0,0,0}, //shiftX
+ {0,0,0,0}, //shiftY
+ {0,128,128,0}, //black
+ FOURCC_444P, FOURCC_444P, &MEDIASUBTYPE_444P
+ },
+ {
+ FF_CSP_411P,_l("411P"),
+ 1,17, //Bpp
+ 3, //numplanes
+ {0,2,2,0}, //shiftX
+ {0,0,0,0}, //shiftY
+ {0,128,128,0}, //black
+ FOURCC_411P, FOURCC_411P, &MEDIASUBTYPE_411P
+ },
+ {
+ FF_CSP_410P,_l("410P"),
+ 1,10, //Bpp
+ 3, //numplanes
+ {0,2,2,0}, //shiftX
+ {0,2,2,0}, //shiftY
+ {0,128,128,0}, //black
+ FOURCC_410P, FOURCC_410P, &MEDIASUBTYPE_410P
+ },
- {
- FF_CSP_YUY2,_l("YUY2"),
- 2,16, //Bpp
- 1, //numplanes
- {0,0,0,0}, //shiftX
- {0,0,0,0}, //shiftY
- {0x8000,0,0,0}, //black
- FOURCC_YUY2, FOURCC_YUY2, &MEDIASUBTYPE_YUY2,
- 0,1 //packedLumaOffset,packedChromaOffset
- },
- {
- FF_CSP_UYVY,_l("UYVY"),
- 2,16, //Bpp
- 1, //numplanes
- {0,0,0,0}, //shiftX
- {0,0,0,0}, //shiftY
- {0x0080,0,0,0}, //black
- FOURCC_UYVY, FOURCC_UYVY, &MEDIASUBTYPE_UYVY,
- 1,0 //packedLumaOffset,packedChromaOffset
- },
- {
- FF_CSP_YVYU,_l("YVYU"),
- 2,16, //Bpp
- 1, //numplanes
- {0,0,0,0}, //shiftX
- {0,0,0,0}, //shiftY
- {0x8000,0,0,0}, //black
- FOURCC_YVYU, FOURCC_YVYU, &MEDIASUBTYPE_YVYU,
- 0,1 //packedLumaOffset,packedChromaOffset
- },
- {
- FF_CSP_VYUY,_l("VYUY"),
- 2,16, //Bpp
- 1, //numplanes
- {0,0,0,0}, //shiftX
- {0,0,0,0}, //shiftY
- {0x0080,0,0,0}, //black
- FOURCC_VYUY, FOURCC_VYUY, &MEDIASUBTYPE_VYUY,
- 1,0 //packedLumaOffset,packedChromaOffset
- },
+ {
+ FF_CSP_YUY2,_l("YUY2"),
+ 2,16, //Bpp
+ 1, //numplanes
+ {0,0,0,0}, //shiftX
+ {0,0,0,0}, //shiftY
+ {0x8000,0,0,0}, //black
+ FOURCC_YUY2, FOURCC_YUY2, &MEDIASUBTYPE_YUY2,
+ 0,1 //packedLumaOffset,packedChromaOffset
+ },
+ {
+ FF_CSP_UYVY,_l("UYVY"),
+ 2,16, //Bpp
+ 1, //numplanes
+ {0,0,0,0}, //shiftX
+ {0,0,0,0}, //shiftY
+ {0x0080,0,0,0}, //black
+ FOURCC_UYVY, FOURCC_UYVY, &MEDIASUBTYPE_UYVY,
+ 1,0 //packedLumaOffset,packedChromaOffset
+ },
+ {
+ FF_CSP_YVYU,_l("YVYU"),
+ 2,16, //Bpp
+ 1, //numplanes
+ {0,0,0,0}, //shiftX
+ {0,0,0,0}, //shiftY
+ {0x8000,0,0,0}, //black
+ FOURCC_YVYU, FOURCC_YVYU, &MEDIASUBTYPE_YVYU,
+ 0,1 //packedLumaOffset,packedChromaOffset
+ },
+ {
+ FF_CSP_VYUY,_l("VYUY"),
+ 2,16, //Bpp
+ 1, //numplanes
+ {0,0,0,0}, //shiftX
+ {0,0,0,0}, //shiftY
+ {0x0080,0,0,0}, //black
+ FOURCC_VYUY, FOURCC_VYUY, &MEDIASUBTYPE_VYUY,
+ 1,0 //packedLumaOffset,packedChromaOffset
+ },
- {
- FF_CSP_ABGR,_l("ABGR"),
- 4,32, //Bpp
- 1, //numplanes
- {0,0,0,0}, //shiftX
- {0,0,0,0}, //shiftY
- {0,0,0,0}, //black
- BI_RGB, 0, &MEDIASUBTYPE_RGB32
- },
- {
- FF_CSP_RGBA,_l("RGBA"),
- 4,32, //Bpp
- 1, //numplanes
- {0,0,0,0}, //shiftX
- {0,0,0,0}, //shiftY
- {0,0,0,0}, //black
- BI_RGB, 0, &MEDIASUBTYPE_RGB32
- },
- {
- FF_CSP_BGR32,_l("BGR32"),
- 4,32, //Bpp
- 1, //numplanes
- {0,0,0,0}, //shiftX
- {0,0,0,0}, //shiftY
- {0,0,0,0}, //black
- BI_RGB, 0, &MEDIASUBTYPE_RGB32
- },
- {
- FF_CSP_BGR24,_l("BGR24"),
- 3,24, //Bpp
- 1, //numplanes
- {0,0,0,0}, //shiftX
- {0,0,0,0}, //shiftY
- {0,0,0,0}, //black
- BI_RGB, 0, &MEDIASUBTYPE_RGB24
- },
- {
- FF_CSP_BGR15,_l("BGR15"),
- 2,16, //Bpp
- 1, //numplanes
- {0,0,0,0}, //shiftX
- {0,0,0,0}, //shiftY
- {0,0,0,0}, //black
- BI_RGB, 0, &MEDIASUBTYPE_RGB555
- },
- {
- FF_CSP_BGR16,_l("BGR16"),
- 2,16, //Bpp
- 1, //numplanes
- {0,0,0,0}, //shiftX
- {0,0,0,0}, //shiftY
- {0,0,0,0}, //black
- BI_RGB, 0, &MEDIASUBTYPE_RGB565
- },
- {
- FF_CSP_RGB32,_l("RGB32"),
- 4,32, //Bpp
- 1, //numplanes
- {0,0,0,0}, //shiftX
- {0,0,0,0}, //shiftY
- {0,0,0,0}, //black
- BI_RGB, FOURCC_RGB3, &MEDIASUBTYPE_RGB32
- },
- {
- FF_CSP_RGB24,_l("RGB24"),
- 3,24, //Bpp
- 1, //numplanes
- {0,0,0,0}, //shiftX
- {0,0,0,0}, //shiftY
- {0,0,0,0}, //black
- BI_RGB, FOURCC_RGB2, &MEDIASUBTYPE_RGB24
- },
- {
- FF_CSP_RGB15,_l("RGB15"),
- 2,16, //Bpp
- 1, //numplanes
- {0,0,0,0}, //shiftX
- {0,0,0,0}, //shiftY
- {0,0,0,0}, //black
- BI_RGB, FOURCC_RGB5, &MEDIASUBTYPE_RGB555
- },
- {
- FF_CSP_RGB16,_l("RGB16"),
- 2,16, //Bpp
- 1, //numplanes
- {0,0,0,0}, //shiftX
- {0,0,0,0}, //shiftY
- {0,0,0,0}, //black
- BI_RGB, FOURCC_RGB6, &MEDIASUBTYPE_RGB565
- },
+ {
+ FF_CSP_ABGR,_l("ABGR"),
+ 4,32, //Bpp
+ 1, //numplanes
+ {0,0,0,0}, //shiftX
+ {0,0,0,0}, //shiftY
+ {0,0,0,0}, //black
+ BI_RGB, 0, &MEDIASUBTYPE_RGB32
+ },
+ {
+ FF_CSP_RGBA,_l("RGBA"),
+ 4,32, //Bpp
+ 1, //numplanes
+ {0,0,0,0}, //shiftX
+ {0,0,0,0}, //shiftY
+ {0,0,0,0}, //black
+ BI_RGB, 0, &MEDIASUBTYPE_RGB32
+ },
+ {
+ FF_CSP_BGR32,_l("BGR32"),
+ 4,32, //Bpp
+ 1, //numplanes
+ {0,0,0,0}, //shiftX
+ {0,0,0,0}, //shiftY
+ {0,0,0,0}, //black
+ BI_RGB, 0, &MEDIASUBTYPE_RGB32
+ },
+ {
+ FF_CSP_BGR24,_l("BGR24"),
+ 3,24, //Bpp
+ 1, //numplanes
+ {0,0,0,0}, //shiftX
+ {0,0,0,0}, //shiftY
+ {0,0,0,0}, //black
+ BI_RGB, 0, &MEDIASUBTYPE_RGB24
+ },
+ {
+ FF_CSP_BGR15,_l("BGR15"),
+ 2,16, //Bpp
+ 1, //numplanes
+ {0,0,0,0}, //shiftX
+ {0,0,0,0}, //shiftY
+ {0,0,0,0}, //black
+ BI_RGB, 0, &MEDIASUBTYPE_RGB555
+ },
+ {
+ FF_CSP_BGR16,_l("BGR16"),
+ 2,16, //Bpp
+ 1, //numplanes
+ {0,0,0,0}, //shiftX
+ {0,0,0,0}, //shiftY
+ {0,0,0,0}, //black
+ BI_RGB, 0, &MEDIASUBTYPE_RGB565
+ },
+ {
+ FF_CSP_RGB32,_l("RGB32"),
+ 4,32, //Bpp
+ 1, //numplanes
+ {0,0,0,0}, //shiftX
+ {0,0,0,0}, //shiftY
+ {0,0,0,0}, //black
+ BI_RGB, FOURCC_RGB3, &MEDIASUBTYPE_RGB32
+ },
+ {
+ FF_CSP_RGB24,_l("RGB24"),
+ 3,24, //Bpp
+ 1, //numplanes
+ {0,0,0,0}, //shiftX
+ {0,0,0,0}, //shiftY
+ {0,0,0,0}, //black
+ BI_RGB, FOURCC_RGB2, &MEDIASUBTYPE_RGB24
+ },
+ {
+ FF_CSP_RGB15,_l("RGB15"),
+ 2,16, //Bpp
+ 1, //numplanes
+ {0,0,0,0}, //shiftX
+ {0,0,0,0}, //shiftY
+ {0,0,0,0}, //black
+ BI_RGB, FOURCC_RGB5, &MEDIASUBTYPE_RGB555
+ },
+ {
+ FF_CSP_RGB16,_l("RGB16"),
+ 2,16, //Bpp
+ 1, //numplanes
+ {0,0,0,0}, //shiftX
+ {0,0,0,0}, //shiftY
+ {0,0,0,0}, //black
+ BI_RGB, FOURCC_RGB6, &MEDIASUBTYPE_RGB565
+ },
- {
- FF_CSP_PAL8,_l("pal8"),
- 1,8, //Bpp
- 1, //numplanes
- {0,0,0,0}, //shiftX
- {0,0,0,0}, //shiftY
- {0,0,0,0}, //black
- BI_RGB, 0, &MEDIASUBTYPE_RGB8
- },
- {
- FF_CSP_CLJR,_l("cljr"),
- 1,16, //Bpp
- 1, //numplanes
- {0,0,0,0}, //shiftX
- {0,0,0,0}, //shiftY
- {0,0,0,0}, //black
- FOURCC_CLJR, FOURCC_CLJR, &MEDIASUBTYPE_CLJR
- },
- {
- FF_CSP_Y800,_l("gray"),
- 1,8, //Bpp
- 1, //numplanes
- {0,0,0,0}, //shiftX
- {0,0,0,0}, //shiftY
- {0,0,0,0}, //black
- FOURCC_Y800, FOURCC_Y800, &MEDIASUBTYPE_Y800
- },
- {
- FF_CSP_NV12,_l("NV12"),
- 1,12, //Bpp
- 2, //numplanes
- {0,0,0,0}, //shiftX
- {0,1,1,0}, //shiftY
- {0,128,128,0}, //black
- FOURCC_NV12, FOURCC_NV12, &MEDIASUBTYPE_NV12
- },
- 0
+ {
+ FF_CSP_PAL8,_l("pal8"),
+ 1,8, //Bpp
+ 1, //numplanes
+ {0,0,0,0}, //shiftX
+ {0,0,0,0}, //shiftY
+ {0,0,0,0}, //black
+ BI_RGB, 0, &MEDIASUBTYPE_RGB8
+ },
+ {
+ FF_CSP_CLJR,_l("cljr"),
+ 1,16, //Bpp
+ 1, //numplanes
+ {0,0,0,0}, //shiftX
+ {0,0,0,0}, //shiftY
+ {0,0,0,0}, //black
+ FOURCC_CLJR, FOURCC_CLJR, &MEDIASUBTYPE_CLJR
+ },
+ {
+ FF_CSP_Y800,_l("gray"),
+ 1,8, //Bpp
+ 1, //numplanes
+ {0,0,0,0}, //shiftX
+ {0,0,0,0}, //shiftY
+ {0,0,0,0}, //black
+ FOURCC_Y800, FOURCC_Y800, &MEDIASUBTYPE_Y800
+ },
+ {
+ FF_CSP_NV12,_l("NV12"),
+ 1,12, //Bpp
+ 2, //numplanes
+ {0,0,0,0}, //shiftX
+ {0,1,1,0}, //shiftY
+ {0,128,128,0}, //black
+ FOURCC_NV12, FOURCC_NV12, &MEDIASUBTYPE_NV12
+ },
+ 0
};
-TcspInfo cspInfoIYUV=
-{
- FF_CSP_420P,_l("YV12"),
- 1,12, //Bpp
- 3, //numplanes
- {0,1,1,0}, //shiftX
- {0,1,1,0}, //shiftY
- {0,128,128,0}, //black,
- FOURCC_IYUV, FOURCC_IYUV, &MEDIASUBTYPE_IYUV
+TcspInfo cspInfoIYUV= {
+ FF_CSP_420P,_l("YV12"),
+ 1,12, //Bpp
+ 3, //numplanes
+ {0,1,1,0}, //shiftX
+ {0,1,1,0}, //shiftY
+ {0,128,128,0}, //black,
+ FOURCC_IYUV, FOURCC_IYUV, &MEDIASUBTYPE_IYUV
};
-TcspInfo cspInfoNV21=
-{
- FF_CSP_NV12,_l("NV21"),
- 1,12, //Bpp
- 2, //numplanes
- {0,0,0,0}, //shiftX
- {0,1,1,0}, //shiftY
- {0,128,128,0}, //black
- FOURCC_NV21, FOURCC_NV21, &MEDIASUBTYPE_NV21
+TcspInfo cspInfoNV21= {
+ FF_CSP_NV12,_l("NV21"),
+ 1,12, //Bpp
+ 2, //numplanes
+ {0,0,0,0}, //shiftX
+ {0,1,1,0}, //shiftY
+ {0,128,128,0}, //black
+ FOURCC_NV21, FOURCC_NV21, &MEDIASUBTYPE_NV21
};
-const TcspFcc cspFccs[]=
-{
- _l("YV12") ,FOURCC_YV12,FF_CSP_420P|FF_CSP_FLAGS_YUV_ADJ,false,true,
- _l("I420/IYUV"),FOURCC_I420,FF_CSP_420P|FF_CSP_FLAGS_YUV_ADJ|FF_CSP_FLAGS_YUV_ORDER,false,true,
- _l("YUY2") ,FOURCC_YUY2,FF_CSP_YUY2,false,true,
- _l("YVYU") ,FOURCC_YVYU,FF_CSP_YVYU,false,true,
- _l("UYVY") ,FOURCC_UYVY,FF_CSP_UYVY,false,true,
- _l("VYUY") ,FOURCC_VYUY,FF_CSP_VYUY,false,true,
- _l("RGB32") ,FOURCC_RGB3,FF_CSP_RGB32,true,true,
- _l("RGB24") ,FOURCC_RGB2,FF_CSP_RGB24,true,true,
- _l("RGB555") ,FOURCC_RGB5,FF_CSP_RGB15,true,true,
- _l("RGB565") ,FOURCC_RGB6,FF_CSP_RGB16,true,true,
- _l("CLJR") ,FOURCC_CLJR,FF_CSP_CLJR,false,false,
- _l("Y800") ,FOURCC_Y800,FF_CSP_Y800,false,true,
- _l("NV12") ,FOURCC_NV12,FF_CSP_NV12,false,false,
- _l("NV21") ,FOURCC_NV21,FF_CSP_NV12|FF_CSP_FLAGS_YUV_ORDER,false,false,
- NULL,0
+const TcspFcc cspFccs[]= {
+ _l("YV12") ,FOURCC_YV12,FF_CSP_420P|FF_CSP_FLAGS_YUV_ADJ,false,true,
+ _l("I420/IYUV"),FOURCC_I420,FF_CSP_420P|FF_CSP_FLAGS_YUV_ADJ|FF_CSP_FLAGS_YUV_ORDER,false,true,
+ _l("YUY2") ,FOURCC_YUY2,FF_CSP_YUY2,false,true,
+ _l("YVYU") ,FOURCC_YVYU,FF_CSP_YVYU,false,true,
+ _l("UYVY") ,FOURCC_UYVY,FF_CSP_UYVY,false,true,
+ _l("VYUY") ,FOURCC_VYUY,FF_CSP_VYUY,false,true,
+ _l("RGB32") ,FOURCC_RGB3,FF_CSP_RGB32,true,true,
+ _l("RGB24") ,FOURCC_RGB2,FF_CSP_RGB24,true,true,
+ _l("RGB555") ,FOURCC_RGB5,FF_CSP_RGB15,true,true,
+ _l("RGB565") ,FOURCC_RGB6,FF_CSP_RGB16,true,true,
+ _l("CLJR") ,FOURCC_CLJR,FF_CSP_CLJR,false,false,
+ _l("Y800") ,FOURCC_Y800,FF_CSP_Y800,false,true,
+ _l("NV12") ,FOURCC_NV12,FF_CSP_NV12,false,false,
+ _l("NV21") ,FOURCC_NV21,FF_CSP_NV12|FF_CSP_FLAGS_YUV_ORDER,false,false,
+ NULL,0
};
char_t* csp_getName(int csp,char_t *buf,size_t len)
{
- return csp_getName2(csp_getInfo(csp),csp,buf,len);
+ return csp_getName2(csp_getInfo(csp),csp,buf,len);
}
char_t* csp_getName2(const TcspInfo *cspInfo,int csp,char_t *buf,size_t len)
{
- const char_t *colorspaceName=cspInfo?cspInfo->name:_l("unknown");
- _sntprintf_s(buf,
- len,
- _TRUNCATE,
- _l("%s%s%s%s%s%s"),
- colorspaceName,
- csp & FF_CSP_FLAGS_VFLIP ? _l(",flipped") : _l(""),
- csp & FF_CSP_FLAGS_INTERLACED ? _l(",interlaced") : _l(""),
- csp & FF_CSP_FLAGS_YUV_ADJ ? _l(",adj") : _l(""),
- csp & FF_CSP_FLAGS_YUV_ORDER ? _l(",VU") : _l(""),
- csp & FF_CSP_FLAGS_YUV_JPEG ? _l(",JPEG") : _l(""));
- return buf;
+ const char_t *colorspaceName=cspInfo?cspInfo->name:_l("unknown");
+ _sntprintf_s(buf,
+ len,
+ _TRUNCATE,
+ _l("%s%s%s%s%s%s"),
+ colorspaceName,
+ csp & FF_CSP_FLAGS_VFLIP ? _l(",flipped") : _l(""),
+ csp & FF_CSP_FLAGS_INTERLACED ? _l(",interlaced") : _l(""),
+ csp & FF_CSP_FLAGS_YUV_ADJ ? _l(",adj") : _l(""),
+ csp & FF_CSP_FLAGS_YUV_ORDER ? _l(",VU") : _l(""),
+ csp & FF_CSP_FLAGS_YUV_JPEG ? _l(",JPEG") : _l(""));
+ return buf;
}
const TcspInfo* csp_getInfoFcc(FOURCC fcccsp)
{
- if (fcccsp==FOURCC_IYUV || fcccsp==FOURCC_I420)
- return &cspInfoIYUV;
- else
- {
- for (int i=0;i<FF_CSPS_NUM;i++)
- if (cspInfos[i].fcccsp==fcccsp)
- return cspInfos+i;
- return NULL;
- }
+ if (fcccsp==FOURCC_IYUV || fcccsp==FOURCC_I420) {
+ return &cspInfoIYUV;
+ } else {
+ for (int i=0; i<FF_CSPS_NUM; i++)
+ if (cspInfos[i].fcccsp==fcccsp) {
+ return cspInfos+i;
+ }
+ return NULL;
+ }
}
int csp_bestMatch(int inCSP,int wantedCSPS,int *rank)
{
- int outCSP=inCSP&wantedCSPS&FF_CSPS_MASK;
- if (outCSP)
- {
- if (rank) *rank=100;
- return outCSP|(inCSP&~FF_CSPS_MASK);
- }
-
- const int *bestcsps=NULL;
- switch (inCSP&FF_CSPS_MASK)
- {
- case FF_CSP_420P:
- {
- static const int best[FF_CSPS_NUM]=
- {
- FF_CSP_422P ,
- FF_CSP_444P ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_RGB32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_BGR16,
- FF_CSP_RGB16,
- FF_CSP_BGR15,
- FF_CSP_RGB15,
- FF_CSP_NULL
- };
- bestcsps=best;
- break;
- }
- case FF_CSP_422P:
- {
- static const int best[FF_CSPS_NUM]=
- {
- FF_CSP_YUY2 ,
- FF_CSP_420P ,
- FF_CSP_444P ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_RGB32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_BGR16,
- FF_CSP_RGB16,
- FF_CSP_BGR15,
- FF_CSP_RGB15,
- FF_CSP_NULL
- };
- bestcsps=best;
- break;
- }
- case FF_CSP_444P:
- {
- static const int best[FF_CSPS_NUM]=
- {
- FF_CSP_422P ,
- FF_CSP_420P ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_RGB32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_BGR16,
- FF_CSP_RGB16,
- FF_CSP_BGR15,
- FF_CSP_RGB15,
- FF_CSP_NULL
- };
- bestcsps=best;
- break;
- }
- case FF_CSP_411P:
- {
- static const int best[FF_CSPS_NUM]=
- {
- FF_CSP_420P ,
- FF_CSP_422P ,
- FF_CSP_444P ,
- FF_CSP_410P ,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_RGB32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_BGR16,
- FF_CSP_RGB16,
- FF_CSP_BGR15,
- FF_CSP_RGB15,
- FF_CSP_NULL
- };
- bestcsps=best;
- break;
- }
- case FF_CSP_410P:
- {
- static const int best[FF_CSPS_NUM]=
- {
- FF_CSP_420P ,
- FF_CSP_422P ,
- FF_CSP_444P ,
- FF_CSP_411P ,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_RGB32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_BGR16,
- FF_CSP_RGB16,
- FF_CSP_BGR15,
- FF_CSP_RGB15,
- FF_CSP_NULL
- };
- bestcsps=best;
- break;
+ int outCSP=inCSP&wantedCSPS&FF_CSPS_MASK;
+ if (outCSP) {
+ if (rank) {
+ *rank=100;
+ }
+ return outCSP|(inCSP&~FF_CSPS_MASK);
}
- case FF_CSP_YUY2:
- {
- static const int best[FF_CSPS_NUM]=
- {
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_420P ,
- FF_CSP_422P ,
- FF_CSP_444P ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_RGB32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_BGR16,
- FF_CSP_RGB16,
- FF_CSP_BGR15,
- FF_CSP_RGB15,
- FF_CSP_NULL
- };
- bestcsps=best;
- break;
- }
- case FF_CSP_UYVY:
- {
- static const int best[FF_CSPS_NUM]=
- {
- FF_CSP_YUY2 ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_420P ,
- FF_CSP_422P ,
- FF_CSP_444P ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_RGB32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_BGR16,
- FF_CSP_RGB16,
- FF_CSP_BGR15,
- FF_CSP_RGB15,
- FF_CSP_NULL
- };
- bestcsps=best;
- break;
- }
- case FF_CSP_YVYU:
- {
- static const int best[FF_CSPS_NUM]=
- {
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_VYUY ,
- FF_CSP_420P ,
- FF_CSP_422P ,
- FF_CSP_444P ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_RGB32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_BGR16,
- FF_CSP_RGB16,
- FF_CSP_BGR15,
- FF_CSP_RGB15,
- FF_CSP_NULL
- };
- bestcsps=best;
- break;
- }
- case FF_CSP_VYUY:
- {
- static const int best[FF_CSPS_NUM]=
- {
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_420P ,
- FF_CSP_422P ,
- FF_CSP_444P ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_RGB32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_BGR16,
- FF_CSP_RGB16,
- FF_CSP_BGR15,
- FF_CSP_RGB15,
- FF_CSP_NULL
- };
- bestcsps=best;
- break;
- }
+ const int *bestcsps=NULL;
+ switch (inCSP&FF_CSPS_MASK) {
+ case FF_CSP_420P: {
+ static const int best[FF_CSPS_NUM]= {
+ FF_CSP_422P ,
+ FF_CSP_444P ,
+ FF_CSP_411P ,
+ FF_CSP_410P ,
+ FF_CSP_YUY2 ,
+ FF_CSP_UYVY ,
+ FF_CSP_YVYU ,
+ FF_CSP_VYUY ,
+ FF_CSP_ABGR ,
+ FF_CSP_RGBA ,
+ FF_CSP_BGR32,
+ FF_CSP_RGB32,
+ FF_CSP_BGR24,
+ FF_CSP_RGB24,
+ FF_CSP_BGR16,
+ FF_CSP_RGB16,
+ FF_CSP_BGR15,
+ FF_CSP_RGB15,
+ FF_CSP_NULL
+ };
+ bestcsps=best;
+ break;
+ }
+ case FF_CSP_422P: {
+ static const int best[FF_CSPS_NUM]= {
+ FF_CSP_YUY2 ,
+ FF_CSP_420P ,
+ FF_CSP_444P ,
+ FF_CSP_411P ,
+ FF_CSP_410P ,
+ FF_CSP_UYVY ,
+ FF_CSP_YVYU ,
+ FF_CSP_VYUY ,
+ FF_CSP_ABGR ,
+ FF_CSP_RGBA ,
+ FF_CSP_BGR32,
+ FF_CSP_RGB32,
+ FF_CSP_BGR24,
+ FF_CSP_RGB24,
+ FF_CSP_BGR16,
+ FF_CSP_RGB16,
+ FF_CSP_BGR15,
+ FF_CSP_RGB15,
+ FF_CSP_NULL
+ };
+ bestcsps=best;
+ break;
+ }
+ case FF_CSP_444P: {
+ static const int best[FF_CSPS_NUM]= {
+ FF_CSP_422P ,
+ FF_CSP_420P ,
+ FF_CSP_411P ,
+ FF_CSP_410P ,
+ FF_CSP_YUY2 ,
+ FF_CSP_UYVY ,
+ FF_CSP_YVYU ,
+ FF_CSP_VYUY ,
+ FF_CSP_ABGR ,
+ FF_CSP_RGBA ,
+ FF_CSP_BGR32,
+ FF_CSP_RGB32,
+ FF_CSP_BGR24,
+ FF_CSP_RGB24,
+ FF_CSP_BGR16,
+ FF_CSP_RGB16,
+ FF_CSP_BGR15,
+ FF_CSP_RGB15,
+ FF_CSP_NULL
+ };
+ bestcsps=best;
+ break;
+ }
+ case FF_CSP_411P: {
+ static const int best[FF_CSPS_NUM]= {
+ FF_CSP_420P ,
+ FF_CSP_422P ,
+ FF_CSP_444P ,
+ FF_CSP_410P ,
+ FF_CSP_YUY2 ,
+ FF_CSP_UYVY ,
+ FF_CSP_YVYU ,
+ FF_CSP_VYUY ,
+ FF_CSP_ABGR ,
+ FF_CSP_RGBA ,
+ FF_CSP_BGR32,
+ FF_CSP_RGB32,
+ FF_CSP_BGR24,
+ FF_CSP_RGB24,
+ FF_CSP_BGR16,
+ FF_CSP_RGB16,
+ FF_CSP_BGR15,
+ FF_CSP_RGB15,
+ FF_CSP_NULL
+ };
+ bestcsps=best;
+ break;
+ }
+ case FF_CSP_410P: {
+ static const int best[FF_CSPS_NUM]= {
+ FF_CSP_420P ,
+ FF_CSP_422P ,
+ FF_CSP_444P ,
+ FF_CSP_411P ,
+ FF_CSP_YUY2 ,
+ FF_CSP_UYVY ,
+ FF_CSP_YVYU ,
+ FF_CSP_VYUY ,
+ FF_CSP_ABGR ,
+ FF_CSP_RGBA ,
+ FF_CSP_BGR32,
+ FF_CSP_RGB32,
+ FF_CSP_BGR24,
+ FF_CSP_RGB24,
+ FF_CSP_BGR16,
+ FF_CSP_RGB16,
+ FF_CSP_BGR15,
+ FF_CSP_RGB15,
+ FF_CSP_NULL
+ };
+ bestcsps=best;
+ break;
+ }
- case FF_CSP_ABGR:
- {
- static const int best[FF_CSPS_NUM]=
- {
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_RGB32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_BGR16,
- FF_CSP_RGB16,
- FF_CSP_BGR15,
- FF_CSP_RGB15,
- FF_CSP_420P ,
- FF_CSP_422P ,
- FF_CSP_444P ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_NULL
- };
- bestcsps=best;
- break;
- }
- case FF_CSP_RGBA:
- {
- static const int best[FF_CSPS_NUM]=
- {
- FF_CSP_ABGR ,
- FF_CSP_BGR32,
- FF_CSP_RGB32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_BGR16,
- FF_CSP_RGB16,
- FF_CSP_BGR15,
- FF_CSP_RGB15,
- FF_CSP_420P ,
- FF_CSP_422P ,
- FF_CSP_444P ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_NULL
- };
- bestcsps=best;
- break;
- }
- case FF_CSP_BGR32:
- {
- static const int best[FF_CSPS_NUM]=
- {
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_RGB32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_BGR16,
- FF_CSP_RGB16,
- FF_CSP_BGR15,
- FF_CSP_RGB15,
- FF_CSP_420P ,
- FF_CSP_422P ,
- FF_CSP_444P ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_NULL
- };
- bestcsps=best;
- break;
- }
- case FF_CSP_BGR24:
- {
- static const int best[FF_CSPS_NUM]=
- {
- FF_CSP_RGB24,
- FF_CSP_BGR32,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_RGB32,
- FF_CSP_BGR16,
- FF_CSP_RGB16,
- FF_CSP_BGR15,
- FF_CSP_RGB15,
- FF_CSP_420P ,
- FF_CSP_422P ,
- FF_CSP_444P ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_NULL
- };
- bestcsps=best;
- break;
- }
- case FF_CSP_BGR15:
- {
- static const int best[FF_CSPS_NUM]=
- {
- FF_CSP_BGR32,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR24,
- FF_CSP_BGR16,
- FF_CSP_RGB32,
- FF_CSP_RGB24,
- FF_CSP_RGB15,
- FF_CSP_RGB16,
- FF_CSP_420P ,
- FF_CSP_422P ,
- FF_CSP_444P ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_NULL
- };
- bestcsps=best;
- break;
- }
- case FF_CSP_BGR16:
- {
- static const int best[FF_CSPS_NUM]=
- {
- FF_CSP_BGR32,
- FF_CSP_BGR24,
- FF_CSP_BGR15,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_RGB32,
- FF_CSP_RGB24,
- FF_CSP_RGB15,
- FF_CSP_RGB16,
- FF_CSP_420P ,
- FF_CSP_422P ,
- FF_CSP_444P ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_NULL
- };
- bestcsps=best;
- break;
- }
- case FF_CSP_RGB32:
- {
- static const int best[FF_CSPS_NUM]=
- {
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_BGR15,
- FF_CSP_BGR16,
- FF_CSP_RGB15,
- FF_CSP_RGB16,
- FF_CSP_420P ,
- FF_CSP_422P ,
- FF_CSP_444P ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_NULL
- };
- bestcsps=best;
- break;
- }
- case FF_CSP_RGB24:
- {
- static const int best[FF_CSPS_NUM]=
- {
- FF_CSP_BGR24,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_RGB32,
- FF_CSP_BGR15,
- FF_CSP_BGR16,
- FF_CSP_RGB15,
- FF_CSP_RGB16,
- FF_CSP_420P ,
- FF_CSP_422P ,
- FF_CSP_444P ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_NULL
- };
- bestcsps=best;
- break;
- }
- case FF_CSP_RGB15:
- {
- static const int best[FF_CSPS_NUM]=
- {
- FF_CSP_BGR15,
- FF_CSP_RGB32,
- FF_CSP_RGB24,
- FF_CSP_RGB16,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_BGR24,
- FF_CSP_BGR16,
- FF_CSP_420P ,
- FF_CSP_422P ,
- FF_CSP_444P ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_NULL
- };
- bestcsps=best;
- break;
- }
- case FF_CSP_RGB16:
- {
- static const int best[FF_CSPS_NUM]=
- {
- FF_CSP_RGB15,
- FF_CSP_RGB32,
- FF_CSP_RGB24,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_BGR24,
- FF_CSP_BGR15,
- FF_CSP_BGR16,
- FF_CSP_420P ,
- FF_CSP_422P ,
- FF_CSP_444P ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_NULL
- };
- bestcsps=best;
- break;
- }
- case FF_CSP_PAL8:
- {
- static const int best[FF_CSPS_NUM]=
- {
- FF_CSP_RGB32,
- FF_CSP_BGR32,
- FF_CSP_RGB24,
- FF_CSP_BGR24,
- FF_CSP_RGB15,
- FF_CSP_BGR15,
- FF_CSP_RGB16,
- FF_CSP_BGR16,
- FF_CSP_420P ,
- FF_CSP_422P ,
- FF_CSP_444P ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_NULL
- };
- bestcsps=best;
- break;
- }
- case FF_CSP_CLJR:
- {
- static const int best[FF_CSPS_NUM]=
- {
- FF_CSP_420P ,
- FF_CSP_422P ,
- FF_CSP_444P ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_RGB32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_BGR16,
- FF_CSP_RGB16,
- FF_CSP_BGR15,
- FF_CSP_RGB15,
- FF_CSP_NULL
- };
- bestcsps=best;
- break;
+ case FF_CSP_YUY2: {
+ static const int best[FF_CSPS_NUM]= {
+ FF_CSP_UYVY ,
+ FF_CSP_YVYU ,
+ FF_CSP_VYUY ,
+ FF_CSP_420P ,
+ FF_CSP_422P ,
+ FF_CSP_444P ,
+ FF_CSP_411P ,
+ FF_CSP_410P ,
+ FF_CSP_ABGR ,
+ FF_CSP_RGBA ,
+ FF_CSP_BGR32,
+ FF_CSP_RGB32,
+ FF_CSP_BGR24,
+ FF_CSP_RGB24,
+ FF_CSP_BGR16,
+ FF_CSP_RGB16,
+ FF_CSP_BGR15,
+ FF_CSP_RGB15,
+ FF_CSP_NULL
+ };
+ bestcsps=best;
+ break;
+ }
+ case FF_CSP_UYVY: {
+ static const int best[FF_CSPS_NUM]= {
+ FF_CSP_YUY2 ,
+ FF_CSP_YVYU ,
+ FF_CSP_VYUY ,
+ FF_CSP_420P ,
+ FF_CSP_422P ,
+ FF_CSP_444P ,
+ FF_CSP_411P ,
+ FF_CSP_410P ,
+ FF_CSP_ABGR ,
+ FF_CSP_RGBA ,
+ FF_CSP_BGR32,
+ FF_CSP_RGB32,
+ FF_CSP_BGR24,
+ FF_CSP_RGB24,
+ FF_CSP_BGR16,
+ FF_CSP_RGB16,
+ FF_CSP_BGR15,
+ FF_CSP_RGB15,
+ FF_CSP_NULL
+ };
+ bestcsps=best;
+ break;
+ }
+ case FF_CSP_YVYU: {
+ static const int best[FF_CSPS_NUM]= {
+ FF_CSP_YUY2 ,
+ FF_CSP_UYVY ,
+ FF_CSP_VYUY ,
+ FF_CSP_420P ,
+ FF_CSP_422P ,
+ FF_CSP_444P ,
+ FF_CSP_411P ,
+ FF_CSP_410P ,
+ FF_CSP_ABGR ,
+ FF_CSP_RGBA ,
+ FF_CSP_BGR32,
+ FF_CSP_RGB32,
+ FF_CSP_BGR24,
+ FF_CSP_RGB24,
+ FF_CSP_BGR16,
+ FF_CSP_RGB16,
+ FF_CSP_BGR15,
+ FF_CSP_RGB15,
+ FF_CSP_NULL
+ };
+ bestcsps=best;
+ break;
+ }
+ case FF_CSP_VYUY: {
+ static const int best[FF_CSPS_NUM]= {
+ FF_CSP_YUY2 ,
+ FF_CSP_UYVY ,
+ FF_CSP_YVYU ,
+ FF_CSP_420P ,
+ FF_CSP_422P ,
+ FF_CSP_444P ,
+ FF_CSP_411P ,
+ FF_CSP_410P ,
+ FF_CSP_ABGR ,
+ FF_CSP_RGBA ,
+ FF_CSP_BGR32,
+ FF_CSP_RGB32,
+ FF_CSP_BGR24,
+ FF_CSP_RGB24,
+ FF_CSP_BGR16,
+ FF_CSP_RGB16,
+ FF_CSP_BGR15,
+ FF_CSP_RGB15,
+ FF_CSP_NULL
+ };
+ bestcsps=best;
+ break;
+ }
+
+ case FF_CSP_ABGR: {
+ static const int best[FF_CSPS_NUM]= {
+ FF_CSP_RGBA ,
+ FF_CSP_BGR32,
+ FF_CSP_RGB32,
+ FF_CSP_BGR24,
+ FF_CSP_RGB24,
+ FF_CSP_BGR16,
+ FF_CSP_RGB16,
+ FF_CSP_BGR15,
+ FF_CSP_RGB15,
+ FF_CSP_420P ,
+ FF_CSP_422P ,
+ FF_CSP_444P ,
+ FF_CSP_411P ,
+ FF_CSP_410P ,
+ FF_CSP_YUY2 ,
+ FF_CSP_UYVY ,
+ FF_CSP_YVYU ,
+ FF_CSP_VYUY ,
+ FF_CSP_NULL
+ };
+ bestcsps=best;
+ break;
+ }
+ case FF_CSP_RGBA: {
+ static const int best[FF_CSPS_NUM]= {
+ FF_CSP_ABGR ,
+ FF_CSP_BGR32,
+ FF_CSP_RGB32,
+ FF_CSP_BGR24,
+ FF_CSP_RGB24,
+ FF_CSP_BGR16,
+ FF_CSP_RGB16,
+ FF_CSP_BGR15,
+ FF_CSP_RGB15,
+ FF_CSP_420P ,
+ FF_CSP_422P ,
+ FF_CSP_444P ,
+ FF_CSP_411P ,
+ FF_CSP_410P ,
+ FF_CSP_YUY2 ,
+ FF_CSP_UYVY ,
+ FF_CSP_YVYU ,
+ FF_CSP_VYUY ,
+ FF_CSP_NULL
+ };
+ bestcsps=best;
+ break;
+ }
+ case FF_CSP_BGR32: {
+ static const int best[FF_CSPS_NUM]= {
+ FF_CSP_ABGR ,
+ FF_CSP_RGBA ,
+ FF_CSP_RGB32,
+ FF_CSP_BGR24,
+ FF_CSP_RGB24,
+ FF_CSP_BGR16,
+ FF_CSP_RGB16,
+ FF_CSP_BGR15,
+ FF_CSP_RGB15,
+ FF_CSP_420P ,
+ FF_CSP_422P ,
+ FF_CSP_444P ,
+ FF_CSP_411P ,
+ FF_CSP_410P ,
+ FF_CSP_YUY2 ,
+ FF_CSP_UYVY ,
+ FF_CSP_YVYU ,
+ FF_CSP_VYUY ,
+ FF_CSP_NULL
+ };
+ bestcsps=best;
+ break;
+ }
+ case FF_CSP_BGR24: {
+ static const int best[FF_CSPS_NUM]= {
+ FF_CSP_RGB24,
+ FF_CSP_BGR32,
+ FF_CSP_ABGR ,
+ FF_CSP_RGBA ,
+ FF_CSP_RGB32,
+ FF_CSP_BGR16,
+ FF_CSP_RGB16,
+ FF_CSP_BGR15,
+ FF_CSP_RGB15,
+ FF_CSP_420P ,
+ FF_CSP_422P ,
+ FF_CSP_444P ,
+ FF_CSP_411P ,
+ FF_CSP_410P ,
+ FF_CSP_YUY2 ,
+ FF_CSP_UYVY ,
+ FF_CSP_YVYU ,
+ FF_CSP_VYUY ,
+ FF_CSP_NULL
+ };
+ bestcsps=best;
+ break;
+ }
+ case FF_CSP_BGR15: {
+ static const int best[FF_CSPS_NUM]= {
+ FF_CSP_BGR32,
+ FF_CSP_ABGR ,
+ FF_CSP_RGBA ,
+ FF_CSP_BGR24,
+ FF_CSP_BGR16,
+ FF_CSP_RGB32,
+ FF_CSP_RGB24,
+ FF_CSP_RGB15,
+ FF_CSP_RGB16,
+ FF_CSP_420P ,
+ FF_CSP_422P ,
+ FF_CSP_444P ,
+ FF_CSP_411P ,
+ FF_CSP_410P ,
+ FF_CSP_YUY2 ,
+ FF_CSP_UYVY ,
+ FF_CSP_YVYU ,
+ FF_CSP_VYUY ,
+ FF_CSP_NULL
+ };
+ bestcsps=best;
+ break;
+ }
+ case FF_CSP_BGR16: {
+ static const int best[FF_CSPS_NUM]= {
+ FF_CSP_BGR32,
+ FF_CSP_BGR24,
+ FF_CSP_BGR15,
+ FF_CSP_ABGR ,
+ FF_CSP_RGBA ,
+ FF_CSP_RGB32,
+ FF_CSP_RGB24,
+ FF_CSP_RGB15,
+ FF_CSP_RGB16,
+ FF_CSP_420P ,
+ FF_CSP_422P ,
+ FF_CSP_444P ,
+ FF_CSP_411P ,
+ FF_CSP_410P ,
+ FF_CSP_YUY2 ,
+ FF_CSP_UYVY ,
+ FF_CSP_YVYU ,
+ FF_CSP_VYUY ,
+ FF_CSP_NULL
+ };
+ bestcsps=best;
+ break;
+ }
+ case FF_CSP_RGB32: {
+ static const int best[FF_CSPS_NUM]= {
+ FF_CSP_ABGR ,
+ FF_CSP_RGBA ,
+ FF_CSP_BGR32,
+ FF_CSP_BGR24,
+ FF_CSP_RGB24,
+ FF_CSP_BGR15,
+ FF_CSP_BGR16,
+ FF_CSP_RGB15,
+ FF_CSP_RGB16,
+ FF_CSP_420P ,
+ FF_CSP_422P ,
+ FF_CSP_444P ,
+ FF_CSP_411P ,
+ FF_CSP_410P ,
+ FF_CSP_YUY2 ,
+ FF_CSP_UYVY ,
+ FF_CSP_YVYU ,
+ FF_CSP_VYUY ,
+ FF_CSP_NULL
+ };
+ bestcsps=best;
+ break;
+ }
+ case FF_CSP_RGB24: {
+ static const int best[FF_CSPS_NUM]= {
+ FF_CSP_BGR24,
+ FF_CSP_ABGR ,
+ FF_CSP_RGBA ,
+ FF_CSP_BGR32,
+ FF_CSP_RGB32,
+ FF_CSP_BGR15,
+ FF_CSP_BGR16,
+ FF_CSP_RGB15,
+ FF_CSP_RGB16,
+ FF_CSP_420P ,
+ FF_CSP_422P ,
+ FF_CSP_444P ,
+ FF_CSP_411P ,
+ FF_CSP_410P ,
+ FF_CSP_YUY2 ,
+ FF_CSP_UYVY ,
+ FF_CSP_YVYU ,
+ FF_CSP_VYUY ,
+ FF_CSP_NULL
+ };
+ bestcsps=best;
+ break;
+ }
+ case FF_CSP_RGB15: {
+ static const int best[FF_CSPS_NUM]= {
+ FF_CSP_BGR15,
+ FF_CSP_RGB32,
+ FF_CSP_RGB24,
+ FF_CSP_RGB16,
+ FF_CSP_ABGR ,
+ FF_CSP_RGBA ,
+ FF_CSP_BGR32,
+ FF_CSP_BGR24,
+ FF_CSP_BGR16,
+ FF_CSP_420P ,
+ FF_CSP_422P ,
+ FF_CSP_444P ,
+ FF_CSP_411P ,
+ FF_CSP_410P ,
+ FF_CSP_YUY2 ,
+ FF_CSP_UYVY ,
+ FF_CSP_YVYU ,
+ FF_CSP_VYUY ,
+ FF_CSP_NULL
+ };
+ bestcsps=best;
+ break;
+ }
+ case FF_CSP_RGB16: {
+ static const int best[FF_CSPS_NUM]= {
+ FF_CSP_RGB15,
+ FF_CSP_RGB32,
+ FF_CSP_RGB24,
+ FF_CSP_ABGR ,
+ FF_CSP_RGBA ,
+ FF_CSP_BGR32,
+ FF_CSP_BGR24,
+ FF_CSP_BGR15,
+ FF_CSP_BGR16,
+ FF_CSP_420P ,
+ FF_CSP_422P ,
+ FF_CSP_444P ,
+ FF_CSP_411P ,
+ FF_CSP_410P ,
+ FF_CSP_YUY2 ,
+ FF_CSP_UYVY ,
+ FF_CSP_YVYU ,
+ FF_CSP_VYUY ,
+ FF_CSP_NULL
+ };
+ bestcsps=best;
+ break;
+ }
+ case FF_CSP_PAL8: {
+ static const int best[FF_CSPS_NUM]= {
+ FF_CSP_RGB32,
+ FF_CSP_BGR32,
+ FF_CSP_RGB24,
+ FF_CSP_BGR24,
+ FF_CSP_RGB15,
+ FF_CSP_BGR15,
+ FF_CSP_RGB16,
+ FF_CSP_BGR16,
+ FF_CSP_420P ,
+ FF_CSP_422P ,
+ FF_CSP_444P ,
+ FF_CSP_411P ,
+ FF_CSP_410P ,
+ FF_CSP_YUY2 ,
+ FF_CSP_UYVY ,
+ FF_CSP_YVYU ,
+ FF_CSP_VYUY ,
+ FF_CSP_NULL
+ };
+ bestcsps=best;
+ break;
+ }
+ case FF_CSP_CLJR: {
+ static const int best[FF_CSPS_NUM]= {
+ FF_CSP_420P ,
+ FF_CSP_422P ,
+ FF_CSP_444P ,
+ FF_CSP_411P ,
+ FF_CSP_410P ,
+ FF_CSP_YUY2 ,
+ FF_CSP_UYVY ,
+ FF_CSP_YVYU ,
+ FF_CSP_VYUY ,
+ FF_CSP_ABGR ,
+ FF_CSP_RGBA ,
+ FF_CSP_BGR32,
+ FF_CSP_RGB32,
+ FF_CSP_BGR24,
+ FF_CSP_RGB24,
+ FF_CSP_BGR16,
+ FF_CSP_RGB16,
+ FF_CSP_BGR15,
+ FF_CSP_RGB15,
+ FF_CSP_NULL
+ };
+ bestcsps=best;
+ break;
+ }
+ case FF_CSP_Y800: {
+ static const int best[FF_CSPS_NUM]= {
+ FF_CSP_420P ,
+ FF_CSP_422P ,
+ FF_CSP_444P ,
+ FF_CSP_411P ,
+ FF_CSP_410P ,
+ FF_CSP_YUY2 ,
+ FF_CSP_UYVY ,
+ FF_CSP_YVYU ,
+ FF_CSP_VYUY ,
+ FF_CSP_ABGR ,
+ FF_CSP_RGBA ,
+ FF_CSP_BGR32,
+ FF_CSP_RGB32,
+ FF_CSP_BGR24,
+ FF_CSP_RGB24,
+ FF_CSP_BGR16,
+ FF_CSP_RGB16,
+ FF_CSP_BGR15,
+ FF_CSP_RGB15,
+ FF_CSP_NULL
+ };
+ bestcsps=best;
+ break;
+ }
+ case FF_CSP_NV12: {
+ static const int best[FF_CSPS_NUM]= {
+ FF_CSP_420P ,
+ FF_CSP_422P ,
+ FF_CSP_444P ,
+ FF_CSP_411P ,
+ FF_CSP_410P ,
+ FF_CSP_YUY2 ,
+ FF_CSP_UYVY ,
+ FF_CSP_YVYU ,
+ FF_CSP_VYUY ,
+ FF_CSP_ABGR ,
+ FF_CSP_RGBA ,
+ FF_CSP_BGR32,
+ FF_CSP_RGB32,
+ FF_CSP_BGR24,
+ FF_CSP_RGB24,
+ FF_CSP_BGR16,
+ FF_CSP_RGB16,
+ FF_CSP_BGR15,
+ FF_CSP_RGB15,
+ FF_CSP_NULL
+ };
+ bestcsps=best;
+ break;
+ }
+ default:
+ return FF_CSP_NULL;
}
- case FF_CSP_Y800:
- {
- static const int best[FF_CSPS_NUM]=
- {
- FF_CSP_420P ,
- FF_CSP_422P ,
- FF_CSP_444P ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_RGB32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_BGR16,
- FF_CSP_RGB16,
- FF_CSP_BGR15,
- FF_CSP_RGB15,
- FF_CSP_NULL
- };
- bestcsps=best;
- break;
+ if (rank) {
+ *rank=99;
}
- case FF_CSP_NV12:
- {
- static const int best[FF_CSPS_NUM]=
- {
- FF_CSP_420P ,
- FF_CSP_422P ,
- FF_CSP_444P ,
- FF_CSP_411P ,
- FF_CSP_410P ,
- FF_CSP_YUY2 ,
- FF_CSP_UYVY ,
- FF_CSP_YVYU ,
- FF_CSP_VYUY ,
- FF_CSP_ABGR ,
- FF_CSP_RGBA ,
- FF_CSP_BGR32,
- FF_CSP_RGB32,
- FF_CSP_BGR24,
- FF_CSP_RGB24,
- FF_CSP_BGR16,
- FF_CSP_RGB16,
- FF_CSP_BGR15,
- FF_CSP_RGB15,
- FF_CSP_NULL
- };
- bestcsps=best;
- break;
+ while (*bestcsps) {
+ if (*bestcsps&wantedCSPS) {
+ return *bestcsps|(inCSP&~FF_CSPS_MASK);
+ }
+ bestcsps++;
+ if (rank) {
+ (*rank)--;
+ }
}
- default:return FF_CSP_NULL;
- }
- if (rank) *rank=99;
- while (*bestcsps)
- {
- if (*bestcsps&wantedCSPS)
- return *bestcsps|(inCSP&~FF_CSPS_MASK);
- bestcsps++;
- if (rank) (*rank)--;
- }
- return FF_CSP_NULL;
+ return FF_CSP_NULL;
}
bool TcspInfos::TsortFc::operator ()(const TcspInfo* &csp1,const TcspInfo* &csp2)
{
- int rank1;csp_bestMatch(csp,csp1->id,&rank1);
- int rank2;csp_bestMatch(csp,csp2->id,&rank2);
- return rank1>rank2;
+ int rank1;
+ csp_bestMatch(csp,csp1->id,&rank1);
+ int rank2;
+ csp_bestMatch(csp,csp2->id,&rank2);
+ return rank1>rank2;
}
/*void TcspInfos::sort(int csp)
{
diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/PODtypes.h b/src/filters/transform/MPCVideoDec/ffmpeg/PODtypes.h
index 5e116d904..007084e96 100644
--- a/src/filters/transform/MPCVideoDec/ffmpeg/PODtypes.h
+++ b/src/filters/transform/MPCVideoDec/ffmpeg/PODtypes.h
@@ -1,32 +1,70 @@
#ifndef _PODTYPES_H_
#define _PODTYPES_H_
-template<class T> struct isPOD {enum {is=false};};
-template<> struct isPOD<bool> {enum {is=true};};
+template<class T> struct isPOD {
+ enum {is=false};
+};
+template<> struct isPOD<bool> {
+ enum {is=true};
+};
-template<> struct isPOD<char> {enum {is=true};};
+template<> struct isPOD<char> {
+ enum {is=true};
+};
-template<> struct isPOD<signed char> {enum {is=true};};
-template<> struct isPOD<short int> {enum {is=true};};
-template<> struct isPOD<int> {enum {is=true};};
-template<> struct isPOD<long int> {enum {is=true};};
-template<> struct isPOD<__int64> {enum {is=true};};
+template<> struct isPOD<signed char> {
+ enum {is=true};
+};
+template<> struct isPOD<short int> {
+ enum {is=true};
+};
+template<> struct isPOD<int> {
+ enum {is=true};
+};
+template<> struct isPOD<long int> {
+ enum {is=true};
+};
+template<> struct isPOD<__int64> {
+ enum {is=true};
+};
-template<> struct isPOD<unsigned char> {enum {is=true};};
-template<> struct isPOD<unsigned short int> {enum {is=true};};
-template<> struct isPOD<unsigned int> {enum {is=true};};
-template<> struct isPOD<unsigned long int> {enum {is=true};};
-template<> struct isPOD<unsigned __int64> {enum {is=true};};
+template<> struct isPOD<unsigned char> {
+ enum {is=true};
+};
+template<> struct isPOD<unsigned short int> {
+ enum {is=true};
+};
+template<> struct isPOD<unsigned int> {
+ enum {is=true};
+};
+template<> struct isPOD<unsigned long int> {
+ enum {is=true};
+};
+template<> struct isPOD<unsigned __int64> {
+ enum {is=true};
+};
-template<> struct isPOD<float> {enum {is=true};};
-template<> struct isPOD<double> {enum {is=true};};
-template<> struct isPOD<long double> {enum {is=true};};
+template<> struct isPOD<float> {
+ enum {is=true};
+};
+template<> struct isPOD<double> {
+ enum {is=true};
+};
+template<> struct isPOD<long double> {
+ enum {is=true};
+};
#if defined(__INTEL_COMPILER) || defined(__GNUC__) || (_MSC_VER>=1300)
-template<> struct isPOD<wchar_t> {enum {is=true};};
-template<class Tp> struct isPOD<Tp*> {enum {is=true};};
+template<> struct isPOD<wchar_t> {
+ enum {is=true};
+};
+template<class Tp> struct isPOD<Tp*> {
+ enum {is=true};
+};
#endif
-template<class A> struct allocator_traits {enum {is_static=false};};
+template<class A> struct allocator_traits {
+ enum {is_static=false};
+};
#endif
diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/array_allocator.h b/src/filters/transform/MPCVideoDec/ffmpeg/array_allocator.h
index a22137d23..dd57c2294 100644
--- a/src/filters/transform/MPCVideoDec/ffmpeg/array_allocator.h
+++ b/src/filters/transform/MPCVideoDec/ffmpeg/array_allocator.h
@@ -4,47 +4,60 @@
template <class T,size_t size> class array_allocator
{
private:
- T array[size];
+ T* p;
public:
- typedef T value_type;
- typedef size_t size_type;
- typedef ptrdiff_t difference_type;
-
- typedef T* pointer;
- typedef const T* const_pointer;
-
- typedef T& reference;
- typedef const T& const_reference;
-
- pointer address(reference r) const { return &r; }
- const_pointer address(const_reference r) const { return &r; }
-
- array_allocator() throw(){}
- template <class U,size_t sz> array_allocator(const array_allocator<U,sz>& ) throw() {}
- ~array_allocator() throw(){}
-
- pointer allocate(size_type n, const void* = 0)
- {
- return array;
- }
- void deallocate(pointer p, size_type)
- {
- }
-
- //Use placement new to engage the constructor
- void construct(pointer p, const T& val) { new((void*)p) T(val); }
- void destroy(pointer p){ ((T*)p)->~T(); }
-
- size_type max_size() const throw() {return size;}
- template<class U> struct rebind { typedef array_allocator<U,size> other; };
+ typedef T value_type;
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+
+ typedef T* pointer;
+ typedef const T* const_pointer;
+
+ typedef T& reference;
+ typedef const T& const_reference;
+
+ pointer address(reference r) const {
+ return &r;
+ }
+ const_pointer address(const_reference r) const {
+ return &r;
+ }
+
+ array_allocator() throw() {}
+ template <class U,size_t sz> array_allocator(const array_allocator<U,sz>& ) throw() {}
+ ~array_allocator() throw() {}
+
+ pointer allocate(size_type n, const void* = 0) {
+ p = ((T *)::operator new(size * sizeof (T)));
+ return p;
+ }
+ void deallocate(pointer p, size_type) {
+ delete p;
+ }
+
+ //Use placement new to engage the constructor
+ void construct(pointer p, const T& val) {
+ new((void*)p) T(val);
+ }
+ void destroy(pointer p) {
+ ((T*)p)->~T();
+ }
+
+ size_type max_size() const throw() {
+ return size;
+ }
+ template<class U> struct rebind {
+ typedef array_allocator<U,size> other;
+ };
};
-template<class T,size_t size> struct array_vector : std::vector<T, array_allocator<T,size> >
-{
+template<class T,size_t size> struct array_vector : std::vector<T, array_allocator<T,size> > {
};
#if defined(__INTEL_COMPILER) || defined(__GNUC__) || (_MSC_VER>=1300)
- template<class T,size_t a> struct allocator_traits<array_allocator<T,a> > {enum {is_static=true};};
+template<class T,size_t a> struct allocator_traits<array_allocator<T,a> > {
+ enum {is_static=true};
+};
#endif
#endif
diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/char_t.h b/src/filters/transform/MPCVideoDec/ffmpeg/char_t.h
index e25cb5dc5..4eacf8114 100644
--- a/src/filters/transform/MPCVideoDec/ffmpeg/char_t.h
+++ b/src/filters/transform/MPCVideoDec/ffmpeg/char_t.h
@@ -7,152 +7,274 @@
#undef _l
#ifdef UNICODE
- typedef wchar_t char_t;
- #define tsprintf swprintf
- #define tsnprintf _snwprintf
- #define tfprintf fwprintf
- #define tsscanf swscanf
- #define __l(x) L ## x
- #define _l(x) __l(x)
+typedef wchar_t char_t;
+#define tsprintf swprintf
+#define tsnprintf_s _snwprintf_s
+#define tfprintf fwprintf
+#define tsscanf swscanf
+#define __l(x) L ## x
+#define _l(x) __l(x)
#else
- typedef char char_t;
- #define tsprintf sprintf
- #define tsnprintf _snprintf
- #define tfprintf fprintf
- #define tsscanf sscanf
- #define _l(x) x
+typedef char char_t;
+#define tsprintf sprintf
+#define tsnprintf_s _snprintf_s
+#define tfprintf fprintf
+#define tsscanf sscanf
+#define _l(x) x
#endif
#ifdef __cplusplus
#ifdef __GNUC__
- #ifndef __forceinline
- #define __forceinline __attribute__((__always_inline__)) inline
- #endif
+#ifndef __forceinline
+#define __forceinline __attribute__((__always_inline__)) inline
#endif
+#endif
+
+static __forceinline errno_t strncat_s(wchar_t *a, size_t b, const wchar_t *c, size_t d)
+{
+ return wcsncat_s(a,b,c,d);
+}
+static __forceinline int vsnprintf_s(wchar_t *a, size_t b, size_t c, const wchar_t *d, va_list e)
+{
+ return _vsnwprintf_s(a,b,c,d,e);
+}
+static __forceinline errno_t _splitpath_s(const wchar_t * a,
+ wchar_t * b, size_t c, wchar_t * d, size_t e,
+ wchar_t * f, size_t g, wchar_t * h, size_t i)
+{
+ return _wsplitpath_s(a,b,c,d,e,f,g,h,i);
+};
+static __forceinline errno_t _makepath_s(wchar_t *a, size_t b,
+ const wchar_t *c, const wchar_t *d,
+ const wchar_t *e, const wchar_t *f)
+{
+ return _wmakepath_s(a,b,c,d,e,f);
+};
+static __forceinline wchar_t* ff_strncpy(wchar_t *dst, const wchar_t *src, size_t count)
+{
+ wcsncpy_s(dst, count, src, _TRUNCATE);
+ return dst;
+}
+static __forceinline char* ff_strncpy(char *dst, const char *src, size_t count)
+{
+ strncpy_s(dst, count, src, _TRUNCATE);
+ return dst;
+}
+
+static __forceinline wchar_t* strcat(wchar_t *a, const wchar_t *b)
+{
+ return wcscat(a,b);
+}
+static __forceinline int strcmp(const wchar_t *a, const wchar_t *b)
+{
+ return wcscmp(a,b);
+}
+static __forceinline int strncmp(const wchar_t *a, const wchar_t *b, size_t c)
+{
+ return wcsncmp(a,b,c);
+}
+static __forceinline int strnicmp(const wchar_t *a, const wchar_t *b,size_t c)
+{
+ return _wcsnicmp(a,b,c);
+}
+
+static __forceinline long strtol(const wchar_t *a, wchar_t **b, int c)
+{
+ return wcstol(a,b,c);
+}
+static __forceinline wchar_t* strchr(const wchar_t *a, wchar_t b)
+{
+ return (wchar_t*)wcschr(a,b);
+}
+static __forceinline int _strnicmp(const wchar_t *a, const wchar_t *b, size_t c)
+{
+ return _wcsnicmp(a,b,c);
+}
+static __forceinline wchar_t* strstr(const wchar_t *a, const wchar_t *b)
+{
+ return (wchar_t*)wcsstr(a,b);
+}
+static __forceinline size_t strlen(const wchar_t *a)
+{
+ return wcslen(a);
+}
+static __forceinline wchar_t* strcpy(wchar_t *a, const wchar_t *b)
+{
+ return wcscpy(a,b);
+}
+static __forceinline int atoi(const wchar_t *a)
+{
+ return _wtoi(a);
+}
+static __forceinline wchar_t* _itoa(int a, wchar_t *b, int c)
+{
+ return _itow(a,b,c);
+}
+static __forceinline int stricmp(const wchar_t *a, const wchar_t *b)
+{
+ return _wcsicmp(a,b);
+}
+static __forceinline unsigned long strtoul(const wchar_t *a,wchar_t **b,int c)
+{
+ return wcstoul(a,b,c);
+}
+static __forceinline double strtod(const wchar_t *a, wchar_t **b)
+{
+ return wcstod(a,b);
+}
+static __forceinline int vsprintf(wchar_t *a, const wchar_t *b, va_list c)
+{
+ return vswprintf(a,b,c);
+}
+static __forceinline int _vsnprintf(wchar_t *a, size_t b, const wchar_t *c, va_list d)
+{
+ return _vsnwprintf(a,b,c,d);
+}
-static __forceinline wchar_t* strcat(wchar_t *a, const wchar_t *b) {return wcscat(a,b);}
-static __forceinline wchar_t* strncat(wchar_t *a, const wchar_t *b,size_t c) {return wcsncat(a,b,c);}
-static __forceinline int strcmp(const wchar_t *a, const wchar_t *b) {return wcscmp(a,b);}
-static __forceinline int strncmp(const wchar_t *a, const wchar_t *b, size_t c) {return wcsncmp(a,b,c);}
-static __forceinline int strnicmp(const wchar_t *a, const wchar_t *b,size_t c) {return _wcsnicmp(a,b,c);}
-static __forceinline wchar_t* strncpy(wchar_t *a, const wchar_t *b, size_t c) {return wcsncpy(a,b,c);}
-static __forceinline long strtol(const wchar_t *a, wchar_t **b, int c) {return wcstol(a,b,c);}
-static __forceinline wchar_t* strchr(const wchar_t *a, wchar_t b) {return (wchar_t*)wcschr(a,b);}
-static __forceinline int _strnicmp(const wchar_t *a, const wchar_t *b, size_t c) {return _wcsnicmp(a,b,c);}
-static __forceinline wchar_t* strstr(const wchar_t *a, const wchar_t *b) {return (wchar_t*)wcsstr(a,b);}
-static __forceinline size_t strlen(const wchar_t *a) {return wcslen(a);}
-static __forceinline wchar_t* strcpy(wchar_t *a, const wchar_t *b) {return wcscpy(a,b);}
-static __forceinline int atoi(const wchar_t *a) {return _wtoi(a);}
-static __forceinline wchar_t* _itoa(int a, wchar_t *b, int c) {return _itow(a,b,c);}
-static __forceinline int stricmp(const wchar_t *a, const wchar_t *b) {return _wcsicmp(a,b);}
-static __forceinline unsigned long strtoul(const wchar_t *a,wchar_t **b,int c) {return wcstoul(a,b,c);}
-static __forceinline double strtod(const wchar_t *a, wchar_t **b) {return wcstod(a,b);}
-static __forceinline int vsprintf(wchar_t *a, const wchar_t *b, va_list c) {return vswprintf(a,b,c);}
-static __forceinline int _vsnprintf(wchar_t *a, size_t b, const wchar_t *c, va_list d) {return _vsnwprintf(a,b,c,d);}
-static __forceinline void _splitpath(const wchar_t *a, wchar_t *b, wchar_t *c, wchar_t *d, wchar_t *e) {_wsplitpath(a,b,c,d,e);}
-static __forceinline void _makepath(wchar_t *a, const wchar_t *b, const wchar_t *c, const wchar_t *d,const wchar_t *e) {_wmakepath(a,b,c,d,e);}
-static __forceinline FILE* fopen(const wchar_t *a, const wchar_t *b) {return _wfopen(a,b);}
-static __forceinline int fputs(const wchar_t *a, FILE *b) {return fputws(a,b);}
-static __forceinline int _stricoll(const wchar_t *a, const wchar_t *b) {return _wcsicoll(a,b);}
-static __forceinline wchar_t* strrchr(const wchar_t *a, wchar_t b) {return (wchar_t*)wcsrchr(a,b);}
-static __forceinline wchar_t* strupr(wchar_t *a) {return _wcsupr(a);}
-static __forceinline wchar_t* strlwr(wchar_t *a) {return _wcslwr(a);}
-static __forceinline wchar_t* _strtime(wchar_t *a) {return _wstrtime(a);}
-static __forceinline wchar_t* memchr(wchar_t *a,wchar_t b,size_t c) {return wmemchr(a,b,c);}
-static __forceinline const wchar_t* memchr(const wchar_t *a,wchar_t b,size_t c) {return wmemchr(a,b,c);}
-static __forceinline wchar_t* strpbrk(const wchar_t *a, const wchar_t *b) {return (wchar_t*)wcspbrk(a,b);}
+static __forceinline FILE* fopen(const wchar_t *a, const wchar_t *b)
+{
+ return _wfopen(a,b);
+}
+static __forceinline int fputs(const wchar_t *a, FILE *b)
+{
+ return fputws(a,b);
+}
+static __forceinline int _stricoll(const wchar_t *a, const wchar_t *b)
+{
+ return _wcsicoll(a,b);
+}
+static __forceinline wchar_t* strrchr(const wchar_t *a, wchar_t b)
+{
+ return (wchar_t*)wcsrchr(a,b);
+}
+static __forceinline wchar_t* strupr(wchar_t *a)
+{
+ return _wcsupr(a);
+}
+static __forceinline wchar_t* strlwr(wchar_t *a)
+{
+ return _wcslwr(a);
+}
+static __forceinline wchar_t* _strtime(wchar_t *a)
+{
+ return _wstrtime(a);
+}
+static __forceinline wchar_t* memchr(wchar_t *a,wchar_t b,size_t c)
+{
+ return wmemchr(a,b,c);
+}
+static __forceinline const wchar_t* memchr(const wchar_t *a,wchar_t b,size_t c)
+{
+ return wmemchr(a,b,c);
+}
+static __forceinline wchar_t* strpbrk(const wchar_t *a, const wchar_t *b)
+{
+ return (wchar_t*)wcspbrk(a,b);
+}
template<class Tout> struct text
-// ANSI <--> UNICODE conversion.
-// in : input string in char* or wchar_t*.
-// inlen : count of characters, not byte size!! -1 for null terminated string.
-// out : output string in char* or wchar_t*.
-// outlen : count of characters, not byte size!!
+ // ANSI <--> UNICODE conversion.
+ // in : input string in char* or wchar_t*.
+ // inlen : count of characters, not byte size!! -1 for null terminated string.
+ // out : output string in char* or wchar_t*.
+ // outlen : count of characters, not byte size!!
{
private:
- Tout *buf;
- bool own;
+ Tout *buf;
+ bool own;
public:
- template<class Tin> inline text(const Tin *in);
- template<class Tin> inline text(const Tin *in,Tout *Ibuf);
- template<class Tin> inline text(const Tin *in,int inlen,Tout *Ibuf,size_t outlen);
- ~text() {if (own) delete []buf;}
- operator const Tout*() const {return buf;}
+ template<class Tin> inline text(const Tin *in,int code_page = CP_ACP);
+ template<class Tin> inline text(const Tin *in,Tout *Ibuf,int code_page = CP_ACP);
+ template<class Tin> inline text(const Tin *in,int inlen,Tout *Ibuf,size_t outlen,int code_page = CP_ACP);
+ ~text() {
+ if (own) {
+ delete []buf;
+ }
+ }
+ operator const Tout*() const {
+ return buf;
+ }
};
-template<> template<> inline text<char>::text(const char *in):buf(const_cast<char*>(in)),own(false) {}
-template<> template<> inline text<char>::text(const char *in,char *Ibuf):buf(strcpy(Ibuf,in)),own(false) {}
-template<> template<> inline text<char>::text(const char *in,int inlen,char *Ibuf,size_t outlen):own(false)
+template<> template<> inline text<char>::text(const char *in,int code_page):buf(const_cast<char*>(in)),own(false) {}
+template<> template<> inline text<char>::text(const char *in,char *Ibuf,int code_page):buf(strcpy(Ibuf,in)),own(false) {}
+template<> template<> inline text<char>::text(const char *in,int inlen,char *Ibuf,size_t outlen,int code_page):own(false)
{
- if (inlen!=-1)
- buf=strncpy(Ibuf,in,((size_t)inlen < outlen ? inlen : outlen));
- else
- {
- size_t inlen1=strlen(in)+1;
- buf=strncpy(Ibuf,in,inlen1 < outlen ? inlen1 : outlen);
- }
+ if (inlen!=-1) {
+ buf=Ibuf;
+ if ((size_t)inlen < outlen) {
+ ff_strncpy(Ibuf, in, inlen + 1);
+ } else {
+ ff_strncpy(Ibuf, in, outlen);
+ }
+ } else {
+ buf=Ibuf;
+ ff_strncpy(Ibuf, in, outlen);
+ }
}
-template<> template<> inline text<wchar_t>::text(const wchar_t *in):buf(const_cast<wchar_t*>(in)),own(false) {}
-template<> template<> inline text<wchar_t>::text(const wchar_t *in,wchar_t *Ibuf):buf(strcpy(Ibuf,in)),own(false) {}
-template<> template<> inline text<wchar_t>::text(const wchar_t *in,int inlen,wchar_t *Ibuf,size_t outlen):own(false)
+template<> template<> inline text<wchar_t>::text(const wchar_t *in,int code_page):buf(const_cast<wchar_t*>(in)),own(false) {}
+template<> template<> inline text<wchar_t>::text(const wchar_t *in,wchar_t *Ibuf,int code_page):buf(strcpy(Ibuf,in)),own(false) {}
+template<> template<> inline text<wchar_t>::text(const wchar_t *in,int inlen,wchar_t *Ibuf,size_t outlen,int code_page):own(false)
{
- if (inlen!=-1)
- buf=strncpy(Ibuf,in,((size_t)inlen < outlen ? inlen : outlen));
- else
- {
- size_t inlen1=strlen(in)+1;
- buf=strncpy(Ibuf,in,inlen1 < outlen ? inlen1 : outlen);
- }
+ if (inlen!=-1) {
+ buf=Ibuf;
+ if ((size_t)inlen < outlen) {
+ ff_strncpy(Ibuf, in, inlen + 1);
+ } else {
+ ff_strncpy(Ibuf, in, outlen);
+ }
+ } else {
+ buf=Ibuf;
+ ff_strncpy(Ibuf, in, outlen);
+ }
}
-template<> template<> inline text<wchar_t>::text(const char *in):own(in?true:false)
+template<> template<> inline text<wchar_t>::text(const char *in,int code_page):own(in?true:false)
{
- if (in)
- {
- size_t l=strlen(in);
- buf=new wchar_t[l+1];
- MultiByteToWideChar(CP_ACP,0,in,int(l+1),buf,int(l+1));
- }
- else
- buf=NULL;
+ if (in) {
+ size_t l=strlen(in);
+ buf=new wchar_t[l+1];
+ MultiByteToWideChar(code_page,0,in,int(l+1),buf,int(l+1));
+ } else {
+ buf=NULL;
+ }
}
-template<> template<> inline text<wchar_t>::text(const char *in,wchar_t *Ibuf):own(false),buf(Ibuf)
+template<> template<> inline text<wchar_t>::text(const char *in,wchar_t *Ibuf,int code_page):own(false),buf(Ibuf)
{
- size_t l=strlen(in);
- MultiByteToWideChar(CP_ACP,0,in,int(l+1),buf,int(l+1));
+ size_t l=strlen(in);
+ MultiByteToWideChar(code_page,0,in,int(l+1),buf,int(l+1));
}
-template<> template<> inline text<wchar_t>::text(const char *in,int inlen,wchar_t *Ibuf,size_t outlen):own(false),buf(Ibuf)
+template<> template<> inline text<wchar_t>::text(const char *in,int inlen,wchar_t *Ibuf,size_t outlen,int code_page):own(false),buf(Ibuf)
{
- MultiByteToWideChar(CP_ACP,0,in,int(inlen),buf,int(outlen));
+ MultiByteToWideChar(code_page,0,in,int(inlen),buf,int(outlen));
}
-template<> template<> inline text<char>::text(const wchar_t *in):own(in?true:false)
+template<> template<> inline text<char>::text(const wchar_t *in,int code_page):own(in?true:false)
{
- if (in)
- {
- size_t l=strlen(in);
- int length=WideCharToMultiByte(CP_ACP,0,in,int(l+1),buf,0,NULL,NULL);
- buf=new char[length+1];
- WideCharToMultiByte(CP_ACP,0,in,int(l+1),buf,int(length+1),NULL,NULL);
- }
- else
- buf=NULL;
+ if (in) {
+ size_t l=strlen(in);
+ int length=WideCharToMultiByte(code_page,0,in,int(l+1),buf,0,NULL,NULL);
+ buf=new char[length+1];
+ WideCharToMultiByte(code_page,0,in,int(l+1),buf,int(length+1),NULL,NULL);
+ } else {
+ buf=NULL;
+ }
}
-template<> template<> inline text<char>::text(const wchar_t *in,char *Ibuf):own(false),buf(Ibuf)
+template<> template<> inline text<char>::text(const wchar_t *in,char *Ibuf,int code_page):own(false),buf(Ibuf)
{
- size_t l=strlen(in);
- int length= WideCharToMultiByte(CP_ACP,0,in,int(l+1),buf,0,NULL,NULL);
- WideCharToMultiByte(CP_ACP,0,in,int(l+1),buf,length,NULL,NULL);
+ size_t l=strlen(in);
+ int length= WideCharToMultiByte(code_page,0,in,int(l+1),buf,0,NULL,NULL);
+ WideCharToMultiByte(code_page,0,in,int(l+1),buf,length,NULL,NULL);
}
-template<> template<> inline text<char>::text(const wchar_t *in,int inlen,char *Ibuf,size_t outlen):own(false),buf(Ibuf)
+template<> template<> inline text<char>::text(const wchar_t *in,int inlen,char *Ibuf,size_t outlen,int code_page):own(false),buf(Ibuf)
{
- WideCharToMultiByte(CP_ACP,0,in,int(inlen),buf,int(outlen),NULL,NULL);
+ WideCharToMultiByte(code_page,0,in,int(inlen),buf,int(outlen),NULL,NULL);
}
#endif
diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/config.h b/src/filters/transform/MPCVideoDec/ffmpeg/config.h
index fcc29c930..01b00ea0c 100644
--- a/src/filters/transform/MPCVideoDec/ffmpeg/config.h
+++ b/src/filters/transform/MPCVideoDec/ffmpeg/config.h
@@ -79,7 +79,6 @@
#define ARCH_SPARC64 0
#define ARCH_TOMI 0
-#define HAVE_ALIGNED_STACK 0
#define HAVE_ALTIVEC 0
#define HAVE_ARMV5TE 0
#define HAVE_ARMV6 0
@@ -91,6 +90,7 @@
#define HAVE_PPC4XX 0
#define HAVE_VIS 0
+#define HAVE_ALIGNED_STACK 0
#define HAVE_ALTIVEC_H 0
#define HAVE_BIGENDIAN 0
#define HAVE_BSWAP 1
@@ -143,31 +143,31 @@
#define cbrtf(x) pow((float)x, (float)1.0/3)
#endif
+#define CONFIG_AC3ENC_FLOAT 0
#define CONFIG_DCT 0
#define CONFIG_DWT 0
-
#define CONFIG_GPL 1
#define CONFIG_GRAY 1
#define CONFIG_H264DSP 1
#define CONFIG_H264PRED 1
#define CONFIG_HARDCODED_TABLES 0
-#define CONFIG_HUFFMAN 0
+#define CONFIG_HUFFMAN 1
#define CONFIG_LIBAMR_NB 1
#define CONFIG_LIBXVID 0
#define CONFIG_LPC 0
#define CONFIG_MDCT 1
#define CONFIG_MPEGAUDIO_HP 1
+#define CONFIG_RUNTIME_CPUDETECT 1
#define CONFIG_SMALL 0
#define CONFIG_ZLIB 1
#define CONFIG_DECODERS 1
#define CONFIG_ENCODERS 0
-#define CONFIG_POSTPROC 0
-#define CONFIG_RUNTIME_CPUDETECT 1
#define CONFIG_SWSCALE 1
#define CONFIG_SWSCALE_ALPHA 1
+#define CONFIG_POSTPROC 0
-/*
+/*
Note: when adding a new codec, you have to:
1) Add a
#define CONFIG_<codec suffix>_<ENCODER|DECODER|PARSER>
@@ -201,6 +201,7 @@ Note: when adding a new codec, you have to:
#define CONFIG_HUFFYUV_DECODER 0
#define CONFIG_INDEO2_DECODER 0
#define CONFIG_INDEO3_DECODER 0
+#define CONFIG_INDEO5_DECODER 0
#define CONFIG_JPEGLS_DECODER 0
#define CONFIG_LOCO_DECODER 0
#define CONFIG_MJPEG_DECODER 0
@@ -325,7 +326,9 @@ Note: when adding a new codec, you have to:
#define CONFIG_SNOW_ENCODER 0
#define CONFIG_WMV1_ENCODER 0
#define CONFIG_WMV2_ENCODER 0
+
#define CONFIG_AC3_ENCODER 0
+#define CONFIG_AC3_FIXED_ENCODER 0
#define CONFIG_AAC_PARSER 0
#define CONFIG_AC3_PARSER 1
diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/ffImgfmt.h b/src/filters/transform/MPCVideoDec/ffmpeg/ffImgfmt.h
index cc5d526ba..efd5e1161 100644
--- a/src/filters/transform/MPCVideoDec/ffmpeg/ffImgfmt.h
+++ b/src/filters/transform/MPCVideoDec/ffmpeg/ffImgfmt.h
@@ -14,36 +14,35 @@
// destination byte order for the file.
// (e.g. PNG images uses RGB order, so select BGR order
// BMP image uses BGR order, so select RGB order)
-enum
-{
- FF_CSP_NULL = 0,
-
- FF_CSP_420P =1U<< 0,
- FF_CSP_422P =1U<< 1,
- FF_CSP_444P =1U<< 2,
- FF_CSP_411P =1U<< 3,
- FF_CSP_410P =1U<< 4,
-
- FF_CSP_YUY2 =1U<< 5,
- FF_CSP_UYVY =1U<< 6,
- FF_CSP_YVYU =1U<< 7,
- FF_CSP_VYUY =1U<< 8,
-
- FF_CSP_ABGR =1U<< 9, // [a|b|g|r]
- FF_CSP_RGBA =1U<<10, // [r|g|b|a]
- FF_CSP_BGR32 =1U<<11,
- FF_CSP_BGR24 =1U<<12,
- FF_CSP_BGR15 =1U<<13,
- FF_CSP_BGR16 =1U<<14,
- FF_CSP_RGB32 =1U<<15,
- FF_CSP_RGB24 =1U<<16,
- FF_CSP_RGB15 =1U<<17,
- FF_CSP_RGB16 =1U<<18,
-
- FF_CSP_PAL8 =1U<<19,
- FF_CSP_CLJR =1U<<20,
- FF_CSP_Y800 =1U<<21,
- FF_CSP_NV12 =1U<<22
+enum {
+ FF_CSP_NULL = 0,
+
+ FF_CSP_420P =1U<< 0,
+ FF_CSP_422P =1U<< 1,
+ FF_CSP_444P =1U<< 2,
+ FF_CSP_411P =1U<< 3,
+ FF_CSP_410P =1U<< 4,
+
+ FF_CSP_YUY2 =1U<< 5,
+ FF_CSP_UYVY =1U<< 6,
+ FF_CSP_YVYU =1U<< 7,
+ FF_CSP_VYUY =1U<< 8,
+
+ FF_CSP_ABGR =1U<< 9, // [a|b|g|r]
+ FF_CSP_RGBA =1U<<10, // [r|g|b|a]
+ FF_CSP_BGR32 =1U<<11,
+ FF_CSP_BGR24 =1U<<12,
+ FF_CSP_BGR15 =1U<<13,
+ FF_CSP_BGR16 =1U<<14,
+ FF_CSP_RGB32 =1U<<15,
+ FF_CSP_RGB24 =1U<<16,
+ FF_CSP_RGB15 =1U<<17,
+ FF_CSP_RGB16 =1U<<18,
+
+ FF_CSP_PAL8 =1U<<19,
+ FF_CSP_CLJR =1U<<20,
+ FF_CSP_Y800 =1U<<21,
+ FF_CSP_NV12 =1U<<22
};
#define FF_CSPS_NUM 24
@@ -84,71 +83,121 @@ typedef ptrdiff_t stride_t;
static __inline int csp_xvid4_2ffdshow(int csp)
{
- switch (csp)
- {
- case XVID4_CSP_BGR :return FF_CSP_RGB24;
- case XVID4_CSP_YV12 :return FF_CSP_420P|FF_CSP_FLAGS_YUV_ADJ;
- case XVID4_CSP_YUY2 :return FF_CSP_YUY2;
- case XVID4_CSP_UYVY :return FF_CSP_UYVY;
- case XVID4_CSP_I420 :return FF_CSP_420P|FF_CSP_FLAGS_YUV_ADJ|FF_CSP_FLAGS_YUV_ORDER;
- case XVID4_CSP_RGB555:return FF_CSP_RGB15;
- case XVID4_CSP_RGB565:return FF_CSP_RGB16;
- case XVID4_CSP_PLANAR:return FF_CSP_420P;
- case XVID4_CSP_YVYU :return FF_CSP_YVYU;
- case XVID4_CSP_BGRA :return FF_CSP_RGB32;
- case XVID4_CSP_ABGR :return FF_CSP_ABGR;
- case XVID4_CSP_RGBA :return FF_CSP_RGBA;
- default :return FF_CSP_NULL;
- }
+ switch (csp) {
+ case XVID4_CSP_BGR :
+ return FF_CSP_RGB24;
+ case XVID4_CSP_YV12 :
+ return FF_CSP_420P|FF_CSP_FLAGS_YUV_ADJ;
+ case XVID4_CSP_YUY2 :
+ return FF_CSP_YUY2;
+ case XVID4_CSP_UYVY :
+ return FF_CSP_UYVY;
+ case XVID4_CSP_I420 :
+ return FF_CSP_420P|FF_CSP_FLAGS_YUV_ADJ|FF_CSP_FLAGS_YUV_ORDER;
+ case XVID4_CSP_RGB555:
+ return FF_CSP_RGB15;
+ case XVID4_CSP_RGB565:
+ return FF_CSP_RGB16;
+ case XVID4_CSP_PLANAR:
+ return FF_CSP_420P;
+ case XVID4_CSP_YVYU :
+ return FF_CSP_YVYU;
+ case XVID4_CSP_BGRA :
+ return FF_CSP_RGB32;
+ case XVID4_CSP_ABGR :
+ return FF_CSP_ABGR;
+ case XVID4_CSP_RGBA :
+ return FF_CSP_RGBA;
+ default :
+ return FF_CSP_NULL;
+ }
}
//================================= ffmpeg ===================================
static __inline int csp_lavc2ffdshow(enum PixelFormat pix_fmt)
{
- switch (pix_fmt)
- {
- case PIX_FMT_YUV420P :return FF_CSP_420P;
- case PIX_FMT_YUVJ420P:return FF_CSP_420P|FF_CSP_FLAGS_YUV_JPEG;
- case PIX_FMT_YUV422P :return FF_CSP_422P;
- case PIX_FMT_YUVJ422P:return FF_CSP_422P|FF_CSP_FLAGS_YUV_JPEG;
- case PIX_FMT_YUV444P :return FF_CSP_444P;
- case PIX_FMT_YUVJ444P:return FF_CSP_444P|FF_CSP_FLAGS_YUV_JPEG;
- case PIX_FMT_YUV411P :return FF_CSP_411P;
- case PIX_FMT_YUV410P :return FF_CSP_410P;
- case PIX_FMT_YUYV422 :return FF_CSP_YUY2;
- case PIX_FMT_UYVY422 :return FF_CSP_UYVY;
- case PIX_FMT_RGB24 :return FF_CSP_RGB24;
- case PIX_FMT_BGR24 :return FF_CSP_BGR24;
- case PIX_FMT_RGB32 :return FF_CSP_RGB32;
- case PIX_FMT_RGB555 :return FF_CSP_RGB15;
- case PIX_FMT_RGB565 :return FF_CSP_RGB16;
- case PIX_FMT_PAL8 :return FF_CSP_PAL8;
- case PIX_FMT_GRAY8 :return FF_CSP_Y800;
- case PIX_FMT_NV12 :return FF_CSP_NV12;
- default :return FF_CSP_NULL;
- }
+ switch (pix_fmt) {
+ case PIX_FMT_YUV420P :
+ return FF_CSP_420P;
+ case PIX_FMT_YUVJ420P:
+ return FF_CSP_420P|FF_CSP_FLAGS_YUV_JPEG;
+ case PIX_FMT_YUV422P :
+ return FF_CSP_422P;
+ case PIX_FMT_YUVJ422P:
+ return FF_CSP_422P|FF_CSP_FLAGS_YUV_JPEG;
+ case PIX_FMT_YUV444P :
+ return FF_CSP_444P;
+ case PIX_FMT_YUVJ444P:
+ return FF_CSP_444P|FF_CSP_FLAGS_YUV_JPEG;
+ case PIX_FMT_YUV411P :
+ return FF_CSP_411P;
+ case PIX_FMT_YUV410P :
+ return FF_CSP_410P;
+ case PIX_FMT_YUYV422 :
+ return FF_CSP_YUY2;
+ case PIX_FMT_UYVY422 :
+ return FF_CSP_UYVY;
+ case PIX_FMT_RGB24 :
+ return FF_CSP_RGB24;
+ case PIX_FMT_BGR24 :
+ return FF_CSP_BGR24;
+ case PIX_FMT_RGB32 :
+ case PIX_FMT_ARGB:
+ return FF_CSP_RGB32;
+ case PIX_FMT_RGB555 :
+ return FF_CSP_RGB15;
+ case PIX_FMT_RGB565 :
+ return FF_CSP_RGB16;
+ case PIX_FMT_PAL8 :
+ return FF_CSP_PAL8;
+ case PIX_FMT_GRAY8 :
+ return FF_CSP_Y800;
+ case PIX_FMT_NV12 :
+ return FF_CSP_NV12;
+ default :
+ return FF_CSP_NULL;
+ }
}
static __inline enum PixelFormat csp_ffdshow2lavc(int pix_fmt)
{
- switch (pix_fmt&FF_CSPS_MASK)
- {
- case FF_CSP_420P:return pix_fmt&FF_CSP_FLAGS_YUV_JPEG?PIX_FMT_YUVJ420P:PIX_FMT_YUV420P;
- case FF_CSP_422P:return pix_fmt&FF_CSP_FLAGS_YUV_JPEG?PIX_FMT_YUVJ422P:PIX_FMT_YUV422P;
- case FF_CSP_444P:return pix_fmt&FF_CSP_FLAGS_YUV_JPEG?PIX_FMT_YUVJ444P:PIX_FMT_YUV444P;
- case FF_CSP_411P:return PIX_FMT_YUV411P;
- case FF_CSP_410P:return PIX_FMT_YUV410P;
- case FF_CSP_YUY2:return PIX_FMT_YUYV422;
- case FF_CSP_UYVY:return PIX_FMT_UYVY422;
- case FF_CSP_RGB24:return PIX_FMT_RGB24;
- case FF_CSP_BGR24:return PIX_FMT_BGR24;
- case FF_CSP_RGB32:return PIX_FMT_RGB32;
- case FF_CSP_RGB15:return PIX_FMT_RGB555;
- case FF_CSP_RGB16:return PIX_FMT_RGB565;
- case FF_CSP_PAL8:return PIX_FMT_PAL8;
- case FF_CSP_Y800:return PIX_FMT_GRAY8;
- case FF_CSP_NV12:return PIX_FMT_NV12;
- default :return PIX_FMT_NB;
- }
+ switch (pix_fmt&FF_CSPS_MASK) {
+ case FF_CSP_420P:
+ return pix_fmt&FF_CSP_FLAGS_YUV_JPEG?PIX_FMT_YUVJ420P:PIX_FMT_YUV420P;
+ case FF_CSP_422P:
+ return pix_fmt&FF_CSP_FLAGS_YUV_JPEG?PIX_FMT_YUVJ422P:PIX_FMT_YUV422P;
+ case FF_CSP_444P:
+ return pix_fmt&FF_CSP_FLAGS_YUV_JPEG?PIX_FMT_YUVJ444P:PIX_FMT_YUV444P;
+ case FF_CSP_411P:
+ return PIX_FMT_YUV411P;
+ case FF_CSP_410P:
+ return PIX_FMT_YUV410P;
+ case FF_CSP_YUY2:
+ return PIX_FMT_YUYV422;
+ case FF_CSP_UYVY:
+ return PIX_FMT_UYVY422;
+ case FF_CSP_RGB24:
+ return PIX_FMT_RGB24;
+ case FF_CSP_BGR24:
+ return PIX_FMT_BGR24;
+ case FF_CSP_RGB32:
+ return PIX_FMT_RGB32;
+ case FF_CSP_RGB15:
+ return PIX_FMT_RGB555;
+ case FF_CSP_RGB16:
+ return PIX_FMT_RGB565;
+ case FF_CSP_PAL8:
+ return PIX_FMT_PAL8;
+ case FF_CSP_Y800:
+ return PIX_FMT_GRAY8;
+ case FF_CSP_NV12:
+ return PIX_FMT_NV12;
+ case FF_CSP_ABGR:
+ return PIX_FMT_ABGR;
+ case FF_CSP_RGBA:
+ return PIX_FMT_RGBA;
+ default :
+ return PIX_FMT_NB;
+ }
}
//=================================== mplayer ===================================
@@ -227,78 +276,119 @@ static __inline enum PixelFormat csp_ffdshow2lavc(int pix_fmt)
static __inline int csp_mplayercsp2Bpp(int mplayercsp)
{
- // return byte per pixel for the first plane.
- // IMGFMT_NV21,IMGFMT_NV12 are troublesome, because bpp is different in first plane and second plane.
- switch (mplayercsp)
- {
- case IMGFMT_YV12 :return 1;
- case IMGFMT_422P :return 1;
- case IMGFMT_444P :return 1;
- case IMGFMT_411P :return 1;
- case IMGFMT_YVU9 :return 1;
-
- case IMGFMT_YUY2 :return 2;
- case IMGFMT_UYVY :return 2;
- case IMGFMT_YVYU :return 2;
- case IMGFMT_VYUY :return 2;
-
- case IMGFMT_RGB32 :return 4;
-
- case IMGFMT_BGR15:return 2;
- case IMGFMT_BGR16:return 2;
- case IMGFMT_BGR24:return 3;
- case IMGFMT_BGR32:return 4;
-
- case IMGFMT_RGB15:return 2;
- case IMGFMT_RGB16:return 2;
- case IMGFMT_RGB24:return 3;
-
- case IMGFMT_Y800 :return 1;
- case IMGFMT_NV12 :return 1;
- case IMGFMT_NV21 :return 1;
- default :return 1;
- }
+ // return byte per pixel for the first plane.
+ // IMGFMT_NV21,IMGFMT_NV12 are troublesome, because bpp is different in first plane and second plane.
+ switch (mplayercsp) {
+ case IMGFMT_YV12 :
+ return 1;
+ case IMGFMT_422P :
+ return 1;
+ case IMGFMT_444P :
+ return 1;
+ case IMGFMT_411P :
+ return 1;
+ case IMGFMT_YVU9 :
+ return 1;
+
+ case IMGFMT_YUY2 :
+ return 2;
+ case IMGFMT_UYVY :
+ return 2;
+ case IMGFMT_YVYU :
+ return 2;
+ case IMGFMT_VYUY :
+ return 2;
+
+ case IMGFMT_RGB32 :
+ return 4;
+
+ case IMGFMT_BGR15:
+ return 2;
+ case IMGFMT_BGR16:
+ return 2;
+ case IMGFMT_BGR24:
+ return 3;
+ case IMGFMT_BGR32:
+ return 4;
+
+ case IMGFMT_RGB15:
+ return 2;
+ case IMGFMT_RGB16:
+ return 2;
+ case IMGFMT_RGB24:
+ return 3;
+
+ case IMGFMT_Y800 :
+ return 1;
+ case IMGFMT_NV12 :
+ return 1;
+ case IMGFMT_NV21 :
+ return 1;
+ default :
+ return 1;
+ }
}
-// libmplayer refers to the write order, FF_CSP_ enum refers to the "memory byte order",
+// libmplayer refers to the write order, FF_CSP_ enum refers to the "memory byte order",
// which under x86 is reversed, see the comment above the FF_CSP_ enum definition.
static __inline int csp_ffdshow2mplayer(int csp)
{
- switch (csp&FF_CSPS_MASK)
- {
- case FF_CSP_420P :return IMGFMT_YV12;
- case FF_CSP_422P :return IMGFMT_422P;
- case FF_CSP_444P :return IMGFMT_444P;
- case FF_CSP_411P :return IMGFMT_411P;
- case FF_CSP_410P :return IMGFMT_YVU9;
-/*
- case FF_CSP_YUY2 :return IMGFMT_YVYU;
- case FF_CSP_UYVY :return IMGFMT_VYUY;
- case FF_CSP_YVYU :return IMGFMT_YUY2;
- case FF_CSP_VYUY :return IMGFMT_UYVY;
-*/
- case FF_CSP_YUY2 :return IMGFMT_YUY2;
- case FF_CSP_UYVY :return IMGFMT_UYVY;
- case FF_CSP_YVYU :return IMGFMT_YVYU;
- case FF_CSP_VYUY :return IMGFMT_VYUY;
-
- case FF_CSP_ABGR :return IMGFMT_RGB32;
- case FF_CSP_RGBA :return IMGFMT_RGB32;
-
- case FF_CSP_RGB15:return IMGFMT_BGR15; // see the comment above
- case FF_CSP_RGB16:return IMGFMT_BGR16; // see the comment above
- case FF_CSP_RGB24:return IMGFMT_BGR24; // see the comment above
- case FF_CSP_RGB32:return IMGFMT_BGR32; // see the comment above
-
- case FF_CSP_BGR15:return IMGFMT_RGB15; // see the comment above
- case FF_CSP_BGR16:return IMGFMT_RGB16; // see the comment above
- case FF_CSP_BGR24:return IMGFMT_RGB24; // see the comment above
- case FF_CSP_BGR32:return IMGFMT_RGB32; // see the comment above
-
- case FF_CSP_Y800 :return IMGFMT_Y800;
- case FF_CSP_NV12 :return csp&FF_CSP_FLAGS_YUV_ORDER?IMGFMT_NV12:IMGFMT_NV21;
- default :return 0;
- }
+ switch (csp&FF_CSPS_MASK) {
+ case FF_CSP_420P :
+ return IMGFMT_YV12;
+ case FF_CSP_422P :
+ return IMGFMT_422P;
+ case FF_CSP_444P :
+ return IMGFMT_444P;
+ case FF_CSP_411P :
+ return IMGFMT_411P;
+ case FF_CSP_410P :
+ return IMGFMT_YVU9;
+ /*
+ case FF_CSP_YUY2 :return IMGFMT_YVYU;
+ case FF_CSP_UYVY :return IMGFMT_VYUY;
+ case FF_CSP_YVYU :return IMGFMT_YUY2;
+ case FF_CSP_VYUY :return IMGFMT_UYVY;
+ */
+ case FF_CSP_YUY2 :
+ return IMGFMT_YUY2;
+ case FF_CSP_UYVY :
+ return IMGFMT_UYVY;
+ case FF_CSP_YVYU :
+ return IMGFMT_YVYU;
+ case FF_CSP_VYUY :
+ return IMGFMT_VYUY;
+
+ case FF_CSP_ABGR :
+ return IMGFMT_RGB32;
+ case FF_CSP_RGBA :
+ return IMGFMT_RGB32;
+
+ case FF_CSP_RGB15:
+ return IMGFMT_BGR15; // see the comment above
+ case FF_CSP_RGB16:
+ return IMGFMT_BGR16; // see the comment above
+ case FF_CSP_RGB24:
+ return IMGFMT_BGR24; // see the comment above
+ case FF_CSP_RGB32:
+ return IMGFMT_BGR32; // see the comment above
+
+ case FF_CSP_BGR15:
+ return IMGFMT_RGB15; // see the comment above
+ case FF_CSP_BGR16:
+ return IMGFMT_RGB16; // see the comment above
+ case FF_CSP_BGR24:
+ return IMGFMT_RGB24; // see the comment above
+ case FF_CSP_BGR32:
+ return IMGFMT_RGB32; // see the comment above
+
+ case FF_CSP_Y800 :
+ return IMGFMT_Y800;
+ case FF_CSP_NV12 :
+ return csp&FF_CSP_FLAGS_YUV_ORDER?IMGFMT_NV12:IMGFMT_NV21;
+ default :
+ return 0;
+ }
}
#define SWS_IN_CSPS \
@@ -348,11 +438,11 @@ static __inline int csp_ffdshow2mplayer(int csp)
static __inline int csp_supSWSin(int x)
{
- return (x&FF_CSPS_MASK)&SWS_IN_CSPS;
+ return (x&FF_CSPS_MASK)&SWS_IN_CSPS;
}
static __inline int csp_supSWSout(int x)
{
- return (x&FF_CSPS_MASK)&SWS_OUT_CSPS;
+ return (x&FF_CSPS_MASK)&SWS_OUT_CSPS;
}
#endif
@@ -365,96 +455,95 @@ static __inline int csp_supSWSout(int x)
#include "array_allocator.h"
#include "char_t.h"
-struct TcspInfo
-{
- int id;
- const char_t *name;
- int Bpp,bpp;
- unsigned int numPlanes;
- unsigned int shiftX[4],shiftY[4];
- unsigned int black[4];
- FOURCC fcc,fcccsp;const GUID *subtype;
- int packedLumaOffset,packedChromaOffset;
+struct TcspInfo {
+ int id;
+ const char_t *name;
+ int Bpp,bpp;
+ unsigned int numPlanes;
+ unsigned int shiftX[4],shiftY[4];
+ unsigned int black[4];
+ FOURCC fcc,fcccsp;
+ const GUID *subtype;
+ int packedLumaOffset,packedChromaOffset;
};
extern const TcspInfo cspInfos[];
-struct TcspInfos :std::vector<const TcspInfo*,array_allocator<const TcspInfo*,FF_CSPS_NUM*2> >
-{
+struct TcspInfos :std::vector<const TcspInfo*,array_allocator<const TcspInfo*,FF_CSPS_NUM*2> > {
private:
- struct TsortFc
- {
- private:
- int csp;
- public:
- TsortFc(int Icsp):csp(Icsp) {}
- bool operator ()(const TcspInfo* &csp1,const TcspInfo* &csp2);
- };
+ struct TsortFc {
+ private:
+ int csp;
+ public:
+ TsortFc(int Icsp):csp(Icsp) {}
+ bool operator ()(const TcspInfo* &csp1,const TcspInfo* &csp2);
+ };
public:
- void sort(int csp);
+ void sort(int csp);
};
static __inline const TcspInfo* csp_getInfo(int csp)
{
- switch (csp&(FF_CSPS_MASK|FF_CSP_FLAGS_YUV_ORDER))
- {
- case FF_CSP_420P|FF_CSP_FLAGS_YUV_ORDER:
- {
- extern TcspInfo cspInfoIYUV;
- return &cspInfoIYUV;
- }
- case FF_CSP_NV12|FF_CSP_FLAGS_YUV_ORDER:
- {
- extern TcspInfo cspInfoNV21;
- return &cspInfoNV21;
+ switch (csp&(FF_CSPS_MASK|FF_CSP_FLAGS_YUV_ORDER)) {
+ case FF_CSP_420P|FF_CSP_FLAGS_YUV_ORDER: {
+ extern TcspInfo cspInfoIYUV;
+ return &cspInfoIYUV;
+ }
+ case FF_CSP_NV12|FF_CSP_FLAGS_YUV_ORDER: {
+ extern TcspInfo cspInfoNV21;
+ return &cspInfoNV21;
+ }
+ default:
+ csp&=FF_CSPS_MASK;
+ if (csp==0) {
+ return NULL;
+ }
+ int i=0;
+ while (csp>>=1) {
+ i++;
+ }
+ if (i<=FF_CSPS_NUM) {
+ return &cspInfos[i];
+ } else {
+ return NULL;
+ }
}
- default:
- csp&=FF_CSPS_MASK;
- if (csp==0) return NULL;
- int i=0;
- while (csp>>=1)
- i++;
- if (i<=FF_CSPS_NUM)
- return &cspInfos[i];
- else
- return NULL;
- }
}
const TcspInfo* csp_getInfoFcc(FOURCC fcc);
static __inline int csp_isYUVplanar(int x)
{
- return x&FF_CSPS_MASK&FF_CSPS_MASK_YUV_PLANAR;
+ return x&FF_CSPS_MASK&FF_CSPS_MASK_YUV_PLANAR;
}
static __inline int csp_isYUVpacked(int x)
{
- return x&FF_CSPS_MASK&FF_CSPS_MASK_YUV_PACKED;
+ return x&FF_CSPS_MASK&FF_CSPS_MASK_YUV_PACKED;
}
static __inline int csp_isYUV(int x)
{
- return csp_isYUVpacked(x)|csp_isYUVplanar(x);
+ return csp_isYUVpacked(x)|csp_isYUVplanar(x);
}
static __inline int csp_isYUV_NV(int x)
{
- return csp_isYUVpacked(x)|csp_isYUVplanar(x)|(x & FF_CSP_NV12);
+ return csp_isYUVpacked(x)|csp_isYUVplanar(x)|(x & FF_CSP_NV12);
}
static __inline int csp_isRGB_RGB(int x)
{
- return x&FF_CSPS_MASK&FF_CSPS_MASK_RGB;
+ return x&FF_CSPS_MASK&FF_CSPS_MASK_RGB;
}
static __inline int csp_isRGB_BGR(int x)
{
- return x&FF_CSPS_MASK&FF_CSPS_MASK_BGR;
+ return x&FF_CSPS_MASK&FF_CSPS_MASK_BGR;
}
static __inline int csp_isRGB(int x)
{
- return csp_isRGB_RGB(x)|csp_isRGB_BGR(x);
+ return csp_isRGB_RGB(x)|csp_isRGB_BGR(x);
}
static __inline int csp_isPAL(int x)
{
- return x&FF_CSPS_MASK&FF_CSP_PAL8;
+ return x&FF_CSPS_MASK&FF_CSP_PAL8;
}
static __inline int csp_supXvid(int x)
{
- return (x&FF_CSPS_MASK)&(FF_CSP_RGB24|FF_CSP_420P|FF_CSP_YUY2|FF_CSP_UYVY|FF_CSP_YVYU|FF_CSP_VYUY|FF_CSP_RGB15|FF_CSP_RGB16|FF_CSP_RGB32|FF_CSP_ABGR|FF_CSP_RGBA|FF_CSP_BGR24);
+ return (x&FF_CSPS_MASK)&(FF_CSP_RGB24|FF_CSP_420P|FF_CSP_YUY2|FF_CSP_UYVY|FF_CSP_YVYU|FF_CSP_VYUY|FF_CSP_RGB15|FF_CSP_RGB16|FF_CSP_RGB32|FF_CSP_ABGR|FF_CSP_RGBA|FF_CSP_BGR24);
}
bool csp_inFOURCCmask(int x,FOURCC fcc);
@@ -467,44 +556,44 @@ static __inline void csp_yuv_adj_to_plane(int &csp,const TcspInfo *cspInfo,unsig
{
if (csp_isYUVplanar(csp) && (csp & FF_CSP_FLAGS_YUV_ADJ)) {
csp&=~FF_CSP_FLAGS_YUV_ADJ;
- data[2]=data[0]+stride[0]*(dy>>cspInfo->shiftY[0]);stride[1]=stride[0]>>cspInfo->shiftX[1];
- data[1]=data[2]+stride[1]*(dy>>cspInfo->shiftY[1]);stride[2]=stride[0]>>cspInfo->shiftX[2];
+ data[2]=data[0]+stride[0]*(dy>>cspInfo->shiftY[0]);
+ stride[1]=stride[0]>>cspInfo->shiftX[1];
+ data[1]=data[2]+stride[1]*(dy>>cspInfo->shiftY[1]);
+ stride[2]=stride[0]>>cspInfo->shiftX[2];
} else if ((csp & FF_CSP_NV12) && (csp & FF_CSP_FLAGS_YUV_ADJ)) {
csp&=~FF_CSP_FLAGS_YUV_ADJ;
data[1] = data[0] + stride[0] *dy;
stride[1] = stride[0];
}
-
+
}
static __inline void csp_yuv_order(int &csp,unsigned char *data[4],stride_t stride[4])
{
- if (csp_isYUVplanar(csp) && (csp&FF_CSP_FLAGS_YUV_ORDER))
- {
- csp&=~FF_CSP_FLAGS_YUV_ORDER;
- std::swap(data[1],data[2]);
- std::swap(stride[1],stride[2]);
- }
+ if (csp_isYUVplanar(csp) && (csp&FF_CSP_FLAGS_YUV_ORDER)) {
+ csp&=~FF_CSP_FLAGS_YUV_ORDER;
+ std::swap(data[1],data[2]);
+ std::swap(stride[1],stride[2]);
+ }
}
static __inline void csp_vflip(int &csp,const TcspInfo *cspInfo,unsigned char *data[],stride_t stride[],unsigned int dy)
{
- if (csp&FF_CSP_FLAGS_VFLIP)
- {
- csp&=~FF_CSP_FLAGS_VFLIP;
- for (unsigned int i=0;i<cspInfo->numPlanes;i++)
- {
- data[i]+=stride[i]*((dy>>cspInfo->shiftY[i])-1);
- stride[i]*=-1;
+ if (csp&FF_CSP_FLAGS_VFLIP) {
+ csp&=~FF_CSP_FLAGS_VFLIP;
+ for (unsigned int i=0; i<cspInfo->numPlanes; i++) {
+ data[i]+=stride[i]*((dy>>cspInfo->shiftY[i])-1);
+ stride[i]*=-1;
+ }
}
- }
}
int getBMPcolorspace(const BITMAPINFOHEADER *hdr,const TcspInfos &forcedCsps);
-struct TcspFcc
-{
- const char_t *name;
- FOURCC fcc;int csp;bool flip;
- bool supEnc;
+struct TcspFcc {
+ const char_t *name;
+ FOURCC fcc;
+ int csp;
+ bool flip;
+ bool supEnc;
};
extern const TcspFcc cspFccs[];
diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/ffcodecs.h b/src/filters/transform/MPCVideoDec/ffmpeg/ffcodecs.h
index ea7197265..22b6a4130 100644
--- a/src/filters/transform/MPCVideoDec/ffmpeg/ffcodecs.h
+++ b/src/filters/transform/MPCVideoDec/ffmpeg/ffcodecs.h
@@ -79,16 +79,17 @@
CODEC_OP(CODEC_ID_RV30 ,69,"rv30") \
CODEC_OP(CODEC_ID_RV40 ,70,"rv40") \
CODEC_OP(CODEC_ID_AMV ,71,"amv") \
+ CODEC_OP(CODEC_ID_VP8 ,72,"vp8") \
\
/* Well-known audio codecs */ \
- CODEC_OP(CODEC_ID_MP2 ,100,"") \
- CODEC_OP(CODEC_ID_MP3 ,101,"") \
+ CODEC_OP(CODEC_ID_MP2 ,100,"mp2") \
+ CODEC_OP(CODEC_ID_MP3 ,101,"mp3") \
CODEC_OP(CODEC_ID_VORBIS ,102,"vorbis") \
- CODEC_OP(CODEC_ID_AC3 ,103,"") \
+ CODEC_OP(CODEC_ID_AC3 ,103,"ac3") \
CODEC_OP(CODEC_ID_WMAV1 ,104,"wmav1") \
CODEC_OP(CODEC_ID_WMAV2 ,105,"wmav2") \
- CODEC_OP(CODEC_ID_AAC ,106,"") \
- CODEC_OP(CODEC_ID_DTS ,107,"") \
+ CODEC_OP(CODEC_ID_AAC ,106,"aac") \
+ CODEC_OP(CODEC_ID_DTS ,107,"dts") \
CODEC_OP(CODEC_ID_IMC ,108,"imc") \
CODEC_OP(CODEC_ID_PCM_U16LE ,109,"") \
CODEC_OP(CODEC_ID_PCM_U16BE ,110,"") \
@@ -114,28 +115,27 @@
CODEC_OP(CODEC_ID_ADPCM_SBPRO_3 ,130,"") \
CODEC_OP(CODEC_ID_ADPCM_SBPRO_4 ,131,"") \
CODEC_OP(CODEC_ID_ADPCM_IMA_AMV ,132,"adpcm ima amv") \
- CODEC_OP(CODEC_ID_XAN_DPCM ,133,"adpcm ima xan") \
- CODEC_OP(CODEC_ID_FLAC ,134,"flac") \
- CODEC_OP(CODEC_ID_AMR_NB ,135,"amr nb") \
- CODEC_OP(CODEC_ID_GSM_MS ,136,"gsm ms") \
- CODEC_OP(CODEC_ID_TTA ,137,"tta") \
- CODEC_OP(CODEC_ID_MACE3 ,138,"mace3") \
- CODEC_OP(CODEC_ID_MACE6 ,139,"mace6") \
- CODEC_OP(CODEC_ID_QDM2 ,140,"qdm2") \
- CODEC_OP(CODEC_ID_COOK ,141,"cook") \
- CODEC_OP(CODEC_ID_TRUESPEECH ,142,"truespeech") \
- CODEC_OP(CODEC_ID_RA_144 ,143,"14_4") \
- CODEC_OP(CODEC_ID_RA_288 ,144,"28_8") \
- CODEC_OP(CODEC_ID_ATRAC3 ,145,"atrac 3") \
- CODEC_OP(CODEC_ID_NELLYMOSER ,146,"nellymoser") \
- CODEC_OP(CODEC_ID_ADPCM_ADX ,147,"adpcm adx") \
- CODEC_OP(CODEC_ID_MLP ,148,"MLP") \
- CODEC_OP(CODEC_ID_EAC3 ,149,"EAC3") \
- CODEC_OP(CODEC_ID_WAVPACK ,150,"Wavpack") \
- CODEC_OP(CODEC_ID_PCM_ZORK ,151,"PCM Zork") \
- CODEC_OP(CODEC_ID_SHORTEN ,152,"Shorten") \
+ CODEC_OP(CODEC_ID_FLAC ,133,"flac") \
+ CODEC_OP(CODEC_ID_AMR_NB ,134,"amr nb") \
+ CODEC_OP(CODEC_ID_GSM_MS ,135,"gsm ms") \
+ CODEC_OP(CODEC_ID_TTA ,136,"tta") \
+ CODEC_OP(CODEC_ID_MACE3 ,137,"mace3") \
+ CODEC_OP(CODEC_ID_MACE6 ,138,"mace6") \
+ CODEC_OP(CODEC_ID_QDM2 ,139,"qdm2") \
+ CODEC_OP(CODEC_ID_COOK ,140,"cook") \
+ CODEC_OP(CODEC_ID_TRUESPEECH ,141,"truespeech") \
+ CODEC_OP(CODEC_ID_RA_144 ,142,"14_4") \
+ CODEC_OP(CODEC_ID_RA_288 ,143,"28_8") \
+ CODEC_OP(CODEC_ID_ATRAC3 ,144,"atrac 3") \
+ CODEC_OP(CODEC_ID_NELLYMOSER ,145,"nellymoser") \
+ CODEC_OP(CODEC_ID_EAC3 ,146,"eac3") \
+ CODEC_OP(CODEC_ID_MP3ADU ,147,"mp3adu") \
+ CODEC_OP(CODEC_ID_MLP ,148,"mlp") \
+ CODEC_OP(CODEC_ID_MP1 ,149,"mp1") \
+ CODEC_OP(CODEC_ID_TRUEHD ,150,"truehd") \
+ CODEC_OP(CODEC_ID_WAVPACK ,151,"wavpack") \
+ CODEC_OP(CODEC_ID_GSM ,152,"gsm") \
CODEC_OP(CODEC_ID_AMR_WB ,153,"amrwb") \
- CODEC_OP(CODEC_ID_TRUEHD ,154,"truehd") \
\
/* Raw formats */ \
CODEC_OP(CODEC_ID_RAW ,300,"raw") \
@@ -164,30 +164,26 @@
CODEC_OP(CODEC_ID_PAL1 ,323,"raw") \
CODEC_OP(CODEC_ID_PAL4 ,324,"raw") \
CODEC_OP(CODEC_ID_PAL8 ,325,"raw") \
- CODEC_OP(CODEC_ID_LPCM ,398,"raw") \
- CODEC_OP(CODEC_ID_PCM ,399,"raw") \
- CODEC_OP(CODEC_ID_RAWVIDEO ,400,"raw") \
+ CODEC_OP(CODEC_ID_YV16 ,326,"raw") \
+ CODEC_OP(CODEC_ID_LPCM ,398,"raw LPCM") \
+ CODEC_OP(CODEC_ID_PCM ,399,"raw PCM") \
\
- CODEC_OP(CODEC_ID_PCM_S32LE ,200,"raw") \
- CODEC_OP(CODEC_ID_PCM_S32BE ,201,"raw") \
- CODEC_OP(CODEC_ID_PCM_U32LE ,202,"raw") \
- CODEC_OP(CODEC_ID_PCM_U32BE ,203,"raw") \
- CODEC_OP(CODEC_ID_PCM_S24LE ,204,"raw") \
- CODEC_OP(CODEC_ID_PCM_S24BE ,205,"raw") \
- CODEC_OP(CODEC_ID_PCM_U24LE ,206,"raw") \
- CODEC_OP(CODEC_ID_PCM_U24BE ,207,"raw") \
- CODEC_OP(CODEC_ID_PCM_S16LE ,208,"raw") \
- CODEC_OP(CODEC_ID_PCM_S16BE ,209,"raw") \
- CODEC_OP(CODEC_ID_PCM_S24DAUD ,210,"raw") \
+ CODEC_OP(CODEC_ID_PCM_S32LE ,200,"raw PCM 32") \
+ CODEC_OP(CODEC_ID_PCM_S32BE ,201,"raw PCM 32") \
+ CODEC_OP(CODEC_ID_PCM_U32LE ,202,"raw PCM 32") \
+ CODEC_OP(CODEC_ID_PCM_U32BE ,203,"raw PCM 32") \
+ CODEC_OP(CODEC_ID_PCM_S24LE ,204,"raw PCM 24") \
+ CODEC_OP(CODEC_ID_PCM_S24BE ,205,"raw PCM 24") \
+ CODEC_OP(CODEC_ID_PCM_U24LE ,206,"raw PCM 24") \
+ CODEC_OP(CODEC_ID_PCM_U24BE ,207,"raw PCM 24") \
+ CODEC_OP(CODEC_ID_PCM_S16LE ,208,"raw PCM 16") \
+ CODEC_OP(CODEC_ID_PCM_S16BE ,209,"raw PCM 16") \
+ CODEC_OP(CODEC_ID_PCM_S24DAUD ,210,"raw PCM 24") \
\
CODEC_OP(CODEC_ID_XVID4 ,400,"xvid") \
\
CODEC_OP(CODEC_ID_LIBMPEG2 ,500,"libmpeg2") \
\
- CODEC_OP(CODEC_ID_THEORA_LIB ,600,"libtheora") \
- \
- CODEC_OP(CODEC_ID_MP3LIB ,700,"mp3lib") \
- \
CODEC_OP(CODEC_ID_LIBMAD ,800,"libmad") \
\
CODEC_OP(CODEC_ID_LIBFAAD ,900,"faad2") \
@@ -196,104 +192,251 @@
\
CODEC_OP(CODEC_ID_AVISYNTH ,1100,"avisynth") \
\
- CODEC_OP(CODEC_ID_SKAL ,1200,"skal's") \
- \
CODEC_OP(CODEC_ID_LIBA52 ,1300,"liba52") \
\
- CODEC_OP(CODEC_ID_SPDIF_AC3 ,1400,"s/pdif") \
- CODEC_OP(CODEC_ID_SPDIF_DTS ,1401,"s/pdif") \
+ CODEC_OP(CODEC_ID_SPDIF_AC3 ,1400,"AC3 s/pdif") \
+ CODEC_OP(CODEC_ID_SPDIF_DTS ,1401,"DTS s/pdif") \
+ CODEC_OP(CODEC_ID_BITSTREAM_TRUEHD ,1402,"bitstream Dolby True HD") \
+ CODEC_OP(CODEC_ID_BITSTREAM_DTSHD ,1403,"bitstream DTS-HD") \
+ CODEC_OP(CODEC_ID_BITSTREAM_EAC3 ,1404,"bitstream EAC3") \
\
CODEC_OP(CODEC_ID_LIBDTS ,1500,"libdts") \
\
- CODEC_OP(CODEC_ID_TREMOR ,1600,"tremor") \
- \
- CODEC_OP(CODEC_ID_REALAAC ,1700,"realaac") \
+ CODEC_OP(CODEC_ID_H264_MT ,2000,"h264 multithreaded") \
+ CODEC_OP(CODEC_ID_VP3_MT ,2001,"vp3 multithreaded") \
+ CODEC_OP(CODEC_ID_THEORA_MT ,2002,"theora multithreaded") \
\
- CODEC_OP(CODEC_ID_AUDX ,1800,"Aud-X") \
+ CODEC_OP(CODEC_ID_H264_DXVA ,2100,"h264 DXVA") \
\
- CODEC_OP(CODEC_ID_X264 ,1900,"x264") \
- CODEC_OP(CODEC_ID_X264_LOSSLESS ,1901,"x264 lossless") \
+ CODEC_OP(CODEC_ID_VC1_DXVA ,2101,"vc1 DXVA") \
\
- CODEC_OP(CODEC_ID_VP8 ,1902,"VP8") \
- \
- /* Subtitles formats */ \
- CODEC_OP(CODEC_ID_DVD_SUBTITLE ,2000,"DVD Subs") \
- CODEC_OP(CODEC_ID_DVB_SUBTITLE ,2001,"DVB Subs") \
- CODEC_OP(CODEC_ID_SSA ,2002,"SSA") \
- CODEC_OP(CODEC_ID_TEXT ,2003,"Text") \
- CODEC_OP(CODEC_ID_XSUB ,2004,"XSUB") \
- /* Other formats */ \
- CODEC_OP(CODEC_ID_GSM ,2101,"GSM") \
- CODEC_OP(CODEC_ID_GIF ,2102,"Gif") \
- CODEC_OP(CODEC_ID_TIFF ,2103,"Tiff") \
- CODEC_OP(CODEC_ID_TTF ,2104,"TTF")
-enum CodecID
-{
- #define CODEC_OP(codecEnum,codecId,codecName) codecEnum=codecId,
- FFDSHOW_CODECS
- #undef CODEC_OP
+ CODEC_OP(CODEC_ID_HDMV_PGS_SUBTITLE, 2200, "PGS subtitles")
+
+
+
+
+enum CodecID {
+#define CODEC_OP(codecEnum,codecId,codecName) codecEnum=codecId,
+ FFDSHOW_CODECS
+#undef CODEC_OP
};
#ifdef __cplusplus
-template<> struct isPOD<CodecID> {enum {is=true};};
+template<> struct isPOD<CodecID> {
+ enum {is=true};
+};
const FOURCC* getCodecFOURCCs(CodecID codecId);
//const char_t* getCodecName(CodecID codecId);
-static __inline bool lavc_codec(int x) {return x>0 && x<200;}
-static __inline bool raw_codec(int x) {return x>=300 && x<400;}
-static __inline bool xvid_codec(int x) {return x==CODEC_ID_XVID4;}
-static __inline bool theora_codec(int x) {return x==CODEC_ID_THEORA_LIB;}
-static __inline bool mplayer_codec(int x) {return x==CODEC_ID_MP3LIB;}
-static __inline bool wmv9_codec(int x) {return x>=1000 && x<1100;}
-static __inline bool mpeg12_codec(int x) {return x==CODEC_ID_MPEG1VIDEO || x==CODEC_ID_MPEG2VIDEO || x==CODEC_ID_LIBMPEG2;}
-static __inline bool mpeg1_codec(int x) {return x==CODEC_ID_MPEG1VIDEO || x==CODEC_ID_LIBMPEG2;}
-static __inline bool mpeg2_codec(int x) {return x==CODEC_ID_MPEG2VIDEO || x==CODEC_ID_LIBMPEG2;}
-static __inline bool mpeg4_codec(int x) {return x==CODEC_ID_MPEG4 || xvid_codec(x) || x==CODEC_ID_SKAL;}
-static __inline bool spdif_codec(int x) {return x==CODEC_ID_SPDIF_AC3 || x==CODEC_ID_SPDIF_DTS;}
-static __inline bool huffyuv_codec(int x) {return x==CODEC_ID_HUFFYUV || x==CODEC_ID_FFVHUFF;}
-static __inline bool x264_codec(int x) {return x==CODEC_ID_X264 || x==CODEC_ID_X264_LOSSLESS;}
-static __inline bool lossless_codec(int x) {return huffyuv_codec(x) || x==CODEC_ID_LJPEG || x==CODEC_ID_FFV1 || x==CODEC_ID_DVVIDEO || x==CODEC_ID_X264_LOSSLESS;}
+static __inline bool lavc_codec(int x)
+{
+ return x>0 && x<200;
+}
+static __inline bool raw_codec(int x)
+{
+ return x>=300 && x<400;
+}
+static __inline bool xvid_codec(int x)
+{
+ return x==CODEC_ID_XVID4;
+}
+static __inline bool wmv9_codec(int x)
+{
+ return x>=1000 && x<1100;
+}
+static __inline bool mpeg12_codec(int x)
+{
+ return x==CODEC_ID_MPEG1VIDEO || x==CODEC_ID_MPEG2VIDEO || x==CODEC_ID_LIBMPEG2;
+}
+static __inline bool mpeg1_codec(int x)
+{
+ return x==CODEC_ID_MPEG1VIDEO || x==CODEC_ID_LIBMPEG2;
+}
+static __inline bool mpeg2_codec(int x)
+{
+ return x==CODEC_ID_MPEG2VIDEO || x==CODEC_ID_LIBMPEG2;
+}
+static __inline bool mpeg4_codec(int x)
+{
+ return x==CODEC_ID_MPEG4 || xvid_codec(x);
+}
+static __inline bool spdif_codec(int x)
+{
+ return x==CODEC_ID_SPDIF_AC3 || x==CODEC_ID_SPDIF_DTS;
+}
+static __inline bool bitstream_codec(int x)
+{
+ return x==CODEC_ID_BITSTREAM_TRUEHD || x==CODEC_ID_BITSTREAM_DTSHD || x==CODEC_ID_BITSTREAM_EAC3;
+}
+static __inline bool huffyuv_codec(int x)
+{
+ return x==CODEC_ID_HUFFYUV || x==CODEC_ID_FFVHUFF;
+}
+static __inline bool lossless_codec(int x)
+{
+ return huffyuv_codec(x) || x==CODEC_ID_LJPEG || x==CODEC_ID_FFV1 || x==CODEC_ID_DVVIDEO;
+}
+static __inline bool h264_codec(int x)
+{
+ return x == CODEC_ID_H264 || x == CODEC_ID_H264_MT;
+}
+static __inline bool vc1_codec(int x)
+{
+ return x == CODEC_ID_VC1 || x == CODEC_ID_WMV9_LIB;
+}
+static __inline bool dxva_codec(int x)
+{
+ return x == CODEC_ID_H264_DXVA || x == CODEC_ID_VC1_DXVA;
+}
//I'm not sure of all these
-static __inline bool sup_CBR(int x) {return !lossless_codec(x) && !raw_codec(x);}
-static __inline bool sup_VBR_QUAL(int x) {return !lossless_codec(x) && !raw_codec(x) && x!=CODEC_ID_SKAL;}
-static __inline bool sup_VBR_QUANT(int x) {return (lavc_codec(x) || xvid_codec(x) || theora_codec(x) || x==CODEC_ID_SKAL || x==CODEC_ID_X264) && !lossless_codec(x) && x!=CODEC_ID_SNOW;}
-static __inline bool sup_XVID2PASS(int x) {return sup_VBR_QUANT(x) && x!=CODEC_ID_X264 && x!=CODEC_ID_SNOW;}
-static __inline bool sup_LAVC2PASS(int x) {return (lavc_codec(x) && !lossless_codec(x) && x!=CODEC_ID_MJPEG && !raw_codec(x)) || x==CODEC_ID_X264;}
+static __inline bool sup_CBR(int x)
+{
+ return !lossless_codec(x) && !raw_codec(x);
+}
+static __inline bool sup_VBR_QUAL(int x)
+{
+ return !lossless_codec(x) && !raw_codec(x);
+}
+static __inline bool sup_VBR_QUANT(int x)
+{
+ return (lavc_codec(x) || xvid_codec(x)) && !lossless_codec(x) && x!=CODEC_ID_SNOW;
+}
+static __inline bool sup_XVID2PASS(int x)
+{
+ return sup_VBR_QUANT(x) && x!=CODEC_ID_SNOW;
+}
+static __inline bool sup_LAVC2PASS(int x)
+{
+ return (lavc_codec(x) && !lossless_codec(x) && x!=CODEC_ID_MJPEG && !raw_codec(x));
+}
-static __inline bool sup_interlace(int x) {return x==CODEC_ID_MPEG4 || x==CODEC_ID_MPEG2VIDEO || xvid_codec(x) || x==CODEC_ID_SKAL;}
-static __inline bool sup_gray(int x) {return x!=CODEC_ID_LJPEG && x!=CODEC_ID_FFV1 && x!=CODEC_ID_SNOW && !theora_codec(x) && !wmv9_codec(x) && !raw_codec(x) && x!=CODEC_ID_SKAL && x!=CODEC_ID_DVVIDEO && !x264_codec(x);}
-static __inline bool sup_globalheader(int x) {return x==CODEC_ID_MPEG4;}
-static __inline bool sup_part(int x) {return x==CODEC_ID_MPEG4;}
-static __inline bool sup_packedBitstream(int x) {return xvid_codec(x);}
-static __inline bool sup_minKeySet(int x) {return x!=CODEC_ID_MJPEG && x!=CODEC_ID_SNOW && (!lossless_codec(x) || x==CODEC_ID_X264_LOSSLESS) && !wmv9_codec(x) && !raw_codec(x);}
-static __inline bool sup_maxKeySet(int x) {return x!=CODEC_ID_MJPEG && (!lossless_codec(x) || x==CODEC_ID_X264_LOSSLESS) && !raw_codec(x);}
-static __inline bool sup_bframes(int x) {return x==CODEC_ID_MPEG4 || x==CODEC_ID_MPEG1VIDEO || x==CODEC_ID_MPEG2VIDEO || xvid_codec(x) || x264_codec(x);}
-static __inline bool sup_adaptiveBframes(int x) {return lavc_codec(x) || x==CODEC_ID_X264;}
-static __inline bool sup_closedGop(int x) {return sup_bframes(x) && !x264_codec(x);}
-static __inline bool sup_lavcme(int x) {return lavc_codec(x) && x!=CODEC_ID_MJPEG && !lossless_codec(x);}
-static __inline bool sup_quantProps(int x) {return !lossless_codec(x) && !theora_codec(x) && !wmv9_codec(x) && !raw_codec(x) && x!=CODEC_ID_SNOW;}
-static __inline bool sup_trellisQuant(int x) {return x==CODEC_ID_MPEG4 || x==CODEC_ID_MPEG1VIDEO || x==CODEC_ID_MPEG2VIDEO || x==CODEC_ID_XVID4 || x==CODEC_ID_H263 || x==CODEC_ID_H263P || x==CODEC_ID_SKAL || x==CODEC_ID_X264;}
-static __inline bool sup_masking(int x) {return x==CODEC_ID_MPEG4 || x==CODEC_ID_H263 || x==CODEC_ID_H263P || x==CODEC_ID_MPEG1VIDEO || x==CODEC_ID_MPEG2VIDEO || xvid_codec(x) || x==CODEC_ID_SKAL || x==CODEC_ID_X264;}
-static __inline bool sup_lavcOnePass(int x) {return (lavc_codec(x) && !lossless_codec(x)) || x==CODEC_ID_X264;}
-static __inline bool sup_perFrameQuant(int x) {return !lossless_codec(x) && !wmv9_codec(x) && !raw_codec(x) && !x264_codec(x) && x!=CODEC_ID_SNOW;}
-static __inline bool sup_4mv(int x) {return x==CODEC_ID_MPEG4 || x==CODEC_ID_H263 || x==CODEC_ID_H263P || x==CODEC_ID_SNOW || x==CODEC_ID_SKAL;}
-static __inline bool sup_aspect(int x) {return x==CODEC_ID_MPEG4 || x==CODEC_ID_MPEG1VIDEO || x==CODEC_ID_MPEG2VIDEO || x==CODEC_ID_XVID4 || x==CODEC_ID_THEORA_LIB || x264_codec(x);}
-static __inline bool sup_PSNR(int x) {return (lavc_codec(x) && !lossless_codec(x)) || xvid_codec(x) || x==CODEC_ID_SKAL || x264_codec(x);}
-static __inline bool sup_quantBias(int x) {return lavc_codec(x) && !lossless_codec(x);}
-static __inline bool sup_MPEGquant(int x) {return x==CODEC_ID_MPEG4 || x==CODEC_ID_MSMPEG4V3 || x==CODEC_ID_MPEG2VIDEO || xvid_codec(x) || x==CODEC_ID_SKAL;}
-static __inline bool sup_lavcQuant(int x) {return lavc_codec(x) && sup_quantProps(x);}
-static __inline bool sup_customQuantTables(int x) {return x==CODEC_ID_MPEG4 || xvid_codec(x) || x==CODEC_ID_MPEG1VIDEO || x==CODEC_ID_MPEG2VIDEO || x==CODEC_ID_SKAL || x==CODEC_ID_X264;}
-static __inline bool sup_qpel(int x) {return x==CODEC_ID_MPEG4 || x==CODEC_ID_SNOW || xvid_codec(x) || x==CODEC_ID_SKAL;}
-static __inline bool sup_gmc(int x) {return xvid_codec(x) || x==CODEC_ID_SKAL;}
-static __inline bool sup_me_mv0(int x) {return sup_lavcme(x) && x!=CODEC_ID_SNOW;}
-static __inline bool sup_cbp_rd(int x) {return x==CODEC_ID_MPEG4;}
-static __inline bool sup_qns(int x) {return lavc_codec(x) && sup_quantProps(x) && x!=CODEC_ID_MSMPEG4V3 && x!=CODEC_ID_MSMPEG4V2 && x!=CODEC_ID_MSMPEG4V1 && x!=CODEC_ID_WMV1 && x!=CODEC_ID_WMV2 && x!=CODEC_ID_MJPEG && x!=CODEC_ID_SNOW;}
-static __inline bool sup_threads(int x) {return x==CODEC_ID_MPEG1VIDEO || x==CODEC_ID_MPEG2VIDEO || x==CODEC_ID_MPEG4 || x==CODEC_ID_XVID4 || x264_codec(x);}
-static __inline bool sup_threads_dec(int x) {return x==CODEC_ID_MPEG1VIDEO || x==CODEC_ID_MPEG2VIDEO || x==CODEC_ID_H264;}
-static __inline bool sup_palette(int x) {return x==CODEC_ID_MSVIDEO1 || x==CODEC_ID_8BPS || x==CODEC_ID_QTRLE || x==CODEC_ID_TSCC || x==CODEC_ID_QPEG || x==CODEC_ID_PNG;}
+static __inline bool sup_interlace(int x)
+{
+ return x==CODEC_ID_MPEG4 || x==CODEC_ID_MPEG2VIDEO || xvid_codec(x);
+}
+static __inline bool sup_gray(int x)
+{
+ return x!=CODEC_ID_LJPEG && x!=CODEC_ID_FFV1 && x!=CODEC_ID_SNOW && !wmv9_codec(x) && !raw_codec(x) && x!=CODEC_ID_DVVIDEO;
+}
+static __inline bool sup_globalheader(int x)
+{
+ return x==CODEC_ID_MPEG4;
+}
+static __inline bool sup_part(int x)
+{
+ return x==CODEC_ID_MPEG4;
+}
+static __inline bool sup_packedBitstream(int x)
+{
+ return xvid_codec(x);
+}
+static __inline bool sup_minKeySet(int x)
+{
+ return x!=CODEC_ID_MJPEG && x!=CODEC_ID_SNOW && !lossless_codec(x) && !wmv9_codec(x) && !raw_codec(x);
+}
+static __inline bool sup_maxKeySet(int x)
+{
+ return x!=CODEC_ID_MJPEG && !lossless_codec(x) && !raw_codec(x);
+}
+static __inline bool sup_bframes(int x)
+{
+ return x==CODEC_ID_MPEG4 || x==CODEC_ID_MPEG1VIDEO || x==CODEC_ID_MPEG2VIDEO || xvid_codec(x);
+}
+static __inline bool sup_adaptiveBframes(int x)
+{
+ return lavc_codec(x);
+}
+static __inline bool sup_closedGop(int x)
+{
+ return sup_bframes(x);
+}
+static __inline bool sup_lavcme(int x)
+{
+ return lavc_codec(x) && x!=CODEC_ID_MJPEG && !lossless_codec(x);
+}
+static __inline bool sup_quantProps(int x)
+{
+ return !lossless_codec(x) && !wmv9_codec(x) && !raw_codec(x) && x!=CODEC_ID_SNOW;
+}
+static __inline bool sup_trellisQuant(int x)
+{
+ return x==CODEC_ID_MPEG4 || x==CODEC_ID_MPEG1VIDEO || x==CODEC_ID_MPEG2VIDEO || x==CODEC_ID_XVID4 || x==CODEC_ID_H263 || x==CODEC_ID_H263P;
+}
+static __inline bool sup_masking(int x)
+{
+ return x==CODEC_ID_MPEG4 || x==CODEC_ID_H263 || x==CODEC_ID_H263P || x==CODEC_ID_MPEG1VIDEO || x==CODEC_ID_MPEG2VIDEO || xvid_codec(x);
+}
+static __inline bool sup_lavcOnePass(int x)
+{
+ return (lavc_codec(x) && !lossless_codec(x));
+}
+static __inline bool sup_perFrameQuant(int x)
+{
+ return !lossless_codec(x) && !wmv9_codec(x) && !raw_codec(x) && x!=CODEC_ID_SNOW;
+}
+static __inline bool sup_4mv(int x)
+{
+ return x==CODEC_ID_MPEG4 || x==CODEC_ID_H263 || x==CODEC_ID_H263P || x==CODEC_ID_SNOW;
+}
+static __inline bool sup_aspect(int x)
+{
+ return x==CODEC_ID_MPEG4 || x==CODEC_ID_MPEG1VIDEO || x==CODEC_ID_MPEG2VIDEO || x==CODEC_ID_XVID4;
+}
+static __inline bool sup_PSNR(int x)
+{
+ return (lavc_codec(x) && !lossless_codec(x)) || xvid_codec(x);
+}
+static __inline bool sup_quantBias(int x)
+{
+ return lavc_codec(x) && !lossless_codec(x);
+}
+static __inline bool sup_MPEGquant(int x)
+{
+ return x==CODEC_ID_MPEG4 || x==CODEC_ID_MSMPEG4V3 || x==CODEC_ID_MPEG2VIDEO || xvid_codec(x);
+}
+static __inline bool sup_lavcQuant(int x)
+{
+ return lavc_codec(x) && sup_quantProps(x);
+}
+static __inline bool sup_customQuantTables(int x)
+{
+ return x==CODEC_ID_MPEG4 || xvid_codec(x) || x==CODEC_ID_MPEG1VIDEO || x==CODEC_ID_MPEG2VIDEO;
+}
+static __inline bool sup_qpel(int x)
+{
+ return x==CODEC_ID_MPEG4 || x==CODEC_ID_SNOW || xvid_codec(x);
+}
+static __inline bool sup_gmc(int x)
+{
+ return xvid_codec(x);
+}
+static __inline bool sup_me_mv0(int x)
+{
+ return sup_lavcme(x) && x!=CODEC_ID_SNOW;
+}
+static __inline bool sup_cbp_rd(int x)
+{
+ return x==CODEC_ID_MPEG4;
+}
+static __inline bool sup_qns(int x)
+{
+ return lavc_codec(x) && sup_quantProps(x) && x!=CODEC_ID_MSMPEG4V3 && x!=CODEC_ID_MSMPEG4V2 && x!=CODEC_ID_MSMPEG4V1 && x!=CODEC_ID_WMV1 && x!=CODEC_ID_WMV2 && x!=CODEC_ID_MJPEG && x!=CODEC_ID_SNOW;
+}
+static __inline bool sup_threads(int x)
+{
+ return x==CODEC_ID_MPEG1VIDEO || x==CODEC_ID_MPEG2VIDEO || x==CODEC_ID_XVID4;
+}
+static __inline bool sup_threads_dec(int x)
+{
+ return x==CODEC_ID_MPEG1VIDEO || x==CODEC_ID_MPEG2VIDEO;
+}
+static __inline bool sup_palette(int x)
+{
+ return x==CODEC_ID_MSVIDEO1 || x==CODEC_ID_8BPS || x==CODEC_ID_QTRLE || x==CODEC_ID_TSCC || x==CODEC_ID_QPEG || x==CODEC_ID_PNG;
+}
#endif
diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/ac3dec_data.c b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/ac3dec_data.c
index ea13d3de5..c40390245 100644
--- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/ac3dec_data.c
+++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/ac3dec_data.c
@@ -43,12 +43,6 @@ const uint8_t ff_ac3_ungroup_3_in_5_bits_tab[32][3] = {
{ 3, 0, 1 }, { 3, 0, 2 }, { 3, 1, 0 }, { 3, 1, 1 }
};
-/**
- * Table of bin locations for rematrixing bands
- * reference: Section 7.5.2 Rematrixing : Frequency Band Definitions
- */
-const uint8_t ff_ac3_rematrix_band_tab[5] = { 13, 25, 37, 61, 253 };
-
const uint8_t ff_eac3_hebap_tab[64] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 8,
8, 8, 9, 9, 9, 10, 10, 10, 10, 11,
diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/ac3dec_data.h b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/ac3dec_data.h
index 9ed7c7318..e2ab7ddbe 100644
--- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/ac3dec_data.h
+++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/ac3dec_data.h
@@ -25,7 +25,6 @@
#include <stdint.h>
extern const uint8_t ff_ac3_ungroup_3_in_5_bits_tab[32][3];
-extern const uint8_t ff_ac3_rematrix_band_tab[5];
extern const uint8_t ff_eac3_hebap_tab[64];
extern const uint8_t ff_eac3_default_cpl_band_struct[18];
diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/ac3tab.c b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/ac3tab.c
index c8e6b068f..0837e95b4 100644
--- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/ac3tab.c
+++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/ac3tab.c
@@ -132,6 +132,12 @@ const uint16_t ff_ac3_bitrate_tab[19] = {
160, 192, 224, 256, 320, 384, 448, 512, 576, 640
};
+/**
+ * Table of bin locations for rematrixing bands
+ * reference: Section 7.5.2 Rematrixing : Frequency Band Definitions
+ */
+const uint8_t ff_ac3_rematrix_band_tab[5] = { 13, 25, 37, 61, 253 };
+
/* AC-3 MDCT window */
/* MDCT window */
diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/ac3tab.h b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/ac3tab.h
index 8f86370ab..8d70f6dc0 100644
--- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/ac3tab.h
+++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/ac3tab.h
@@ -32,6 +32,7 @@ extern const uint8_t ff_ac3_enc_channel_map[8][2][6];
extern const uint8_t ff_ac3_dec_channel_map[8][2][6];
extern const uint16_t ff_ac3_sample_rate_tab[3];
extern const uint16_t ff_ac3_bitrate_tab[19];
+extern const uint8_t ff_ac3_rematrix_band_tab[5];
extern const int16_t ff_ac3_window[AC3_WINDOW_SIZE/2];
extern const uint8_t ff_ac3_log_add_tab[260];
extern const uint16_t ff_ac3_hearing_threshold_tab[AC3_CRITICAL_BANDS][3];
diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/allcodecs.c b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/allcodecs.c
index cce50bef4..c760fdcb5 100644
--- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/allcodecs.c
+++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/allcodecs.c
@@ -70,6 +70,7 @@ void avcodec_register_all(void)
//REGISTER_ENCDEC (HUFFYUV, huffyuv);
//REGISTER_DECODER (INDEO2, indeo2);
//REGISTER_DECODER (INDEO3, indeo3);
+ //REGISTER_DECODER (INDEO5, indeo5);
//REGISTER_DECODER (JPEGLS, jpegls);
//REGISTER_ENCODER (LJPEG, ljpeg);
//REGISTER_DECODER (LOCO, loco);
@@ -148,6 +149,8 @@ void avcodec_register_all(void)
//REGISTER_DECODER (WMAV1, wmav1);
//REGISTER_DECODER (WMAV2, wmav2);
//REGISTER_DECODER (WAVPACK, wavpack);
+ //REGISTER_ENCODER (AC3, ac3);
+ //REGISTER_ENCODER (AC3_FIXED, ac3_fixed);
/* PCM codecs */
//REGISTER_DECODER (PCM_ALAW, pcm_alaw);
diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/avcodec.h b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/avcodec.h
index a6358a7fb..43f308393 100644
--- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/avcodec.h
+++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/avcodec.h
@@ -46,7 +46,7 @@
#include "libavutil/cpu.h"
#define LIBAVCODEC_VERSION_MAJOR 52
-#define LIBAVCODEC_VERSION_MINOR 99
+#define LIBAVCODEC_VERSION_MINOR 103
#define LIBAVCODEC_VERSION_MICRO 1
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
@@ -712,11 +712,11 @@ typedef struct AVPanScan{
int8_t *ref_index[2];\
\
/**\
- * reordered opaque 64bit (generally a integer or double preccission float \
+ * reordered opaque 64bit (generally an integer or a double precision float\
* PTS but can be anything). \
* The user sets AVCodecContext.reordered_opaque to represent the input at\
- * that time ,\
- * the decoder reorderes values as needed and sets AVFrame.reordered_opaque\
+ * that time,\
+ * the decoder reorders values as needed and sets AVFrame.reordered_opaque\
* to exactly one of the values provided by the user through AVCodecContext.reordered_opaque \
* - encoding: unused\
* - decoding: Read by user.\
@@ -1995,6 +1995,12 @@ typedef struct AVCodecContext {
#define FF_PROFILE_AAC_SSR 2
#define FF_PROFILE_AAC_LTP 3
+#define FF_PROFILE_DTS 20
+#define FF_PROFILE_DTS_ES 30
+#define FF_PROFILE_DTS_96_24 40
+#define FF_PROFILE_DTS_HD_HRA 50
+#define FF_PROFILE_DTS_HD_MA 60
+
#define FF_PROFILE_H264_BASELINE 66
#define FF_PROFILE_H264_MAIN 77
#define FF_PROFILE_H264_EXTENDED 88
@@ -2559,8 +2565,7 @@ typedef struct AVCodecContext {
int qmin_b,qmax_b;
float postgain;
- int ac3mode,ac3lfe;
- int ac3channels[6];
+ uint8_t ac3channels[6];
int nal_length_size;
int vorbis_header_size[3];
int64_t granulepos;
@@ -3370,18 +3375,6 @@ void *av_fast_realloc(void *ptr, unsigned int *size, FF_INTERNALC_MEM_TYPE min_s
*/
void av_fast_malloc(void *ptr, unsigned int *size, FF_INTERNALC_MEM_TYPE min_size);
-/* for static data only */
-
-/**
- * Frees all static arrays and resets their pointers to 0.
- * Call this function to release all statically allocated tables.
- *
- * @deprecated. Code which uses av_free_static is broken/misdesigned
- * and should correctly use static arrays
- *
- */
-attribute_deprecated void av_free_static(void);
-
#if LIBAVCODEC_VERSION_MAJOR < 53
/**
* @deprecated Deprecated in favor of av_image_copy().
diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/dsputil.c b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/dsputil.c
index 60da0d11e..358fb565d 100644
--- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/dsputil.c
+++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/dsputil.c
@@ -40,7 +40,6 @@
#include "ac3dec.h"
#include "vorbis.h"
#include "png.h"
-#include "vp8dsp.h"
uint8_t ff_cropTbl[256 + 2 * MAX_NEG_CROP] = {0, };
uint32_t ff_squareTbl[512] = {0, };
diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/h264.c b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/h264.c
index 25b2c7b14..d6f9a63f4 100644
--- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/h264.c
+++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/h264.c
@@ -1741,7 +1741,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
if (s->context_initialized
&& ( s->width != s->avctx->width || s->height != s->avctx->height
- || av_cmp_q(h->sps.sar, s->avctx->sample_aspect_ratio))) {
+ || (s->avctx->sample_aspect_ratio.num && av_cmp_q(h->sps.sar, s->avctx->sample_aspect_ratio)))) { //workaround to avoid crash with linked Matroska files, see fixme in line 1801
if(h != h0)
return -1; // width / height changed during parallelized decoding
free_tables(h);
@@ -1798,7 +1798,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0){
return -1;
}
- h->frame_num= get_bits(&s->gb, h->sps.log2_max_frame_num);
+ h->frame_num= get_bits(&s->gb, h->sps.log2_max_frame_num); // fixme: a crash occurs here with certain linked Matroska files if context is reset above
h->mb_mbaff = 0;
h->mb_aff_frame = 0;
diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/h264pred.c b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/h264pred.c
index aad472b7d..c71291b22 100644
--- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/h264pred.c
+++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/h264pred.c
@@ -80,6 +80,20 @@ static void pred4x4_128_dc_c(uint8_t *src, const uint8_t *topright, int stride){
((uint32_t*)(src+3*stride))[0]= 128U*0x01010101U;
}
+static void pred4x4_127_dc_c(uint8_t *src, const uint8_t *topright, int stride){
+ ((uint32_t*)(src+0*stride))[0]=
+ ((uint32_t*)(src+1*stride))[0]=
+ ((uint32_t*)(src+2*stride))[0]=
+ ((uint32_t*)(src+3*stride))[0]= 127U*0x01010101U;
+}
+
+static void pred4x4_129_dc_c(uint8_t *src, const uint8_t *topright, int stride){
+ ((uint32_t*)(src+0*stride))[0]=
+ ((uint32_t*)(src+1*stride))[0]=
+ ((uint32_t*)(src+2*stride))[0]=
+ ((uint32_t*)(src+3*stride))[0]= 129U*0x01010101U;
+}
+
#define LOAD_TOP_RIGHT_EDGE\
const int av_unused t4= topright[0];\
@@ -547,6 +561,28 @@ static void pred16x16_128_dc_c(uint8_t *src, int stride){
}
}
+static void pred16x16_127_dc_c(uint8_t *src, int stride){
+ int i;
+
+ for(i=0; i<16; i++){
+ ((uint32_t*)(src+i*stride))[0]=
+ ((uint32_t*)(src+i*stride))[1]=
+ ((uint32_t*)(src+i*stride))[2]=
+ ((uint32_t*)(src+i*stride))[3]= 0x01010101U*127U;
+ }
+}
+
+static void pred16x16_129_dc_c(uint8_t *src, int stride){
+ int i;
+
+ for(i=0; i<16; i++){
+ ((uint32_t*)(src+i*stride))[0]=
+ ((uint32_t*)(src+i*stride))[1]=
+ ((uint32_t*)(src+i*stride))[2]=
+ ((uint32_t*)(src+i*stride))[3]= 0x01010101U*129U;
+ }
+}
+
static inline void pred16x16_plane_compat_c(uint8_t *src, int stride, const int svq3, const int rv40){
int i, j, k;
int a;
@@ -658,6 +694,23 @@ static void pred8x8_128_dc_c(uint8_t *src, int stride){
}
}
+static void pred8x8_127_dc_c(uint8_t *src, int stride){
+ int i;
+
+ for(i=0; i<8; i++){
+ ((uint32_t*)(src+i*stride))[0]=
+ ((uint32_t*)(src+i*stride))[1]= 0x01010101U*127U;
+ }
+}
+static void pred8x8_129_dc_c(uint8_t *src, int stride){
+ int i;
+
+ for(i=0; i<8; i++){
+ ((uint32_t*)(src+i*stride))[0]=
+ ((uint32_t*)(src+i*stride))[1]= 0x01010101U*129U;
+ }
+}
+
static void pred8x8_left_dc_c(uint8_t *src, int stride){
int i;
int dc0, dc2;
@@ -1210,11 +1263,17 @@ void ff_h264_pred_init(H264PredContext *h, int codec_id){
} else
h->pred4x4[VERT_LEFT_PRED ]= pred4x4_vertical_left_c;
h->pred4x4[HOR_UP_PRED ]= pred4x4_horizontal_up_c;
- h->pred4x4[LEFT_DC_PRED ]= pred4x4_left_dc_c;
- h->pred4x4[TOP_DC_PRED ]= pred4x4_top_dc_c;
- h->pred4x4[DC_128_PRED ]= pred4x4_128_dc_c;
- if(codec_id == CODEC_ID_VP8)
+ if(codec_id != CODEC_ID_VP8) {
+ h->pred4x4[LEFT_DC_PRED ]= pred4x4_left_dc_c;
+ h->pred4x4[TOP_DC_PRED ]= pred4x4_top_dc_c;
+ h->pred4x4[DC_128_PRED ]= pred4x4_128_dc_c;
+ } else {
h->pred4x4[TM_VP8_PRED ]= pred4x4_tm_vp8_c;
+ h->pred4x4[DC_127_PRED ]= pred4x4_127_dc_c;
+ h->pred4x4[DC_129_PRED ]= pred4x4_129_dc_c;
+ h->pred4x4[VERT_VP8_PRED ]= pred4x4_vertical_c;
+ h->pred4x4[HOR_VP8_PRED ]= pred4x4_horizontal_c;
+ }
}else{
h->pred4x4[VERT_PRED ]= pred4x4_vertical_c;
h->pred4x4[HOR_PRED ]= pred4x4_horizontal_c;
@@ -1264,13 +1323,16 @@ void ff_h264_pred_init(H264PredContext *h, int codec_id){
h->pred8x8[DC_PRED8x8 ]= pred8x8_dc_rv40_c;
h->pred8x8[LEFT_DC_PRED8x8]= pred8x8_left_dc_rv40_c;
h->pred8x8[TOP_DC_PRED8x8 ]= pred8x8_top_dc_rv40_c;
+ if (codec_id == CODEC_ID_VP8) {
+ h->pred8x8[DC_127_PRED8x8]= pred8x8_127_dc_c;
+ h->pred8x8[DC_129_PRED8x8]= pred8x8_129_dc_c;
+ }
}
h->pred8x8[DC_128_PRED8x8 ]= pred8x8_128_dc_c;
h->pred16x16[DC_PRED8x8 ]= pred16x16_dc_c;
h->pred16x16[VERT_PRED8x8 ]= pred16x16_vertical_c;
h->pred16x16[HOR_PRED8x8 ]= pred16x16_horizontal_c;
- h->pred16x16[PLANE_PRED8x8 ]= pred16x16_plane_c;
switch(codec_id){
case CODEC_ID_SVQ3:
h->pred16x16[PLANE_PRED8x8 ]= pred16x16_plane_svq3_c;
@@ -1280,9 +1342,12 @@ void ff_h264_pred_init(H264PredContext *h, int codec_id){
break;
case CODEC_ID_VP8:
h->pred16x16[PLANE_PRED8x8 ]= pred16x16_tm_vp8_c;
+ h->pred16x16[DC_127_PRED8x8]= pred16x16_127_dc_c;
+ h->pred16x16[DC_129_PRED8x8]= pred16x16_129_dc_c;
break;
default:
h->pred16x16[PLANE_PRED8x8 ]= pred16x16_plane_c;
+ break;
}
h->pred16x16[LEFT_DC_PRED8x8]= pred16x16_left_dc_c;
h->pred16x16[TOP_DC_PRED8x8 ]= pred16x16_top_dc_c;
diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/h264pred.h b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/h264pred.h
index 9ac1fec8b..5a3199798 100644
--- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/h264pred.h
+++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/h264pred.h
@@ -45,29 +45,45 @@
#define VERT_LEFT_PRED 7
#define HOR_UP_PRED 8
+// DC edge (not for VP8)
#define LEFT_DC_PRED 9
#define TOP_DC_PRED 10
#define DC_128_PRED 11
-#define TM_VP8_PRED 9 ///< "True Motion", used instead of plane
-
+// RV40 specific
#define DIAG_DOWN_LEFT_PRED_RV40_NODOWN 12
#define HOR_UP_PRED_RV40_NODOWN 13
#define VERT_LEFT_PRED_RV40_NODOWN 14
+// VP8 specific
+#define TM_VP8_PRED 9 ///< "True Motion", used instead of plane
+#define VERT_VP8_PRED 10 ///< for VP8, #VERT_PRED is the average of
+ ///< (left col+cur col x2+right col) / 4;
+ ///< this is the "unaveraged" one
+#define HOR_VP8_PRED 11 ///< unaveraged version of #HOR_PRED, see
+ ///< #VERT_VP8_PRED for details
+#define DC_127_PRED 12
+#define DC_129_PRED 13
+
#define DC_PRED8x8 0
#define HOR_PRED8x8 1
#define VERT_PRED8x8 2
#define PLANE_PRED8x8 3
+// DC edge
#define LEFT_DC_PRED8x8 4
#define TOP_DC_PRED8x8 5
#define DC_128_PRED8x8 6
+// H264/SVQ3 (8x8) specific
#define ALZHEIMER_DC_L0T_PRED8x8 7
#define ALZHEIMER_DC_0LT_PRED8x8 8
#define ALZHEIMER_DC_L00_PRED8x8 9
#define ALZHEIMER_DC_0L0_PRED8x8 10
+
+// VP8 specific
+#define DC_127_PRED8x8 7
+#define DC_129_PRED8x8 8
//@}
/**
@@ -77,7 +93,7 @@ typedef struct H264PredContext{
void (*pred4x4 [9+3+3])(uint8_t *src, const uint8_t *topright, int stride);//FIXME move to dsp?
void (*pred8x8l [9+3])(uint8_t *src, int topleft, int topright, int stride);
void (*pred8x8 [4+3+4])(uint8_t *src, int stride);
- void (*pred16x16[4+3])(uint8_t *src, int stride);
+ void (*pred16x16[4+3+2])(uint8_t *src, int stride);
void (*pred4x4_add [2])(uint8_t *pix/*align 4*/, const DCTELEM *block/*align 16*/, int stride);
void (*pred8x8l_add [2])(uint8_t *pix/*align 8*/, const DCTELEM *block/*align 16*/, int stride);
diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/intelh263dec.c b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/intelh263dec.c
index 4f95fc1f1..b865b94b7 100644
--- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/intelh263dec.c
+++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/intelh263dec.c
@@ -46,7 +46,7 @@ int ff_intel_h263_decode_picture_header(MpegEncContext *s)
skip_bits1(&s->gb); /* freeze picture release off */
format = get_bits(&s->gb, 3);
- if (format != 7) {
+ if (format == 0 || format == 6) {
av_log(s->avctx, AV_LOG_ERROR, "Intel H263 free format not supported\n");
return -1;
}
@@ -64,7 +64,12 @@ int ff_intel_h263_decode_picture_header(MpegEncContext *s)
s->obmc= get_bits1(&s->gb);
s->pb_frame = get_bits1(&s->gb);
- if(format == 7){
+ if (format < 6) {
+ s->width = h263_format[format][0];
+ s->height = h263_format[format][1];
+ s->avctx->sample_aspect_ratio.num=12;s->avctx->sample_aspect_ratio.den=11;
+ }
+ else {
format = get_bits(&s->gb, 3);
if(format == 0 || format == 7){
av_log(s->avctx, AV_LOG_ERROR, "Wrong Intel H263 format\n");
@@ -88,9 +93,14 @@ int ff_intel_h263_decode_picture_header(MpegEncContext *s)
skip_bits1(&s->gb);
skip_bits(&s->gb, 9); // display height
if(ar == 15){
- skip_bits(&s->gb, 8); // aspect ratio - width
- skip_bits(&s->gb, 8); // aspect ratio - height
+ s->avctx->sample_aspect_ratio.num = get_bits(&s->gb, 8); // aspect ratio - width
+ s->avctx->sample_aspect_ratio.den = get_bits(&s->gb, 8); // aspect ratio - height
+ }
+ else {
+ s->avctx->sample_aspect_ratio = ff_h263_pixel_aspect[ar];
}
+ if(s->avctx->sample_aspect_ratio.num == 0)
+ av_log(s->avctx, AV_LOG_ERROR, "Invalid aspect ratio\n");
}
s->chroma_qscale= s->qscale = get_bits(&s->gb, 5);
diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/mpeg12.c b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/mpeg12.c
index 6aab625c8..a5b68515a 100644
--- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/mpeg12.c
+++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/mpeg12.c
@@ -135,6 +135,9 @@ void ff_mpeg1_clean_buffers(MpegEncContext *s){
/******************************************/
/* decoding */
+VLC ff_dc_lum_vlc;
+VLC ff_dc_chroma_vlc;
+
static VLC mv_vlc;
static VLC mbincr_vlc;
static VLC mb_ptype_vlc;
@@ -148,10 +151,10 @@ av_cold void ff_mpeg12_init_vlcs(void)
if (!done) {
done = 1;
- INIT_VLC_STATIC(&dc_lum_vlc, DC_VLC_BITS, 12,
+ INIT_VLC_STATIC(&ff_dc_lum_vlc, DC_VLC_BITS, 12,
ff_mpeg12_vlc_dc_lum_bits, 1, 1,
ff_mpeg12_vlc_dc_lum_code, 2, 2, 512);
- INIT_VLC_STATIC(&dc_chroma_vlc, DC_VLC_BITS, 12,
+ INIT_VLC_STATIC(&ff_dc_chroma_vlc, DC_VLC_BITS, 12,
ff_mpeg12_vlc_dc_chroma_bits, 1, 1,
ff_mpeg12_vlc_dc_chroma_code, 2, 2, 514);
INIT_VLC_STATIC(&mv_vlc, MV_VLC_BITS, 17,
diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/mpeg12.h b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/mpeg12.h
index 30bb675d3..541b66bd9 100644
--- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/mpeg12.h
+++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/mpeg12.h
@@ -27,8 +27,8 @@
#define DC_VLC_BITS 9
#define TEX_VLC_BITS 9
-static VLC dc_lum_vlc;
-static VLC dc_chroma_vlc;
+extern VLC ff_dc_lum_vlc;
+extern VLC ff_dc_chroma_vlc;
extern uint8_t ff_mpeg12_static_rl_table_store[2][2][2*MAX_RUN + MAX_LEVEL + 3];
@@ -40,9 +40,9 @@ static inline int decode_dc(GetBitContext *gb, int component)
int code, diff;
if (component == 0) {
- code = get_vlc2(gb, dc_lum_vlc.table, DC_VLC_BITS, 2);
+ code = get_vlc2(gb, ff_dc_lum_vlc.table, DC_VLC_BITS, 2);
} else {
- code = get_vlc2(gb, dc_chroma_vlc.table, DC_VLC_BITS, 2);
+ code = get_vlc2(gb, ff_dc_chroma_vlc.table, DC_VLC_BITS, 2);
}
if (code < 0){
av_log(NULL, AV_LOG_ERROR, "invalid dc code at\n");
diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/mpeg4videodec.c b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/mpeg4videodec.c
index 539d3a451..1263ef141 100644
--- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/mpeg4videodec.c
+++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/mpeg4videodec.c
@@ -1575,6 +1575,7 @@ static int decode_vol_header(MpegEncContext *s, GetBitContext *gb){
s->avctx->time_base.den = get_bits(gb, 16);
if(!s->avctx->time_base.den){
av_log(s->avctx, AV_LOG_ERROR, "time_base.den==0\n");
+ s->avctx->time_base.num = 0;
return -1;
}
diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/mpegvideo.c b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/mpegvideo.c
index 65b8f9c9d..110e5c739 100644
--- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/mpegvideo.c
+++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/mpegvideo.c
@@ -950,13 +950,11 @@ int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
s->current_picture_ptr= pic;
//FIXME use only the vars from current_pic
+ s->current_picture_ptr->top_field_first= s->top_field_first;
if(s->codec_id == CODEC_ID_MPEG1VIDEO || s->codec_id == CODEC_ID_MPEG2VIDEO) {
- if(s->picture_structure == PICT_FRAME)
- s->current_picture_ptr->top_field_first= s->top_field_first;
- else
+ if(s->picture_structure != PICT_FRAME)
s->current_picture_ptr->top_field_first= (s->picture_structure == PICT_TOP_FIELD) == s->first_field;
- } else
- s->current_picture_ptr->top_field_first= s->top_field_first;
+ }
s->current_picture_ptr->interlaced_frame= !s->progressive_frame && !s->progressive_sequence;
}
diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/utils.c b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/utils.c
index 588b81aac..06ffd6b8c 100644
--- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/utils.c
+++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/utils.c
@@ -74,19 +74,6 @@ void av_fast_malloc(void *ptr, unsigned int *size, FF_INTERNALC_MEM_TYPE min_siz
*size= min_size;
}
-/* ffdshow custom code (begin) */
-static unsigned int last_static = 0;
-static void** array_static = NULL;
-
-void av_free_static(void)
-{
- while(last_static){
- av_freep(&array_static[--last_static]);
- }
- av_freep(&array_static);
-}
-/* ffdshow custom code (end) */
-
/* encoder management */
static AVCodec *first_avcodec = NULL;
@@ -182,8 +169,9 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, int l
*width = FFALIGN(*width , w_align);
*height= FFALIGN(*height, h_align);
- if(s->codec_id == CODEC_ID_H264)
+ if(s->codec_id == CODEC_ID_H264 || s->lowres)
*height+=2; // some of the optimized chroma MC reads one line too much
+ // which is also done in mpeg decoders with lowres > 0
linesize_align[0] =
linesize_align[1] =
diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp8.c b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp8.c
index de97489a8..1abf500c7 100644
--- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp8.c
+++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/vp8.c
@@ -983,14 +983,91 @@ void xchg_mb_border(uint8_t *top_border, uint8_t *src_y, uint8_t *src_cb, uint8_
}
static av_always_inline
-int check_intra_pred_mode(int mode, int mb_x, int mb_y)
+int check_dc_pred8x8_mode(int mode, int mb_x, int mb_y)
+{
+ if (!mb_x) {
+ return mb_y ? TOP_DC_PRED8x8 : DC_128_PRED8x8;
+ } else {
+ return mb_y ? mode : LEFT_DC_PRED8x8;
+ }
+}
+
+static av_always_inline
+int check_tm_pred8x8_mode(int mode, int mb_x, int mb_y)
+{
+ if (!mb_x) {
+ return mb_y ? VERT_PRED8x8 : DC_129_PRED8x8;
+ } else {
+ return mb_y ? mode : HOR_PRED8x8;
+ }
+}
+
+static av_always_inline
+int check_intra_pred8x8_mode(int mode, int mb_x, int mb_y)
{
if (mode == DC_PRED8x8) {
- if (!mb_x) {
- mode = mb_y ? TOP_DC_PRED8x8 : DC_128_PRED8x8;
- } else if (!mb_y) {
- mode = LEFT_DC_PRED8x8;
+ return check_dc_pred8x8_mode(mode, mb_x, mb_y);
+ } else {
+ return mode;
+ }
+}
+
+static av_always_inline
+int check_intra_pred8x8_mode_emuedge(int mode, int mb_x, int mb_y)
+{
+ switch (mode) {
+ case DC_PRED8x8:
+ return check_dc_pred8x8_mode(mode, mb_x, mb_y);
+ case VERT_PRED8x8:
+ return !mb_y ? DC_127_PRED8x8 : mode;
+ case HOR_PRED8x8:
+ return !mb_x ? DC_129_PRED8x8 : mode;
+ case PLANE_PRED8x8 /*TM*/:
+ return check_tm_pred8x8_mode(mode, mb_x, mb_y);
+ }
+ return mode;
+}
+
+static av_always_inline
+int check_tm_pred4x4_mode(int mode, int mb_x, int mb_y)
+{
+ if (!mb_x) {
+ return mb_y ? VERT_VP8_PRED : DC_129_PRED;
+ } else {
+ return mb_y ? mode : HOR_VP8_PRED;
+ }
+}
+
+static av_always_inline
+int check_intra_pred4x4_mode_emuedge(int mode, int mb_x, int mb_y, int *copy_buf)
+{
+ switch (mode) {
+ case VERT_PRED:
+ if (!mb_x && mb_y) {
+ *copy_buf = 1;
+ return mode;
+ }
+ /* fall-through */
+ case DIAG_DOWN_LEFT_PRED:
+ case VERT_LEFT_PRED:
+ return !mb_y ? DC_127_PRED : mode;
+ case HOR_PRED:
+ if (!mb_y) {
+ *copy_buf = 1;
+ return mode;
}
+ /* fall-through */
+ case HOR_UP_PRED:
+ return !mb_x ? DC_129_PRED : mode;
+ case TM_VP8_PRED:
+ return check_tm_pred4x4_mode(mode, mb_x, mb_y);
+ case DC_PRED: // 4x4 DC doesn't use the same "H.264-style" exceptions as 16x16/8x8 DC
+ case DIAG_DOWN_RIGHT_PRED:
+ case VERT_RIGHT_PRED:
+ case HOR_DOWN_PRED:
+ if (!mb_y || !mb_x)
+ *copy_buf = 1;
+ return mode;
}
return mode;
}
@@ -999,21 +1076,27 @@ static av_always_inline
void intra_predict(VP8Context *s, uint8_t *dst[3], VP8Macroblock *mb,
int mb_x, int mb_y)
{
+ AVCodecContext *avctx = s->avctx;
int x, y, mode, nnz, tr;
// for the first row, we need to run xchg_mb_border to init the top edge to 127
// otherwise, skip it if we aren't going to deblock
- if (s->deblock_filter || !mb_y)
+ if (!(avctx->flags & CODEC_FLAG_EMU_EDGE && !mb_y) && (s->deblock_filter || !mb_y))
xchg_mb_border(s->top_border[mb_x+1], dst[0], dst[1], dst[2],
s->linesize, s->uvlinesize, mb_x, mb_y, s->mb_width,
s->filter.simple, 1);
if (mb->mode < MODE_I4x4) {
- mode = check_intra_pred_mode(mb->mode, mb_x, mb_y);
+ if (avctx->flags & CODEC_FLAG_EMU_EDGE) { // tested
+ mode = check_intra_pred8x8_mode_emuedge(mb->mode, mb_x, mb_y);
+ } else {
+ mode = check_intra_pred8x8_mode(mb->mode, mb_x, mb_y);
+ }
s->hpc.pred16x16[mode](dst[0], s->linesize);
} else {
uint8_t *ptr = dst[0];
uint8_t *intra4x4 = s->intra4x4_pred_mode_mb;
+ uint8_t tr_top[4] = { 127, 127, 127, 127 };
// all blocks on the right edge of the macroblock use bottom edge
// the top macroblock for their topright edge
@@ -1021,7 +1104,8 @@ void intra_predict(VP8Context *s, uint8_t *dst[3], VP8Macroblock *mb,
// if we're on the right edge of the frame, said edge is extended
// from the top macroblock
- if (mb_x == s->mb_width-1) {
+ if (!(!mb_y && avctx->flags & CODEC_FLAG_EMU_EDGE) &&
+ mb_x == s->mb_width-1) {
tr = tr_right[-1]*0x01010101;
tr_right = (uint8_t *)&tr;
}
@@ -1032,10 +1116,53 @@ void intra_predict(VP8Context *s, uint8_t *dst[3], VP8Macroblock *mb,
for (y = 0; y < 4; y++) {
uint8_t *topright = ptr + 4 - s->linesize;
for (x = 0; x < 4; x++) {
- if (x == 3)
+ int copy = 0, linesize = s->linesize;
+ uint8_t *dst = ptr+4*x;
+ DECLARE_ALIGNED(4, uint8_t, copy_dst)[5*8];
+
+ if ((y == 0 || x == 3) && mb_y == 0 && avctx->flags & CODEC_FLAG_EMU_EDGE) {
+ topright = tr_top;
+ } else if (x == 3)
topright = tr_right;
- s->hpc.pred4x4[intra4x4[x]](ptr+4*x, topright, s->linesize);
+ if (avctx->flags & CODEC_FLAG_EMU_EDGE) { // mb_x+x or mb_y+y is a hack but works
+ mode = check_intra_pred4x4_mode_emuedge(intra4x4[x], mb_x + x, mb_y + y, &copy);
+ if (copy) {
+ dst = copy_dst + 12;
+ linesize = 8;
+ if (!(mb_y + y)) {
+ copy_dst[3] = 127U;
+ * (uint32_t *) (copy_dst + 4) = 127U * 0x01010101U;
+ } else {
+ * (uint32_t *) (copy_dst + 4) = * (uint32_t *) (ptr+4*x-s->linesize);
+ if (!(mb_x + x)) {
+ copy_dst[3] = 129U;
+ } else {
+ copy_dst[3] = ptr[4*x-s->linesize-1];
+ }
+ }
+ if (!(mb_x + x)) {
+ copy_dst[11] =
+ copy_dst[19] =
+ copy_dst[27] =
+ copy_dst[35] = 129U;
+ } else {
+ copy_dst[11] = ptr[4*x -1];
+ copy_dst[19] = ptr[4*x+s->linesize -1];
+ copy_dst[27] = ptr[4*x+s->linesize*2-1];
+ copy_dst[35] = ptr[4*x+s->linesize*3-1];
+ }
+ }
+ } else {
+ mode = intra4x4[x];
+ }
+ s->hpc.pred4x4[mode](dst, topright, linesize);
+ if (copy) {
+ * (uint32_t *) (ptr+4*x) = * (uint32_t *) (copy_dst + 12);
+ * (uint32_t *) (ptr+4*x+s->linesize) = * (uint32_t *) (copy_dst + 20);
+ * (uint32_t *) (ptr+4*x+s->linesize*2) = * (uint32_t *) (copy_dst + 28);
+ * (uint32_t *) (ptr+4*x+s->linesize*3) = * (uint32_t *) (copy_dst + 36);
+ }
nnz = s->non_zero_count_cache[y][x];
if (nnz) {
@@ -1052,11 +1179,15 @@ void intra_predict(VP8Context *s, uint8_t *dst[3], VP8Macroblock *mb,
}
}
- mode = check_intra_pred_mode(s->chroma_pred_mode, mb_x, mb_y);
+ if (avctx->flags & CODEC_FLAG_EMU_EDGE) {
+ mode = check_intra_pred8x8_mode_emuedge(s->chroma_pred_mode, mb_x, mb_y);
+ } else {
+ mode = check_intra_pred8x8_mode(s->chroma_pred_mode, mb_x, mb_y);
+ }
s->hpc.pred8x8[mode](dst[1], s->uvlinesize);
s->hpc.pred8x8[mode](dst[2], s->uvlinesize);
- if (s->deblock_filter || !mb_y)
+ if (!(avctx->flags & CODEC_FLAG_EMU_EDGE && !mb_y) && (s->deblock_filter || !mb_y))
xchg_mb_border(s->top_border[mb_x+1], dst[0], dst[1], dst[2],
s->linesize, s->uvlinesize, mb_x, mb_y, s->mb_width,
s->filter.simple, 0);
@@ -1533,7 +1664,10 @@ static int vp8_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
memset(s->macroblocks + s->mb_height*2 - 1, 0, (s->mb_width+1)*sizeof(*s->macroblocks));
// top edge of 127 for intra prediction
- memset(s->top_border, 127, (s->mb_width+1)*sizeof(*s->top_border));
+ if (!(avctx->flags & CODEC_FLAG_EMU_EDGE)) {
+ s->top_border[0][15] = s->top_border[0][23] = 127;
+ memset(s->top_border[1]-1, 127, s->mb_width*sizeof(*s->top_border)+1);
+ }
memset(s->ref_count, 0, sizeof(s->ref_count));
if (s->keyframe)
memset(s->intra4x4_pred_mode_top, DC_PRED, s->mb_width*4);
@@ -1553,12 +1687,13 @@ static int vp8_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
AV_WN32A(s->intra4x4_pred_mode_left, DC_PRED*0x01010101);
// left edge of 129 for intra prediction
- if (!(avctx->flags & CODEC_FLAG_EMU_EDGE))
+ if (!(avctx->flags & CODEC_FLAG_EMU_EDGE)) {
for (i = 0; i < 3; i++)
for (y = 0; y < 16>>!!i; y++)
dst[i][y*curframe->linesize[i]-1] = 129;
- if (mb_y)
- memset(s->top_border, 129, sizeof(*s->top_border));
+ if (mb_y == 1) // top left edge is also 129
+ s->top_border[0][15] = s->top_border[0][23] = s->top_border[0][31] = 129;
+ }
for (mb_x = 0; mb_x < s->mb_width; mb_x++, mb_xy++, mb++) {
/* Prefetch the current frame, 4 MBs ahead */
@@ -1658,12 +1793,6 @@ static av_cold int vp8_decode_init(AVCodecContext *avctx)
ff_h264_pred_init(&s->hpc, CODEC_ID_VP8);
ff_vp8dsp_init(&s->vp8dsp);
- // intra pred needs edge emulation among other things
- if (avctx->flags&CODEC_FLAG_EMU_EDGE) {
- av_log(avctx, AV_LOG_ERROR, "Edge emulation not supported\n");
- return AVERROR_PATCHWELCOME;
- }
-
return 0;
}
diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/wmv2dec.c b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/wmv2dec.c
index 407b9355b..75592f5ef 100644
--- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/wmv2dec.c
+++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/wmv2dec.c
@@ -87,7 +87,7 @@ static int decode_ext_header(Wmv2Context *w){
if(s->avctx->extradata_size<4) return -1;
- init_get_bits(&gb, s->avctx->extradata, s->avctx->extradata_size*8);
+ init_get_bits(&gb, s->avctx->extradata, 32);
fps = get_bits(&gb, 5);
s->bit_rate = get_bits(&gb, 11)*1024;
diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/config.asm b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/config.asm
index 8efc2c533..8a9faa117 100644
--- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/config.asm
+++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/config.asm
@@ -1 +1,2 @@
-%define ARCH_X86
+%define ARCH_X86 1
+%define CONFIG_GPL 1
diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/dsputil_mmx.c b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/dsputil_mmx.c
index 8c19b170d..1a6675f0b 100644
--- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/dsputil_mmx.c
+++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/dsputil_mmx.c
@@ -41,7 +41,7 @@ DECLARE_ALIGNED(8, const uint64_t, ff_wtwo) = 0x0002000200020002ULL;
DECLARE_ALIGNED(16, const uint64_t, ff_pdw_80000000)[2] =
{0x8000000080000000ULL, 0x8000000080000000ULL};
-DECLARE_ALIGNED(8, const uint64_t, ff_pw_3 ) = 0x0003000300030003ULL;
+DECLARE_ALIGNED(8, const xmm_reg, ff_pw_3 ) = {0x0003000300030003ULL, 0x0003000300030003ULL};
DECLARE_ALIGNED(16, const xmm_reg, ff_pw_4 ) = {0x0004000400040004ULL, 0x0004000400040004ULL};
DECLARE_ALIGNED(16, const xmm_reg, ff_pw_5 ) = {0x0005000500050005ULL, 0x0005000500050005ULL};
DECLARE_ALIGNED(16, const xmm_reg, ff_pw_8 ) = {0x0008000800080008ULL, 0x0008000800080008ULL};
diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/dsputil_mmx.h b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/dsputil_mmx.h
index 58256fd40..3259bb4c0 100644
--- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/dsputil_mmx.h
+++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/dsputil_mmx.h
@@ -24,6 +24,7 @@
#include <stdint.h>
#include "libavcodec/dsputil.h"
+#include "libavutil/x86_cpu.h"
typedef struct { uint64_t a, b; } xmm_reg;
@@ -32,7 +33,7 @@ extern const uint64_t ff_wtwo;
extern const uint64_t ff_pdw_80000000[2];
-extern const uint64_t ff_pw_3;
+extern const xmm_reg ff_pw_3;
extern const xmm_reg ff_pw_4;
extern const xmm_reg ff_pw_5;
extern const xmm_reg ff_pw_8;
@@ -94,32 +95,31 @@ extern const double ff_pd_2[2];
SBUTTERFLY(a,c,d,dq,q) /* a=aeim d=bfjn */\
SBUTTERFLY(t,b,c,dq,q) /* t=cgko c=dhlp */
-static inline void transpose4x4(uint8_t *dst, uint8_t *src, int dst_stride, int src_stride){
+static inline void transpose4x4(uint8_t *dst, uint8_t *src, x86_reg dst_stride, x86_reg src_stride){
__asm__ volatile( //FIXME could save 1 instruction if done as 8x4 ...
- "movd %4, %%mm0 \n\t"
- "movd %5, %%mm1 \n\t"
- "movd %6, %%mm2 \n\t"
- "movd %7, %%mm3 \n\t"
+ "movd (%1), %%mm0 \n\t"
+ "add %3, %1 \n\t"
+ "movd (%1), %%mm1 \n\t"
+ "movd (%1,%3,1), %%mm2 \n\t"
+ "movd (%1,%3,2), %%mm3 \n\t"
"punpcklbw %%mm1, %%mm0 \n\t"
"punpcklbw %%mm3, %%mm2 \n\t"
"movq %%mm0, %%mm1 \n\t"
"punpcklwd %%mm2, %%mm0 \n\t"
"punpckhwd %%mm2, %%mm1 \n\t"
- "movd %%mm0, %0 \n\t"
+ "movd %%mm0, (%0) \n\t"
+ "add %2, %0 \n\t"
"punpckhdq %%mm0, %%mm0 \n\t"
- "movd %%mm0, %1 \n\t"
- "movd %%mm1, %2 \n\t"
+ "movd %%mm0, (%0) \n\t"
+ "movd %%mm1, (%0,%2,1) \n\t"
"punpckhdq %%mm1, %%mm1 \n\t"
- "movd %%mm1, %3 \n\t"
-
- : "=m" (*(uint32_t*)(dst + 0*dst_stride)),
- "=m" (*(uint32_t*)(dst + 1*dst_stride)),
- "=m" (*(uint32_t*)(dst + 2*dst_stride)),
- "=m" (*(uint32_t*)(dst + 3*dst_stride))
- : "m" (*(uint32_t*)(src + 0*src_stride)),
- "m" (*(uint32_t*)(src + 1*src_stride)),
- "m" (*(uint32_t*)(src + 2*src_stride)),
- "m" (*(uint32_t*)(src + 3*src_stride))
+ "movd %%mm1, (%0,%2,2) \n\t"
+
+ : "+&r" (dst),
+ "+&r" (src)
+ : "r" (dst_stride),
+ "r" (src_stride)
+ : "memory"
);
}
diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/h264_chromamc.asm b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/h264_chromamc.asm
index 6df82cc52..3bb5ed485 100644
--- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/h264_chromamc.asm
+++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/h264_chromamc.asm
@@ -530,9 +530,8 @@ cglobal %1_%2_chroma_mc8_%3, 6, 7, 8
add r4, 8
sub r4, r5 ; 255*x+8 = x<<8 | (8-x)
movd m7, r4d
- movq m6, [rnd_1d_%2]
+ movdqa m6, [rnd_1d_%2]
pshuflw m7, m7, 0
- movlhps m6, m6
movlhps m7, m7
.next2xrows
@@ -568,9 +567,8 @@ cglobal %1_%2_chroma_mc8_%3, 6, 7, 8
add r5, 8
sub r5, r4 ; 255*y+8 = y<<8 | (8-y)
movd m7, r5d
- movq m6, [rnd_1d_%2]
+ movdqa m6, [rnd_1d_%2]
pshuflw m7, m7, 0
- movlhps m6, m6
movlhps m7, m7
.next2yrows
diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/h264_intrapred.asm b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/h264_intrapred.asm
index 7d3ef9555..52e691df8 100644
--- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/h264_intrapred.asm
+++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/h264_intrapred.asm
@@ -1,6 +1,9 @@
;******************************************************************************
;* H.264 intra prediction asm optimizations
;* Copyright (c) 2010 Jason Garrett-Glaser
+;* Copyright (c) 2010 Holger Lubitz
+;* Copyright (c) 2010 Loren Merritt
+;* Copyright (c) 2010 Ronald S. Bultje
;*
;* This file is part of FFmpeg.
;*
@@ -20,10 +23,12 @@
;******************************************************************************
%include "x86inc.asm"
+%include "x86util.asm"
SECTION_RODATA
tm_shuf: times 8 db 0x03, 0x80
+pw_ff00: times 8 dw 0xff00
plane_shuf: db -8, -7, -6, -5, -4, -3, -2, -1
db 1, 2, 3, 4, 5, 6, 7, 8
plane8_shuf: db -4, -3, -2, -1, 0, 0, 0, 0
@@ -37,7 +42,9 @@ SECTION .text
cextern pb_1
cextern pb_3
+cextern pw_4
cextern pw_5
+cextern pw_8
cextern pw_16
cextern pw_17
cextern pw_32
@@ -828,6 +835,102 @@ PRED8x8_H mmxext
PRED8x8_H ssse3
;-----------------------------------------------------------------------------
+; void pred8x8_top_dc_mmxext(uint8_t *src, int stride)
+;-----------------------------------------------------------------------------
+%ifdef CONFIG_GPL
+cglobal pred8x8_top_dc_mmxext, 2,5
+ sub r0, r1
+ movq mm0, [r0]
+ pxor mm1, mm1
+ pxor mm2, mm2
+ lea r2, [r0+r1*2]
+ punpckhbw mm1, mm0
+ punpcklbw mm0, mm2
+ psadbw mm1, mm2 ; s1
+ lea r3, [r2+r1*2]
+ psadbw mm0, mm2 ; s0
+ psrlw mm1, 1
+ psrlw mm0, 1
+ pavgw mm1, mm2
+ lea r4, [r3+r1*2]
+ pavgw mm0, mm2
+ pshufw mm1, mm1, 0
+ pshufw mm0, mm0, 0 ; dc0 (w)
+ packuswb mm0, mm1 ; dc0,dc1 (b)
+ movq [r0+r1*1], mm0
+ movq [r0+r1*2], mm0
+ lea r0, [r3+r1*2]
+ movq [r2+r1*1], mm0
+ movq [r2+r1*2], mm0
+ movq [r3+r1*1], mm0
+ movq [r3+r1*2], mm0
+ movq [r0+r1*1], mm0
+ movq [r0+r1*2], mm0
+ RET
+
+;-----------------------------------------------------------------------------
+; void pred8x8_dc_mmxext(uint8_t *src, int stride)
+;-----------------------------------------------------------------------------
+
+INIT_MMX
+cglobal pred8x8_dc_mmxext, 2,5
+ sub r0, r1
+ pxor m7, m7
+ movd m0, [r0+0]
+ movd m1, [r0+4]
+ psadbw m0, m7 ; s0
+ mov r4, r0
+ psadbw m1, m7 ; s1
+
+ movzx r2d, byte [r0+r1*1-1]
+ movzx r3d, byte [r0+r1*2-1]
+ lea r0, [r0+r1*2]
+ add r2d, r3d
+ movzx r3d, byte [r0+r1*1-1]
+ add r2d, r3d
+ movzx r3d, byte [r0+r1*2-1]
+ add r2d, r3d
+ lea r0, [r0+r1*2]
+ movd m2, r2d ; s2
+ movzx r2d, byte [r0+r1*1-1]
+ movzx r3d, byte [r0+r1*2-1]
+ lea r0, [r0+r1*2]
+ add r2d, r3d
+ movzx r3d, byte [r0+r1*1-1]
+ add r2d, r3d
+ movzx r3d, byte [r0+r1*2-1]
+ add r2d, r3d
+ movd m3, r2d ; s3
+
+ punpcklwd m0, m1
+ mov r0, r4
+ punpcklwd m2, m3
+ punpckldq m0, m2 ; s0, s1, s2, s3
+ pshufw m3, m0, 11110110b ; s2, s1, s3, s3
+ lea r2, [r0+r1*2]
+ pshufw m0, m0, 01110100b ; s0, s1, s3, s1
+ paddw m0, m3
+ lea r3, [r2+r1*2]
+ psrlw m0, 2
+ pavgw m0, m7 ; s0+s2, s1, s3, s1+s3
+ lea r4, [r3+r1*2]
+ packuswb m0, m0
+ punpcklbw m0, m0
+ movq m1, m0
+ punpcklbw m0, m0
+ punpckhbw m1, m1
+ movq [r0+r1*1], m0
+ movq [r0+r1*2], m0
+ movq [r2+r1*1], m0
+ movq [r2+r1*2], m0
+ movq [r3+r1*1], m1
+ movq [r3+r1*2], m1
+ movq [r4+r1*1], m1
+ movq [r4+r1*2], m1
+ RET
+%endif
+
+;-----------------------------------------------------------------------------
; void pred8x8_dc_rv40(uint8_t *src, int stride)
;-----------------------------------------------------------------------------
@@ -966,6 +1069,1428 @@ cglobal pred8x8_tm_vp8_ssse3, 2,3,6
jg .loop
REP_RET
+; dest, left, right, src, tmp
+; output: %1 = (t[n-1] + t[n]*2 + t[n+1] + 2) >> 2
+%macro PRED4x4_LOWPASS 5
+ mova %5, %2
+ pavgb %2, %3
+ pxor %3, %5
+ mova %1, %4
+ pand %3, [pb_1]
+ psubusb %2, %3
+ pavgb %1, %2
+%endmacro
+
+;-----------------------------------------------------------------------------
+; void pred8x8l_top_dc(uint8_t *src, int has_topleft, int has_topright, int stride)
+;-----------------------------------------------------------------------------
+%ifdef CONFIG_GPL
+%macro PRED8x8L_TOP_DC 1
+cglobal pred8x8l_top_dc_%1, 4,4
+ sub r0, r3
+ pxor mm7, mm7
+ movq mm0, [r0-8]
+ movq mm3, [r0]
+ movq mm1, [r0+8]
+ movq mm2, mm3
+ movq mm4, mm3
+ PALIGNR mm2, mm0, 7, mm0
+ PALIGNR mm1, mm4, 1, mm4
+ test r1, r1 ; top_left
+ jz .fix_lt_2
+ test r2, r2 ; top_right
+ jz .fix_tr_1
+ jmp .body
+.fix_lt_2:
+ movq mm5, mm3
+ pxor mm5, mm2
+ psllq mm5, 56
+ psrlq mm5, 56
+ pxor mm2, mm5
+ test r2, r2 ; top_right
+ jnz .body
+.fix_tr_1:
+ movq mm5, mm3
+ pxor mm5, mm1
+ psrlq mm5, 56
+ psllq mm5, 56
+ pxor mm1, mm5
+.body
+ PRED4x4_LOWPASS mm0, mm2, mm1, mm3, mm5
+ psadbw mm7, mm0
+ paddw mm7, [pw_4]
+ psrlw mm7, 3
+ pshufw mm7, mm7, 0
+ packuswb mm7, mm7
+%rep 3
+ movq [r0+r3*1], mm7
+ movq [r0+r3*2], mm7
+ lea r0, [r0+r3*2]
+%endrep
+ movq [r0+r3*1], mm7
+ movq [r0+r3*2], mm7
+ RET
+%endmacro
+
+INIT_MMX
+%define PALIGNR PALIGNR_MMX
+PRED8x8L_TOP_DC mmxext
+%define PALIGNR PALIGNR_SSSE3
+PRED8x8L_TOP_DC ssse3
+
+;-----------------------------------------------------------------------------
+;void pred8x8l_dc(uint8_t *src, int has_topleft, int has_topright, int stride)
+;-----------------------------------------------------------------------------
+
+%macro PRED8x8L_DC 1
+cglobal pred8x8l_dc_%1, 4,5
+ sub r0, r3
+ lea r4, [r0+r3*2]
+ movq mm0, [r0+r3*1-8]
+ punpckhbw mm0, [r0+r3*0-8]
+ movq mm1, [r4+r3*1-8]
+ punpckhbw mm1, [r0+r3*2-8]
+ mov r4, r0
+ punpckhwd mm1, mm0
+ lea r0, [r0+r3*4]
+ movq mm2, [r0+r3*1-8]
+ punpckhbw mm2, [r0+r3*0-8]
+ lea r0, [r0+r3*2]
+ movq mm3, [r0+r3*1-8]
+ punpckhbw mm3, [r0+r3*0-8]
+ punpckhwd mm3, mm2
+ punpckhdq mm3, mm1
+ lea r0, [r0+r3*2]
+ movq mm0, [r0+r3*0-8]
+ movq mm1, [r4]
+ mov r0, r4
+ movq mm4, mm3
+ movq mm2, mm3
+ PALIGNR mm4, mm0, 7, mm0
+ PALIGNR mm1, mm2, 1, mm2
+ test r1, r1
+ jnz .do_left
+.fix_lt_1:
+ movq mm5, mm3
+ pxor mm5, mm4
+ psrlq mm5, 56
+ psllq mm5, 48
+ pxor mm1, mm5
+ jmp .do_left
+.fix_lt_2:
+ movq mm5, mm3
+ pxor mm5, mm2
+ psllq mm5, 56
+ psrlq mm5, 56
+ pxor mm2, mm5
+ test r2, r2
+ jnz .body
+.fix_tr_1:
+ movq mm5, mm3
+ pxor mm5, mm1
+ psrlq mm5, 56
+ psllq mm5, 56
+ pxor mm1, mm5
+ jmp .body
+.do_left:
+ movq mm0, mm4
+ PRED4x4_LOWPASS mm2, mm1, mm4, mm3, mm5
+ movq mm4, mm0
+ movq mm7, mm2
+ PRED4x4_LOWPASS mm1, mm3, mm0, mm4, mm5
+ psllq mm1, 56
+ PALIGNR mm7, mm1, 7, mm3
+ movq mm0, [r0-8]
+ movq mm3, [r0]
+ movq mm1, [r0+8]
+ movq mm2, mm3
+ movq mm4, mm3
+ PALIGNR mm2, mm0, 7, mm0
+ PALIGNR mm1, mm4, 1, mm4
+ test r1, r1
+ jz .fix_lt_2
+ test r2, r2
+ jz .fix_tr_1
+.body
+ lea r1, [r0+r3*2]
+ PRED4x4_LOWPASS mm6, mm2, mm1, mm3, mm5
+ pxor mm0, mm0
+ pxor mm1, mm1
+ lea r2, [r1+r3*2]
+ psadbw mm0, mm7
+ psadbw mm1, mm6
+ paddw mm0, [pw_8]
+ paddw mm0, mm1
+ lea r4, [r2+r3*2]
+ psrlw mm0, 4
+ pshufw mm0, mm0, 0
+ packuswb mm0, mm0
+ movq [r0+r3*1], mm0
+ movq [r0+r3*2], mm0
+ movq [r1+r3*1], mm0
+ movq [r1+r3*2], mm0
+ movq [r2+r3*1], mm0
+ movq [r2+r3*2], mm0
+ movq [r4+r3*1], mm0
+ movq [r4+r3*2], mm0
+ RET
+%endmacro
+INIT_MMX
+%define PALIGNR PALIGNR_MMX
+PRED8x8L_DC mmxext
+%define PALIGNR PALIGNR_SSSE3
+PRED8x8L_DC ssse3
+
+;-----------------------------------------------------------------------------
+; void pred8x8l_horizontal(uint8_t *src, int has_topleft, int has_topright, int stride)
+;-----------------------------------------------------------------------------
+
+%macro PRED8x8L_HORIZONTAL 1
+cglobal pred8x8l_horizontal_%1, 4,4
+ sub r0, r3
+ lea r2, [r0+r3*2]
+ movq mm0, [r0+r3*1-8]
+ punpckhbw mm0, [r0+r3*0-8]
+ movq mm1, [r2+r3*1-8]
+ punpckhbw mm1, [r0+r3*2-8]
+ mov r2, r0
+ punpckhwd mm1, mm0
+ lea r0, [r0+r3*4]
+ movq mm2, [r0+r3*1-8]
+ punpckhbw mm2, [r0+r3*0-8]
+ lea r0, [r0+r3*2]
+ movq mm3, [r0+r3*1-8]
+ punpckhbw mm3, [r0+r3*0-8]
+ punpckhwd mm3, mm2
+ punpckhdq mm3, mm1
+ lea r0, [r0+r3*2]
+ movq mm0, [r0+r3*0-8]
+ movq mm1, [r2]
+ mov r0, r2
+ movq mm4, mm3
+ movq mm2, mm3
+ PALIGNR mm4, mm0, 7, mm0
+ PALIGNR mm1, mm2, 1, mm2
+ test r1, r1 ; top_left
+ jnz .do_left
+.fix_lt_1:
+ movq mm5, mm3
+ pxor mm5, mm4
+ psrlq mm5, 56
+ psllq mm5, 48
+ pxor mm1, mm5
+.do_left:
+ movq mm0, mm4
+ PRED4x4_LOWPASS mm2, mm1, mm4, mm3, mm5
+ movq mm4, mm0
+ movq mm7, mm2
+ PRED4x4_LOWPASS mm1, mm3, mm0, mm4, mm5
+ psllq mm1, 56
+ PALIGNR mm7, mm1, 7, mm3
+ movq mm3, mm7
+ lea r1, [r0+r3*2]
+ movq mm7, mm3
+ punpckhbw mm3, mm3
+ punpcklbw mm7, mm7
+ pshufw mm0, mm3, 0xff
+ pshufw mm1, mm3, 0xaa
+ lea r2, [r1+r3*2]
+ pshufw mm2, mm3, 0x55
+ pshufw mm3, mm3, 0x00
+ pshufw mm4, mm7, 0xff
+ pshufw mm5, mm7, 0xaa
+ pshufw mm6, mm7, 0x55
+ pshufw mm7, mm7, 0x00
+ movq [r0+r3*1], mm0
+ movq [r0+r3*2], mm1
+ movq [r1+r3*1], mm2
+ movq [r1+r3*2], mm3
+ movq [r2+r3*1], mm4
+ movq [r2+r3*2], mm5
+ lea r0, [r2+r3*2]
+ movq [r0+r3*1], mm6
+ movq [r0+r3*2], mm7
+ RET
+%endmacro
+
+INIT_MMX
+%define PALIGNR PALIGNR_MMX
+PRED8x8L_HORIZONTAL mmxext
+%define PALIGNR PALIGNR_SSSE3
+PRED8x8L_HORIZONTAL ssse3
+
+;-----------------------------------------------------------------------------
+; void pred8x8l_vertical(uint8_t *src, int has_topleft, int has_topright, int stride)
+;-----------------------------------------------------------------------------
+
+%macro PRED8x8L_VERTICAL 1
+cglobal pred8x8l_vertical_%1, 4,4
+ sub r0, r3
+ movq mm0, [r0-8]
+ movq mm3, [r0]
+ movq mm1, [r0+8]
+ movq mm2, mm3
+ movq mm4, mm3
+ PALIGNR mm2, mm0, 7, mm0
+ PALIGNR mm1, mm4, 1, mm4
+ test r1, r1 ; top_left
+ jz .fix_lt_2
+ test r2, r2 ; top_right
+ jz .fix_tr_1
+ jmp .body
+.fix_lt_2:
+ movq mm5, mm3
+ pxor mm5, mm2
+ psllq mm5, 56
+ psrlq mm5, 56
+ pxor mm2, mm5
+ test r2, r2 ; top_right
+ jnz .body
+.fix_tr_1:
+ movq mm5, mm3
+ pxor mm5, mm1
+ psrlq mm5, 56
+ psllq mm5, 56
+ pxor mm1, mm5
+.body
+ PRED4x4_LOWPASS mm0, mm2, mm1, mm3, mm5
+%rep 3
+ movq [r0+r3*1], mm0
+ movq [r0+r3*2], mm0
+ lea r0, [r0+r3*2]
+%endrep
+ movq [r0+r3*1], mm0
+ movq [r0+r3*2], mm0
+ RET
+%endmacro
+
+INIT_MMX
+%define PALIGNR PALIGNR_MMX
+PRED8x8L_VERTICAL mmxext
+%define PALIGNR PALIGNR_SSSE3
+PRED8x8L_VERTICAL ssse3
+
+;-----------------------------------------------------------------------------
+;void pred8x8l_down_left(uint8_t *src, int has_topleft, int has_topright, int stride)
+;-----------------------------------------------------------------------------
+
+INIT_MMX
+%define PALIGNR PALIGNR_MMX
+cglobal pred8x8l_down_left_mmxext, 4,5
+ sub r0, r3
+ movq mm0, [r0-8]
+ movq mm3, [r0]
+ movq mm1, [r0+8]
+ movq mm2, mm3
+ movq mm4, mm3
+ PALIGNR mm2, mm0, 7, mm0
+ PALIGNR mm1, mm4, 1, mm4
+ test r1, r1
+ jz .fix_lt_2
+ test r2, r2
+ jz .fix_tr_1
+ jmp .do_top
+.fix_lt_2:
+ movq mm5, mm3
+ pxor mm5, mm2
+ psllq mm5, 56
+ psrlq mm5, 56
+ pxor mm2, mm5
+ test r2, r2
+ jnz .do_top
+.fix_tr_1:
+ movq mm5, mm3
+ pxor mm5, mm1
+ psrlq mm5, 56
+ psllq mm5, 56
+ pxor mm1, mm5
+ jmp .do_top
+.fix_tr_2:
+ punpckhbw mm3, mm3
+ pshufw mm1, mm3, 0xFF
+ jmp .do_topright
+.do_top:
+ PRED4x4_LOWPASS mm4, mm2, mm1, mm3, mm5
+ movq mm7, mm4
+ test r2, r2
+ jz .fix_tr_2
+ movq mm0, [r0+8]
+ movq mm5, mm0
+ movq mm2, mm0
+ movq mm4, mm0
+ psrlq mm5, 56
+ PALIGNR mm2, mm3, 7, mm3
+ PALIGNR mm5, mm4, 1, mm4
+ PRED4x4_LOWPASS mm1, mm2, mm5, mm0, mm4
+.do_topright:
+ lea r1, [r0+r3*2]
+ movq mm6, mm1
+ psrlq mm1, 56
+ movq mm4, mm1
+ lea r2, [r1+r3*2]
+ movq mm2, mm6
+ PALIGNR mm2, mm7, 1, mm0
+ movq mm3, mm6
+ PALIGNR mm3, mm7, 7, mm0
+ PALIGNR mm4, mm6, 1, mm0
+ movq mm5, mm7
+ movq mm1, mm7
+ movq mm7, mm6
+ lea r4, [r2+r3*2]
+ psllq mm1, 8
+ PRED4x4_LOWPASS mm0, mm1, mm2, mm5, mm6
+ PRED4x4_LOWPASS mm1, mm3, mm4, mm7, mm6
+ movq [r4+r3*2], mm1
+ movq mm2, mm0
+ psllq mm1, 8
+ psrlq mm2, 56
+ psllq mm0, 8
+ por mm1, mm2
+ movq [r4+r3*1], mm1
+ movq mm2, mm0
+ psllq mm1, 8
+ psrlq mm2, 56
+ psllq mm0, 8
+ por mm1, mm2
+ movq [r2+r3*2], mm1
+ movq mm2, mm0
+ psllq mm1, 8
+ psrlq mm2, 56
+ psllq mm0, 8
+ por mm1, mm2
+ movq [r2+r3*1], mm1
+ movq mm2, mm0
+ psllq mm1, 8
+ psrlq mm2, 56
+ psllq mm0, 8
+ por mm1, mm2
+ movq [r1+r3*2], mm1
+ movq mm2, mm0
+ psllq mm1, 8
+ psrlq mm2, 56
+ psllq mm0, 8
+ por mm1, mm2
+ movq [r1+r3*1], mm1
+ movq mm2, mm0
+ psllq mm1, 8
+ psrlq mm2, 56
+ psllq mm0, 8
+ por mm1, mm2
+ movq [r0+r3*2], mm1
+ psllq mm1, 8
+ psrlq mm0, 56
+ por mm1, mm0
+ movq [r0+r3*1], mm1
+ RET
+
+%macro PRED8x8L_DOWN_LEFT 1
+cglobal pred8x8l_down_left_%1, 4,4
+ sub r0, r3
+ movq mm0, [r0-8]
+ movq mm3, [r0]
+ movq mm1, [r0+8]
+ movq mm2, mm3
+ movq mm4, mm3
+ PALIGNR mm2, mm0, 7, mm0
+ PALIGNR mm1, mm4, 1, mm4
+ test r1, r1 ; top_left
+ jz .fix_lt_2
+ test r2, r2 ; top_right
+ jz .fix_tr_1
+ jmp .do_top
+.fix_lt_2:
+ movq mm5, mm3
+ pxor mm5, mm2
+ psllq mm5, 56
+ psrlq mm5, 56
+ pxor mm2, mm5
+ test r2, r2 ; top_right
+ jnz .do_top
+.fix_tr_1:
+ movq mm5, mm3
+ pxor mm5, mm1
+ psrlq mm5, 56
+ psllq mm5, 56
+ pxor mm1, mm5
+ jmp .do_top
+.fix_tr_2:
+ punpckhbw mm3, mm3
+ pshufw mm1, mm3, 0xFF
+ jmp .do_topright
+.do_top:
+ PRED4x4_LOWPASS mm4, mm2, mm1, mm3, mm5
+ movq2dq xmm3, mm4
+ test r2, r2 ; top_right
+ jz .fix_tr_2
+ movq mm0, [r0+8]
+ movq mm5, mm0
+ movq mm2, mm0
+ movq mm4, mm0
+ psrlq mm5, 56
+ PALIGNR mm2, mm3, 7, mm3
+ PALIGNR mm5, mm4, 1, mm4
+ PRED4x4_LOWPASS mm1, mm2, mm5, mm0, mm4
+.do_topright:
+ movq2dq xmm4, mm1
+ psrlq mm1, 56
+ movq2dq xmm5, mm1
+ lea r1, [r0+r3*2]
+ pslldq xmm4, 8
+ por xmm3, xmm4
+ movdqa xmm2, xmm3
+ psrldq xmm2, 1
+ pslldq xmm5, 15
+ por xmm2, xmm5
+ lea r2, [r1+r3*2]
+ movdqa xmm1, xmm3
+ pslldq xmm1, 1
+INIT_XMM
+ PRED4x4_LOWPASS xmm0, xmm1, xmm2, xmm3, xmm4
+ psrldq xmm0, 1
+ movq [r0+r3*1], xmm0
+ psrldq xmm0, 1
+ movq [r0+r3*2], xmm0
+ psrldq xmm0, 1
+ lea r0, [r2+r3*2]
+ movq [r1+r3*1], xmm0
+ psrldq xmm0, 1
+ movq [r1+r3*2], xmm0
+ psrldq xmm0, 1
+ movq [r2+r3*1], xmm0
+ psrldq xmm0, 1
+ movq [r2+r3*2], xmm0
+ psrldq xmm0, 1
+ movq [r0+r3*1], xmm0
+ psrldq xmm0, 1
+ movq [r0+r3*2], xmm0
+ RET
+%endmacro
+
+INIT_MMX
+%define PALIGNR PALIGNR_MMX
+PRED8x8L_DOWN_LEFT sse2
+INIT_MMX
+%define PALIGNR PALIGNR_SSSE3
+PRED8x8L_DOWN_LEFT ssse3
+
+;-----------------------------------------------------------------------------
+;void pred8x8l_down_right_mmxext(uint8_t *src, int has_topleft, int has_topright, int stride)
+;-----------------------------------------------------------------------------
+
+INIT_MMX
+%define PALIGNR PALIGNR_MMX
+cglobal pred8x8l_down_right_mmxext, 4,5
+ sub r0, r3
+ lea r4, [r0+r3*2]
+ movq mm0, [r0+r3*1-8]
+ punpckhbw mm0, [r0+r3*0-8]
+ movq mm1, [r4+r3*1-8]
+ punpckhbw mm1, [r0+r3*2-8]
+ mov r4, r0
+ punpckhwd mm1, mm0
+ lea r0, [r0+r3*4]
+ movq mm2, [r0+r3*1-8]
+ punpckhbw mm2, [r0+r3*0-8]
+ lea r0, [r0+r3*2]
+ movq mm3, [r0+r3*1-8]
+ punpckhbw mm3, [r0+r3*0-8]
+ punpckhwd mm3, mm2
+ punpckhdq mm3, mm1
+ lea r0, [r0+r3*2]
+ movq mm0, [r0+r3*0-8]
+ movq mm1, [r4]
+ mov r0, r4
+ movq mm4, mm3
+ movq mm2, mm3
+ PALIGNR mm4, mm0, 7, mm0
+ PALIGNR mm1, mm2, 1, mm2
+ test r1, r1 ; top_left
+ jz .fix_lt_1
+.do_left:
+ movq mm0, mm4
+ PRED4x4_LOWPASS mm2, mm1, mm4, mm3, mm5
+ movq mm4, mm0
+ movq mm7, mm2
+ movq mm6, mm2
+ PRED4x4_LOWPASS mm1, mm3, mm0, mm4, mm5
+ psllq mm1, 56
+ PALIGNR mm7, mm1, 7, mm3
+ movq mm0, [r0-8]
+ movq mm3, [r0]
+ movq mm1, [r0+8]
+ movq mm2, mm3
+ movq mm4, mm3
+ PALIGNR mm2, mm0, 7, mm0
+ PALIGNR mm1, mm4, 1, mm4
+ test r1, r1 ; top_left
+ jz .fix_lt_2
+ test r2, r2 ; top_right
+ jz .fix_tr_1
+.do_top:
+ PRED4x4_LOWPASS mm4, mm2, mm1, mm3, mm5
+ movq mm5, mm4
+ jmp .body
+.fix_lt_1:
+ movq mm5, mm3
+ pxor mm5, mm4
+ psrlq mm5, 56
+ psllq mm5, 48
+ pxor mm1, mm5
+ jmp .do_left
+.fix_lt_2:
+ movq mm5, mm3
+ pxor mm5, mm2
+ psllq mm5, 56
+ psrlq mm5, 56
+ pxor mm2, mm5
+ test r2, r2 ; top_right
+ jnz .do_top
+.fix_tr_1:
+ movq mm5, mm3
+ pxor mm5, mm1
+ psrlq mm5, 56
+ psllq mm5, 56
+ pxor mm1, mm5
+ jmp .do_top
+.body
+ lea r1, [r0+r3*2]
+ movq mm1, mm7
+ movq mm7, mm5
+ movq mm5, mm6
+ movq mm2, mm7
+ lea r2, [r1+r3*2]
+ PALIGNR mm2, mm6, 1, mm0
+ movq mm3, mm7
+ PALIGNR mm3, mm6, 7, mm0
+ movq mm4, mm7
+ lea r4, [r2+r3*2]
+ psrlq mm4, 8
+ PRED4x4_LOWPASS mm0, mm1, mm2, mm5, mm6
+ PRED4x4_LOWPASS mm1, mm3, mm4, mm7, mm6
+ movq [r4+r3*2], mm0
+ movq mm2, mm1
+ psrlq mm0, 8
+ psllq mm2, 56
+ psrlq mm1, 8
+ por mm0, mm2
+ movq [r4+r3*1], mm0
+ movq mm2, mm1
+ psrlq mm0, 8
+ psllq mm2, 56
+ psrlq mm1, 8
+ por mm0, mm2
+ movq [r2+r3*2], mm0
+ movq mm2, mm1
+ psrlq mm0, 8
+ psllq mm2, 56
+ psrlq mm1, 8
+ por mm0, mm2
+ movq [r2+r3*1], mm0
+ movq mm2, mm1
+ psrlq mm0, 8
+ psllq mm2, 56
+ psrlq mm1, 8
+ por mm0, mm2
+ movq [r1+r3*2], mm0
+ movq mm2, mm1
+ psrlq mm0, 8
+ psllq mm2, 56
+ psrlq mm1, 8
+ por mm0, mm2
+ movq [r1+r3*1], mm0
+ movq mm2, mm1
+ psrlq mm0, 8
+ psllq mm2, 56
+ psrlq mm1, 8
+ por mm0, mm2
+ movq [r0+r3*2], mm0
+ psrlq mm0, 8
+ psllq mm1, 56
+ por mm0, mm1
+ movq [r0+r3*1], mm0
+ RET
+
+%macro PRED8x8L_DOWN_RIGHT 1
+cglobal pred8x8l_down_right_%1, 4,5
+ sub r0, r3
+ lea r4, [r0+r3*2]
+ movq mm0, [r0+r3*1-8]
+ punpckhbw mm0, [r0+r3*0-8]
+ movq mm1, [r4+r3*1-8]
+ punpckhbw mm1, [r0+r3*2-8]
+ mov r4, r0
+ punpckhwd mm1, mm0
+ lea r0, [r0+r3*4]
+ movq mm2, [r0+r3*1-8]
+ punpckhbw mm2, [r0+r3*0-8]
+ lea r0, [r0+r3*2]
+ movq mm3, [r0+r3*1-8]
+ punpckhbw mm3, [r0+r3*0-8]
+ punpckhwd mm3, mm2
+ punpckhdq mm3, mm1
+ lea r0, [r0+r3*2]
+ movq mm0, [r0+r3*0-8]
+ movq mm1, [r4]
+ mov r0, r4
+ movq mm4, mm3
+ movq mm2, mm3
+ PALIGNR mm4, mm0, 7, mm0
+ PALIGNR mm1, mm2, 1, mm2
+ test r1, r1
+ jz .fix_lt_1
+ jmp .do_left
+.fix_lt_1:
+ movq mm5, mm3
+ pxor mm5, mm4
+ psrlq mm5, 56
+ psllq mm5, 48
+ pxor mm1, mm5
+ jmp .do_left
+.fix_lt_2:
+ movq mm5, mm3
+ pxor mm5, mm2
+ psllq mm5, 56
+ psrlq mm5, 56
+ pxor mm2, mm5
+ test r2, r2
+ jnz .do_top
+.fix_tr_1:
+ movq mm5, mm3
+ pxor mm5, mm1
+ psrlq mm5, 56
+ psllq mm5, 56
+ pxor mm1, mm5
+ jmp .do_top
+.do_left:
+ movq mm0, mm4
+ PRED4x4_LOWPASS mm2, mm1, mm4, mm3, mm5
+ movq mm4, mm0
+ movq mm7, mm2
+ movq2dq xmm3, mm2
+ PRED4x4_LOWPASS mm1, mm3, mm0, mm4, mm5
+ psllq mm1, 56
+ PALIGNR mm7, mm1, 7, mm3
+ movq2dq xmm1, mm7
+ movq mm0, [r0-8]
+ movq mm3, [r0]
+ movq mm1, [r0+8]
+ movq mm2, mm3
+ movq mm4, mm3
+ PALIGNR mm2, mm0, 7, mm0
+ PALIGNR mm1, mm4, 1, mm4
+ test r1, r1
+ jz .fix_lt_2
+ test r2, r2
+ jz .fix_tr_1
+.do_top:
+ PRED4x4_LOWPASS mm4, mm2, mm1, mm3, mm5
+ movq2dq xmm4, mm4
+ lea r1, [r0+r3*2]
+ movdqa xmm0, xmm3
+ pslldq xmm4, 8
+ por xmm3, xmm4
+ lea r2, [r1+r3*2]
+ pslldq xmm4, 1
+ por xmm1, xmm4
+ psrldq xmm0, 7
+ pslldq xmm0, 15
+ psrldq xmm0, 7
+ por xmm1, xmm0
+ lea r0, [r2+r3*2]
+ movdqa xmm2, xmm3
+ psrldq xmm2, 1
+INIT_XMM
+ PRED4x4_LOWPASS xmm0, xmm1, xmm2, xmm3, xmm4
+ movdqa xmm1, xmm0
+ psrldq xmm1, 1
+ movq [r0+r3*2], xmm0
+ movq [r0+r3*1], xmm1
+ psrldq xmm0, 2
+ psrldq xmm1, 2
+ movq [r2+r3*2], xmm0
+ movq [r2+r3*1], xmm1
+ psrldq xmm0, 2
+ psrldq xmm1, 2
+ movq [r1+r3*2], xmm0
+ movq [r1+r3*1], xmm1
+ psrldq xmm0, 2
+ psrldq xmm1, 2
+ movq [r4+r3*2], xmm0
+ movq [r4+r3*1], xmm1
+ RET
+%endmacro
+
+INIT_MMX
+%define PALIGNR PALIGNR_MMX
+PRED8x8L_DOWN_RIGHT sse2
+INIT_MMX
+%define PALIGNR PALIGNR_SSSE3
+PRED8x8L_DOWN_RIGHT ssse3
+
+;-----------------------------------------------------------------------------
+; void pred8x8l_vertical_right(uint8_t *src, int has_topleft, int has_topright, int stride)
+;-----------------------------------------------------------------------------
+
+INIT_MMX
+%define PALIGNR PALIGNR_MMX
+cglobal pred8x8l_vertical_right_mmxext, 4,5
+ sub r0, r3
+ lea r4, [r0+r3*2]
+ movq mm0, [r0+r3*1-8]
+ punpckhbw mm0, [r0+r3*0-8]
+ movq mm1, [r4+r3*1-8]
+ punpckhbw mm1, [r0+r3*2-8]
+ mov r4, r0
+ punpckhwd mm1, mm0
+ lea r0, [r0+r3*4]
+ movq mm2, [r0+r3*1-8]
+ punpckhbw mm2, [r0+r3*0-8]
+ lea r0, [r0+r3*2]
+ movq mm3, [r0+r3*1-8]
+ punpckhbw mm3, [r0+r3*0-8]
+ punpckhwd mm3, mm2
+ punpckhdq mm3, mm1
+ lea r0, [r0+r3*2]
+ movq mm0, [r0+r3*0-8]
+ movq mm1, [r4]
+ mov r0, r4
+ movq mm4, mm3
+ movq mm2, mm3
+ PALIGNR mm4, mm0, 7, mm0
+ PALIGNR mm1, mm2, 1, mm2
+ test r1, r1
+ jz .fix_lt_1
+ jmp .do_left
+.fix_lt_1:
+ movq mm5, mm3
+ pxor mm5, mm4
+ psrlq mm5, 56
+ psllq mm5, 48
+ pxor mm1, mm5
+ jmp .do_left
+.fix_lt_2:
+ movq mm5, mm3
+ pxor mm5, mm2
+ psllq mm5, 56
+ psrlq mm5, 56
+ pxor mm2, mm5
+ test r2, r2
+ jnz .do_top
+.fix_tr_1:
+ movq mm5, mm3
+ pxor mm5, mm1
+ psrlq mm5, 56
+ psllq mm5, 56
+ pxor mm1, mm5
+ jmp .do_top
+.do_left:
+ movq mm0, mm4
+ PRED4x4_LOWPASS mm2, mm1, mm4, mm3, mm5
+ movq mm7, mm2
+ movq mm0, [r0-8]
+ movq mm3, [r0]
+ movq mm1, [r0+8]
+ movq mm2, mm3
+ movq mm4, mm3
+ PALIGNR mm2, mm0, 7, mm0
+ PALIGNR mm1, mm4, 1, mm4
+ test r1, r1
+ jz .fix_lt_2
+ test r2, r2
+ jz .fix_tr_1
+.do_top
+ PRED4x4_LOWPASS mm6, mm2, mm1, mm3, mm5
+ lea r1, [r0+r3*2]
+ movq mm2, mm6
+ movq mm3, mm6
+ PALIGNR mm3, mm7, 7, mm0
+ PALIGNR mm6, mm7, 6, mm1
+ movq mm4, mm3
+ pavgb mm3, mm2
+ lea r2, [r1+r3*2]
+ PRED4x4_LOWPASS mm0, mm6, mm2, mm4, mm5
+ movq [r0+r3*1], mm3
+ movq [r0+r3*2], mm0
+ movq mm5, mm0
+ movq mm6, mm3
+ movq mm1, mm7
+ movq mm2, mm1
+ psllq mm2, 8
+ movq mm3, mm1
+ psllq mm3, 16
+ lea r4, [r2+r3*2]
+ PRED4x4_LOWPASS mm0, mm1, mm3, mm2, mm4
+ PALIGNR mm6, mm0, 7, mm2
+ movq [r1+r3*1], mm6
+ psllq mm0, 8
+ PALIGNR mm5, mm0, 7, mm1
+ movq [r1+r3*2], mm5
+ psllq mm0, 8
+ PALIGNR mm6, mm0, 7, mm2
+ movq [r2+r3*1], mm6
+ psllq mm0, 8
+ PALIGNR mm5, mm0, 7, mm1
+ movq [r2+r3*2], mm5
+ psllq mm0, 8
+ PALIGNR mm6, mm0, 7, mm2
+ movq [r4+r3*1], mm6
+ psllq mm0, 8
+ PALIGNR mm5, mm0, 7, mm1
+ movq [r4+r3*2], mm5
+ RET
+
+%macro PRED8x8L_VERTICAL_RIGHT 1
+cglobal pred8x8l_vertical_right_%1, 4,5,7
+ sub r0, r3
+ lea r4, [r0+r3*2]
+ movq mm0, [r0+r3*1-8]
+ punpckhbw mm0, [r0+r3*0-8]
+ movq mm1, [r4+r3*1-8]
+ punpckhbw mm1, [r0+r3*2-8]
+ mov r4, r0
+ punpckhwd mm1, mm0
+ lea r0, [r0+r3*4]
+ movq mm2, [r0+r3*1-8]
+ punpckhbw mm2, [r0+r3*0-8]
+ lea r0, [r0+r3*2]
+ movq mm3, [r0+r3*1-8]
+ punpckhbw mm3, [r0+r3*0-8]
+ punpckhwd mm3, mm2
+ punpckhdq mm3, mm1
+ lea r0, [r0+r3*2]
+ movq mm0, [r0+r3*0-8]
+ movq mm1, [r4]
+ mov r0, r4
+ movq mm4, mm3
+ movq mm2, mm3
+ PALIGNR mm4, mm0, 7, mm0
+ PALIGNR mm1, mm2, 1, mm2
+ test r1, r1
+ jnz .do_left
+.fix_lt_1:
+ movq mm5, mm3
+ pxor mm5, mm4
+ psrlq mm5, 56
+ psllq mm5, 48
+ pxor mm1, mm5
+ jmp .do_left
+.fix_lt_2:
+ movq mm5, mm3
+ pxor mm5, mm2
+ psllq mm5, 56
+ psrlq mm5, 56
+ pxor mm2, mm5
+ test r2, r2
+ jnz .do_top
+.fix_tr_1:
+ movq mm5, mm3
+ pxor mm5, mm1
+ psrlq mm5, 56
+ psllq mm5, 56
+ pxor mm1, mm5
+ jmp .do_top
+.do_left:
+ movq mm0, mm4
+ PRED4x4_LOWPASS mm2, mm1, mm4, mm3, mm5
+ movq2dq xmm0, mm2
+ movq mm0, [r0-8]
+ movq mm3, [r0]
+ movq mm1, [r0+8]
+ movq mm2, mm3
+ movq mm4, mm3
+ PALIGNR mm2, mm0, 7, mm0
+ PALIGNR mm1, mm4, 1, mm4
+ test r1, r1
+ jz .fix_lt_2
+ test r2, r2
+ jz .fix_tr_1
+.do_top
+ PRED4x4_LOWPASS mm6, mm2, mm1, mm3, mm5
+ lea r1, [r0+r3*2]
+ movq2dq xmm4, mm6
+ pslldq xmm4, 8
+ por xmm0, xmm4
+ movdqa xmm6, [pw_ff00]
+ movdqa xmm1, xmm0
+ lea r2, [r1+r3*2]
+ movdqa xmm2, xmm0
+ movdqa xmm3, xmm0
+ pslldq xmm0, 1
+ pslldq xmm1, 2
+ pavgb xmm2, xmm0
+INIT_XMM
+ PRED4x4_LOWPASS xmm4, xmm3, xmm1, xmm0, xmm5
+ pandn xmm6, xmm4
+ movdqa xmm5, xmm4
+ psrlw xmm4, 8
+ packuswb xmm6, xmm4
+ movhlps xmm4, xmm6
+ movhps [r0+r3*2], xmm5
+ movhps [r0+r3*1], xmm2
+ psrldq xmm5, 4
+ movss xmm5, xmm6
+ psrldq xmm2, 4
+ movss xmm2, xmm4
+ lea r0, [r2+r3*2]
+ psrldq xmm5, 1
+ psrldq xmm2, 1
+ movq [r0+r3*2], xmm5
+ movq [r0+r3*1], xmm2
+ psrldq xmm5, 1
+ psrldq xmm2, 1
+ movq [r2+r3*2], xmm5
+ movq [r2+r3*1], xmm2
+ psrldq xmm5, 1
+ psrldq xmm2, 1
+ movq [r1+r3*2], xmm5
+ movq [r1+r3*1], xmm2
+ RET
+%endmacro
+
+INIT_MMX
+%define PALIGNR PALIGNR_MMX
+PRED8x8L_VERTICAL_RIGHT sse2
+INIT_MMX
+%define PALIGNR PALIGNR_SSSE3
+PRED8x8L_VERTICAL_RIGHT ssse3
+
+;-----------------------------------------------------------------------------
+;void pred8x8l_vertical_left(uint8_t *src, int has_topleft, int has_topright, int stride)
+;-----------------------------------------------------------------------------
+
+%macro PRED8x8L_VERTICAL_LEFT 1
+cglobal pred8x8l_vertical_left_%1, 4,4
+ sub r0, r3
+ movq mm0, [r0-8]
+ movq mm3, [r0]
+ movq mm1, [r0+8]
+ movq mm2, mm3
+ movq mm4, mm3
+ PALIGNR mm2, mm0, 7, mm0
+ PALIGNR mm1, mm4, 1, mm4
+ test r1, r1
+ jz .fix_lt_2
+ test r2, r2
+ jz .fix_tr_1
+ jmp .do_top
+.fix_lt_2:
+ movq mm5, mm3
+ pxor mm5, mm2
+ psllq mm5, 56
+ psrlq mm5, 56
+ pxor mm2, mm5
+ test r2, r2
+ jnz .do_top
+.fix_tr_1:
+ movq mm5, mm3
+ pxor mm5, mm1
+ psrlq mm5, 56
+ psllq mm5, 56
+ pxor mm1, mm5
+ jmp .do_top
+.fix_tr_2:
+ punpckhbw mm3, mm3
+ pshufw mm1, mm3, 0xFF
+ jmp .do_topright
+.do_top:
+ PRED4x4_LOWPASS mm4, mm2, mm1, mm3, mm5
+ movq2dq xmm4, mm4
+ test r2, r2
+ jz .fix_tr_2
+ movq mm0, [r0+8]
+ movq mm5, mm0
+ movq mm2, mm0
+ movq mm4, mm0
+ psrlq mm5, 56
+ PALIGNR mm2, mm3, 7, mm3
+ PALIGNR mm5, mm4, 1, mm4
+ PRED4x4_LOWPASS mm1, mm2, mm5, mm0, mm4
+.do_topright:
+ movq2dq xmm3, mm1
+ lea r1, [r0+r3*2]
+ pslldq xmm3, 8
+ por xmm4, xmm3
+ movdqa xmm2, xmm4
+ movdqa xmm1, xmm4
+ movdqa xmm3, xmm4
+ psrldq xmm2, 1
+ pslldq xmm1, 1
+ pavgb xmm3, xmm2
+ lea r2, [r1+r3*2]
+INIT_XMM
+ PRED4x4_LOWPASS xmm0, xmm1, xmm2, xmm4, xmm5
+ psrldq xmm0, 1
+ movq [r0+r3*1], xmm3
+ movq [r0+r3*2], xmm0
+ lea r0, [r2+r3*2]
+ psrldq xmm3, 1
+ psrldq xmm0, 1
+ movq [r1+r3*1], xmm3
+ movq [r1+r3*2], xmm0
+ psrldq xmm3, 1
+ psrldq xmm0, 1
+ movq [r2+r3*1], xmm3
+ movq [r2+r3*2], xmm0
+ psrldq xmm3, 1
+ psrldq xmm0, 1
+ movq [r0+r3*1], xmm3
+ movq [r0+r3*2], xmm0
+ RET
+%endmacro
+
+INIT_MMX
+%define PALIGNR PALIGNR_MMX
+PRED8x8L_VERTICAL_LEFT sse2
+%define PALIGNR PALIGNR_SSSE3
+INIT_MMX
+PRED8x8L_VERTICAL_LEFT ssse3
+
+;-----------------------------------------------------------------------------
+; void pred8x8l_horizontal_up(uint8_t *src, int has_topleft, int has_topright, int stride)
+;-----------------------------------------------------------------------------
+
+%macro PRED8x8L_HORIZONTAL_UP 1
+cglobal pred8x8l_horizontal_up_%1, 4,4
+ sub r0, r3
+ lea r2, [r0+r3*2]
+ movq mm0, [r0+r3*1-8]
+ punpckhbw mm0, [r0+r3*0-8]
+ movq mm1, [r2+r3*1-8]
+ punpckhbw mm1, [r0+r3*2-8]
+ mov r2, r0
+ punpckhwd mm1, mm0
+ lea r0, [r0+r3*4]
+ movq mm2, [r0+r3*1-8]
+ punpckhbw mm2, [r0+r3*0-8]
+ lea r0, [r0+r3*2]
+ movq mm3, [r0+r3*1-8]
+ punpckhbw mm3, [r0+r3*0-8]
+ punpckhwd mm3, mm2
+ punpckhdq mm3, mm1
+ lea r0, [r0+r3*2]
+ movq mm0, [r0+r3*0-8]
+ movq mm1, [r2]
+ mov r0, r2
+ movq mm4, mm3
+ movq mm2, mm3
+ PALIGNR mm4, mm0, 7, mm0
+ PALIGNR mm1, mm2, 1, mm2
+ test r1, r1
+ jnz .do_left
+.fix_lt_1:
+ movq mm5, mm3
+ pxor mm5, mm4
+ psrlq mm5, 56
+ psllq mm5, 48
+ pxor mm1, mm5
+.do_left:
+ movq mm0, mm4
+ PRED4x4_LOWPASS mm2, mm1, mm4, mm3, mm5
+ movq mm4, mm0
+ movq mm7, mm2
+ PRED4x4_LOWPASS mm1, mm3, mm0, mm4, mm5
+ psllq mm1, 56
+ PALIGNR mm7, mm1, 7, mm3
+ lea r1, [r0+r3*2]
+ pshufw mm0, mm7, 00011011b ; l6 l7 l4 l5 l2 l3 l0 l1
+ psllq mm7, 56 ; l7 .. .. .. .. .. .. ..
+ movq mm2, mm0
+ psllw mm0, 8
+ psrlw mm2, 8
+ por mm2, mm0 ; l7 l6 l5 l4 l3 l2 l1 l0
+ movq mm3, mm2
+ movq mm4, mm2
+ movq mm5, mm2
+ psrlq mm2, 8
+ psrlq mm3, 16
+ lea r2, [r1+r3*2]
+ por mm2, mm7 ; l7 l7 l6 l5 l4 l3 l2 l1
+ punpckhbw mm7, mm7
+ por mm3, mm7 ; l7 l7 l7 l6 l5 l4 l3 l2
+ pavgb mm4, mm2
+ PRED4x4_LOWPASS mm1, mm3, mm5, mm2, mm6
+ movq mm5, mm4
+ punpcklbw mm4, mm1 ; p4 p3 p2 p1
+ punpckhbw mm5, mm1 ; p8 p7 p6 p5
+ movq mm6, mm5
+ movq mm7, mm5
+ movq mm0, mm5
+ PALIGNR mm5, mm4, 2, mm1
+ pshufw mm1, mm6, 11111001b
+ PALIGNR mm6, mm4, 4, mm2
+ pshufw mm2, mm7, 11111110b
+ PALIGNR mm7, mm4, 6, mm3
+ pshufw mm3, mm0, 11111111b
+ movq [r0+r3*1], mm4
+ movq [r0+r3*2], mm5
+ lea r0, [r2+r3*2]
+ movq [r1+r3*1], mm6
+ movq [r1+r3*2], mm7
+ movq [r2+r3*1], mm0
+ movq [r2+r3*2], mm1
+ movq [r0+r3*1], mm2
+ movq [r0+r3*2], mm3
+ RET
+%endmacro
+
+INIT_MMX
+%define PALIGNR PALIGNR_MMX
+PRED8x8L_HORIZONTAL_UP mmxext
+%define PALIGNR PALIGNR_SSSE3
+PRED8x8L_HORIZONTAL_UP ssse3
+
+;-----------------------------------------------------------------------------
+;void pred8x8l_horizontal_down(uint8_t *src, int has_topleft, int has_topright, int stride)
+;-----------------------------------------------------------------------------
+
+INIT_MMX
+%define PALIGNR PALIGNR_MMX
+cglobal pred8x8l_horizontal_down_mmxext, 4,5
+ sub r0, r3
+ lea r4, [r0+r3*2]
+ movq mm0, [r0+r3*1-8]
+ punpckhbw mm0, [r0+r3*0-8]
+ movq mm1, [r4+r3*1-8]
+ punpckhbw mm1, [r0+r3*2-8]
+ mov r4, r0
+ punpckhwd mm1, mm0
+ lea r0, [r0+r3*4]
+ movq mm2, [r0+r3*1-8]
+ punpckhbw mm2, [r0+r3*0-8]
+ lea r0, [r0+r3*2]
+ movq mm3, [r0+r3*1-8]
+ punpckhbw mm3, [r0+r3*0-8]
+ punpckhwd mm3, mm2
+ punpckhdq mm3, mm1
+ lea r0, [r0+r3*2]
+ movq mm0, [r0+r3*0-8]
+ movq mm1, [r4]
+ mov r0, r4
+ movq mm4, mm3
+ movq mm2, mm3
+ PALIGNR mm4, mm0, 7, mm0
+ PALIGNR mm1, mm2, 1, mm2
+ test r1, r1
+ jnz .do_left
+.fix_lt_1:
+ movq mm5, mm3
+ pxor mm5, mm4
+ psrlq mm5, 56
+ psllq mm5, 48
+ pxor mm1, mm5
+ jmp .do_left
+.fix_lt_2:
+ movq mm5, mm3
+ pxor mm5, mm2
+ psllq mm5, 56
+ psrlq mm5, 56
+ pxor mm2, mm5
+ test r2, r2
+ jnz .do_top
+.fix_tr_1:
+ movq mm5, mm3
+ pxor mm5, mm1
+ psrlq mm5, 56
+ psllq mm5, 56
+ pxor mm1, mm5
+ jmp .do_top
+.do_left:
+ movq mm0, mm4
+ PRED4x4_LOWPASS mm2, mm1, mm4, mm3, mm5
+ movq mm4, mm0
+ movq mm7, mm2
+ movq mm6, mm2
+ PRED4x4_LOWPASS mm1, mm3, mm0, mm4, mm5
+ psllq mm1, 56
+ PALIGNR mm7, mm1, 7, mm3
+ movq mm0, [r0-8]
+ movq mm3, [r0]
+ movq mm1, [r0+8]
+ movq mm2, mm3
+ movq mm4, mm3
+ PALIGNR mm2, mm0, 7, mm0
+ PALIGNR mm1, mm4, 1, mm4
+ test r1, r1
+ jz .fix_lt_2
+ test r2, r2
+ jz .fix_tr_1
+.do_top:
+ PRED4x4_LOWPASS mm4, mm2, mm1, mm3, mm5
+ movq mm5, mm4
+ lea r1, [r0+r3*2]
+ psllq mm7, 56
+ movq mm2, mm5
+ movq mm3, mm6
+ movq mm4, mm2
+ PALIGNR mm2, mm6, 7, mm5
+ PALIGNR mm6, mm7, 7, mm0
+ lea r2, [r1+r3*2]
+ PALIGNR mm4, mm3, 1, mm7
+ movq mm5, mm3
+ pavgb mm3, mm6
+ PRED4x4_LOWPASS mm0, mm4, mm6, mm5, mm7
+ movq mm4, mm2
+ movq mm1, mm2
+ lea r4, [r2+r3*2]
+ psrlq mm4, 16
+ psrlq mm1, 8
+ PRED4x4_LOWPASS mm6, mm4, mm2, mm1, mm5
+ movq mm7, mm3
+ punpcklbw mm3, mm0
+ punpckhbw mm7, mm0
+ movq mm1, mm7
+ movq mm0, mm7
+ movq mm4, mm7
+ movq [r4+r3*2], mm3
+ PALIGNR mm7, mm3, 2, mm5
+ movq [r4+r3*1], mm7
+ PALIGNR mm1, mm3, 4, mm5
+ movq [r2+r3*2], mm1
+ PALIGNR mm0, mm3, 6, mm3
+ movq [r2+r3*1], mm0
+ movq mm2, mm6
+ movq mm3, mm6
+ movq [r1+r3*2], mm4
+ PALIGNR mm6, mm4, 2, mm5
+ movq [r1+r3*1], mm6
+ PALIGNR mm2, mm4, 4, mm5
+ movq [r0+r3*2], mm2
+ PALIGNR mm3, mm4, 6, mm4
+ movq [r0+r3*1], mm3
+ RET
+
+%macro PRED8x8L_HORIZONTAL_DOWN 1
+cglobal pred8x8l_horizontal_down_%1, 4,5
+ sub r0, r3
+ lea r4, [r0+r3*2]
+ movq mm0, [r0+r3*1-8]
+ punpckhbw mm0, [r0+r3*0-8]
+ movq mm1, [r4+r3*1-8]
+ punpckhbw mm1, [r0+r3*2-8]
+ mov r4, r0
+ punpckhwd mm1, mm0
+ lea r0, [r0+r3*4]
+ movq mm2, [r0+r3*1-8]
+ punpckhbw mm2, [r0+r3*0-8]
+ lea r0, [r0+r3*2]
+ movq mm3, [r0+r3*1-8]
+ punpckhbw mm3, [r0+r3*0-8]
+ punpckhwd mm3, mm2
+ punpckhdq mm3, mm1
+ lea r0, [r0+r3*2]
+ movq mm0, [r0+r3*0-8]
+ movq mm1, [r4]
+ mov r0, r4
+ movq mm4, mm3
+ movq mm2, mm3
+ PALIGNR mm4, mm0, 7, mm0
+ PALIGNR mm1, mm2, 1, mm2
+ test r1, r1
+ jnz .do_left
+.fix_lt_1:
+ movq mm5, mm3
+ pxor mm5, mm4
+ psrlq mm5, 56
+ psllq mm5, 48
+ pxor mm1, mm5
+ jmp .do_left
+.fix_lt_2:
+ movq mm5, mm3
+ pxor mm5, mm2
+ psllq mm5, 56
+ psrlq mm5, 56
+ pxor mm2, mm5
+ test r2, r2
+ jnz .do_top
+.fix_tr_1:
+ movq mm5, mm3
+ pxor mm5, mm1
+ psrlq mm5, 56
+ psllq mm5, 56
+ pxor mm1, mm5
+ jmp .do_top
+.fix_tr_2:
+ punpckhbw mm3, mm3
+ pshufw mm1, mm3, 0xFF
+ jmp .do_topright
+.do_left:
+ movq mm0, mm4
+ PRED4x4_LOWPASS mm2, mm1, mm4, mm3, mm5
+ movq2dq xmm0, mm2
+ pslldq xmm0, 8
+ movq mm4, mm0
+ PRED4x4_LOWPASS mm1, mm3, mm0, mm4, mm5
+ movq2dq xmm2, mm1
+ pslldq xmm2, 15
+ psrldq xmm2, 8
+ por xmm0, xmm2
+ movq mm0, [r0-8]
+ movq mm3, [r0]
+ movq mm1, [r0+8]
+ movq mm2, mm3
+ movq mm4, mm3
+ PALIGNR mm2, mm0, 7, mm0
+ PALIGNR mm1, mm4, 1, mm4
+ test r1, r1
+ jz .fix_lt_2
+ test r2, r2
+ jz .fix_tr_1
+.do_top:
+ PRED4x4_LOWPASS mm4, mm2, mm1, mm3, mm5
+ movq2dq xmm1, mm4
+ test r2, r2
+ jz .fix_tr_2
+ movq mm0, [r0+8]
+ movq mm5, mm0
+ movq mm2, mm0
+ movq mm4, mm0
+ psrlq mm5, 56
+ PALIGNR mm2, mm3, 7, mm3
+ PALIGNR mm5, mm4, 1, mm4
+ PRED4x4_LOWPASS mm1, mm2, mm5, mm0, mm4
+.do_topright:
+ movq2dq xmm5, mm1
+ pslldq xmm5, 8
+ por xmm1, xmm5
+INIT_XMM
+ lea r2, [r4+r3*2]
+ movdqa xmm2, xmm1
+ movdqa xmm3, xmm1
+ PALIGNR xmm1, xmm0, 7, xmm4
+ PALIGNR xmm2, xmm0, 9, xmm5
+ lea r1, [r2+r3*2]
+ PALIGNR xmm3, xmm0, 8, xmm0
+ movdqa xmm4, xmm1
+ pavgb xmm4, xmm3
+ lea r0, [r1+r3*2]
+ PRED4x4_LOWPASS xmm0, xmm1, xmm2, xmm3, xmm5
+ punpcklbw xmm4, xmm0
+ movhlps xmm0, xmm4
+ movq [r0+r3*2], xmm4
+ movq [r2+r3*2], xmm0
+ psrldq xmm4, 2
+ psrldq xmm0, 2
+ movq [r0+r3*1], xmm4
+ movq [r2+r3*1], xmm0
+ psrldq xmm4, 2
+ psrldq xmm0, 2
+ movq [r1+r3*2], xmm4
+ movq [r4+r3*2], xmm0
+ psrldq xmm4, 2
+ psrldq xmm0, 2
+ movq [r1+r3*1], xmm4
+ movq [r4+r3*1], xmm0
+ RET
+%endmacro
+
+INIT_MMX
+%define PALIGNR PALIGNR_MMX
+PRED8x8L_HORIZONTAL_DOWN sse2
+INIT_MMX
+%define PALIGNR PALIGNR_SSSE3
+PRED8x8L_HORIZONTAL_DOWN ssse3
+%endif
+
;-----------------------------------------------------------------------------
; void pred4x4_dc_mmxext(uint8_t *src, const uint8_t *topright, int stride)
;-----------------------------------------------------------------------------
@@ -1073,18 +2598,6 @@ cglobal pred4x4_tm_vp8_ssse3, 3,3
movd [r1+r2*2], mm5
RET
-; dest, left, right, src, tmp
-; output: %1 = (t[n-1] + t[n]*2 + t[n+1] + 2) >> 2
-%macro PRED4x4_LOWPASS 5
- mova %5, %2
- pavgb %2, %3
- pxor %3, %5
- mova %1, %4
- pand %3, [pb_1]
- psubusb %2, %3
- pavgb %1, %2
-%endmacro
-
;-----------------------------------------------------------------------------
; void pred4x4_vertical_vp8_mmxext(uint8_t *src, const uint8_t *topright, int stride)
;-----------------------------------------------------------------------------
@@ -1104,3 +2617,186 @@ cglobal pred4x4_vertical_vp8_mmxext, 3,3
movd [r1+r2*1], m3
movd [r1+r2*2], m3
RET
+
+;-----------------------------------------------------------------------------
+; void pred4x4_down_left_mmxext(uint8_t *src, const uint8_t *topright, int stride)
+;-----------------------------------------------------------------------------
+%ifdef CONFIG_GPL
+INIT_MMX
+cglobal pred4x4_down_left_mmxext, 3,3
+ sub r0, r2
+ movq m1, [r0]
+ punpckldq m1, [r1]
+ movq m2, m1
+ movq m3, m1
+ movq m4, m1
+ psllq m1, 8
+ pxor m2, m1
+ psrlq m2, 8
+ pxor m3, m2
+ PRED4x4_LOWPASS m0, m1, m3, m4, m5
+ lea r1, [r0+r2*2]
+ psrlq m0, 8
+ movd [r0+r2*1], m0
+ psrlq m0, 8
+ movd [r0+r2*2], m0
+ psrlq m0, 8
+ movd [r1+r2*1], m0
+ psrlq m0, 8
+ movd [r1+r2*2], m0
+ RET
+
+;-----------------------------------------------------------------------------
+; void pred4x4_vertical_left_mmxext(uint8_t *src, const uint8_t *topright, int stride)
+;-----------------------------------------------------------------------------
+
+INIT_MMX
+cglobal pred4x4_vertical_left_mmxext, 3,3
+ sub r0, r2
+ movq m1, [r0]
+ punpckldq m1, [r1]
+ movq m3, m1
+ movq m2, m1
+ psrlq m3, 8
+ psrlq m2, 16
+ movq m4, m3
+ pavgb m4, m1
+ PRED4x4_LOWPASS m0, m1, m2, m3, m5
+ lea r1, [r0+r2*2]
+ movh [r0+r2*1], m4
+ movh [r0+r2*2], m0
+ psrlq m4, 8
+ psrlq m0, 8
+ movh [r1+r2*1], m4
+ movh [r1+r2*2], m0
+ RET
+
+;-----------------------------------------------------------------------------
+; void pred4x4_horizontal_up_mmxext(uint8_t *src, const uint8_t *topright, int stride)
+;-----------------------------------------------------------------------------
+
+INIT_MMX
+cglobal pred4x4_horizontal_up_mmxext, 3,3
+ sub r0, r2
+ lea r1, [r0+r2*2]
+ movd m0, [r0+r2*1-4]
+ punpcklbw m0, [r0+r2*2-4]
+ movd m1, [r1+r2*1-4]
+ punpcklbw m1, [r1+r2*2-4]
+ punpckhwd m0, m1
+ movq m1, m0
+ punpckhbw m1, m1
+ pshufw m1, m1, 0xFF
+ punpckhdq m0, m1
+ movq m2, m0
+ movq m3, m0
+ movq m7, m0
+ psrlq m2, 16
+ psrlq m3, 8
+ pavgb m7, m3
+ PRED4x4_LOWPASS m4, m0, m2, m3, m5
+ punpcklbw m7, m4
+ movd [r0+r2*1], m7
+ psrlq m7, 16
+ movd [r0+r2*2], m7
+ psrlq m7, 16
+ movd [r1+r2*1], m7
+ movd [r1+r2*2], m1
+ RET
+
+;-----------------------------------------------------------------------------
+; void pred4x4_horizontal_down_mmxext(uint8_t *src, const uint8_t *topright, int stride)
+;-----------------------------------------------------------------------------
+
+INIT_MMX
+%define PALIGNR PALIGNR_MMX
+cglobal pred4x4_horizontal_down_mmxext, 3,3
+ sub r0, r2
+ lea r1, [r0+r2*2]
+ movh m0, [r0-4] ; lt ..
+ punpckldq m0, [r0] ; t3 t2 t1 t0 lt .. .. ..
+ psllq m0, 8 ; t2 t1 t0 lt .. .. .. ..
+ movd m1, [r1+r2*2-4] ; l3
+ punpcklbw m1, [r1+r2*1-4] ; l2 l3
+ movd m2, [r0+r2*2-4] ; l1
+ punpcklbw m2, [r0+r2*1-4] ; l0 l1
+ punpckhwd m1, m2 ; l0 l1 l2 l3
+ punpckhdq m1, m0 ; t2 t1 t0 lt l0 l1 l2 l3
+ movq m0, m1
+ movq m2, m1
+ movq m5, m1
+ psrlq m0, 16 ; .. .. t2 t1 t0 lt l0 l1
+ psrlq m2, 8 ; .. t2 t1 t0 lt l0 l1 l2
+ pavgb m5, m2
+ PRED4x4_LOWPASS m3, m1, m0, m2, m4
+ punpcklbw m5, m3
+ psrlq m3, 32
+ PALIGNR m3, m5, 6, m4
+ movh [r1+r2*2], m5
+ psrlq m5, 16
+ movh [r1+r2*1], m5
+ psrlq m5, 16
+ movh [r0+r2*2], m5
+ movh [r0+r2*1], m3
+ RET
+
+;-----------------------------------------------------------------------------
+; void pred4x4_vertical_right_mmxext(uint8_t *src, const uint8_t *topright, int stride)
+;-----------------------------------------------------------------------------
+
+INIT_MMX
+%define PALIGNR PALIGNR_MMX
+cglobal pred4x4_vertical_right_mmxext, 3,3
+ sub r0, r2
+ lea r1, [r0+r2*2]
+ movh m0, [r0] ; ........t3t2t1t0
+ movq m5, m0
+ PALIGNR m0, [r0-8], 7, m1 ; ......t3t2t1t0lt
+ pavgb m5, m0
+ PALIGNR m0, [r0+r2*1-8], 7, m1 ; ....t3t2t1t0ltl0
+ movq m1, m0
+ PALIGNR m0, [r0+r2*2-8], 7, m2 ; ..t3t2t1t0ltl0l1
+ movq m2, m0
+ PALIGNR m0, [r1+r2*1-8], 7, m3 ; t3t2t1t0ltl0l1l2
+ PRED4x4_LOWPASS m3, m1, m0, m2, m4
+ movq m1, m3
+ psrlq m3, 16
+ psllq m1, 48
+ movh [r0+r2*1], m5
+ movh [r0+r2*2], m3
+ PALIGNR m5, m1, 7, m2
+ psllq m1, 8
+ movh [r1+r2*1], m5
+ PALIGNR m3, m1, 7, m1
+ movh [r1+r2*2], m3
+ RET
+
+;-----------------------------------------------------------------------------
+; void pred4x4_down_right_mmxext(uint8_t *src, const uint8_t *topright, int stride)
+;-----------------------------------------------------------------------------
+
+INIT_MMX
+%define PALIGNR PALIGNR_MMX
+cglobal pred4x4_down_right_mmxext, 3,3
+ sub r0, r2
+ lea r1, [r0+r2*2]
+ movq m1, [r1-8]
+ movq m2, [r0+r2*1-8]
+ punpckhbw m2, [r0-8]
+ movh m3, [r0]
+ punpckhwd m1, m2
+ PALIGNR m3, m1, 5, m1
+ movq m1, m3
+ PALIGNR m3, [r1+r2*1-8], 7, m4
+ movq m2, m3
+ PALIGNR m3, [r1+r2*2-8], 7, m4
+ PRED4x4_LOWPASS m0, m3, m1, m2, m4
+ movh [r1+r2*2], m0
+ psrlq m0, 8
+ movh [r1+r2*1], m0
+ psrlq m0, 8
+ movh [r0+r2*2], m0
+ psrlq m0, 8
+ movh [r0+r2*1], m0
+ RET
+%endif
diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/h264_intrapred_init.c b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/h264_intrapred_init.c
index a3ce40b9f..ee893a336 100644
--- a/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/h264_intrapred_init.c
+++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavcodec/x86/h264_intrapred_init.c
@@ -44,7 +44,9 @@ void ff_pred16x16_plane_svq3_ssse3 (uint8_t *src, int stride);
void ff_pred16x16_tm_vp8_mmx (uint8_t *src, int stride);
void ff_pred16x16_tm_vp8_mmxext (uint8_t *src, int stride);
void ff_pred16x16_tm_vp8_sse2 (uint8_t *src, int stride);
+void ff_pred8x8_top_dc_mmxext (uint8_t *src, int stride);
void ff_pred8x8_dc_rv40_mmxext (uint8_t *src, int stride);
+void ff_pred8x8_dc_mmxext (uint8_t *src, int stride);
void ff_pred8x8_vertical_mmx (uint8_t *src, int stride);
void ff_pred8x8_horizontal_mmx (uint8_t *src, int stride);
void ff_pred8x8_horizontal_mmxext (uint8_t *src, int stride);
@@ -57,7 +59,37 @@ void ff_pred8x8_tm_vp8_mmx (uint8_t *src, int stride);
void ff_pred8x8_tm_vp8_mmxext (uint8_t *src, int stride);
void ff_pred8x8_tm_vp8_sse2 (uint8_t *src, int stride);
void ff_pred8x8_tm_vp8_ssse3 (uint8_t *src, int stride);
+void ff_pred8x8l_top_dc_mmxext (uint8_t *src, int has_topleft, int has_topright, int stride);
+void ff_pred8x8l_top_dc_ssse3 (uint8_t *src, int has_topleft, int has_topright, int stride);
+void ff_pred8x8l_dc_mmxext (uint8_t *src, int has_topleft, int has_topright, int stride);
+void ff_pred8x8l_dc_ssse3 (uint8_t *src, int has_topleft, int has_topright, int stride);
+void ff_pred8x8l_horizontal_mmxext (uint8_t *src, int has_topleft, int has_topright, int stride);
+void ff_pred8x8l_horizontal_ssse3 (uint8_t *src, int has_topleft, int has_topright, int stride);
+void ff_pred8x8l_vertical_mmxext (uint8_t *src, int has_topleft, int has_topright, int stride);
+void ff_pred8x8l_vertical_ssse3 (uint8_t *src, int has_topleft, int has_topright, int stride);
+void ff_pred8x8l_down_left_mmxext (uint8_t *src, int has_topleft, int has_topright, int stride);
+void ff_pred8x8l_down_left_sse2 (uint8_t *src, int has_topleft, int has_topright, int stride);
+void ff_pred8x8l_down_left_ssse3 (uint8_t *src, int has_topleft, int has_topright, int stride);
+void ff_pred8x8l_down_right_mmxext (uint8_t *src, int has_topleft, int has_topright, int stride);
+void ff_pred8x8l_down_right_sse2 (uint8_t *src, int has_topleft, int has_topright, int stride);
+void ff_pred8x8l_down_right_ssse3 (uint8_t *src, int has_topleft, int has_topright, int stride);
+void ff_pred8x8l_vertical_right_mmxext(uint8_t *src, int has_topleft, int has_topright, int stride);
+void ff_pred8x8l_vertical_right_sse2(uint8_t *src, int has_topleft, int has_topright, int stride);
+void ff_pred8x8l_vertical_right_ssse3(uint8_t *src, int has_topleft, int has_topright, int stride);
+void ff_pred8x8l_vertical_left_sse2(uint8_t *src, int has_topleft, int has_topright, int stride);
+void ff_pred8x8l_vertical_left_ssse3(uint8_t *src, int has_topleft, int has_topright, int stride);
+void ff_pred8x8l_horizontal_up_mmxext(uint8_t *src, int has_topleft, int has_topright, int stride);
+void ff_pred8x8l_horizontal_up_ssse3(uint8_t *src, int has_topleft, int has_topright, int stride);
+void ff_pred8x8l_horizontal_down_mmxext(uint8_t *src, int has_topleft, int has_topright, int stride);
+void ff_pred8x8l_horizontal_down_sse2(uint8_t *src, int has_topleft, int has_topright, int stride);
+void ff_pred8x8l_horizontal_down_ssse3(uint8_t *src, int has_topleft, int has_topright, int stride);
void ff_pred4x4_dc_mmxext (uint8_t *src, const uint8_t *topright, int stride);
+void ff_pred4x4_down_left_mmxext (uint8_t *src, const uint8_t *topright, int stride);
+void ff_pred4x4_down_right_mmxext (uint8_t *src, const uint8_t *topright, int stride);
+void ff_pred4x4_vertical_left_mmxext(uint8_t *src, const uint8_t *topright, int stride);
+void ff_pred4x4_vertical_right_mmxext(uint8_t *src, const uint8_t *topright, int stride);
+void ff_pred4x4_horizontal_up_mmxext(uint8_t *src, const uint8_t *topright, int stride);
+void ff_pred4x4_horizontal_down_mmxext(uint8_t *src, const uint8_t *topright, int stride);
void ff_pred4x4_tm_vp8_mmx (uint8_t *src, const uint8_t *topright, int stride);
void ff_pred4x4_tm_vp8_mmxext (uint8_t *src, const uint8_t *topright, int stride);
void ff_pred4x4_tm_vp8_ssse3 (uint8_t *src, const uint8_t *topright, int stride);
@@ -93,7 +125,34 @@ void ff_h264_pred_init_x86(H264PredContext *h, int codec_id)
h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_mmxext;
h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_mmxext;
h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_mmxext;
+#if CONFIG_GPL
+ h->pred8x8l [TOP_DC_PRED ] = ff_pred8x8l_top_dc_mmxext;
+ h->pred8x8l [DC_PRED ] = ff_pred8x8l_dc_mmxext;
+ h->pred8x8l [HOR_PRED ] = ff_pred8x8l_horizontal_mmxext;
+ h->pred8x8l [VERT_PRED ] = ff_pred8x8l_vertical_mmxext;
+ h->pred8x8l [DIAG_DOWN_RIGHT_PRED] = ff_pred8x8l_down_right_mmxext;
+ h->pred8x8l [VERT_RIGHT_PRED ] = ff_pred8x8l_vertical_right_mmxext;
+ h->pred8x8l [HOR_UP_PRED ] = ff_pred8x8l_horizontal_up_mmxext;
+ h->pred8x8l [DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_mmxext;
+ h->pred8x8l [HOR_DOWN_PRED ] = ff_pred8x8l_horizontal_down_mmxext;
+ h->pred4x4 [DIAG_DOWN_RIGHT_PRED] = ff_pred4x4_down_right_mmxext;
+ h->pred4x4 [VERT_RIGHT_PRED ] = ff_pred4x4_vertical_right_mmxext;
+ h->pred4x4 [HOR_DOWN_PRED ] = ff_pred4x4_horizontal_down_mmxext;
+#endif
h->pred4x4 [DC_PRED ] = ff_pred4x4_dc_mmxext;
+#if CONFIG_GPL
+ if (codec_id == CODEC_ID_VP8 || codec_id == CODEC_ID_H264)
+ h->pred4x4 [DIAG_DOWN_LEFT_PRED ] = ff_pred4x4_down_left_mmxext;
+ if (codec_id == CODEC_ID_SVQ3 || codec_id == CODEC_ID_H264)
+ h->pred4x4 [VERT_LEFT_PRED ] = ff_pred4x4_vertical_left_mmxext;
+ if (codec_id != CODEC_ID_RV40) {
+ h->pred4x4 [HOR_UP_PRED ] = ff_pred4x4_horizontal_up_mmxext;
+ }
+ if (codec_id == CODEC_ID_SVQ3 || codec_id == CODEC_ID_H264) {
+ h->pred8x8 [TOP_DC_PRED8x8 ] = ff_pred8x8_top_dc_mmxext;
+ h->pred8x8 [DC_PRED8x8 ] = ff_pred8x8_dc_mmxext;
+ }
+#endif
if (codec_id == CODEC_ID_VP8) {
h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_tm_vp8_mmxext;
h->pred8x8 [DC_PRED8x8 ] = ff_pred8x8_dc_rv40_mmxext;
@@ -118,6 +177,13 @@ void ff_h264_pred_init_x86(H264PredContext *h, int codec_id)
if (mm_flags & AV_CPU_FLAG_SSE2) {
h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_sse2;
+#if CONFIG_GPL
+ h->pred8x8l [DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_sse2;
+ h->pred8x8l [DIAG_DOWN_RIGHT_PRED] = ff_pred8x8l_down_right_sse2;
+ h->pred8x8l [VERT_RIGHT_PRED ] = ff_pred8x8l_vertical_right_sse2;
+ h->pred8x8l [VERT_LEFT_PRED ] = ff_pred8x8l_vertical_left_sse2;
+ h->pred8x8l [HOR_DOWN_PRED ] = ff_pred8x8l_horizontal_down_sse2;
+#endif
if (codec_id == CODEC_ID_VP8) {
h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_tm_vp8_sse2;
h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_tm_vp8_sse2;
@@ -137,6 +203,18 @@ void ff_h264_pred_init_x86(H264PredContext *h, int codec_id)
h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_ssse3;
h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_ssse3;
h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_ssse3;
+#if CONFIG_GPL
+ h->pred8x8l [TOP_DC_PRED ] = ff_pred8x8l_top_dc_ssse3;
+ h->pred8x8l [DC_PRED ] = ff_pred8x8l_dc_ssse3;
+ h->pred8x8l [HOR_PRED ] = ff_pred8x8l_horizontal_ssse3;
+ h->pred8x8l [VERT_PRED ] = ff_pred8x8l_vertical_ssse3;
+ h->pred8x8l [DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_ssse3;
+ h->pred8x8l [DIAG_DOWN_RIGHT_PRED] = ff_pred8x8l_down_right_ssse3;
+ h->pred8x8l [VERT_RIGHT_PRED ] = ff_pred8x8l_vertical_right_ssse3;
+ h->pred8x8l [VERT_LEFT_PRED ] = ff_pred8x8l_vertical_left_ssse3;
+ h->pred8x8l [HOR_UP_PRED ] = ff_pred8x8l_horizontal_up_ssse3;
+ h->pred8x8l [HOR_DOWN_PRED ] = ff_pred8x8l_horizontal_down_ssse3;
+#endif
if (codec_id == CODEC_ID_VP8) {
h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_tm_vp8_ssse3;
h->pred4x4 [TM_VP8_PRED ] = ff_pred4x4_tm_vp8_ssse3;
diff --git a/src/filters/transform/MPCVideoDec/ffmpeg/libavutil/common.h b/src/filters/transform/MPCVideoDec/ffmpeg/libavutil/common.h
index 5d5e0f2c4..670d3b934 100644
--- a/src/filters/transform/MPCVideoDec/ffmpeg/libavutil/common.h
+++ b/src/filters/transform/MPCVideoDec/ffmpeg/libavutil/common.h
@@ -198,6 +198,20 @@ static inline av_const int av_ceil_log2_c(int x)
return av_log2((x - 1) << 1);
}
+/**
+ * Count number of bits set to one in x
+ * @param x value to count bits of
+ * @return the number of bits set to one in x
+ */
+static inline av_const int av_popcount_c(uint32_t x)
+{
+ x -= (x >> 1) & 0x55555555;
+ x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
+ x = (x + (x >> 4)) & 0x0F0F0F0F;
+ x += x >> 8;
+ return (x + (x >> 16)) & 0x3F;
+}
+
#define MKTAG(a,b,c,d) ((a) | ((b) << 8) | ((c) << 16) | ((d) << 24))
#define MKBETAG(a,b,c,d) ((d) | ((c) << 8) | ((b) << 16) | ((a) << 24))
@@ -360,5 +374,8 @@ static inline av_const int av_ceil_log2_c(int x)
#ifndef av_clipf
# define av_clipf av_clipf_c
#endif
+#ifndef av_popcount
+# define av_popcount av_popcount_c
+#endif
#endif /* HAVE_AV_CONFIG_H */
diff --git a/src/filters/transform/MPCVideoDec/stdafx.cpp b/src/filters/transform/MPCVideoDec/stdafx.cpp
index 1734bc03d..5008ff8b5 100644
--- a/src/filters/transform/MPCVideoDec/stdafx.cpp
+++ b/src/filters/transform/MPCVideoDec/stdafx.cpp
@@ -31,11 +31,9 @@ void LOG(LPCTSTR fmt, ...)
{
va_list args;
va_start(args, fmt);
- if(TCHAR* buff = new TCHAR[_vsctprintf(fmt, args) + 1])
- {
+ if(TCHAR* buff = new TCHAR[_vsctprintf(fmt, args) + 1]) {
_vstprintf(buff, fmt, args);
- if(FILE* f = _tfopen(LOG_FILE, _T("at")))
- {
+ if(FILE* f = _tfopen(LOG_FILE, _T("at"))) {
fseek(f, 0, 2);
_ftprintf(f, _T("%s\n"), buff);
fclose(f);
diff --git a/src/filters/transform/MpaDecFilter/IMpaDecFilter.h b/src/filters/transform/MpaDecFilter/IMpaDecFilter.h
index 718755179..6c933d6bd 100644
--- a/src/filters/transform/MpaDecFilter/IMpaDecFilter.h
+++ b/src/filters/transform/MpaDecFilter/IMpaDecFilter.h
@@ -26,8 +26,7 @@
enum MPCSampleFormat {SF_PCM16, SF_PCM24, SF_PCM32, SF_FLOAT32};
enum {AAC_ASIS, AAC_STEREO};
-enum DolbyDigitalMode
-{
+enum DolbyDigitalMode {
DD_Unknown,
DD_AC3, // Standard AC3
DD_EAC3, // Dolby Digital +
@@ -38,8 +37,7 @@ enum DolbyDigitalMode
interface __declspec(uuid("2067C60F-752F-4EBD-B0B1-4CBC5E00741C"))
IMpaDecFilter :
-public IUnknown
-{
+public IUnknown {
enum enctype {ac3, dts, aac, etlast};
STDMETHOD(SetSampleFormat(MPCSampleFormat sf)) = 0;
diff --git a/src/filters/transform/MpaDecFilter/MpaDecFilter.cpp b/src/filters/transform/MpaDecFilter/MpaDecFilter.cpp
index e5c0e565f..07a4aeb00 100644
--- a/src/filters/transform/MpaDecFilter/MpaDecFilter.cpp
+++ b/src/filters/transform/MpaDecFilter/MpaDecFilter.cpp
@@ -43,8 +43,7 @@
#define EAC3_FRAME_TYPE_RESERVED 3
#define AC3_HEADER_SIZE 7
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
{&MEDIATYPE_Audio, &MEDIASUBTYPE_MP3},
{&MEDIATYPE_Audio, &MEDIASUBTYPE_MPEG1AudioPayload},
{&MEDIATYPE_Audio, &MEDIASUBTYPE_MPEG1Payload},
@@ -119,24 +118,20 @@ const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
#ifdef REGISTER_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
{&MEDIATYPE_Audio, &MEDIASUBTYPE_PCM},
};
-const AMOVIESETUP_PIN sudpPins[] =
-{
+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}
};
-const AMOVIESETUP_FILTER sudFilter[] =
-{
+const AMOVIESETUP_FILTER sudFilter[] = {
{&__uuidof(CMpaDecFilter), L"MPC - MPA Decoder Filter", /*MERIT_DO_NOT_USE*/0x40000001, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
};
-CFactoryTemplate g_Templates[] =
-{
+CFactoryTemplate g_Templates[] = {
{sudFilter[0].strName, &__uuidof(CMpaDecFilter), CreateInstance<CMpaDecFilter>, NULL, &sudFilter[0]},
{L"CMpaDecPropertyPage", &__uuidof(CMpaDecSettingsWnd), CreateInstance<CInternalPropertyPageTempl<CMpaDecSettingsWnd> >},
};
@@ -168,14 +163,12 @@ CFilterApp theApp;
// lets see how we can map these things to dshow (oh the joy!)
#pragma warning(disable : 4245)
-static struct scmap_t
-{
+static struct scmap_t {
WORD nChannels;
BYTE ch[8];
DWORD dwChannelMask;
}
-s_scmap_ac3[2*11] =
-{
+s_scmap_ac3[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
@@ -200,8 +193,7 @@ s_scmap_ac3[2*11] =
{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_dts[2*10] =
-{
+s_scmap_dts[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
@@ -224,8 +216,7 @@ s_scmap_dts[2*10] =
{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_vorbis[6] =
-{
+s_scmap_vorbis[6] = {
{1, {0,-1,-1,-1,-1,-1,-1,-1}, 0}, // 1F
{2, {0, 1,-1,-1,-1,-1,-1,-1}, 0}, // 2F
{3, {0, 2, 1,-1,-1,-1,-1,-1}, SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_FRONT_CENTER}, // 2F1R
@@ -233,9 +224,8 @@ s_scmap_vorbis[6] =
{5, {0, 2, 1, 3, 4,-1,-1,-1}, SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_FRONT_CENTER|SPEAKER_BACK_LEFT|SPEAKER_BACK_RIGHT}, // 3F2R
{6, {0, 2, 1, 5, 3, 4,-1,-1}, SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_FRONT_CENTER|SPEAKER_LOW_FREQUENCY|SPEAKER_BACK_LEFT|SPEAKER_BACK_RIGHT}, // 3F2R + LFE
},
-s_scmap_hdmv[] =
-{
-// FL FR FC LFe BL BR FLC FRC
+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
@@ -249,9 +239,8 @@ s_scmap_hdmv[] =
{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
},
-m_scmap_default[] =
-{
-// FL FR FC LFe BL BR FLC FRC
+m_scmap_default[] = {
+ // FL FR FC LFe BL BR FLC FRC
{1, { 0,-1,-1,-1,-1,-1,-1,-1 }, 0}, // Mono M1, 0
{2, { 0, 1,-1,-1,-1,-1,-1,-1 }, 0}, // Stereo FL, FR
{3, { 0, 1, 2,-1,-1,-1,-1,-1 }, SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_FRONT_CENTER}, // 3/0 FL, FR, FC
@@ -261,9 +250,8 @@ m_scmap_default[] =
{7, { 0, 1, 2, 3, 4, 5, 6,-1 }, SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_FRONT_CENTER|SPEAKER_LOW_FREQUENCY|SPEAKER_SIDE_LEFT|SPEAKER_SIDE_RIGHT|SPEAKER_BACK_CENTER}, // 3/4 FL, FR, FC, BL, Bls, Brs, BR
{8, { 0, 1, 2, 3, 6, 7, 4, 5 }, SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_FRONT_CENTER|SPEAKER_LOW_FREQUENCY|SPEAKER_SIDE_LEFT|SPEAKER_SIDE_RIGHT|SPEAKER_BACK_LEFT|SPEAKER_BACK_RIGHT},// 3/4+LFe FL, FR, FC, BL, Bls, Brs, BR, LFe
},
-m_ffmpeg_ac3[] =
-{
-// FL FR FC LFe BL BR FLC FRC
+m_ffmpeg_ac3[] = {
+ // FL FR FC LFe BL BR FLC FRC
{2, {0, 1,-1,-1,-1,-1,-1,-1}, 0}, // AC3_CHMODE_DUALMONO
{1, {0,-1,-1,-1,-1,-1,-1,-1}, 0}, // AC3_CHMODE_MONO
{2, {0, 1,-1,-1,-1,-1,-1,-1}, 0}, // AC3_CHMODE_STEREO
@@ -284,14 +272,22 @@ CMpaDecFilter::CMpaDecFilter(LPUNKNOWN lpunk, HRESULT* phr)
, m_fNormalize(false)
, m_boost(1)
{
- if(phr) *phr = S_OK;
+ if(phr) {
+ *phr = S_OK;
+ }
m_pInput = DNew CMpaDecInputPin(this, phr, L"In");
- if(!m_pInput) *phr = E_OUTOFMEMORY;
- if(FAILED(*phr)) return;
+ 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(!m_pOutput) {
+ *phr = E_OUTOFMEMORY;
+ }
if(FAILED(*phr)) {
delete m_pInput, m_pInput = NULL;
return;
@@ -320,25 +316,44 @@ CMpaDecFilter::CMpaDecFilter(LPUNKNOWN lpunk, HRESULT* phr)
#endif
CRegKey key;
- if(ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPEG Audio Decoder"), KEY_READ))
- {
+ 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("Normalize"), dw)) m_fNormalize = !!dw;
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("Boost"), dw)) m_boost = *(float*)&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("AacSpeakerConfig"), dw)) m_iSpeakerConfig[aac] = (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;
- if(ERROR_SUCCESS == key.QueryDWORDValue(_T("AacDynamicRangeControl"), dw)) m_fDynamicRangeControl[aac] = !!dw;
+ if(ERROR_SUCCESS == key.QueryDWORDValue(_T("SampleFormat"), dw)) {
+ m_iSampleFormat = (MPCSampleFormat)dw;
+ }
+ if(ERROR_SUCCESS == key.QueryDWORDValue(_T("Normalize"), dw)) {
+ m_fNormalize = !!dw;
+ }
+ if(ERROR_SUCCESS == key.QueryDWORDValue(_T("Boost"), dw)) {
+ m_boost = *(float*)&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("AacSpeakerConfig"), dw)) {
+ m_iSpeakerConfig[aac] = (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;
+ }
+ if(ERROR_SUCCESS == key.QueryDWORDValue(_T("AacDynamicRangeControl"), dw)) {
+ m_fDynamicRangeControl[aac] = !!dw;
+ }
}
}
CMpaDecFilter::~CMpaDecFilter()
{
#if defined(REGISTER_FILTER) | HAS_FFMPEG_AUDIO_DECODERS
- if (m_pFFBuffer) free(m_pFFBuffer);
+ if (m_pFFBuffer) {
+ free(m_pFFBuffer);
+ }
m_nFFBufferSize = 0;
#endif
@@ -395,12 +410,14 @@ HRESULT CMpaDecFilter::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, d
m_ps2_state.sync = false;
m_DolbyDigitalMode = DD_Unknown;
#if defined(REGISTER_FILTER) | HAS_FFMPEG_AUDIO_DECODERS
- if (m_pAVCtx)
+ if (m_pAVCtx) {
avcodec_flush_buffers (m_pAVCtx);
+ }
#endif
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_FLAC
- if (m_flac.pDecoder)
+ if (m_flac.pDecoder) {
FLAC__stream_decoder_flush((FLAC__StreamDecoder*) m_flac.pDecoder);
+ }
#endif
return __super::NewSegment(tStart, tStop, dRate);
}
@@ -412,12 +429,12 @@ HRESULT CMpaDecFilter::Receive(IMediaSample* pIn)
HRESULT hr;
AM_SAMPLE2_PROPERTIES* const pProps = m_pInput->SampleProps();
- if(pProps->dwStreamId != AM_STREAM_MEDIA)
+ if(pProps->dwStreamId != AM_STREAM_MEDIA) {
return m_pOutput->Deliver(pIn);
+ }
AM_MEDIA_TYPE* pmt;
- if(SUCCEEDED(pIn->GetMediaType(&pmt)) && pmt)
- {
+ if(SUCCEEDED(pIn->GetMediaType(&pmt)) && pmt) {
CMediaType mt(*pmt);
m_pInput->SetMediaType(&mt);
DeleteMediaType(pmt);
@@ -433,7 +450,9 @@ HRESULT CMpaDecFilter::Receive(IMediaSample* pIn)
}
BYTE* pDataIn = NULL;
- if(FAILED(hr = pIn->GetPointer(&pDataIn))) return hr;
+ if(FAILED(hr = pIn->GetPointer(&pDataIn))) {
+ return hr;
+ }
long len = pIn->GetActualDataLength();
@@ -442,8 +461,7 @@ HRESULT CMpaDecFilter::Receive(IMediaSample* pIn)
REFERENCE_TIME rtStart = _I64_MIN, rtStop = _I64_MIN;
hr = pIn->GetTime(&rtStart, &rtStop);
- if(pIn->IsDiscontinuity() == S_OK)
- {
+ if(pIn->IsDiscontinuity() == S_OK) {
m_fDiscontinuity = true;
m_buff.RemoveAll();
m_sample_max = 0.1f;
@@ -458,13 +476,11 @@ HRESULT CMpaDecFilter::Receive(IMediaSample* pIn)
const GUID& subtype = m_pInput->CurrentMediaType().subtype;
BOOL bNoJitterControl = false;
- if(subtype == MEDIASUBTYPE_AMR || subtype == MEDIASUBTYPE_SAMR || subtype == MEDIASUBTYPE_SAWB)
- {
+ if(subtype == MEDIASUBTYPE_AMR || subtype == MEDIASUBTYPE_SAMR || subtype == MEDIASUBTYPE_SAWB) {
bNoJitterControl = true;
}
- if(SUCCEEDED(hr) && _abs64((m_rtStart - rtStart)) > 1000000i64 && !bNoJitterControl) // +-100ms jitter is allowed for now
- {
+ if(SUCCEEDED(hr) && _abs64((m_rtStart - rtStart)) > 1000000i64 && !bNoJitterControl) { // +-100ms jitter is allowed for now
m_buff.RemoveAll();
m_rtStart = rtStart;
}
@@ -475,51 +491,60 @@ HRESULT CMpaDecFilter::Receive(IMediaSample* pIn)
len += bufflen;
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_AMR
- if(subtype == MEDIASUBTYPE_AMR || subtype == MEDIASUBTYPE_SAMR)
+ if(subtype == MEDIASUBTYPE_AMR || subtype == MEDIASUBTYPE_SAMR) {
hr = ProcessFFmpeg(CODEC_ID_AMR_NB);
- else if(subtype == MEDIASUBTYPE_SAWB)
+ } else if(subtype == MEDIASUBTYPE_SAWB) {
hr = ProcessFFmpeg(CODEC_ID_AMR_WB);
+ }
#else
if(0) {}
#endif
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_LPCM
- else if(subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO)
+ else if(subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO) {
hr = ProcessLPCM();
- else if(subtype == MEDIASUBTYPE_HDMV_LPCM_AUDIO)
+ } 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_DOLBY_DDPLUS ||
- subtype == MEDIASUBTYPE_DOLBY_TRUEHD)
+ subtype == MEDIASUBTYPE_DOLBY_TRUEHD) {
hr = ProcessAC3();
+ }
#endif
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_DTS
- else if(subtype == MEDIASUBTYPE_DTS || subtype == MEDIASUBTYPE_WAVE_DTS)
+ else if(subtype == MEDIASUBTYPE_DTS || subtype == MEDIASUBTYPE_WAVE_DTS) {
hr = ProcessDTS();
+ }
#endif
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_AAC
- else if(subtype == MEDIASUBTYPE_AAC || subtype == MEDIASUBTYPE_MP4A || subtype == MEDIASUBTYPE_mp4a)
+ else if(subtype == MEDIASUBTYPE_AAC || subtype == MEDIASUBTYPE_MP4A || subtype == MEDIASUBTYPE_mp4a) {
hr = ProcessAAC();
+ }
#endif
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_PS2AUDIO
- else if(subtype == MEDIASUBTYPE_PS2_PCM)
+ else if(subtype == MEDIASUBTYPE_PS2_PCM) {
hr = ProcessPS2PCM();
- else if(subtype == MEDIASUBTYPE_PS2_ADPCM)
+ } else if(subtype == MEDIASUBTYPE_PS2_ADPCM) {
hr = ProcessPS2ADPCM();
+ }
#endif
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_VORBIS
- else if(subtype == MEDIASUBTYPE_Vorbis2)
+ else if(subtype == MEDIASUBTYPE_Vorbis2) {
hr = ProcessVorbis();
+ }
#endif
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_FLAC
- else if(subtype == MEDIASUBTYPE_FLAC_FRAMED)
+ else if(subtype == MEDIASUBTYPE_FLAC_FRAMED) {
hr = ProcessFlac();
+ }
#endif
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_NELLYMOSER
- else if(subtype == MEDIASUBTYPE_NELLYMOSER)
+ else if(subtype == MEDIASUBTYPE_NELLYMOSER) {
hr = ProcessFFmpeg(CODEC_ID_NELLYMOSER);
+ }
#endif
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_PCM
else if(subtype == MEDIASUBTYPE_PCM_NONE ||
@@ -528,42 +553,36 @@ HRESULT CMpaDecFilter::Receive(IMediaSample* pIn)
return S_OK;
}
hr = ProcessPCMraw();
- }
- else if(subtype == MEDIASUBTYPE_PCM_TWOS) {
+ } else if(subtype == MEDIASUBTYPE_PCM_TWOS) {
if(m_buff.GetCount() < 960) {
return S_OK;
}
hr = ProcessPCMintBE();
- }
- else if(subtype == MEDIASUBTYPE_PCM_SOWT) {
+ } else if(subtype == MEDIASUBTYPE_PCM_SOWT) {
if(m_buff.GetCount() < 960) {
return S_OK;
}
hr = ProcessPCMintLE();
- }
- else if(subtype == MEDIASUBTYPE_PCM_IN24 ||
- subtype == MEDIASUBTYPE_PCM_IN32) {
+ } else if(subtype == MEDIASUBTYPE_PCM_IN24 ||
+ subtype == MEDIASUBTYPE_PCM_IN32) {
if(m_buff.GetCount() < 1920) {
return S_OK;
}
hr = ProcessPCMintBE();
- }
- else if(subtype == MEDIASUBTYPE_PCM_IN24_le ||
- subtype == MEDIASUBTYPE_PCM_IN32_le) {
+ } else if(subtype == MEDIASUBTYPE_PCM_IN24_le ||
+ subtype == MEDIASUBTYPE_PCM_IN32_le) {
if(m_buff.GetCount() < 1920) {
return S_OK;
}
hr = ProcessPCMintLE();
- }
- else if(subtype == MEDIASUBTYPE_PCM_FL32 ||
- subtype == MEDIASUBTYPE_PCM_FL64) {
+ } else if(subtype == MEDIASUBTYPE_PCM_FL32 ||
+ subtype == MEDIASUBTYPE_PCM_FL64) {
if(m_buff.GetCount() < 3840) {
return S_OK;
}
hr = ProcessPCMfloatBE();
- }
- else if(subtype == MEDIASUBTYPE_PCM_FL32_le ||
- subtype == MEDIASUBTYPE_PCM_FL64_le) {
+ } else if(subtype == MEDIASUBTYPE_PCM_FL32_le ||
+ subtype == MEDIASUBTYPE_PCM_FL64_le) {
if(m_buff.GetCount() < 3840) {
return S_OK;
}
@@ -571,12 +590,14 @@ HRESULT CMpaDecFilter::Receive(IMediaSample* pIn)
}
#endif
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_IMA4
- else if(subtype == MEDIASUBTYPE_IMA4)
+ else if(subtype == MEDIASUBTYPE_IMA4) {
hr = ProcessFFmpeg(CODEC_ID_ADPCM_IMA_QT);
+ }
#endif
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_MPEGAUDIO
- else // if(.. the rest ..)
+ else { // if(.. the rest ..)
hr = ProcessMPA();
+ }
#endif
return hr;
@@ -587,8 +608,9 @@ HRESULT CMpaDecFilter::ProcessLPCM()
{
WAVEFORMATEX* wfein = (WAVEFORMATEX*)m_pInput->CurrentMediaType().Format();
- if (wfein->nChannels < 1 || wfein->nChannels > 8)
+ if (wfein->nChannels < 1 || wfein->nChannels > 8) {
return ERROR_NOT_SUPPORTED;
+ }
scmap_t* remap = &m_scmap_default [wfein->nChannels-1];
int nChannels = wfein->nChannels;
@@ -604,144 +626,122 @@ HRESULT CMpaDecFilter::ProcessLPCM()
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;
- }
+ 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++)
- {
- int nRemap = remap->ch[j];
- *pDataOut = float(Temp[0][nRemap]) / float(SHRT_MAX);
- ++pDataOut;
- }
- for(int j = 0; j < nChannels; j++)
- {
- int nRemap = remap->ch[j];
- *pDataOut = float(Temp[1][nRemap]) / float(SHRT_MAX);
- ++pDataOut;
+ for(int j = 0; j < nChannels; j++) {
+ int nRemap = remap->ch[j];
+ *pDataOut = float(Temp[0][nRemap]) / float(SHRT_MAX);
+ ++pDataOut;
+ }
+ for(int j = 0; j < nChannels; j++) {
+ int nRemap = remap->ch[j];
+ *pDataOut = float(Temp[1][nRemap]) / float(SHRT_MAX);
+ ++pDataOut;
+ }
}
}
- }
- break;
+ 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;
- }
+ 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;
- }
+ // 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++)
- {
- int nRemap = remap->ch[j];
- *pDataOut = float(Temp[0][nRemap]) / float(1<<23);
- ++pDataOut;
- }
- for(int j = 0; j < nChannels; j++)
- {
- int nRemap = remap->ch[j];
- *pDataOut = float(Temp[1][nRemap]) / float(1<<23);
- ++pDataOut;
+ // Convert into float
+ for(int j = 0; j < nChannels; j++) {
+ int nRemap = remap->ch[j];
+ *pDataOut = float(Temp[0][nRemap]) / float(1<<23);
+ ++pDataOut;
+ }
+ for(int j = 0; j < nChannels; j++) {
+ int nRemap = remap->ch[j];
+ *pDataOut = float(Temp[1][nRemap]) / float(1<<23);
+ ++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;
- }
+ 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;
- }
+ // 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++)
- {
- int nRemap = remap->ch[j];
- *pDataOut = float(Temp[0][nRemap]) / float(1<<23);
- ++pDataOut;
- }
- for(int j = 0; j < nChannels; j++)
- {
- int nRemap = remap->ch[j];
- *pDataOut = float(Temp[1][nRemap]) / float(1<<23);
- ++pDataOut;
+ // Convert into float
+ for(int j = 0; j < nChannels; j++) {
+ int nRemap = remap->ch[j];
+ *pDataOut = float(Temp[0][nRemap]) / float(1<<23);
+ ++pDataOut;
+ }
+ for(int j = 0; j < nChannels; j++) {
+ int nRemap = remap->ch[j];
+ *pDataOut = float(Temp[1][nRemap]) / float(1<<23);
+ ++pDataOut;
+ }
}
}
- }
- break;
+ break;
}
memmove(m_buff.GetData(), pDataIn, m_buff.GetCount() - len );
@@ -760,8 +760,7 @@ HRESULT CMpaDecFilter::ProcessHdmvLPCM(bool bAlignOldBuffer) // Blu ray LPCM
int BytesPerSample = wfein->nChannels*BytesPerChannelSample; // Beliyaal: Old calculation only worked if nChannel*bytespersample is power of 2
int oldlen = m_buff.GetCount();
int len = (oldlen / BytesPerSample) * BytesPerSample;
- if (bAlignOldBuffer)
- {
+ if (bAlignOldBuffer) {
m_buff.SetCount(len);
}
scmap_t* remap = &s_scmap_hdmv [wfein->channel_conf];
@@ -771,39 +770,34 @@ HRESULT CMpaDecFilter::ProcessHdmvLPCM(bool bAlignOldBuffer) // Blu ray LPCM
float* pDataOut = pBuff.GetData();
- switch (wfein->wBitsPerSample)
- {
- case 16 :
- for (int i=0; i<len/wfein->nChannels/2; i++)
- {
- for(int j = 0; j < wfein->nChannels; j++)
- {
- int nRemap = remap->ch[j];
- *pDataOut = (float)(short)((pDataIn[nRemap*2]<<8)|pDataIn[nRemap*2+1]) / SHRT_MAX;
- pDataOut++;
+ switch (wfein->wBitsPerSample) {
+ case 16 :
+ for (int i=0; i<len/wfein->nChannels/2; i++) {
+ for(int j = 0; j < wfein->nChannels; j++) {
+ int nRemap = remap->ch[j];
+ *pDataOut = (float)(short)((pDataIn[nRemap*2]<<8)|pDataIn[nRemap*2+1]) / SHRT_MAX;
+ pDataOut++;
+ }
+ pDataIn += wfein->nChannels*2;
}
- pDataIn += wfein->nChannels*2;
- }
- break;
+ break;
- case 24 :
- case 20 :
- long lSample;
+ case 24 :
+ case 20 :
+ long lSample;
- for (int i=0; i<len/wfein->nChannels/3; i++)
- {
- for(int j = 0; j < wfein->nChannels; j++)
- {
- BYTE nRemap = remap->ch[j];
+ for (int i=0; i<len/wfein->nChannels/3; i++) {
+ for(int j = 0; j < wfein->nChannels; j++) {
+ BYTE nRemap = remap->ch[j];
- lSample = (long)pDataIn[nRemap*3]<<24 | (long)pDataIn[nRemap*3+1]<<16 | (long)pDataIn[nRemap*3+2]<<8;
- *pDataOut = (float)(long)lSample / 0x80000000;
+ lSample = (long)pDataIn[nRemap*3]<<24 | (long)pDataIn[nRemap*3+1]<<16 | (long)pDataIn[nRemap*3+2]<<8;
+ *pDataOut = (float)(long)lSample / 0x80000000;
- pDataOut++;
+ pDataOut++;
+ }
+ pDataIn += wfein->nChannels*3;
}
- pDataIn += wfein->nChannels*3;
- }
- break;
+ break;
}
memmove(m_buff.GetData(), pDataIn, m_buff.GetCount() - len );
@@ -818,34 +812,30 @@ HRESULT CMpaDecFilter::ProcessA52(BYTE* p, int buffsize, int& size, bool& fEnoug
{
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);
+ 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)
- {
+ if(fEnoughData) {
int iSpeakerConfig = GetSpeakerConfig(ac3);
- if(iSpeakerConfig < 0)
- {
+ if(iSpeakerConfig < 0) {
HRESULT hr;
- if(S_OK != (hr = Deliver(p, size, bit_rate, 0x0001)))
+ if(S_OK != (hr = Deliver(p, size, bit_rate, 0x0001))) {
return hr;
- }
- else
- {
+ }
+ } 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))
+ 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_ac3)/2);
scmap_t& scmap = s_scmap_ac3[scmapidx + ((flags&A52_LFE)?(countof(s_scmap_ac3)/2):0)];
@@ -856,25 +846,22 @@ HRESULT CMpaDecFilter::ProcessA52(BYTE* p, int buffsize, int& size, bool& fEnoug
int i = 0;
- for(; i < 6 && a52_block(m_a52_state) == 0; i++)
- {
+ 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++)
- {
+ 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)
- {
+ if(i == 6) {
HRESULT hr;
- if(S_OK != (hr = Deliver(pBuff, sample_rate, scmap.nChannels, scmap.dwChannelMask)))
+ if(S_OK != (hr = Deliver(pBuff, sample_rate, scmap.nChannels, scmap.dwChannelMask))) {
return hr;
+ }
}
}
}
@@ -892,38 +879,33 @@ HRESULT CMpaDecFilter::ProcessAC3()
BYTE* base = p;
BYTE* end = p + m_buff.GetCount();
- while(end - p >= 7)
- {
+ while(end - p >= 7) {
int size = 0, 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);
+ 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);
bool fEnoughData = p + size <= end;
- if(fEnoughData)
- {
+ if(fEnoughData) {
int iSpeakerConfig = GetSpeakerConfig(ac3);
- if(iSpeakerConfig < 0)
- {
+ if(iSpeakerConfig < 0) {
HRESULT hr;
- if(S_OK != (hr = Deliver(p, size, bit_rate, 0x0001)))
+ if(S_OK != (hr = Deliver(p, size, bit_rate, 0x0001))) {
return hr;
- }
- else
- {
+ }
+ } 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))
+ 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_ac3)/2);
scmap_t& scmap = s_scmap_ac3[scmapidx + ((flags&A52_LFE)?(countof(s_scmap_ac3)/2):0)];
@@ -934,25 +916,22 @@ HRESULT CMpaDecFilter::ProcessAC3()
int i = 0;
- for(; i < 6 && a52_block(m_a52_state) == 0; i++)
- {
+ 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++)
- {
+ 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)
- {
+ if(i == 6) {
HRESULT hr;
- if(S_OK != (hr = Deliver(pBuff, sample_rate, scmap.nChannels, scmap.dwChannelMask)))
+ if(S_OK != (hr = Deliver(pBuff, sample_rate, scmap.nChannels, scmap.dwChannelMask))) {
return hr;
+ }
}
}
}
@@ -964,11 +943,10 @@ HRESULT CMpaDecFilter::ProcessAC3()
end = base + (end - p);
p = base;
- if(!fEnoughData)
+ if(!fEnoughData) {
break;
- }
- else
- {
+ }
+ } else {
p++;
}
}
@@ -987,76 +965,70 @@ HRESULT CMpaDecFilter::ProcessAC3()
BYTE* base = p;
BYTE* end = p + m_buff.GetCount();
- while(end - p >= AC3_HEADER_SIZE)
- {
+ while(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 */
- {
+ if (m_DolbyDigitalMode != DD_TRUEHD && m_DolbyDigitalMode != DD_MLP && (*((__int16*)p) == 0x770b)) { /* AC3-EAC3 syncword */
BYTE bsid = p[5] >> 3;
- if ((m_DolbyDigitalMode != DD_EAC3) && bsid <= 12)
- {
+ if ((m_DolbyDigitalMode != DD_EAC3) && bsid <= 12) {
m_DolbyDigitalMode = DD_AC3;
- if (FAILED (hr = ProcessA52 (p, end-p, size, fEnoughData))) return hr;
- }
- else if (bsid <= 16)
- {
+ if (FAILED (hr = ProcessA52 (p, end-p, size, fEnoughData))) {
+ return hr;
+ }
+ } else if (bsid <= 16) {
DeliverFFmpeg(CODEC_ID_EAC3, p, end-p, size);
- if (size > 0)
+ if (size > 0) {
m_DolbyDigitalMode = DD_EAC3;
- }
- else
- {
+ }
+ } else {
p++;
continue;
}
- }
- else if ( (*((__int32*)(p+4)) == 0xba6f72f8) || // True HD major sync frame
- m_DolbyDigitalMode == DD_TRUEHD )
- {
+ } else if ( (*((__int32*)(p+4)) == 0xba6f72f8) || // True HD major sync frame
+ m_DolbyDigitalMode == DD_TRUEHD ) {
int nLenght = (((p[0]<<8) + p[1]) & 0x0FFF)*2;
m_DolbyDigitalMode = DD_TRUEHD;
- if (nLenght >= 4)
- {
+ if (nLenght >= 4) {
DeliverFFmpeg(CODEC_ID_TRUEHD, p, end-p, size);
- if (size<0) size = end-p;
+ if (size<0) {
+ size = end-p;
+ }
}
- }
- else if ( (*((__int32*)(p+4)) == 0xbb6f72f8) ||
- m_DolbyDigitalMode == DD_MLP ) // MLP
- {
+ } else if ( (*((__int32*)(p+4)) == 0xbb6f72f8) ||
+ m_DolbyDigitalMode == DD_MLP ) { // MLP
int nLenght = (((p[0]<<8) + p[1]) & 0x0FFF)*2;
m_DolbyDigitalMode = DD_MLP;
- if (nLenght >= 4)
- {
+ if (nLenght >= 4) {
DeliverFFmpeg(CODEC_ID_MLP, p, end-p, size);
- if (size<0) size = end-p;
+ if (size<0) {
+ size = end-p;
+ }
}
- }
- else
- {
+ } else {
p++;
continue;
}
// Update buffer position
- if (fEnoughData)
- {
+ if (fEnoughData) {
ASSERT (size <= end-p);
- if (size <= 0) break;
+ if (size <= 0) {
+ break;
+ }
p += size;
}
memmove(base, p, end - p);
end = base + (end - p);
p = base;
- if(!fEnoughData)
+ if(!fEnoughData) {
break;
+ }
}
m_buff.SetCount(end - p);
@@ -1077,7 +1049,9 @@ HRESULT CMpaDecFilter::ProcessFFmpeg(int nCodecId)
int size = 0;
hr = DeliverFFmpeg(nCodecId, p, end-p, size);
- if (size <= 0) return S_OK;
+ if (size <= 0) {
+ return S_OK;
+ }
p += size;
memmove(base, p, end - p);
end = base + (end - p);
@@ -1095,38 +1069,33 @@ HRESULT CMpaDecFilter::ProcessDTS()
BYTE* base = p;
BYTE* end = p + m_buff.GetCount();
- while(end - p >= 14)
- {
+ 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);
+ 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);
bool fEnoughData = p + size <= end;
- if(fEnoughData)
- {
+ if(fEnoughData) {
int iSpeakerConfig = GetSpeakerConfig(dts);
- if(iSpeakerConfig < 0)
- {
+ if(iSpeakerConfig < 0) {
HRESULT hr;
- if(S_OK != (hr = Deliver(p, size, bit_rate, 0x000b)))
+ if(S_OK != (hr = Deliver(p, size, bit_rate, 0x000b))) {
return hr;
- }
- else
- {
+ }
+ } 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))
+ 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_dts)/2);
scmap_t& scmap = s_scmap_dts[scmapidx + ((flags&DTS_LFE)?(countof(s_scmap_dts)/2):0)];
@@ -1139,25 +1108,22 @@ HRESULT CMpaDecFilter::ProcessDTS()
int i = 0;
- for(; i < blocks && dts_block(m_dts_state) == 0; i++)
- {
+ 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++)
- {
+ 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)
- {
+ if(i == blocks) {
HRESULT hr;
- if(S_OK != (hr = Deliver(pBuff, sample_rate, scmap.nChannels, scmap.dwChannelMask)))
+ if(S_OK != (hr = Deliver(pBuff, sample_rate, scmap.nChannels, scmap.dwChannelMask))) {
return hr;
+ }
}
}
}
@@ -1169,11 +1135,10 @@ HRESULT CMpaDecFilter::ProcessDTS()
end = base + (end - p);
p = base;
- if(!fEnoughData)
+ if(!fEnoughData) {
break;
- }
- else
- {
+ }
+ } else {
p++;
}
}
@@ -1197,12 +1162,15 @@ HRESULT CMpaDecFilter::ProcessAAC()
float* src = (float*)NeAACDecDecode(m_aac_state.h, &info, m_buff.GetData(), m_buff.GetCount());
m_buff.RemoveAll();
//if(!src) return E_FAIL;
- if(info.error) m_aac_state.init(m_pInput->CurrentMediaType());
- if(!src || info.samples == 0) return S_OK;
+ if(info.error) {
+ m_aac_state.init(m_pInput->CurrentMediaType());
+ }
+ if(!src || info.samples == 0) {
+ return S_OK;
+ }
// HACK: bug in faad2 with mono sources?
- if(info.channels == 2 && info.channel_position[1] == UNKNOWN_CHANNEL)
- {
+ if(info.channels == 2 && info.channel_position[1] == UNKNOWN_CHANNEL) {
info.channel_position[0] = FRONT_CHANNEL_LEFT;
info.channel_position[1] = FRONT_CHANNEL_RIGHT;
}
@@ -1223,8 +1191,7 @@ HRESULT CMpaDecFilter::ProcessAAC()
chmask[LFE_CHANNEL] = SPEAKER_LOW_FREQUENCY;
DWORD dwChannelMask = 0;
- for(int i = 0; i < info.channels; i++)
- {
+ for(int i = 0; i < info.channels; i++) {
if(info.channel_position[i] == UNKNOWN_CHANNEL) {
ASSERT(0);
return E_FAIL;
@@ -1235,14 +1202,11 @@ HRESULT CMpaDecFilter::ProcessAAC()
int chmap[countof(info.channel_position)];
memset(chmap, 0, sizeof(chmap));
- for(int i = 0; i < info.channels; i++)
- {
+ for(int i = 0; i < info.channels; i++) {
unsigned int ch = 0, mask = chmask[info.channel_position[i]];
- for(int j = 0; j < 32; j++)
- {
- if(dwChannelMask & (1 << j))
- {
+ for(int j = 0; j < 32; j++) {
+ if(dwChannelMask & (1 << j)) {
if((1 << j) == mask) {
chmap[i] = ch;
break;
@@ -1252,15 +1216,19 @@ HRESULT CMpaDecFilter::ProcessAAC()
}
}
- if(info.channels <= 2) dwChannelMask = 0;
+ if(info.channels <= 2) {
+ dwChannelMask = 0;
+ }
for(int j = 0; j < info.samples; j += info.channels, dst += info.channels)
- for(int i = 0; i < info.channels; i++)
+ for(int i = 0; i < info.channels; i++) {
dst[chmap[i]] = *src++;
+ }
HRESULT hr;
- if(S_OK != (hr = Deliver(pBuff, info.samplerate, info.channels, dwChannelMask)))
+ if(S_OK != (hr = Deliver(pBuff, info.samplerate, info.channels, dwChannelMask))) {
return hr;
+ }
return S_OK;
}
@@ -1276,20 +1244,20 @@ HRESULT CMpaDecFilter::ProcessPCMraw() //'raw '
float* f = pBuff.GetData();
switch(wfe->wBitsPerSample) {
- case 8: //unsigned 8-bit
- { BYTE* b = m_buff.GetData();
- for(int i = 0; i < nSamples; i++) {
- f[i] = (float)(CHAR)(b[i] - 128) / 128;
+ case 8: { //unsigned 8-bit
+ BYTE* b = m_buff.GetData();
+ for(int i = 0; i < nSamples; i++) {
+ f[i] = (float)(CHAR)(b[i] - 128) / 128;
+ }
}
- }
- break;
- case 16: //signed big-endian 16 bit
- { USHORT* d = (USHORT*)m_buff.GetData();//signed take as an unsigned to shift operations.
- for(int i = 0; i < nSamples; i++) {
- f[i] = (float)(SHORT)(d[i] << 8 | d[i] >> 8) / 32768;
+ break;
+ case 16: { //signed big-endian 16 bit
+ USHORT* d = (USHORT*)m_buff.GetData();//signed take as an unsigned to shift operations.
+ for(int i = 0; i < nSamples; i++) {
+ f[i] = (float)(SHORT)(d[i] << 8 | d[i] >> 8) / 32768;
+ }
}
- }
- break;
+ break;
}
HRESULT hr;
@@ -1311,39 +1279,39 @@ HRESULT CMpaDecFilter::ProcessPCMintBE() //'twos', big-endian 'in24' and 'in32'
float* f = pBuff.GetData();
switch(wfe->wBitsPerSample) {
- case 8: //signed 8-bit
- { CHAR* b = (CHAR*)m_buff.GetData();
- for(int i = 0; i < nSamples; i++) {
- f[i] = (float)b[i] / 128;
+ case 8: { //signed 8-bit
+ CHAR* b = (CHAR*)m_buff.GetData();
+ for(int i = 0; i < nSamples; i++) {
+ f[i] = (float)b[i] / 128;
+ }
}
- }
- break;
- case 16: //signed big-endian 16-bit
- { USHORT* d = (USHORT*)m_buff.GetData();//signed take as an unsigned to shift operations.
- for(int i = 0; i < nSamples; i++) {
- f[i] = (float)(SHORT)(d[i] << 8 | d[i] >> 8) / 32768;
+ break;
+ case 16: { //signed big-endian 16-bit
+ USHORT* d = (USHORT*)m_buff.GetData();//signed take as an unsigned to shift operations.
+ for(int i = 0; i < nSamples; i++) {
+ f[i] = (float)(SHORT)(d[i] << 8 | d[i] >> 8) / 32768;
+ }
}
- }
- break;
- case 24: //signed big-endian 24-bit
- { BYTE* b = (BYTE*)m_buff.GetData();
- for(int i = 0; i < nSamples; i++) {
- f[i] = (float)(signed int)((unsigned int)b[3*i] << 24 |
- (unsigned int)b[3*i+1] << 16 |
- (unsigned int)b[3*i+2] << 8) / 2147483648;
+ break;
+ case 24: { //signed big-endian 24-bit
+ BYTE* b = (BYTE*)m_buff.GetData();
+ for(int i = 0; i < nSamples; i++) {
+ f[i] = (float)(signed int)((unsigned int)b[3*i] << 24 |
+ (unsigned int)b[3*i+1] << 16 |
+ (unsigned int)b[3*i+2] << 8) / 2147483648;
+ }
}
- }
- break;
- case 32: //signed big-endian 32-bit
- { UINT* q = (UINT*)m_buff.GetData();//signed take as an unsigned to shift operations.
- for(int i = 0; i < nSamples; i++) {
- f[i] = (float)(INT)(q[i] >> 24 |
- (q[i] & 0x00ff0000) >> 8 |
- (q[i] & 0x0000ff00) << 8 |
- q[i] << 24) / 2147483648;
+ break;
+ case 32: { //signed big-endian 32-bit
+ UINT* q = (UINT*)m_buff.GetData();//signed take as an unsigned to shift operations.
+ for(int i = 0; i < nSamples; i++) {
+ f[i] = (float)(INT)(q[i] >> 24 |
+ (q[i] & 0x00ff0000) >> 8 |
+ (q[i] & 0x0000ff00) << 8 |
+ q[i] << 24) / 2147483648;
+ }
}
- }
- break;
+ break;
}
HRESULT hr;
@@ -1365,36 +1333,36 @@ HRESULT CMpaDecFilter::ProcessPCMintLE() //'sowt', little-endian 'in24' and 'in3
float* f = pBuff.GetData();
switch(wfe->wBitsPerSample) {
- case 8: //signed 8-bit
- { CHAR* b = (CHAR*)m_buff.GetData();
- for(int i = 0; i < nSamples; i++) {
- f[i] = (float)b[i] / 128;
+ case 8: { //signed 8-bit
+ CHAR* b = (CHAR*)m_buff.GetData();
+ for(int i = 0; i < nSamples; i++) {
+ f[i] = (float)b[i] / 128;
+ }
}
- }
- break;
- case 16: //signed little-endian 16-bit
- { SHORT* d = (SHORT*)m_buff.GetData();
- for(int i = 0; i < nSamples; i++) {
- f[i] = (float)d[i] / 32768;
+ break;
+ case 16: { //signed little-endian 16-bit
+ SHORT* d = (SHORT*)m_buff.GetData();
+ for(int i = 0; i < nSamples; i++) {
+ f[i] = (float)d[i] / 32768;
+ }
}
- }
- break;
- case 24: //signed little-endian 32-bit
- { BYTE* b = (BYTE*)m_buff.GetData();
- for(int i = 0; i < nSamples; i++) {
- f[i] = (float)(signed int)((unsigned int)b[3*i] << 8 |
- (unsigned int)b[3*i+1] << 16 |
- (unsigned int)b[3*i+2] << 24) / 2147483648;
+ break;
+ case 24: { //signed little-endian 32-bit
+ BYTE* b = (BYTE*)m_buff.GetData();
+ for(int i = 0; i < nSamples; i++) {
+ f[i] = (float)(signed int)((unsigned int)b[3*i] << 8 |
+ (unsigned int)b[3*i+1] << 16 |
+ (unsigned int)b[3*i+2] << 24) / 2147483648;
+ }
}
- }
- break;
- case 32: //signed little-endian 32-bit
- { INT* q = (INT*)m_buff.GetData();
- for(int i = 0; i < nSamples; i++) {
- f[i] = (float)q[i] / 2147483648;
+ break;
+ case 32: { //signed little-endian 32-bit
+ INT* q = (INT*)m_buff.GetData();
+ for(int i = 0; i < nSamples; i++) {
+ f[i] = (float)q[i] / 2147483648;
+ }
}
- }
- break;
+ break;
}
HRESULT hr;
@@ -1416,33 +1384,33 @@ HRESULT CMpaDecFilter::ProcessPCMfloatBE() //big-endian 'fl32' and 'fl64'
float* f = pBuff.GetData();
switch(wfe->wBitsPerSample) {
- case 32:
- { unsigned int* q = (unsigned int*)m_buff.GetData();
- unsigned int* vf = (unsigned int*)f;
- for(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:
- { unsigned __int64* q = (unsigned __int64*)m_buff.GetData();
- unsigned __int64 x;
- for(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;
+ case 32: {
+ unsigned int* q = (unsigned int*)m_buff.GetData();
+ unsigned int* vf = (unsigned int*)f;
+ for(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: {
+ unsigned __int64* q = (unsigned __int64*)m_buff.GetData();
+ unsigned __int64 x;
+ for(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;
@@ -1464,20 +1432,20 @@ HRESULT CMpaDecFilter::ProcessPCMfloatLE() //little-endian 'fl32' and 'fl64'
float* f = pBuff.GetData();
switch(wfe->wBitsPerSample) {
- case 32:
- { float* q = (float*)m_buff.GetData();
- for(int i = 0; i < nSamples; i++) {
- f[i] = q[i];
+ case 32: {
+ float* q = (float*)m_buff.GetData();
+ for(int i = 0; i < nSamples; i++) {
+ f[i] = q[i];
+ }
}
- }
- break;
- case 64:
- { double* q = (double*)m_buff.GetData();
- for(int i = 0; i < nSamples; i++) {
- f[i] = (float)q[i];
+ break;
+ case 64: {
+ double* q = (double*)m_buff.GetData();
+ for(int i = 0; i < nSamples; i++) {
+ f[i] = (float)q[i];
+ }
}
- }
- break;
+ break;
}
HRESULT hr;
@@ -1504,38 +1472,32 @@ HRESULT CMpaDecFilter::ProcessPS2PCM()
pBuff.SetCount(samples*channels);
float* f = pBuff.GetData();
- while(end - p >= size)
- {
+ while(end - p >= size) {
DWORD* dw = (DWORD*)p;
- if(dw[0] == 'dhSS')
- {
+ if(dw[0] == 'dhSS') {
p += dw[1] + 8;
- }
- else if(dw[0] == 'dbSS')
- {
+ } else if(dw[0] == 'dbSS') {
p += 8;
m_ps2_state.sync = true;
- }
- else
- {
- if(m_ps2_state.sync)
- {
+ } else {
+ if(m_ps2_state.sync) {
short* s = (short*)p;
for(int i = 0; i < samples; i++)
- for(int j = 0; j < channels; j++)
+ for(int j = 0; j < channels; j++) {
f[i*channels+j] = (float)s[j*samples+i] / 32768;
- }
- else
- {
- for(int i = 0, j = samples*channels; i < j; i++)
+ }
+ } 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)))
+ if(S_OK != (hr = Deliver(pBuff, wfe->nSamplesPerSec, wfe->nChannels))) {
return hr;
+ }
p += size;
@@ -1563,8 +1525,7 @@ static void decodeps2adpcm(ps2_state_t& s, int channel, BYTE* pin, double* pout)
}
// if(unk == 7) {ASSERT(0); return;} // ???
- static double s_tbl[] =
- {
+ 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
};
@@ -1573,8 +1534,7 @@ static void decodeps2adpcm(ps2_state_t& s, int channel, BYTE* pin, double* pout)
double& a = s.a[channel];
double& b = s.b[channel];
- for(int i = 0; i < 28; i++)
- {
+ 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;
@@ -1600,44 +1560,39 @@ HRESULT CMpaDecFilter::ProcessPS2ADPCM()
pBuff.SetCount(samples*channels);
float* f = pBuff.GetData();
- while(end - p >= size)
- {
+ while(end - p >= size) {
DWORD* dw = (DWORD*)p;
- if(dw[0] == 'dhSS')
- {
+ if(dw[0] == 'dhSS') {
p += dw[1] + 8;
- }
- else if(dw[0] == 'dbSS')
- {
+ } else if(dw[0] == 'dbSS') {
p += 8;
m_ps2_state.sync = true;
- }
- else
- {
- if(m_ps2_state.sync)
- {
+ } 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(int i = 0; i < wfe->dwInterleave; i += 16, k += 28)
+ for(int 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++)
+ 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++)
+ } 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)))
+ if(S_OK != (hr = Deliver(pBuff, wfe->nSamplesPerSec, wfe->nChannels))) {
return hr;
+ }
p += size;
}
@@ -1655,11 +1610,13 @@ HRESULT CMpaDecFilter::ProcessPS2ADPCM()
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_VORBIS
HRESULT CMpaDecFilter::ProcessVorbis()
{
- if(m_vorbis.vi.channels < 1 || m_vorbis.vi.channels > 6)
+ if(m_vorbis.vi.channels < 1 || m_vorbis.vi.channels > 6) {
return E_FAIL;
+ }
- if(m_buff.IsEmpty())
+ if(m_buff.IsEmpty()) {
return S_OK;
+ }
HRESULT hr = S_OK;
@@ -1670,31 +1627,30 @@ HRESULT CMpaDecFilter::ProcessVorbis()
op.b_o_s = 0;
op.packetno = m_vorbis.packetno++;
- if(vorbis_synthesis(&m_vorbis.vb, &op) == 0)
- {
+ if(vorbis_synthesis(&m_vorbis.vb, &op) == 0) {
vorbis_synthesis_blockin(&m_vorbis.vd, &m_vorbis.vb);
int samples;
float** pcm;
- while((samples = vorbis_synthesis_pcmout(&m_vorbis.vd, &pcm)) > 0)
- {
+ while((samples = vorbis_synthesis_pcmout(&m_vorbis.vd, &pcm)) > 0) {
const scmap_t& scmap = s_scmap_vorbis[m_vorbis.vi.channels-1];
CAtlArray<float> pBuff;
pBuff.SetCount(samples * scmap.nChannels);
float* dst = pBuff.GetData();
- for(int j = 0, ch = scmap.nChannels; j < ch; j++)
- {
+ for(int j = 0, ch = scmap.nChannels; j < ch; j++) {
float* src = pcm[scmap.ch[j]];
- for(int i = 0; i < samples; i++)
+ for(int i = 0; i < samples; i++) {
dst[j + i*ch] = src[i];
+ }
// dst[j + i*ch] = (float)max(min(src[i], 1<<24), -1<<24) / (1<<24);
}
- if(S_OK != (hr = Deliver(pBuff, m_vorbis.vi.rate, scmap.nChannels, scmap.dwChannelMask)))
+ if(S_OK != (hr = Deliver(pBuff, m_vorbis.vi.rate, scmap.nChannels, scmap.dwChannelMask))) {
break;
+ }
vorbis_synthesis_read(&m_vorbis.vd, samples);
}
@@ -1708,8 +1664,11 @@ HRESULT CMpaDecFilter::ProcessVorbis()
static inline float fscale(mad_fixed_t sample)
{
- if(sample >= MAD_F_ONE) sample = MAD_F_ONE - 1;
- else if(sample < -MAD_F_ONE) sample = -MAD_F_ONE;
+ if(sample >= MAD_F_ONE) {
+ sample = MAD_F_ONE - 1;
+ } else if(sample < -MAD_F_ONE) {
+ sample = -MAD_F_ONE;
+ }
return (float)sample / (1 << MAD_F_FRACBITS);
}
@@ -1730,12 +1689,9 @@ HRESULT CMpaDecFilter::ProcessMPA()
{
mad_stream_buffer(&m_stream, m_buff.GetData(), m_buff.GetCount());
- while(1)
- {
- if(mad_frame_decode(&m_frame, &m_stream) == -1)
- {
- if(m_stream.error == MAD_ERROR_BUFLEN)
- {
+ while(1) {
+ if(mad_frame_decode(&m_frame, &m_stream) == -1) {
+ if(m_stream.error == MAD_ERROR_BUFLEN) {
memmove(m_buff.GetData(), m_stream.this_frame, m_stream.bufend - m_stream.this_frame);
m_buff.SetCount(m_stream.bufend - m_stream.this_frame);
break;
@@ -1747,8 +1703,7 @@ HRESULT CMpaDecFilter::ProcessMPA()
}
- if(!MAD_RECOVERABLE(m_stream.error))
- {
+ if(!MAD_RECOVERABLE(m_stream.error)) {
TRACE(_T("*m_stream.error == %d\n"), m_stream.error);
return E_FAIL;
}
@@ -1772,8 +1727,7 @@ HRESULT CMpaDecFilter::ProcessMPA()
mad_synth_frame(&m_synth, &m_frame);
WAVEFORMATEX* wfein = (WAVEFORMATEX*)m_pInput->CurrentMediaType().Format();
- if(wfein->nChannels != m_synth.pcm.channels || wfein->nSamplesPerSec != m_synth.pcm.samplerate)
- {
+ if(wfein->nChannels != m_synth.pcm.channels || wfein->nSamplesPerSec != m_synth.pcm.samplerate) {
TRACE(_T("MAD channels %d %d samplerate %d %d \n"),wfein->nChannels , m_synth.pcm.channels, wfein->nSamplesPerSec , m_synth.pcm.samplerate);
//Some time this does happened - need more testing ...
//continue;
@@ -1786,15 +1740,17 @@ HRESULT CMpaDecFilter::ProcessMPA()
pBuff.SetCount(m_synth.pcm.length*m_synth.pcm.channels);
float* pDataOut = pBuff.GetData();
- for(unsigned short i = 0; i < m_synth.pcm.length; i++)
- {
+ for(unsigned short i = 0; i < m_synth.pcm.length; i++) {
*pDataOut++ = fscale(*left_ch++);
- if(m_synth.pcm.channels == 2) *pDataOut++ = fscale(*right_ch++);
+ if(m_synth.pcm.channels == 2) {
+ *pDataOut++ = fscale(*right_ch++);
+ }
}
HRESULT hr;
- if(S_OK != (hr = Deliver(pBuff, m_synth.pcm.samplerate, m_synth.pcm.channels)))
+ if(S_OK != (hr = Deliver(pBuff, m_synth.pcm.samplerate, m_synth.pcm.channels))) {
return hr;
+ }
}
return S_OK;
@@ -1807,12 +1763,12 @@ HRESULT CMpaDecFilter::GetDeliveryBuffer(IMediaSample** pSample, BYTE** pData)
*pData = NULL;
if(FAILED(hr = m_pOutput->GetDeliveryBuffer(pSample, NULL, NULL, 0))
- || FAILED(hr = (*pSample)->GetPointer(pData)))
+ || FAILED(hr = (*pSample)->GetPointer(pData))) {
return hr;
+ }
AM_MEDIA_TYPE* pmt = NULL;
- if(SUCCEEDED((*pSample)->GetMediaType(&pmt)) && pmt)
- {
+ if(SUCCEEDED((*pSample)->GetMediaType(&pmt)) && pmt) {
CMediaType mt = *pmt;
m_pOutput->SetMediaType(&mt);
DeleteMediaType(pmt);
@@ -1833,23 +1789,25 @@ HRESULT CMpaDecFilter::Deliver(CAtlArray<float>& pBuff, DWORD nSamplesPerSec, WO
int nSamples = pBuff.GetCount()/wfe->nChannels;
- if(FAILED(hr = ReconnectOutput(nSamples, mt)))
+ if(FAILED(hr = ReconnectOutput(nSamples, mt))) {
return hr;
+ }
CComPtr<IMediaSample> pOut;
BYTE* pDataOut = NULL;
- if(FAILED(GetDeliveryBuffer(&pOut, &pDataOut)))
+ 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 */)
+ //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)
- {
+ if(hr == S_OK) {
m_pOutput->SetMediaType(&mt);
pOut->SetMediaType(&mt);
}
@@ -1872,13 +1830,15 @@ HRESULT CMpaDecFilter::Deliver(CAtlArray<float>& pBuff, DWORD nSamplesPerSec, WO
// TODO: move this into the audio switcher
float sample_mul = 1;
- if(m_fNormalize)
- {
- for(int i = 0, len = pBuff.GetCount(); i < len; i++)
- {
+ if(m_fNormalize) {
+ for(int i = 0, len = pBuff.GetCount(); i < len; i++) {
float f = *pDataIn++;
- if(f < 0) f = -f;
- if(m_sample_max < f) m_sample_max = f;
+ if(f < 0) {
+ f = -f;
+ }
+ if(m_sample_max < f) {
+ m_sample_max = f;
+ }
}
sample_mul = 1.0f / m_sample_max;
pDataIn = pBuff.GetData();
@@ -1887,45 +1847,48 @@ HRESULT CMpaDecFilter::Deliver(CAtlArray<float>& pBuff, DWORD nSamplesPerSec, WO
bool fBoost = m_boost > 1;
double boost = 1+log10(m_boost);
- for(int i = 0, len = pBuff.GetCount(); i < len; i++)
- {
+ for(int i = 0, len = pBuff.GetCount(); i < len; i++) {
float f = *pDataIn++;
// TODO: move this into the audio switcher
- if(m_fNormalize)
+ if(m_fNormalize) {
f *= sample_mul;
+ }
- if(fBoost)
+ if(fBoost) {
f *= boost;
+ }
- if(f < -1) f = -1;
- else if(f > 1) f = 1;
+ if(f < -1) {
+ f = -1;
+ } else if(f > 1) {
+ f = 1;
+ }
#define round(x) ((x) > 0 ? (x) + 0.5 : (x) - 0.5)
- switch(sf)
- {
- default:
- case SF_PCM16:
- *(short*)pDataOut = (short)round(f * SHRT_MAX);
- pDataOut += sizeof(short);
- break;
- case SF_PCM24:
- { DWORD i24 = (DWORD)(int)round(f * ((1<<23)-1));
- *pDataOut++ = (BYTE)(i24);
- *pDataOut++ = (BYTE)(i24>>8);
- *pDataOut++ = (BYTE)(i24>>16);
- }
- break;
- case SF_PCM32:
- *(int*)pDataOut = (int)round(f * INT_MAX);
- pDataOut += sizeof(int);
- break;
- case SF_FLOAT32:
- *(float*)pDataOut = f;
- pDataOut += sizeof(float);
+ switch(sf) {
+ default:
+ case SF_PCM16:
+ *(short*)pDataOut = (short)round(f * SHRT_MAX);
+ pDataOut += sizeof(short);
+ break;
+ case SF_PCM24: {
+ DWORD i24 = (DWORD)(int)round(f * ((1<<23)-1));
+ *pDataOut++ = (BYTE)(i24);
+ *pDataOut++ = (BYTE)(i24>>8);
+ *pDataOut++ = (BYTE)(i24>>16);
+ }
break;
+ case SF_PCM32:
+ *(int*)pDataOut = (int)round((double)f * INT_MAX);
+ pDataOut += sizeof(int);
+ break;
+ case SF_FLOAT32:
+ *(float*)pDataOut = f;
+ pDataOut += sizeof(float);
+ break;
}
}
@@ -1941,19 +1904,26 @@ HRESULT CMpaDecFilter::Deliver(BYTE* pBuff, int size, int bit_rate, BYTE type)
WAVEFORMATEX* wfe = (WAVEFORMATEX*)mt.Format();
int length = 0;
- while(length < size+sizeof(WORD)*4) length += 0x800;
+ while(length < size+sizeof(WORD)*4) {
+ length += 0x800;
+ }
int size2 = 1i64 * wfe->nBlockAlign * wfe->nSamplesPerSec * size*8 / bit_rate;
- while(length < size2) length += 0x800;
- if(length > size2)
+ while(length < size2) {
+ length += 0x800;
+ }
+ if(length > size2) {
padded = true;
+ }
- if(FAILED(hr = ReconnectOutput(length / wfe->nBlockAlign, mt)))
+ if(FAILED(hr = ReconnectOutput(length / wfe->nBlockAlign, mt))) {
return hr;
+ }
CComPtr<IMediaSample> pOut;
BYTE* pDataOut = NULL;
- if(FAILED(GetDeliveryBuffer(&pOut, &pDataOut)))
+ if(FAILED(GetDeliveryBuffer(&pOut, &pDataOut))) {
return E_FAIL;
+ }
WORD* pDataOutW = (WORD*)pDataOut;
pDataOutW[0] = 0xf872;
@@ -1962,14 +1932,11 @@ HRESULT CMpaDecFilter::Deliver(BYTE* pBuff, int size, int bit_rate, BYTE type)
REFERENCE_TIME rtDur;
- if(!padded)
- {
+ if(!padded) {
rtDur = 10000000i64 * size*8 / bit_rate;
pDataOutW[3] = size*8;
_swab((char*)pBuff, (char*)&pDataOutW[4], size);
- }
- else
- {
+ } else {
const size_t blocks = (size + length - 1) / length;
rtDur = 10000000i64 * blocks * length*8 / bit_rate;
pDataOutW[3] = length*8;
@@ -1978,11 +1945,11 @@ HRESULT CMpaDecFilter::Deliver(BYTE* pBuff, int size, int bit_rate, BYTE type)
REFERENCE_TIME rtStart = m_rtStart, rtStop = m_rtStart + rtDur;
m_rtStart += rtDur;
- if(rtStart < 0)
+ if(rtStart < 0) {
return S_OK;
+ }
- if(hr == S_OK)
- {
+ if(hr == S_OK) {
m_pOutput->SetMediaType(&mt);
pOut->SetMediaType(&mt);
}
@@ -2005,35 +1972,37 @@ HRESULT CMpaDecFilter::ReconnectOutput(int nSamples, CMediaType& mt)
HRESULT hr;
CComQIPtr<IMemInputPin> pPin = m_pOutput->GetConnected();
- if(!pPin) return E_NOINTERFACE;
+ if(!pPin) {
+ return E_NOINTERFACE;
+ }
CComPtr<IMemAllocator> pAllocator;
- if(FAILED(hr = pPin->GetAllocator(&pAllocator)) || !pAllocator)
+ if(FAILED(hr = pPin->GetAllocator(&pAllocator)) || !pAllocator) {
return hr;
+ }
ALLOCATOR_PROPERTIES props, actual;
- if(FAILED(hr = pAllocator->GetProperties(&props)))
+ 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)
- {
+ 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()))
+ || 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)
- {
+ if(props.cBuffers > actual.cBuffers || props.cbBuffer > actual.cbBuffer) {
NotifyEvent(EC_ERRORABORT, hr, 0);
return E_FAIL;
}
@@ -2059,30 +2028,29 @@ CMediaType CMpaDecFilter::CreateMediaType(MPCSampleFormat sf, DWORD nSamplesPerS
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;
+ 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))
+ if(dwChannelMask == 0 && (sf == SF_PCM24 || sf == SF_PCM32)) {
dwChannelMask = nChannels == 2 ? (SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT) : SPEAKER_FRONT_CENTER;
+ }
- if(dwChannelMask)
- {
+ if(dwChannelMask) {
wfex.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
wfex.Format.cbSize = sizeof(wfex) - sizeof(wfex.Format);
wfex.dwChannelMask = dwChannelMask;
@@ -2105,14 +2073,12 @@ CMediaType CMpaDecFilter::CreateMediaTypeSPDIF()
HRESULT CMpaDecFilter::CheckInputType(const CMediaType* mtIn)
{
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_LPCM
- if(mtIn->subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO)
- {
+ 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))
+ 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_HDMV_LPCM_AUDIO)
- {
+ }
+ } else if(mtIn->subtype == MEDIASUBTYPE_HDMV_LPCM_AUDIO) {
WAVEFORMATEX* wfe = (WAVEFORMATEX*)mtIn->Format();
UNUSED_ALWAYS(wfe);
return S_OK;
@@ -2121,46 +2087,45 @@ HRESULT CMpaDecFilter::CheckInputType(const CMediaType* mtIn)
if(0) {}
#endif
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_PS2AUD
- else if(mtIn->subtype == MEDIASUBTYPE_PS2_ADPCM)
- {
+ else if(mtIn->subtype == MEDIASUBTYPE_PS2_ADPCM) {
WAVEFORMATEXPS2* wfe = (WAVEFORMATEXPS2*)mtIn->Format();
UNUSED_ALWAYS(wfe);
- if(wfe->dwInterleave & 0xf) // has to be a multiple of the block size (16 bytes)
+ 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_VORBIS
- else if(mtIn->subtype == MEDIASUBTYPE_Vorbis2)
- {
- if(!m_vorbis.init(*mtIn))
+ else if(mtIn->subtype == MEDIASUBTYPE_Vorbis2) {
+ if(!m_vorbis.init(*mtIn)) {
return VFW_E_TYPE_NOT_ACCEPTED;
+ }
}
#endif
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_FLAC
- else if(mtIn->subtype == MEDIASUBTYPE_FLAC_FRAMED)
- {
+ else if(mtIn->subtype == MEDIASUBTYPE_FLAC_FRAMED) {
return S_OK;
}
#endif
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_NELLYMOSER
- else if(mtIn->subtype == MEDIASUBTYPE_NELLYMOSER)
- {
+ else if(mtIn->subtype == MEDIASUBTYPE_NELLYMOSER) {
return S_OK;
}
#endif
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_AAC
- else if(mtIn->subtype == MEDIASUBTYPE_AAC)
- {
+ else if(mtIn->subtype == MEDIASUBTYPE_AAC) {
// Reject invalid AAC stream on connection
- if (!m_aac_state.init(*mtIn)) return VFW_E_TYPE_NOT_ACCEPTED;
+ if (!m_aac_state.init(*mtIn)) {
+ return VFW_E_TYPE_NOT_ACCEPTED;
+ }
}
#endif
- for(int i = 0; i < countof(sudPinTypesIn); i++)
- {
+ for(int i = 0; i < countof(sudPinTypesIn); i++) {
if(*sudPinTypesIn[i].clsMajorType == mtIn->majortype
- && *sudPinTypesIn[i].clsMinorType == mtIn->subtype)
+ && *sudPinTypesIn[i].clsMinorType == mtIn->subtype) {
return S_OK;
+ }
}
return VFW_E_TYPE_NOT_ACCEPTED;
@@ -2177,7 +2142,9 @@ HRESULT CMpaDecFilter::CheckTransform(const CMediaType* mtIn, const CMediaType*
HRESULT CMpaDecFilter::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties)
{
- if(m_pInput->IsConnected() == FALSE) return E_UNEXPECTED;
+ if(m_pInput->IsConnected() == FALSE) {
+ return E_UNEXPECTED;
+ }
CMediaType& mt = m_pInput->CurrentMediaType();
WAVEFORMATEX* wfe = (WAVEFORMATEX*)mt.Format();
@@ -2191,8 +2158,9 @@ HRESULT CMpaDecFilter::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PRO
HRESULT hr;
ALLOCATOR_PROPERTIES Actual;
- if(FAILED(hr = pAllocator->SetProperties(pProperties, &Actual)))
+ if(FAILED(hr = pAllocator->SetProperties(pProperties, &Actual))) {
return hr;
+ }
return pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer
? E_FAIL
@@ -2201,36 +2169,41 @@ HRESULT CMpaDecFilter::DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PRO
HRESULT CMpaDecFilter::GetMediaType(int iPosition, CMediaType* pmt)
{
- if(m_pInput->IsConnected() == FALSE) return E_UNEXPECTED;
+ if(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;
+ }
CMediaType mt = m_pInput->CurrentMediaType();
const GUID& subtype = mt.subtype;
WAVEFORMATEX* wfe = (WAVEFORMATEX*)mt.Format();
- if (wfe == NULL) return E_INVALIDARG;
+ 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))
- {
+ || GetSpeakerConfig(dts) < 0 && (subtype == MEDIASUBTYPE_DTS || subtype == MEDIASUBTYPE_WAVE_DTS)) {
*pmt = CreateMediaTypeSPDIF();
}
#else
if(0) {}
#endif
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_VORBIS
- else if(subtype == MEDIASUBTYPE_Vorbis2)
- {
+ else if(subtype == MEDIASUBTYPE_Vorbis2) {
*pmt = CreateMediaType(GetSampleFormat(), m_vorbis.vi.rate, m_vorbis.vi.channels);
}
#endif
- else
- {
+ else {
*pmt = CreateMediaType(GetSampleFormat(), wfe->nSamplesPerSec, min(2, wfe->nChannels));
}
@@ -2240,7 +2213,9 @@ HRESULT CMpaDecFilter::GetMediaType(int iPosition, CMediaType* pmt)
HRESULT CMpaDecFilter::StartStreaming()
{
HRESULT hr = __super::StartStreaming();
- if(FAILED(hr)) return hr;
+ if(FAILED(hr)) {
+ return hr;
+ }
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_AC3
m_a52_state = a52_init(0);
@@ -2316,7 +2291,9 @@ STDMETHODIMP_(MPCSampleFormat) CMpaDecFilter::GetSampleFormat()
STDMETHODIMP CMpaDecFilter::SetNormalize(bool fNormalize)
{
CAutoLock cAutoLock(&m_csProps);
- if(m_fNormalize != fNormalize) m_sample_max = 0.1f;
+ if(m_fNormalize != fNormalize) {
+ m_sample_max = 0.1f;
+ }
m_fNormalize = fNormalize;
return S_OK;
}
@@ -2330,29 +2307,38 @@ STDMETHODIMP_(bool) CMpaDecFilter::GetNormalize()
STDMETHODIMP CMpaDecFilter::SetSpeakerConfig(enctype et, int sc)
{
CAutoLock cAutoLock(&m_csProps);
- if(et >= 0 && et < etlast) m_iSpeakerConfig[et] = sc;
+ 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];
+ 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;
+ 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];
+ if(et >= 0 && et < etlast) {
+ return m_fDynamicRangeControl[et];
+ }
return false;
}
@@ -2379,8 +2365,7 @@ STDMETHODIMP CMpaDecFilter::SaveSettings()
{
CAutoLock cAutoLock(&m_csProps);
CRegKey key;
- if(ERROR_SUCCESS == key.Create(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPEG Audio Decoder")))
- {
+ if(ERROR_SUCCESS == key.Create(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPEG Audio Decoder"))) {
key.SetDWORDValue(_T("SampleFormat"), m_iSampleFormat);
key.SetDWORDValue(_T("Normalize"), m_fNormalize);
key.SetDWORDValue(_T("Boost"), *(DWORD*)&m_boost);
@@ -2411,12 +2396,13 @@ STDMETHODIMP CMpaDecFilter::CreatePage(const GUID& guid, IPropertyPage** ppPage)
{
CheckPointer(ppPage, E_POINTER);
- if(*ppPage != NULL) return E_INVALIDARG;
+ if(*ppPage != NULL) {
+ return E_INVALIDARG;
+ }
HRESULT hr;
- if(guid == __uuidof(CMpaDecSettingsWnd))
- {
+ if(guid == __uuidof(CMpaDecSettingsWnd)) {
(*ppPage = DNew CInternalPropertyPageTempl<CMpaDecSettingsWnd>(NULL, &hr))->AddRef();
}
@@ -2437,10 +2423,12 @@ CMpaDecInputPin::CMpaDecInputPin(CTransformFilter* pFilter, HRESULT* phr, LPWSTR
// aac_state_t
//
-aac_state_t::aac_state_t() : h(NULL), freq(0), channels(0) {
+aac_state_t::aac_state_t() : h(NULL), freq(0), channels(0)
+{
open();
}
-aac_state_t::~aac_state_t() {
+aac_state_t::~aac_state_t()
+{
close();
}
@@ -2448,7 +2436,9 @@ bool aac_state_t::open()
{
close();
h = NeAACDecOpen();
- if(!h) return false;
+ if(!h) {
+ return false;
+ }
NeAACDecConfigurationPtr c = NeAACDecGetCurrentConfiguration(h);
c->outputFormat = FAAD_FMT_FLOAT;
NeAACDecSetConfiguration(h, c);
@@ -2457,16 +2447,19 @@ bool aac_state_t::open()
void aac_state_t::close()
{
- if(h) NeAACDecClose(h);
+ if(h) {
+ NeAACDecClose(h);
+ }
h = NULL;
}
bool aac_state_t::init(const CMediaType& mt)
{
if(mt.subtype != MEDIASUBTYPE_AAC
- && mt.subtype != MEDIASUBTYPE_MP4A
- && mt.subtype != MEDIASUBTYPE_mp4a)
- return true; // nothing to do
+ && mt.subtype != MEDIASUBTYPE_MP4A
+ && mt.subtype != MEDIASUBTYPE_mp4a) {
+ return true; // nothing to do
+ }
open();
const WAVEFORMATEX* wfe = (WAVEFORMATEX*)mt.Format();
@@ -2502,8 +2495,9 @@ void vorbis_state_t::clear()
bool vorbis_state_t::init(const CMediaType& mt)
{
- if(mt.subtype != MEDIASUBTYPE_Vorbis2)
- return true; // nothing to do
+ if(mt.subtype != MEDIASUBTYPE_Vorbis2) {
+ return true; // nothing to do
+ }
clear();
@@ -2521,8 +2515,9 @@ bool vorbis_state_t::init(const CMediaType& mt)
op.b_o_s = 1;
op.packetno = packetno++;
- if(vorbis_synthesis_headerin(&vi, &vc, &op) < 0)
+ if(vorbis_synthesis_headerin(&vi, &vc, &op) < 0) {
return false;
+ }
memset(&op, 0, sizeof(op));
op.packet = (fmt += vf->HeaderSize[0]);
@@ -2530,8 +2525,9 @@ bool vorbis_state_t::init(const CMediaType& mt)
op.b_o_s = 0;
op.packetno = packetno++;
- if(vorbis_synthesis_headerin(&vi, &vc, &op) < 0)
+ if(vorbis_synthesis_headerin(&vi, &vc, &op) < 0) {
return false;
+ }
memset(&op, 0, sizeof(op));
op.packet = (fmt += vf->HeaderSize[1]);
@@ -2539,19 +2535,23 @@ bool vorbis_state_t::init(const CMediaType& mt)
op.b_o_s = 0;
op.packetno = packetno++;
- if(vorbis_synthesis_headerin(&vi, &vc, &op) < 0)
+ if(vorbis_synthesis_headerin(&vi, &vc, &op) < 0) {
return false;
+ }
postgain = 1.0;
- if(vorbis_comment_query_count(&vc, "LWING_GAIN"))
+ if(vorbis_comment_query_count(&vc, "LWING_GAIN")) {
postgain = atof(vorbis_comment_query(&vc, "LWING_GAIN", 0));
+ }
- if(vorbis_comment_query_count(&vc, "POSTGAIN"))
+ if(vorbis_comment_query_count(&vc, "POSTGAIN")) {
postgain = atof(vorbis_comment_query(&vc, "POSTGAIN", 0));
+ }
- if(vorbis_comment_query_count(&vc, "REPLAYGAIN_TRACK_GAIN"))
+ if(vorbis_comment_query_count(&vc, "REPLAYGAIN_TRACK_GAIN")) {
postgain = pow(10.0, atof(vorbis_comment_query(&vc, "REPLAYGAIN_TRACK_GAIN", 0)) / 20.0);
+ }
vorbis_synthesis_init(&vd, &vi);
vorbis_block_init(&vd, &vb);
@@ -2568,8 +2568,7 @@ void CMpaDecFilter::FlacFillBuffer(BYTE buffer[], size_t *bytes)
{
UINT nSize = min (*bytes, m_buff.GetCount());
- if (nSize > 0)
- {
+ if (nSize > 0) {
memcpy_s (buffer, *bytes, m_buff.GetData(), nSize);
memmove(m_buff.GetData(), m_buff.GetData() + nSize, m_buff.GetCount() - nSize);
m_buff.SetCount(m_buff.GetCount() - nSize);
@@ -2588,31 +2587,26 @@ void CMpaDecFilter::FlacDeliverBuffer (unsigned blocksize, const __int32 * cons
scmap_t& scmap = m_scmap_default[wfein->nChannels-1];
- switch (wfein->wBitsPerSample)
- {
- case 16 :
- for(unsigned i = 0; i < blocksize; i++)
- {
- for(int nChannel = 0; nChannel < wfein->nChannels; nChannel++)
- {
- FLAC__int16 nVal = (FLAC__int16)buffer[nChannel][i];
- *pDataOut = (float)nVal / SHRT_MAX;
- pDataOut++;
+ switch (wfein->wBitsPerSample) {
+ case 16 :
+ for(unsigned i = 0; i < blocksize; i++) {
+ for(int nChannel = 0; nChannel < wfein->nChannels; nChannel++) {
+ FLAC__int16 nVal = (FLAC__int16)buffer[nChannel][i];
+ *pDataOut = (float)nVal / SHRT_MAX;
+ pDataOut++;
+ }
}
- }
- break;
- case 20 :
- case 24 :
- for(unsigned i = 0; i < blocksize; i++)
- {
- for(int nChannel = 0; nChannel < wfein->nChannels; nChannel++)
- {
- FLAC__int32 nVal = (FLAC__int32)buffer[nChannel][i];
- *pDataOut = (float)nVal / INT24_MAX;
- pDataOut++;
+ break;
+ case 20 :
+ case 24 :
+ for(unsigned i = 0; i < blocksize; i++) {
+ for(int nChannel = 0; nChannel < wfein->nChannels; nChannel++) {
+ FLAC__int32 nVal = (FLAC__int32)buffer[nChannel][i];
+ *pDataOut = (float)nVal / INT24_MAX;
+ pDataOut++;
+ }
}
- }
- break;
+ break;
}
m_flac.hr = Deliver(pBuff, wfein->nSamplesPerSec, wfein->nChannels, scmap.dwChannelMask);
@@ -2648,11 +2642,9 @@ static void StreamDecoderMetadata(const FLAC__StreamDecoder *decoder, const FLAC
void CMpaDecFilter::FlacInitDecoder()
{
- if (!m_flac.pDecoder)
- {
+ if (!m_flac.pDecoder) {
m_flac.pDecoder = FLAC__stream_decoder_new();
- if (m_flac.pDecoder)
- {
+ if (m_flac.pDecoder) {
FLAC__stream_decoder_init_stream ((FLAC__StreamDecoder*)m_flac.pDecoder,
StreamDecoderRead,
NULL,
@@ -2664,9 +2656,7 @@ void CMpaDecFilter::FlacInitDecoder()
StreamDecoderError,
this);
}
- }
- else
- {
+ } else {
FLAC__stream_decoder_reset ((FLAC__StreamDecoder*)m_flac.pDecoder);
}
}
@@ -2674,8 +2664,7 @@ void CMpaDecFilter::FlacInitDecoder()
void CMpaDecFilter::flac_stream_finish()
{
- if (m_flac.pDecoder)
- {
+ if (m_flac.pDecoder) {
FLAC__stream_decoder_delete ((FLAC__StreamDecoder*)m_flac.pDecoder);
m_flac.pDecoder = NULL;
}
@@ -2697,93 +2686,86 @@ HRESULT CMpaDecFilter::DeliverFFmpeg(int nCodecId, BYTE* p, int buffsize, int& s
size = 0;
if (!m_pAVCtx || nCodecId != m_pAVCtx->codec_id)
- if (!InitFFmpeg (nCodecId)) return E_FAIL;
+ if (!InitFFmpeg (nCodecId)) {
+ return E_FAIL;
+ }
- while (buffsize > 0)
- {
+ while (buffsize > 0) {
BYTE* pParserData;
int nParserLength = AVCODEC_MAX_AUDIO_FRAME_SIZE;
int nPCMLength = AVCODEC_MAX_AUDIO_FRAME_SIZE;
int nRet;
- if (m_pAVCtx->codec_id != CODEC_ID_MLP)
- {
+ if (m_pAVCtx->codec_id != CODEC_ID_MLP) {
// Parse buffer
nRet = av_parser_parse( m_pParser, m_pAVCtx, (uint8_t**)&pParserData, &nParserLength,
(const uint8_t*)p, buffsize, AV_NOPTS_VALUE, AV_NOPTS_VALUE);
- if (nRet<0 || (nRet==0 && nParserLength==0))
+ if (nRet<0 || (nRet==0 && nParserLength==0)) {
return S_OK;
+ }
buffsize -= nRet;
p += nRet;
size += nRet;
// Decode frame
- if (nParserLength > 0)
- {
+ if (nParserLength > 0) {
nRet = avcodec_decode_audio2(m_pAVCtx, (int16_t*)m_pPCMData, &nPCMLength, (const uint8_t*)pParserData, nParserLength);
- if (nRet<0 || (nRet==0 &&nPCMLength==0))
+ if (nRet<0 || (nRet==0 &&nPCMLength==0)) {
continue;
- }
- else
+ }
+ } else {
continue;
- }
- else
- {
+ }
+ } else {
// No parsing for MLP : decode only
nRet = avcodec_decode_audio2(m_pAVCtx, (int16_t*)m_pPCMData, &nPCMLength, (const uint8_t*)p, buffsize);
- if (nRet<0 || (nRet==0 && nParserLength==0))
+ if (nRet<0 || (nRet==0 && nParserLength==0)) {
return S_OK;
+ }
buffsize -= nRet;
p += nRet;
size += nRet;
}
- if (nPCMLength > 0)
- {
+ if (nPCMLength > 0) {
WAVEFORMATEX* wfein = (WAVEFORMATEX*)m_pInput->CurrentMediaType().Format();
CAtlArray<float> pBuff;
int nRemap;
float* pDataOut;
nRemap = FFGetChannelMap (m_pAVCtx);
- if (nRemap >=0)
- {
+ if (nRemap >=0) {
scmap_t& scmap = s_scmap_ac3[nRemap];
- switch (m_pAVCtx->sample_fmt)
- {
- case SAMPLE_FMT_S16 :
- pBuff.SetCount (nPCMLength / 2);
- pDataOut = pBuff.GetData();
-
- for (int i=0; i<pBuff.GetCount()/m_pAVCtx->channels; i++)
- {
- for(int ch=0; ch<m_pAVCtx->channels; ch++)
- {
- *pDataOut = (float)((int16_t*)m_pPCMData) [scmap.ch[ch]+i*m_pAVCtx->channels] / SHRT_MAX;
- pDataOut++;
+ switch (m_pAVCtx->sample_fmt) {
+ case SAMPLE_FMT_S16 :
+ pBuff.SetCount (nPCMLength / 2);
+ pDataOut = pBuff.GetData();
+
+ for (int i=0; i<pBuff.GetCount()/m_pAVCtx->channels; i++) {
+ for(int ch=0; ch<m_pAVCtx->channels; ch++) {
+ *pDataOut = (float)((int16_t*)m_pPCMData) [scmap.ch[ch]+i*m_pAVCtx->channels] / SHRT_MAX;
+ pDataOut++;
+ }
}
- }
- break;
+ break;
- case SAMPLE_FMT_S32 :
- pBuff.SetCount (nPCMLength / 4);
- pDataOut = pBuff.GetData();
+ case SAMPLE_FMT_S32 :
+ pBuff.SetCount (nPCMLength / 4);
+ pDataOut = pBuff.GetData();
- for (int i=0; i<pBuff.GetCount()/m_pAVCtx->channels; i++)
- {
- for(int ch=0; ch<m_pAVCtx->channels; ch++)
- {
- *pDataOut = (float)((int32_t*)m_pPCMData) [scmap.ch[ch]+i*m_pAVCtx->channels] / INT_MAX;
- pDataOut++;
+ for (int i=0; i<pBuff.GetCount()/m_pAVCtx->channels; i++) {
+ for(int ch=0; ch<m_pAVCtx->channels; ch++) {
+ *pDataOut = (float)((int32_t*)m_pPCMData) [scmap.ch[ch]+i*m_pAVCtx->channels] / INT_MAX;
+ pDataOut++;
+ }
}
- }
- break;
- default :
- ASSERT(FALSE);
- break;
+ break;
+ default :
+ ASSERT(FALSE);
+ break;
}
hr = Deliver(pBuff, m_pAVCtx->sample_rate, m_pAVCtx->channels, scmap.dwChannelMask);
}
@@ -2801,8 +2783,7 @@ HRESULT CMpaDecFilter::DeliverFFmpeg(int nCodecId, BYTE* p, int buffsize, int& s
HRESULT hr = S_OK;
int nPCMLength = 0;
if (!m_pAVCtx || nCodecId != m_pAVCtx->codec_id)
- if (!InitFFmpeg (nCodecId))
- {
+ if (!InitFFmpeg (nCodecId)) {
size = 0;
return E_FAIL;
}
@@ -2810,14 +2791,12 @@ HRESULT CMpaDecFilter::DeliverFFmpeg(int nCodecId, BYTE* p, int buffsize, int& s
CAtlArray<float> pBuffOut;
scmap_t* scmap = NULL;
- AVPacket avpkt;
- av_init_packet(&avpkt);
+ AVPacket avpkt;
+ av_init_packet(&avpkt);
- while (buffsize > 0)
- {
+ while (buffsize > 0) {
nPCMLength = AVCODEC_MAX_AUDIO_FRAME_SIZE;
- if (buffsize+FF_INPUT_BUFFER_PADDING_SIZE > m_nFFBufferSize)
- {
+ if (buffsize+FF_INPUT_BUFFER_PADDING_SIZE > m_nFFBufferSize) {
m_nFFBufferSize = buffsize+FF_INPUT_BUFFER_PADDING_SIZE;
m_pFFBuffer = (BYTE*)realloc(m_pFFBuffer, m_nFFBufferSize);
@@ -2846,60 +2825,52 @@ HRESULT CMpaDecFilter::DeliverFFmpeg(int nCodecId, BYTE* p, int buffsize, int& s
}
size += used_byte;//
- if ( nPCMLength>0)
- {
+ if ( nPCMLength>0) {
WAVEFORMATEX* wfein = (WAVEFORMATEX*)m_pInput->CurrentMediaType().Format();
CAtlArray<float> pBuff;
int nRemap;
float* pDataOut;
nRemap = FFGetChannelMap (m_pAVCtx);
- if (nRemap >=0)
- {
+ if (nRemap >=0) {
- switch (nCodecId)
- {
- case CODEC_ID_EAC3 :
- scmap = &m_ffmpeg_ac3[FFGetChannelMap(m_pAVCtx)];
- break;
- default :
- scmap = &m_scmap_default[m_pAVCtx->channels-1];
- break;
+ switch (nCodecId) {
+ case CODEC_ID_EAC3 :
+ scmap = &m_ffmpeg_ac3[FFGetChannelMap(m_pAVCtx)];
+ break;
+ default :
+ scmap = &m_scmap_default[m_pAVCtx->channels-1];
+ break;
}
- switch (m_pAVCtx->sample_fmt)
- {
- case SAMPLE_FMT_S16 :
- pBuff.SetCount (nPCMLength / 2);
- pDataOut = pBuff.GetData();
-
- for (size_t i=0; i<pBuff.GetCount()/m_pAVCtx->channels; i++)
- {
- for(int ch=0; ch<m_pAVCtx->channels; ch++)
- {
- *pDataOut = (float)((int16_t*)m_pPCMData) [scmap->ch[ch]+i*m_pAVCtx->channels] / SHRT_MAX;
- pDataOut++;
+ switch (m_pAVCtx->sample_fmt) {
+ case SAMPLE_FMT_S16 :
+ pBuff.SetCount (nPCMLength / 2);
+ pDataOut = pBuff.GetData();
+
+ for (size_t i=0; i<pBuff.GetCount()/m_pAVCtx->channels; i++) {
+ for(int ch=0; ch<m_pAVCtx->channels; ch++) {
+ *pDataOut = (float)((int16_t*)m_pPCMData) [scmap->ch[ch]+i*m_pAVCtx->channels] / SHRT_MAX;
+ pDataOut++;
+ }
}
- }
- break;
+ break;
- case SAMPLE_FMT_S32 :
- pBuff.SetCount (nPCMLength / 4);
- pDataOut = pBuff.GetData();
+ case SAMPLE_FMT_S32 :
+ pBuff.SetCount (nPCMLength / 4);
+ pDataOut = pBuff.GetData();
- for (size_t i=0; i<pBuff.GetCount()/m_pAVCtx->channels; i++)
- {
- for(int ch=0; ch<m_pAVCtx->channels; ch++)
- {
- *pDataOut = (float)((int32_t*)m_pPCMData) [scmap->ch[ch]+i*m_pAVCtx->channels] / INT_MAX;
- pDataOut++;
+ for (size_t i=0; i<pBuff.GetCount()/m_pAVCtx->channels; i++) {
+ for(int ch=0; ch<m_pAVCtx->channels; ch++) {
+ *pDataOut = (float)((int32_t*)m_pPCMData) [scmap->ch[ch]+i*m_pAVCtx->channels] / INT_MAX;
+ pDataOut++;
+ }
}
- }
- break;
- default :
- ASSERT(FALSE);
- break;
+ break;
+ default :
+ ASSERT(FALSE);
+ break;
}
if(pBuff.GetCount() > 0) {
@@ -2916,8 +2887,9 @@ HRESULT CMpaDecFilter::DeliverFFmpeg(int nCodecId, BYTE* p, int buffsize, int& s
buffsize -= used_byte;
pDataInBuff += used_byte;
}
- if(pBuffOut.GetCount() > 0 && scmap)
+ if(pBuffOut.GetCount() > 0 && scmap) {
hr = Deliver(pBuffOut, m_pAVCtx->sample_rate, scmap->nChannels, scmap->dwChannelMask);
+ }
return hr;
}
#endif
@@ -2933,13 +2905,13 @@ bool CMpaDecFilter::InitFFmpeg(int nCodecId)
av_log_set_callback(LogLibAVCodec);
#endif
- if (m_pAVCodec) ffmpeg_stream_finish();
+ if (m_pAVCodec) {
+ ffmpeg_stream_finish();
+ }
m_pAVCodec = avcodec_find_decoder((CodecID)nCodecId);
- if (m_pAVCodec)
- {
- if (nCodecId==CODEC_ID_AMR_NB || nCodecId== CODEC_ID_AMR_WB)
- {
+ if (m_pAVCodec) {
+ if (nCodecId==CODEC_ID_AMR_NB || nCodecId== CODEC_ID_AMR_WB) {
wfein->nChannels = 1;
wfein->nSamplesPerSec = 8000;
}
@@ -2955,14 +2927,15 @@ bool CMpaDecFilter::InitFFmpeg(int nCodecId)
m_pAVCtx->codec_id = (CodecID)nCodecId;
m_pParser = av_parser_init(nCodecId);
- if (avcodec_open(m_pAVCtx,m_pAVCodec)>=0)
- {
+ if (avcodec_open(m_pAVCtx,m_pAVCodec)>=0) {
m_pPCMData = (BYTE*)FF_aligned_malloc (AVCODEC_MAX_AUDIO_FRAME_SIZE+FF_INPUT_BUFFER_PADDING_SIZE, 64);
bRet = true;
}
}
- if (!bRet) ffmpeg_stream_finish();
+ if (!bRet) {
+ ffmpeg_stream_finish();
+ }
return bRet;
}
@@ -2977,20 +2950,20 @@ void CMpaDecFilter::LogLibAVCodec(void* par,int level,const char *fmt,va_list va
void CMpaDecFilter::ffmpeg_stream_finish()
{
m_pAVCodec = NULL;
- if (m_pAVCtx)
- {
+ if (m_pAVCtx) {
avcodec_close (m_pAVCtx);
av_free (m_pAVCtx);
m_pAVCtx = NULL;
}
- if (m_pParser)
- {
+ if (m_pParser) {
av_parser_close (m_pParser);
m_pParser = NULL;
}
- if (m_pPCMData) FF_aligned_free (m_pPCMData);
+ if (m_pPCMData) {
+ FF_aligned_free (m_pPCMData);
+ }
}
#pragma endregion
diff --git a/src/filters/transform/MpaDecFilter/MpaDecFilter.h b/src/filters/transform/MpaDecFilter/MpaDecFilter.h
index 16dc0c509..b26f98c82 100644
--- a/src/filters/transform/MpaDecFilter/MpaDecFilter.h
+++ b/src/filters/transform/MpaDecFilter/MpaDecFilter.h
@@ -38,8 +38,7 @@
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_AAC
-struct aac_state_t
-{
+struct aac_state_t {
void* h; // NeAACDecHandle h;
DWORD freq;
BYTE channels;
@@ -52,8 +51,7 @@ struct aac_state_t
};
#endif
-struct ps2_state_t
-{
+struct ps2_state_t {
bool sync;
double a[2], b[2];
ps2_state_t() {
@@ -66,8 +64,7 @@ struct ps2_state_t
};
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_VORBIS
-struct vorbis_state_t
-{
+struct vorbis_state_t {
vorbis_info vi;
vorbis_comment vc;
vorbis_block vb;
@@ -84,8 +81,7 @@ struct vorbis_state_t
#endif
#if defined(REGISTER_FILTER) | INTERNAL_DECODER_FLAC
-struct flac_state_t
-{
+struct flac_state_t {
void* pDecoder;
HRESULT hr;
};
diff --git a/src/filters/transform/MpaDecFilter/MpaDecSettingsWnd.cpp b/src/filters/transform/MpaDecFilter/MpaDecSettingsWnd.cpp
index cf56cd629..cf5bc2a91 100644
--- a/src/filters/transform/MpaDecFilter/MpaDecSettingsWnd.cpp
+++ b/src/filters/transform/MpaDecFilter/MpaDecSettingsWnd.cpp
@@ -48,9 +48,13 @@ bool CMpaDecSettingsWnd::OnConnect(const CInterfaceList<IUnknown, &IID_IUnknown>
m_pMDF.Release();
POSITION pos = pUnks.GetHeadPosition();
- while(pos && !(m_pMDF = pUnks.GetNext(pos)));
+ 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);
@@ -70,18 +74,17 @@ void CMpaDecSettingsWnd::OnDisconnect()
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("");
}
}
@@ -105,8 +108,9 @@ bool CMpaDecSettingsWnd::OnActivate()
m_outputformat_combo.SetCurSel(0);
for(int i = 0; i < m_outputformat_combo.GetCount(); i++)
- if((int)m_outputformat_combo.GetItemData(i) == m_outputformat)
+ if((int)m_outputformat_combo.GetItemData(i) == m_outputformat) {
m_outputformat_combo.SetCurSel(i);
+ }
p.y += 30;
@@ -130,8 +134,9 @@ bool CMpaDecSettingsWnd::OnActivate()
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)
+ if((int)m_ac3spkcfg_combo.GetItemData(i) == sel) {
m_ac3spkcfg_combo.SetCurSel(i);
+ }
m_ac3spkcfg_combo.GetWindowRect(r);
ScreenToClient(r);
@@ -139,8 +144,7 @@ bool CMpaDecSettingsWnd::OnActivate()
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)
- {
+ 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);
}
@@ -171,8 +175,9 @@ bool CMpaDecSettingsWnd::OnActivate()
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)
+ if((int)m_dtsspkcfg_combo.GetItemData(i) == sel) {
m_dtsspkcfg_combo.SetCurSel(i);
+ }
m_dtsspkcfg_combo.GetWindowRect(r);
ScreenToClient(r);
@@ -180,8 +185,7 @@ bool CMpaDecSettingsWnd::OnActivate()
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)
- {
+ 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);
}
@@ -202,8 +206,9 @@ bool CMpaDecSettingsWnd::OnActivate()
m_aacdownmix_check.Create(ResStr(IDS_MPADECSETTINGSWND_12), dwStyle|BS_AUTOCHECKBOX, CRect(p + CPoint(10, 0), CSize(150, m_fontheight)), this, IDC_PP_CHECK3);
m_aacdownmix_check.SetCheck(m_aacdownmix);
- for(CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow())
+ for(CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow()) {
pWnd->SetFont(&m_font, FALSE);
+ }
return true;
}
@@ -212,12 +217,20 @@ void CMpaDecSettingsWnd::OnDeactivate()
{
m_outputformat = m_outputformat_combo.GetItemData(m_outputformat_combo.GetCurSel());
m_ac3spkcfg = 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;
+ 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 = 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;
+ 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_aacdownmix = !!m_aacdownmix_check.GetCheck();
}
@@ -226,8 +239,7 @@ bool CMpaDecSettingsWnd::OnApply()
{
OnDeactivate();
- if(m_pMDF)
- {
+ if(m_pMDF) {
m_pMDF->SetSampleFormat((MPCSampleFormat)m_outputformat);
m_pMDF->SetSpeakerConfig(IMpaDecFilter::ac3, m_ac3spkcfg);
m_pMDF->SetDynamicRangeControl(IMpaDecFilter::ac3, m_ac3drc);
diff --git a/src/filters/transform/MpaDecFilter/MpaDecSettingsWnd.h b/src/filters/transform/MpaDecFilter/MpaDecSettingsWnd.h
index 143369335..7e1ab6b2c 100644
--- a/src/filters/transform/MpaDecFilter/MpaDecSettingsWnd.h
+++ b/src/filters/transform/MpaDecFilter/MpaDecSettingsWnd.h
@@ -40,8 +40,7 @@ class __declspec(uuid("24103041-884B-4772-B0D3-A600E7CBFEC7"))
bool m_aacdownmix;
DolbyDigitalMode m_ddmode;
- enum
- {
+ enum {
IDC_PP_RADIO1 = 10000,
IDC_PP_RADIO2,
IDC_PP_RADIO3,
diff --git a/src/filters/transform/Mpeg2DecFilter/IMpeg2DecFilter.h b/src/filters/transform/Mpeg2DecFilter/IMpeg2DecFilter.h
index a36174c94..054337be6 100644
--- a/src/filters/transform/Mpeg2DecFilter/IMpeg2DecFilter.h
+++ b/src/filters/transform/Mpeg2DecFilter/IMpeg2DecFilter.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -24,8 +24,8 @@
typedef enum {DIAuto, DIWeave, DIBlend, DIBob, DIFieldShift, DIELA} ditype;
interface __declspec(uuid("0ABEAA65-0317-47B9-AE1D-D9EA905AFD25"))
-IMpeg2DecFilter : public IUnknown
-{
+IMpeg2DecFilter :
+public IUnknown {
STDMETHOD(SetDeinterlaceMethod(ditype di)) = 0;
STDMETHOD_(ditype, GetDeinterlaceMethod()) = 0;
diff --git a/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.cpp b/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.cpp
index 75f777984..d2e74b47e 100644
--- a/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.cpp
+++ b/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -40,8 +40,7 @@
#ifdef REGISTER_FILTER
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
{&MEDIATYPE_DVD_ENCRYPTED_PACK, &MEDIASUBTYPE_MPEG2_VIDEO},
{&MEDIATYPE_MPEG2_PACK, &MEDIASUBTYPE_MPEG2_VIDEO},
{&MEDIATYPE_MPEG2_PES, &MEDIASUBTYPE_MPEG2_VIDEO},
@@ -52,29 +51,25 @@ const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
#endif
};
-const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
{&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}
+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}
};
-const AMOVIESETUP_FILTER sudFilter[] =
-{
- #ifdef MPEG2ONLY
+const AMOVIESETUP_FILTER sudFilter[] = {
+#ifdef MPEG2ONLY
{&__uuidof(CMpeg2DecFilter), L"MPC - MPEG-2 Video Decoder (Gabest)", 0x00600001, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
- #else
+#else
{&__uuidof(CMpeg2DecFilter), L"MPC - MPEG Video Decoder (Gabest)", 0x00600001, countof(sudpPins), sudpPins, CLSID_LegacyAmFilterCategory},
- #endif
+#endif
};
-CFactoryTemplate g_Templates[] =
-{
- {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CMpeg2DecFilter>, NULL, &sudFilter[0]},
+CFactoryTemplate g_Templates[] = {
+ {sudFilter[0].strName, sudFilter[0].clsID, CreateInstance<CMpeg2DecFilter>, NULL, &sudFilter[0]},
{L"CMpeg2DecPropertyPage", &__uuidof(CMpeg2DecSettingsWnd), CreateInstance<CInternalPropertyPageTempl<CMpeg2DecSettingsWnd> >},
};
@@ -95,48 +90,42 @@ STDAPI DllUnregisterServer()
#include <detours/detours.h>
BOOL (__stdcall * Real_IsDebuggerPresent)(void)
- = IsDebuggerPresent;
+= IsDebuggerPresent;
LONG (__stdcall * Real_ChangeDisplaySettingsExA)(LPCSTR a0,
- LPDEVMODEA a1,
- HWND a2,
- DWORD a3,
- LPVOID a4)
- = ChangeDisplaySettingsExA;
+ LPDEVMODEA a1,
+ HWND a2,
+ DWORD a3,
+ LPVOID a4)
+= ChangeDisplaySettingsExA;
LONG (__stdcall * Real_ChangeDisplaySettingsExW)(LPCWSTR a0,
- LPDEVMODEW a1,
- HWND a2,
- DWORD a3,
- LPVOID a4)
- = ChangeDisplaySettingsExW;
+ 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"));
+ 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)
- {
+ 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)
- {
+ && (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)
- {
+ } else if(vp->dwCommand == VP_COMMAND_SET) {
TRACE(_T("Ooops, as I already told ya, no need for any macrovision bs here"));
return 0;
}
@@ -161,11 +150,12 @@ LONG WINAPI Mine_ChangeDisplaySettingsExW(LPCWSTR lpszDeviceName, LPDEVMODEW lpD
class CMpeg2DecFilterApp : public CFilterApp
{
public:
- BOOL InitInstance()
- {
+ BOOL InitInstance() {
long lError;
- if(!__super::InitInstance()) return FALSE;
+ if(!__super::InitInstance()) {
+ return FALSE;
+ }
DetourRestoreAfterWith();
DetourTransactionBegin();
@@ -190,31 +180,45 @@ CMpeg2DecFilterApp theApp;
// CMpeg2DecFilter
//
-CMpeg2DecFilter::CMpeg2DecFilter(LPUNKNOWN lpunk, HRESULT* phr)
+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;
+ // delete m_pOutput;
- if(FAILED(*phr)) return;
+ if(FAILED(*phr)) {
+ return;
+ }
m_pInput = DNew CMpeg2DecInputPin(this, phr, L"Video");
- if(!m_pInput) *phr = E_OUTOFMEMORY;
- if(FAILED(*phr)) return;
+ 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_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;
+ 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;
+ if(!m_pClosedCaptionOutput) {
+ *phr = E_OUTOFMEMORY;
+ }
+ if(FAILED(*phr)) {
+ return;
+ }
SetDeinterlaceMethod(DIAuto);
SetBrightness(0.0f);
@@ -227,18 +231,35 @@ CMpeg2DecFilter::CMpeg2DecFilter(LPUNKNOWN lpunk, HRESULT* phr)
EnableReadARFromStream(true);
CRegKey key;
- if(ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPEG Video Decoder"), KEY_READ))
- {
+ 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);
+ 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);
+ }
}
m_rate.Rate = 10000;
@@ -250,8 +271,7 @@ CMpeg2DecFilter::CMpeg2DecFilter(LPUNKNOWN lpunk, HRESULT* phr)
CMpeg2DecFilter::~CMpeg2DecFilter()
{
CRegKey key;
- if(ERROR_SUCCESS == key.Create(HKEY_CURRENT_USER, _T("Software\\Gabest\\Filters\\MPEG Video Decoder")))
- {
+ 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);
@@ -273,7 +293,7 @@ STDMETHODIMP CMpeg2DecFilter::NonDelegatingQueryInterface(REFIID riid, void** pp
QI(IMpeg2DecFilter)
QI(ISpecifyPropertyPages)
QI(ISpecifyPropertyPages2)
- __super::NonDelegatingQueryInterface(riid, ppv);
+ __super::NonDelegatingQueryInterface(riid, ppv);
}
int CMpeg2DecFilter::GetPinCount()
@@ -283,12 +303,15 @@ int CMpeg2DecFilter::GetPinCount()
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;
+ switch(n) {
+ case 0:
+ return m_pInput;
+ case 1:
+ return m_pOutput;
+ case 2:
+ return m_pSubpicInput;
+ case 3:
+ return m_pClosedCaptionOutput;
}
return NULL;
}
@@ -323,11 +346,10 @@ HRESULT CMpeg2DecFilter::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop,
void CMpeg2DecFilter::InputTypeChanged()
{
CAutoLock cAutoLock(&m_csReceive);
-
+
TRACE(_T("ResetMpeg2Decoder()\n"));
- for(int i = 0; i < countof(m_dec->m_pictures); i++)
- {
+ 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;
@@ -338,13 +360,10 @@ void CMpeg2DecFilter::InputTypeChanged()
BYTE* pSequenceHeader = NULL;
DWORD cbSequenceHeader = 0;
- if(mt.formattype == FORMAT_MPEGVideo)
- {
+ if(mt.formattype == FORMAT_MPEGVideo) {
pSequenceHeader = ((MPEG1VIDEOINFO*)mt.Format())->bSequenceHeader;
cbSequenceHeader = ((MPEG1VIDEOINFO*)mt.Format())->cbSequenceHeader;
- }
- else if(mt.formattype == FORMAT_MPEG2_VIDEO)
- {
+ } else if(mt.formattype == FORMAT_MPEG2_VIDEO) {
pSequenceHeader = (BYTE*)((MPEG2VIDEOINFO*)mt.Format())->dwSequenceHeader;
cbSequenceHeader = ((MPEG2VIDEOINFO*)mt.Format())->cbSequenceHeader;
}
@@ -369,17 +388,13 @@ void CMpeg2DecFilter::SetDeinterlaceMethod()
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))
- {
+ 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))
- {
+ } else if(m_fFilm && !(newflags & PIC_FLAG_REPEAT_FIRST_FIELD)) {
TRACE(_T("m_fFilm = false\n"));
m_fFilm = false;
}
@@ -387,28 +402,26 @@ void CMpeg2DecFilter::SetDeinterlaceMethod()
const CMediaType& mt = m_pOutput->CurrentMediaType();
- if(mt.formattype == FORMAT_VideoInfo2 && (((VIDEOINFOHEADER2*)mt.pbFormat)->dwInterlaceFlags & AMINTERLACE_IsInterlaced))
- {
+ if(mt.formattype == FORMAT_VideoInfo2 && (((VIDEOINFOHEADER2*)mt.pbFormat)->dwInterlaceFlags & AMINTERLACE_IsInterlaced)) {
m_fb.di = DIWeave;
- }
- else
- {
+ } 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
+ 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
+ // 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;
+ }
}
}
@@ -417,32 +430,35 @@ void CMpeg2DecFilter::SetDeinterlaceMethod()
void CMpeg2DecFilter::SetTypeSpecificFlags(IMediaSample* pMS)
{
- if(CComQIPtr<IMediaSample2> pMS2 = pMS)
- {
+ if(CComQIPtr<IMediaSample2> pMS2 = pMS) {
AM_SAMPLE2_PROPERTIES props;
- if(SUCCEEDED(pMS2->GetProperties(sizeof(props), (BYTE*)&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))
- {
+ 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)
+ 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)
+ if(m_fb.flags & PIC_FLAG_TOP_FIELD_FIRST) {
props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_FIELD1FIRST;
- if(m_fb.flags & PIC_FLAG_REPEAT_FIRST_FIELD)
+ }
+ 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)
+ 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)
+ }
+ 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)
+ }
+ 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);
@@ -455,58 +471,61 @@ HRESULT CMpeg2DecFilter::Transform(IMediaSample* pIn)
HRESULT hr;
BYTE* pDataIn = NULL;
- if(FAILED(hr = pIn->GetPointer(&pDataIn)))
+ if(FAILED(hr = pIn->GetPointer(&pDataIn))) {
return hr;
+ }
long len = pIn->GetActualDataLength();
(static_cast<CDeCSSInputPin*>(m_pInput))->StripPacket(pDataIn, len);
- if(pIn->IsDiscontinuity() == S_OK)
- {
+ 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;
+ if(FAILED(hr)) {
+ rtStart = rtStop = _I64_MIN;
+ }
- while(len >= 0)
- {
+ 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
#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:
- {
+ 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)
- {
+ if(picture && !(picture->flags&PIC_FLAG_SKIP) && fbuf) {
ASSERT(!picture->fDelivered);
picture->fDelivered = true;
@@ -517,8 +536,7 @@ HRESULT CMpeg2DecFilter::Transform(IMediaSample* pIn)
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)
- {
+ if(m_fb.w != w || m_fb.h != h || m_fb.pitch != pitch) {
m_fb.Alloc(w, h, pitch);
m_fInitializedBuffer = false;
}
@@ -526,7 +544,9 @@ HRESULT CMpeg2DecFilter::Transform(IMediaSample* pIn)
// start - end
m_fb.rtStart = picture->rtStart;
- if(m_fb.rtStart == _I64_MIN) m_fb.rtStart = m_fb.rtStop;
+ 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;
@@ -540,19 +560,22 @@ HRESULT CMpeg2DecFilter::Transform(IMediaSample* pIn)
UpdateAspectRatio();
hr = DeliverFast();
- if(hr != S_OK)
+ if(hr != S_OK) {
hr = DeliverNormal();
- if(hr != S_OK)
+ }
+ if(hr != S_OK) {
return hr;
- if(hr == S_OK && !m_fWaitForKeyFrame)
+ }
+ if(hr == S_OK && !m_fWaitForKeyFrame) {
m_fInitializedBuffer = true;
+ }
}
}
break;
- default:
- break;
+ default:
+ break;
}
- }
+ }
return S_OK;
}
@@ -564,14 +587,15 @@ bool CMpeg2DecFilter::IsVideoInterlaced()
void CMpeg2DecFilter::UpdateAspectRatio()
{
- if(m_bReadARFromStream && (m_par.cx != m_dec->m_info.m_sequence->pixel_width || m_par.cy != m_dec->m_info.m_sequence->pixel_height))
- {
+ if(m_bReadARFromStream && (m_par.cx != m_dec->m_info.m_sequence->pixel_width || 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);
+ 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;
+ if(lnko > 1) {
+ dar.cx /= lnko, dar.cy /= lnko;
+ }
SetAspect(dar);
}
}
@@ -583,38 +607,46 @@ HRESULT CMpeg2DecFilter::DeliverFast()
CAutoLock cAutoLock(&m_csReceive);
mpeg2_fbuf_t* fbuf = m_dec->m_info.m_display_fbuf;
- if(!fbuf) return S_FALSE;
+ 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)
+ if((m_fb.flags & PIC_MASK_CODING_TYPE) == PIC_FLAG_CODING_TYPE_I) {
m_fWaitForKeyFrame = false;
+ }
- if(m_fb.rtStart < 0 || m_fWaitForKeyFrame)
+ if(m_fb.rtStart < 0 || m_fWaitForKeyFrame) {
return S_OK;
+ }
const CMediaType& mt = m_pOutput->CurrentMediaType();
-
- if(mt.subtype != MEDIASUBTYPE_I420 && mt.subtype != MEDIASUBTYPE_IYUV && mt.subtype != MEDIASUBTYPE_YV12)
+
+ 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)))
+ || FAILED(hr = pOut->GetPointer(&pDataOut))) {
return hr;
+ }
- if(mt.subtype != MEDIASUBTYPE_I420 && mt.subtype != MEDIASUBTYPE_IYUV && mt.subtype != MEDIASUBTYPE_YV12)
+ if(mt.subtype != MEDIASUBTYPE_I420 && mt.subtype != MEDIASUBTYPE_IYUV && mt.subtype != MEDIASUBTYPE_YV12) {
return S_FALSE;
+ }
BITMAPINFOHEADER bihOut;
ExtractBIH(&mt, &bihOut);
@@ -628,36 +660,32 @@ HRESULT CMpeg2DecFilter::DeliverFast()
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)
- {
+ 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)
- {
+ } 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
- {
+ } else { // TODO
return S_FALSE;
}
- if(h == 1088)
- {
+ 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))
- {
+ if(CMpeg2DecInputPin* pPin = dynamic_cast<CMpeg2DecInputPin*>(m_pInput)) {
CAutoLock cAutoLock(&pPin->m_csRateLock);
- if(m_rate.Rate != pPin->m_ratechange.Rate)
- {
+ if(m_rate.Rate != pPin->m_ratechange.Rate) {
m_rate.Rate = pPin->m_ratechange.Rate;
m_rate.StartTime = m_fb.rtStart;
}
@@ -688,7 +716,9 @@ HRESULT CMpeg2DecFilter::DeliverNormal()
CAutoLock cAutoLock(&m_csReceive);
mpeg2_fbuf_t* fbuf = m_dec->m_info.m_display_fbuf;
- if(!fbuf) return S_FALSE;
+ if(!fbuf) {
+ return S_FALSE;
+ }
int w = m_fb.w;
int h = m_fb.h;
@@ -702,35 +732,26 @@ HRESULT CMpeg2DecFilter::DeliverNormal()
// deinterlace
- if(m_fb.di == DIWeave)
- {
+ 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)
- {
+ } 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)
- {
+ } 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)
- {
+ } 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)
- {
+ } 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);
@@ -742,15 +763,14 @@ HRESULT CMpeg2DecFilter::DeliverNormal()
// deliver
- if (m_fb.di == DIWeave || m_fInitializedBuffer)
- {
+ if (m_fb.di == DIWeave || m_fInitializedBuffer) {
hr = Deliver(false);
- if(FAILED(hr))
+ if(FAILED(hr)) {
return hr;
+ }
}
- if(m_fb.di == DIBob)
- {
+ 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);
@@ -765,24 +785,21 @@ HRESULT CMpeg2DecFilter::DeliverNormal()
// deliver
hr = Deliver(false);
- }
- else if(m_fb.di == DIFieldShift)
- {
+ } 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)
- {
+ } 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)
+ if (!m_fInitializedBuffer) {
hr = Deliver(false);
+ }
return hr;
}
@@ -792,22 +809,24 @@ HRESULT CMpeg2DecFilter::Deliver(bool fRepeatLast)
{
CAutoLock cAutoLock(&m_csReceive);
- if((m_fb.flags&PIC_MASK_CODING_TYPE) == PIC_FLAG_CODING_TYPE_I)
+ if((m_fb.flags&PIC_MASK_CODING_TYPE) == PIC_FLAG_CODING_TYPE_I) {
m_fWaitForKeyFrame = false;
+ }
- if(m_fb.rtStart < 0 || m_fWaitForKeyFrame)
+ if(m_fb.rtStart < 0 || m_fWaitForKeyFrame) {
return S_OK;
+ }
HRESULT hr;
CComPtr<IMediaSample> pOut;
BYTE* pDataOut = NULL;
if(FAILED(hr = GetDeliveryBuffer(m_fb.w, m_fb.h, &pOut))
- || FAILED(hr = pOut->GetPointer(&pDataOut)))
+ || FAILED(hr = pOut->GetPointer(&pDataOut))) {
return hr;
+ }
- if(m_fb.h == 1088)
- {
+ 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);
@@ -815,11 +834,10 @@ HRESULT CMpeg2DecFilter::Deliver(bool fRepeatLast)
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];
@@ -830,12 +848,10 @@ HRESULT CMpeg2DecFilter::Deliver(bool fRepeatLast)
//
- if(CMpeg2DecInputPin* pPin = dynamic_cast<CMpeg2DecInputPin*>(m_pInput))
- {
+ if(CMpeg2DecInputPin* pPin = dynamic_cast<CMpeg2DecInputPin*>(m_pInput)) {
CAutoLock cAutoLock(&pPin->m_csRateLock);
- if(m_rate.Rate != pPin->m_ratechange.Rate)
- {
+ if(m_rate.Rate != pPin->m_ratechange.Rate) {
m_rate.Rate = pPin->m_ratechange.Rate;
m_rate.StartTime = m_fb.rtStart;
}
@@ -865,29 +881,29 @@ HRESULT CMpeg2DecFilter::Deliver(bool fRepeatLast)
HRESULT CMpeg2DecFilter::CheckConnect(PIN_DIRECTION dir, IPin* pPin)
{
- if(dir == PINDIR_OUTPUT)
- {
- if(GetCLSID(m_pInput->GetConnected()) == CLSID_DVDNavigator)
- {
+ if(dir == PINDIR_OUTPUT) {
+ if(GetCLSID(m_pInput->GetConnected()) == CLSID_DVDNavigator) {
// one of these needed for dynamic format changes
CLSID clsid = GetCLSID(pPin);
DWORD ver = 0;
- if(CComQIPtr<IFilterVersion> pFV = GetFilterFromPin(pPin))
+ 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
+ /*&& 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;
+ }
}
}
@@ -896,11 +912,11 @@ HRESULT CMpeg2DecFilter::CheckConnect(PIN_DIRECTION dir, IPin* pPin)
HRESULT CMpeg2DecFilter::CheckInputType(const CMediaType* mtIn)
{
- if(mtIn->formattype == FORMAT_MPEG2_VIDEO && mtIn->pbFormat)
- {
+ if(mtIn->formattype == FORMAT_MPEG2_VIDEO && mtIn->pbFormat) {
MPEG2VIDEOINFO* vih = (MPEG2VIDEOINFO*)mtIn->pbFormat;
- if(vih->cbSequenceHeader > 0 && (vih->dwSequenceHeader[0] & 0x00ffffff) != 0x00010000)
+ if(vih->cbSequenceHeader > 0 && (vih->dwSequenceHeader[0] & 0x00ffffff) != 0x00010000) {
return VFW_E_TYPE_NOT_ACCEPTED;
+ }
}
return (mtIn->majortype == MEDIATYPE_DVD_ENCRYPTED_PACK && mtIn->subtype == MEDIASUBTYPE_MPEG2_VIDEO
@@ -909,20 +925,20 @@ HRESULT CMpeg2DecFilter::CheckInputType(const CMediaType* mtIn)
|| mtIn->majortype == MEDIATYPE_Video && mtIn->subtype == MEDIASUBTYPE_MPEG2_VIDEO
|| mtIn->majortype == MEDIATYPE_Video && mtIn->subtype == MEDIASUBTYPE_MPEG1Packet
|| mtIn->majortype == MEDIATYPE_Video && mtIn->subtype == MEDIASUBTYPE_MPEG1Payload)
- ? S_OK
- : VFW_E_TYPE_NOT_ACCEPTED;
+ ? 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;
+ && (!fPlanarYUV || IsPlanarYUVEnabled())
+ ? S_OK
+ : VFW_E_TYPE_NOT_ACCEPTED;
}
DWORD g_clock;
@@ -930,25 +946,29 @@ DWORD g_clock;
HRESULT CMpeg2DecFilter::StartStreaming()
{
HRESULT hr = __super::StartStreaming();
- if(FAILED(hr)) return hr;
+ if(FAILED(hr)) {
+ return hr;
+ }
m_dec.Attach(DNew CMpeg2Dec());
- if(!m_dec) return E_OUTOFMEMORY;
+ if(!m_dec) {
+ return E_OUTOFMEMORY;
+ }
InputTypeChanged();
-// g_clock = clock();
+ // g_clock = clock();
return S_OK;
}
HRESULT CMpeg2DecFilter::StopStreaming()
{
-/*
- CString str;
- str.Format(_T("%d"), clock()-g_clock);
- AfxMessageBox(str);
-*/
+ /*
+ CString str;
+ str.Format(_T("%d"), clock()-g_clock);
+ AfxMessageBox(str);
+ */
m_dec.Free();
return __super::StopStreaming();
@@ -956,10 +976,13 @@ HRESULT CMpeg2DecFilter::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);
+ // TRACE(_T("CMpeg2DecFilter::AlterQuality: Type=%d, Proportion=%d, Late=%I64d, TimeStamp=%I64d\n"), q.Type, q.Proportion, q.Late, q.TimeStamp);
return S_OK;
}
@@ -980,12 +1003,13 @@ STDMETHODIMP CMpeg2DecFilter::CreatePage(const GUID& guid, IPropertyPage** ppPag
{
CheckPointer(ppPage, E_POINTER);
- if(*ppPage != NULL) return E_INVALIDARG;
+ if(*ppPage != NULL) {
+ return E_INVALIDARG;
+ }
HRESULT hr;
- if(guid == __uuidof(CMpeg2DecSettingsWnd))
- {
+ if(guid == __uuidof(CMpeg2DecSettingsWnd)) {
(*ppPage = DNew CInternalPropertyPageTempl<CMpeg2DecSettingsWnd>(NULL, &hr))->AddRef();
}
@@ -1012,11 +1036,10 @@ void CMpeg2DecFilter::CalcBrCont(BYTE* YTbl, float bright, float cont)
int Cont = (int)(cont * 512);
int Bright = (int)bright;
- for(int i = 0; i < 256; i++)
- {
+ 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);
+ // YTbl[i] = min(max(y, 16), 235);
}
}
@@ -1027,11 +1050,9 @@ void CMpeg2DecFilter::CalcHueSat(BYTE* UTbl, BYTE* VTbl, float hue, float sat)
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;
+ 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;
@@ -1049,12 +1070,10 @@ void CMpeg2DecFilter::ApplyBrContHueSat(BYTE* srcy, BYTE* srcu, BYTE* srcv, int
{
CAutoLock cAutoLock(&m_csProps);
- if(fabs(m_bright) > EPSILON || fabs(m_cont-1.0) > EPSILON)
- {
+ 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)
- {
+ 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);
@@ -1064,8 +1083,7 @@ void CMpeg2DecFilter::ApplyBrContHueSat(BYTE* srcy, BYTE* srcu, BYTE* srcv, int
__m128i _16 = _mm_set1_epi16(16);
__m128i _512 = _mm_set1_epi16(512);
- for(int i = 0, j = size>>4; i < j; i++)
- {
+ 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);
@@ -1101,8 +1119,7 @@ void CMpeg2DecFilter::ApplyBrContHueSat(BYTE* srcy, BYTE* srcu, BYTE* srcv, int
size &= 15;
}
- for(; size > 0; size--)
- {
+ for(; size > 0; size--) {
*srcy++ = m_YTbl[*srcy];
}
}
@@ -1111,10 +1128,8 @@ void CMpeg2DecFilter::ApplyBrContHueSat(BYTE* srcy, BYTE* srcu, BYTE* srcv, int
w /= 2;
h /= 2;
- if(fabs(m_hue) > EPSILON || fabs(m_sat-1.0) > EPSILON)
- {
- for(int size = pitch*h; size > 0; size--)
- {
+ 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];
@@ -1242,175 +1257,172 @@ CMpeg2DecInputPin::CMpeg2DecInputPin(CTransformFilter* pFilter, HRESULT* phr, LP
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*/)
+ 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;
+ 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;
}
- break;
- default:
- return E_PROP_ID_UNSUPPORTED;
- }
-/*
- if(PropSet == AM_KSPROPSETID_DVD_RateChange)
- switch(Id)
- {
- case AM_RATE_ChangeRate:
+ /*
+ if(PropSet == AM_KSPROPSETID_DVD_RateChange)
+ switch(Id)
{
- AM_DVD_ChangeRate* p = (AM_DVD_ChangeRate*)pPropertyData;
+ case AM_RATE_ChangeRate:
+ {
+ AM_DVD_ChangeRate* p = (AM_DVD_ChangeRate*)pPropertyData;
+ }
+ break;
+ default:
+ return E_PROP_ID_UNSUPPORTED;
}
- 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*/)
+ 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;
- UNUSED_ALWAYS(p);
- return E_PROP_ID_UNSUPPORTED;
- }
- break;
- case AM_RATE_MaxFullDataRate:
- {
- AM_MaxFullDataRate* p = (AM_MaxFullDataRate*)pPropertyData;
- UNUSED_ALWAYS(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);
+ switch(Id) {
+ case AM_RATE_SimpleRateChange: {
+ AM_SimpleRateChange* p = (AM_SimpleRateChange*)pPropertyData;
+ UNUSED_ALWAYS(p);
+ return E_PROP_ID_UNSUPPORTED;
+ }
+ break;
+ case AM_RATE_MaxFullDataRate: {
+ AM_MaxFullDataRate* p = (AM_MaxFullDataRate*)pPropertyData;
+ UNUSED_ALWAYS(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;
}
- break;
- case AM_RATE_QueryLastRateSegPTS:
+ /*
+ if(PropSet == AM_KSPROPSETID_DVD_RateChange)
+ switch(Id)
{
- REFERENCE_TIME* p = (REFERENCE_TIME*)pPropertyData;
+ 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;
}
- 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*/)
+ 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;
- }
-*/
+ 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;
}
@@ -1429,15 +1441,15 @@ HRESULT CMpeg2DecOutputPin::Active()
// TODO
- if(m_Connected && !m_pOutputQueue)
- {
+ if(m_Connected && !m_pOutputQueue) {
HRESULT hr = NOERROR;
m_pOutputQueue.Attach(DNew COutputQueue(m_Connected, &hr));
- if(!m_pOutputQueue) hr = E_OUTOFMEMORY;
+ if(!m_pOutputQueue) {
+ hr = E_OUTOFMEMORY;
+ }
- if(FAILED(hr))
- {
+ if(FAILED(hr)) {
m_pOutputQueue.Free();
return hr;
}
@@ -1455,7 +1467,9 @@ HRESULT CMpeg2DecOutputPin::Inactive()
HRESULT CMpeg2DecOutputPin::Deliver(IMediaSample* pMediaSample)
{
- if(!m_pOutputQueue) return NOERROR;
+ if(!m_pOutputQueue) {
+ return NOERROR;
+ }
pMediaSample->AddRef();
return m_pOutputQueue->Receive(pMediaSample);
}
@@ -1464,7 +1478,7 @@ HRESULT CMpeg2DecOutputPin::Deliver(IMediaSample* pMediaSample)
if(!m_pOutputQueue) return NOERROR; \
m_pOutputQueue->##call; \
return NOERROR; \
-
+
HRESULT CMpeg2DecOutputPin::DeliverEndOfStream()
{
CallQueue(EOS());
@@ -1492,7 +1506,7 @@ HRESULT CMpeg2DecOutputPin::DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_T
#define PTS2RT(pts) (10000i64*pts/90)
-CSubpicInputPin::CSubpicInputPin(CTransformFilter* pFilter, HRESULT* phr)
+CSubpicInputPin::CSubpicInputPin(CTransformFilter* pFilter, HRESULT* phr)
: CMpeg2DecInputPin(pFilter, phr, L"SubPicture")
, m_spon(TRUE)
, m_fsppal(false)
@@ -1512,12 +1526,12 @@ 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;
+ || 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)
@@ -1527,16 +1541,18 @@ HRESULT CSubpicInputPin::SetMediaType(const CMediaType* mtIn)
bool CSubpicInputPin::HasAnythingToRender(REFERENCE_TIME rt)
{
- if(!IsConnected()) return(false);
+ if(!IsConnected()) {
+ return(false);
+ }
CAutoLock cAutoLock(&m_csReceive);
POSITION pos = m_sps.GetHeadPosition();
- while(pos)
- {
+ 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))
+ if(sp->m_rtStart <= rt && rt < sp->m_rtStop && (/*sp->m_psphli ||*/ sp->m_fForced || m_spon)) {
return(true);
+ }
}
return(false);
@@ -1550,20 +1566,21 @@ void CSubpicInputPin::RenderSubpics(REFERENCE_TIME rt, BYTE** yuv, int w, int h)
// remove no longer needed things first
pos = m_sps.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
POSITION cur = pos;
spu* sp = m_sps.GetNext(pos);
- if(sp->m_rtStop <= rt) m_sps.RemoveAt(cur);
+ if(sp->m_rtStop <= rt) {
+ m_sps.RemoveAt(cur);
+ }
}
pos = m_sps.GetHeadPosition();
- while(pos)
- {
+ 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)))
+ 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);
+ }
}
}
@@ -1572,29 +1589,33 @@ HRESULT CSubpicInputPin::Transform(IMediaSample* pSample)
HRESULT hr;
AM_MEDIA_TYPE* pmt;
- if(SUCCEEDED(pSample->GetMediaType(&pmt)) && 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;
+ if(FAILED(hr = pSample->GetPointer(&pDataIn))) {
+ return hr;
+ }
long len = pSample->GetActualDataLength();
StripPacket(pDataIn, len);
- if(len <= 0) return S_FALSE;
+ if(len <= 0) {
+ return S_FALSE;
+ }
- if(m_mt.subtype == MEDIASUBTYPE_SVCD_SUBPICTURE)
- {
+ 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);
@@ -1603,23 +1624,17 @@ HRESULT CSubpicInputPin::Transform(IMediaSample* pSample)
bool fRefresh = false;
- if(FAILED(hr))
- {
- if(!m_sps.IsEmpty())
- {
+ 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
- {
+ } else {
POSITION pos = m_sps.GetTailPosition();
- while(pos)
- {
+ while(pos) {
spu* sp = m_sps.GetPrev(pos);
- if(sp->m_rtStop == _I64_MAX)
- {
+ if(sp->m_rtStop == _I64_MAX) {
sp->m_rtStop = rtStart;
break;
}
@@ -1627,10 +1642,15 @@ HRESULT CSubpicInputPin::Transform(IMediaSample* pSample)
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;
@@ -1638,8 +1658,7 @@ HRESULT CSubpicInputPin::Transform(IMediaSample* pSample)
p->SetCount(len);
memcpy(p->GetData(), pDataIn, len);
- if(m_sphli && p->m_rtStart == PTS2RT(m_sphli->StartPTM))
- {
+ if(m_sphli && p->m_rtStart == PTS2RT(m_sphli->StartPTM)) {
p->m_psphli = m_sphli;
fRefresh = true;
}
@@ -1647,14 +1666,12 @@ HRESULT CSubpicInputPin::Transform(IMediaSample* pSample)
m_sps.AddTail(p);
}
- if(!m_sps.IsEmpty())
- {
+ 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;
@@ -1671,15 +1688,14 @@ STDMETHODIMP CSubpicInputPin::EndFlush()
STDMETHODIMP CSubpicInputPin::Set(REFGUID PropSet, ULONG Id, LPVOID pInstanceData, ULONG InstanceLength, LPVOID pPropertyData, ULONG DataLength)
{
- if(PropSet != AM_KSPROPSETID_DvdSubPic)
+ if(PropSet != AM_KSPROPSETID_DvdSubPic) {
return __super::Set(PropSet, Id, pInstanceData, InstanceLength, pPropertyData, DataLength);
+ }
bool fRefresh = false;
- switch(Id)
- {
- case AM_PROPERTY_DVDSUBPIC_PALETTE:
- {
+ switch(Id) {
+ case AM_PROPERTY_DVDSUBPIC_PALETTE: {
CAutoLock cAutoLock(&m_csReceive);
AM_PROPERTY_SPPAL* pSPPAL = (AM_PROPERTY_SPPAL*)pPropertyData;
@@ -1689,22 +1705,18 @@ STDMETHODIMP CSubpicInputPin::Set(REFGUID PropSet, ULONG Id, LPVOID pInstanceDat
DbgLog((LOG_TRACE, 0, _T("new palette")));
}
break;
- case AM_PROPERTY_DVDSUBPIC_HLI:
- {
+ case AM_PROPERTY_DVDSUBPIC_HLI: {
CAutoLock cAutoLock(&m_csReceive);
AM_PROPERTY_SPHLI* pSPHLI = (AM_PROPERTY_SPHLI*)pPropertyData;
m_sphli.Free();
- if(pSPHLI->HLISS)
- {
+ if(pSPHLI->HLISS) {
POSITION pos = m_sps.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
spu* sp = m_sps.GetNext(pos);
- if(sp->m_rtStart <= PTS2RT(pSPHLI->StartPTM) && PTS2RT(pSPHLI->StartPTM) < sp->m_rtStop)
- {
+ 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);
@@ -1712,17 +1724,13 @@ STDMETHODIMP CSubpicInputPin::Set(REFGUID PropSet, ULONG Id, LPVOID pInstanceDat
}
}
- if(!fRefresh) // save it for later, a subpic might be late for this hli
- {
+ 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
- {
+ } else {
POSITION pos = m_sps.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
spu* sp = m_sps.GetNext(pos);
fRefresh |= !!sp->m_psphli;
sp->m_psphli.Free();
@@ -1730,25 +1738,23 @@ STDMETHODIMP CSubpicInputPin::Set(REFGUID PropSet, ULONG Id, LPVOID pInstanceDat
}
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));
+ 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:
- {
+ 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;
+ default:
+ return E_PROP_ID_UNSUPPORTED;
}
- if(fRefresh)
- {
+ if(fRefresh) {
(static_cast<CMpeg2DecFilter*>(m_pFilter))->Deliver(true);
}
@@ -1757,24 +1763,24 @@ STDMETHODIMP CSubpicInputPin::Set(REFGUID PropSet, ULONG Id, LPVOID pInstanceDat
STDMETHODIMP CSubpicInputPin::QuerySupported(REFGUID PropSet, ULONG Id, ULONG* pTypeSupport)
{
- if(PropSet != AM_KSPROPSETID_DvdSubPic)
+ 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;
}
@@ -1785,26 +1791,32 @@ static __inline BYTE GetNibble(BYTE* p, DWORD* offset, int& nField, int& fAligne
BYTE ret = (p[offset[nField]] >> (fAligned << 2)) & 0x0f;
offset[nField] += 1-fAligned;
fAligned = !fAligned;
- return ret;
+ 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]++;
+ if(!n) {
+ offset[nField]++;
+ }
n = (n-1+4)&3;
- return ret;
+ 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*(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
@@ -1813,11 +1825,11 @@ static __inline void DrawPixel(BYTE** yuv, CPoint pt, int pitch, AM_DVD_YUV& c)
// 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 = (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 = (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").
@@ -1827,23 +1839,32 @@ static __inline void DrawPixel(BYTE** yuv, CPoint pt, int pitch, AM_DVD_YUV& c)
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(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())
+ 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)
+ if(pt.y < rc.top || pt.y >= rc.bottom
+ || pt.x+len < rc.left || pt.x >= rc.right) {
return;
+ }
}
- while(len-- > 0)
- {
+ while(len-- > 0) {
DrawPixel(yuv, pt, pitch, c);
pt.x++;
}
@@ -1860,50 +1881,65 @@ bool CSubpicInputPin::dvdspu::Parse()
WORD packetsize = (p[0]<<8)|p[1];
WORD datasize = (p[2]<<8)|p[3];
- if(packetsize > GetCount() || datasize > packetsize)
+ if(packetsize > GetCount() || datasize > packetsize) {
return(false);
+ }
int i, next = datasize;
- #define GetWORD (p[i]<<8)|p[i+1]; i += 2
+#define GetWORD (p[i]<<8)|p[i+1]; i += 2
- do
- {
+ do {
i = next;
int pts = GetWORD;
next = GetWORD;
- if(next > packetsize || next < datasize)
+ if(next > packetsize || next < datasize) {
return(false);
+ }
REFERENCE_TIME rt = m_rtStart + 1024*PTS2RT(pts);
- for(bool fBreak = false; !fBreak; )
- {
+ 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;
+ 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)
- {
+ if(i+len >= packetsize) {
TRACE(_T("Warning: Wrong subpicture parameter block ending\n"));
break;
}
- switch(p[i++])
- {
+ switch(p[i++]) {
case 0x00: // forced start displaying
m_fForced = true;
break;
@@ -1952,8 +1988,7 @@ bool CSubpicInputPin::dvdspu::Parse()
offset_t o = {rt, m_sphli};
m_offsets.AddTail(o); // is it always going to be sorted?
- }
- while(i <= next && i < packetsize);
+ } while(i <= next && i < packetsize);
return(true);
}
@@ -1970,18 +2005,17 @@ void CSubpicInputPin::dvdspu::Render(REFERENCE_TIME rt, BYTE** yuv, int w, int h
CRect rcclip(0, 0, w, h);
rcclip &= rc;
- if(m_psphli)
- {
+ 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)
- {
+ } else if(m_offsets.GetCount() > 1) {
POSITION pos = m_offsets.GetTailPosition();
- while(pos)
- {
+ while(pos) {
const offset_t& o = m_offsets.GetPrev(pos);
- if(rt >= o.rt) {sphli = o.sphli; break;}
+ if(rt >= o.rt) {
+ sphli = o.sphli;
+ break;
+ }
}
}
@@ -2000,22 +2034,24 @@ void CSubpicInputPin::dvdspu::Render(REFERENCE_TIME rt, BYTE** yuv, int w, int h
DWORD end[2] = {offset[1], (p[2]<<8)|p[3]};
- while((nField == 0 && offset[0] < end[0]) || (nField == 1 && offset[1] < end[1]))
- {
+ 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)
- {
+ || (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;
+ 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
+ if(!fAligned) {
+ GetNibble(p, offset, nField, fAligned); // align to byte
+ }
pt.x = rc.left;
pt.y++;
@@ -2032,58 +2068,63 @@ bool CSubpicInputPin::cvdspu::Parse()
WORD packetsize = (p[0]<<8)|p[1];
WORD datasize = (p[2]<<8)|p[3];
- if(packetsize > GetCount() || datasize > packetsize)
+ 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;
+ 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;
}
}
@@ -2111,12 +2152,10 @@ void CSubpicInputPin::cvdspu::Render(REFERENCE_TIME rt, BYTE** yuv, int w, int h
DWORD end[2] = {offset[1], (p[2]<<8)|p[3]};
- while((nField == 0 && offset[0] < end[0]) || (nField == 1 && offset[1] < end[1]))
- {
+ while((nField == 0 && offset[0] < end[0]) || (nField == 1 && offset[1] < end[1])) {
BYTE code;
- if((code = GetNibble(p, offset, nField, fAligned)) >= 0x4)
- {
+ 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;
@@ -2125,7 +2164,9 @@ void CSubpicInputPin::cvdspu::Render(REFERENCE_TIME rt, BYTE** yuv, int w, int h
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++;
@@ -2140,41 +2181,48 @@ bool CSubpicInputPin::svcdspu::Parse()
BYTE* p = GetData();
BYTE* p0 = p;
- if(GetCount() < 2)
+ 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())
+ if(packetsize > GetCount()) {
return(false);
+ }
bool duration = !!(*p++&0x04);
*p++; // unknown
- if(duration)
- {
+ 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++)
- {
+ 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];
@@ -2203,16 +2251,18 @@ void CSubpicInputPin::svcdspu::Render(REFERENCE_TIME rt, BYTE** yuv, int w, int
DWORD end[2] = {offset[1], (p[2]<<8)|p[3]};
- while((nField == 0 && offset[0] < end[0]) || (nField == 1 && offset[1] < end[1]))
- {
+ 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;
+ 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++;
@@ -2232,14 +2282,18 @@ CClosedCaptionOutputPin::CClosedCaptionOutputPin(CBaseFilter* pFilter, CCritSec*
HRESULT CClosedCaptionOutputPin::CheckMediaType(const CMediaType* mtOut)
{
return mtOut->majortype == MEDIATYPE_AUXLine21Data && mtOut->subtype == MEDIASUBTYPE_Line21_GOPPacket
- ? S_OK
- : VFW_E_TYPE_NOT_ACCEPTED;
+ ? 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;
@@ -2258,20 +2312,20 @@ HRESULT CClosedCaptionOutputPin::DecideBufferSize(IMemAllocator* pAllocator, ALL
HRESULT hr;
ALLOCATOR_PROPERTIES Actual;
- if(FAILED(hr = pAllocator->SetProperties(pProperties, &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;
- if(len > 4 && ptr && *(DWORD*)ptr == 0xf8014343 && IsConnected())
- {
+ if(len > 4 && ptr && *(DWORD*)ptr == 0xf8014343 && IsConnected()) {
CComPtr<IMediaSample> pSample;
GetDeliveryBuffer(&pSample, NULL, NULL, 0);
BYTE* pData = NULL;
diff --git a/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.h b/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.h
index 829ec6fa3..a6d5f10d2 100644
--- a/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.h
+++ b/src/filters/transform/Mpeg2DecFilter/Mpeg2DecFilter.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -33,7 +33,7 @@ class CClosedCaptionOutputPin;
class CMpeg2Dec;
class __declspec(uuid("39F498AF-1A09-4275-B193-673B0BA3D478"))
-CMpeg2DecFilter
+ CMpeg2DecFilter
: public CBaseVideoFilter
, public IMpeg2DecFilter
, public ISpecifyPropertyPages2
@@ -48,39 +48,47 @@ CMpeg2DecFilter
bool m_fInitializedBuffer;
CSize m_par;
- struct framebuf
- {
+ struct framebuf {
int w, h, pitch;
BYTE* buf_base;
BYTE* buf[6];
REFERENCE_TIME rtStart, rtStop;
DWORD flags;
ditype di;
- framebuf()
- {
+ 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;
+ ~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;
+ 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);
+ void Free() {
+ if(buf_base) {
+ _aligned_free(buf_base);
+ }
buf_base = NULL;
}
} m_fb;
@@ -102,7 +110,7 @@ public:
virtual ~CMpeg2DecFilter();
DECLARE_IUNKNOWN
- STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
HRESULT DeliverFast();
HRESULT DeliverNormal();
@@ -111,13 +119,13 @@ public:
int GetPinCount();
CBasePin* GetPin(int n);
- HRESULT EndOfStream();
+ HRESULT EndOfStream();
HRESULT BeginFlush();
HRESULT EndFlush();
- HRESULT NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
+ HRESULT NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
HRESULT CheckConnect(PIN_DIRECTION dir, IPin* pPin);
- HRESULT CheckInputType(const CMediaType* mtIn);
+ HRESULT CheckInputType(const CMediaType* mtIn);
HRESULT CheckTransform(const CMediaType* mtIn, const CMediaType* mtOut);
HRESULT StartStreaming();
@@ -139,7 +147,7 @@ protected:
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
@@ -181,15 +189,15 @@ class CMpeg2DecInputPin : public CDeCSSInputPin
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;
// 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);
+ 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
@@ -200,13 +208,13 @@ public:
CAutoPtr<COutputQueue> m_pOutputQueue;
HRESULT Active();
- HRESULT Inactive();
+ HRESULT Inactive();
HRESULT Deliver(IMediaSample* pMediaSample);
- HRESULT DeliverEndOfStream();
- HRESULT DeliverBeginFlush();
+ HRESULT DeliverEndOfStream();
+ HRESULT DeliverBeginFlush();
HRESULT DeliverEndFlush();
- HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
+ HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
};
class CSubpicInputPin : public CMpeg2DecInputPin
@@ -222,11 +230,15 @@ class CSubpicInputPin : public CMpeg2DecInputPin
{
public:
bool m_fForced;
- REFERENCE_TIME m_rtStart, m_rtStop;
+ 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;}
+ 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;
@@ -235,7 +247,10 @@ class CSubpicInputPin : public CMpeg2DecInputPin
class dvdspu : public spu
{
public:
- struct offset_t {REFERENCE_TIME rt; AM_PROPERTY_SPHLI sphli;};
+ 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);
@@ -245,7 +260,9 @@ class CSubpicInputPin : public CMpeg2DecInputPin
{
public:
AM_DVD_YUV m_sppal[2][4];
- cvdspu() {memset(m_sppal, 0, sizeof(m_sppal));}
+ 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);
};
@@ -254,7 +271,9 @@ class CSubpicInputPin : public CMpeg2DecInputPin
{
public:
AM_DVD_YUV m_sppal[4];
- svcdspu() {memset(m_sppal, 0, sizeof(m_sppal));}
+ 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);
};
@@ -270,18 +289,24 @@ public:
bool HasAnythingToRender(REFERENCE_TIME rt);
void RenderSubpics(REFERENCE_TIME rt, BYTE** p, int w, int h);
- HRESULT CheckMediaType(const CMediaType* mtIn);
+ 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;}
+ 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);
+ 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
@@ -289,11 +314,13 @@ class CClosedCaptionOutputPin : public CBaseOutputPin
public:
CClosedCaptionOutputPin(CBaseFilter* pFilter, CCritSec* pLock, HRESULT* phr);
- HRESULT CheckMediaType(const CMediaType* mtOut);
+ HRESULT CheckMediaType(const CMediaType* mtOut);
HRESULT GetMediaType(int iPosition, CMediaType* pmt);
- HRESULT DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties);
+ HRESULT DecideBufferSize(IMemAllocator* pAllocator, ALLOCATOR_PROPERTIES* pProperties);
- CMediaType& CurrentMediaType() {return m_mt;}
+ CMediaType& CurrentMediaType() {
+ return m_mt;
+ }
HRESULT Deliver(const void* ptr, int len);
};
diff --git a/src/filters/transform/Mpeg2DecFilter/Mpeg2DecSettingsWnd.cpp b/src/filters/transform/Mpeg2DecFilter/Mpeg2DecSettingsWnd.cpp
index c8de3e7ea..4be2a2f54 100644
--- a/src/filters/transform/Mpeg2DecFilter/Mpeg2DecSettingsWnd.cpp
+++ b/src/filters/transform/Mpeg2DecFilter/Mpeg2DecSettingsWnd.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -51,9 +51,13 @@ bool CMpeg2DecSettingsWnd::OnConnect(const CInterfaceList<IUnknown, &IID_IUnknow
m_pM2DF.Release();
POSITION pos = pUnks.GetHeadPosition();
- while(pos && !(m_pM2DF = pUnks.GetNext(pos)));
-
- if(!m_pM2DF) return false;
+ while(pos && !(m_pM2DF = pUnks.GetNext(pos))) {
+ ;
+ }
+
+ if(!m_pM2DF) {
+ return false;
+ }
m_ditype = m_pM2DF->GetDeinterlaceMethod();
m_procamp[0] = m_pM2DF->GetBrightness();
@@ -107,15 +111,15 @@ bool CMpeg2DecSettingsWnd::OnActivate()
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)
+ 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)
- {
+ 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(200, h)), this, IDC_PP_SLIDER1+i);
@@ -149,8 +153,9 @@ bool CMpeg2DecSettingsWnd::OnActivate()
ResStr(IDS_MPEG2DECSETTINGSWND_8),
dwStyle, CRect(p, CSize(320, m_fontheight * 4)), this);
- for(CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow())
+ for(CWnd* pWnd = GetWindow(GW_CHILD); pWnd; pWnd = pWnd->GetNextWindow()) {
pWnd->SetFont(&m_font, FALSE);
+ }
return true;
}
@@ -172,8 +177,7 @@ bool CMpeg2DecSettingsWnd::OnApply()
{
OnDeactivate();
- if(m_pM2DF)
- {
+ if(m_pM2DF) {
m_pM2DF->SetDeinterlaceMethod(m_ditype);
m_pM2DF->SetBrightness(m_procamp[0]);
m_pM2DF->SetContrast(m_procamp[1]);
@@ -205,7 +209,7 @@ void CMpeg2DecSettingsWnd::UpdateProcampValues()
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_BN_CLICKED(IDC_PP_CHECK2, OnButtonInterlaced)
ON_WM_HSCROLL()
END_MESSAGE_MAP()
diff --git a/src/filters/transform/Mpeg2DecFilter/Mpeg2DecSettingsWnd.h b/src/filters/transform/Mpeg2DecFilter/Mpeg2DecSettingsWnd.h
index a358fdb8a..9a3e25939 100644
--- a/src/filters/transform/Mpeg2DecFilter/Mpeg2DecSettingsWnd.h
+++ b/src/filters/transform/Mpeg2DecFilter/Mpeg2DecSettingsWnd.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
@@ -26,7 +26,7 @@
#include <afxcmn.h>
class __declspec(uuid("E5FB6957-65E6-491B-BB37-B25C9FE3BEA7"))
-CMpeg2DecSettingsWnd : public CInternalPropertyPageWnd
+ CMpeg2DecSettingsWnd : public CInternalPropertyPageWnd
{
CComQIPtr<IMpeg2DecFilter> m_pM2DF;
@@ -37,8 +37,7 @@ CMpeg2DecSettingsWnd : public CInternalPropertyPageWnd
bool m_forcedsubs;
bool m_readARFromStream;
- enum
- {
+ enum {
IDC_PP_COMBO1 = 10000,
IDC_PP_SLIDER1,
IDC_PP_SLIDER2,
@@ -69,15 +68,19 @@ CMpeg2DecSettingsWnd : public CInternalPropertyPageWnd
public:
CMpeg2DecSettingsWnd();
-
+
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()
diff --git a/src/filters/transform/Mpeg2DecFilter/idct_sse2.cpp b/src/filters/transform/Mpeg2DecFilter/idct_sse2.cpp
index 134707c76..7eab60218 100644
--- a/src/filters/transform/Mpeg2DecFilter/idct_sse2.cpp
+++ b/src/filters/transform/Mpeg2DecFilter/idct_sse2.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -47,276 +47,276 @@ static __align16(const short,M128_tg_2_16[8]) = {27146, 27146, 27146, 27146, 271
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)
{
- 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)
+ __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)
{
-__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)
{
- __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 3d5061bd0..c71dad156 100644
--- a/src/filters/transform/Mpeg2DecFilter/mc_sse2.cpp
+++ b/src/filters/transform/Mpeg2DecFilter/mc_sse2.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -31,459 +31,452 @@ 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}
+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
+ }
};
diff --git a/src/filters/transform/Mpeg2DecFilter/stdafx.cpp b/src/filters/transform/Mpeg2DecFilter/stdafx.cpp
index 13934d005..bea3f980a 100644
--- a/src/filters/transform/Mpeg2DecFilter/stdafx.cpp
+++ b/src/filters/transform/Mpeg2DecFilter/stdafx.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/transform/Mpeg2DecFilter/stdafx.h b/src/filters/transform/Mpeg2DecFilter/stdafx.h
index e1b753d82..2e566de2c 100644
--- a/src/filters/transform/Mpeg2DecFilter/stdafx.h
+++ b/src/filters/transform/Mpeg2DecFilter/stdafx.h
@@ -1,4 +1,4 @@
-/*
+/*
* Copyright (C) 2003-2006 Gabest
* http://www.gabest.org
*
@@ -6,12 +6,12 @@
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, 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.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/src/filters/transform/VSFilter/AvgLines.cpp b/src/filters/transform/VSFilter/AvgLines.cpp
index 19e80a305..2a0b89311 100644
--- a/src/filters/transform/VSFilter/AvgLines.cpp
+++ b/src/filters/transform/VSFilter/AvgLines.cpp
@@ -20,28 +20,26 @@
void AvgLines8(BYTE* dst, DWORD h, DWORD pitch)
{
- if(h <= 1)
+ if(h <= 1) {
return;
+ }
BYTE* s = dst;
BYTE* d = dst + (h-2)*pitch;
- for(; s < d; s += pitch*2)
- {
+ 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
- {
+ 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
-AvgLines8_sse2_loop:
+ AvgLines8_sse2_loop:
movdqa xmm0, [esi]
pavgb xmm0, [esi+ebx*2]
movdqa [esi+ebx], xmm0
@@ -53,15 +51,11 @@ AvgLines8_sse2_loop:
mov tmp, esi
}
- for(ptrdiff_t i = pitch&7; i--; tmp++)
- {
+ 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
- {
+ } else if(g_cpuid.m_flags & CCpuID::mmx) {
+ __asm {
mov esi, tmp
mov ebx, pitch
@@ -69,7 +63,7 @@ AvgLines8_sse2_loop:
shr ecx, 3
pxor mm7, mm7
-AvgLines8_mmx_loop:
+ AvgLines8_mmx_loop:
movq mm0, [esi]
movq mm1, mm0
@@ -100,23 +94,19 @@ AvgLines8_mmx_loop:
mov tmp, esi
}
- for(ptrdiff_t i = pitch&7; i--; tmp++)
- {
+ for(ptrdiff_t i = pitch&7; i--; tmp++) {
tmp[pitch] = (tmp[0] + tmp[pitch<<1] + 1) >> 1;
}
- }
- else
+ } else
#endif
{
- for(ptrdiff_t i = pitch; i--; tmp++)
- {
+ for(ptrdiff_t i = pitch; i--; tmp++) {
tmp[pitch] = (tmp[0] + tmp[pitch<<1] + 1) >> 1;
}
}
}
- if(!(h&1) && h >= 2)
- {
+ if(!(h&1) && h >= 2) {
dst += (h-2)*pitch;
memcpy(dst + pitch, dst, pitch);
}
@@ -128,8 +118,9 @@ AvgLines8_mmx_loop:
void AvgLines555(BYTE* dst, DWORD h, DWORD pitch)
{
- if(h <= 1)
+ if(h <= 1) {
return;
+ }
unsigned __int64 __0x03e003e003e003e0 = 0x03e003e003e003e0;
unsigned __int64 __0x001f001f001f001f = 0x001f001f001f001f;
@@ -137,13 +128,11 @@ void AvgLines555(BYTE* dst, DWORD h, DWORD pitch)
BYTE* s = dst;
BYTE* d = dst + (h-2)*pitch;
- for(; s < d; s += pitch*2)
- {
+ for(; s < d; s += pitch*2) {
BYTE* tmp = s;
#ifndef _WIN64
- __asm
- {
+ __asm {
mov esi, tmp
mov ebx, pitch
@@ -153,7 +142,7 @@ void AvgLines555(BYTE* dst, DWORD h, DWORD pitch)
movq mm6, __0x03e003e003e003e0
movq mm7, __0x001f001f001f001f
-AvgLines555_loop:
+ AvgLines555_loop:
movq mm0, [esi]
movq mm1, mm0
movq mm2, mm0
@@ -196,8 +185,7 @@ AvgLines555_loop:
}
#endif
- for(ptrdiff_t i = (pitch&7)>>1; i--; tmp++)
- {
+ 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)|
@@ -205,8 +193,7 @@ AvgLines555_loop:
}
}
- if(!(h&1) && h >= 2)
- {
+ if(!(h&1) && h >= 2) {
dst += (h-2)*pitch;
memcpy(dst + pitch, dst, pitch);
}
@@ -218,8 +205,9 @@ AvgLines555_loop:
void AvgLines565(BYTE* dst, DWORD h, DWORD pitch)
{
- if(h <= 1)
+ if(h <= 1) {
return;
+ }
unsigned __int64 __0x07e007e007e007e0 = 0x07e007e007e007e0;
unsigned __int64 __0x001f001f001f001f = 0x001f001f001f001f;
@@ -227,13 +215,11 @@ void AvgLines565(BYTE* dst, DWORD h, DWORD pitch)
BYTE* s = dst;
BYTE* d = dst + (h-2)*pitch;
- for(; s < d; s += pitch*2)
- {
+ for(; s < d; s += pitch*2) {
WORD* tmp = (WORD*)s;
#ifndef _WIN64
- __asm
- {
+ __asm {
mov esi, tmp
mov ebx, pitch
@@ -243,7 +229,7 @@ void AvgLines565(BYTE* dst, DWORD h, DWORD pitch)
movq mm6, __0x07e007e007e007e0
movq mm7, __0x001f001f001f001f
-AvgLines565_loop:
+ AvgLines565_loop:
movq mm0, [esi]
movq mm1, mm0
movq mm2, mm0
@@ -285,8 +271,7 @@ AvgLines565_loop:
mov tmp, esi
}
#else
- for(ptrdiff_t wd=(pitch>>3); wd--; tmp++)
- {
+ 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)|
@@ -294,8 +279,7 @@ AvgLines565_loop:
}
#endif
- for(ptrdiff_t i = (pitch&7)>>1; i--; tmp++)
- {
+ 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)|
@@ -303,8 +287,7 @@ AvgLines565_loop:
}
}
- if(!(h&1) && h >= 2)
- {
+ if(!(h&1) && h >= 2) {
dst += (h-2)*pitch;
memcpy(dst + pitch, dst, pitch);
}
diff --git a/src/filters/transform/VSFilter/Copy.cpp b/src/filters/transform/VSFilter/Copy.cpp
index 7c6e077ea..575b2103d 100644
--- a/src/filters/transform/VSFilter/Copy.cpp
+++ b/src/filters/transform/VSFilter/Copy.cpp
@@ -33,82 +33,62 @@ extern void ColorConvInit();
void BltLineRGB32(DWORD* d, BYTE* sub, int w, const GUID& subtype)
{
- if(subtype == MEDIASUBTYPE_YV12 || subtype == MEDIASUBTYPE_I420 || subtype == MEDIASUBTYPE_IYUV)
- {
+ 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)
- {
+ 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)
- {
+ } else if(subtype == MEDIASUBTYPE_YUY2) {
WORD* ds = (WORD*)d;
WORD* dstend = ds + w;
- for(; ds < dstend; sub+=4, ds++)
- {
- if(sub[3] < 0xff)
- {
+ 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)
- {
+ } else if(subtype == MEDIASUBTYPE_RGB555) {
WORD* ds = (WORD*)d;
WORD* dstend = ds + w;
- for(; ds < dstend; sub+=4, ds++)
- {
- if(sub[3] < 0xff)
- {
+ 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)
- {
+ } else if(subtype == MEDIASUBTYPE_RGB565) {
WORD* ds = (WORD*)d;
WORD* dstend = ds + w;
- for(; ds < dstend; sub+=4, ds++)
- {
- if(sub[3] < 0xff)
- {
+ 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)
- {
+ } 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)
- {
+ 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)
- {
+ } 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;
+ for(; d < dstend; sub+=4, d++) {
+ if(sub[3] < 0xff) {
+ *d = *((DWORD*)sub)&0xffffff;
+ }
}
}
}
@@ -119,7 +99,9 @@ HRESULT CDirectVobSubFilter::Copy(BYTE* pSub, BYTE* pIn, CSize sub, CSize in, in
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;
@@ -136,32 +118,27 @@ HRESULT CDirectVobSubFilter::Copy(BYTE* pSub, BYTE* pIn, CSize sub, CSize in, in
j += (hSub - hIn) >> 1;
- for(; i < j; i++, pSub += pitchSub)
- {
+ for(; i < j; i++, pSub += pitchSub) {
memsetd(pSub, black, dpLeft+dpMid+dpRight);
}
j += hIn;
- if(hIn > hSub)
+ if(hIn > hSub) {
pIn += pitchIn * ((hIn - hSub) >> (fScale2x?2:1));
+ }
- if(fScale2x)
- {
+ 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)
- {
+ 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)
- {
+ } 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);
@@ -170,8 +147,7 @@ HRESULT CDirectVobSubFilter::Copy(BYTE* pSub, BYTE* pIn, CSize sub, CSize in, in
j = hSub;
- for(; i < j; i++, pSub += pitchSub)
- {
+ for(; i < j; i++, pSub += pitchSub) {
memsetd(pSub, black, dpLeft+dpMid+dpRight);
}
}
@@ -181,8 +157,9 @@ HRESULT CDirectVobSubFilter::Copy(BYTE* pSub, BYTE* pIn, CSize sub, CSize in, in
void CDirectVobSubFilter::PrintMessages(BYTE* pOut)
{
- if(!m_hdc || !m_hbm)
+ if(!m_hdc || !m_hbm) {
return;
+ }
ColorConvInit();
@@ -193,8 +170,7 @@ void CDirectVobSubFilter::PrintMessages(BYTE* pOut)
CString msg, tmp;
- if(m_fOSD)
- {
+ if(m_fOSD) {
tmp.Format(_T("in: %dx%d %s\nout: %dx%d %s\n"),
m_w, m_h,
Subtype2String(m_pInput->CurrentMediaType().subtype),
@@ -211,16 +187,14 @@ void CDirectVobSubFilter::PrintMessages(BYTE* pOut)
CAutoLock cAutoLock(&m_csQueueLock);
- if(m_pSubPicQueue)
- {
+ if(m_pSubPicQueue) {
int nSubPics = -1;
REFERENCE_TIME rtNow = -1, rtStart = -1, rtStop = -1;
m_pSubPicQueue->GetStats(nSubPics, rtNow, rtStart, rtStop);
tmp.Format(_T("queue stats: %I64d - %I64d [ms]\n"), rtStart/10000, rtStop/10000);
msg += tmp;
- for(ptrdiff_t i = 0; i < nSubPics; i++)
- {
+ for(ptrdiff_t i = 0; i < nSubPics; i++) {
m_pSubPicQueue->GetStats(i, rtStart, rtStop);
tmp.Format(_T("%d: %I64d - %I64d [ms]\n"), i, rtStart/10000, rtStop/10000);
msg += tmp;
@@ -229,7 +203,9 @@ void CDirectVobSubFilter::PrintMessages(BYTE* pOut)
}
}
- if(msg.IsEmpty()) return;
+ if(msg.IsEmpty()) {
+ return;
+ }
HANDLE hOldBitmap = SelectObject(m_hdc, m_hbm);
HANDLE hOldFont = SelectObject(m_hdc, m_hfont);
@@ -253,14 +229,14 @@ void CDirectVobSubFilter::PrintMessages(BYTE* pOut)
int pitchIn = bm.bmWidthBytes;
int pitchOut = bihOut.biWidth * bihOut.biBitCount >> 3;
- if(subtype == MEDIASUBTYPE_YV12 || subtype == MEDIASUBTYPE_I420 || subtype == MEDIASUBTYPE_IYUV)
+ if(subtype == MEDIASUBTYPE_YV12 || subtype == MEDIASUBTYPE_I420 || subtype == MEDIASUBTYPE_IYUV) {
pitchOut = bihOut.biWidth;
+ }
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)
- {
+ 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;
}
@@ -268,8 +244,7 @@ void CDirectVobSubFilter::PrintMessages(BYTE* pOut)
pIn += pitchIn * r.top;
pOut += pitchOut * r.top;
- for(ptrdiff_t w = min(r.right, m_w), h = r.Height(); h--; pIn += pitchIn, pOut += pitchOut)
- {
+ for(ptrdiff_t 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);
}
diff --git a/src/filters/transform/VSFilter/DirectVobSub.cpp b/src/filters/transform/VSFilter/DirectVobSub.cpp
index 59d3a8ec1..8ae4bba69 100644
--- a/src/filters/transform/VSFilter/DirectVobSub.cpp
+++ b/src/filters/transform/VSFilter/DirectVobSub.cpp
@@ -53,10 +53,12 @@ CDirectVobSub::CDirectVobSub()
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));
+ 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;
@@ -74,7 +76,9 @@ STDMETHODIMP CDirectVobSub::get_FileName(WCHAR* fn)
{
CAutoLock cAutoLock(&m_propsLock);
- if(!fn) return E_POINTER;
+ if(!fn) {
+ return E_POINTER;
+ }
#ifdef UNICODE
wcscpy(fn, m_FileName);
@@ -89,10 +93,14 @@ STDMETHODIMP CDirectVobSub::put_FileName(WCHAR* fn)
{
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;
+ if(!m_FileName.Left(m_FileName.ReverseFind('.')+1).CompareNoCase(tmp.Left(tmp.ReverseFind('.')+1))) {
+ return S_FALSE;
+ }
#ifdef UNICODE
m_FileName = fn;
@@ -130,13 +138,16 @@ STDMETHODIMP CDirectVobSub::put_SelectedLanguage(int iSelected)
{
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)
+ || iSelected < 0
+ || iSelected >= nCount) {
return E_FAIL;
+ }
m_iSelectedLanguage = iSelected;
@@ -154,7 +165,9 @@ STDMETHODIMP CDirectVobSub::put_HideSubtitles(bool fHideSubtitles)
{
CAutoLock cAutoLock(&m_propsLock);
- if(m_fHideSubtitles == fHideSubtitles) return S_FALSE;
+ if(m_fHideSubtitles == fHideSubtitles) {
+ return S_FALSE;
+ }
m_fHideSubtitles = fHideSubtitles;
@@ -172,7 +185,9 @@ STDMETHODIMP CDirectVobSub::put_PreBuffering(bool fDoPreBuffering)
{
CAutoLock cAutoLock(&m_propsLock);
- if(m_fDoPreBuffering == fDoPreBuffering) return S_FALSE;
+ if(m_fDoPreBuffering == fDoPreBuffering) {
+ return S_FALSE;
+ }
m_fDoPreBuffering = fDoPreBuffering;
@@ -183,9 +198,15 @@ STDMETHODIMP CDirectVobSub::get_Placement(bool* fOverridePlacement, int* xperc,
{
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;
}
@@ -194,7 +215,9 @@ STDMETHODIMP CDirectVobSub::put_Placement(bool fOverridePlacement, int xperc, in
{
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;
@@ -207,9 +230,15 @@ STDMETHODIMP CDirectVobSub::get_VobSubSettings(bool* fBuffer, bool* fOnlyShowFor
{
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;
}
@@ -218,7 +247,9 @@ STDMETHODIMP CDirectVobSub::put_VobSubSettings(bool fBuffer, bool fOnlyShowForce
{
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;
@@ -231,14 +262,14 @@ STDMETHODIMP CDirectVobSub::get_TextSettings(void* lf, int lflen, COLORREF* colo
{
CAutoLock cAutoLock(&m_propsLock);
- if(lf)
- {
- if(lflen == sizeof(LOGFONTA))
+ if(lf) {
+ if(lflen == sizeof(LOGFONTA)) {
strncpy_s(((LOGFONTA*)lf)->lfFaceName, LF_FACESIZE, CStringA(m_defStyle.fontName), _TRUNCATE);
- else if(lflen == sizeof(LOGFONTW))
+ } else if(lflen == sizeof(LOGFONTW)) {
wcsncpy_s(((LOGFONTW*)lf)->lfFaceName, LF_FACESIZE, CStringW(m_defStyle.fontName), _TRUNCATE);
- else
+ } else {
return E_INVALIDARG;
+ }
((LOGFONT*)lf)->lfCharSet = m_defStyle.charSet;
((LOGFONT*)lf)->lfItalic = m_defStyle.fItalic;
@@ -248,10 +279,18 @@ STDMETHODIMP CDirectVobSub::get_TextSettings(void* lf, int lflen, COLORREF* colo
((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;
+ 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;
}
@@ -260,14 +299,14 @@ STDMETHODIMP CDirectVobSub::put_TextSettings(void* lf, int lflen, COLORREF color
{
CAutoLock cAutoLock(&m_propsLock);
- if(lf)
- {
- if(lflen == sizeof(LOGFONTA))
+ if(lf) {
+ if(lflen == sizeof(LOGFONTA)) {
m_defStyle.fontName = ((LOGFONTA*)lf)->lfFaceName;
- else if(lflen == sizeof(LOGFONTW))
+ } else if(lflen == sizeof(LOGFONTW)) {
m_defStyle.fontName = ((LOGFONTW*)lf)->lfFaceName;
- else
+ } else {
return E_INVALIDARG;
+ }
m_defStyle.charSet = ((LOGFONT*)lf)->lfCharSet;
m_defStyle.fItalic = !!((LOGFONT*)lf)->lfItalic;
@@ -276,8 +315,7 @@ STDMETHODIMP CDirectVobSub::put_TextSettings(void* lf, int lflen, COLORREF color
m_defStyle.fStrikeOut = !!((LOGFONT*)lf)->lfStrikeOut;
m_defStyle.fUnderline = !!((LOGFONT*)lf)->lfUnderline;
- if(m_defStyle.fontSize < 0)
- {
+ if(m_defStyle.fontSize < 0) {
HDC hdc = ::GetDC(0);
m_defStyle.fontSize = -m_defStyle.fontSize * 72 / GetDeviceCaps(hdc, LOGPIXELSY);
::ReleaseDC(0, hdc);
@@ -297,8 +335,12 @@ STDMETHODIMP CDirectVobSub::get_Flip(bool* fPicture, bool* fSubtitles)
{
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;
}
@@ -307,7 +349,9 @@ STDMETHODIMP CDirectVobSub::put_Flip(bool fPicture, bool fSubtitles)
{
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;
@@ -326,7 +370,9 @@ STDMETHODIMP CDirectVobSub::put_OSD(bool fOSD)
{
CAutoLock cAutoLock(&m_propsLock);
- if(m_fOSD == fOSD) return S_FALSE;
+ if(m_fOSD == fOSD) {
+ return S_FALSE;
+ }
m_fOSD = fOSD;
@@ -344,7 +390,9 @@ STDMETHODIMP CDirectVobSub::put_SaveFullPath(bool fSaveFullPath)
{
CAutoLock cAutoLock(&m_propsLock);
- if(m_fSaveFullPath == fSaveFullPath) return S_FALSE;
+ if(m_fSaveFullPath == fSaveFullPath) {
+ return S_FALSE;
+ }
m_fSaveFullPath = fSaveFullPath;
@@ -355,9 +403,15 @@ STDMETHODIMP CDirectVobSub::get_SubtitleTiming(int* delay, int* speedmul, int* s
{
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;
}
@@ -366,11 +420,15 @@ STDMETHODIMP CDirectVobSub::put_SubtitleTiming(int delay, int speedmul, int spee
{
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;
+ if(speeddiv > 0) {
+ m_SubtitleSpeedDiv = speeddiv;
+ }
return S_OK;
}
@@ -379,8 +437,12 @@ STDMETHODIMP CDirectVobSub::get_MediaFPS(bool* fEnabled, double* fps)
{
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;
}
@@ -389,10 +451,14 @@ STDMETHODIMP CDirectVobSub::put_MediaFPS(bool fEnabled, double fps)
{
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;
+ if(fps > 0) {
+ m_MediaFPS = fps;
+ }
return S_OK;
}
@@ -401,7 +467,9 @@ STDMETHODIMP CDirectVobSub::get_ZoomRect(NORMALIZEDRECT* rect)
{
CAutoLock cAutoLock(&m_propsLock);
- if(!rect) return E_POINTER;
+ if(!rect) {
+ return E_POINTER;
+ }
*rect = m_ZoomRect;
@@ -412,9 +480,13 @@ STDMETHODIMP CDirectVobSub::put_ZoomRect(NORMALIZEDRECT* rect)
{
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;
@@ -465,7 +537,9 @@ STDMETHODIMP CDirectVobSub::IsSubtitleReloaderLocked(bool* fLocked)
{
CAutoLock cAutoLock(&m_propsLock);
- if(!fLocked) return E_POINTER;
+ if(!fLocked) {
+ return E_POINTER;
+ }
bool fDisabled;
get_SubtitleReloader(&fDisabled);
@@ -479,11 +553,16 @@ STDMETHODIMP CDirectVobSub::LockSubtitleReloader(bool fLock)
{
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;
+ if(m_nReloaderDisableCount < 0) {
+ m_nReloaderDisableCount = 0;
+ }
return S_OK;
}
@@ -494,7 +573,9 @@ STDMETHODIMP CDirectVobSub::get_SubtitleReloader(bool* fDisabled)
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;
}
@@ -507,7 +588,9 @@ STDMETHODIMP CDirectVobSub::put_SubtitleReloader(bool fDisable)
bool b;
get_SubtitleReloader(&b);
- if(b == fDisable) return S_FALSE;
+ if(b == fDisable) {
+ return S_FALSE;
+ }
theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_DISABLERELOADER), fDisable);
@@ -520,11 +603,21 @@ STDMETHODIMP CDirectVobSub::get_ExtendPicture(int* horizontal, int* vertical, in
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;
}
@@ -537,7 +630,9 @@ STDMETHODIMP CDirectVobSub::put_ExtendPicture(int horizontal, int vertical, int
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;
+ 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);
@@ -554,10 +649,18 @@ STDMETHODIMP CDirectVobSub::get_LoadSettings(int* level, bool* fExternalLoad, bo
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;
}
@@ -571,7 +674,9 @@ STDMETHODIMP CDirectVobSub::put_LoadSettings(int level, bool fExternalLoad, bool
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;
+ 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);
@@ -617,8 +722,9 @@ STDMETHODIMP CDirectVobSub::put_TextSettings(STSStyle* pDefStyle)
CAutoLock cAutoLock(&m_propsLock);
- if(!memcmp(&m_defStyle, pDefStyle, sizeof(m_defStyle)))
+ if(!memcmp(&m_defStyle, pDefStyle, sizeof(m_defStyle))) {
return S_FALSE;
+ }
m_defStyle = *pDefStyle;
diff --git a/src/filters/transform/VSFilter/DirectVobSub.h b/src/filters/transform/VSFilter/DirectVobSub.h
index 7f6edcba4..1c3917707 100644
--- a/src/filters/transform/VSFilter/DirectVobSub.h
+++ b/src/filters/transform/VSFilter/DirectVobSub.h
@@ -91,8 +91,12 @@ public:
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 get_ColorFormat(int* iPosition) {
+ return E_NOTIMPL;
+ }
+ STDMETHODIMP put_ColorFormat(int iPosition) {
+ return E_NOTIMPL;
+ }
STDMETHODIMP UpdateRegistry();
diff --git a/src/filters/transform/VSFilter/DirectVobSubFilter.cpp b/src/filters/transform/VSFilter/DirectVobSubFilter.cpp
index 1d0726364..935e29b57 100644
--- a/src/filters/transform/VSFilter/DirectVobSubFilter.cpp
+++ b/src/filters/transform/VSFilter/DirectVobSubFilter.cpp
@@ -100,7 +100,9 @@ CDirectVobSubFilter::CDirectVobSubFilter(LPUNKNOWN punk, HRESULT* phr, const GUI
CDirectVobSubFilter::~CDirectVobSubFilter()
{
CAutoLock cAutoLock(&m_csQueueLock);
- if(m_pSubPicQueue) m_pSubPicQueue->Invalidate();
+ if(m_pSubPicQueue) {
+ m_pSubPicQueue->Invalidate();
+ }
m_pSubPicQueue = NULL;
if(m_hfont) {
@@ -116,8 +118,9 @@ CDirectVobSubFilter::~CDirectVobSubFilter()
m_hdc = 0;
}
- for(ptrdiff_t i = 0; i < m_pTextInput.GetCount(); i++)
+ for(ptrdiff_t i = 0; i < m_pTextInput.GetCount(); i++) {
delete m_pTextInput[i];
+ }
m_frd.EndThreadEvent.Set();
CAMThread::Close();
@@ -145,15 +148,17 @@ void CDirectVobSubFilter::GetOutputSize(int& w, int& h, int& arx, int& ary)
w = s.cx;
h = s.cy;
- if(w != os.cx)
- {
- while(arx < 100) arx *= 10, ary *= 10;
+ 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;
+ if(h != os.cy) {
+ while(ary < 100) {
+ arx *= 10, ary *= 10;
+ }
ary = ary * h / os.cy;
}
}
@@ -164,18 +169,17 @@ HRESULT CDirectVobSubFilter::Transform(IMediaSample* pIn)
REFERENCE_TIME rtStart, rtStop;
- if(SUCCEEDED(pIn->GetTime(&rtStart, &rtStop)))
- {
+ if(SUCCEEDED(pIn->GetTime(&rtStart, &rtStop))) {
double dRate = m_pInput->CurrentRate();
m_tPrev = m_pInput->CurrentStartTime() + dRate*rtStart;
REFERENCE_TIME rtAvgTimePerFrame = rtStop - rtStart;
- if(CComQIPtr<ISubClock2> pSC2 = m_pSubClock)
- {
+ if(CComQIPtr<ISubClock2> pSC2 = m_pSubClock) {
REFERENCE_TIME rt;
- if(S_OK == pSC2->GetAvgTimePerFrame(&rt))
+ if(S_OK == pSC2->GetAvgTimePerFrame(&rt)) {
rtAvgTimePerFrame = rt;
+ }
}
m_fps = 10000000.0/rtAvgTimePerFrame / dRate;
@@ -186,8 +190,7 @@ HRESULT CDirectVobSubFilter::Transform(IMediaSample* pIn)
{
CAutoLock cAutoLock(&m_csQueueLock);
- if(m_pSubPicQueue)
- {
+ if(m_pSubPicQueue) {
m_pSubPicQueue->SetTime(CalcCurrentTime());
m_pSubPicQueue->SetFPS(m_fps);
}
@@ -196,8 +199,9 @@ HRESULT CDirectVobSubFilter::Transform(IMediaSample* pIn)
//
BYTE* pDataIn = NULL;
- if(FAILED(pIn->GetPointer(&pDataIn)) || !pDataIn)
+ if(FAILED(pIn->GetPointer(&pDataIn)) || !pDataIn) {
return S_FALSE;
+ }
const CMediaType& mt = m_pInput->CurrentMediaType();
@@ -211,11 +215,11 @@ HRESULT CDirectVobSubFilter::Transform(IMediaSample* pIn)
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)))
+ if(FAILED(Copy((BYTE*)m_pTempPicBuff, pDataIn, sub, in, bpp, mt.subtype, black))) {
return E_FAIL;
+ }
- if(fYV12)
- {
+ 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;
@@ -224,10 +228,12 @@ HRESULT CDirectVobSubFilter::Transform(IMediaSample* pIn)
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)))
+ 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)))
+ }
+ if(FAILED(Copy(pSubU, pInU, sub, in, bpp, mt.subtype, 0x80808080))) {
return E_FAIL;
+ }
}
//
@@ -237,8 +243,9 @@ HRESULT CDirectVobSubFilter::Transform(IMediaSample* pIn)
CComPtr<IMediaSample> pOut;
BYTE* pDataOut = NULL;
if(FAILED(hr = GetDeliveryBuffer(spd.w, spd.h, &pOut))
- || FAILED(hr = pOut->GetPointer(&pDataOut)))
+ || FAILED(hr = pOut->GetPointer(&pDataOut))) {
return hr;
+ }
pOut->SetTime(&rtStart, &rtStop);
pOut->SetMediaTime(NULL, NULL);
@@ -256,27 +263,32 @@ HRESULT CDirectVobSubFilter::Transform(IMediaSample* pIn)
bool fOutputFlipped = bihOut.biHeight >= 0 && bihOut.biCompression <= 3;
bool fFlip = fInputFlipped != fOutputFlipped;
- if(m_fFlipPicture) fFlip = !fFlip;
- if(m_fMSMpeg4Fix) fFlip = !fFlip;
+ if(m_fFlipPicture) {
+ fFlip = !fFlip;
+ }
+ if(m_fMSMpeg4Fix) {
+ fFlip = !fFlip;
+ }
bool fFlipSub = fOutputFlipped;
- if(m_fFlipSubtitles) fFlipSub = !fFlipSub;
+ if(m_fFlipSubtitles) {
+ fFlipSub = !fFlipSub;
+ }
//
{
CAutoLock cAutoLock(&m_csQueueLock);
- if(m_pSubPicQueue)
- {
+ if(m_pSubPicQueue) {
CComPtr<ISubPic> pSubPic;
- if(SUCCEEDED(m_pSubPicQueue->LookupSubPic(CalcCurrentTime(), pSubPic)) && pSubPic)
- {
+ if(SUCCEEDED(m_pSubPicQueue->LookupSubPic(CalcCurrentTime(), pSubPic)) && pSubPic) {
CRect r;
pSubPic->GetDirtyRect(r);
- if(fFlip ^ fFlipSub)
+ if(fFlip ^ fFlipSub) {
spd.h = -spd.h;
+ }
pSubPic->AlphaBlt(r, r, &spd);
}
@@ -294,13 +306,15 @@ HRESULT CDirectVobSubFilter::Transform(IMediaSample* pIn)
CBasePin* CDirectVobSubFilter::GetPin(int n)
{
- if(n < __super::GetPinCount())
+ if(n < __super::GetPinCount()) {
return __super::GetPin(n);
+ }
n -= __super::GetPinCount();
- if(n >= 0 && n < m_pTextInput.GetCount())
+ if(n >= 0 && n < m_pTextInput.GetCount()) {
return m_pTextInput[n];
+ }
n -= m_pTextInput.GetCount();
@@ -314,21 +328,17 @@ int CDirectVobSubFilter::GetPinCount()
HRESULT CDirectVobSubFilter::JoinFilterGraph(IFilterGraph* pGraph, LPCWSTR pName)
{
- if(pGraph)
- {
+ if(pGraph) {
AFX_MANAGE_STATE(AfxGetStaticModuleState());
- if(!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_SEENDIVXWARNING), 0))
- {
+ 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)
- {
+ 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)
- {
+ if(dwVersion < 0x80000000 && dwWindowsMajorVersion >= 5) {
AfxMessageBox(IDS_DIVX_WARNING);
theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_SEENDIVXWARNING), 1);
}
@@ -336,20 +346,15 @@ HRESULT CDirectVobSubFilter::JoinFilterGraph(IFilterGraph* pGraph, LPCWSTR pName
}
/*removeme*/
- if(!g_RegOK)
- {
+ if(!g_RegOK) {
DllRegisterServer();
g_RegOK = true;
}
- }
- else
- {
- if(m_hSystrayThread)
- {
+ } else {
+ if(m_hSystrayThread) {
SendMessage(m_tbid.hSystrayWnd, WM_CLOSE, 0, 0);
- if(WaitForSingleObject(m_hSystrayThread, 10000) != WAIT_OBJECT_0)
- {
+ if(WaitForSingleObject(m_hSystrayThread, 10000) != WAIT_OBJECT_0) {
DbgLog((LOG_TRACE, 0, _T("CALL THE AMBULANCE!!!")));
TerminateThread(m_hSystrayThread, (DWORD)-1);
}
@@ -366,13 +371,15 @@ STDMETHODIMP CDirectVobSubFilter::QueryFilterInfo(FILTER_INFO* pInfo)
CheckPointer(pInfo, E_POINTER);
ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));
- if(!get_Forced())
+ if(!get_Forced()) {
return __super::QueryFilterInfo(pInfo);
+ }
wcscpy(pInfo->achName, L"DirectVobSub (forced auto-loading version)");
pInfo->pGraph = m_pGraph;
- if(m_pGraph)
+ if(m_pGraph) {
m_pGraph->AddRef();
+ }
return S_OK;
}
@@ -382,10 +389,11 @@ STDMETHODIMP CDirectVobSubFilter::QueryFilterInfo(FILTER_INFO* pInfo)
HRESULT CDirectVobSubFilter::SetMediaType(PIN_DIRECTION dir, const CMediaType* pmt)
{
HRESULT hr = __super::SetMediaType(dir, pmt);
- if(FAILED(hr)) return hr;
+ if(FAILED(hr)) {
+ return hr;
+ }
- if(dir == PINDIR_INPUT)
- {
+ if(dir == PINDIR_INPUT) {
CAutoLock cAutoLock(&m_csReceive);
REFERENCE_TIME atpf =
@@ -395,13 +403,12 @@ HRESULT CDirectVobSubFilter::SetMediaType(PIN_DIRECTION dir, const CMediaType* p
m_fps = atpf ? 10000000.0 / atpf : 25;
- if (pmt->formattype == FORMAT_VideoInfo2)
+ if (pmt->formattype == FORMAT_VideoInfo2) {
m_CurrentVIH2 = *(VIDEOINFOHEADER2*)pmt->Format();
+ }
InitSubPicQueue();
- }
- else if(dir == PINDIR_OUTPUT)
- {
+ } else if(dir == PINDIR_OUTPUT) {
}
@@ -410,11 +417,8 @@ HRESULT CDirectVobSubFilter::SetMediaType(PIN_DIRECTION dir, const CMediaType* p
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);
@@ -422,24 +426,19 @@ HRESULT CDirectVobSubFilter::CheckConnect(PIN_DIRECTION dir, IPin* pPin)
HRESULT CDirectVobSubFilter::CompleteConnect(PIN_DIRECTION dir, IPin* pReceivePin)
{
- if(dir == PINDIR_INPUT)
- {
+ 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)
- {
+ && (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)
- {
+ } else if(dir == PINDIR_OUTPUT) {
+ if(!m_hSystrayThread) {
m_tbid.graph = m_pGraph;
m_tbid.dvs = static_cast<IDirectVobSub*>(this);
@@ -456,16 +455,12 @@ HRESULT CDirectVobSubFilter::CompleteConnect(PIN_DIRECTION dir, IPin* pReceivePi
HRESULT CDirectVobSubFilter::BreakConnect(PIN_DIRECTION dir)
{
- if(dir == PINDIR_INPUT)
- {
- if(m_pOutput->IsConnected())
- {
+ if(dir == PINDIR_INPUT) {
+ if(m_pOutput->IsConnected()) {
m_pOutput->GetConnected()->Disconnect();
m_pOutput->Disconnect();
}
- }
- else if(dir == PINDIR_OUTPUT)
- {
+ } else if(dir == PINDIR_OUTPUT) {
// not really needed, but may free up a little memory
CAutoLock cAutoLock(&m_csQueueLock);
m_pSubPicQueue = NULL;
@@ -526,13 +521,21 @@ void CDirectVobSubFilter::InitSubPicQueue()
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;
+ 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;
@@ -542,7 +545,9 @@ void CDirectVobSubFilter::InitSubPicQueue()
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;
+ if(AdjustFrameSize(window)) {
+ video += video;
+ }
ASSERT(window == CSize(m_w, m_h));
pSubPicAllocator->SetCurSize(window);
@@ -553,7 +558,9 @@ void CDirectVobSubFilter::InitSubPicQueue()
? (ISubPicQueue*)new CSubPicQueue(10, false, pSubPicAllocator, &hr)
: (ISubPicQueue*)new CSubPicQueueNoThread(pSubPicAllocator, &hr);
- if(FAILED(hr)) m_pSubPicQueue = NULL;
+ if(FAILED(hr)) {
+ m_pSubPicQueue = NULL;
+ }
UpdateSubtitle(false);
@@ -585,35 +592,40 @@ bool CDirectVobSubFilter::AdjustFrameSize(CSize& s)
bool fRet = (resx2 == 1) || (resx2 == 2 && s.cx*s.cy <= resx2minw*resx2minh);
- if(fRet)
- {
+ 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)
- {
+ 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;
}
@@ -623,13 +635,16 @@ bool CDirectVobSubFilter::AdjustFrameSize(CSize& s)
STDMETHODIMP CDirectVobSubFilter::Count(DWORD* pcStreams)
{
- if(!pcStreams) return E_POINTER;
+ if(!pcStreams) {
+ return E_POINTER;
+ }
*pcStreams = 0;
int nLangs = 0;
- if(SUCCEEDED(get_LanguageCount(&nLangs)))
+ if(SUCCEEDED(get_LanguageCount(&nLangs))) {
(*pcStreams) += nLangs;
+ }
(*pcStreams) += 2; // enable ... disable
@@ -647,26 +662,27 @@ int CDirectVobSubFilter::FindPreferedLanguage(bool fHideToo)
int nLangs;
get_LanguageCount(&nLangs);
- if(nLangs <= 0) return(0);
+ if(nLangs <= 0) {
+ return(0);
+ }
- for(ptrdiff_t i = 0; i < MAXPREFLANGS; 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);
- if(!lang.IsEmpty())
- {
- for(ptrdiff_t ret = 0; ret < nLangs; ret++)
- {
+ if(!lang.IsEmpty()) {
+ for(ptrdiff_t 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);
+ }
}
}
}
@@ -681,30 +697,28 @@ void CDirectVobSubFilter::UpdatePreferedLanguages(CString l)
CString langs[MAXPREFLANGS+1];
int i = 0, j = 0, k = -1;
- for(; i < MAXPREFLANGS; i++)
- {
+ 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;
+ if(!langs[j].IsEmpty()) {
+ if(!langs[j].CompareNoCase(l)) {
+ k = j;
+ }
j++;
}
}
- if(k == -1)
- {
+ if(k == -1) {
langs[k = j] = l;
j++;
}
// move the selected to the top of the list
- while(k > 0)
- {
+ while(k > 0) {
CString tmp = langs[k];
langs[k] = langs[k-1];
langs[k-1] = tmp;
@@ -716,21 +730,20 @@ void CDirectVobSubFilter::UpdatePreferedLanguages(CString l)
CString hidesubs;
hidesubs.LoadString(IDS_M_HIDESUBTITLES);
- for(k = 1; k < j; k++)
- {
- if(!langs[k].CompareNoCase(hidesubs)) break;
+ for(k = 1; k < j; k++) {
+ if(!langs[k].CompareNoCase(hidesubs)) {
+ break;
+ }
}
- while(k < j-1)
- {
+ while(k < j-1) {
CString tmp = langs[k];
langs[k] = langs[k+1];
langs[k+1] = tmp;
k++;
}
- for(i = 0; i < j; i++)
- {
+ for(i = 0; i < j; i++) {
CString tmp;
tmp.Format(IDS_RL_LANG, i);
@@ -740,39 +753,35 @@ void CDirectVobSubFilter::UpdatePreferedLanguages(CString l)
STDMETHODIMP CDirectVobSubFilter::Enable(long lIndex, DWORD dwFlags)
{
- if(!(dwFlags & AMSTREAMSELECTENABLE_ENABLE))
+ if(!(dwFlags & AMSTREAMSELECTENABLE_ENABLE)) {
return E_NOTIMPL;
+ }
int nLangs = 0;
get_LanguageCount(&nLangs);
- if(!(lIndex >= 0 && lIndex < nLangs+2+2))
+ 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
- {
+ 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)
- {
+ } else if(i >= 0 && i < nLangs) {
put_HideSubtitles(false);
put_SelectedLanguage(i);
WCHAR* pName = NULL;
- if(SUCCEEDED(get_LanguageName(i, &pName)))
- {
+ if(SUCCEEDED(get_LanguageName(i, &pName))) {
UpdatePreferedLanguages(CString(pName));
- if(pName) CoTaskMemFree(pName);
+ if(pName) {
+ CoTaskMemFree(pName);
+ }
}
- }
- else if(i == nLangs && !m_fLoading)
- {
+ } else if(i == nLangs && !m_fLoading) {
put_HideSubtitles(true);
- }
- else if((i == nLangs+1 || i == nLangs+2) && !m_fLoading)
- {
+ } else if((i == nLangs+1 || i == nLangs+2) && !m_fLoading) {
put_Flip(i == nLangs+2, m_fFlipSubtitles);
}
@@ -786,66 +795,83 @@ STDMETHODIMP CDirectVobSubFilter::Info(long lIndex, AM_MEDIA_TYPE** ppmt, DWORD*
int nLangs = 0;
get_LanguageCount(&nLangs);
- if(!(lIndex >= 0 && lIndex < nLangs+2+2))
+ if(!(lIndex >= 0 && lIndex < nLangs+2+2)) {
return E_INVALIDARG;
+ }
int i = lIndex-1;
- if(ppmt) *ppmt = CreateMediaType(&m_pInput->CurrentMediaType());
+ if(ppmt) {
+ *ppmt = CreateMediaType(&m_pInput->CurrentMediaType());
+ }
- if(pdwFlags)
- {
+ 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)
- {
+ || 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(plcid) {
+ *plcid = 0;
+ }
- if(pdwGroup) *pdwGroup = 0x648E51;
+ if(pdwGroup) {
+ *pdwGroup = 0x648E51;
+ }
- if(ppszName)
- {
+ if(ppszName) {
*ppszName = NULL;
CStringW str;
- if(i == -1) str = ResStr(IDS_M_SHOWSUBTITLES);
- else if(i >= 0 && i < nLangs) get_LanguageName(i, ppszName);
- else if(i == nLangs) str = ResStr(IDS_M_HIDESUBTITLES);
- else if(i == nLangs+1) {
+ if(i == -1) {
+ str = ResStr(IDS_M_SHOWSUBTITLES);
+ } else if(i >= 0 && i < nLangs) {
+ get_LanguageName(i, ppszName);
+ } else if(i == nLangs) {
+ str = ResStr(IDS_M_HIDESUBTITLES);
+ } else if(i == nLangs+1) {
str = ResStr(IDS_M_ORIGINALPICTURE);
- if(pdwGroup) (*pdwGroup)++;
- }
- else if(i == nLangs+2) {
+ if(pdwGroup) {
+ (*pdwGroup)++;
+ }
+ } else if(i == nLangs+2) {
str = ResStr(IDS_M_FLIPPEDPICTURE);
- if(pdwGroup) (*pdwGroup)++;
+ if(pdwGroup) {
+ (*pdwGroup)++;
+ }
}
- if(!str.IsEmpty())
- {
+ if(!str.IsEmpty()) {
*ppszName = (WCHAR*)CoTaskMemAlloc((str.GetLength()+1)*sizeof(WCHAR));
- if(*ppszName == NULL) return S_FALSE;
+ if(*ppszName == NULL) {
+ return S_FALSE;
+ }
wcscpy(*ppszName, str);
}
}
- if(ppObject) *ppObject = NULL;
+ if(ppObject) {
+ *ppObject = NULL;
+ }
- if(ppUnk) *ppUnk = NULL;
+ if(ppUnk) {
+ *ppUnk = NULL;
+ }
return S_OK;
}
STDMETHODIMP CDirectVobSubFilter::GetClassID(CLSID* pClsid)
{
- if(pClsid == NULL) return E_POINTER;
+ if(pClsid == NULL) {
+ return E_POINTER;
+ }
*pClsid = m_clsid;
return NOERROR;
}
@@ -857,7 +883,9 @@ STDMETHODIMP CDirectVobSubFilter::GetPages(CAUUID* pPages)
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);
@@ -877,8 +905,7 @@ STDMETHODIMP CDirectVobSubFilter::put_FileName(WCHAR* fn)
{
HRESULT hr = CDirectVobSub::put_FileName(fn);
- if(hr == S_OK && !Open())
- {
+ if(hr == S_OK && !Open()) {
m_FileName.Empty();
hr = E_FAIL;
}
@@ -890,13 +917,14 @@ STDMETHODIMP CDirectVobSubFilter::get_LanguageCount(int* nLangs)
{
HRESULT hr = CDirectVobSub::get_LanguageCount(nLangs);
- if(hr == NOERROR && nLangs)
- {
+ if(hr == NOERROR && nLangs) {
CAutoLock cAutolock(&m_csQueueLock);
*nLangs = 0;
POSITION pos = m_pSubStreams.GetHeadPosition();
- while(pos) (*nLangs) += m_pSubStreams.GetNext(pos)->GetStreamCount();
+ while(pos) {
+ (*nLangs) += m_pSubStreams.GetNext(pos)->GetStreamCount();
+ }
}
return hr;
@@ -906,10 +934,11 @@ STDMETHODIMP CDirectVobSubFilter::get_LanguageName(int iLanguage, WCHAR** ppName
{
HRESULT hr = CDirectVobSub::get_LanguageName(iLanguage, ppName);
- if(!ppName) return E_POINTER;
+ if(!ppName) {
+ return E_POINTER;
+ }
- if(hr == NOERROR)
- {
+ if(hr == NOERROR) {
CAutoLock cAutolock(&m_csQueueLock);
hr = E_INVALIDARG;
@@ -917,12 +946,10 @@ STDMETHODIMP CDirectVobSubFilter::get_LanguageName(int iLanguage, WCHAR** ppName
int i = iLanguage;
POSITION pos = m_pSubStreams.GetHeadPosition();
- while(i >= 0 && pos)
- {
+ while(i >= 0 && pos) {
CComPtr<ISubStream> pSubStream = m_pSubStreams.GetNext(pos);
- if(i < pSubStream->GetStreamCount())
- {
+ if(i < pSubStream->GetStreamCount()) {
pSubStream->GetStreamInfo(i, ppName, NULL);
hr = NOERROR;
break;
@@ -939,8 +966,7 @@ STDMETHODIMP CDirectVobSubFilter::put_SelectedLanguage(int iSelected)
{
HRESULT hr = CDirectVobSub::put_SelectedLanguage(iSelected);
- if(hr == NOERROR)
- {
+ if(hr == NOERROR) {
UpdateSubtitle(false);
}
@@ -951,8 +977,7 @@ STDMETHODIMP CDirectVobSubFilter::put_HideSubtitles(bool fHideSubtitles)
{
HRESULT hr = CDirectVobSub::put_HideSubtitles(fHideSubtitles);
- if(hr == NOERROR)
- {
+ if(hr == NOERROR) {
UpdateSubtitle(false);
}
@@ -963,8 +988,7 @@ STDMETHODIMP CDirectVobSubFilter::put_PreBuffering(bool fDoPreBuffering)
{
HRESULT hr = CDirectVobSub::put_PreBuffering(fDoPreBuffering);
- if(hr == NOERROR)
- {
+ if(hr == NOERROR) {
InitSubPicQueue();
}
@@ -975,8 +999,7 @@ STDMETHODIMP CDirectVobSubFilter::put_Placement(bool fOverridePlacement, int xpe
{
HRESULT hr = CDirectVobSub::put_Placement(fOverridePlacement, xperc, yperc);
- if(hr == NOERROR)
- {
+ if(hr == NOERROR) {
UpdateSubtitle(true);
}
@@ -987,9 +1010,8 @@ STDMETHODIMP CDirectVobSubFilter::put_VobSubSettings(bool fBuffer, bool fOnlySho
{
HRESULT hr = CDirectVobSub::put_VobSubSettings(fBuffer, fOnlyShowForcedSubs, fReserved);
- if(hr == NOERROR)
- {
-// UpdateSubtitle(false);
+ if(hr == NOERROR) {
+ // UpdateSubtitle(false);
InvalidateSubtitle();
}
@@ -1000,9 +1022,8 @@ STDMETHODIMP CDirectVobSubFilter::put_TextSettings(void* lf, int lflen, COLORREF
{
HRESULT hr = CDirectVobSub::put_TextSettings(lf, lflen, color, fShadow, fOutline, fAdvancedRenderer);
- if(hr == NOERROR)
- {
-// UpdateSubtitle(true);
+ if(hr == NOERROR) {
+ // UpdateSubtitle(true);
InvalidateSubtitle();
}
@@ -1013,8 +1034,7 @@ STDMETHODIMP CDirectVobSubFilter::put_SubtitleTiming(int delay, int speedmul, in
{
HRESULT hr = CDirectVobSub::put_SubtitleTiming(delay, speedmul, speeddiv);
- if(hr == NOERROR)
- {
+ if(hr == NOERROR) {
InvalidateSubtitle();
}
@@ -1027,10 +1047,11 @@ STDMETHODIMP CDirectVobSubFilter::get_MediaFPS(bool* fEnabled, double* fps)
CComQIPtr<IMediaSeeking> pMS = m_pGraph;
double rate;
- if(pMS && SUCCEEDED(pMS->GetRate(&rate)))
- {
+ if(pMS && SUCCEEDED(pMS->GetRate(&rate))) {
m_MediaFPS = rate * m_fps;
- if(fps) *fps = m_MediaFPS;
+ if(fps) {
+ *fps = m_MediaFPS;
+ }
}
return hr;
@@ -1041,16 +1062,15 @@ STDMETHODIMP CDirectVobSubFilter::put_MediaFPS(bool fEnabled, double fps)
HRESULT hr = CDirectVobSub::put_MediaFPS(fEnabled, fps);
CComQIPtr<IMediaSeeking> pMS = m_pGraph;
- if(pMS)
- {
- if(hr == NOERROR)
- {
+ if(pMS) {
+ if(hr == NOERROR) {
hr = pMS->SetRate(m_fMediaFPSEnabled ? m_MediaFPS / m_fps : 1.0);
}
double dRate;
- if(SUCCEEDED(pMS->GetRate(&dRate)))
+ if(SUCCEEDED(pMS->GetRate(&dRate))) {
m_MediaFPS = dRate * m_fps;
+ }
}
return hr;
@@ -1072,8 +1092,7 @@ STDMETHODIMP CDirectVobSubFilter::put_TextSettings(STSStyle* pDefStyle)
{
HRESULT hr = CDirectVobSub::put_TextSettings(pDefStyle);
- if(hr == NOERROR)
- {
+ if(hr == NOERROR) {
UpdateSubtitle(true);
}
@@ -1084,8 +1103,7 @@ STDMETHODIMP CDirectVobSubFilter::put_AspectRatioSettings(CSimpleTextSubtitle::E
{
HRESULT hr = CDirectVobSub::put_AspectRatioSettings(ePARCompensationType);
- if(hr == NOERROR)
- {
+ if(hr == NOERROR) {
UpdateSubtitle(true);
}
@@ -1097,10 +1115,12 @@ STDMETHODIMP CDirectVobSubFilter::put_AspectRatioSettings(CSimpleTextSubtitle::E
STDMETHODIMP CDirectVobSubFilter::HasConfigDialog(int iSelected)
{
int nLangs;
- if(FAILED(get_LanguageCount(&nLangs))) return E_FAIL;
+ 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);
+ // return(nLangs >= 0 && iSelected < nLangs ? S_OK : E_FAIL);
}
STDMETHODIMP CDirectVobSubFilter::ShowConfigDialog(int iSelected, HWND hWndParent)
@@ -1119,19 +1139,21 @@ CDirectVobSubFilter2::CDirectVobSubFilter2(LPUNKNOWN punk, HRESULT* phr, const G
HRESULT CDirectVobSubFilter2::CheckConnect(PIN_DIRECTION dir, IPin* pPin)
{
CPinInfo pi;
- if(FAILED(pPin->QueryPinInfo(&pi))) return E_FAIL;
+ if(FAILED(pPin->QueryPinInfo(&pi))) {
+ return E_FAIL;
+ }
- if(CComQIPtr<IDirectVobSub>(pi.pFilter)) return E_FAIL;
+ if(CComQIPtr<IDirectVobSub>(pi.pFilter)) {
+ return E_FAIL;
+ }
- if(dir == PINDIR_INPUT)
- {
+ if(dir == PINDIR_INPUT) {
CFilterInfo fi;
if(SUCCEEDED(pi.pFilter->QueryFilterInfo(&fi))
- && !wcsnicmp(fi.achName, L"Overlay Mixer", 13))
+ && !wcsnicmp(fi.achName, L"Overlay Mixer", 13)) {
return(E_FAIL);
- }
- else
- {
+ }
+ } else {
}
return __super::CheckConnect(dir, pPin);
@@ -1139,12 +1161,11 @@ HRESULT CDirectVobSubFilter2::CheckConnect(PIN_DIRECTION dir, IPin* pPin)
HRESULT CDirectVobSubFilter2::JoinFilterGraph(IFilterGraph* pGraph, LPCWSTR pName)
{
- if(pGraph)
- {
- BeginEnumFilters(pGraph, pEF, pBF)
- {
- if(pBF != (IBaseFilter*)this && CComQIPtr<IDirectVobSub>(pBF))
+ if(pGraph) {
+ BeginEnumFilters(pGraph, pEF, pBF) {
+ if(pBF != (IBaseFilter*)this && CComQIPtr<IDirectVobSub>(pBF)) {
return E_FAIL;
+ }
}
EndEnumFilters
@@ -1158,31 +1179,32 @@ HRESULT CDirectVobSubFilter2::JoinFilterGraph(IFilterGraph* pGraph, LPCWSTR pNam
// 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))
+ 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)
+ if(!pInPin) {
continue;
+ }
CComPtr<IPin> pPin;
if(pInPin && SUCCEEDED(pInPin->ConnectedTo(&pPin))
- || pOutPin && SUCCEEDED(pOutPin->ConnectedTo(&pPin)))
+ || pOutPin && SUCCEEDED(pOutPin->ConnectedTo(&pPin))) {
continue;
+ }
- if(pOutPin && GetFilterName(pBF) == _T("Overlay Mixer"))
+ if(pOutPin && GetFilterName(pBF) == _T("Overlay Mixer")) {
continue;
+ }
bool fVideoInputPin = false;
- do
- {
+ do {
BITMAPINFOHEADER bih = {sizeof(BITMAPINFOHEADER), 384, 288, 1, 16, '2YUY', 384*288*2, 0, 0, 0, 0};
CMediaType cmt;
@@ -1198,8 +1220,7 @@ HRESULT CDirectVobSubFilter2::JoinFilterGraph(IFilterGraph* pGraph, LPCWSTR pNam
memcpy(&vih->bmiHeader, &bih, sizeof(bih));
vih->AvgTimePerFrame = 400000;
- if(SUCCEEDED(pInPin->QueryAccept(&cmt)))
- {
+ if(SUCCEEDED(pInPin->QueryAccept(&cmt))) {
fVideoInputPin = true;
break;
}
@@ -1211,19 +1232,15 @@ HRESULT CDirectVobSubFilter2::JoinFilterGraph(IFilterGraph* pGraph, LPCWSTR pNam
vih2->dwPictAspectRatioX = 384;
vih2->dwPictAspectRatioY = 288;
- if(SUCCEEDED(pInPin->QueryAccept(&cmt)))
- {
+ if(SUCCEEDED(pInPin->QueryAccept(&cmt))) {
fVideoInputPin = true;
break;
}
- }
- while(false);
+ } while(false);
- if(fVideoInputPin)
- {
+ if(fVideoInputPin) {
CComPtr<IBaseFilter> pDVS;
- if(ShouldWeAutoload(pGraph) && SUCCEEDED(pDVS.CoCreateInstance(__uuidof(CDirectVobSubFilter2))))
- {
+ if(ShouldWeAutoload(pGraph) && SUCCEEDED(pDVS.CoCreateInstance(__uuidof(CDirectVobSubFilter2)))) {
CComQIPtr<IDirectVobSub2>(pDVS)->put_Forced(true);
CComQIPtr<IGraphConfig>(pGraph)->AddFilterToCache(pDVS);
}
@@ -1233,9 +1250,7 @@ HRESULT CDirectVobSubFilter2::JoinFilterGraph(IFilterGraph* pGraph, LPCWSTR pNam
}
EndEnumFilters
}
- }
- else
- {
+ } else {
}
return __super::JoinFilterGraph(pGraph, pName);
@@ -1245,9 +1260,13 @@ HRESULT CDirectVobSubFilter2::CheckInputType(const CMediaType* 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();
@@ -1256,8 +1275,7 @@ HRESULT CDirectVobSubFilter2::CheckInputType(const CMediaType* mtIn)
bool CDirectVobSubFilter2::ShouldWeAutoload(IFilterGraph* pGraph)
{
- TCHAR blacklistedapps[][32] =
- {
+ 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
@@ -1266,54 +1284,54 @@ bool CDirectVobSubFilter2::ShouldWeAutoload(IFilterGraph* pGraph)
_T("GoogleDesktopCrawl."), // Google Desktop
};
- for(ptrdiff_t i = 0; i < countof(blacklistedapps); i++)
- {
- if(theApp.m_AppName.Find(blacklistedapps[i]) >= 0)
+ 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);
+ if(level < 0 || level >= 2) {
+ return(false);
+ }
bool fRet = false;
- if(level == 1)
+ if(level == 1) {
fRet = m_fExternalLoad = m_fWebLoad = m_fEmbeddedLoad = true;
+ }
// find text stream on known splitters
- if(!fRet && m_fEmbeddedLoad)
- {
+ 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"{9AB95E90-1F37-427e-9B3D-257FB0CB25F7}", pGraph)) // Haali's matroska splitter (?)
- || (pBF = FindFilter(L"{55DA30FC-F16B-49fc-BAA5-AE59FC65F82D}", pGraph)) // Haali's 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)
- {
+ || (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"{9AB95E90-1F37-427e-9B3D-257FB0CB25F7}", pGraph)) // Haali's matroska splitter (?)
+ || (pBF = FindFilter(L"{55DA30FC-F16B-49fc-BAA5-AE59FC65F82D}", pGraph)) // Haali's 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;
+ if(fRet) {
+ break;
+ }
}
EndEnumFilters
}
@@ -1323,13 +1341,12 @@ bool CDirectVobSubFilter2::ShouldWeAutoload(IFilterGraph* pGraph)
CStringW fn;
- BeginEnumFilters(pGraph, pEF, pBF)
- {
- if(CComQIPtr<IFileSourceFilter> pFSF = pBF)
- {
+ BeginEnumFilters(pGraph, pEF, pBF) {
+ if(CComQIPtr<IFileSourceFilter> pFSF = pBF) {
LPOLESTR fnw = NULL;
- if(!pFSF || FAILED(pFSF->GetCurFile(&fnw, NULL)) || !fnw)
+ if(!pFSF || FAILED(pFSF->GetCurFile(&fnw, NULL)) || !fnw) {
continue;
+ }
fn = CString(fnw);
CoTaskMemFree(fnw);
break;
@@ -1337,13 +1354,14 @@ bool CDirectVobSubFilter2::ShouldWeAutoload(IFilterGraph* pGraph)
}
EndEnumFilters
- if((m_fExternalLoad || m_fWebLoad) && (m_fWebLoad || !(wcsstr(fn, L"http://") || wcsstr(fn, L"mms://"))))
- {
+ 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;
+ if(fTemp) {
+ m_fHideSubtitles = true;
+ }
}
return(fRet);
@@ -1351,16 +1369,13 @@ bool CDirectVobSubFilter2::ShouldWeAutoload(IFilterGraph* pGraph)
void CDirectVobSubFilter2::GetRidOfInternalScriptRenderer()
{
- while(CComPtr<IBaseFilter> pBF = FindFilter(L"{48025243-2D39-11CE-875D-00608CB78066}", m_pGraph))
- {
- BeginEnumPins(pBF, pEP, pPin)
- {
+ 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)))
- {
+ && SUCCEEDED(pPin->ConnectedTo(&pPinTo))) {
m_pGraph->Disconnect(pPinTo);
m_pGraph->Disconnect(pPin);
m_pGraph->ConnectDirect(pPinTo, GetPin(2 + m_pTextInput.GetCount()-1), NULL);
@@ -1368,8 +1383,9 @@ void CDirectVobSubFilter2::GetRidOfInternalScriptRenderer()
}
EndEnumPins
- if(FAILED(m_pGraph->RemoveFilter(pBF)))
+ if(FAILED(m_pGraph->RemoveFilter(pBF))) {
break;
+ }
}
}
@@ -1387,68 +1403,63 @@ bool CDirectVobSubFilter::Open()
CAtlArray<CString> paths;
- for(ptrdiff_t i = 0; i < 10; i++)
- {
+ 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);
+ if(!path.IsEmpty()) {
+ paths.Add(path);
+ }
}
CAtlArray<SubFile> ret;
GetSubFileNames(m_FileName, paths, ret);
- for(ptrdiff_t i = 0; i < ret.GetCount(); i++)
- {
- if(m_frd.files.Find(ret[i].fn))
+ for(ptrdiff_t i = 0; i < ret.GetCount(); i++) {
+ if(m_frd.files.Find(ret[i].fn)) {
continue;
+ }
CComPtr<ISubStream> pSubStream;
- if(!pSubStream)
- {
+ if(!pSubStream) {
CAutoPtr<CVobSubFile> pVSF(new CVobSubFile(&m_csSubLock));
- if(pVSF && pVSF->Open(ret[i].fn) && pVSF->GetStreamCount() > 0)
- {
+ 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)
- {
+ if(!pSubStream) {
CAutoPtr<ssf::CRenderer> pSSF(new ssf::CRenderer(&m_csSubLock));
- if(pSSF && pSSF->Open(ret[i].fn) && pSSF->GetStreamCount() > 0)
- {
+ if(pSSF && pSSF->Open(ret[i].fn) && pSSF->GetStreamCount() > 0) {
pSubStream = pSSF.Detach();
}
}
- if(!pSubStream)
- {
+ if(!pSubStream) {
CAutoPtr<CRenderedTextSubtitle> pRTS(new CRenderedTextSubtitle(&m_csSubLock));
- if(pRTS && pRTS->Open(ret[i].fn, DEFAULT_CHARSET) && pRTS->GetStreamCount() > 0)
- {
+ 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)
- {
+ if(pSubStream) {
m_pSubStreams.AddTail(pSubStream);
m_frd.files.AddTail(ret[i].fn);
}
}
- for(ptrdiff_t i = 0; i < m_pTextInput.GetCount(); i++)
- {
- if(m_pTextInput[i]->IsConnected())
+ for(ptrdiff_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
+ 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();
@@ -1459,22 +1470,21 @@ void CDirectVobSubFilter::UpdateSubtitle(bool fApplyDefStyle)
{
CAutoLock cAutolock(&m_csQueueLock);
- if(!m_pSubPicQueue) return;
+ if(!m_pSubPicQueue) {
+ return;
+ }
InvalidateSubtitle();
CComPtr<ISubStream> pSubStream;
- if(!m_fHideSubtitles)
- {
+ if(!m_fHideSubtitles) {
int i = m_iSelectedLanguage;
- for(POSITION pos = m_pSubStreams.GetHeadPosition(); i >= 0 && pos; pSubStream = NULL)
- {
+ for(POSITION pos = m_pSubStreams.GetHeadPosition(); i >= 0 && pos; pSubStream = NULL) {
pSubStream = m_pSubStreams.GetNext(pos);
- if(i < pSubStream->GetStreamCount())
- {
+ if(i < pSubStream->GetStreamCount()) {
CAutoLock cAutoLock(&m_csSubLock);
pSubStream->SetStream(i);
break;
@@ -1491,43 +1501,33 @@ void CDirectVobSubFilter::SetSubtitle(ISubStream* pSubStream, bool fApplyDefStyl
{
CAutoLock cAutolock(&m_csQueueLock);
- if(pSubStream)
- {
+ if(pSubStream) {
CAutoLock cAutolock(&m_csSubLock);
CLSID clsid;
pSubStream->GetClassID(&clsid);
- if(clsid == __uuidof(CVobSubFile))
- {
+ if(clsid == __uuidof(CVobSubFile)) {
CVobSubSettings* pVSS = (CVobSubFile*)(ISubStream*)pSubStream;
- if(fApplyDefStyle)
- {
+ if(fApplyDefStyle) {
pVSS->SetAlignment(m_fOverridePlacement, m_PlacementXperc, m_PlacementYperc, 1, 1);
pVSS->m_fOnlyShowForcedSubs = m_fOnlyShowForcedVobSubs;
}
- }
- else if(clsid == __uuidof(CVobSubStream))
- {
+ } else if(clsid == __uuidof(CVobSubStream)) {
CVobSubSettings* pVSS = (CVobSubStream*)(ISubStream*)pSubStream;
- if(fApplyDefStyle)
- {
+ if(fApplyDefStyle) {
pVSS->SetAlignment(m_fOverridePlacement, m_PlacementXperc, m_PlacementYperc, 1, 1);
pVSS->m_fOnlyShowForcedSubs = m_fOnlyShowForcedVobSubs;
}
- }
- else if(clsid == __uuidof(CRenderedTextSubtitle))
- {
+ } else if(clsid == __uuidof(CRenderedTextSubtitle)) {
CRenderedTextSubtitle* pRTS = (CRenderedTextSubtitle*)(ISubStream*)pSubStream;
- if(fApplyDefStyle || pRTS->m_fUsingAutoGeneratedDefaultStyle)
- {
+ if(fApplyDefStyle || pRTS->m_fUsingAutoGeneratedDefaultStyle) {
STSStyle s = m_defStyle;
- if(m_fOverridePlacement)
- {
+ if(m_fOverridePlacement) {
s.scrAlignment = 2;
int w = pRTS->m_dstScreenSize.cx;
int h = pRTS->m_dstScreenSize.cy;
@@ -1541,14 +1541,11 @@ void CDirectVobSubFilter::SetSubtitle(ISubStream* pSubStream, bool fApplyDefStyl
}
pRTS->m_ePARCompensationType = m_ePARCompensationType;
- if (m_CurrentVIH2.dwPictAspectRatioX != 0 && m_CurrentVIH2.dwPictAspectRatioY != 0&& m_CurrentVIH2.bmiHeader.biWidth != 0 && m_CurrentVIH2.bmiHeader.biHeight != 0)
- {
+ 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
- {
+ } else {
pRTS->m_dPARCompensation = 1.00;
}
@@ -1556,17 +1553,14 @@ void CDirectVobSubFilter::SetSubtitle(ISubStream* pSubStream, bool fApplyDefStyl
}
}
- if(!fApplyDefStyle)
- {
+ if(!fApplyDefStyle) {
int i = 0;
POSITION pos = m_pSubStreams.GetHeadPosition();
- while(pos)
- {
+ while(pos) {
CComPtr<ISubStream> pSubStream2 = m_pSubStreams.GetNext(pos);
- if(pSubStream == pSubStream2)
- {
+ if(pSubStream == pSubStream2) {
m_iSelectedLanguage = i + pSubStream2->GetStream();
break;
}
@@ -1577,18 +1571,19 @@ void CDirectVobSubFilter::SetSubtitle(ISubStream* pSubStream, bool fApplyDefStyl
m_nSubtitleId = (DWORD_PTR)pSubStream;
- if(m_pSubPicQueue)
+ if(m_pSubPicQueue) {
m_pSubPicQueue->SetSubPicProvider(CComQIPtr<ISubPicProvider>(pSubStream));
+ }
}
void CDirectVobSubFilter::InvalidateSubtitle(REFERENCE_TIME rtInvalidate, DWORD_PTR nSubtitleId)
{
CAutoLock cAutolock(&m_csQueueLock);
- if(m_pSubPicQueue)
- {
- if(nSubtitleId == -1 || nSubtitleId == m_nSubtitleId)
+ if(m_pSubPicQueue) {
+ if(nSubtitleId == -1 || nSubtitleId == m_nSubtitleId) {
m_pSubPicQueue->Invalidate(rtInvalidate);
+ }
}
}
@@ -1599,14 +1594,17 @@ void CDirectVobSubFilter::AddSubStream(ISubStream* pSubStream)
CAutoLock cAutoLock(&m_csQueueLock);
POSITION pos = m_pSubStreams.Find(pSubStream);
- if(!pos) m_pSubStreams.AddTail(pSubStream);
+ if(!pos) {
+ m_pSubStreams.AddTail(pSubStream);
+ }
int len = m_pTextInput.GetCount();
for(ptrdiff_t i = 0; i < m_pTextInput.GetCount(); i++)
- if(m_pTextInput[i]->IsConnected()) len--;
+ if(m_pTextInput[i]->IsConnected()) {
+ len--;
+ }
- if(len == 0)
- {
+ if(len == 0) {
HRESULT hr = S_OK;
m_pTextInput.Add(new CTextInputPin(this, m_pLock, &m_csSubLock, &hr));
}
@@ -1617,21 +1615,28 @@ void CDirectVobSubFilter::RemoveSubStream(ISubStream* pSubStream)
CAutoLock cAutoLock(&m_csQueueLock);
POSITION pos = m_pSubStreams.Find(pSubStream);
- if(pos) m_pSubStreams.RemoveAt(pos);
+ if(pos) {
+ m_pSubStreams.RemoveAt(pos);
+ }
}
void CDirectVobSubFilter::Post_EC_OLE_EVENT(CString str, DWORD_PTR nSubtitleId)
{
- if(nSubtitleId != -1 && nSubtitleId != m_nSubtitleId)
+ if(nSubtitleId != -1 && nSubtitleId != m_nSubtitleId) {
return;
+ }
CComQIPtr<IMediaEventSink> pMES = m_pGraph;
- if(!pMES) return;
+ if(!pMES) {
+ return;
+ }
CComBSTR bstr1("Text"), bstr2(" ");
str.Trim();
- if(!str.IsEmpty()) bstr2 = CStringA(str);
+ if(!str.IsEmpty()) {
+ bstr2 = CStringA(str);
+ }
pMES->Notify(EC_OLE_EVENT, (LONG_PTR)bstr1.Detach(), (LONG_PTR)bstr2.Detach());
}
@@ -1642,8 +1647,7 @@ void CDirectVobSubFilter::SetupFRD(CStringArray& paths, CAtlArray<HANDLE>& handl
{
CAutoLock cAutolock(&m_csSubLock);
- for(ptrdiff_t i = 2; i < handles.GetCount(); i++)
- {
+ for(ptrdiff_t i = 2; i < handles.GetCount(); i++) {
FindCloseChangeNotification(handles[i]);
}
@@ -1656,30 +1660,32 @@ void CDirectVobSubFilter::SetupFRD(CStringArray& paths, CAtlArray<HANDLE>& handl
m_frd.mtime.SetCount(m_frd.files.GetCount());
POSITION pos = m_frd.files.GetHeadPosition();
- for(ptrdiff_t i = 0; pos; i++)
- {
+ for(ptrdiff_t i = 0; pos; i++) {
CString fn = m_frd.files.GetNext(pos);
CFileStatus status;
- if(CFileGetStatus(fn, status))
+ if(CFileGetStatus(fn, status)) {
m_frd.mtime[i] = status.m_mtime;
+ }
fn.Replace('\\', '/');
fn = fn.Left(fn.ReverseFind('/')+1);
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)
- {
+ if(!fFound) {
paths.Add(fn);
HANDLE h = FindFirstChangeNotification(fn, FALSE, FILE_NOTIFY_CHANGE_LAST_WRITE);
- if(h != INVALID_HANDLE_VALUE) handles.Add(h);
+ if(h != INVALID_HANDLE_VALUE) {
+ handles.Add(h);
+ }
}
}
}
@@ -1693,47 +1699,39 @@ DWORD CDirectVobSubFilter::ThreadProc()
SetupFRD(paths, handles);
- while(1)
- {
+ while(1) {
DWORD idx = WaitForMultipleObjects(handles.GetCount(), handles.GetData(), FALSE, INFINITE);
- if(idx == (WAIT_OBJECT_0 + 0)) // m_frd.hEndThreadEvent
- {
+ if(idx == (WAIT_OBJECT_0 + 0)) { // m_frd.hEndThreadEvent
break;
}
- if(idx == (WAIT_OBJECT_0 + 1)) // m_frd.hRefreshEvent
- {
+ 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()))
- {
+ } else if(idx >= (WAIT_OBJECT_0 + 2) && idx < (WAIT_OBJECT_0 + handles.GetCount())) {
bool fLocked = true;
IsSubtitleReloaderLocked(&fLocked);
- if(fLocked) continue;
+ if(fLocked) {
+ continue;
+ }
- if(FindNextChangeNotification(handles[idx - WAIT_OBJECT_0]) == FALSE)
+ 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++)
- {
+ 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++)
- {
- if(FILE* f = _tfopen(fn, _T("rb+")))
- {
+ if(CFileGetStatus(fn, status) && m_frd.mtime[i] != status.m_mtime) {
+ for(j = 0; j < 10; j++) {
+ if(FILE* f = _tfopen(fn, _T("rb+"))) {
fclose(f);
j = 0;
break;
- }
- else
- {
+ } else {
Sleep(100);
j++;
}
@@ -1741,36 +1739,28 @@ DWORD CDirectVobSubFilter::ThreadProc()
}
}
- if(j > 0)
- {
+ if(j > 0) {
SetupFRD(paths, handles);
- }
- else
- {
+ } else {
Sleep(500);
POSITION pos = m_frd.files.GetHeadPosition();
- for(ptrdiff_t i = 0; pos; i++)
- {
+ for(ptrdiff_t i = 0; pos; i++) {
CFileStatus status;
if(CFileGetStatus(m_frd.files.GetNext(pos), status)
- && m_frd.mtime[i] != status.m_mtime)
- {
+ && m_frd.mtime[i] != status.m_mtime) {
Open();
SetupFRD(paths, handles);
break;
}
}
}
- }
- else
- {
+ } else {
break;
}
}
- for(ptrdiff_t i = 2; i < handles.GetCount(); i++)
- {
+ for(ptrdiff_t i = 2; i < handles.GetCount(); i++) {
FindCloseChangeNotification(handles[i]);
}
diff --git a/src/filters/transform/VSFilter/DirectVobSubFilter.h b/src/filters/transform/VSFilter/DirectVobSubFilter.h
index 6552d5f17..82932bd2c 100644
--- a/src/filters/transform/VSFilter/DirectVobSubFilter.h
+++ b/src/filters/transform/VSFilter/DirectVobSubFilter.h
@@ -30,8 +30,7 @@
#include "../../../Subtitles/RTS.h"
#include "../../../Subtitles/SSF.h"
-typedef struct
-{
+typedef struct {
HWND hSystrayWnd;
IFilterGraph* graph;
IDirectVobSub* dvs;
diff --git a/src/filters/transform/VSFilter/DirectVobSubPropPage.cpp b/src/filters/transform/VSFilter/DirectVobSubPropPage.cpp
index 4b4713a64..79196273c 100644
--- a/src/filters/transform/VSFilter/DirectVobSubPropPage.cpp
+++ b/src/filters/transform/VSFilter/DirectVobSubPropPage.cpp
@@ -48,7 +48,9 @@ BOOL WINAPI MyGetDialogSize(int iResourceID, DLGPROC pDlgProc, LPARAM lParam, SI
pDlgProc,
lParam);
- if(hwnd == NULL) return FALSE;
+ if(hwnd == NULL) {
+ return FALSE;
+ }
RECT rc;
GetWindowRect(hwnd, &rc);
@@ -65,7 +67,9 @@ STDMETHODIMP CDVSBasePPage::GetPageInfo(LPPROPPAGEINFO pPageInfo)
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CString str;
- if(!str.LoadString(m_TitleId)) return E_FAIL;
+ if(!str.LoadString(m_TitleId)) {
+ return E_FAIL;
+ }
WCHAR wszTitle[STR_MAX_LENGTH];
#ifdef UNICODE
@@ -104,16 +108,20 @@ 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 failure if SetObject has not been called.
+ if (m_bObjectSet == FALSE) {
+ return E_UNEXPECTED;
+ }
+ */
+ if(m_hwnd) {
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;
+ if(m_hwnd == NULL) {
+ return E_OUTOFMEMORY;
+ }
OnActivate();
Move(pRect);
@@ -132,36 +140,34 @@ CDVSBasePPage::CDVSBasePPage(TCHAR* pName, LPUNKNOWN lpunk, int DialogId, int Ti
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)
- && !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_INSTANTUPDATE), 1))
- OnApplyChanges();
- }
+ 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)
+ && !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_INSTANTUPDATE), 1)) {
+ OnApplyChanges();
+ }
+ }
+ }
}
}
- }
- break;
-
- case WM_NCDESTROY:
- DetachControls();
break;
+
+ case WM_NCDESTROY:
+ DetachControls();
+ break;
}
return OnMessage(uMsg, wParam, lParam)
@@ -171,7 +177,9 @@ INT_PTR CDVSBasePPage::OnReceiveMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPA
HRESULT CDVSBasePPage::OnConnect(IUnknown* pUnknown)
{
- if(!(m_pDirectVobSub = pUnknown)) return E_NOINTERFACE;
+ if(!(m_pDirectVobSub = pUnknown)) {
+ return E_NOINTERFACE;
+ }
m_pDirectVobSub->LockSubtitleReloader(true); // *
@@ -186,7 +194,9 @@ HRESULT CDVSBasePPage::OnConnect(IUnknown* pUnknown)
HRESULT CDVSBasePPage::OnDisconnect()
{
- if(m_pDirectVobSub == NULL) return E_UNEXPECTED;
+ if(m_pDirectVobSub == NULL) {
+ return E_UNEXPECTED;
+ }
m_pDirectVobSub->LockSubtitleReloader(false); // *
@@ -233,8 +243,7 @@ HRESULT CDVSBasePPage::OnApplyChanges()
AFX_MANAGE_STATE(AfxGetStaticModuleState());
- if(m_bIsInitialized)
- {
+ if(m_bIsInitialized) {
OnDeactivate();
UpdateObjectData(true);
m_pDirectVobSub->UpdateRegistry(); // *
@@ -251,13 +260,11 @@ void CDVSBasePPage::AttachControls()
AFX_MANAGE_STATE(AfxGetStaticModuleState());
POSITION pos = m_controls.GetStartPosition();
- while(pos)
- {
+ while(pos) {
UINT id;
CWnd* pControl;
m_controls.GetNextAssoc(pos, id, pControl);
- if(pControl)
- {
+ if(pControl) {
BOOL fRet = pControl->Attach(GetDlgItem(m_Dlg, id));
ASSERT(fRet);
}
@@ -268,17 +275,20 @@ void CDVSBasePPage::AttachControls()
void CDVSBasePPage::DetachControls()
{
- if(!m_fAttached) return;
+ if(!m_fAttached) {
+ return;
+ }
AFX_MANAGE_STATE(AfxGetStaticModuleState());
POSITION pos = m_controls.GetStartPosition();
- while(pos)
- {
+ while(pos) {
UINT id;
CWnd* pControl;
m_controls.GetNextAssoc(pos, id, pControl);
- if(pControl) pControl->Detach();
+ if(pControl) {
+ pControl->Detach();
+ }
}
m_fAttached = false;
@@ -313,9 +323,10 @@ CDVSMainPPage::~CDVSMainPPage()
void CDVSMainPPage::FreeLangs()
{
- if(m_nLangs > 0 && m_ppLangs)
- {
- for(ptrdiff_t i = 0; i < m_nLangs; i++) CoTaskMemFree(m_ppLangs[i]);
+ 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;
@@ -330,52 +341,45 @@ void CDVSMainPPage::AllocLangs(int 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 .ssf|*.idx;*.smi;*.sub;*.srt;*.psb;*.ssa;*.ass;*.usf;*.ssf|")
- _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);
+ 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 .ssf|*.idx;*.smi;*.sub;*.srt;*.psb;*.ssa;*.ass;*.usf;*.ssf|")
+ _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);
+ }
}
-
- return(true);
+ break;
}
}
break;
- }
- }
- break;
}
return(false);
@@ -383,14 +387,14 @@ bool CDVSMainPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
void CDVSMainPPage::UpdateObjectData(bool fSave)
{
- if(fSave)
- {
- if(m_pDirectVobSub->put_FileName(m_fn) == S_OK)
- {
+ 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]);
+ for(ptrdiff_t i = 0; i < m_nLangs; i++) {
+ m_pDirectVobSub->get_LanguageName(i, &m_ppLangs[i]);
+ }
m_pDirectVobSub->get_SelectedLanguage(&m_iSelectedLanguage);
}
@@ -399,14 +403,14 @@ void CDVSMainPPage::UpdateObjectData(bool fSave)
m_pDirectVobSub->put_VobSubSettings(true, m_fOnlyShowForcedVobSubs, false);
m_pDirectVobSub->put_TextSettings(&m_defStyle);
m_pDirectVobSub->put_AspectRatioSettings(&m_ePARCompensationType);
- }
- else
- {
+ } 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]);
+ 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);
@@ -417,8 +421,7 @@ void CDVSMainPPage::UpdateObjectData(bool fSave)
void CDVSMainPPage::UpdateControlData(bool fSave)
{
- if(fSave)
- {
+ if(fSave) {
CString fn;
m_fnedit.GetWindowText(fn);
#ifdef UNICODE
@@ -431,13 +434,12 @@ void CDVSMainPPage::UpdateControlData(bool fSave)
m_PlacementXperc = m_subposx.GetPos();
m_PlacementYperc = m_subposy.GetPos();
m_fOnlyShowForcedVobSubs = !!m_forcedsubs.GetCheck();
- if (m_PARCombo.GetCurSel() != CB_ERR)
+ if (m_PARCombo.GetCurSel() != CB_ERR) {
m_ePARCompensationType = static_cast<CSimpleTextSubtitle::EPARCompensationType>(m_PARCombo.GetItemData(m_PARCombo.GetCurSel()));
- else
+ } else {
m_ePARCompensationType = CSimpleTextSubtitle::EPCTDisabled;
- }
- else
- {
+ }
+ } else {
m_fnedit.SetWindowText(CString(m_fn));
m_oplacement.SetCheck(m_fOverridePlacement);
m_subposx.SetRange(-20, 120);
@@ -450,29 +452,35 @@ void CDVSMainPPage::UpdateControlData(bool fSave)
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]));
+ 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)
+ 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)
+ 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)
+ 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)
+ if (m_ePARCompensationType == CSimpleTextSubtitle::EPCTAccurateSize) {
m_PARCombo.SetCurSel(3);
+ }
}
}
@@ -494,34 +502,27 @@ CDVSGeneralPPage::CDVSGeneralPPage(LPUNKNOWN pUnk, HRESULT* phr) :
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);
+ 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;
- }
- }
- break;
}
return(false);
@@ -529,13 +530,10 @@ bool CDVSGeneralPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
void CDVSGeneralPPage::UpdateObjectData(bool fSave)
{
- if(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
- {
+ } 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);
}
@@ -543,20 +541,23 @@ void CDVSGeneralPPage::UpdateObjectData(bool fSave)
void CDVSGeneralPPage::UpdateControlData(bool fSave)
{
- if(fSave)
- {
- if(m_verext.GetCurSel() >= 0) m_VerExt = m_verext.GetItemData(m_verext.GetCurSel());
+ 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());
+ 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());
+ 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
- {
+ } else {
m_verext.ResetContent();
m_verext.AddString(ResStr(IDS_ORGHEIGHT));
m_verext.SetItemData(0, 0);
@@ -622,25 +623,20 @@ CDVSMiscPPage::CDVSMiscPPage(LPUNKNOWN pUnk, HRESULT* phr) :
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);
+ 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;
- }
- }
- break;
}
return(false);
@@ -648,17 +644,14 @@ bool CDVSMiscPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
void CDVSMiscPPage::UpdateObjectData(bool fSave)
{
- if(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_PreBuffering(m_fDoPreBuffering);
m_pDirectVobSub->put_SubtitleReloader(m_fReloaderDisabled);
m_pDirectVobSub->put_SaveFullPath(m_fSaveFullPath);
- }
- else
- {
+ } else {
m_pDirectVobSub->get_Flip(&m_fFlipPicture, &m_fFlipSubtitles);
m_pDirectVobSub->get_HideSubtitles(&m_fHideSubtitles);
m_pDirectVobSub->get_OSD(&m_fOSD);
@@ -670,8 +663,7 @@ void CDVSMiscPPage::UpdateObjectData(bool fSave)
void CDVSMiscPPage::UpdateControlData(bool fSave)
{
- if(fSave)
- {
+ if(fSave) {
m_fFlipPicture = !!m_flippic.GetCheck();
m_fFlipSubtitles = !!m_flipsub.GetCheck();
m_fHideSubtitles = !!m_hidesub.GetCheck();
@@ -679,9 +671,7 @@ void CDVSMiscPPage::UpdateControlData(bool fSave)
m_fDoPreBuffering = !!m_prebuff.GetCheck();
m_fOSD = !!m_showosd.GetCheck();
m_fReloaderDisabled = !m_autoreload.GetCheck();
- }
- else
- {
+ } else {
m_flippic.SetCheck(m_fFlipPicture);
m_flipsub.SetCheck(m_fFlipSubtitles);
m_hidesub.SetCheck(m_fHideSubtitles);
@@ -707,25 +697,20 @@ CDVSTimingPPage::CDVSTimingPPage(LPUNKNOWN pUnk, HRESULT* phr) :
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);
+ 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;
- }
- }
- break;
}
return(false);
@@ -733,13 +718,10 @@ bool CDVSTimingPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
void CDVSTimingPPage::UpdateObjectData(bool fSave)
{
- if(fSave)
- {
+ if(fSave) {
m_pDirectVobSub->put_SubtitleTiming(m_SubtitleDelay, m_SubtitleSpeedMul, m_SubtitleSpeedDiv);
m_pDirectVobSub->put_MediaFPS(m_fMediaFPSEnabled, m_MediaFPS);
- }
- else
- {
+ } else {
m_pDirectVobSub->get_SubtitleTiming(&m_SubtitleDelay, &m_SubtitleSpeedMul, &m_SubtitleSpeedDiv);
m_pDirectVobSub->get_MediaFPS(&m_fMediaFPSEnabled, &m_MediaFPS);
}
@@ -747,13 +729,14 @@ void CDVSTimingPPage::UpdateObjectData(bool fSave)
void CDVSTimingPPage::UpdateControlData(bool fSave)
{
- if(fSave)
- {
+ if(fSave) {
m_fMediaFPSEnabled = !!m_modfps.GetCheck();
CString fpsstr;
m_fps.GetWindowText(fpsstr);
float fps;
- if(_stscanf(fpsstr, _T("%f"), &fps) == 1) m_MediaFPS = fps;
+ if(_stscanf(fpsstr, _T("%f"), &fps) == 1) {
+ m_MediaFPS = fps;
+ }
#if _MFC_VER >= 0x0700
m_SubtitleDelay = m_subdelay.GetPos32();
m_SubtitleSpeedMul = m_subspeedmul.GetPos32();
@@ -763,9 +746,7 @@ void CDVSTimingPPage::UpdateControlData(bool fSave)
m_SubtitleSpeedMul = SendMessage(GetDlgItem(m_Dlg, IDC_SPIN6), UDM_GETPOS32, 0, 0);
m_SubtitleSpeedDiv = SendMessage(GetDlgItem(m_Dlg, IDC_SPIN9), UDM_GETPOS32, 0, 0);
#endif
- }
- else
- {
+ } else {
m_modfps.SetCheck(m_fMediaFPSEnabled);
CString fpsstr;
fpsstr.Format(_T("%.4f"), m_MediaFPS);
@@ -796,40 +777,32 @@ CDVSAboutPPage::CDVSAboutPPage(LPUNKNOWN lpunk, HRESULT* phr) :
bool CDVSAboutPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- switch(uMsg)
- {
- case WM_INITDIALOG:
- {
+ switch(uMsg) {
+ case WM_INITDIALOG: {
#ifdef _VSMOD
- SetDlgItemTextA( m_Dlg, IDC_VERSION, "DirectVobSub 2.40."MAKE_STR(MPC_VERSION_REV)"."MAKE_STR(MPC_VERSION_PATCH)" "MAKE_STR(VERSION_ARCH)", MOD\nCopyright 2001-2010 MPC-HC & VSFilterMod Teams" );
+ SetDlgItemTextA( m_Dlg, IDC_VERSION, "DirectVobSub 2.40."MAKE_STR(MPC_VERSION_REV)"."MAKE_STR(MPC_VERSION_PATCH)" "MAKE_STR(VERSION_ARCH)", MOD\nCopyright 2001-2010 MPC-HC & VSFilterMod Teams" );
#else
- SetDlgItemTextA( m_Dlg, IDC_VERSION, "DirectVobSub 2.40."MAKE_STR(MPC_VERSION_REV)"."MAKE_STR(MPC_VERSION_PATCH)" "MAKE_STR(VERSION_ARCH)"\nCopyright 2001-2010 MPC-HC Team" );
+ SetDlgItemTextA( m_Dlg, IDC_VERSION, "DirectVobSub 2.40."MAKE_STR(MPC_VERSION_REV)"."MAKE_STR(MPC_VERSION_PATCH)" "MAKE_STR(VERSION_ARCH)"\nCopyright 2001-2010 MPC-HC Team" );
#endif
- }
- 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;
+ 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;
+ break;
}
return(false);
@@ -848,28 +821,23 @@ CDVSZoomPPage::CDVSZoomPPage(LPUNKNOWN pUnk, HRESULT* phr) :
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);
+ 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;
- }
- }
- break;
}
return(false);
@@ -877,15 +845,12 @@ bool CDVSZoomPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
void CDVSZoomPPage::UpdateControlData(bool fSave)
{
- if(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
- {
+ } else {
m_posx.SetRange(-100, 100);
m_posx.SetPos((int)(m_rect.left*100));
m_posy.SetRange(-100, 100);
@@ -899,12 +864,9 @@ void CDVSZoomPPage::UpdateControlData(bool fSave)
void CDVSZoomPPage::UpdateObjectData(bool fSave)
{
- if(fSave)
- {
+ if(fSave) {
m_pDirectVobSub->put_ZoomRect(&m_rect);
- }
- else
- {
+ } else {
m_pDirectVobSub->get_ZoomRect(&m_rect);
}
}
@@ -925,77 +887,68 @@ CDVSColorPPage::CDVSColorPPage(LPUNKNOWN pUnk, HRESULT* phr) :
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);
+ 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);
+ }
+ }
}
-
- return(true);
- }
+ break;
}
}
break;
- }
- }
- break;
}
return(false);
@@ -1003,35 +956,30 @@ bool CDVSColorPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
void CDVSColorPPage::UpdateObjectData(bool fSave)
{
- if(fSave)
- {
- }
- else
- {
+ if(fSave) {
+ } else {
}
}
void CDVSColorPPage::UpdateControlData(bool fSave)
{
- if(fSave)
- {
- if((UINT)m_preflist.GetCount() == VIHSIZE)
- {
+ if(fSave) {
+ if((UINT)m_preflist.GetCount() == VIHSIZE) {
BYTE* pData = new BYTE[VIHSIZE];
- for(ptrdiff_t i = 0; i < m_preflist.GetCount(); i++)
+ 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);
}
- else ASSERT(0);
theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_FORCERGB), !!m_forcergb.GetCheck());
- }
- else
- {
+ } else {
m_preflist.ResetContent();
m_dynchglist.ResetContent();
@@ -1039,19 +987,20 @@ void CDVSColorPPage::UpdateControlData(bool fSave)
UINT nSize;
if(!theApp.GetProfileBinary(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_COLORFORMATS), &pData, &nSize)
- || !pData || nSize != VIHSIZE)
- {
- if(pData) delete [] pData, pData = NULL;
+ || !pData || nSize != VIHSIZE) {
+ if(pData) {
+ delete [] pData, pData = NULL;
+ }
nSize = VIHSIZE;
pData = new BYTE[VIHSIZE];
- for(ptrdiff_t i = 0; i < VIHSIZE; i++) pData[i] = i;
+ for(ptrdiff_t i = 0; i < VIHSIZE; i++) {
+ pData[i] = i;
+ }
}
- if(pData)
- {
- for(ptrdiff_t i = 0; i < (int)nSize; 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]));
@@ -1085,98 +1034,85 @@ CDVSPathsPPage::CDVSPathsPPage(LPUNKNOWN pUnk, HRESULT* phr) :
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);
+ 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);
}
- }
-
- return(true);
- }
- break;
+ 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;
+ 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;
- }
- }
- break;
}
return(false);
@@ -1184,55 +1120,48 @@ bool CDVSPathsPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
void CDVSPathsPPage::UpdateObjectData(bool fSave)
{
- if(fSave)
- {
+ if(fSave) {
CString chk(_T("123456789")), path, tmp;
int i = 0;
- do
- {
+ do {
tmp.Format(ResStr(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);
+ if(path != chk) {
+ theApp.WriteProfileString(ResStr(IDS_R_DEFTEXTPATHES), tmp, _T(""));
+ }
+ } while(path != chk);
- for(i = 0; i < m_paths.GetSize(); i++)
- {
+ for(i = 0; i < m_paths.GetSize(); i++) {
tmp.Format(ResStr(IDS_RP_PATH), i);
theApp.WriteProfileString(ResStr(IDS_R_DEFTEXTPATHES), tmp, m_paths[i]);
}
- }
- else
- {
+ } else {
CString chk(_T("123456789")), path, tmp;
int i = 0;
- do
- {
- if(!path.IsEmpty()) m_paths.Add(path);
+ do {
+ if(!path.IsEmpty()) {
+ m_paths.Add(path);
+ }
tmp.Format(ResStr(IDS_RP_PATH), i++);
path = theApp.GetProfileString(ResStr(IDS_R_DEFTEXTPATHES), tmp, chk);
- }
- while(path != chk);
+ } while(path != chk);
}
}
void CDVSPathsPPage::UpdateControlData(bool fSave)
{
- if(fSave)
- {
+ if(fSave) {
m_paths.RemoveAll();
- for(ptrdiff_t i = 0; i < m_pathlist.GetCount(); i++)
- {
+ for(ptrdiff_t i = 0; i < m_pathlist.GetCount(); i++) {
CString path;
m_pathlist.GetText(i, path);
m_paths.Add(path);
}
- }
- else
- {
+ } else {
m_pathlist.ResetContent();
- for(ptrdiff_t i = 0; i < m_paths.GetSize(); i++)
+ 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/IDirectVobSub.h b/src/filters/transform/VSFilter/IDirectVobSub.h
index b917f87c3..37fefc6d1 100644
--- a/src/filters/transform/VSFilter/IDirectVobSub.h
+++ b/src/filters/transform/VSFilter/IDirectVobSub.h
@@ -253,24 +253,21 @@ IDirectVobSub :
interface __declspec(uuid("FE6EC6A0-21CA-4970-9EF0-B296F7F38AF0"))
ISubClock :
- public IUnknown
- {
+ public IUnknown {
STDMETHOD(SetTime)(REFERENCE_TIME rt) PURE;
STDMETHOD_(REFERENCE_TIME, GetTime)() PURE;
};
interface __declspec(uuid("0665B760-FBC1-46C3-A35F-E471527C96A4"))
ISubClock2 :
- public ISubClock
- {
+ 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"))
IDirectVobSub2 :
- public IDirectVobSub
- {
+ public IDirectVobSub {
STDMETHOD(AdviseSubClock) (THIS_
ISubClock* pSubClock
) PURE;
diff --git a/src/filters/transform/VSFilter/Scale2x.cpp b/src/filters/transform/VSFilter/Scale2x.cpp
index 71cf01f24..f05773520 100644
--- a/src/filters/transform/VSFilter/Scale2x.cpp
+++ b/src/filters/transform/VSFilter/Scale2x.cpp
@@ -37,13 +37,11 @@ void Scale2x_YV( int w, int h, BYTE* d, int dpitch, BYTE* s, int spitch )
BYTE* s2;
BYTE* d1;
- for(s1 = s, s2 = s + h*spitch, d1 = d; s1 < s2; d1 += dpitch) // TODO: replace this mess with mmx code
- {
+ 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)
- {
+ for(BYTE* s3 = s1 + (w-1); s1 < s3; s1 += 1, d1 += 2) {
d1[0] = s1[0];
d1[1] = (s1[0]+s1[1])>>1;
}
@@ -70,8 +68,7 @@ void Scale2x_YUY2_SSE2( BYTE* s1, BYTE* d1, int w )
__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)
- {
+ 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
@@ -112,8 +109,7 @@ void Scale2x_YUY2_MMX( BYTE* s1, BYTE* d1, int w )
unsigned __int64 __0x00000000ffffffff = 0x00000000ffffffff;
unsigned __int64 __0x00ff00ff00ff00ff = 0x00ff00ff00ff00ff;
- __asm
- {
+ __asm {
mov esi, s1
mov edi, d1
@@ -124,7 +120,7 @@ void Scale2x_YUY2_MMX( BYTE* s1, BYTE* d1, int w )
movq mm4, __0x00ff00ff00ff00ff
movq mm5, __0x00000000ffffffff
movq mm6, __0xffffffff00000000
-row_loop1:
+ row_loop1:
movq mm0, [esi]
movq mm2, mm0
@@ -185,8 +181,7 @@ row_loop1:
void Scale2x_YUY2_c( BYTE* s1, BYTE* d1, int w )
{
- for(BYTE* s3 = s1 + ((w>>1)-1)*4; s1 < s3; s1 += 4, d1 += 8)
- {
+ 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;
@@ -229,8 +224,7 @@ void Scale2x_YUY2( int w, int h, BYTE* d, int dpitch, BYTE* s, int spitch )
BYTE* s2;
BYTE* d1;
- for(s1 = s, s2 = s + h*spitch, d1 = d; s1 < s2; d1 += dpitch)
- {
+ 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
@@ -254,13 +248,11 @@ void Scale2x_RGB555( int w, int h, BYTE* d, int dpitch, BYTE* s, int spitch )
BYTE* s2;
BYTE* d1;
- for(s1 = s, s2 = s + h*spitch, d1 = d; s1 < s2; d1 += dpitch) // TODO: replace this mess with mmx code
- {
+ 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)
- {
+ 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)|
@@ -287,13 +279,11 @@ void Scale2x_RGB565( int w, int h, BYTE* d, int dpitch, BYTE* s, int spitch )
BYTE* s2;
BYTE* d1;
- for(s1 = s, s2 = s + h*spitch, d1 = d; s1 < s2; d1 += dpitch) // TODO: replace this mess with mmx code
- {
+ 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)
- {
+ 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)|
@@ -320,13 +310,11 @@ void Scale2x_RGB24( int w, int h, BYTE* d, int dpitch, BYTE* s, int spitch )
BYTE* s2;
BYTE* d1;
- for(s1 = s, s2 = s + h*spitch, d1 = d; s1 < s2; d1 += dpitch) // TODO: replace this mess with mmx code
- {
+ 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)
- {
+ 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];
@@ -353,8 +341,7 @@ void Scale2x_RGB24( int w, int h, BYTE* d, int dpitch, BYTE* s, int spitch )
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)
- {
+ 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
@@ -379,8 +366,7 @@ void Scale2x_XRGB32_SSE2( BYTE* s1, BYTE* d1, int w )
#else
void Scale2x_XRGB32_MMX( BYTE* s1, BYTE* d1, int w )
{
- __asm
- {
+ __asm {
mov esi, s1
mov edi, d1
@@ -388,7 +374,7 @@ void Scale2x_XRGB32_MMX( BYTE* s1, BYTE* d1, int w )
dec ecx
pxor mm0, mm0
-row_loop3:
+ row_loop3:
movq mm1, [esi]
movq mm2, mm1
@@ -422,8 +408,7 @@ row_loop3:
void Scale2x_XRGB32_c( BYTE* s1, BYTE* d1, int w )
{
- for(BYTE* s3 = s1 + (w-1)*4; s1 < s3; s1 += 3, d1 += 6)
- {
+ 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];
@@ -456,8 +441,7 @@ void Scale2x_XRGB32( int w, int h, BYTE* d, int dpitch, BYTE* s, int spitch )
BYTE* s2;
BYTE* d1;
- for(s1 = s, s2 = s + h*spitch, d1 = d; s1 < s2; d1 += dpitch)
- {
+ for(s1 = s, s2 = s + h*spitch, d1 = d; s1 < s2; d1 += dpitch) {
scale_func(s1, d1, w);
s1 += spitch;
@@ -474,16 +458,17 @@ void Scale2x_XRGB32( int w, int h, BYTE* d, int dpitch, BYTE* s, int spitch )
/* 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)
+ if(subtype == MEDIASUBTYPE_YV12 || subtype == MEDIASUBTYPE_I420 || subtype == MEDIASUBTYPE_IYUV) {
Scale2x_YV(w, h, d, dpitch, s, spitch);
- else if(subtype == MEDIASUBTYPE_YUY2)
+ } else if(subtype == MEDIASUBTYPE_YUY2) {
Scale2x_YUY2(w, h, d, dpitch, s, spitch);
- else if(subtype == MEDIASUBTYPE_RGB555)
+ } else if(subtype == MEDIASUBTYPE_RGB555) {
Scale2x_RGB555(w, h, d, dpitch, s, spitch);
- else if(subtype == MEDIASUBTYPE_RGB565)
+ } else if(subtype == MEDIASUBTYPE_RGB565) {
Scale2x_RGB565(w, h, d, dpitch, s, spitch);
- else if(subtype == MEDIASUBTYPE_RGB24)
+ } else if(subtype == MEDIASUBTYPE_RGB24) {
Scale2x_RGB24(w, h, d, dpitch, s, spitch);
- else if(subtype == MEDIASUBTYPE_RGB32 || subtype == MEDIASUBTYPE_ARGB32)
+ } 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 b31fa4b9c..0cd270f06 100644
--- a/src/filters/transform/VSFilter/StyleEditorDialog.cpp
+++ b/src/filters/transform/VSFilter/StyleEditorDialog.cpp
@@ -106,11 +106,12 @@ void CStyleEditorDialog::DoDataExchange(CDataExchange* pDX)
void CStyleEditorDialog::UpdateControlData(bool fSave)
{
- if(fSave)
- {
+ if(fSave) {
UpdateData();
- if(m_iCharset >= 0) m_stss.charSet = m_charset.GetItemData(m_iCharset);
+ 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;
@@ -123,24 +124,27 @@ void CStyleEditorDialog::UpdateControlData(bool fSave)
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
- {
+ 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++)
- {
+ 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;
+ if(m_stss.charSet == CharSetList[i]) {
+ m_iCharset = i;
+ }
}
// TODO: allow floats in these edit boxes
m_spacing = m_stss.fontSpacing;
m_spacingspin.SetRange32(-10000, 10000);
- while(m_stss.fontAngleZ < 0) m_stss.fontAngleZ += 360;
+ while(m_stss.fontAngleZ < 0) {
+ m_stss.fontAngleZ += 360;
+ }
m_angle = fmod(m_stss.fontAngleZ, 360);
m_anglespin.SetRange32(0, 359);
m_scalex = m_stss.fontScaleX;
@@ -161,8 +165,7 @@ void CStyleEditorDialog::UpdateControlData(bool fSave)
m_margintopspin.SetRange32(-10000, 10000);
m_marginbottomspin.SetRange32(-10000, 10000);
- for(ptrdiff_t i = 0; i < 4; i++)
- {
+ 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);
@@ -178,8 +181,7 @@ void CStyleEditorDialog::AskColor(int i)
{
CColorDialog dlg(m_stss.colors[i]);
dlg.m_cc.Flags |= CC_FULLOPEN;
- if(dlg.DoModal() == IDOK)
- {
+ if(dlg.DoModal() == IDOK) {
m_stss.colors[i] = dlg.m_cc.rgbResult;
m_color[i].Invalidate();
}
@@ -223,16 +225,15 @@ void CStyleEditorDialog::OnBnClickedButton1()
lf <<= m_stss;
CFontDialog dlg(&lf, CF_SCREENFONTS|CF_INITTOLOGFONTSTRUCT|CF_FORCEFONTEXIST|CF_SCALABLEONLY|CF_EFFECTS);
- if(dlg.DoModal() == IDOK)
- {
+ if(dlg.DoModal() == IDOK) {
CString str(lf.lfFaceName);
- if(str.GetLength() > 16) str = str.Left(14) + _T("...");
+ if(str.GetLength() > 16) {
+ str = str.Left(14) + _T("...");
+ }
m_font.SetWindowText(str);
- for(ptrdiff_t i = 0, j = m_charset.GetCount(); i < j; i++)
- {
- if(m_charset.GetItemData(i) == lf.lfCharSet)
- {
+ for(ptrdiff_t i = 0, j = m_charset.GetCount(); i < j; i++) {
+ if(m_charset.GetItemData(i) == lf.lfCharSet) {
m_charset.SetCurSel(i);
break;
}
@@ -267,17 +268,22 @@ void CStyleEditorDialog::OnBnClickedCheck1()
UpdateData();
int avg = 0;
- for(ptrdiff_t i = 0; i < 4; i++) avg += m_alphasliders[i].GetPos();
+ 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);
+ 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)
- {
+ if(m_linkalphasliders && pScrollBar) {
int pos = ((CSliderCtrl*)pScrollBar)->GetPos();
- for(ptrdiff_t i = 0; i < 4; i++) m_alphasliders[i].SetPos(pos);
+ 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 b0760539d..ce6585d4b 100644
--- a/src/filters/transform/VSFilter/StyleEditorDialog.h
+++ b/src/filters/transform/VSFilter/StyleEditorDialog.h
@@ -46,8 +46,7 @@ public:
DECLARE_MESSAGE_MAP()
protected:
- virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
- {
+ virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) {
CRect r;
GetClientRect(r);
CDC::FromHandle(lpDrawItemStruct->hDC)->FillSolidRect(r, m_pColor ? *m_pColor : ::GetSysColor(COLOR_BTNFACE));
@@ -70,7 +69,7 @@ public:
CStyleEditorDialog(CString title, STSStyle* pstss, CWnd* pParent = NULL); // standard constructor
virtual ~CStyleEditorDialog();
-// Dialog Data
+ // Dialog Data
enum { IDD = IDD_STYLEDIALOG };
STSStyle m_stss;
diff --git a/src/filters/transform/VSFilter/Systray.cpp b/src/filters/transform/VSFilter/Systray.cpp
index 63a4aa0fa..8fcb10948 100644
--- a/src/filters/transform/VSFilter/Systray.cpp
+++ b/src/filters/transform/VSFilter/Systray.cpp
@@ -43,27 +43,25 @@ 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;
+ 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;
}
}
@@ -75,23 +73,28 @@ class CSystrayWindow : public CWnd
{
SystrayIconData* m_tbid;
- void StepSub(int dir)
- {
+ 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);
+ 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)
- {
+ void ShowSub(bool fShow) {
m_tbid->dvs->put_HideSubtitles(!fShow);
}
- void ToggleSub()
- {
+ void ToggleSub() {
bool fShow;
- if(FAILED(m_tbid->dvs->get_HideSubtitles(&fShow))) return;
+ if(FAILED(m_tbid->dvs->get_HideSubtitles(&fShow))) {
+ return;
+ }
m_tbid->dvs->put_HideSubtitles(!fShow);
}
@@ -131,13 +134,13 @@ END_MESSAGE_MAP()
int CSystrayWindow::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
- if(CWnd::OnCreate(lpCreateStruct) == -1)
+ if(CWnd::OnCreate(lpCreateStruct) == -1) {
return -1;
+ }
- if(g_hHook == INVALID_HANDLE_VALUE)
- {
+ if(g_hHook == INVALID_HANDLE_VALUE) {
AFX_MANAGE_STATE(AfxGetStaticModuleState());
-// g_hHook = SetWindowsHookEx(WH_GETMESSAGE, (HOOKPROC)HookProc, AfxGetInstanceHandle(), 0);
+ // g_hHook = SetWindowsHookEx(WH_GETMESSAGE, (HOOKPROC)HookProc, AfxGetInstanceHandle(), 0);
}
SetTimer(1, 5000, NULL);
@@ -160,8 +163,7 @@ void CSystrayWindow::OnDestroy()
tnid.uID = IDI_ICON1;
Shell_NotifyIcon(NIM_DELETE, &tnid);
- if(g_hHook != INVALID_HANDLE_VALUE)
- {
+ if(g_hHook != INVALID_HANDLE_VALUE) {
UnhookWindowsHookEx(g_hHook);
g_hHook = (HHOOK)INVALID_HANDLE_VALUE;
}
@@ -171,11 +173,9 @@ void CSystrayWindow::OnDestroy()
void CSystrayWindow::OnTimer(UINT_PTR nIDEvent)
{
- if(nIDEvent == 1)
- {
+ if(nIDEvent == 1) {
UINT fScreenSaver = 0;
- if(SystemParametersInfo(SPI_GETSCREENSAVEACTIVE, 0, (PVOID)&fScreenSaver, 0))
- {
+ if(SystemParametersInfo(SPI_GETSCREENSAVEACTIVE, 0, (PVOID)&fScreenSaver, 0)) {
SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, 0, 0, SPIF_SENDWININICHANGE); // this might not be needed at all...
SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, fScreenSaver, 0, SPIF_SENDWININICHANGE);
}
@@ -214,21 +214,22 @@ LRESULT CSystrayWindow::OnTaskBarRestart(WPARAM, LPARAM)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
- if(m_tbid->fShowIcon)
- {
+ if(m_tbid->fShowIcon) {
NOTIFYICONDATA tnid;
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.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;
lstrcpyn(tnid.szTip, TEXT("DirectVobSub"), sizeof(tnid.szTip));
BOOL res = Shell_NotifyIcon(NIM_ADD, &tnid);
- if(tnid.hIcon) DestroyIcon(tnid.hIcon);
+ if(tnid.hIcon) {
+ DestroyIcon(tnid.hIcon);
+ }
return res?0:-1;
}
@@ -238,145 +239,138 @@ LRESULT CSystrayWindow::OnTaskBarRestart(WPARAM, LPARAM)
LRESULT CSystrayWindow::OnNotifyIcon(WPARAM wParam, LPARAM lParam)
{
- if((UINT)wParam != IDI_ICON1)
+ 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;
- }
+ 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.
- pBF2 = pBF;
+ CComPtr<IBaseFilter> pBF2;
- break;
- }
- EndEnumFilters
-
- if(pBF2)
- ShowPPage(pBF2, hWnd);
- }
- break;
+ BeginEnumFilters(m_tbid->graph, pEF, pBF) {
+ if(!CComQIPtr<IDirectVobSub>(pBF)) {
+ continue;
+ }
- case WM_RBUTTONDOWN:
- {
- POINT p;
- GetCursorPos(&p);
+ if(CComQIPtr<IVideoWindow> pVW = m_tbid->graph) {
+ HWND hwnd;
+ if(SUCCEEDED(pVW->get_Owner((OAHWND*)&hwnd))
+ || SUCCEEDED(pVW->get_MessageDrain((OAHWND*)&hwnd))) {
+ hWnd = hwnd;
+ }
+ }
- CInterfaceArray<IAMStreamSelect> pStreams;
- CStringArray names;
+ pBF2 = pBF;
- BeginEnumFilters(m_tbid->graph, pEF, pBF)
- {
- CString name = GetFilterName(pBF);
- if(name.IsEmpty()) continue;
+ break;
+ }
+ EndEnumFilters
- if(CComQIPtr<IAMStreamSelect> pSS = pBF)
- {
- pStreams.Add(pSS);
- names.Add(name);
+ if(pBF2) {
+ ShowPPage(pBF2, hWnd);
}
}
- EndEnumFilters
+ break;
- CMenu popup;
- popup.CreatePopupMenu();
+ case WM_RBUTTONDOWN: {
+ POINT p;
+ GetCursorPos(&p);
- for(ptrdiff_t j = 0; j < pStreams.GetCount(); j++)
- {
- bool fMMSwitcher = !names[j].Compare(_T("Morgan Stream Switcher"));
+ 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
- DWORD cStreams = 0;
- pStreams[j]->Count(&cStreams);
+ CMenu popup;
+ popup.CreatePopupMenu();
- DWORD flags, group, prevgroup = (DWORD)-1;
+ for(ptrdiff_t j = 0; j < pStreams.GetCount(); j++) {
+ bool fMMSwitcher = !names[j].Compare(_T("Morgan Stream Switcher"));
- for(UINT i = 0; i < cStreams; i++)
- {
- WCHAR* pName = NULL;
+ DWORD cStreams = 0;
+ pStreams[j]->Count(&cStreams);
- if(S_OK == pStreams[j]->Info(i, 0, &flags, 0, &group, &pName, 0, 0))
- {
- if(prevgroup != group && i > 1)
- {
- if(fMMSwitcher) {
- cStreams = i;
- break;
+ 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);
}
- popup.AppendMenu(MF_SEPARATOR);
- }
- prevgroup = group;
+ 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(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);
+ if(cStreams > 0) {
+ popup.AppendMenu(MF_SEPARATOR);
+ }
+ }
- delete [] str;
+ int i = 0;
- i++;
+ 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);
+ }
- SetForegroundWindow();
- UINT id = popup.TrackPopupMenu(TPM_LEFTBUTTON|TPM_RETURNCMD, p.x, p.y, CWnd::FromHandle(hWnd), 0);
- PostMessage(WM_NULL);
+ delete [] str;
- 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;
+ i++;
+ str = CallPPage(m_tbid->graph, i, (HWND)INVALID_HANDLE_VALUE);
}
- CallPPage(m_tbid->graph, id&0xff, hWnd);
- }
- }
- break;
+ 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;
+ }
+ }
- default:
+ CallPPage(m_tbid->graph, id&0xff, hWnd);
+ }
+ }
break;
+
+ default:
+ break;
}
return 0;
@@ -389,14 +383,14 @@ DWORD CALLBACK SystrayThreadProc(void* pParam)
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))
+ 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;
MSG msg;
- while(GetMessage(&msg, NULL/*wnd.m_hWnd*/, 0, 0))
- {
+ while(GetMessage(&msg, NULL/*wnd.m_hWnd*/, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
@@ -417,13 +411,13 @@ static TCHAR* CallPPage(IFilterGraph* pGraph, int idx, HWND hWnd)
CAUUID caGUID;
caGUID.pElems = NULL;
- BeginEnumFilters(pGraph, pEF, pBF)
- {
+ BeginEnumFilters(pGraph, pEF, pBF) {
CComQIPtr<ISpecifyPropertyPages> pSPS = pBF;
- if(!pSPS) continue;
+ if(!pSPS) {
+ continue;
+ }
- if(i == idx)
- {
+ 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... :)
@@ -436,22 +430,23 @@ static TCHAR* CallPPage(IFilterGraph* pGraph, int idx, HWND hWnd)
TCHAR* ret = NULL;
- if(pFilter)
- {
- if(hWnd != INVALID_HANDLE_VALUE)
- {
+ if(pFilter) {
+ if(hWnd != INVALID_HANDLE_VALUE) {
ShowPPage(pFilter, hWnd);
- }
- else
- {
+ } else {
ret = new TCHAR[wcslen(wstr)+1];
- if(ret)
+ if(ret) {
_tcscpy(ret, CString(wstr));
+ }
}
}
- if(caGUID.pElems) CoTaskMemFree(caGUID.pElems);
- if(wstr) free(wstr);
+ if(caGUID.pElems) {
+ CoTaskMemFree(caGUID.pElems);
+ }
+ if(wstr) {
+ free(wstr);
+ }
return(ret);
}
diff --git a/src/filters/transform/VSFilter/VSFilter.cpp b/src/filters/transform/VSFilter/VSFilter.cpp
index 12ae93e67..2bb1d23fb 100644
--- a/src/filters/transform/VSFilter/VSFilter.cpp
+++ b/src/filters/transform/VSFilter/VSFilter.cpp
@@ -44,8 +44,9 @@ extern "C" BOOL WINAPI DllEntryPoint(HINSTANCE, ULONG, LPVOID);
BOOL CVSFilterApp::InitInstance()
{
- if(!CWinApp::InitInstance())
+ if(!CWinApp::InitInstance()) {
return FALSE;
+ }
SetRegistryKey(_T("Gabest"));
@@ -82,8 +83,7 @@ CVSFilterApp theApp;
//////////////////////////////////////////////////////////////////////////
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] = {
{&MEDIATYPE_NULL, &MEDIASUBTYPE_NULL},
{&MEDIATYPE_Video, &MEDIASUBTYPE_YUY2},
{&MEDIATYPE_Video, &MEDIASUBTYPE_YV12},
@@ -95,31 +95,27 @@ const AMOVIESETUP_MEDIATYPE sudPinTypesIn[] =
{&MEDIATYPE_Video, &MEDIASUBTYPE_RGB24},
};
-const AMOVIESETUP_MEDIATYPE sudPinTypesIn2[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesIn2[] = {
{&MEDIATYPE_Text, &MEDIASUBTYPE_None},
};
-const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] =
-{
+const AMOVIESETUP_MEDIATYPE sudPinTypesOut[] = {
{&MEDIATYPE_Video, &MEDIASUBTYPE_None},
};
-const AMOVIESETUP_PIN sudpPins[] =
-{
+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}
};
-/*const*/ AMOVIESETUP_FILTER sudFilter[] =
-{
+/*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},
};
-CFactoryTemplate g_Templates[] =
-{
+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>},
@@ -140,34 +136,38 @@ STDAPI DllRegisterServer()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
- if(theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_SEENDIVXWARNING), 0) != 1)
+ 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)
+ 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)
+ 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);
}
STDAPI DllUnregisterServer()
{
-// DVS_WriteProfileInt2(IDS_R_GENERAL, IDS_RG_SEENDIVXWARNING, 0);
+ // DVS_WriteProfileInt2(IDS_R_GENERAL, IDS_RG_SEENDIVXWARNING, 0);
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;
- if(SUCCEEDED(pFilter.CoCreateInstance(__uuidof(CDirectVobSubFilter))) && (pSpecify = pFilter))
- {
+ if(SUCCEEDED(pFilter.CoCreateInstance(__uuidof(CDirectVobSubFilter))) && (pSpecify = pFilter)) {
ShowPPage(pFilter, hwnd);
}
diff --git a/src/filters/transform/VSFilter/csri.h b/src/filters/transform/VSFilter/csri.h
index 83ee828fa..7d67bae96 100644
--- a/src/filters/transform/VSFilter/csri.h
+++ b/src/filters/transform/VSFilter/csri.h
@@ -43,39 +43,39 @@ 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 @@ enum csri_pixfmt {
#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.
+ /** 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.
*/
- const char *name;
- /** an identifier to the exact version of the renderer.
- * most likely a version number or revision identifier.
+ 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.
*
- * 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.
+ * currently registered namespaces are:
+ *
+ * \code
+ * csri.* - official extensions
+ * asa.* - custom extensions of the asa renderer
+ * \endcode
*/
- 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);
+ 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.
+ */
-/** \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);
-
-/*@}*/
+ 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 059c02c84..498c1d592 100644
--- a/src/filters/transform/VSFilter/csriapi.cpp
+++ b/src/filters/transform/VSFilter/csriapi.cpp
@@ -54,8 +54,9 @@ CSRIAPI csri_inst *csri_open_file(csri_rend *renderer, const char *filename, str
wchar_t *namebuf;
namesize = MultiByteToWideChar(CP_UTF8, 0, filename, -1, NULL, 0);
- if (!namesize)
+ if (!namesize) {
return 0;
+ }
namesize++;
namebuf = new wchar_t[namesize];
MultiByteToWideChar(CP_UTF8, 0, filename, -1, namebuf, namesize);
@@ -98,7 +99,9 @@ CSRIAPI csri_inst *csri_open_mem(csri_rend *renderer, const void *data, size_t l
CSRIAPI void csri_close(csri_inst *inst)
{
- if (!inst) return;
+ if (!inst) {
+ return;
+ }
delete inst->rts;
delete inst->cs;
@@ -108,10 +111,13 @@ CSRIAPI void csri_close(csri_inst *inst)
CSRIAPI int csri_request_fmt(csri_inst *inst, const struct csri_fmt *fmt)
{
- if (!inst) return -1;
+ if (!inst) {
+ return -1;
+ }
- if (!fmt->width || !fmt->height)
+ if (!fmt->width || !fmt->height) {
return -1;
+ }
// Check if pixel format is supported
switch (fmt->pixfmt) {
@@ -188,18 +194,18 @@ CSRIAPI void *csri_query_ext(csri_rend *rend, csri_ext_id extname)
// Get info for renderer
static struct csri_info csri_vsfilter_info = {
#ifdef _DEBUG
- #ifdef _VSMOD
- "vsfiltermod_textsub_debug", // name
- #else
- "vsfilter_textsub_debug", // name
- #endif
+#ifdef _VSMOD
+ "vsfiltermod_textsub_debug", // name
+#else
+ "vsfilter_textsub_debug", // name
+#endif
"2.40", // version (assumed version number, svn revision, patchlevel)
#else
- #ifdef _VSMOD
- "vsfiltermod_textsub", // name
- #else
- "vsfilter_textsub", // name
- #endif
+#ifdef _VSMOD
+ "vsfiltermod_textsub", // name
+#else
+ "vsfilter_textsub", // name
+#endif
"2.40", // version (assumed version number, svn revision, patchlevel)
#endif
// 2.38-0611 is base svn 611
@@ -216,17 +222,18 @@ static struct csri_info csri_vsfilter_info = {
"Gabest", // author
"Copyright (c) 2003-2010 by Gabest and others" // copyright
};
-CSRIAPI struct csri_info *csri_renderer_info(csri_rend *rend)
-{
+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)
{
- if (strcmp(name, csri_vsfilter_info.name))
+ if (strcmp(name, csri_vsfilter_info.name)) {
return 0;
- if (specific && strcmp(specific, csri_vsfilter_info.specific))
+ }
+ if (specific && strcmp(specific, csri_vsfilter_info.specific)) {
return 0;
+ }
return &csri_vsfilter;
}
// Still just one
diff --git a/src/filters/transform/VSFilter/plugins.cpp b/src/filters/transform/VSFilter/plugins.cpp
index 9f7146b1f..6e4732c0c 100644
--- a/src/filters/transform/VSFilter/plugins.cpp
+++ b/src/filters/transform/VSFilter/plugins.cpp
@@ -39,1104 +39,1102 @@
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);
- }
+ 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;
- }
+ 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);
+ bool Render(SubPicDesc& dst, REFERENCE_TIME rt, float fps) {
+ if(!m_pSubPicProvider) {
+ return(false);
+ }
- CSize size(dst.w, dst.h);
+ CSize size(dst.w, dst.h);
- if(!m_pSubPicQueue)
- {
- CComPtr<ISubPicAllocator> pAllocator = new CMemSubPicAllocator(dst.type, size);
+ if(!m_pSubPicQueue) {
+ CComPtr<ISubPicAllocator> pAllocator = new CMemSubPicAllocator(dst.type, size);
+
+ HRESULT hr;
+ if(!(m_pSubPicQueue = new 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;
+ }
- HRESULT hr;
- if(!(m_pSubPicQueue = new CSubPicQueueNoThread(pAllocator, &hr)) || FAILED(hr))
- {
- m_pSubPicQueue = NULL;
+ CComPtr<ISubPic> pSubPic;
+ if(!m_pSubPicQueue->LookupSubPic(rt, pSubPic)) {
return(false);
}
- }
- if(m_SubPicProviderId != (DWORD_PTR)(ISubPicProvider*)m_pSubPicProvider)
- {
- m_pSubPicQueue->SetSubPicProvider(m_pSubPicProvider);
- m_SubPicProviderId = (DWORD_PTR)(ISubPicProvider*)m_pSubPicProvider;
- }
+ CRect r;
+ pSubPic->GetDirtyRect(r);
- CComPtr<ISubPic> pSubPic;
- if(!m_pSubPicQueue->LookupSubPic(rt, pSubPic))
- return(false);
+ if(dst.type == MSP_RGB32 || dst.type == MSP_RGB24 || dst.type == MSP_RGB16 || dst.type == MSP_RGB15) {
+ dst.h = -dst.h;
+ }
- CRect r;
- pSubPic->GetDirtyRect(r);
+ pSubPic->AlphaBlt(r, r, &dst);
- if(dst.type == MSP_RGB32 || dst.type == MSP_RGB24 || dst.type == MSP_RGB16 || dst.type == MSP_RGB15)
- dst.h = -dst.h;
+ return(true);
+ }
- pSubPic->AlphaBlt(r, r, &dst);
+ DWORD ThreadProc() {
+ SetThreadPriority(m_hThread, THREAD_PRIORITY_LOWEST);
- return(true);
- }
+ CAtlArray<HANDLE> handles;
+ handles.Add(GetRequestHandle());
- DWORD ThreadProc()
- {
- SetThreadPriority(m_hThread, THREAD_PRIORITY_LOWEST);
+ CString fn = GetFileName();
+ CFileStatus fs;
+ fs.m_mtime = 0;
+ CFileGetStatus(fn, fs);
- CAtlArray<HANDLE> handles;
- handles.Add(GetRequestHandle());
+ while(1) {
+ DWORD i = WaitForMultipleObjects(handles.GetCount(), handles.GetData(), FALSE, 1000);
- CString fn = GetFileName();
- CFileStatus fs;
- fs.m_mtime = 0;
- CFileGetStatus(fn, fs);
+ 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);
- while(1)
- {
- DWORD i = WaitForMultipleObjects(handles.GetCount(), handles.GetData(), FALSE, 1000);
+ if(fs.m_mtime < fs2.m_mtime) {
+ fs.m_mtime = fs2.m_mtime;
- 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();
+ 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_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;
}
}
- else // if(WAIT_ABANDONED_0 == i || WAIT_FAILED == i)
- {
- break;
- }
- }
- m_hThread = 0;
+ m_hThread = 0;
- for(ptrdiff_t i = 1; i < handles.GetCount(); i++)
- FindCloseChangeNotification(handles[i]);
-
- return 0;
- }
-};
+ for(ptrdiff_t i = 1; i < handles.GetCount(); i++) {
+ FindCloseChangeNotification(handles[i]);
+ }
-class CVobSubFilter : virtual public CFilter
-{
-public:
- CVobSubFilter(CString fn = _T(""))
- {
- if(!fn.IsEmpty()) Open(fn);
- }
+ return 0;
+ }
+ };
- bool Open(CString fn)
+ class CVobSubFilter : virtual public CFilter
{
- SetFileName(_T(""));
- m_pSubPicProvider = NULL;
-
- if(CVobSubFile* vsf = new CVobSubFile(&m_csSubLock))
- {
- m_pSubPicProvider = (ISubPicProvider*)vsf;
- if(vsf->Open(CString(fn))) SetFileName(fn);
- else m_pSubPicProvider = NULL;
+ public:
+ CVobSubFilter(CString fn = _T("")) {
+ if(!fn.IsEmpty()) {
+ Open(fn);
+ }
}
- return !!m_pSubPicProvider;
- }
-};
-
-class CTextSubFilter : virtual public CFilter
-{
- int m_CharSet;
+ bool Open(CString fn) {
+ SetFileName(_T(""));
+ m_pSubPicProvider = NULL;
-public:
- CTextSubFilter(CString fn = _T(""), int CharSet = DEFAULT_CHARSET, float fps = -1)
- : m_CharSet(CharSet)
- {
- m_fps = fps;
- if(!fn.IsEmpty()) Open(fn, CharSet);
- }
+ if(CVobSubFile* vsf = new CVobSubFile(&m_csSubLock)) {
+ m_pSubPicProvider = (ISubPicProvider*)vsf;
+ if(vsf->Open(CString(fn))) {
+ SetFileName(fn);
+ } else {
+ m_pSubPicProvider = NULL;
+ }
+ }
- int GetCharSet() {
- return(m_CharSet);
- }
+ return !!m_pSubPicProvider;
+ }
+ };
- bool Open(CString fn, int CharSet = DEFAULT_CHARSET)
+ class CTextSubFilter : virtual public CFilter
{
- SetFileName(_T(""));
- m_pSubPicProvider = NULL;
-
- if(!m_pSubPicProvider)
- {
- if(ssf::CRenderer* ssf = new ssf::CRenderer(&m_csSubLock))
- {
- m_pSubPicProvider = (ISubPicProvider*)ssf;
- if(ssf->Open(CString(fn))) SetFileName(fn);
- else m_pSubPicProvider = NULL;
+ 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);
}
}
- if(!m_pSubPicProvider)
- {
- if(CRenderedTextSubtitle* rts = new CRenderedTextSubtitle(&m_csSubLock))
- {
- m_pSubPicProvider = (ISubPicProvider*)rts;
- if(rts->Open(CString(fn), CharSet)) SetFileName(fn);
- else m_pSubPicProvider = NULL;
- }
+ int GetCharSet() {
+ return(m_CharSet);
}
- return !!m_pSubPicProvider;
- }
-};
-
-#ifndef WIN64
-//
-// old VirtualDub interface
-//
-
-namespace VirtualDub
-{
-//#include <VirtualDub\VirtualDub.h>
-//#include <vd2/OldFilterSDK/VirtualDub.h>
-#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;
+ bool Open(CString fn, int CharSet = DEFAULT_CHARSET) {
+ SetFileName(_T(""));
+ m_pSubPicProvider = NULL;
+
+ if(!m_pSubPicProvider) {
+ if(ssf::CRenderer* ssf = new ssf::CRenderer(&m_csSubLock)) {
+ m_pSubPicProvider = (ISubPicProvider*)ssf;
+ if(ssf->Open(CString(fn))) {
+ SetFileName(fn);
+ } else {
+ m_pSubPicProvider = NULL;
+ }
+ }
+ }
- return 0;
- }
+ if(!m_pSubPicProvider) {
+ if(CRenderedTextSubtitle* rts = new CRenderedTextSubtitle(&m_csSubLock)) {
+ m_pSubPicProvider = (ISubPicProvider*)rts;
+ if(rts->Open(CString(fn), CharSet)) {
+ SetFileName(fn);
+ } else {
+ m_pSubPicProvider = NULL;
+ }
+ }
+ }
- 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;
-};
+ return !!m_pSubPicProvider;
+ }
+ };
-class CVobSubVirtualDubFilter : public CVobSubFilter, public CVirtualDubFilter
-{
-public:
- CVobSubVirtualDubFilter(CString fn = _T(""))
- : CVobSubFilter(fn) {}
+#ifndef WIN64
+ //
+ // old VirtualDub interface
+ //
- int ConfigProc(FilterActivation* fa, const FilterFunctions* ff, HWND hwnd)
+ namespace VirtualDub
{
- AFX_MANAGE_STATE(AfxGetStaticModuleState());
+ //#include <VirtualDub\VirtualDub.h>
+ //#include <vd2/OldFilterSDK/VirtualDub.h>
+#include <vd2/extras/FilterSDK/VirtualDub.h>
- CFileDialog fd(TRUE, NULL, GetFileName(), OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY,
- _T("VobSub files (*.idx;*.sub)|*.idx;*.sub||"), CWnd::FromHandle(hwnd), 0);
+ 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;
+ }
- if(fd.DoModal() != IDOK) return 1;
+ 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 Open(fd.GetPathName()) ? 0 : 1;
- }
+ return 0;
+ }
- void StringProc(const FilterActivation* fa, const FilterFunctions* ff, char* str)
- {
- sprintf(str, " (%s)", !GetFileName().IsEmpty() ? CStringA(GetFileName()) : " (empty)");
- }
+ 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;
+ };
- bool FssProc(FilterActivation* fa, const FilterFunctions* ff, char* buf, int buflen)
- {
- CStringA fn(GetFileName());
- fn.Replace("\\", "\\\\");
- _snprintf(buf, buflen, "Config(\"%s\")", fn);
- return(true);
- }
-};
+ class CVobSubVirtualDubFilter : public CVobSubFilter, public CVirtualDubFilter
+ {
+ public:
+ CVobSubVirtualDubFilter(CString fn = _T(""))
+ : CVobSubFilter(fn) {}
-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());
- 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);
- 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));
- //OPENFILENAME_SIZE_VERSION_400 /*0* /);
- UINT_PTR CALLBACK OpenHookProc(HWND hDlg, UINT uiMsg, WPARAM wParam, LPARAM lParam);
+ if(fd.DoModal() != IDOK) {
+ return 1;
+ }
- 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;
+ return Open(fd.GetPathName()) ? 0 : 1;
+ }
- if(fd.DoModal() != IDOK) return 1;
+ void StringProc(const FilterActivation* fa, const FilterFunctions* ff, char* str) {
+ sprintf(str, " (%s)", !GetFileName().IsEmpty() ? CStringA(GetFileName()) : " (empty)");
+ }
- return Open(fd.GetPathName(), fd.m_pOFN->lCustData) ? 0 : 1;
- }
+ bool FssProc(FilterActivation* fa, const FilterFunctions* ff, char* buf, int buflen) {
+ CStringA fn(GetFileName());
+ fn.Replace("\\", "\\\\");
+ _snprintf(buf, buflen, "Config(\"%s\")", fn);
+ return(true);
+ }
+ };
- void StringProc(const FilterActivation* fa, const FilterFunctions* ff, char* str)
- {
- if(!GetFileName().IsEmpty()) sprintf(str, " (%s, %d)", CStringA(GetFileName()), GetCharSet());
- else sprintf(str, " (empty)");
- }
+ 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));
+ //OPENFILENAME_SIZE_VERSION_400 /*0* /);
+ 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;
+ }
- bool FssProc(FilterActivation* fa, const FilterFunctions* ff, char* buf, int buflen)
- {
- CStringA fn(GetFileName());
- fn.Replace("\\", "\\\\");
- _snprintf(buf, buflen, "Config(\"%s\", %d)", fn, GetCharSet());
- return(true);
- }
-};
+ return Open(fd.GetPathName(), fd.m_pOFN->lCustData) ? 0 : 1;
+ }
-int vobsubInitProc(FilterActivation* fa, const FilterFunctions* ff)
-{
- *(CVirtualDubFilter**)fa->filter_data = new CVobSubVirtualDubFilter();
- return !(*(CVirtualDubFilter**)fa->filter_data);
-}
+ void StringProc(const FilterActivation* fa, const FilterFunctions* ff, char* str) {
+ if(!GetFileName().IsEmpty()) {
+ sprintf(str, " (%s, %d)", CStringA(GetFileName()), GetCharSet());
+ } else {
+ sprintf(str, " (empty)");
+ }
+ }
-int textsubInitProc(FilterActivation* fa, const FilterFunctions* ff)
-{
- *(CVirtualDubFilter**)fa->filter_data = new CTextSubVirtualDubFilter();
- return !(*(CVirtualDubFilter**)fa->filter_data);
-}
+ bool FssProc(FilterActivation* fa, const FilterFunctions* ff, char* buf, int buflen) {
+ CStringA fn(GetFileName());
+ fn.Replace("\\", "\\\\");
+ _snprintf(buf, buflen, "Config(\"%s\", %d)", fn, GetCharSet());
+ return(true);
+ }
+ };
-void baseDeinitProc(FilterActivation* fa, const FilterFunctions* ff)
-{
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- if(f) delete f, f = NULL;
-}
+ int vobsubInitProc(FilterActivation* fa, const FilterFunctions* ff)
+ {
+ *(CVirtualDubFilter**)fa->filter_data = new CVobSubVirtualDubFilter();
+ return !(*(CVirtualDubFilter**)fa->filter_data);
+ }
-int baseRunProc(const FilterActivation* fa, const FilterFunctions* ff)
-{
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- return f ? f->RunProc(fa, ff) : 1;
-}
+ int textsubInitProc(FilterActivation* fa, const FilterFunctions* ff)
+ {
+ *(CVirtualDubFilter**)fa->filter_data = new CTextSubVirtualDubFilter();
+ return !(*(CVirtualDubFilter**)fa->filter_data);
+ }
-long baseParamProc(FilterActivation* fa, const FilterFunctions* ff)
-{
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- return f ? f->ParamProc(fa, ff) : 1;
-}
+ void baseDeinitProc(FilterActivation* fa, const FilterFunctions* ff)
+ {
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ if(f) {
+ delete f, f = NULL;
+ }
+ }
-int baseConfigProc(FilterActivation* fa, const FilterFunctions* ff, HWND hwnd)
-{
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- return f ? f->ConfigProc(fa, ff, hwnd) : 1;
-}
+ int baseRunProc(const FilterActivation* fa, const FilterFunctions* ff)
+ {
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ return f ? f->RunProc(fa, ff) : 1;
+ }
-void baseStringProc(const FilterActivation* fa, const FilterFunctions* ff, char* str)
-{
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- if(f) f->StringProc(fa, ff, str);
-}
+ long baseParamProc(FilterActivation* fa, const FilterFunctions* ff)
+ {
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ return f ? f->ParamProc(fa, ff) : 1;
+ }
-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;
-}
+ int baseConfigProc(FilterActivation* fa, const FilterFunctions* ff, HWND hwnd)
+ {
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ return f ? f->ConfigProc(fa, ff, hwnd) : 1;
+ }
-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 = new CVobSubVirtualDubFilter(CString(*argv[0].asString()));
- *(CVirtualDubFilter**)fa->filter_data = f;
-}
+ void baseStringProc(const FilterActivation* fa, const FilterFunctions* ff, char* str)
+ {
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ if(f) {
+ f->StringProc(fa, ff, str);
+ }
+ }
-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 = new CTextSubVirtualDubFilter(CString(*argv[0].asString()), argv[1].asInt());
- *(CVirtualDubFilter**)fa->filter_data = f;
-}
+ 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;
+ }
-ScriptFunctionDef vobsub_func_defs[]= {
- { (ScriptFunctionPtr)vobsubScriptConfig, "Config", "0s" },
- { NULL },
-};
+ 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 = new CVobSubVirtualDubFilter(CString(*argv[0].asString()));
+ *(CVirtualDubFilter**)fa->filter_data = f;
+ }
-CScriptObject vobsub_obj= {
- NULL, vobsub_func_defs
-};
+ 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 = new CTextSubVirtualDubFilter(CString(*argv[0].asString()), argv[1].asInt());
+ *(CVirtualDubFilter**)fa->filter_data = f;
+ }
-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
+ 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
#ifdef _VSMOD
- "TextSubMod", // name
+ "TextSubMod", // name
#else
- "TextSub", // name
+ "TextSub", // name
#endif
- "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;
+ "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;
+ vdfd_ver = VIRTUALDUB_FILTERDEF_VERSION;
+ vdfd_compat = VIRTUALDUB_FILTERDEF_COMPATIBLE;
- return 0;
-}
+ return 0;
+ }
-extern "C" __declspec(dllexport) void __cdecl VirtualdubFilterModuleDeinit(FilterModule *fm, const FilterFunctions *ff)
-{
- ff->removeFilter(fd_textsub);
- ff->removeFilter(fd_vobsub);
-}
-}/**/
+ 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;
- }
+ 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;
+ 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;
- }
+ 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;
-};
+ 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) {}
+ 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());
+ 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);
+ 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;
+ if(fd.DoModal() != IDOK) {
+ return 1;
+ }
- return Open(fd.GetPathName()) ? 0 : 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)");
- }
+ 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(buf, buflen, "Config(\"%s\")", fn);
- return(true);
- }
-};
+ bool FssProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* buf, int buflen) {
+ CStringA fn(GetFileName());
+ fn.Replace("\\", "\\\\");
+ _snprintf(buf, buflen, "Config(\"%s\")", fn);
+ return(true);
+ }
+ };
-class CTextSubVirtualDubFilter : public CTextSubFilter, public CVirtualDubFilter
-{
-public:
- CTextSubVirtualDubFilter(CString fn = _T(""), int CharSet = DEFAULT_CHARSET)
- : CTextSubFilter(fn, CharSet) {}
+ 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());
+ int ConfigProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, VDXHWND hwnd) {
+ AFX_MANAGE_STATE(AfxGetStaticModuleState());
- /* off encoding changing */
+ /* 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));
- //OPENFILENAME_SIZE_VERSION_400 /*0*/);
- 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));
+ //OPENFILENAME_SIZE_VERSION_400 /*0*/);
+ 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)");
- }
+ if(fd.DoModal() != IDOK) {
+ return 1;
+ }
- bool FssProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* buf, int buflen)
- {
- CStringA fn(GetFileName());
- fn.Replace("\\", "\\\\");
- _snprintf(buf, buflen, "Config(\"%s\", %d)", fn, GetCharSet());
- return(true);
- }
-};
+ return Open(fd.GetPathName(), fd.m_pOFN->lCustData) ? 0 : 1;
+ }
-int vobsubInitProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff)
-{
- return !(*(CVirtualDubFilter**)fa->filter_data = new CVobSubVirtualDubFilter());
-}
+ void StringProc(const VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* str) {
+ if(!GetFileName().IsEmpty()) {
+ sprintf(str, " (%s, %d)", CStringA(GetFileName()), GetCharSet());
+ } else {
+ sprintf(str, " (empty)");
+ }
+ }
-int textsubInitProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff)
-{
- return !(*(CVirtualDubFilter**)fa->filter_data = new CTextSubVirtualDubFilter());
-}
+ bool FssProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* buf, int buflen) {
+ CStringA fn(GetFileName());
+ fn.Replace("\\", "\\\\");
+ _snprintf(buf, buflen, "Config(\"%s\", %d)", fn, GetCharSet());
+ return(true);
+ }
+ };
-void baseDeinitProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff)
-{
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- if(f) delete f, f = NULL;
-}
+ int vobsubInitProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff)
+ {
+ return !(*(CVirtualDubFilter**)fa->filter_data = new CVobSubVirtualDubFilter());
+ }
-int baseRunProc(const VDXFilterActivation* fa, const VDXFilterFunctions* ff)
-{
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- return f ? f->RunProc(fa, ff) : 1;
-}
+ int textsubInitProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff)
+ {
+ return !(*(CVirtualDubFilter**)fa->filter_data = new CTextSubVirtualDubFilter());
+ }
-long baseParamProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff)
-{
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- return f ? f->ParamProc(fa, ff) : 1;
-}
+ void baseDeinitProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff)
+ {
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ if(f) {
+ delete f, f = NULL;
+ }
+ }
-int baseConfigProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, VDXHWND hwnd)
-{
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- return f ? f->ConfigProc(fa, ff, hwnd) : 1;
-}
+ int baseRunProc(const VDXFilterActivation* fa, const VDXFilterFunctions* ff)
+ {
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ return f ? f->RunProc(fa, ff) : 1;
+ }
-void baseStringProc(const VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* str)
-{
- CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
- if(f) f->StringProc(fa, ff, str);
-}
+ long baseParamProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff)
+ {
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ return f ? f->ParamProc(fa, ff) : 1;
+ }
-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;
-}
+ int baseConfigProc(VDXFilterActivation* fa, const VDXFilterFunctions* ff, VDXHWND hwnd)
+ {
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ return f ? f->ConfigProc(fa, ff, hwnd) : 1;
+ }
-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 = new CVobSubVirtualDubFilter(CString(*argv[0].asString()));
- *(CVirtualDubFilter**)fa->filter_data = f;
-}
+ void baseStringProc(const VDXFilterActivation* fa, const VDXFilterFunctions* ff, char* str)
+ {
+ CVirtualDubFilter* f = *(CVirtualDubFilter**)fa->filter_data;
+ if(f) {
+ f->StringProc(fa, ff, str);
+ }
+ }
-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 = new CTextSubVirtualDubFilter(CString(*argv[0].asString()), argv[1].asInt());
- *(CVirtualDubFilter**)fa->filter_data = f;
-}
+ 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;
+ }
-VDXScriptFunctionDef vobsub_func_defs[]= {
- { (VDXScriptFunctionPtr)vobsubScriptConfig, "Config", "0s" },
- { NULL },
-};
+ 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 = new CVobSubVirtualDubFilter(CString(*argv[0].asString()));
+ *(CVirtualDubFilter**)fa->filter_data = f;
+ }
-VDXScriptObject vobsub_obj= {
- NULL, vobsub_func_defs
-};
+ 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 = new CTextSubVirtualDubFilter(CString(*argv[0].asString()), argv[1].asInt());
+ *(CVirtualDubFilter**)fa->filter_data = f;
+ }
-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
+ 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
#ifdef _VSMOD
- "TextSubMod", // name
+ "TextSubMod", // name
#else
-"TextSub", // name
+ "TextSub", // name
#endif
- "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)))
- || !(fd_textsub = ff->addFilter(fm, &filterDef_textsub, sizeof(VDXFilterDefinition))))
- return 1;
+ "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)))
+ || !(fd_textsub = ff->addFilter(fm, &filterDef_textsub, sizeof(VDXFilterDefinition)))) {
+ return 1;
+ }
- vdfd_ver = VIRTUALDUB_FILTERDEF_VERSION;
- vdfd_compat = VIRTUALDUB_FILTERDEF_COMPATIBLE;
+ vdfd_ver = VIRTUALDUB_FILTERDEF_VERSION;
+ vdfd_compat = VIRTUALDUB_FILTERDEF_COMPATIBLE;
- return 0;
-}
+ return 0;
+ }
-extern "C" __declspec(dllexport) void __cdecl VirtualdubFilterModuleDeinit(VDXFilterModule *fm, const VDXFilterFunctions *ff)
-{
- ff->removeFilter(fd_textsub);
- ff->removeFilter(fd_vobsub);
-}
-}
+ 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) {}
+ 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);
+ PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env) {
+ PVideoFrame frame = child->GetFrame(n, env);
- env->MakeWritable(&frame);
+ 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;
+ 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;
+ float fps = m_fps > 0 ? m_fps : (float)vi.fps_numerator / vi.fps_denominator;
- Render(dst, (REFERENCE_TIME)(10000000i64 * n / fps), fps);
+ Render(dst, (REFERENCE_TIME)(10000000i64 * n / fps), fps);
- return(frame);
- }
-};
+ 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);
- }
-};
+ 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(new CVobSubAvisynthFilter(args[0].AsClip(), args[1].AsString(), env));
-}
+ AVSValue __cdecl VobSubCreateS(AVSValue args, void* user_data, IScriptEnvironment* env)
+ {
+ return(new 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)
+ 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)
#ifdef _VSMOD
- env->ThrowError("TextSubMod: Can't open \"%s\"", fn);
+ env->ThrowError("TextSubMod: Can't open \"%s\"", fn);
#else
- env->ThrowError("TextSub: Can't open \"%s\"", fn);
+ env->ThrowError("TextSub: Can't open \"%s\"", fn);
#endif
- }
-};
+ }
+ };
-AVSValue __cdecl TextSubCreateS(AVSValue args, void* user_data, IScriptEnvironment* env)
-{
- return(new CTextSubAvisynthFilter(args[0].AsClip(), env, args[1].AsString()));
-}
+ AVSValue __cdecl TextSubCreateS(AVSValue args, void* user_data, IScriptEnvironment* env)
+ {
+ return(new CTextSubAvisynthFilter(args[0].AsClip(), env, args[1].AsString()));
+ }
-AVSValue __cdecl TextSubCreateSI(AVSValue args, void* user_data, IScriptEnvironment* env)
-{
- return(new CTextSubAvisynthFilter(args[0].AsClip(), env, args[1].AsString(), args[2].AsInt()));
-}
+ AVSValue __cdecl TextSubCreateSI(AVSValue args, void* user_data, IScriptEnvironment* env)
+ {
+ return(new CTextSubAvisynthFilter(args[0].AsClip(), env, args[1].AsString(), args[2].AsInt()));
+ }
-AVSValue __cdecl TextSubCreateSIF(AVSValue args, void* user_data, IScriptEnvironment* env)
-{
- return(new CTextSubAvisynthFilter(args[0].AsClip(), env, args[1].AsString(), args[2].AsInt(), args[3].AsFloat()));
-}
+ AVSValue __cdecl TextSubCreateSIF(AVSValue args, void* user_data, IScriptEnvironment* env)
+ {
+ return(new CTextSubAvisynthFilter(args[0].AsClip(), env, args[1].AsString(), args[2].AsInt(), 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(new CTextSubAvisynthFilter(clip.AsClip(), env, args[0].AsString()));
-}
+ 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(new CTextSubAvisynthFilter(clip.AsClip(), env, args[0].AsString()));
+ }
-extern "C" __declspec(dllexport) const char* __stdcall AvisynthPluginInit(IScriptEnvironment* env)
-{
- env->AddFunction("VobSub", "cs", VobSubCreateS, 0);
+ extern "C" __declspec(dllexport) const char* __stdcall AvisynthPluginInit(IScriptEnvironment* env)
+ {
+ env->AddFunction("VobSub", "cs", VobSubCreateS, 0);
#ifdef _VSMOD
- env->AddFunction("TextSubMod", "cs", TextSubCreateS, 0);
- env->AddFunction("TextSubMod", "csi", TextSubCreateSI, 0);
- env->AddFunction("TextSubMod", "csif", TextSubCreateSIF, 0);
- env->AddFunction("MaskSubMod", "siifi", MaskSubCreateSIIFI, 0);
+ env->AddFunction("TextSubMod", "cs", TextSubCreateS, 0);
+ env->AddFunction("TextSubMod", "csi", TextSubCreateSI, 0);
+ env->AddFunction("TextSubMod", "csif", TextSubCreateSIF, 0);
+ env->AddFunction("MaskSubMod", "siifi", MaskSubCreateSIIFI, 0);
#else
- 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->AddFunction("TextSub", "cs", TextSubCreateS, 0);
+ env->AddFunction("TextSub", "csi", TextSubCreateSI, 0);
+ env->AddFunction("TextSub", "csif", TextSubCreateSIF, 0);
+ env->AddFunction("MaskSub", "siifi", MaskSubCreateSIIFI, 0);
#endif
- env->SetVar(env->SaveString("RGBA"),false);
- return(NULL);
-}
-}
+ env->SetVar(env->SaveString("RGBA"),false);
+ return(NULL);
+ }
+ }
-namespace AviSynth25
-{
+ namespace AviSynth25
+ {
#include <avisynth\avisynth25.h>
-static bool s_fSwapUV = false;
+ static bool s_fSwapUV = false;
-class CAvisynthFilter : public GenericVideoFilter, virtual public CFilter
-{
-public:
- VFRTranslator *vfr;
+ 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));
+ }
- CAvisynthFilter(PClip c, IScriptEnvironment* env, VFRTranslator *_vfr=0) : GenericVideoFilter(c), vfr(_vfr) {}
+ Render(dst, timestamp, fps);
- 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);
- }
-};
+ 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);
- }
-};
+ 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(new CVobSubAvisynthFilter(args[0].AsClip(), args[1].AsString(), env));
-}
+ AVSValue __cdecl VobSubCreateS(AVSValue args, void* user_data, IScriptEnvironment* env)
+ {
+ return(new 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)
+ 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)
#ifdef _VSMOD
- env->ThrowError("TextSubMod: Can't open \"%s\"", fn);
+ env->ThrowError("TextSubMod: Can't open \"%s\"", fn);
#else
- env->ThrowError("TextSub: Can't open \"%s\"", fn);
+ env->ThrowError("TextSub: Can't open \"%s\"", fn);
#endif
- }
-};
+ }
+ };
-AVSValue __cdecl TextSubCreateGeneral(AVSValue args, void* user_data, IScriptEnvironment* env)
-{
- if (!args[1].Defined())
+ AVSValue __cdecl TextSubCreateGeneral(AVSValue args, void* user_data, IScriptEnvironment* env)
+ {
+ if (!args[1].Defined())
#ifdef _VSMOD
- env->ThrowError("TextSubMod: You must specify a subtitle file to use");
+ env->ThrowError("TextSubMod: You must specify a subtitle file to use");
#else
- env->ThrowError("TextSub: You must specify a subtitle file to use");
+ env->ThrowError("TextSub: You must specify a subtitle file to use");
#endif
- VFRTranslator *vfr = 0;
- if (args[4].Defined())
- vfr = GetVFRTranslator(args[4].AsString());
-
- return(new CTextSubAvisynthFilter(
- args[0].AsClip(),
- env,
- args[1].AsString(),
- args[2].AsInt(DEFAULT_CHARSET),
- args[3].AsFloat(-1),
- vfr));
-}
+ VFRTranslator *vfr = 0;
+ if (args[4].Defined()) {
+ vfr = GetVFRTranslator(args[4].AsString());
+ }
-AVSValue __cdecl TextSubSwapUV(AVSValue args, void* user_data, IScriptEnvironment* env)
-{
- s_fSwapUV = args[0].AsBool(false);
- return(AVSValue());
-}
+ return(new CTextSubAvisynthFilter(
+ args[0].AsClip(),
+ env,
+ args[1].AsString(),
+ args[2].AsInt(DEFAULT_CHARSET),
+ args[3].AsFloat(-1),
+ vfr));
+ }
-AVSValue __cdecl MaskSubCreate(AVSValue args, void* user_data, IScriptEnvironment* env)/*SIIFI*/
-{
- if (!args[0].Defined())
+ 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())
#ifdef _VSMOD
- env->ThrowError("MaskSubMod: You must specify a subtitle file to use");
+ env->ThrowError("MaskSubMod: You must specify a subtitle file to use");
#else
- env->ThrowError("MaskSub: You must specify a subtitle file to use");
+ env->ThrowError("MaskSub: You must specify a subtitle file to use");
#endif
- if (!args[3].Defined() && !args[6].Defined())
+ if (!args[3].Defined() && !args[6].Defined())
#ifdef _VSMOD
- env->ThrowError("MaskSubMod: You must specify either FPS or a VFR timecodes file");
+ env->ThrowError("MaskSubMod: You must specify either FPS or a VFR timecodes file");
#else
- env->ThrowError("MaskSub: You must specify either FPS or a VFR timecodes file");
+ env->ThrowError("MaskSub: You must specify either FPS or a VFR timecodes file");
#endif
- 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(new CTextSubAvisynthFilter(clip.AsClip(), env, args[0].AsString()));
- return(new CTextSubAvisynthFilter(
- clip.AsClip(),
- env,
- args[0].AsString(),
- args[5].AsInt(DEFAULT_CHARSET),
- args[3].AsFloat(-1),
- vfr));
-}
+ VFRTranslator *vfr = 0;
+ if (args[6].Defined()) {
+ vfr = GetVFRTranslator(args[6].AsString());
+ }
-extern "C" __declspec(dllexport) const char* __stdcall AvisynthPluginInit2(IScriptEnvironment* env)
-{
- env->AddFunction("VobSub", "cs", VobSubCreateS, 0);
+ 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(new CTextSubAvisynthFilter(clip.AsClip(), env, args[0].AsString()));
+ return(new CTextSubAvisynthFilter(
+ clip.AsClip(),
+ env,
+ args[0].AsString(),
+ args[5].AsInt(DEFAULT_CHARSET),
+ args[3].AsFloat(-1),
+ vfr));
+ }
+
+ extern "C" __declspec(dllexport) const char* __stdcall AvisynthPluginInit2(IScriptEnvironment* env)
+ {
+ env->AddFunction("VobSub", "cs", VobSubCreateS, 0);
#ifdef _VSMOD
- env->AddFunction("TextSubMod", "c[file]s[charset]i[fps]f[vfr]s", TextSubCreateGeneral, 0);
- env->AddFunction("TextSubModSwapUV", "b", TextSubSwapUV, 0);
- env->AddFunction("MaskSubMod", "[file]s[width]i[height]i[fps]f[length]i[charset]i[vfr]s", MaskSubCreate, 0);
+ env->AddFunction("TextSubMod", "c[file]s[charset]i[fps]f[vfr]s", TextSubCreateGeneral, 0);
+ env->AddFunction("TextSubModSwapUV", "b", TextSubSwapUV, 0);
+ env->AddFunction("MaskSubMod", "[file]s[width]i[height]i[fps]f[length]i[charset]i[vfr]s", MaskSubCreate, 0);
#else
- 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->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);
#endif
- env->SetVar(env->SaveString("RGBA"),false);
- return(NULL);
-}
-}
+ 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:
- {
+ case WM_INITDIALOG: {
#ifdef WIN64
- SetWindowLongPtr(hDlg, GWLP_USERDATA, lParam);
+ SetWindowLongPtr(hDlg, GWLP_USERDATA, lParam);
#else
- SetWindowLongPtr(hDlg, GWL_USERDATA, lParam);
+ SetWindowLongPtr(hDlg, GWL_USERDATA, lParam);
#endif
- 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, (LONG)(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, (LONG)(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;
diff --git a/src/filters/transform/VSFilter/vfr.cpp b/src/filters/transform/VSFilter/vfr.cpp
index bb56a6126..0c0eb36a5 100644
--- a/src/filters/transform/VSFilter/vfr.cpp
+++ b/src/filters/transform/VSFilter/vfr.cpp
@@ -32,7 +32,8 @@
// Work with seconds per frame (spf) here instead of fps since that's more natural for the translation we're doing
-class TimecodesV1 : public VFRTranslator {
+class TimecodesV1 : public VFRTranslator
+{
private:
// Used when sections run out
double default_spf;
@@ -50,8 +51,7 @@ private:
std::vector<FrameRateSection> sections;
public:
- virtual double TimeStampFromFrameNumber(int n)
- {
+ virtual double TimeStampFromFrameNumber(int n) {
// Find correct section
for (size_t i = 0; i < sections.size(); i++) {
FrameRateSection &sect = sections[i];
@@ -60,12 +60,13 @@ public:
}
}
// Not in a section
- if (n < 0) return 0.0;
+ if (n < 0) {
+ return 0.0;
+ }
return first_non_section_timestamp + (n - first_non_section_frame) * default_spf;
}
- TimecodesV1(FILE *vfrfile)
- {
+ TimecodesV1(FILE *vfrfile) {
char buf[100];
default_spf = -1;
@@ -79,15 +80,18 @@ public:
while (fgets(buf, 100, vfrfile)) {
// Comment?
- if (buf[0] == '#') continue;
+ 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)
+ if (default_spf > 0) {
default_spf = 1 / default_spf;
- else
+ } else {
default_spf = -1;
+ }
temp_section.spf = default_spf;
continue;
}
@@ -123,7 +127,8 @@ public:
};
-class TimecodesV2 : public VFRTranslator {
+class TimecodesV2 : public VFRTranslator
+{
private:
// Main data
std::vector<double> timestamps;
@@ -133,24 +138,26 @@ private:
double assumed_spf;
public:
- virtual double TimeStampFromFrameNumber(int n)
- {
+ virtual double TimeStampFromFrameNumber(int n) {
if (n < (int)timestamps.size() && n >= 0) {
return timestamps[n];
}
- if (n < 0) return 0.0;
+ if (n < 0) {
+ return 0.0;
+ }
return last_known_timestamp + (n - last_known_frame) * assumed_spf;
}
- TimecodesV2(FILE *vfrfile)
- {
+ 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;
+ if (buf[0] == '#') {
+ continue;
+ }
// Otherwise assume it's a good timestamp
timestamps.push_back(atof(buf)/1000);
}
diff --git a/src/filters/transform/VSFilter/vfr.h b/src/filters/transform/VSFilter/vfr.h
index a4aafffd4..837577b6e 100644
--- a/src/filters/transform/VSFilter/vfr.h
+++ b/src/filters/transform/VSFilter/vfr.h
@@ -26,7 +26,8 @@
#ifndef VFR_H
#define VFR_H
-class VFRTranslator {
+class VFRTranslator
+{
public:
virtual double TimeStampFromFrameNumber(int n) = 0;
};
diff --git a/src/thirdparty/MediaInfo/MediaInfoLib.vcproj b/src/thirdparty/MediaInfo/MediaInfoLib.vcproj
index cf36f5a04..2d37c35e5 100644
--- a/src/thirdparty/MediaInfo/MediaInfoLib.vcproj
+++ b/src/thirdparty/MediaInfo/MediaInfoLib.vcproj
@@ -46,7 +46,7 @@
AdditionalIncludeDirectories=".;Source;../ZenLib;../zlib"
AdditionalUsingDirectories=""
PreprocessorDefinitions="WIN32;_DEBUG;MEDIAINFO_TRACE_NO;MEDIAINFO_LIBCURL_NO;MEDIAINFO_LIBMMS_NO;CURL_STATICLIB; MEDIAINFO_N19_NO; MEDIAINFO_OTHERTEXT_NO; MEDIAINFO_IMAGE_NO; MEDIAINFO_ARCHIVE_NO; MEDIAINFO_EVENTS_NO; MEDIAINFO_DEMUX_NO; MEDIAINFO_MPEGTS_DUPLICATE_NO; MEDIAINFO_DVDIF_ANALYZE_NO"
- DisableSpecificWarnings="4065;4244;4390"
+ DisableSpecificWarnings="4065;4244;4309"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@@ -105,7 +105,7 @@
AdditionalUsingDirectories=""
PreprocessorDefinitions="WIN32;_DEBUG;MEDIAINFO_TRACE_NO;MEDIAINFO_LIBCURL_NO;MEDIAINFO_LIBMMS_NO;CURL_STATICLIB; MEDIAINFO_N19_NO; MEDIAINFO_OTHERTEXT_NO; MEDIAINFO_IMAGE_NO; MEDIAINFO_ARCHIVE_NO; MEDIAINFO_EVENTS_NO; MEDIAINFO_DEMUX_NO; MEDIAINFO_MPEGTS_DUPLICATE_NO; MEDIAINFO_DVDIF_ANALYZE_NO"
DebugInformationFormat="3"
- DisableSpecificWarnings="4065;4244;4267;4390"
+ DisableSpecificWarnings="4065;4244;4267;4309"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@@ -164,7 +164,7 @@
AdditionalIncludeDirectories=".;Source;../ZenLib;../zlib"
AdditionalUsingDirectories=""
PreprocessorDefinitions="WIN32;NDEBUG;MEDIAINFO_TRACE_NO;MEDIAINFO_LIBCURL_NO;MEDIAINFO_LIBMMS_NO;CURL_STATICLIB; MEDIAINFO_N19_NO; MEDIAINFO_OTHERTEXT_NO; MEDIAINFO_IMAGE_NO; MEDIAINFO_ARCHIVE_NO; MEDIAINFO_EVENTS_NO; MEDIAINFO_DEMUX_NO; MEDIAINFO_MPEGTS_DUPLICATE_NO; MEDIAINFO_DVDIF_ANALYZE_NO"
- DisableSpecificWarnings="4065;4244;4390"
+ DisableSpecificWarnings="4065;4244;4309"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@@ -226,7 +226,7 @@
AdditionalUsingDirectories=""
PreprocessorDefinitions="WIN32;NDEBUG;MEDIAINFO_TRACE_NO;MEDIAINFO_LIBCURL_NO;MEDIAINFO_LIBMMS_NO;CURL_STATICLIB; MEDIAINFO_N19_NO; MEDIAINFO_OTHERTEXT_NO; MEDIAINFO_IMAGE_NO; MEDIAINFO_ARCHIVE_NO; MEDIAINFO_EVENTS_NO; MEDIAINFO_DEMUX_NO; MEDIAINFO_MPEGTS_DUPLICATE_NO; MEDIAINFO_DVDIF_ANALYZE_NO"
EnableEnhancedInstructionSet="0"
- DisableSpecificWarnings="4065;4244;4267;4390"
+ DisableSpecificWarnings="4065;4244;4267;4309"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@@ -446,6 +446,10 @@
>
</File>
<File
+ RelativePath=".\MediaInfo\Audio\File_Celt.cpp"
+ >
+ </File>
+ <File
RelativePath=".\MediaInfo\Audio\File_DolbyE.cpp"
>
</File>
@@ -1100,6 +1104,10 @@
>
</File>
<File
+ RelativePath=".\MediaInfo\Audio\File_Celt.h"
+ >
+ </File>
+ <File
RelativePath=".\MediaInfo\Audio\File_DolbyE.h"
>
</File>
@@ -1513,12 +1521,6 @@
</File>
</Filter>
</Filter>
- <Filter
- Name="Resource Files"
- Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
- UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
- >
- </Filter>
</Files>
<Globals>
</Globals>
diff --git a/src/thirdparty/MediaInfo/MediaInfoLib.vcxproj b/src/thirdparty/MediaInfo/MediaInfoLib.vcxproj
index 6989662ff..a25948128 100644
--- a/src/thirdparty/MediaInfo/MediaInfoLib.vcxproj
+++ b/src/thirdparty/MediaInfo/MediaInfoLib.vcxproj
@@ -40,6 +40,7 @@
<ClInclude Include="MediaInfo\Audio\File_Amv.h" />
<ClInclude Include="MediaInfo\Audio\File_Ape.h" />
<ClInclude Include="MediaInfo\Audio\File_Au.h" />
+ <ClInclude Include="MediaInfo\Audio\File_Celt.h" />
<ClInclude Include="MediaInfo\Audio\File_DolbyE.h" />
<ClInclude Include="MediaInfo\Audio\File_Dts.h" />
<ClInclude Include="MediaInfo\Audio\File_ExtendedModule.h" />
@@ -148,7 +149,6 @@
<ClInclude Include="MediaInfo\Text\File_OtherText.h" />
<ClInclude Include="MediaInfo\Text\File_Pgs.h" />
<ClInclude Include="MediaInfo\Text\File_Scte20.h" />
- <ClInclude Include="MediaInfo\Video\File_Afd.h" />
<ClInclude Include="MediaInfo\Video\File_AfdBarData.h" />
<ClInclude Include="MediaInfo\Video\File_Avc.h" />
<ClInclude Include="MediaInfo\Video\File_AvsV.h" />
@@ -186,6 +186,7 @@
<ClCompile Include="MediaInfo\Audio\File_Amv.cpp" />
<ClCompile Include="MediaInfo\Audio\File_Ape.cpp" />
<ClCompile Include="MediaInfo\Audio\File_Au.cpp" />
+ <ClCompile Include="MediaInfo\Audio\File_Celt.cpp" />
<ClCompile Include="MediaInfo\Audio\File_DolbyE.cpp" />
<ClCompile Include="MediaInfo\Audio\File_Dts.cpp" />
<ClCompile Include="MediaInfo\Audio\File_ExtendedModule.cpp" />
@@ -296,7 +297,6 @@
<ClCompile Include="MediaInfo\Text\File_OtherText.cpp" />
<ClCompile Include="MediaInfo\Text\File_Pgs.cpp" />
<ClCompile Include="MediaInfo\Text\File_Scte20.cpp" />
- <ClCompile Include="MediaInfo\Video\File_Afd.cpp" />
<ClCompile Include="MediaInfo\Video\File_AfdBarData.cpp" />
<ClCompile Include="MediaInfo\Video\File_Avc.cpp" />
<ClCompile Include="MediaInfo\Video\File_Avc_Duplicate.cpp" />
@@ -382,7 +382,7 @@
<AdditionalUsingDirectories>%(AdditionalUsingDirectories)</AdditionalUsingDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;MEDIAINFO_TRACE_NO;MEDIAINFO_LIBCURL_NO;MEDIAINFO_LIBMMS_NO;CURL_STATICLIB; MEDIAINFO_N19_NO; MEDIAINFO_OTHERTEXT_NO; MEDIAINFO_IMAGE_NO; MEDIAINFO_ARCHIVE_NO; MEDIAINFO_EVENTS_NO; MEDIAINFO_DEMUX_NO; MEDIAINFO_MPEGTS_DUPLICATE_NO; MEDIAINFO_DVDIF_ANALYZE_NO;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
- <DisableSpecificWarnings>4065;4244;4390;%(DisableSpecificWarnings)</DisableSpecificWarnings>
+ <DisableSpecificWarnings>4065;4244;4309;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Lib>
<TargetMachine>MachineX86</TargetMachine>
@@ -397,7 +397,7 @@
<AdditionalUsingDirectories>%(AdditionalUsingDirectories)</AdditionalUsingDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;MEDIAINFO_TRACE_NO;MEDIAINFO_LIBCURL_NO;MEDIAINFO_LIBMMS_NO;CURL_STATICLIB; MEDIAINFO_N19_NO; MEDIAINFO_OTHERTEXT_NO; MEDIAINFO_IMAGE_NO; MEDIAINFO_ARCHIVE_NO; MEDIAINFO_EVENTS_NO; MEDIAINFO_DEMUX_NO; MEDIAINFO_MPEGTS_DUPLICATE_NO; MEDIAINFO_DVDIF_ANALYZE_NO;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
- <DisableSpecificWarnings>4065;4244;4267;4390;%(DisableSpecificWarnings)</DisableSpecificWarnings>
+ <DisableSpecificWarnings>4065;4244;4267;4309;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<EnablePREfast>false</EnablePREfast>
</ClCompile>
<Lib>
@@ -410,7 +410,7 @@
<AdditionalUsingDirectories>%(AdditionalUsingDirectories)</AdditionalUsingDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;MEDIAINFO_TRACE_NO;MEDIAINFO_LIBCURL_NO;MEDIAINFO_LIBMMS_NO;CURL_STATICLIB; MEDIAINFO_N19_NO; MEDIAINFO_OTHERTEXT_NO; MEDIAINFO_IMAGE_NO; MEDIAINFO_ARCHIVE_NO; MEDIAINFO_EVENTS_NO; MEDIAINFO_DEMUX_NO; MEDIAINFO_MPEGTS_DUPLICATE_NO; MEDIAINFO_DVDIF_ANALYZE_NO;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
- <DisableSpecificWarnings>4065;4244;4390;%(DisableSpecificWarnings)</DisableSpecificWarnings>
+ <DisableSpecificWarnings>4065;4244;4309;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<Optimization>MinSpace</Optimization>
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
</ClCompile>
@@ -428,7 +428,7 @@
<AdditionalUsingDirectories>%(AdditionalUsingDirectories)</AdditionalUsingDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;MEDIAINFO_TRACE_NO;MEDIAINFO_LIBCURL_NO;MEDIAINFO_LIBMMS_NO;CURL_STATICLIB; MEDIAINFO_N19_NO; MEDIAINFO_OTHERTEXT_NO; MEDIAINFO_IMAGE_NO; MEDIAINFO_ARCHIVE_NO; MEDIAINFO_EVENTS_NO; MEDIAINFO_DEMUX_NO; MEDIAINFO_MPEGTS_DUPLICATE_NO; MEDIAINFO_DVDIF_ANALYZE_NO;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
- <DisableSpecificWarnings>4065;4244;4267;4390;%(DisableSpecificWarnings)</DisableSpecificWarnings>
+ <DisableSpecificWarnings>4065;4244;4267;4309;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<Optimization>MinSpace</Optimization>
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
</ClCompile>
diff --git a/src/thirdparty/MediaInfo/MediaInfoLib.vcxproj.filters b/src/thirdparty/MediaInfo/MediaInfoLib.vcxproj.filters
index 52d74defa..4b424c63c 100644
--- a/src/thirdparty/MediaInfo/MediaInfoLib.vcxproj.filters
+++ b/src/thirdparty/MediaInfo/MediaInfoLib.vcxproj.filters
@@ -362,9 +362,6 @@
<ClInclude Include="MediaInfo\Text\File_Scte20.h">
<Filter>Header Files\Text</Filter>
</ClInclude>
- <ClInclude Include="MediaInfo\Video\File_Afd.h">
- <Filter>Header Files\Video</Filter>
- </ClInclude>
<ClInclude Include="MediaInfo\Video\File_AfdBarData.h">
<Filter>Header Files\Video</Filter>
</ClInclude>
@@ -437,6 +434,9 @@
<ClInclude Include="MediaInfo\Audio\File_Au.h">
<Filter>Header Files\Audio</Filter>
</ClInclude>
+ <ClInclude Include="MediaInfo\Audio\File_Celt.h">
+ <Filter>Header Files\Audio</Filter>
+ </ClInclude>
<ClInclude Include="MediaInfo\Audio\File_DolbyE.h">
<Filter>Header Files\Audio</Filter>
</ClInclude>
@@ -733,9 +733,6 @@
<ClCompile Include="MediaInfo\Export\Export_PBCore.cpp">
<Filter>Source Files\Export</Filter>
</ClCompile>
- <ClCompile Include="MediaInfo\Video\File_Afd.cpp">
- <Filter>Source Files\Video</Filter>
- </ClCompile>
<ClCompile Include="MediaInfo\Video\File_AfdBarData.cpp">
<Filter>Source Files\Video</Filter>
</ClCompile>
@@ -880,6 +877,9 @@
<ClCompile Include="MediaInfo\Audio\File_Au.cpp">
<Filter>Source Files\Audio</Filter>
</ClCompile>
+ <ClCompile Include="MediaInfo\Audio\File_Celt.cpp">
+ <Filter>Source Files\Audio</Filter>
+ </ClCompile>
<ClCompile Include="MediaInfo\Audio\File_DolbyE.cpp">
<Filter>Source Files\Audio</Filter>
</ClCompile>
diff --git a/src/thirdparty/lcms2/src/cmsintrp.c b/src/thirdparty/lcms2/src/cmsintrp.c
index 6e2ba47a3..a2a5f2209 100644
--- a/src/thirdparty/lcms2/src/cmsintrp.c
+++ b/src/thirdparty/lcms2/src/cmsintrp.c
@@ -1207,7 +1207,7 @@ void Eval7Inputs(register const cmsUInt16Number Input[],
K1 = p16 -> opta[6] * (k0 + (Input[0] != 0xFFFFU ? 1 : 0));
p1 = *p16;
- memmove(&p1.Domain[0], &p16 ->Domain[1], 5*sizeof(cmsUInt32Number));
+ memmove(&p1.Domain[0], &p16 ->Domain[1], 6*sizeof(cmsUInt32Number));
T = LutTable + K0;
p1.Table = T;