<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet title="XSL formatting" type="text/xsl" href="http://www.mustelidae.fr/index.php?feed/rss2/xslt" ?><rss version="2.0"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:wfw="http://wellformedweb.org/CommentAPI/"
  xmlns:content="http://purl.org/rss/1.0/modules/content/"
  xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
  <title>Chouquette's blog</title>
  <link>http://www.mustelidae.fr/index.php?</link>
  <atom:link href="http://www.mustelidae.fr/index.php?feed/rss2" rel="self" type="application/rss+xml"/>
  <description></description>
  <language>en</language>
  <pubDate>Sat, 04 Sep 2010 21:20:29 +0200</pubDate>
  <copyright></copyright>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Dotclear</generator>
  
    
  <item>
    <title>VLMC 0.1.0 released !</title>
    <link>http://www.mustelidae.fr/index.php?post/2010/04/14/VLMC-0%2C1.0-released-%21</link>
    <guid isPermaLink="false">urn:md5:b778dec7aa42d9936d311acaf41bb9e6</guid>
    <pubDate>Wed, 14 Apr 2010 09:47:00 +0100</pubDate>
    <dc:creator>Hugo</dc:creator>
        <category>VideoLAN</category>
        <category>release</category><category>vlmc</category>    
    <description>    &lt;p&gt;Good news everyone !&lt;/p&gt;


&lt;p&gt;The first pre-pre-...-pre-alpha of VLMC just has been released for win32. Please keep in mind that this is realy just about testing, and is not intented to be fully functionnal.
Many bugs can occur, even crash, and using it may lead to an early end of the world.&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;If you're willing to test it though, you can find it there : &lt;a href=&quot;ftp://ftp.videolan.org/pub/videolan/testing/vlmc/vlmc-0.1.0.exe&quot; title=&quot;ftp://ftp.videolan.org/pub/videolan/testing/vlmc/vlmc-0.1.0.exe&quot;&gt;ftp://ftp.videolan.org/pub/videolan...&lt;/a&gt;
&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;Please, and I really meen it : please keep in mind that we're currently only two developpers, and that vlmc is developped in our free time. Before yelling at us because vlmc didn't work the way you expected it to, think twice (and maybe more). Instead, if you find a bug, even the smallest one, if you feel something needs improvements, if you think of a nice feature, or if you're willing to help us, please do ! Open up tickets (www.vlmc.org), send us patches, come and discuss with us on IRC :)&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;Have as many fun as possible testing VLMC !&lt;/p&gt;</description>
    
    
    
      </item>
    
  <item>
    <title>VLMC: More infos on release process</title>
    <link>http://www.mustelidae.fr/index.php?post/2010/03/17/VLMC%3A-More-infos-on-release-process</link>
    <guid isPermaLink="false">urn:md5:d8349b5604147d00cb362858f1fff15e</guid>
    <pubDate>Wed, 17 Mar 2010 22:10:00 +0000</pubDate>
    <dc:creator>Hugo</dc:creator>
        <category>VideoLAN</category>
        <category>VideoLAN</category><category>VLC</category><category>VLMC</category>    
    <description>&lt;p&gt;As this seems to bother many people, here are some update on the VLMC release :)&lt;/p&gt;    &lt;p&gt;As VLMC was showed on the Solutions Linux expo (in Paris), we had time to chat with some people interested in VLMC. It was great having feedback, and allow us to spot many bugs, that have mostly been fixed :)&lt;/p&gt;


&lt;p&gt;We decided today that it was pointless releasing VLMC for linux until VLC 1.1 has been release. So we will wait until then. We're going to release for win32 soon, as we have fixed the last specific bug tonight (unless we found another in the next days)
For those of you who follow the git, you may have noticed that a 0.0.1-bugfix branch has been created a month ago. This branch will be droped, as it became pointless as time goes. In the last weeks, many parts of the code has been rewritten, and since we didn't release, and had time to fix the bug introduced by this big refactoring, there's no point keeping this old code up.
Here's some of the things that has been fixed/rewritten :&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Settings widget are now autogenerated.&lt;/li&gt;
&lt;li&gt;Settings are now categorized, and variables must be created before using.&lt;/li&gt;
&lt;li&gt;Media list has been unified, and useless classes have been removed&lt;/li&gt;
&lt;li&gt;Synchronisation problem are fixed.&lt;/li&gt;
&lt;li&gt;Memory usage has been reduced.&lt;/li&gt;
&lt;li&gt;Some GUI bugs have been fixed&lt;/li&gt;
&lt;li&gt;Import has been mostly rewritten, and is more efficient now&lt;/li&gt;
&lt;li&gt;Win32 fixes&lt;/li&gt;
&lt;li&gt;Many crash are now gone&lt;/li&gt;
&lt;li&gt;Many more cleanups&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In the last two weeks, I'd say i dropped from 1000 to 2000 lines of code. There's still many things to do, bug the code is gettings cleaner and cleaner everyday.&lt;/p&gt;


&lt;p&gt;I hope the win32 release will come up in the next days. The binary release will come later, along with VLC 1.1&lt;/p&gt;


&lt;p&gt;For those of you who use gentoo or archlinux, an ebuild/aur package is already available.
In any case, this is the page to watch : http://trac.videolan.org/vlmc/wiki/Downloads&lt;/p&gt;</description>
    
    
    
      </item>
    
  <item>
    <title>VLMC, On the way to the release</title>
    <link>http://www.mustelidae.fr/index.php?post/2010/03/15/VLMC%2C-On-the-way-to-the-release</link>
    <guid isPermaLink="false">urn:md5:3e69195649774168b8c1a72ec2740a2f</guid>
    <pubDate>Mon, 15 Mar 2010 11:02:00 +0000</pubDate>
    <dc:creator>Hugo</dc:creator>
        <category>VideoLAN</category>
        <category>VideoLAN</category><category>VLMC</category>    
    <description>&lt;p&gt;Hi folks,&lt;/p&gt;


&lt;p&gt;Just a quick post to inform you of the current VLMC state...&lt;/p&gt;    &lt;p&gt;We've been working hard to fix the latest bugs, and to clean the code up. We still have a few problem under win32... some crashes, and most of all, the project preview doesn't work.
We were planning on releasing yesterday, but it seems that we'll be late, again... We're doing our best to fix as many bug as possible, as quick as possible, but that's not easy, as VLMC team counts only 2 devs right now. Contributors are wanted and welcome&amp;nbsp;!&lt;/p&gt;


&lt;p&gt;About OSX, we can't test, as nobody on the team owns a mac. If you're a macosx developer, and you're willing to spend some time helping us out, you're more than welcome.&lt;/p&gt;


&lt;p&gt;As you may have noticed, our &lt;a href=&quot;http://www.mustelidae.fr/index.php?post/2010/03/15/www.vlmc.org&quot; hreflang=&quot;en&quot;&gt;website&lt;/a&gt; is back online. It's currently just a bugtracker, but it will become a real website, eventually. Please submit every bug you come across&amp;nbsp;!&lt;/p&gt;


&lt;p&gt;I really hope next post will be to announce a release :)&lt;/p&gt;</description>
    
    
    
      </item>
    
  <item>
    <title>What about VLMC ?</title>
    <link>http://www.mustelidae.fr/index.php?post/2010/03/09/What-about-VLMC</link>
    <guid isPermaLink="false">urn:md5:8c7d3cf250ae7a8940276ba264e48b80</guid>
    <pubDate>Tue, 09 Mar 2010 17:35:00 +0000</pubDate>
    <dc:creator>Hugo</dc:creator>
        <category>VideoLAN</category>
            
    <description>&lt;p&gt;Hi everyone,&lt;/p&gt;


&lt;p&gt;Long time since last post... at this time, VLMC wasn't abble to render anything, and was pretty much all about loading videos... and doing nothing with it....So what now&amp;nbsp;?&lt;/p&gt;    &lt;p&gt;Many progress has been made since this time&amp;nbsp;! Right now, we're able to do some basic video editing. Cutting, moving, trimming, resizing, extracting parts from a rush... and many more to come hopefully&amp;nbsp;!
Why didn't we talked much in the last two month&amp;nbsp;? Well... first VLMC was our end of studies project... we had to stop coding, and prepare for the boring stuff... oral defense, papers... but that's over.
Then, we had a &quot;small&quot; problem with our server... by small, i mean that it completely burned down, which was pretty annoying...&lt;/p&gt;


&lt;p&gt;We're currently moving to the VideoLAN infrastructure. You can already fetch the new git at&amp;nbsp;: git://git.videolan.org/vlmc.git or if you feel like it, there's the RSS feed&amp;nbsp;: http://git.videolan.org/?p=vlmc.git;a=rss
Mailing list should be back by the end of the week, along with the bugtracker.&lt;/p&gt;


&lt;p&gt;As the school project ended, the VLMC team was pretty much shrinked to a 2 or 3 developpers team... we definitely need some contributors&amp;nbsp;! Developers, translators, testers, advices, anything can be of assistance&amp;nbsp;!
VLMC is now a fully open source project, and definitely needs your help&amp;nbsp;!&lt;/p&gt;


&lt;p&gt;Right now, I'm currently rewriting many parts of the code, that needed to be cleaned before anything else happen (you don't build you house over a swamp don't you&amp;nbsp;? ;) )
This should be done by the end of the week. After that, a small bug in the file rendering, and a crash when moving clips in the timeline prevents us from releasing a developer's preview. Once fixed, release will be on the way.
Don't forget that we require a stable VLC version before packaging anything (unless we build it statically... but no.) The VLC 1.1 should be out in a few weeks now. Please be patient&amp;nbsp;! :)&lt;/p&gt;


&lt;p&gt;Here you can find the latest demo video&amp;nbsp;:&lt;/p&gt;
&lt;object width=&quot;480&quot; height=&quot;385&quot;&gt;&lt;param name=&quot;movie&quot; value=&quot;http://www.youtube.com/v/KAzfABd8JmU&amp;hl=en_US&amp;fs=1&amp;&quot;&gt;&lt;/param&gt;&lt;param name=&quot;allowFullScreen&quot; value=&quot;true&quot;&gt;&lt;/param&gt;&lt;param name=&quot;allowscriptaccess&quot; value=&quot;always&quot;&gt;&lt;/param&gt;&lt;embed src=&quot;http://www.youtube.com/v/KAzfABd8JmU&amp;hl=en_US&amp;fs=1&amp;&quot; type=&quot;application/x-shockwave-flash&quot; allowscriptaccess=&quot;always&quot; allowfullscreen=&quot;true&quot; width=&quot;480&quot; height=&quot;385&quot;&gt;&lt;/embed&gt;&lt;/object&gt;




