<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Abstract</title>
	<atom:link href="http://dranger003.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://dranger003.wordpress.com</link>
	<description>Kilobits of Life</description>
	<lastBuildDate>Thu, 25 Mar 2010 01:22:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='dranger003.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Abstract</title>
		<link>http://dranger003.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://dranger003.wordpress.com/osd.xml" title="Abstract" />
	<atom:link rel='hub' href='http://dranger003.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Converting Bluray to Matroska (MKV)</title>
		<link>http://dranger003.wordpress.com/2010/01/03/converting-bluray-to-matroska-mkv/</link>
		<comments>http://dranger003.wordpress.com/2010/01/03/converting-bluray-to-matroska-mkv/#comments</comments>
		<pubDate>Sun, 03 Jan 2010 19:13:19 +0000</pubDate>
		<dc:creator>dranger003</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Transcoding]]></category>

		<guid isPermaLink="false">http://dranger003.wordpress.com/?p=110</guid>
		<description><![CDATA[Since you may not want to spend over 300$ USD for a 25pk BD-R DL here&#8217;s how one can convert a Bluray to the well known Matroska format, bringing down the total size to 8.5GB. Of course, one may also just buy the Bluray&#8230; What you&#8217;ll need for this manual conversion guide: CUDA capable system [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dranger003.wordpress.com&amp;blog=8657040&amp;post=110&amp;subd=dranger003&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Since you may not want to spend <a href="http://www.amazon.com/s/ref=nb_ss?url=search-alias%3Daps&amp;field-keywords=bd-r+dl&amp;x=0&amp;y=0">over 300$ USD for a 25pk BD-R DL</a> here&#8217;s how one can convert a Bluray to the well known Matroska format, bringing down the total size to 8.5GB. Of course, one may also just buy the Bluray&#8230; <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>What you&#8217;ll need for this manual conversion guide:</p>
<ol>
<li><a href="http://www.nvidia.com/object/cuda_what_is.html">CUDA capable system</a></li>
<li><a href="http://www.cinemasquid.com/blu-ray/tools/bdinfo">Blu-ray Video and Audio Analysis Tool</a></li>
<li><a href="http://www.smlabs.net/tsmuxer_en.html">Demuxer</a></li>
<li><a href="http://neuron2.net/dgdecnv/dgdecnv.html">AVC/MPG/VC1 Decoder and Frame Server</a></li>
<li><a href="http://avisynth.org/mediawiki/Main_Page">AviSynth Frame Server</a></li>
<li><a href="http://x264.nl/">H.264 Video Encoder</a></li>
<li><a href="http://exar.ch/suprip/">Bluray Subtitle OCR Processor</a></li>
<li><a href="http://www.bunkus.org/videotools/mkvtoolnix/">Matroska Muxer</a></li>
</ol>
<p>First step is to find out where is the main movie inside the Bluray structure. Open up BDInfo and browse to the Bluray drive. Once scanning has completed you should be able to determine the main movie&#8217;s playlist by its length:</p>
<p><img class="alignnone size-medium wp-image-111" title="BDInfo v.0.5.3" src="http://dranger003.files.wordpress.com/2010/01/bdinfo-v-0-5-3-2.png?w=293&#038;h=300" alt="" width="293" height="300" /></p>
<p>In this case, there are 2 playlist with the same length however they both link to the same stream so we&#8217;ll just use 00000.mpls.  Next is to extract the chapter timecodes so click on &#8220;View Report&#8230;&#8221; and scroll to your main playlist. Once there, scroll down a bit and you should see the chapters listing:</p>
<pre>1               0:00:00.000     0:04:06.913     0 kbps          0 kbps          00:00:00.000    0 kbps          00:00:00.000    0 kbps          00:00:00.000    0 bytes         0 bytes         00:00:00.000
2               0:04:06.913     0:05:44.260     0 kbps          0 kbps          00:00:00.000    0 kbps          00:00:00.000    0 kbps          00:00:00.000    0 bytes         0 bytes         00:00:00.000
3               0:09:51.173     0:02:17.262     0 kbps          0 kbps          00:00:00.000    0 kbps          00:00:00.000    0 kbps          00:00:00.000    0 bytes         0 bytes         00:00:00.000
...</pre>
<p>Copy/paste the chapters listing into a text file and put it aside for now. We&#8217;ll need it at the end during the muxing phase.</p>
<p>Now that we know which playlist to process we need to demux its linked stream. Open up tsMuxer GUI and add your main movie playlist file:</p>
<p><img class="alignnone size-medium wp-image-112" title="tsMuxeR GUI 1.10.6" src="http://dranger003.files.wordpress.com/2010/01/tsmuxer-gui-1-10-6.png?w=295&#038;h=300" alt="" width="295" height="300" /></p>
<p>Now uncheck all the streams except for the video/audio/subtitles you&#8217;re interested in then under &#8220;Output&#8221; select &#8220;Demux&#8221; then set your output folder and click &#8220;Start demuxing&#8221;. Now is a good time to take a break as this may take some time.</p>
<p>Once everything is demuxed load DGIndexNV and open the video stream (may be saved as .264 or .vc1):</p>
<p><img class="alignnone size-medium wp-image-113" title="DGIndexNV" src="http://dranger003.files.wordpress.com/2010/01/untitled-2-2.png?w=300&#038;h=200" alt="" width="300" height="200" /></p>
<p>Next go to File -&gt; Save Project and save your project as .DGI file. This may also take some time.</p>
<p>Now create a new AviSynth script that looks something like this:</p>
<pre>LoadPlugin("C:\Program Files (x86)\AviSynth 2.5\plugins\DGDecodeNV.dll")
DGSource("00115.track_4113.dgi")
Crop(0, 20, -0, -20)</pre>
<p>In my case I used the &#8220;Crop&#8221; function to strip out tiny black borders. Be warned that if you also do so your <a href="http://en.wikipedia.org/wiki/Aspect_ratio_%28image%29">DAR</a> will be affected and will need to be adjusted accordingly. In my case it went from 1.78 (16:9) to 1.85 (24:13). Also, in order for DGDecodeNV to work you&#8217;ll need to fire up CUVIDServer.exe which comes with DGIndexNV.</p>
<p>Now is the time to re-encode the video stream. Use a bitrate calculator to find out the bitrate you should be using to fit this converted movie onto the media of your choice. I used this very basic <a href="http://www.videohelp.com/calc.htm">calculator</a>:</p>
<p><img class="alignnone size-medium wp-image-114" title="Bitrate Calculator" src="http://dranger003.files.wordpress.com/2010/01/windowclipping.png?w=300&#038;h=87" alt="" width="300" height="87" /></p>
<p>Next open up a command prompt to your output folder and launch the encoding. The encoding options are almost endless but I usually stick with standard profiles so in this case I opted for a high profile at level 4 and a 2-pass encode:</p>
<pre>K:\9&gt;x264.exe --profile high --level 4 --bitrate 12751 --pass 1 --output 00115.track_4113.dgi.avs.mkv 00115.track_4113.dgi.avs
K:\9&gt;x264.exe --profile high --level 4 --bitrate 12751 --pass 3 --output 00115.track_4113.dgi.avs.mkv 00115.track_4113.dgi.avs</pre>
<p>Depending on your hardware this may take quite a while especially for a 2-pass or more encode.</p>
<p>Next we need to take care of the subtitles. Open up SupRip and load your first (and maybe only) subtitle file (.sup):</p>
<p><img class="alignnone size-medium wp-image-115" title="SupRip 1.16" src="http://dranger003.files.wordpress.com/2010/01/suprip-1-16-00115-track_4608-sup.png?w=300&#038;h=173" alt="" width="300" height="173" /></p>
<p>Click on the first character in red and at the bottom type in the right text for that character and press enter to switch to the next missing character. Yes, this is a long process which may not suit your level of patience&#8230; Once done, switch to the &#8220;SRT&#8221; tab and review the final text then save to a .SRT file. Repeat for all other subtitles you want to keep (because of the process I usually tend to keep as least subtitles as possible).</p>
<p>We&#8217;re getting close now but there is one remaining task before we mux everything back, we need to set up the chapters. Open up mkvmerge GUI (mmg.exe) then switch to the &#8220;Chapter Editor&#8221; tab. Click Chapter Editor -&gt; New Chapters and click &#8220;&#8211; (new chapter file)&#8221; in the &#8220;Chapters:&#8221; listbox then click &#8220;Add chapter&#8221;. Under &#8220;EditionEntry 1&#8243; click &#8220;(unnamed) [eng]&#8221; &#8211; this is your first chapter. At the bottom, click &#8220;(unnamed)&#8221; and enter a name for the chapter. Here I like to play the bluray menu and go to the chapters section to see all the chapter names then I use those names in the chapter editor.</p>
<p>For the timecodes, you&#8217;ll need that text file we saved at the beginning. Open that up and copy/paste the start/end timecodes in the corresponding &#8220;Start:&#8221; and &#8220;End:&#8221; boxes then click &#8220;Add chapter&#8221; again to create a new chapter. Repeat the process until you&#8217;ve managed to enter all the chapters you want to keep. You may also want to set the language/country by clicking the &#8220;Set values&#8221; button (if you click the root node first you can apply those values to all children quickly). Now save your chapters into an XML file by going to Chapter Editor -&gt; Save as.</p>
<p>Finally we can setup everything to start muxing. Under the &#8220;Input&#8221; tab drag/add all your streams (in order: video, audio, subtitles). For each stream, click on it then at the bottom make sure to set as much information as possible from the first 2 tabs (&#8220;General track options&#8221;, &#8220;Format specific options&#8221;). I usually set the language, default track (default for video/audio and no for each subtitles), aspect ratio or display width and FPS. Under the &#8220;Global&#8221; tab, make sure to put in a &#8220;File/segment title&#8221; and load your chapters file then click &#8220;Start muxing&#8221;.</p>
<p>Enjoy the final result:</p>
<p><img class="alignnone size-medium wp-image-120" title="Windows Media Player" src="http://dranger003.files.wordpress.com/2010/01/windows-media-player-10.png?w=300&#038;h=218" alt="" width="300" height="218" /></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dranger003.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dranger003.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dranger003.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dranger003.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/dranger003.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/dranger003.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/dranger003.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/dranger003.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dranger003.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dranger003.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dranger003.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dranger003.wordpress.com/110/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dranger003.wordpress.com/110/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dranger003.wordpress.com/110/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dranger003.wordpress.com&amp;blog=8657040&amp;post=110&amp;subd=dranger003&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dranger003.wordpress.com/2010/01/03/converting-bluray-to-matroska-mkv/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4cd276aaa319b12d0beaf23c65630769?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dranger003</media:title>
		</media:content>

		<media:content url="http://dranger003.files.wordpress.com/2010/01/bdinfo-v-0-5-3-2.png?w=293" medium="image">
			<media:title type="html">BDInfo v.0.5.3</media:title>
		</media:content>

		<media:content url="http://dranger003.files.wordpress.com/2010/01/tsmuxer-gui-1-10-6.png?w=295" medium="image">
			<media:title type="html">tsMuxeR GUI 1.10.6</media:title>
		</media:content>

		<media:content url="http://dranger003.files.wordpress.com/2010/01/untitled-2-2.png?w=300" medium="image">
			<media:title type="html">DGIndexNV</media:title>
		</media:content>

		<media:content url="http://dranger003.files.wordpress.com/2010/01/windowclipping.png?w=300" medium="image">
			<media:title type="html">Bitrate Calculator</media:title>
		</media:content>

		<media:content url="http://dranger003.files.wordpress.com/2010/01/suprip-1-16-00115-track_4608-sup.png?w=300" medium="image">
			<media:title type="html">SupRip 1.16</media:title>
		</media:content>

		<media:content url="http://dranger003.files.wordpress.com/2010/01/windows-media-player-10.png?w=300" medium="image">
			<media:title type="html">Windows Media Player</media:title>
		</media:content>
	</item>
		<item>
		<title>Ubuntu 9.10 (Karmic Koala) Released</title>
		<link>http://dranger003.wordpress.com/2009/10/31/ubuntu-9-10-karmic-koala-released/</link>
		<comments>http://dranger003.wordpress.com/2009/10/31/ubuntu-9-10-karmic-koala-released/#comments</comments>
		<pubDate>Sun, 01 Nov 2009 03:56:50 +0000</pubDate>
		<dc:creator>dranger003</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://dranger003.wordpress.com/?p=101</guid>
		<description><![CDATA[Yes, another release of Ubuntu is out the door with an interesting list of new features, including the new Wave theme:<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dranger003.wordpress.com&amp;blog=8657040&amp;post=101&amp;subd=dranger003&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.ubuntu.com/" target="_blank"><img class="alignnone size-full wp-image-103" title="Ubuntu Home Page  Ubuntu - Mozilla Firefox" src="http://dranger003.files.wordpress.com/2009/10/ubuntu-home-page-ubuntu-mozilla-firefox.png?w=477&#038;h=154" alt="Ubuntu Home Page  Ubuntu - Mozilla Firefox" width="477" height="154" /></a></p>
<p>Yes, another release of Ubuntu is out the door with an <a href="http://www.ubuntu.com/getubuntu/releasenotes/910overview" target="_blank">interesting list of new features</a>, including the new Wave theme:</p>
<p><img class="alignnone size-full wp-image-102" title="JauntyGUI" src="http://dranger003.files.wordpress.com/2009/10/jauntygui.png?w=500&#038;h=312" alt="JauntyGUI" width="500" height="312" /></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dranger003.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dranger003.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dranger003.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dranger003.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/dranger003.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/dranger003.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/dranger003.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/dranger003.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dranger003.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dranger003.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dranger003.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dranger003.wordpress.com/101/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dranger003.wordpress.com/101/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dranger003.wordpress.com/101/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dranger003.wordpress.com&amp;blog=8657040&amp;post=101&amp;subd=dranger003&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dranger003.wordpress.com/2009/10/31/ubuntu-9-10-karmic-koala-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4cd276aaa319b12d0beaf23c65630769?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dranger003</media:title>
		</media:content>

		<media:content url="http://dranger003.files.wordpress.com/2009/10/ubuntu-home-page-ubuntu-mozilla-firefox.png" medium="image">
			<media:title type="html">Ubuntu Home Page  Ubuntu - Mozilla Firefox</media:title>
		</media:content>

		<media:content url="http://dranger003.files.wordpress.com/2009/10/jauntygui.png" medium="image">
			<media:title type="html">JauntyGUI</media:title>
		</media:content>
	</item>
		<item>
		<title>VMware Workstation 7 Released</title>
		<link>http://dranger003.wordpress.com/2009/10/31/vmware-workstation-7-released/</link>
		<comments>http://dranger003.wordpress.com/2009/10/31/vmware-workstation-7-released/#comments</comments>
		<pubDate>Sun, 01 Nov 2009 03:41:54 +0000</pubDate>
		<dc:creator>dranger003</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Virtualization]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://dranger003.wordpress.com/?p=96</guid>
		<description><![CDATA[VMware just released version 7 of their well known Workstation application. Here&#8217;s an interesting new feature many have been waiting for: &#8220;Aero Glass — A new Windows Display Driver Model (WDDM) graphics driver has been developed for Windows Vista and Windows 7 virtual machines. The WDDM driver can display the Windows Aero user interface, OpenGL [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dranger003.wordpress.com&amp;blog=8657040&amp;post=96&amp;subd=dranger003&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>VMware just released version 7 of their well known Workstation application. Here&#8217;s an interesting new feature many have been waiting for:</p>
<p><em>&#8220;<strong>Aero Glass </strong> — A new Windows Display Driver Model (WDDM) graphics driver has been developed for Windows Vista and Windows 7 virtual machines. The WDDM driver can display the Windows Aero user interface, OpenGL 1.4, and Shader Model 3.0. For more information on the VMware recommended graphics hardware, see the <a href="http://www.vmware.com/pdf/ws7_manual.pdf" target="_blank">VMware Workstation User&#8217;s Manual.</a>&#8220;</em></p>
<p>Full release notes can be found <a href="http://www.vmware.com/support/ws7/doc/releasenotes_ws7.html" target="_blank">here</a>.<br />
Downloads are <a href="http://downloads.vmware.com/d/info/desktop_downloads/vmware_workstation/7_0" target="_blank">here</a>.</p>
<p><img class="alignnone size-full wp-image-97" title="Windows 7 x64 - VMware Workstation" src="http://dranger003.files.wordpress.com/2009/10/windows-7-x64-vmware-workstation.png?w=500&#038;h=302" alt="Windows 7 x64 - VMware Workstation" width="500" height="302" /></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dranger003.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dranger003.wordpress.com/96/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dranger003.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dranger003.wordpress.com/96/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/dranger003.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/dranger003.wordpress.com/96/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/dranger003.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/dranger003.wordpress.com/96/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dranger003.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dranger003.wordpress.com/96/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dranger003.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dranger003.wordpress.com/96/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dranger003.wordpress.com/96/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dranger003.wordpress.com/96/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dranger003.wordpress.com&amp;blog=8657040&amp;post=96&amp;subd=dranger003&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dranger003.wordpress.com/2009/10/31/vmware-workstation-7-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4cd276aaa319b12d0beaf23c65630769?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dranger003</media:title>
		</media:content>

		<media:content url="http://dranger003.files.wordpress.com/2009/10/windows-7-x64-vmware-workstation.png" medium="image">
			<media:title type="html">Windows 7 x64 - VMware Workstation</media:title>
		</media:content>
	</item>
		<item>
		<title>Statically Linked Qt On Win32 Using MSVC</title>
		<link>http://dranger003.wordpress.com/2009/10/14/statically-linke-qt-on-win32/</link>
		<comments>http://dranger003.wordpress.com/2009/10/14/statically-linke-qt-on-win32/#comments</comments>
		<pubDate>Wed, 14 Oct 2009 15:13:19 +0000</pubDate>
		<dc:creator>dranger003</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[Qt]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://dranger003.wordpress.com/?p=87</guid>
		<description><![CDATA[I have been trying to compile a statically linked version of Qt on Windows using MSVC for some time now but never found my way through until recently. There is a lot of information on the web about how to do this however I haven&#8217;t found one that actually worked for me (some information can [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dranger003.wordpress.com&amp;blog=8657040&amp;post=87&amp;subd=dranger003&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I have been trying to compile a statically linked version of Qt on Windows using MSVC for some time now but never found my way through until recently. There is a lot of information on the web about how to do this however I haven&#8217;t found one that actually worked for me (some information can be found on <a href="http://doc.trolltech.com/4.5/deployment-windows.html#static-linking">Trolltech&#8217;s website</a>). So here&#8217;s yet another howto for using a static version of Qt with Visual Studio 2008!</p>
<p>What you need:</p>
<ul>
<li>Microsoft <a href="http://www.microsoft.com/visualstudio/en-us/default.mspx">Visual Studio 2008</a></li>
<li>The <a href="ftp://ftp.trolltech.com/qt/source/">Qt sources</a> (4.5.3 at the time of this writing)</li>
<li><a href="http://qt.nokia.com/downloads/visual-studio-add-in">Qt Visual Studio Addin</a></li>
</ul>
<p>What you do (assuming VS2008 is already installed):</p>
<ol>
<li> Unpack the Qt sources. I used C:\Qt\4.5.3-win32-msvc2008 as target (%QTDIR%)</li>
<li>If you have a multicore CPU you might want to speedup things by modifying %QTDIR%\mkspecs\win32-msvc2008\qmake.conf and adding those two lines (change 2 for the no. of CPUs you have):
<pre>QMAKE_CXXFLAGS_RELEASE += -MP2
QMAKE_CXXFLAGS_DEBUG += -MP2</pre>
</li>
<li>Next, open a <em>Visual Studio 2008 Command Prompt</em> (under the Start menu), go to %QTDIR% and run <code>configure.exe</code> with at least <code>-static</code> as option. I used the following (minimal build):</li>
<p><code>configure.exe -debug-and-release -opensource -static -no-exceptions -no-accessibility -no-stl -no-qt3support -no-opengl -platform win32-msvc2008 -qt-zlib -qt-gif -qt-libpng -qt-libmng -qt-libtiff -qt-libjpeg -no-openssl -no-dbus -no-phonon -no-webkit -no-scripttools</code></p>
<li>Once configured, start the build:
<pre>nmake sub-src</pre>
</li>
<li>Install the Qt Visual Studio Addin</li>
<li>In Visual Studio, under the <strong>Qt</strong> menu choose <strong>Qt Options</strong>. Under the <strong>Qt Versions</strong> tab click <strong>Add</strong> and type <em>4.5.3_win32-msvc2008</em> (or whatever you want) and fill in the path where you extracted the Qt sources</li>
<li>Optionally you can test your installation by creating a new Qt Project, compiling it and running it.</li>
</ol>
<p>Easy enough?! Happy Qt&#8217;ing!</p>
<p><strong>UPDATE 15/10/2009:</strong> This also works with MS Visual Studio C++ Express Edition!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dranger003.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dranger003.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dranger003.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dranger003.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/dranger003.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/dranger003.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/dranger003.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/dranger003.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dranger003.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dranger003.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dranger003.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dranger003.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dranger003.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dranger003.wordpress.com/87/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dranger003.wordpress.com&amp;blog=8657040&amp;post=87&amp;subd=dranger003&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dranger003.wordpress.com/2009/10/14/statically-linke-qt-on-win32/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4cd276aaa319b12d0beaf23c65630769?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dranger003</media:title>
		</media:content>
	</item>
		<item>
		<title>Organizing Your Files</title>
		<link>http://dranger003.wordpress.com/2009/10/12/organizing-your-files/</link>
		<comments>http://dranger003.wordpress.com/2009/10/12/organizing-your-files/#comments</comments>
		<pubDate>Mon, 12 Oct 2009 22:16:26 +0000</pubDate>
		<dc:creator>dranger003</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://dranger003.wordpress.com/?p=83</guid>
		<description><![CDATA[I don&#8217;t know about you but I have files spread over multiple PCs since I use multiple PCs. Sometimes you simply don&#8217;t have time to transfer them over and find yourself missing a file and looking all over the place to find it. Welcome Dropbox!  A very neat simple software that allows to automatically sync [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dranger003.wordpress.com&amp;blog=8657040&amp;post=83&amp;subd=dranger003&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I don&#8217;t know about you but I have files spread over multiple PCs since I use multiple PCs. Sometimes you simply don&#8217;t have time to transfer them over and find yourself missing a file and looking all over the place to find it.</p>
<p>Welcome <a href="http://www.getdropbox.com">Dropbox</a>!  A very neat simple software that allows to automatically sync your files between multiple PCs. It also provides a website repository so you can share files with other people. I&#8217;ve been using it for some time now and find it very useful!</p>
<p><a href="https://www.getdropbox.com/screencast">Check it out.</a></p>
<p>If you wish to join and don&#8217;t mind giving me credits for the referral, <a href="mailto:dranger003@gmail.com">send me your email address</a> and I&#8217;ll send you an invite. Referrals can help you gain more disk space online.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dranger003.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dranger003.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dranger003.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dranger003.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/dranger003.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/dranger003.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/dranger003.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/dranger003.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dranger003.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dranger003.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dranger003.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dranger003.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dranger003.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dranger003.wordpress.com/83/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dranger003.wordpress.com&amp;blog=8657040&amp;post=83&amp;subd=dranger003&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dranger003.wordpress.com/2009/10/12/organizing-your-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4cd276aaa319b12d0beaf23c65630769?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dranger003</media:title>
		</media:content>
	</item>
		<item>
		<title>HD-PVR Post-production</title>
		<link>http://dranger003.wordpress.com/2009/10/12/hd-pvr-post-production/</link>
		<comments>http://dranger003.wordpress.com/2009/10/12/hd-pvr-post-production/#comments</comments>
		<pubDate>Mon, 12 Oct 2009 15:56:07 +0000</pubDate>
		<dc:creator>dranger003</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[HD-PVR]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://dranger003.wordpress.com/?p=78</guid>
		<description><![CDATA[As already posted, last year I bought the Hauppauge HD-PVR. Since I&#8217;m a geek (am I?!) and I like doing things my way, using all the software provided with the device wasn&#8217;t an option I was going to choose. Also, since I always want maximum picture quality I always set the HD-PVR to record at [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dranger003.wordpress.com&amp;blog=8657040&amp;post=78&amp;subd=dranger003&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>As already posted, last year I bought the <a href="http://www.hauppauge.com/site/products/data_hdpvr.html">Hauppauge HD-PVR</a>. Since I&#8217;m a geek (am I?!) and I like doing things my way, using all the software provided with the device wasn&#8217;t an option I was going to choose. Also, since I always want maximum picture quality I always set the HD-PVR to record at full bitrate (13.5Mpbs CBR).</p>
<p>As you can imagine recording at 13.5Mpbs will produce some quite big files, but thats all good as I have plenty of disk space to waste (temporarily). For example, a 1 1/2 hour recording will take approx. 9.7GB. That&#8217;s big, even with lots of disk space to waste. So, I convert the recording to at least an MKV (AVC/AAC) as an archive/computer playable version and sometimes a DVD  (to watch on the TV set, which only has a DVD player, for now).</p>
<p>Now since I&#8217;m a command line freak (did I say I was a geek?!), here&#8217;s how I do it. In order to do the same you will need at least the following software (all free):</p>
<ul>
<li><a href="http://www.neuron2.net/dgavcdec/dgavcdec.html">DGAVCDec AVC/H.264 Decoder and Frame Server</a> (or <a href="http://www.neuron2.net/dgavcdecnv/dgavcdecnv.html">GPU enabled version DGAVCDecNV</a>) [<strong>UPDATE 1/3/2010</strong>: Unfortunately DGAVCDec seems to have been discontinued and only the new <a href="http://neuron2.net/dgdecnv/dgdecnv.html">GPU enabled version</a> is now available]</li>
<li><a href="http://avisynth.org/mediawiki/Main_Page">Avisynth</a> (frame server)</li>
<li><a href="http://avisynth.org.ru/yadif/yadif.html">Yadif Avisynth Plugin</a> (deinterlace the 1080i source)</li>
<li><a href="http://x264.nl/">x264</a> (h.264 video encoder)</li>
<li><a href="http://wavi-avi2wav.sourceforge.net/">WAVI</a> (extract WAV from an AVS)</li>
<li><a href="http://www.rarewares.org/aac-encoders.php">FAAC</a> (AAC/MP4 audio encoder)</li>
<li><a href="http://www.bunkus.org/videotools/mkvtoolnix/">MKVToolnix</a> (MKV multiplexing)</li>
<li><a href="http://oss.netfarm.it/mplayer-win32.php">MPlayer</a> (for mencoder to encode MPEG2/AC3 DVD)</li>
<li><a href="http://www.videohelp.com/calc.htm">Bitrate Calculator</a> (make the result fit a 4.3GB or 7.9GB DVD disc)</li>
<li><a href="http://www.imgburn.com/">ImgBurn</a> (create ISOs and burn to disc)</li>
<li><a href="http://www.virtualdub.org/">VirtualDub</a> (find frame numbers to strip commercials)</li>
<li><a href="http://dvdauthor.sourceforge.net/">DVDAuthor</a> (<a href="http://www.paehl.com/open_source/?DVDAuthor">compiled for Windows</a>)</li>
</ul>
<p>1. The first step is is to load the .TS (or M2TS) file in DGAVCIndex:</p>
<p><img class="alignnone size-full wp-image-79" title="DGAVCDec" src="http://dranger003.files.wordpress.com/2009/10/image1.png?w=400&#038;h=267" alt="DGAVCDec" width="400" height="267" /></p>
<p>And save the whole stream into a DGA project (File -&gt; Save Project or F4). This will also demux the audio and create a [filename] PID 1100 DELAY [delay]ms.aac file.</p>
<p>2. Then I create an Avisynth script to load the DGA project in VirtualDub to make a stream selection (strip the beginning/end and commercials). The script looks like this:</p>
<p><code>LoadPlugin("DGAVCDecode.dll")<br />
V=AVCSource("Project.dga")<br />
A=DirectShowSource("Project PID 1100 DELAY -180ms.aac", video=false, seek=false)<br />
AudioDub(V, A)<br />
DelayAudio(-0.180)</code></p>
<p>[<strong>UPDATE 1/3/2010</strong>: You may want to use <code>seekzero=true</code> instead of <code>seek=false</code> as <em>some</em> seeking may be required depending on the context.]</p>
<p>Make sure to match the DelayAudio() with the delay from the AAC file then load the AVS into VirtualDub. This part can be time consuming as this is where I seek through the whole stream to find commercials and other parts I want to strip. For every part to strip I write down the first frame and last frame numbers to insert into the AVS. Once this is done you simply trim all the frames you want to keep like this:</p>
<p><code>Trim(29, 13187)+Trim(19031, 57183)+Trim(60138, 62091)</code></p>
<p>This strips the following frame ranges: 0-28, 13188-19030, 57184-60137 and 62092 to the end. Basically, Trim tells Avisynth to <em>keep</em> the specified frame range.</p>
<p>3. Now is the time to start encoding. First you will need to calculate your bitrate to make sure the newly encoded stream will fit your target media. Open the Bitrate Calculator and input your stream length and audio bitrate (I use 128Kpbs) and select your target media. Keep in mind the target bitrate is an average bitrate therefore you may want to bring it down by 1-2% to make sure you won&#8217;t have to re-encode the stream a second time.</p>
<p>For encoding the video, I use the following 2-pass encode:</p>
<p><code>x264.exe --profile high --pass 1 --bitrate 16000 --threads auto --thread-input --output Project.ts.avs.264 Project.ts.avs<br />
x264.exe --profile high --pass 2 --bitrate 16000 --threads auto --thread-input --output Project.ts.avs.264 Project.ts.avs</code></p>
<p>For the audio, I use the following 1-pass encode:</p>
<p><code>wavi Project.ts.avs - | faac.exe -b 128 -o Project.ts.avs.aac -</code></p>
<p>Then I end up with 2 files, Project.ts.avs.264 and Project.ts.avs.aac which I multiplex in MKVToolnix to produce an MKV file. Make sure to select your video framerate in mmg.exe as .264 files do not store that information (you should get a warning after adding the .264 into mmg). Optionally, you can also select the language for both streams. That&#8217;s it for the high quality archive copy!</p>
<p>4. To create a DVD compliant structure, I use mencoder (lavcodec) for encoding both the video and audio. Here&#8217;s the command line I use for a high quality encode:</p>
<p><code>mencoder.exe -mc 0 -noskip -ovc lavc -nosound -lavcopts threads=2:vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:vbitrate=9668:keyint=15:vpass=1:trell:mbd=2:precmp=2:subcmp=2:cmp=2:dia=-10:predia=-10:cbp:mv0:vqmin=1:lmin=1:dc=10:vstrict=0:aspect=16/9 Project.ts.avs -o Project.ts.avs.mpg -ofps 30000/1001 -of mpeg -mpegopts format=dvd:tsaf<br />
mencoder.exe -mc 0 -noskip -ovc lavc -nosound -lavcopts threads=2:vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:vbitrate=9668:keyint=15:vpass=3:trell:mbd=2:precmp=2:subcmp=2:cmp=2:dia=-10:predia=-10:cbp:mv0:vqmin=1:lmin=1:dc=10:vstrict=0:aspect=16/9 Project.ts.avs -o Project.ts.avs.mpg -ofps 30000/1001 -of mpeg -mpegopts format=dvd:tsaf<br />
mencoder.exe -mc 0 -noskip -ovc lavc -oac lavc -lavcopts acodec=ac3:abitrate=128:threads=2:vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:vbitrate=9668:keyint=15:vpass=3:trell:mbd=2:precmp=2:subcmp=2:cmp=2:dia=-10:predia=-10:cbp:mv0:vqmin=1:lmin=1:dc=10:vstrict=0:aspect=16/9 -srate 48000 -af lavcresample=48000 Project.ts.avs -o Project.ts.avs.mpg -ofps 30000/1001 -of mpeg -mpegopts format=dvd:tsaf</code></p>
<p>Here you could tweak the first and 2nd pass for better performance (remove CPU intensive switches). Also, vpass=3 isn&#8217;t a mistake for pass no. 2 (you can read mencoder&#8217;s manpage for more details). Now at this point if everything went fine with the encode you should end up with a Project.ts.avs.mpg file.</p>
<p>5. Time to create the DVD structure with DVDAuthor. This is as simple as this:</p>
<p><code>dvdauthor.exe -t -o PROJECT Project.ts.avs.mpg<br />
dvdauthor.exe -T -o PROJECT</code></p>
<p>Here, PROJECT is an output folder containing the DVD structure (AUDIO_TS and VIDEO_TS folders). The -t switch creates the titleset and the -T switch creates the table of content (which contains only the single titleset created from -t).</p>
<p>6. The last step to create the DVD is to burn the disc. Just fire up ImgBurn and select Create image file from files/folders and under the Output menu select Device to burn the result to disc.</p>
<p>Et voilà. Of course there is always a thousand ways of re-encoding a stream so keep in mind this is only one way of doing it&#8230; <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dranger003.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dranger003.wordpress.com/78/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dranger003.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dranger003.wordpress.com/78/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/dranger003.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/dranger003.wordpress.com/78/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/dranger003.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/dranger003.wordpress.com/78/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dranger003.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dranger003.wordpress.com/78/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dranger003.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dranger003.wordpress.com/78/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dranger003.wordpress.com/78/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dranger003.wordpress.com/78/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dranger003.wordpress.com&amp;blog=8657040&amp;post=78&amp;subd=dranger003&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dranger003.wordpress.com/2009/10/12/hd-pvr-post-production/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4cd276aaa319b12d0beaf23c65630769?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dranger003</media:title>
		</media:content>

		<media:content url="http://dranger003.files.wordpress.com/2009/10/image1.png" medium="image">
			<media:title type="html">DGAVCDec</media:title>
		</media:content>
	</item>
		<item>
		<title>PPA Update</title>
		<link>http://dranger003.wordpress.com/2009/09/28/ppa-update/</link>
		<comments>http://dranger003.wordpress.com/2009/09/28/ppa-update/#comments</comments>
		<pubDate>Mon, 28 Sep 2009 21:58:29 +0000</pubDate>
		<dc:creator>dranger003</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://dranger003.wordpress.com/?p=75</guid>
		<description><![CDATA[Yes, I have found some time (sorry, I meant &#8220;took some time&#8221;) to update my PPA. I&#8217;ve updated my x264 package to core 76 for now. You&#8217;ll find my PPA on launchpad. I also want to update my other packages but first I need to better understand the process of updating an existing source package [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dranger003.wordpress.com&amp;blog=8657040&amp;post=75&amp;subd=dranger003&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Yes, I have found some time (sorry, I meant &#8220;took some time&#8221;) to update my PPA. I&#8217;ve updated my x264 package to core 76 for now. You&#8217;ll find my PPA on <a href="https://launchpad.net/~dranger003/+archive/ppa" target="_blank">launchpad</a>.</p>
<p>I also want to update my other packages but first I need to better understand the process of updating an existing source package with a new upstream version using version control (git). Launchpad has lots of good resources on <a href="https://help.launchpad.net/Packaging/PPA" target="_blank">packaging software for Ubuntu</a> (or any Debian based distro).</p>
<p>I found <a href="http://www.eyrie.org/~eagle/notes/debian/git.html" target="_blank">interesting</a> <a href="http://www.golden-gryphon.com/software/misc/packaging.html" target="_blank">links</a> on <a href="http://madduck.net/blog/2007.10.03:packaging-with-git/" target="_blank">packaging</a> for Debian. However they all seem to be using their &#8220;own&#8221; way and there seems to be no &#8220;standard/official&#8221; way of doing it. There is also the <a href="http://www.vcs-pkg.org/" target="_blank">vcs-pkg</a> project that aims to further investigate the use of version control for packaging. Interesting.</p>
<p>Any good links aside those ones you would like to suggest?</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dranger003.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dranger003.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dranger003.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dranger003.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/dranger003.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/dranger003.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/dranger003.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/dranger003.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dranger003.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dranger003.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dranger003.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dranger003.wordpress.com/75/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dranger003.wordpress.com/75/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dranger003.wordpress.com/75/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dranger003.wordpress.com&amp;blog=8657040&amp;post=75&amp;subd=dranger003&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dranger003.wordpress.com/2009/09/28/ppa-update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4cd276aaa319b12d0beaf23c65630769?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dranger003</media:title>
		</media:content>
	</item>
		<item>
		<title>Reference Counting Garbage Collection</title>
		<link>http://dranger003.wordpress.com/2009/09/15/reference-counting-garbage-collection/</link>
		<comments>http://dranger003.wordpress.com/2009/09/15/reference-counting-garbage-collection/#comments</comments>
		<pubDate>Wed, 16 Sep 2009 00:59:37 +0000</pubDate>
		<dc:creator>dranger003</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://dranger003.wordpress.com/?p=70</guid>
		<description><![CDATA[One nice feature from the .NET world is garbage collection. You simply don&#8217;t need to worry (99% of the time) about memory allocation resulting from creating new objects. The .NET garbage collector detects when an object is no longer needed based on a few heuristics but mainly based on reference count. Using the same technique [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dranger003.wordpress.com&amp;blog=8657040&amp;post=70&amp;subd=dranger003&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>One nice feature from the .NET world is garbage collection. You simply don&#8217;t need to worry (99% of the time) about memory allocation resulting from creating new objects. The .NET garbage collector detects when an object is no longer needed based on a few heuristics but mainly based on reference count.</p>
<p>Using the same technique while using C++ is possible, and even easy. Since programming is about reuse I opted to create a class that wraps existing objects to add the wanted feature. It looks like this:</p>
<p><code>CRefObject&lt;TExisting&gt;* p = CRefObject&lt;TExisting&gt;::CreateInstance(/* TExisting ctor args */);</code></p>
<p><code>CRefObject</code> basically derives from <code>TExisting</code> to keep all the same functionality:</p>
<pre><code>template&lt;typename TBase, typename TActivator = CRefActivatorTraits&lt;TBase&gt;&gt;
class CRefObject : public TBase
{

...

};</code></pre>
<p>Keeping the reference count within the object itself is important as one objective is to pass objects between threads without having to worry about memory allocation. There are many smart pointers out there and many implement reference counting however I haven&#8217;t found one that keeps the reference count as an part of an object identity.</p>
<p>Implementing CRefObject&lt;T&gt; is quite straightforward: manage reference counting.</p>
<pre><code>	ULONG AddRef()
	{
		return ::InterlockedIncrement(&amp;m_lRefCount);
	}

	ULONG Release()
	{
		LONG lCount = ::InterlockedDecrement(&amp;m_lRefCount);
		ATLASSERT(lCount &gt;= 0);
		if (lCount == 0)
			TActivator::Destroy(this);

		return lCount;
	}</code></pre>
<p>Now that we have reference counting we can upgrade existing objects and manage reference counting like this:</p>
<p><code>CRefObject&lt;TExisting&gt;* p = CRefObject&lt;TExisting&gt;::CreateInstance(/* TExisting ctor args */);<br />
...<br />
// When done with the object, release it<br />
p-&gt;Release();</code></p>
<p>That looks like COM doesn&#8217;t it? Yes it does. And there is one more feature we can add to make it look even more like COM using ATL: using smart pointers. This makes it much easier to track the reference count. Welcome CRefAutoPtr&lt;T&gt;:</p>
<pre><code>template&lt;typename T&gt;
class CRefAutoPtr
{
public:
	CRefAutoPtr() throw() :
		m_pT(NULL)
	{ }

	CRefAutoPtr(const CRefAutoPtr&amp; sp) throw() :
		m_pT(sp.m_pT)
	{
		_AddRef();
	}

	explicit CRefAutoPtr(CRefObject* pT) throw() :
		m_pT(NULL)
	{
		_Attach(pT);
	}

	virtual ~CRefAutoPtr() throw()
	{
		_Release();
	}

	CRefAutoPtr&amp; operator =(const CRefAutoPtr&amp; sp) throw()
	{
		_Release();
		m_pT = sp.m_pT;
		_AddRef();
		return *this;
	}

	CRefObject* operator &amp;() throw()
	{
		_AddRef();
		return m_pT;
	}

	operator CRefObject*() throw()
	{
		return operator&amp;();
	}

	CRefObject* operator -&gt;() const throw()
	{
		return m_pT;
	}

	bool operator !=(const CRefAutoPtr&amp; sp) const throw()
	{
		return !operator==(sp);
	}

	bool operator ==(const CRefAutoPtr&amp; sp) const throw()
	{
		return m_pT == sp.m_pT;
	}

	CRefObject* Detach() throw()
	{
		CRefObject* pT = m_pT;
		m_pT = NULL;
		return pT;
	}

protected:
	VOID _Attach(CRefObject* pT) throw()
	{
		_Release();
		m_pT = pT;
	}

	VOID _AddRef() throw()
	{
		CRefObject* pT = m_pT;
		if (pT)
			pT-&gt;AddRef();
	}

	VOID _Release() throw()
	{
		CRefObject* pT = m_pT;
		if (pT)
		{
			m_pT = NULL;
			pT-&gt;Release();
		}
	}

public:
	CRefObject* m_pT;
};</code></pre>
<p>The whole implementation isn&#8217;t 100% complete, but its quite a good start.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dranger003.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dranger003.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dranger003.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dranger003.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/dranger003.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/dranger003.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/dranger003.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/dranger003.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dranger003.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dranger003.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dranger003.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dranger003.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dranger003.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dranger003.wordpress.com/70/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dranger003.wordpress.com&amp;blog=8657040&amp;post=70&amp;subd=dranger003&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dranger003.wordpress.com/2009/09/15/reference-counting-garbage-collection/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4cd276aaa319b12d0beaf23c65630769?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dranger003</media:title>
		</media:content>
	</item>
		<item>
		<title>Byte Formatting Revisited</title>
		<link>http://dranger003.wordpress.com/2009/09/05/byte-formatting-revisited/</link>
		<comments>http://dranger003.wordpress.com/2009/09/05/byte-formatting-revisited/#comments</comments>
		<pubDate>Sat, 05 Sep 2009 17:06:46 +0000</pubDate>
		<dc:creator>dranger003</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://dranger003.wordpress.com/?p=66</guid>
		<description><![CDATA[If you read my last post you may have noticed both ConvertBytes and FormatBytes could benefit a few improvements. After thinking the implementation over again I made the following improvements. The biggest change is the order of the parameters in both functions; in order to allow for default parameters I moved the out parameters (pointers) [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dranger003.wordpress.com&amp;blog=8657040&amp;post=66&amp;subd=dranger003&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>If you read my <a href="http://dranger003.wordpress.com/2009/09/03/byte-formatting/">last post</a> you may have noticed both <code>ConvertBytes</code> and <code>FormatBytes</code> could benefit a few improvements. After thinking the implementation over again I made the following improvements.</p>
<ol>
<li>The biggest change is the order of the parameters in both functions; in order to allow for default parameters I moved the out parameters (pointers) to the beginning of the parameter list</li>
<li>In <code>ConvertBytes</code> instead of linking the binary prefix to the exponent I now use a different variable for less confusion</li>
<li>If the provided size is already below the base then the output binary prefix is set to <code>BP_NONE</code></li>
<li>I renamed <code>iPrefix</code> to <code>iBinaryPrefix</code> in both functions for consistency</li>
<li>In <code>FormatBytes</code> I now use the new <code>BP_NONE</code> output prefix</li>
<li>Formatting has been changed to 2 decimals instead of 3 (can be specified otherwise)</li>
<li>An extra parameter has been added to <code>FormatBytes</code> for specifying whether the binary prefix is to appear in the fomatting (i.e. useful when formatting a range of bytes; e.g. <code>5.6-9.1 KB</code>)</li>
<li>Finally, <code>FormatBytes</code> now handles formatting provided bytes if below the base (i.e. using <code>B</code>)</li>
</ol>
<p>Here&#8217;s what both functions now look like:</p>
<pre>enum PREFIXNORM
{
	PN_SI,					// Base 10 (i.e. 1000)
	PN_IEC,					// Base 2 (i.e. 1024)
	PN_DECIMAL = PN_SI,
	PN_BINARY = PN_IEC
};

const INT iPrefixBase[] = { 1000, 1024 };

enum BINARYPREFIX
{
	BP_NONE = -2,
	BP_AUTO,
//	SI				IEC 60027	Exp (b10/b2)	Exp (b1000/b1024)
	BP_KILO,		// KIBI		3				1
	BP_MEGA,		// MEBI		6				2
	BP_GIGA,		// GIBI		9				3
	BP_TERA,		// TEBI		12				4
	BP_PETA,		// PEBI		15				5
	BP_EXA,			// EXBI		18				6
	BP_ZETTA,		// ZEBI		21				7
	BP_YOTTA		// YOBI		24				8
};

const LPTSTR pszPrefixes[][8] = {
	{ _T("KB"),  _T("MB"),  _T("GB"),  _T("TB"),  _T("PB"),  _T("EB"),  _T("ZB"),  _T("YB") },
	{ _T("KiB"), _T("MiB"), _T("GiB"), _T("TiB"), _T("PiB"), _T("EiB"), _T("ZiB"), _T("YiB") },
};

typedef DOUBLE *LPDOUBLE;
typedef BINARYPREFIX *LPBINARYPREFIX;

BOOL ConvertBytes(
	LPDOUBLE pdResult,
	LPBINARYPREFIX piBinaryPrefix,
	ULONGLONG ullBytes,
	BINARYPREFIX iBinaryPrefix = BP_AUTO,
	PREFIXNORM iPrefixNorm = PN_DECIMAL)
{
	if (!pdResult || !piBinaryPrefix)
		return FALSE;

	DOUBLE dSize = (DOUBLE)ullBytes;
	DOUBLE dBase = (FLOAT)iPrefixBase[iPrefixNorm];

	*pdResult = dSize;
	*piBinaryPrefix = iBinaryPrefix;

	if (iBinaryPrefix == BP_NONE)	// No conversion required
		return TRUE;

	DOUBLE dExponent = 0;

	if (iBinaryPrefix == BP_AUTO) // Try to find a suitable prefix
	{
		if (dSize &lt; dBase)
		{
			*piBinaryPrefix = BP_NONE;
		}
		else
		{
			dExponent = ::floor(::log(dSize) / ::log(dBase));
			*piBinaryPrefix = (BINARYPREFIX)((INT)dExponent - 1);
		}
	}
	else					// Use provided prefix
	{
		dExponent = iBinaryPrefix + 1;
	}

	*pdResult = dSize / ::pow(dBase, dExponent);

	return TRUE;
}

CString FormatBytes(
	LPBINARYPREFIX piBinaryPrefix,
	ULONGLONG ullBytes,
	BINARYPREFIX iBinaryPrefix = BP_AUTO,
	PREFIXNORM iPrefixNorm = PN_SI,
	INT iDecimals = 2,
	BOOL bFormatPrefix = TRUE)
{
	DOUBLE dResult;
	BOOL bRes = ::ConvertBytes(&amp;dResult, piBinaryPrefix, ullBytes, iBinaryPrefix, iPrefixNorm);
	ATLASSERT(bRes);

	if (*piBinaryPrefix == BP_NONE || ullBytes &lt; iPrefixBase[iPrefixNorm])
		iDecimals = 0;

	CString szFormat, szResult;
	szFormat.Format(_T("%%.%df"), iDecimals);

	if (bFormatPrefix)
	{
		if (*piBinaryPrefix == BP_NONE)
			szFormat.Append(_T(" B"));
		else
			szFormat.AppendFormat(_T(" %s"), pszPrefixes[iPrefixNorm][*piBinaryPrefix]);
	}

	szResult.Format(szFormat, dResult);

	return szResult;
}</pre>
<p>If you ever find good use of these functions please let me know. I personally use them quite often, hopefully they will be as useful for someone else. Oh, if you wonder how to format a range of bytes this is how to do it:</p>
<pre>                DOUBLE dMinSize = 123801, dMaxSize = 92873429;
		BINARYPREFIX ibp = BP_AUTO;
		CString szMaxSize(::FormatBytes(&amp;ibp, dMaxSize, ibp, PN_DECIMAL, 1, TRUE));
		CString szMinSize(::FormatBytes(&amp;ibp, dMinSize, ibp, PN_DECIMAL, 1, FALSE));
		CString szSize;
		szSize.Format(_T("%s-%s"), szMinSize, szMaxSize);
                ...</pre>
<p>It is important to note that you might be tempted to do:</p>
<pre>                DOUBLE dMinSize = 123801, dMaxSize = 92873429;
                BINARYPREFIX ibp = BP_AUTO;
                CString szSize;
                szSize.Format(_T("%s-%s"),
                                ::FormatBytes(&amp;ibp, dMaxSize, ibp, PN_DECIMAL, 1, TRUE),
                                ::FormatBytes(&amp;ibp, dMinSize, ibp, PN_DECIMAL, 1, FALSE));
                ...</pre>
<p>However doing so will most likely result in a wrong output because of the parameter evaluation strategy which might differ from one compiler to another.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dranger003.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dranger003.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dranger003.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dranger003.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/dranger003.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/dranger003.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/dranger003.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/dranger003.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dranger003.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dranger003.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dranger003.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dranger003.wordpress.com/66/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dranger003.wordpress.com/66/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dranger003.wordpress.com/66/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dranger003.wordpress.com&amp;blog=8657040&amp;post=66&amp;subd=dranger003&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dranger003.wordpress.com/2009/09/05/byte-formatting-revisited/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4cd276aaa319b12d0beaf23c65630769?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dranger003</media:title>
		</media:content>
	</item>
		<item>
		<title>Byte Formatting</title>
		<link>http://dranger003.wordpress.com/2009/09/03/byte-formatting/</link>
		<comments>http://dranger003.wordpress.com/2009/09/03/byte-formatting/#comments</comments>
		<pubDate>Fri, 04 Sep 2009 00:19:29 +0000</pubDate>
		<dc:creator>dranger003</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://dranger003.wordpress.com/?p=59</guid>
		<description><![CDATA[Now that we know all about the binary prefix origins the next question is how do we format bytes? The answer is not as straightforward as it should be. This proposed implementation offers 2 options. One is to auto-select the prefix based on the number of bytes and the other is to use a specific [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dranger003.wordpress.com&amp;blog=8657040&amp;post=59&amp;subd=dranger003&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Now that we know all about the <a href="http://dranger003.wordpress.com/2009/09/02/binary-prefix-origins/">binary prefix origins</a> the next question is how do we format bytes? The answer is not as straightforward as it should be.</p>
<p>This proposed implementation offers 2 options. One is to auto-select the prefix based on the number of bytes and the other is to use a specific prefix. There are two core operations involved in formatting bytes, one is to convert the byte size to the requested unit and the other is to format the converted size into a string, managing decimals.</p>
<p>To help the implementation we need to define a few things. First, will the conversion follow the SI or IEC standard? Then which unit are we making the conversion to? Finally, we need to define the prefixes themselves. To make this all fit together we make the prefix array match the definition of the used norm and the selected unit:</p>
<pre>enum PREFIXNORM
{
   PN_SI,                    // Base 10 (i.e. 1000)
   PN_IEC,                   // Base 2 (i.e. 1024)
   PN_DECIMAL = PN_SI,
   PN_BINARY = PN_IEC
};

const INT iPrefixBase[] = { 1000, 1024 };

enum BINARYPREFIX
{
   BP_NONE = -2,
   BP_AUTO,
// SI              IEC 60027      Exp (b10/b2)     Exp (b1000/b1024)
   BP_KILO,        // KIBI        3                1
   BP_MEGA,        // MEBI        6                2
   BP_GIGA,        // GIBI        9                3
   BP_TERA,        // TEBI        12               4
   BP_PETA,        // PEBI        15               5
   BP_EXA,         // EXBI        18               6
   BP_ZETTA,       // ZEBI        21               7
   BP_YOTTA        // YOBI        24               8
};

typedef BINARYPREFIX *LPBINARYPREFIX;

const LPTSTR pszPrefixes[][8] = {
   { _T("KB"),  _T("MB"),  _T("GB"),  _T("TB"),  _T("PB"),  _T("EB"),  _T("ZB"),  _T("YB") },
   { _T("KiB"), _T("MiB"), _T("GiB"), _T("TiB"), _T("PiB"), _T("EiB"), _T("ZiB"), _T("YiB") }
};</pre>
<p>To do the actual conversion we need the byte size, the norm to use and the unit to convert to. The function returns the converted byte size and the unit used (if BP_AUTO is specified):</p>
<pre>BOOL ConvertBytes(
   ULONGLONG ullSize,
   PREFIXNORM iPrefixNorm,
   BINARYPREFIX iPrefix,
   LPDOUBLE pdResult,
   LPBINARYPREFIX piPrefix)
{
   if (!pdResult || !piPrefix)
       return FALSE;

   DOUBLE dSize = (DOUBLE)ullSize;
   DOUBLE dBase = (FLOAT)iPrefixBase[iPrefixNorm];

   *pdResult = dSize;
   *piPrefix = BP_NONE;

   if (dSize &lt; dBase)    // Already in bytes?
       return TRUE;

   if (iPrefix == BP_AUTO)
       *piPrefix = (BINARYPREFIX)((INT)::floor(::log(dSize) / ::log(dBase)) - 1);
   else
       *piPrefix = iPrefix;

   *pdResult = dSize / ::pow(dBase, (DOUBLE)(*piPrefix) + 1);

   return TRUE;
}</pre>
<p>As you may have noticed the auto conversion is flawed. Indeed the maximum precision of a double allows to convert reliably only up to a terabyte. The conversion is still valid with higher values however the auto unit selection will diverge away from the multiple of the base as the number of bytes increases. For example converting the following values:</p>
<pre>ULONGLONG ullSizes[] = {
   999ULL,
   1000ULL,                // 1K
   999999ULL,
   1000000ULL,             // 1M
   999999999ULL,
   1000000000ULL,          // 1G
   999999999999ULL,
   1000000000000ULL,       // 1T
   999999999999999ULL,
   1000000000000000ULL,    // 1P
   999999999999999999ULL,
   1000000000000000000ULL, // 1E
   // ...
};</pre>
<p>Yields to these results (formatted with %.9f):</p>
<p><code>999.000000000 B<br />
1.000000000 KB<br />
999.999000000 KB<br />
1.000000000 MB<br />
999.999999000 MB<br />
1.000000000 GB<br />
999.999999999 GB<br />
1.000000000 TB<br />
1.000000000 PB // Should be 999­.999999999 TB but rounded to 1 PB<br />
1.000000000 PB<br />
1.000000000 EB // Should be 999.999999999 PB but rounded to 1 EB<br />
1.000000000 EB</code></p>
<p>Now formatting the converted size into a readable string is a matter of using the prefix array:</p>
<pre>CString FormatBytes(
    ULONGLONG ullBytes,
    INT iDecimals = 3,
    BINARYPREFIX iPrefix = BP_AUTO,
    PREFIXNORM iPrefixNorm = PN_SI)
{
    CString szResult;

    if (iPrefix == BP_NONE)
    {
        szResult.Format(_T("%I64u B"), ullBytes);
    }
    else
    {
        DOUBLE dResult;
        BOOL bRes = ::ConvertBytes(ullBytes, iPrefixNorm, iPrefix, &amp;dResult, &amp;iPrefix);
        ATLASSERT(bRes);

        CString szFormat;
        szFormat.Format(_T("%%.%df %%s"), iDecimals);
        szResult.Format(szFormat, dResult, pszPrefixes[iPrefixNorm][iPrefix]);
    }

    return szResult;
}</pre>
<p>Finally, using the formatting is as simple as this:</p>
<pre>::_tprintf(_T("%s\n"), ::FormatBytes(357913941));</pre>
<p>To give this output:</p>
<p><code>357.914 MB</code></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/dranger003.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/dranger003.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/dranger003.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/dranger003.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/dranger003.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/dranger003.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/dranger003.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/dranger003.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/dranger003.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/dranger003.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/dranger003.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/dranger003.wordpress.com/59/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/dranger003.wordpress.com/59/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/dranger003.wordpress.com/59/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=dranger003.wordpress.com&amp;blog=8657040&amp;post=59&amp;subd=dranger003&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://dranger003.wordpress.com/2009/09/03/byte-formatting/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/4cd276aaa319b12d0beaf23c65630769?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">dranger003</media:title>
		</media:content>
	</item>
	</channel>
</rss>
