Cocoa Port:

- The OpenGL 3D renderer now respects the "Rendering Threads" setting.
- Display output now auto-configures whether to run video filters in single-threaded or multi-threaded mode.
- Video filters now run much better in single-threaded mode.
- Do a lot of very heavy cleanup of the video filter code.
- Fixed bug in the UI where the HQ4xS option didn't work correctly in the user preferences.
This commit is contained in:
rogerman 2012-12-29 02:15:58 +00:00
parent 06cd0ef7f9
commit a62168ccff
6 changed files with 220 additions and 648 deletions

View File

@ -931,6 +931,10 @@ GPU3DInterface *core3DList[] = {
{
NDS_3D_ChangeCore(CORE3DLIST_SWRASTERIZE);
}
else if ([self render3DRenderingEngine] == CORE3DLIST_OPENGL)
{
NDS_3D_ChangeCore(CORE3DLIST_OPENGL);
}
pthread_mutex_unlock(self.mutexProducer);
}
@ -1384,7 +1388,14 @@ GPU3DInterface *core3DList[] = {
spinlockVideoFilterType = OS_SPINLOCK_INIT;
spinlockVfSrcBuffer = OS_SPINLOCK_INIT;
vf = [[CocoaVideoFilter alloc] initWithSize:frameSize typeID:VideoFilterTypeID_None numberThreads:2];
if ([[NSProcessInfo processInfo] activeProcessorCount] >= 2)
{
vf = [[CocoaVideoFilter alloc] initWithSize:frameSize typeID:VideoFilterTypeID_None numberThreads:2];
}
else
{
vf = [[CocoaVideoFilter alloc] initWithSize:frameSize typeID:VideoFilterTypeID_None numberThreads:0];
}
[property setValue:[NSNumber numberWithInteger:(NSInteger)VideoFilterTypeID_None] forKey:@"videoFilterType"];
[property setValue:[CocoaVideoFilter typeStringByID:VideoFilterTypeID_None] forKey:@"videoFilterTypeString"];

View File

@ -24,17 +24,17 @@
- (id)init
{
return [self initWithSize:NSMakeSize(1, 1) typeID:VideoFilterTypeID_None numberThreads:1];
return [self initWithSize:NSMakeSize(1, 1) typeID:VideoFilterTypeID_None numberThreads:0];
}
- (id) initWithSize:(NSSize)theSize
{
return [self initWithSize:theSize typeID:VideoFilterTypeID_None numberThreads:1];
return [self initWithSize:theSize typeID:VideoFilterTypeID_None numberThreads:0];
}
- (id) initWithSize:(NSSize)theSize typeID:(VideoFilterTypeID)typeID
{
return [self initWithSize:theSize typeID:typeID numberThreads:1];
return [self initWithSize:theSize typeID:typeID numberThreads:0];
}
- (id) initWithSize:(NSSize)theSize typeID:(VideoFilterTypeID)typeID numberThreads:(NSUInteger)numThreads

View File

@ -13,6 +13,7 @@
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="29"/>
<integer value="1584"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@ -7047,7 +7048,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<int key="NSvFlags">12</int>
<string key="NSFrame">{{13, 10}, {463, 401}}</string>
<reference key="NSSuperview" ref="373257179"/>
<reference key="NSWindow"/>
<object class="NSMutableArray" key="NSTabViewItems">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSTabViewItem" id="750316744">
@ -7072,7 +7072,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{72, 44}, {84, 17}}</string>
<reference key="NSSuperview" ref="610612997"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="1051872315">
<int key="NSCellFlags">68288064</int>
@ -7089,7 +7088,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{44, 16}, {112, 17}}</string>
<reference key="NSSuperview" ref="610612997"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="279286359">
<int key="NSCellFlags">68288064</int>
@ -7106,7 +7104,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{158, 38}, {126, 26}}</string>
<reference key="NSSuperview" ref="610612997"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSPopUpButtonCell" key="NSCell" id="644484329">
<int key="NSCellFlags">-2076049856</int>
@ -7187,7 +7184,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{289, 14}, {96, 22}}</string>
<reference key="NSSuperview" ref="610612997"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="689714106">
<int key="NSCellFlags">-1804468671</int>
@ -7265,7 +7261,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{63, 72}, {93, 17}}</string>
<reference key="NSSuperview" ref="610612997"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="86457779">
<int key="NSCellFlags">68288064</int>
@ -7282,7 +7277,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{158, 66}, {126, 26}}</string>
<reference key="NSSuperview" ref="610612997"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSPopUpButtonCell" key="NSCell" id="977881385">
<int key="NSCellFlags">-2076049856</int>
@ -7350,7 +7344,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{158, 11}, {126, 26}}</string>
<reference key="NSSuperview" ref="610612997"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSPopUpButtonCell" key="NSCell" id="729105354">
<int key="NSCellFlags">-2076049856</int>
@ -7452,12 +7445,10 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
</object>
<string key="NSFrame">{{1, 1}, {429, 100}}</string>
<reference key="NSSuperview" ref="654619277"/>
<reference key="NSWindow"/>
</object>
</object>
<string key="NSFrame">{{6, 187}, {431, 116}}</string>
<reference key="NSSuperview" ref="698863500"/>
<reference key="NSWindow"/>
<string key="NSOffsets">{0, 0}</string>
<object class="NSTextFieldCell" key="NSTitleCell">
<int key="NSCellFlags">67239424</int>
@ -7501,7 +7492,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{18, 14}, {100, 38}}</string>
<reference key="NSSuperview" ref="713770080"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<int key="NSNumRows">2</int>
<int key="NSNumCols">1</int>
@ -7692,12 +7682,10 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
</object>
<string key="NSFrame">{{1, 1}, {194, 62}}</string>
<reference key="NSSuperview" ref="405894970"/>
<reference key="NSWindow"/>
</object>
</object>
<string key="NSFrame">{{15, 10}, {196, 78}}</string>
<reference key="NSSuperview" ref="320484480"/>
<reference key="NSWindow"/>
<string key="NSOffsets">{0, 0}</string>
<object class="NSTextFieldCell" key="NSTitleCell">
<int key="NSCellFlags">67239424</int>
@ -7731,7 +7719,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{18, 14}, {150, 38}}</string>
<reference key="NSSuperview" ref="533349872"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<int key="NSNumRows">2</int>
<int key="NSNumCols">1</int>
@ -7922,12 +7909,10 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
</object>
<string key="NSFrame">{{1, 1}, {194, 62}}</string>
<reference key="NSSuperview" ref="1057767226"/>
<reference key="NSWindow"/>
</object>
</object>
<string key="NSFrame">{{218, 10}, {196, 78}}</string>
<reference key="NSSuperview" ref="320484480"/>
<reference key="NSWindow"/>
<string key="NSOffsets">{0, 0}</string>
<object class="NSTextFieldCell" key="NSTitleCell">
<int key="NSCellFlags">67239424</int>
@ -7949,12 +7934,10 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
</object>
<string key="NSFrame">{{1, 1}, {429, 98}}</string>
<reference key="NSSuperview" ref="367271593"/>
<reference key="NSWindow"/>
</object>
</object>
<string key="NSFrame">{{6, 69}, {431, 114}}</string>
<reference key="NSSuperview" ref="698863500"/>
<reference key="NSWindow"/>
<string key="NSOffsets">{0, 0}</string>
<object class="NSTextFieldCell" key="NSTitleCell">
<int key="NSCellFlags">67239424</int>
@ -7976,7 +7959,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
</object>
<string key="NSFrame">{{10, 33}, {443, 355}}</string>
<reference key="NSSuperview" ref="286093627"/>
<reference key="NSWindow"/>
</object>
<string key="NSLabel">Display Views</string>
<reference key="NSColor" ref="266180242"/>
@ -8614,16 +8596,16 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<string key="NSKeyEquivalent"/>
<int key="NSPeriodicDelay">400</int>
<int key="NSPeriodicInterval">75</int>
<object class="NSMenuItem" key="NSMenuItem" id="621082995">
<object class="NSMenuItem" key="NSMenuItem" id="823815537">
<reference key="NSMenu" ref="55340633"/>
<string key="NSTitle">OpenGL</string>
<string key="NSTitle">SoftRasterizer</string>
<string key="NSKeyEquiv"/>
<int key="NSMnemonicLoc">2147483647</int>
<int key="NSState">1</int>
<reference key="NSOnImage" ref="396634170"/>
<reference key="NSMixedImage" ref="678976864"/>
<string key="NSAction">_popUpItemAction:</string>
<int key="NSTag">2</int>
<int key="NSTag">1</int>
<reference key="NSTarget" ref="458352299"/>
</object>
<bool key="NSMenuItemRespectAlignment">YES</bool>
@ -8641,22 +8623,22 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<string key="NSAction">_popUpItemAction:</string>
<reference key="NSTarget" ref="458352299"/>
</object>
<object class="NSMenuItem" id="823815537">
<reference ref="823815537"/>
<object class="NSMenuItem" id="621082995">
<reference key="NSMenu" ref="55340633"/>
<string key="NSTitle">SoftRasterizer</string>
<string key="NSTitle">OpenGL</string>
<string key="NSKeyEquiv"/>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="396634170"/>
<reference key="NSMixedImage" ref="678976864"/>
<string key="NSAction">_popUpItemAction:</string>
<int key="NSTag">1</int>
<int key="NSTag">2</int>
<reference key="NSTarget" ref="458352299"/>
</object>
<reference ref="621082995"/>
</object>
<reference key="NSMenuFont" ref="462791774"/>
</object>
<int key="NSSelectedIndex">2</int>
<int key="NSSelectedIndex">1</int>
<int key="NSPreferredEdge">1</int>
<bool key="NSUsesItemFromMenu">YES</bool>
<bool key="NSAltersState">YES</bool>
@ -8682,7 +8664,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<object class="NSPopUpButton" id="515405915">
<reference key="NSNextResponder" ref="926005793"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{250, 34}, {165, 26}}</string>
<string key="NSFrame">{{205, 34}, {165, 26}}</string>
<reference key="NSSuperview" ref="926005793"/>
<bool key="NSEnabled">YES</bool>
<object class="NSPopUpButtonCell" key="NSCell" id="770553605">
@ -8761,13 +8743,13 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<object class="NSTextField" id="30639279">
<reference key="NSNextResponder" ref="926005793"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{28, 40}, {220, 17}}</string>
<string key="NSFrame">{{47, 40}, {156, 17}}</string>
<reference key="NSSuperview" ref="926005793"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="690717945">
<int key="NSCellFlags">68288064</int>
<int key="NSCellFlags2">272630784</int>
<string key="NSContents">SoftRasterizer Rendering Threads:</string>
<int key="NSCellFlags2">71304192</int>
<string key="NSContents">Rendering Threads:</string>
<reference key="NSSupport" ref="462791774"/>
<reference key="NSControlView" ref="30639279"/>
<reference key="NSBackgroundColor" ref="266180242"/>
@ -8874,7 +8856,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
</object>
<string key="NSFrameSize">{489, 425}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<string key="NSClassName">NSView</string>
</object>
<object class="NSCustomView" id="704316683">
@ -9718,7 +9699,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<string key="NSClassName">NSView</string>
</object>
<object class="NSCustomView" id="748902585">
<nil key="NSNextResponder"/>
<reference key="NSNextResponder"/>
<int key="NSvFlags">268</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
@ -9737,6 +9718,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{18, 14}, {165, 38}}</string>
<reference key="NSSuperview" ref="16233"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<int key="NSNumRows">2</int>
<int key="NSNumCols">1</int>
@ -9927,10 +9909,12 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
</object>
<string key="NSFrame">{{1, 1}, {494, 62}}</string>
<reference key="NSSuperview" ref="1034534989"/>
<reference key="NSWindow"/>
</object>
</object>
<string key="NSFrame">{{17, 454}, {496, 78}}</string>
<reference key="NSSuperview" ref="748902585"/>
<reference key="NSWindow"/>
<string key="NSOffsets">{0, 0}</string>
<object class="NSTextFieldCell" key="NSTitleCell">
<int key="NSCellFlags">67239424</int>
@ -9964,6 +9948,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{16, 12}, {462, 18}}</string>
<reference key="NSSuperview" ref="675831467"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="830122320">
<int key="NSCellFlags">-2080244224</int>
@ -9984,10 +9969,12 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
</object>
<string key="NSFrame">{{1, 1}, {494, 38}}</string>
<reference key="NSSuperview" ref="808054783"/>
<reference key="NSWindow"/>
</object>
</object>
<string key="NSFrame">{{17, 16}, {496, 54}}</string>
<reference key="NSSuperview" ref="748902585"/>
<reference key="NSWindow"/>
<string key="NSOffsets">{0, 0}</string>
<object class="NSTextFieldCell" key="NSTitleCell">
<int key="NSCellFlags">67239424</int>
@ -10021,6 +10008,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{16, 32}, {145, 18}}</string>
<reference key="NSSuperview" ref="808083999"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="340220192">
<int key="NSCellFlags">67239424</int>
@ -10043,6 +10031,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{16, 12}, {118, 18}}</string>
<reference key="NSSuperview" ref="808083999"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="16571944">
<int key="NSCellFlags">67239424</int>
@ -10063,10 +10052,12 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
</object>
<string key="NSFrame">{{1, 1}, {494, 58}}</string>
<reference key="NSSuperview" ref="337932383"/>
<reference key="NSWindow"/>
</object>
</object>
<string key="NSFrame">{{17, 74}, {496, 74}}</string>
<reference key="NSSuperview" ref="748902585"/>
<reference key="NSWindow"/>
<string key="NSOffsets">{0, 0}</string>
<object class="NSTextFieldCell" key="NSTitleCell">
<int key="NSCellFlags">67239424</int>
@ -10100,6 +10091,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{16, 61}, {205, 18}}</string>
<reference key="NSSuperview" ref="400774933"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="337267081">
<int key="NSCellFlags">604110336</int>
@ -10122,6 +10114,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{140, 33}, {240, 22}}</string>
<reference key="NSSuperview" ref="400774933"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="764651405">
<int key="NSCellFlags">-2070806976</int>
@ -10140,6 +10133,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{15, 37}, {120, 17}}</string>
<reference key="NSSuperview" ref="400774933"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="1028152583">
<int key="NSCellFlags">68288064</int>
@ -10156,6 +10150,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{382, 27}, {100, 32}}</string>
<reference key="NSSuperview" ref="400774933"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="820292401">
<int key="NSCellFlags">67239424</int>
@ -10176,6 +10171,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{16, 12}, {149, 18}}</string>
<reference key="NSSuperview" ref="400774933"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="975896369">
<int key="NSCellFlags">604110336</int>
@ -10198,6 +10194,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{12, 81}, {229, 32}}</string>
<reference key="NSSuperview" ref="400774933"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="1052182945">
<int key="NSCellFlags">67239424</int>
@ -10216,10 +10213,12 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
</object>
<string key="NSFrame">{{1, 1}, {494, 119}}</string>
<reference key="NSSuperview" ref="269747406"/>
<reference key="NSWindow"/>
</object>
</object>
<string key="NSFrame">{{17, 152}, {496, 135}}</string>
<reference key="NSSuperview" ref="748902585"/>
<reference key="NSWindow"/>
<string key="NSOffsets">{0, 0}</string>
<object class="NSTextFieldCell" key="NSTitleCell">
<int key="NSCellFlags">67239424</int>
@ -10253,6 +10252,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{16, 117}, {182, 18}}</string>
<reference key="NSSuperview" ref="583474551"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="469931880">
<int key="NSCellFlags">67239424</int>
@ -10275,6 +10275,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{140, 86}, {240, 22}}</string>
<reference key="NSSuperview" ref="583474551"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="173370867">
<int key="NSCellFlags">-2070806976</int>
@ -10293,6 +10294,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{15, 89}, {120, 17}}</string>
<reference key="NSSuperview" ref="583474551"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="553485788">
<int key="NSCellFlags">68288064</int>
@ -10309,6 +10311,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{382, 80}, {100, 32}}</string>
<reference key="NSSuperview" ref="583474551"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="1066457191">
<int key="NSCellFlags">67239424</int>
@ -10329,6 +10332,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{140, 59}, {240, 22}}</string>
<reference key="NSSuperview" ref="583474551"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="910485558">
<int key="NSCellFlags">-2070806976</int>
@ -10347,6 +10351,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{15, 62}, {120, 17}}</string>
<reference key="NSSuperview" ref="583474551"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="1063888642">
<int key="NSCellFlags">68288064</int>
@ -10363,6 +10368,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{382, 53}, {100, 32}}</string>
<reference key="NSSuperview" ref="583474551"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="582159211">
<int key="NSCellFlags">67239424</int>
@ -10383,6 +10389,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{16, 32}, {230, 18}}</string>
<reference key="NSSuperview" ref="583474551"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="850204688">
<int key="NSCellFlags">-1543373312</int>
@ -10405,6 +10412,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{16, 12}, {236, 18}}</string>
<reference key="NSSuperview" ref="583474551"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="573619370">
<int key="NSCellFlags">604110336</int>
@ -10425,10 +10433,12 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
</object>
<string key="NSFrame">{{1, 1}, {494, 143}}</string>
<reference key="NSSuperview" ref="1013462952"/>
<reference key="NSWindow"/>
</object>
</object>
<string key="NSFrame">{{17, 291}, {496, 159}}</string>
<reference key="NSSuperview" ref="748902585"/>
<reference key="NSWindow"/>
<string key="NSOffsets">{0, 0}</string>
<object class="NSTextFieldCell" key="NSTitleCell">
<int key="NSCellFlags">67239424</int>
@ -10462,6 +10472,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{16, 12}, {197, 18}}</string>
<reference key="NSSuperview" ref="330186328"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="152711854">
<int key="NSCellFlags">-2080244224</int>
@ -10482,10 +10493,12 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
</object>
<string key="NSFrame">{{1, 1}, {494, 38}}</string>
<reference key="NSSuperview" ref="699930286"/>
<reference key="NSWindow"/>
</object>
</object>
<string key="NSFrame">{{17, 536}, {496, 54}}</string>
<reference key="NSSuperview" ref="748902585"/>
<reference key="NSWindow"/>
<string key="NSOffsets">{0, 0}</string>
<object class="NSTextFieldCell" key="NSTitleCell">
<int key="NSCellFlags">67239424</int>
@ -10506,6 +10519,8 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
</object>
</object>
<string key="NSFrameSize">{530, 610}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<string key="NSClassName">NSView</string>
</object>
<object class="NSCustomObject" id="660705428">
@ -16068,7 +16083,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<nil key="NSViewClass"/>
<string key="NSWindowContentMaxSize">{1.79769e+308, 1.79769e+308}</string>
<object class="NSView" key="NSWindowView" id="729561310">
<nil key="NSNextResponder"/>
<reference key="NSNextResponder"/>
<int key="NSvFlags">256</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
@ -16087,6 +16102,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{15, 77}, {206, 18}}</string>
<reference key="NSSuperview" ref="372893695"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="715693022">
<int key="NSCellFlags">-2080244224</int>
@ -16109,6 +16125,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{15, 57}, {134, 18}}</string>
<reference key="NSSuperview" ref="372893695"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="874032897">
<int key="NSCellFlags">-2080244224</int>
@ -16131,6 +16148,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{15, 37}, {80, 18}}</string>
<reference key="NSSuperview" ref="372893695"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="67001337">
<int key="NSCellFlags">-2080244224</int>
@ -16153,6 +16171,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{185, 12}, {45, 19}}</string>
<reference key="NSSuperview" ref="372893695"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="424545719">
<int key="NSCellFlags">-1804468671</int>
@ -16233,6 +16252,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{15, 14}, {165, 14}}</string>
<reference key="NSSuperview" ref="372893695"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="714807735">
<int key="NSCellFlags">68288064</int>
@ -16247,10 +16267,12 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
</object>
<string key="NSFrame">{{1, 1}, {248, 103}}</string>
<reference key="NSSuperview" ref="219189503"/>
<reference key="NSWindow"/>
</object>
</object>
<string key="NSFrame">{{17, 163}, {250, 119}}</string>
<reference key="NSSuperview" ref="729561310"/>
<reference key="NSWindow"/>
<string key="NSOffsets">{0, 0}</string>
<object class="NSTextFieldCell" key="NSTitleCell">
<int key="NSCellFlags">67239424</int>
@ -16274,6 +16296,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{65, 18}, {154, 19}}</string>
<reference key="NSSuperview" ref="729561310"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="837427736">
<int key="NSCellFlags">-2080244224</int>
@ -16304,6 +16327,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{18, 14}, {107, 58}}</string>
<reference key="NSSuperview" ref="909175549"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<int key="NSNumRows">3</int>
<int key="NSNumCols">1</int>
@ -16508,10 +16532,12 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
</object>
<string key="NSFrame">{{1, 1}, {248, 82}}</string>
<reference key="NSSuperview" ref="299127137"/>
<reference key="NSWindow"/>
</object>
</object>
<string key="NSFrame">{{17, 364}, {250, 98}}</string>
<reference key="NSSuperview" ref="729561310"/>
<reference key="NSWindow"/>
<string key="NSOffsets">{0, 0}</string>
<object class="NSTextFieldCell" key="NSTitleCell">
<int key="NSCellFlags">67239424</int>
@ -16545,6 +16571,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{18, 14}, {120, 78}}</string>
<reference key="NSSuperview" ref="1000433834"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<int key="NSNumRows">4</int>
<int key="NSNumCols">1</int>
@ -16796,15 +16823,17 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
</object>
<string key="NSFrame">{{1, 1}, {248, 102}}</string>
<reference key="NSSuperview" ref="264524412"/>
<reference key="NSWindow"/>
</object>
</object>
<string key="NSFrame">{{17, 41}, {250, 118}}</string>
<reference key="NSSuperview" ref="729561310"/>
<reference key="NSWindow"/>
<string key="NSOffsets">{0, 0}</string>
<object class="NSTextFieldCell" key="NSTitleCell">
<int key="NSCellFlags">67239424</int>
<int key="NSCellFlags2">0</int>
<string key="NSContents">SoftRasterizer Rendering Threads</string>
<string key="NSContents">Rendering Threads</string>
<reference key="NSSupport" ref="26"/>
<reference key="NSBackgroundColor" ref="527409595"/>
<object class="NSColor" key="NSTextColor">
@ -16833,6 +16862,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{15, 32}, {113, 18}}</string>
<reference key="NSSuperview" ref="887816052"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="394241287">
<int key="NSCellFlags">-2080244224</int>
@ -16855,6 +16885,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{15, 12}, {108, 18}}</string>
<reference key="NSSuperview" ref="887816052"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="109440671">
<int key="NSCellFlags">-2080244224</int>
@ -16875,10 +16906,12 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
</object>
<string key="NSFrame">{{1, 1}, {248, 58}}</string>
<reference key="NSSuperview" ref="353783913"/>
<reference key="NSWindow"/>
</object>
</object>
<string key="NSFrame">{{17, 286}, {250, 74}}</string>
<reference key="NSSuperview" ref="729561310"/>
<reference key="NSWindow"/>
<string key="NSOffsets">{0, 0}</string>
<object class="NSTextFieldCell" key="NSTitleCell">
<int key="NSCellFlags">67239424</int>
@ -16899,6 +16932,8 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
</object>
</object>
<string key="NSFrameSize">{284, 482}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
</object>
<string key="NSScreenRect">{{0, 0}, {1920, 1178}}</string>
<string key="NSMaxSize">{1.79769e+308, 1.79769e+308}</string>
@ -28955,6 +28990,14 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
</object>
<int key="connectionID">6237</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">selectVideoFilterType:</string>
<reference key="source" ref="660705428"/>
<reference key="destination" ref="704515259"/>
</object>
<int key="connectionID">6239</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@ -42159,7 +42202,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{872, 628}, {489, 425}}</string>
<string>{{1040, 623}, {489, 425}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<object class="NSAffineTransform">
@ -42211,7 +42254,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<bytes key="NSTransformStruct">P4AAAL+AAABC6AAAw5QAAA</bytes>
</object>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{1002, 572}, {151, 383}}</string>
<string>{{1170, 567}, {151, 383}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@ -43232,9 +43275,9 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<bytes key="NSTransformStruct">AUGIAABDIwAAA</bytes>
</object>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{1269, 175}, {284, 482}}</string>
<string>{{1219, 241}, {284, 482}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{1269, 175}, {284, 482}}</string>
<string>{{1219, 241}, {284, 482}}</string>
<boolean value="NO"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@ -43359,7 +43402,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<bytes key="NSTransformStruct">P4AAAL+AAABDXAAAw5qAAA</bytes>
</object>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{1233, 861}, {152, 63}}</string>
<string>{{1269, 906}, {152, 63}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<object class="NSMutableDictionary">
<string key="NS.key.0">ToolTip</string>
@ -43454,7 +43497,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
</object>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<object class="NSAffineTransform">
<bytes key="NSTransformStruct">P4AAAL+AAABDegAAwrgAAA</bytes>
<bytes key="NSTransformStruct">P4AAAL+AAABDegAAwmgAAA</bytes>
</object>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{881, 382}, {180, 83}}</string>
@ -43497,7 +43540,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<object class="NSAffineTransform">
<bytes key="NSTransformStruct">P4AAAL+AAABB4AAAwrIAAA</bytes>
<bytes key="NSTransformStruct">P4AAAL+AAABCeAAAwlwAAA</bytes>
</object>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@ -45782,7 +45825,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
</object>
</object>
<nil key="sourceID"/>
<int key="maxID">6238</int>
<int key="maxID">6239</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">