&lt;p&gt;See you soon on #vlmc @ freenode&amp;nbsp;!&lt;/p&gt;</description>
    
    
    
      </item>
    
  <item>
    <title>GSoC : Day 1</title>
    <link>http://www.mustelidae.fr/index.php?post/2009/05/25/GSoC-%3A-Day-1</link>
    <guid isPermaLink="false">urn:md5:e8430c67408b94c925db32dbf78b6b33</guid>
    <pubDate>Mon, 25 May 2009 08:12:00 +0100</pubDate>
    <dc:creator>Hugo</dc:creator>
        <category>VideoLAN</category>
            
    <description>&lt;p&gt;Here we start :)&lt;/p&gt;


&lt;p&gt;This is the first real GSoC post, hurray \o/&lt;/p&gt;    &lt;p&gt;For this first day, I'll need to code a quick render preview widget.
&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;I already started to split the VLMC's RenderWidget into 2 separate classes&amp;nbsp;: one for the clips/media preview, one for the timeline/workflow render, but the second isn't implemented yet, this will be my first day job. I'll post along the day, as the code is written :)
&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;In order to provide a little more genericity and flexibility to the code, i'll add an generic class on the top of the two described above.
&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;First surprise, the Q_DISABLE_COPY macro disable the default ctor... this is quite normal since this maccro adds a private copy ctor, and as soon as the compiler sees a user defined constructor, it disable every default ctor... so normal but surprising :p
&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;After a quick code fix, it works as good as the old version :)&lt;/p&gt;


&lt;p&gt;I was kinda scared by the idea of having pure virtual slots, but this works just fine. I really do love Qt more and more every day :o
&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;So now, VLMC has a GenericPreviewWidget... it just needs to be used (as the generic type) a little more, and moreover, it needs a RenderPreviewWidget implementation :)
&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;10:33AM&amp;nbsp;: VLMC now has an &quot;independent&quot; GUI for its two renderers. Code has been pushed to GIT, and now the fun part begin, with the render preview implementation, which depends on in-vmem codec, freshly fixed by etix :)&lt;/p&gt;


&lt;p&gt;01:00Pm&amp;nbsp;: invmem isn't as simple as I expected :(
&lt;br /&gt;
At the moment, it just displays a white screen, and it seems that the clip workflow that wasn't tested isn't functionnal...
Hopefully this will be solved soon :/&lt;/p&gt;


&lt;p&gt;01:05Pm&amp;nbsp;: woops, I just didn't remember how to use memset anymore... shame on me, the problem definitly doesn't come from the invmem codec...
&lt;br /&gt;
Next step will be to export what the vout:vmem save into the memory, and see if that's correct...&lt;/p&gt;


&lt;p&gt;2:15Pm&amp;nbsp;: Damn it.... each time a graphic window pops over VLC, my X-server crashes... I hope that the recent Xorg update (1.5.3-r5 -&amp;gt; 1.5.3-r6 on gentoo is to blame, but I don't feel like it :/ )
&lt;br /&gt; It reminds me of a bug I came across last year, each time a graphic window would cover an opengl window, X was completly frozen... the only solution was to reboot the computer, and it looked like the intel graphics drivers were to blame... i *really* do hope that this won't be the case here :/
&lt;br /&gt;
This hasn't been solved yet... that's sad :/&lt;/p&gt;


&lt;p&gt;3:30Pm&amp;nbsp;: Hurray it works !&lt;br /&gt;
We now have a basic clip workflow that output a clip to a video buffer, and a main workflow that asks the first track to output the first clip output, and output it through the render preview widget, using the invmem codec. Basically, it just reads the video at the moment, but now our primary workflow is functionnal.
&lt;br /&gt;
Next step&amp;nbsp;: we should use Clip instead of Media. A clip is a representation of a media inside the timeline, and can cover just a part of it, or the entire media. Inside of the timeline, we must use Clip, but we use Media at the moment.
&lt;br /&gt;
This implies that we have to handle at least&amp;nbsp;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Videos that doesn't start at &quot;0&quot;&lt;/li&gt;
&lt;li&gt;Videos that ends (this case hasn't been tested yet, funny isn't it ?)&lt;/li&gt;
&lt;li&gt;Videos that ends before the real end of the video&lt;/li&gt;
&lt;li&gt;Generating a Clip from the Media, using the GUI.&lt;/li&gt;
&lt;li&gt;Probably many other things :)&lt;/li&gt;
&lt;/ul&gt;</description>
    
    
    
      </item>
    
  <item>
    <title>Recent VLC patches</title>
    <link>http://www.mustelidae.fr/index.php?post/2009/05/11/Recent-VLC-patches</link>
    <guid isPermaLink="false">urn:md5:6dd64bfe46077b432e43692723ae594a</guid>
    <pubDate>Mon, 11 May 2009 09:35:00 +0100</pubDate>
    <dc:creator>Hugo</dc:creator>
        <category>VideoLAN</category>
        <category>GSoC</category><category>VLC</category><category>VLMC</category>    
    <description>&lt;p&gt;Hi,&lt;/p&gt;


&lt;p&gt;This is a follow up from the previous post, and a little more :)&lt;/p&gt;    &lt;p&gt;Regarding the libvlc_media_player_play() race condition, a &lt;a href=&quot;http://git.videolan.org/?p=vlc.git;a=commit;h=80684e7846b29534eab9d1844e77516efbc42055&quot; hreflang=&quot;en&quot;&gt;patch&lt;/a&gt; just has been commited by fenrir.
&lt;br /&gt;
With this new patch, VLMC moved to a unstable-creeping software to something a lot more stable. No more freeze when loading a video, which is good :)
&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;In addition, a tiny patch has just been commit, this is really not a big deal, but I really wonder why this wasn't like this in the first place :o A filename must be const...
&lt;br /&gt;
As this wasn't the case, we ended up doing things like this&amp;nbsp;:&lt;/p&gt;
&lt;pre class=&quot;cpp&quot;&gt;QTemporaryFile tmp;
tmp.&lt;span style=&quot;color: #00eeff;&quot;&gt;setAutoRemove&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;false&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;;
tmp.&lt;span style=&quot;color: #00eeff;&quot;&gt;open&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;;
&lt;span style=&quot;color: #0000dd;&quot;&gt;strncpy&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;m_tmpSnapshotFilename, tmp.&lt;span style=&quot;color: #00eeff;&quot;&gt;fileName&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #00eeff;&quot;&gt;toStdString&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #00eeff;&quot;&gt;c_str&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;, tmp.&lt;span style=&quot;color: #00eeff;&quot;&gt;fileName&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #00eeff;&quot;&gt;length&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;;
m_mediaPlayer&lt;span style=&quot;color: #000040;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt;takeSnapshot&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt; m_tmpSnapshotFilename, &lt;span style=&quot;color: #0000dd;&quot;&gt;32&lt;/span&gt;, &lt;span style=&quot;color: #0000dd;&quot;&gt;32&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/pre&gt;

&lt;p&gt;Since the takeSnapshot parameter cannot be const, we have to copy it and pass it as a non const parameter... sigh :(
However, this is fixed :)&lt;/p&gt;


&lt;p&gt;&lt;a href=&quot;http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=deabbf7d1dcb6b83ec7e8e4d67b260a13e840910&quot; hreflang=&quot;en&quot;&gt;Patch reference&lt;/a&gt;&lt;/p&gt;</description>
    
    
    
      </item>
    
  <item>
    <title>Using VLC with Qt-Creator</title>
    <link>http://www.mustelidae.fr/index.php?post/2009/04/30/Using-VLC-with-Qt-Creator</link>
    <guid isPermaLink="false">urn:md5:958814b166a8e1112e6481f047fe1070</guid>
    <pubDate>Thu, 30 Apr 2009 16:32:00 +0100</pubDate>
    <dc:creator>Hugo</dc:creator>
        <category>VideoLAN</category>
        <category>GSoC</category><category>VLC</category>    
    <description>&lt;p&gt;QtCreator is great, really really great, so why don't using it when browsing/editing/patching vlc source code&amp;nbsp;?
This article is based on the original Jean-Baptiste Kempf post, in the vlc-devel mailing list.&lt;/p&gt;    &lt;p&gt;I feel like I'm gonna have to look into the VLC source code very soon...
&lt;br /&gt;
A &quot;problem&quot; I came across is that once you've launch the playback with libvlc_media_player_play, you have to let the first frame render before accessing the &quot;vlc message pump&quot; again (ie the Control_Pop and co).&lt;/p&gt;


