<?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/"
	>

<channel>
	<title>Jean&#039;s Page &#187; video</title>
	<atom:link href="http://jeanbruenn.info/category/video/feed/" rel="self" type="application/rss+xml" />
	<link>http://jeanbruenn.info</link>
	<description>so what?</description>
	<lastBuildDate>Fri, 06 Jan 2012 21:38:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Upscaling in Avisynth &#8211; Comparison of resizers</title>
		<link>http://jeanbruenn.info/2011/10/30/upscaling-in-avisynth-comparison-of-resizers/</link>
		<comments>http://jeanbruenn.info/2011/10/30/upscaling-in-avisynth-comparison-of-resizers/#comments</comments>
		<pubDate>Sun, 30 Oct 2011 20:05:27 +0000</pubDate>
		<dc:creator>Jean</dc:creator>
				<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://jeanbruenn.info/?p=1106</guid>
		<description><![CDATA[I made this tests because I was searching for a pretty good upscaler. Checking pictures manually is a very subjective thing and so I wanted a way to &#8220;calculate&#8221; how good a/an scaler/upscaler is. The easiest approach is to check, how similar the upscaled variant is to the original variant. Which is, what my tests [...]]]></description>
			<content:encoded><![CDATA[<p>I made this tests because I was searching for a pretty good upscaler. Checking pictures manually is a very subjective thing and so I wanted a way to &#8220;calculate&#8221; how good a/an scaler/upscaler is. The easiest approach is to check, how similar the upscaled variant is to the original variant. Which is, what my tests do.</p>
<p><span id="more-1106"></span></p>
<ol>
<li><a href="#usedsoftware">used software/material</a></li>
<li><a href="#preparation">preparation</a></li>
<li><a href="#execution">execution</a></li>
<li><a href="#results">results</a>
<ol>
<li><a href="#testcase1">testcase1 &#8211; big buck bunny 1920&#215;1080 &raquo; lanczos 854&#215;480 &raquo; 1920&#215;1080</a></li>
<li><a href="#testcase2">testcase2 &#8211; sintel 1920&#215;818 &raquo; lanczos 1126&#215;480 &raquo; 1920&#215;1080</a></li>
<li><a href="#testcase3">testcase3 &#8211; elephants dream 1920&#215;1080 &raquo; bicubic 640&#215;360 &raquo; 1920&#215;1080</a></li>
<li><a href="#result">overall result</a></li>
<li><a href="#visual">visual results</a></li>
</ol>
</li>
<li><a href="#conclusion">conclusion</a></li>
</ol>
<p><a name="usedsoftware">&nbsp;</a><br />
<strong>used software/material</strong><br />
MPlayer, Avisynth, Bash, Gimp, ImageMagick, OpenMovie Sintel, OpenMovie Big Buck Bunny, OpenMovie Elephants Dream</p>
<p><a name="preparation">&nbsp;</a><br />
<strong>preparation</strong><br />
I took screenshots of a movie, stored the original highres image and created a lowscaled version of it. Then I created upscaled (to the same resolution as the highres image) variants of that lowscaled variant. And finally I compared the upscaled variant with the original highres variant.</p>
<p><a name="execution">&nbsp;</a><br />
<strong>execution</strong><br />
To create screenshots I have written a little Bashscript which gets screenshots using mplayer. The quality of the jpegs is set to 100 to have &#8220;lossless&#8221; images (more or less). The script needs ffmpeg to get the duration of the movie (pretty sure that might work with mplayer aswell, just didn&#8217;t find out how to easily parse that):</p>
<pre>#!/bin/bash

infile=$1;
amount=$2;

# getting the length of the movie in seconds
ffmpeg -i "$infile" 2>/tmp/video.log
h=$(grep Duration /tmp/video.log | awk '{ print $2 }' | cut -d: -f1);
m=$(grep Duration /tmp/video.log | awk '{ print $2 }' | cut -d: -f2);
s=$(echo "($h * 60 * 60) + ($m * 60) - 60" | bc);

for (( x=1; x<=$amount; x++)); do
  stime=$(echo "$x * ($s / $amount)" | bc);
  echo $stime;
  tmp=$(mplayer -frames 1 -ss $stime -vo jpeg:quality=100:outdir=screens $infile > /dev/null);
  mv screens/00000001.jpg screens/$x.jpg
done</pre>
<p>Then I&#8217;ve used gimp to create low-res variants of that screens &#8211; For the first two testcases I used lanczos and downscaled to a height of 480px. For the third testcase I used bicubic and downscaled to a height of 360px.</p>
<p>Then I&#8217;ve used lots of avisynth scripts to do the upscaling. An example for blackman and nnedi3:</p>
<pre>source = ImageSource("3.jpg").Trim(0,-1)
us3 = BlackmanResize(source, 1920, 1080)
us13 = nnedi3_rpow2(source, rfactor=4, cshift="spline36resize", fwidth=1920, fheight=1080)

#ImageWriter(us3, file="3_blackman", type="jpeg")
ImageWriter(us13, file="3_nnedi3", type="jpeg")</pre>
<p>The resulting upscaled image I&#8217;ve compared to the original image using ImageMagick:</p>
<pre>convert originalimage.jpg upscaledimage.jpg -fx "abs(u[0]-u[1])" pgm:- \
  | identify -verbose pgm:- \
  | grep -E "mean|max|devi"</pre>
<p><a name="results">&nbsp;</a><br />
<strong>results</strong></p>
<p><a name="testcase1">&nbsp;</a><br />
<em>Big Buck Bunny</em></p>
<p>1920&#215;1080 &raquo; (lanczos) 854&#215;480 &raquo; 1920&#215;1080</p>
<table cellspacing="5" cellpadding="3" border="0" style="font-size: 10px;" class="video">
<tr>
<td><b>screenthumbnail</b></td>
<td><b>method used</b></td>
<td><b>peak</b></td>
<td><b>average</b></td>
<td><b>standard deviation</b></td>
<td><b>filesize</b></td>
</tr>
<tr>
<td rowspan="14" style="vertical-align: top;"><a rel="lightbox[]" href='http://jeanbruenn.info/wp-content/gallery/video_upscale/1.jpg' title=''><img src='http://jeanbruenn.info/wp-content/gallery/video_upscale/thumbs/thumbs_1.jpg' height='60' alt='1' class='ngg-singlepic ngg-none' /></a></td>
<td>original</td>
<td>-</td>
<td>-</td>
<td>-</td>
<td>640K</td>
</tr>
<tr>
<td>bicubicResize</td>
<td>63 (0.247059)</td>
<td>1.39138 (0.0054564)</td>
<td>2.02799 (0.00795292)</td>
<td>564K</td>
</tr>
<tr>
<td>bilinearResize</td>
<td>66 (0.258824)</td>
<td>1.41046 (0.00553122)</td>
<td>2.1246 (0.00833176)</td>
<td>568K</td>
</tr>
<tr>
<td>blackmanResize</td>
<td>60 (0.235294)</td>
<td>1.32716 (0.00520453)</td>
<td>1.7842 (0.00699688)</td>
<td>584K</td>
</tr>
<tr>
<td>lanczosResize</td>
<td>59 (0.231373)</td>
<td>1.32695 (0.00520371)</td>
<td>1.76561 (0.00692397)</td>
<td>588K</td>
</tr>
<tr>
<td>lanczos4resize</td>
<td>58 (0.227451)</td>
<td>1.31528 (0.00515796)</td>
<td>1.73246 (0.00679397)</td>
<td>592K</td>
</tr>
<tr>
<td>pointresize</td>
<td>138 (0.541176)</td>
<td>1.93816 (0.00760062)</td>
<td>3.38685 (0.0132818)</td>
<td>688K</td>
</tr>
<tr>
<td>sincresize</td>
<td>97 (0.380392)</td>
<td>1.94942 (0.00764479)</td>
<td>3.12623 (0.0122597)</td>
<td>712K</td>
</tr>
<tr>
<td>spline16resize</td>
<td>60 (0.235294)</td>
<td>1.34655 (0.0052806)</td>
<td>1.85531 (0.00727572)</td>
<td>580K</td>
</tr>
<tr>
<td>spline36resize</td>
<td>58 (0.227451)</td>
<td>1.32948 (0.00521366)</td>
<td>1.78602 (0.00700402)</td>
<td>584K</td>
</tr>
<tr>
<td>spline64resize</td>
<td>59 (0.231373)</td>
<td>1.3242 (0.00519292)</td>
<td>1.77446 (0.00695865)</td>
<td>584K</td>
</tr>
<tr>
<td>nnedi3 (cshift=spline36)</td>
<td>59 (0.231373)</td>
<td>1.34151 (0.00526083)</td>
<td>1.76169 (0.00690858)</td>
<td>616K</td>
</tr>
<tr>
<td>nnedi3 (cshift=spline36, pscnr=4, etype=1)</td>
<td>56 (0.219608)</td>
<td>1.34097 (0.0052587)</td>
<td>1.76592 (0.00692518)</td>
<td>620K</td>
</tr>
<tr>
<td>spline36resize(hq4x)</td>
<td>81 (0.317647)</td>
<td>1.61154 (0.00631977)</td>
<td>2.08531 (0.00817769)</td>
<td>568K</td>
</tr>
<tr>
<td><b>screenthumbnail</b></td>
<td><b>method used</b></td>
<td><b>peak</b></td>
<td><b>average</b></td>
<td><b>standard deviation</b></td>
<td><b>filesize</b></td>
</tr>
<tr>
<td rowspan="14" style="vertical-align: top;"><a rel="lightbox[]" href='http://jeanbruenn.info/wp-content/gallery/video_upscale/2.jpg' title=''><img src='http://jeanbruenn.info/wp-content/gallery/video_upscale/thumbs/thumbs_2.jpg' height='60' alt='2' class='ngg-singlepic ngg-none' /></a></td>
<td>original</td>
<td>-</td>
<td>-</td>
<td>-</td>
<td>1100K</td>
</tr>
<tr>
<td>bicubicresize</td>
<td>131 (0.513725)</td>
<td>2.01965 (0.0079202)</td>
<td>2.58451 (0.0101353)</td>
<td>716K</td>
</tr>
<tr>
<td>bilinearresize</td>
<td>129 (0.505882)</td>
<td>2.06215 (0.00808685)</td>
<td>2.66154 (0.0104374)</td>
<td>724K</td>
</tr>
<tr>
<td>blackmanresize</td>
<td>128 (0.501961)</td>
<td>1.92173 (0.0075362)</td>
<td>2.37666 (0.00932023)</td>
<td>744K</td>
</tr>
<tr>
<td>lanczosresize</td>
<td>128 (0.501961)</td>
<td>1.91967 (0.0075281)</td>
<td>2.36059 (0.00925722)</td>
<td>752K</td>
</tr>
<tr>
<td>lanczos4resize</td>
<td>128 (0.501961)</td>
<td>1.89933 (0.00744836)</td>
<td>2.33001 (0.00913729)</td>
<td>756K</td>
</tr>
<tr>
<td>pointresize</td>
<td>173 (0.678431)</td>
<td>3.04469 (0.01194)</td>
<td>3.97362 (0.0155828)</td>
<td>924K</td>
</tr>
<tr>
<td>sincresize</td>
<td>167 (0.654902)</td>
<td>2.94485 (0.0115484)</td>
<td>3.62896 (0.0142312)</td>
<td>920K</td>
</tr>
<tr>
<td>spline16resize</td>
<td>128 (0.501961)</td>
<td>1.95451 (0.00766474)</td>
<td>2.44045 (0.00957039)</td>
<td>740K</td>
</tr>
<tr>
<td>spline36resize</td>
<td>128 (0.501961)</td>
<td>1.92393 (0.00754484)</td>
<td>2.37922 (0.00933026)</td>
<td>744K</td>
</tr>
<tr>
<td>spline64resize</td>
<td>129 (0.505882)</td>
<td>1.91636 (0.00751512)</td>
<td>2.36858 (0.00928855)</td>
<td>744K</td>
</tr>
<tr>
<td>nnedi3 (cshift=spline36)</td>
<td>119 (0.466667)</td>
<td>1.94348 (0.00762151)</td>
<td>2.34163 (0.00918287)</td>
<td>776K</td>
</tr>
<tr>
<td>nnedi3 (cshift=spline36, pscnr=4, etype=1)</td>
<td>112 (0.439216)</td>
<td>1.94203 (0.00761579)</td>
<td>2.34288 (0.00918778)</td>
<td>776K</td>
</tr>
<tr>
<td>spline36resize(hq4x)</td>
<td>122 (0.478431)</td>
<td>2.19204 (0.00859625)</td>
<td>2.6589 (0.0104271)</td>
<td>744K</td>
</tr>
<tr>
<td><b>screenthumbnail</b></td>
<td><b>method used</b></td>
<td><b>peak</b></td>
<td><b>average</b></td>
<td><b>standard deviation</b></td>
<td><b>filesize</b></td>
</tr>
<tr>
<td rowspan="14" style="vertical-align: top;"><a rel="lightbox[]" href='http://jeanbruenn.info/wp-content/gallery/video_upscale/3.jpg' title=''><img src='http://jeanbruenn.info/wp-content/gallery/video_upscale/thumbs/thumbs_3.jpg' height='60' alt='3' class='ngg-singlepic ngg-none' /></a></td>
<td>original</td>
<td>-</td>
<td>-</td>
<td>-</td>
<td>732K</td>
</tr>
<tr>
<td>bicubicresize</td>
<td>49 (0.192157)</td>
<td>1.32602 (0.00520009)</td>
<td>1.51821 (0.00595376)</td>
<td>572K</td>
</tr>
<tr>
<td>bilinearresize</td>
<td>53 (0.207843)</td>
<td>1.33697 (0.00524301)</td>
<td>1.57944 (0.0061939)</td>
<td>572K</td>
</tr>
<tr>
<td>blackmanresize</td>
<td>43 (0.168627)</td>
<td>1.29434 (0.00507583)</td>
<td>1.3829 (0.00542314)</td>
<td>592K</td>
</tr>
<tr>
<td>lanczosresize</td>
<td>41 (0.160784)</td>
<td>1.29722 (0.00508715)</td>
<td>1.37439 (0.00538977)</td>
<td>596K</td>
</tr>
<tr>
<td>lanczos4resize</td>
<td>41 (0.160784)</td>
<td>1.28806 (0.00505121)</td>
<td>1.35241 (0.00530357)</td>
<td>596K</td>
</tr>
<tr>
<td>pointresize</td>
<td>144 (0.564706)</td>
<td>1.86225 (0.00730295)</td>
<td>2.74764 (0.010775)</td>
<td>692K</td>
</tr>
<tr>
<td>sincresize</td>
<td>110 (0.431373)</td>
<td>1.85213 (0.00726325)</td>
<td>2.47998 (0.00972541)</td>
<td>708K</td>
</tr>
<tr>
<td>spline16resize</td>
<td>44 (0.172549)</td>
<td>1.306 (0.00512158)</td>
<td>1.42527 (0.00558931)</td>
<td>584K</td>
</tr>
<tr>
<td>spline36resize</td>
<td>43 (0.168627)</td>
<td>1.29596 (0.00508218)</td>
<td>1.38413 (0.00542798)</td>
<td>588K</td>
</tr>
<tr>
<td>spline64resize</td>
<td>42 (0.164706)</td>
<td>1.29306 (0.00507082)</td>
<td>1.37745 (0.00540178)</td>
<td>592K</td>
</tr>
<tr>
<td>nnedi3 (cshift=spline36)</td>
<td>39 (0.152941)</td>
<td>1.30354 (0.00511192)</td>
<td>1.36729 (0.00536193)</td>
<td>620K</td>
</tr>
<tr>
<td>nnedi3 (cshift=spline36, pscnr=4, etype=1)</td>
<td>39 (0.152941)</td>
<td>1.30032 (0.00509928)</td>
<td>1.36227 (0.00534222)</td>
<td>624K</td>
</tr>
<tr>
<td>spline36resize(hq4x)</td>
<td>77 (0.301961)</td>
<td>1.52609 (0.00598468)</td>
<td>1.58047 (0.00619794)</td>
<td>572K</td>
</tr>
</table>
<p><a name="testcase2">&nbsp;</a><br />
<em>Sintel</em></p>
<p>1920&#215;818 &raquo; (lanczos) 1126&#215;480 &raquo; 1920&#215;1080</p>
<table cellspacing="5" cellpadding="3" border="0" style="font-size: 10px;" class="video">
<tr>
<td><b>screenthumbnail</b></td>
<td><b>method used</b></td>
<td><b>peak</b></td>
<td><b>average</b></td>
<td><b>standard deviation</b></td>
<td><b>filesize</b></td>
</tr>
<tr>
<td rowspan="15" style="vertical-align: top;"><a rel="lightbox[]" href='http://jeanbruenn.info/wp-content/gallery/video_upscale/1_0.jpg' title=''><img src='http://jeanbruenn.info/wp-content/gallery/video_upscale/thumbs/thumbs_1_0.jpg' height='40' alt='1_0' class='ngg-singlepic ngg-none' /></a></td>
</tr>
<tr>
<td>original</td>
<td>-</td>
<td>-</td>
<td>-</td>
<td>620K</td>
</tr>
<tr>
<td>bicubicresize</td>
<td>76 (0.298039)</td>
<td>1.22795 (0.00481549)</td>
<td>1.64521 (0.00645182)</td>
<td>444K</td>
</tr>
<tr>
<td>bilinearresize</td>
<td>78 (0.305882)</td>
<td>1.22377 (0.0047991)</td>
<td>1.66566 (0.00653199)</td>
<td>440K</td>
</tr>
<tr>
<td>blackmanresize</td>
<td>72 (0.282353)</td>
<td>1.23057 (0.00482575)</td>
<td>1.57433 (0.00617384)</td>
<td>464K</td>
</tr>
<tr>
<td>lanczosresize</td>
<td>71 (0.278431)</td>
<td>1.2383 (0.00485609)</td>
<td>1.57933 (0.00619346)</td>
<td>468K</td>
</tr>
<tr>
<td>lanczos4resize</td>
<td>70 (0.27451)</td>
<td>1.24825 (0.00489511)</td>
<td>1.59137 (0.00624068)</td>
<td>472K</td>
</tr>
<tr>
<td>pointresize</td>
<td>106 (0.415686)</td>
<td>1.48345 (0.00581747)</td>
<td>2.42587 (0.00951323)</td>
<td>508K</td>
</tr>
<tr>
<td>sincresize</td>
<td>88 (0.345098)</td>
<td>1.47682 (0.00579147)</td>
<td>2.15301 (0.00844318)</td>
<td>492K</td>
</tr>
<tr>
<td>spline16resize</td>
<td>73 (0.286275)</td>
<td>1.2257 (0.00480666)</td>
<td>1.58467 (0.00621438)</td>
<td>460K</td>
</tr>
<tr>
<td>spline36resize</td>
<td>72 (0.282353)</td>
<td>1.23204 (0.00483153)</td>
<td>1.57656 (0.00618259)</td>
<td>464K</td>
</tr>
<tr>
<td>spline64resize</td>
<td>71 (0.278431)</td>
<td>1.23371 (0.00483806)</td>
<td>1.57686 (0.00618377)</td>
<td>464K</td>
</tr>
<tr>
<td>nnedi3 (cshift=spline36)</td>
<td>70 (0.27451)</td>
<td>1.2102 (0.00474587)</td>
<td>1.53526 (0.00602061)</td>
<td>484K</td>
</tr>
<tr>
<td>nnedi3 (cshift=spline36, pscnr=4, etype=1)</td>
<td>76 (0.298039)</td>
<td>1.20684 (0.00473269)</td>
<td>1.53277 (0.00601086)</td>
<td>484K</td>
</tr>
<tr>
<td>spline36resize(hq4x)</td>
<td>77 (0.301961)</td>
<td>1.4199 (0.00556825)</td>
<td>1.62984 (0.00639155)</td>
<td>416K</td>
</tr>
<tr>
<td><b>screenthumbnail</b></td>
<td><b>method used</b></td>
<td><b>peak</b></td>
<td><b>average</b></td>
<td><b>standard deviation</b></td>
<td><b>filesize</b></td>
</tr>
<tr>
<td rowspan="15" style="vertical-align: top;"><a rel="lightbox[]" href='http://jeanbruenn.info/wp-content/gallery/video_upscale/2_0.jpg' title=''><img src='http://jeanbruenn.info/wp-content/gallery/video_upscale/thumbs/thumbs_2_0.jpg' height='40' alt='2_0' class='ngg-singlepic ngg-none' /></a></td>
</tr>
<tr>
<td>original</td>
<td>-</td>
<td>-</td>
<td>-</td>
<td>1200K</td>
</tr>
<tr>
<td>bicubicresize</td>
<td>68 (0.266667)</td>
<td>3.90677 (0.0153207)</td>
<td>4.63845 (0.01819)</td>
<td>756K</td>
</tr>
<tr>
<td>bilinearresize</td>
<td>72 (0.282353)</td>
<td>3.93428 (0.0154286)</td>
<td>4.70239 (0.0184407)</td>
<td>772K</td>
</tr>
<tr>
<td>blackmanresize</td>
<td>70 (0.27451)</td>
<td>3.75073 (0.0147087)</td>
<td>4.45619 (0.0174752)</td>
<td>824K</td>
</tr>
<tr>
<td>lanczosresize</td>
<td>69 (0.270588)</td>
<td>3.77025 (0.0147853)</td>
<td>4.47537 (0.0175505)</td>
<td>832K</td>
</tr>
<tr>
<td>lanczos4resize</td>
<td>70 (0.27451)</td>
<td>3.80719 (0.0149302)</td>
<td>4.51547 (0.0177077)</td>
<td>832K</td>
</tr>
<tr>
<td>pointresize</td>
<td>141 (0.552941)</td>
<td>5.41135 (0.021221)</td>
<td>7.10313 (0.0278554)</td>
<td>992K</td>
</tr>
<tr>
<td>sincresize</td>
<td>113 (0.443137)</td>
<td>5.13697 (0.020145)</td>
<td>6.00752 (0.0235589)</td>
<td>880K</td>
</tr>
<tr>
<td>spline16resize</td>
<td>70 (0.27451)</td>
<td>3.76273 (0.0147558)</td>
<td>4.47469 (0.0175478)</td>
<td>812K</td>
</tr>
<tr>
<td>spline36resize</td>
<td>70 (0.27451)</td>
<td>3.75862 (0.0147397)</td>
<td>4.46286 (0.0175014)</td>
<td>820K</td>
</tr>
<tr>
<td>spline64resize</td>
<td>70 (0.27451)</td>
<td>3.7603 (0.0147463)</td>
<td>4.46454 (0.017508)</td>
<td>824K</td>
</tr>
<tr>
<td>nnedi3 (cshift=spline36)</td>
<td>75 (0.294118)</td>
<td>3.69705 (0.0144982)</td>
<td>4.36505 (0.0171178)</td>
<td>836K</td>
</tr>
<tr>
<td>nnedi3 (cshift=spline36, pscnr=4, etype=1)</td>
<td>72 (0.282353)</td>
<td>3.68776 (0.0144618)</td>
<td>4.35658 (0.0170846)</td>
<td>836K</td>
</tr>
<tr>
<td>spline36resize(hq4x)</td>
<td>68 (0.266667)</td>
<td>3.9761 (0.0155926)</td>
<td>4.64142 (0.0182016)</td>
<td>760K</td>
</tr>
<tr>
<td><b>screenthumbnail</b></td>
<td><b>method used</b></td>
<td><b>peak</b></td>
<td><b>average</b></td>
<td><b>standard deviation</b></td>
<td><b>filesize</b></td>
</tr>
<tr>
<td rowspan="15" style="vertical-align: top;"><a rel="lightbox[]" href='http://jeanbruenn.info/wp-content/gallery/video_upscale/3_0.jpg' title=''><img src='http://jeanbruenn.info/wp-content/gallery/video_upscale/thumbs/thumbs_3_0.jpg' height='40' alt='3_0' class='ngg-singlepic ngg-none' /></a></td>
</tr>
<tr>
<td>original</td>
<td>-</td>
<td>-</td>
<td>-</td>
<td>652K</td>
</tr>
<tr>
<td>bicubicresize</td>
<td>102 (0.4)</td>
<td>1.61719 (0.00634193)</td>
<td>3.41673 (0.013399)</td>
<td>516K</td>
</tr>
<tr>
<td>bilinearresize</td>
<td>113 (0.443137)</td>
<td>1.62747 (0.00638224)</td>
<td>3.50645 (0.0137508)</td>
<td>516K</td>
</tr>
<tr>
<td>blackmanresize</td>
<td>103 (0.403922)</td>
<td>1.57874 (0.00619113)</td>
<td>3.1816 (0.0124769)</td>
<td>544K</td>
</tr>
<tr>
<td>lanczosresize</td>
<td>107 (0.419608)</td>
<td>1.58978 (0.00623445)</td>
<td>3.1924 (0.0125192)</td>
<td>548K</td>
</tr>
<tr>
<td>lanczos4resize</td>
<td>118 (0.462745)</td>
<td>1.60308 (0.00628658)</td>
<td>3.20413 (0.0125652)</td>
<td>552K</td>
</tr>
<tr>
<td>pointresize</td>
<td>212 (0.831373)</td>
<td>2.33259 (0.00914742)</td>
<td>5.96943 (0.0234095)</td>
<td>612K</td>
</tr>
<tr>
<td>sincresize</td>
<td>141 (0.552941)</td>
<td>2.18924 (0.00858526)</td>
<td>4.94182 (0.0193797)</td>
<td>588K</td>
</tr>
<tr>
<td>spline16resize</td>
<td>102 (0.4)</td>
<td>1.58086 (0.00619945)</td>
<td>3.22538 (0.0126486)</td>
<td>536K</td>
</tr>
<tr>
<td>spline36resize</td>
<td>104 (0.407843)</td>
<td>1.58196 (0.00620377)</td>
<td>3.18951 (0.0125079)</td>
<td>544K</td>
</tr>
<tr>
<td>spline64resize</td>
<td>106 (0.415686)</td>
<td>1.58257 (0.00620615)</td>
<td>3.18302 (0.0124824)</td>
<td>544K</td>
</tr>
<tr>
<td>nnedi3 (cshift=spline36)</td>
<td>99 (0.388235)</td>
<td>1.52185 (0.00596802)</td>
<td>2.96699 (0.0116352)</td>
<td>560K</td>
</tr>
<tr>
<td>nnedi3 (cshift=spline36, pscnr=4, etype=1)</td>
<td>101 (0.396078)</td>
<td>1.52184 (0.00596802)</td>
<td>2.98155 (0.0116923)</td>
<td>560K</td>
</tr>
<tr>
<td>spline36resize(hq4x)</td>
<td>106 (0.415686)</td>
<td>1.80159 (0.00706505)</td>
<td>3.38661 (0.0132808)</td>
<td>496K</td>
</tr>
</table>
<p><em>Averaged</em></p>
<table cellspacing="5" cellpadding="3" border="0" class="video">
<tr>
<td><b>method</b></td>
<td><b>average peak</b></td>
<td><b>average mean</b></td>
<td><b>average standard deviatation</b></td>
</tr>
<tr>
<td>bicubicresize</td>
<td>81.5</td>
<td>1.91</td>
<td>2.63</td>
</tr>
<tr>
<td>bilinearresize</td>
<td>85.16</td>
<td>1.93</td>
<td>2.70</td>
</tr>
<tr>
<td>blackmanresize</td>
<td>79.33</td>
<td>1.85</td>
<td>2.45</td>
</tr>
<tr>
<td>lanczosresize</td>
<td>79.16</td>
<td>1.85</td>
<td>2.45</td>
</tr>
<tr>
<td>lanczos4resize</td>
<td>80.83</td>
<td>1.86</td>
<td>2.45</td>
</tr>
<tr>
<td class="lightred">pointresize</td>
<td class="lightred">152.33</td>
<td class="lightred">2.67</td>
<td class="lightred">4.26</td>
</tr>
<tr>
<td class="lightred">sincresize</td>
<td class="lightred">119.33</td>
<td class="lightred">2.59</td>
<td class="lightred">3.72</td>
</tr>
<tr>
<td>spline16resize</td>
<td>79.5</td>
<td>1.86</td>
<td>2.5</td>
</tr>
<tr>
<td>spline36resize</td>
<td>79.16</td>
<td>1.85</td>
<td>2.46</td>
</tr>
<tr>
<td>spline64resize</td>
<td>79.5</td>
<td>1.85</td>
<td>2.45</td>
</tr>
<tr>
<td class="lightgreen">nnedi3 (cshift=spline36)</td>
<td class="lightgreen">76.83</td>
<td class="lightgreen">1.83</td>
<td class="lightgreen">2.38</td>
</tr>
<tr>
<td class="lightgreen">nnedi3 (cshift=spline36, pscnr=4, etype=1)</td>
<td class="lightgreen">76</td>
<td class="lightgreen">1.83</td>
<td class="lightgreen">2.39</td>
</tr>
<tr>
<td>spline36resize(hq4x)</td>
<td>88.5</td>
<td>2.08</td>
<td>2.66</td>
</tr>
</table>
<p><a name="testcase3">&nbsp;</a><br />
<em>Elephants Dream</em></p>
<p>1920&#215;1080 &raquo; (bicubic) 640&#215;360 &raquo; 1920&#215;1080</p>
<table cellspacing="5" cellpadding="3" border="0" style="font-size: 10px;" class="video">
<tr>
<td><b>screenthumbnail</b></td>
<td><b>method used</b></td>
<td><b>peak</b></td>
<td><b>average</b></td>
<td><b>standard deviation</b></td>
<td><b>filesize</b></td>
</tr>
<tr>
<td rowspan="10" style="vertical-align: top;"><a rel="lightbox[]" href='http://jeanbruenn.info/wp-content/gallery/video_upscale/1_1.jpg' title=''><img src='http://jeanbruenn.info/wp-content/gallery/video_upscale/thumbs/thumbs_1_1.jpg' height='40' alt='1_1' class='ngg-singlepic ngg-none' /></a></td>
</tr>
<tr>
<td>original</td>
<td>-</td>
<td>-</td>
<td>-</td>
<td>696K</td>
</tr>
<tr>
<td>blackmanresize</td>
<td>182 (0.713725)</td>
<td>5.15758 (0.0202258)</td>
<td>9.2996 (0.036469)</td>
<td>672K</td>
</tr>
<tr>
<td>lanczosresize</td>
<td>181 (0.709804)</td>
<td>5.17115 (0.020279)</td>
<td>9.25688 (0.0363015)</td>
<td>676K</td>
</tr>
<tr>
<td>lanczos4resize</td>
<td>180 (0.705882)</td>
<td>5.19959 (0.0203906)</td>
<td>9.21027 (0.0361187)</td>
<td>684K</td>
</tr>
<tr>
<td>spline16resize</td>
<td>183 (0.717647)</td>
<td>5.21444 (0.0204488)</td>
<td>9.46563 (0.0371201)</td>
<td>672K</td>
</tr>
<tr>
<td>spline36resize</td>
<td>182 (0.713725)</td>
<td>5.1683 (0.0202678)</td>
<td>9.30998 (0.0365097)</td>
<td>672K</td>
</tr>
<tr>
<td>spline64resize</td>
<td>182 (0.713725)</td>
<td>5.16437 (0.0202524)</td>
<td>9.28429 (0.036409)</td>
<td>672K</td>
</tr>
<tr>
<td>nnedi3 (cshift=spline36)</td>
<td>174 (0.682353)</td>
<td>4.71817 (0.0185026)</td>
<td>8.52777 (0.0334422)</td>
<td>724K</td>
</tr>
<tr>
<td>nnedi3 (cshift=spline36, pscnr=4, etype=1)</td>
<td>176 (0.690196)</td>
<td>4.70834 (0.0184641)</td>
<td>8.60432 (0.0337424)</td>
<td>732K</td>
</tr>
<tr>
<td><b>screenthumbnail</b></td>
<td><b>method used</b></td>
<td><b>peak</b></td>
<td><b>average</b></td>
<td><b>standard deviation</b></td>
<td><b>filesize</b></td>
</tr>
<tr>
<td rowspan="10" style="vertical-align: top;"><a rel="lightbox[]" href='http://jeanbruenn.info/wp-content/gallery/video_upscale/2_1.jpg' title=''><img src='http://jeanbruenn.info/wp-content/gallery/video_upscale/thumbs/thumbs_2_1.jpg' height='40' alt='2_1' class='ngg-singlepic ngg-none' /></a></td>
</tr>
<tr>
<td>original</td>
<td>-</td>
<td>-</td>
<td>-</td>
<td>328K</td>
</tr>
<tr>
<td>blackmanresize</td>
<td>62 (0.243137)</td>
<td>1.10186 (0.00432103)</td>
<td>1.69206 (0.00663553)</td>
<td>496K</td>
</tr>
<tr>
<td>lanczosresize</td>
<td>63 (0.247059)</td>
<td>1.10822 (0.00434597)</td>
<td>1.68183 (0.0065954)</td>
<td>676K</td>
</tr>
<tr>
<td>lanczos4resize</td>
<td>62 (0.243137)</td>
<td>1.11478 (0.00437168)</td>
<td>1.67341 (0.00656238)</td>
<td>504K</td>
</tr>
<tr>
<td>spline16resize</td>
<td>62 (0.243137)</td>
<td>1.10619 (0.00433802)</td>
<td>1.73069 (0.00678702)</td>
<td>488K</td>
</tr>
<tr>
<td>spline36resize</td>
<td>62 (0.243137)</td>
<td>1.10259 (0.00432386)</td>
<td>1.69271 (0.00663806)</td>
<td>496K</td>
</tr>
<tr>
<td>spline64resize</td>
<td>63 (0.247059)</td>
<td>1.10177 (0.00432066)</td>
<td>1.68822 (0.00662046)</td>
<td>496K</td>
</tr>
<tr>
<td>nnedi3 (cshift=spline36)</td>
<td>56 (0.219608)</td>
<td>1.08019 (0.00423605)</td>
<td>1.54706 (0.00606689)</td>
<td>524K</td>
</tr>
<tr>
<td>nnedi3 (cshift=spline36, pscnr=4, etype=1)</td>
<td>52 (0.203922)</td>
<td>1.07437 (0.00421321)</td>
<td>1.53682 (0.00602673)</td>
<td>524K</td>
</tr>
<tr>
<td><b>screenthumbnail</b></td>
<td><b>method used</b></td>
<td><b>peak</b></td>
<td><b>average</b></td>
<td><b>standard deviation</b></td>
<td><b>filesize</b></td>
</tr>
<tr>
<td rowspan="10" style="vertical-align: top;"><a rel="lightbox[]" href='http://jeanbruenn.info/wp-content/gallery/video_upscale/3_1.jpg' title=''><img src='http://jeanbruenn.info/wp-content/gallery/video_upscale/thumbs/thumbs_3_1.jpg' height='40' alt='3_1' class='ngg-singlepic ngg-none' /></a></td>
</tr>
<tr>
<td>original</td>
<td>-</td>
<td>-</td>
<td>-</td>
<td>648K</td>
</tr>
<tr>
<td>blackmanresize</td>
<td>131 (0.513725)</td>
<td>3.69918 (0.0145066)</td>
<td>6.33968 (0.0248615)</td>
<td>688K</td>
</tr>
<tr>
<td>lanczosresize</td>
<td>128 (0.501961)</td>
<td>3.70108 (0.014514)</td>
<td>6.31411 (0.0247612)</td>
<td>696K</td>
</tr>
<tr>
<td>lanczos4resize</td>
<td>127 (0.498039)</td>
<td>3.72408 (0.0146042)</td>
<td>6.30599 (0.0247294)</td>
<td>700K</td>
</tr>
<tr>
<td>spline16resize</td>
<td>132 (0.517647)</td>
<td>3.74263 (0.014677)</td>
<td>6.43383 (0.0252307)</td>
<td>684K</td>
</tr>
<tr>
<td>spline36resize</td>
<td>129 (0.505882)</td>
<td>3.7027 (0.0145204)</td>
<td>6.3419 (0.0248702)</td>
<td>688K</td>
</tr>
<tr>
<td>spline64resize</td>
<td>129 (0.505882)</td>
<td>3.70227 (0.0145187)</td>
<td>6.33526 (0.0248442)</td>
<td>688K</td>
</tr>
<tr>
<td>nnedi3 (cshift=spline36)</td>
<td>127 (0.498039)</td>
<td>3.39755 (0.0133237)</td>
<td>5.79667 (0.022732)</td>
<td>736K</td>
</tr>
<tr>
<td>nnedi3 (cshift=spline36, pscnr=4, etype=1)</td>
<td>125 (0.490196)</td>
<td>3.39746 (0.0133234)</td>
<td>5.7985 (0.0227392)</td>
<td>740K</td>
</tr>
</table>
<p><a name="result">&nbsp;</a><br />
<em>Averaged #2</em></p>
<p>first average result + picture 1 result + picture 2 result + picture 3 result / 4</p>
<table cellspacing="5" cellpadding="3" border="0" class="video">
<tr>
<td><b>method</b></td>
<td><b>average peak</b></td>
<td><b>average mean</b></td>
<td><b>average standard deviatation</b></td>
</tr>
<tr>
<td>blackmanresize</td>
<td>113.58</td>
<td>2.95</td>
<td>4.94</td>
</tr>
<tr>
<td>lanczosresize</td>
<td>112.79</td>
<td>2.95</td>
<td>4.92</td>
</tr>
<tr>
<td>lanczos4resize</td>
<td>112.45</td>
<td>2.97</td>
<td>4.90</td>
</tr>
<tr>
<td class="lightred">spline16resize</td>
<td class="lightred">114.12</td>
<td class="lightred">2.98</td>
<td class="lightred">5.03</td>
</tr>
<tr>
<td>spline36resize</td>
<td>113.04</td>
<td>2.95</td>
<td>4.95</td>
</tr>
<tr>
<td>spline64resize</td>
<td>113.37</td>
<td>2.95</td>
<td>4.93</td>
</tr>
<tr>
<td class="lightgreen">nnedi3 (cshift=spline36)</td>
<td class="lightgreen">108.45</td>
<td class="lightgreen">2.75</td>
<td class="lightgreen">4.56</td>
</tr>
<tr>
<td class="lightgreen">nnedi3 (cshift=spline36, pscnr=4, etype=1)</td>
<td class="lightgreen">107.25</td>
<td class="lightgreen">2.75</td>
<td class="lightgreen">4.58</td>
</tr>
</table>
<p><a name="visual">&nbsp;</a><br />
<strong>visual results</strong><br />
At the top of this long article I already explained that visual results are very subjective; that is because things look differently on different screens (tft/crt/etc), also due to different brightness and similar settings. However, sometimes the visual difference is obvious. Here are some examples:</p>
<table cellspacing="5" cellpadding="3" border="0">
<tr>
<td>original<br /><a rel="lightbox[]" href='http://jeanbruenn.info/wp-content/gallery/video_upscale/original.jpg' title=''><img src='http://jeanbruenn.info/wp-content/gallery/video_upscale/thumbs/thumbs_original.jpg' alt='original' class='ngg-singlepic ngg-none' /></a></td>
<td>lanczos<br /><a rel="lightbox[]" href='http://jeanbruenn.info/wp-content/gallery/video_upscale/lanczos.jpg' title=''><img src='http://jeanbruenn.info/wp-content/gallery/video_upscale/thumbs/thumbs_lanczos.jpg' alt='lanczos' class='ngg-singlepic ngg-none' /></a></td>
</tr>
<tr>
<td>spline36<br /><a rel="lightbox[]" href='http://jeanbruenn.info/wp-content/gallery/video_upscale/spline36.jpg' title=''><img src='http://jeanbruenn.info/wp-content/gallery/video_upscale/thumbs/thumbs_spline36.jpg' alt='spline36' class='ngg-singlepic ngg-none' /></a></td>
<td>nnedi3<br /><a rel="lightbox[]" href='http://jeanbruenn.info/wp-content/gallery/video_upscale/nnedi_pscrn.jpg' title=''><img src='http://jeanbruenn.info/wp-content/gallery/video_upscale/thumbs/thumbs_nnedi_pscrn.jpg' alt='nnedi_pscrn' class='ngg-singlepic ngg-none' /></a></td>
</tr>
</table>
<p><a name="conclusion">&nbsp;</a><br />
<strong>Conclusion</strong><br />
What we can see, looking at the numbers, is that the higher the resolution of your source (or better, the more details the source has) the better upscaling works. If your source is too blurry, upscaling won&#8217;t work as good as it could. All scalers perform quite good (except for point and sinc, but that was to be expected). Spline16 performs worse than spline36 and spline64, for upscaling spline36 performs better than spline64. Lanczos and spline are quite similar the difference is very minimal, according to the numbers, lanczos performs better than spline; overall best resizer for upscaling is nnedi3. Another thing which you can see in the visual results above is that the nnedi3 image doesn&#8217;t have the stairs-effect.</p>
<p>If you have to decide which resizer (in avisynth) to use for upscaling, go this route:</p>
<pre>nnedi3 > lanczos/lanczos4 > spline36 > everything else</pre>
]]></content:encoded>
			<wfw:commentRss>http://jeanbruenn.info/2011/10/30/upscaling-in-avisynth-comparison-of-resizers/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>AviSynth Networking &amp; MultiCores in Linux</title>
		<link>http://jeanbruenn.info/2011/06/03/avisynth-networking-multicores-in-linux/</link>
		<comments>http://jeanbruenn.info/2011/06/03/avisynth-networking-multicores-in-linux/#comments</comments>
		<pubDate>Fri, 03 Jun 2011 20:55:36 +0000</pubDate>
		<dc:creator>Jean</dc:creator>
				<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://jeanbruenn.info/new/?p=604</guid>
		<description><![CDATA[I have a few boxes around at home, so if i do video-editing i&#8217;d like to benefit from that. We can use some avisynth plugins/enhancements to do so. There are two things we might do: a) running filters in parallel b) handing filters to another box (networking). The problem with multiple cores in Linux is [...]]]></description>
			<content:encoded><![CDATA[<p>I have a few boxes around at home, so if i do video-editing i&#8217;d like to benefit from that. We can use some avisynth plugins/enhancements to do so. There are two things we might do: a) running filters in parallel b) handing filters to another box (networking). The problem with multiple cores in Linux is that it&#8217;s not easily possible to run Avisynth on many cores in fact it&#8217;s per default just running on one core.<br />
<span id="more-604"></span></p>
<h2>MT Approach</h2>
<p>Let&#8217;s first take a look at the multiple cores issue.</p>
<pre> 3760 wdp       20   0 1573m  48m 6584 R   99  2.4   0:58.37 avs2yuv
 3761 wdp       20   0  104m  57m 1336 S    4  2.8   0:01.40 x264
</pre>
<p>What you can see here is simple &#8211; I&#8217;m running avisynth using</p>
<pre>wine avs2yuv test.avs - | x264 --demuxer y4m --output output.264 -</pre>
<p>avs2yuv has 99% CPU where as it should have 200% (taking both cores into account) and x264 needs only 4% cpu (because the avisynth script is way too slow for x264 to even notice) &#8211; And here we got our first problem. Let&#8217;s see if we can change that behaviour. So i installed MT() and played around.</p>
<ul>
<li>SetMtMode(2) doesn&#8217;t change this behaviour.</li>
<li>MT(, threads=2) changes this behaviour</li>
</ul>
<pre> 3928 wdp       20   0 1574m 192m 6736 R  186  9.5   1:30.97 avs2yuv
 3929 wdp       20   0  105m  63m 1336 S    8  3.1   0:02.78 x264
</pre>
<p>The downside of this is, that MT() might be bad for quality, and it might not work for everything. However, let&#8217;s put this into real numbers now:</p>
<p><b>Intel(R) Core(TM)2 Duo CPU     T7500  @ 2.20GHz, 1001 frames, FFmpegSource2 + TNLMeans(), 2 threads</b></p>
<ul>
<li>with MT <b>encoded 1001 frames, 2.51 fps, 279.84 kb/s</b></li>
<li>without MT <b>encoded 1001 frames, 1.47 fps, 278.98 kb/s</b></li>
</ul>
<p><b>AMD Athlon(tm) II X4 645 Processor (3,1 GHz), 1001 frames, FFmpegSource2 + TNLMeans(), 4 threads</b></p>
<ul>
<li>with MT <b>encoded 1001 frames, 6.96 fps, 279.23 kb/s</b></li>
<li>without MT <b>encoded 1001 frames, 2.05 fps, 279.22 kb/s</b></li>
</ul>
<p><b>AMD Athlon(tm) II X4 630 Processor (2,8 GHz), 1001 frames, FFmpegSource2 + TNLMeans(), 4 threads</b></p>
<ul>
<li>with MT <b>encoded 1001 frames, 6.96 fps, 279.23 kb/s</b></li>
<li>without MT <b>encoded 1001 frames, 2.05 fps, 279.22 kb/s</b></li>
</ul>
<table cellspacing="3" cellpadding="5" border="0">
<tr>
<td style="font-weight: bold;">&nbsp;</td>
<td style="font-weight: bold;">Intel Dualcore 2,2 GHz<br />mobile cpu, 32bit system</td>
<td style="font-weight: bold;">Amd Quad Core 3,1 GHz<br />32 bit system</td>
<td style="font-weight: bold;">AMD Quadcore 2,8 GHz</td>
</tr>
<tr>
<td style="font-weight: bold;">without MT</td>
<td>1.47</td>
<td>2.05</td>
<td>&nbsp;</td>
</tr>
<tr>
<td style="font-weight: bold;">with MT</td>
<td>2.51</td>
<td>6.96</td>
<td>&nbsp;</td>
</tr>
<tr>
<td style="font-weight: bold;">speedup</td>
<td>170%<br />(ca 2 times)</td>
<td>339%<br />(ca 3 1/2 times)</td>
<td>&nbsp;</td>
</tr>
</table>
<p>I&#8217;d say that&#8217;s a good improvement and worth it.</p>
<h2>Networking Approach</h2>
<p>The networking approach has some flaws. For example: The Concept in Avisynth works like this: You&#8217;re filtering a video, you&#8217;re handing the clip to another box using TCPServer &#8211; After TCPServer you can&#8217;t do anything anymore (thus you can&#8217;t do TCPSource to get the clip back). This means, if you want to hand it back you have to run several avisynth instances, like this:</p>
<table cellspacing="3" cellpadding="5" border="0">
<tr>
<td>box1 instance 1</td>
<td>box2</td>
<td>box1 instance 2</td>
</tr>
<tr>
<td>Blur(1) TCPServer()</td>
<td>TCPSource(&#8220;box1 instance1&#8243;) nnedi3 TCPServer()</td>
<td>TCPSource(box2) Sharpen</td>
</tr>
</table>
<p>i.e.: box 1 instance 1 (10.0.0.1 port 7777) &raquo; box 2 (10.0.0.2) port 8888 &raquo; box 1 instance 2 (10.0.0.1 port 6666)</p>
<p>The next flaw is, this is still only linear processing, so it doesn&#8217;t matter how many boxes you add, if your boxes are equal in power a full encode will take just as much time as it would on one box, probably due to the networking a bit more. So this makes only sense, if you have expensive filters on a fast box and the rest on your slow box. However, we can try to work around that using Crop.</p>
<p><b>box1</b></p>
<pre>FFMpegSource2()
_do_some_fast_filtering_
TCPServer()</pre>
<p><b>box2</b></p>
<pre>TCPSource().Crop() # take the upper half of the frame
do some filtering
TCPServer()</pre>
<p><b>box3</b></p>
<pre>TCPSource().Crop() # take the bottom half of the frame
do some filtering
TCPServer()</pre>
<p><b>box1 instance2</b></p>
<pre>top = TCPSource(box2)
bottom = TCPSource(box3)
StackVertical(top, bottom)</pre>
<p>That&#8217;d be very basic threading. And it works fine. The problematic part is that some filters aren&#8217;t processing the edges &#8211; So you might have trouble at the edges where you cropped. Some Way to come around that, would be to crop 16px more and when setting it together, average those 16px or remove them completly.</p>
<h2>Alltogether</h2>
<p>Now you can use MT() also, of course if you hand your clip to another box. i.e.</p>
<pre>TCPSource()
MT("filter", threads=x)
TCPServer()</pre>
<p>But let&#8217;s see, what do i get when doing both?</p>
<h2>Conclusion</h2>
<p>Well well, i&#8217;m a bit disapointed, because the networking stuff is pretty complicated. Features i&#8217;m missing for example are giving filters from one box to another. i.e. some feature like:</p>
<p>TCPRun(&#8220;Filter1().Filter2().Filter3()&#8221;, &#8220;ip&#8221;, port, compression)</p>
<p>The way it&#8217;s currently done, i have to write scripts and place them onto the specific box. In Linux it&#8217;s even more complicated (no idea how the windows guys are doing that) i have to open the .avs in virtualdub in wine first, before i can connect to em using TCPSource. Thus the administrative part behind this magic is quite high.</p>
]]></content:encoded>
			<wfw:commentRss>http://jeanbruenn.info/2011/06/03/avisynth-networking-multicores-in-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Avisynth&#8217;s convolution stuff explained</title>
		<link>http://jeanbruenn.info/2011/03/13/avisynths-convolution-stuff-explained/</link>
		<comments>http://jeanbruenn.info/2011/03/13/avisynths-convolution-stuff-explained/#comments</comments>
		<pubDate>Sun, 13 Mar 2011 23:46:26 +0000</pubDate>
		<dc:creator>Jean</dc:creator>
				<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://jeanbruenn.info/new/?p=465</guid>
		<description><![CDATA[Since I&#8217;m working with avisynth I&#8217;ve always been impressed about people who came up with convolution stuff, many numbers and I had no idea what they mean. Reading the help pages on avisynth.org didn&#8217;t help &#8211; For all people who wanted to know how that works, here&#8217;s a little guide (thanks to Kuukunen for explaining) [...]]]></description>
			<content:encoded><![CDATA[<p>Since I&#8217;m working with avisynth I&#8217;ve always been impressed about people who came up with convolution stuff, many numbers and I had no idea what they mean. Reading the help pages on avisynth.org didn&#8217;t help &#8211; For all people who wanted to know how that works, here&#8217;s a little guide (thanks to Kuukunen for explaining)</p>
<p><span id="more-465"></span></p>
<p>Alright. First of all, some basics: GeneralConvolution takes an RGB Clip. RGB has 16 million colours (255 per channel, that means: 255 red, 255 green, 255 blue, and 255*255*255 = 16581375) &#8211; The Convolution thingy is processing each channel seperatly. You don&#8217;t even need to care.</p>
<p>Our first test movie is 1&#215;5 pixel in resolution (let&#8217;s assume 0 0 255 0 0 which&#8217;d mean, the first 2 px are black, then a white px then 2 black ones &#8211; so in simple, a black movie with a white dot in the middle)</p>
<p>Now we can decide between a 3&#215;3 and a 5&#215;5 matrix. For simplicity we take a 3&#215;1 matrix. A 3&#215;1 matrix would be 0 0 1, a 5&#215;1 matrix would be 0 0 0 0 1. So every value represents a pixel. Every pixel-value is done for every pixel in the movie. For the edges the outer px is mirrored. So you can look at it this way:</p>
<table>
<tr>
<td>Current pixel value</td>
<td>Pixels used by Matrix</td>
<td>Matrix</td>
<td>Matrix Calc</td>
<td>Matrix result</td>
</tr>
<tr>
<td>0</td>
<td>1px mirrored to left = 0 0 0</td>
<td>0 0 1</td>
<td>(0*0 + 0*0 + 0*1)</td>
<td>0</td>
</tr>
<tr>
<td>0</td>
<td>0 0 255</td>
<td>0 0 1</td>
<td>(0*0 + 0*0 + 255*1)</td>
<td>255</td>
</tr>
<tr>
<td>255</td>
<td>0 255 0</td>
<td>0 0 1</td>
<td>(0*0 + 0*255 + 1*0)</td>
<td>0</td>
</tr>
<tr>
<td>0</td>
<td>255 0 0</td>
<td>0 0 1</td>
<td>(255*0 + 0*0 + 0*1)</td>
<td>0</td>
</tr>
<tr>
<td>0</td>
<td>1px mirrored to right = 0 0 0</td>
<td>0 0 1</td>
<td>(0*0 + 0*0 + 0*1)</td>
<td>0</td>
</tr>
</table>
<p>As you can see the result of our matrix is, that it just shifted the white dot 1px to the left. So: 1 0 0 would shift the image to the right. In the matrix you can have any value, negative and positive. I guess mostly used are 0 -1 and some positive value. We&#8217;ll come later to -1. Anyway. You&#8217;ve just seen how shifting via convolution works &#8211; lemme show you how to blur. You can do a simple blur by just doing a matrix of 1 1 1. However at this matrix we have to talk about something else, called &#8220;divisor&#8221;. Basically all values in your matrix are sumed to make the divisor. So a matrix of 1 1 1 means a divisor of 3. A matrix of 2 4 2 would make a divisor of 8. A matrix of -1 2 -1 would mean a divisor of 0 (here the divisor&#8217;s auto detection fails). Let&#8217;s take a look at a table which shows what it does. Still using 0 0 255 0 0 (our white dot 5&#215;1 px video)</p>
<table>
<tr>
<td>Current pixel value</td>
<td>Pixels used by Matrix</td>
<td>Matrix</td>
<td>Matrix Calc</td>
<td>Matrix result</td>
</tr>
<tr>
<td>0</td>
<td>1px mirrored to left = 0 0 0</td>
<td>1 1 1 (div=3)</td>
<td>(0*1 + 0*1 + 0*1) / 3</td>
<td>0</td>
</tr>
<tr>
<td>0</td>
<td>0 0 255</td>
<td>1 1 1 (div=3)</td>
<td>(0*1 + 0*1 + 255*1) / 3</td>
<td>85</td>
</tr>
<tr>
<td>255</td>
<td>0 255 0</td>
<td>1 1 1 (div=3)</td>
<td>(0*1 + 255*1 + 0*1) / 3</td>
<td>85</td>
</tr>
<tr>
<td>0</td>
<td>255 0 0</td>
<td>1 1 1 (div=3)</td>
<td>(255*1 + 0*1 + 0*1)</td>
<td>85</td>
</tr>
<tr>
<td>0</td>
<td>1px mirrored to right = 0 0 0</td>
<td>1 1 1 (div=3)</td>
<td>(0*1 + 0*1 + 0*1) / 3</td>
<td>0</td>
</tr>
</table>
<p>So you can see that instead of 0 0 255 0 0 we now have: 0 85 85 85 0 that means the white dot px value was copied 1px to left and right and reduced (which we can refer to as blurred). Not that difficult, or? By the way, that should be Blur(1.58) (so blur, with it&#8217;s max value).</p>
<p>Now, let&#8217;s take a look at a more complicated example. We want to do &#8220;unsharping&#8221; this is possible with a convolution. In simple you&#8217;d do a matrix like: -1 4 -1. That&#8217;s basically unsharping. However, unsharping at a white dot doesn&#8217;t make much sense, so we&#8217;re going to use another &#8220;video&#8221;. This time: 9x1px resolution represented by 100 100 150 200 200 200 150 100 100. Let&#8217;s look at the following table:</p>
<table>
<tr>
<td>Current pixel value</td>
<td>Pixels used by Matrix</td>
<td>Matrix</td>
<td>Matrix Calc</td>
<td>Matrix result</td>
</tr>
<tr>
<td>100</td>
<td>1px mirrored to left = 100 100 100</td>
<td>-1 4 -1 (div=2)</td>
<td>((100*-1) + (100*4) + (100*-1)) / 2</td>
<td>100</td>
</tr>
<tr>
<td>100</td>
<td>100 100 150</td>
<td>-1 4 -1 (div=2)</td>
<td>((100*-1) + 100*4 + (150*-1)) / 2</td>
<td>75</td>
</tr>
<tr>
<td>150</td>
<td>100 150 100</td>
<td>-1 4 -1 (div=2)</td>
<td>((100*-1) + 150*4 + (200*-1)) / 2</td>
<td>150</td>
</tr>
<tr>
<td>200</td>
<td>150 200 200</td>
<td>-1 4 -1 (div=2)</td>
<td>((150*-1) + 200*4 + (200*-1)) / 2</td>
<td>225</td>
</tr>
<tr>
<td>200</td>
<td>200 200 200</td>
<td>-1 4 -1 (div=2)</td>
<td>((200*-1) + 200*4 + (200*-1)) / 2</td>
<td>200</td>
</tr>
<tr>
<td>200</td>
<td>200 200 150</td>
<td>-1 4 -1 (div=2)</td>
<td>((200*-1) + 200*4 + (150*-1)) / 2</td>
<td>225</td>
</tr>
<tr>
<td>150</td>
<td>200 150 100</td>
<td>-1 4 -1 (div=2)</td>
<td>((200*-1) + 150*4 + (100*-1)) / 2</td>
<td>150</td>
</tr>
<tr>
<td>100</td>
<td>150 100 100</td>
<td>-1 4 -1 (div=2)</td>
<td>((150*-1) + (100*4) + (100*-1)) / 2</td>
<td>75</td>
</tr>
<tr>
<td>100</td>
<td>1px mirrored to right = 100 100 100</td>
<td>-1 4 -1 (div=2)</td>
<td>((100*-1) + 100*4 + (100*-1)) / 2</td>
<td>100</td>
</tr>
</table>
<p>So, you can see that we get</p>
<p>100 75 150 225 200 225 150 75 100</p>
<p>from</p>
<p>100 100 150 200 200 200 150 100 100</p>
<p>which results in a sharpened image. The center is 200 (the value in the middle) around that it&#8217;s highering the brightness a bit (making it more white from 200 to 225) and before the 150 it&#8217;s lowering the brightness from 100 to 75, making it more black. What this does you can easily see in an image at wikipedia. Just take a look at:</p>
<p>http://en.wikipedia.org/wiki/File:Usm-unsharp-mask.png</p>
<p>You can see the black and the white, which looks like shadow in the bottom part of the picture? That&#8217;s exactly what we did here, and that&#8217;s exactly what unsharping is about. This &#8220;white&#8221; stuff is also called &#8220;halos&#8221; those nasty things everyone tries to remove.</p>
<p>However, we still didn&#8217;t finished understanding the matrices. What we did so far was: unsharping, shifting, bluring. Now i&#8217;ll give two examples for edge detection, and then we&#8217;ll have to talk about dimensions. </p>
<p>Video: 100 100 100 200 200 200 200 100 100 100<br />
Matrix: 0 -1 1<br />
Divisor: 1 (so.. none)<br />
Result: 0 0 100 0 0 0 -100 0 0 0</p>
<p>Values above 255 are clipped to 255.<br />
Values below 0 are clipped to 0. So -100 = 0</p>
<p>As you can see at the result, we&#8217;ve got a black image with just the edge selected. Though this is only detecting the left edges (the point is, it will cause edges in one direction to fall below 0). For both directions you have to use a 2dimensional matrix or mt_edge for example.</p>
<p>Now, let&#8217;s talk about dimensions. This is where it get&#8217;s difficult. With our 5&#215;1 videos we just faced 1 dimensional matrices. However, we want to do 2 dimensional matrices because our video is 2d. So let&#8217;s take a look at a 2d video with a white dot in the middle:</p>
<table>
<tr>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td>0</td>
<td>0</td>
<td>255</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
<td>0</td>
</tr>
</table>
<p>That&#8217;s a 5&#215;5 video. a 3&#215;3 matrix would look like this:</p>
<table>
<tr>
<td>1</td>
<td>1</td>
<td>1</td>
</tr>
<tr>
<td>1</td>
<td>1</td>
<td>1</td>
</tr>
<tr>
<td>1</td>
<td>1</td>
<td>1</td>
</tr>
</table>
<p>This would do the same, as our 1d blur. You could change the blurring (shape) to produce less strong blurrying, for example like this:</p>
<table>
<tr>
<td>0</td>
<td>1</td>
<td>0</td>
</tr>
<tr>
<td>1</td>
<td>1</td>
<td>1</td>
</tr>
<tr>
<td>0</td>
<td>1</td>
<td>0</td>
</tr>
</table>
<p>If you run this twice, the first one should look a bit blocky, the second will be as strong as the original blur but it will look a bit different. So.. You can really do a lot with this. However, you have to keep in mind, while at 1d the matrix was done to the left, current and right px, it&#8217;s different now. now it&#8217;s applied to the surrounding px. </p>
<p>For example:</p>
<table>
<tr>
<td>-1</td>
<td>-1</td>
<td>-1</td>
</tr>
<tr>
<td>-1</td>
<td>12</td>
<td>-1</td>
</tr>
<tr>
<td>-1</td>
<td>-1</td>
<td>-1</td>
</tr>
</table>
<p>That&#8217;d be our unsharp mask in 2d. The matrix is applied to ALL surrounding px. That means: not just to left and right, and not just to top and bottom and left and right &#8211; it&#8217;s also applied to the top left, top right, bottom left, bottom right.</p>
<p>Apart from 2d convolution there&#8217;s also 3d convolution (a filter made for that) this one is working temporal (using the previous frame) which &#8220;might&#8221; be useful in very slow motion to improve things, tho in high motion it will create ghosting and thus might not be very useful.</p>
<p>I hope this article helps other people to better understand about this.</p>
]]></content:encoded>
			<wfw:commentRss>http://jeanbruenn.info/2011/03/13/avisynths-convolution-stuff-explained/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Avisynth: Color Correction &amp; Improvement</title>
		<link>http://jeanbruenn.info/2010/12/29/avisynth-color-correction-improvement/</link>
		<comments>http://jeanbruenn.info/2010/12/29/avisynth-color-correction-improvement/#comments</comments>
		<pubDate>Wed, 29 Dec 2010 10:35:31 +0000</pubDate>
		<dc:creator>Jean</dc:creator>
				<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://jeanbruenn.info/new/?p=198</guid>
		<description><![CDATA[To get a bit more experience with avisynth I read a lot of articles and howtos. I think the most important thing when restoring (repairing, enhancing, whatever you like to call it) videos right after de-interlacing (if interlaced) is color correction. So let&#8217;s take a look at colors and avisynth. There are three things, which [...]]]></description>
			<content:encoded><![CDATA[<p>To get a bit more experience with avisynth I read a lot of articles and howtos. I think the most important thing when restoring (repairing, enhancing, whatever you like to call it) videos right after de-interlacing (if interlaced) is color correction. So let&#8217;s take a look at colors and avisynth.</p>
<p><span id="more-198"></span></p>
<p>There are three things, which can be tuned easily to provide better colors: Brightness, Contrast, Saturation. Going a bit deeper, you could also handle the color-channels independently, for example if you convert the clip to RGB you could higher the saturation for the red channel, for the green channel and/or for the blue channel (so if you think theres too much blue, you&#8217;d just limit blue a bit without touching red and green). Apart from that, there are some more techniques which might be useful. For example color-enhancement &#8211; Sometimes you got dark parts in a picture (nearly black) &#8211; Such parts contain some information, for example there might be a table but you won&#8217;t see it. If you higher gamma/brightness you&#8217;ll start to see it. So yes, it&#8217;s there, even if you don&#8217;t see it. You got two options: a) you&#8217;re increasing brightness/gamma just in that black part to see more of the frame or b) you&#8217;re making it even darker (more black) and blur it a bit (to remove such information which you won&#8217;t see anyway) to enhance compressibility. So, as you can see, there&#8217;s a lot you can do to colors in a video. And believe me, that&#8217;s not all.</p>
<p><strong>TV &#038; PC</strong></p>
<p>At a PC you got a range from 0 to 255 at the YUV signal. On a TV these are limited, at the luma component from 16 to 235 and for the chroma component 16 to 240.  I don&#8217;t think that this is still important today, however, just to make sure (Because they&#8217;re causing problems with some tv sets / and well it&#8217;s an legacy thing out of analogue times), we should limit this accordingly. However, let&#8217;s take a look at some example:</p>
<p><a rel="lightbox" href='http://jeanbruenn.info/wp-content/gallery/colorcorrection/histogram_1.png' title=''><img src='http://jeanbruenn.info/wp-content/gallery/colorcorrection/thumbs/thumbs_histogram_1.png' alt='histogram_1' class='ngg-singlepic ngg-none' /></a></p>
<p>You can see in the first histogram (the top thing) that there are brown borders on the left and on the right, these define the &#8220;invalid&#8221; parts. As you can also see on the left, there&#8217;s a bit in the invalid part (marked yellow), and also a bit on the right (not that easy to see).</p>
<pre>
ColorYUV(levels="PC->TV")
</pre>
<p><a rel="lightbox" href='http://jeanbruenn.info/wp-content/gallery/colorcorrection/histogram_2.png' title=''><img src='http://jeanbruenn.info/wp-content/gallery/colorcorrection/thumbs/thumbs_histogram_2.png' alt='histogram_2' class='ngg-singlepic ngg-none' /></a></p>
<p>or</p>
<pre>
Limiter(16, 235, 16, 240)
</pre>
<p><a rel="lightbox" href='http://jeanbruenn.info/wp-content/gallery/colorcorrection/histogram_3.png' title=''><img src='http://jeanbruenn.info/wp-content/gallery/colorcorrection/thumbs/thumbs_histogram_3.png' alt='histogram_3' class='ngg-singlepic ngg-none' /></a></p>
<p>The ColorYUV example leads to a more bright image / less saturation, we can correct this later. You can see that the histogram changed &#8220;noticable&#8221; with coloryuv &#8211; With Limiter the invalid ranges are just removed and nothing else changed. I&#8217;d prefer ColorYuv. However &#8211; Whatever you did, we got now good values for a TV (Always assumed, you want to be able to watch that video flawlessly on your TV)</p>
<p><strong>Brightness &#038; Contrast</strong></p>
<p>As you can see on the histogram above (the coloryuv one) the white doesn&#8217;t start at the left brown bar. We need to change that by tuning off_y of ColorYUV. In case you&#8217;re using this to manually tune the colors, you don&#8217;t need to do the conversation (pc->tv) above. So start by doing:</p>
<pre>ColorYuv(off_y=6, gain_y=0) </pre>
<p>and adjust off_y till there&#8217;s no yellow parts in the brown bar anymore. This should look like this:<br />
<a rel="lightbox" href='http://jeanbruenn.info/wp-content/gallery/colorcorrection/histogram_5.png' title=''><img src='http://jeanbruenn.info/wp-content/gallery/colorcorrection/thumbs/thumbs_histogram_5.png' alt='histogram_5' class='ngg-singlepic ngg-none' /></a><br />
Now you can see that a lot goes into the right brown bar, so we need to limit it there, too, you can do that by tuning gain_y, for example (the white stuff should always be between the brown bars):</p>
<pre>ColorYuv(off_y=6, gain_y=-12)</pre>
<p>This looks in my source like this:</p>
<p><a rel="lightbox" href='http://jeanbruenn.info/wp-content/gallery/colorcorrection/histogram_6.png' title=''><img src='http://jeanbruenn.info/wp-content/gallery/colorcorrection/thumbs/thumbs_histogram_6.png' alt='histogram_6' class='ngg-singlepic ngg-none' /></a></p>
<p><strong>Saturation / Hue</strong></p>
<p>Changing the Saturation and Hue is way easier, though i&#8217;d recommend to not deal with it, except you got a very bad source. Because let&#8217;s imagine you&#8217;re noticing that some picture is way too red. You could now limit the red color a bit, by doing so &#8220;every&#8221; red would be limited in your movie, so some parts might look worse than before. Also highering red &#8211; Faces might look weird. So this is something you should try to avoid in my humble opinion. However:</p>
<p>You could use TweakColor to work on the colors. For example:</p>
<pre>
# just a wrapper around TweakColor not useful at all
function pseudoColors(clip input)
{
    # magenta: 20 - 80 (center: 50) - higher saturation of magenta with 1.2
    TweakColor(input, startHue=20, endHue=80, sat=1.2)
    # red: 80 - 140 (center: 110) - lower saturation of red with 0.5
    TweakColor(startHue=80, endHue=140, sat=0.5)
    # yellow: 140 - 200 (center: 170) - don't do anything
    TweakColor(startHue=140, endHue=200, sat=1.0)
    # green: 200 - 260 (center: 230) - higher green by 2.0
    TweakColor(startHue=200, endHue=260, sat=2)
    # cyan: 260 - 320 (center: 290) - make cyan greyscale/filter it out
    TweakColor(startHue=260, endHue=290, sat=0)
    # blue: 320 - 20 (center: 350) - do nothing
    TweakColor(startHue=320, endHue=20, sat=1)

    return last
}
</pre>
<p>Instead of &#8220;sat&#8221; you might also use bright cont and hue. For example: There&#8217;s something yellow in your video, which should be green. So you want to shift the hue of &#8220;yellow&#8221; to &#8220;green&#8221;. Negative values in &#8220;hue&#8221; will do that. For example (not tested):</p>
<pre>
# selected yellow with start and endhue, and shifting hue to -50, negative values -> green, positive values -> red
TweakColor(input, startHue=140, endHue=200, hue=-50)
</pre>
<p>You see, there&#8217;s much you can do, you could even just remove some annoying colors. The usual way of doing such tuning is watching the video and looking for parts which seems to have wrong colors. Tuning them, and making sure it doesn&#8217;t make any other frame worse.</p>
<p><strong>Automatism</strong></p>
<p>However, the above stuff needs to be applied to every frame; you need to find out the brightest and the darkest frame in the whole movie, and tune the settings accordingly. so with these settings you can make some frames too bright and some not bright enough; something which does this automatically would be cool, hm? Well, i&#8217;m using &#8220;autolevels&#8221; for that, which does a quite good job if you feed it with many frames. It&#8217;s default value (5) isn&#8217;t very useful in the source i&#8217;m using here, while a value of 50 gives very good results. Take a look at the histogram:</p>
<p><a rel="lightbox" href='http://jeanbruenn.info/wp-content/gallery/colorcorrection/histogram_4.png' title=''><img src='http://jeanbruenn.info/wp-content/gallery/colorcorrection/thumbs/thumbs_histogram_4.png' alt='histogram_4' class='ngg-singlepic ngg-none' /></a></p>
<p>Autolevels got a few problems though; due to the automatism weird light(ning) effects occur sometimes and on real dark frames like a star-field it makes the whole black into grey &#8211; So while it might be good for some sources, for most of the sience-fiction movies you probably have, you should look at it skeptical <img src='http://jeanbruenn.info/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><strong>Enhancing</strong></p>
<p>there are three other plugins, which might be useful to you, when dealing with colors:</p>
<ol>
<li><img src="http://www.jeanbruenn.info/images/lang/lang_en.png" /> <a href="http://strony.aster.pl/paviko/hdragc.htm">HDRAGC</a> &#8211; Enhances Shadows (I never got good settings with it for my sources)</li>
<li><img src="http://www.jeanbruenn.info/images/lang/lang_en.png" /> <a href="http://expsat.sourceforge.net/">ExpLabo</a> &#8211; Can be used for Color Correction (haven&#8217;t tried it yet)</li>
<li><img src="http://www.jeanbruenn.info/images/lang/lang_en.png" /> <a href="http://avisynth.org/mediawiki/FlimsYlevels">FilmYlevels</a> &#8211; Gives a filmish look (haven&#8217;t tried it yet)</li>
</ol>
<p>Haven&#8217;t tried it yet means, the screenshots looked promising, but well as you might (or should) know, screenshots are.. hehe. Usually optimized for a specific source; it&#8217;s simply not a good way to say something&#8217;s good or bad just because of a awesome good screenshot.</p>
<p>Update: I tried ylevels and flimylevels today, it seems those things are most useful on anime and not really useful on &#8220;normal&#8221; video, because of the light-changes. If you use one of those (also hdragc, even if its lower there) it might well be that you notice a fading light from frame to frame (which looks bad) with autolevels the frames get a bit over-saturated, too &#8211; So finding good values is not that easy. autolevels has the advantage of using many frames, thus you can reduce the noticeable lighting. So.. Well, you have to check yourself. For very bad old sources this might be good, for anime this might be good also, for everything else.. Be skeptical and use your eyes.</p>
<p><strong>Making White really White</strong></p>
<p>At one old movie i noticed that they used a white paper to simulate &#8220;lightning&#8221; the thing which occurs at a thunder. So they hold a white paper in front of the camera for one or two frames &#8211; At the bottom right edge this was noticable because there&#8217;s a curve. Here&#8217;s a screenshot:</p>
<p><a rel="lightbox" href='http://jeanbruenn.info/wp-content/gallery/colorcorrection/lightning.png' title=''><img src='http://jeanbruenn.info/wp-content/gallery/colorcorrection/thumbs/thumbs_lightning.png' alt='lightning' class='ngg-singlepic ngg-none' /></a></p>
<p>So instead of using that it might be useful to turn such a frame into real white. Like saying: If 95% of the Screen is white, make it real white or something like that. Kuukuunen (thanks once again!) helped me a bit to get something which is doing that. There&#8217;s also a Thread which he wrote regarding &#8220;Understanding YUV, Luma, Luminance&#8221; because there are some problems with greyscale -> i linked his thread at the bottom. Here&#8217;s by the way the function which would do the above:</p>
<pre>
function turnWhite(clip v, int "threshold")
{
    threshold = default(threshold, 235)
    v.converttorgb()
    grayscale()
    converttoyv12()
    conditionalfilter(last, blankclip( v, pixel_type="YV12", color_yuv=$FF8080 ), v, "averageluma()", ">", string(threshold))
}
</pre>
<p>play around with threshold and test for yourself. A value of 200 did what i wanted at the frame, i guess highering this would be possible, haven&#8217;t tried yet. Try to make the threshold as high as possible to not cause any false-positives. Whether thats useful or not you have to decide yourself; in fact as those are only 1-2 frames, you wouldn&#8217;t notice in normal motion. You should only notice this in slowmotion (like playing it with mplayer and using the dot to look at it frame by frame) however, it MIGHT enhance compressibility.</p>
<p><strong>Other useful information</strong></p>
<ul>
<li><img src="http://www.jeanbruenn.info/images/lang/lang_en.png" /> <a href="http://neuron2.net/LVG/videotuning.html">Videotuning</a></li>
<li><img src="http://www.jeanbruenn.info/images/lang/lang_en.png" /> <a href="http://www.doom9.org/index.html?/capture/postprocessing_avisynth.html">Postprocessing Avisynth.html</a> (scroll down to: 7.2.9 Color adjustment)</li>
<li><img src="http://www.jeanbruenn.info/images/lang/lang_en.png" /> <a href="http://forum.doom9.org/showthread.php?p=1467877">Understanding YUV, Luma, Luminance</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://jeanbruenn.info/2010/12/29/avisynth-color-correction-improvement/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Avisynth using wine in Linux</title>
		<link>http://jeanbruenn.info/2010/12/24/avisynth-and-linux/</link>
		<comments>http://jeanbruenn.info/2010/12/24/avisynth-and-linux/#comments</comments>
		<pubDate>Fri, 24 Dec 2010 21:32:41 +0000</pubDate>
		<dc:creator>Jean</dc:creator>
				<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://jeanbruenn.info/new/?p=193</guid>
		<description><![CDATA[Just some little guide how to get avisynth working in linux using wine. If you run Lunar Linux like I do, you want to update first, followed by installing wine, if not already done. In Debian you&#8217;d do something like &#8220;apt-get update&#8221; .. &#8220;apt-get dist-upgrade&#8221; .. &#8220;apt-get install wine&#8221;. # retrive updates/new versions lin moonbase; [...]]]></description>
			<content:encoded><![CDATA[<p>Just some little guide how to get avisynth working in linux using wine.</p>
<p><span id="more-193"></span></p>
<p>If you run Lunar Linux like I do, you want to update first, followed by installing wine, if not already done. In Debian you&#8217;d do something like &#8220;apt-get update&#8221; .. &#8220;apt-get dist-upgrade&#8221; .. &#8220;apt-get install wine&#8221;. </p>
<pre>
# retrive updates/new versions
lin moonbase; lin theedge

# install wine
lin -cr wine
</pre>
<p>When I initially wrote this article, I was using wine 1.2.2. Currently I&#8217;m using version 1.2.3. Right after installing wine, download required files:</p>
<p><b>Requirenments</b></p>
<ul>
<li><a href="http://sourceforge.net/projects/avisynth2/files/AviSynth%202.5/AviSynth%202.5.8/DirectShowSource_2588.zip">DirectShowSource_2588.zip</a></li>
<li><a href="http://sourceforge.net/projects/avisynth2/files/AviSynth%202.5/AviSynth%202.5.8/Avisynth_258.exe">Avisynth_258.exe</a></li>
<li><a href="https://sourceforge.net/projects/openil/files/DevIL%20Win32/1.7.8/DevIL-EndUser-x86-1.7.8.zip">DevIL-EndUser-x86-1.7.8.zip</a></li>
<li><a href="ftp://ftp.fftw.org/pub/fftw/fftw3win32mingw.zip">fftw3win32mingw.zip</a></li>
<li><a href="ftp://ftp.fftw.org/pub/fftw/fftw-3.3-dll32.zip">fftw-3.3-dll32.zip</a></li>
<li><a href="http://akuvian.org/src/avisynth/avs2yuv/avs2yuv.exe">avs2yuv.exe</a></li>
</ul>
<pre>cp DirectShowSource.dll .wine/drive_c/Program\ Files/AviSynth\ 2.5/plugins/DirectShowSource.dll
cp DevIL.dll .wine/drive_c/windows/system32/devil.dll
cp ILU.dll ILUT.dll .wine/drive_c/windows/system32/
cp fftw3win32mingw/fftw3.dll .wine/drive_c/windows/system32/
cp libfftw3-3.dll libfftw3f-3.dll libfftw3l-3.dll .wine/drive_c/windows/system32/
cp avs2yuv.exe .wine/drive_c/windows/system32/</pre>
<p>You should have all basic things which might be needed now. I&#8217;d suggest you to step through the import-filters on avisynth&#8217;s external-plugins page and install those, you might need. If such a tool comes with .exe files (like ffmpegsource&#8217; ffindex.exe) I&#8217;d suggest you to place them into .wine/drive_c/windows/system32 because then they&#8217;ll be in wine&#8217;s PATH and issuing &#8220;wine ffindex.exe&#8221; will just work without the hassle to write down the whole path all the time.</p>
<p>Now you&#8217;re able to encode videos with avisynth. Here&#8217;s an example:</p>
<pre>wine avs2yuv test.avs - | x264 --stdin y4m --crf 0 --fps 25 --output output.264 -</pre>
<p><strong>Troubleshooting</strong><br />
You might get one or some of the following errors:</p>
<pre>Avisynth error: AVISource: couldn't locate a decompressor for fourcc xvid</pre>
<p>Time to <a href="http://winezeug.googlecode.com/svn/trunk/winetricks">get winetricks from here</a>. </p>
<pre># Now make it executable using:
chmod a+x winetricks

# and install some codecs:
./winetricks allcodecs</pre>
<p>Another error:</p>
<pre>Avisynth error: No compatible ACM codec to decode 0x2000 audio stream to PCM.</pre>
<p>If you get that error, just use another Source filter, for example DirectShowSource() instead of AviSource(). Or you might use FFmpegSource.</p>
<pre>fixme:actctx:parse_depend_manifests Could not find dependent assembly L"Microsoft.VC80.CRT" (8.0.50727.762)
err:module:import_dll Library MSVCP80.dll (which is needed by L"C:\\windows\\system32\\DevIL.dll") not found
err:module:import_dll Library DevIL.dll (which is needed by L"C:\\windows\\system32\\avisynth.dll") not found
failed to load avisynth.dll</pre>
<p>Some plugins and above dll&#8217;s need a few things which you might obtain by winetricks. For example:<br />
winetricks -> select the default wineprefix (whatever they mean by that) -> install a windows dll or component -> tick vcrun2003, vcrun2005 and vcrun2008</p>
<p> Another hint: use WINEDEBUG=&#8221;-all&#8221; in front of wine or create a bash script for that. It will remove wine&#8217;s debug output, a nice bash script could be this one:</p>
<p><strong>avisynth.sh</strong></p>
<pre>#!/bin/bash
#
#  avisynth/avs2yuv/wine wrapper
#
#  Syntax:
#    avisynth mode script.avs [output.264] [parameters]
#  Modes:
#    lossless (pipe to x264)
#      --crf 0
#    normal (pipe to x264)
#      --preset slower --tune film --ref 6 --bframes 5
#      --b-adapt 2 --direct auto --crf 18 --me umh
#      --subme 8 --trellis 2 --weightp 0
#    user (pipe to x264)
#    display (output using mplayer (realtime playback)
#    picture (output to /dev/null)
#  Explaination:
#    lossless and normal should be obvious, normal uses
#    the settings I'm usually using, you might want to
#    change them below. picture is a special case: sometimes
#    I'm using ImageWriter and thus I don't need x264 or
#    a pipe. You can use "user" to set your own settings.
#    display will just let mplayer
#    display the movie - useful for realtime playback.
#  Examples:
#    avisynth display test.avs
#    avisynth lossless test.avs myfile.264 "--fps 50"
#    avisynth picture test.avs
#    avisynth user test.avs output.264 "--preset placebo --fps 25"
#

# general x264 parameters
genparm="--stdin y4m --thread-input"
# parameters for the normal/my usual x264 encode
normparm="--preset slower --tune film --ref 6 --bframes 5 --b-adapt 2 --direct auto --crf 18 --me umh --subme 8 --trellis 2 --weightp 0"

mode="$1"
avsf="$2"
outf="$3"
parm="$4"

if [ -z "$mode" ]; then
  echo " + Error: Mode needs to be given (display, lossless, normal, none, picture)";
  exit 1;
fi

if [ -z "$avsf" ]; then
  echo " + Error: AVS needs to be given (path to your .avs file)";
  exit 1;
fi

#
# x264 encoding
#
if [ "$mode" == "lossless" ] || [ "$mode" == "normal" ] || [ "$mode" == "user" ]; then
  if [ -z "$outf" ]; then
    echo " + Error: Given mode requires an output filename";
    exit 1;
  fi
  if [ "$mode" == "user" ]; then
    if [ -z "$parm" ]; then
      echo " + Error: Given mode requires additional parameters";
      exit 1;
    else
      x264="$genparm $parm"
    fi
  elif [ "$mode" == "normal" ]; then
    x264="$genparm $normparm $parm"
  else
    x264="$genparm --crf 0"
  fi
  WINEDEBUG="-all" wine avs2yuv $avsf - | x264 $x264 --output $outf -
else
  #
  # mplayer display
  #
  if [[ "$mode" == "display" ]]; then
    WINEDEBUG="-all" wine avs2yuv "$avsf" - | mplayer -cache 2048 -noidx -
  #
  # picture part
  #
  elif [[ "$mode" == "picture" ]]; then
    WINEDEBUG="-all" wine avs2yuv "$avsf" -frames 1 /dev/null
  else
    echo " + Error: mode not implemented (yet?)";
    exit 1;
  fi
fi
</pre>
<p>That&#8217;s all about it <img src='http://jeanbruenn.info/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://jeanbruenn.info/2010/12/24/avisynth-and-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