View File

@ -27,32 +27,18 @@ int scanline_filter_d = 4;
/********************************************************************************************
CLASS CONSTRUCTORS
********************************************************************************************/
VideoFilter::VideoFilter()
VideoFilter::VideoFilter(unsigned int srcWidth = 1,
unsigned int srcHeight = 1,
VideoFilterTypeID typeID = VideoFilterTypeID_None,
unsigned int numberThreads = 0)
{
_threadCount = 1;
SSurface *newSrcSurface = (SSurface *)malloc(sizeof(SSurface));
if (newSrcSurface == NULL)
{
throw;
}
SSurface *newDestSurface = (SSurface *)malloc(sizeof(SSurface));
if (newDestSurface == NULL)
{
free(newSrcSurface);
newSrcSurface = NULL;
throw;
}
_srcSurfaceMaster = newSrcSurface;
_destSurfaceMaster = newDestSurface;
_srcSurfaceThread = _srcSurfaceMaster;
_destSurfaceThread = _destSurfaceMaster;
SSurface newSurface = {NULL, srcWidth*2, srcWidth, srcHeight};
_vfSrcSurface = newSurface;
_vfDstSurface = newSurface;
_isFilterRunning = false;
_srcSurfaceBufferMaster = NULL;
_typeID = VideoFilterTypeID_None;
_vfSrcSurfacePixBuffer = NULL;
_vfTypeID = typeID;
pthread_mutex_init(&_mutexSrc, NULL);
pthread_mutex_init(&_mutexDest, NULL);
@ -60,437 +46,19 @@ VideoFilter::VideoFilter()
pthread_mutex_init(&_mutexTypeString, NULL);
pthread_cond_init(&_condRunning, NULL);
_vfThread = (pthread_t *)malloc(sizeof(pthread_t));
if (_vfThread == NULL)
{
throw;
}
// Create all threads
_vfThread.resize(numberThreads);
_vfThreadParam = (VideoFilterThreadParam *)malloc(sizeof(VideoFilterThreadParam));
if (_vfThreadParam == NULL)
for (unsigned int i = 0; i < numberThreads; i++)
{
free(_vfThreadParam);
_vfThreadParam = NULL;
throw;
}
_condVFThreadFinish = (pthread_cond_t *)malloc(sizeof(pthread_cond_t));
if (_condVFThreadFinish == NULL)
{
free(_vfThread);
_vfThread = NULL;
_vfThread[i].param.srcSurface = _vfSrcSurface;
_vfThread[i].param.destSurface = _vfDstSurface;
_vfThread[i].param.filterFunction = NULL;
free(_vfThreadParam);
_vfThreadParam = NULL;
throw;
_vfThread[i].task = new Task;
_vfThread[i].task->start(false);
}
_mutexVFThreadFinish = (pthread_mutex_t *)malloc(sizeof(pthread_mutex_t));
if (_mutexVFThreadFinish == NULL)
{
free(_vfThread);
_vfThread = NULL;
free(_vfThreadParam);
_vfThreadParam = NULL;
free(_condVFThreadFinish);
_condVFThreadFinish = NULL;
throw;
}
_isFilterRunningThread = (bool *)malloc(sizeof(bool));
if (_isFilterRunningThread == NULL)
{
free(_vfThread);
_vfThread = NULL;
free(_vfThreadParam);
_vfThreadParam = NULL;
free(_condVFThreadFinish);
_condVFThreadFinish = NULL;
free(_mutexVFThreadFinish);
_mutexVFThreadFinish = NULL;
throw;
}
_vfThreadParam->exitThread = false;
pthread_mutex_init(&_vfThreadParam->mutexThreadExecute, NULL);
pthread_cond_init(&_vfThreadParam->condThreadExecute, NULL);
pthread_cond_init(_condVFThreadFinish, NULL);
_vfThreadParam->condThreadFinish = _condVFThreadFinish;
pthread_mutex_init(_mutexVFThreadFinish, NULL);
_vfThreadParam->mutexThreadFinish = _mutexVFThreadFinish;
*_isFilterRunningThread = false;
_vfThreadParam->isFilterRunning = _isFilterRunningThread;
pthread_create(_vfThread, NULL, &RunVideoFilterThread, _vfThreadParam);
_srcSurfaceMaster->Surface = NULL;
_destSurfaceMaster->Surface = NULL;
SetSourceSize(1, 1);
}
VideoFilter::VideoFilter(unsigned int srcWidth, unsigned int srcHeight)
{
_threadCount = 1;
SSurface *newSrcSurface = (SSurface *)malloc(sizeof(SSurface));
if (newSrcSurface == NULL)
{
throw;
}
SSurface *newDestSurface = (SSurface *)malloc(sizeof(SSurface));
if (newDestSurface == NULL)
{
free(newSrcSurface);
newSrcSurface = NULL;
throw;
}
_srcSurfaceMaster = newSrcSurface;
_destSurfaceMaster = newDestSurface;
_srcSurfaceThread = _srcSurfaceMaster;
_destSurfaceThread = _destSurfaceMaster;
_isFilterRunning = false;
_srcSurfaceBufferMaster = NULL;
_typeID = VideoFilterTypeID_None;
pthread_mutex_init(&_mutexSrc, NULL);
pthread_mutex_init(&_mutexDest, NULL);
pthread_mutex_init(&_mutexTypeID, NULL);
pthread_mutex_init(&_mutexTypeString, NULL);
pthread_cond_init(&_condRunning, NULL);
_vfThread = (pthread_t *)malloc(sizeof(pthread_t));
if (_vfThread == NULL)
{
throw;
}
_vfThreadParam = (VideoFilterThreadParam *)malloc(sizeof(VideoFilterThreadParam));
if (_vfThreadParam == NULL)
{
free(_vfThreadParam);
_vfThreadParam = NULL;
throw;
}
_condVFThreadFinish = (pthread_cond_t *)malloc(sizeof(pthread_cond_t));
if (_condVFThreadFinish == NULL)
{
free(_vfThread);
_vfThread = NULL;
free(_vfThreadParam);
_vfThreadParam = NULL;
throw;
}
_mutexVFThreadFinish = (pthread_mutex_t *)malloc(sizeof(pthread_mutex_t));
if (_mutexVFThreadFinish == NULL)
{
free(_vfThread);
_vfThread = NULL;
free(_vfThreadParam);
_vfThreadParam = NULL;
free(_condVFThreadFinish);
_condVFThreadFinish = NULL;
throw;
}
_isFilterRunningThread = (bool *)malloc(sizeof(bool));
if (_isFilterRunningThread == NULL)
{
free(_vfThread);
_vfThread = NULL;
free(_vfThreadParam);
_vfThreadParam = NULL;
free(_condVFThreadFinish);
_condVFThreadFinish = NULL;
free(_mutexVFThreadFinish);
_mutexVFThreadFinish = NULL;
throw;
}
_vfThreadParam->exitThread = false;
pthread_mutex_init(&_vfThreadParam->mutexThreadExecute, NULL);
pthread_cond_init(&_vfThreadParam->condThreadExecute, NULL);
pthread_cond_init(_condVFThreadFinish, NULL);
_vfThreadParam->condThreadFinish = _condVFThreadFinish;
pthread_mutex_init(_mutexVFThreadFinish, NULL);
_vfThreadParam->mutexThreadFinish = _mutexVFThreadFinish;
*_isFilterRunningThread = false;
_vfThreadParam->isFilterRunning = _isFilterRunningThread;
pthread_create(_vfThread, NULL, &RunVideoFilterThread, _vfThreadParam);
_srcSurfaceMaster->Surface = NULL;
_destSurfaceMaster->Surface = NULL;
SetSourceSize(srcWidth, srcHeight);
}
VideoFilter::VideoFilter(unsigned int srcWidth, unsigned int srcHeight, VideoFilterTypeID typeID)
{
_threadCount = 1;
SSurface *newSrcSurface = (SSurface *)malloc(sizeof(SSurface));
if (newSrcSurface == NULL)
{
throw;
}
SSurface *newDestSurface = (SSurface *)malloc(sizeof(SSurface));
if (newDestSurface == NULL)
{
free(newSrcSurface);
newSrcSurface = NULL;
throw;
}
_srcSurfaceMaster = newSrcSurface;
_destSurfaceMaster = newDestSurface;
_srcSurfaceThread = _srcSurfaceMaster;
_destSurfaceThread = _destSurfaceMaster;
_isFilterRunning = false;
_srcSurfaceBufferMaster = NULL;
_typeID = typeID;
pthread_mutex_init(&_mutexSrc, NULL);
pthread_mutex_init(&_mutexDest, NULL);
pthread_mutex_init(&_mutexTypeID, NULL);
pthread_mutex_init(&_mutexTypeString, NULL);
pthread_cond_init(&_condRunning, NULL);
_vfThread = (pthread_t *)malloc(sizeof(pthread_t));
if (_vfThread == NULL)
{
throw;
}
_vfThreadParam = (VideoFilterThreadParam *)malloc(sizeof(VideoFilterThreadParam));
if (_vfThreadParam == NULL)
{
free(_vfThreadParam);
_vfThreadParam = NULL;
throw;
}
_condVFThreadFinish = (pthread_cond_t *)malloc(sizeof(pthread_cond_t));
if (_condVFThreadFinish == NULL)
{
free(_vfThread);
_vfThread = NULL;
free(_vfThreadParam);
_vfThreadParam = NULL;
throw;
}
_mutexVFThreadFinish = (pthread_mutex_t *)malloc(sizeof(pthread_mutex_t));
if (_mutexVFThreadFinish == NULL)
{
free(_vfThread);
_vfThread = NULL;
free(_vfThreadParam);
_vfThreadParam = NULL;
free(_condVFThreadFinish);
_condVFThreadFinish = NULL;
throw;
}
_isFilterRunningThread = (bool *)malloc(sizeof(bool));
if (_isFilterRunningThread == NULL)
{
free(_vfThread);
_vfThread = NULL;
free(_vfThreadParam);
_vfThreadParam = NULL;
free(_condVFThreadFinish);
_condVFThreadFinish = NULL;
free(_mutexVFThreadFinish);
_mutexVFThreadFinish = NULL;
throw;
}
_vfThreadParam->exitThread = false;
pthread_mutex_init(&_vfThreadParam->mutexThreadExecute, NULL);
pthread_cond_init(&_vfThreadParam->condThreadExecute, NULL);
pthread_cond_init(_condVFThreadFinish, NULL);
_vfThreadParam->condThreadFinish = _condVFThreadFinish;
pthread_mutex_init(_mutexVFThreadFinish, NULL);
_vfThreadParam->mutexThreadFinish = _mutexVFThreadFinish;
*_isFilterRunningThread = false;
_vfThreadParam->isFilterRunning = _isFilterRunningThread;
pthread_create(_vfThread, NULL, &RunVideoFilterThread, _vfThreadParam);
_srcSurfaceMaster->Surface = NULL;
_destSurfaceMaster->Surface = NULL;
SetSourceSize(srcWidth, srcHeight);
}
VideoFilter::VideoFilter(unsigned int srcWidth, unsigned int srcHeight, VideoFilterTypeID typeID, unsigned int numberThreads)
{
// Bounds check
if (numberThreads <= 1)
{
numberThreads = 1;
}
_threadCount = numberThreads;
// We maintain a master surface with our master settings, plus additional surfaces
// specific to each thread that work off the master surface.
size_t threadAlloc = numberThreads + 1;
if (numberThreads == 1)
{
threadAlloc = 1;
}
SSurface *newSrcSurface = (SSurface *)malloc(sizeof(SSurface) * threadAlloc);
if (newSrcSurface == NULL)
{
throw;
}
SSurface *newDestSurface = (SSurface *)malloc(sizeof(SSurface) * threadAlloc);
if (newDestSurface == NULL)
{
free(newSrcSurface);
newSrcSurface = NULL;
throw;
}
// Index the master surface at 0. When freeing, always free the master surface.
_srcSurfaceMaster = newSrcSurface;
_destSurfaceMaster = newDestSurface;
// If we're only using one thread, we can make the master surface and the thread
// surface the same. Otherwise, index the thread surfaces starting at 1. Since
// thread surfaces are pointers relative to the master surface, do not free any
// thread surface directly!
if (_threadCount <= 1)
{
_srcSurfaceThread = _srcSurfaceMaster;
_destSurfaceThread = _destSurfaceMaster;
}
else
{
_srcSurfaceThread = _srcSurfaceMaster + 1;
_destSurfaceThread = _destSurfaceMaster + 1;
}
_isFilterRunning = false;
_srcSurfaceBufferMaster = NULL;
_typeID = typeID;
pthread_mutex_init(&_mutexSrc, NULL);
pthread_mutex_init(&_mutexDest, NULL);
pthread_mutex_init(&_mutexTypeID, NULL);
pthread_mutex_init(&_mutexTypeString, NULL);
pthread_cond_init(&_condRunning, NULL);
_vfThread = (pthread_t *)malloc(sizeof(pthread_t) * _threadCount);
if (_vfThread == NULL)
{
throw;
}
_vfThreadParam = (VideoFilterThreadParam *)malloc(sizeof(VideoFilterThreadParam) * _threadCount);
if (_vfThreadParam == NULL)
{
free(_vfThread);
_vfThread = NULL;
throw;
}
_condVFThreadFinish = (pthread_cond_t *)malloc(sizeof(pthread_cond_t) * _threadCount);
if (_condVFThreadFinish == NULL)
{
free(_vfThread);
_vfThread = NULL;
free(_vfThreadParam);
_vfThreadParam = NULL;
throw;
}
_mutexVFThreadFinish = (pthread_mutex_t *)malloc(sizeof(pthread_mutex_t) * _threadCount);
if (_mutexVFThreadFinish == NULL)
{
free(_vfThread);
_vfThread = NULL;
free(_vfThreadParam);
_vfThreadParam = NULL;
free(_condVFThreadFinish);
_condVFThreadFinish = NULL;
throw;
}
_isFilterRunningThread = (bool *)malloc(sizeof(bool) * _threadCount);
if (_isFilterRunningThread == NULL)
{
free(_vfThread);
_vfThread = NULL;
free(_vfThreadParam);
_vfThreadParam = NULL;
free(_condVFThreadFinish);
_condVFThreadFinish = NULL;
free(_mutexVFThreadFinish);
_mutexVFThreadFinish = NULL;
throw;
}
for (unsigned int i = 0; i < _threadCount; i++)
{
_vfThreadParam[i].exitThread = false;
pthread_mutex_init(&_vfThreadParam[i].mutexThreadExecute, NULL);
pthread_cond_init(&_vfThreadParam[i].condThreadExecute, NULL);
pthread_cond_init(&_condVFThreadFinish[i], NULL);
_vfThreadParam[i].condThreadFinish = &_condVFThreadFinish[i];
pthread_mutex_init(&_mutexVFThreadFinish[i], NULL);
_vfThreadParam[i].mutexThreadFinish = &_mutexVFThreadFinish[i];
_isFilterRunningThread[i] = false;
_vfThreadParam[i].isFilterRunning = &_isFilterRunningThread[i];
pthread_create(&_vfThread[i], NULL, &RunVideoFilterThread, &_vfThreadParam[i]);
}
_srcSurfaceMaster->Surface = NULL;
_destSurfaceMaster->Surface = NULL;
SetSourceSize(srcWidth, srcHeight);
}
@ -499,6 +67,18 @@ VideoFilter::VideoFilter(unsigned int srcWidth, unsigned int srcHeight, VideoFil
********************************************************************************************/
VideoFilter::~VideoFilter()
{
// Destroy all threads first
for (unsigned int i = 0; i < _vfThread.size(); i++)
{
_vfThread[i].task->finish();
_vfThread[i].task->shutdown();
delete _vfThread[i].task;
}
_vfThread.clear();
// Destroy everything else
pthread_mutex_lock(&this->_mutexDest);
while (this->_isFilterRunning)
@ -506,50 +86,19 @@ VideoFilter::~VideoFilter()
pthread_cond_wait(&this->_condRunning, &this->_mutexDest);
}
free(_destSurfaceMaster->Surface);
_destSurfaceMaster->Surface = NULL;
free(_destSurfaceMaster);
_destSurfaceMaster = NULL;
free(_vfDstSurface.Surface);
_vfDstSurface.Surface = NULL;
pthread_mutex_unlock(&_mutexDest);
pthread_mutex_lock(&_mutexSrc);
free(_srcSurfaceBufferMaster);
_srcSurfaceBufferMaster = NULL;
_srcSurfaceMaster->Surface = NULL;
free(_srcSurfaceMaster);
_srcSurfaceMaster = NULL;
free(_vfSrcSurfacePixBuffer);
_vfSrcSurfacePixBuffer = NULL;
_vfSrcSurface.Surface = NULL;
pthread_mutex_unlock(&_mutexSrc);
for (unsigned int i = 0; i < _threadCount; i++)
{
pthread_mutex_lock(&_vfThreadParam[i].mutexThreadExecute);
_vfThreadParam[i].exitThread = true;
pthread_cond_signal(&_vfThreadParam[i].condThreadExecute);
pthread_mutex_unlock(&_vfThreadParam[i].mutexThreadExecute);
pthread_join(_vfThread[i], NULL);
_vfThread[i] = NULL;
pthread_mutex_destroy(&_vfThreadParam[i].mutexThreadExecute);
pthread_cond_destroy(&_vfThreadParam[i].condThreadExecute);
pthread_cond_destroy(&_condVFThreadFinish[i]);
pthread_mutex_destroy(&_mutexVFThreadFinish[i]);
}
free(_vfThread);
_vfThread = NULL;
free(_vfThreadParam);
_vfThreadParam = NULL;
free(_condVFThreadFinish);
_condVFThreadFinish = NULL;
free(_mutexVFThreadFinish);
_mutexVFThreadFinish = NULL;
free(_isFilterRunningThread);
_isFilterRunningThread = NULL;
pthread_mutex_destroy(&_mutexSrc);
pthread_mutex_destroy(&_mutexDest);
pthread_mutex_destroy(&_mutexTypeID);
@ -580,34 +129,36 @@ bool VideoFilter::SetSourceSize(const unsigned int width, const unsigned int hei
// Overallocate the source buffer by 8 rows of pixels to account for out-of-bounds
// memory reads done by some filters.
uint32_t *newSurfaceBuffer = (uint32_t *)calloc(width * (height + 8), sizeof(uint32_t));
if (newSurfaceBuffer == NULL)
uint32_t *newPixBuffer = (uint32_t *)calloc(width * (height + 8), sizeof(uint32_t));
if (newPixBuffer == NULL)
{
return result;
}
this->_srcSurfaceMaster->Width = width;
this->_srcSurfaceMaster->Height = height;
this->_srcSurfaceMaster->Pitch = width * 2;
this->_vfSrcSurface.Width = width;
this->_vfSrcSurface.Height = height;
this->_vfSrcSurface.Pitch = width * 2;
// Set the working source buffer pointer so that the working memory block is padded
// with 4 pixel rows worth of memory on both sides.
this->_srcSurfaceMaster->Surface = (unsigned char *)(newSurfaceBuffer + (width * 4));
this->_vfSrcSurface.Surface = (unsigned char *)(newPixBuffer + (width * 4));
free(this->_srcSurfaceBufferMaster);
this->_srcSurfaceBufferMaster = newSurfaceBuffer;
free(this->_vfSrcSurfacePixBuffer);
this->_vfSrcSurfacePixBuffer = newPixBuffer;
// Update the surfaces on threads.
for (unsigned int i = 0; i < this->_threadCount; i++)
size_t threadCount = this->_vfThread.size();
for (unsigned int i = 0; i < threadCount; i++)
{
this->_srcSurfaceThread[i] = *this->_srcSurfaceMaster;
this->_srcSurfaceThread[i].Height /= this->_threadCount;
SSurface &threadSrcSurface = this->_vfThread[i].param.srcSurface;
threadSrcSurface = this->_vfSrcSurface;
threadSrcSurface.Height /= threadCount;
if (i > 0)
{
this->_srcSurfaceThread[i].Surface = (unsigned char *)((uint32_t *)this->_srcSurfaceThread[i - 1].Surface + (this->_srcSurfaceThread[i - 1].Width * this->_srcSurfaceThread[i - 1].Height));
SSurface &prevThreadSrcSurface = this->_vfThread[i - 1].param.srcSurface;
threadSrcSurface.Surface = (unsigned char *)((uint32_t *)prevThreadSrcSurface.Surface + (prevThreadSrcSurface.Width * prevThreadSrcSurface.Height));
}
this->_vfThreadParam[i].srcSurface = this->_srcSurfaceThread[i];
}
pthread_mutex_unlock(&this->_mutexSrc);
@ -664,15 +215,15 @@ bool VideoFilter::ChangeFilterByAttributes(const VideoFilterAttributes *vfAttr)
}
pthread_mutex_lock(&this->_mutexSrc);
const unsigned int srcWidth = this->_srcSurfaceMaster->Width;
const unsigned int srcHeight = this->_srcSurfaceMaster->Height;
const unsigned int srcWidth = this->_vfSrcSurface.Width;
const unsigned int srcHeight = this->_vfSrcSurface.Height;
pthread_mutex_unlock(&this->_mutexSrc);
const VideoFilterTypeID typeID = vfAttr->typeID;
const unsigned int dstWidth = srcWidth * vfAttr->scaleMultiply / vfAttr->scaleDivide;
const unsigned int dstHeight = srcHeight * vfAttr->scaleMultiply / vfAttr->scaleDivide;
const char *typeString = vfAttr->typeString;
const VideoFilterCallback filterCallback = vfAttr->filterFunction;
const VideoFilterFunc filterFunction = vfAttr->filterFunction;
pthread_mutex_lock(&this->_mutexDest);
@ -682,27 +233,30 @@ bool VideoFilter::ChangeFilterByAttributes(const VideoFilterAttributes *vfAttr)
return result;
}
this->_filterCallback = filterCallback;
this->_destSurfaceMaster->Width = dstWidth;
this->_destSurfaceMaster->Height = dstHeight;
this->_destSurfaceMaster->Pitch = dstWidth * 2;
this->_vfFunc = filterFunction;
this->_vfDstSurface.Width = dstWidth;
this->_vfDstSurface.Height = dstHeight;
this->_vfDstSurface.Pitch = dstWidth * 2;
free(this->_destSurfaceMaster->Surface);
this->_destSurfaceMaster->Surface = (unsigned char*)newSurfaceBuffer;
free(this->_vfDstSurface.Surface);
this->_vfDstSurface.Surface = (unsigned char *)newSurfaceBuffer;
// Update the surfaces on threads.
for (unsigned int i = 0; i < this->_threadCount; i++)
size_t threadCount = this->_vfThread.size();
for (unsigned int i = 0; i < threadCount; i++)
{
this->_destSurfaceThread[i] = *this->_destSurfaceMaster;
this->_destSurfaceThread[i].Height /= this->_threadCount;
SSurface &threadDstSurface = this->_vfThread[i].param.destSurface;
threadDstSurface = this->_vfDstSurface;
threadDstSurface.Height /= threadCount;
if (i > 0)
{
this->_destSurfaceThread[i].Surface = (unsigned char *)((uint32_t *)this->_destSurfaceThread[i - 1].Surface + (this->_destSurfaceThread[i - 1].Width * this->_destSurfaceThread[i - 1].Height));
SSurface &prevThreadDstSurface = this->_vfThread[i - 1].param.destSurface;
threadDstSurface.Surface = (unsigned char *)((uint32_t *)prevThreadDstSurface.Surface + (prevThreadDstSurface.Width * prevThreadDstSurface.Height));
}
this->_vfThreadParam[i].destSurface = this->_destSurfaceThread[i];
this->_vfThreadParam[i].filterCallback = this->_filterCallback;
this->_vfThread[i].param.filterFunction = this->_vfFunc;
}
pthread_mutex_unlock(&this->_mutexDest);
@ -732,34 +286,33 @@ uint32_t* VideoFilter::RunFilter()
pthread_mutex_lock(&this->_mutexDest);
this->_isFilterRunning = true;
uint32_t *destBufPtr = (uint32_t *)this->_destSurfaceMaster->Surface;
uint32_t *destBufPtr = (uint32_t *)this->_vfDstSurface.Surface;
pthread_mutex_lock(&this->_mutexSrc);
if (this->_filterCallback == NULL)
if (this->_vfFunc == NULL)
{
memcpy(this->_destSurfaceMaster->Surface, this->_srcSurfaceMaster->Surface, this->_destSurfaceMaster->Width * this->_destSurfaceMaster->Height * sizeof(uint32_t));
memcpy(this->_vfDstSurface.Surface, this->_vfSrcSurface.Surface, this->_vfDstSurface.Width * this->_vfDstSurface.Height * sizeof(uint32_t));
}
else
{
for (unsigned int i = 0; i < this->_threadCount; i++)
{
pthread_mutex_lock(&this->_vfThreadParam[i].mutexThreadExecute);
*this->_vfThreadParam[i].isFilterRunning = true;
pthread_cond_signal(&this->_vfThreadParam[i].condThreadExecute);
pthread_mutex_unlock(&this->_vfThreadParam[i].mutexThreadExecute);
}
size_t threadCount = this->_vfThread.size();
for (unsigned int i = 0; i < this->_threadCount; i++)
if (threadCount > 0)
{
pthread_mutex_lock(&this->_mutexVFThreadFinish[i]);
while (this->_isFilterRunningThread[i])
for (unsigned int i = 0; i < threadCount; i++)
{
pthread_cond_wait(&this->_condVFThreadFinish[i], &this->_mutexVFThreadFinish[i]);
this->_vfThread[i].task->execute(RunVideoFilterTask, &this->_vfThread[i].param);
}
pthread_mutex_unlock(&this->_mutexVFThreadFinish[i]);
for (unsigned int i = 0; i < threadCount; i++)
{
this->_vfThread[i].task->finish();
}
}
else
{
this->_vfFunc(this->_vfSrcSurface, this->_vfDstSurface);
}
}
@ -810,7 +363,7 @@ void VideoFilter::RunFilterCustom(const uint32_t *__restrict__ srcBuffer, uint32
const VideoFilterAttributes *vfAttr = &VideoFilterAttributesList[typeID];
const unsigned int dstWidth = srcWidth * vfAttr->scaleMultiply / vfAttr->scaleDivide;
const unsigned int dstHeight = dstWidth * vfAttr->scaleMultiply / vfAttr->scaleDivide;
const VideoFilterCallback filterFunction = vfAttr->filterFunction;
const VideoFilterFunc filterFunction = vfAttr->filterFunction;
SSurface srcSurface = {(unsigned char *)srcBuffer, srcWidth*2, srcWidth, srcHeight};
SSurface dstSurface = {(unsigned char *)dstBuffer, dstWidth*2, dstWidth, dstHeight};
@ -854,7 +407,7 @@ const char* VideoFilter::GetTypeStringByID(const VideoFilterTypeID typeID)
VideoFilterTypeID VideoFilter::GetTypeID()
{
pthread_mutex_lock(&this->_mutexTypeID);
VideoFilterTypeID typeID = this->_typeID;
VideoFilterTypeID typeID = this->_vfTypeID;
pthread_mutex_unlock(&this->_mutexTypeID);
return typeID;
@ -863,14 +416,14 @@ VideoFilterTypeID VideoFilter::GetTypeID()
void VideoFilter::SetTypeID(const VideoFilterTypeID typeID)
{
pthread_mutex_lock(&this->_mutexTypeID);
this->_typeID = typeID;
this->_vfTypeID = typeID;
pthread_mutex_unlock(&this->_mutexTypeID);
}
const char* VideoFilter::GetTypeString()
{
pthread_mutex_lock(&this->_mutexTypeString);
const char *typeString = this->_typeString.c_str();
const char *typeString = this->_vfTypeString.c_str();
pthread_mutex_unlock(&this->_mutexTypeString);
return typeString;
@ -878,22 +431,20 @@ const char* VideoFilter::GetTypeString()
void VideoFilter::SetTypeString(const char *typeString)
{
pthread_mutex_lock(&this->_mutexTypeString);
this->_typeString = typeString;
pthread_mutex_unlock(&this->_mutexTypeString);
this->SetTypeString(std::string(typeString));
}
void VideoFilter::SetTypeString(std::string typeString)
{
pthread_mutex_lock(&this->_mutexTypeString);
this->_typeString = typeString;
this->_vfTypeString = typeString;
pthread_mutex_unlock(&this->_mutexTypeString);
}
uint32_t* VideoFilter::GetSrcBufferPtr()
{
pthread_mutex_lock(&this->_mutexSrc);
uint32_t *ptr = (uint32_t *)this->_srcSurfaceMaster->Surface;
uint32_t *ptr = (uint32_t *)this->_vfSrcSurface.Surface;
pthread_mutex_unlock(&this->_mutexSrc);
return ptr;
@ -902,7 +453,7 @@ uint32_t* VideoFilter::GetSrcBufferPtr()
uint32_t* VideoFilter::GetDestBufferPtr()
{
pthread_mutex_lock(&this->_mutexDest);
uint32_t *ptr = (uint32_t *)this->_destSurfaceMaster->Surface;
uint32_t *ptr = (uint32_t *)this->_vfDstSurface.Surface;
pthread_mutex_unlock(&this->_mutexDest);
return ptr;
@ -911,7 +462,7 @@ uint32_t* VideoFilter::GetDestBufferPtr()
unsigned int VideoFilter::GetSrcWidth()
{
pthread_mutex_lock(&this->_mutexSrc);
unsigned int width = this->_srcSurfaceMaster->Width;
unsigned int width = this->_vfSrcSurface.Width;
pthread_mutex_unlock(&this->_mutexSrc);
return width;
@ -920,7 +471,7 @@ unsigned int VideoFilter::GetSrcWidth()
unsigned int VideoFilter::GetSrcHeight()
{
pthread_mutex_lock(&this->_mutexSrc);
unsigned int height = this->_srcSurfaceMaster->Height;
unsigned int height = this->_vfSrcSurface.Height;
pthread_mutex_unlock(&this->_mutexSrc);
return height;
@ -929,7 +480,7 @@ unsigned int VideoFilter::GetSrcHeight()
unsigned int VideoFilter::GetDestWidth()
{
pthread_mutex_lock(&this->_mutexDest);
unsigned int width = this->_destSurfaceMaster->Width;
unsigned int width = this->_vfDstSurface.Width;
pthread_mutex_unlock(&this->_mutexDest);
return width;
@ -938,41 +489,18 @@ unsigned int VideoFilter::GetDestWidth()
unsigned int VideoFilter::GetDestHeight()
{
pthread_mutex_lock(&this->_mutexDest);
unsigned int height = this->_destSurfaceMaster->Height;
unsigned int height = this->_vfDstSurface.Height;
pthread_mutex_unlock(&this->_mutexDest);
return height;
}
static void* RunVideoFilterThread(void *arg)
// Task function for multithreaded filtering
static void* RunVideoFilterTask(void *arg)
{
VideoFilterThreadParam *param = (VideoFilterThreadParam *)arg;
do
{
pthread_mutex_lock(&param->mutexThreadExecute);
while (!*param->isFilterRunning && !param->exitThread)
{
pthread_cond_wait(&param->condThreadExecute, &param->mutexThreadExecute);
}
if (param->exitThread)
{
pthread_mutex_unlock(&param->mutexThreadExecute);
break;
}
param->filterCallback(param->srcSurface, param->destSurface);
pthread_mutex_lock(param->mutexThreadFinish);
*param->isFilterRunning = false;
pthread_cond_signal(param->condThreadFinish);
pthread_mutex_unlock(param->mutexThreadFinish);
pthread_mutex_unlock(&param->mutexThreadExecute);
} while (!param->exitThread);
param->filterFunction(param->srcSurface, param->destSurface);
return NULL;
}

View File

@ -21,8 +21,10 @@
#include <stdlib.h>
#include <string>
#include <vector>
#include <pthread.h>
#include "../filter/filter.h"
#include "../utils/task.h"
// VIDEO FILTER TYPES
@ -53,13 +55,13 @@ enum VideoFilterTypeID
#define VIDEOFILTERTYPE_UNKNOWN_STRING "Unknown"
typedef void (*VideoFilterCallback)(SSurface Src, SSurface Dst);
typedef void (*VideoFilterFunc)(SSurface Src, SSurface Dst);
typedef struct
{
VideoFilterTypeID typeID;
const char *typeString;
VideoFilterCallback filterFunction;
VideoFilterFunc filterFunction;
unsigned int scaleMultiply;
unsigned int scaleDivide;
} VideoFilterAttributes;
@ -91,17 +93,15 @@ typedef struct
{
SSurface srcSurface;
SSurface destSurface;
VideoFilterCallback filterCallback;
bool exitThread;
pthread_mutex_t mutexThreadExecute;
pthread_cond_t condThreadExecute;
pthread_cond_t *condThreadFinish;
pthread_mutex_t *mutexThreadFinish;
bool *isFilterRunning;
VideoFilterFunc filterFunction;
} VideoFilterThreadParam;
typedef struct
{
Task *task;
VideoFilterThreadParam param;
} VideoFilterThread;
/********************************************************************************************
VideoFilter - C++ CLASS
@ -127,23 +127,16 @@ typedef struct
class VideoFilter
{
private:
VideoFilterTypeID _typeID;
std::string _typeString;
SSurface *_srcSurfaceMaster;
SSurface *_destSurfaceMaster;
SSurface *_srcSurfaceThread;
SSurface *_destSurfaceThread;
uint32_t *_srcSurfaceBufferMaster;
VideoFilterCallback _filterCallback;
VideoFilterTypeID _vfTypeID;
std::string _vfTypeString;
SSurface _vfSrcSurface;
SSurface _vfDstSurface;
uint32_t *_vfSrcSurfacePixBuffer;
VideoFilterFunc _vfFunc;
std::vector<VideoFilterThread> _vfThread;
bool _isFilterRunning;
unsigned int _threadCount;
pthread_t *_vfThread;
VideoFilterThreadParam *_vfThreadParam;
pthread_cond_t *_condVFThreadFinish;
pthread_mutex_t *_mutexVFThreadFinish;
bool *_isFilterRunningThread;
pthread_mutex_t _mutexSrc;
pthread_mutex_t _mutexDest;
pthread_mutex_t _mutexTypeID;
@ -155,9 +148,6 @@ private:
void SetTypeString(std::string typeString);
public:
VideoFilter();
VideoFilter(unsigned int srcWidth, unsigned int srcHeight);
VideoFilter(unsigned int srcWidth, unsigned int srcHeight, VideoFilterTypeID typeID);
VideoFilter(unsigned int srcWidth, unsigned int srcHeight, VideoFilterTypeID typeID, unsigned int numberThreads);
~VideoFilter();
@ -179,6 +169,6 @@ public:
unsigned int GetDestHeight();
};
static void* RunVideoFilterThread(void *arg);
static void* RunVideoFilterTask(void *arg);
#endif