&lt;p&gt;It would be nice if I could provide a patch to look at the control stack *before* anything is done... however, I will have to browse some pieces of the VLC source code, and I'm kinda sick of greping and filtering the results by hand... Since Qt-Creator can be used with VLC, this is a good occasion to set it up&amp;nbsp;!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Step 1: Launch Qt-Creator :D&lt;/li&gt;
&lt;li&gt;Step 2: Create a new session (that can be seen as a sort of visual studio solution) named VLC (or whatever you wan't actually) =&amp;gt; File -&amp;gt; session -&amp;gt; session manager -&amp;gt; add. The new session is set as the current one.&lt;/li&gt;
&lt;li&gt;Step 3: If you haven't already, create a build subdir into your VLC directory&amp;nbsp;:&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;q&gt;$&amp;gt; mkdir build &amp;amp;&amp;amp; cd build &amp;amp;&amp;amp; ../bootstrap &amp;amp;&amp;amp; ../configure&lt;/q&gt; and wait a few minutes :)&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Step 4: Import the VLC project&amp;nbsp;: File -&amp;gt; new&amp;nbsp;; Project/Import of Makefile-based Project&amp;nbsp;; Select your VLC dir as the project path, and name your newly imported project VLC&lt;/li&gt;
&lt;li&gt;Step 5: close Qt-Creator&lt;/li&gt;
&lt;li&gt;Step 6: Download those to files&amp;nbsp;: &lt;a href=&quot;http://people.videolan.org/~jb/QtCreator/VLC.files&quot;&gt;http://people.videolan.org/~jb/QtCreator/VLC.files&lt;/a&gt; and &lt;a href=&quot;http://people.videolan.org/~jb/QtCreator/VLC.includes&quot;&gt;http://people.videolan.org/~jb/QtCreator/VLC.includes&lt;/a&gt; inside your VLC dir (you should have to overwrite the ones Qt-Creator just generated&lt;/li&gt;
&lt;li&gt;Step 7: Relaunch Qt-Creator&lt;/li&gt;
&lt;li&gt;Step 8: Reload your last session (Should be the one you just created)&lt;/li&gt;
&lt;li&gt;Step 9: Setup the build configuration&amp;nbsp;: go to the big &quot;project&quot; button on the left, and adjust the field &quot;Build directory&quot; to your vlc build dir.&lt;br /&gt;Go to the &quot;run settings&quot; tab, and create a new run configuration by clicking the blue &quot;+&quot; button. Name: VLC, Excutable: /path/to/your/vlc/build/vlc&lt;br /&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;j-b advised to add &quot;-lqt&quot; as the only argument, everytime I try, vlc just launched and quit, so I left the &quot;argument&quot; field empty.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Step 10: enjoy the &quot;ctrl + click&quot; on a symbol which brings you to its definition&amp;nbsp;! w00t !!&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.jbkempf.com/blog/post/2009/04/30/VLC-and-IDE&quot; hreflang=&quot;en&quot;&gt;Original post by Jean-Baptiste Kempf &lt;/a&gt;&lt;/p&gt;</description>
    
    
    
      </item>
    
  <item>
    <title>Getting into VLC source code</title>
    <link>http://www.mustelidae.fr/index.php?post/2009/04/30/Getting-into-VLC-source-code</link>
    <guid isPermaLink="false">urn:md5:139572feb9718654b1386f11afbee0fd</guid>
    <pubDate>Thu, 30 Apr 2009 10:54:00 +0100</pubDate>
    <dc:creator>Hugo</dc:creator>
        <category>VideoLAN</category>
            
    <description>&lt;p&gt;As VLMC is built uppon VLC, I'll frequently have to take a closer look at the source code...
At the moment, we have an annoying bug&amp;nbsp;: when we ask for a media player to play a media, it's supposed to fire a &quot;libvlc_MediaPlayerPlaying&quot; somehow (at least it works for most of the media), but it doesn't with a specific mpeg file... let's try understanding why o//&lt;/p&gt;    &lt;p&gt;&lt;br /&gt;
First, we'll have to locate the file in which libvlc_media_player_play is declared.
&lt;br /&gt;
Like most of the media_player functions, this one is located in &quot;src/control/media_player.c&quot;
&lt;br /&gt;
Let's start by analysing what is does&amp;nbsp;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Releasing the input thread (which is the thread that handle the media playback) in case a media was already playing.&lt;/li&gt;
&lt;li&gt;Creating a new input thread&lt;/li&gt;
&lt;li&gt;Adding a bunch of rendering related variables (we'll certainly have to go back to variables later)&lt;/li&gt;
&lt;li&gt;Adding 3 callbacks&amp;nbsp;: input_seekable_changed, input_pausable_changed, input_event_changed&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;br /&gt;
As far as i know, everything that's related to the media playback is managed by the input_thread, so let's take a closer look at the input_CreateThread() function...
&lt;br /&gt;
&lt;br /&gt;
This new function is located in &quot;src/input/input.c&quot;. It's actually some kind of a wrapper on the &quot;__input_CreateThreadExtended&quot; function, which is located 10lines below.
The only thing it does it to create a new thread, and launch it wich the &quot;Run&quot; function, which is located in the same file.
&lt;br /&gt;
&lt;br /&gt;
This Run function will call&amp;nbsp;: Init(), MainLoop(), and finally, End().
At this time, I really don't care about End(), so I'll focus on the Init and MainLoop functions, which are, once again, located in the same file.
&lt;br /&gt;
&lt;br /&gt;
If I'm not mistaking, VLC worlflow consists of getting an elementary stream from a demuxer (among many other things)
The init function creates the elementary streams (ES), creates 2 vlc-variables containing the bit-rate and the sample-rate.
&lt;br /&gt;
Once this is done, it changes the media state to &quot;Opening&quot;, and then call the InputSourceInit function.
&lt;br /&gt;
&lt;br /&gt;
This function is in charge of selecting the appropriate demux, or eventually selecting one that has been set by the command line. Selecting the demux is done by calling the demux_New() function. The selected demux is used to get a bunch of informations about the media, such as &quot;can-seek&quot;, &quot;can-pause&quot;... and do many other things that I don't really understand at the moment :(
&lt;br /&gt;
Let's go back to the Init function, and see what is does next...
&lt;br /&gt;
&lt;br /&gt;
Basically, it gets information about the file, init some stuff such as subtitles, and then changes the state to &quot;Playing&quot;, which is what isn't always working in vlmc...
I'm pretty confident that our problem is in this state change...
&lt;br /&gt;
&lt;br /&gt;
Even if this in kind of dirty, i'm going to add debug code to see what the hell happens in this function.
&lt;br /&gt;
&lt;br /&gt;
I'm going to add debug into the input_ChangeState, and to be sure that our problem isn't event related (and it seems like it, since the playback continues when we display the VLC debug lines...), into the input_SendEventState, which is located in the &quot;src/input/event.c&quot; file.
&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;The &quot;difficult&quot; thing is that the input_SendEventState uses vlc-variables, which is a really nice thing, but something that's hard to apprehend (or at least it was for me).
variable value is changed that way&amp;nbsp;:&lt;/p&gt;
&lt;pre class=&quot;c&quot;&gt;var_Change&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; p_input, &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;state&amp;quot;&lt;/span&gt;, VLC_VAR_SETVALUE, &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;amp;&lt;/span&gt;val, &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;NULL&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/pre&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;When the &quot;state&quot; var is changed, it triggers a callback... but which one ?!
Let's call or friend grep&amp;nbsp;: grep --color -HRn &quot;\&quot;state\&quot;&quot; src/*
Which highlight this line in particular&amp;nbsp;: src/input/var.c:87:    CALLBACK( &quot;state&quot;, StateCallback ),
Let's take a closer look... this callback calls &quot;input_ControlPush( p_input, INPUT_CONTROL_SET_STATE, &amp;amp;newval );&quot;, provided that the new state is PLAYING_S, or PAUSE_S.
&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;Good news everyone&amp;nbsp;! The state that was set is indeed PLAYING_S. We can keep going...
&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;input_ControlPush takes us back into input.c.
&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;What's the control inside vlc ?? The VLC playback thread has an array of struct input_control_t, that are executed by the thread, from the MainLoop().
This function will basically push a new control to be executed later... so this code is definitely asynchronous (did you still doubt it ?!)
&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;Ok no worries, let's go to the MainLoop code, and see how this control stack is handled...
&lt;br /&gt;
&lt;br /&gt;
MainLoop() is located in input.c (big file ain't it&amp;nbsp;? :p). At every iteration, it clears the control stack by calling ControlPop(), until the stack is empty.
The poped value is handled by the Control() function.
&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;Control function is basically a good old fashioned switch/case, in which we're going to seek for the control we pass.
We finally come down to this piece of code&amp;nbsp;:&lt;/p&gt;
&lt;pre class=&quot;c&quot;&gt;&lt;span style=&quot;color: #b1b100;&quot;&gt;case&lt;/span&gt; INPUT_CONTROL_SET_STATE&lt;span style=&quot;color: #66cc66;&quot;&gt;:&lt;/span&gt;
    &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; val.&lt;span style=&quot;color: #202020;&quot;&gt;i_int&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;==&lt;/span&gt; PLAYING_S &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; p_input&lt;span style=&quot;color: #66cc66;&quot;&gt;-&lt;/span&gt;&amp;gt;p&lt;span style=&quot;color: #66cc66;&quot;&gt;-&lt;/span&gt;&amp;gt;i_state &lt;span style=&quot;color: #66cc66;&quot;&gt;==&lt;/span&gt; PAUSE_S &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; ||
        &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; val.&lt;span style=&quot;color: #202020;&quot;&gt;i_int&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;==&lt;/span&gt; PAUSE_S &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; p_input&lt;span style=&quot;color: #66cc66;&quot;&gt;-&lt;/span&gt;&amp;gt;p&lt;span style=&quot;color: #66cc66;&quot;&gt;-&lt;/span&gt;&amp;gt;i_state &lt;span style=&quot;color: #66cc66;&quot;&gt;==&lt;/span&gt; PAUSE_S &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
    &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
        ControlUnpause&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; p_input, i_control_date &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
&amp;nbsp;
        b_force_update &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;true&lt;/span&gt;;
    &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
    &lt;span style=&quot;color: #b1b100;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; val.&lt;span style=&quot;color: #202020;&quot;&gt;i_int&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;==&lt;/span&gt; PAUSE_S &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; p_input&lt;span style=&quot;color: #66cc66;&quot;&gt;-&lt;/span&gt;&amp;gt;p&lt;span style=&quot;color: #66cc66;&quot;&gt;-&lt;/span&gt;&amp;gt;i_state &lt;span style=&quot;color: #66cc66;&quot;&gt;==&lt;/span&gt; PLAYING_S &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/* &amp;amp;&amp;amp;
              p_input-&amp;gt;p-&amp;gt;b_can_pause */&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
    &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
        ControlPause&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; p_input, i_control_date &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
&amp;nbsp;
        b_force_update &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;true&lt;/span&gt;;
    &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
    &lt;span style=&quot;color: #b1b100;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; val.&lt;span style=&quot;color: #202020;&quot;&gt;i_int&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;==&lt;/span&gt; PAUSE_S &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;!&lt;/span&gt;p_input&lt;span style=&quot;color: #66cc66;&quot;&gt;-&lt;/span&gt;&amp;gt;p&lt;span style=&quot;color: #66cc66;&quot;&gt;-&lt;/span&gt;&amp;gt;b_can_pause &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
    &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
        b_force_update &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;true&lt;/span&gt;;
&amp;nbsp;
        &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/* Correct &amp;quot;state&amp;quot; value */&lt;/span&gt;
        input_ChangeState&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; p_input, p_input&lt;span style=&quot;color: #66cc66;&quot;&gt;-&lt;/span&gt;&amp;gt;p&lt;span style=&quot;color: #66cc66;&quot;&gt;-&lt;/span&gt;&amp;gt;i_state &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
    &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
    &lt;span style=&quot;color: #b1b100;&quot;&gt;else&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; val.&lt;span style=&quot;color: #202020;&quot;&gt;i_int&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;!=&lt;/span&gt; PLAYING_S &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; val.&lt;span style=&quot;color: #202020;&quot;&gt;i_int&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;!=&lt;/span&gt; PAUSE_S &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
    &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
        msg_Err&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; p_input, &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;invalid state in INPUT_CONTROL_SET_STATE&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
    &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
    &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;break&lt;/span&gt;;&lt;/pre&gt;


&lt;p&gt;This is were we're going to put our second piece of debug.
Now let's build'n pray&amp;nbsp;!
&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;As expected, the second debug output isn't displayed... just have to figure out why :)
Since this will consist only of putting debug text here and there, I'll skip the details, and only explain the problem :p
&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;In the end, the problem seems to be a race condition inside the libvlc_media_player_play() function code... More precisely&amp;nbsp;:&lt;/p&gt;
&lt;pre class=&quot;c&quot;&gt;&lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt; libvlc_media_player_play&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; libvlc_media_player_t &lt;span style=&quot;color: #66cc66;&quot;&gt;*&lt;/span&gt;p_mi,
                                 libvlc_exception_t &lt;span style=&quot;color: #66cc66;&quot;&gt;*&lt;/span&gt;p_e &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
    input_thread_t &lt;span style=&quot;color: #66cc66;&quot;&gt;*&lt;/span&gt; p_input_thread;
&amp;nbsp;
    &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;p_input_thread &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; libvlc_get_input_thread&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; p_mi, p_e &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
    &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//stoping the thread, releasing the old media...&lt;/span&gt;
    &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
    &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//Some stuff&lt;/span&gt;
&amp;nbsp;
    &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//Creates the thread, thats spawn onto the Run() function, which will call Init() (which basically send the event)&lt;/span&gt;
    p_mi&lt;span style=&quot;color: #66cc66;&quot;&gt;-&lt;/span&gt;&amp;gt;p_input_thread &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; input_CreateThread&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;
            p_mi&lt;span style=&quot;color: #66cc66;&quot;&gt;-&lt;/span&gt;&amp;gt;p_libvlc_instance&lt;span style=&quot;color: #66cc66;&quot;&gt;-&lt;/span&gt;&amp;gt;p_libvlc_int, p_mi&lt;span style=&quot;color: #66cc66;&quot;&gt;-&lt;/span&gt;&amp;gt;p_md&lt;span style=&quot;color: #66cc66;&quot;&gt;-&lt;/span&gt;&amp;gt;p_input_item &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
&amp;nbsp;
    &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;!&lt;/span&gt;p_mi&lt;span style=&quot;color: #66cc66;&quot;&gt;-&lt;/span&gt;&amp;gt;p_input_thread &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
    &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
        vlc_mutex_unlock&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;amp;&lt;/span&gt;p_mi&lt;span style=&quot;color: #66cc66;&quot;&gt;-&lt;/span&gt;&amp;gt;object_lock &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
        &lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt;;
    &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
    p_input_thread &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; p_mi&lt;span style=&quot;color: #66cc66;&quot;&gt;-&lt;/span&gt;&amp;gt;p_input_thread;
&amp;nbsp;
    &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//Another block of stuff&lt;/span&gt;
&amp;nbsp;
    &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//Setting the callbacks	&lt;/span&gt;
    var_AddCallback&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; p_input_thread, &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;can-seek&amp;quot;&lt;/span&gt;, input_seekable_changed, p_mi &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
    var_AddCallback&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; p_input_thread, &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;can-pause&amp;quot;&lt;/span&gt;, input_pausable_changed, p_mi &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
    var_AddCallback&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; p_input_thread, &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;intf-event&amp;quot;&lt;/span&gt;, input_event_changed, p_mi &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
&amp;nbsp;
    vlc_mutex_unlock&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;amp;&lt;/span&gt;p_mi&lt;span style=&quot;color: #66cc66;&quot;&gt;-&lt;/span&gt;&amp;gt;object_lock &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;In all my tests, the call to var_AddCallback was made *after* the Init function completed, which is baaaaad, since no event can be fired.
&lt;br /&gt;
&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;Anyway, a mail has been sent to the vlc-devel mailing list in order to get some instructions on how to fix this (I don't feel like fixing it on my own without asking for advice, since it's somehow a big big part of the libvlc, and it touches some critical part of vlc, IE. the input thread), This should be fixed very soon :)
&lt;br /&gt;&lt;/p&gt;


&lt;p&gt;This is a one-shot post, please forgive me if some incoherence appears ;)&lt;/p&gt;</description>
    
    
    
      </item>
    
  <item>
    <title>GSoC : Let's get started !</title>
    <link>http://www.mustelidae.fr/index.php?post/2009/04/27/GSoC-%3A-Let-s-get-started</link>
    <guid isPermaLink="false">urn:md5:224e33166199ed1d0f1f721de8ce0d7f</guid>
    <pubDate>Mon, 27 Apr 2009 07:27:00 +0100</pubDate>
    <dc:creator>Hugo</dc:creator>
        <category>GSoC</category>
            
    <description>    &lt;p&gt;Hi everyone&amp;nbsp;!&lt;/p&gt;


&lt;p&gt;It's been a looooong time since I've post anything arround... but this is about to stop, since I'm going to participate to the 2009 edition of the Google summer of code, for the VideoLAN project, more preciselly for the vlmc project (www.vlmc.org)&lt;/p&gt;


&lt;p&gt;Just a few words to present the project&amp;nbsp;: The aim is to provide a simple but powerfull video editing software, based on vlc.&lt;/p&gt;


&lt;p&gt;At this time, it doesn't do much, just video loading, getting a snapshot and some meta informations, and a basic timeline that doesn't do much either.&lt;/p&gt;


&lt;p&gt;In the next days, we will have to enable a basic workflow, so that we will be able to concatenate two videos. Once this is done, the fun part will begin&amp;nbsp;! My work during this gsoc will consist of conceiving an effects/transition API, add some functionnality to the timeline widget (in order to reflect whan can be done with the API), and probably many things that hasn't be though of right now :p&lt;/p&gt;


&lt;p&gt;I'll try to keep the blog updated, as the features appears on the project :)&lt;/p&gt;


&lt;p&gt;By the way, a big thanks to VideoLan association president Jean Baptiste Kempf, and to my mentor and friend, Ludovic Fauvet :)
Some kisses to the vlmc team, which will go on vacation this summer, while I'll be coding :D&lt;/p&gt;</description>
    
    
    
      </item>
    
  <item>
    <title>Cuda... episode 2</title>
    <link>http://www.mustelidae.fr/index.php?post/2008/10/05/Cuda-episode-2</link>
    <guid isPermaLink="false">urn:md5:7d936ff784aff29c490846de7d6c2c20</guid>
    <pubDate>Sun, 05 Oct 2008 15:16:00 +0100</pubDate>
    <dc:creator>Hugo</dc:creator>
        <category>GPU</category>
        <category>Cpp</category><category>cuda</category><category>GPU</category>    
    <description>&lt;p&gt;Le premier programme en cuda, c'est fait, maintenant il serait bon de ne pas avoir a se prendre la tete avec les allocations memoires, ou tout du moins les simplifier un peu...&lt;/p&gt;    &lt;p&gt;Ha aufait je vais ecrire en francais a partir de cet article, apres tout il n'y a pas d'articles en francais sur cuda (en tout cas pas la derniere fois que j'ai regarde :p) et puis ca me permettra surement d'etre plus clair.&lt;/p&gt;


&lt;p&gt;Donc, personnellement les cudaMemcpy, cudaFree etc, ca va 5minutes, mais ca va me gonfler de devoir taper cudaMemcpyHostToDevice a longueur de temps, donc je me suis code une petite classe pour faire officer de &quot;container&quot; cuda.
Il n'y aura rien d'extraordinaire la dedans, juste une petite classe fonctionnelle :)&lt;/p&gt;


&lt;p&gt;Un rapide &quot;cahier des charges&quot;, la classe doit pouvoir&amp;nbsp;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Envoyer des donnees vers la carte graphique&lt;/li&gt;
&lt;li&gt;S'occuper seule comme une grande d'allouer la memoire dans la memoire de la carte graphique&lt;/li&gt;
&lt;li&gt;liberer cet espace&lt;/li&gt;
&lt;li&gt;Permettre de recuperer le pointeur vers le device pour pouvoir appeler les kernels&lt;/li&gt;
&lt;li&gt;Pouvoir fonctionner avec n'importe quel type&lt;/li&gt;
&lt;li&gt;Recuperer les donnees traitees par la CG&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Ce qui nous donne la declaration de classe suivante&amp;nbsp;:&lt;/p&gt;
&lt;pre class=&quot;cpp&quot;&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;template&lt;/span&gt; &lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;typename&lt;/span&gt; T&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span style=&quot;color: #0000ff;&quot;&gt;class&lt;/span&gt;		CudaContainer
&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;
&lt;span style=&quot;color: #0000ff;&quot;&gt;public&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;:&lt;/span&gt;
	CudaContainer&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;T&lt;span style=&quot;color: #000040;&quot;&gt;*&lt;/span&gt; var, &lt;span style=&quot;color: #0000ff;&quot;&gt;size_t&lt;/span&gt; size&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;;
	CudaContainer&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;T&lt;span style=&quot;color: #000040;&quot;&gt;&amp;amp;&lt;/span&gt; var&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;;
	CudaContainer&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;size_t&lt;/span&gt; size&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;;
	~CudaContainer&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;;
	&lt;span style=&quot;color: #0000ff;&quot;&gt;void&lt;/span&gt;		sendToDevice&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;;
	&lt;span style=&quot;color: #0000ff;&quot;&gt;void&lt;/span&gt;		getFromDevice&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;;
	T&lt;span style=&quot;color: #000040;&quot;&gt;*&lt;/span&gt;		getHost&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;
	T&lt;span style=&quot;color: #000040;&quot;&gt;*&lt;/span&gt;		getDevice&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span style=&quot;color: #0000ff;&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;:&lt;/span&gt;
       &lt;span style=&quot;color: #666666;&quot;&gt;//probably more stuff here&lt;/span&gt;
&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;;&lt;/pre&gt;


&lt;p&gt;ce qui une fois implemente, donne le fichier fourni en piece jointe de ce billet :)&lt;/p&gt;


&lt;p&gt;Je n'ai pas commente abusivement, je pense que les noms de methodes et des fonctions de l'API cuda sont assez clairs ;)&lt;/p&gt;


&lt;p&gt;Et voila le main du billet precedent, retouche pour fonctionner avec ce &quot;container&quot;&amp;nbsp;:&lt;/p&gt;

&lt;pre class=&quot;c&quot;&gt;&lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt;		main&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #993333;&quot;&gt;const&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; NbElems &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;100&lt;/span&gt;;
	&lt;span style=&quot;color: #993333;&quot;&gt;float&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;*&lt;/span&gt;toSquare &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; new &lt;span style=&quot;color: #993333;&quot;&gt;float&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;NbElems&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;;
	&lt;span style=&quot;color: #b1b100;&quot;&gt;for&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; i &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;; i &amp;lt; NbElems; &lt;span style=&quot;color: #66cc66;&quot;&gt;++&lt;/span&gt;i&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
		toSquare&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;i&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #993333;&quot;&gt;float&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;i;
&amp;nbsp;
	CudaContainer&amp;lt;float&amp;gt;		c&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;toSquare, &lt;span style=&quot;color: #993333;&quot;&gt;sizeof&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #993333;&quot;&gt;float&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;*&lt;/span&gt; NbElems&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
	c.&lt;span style=&quot;color: #202020;&quot;&gt;sendToDevice&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//Cuda Kernel execution&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
		dim3 blockSize&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;5&lt;/span&gt;, &lt;span style=&quot;color: #cc66cc;&quot;&gt;5&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
		&lt;span style=&quot;color: #993333;&quot;&gt;const&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; nbThreads &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; blockSize.&lt;span style=&quot;color: #202020;&quot;&gt;x&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;*&lt;/span&gt; blockSize.&lt;span style=&quot;color: #202020;&quot;&gt;y&lt;/span&gt;;
		&lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; nbBlocks &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; NbElems &lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt; nbThreads &lt;span style=&quot;color: #66cc66;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;NbElems &lt;span style=&quot;color: #66cc66;&quot;&gt;%&lt;/span&gt; nbThreads &lt;span style=&quot;color: #66cc66;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt; ? &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
		SquareArray&amp;lt;&amp;lt;&amp;lt;nbBlocks, blockSize&amp;gt;&amp;gt;&amp;gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;c.&lt;span style=&quot;color: #202020;&quot;&gt;getDevice&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;, NbElems&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
	c.&lt;span style=&quot;color: #202020;&quot;&gt;getFromDevice&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
	&lt;span style=&quot;color: #b1b100;&quot;&gt;for&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; i &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;; i &amp;lt; NbElems; &lt;span style=&quot;color: #66cc66;&quot;&gt;++&lt;/span&gt;i&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
		std&lt;span style=&quot;color: #66cc66;&quot;&gt;::&lt;/span&gt;&lt;a href=&quot;http://www.opengroup.org/onlinepubs/009695399/functions/cout.html&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;cout&lt;/span&gt;&lt;/a&gt; &amp;lt;&amp;lt; i &amp;lt;&amp;lt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot; =&amp;gt; &amp;quot;&lt;/span&gt; &amp;lt;&amp;lt; toSquare&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;i&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt; &amp;lt;&amp;lt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;;
	std&lt;span style=&quot;color: #66cc66;&quot;&gt;::&lt;/span&gt;&lt;a href=&quot;http://www.opengroup.org/onlinepubs/009695399/functions/cout.html&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;cout&lt;/span&gt;&lt;/a&gt;.&lt;span style=&quot;color: #202020;&quot;&gt;flush&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Ce qui, a mes yeux, est toujours un peu plus agreable a lire/utiliser, qu'avec les fonctions initiales :)&lt;/p&gt;</description>
    
    
    
      </item>
    
  <item>
    <title>Shader loading class</title>
    <link>http://www.mustelidae.fr/index.php?post/2008/10/01/Shader-loading-class</link>
    <guid isPermaLink="false">urn:md5:bc0393269e2d7488301bc1c58d9043ff</guid>
    <pubDate>Wed, 01 Oct 2008 22:52:00 +0100</pubDate>
    <dc:creator>Hugo</dc:creator>
        <category>C++</category>
            
    <description>&lt;p&gt;For a little project I'll probably speak about here someday, I wrote a shader loading class to ease my pain, as i was discovering shaders...&lt;/p&gt;    &lt;p&gt;I didn't wan't to bother loading shaders to try them, so I decided to write a class to do this for me once and for all.&lt;/p&gt;


&lt;p&gt;Just as a reminder, a shader is a piece of code that will be executed by your graphical controller, instead of what's called the fixed function pipeline, which consists of a set of instructions for the vertice (object space to screen space, basic lighting), and a set of instructions for the fragments -aka pixels- (applying textures, fog, color blending).&lt;/p&gt;


&lt;p&gt;You can write your shader in GLSL (openGL Shading Language), HLSL (High Level Shader Language, for DirectX), and CG (C for Graphics), which is the nvidia language, that will be compiled in binary code that can match with the ones generated by GLSL or HLSL compiler (but it does fail to sometimes :p )&lt;/p&gt;


&lt;p&gt;The language i used at this time was GLSL, because it seemed to me that it would be easier to apprehend than HLSL, and I didn't really knew what CG was about...&lt;/p&gt;


&lt;p&gt;This is basic c++, no killer language feature here, no pownage algorithm.
Source can be found at the bottom.&lt;/p&gt;


&lt;p&gt;It can be used like this&amp;nbsp;:&lt;/p&gt;

&lt;pre class=&quot;cpp&quot;&gt;Shaders&lt;span style=&quot;color: #000040;&quot;&gt;*&lt;/span&gt; shad &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000dd;&quot;&gt;new&lt;/span&gt; Shaders&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;;
shad&lt;span style=&quot;color: #000040;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt;setPixelShader&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;quot;lightPS.glsl&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;;
shad&lt;span style=&quot;color: #000040;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt;setVertexShader&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;quot;lightVS.glsl&amp;quot;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;;
shad&lt;span style=&quot;color: #000040;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt;makeAll&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;;
&amp;nbsp;
&lt;span style=&quot;color: #666666;&quot;&gt;//......&lt;/span&gt;
&amp;nbsp;
shad&lt;span style=&quot;color: #000040;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt;enable&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;;
glBegin&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;GL_QUADS&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;;
glColor3ub&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000dd;&quot;&gt;0&lt;/span&gt;,&lt;span style=&quot;color: #0000dd;&quot;&gt;0&lt;/span&gt;,&lt;span style=&quot;color: #0000dd;&quot;&gt;255&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;; &lt;span style=&quot;color: #666666;&quot;&gt;//face bleue&lt;/span&gt;
glNormal3f&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000dd;&quot;&gt;0&lt;/span&gt;.&lt;span style=&quot;color: #00eeff;&quot;&gt;f&lt;/span&gt;, &lt;span style=&quot;color: #0000dd;&quot;&gt;1&lt;/span&gt;.&lt;span style=&quot;color: #00eeff;&quot;&gt;f&lt;/span&gt;, &lt;span style=&quot;color: #0000dd;&quot;&gt;0&lt;/span&gt;.&lt;span style=&quot;color: #00eeff;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;;
glVertex3d&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000dd;&quot;&gt;-10&lt;/span&gt;, &lt;span style=&quot;color: #0000dd;&quot;&gt;-1&lt;/span&gt;, &lt;span style=&quot;color: #0000dd;&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;;
glNormal3f&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000dd;&quot;&gt;0&lt;/span&gt;.&lt;span style=&quot;color: #00eeff;&quot;&gt;f&lt;/span&gt;, &lt;span style=&quot;color: #0000dd;&quot;&gt;1&lt;/span&gt;.&lt;span style=&quot;color: #00eeff;&quot;&gt;f&lt;/span&gt;, &lt;span style=&quot;color: #0000dd;&quot;&gt;0&lt;/span&gt;.&lt;span style=&quot;color: #00eeff;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;;
glVertex3d&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000dd;&quot;&gt;-10&lt;/span&gt;, &lt;span style=&quot;color: #0000dd;&quot;&gt;-1&lt;/span&gt;, &lt;span style=&quot;color: #0000dd;&quot;&gt;-10&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;;
glNormal3f&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000dd;&quot;&gt;0&lt;/span&gt;.&lt;span style=&quot;color: #00eeff;&quot;&gt;f&lt;/span&gt;, &lt;span style=&quot;color: #0000dd;&quot;&gt;1&lt;/span&gt;.&lt;span style=&quot;color: #00eeff;&quot;&gt;f&lt;/span&gt;, &lt;span style=&quot;color: #0000dd;&quot;&gt;0&lt;/span&gt;.&lt;span style=&quot;color: #00eeff;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;;
glVertex3d&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000dd;&quot;&gt;10&lt;/span&gt;,	&lt;span style=&quot;color: #0000dd;&quot;&gt;-1&lt;/span&gt;, &lt;span style=&quot;color: #0000dd;&quot;&gt;-10&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;;
glNormal3f&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000dd;&quot;&gt;0&lt;/span&gt;.&lt;span style=&quot;color: #00eeff;&quot;&gt;f&lt;/span&gt;, &lt;span style=&quot;color: #0000dd;&quot;&gt;1&lt;/span&gt;.&lt;span style=&quot;color: #00eeff;&quot;&gt;f&lt;/span&gt;, &lt;span style=&quot;color: #0000dd;&quot;&gt;0&lt;/span&gt;.&lt;span style=&quot;color: #00eeff;&quot;&gt;f&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;;
glVertex3d&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000dd;&quot;&gt;10&lt;/span&gt;,	&lt;span style=&quot;color: #0000dd;&quot;&gt;-1&lt;/span&gt;, &lt;span style=&quot;color: #0000dd;&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;;
&amp;nbsp;
glEnd&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;;
shad&lt;span style=&quot;color: #000040;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt;disable&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/pre&gt;


&lt;p&gt;and here is the test lighting shader i used for test&amp;nbsp;:&lt;/p&gt;


&lt;p&gt;Vertex shader&amp;nbsp;:&lt;/p&gt;
&lt;pre class=&quot;c&quot;&gt;varying vec3	normal;
varying vec3	vl;
&amp;nbsp;
&lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt;	main&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
	vec4	light &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; vec4&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;0.0&lt;/span&gt;, &lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;.&lt;span style=&quot;color: #202020;&quot;&gt;f&lt;/span&gt;, &lt;span style=&quot;color: #cc66cc;&quot;&gt;0.0&lt;/span&gt;, &lt;span style=&quot;color: #cc66cc;&quot;&gt;1.0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
&amp;nbsp;
	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/// Putting the normal in the world space&lt;/span&gt;
	normal &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; gl_NormalMatrix &lt;span style=&quot;color: #66cc66;&quot;&gt;*&lt;/span&gt; gl_Normal;
       &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/// Calculating the vertex position in world space&lt;/span&gt;
	vec3 point &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; gl_ModelViewMatrix &lt;span style=&quot;color: #66cc66;&quot;&gt;*&lt;/span&gt; gl_Vertex;
       &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/// calculating the vertex-light ray&lt;/span&gt;
	vl &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;gl_ModelViewMatrix &lt;span style=&quot;color: #66cc66;&quot;&gt;*&lt;/span&gt; light&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;.&lt;span style=&quot;color: #202020;&quot;&gt;xyz&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;-&lt;/span&gt; point;
       &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/// Calculating the vertex position in the projection space&lt;/span&gt;
	gl_Position &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; gl_ModelViewProjectionMatrix &lt;span style=&quot;color: #66cc66;&quot;&gt;*&lt;/span&gt; gl_Vertex;
       &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/// Passing the color of the vertex to the fragment shader&lt;/span&gt;
	gl_FrontColor &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; gl_Color;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Fragment/Pixel shader&amp;nbsp;:&lt;/p&gt;
&lt;pre class=&quot;c&quot;&gt;varying vec3	normal;
varying vec3	vl;
&amp;nbsp;
&lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt;	main&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/// normalizing both vectors to have a correct dot product result&lt;/span&gt;
	vec3 n &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; normalize&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;normal&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
	vec3 lvect &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; normalize&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;vl&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
       &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/// We get the angle between both vectors by using dot product, and clamping it between 0 and 1 to be sure&lt;/span&gt;
	&lt;span style=&quot;color: #993333;&quot;&gt;float&lt;/span&gt; factor &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; clamp&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;dot&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;n, lvect&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;, &lt;span style=&quot;color: #cc66cc;&quot;&gt;0.0&lt;/span&gt;, &lt;span style=&quot;color: #cc66cc;&quot;&gt;1.0&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
       &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;/// Finally, this angle is used to tweak the color, simulating the light&lt;/span&gt;
	gl_FragColor &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; gl_Color &lt;span style=&quot;color: #66cc66;&quot;&gt;*&lt;/span&gt; factor;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;with proper opengl initialisation and render, here is what we get&amp;nbsp;:
&lt;img src=&quot;http://www.mustelidae.fr/public/images/.lighting_m.jpg&quot; alt=&quot;lighting.jpg&quot; title=&quot;lighting.jpg, oct 2008&quot; /&gt;
Et voila&amp;nbsp;! o//&lt;/p&gt;</description>
    
    
    
      </item>
    
  <item>
    <title>First steps in CUDA</title>
    <link>http://www.mustelidae.fr/index.php?post/2008/09/18/My-first-step-in-CUDA</link>
    <guid isPermaLink="false">urn:md5:02643df8f78b9e1fd3d0a05fa0707666</guid>
    <pubDate>Thu, 18 Sep 2008 23:42:00 +0100</pubDate>
    <dc:creator>Hugo</dc:creator>
        <category>GPU</category>
        <category>cuda</category><category>GPU</category><category>Visual studio</category>    
    <description>&lt;p&gt;I really want to throw myself in CUDA, so here I go.
The first step will be to create a simple project, that runs under visual studio.&lt;/p&gt;    &lt;p&gt;First, I just want to have a working environment that works with cuda.
Since I don't want to fight with VS to handle cuda, i just searched for a VS2005 (sigh, cuda doesn't support VS2008 yet :'( ) project template.
I found this one, which was the google first guess&amp;nbsp;: http://forums.nvidia.com/index.php?showtopic=69183 It provides the Debug/Release/EmuDebug/EmuRelease modes, and the appropriated paths for compiling, which is exactly what i was looking for.&lt;/p&gt;


&lt;p&gt;Good surprise, i works perfectly. The provided sample compiles without any issue, but it won't launch itself, because it can't find &quot;cutild64.dll&quot;.
It seems that the SDK doesn't set the PATH so the system can find cuda's dlls... I don't want my cuda's dll to be somewhere in \system32 or anywhere else than the cuda sdk, so i will upgrade my env variables.
Go to the environment variable setting pannel (win key + pause key =&amp;gt; advanced =&amp;gt; env variables)
For the moment I will only add debug DLLs, in order to try.
I add a CUDA_DLL_PATH var that is equal to &quot;%NVSDKCUDA_ROOT%\bin\win64\Debug&quot;
and added the following to my Path variable&amp;nbsp;:
&quot;;%CUDA_DLL_PATH%&quot;&lt;/p&gt;


&lt;p&gt;After relaunching visual studio, it worked verry well. So let's add the release path, (before i forget to :D ) by adding
&quot;%NVSDKCUDA_ROOT%\bin\win64\Debug&quot; to your newly created CUDA_DLL_PATH
From now, I can compile and then launch CUDA project, after associating .cu files to visual c++, it's finally ok to start coding :)&lt;/p&gt;


&lt;p&gt;Now lets go into cuda itself...&lt;/p&gt;


&lt;p&gt;In order to launch code on the GPU, CUDA provides &quot;Kernels&quot;. These are function that you can call from the CPU, but that will be run on the GPU. These functions are declared by the &quot;&lt;strong&gt;global&lt;/strong&gt;&quot; keyword.&lt;/p&gt;


&lt;p&gt;The &quot;&lt;strong&gt;device&lt;/strong&gt;&quot; keywords means that the function will be callable from the GPU only, and run on it. The &quot;&lt;strong&gt;host&lt;/strong&gt;&quot; keyword means that the function will be callable from the CPU only, and run on it. &quot;&lt;strong&gt;host&lt;/strong&gt;&quot; is the default function qualifier. If you don't specify one, it will be &lt;strong&gt;host&lt;/strong&gt; by default.&lt;/p&gt;


&lt;p&gt;GPUs are highly parallel architectures, a high number of threads will run through your code, but you have to specify this number of threads. This is done when calling the kernel&amp;nbsp;:&lt;/p&gt;
&lt;pre class=&quot;c&quot;&gt;kernelFunctionName&amp;lt;&amp;lt;&amp;lt;blocksNumber, blockSize&amp;gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;params&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/pre&gt;


&lt;p&gt;It allows you to set your thread blocks parameters.
A thread block is... well it's a block containing threads :D
These informations are contained in a cuda special type called &quot;dim3&quot; which is basically an array of 3 integers.&lt;/p&gt;


&lt;p&gt;If you set your blockSize to &quot;dim3(5, 5)&quot; you will have 5 * 5 ( * 1, for the implicit Z dimension) = 25 threads.&lt;/p&gt;


&lt;p&gt;Then you can choose to create multiple threads blocks, by doing the same for the first kernel parameter (blocksNumber).&lt;/p&gt;


&lt;p&gt;A set of threads blocks is called a grid.&lt;/p&gt;


&lt;p&gt;If you choose dim3(2, 2) you will have 4 blocks of 25threads running through your code. Optimally choosing the right number of blocks and threads probably requires a high knowledge of the cuda doc, mostly the chapter 5, which is focused on optimisation.&lt;/p&gt;


&lt;p&gt;But if you call your kernel, you must have a way to get the results of your computation back. This is done by allocating memory on the device, copying data to it, and then copy the results back in the main memory. CUDA provides a set of functions for this purpose. The one I will use are&amp;nbsp;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;cudaMalloc(void** ptrToAlloc, size_t sizeToAlloc);&lt;/li&gt;
&lt;li&gt;cudaMemcpy(void* destination, void* source, size_t sizeToCopy, cudaMemcpyKind mode); //cudaMemcpyKind is an enum to set the copy mode (host to device, device to host...)&lt;/li&gt;
&lt;li&gt;cudaFree(void* ptrToFree);&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For a test, i will write a little main.cu which will square every elements in an array.&amp;nbsp;:&lt;/p&gt;


&lt;p&gt;First, the main itself. It consists of classic c/c++&lt;/p&gt;
&lt;pre class=&quot;c&quot;&gt;&lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt;		main&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//setting the number of elements to compute&lt;/span&gt;
	&lt;span style=&quot;color: #993333;&quot;&gt;const&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; NbElems &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;100&lt;/span&gt;;
        &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//classic c++ allocation of the data to compute&lt;/span&gt;
	&lt;span style=&quot;color: #993333;&quot;&gt;float&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;*&lt;/span&gt;toSquare &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; new &lt;span style=&quot;color: #993333;&quot;&gt;float&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;NbElems&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;;
	&lt;span style=&quot;color: #b1b100;&quot;&gt;for&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; i &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;; i &amp;lt; NbElems; &lt;span style=&quot;color: #66cc66;&quot;&gt;++&lt;/span&gt;i&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
		toSquare&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;i&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #993333;&quot;&gt;float&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;i;
	&lt;span style=&quot;color: #993333;&quot;&gt;float&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;*&lt;/span&gt;	device &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;NULL&lt;/span&gt;;
        &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//allocating memory on the device&lt;/span&gt;
	cudaMalloc&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;**&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;amp;&lt;/span&gt;device, &lt;span style=&quot;color: #993333;&quot;&gt;sizeof&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;*&lt;/span&gt;toSquare&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;*&lt;/span&gt; NbElems&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
        &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// and copying datas to this mevory space&lt;/span&gt;
	cudaMemcpy&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;device, toSquare, &lt;span style=&quot;color: #993333;&quot;&gt;sizeof&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;*&lt;/span&gt;toSquare&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;*&lt;/span&gt; NbElems, cudaMemcpyHostToDevice&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
	&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//Cuda Kernel execution&lt;/span&gt;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
                &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//we will have 5 * 5 threads blocks :&lt;/span&gt;
		dim3 blockSize&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #cc66cc;&quot;&gt;10&lt;/span&gt;, &lt;span style=&quot;color: #cc66cc;&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//Z dimension is implicitly 1&lt;/span&gt;
		&lt;span style=&quot;color: #993333;&quot;&gt;const&lt;/span&gt; &lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; nbThreads &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; blockSize.&lt;span style=&quot;color: #202020;&quot;&gt;x&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;*&lt;/span&gt; blockSize.&lt;span style=&quot;color: #202020;&quot;&gt;y&lt;/span&gt;;
               &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//we must have a grid containing enougth threads to compute every data, so the number of elements divided by the number of threads, and if it remains data to compute, we add one thread block&lt;/span&gt;
		&lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; nbBlocks &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; NbElems &lt;span style=&quot;color: #66cc66;&quot;&gt;/&lt;/span&gt; nbThreads &lt;span style=&quot;color: #66cc66;&quot;&gt;+&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;NbElems &lt;span style=&quot;color: #66cc66;&quot;&gt;%&lt;/span&gt; nbThreads &lt;span style=&quot;color: #66cc66;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt; ? &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;:&lt;/span&gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
               &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// and we launch the kernel !&lt;/span&gt;
		SquareArray&amp;lt;&amp;lt;&amp;lt;nbBlocks, blockSize&amp;gt;&amp;gt;&amp;gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;device, NbElems&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
	&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
        &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// getting the results back&lt;/span&gt;
	cudaMemcpy&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;toSquare, device, &lt;span style=&quot;color: #993333;&quot;&gt;sizeof&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;*&lt;/span&gt;toSquare&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;*&lt;/span&gt; NbElems, cudaMemcpyDeviceToHost&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
       &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;//and this doesn't need commentary i guess :p&lt;/span&gt;
	&lt;span style=&quot;color: #b1b100;&quot;&gt;for&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; i &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;; i &amp;lt; NbElems; &lt;span style=&quot;color: #66cc66;&quot;&gt;++&lt;/span&gt;i&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
		std&lt;span style=&quot;color: #66cc66;&quot;&gt;::&lt;/span&gt;&lt;a href=&quot;http://www.opengroup.org/onlinepubs/009695399/functions/cout.html&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;cout&lt;/span&gt;&lt;/a&gt; &amp;lt;&amp;lt; i &amp;lt;&amp;lt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot; =&amp;gt; &amp;quot;&lt;/span&gt; &amp;lt;&amp;lt; toSquare&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;i&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt; &amp;lt;&amp;lt; &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;;
	std&lt;span style=&quot;color: #66cc66;&quot;&gt;::&lt;/span&gt;&lt;a href=&quot;http://www.opengroup.org/onlinepubs/009695399/functions/cout.html&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;cout&lt;/span&gt;&lt;/a&gt;.&lt;span style=&quot;color: #202020;&quot;&gt;flush&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
       cudaFree&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;device&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
       delete&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt; toSquare;
       &lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;0&lt;/span&gt;;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;So we have our main code, but it misses a kernel to compile and run... Beside the &lt;strong&gt;global&lt;/strong&gt; qualifier, a cuda function is exactly the same as in C&amp;nbsp;:&lt;/p&gt;
&lt;pre class=&quot;c&quot;&gt;__global__ &lt;span style=&quot;color: #993333;&quot;&gt;void&lt;/span&gt;		SquareArray&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #993333;&quot;&gt;float&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;*&lt;/span&gt; in, &lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt; nb&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
	&lt;span style=&quot;color: #993333;&quot;&gt;int&lt;/span&gt;	id &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;blockIdx.&lt;span style=&quot;color: #202020;&quot;&gt;x&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;+&lt;/span&gt; blockIdx.&lt;span style=&quot;color: #202020;&quot;&gt;y&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;*&lt;/span&gt; blockDim.&lt;span style=&quot;color: #202020;&quot;&gt;x&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;*&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;blockDim.&lt;span style=&quot;color: #202020;&quot;&gt;x&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;*&lt;/span&gt; blockDim.&lt;span style=&quot;color: #202020;&quot;&gt;y&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
				&lt;span style=&quot;color: #66cc66;&quot;&gt;+&lt;/span&gt; blockDim.&lt;span style=&quot;color: #202020;&quot;&gt;x&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;*&lt;/span&gt; threadIdx.&lt;span style=&quot;color: #202020;&quot;&gt;y&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;+&lt;/span&gt; threadIdx.&lt;span style=&quot;color: #202020;&quot;&gt;x&lt;/span&gt;;
	&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;id &amp;lt; nb&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
		in&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;id&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;=&lt;/span&gt; in&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;id&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;*&lt;/span&gt; in&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;id&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;The first line is just to know the array of the current array index this kernel has do compute. Knowing the thread and blocks size and id allow a cuda code to run lock free, which is kinda fast :p&lt;/p&gt;


&lt;p&gt;Then there's just a &quot;bounds&quot; check, which, actually, isn't necessary. Without it the code will be executed just fine. Maybe there's a change in perfs, but I didn't pay attention to this yet.&lt;/p&gt;


&lt;p&gt;Now it's complete, both main and kernel are done, compile and run, and you've a nice &quot;array squarer&quot; in cuda&amp;nbsp;! Hurray&amp;nbsp;!&lt;/p&gt;


&lt;p&gt;Now the next step will be to abstract the memory stuff in a class, to ease the pain :p&lt;/p&gt;</description>
    
    
    
      </item>
    
  <item>
    <title>Calling contructor without parameter</title>
    <link>http://www.mustelidae.fr/index.php?post/2008/09/13/Calling-contructor-without-parameter</link>
    <guid isPermaLink="false">urn:md5:2ced35639c91a5bcdfcb27dac0678a0b</guid>
    <pubDate>Sat, 13 Sep 2008 15:29:00 +0100</pubDate>
    <dc:creator>Hugo</dc:creator>
        <category>C++</category>
        <category>Cpp</category>    
    <description>    &lt;p&gt;Maybe something like that already happens to you&amp;nbsp;: You wan't to build an instance of your class without calling the constructor&amp;nbsp;:&lt;/p&gt;
&lt;pre class=&quot;cpp&quot;&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;class&lt;/span&gt;   A
&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;
    &lt;span style=&quot;color: #0000ff;&quot;&gt;private&lt;/span&gt;&lt;span style=&quot;color: #008080;&quot;&gt;:&lt;/span&gt;
        A&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;;
        ~A&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;;
&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;;
&amp;nbsp;
&lt;span style=&quot;color: #0000ff;&quot;&gt;int&lt;/span&gt; main&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;
    A   a&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;;
&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;But this will compile on g++ without any problem... why is that&amp;nbsp;?
Because you're not building an instance of your class, your declaring a function called &quot;a&quot;, which will return an instance of A.
If you pass parameters, g++ will understand this a a constructor call, but if you wan't to call a 0 parameter constructor, you will have to call your CTOR without parenthesis...&lt;/p&gt;</description>
    
    
    
      </item>
    
  <item>
    <title>The almost useless c++ trick of the day</title>
    <link>http://www.mustelidae.fr/index.php?post/2008/09/03/The-almost-useless-c-trick-of-the-day</link>
    <guid isPermaLink="false">urn:md5:8cf2102c861e7bcb9fe8e9f88144444f</guid>
    <pubDate>Wed, 03 Sep 2008 23:37:00 +0100</pubDate>
    <dc:creator>Hugo</dc:creator>
        <category>C++</category>
        <category>Cpp</category><category>Tricks</category>    
    <description>    &lt;p&gt;When I learn c++, I remember my teacher telling&amp;nbsp;: &quot;A pure virtual method is a method without implementation&quot;, well that's not entirelly true...
Actually, you can have a method beeing both pure virtual, and implementated. How is that possible&amp;nbsp;? well i must say that I don't know, since every assertions I ever made concerning how a compiler handles pure virtual methods was using the fact that a pure virtual was a null pointer in the class vtable... since you can have a body in it, it's obviously not null anonyme...&lt;/p&gt;


&lt;p&gt;Anyway, implementing a pure virtual method is quite easy&amp;nbsp;:&lt;/p&gt;

&lt;pre class=&quot;cpp&quot;&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;class&lt;/span&gt;  A
&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;
&lt;span style=&quot;color: #0000ff;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #008080;&quot;&gt;:&lt;/span&gt;
	&lt;span style=&quot;color: #0000ff;&quot;&gt;virtual&lt;/span&gt;   &lt;span style=&quot;color: #0000ff;&quot;&gt;void&lt;/span&gt; pureVirtual&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000dd;&quot;&gt;0&lt;/span&gt;
        &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;
            std&lt;span style=&quot;color: #008080;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #0000dd;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;quot;Me love otters&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; std&lt;span style=&quot;color: #008080;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #00eeff;&quot;&gt;endl&lt;/span&gt;;
        &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;;&lt;/pre&gt;


&lt;p&gt;And this will compile without any problem&amp;nbsp;!&lt;/p&gt;


&lt;p&gt;The comportment of an implemented pure virtual method is quite simple, like any other pure virtual method, it prevents your class from beeing implemented.
So here you can't have&lt;/p&gt;
&lt;pre class=&quot;cpp&quot;&gt;A&lt;span style=&quot;color: #000040;&quot;&gt;*&lt;/span&gt; a &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000dd;&quot;&gt;new&lt;/span&gt; A&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/pre&gt;

&lt;p&gt;it would print the usual error message&amp;nbsp;: cannot instanciate abstract class.
But what you can do, is call the implementation from a inherithed class of A, so here, you could do&amp;nbsp;:&lt;/p&gt;
&lt;pre class=&quot;cpp&quot;&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;class&lt;/span&gt; B &lt;span style=&quot;color: #008080;&quot;&gt;:&lt;/span&gt; A
&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;
&lt;span style=&quot;color: #0000ff;&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #008080;&quot;&gt;:&lt;/span&gt;
	&lt;span style=&quot;color: #0000ff;&quot;&gt;virtual&lt;/span&gt;   &lt;span style=&quot;color: #0000ff;&quot;&gt;void&lt;/span&gt; pureVirtual&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;
        &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;
            std&lt;span style=&quot;color: #008080;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #0000dd;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;quot;Not pure virtual anymore&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; std&lt;span style=&quot;color: #008080;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #00eeff;&quot;&gt;endl&lt;/span&gt;;
            A&lt;span style=&quot;color: #008080;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #00eeff;&quot;&gt;pureVirtual&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;;
        &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;;
&amp;nbsp;
&lt;span style=&quot;color: #0000ff;&quot;&gt;int&lt;/span&gt; main&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;
&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;
    B&lt;span style=&quot;color: #000040;&quot;&gt;*&lt;/span&gt;b &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; &lt;span style=&quot;color: #0000dd;&quot;&gt;new&lt;/span&gt; B&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;;
    b&lt;span style=&quot;color: #000040;&quot;&gt;-&lt;/span&gt;&lt;span style=&quot;color: #000080;&quot;&gt;&amp;gt;&lt;/span&gt;pureVirtual&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;;    
&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;which would print&amp;nbsp;:&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;Not pure virtual anymore &lt;br /&gt;
Me love otters&lt;/p&gt;&lt;/blockquote&gt;


&lt;p&gt;And the worst part, is that even if a implemented pure virtual method seems a little bit of a non sense, not only it can be done, but it could be usefull, if you want to provide an interface with a default behavior, or probably many things else :)&lt;/p&gt;</description>
    
    
    
      </item>
    
  <item>
    <title>Of debugging efficiency</title>
    <link>http://www.mustelidae.fr/index.php?post/2008/08/30/Of-debugging-efficiency</link>
    <guid isPermaLink="false">urn:md5:5c43dfbaf0b31124dcb953e83c6fe98e</guid>
    <pubDate>Sat, 30 Aug 2008 22:52:00 +0100</pubDate>
    <dc:creator>Hugo</dc:creator>
        <category>Visual studio</category>    
    <description>&lt;p&gt;Important part of the developpment process is &quot;wasted&quot; in debugging.
The most used technique (or at least, the technique I most observed at school) is the good old printf technique, or for c++ programmers std::cout/cerr, but there are a few drawbacks with this technique&amp;nbsp;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;You need to recompile your code&lt;/li&gt;
&lt;li&gt;Both printf and std::cout are buffering the data you want to print, and in some case, it can hide your memory allocation bugs, and your code will run with the debug stuff, but will crash without.&lt;/li&gt;
&lt;li&gt;It's hard to get some informations about which function called this one, or about the entire callstack&lt;/li&gt;
&lt;li&gt;It's annoying to get the process id, but mostly the thread id, in case multithreaded program developpment.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But like every problem, there's a solution, that isn't used enough considering the advantages it offers.&lt;/p&gt;


&lt;p&gt;In visual studio, a breakpoint isn't just about pausing the execution when reached, it's a lot more, and I invite you to read the following arcticle&lt;/p&gt;    &lt;p&gt;As you certainly already know, you can put breakpoints in your code bu pressing F9, but sometimes, you want to break only if something is equal to a specific value, or if the value has changed since the last call, or anything else.
What I used to do was this sort of code&amp;nbsp;:&lt;/p&gt;
&lt;pre class=&quot;cpp&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;void&lt;/span&gt;   randomFunction&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;int&lt;/span&gt; value&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;  &lt;span style=&quot;color: #0000ff;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;value &lt;span style=&quot;color: #000080;&quot;&gt;==&lt;/span&gt; &lt;span style=&quot;color: #0000dd;&quot;&gt;1234&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;     std&lt;span style=&quot;color: #008080;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #0000dd;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;quot;Breakpoint&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; std&lt;span style=&quot;color: #008080;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #00eeff;&quot;&gt;endl&lt;/span&gt;; &lt;span style=&quot;color: #666666;&quot;&gt;//Here goes the breakpoint.&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;  &lt;span style=&quot;color: #666666;&quot;&gt;//...&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;


&lt;p&gt;or something like that&amp;nbsp;:&lt;/p&gt;
&lt;pre class=&quot;cpp&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;void&lt;/span&gt;  anotherFunction&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;int&lt;/span&gt; value&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;  &lt;span style=&quot;color: #0000ff;&quot;&gt;static&lt;/span&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;int&lt;/span&gt; debugValue;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&amp;nbsp;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;  &lt;span style=&quot;color: #0000ff;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;value &lt;span style=&quot;color: #000040;&quot;&gt;!&lt;/span&gt;&lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; debugValue&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;    std&lt;span style=&quot;color: #008080;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #0000dd;&quot;&gt;cout&lt;/span&gt; &lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span style=&quot;color: #FF0000;&quot;&gt;&amp;quot;Changed value&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000080;&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; std&lt;span style=&quot;color: #008080;&quot;&gt;::&lt;/span&gt;&lt;span style=&quot;color: #00eeff;&quot;&gt;endl&lt;/span&gt;; &lt;span style=&quot;color: #666666;&quot;&gt;//Another breakpoint&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;  debugValue &lt;span style=&quot;color: #000080;&quot;&gt;=&lt;/span&gt; value;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;  &lt;span style=&quot;color: #666666;&quot;&gt;//...&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;


&lt;p&gt;And then put some breakpoints where they should be.
But visual studio (since, i guess, 2005 version) allows you to do nice stuff with your breakpoints.
You have a nice set of options if you right click on your breakpoint.
You can set a breaking condition by clicking... condition.&lt;/p&gt;


&lt;p&gt;Here is what you will get&amp;nbsp;: (sorry for the french version of VS...)&lt;/p&gt;


&lt;p&gt;&lt;a href=&quot;http://www.mustelidae.fr/public/images/condition.jpg&quot;&gt;&lt;img src=&quot;http://www.mustelidae.fr/public/images/.condition_m.jpg&quot; alt=&quot;condition.jpg&quot; title=&quot;condition.jpg, aoû 2008&quot; /&gt;&lt;/a&gt;
Here, I want to break only if value == 0, so i just have to set this as my condition.
You will notice the little &quot;plus&quot; icone of your breakpoint, which means this breakpoint is now conditionnal, and will only be triggered when your condition is satisfied.&lt;/p&gt;


&lt;p&gt;If you want to check that your value hasn't change (or has changed), you can select &quot;has changed&quot;. Your breakpoint will now be triggered when the comparaison is different from the last one.
For an exemple, if i change my main to this&amp;nbsp;:&lt;/p&gt;
&lt;pre class=&quot;cpp&quot;&gt;&lt;ol&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;int&lt;/span&gt;		main&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	testFunc1&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000dd;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	testFunc1&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000dd;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	testFunc1&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000dd;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;	testFunc1&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000dd;&quot;&gt;2&lt;/span&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#41;&lt;/span&gt;;&lt;/div&gt;&lt;/li&gt;&lt;li style=&quot;font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;&quot;&gt;&lt;div style=&quot;font-family: 'Courier New', Courier, monospace; font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #008000;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;

&lt;p&gt;It will be trigged after the second call, since now value is really equal to zero, not the third, because value is still equal to zero, and the 4th and last time, because 2 isn't equal to zero, so the condition result changed from true to false&lt;/p&gt;


&lt;p&gt;Another nice feature is the tracepoint, which is a breakpoint that doesn't break...
in the break point right click menu, select &quot;when hit&quot;
Once you're here, you will get this screen&amp;nbsp;:&lt;/p&gt;


&lt;p&gt;&lt;a href=&quot;http://www.mustelidae.fr/public/images/whenhit.jpg&quot;&gt;&lt;img src=&quot;http://www.mustelidae.fr/public/images/.whenhit_s.jpg&quot; alt=&quot;whenhit.jpg&quot; title=&quot;whenhit.jpg, aoû 2008&quot; /&gt;&lt;/a&gt;&lt;/p&gt;


&lt;p&gt;If you check &quot;Print a message&quot;, you will be able to trace your code, like you can with printf, but this won't require code modification, so no need to build your code again. This is more appreciable when you want to add trace in a header file, containing your templates function for examples, and you don't want to rebuild your entire project.
The huge drawback of this method is that is slows your program &lt;strong&gt;a lot&lt;/strong&gt;&lt;/p&gt;


&lt;p&gt;You can also break after a number of calls, only from a given thread id... this is a powerful tool :)&lt;/p&gt;


&lt;p&gt;If you just discovered this feature, i hope you will use it a lot (but let's hope you won't have to ;) )&lt;/p&gt;</description>
    
    
    
      </item>
    
  <item>
    <title>OpenCL</title>
    <link>http://www.mustelidae.fr/index.php?post/2008/08/10/OpenCL</link>
    <guid isPermaLink="false">urn:md5:a8035bebba681fadde8e865239d48d21</guid>
    <pubDate>Sun, 10 Aug 2008 01:06:00 +0100</pubDate>
    <dc:creator>Hugo</dc:creator>
        <category>GPU</category>
        <category>GPU</category>    
    <description>    &lt;p&gt;Hi all,
With almost 2 month late, i would like to point out the great news that OpenCL is :&lt;br /&gt;
Right now, the GP/GPU solutions are&amp;nbsp;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;CUDA for NVidia hardware&lt;/li&gt;
&lt;li&gt;CTM for AMD(ATI) hardware&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;which is sad for developpers, since we (and by we, I mostly mean I) don't want to have to use 2 APIs, and 2 languages, of different abstraction levels (CUDA is &quot;high&quot; level, where CTM is close to hardware (or to metal in that case \o/))&lt;br /&gt;
Considering NVidia goes well with CUDA, we could have bet on CTM death, but what's gonna happen is far better&amp;nbsp;: OpenCL will born &quot;soon&quot;, and will provide a unify way to use your GPU's power.&lt;br /&gt;
Gigaflop and mass parallel programming, here we are&amp;nbsp;! (as soon as specification and compiler will be out, which lets us a few years at least)&lt;/p&gt;


&lt;p&gt;Let's wish good luck to the &lt;a href=&quot;http://www.khronos.org/&quot; hreflang=&quot;en&quot;&gt;Khronos group&lt;/a&gt; which have to write the standards&amp;nbsp;!&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/OpenCL&quot; hreflang=&quot;en&quot;&gt;OpenCL &lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/CUDA&quot; hreflang=&quot;en&quot;&gt;CUDA&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Close_to_Metal&quot; hreflang=&quot;en&quot;&gt;CTM&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description>
    
    
    
      </item>
    
  <item>
    <title>Hello World</title>
    <link>http://www.mustelidae.fr/index.php?post/2008/08/06/Hello-World</link>
    <guid isPermaLink="false">urn:md5:b0cb80eac24fb4b242a1d207f90876d1</guid>
    <pubDate>Wed, 06 Aug 2008 22:12:00 +0100</pubDate>
    <dc:creator>Hugo</dc:creator>
            
    <description>    &lt;p&gt;Hi all,
Welcome on this blog. This isn't my first attempt, but i'll make my best to keep this one up to date.
This won't be much of a &quot;mylife&quot; blog. More likely, this will be a technical blog.&lt;/p&gt;


&lt;p&gt;But first of all, It would be best to introduce myself&amp;nbsp;:
I'm Hugo Beauzee-Luyssen, 21 years old, studying computer science in Epitech (Paris), and currently in internship at Ubisoft Paris, as a gameplay engineer.
I've felt a need to share my developer experience since for a while, and here it is.&lt;/p&gt;


&lt;p&gt;I'm currently working on a raytracer with a friend, this will be an excuse for writing a bunch of articles, but i'll write a new post a soon as i find a new trick, a new technique, or just something worth looking.&lt;/p&gt;


&lt;p&gt;Even if i'll do my best, I apologize for any grammatical mistakes that could haunt my posts ;)&lt;/p&gt;


&lt;p&gt;Ho and if you ask why mustelidae.fr, the answer is quite simple&amp;nbsp;: everyone has a favorite debug word. In my school, some use &quot;toto&quot;, others use &quot;bite&quot;, you can even find some &quot;chiche donne nous tout&quot;, but I prefer to use &quot;loutre&quot;, which is the french word for &quot;otter&quot;. Since I had to write course for 2nd year students, I used otters in every of my exemple, and so i was known as the man who loves otters.
As you probably don't know (or maybe you do ?) otters are from the mustelidae animal familly (http://en.wikipedia.org/wiki/Mustelidae), and this is why my website is &quot;mustelidae.fr&quot; :)&lt;/p&gt;


&lt;p&gt;I hope you'll enjoy reading the articles i'll post here, and event learn a few things&amp;nbsp;!&lt;/p&gt;</description>
    
    
    
      </item>
    
</channel>
</rss>