<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.videolan.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Technologicat</id>
	<title>VideoLAN Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.videolan.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Technologicat"/>
	<link rel="alternate" type="text/html" href="https://wiki.videolan.org/Special:Contributions/Technologicat/"/>
	<updated>2026-11-04T19:55:46Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.11</generator>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=UnixCompile&amp;diff=22034</id>
		<title>UnixCompile</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=UnixCompile&amp;diff=22034"/>
		<updated>2012-02-17T13:17:38Z</updated>

		<summary type="html">&lt;p&gt;Technologicat: /* Prepare your environment */ Added Debian/Ubuntu example to go with Fedora example&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Prepare your environment  ==&lt;br /&gt;
&lt;br /&gt;
VLC requires a C compiler, development headers and a toolchain. gcc will do but you could also use LLVM or proprietary C99/C++ compilers such as Intel&#039;s.&lt;br /&gt;
&lt;br /&gt;
If you build from the [[Git]] repositories, you will also need the GNU build system, a.k.a. the &amp;quot;autotools&amp;quot; (autoconf, automake, libtool and gettext) to setup the Makefiles. Make sure they are up-to-date and usable for your system.&lt;br /&gt;
&lt;br /&gt;
On Fedora:&lt;br /&gt;
&lt;br /&gt;
 % sudo yum install git libtool&lt;br /&gt;
&lt;br /&gt;
On Debian or Ubuntu:&lt;br /&gt;
&lt;br /&gt;
 % sudo apt-get install git libtool&lt;br /&gt;
&lt;br /&gt;
== Get the source  ==&lt;br /&gt;
Start by [[GetTheSource|getting the source]], using FTP for official releases, or using [[Git]] to track VLC development. &lt;br /&gt;
&lt;br /&gt;
If your are using an official release, download source code, extract the archive and go into the resulting VLC directory, e.g.:&lt;br /&gt;
 % wget ftp://ftp.videolan.org/pub/videolan/vlc/1.1.11/vlc-1.1.11.tar.bz2&lt;br /&gt;
 % tar xvjf vlc-1.1.11.tar.bz2&lt;br /&gt;
 % cd vlc-1.1.11&lt;br /&gt;
&lt;br /&gt;
If you are using the [[Git]] development version, start by bootstrapping the source tree:&lt;br /&gt;
 % cd vlc&lt;br /&gt;
 % ./bootstrap&lt;br /&gt;
Bootstrapping will fail if the autotools are missing or out-of-date.&lt;br /&gt;
&lt;br /&gt;
== Get the third-party libraries  ==&lt;br /&gt;
Now you could configure the VLC build. But first, you need to make sure that all the required dependencies are in place. Take a look at &amp;lt;tt&amp;gt;./configure --help&amp;lt;/tt&amp;gt;. Take a good look at that enormous list of options.&lt;br /&gt;
&lt;br /&gt;
It is very important that you do install and enable all the 3rd party libraries that you need. Yes, there is going to be a lot of them if you want a complete or even mostly functional VLC build. If you fail to install a required library, you will end up with a VLC application that well..... essentially does not do anything useful. See [[Contrib Status|here]] for a complete list.&lt;br /&gt;
 &lt;br /&gt;
There are some very important dependencies: gettext (NLS) for international support (required), libdvbpsi for MPEG-TS files and streams support, libmad for MP3 audio decoding, libmpeg2 for MPEG1 and MPEG2 video support, FFmpeg or libav (libavcodec, libavformat, libpostproc, libswscale and optionally libavio) for MPEG4 and most other audio and video codecs, and many file formats, liba52 for Dolby (AC3) sound, dvdread and dvdnav for DVD playback, live555 for RTSP stream playback, etc.&lt;br /&gt;
&lt;br /&gt;
For audio output, you will need probably alsa-lib (on [[Linux]]) and/or libpulse (for [[PulseAudio]]).&lt;br /&gt;
For video output, you will normally need XCB/XVideo and/or OpenGL/GLX.&lt;br /&gt;
And Qt4 is required to get the GUI support.&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039; that you need to install the development packages (development header files and import libraries) to compile VLC, not just the run-time. On Debian/Ubuntu, the correct package names end with -dev. On RPM distributions, they usually end in -devel.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Be careful!&#039;&#039;&#039; If the libraries are not provided by your distribution, you may be better off linking VLC with them statically. Otherwise, you may encounter version problems if another multimedia application updates the libraries later. This is especially true of FFmpeg or libav, and live555.&lt;br /&gt;
&lt;br /&gt;
There are a several ways to get those libraries. You should use only one method at a time: &lt;br /&gt;
 &lt;br /&gt;
=== The preferred method ===&lt;br /&gt;
Use your distribution packaging or portage system, in order to get all the needed libs.&lt;br /&gt;
For example on Debian or Ubuntu: &lt;br /&gt;
 # apt-get build-dep vlc&lt;br /&gt;
&lt;br /&gt;
openSUSE users might have a look at the source-install (si) command in the zypper manpage:&lt;br /&gt;
 # zypper si -d vlc&lt;br /&gt;
&lt;br /&gt;
=== The method for badly-behaved distributions ===&lt;br /&gt;
If your distribution does not provide the needed libraries,&lt;br /&gt;
or you really want to link VLC statically, use the VLC contribs system. It is included in the VLC source.&lt;br /&gt;
&lt;br /&gt;
First, you need to install the GNU autotools (if you have not already done so), CMake, subversion, Git and a recent GNU/tar utility or equivalent. Then you can run:&lt;br /&gt;
 % cd contrib&lt;br /&gt;
 % mkdir native&lt;br /&gt;
 % cd native&lt;br /&gt;
 % ../bootstrap&lt;br /&gt;
 % make&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039; the commands above are for VLC 1.2 or later. Details differ slightly for older versions:&lt;br /&gt;
 % cd extras/contrib&lt;br /&gt;
 % ./bootstrap&lt;br /&gt;
 % make&lt;br /&gt;
&lt;br /&gt;
That should download and build a lot of those libraries for you.  Unfortunately, given the large number of libraries and the variety of the platforms people build VLC for, it is not unlikely that you will hit an error while contribs are compiling. Thus, this approach is only recommended for experienced Unix compilers.&lt;br /&gt;
&lt;br /&gt;
=== The method for people with too much time to waste ===&lt;br /&gt;
Read the [[Contrib Status|list]], download them and build them by hand.&lt;br /&gt;
&lt;br /&gt;
=== Regardless of the method ===&lt;br /&gt;
In any case, some basic OS support libraries are not included and must really be installed through the packaging system in any case, notably [[ALSA]], [[PulseAudio]] and [[OpenGL]].&lt;br /&gt;
&lt;br /&gt;
== Configuration  ==&lt;br /&gt;
&amp;lt;tt&amp;gt;./configure&amp;lt;/tt&amp;gt; is used to check whether your system is able to compile VLC. Also you can choose the features in your build. As a reminder, this command will show the various options:&lt;br /&gt;
 % ./configure --help&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;VLC 2.0 and later&#039;&#039;&#039;: For most users, &amp;lt;tt&amp;gt;./configure&amp;lt;/tt&amp;gt; does not require any command-line options.&lt;br /&gt;
&lt;br /&gt;
By default, features to be compiled are chosen automatically depending on what libraries are detected as available. If the contribs have been compiled first, the resulting VLC will be reasonably functional.&lt;br /&gt;
&lt;br /&gt;
Note that libraries that are not in the default prefix, and not in vlc contribs, must be known to pkg-config in order for &amp;lt;tt&amp;gt;./configure&amp;lt;/tt&amp;gt; to find them.&lt;br /&gt;
&lt;br /&gt;
There are some features that are disabled (not compiled) by default. If you want them, they must be forced on by using configure flags. You can find a list of these features by searching for &amp;quot;disabled&amp;quot; in &amp;lt;tt&amp;gt;./configure --help&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
(&#039;&#039;Beginner&#039;s guide&#039;&#039;: enter the command&lt;br /&gt;
 % ./configure --help | less&lt;br /&gt;
and hit enter. Type a slash &#039;/&#039;, type &amp;quot;disabled&amp;quot; (without quotes), hit enter. Pressing &#039;&#039;&#039;n&#039;&#039;&#039; goes to the next match, &#039;&#039;&#039;N&#039;&#039;&#039; goes to previous match, &#039;&#039;&#039;q&#039;&#039;&#039; returns to the command line. Use the up/down arrow keys to scroll. All matches except the &#039;&#039;--cache-file&#039;&#039; option (which belongs to &amp;lt;tt&amp;gt;configure&amp;lt;/tt&amp;gt; itself) are VLC features that must be forced on if desired.)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;VLC 1.1 and earlier&#039;&#039;&#039;: You probably need to tweak the &amp;quot;configure&amp;quot; line. &lt;br /&gt;
 &lt;br /&gt;
=== Special libs  ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;VLC 2.0 and later&#039;&#039;&#039;: there are no special libraries. If live555 exists in the &amp;lt;tt&amp;gt;contrib/&amp;lt;/tt&amp;gt; subdirectory, it is detected automatically. &#039;&#039;Any&#039;&#039; libraries that are not in the default prefix, and not in vlc contribs, must be known to pkg-config in order for &amp;lt;tt&amp;gt;./configure&amp;lt;/tt&amp;gt; to find them.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;VLC 1.1 and earlier&#039;&#039;&#039;: Use &amp;lt;tt&amp;gt;--with-live555-path=path/to/livemedia/source/tree&amp;lt;/tt&amp;gt; in connection with &amp;lt;tt&amp;gt;--enable-live555&amp;lt;/tt&amp;gt;. For FFmpeg or libav, pkg-config is the only reliable way for VLC&#039;s configure to find the libraries. So you need to set PKG_CONFIG_PATH correctly if your FFmpeg/libav libraries are not installed at the default prefix (meaning /usr) or you want to use static linking.&lt;br /&gt;
&lt;br /&gt;
=== Final configuration  ===&lt;br /&gt;
If you want to install VLC into another directory, run &lt;br /&gt;
 &lt;br /&gt;
 % ./configure --prefix=/path/to/install/folder/&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;VLC 1.1 and earlier&#039;&#039;&#039;: This is an example of a typical VLC configure line: &lt;br /&gt;
 &lt;br /&gt;
 % ./configure --enable-x11 --enable-xvideo --enable-sdl --enable-avcodec --enable-avformat \&lt;br /&gt;
  --enable-swscale --enable-mad --enable-libdvbpsi --enable-a52 --enable-libmpeg2 --enable-dvdnav \&lt;br /&gt;
  --enable-faad --enable-vorbis --enable-ogg --enable-theora --enable-faac --enable-mkv --enable-freetype \&lt;br /&gt;
  --enable-fribidi --enable-speex --enable-flac --enable-live555 --with-live555-tree=/usr/lib/live \&lt;br /&gt;
  --enable-caca --enable-skins --enable-skins2 --enable-alsa --enable-qt4 --enable-ncurses&lt;br /&gt;
 &lt;br /&gt;
[[User:J-b#VLC_configure_line|Here]] is another. &lt;br /&gt;
&lt;br /&gt;
=== Ubuntu ===&lt;br /&gt;
&lt;br /&gt;
If you get continuous errors while ./configure then consider reinstalling the corresponding libraries. This will set the paths and other information correctly. Check the $PKG_CONFIG_PATH(environment variable) whether it is set to a path where the libraries like libavcodec.pc are available. Otherwise create the environment variable, export it and then update the ldconfig.&lt;br /&gt;
&lt;br /&gt;
== Compilation ==&lt;br /&gt;
Compile VLC: &lt;br /&gt;
 % make&lt;br /&gt;
&lt;br /&gt;
You do not need to install VLC to use it. You can also simply run it from the build directory:&lt;br /&gt;
 # ./vlc&lt;br /&gt;
&lt;br /&gt;
If you really want to install VLC to the system, run this as root:&lt;br /&gt;
 # make install&lt;br /&gt;
&lt;br /&gt;
You can uninstall later with this, but you need to keep the build tree untouched until then:&lt;br /&gt;
 # make uninstall&lt;br /&gt;
&lt;br /&gt;
To remove files created during the compile (optional) type:&lt;br /&gt;
 % make clean&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
&lt;br /&gt;
=== Cygwin ===&lt;br /&gt;
&lt;br /&gt;
Compiling on [[Win32CompileCygwin|Cygwin]] may be broken from time to time as Cygwin packages change.&lt;br /&gt;
We recommend [[Win32Compile|cross-compiling from Linux to Windows]] instead. &#039;&#039;&#039;Consider yourself warned.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Debian/Ubuntu ===&lt;br /&gt;
Debian users who want to compile VLC should install the packages below:&lt;br /&gt;
*[http://packages.debian.org/unstable/libdevel/libavcodec-dev libavcodec-dev] &lt;br /&gt;
*[http://packages.debian.org/unstable/libdevel/libpostproc-dev libpostproc-dev] &lt;br /&gt;
*[http://packages.debian.org/unstable/libdevel/libmpeg2-4-dev libmpeg2-4-dev]&lt;br /&gt;
&lt;br /&gt;
If you just want to &#039;&#039;use&#039;&#039; VLC media player then simply install the package vlc (&amp;lt;tt&amp;gt;sudo apt-get install vlc&amp;lt;/tt&amp;gt;) - the unstable version is fairly up-to-date most of the time, while the stable is, err, stable and very old&amp;amp;nbsp;;-)&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting / common problems ==&lt;br /&gt;
&lt;br /&gt;
=== Lua ===&lt;br /&gt;
You may need to install Lua if you get &amp;quot;LUA byte compiler missing.&amp;quot; message. You namely need to install &amp;quot;luac&amp;quot;, the Lua byte compiler.&lt;br /&gt;
&lt;br /&gt;
On Debian/Ubuntu:&lt;br /&gt;
 % sudo apt-get install lua5.1&lt;br /&gt;
&lt;br /&gt;
On Fedora:&lt;br /&gt;
 % sudo yum install lua&lt;br /&gt;
&lt;br /&gt;
=== XCB ===&lt;br /&gt;
&lt;br /&gt;
VLC 1.1 and later requires XCB libraries to deal with X11 displays. Do not disable XCB or you will not get any video support!&lt;br /&gt;
&lt;br /&gt;
To install these libraries run the following commands (Debian/Ubuntu):&lt;br /&gt;
 % sudo apt-get install libxcb-shm0-dev libxcb-xv0-dev libxcb-keysyms1-dev libxcb-randr0-dev libxcb-composite0-dev&lt;br /&gt;
&lt;br /&gt;
Under Fedora:&lt;br /&gt;
 % sudo yum install libxcb-devel xcb-util-devel&lt;br /&gt;
&lt;br /&gt;
For OpenGL (Debian/Ubuntu only), you will additionally need XLib with XCB:&lt;br /&gt;
 % sudo apt-get install libx11-xcb-dev&lt;br /&gt;
&lt;br /&gt;
If your distribution provides a version of XLib without XCB, then this later package will not be available. So you will not be able to use OpenGL. Use XVideo instead.&lt;br /&gt;
&lt;br /&gt;
=== Compile fails after git pull ===&lt;br /&gt;
&lt;br /&gt;
It is likely that the sources in the repository have changed significantly since they were last pulled, and a build system cache has gone out of date. Try the troubleshooting methods described in the [[Hacker_Guide/How_To_Write_a_Module#Module_load_troubleshooting|hacker guide for modules]].&lt;br /&gt;
&lt;br /&gt;
[[Category:Building]]&lt;/div&gt;</summary>
		<author><name>Technologicat</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=UnixCompile&amp;diff=22033</id>
		<title>UnixCompile</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=UnixCompile&amp;diff=22033"/>
		<updated>2012-02-17T13:16:04Z</updated>

		<summary type="html">&lt;p&gt;Technologicat: /* Troubleshooting / common problems */ What to do if compile fails after git pull&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Prepare your environment  ==&lt;br /&gt;
&lt;br /&gt;
VLC requires a C compiler, development headers and a toolchain. gcc will do but you could also use LLVM or proprietary C99/C++ compilers such as Intel&#039;s.&lt;br /&gt;
&lt;br /&gt;
If you build from the [[Git]] repositories, you will also need the GNU build system, a.k.a. the &amp;quot;autotools&amp;quot; (autoconf, automake, libtool and gettext) to setup the Makefiles. Make sure they are up-to-date and usable for your system.&lt;br /&gt;
&lt;br /&gt;
On Fedora:&lt;br /&gt;
&lt;br /&gt;
 % sudo yum install git libtool&lt;br /&gt;
&lt;br /&gt;
== Get the source  ==&lt;br /&gt;
Start by [[GetTheSource|getting the source]], using FTP for official releases, or using [[Git]] to track VLC development. &lt;br /&gt;
&lt;br /&gt;
If your are using an official release, download source code, extract the archive and go into the resulting VLC directory, e.g.:&lt;br /&gt;
 % wget ftp://ftp.videolan.org/pub/videolan/vlc/1.1.11/vlc-1.1.11.tar.bz2&lt;br /&gt;
 % tar xvjf vlc-1.1.11.tar.bz2&lt;br /&gt;
 % cd vlc-1.1.11&lt;br /&gt;
&lt;br /&gt;
If you are using the [[Git]] development version, start by bootstrapping the source tree:&lt;br /&gt;
 % cd vlc&lt;br /&gt;
 % ./bootstrap&lt;br /&gt;
Bootstrapping will fail if the autotools are missing or out-of-date.&lt;br /&gt;
&lt;br /&gt;
== Get the third-party libraries  ==&lt;br /&gt;
Now you could configure the VLC build. But first, you need to make sure that all the required dependencies are in place. Take a look at &amp;lt;tt&amp;gt;./configure --help&amp;lt;/tt&amp;gt;. Take a good look at that enormous list of options.&lt;br /&gt;
&lt;br /&gt;
It is very important that you do install and enable all the 3rd party libraries that you need. Yes, there is going to be a lot of them if you want a complete or even mostly functional VLC build. If you fail to install a required library, you will end up with a VLC application that well..... essentially does not do anything useful. See [[Contrib Status|here]] for a complete list.&lt;br /&gt;
 &lt;br /&gt;
There are some very important dependencies: gettext (NLS) for international support (required), libdvbpsi for MPEG-TS files and streams support, libmad for MP3 audio decoding, libmpeg2 for MPEG1 and MPEG2 video support, FFmpeg or libav (libavcodec, libavformat, libpostproc, libswscale and optionally libavio) for MPEG4 and most other audio and video codecs, and many file formats, liba52 for Dolby (AC3) sound, dvdread and dvdnav for DVD playback, live555 for RTSP stream playback, etc.&lt;br /&gt;
&lt;br /&gt;
For audio output, you will need probably alsa-lib (on [[Linux]]) and/or libpulse (for [[PulseAudio]]).&lt;br /&gt;
For video output, you will normally need XCB/XVideo and/or OpenGL/GLX.&lt;br /&gt;
And Qt4 is required to get the GUI support.&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039; that you need to install the development packages (development header files and import libraries) to compile VLC, not just the run-time. On Debian/Ubuntu, the correct package names end with -dev. On RPM distributions, they usually end in -devel.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Be careful!&#039;&#039;&#039; If the libraries are not provided by your distribution, you may be better off linking VLC with them statically. Otherwise, you may encounter version problems if another multimedia application updates the libraries later. This is especially true of FFmpeg or libav, and live555.&lt;br /&gt;
&lt;br /&gt;
There are a several ways to get those libraries. You should use only one method at a time: &lt;br /&gt;
 &lt;br /&gt;
=== The preferred method ===&lt;br /&gt;
Use your distribution packaging or portage system, in order to get all the needed libs.&lt;br /&gt;
For example on Debian or Ubuntu: &lt;br /&gt;
 # apt-get build-dep vlc&lt;br /&gt;
&lt;br /&gt;
openSUSE users might have a look at the source-install (si) command in the zypper manpage:&lt;br /&gt;
 # zypper si -d vlc&lt;br /&gt;
&lt;br /&gt;
=== The method for badly-behaved distributions ===&lt;br /&gt;
If your distribution does not provide the needed libraries,&lt;br /&gt;
or you really want to link VLC statically, use the VLC contribs system. It is included in the VLC source.&lt;br /&gt;
&lt;br /&gt;
First, you need to install the GNU autotools (if you have not already done so), CMake, subversion, Git and a recent GNU/tar utility or equivalent. Then you can run:&lt;br /&gt;
 % cd contrib&lt;br /&gt;
 % mkdir native&lt;br /&gt;
 % cd native&lt;br /&gt;
 % ../bootstrap&lt;br /&gt;
 % make&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039; the commands above are for VLC 1.2 or later. Details differ slightly for older versions:&lt;br /&gt;
 % cd extras/contrib&lt;br /&gt;
 % ./bootstrap&lt;br /&gt;
 % make&lt;br /&gt;
&lt;br /&gt;
That should download and build a lot of those libraries for you.  Unfortunately, given the large number of libraries and the variety of the platforms people build VLC for, it is not unlikely that you will hit an error while contribs are compiling. Thus, this approach is only recommended for experienced Unix compilers.&lt;br /&gt;
&lt;br /&gt;
=== The method for people with too much time to waste ===&lt;br /&gt;
Read the [[Contrib Status|list]], download them and build them by hand.&lt;br /&gt;
&lt;br /&gt;
=== Regardless of the method ===&lt;br /&gt;
In any case, some basic OS support libraries are not included and must really be installed through the packaging system in any case, notably [[ALSA]], [[PulseAudio]] and [[OpenGL]].&lt;br /&gt;
&lt;br /&gt;
== Configuration  ==&lt;br /&gt;
&amp;lt;tt&amp;gt;./configure&amp;lt;/tt&amp;gt; is used to check whether your system is able to compile VLC. Also you can choose the features in your build. As a reminder, this command will show the various options:&lt;br /&gt;
 % ./configure --help&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;VLC 2.0 and later&#039;&#039;&#039;: For most users, &amp;lt;tt&amp;gt;./configure&amp;lt;/tt&amp;gt; does not require any command-line options.&lt;br /&gt;
&lt;br /&gt;
By default, features to be compiled are chosen automatically depending on what libraries are detected as available. If the contribs have been compiled first, the resulting VLC will be reasonably functional.&lt;br /&gt;
&lt;br /&gt;
Note that libraries that are not in the default prefix, and not in vlc contribs, must be known to pkg-config in order for &amp;lt;tt&amp;gt;./configure&amp;lt;/tt&amp;gt; to find them.&lt;br /&gt;
&lt;br /&gt;
There are some features that are disabled (not compiled) by default. If you want them, they must be forced on by using configure flags. You can find a list of these features by searching for &amp;quot;disabled&amp;quot; in &amp;lt;tt&amp;gt;./configure --help&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
(&#039;&#039;Beginner&#039;s guide&#039;&#039;: enter the command&lt;br /&gt;
 % ./configure --help | less&lt;br /&gt;
and hit enter. Type a slash &#039;/&#039;, type &amp;quot;disabled&amp;quot; (without quotes), hit enter. Pressing &#039;&#039;&#039;n&#039;&#039;&#039; goes to the next match, &#039;&#039;&#039;N&#039;&#039;&#039; goes to previous match, &#039;&#039;&#039;q&#039;&#039;&#039; returns to the command line. Use the up/down arrow keys to scroll. All matches except the &#039;&#039;--cache-file&#039;&#039; option (which belongs to &amp;lt;tt&amp;gt;configure&amp;lt;/tt&amp;gt; itself) are VLC features that must be forced on if desired.)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;VLC 1.1 and earlier&#039;&#039;&#039;: You probably need to tweak the &amp;quot;configure&amp;quot; line. &lt;br /&gt;
 &lt;br /&gt;
=== Special libs  ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;VLC 2.0 and later&#039;&#039;&#039;: there are no special libraries. If live555 exists in the &amp;lt;tt&amp;gt;contrib/&amp;lt;/tt&amp;gt; subdirectory, it is detected automatically. &#039;&#039;Any&#039;&#039; libraries that are not in the default prefix, and not in vlc contribs, must be known to pkg-config in order for &amp;lt;tt&amp;gt;./configure&amp;lt;/tt&amp;gt; to find them.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;VLC 1.1 and earlier&#039;&#039;&#039;: Use &amp;lt;tt&amp;gt;--with-live555-path=path/to/livemedia/source/tree&amp;lt;/tt&amp;gt; in connection with &amp;lt;tt&amp;gt;--enable-live555&amp;lt;/tt&amp;gt;. For FFmpeg or libav, pkg-config is the only reliable way for VLC&#039;s configure to find the libraries. So you need to set PKG_CONFIG_PATH correctly if your FFmpeg/libav libraries are not installed at the default prefix (meaning /usr) or you want to use static linking.&lt;br /&gt;
&lt;br /&gt;
=== Final configuration  ===&lt;br /&gt;
If you want to install VLC into another directory, run &lt;br /&gt;
 &lt;br /&gt;
 % ./configure --prefix=/path/to/install/folder/&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;VLC 1.1 and earlier&#039;&#039;&#039;: This is an example of a typical VLC configure line: &lt;br /&gt;
 &lt;br /&gt;
 % ./configure --enable-x11 --enable-xvideo --enable-sdl --enable-avcodec --enable-avformat \&lt;br /&gt;
  --enable-swscale --enable-mad --enable-libdvbpsi --enable-a52 --enable-libmpeg2 --enable-dvdnav \&lt;br /&gt;
  --enable-faad --enable-vorbis --enable-ogg --enable-theora --enable-faac --enable-mkv --enable-freetype \&lt;br /&gt;
  --enable-fribidi --enable-speex --enable-flac --enable-live555 --with-live555-tree=/usr/lib/live \&lt;br /&gt;
  --enable-caca --enable-skins --enable-skins2 --enable-alsa --enable-qt4 --enable-ncurses&lt;br /&gt;
 &lt;br /&gt;
[[User:J-b#VLC_configure_line|Here]] is another. &lt;br /&gt;
&lt;br /&gt;
=== Ubuntu ===&lt;br /&gt;
&lt;br /&gt;
If you get continuous errors while ./configure then consider reinstalling the corresponding libraries. This will set the paths and other information correctly. Check the $PKG_CONFIG_PATH(environment variable) whether it is set to a path where the libraries like libavcodec.pc are available. Otherwise create the environment variable, export it and then update the ldconfig.&lt;br /&gt;
&lt;br /&gt;
== Compilation ==&lt;br /&gt;
Compile VLC: &lt;br /&gt;
 % make&lt;br /&gt;
&lt;br /&gt;
You do not need to install VLC to use it. You can also simply run it from the build directory:&lt;br /&gt;
 # ./vlc&lt;br /&gt;
&lt;br /&gt;
If you really want to install VLC to the system, run this as root:&lt;br /&gt;
 # make install&lt;br /&gt;
&lt;br /&gt;
You can uninstall later with this, but you need to keep the build tree untouched until then:&lt;br /&gt;
 # make uninstall&lt;br /&gt;
&lt;br /&gt;
To remove files created during the compile (optional) type:&lt;br /&gt;
 % make clean&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
&lt;br /&gt;
=== Cygwin ===&lt;br /&gt;
&lt;br /&gt;
Compiling on [[Win32CompileCygwin|Cygwin]] may be broken from time to time as Cygwin packages change.&lt;br /&gt;
We recommend [[Win32Compile|cross-compiling from Linux to Windows]] instead. &#039;&#039;&#039;Consider yourself warned.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Debian/Ubuntu ===&lt;br /&gt;
Debian users who want to compile VLC should install the packages below:&lt;br /&gt;
*[http://packages.debian.org/unstable/libdevel/libavcodec-dev libavcodec-dev] &lt;br /&gt;
*[http://packages.debian.org/unstable/libdevel/libpostproc-dev libpostproc-dev] &lt;br /&gt;
*[http://packages.debian.org/unstable/libdevel/libmpeg2-4-dev libmpeg2-4-dev]&lt;br /&gt;
&lt;br /&gt;
If you just want to &#039;&#039;use&#039;&#039; VLC media player then simply install the package vlc (&amp;lt;tt&amp;gt;sudo apt-get install vlc&amp;lt;/tt&amp;gt;) - the unstable version is fairly up-to-date most of the time, while the stable is, err, stable and very old&amp;amp;nbsp;;-)&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting / common problems ==&lt;br /&gt;
&lt;br /&gt;
=== Lua ===&lt;br /&gt;
You may need to install Lua if you get &amp;quot;LUA byte compiler missing.&amp;quot; message. You namely need to install &amp;quot;luac&amp;quot;, the Lua byte compiler.&lt;br /&gt;
&lt;br /&gt;
On Debian/Ubuntu:&lt;br /&gt;
 % sudo apt-get install lua5.1&lt;br /&gt;
&lt;br /&gt;
On Fedora:&lt;br /&gt;
 % sudo yum install lua&lt;br /&gt;
&lt;br /&gt;
=== XCB ===&lt;br /&gt;
&lt;br /&gt;
VLC 1.1 and later requires XCB libraries to deal with X11 displays. Do not disable XCB or you will not get any video support!&lt;br /&gt;
&lt;br /&gt;
To install these libraries run the following commands (Debian/Ubuntu):&lt;br /&gt;
 % sudo apt-get install libxcb-shm0-dev libxcb-xv0-dev libxcb-keysyms1-dev libxcb-randr0-dev libxcb-composite0-dev&lt;br /&gt;
&lt;br /&gt;
Under Fedora:&lt;br /&gt;
 % sudo yum install libxcb-devel xcb-util-devel&lt;br /&gt;
&lt;br /&gt;
For OpenGL (Debian/Ubuntu only), you will additionally need XLib with XCB:&lt;br /&gt;
 % sudo apt-get install libx11-xcb-dev&lt;br /&gt;
&lt;br /&gt;
If your distribution provides a version of XLib without XCB, then this later package will not be available. So you will not be able to use OpenGL. Use XVideo instead.&lt;br /&gt;
&lt;br /&gt;
=== Compile fails after git pull ===&lt;br /&gt;
&lt;br /&gt;
It is likely that the sources in the repository have changed significantly since they were last pulled, and a build system cache has gone out of date. Try the troubleshooting methods described in the [[Hacker_Guide/How_To_Write_a_Module#Module_load_troubleshooting|hacker guide for modules]].&lt;br /&gt;
&lt;br /&gt;
[[Category:Building]]&lt;/div&gt;</summary>
		<author><name>Technologicat</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=Hacker_Guide/How_To_Write_a_Module&amp;diff=22032</id>
		<title>Hacker Guide/How To Write a Module</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=Hacker_Guide/How_To_Write_a_Module&amp;diff=22032"/>
		<updated>2012-02-17T13:13:44Z</updated>

		<summary type="html">&lt;p&gt;Technologicat: /* Module load troubleshooting */ grammar: -ing&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;VLC is based on many independent modules, like most competing multimedia frameworks. Each module introduces a new functionality.&lt;br /&gt;
&lt;br /&gt;
This article focuses on adding a new module (a.k.a. plug-in) to VLC. You &#039;&#039;&#039;will need to read&#039;&#039;&#039; [[Documentation:Hacker%27s_Guide/Core#VLC_Pipeline_and_Modularity|VLC Core and Modules ]] and [[Documentation:VLC_Modules_Loading|How VLC loads modules]] first, otherwise you will not be able to flesh out the content of your new module.&lt;br /&gt;
&lt;br /&gt;
== In-tree and out-of-tree modules ==&lt;br /&gt;
&lt;br /&gt;
Most existing VLC modules are provided as source code within the main VLC source code repository (and also the source tarballs). They are compiled at the same time as the VLC core, and usually provided distributed together with VLC binary packages and installers. These modules are called in-tree modules.&lt;br /&gt;
&lt;br /&gt;
However, it is also possible to write and compile VLC modules outside of VLC. That has some pros and cons over developing modules in-tree:&lt;br /&gt;
===Pros===&lt;br /&gt;
* Compilation is a lot faster (VLC and other modules are not included in the process).&lt;br /&gt;
* You can use your own version control system, or even none at all.&lt;br /&gt;
* The copyright license does not need to abide by the requirements of the [[VideoLAN]] association for inclusion in VLC. &lt;br /&gt;
* The source code does not need to be provided, reviewed and accepted by the VLC developers.&lt;br /&gt;
* The release schedule is independent of VLC releases. New versions of the module can be published at any time regardless of VLC release planning.&lt;br /&gt;
* Different programming languages can be used at least in theory. (The main VLC code base only uses C, C++ and Lua, and on MacOS Objective C.)&lt;br /&gt;
* The module can use software libraries that would be inadequate for VLC to depend on.&lt;br /&gt;
&lt;br /&gt;
===Cons===&lt;br /&gt;
* The VLC developers will not review the code, which would be a good opportunity fo improve the code quality.&lt;br /&gt;
* VLC translators will not take care of localization for the module(s) where applicable. VLC is translated in many tens of languages.&lt;br /&gt;
* The module(s) cannot be distributed through the [http://www.videolan.org/ videolan.org] website and use the VideoLAN infrastructure such as the bug tracker and the build bots.&lt;br /&gt;
* The module(s) will only work with the particular VLC (major) version that it has been compiled for. For instance, a module compiled for VLC 1.1.x will not work with VLC 1.0.x or VLC 2.0.x.&lt;br /&gt;
* The module(s) will only work on the particular operating systems and architecture that it has been compiled for. For instance, a Windows 32-bit module will only work with Windows 32-bit versions of VLC. VLC supports many different combinations of operating systems and architectures.&lt;br /&gt;
&lt;br /&gt;
== Example stub module  ==&lt;br /&gt;
&lt;br /&gt;
Let&#039;s start with a small example module in the C language: &lt;br /&gt;
&amp;lt;pre&amp;gt;/**&lt;br /&gt;
 * @file hello.c&lt;br /&gt;
 * @brief Hello world interface VLC module example&lt;br /&gt;
 */&lt;br /&gt;
#ifdef HAVE_CONFIG_H&lt;br /&gt;
# include &amp;quot;config.h&amp;quot;&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
/* VLC core API headers */&lt;br /&gt;
#include &amp;amp;lt;vlc_common.h&amp;amp;gt;&lt;br /&gt;
#include &amp;amp;lt;vlc_plugin.h&amp;amp;gt;&lt;br /&gt;
#include &amp;amp;lt;vlc_interface.h&amp;amp;gt;&lt;br /&gt;
&lt;br /&gt;
/* Forward declarations */&lt;br /&gt;
static int Open(vlc_object_t *);&lt;br /&gt;
static void Close(vlc_object_t *);&lt;br /&gt;
&lt;br /&gt;
/* Module descriptor */&lt;br /&gt;
vlc_module_begin()&lt;br /&gt;
    set_shortname(N_(&amp;quot;Hello&amp;quot;))&lt;br /&gt;
    set_description(N_(&amp;quot;Hello interface&amp;quot;))&lt;br /&gt;
    set_capability(&amp;quot;interface&amp;quot;, 0)&lt;br /&gt;
    set_callbacks(Open, Close)&lt;br /&gt;
    set_category(CAT_INTERFACE)&lt;br /&gt;
    add_string(&amp;quot;hello-who&amp;quot;, &amp;quot;world&amp;quot;, &amp;quot;Target&amp;quot;, &amp;quot;Whom to say hello to.&amp;quot;, false)&lt;br /&gt;
vlc_module_end ()&lt;br /&gt;
&lt;br /&gt;
/* Internal state for an instance of the module */&lt;br /&gt;
struct intf_sys_t&lt;br /&gt;
{&lt;br /&gt;
    char *who;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Starts our example interface.&lt;br /&gt;
 */&lt;br /&gt;
static int Open(vlc_object_t *obj)&lt;br /&gt;
{&lt;br /&gt;
    intf_thread_t *intf = (intf_thread_t *)obj;&lt;br /&gt;
&lt;br /&gt;
    /* Allocate internal state */&lt;br /&gt;
    intf_sys_t *sys = malloc(sizeof (*sys));&lt;br /&gt;
    if (unlikely(sys == NULL))&lt;br /&gt;
        return VLC_ENOMEM;&lt;br /&gt;
    intf-&amp;gt;p_sys = sys;&lt;br /&gt;
&lt;br /&gt;
    /* Read settings */&lt;br /&gt;
    char *who = var_InheritString(intf, &amp;quot;hello-who&amp;quot;);&lt;br /&gt;
    if (who == NULL)&lt;br /&gt;
    {&lt;br /&gt;
        msg_Err(intf, &amp;quot;Nobody to say hello to!&amp;quot;);&lt;br /&gt;
        goto error;&lt;br /&gt;
    }&lt;br /&gt;
    sys-&amp;gt;who = who;&lt;br /&gt;
&lt;br /&gt;
    msg_Info(intf, &amp;quot;Hello %s!&amp;quot;, who);&lt;br /&gt;
    return VLC_SUCCESS;&lt;br /&gt;
&lt;br /&gt;
error:&lt;br /&gt;
    free(sys);&lt;br /&gt;
    return VLC_EGENERIC;    &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Stops the interface. &lt;br /&gt;
 */&lt;br /&gt;
static void Close(vlc_object_t *obj)&lt;br /&gt;
{&lt;br /&gt;
    intf_thread_t *intf = (intf_thread_t *)obj;&lt;br /&gt;
    intf_sys_t *sys = intf-&amp;gt;p_sys;&lt;br /&gt;
&lt;br /&gt;
    msg_Info(intf, &amp;quot;Good bye %s!&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    /* Free internal state */&lt;br /&gt;
    free(sys-&amp;gt;who);&lt;br /&gt;
    free(sys);&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And now some explanations about the code...&lt;br /&gt;
&lt;br /&gt;
=== Module Descriptor  ===&lt;br /&gt;
&lt;br /&gt;
A {{VLC}} module &#039;&#039;&#039;must&#039;&#039;&#039; include a &#039;&#039;description&#039;&#039; of itself, and the &#039;&#039;parameters&#039;&#039; it accepts. &lt;br /&gt;
&lt;br /&gt;
The module descriptor begins with: &lt;br /&gt;
&amp;lt;pre&amp;gt;vlc_module_begin();&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
You should set some basic information about your module. This is for the dvdread module:&lt;br /&gt;
&amp;lt;pre&amp;gt;    set_shortname(N_(&amp;quot;DVD without menus&amp;quot;));&lt;br /&gt;
    set_description(N_(&amp;quot;DVDRead Input&amp;quot;));&lt;br /&gt;
    set_category(CAT_INPUT);&lt;br /&gt;
    set_subcategory(SUBCAT_INPUT_ACCESS);&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&#039;&#039;Note&#039;&#039; the use of N_(&amp;quot;&amp;quot;) to create a string that needs to be translated by gettext.&lt;br /&gt;
&lt;br /&gt;
==== Capability and score ====&lt;br /&gt;
&lt;br /&gt;
Definition &#039;&#039;&#039;Example&#039;&#039;&#039;: &lt;br /&gt;
&amp;lt;pre&amp;gt;   set_capability(&amp;quot;interface&amp;quot;, 0)&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
This defines a module of &amp;quot;interface&amp;quot; capability and a score of 0.&lt;br /&gt;
&lt;br /&gt;
The capability determines the type of module we are dealing with. It could be an access, a demux, a decoder, an interface, etc. Now is the time to &#039;&#039;&#039;re-read [[Documentation:VLC Modules Loading#How_does_the_loading_of_modules_happens|how VLC loads modules]]&#039;&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
*If VLC needs to load a specific name, it will load it by its name and VLC directly opens this module &lt;br /&gt;
*If VLC needs a type of module (&amp;quot;I need a decoder&amp;quot;), VLC will load all modules matching this capability in a decreasing score order until one modules&#039;s Open() function (see later) returns VLC_SUCCESS.&lt;br /&gt;
&lt;br /&gt;
See the major types of [[Documentation:VLC Modules Loading#Major_Capabilities_of_Modules|capabilities of VLC]]. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Score&#039;&#039;&#039; should be an integer, and related to other scores in the same category. Score 0 is a [[Documentation:VLC_Modules_Loading#Score_of_0|special case]].&lt;br /&gt;
&lt;br /&gt;
==== Configuration categories and sub-categories  ====&lt;br /&gt;
&lt;br /&gt;
You should use &#039;&#039;&#039;one&#039;&#039;&#039; of the &#039;&#039;&#039;predefined categories&#039;&#039;&#039; for configuration. The configuration categories and sub-categories specify &#039;&#039;&#039;where&#039;&#039;&#039; the module will appear in the &#039;&#039;&#039;preferences&#039;&#039;&#039; UI dialog. &lt;br /&gt;
&lt;br /&gt;
The configuration categories include: &lt;br /&gt;
*CAT_INTERFACE &lt;br /&gt;
*CAT_AUDIO &lt;br /&gt;
*CAT_VIDEO &lt;br /&gt;
*CAT_INPUT &lt;br /&gt;
*CAT_SOUT &lt;br /&gt;
*CAT_ADVANCED &lt;br /&gt;
*CAT_PLAYLIST&lt;br /&gt;
&lt;br /&gt;
You should use one of &#039;&#039;&#039;predefined sub-categories&#039;&#039;&#039; as well. See {{VLCSourceFile|name=include/vlc_configuration.h}} for definition of all configuration categories and sub-categories. &lt;br /&gt;
&lt;br /&gt;
==== Configuration parameters ====&lt;br /&gt;
&lt;br /&gt;
You may need options to configure the run-time behavior of your module. Defining new options is easy. &lt;br /&gt;
&lt;br /&gt;
All option definitions take the following argument list: &lt;br /&gt;
&amp;lt;pre&amp;gt; add_integer(name, value, text, longtext, advanced) &amp;lt;/pre&amp;gt; &lt;br /&gt;
*&#039;&#039;&#039;name&#039;&#039;&#039; is the string that identifies this parameter in the configuration. This name is used at the command prompt to set the configuration value. &lt;br /&gt;
*&#039;&#039;&#039;value&#039;&#039;&#039; is the default value for this parameter, &lt;br /&gt;
*&#039;&#039;&#039;text&#039;&#039;&#039; A short description of the parameter, use _(&amp;quot;&amp;quot;) to create a string that needs to be translated, &lt;br /&gt;
*&#039;&#039;&#039;longtext&#039;&#039;&#039; A complete description of the parameter, use _(&amp;quot;&amp;quot;) to create a string that needs to be translated,&lt;br /&gt;
*&#039;&#039;&#039;advanced&#039;&#039;&#039; Boolean, ADVanced Configuration. If TRUE, this parameter will only be displayed when using the --advanced flag.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt; You may add the following options/parameter types to your module: &lt;br /&gt;
*add_integer, &lt;br /&gt;
*add_string, &lt;br /&gt;
*add_float, &lt;br /&gt;
*add_bool, &lt;br /&gt;
*add_key, &lt;br /&gt;
*add_file, &lt;br /&gt;
*add_directory,&lt;br /&gt;
&lt;br /&gt;
For complete definitions, see {{VLCSourceFile|name=include/vlc_plugin.h}}&lt;br /&gt;
&lt;br /&gt;
==== Callback  ====&lt;br /&gt;
&lt;br /&gt;
The activation and deactivation functions, detailed afterwards, must be defined in the descriptor. This is so that the VLC core knows how to instantiate and run the module.&lt;br /&gt;
&lt;br /&gt;
The set_callbacks() macro allows you to define 2 parameters: the first parameter is the pf_activate callback, and the second one, pf_deactivate. The functions are most often called &amp;quot;Open&amp;quot; and &amp;quot;Close&amp;quot; respectively, though. VLC invokes the pf_activate callback if/when it needs a plugin instance providing the correct interface, as declared with the set_capability() macro.&lt;br /&gt;
&lt;br /&gt;
Conversely, VLC invokes the pf_deactivate callback when the plugin is no longer needed - but only if the pf_activate callback returned VLC_SUCCESS (0) earlier.&lt;br /&gt;
&lt;br /&gt;
=== Open(vlc_object_t *) ===&lt;br /&gt;
&lt;br /&gt;
The most important function of a module is the opening: the usually-named Open() function. &lt;br /&gt;
&amp;lt;pre&amp;gt;static int  Open ( vlc_object_t * );&amp;lt;/pre&amp;gt; &lt;br /&gt;
The Open() function is called when the VLC core tries to open the module, and wants to load it. &lt;br /&gt;
&lt;br /&gt;
During Open(), setup of structures, devices or I/O, checks should be done. A successful open should return VLC_SUCCESS. If the module cannot complete its initialization, it can return any other value, usually VLC_EGENERIC or VLC_ENOMEM.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Open()&#039;&#039;&#039; function is expected to allocate private data (if any), and set up the private structure.&lt;br /&gt;
&lt;br /&gt;
If the Opening fails, you may need to free any already allocated resources before returning. Otherwise, leaks will occur.&lt;br /&gt;
&lt;br /&gt;
=== Close(vlc_object_t *)  ===&lt;br /&gt;
The second most important function of a module is the closing: the usually-named Close() function.&lt;br /&gt;
&amp;lt;pre&amp;gt;static int  Close ( vlc_object_t * );&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Close() function is called when the VLC core tries to close or unload an &#039;&#039;&#039;already-loaded&#039;&#039;&#039; module.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NB:&#039;&#039;&#039; If the Open() function failed, Close() will not get called.&lt;br /&gt;
&lt;br /&gt;
During Close(), closing devices or I/O, and cleaning of structures should be done. Do not leak memory here!&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Close()&#039;&#039;&#039; function should deallocate private data.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== In-tree module integration ==&lt;br /&gt;
&lt;br /&gt;
=== Git ===&lt;br /&gt;
If you plan to submit your work to VLC upstream, be sure to look at [[Git |the git introduction]] and check the [[Git#Submitting_patches_to_the_vlc-devel_or_x264-devel|send patches part]].&lt;br /&gt;
&lt;br /&gt;
=== Compiling your module ===&lt;br /&gt;
&lt;br /&gt;
==== Modules.am ====&lt;br /&gt;
First, find the right subdirectory under [[Modules_source_tree| modules/]] to add your new code.&lt;br /&gt;
&lt;br /&gt;
# If the module has only one source code file module, simply add it in the subdirectory (e.g. modules/control/hello.c).&lt;br /&gt;
# Larger modules should get a sub-subdirectory of their own (e.g. modules/control/hello/*).&lt;br /&gt;
&lt;br /&gt;
Then you need to declare the module in the build system. For example, the file {{VLCSourceFile|name=modules/control/Modules.am}} tells the build system which source files are needed for each control module. For the example above, we could add these lines:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
libhello_plugin_la_SOURCES = hello.c&lt;br /&gt;
libhello_plugin_la_CFLAGS = $(AM_CFLAGS)&lt;br /&gt;
libhello_plugin_la_LIBADD = $(AM_LIBADD)&lt;br /&gt;
libhello_plugin_la_DEPENDENCIES =&lt;br /&gt;
# Always compile the hello module:&lt;br /&gt;
libvlc_LTLIBRARIES += libhello_plugin.la&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that indentation in Modules.am (if needed) uses tabulations (ASCII 0x09), not white spaces.&lt;br /&gt;
&lt;br /&gt;
==== configure.ac ====&lt;br /&gt;
&lt;br /&gt;
If the module depends on some new library, some architecture or some operating system characteristics, you may need to extend configure.ac to detect when and how to build the module. Refer to the configure.ac file and the [http://www.gnu.org/software/autoconf/manual/index.html GNU autoconf documentation] for details.&lt;br /&gt;
&lt;br /&gt;
Once this is done, you should only need to rebuild VLC:&lt;br /&gt;
 make&lt;br /&gt;
(This will probably trigger a re-run of autoconf and automake, so it might take a while.)&lt;br /&gt;
&lt;br /&gt;
=== Loading your module ===&lt;br /&gt;
&lt;br /&gt;
VLC keeps a cache of available modules for performance reasons. It should be updated automatically. But you can use &#039;&#039;./vlc --reset-plugins-cache&#039;&#039; to force a reset.&lt;br /&gt;
&lt;br /&gt;
Then use&lt;br /&gt;
 ./vlc -vvv --color --list&lt;br /&gt;
to check that your plugin is seen by {{VLC}}.&lt;br /&gt;
&lt;br /&gt;
You should also see it in the plugins dialog of the [[Qt interface]] (Linux and Windows).&lt;br /&gt;
&lt;br /&gt;
== Out-of-tree module ==&lt;br /&gt;
&lt;br /&gt;
There is a dedicated article. Please read [[OutOfTreeCompile|out of tree compilation]].&lt;br /&gt;
&lt;br /&gt;
== Sub-modules  ==&lt;br /&gt;
&lt;br /&gt;
Sub-modules, declared in some module descriptors with &lt;br /&gt;
&lt;br /&gt;
 add_submodule()&lt;br /&gt;
&lt;br /&gt;
work exactly the same way as modules. They are useful when different modules (usually but not necessarily of different capability) share common code. All sub-modules will be included in the same run-time library as the main module.&lt;br /&gt;
&lt;br /&gt;
== Module types ==&lt;br /&gt;
&lt;br /&gt;
Depending on the module capability, you will need more information, about the necessary functions to implement.&lt;br /&gt;
&lt;br /&gt;
We will detail those here:&lt;br /&gt;
* [[Hacker_Guide/Access|Access]]&lt;br /&gt;
* [[Hacker_Guide/Demux|Demux]]&lt;br /&gt;
* [[Hacker_Guide/Access_Demux|Access_Demux]]&lt;br /&gt;
* [[Hacker_Guide/Decoder|Decoder]]&lt;br /&gt;
* Interface&lt;br /&gt;
* [[Hacker_Guide/Video_Filters|Video filter]]&lt;br /&gt;
* [[Hacker_Guide/Audio_Filters|Audio filter]]&lt;br /&gt;
* [[Hacker_Guide/Audio_Output|Audio output]]&lt;br /&gt;
&lt;br /&gt;
== Module load troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
Sometimes when building an in-tree module, stuff doesn&#039;t work due to build system problems and other inconsistencies.&lt;br /&gt;
&lt;br /&gt;
You probably need to go to the root of your VLC source tree, and do something akin to the following. The examples here assume the &#039;&#039;bash&#039;&#039; shell.&lt;br /&gt;
&lt;br /&gt;
===&#039;&#039;&#039;Mild version&#039;&#039;&#039;===&lt;br /&gt;
&lt;br /&gt;
In some cases, automake dependencies break (for instance after some filenames have changed). This might then work:&lt;br /&gt;
&lt;br /&gt;
 find . -name .deps -exec rm -rf \{\} \;&lt;br /&gt;
 ./config.status&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
...but not always, so it may save some headaches to always use the &amp;quot;medium version&amp;quot; below.&lt;br /&gt;
&lt;br /&gt;
===&#039;&#039;&#039;Medium version&#039;&#039;&#039; (try this first)===&lt;br /&gt;
&lt;br /&gt;
This is a more radical but still safe rebuild procedure:&lt;br /&gt;
&lt;br /&gt;
 find . -name .deps -exec rm -rf \{\} \;&lt;br /&gt;
 ./bootstrap&lt;br /&gt;
 ./configure&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
===&#039;&#039;&#039;Extreme version&#039;&#039;&#039;===&lt;br /&gt;
&lt;br /&gt;
If the none of the above helped, you can clean the source tree as a measure of last resort.&lt;br /&gt;
Before you proceed, it is highly recommended that you check which files are going to be erased:&lt;br /&gt;
 git clean -nxd&lt;br /&gt;
&lt;br /&gt;
And then check what source code changes you would lose (if any):&lt;br /&gt;
 git diff&lt;br /&gt;
&lt;br /&gt;
You can extremely easily lose entire days of hard work with the following commands. &lt;br /&gt;
The first command will permanently remove any files not tracked in [[git]], including files that you might have created yourself.&lt;br /&gt;
The second command will remove any uncommitted modification to existing files. Consider yourself warned.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;!!!BEWARE: THIS MAY CAUSE UNRECOVERABLE DATA LOSS!!!&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 git clean -fxd&lt;br /&gt;
 git reset --hard HEAD&lt;br /&gt;
 ./bootstrap&lt;br /&gt;
 ./configure&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
{{Documentation}} &lt;br /&gt;
[[Category:Coding]]&lt;/div&gt;</summary>
		<author><name>Technologicat</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=UnixCompile&amp;diff=22031</id>
		<title>UnixCompile</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=UnixCompile&amp;diff=22031"/>
		<updated>2012-02-17T13:05:15Z</updated>

		<summary type="html">&lt;p&gt;Technologicat: /* Configuration */ Updated for 2.0. Updated note on special libs.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Prepare your environment  ==&lt;br /&gt;
&lt;br /&gt;
VLC requires a C compiler, development headers and a toolchain. gcc will do but you could also use LLVM or proprietary C99/C++ compilers such as Intel&#039;s.&lt;br /&gt;
&lt;br /&gt;
If you build from the [[Git]] repositories, you will also need the GNU build system, a.k.a. the &amp;quot;autotools&amp;quot; (autoconf, automake, libtool and gettext) to setup the Makefiles. Make sure they are up-to-date and usable for your system.&lt;br /&gt;
&lt;br /&gt;
On Fedora:&lt;br /&gt;
&lt;br /&gt;
 % sudo yum install git libtool&lt;br /&gt;
&lt;br /&gt;
== Get the source  ==&lt;br /&gt;
Start by [[GetTheSource|getting the source]], using FTP for official releases, or using [[Git]] to track VLC development. &lt;br /&gt;
&lt;br /&gt;
If your are using an official release, download source code, extract the archive and go into the resulting VLC directory, e.g.:&lt;br /&gt;
 % wget ftp://ftp.videolan.org/pub/videolan/vlc/1.1.11/vlc-1.1.11.tar.bz2&lt;br /&gt;
 % tar xvjf vlc-1.1.11.tar.bz2&lt;br /&gt;
 % cd vlc-1.1.11&lt;br /&gt;
&lt;br /&gt;
If you are using the [[Git]] development version, start by bootstrapping the source tree:&lt;br /&gt;
 % cd vlc&lt;br /&gt;
 % ./bootstrap&lt;br /&gt;
Bootstrapping will fail if the autotools are missing or out-of-date.&lt;br /&gt;
&lt;br /&gt;
== Get the third-party libraries  ==&lt;br /&gt;
Now you could configure the VLC build. But first, you need to make sure that all the required dependencies are in place. Take a look at &amp;lt;tt&amp;gt;./configure --help&amp;lt;/tt&amp;gt;. Take a good look at that enormous list of options.&lt;br /&gt;
&lt;br /&gt;
It is very important that you do install and enable all the 3rd party libraries that you need. Yes, there is going to be a lot of them if you want a complete or even mostly functional VLC build. If you fail to install a required library, you will end up with a VLC application that well..... essentially does not do anything useful. See [[Contrib Status|here]] for a complete list.&lt;br /&gt;
 &lt;br /&gt;
There are some very important dependencies: gettext (NLS) for international support (required), libdvbpsi for MPEG-TS files and streams support, libmad for MP3 audio decoding, libmpeg2 for MPEG1 and MPEG2 video support, FFmpeg or libav (libavcodec, libavformat, libpostproc, libswscale and optionally libavio) for MPEG4 and most other audio and video codecs, and many file formats, liba52 for Dolby (AC3) sound, dvdread and dvdnav for DVD playback, live555 for RTSP stream playback, etc.&lt;br /&gt;
&lt;br /&gt;
For audio output, you will need probably alsa-lib (on [[Linux]]) and/or libpulse (for [[PulseAudio]]).&lt;br /&gt;
For video output, you will normally need XCB/XVideo and/or OpenGL/GLX.&lt;br /&gt;
And Qt4 is required to get the GUI support.&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039; that you need to install the development packages (development header files and import libraries) to compile VLC, not just the run-time. On Debian/Ubuntu, the correct package names end with -dev. On RPM distributions, they usually end in -devel.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Be careful!&#039;&#039;&#039; If the libraries are not provided by your distribution, you may be better off linking VLC with them statically. Otherwise, you may encounter version problems if another multimedia application updates the libraries later. This is especially true of FFmpeg or libav, and live555.&lt;br /&gt;
&lt;br /&gt;
There are a several ways to get those libraries. You should use only one method at a time: &lt;br /&gt;
 &lt;br /&gt;
=== The preferred method ===&lt;br /&gt;
Use your distribution packaging or portage system, in order to get all the needed libs.&lt;br /&gt;
For example on Debian or Ubuntu: &lt;br /&gt;
 # apt-get build-dep vlc&lt;br /&gt;
&lt;br /&gt;
openSUSE users might have a look at the source-install (si) command in the zypper manpage:&lt;br /&gt;
 # zypper si -d vlc&lt;br /&gt;
&lt;br /&gt;
=== The method for badly-behaved distributions ===&lt;br /&gt;
If your distribution does not provide the needed libraries,&lt;br /&gt;
or you really want to link VLC statically, use the VLC contribs system. It is included in the VLC source.&lt;br /&gt;
&lt;br /&gt;
First, you need to install the GNU autotools (if you have not already done so), CMake, subversion, Git and a recent GNU/tar utility or equivalent. Then you can run:&lt;br /&gt;
 % cd contrib&lt;br /&gt;
 % mkdir native&lt;br /&gt;
 % cd native&lt;br /&gt;
 % ../bootstrap&lt;br /&gt;
 % make&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039; the commands above are for VLC 1.2 or later. Details differ slightly for older versions:&lt;br /&gt;
 % cd extras/contrib&lt;br /&gt;
 % ./bootstrap&lt;br /&gt;
 % make&lt;br /&gt;
&lt;br /&gt;
That should download and build a lot of those libraries for you.  Unfortunately, given the large number of libraries and the variety of the platforms people build VLC for, it is not unlikely that you will hit an error while contribs are compiling. Thus, this approach is only recommended for experienced Unix compilers.&lt;br /&gt;
&lt;br /&gt;
=== The method for people with too much time to waste ===&lt;br /&gt;
Read the [[Contrib Status|list]], download them and build them by hand.&lt;br /&gt;
&lt;br /&gt;
=== Regardless of the method ===&lt;br /&gt;
In any case, some basic OS support libraries are not included and must really be installed through the packaging system in any case, notably [[ALSA]], [[PulseAudio]] and [[OpenGL]].&lt;br /&gt;
&lt;br /&gt;
== Configuration  ==&lt;br /&gt;
&amp;lt;tt&amp;gt;./configure&amp;lt;/tt&amp;gt; is used to check whether your system is able to compile VLC. Also you can choose the features in your build. As a reminder, this command will show the various options:&lt;br /&gt;
 % ./configure --help&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;VLC 2.0 and later&#039;&#039;&#039;: For most users, &amp;lt;tt&amp;gt;./configure&amp;lt;/tt&amp;gt; does not require any command-line options.&lt;br /&gt;
&lt;br /&gt;
By default, features to be compiled are chosen automatically depending on what libraries are detected as available. If the contribs have been compiled first, the resulting VLC will be reasonably functional.&lt;br /&gt;
&lt;br /&gt;
Note that libraries that are not in the default prefix, and not in vlc contribs, must be known to pkg-config in order for &amp;lt;tt&amp;gt;./configure&amp;lt;/tt&amp;gt; to find them.&lt;br /&gt;
&lt;br /&gt;
There are some features that are disabled (not compiled) by default. If you want them, they must be forced on by using configure flags. You can find a list of these features by searching for &amp;quot;disabled&amp;quot; in &amp;lt;tt&amp;gt;./configure --help&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
(&#039;&#039;Beginner&#039;s guide&#039;&#039;: enter the command&lt;br /&gt;
 % ./configure --help | less&lt;br /&gt;
and hit enter. Type a slash &#039;/&#039;, type &amp;quot;disabled&amp;quot; (without quotes), hit enter. Pressing &#039;&#039;&#039;n&#039;&#039;&#039; goes to the next match, &#039;&#039;&#039;N&#039;&#039;&#039; goes to previous match, &#039;&#039;&#039;q&#039;&#039;&#039; returns to the command line. Use the up/down arrow keys to scroll. All matches except the &#039;&#039;--cache-file&#039;&#039; option (which belongs to &amp;lt;tt&amp;gt;configure&amp;lt;/tt&amp;gt; itself) are VLC features that must be forced on if desired.)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;VLC 1.1 and earlier&#039;&#039;&#039;: You probably need to tweak the &amp;quot;configure&amp;quot; line. &lt;br /&gt;
 &lt;br /&gt;
=== Special libs  ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;VLC 2.0 and later&#039;&#039;&#039;: there are no special libraries. If live555 exists in the &amp;lt;tt&amp;gt;contrib/&amp;lt;/tt&amp;gt; subdirectory, it is detected automatically. &#039;&#039;Any&#039;&#039; libraries that are not in the default prefix, and not in vlc contribs, must be known to pkg-config in order for &amp;lt;tt&amp;gt;./configure&amp;lt;/tt&amp;gt; to find them.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;VLC 1.1 and earlier&#039;&#039;&#039;: Use &amp;lt;tt&amp;gt;--with-live555-path=path/to/livemedia/source/tree&amp;lt;/tt&amp;gt; in connection with &amp;lt;tt&amp;gt;--enable-live555&amp;lt;/tt&amp;gt;. For FFmpeg or libav, pkg-config is the only reliable way for VLC&#039;s configure to find the libraries. So you need to set PKG_CONFIG_PATH correctly if your FFmpeg/libav libraries are not installed at the default prefix (meaning /usr) or you want to use static linking.&lt;br /&gt;
&lt;br /&gt;
=== Final configuration  ===&lt;br /&gt;
If you want to install VLC into another directory, run &lt;br /&gt;
 &lt;br /&gt;
 % ./configure --prefix=/path/to/install/folder/&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;VLC 1.1 and earlier&#039;&#039;&#039;: This is an example of a typical VLC configure line: &lt;br /&gt;
 &lt;br /&gt;
 % ./configure --enable-x11 --enable-xvideo --enable-sdl --enable-avcodec --enable-avformat \&lt;br /&gt;
  --enable-swscale --enable-mad --enable-libdvbpsi --enable-a52 --enable-libmpeg2 --enable-dvdnav \&lt;br /&gt;
  --enable-faad --enable-vorbis --enable-ogg --enable-theora --enable-faac --enable-mkv --enable-freetype \&lt;br /&gt;
  --enable-fribidi --enable-speex --enable-flac --enable-live555 --with-live555-tree=/usr/lib/live \&lt;br /&gt;
  --enable-caca --enable-skins --enable-skins2 --enable-alsa --enable-qt4 --enable-ncurses&lt;br /&gt;
 &lt;br /&gt;
[[User:J-b#VLC_configure_line|Here]] is another. &lt;br /&gt;
&lt;br /&gt;
=== Ubuntu ===&lt;br /&gt;
&lt;br /&gt;
If you get continuous errors while ./configure then consider reinstalling the corresponding libraries. This will set the paths and other information correctly. Check the $PKG_CONFIG_PATH(environment variable) whether it is set to a path where the libraries like libavcodec.pc are available. Otherwise create the environment variable, export it and then update the ldconfig.&lt;br /&gt;
&lt;br /&gt;
== Compilation ==&lt;br /&gt;
Compile VLC: &lt;br /&gt;
 % make&lt;br /&gt;
&lt;br /&gt;
You do not need to install VLC to use it. You can also simply run it from the build directory:&lt;br /&gt;
 # ./vlc&lt;br /&gt;
&lt;br /&gt;
If you really want to install VLC to the system, run this as root:&lt;br /&gt;
 # make install&lt;br /&gt;
&lt;br /&gt;
You can uninstall later with this, but you need to keep the build tree untouched until then:&lt;br /&gt;
 # make uninstall&lt;br /&gt;
&lt;br /&gt;
To remove files created during the compile (optional) type:&lt;br /&gt;
 % make clean&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
&lt;br /&gt;
=== Cygwin ===&lt;br /&gt;
&lt;br /&gt;
Compiling on [[Win32CompileCygwin|Cygwin]] may be broken from time to time as Cygwin packages change.&lt;br /&gt;
We recommend [[Win32Compile|cross-compiling from Linux to Windows]] instead. &#039;&#039;&#039;Consider yourself warned.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Debian/Ubuntu ===&lt;br /&gt;
Debian users who want to compile VLC should install the packages below:&lt;br /&gt;
*[http://packages.debian.org/unstable/libdevel/libavcodec-dev libavcodec-dev] &lt;br /&gt;
*[http://packages.debian.org/unstable/libdevel/libpostproc-dev libpostproc-dev] &lt;br /&gt;
*[http://packages.debian.org/unstable/libdevel/libmpeg2-4-dev libmpeg2-4-dev]&lt;br /&gt;
&lt;br /&gt;
If you just want to &#039;&#039;use&#039;&#039; VLC media player then simply install the package vlc (&amp;lt;tt&amp;gt;sudo apt-get install vlc&amp;lt;/tt&amp;gt;) - the unstable version is fairly up-to-date most of the time, while the stable is, err, stable and very old&amp;amp;nbsp;;-)&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting / common problems ==&lt;br /&gt;
&lt;br /&gt;
=== Lua ===&lt;br /&gt;
You may need to install Lua if you get &amp;quot;LUA byte compiler missing.&amp;quot; message. You namely need to install &amp;quot;luac&amp;quot;, the Lua byte compiler.&lt;br /&gt;
&lt;br /&gt;
On Debian/Ubuntu:&lt;br /&gt;
 % sudo apt-get install lua5.1&lt;br /&gt;
&lt;br /&gt;
On Fedora:&lt;br /&gt;
 % sudo yum install lua&lt;br /&gt;
&lt;br /&gt;
=== XCB ===&lt;br /&gt;
&lt;br /&gt;
VLC 1.1 and later requires XCB libraries to deal with X11 displays. Do not disable XCB or you will not get any video support!&lt;br /&gt;
&lt;br /&gt;
To install these libraries run the following commands (Debian/Ubuntu):&lt;br /&gt;
 % sudo apt-get install libxcb-shm0-dev libxcb-xv0-dev libxcb-keysyms1-dev libxcb-randr0-dev libxcb-composite0-dev&lt;br /&gt;
&lt;br /&gt;
Under Fedora:&lt;br /&gt;
 % sudo yum install libxcb-devel xcb-util-devel&lt;br /&gt;
&lt;br /&gt;
For OpenGL (Debian/Ubuntu only), you will additionally need XLib with XCB:&lt;br /&gt;
 % sudo apt-get install libx11-xcb-dev&lt;br /&gt;
&lt;br /&gt;
If your distribution provides a version of XLib without XCB, then this later package will not be available. So you will not be able to use OpenGL. Use XVideo instead.&lt;br /&gt;
&lt;br /&gt;
[[Category:Building]]&lt;/div&gt;</summary>
		<author><name>Technologicat</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=Deinterlacing&amp;diff=22030</id>
		<title>Deinterlacing</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=Deinterlacing&amp;diff=22030"/>
		<updated>2012-02-17T12:40:48Z</updated>

		<summary type="html">&lt;p&gt;Technologicat: /* VLC settings */ Updated the part about Automatic mode.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:VLC_-_Deinterlace_action_options.png|400px|thumb|right|deinterlace switch menu]]&lt;br /&gt;
&#039;&#039;&#039;Deinterlacing&#039;&#039;&#039; is the process of converting source material that contains alternating half-pictures to a computer screen that displays a full picture at a time.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Description ==&lt;br /&gt;
Traditional TVs do not display one picture-frame at a time.  Instead, they display alternately all the odd lines and all the even lines of the picture.  That way, they can get a fast display rate of 50 or 60 half-pictures per second, without the bandwidth requirements that full pictures have.&lt;br /&gt;
&lt;br /&gt;
Computers however, do display full pictures, typically at a rate of at least 60 pictures per second.  So to get optimum quality when displaying TV-material (such as DVDs) on a computer, the player can convert the alternating half-pictures to full pictures.  That is called &#039;&#039;deinterlacing&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Modern HDTVs operate much like computers in that they display full pictures. Much like computer-based video players, they have deinterlacing built in so that they can display traditional TV material.&lt;br /&gt;
&lt;br /&gt;
A very good description of the problem and the various ways of deinterlacing can be found at [http://www.100fps.com/ 100fps.com].&lt;br /&gt;
&lt;br /&gt;
== VLC settings ==&lt;br /&gt;
{{VLC}} has deinterlacing off by default. &lt;br /&gt;
&lt;br /&gt;
You can enable it for the currently playing video by using the main menus, the right-click menus or by using [[hotkey] (by default: &#039;&#039;&#039;D&#039;&#039;&#039;). It switches deinterlacing on and off (using the mode selected in the Preferences).&lt;br /&gt;
&lt;br /&gt;
To change the settings, go to the Video section in the Simple Preferences. You can choose from On, Automatic or Off. This setting controls whether VLC enables deinterlacing when you open a video. You can also choose the mode (algorithm). See below for available modes and mode recommendations.&lt;br /&gt;
&lt;br /&gt;
In the mode &#039;&#039;Automatic&#039;&#039;, VLC will check the stream flags (technical term for information embedded in the video) and automatically set deinterlacing on or off, depending on if the current video is marked as interlaced. However, the detection is not always reliable. If the setting is &#039;&#039;On&#039;&#039;, VLC will apply deinterlacing even if the original is not interlaced (which is a really bad idea). The setting &#039;&#039;Off&#039;&#039;, respectively, always keeps deinterlacing off.&lt;br /&gt;
&lt;br /&gt;
The most reliable choice is to switch deinterlacing on/off manually when needed.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;For advanced users&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In All Preferences, the settings for deinterlacing can be found in Preferences &amp;gt; Video &amp;gt; Filters &amp;gt; Deinterlace. The available settings are the mode (algorithm), and in v1.2.0+ also some algorithm-specific settings.&lt;br /&gt;
&lt;br /&gt;
Note that if you enable deinterlacing from the menu, the setting will only take effect for the currently playing video. When the video ends, both the on/off/automatic and the mode settings will return to the values set in the preferences. If you want to always enable deinterlacing on every video, type &amp;quot;Deinterlace&amp;quot; in the Video Filter preferences.&lt;br /&gt;
&lt;br /&gt;
The [[Hotkeys|keyboard shortcut]] to switch deinterlacing on and off can be configured in the [[Hotkeys]] section of the Simple Preferences. Its name is &#039;&#039;Cycle deinterlace modes&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
If you use VLC from the command line, you can also set the deinterlace options in your command. To get a list and short description of the available options, run &amp;lt;pre&amp;gt;vlc -p deinterlace --advanced&amp;lt;/pre&amp;gt; Note that the deinterlace command-line options are prefixed by &amp;quot;sout&amp;quot; for historical reasons only; they are intended for normal playback use. For more information on using VLC from the command line, see [[VLC_command-line_help|VLC command-line help]].&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Technical detail about Automatic mode&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The version control history (git log) says the following about the &#039;&#039;Automatic&#039;&#039; mode (see commit [f96b075043c421fb6466829a15ae0c8792b8ffe8]):&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;The detection is based on the progressive/interlaced flags transported at the codec level. As such, it is not really reliable (for 25fps at least).&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;As soon as a picture is detected as interlaced, the configured deinterlace mode is applied. After 30s of progressive video, the filter is removed. The hysteresis helps with unreliable interlaced flags.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Interlaced or telecined? ==&lt;br /&gt;
In addition to true interlaced signals, there exists also a process called telecine which produces interlacing. It is a type of artificial interlacing that may be added to sources that were originally progressive. Telecine produces a characteristic look, with a repeating sequence of 3 progressive frames followed by 2 artificially interlaced frames.&lt;br /&gt;
&lt;br /&gt;
Why would anyone want to do that? The answer lies in different framerates, and in transfer of film sources to television and video. Film is commonly shot at 24 pictures per second, while NTSC television and video equipment operates at 60 half-pictures per second. Telecine inserts extra half-pictures so that films can be stored in the NTSC format (for example on DVDs in Japan and USA).&lt;br /&gt;
&lt;br /&gt;
For more on telecine, see for example the following links:&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Telecine Telecine (in Wikipedia)]&lt;br /&gt;
*[http://arbor.ee.ntu.edu.tw/~jackeikuo/dvd2avi/ivtc/ Inverse Telecine]&lt;br /&gt;
*[http://neuron2.net/LVG/telecining1.html NTSC Telecine - Luke&#039;s Video Guide]&lt;br /&gt;
*[http://users.softlab.ece.ntua.gr/~ttsiod/ivtc.html NTSC, telecine, and how to cope (using telecide and decimate)]&lt;br /&gt;
&lt;br /&gt;
== Which type of interlacing do I have? ==&lt;br /&gt;
This depends on the format (PAL, NTSC) and the content of the source. PAL is used in Europe and Australia, NTSC in USA and Japan. This also applies to the DVDs produced in those regions.&lt;br /&gt;
&lt;br /&gt;
Live-action movies in the PAL format typically are not interlaced at all. This is because it is easier to transfer film to PAL than to NTSC.&lt;br /&gt;
&lt;br /&gt;
Home movies shot on a camcorder are typically true interlaced.&lt;br /&gt;
&lt;br /&gt;
Telecine is very common in Asia and especially in Japan. Anything originating in Asia is likely to be telecined. For example, with very few exceptions, all anime in the NTSC format is telecined. This includes the corresponding North American releases.&lt;br /&gt;
&lt;br /&gt;
Source material that was converted from a different format is a special case. Producing a correct transfer for pure video material from NTSC to PAL or vice versa is very difficult due to the differences in framerate and number of lines. Whether a deinterlacer is needed depends on the details of the transfer. In the particular case of anime, a PAL conversion usually spells disaster for deinterlacing; see [http://www.animemusicvideos.org/guides/avtech/videogetb2a.html].&lt;br /&gt;
&lt;br /&gt;
== Algorithm types ==&lt;br /&gt;
&lt;br /&gt;
{{Module|name=deinterlace|type=Video Filter|description=Removes interlacing from display}}&lt;br /&gt;
&lt;br /&gt;
In {{VLC}}, there are several deinterlacing algorithms to choose from. This section presents a general classification. Skip ahead for an individual description of each mode.&lt;br /&gt;
&lt;br /&gt;
Algorithms available from a specific VLC version onward are marked with Name(vx.y.z+).&lt;br /&gt;
&lt;br /&gt;
=== Doublers ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;VLC modes&#039;&#039;&#039;: Bob, Linear, Yadif (2x) (v1.1.0+), Phosphor(v1.2.0+)&lt;br /&gt;
&lt;br /&gt;
These algorithms display the video at the original half-picture rate, which is typically 50 (PAL) or 60 (NTSC) half-pictures per second. This is double the full picture rate, hence the name. This approach to deinterlacing is also known as field rendering.&lt;br /&gt;
&lt;br /&gt;
This group takes into account that the half-pictures of a true interlaced video were intended to be displayed at different times. This can make the motion look very smooth.&lt;br /&gt;
&lt;br /&gt;
Simple doublers (Bob and Linear) display only one half-picture at a time. Nevertheless, the quick alternating display produces a convincing illusion of full vertical resolution while playback is running.&lt;br /&gt;
&lt;br /&gt;
Some more advanced doublers (such as Yadif (2x)) are based on interpolators (see below), and attempt to generate full pictures to display. When interpolators are used in this way, which field is kept, alternates just like in the simple doublers.&lt;br /&gt;
&lt;br /&gt;
The last doubler (Phosphor) does not fit into either of these categories, but attempts to simulate a traditional CRT TV.&lt;br /&gt;
&lt;br /&gt;
All doublers can be used with both true interlaced and telecined video.&lt;br /&gt;
&lt;br /&gt;
=== Interpolators ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;VLC modes&#039;&#039;&#039;: X, Yadif(v1.1.0+), (Discard)&lt;br /&gt;
&lt;br /&gt;
These algorithms analyze the picture, detecting progressive and interlaced parts. Typically the progressive parts of the picture are passed through unchanged, although in some algorithms various kinds of filtering may be used.&lt;br /&gt;
&lt;br /&gt;
For the interlaced parts, one half-picture is kept, while the other is generated out of thin air with various mathematical methods, based on the information in one or both of the original half-pictures.&lt;br /&gt;
&lt;br /&gt;
The Discard algorithm is a degenerate case of this type, which does not analyze the picture. It simply keeps one half-picture and discards the other one.&lt;br /&gt;
&lt;br /&gt;
The output runs at the full-picture rate, which is typically 25 (PAL) or 30 (NTSC) pictures per second. The different intended display times for the half-pictures in a true interlaced video are ignored.&lt;br /&gt;
&lt;br /&gt;
Interpolators are designed for use with true interlaced video only. They will stutter if applied to telecined video.&lt;br /&gt;
&lt;br /&gt;
Some doublers exist, such as Yadif (2x), which are based on interpolators. These hybrid algorithms behave like doublers (see above). They may be able to improve the picture quality compared to simple doublers, at the cost of more CPU cycles (requiring a faster processor).&lt;br /&gt;
&lt;br /&gt;
=== Blenders ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;VLC modes&#039;&#039;&#039;: Mean, Blend&lt;br /&gt;
&lt;br /&gt;
These algorithms mix information from both half-pictures to produce a blended (mixed) full picture. This is simple and removes interlacing, but causes ghostlike trails for fast motion.&lt;br /&gt;
&lt;br /&gt;
The output runs at the full-picture rate, which is typically 25 (PAL) or 30 (NTSC) pictures per second. The different intended display times for the half-pictures in a true interlaced video are ignored.&lt;br /&gt;
&lt;br /&gt;
Blenders are designed for use with true interlaced video only, and will stutter with telecined video.&lt;br /&gt;
&lt;br /&gt;
=== Inverse telecine ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;VLC modes&#039;&#039;&#039;: IVTC(v1.2.0+)&lt;br /&gt;
&lt;br /&gt;
This group of algorithms is specifically designed for removing telecine from NTSC telecined video. Inverse telecine is also known as &#039;&#039;IVTC&#039;&#039;, &#039;&#039;film mode&#039;&#039; and &#039;&#039;3:2 reverse pulldown&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Inverse telecine algorithms try to extract the original progressive film frames and to display them at the original framerate (24 pictures per second). In the ideal case, this perfectly restores the progressive signal. There is no loss of information and no need to generate anything out of thin air.&lt;br /&gt;
&lt;br /&gt;
Due to practical reasons, these algorithms are always based on analyzing the picture. They are not and cannot be perfectly accurate, but in practice they work well for most telecined sources.&lt;br /&gt;
&lt;br /&gt;
== VLC deinterlace modes ==&lt;br /&gt;
[[File:VLC_-_Deinterlace_Mode.png|250px|thumb|right|The deinterlace options selection]]&lt;br /&gt;
VLC has the following deinterlace modes.  Refer to 100fps.com for illustrations.  VLC does not have anything like what 100fps.com calls Motion blur, Hybrid, and Motion compensation.&lt;br /&gt;
&lt;br /&gt;
=== Disabled ===&lt;br /&gt;
This is what 100fps.com calls &amp;quot;do nothing&amp;quot;. Other names: &amp;quot;weave&amp;quot; or &amp;quot;no deinterlacing&amp;quot;. Should be used for PsF ([http://en.wikipedia.org/wiki/Progressive_segmented_Frame]) content.&lt;br /&gt;
&lt;br /&gt;
=== Blend ===&lt;br /&gt;
Blender (full resolution). Each line of the picture is created as the average of a line from the odd and a line from the even half-pictures.  This ignores the fact that they are supposed to be displayed at different times.&lt;br /&gt;
&lt;br /&gt;
=== Bob ===&lt;br /&gt;
Doubler. Display each half-picture like a full picture, by simply displaying each line twice. Preserves temporal resolution of interlaced video.&lt;br /&gt;
&lt;br /&gt;
=== Discard ===&lt;br /&gt;
Only display one of the half-pictures, discard the other. Other name: &amp;quot;single field&amp;quot;. Both temporal and vertical spatial resolutions are halved. Can be used for slower computers or to give interlaced video movie-like look with characteristic judder.&lt;br /&gt;
&lt;br /&gt;
=== Linear ===&lt;br /&gt;
Doubler. Bob with linear interpolation: instead of displaying each line twice, line 2 is created as the average of line 1 and 3, etc.&lt;br /&gt;
&lt;br /&gt;
=== Mean ===&lt;br /&gt;
Blender (half resolution). Display a half-picture that is created as the average of the two original half-pictures.&lt;br /&gt;
&lt;br /&gt;
=== X ===&lt;br /&gt;
Interpolator. Generates a full picture taking the odd lines from the odd half-picture, and creating the even lines through a complicated algorithm (involving ME, MC, edge-oriented interpolation) that uses information from both half-pictures.&lt;br /&gt;
&lt;br /&gt;
This is similar to what 100fps.com calls Area based.&lt;br /&gt;
&lt;br /&gt;
=== Yadif (v1.1.0+)===&lt;br /&gt;
Interpolator. The &#039;&#039;Yet Another DeInterlacing Filter&#039;&#039; from the MPlayer project. Generates a full picture taking the odd lines from the odd half-picture, and creating the even lines through a complicated algorithm that includes both temporal and spatial interpolation.&lt;br /&gt;
&lt;br /&gt;
=== Yadif (2x) (v1.1.0+)===&lt;br /&gt;
Doubler. Bob with Yadif interpolation. &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&#039;&#039;&#039;Caution&#039;&#039;&#039;: Very heavy on the CPU.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Phosphor (v1.2.0+) ===&lt;br /&gt;
Doubler. This filter attempts to simulate the rendering mechanism of a traditional CRT TV. The latest two half-pictures are displayed, the old one fading out. The strength of the fade effect can be configured in All Preferences, see Video &amp;gt; Filters &amp;gt; Deinterlace.&lt;br /&gt;
&lt;br /&gt;
=== IVTC (v1.2.0+) ===&lt;br /&gt;
Inverse telecine. Removes telecine from NTSC telecined video in realtime, losslessly recovering the progressive signal. &#039;&#039;&#039;Note&#039;&#039;&#039;: Only applicable to telecined sources. Particularly useful for NTSC anime DVDs.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
File:Example- Disabled Deinterlace.png|Interlaced&lt;br /&gt;
File:Example- Discard interpolate.png|Discard&lt;br /&gt;
File:Example- Blend Deinterlace.png|Blend&lt;br /&gt;
File:Example- Mean Blender.png|Mean&lt;br /&gt;
File:Example- Bob Doubler.png|Bob&lt;br /&gt;
File:Example- Linear Doubler.png|Linear&lt;br /&gt;
File:Example-X interpolate.png|X&lt;br /&gt;
File:Example-Yadif 1.png|Yadif&lt;br /&gt;
File:Example-Yadif 2.png|Yadif (2x)&lt;br /&gt;
File:Example-Phospor Doubler.png|Phosphor&lt;br /&gt;
File:Example-Invert Telecine.png|IVTC&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Recommendation ==&lt;br /&gt;
For telecined sources, use &#039;&#039;&#039;IVTC&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
For true interlaced sources, use a doubler. Which one is a matter of taste. Try &#039;&#039;&#039;Linear&#039;&#039;&#039; first; it is pretty good while simple and light on the CPU.&lt;br /&gt;
&lt;br /&gt;
The classic &#039;&#039;&#039;Bob&#039;&#039;&#039; gives the lowest CPU load and is very simple.&lt;br /&gt;
&lt;br /&gt;
You can use &#039;&#039;&#039;Yadif (2x)&#039;&#039;&#039; if you have a very fast CPU or fastest graphics cards such as NVIDIA Geforce, AMD Radeon or other best graphics cards.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Phosphor&#039;&#039;&#039; (v1.2.0+) mode is different, and may be worth a try if you want a &amp;quot;TV look&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Disclaimer ==&lt;br /&gt;
Please update this page if it contains any errors, is incomplete, or when it goes out of date.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Appendix: Technical summary ==&lt;br /&gt;
&lt;br /&gt;
This table summarizes various technical information on the algorithms. Don&#039;t be afraid to dive in - it&#039;s intended for users.&lt;br /&gt;
&lt;br /&gt;
If you are a developer looking for more detailed technical understanding, this module also has a section in the [[Documentation:Hacker&#039;s Guide/Video Filters/Deinterlace|Hacker&#039;s Guide]].&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Terminology&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;field&amp;quot; = half-picture&lt;br /&gt;
* &amp;quot;top field&amp;quot; = &amp;quot;odd lines&amp;quot; in other sections above (note that the numbering started from 1)&lt;br /&gt;
* &amp;quot;bottom field&amp;quot; = &amp;quot;even lines&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Legend&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Column 4:2:0 in the table = &amp;quot;if input has 4:2:0 chroma, then...&amp;quot; See [http://en.wikipedia.org/wiki/Chroma_subsampling#Sampling_systems_and_ratios] for an explanation and pictures. This format is common on DVDs.&lt;br /&gt;
* Column 4:2:2 in the table = &amp;quot;if input has 4:2:2 chroma, then...&amp;quot;&lt;br /&gt;
* C, H, FR = output Chroma, Height, Framerate&lt;br /&gt;
* 0 = output has 4:2:0 chroma&lt;br /&gt;
* 2 = output has 4:2:2 chroma&lt;br /&gt;
* h = half height; output has as many lines as an input half-picture&lt;br /&gt;
* f = full height; output has as many lines as an input full picture&lt;br /&gt;
* 1x = output has original framerate (original full-picture rate; typically 25 (PAL) or 30 (NTSC) times per second)&lt;br /&gt;
* 2x = output has double framerate (original half-picture rate; typically 50 (PAL) or 60 (NTSC) times per second)&lt;br /&gt;
* &#039;&#039;&#039;n)&#039;&#039;&#039; = numbered note, read below for details&lt;br /&gt;
&lt;br /&gt;
Note that the picture will be scaled before being displayed, so the number of lines just tells us how detailed the picture could potentially be.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| align=&amp;quot;left &amp;quot;valign=&amp;quot;center&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Algo&lt;br /&gt;
! 4:2:0&lt;br /&gt;
! 4:2:2&lt;br /&gt;
! Algo type&lt;br /&gt;
! Interpolation (if applic.)&lt;br /&gt;
! Notes&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| C, H, FR&lt;br /&gt;
| C, H, FR&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| Discard&lt;br /&gt;
| 0, h, 1x&lt;br /&gt;
| 0, f, 1x&lt;br /&gt;
| interpolator&lt;br /&gt;
| none&lt;br /&gt;
| keeps only top field; each line is repeated&lt;br /&gt;
|-&lt;br /&gt;
| Mean&lt;br /&gt;
| 0, h, 1x&lt;br /&gt;
| 2, h, 1x&lt;br /&gt;
| blender&lt;br /&gt;
| &lt;br /&gt;
| half-resolution blender; &#039;&#039;&#039;1)&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| Blend&lt;br /&gt;
| 0, f, 1x&lt;br /&gt;
| 0, f, 1x&lt;br /&gt;
| blender&lt;br /&gt;
| &lt;br /&gt;
| full-resolution blender; &#039;&#039;&#039;2)&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| Bob&lt;br /&gt;
| 0, f, 2x&lt;br /&gt;
| 0, f, 2x&lt;br /&gt;
| doubler&lt;br /&gt;
| none&lt;br /&gt;
| each line is repeated; &#039;&#039;&#039;3)&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| Linear&lt;br /&gt;
| 0, f, 2x&lt;br /&gt;
| 2, f, 2x&lt;br /&gt;
| doubler&lt;br /&gt;
| simple linear&lt;br /&gt;
| first/last line copied; others interpolated; &#039;&#039;&#039;3)&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| X&lt;br /&gt;
| 0, f, 1x&lt;br /&gt;
| 2, f, 1x&lt;br /&gt;
| interpolator&lt;br /&gt;
| MC + edge-oriented&lt;br /&gt;
| keeps only top field in interlaced parts; &#039;&#039;&#039;4)&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| Yadif&lt;br /&gt;
| 0, f, 1x&lt;br /&gt;
| 2, f, 1x&lt;br /&gt;
| interpolator&lt;br /&gt;
| spatial/temporal&lt;br /&gt;
| keeps only top field in interlaced parts&lt;br /&gt;
|-&lt;br /&gt;
| Yadif (2x)&lt;br /&gt;
| 0, f, 2x&lt;br /&gt;
| 2, f, 2x&lt;br /&gt;
| doubler&lt;br /&gt;
| spatial/temporal&lt;br /&gt;
| Yadif and Yadif (2x) come from MPlayer&lt;br /&gt;
|-&lt;br /&gt;
| Phosphor&lt;br /&gt;
| &#039;&#039;&#039;5)&#039;&#039;&#039;, f, 2x&lt;br /&gt;
| 2, f, 2x&lt;br /&gt;
| doubler&lt;br /&gt;
| &lt;br /&gt;
| CRT TV simulator; &#039;&#039;&#039;6)&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| IVTC&lt;br /&gt;
| 0, f, &#039;&#039;&#039;7)&#039;&#039;&#039;&lt;br /&gt;
| 2, f, &#039;&#039;&#039;7)&#039;&#039;&#039;&lt;br /&gt;
| inverse telecine&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The luma (Y) component scale I (&amp;quot;analog&amp;quot;, 16..240) vs. J (full scale, &amp;quot;digital&amp;quot;, 0..255) is preserved in all format conversions.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Notes&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;1)&#039;&#039;&#039; The Mean algorithm simply pairs the original lines, and averages each pair into one output line. Line 1 of output is the mean of lines 1 and 2 in input, line 2 of output is the mean of lines 3 and 4 in input, and so on.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;2)&#039;&#039;&#039; Blend is slightly more sophisticated than Mean. The first line of output is copied from the first line of input. For any other output line N, the line is the mean of input lines N and N-1. That is, the second line of output is the mean of lines 1 and 2 in input, the third line is the mean of lines 2 and 3, ... and finally, the last line of output is the mean of the last two lines in input. The sliding averaging procedure preserves the original vertical resolution.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;3)&#039;&#039;&#039; Bob converts the half-pictures to full-pictures by simply showing each line twice; so while the full number of lines are displayed, the true resolution is only half.  The same goes for Linear, though it&#039;s a bit smarter about the process.&lt;br /&gt;
&lt;br /&gt;
Still, even the basic Bob is slightly more clever than just a 2x version of Discard. In the output, the bottom field is offset by one line with respect to the top field. This is the technical reason behind the perceived full resolution magic. (As a side effect, it also causes perfectly horizontal lines to flicker in a way characteristic to the Bob algorithm. The other doublers try to overcome this.)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;4)&#039;&#039;&#039; The X algorithm divides the video into blocks of 8x8 pixels, and analyzes them. It blurs the progressive blocks lightly. In the interlaced blocks, it keeps only the top field, and uses MC and edge-oriented interpolation to create the bottom field.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;5)&#039;&#039;&#039; Output from Phosphor is 4:2:2 if the Upconvert mode is chosen in the settings, otherwise 4:2:0 is used.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;6)&#039;&#039;&#039; Phosphor displays the latest two fields, regardless of temporal frame boundaries. To simulate phosphor light output decay, the old field is darkened by an amount that can be configured in All settings &amp;gt; Video &amp;gt; Filters &amp;gt; Deinterlace.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;7)&#039;&#039;&#039; IVTC outputs at (4/5)x of original framerate, when inverting telecine on a locked-on cadence, and at 1x while trying to acquire lock-on.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Video Filters]]&lt;br /&gt;
{{Documentation}}&lt;/div&gt;</summary>
		<author><name>Technologicat</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=UnixCompile&amp;diff=21924</id>
		<title>UnixCompile</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=UnixCompile&amp;diff=21924"/>
		<updated>2012-02-14T09:56:08Z</updated>

		<summary type="html">&lt;p&gt;Technologicat: /* The method for badly-behaved distributions */ Reverted my earlier edits to this section. Compiling just select libraries may introduce problems, as pointed out by Rémi on vlc-devel.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Prepare your environment  ==&lt;br /&gt;
&lt;br /&gt;
VLC requires a C compiler, development headers and a toolchain. gcc will do but you could also use LLVM or proprietary C99/C++ compilers such as Intel&#039;s.&lt;br /&gt;
&lt;br /&gt;
If you build from the [[Git]] repositories, you will also need the GNU build system, a.k.a. the &amp;quot;autotools&amp;quot; (autoconf, automake, libtool and gettext) to setup the Makefiles. Make sure they are up-to-date and usable for your system.&lt;br /&gt;
&lt;br /&gt;
On Fedora:&lt;br /&gt;
&lt;br /&gt;
 % sudo yum install git libtool&lt;br /&gt;
&lt;br /&gt;
== Get the source  ==&lt;br /&gt;
Start by [[GetTheSource|getting the source]], using FTP for official releases, or using [[Git]] to track VLC development. &lt;br /&gt;
&lt;br /&gt;
If your are using an official release, download source code, extract the archive and go into the resulting VLC directory, e.g.:&lt;br /&gt;
 % wget ftp://ftp.videolan.org/pub/videolan/vlc/1.1.11/vlc-1.1.11.tar.bz2&lt;br /&gt;
 % tar xvjf vlc-1.1.11.tar.bz2&lt;br /&gt;
 % cd vlc-1.1.11&lt;br /&gt;
&lt;br /&gt;
If you are using the [[Git]] development version, start by bootstrapping the source tree:&lt;br /&gt;
 % cd vlc&lt;br /&gt;
 % ./bootstrap&lt;br /&gt;
Bootstrapping will fail if the autotools are missing or out-of-date.&lt;br /&gt;
&lt;br /&gt;
== Get the third-party libraries  ==&lt;br /&gt;
Now you could configure the VLC build. But first, you need to make sure that all the required dependencies are in place. Take a look at &amp;lt;tt&amp;gt;./configure --help&amp;lt;/tt&amp;gt;. Take a good look at that enormous list of options.&lt;br /&gt;
&lt;br /&gt;
It is very important that you do install and enable all the 3rd party libraries that you need. Yes, there is going to be a lot of them if you want a complete or even mostly functional VLC build. If you fail to install a required library, you will end up with a VLC application that well..... essentially does not do anything useful. See [[Contrib Status|here]] for a complete list.&lt;br /&gt;
 &lt;br /&gt;
There are some very important dependencies: gettext (NLS) for international support (required), libdvbpsi for MPEG-TS files and streams support, libmad for MP3 audio decoding, libmpeg2 for MPEG1 and MPEG2 video support, FFmpeg or libav (libavcodec, libavformat, libpostproc, libswscale and optionally libavio) for MPEG4 and most other audio and video codecs, and many file formats, liba52 for Dolby (AC3) sound, dvdread and dvdnav for DVD playback, live555 for RTSP stream playback, etc.&lt;br /&gt;
&lt;br /&gt;
For audio output, you will need probably alsa-lib (on [[Linux]]) and/or libpulse (for [[PulseAudio]]).&lt;br /&gt;
For video output, you will normally need XCB/XVideo and/or OpenGL/GLX.&lt;br /&gt;
And Qt4 is required to get the GUI support.&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039; that you need to install the development packages (development header files and import libraries) to compile VLC, not just the run-time. On Debian/Ubuntu, the correct package names end with -dev. On RPM distributions, they usually end in -devel.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Be careful!&#039;&#039;&#039; If the libraries are not provided by your distribution, you may be better off linking VLC with them statically. Otherwise, you may encounter version problems if another multimedia application updates the libraries later. This is especially true of FFmpeg or libav, and live555.&lt;br /&gt;
&lt;br /&gt;
There are a several ways to get those libraries. You should use only one method at a time: &lt;br /&gt;
 &lt;br /&gt;
=== The preferred method ===&lt;br /&gt;
Use your distribution packaging or portage system, in order to get all the needed libs.&lt;br /&gt;
For example on Debian or Ubuntu: &lt;br /&gt;
 # apt-get build-dep vlc&lt;br /&gt;
&lt;br /&gt;
openSUSE users might have a look at the source-install (si) command in the zypper manpage:&lt;br /&gt;
 # zypper si -d vlc&lt;br /&gt;
&lt;br /&gt;
=== The method for badly-behaved distributions ===&lt;br /&gt;
If your distribution does not provide the needed libraries,&lt;br /&gt;
or you really want to link VLC statically, use the VLC contribs system. It is included in the VLC source.&lt;br /&gt;
&lt;br /&gt;
First, you need to install the GNU autotools (if you have not already done so), CMake, subversion, Git and a recent GNU/tar utility or equivalent. Then you can run:&lt;br /&gt;
 % cd contrib&lt;br /&gt;
 % mkdir native&lt;br /&gt;
 % cd native&lt;br /&gt;
 % ../bootstrap&lt;br /&gt;
 % make&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039; the commands above are for VLC 1.2 or later. Details differ slightly for older versions:&lt;br /&gt;
 % cd extras/contrib&lt;br /&gt;
 % ./bootstrap&lt;br /&gt;
 % make&lt;br /&gt;
&lt;br /&gt;
That should download and build a lot of those libraries for you.  Unfortunately, given the large number of libraries and the variety of the platforms people build VLC for, it is not unlikely that you will hit an error while contribs are compiling. Thus, this approach is only recommended for experienced Unix compilers.&lt;br /&gt;
&lt;br /&gt;
=== The method for people with too much time to waste ===&lt;br /&gt;
Read the [[Contrib Status|list]], download them and build them by hand.&lt;br /&gt;
&lt;br /&gt;
=== Regardless of the method ===&lt;br /&gt;
In any case, some basic OS support libraries are not included and must really be installed through the packaging system in any case, notably [[ALSA]], [[PulseAudio]] and [[OpenGL]].&lt;br /&gt;
&lt;br /&gt;
== Configuration  ==&lt;br /&gt;
You probably need to tweak the &amp;quot;configure&amp;quot; line. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;./configure&amp;lt;/tt&amp;gt; is used to check whether your system is able to compile VLC. Also you can choose the features in your build. As a reminder, this command will show the various options:&lt;br /&gt;
 % ./configure --help&lt;br /&gt;
 &lt;br /&gt;
=== Special libs  ===&lt;br /&gt;
Use &amp;lt;tt&amp;gt;--with-live555-path=path/to/livemedia/source/tree&amp;lt;/tt&amp;gt; in connection with &amp;lt;tt&amp;gt;--enable-live555&amp;lt;/tt&amp;gt;. For FFmpeg or libav, pkg-config is the only reliable way for VLC&#039;s configure to find the libraries. So you need to set PKG_CONFIG_PATH correctly if your FFmpeg/libav libraries are not installed at the default prefix (meaning /usr) or you want to use static linking.&lt;br /&gt;
&lt;br /&gt;
=== Final configuration  ===&lt;br /&gt;
If you want to install VLC into another directory, run &lt;br /&gt;
 &lt;br /&gt;
 % ./configure --prefix=/path/to/install/folder/&lt;br /&gt;
&lt;br /&gt;
This is an example of a typical VLC configure line: &lt;br /&gt;
 &lt;br /&gt;
 % ./configure --enable-x11 --enable-xvideo --enable-sdl --enable-avcodec --enable-avformat \&lt;br /&gt;
  --enable-swscale --enable-mad --enable-libdvbpsi --enable-a52 --enable-libmpeg2 --enable-dvdnav \&lt;br /&gt;
  --enable-faad --enable-vorbis --enable-ogg --enable-theora --enable-faac --enable-mkv --enable-freetype \&lt;br /&gt;
  --enable-fribidi --enable-speex --enable-flac --enable-live555 --with-live555-tree=/usr/lib/live \&lt;br /&gt;
  --enable-caca --enable-skins --enable-skins2 --enable-alsa --enable-qt4 --enable-ncurses&lt;br /&gt;
 &lt;br /&gt;
[[User:J-b#VLC_configure_line|Here]] is another. &lt;br /&gt;
&lt;br /&gt;
=== Ubuntu ===&lt;br /&gt;
&lt;br /&gt;
If you get continuous errors while ./configure then consider reinstalling the corresponding libraries. This will set the paths and other information correctly. Check the $PKG_CONFIG_PATH(environment variable) whether it is set to a path where the libraries like libavcodec.pc are available. Otherwise create the environment variable, export it and then update the ldconfig.&lt;br /&gt;
&lt;br /&gt;
== Compilation ==&lt;br /&gt;
Compile VLC: &lt;br /&gt;
 % make&lt;br /&gt;
&lt;br /&gt;
You do not need to install VLC to use it. You can also simply run it from the build directory:&lt;br /&gt;
 # ./vlc&lt;br /&gt;
&lt;br /&gt;
If you really want to install VLC to the system, run this as root:&lt;br /&gt;
 # make install&lt;br /&gt;
&lt;br /&gt;
You can uninstall later with this, but you need to keep the build tree untouched until then:&lt;br /&gt;
 # make uninstall&lt;br /&gt;
&lt;br /&gt;
To remove files created during the compile (optional) type:&lt;br /&gt;
 % make clean&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
&lt;br /&gt;
=== Cygwin ===&lt;br /&gt;
&lt;br /&gt;
Compiling on [[Win32CompileCygwin|Cygwin]] may be broken from time to time as Cygwin packages change.&lt;br /&gt;
We recommend [[Win32Compile|cross-compiling from Linux to Windows]] instead. &#039;&#039;&#039;Consider yourself warned.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Debian/Ubuntu ===&lt;br /&gt;
Debian users who want to compile VLC should install the packages below:&lt;br /&gt;
*[http://packages.debian.org/unstable/libdevel/libavcodec-dev libavcodec-dev] &lt;br /&gt;
*[http://packages.debian.org/unstable/libdevel/libpostproc-dev libpostproc-dev] &lt;br /&gt;
*[http://packages.debian.org/unstable/libdevel/libmpeg2-4-dev libmpeg2-4-dev]&lt;br /&gt;
&lt;br /&gt;
If you just want to &#039;&#039;use&#039;&#039; VLC media player then simply install the package vlc (&amp;lt;tt&amp;gt;sudo apt-get install vlc&amp;lt;/tt&amp;gt;) - the unstable version is fairly up-to-date most of the time, while the stable is, err, stable and very old&amp;amp;nbsp;;-)&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting / common problems ==&lt;br /&gt;
&lt;br /&gt;
=== Lua ===&lt;br /&gt;
You may need to install Lua if you get &amp;quot;LUA byte compiler missing.&amp;quot; message. You namely need to install &amp;quot;luac&amp;quot;, the Lua byte compiler.&lt;br /&gt;
&lt;br /&gt;
On Debian/Ubuntu:&lt;br /&gt;
 % sudo apt-get install lua5.1&lt;br /&gt;
&lt;br /&gt;
On Fedora:&lt;br /&gt;
 % sudo yum install lua&lt;br /&gt;
&lt;br /&gt;
=== XCB ===&lt;br /&gt;
&lt;br /&gt;
VLC 1.1 and later requires XCB libraries to deal with X11 displays. Do not disable XCB or you will not get any video support!&lt;br /&gt;
&lt;br /&gt;
To install these libraries run the following commands (Debian/Ubuntu):&lt;br /&gt;
 % sudo apt-get install libxcb-shm0-dev libxcb-xv0-dev libxcb-keysyms1-dev libxcb-randr0-dev libxcb-composite0-dev&lt;br /&gt;
&lt;br /&gt;
Under Fedora:&lt;br /&gt;
 % sudo yum install libxcb-devel xcb-util-devel&lt;br /&gt;
&lt;br /&gt;
For OpenGL (Debian/Ubuntu only), you will additionally need XLib with XCB:&lt;br /&gt;
 % sudo apt-get install libx11-xcb-dev&lt;br /&gt;
&lt;br /&gt;
If your distribution provides a version of XLib without XCB, then this later package will not be available. So you will not be able to use OpenGL. Use XVideo instead.&lt;br /&gt;
&lt;br /&gt;
[[Category:Building]]&lt;/div&gt;</summary>
		<author><name>Technologicat</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=Contrib_Status&amp;diff=21921</id>
		<title>Contrib Status</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=Contrib_Status&amp;diff=21921"/>
		<updated>2012-02-14T09:16:04Z</updated>

		<summary type="html">&lt;p&gt;Technologicat: Added note that the build instructions include contrib instructions, too.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page lists the libraries needed to have a fully featured {{VLC}}. &amp;lt;br&amp;gt; The additional information in the table refers to the VLC contrib build system (located in extras/contrib in VLC 1.1; in contrib in VLC 2.0+). These versions are against the trunk version. &lt;br /&gt;
&lt;br /&gt;
For information on how to compile {{VLC}} (including the contribs) on your platform see the [[Developers Corner|Build VLC media player]] box on the Developer Corner&#039;s page. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
=== Codecs  ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin: 1em auto; font-size: smaller; text-align: center; width: 100%;&amp;quot;&lt;br /&gt;
|+ &#039;&#039;&#039;Contrib Status&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
! Contrib lib &lt;br /&gt;
! VLC version &lt;br /&gt;
! Most recent version &lt;br /&gt;
! Compile &lt;br /&gt;
! Win32 &lt;br /&gt;
! MacOSX &lt;br /&gt;
! *Nix &lt;br /&gt;
! WinCE &lt;br /&gt;
! Where&amp;amp;nbsp;? &lt;br /&gt;
! License &lt;br /&gt;
! Comment&lt;br /&gt;
|-&lt;br /&gt;
! libvorbis &lt;br /&gt;
| 1.3.2 &lt;br /&gt;
| 1.3.2 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://www.xiph.org/downloads/ Xiph.org] &lt;br /&gt;
| BSD-like&amp;lt;br&amp;gt; &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! libogg &lt;br /&gt;
| 1.3.0 &lt;br /&gt;
| 1.3.0 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| [http://www.xiph.org/downloads/ Xiph.org] &lt;br /&gt;
| BSD-like&amp;lt;br&amp;gt; &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! libtheora &lt;br /&gt;
| &lt;br /&gt;
1.1.1 &lt;br /&gt;
&lt;br /&gt;
| 1.1.1 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://www.xiph.org/downloads/ Xiph.org] &lt;br /&gt;
| BSD-like&amp;lt;br&amp;gt; &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! speex &lt;br /&gt;
| 1.2rc1 &lt;br /&gt;
| 1.2rc1 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://www.xiph.org/downloads/ Xiph.org] &lt;br /&gt;
| BSD-like&amp;lt;br&amp;gt; &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! flac &lt;br /&gt;
| 1.2.1 &lt;br /&gt;
| 1.2.1 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://sourceforge.net/projects/flac/files/flac-src/ Flac] &lt;br /&gt;
| BSD-like&amp;lt;br&amp;gt; &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! x264 &lt;br /&gt;
| svn &lt;br /&gt;
| svn &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| SVN &lt;br /&gt;
| GPLv2+&amp;lt;br&amp;gt; &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! a52 &lt;br /&gt;
| 0.7.4 &lt;br /&gt;
| 0.7.4 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://liba52.sf.net liba52.sf] &lt;br /&gt;
| GPLv2+&amp;lt;br&amp;gt; &lt;br /&gt;
| Not likely to be updated&lt;br /&gt;
|-&lt;br /&gt;
! MPEG2DEC &lt;br /&gt;
| 0.5.1 &lt;br /&gt;
| 0.5.1 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| [http://libmpeg2.sf.net libmpeg2.sf] &lt;br /&gt;
| GPLv2+&amp;lt;br&amp;gt; &lt;br /&gt;
| Not likely to be updated&lt;br /&gt;
|-&lt;br /&gt;
! faad2 &lt;br /&gt;
| 2.7 &lt;br /&gt;
| 2.7 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://www.audiocoding.com/faad2.html audiocoding] &lt;br /&gt;
| GPLv2+&amp;lt;br&amp;gt; &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! faac &lt;br /&gt;
| 1.28 &lt;br /&gt;
| 1.28 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://www.audiocoding.com/faac.html audiocoding] &lt;br /&gt;
| LGPL for modifications&amp;lt;br&amp;gt; &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! lame &lt;br /&gt;
| 3.99.1 &lt;br /&gt;
| 3.99.1 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://sourceforge.net/project/showfiles.php?group_id=290&amp;amp;package_id=309 sf.net] &lt;br /&gt;
| LGPLv2+&amp;lt;br&amp;gt; &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! FFmpeg &lt;br /&gt;
| SVN &lt;br /&gt;
| SVN &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| SVN &lt;br /&gt;
| GPLv2/3/LGPL&amp;lt;br&amp;gt; &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! libmad &lt;br /&gt;
| 0.15.1b &lt;br /&gt;
| 0.15.1b &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://sourceforge.net/project/showfiles.php?group_id=12349&amp;amp;package_id=86999 SF] &lt;br /&gt;
| GPLv2+&amp;lt;br&amp;gt; &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! orc &lt;br /&gt;
| 0.4.16&lt;br /&gt;
| 0.4.16 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://code.entropywave.com/download/orc/ orc ] &lt;br /&gt;
| Two-Clause BSD &lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
! schroedinger &lt;br /&gt;
| 1.0.10 &lt;br /&gt;
| 1.0.10 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://www.diracvideo.org/download/schroedinger/ diracvideo.org] &lt;br /&gt;
| GPLv2/LGPL 2.1/MIT&amp;lt;br&amp;gt; &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! libdca &lt;br /&gt;
| SVN &lt;br /&gt;
| SVN &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| SVN &lt;br /&gt;
| GPLv2+&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
! twolame &lt;br /&gt;
| 0.3.13 &lt;br /&gt;
| 0.3.13 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://www.twolame.org/ twolame.org] &lt;br /&gt;
| LGPL 2.1+&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
! libmpcdec &lt;br /&gt;
| SVN &lt;br /&gt;
| SVN &lt;br /&gt;
| {{Up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://www.musepack.net/index.php?pg=src musepack] &lt;br /&gt;
| BSD&lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
! Tremor &lt;br /&gt;
| SVN &lt;br /&gt;
| SVN &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| SVN &lt;br /&gt;
| BSD-like &lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
! libass &lt;br /&gt;
| 0.10.0&lt;br /&gt;
| 0.10.0&lt;br /&gt;
| {{up-to-date}}&lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://code.google.com/p/libass/downloads/list Google Code]&amp;lt;br&amp;gt; &lt;br /&gt;
| Simplified 2-clause BSD license&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Demuxers and Muxers  ===&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;margin: 1em auto; font-size: smaller; text-align: center; width: 100%;&amp;quot; class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ &#039;&#039;&#039;Contrib Status&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
! Contrib lib &lt;br /&gt;
! VLC version &lt;br /&gt;
! Most recent version &lt;br /&gt;
! Compile &lt;br /&gt;
! Win32 &lt;br /&gt;
! MacOSX &lt;br /&gt;
! *Nix &lt;br /&gt;
! WinCE &lt;br /&gt;
! Where &lt;br /&gt;
! License&amp;lt;br&amp;gt; &lt;br /&gt;
! Comment&lt;br /&gt;
|-&lt;br /&gt;
! libebml &lt;br /&gt;
| 1.2.2&lt;br /&gt;
| 1.2.2 &lt;br /&gt;
| {{up-to-date}}&lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://www.matroska.org/downloads/linux.html matroska.org] &lt;br /&gt;
| LGPLv2.1+&amp;lt;br&amp;gt; &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! libmatroska &lt;br /&gt;
| 1.3.0 &lt;br /&gt;
| 1.3.0 &lt;br /&gt;
| {{up-to-date}}&lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://www.matroska.org/downloads/linux.html matroska.org] &lt;br /&gt;
| LGPLv2.1+&amp;lt;br&amp;gt; &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! libdvbpsi &lt;br /&gt;
| 0.2.2 &lt;br /&gt;
| 0.2.2 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| [http://www.videolan.org/developers/libdvbpsi.html libdvbpsi] &lt;br /&gt;
| LGPLv2.1+&lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
! libmodplug &lt;br /&gt;
| 0.8.8.4 &lt;br /&gt;
| 0.8.8.4 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://modplug-xmms.sourceforge.net/ modplug sur sf.net] &lt;br /&gt;
| Public domain&lt;br /&gt;
|-&lt;br /&gt;
! GME&lt;br /&gt;
| 0.5.5&lt;br /&gt;
| 0.5.5&lt;br /&gt;
| {{up-to-date}}&lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
| [http://code.google.com/p/game-music-emu/downloads/list GME on Google]&lt;br /&gt;
| LGPLv2.1+&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Access  ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin: 1em auto; font-size: smaller; text-align: center; width: 100%;&amp;quot;&lt;br /&gt;
|+ &#039;&#039;&#039;Contrib Status&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
! Contrib lib &lt;br /&gt;
! VLC version &lt;br /&gt;
! Most recent version &lt;br /&gt;
! Compile &lt;br /&gt;
! Win32 &lt;br /&gt;
! MacOSX &lt;br /&gt;
! *Nix &lt;br /&gt;
! WinCE &lt;br /&gt;
! Where&amp;amp;nbsp;? &lt;br /&gt;
! License &lt;br /&gt;
! Comment&lt;br /&gt;
|-&lt;br /&gt;
! shout &lt;br /&gt;
| 2.2.2 &lt;br /&gt;
| 2.2.2 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://www.icecast.org/download.php icecast.org] &lt;br /&gt;
| LGPLv2.1+ &lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
! libdvdcss &lt;br /&gt;
| 1.2.11 &lt;br /&gt;
| 1.2.11&lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://download.videolan.org/pub/libdvdcss/?C=N;O=D libdvdcss on v.o] &lt;br /&gt;
| GPLv2+ &lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
! libdvdread &lt;br /&gt;
| 4.2.0 &lt;br /&gt;
| 4.2.0 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://dvdnav.mplayerhq.hu/ dvd.sf.net] &lt;br /&gt;
| GPLv2+ &lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
! libdvdnav &lt;br /&gt;
| 4.2.0 &lt;br /&gt;
| 4.2.0 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://dvdnav.mplayerhq.hu/ dvd.sf.net] &lt;br /&gt;
| GPLv2+ &lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
! livedotcom &lt;br /&gt;
| latest trunk &lt;br /&gt;
| latest trunk &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| [http://www.live555.com/mediaServer/#downloading live555] &lt;br /&gt;
| LGPLv2.1+ &lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
! libcddb &lt;br /&gt;
| 1.3.2 &lt;br /&gt;
| 1.3.2 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://libcddb.sourceforge.net/download.html libcddb.sf.net] &lt;br /&gt;
| LGPLv2+ &lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
! libcdio &lt;br /&gt;
| 0.80 &lt;br /&gt;
| 0.82 &lt;br /&gt;
| {{Untested}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://ftp.gnu.org/gnu/libcdio/?M=D gnu.org] &lt;br /&gt;
| GPLv2+ &lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
! VCDimager &lt;br /&gt;
| 0.7.23 &lt;br /&gt;
| 0.7.23 &lt;br /&gt;
| {{Up-to-date}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://www.vcdimager.org/pub/vcdimager/vcdimager-0.7/ vcdimager] &lt;br /&gt;
| GPLv2+ &lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
! libgpg-error &lt;br /&gt;
| 1.10&lt;br /&gt;
| 1.10 &lt;br /&gt;
| {{Up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [ftp://ftp.gnupg.org/gcrypt/libgpg-error/ gnupg.org] &lt;br /&gt;
| LGPLv2.1+ &lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
! libgcrypt &lt;br /&gt;
| 1.5.0&lt;br /&gt;
| 1.5.0 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [ftp://ftp.gnupg.org/gcrypt/libgcrypt/ gnupg.org] &lt;br /&gt;
| LGPLv2.1+ &lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
! gnuTLS &lt;br /&gt;
| 2.12.7&lt;br /&gt;
| 2.12.7 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://www.gnu.org/software/gnutls/news.html gnu.org] &lt;br /&gt;
| LGPLv2.1+(core)/GPLv3(extra) &lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
! Opendaap &lt;br /&gt;
| 0.4.0 &lt;br /&gt;
| 0.4.0 &lt;br /&gt;
| {{Up-to-date}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
! libxml2 &lt;br /&gt;
| 2.7.8 &lt;br /&gt;
| 2.7.8 &lt;br /&gt;
| {{Up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [ftp://xmlsoft.org/libxml2/ xmlsoft ftp] &lt;br /&gt;
| MIT License&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Images  ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin: 1em auto; font-size: smaller; text-align: center; width: 100%;&amp;quot;&lt;br /&gt;
|+ &#039;&#039;&#039;Contrib Status&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
! Contrib lib &lt;br /&gt;
! VLC version &lt;br /&gt;
! Most recent version &lt;br /&gt;
! Compile &lt;br /&gt;
! Win32 &lt;br /&gt;
! MacOSX &lt;br /&gt;
! *Nix &lt;br /&gt;
! WinCE &lt;br /&gt;
! Where &lt;br /&gt;
! License&amp;lt;br&amp;gt; &lt;br /&gt;
! Comment&lt;br /&gt;
|-&lt;br /&gt;
! libpng &lt;br /&gt;
| 1.5.6&lt;br /&gt;
| 1.5.6 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://www.libpng.org/pub/png/libpng.html libpng.org] &lt;br /&gt;
| Very open license, approaching BSD 2-clause&lt;br /&gt;
|-&lt;br /&gt;
! libjpeg &lt;br /&gt;
| 8c &lt;br /&gt;
| 8c &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://www.ijg.org/files/ ijg.org] &lt;br /&gt;
| 1. We don&#039;t promise that this software works. &lt;br /&gt;
2. You can use this software for whatever you want. You don&#039;t have to pay us.&amp;lt;br&amp;gt; 3. You may not pretend that you wrote this software. If you use it in a program, you must acknowledge somewhere in your documentation that you&#039;ve used the IJG code. &lt;br /&gt;
&lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
! libtiff &lt;br /&gt;
| 3.9.5 &lt;br /&gt;
| 3.9.5 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [ftp://ftp.remotesensing.org/pub/libtiff/ Main libtiff ftp] &lt;br /&gt;
| BSD with Copyright attribution &lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
! SDL &lt;br /&gt;
| 1.2.14 &lt;br /&gt;
| 1.2.14 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://www.libsdl.org/download-1.2.php libsdl.org] &lt;br /&gt;
| LGPLv2.1+&amp;lt;br&amp;gt; &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! SDL_image &lt;br /&gt;
| 1.2.10 &lt;br /&gt;
| 1.2.10 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://www.libsdl.org/projects/SDL_image/ libsdl.org] &lt;br /&gt;
| LGPLv2.1+&amp;lt;br&amp;gt; &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Tools  ===&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;margin: 1em auto; font-size: smaller; text-align: center; width: 100%;&amp;quot; class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ &#039;&#039;&#039;Contrib Status&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
! Contrib lib &lt;br /&gt;
! VLC version &lt;br /&gt;
! Most recent version &lt;br /&gt;
! Compile &lt;br /&gt;
! Win32 &lt;br /&gt;
! MacOSX &lt;br /&gt;
! *Nix &lt;br /&gt;
! WinCE &lt;br /&gt;
! Where&amp;amp;nbsp;! &lt;br /&gt;
! License&amp;lt;br&amp;gt; &lt;br /&gt;
! Comment&lt;br /&gt;
|-&lt;br /&gt;
! Autoconf &lt;br /&gt;
| 2.68 &lt;br /&gt;
| 2.68 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://ftp.gnu.org/gnu/autoconf/?M=D Gnu(slow)] &lt;br /&gt;
| We don&#039;t care&amp;lt;br&amp;gt; &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! automake &lt;br /&gt;
| 1.11 &lt;br /&gt;
| 1.11 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://ftp.gnu.org/gnu/automake/?M=D Gnu(slow)] &lt;br /&gt;
| We don&#039;t care&amp;lt;br&amp;gt; &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! Pkgconfig &lt;br /&gt;
| 0.26 &lt;br /&gt;
| 0.26 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://pkgconfig.freedesktop.org/wiki/ fd.org] &lt;br /&gt;
| We don&#039;t care&amp;lt;br&amp;gt; &lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
! libtool &lt;br /&gt;
| 2.2.10 &lt;br /&gt;
| 2.2.10 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://www.gnu.org/software/libtool/ GNU-libtool] &lt;br /&gt;
| We don&#039;t care&amp;lt;br&amp;gt; &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! libiconv &lt;br /&gt;
| 1.13.1 &lt;br /&gt;
| 1.13.1 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| [http://www.gnu.org/software/libiconv/#downloading Gnu] &lt;br /&gt;
| LGPLv2.0+&amp;lt;br&amp;gt; &lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
! gettext &lt;br /&gt;
| 0.18.1.1 &lt;br /&gt;
| 0.18.1.1 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://ftp.gnu.org/gnu/gettext/ Gnu(slow)] &lt;br /&gt;
| LGPLv2.1+&amp;lt;br&amp;gt; &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! freetype2 &lt;br /&gt;
| 2.4.8&lt;br /&gt;
| 2.4.8 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://freetype.org/index2.html freetype.org] &lt;br /&gt;
| FreeType+GPLv2+&amp;lt;br&amp;gt; &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! fribidi &lt;br /&gt;
| 0.19.2 &lt;br /&gt;
| 0.19.2 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://fribidi.org/download/ fribidi.org] &lt;br /&gt;
| LGPLv2.1+&amp;lt;br&amp;gt; &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! zlib &lt;br /&gt;
| 1.2.5 &lt;br /&gt;
| 1.2.5 &lt;br /&gt;
| {{Up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://www.zlib.net/ zlib] &lt;br /&gt;
| Free&amp;lt;br&amp;gt; &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&amp;lt;br&amp;gt;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Others  ===&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;margin: 1em auto; font-size: smaller; text-align: center; width: 100%;&amp;quot; class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ &#039;&#039;&#039;Contrib Status&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
! Contrib lib &lt;br /&gt;
! VLC version &lt;br /&gt;
! Most recent version &lt;br /&gt;
! Compile &lt;br /&gt;
! Win32 &lt;br /&gt;
! MacOSX &lt;br /&gt;
! *Nix &lt;br /&gt;
! WinCE &lt;br /&gt;
! Where &lt;br /&gt;
! License &lt;br /&gt;
! Comment&lt;br /&gt;
|-&lt;br /&gt;
! taglib &lt;br /&gt;
| 1.7 &lt;br /&gt;
| 1.7 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| http://developer.kde.org/~wheeler/taglib.html &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! goom2k4 &lt;br /&gt;
| 2k4-0 &lt;br /&gt;
| 2k4-0 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! projectM &lt;br /&gt;
| 2.0.1 &lt;br /&gt;
| 2.0.1 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}}&lt;br /&gt;
| http://sourceforge.net/projects/projectm/files/&lt;br /&gt;
| LGPLv2.1+&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! libcaca &lt;br /&gt;
| 0.99-beta17 &lt;br /&gt;
| 0.99-beta17 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! Qt &lt;br /&gt;
| 4.3 &lt;br /&gt;
| 4.6 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! portaudio &lt;br /&gt;
| 19 &lt;br /&gt;
| 19 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Yes}}&amp;lt;br&amp;gt; &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
| Commented for Win32&lt;br /&gt;
|-&lt;br /&gt;
! Upnp &lt;br /&gt;
| 1.6.13 &lt;br /&gt;
| 1.6.13 &lt;br /&gt;
| {{up-to-date}}&lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| http://pupnp.sourceforge.net/ &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! expat &lt;br /&gt;
| 2.0.0 &lt;br /&gt;
| 2.0.1 &lt;br /&gt;
| {{untested}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
| Commented for MacOSX&lt;br /&gt;
|-&lt;br /&gt;
! yasm &lt;br /&gt;
| 1.1.0 &lt;br /&gt;
| 1.1.0 &lt;br /&gt;
| {{untested}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
| For Intel-based Macs&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
! SQLite &lt;br /&gt;
| 3.6 &lt;br /&gt;
| 3.6 &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! Contrib lib &lt;br /&gt;
! VLC version &lt;br /&gt;
! Most recent version &lt;br /&gt;
! Compile &lt;br /&gt;
! Win32 &lt;br /&gt;
! MacOSX &lt;br /&gt;
! *Nix &lt;br /&gt;
! WinCE &lt;br /&gt;
! &amp;lt;br&amp;gt;&lt;br /&gt;
! &amp;lt;br&amp;gt;&lt;br /&gt;
! Comment&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Single command installation in Ubuntu  ===&lt;br /&gt;
&lt;br /&gt;
 $ sudo apt-get -y install libvorbis-dev libogg-dev libtheora-dev speex libspeex-dev flac libflac-dev \&lt;br /&gt;
   x264 libx264-dev a52-0.7.4 liba52-0.7.4-dev mpeg2dec libmpeg2-4-dev faad libfaad-dev faac libfaac-dev \&lt;br /&gt;
   lame libmp3lame-dev ffmpeg libavdevice-dev libmad0 libmad0-dev dirac libdirac-dev liboil-dev libschroedinger-dev \&lt;br /&gt;
   libdca-dev twolame libtwolame-dev libmpcdec-dev libvorbisidec1 libvorbisidec-dev libass-dev libass4 libebml2 \&lt;br /&gt;
   libebml-dev libmatroska2 libmatroska-dev libdvbpsi6 libdvbpsi-dev libmodplug1 libmodplug-dev libshout3 libshout3-dev \&lt;br /&gt;
   libdvdread4 libdvdnav4 libdvdnav-dev livemedia-utils liblivemedia-dev libcddb2 libcddb2-dev libcdio10 libcdio-dev \&lt;br /&gt;
   libcdio-utils vcdimager libvcdinfo0 libvcdinfo-dev libgpg-error0 libgpg-error-dev libgcrypt11 libgcrypt11-dev \&lt;br /&gt;
   gnutls-bin libgnutls26 libgnutls-dev libdap10 libdap-bin libdap-dev libxml2 libxml2-dev libpng12-0 libpng12-dev \&lt;br /&gt;
   libjpeg8 libtiff4 libsdl1.2-dev libsdl-image1.2 libsdl-image1.2-dev libc-bin gettext libfreetype6 libfreetype6-dev \&lt;br /&gt;
   libfribidi-dev libfribidi0 zlib1g zlib1g-dev libtag1-dev libcaca0 libcaca-dev caca-utils libqt4-core libqt4-dev \&lt;br /&gt;
   libportaudio2 libportaudio-dev libupnp-dev libupnp4 libupnp3 libexpat1 libexpat1-dev yasm libxcb-xv0 libxcb-xv0-dev \&lt;br /&gt;
   libx11-xcb1 libx11-xcb-dev&lt;br /&gt;
&lt;br /&gt;
[[Category:Coding]] [[Category:Building]] [[Category:Libraries]]&lt;br /&gt;
&lt;br /&gt;
{{Documentation}}&lt;/div&gt;</summary>
		<author><name>Technologicat</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=UnixCompile&amp;diff=21920</id>
		<title>UnixCompile</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=UnixCompile&amp;diff=21920"/>
		<updated>2012-02-14T09:14:01Z</updated>

		<summary type="html">&lt;p&gt;Technologicat: /* Regarless of the method */ Typo regarless -&amp;gt; regardless&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Prepare your environment  ==&lt;br /&gt;
&lt;br /&gt;
VLC requires a C compiler, development headers and a toolchain. gcc will do but you could also use LLVM or proprietary C99/C++ compilers such as Intel&#039;s.&lt;br /&gt;
&lt;br /&gt;
If you build from the [[Git]] repositories, you will also need the GNU build system, a.k.a. the &amp;quot;autotools&amp;quot; (autoconf, automake, libtool and gettext) to setup the Makefiles. Make sure they are up-to-date and usable for your system.&lt;br /&gt;
&lt;br /&gt;
On Fedora:&lt;br /&gt;
&lt;br /&gt;
 % sudo yum install git libtool&lt;br /&gt;
&lt;br /&gt;
== Get the source  ==&lt;br /&gt;
Start by [[GetTheSource|getting the source]], using FTP for official releases, or using [[Git]] to track VLC development. &lt;br /&gt;
&lt;br /&gt;
If your are using an official release, download source code, extract the archive and go into the resulting VLC directory, e.g.:&lt;br /&gt;
 % wget ftp://ftp.videolan.org/pub/videolan/vlc/1.1.11/vlc-1.1.11.tar.bz2&lt;br /&gt;
 % tar xvjf vlc-1.1.11.tar.bz2&lt;br /&gt;
 % cd vlc-1.1.11&lt;br /&gt;
&lt;br /&gt;
If you are using the [[Git]] development version, start by bootstrapping the source tree:&lt;br /&gt;
 % cd vlc&lt;br /&gt;
 % ./bootstrap&lt;br /&gt;
Bootstrapping will fail if the autotools are missing or out-of-date.&lt;br /&gt;
&lt;br /&gt;
== Get the third-party libraries  ==&lt;br /&gt;
Now you could configure the VLC build. But first, you need to make sure that all the required dependencies are in place. Take a look at &amp;lt;tt&amp;gt;./configure --help&amp;lt;/tt&amp;gt;. Take a good look at that enormous list of options.&lt;br /&gt;
&lt;br /&gt;
It is very important that you do install and enable all the 3rd party libraries that you need. Yes, there is going to be a lot of them if you want a complete or even mostly functional VLC build. If you fail to install a required library, you will end up with a VLC application that well..... essentially does not do anything useful. See [[Contrib Status|here]] for a complete list.&lt;br /&gt;
 &lt;br /&gt;
There are some very important dependencies: gettext (NLS) for international support (required), libdvbpsi for MPEG-TS files and streams support, libmad for MP3 audio decoding, libmpeg2 for MPEG1 and MPEG2 video support, FFmpeg or libav (libavcodec, libavformat, libpostproc, libswscale and optionally libavio) for MPEG4 and most other audio and video codecs, and many file formats, liba52 for Dolby (AC3) sound, dvdread and dvdnav for DVD playback, live555 for RTSP stream playback, etc.&lt;br /&gt;
&lt;br /&gt;
For audio output, you will need probably alsa-lib (on [[Linux]]) and/or libpulse (for [[PulseAudio]]).&lt;br /&gt;
For video output, you will normally need XCB/XVideo and/or OpenGL/GLX.&lt;br /&gt;
And Qt4 is required to get the GUI support.&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039; that you need to install the development packages (development header files and import libraries) to compile VLC, not just the run-time. On Debian/Ubuntu, the correct package names end with -dev. On RPM distributions, they usually end in -devel.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Be careful!&#039;&#039;&#039; If the libraries are not provided by your distribution, you may be better off linking VLC with them statically. Otherwise, you may encounter version problems if another multimedia application updates the libraries later. This is especially true of FFmpeg or libav, and live555.&lt;br /&gt;
&lt;br /&gt;
There are a several ways to get those libraries. You should use only one method at a time: &lt;br /&gt;
 &lt;br /&gt;
=== The preferred method ===&lt;br /&gt;
Use your distribution packaging or portage system, in order to get all the needed libs.&lt;br /&gt;
For example on Debian or Ubuntu: &lt;br /&gt;
 # apt-get build-dep vlc&lt;br /&gt;
&lt;br /&gt;
openSUSE users might have a look at the source-install (si) command in the zypper manpage:&lt;br /&gt;
 # zypper si -d vlc&lt;br /&gt;
&lt;br /&gt;
=== The method for badly-behaved distributions ===&lt;br /&gt;
If your distribution does not provide the needed libraries,&lt;br /&gt;
or you really want to link VLC statically, use the VLC contribs system. It is included in the VLC source.&lt;br /&gt;
&lt;br /&gt;
First, you need to install the GNU autotools (if you have not already done so), CMake, subversion, Git and a recent GNU/tar utility or equivalent. Then you can run:&lt;br /&gt;
 % cd contrib&lt;br /&gt;
 % mkdir native&lt;br /&gt;
 % cd native&lt;br /&gt;
 % ../bootstrap&lt;br /&gt;
 % make&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039; the commands above are for VLC 1.2 or later. Details differ slightly for older versions:&lt;br /&gt;
 % cd extras/contrib&lt;br /&gt;
 % ./bootstrap&lt;br /&gt;
 % make&lt;br /&gt;
&lt;br /&gt;
That should download and build a lot of those libraries for you.  Unfortunately, given the large number of libraries and the variety of the platforms people build VLC for, it is not unlikely that you will hit an error while contribs are compiling. Thus, this approach is only recommended for experienced Unix compilers.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;For 1.2 or later&#039;&#039;&#039;: If you want to compile only a few select libraries instead of everything, you can run e.g.:&lt;br /&gt;
 % cd contrib&lt;br /&gt;
 % mkdir native&lt;br /&gt;
 % cd native&lt;br /&gt;
 % ../bootstrap&lt;br /&gt;
 % make .orc .schroedinger .x264 .ffmpeg&lt;br /&gt;
&lt;br /&gt;
Note the dot in front of each target name; otherwise the target names are the same as the directory names in &#039;&#039;contrib/src/&#039;&#039;. Note however that some of the libraries may depend on others; for example &#039;&#039;schroedinger&#039;&#039; depends on &#039;&#039;orc&#039;&#039;. When compiling single libraries like this, you will have to fulfill the dependencies manually by compiling the libraries in the right order.&lt;br /&gt;
&lt;br /&gt;
When building manually (regardless of VLC version or whether you&#039;re building everything or just a few libraries), you can also use standard make flags such as -jN for multicore (where N is the number of processes to use). Examples:&lt;br /&gt;
 % # everything&lt;br /&gt;
 % make -j2&lt;br /&gt;
 % # chosen libraries only&lt;br /&gt;
 % make -j2 .orc .schroedinger .x264 .ffmpeg&lt;br /&gt;
would use two processes for compiling.&lt;br /&gt;
&lt;br /&gt;
=== The method for people with too much time to waste ===&lt;br /&gt;
Read the [[Contrib Status|list]], download them and build them by hand.&lt;br /&gt;
&lt;br /&gt;
=== Regardless of the method ===&lt;br /&gt;
In any case, some basic OS support libraries are not included and must really be installed through the packaging system in any case, notably [[ALSA]], [[PulseAudio]] and [[OpenGL]].&lt;br /&gt;
&lt;br /&gt;
== Configuration  ==&lt;br /&gt;
You probably need to tweak the &amp;quot;configure&amp;quot; line. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;./configure&amp;lt;/tt&amp;gt; is used to check whether your system is able to compile VLC. Also you can choose the features in your build. As a reminder, this command will show the various options:&lt;br /&gt;
 % ./configure --help&lt;br /&gt;
 &lt;br /&gt;
=== Special libs  ===&lt;br /&gt;
Use &amp;lt;tt&amp;gt;--with-live555-path=path/to/livemedia/source/tree&amp;lt;/tt&amp;gt; in connection with &amp;lt;tt&amp;gt;--enable-live555&amp;lt;/tt&amp;gt;. For FFmpeg or libav, pkg-config is the only reliable way for VLC&#039;s configure to find the libraries. So you need to set PKG_CONFIG_PATH correctly if your FFmpeg/libav libraries are not installed at the default prefix (meaning /usr) or you want to use static linking.&lt;br /&gt;
&lt;br /&gt;
=== Final configuration  ===&lt;br /&gt;
If you want to install VLC into another directory, run &lt;br /&gt;
 &lt;br /&gt;
 % ./configure --prefix=/path/to/install/folder/&lt;br /&gt;
&lt;br /&gt;
This is an example of a typical VLC configure line: &lt;br /&gt;
 &lt;br /&gt;
 % ./configure --enable-x11 --enable-xvideo --enable-sdl --enable-avcodec --enable-avformat \&lt;br /&gt;
  --enable-swscale --enable-mad --enable-libdvbpsi --enable-a52 --enable-libmpeg2 --enable-dvdnav \&lt;br /&gt;
  --enable-faad --enable-vorbis --enable-ogg --enable-theora --enable-faac --enable-mkv --enable-freetype \&lt;br /&gt;
  --enable-fribidi --enable-speex --enable-flac --enable-live555 --with-live555-tree=/usr/lib/live \&lt;br /&gt;
  --enable-caca --enable-skins --enable-skins2 --enable-alsa --enable-qt4 --enable-ncurses&lt;br /&gt;
 &lt;br /&gt;
[[User:J-b#VLC_configure_line|Here]] is another. &lt;br /&gt;
&lt;br /&gt;
=== Ubuntu ===&lt;br /&gt;
&lt;br /&gt;
If you get continuous errors while ./configure then consider reinstalling the corresponding libraries. This will set the paths and other information correctly. Check the $PKG_CONFIG_PATH(environment variable) whether it is set to a path where the libraries like libavcodec.pc are available. Otherwise create the environment variable, export it and then update the ldconfig.&lt;br /&gt;
&lt;br /&gt;
== Compilation ==&lt;br /&gt;
Compile VLC: &lt;br /&gt;
 % make&lt;br /&gt;
&lt;br /&gt;
You do not need to install VLC to use it. You can also simply run it from the build directory:&lt;br /&gt;
 # ./vlc&lt;br /&gt;
&lt;br /&gt;
If you really want to install VLC to the system, run this as root:&lt;br /&gt;
 # make install&lt;br /&gt;
&lt;br /&gt;
You can uninstall later with this, but you need to keep the build tree untouched until then:&lt;br /&gt;
 # make uninstall&lt;br /&gt;
&lt;br /&gt;
To remove files created during the compile (optional) type:&lt;br /&gt;
 % make clean&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
&lt;br /&gt;
=== Cygwin ===&lt;br /&gt;
&lt;br /&gt;
Compiling on [[Win32CompileCygwin|Cygwin]] may be broken from time to time as Cygwin packages change.&lt;br /&gt;
We recommend [[Win32Compile|cross-compiling from Linux to Windows]] instead. &#039;&#039;&#039;Consider yourself warned.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Debian/Ubuntu ===&lt;br /&gt;
Debian users who want to compile VLC should install the packages below:&lt;br /&gt;
*[http://packages.debian.org/unstable/libdevel/libavcodec-dev libavcodec-dev] &lt;br /&gt;
*[http://packages.debian.org/unstable/libdevel/libpostproc-dev libpostproc-dev] &lt;br /&gt;
*[http://packages.debian.org/unstable/libdevel/libmpeg2-4-dev libmpeg2-4-dev]&lt;br /&gt;
&lt;br /&gt;
If you just want to &#039;&#039;use&#039;&#039; VLC media player then simply install the package vlc (&amp;lt;tt&amp;gt;sudo apt-get install vlc&amp;lt;/tt&amp;gt;) - the unstable version is fairly up-to-date most of the time, while the stable is, err, stable and very old&amp;amp;nbsp;;-)&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting / common problems ==&lt;br /&gt;
&lt;br /&gt;
=== Lua ===&lt;br /&gt;
You may need to install Lua if you get &amp;quot;LUA byte compiler missing.&amp;quot; message. You namely need to install &amp;quot;luac&amp;quot;, the Lua byte compiler.&lt;br /&gt;
&lt;br /&gt;
On Debian/Ubuntu:&lt;br /&gt;
 % sudo apt-get install lua5.1&lt;br /&gt;
&lt;br /&gt;
On Fedora:&lt;br /&gt;
 % sudo yum install lua&lt;br /&gt;
&lt;br /&gt;
=== XCB ===&lt;br /&gt;
&lt;br /&gt;
VLC 1.1 and later requires XCB libraries to deal with X11 displays. Do not disable XCB or you will not get any video support!&lt;br /&gt;
&lt;br /&gt;
To install these libraries run the following commands (Debian/Ubuntu):&lt;br /&gt;
 % sudo apt-get install libxcb-shm0-dev libxcb-xv0-dev libxcb-keysyms1-dev libxcb-randr0-dev libxcb-composite0-dev&lt;br /&gt;
&lt;br /&gt;
Under Fedora:&lt;br /&gt;
 % sudo yum install libxcb-devel xcb-util-devel&lt;br /&gt;
&lt;br /&gt;
For OpenGL (Debian/Ubuntu only), you will additionally need XLib with XCB:&lt;br /&gt;
 % sudo apt-get install libx11-xcb-dev&lt;br /&gt;
&lt;br /&gt;
If your distribution provides a version of XLib without XCB, then this later package will not be available. So you will not be able to use OpenGL. Use XVideo instead.&lt;br /&gt;
&lt;br /&gt;
[[Category:Building]]&lt;/div&gt;</summary>
		<author><name>Technologicat</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=UnixCompile&amp;diff=21919</id>
		<title>UnixCompile</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=UnixCompile&amp;diff=21919"/>
		<updated>2012-02-14T09:12:22Z</updated>

		<summary type="html">&lt;p&gt;Technologicat: /* The method for badly-behaved distributions */ Note about make -jN&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Prepare your environment  ==&lt;br /&gt;
&lt;br /&gt;
VLC requires a C compiler, development headers and a toolchain. gcc will do but you could also use LLVM or proprietary C99/C++ compilers such as Intel&#039;s.&lt;br /&gt;
&lt;br /&gt;
If you build from the [[Git]] repositories, you will also need the GNU build system, a.k.a. the &amp;quot;autotools&amp;quot; (autoconf, automake, libtool and gettext) to setup the Makefiles. Make sure they are up-to-date and usable for your system.&lt;br /&gt;
&lt;br /&gt;
On Fedora:&lt;br /&gt;
&lt;br /&gt;
 % sudo yum install git libtool&lt;br /&gt;
&lt;br /&gt;
== Get the source  ==&lt;br /&gt;
Start by [[GetTheSource|getting the source]], using FTP for official releases, or using [[Git]] to track VLC development. &lt;br /&gt;
&lt;br /&gt;
If your are using an official release, download source code, extract the archive and go into the resulting VLC directory, e.g.:&lt;br /&gt;
 % wget ftp://ftp.videolan.org/pub/videolan/vlc/1.1.11/vlc-1.1.11.tar.bz2&lt;br /&gt;
 % tar xvjf vlc-1.1.11.tar.bz2&lt;br /&gt;
 % cd vlc-1.1.11&lt;br /&gt;
&lt;br /&gt;
If you are using the [[Git]] development version, start by bootstrapping the source tree:&lt;br /&gt;
 % cd vlc&lt;br /&gt;
 % ./bootstrap&lt;br /&gt;
Bootstrapping will fail if the autotools are missing or out-of-date.&lt;br /&gt;
&lt;br /&gt;
== Get the third-party libraries  ==&lt;br /&gt;
Now you could configure the VLC build. But first, you need to make sure that all the required dependencies are in place. Take a look at &amp;lt;tt&amp;gt;./configure --help&amp;lt;/tt&amp;gt;. Take a good look at that enormous list of options.&lt;br /&gt;
&lt;br /&gt;
It is very important that you do install and enable all the 3rd party libraries that you need. Yes, there is going to be a lot of them if you want a complete or even mostly functional VLC build. If you fail to install a required library, you will end up with a VLC application that well..... essentially does not do anything useful. See [[Contrib Status|here]] for a complete list.&lt;br /&gt;
 &lt;br /&gt;
There are some very important dependencies: gettext (NLS) for international support (required), libdvbpsi for MPEG-TS files and streams support, libmad for MP3 audio decoding, libmpeg2 for MPEG1 and MPEG2 video support, FFmpeg or libav (libavcodec, libavformat, libpostproc, libswscale and optionally libavio) for MPEG4 and most other audio and video codecs, and many file formats, liba52 for Dolby (AC3) sound, dvdread and dvdnav for DVD playback, live555 for RTSP stream playback, etc.&lt;br /&gt;
&lt;br /&gt;
For audio output, you will need probably alsa-lib (on [[Linux]]) and/or libpulse (for [[PulseAudio]]).&lt;br /&gt;
For video output, you will normally need XCB/XVideo and/or OpenGL/GLX.&lt;br /&gt;
And Qt4 is required to get the GUI support.&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039; that you need to install the development packages (development header files and import libraries) to compile VLC, not just the run-time. On Debian/Ubuntu, the correct package names end with -dev. On RPM distributions, they usually end in -devel.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Be careful!&#039;&#039;&#039; If the libraries are not provided by your distribution, you may be better off linking VLC with them statically. Otherwise, you may encounter version problems if another multimedia application updates the libraries later. This is especially true of FFmpeg or libav, and live555.&lt;br /&gt;
&lt;br /&gt;
There are a several ways to get those libraries. You should use only one method at a time: &lt;br /&gt;
 &lt;br /&gt;
=== The preferred method ===&lt;br /&gt;
Use your distribution packaging or portage system, in order to get all the needed libs.&lt;br /&gt;
For example on Debian or Ubuntu: &lt;br /&gt;
 # apt-get build-dep vlc&lt;br /&gt;
&lt;br /&gt;
openSUSE users might have a look at the source-install (si) command in the zypper manpage:&lt;br /&gt;
 # zypper si -d vlc&lt;br /&gt;
&lt;br /&gt;
=== The method for badly-behaved distributions ===&lt;br /&gt;
If your distribution does not provide the needed libraries,&lt;br /&gt;
or you really want to link VLC statically, use the VLC contribs system. It is included in the VLC source.&lt;br /&gt;
&lt;br /&gt;
First, you need to install the GNU autotools (if you have not already done so), CMake, subversion, Git and a recent GNU/tar utility or equivalent. Then you can run:&lt;br /&gt;
 % cd contrib&lt;br /&gt;
 % mkdir native&lt;br /&gt;
 % cd native&lt;br /&gt;
 % ../bootstrap&lt;br /&gt;
 % make&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039; the commands above are for VLC 1.2 or later. Details differ slightly for older versions:&lt;br /&gt;
 % cd extras/contrib&lt;br /&gt;
 % ./bootstrap&lt;br /&gt;
 % make&lt;br /&gt;
&lt;br /&gt;
That should download and build a lot of those libraries for you.  Unfortunately, given the large number of libraries and the variety of the platforms people build VLC for, it is not unlikely that you will hit an error while contribs are compiling. Thus, this approach is only recommended for experienced Unix compilers.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;For 1.2 or later&#039;&#039;&#039;: If you want to compile only a few select libraries instead of everything, you can run e.g.:&lt;br /&gt;
 % cd contrib&lt;br /&gt;
 % mkdir native&lt;br /&gt;
 % cd native&lt;br /&gt;
 % ../bootstrap&lt;br /&gt;
 % make .orc .schroedinger .x264 .ffmpeg&lt;br /&gt;
&lt;br /&gt;
Note the dot in front of each target name; otherwise the target names are the same as the directory names in &#039;&#039;contrib/src/&#039;&#039;. Note however that some of the libraries may depend on others; for example &#039;&#039;schroedinger&#039;&#039; depends on &#039;&#039;orc&#039;&#039;. When compiling single libraries like this, you will have to fulfill the dependencies manually by compiling the libraries in the right order.&lt;br /&gt;
&lt;br /&gt;
When building manually (regardless of VLC version or whether you&#039;re building everything or just a few libraries), you can also use standard make flags such as -jN for multicore (where N is the number of processes to use). Examples:&lt;br /&gt;
 % # everything&lt;br /&gt;
 % make -j2&lt;br /&gt;
 % # chosen libraries only&lt;br /&gt;
 % make -j2 .orc .schroedinger .x264 .ffmpeg&lt;br /&gt;
would use two processes for compiling.&lt;br /&gt;
&lt;br /&gt;
=== The method for people with too much time to waste ===&lt;br /&gt;
Read the [[Contrib Status|list]], download them and build them by hand.&lt;br /&gt;
&lt;br /&gt;
=== Regarless of the method ===&lt;br /&gt;
In any case, some basic OS support libraries are not included and must really be installed through the packaging system in any case, notably [[ALSA]], [[PulseAudio]] and [[OpenGL]].&lt;br /&gt;
&lt;br /&gt;
== Configuration  ==&lt;br /&gt;
You probably need to tweak the &amp;quot;configure&amp;quot; line. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;./configure&amp;lt;/tt&amp;gt; is used to check whether your system is able to compile VLC. Also you can choose the features in your build. As a reminder, this command will show the various options:&lt;br /&gt;
 % ./configure --help&lt;br /&gt;
 &lt;br /&gt;
=== Special libs  ===&lt;br /&gt;
Use &amp;lt;tt&amp;gt;--with-live555-path=path/to/livemedia/source/tree&amp;lt;/tt&amp;gt; in connection with &amp;lt;tt&amp;gt;--enable-live555&amp;lt;/tt&amp;gt;. For FFmpeg or libav, pkg-config is the only reliable way for VLC&#039;s configure to find the libraries. So you need to set PKG_CONFIG_PATH correctly if your FFmpeg/libav libraries are not installed at the default prefix (meaning /usr) or you want to use static linking.&lt;br /&gt;
&lt;br /&gt;
=== Final configuration  ===&lt;br /&gt;
If you want to install VLC into another directory, run &lt;br /&gt;
 &lt;br /&gt;
 % ./configure --prefix=/path/to/install/folder/&lt;br /&gt;
&lt;br /&gt;
This is an example of a typical VLC configure line: &lt;br /&gt;
 &lt;br /&gt;
 % ./configure --enable-x11 --enable-xvideo --enable-sdl --enable-avcodec --enable-avformat \&lt;br /&gt;
  --enable-swscale --enable-mad --enable-libdvbpsi --enable-a52 --enable-libmpeg2 --enable-dvdnav \&lt;br /&gt;
  --enable-faad --enable-vorbis --enable-ogg --enable-theora --enable-faac --enable-mkv --enable-freetype \&lt;br /&gt;
  --enable-fribidi --enable-speex --enable-flac --enable-live555 --with-live555-tree=/usr/lib/live \&lt;br /&gt;
  --enable-caca --enable-skins --enable-skins2 --enable-alsa --enable-qt4 --enable-ncurses&lt;br /&gt;
 &lt;br /&gt;
[[User:J-b#VLC_configure_line|Here]] is another. &lt;br /&gt;
&lt;br /&gt;
=== Ubuntu ===&lt;br /&gt;
&lt;br /&gt;
If you get continuous errors while ./configure then consider reinstalling the corresponding libraries. This will set the paths and other information correctly. Check the $PKG_CONFIG_PATH(environment variable) whether it is set to a path where the libraries like libavcodec.pc are available. Otherwise create the environment variable, export it and then update the ldconfig.&lt;br /&gt;
&lt;br /&gt;
== Compilation ==&lt;br /&gt;
Compile VLC: &lt;br /&gt;
 % make&lt;br /&gt;
&lt;br /&gt;
You do not need to install VLC to use it. You can also simply run it from the build directory:&lt;br /&gt;
 # ./vlc&lt;br /&gt;
&lt;br /&gt;
If you really want to install VLC to the system, run this as root:&lt;br /&gt;
 # make install&lt;br /&gt;
&lt;br /&gt;
You can uninstall later with this, but you need to keep the build tree untouched until then:&lt;br /&gt;
 # make uninstall&lt;br /&gt;
&lt;br /&gt;
To remove files created during the compile (optional) type:&lt;br /&gt;
 % make clean&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
&lt;br /&gt;
=== Cygwin ===&lt;br /&gt;
&lt;br /&gt;
Compiling on [[Win32CompileCygwin|Cygwin]] may be broken from time to time as Cygwin packages change.&lt;br /&gt;
We recommend [[Win32Compile|cross-compiling from Linux to Windows]] instead. &#039;&#039;&#039;Consider yourself warned.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Debian/Ubuntu ===&lt;br /&gt;
Debian users who want to compile VLC should install the packages below:&lt;br /&gt;
*[http://packages.debian.org/unstable/libdevel/libavcodec-dev libavcodec-dev] &lt;br /&gt;
*[http://packages.debian.org/unstable/libdevel/libpostproc-dev libpostproc-dev] &lt;br /&gt;
*[http://packages.debian.org/unstable/libdevel/libmpeg2-4-dev libmpeg2-4-dev]&lt;br /&gt;
&lt;br /&gt;
If you just want to &#039;&#039;use&#039;&#039; VLC media player then simply install the package vlc (&amp;lt;tt&amp;gt;sudo apt-get install vlc&amp;lt;/tt&amp;gt;) - the unstable version is fairly up-to-date most of the time, while the stable is, err, stable and very old&amp;amp;nbsp;;-)&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting / common problems ==&lt;br /&gt;
&lt;br /&gt;
=== Lua ===&lt;br /&gt;
You may need to install Lua if you get &amp;quot;LUA byte compiler missing.&amp;quot; message. You namely need to install &amp;quot;luac&amp;quot;, the Lua byte compiler.&lt;br /&gt;
&lt;br /&gt;
On Debian/Ubuntu:&lt;br /&gt;
 % sudo apt-get install lua5.1&lt;br /&gt;
&lt;br /&gt;
On Fedora:&lt;br /&gt;
 % sudo yum install lua&lt;br /&gt;
&lt;br /&gt;
=== XCB ===&lt;br /&gt;
&lt;br /&gt;
VLC 1.1 and later requires XCB libraries to deal with X11 displays. Do not disable XCB or you will not get any video support!&lt;br /&gt;
&lt;br /&gt;
To install these libraries run the following commands (Debian/Ubuntu):&lt;br /&gt;
 % sudo apt-get install libxcb-shm0-dev libxcb-xv0-dev libxcb-keysyms1-dev libxcb-randr0-dev libxcb-composite0-dev&lt;br /&gt;
&lt;br /&gt;
Under Fedora:&lt;br /&gt;
 % sudo yum install libxcb-devel xcb-util-devel&lt;br /&gt;
&lt;br /&gt;
For OpenGL (Debian/Ubuntu only), you will additionally need XLib with XCB:&lt;br /&gt;
 % sudo apt-get install libx11-xcb-dev&lt;br /&gt;
&lt;br /&gt;
If your distribution provides a version of XLib without XCB, then this later package will not be available. So you will not be able to use OpenGL. Use XVideo instead.&lt;br /&gt;
&lt;br /&gt;
[[Category:Building]]&lt;/div&gt;</summary>
		<author><name>Technologicat</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=UnixCompile&amp;diff=21918</id>
		<title>UnixCompile</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=UnixCompile&amp;diff=21918"/>
		<updated>2012-02-14T09:06:15Z</updated>

		<summary type="html">&lt;p&gt;Technologicat: /* The method for badly-behaved distributions */  Added how to compile a few select libraries only&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Prepare your environment  ==&lt;br /&gt;
&lt;br /&gt;
VLC requires a C compiler, development headers and a toolchain. gcc will do but you could also use LLVM or proprietary C99/C++ compilers such as Intel&#039;s.&lt;br /&gt;
&lt;br /&gt;
If you build from the [[Git]] repositories, you will also need the GNU build system, a.k.a. the &amp;quot;autotools&amp;quot; (autoconf, automake, libtool and gettext) to setup the Makefiles. Make sure they are up-to-date and usable for your system.&lt;br /&gt;
&lt;br /&gt;
On Fedora:&lt;br /&gt;
&lt;br /&gt;
 % sudo yum install git libtool&lt;br /&gt;
&lt;br /&gt;
== Get the source  ==&lt;br /&gt;
Start by [[GetTheSource|getting the source]], using FTP for official releases, or using [[Git]] to track VLC development. &lt;br /&gt;
&lt;br /&gt;
If your are using an official release, download source code, extract the archive and go into the resulting VLC directory, e.g.:&lt;br /&gt;
 % wget ftp://ftp.videolan.org/pub/videolan/vlc/1.1.11/vlc-1.1.11.tar.bz2&lt;br /&gt;
 % tar xvjf vlc-1.1.11.tar.bz2&lt;br /&gt;
 % cd vlc-1.1.11&lt;br /&gt;
&lt;br /&gt;
If you are using the [[Git]] development version, start by bootstrapping the source tree:&lt;br /&gt;
 % cd vlc&lt;br /&gt;
 % ./bootstrap&lt;br /&gt;
Bootstrapping will fail if the autotools are missing or out-of-date.&lt;br /&gt;
&lt;br /&gt;
== Get the third-party libraries  ==&lt;br /&gt;
Now you could configure the VLC build. But first, you need to make sure that all the required dependencies are in place. Take a look at &amp;lt;tt&amp;gt;./configure --help&amp;lt;/tt&amp;gt;. Take a good look at that enormous list of options.&lt;br /&gt;
&lt;br /&gt;
It is very important that you do install and enable all the 3rd party libraries that you need. Yes, there is going to be a lot of them if you want a complete or even mostly functional VLC build. If you fail to install a required library, you will end up with a VLC application that well..... essentially does not do anything useful. See [[Contrib Status|here]] for a complete list.&lt;br /&gt;
 &lt;br /&gt;
There are some very important dependencies: gettext (NLS) for international support (required), libdvbpsi for MPEG-TS files and streams support, libmad for MP3 audio decoding, libmpeg2 for MPEG1 and MPEG2 video support, FFmpeg or libav (libavcodec, libavformat, libpostproc, libswscale and optionally libavio) for MPEG4 and most other audio and video codecs, and many file formats, liba52 for Dolby (AC3) sound, dvdread and dvdnav for DVD playback, live555 for RTSP stream playback, etc.&lt;br /&gt;
&lt;br /&gt;
For audio output, you will need probably alsa-lib (on [[Linux]]) and/or libpulse (for [[PulseAudio]]).&lt;br /&gt;
For video output, you will normally need XCB/XVideo and/or OpenGL/GLX.&lt;br /&gt;
And Qt4 is required to get the GUI support.&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039; that you need to install the development packages (development header files and import libraries) to compile VLC, not just the run-time. On Debian/Ubuntu, the correct package names end with -dev. On RPM distributions, they usually end in -devel.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Be careful!&#039;&#039;&#039; If the libraries are not provided by your distribution, you may be better off linking VLC with them statically. Otherwise, you may encounter version problems if another multimedia application updates the libraries later. This is especially true of FFmpeg or libav, and live555.&lt;br /&gt;
&lt;br /&gt;
There are a several ways to get those libraries. You should use only one method at a time: &lt;br /&gt;
 &lt;br /&gt;
=== The preferred method ===&lt;br /&gt;
Use your distribution packaging or portage system, in order to get all the needed libs.&lt;br /&gt;
For example on Debian or Ubuntu: &lt;br /&gt;
 # apt-get build-dep vlc&lt;br /&gt;
&lt;br /&gt;
openSUSE users might have a look at the source-install (si) command in the zypper manpage:&lt;br /&gt;
 # zypper si -d vlc&lt;br /&gt;
&lt;br /&gt;
=== The method for badly-behaved distributions ===&lt;br /&gt;
If your distribution does not provide the needed libraries,&lt;br /&gt;
or you really want to link VLC statically, use the VLC contribs system. It is included in the VLC source.&lt;br /&gt;
&lt;br /&gt;
First, you need to install the GNU autotools (if you have not already done so), CMake, subversion, Git and a recent GNU/tar utility or equivalent. Then you can run:&lt;br /&gt;
 % cd contrib&lt;br /&gt;
 % mkdir native&lt;br /&gt;
 % cd native&lt;br /&gt;
 % ../bootstrap&lt;br /&gt;
 % make&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039; the commands above are for VLC 1.2 or later. Details differ slightly for older versions:&lt;br /&gt;
 % cd extras/contrib&lt;br /&gt;
 % ./bootstrap&lt;br /&gt;
 % make&lt;br /&gt;
&lt;br /&gt;
That should download and build a lot of those libraries for you.  Unfortunately, given the large number of libraries and the variety of the platforms people build VLC for, it is not unlikely that you will hit an error while contribs are compiling. Thus, this approach is only recommended for experienced Unix compilers.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;For 1.2 or later&#039;&#039;&#039;: If you want to compile only a few select libraries instead of everything, you can run e.g.:&lt;br /&gt;
 % cd contrib&lt;br /&gt;
 % mkdir native&lt;br /&gt;
 % cd native&lt;br /&gt;
 % ../bootstrap&lt;br /&gt;
 % make .orc .schroedinger .x264 .ffmpeg&lt;br /&gt;
&lt;br /&gt;
Note the dot in front of each target name; otherwise the target names are the same as the directory names in &#039;&#039;contrib/src/&#039;&#039;. Note however that some of the libraries may depend on others; for example &#039;&#039;schroedinger&#039;&#039; depends on &#039;&#039;orc&#039;&#039;. When compiling single libraries like this, you will have to fulfill the dependencies manually by compiling the libraries in the right order.&lt;br /&gt;
&lt;br /&gt;
=== The method for people with too much time to waste ===&lt;br /&gt;
Read the [[Contrib Status|list]], download them and build them by hand.&lt;br /&gt;
&lt;br /&gt;
=== Regarless of the method ===&lt;br /&gt;
In any case, some basic OS support libraries are not included and must really be installed through the packaging system in any case, notably [[ALSA]], [[PulseAudio]] and [[OpenGL]].&lt;br /&gt;
&lt;br /&gt;
== Configuration  ==&lt;br /&gt;
You probably need to tweak the &amp;quot;configure&amp;quot; line. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;./configure&amp;lt;/tt&amp;gt; is used to check whether your system is able to compile VLC. Also you can choose the features in your build. As a reminder, this command will show the various options:&lt;br /&gt;
 % ./configure --help&lt;br /&gt;
 &lt;br /&gt;
=== Special libs  ===&lt;br /&gt;
Use &amp;lt;tt&amp;gt;--with-live555-path=path/to/livemedia/source/tree&amp;lt;/tt&amp;gt; in connection with &amp;lt;tt&amp;gt;--enable-live555&amp;lt;/tt&amp;gt;. For FFmpeg or libav, pkg-config is the only reliable way for VLC&#039;s configure to find the libraries. So you need to set PKG_CONFIG_PATH correctly if your FFmpeg/libav libraries are not installed at the default prefix (meaning /usr) or you want to use static linking.&lt;br /&gt;
&lt;br /&gt;
=== Final configuration  ===&lt;br /&gt;
If you want to install VLC into another directory, run &lt;br /&gt;
 &lt;br /&gt;
 % ./configure --prefix=/path/to/install/folder/&lt;br /&gt;
&lt;br /&gt;
This is an example of a typical VLC configure line: &lt;br /&gt;
 &lt;br /&gt;
 % ./configure --enable-x11 --enable-xvideo --enable-sdl --enable-avcodec --enable-avformat \&lt;br /&gt;
  --enable-swscale --enable-mad --enable-libdvbpsi --enable-a52 --enable-libmpeg2 --enable-dvdnav \&lt;br /&gt;
  --enable-faad --enable-vorbis --enable-ogg --enable-theora --enable-faac --enable-mkv --enable-freetype \&lt;br /&gt;
  --enable-fribidi --enable-speex --enable-flac --enable-live555 --with-live555-tree=/usr/lib/live \&lt;br /&gt;
  --enable-caca --enable-skins --enable-skins2 --enable-alsa --enable-qt4 --enable-ncurses&lt;br /&gt;
 &lt;br /&gt;
[[User:J-b#VLC_configure_line|Here]] is another. &lt;br /&gt;
&lt;br /&gt;
=== Ubuntu ===&lt;br /&gt;
&lt;br /&gt;
If you get continuous errors while ./configure then consider reinstalling the corresponding libraries. This will set the paths and other information correctly. Check the $PKG_CONFIG_PATH(environment variable) whether it is set to a path where the libraries like libavcodec.pc are available. Otherwise create the environment variable, export it and then update the ldconfig.&lt;br /&gt;
&lt;br /&gt;
== Compilation ==&lt;br /&gt;
Compile VLC: &lt;br /&gt;
 % make&lt;br /&gt;
&lt;br /&gt;
You do not need to install VLC to use it. You can also simply run it from the build directory:&lt;br /&gt;
 # ./vlc&lt;br /&gt;
&lt;br /&gt;
If you really want to install VLC to the system, run this as root:&lt;br /&gt;
 # make install&lt;br /&gt;
&lt;br /&gt;
You can uninstall later with this, but you need to keep the build tree untouched until then:&lt;br /&gt;
 # make uninstall&lt;br /&gt;
&lt;br /&gt;
To remove files created during the compile (optional) type:&lt;br /&gt;
 % make clean&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
&lt;br /&gt;
=== Cygwin ===&lt;br /&gt;
&lt;br /&gt;
Compiling on [[Win32CompileCygwin|Cygwin]] may be broken from time to time as Cygwin packages change.&lt;br /&gt;
We recommend [[Win32Compile|cross-compiling from Linux to Windows]] instead. &#039;&#039;&#039;Consider yourself warned.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Debian/Ubuntu ===&lt;br /&gt;
Debian users who want to compile VLC should install the packages below:&lt;br /&gt;
*[http://packages.debian.org/unstable/libdevel/libavcodec-dev libavcodec-dev] &lt;br /&gt;
*[http://packages.debian.org/unstable/libdevel/libpostproc-dev libpostproc-dev] &lt;br /&gt;
*[http://packages.debian.org/unstable/libdevel/libmpeg2-4-dev libmpeg2-4-dev]&lt;br /&gt;
&lt;br /&gt;
If you just want to &#039;&#039;use&#039;&#039; VLC media player then simply install the package vlc (&amp;lt;tt&amp;gt;sudo apt-get install vlc&amp;lt;/tt&amp;gt;) - the unstable version is fairly up-to-date most of the time, while the stable is, err, stable and very old&amp;amp;nbsp;;-)&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting / common problems ==&lt;br /&gt;
&lt;br /&gt;
=== Lua ===&lt;br /&gt;
You may need to install Lua if you get &amp;quot;LUA byte compiler missing.&amp;quot; message. You namely need to install &amp;quot;luac&amp;quot;, the Lua byte compiler.&lt;br /&gt;
&lt;br /&gt;
On Debian/Ubuntu:&lt;br /&gt;
 % sudo apt-get install lua5.1&lt;br /&gt;
&lt;br /&gt;
On Fedora:&lt;br /&gt;
 % sudo yum install lua&lt;br /&gt;
&lt;br /&gt;
=== XCB ===&lt;br /&gt;
&lt;br /&gt;
VLC 1.1 and later requires XCB libraries to deal with X11 displays. Do not disable XCB or you will not get any video support!&lt;br /&gt;
&lt;br /&gt;
To install these libraries run the following commands (Debian/Ubuntu):&lt;br /&gt;
 % sudo apt-get install libxcb-shm0-dev libxcb-xv0-dev libxcb-keysyms1-dev libxcb-randr0-dev libxcb-composite0-dev&lt;br /&gt;
&lt;br /&gt;
Under Fedora:&lt;br /&gt;
 % sudo yum install libxcb-devel xcb-util-devel&lt;br /&gt;
&lt;br /&gt;
For OpenGL (Debian/Ubuntu only), you will additionally need XLib with XCB:&lt;br /&gt;
 % sudo apt-get install libx11-xcb-dev&lt;br /&gt;
&lt;br /&gt;
If your distribution provides a version of XLib without XCB, then this later package will not be available. So you will not be able to use OpenGL. Use XVideo instead.&lt;br /&gt;
&lt;br /&gt;
[[Category:Building]]&lt;/div&gt;</summary>
		<author><name>Technologicat</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=Contrib_Status&amp;diff=21751</id>
		<title>Contrib Status</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=Contrib_Status&amp;diff=21751"/>
		<updated>2012-02-08T17:14:21Z</updated>

		<summary type="html">&lt;p&gt;Technologicat: contrib moved from extras/contrib to contrib&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page lists the libraries needed to have a fully featured {{VLC}}. &amp;lt;br&amp;gt; The additional information in the table refers to the VLC contrib build system (located in extras/contrib in VLC 1.1; in contrib in VLC 2.0+). These versions are against the trunk version. &lt;br /&gt;
&lt;br /&gt;
For information on how to compile {{VLC}} on your platform see the [[Developers Corner|Build VLC media player]] box on the Developer Corner&#039;s page. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
=== Codecs  ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin: 1em auto; font-size: smaller; text-align: center; width: 100%;&amp;quot;&lt;br /&gt;
|+ &#039;&#039;&#039;Contrib Status&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
! Contrib lib &lt;br /&gt;
! VLC version &lt;br /&gt;
! Most recent version &lt;br /&gt;
! Compile &lt;br /&gt;
! Win32 &lt;br /&gt;
! MacOSX &lt;br /&gt;
! *Nix &lt;br /&gt;
! WinCE &lt;br /&gt;
! Where&amp;amp;nbsp;? &lt;br /&gt;
! License &lt;br /&gt;
! Comment&lt;br /&gt;
|-&lt;br /&gt;
! libvorbis &lt;br /&gt;
| 1.3.2 &lt;br /&gt;
| 1.3.2 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://www.xiph.org/downloads/ Xiph.org] &lt;br /&gt;
| BSD-like&amp;lt;br&amp;gt; &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! libogg &lt;br /&gt;
| 1.3.0 &lt;br /&gt;
| 1.3.0 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| [http://www.xiph.org/downloads/ Xiph.org] &lt;br /&gt;
| BSD-like&amp;lt;br&amp;gt; &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! libtheora &lt;br /&gt;
| &lt;br /&gt;
1.1.1 &lt;br /&gt;
&lt;br /&gt;
| 1.1.1 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://www.xiph.org/downloads/ Xiph.org] &lt;br /&gt;
| BSD-like&amp;lt;br&amp;gt; &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! speex &lt;br /&gt;
| 1.2rc1 &lt;br /&gt;
| 1.2rc1 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://www.xiph.org/downloads/ Xiph.org] &lt;br /&gt;
| BSD-like&amp;lt;br&amp;gt; &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! flac &lt;br /&gt;
| 1.2.1 &lt;br /&gt;
| 1.2.1 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://sourceforge.net/projects/flac/files/flac-src/ Flac] &lt;br /&gt;
| BSD-like&amp;lt;br&amp;gt; &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! x264 &lt;br /&gt;
| svn &lt;br /&gt;
| svn &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| SVN &lt;br /&gt;
| GPLv2+&amp;lt;br&amp;gt; &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! a52 &lt;br /&gt;
| 0.7.4 &lt;br /&gt;
| 0.7.4 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://liba52.sf.net liba52.sf] &lt;br /&gt;
| GPLv2+&amp;lt;br&amp;gt; &lt;br /&gt;
| Not likely to be updated&lt;br /&gt;
|-&lt;br /&gt;
! MPEG2DEC &lt;br /&gt;
| 0.5.1 &lt;br /&gt;
| 0.5.1 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| [http://libmpeg2.sf.net libmpeg2.sf] &lt;br /&gt;
| GPLv2+&amp;lt;br&amp;gt; &lt;br /&gt;
| Not likely to be updated&lt;br /&gt;
|-&lt;br /&gt;
! faad2 &lt;br /&gt;
| 2.7 &lt;br /&gt;
| 2.7 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://www.audiocoding.com/faad2.html audiocoding] &lt;br /&gt;
| GPLv2+&amp;lt;br&amp;gt; &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! faac &lt;br /&gt;
| 1.28 &lt;br /&gt;
| 1.28 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://www.audiocoding.com/faac.html audiocoding] &lt;br /&gt;
| LGPL for modifications&amp;lt;br&amp;gt; &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! lame &lt;br /&gt;
| 3.99.1 &lt;br /&gt;
| 3.99.1 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://sourceforge.net/project/showfiles.php?group_id=290&amp;amp;package_id=309 sf.net] &lt;br /&gt;
| LGPLv2+&amp;lt;br&amp;gt; &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! FFmpeg &lt;br /&gt;
| SVN &lt;br /&gt;
| SVN &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| SVN &lt;br /&gt;
| GPLv2/3/LGPL&amp;lt;br&amp;gt; &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! libmad &lt;br /&gt;
| 0.15.1b &lt;br /&gt;
| 0.15.1b &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://sourceforge.net/project/showfiles.php?group_id=12349&amp;amp;package_id=86999 SF] &lt;br /&gt;
| GPLv2+&amp;lt;br&amp;gt; &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! orc &lt;br /&gt;
| 0.4.16&lt;br /&gt;
| 0.4.16 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://code.entropywave.com/download/orc/ orc ] &lt;br /&gt;
| Two-Clause BSD &lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
! schroedinger &lt;br /&gt;
| 1.0.10 &lt;br /&gt;
| 1.0.10 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://www.diracvideo.org/download/schroedinger/ diracvideo.org] &lt;br /&gt;
| GPLv2/LGPL 2.1/MIT&amp;lt;br&amp;gt; &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! libdca &lt;br /&gt;
| SVN &lt;br /&gt;
| SVN &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| SVN &lt;br /&gt;
| GPLv2+&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
! twolame &lt;br /&gt;
| 0.3.13 &lt;br /&gt;
| 0.3.13 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://www.twolame.org/ twolame.org] &lt;br /&gt;
| LGPL 2.1+&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
! libmpcdec &lt;br /&gt;
| SVN &lt;br /&gt;
| SVN &lt;br /&gt;
| {{Up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://www.musepack.net/index.php?pg=src musepack] &lt;br /&gt;
| BSD&lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
! Tremor &lt;br /&gt;
| SVN &lt;br /&gt;
| SVN &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| SVN &lt;br /&gt;
| BSD-like &lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
! libass &lt;br /&gt;
| 0.10.0&lt;br /&gt;
| 0.10.0&lt;br /&gt;
| {{up-to-date}}&lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://code.google.com/p/libass/downloads/list Google Code]&amp;lt;br&amp;gt; &lt;br /&gt;
| Simplified 2-clause BSD license&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Demuxers and Muxers  ===&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;margin: 1em auto; font-size: smaller; text-align: center; width: 100%;&amp;quot; class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ &#039;&#039;&#039;Contrib Status&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
! Contrib lib &lt;br /&gt;
! VLC version &lt;br /&gt;
! Most recent version &lt;br /&gt;
! Compile &lt;br /&gt;
! Win32 &lt;br /&gt;
! MacOSX &lt;br /&gt;
! *Nix &lt;br /&gt;
! WinCE &lt;br /&gt;
! Where &lt;br /&gt;
! License&amp;lt;br&amp;gt; &lt;br /&gt;
! Comment&lt;br /&gt;
|-&lt;br /&gt;
! libebml &lt;br /&gt;
| 1.2.2&lt;br /&gt;
| 1.2.2 &lt;br /&gt;
| {{up-to-date}}&lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://www.matroska.org/downloads/linux.html matroska.org] &lt;br /&gt;
| LGPLv2.1+&amp;lt;br&amp;gt; &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! libmatroska &lt;br /&gt;
| 1.3.0 &lt;br /&gt;
| 1.3.0 &lt;br /&gt;
| {{up-to-date}}&lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://www.matroska.org/downloads/linux.html matroska.org] &lt;br /&gt;
| LGPLv2.1+&amp;lt;br&amp;gt; &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! libdvbpsi &lt;br /&gt;
| 0.2.2 &lt;br /&gt;
| 0.2.2 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| [http://www.videolan.org/developers/libdvbpsi.html libdvbpsi] &lt;br /&gt;
| LGPLv2.1+&lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
! libmodplug &lt;br /&gt;
| 0.8.8.4 &lt;br /&gt;
| 0.8.8.4 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://modplug-xmms.sourceforge.net/ modplug sur sf.net] &lt;br /&gt;
| Public domain&lt;br /&gt;
|-&lt;br /&gt;
! GME&lt;br /&gt;
| 0.5.5&lt;br /&gt;
| 0.5.5&lt;br /&gt;
| {{up-to-date}}&lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
| [http://code.google.com/p/game-music-emu/downloads/list GME on Google]&lt;br /&gt;
| LGPLv2.1+&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Access  ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin: 1em auto; font-size: smaller; text-align: center; width: 100%;&amp;quot;&lt;br /&gt;
|+ &#039;&#039;&#039;Contrib Status&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
! Contrib lib &lt;br /&gt;
! VLC version &lt;br /&gt;
! Most recent version &lt;br /&gt;
! Compile &lt;br /&gt;
! Win32 &lt;br /&gt;
! MacOSX &lt;br /&gt;
! *Nix &lt;br /&gt;
! WinCE &lt;br /&gt;
! Where&amp;amp;nbsp;? &lt;br /&gt;
! License &lt;br /&gt;
! Comment&lt;br /&gt;
|-&lt;br /&gt;
! shout &lt;br /&gt;
| 2.2.2 &lt;br /&gt;
| 2.2.2 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://www.icecast.org/download.php icecast.org] &lt;br /&gt;
| LGPLv2.1+ &lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
! libdvdcss &lt;br /&gt;
| 1.2.11 &lt;br /&gt;
| 1.2.11&lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://download.videolan.org/pub/libdvdcss/?C=N;O=D libdvdcss on v.o] &lt;br /&gt;
| GPLv2+ &lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
! libdvdread &lt;br /&gt;
| 4.2.0 &lt;br /&gt;
| 4.2.0 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://dvdnav.mplayerhq.hu/ dvd.sf.net] &lt;br /&gt;
| GPLv2+ &lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
! libdvdnav &lt;br /&gt;
| 4.2.0 &lt;br /&gt;
| 4.2.0 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://dvdnav.mplayerhq.hu/ dvd.sf.net] &lt;br /&gt;
| GPLv2+ &lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
! livedotcom &lt;br /&gt;
| latest trunk &lt;br /&gt;
| latest trunk &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| [http://www.live555.com/mediaServer/#downloading live555] &lt;br /&gt;
| LGPLv2.1+ &lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
! libcddb &lt;br /&gt;
| 1.3.2 &lt;br /&gt;
| 1.3.2 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://libcddb.sourceforge.net/download.html libcddb.sf.net] &lt;br /&gt;
| LGPLv2+ &lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
! libcdio &lt;br /&gt;
| 0.80 &lt;br /&gt;
| 0.82 &lt;br /&gt;
| {{Untested}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://ftp.gnu.org/gnu/libcdio/?M=D gnu.org] &lt;br /&gt;
| GPLv2+ &lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
! VCDimager &lt;br /&gt;
| 0.7.23 &lt;br /&gt;
| 0.7.23 &lt;br /&gt;
| {{Up-to-date}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://www.vcdimager.org/pub/vcdimager/vcdimager-0.7/ vcdimager] &lt;br /&gt;
| GPLv2+ &lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
! libgpg-error &lt;br /&gt;
| 1.10&lt;br /&gt;
| 1.10 &lt;br /&gt;
| {{Up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [ftp://ftp.gnupg.org/gcrypt/libgpg-error/ gnupg.org] &lt;br /&gt;
| LGPLv2.1+ &lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
! libgcrypt &lt;br /&gt;
| 1.5.0&lt;br /&gt;
| 1.5.0 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [ftp://ftp.gnupg.org/gcrypt/libgcrypt/ gnupg.org] &lt;br /&gt;
| LGPLv2.1+ &lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
! gnuTLS &lt;br /&gt;
| 2.12.7&lt;br /&gt;
| 2.12.7 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://www.gnu.org/software/gnutls/news.html gnu.org] &lt;br /&gt;
| LGPLv2.1+(core)/GPLv3(extra) &lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
! Opendaap &lt;br /&gt;
| 0.4.0 &lt;br /&gt;
| 0.4.0 &lt;br /&gt;
| {{Up-to-date}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
! libxml2 &lt;br /&gt;
| 2.7.8 &lt;br /&gt;
| 2.7.8 &lt;br /&gt;
| {{Up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [ftp://xmlsoft.org/libxml2/ xmlsoft ftp] &lt;br /&gt;
| MIT License&lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Images  ===&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;margin: 1em auto; font-size: smaller; text-align: center; width: 100%;&amp;quot;&lt;br /&gt;
|+ &#039;&#039;&#039;Contrib Status&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
! Contrib lib &lt;br /&gt;
! VLC version &lt;br /&gt;
! Most recent version &lt;br /&gt;
! Compile &lt;br /&gt;
! Win32 &lt;br /&gt;
! MacOSX &lt;br /&gt;
! *Nix &lt;br /&gt;
! WinCE &lt;br /&gt;
! Where &lt;br /&gt;
! License&amp;lt;br&amp;gt; &lt;br /&gt;
! Comment&lt;br /&gt;
|-&lt;br /&gt;
! libpng &lt;br /&gt;
| 1.5.6&lt;br /&gt;
| 1.5.6 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://www.libpng.org/pub/png/libpng.html libpng.org] &lt;br /&gt;
| Very open license, approaching BSD 2-clause&lt;br /&gt;
|-&lt;br /&gt;
! libjpeg &lt;br /&gt;
| 8c &lt;br /&gt;
| 8c &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://www.ijg.org/files/ ijg.org] &lt;br /&gt;
| 1. We don&#039;t promise that this software works. &lt;br /&gt;
2. You can use this software for whatever you want. You don&#039;t have to pay us.&amp;lt;br&amp;gt; 3. You may not pretend that you wrote this software. If you use it in a program, you must acknowledge somewhere in your documentation that you&#039;ve used the IJG code. &lt;br /&gt;
&lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
! libtiff &lt;br /&gt;
| 3.9.5 &lt;br /&gt;
| 3.9.5 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [ftp://ftp.remotesensing.org/pub/libtiff/ Main libtiff ftp] &lt;br /&gt;
| BSD with Copyright attribution &lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
! SDL &lt;br /&gt;
| 1.2.14 &lt;br /&gt;
| 1.2.14 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://www.libsdl.org/download-1.2.php libsdl.org] &lt;br /&gt;
| LGPLv2.1+&amp;lt;br&amp;gt; &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! SDL_image &lt;br /&gt;
| 1.2.10 &lt;br /&gt;
| 1.2.10 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://www.libsdl.org/projects/SDL_image/ libsdl.org] &lt;br /&gt;
| LGPLv2.1+&amp;lt;br&amp;gt; &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Tools  ===&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;margin: 1em auto; font-size: smaller; text-align: center; width: 100%;&amp;quot; class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ &#039;&#039;&#039;Contrib Status&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
! Contrib lib &lt;br /&gt;
! VLC version &lt;br /&gt;
! Most recent version &lt;br /&gt;
! Compile &lt;br /&gt;
! Win32 &lt;br /&gt;
! MacOSX &lt;br /&gt;
! *Nix &lt;br /&gt;
! WinCE &lt;br /&gt;
! Where&amp;amp;nbsp;! &lt;br /&gt;
! License&amp;lt;br&amp;gt; &lt;br /&gt;
! Comment&lt;br /&gt;
|-&lt;br /&gt;
! Autoconf &lt;br /&gt;
| 2.68 &lt;br /&gt;
| 2.68 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://ftp.gnu.org/gnu/autoconf/?M=D Gnu(slow)] &lt;br /&gt;
| We don&#039;t care&amp;lt;br&amp;gt; &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! automake &lt;br /&gt;
| 1.11 &lt;br /&gt;
| 1.11 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://ftp.gnu.org/gnu/automake/?M=D Gnu(slow)] &lt;br /&gt;
| We don&#039;t care&amp;lt;br&amp;gt; &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! Pkgconfig &lt;br /&gt;
| 0.26 &lt;br /&gt;
| 0.26 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://pkgconfig.freedesktop.org/wiki/ fd.org] &lt;br /&gt;
| We don&#039;t care&amp;lt;br&amp;gt; &lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
! libtool &lt;br /&gt;
| 2.2.10 &lt;br /&gt;
| 2.2.10 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://www.gnu.org/software/libtool/ GNU-libtool] &lt;br /&gt;
| We don&#039;t care&amp;lt;br&amp;gt; &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! libiconv &lt;br /&gt;
| 1.13.1 &lt;br /&gt;
| 1.13.1 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| [http://www.gnu.org/software/libiconv/#downloading Gnu] &lt;br /&gt;
| LGPLv2.0+&amp;lt;br&amp;gt; &lt;br /&gt;
| &lt;br /&gt;
|-&lt;br /&gt;
! gettext &lt;br /&gt;
| 0.18.1.1 &lt;br /&gt;
| 0.18.1.1 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://ftp.gnu.org/gnu/gettext/ Gnu(slow)] &lt;br /&gt;
| LGPLv2.1+&amp;lt;br&amp;gt; &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! freetype2 &lt;br /&gt;
| 2.4.8&lt;br /&gt;
| 2.4.8 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://freetype.org/index2.html freetype.org] &lt;br /&gt;
| FreeType+GPLv2+&amp;lt;br&amp;gt; &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! fribidi &lt;br /&gt;
| 0.19.2 &lt;br /&gt;
| 0.19.2 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://fribidi.org/download/ fribidi.org] &lt;br /&gt;
| LGPLv2.1+&amp;lt;br&amp;gt; &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! zlib &lt;br /&gt;
| 1.2.5 &lt;br /&gt;
| 1.2.5 &lt;br /&gt;
| {{Up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| [http://www.zlib.net/ zlib] &lt;br /&gt;
| Free&amp;lt;br&amp;gt; &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&amp;lt;br&amp;gt;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Others  ===&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;margin: 1em auto; font-size: smaller; text-align: center; width: 100%;&amp;quot; class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ &#039;&#039;&#039;Contrib Status&#039;&#039;&#039; &lt;br /&gt;
|-&lt;br /&gt;
! Contrib lib &lt;br /&gt;
! VLC version &lt;br /&gt;
! Most recent version &lt;br /&gt;
! Compile &lt;br /&gt;
! Win32 &lt;br /&gt;
! MacOSX &lt;br /&gt;
! *Nix &lt;br /&gt;
! WinCE &lt;br /&gt;
! Where &lt;br /&gt;
! License &lt;br /&gt;
! Comment&lt;br /&gt;
|-&lt;br /&gt;
! taglib &lt;br /&gt;
| 1.7 &lt;br /&gt;
| 1.7 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| http://developer.kde.org/~wheeler/taglib.html &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! goom2k4 &lt;br /&gt;
| 2k4-0 &lt;br /&gt;
| 2k4-0 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! projectM &lt;br /&gt;
| 2.0.1 &lt;br /&gt;
| 2.0.1 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}}&lt;br /&gt;
| http://sourceforge.net/projects/projectm/files/&lt;br /&gt;
| LGPLv2.1+&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! libcaca &lt;br /&gt;
| 0.99-beta17 &lt;br /&gt;
| 0.99-beta17 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! Qt &lt;br /&gt;
| 4.3 &lt;br /&gt;
| 4.6 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! portaudio &lt;br /&gt;
| 19 &lt;br /&gt;
| 19 &lt;br /&gt;
| {{up-to-date}} &lt;br /&gt;
| {{Yes}}&amp;lt;br&amp;gt; &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
| Commented for Win32&lt;br /&gt;
|-&lt;br /&gt;
! Upnp &lt;br /&gt;
| 1.6.13 &lt;br /&gt;
| 1.6.13 &lt;br /&gt;
| {{up-to-date}}&lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| http://pupnp.sourceforge.net/ &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! expat &lt;br /&gt;
| 2.0.0 &lt;br /&gt;
| 2.0.1 &lt;br /&gt;
| {{untested}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
| Commented for MacOSX&lt;br /&gt;
|-&lt;br /&gt;
! yasm &lt;br /&gt;
| 1.1.0 &lt;br /&gt;
| 1.1.0 &lt;br /&gt;
| {{untested}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{Needed}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| {{unNeeded}} &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
| For Intel-based Macs&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
! SQLite &lt;br /&gt;
| 3.6 &lt;br /&gt;
| 3.6 &lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
| &amp;lt;br&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
! Contrib lib &lt;br /&gt;
! VLC version &lt;br /&gt;
! Most recent version &lt;br /&gt;
! Compile &lt;br /&gt;
! Win32 &lt;br /&gt;
! MacOSX &lt;br /&gt;
! *Nix &lt;br /&gt;
! WinCE &lt;br /&gt;
! &amp;lt;br&amp;gt;&lt;br /&gt;
! &amp;lt;br&amp;gt;&lt;br /&gt;
! Comment&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Single command installation in Ubuntu  ===&lt;br /&gt;
&lt;br /&gt;
 $ sudo apt-get -y install libvorbis-dev libogg-dev libtheora-dev speex libspeex-dev flac libflac-dev \&lt;br /&gt;
   x264 libx264-dev a52-0.7.4 liba52-0.7.4-dev mpeg2dec libmpeg2-4-dev faad libfaad-dev faac libfaac-dev \&lt;br /&gt;
   lame libmp3lame-dev ffmpeg libavdevice-dev libmad0 libmad0-dev dirac libdirac-dev liboil-dev libschroedinger-dev \&lt;br /&gt;
   libdca-dev twolame libtwolame-dev libmpcdec-dev libvorbisidec1 libvorbisidec-dev libass-dev libass4 libebml2 \&lt;br /&gt;
   libebml-dev libmatroska2 libmatroska-dev libdvbpsi6 libdvbpsi-dev libmodplug1 libmodplug-dev libshout3 libshout3-dev \&lt;br /&gt;
   libdvdread4 libdvdnav4 libdvdnav-dev livemedia-utils liblivemedia-dev libcddb2 libcddb2-dev libcdio10 libcdio-dev \&lt;br /&gt;
   libcdio-utils vcdimager libvcdinfo0 libvcdinfo-dev libgpg-error0 libgpg-error-dev libgcrypt11 libgcrypt11-dev \&lt;br /&gt;
   gnutls-bin libgnutls26 libgnutls-dev libdap10 libdap-bin libdap-dev libxml2 libxml2-dev libpng12-0 libpng12-dev \&lt;br /&gt;
   libjpeg8 libtiff4 libsdl1.2-dev libsdl-image1.2 libsdl-image1.2-dev libc-bin gettext libfreetype6 libfreetype6-dev \&lt;br /&gt;
   libfribidi-dev libfribidi0 zlib1g zlib1g-dev libtag1-dev libcaca0 libcaca-dev caca-utils libqt4-core libqt4-dev \&lt;br /&gt;
   libportaudio2 libportaudio-dev libupnp-dev libupnp4 libupnp3 libexpat1 libexpat1-dev yasm libxcb-xv0 libxcb-xv0-dev \&lt;br /&gt;
   libx11-xcb1 libx11-xcb-dev&lt;br /&gt;
&lt;br /&gt;
[[Category:Coding]] [[Category:Building]] [[Category:Libraries]]&lt;br /&gt;
&lt;br /&gt;
{{Documentation}}&lt;/div&gt;</summary>
		<author><name>Technologicat</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=Hacker_Guide/Video_Filters&amp;diff=21558</id>
		<title>Hacker Guide/Video Filters</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=Hacker_Guide/Video_Filters&amp;diff=21558"/>
		<updated>2012-02-04T16:25:53Z</updated>

		<summary type="html">&lt;p&gt;Technologicat: /* Disclaimer */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is the [[Hacker_Guide|Hacker&#039;s Guide]] for video filters (&#039;&#039;&#039;video filter2&#039;&#039;&#039;, VLC 2.0).&lt;br /&gt;
&lt;br /&gt;
== Location in source tree, compilation ==&lt;br /&gt;
&lt;br /&gt;
The right place for video filters is in the {{VLCSourceFile|name=modules/video_filter/}} folder.&lt;br /&gt;
&lt;br /&gt;
See {{VLCSourceFile|name=modules/video_filter/Modules.am}} for a list of video filters currently in VLC, and which source files belong to which.&lt;br /&gt;
&lt;br /&gt;
See [[Documentation:Hacker&#039;s_Guide/How_To_Write_a_Module#Git_and_Repository_integration|new module integration]] for additional help on how to integrate a new module in the build system.&lt;br /&gt;
&lt;br /&gt;
== Additional documentation ==&lt;br /&gt;
&lt;br /&gt;
Reading [[Documentation:Hacker&#039;s_Guide/How_To_Write_a_Module|How to write a module]] first is highly advised.&lt;br /&gt;
&lt;br /&gt;
Some &#039;&#039;video filters&#039;&#039; may have their own [[Documentation:Hacker&#039;s Guide|Hacker&#039;s Guide]] sections.&lt;br /&gt;
&lt;br /&gt;
Currently, the &#039;&#039;&#039;deinterlace&#039;&#039;&#039; filter has both a [[Documentation:Hacker&#039;s Guide/Video Filters/Deinterlace|Hacker&#039;s Guide section]] and [[Deinterlace|user documentation]] with some useful additional  technical information.&lt;br /&gt;
&lt;br /&gt;
== Programming conventions and tips ==&lt;br /&gt;
&lt;br /&gt;
{{VLC}} [[video filters]] are usually written in C99, like the rest of VLC. Some use C++, like the AtmoLight plugin.&lt;br /&gt;
&lt;br /&gt;
The usual stuff holds here too:&lt;br /&gt;
* Use &#039;&#039;&#039;assert()&#039;&#039;&#039; for checking conditions that, in presence of no bugs, always hold.&lt;br /&gt;
** &#039;&#039;Don&#039;t&#039;&#039; use &#039;&#039;&#039;assert()&#039;&#039;&#039; for checking stuff that may fail at runtime. Handle errors gracefully.&lt;br /&gt;
* Keep your code readable. Make private functions when it simplifies things.&lt;br /&gt;
* Prefer 80 characters per line at maximum, if possible.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Particularly&#039;&#039;&#039; for video filters: keep in mind that this is &#039;&#039;&#039;low-level stuff&#039;&#039;&#039; and needs to be &#039;&#039;&#039;fast&#039;&#039;&#039;.&lt;br /&gt;
* How fast? Note that the source may be interlaced, and someone may have thrown a framerate doubler into the filter chain... this means that for a 60i signal, the entire processing chain from decode to render has about 16ms per output frame.&lt;br /&gt;
* Keep the required memory bandwidth down.&lt;br /&gt;
** Don&#039;t copy whole pictures unless you absolutely must. Moving pixels costs time.&lt;br /&gt;
** Allocate an output picture and render directly into it.&lt;br /&gt;
** If you need more than one pass, do in-place processing in the subsequent ones if possible.&lt;br /&gt;
** If your processing cannot avoid multiple passes, consider doing all passes for a picture line (or a few) at a time, instead of iterating over the whole picture separately for each pass. This will help to keep down the pressure on the CPU cache (since a few picture lines may fit in the L2 cache).&lt;br /&gt;
* Consider writing the inner processing loops in vectorized inline assembly, such as MMX. This can often gain a factor of 2-8x in speed, depending on how much and what kind of processing your algorithm needs.&lt;br /&gt;
&lt;br /&gt;
== Some notes on video filter API ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: See {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.c}} and {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.h}} for an example of everything discussed in this section. See also the [[Documentation:Hacker&#039;s Guide/Video Filters/Deinterlace|Deinterlace Hacker&#039;s Guide]] for some further details.&lt;br /&gt;
&lt;br /&gt;
The video filters use an object-based model. Calls to the filter will come with an instance pointer, so each filter instance can keep local data.&lt;br /&gt;
&lt;br /&gt;
Usually, each filter defines its own internal data structure called &#039;&#039;&#039;filter_sys_t&#039;&#039;&#039;. It is completely private to the filter.&lt;br /&gt;
&lt;br /&gt;
The API for video filters in VLC 1.2 is called &#039;&#039;&#039;video filter2&#039;&#039;&#039;. This requires the functions &#039;&#039;&#039;Open()&#039;&#039;&#039; and &#039;&#039;&#039;Close()&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Open()&#039;&#039;&#039; function is expected to allocate private data (if any), and set up the filter structure with pointers to a frame processing function (&#039;&#039;&#039;p_filter-&amp;gt;pf_video_filter&#039;&#039;&#039;, which is the actual filter), a flush function (&#039;&#039;&#039;p_filter-&amp;gt;pf_video_flush&#039;&#039;&#039;), and a mouse event function (&#039;&#039;&#039;p_filter-&amp;gt;pf_video_mouse&#039;&#039;&#039;). The relevant types are defined in {{VLCSourceFile|name=include/vlc_filter.h}}.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Close()&#039;&#039;&#039; function should deallocate private data.&lt;br /&gt;
&lt;br /&gt;
See [[Documentation:Hacker&#039;s_Guide/How_To_Write_a_Module|How to write a module]] for details about these functions in modules in general.&lt;br /&gt;
&lt;br /&gt;
The mouse function should convert mouse events, from filter output format to filter input format (note the direction!). This is needed when doing scaling or geometrical distortions, so that the mouse position will map correctly. See {{VLCSourceFile|name=include/vlc_filter.h}} for the definition and &#039;&#039;&#039;Mouse()&#039;&#039;&#039; in {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.c}} for an example. If you do not need to remap mouse events, you can leave &#039;&#039;&#039;p_filter-&amp;gt;pf_video_mouse&#039;&#039;&#039; as &#039;&#039;&#039;NULL&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=== Filter work (frame processing function) ===&lt;br /&gt;
The frame processing function takes a frame as input (&#039;&#039;&#039;picture_t*&#039;&#039;&#039;, {{VLCSourceFile|name=include/vlc_picture.h}}), and optionally outputs one or more frames (&#039;&#039;&#039;picture_t*&#039;&#039;&#039;) as a linked list. The usual case is one frame in, one frame out, but this is not a requirement. (See framerate doublers and IVTC in the [[deinterlace]] module for counterexamples.)&lt;br /&gt;
&lt;br /&gt;
If you do not wish to output a frame at a particular call to your processing function, you can return &#039;&#039;&#039;NULL&#039;&#039;&#039;. If you wish to output several, make a linked list by using the &#039;&#039;&#039;p_next&#039;&#039;&#039; member of &#039;&#039;&#039;picture_t&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
You don&#039;t have to necessarily output the &#039;&#039;same&#039;&#039; frame (after processing) that just came in. You can keep a private input frame history in your &#039;&#039;&#039;filter_sys_t&#039;&#039;&#039;, pick the base frame for your output from that, and adjust the PTSs (presentation timestamps, member &#039;&#039;&#039;date&#039;&#039;&#039; in &#039;&#039;&#039;picture_t&#039;&#039;&#039;) of your output as you deem necessary. The deinterlacer provides an example of how to do this.&lt;br /&gt;
&lt;br /&gt;
Note however that there may be other filters in the chain that already set up a frame offset; this leaves less time (until the designated PTS) for the rest of the filters to do their processing.&lt;br /&gt;
&lt;br /&gt;
The input picture coming in to the processing function is considered as owned by the processing function, and should be released before returning. To do this, use&lt;br /&gt;
&amp;lt;pre&amp;gt;picture_Release( p_inpic );&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Frame allocation ===&lt;br /&gt;
Be sure to allocate your output pictures using &amp;lt;pre&amp;gt;picture_t *p_outpic = filter_NewPicture( p_filter );&amp;lt;/pre&amp;gt;&lt;br /&gt;
This function requests a new picture from the private pool (see {{VLCSourceFile|name=src/video_output/vout_wrapper.c}}). This is very important! Be aware that pictures created like&lt;br /&gt;
&amp;lt;pre&amp;gt;picture_t *p_temp = picture_NewFromFormat( &amp;amp;p_input_pic-&amp;gt;format );&amp;lt;/pre&amp;gt;&lt;br /&gt;
lack a shared memory context (in Linux; or the equivalent in other OS), and thus cannot be passed to the video output logic. If your filter attempts to do so, VLC will crash.&lt;br /&gt;
&lt;br /&gt;
If you need temporary pictures, you can allocate those using &#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;, but remember to &#039;&#039;always create output pictures using &#039;&#039;&#039;filter_NewPicture()&#039;&#039;&#039;&#039;&#039;. Here an &#039;&#039;output picture&#039;&#039; is defined as a picture which goes out from the filter to the caller.&lt;br /&gt;
&lt;br /&gt;
There is a limit to the number of simultaneous picture slots available in the private pool. Currently (&amp;lt;nowiki&amp;gt;[71992c5fbc75ee2c94cd2a3ab1aaca70bfc688a9]&amp;lt;/nowiki&amp;gt;) this is 3 pictures for the filter layer. See the constant &#039;&#039;&#039;private_picture&#039;&#039;&#039; in {{VLCSourceFile|name=src/video_output/vout_wrapper.c}}. If you try to allocate more output pictures than this (during a single processing call), the allocation will fail.&lt;br /&gt;
&lt;br /&gt;
=== Notes ===&lt;br /&gt;
* In VLC 1.2, the video format (resolution, chroma) never changes on the fly. The whole filter chain is &#039;&#039;&#039;Close()&#039;&#039;&#039;d and then &#039;&#039;&#039;Open()&#039;&#039;&#039;ed again if the format changes.&lt;br /&gt;
&lt;br /&gt;
* Note that it &#039;&#039;is&#039;&#039; allowed to flush the filter without closing it. This actually happens under some circumstances, so &#039;&#039;don&#039;t deallocate stuff in your flush function&#039;&#039;. Rather, allocate dynamic resources in &#039;&#039;&#039;Open()&#039;&#039;&#039;, and deallocate them in &#039;&#039;&#039;Close()&#039;&#039;&#039; (or in private functions called from those). See [[Documentation:Hacker&#039;s_Guide/How_To_Write_a_Module|How to write a module]].&lt;br /&gt;
&lt;br /&gt;
* Supported input and output formats are decided by each filter. The usual thing is to support [[YUV]] formats, e.g. [[I420]], [[J420]], [[YV12]], [[I422]] and [[J422]]. See {{VLCSourceFile|name=include/vlc_fourcc.h}}. The most important ones to support are [[I420]] and [[I422]].&lt;br /&gt;
&lt;br /&gt;
== Pitch, visible pitch, planes et al. ==&lt;br /&gt;
&lt;br /&gt;
=== Pitch and visible pitch ===&lt;br /&gt;
Important to know:&lt;br /&gt;
&lt;br /&gt;
* i_pitch = number of (macro)pixels on one line&lt;br /&gt;
* i_visible_pitch = number of (macro)pixels on one line, adjusted for memory alignment constraints etc. (see below)&lt;br /&gt;
&lt;br /&gt;
Note that the pitches may be different for each plane, and indeed in YUV formats the luma (&#039;&#039;&#039;Y_PLANE&#039;&#039;&#039;) and chroma (&#039;&#039;&#039;U_PLANE&#039;&#039;&#039;, &#039;&#039;&#039;V_PLANE&#039;&#039;&#039;) have different pitches due to chroma subsampling. (In 4:2:0 formats, the number of lines differs, too.)&lt;br /&gt;
&lt;br /&gt;
Pitches also tend to slightly differ depending on how the picture was allocated, even if the visible size is the same. The input picture to the filter may have one pitch, temporary pictures (&#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;) another, and output pictures (&#039;&#039;&#039;filter_NewPicture()&#039;&#039;&#039;) yet another.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Be sure to always use the correct pitch when you handle the pixels of a picture.&#039;&#039; That is, always use the &#039;&#039;&#039;i_pitch&#039;&#039;&#039; member of the actual &#039;&#039;&#039;plane_t&#039;&#039;&#039; you are working on.&lt;br /&gt;
&lt;br /&gt;
If you absolutely need matching pitches (e.g. if you are glueing in processing code from another GPL-compatible project which assumes this and you don&#039;t want to rewrite it...), consider making temporary copies with &#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;. See {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.c}} (the history mechanism &amp;lt;nowiki&amp;gt;pp_history[]&amp;lt;/nowiki&amp;gt;) and {{VLCSourceFile|name=modules/video_filter/deinterlace/algo_yadif.c}} (its usage) for an example.&lt;br /&gt;
&lt;br /&gt;
If you are processing pixels from one picture to another, the safe thing to do is to take the smallest &#039;&#039;&#039;i_visible_pitch&#039;&#039;&#039;, and loop from x = 0 until the visible pitch has been reached, but use the individual &#039;&#039;&#039;i_pitch&#039;&#039;&#039;es for computing the pixel locations. See {{VLCSourceFile|name=modules/video_filter/deinterlace/helpers.c}} for examples.&lt;br /&gt;
&lt;br /&gt;
=== Video_format_t vs. Plane_t ===&lt;br /&gt;
&lt;br /&gt;
In &#039;&#039;&#039;video_format_t&#039;&#039;&#039;, the &#039;&#039;&#039;i_visible_width&#039;&#039;&#039; and &#039;&#039;&#039;i_visible_height&#039;&#039;&#039; members go with &#039;&#039;&#039;i_x_offset&#039;&#039;&#039; and &#039;&#039;&#039;i_y_offset&#039;&#039;&#039;, but they are not related to &#039;&#039;&#039;plane_t::i_visible_*&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;plane_t::i_visible_*&#039;&#039;&#039; fields are there to know which part of the memory planes can at most be displayed. Usually these are different from the whole surface due to memory alignment constraints (like mod 16 for SSE2 or to be aligned on a macroblock). Those values are decided when the picture is allocated and they usually don&#039;t change for a given picture pointer (but they can change, like in direct3d buffers).&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;video_format_t:i_visible_width/height&#039;&#039;&#039; and &#039;&#039;&#039;i_x/y_offset&#039;&#039;&#039; are more a &#039;hint&#039; regarding what will be actually displayed. A filter should update &#039;&#039;&#039;filter_t::fmt_out&#039;&#039;&#039; if needed to ensure that the allocated pictures get the right value. A filter should, however, not limit its processing to this area, because VLC supports dynamic cropping.&lt;br /&gt;
&lt;br /&gt;
Thus, the correct thing to do in a filter is to process the whole picture area, or at least the first i_visible_* lines and pixels &#039;&#039;according to the &#039;&#039;&#039;plane_t&#039;&#039;&#039;s&#039;&#039;. Filters do not need to care about margin positioning or that there even exists such a thing as margins.&lt;br /&gt;
&lt;br /&gt;
== About creating and merging pictures ==&lt;br /&gt;
&lt;br /&gt;
This section talks about how to create filters which create and merge a picture onto the top of the already existing video.&lt;br /&gt;
&lt;br /&gt;
=== What is the difference between picture_t and subpicture_t? ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;picture_t&#039;&#039;&#039; is a full image, typically a decoded video frame.&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;subpicture_t&#039;&#039;&#039; is an element (to be exact, a list of elements) which can be overlayed on top of an image. Two types of elements exist: text and images. Text elements are rendered by the VLC core before overlay.&lt;br /&gt;
&lt;br /&gt;
=== How to create a picture and merge it with the existing picture? ===&lt;br /&gt;
&lt;br /&gt;
Code-wise the simplest way is to create a video filter of type &#039;&#039;&#039;subpicture source&#039;&#039;&#039; (in VLC 2.0). The task of a &#039;&#039;&#039;subpicture source&#039;&#039;&#039; is to create a &#039;&#039;&#039;subpicture_t&#039;&#039;&#039;, and then let the VLC core deal with blending it on top of the video stream.&lt;br /&gt;
&lt;br /&gt;
Another way is to create a &#039;&#039;&#039;picture_t&#039;&#039;&#039; (e.g. with &#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;) and do the blending yourself. See below.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note&#039;&#039;: in versions of VLC prior to 2.0 (version 1.1 and below), &#039;&#039;&#039;subpicture sources&#039;&#039;&#039; were called &#039;&#039;&#039;subpicture filters&#039;&#039;&#039;. This video filter type has been renamed in order to allow for the creation of actual &#039;&#039;&#039;subpicture filters&#039;&#039;&#039;, which edit (i.e. filter) existing &#039;&#039;&#039;subpicture_t&#039;&#039;&#039;s.&lt;br /&gt;
&lt;br /&gt;
=== What is the simplest example I can look at for writing a filter that does this? ===&lt;br /&gt;
&lt;br /&gt;
Such filters can be found in [http://git.videolan.org/?p=vlc.git;f=modules/video_filter;hb=HEAD modules/video_filter/] and match the capability &#039;&#039;&#039;sub source&#039;&#039;&#039;. Noteworthy examples include:&lt;br /&gt;
&lt;br /&gt;
* {{VLCSourceFile|name=modules/video_filter/logo.c}}: overlay an image on top of the video. Note that this is also implemented as a &#039;&#039;&#039;video filter2&#039;&#039;&#039; which directly edits the &#039;&#039;&#039;picture_t&#039;&#039;&#039;. So that might not be the simplest source to look at. If you wish to take this approach, see also the [[Documentation:Hacker&#039;s Guide/Video Filters/Deinterlace|deinterlace filter]], if you need inline assembler optimized 50/50 blending.&lt;br /&gt;
* {{VLCSourceFile|name=modules/video_filter/marq.c}}: overlay text on top of the video.&lt;br /&gt;
* {{VLCSourceFile|name=modules/video_filter/rss.c}}: overlay text from an RSS stream on top of the video. This one also includes picture elements sometimes which makes it a good example to understand how composite &#039;&#039;&#039;subpicture_t&#039;&#039;&#039; elements can be used.&lt;br /&gt;
&lt;br /&gt;
== Disclaimer ==&lt;br /&gt;
&lt;br /&gt;
The information is mostly based on a few months&#039; hacking on the deinterlacer, with some contributions from fenrir and dionoea.&lt;br /&gt;
&lt;br /&gt;
Please add new relevant stuff to this page as needed.&lt;br /&gt;
&lt;br /&gt;
{{Documentation}}&lt;/div&gt;</summary>
		<author><name>Technologicat</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=Hacker_Guide/Video_Filters&amp;diff=21557</id>
		<title>Hacker Guide/Video Filters</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=Hacker_Guide/Video_Filters&amp;diff=21557"/>
		<updated>2012-02-04T16:23:18Z</updated>

		<summary type="html">&lt;p&gt;Technologicat: /* What is the simplest example I can look at for writing a filter that does this? */  emphasize picture_t&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is the [[Hacker_Guide|Hacker&#039;s Guide]] for video filters (&#039;&#039;&#039;video filter2&#039;&#039;&#039;, VLC 2.0).&lt;br /&gt;
&lt;br /&gt;
== Location in source tree, compilation ==&lt;br /&gt;
&lt;br /&gt;
The right place for video filters is in the {{VLCSourceFile|name=modules/video_filter/}} folder.&lt;br /&gt;
&lt;br /&gt;
See {{VLCSourceFile|name=modules/video_filter/Modules.am}} for a list of video filters currently in VLC, and which source files belong to which.&lt;br /&gt;
&lt;br /&gt;
See [[Documentation:Hacker&#039;s_Guide/How_To_Write_a_Module#Git_and_Repository_integration|new module integration]] for additional help on how to integrate a new module in the build system.&lt;br /&gt;
&lt;br /&gt;
== Additional documentation ==&lt;br /&gt;
&lt;br /&gt;
Reading [[Documentation:Hacker&#039;s_Guide/How_To_Write_a_Module|How to write a module]] first is highly advised.&lt;br /&gt;
&lt;br /&gt;
Some &#039;&#039;video filters&#039;&#039; may have their own [[Documentation:Hacker&#039;s Guide|Hacker&#039;s Guide]] sections.&lt;br /&gt;
&lt;br /&gt;
Currently, the &#039;&#039;&#039;deinterlace&#039;&#039;&#039; filter has both a [[Documentation:Hacker&#039;s Guide/Video Filters/Deinterlace|Hacker&#039;s Guide section]] and [[Deinterlace|user documentation]] with some useful additional  technical information.&lt;br /&gt;
&lt;br /&gt;
== Programming conventions and tips ==&lt;br /&gt;
&lt;br /&gt;
{{VLC}} [[video filters]] are usually written in C99, like the rest of VLC. Some use C++, like the AtmoLight plugin.&lt;br /&gt;
&lt;br /&gt;
The usual stuff holds here too:&lt;br /&gt;
* Use &#039;&#039;&#039;assert()&#039;&#039;&#039; for checking conditions that, in presence of no bugs, always hold.&lt;br /&gt;
** &#039;&#039;Don&#039;t&#039;&#039; use &#039;&#039;&#039;assert()&#039;&#039;&#039; for checking stuff that may fail at runtime. Handle errors gracefully.&lt;br /&gt;
* Keep your code readable. Make private functions when it simplifies things.&lt;br /&gt;
* Prefer 80 characters per line at maximum, if possible.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Particularly&#039;&#039;&#039; for video filters: keep in mind that this is &#039;&#039;&#039;low-level stuff&#039;&#039;&#039; and needs to be &#039;&#039;&#039;fast&#039;&#039;&#039;.&lt;br /&gt;
* How fast? Note that the source may be interlaced, and someone may have thrown a framerate doubler into the filter chain... this means that for a 60i signal, the entire processing chain from decode to render has about 16ms per output frame.&lt;br /&gt;
* Keep the required memory bandwidth down.&lt;br /&gt;
** Don&#039;t copy whole pictures unless you absolutely must. Moving pixels costs time.&lt;br /&gt;
** Allocate an output picture and render directly into it.&lt;br /&gt;
** If you need more than one pass, do in-place processing in the subsequent ones if possible.&lt;br /&gt;
** If your processing cannot avoid multiple passes, consider doing all passes for a picture line (or a few) at a time, instead of iterating over the whole picture separately for each pass. This will help to keep down the pressure on the CPU cache (since a few picture lines may fit in the L2 cache).&lt;br /&gt;
* Consider writing the inner processing loops in vectorized inline assembly, such as MMX. This can often gain a factor of 2-8x in speed, depending on how much and what kind of processing your algorithm needs.&lt;br /&gt;
&lt;br /&gt;
== Some notes on video filter API ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: See {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.c}} and {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.h}} for an example of everything discussed in this section. See also the [[Documentation:Hacker&#039;s Guide/Video Filters/Deinterlace|Deinterlace Hacker&#039;s Guide]] for some further details.&lt;br /&gt;
&lt;br /&gt;
The video filters use an object-based model. Calls to the filter will come with an instance pointer, so each filter instance can keep local data.&lt;br /&gt;
&lt;br /&gt;
Usually, each filter defines its own internal data structure called &#039;&#039;&#039;filter_sys_t&#039;&#039;&#039;. It is completely private to the filter.&lt;br /&gt;
&lt;br /&gt;
The API for video filters in VLC 1.2 is called &#039;&#039;&#039;video filter2&#039;&#039;&#039;. This requires the functions &#039;&#039;&#039;Open()&#039;&#039;&#039; and &#039;&#039;&#039;Close()&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Open()&#039;&#039;&#039; function is expected to allocate private data (if any), and set up the filter structure with pointers to a frame processing function (&#039;&#039;&#039;p_filter-&amp;gt;pf_video_filter&#039;&#039;&#039;, which is the actual filter), a flush function (&#039;&#039;&#039;p_filter-&amp;gt;pf_video_flush&#039;&#039;&#039;), and a mouse event function (&#039;&#039;&#039;p_filter-&amp;gt;pf_video_mouse&#039;&#039;&#039;). The relevant types are defined in {{VLCSourceFile|name=include/vlc_filter.h}}.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Close()&#039;&#039;&#039; function should deallocate private data.&lt;br /&gt;
&lt;br /&gt;
See [[Documentation:Hacker&#039;s_Guide/How_To_Write_a_Module|How to write a module]] for details about these functions in modules in general.&lt;br /&gt;
&lt;br /&gt;
The mouse function should convert mouse events, from filter output format to filter input format (note the direction!). This is needed when doing scaling or geometrical distortions, so that the mouse position will map correctly. See {{VLCSourceFile|name=include/vlc_filter.h}} for the definition and &#039;&#039;&#039;Mouse()&#039;&#039;&#039; in {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.c}} for an example. If you do not need to remap mouse events, you can leave &#039;&#039;&#039;p_filter-&amp;gt;pf_video_mouse&#039;&#039;&#039; as &#039;&#039;&#039;NULL&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=== Filter work (frame processing function) ===&lt;br /&gt;
The frame processing function takes a frame as input (&#039;&#039;&#039;picture_t*&#039;&#039;&#039;, {{VLCSourceFile|name=include/vlc_picture.h}}), and optionally outputs one or more frames (&#039;&#039;&#039;picture_t*&#039;&#039;&#039;) as a linked list. The usual case is one frame in, one frame out, but this is not a requirement. (See framerate doublers and IVTC in the [[deinterlace]] module for counterexamples.)&lt;br /&gt;
&lt;br /&gt;
If you do not wish to output a frame at a particular call to your processing function, you can return &#039;&#039;&#039;NULL&#039;&#039;&#039;. If you wish to output several, make a linked list by using the &#039;&#039;&#039;p_next&#039;&#039;&#039; member of &#039;&#039;&#039;picture_t&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
You don&#039;t have to necessarily output the &#039;&#039;same&#039;&#039; frame (after processing) that just came in. You can keep a private input frame history in your &#039;&#039;&#039;filter_sys_t&#039;&#039;&#039;, pick the base frame for your output from that, and adjust the PTSs (presentation timestamps, member &#039;&#039;&#039;date&#039;&#039;&#039; in &#039;&#039;&#039;picture_t&#039;&#039;&#039;) of your output as you deem necessary. The deinterlacer provides an example of how to do this.&lt;br /&gt;
&lt;br /&gt;
Note however that there may be other filters in the chain that already set up a frame offset; this leaves less time (until the designated PTS) for the rest of the filters to do their processing.&lt;br /&gt;
&lt;br /&gt;
The input picture coming in to the processing function is considered as owned by the processing function, and should be released before returning. To do this, use&lt;br /&gt;
&amp;lt;pre&amp;gt;picture_Release( p_inpic );&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Frame allocation ===&lt;br /&gt;
Be sure to allocate your output pictures using &amp;lt;pre&amp;gt;picture_t *p_outpic = filter_NewPicture( p_filter );&amp;lt;/pre&amp;gt;&lt;br /&gt;
This function requests a new picture from the private pool (see {{VLCSourceFile|name=src/video_output/vout_wrapper.c}}). This is very important! Be aware that pictures created like&lt;br /&gt;
&amp;lt;pre&amp;gt;picture_t *p_temp = picture_NewFromFormat( &amp;amp;p_input_pic-&amp;gt;format );&amp;lt;/pre&amp;gt;&lt;br /&gt;
lack a shared memory context (in Linux; or the equivalent in other OS), and thus cannot be passed to the video output logic. If your filter attempts to do so, VLC will crash.&lt;br /&gt;
&lt;br /&gt;
If you need temporary pictures, you can allocate those using &#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;, but remember to &#039;&#039;always create output pictures using &#039;&#039;&#039;filter_NewPicture()&#039;&#039;&#039;&#039;&#039;. Here an &#039;&#039;output picture&#039;&#039; is defined as a picture which goes out from the filter to the caller.&lt;br /&gt;
&lt;br /&gt;
There is a limit to the number of simultaneous picture slots available in the private pool. Currently (&amp;lt;nowiki&amp;gt;[71992c5fbc75ee2c94cd2a3ab1aaca70bfc688a9]&amp;lt;/nowiki&amp;gt;) this is 3 pictures for the filter layer. See the constant &#039;&#039;&#039;private_picture&#039;&#039;&#039; in {{VLCSourceFile|name=src/video_output/vout_wrapper.c}}. If you try to allocate more output pictures than this (during a single processing call), the allocation will fail.&lt;br /&gt;
&lt;br /&gt;
=== Notes ===&lt;br /&gt;
* In VLC 1.2, the video format (resolution, chroma) never changes on the fly. The whole filter chain is &#039;&#039;&#039;Close()&#039;&#039;&#039;d and then &#039;&#039;&#039;Open()&#039;&#039;&#039;ed again if the format changes.&lt;br /&gt;
&lt;br /&gt;
* Note that it &#039;&#039;is&#039;&#039; allowed to flush the filter without closing it. This actually happens under some circumstances, so &#039;&#039;don&#039;t deallocate stuff in your flush function&#039;&#039;. Rather, allocate dynamic resources in &#039;&#039;&#039;Open()&#039;&#039;&#039;, and deallocate them in &#039;&#039;&#039;Close()&#039;&#039;&#039; (or in private functions called from those). See [[Documentation:Hacker&#039;s_Guide/How_To_Write_a_Module|How to write a module]].&lt;br /&gt;
&lt;br /&gt;
* Supported input and output formats are decided by each filter. The usual thing is to support [[YUV]] formats, e.g. [[I420]], [[J420]], [[YV12]], [[I422]] and [[J422]]. See {{VLCSourceFile|name=include/vlc_fourcc.h}}. The most important ones to support are [[I420]] and [[I422]].&lt;br /&gt;
&lt;br /&gt;
== Pitch, visible pitch, planes et al. ==&lt;br /&gt;
&lt;br /&gt;
=== Pitch and visible pitch ===&lt;br /&gt;
Important to know:&lt;br /&gt;
&lt;br /&gt;
* i_pitch = number of (macro)pixels on one line&lt;br /&gt;
* i_visible_pitch = number of (macro)pixels on one line, adjusted for memory alignment constraints etc. (see below)&lt;br /&gt;
&lt;br /&gt;
Note that the pitches may be different for each plane, and indeed in YUV formats the luma (&#039;&#039;&#039;Y_PLANE&#039;&#039;&#039;) and chroma (&#039;&#039;&#039;U_PLANE&#039;&#039;&#039;, &#039;&#039;&#039;V_PLANE&#039;&#039;&#039;) have different pitches due to chroma subsampling. (In 4:2:0 formats, the number of lines differs, too.)&lt;br /&gt;
&lt;br /&gt;
Pitches also tend to slightly differ depending on how the picture was allocated, even if the visible size is the same. The input picture to the filter may have one pitch, temporary pictures (&#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;) another, and output pictures (&#039;&#039;&#039;filter_NewPicture()&#039;&#039;&#039;) yet another.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Be sure to always use the correct pitch when you handle the pixels of a picture.&#039;&#039; That is, always use the &#039;&#039;&#039;i_pitch&#039;&#039;&#039; member of the actual &#039;&#039;&#039;plane_t&#039;&#039;&#039; you are working on.&lt;br /&gt;
&lt;br /&gt;
If you absolutely need matching pitches (e.g. if you are glueing in processing code from another GPL-compatible project which assumes this and you don&#039;t want to rewrite it...), consider making temporary copies with &#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;. See {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.c}} (the history mechanism &amp;lt;nowiki&amp;gt;pp_history[]&amp;lt;/nowiki&amp;gt;) and {{VLCSourceFile|name=modules/video_filter/deinterlace/algo_yadif.c}} (its usage) for an example.&lt;br /&gt;
&lt;br /&gt;
If you are processing pixels from one picture to another, the safe thing to do is to take the smallest &#039;&#039;&#039;i_visible_pitch&#039;&#039;&#039;, and loop from x = 0 until the visible pitch has been reached, but use the individual &#039;&#039;&#039;i_pitch&#039;&#039;&#039;es for computing the pixel locations. See {{VLCSourceFile|name=modules/video_filter/deinterlace/helpers.c}} for examples.&lt;br /&gt;
&lt;br /&gt;
=== Video_format_t vs. Plane_t ===&lt;br /&gt;
&lt;br /&gt;
In &#039;&#039;&#039;video_format_t&#039;&#039;&#039;, the &#039;&#039;&#039;i_visible_width&#039;&#039;&#039; and &#039;&#039;&#039;i_visible_height&#039;&#039;&#039; members go with &#039;&#039;&#039;i_x_offset&#039;&#039;&#039; and &#039;&#039;&#039;i_y_offset&#039;&#039;&#039;, but they are not related to &#039;&#039;&#039;plane_t::i_visible_*&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;plane_t::i_visible_*&#039;&#039;&#039; fields are there to know which part of the memory planes can at most be displayed. Usually these are different from the whole surface due to memory alignment constraints (like mod 16 for SSE2 or to be aligned on a macroblock). Those values are decided when the picture is allocated and they usually don&#039;t change for a given picture pointer (but they can change, like in direct3d buffers).&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;video_format_t:i_visible_width/height&#039;&#039;&#039; and &#039;&#039;&#039;i_x/y_offset&#039;&#039;&#039; are more a &#039;hint&#039; regarding what will be actually displayed. A filter should update &#039;&#039;&#039;filter_t::fmt_out&#039;&#039;&#039; if needed to ensure that the allocated pictures get the right value. A filter should, however, not limit its processing to this area, because VLC supports dynamic cropping.&lt;br /&gt;
&lt;br /&gt;
Thus, the correct thing to do in a filter is to process the whole picture area, or at least the first i_visible_* lines and pixels &#039;&#039;according to the &#039;&#039;&#039;plane_t&#039;&#039;&#039;s&#039;&#039;. Filters do not need to care about margin positioning or that there even exists such a thing as margins.&lt;br /&gt;
&lt;br /&gt;
== About creating and merging pictures ==&lt;br /&gt;
&lt;br /&gt;
This section talks about how to create filters which create and merge a picture onto the top of the already existing video.&lt;br /&gt;
&lt;br /&gt;
=== What is the difference between picture_t and subpicture_t? ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;picture_t&#039;&#039;&#039; is a full image, typically a decoded video frame.&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;subpicture_t&#039;&#039;&#039; is an element (to be exact, a list of elements) which can be overlayed on top of an image. Two types of elements exist: text and images. Text elements are rendered by the VLC core before overlay.&lt;br /&gt;
&lt;br /&gt;
=== How to create a picture and merge it with the existing picture? ===&lt;br /&gt;
&lt;br /&gt;
Code-wise the simplest way is to create a video filter of type &#039;&#039;&#039;subpicture source&#039;&#039;&#039; (in VLC 2.0). The task of a &#039;&#039;&#039;subpicture source&#039;&#039;&#039; is to create a &#039;&#039;&#039;subpicture_t&#039;&#039;&#039;, and then let the VLC core deal with blending it on top of the video stream.&lt;br /&gt;
&lt;br /&gt;
Another way is to create a &#039;&#039;&#039;picture_t&#039;&#039;&#039; (e.g. with &#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;) and do the blending yourself. See below.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note&#039;&#039;: in versions of VLC prior to 2.0 (version 1.1 and below), &#039;&#039;&#039;subpicture sources&#039;&#039;&#039; were called &#039;&#039;&#039;subpicture filters&#039;&#039;&#039;. This video filter type has been renamed in order to allow for the creation of actual &#039;&#039;&#039;subpicture filters&#039;&#039;&#039;, which edit (i.e. filter) existing &#039;&#039;&#039;subpicture_t&#039;&#039;&#039;s.&lt;br /&gt;
&lt;br /&gt;
=== What is the simplest example I can look at for writing a filter that does this? ===&lt;br /&gt;
&lt;br /&gt;
Such filters can be found in [http://git.videolan.org/?p=vlc.git;f=modules/video_filter;hb=HEAD modules/video_filter/] and match the capability &#039;&#039;&#039;sub source&#039;&#039;&#039;. Noteworthy examples include:&lt;br /&gt;
&lt;br /&gt;
* {{VLCSourceFile|name=modules/video_filter/logo.c}}: overlay an image on top of the video. Note that this is also implemented as a &#039;&#039;&#039;video filter2&#039;&#039;&#039; which directly edits the &#039;&#039;&#039;picture_t&#039;&#039;&#039;. So that might not be the simplest source to look at. If you wish to take this approach, see also the [[Documentation:Hacker&#039;s Guide/Video Filters/Deinterlace|deinterlace filter]], if you need inline assembler optimized 50/50 blending.&lt;br /&gt;
* {{VLCSourceFile|name=modules/video_filter/marq.c}}: overlay text on top of the video.&lt;br /&gt;
* {{VLCSourceFile|name=modules/video_filter/rss.c}}: overlay text from an RSS stream on top of the video. This one also includes picture elements sometimes which makes it a good example to understand how composite &#039;&#039;&#039;subpicture_t&#039;&#039;&#039; elements can be used.&lt;br /&gt;
&lt;br /&gt;
== Disclaimer ==&lt;br /&gt;
&lt;br /&gt;
The information is mostly based on a few months&#039; hacking on the deinterlacer.&lt;br /&gt;
&lt;br /&gt;
This page is still a stub. Please add new relevant stuff.&lt;br /&gt;
&lt;br /&gt;
Also, the stuff that already exists could use better organization and formatting.&lt;br /&gt;
&lt;br /&gt;
{{Documentation}}&lt;/div&gt;</summary>
		<author><name>Technologicat</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=Hacker_Guide/Video_Filters&amp;diff=21556</id>
		<title>Hacker Guide/Video Filters</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=Hacker_Guide/Video_Filters&amp;diff=21556"/>
		<updated>2012-02-04T16:21:02Z</updated>

		<summary type="html">&lt;p&gt;Technologicat: /* What is the simplest example I can look at for writing a filter that does this? */  links for VLC sources&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is the [[Hacker_Guide|Hacker&#039;s Guide]] for video filters (&#039;&#039;&#039;video filter2&#039;&#039;&#039;, VLC 2.0).&lt;br /&gt;
&lt;br /&gt;
== Location in source tree, compilation ==&lt;br /&gt;
&lt;br /&gt;
The right place for video filters is in the {{VLCSourceFile|name=modules/video_filter/}} folder.&lt;br /&gt;
&lt;br /&gt;
See {{VLCSourceFile|name=modules/video_filter/Modules.am}} for a list of video filters currently in VLC, and which source files belong to which.&lt;br /&gt;
&lt;br /&gt;
See [[Documentation:Hacker&#039;s_Guide/How_To_Write_a_Module#Git_and_Repository_integration|new module integration]] for additional help on how to integrate a new module in the build system.&lt;br /&gt;
&lt;br /&gt;
== Additional documentation ==&lt;br /&gt;
&lt;br /&gt;
Reading [[Documentation:Hacker&#039;s_Guide/How_To_Write_a_Module|How to write a module]] first is highly advised.&lt;br /&gt;
&lt;br /&gt;
Some &#039;&#039;video filters&#039;&#039; may have their own [[Documentation:Hacker&#039;s Guide|Hacker&#039;s Guide]] sections.&lt;br /&gt;
&lt;br /&gt;
Currently, the &#039;&#039;&#039;deinterlace&#039;&#039;&#039; filter has both a [[Documentation:Hacker&#039;s Guide/Video Filters/Deinterlace|Hacker&#039;s Guide section]] and [[Deinterlace|user documentation]] with some useful additional  technical information.&lt;br /&gt;
&lt;br /&gt;
== Programming conventions and tips ==&lt;br /&gt;
&lt;br /&gt;
{{VLC}} [[video filters]] are usually written in C99, like the rest of VLC. Some use C++, like the AtmoLight plugin.&lt;br /&gt;
&lt;br /&gt;
The usual stuff holds here too:&lt;br /&gt;
* Use &#039;&#039;&#039;assert()&#039;&#039;&#039; for checking conditions that, in presence of no bugs, always hold.&lt;br /&gt;
** &#039;&#039;Don&#039;t&#039;&#039; use &#039;&#039;&#039;assert()&#039;&#039;&#039; for checking stuff that may fail at runtime. Handle errors gracefully.&lt;br /&gt;
* Keep your code readable. Make private functions when it simplifies things.&lt;br /&gt;
* Prefer 80 characters per line at maximum, if possible.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Particularly&#039;&#039;&#039; for video filters: keep in mind that this is &#039;&#039;&#039;low-level stuff&#039;&#039;&#039; and needs to be &#039;&#039;&#039;fast&#039;&#039;&#039;.&lt;br /&gt;
* How fast? Note that the source may be interlaced, and someone may have thrown a framerate doubler into the filter chain... this means that for a 60i signal, the entire processing chain from decode to render has about 16ms per output frame.&lt;br /&gt;
* Keep the required memory bandwidth down.&lt;br /&gt;
** Don&#039;t copy whole pictures unless you absolutely must. Moving pixels costs time.&lt;br /&gt;
** Allocate an output picture and render directly into it.&lt;br /&gt;
** If you need more than one pass, do in-place processing in the subsequent ones if possible.&lt;br /&gt;
** If your processing cannot avoid multiple passes, consider doing all passes for a picture line (or a few) at a time, instead of iterating over the whole picture separately for each pass. This will help to keep down the pressure on the CPU cache (since a few picture lines may fit in the L2 cache).&lt;br /&gt;
* Consider writing the inner processing loops in vectorized inline assembly, such as MMX. This can often gain a factor of 2-8x in speed, depending on how much and what kind of processing your algorithm needs.&lt;br /&gt;
&lt;br /&gt;
== Some notes on video filter API ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: See {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.c}} and {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.h}} for an example of everything discussed in this section. See also the [[Documentation:Hacker&#039;s Guide/Video Filters/Deinterlace|Deinterlace Hacker&#039;s Guide]] for some further details.&lt;br /&gt;
&lt;br /&gt;
The video filters use an object-based model. Calls to the filter will come with an instance pointer, so each filter instance can keep local data.&lt;br /&gt;
&lt;br /&gt;
Usually, each filter defines its own internal data structure called &#039;&#039;&#039;filter_sys_t&#039;&#039;&#039;. It is completely private to the filter.&lt;br /&gt;
&lt;br /&gt;
The API for video filters in VLC 1.2 is called &#039;&#039;&#039;video filter2&#039;&#039;&#039;. This requires the functions &#039;&#039;&#039;Open()&#039;&#039;&#039; and &#039;&#039;&#039;Close()&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Open()&#039;&#039;&#039; function is expected to allocate private data (if any), and set up the filter structure with pointers to a frame processing function (&#039;&#039;&#039;p_filter-&amp;gt;pf_video_filter&#039;&#039;&#039;, which is the actual filter), a flush function (&#039;&#039;&#039;p_filter-&amp;gt;pf_video_flush&#039;&#039;&#039;), and a mouse event function (&#039;&#039;&#039;p_filter-&amp;gt;pf_video_mouse&#039;&#039;&#039;). The relevant types are defined in {{VLCSourceFile|name=include/vlc_filter.h}}.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Close()&#039;&#039;&#039; function should deallocate private data.&lt;br /&gt;
&lt;br /&gt;
See [[Documentation:Hacker&#039;s_Guide/How_To_Write_a_Module|How to write a module]] for details about these functions in modules in general.&lt;br /&gt;
&lt;br /&gt;
The mouse function should convert mouse events, from filter output format to filter input format (note the direction!). This is needed when doing scaling or geometrical distortions, so that the mouse position will map correctly. See {{VLCSourceFile|name=include/vlc_filter.h}} for the definition and &#039;&#039;&#039;Mouse()&#039;&#039;&#039; in {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.c}} for an example. If you do not need to remap mouse events, you can leave &#039;&#039;&#039;p_filter-&amp;gt;pf_video_mouse&#039;&#039;&#039; as &#039;&#039;&#039;NULL&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=== Filter work (frame processing function) ===&lt;br /&gt;
The frame processing function takes a frame as input (&#039;&#039;&#039;picture_t*&#039;&#039;&#039;, {{VLCSourceFile|name=include/vlc_picture.h}}), and optionally outputs one or more frames (&#039;&#039;&#039;picture_t*&#039;&#039;&#039;) as a linked list. The usual case is one frame in, one frame out, but this is not a requirement. (See framerate doublers and IVTC in the [[deinterlace]] module for counterexamples.)&lt;br /&gt;
&lt;br /&gt;
If you do not wish to output a frame at a particular call to your processing function, you can return &#039;&#039;&#039;NULL&#039;&#039;&#039;. If you wish to output several, make a linked list by using the &#039;&#039;&#039;p_next&#039;&#039;&#039; member of &#039;&#039;&#039;picture_t&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
You don&#039;t have to necessarily output the &#039;&#039;same&#039;&#039; frame (after processing) that just came in. You can keep a private input frame history in your &#039;&#039;&#039;filter_sys_t&#039;&#039;&#039;, pick the base frame for your output from that, and adjust the PTSs (presentation timestamps, member &#039;&#039;&#039;date&#039;&#039;&#039; in &#039;&#039;&#039;picture_t&#039;&#039;&#039;) of your output as you deem necessary. The deinterlacer provides an example of how to do this.&lt;br /&gt;
&lt;br /&gt;
Note however that there may be other filters in the chain that already set up a frame offset; this leaves less time (until the designated PTS) for the rest of the filters to do their processing.&lt;br /&gt;
&lt;br /&gt;
The input picture coming in to the processing function is considered as owned by the processing function, and should be released before returning. To do this, use&lt;br /&gt;
&amp;lt;pre&amp;gt;picture_Release( p_inpic );&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Frame allocation ===&lt;br /&gt;
Be sure to allocate your output pictures using &amp;lt;pre&amp;gt;picture_t *p_outpic = filter_NewPicture( p_filter );&amp;lt;/pre&amp;gt;&lt;br /&gt;
This function requests a new picture from the private pool (see {{VLCSourceFile|name=src/video_output/vout_wrapper.c}}). This is very important! Be aware that pictures created like&lt;br /&gt;
&amp;lt;pre&amp;gt;picture_t *p_temp = picture_NewFromFormat( &amp;amp;p_input_pic-&amp;gt;format );&amp;lt;/pre&amp;gt;&lt;br /&gt;
lack a shared memory context (in Linux; or the equivalent in other OS), and thus cannot be passed to the video output logic. If your filter attempts to do so, VLC will crash.&lt;br /&gt;
&lt;br /&gt;
If you need temporary pictures, you can allocate those using &#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;, but remember to &#039;&#039;always create output pictures using &#039;&#039;&#039;filter_NewPicture()&#039;&#039;&#039;&#039;&#039;. Here an &#039;&#039;output picture&#039;&#039; is defined as a picture which goes out from the filter to the caller.&lt;br /&gt;
&lt;br /&gt;
There is a limit to the number of simultaneous picture slots available in the private pool. Currently (&amp;lt;nowiki&amp;gt;[71992c5fbc75ee2c94cd2a3ab1aaca70bfc688a9]&amp;lt;/nowiki&amp;gt;) this is 3 pictures for the filter layer. See the constant &#039;&#039;&#039;private_picture&#039;&#039;&#039; in {{VLCSourceFile|name=src/video_output/vout_wrapper.c}}. If you try to allocate more output pictures than this (during a single processing call), the allocation will fail.&lt;br /&gt;
&lt;br /&gt;
=== Notes ===&lt;br /&gt;
* In VLC 1.2, the video format (resolution, chroma) never changes on the fly. The whole filter chain is &#039;&#039;&#039;Close()&#039;&#039;&#039;d and then &#039;&#039;&#039;Open()&#039;&#039;&#039;ed again if the format changes.&lt;br /&gt;
&lt;br /&gt;
* Note that it &#039;&#039;is&#039;&#039; allowed to flush the filter without closing it. This actually happens under some circumstances, so &#039;&#039;don&#039;t deallocate stuff in your flush function&#039;&#039;. Rather, allocate dynamic resources in &#039;&#039;&#039;Open()&#039;&#039;&#039;, and deallocate them in &#039;&#039;&#039;Close()&#039;&#039;&#039; (or in private functions called from those). See [[Documentation:Hacker&#039;s_Guide/How_To_Write_a_Module|How to write a module]].&lt;br /&gt;
&lt;br /&gt;
* Supported input and output formats are decided by each filter. The usual thing is to support [[YUV]] formats, e.g. [[I420]], [[J420]], [[YV12]], [[I422]] and [[J422]]. See {{VLCSourceFile|name=include/vlc_fourcc.h}}. The most important ones to support are [[I420]] and [[I422]].&lt;br /&gt;
&lt;br /&gt;
== Pitch, visible pitch, planes et al. ==&lt;br /&gt;
&lt;br /&gt;
=== Pitch and visible pitch ===&lt;br /&gt;
Important to know:&lt;br /&gt;
&lt;br /&gt;
* i_pitch = number of (macro)pixels on one line&lt;br /&gt;
* i_visible_pitch = number of (macro)pixels on one line, adjusted for memory alignment constraints etc. (see below)&lt;br /&gt;
&lt;br /&gt;
Note that the pitches may be different for each plane, and indeed in YUV formats the luma (&#039;&#039;&#039;Y_PLANE&#039;&#039;&#039;) and chroma (&#039;&#039;&#039;U_PLANE&#039;&#039;&#039;, &#039;&#039;&#039;V_PLANE&#039;&#039;&#039;) have different pitches due to chroma subsampling. (In 4:2:0 formats, the number of lines differs, too.)&lt;br /&gt;
&lt;br /&gt;
Pitches also tend to slightly differ depending on how the picture was allocated, even if the visible size is the same. The input picture to the filter may have one pitch, temporary pictures (&#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;) another, and output pictures (&#039;&#039;&#039;filter_NewPicture()&#039;&#039;&#039;) yet another.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Be sure to always use the correct pitch when you handle the pixels of a picture.&#039;&#039; That is, always use the &#039;&#039;&#039;i_pitch&#039;&#039;&#039; member of the actual &#039;&#039;&#039;plane_t&#039;&#039;&#039; you are working on.&lt;br /&gt;
&lt;br /&gt;
If you absolutely need matching pitches (e.g. if you are glueing in processing code from another GPL-compatible project which assumes this and you don&#039;t want to rewrite it...), consider making temporary copies with &#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;. See {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.c}} (the history mechanism &amp;lt;nowiki&amp;gt;pp_history[]&amp;lt;/nowiki&amp;gt;) and {{VLCSourceFile|name=modules/video_filter/deinterlace/algo_yadif.c}} (its usage) for an example.&lt;br /&gt;
&lt;br /&gt;
If you are processing pixels from one picture to another, the safe thing to do is to take the smallest &#039;&#039;&#039;i_visible_pitch&#039;&#039;&#039;, and loop from x = 0 until the visible pitch has been reached, but use the individual &#039;&#039;&#039;i_pitch&#039;&#039;&#039;es for computing the pixel locations. See {{VLCSourceFile|name=modules/video_filter/deinterlace/helpers.c}} for examples.&lt;br /&gt;
&lt;br /&gt;
=== Video_format_t vs. Plane_t ===&lt;br /&gt;
&lt;br /&gt;
In &#039;&#039;&#039;video_format_t&#039;&#039;&#039;, the &#039;&#039;&#039;i_visible_width&#039;&#039;&#039; and &#039;&#039;&#039;i_visible_height&#039;&#039;&#039; members go with &#039;&#039;&#039;i_x_offset&#039;&#039;&#039; and &#039;&#039;&#039;i_y_offset&#039;&#039;&#039;, but they are not related to &#039;&#039;&#039;plane_t::i_visible_*&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;plane_t::i_visible_*&#039;&#039;&#039; fields are there to know which part of the memory planes can at most be displayed. Usually these are different from the whole surface due to memory alignment constraints (like mod 16 for SSE2 or to be aligned on a macroblock). Those values are decided when the picture is allocated and they usually don&#039;t change for a given picture pointer (but they can change, like in direct3d buffers).&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;video_format_t:i_visible_width/height&#039;&#039;&#039; and &#039;&#039;&#039;i_x/y_offset&#039;&#039;&#039; are more a &#039;hint&#039; regarding what will be actually displayed. A filter should update &#039;&#039;&#039;filter_t::fmt_out&#039;&#039;&#039; if needed to ensure that the allocated pictures get the right value. A filter should, however, not limit its processing to this area, because VLC supports dynamic cropping.&lt;br /&gt;
&lt;br /&gt;
Thus, the correct thing to do in a filter is to process the whole picture area, or at least the first i_visible_* lines and pixels &#039;&#039;according to the &#039;&#039;&#039;plane_t&#039;&#039;&#039;s&#039;&#039;. Filters do not need to care about margin positioning or that there even exists such a thing as margins.&lt;br /&gt;
&lt;br /&gt;
== About creating and merging pictures ==&lt;br /&gt;
&lt;br /&gt;
This section talks about how to create filters which create and merge a picture onto the top of the already existing video.&lt;br /&gt;
&lt;br /&gt;
=== What is the difference between picture_t and subpicture_t? ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;picture_t&#039;&#039;&#039; is a full image, typically a decoded video frame.&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;subpicture_t&#039;&#039;&#039; is an element (to be exact, a list of elements) which can be overlayed on top of an image. Two types of elements exist: text and images. Text elements are rendered by the VLC core before overlay.&lt;br /&gt;
&lt;br /&gt;
=== How to create a picture and merge it with the existing picture? ===&lt;br /&gt;
&lt;br /&gt;
Code-wise the simplest way is to create a video filter of type &#039;&#039;&#039;subpicture source&#039;&#039;&#039; (in VLC 2.0). The task of a &#039;&#039;&#039;subpicture source&#039;&#039;&#039; is to create a &#039;&#039;&#039;subpicture_t&#039;&#039;&#039;, and then let the VLC core deal with blending it on top of the video stream.&lt;br /&gt;
&lt;br /&gt;
Another way is to create a &#039;&#039;&#039;picture_t&#039;&#039;&#039; (e.g. with &#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;) and do the blending yourself. See below.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note&#039;&#039;: in versions of VLC prior to 2.0 (version 1.1 and below), &#039;&#039;&#039;subpicture sources&#039;&#039;&#039; were called &#039;&#039;&#039;subpicture filters&#039;&#039;&#039;. This video filter type has been renamed in order to allow for the creation of actual &#039;&#039;&#039;subpicture filters&#039;&#039;&#039;, which edit (i.e. filter) existing &#039;&#039;&#039;subpicture_t&#039;&#039;&#039;s.&lt;br /&gt;
&lt;br /&gt;
=== What is the simplest example I can look at for writing a filter that does this? ===&lt;br /&gt;
&lt;br /&gt;
Such filters can be found in [http://git.videolan.org/?p=vlc.git;f=modules/video_filter;hb=HEAD modules/video_filter/] and match the capability &#039;&#039;&#039;sub source&#039;&#039;&#039;. Noteworthy examples include:&lt;br /&gt;
&lt;br /&gt;
* {{VLCSourceFile|name=modules/video_filter/logo.c}}: overlay an image on top of the video. Note that this is also implemented as a &#039;&#039;&#039;video filter2&#039;&#039;&#039; which directly edits the picture_t. So that might not be the simplest source to look at. If you wish to take this approach, see also the [[Documentation:Hacker&#039;s Guide/Video Filters/Deinterlace|deinterlace filter]], if you need inline assembler optimized 50/50 blending.&lt;br /&gt;
* {{VLCSourceFile|name=modules/video_filter/marq.c}}: overlay text on top of the video.&lt;br /&gt;
* {{VLCSourceFile|name=modules/video_filter/rss.c}}: overlay text from an RSS stream on top of the video. This one also includes picture elements sometimes which makes it a good example to understand how composite &#039;&#039;&#039;subpicture_t&#039;&#039;&#039; elements can be used.&lt;br /&gt;
&lt;br /&gt;
== Disclaimer ==&lt;br /&gt;
&lt;br /&gt;
The information is mostly based on a few months&#039; hacking on the deinterlacer.&lt;br /&gt;
&lt;br /&gt;
This page is still a stub. Please add new relevant stuff.&lt;br /&gt;
&lt;br /&gt;
Also, the stuff that already exists could use better organization and formatting.&lt;br /&gt;
&lt;br /&gt;
{{Documentation}}&lt;/div&gt;</summary>
		<author><name>Technologicat</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=Hacker_Guide/Video_Filters&amp;diff=21555</id>
		<title>Hacker Guide/Video Filters</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=Hacker_Guide/Video_Filters&amp;diff=21555"/>
		<updated>2012-02-04T16:18:48Z</updated>

		<summary type="html">&lt;p&gt;Technologicat: VLC 1.2 -&amp;gt; VLC 2.0&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is the [[Hacker_Guide|Hacker&#039;s Guide]] for video filters (&#039;&#039;&#039;video filter2&#039;&#039;&#039;, VLC 2.0).&lt;br /&gt;
&lt;br /&gt;
== Location in source tree, compilation ==&lt;br /&gt;
&lt;br /&gt;
The right place for video filters is in the {{VLCSourceFile|name=modules/video_filter/}} folder.&lt;br /&gt;
&lt;br /&gt;
See {{VLCSourceFile|name=modules/video_filter/Modules.am}} for a list of video filters currently in VLC, and which source files belong to which.&lt;br /&gt;
&lt;br /&gt;
See [[Documentation:Hacker&#039;s_Guide/How_To_Write_a_Module#Git_and_Repository_integration|new module integration]] for additional help on how to integrate a new module in the build system.&lt;br /&gt;
&lt;br /&gt;
== Additional documentation ==&lt;br /&gt;
&lt;br /&gt;
Reading [[Documentation:Hacker&#039;s_Guide/How_To_Write_a_Module|How to write a module]] first is highly advised.&lt;br /&gt;
&lt;br /&gt;
Some &#039;&#039;video filters&#039;&#039; may have their own [[Documentation:Hacker&#039;s Guide|Hacker&#039;s Guide]] sections.&lt;br /&gt;
&lt;br /&gt;
Currently, the &#039;&#039;&#039;deinterlace&#039;&#039;&#039; filter has both a [[Documentation:Hacker&#039;s Guide/Video Filters/Deinterlace|Hacker&#039;s Guide section]] and [[Deinterlace|user documentation]] with some useful additional  technical information.&lt;br /&gt;
&lt;br /&gt;
== Programming conventions and tips ==&lt;br /&gt;
&lt;br /&gt;
{{VLC}} [[video filters]] are usually written in C99, like the rest of VLC. Some use C++, like the AtmoLight plugin.&lt;br /&gt;
&lt;br /&gt;
The usual stuff holds here too:&lt;br /&gt;
* Use &#039;&#039;&#039;assert()&#039;&#039;&#039; for checking conditions that, in presence of no bugs, always hold.&lt;br /&gt;
** &#039;&#039;Don&#039;t&#039;&#039; use &#039;&#039;&#039;assert()&#039;&#039;&#039; for checking stuff that may fail at runtime. Handle errors gracefully.&lt;br /&gt;
* Keep your code readable. Make private functions when it simplifies things.&lt;br /&gt;
* Prefer 80 characters per line at maximum, if possible.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Particularly&#039;&#039;&#039; for video filters: keep in mind that this is &#039;&#039;&#039;low-level stuff&#039;&#039;&#039; and needs to be &#039;&#039;&#039;fast&#039;&#039;&#039;.&lt;br /&gt;
* How fast? Note that the source may be interlaced, and someone may have thrown a framerate doubler into the filter chain... this means that for a 60i signal, the entire processing chain from decode to render has about 16ms per output frame.&lt;br /&gt;
* Keep the required memory bandwidth down.&lt;br /&gt;
** Don&#039;t copy whole pictures unless you absolutely must. Moving pixels costs time.&lt;br /&gt;
** Allocate an output picture and render directly into it.&lt;br /&gt;
** If you need more than one pass, do in-place processing in the subsequent ones if possible.&lt;br /&gt;
** If your processing cannot avoid multiple passes, consider doing all passes for a picture line (or a few) at a time, instead of iterating over the whole picture separately for each pass. This will help to keep down the pressure on the CPU cache (since a few picture lines may fit in the L2 cache).&lt;br /&gt;
* Consider writing the inner processing loops in vectorized inline assembly, such as MMX. This can often gain a factor of 2-8x in speed, depending on how much and what kind of processing your algorithm needs.&lt;br /&gt;
&lt;br /&gt;
== Some notes on video filter API ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: See {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.c}} and {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.h}} for an example of everything discussed in this section. See also the [[Documentation:Hacker&#039;s Guide/Video Filters/Deinterlace|Deinterlace Hacker&#039;s Guide]] for some further details.&lt;br /&gt;
&lt;br /&gt;
The video filters use an object-based model. Calls to the filter will come with an instance pointer, so each filter instance can keep local data.&lt;br /&gt;
&lt;br /&gt;
Usually, each filter defines its own internal data structure called &#039;&#039;&#039;filter_sys_t&#039;&#039;&#039;. It is completely private to the filter.&lt;br /&gt;
&lt;br /&gt;
The API for video filters in VLC 1.2 is called &#039;&#039;&#039;video filter2&#039;&#039;&#039;. This requires the functions &#039;&#039;&#039;Open()&#039;&#039;&#039; and &#039;&#039;&#039;Close()&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Open()&#039;&#039;&#039; function is expected to allocate private data (if any), and set up the filter structure with pointers to a frame processing function (&#039;&#039;&#039;p_filter-&amp;gt;pf_video_filter&#039;&#039;&#039;, which is the actual filter), a flush function (&#039;&#039;&#039;p_filter-&amp;gt;pf_video_flush&#039;&#039;&#039;), and a mouse event function (&#039;&#039;&#039;p_filter-&amp;gt;pf_video_mouse&#039;&#039;&#039;). The relevant types are defined in {{VLCSourceFile|name=include/vlc_filter.h}}.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Close()&#039;&#039;&#039; function should deallocate private data.&lt;br /&gt;
&lt;br /&gt;
See [[Documentation:Hacker&#039;s_Guide/How_To_Write_a_Module|How to write a module]] for details about these functions in modules in general.&lt;br /&gt;
&lt;br /&gt;
The mouse function should convert mouse events, from filter output format to filter input format (note the direction!). This is needed when doing scaling or geometrical distortions, so that the mouse position will map correctly. See {{VLCSourceFile|name=include/vlc_filter.h}} for the definition and &#039;&#039;&#039;Mouse()&#039;&#039;&#039; in {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.c}} for an example. If you do not need to remap mouse events, you can leave &#039;&#039;&#039;p_filter-&amp;gt;pf_video_mouse&#039;&#039;&#039; as &#039;&#039;&#039;NULL&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=== Filter work (frame processing function) ===&lt;br /&gt;
The frame processing function takes a frame as input (&#039;&#039;&#039;picture_t*&#039;&#039;&#039;, {{VLCSourceFile|name=include/vlc_picture.h}}), and optionally outputs one or more frames (&#039;&#039;&#039;picture_t*&#039;&#039;&#039;) as a linked list. The usual case is one frame in, one frame out, but this is not a requirement. (See framerate doublers and IVTC in the [[deinterlace]] module for counterexamples.)&lt;br /&gt;
&lt;br /&gt;
If you do not wish to output a frame at a particular call to your processing function, you can return &#039;&#039;&#039;NULL&#039;&#039;&#039;. If you wish to output several, make a linked list by using the &#039;&#039;&#039;p_next&#039;&#039;&#039; member of &#039;&#039;&#039;picture_t&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
You don&#039;t have to necessarily output the &#039;&#039;same&#039;&#039; frame (after processing) that just came in. You can keep a private input frame history in your &#039;&#039;&#039;filter_sys_t&#039;&#039;&#039;, pick the base frame for your output from that, and adjust the PTSs (presentation timestamps, member &#039;&#039;&#039;date&#039;&#039;&#039; in &#039;&#039;&#039;picture_t&#039;&#039;&#039;) of your output as you deem necessary. The deinterlacer provides an example of how to do this.&lt;br /&gt;
&lt;br /&gt;
Note however that there may be other filters in the chain that already set up a frame offset; this leaves less time (until the designated PTS) for the rest of the filters to do their processing.&lt;br /&gt;
&lt;br /&gt;
The input picture coming in to the processing function is considered as owned by the processing function, and should be released before returning. To do this, use&lt;br /&gt;
&amp;lt;pre&amp;gt;picture_Release( p_inpic );&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Frame allocation ===&lt;br /&gt;
Be sure to allocate your output pictures using &amp;lt;pre&amp;gt;picture_t *p_outpic = filter_NewPicture( p_filter );&amp;lt;/pre&amp;gt;&lt;br /&gt;
This function requests a new picture from the private pool (see {{VLCSourceFile|name=src/video_output/vout_wrapper.c}}). This is very important! Be aware that pictures created like&lt;br /&gt;
&amp;lt;pre&amp;gt;picture_t *p_temp = picture_NewFromFormat( &amp;amp;p_input_pic-&amp;gt;format );&amp;lt;/pre&amp;gt;&lt;br /&gt;
lack a shared memory context (in Linux; or the equivalent in other OS), and thus cannot be passed to the video output logic. If your filter attempts to do so, VLC will crash.&lt;br /&gt;
&lt;br /&gt;
If you need temporary pictures, you can allocate those using &#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;, but remember to &#039;&#039;always create output pictures using &#039;&#039;&#039;filter_NewPicture()&#039;&#039;&#039;&#039;&#039;. Here an &#039;&#039;output picture&#039;&#039; is defined as a picture which goes out from the filter to the caller.&lt;br /&gt;
&lt;br /&gt;
There is a limit to the number of simultaneous picture slots available in the private pool. Currently (&amp;lt;nowiki&amp;gt;[71992c5fbc75ee2c94cd2a3ab1aaca70bfc688a9]&amp;lt;/nowiki&amp;gt;) this is 3 pictures for the filter layer. See the constant &#039;&#039;&#039;private_picture&#039;&#039;&#039; in {{VLCSourceFile|name=src/video_output/vout_wrapper.c}}. If you try to allocate more output pictures than this (during a single processing call), the allocation will fail.&lt;br /&gt;
&lt;br /&gt;
=== Notes ===&lt;br /&gt;
* In VLC 1.2, the video format (resolution, chroma) never changes on the fly. The whole filter chain is &#039;&#039;&#039;Close()&#039;&#039;&#039;d and then &#039;&#039;&#039;Open()&#039;&#039;&#039;ed again if the format changes.&lt;br /&gt;
&lt;br /&gt;
* Note that it &#039;&#039;is&#039;&#039; allowed to flush the filter without closing it. This actually happens under some circumstances, so &#039;&#039;don&#039;t deallocate stuff in your flush function&#039;&#039;. Rather, allocate dynamic resources in &#039;&#039;&#039;Open()&#039;&#039;&#039;, and deallocate them in &#039;&#039;&#039;Close()&#039;&#039;&#039; (or in private functions called from those). See [[Documentation:Hacker&#039;s_Guide/How_To_Write_a_Module|How to write a module]].&lt;br /&gt;
&lt;br /&gt;
* Supported input and output formats are decided by each filter. The usual thing is to support [[YUV]] formats, e.g. [[I420]], [[J420]], [[YV12]], [[I422]] and [[J422]]. See {{VLCSourceFile|name=include/vlc_fourcc.h}}. The most important ones to support are [[I420]] and [[I422]].&lt;br /&gt;
&lt;br /&gt;
== Pitch, visible pitch, planes et al. ==&lt;br /&gt;
&lt;br /&gt;
=== Pitch and visible pitch ===&lt;br /&gt;
Important to know:&lt;br /&gt;
&lt;br /&gt;
* i_pitch = number of (macro)pixels on one line&lt;br /&gt;
* i_visible_pitch = number of (macro)pixels on one line, adjusted for memory alignment constraints etc. (see below)&lt;br /&gt;
&lt;br /&gt;
Note that the pitches may be different for each plane, and indeed in YUV formats the luma (&#039;&#039;&#039;Y_PLANE&#039;&#039;&#039;) and chroma (&#039;&#039;&#039;U_PLANE&#039;&#039;&#039;, &#039;&#039;&#039;V_PLANE&#039;&#039;&#039;) have different pitches due to chroma subsampling. (In 4:2:0 formats, the number of lines differs, too.)&lt;br /&gt;
&lt;br /&gt;
Pitches also tend to slightly differ depending on how the picture was allocated, even if the visible size is the same. The input picture to the filter may have one pitch, temporary pictures (&#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;) another, and output pictures (&#039;&#039;&#039;filter_NewPicture()&#039;&#039;&#039;) yet another.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Be sure to always use the correct pitch when you handle the pixels of a picture.&#039;&#039; That is, always use the &#039;&#039;&#039;i_pitch&#039;&#039;&#039; member of the actual &#039;&#039;&#039;plane_t&#039;&#039;&#039; you are working on.&lt;br /&gt;
&lt;br /&gt;
If you absolutely need matching pitches (e.g. if you are glueing in processing code from another GPL-compatible project which assumes this and you don&#039;t want to rewrite it...), consider making temporary copies with &#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;. See {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.c}} (the history mechanism &amp;lt;nowiki&amp;gt;pp_history[]&amp;lt;/nowiki&amp;gt;) and {{VLCSourceFile|name=modules/video_filter/deinterlace/algo_yadif.c}} (its usage) for an example.&lt;br /&gt;
&lt;br /&gt;
If you are processing pixels from one picture to another, the safe thing to do is to take the smallest &#039;&#039;&#039;i_visible_pitch&#039;&#039;&#039;, and loop from x = 0 until the visible pitch has been reached, but use the individual &#039;&#039;&#039;i_pitch&#039;&#039;&#039;es for computing the pixel locations. See {{VLCSourceFile|name=modules/video_filter/deinterlace/helpers.c}} for examples.&lt;br /&gt;
&lt;br /&gt;
=== Video_format_t vs. Plane_t ===&lt;br /&gt;
&lt;br /&gt;
In &#039;&#039;&#039;video_format_t&#039;&#039;&#039;, the &#039;&#039;&#039;i_visible_width&#039;&#039;&#039; and &#039;&#039;&#039;i_visible_height&#039;&#039;&#039; members go with &#039;&#039;&#039;i_x_offset&#039;&#039;&#039; and &#039;&#039;&#039;i_y_offset&#039;&#039;&#039;, but they are not related to &#039;&#039;&#039;plane_t::i_visible_*&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;plane_t::i_visible_*&#039;&#039;&#039; fields are there to know which part of the memory planes can at most be displayed. Usually these are different from the whole surface due to memory alignment constraints (like mod 16 for SSE2 or to be aligned on a macroblock). Those values are decided when the picture is allocated and they usually don&#039;t change for a given picture pointer (but they can change, like in direct3d buffers).&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;video_format_t:i_visible_width/height&#039;&#039;&#039; and &#039;&#039;&#039;i_x/y_offset&#039;&#039;&#039; are more a &#039;hint&#039; regarding what will be actually displayed. A filter should update &#039;&#039;&#039;filter_t::fmt_out&#039;&#039;&#039; if needed to ensure that the allocated pictures get the right value. A filter should, however, not limit its processing to this area, because VLC supports dynamic cropping.&lt;br /&gt;
&lt;br /&gt;
Thus, the correct thing to do in a filter is to process the whole picture area, or at least the first i_visible_* lines and pixels &#039;&#039;according to the &#039;&#039;&#039;plane_t&#039;&#039;&#039;s&#039;&#039;. Filters do not need to care about margin positioning or that there even exists such a thing as margins.&lt;br /&gt;
&lt;br /&gt;
== About creating and merging pictures ==&lt;br /&gt;
&lt;br /&gt;
This section talks about how to create filters which create and merge a picture onto the top of the already existing video.&lt;br /&gt;
&lt;br /&gt;
=== What is the difference between picture_t and subpicture_t? ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;picture_t&#039;&#039;&#039; is a full image, typically a decoded video frame.&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;subpicture_t&#039;&#039;&#039; is an element (to be exact, a list of elements) which can be overlayed on top of an image. Two types of elements exist: text and images. Text elements are rendered by the VLC core before overlay.&lt;br /&gt;
&lt;br /&gt;
=== How to create a picture and merge it with the existing picture? ===&lt;br /&gt;
&lt;br /&gt;
Code-wise the simplest way is to create a video filter of type &#039;&#039;&#039;subpicture source&#039;&#039;&#039; (in VLC 2.0). The task of a &#039;&#039;&#039;subpicture source&#039;&#039;&#039; is to create a &#039;&#039;&#039;subpicture_t&#039;&#039;&#039;, and then let the VLC core deal with blending it on top of the video stream.&lt;br /&gt;
&lt;br /&gt;
Another way is to create a &#039;&#039;&#039;picture_t&#039;&#039;&#039; (e.g. with &#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;) and do the blending yourself. See below.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note&#039;&#039;: in versions of VLC prior to 2.0 (version 1.1 and below), &#039;&#039;&#039;subpicture sources&#039;&#039;&#039; were called &#039;&#039;&#039;subpicture filters&#039;&#039;&#039;. This video filter type has been renamed in order to allow for the creation of actual &#039;&#039;&#039;subpicture filters&#039;&#039;&#039;, which edit (i.e. filter) existing &#039;&#039;&#039;subpicture_t&#039;&#039;&#039;s.&lt;br /&gt;
&lt;br /&gt;
=== What is the simplest example I can look at for writing a filter that does this? ===&lt;br /&gt;
&lt;br /&gt;
Such filters can be found in modules/video_filter/ and match the capability &#039;&#039;&#039;sub source&#039;&#039;&#039;. Noteworthy examples include:&lt;br /&gt;
&lt;br /&gt;
* logo.c: overlay an image on top of the video. Note that this is also implemented as a &#039;&#039;&#039;video filter2&#039;&#039;&#039; which directly edits the picture_t. So that might not be the simplest source to look at. If you wish to take this approach, see also the [[Documentation:Hacker&#039;s Guide/Video Filters/Deinterlace|deinterlace filter]], if you need inline assembler optimized 50/50 blending.&lt;br /&gt;
* marq.c: overlay text on top of the video.&lt;br /&gt;
* rss.c: overlay text from an RSS stream on top of the video. This one also includes picture elements sometimes which makes it a good example to understand how composite &#039;&#039;&#039;subpicture_t&#039;&#039;&#039; elements can be used.&lt;br /&gt;
&lt;br /&gt;
== Disclaimer ==&lt;br /&gt;
&lt;br /&gt;
The information is mostly based on a few months&#039; hacking on the deinterlacer.&lt;br /&gt;
&lt;br /&gt;
This page is still a stub. Please add new relevant stuff.&lt;br /&gt;
&lt;br /&gt;
Also, the stuff that already exists could use better organization and formatting.&lt;br /&gt;
&lt;br /&gt;
{{Documentation}}&lt;/div&gt;</summary>
		<author><name>Technologicat</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=Hacker_Guide/Video_Filters&amp;diff=21554</id>
		<title>Hacker Guide/Video Filters</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=Hacker_Guide/Video_Filters&amp;diff=21554"/>
		<updated>2012-02-04T16:17:13Z</updated>

		<summary type="html">&lt;p&gt;Technologicat: /* What is the simplest example I can look at for writing a filter that does this? */  oops, confused different wiki markup syntaxes... list fixed&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is the [[Hacker_Guide|Hacker&#039;s Guide]] for video filters (&#039;&#039;&#039;video filter2&#039;&#039;&#039;, VLC 1.2).&lt;br /&gt;
&lt;br /&gt;
== Location in source tree, compilation ==&lt;br /&gt;
&lt;br /&gt;
The right place for video filters is in the {{VLCSourceFile|name=modules/video_filter/}} folder.&lt;br /&gt;
&lt;br /&gt;
See {{VLCSourceFile|name=modules/video_filter/Modules.am}} for a list of video filters currently in VLC, and which source files belong to which.&lt;br /&gt;
&lt;br /&gt;
See [[Documentation:Hacker&#039;s_Guide/How_To_Write_a_Module#Git_and_Repository_integration|new module integration]] for additional help on how to integrate a new module in the build system.&lt;br /&gt;
&lt;br /&gt;
== Additional documentation ==&lt;br /&gt;
&lt;br /&gt;
Reading [[Documentation:Hacker&#039;s_Guide/How_To_Write_a_Module|How to write a module]] first is highly advised.&lt;br /&gt;
&lt;br /&gt;
Some &#039;&#039;video filters&#039;&#039; may have their own [[Documentation:Hacker&#039;s Guide|Hacker&#039;s Guide]] sections.&lt;br /&gt;
&lt;br /&gt;
Currently, the &#039;&#039;&#039;deinterlace&#039;&#039;&#039; filter has both a [[Documentation:Hacker&#039;s Guide/Video Filters/Deinterlace|Hacker&#039;s Guide section]] and [[Deinterlace|user documentation]] with some useful additional  technical information.&lt;br /&gt;
&lt;br /&gt;
== Programming conventions and tips ==&lt;br /&gt;
&lt;br /&gt;
{{VLC}} [[video filters]] are usually written in C99, like the rest of VLC. Some use C++, like the AtmoLight plugin.&lt;br /&gt;
&lt;br /&gt;
The usual stuff holds here too:&lt;br /&gt;
* Use &#039;&#039;&#039;assert()&#039;&#039;&#039; for checking conditions that, in presence of no bugs, always hold.&lt;br /&gt;
** &#039;&#039;Don&#039;t&#039;&#039; use &#039;&#039;&#039;assert()&#039;&#039;&#039; for checking stuff that may fail at runtime. Handle errors gracefully.&lt;br /&gt;
* Keep your code readable. Make private functions when it simplifies things.&lt;br /&gt;
* Prefer 80 characters per line at maximum, if possible.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Particularly&#039;&#039;&#039; for video filters: keep in mind that this is &#039;&#039;&#039;low-level stuff&#039;&#039;&#039; and needs to be &#039;&#039;&#039;fast&#039;&#039;&#039;.&lt;br /&gt;
* How fast? Note that the source may be interlaced, and someone may have thrown a framerate doubler into the filter chain... this means that for a 60i signal, the entire processing chain from decode to render has about 16ms per output frame.&lt;br /&gt;
* Keep the required memory bandwidth down.&lt;br /&gt;
** Don&#039;t copy whole pictures unless you absolutely must. Moving pixels costs time.&lt;br /&gt;
** Allocate an output picture and render directly into it.&lt;br /&gt;
** If you need more than one pass, do in-place processing in the subsequent ones if possible.&lt;br /&gt;
** If your processing cannot avoid multiple passes, consider doing all passes for a picture line (or a few) at a time, instead of iterating over the whole picture separately for each pass. This will help to keep down the pressure on the CPU cache (since a few picture lines may fit in the L2 cache).&lt;br /&gt;
* Consider writing the inner processing loops in vectorized inline assembly, such as MMX. This can often gain a factor of 2-8x in speed, depending on how much and what kind of processing your algorithm needs.&lt;br /&gt;
&lt;br /&gt;
== Some notes on video filter API ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: See {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.c}} and {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.h}} for an example of everything discussed in this section. See also the [[Documentation:Hacker&#039;s Guide/Video Filters/Deinterlace|Deinterlace Hacker&#039;s Guide]] for some further details.&lt;br /&gt;
&lt;br /&gt;
The video filters use an object-based model. Calls to the filter will come with an instance pointer, so each filter instance can keep local data.&lt;br /&gt;
&lt;br /&gt;
Usually, each filter defines its own internal data structure called &#039;&#039;&#039;filter_sys_t&#039;&#039;&#039;. It is completely private to the filter.&lt;br /&gt;
&lt;br /&gt;
The API for video filters in VLC 1.2 is called &#039;&#039;&#039;video filter2&#039;&#039;&#039;. This requires the functions &#039;&#039;&#039;Open()&#039;&#039;&#039; and &#039;&#039;&#039;Close()&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Open()&#039;&#039;&#039; function is expected to allocate private data (if any), and set up the filter structure with pointers to a frame processing function (&#039;&#039;&#039;p_filter-&amp;gt;pf_video_filter&#039;&#039;&#039;, which is the actual filter), a flush function (&#039;&#039;&#039;p_filter-&amp;gt;pf_video_flush&#039;&#039;&#039;), and a mouse event function (&#039;&#039;&#039;p_filter-&amp;gt;pf_video_mouse&#039;&#039;&#039;). The relevant types are defined in {{VLCSourceFile|name=include/vlc_filter.h}}.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Close()&#039;&#039;&#039; function should deallocate private data.&lt;br /&gt;
&lt;br /&gt;
See [[Documentation:Hacker&#039;s_Guide/How_To_Write_a_Module|How to write a module]] for details about these functions in modules in general.&lt;br /&gt;
&lt;br /&gt;
The mouse function should convert mouse events, from filter output format to filter input format (note the direction!). This is needed when doing scaling or geometrical distortions, so that the mouse position will map correctly. See {{VLCSourceFile|name=include/vlc_filter.h}} for the definition and &#039;&#039;&#039;Mouse()&#039;&#039;&#039; in {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.c}} for an example. If you do not need to remap mouse events, you can leave &#039;&#039;&#039;p_filter-&amp;gt;pf_video_mouse&#039;&#039;&#039; as &#039;&#039;&#039;NULL&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=== Filter work (frame processing function) ===&lt;br /&gt;
The frame processing function takes a frame as input (&#039;&#039;&#039;picture_t*&#039;&#039;&#039;, {{VLCSourceFile|name=include/vlc_picture.h}}), and optionally outputs one or more frames (&#039;&#039;&#039;picture_t*&#039;&#039;&#039;) as a linked list. The usual case is one frame in, one frame out, but this is not a requirement. (See framerate doublers and IVTC in the [[deinterlace]] module for counterexamples.)&lt;br /&gt;
&lt;br /&gt;
If you do not wish to output a frame at a particular call to your processing function, you can return &#039;&#039;&#039;NULL&#039;&#039;&#039;. If you wish to output several, make a linked list by using the &#039;&#039;&#039;p_next&#039;&#039;&#039; member of &#039;&#039;&#039;picture_t&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
You don&#039;t have to necessarily output the &#039;&#039;same&#039;&#039; frame (after processing) that just came in. You can keep a private input frame history in your &#039;&#039;&#039;filter_sys_t&#039;&#039;&#039;, pick the base frame for your output from that, and adjust the PTSs (presentation timestamps, member &#039;&#039;&#039;date&#039;&#039;&#039; in &#039;&#039;&#039;picture_t&#039;&#039;&#039;) of your output as you deem necessary. The deinterlacer provides an example of how to do this.&lt;br /&gt;
&lt;br /&gt;
Note however that there may be other filters in the chain that already set up a frame offset; this leaves less time (until the designated PTS) for the rest of the filters to do their processing.&lt;br /&gt;
&lt;br /&gt;
The input picture coming in to the processing function is considered as owned by the processing function, and should be released before returning. To do this, use&lt;br /&gt;
&amp;lt;pre&amp;gt;picture_Release( p_inpic );&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Frame allocation ===&lt;br /&gt;
Be sure to allocate your output pictures using &amp;lt;pre&amp;gt;picture_t *p_outpic = filter_NewPicture( p_filter );&amp;lt;/pre&amp;gt;&lt;br /&gt;
This function requests a new picture from the private pool (see {{VLCSourceFile|name=src/video_output/vout_wrapper.c}}). This is very important! Be aware that pictures created like&lt;br /&gt;
&amp;lt;pre&amp;gt;picture_t *p_temp = picture_NewFromFormat( &amp;amp;p_input_pic-&amp;gt;format );&amp;lt;/pre&amp;gt;&lt;br /&gt;
lack a shared memory context (in Linux; or the equivalent in other OS), and thus cannot be passed to the video output logic. If your filter attempts to do so, VLC will crash.&lt;br /&gt;
&lt;br /&gt;
If you need temporary pictures, you can allocate those using &#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;, but remember to &#039;&#039;always create output pictures using &#039;&#039;&#039;filter_NewPicture()&#039;&#039;&#039;&#039;&#039;. Here an &#039;&#039;output picture&#039;&#039; is defined as a picture which goes out from the filter to the caller.&lt;br /&gt;
&lt;br /&gt;
There is a limit to the number of simultaneous picture slots available in the private pool. Currently (&amp;lt;nowiki&amp;gt;[71992c5fbc75ee2c94cd2a3ab1aaca70bfc688a9]&amp;lt;/nowiki&amp;gt;) this is 3 pictures for the filter layer. See the constant &#039;&#039;&#039;private_picture&#039;&#039;&#039; in {{VLCSourceFile|name=src/video_output/vout_wrapper.c}}. If you try to allocate more output pictures than this (during a single processing call), the allocation will fail.&lt;br /&gt;
&lt;br /&gt;
=== Notes ===&lt;br /&gt;
* In VLC 1.2, the video format (resolution, chroma) never changes on the fly. The whole filter chain is &#039;&#039;&#039;Close()&#039;&#039;&#039;d and then &#039;&#039;&#039;Open()&#039;&#039;&#039;ed again if the format changes.&lt;br /&gt;
&lt;br /&gt;
* Note that it &#039;&#039;is&#039;&#039; allowed to flush the filter without closing it. This actually happens under some circumstances, so &#039;&#039;don&#039;t deallocate stuff in your flush function&#039;&#039;. Rather, allocate dynamic resources in &#039;&#039;&#039;Open()&#039;&#039;&#039;, and deallocate them in &#039;&#039;&#039;Close()&#039;&#039;&#039; (or in private functions called from those). See [[Documentation:Hacker&#039;s_Guide/How_To_Write_a_Module|How to write a module]].&lt;br /&gt;
&lt;br /&gt;
* Supported input and output formats are decided by each filter. The usual thing is to support [[YUV]] formats, e.g. [[I420]], [[J420]], [[YV12]], [[I422]] and [[J422]]. See {{VLCSourceFile|name=include/vlc_fourcc.h}}. The most important ones to support are [[I420]] and [[I422]].&lt;br /&gt;
&lt;br /&gt;
== Pitch, visible pitch, planes et al. ==&lt;br /&gt;
&lt;br /&gt;
=== Pitch and visible pitch ===&lt;br /&gt;
Important to know:&lt;br /&gt;
&lt;br /&gt;
* i_pitch = number of (macro)pixels on one line&lt;br /&gt;
* i_visible_pitch = number of (macro)pixels on one line, adjusted for memory alignment constraints etc. (see below)&lt;br /&gt;
&lt;br /&gt;
Note that the pitches may be different for each plane, and indeed in YUV formats the luma (&#039;&#039;&#039;Y_PLANE&#039;&#039;&#039;) and chroma (&#039;&#039;&#039;U_PLANE&#039;&#039;&#039;, &#039;&#039;&#039;V_PLANE&#039;&#039;&#039;) have different pitches due to chroma subsampling. (In 4:2:0 formats, the number of lines differs, too.)&lt;br /&gt;
&lt;br /&gt;
Pitches also tend to slightly differ depending on how the picture was allocated, even if the visible size is the same. The input picture to the filter may have one pitch, temporary pictures (&#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;) another, and output pictures (&#039;&#039;&#039;filter_NewPicture()&#039;&#039;&#039;) yet another.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Be sure to always use the correct pitch when you handle the pixels of a picture.&#039;&#039; That is, always use the &#039;&#039;&#039;i_pitch&#039;&#039;&#039; member of the actual &#039;&#039;&#039;plane_t&#039;&#039;&#039; you are working on.&lt;br /&gt;
&lt;br /&gt;
If you absolutely need matching pitches (e.g. if you are glueing in processing code from another GPL-compatible project which assumes this and you don&#039;t want to rewrite it...), consider making temporary copies with &#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;. See {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.c}} (the history mechanism &amp;lt;nowiki&amp;gt;pp_history[]&amp;lt;/nowiki&amp;gt;) and {{VLCSourceFile|name=modules/video_filter/deinterlace/algo_yadif.c}} (its usage) for an example.&lt;br /&gt;
&lt;br /&gt;
If you are processing pixels from one picture to another, the safe thing to do is to take the smallest &#039;&#039;&#039;i_visible_pitch&#039;&#039;&#039;, and loop from x = 0 until the visible pitch has been reached, but use the individual &#039;&#039;&#039;i_pitch&#039;&#039;&#039;es for computing the pixel locations. See {{VLCSourceFile|name=modules/video_filter/deinterlace/helpers.c}} for examples.&lt;br /&gt;
&lt;br /&gt;
=== Video_format_t vs. Plane_t ===&lt;br /&gt;
&lt;br /&gt;
In &#039;&#039;&#039;video_format_t&#039;&#039;&#039;, the &#039;&#039;&#039;i_visible_width&#039;&#039;&#039; and &#039;&#039;&#039;i_visible_height&#039;&#039;&#039; members go with &#039;&#039;&#039;i_x_offset&#039;&#039;&#039; and &#039;&#039;&#039;i_y_offset&#039;&#039;&#039;, but they are not related to &#039;&#039;&#039;plane_t::i_visible_*&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;plane_t::i_visible_*&#039;&#039;&#039; fields are there to know which part of the memory planes can at most be displayed. Usually these are different from the whole surface due to memory alignment constraints (like mod 16 for SSE2 or to be aligned on a macroblock). Those values are decided when the picture is allocated and they usually don&#039;t change for a given picture pointer (but they can change, like in direct3d buffers).&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;video_format_t:i_visible_width/height&#039;&#039;&#039; and &#039;&#039;&#039;i_x/y_offset&#039;&#039;&#039; are more a &#039;hint&#039; regarding what will be actually displayed. A filter should update &#039;&#039;&#039;filter_t::fmt_out&#039;&#039;&#039; if needed to ensure that the allocated pictures get the right value. A filter should, however, not limit its processing to this area, because VLC supports dynamic cropping.&lt;br /&gt;
&lt;br /&gt;
Thus, the correct thing to do in a filter is to process the whole picture area, or at least the first i_visible_* lines and pixels &#039;&#039;according to the &#039;&#039;&#039;plane_t&#039;&#039;&#039;s&#039;&#039;. Filters do not need to care about margin positioning or that there even exists such a thing as margins.&lt;br /&gt;
&lt;br /&gt;
== About creating and merging pictures ==&lt;br /&gt;
&lt;br /&gt;
This section talks about how to create filters which create and merge a picture onto the top of the already existing video.&lt;br /&gt;
&lt;br /&gt;
=== What is the difference between picture_t and subpicture_t? ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;picture_t&#039;&#039;&#039; is a full image, typically a decoded video frame.&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;subpicture_t&#039;&#039;&#039; is an element (to be exact, a list of elements) which can be overlayed on top of an image. Two types of elements exist: text and images. Text elements are rendered by the VLC core before overlay.&lt;br /&gt;
&lt;br /&gt;
=== How to create a picture and merge it with the existing picture? ===&lt;br /&gt;
&lt;br /&gt;
Code-wise the simplest way is to create a video filter of type &#039;&#039;&#039;subpicture source&#039;&#039;&#039; (in VLC 2.0). The task of a &#039;&#039;&#039;subpicture source&#039;&#039;&#039; is to create a &#039;&#039;&#039;subpicture_t&#039;&#039;&#039;, and then let the VLC core deal with blending it on top of the video stream.&lt;br /&gt;
&lt;br /&gt;
Another way is to create a &#039;&#039;&#039;picture_t&#039;&#039;&#039; (e.g. with &#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;) and do the blending yourself. See below.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note&#039;&#039;: in versions of VLC prior to 2.0 (version 1.1 and below), &#039;&#039;&#039;subpicture sources&#039;&#039;&#039; were called &#039;&#039;&#039;subpicture filters&#039;&#039;&#039;. This video filter type has been renamed in order to allow for the creation of actual &#039;&#039;&#039;subpicture filters&#039;&#039;&#039;, which edit (i.e. filter) existing &#039;&#039;&#039;subpicture_t&#039;&#039;&#039;s.&lt;br /&gt;
&lt;br /&gt;
=== What is the simplest example I can look at for writing a filter that does this? ===&lt;br /&gt;
&lt;br /&gt;
Such filters can be found in modules/video_filter/ and match the capability &#039;&#039;&#039;sub source&#039;&#039;&#039;. Noteworthy examples include:&lt;br /&gt;
&lt;br /&gt;
* logo.c: overlay an image on top of the video. Note that this is also implemented as a &#039;&#039;&#039;video filter2&#039;&#039;&#039; which directly edits the picture_t. So that might not be the simplest source to look at. If you wish to take this approach, see also the [[Documentation:Hacker&#039;s Guide/Video Filters/Deinterlace|deinterlace filter]], if you need inline assembler optimized 50/50 blending.&lt;br /&gt;
* marq.c: overlay text on top of the video.&lt;br /&gt;
* rss.c: overlay text from an RSS stream on top of the video. This one also includes picture elements sometimes which makes it a good example to understand how composite &#039;&#039;&#039;subpicture_t&#039;&#039;&#039; elements can be used.&lt;br /&gt;
&lt;br /&gt;
== Disclaimer ==&lt;br /&gt;
&lt;br /&gt;
The information is mostly based on a few months&#039; hacking on the deinterlacer.&lt;br /&gt;
&lt;br /&gt;
This page is still a stub. Please add new relevant stuff.&lt;br /&gt;
&lt;br /&gt;
Also, the stuff that already exists could use better organization and formatting.&lt;br /&gt;
&lt;br /&gt;
{{Documentation}}&lt;/div&gt;</summary>
		<author><name>Technologicat</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=Hacker_Guide/Video_Filters&amp;diff=21553</id>
		<title>Hacker Guide/Video Filters</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=Hacker_Guide/Video_Filters&amp;diff=21553"/>
		<updated>2012-02-04T16:16:02Z</updated>

		<summary type="html">&lt;p&gt;Technologicat: /* How to create a picture and merge it with the existing picture? */ italic note&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is the [[Hacker_Guide|Hacker&#039;s Guide]] for video filters (&#039;&#039;&#039;video filter2&#039;&#039;&#039;, VLC 1.2).&lt;br /&gt;
&lt;br /&gt;
== Location in source tree, compilation ==&lt;br /&gt;
&lt;br /&gt;
The right place for video filters is in the {{VLCSourceFile|name=modules/video_filter/}} folder.&lt;br /&gt;
&lt;br /&gt;
See {{VLCSourceFile|name=modules/video_filter/Modules.am}} for a list of video filters currently in VLC, and which source files belong to which.&lt;br /&gt;
&lt;br /&gt;
See [[Documentation:Hacker&#039;s_Guide/How_To_Write_a_Module#Git_and_Repository_integration|new module integration]] for additional help on how to integrate a new module in the build system.&lt;br /&gt;
&lt;br /&gt;
== Additional documentation ==&lt;br /&gt;
&lt;br /&gt;
Reading [[Documentation:Hacker&#039;s_Guide/How_To_Write_a_Module|How to write a module]] first is highly advised.&lt;br /&gt;
&lt;br /&gt;
Some &#039;&#039;video filters&#039;&#039; may have their own [[Documentation:Hacker&#039;s Guide|Hacker&#039;s Guide]] sections.&lt;br /&gt;
&lt;br /&gt;
Currently, the &#039;&#039;&#039;deinterlace&#039;&#039;&#039; filter has both a [[Documentation:Hacker&#039;s Guide/Video Filters/Deinterlace|Hacker&#039;s Guide section]] and [[Deinterlace|user documentation]] with some useful additional  technical information.&lt;br /&gt;
&lt;br /&gt;
== Programming conventions and tips ==&lt;br /&gt;
&lt;br /&gt;
{{VLC}} [[video filters]] are usually written in C99, like the rest of VLC. Some use C++, like the AtmoLight plugin.&lt;br /&gt;
&lt;br /&gt;
The usual stuff holds here too:&lt;br /&gt;
* Use &#039;&#039;&#039;assert()&#039;&#039;&#039; for checking conditions that, in presence of no bugs, always hold.&lt;br /&gt;
** &#039;&#039;Don&#039;t&#039;&#039; use &#039;&#039;&#039;assert()&#039;&#039;&#039; for checking stuff that may fail at runtime. Handle errors gracefully.&lt;br /&gt;
* Keep your code readable. Make private functions when it simplifies things.&lt;br /&gt;
* Prefer 80 characters per line at maximum, if possible.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Particularly&#039;&#039;&#039; for video filters: keep in mind that this is &#039;&#039;&#039;low-level stuff&#039;&#039;&#039; and needs to be &#039;&#039;&#039;fast&#039;&#039;&#039;.&lt;br /&gt;
* How fast? Note that the source may be interlaced, and someone may have thrown a framerate doubler into the filter chain... this means that for a 60i signal, the entire processing chain from decode to render has about 16ms per output frame.&lt;br /&gt;
* Keep the required memory bandwidth down.&lt;br /&gt;
** Don&#039;t copy whole pictures unless you absolutely must. Moving pixels costs time.&lt;br /&gt;
** Allocate an output picture and render directly into it.&lt;br /&gt;
** If you need more than one pass, do in-place processing in the subsequent ones if possible.&lt;br /&gt;
** If your processing cannot avoid multiple passes, consider doing all passes for a picture line (or a few) at a time, instead of iterating over the whole picture separately for each pass. This will help to keep down the pressure on the CPU cache (since a few picture lines may fit in the L2 cache).&lt;br /&gt;
* Consider writing the inner processing loops in vectorized inline assembly, such as MMX. This can often gain a factor of 2-8x in speed, depending on how much and what kind of processing your algorithm needs.&lt;br /&gt;
&lt;br /&gt;
== Some notes on video filter API ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: See {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.c}} and {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.h}} for an example of everything discussed in this section. See also the [[Documentation:Hacker&#039;s Guide/Video Filters/Deinterlace|Deinterlace Hacker&#039;s Guide]] for some further details.&lt;br /&gt;
&lt;br /&gt;
The video filters use an object-based model. Calls to the filter will come with an instance pointer, so each filter instance can keep local data.&lt;br /&gt;
&lt;br /&gt;
Usually, each filter defines its own internal data structure called &#039;&#039;&#039;filter_sys_t&#039;&#039;&#039;. It is completely private to the filter.&lt;br /&gt;
&lt;br /&gt;
The API for video filters in VLC 1.2 is called &#039;&#039;&#039;video filter2&#039;&#039;&#039;. This requires the functions &#039;&#039;&#039;Open()&#039;&#039;&#039; and &#039;&#039;&#039;Close()&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Open()&#039;&#039;&#039; function is expected to allocate private data (if any), and set up the filter structure with pointers to a frame processing function (&#039;&#039;&#039;p_filter-&amp;gt;pf_video_filter&#039;&#039;&#039;, which is the actual filter), a flush function (&#039;&#039;&#039;p_filter-&amp;gt;pf_video_flush&#039;&#039;&#039;), and a mouse event function (&#039;&#039;&#039;p_filter-&amp;gt;pf_video_mouse&#039;&#039;&#039;). The relevant types are defined in {{VLCSourceFile|name=include/vlc_filter.h}}.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Close()&#039;&#039;&#039; function should deallocate private data.&lt;br /&gt;
&lt;br /&gt;
See [[Documentation:Hacker&#039;s_Guide/How_To_Write_a_Module|How to write a module]] for details about these functions in modules in general.&lt;br /&gt;
&lt;br /&gt;
The mouse function should convert mouse events, from filter output format to filter input format (note the direction!). This is needed when doing scaling or geometrical distortions, so that the mouse position will map correctly. See {{VLCSourceFile|name=include/vlc_filter.h}} for the definition and &#039;&#039;&#039;Mouse()&#039;&#039;&#039; in {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.c}} for an example. If you do not need to remap mouse events, you can leave &#039;&#039;&#039;p_filter-&amp;gt;pf_video_mouse&#039;&#039;&#039; as &#039;&#039;&#039;NULL&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=== Filter work (frame processing function) ===&lt;br /&gt;
The frame processing function takes a frame as input (&#039;&#039;&#039;picture_t*&#039;&#039;&#039;, {{VLCSourceFile|name=include/vlc_picture.h}}), and optionally outputs one or more frames (&#039;&#039;&#039;picture_t*&#039;&#039;&#039;) as a linked list. The usual case is one frame in, one frame out, but this is not a requirement. (See framerate doublers and IVTC in the [[deinterlace]] module for counterexamples.)&lt;br /&gt;
&lt;br /&gt;
If you do not wish to output a frame at a particular call to your processing function, you can return &#039;&#039;&#039;NULL&#039;&#039;&#039;. If you wish to output several, make a linked list by using the &#039;&#039;&#039;p_next&#039;&#039;&#039; member of &#039;&#039;&#039;picture_t&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
You don&#039;t have to necessarily output the &#039;&#039;same&#039;&#039; frame (after processing) that just came in. You can keep a private input frame history in your &#039;&#039;&#039;filter_sys_t&#039;&#039;&#039;, pick the base frame for your output from that, and adjust the PTSs (presentation timestamps, member &#039;&#039;&#039;date&#039;&#039;&#039; in &#039;&#039;&#039;picture_t&#039;&#039;&#039;) of your output as you deem necessary. The deinterlacer provides an example of how to do this.&lt;br /&gt;
&lt;br /&gt;
Note however that there may be other filters in the chain that already set up a frame offset; this leaves less time (until the designated PTS) for the rest of the filters to do their processing.&lt;br /&gt;
&lt;br /&gt;
The input picture coming in to the processing function is considered as owned by the processing function, and should be released before returning. To do this, use&lt;br /&gt;
&amp;lt;pre&amp;gt;picture_Release( p_inpic );&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Frame allocation ===&lt;br /&gt;
Be sure to allocate your output pictures using &amp;lt;pre&amp;gt;picture_t *p_outpic = filter_NewPicture( p_filter );&amp;lt;/pre&amp;gt;&lt;br /&gt;
This function requests a new picture from the private pool (see {{VLCSourceFile|name=src/video_output/vout_wrapper.c}}). This is very important! Be aware that pictures created like&lt;br /&gt;
&amp;lt;pre&amp;gt;picture_t *p_temp = picture_NewFromFormat( &amp;amp;p_input_pic-&amp;gt;format );&amp;lt;/pre&amp;gt;&lt;br /&gt;
lack a shared memory context (in Linux; or the equivalent in other OS), and thus cannot be passed to the video output logic. If your filter attempts to do so, VLC will crash.&lt;br /&gt;
&lt;br /&gt;
If you need temporary pictures, you can allocate those using &#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;, but remember to &#039;&#039;always create output pictures using &#039;&#039;&#039;filter_NewPicture()&#039;&#039;&#039;&#039;&#039;. Here an &#039;&#039;output picture&#039;&#039; is defined as a picture which goes out from the filter to the caller.&lt;br /&gt;
&lt;br /&gt;
There is a limit to the number of simultaneous picture slots available in the private pool. Currently (&amp;lt;nowiki&amp;gt;[71992c5fbc75ee2c94cd2a3ab1aaca70bfc688a9]&amp;lt;/nowiki&amp;gt;) this is 3 pictures for the filter layer. See the constant &#039;&#039;&#039;private_picture&#039;&#039;&#039; in {{VLCSourceFile|name=src/video_output/vout_wrapper.c}}. If you try to allocate more output pictures than this (during a single processing call), the allocation will fail.&lt;br /&gt;
&lt;br /&gt;
=== Notes ===&lt;br /&gt;
* In VLC 1.2, the video format (resolution, chroma) never changes on the fly. The whole filter chain is &#039;&#039;&#039;Close()&#039;&#039;&#039;d and then &#039;&#039;&#039;Open()&#039;&#039;&#039;ed again if the format changes.&lt;br /&gt;
&lt;br /&gt;
* Note that it &#039;&#039;is&#039;&#039; allowed to flush the filter without closing it. This actually happens under some circumstances, so &#039;&#039;don&#039;t deallocate stuff in your flush function&#039;&#039;. Rather, allocate dynamic resources in &#039;&#039;&#039;Open()&#039;&#039;&#039;, and deallocate them in &#039;&#039;&#039;Close()&#039;&#039;&#039; (or in private functions called from those). See [[Documentation:Hacker&#039;s_Guide/How_To_Write_a_Module|How to write a module]].&lt;br /&gt;
&lt;br /&gt;
* Supported input and output formats are decided by each filter. The usual thing is to support [[YUV]] formats, e.g. [[I420]], [[J420]], [[YV12]], [[I422]] and [[J422]]. See {{VLCSourceFile|name=include/vlc_fourcc.h}}. The most important ones to support are [[I420]] and [[I422]].&lt;br /&gt;
&lt;br /&gt;
== Pitch, visible pitch, planes et al. ==&lt;br /&gt;
&lt;br /&gt;
=== Pitch and visible pitch ===&lt;br /&gt;
Important to know:&lt;br /&gt;
&lt;br /&gt;
* i_pitch = number of (macro)pixels on one line&lt;br /&gt;
* i_visible_pitch = number of (macro)pixels on one line, adjusted for memory alignment constraints etc. (see below)&lt;br /&gt;
&lt;br /&gt;
Note that the pitches may be different for each plane, and indeed in YUV formats the luma (&#039;&#039;&#039;Y_PLANE&#039;&#039;&#039;) and chroma (&#039;&#039;&#039;U_PLANE&#039;&#039;&#039;, &#039;&#039;&#039;V_PLANE&#039;&#039;&#039;) have different pitches due to chroma subsampling. (In 4:2:0 formats, the number of lines differs, too.)&lt;br /&gt;
&lt;br /&gt;
Pitches also tend to slightly differ depending on how the picture was allocated, even if the visible size is the same. The input picture to the filter may have one pitch, temporary pictures (&#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;) another, and output pictures (&#039;&#039;&#039;filter_NewPicture()&#039;&#039;&#039;) yet another.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Be sure to always use the correct pitch when you handle the pixels of a picture.&#039;&#039; That is, always use the &#039;&#039;&#039;i_pitch&#039;&#039;&#039; member of the actual &#039;&#039;&#039;plane_t&#039;&#039;&#039; you are working on.&lt;br /&gt;
&lt;br /&gt;
If you absolutely need matching pitches (e.g. if you are glueing in processing code from another GPL-compatible project which assumes this and you don&#039;t want to rewrite it...), consider making temporary copies with &#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;. See {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.c}} (the history mechanism &amp;lt;nowiki&amp;gt;pp_history[]&amp;lt;/nowiki&amp;gt;) and {{VLCSourceFile|name=modules/video_filter/deinterlace/algo_yadif.c}} (its usage) for an example.&lt;br /&gt;
&lt;br /&gt;
If you are processing pixels from one picture to another, the safe thing to do is to take the smallest &#039;&#039;&#039;i_visible_pitch&#039;&#039;&#039;, and loop from x = 0 until the visible pitch has been reached, but use the individual &#039;&#039;&#039;i_pitch&#039;&#039;&#039;es for computing the pixel locations. See {{VLCSourceFile|name=modules/video_filter/deinterlace/helpers.c}} for examples.&lt;br /&gt;
&lt;br /&gt;
=== Video_format_t vs. Plane_t ===&lt;br /&gt;
&lt;br /&gt;
In &#039;&#039;&#039;video_format_t&#039;&#039;&#039;, the &#039;&#039;&#039;i_visible_width&#039;&#039;&#039; and &#039;&#039;&#039;i_visible_height&#039;&#039;&#039; members go with &#039;&#039;&#039;i_x_offset&#039;&#039;&#039; and &#039;&#039;&#039;i_y_offset&#039;&#039;&#039;, but they are not related to &#039;&#039;&#039;plane_t::i_visible_*&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;plane_t::i_visible_*&#039;&#039;&#039; fields are there to know which part of the memory planes can at most be displayed. Usually these are different from the whole surface due to memory alignment constraints (like mod 16 for SSE2 or to be aligned on a macroblock). Those values are decided when the picture is allocated and they usually don&#039;t change for a given picture pointer (but they can change, like in direct3d buffers).&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;video_format_t:i_visible_width/height&#039;&#039;&#039; and &#039;&#039;&#039;i_x/y_offset&#039;&#039;&#039; are more a &#039;hint&#039; regarding what will be actually displayed. A filter should update &#039;&#039;&#039;filter_t::fmt_out&#039;&#039;&#039; if needed to ensure that the allocated pictures get the right value. A filter should, however, not limit its processing to this area, because VLC supports dynamic cropping.&lt;br /&gt;
&lt;br /&gt;
Thus, the correct thing to do in a filter is to process the whole picture area, or at least the first i_visible_* lines and pixels &#039;&#039;according to the &#039;&#039;&#039;plane_t&#039;&#039;&#039;s&#039;&#039;. Filters do not need to care about margin positioning or that there even exists such a thing as margins.&lt;br /&gt;
&lt;br /&gt;
== About creating and merging pictures ==&lt;br /&gt;
&lt;br /&gt;
This section talks about how to create filters which create and merge a picture onto the top of the already existing video.&lt;br /&gt;
&lt;br /&gt;
=== What is the difference between picture_t and subpicture_t? ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;picture_t&#039;&#039;&#039; is a full image, typically a decoded video frame.&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;subpicture_t&#039;&#039;&#039; is an element (to be exact, a list of elements) which can be overlayed on top of an image. Two types of elements exist: text and images. Text elements are rendered by the VLC core before overlay.&lt;br /&gt;
&lt;br /&gt;
=== How to create a picture and merge it with the existing picture? ===&lt;br /&gt;
&lt;br /&gt;
Code-wise the simplest way is to create a video filter of type &#039;&#039;&#039;subpicture source&#039;&#039;&#039; (in VLC 2.0). The task of a &#039;&#039;&#039;subpicture source&#039;&#039;&#039; is to create a &#039;&#039;&#039;subpicture_t&#039;&#039;&#039;, and then let the VLC core deal with blending it on top of the video stream.&lt;br /&gt;
&lt;br /&gt;
Another way is to create a &#039;&#039;&#039;picture_t&#039;&#039;&#039; (e.g. with &#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;) and do the blending yourself. See below.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note&#039;&#039;: in versions of VLC prior to 2.0 (version 1.1 and below), &#039;&#039;&#039;subpicture sources&#039;&#039;&#039; were called &#039;&#039;&#039;subpicture filters&#039;&#039;&#039;. This video filter type has been renamed in order to allow for the creation of actual &#039;&#039;&#039;subpicture filters&#039;&#039;&#039;, which edit (i.e. filter) existing &#039;&#039;&#039;subpicture_t&#039;&#039;&#039;s.&lt;br /&gt;
&lt;br /&gt;
=== What is the simplest example I can look at for writing a filter that does this? ===&lt;br /&gt;
&lt;br /&gt;
Such filters can be found in modules/video_filter/ and match the capability &#039;&#039;&#039;sub source&#039;&#039;&#039;. Noteworthy examples include:&lt;br /&gt;
&lt;br /&gt;
 - logo.c: overlay an image on top of the video. Note that this is also implemented as a &#039;&#039;&#039;video filter2&#039;&#039;&#039; which directly edits the picture_t. So that might not be the simplest source to look at. If you wish to take this approach, see also the [[Documentation:Hacker&#039;s Guide/Video Filters/Deinterlace|deinterlace filter]], if you need inline assembler optimized 50/50 blending.&lt;br /&gt;
 - marq.c: overlay text on top of the video.&lt;br /&gt;
 - rss.c: overlay text from an RSS stream on top of the video. This one also includes picture elements sometimes which makes it a good example to understand how composite &#039;&#039;&#039;subpicture_t&#039;&#039;&#039; elements can be used.&lt;br /&gt;
&lt;br /&gt;
== Disclaimer ==&lt;br /&gt;
&lt;br /&gt;
The information is mostly based on a few months&#039; hacking on the deinterlacer.&lt;br /&gt;
&lt;br /&gt;
This page is still a stub. Please add new relevant stuff.&lt;br /&gt;
&lt;br /&gt;
Also, the stuff that already exists could use better organization and formatting.&lt;br /&gt;
&lt;br /&gt;
{{Documentation}}&lt;/div&gt;</summary>
		<author><name>Technologicat</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=Hacker_Guide/Video_Filters&amp;diff=21552</id>
		<title>Hacker Guide/Video Filters</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=Hacker_Guide/Video_Filters&amp;diff=21552"/>
		<updated>2012-02-04T16:15:22Z</updated>

		<summary type="html">&lt;p&gt;Technologicat: /* About creating and merging pictures (picture_t and subpicture_t) */ section title shortened&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is the [[Hacker_Guide|Hacker&#039;s Guide]] for video filters (&#039;&#039;&#039;video filter2&#039;&#039;&#039;, VLC 1.2).&lt;br /&gt;
&lt;br /&gt;
== Location in source tree, compilation ==&lt;br /&gt;
&lt;br /&gt;
The right place for video filters is in the {{VLCSourceFile|name=modules/video_filter/}} folder.&lt;br /&gt;
&lt;br /&gt;
See {{VLCSourceFile|name=modules/video_filter/Modules.am}} for a list of video filters currently in VLC, and which source files belong to which.&lt;br /&gt;
&lt;br /&gt;
See [[Documentation:Hacker&#039;s_Guide/How_To_Write_a_Module#Git_and_Repository_integration|new module integration]] for additional help on how to integrate a new module in the build system.&lt;br /&gt;
&lt;br /&gt;
== Additional documentation ==&lt;br /&gt;
&lt;br /&gt;
Reading [[Documentation:Hacker&#039;s_Guide/How_To_Write_a_Module|How to write a module]] first is highly advised.&lt;br /&gt;
&lt;br /&gt;
Some &#039;&#039;video filters&#039;&#039; may have their own [[Documentation:Hacker&#039;s Guide|Hacker&#039;s Guide]] sections.&lt;br /&gt;
&lt;br /&gt;
Currently, the &#039;&#039;&#039;deinterlace&#039;&#039;&#039; filter has both a [[Documentation:Hacker&#039;s Guide/Video Filters/Deinterlace|Hacker&#039;s Guide section]] and [[Deinterlace|user documentation]] with some useful additional  technical information.&lt;br /&gt;
&lt;br /&gt;
== Programming conventions and tips ==&lt;br /&gt;
&lt;br /&gt;
{{VLC}} [[video filters]] are usually written in C99, like the rest of VLC. Some use C++, like the AtmoLight plugin.&lt;br /&gt;
&lt;br /&gt;
The usual stuff holds here too:&lt;br /&gt;
* Use &#039;&#039;&#039;assert()&#039;&#039;&#039; for checking conditions that, in presence of no bugs, always hold.&lt;br /&gt;
** &#039;&#039;Don&#039;t&#039;&#039; use &#039;&#039;&#039;assert()&#039;&#039;&#039; for checking stuff that may fail at runtime. Handle errors gracefully.&lt;br /&gt;
* Keep your code readable. Make private functions when it simplifies things.&lt;br /&gt;
* Prefer 80 characters per line at maximum, if possible.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Particularly&#039;&#039;&#039; for video filters: keep in mind that this is &#039;&#039;&#039;low-level stuff&#039;&#039;&#039; and needs to be &#039;&#039;&#039;fast&#039;&#039;&#039;.&lt;br /&gt;
* How fast? Note that the source may be interlaced, and someone may have thrown a framerate doubler into the filter chain... this means that for a 60i signal, the entire processing chain from decode to render has about 16ms per output frame.&lt;br /&gt;
* Keep the required memory bandwidth down.&lt;br /&gt;
** Don&#039;t copy whole pictures unless you absolutely must. Moving pixels costs time.&lt;br /&gt;
** Allocate an output picture and render directly into it.&lt;br /&gt;
** If you need more than one pass, do in-place processing in the subsequent ones if possible.&lt;br /&gt;
** If your processing cannot avoid multiple passes, consider doing all passes for a picture line (or a few) at a time, instead of iterating over the whole picture separately for each pass. This will help to keep down the pressure on the CPU cache (since a few picture lines may fit in the L2 cache).&lt;br /&gt;
* Consider writing the inner processing loops in vectorized inline assembly, such as MMX. This can often gain a factor of 2-8x in speed, depending on how much and what kind of processing your algorithm needs.&lt;br /&gt;
&lt;br /&gt;
== Some notes on video filter API ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: See {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.c}} and {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.h}} for an example of everything discussed in this section. See also the [[Documentation:Hacker&#039;s Guide/Video Filters/Deinterlace|Deinterlace Hacker&#039;s Guide]] for some further details.&lt;br /&gt;
&lt;br /&gt;
The video filters use an object-based model. Calls to the filter will come with an instance pointer, so each filter instance can keep local data.&lt;br /&gt;
&lt;br /&gt;
Usually, each filter defines its own internal data structure called &#039;&#039;&#039;filter_sys_t&#039;&#039;&#039;. It is completely private to the filter.&lt;br /&gt;
&lt;br /&gt;
The API for video filters in VLC 1.2 is called &#039;&#039;&#039;video filter2&#039;&#039;&#039;. This requires the functions &#039;&#039;&#039;Open()&#039;&#039;&#039; and &#039;&#039;&#039;Close()&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Open()&#039;&#039;&#039; function is expected to allocate private data (if any), and set up the filter structure with pointers to a frame processing function (&#039;&#039;&#039;p_filter-&amp;gt;pf_video_filter&#039;&#039;&#039;, which is the actual filter), a flush function (&#039;&#039;&#039;p_filter-&amp;gt;pf_video_flush&#039;&#039;&#039;), and a mouse event function (&#039;&#039;&#039;p_filter-&amp;gt;pf_video_mouse&#039;&#039;&#039;). The relevant types are defined in {{VLCSourceFile|name=include/vlc_filter.h}}.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Close()&#039;&#039;&#039; function should deallocate private data.&lt;br /&gt;
&lt;br /&gt;
See [[Documentation:Hacker&#039;s_Guide/How_To_Write_a_Module|How to write a module]] for details about these functions in modules in general.&lt;br /&gt;
&lt;br /&gt;
The mouse function should convert mouse events, from filter output format to filter input format (note the direction!). This is needed when doing scaling or geometrical distortions, so that the mouse position will map correctly. See {{VLCSourceFile|name=include/vlc_filter.h}} for the definition and &#039;&#039;&#039;Mouse()&#039;&#039;&#039; in {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.c}} for an example. If you do not need to remap mouse events, you can leave &#039;&#039;&#039;p_filter-&amp;gt;pf_video_mouse&#039;&#039;&#039; as &#039;&#039;&#039;NULL&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=== Filter work (frame processing function) ===&lt;br /&gt;
The frame processing function takes a frame as input (&#039;&#039;&#039;picture_t*&#039;&#039;&#039;, {{VLCSourceFile|name=include/vlc_picture.h}}), and optionally outputs one or more frames (&#039;&#039;&#039;picture_t*&#039;&#039;&#039;) as a linked list. The usual case is one frame in, one frame out, but this is not a requirement. (See framerate doublers and IVTC in the [[deinterlace]] module for counterexamples.)&lt;br /&gt;
&lt;br /&gt;
If you do not wish to output a frame at a particular call to your processing function, you can return &#039;&#039;&#039;NULL&#039;&#039;&#039;. If you wish to output several, make a linked list by using the &#039;&#039;&#039;p_next&#039;&#039;&#039; member of &#039;&#039;&#039;picture_t&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
You don&#039;t have to necessarily output the &#039;&#039;same&#039;&#039; frame (after processing) that just came in. You can keep a private input frame history in your &#039;&#039;&#039;filter_sys_t&#039;&#039;&#039;, pick the base frame for your output from that, and adjust the PTSs (presentation timestamps, member &#039;&#039;&#039;date&#039;&#039;&#039; in &#039;&#039;&#039;picture_t&#039;&#039;&#039;) of your output as you deem necessary. The deinterlacer provides an example of how to do this.&lt;br /&gt;
&lt;br /&gt;
Note however that there may be other filters in the chain that already set up a frame offset; this leaves less time (until the designated PTS) for the rest of the filters to do their processing.&lt;br /&gt;
&lt;br /&gt;
The input picture coming in to the processing function is considered as owned by the processing function, and should be released before returning. To do this, use&lt;br /&gt;
&amp;lt;pre&amp;gt;picture_Release( p_inpic );&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Frame allocation ===&lt;br /&gt;
Be sure to allocate your output pictures using &amp;lt;pre&amp;gt;picture_t *p_outpic = filter_NewPicture( p_filter );&amp;lt;/pre&amp;gt;&lt;br /&gt;
This function requests a new picture from the private pool (see {{VLCSourceFile|name=src/video_output/vout_wrapper.c}}). This is very important! Be aware that pictures created like&lt;br /&gt;
&amp;lt;pre&amp;gt;picture_t *p_temp = picture_NewFromFormat( &amp;amp;p_input_pic-&amp;gt;format );&amp;lt;/pre&amp;gt;&lt;br /&gt;
lack a shared memory context (in Linux; or the equivalent in other OS), and thus cannot be passed to the video output logic. If your filter attempts to do so, VLC will crash.&lt;br /&gt;
&lt;br /&gt;
If you need temporary pictures, you can allocate those using &#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;, but remember to &#039;&#039;always create output pictures using &#039;&#039;&#039;filter_NewPicture()&#039;&#039;&#039;&#039;&#039;. Here an &#039;&#039;output picture&#039;&#039; is defined as a picture which goes out from the filter to the caller.&lt;br /&gt;
&lt;br /&gt;
There is a limit to the number of simultaneous picture slots available in the private pool. Currently (&amp;lt;nowiki&amp;gt;[71992c5fbc75ee2c94cd2a3ab1aaca70bfc688a9]&amp;lt;/nowiki&amp;gt;) this is 3 pictures for the filter layer. See the constant &#039;&#039;&#039;private_picture&#039;&#039;&#039; in {{VLCSourceFile|name=src/video_output/vout_wrapper.c}}. If you try to allocate more output pictures than this (during a single processing call), the allocation will fail.&lt;br /&gt;
&lt;br /&gt;
=== Notes ===&lt;br /&gt;
* In VLC 1.2, the video format (resolution, chroma) never changes on the fly. The whole filter chain is &#039;&#039;&#039;Close()&#039;&#039;&#039;d and then &#039;&#039;&#039;Open()&#039;&#039;&#039;ed again if the format changes.&lt;br /&gt;
&lt;br /&gt;
* Note that it &#039;&#039;is&#039;&#039; allowed to flush the filter without closing it. This actually happens under some circumstances, so &#039;&#039;don&#039;t deallocate stuff in your flush function&#039;&#039;. Rather, allocate dynamic resources in &#039;&#039;&#039;Open()&#039;&#039;&#039;, and deallocate them in &#039;&#039;&#039;Close()&#039;&#039;&#039; (or in private functions called from those). See [[Documentation:Hacker&#039;s_Guide/How_To_Write_a_Module|How to write a module]].&lt;br /&gt;
&lt;br /&gt;
* Supported input and output formats are decided by each filter. The usual thing is to support [[YUV]] formats, e.g. [[I420]], [[J420]], [[YV12]], [[I422]] and [[J422]]. See {{VLCSourceFile|name=include/vlc_fourcc.h}}. The most important ones to support are [[I420]] and [[I422]].&lt;br /&gt;
&lt;br /&gt;
== Pitch, visible pitch, planes et al. ==&lt;br /&gt;
&lt;br /&gt;
=== Pitch and visible pitch ===&lt;br /&gt;
Important to know:&lt;br /&gt;
&lt;br /&gt;
* i_pitch = number of (macro)pixels on one line&lt;br /&gt;
* i_visible_pitch = number of (macro)pixels on one line, adjusted for memory alignment constraints etc. (see below)&lt;br /&gt;
&lt;br /&gt;
Note that the pitches may be different for each plane, and indeed in YUV formats the luma (&#039;&#039;&#039;Y_PLANE&#039;&#039;&#039;) and chroma (&#039;&#039;&#039;U_PLANE&#039;&#039;&#039;, &#039;&#039;&#039;V_PLANE&#039;&#039;&#039;) have different pitches due to chroma subsampling. (In 4:2:0 formats, the number of lines differs, too.)&lt;br /&gt;
&lt;br /&gt;
Pitches also tend to slightly differ depending on how the picture was allocated, even if the visible size is the same. The input picture to the filter may have one pitch, temporary pictures (&#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;) another, and output pictures (&#039;&#039;&#039;filter_NewPicture()&#039;&#039;&#039;) yet another.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Be sure to always use the correct pitch when you handle the pixels of a picture.&#039;&#039; That is, always use the &#039;&#039;&#039;i_pitch&#039;&#039;&#039; member of the actual &#039;&#039;&#039;plane_t&#039;&#039;&#039; you are working on.&lt;br /&gt;
&lt;br /&gt;
If you absolutely need matching pitches (e.g. if you are glueing in processing code from another GPL-compatible project which assumes this and you don&#039;t want to rewrite it...), consider making temporary copies with &#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;. See {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.c}} (the history mechanism &amp;lt;nowiki&amp;gt;pp_history[]&amp;lt;/nowiki&amp;gt;) and {{VLCSourceFile|name=modules/video_filter/deinterlace/algo_yadif.c}} (its usage) for an example.&lt;br /&gt;
&lt;br /&gt;
If you are processing pixels from one picture to another, the safe thing to do is to take the smallest &#039;&#039;&#039;i_visible_pitch&#039;&#039;&#039;, and loop from x = 0 until the visible pitch has been reached, but use the individual &#039;&#039;&#039;i_pitch&#039;&#039;&#039;es for computing the pixel locations. See {{VLCSourceFile|name=modules/video_filter/deinterlace/helpers.c}} for examples.&lt;br /&gt;
&lt;br /&gt;
=== Video_format_t vs. Plane_t ===&lt;br /&gt;
&lt;br /&gt;
In &#039;&#039;&#039;video_format_t&#039;&#039;&#039;, the &#039;&#039;&#039;i_visible_width&#039;&#039;&#039; and &#039;&#039;&#039;i_visible_height&#039;&#039;&#039; members go with &#039;&#039;&#039;i_x_offset&#039;&#039;&#039; and &#039;&#039;&#039;i_y_offset&#039;&#039;&#039;, but they are not related to &#039;&#039;&#039;plane_t::i_visible_*&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;plane_t::i_visible_*&#039;&#039;&#039; fields are there to know which part of the memory planes can at most be displayed. Usually these are different from the whole surface due to memory alignment constraints (like mod 16 for SSE2 or to be aligned on a macroblock). Those values are decided when the picture is allocated and they usually don&#039;t change for a given picture pointer (but they can change, like in direct3d buffers).&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;video_format_t:i_visible_width/height&#039;&#039;&#039; and &#039;&#039;&#039;i_x/y_offset&#039;&#039;&#039; are more a &#039;hint&#039; regarding what will be actually displayed. A filter should update &#039;&#039;&#039;filter_t::fmt_out&#039;&#039;&#039; if needed to ensure that the allocated pictures get the right value. A filter should, however, not limit its processing to this area, because VLC supports dynamic cropping.&lt;br /&gt;
&lt;br /&gt;
Thus, the correct thing to do in a filter is to process the whole picture area, or at least the first i_visible_* lines and pixels &#039;&#039;according to the &#039;&#039;&#039;plane_t&#039;&#039;&#039;s&#039;&#039;. Filters do not need to care about margin positioning or that there even exists such a thing as margins.&lt;br /&gt;
&lt;br /&gt;
== About creating and merging pictures ==&lt;br /&gt;
&lt;br /&gt;
This section talks about how to create filters which create and merge a picture onto the top of the already existing video.&lt;br /&gt;
&lt;br /&gt;
=== What is the difference between picture_t and subpicture_t? ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;picture_t&#039;&#039;&#039; is a full image, typically a decoded video frame.&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;subpicture_t&#039;&#039;&#039; is an element (to be exact, a list of elements) which can be overlayed on top of an image. Two types of elements exist: text and images. Text elements are rendered by the VLC core before overlay.&lt;br /&gt;
&lt;br /&gt;
=== How to create a picture and merge it with the existing picture? ===&lt;br /&gt;
&lt;br /&gt;
Code-wise the simplest way is to create a video filter of type &#039;&#039;&#039;subpicture source&#039;&#039;&#039; (in VLC 2.0). The task of a &#039;&#039;&#039;subpicture source&#039;&#039;&#039; is to create a &#039;&#039;&#039;subpicture_t&#039;&#039;&#039;, and then let the VLC core deal with blending it on top of the video stream.&lt;br /&gt;
&lt;br /&gt;
Another way is to create a &#039;&#039;&#039;picture_t&#039;&#039;&#039; (e.g. with &#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;) and do the blending yourself. See below.&lt;br /&gt;
&lt;br /&gt;
Note: in versions of VLC prior to 2.0 (version 1.1 and below), &#039;&#039;&#039;subpicture sources&#039;&#039;&#039; were called &#039;&#039;&#039;subpicture filters&#039;&#039;&#039;. This video filter type has been renamed in order to allow for the creation of actual &#039;&#039;&#039;subpicture filters&#039;&#039;&#039;, which edit (i.e. filter) existing &#039;&#039;&#039;subpicture_t&#039;&#039;&#039;s.&lt;br /&gt;
&lt;br /&gt;
=== What is the simplest example I can look at for writing a filter that does this? ===&lt;br /&gt;
&lt;br /&gt;
Such filters can be found in modules/video_filter/ and match the capability &#039;&#039;&#039;sub source&#039;&#039;&#039;. Noteworthy examples include:&lt;br /&gt;
&lt;br /&gt;
 - logo.c: overlay an image on top of the video. Note that this is also implemented as a &#039;&#039;&#039;video filter2&#039;&#039;&#039; which directly edits the picture_t. So that might not be the simplest source to look at. If you wish to take this approach, see also the [[Documentation:Hacker&#039;s Guide/Video Filters/Deinterlace|deinterlace filter]], if you need inline assembler optimized 50/50 blending.&lt;br /&gt;
 - marq.c: overlay text on top of the video.&lt;br /&gt;
 - rss.c: overlay text from an RSS stream on top of the video. This one also includes picture elements sometimes which makes it a good example to understand how composite &#039;&#039;&#039;subpicture_t&#039;&#039;&#039; elements can be used.&lt;br /&gt;
&lt;br /&gt;
== Disclaimer ==&lt;br /&gt;
&lt;br /&gt;
The information is mostly based on a few months&#039; hacking on the deinterlacer.&lt;br /&gt;
&lt;br /&gt;
This page is still a stub. Please add new relevant stuff.&lt;br /&gt;
&lt;br /&gt;
Also, the stuff that already exists could use better organization and formatting.&lt;br /&gt;
&lt;br /&gt;
{{Documentation}}&lt;/div&gt;</summary>
		<author><name>Technologicat</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=Hacker_Guide/Video_Filters&amp;diff=21551</id>
		<title>Hacker Guide/Video Filters</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=Hacker_Guide/Video_Filters&amp;diff=21551"/>
		<updated>2012-02-04T16:14:48Z</updated>

		<summary type="html">&lt;p&gt;Technologicat: Added section on picture_t and subpicture_t, courtesy of dionoea&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is the [[Hacker_Guide|Hacker&#039;s Guide]] for video filters (&#039;&#039;&#039;video filter2&#039;&#039;&#039;, VLC 1.2).&lt;br /&gt;
&lt;br /&gt;
== Location in source tree, compilation ==&lt;br /&gt;
&lt;br /&gt;
The right place for video filters is in the {{VLCSourceFile|name=modules/video_filter/}} folder.&lt;br /&gt;
&lt;br /&gt;
See {{VLCSourceFile|name=modules/video_filter/Modules.am}} for a list of video filters currently in VLC, and which source files belong to which.&lt;br /&gt;
&lt;br /&gt;
See [[Documentation:Hacker&#039;s_Guide/How_To_Write_a_Module#Git_and_Repository_integration|new module integration]] for additional help on how to integrate a new module in the build system.&lt;br /&gt;
&lt;br /&gt;
== Additional documentation ==&lt;br /&gt;
&lt;br /&gt;
Reading [[Documentation:Hacker&#039;s_Guide/How_To_Write_a_Module|How to write a module]] first is highly advised.&lt;br /&gt;
&lt;br /&gt;
Some &#039;&#039;video filters&#039;&#039; may have their own [[Documentation:Hacker&#039;s Guide|Hacker&#039;s Guide]] sections.&lt;br /&gt;
&lt;br /&gt;
Currently, the &#039;&#039;&#039;deinterlace&#039;&#039;&#039; filter has both a [[Documentation:Hacker&#039;s Guide/Video Filters/Deinterlace|Hacker&#039;s Guide section]] and [[Deinterlace|user documentation]] with some useful additional  technical information.&lt;br /&gt;
&lt;br /&gt;
== Programming conventions and tips ==&lt;br /&gt;
&lt;br /&gt;
{{VLC}} [[video filters]] are usually written in C99, like the rest of VLC. Some use C++, like the AtmoLight plugin.&lt;br /&gt;
&lt;br /&gt;
The usual stuff holds here too:&lt;br /&gt;
* Use &#039;&#039;&#039;assert()&#039;&#039;&#039; for checking conditions that, in presence of no bugs, always hold.&lt;br /&gt;
** &#039;&#039;Don&#039;t&#039;&#039; use &#039;&#039;&#039;assert()&#039;&#039;&#039; for checking stuff that may fail at runtime. Handle errors gracefully.&lt;br /&gt;
* Keep your code readable. Make private functions when it simplifies things.&lt;br /&gt;
* Prefer 80 characters per line at maximum, if possible.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Particularly&#039;&#039;&#039; for video filters: keep in mind that this is &#039;&#039;&#039;low-level stuff&#039;&#039;&#039; and needs to be &#039;&#039;&#039;fast&#039;&#039;&#039;.&lt;br /&gt;
* How fast? Note that the source may be interlaced, and someone may have thrown a framerate doubler into the filter chain... this means that for a 60i signal, the entire processing chain from decode to render has about 16ms per output frame.&lt;br /&gt;
* Keep the required memory bandwidth down.&lt;br /&gt;
** Don&#039;t copy whole pictures unless you absolutely must. Moving pixels costs time.&lt;br /&gt;
** Allocate an output picture and render directly into it.&lt;br /&gt;
** If you need more than one pass, do in-place processing in the subsequent ones if possible.&lt;br /&gt;
** If your processing cannot avoid multiple passes, consider doing all passes for a picture line (or a few) at a time, instead of iterating over the whole picture separately for each pass. This will help to keep down the pressure on the CPU cache (since a few picture lines may fit in the L2 cache).&lt;br /&gt;
* Consider writing the inner processing loops in vectorized inline assembly, such as MMX. This can often gain a factor of 2-8x in speed, depending on how much and what kind of processing your algorithm needs.&lt;br /&gt;
&lt;br /&gt;
== Some notes on video filter API ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: See {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.c}} and {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.h}} for an example of everything discussed in this section. See also the [[Documentation:Hacker&#039;s Guide/Video Filters/Deinterlace|Deinterlace Hacker&#039;s Guide]] for some further details.&lt;br /&gt;
&lt;br /&gt;
The video filters use an object-based model. Calls to the filter will come with an instance pointer, so each filter instance can keep local data.&lt;br /&gt;
&lt;br /&gt;
Usually, each filter defines its own internal data structure called &#039;&#039;&#039;filter_sys_t&#039;&#039;&#039;. It is completely private to the filter.&lt;br /&gt;
&lt;br /&gt;
The API for video filters in VLC 1.2 is called &#039;&#039;&#039;video filter2&#039;&#039;&#039;. This requires the functions &#039;&#039;&#039;Open()&#039;&#039;&#039; and &#039;&#039;&#039;Close()&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Open()&#039;&#039;&#039; function is expected to allocate private data (if any), and set up the filter structure with pointers to a frame processing function (&#039;&#039;&#039;p_filter-&amp;gt;pf_video_filter&#039;&#039;&#039;, which is the actual filter), a flush function (&#039;&#039;&#039;p_filter-&amp;gt;pf_video_flush&#039;&#039;&#039;), and a mouse event function (&#039;&#039;&#039;p_filter-&amp;gt;pf_video_mouse&#039;&#039;&#039;). The relevant types are defined in {{VLCSourceFile|name=include/vlc_filter.h}}.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Close()&#039;&#039;&#039; function should deallocate private data.&lt;br /&gt;
&lt;br /&gt;
See [[Documentation:Hacker&#039;s_Guide/How_To_Write_a_Module|How to write a module]] for details about these functions in modules in general.&lt;br /&gt;
&lt;br /&gt;
The mouse function should convert mouse events, from filter output format to filter input format (note the direction!). This is needed when doing scaling or geometrical distortions, so that the mouse position will map correctly. See {{VLCSourceFile|name=include/vlc_filter.h}} for the definition and &#039;&#039;&#039;Mouse()&#039;&#039;&#039; in {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.c}} for an example. If you do not need to remap mouse events, you can leave &#039;&#039;&#039;p_filter-&amp;gt;pf_video_mouse&#039;&#039;&#039; as &#039;&#039;&#039;NULL&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=== Filter work (frame processing function) ===&lt;br /&gt;
The frame processing function takes a frame as input (&#039;&#039;&#039;picture_t*&#039;&#039;&#039;, {{VLCSourceFile|name=include/vlc_picture.h}}), and optionally outputs one or more frames (&#039;&#039;&#039;picture_t*&#039;&#039;&#039;) as a linked list. The usual case is one frame in, one frame out, but this is not a requirement. (See framerate doublers and IVTC in the [[deinterlace]] module for counterexamples.)&lt;br /&gt;
&lt;br /&gt;
If you do not wish to output a frame at a particular call to your processing function, you can return &#039;&#039;&#039;NULL&#039;&#039;&#039;. If you wish to output several, make a linked list by using the &#039;&#039;&#039;p_next&#039;&#039;&#039; member of &#039;&#039;&#039;picture_t&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
You don&#039;t have to necessarily output the &#039;&#039;same&#039;&#039; frame (after processing) that just came in. You can keep a private input frame history in your &#039;&#039;&#039;filter_sys_t&#039;&#039;&#039;, pick the base frame for your output from that, and adjust the PTSs (presentation timestamps, member &#039;&#039;&#039;date&#039;&#039;&#039; in &#039;&#039;&#039;picture_t&#039;&#039;&#039;) of your output as you deem necessary. The deinterlacer provides an example of how to do this.&lt;br /&gt;
&lt;br /&gt;
Note however that there may be other filters in the chain that already set up a frame offset; this leaves less time (until the designated PTS) for the rest of the filters to do their processing.&lt;br /&gt;
&lt;br /&gt;
The input picture coming in to the processing function is considered as owned by the processing function, and should be released before returning. To do this, use&lt;br /&gt;
&amp;lt;pre&amp;gt;picture_Release( p_inpic );&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Frame allocation ===&lt;br /&gt;
Be sure to allocate your output pictures using &amp;lt;pre&amp;gt;picture_t *p_outpic = filter_NewPicture( p_filter );&amp;lt;/pre&amp;gt;&lt;br /&gt;
This function requests a new picture from the private pool (see {{VLCSourceFile|name=src/video_output/vout_wrapper.c}}). This is very important! Be aware that pictures created like&lt;br /&gt;
&amp;lt;pre&amp;gt;picture_t *p_temp = picture_NewFromFormat( &amp;amp;p_input_pic-&amp;gt;format );&amp;lt;/pre&amp;gt;&lt;br /&gt;
lack a shared memory context (in Linux; or the equivalent in other OS), and thus cannot be passed to the video output logic. If your filter attempts to do so, VLC will crash.&lt;br /&gt;
&lt;br /&gt;
If you need temporary pictures, you can allocate those using &#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;, but remember to &#039;&#039;always create output pictures using &#039;&#039;&#039;filter_NewPicture()&#039;&#039;&#039;&#039;&#039;. Here an &#039;&#039;output picture&#039;&#039; is defined as a picture which goes out from the filter to the caller.&lt;br /&gt;
&lt;br /&gt;
There is a limit to the number of simultaneous picture slots available in the private pool. Currently (&amp;lt;nowiki&amp;gt;[71992c5fbc75ee2c94cd2a3ab1aaca70bfc688a9]&amp;lt;/nowiki&amp;gt;) this is 3 pictures for the filter layer. See the constant &#039;&#039;&#039;private_picture&#039;&#039;&#039; in {{VLCSourceFile|name=src/video_output/vout_wrapper.c}}. If you try to allocate more output pictures than this (during a single processing call), the allocation will fail.&lt;br /&gt;
&lt;br /&gt;
=== Notes ===&lt;br /&gt;
* In VLC 1.2, the video format (resolution, chroma) never changes on the fly. The whole filter chain is &#039;&#039;&#039;Close()&#039;&#039;&#039;d and then &#039;&#039;&#039;Open()&#039;&#039;&#039;ed again if the format changes.&lt;br /&gt;
&lt;br /&gt;
* Note that it &#039;&#039;is&#039;&#039; allowed to flush the filter without closing it. This actually happens under some circumstances, so &#039;&#039;don&#039;t deallocate stuff in your flush function&#039;&#039;. Rather, allocate dynamic resources in &#039;&#039;&#039;Open()&#039;&#039;&#039;, and deallocate them in &#039;&#039;&#039;Close()&#039;&#039;&#039; (or in private functions called from those). See [[Documentation:Hacker&#039;s_Guide/How_To_Write_a_Module|How to write a module]].&lt;br /&gt;
&lt;br /&gt;
* Supported input and output formats are decided by each filter. The usual thing is to support [[YUV]] formats, e.g. [[I420]], [[J420]], [[YV12]], [[I422]] and [[J422]]. See {{VLCSourceFile|name=include/vlc_fourcc.h}}. The most important ones to support are [[I420]] and [[I422]].&lt;br /&gt;
&lt;br /&gt;
== Pitch, visible pitch, planes et al. ==&lt;br /&gt;
&lt;br /&gt;
=== Pitch and visible pitch ===&lt;br /&gt;
Important to know:&lt;br /&gt;
&lt;br /&gt;
* i_pitch = number of (macro)pixels on one line&lt;br /&gt;
* i_visible_pitch = number of (macro)pixels on one line, adjusted for memory alignment constraints etc. (see below)&lt;br /&gt;
&lt;br /&gt;
Note that the pitches may be different for each plane, and indeed in YUV formats the luma (&#039;&#039;&#039;Y_PLANE&#039;&#039;&#039;) and chroma (&#039;&#039;&#039;U_PLANE&#039;&#039;&#039;, &#039;&#039;&#039;V_PLANE&#039;&#039;&#039;) have different pitches due to chroma subsampling. (In 4:2:0 formats, the number of lines differs, too.)&lt;br /&gt;
&lt;br /&gt;
Pitches also tend to slightly differ depending on how the picture was allocated, even if the visible size is the same. The input picture to the filter may have one pitch, temporary pictures (&#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;) another, and output pictures (&#039;&#039;&#039;filter_NewPicture()&#039;&#039;&#039;) yet another.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Be sure to always use the correct pitch when you handle the pixels of a picture.&#039;&#039; That is, always use the &#039;&#039;&#039;i_pitch&#039;&#039;&#039; member of the actual &#039;&#039;&#039;plane_t&#039;&#039;&#039; you are working on.&lt;br /&gt;
&lt;br /&gt;
If you absolutely need matching pitches (e.g. if you are glueing in processing code from another GPL-compatible project which assumes this and you don&#039;t want to rewrite it...), consider making temporary copies with &#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;. See {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.c}} (the history mechanism &amp;lt;nowiki&amp;gt;pp_history[]&amp;lt;/nowiki&amp;gt;) and {{VLCSourceFile|name=modules/video_filter/deinterlace/algo_yadif.c}} (its usage) for an example.&lt;br /&gt;
&lt;br /&gt;
If you are processing pixels from one picture to another, the safe thing to do is to take the smallest &#039;&#039;&#039;i_visible_pitch&#039;&#039;&#039;, and loop from x = 0 until the visible pitch has been reached, but use the individual &#039;&#039;&#039;i_pitch&#039;&#039;&#039;es for computing the pixel locations. See {{VLCSourceFile|name=modules/video_filter/deinterlace/helpers.c}} for examples.&lt;br /&gt;
&lt;br /&gt;
=== Video_format_t vs. Plane_t ===&lt;br /&gt;
&lt;br /&gt;
In &#039;&#039;&#039;video_format_t&#039;&#039;&#039;, the &#039;&#039;&#039;i_visible_width&#039;&#039;&#039; and &#039;&#039;&#039;i_visible_height&#039;&#039;&#039; members go with &#039;&#039;&#039;i_x_offset&#039;&#039;&#039; and &#039;&#039;&#039;i_y_offset&#039;&#039;&#039;, but they are not related to &#039;&#039;&#039;plane_t::i_visible_*&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;plane_t::i_visible_*&#039;&#039;&#039; fields are there to know which part of the memory planes can at most be displayed. Usually these are different from the whole surface due to memory alignment constraints (like mod 16 for SSE2 or to be aligned on a macroblock). Those values are decided when the picture is allocated and they usually don&#039;t change for a given picture pointer (but they can change, like in direct3d buffers).&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;video_format_t:i_visible_width/height&#039;&#039;&#039; and &#039;&#039;&#039;i_x/y_offset&#039;&#039;&#039; are more a &#039;hint&#039; regarding what will be actually displayed. A filter should update &#039;&#039;&#039;filter_t::fmt_out&#039;&#039;&#039; if needed to ensure that the allocated pictures get the right value. A filter should, however, not limit its processing to this area, because VLC supports dynamic cropping.&lt;br /&gt;
&lt;br /&gt;
Thus, the correct thing to do in a filter is to process the whole picture area, or at least the first i_visible_* lines and pixels &#039;&#039;according to the &#039;&#039;&#039;plane_t&#039;&#039;&#039;s&#039;&#039;. Filters do not need to care about margin positioning or that there even exists such a thing as margins.&lt;br /&gt;
&lt;br /&gt;
== About creating and merging pictures (picture_t and subpicture_t) ==&lt;br /&gt;
&lt;br /&gt;
This section talks about how to create filters which create and merge a picture onto the top of the already existing video.&lt;br /&gt;
&lt;br /&gt;
=== What is the difference between picture_t and subpicture_t? ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;picture_t&#039;&#039;&#039; is a full image, typically a decoded video frame.&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;subpicture_t&#039;&#039;&#039; is an element (to be exact, a list of elements) which can be overlayed on top of an image. Two types of elements exist: text and images. Text elements are rendered by the VLC core before overlay.&lt;br /&gt;
&lt;br /&gt;
=== How to create a picture and merge it with the existing picture? ===&lt;br /&gt;
&lt;br /&gt;
Code-wise the simplest way is to create a video filter of type &#039;&#039;&#039;subpicture source&#039;&#039;&#039; (in VLC 2.0). The task of a &#039;&#039;&#039;subpicture source&#039;&#039;&#039; is to create a &#039;&#039;&#039;subpicture_t&#039;&#039;&#039;, and then let the VLC core deal with blending it on top of the video stream.&lt;br /&gt;
&lt;br /&gt;
Another way is to create a &#039;&#039;&#039;picture_t&#039;&#039;&#039; (e.g. with &#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;) and do the blending yourself. See below.&lt;br /&gt;
&lt;br /&gt;
Note: in versions of VLC prior to 2.0 (version 1.1 and below), &#039;&#039;&#039;subpicture sources&#039;&#039;&#039; were called &#039;&#039;&#039;subpicture filters&#039;&#039;&#039;. This video filter type has been renamed in order to allow for the creation of actual &#039;&#039;&#039;subpicture filters&#039;&#039;&#039;, which edit (i.e. filter) existing &#039;&#039;&#039;subpicture_t&#039;&#039;&#039;s.&lt;br /&gt;
&lt;br /&gt;
=== What is the simplest example I can look at for writing a filter that does this? ===&lt;br /&gt;
&lt;br /&gt;
Such filters can be found in modules/video_filter/ and match the capability &#039;&#039;&#039;sub source&#039;&#039;&#039;. Noteworthy examples include:&lt;br /&gt;
&lt;br /&gt;
 - logo.c: overlay an image on top of the video. Note that this is also implemented as a &#039;&#039;&#039;video filter2&#039;&#039;&#039; which directly edits the picture_t. So that might not be the simplest source to look at. If you wish to take this approach, see also the [[Documentation:Hacker&#039;s Guide/Video Filters/Deinterlace|deinterlace filter]], if you need inline assembler optimized 50/50 blending.&lt;br /&gt;
 - marq.c: overlay text on top of the video.&lt;br /&gt;
 - rss.c: overlay text from an RSS stream on top of the video. This one also includes picture elements sometimes which makes it a good example to understand how composite &#039;&#039;&#039;subpicture_t&#039;&#039;&#039; elements can be used.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Disclaimer ==&lt;br /&gt;
&lt;br /&gt;
The information is mostly based on a few months&#039; hacking on the deinterlacer.&lt;br /&gt;
&lt;br /&gt;
This page is still a stub. Please add new relevant stuff.&lt;br /&gt;
&lt;br /&gt;
Also, the stuff that already exists could use better organization and formatting.&lt;br /&gt;
&lt;br /&gt;
{{Documentation}}&lt;/div&gt;</summary>
		<author><name>Technologicat</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=User:Technologicat&amp;diff=21337</id>
		<title>User:Technologicat</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=User:Technologicat&amp;diff=21337"/>
		<updated>2012-01-27T11:21:24Z</updated>

		<summary type="html">&lt;p&gt;Technologicat: Let&amp;#039;s be more specific.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;My name is Juha Jeronen. Technically, I&#039;m not an official VLC developer, but I subscribe to vlc-devel.&lt;br /&gt;
&lt;br /&gt;
I designed and programmed the IVTC and Phosphor deinterlacers for VLC 2.0 (which was then VLC 1.2), with help from fenrir for the MMX inline assembly. I also refactored the deinterlacer module at that time.&lt;br /&gt;
&lt;br /&gt;
I&#039;ve updated the [[Deinterlacing|deinterlacer]] documentation on the wiki, and written a [[Hacker_Guide/Video_Filters/Deinterlace|hacker&#039;s guide for the deinterlacer]]. I&#039;ve also written a [[Hacker_Guide/Video_Filters|hacker&#039;s guide for VLC&#039;s video filters in general]].&lt;br /&gt;
&lt;br /&gt;
As of 2012-01-27, I maintain VLC&#039;s Finnish translation.&lt;/div&gt;</summary>
		<author><name>Technologicat</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=Hacker_Guide/Video_Filters&amp;diff=21336</id>
		<title>Hacker Guide/Video Filters</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=Hacker_Guide/Video_Filters&amp;diff=21336"/>
		<updated>2012-01-27T11:10:27Z</updated>

		<summary type="html">&lt;p&gt;Technologicat: English checks plus some links&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is the [[Hacker_Guide|Hacker&#039;s Guide]] for video filters (&#039;&#039;&#039;video filter2&#039;&#039;&#039;, VLC 1.2).&lt;br /&gt;
&lt;br /&gt;
== Location in source tree, compilation ==&lt;br /&gt;
&lt;br /&gt;
The right place for video filters is in the {{VLCSourceFile|name=modules/video_filter/}} folder.&lt;br /&gt;
&lt;br /&gt;
See {{VLCSourceFile|name=modules/video_filter/Modules.am}} for a list of video filters currently in VLC, and which source files belong to which.&lt;br /&gt;
&lt;br /&gt;
See [[Documentation:Hacker&#039;s_Guide/How_To_Write_a_Module#Git_and_Repository_integration|new module integration]] for additional help on how to integrate a new module in the build system.&lt;br /&gt;
&lt;br /&gt;
== Additional documentation ==&lt;br /&gt;
&lt;br /&gt;
Reading [[Documentation:Hacker&#039;s_Guide/How_To_Write_a_Module|How to write a module]] first is highly advised.&lt;br /&gt;
&lt;br /&gt;
Some &#039;&#039;video filters&#039;&#039; may have their own [[Documentation:Hacker&#039;s Guide|Hacker&#039;s Guide]] sections.&lt;br /&gt;
&lt;br /&gt;
Currently, the &#039;&#039;&#039;deinterlace&#039;&#039;&#039; filter has both a [[Documentation:Hacker&#039;s Guide/Video Filters/Deinterlace|Hacker&#039;s Guide section]] and [[Deinterlace|user documentation]] with some useful additional  technical information.&lt;br /&gt;
&lt;br /&gt;
== Programming conventions and tips ==&lt;br /&gt;
&lt;br /&gt;
{{VLC}} [[video filters]] are usually written in C99, like the rest of VLC. Some use C++, like the AtmoLight plugin.&lt;br /&gt;
&lt;br /&gt;
The usual stuff holds here too:&lt;br /&gt;
* Use &#039;&#039;&#039;assert()&#039;&#039;&#039; for checking conditions that, in presence of no bugs, always hold.&lt;br /&gt;
** &#039;&#039;Don&#039;t&#039;&#039; use &#039;&#039;&#039;assert()&#039;&#039;&#039; for checking stuff that may fail at runtime. Handle errors gracefully.&lt;br /&gt;
* Keep your code readable. Make private functions when it simplifies things.&lt;br /&gt;
* Prefer 80 characters per line at maximum, if possible.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Particularly&#039;&#039;&#039; for video filters: keep in mind that this is &#039;&#039;&#039;low-level stuff&#039;&#039;&#039; and needs to be &#039;&#039;&#039;fast&#039;&#039;&#039;.&lt;br /&gt;
* How fast? Note that the source may be interlaced, and someone may have thrown a framerate doubler into the filter chain... this means that for a 60i signal, the entire processing chain from decode to render has about 16ms per output frame.&lt;br /&gt;
* Keep the required memory bandwidth down.&lt;br /&gt;
** Don&#039;t copy whole pictures unless you absolutely must. Moving pixels costs time.&lt;br /&gt;
** Allocate an output picture and render directly into it.&lt;br /&gt;
** If you need more than one pass, do in-place processing in the subsequent ones if possible.&lt;br /&gt;
** If your processing cannot avoid multiple passes, consider doing all passes for a picture line (or a few) at a time, instead of iterating over the whole picture separately for each pass. This will help to keep down the pressure on the CPU cache (since a few picture lines may fit in the L2 cache).&lt;br /&gt;
* Consider writing the inner processing loops in vectorized inline assembly, such as MMX. This can often gain a factor of 2-8x in speed, depending on how much and what kind of processing your algorithm needs.&lt;br /&gt;
&lt;br /&gt;
== Some notes on video filter API ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: See {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.c}} and {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.h}} for an example of everything discussed in this section. See also the [[Documentation:Hacker&#039;s Guide/Video Filters/Deinterlace|Deinterlace Hacker&#039;s Guide]] for some further details.&lt;br /&gt;
&lt;br /&gt;
The video filters use an object-based model. Calls to the filter will come with an instance pointer, so each filter instance can keep local data.&lt;br /&gt;
&lt;br /&gt;
Usually, each filter defines its own internal data structure called &#039;&#039;&#039;filter_sys_t&#039;&#039;&#039;. It is completely private to the filter.&lt;br /&gt;
&lt;br /&gt;
The API for video filters in VLC 1.2 is called &#039;&#039;&#039;video filter2&#039;&#039;&#039;. This requires the functions &#039;&#039;&#039;Open()&#039;&#039;&#039; and &#039;&#039;&#039;Close()&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Open()&#039;&#039;&#039; function is expected to allocate private data (if any), and set up the filter structure with pointers to a frame processing function (&#039;&#039;&#039;p_filter-&amp;gt;pf_video_filter&#039;&#039;&#039;, which is the actual filter), a flush function (&#039;&#039;&#039;p_filter-&amp;gt;pf_video_flush&#039;&#039;&#039;), and a mouse event function (&#039;&#039;&#039;p_filter-&amp;gt;pf_video_mouse&#039;&#039;&#039;). The relevant types are defined in {{VLCSourceFile|name=include/vlc_filter.h}}.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Close()&#039;&#039;&#039; function should deallocate private data.&lt;br /&gt;
&lt;br /&gt;
See [[Documentation:Hacker&#039;s_Guide/How_To_Write_a_Module|How to write a module]] for details about these functions in modules in general.&lt;br /&gt;
&lt;br /&gt;
The mouse function should convert mouse events, from filter output format to filter input format (note the direction!). This is needed when doing scaling or geometrical distortions, so that the mouse position will map correctly. See {{VLCSourceFile|name=include/vlc_filter.h}} for the definition and &#039;&#039;&#039;Mouse()&#039;&#039;&#039; in {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.c}} for an example. If you do not need to remap mouse events, you can leave &#039;&#039;&#039;p_filter-&amp;gt;pf_video_mouse&#039;&#039;&#039; as &#039;&#039;&#039;NULL&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=== Filter work (frame processing function) ===&lt;br /&gt;
The frame processing function takes a frame as input (&#039;&#039;&#039;picture_t*&#039;&#039;&#039;, {{VLCSourceFile|name=include/vlc_picture.h}}), and optionally outputs one or more frames (&#039;&#039;&#039;picture_t*&#039;&#039;&#039;) as a linked list. The usual case is one frame in, one frame out, but this is not a requirement. (See framerate doublers and IVTC in the [[deinterlace]] module for counterexamples.)&lt;br /&gt;
&lt;br /&gt;
If you do not wish to output a frame at a particular call to your processing function, you can return &#039;&#039;&#039;NULL&#039;&#039;&#039;. If you wish to output several, make a linked list by using the &#039;&#039;&#039;p_next&#039;&#039;&#039; member of &#039;&#039;&#039;picture_t&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
You don&#039;t have to necessarily output the &#039;&#039;same&#039;&#039; frame (after processing) that just came in. You can keep a private input frame history in your &#039;&#039;&#039;filter_sys_t&#039;&#039;&#039;, pick the base frame for your output from that, and adjust the PTSs (presentation timestamps, member &#039;&#039;&#039;date&#039;&#039;&#039; in &#039;&#039;&#039;picture_t&#039;&#039;&#039;) of your output as you deem necessary. The deinterlacer provides an example of how to do this.&lt;br /&gt;
&lt;br /&gt;
Note however that there may be other filters in the chain that already set up a frame offset; this leaves less time (until the designated PTS) for the rest of the filters to do their processing.&lt;br /&gt;
&lt;br /&gt;
The input picture coming in to the processing function is considered as owned by the processing function, and should be released before returning. To do this, use&lt;br /&gt;
&amp;lt;pre&amp;gt;picture_Release( p_inpic );&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Frame allocation ===&lt;br /&gt;
Be sure to allocate your output pictures using &amp;lt;pre&amp;gt;picture_t *p_outpic = filter_NewPicture( p_filter );&amp;lt;/pre&amp;gt;&lt;br /&gt;
This function requests a new picture from the private pool (see {{VLCSourceFile|name=src/video_output/vout_wrapper.c}}). This is very important! Be aware that pictures created like&lt;br /&gt;
&amp;lt;pre&amp;gt;picture_t *p_temp = picture_NewFromFormat( &amp;amp;p_input_pic-&amp;gt;format );&amp;lt;/pre&amp;gt;&lt;br /&gt;
lack a shared memory context (in Linux; or the equivalent in other OS), and thus cannot be passed to the video output logic. If your filter attempts to do so, VLC will crash.&lt;br /&gt;
&lt;br /&gt;
If you need temporary pictures, you can allocate those using &#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;, but remember to &#039;&#039;always create output pictures using &#039;&#039;&#039;filter_NewPicture()&#039;&#039;&#039;&#039;&#039;. Here an &#039;&#039;output picture&#039;&#039; is defined as a picture which goes out from the filter to the caller.&lt;br /&gt;
&lt;br /&gt;
There is a limit to the number of simultaneous picture slots available in the private pool. Currently (&amp;lt;nowiki&amp;gt;[71992c5fbc75ee2c94cd2a3ab1aaca70bfc688a9]&amp;lt;/nowiki&amp;gt;) this is 3 pictures for the filter layer. See the constant &#039;&#039;&#039;private_picture&#039;&#039;&#039; in {{VLCSourceFile|name=src/video_output/vout_wrapper.c}}. If you try to allocate more output pictures than this (during a single processing call), the allocation will fail.&lt;br /&gt;
&lt;br /&gt;
=== Notes ===&lt;br /&gt;
* In VLC 1.2, the video format (resolution, chroma) never changes on the fly. The whole filter chain is &#039;&#039;&#039;Close()&#039;&#039;&#039;d and then &#039;&#039;&#039;Open()&#039;&#039;&#039;ed again if the format changes.&lt;br /&gt;
&lt;br /&gt;
* Note that it &#039;&#039;is&#039;&#039; allowed to flush the filter without closing it. This actually happens under some circumstances, so &#039;&#039;don&#039;t deallocate stuff in your flush function&#039;&#039;. Rather, allocate dynamic resources in &#039;&#039;&#039;Open()&#039;&#039;&#039;, and deallocate them in &#039;&#039;&#039;Close()&#039;&#039;&#039; (or in private functions called from those). See [[Documentation:Hacker&#039;s_Guide/How_To_Write_a_Module|How to write a module]].&lt;br /&gt;
&lt;br /&gt;
* Supported input and output formats are decided by each filter. The usual thing is to support [[YUV]] formats, e.g. [[I420]], [[J420]], [[YV12]], [[I422]] and [[J422]]. See {{VLCSourceFile|name=include/vlc_fourcc.h}}. The most important ones to support are [[I420]] and [[I422]].&lt;br /&gt;
&lt;br /&gt;
== Pitch, visible pitch, planes et al. ==&lt;br /&gt;
&lt;br /&gt;
=== Pitch and visible pitch ===&lt;br /&gt;
Important to know:&lt;br /&gt;
&lt;br /&gt;
* i_pitch = number of (macro)pixels on one line&lt;br /&gt;
* i_visible_pitch = number of (macro)pixels on one line, adjusted for memory alignment constraints etc. (see below)&lt;br /&gt;
&lt;br /&gt;
Note that the pitches may be different for each plane, and indeed in YUV formats the luma (&#039;&#039;&#039;Y_PLANE&#039;&#039;&#039;) and chroma (&#039;&#039;&#039;U_PLANE&#039;&#039;&#039;, &#039;&#039;&#039;V_PLANE&#039;&#039;&#039;) have different pitches due to chroma subsampling. (In 4:2:0 formats, the number of lines differs, too.)&lt;br /&gt;
&lt;br /&gt;
Pitches also tend to slightly differ depending on how the picture was allocated, even if the visible size is the same. The input picture to the filter may have one pitch, temporary pictures (&#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;) another, and output pictures (&#039;&#039;&#039;filter_NewPicture()&#039;&#039;&#039;) yet another.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Be sure to always use the correct pitch when you handle the pixels of a picture.&#039;&#039; That is, always use the &#039;&#039;&#039;i_pitch&#039;&#039;&#039; member of the actual &#039;&#039;&#039;plane_t&#039;&#039;&#039; you are working on.&lt;br /&gt;
&lt;br /&gt;
If you absolutely need matching pitches (e.g. if you are glueing in processing code from another GPL-compatible project which assumes this and you don&#039;t want to rewrite it...), consider making temporary copies with &#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;. See {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.c}} (the history mechanism &amp;lt;nowiki&amp;gt;pp_history[]&amp;lt;/nowiki&amp;gt;) and {{VLCSourceFile|name=modules/video_filter/deinterlace/algo_yadif.c}} (its usage) for an example.&lt;br /&gt;
&lt;br /&gt;
If you are processing pixels from one picture to another, the safe thing to do is to take the smallest &#039;&#039;&#039;i_visible_pitch&#039;&#039;&#039;, and loop from x = 0 until the visible pitch has been reached, but use the individual &#039;&#039;&#039;i_pitch&#039;&#039;&#039;es for computing the pixel locations. See {{VLCSourceFile|name=modules/video_filter/deinterlace/helpers.c}} for examples.&lt;br /&gt;
&lt;br /&gt;
=== Video_format_t vs. Plane_t ===&lt;br /&gt;
&lt;br /&gt;
In &#039;&#039;&#039;video_format_t&#039;&#039;&#039;, the &#039;&#039;&#039;i_visible_width&#039;&#039;&#039; and &#039;&#039;&#039;i_visible_height&#039;&#039;&#039; members go with &#039;&#039;&#039;i_x_offset&#039;&#039;&#039; and &#039;&#039;&#039;i_y_offset&#039;&#039;&#039;, but they are not related to &#039;&#039;&#039;plane_t::i_visible_*&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;plane_t::i_visible_*&#039;&#039;&#039; fields are there to know which part of the memory planes can at most be displayed. Usually these are different from the whole surface due to memory alignment constraints (like mod 16 for SSE2 or to be aligned on a macroblock). Those values are decided when the picture is allocated and they usually don&#039;t change for a given picture pointer (but they can change, like in direct3d buffers).&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;video_format_t:i_visible_width/height&#039;&#039;&#039; and &#039;&#039;&#039;i_x/y_offset&#039;&#039;&#039; are more a &#039;hint&#039; regarding what will be actually displayed. A filter should update &#039;&#039;&#039;filter_t::fmt_out&#039;&#039;&#039; if needed to ensure that the allocated pictures get the right value. A filter should, however, not limit its processing to this area, because VLC supports dynamic cropping.&lt;br /&gt;
&lt;br /&gt;
Thus, the correct thing to do in a filter is to process the whole picture area, or at least the first i_visible_* lines and pixels &#039;&#039;according to the &#039;&#039;&#039;plane_t&#039;&#039;&#039;s&#039;&#039;. Filters do not need to care about margin positioning or that there even exists such a thing as margins.&lt;br /&gt;
&lt;br /&gt;
== Disclaimer ==&lt;br /&gt;
&lt;br /&gt;
The information is mostly based on a few months&#039; hacking on the deinterlacer.&lt;br /&gt;
&lt;br /&gt;
This page is still a stub. Please add new relevant stuff.&lt;br /&gt;
&lt;br /&gt;
Also, the stuff that already exists could use better organization and formatting.&lt;br /&gt;
&lt;br /&gt;
{{Documentation}}&lt;/div&gt;</summary>
		<author><name>Technologicat</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=Hacker_Guide/Video_Filters&amp;diff=21335</id>
		<title>Hacker Guide/Video Filters</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=Hacker_Guide/Video_Filters&amp;diff=21335"/>
		<updated>2012-01-27T10:57:49Z</updated>

		<summary type="html">&lt;p&gt;Technologicat: Hacker&amp;#039;s guide link update&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is the [[Hacker_Guide|Hacker&#039;s Guide]] for video filters (&#039;&#039;&#039;video filter2&#039;&#039;&#039;, VLC 1.2).&lt;br /&gt;
&lt;br /&gt;
== Location in source tree, compilation ==&lt;br /&gt;
&lt;br /&gt;
The right place for video filter is in the {{VLCSourceFile|name=modules/video_filter/}} folder.&lt;br /&gt;
&lt;br /&gt;
See {{VLCSourceFile|name=modules/video_filter/Modules.am}} for a list of video filters currently in VLC, and which source files belong to which.&lt;br /&gt;
&lt;br /&gt;
See [[Documentation:Hacker&#039;s_Guide/How_To_Write_a_Module#Git_and_Repository_integration|new module integration]] for additional help on how to integrate a new module in the build-system.&lt;br /&gt;
&lt;br /&gt;
== Additional documentation ==&lt;br /&gt;
&lt;br /&gt;
Reading [[Documentation:Hacker&#039;s_Guide/How_To_Write_a_Module|How to write a module]] before is very advised.&lt;br /&gt;
&lt;br /&gt;
Some &#039;&#039;video filters&#039;&#039; may have their own [[Documentation:Hacker&#039;s Guide|Hacker&#039;s Guide]] sections.&lt;br /&gt;
&lt;br /&gt;
Currently, the &#039;&#039;&#039;deinterlace&#039;&#039;&#039; filter has both a [[Documentation:Hacker&#039;s Guide/Video Filters/Deinterlace|Hacker&#039;s Guide section]] and [[Deinterlace|user documentation]] with some useful additional  technical information.&lt;br /&gt;
&lt;br /&gt;
== Programming conventions and tips ==&lt;br /&gt;
&lt;br /&gt;
{{VLC}} [[video filters]] are usually written in C99, like the rest of VLC. Some use C++, like the AtmoLight plugin.&lt;br /&gt;
&lt;br /&gt;
The usual stuff holds here too:&lt;br /&gt;
* Use &#039;&#039;&#039;assert()&#039;&#039;&#039; for checking conditions that, in presence of no bugs, always hold.&lt;br /&gt;
** &#039;&#039;Don&#039;t&#039;&#039; use &#039;&#039;&#039;assert()&#039;&#039;&#039; for checking stuff that may fail at runtime. Handle errors gracefully.&lt;br /&gt;
* Keep your code readable. Make private functions when it simplifies things.&lt;br /&gt;
* Prefer 80 characters per line at maximum, if possible.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Particularly&#039;&#039;&#039; for video filters: keep in mind that this is &#039;&#039;&#039;low-level stuff&#039;&#039;&#039; and needs to be &#039;&#039;&#039;fast&#039;&#039;&#039;.&lt;br /&gt;
* How fast? Note that the source may be interlaced, and someone may have thrown a framerate doubler into the filter chain... this means that for a 60i signal, the entire processing chain from decode to render has about 16ms per output frame.&lt;br /&gt;
* Keep the required memory bandwidth down.&lt;br /&gt;
** Don&#039;t copy whole pictures unless you absolutely must. Moving pixels costs time.&lt;br /&gt;
** Allocate an output picture and render directly into it.&lt;br /&gt;
** If you need more than one pass, do in-place processing in the subsequent ones if possible.&lt;br /&gt;
** If your processing cannot avoid multiple passes, consider doing all passes for a picture line (or a few) at a time, instead of iterating over the whole picture separately for each pass. This will help to keep down the pressure on the CPU cache.&lt;br /&gt;
* Consider writing the inner processing loops in vectorized inline assembly, such as MMX. This can often gain a factor of 2-8x in speed, depending on how much and what kind of processing your algorithm needs.&lt;br /&gt;
&lt;br /&gt;
== Some notes on video filter API ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: See {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.c}} and {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.h}} for an example of everything discussed in this section. See also the [[Documentation:Hacker&#039;s Guide/Video Filters/Deinterlace|Deinterlace Hacker&#039;s Guide]] for some further details.&lt;br /&gt;
&lt;br /&gt;
The video filters use an object-based model. Calls to the filter will come with an instance pointer, so each filter instance can keep local data.&lt;br /&gt;
&lt;br /&gt;
Usually, each filter defines its own internal data structure called &#039;&#039;&#039;filter_sys_t&#039;&#039;&#039;. It is completely private to the filter.&lt;br /&gt;
&lt;br /&gt;
The API for video filters in VLC 1.2 is called &#039;&#039;&#039;video filter2&#039;&#039;&#039;. This requires the functions &#039;&#039;&#039;Open()&#039;&#039;&#039; and &#039;&#039;&#039;Close()&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Open()&#039;&#039;&#039; function is expected to allocate private data (if any), and set up the filter structure with pointers to a frame processing function (&#039;&#039;&#039;p_filter-&amp;gt;pf_video_filter&#039;&#039;&#039;, which is the actual filter), a flush function (&#039;&#039;&#039;p_filter-&amp;gt;pf_video_flush&#039;&#039;&#039;), and a mouse event function (&#039;&#039;&#039;p_filter-&amp;gt;pf_video_mouse&#039;&#039;&#039;). The relevant types are defined in {{VLCSourceFile|name=include/vlc_filter.h}}.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Close()&#039;&#039;&#039; function should deallocate private data.&lt;br /&gt;
&lt;br /&gt;
The mouse function should convert mouse events, from filter output format to filter input format (note the direction!). This is needed when doing scaling or geometrical distortions, so that the mouse position will map correctly. See {{VLCSourceFile|name=include/vlc_filter.h}} for the definition and &#039;&#039;&#039;Mouse()&#039;&#039;&#039; in {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.c}} for an example. If you do not need to remap mouse events, you can leave &#039;&#039;&#039;p_filter-&amp;gt;pf_video_mouse&#039;&#039;&#039; as &#039;&#039;&#039;NULL&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=== Filter work (frame processing function) ===&lt;br /&gt;
The frame processing function takes a frame as input (&#039;&#039;&#039;picture_t*&#039;&#039;&#039;, {{VLCSourceFile|name=include/vlc_picture.h}}), and optionally outputs one or more frames (&#039;&#039;&#039;picture_t*&#039;&#039;&#039;) as a linked list. The usual case is one frame in, one frame out, but this is not a requirement. (See framerate doublers and IVTC in the [[deinterlace]] module for counterexamples.)&lt;br /&gt;
&lt;br /&gt;
If you do not wish to output a frame at a particular call to your processing function, you can return &#039;&#039;&#039;NULL&#039;&#039;&#039;. If you wish to output several, make a linked list by using the &#039;&#039;&#039;p_next&#039;&#039;&#039; member of &#039;&#039;&#039;picture_t&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
You don&#039;t have to necessarily output the &#039;&#039;same&#039;&#039; frame (after processing) that just came in. You can keep a private input frame history in your &#039;&#039;&#039;filter_sys_t&#039;&#039;&#039;, pick the base frame for your output from that, and adjust the PTSs (presentation timestamps, member &#039;&#039;&#039;date&#039;&#039;&#039; in &#039;&#039;&#039;picture_t&#039;&#039;&#039;) of your output as you deem necessary. The deinterlacer provides an example of how to do this.&lt;br /&gt;
&lt;br /&gt;
Note however that there may be other filters in the chain that already set up an offset; this leaves less time (until the designated PTS) for the rest of the filters to do their processing.&lt;br /&gt;
&lt;br /&gt;
The input picture coming in to the processing function is considered as owned by the processing function, and should be released before returning. To do this, use&lt;br /&gt;
&amp;lt;pre&amp;gt;picture_Release( p_inpic );&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Frame allocation ===&lt;br /&gt;
Be sure to allocate your output pictures using &amp;lt;pre&amp;gt;picture_t *p_outpic = filter_NewPicture( p_filter );&amp;lt;/pre&amp;gt;&lt;br /&gt;
This function requests a new picture from the private pool (see {{VLCSourceFile|name=src/video_output/vout_wrapper.c}}). This is very important! Be aware that pictures created like&lt;br /&gt;
&amp;lt;pre&amp;gt;picture_t *p_temp = picture_NewFromFormat( &amp;amp;p_input_pic-&amp;gt;format );&amp;lt;/pre&amp;gt;&lt;br /&gt;
lack a shared memory context (in Linux; or the equivalent in other OS), and thus cannot be passed to the video output logic. If your filter attempts to do so, VLC will crash.&lt;br /&gt;
&lt;br /&gt;
If you need temporary pictures, you can allocate those using &#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;, but remember to &#039;&#039;always create output pictures using &#039;&#039;&#039;filter_NewPicture()&#039;&#039;&#039;&#039;&#039;. Here an &#039;&#039;output picture&#039;&#039; is defined as a picture which goes out from the filter to the caller.&lt;br /&gt;
&lt;br /&gt;
There is a limit to the number of simultaneous picture slots available in the private pool. Currently (&amp;lt;nowiki&amp;gt;[71992c5fbc75ee2c94cd2a3ab1aaca70bfc688a9]&amp;lt;/nowiki&amp;gt;) this is 3 pictures for the filter layer. See constant &#039;&#039;&#039;private_picture&#039;&#039;&#039; in {{VLCSourceFile|name=src/video_output/vout_wrapper.c}}. If you try to allocate more output pictures than this (during a single processing call), the allocation will fail.&lt;br /&gt;
&lt;br /&gt;
=== Notes ===&lt;br /&gt;
* In VLC 1.2, the video format (resolution, chroma) never changes on the fly. The whole filter chain is &#039;&#039;&#039;Close()&#039;&#039;&#039;d and then &#039;&#039;&#039;Open()&#039;&#039;&#039;ed again if the format changes.&lt;br /&gt;
&lt;br /&gt;
* Note that it &#039;&#039;is&#039;&#039; allowed to flush the filter without closing it. This actually happens under some circumstances, so &#039;&#039;don&#039;t deallocate stuff in your flush function&#039;&#039;. Rather, allocate dynamic resources in &#039;&#039;&#039;Open()&#039;&#039;&#039;, and deallocate them in &#039;&#039;&#039;Close()&#039;&#039;&#039; (or in private functions called from those).&lt;br /&gt;
&lt;br /&gt;
* Supported input and output formats are left up to each filter. The usual thing is to support YUV formats, e.g. I420, J420, YV12, I422 and J422. See {{VLCSourceFile|name=include/vlc_fourcc.h}}. The most important ones to support are I420 and I422.&lt;br /&gt;
&lt;br /&gt;
== Pitch, visible pitch, planes et al. ==&lt;br /&gt;
&lt;br /&gt;
=== Pitch and visible pitch ===&lt;br /&gt;
Important to know:&lt;br /&gt;
&lt;br /&gt;
* i_pitch = number of (macro)pixels on one line&lt;br /&gt;
* i_visible_pitch = number of (macro)pixels on one line, adjusted for memory alignment constraints etc. (see below)&lt;br /&gt;
&lt;br /&gt;
Note that the pitches may be different for each plane, and indeed in YUV formats the luma (&#039;&#039;&#039;Y_PLANE&#039;&#039;&#039;) and chroma (&#039;&#039;&#039;U_PLANE&#039;&#039;&#039;, &#039;&#039;&#039;V_PLANE&#039;&#039;&#039;) have different pitches due to chroma subsampling. (In 4:2:0 formats, the number of lines differs, too.)&lt;br /&gt;
&lt;br /&gt;
Pitches also tend to slightly differ depending on how the picture was allocated, even if the visible size is the same. The input picture to the filter may have one pitch, temporary pictures (&#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;) another, and output pictures (&#039;&#039;&#039;filter_NewPicture()&#039;&#039;&#039;) yet another.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Be sure to always use the correct pitch when you handle the pixels of a picture.&#039;&#039; That is, always use the &#039;&#039;&#039;i_pitch&#039;&#039;&#039; member of the actual &#039;&#039;&#039;plane_t&#039;&#039;&#039; you are working on.&lt;br /&gt;
&lt;br /&gt;
If you absolutely need matching pitches (e.g. if you are glueing in processing code from another GPL-compatible project which assumes this and you don&#039;t want to rewrite it...), consider making temporary copies with &#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;. See {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.c}} (the history mechanism &amp;lt;nowiki&amp;gt;pp_history[]&amp;lt;/nowiki&amp;gt;) and {{VLCSourceFile|name=modules/video_filter/deinterlace/algo_yadif.c}} (its usage) for an example.&lt;br /&gt;
&lt;br /&gt;
If you are processing pixels from one picture to another, the safe thing to do is to take the smallest &#039;&#039;&#039;i_visible_pitch&#039;&#039;&#039;, and loop from x = 0 until the visible pitch has been reached, but use the individual &#039;&#039;&#039;i_pitch&#039;&#039;&#039;es for computing the pixel locations. See {{VLCSourceFile|name=modules/video_filter/deinterlace/helpers.c}} for examples.&lt;br /&gt;
&lt;br /&gt;
=== Video_format_t vs. Plane_t ===&lt;br /&gt;
&lt;br /&gt;
In &#039;&#039;&#039;video_format_t&#039;&#039;&#039;, the &#039;&#039;&#039;i_visible_width&#039;&#039;&#039; and &#039;&#039;&#039;i_visible_height&#039;&#039;&#039; members go with &#039;&#039;&#039;i_x_offset&#039;&#039;&#039; and &#039;&#039;&#039;i_y_offset&#039;&#039;&#039;, but they are not related to &#039;&#039;&#039;plane_t::i_visible_*&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;plane_t::i_visible_*&#039;&#039;&#039; fields are there to know which part of the memory planes can at most be displayed. Usually these are different from the whole surface due to memory alignment constraints (like mod 16 for SSE2 or to be aligned on a macroblock). Those values are decided when the picture is allocated and they usually don&#039;t change for a given picture pointer (but they can change, like in direct3d buffers).&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;video_format_t:i_visible_width/height&#039;&#039;&#039; and &#039;&#039;&#039;i_x/y_offset&#039;&#039;&#039; are more a &#039;hint&#039; regarding what will be actually displayed. A filter should update &#039;&#039;&#039;filter_t::fmt_out&#039;&#039;&#039; if needed to ensure that the allocated pictures get the right value. A filter should, however, not limit its processing to this area, because VLC supports dynamic cropping.&lt;br /&gt;
&lt;br /&gt;
Thus, the correct thing to do in a filter is to process the whole picture area, or at least the first i_visible_* lines and pixels &#039;&#039;according to the &#039;&#039;&#039;plane_t&#039;&#039;&#039;s&#039;&#039;. Filters do not need to care about margin positioning or that there even exists such a thing as margins.&lt;br /&gt;
&lt;br /&gt;
== Disclaimer ==&lt;br /&gt;
&lt;br /&gt;
The information is mostly based on a few months&#039; hacking on the deinterlacer.&lt;br /&gt;
&lt;br /&gt;
This page is still a stub. Please add new relevant stuff.&lt;br /&gt;
&lt;br /&gt;
Also, the stuff that already exists could use better organization and formatting.&lt;br /&gt;
&lt;br /&gt;
{{Documentation}}&lt;/div&gt;</summary>
		<author><name>Technologicat</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=User:Technologicat&amp;diff=21334</id>
		<title>User:Technologicat</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=User:Technologicat&amp;diff=21334"/>
		<updated>2012-01-27T10:56:34Z</updated>

		<summary type="html">&lt;p&gt;Technologicat: Added note of video filter hacker guide&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;My name is Juha Jeronen. Technically, I&#039;m not an official VLC developer, but I subscribe to vlc-devel.&lt;br /&gt;
&lt;br /&gt;
I designed and programmed the IVTC and Phosphor deinterlacers for VLC 2.0 (which was then VLC 1.2), with help from fenrir for the MMX inline assembly. I also refactored the deinterlacer module at that time.&lt;br /&gt;
&lt;br /&gt;
I&#039;ve updated the [[Deinterlacing|deinterlacer]] documentation on the wiki, and written a [[Hacker_Guide/Video_Filters/Deinterlace|hacker&#039;s guide for the deinterlacer]]. I&#039;ve also written a [[Hacker_Guide/Video_Filters|hacker&#039;s guide for VLC&#039;s video filters in general]].&lt;br /&gt;
&lt;br /&gt;
As of 2012-01-27, I maintain the Finnish translation.&lt;/div&gt;</summary>
		<author><name>Technologicat</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=Hacker_Guide/How_To_Write_a_Module&amp;diff=21333</id>
		<title>Hacker Guide/How To Write a Module</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=Hacker_Guide/How_To_Write_a_Module&amp;diff=21333"/>
		<updated>2012-01-27T10:53:14Z</updated>

		<summary type="html">&lt;p&gt;Technologicat: Minor corrections to the English&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;VLC is based on many independent modules, like most competing multimedia frameworks. Each module introduces a new functionality.&lt;br /&gt;
&lt;br /&gt;
This article focuses on adding a new module (a.k.a. plug-in) to VLC. You &#039;&#039;&#039;will need to read&#039;&#039;&#039; [[Documentation:Hacker%27s_Guide/Core#VLC_Pipeline_and_Modularity|VLC Core and Modules ]] and [[Documentation:VLC_Modules_Loading|How VLC loads modules]] first, otherwise you will not be able to flesh out the content of your new module.&lt;br /&gt;
&lt;br /&gt;
== In-tree and out-of-tree modules ==&lt;br /&gt;
&lt;br /&gt;
Most existing VLC modules are provided as source code within the main VLC source code repository (and also the source tarballs). They are compiled at the same time as the VLC core, and usually provided distributed together with VLC binary packages and installers. These modules are called in-tree modules.&lt;br /&gt;
&lt;br /&gt;
However, it is also possible to write and compile VLC modules outside of VLC. That has some pros and cons over developing modules in-tree:&lt;br /&gt;
===Pros===&lt;br /&gt;
* Compilation is a lot faster (VLC and other modules are not included in the process).&lt;br /&gt;
* You can use your own version control system, or even none at all.&lt;br /&gt;
* The copyright license does not need to abide by the requirements of the [[VideoLAN]] association for inclusion in VLC. &lt;br /&gt;
* The source code does not need to be provided, reviewed and accepted by the VLC developers.&lt;br /&gt;
* The release schedule is independent of VLC releases. New versions of the module can be published at any time regardless of VLC release planning.&lt;br /&gt;
* Different programming languages can be used at least in theory. (The main VLC code base only uses C, C++ and Lua, and on MacOS Objective C.)&lt;br /&gt;
* The module can use software libraries that would be inadequate for VLC to depend on.&lt;br /&gt;
&lt;br /&gt;
===Cons===&lt;br /&gt;
* The VLC developers will not review the code, which would be a good opportunity fo improve the code quality.&lt;br /&gt;
* VLC translators will not take care of localization for the module(s) where applicable. VLC is translated in many tens of languages.&lt;br /&gt;
* The module(s) cannot be distributed through the [http://www.videolan.org/ videolan.org] website and use the VideoLAN infrastructure such as the bug tracker and the build bots.&lt;br /&gt;
* The module(s) will only work with the particular VLC (major) version that it has been compiled for. For instance, a module compiled for VLC 1.1.x will not work with VLC 1.0.x or VLC 2.0.x.&lt;br /&gt;
* The module(s) will only work on the particular operating systems and architecture that it has been compiled for. For instance, a Windows 32-bit module will only work with Windows 32-bit versions of VLC. VLC supports many different combinations of operating systems and architectures.&lt;br /&gt;
&lt;br /&gt;
== Example stub module  ==&lt;br /&gt;
&lt;br /&gt;
Let&#039;s start with a small example module in the C language: &lt;br /&gt;
&amp;lt;pre&amp;gt;/**&lt;br /&gt;
 * @file hello.c&lt;br /&gt;
 * @brief Hello world interface VLC module example&lt;br /&gt;
 */&lt;br /&gt;
#ifdef HAVE_CONFIG_H&lt;br /&gt;
# include &amp;quot;config.h&amp;quot;&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
/* VLC core API headers */&lt;br /&gt;
#include &amp;amp;lt;vlc_common.h&amp;amp;gt;&lt;br /&gt;
#include &amp;amp;lt;vlc_plugin.h&amp;amp;gt;&lt;br /&gt;
#include &amp;amp;lt;vlc_interface.h&amp;amp;gt;&lt;br /&gt;
&lt;br /&gt;
/* Forward declarations */&lt;br /&gt;
static int Open(vlc_object_t *);&lt;br /&gt;
static void Close(vlc_object_t *);&lt;br /&gt;
&lt;br /&gt;
/* Module descriptor */&lt;br /&gt;
vlc_module_begin()&lt;br /&gt;
    set_shortname(N_(&amp;quot;Hello&amp;quot;))&lt;br /&gt;
    set_description(N_(&amp;quot;Hello interface&amp;quot;))&lt;br /&gt;
    set_capability(&amp;quot;interface&amp;quot;, 0)&lt;br /&gt;
    set_callbacks(Open, Close)&lt;br /&gt;
    set_category(CAT_INTERFACE)&lt;br /&gt;
    add_string(&amp;quot;hello-who&amp;quot;, &amp;quot;world&amp;quot;, &amp;quot;Target&amp;quot;, &amp;quot;Whom to say hello to.&amp;quot;, false)&lt;br /&gt;
vlc_module_end ()&lt;br /&gt;
&lt;br /&gt;
/* Internal state for an instance of the module */&lt;br /&gt;
struct intf_sys_t&lt;br /&gt;
{&lt;br /&gt;
    char *who;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Starts our example interface.&lt;br /&gt;
 */&lt;br /&gt;
static int Open(vlc_object_t *obj)&lt;br /&gt;
{&lt;br /&gt;
    intf_thread_t *intf = (intf_thread_t *)obj;&lt;br /&gt;
&lt;br /&gt;
    /* Allocate internal state */&lt;br /&gt;
    intf_sys_t *sys = malloc(sizeof (*sys));&lt;br /&gt;
    if (unlikely(sys == NULL))&lt;br /&gt;
        return VLC_ENOMEM;&lt;br /&gt;
    intf-&amp;gt;p_sys = sys;&lt;br /&gt;
&lt;br /&gt;
    /* Read settings */&lt;br /&gt;
    char *who = var_InheritString(intf, &amp;quot;hello-who&amp;quot;);&lt;br /&gt;
    if (who == NULL)&lt;br /&gt;
    {&lt;br /&gt;
        msg_Err(intf, &amp;quot;Nobody to say hello to!&amp;quot;);&lt;br /&gt;
        goto error;&lt;br /&gt;
    }&lt;br /&gt;
    sys-&amp;gt;who = who;&lt;br /&gt;
&lt;br /&gt;
    msg_Info(intf, &amp;quot;Hello %s!&amp;quot;, who);&lt;br /&gt;
    return VLC_SUCCESS;&lt;br /&gt;
&lt;br /&gt;
error:&lt;br /&gt;
    free(sys);&lt;br /&gt;
    return VLC_EGENERIC;    &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * Stops the interface. &lt;br /&gt;
 */&lt;br /&gt;
static void Close(vlc_object_t *obj)&lt;br /&gt;
{&lt;br /&gt;
    intf_thread_t *intf = (intf_thread_t *)obj;&lt;br /&gt;
    intf_sys_t *sys = intf-&amp;gt;p_sys;&lt;br /&gt;
&lt;br /&gt;
    msg_Info(intf, &amp;quot;Good bye %s!&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    /* Free internal state */&lt;br /&gt;
    free(sys-&amp;gt;who);&lt;br /&gt;
    free(sys);&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And now some explanations about the code...&lt;br /&gt;
&lt;br /&gt;
=== Module Descriptor  ===&lt;br /&gt;
&lt;br /&gt;
A {{VLC}} module &#039;&#039;&#039;must&#039;&#039;&#039; include a &#039;&#039;description&#039;&#039; of itself, and the &#039;&#039;parameters&#039;&#039; it accepts. &lt;br /&gt;
&lt;br /&gt;
The module descriptor begins with: &lt;br /&gt;
&amp;lt;pre&amp;gt;vlc_module_begin();&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
You should set some basic information about your module. This is for the dvdread module:&lt;br /&gt;
&amp;lt;pre&amp;gt;    set_shortname(N_(&amp;quot;DVD without menus&amp;quot;));&lt;br /&gt;
    set_description(N_(&amp;quot;DVDRead Input&amp;quot;));&lt;br /&gt;
    set_category(CAT_INPUT);&lt;br /&gt;
    set_subcategory(SUBCAT_INPUT_ACCESS);&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&#039;&#039;Note&#039;&#039; the use of N_(&amp;quot;&amp;quot;) to create a string that needs to be translated by gettext.&lt;br /&gt;
&lt;br /&gt;
==== Capability and score ====&lt;br /&gt;
&lt;br /&gt;
Definition &#039;&#039;&#039;Example&#039;&#039;&#039;: &lt;br /&gt;
&amp;lt;pre&amp;gt;   set_capability(&amp;quot;interface&amp;quot;, 0)&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
This defines a module of &amp;quot;interface&amp;quot; capability and a score of 0.&lt;br /&gt;
&lt;br /&gt;
The capability determines the type of module we are dealing with. It could be an access, a demux, a decoder, an interface, etc. Now is the time to &#039;&#039;&#039;re-read [[Documentation:VLC Modules Loading#How_does_the_loading_of_modules_happens|how VLC loads modules]]&#039;&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
*If VLC needs to load a specific name, it will load it by its name and VLC directly opens this module &lt;br /&gt;
*If VLC needs a type of module (&amp;quot;I need a decoder&amp;quot;), VLC will load all modules matching this capability in a decreasing score order until one modules&#039;s Open() function (see later) returns VLC_SUCCESS.&lt;br /&gt;
&lt;br /&gt;
See the major types of [[Documentation:VLC Modules Loading#Major_Capabilities_of_Modules|capabilities of VLC]]. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Score&#039;&#039;&#039; should be an integer, and related to other scores in the same category. Score 0 is a [[Documentation:VLC_Modules_Loading#Score_of_0|special case]].&lt;br /&gt;
&lt;br /&gt;
==== Configuration categories and sub-categories  ====&lt;br /&gt;
&lt;br /&gt;
You should use &#039;&#039;&#039;one&#039;&#039;&#039; of the &#039;&#039;&#039;predefined categories&#039;&#039;&#039; for configuration. The configuration categories and sub-categories specify &#039;&#039;&#039;where&#039;&#039;&#039; the module will appear in the &#039;&#039;&#039;preferences&#039;&#039;&#039; UI dialog. &lt;br /&gt;
&lt;br /&gt;
The configuration categories include: &lt;br /&gt;
*CAT_INTERFACE &lt;br /&gt;
*CAT_AUDIO &lt;br /&gt;
*CAT_VIDEO &lt;br /&gt;
*CAT_INPUT &lt;br /&gt;
*CAT_SOUT &lt;br /&gt;
*CAT_ADVANCED &lt;br /&gt;
*CAT_PLAYLIST&lt;br /&gt;
&lt;br /&gt;
You should use one of &#039;&#039;&#039;predefined sub-categories&#039;&#039;&#039; as well. See {{VLCSourceFile|name=include/vlc_configuration.h}} for definition of all configuration categories and sub-categories. &lt;br /&gt;
&lt;br /&gt;
==== Configuration parameters ====&lt;br /&gt;
&lt;br /&gt;
You may need options to configure the run-time behavior of your module. Defining new options is easy. &lt;br /&gt;
&lt;br /&gt;
All option definitions take the following argument list: &lt;br /&gt;
&amp;lt;pre&amp;gt; add_integer(name, value, text, longtext, advanced) &amp;lt;/pre&amp;gt; &lt;br /&gt;
*&#039;&#039;&#039;name&#039;&#039;&#039; is the string that identifies this parameter in the configuration. This name is used at the command prompt to set the configuration value. &lt;br /&gt;
*&#039;&#039;&#039;value&#039;&#039;&#039; is the default value for this parameter, &lt;br /&gt;
*&#039;&#039;&#039;text&#039;&#039;&#039; A short description of the parameter, use _(&amp;quot;&amp;quot;) to create a string that needs to be translated, &lt;br /&gt;
*&#039;&#039;&#039;longtext&#039;&#039;&#039; A complete description of the parameter, use _(&amp;quot;&amp;quot;) to create a string that needs to be translated,&lt;br /&gt;
*&#039;&#039;&#039;advanced&#039;&#039;&#039; Boolean, ADVanced Configuration. If TRUE, this parameter will only be displayed when using the --advanced flag.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt; You may add the following options/parameter types to your module: &lt;br /&gt;
*add_integer, &lt;br /&gt;
*add_string, &lt;br /&gt;
*add_float, &lt;br /&gt;
*add_bool, &lt;br /&gt;
*add_key, &lt;br /&gt;
*add_file, &lt;br /&gt;
*add_directory,&lt;br /&gt;
&lt;br /&gt;
For complete definitions, see {{VLCSourceFile|name=include/vlc_plugin.h}}&lt;br /&gt;
&lt;br /&gt;
==== Callback  ====&lt;br /&gt;
&lt;br /&gt;
The activation and deactivation functions, detailed afterwards, must be defined in the descriptor. This is so that the VLC core knows how to instantiate and run the module.&lt;br /&gt;
&lt;br /&gt;
The set_callbacks() macro allows you to define 2 parameters: the first parameter is the pf_activate callback, and the second one, pf_deactivate. The functions are most often called &amp;quot;Open&amp;quot; and &amp;quot;Close&amp;quot; respectively, though. VLC invokes the pf_activate callback if/when it needs a plugin instance providing the correct interface, as declared with the set_capability() macro.&lt;br /&gt;
&lt;br /&gt;
Conversely, VLC invokes the pf_deactivate callback when the plugin is no longer needed - but only if the pf_activate callback returned VLC_SUCCESS (0) earlier.&lt;br /&gt;
&lt;br /&gt;
=== Open(vlc_object_t *) ===&lt;br /&gt;
&lt;br /&gt;
The most important function of a module is the opening: the usually-named Open() function. &lt;br /&gt;
&amp;lt;pre&amp;gt;static int  Open ( vlc_object_t * );&amp;lt;/pre&amp;gt; &lt;br /&gt;
The Open() function is called when the VLC core tries to open the module, and wants to load it. &lt;br /&gt;
&lt;br /&gt;
During Open(), setup of structures, devices or I/O, checks should be done. A successful open should return VLC_SUCCESS. If the module cannot complete its initialization, it can return any other value, usually VLC_EGENERIC or VLC_ENOMEM.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Open()&#039;&#039;&#039; function is expected to allocate private data (if any), and set up the private structure.&lt;br /&gt;
&lt;br /&gt;
If the Opening fails, you may need to free any already allocated resources before returning. Otherwise, leaks will occur.&lt;br /&gt;
&lt;br /&gt;
=== Close(vlc_object_t *)  ===&lt;br /&gt;
The second most important function of a module is the closing: the usually-named Close() function.&lt;br /&gt;
&amp;lt;pre&amp;gt;static int  Close ( vlc_object_t * );&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Close() function is called when the VLC core tries to close or unload an &#039;&#039;&#039;already-loaded&#039;&#039;&#039; module.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NB:&#039;&#039;&#039; If the Open() function failed, Close() will not get called.&lt;br /&gt;
&lt;br /&gt;
During Close(), closing devices or I/O, and cleaning of structures should be done. Do not leak memory here!&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Close()&#039;&#039;&#039; function should deallocate private data.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== In-tree module integration ==&lt;br /&gt;
&lt;br /&gt;
=== Git ===&lt;br /&gt;
If you plan to submit your work to VLC upstream, be sure to look at [[Git |the git introduction]] and check the [[Git#Submitting_patches_to_the_vlc-devel_or_x264-devel|send patches part]].&lt;br /&gt;
&lt;br /&gt;
=== Compiling your module ===&lt;br /&gt;
&lt;br /&gt;
==== Modules.am ====&lt;br /&gt;
First, find the right subdirectory under [[Modules_source_tree| modules/]] to add your new code.&lt;br /&gt;
&lt;br /&gt;
# If the module has only one source code file module, simply add it in the subdirectory (e.g. modules/control/hello.c).&lt;br /&gt;
# Larger modules should get a sub-subdirectory of their own (e.g. modules/control/hello/*).&lt;br /&gt;
&lt;br /&gt;
Then you need to declare the module in the build system. For example, the file {{VLCSourceFile|name=modules/control/Modules.am}} tells the build system which source files are needed for each control module. For the example above, we could add these lines:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
libhello_plugin_la_SOURCES = hello.c&lt;br /&gt;
libhello_plugin_la_CFLAGS = $(AM_CFLAGS)&lt;br /&gt;
libhello_plugin_la_LIBADD = $(AM_LIBADD)&lt;br /&gt;
libhello_plugin_la_DEPENDENCIES =&lt;br /&gt;
# Always compile the hello module:&lt;br /&gt;
libvlc_LTLIBRARIES += libhello_plugin.la&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that indentation in Modules.am (if needed) uses tabulations (ASCII 0x09), not white spaces.&lt;br /&gt;
&lt;br /&gt;
==== configure.ac ====&lt;br /&gt;
&lt;br /&gt;
If the module depends on some new library, some architecture or some operating system characteristics, you may need to extend configure.ac to detect when and how to build the module. Refer to the configure.ac file and the [http://www.gnu.org/software/autoconf/manual/index.html GNU autoconf documentation] for details.&lt;br /&gt;
&lt;br /&gt;
Once this is done, you should only need to rebuild VLC:&lt;br /&gt;
 make&lt;br /&gt;
(This will probably trigger a re-run of autoconf and automake, so it might take a while.)&lt;br /&gt;
&lt;br /&gt;
=== Loading your module ===&lt;br /&gt;
&lt;br /&gt;
VLC keeps a cache of available modules for performance reasons. It should be updated automatically. But you can use &#039;&#039;./vlc --reset-plugins-cache&#039;&#039; to force a reset.&lt;br /&gt;
&lt;br /&gt;
Then use&lt;br /&gt;
 ./vlc -vvv --color --list&lt;br /&gt;
to check that your plugin is seen by {{VLC}}.&lt;br /&gt;
&lt;br /&gt;
You should also see it in the plugins dialog of the [[Qt interface]] (Linux and Windows).&lt;br /&gt;
&lt;br /&gt;
== Out-of-tree module ==&lt;br /&gt;
&lt;br /&gt;
There is a dedicated article. Please read [[OutOfTreeCompile|out of tree compilation]].&lt;br /&gt;
&lt;br /&gt;
== Sub-modules  ==&lt;br /&gt;
&lt;br /&gt;
Sub-modules, declared in some module descriptors with &lt;br /&gt;
&lt;br /&gt;
 add_submodule()&lt;br /&gt;
&lt;br /&gt;
work exactly the same way as modules. They are useful when different modules (usually but not necessarily of different capability) share common code. All sub-modules will be included in the same run-time library as the main module.&lt;br /&gt;
&lt;br /&gt;
== Module types ==&lt;br /&gt;
&lt;br /&gt;
Depending on the module capability, you will need more information, about the necessary functions to implement.&lt;br /&gt;
&lt;br /&gt;
We will detail those here:&lt;br /&gt;
* [[Hacker_Guide/Access|Access]]&lt;br /&gt;
* [[Hacker_Guide/Demux|Demux]]&lt;br /&gt;
* [[Hacker_Guide/Access_Demux|Access_Demux]]&lt;br /&gt;
* [[Hacker_Guide/Decoder|Decoder]]&lt;br /&gt;
* Interface&lt;br /&gt;
* [[Hacker_Guide/Video_Filters|Video filter]]&lt;br /&gt;
* [[Hacker_Guide/Audio_Filters|Audio filter]]&lt;br /&gt;
* [[Hacker_Guide/Audio_Output|Audio output]]&lt;br /&gt;
&lt;br /&gt;
== Module load troubleshooting ==&lt;br /&gt;
&lt;br /&gt;
Sometimes when build an in-tree module, stuff doesn&#039;t work due to build system problems and other inconsistencies.&lt;br /&gt;
&lt;br /&gt;
You probably need to go to the root of your VLC source tree, and do something akin to the following. The examples here assume the &#039;&#039;bash&#039;&#039; shell.&lt;br /&gt;
&lt;br /&gt;
===&#039;&#039;&#039;Mild version&#039;&#039;&#039;===&lt;br /&gt;
&lt;br /&gt;
In some cases, automake dependencies break (for instance after some filenames have changed). This might then work:&lt;br /&gt;
&lt;br /&gt;
 find . -name .deps -exec rm -rf \{\} \;&lt;br /&gt;
 ./config.status&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
...but not always, so it may save some headaches to always use the &amp;quot;medium version&amp;quot; below.&lt;br /&gt;
&lt;br /&gt;
===&#039;&#039;&#039;Medium version&#039;&#039;&#039; (try this first)===&lt;br /&gt;
&lt;br /&gt;
This is a more radical but still safe rebuild procedure:&lt;br /&gt;
&lt;br /&gt;
 find . -name .deps -exec rm -rf \{\} \;&lt;br /&gt;
 ./bootstrap&lt;br /&gt;
 ./configure&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
===&#039;&#039;&#039;Extreme version&#039;&#039;&#039;===&lt;br /&gt;
&lt;br /&gt;
If the none of the above helped, you can clean the source tree as a measure of last resort.&lt;br /&gt;
Before you proceed, it is highly recommended that you check which files are going to be erased:&lt;br /&gt;
 git clean -nxd&lt;br /&gt;
&lt;br /&gt;
And then check what source code changes you would lose (if any):&lt;br /&gt;
 git diff&lt;br /&gt;
&lt;br /&gt;
You can extremely easily lose entire days of hard work with the following commands. &lt;br /&gt;
The first command will permanently remove any files not tracked in [[git]], including files that you might have created yourself.&lt;br /&gt;
The second command will remove any uncommitted modification to existing files. Consider yourself warned.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;!!!BEWARE: THIS MAY CAUSE UNRECOVERABLE DATA LOSS!!!&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 git clean -fxd&lt;br /&gt;
 git reset --hard HEAD&lt;br /&gt;
 ./bootstrap&lt;br /&gt;
 ./configure&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
{{Documentation}} &lt;br /&gt;
[[Category:Coding]]&lt;/div&gt;</summary>
		<author><name>Technologicat</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=User:Technologicat&amp;diff=21332</id>
		<title>User:Technologicat</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=User:Technologicat&amp;diff=21332"/>
		<updated>2012-01-27T10:39:24Z</updated>

		<summary type="html">&lt;p&gt;Technologicat: User page created&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;My name is Juha Jeronen. Technically, I&#039;m not an official VLC developer, but I subscribe to vlc-devel.&lt;br /&gt;
&lt;br /&gt;
I designed and programmed the IVTC and Phosphor deinterlacers for VLC 2.0 (which was then VLC 1.2), with help from fenrir for the MMX inline assembly. I also refactored the deinterlacer module at that time. I&#039;ve updated the [[Deinterlacing|deinterlacer]] documentation on the wiki, and written a [[Hacker_Guide/Video_Filters/Deinterlace|hacker&#039;s guide]] for the deinterlacer.&lt;br /&gt;
&lt;br /&gt;
As of 2012-01-27, I maintain the Finnish translation.&lt;/div&gt;</summary>
		<author><name>Technologicat</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=Hacker_Guide/Video_Filters/Deinterlace&amp;diff=21330</id>
		<title>Hacker Guide/Video Filters/Deinterlace</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=Hacker_Guide/Video_Filters/Deinterlace&amp;diff=21330"/>
		<updated>2012-01-27T10:13:05Z</updated>

		<summary type="html">&lt;p&gt;Technologicat: Added some more links to YUV page. Mainly the new J420, J422 (which now have a description there), but also some missing I420, I422, YV12.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Module|name=deinterlace|type=video filter2|description=Removes interlacing from display}}&lt;br /&gt;
&lt;br /&gt;
This is the [[Documentation:Hacker&#039;s_Guide|Hacker&#039;s Guide]] for the deinterlace module. See also the technical summary in the [[Deinterlace|user documentation]].&lt;br /&gt;
&lt;br /&gt;
== Interfacing with the deinterlacer ==&lt;br /&gt;
&lt;br /&gt;
This section deals with interfacing other parts of {{VLC}} with the deinterlacer. For a description of the internals, skip ahead.&lt;br /&gt;
&lt;br /&gt;
=== How to prepare input ===&lt;br /&gt;
&lt;br /&gt;
The deinterlacer assumes that the input consists of full frames (picture_t), with i_nb_fields == 2 or 3 (depending of repeat_pict flags in the input stream), b_progressive == false, and full vertical resolution (i_visible_lines) of the input stream. The b_top_field_first flag is also optionally used by the deinterlacer, and must be set correctly to guarantee correct operation in all modes.&lt;br /&gt;
&lt;br /&gt;
Each plane is stored linearly, one line at a time, in an uint8_t array of size i_lines*i_pitch, where i_lines and i_pitch can be read off the plane_t for each plane (e.g. &amp;lt;nowiki&amp;gt;p_pic-&amp;gt;p[plane_index].i_lines&amp;lt;/nowiki&amp;gt;). In YUV formats, the luma and chroma planes have different resolution.&lt;br /&gt;
&lt;br /&gt;
Note that i_lines may differ from i_visible_lines and i_pitch from i_visible_pitch. The value of i_pitch depends on how the picture_t was created. The filter picture pool may, and usually does, have a pitch different from that produced by picture_NewFromFormat(), even though the visible pitches are the same.&lt;br /&gt;
&lt;br /&gt;
It is assumed that the active picture area starts at the upper left edge. The first i_visible_lines lines (0 through i_visible_lines-1, inclusive), make up the visible lines. The rest of the lines (i_visible_lines through i_lines-1, inclusive) are the (invisible) vertical margin.&lt;br /&gt;
&lt;br /&gt;
Pixels at offsets 0 to i_visible_pitch-1 relative to each visible line start are visible. The rest of the pixels, at offsets i_visible_pitch to i_pitch-1, make up the (invisible) horizontal margin.&lt;br /&gt;
&lt;br /&gt;
It is not necessary to initialize the memory in the invisible parts; writing just the visible part of the picture is enough.&lt;br /&gt;
&lt;br /&gt;
Note that this implies that any processing loops only need to iterate through the part from 0 to i_visible_pitch (and i_visible_lines), but the pixel offsets in the array must be computed using i_pitch.&lt;br /&gt;
&lt;br /&gt;
For any plane that has full vertical resolution, the (macro-)pixels are stored as if the frame was progressive, i.e. the fields are interleaved. Line 0 of the plane comes from the top field, line 1 from the bottom field, line 2 from the top field, and so on. This always holds for the luma plane, and in the 4:2:2 chroma formats ([[I422]] and [[J422]]), also for the chroma planes.&lt;br /&gt;
&lt;br /&gt;
If the chroma format is 4:2:0 ([[I420]], [[J420]] or [[YV12]]), both fields share the same chroma. This kind of chroma is stored as-is, at half resolution (both horizontal and vertical) in the U and V planes of the picture_t. The same linear format is used as above (array of size i_lines*i_pitch, first i_visible_lines used, and first i_visible_pitch pixels on each visible line used), but because there is only one &amp;quot;chroma field&amp;quot; in this case, the fields do not alternate. Instead, chroma line 0 corresponds to luma lines 0 and 1, chroma line 1 to luma lines 2 and 3, and so on.&lt;br /&gt;
&lt;br /&gt;
Additionally, if chroma is [[YV12]], the U plane is stored in the array index V_PLANE, and the V plane is stored in the array index U_PLANE. This is because [[YV12]] uses the plane ordering YVU, while the array index constants (see include/vlc_picture.h) are named according to the more common ordering YUV. For all chroma formats using the more common ordering, U_PLANE refers to the U component and V_PLANE to the V component, as expected.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;p_pic-&amp;gt;p[Y_PLANE].p_pixels[23*w+42]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;nowiki&amp;gt;w = p_pic-&amp;gt;p[Y_PLANE].i_pitch&amp;lt;/nowiki&amp;gt;, refers to the pixel on the luma&lt;br /&gt;
plane at x = 42, y = 23 (0-based indexing).&lt;br /&gt;
&lt;br /&gt;
If the chroma is [[I420]] or [[J420]],&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;p_pic-&amp;gt;p[U_PLANE].p_pixels[11*w+21]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where now &amp;lt;nowiki&amp;gt;w = p_pic-&amp;gt;p[U_PLANE].i_pitch&amp;lt;/nowiki&amp;gt;, refers to the chroma macropixel&lt;br /&gt;
on the U plane that corresponds to the above example. Obviously, 11 =&lt;br /&gt;
floor(23/2).&lt;br /&gt;
&lt;br /&gt;
For 4:2:2 chroma ([[I422]] or [[J422]]), only the horizontal chroma resolution is half that of the luma, and the corresponding macropixel is&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;p_pic-&amp;gt;p[U_PLANE].p_pixels[23*w+21]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== How to interpret output ===&lt;br /&gt;
&lt;br /&gt;
The frames output by the deinterlacer are picture_t&#039;s, with i_nb_fields == 2 and b_progressive == true. The output chroma format and number of visible lines are algorithm-dependent.&lt;br /&gt;
&lt;br /&gt;
Resolution and chroma conversions are allowed, and it should be assumed there is no particular relation between input and output. Currently possible output chroma formats are [[I420]], [[YV12]], [[J420]], [[I422]] and [[J422]]. Vertical resolution may be original or half. Thus, chroma format and vertical resolution should be read off the output frame metadata (appropriate picture_t data fields).&lt;br /&gt;
&lt;br /&gt;
From the top-level Deinterlace(), the output pictures go into a linked list (using the &amp;quot;next&amp;quot; pointer in picture_t), which is then given to the caller. What happens to the pictures then, is outside the scope of the module.&lt;br /&gt;
&lt;br /&gt;
Temporally, non-doubling deinterlacers produce exactly one output picture per one input, IVTC produces one or zero (at the dropped frame), and framerate doublers produce two or three (depending on repeat_pict of each input frame).&lt;br /&gt;
&lt;br /&gt;
The timings (presentation timestamp; PTS; picture_t data field &amp;quot;date&amp;quot;) may change arbitrarily between input and output. It is not even guaranteed that calling the deinterlacer for an input frame outputs a frame corresponding to that input frame. Yadif uses the frame offset feature, and IVTC effectively does, too. This means that when frame &amp;quot;2&amp;quot; goes in, what comes out is deinterlaced frame &amp;quot;1&amp;quot; - in the case of Yadif, still with its original PTS! (The offset does NOT introduce a delay; thus it keeps A/V sync intact. This is why it is called i_frame_offset and not i_frame_delay in the code.) In the case of IVTC, the PTS is somewhat like original, but corrected for the 29.97 &amp;gt; 23.976 fps conversion... usually.&lt;br /&gt;
&lt;br /&gt;
The [[deinterlace]] filter is not required to actually output anything the first few times it is called. Some algorithms keep a history and use it for temporal filtering. Currently, this is 3 input pictures, and the first call to Deinterlace() always outputs a picture. The second call may drop. From the third call on, the history buffer has filled, and at this point it is guaranteed that normal operation starts as defined by the chosen algorithm.&lt;br /&gt;
&lt;br /&gt;
For generality, it should be assumed that M input pictures map to N output pictures, with arbitrary, different M and N. Note that even though repeat_pict means &amp;quot;repeat first field&amp;quot;, the first and third output pictures from a framerate doubler, for any given input frame, are allowed to be different due to temporal filtering. (Phosphor does this.) Thus, it should also be assumed that each output picture is unique.&lt;br /&gt;
&lt;br /&gt;
It may or may not be safe to display-hold still images, depending on the deinterlacing algorithm. For non-doublers, this is safe. For doublers, it is not. This is because framerate doubling algorithms are often designed based on the illusion of increased perceived resolution that can be achieved by rapidly alternating half-resolution images in an appropriate way.&lt;br /&gt;
&lt;br /&gt;
Thus, &amp;quot;progressive&amp;quot; pictures from framerate doublers are not actually progressive (at least not at full resolution), but only appear so while the filter is constantly producing new pictures at a steady framerate. Unfortunately, currently there is no way to determine from the outside which kind of algorithm has been chosen.&lt;br /&gt;
&lt;br /&gt;
== File structure ==&lt;br /&gt;
&lt;br /&gt;
This applies to &amp;lt;nowiki&amp;gt;[c7d289cad5c9f73d1bfc5b136b503fc3646b6e41]&amp;lt;/nowiki&amp;gt; (1st May 2011) and later.&lt;br /&gt;
&lt;br /&gt;
The deinterlace filter is located in [http://git.videolan.org/?p=vlc.git;f=modules/video_filter/deinterlace;hb=HEAD modules/video_filter/deinterlace/].&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;modules/video_filter/deinterlace/deinterlace.[ch]&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
** The main files of the filter.&lt;br /&gt;
** {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.c}}&lt;br /&gt;
** {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.h}}&lt;br /&gt;
* &#039;&#039;&#039;{{VLCSourceFile|name=modules/video_filter/deinterlace/common.h}}&#039;&#039;&#039;&lt;br /&gt;
** Common macros (min, max, etc.).&lt;br /&gt;
* &#039;&#039;&#039;{{VLCSourceFile|name=modules/video_filter/deinterlace/mmx.h}}&#039;&#039;&#039;&lt;br /&gt;
** Macros for MMX inline assembly support. Safe to include only #ifdef CAN_COMPILE_MMXEXT.&lt;br /&gt;
* &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;modules/video_filter/deinterlace/helpers.[ch]&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
** General-use helper functions: interlace detection, motion detection, glueing a field pair to make a frame.&lt;br /&gt;
** {{VLCSourceFile|name=modules/video_filter/deinterlace/helpers.c}}&lt;br /&gt;
** {{VLCSourceFile|name=modules/video_filter/deinterlace/helpers.h}}&lt;br /&gt;
* &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;modules/video_filter/deinterlace/merge.[ch]&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
** Line-blending functions and (in header) macros for mixing two picture lines into one. (You&#039;ll want to use the Merge() and EndMerge() macros.)&lt;br /&gt;
** {{VLCSourceFile|name=modules/video_filter/deinterlace/merge.c}}&lt;br /&gt;
** {{VLCSourceFile|name=modules/video_filter/deinterlace/merge.h}}&lt;br /&gt;
* &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;modules/video_filter/deinterlace/algo_basic.[ch]&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
** Basic algorithms: Discard, Bob, Linear, Mean, Blend.&lt;br /&gt;
** {{VLCSourceFile|name=modules/video_filter/deinterlace/algo_basic.c}}&lt;br /&gt;
** {{VLCSourceFile|name=modules/video_filter/deinterlace/algo_basic.h}}&lt;br /&gt;
* &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;modules/video_filter/deinterlace/algo_*.[ch]&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
** Advanced algorithms, one algorithm per set of .c and .h.&lt;br /&gt;
** If the same algorithm has framerate-doubling and non-doubling versions, it counts here as the same algorithm. For example, both yadif and yadif2x are implemented in algo_yadif.c (in the same render function, even).&lt;br /&gt;
** As of &amp;lt;nowiki&amp;gt;[c7d289cad5c9f73d1bfc5b136b503fc3646b6e41]&amp;lt;/nowiki&amp;gt;, the following files exist:&lt;br /&gt;
** {{VLCSourceFile|name=modules/video_filter/deinterlace/algo_x.c}}&lt;br /&gt;
** {{VLCSourceFile|name=modules/video_filter/deinterlace/algo_x.h}}&lt;br /&gt;
** {{VLCSourceFile|name=modules/video_filter/deinterlace/algo_yadif.c}}&lt;br /&gt;
** {{VLCSourceFile|name=modules/video_filter/deinterlace/algo_yadif.h}}&lt;br /&gt;
** {{VLCSourceFile|name=modules/video_filter/deinterlace/algo_phosphor.c}}&lt;br /&gt;
** {{VLCSourceFile|name=modules/video_filter/deinterlace/algo_phosphor.h}}&lt;br /&gt;
** {{VLCSourceFile|name=modules/video_filter/deinterlace/algo_ivtc.c}}&lt;br /&gt;
** {{VLCSourceFile|name=modules/video_filter/deinterlace/algo_ivtc.h}}&lt;br /&gt;
&lt;br /&gt;
The list of files making up the module (for the build system) is in {{VLCSourceFile|name=modules/video_filter/Modules.am}}.&lt;br /&gt;
&lt;br /&gt;
== Understanding the code ==&lt;br /&gt;
&lt;br /&gt;
It is recommended to look at the existing algorithms:&lt;br /&gt;
&lt;br /&gt;
* The simple algorithms in algo_basic.c make good first examples in getting to know the internals of the deinterlacer. But to avoid becoming confused:&lt;br /&gt;
** First, make sure to understand the implications of the flags (b_double_rate, b_half_height) for each mode in SetFilterMethod() (deinterlace.c).&lt;br /&gt;
** Then, understand the implications of the output chroma choosing logic in GetOutputFormat() (deinterlace.c).&lt;br /&gt;
** Note that these flags are nowhere to be seen inside algo_basic.c itself!&lt;br /&gt;
** You can also refer to the technical summary table in [[Deinterlacing]]. After reading that, it should all make (more) sense.&lt;br /&gt;
* algo_x.c provides an example of an advanced algorithm with lots of private functions.&lt;br /&gt;
* algo_yadif.c provides an example of glueing an existing algorithm to VLC. The original file from MPlayer is yadif.h; algo_yadif.* are glue code for VLC.&lt;br /&gt;
* ComposeFrame() in helpers.c provides an example of chroma conversions. See algo_phosphor.c for its usage.&lt;br /&gt;
* Soft field repeat, which &#039;&#039;&#039;must&#039;&#039;&#039; be supported by all framerate doublers, is handled differently in different filters. What is a sensible way depends on how the algorithm works. See Bob, Yadif, and Phosphor for very different examples.&lt;br /&gt;
&lt;br /&gt;
Also, generally:&lt;br /&gt;
&lt;br /&gt;
* See the available macros and helper functions in common.h, helpers.h, merge.h, and also {{VLCSourceFile|name=include/vlc_picture.h}}.&lt;br /&gt;
* Make sure you understand 4:2:0 and 4:2:2 chroma (explanation and pictures at [http://en.wikipedia.org/wiki/Chroma_subsampling#Sampling_systems_and_ratios Wikipedia]).&lt;br /&gt;
** The filter supports [[I420]], [[J420]], [[YV12]], [[I422]] and [[J422]] chroma. See [[YUV]] on the VideoLAN wiki.&lt;br /&gt;
** [[YV12]] is YVU (3 planes), others are YUV (3 planes). Except the plane order, [[YV12]] is identical to [[I420]].&lt;br /&gt;
** The Y component of J has full (&amp;quot;digital&amp;quot;) scale 0..255, instead of the &amp;quot;analog&amp;quot; 16..240 of I. Usually you don&#039;t need to care about this distinction, if you stay within the same chroma, or only convert between 4:2:0 and 4:2:2, preserving I/J.&lt;br /&gt;
** Note that if you want to upconvert [[YV12]] into [[I422]], you will need to swap the U and V planes. For an example, see ComposeFrame() in helpers.c.&lt;br /&gt;
** See {{VLCSourceFile|name=include/vlc_fourcc.h}}.&lt;br /&gt;
** Useful constants: Y_PLANE, U_PLANE, V_PLANE ({{VLCSourceFile|name=include/vlc_picture.h}}). For [[YV12]], U_PLANE actually refers to V, and V_PLANE to U.&lt;br /&gt;
* Much of the stuff is thoroughly documented. See the comments (and please keep them up to date when you modify things).&lt;br /&gt;
&lt;br /&gt;
== Adding a new mode ==&lt;br /&gt;
&lt;br /&gt;
So, you have thought up a new algorithm, or maybe you want to add in an existing one from another GPL-compatible project.&lt;br /&gt;
&lt;br /&gt;
Here is a checklist for implementing a new mode:&lt;br /&gt;
&lt;br /&gt;
* Choose a unique internal name (for config system and module internal use), and a user label (for GUI).&lt;br /&gt;
** Update the mode lists in {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.h}}&lt;br /&gt;
** The internal names must not be localized; use bare strings, e.g. &amp;quot;label&amp;quot;&lt;br /&gt;
** The user labels should be localized if they contain English, e.g. N_(&amp;quot;My Label&amp;quot;)&lt;br /&gt;
** In some special cases, user labels might not need localization, e.g. &amp;quot;X&amp;quot;&lt;br /&gt;
** If you need unicode characters in the user label, use the \uxxxx feature of C99 (e.g. \u00b2 is the superscript two / math squared symbol, so &amp;lt;nowiki&amp;gt;static const char* const my_label = &amp;quot;X\u00b2&amp;quot;;&amp;lt;/nowiki&amp;gt; will render as X&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt; in the GUI).&lt;br /&gt;
*** Here unicode = anything that is not 7-bit ASCII&lt;br /&gt;
*** This is especially important if you intend it for translation, since gettext does not allow unicode characters in the original C locale strings.&lt;br /&gt;
* Write support code in {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.c}}:&lt;br /&gt;
** Need configuration options? Search for &#039;&#039;phosphor-chroma&#039;&#039; for an example of making one.&lt;br /&gt;
*** If you do add an option, update ppsz_filter_options[]. It is used to validate what options exist.&lt;br /&gt;
** Update SetFilterMethod():&lt;br /&gt;
*** Setup the flags for your mode. It is up to you to define how you want your algorithm to behave; certain conversions between input and output are allowed. (Keep this in mind when reading existing modes as examples! Refer to this function if necessary.)&lt;br /&gt;
**** b_double_rate = framerate doubler/field renderer.&lt;br /&gt;
***** If true, it means your mode outputs one frame for each input field.&lt;br /&gt;
***** If false, it means your mode outputs one frame for each input frame.&lt;br /&gt;
***** These two types behave differently; see e.g. RenderDiscard() (no doubling) and RenderBob() (doubling) for the simplest examples.&lt;br /&gt;
***** Framerate doublers &#039;&#039;&#039;must&#039;&#039;&#039; support soft field repeat (nb_fields == 3). If you&#039;re not quite sure how to process the middle field, it&#039;s usually safe just to copy the input picture, since a field repeat usually implies no motion during that frame.&lt;br /&gt;
***** Soft field repeat is necessary to support some NTSC film sources correctly. These include anything that is soft-telecined, as well as sources where some space has been saved by using field repeat in some frames with no motion. Examples from anime: Sol Bianca (field repeats; this is a 24p/60i hybrid anime), Silent Mobius (field repeats, soft TC), Angel Links (soft TC), Stellvia of the Universe (soft TC).&lt;br /&gt;
**** b_half_height = halved vertical resolution in output.&lt;br /&gt;
***** If false, the output has as many lines as the input. (This is the usual choice.)&lt;br /&gt;
***** If true, the output has only half the number of lines when compared to input. Useful for some special cases, though it&#039;s fair to say all useful ones have already been covered in algo_basic.c.&lt;br /&gt;
***** Note that this refers to the data resolution; you can still output a picture with doubled (copied) lines even if you use full resolution (RenderBob() does this).&lt;br /&gt;
**** b_use_frame_history = use the input frame history buffer.&lt;br /&gt;
***** If true, you will have the three (HISTORY_SIZE) latest frames available in the array pp_history[] in filter_sys_t. You can fetch the frames from there; your render function does not need an input picture parameter. This is useful for temporal filtering. See RenderYadif() for an example of using the history buffer.&lt;br /&gt;
***** If false, you will need to feed each input picture to your render function directly. This is meant for filters that map the frames in a simple 1 -&amp;gt; 1 (or 1 -&amp;gt; 2) manner, needing no history. See anything in algo_basic.c, or RenderX() (algo_x.c), for an example.&lt;br /&gt;
***** It is up to you to decide which frame you want to output at each call; see RenderYadif() (outputs second latest frame) and RenderPhosphor() (outputs latest frame) for examples. See i_frame_offset in filter_sys_t.&lt;br /&gt;
** Update GetOutputFormat():&lt;br /&gt;
*** Setup which chroma your mode outputs, and under which kind of input.&lt;br /&gt;
**** Usually you just want to pass it through. This is the default for 4:2:0 input, but &#039;&#039;&#039;do&#039;&#039;&#039; add your mode into the first switch statement to support 4:2:2 input correctly.&lt;br /&gt;
**** What &amp;quot;correct&amp;quot; means is up to you; see the Phosphor algorithm for an example doing chroma conversions.&lt;br /&gt;
*** Half-heighting is already handled by setting the flag in SetFilterMethod(), so there&#039;s no need to touch that part.&lt;br /&gt;
** Deinterlace() handles some things for you automatically:&lt;br /&gt;
*** Allocation of output frames (so you can simply render into them).&lt;br /&gt;
*** Setting the correct output timestamps (PTS), also for framerate doublers.&lt;br /&gt;
**** You &#039;&#039;&#039;can&#039;&#039;&#039; use i_frame_offset = CUSTOM_PTS and compute the timestamps yourself, but this is needed only for nontrivial framerate conversions. For an example, see algo_ivtc.c, function IVTCOutputOrDropFrame().&lt;br /&gt;
** Update the switch statement in Deinterlace() to handle your new algorithm. See the existing cases for examples.&lt;br /&gt;
* Create algo_zzz.c and algo_zzz.h, where zzz is the internal name of your new mode.&lt;br /&gt;
** You want to write at least one public function: RenderZzz(), called from Deinterlace(). Most of the parameters of the render functions are self-explanatory, but i_order and i_field may need an explanation.&lt;br /&gt;
*** These two parameters are used only for algorithms, which support framerate doubling.&lt;br /&gt;
*** i_order is the temporal number, inside the current frame, of the current field being rendered: 0 (first), 1 (second) or 2 (repeated first, used only when nb_fields == 3).&lt;br /&gt;
*** i_field indicates which field is being rendered: 0 for top (lines 0, 2, 4, ...), 1 for bottom (lines 1, 3, 5, ...). &lt;br /&gt;
**** This needs to match i_order and the b_top_field_first flag &#039;&#039;of the picture you are currently rendering&#039;&#039;. (Note that this may not be the latest input picture, if you use the history buffer.)&lt;br /&gt;
**** To automatically get it correct, implement your case in Deinterlace() like the existing ones, and use i_frame_offset as instructed in deinterlace.h. Note that if you set i_frame_offset in your render function, it takes effect at the &#039;&#039;&#039;next&#039;&#039;&#039; input frame (defined as the next time Deinterlace() is called). See the rationale in {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.h}}.&lt;br /&gt;
*** If you want to use a framerate doubling algorithm in non-doubling mode, you can pass i_order = 0 and i_field = 0 (like the existing filters, which have both modes).&lt;br /&gt;
** If you need to have startup or cleanup code, see the Phosphor and IVTC algorithms for examples.&lt;br /&gt;
*** Phosphor configuration options are read in Open().&lt;br /&gt;
*** IVTCClearState() is called in Open() and in Flush(). It initializes/resets IVTC state.&lt;br /&gt;
*** Note that the filter may be flushed while running under some circumstances. If you allocated something upon startup, don&#039;t deallocate from Flush(), but make a separate deallocation function and call that from Close().&lt;br /&gt;
*** Note that the filter chain &#039;&#039;&#039;never&#039;&#039;&#039; changes the input format on the fly; it always Close()s and Open()s again.&lt;br /&gt;
** Keep in mind that the deinterlacer is low-level code and needs to be fast.&lt;br /&gt;
*** For example, for a 60i stream, a framerate doubler should render one output frame in preferably under 5ms. Note that the field interval in 60i is about 16ms, and some time is needed for decoding, rendering and such. 8ms and above is dangerously slow (will cause skipping).&lt;br /&gt;
*** Consider writing the inner processing loops in vectorized inline assembly, such as MMX. This can often gain a factor of 2-8x in speed, depending on how much and what kind of processing your algorithm needs.&lt;br /&gt;
* Update {{VLCSourceFile|name=modules/video_filter/Modules.am}}, so that the build system will compile your new files into the module. &lt;br /&gt;
See [[Documentation:Hacker&#039;s_Guide/How_To_Write_a_Module#Git_and_Repository_integration|new module integration]] for additional help.&lt;br /&gt;
&lt;br /&gt;
Finally, inform the rest of VLC about the existence of your new mode. There are some deinterlacer mode lists and validity checking code that is external to the deinterlacer module itself. Some of these contain the internal name, some the user label. Make sure that these match the ones you put in {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.h}}.&lt;br /&gt;
&lt;br /&gt;
As of this writing, these are located in:&lt;br /&gt;
&lt;br /&gt;
* {{VLCSourceFile|name=src/libvlc-module.c}}&lt;br /&gt;
* {{VLCSourceFile|name=src/control/video.c}}&lt;br /&gt;
* {{VLCSourceFile|name=src/video_output/interlacing.c}}&lt;br /&gt;
&lt;br /&gt;
Search for the string &#039;&#039;yadif&#039;&#039; to find the relevant parts quickly. The string is unique enough to match even from the whole source tree.&lt;br /&gt;
&lt;br /&gt;
Speaking of which, a pretty good way to keep up to date as to where to find this stuff is to go to the root of the vlc source tree in the terminal, and search for &#039;&#039;yadif&#039;&#039; recursively:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;find . -name &amp;quot;*.[ch]&amp;quot; -exec grep -Hr &#039;yadif&#039; \{\} \;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then just note down anything that matches anywhere else except modules/video_filter/deinterlace/.&lt;br /&gt;
&lt;br /&gt;
{{Documentation}}&lt;/div&gt;</summary>
		<author><name>Technologicat</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=Hacker_Guide/Video_Filters/Deinterlace&amp;diff=21329</id>
		<title>Hacker Guide/Video Filters/Deinterlace</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=Hacker_Guide/Video_Filters/Deinterlace&amp;diff=21329"/>
		<updated>2012-01-27T10:06:55Z</updated>

		<summary type="html">&lt;p&gt;Technologicat: /* Understanding the code */ Original statement maybe too strong...&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Module|name=deinterlace|type=video filter2|description=Removes interlacing from display}}&lt;br /&gt;
&lt;br /&gt;
This is the [[Documentation:Hacker&#039;s_Guide|Hacker&#039;s Guide]] for the deinterlace module. See also the technical summary in the [[Deinterlace|user documentation]].&lt;br /&gt;
&lt;br /&gt;
== Interfacing with the deinterlacer ==&lt;br /&gt;
&lt;br /&gt;
This section deals with interfacing other parts of {{VLC}} with the deinterlacer. For a description of the internals, skip ahead.&lt;br /&gt;
&lt;br /&gt;
=== How to prepare input ===&lt;br /&gt;
&lt;br /&gt;
The deinterlacer assumes that the input consists of full frames (picture_t), with i_nb_fields == 2 or 3 (depending of repeat_pict flags in the input stream), b_progressive == false, and full vertical resolution (i_visible_lines) of the input stream. The b_top_field_first flag is also optionally used by the deinterlacer, and must be set correctly to guarantee correct operation in all modes.&lt;br /&gt;
&lt;br /&gt;
Each plane is stored linearly, one line at a time, in an uint8_t array of size i_lines*i_pitch, where i_lines and i_pitch can be read off the plane_t for each plane (e.g. &amp;lt;nowiki&amp;gt;p_pic-&amp;gt;p[plane_index].i_lines&amp;lt;/nowiki&amp;gt;). In YUV formats, the luma and chroma planes have different resolution.&lt;br /&gt;
&lt;br /&gt;
Note that i_lines may differ from i_visible_lines and i_pitch from i_visible_pitch. The value of i_pitch depends on how the picture_t was created. The filter picture pool may, and usually does, have a pitch different from that produced by picture_NewFromFormat(), even though the visible pitches are the same.&lt;br /&gt;
&lt;br /&gt;
It is assumed that the active picture area starts at the upper left edge. The first i_visible_lines lines (0 through i_visible_lines-1, inclusive), make up the visible lines. The rest of the lines (i_visible_lines through i_lines-1, inclusive) are the (invisible) vertical margin.&lt;br /&gt;
&lt;br /&gt;
Pixels at offsets 0 to i_visible_pitch-1 relative to each visible line start are visible. The rest of the pixels, at offsets i_visible_pitch to i_pitch-1, make up the (invisible) horizontal margin.&lt;br /&gt;
&lt;br /&gt;
It is not necessary to initialize the memory in the invisible parts; writing just the visible part of the picture is enough.&lt;br /&gt;
&lt;br /&gt;
Note that this implies that any processing loops only need to iterate through the part from 0 to i_visible_pitch (and i_visible_lines), but the pixel offsets in the array must be computed using i_pitch.&lt;br /&gt;
&lt;br /&gt;
For any plane that has full vertical resolution, the (macro-)pixels are stored as if the frame was progressive, i.e. the fields are interleaved. Line 0 of the plane comes from the top field, line 1 from the bottom field, line 2 from the top field, and so on. This always holds for the luma plane, and in the 4:2:2 chroma formats ([[I422]] and J422), also for the chroma planes.&lt;br /&gt;
&lt;br /&gt;
If the chroma format is 4:2:0 ([[I420]], J420 or [[YV12]]), both fields share the same chroma. This kind of chroma is stored as-is, at half resolution (both horizontal and vertical) in the U and V planes of the picture_t. The same linear format is used as above (array of size i_lines*i_pitch, first i_visible_lines used, and first i_visible_pitch pixels on each visible line used), but because there is only one &amp;quot;chroma field&amp;quot; in this case, the fields do not alternate. Instead, chroma line 0 corresponds to luma lines 0 and 1, chroma line 1 to luma lines 2 and 3, and so on.&lt;br /&gt;
&lt;br /&gt;
Additionally, if chroma is [[YV12]], the U plane is stored in the array index V_PLANE, and the V plane is stored in the array index U_PLANE. This is because YV12 uses the plane ordering YVU, while the array index constants (see include/vlc_picture.h) are named according to the more common ordering YUV. For all chroma formats using the more common ordering, U_PLANE refers to the U component and V_PLANE to the V component, as expected.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;p_pic-&amp;gt;p[Y_PLANE].p_pixels[23*w+42]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;nowiki&amp;gt;w = p_pic-&amp;gt;p[Y_PLANE].i_pitch&amp;lt;/nowiki&amp;gt;, refers to the pixel on the luma&lt;br /&gt;
plane at x = 42, y = 23 (0-based indexing).&lt;br /&gt;
&lt;br /&gt;
If the chroma is I420 or J420,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;p_pic-&amp;gt;p[U_PLANE].p_pixels[11*w+21]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where now &amp;lt;nowiki&amp;gt;w = p_pic-&amp;gt;p[U_PLANE].i_pitch&amp;lt;/nowiki&amp;gt;, refers to the chroma macropixel&lt;br /&gt;
on the U plane that corresponds to the above example. Obviously, 11 =&lt;br /&gt;
floor(23/2).&lt;br /&gt;
&lt;br /&gt;
For 4:2:2 chroma (I422 or J422), only the horizontal chroma resolution is half that of the luma, and the corresponding macropixel is&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;p_pic-&amp;gt;p[U_PLANE].p_pixels[23*w+21]&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== How to interpret output ===&lt;br /&gt;
&lt;br /&gt;
The frames output by the deinterlacer are picture_t&#039;s, with i_nb_fields == 2 and b_progressive == true. The output chroma format and number of visible lines are algorithm-dependent.&lt;br /&gt;
&lt;br /&gt;
Resolution and chroma conversions are allowed, and it should be assumed there is no particular relation between input and output. Currently possible output chroma formats are [[I420]], [[YV12]], J420, [[I422]] and J422. Vertical resolution may be original or half. Thus, chroma format and vertical resolution should be read off the output frame metadata (appropriate picture_t data fields).&lt;br /&gt;
&lt;br /&gt;
From the top-level Deinterlace(), the output pictures go into a linked list (using the &amp;quot;next&amp;quot; pointer in picture_t), which is then given to the caller. What happens to the pictures then, is outside the scope of the module.&lt;br /&gt;
&lt;br /&gt;
Temporally, non-doubling deinterlacers produce exactly one output picture per one input, IVTC produces one or zero (at the dropped frame), and framerate doublers produce two or three (depending on repeat_pict of each input frame).&lt;br /&gt;
&lt;br /&gt;
The timings (presentation timestamp; PTS; picture_t data field &amp;quot;date&amp;quot;) may change arbitrarily between input and output. It is not even guaranteed that calling the deinterlacer for an input frame outputs a frame corresponding to that input frame. Yadif uses the frame offset feature, and IVTC effectively does, too. This means that when frame &amp;quot;2&amp;quot; goes in, what comes out is deinterlaced frame &amp;quot;1&amp;quot; - in the case of Yadif, still with its original PTS! (The offset does NOT introduce a delay; thus it keeps A/V sync intact. This is why it is called i_frame_offset and not i_frame_delay in the code.) In the case of IVTC, the PTS is somewhat like original, but corrected for the 29.97 &amp;gt; 23.976 fps conversion... usually.&lt;br /&gt;
&lt;br /&gt;
The [[deinterlace]] filter is not required to actually output anything the first few times it is called. Some algorithms keep a history and use it for temporal filtering. Currently, this is 3 input pictures, and the first call to Deinterlace() always outputs a picture. The second call may drop. From the third call on, the history buffer has filled, and at this point it is guaranteed that normal operation starts as defined by the chosen algorithm.&lt;br /&gt;
&lt;br /&gt;
For generality, it should be assumed that M input pictures map to N output pictures, with arbitrary, different M and N. Note that even though repeat_pict means &amp;quot;repeat first field&amp;quot;, the first and third output pictures from a framerate doubler, for any given input frame, are allowed to be different due to temporal filtering. (Phosphor does this.) Thus, it should also be assumed that each output picture is unique.&lt;br /&gt;
&lt;br /&gt;
It may or may not be safe to display-hold still images, depending on the deinterlacing algorithm. For non-doublers, this is safe. For doublers, it is not. This is because framerate doubling algorithms are often designed based on the illusion of increased perceived resolution that can be achieved by rapidly alternating half-resolution images in an appropriate way.&lt;br /&gt;
&lt;br /&gt;
Thus, &amp;quot;progressive&amp;quot; pictures from framerate doublers are not actually progressive (at least not at full resolution), but only appear so while the filter is constantly producing new pictures at a steady framerate. Unfortunately, currently there is no way to determine from the outside which kind of algorithm has been chosen.&lt;br /&gt;
&lt;br /&gt;
== File structure ==&lt;br /&gt;
&lt;br /&gt;
This applies to &amp;lt;nowiki&amp;gt;[c7d289cad5c9f73d1bfc5b136b503fc3646b6e41]&amp;lt;/nowiki&amp;gt; (1st May 2011) and later.&lt;br /&gt;
&lt;br /&gt;
The deinterlace filter is located in [http://git.videolan.org/?p=vlc.git;f=modules/video_filter/deinterlace;hb=HEAD modules/video_filter/deinterlace/].&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;modules/video_filter/deinterlace/deinterlace.[ch]&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
** The main files of the filter.&lt;br /&gt;
** {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.c}}&lt;br /&gt;
** {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.h}}&lt;br /&gt;
* &#039;&#039;&#039;{{VLCSourceFile|name=modules/video_filter/deinterlace/common.h}}&#039;&#039;&#039;&lt;br /&gt;
** Common macros (min, max, etc.).&lt;br /&gt;
* &#039;&#039;&#039;{{VLCSourceFile|name=modules/video_filter/deinterlace/mmx.h}}&#039;&#039;&#039;&lt;br /&gt;
** Macros for MMX inline assembly support. Safe to include only #ifdef CAN_COMPILE_MMXEXT.&lt;br /&gt;
* &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;modules/video_filter/deinterlace/helpers.[ch]&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
** General-use helper functions: interlace detection, motion detection, glueing a field pair to make a frame.&lt;br /&gt;
** {{VLCSourceFile|name=modules/video_filter/deinterlace/helpers.c}}&lt;br /&gt;
** {{VLCSourceFile|name=modules/video_filter/deinterlace/helpers.h}}&lt;br /&gt;
* &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;modules/video_filter/deinterlace/merge.[ch]&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
** Line-blending functions and (in header) macros for mixing two picture lines into one. (You&#039;ll want to use the Merge() and EndMerge() macros.)&lt;br /&gt;
** {{VLCSourceFile|name=modules/video_filter/deinterlace/merge.c}}&lt;br /&gt;
** {{VLCSourceFile|name=modules/video_filter/deinterlace/merge.h}}&lt;br /&gt;
* &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;modules/video_filter/deinterlace/algo_basic.[ch]&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
** Basic algorithms: Discard, Bob, Linear, Mean, Blend.&lt;br /&gt;
** {{VLCSourceFile|name=modules/video_filter/deinterlace/algo_basic.c}}&lt;br /&gt;
** {{VLCSourceFile|name=modules/video_filter/deinterlace/algo_basic.h}}&lt;br /&gt;
* &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;modules/video_filter/deinterlace/algo_*.[ch]&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;&lt;br /&gt;
** Advanced algorithms, one algorithm per set of .c and .h.&lt;br /&gt;
** If the same algorithm has framerate-doubling and non-doubling versions, it counts here as the same algorithm. For example, both yadif and yadif2x are implemented in algo_yadif.c (in the same render function, even).&lt;br /&gt;
** As of &amp;lt;nowiki&amp;gt;[c7d289cad5c9f73d1bfc5b136b503fc3646b6e41]&amp;lt;/nowiki&amp;gt;, the following files exist:&lt;br /&gt;
** {{VLCSourceFile|name=modules/video_filter/deinterlace/algo_x.c}}&lt;br /&gt;
** {{VLCSourceFile|name=modules/video_filter/deinterlace/algo_x.h}}&lt;br /&gt;
** {{VLCSourceFile|name=modules/video_filter/deinterlace/algo_yadif.c}}&lt;br /&gt;
** {{VLCSourceFile|name=modules/video_filter/deinterlace/algo_yadif.h}}&lt;br /&gt;
** {{VLCSourceFile|name=modules/video_filter/deinterlace/algo_phosphor.c}}&lt;br /&gt;
** {{VLCSourceFile|name=modules/video_filter/deinterlace/algo_phosphor.h}}&lt;br /&gt;
** {{VLCSourceFile|name=modules/video_filter/deinterlace/algo_ivtc.c}}&lt;br /&gt;
** {{VLCSourceFile|name=modules/video_filter/deinterlace/algo_ivtc.h}}&lt;br /&gt;
&lt;br /&gt;
The list of files making up the module (for the build system) is in {{VLCSourceFile|name=modules/video_filter/Modules.am}}.&lt;br /&gt;
&lt;br /&gt;
== Understanding the code ==&lt;br /&gt;
&lt;br /&gt;
It is recommended to look at the existing algorithms:&lt;br /&gt;
&lt;br /&gt;
* The simple algorithms in algo_basic.c make good first examples in getting to know the internals of the deinterlacer. But to avoid becoming confused:&lt;br /&gt;
** First, make sure to understand the implications of the flags (b_double_rate, b_half_height) for each mode in SetFilterMethod() (deinterlace.c).&lt;br /&gt;
** Then, understand the implications of the output chroma choosing logic in GetOutputFormat() (deinterlace.c).&lt;br /&gt;
** Note that these flags are nowhere to be seen inside algo_basic.c itself!&lt;br /&gt;
** You can also refer to the technical summary table in [[Deinterlacing]]. After reading that, it should all make (more) sense.&lt;br /&gt;
* algo_x.c provides an example of an advanced algorithm with lots of private functions.&lt;br /&gt;
* algo_yadif.c provides an example of glueing an existing algorithm to VLC. The original file from MPlayer is yadif.h; algo_yadif.* are glue code for VLC.&lt;br /&gt;
* ComposeFrame() in helpers.c provides an example of chroma conversions. See algo_phosphor.c for its usage.&lt;br /&gt;
* Soft field repeat, which &#039;&#039;&#039;must&#039;&#039;&#039; be supported by all framerate doublers, is handled differently in different filters. What is a sensible way depends on how the algorithm works. See Bob, Yadif, and Phosphor for very different examples.&lt;br /&gt;
&lt;br /&gt;
Also, generally:&lt;br /&gt;
&lt;br /&gt;
* See the available macros and helper functions in common.h, helpers.h, merge.h, and also {{VLCSourceFile|name=include/vlc_picture.h}}.&lt;br /&gt;
* Make sure you understand 4:2:0 and 4:2:2 chroma (explanation and pictures at [http://en.wikipedia.org/wiki/Chroma_subsampling#Sampling_systems_and_ratios Wikipedia]).&lt;br /&gt;
** The filter supports I420, J420, YV12, I422 and J422 chroma.&lt;br /&gt;
** YV12 is YVU (3 planes), others are YUV (3 planes). Except the plane order, YV12 is identical to I420.&lt;br /&gt;
** The Y component of J has full (&amp;quot;digital&amp;quot;) scale 0..255, instead of the &amp;quot;analog&amp;quot; 16..240 of I. Usually you don&#039;t need to care about this distinction, if you stay within the same chroma, or only convert between 4:2:0 and 4:2:2, preserving I/J.&lt;br /&gt;
** Note that if you want to upconvert YV12 into I422, you will need to swap the U and V planes. For an example, see ComposeFrame() in helpers.c.&lt;br /&gt;
** See {{VLCSourceFile|name=include/vlc_fourcc.h}}.&lt;br /&gt;
** Useful constants: Y_PLANE, U_PLANE, V_PLANE ({{VLCSourceFile|name=include/vlc_picture.h}}). For YV12, U_PLANE actually refers to V, and V_PLANE to U.&lt;br /&gt;
* Much of the stuff is thoroughly documented. See the comments (and please keep them up to date when you modify things).&lt;br /&gt;
&lt;br /&gt;
== Adding a new mode ==&lt;br /&gt;
&lt;br /&gt;
So, you have thought up a new algorithm, or maybe you want to add in an existing one from another GPL-compatible project.&lt;br /&gt;
&lt;br /&gt;
Here is a checklist for implementing a new mode:&lt;br /&gt;
&lt;br /&gt;
* Choose a unique internal name (for config system and module internal use), and a user label (for GUI).&lt;br /&gt;
** Update the mode lists in {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.h}}&lt;br /&gt;
** The internal names must not be localized; use bare strings, e.g. &amp;quot;label&amp;quot;&lt;br /&gt;
** The user labels should be localized if they contain English, e.g. N_(&amp;quot;My Label&amp;quot;)&lt;br /&gt;
** In some special cases, user labels might not need localization, e.g. &amp;quot;X&amp;quot;&lt;br /&gt;
** If you need unicode characters in the user label, use the \uxxxx feature of C99 (e.g. \u00b2 is the superscript two / math squared symbol, so &amp;lt;nowiki&amp;gt;static const char* const my_label = &amp;quot;X\u00b2&amp;quot;;&amp;lt;/nowiki&amp;gt; will render as X&amp;lt;sup&amp;gt;2&amp;lt;/sup&amp;gt; in the GUI).&lt;br /&gt;
*** Here unicode = anything that is not 7-bit ASCII&lt;br /&gt;
*** This is especially important if you intend it for translation, since gettext does not allow unicode characters in the original C locale strings.&lt;br /&gt;
* Write support code in {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.c}}:&lt;br /&gt;
** Need configuration options? Search for &#039;&#039;phosphor-chroma&#039;&#039; for an example of making one.&lt;br /&gt;
*** If you do add an option, update ppsz_filter_options[]. It is used to validate what options exist.&lt;br /&gt;
** Update SetFilterMethod():&lt;br /&gt;
*** Setup the flags for your mode. It is up to you to define how you want your algorithm to behave; certain conversions between input and output are allowed. (Keep this in mind when reading existing modes as examples! Refer to this function if necessary.)&lt;br /&gt;
**** b_double_rate = framerate doubler/field renderer.&lt;br /&gt;
***** If true, it means your mode outputs one frame for each input field.&lt;br /&gt;
***** If false, it means your mode outputs one frame for each input frame.&lt;br /&gt;
***** These two types behave differently; see e.g. RenderDiscard() (no doubling) and RenderBob() (doubling) for the simplest examples.&lt;br /&gt;
***** Framerate doublers &#039;&#039;&#039;must&#039;&#039;&#039; support soft field repeat (nb_fields == 3). If you&#039;re not quite sure how to process the middle field, it&#039;s usually safe just to copy the input picture, since a field repeat usually implies no motion during that frame.&lt;br /&gt;
***** Soft field repeat is necessary to support some NTSC film sources correctly. These include anything that is soft-telecined, as well as sources where some space has been saved by using field repeat in some frames with no motion. Examples from anime: Sol Bianca (field repeats; this is a 24p/60i hybrid anime), Silent Mobius (field repeats, soft TC), Angel Links (soft TC), Stellvia of the Universe (soft TC).&lt;br /&gt;
**** b_half_height = halved vertical resolution in output.&lt;br /&gt;
***** If false, the output has as many lines as the input. (This is the usual choice.)&lt;br /&gt;
***** If true, the output has only half the number of lines when compared to input. Useful for some special cases, though it&#039;s fair to say all useful ones have already been covered in algo_basic.c.&lt;br /&gt;
***** Note that this refers to the data resolution; you can still output a picture with doubled (copied) lines even if you use full resolution (RenderBob() does this).&lt;br /&gt;
**** b_use_frame_history = use the input frame history buffer.&lt;br /&gt;
***** If true, you will have the three (HISTORY_SIZE) latest frames available in the array pp_history[] in filter_sys_t. You can fetch the frames from there; your render function does not need an input picture parameter. This is useful for temporal filtering. See RenderYadif() for an example of using the history buffer.&lt;br /&gt;
***** If false, you will need to feed each input picture to your render function directly. This is meant for filters that map the frames in a simple 1 -&amp;gt; 1 (or 1 -&amp;gt; 2) manner, needing no history. See anything in algo_basic.c, or RenderX() (algo_x.c), for an example.&lt;br /&gt;
***** It is up to you to decide which frame you want to output at each call; see RenderYadif() (outputs second latest frame) and RenderPhosphor() (outputs latest frame) for examples. See i_frame_offset in filter_sys_t.&lt;br /&gt;
** Update GetOutputFormat():&lt;br /&gt;
*** Setup which chroma your mode outputs, and under which kind of input.&lt;br /&gt;
**** Usually you just want to pass it through. This is the default for 4:2:0 input, but &#039;&#039;&#039;do&#039;&#039;&#039; add your mode into the first switch statement to support 4:2:2 input correctly.&lt;br /&gt;
**** What &amp;quot;correct&amp;quot; means is up to you; see the Phosphor algorithm for an example doing chroma conversions.&lt;br /&gt;
*** Half-heighting is already handled by setting the flag in SetFilterMethod(), so there&#039;s no need to touch that part.&lt;br /&gt;
** Deinterlace() handles some things for you automatically:&lt;br /&gt;
*** Allocation of output frames (so you can simply render into them).&lt;br /&gt;
*** Setting the correct output timestamps (PTS), also for framerate doublers.&lt;br /&gt;
**** You &#039;&#039;&#039;can&#039;&#039;&#039; use i_frame_offset = CUSTOM_PTS and compute the timestamps yourself, but this is needed only for nontrivial framerate conversions. For an example, see algo_ivtc.c, function IVTCOutputOrDropFrame().&lt;br /&gt;
** Update the switch statement in Deinterlace() to handle your new algorithm. See the existing cases for examples.&lt;br /&gt;
* Create algo_zzz.c and algo_zzz.h, where zzz is the internal name of your new mode.&lt;br /&gt;
** You want to write at least one public function: RenderZzz(), called from Deinterlace(). Most of the parameters of the render functions are self-explanatory, but i_order and i_field may need an explanation.&lt;br /&gt;
*** These two parameters are used only for algorithms, which support framerate doubling.&lt;br /&gt;
*** i_order is the temporal number, inside the current frame, of the current field being rendered: 0 (first), 1 (second) or 2 (repeated first, used only when nb_fields == 3).&lt;br /&gt;
*** i_field indicates which field is being rendered: 0 for top (lines 0, 2, 4, ...), 1 for bottom (lines 1, 3, 5, ...). &lt;br /&gt;
**** This needs to match i_order and the b_top_field_first flag &#039;&#039;of the picture you are currently rendering&#039;&#039;. (Note that this may not be the latest input picture, if you use the history buffer.)&lt;br /&gt;
**** To automatically get it correct, implement your case in Deinterlace() like the existing ones, and use i_frame_offset as instructed in deinterlace.h. Note that if you set i_frame_offset in your render function, it takes effect at the &#039;&#039;&#039;next&#039;&#039;&#039; input frame (defined as the next time Deinterlace() is called). See the rationale in {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.h}}.&lt;br /&gt;
*** If you want to use a framerate doubling algorithm in non-doubling mode, you can pass i_order = 0 and i_field = 0 (like the existing filters, which have both modes).&lt;br /&gt;
** If you need to have startup or cleanup code, see the Phosphor and IVTC algorithms for examples.&lt;br /&gt;
*** Phosphor configuration options are read in Open().&lt;br /&gt;
*** IVTCClearState() is called in Open() and in Flush(). It initializes/resets IVTC state.&lt;br /&gt;
*** Note that the filter may be flushed while running under some circumstances. If you allocated something upon startup, don&#039;t deallocate from Flush(), but make a separate deallocation function and call that from Close().&lt;br /&gt;
*** Note that the filter chain &#039;&#039;&#039;never&#039;&#039;&#039; changes the input format on the fly; it always Close()s and Open()s again.&lt;br /&gt;
** Keep in mind that the deinterlacer is low-level code and needs to be fast.&lt;br /&gt;
*** For example, for a 60i stream, a framerate doubler should render one output frame in preferably under 5ms. Note that the field interval in 60i is about 16ms, and some time is needed for decoding, rendering and such. 8ms and above is dangerously slow (will cause skipping).&lt;br /&gt;
*** Consider writing the inner processing loops in vectorized inline assembly, such as MMX. This can often gain a factor of 2-8x in speed, depending on how much and what kind of processing your algorithm needs.&lt;br /&gt;
* Update {{VLCSourceFile|name=modules/video_filter/Modules.am}}, so that the build system will compile your new files into the module. &lt;br /&gt;
See [[Documentation:Hacker&#039;s_Guide/How_To_Write_a_Module#Git_and_Repository_integration|new module integration]] for additional help.&lt;br /&gt;
&lt;br /&gt;
Finally, inform the rest of VLC about the existence of your new mode. There are some deinterlacer mode lists and validity checking code that is external to the deinterlacer module itself. Some of these contain the internal name, some the user label. Make sure that these match the ones you put in {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.h}}.&lt;br /&gt;
&lt;br /&gt;
As of this writing, these are located in:&lt;br /&gt;
&lt;br /&gt;
* {{VLCSourceFile|name=src/libvlc-module.c}}&lt;br /&gt;
* {{VLCSourceFile|name=src/control/video.c}}&lt;br /&gt;
* {{VLCSourceFile|name=src/video_output/interlacing.c}}&lt;br /&gt;
&lt;br /&gt;
Search for the string &#039;&#039;yadif&#039;&#039; to find the relevant parts quickly. The string is unique enough to match even from the whole source tree.&lt;br /&gt;
&lt;br /&gt;
Speaking of which, a pretty good way to keep up to date as to where to find this stuff is to go to the root of the vlc source tree in the terminal, and search for &#039;&#039;yadif&#039;&#039; recursively:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;find . -name &amp;quot;*.[ch]&amp;quot; -exec grep -Hr &#039;yadif&#039; \{\} \;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then just note down anything that matches anywhere else except modules/video_filter/deinterlace/.&lt;br /&gt;
&lt;br /&gt;
{{Documentation}}&lt;/div&gt;</summary>
		<author><name>Technologicat</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=YUV&amp;diff=21328</id>
		<title>YUV</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=YUV&amp;diff=21328"/>
		<updated>2012-01-27T10:05:26Z</updated>

		<summary type="html">&lt;p&gt;Technologicat: /* J422 */ Let&amp;#039;s get the numbers correct, too...&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;YUV is a class of pixel formats used in Video application and in {{VLC}}.&lt;br /&gt;
&lt;br /&gt;
YUV is also colorspace and the way to represent pixels colors is based on Luminance and Chrominance.&lt;br /&gt;
&lt;br /&gt;
This pages explains the most useful ones in {{VLC}}.&lt;br /&gt;
&lt;br /&gt;
= Planar formats =&lt;br /&gt;
== YUV 4:2:0 (I420/J420/YV12)==&lt;br /&gt;
&lt;br /&gt;
=== I420 ===&lt;br /&gt;
In I420, you have one luma &amp;quot;luminance&amp;quot; plane &#039;&#039;&#039;&#039;&#039;Y&#039;&#039;&#039;&#039;&#039; and 2 chroma planes &#039;&#039;&#039;&#039;&#039;U&#039;&#039;&#039;&#039;&#039;, &#039;&#039;&#039;&#039;&#039;V&#039;&#039;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
In I420, chroma planes (blue and red projections) are subsampled in both the horizontal and vertical dimensions by a factor of 2.&lt;br /&gt;
&lt;br /&gt;
For a 2x2 group of pixels, you have 4 Y samples and 1 U and 1 V sample.&lt;br /&gt;
&lt;br /&gt;
=== J420 ===&lt;br /&gt;
J420 is exactly like [[I420]], but with a full range (&amp;quot;digital&amp;quot;, 0-255) luma (&#039;&#039;&#039;&#039;&#039;Y&#039;&#039;&#039;&#039;&#039;) component instead of limited range (&amp;quot;analog&amp;quot;, 16-240). The chroma planes are exactly the same as in [[I420]].&lt;br /&gt;
&lt;br /&gt;
=== YV12 ===&lt;br /&gt;
&lt;br /&gt;
YV12 is exactly like [[I420]], but with &#039;&#039;&#039;U&#039;&#039;&#039; and &#039;&#039;&#039;V&#039;&#039;&#039; order reversed.&lt;br /&gt;
&lt;br /&gt;
== NV12/NV21 ==&lt;br /&gt;
&lt;br /&gt;
=== NV12 ===&lt;br /&gt;
Related to [[I420]], in NV12, you have one luma &amp;quot;luminance&amp;quot; planes &#039;&#039;&#039;&#039;&#039;Y&#039;&#039;&#039;&#039;&#039; and one plane with &#039;&#039;&#039;&#039;&#039;U&#039;&#039;&#039;&#039;&#039; and &#039;&#039;&#039;&#039;&#039;V&#039;&#039;&#039;&#039;&#039; data interleaved. NV12 is considered as &#039;&#039;semiplanar&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
In NV12, chroma planes (blue and red) are subsampled in both the horizontal and vertical dimensions by a factor of 2.&lt;br /&gt;
&lt;br /&gt;
For a 2x2 group of pixels, you have 4 Y samples and 1 U and 1 V sample.&lt;br /&gt;
&lt;br /&gt;
=== NV21 ===&lt;br /&gt;
&lt;br /&gt;
NV21 is like [[NV12]], but with &#039;&#039;&#039;U&#039;&#039;&#039; and &#039;&#039;&#039;V&#039;&#039;&#039; order reversed: it starts with &#039;&#039;&#039;V&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== YUV 4:2:2 (I422/J422) ==&lt;br /&gt;
=== I422 ===&lt;br /&gt;
In I422, like in [[I420]], you have one luma  plane &#039;&#039;&#039;&#039;&#039;Y&#039;&#039;&#039;&#039;&#039; and 2 chroma planes &#039;&#039;&#039;U&#039;&#039;&#039;, &#039;&#039;&#039;V&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
However, in I422, chroma planes (blue and red projections) are subsampled just in the horizontal dimension by a factor of 2.&lt;br /&gt;
There is the same amount of lines than in the luma.&lt;br /&gt;
&lt;br /&gt;
For a 2x2 group of pixels, you have 4 Y samples and 2 U and 2 V sample.&lt;br /&gt;
&lt;br /&gt;
=== J422 ===&lt;br /&gt;
J422 is exactly like [[I422]], but with a full range (&amp;quot;digital&amp;quot;, 0-255) luma (&#039;&#039;&#039;&#039;&#039;Y&#039;&#039;&#039;&#039;&#039;) component instead of limited range (&amp;quot;analog&amp;quot;, 16-240). The chroma planes are exactly the same as in [[I422]].&lt;br /&gt;
&lt;br /&gt;
= Packed formats =&lt;br /&gt;
In packed formats, you usually have only one plane, with all the luma and chroma data interleaved.&lt;br /&gt;
&lt;br /&gt;
== UYVY ==&lt;br /&gt;
Know as &#039;&#039;UYVY&#039;&#039;, &#039;&#039;Y422&#039;&#039;, &#039;&#039;UYNV&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In UYVY, the chroma samples are sub-sampled by a factor of 2.&lt;br /&gt;
&lt;br /&gt;
In UYVY, the succession for 2 pixels, starts by &#039;&#039;&#039;U&#039;&#039;&#039; then one luma, then &#039;&#039;&#039;V&#039;&#039;&#039; again and then another luma.&lt;br /&gt;
&lt;br /&gt;
== YUY2 ==&lt;br /&gt;
Know as &#039;&#039;YUY2&#039;&#039;, &#039;&#039;YUYV&#039;&#039;, &#039;&#039;V422&#039;&#039;, &#039;&#039;YUNV&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In YUY2, the chroma samples are sub-sampled by a factor of 2.&lt;br /&gt;
&lt;br /&gt;
In YUY2, the succession for 2 pixels, starts by one luma, then &#039;&#039;&#039;U&#039;&#039;&#039;, then another luma and then &#039;&#039;&#039;V&#039;&#039;&#039; again.&lt;br /&gt;
&lt;br /&gt;
== YVYU ==&lt;br /&gt;
YVYU is just like [[YUY2]], but with &#039;&#039;&#039;U&#039;&#039;&#039; and &#039;&#039;&#039;V&#039;&#039;&#039; order reversed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{documentation}}&lt;/div&gt;</summary>
		<author><name>Technologicat</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=YUV&amp;diff=21327</id>
		<title>YUV</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=YUV&amp;diff=21327"/>
		<updated>2012-01-27T10:04:43Z</updated>

		<summary type="html">&lt;p&gt;Technologicat: /* J420 */ Let&amp;#039;s get the numbers correct, too...&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;YUV is a class of pixel formats used in Video application and in {{VLC}}.&lt;br /&gt;
&lt;br /&gt;
YUV is also colorspace and the way to represent pixels colors is based on Luminance and Chrominance.&lt;br /&gt;
&lt;br /&gt;
This pages explains the most useful ones in {{VLC}}.&lt;br /&gt;
&lt;br /&gt;
= Planar formats =&lt;br /&gt;
== YUV 4:2:0 (I420/J420/YV12)==&lt;br /&gt;
&lt;br /&gt;
=== I420 ===&lt;br /&gt;
In I420, you have one luma &amp;quot;luminance&amp;quot; plane &#039;&#039;&#039;&#039;&#039;Y&#039;&#039;&#039;&#039;&#039; and 2 chroma planes &#039;&#039;&#039;&#039;&#039;U&#039;&#039;&#039;&#039;&#039;, &#039;&#039;&#039;&#039;&#039;V&#039;&#039;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
In I420, chroma planes (blue and red projections) are subsampled in both the horizontal and vertical dimensions by a factor of 2.&lt;br /&gt;
&lt;br /&gt;
For a 2x2 group of pixels, you have 4 Y samples and 1 U and 1 V sample.&lt;br /&gt;
&lt;br /&gt;
=== J420 ===&lt;br /&gt;
J420 is exactly like [[I420]], but with a full range (&amp;quot;digital&amp;quot;, 0-255) luma (&#039;&#039;&#039;&#039;&#039;Y&#039;&#039;&#039;&#039;&#039;) component instead of limited range (&amp;quot;analog&amp;quot;, 16-240). The chroma planes are exactly the same as in [[I420]].&lt;br /&gt;
&lt;br /&gt;
=== YV12 ===&lt;br /&gt;
&lt;br /&gt;
YV12 is exactly like [[I420]], but with &#039;&#039;&#039;U&#039;&#039;&#039; and &#039;&#039;&#039;V&#039;&#039;&#039; order reversed.&lt;br /&gt;
&lt;br /&gt;
== NV12/NV21 ==&lt;br /&gt;
&lt;br /&gt;
=== NV12 ===&lt;br /&gt;
Related to [[I420]], in NV12, you have one luma &amp;quot;luminance&amp;quot; planes &#039;&#039;&#039;&#039;&#039;Y&#039;&#039;&#039;&#039;&#039; and one plane with &#039;&#039;&#039;&#039;&#039;U&#039;&#039;&#039;&#039;&#039; and &#039;&#039;&#039;&#039;&#039;V&#039;&#039;&#039;&#039;&#039; data interleaved. NV12 is considered as &#039;&#039;semiplanar&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
In NV12, chroma planes (blue and red) are subsampled in both the horizontal and vertical dimensions by a factor of 2.&lt;br /&gt;
&lt;br /&gt;
For a 2x2 group of pixels, you have 4 Y samples and 1 U and 1 V sample.&lt;br /&gt;
&lt;br /&gt;
=== NV21 ===&lt;br /&gt;
&lt;br /&gt;
NV21 is like [[NV12]], but with &#039;&#039;&#039;U&#039;&#039;&#039; and &#039;&#039;&#039;V&#039;&#039;&#039; order reversed: it starts with &#039;&#039;&#039;V&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== YUV 4:2:2 (I422/J422) ==&lt;br /&gt;
=== I422 ===&lt;br /&gt;
In I422, like in [[I420]], you have one luma  plane &#039;&#039;&#039;&#039;&#039;Y&#039;&#039;&#039;&#039;&#039; and 2 chroma planes &#039;&#039;&#039;U&#039;&#039;&#039;, &#039;&#039;&#039;V&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
However, in I422, chroma planes (blue and red projections) are subsampled just in the horizontal dimension by a factor of 2.&lt;br /&gt;
There is the same amount of lines than in the luma.&lt;br /&gt;
&lt;br /&gt;
For a 2x2 group of pixels, you have 4 Y samples and 2 U and 2 V sample.&lt;br /&gt;
&lt;br /&gt;
=== J422 ===&lt;br /&gt;
J422 is exactly like [[I422]], but with a full range (&amp;quot;digital&amp;quot;, 0-255) luma (&#039;&#039;&#039;&#039;&#039;Y&#039;&#039;&#039;&#039;&#039;) component instead of limited range (&amp;quot;analog&amp;quot;, 16-235). The chroma planes are exactly the same as in [[I422]].&lt;br /&gt;
&lt;br /&gt;
= Packed formats =&lt;br /&gt;
In packed formats, you usually have only one plane, with all the luma and chroma data interleaved.&lt;br /&gt;
&lt;br /&gt;
== UYVY ==&lt;br /&gt;
Know as &#039;&#039;UYVY&#039;&#039;, &#039;&#039;Y422&#039;&#039;, &#039;&#039;UYNV&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In UYVY, the chroma samples are sub-sampled by a factor of 2.&lt;br /&gt;
&lt;br /&gt;
In UYVY, the succession for 2 pixels, starts by &#039;&#039;&#039;U&#039;&#039;&#039; then one luma, then &#039;&#039;&#039;V&#039;&#039;&#039; again and then another luma.&lt;br /&gt;
&lt;br /&gt;
== YUY2 ==&lt;br /&gt;
Know as &#039;&#039;YUY2&#039;&#039;, &#039;&#039;YUYV&#039;&#039;, &#039;&#039;V422&#039;&#039;, &#039;&#039;YUNV&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In YUY2, the chroma samples are sub-sampled by a factor of 2.&lt;br /&gt;
&lt;br /&gt;
In YUY2, the succession for 2 pixels, starts by one luma, then &#039;&#039;&#039;U&#039;&#039;&#039;, then another luma and then &#039;&#039;&#039;V&#039;&#039;&#039; again.&lt;br /&gt;
&lt;br /&gt;
== YVYU ==&lt;br /&gt;
YVYU is just like [[YUY2]], but with &#039;&#039;&#039;U&#039;&#039;&#039; and &#039;&#039;&#039;V&#039;&#039;&#039; order reversed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{documentation}}&lt;/div&gt;</summary>
		<author><name>Technologicat</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=J420&amp;diff=21326</id>
		<title>J420</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=J420&amp;diff=21326"/>
		<updated>2012-01-27T09:58:39Z</updated>

		<summary type="html">&lt;p&gt;Technologicat: Set up redirect to YUV/J420&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#redirect[[YUV#J420]]&lt;/div&gt;</summary>
		<author><name>Technologicat</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=J422&amp;diff=21325</id>
		<title>J422</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=J422&amp;diff=21325"/>
		<updated>2012-01-27T09:57:51Z</updated>

		<summary type="html">&lt;p&gt;Technologicat: Set up redirect to YUV/J422&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#redirect[[YUV#J422]]&lt;/div&gt;</summary>
		<author><name>Technologicat</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=YUV&amp;diff=21324</id>
		<title>YUV</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=YUV&amp;diff=21324"/>
		<updated>2012-01-27T09:54:22Z</updated>

		<summary type="html">&lt;p&gt;Technologicat: /* YUY2 */ Typo fix: thenU -&amp;gt; then U&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;YUV is a class of pixel formats used in Video application and in {{VLC}}.&lt;br /&gt;
&lt;br /&gt;
YUV is also colorspace and the way to represent pixels colors is based on Luminance and Chrominance.&lt;br /&gt;
&lt;br /&gt;
This pages explains the most useful ones in {{VLC}}.&lt;br /&gt;
&lt;br /&gt;
= Planar formats =&lt;br /&gt;
== YUV 4:2:0 (I420/J420/YV12)==&lt;br /&gt;
&lt;br /&gt;
=== I420 ===&lt;br /&gt;
In I420, you have one luma &amp;quot;luminance&amp;quot; plane &#039;&#039;&#039;&#039;&#039;Y&#039;&#039;&#039;&#039;&#039; and 2 chroma planes &#039;&#039;&#039;&#039;&#039;U&#039;&#039;&#039;&#039;&#039;, &#039;&#039;&#039;&#039;&#039;V&#039;&#039;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
In I420, chroma planes (blue and red projections) are subsampled in both the horizontal and vertical dimensions by a factor of 2.&lt;br /&gt;
&lt;br /&gt;
For a 2x2 group of pixels, you have 4 Y samples and 1 U and 1 V sample.&lt;br /&gt;
&lt;br /&gt;
=== J420 ===&lt;br /&gt;
J420 is exactly like [[I420]], but with a full range (&amp;quot;digital&amp;quot;, 0-255) luma (&#039;&#039;&#039;&#039;&#039;Y&#039;&#039;&#039;&#039;&#039;) component instead of limited range (&amp;quot;analog&amp;quot;, 16-235). The chroma planes are exactly the same as in [[I420]].&lt;br /&gt;
&lt;br /&gt;
=== YV12 ===&lt;br /&gt;
&lt;br /&gt;
YV12 is exactly like [[I420]], but with &#039;&#039;&#039;U&#039;&#039;&#039; and &#039;&#039;&#039;V&#039;&#039;&#039; order reversed.&lt;br /&gt;
&lt;br /&gt;
== NV12/NV21 ==&lt;br /&gt;
&lt;br /&gt;
=== NV12 ===&lt;br /&gt;
Related to [[I420]], in NV12, you have one luma &amp;quot;luminance&amp;quot; planes &#039;&#039;&#039;&#039;&#039;Y&#039;&#039;&#039;&#039;&#039; and one plane with &#039;&#039;&#039;&#039;&#039;U&#039;&#039;&#039;&#039;&#039; and &#039;&#039;&#039;&#039;&#039;V&#039;&#039;&#039;&#039;&#039; data interleaved. NV12 is considered as &#039;&#039;semiplanar&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
In NV12, chroma planes (blue and red) are subsampled in both the horizontal and vertical dimensions by a factor of 2.&lt;br /&gt;
&lt;br /&gt;
For a 2x2 group of pixels, you have 4 Y samples and 1 U and 1 V sample.&lt;br /&gt;
&lt;br /&gt;
=== NV21 ===&lt;br /&gt;
&lt;br /&gt;
NV21 is like [[NV12]], but with &#039;&#039;&#039;U&#039;&#039;&#039; and &#039;&#039;&#039;V&#039;&#039;&#039; order reversed: it starts with &#039;&#039;&#039;V&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== YUV 4:2:2 (I422/J422) ==&lt;br /&gt;
=== I422 ===&lt;br /&gt;
In I422, like in [[I420]], you have one luma  plane &#039;&#039;&#039;&#039;&#039;Y&#039;&#039;&#039;&#039;&#039; and 2 chroma planes &#039;&#039;&#039;U&#039;&#039;&#039;, &#039;&#039;&#039;V&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
However, in I422, chroma planes (blue and red projections) are subsampled just in the horizontal dimension by a factor of 2.&lt;br /&gt;
There is the same amount of lines than in the luma.&lt;br /&gt;
&lt;br /&gt;
For a 2x2 group of pixels, you have 4 Y samples and 2 U and 2 V sample.&lt;br /&gt;
&lt;br /&gt;
=== J422 ===&lt;br /&gt;
J422 is exactly like [[I422]], but with a full range (&amp;quot;digital&amp;quot;, 0-255) luma (&#039;&#039;&#039;&#039;&#039;Y&#039;&#039;&#039;&#039;&#039;) component instead of limited range (&amp;quot;analog&amp;quot;, 16-235). The chroma planes are exactly the same as in [[I422]].&lt;br /&gt;
&lt;br /&gt;
= Packed formats =&lt;br /&gt;
In packed formats, you usually have only one plane, with all the luma and chroma data interleaved.&lt;br /&gt;
&lt;br /&gt;
== UYVY ==&lt;br /&gt;
Know as &#039;&#039;UYVY&#039;&#039;, &#039;&#039;Y422&#039;&#039;, &#039;&#039;UYNV&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In UYVY, the chroma samples are sub-sampled by a factor of 2.&lt;br /&gt;
&lt;br /&gt;
In UYVY, the succession for 2 pixels, starts by &#039;&#039;&#039;U&#039;&#039;&#039; then one luma, then &#039;&#039;&#039;V&#039;&#039;&#039; again and then another luma.&lt;br /&gt;
&lt;br /&gt;
== YUY2 ==&lt;br /&gt;
Know as &#039;&#039;YUY2&#039;&#039;, &#039;&#039;YUYV&#039;&#039;, &#039;&#039;V422&#039;&#039;, &#039;&#039;YUNV&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In YUY2, the chroma samples are sub-sampled by a factor of 2.&lt;br /&gt;
&lt;br /&gt;
In YUY2, the succession for 2 pixels, starts by one luma, then &#039;&#039;&#039;U&#039;&#039;&#039;, then another luma and then &#039;&#039;&#039;V&#039;&#039;&#039; again.&lt;br /&gt;
&lt;br /&gt;
== YVYU ==&lt;br /&gt;
YVYU is just like [[YUY2]], but with &#039;&#039;&#039;U&#039;&#039;&#039; and &#039;&#039;&#039;V&#039;&#039;&#039; order reversed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{documentation}}&lt;/div&gt;</summary>
		<author><name>Technologicat</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=YUV&amp;diff=21323</id>
		<title>YUV</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=YUV&amp;diff=21323"/>
		<updated>2012-01-27T09:53:05Z</updated>

		<summary type="html">&lt;p&gt;Technologicat: /* YUV 4:2:2 */ Added description of J422&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;YUV is a class of pixel formats used in Video application and in {{VLC}}.&lt;br /&gt;
&lt;br /&gt;
YUV is also colorspace and the way to represent pixels colors is based on Luminance and Chrominance.&lt;br /&gt;
&lt;br /&gt;
This pages explains the most useful ones in {{VLC}}.&lt;br /&gt;
&lt;br /&gt;
= Planar formats =&lt;br /&gt;
== YUV 4:2:0 (I420/J420/YV12)==&lt;br /&gt;
&lt;br /&gt;
=== I420 ===&lt;br /&gt;
In I420, you have one luma &amp;quot;luminance&amp;quot; plane &#039;&#039;&#039;&#039;&#039;Y&#039;&#039;&#039;&#039;&#039; and 2 chroma planes &#039;&#039;&#039;&#039;&#039;U&#039;&#039;&#039;&#039;&#039;, &#039;&#039;&#039;&#039;&#039;V&#039;&#039;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
In I420, chroma planes (blue and red projections) are subsampled in both the horizontal and vertical dimensions by a factor of 2.&lt;br /&gt;
&lt;br /&gt;
For a 2x2 group of pixels, you have 4 Y samples and 1 U and 1 V sample.&lt;br /&gt;
&lt;br /&gt;
=== J420 ===&lt;br /&gt;
J420 is exactly like [[I420]], but with a full range (&amp;quot;digital&amp;quot;, 0-255) luma (&#039;&#039;&#039;&#039;&#039;Y&#039;&#039;&#039;&#039;&#039;) component instead of limited range (&amp;quot;analog&amp;quot;, 16-235). The chroma planes are exactly the same as in [[I420]].&lt;br /&gt;
&lt;br /&gt;
=== YV12 ===&lt;br /&gt;
&lt;br /&gt;
YV12 is exactly like [[I420]], but with &#039;&#039;&#039;U&#039;&#039;&#039; and &#039;&#039;&#039;V&#039;&#039;&#039; order reversed.&lt;br /&gt;
&lt;br /&gt;
== NV12/NV21 ==&lt;br /&gt;
&lt;br /&gt;
=== NV12 ===&lt;br /&gt;
Related to [[I420]], in NV12, you have one luma &amp;quot;luminance&amp;quot; planes &#039;&#039;&#039;&#039;&#039;Y&#039;&#039;&#039;&#039;&#039; and one plane with &#039;&#039;&#039;&#039;&#039;U&#039;&#039;&#039;&#039;&#039; and &#039;&#039;&#039;&#039;&#039;V&#039;&#039;&#039;&#039;&#039; data interleaved. NV12 is considered as &#039;&#039;semiplanar&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
In NV12, chroma planes (blue and red) are subsampled in both the horizontal and vertical dimensions by a factor of 2.&lt;br /&gt;
&lt;br /&gt;
For a 2x2 group of pixels, you have 4 Y samples and 1 U and 1 V sample.&lt;br /&gt;
&lt;br /&gt;
=== NV21 ===&lt;br /&gt;
&lt;br /&gt;
NV21 is like [[NV12]], but with &#039;&#039;&#039;U&#039;&#039;&#039; and &#039;&#039;&#039;V&#039;&#039;&#039; order reversed: it starts with &#039;&#039;&#039;V&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== YUV 4:2:2 (I422/J422) ==&lt;br /&gt;
=== I422 ===&lt;br /&gt;
In I422, like in [[I420]], you have one luma  plane &#039;&#039;&#039;&#039;&#039;Y&#039;&#039;&#039;&#039;&#039; and 2 chroma planes &#039;&#039;&#039;U&#039;&#039;&#039;, &#039;&#039;&#039;V&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
However, in I422, chroma planes (blue and red projections) are subsampled just in the horizontal dimension by a factor of 2.&lt;br /&gt;
There is the same amount of lines than in the luma.&lt;br /&gt;
&lt;br /&gt;
For a 2x2 group of pixels, you have 4 Y samples and 2 U and 2 V sample.&lt;br /&gt;
&lt;br /&gt;
=== J422 ===&lt;br /&gt;
J422 is exactly like [[I422]], but with a full range (&amp;quot;digital&amp;quot;, 0-255) luma (&#039;&#039;&#039;&#039;&#039;Y&#039;&#039;&#039;&#039;&#039;) component instead of limited range (&amp;quot;analog&amp;quot;, 16-235). The chroma planes are exactly the same as in [[I422]].&lt;br /&gt;
&lt;br /&gt;
= Packed formats =&lt;br /&gt;
In packed formats, you usually have only one plane, with all the luma and chroma data interleaved.&lt;br /&gt;
&lt;br /&gt;
== UYVY ==&lt;br /&gt;
Know as &#039;&#039;UYVY&#039;&#039;, &#039;&#039;Y422&#039;&#039;, &#039;&#039;UYNV&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In UYVY, the chroma samples are sub-sampled by a factor of 2.&lt;br /&gt;
&lt;br /&gt;
In UYVY, the succession for 2 pixels, starts by &#039;&#039;&#039;U&#039;&#039;&#039; then one luma, then &#039;&#039;&#039;V&#039;&#039;&#039; again and then another luma.&lt;br /&gt;
&lt;br /&gt;
== YUY2 ==&lt;br /&gt;
Know as &#039;&#039;YUY2&#039;&#039;, &#039;&#039;YUYV&#039;&#039;, &#039;&#039;V422&#039;&#039;, &#039;&#039;YUNV&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In YUY2, the chroma samples are sub-sampled by a factor of 2.&lt;br /&gt;
&lt;br /&gt;
In YUY2, the succession for 2 pixels, starts by one luma, then&#039;&#039;&#039;U&#039;&#039;&#039;, then another luma and then &#039;&#039;&#039;V&#039;&#039;&#039; again.&lt;br /&gt;
&lt;br /&gt;
== YVYU ==&lt;br /&gt;
YVYU is just like [[YUY2]], but with &#039;&#039;&#039;U&#039;&#039;&#039; and &#039;&#039;&#039;V&#039;&#039;&#039; order reversed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{documentation}}&lt;/div&gt;</summary>
		<author><name>Technologicat</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=YUV&amp;diff=21322</id>
		<title>YUV</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=YUV&amp;diff=21322"/>
		<updated>2012-01-27T09:51:40Z</updated>

		<summary type="html">&lt;p&gt;Technologicat: /* YUV 4:2:0 (I420/YV12) */  Added description of J420&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;YUV is a class of pixel formats used in Video application and in {{VLC}}.&lt;br /&gt;
&lt;br /&gt;
YUV is also colorspace and the way to represent pixels colors is based on Luminance and Chrominance.&lt;br /&gt;
&lt;br /&gt;
This pages explains the most useful ones in {{VLC}}.&lt;br /&gt;
&lt;br /&gt;
= Planar formats =&lt;br /&gt;
== YUV 4:2:0 (I420/J420/YV12)==&lt;br /&gt;
&lt;br /&gt;
=== I420 ===&lt;br /&gt;
In I420, you have one luma &amp;quot;luminance&amp;quot; plane &#039;&#039;&#039;&#039;&#039;Y&#039;&#039;&#039;&#039;&#039; and 2 chroma planes &#039;&#039;&#039;&#039;&#039;U&#039;&#039;&#039;&#039;&#039;, &#039;&#039;&#039;&#039;&#039;V&#039;&#039;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
In I420, chroma planes (blue and red projections) are subsampled in both the horizontal and vertical dimensions by a factor of 2.&lt;br /&gt;
&lt;br /&gt;
For a 2x2 group of pixels, you have 4 Y samples and 1 U and 1 V sample.&lt;br /&gt;
&lt;br /&gt;
=== J420 ===&lt;br /&gt;
J420 is exactly like [[I420]], but with a full range (&amp;quot;digital&amp;quot;, 0-255) luma (&#039;&#039;&#039;&#039;&#039;Y&#039;&#039;&#039;&#039;&#039;) component instead of limited range (&amp;quot;analog&amp;quot;, 16-235). The chroma planes are exactly the same as in [[I420]].&lt;br /&gt;
&lt;br /&gt;
=== YV12 ===&lt;br /&gt;
&lt;br /&gt;
YV12 is exactly like [[I420]], but with &#039;&#039;&#039;U&#039;&#039;&#039; and &#039;&#039;&#039;V&#039;&#039;&#039; order reversed.&lt;br /&gt;
&lt;br /&gt;
== NV12/NV21 ==&lt;br /&gt;
&lt;br /&gt;
=== NV12 ===&lt;br /&gt;
Related to [[I420]], in NV12, you have one luma &amp;quot;luminance&amp;quot; planes &#039;&#039;&#039;&#039;&#039;Y&#039;&#039;&#039;&#039;&#039; and one plane with &#039;&#039;&#039;&#039;&#039;U&#039;&#039;&#039;&#039;&#039; and &#039;&#039;&#039;&#039;&#039;V&#039;&#039;&#039;&#039;&#039; data interleaved. NV12 is considered as &#039;&#039;semiplanar&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
In NV12, chroma planes (blue and red) are subsampled in both the horizontal and vertical dimensions by a factor of 2.&lt;br /&gt;
&lt;br /&gt;
For a 2x2 group of pixels, you have 4 Y samples and 1 U and 1 V sample.&lt;br /&gt;
&lt;br /&gt;
=== NV21 ===&lt;br /&gt;
&lt;br /&gt;
NV21 is like [[NV12]], but with &#039;&#039;&#039;U&#039;&#039;&#039; and &#039;&#039;&#039;V&#039;&#039;&#039; order reversed: it starts with &#039;&#039;&#039;V&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== YUV 4:2:2 ==&lt;br /&gt;
=== I422 ===&lt;br /&gt;
In I422, like in [[I420]], you have one luma  plane &#039;&#039;&#039;&#039;&#039;Y&#039;&#039;&#039;&#039;&#039; and 2 chroma planes &#039;&#039;&#039;U&#039;&#039;&#039;, &#039;&#039;&#039;V&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
However, in I422, chroma planes (blue and red projections) are subsampled just in the horizontal dimension by a factor of 2.&lt;br /&gt;
There is the same amount of lines than in the luma.&lt;br /&gt;
&lt;br /&gt;
For a 2x2 group of pixels, you have 4 Y samples and 2 U and 2 V sample.&lt;br /&gt;
&lt;br /&gt;
= Packed formats =&lt;br /&gt;
In packed formats, you usually have only one plane, with all the luma and chroma data interleaved.&lt;br /&gt;
&lt;br /&gt;
== UYVY ==&lt;br /&gt;
Know as &#039;&#039;UYVY&#039;&#039;, &#039;&#039;Y422&#039;&#039;, &#039;&#039;UYNV&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In UYVY, the chroma samples are sub-sampled by a factor of 2.&lt;br /&gt;
&lt;br /&gt;
In UYVY, the succession for 2 pixels, starts by &#039;&#039;&#039;U&#039;&#039;&#039; then one luma, then &#039;&#039;&#039;V&#039;&#039;&#039; again and then another luma.&lt;br /&gt;
&lt;br /&gt;
== YUY2 ==&lt;br /&gt;
Know as &#039;&#039;YUY2&#039;&#039;, &#039;&#039;YUYV&#039;&#039;, &#039;&#039;V422&#039;&#039;, &#039;&#039;YUNV&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In YUY2, the chroma samples are sub-sampled by a factor of 2.&lt;br /&gt;
&lt;br /&gt;
In YUY2, the succession for 2 pixels, starts by one luma, then&#039;&#039;&#039;U&#039;&#039;&#039;, then another luma and then &#039;&#039;&#039;V&#039;&#039;&#039; again.&lt;br /&gt;
&lt;br /&gt;
== YVYU ==&lt;br /&gt;
YVYU is just like [[YUY2]], but with &#039;&#039;&#039;U&#039;&#039;&#039; and &#039;&#039;&#039;V&#039;&#039;&#039; order reversed.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{documentation}}&lt;/div&gt;</summary>
		<author><name>Technologicat</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=Deinterlacing&amp;diff=21321</id>
		<title>Deinterlacing</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=Deinterlacing&amp;diff=21321"/>
		<updated>2012-01-27T09:40:13Z</updated>

		<summary type="html">&lt;p&gt;Technologicat: /* VLC settings */ Some editing - I think this is what was meant?&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:VLC_-_Deinterlace_action_options.png|400px|thumb|right|deinterlace switch menu]]&lt;br /&gt;
&#039;&#039;&#039;Deinterlacing&#039;&#039;&#039; is the process of converting source material that contains alternating half-pictures to a computer screen that displays a full picture at a time.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Description ==&lt;br /&gt;
Traditional TVs do not display one picture-frame at a time.  Instead, they display alternately all the odd lines and all the even lines of the picture.  That way, they can get a fast display rate of 50 or 60 half-pictures per second, without the bandwidth requirements that full pictures have.&lt;br /&gt;
&lt;br /&gt;
Computers however, do display full pictures, typically at a rate of at least 60 pictures per second.  So to get optimum quality when displaying TV-material (such as DVDs) on a computer, the player can convert the alternating half-pictures to full pictures.  That is called &#039;&#039;deinterlacing&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Modern HDTVs operate much like computers in that they display full pictures. Much like computer-based video players, they have deinterlacing built in so that they can display traditional TV material.&lt;br /&gt;
&lt;br /&gt;
A very good description of the problem and the various ways of deinterlacing can be found at [http://www.100fps.com/ 100fps.com].&lt;br /&gt;
&lt;br /&gt;
== VLC settings ==&lt;br /&gt;
{{VLC}} has deinterlacing off by default. &lt;br /&gt;
&lt;br /&gt;
You can enable it for the currently playing video by using the main menus, the right-click menus or by using [[hotkey] (by default: &#039;&#039;&#039;D&#039;&#039;&#039;). It switches deinterlacing on and off (using the mode selected in the Preferences).&lt;br /&gt;
&lt;br /&gt;
To change the settings, go to the Video section in the Simple Preferences. You can choose from On, Automatic or Off. This setting controls whether VLC enables deinterlacing when you open a video. You can also choose the mode (algorithm). See below for available modes and mode recommendations.&lt;br /&gt;
&lt;br /&gt;
The recommended choice is &#039;&#039;Automatic&#039;&#039;. VLC will then check the stream flags (technical term for information embedded in the video) and automatically set deinterlacing on or off, depending on if the current video is marked as interlaced. If the setting is &#039;&#039;On&#039;&#039;, VLC will apply deinterlacing even if the original is not interlaced (which is a really bad idea). The setting &#039;&#039;Off&#039;&#039;, respectively, always keeps deinterlacing off.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;For advanced users&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In All Preferences, the settings for deinterlacing can be found in Preferences &amp;gt; Video &amp;gt; Filters &amp;gt; Deinterlace. The available settings are the mode (algorithm), and in v1.2.0+ also some algorithm-specific settings.&lt;br /&gt;
&lt;br /&gt;
Note that if you enable deinterlacing from the menu, the setting will only take effect for the currently playing video. When the video ends, both the on/off/automatic and the mode settings will return to the values set in the preferences. If you want to always enable deinterlacing on every video, type &amp;quot;Deinterlace&amp;quot; in the Video Filter preferences.&lt;br /&gt;
&lt;br /&gt;
The [[Hotkeys|keyboard shortcut]] to switch deinterlacing on and off can be configured in the [[Hotkeys]] section of the Simple Preferences. Its name is &#039;&#039;Cycle deinterlace modes&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
If you use VLC from the command line, you can also set the deinterlace options in your command. To get a list and short description of the available options, run &amp;lt;pre&amp;gt;vlc -p deinterlace --advanced&amp;lt;/pre&amp;gt; Note that the deinterlace command-line options are prefixed by &amp;quot;sout&amp;quot; for historical reasons only; they are intended for normal playback use. For more information on using VLC from the command line, see [[VLC_command-line_help|VLC command-line help]].&lt;br /&gt;
&lt;br /&gt;
== Interlaced or telecined? ==&lt;br /&gt;
In addition to true interlaced signals, there exists also a process called telecine which produces interlacing. It is a type of artificial interlacing that may be added to sources that were originally progressive. Telecine produces a characteristic look, with a repeating sequence of 3 progressive frames followed by 2 artificially interlaced frames.&lt;br /&gt;
&lt;br /&gt;
Why would anyone want to do that? The answer lies in different framerates, and in transfer of film sources to television and video. Film is commonly shot at 24 pictures per second, while NTSC television and video equipment operates at 60 half-pictures per second. Telecine inserts extra half-pictures so that films can be stored in the NTSC format (for example on DVDs in Japan and USA).&lt;br /&gt;
&lt;br /&gt;
For more on telecine, see for example the following links:&lt;br /&gt;
*[http://en.wikipedia.org/wiki/Telecine Telecine (in Wikipedia)]&lt;br /&gt;
*[http://arbor.ee.ntu.edu.tw/~jackeikuo/dvd2avi/ivtc/ Inverse Telecine]&lt;br /&gt;
*[http://neuron2.net/LVG/telecining1.html NTSC Telecine - Luke&#039;s Video Guide]&lt;br /&gt;
*[http://users.softlab.ece.ntua.gr/~ttsiod/ivtc.html NTSC, telecine, and how to cope (using telecide and decimate)]&lt;br /&gt;
&lt;br /&gt;
== Which type of interlacing do I have? ==&lt;br /&gt;
This depends on the format (PAL, NTSC) and the content of the source. PAL is used in Europe and Australia, NTSC in USA and Japan. This also applies to the DVDs produced in those regions.&lt;br /&gt;
&lt;br /&gt;
Live-action movies in the PAL format typically are not interlaced at all. This is because it is easier to transfer film to PAL than to NTSC.&lt;br /&gt;
&lt;br /&gt;
Home movies shot on a camcorder are typically true interlaced.&lt;br /&gt;
&lt;br /&gt;
Telecine is very common in Asia and especially in Japan. Anything originating in Asia is likely to be telecined. For example, with very few exceptions, all anime in the NTSC format is telecined. This includes the corresponding North American releases.&lt;br /&gt;
&lt;br /&gt;
Source material that was converted from a different format is a special case. Producing a correct transfer for pure video material from NTSC to PAL or vice versa is very difficult due to the differences in framerate and number of lines. Whether a deinterlacer is needed depends on the details of the transfer. In the particular case of anime, a PAL conversion usually spells disaster for deinterlacing; see [http://www.animemusicvideos.org/guides/avtech/videogetb2a.html].&lt;br /&gt;
&lt;br /&gt;
== Algorithm types ==&lt;br /&gt;
&lt;br /&gt;
{{Module|name=deinterlace|type=Video Filter|description=Removes interlacing from display}}&lt;br /&gt;
&lt;br /&gt;
In {{VLC}}, there are several deinterlacing algorithms to choose from. This section presents a general classification. Skip ahead for an individual description of each mode.&lt;br /&gt;
&lt;br /&gt;
Algorithms available from a specific VLC version onward are marked with Name(vx.y.z+).&lt;br /&gt;
&lt;br /&gt;
=== Doublers ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;VLC modes&#039;&#039;&#039;: Bob, Linear, Yadif (2x) (v1.1.0+), Phosphor(v1.2.0+)&lt;br /&gt;
&lt;br /&gt;
These algorithms display the video at the original half-picture rate, which is typically 50 (PAL) or 60 (NTSC) half-pictures per second. This is double the full picture rate, hence the name. This approach to deinterlacing is also known as field rendering.&lt;br /&gt;
&lt;br /&gt;
This group takes into account that the half-pictures of a true interlaced video were intended to be displayed at different times. This can make the motion look very smooth.&lt;br /&gt;
&lt;br /&gt;
Simple doublers (Bob and Linear) display only one half-picture at a time. Nevertheless, the quick alternating display produces a convincing illusion of full vertical resolution while playback is running.&lt;br /&gt;
&lt;br /&gt;
Some more advanced doublers (such as Yadif (2x)) are based on interpolators (see below), and attempt to generate full pictures to display. When interpolators are used in this way, which field is kept, alternates just like in the simple doublers.&lt;br /&gt;
&lt;br /&gt;
The last doubler (Phosphor) does not fit into either of these categories, but attempts to simulate a traditional CRT TV.&lt;br /&gt;
&lt;br /&gt;
All doublers can be used with both true interlaced and telecined video.&lt;br /&gt;
&lt;br /&gt;
=== Interpolators ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;VLC modes&#039;&#039;&#039;: X, Yadif(v1.1.0+), (Discard)&lt;br /&gt;
&lt;br /&gt;
These algorithms analyze the picture, detecting progressive and interlaced parts. Typically the progressive parts of the picture are passed through unchanged, although in some algorithms various kinds of filtering may be used.&lt;br /&gt;
&lt;br /&gt;
For the interlaced parts, one half-picture is kept, while the other is generated out of thin air with various mathematical methods, based on the information in one or both of the original half-pictures.&lt;br /&gt;
&lt;br /&gt;
The Discard algorithm is a degenerate case of this type, which does not analyze the picture. It simply keeps one half-picture and discards the other one.&lt;br /&gt;
&lt;br /&gt;
The output runs at the full-picture rate, which is typically 25 (PAL) or 30 (NTSC) pictures per second. The different intended display times for the half-pictures in a true interlaced video are ignored.&lt;br /&gt;
&lt;br /&gt;
Interpolators are designed for use with true interlaced video only. They will stutter if applied to telecined video.&lt;br /&gt;
&lt;br /&gt;
Some doublers exist, such as Yadif (2x), which are based on interpolators. These hybrid algorithms behave like doublers (see above). They may be able to improve the picture quality compared to simple doublers, at the cost of more CPU cycles (requiring a faster processor).&lt;br /&gt;
&lt;br /&gt;
=== Blenders ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;VLC modes&#039;&#039;&#039;: Mean, Blend&lt;br /&gt;
&lt;br /&gt;
These algorithms mix information from both half-pictures to produce a blended (mixed) full picture. This is simple and removes interlacing, but causes ghostlike trails for fast motion.&lt;br /&gt;
&lt;br /&gt;
The output runs at the full-picture rate, which is typically 25 (PAL) or 30 (NTSC) pictures per second. The different intended display times for the half-pictures in a true interlaced video are ignored.&lt;br /&gt;
&lt;br /&gt;
Blenders are designed for use with true interlaced video only, and will stutter with telecined video.&lt;br /&gt;
&lt;br /&gt;
=== Inverse telecine ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;VLC modes&#039;&#039;&#039;: IVTC(v1.2.0+)&lt;br /&gt;
&lt;br /&gt;
This group of algorithms is specifically designed for removing telecine from NTSC telecined video. Inverse telecine is also known as &#039;&#039;IVTC&#039;&#039;, &#039;&#039;film mode&#039;&#039; and &#039;&#039;3:2 reverse pulldown&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Inverse telecine algorithms try to extract the original progressive film frames and to display them at the original framerate (24 pictures per second). In the ideal case, this perfectly restores the progressive signal. There is no loss of information and no need to generate anything out of thin air.&lt;br /&gt;
&lt;br /&gt;
Due to practical reasons, these algorithms are always based on analyzing the picture. They are not and cannot be perfectly accurate, but in practice they work well for most telecined sources.&lt;br /&gt;
&lt;br /&gt;
== VLC deinterlace modes ==&lt;br /&gt;
[[File:VLC_-_Deinterlace_Mode.png|250px|thumb|right|The deinterlace options selection]]&lt;br /&gt;
VLC has the following deinterlace modes.  Refer to 100fps.com for illustrations.  VLC does not have anything like what 100fps.com calls Motion blur, Hybrid, and Motion compensation.&lt;br /&gt;
&lt;br /&gt;
=== Disabled ===&lt;br /&gt;
This is what 100fps.com calls &amp;quot;do nothing&amp;quot;. Other names: &amp;quot;weave&amp;quot; or &amp;quot;no deinterlacing&amp;quot;. Should be used for PsF ([http://en.wikipedia.org/wiki/Progressive_segmented_Frame]) content.&lt;br /&gt;
&lt;br /&gt;
=== Blend ===&lt;br /&gt;
Blender (full resolution). Each line of the picture is created as the average of a line from the odd and a line from the even half-pictures.  This ignores the fact that they are supposed to be displayed at different times.&lt;br /&gt;
&lt;br /&gt;
=== Bob ===&lt;br /&gt;
Doubler. Display each half-picture like a full picture, by simply displaying each line twice. Preserves temporal resolution of interlaced video.&lt;br /&gt;
&lt;br /&gt;
=== Discard ===&lt;br /&gt;
Only display one of the half-pictures, discard the other. Other name: &amp;quot;single field&amp;quot;. Both temporal and vertical spatial resolutions are halved. Can be used for slower computers or to give interlaced video movie-like look with characteristic judder.&lt;br /&gt;
&lt;br /&gt;
=== Linear ===&lt;br /&gt;
Doubler. Bob with linear interpolation: instead of displaying each line twice, line 2 is created as the average of line 1 and 3, etc.&lt;br /&gt;
&lt;br /&gt;
=== Mean ===&lt;br /&gt;
Blender (half resolution). Display a half-picture that is created as the average of the two original half-pictures.&lt;br /&gt;
&lt;br /&gt;
=== X ===&lt;br /&gt;
Interpolator. Generates a full picture taking the odd lines from the odd half-picture, and creating the even lines through a complicated algorithm (involving ME, MC, edge-oriented interpolation) that uses information from both half-pictures.&lt;br /&gt;
&lt;br /&gt;
This is similar to what 100fps.com calls Area based.&lt;br /&gt;
&lt;br /&gt;
=== Yadif (v1.1.0+)===&lt;br /&gt;
Interpolator. The &#039;&#039;Yet Another DeInterlacing Filter&#039;&#039; from the MPlayer project. Generates a full picture taking the odd lines from the odd half-picture, and creating the even lines through a complicated algorithm that includes both temporal and spatial interpolation.&lt;br /&gt;
&lt;br /&gt;
=== Yadif (2x) (v1.1.0+)===&lt;br /&gt;
Doubler. Bob with Yadif interpolation. &amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;&#039;&#039;&#039;Caution&#039;&#039;&#039;: Very heavy on the CPU.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Phosphor (v1.2.0+) ===&lt;br /&gt;
Doubler. This filter attempts to simulate the rendering mechanism of a traditional CRT TV. The latest two half-pictures are displayed, the old one fading out. The strength of the fade effect can be configured in All Preferences, see Video &amp;gt; Filters &amp;gt; Deinterlace.&lt;br /&gt;
&lt;br /&gt;
=== IVTC (v1.2.0+) ===&lt;br /&gt;
Inverse telecine. Removes telecine from NTSC telecined video in realtime, losslessly recovering the progressive signal. &#039;&#039;&#039;Note&#039;&#039;&#039;: Only applicable to telecined sources. Particularly useful for NTSC anime DVDs.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
File:Example- Disabled Deinterlace.png|Interlaced&lt;br /&gt;
File:Example- Discard interpolate.png|Discard&lt;br /&gt;
File:Example- Blend Deinterlace.png|Blend&lt;br /&gt;
File:Example- Mean Blender.png|Mean&lt;br /&gt;
File:Example- Bob Doubler.png|Bob&lt;br /&gt;
File:Example- Linear Doubler.png|Linear&lt;br /&gt;
File:Example-X interpolate.png|X&lt;br /&gt;
File:Example-Yadif 1.png|Yadif&lt;br /&gt;
File:Example-Yadif 2.png|Yadif (2x)&lt;br /&gt;
File:Example-Phospor Doubler.png|Phosphor&lt;br /&gt;
File:Example-Invert Telecine.png|IVTC&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Recommendation ==&lt;br /&gt;
For telecined sources, use &#039;&#039;&#039;IVTC&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
For true interlaced sources, use a doubler. Which one is a matter of taste. Try &#039;&#039;&#039;Linear&#039;&#039;&#039; first; it is pretty good while simple and light on the CPU.&lt;br /&gt;
&lt;br /&gt;
The classic &#039;&#039;&#039;Bob&#039;&#039;&#039; gives the lowest CPU load and is very simple.&lt;br /&gt;
&lt;br /&gt;
You can use &#039;&#039;&#039;Yadif (2x)&#039;&#039;&#039; if you have a very fast CPU or fastest graphics cards such as NVIDIA Geforce, AMD Radeon or other best graphics cards.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Phosphor&#039;&#039;&#039; (v1.2.0+) mode is different, and may be worth a try if you want a &amp;quot;TV look&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Disclaimer ==&lt;br /&gt;
Please update this page if it contains any errors, is incomplete, or when it goes out of date.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Appendix: Technical summary ==&lt;br /&gt;
&lt;br /&gt;
This table summarizes various technical information on the algorithms. Don&#039;t be afraid to dive in - it&#039;s intended for users.&lt;br /&gt;
&lt;br /&gt;
If you are a developer looking for more detailed technical understanding, this module also has a section in the [[Documentation:Hacker&#039;s Guide/Video Filters/Deinterlace|Hacker&#039;s Guide]].&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Terminology&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* &amp;quot;field&amp;quot; = half-picture&lt;br /&gt;
* &amp;quot;top field&amp;quot; = &amp;quot;odd lines&amp;quot; in other sections above (note that the numbering started from 1)&lt;br /&gt;
* &amp;quot;bottom field&amp;quot; = &amp;quot;even lines&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Legend&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Column 4:2:0 in the table = &amp;quot;if input has 4:2:0 chroma, then...&amp;quot; See [http://en.wikipedia.org/wiki/Chroma_subsampling#Sampling_systems_and_ratios] for an explanation and pictures. This format is common on DVDs.&lt;br /&gt;
* Column 4:2:2 in the table = &amp;quot;if input has 4:2:2 chroma, then...&amp;quot;&lt;br /&gt;
* C, H, FR = output Chroma, Height, Framerate&lt;br /&gt;
* 0 = output has 4:2:0 chroma&lt;br /&gt;
* 2 = output has 4:2:2 chroma&lt;br /&gt;
* h = half height; output has as many lines as an input half-picture&lt;br /&gt;
* f = full height; output has as many lines as an input full picture&lt;br /&gt;
* 1x = output has original framerate (original full-picture rate; typically 25 (PAL) or 30 (NTSC) times per second)&lt;br /&gt;
* 2x = output has double framerate (original half-picture rate; typically 50 (PAL) or 60 (NTSC) times per second)&lt;br /&gt;
* &#039;&#039;&#039;n)&#039;&#039;&#039; = numbered note, read below for details&lt;br /&gt;
&lt;br /&gt;
Note that the picture will be scaled before being displayed, so the number of lines just tells us how detailed the picture could potentially be.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| align=&amp;quot;left &amp;quot;valign=&amp;quot;center&amp;quot; border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Algo&lt;br /&gt;
! 4:2:0&lt;br /&gt;
! 4:2:2&lt;br /&gt;
! Algo type&lt;br /&gt;
! Interpolation (if applic.)&lt;br /&gt;
! Notes&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
| C, H, FR&lt;br /&gt;
| C, H, FR&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| Discard&lt;br /&gt;
| 0, h, 1x&lt;br /&gt;
| 0, f, 1x&lt;br /&gt;
| interpolator&lt;br /&gt;
| none&lt;br /&gt;
| keeps only top field; each line is repeated&lt;br /&gt;
|-&lt;br /&gt;
| Mean&lt;br /&gt;
| 0, h, 1x&lt;br /&gt;
| 2, h, 1x&lt;br /&gt;
| blender&lt;br /&gt;
| &lt;br /&gt;
| half-resolution blender; &#039;&#039;&#039;1)&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| Blend&lt;br /&gt;
| 0, f, 1x&lt;br /&gt;
| 0, f, 1x&lt;br /&gt;
| blender&lt;br /&gt;
| &lt;br /&gt;
| full-resolution blender; &#039;&#039;&#039;2)&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| Bob&lt;br /&gt;
| 0, f, 2x&lt;br /&gt;
| 0, f, 2x&lt;br /&gt;
| doubler&lt;br /&gt;
| none&lt;br /&gt;
| each line is repeated; &#039;&#039;&#039;3)&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| Linear&lt;br /&gt;
| 0, f, 2x&lt;br /&gt;
| 2, f, 2x&lt;br /&gt;
| doubler&lt;br /&gt;
| simple linear&lt;br /&gt;
| first/last line copied; others interpolated; &#039;&#039;&#039;3)&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| X&lt;br /&gt;
| 0, f, 1x&lt;br /&gt;
| 2, f, 1x&lt;br /&gt;
| interpolator&lt;br /&gt;
| MC + edge-oriented&lt;br /&gt;
| keeps only top field in interlaced parts; &#039;&#039;&#039;4)&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| Yadif&lt;br /&gt;
| 0, f, 1x&lt;br /&gt;
| 2, f, 1x&lt;br /&gt;
| interpolator&lt;br /&gt;
| spatial/temporal&lt;br /&gt;
| keeps only top field in interlaced parts&lt;br /&gt;
|-&lt;br /&gt;
| Yadif (2x)&lt;br /&gt;
| 0, f, 2x&lt;br /&gt;
| 2, f, 2x&lt;br /&gt;
| doubler&lt;br /&gt;
| spatial/temporal&lt;br /&gt;
| Yadif and Yadif (2x) come from MPlayer&lt;br /&gt;
|-&lt;br /&gt;
| Phosphor&lt;br /&gt;
| &#039;&#039;&#039;5)&#039;&#039;&#039;, f, 2x&lt;br /&gt;
| 2, f, 2x&lt;br /&gt;
| doubler&lt;br /&gt;
| &lt;br /&gt;
| CRT TV simulator; &#039;&#039;&#039;6)&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
| IVTC&lt;br /&gt;
| 0, f, &#039;&#039;&#039;7)&#039;&#039;&#039;&lt;br /&gt;
| 2, f, &#039;&#039;&#039;7)&#039;&#039;&#039;&lt;br /&gt;
| inverse telecine&lt;br /&gt;
| &lt;br /&gt;
| &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The luma (Y) component scale I (&amp;quot;analog&amp;quot;, 16..240) vs. J (full scale, &amp;quot;digital&amp;quot;, 0..255) is preserved in all format conversions.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Notes&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;1)&#039;&#039;&#039; The Mean algorithm simply pairs the original lines, and averages each pair into one output line. Line 1 of output is the mean of lines 1 and 2 in input, line 2 of output is the mean of lines 3 and 4 in input, and so on.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;2)&#039;&#039;&#039; Blend is slightly more sophisticated than Mean. The first line of output is copied from the first line of input. For any other output line N, the line is the mean of input lines N and N-1. That is, the second line of output is the mean of lines 1 and 2 in input, the third line is the mean of lines 2 and 3, ... and finally, the last line of output is the mean of the last two lines in input. The sliding averaging procedure preserves the original vertical resolution.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;3)&#039;&#039;&#039; Bob converts the half-pictures to full-pictures by simply showing each line twice; so while the full number of lines are displayed, the true resolution is only half.  The same goes for Linear, though it&#039;s a bit smarter about the process.&lt;br /&gt;
&lt;br /&gt;
Still, even the basic Bob is slightly more clever than just a 2x version of Discard. In the output, the bottom field is offset by one line with respect to the top field. This is the technical reason behind the perceived full resolution magic. (As a side effect, it also causes perfectly horizontal lines to flicker in a way characteristic to the Bob algorithm. The other doublers try to overcome this.)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;4)&#039;&#039;&#039; The X algorithm divides the video into blocks of 8x8 pixels, and analyzes them. It blurs the progressive blocks lightly. In the interlaced blocks, it keeps only the top field, and uses MC and edge-oriented interpolation to create the bottom field.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;5)&#039;&#039;&#039; Output from Phosphor is 4:2:2 if the Upconvert mode is chosen in the settings, otherwise 4:2:0 is used.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;6)&#039;&#039;&#039; Phosphor displays the latest two fields, regardless of temporal frame boundaries. To simulate phosphor light output decay, the old field is darkened by an amount that can be configured in All settings &amp;gt; Video &amp;gt; Filters &amp;gt; Deinterlace.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;7)&#039;&#039;&#039; IVTC outputs at (4/5)x of original framerate, when inverting telecine on a locked-on cadence, and at 1x while trying to acquire lock-on.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Video Filters]]&lt;br /&gt;
{{Documentation}}&lt;/div&gt;</summary>
		<author><name>Technologicat</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=Hacker_Guide/How_To_Write_a_Module&amp;diff=19149</id>
		<title>Hacker Guide/How To Write a Module</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=Hacker_Guide/How_To_Write_a_Module&amp;diff=19149"/>
		<updated>2011-05-16T13:31:25Z</updated>

		<summary type="html">&lt;p&gt;Technologicat: /* Troubleshooting */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction to modules writer guide ==&lt;br /&gt;
&lt;br /&gt;
VLC is based on many independent modules, like most multimedia frameworks. Each module introduces a new functionnality.&lt;br /&gt;
&lt;br /&gt;
You &#039;&#039;&#039;MUST&#039;&#039;&#039; &#039;&#039;&#039;read&#039;&#039;&#039; [[Documentation:Hacker%27s_Guide/Core#VLC_Pipeline_and_Modularity|VLC Core and Modules ]] and [[Documentation:VLC_Modules_Loading|How VLC loads modules]] &#039;&#039;&#039;before&#039;&#039;&#039; reading this howto.&lt;br /&gt;
&lt;br /&gt;
This is a description about how you can write a new module for VLC.&lt;br /&gt;
&lt;br /&gt;
== Git and Repository integration ==&lt;br /&gt;
&lt;br /&gt;
=== Git ===&lt;br /&gt;
If you plan to submit your work to VLC upstream, be sure to look at [[Git |the git introduction]] and check the [[Git#Submitting_patches_to_the_vlc-devel_or_x264-devel|send patches part]].&lt;br /&gt;
&lt;br /&gt;
=== Compiling your module ===&lt;br /&gt;
&lt;br /&gt;
==== Modules.am ====&lt;br /&gt;
First, find the right place under [[Modules_source_tree| modules/]] to add your new code.&lt;br /&gt;
&lt;br /&gt;
# If you are adding a one-file module to the repository, just add its sources to the Modules.am in the same folder.&lt;br /&gt;
# If you are adding a bigger modules to the repository:&lt;br /&gt;
#* create a new directory&lt;br /&gt;
#* create a new Modules.am, inside that directory.&lt;br /&gt;
#* Add a corresponding Makefile line at the end of configure.ac for this new Modules.am.&lt;br /&gt;
&lt;br /&gt;
For example, the file {{VLCSourceFile|name=modules/video_filter/Modules.am}} tells the build system which source files go into which video filter module.&lt;br /&gt;
&lt;br /&gt;
Note that the indentation in Modules.am uses a tab (ASCII 0x09), not spaces.&lt;br /&gt;
&lt;br /&gt;
==== configure.ac ====&lt;br /&gt;
&lt;br /&gt;
To have the module built, you need to use &#039;&#039;VLC_ADD_PLUGIN&#039;&#039; or &#039;&#039;PKG_ENABLE_MODULES_VLC&#039;&#039; inside the {{VLCSourceFile|name=configure.ac}} with your new module name as argument. Look at other modules for guidelines on how to add build and linkage options.&lt;br /&gt;
&lt;br /&gt;
After changing {{VLCSourceFile|name=configure.ac}}, you will always need to rerun &lt;br /&gt;
 ./bootstrap &amp;amp;&amp;amp; ./configure&lt;br /&gt;
&lt;br /&gt;
=== Troubleshooting ===&lt;br /&gt;
&lt;br /&gt;
Sometimes, it doesn&#039;t work, because of some libtool bug.&lt;br /&gt;
&lt;br /&gt;
You probably need to go to the root of your VLC source tree, and do something akin to the following. The examples here assume the &#039;&#039;bash&#039;&#039; shell.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Medium version&#039;&#039;&#039; (try this first)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;find . -name .deps -exec rm -rf \{\} \;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;./bootstrap&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;./configure&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The dangerous-looking recursive &#039;&#039;rm -rf&#039;&#039; deletes the dependency caches in the source tree.&lt;br /&gt;
&lt;br /&gt;
This ensures that the build system finds your new files. Then you can go on as usual:&lt;br /&gt;
&amp;lt;pre&amp;gt;./compile&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And finally:&lt;br /&gt;
&amp;lt;pre&amp;gt;./vlc --reset-plugins-cache&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Mild version&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Sometimes &#039;&#039;config.status&#039;&#039; after resetting the .deps cache is enough:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;find . -name .deps -exec rm -rf \{\} \;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;./config.status&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;./compile&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;./vlc --reset-plugins-cache&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
...but not always, so it may save some headaches to always use the &amp;quot;medium version&amp;quot; above.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Extreme version&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the above didn&#039;t help, you can use this more extreme version:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;find . -name .deps -exec rm -rf \{\} \;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;find . -name .libs -exec rm -rf \{\} \;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;./bootstrap&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;./configure&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;./compile&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;./vlc --reset-plugins-cache&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
...which also deletes library caches. Note that when you do this, you &#039;&#039;&#039;must&#039;&#039;&#039; run &#039;&#039;configure&#039;&#039; and not just &#039;&#039;config.status&#039;&#039;, because &#039;&#039;config.status&#039;&#039; runs configure in &#039;&#039;--no-create&#039;&#039; mode, which will not re-create the .libs caches.&lt;br /&gt;
&lt;br /&gt;
==== Out of Tree Compile ====&lt;br /&gt;
&lt;br /&gt;
If you need to compile just a module, please read [[OutOfTreeCompile|out of tree compilation]].&lt;br /&gt;
&lt;br /&gt;
=== Loading your module ===&lt;br /&gt;
&lt;br /&gt;
VLC keeps the cache of its modules (in ~/.cache/vlc/ on Linux), you&#039;ll have to delete it (or use vlc --reset-plugins-cache) so that your module gets loaded.&lt;br /&gt;
&lt;br /&gt;
Then use&lt;br /&gt;
 vlc -vvv --color --list&lt;br /&gt;
to check that your plugin is seen by {{VLC}}.&lt;br /&gt;
&lt;br /&gt;
You should also see it in the plugins dialog of the [[Qt interface]] (Linux and Windows).&lt;br /&gt;
&lt;br /&gt;
== Example of an empty module  ==&lt;br /&gt;
&lt;br /&gt;
We will start with a small example, so you can understand it better. &lt;br /&gt;
&amp;lt;pre&amp;gt;/*****************************************************************************&lt;br /&gt;
 * Preamble&lt;br /&gt;
 *****************************************************************************/&lt;br /&gt;
&lt;br /&gt;
#ifdef HAVE_CONFIG_H&lt;br /&gt;
# include &amp;quot;config.h&amp;quot;&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
#include &amp;amp;lt;vlc_common.h&amp;amp;gt;&lt;br /&gt;
#include &amp;amp;lt;vlc_plugin.h&amp;amp;gt;&lt;br /&gt;
&lt;br /&gt;
/*****************************************************************************&lt;br /&gt;
* Local prototypes.&lt;br /&gt;
*****************************************************************************/&lt;br /&gt;
&lt;br /&gt;
static int  Open           ( vlc_object_t * );&lt;br /&gt;
static void Close          ( vlc_object_t * );&lt;br /&gt;
&lt;br /&gt;
/*****************************************************************************&lt;br /&gt;
 * Module descriptor&lt;br /&gt;
 *****************************************************************************/&lt;br /&gt;
&lt;br /&gt;
vlc_module_begin()&lt;br /&gt;
    set_shortname( _(&amp;quot;testmodule&amp;quot;) )&lt;br /&gt;
    set_description( _(&amp;quot;testmodle plug-in&amp;quot;) )&lt;br /&gt;
    set_capability( &amp;quot;testing&amp;quot;, 0 )&lt;br /&gt;
    set_callbacks( Open, Close )&lt;br /&gt;
    set_category( CAT_INTERFACE ) /* choose relevant category, default categories in vlc/include/vlc_configuration.h */&lt;br /&gt;
&lt;br /&gt;
    add_integer( &amp;quot;test-angle&amp;quot;, 1, &amp;quot;DVD Angle&amp;quot;, &amp;quot;Default DVD Angle&amp;quot;, false)&lt;br /&gt;
vlc_module_end ()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/*****************************************************************************&lt;br /&gt;
 * Open: initialize interface&lt;br /&gt;
 *****************************************************************************/&lt;br /&gt;
static int Open( vlc_object_t *p_this )&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/*****************************************************************************&lt;br /&gt;
 * Close: destroy interface&lt;br /&gt;
 *****************************************************************************/&lt;br /&gt;
static void Close( vlc_object_t *p_this )&lt;br /&gt;
{&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== How to write the module, aka Explanations about the empty module ==&lt;br /&gt;
&lt;br /&gt;
=== Module Descriptor  ===&lt;br /&gt;
&lt;br /&gt;
A {{VLC}} module &#039;&#039;&#039;must&#039;&#039;&#039; include a &#039;&#039;description&#039;&#039; of itself, and the &#039;&#039;parameters&#039;&#039; it accepts. &lt;br /&gt;
&lt;br /&gt;
The module descriptor begins with: &lt;br /&gt;
&amp;lt;pre&amp;gt;vlc_module_begin();&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
You should set some basic information about your module: &lt;br /&gt;
&amp;lt;pre&amp;gt;    set_shortname( _(&amp;quot;DVD without menus&amp;quot;) );&lt;br /&gt;
    set_description( _(&amp;quot;DVDRead Input&amp;quot;) );&lt;br /&gt;
    set_category( CAT_INPUT );&lt;br /&gt;
    set_subcategory( SUBCAT_INPUT_ACCESS );&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&#039;&#039;Note&#039;&#039; the use of _(&amp;quot;&amp;quot;) to create a string that needs to be translated. &lt;br /&gt;
&lt;br /&gt;
==== Capability and score ====&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The capability is key to the module loading&#039;&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
It defines the type of module we are dealing with, whether it is an access, a demux, a decoder or else... &lt;br /&gt;
&lt;br /&gt;
Now is the time to &#039;&#039;&#039;re-read [[Documentation:VLC Modules Loading#How_does_the_loading_of_modules_happens|how VLC loads modules]]&#039;&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*If VLC needs to load a specific name, it will load it by its name and VLC directly opens this module &lt;br /&gt;
*If VLC needs a type of modules (&amp;quot;I need a decoder&amp;quot;), VLC will load all modules matching this capability by decreasing score order until one modules&#039;s Open() function (see later) returns VLC_SUCCESS.&lt;br /&gt;
&lt;br /&gt;
See the major types of [[Documentation:VLC Modules Loading#Major_Capabilities_of_Modules|capabilities of VLC]]. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Score&#039;&#039;&#039; should be an integer, and related to other scores in the same category. Score 0 is a [[Documentation:VLC_Modules_Loading#Score_of_0|special case]].&lt;br /&gt;
&lt;br /&gt;
Definition &#039;&#039;&#039;Example&#039;&#039;&#039;: &lt;br /&gt;
&amp;lt;pre&amp;gt;   set_capability( &amp;quot;testing&amp;quot;, 10 )&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
This defines a module of &amp;quot;testing&amp;quot; capability and a score of 10.&lt;br /&gt;
&lt;br /&gt;
==== Configuration Categories and SubCategories  ====&lt;br /&gt;
&lt;br /&gt;
You should use &#039;&#039;&#039;one&#039;&#039;&#039; of the &#039;&#039;&#039;predefined categories&#039;&#039;&#039; for configuration. &lt;br /&gt;
&lt;br /&gt;
The Configuration Categories and Subcategories define &#039;&#039;&#039;where&#039;&#039;&#039; the module will appear in the &#039;&#039;&#039;preferences&#039;&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
The configuration categories include: &lt;br /&gt;
&lt;br /&gt;
*CAT_INTERFACE &lt;br /&gt;
*CAT_AUDIO &lt;br /&gt;
*CAT_VIDEO &lt;br /&gt;
*CAT_INPUT &lt;br /&gt;
*CAT_SOUT &lt;br /&gt;
*CAT_ADVANCED &lt;br /&gt;
*CAT_PLAYLIST&lt;br /&gt;
&lt;br /&gt;
You should use one of &#039;&#039;&#039;predefined sub-categories&#039;&#039;&#039; too. &lt;br /&gt;
&lt;br /&gt;
See {{VLCSourceFile|name=include/vlc_configuration.h}} for definition of all configuration categories and sub-categories. &lt;br /&gt;
&lt;br /&gt;
==== Configuration and Parameters Options  ====&lt;br /&gt;
&lt;br /&gt;
You will need options for your module. Defining new options is easy. &lt;br /&gt;
&lt;br /&gt;
All options definitions take the following argument list: &lt;br /&gt;
&amp;lt;pre&amp;gt; add_integer(name, value, text, longtext, advanced) &amp;lt;/pre&amp;gt; &lt;br /&gt;
*&#039;&#039;&#039;name&#039;&#039;&#039; is the string that identifies this parameter in the configuration. This name is used at the command prompt to set the configuration value. &lt;br /&gt;
*&#039;&#039;&#039;value&#039;&#039;&#039; is the default value for this parameter, &lt;br /&gt;
*&#039;&#039;&#039;text&#039;&#039;&#039; A short description of the parameter, use _(&amp;quot;&amp;quot;) to create a string that needs to be translated, &lt;br /&gt;
*&#039;&#039;&#039;longtext&#039;&#039;&#039; A complete description of the parameter, use _(&amp;quot;&amp;quot;) to create a string that needs to be translated,&lt;br /&gt;
*&#039;&#039;&#039;advanced&#039;&#039;&#039; Boolean, ADVanced Configuration. If TRUE, this parameter will only be displayed when using the --advanced flag. e.g.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt; You may add the following options/parameter types to your module: &lt;br /&gt;
&lt;br /&gt;
*add_integer, &lt;br /&gt;
*add_string, &lt;br /&gt;
*add_float, &lt;br /&gt;
*add_bool, &lt;br /&gt;
*add_key, &lt;br /&gt;
*add_file, &lt;br /&gt;
*add_directory,&lt;br /&gt;
&lt;br /&gt;
For complete definitions, see {{VLCSourceFile|name=include/vlc_plugin.h}}&lt;br /&gt;
&lt;br /&gt;
==== Callback  ====&lt;br /&gt;
&lt;br /&gt;
The opening and closing static functions, detailed afterwards, need to be defined in the descriptor, so VLC can discuss with the module.&lt;br /&gt;
&lt;br /&gt;
=== Open(vlc_object_t *)  ===&lt;br /&gt;
&lt;br /&gt;
The most important function of a module, is the opening: the usually-named Open() function. &lt;br /&gt;
&amp;lt;pre&amp;gt;static int  Open ( vlc_object_t * );&amp;lt;/pre&amp;gt; &lt;br /&gt;
The Open() function is called when the VLC core tries to open the module, and wants to load it. &lt;br /&gt;
&lt;br /&gt;
During Open(), setup of structures, devices or I/O, checks should be done. A working open should return VLC_SUCCESS. In all other cases, it will not be considered as loaded.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Open()&#039;&#039;&#039; function is expected to allocate private data (if any), and set up the private structure.&lt;br /&gt;
&lt;br /&gt;
If the Opening fails, you need to clean-up your own structures.&lt;br /&gt;
&lt;br /&gt;
=== Close(vlc_object_t *)  ===&lt;br /&gt;
The second most important function of a module, is the closing: the usually-named Close() function.&lt;br /&gt;
&amp;lt;pre&amp;gt;static int  Close ( vlc_object_t * );&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Close() function is called when the VLC core tries to close or unload an &#039;&#039;&#039;already-loaded&#039;&#039;&#039; module.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NB:&#039;&#039;&#039; If the Open() function failed, Close() will not get called.&lt;br /&gt;
&lt;br /&gt;
During Close(), close devices or I/O and cleaning of structures should be done. Do not leak memory here!&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Close()&#039;&#039;&#039; function should deallocate private data.&lt;br /&gt;
&lt;br /&gt;
== SubModules  ==&lt;br /&gt;
&lt;br /&gt;
Submodules, created in some modules with &lt;br /&gt;
&lt;br /&gt;
 add_submodule()&lt;br /&gt;
&lt;br /&gt;
work exactly the same way as modules. They are useful to parent modules, and to share code between modules.&lt;br /&gt;
&lt;br /&gt;
The submodules will be separated in the cache, and will be loaded by VLC in the exact same way as a module.&lt;br /&gt;
&lt;br /&gt;
== Modules types ==&lt;br /&gt;
&lt;br /&gt;
Depending on the module capability, you will need more information, about the necessary functions to implement.&lt;br /&gt;
&lt;br /&gt;
We will detail those here:&lt;br /&gt;
* [[Documentation:Hacker&#039;s_Guide/Access|Access]]&lt;br /&gt;
* [[Documentation:Hacker&#039;s_Guide/Demux|Demux]]&lt;br /&gt;
* [[Documentation:Hacker&#039;s_Guide/Access_Demux|Access_Demux]]&lt;br /&gt;
* Decoder&lt;br /&gt;
* Interface&lt;br /&gt;
* [[Documentation:Hacker&#039;s_Guide/Video_Filters|Video Filter]]&lt;br /&gt;
* [[Documentation:Hacker&#039;s_Guide/Audio_Filters|Audio Filter]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Documentation}} &lt;br /&gt;
&lt;br /&gt;
[[Category:Coding]]&lt;/div&gt;</summary>
		<author><name>Technologicat</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=Hacker_Guide/How_To_Write_a_Module&amp;diff=19148</id>
		<title>Hacker Guide/How To Write a Module</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=Hacker_Guide/How_To_Write_a_Module&amp;diff=19148"/>
		<updated>2011-05-16T13:30:05Z</updated>

		<summary type="html">&lt;p&gt;Technologicat: /* Troubleshooting */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction to modules writer guide ==&lt;br /&gt;
&lt;br /&gt;
VLC is based on many independent modules, like most multimedia frameworks. Each module introduces a new functionnality.&lt;br /&gt;
&lt;br /&gt;
You &#039;&#039;&#039;MUST&#039;&#039;&#039; &#039;&#039;&#039;read&#039;&#039;&#039; [[Documentation:Hacker%27s_Guide/Core#VLC_Pipeline_and_Modularity|VLC Core and Modules ]] and [[Documentation:VLC_Modules_Loading|How VLC loads modules]] &#039;&#039;&#039;before&#039;&#039;&#039; reading this howto.&lt;br /&gt;
&lt;br /&gt;
This is a description about how you can write a new module for VLC.&lt;br /&gt;
&lt;br /&gt;
== Git and Repository integration ==&lt;br /&gt;
&lt;br /&gt;
=== Git ===&lt;br /&gt;
If you plan to submit your work to VLC upstream, be sure to look at [[Git |the git introduction]] and check the [[Git#Submitting_patches_to_the_vlc-devel_or_x264-devel|send patches part]].&lt;br /&gt;
&lt;br /&gt;
=== Compiling your module ===&lt;br /&gt;
&lt;br /&gt;
==== Modules.am ====&lt;br /&gt;
First, find the right place under [[Modules_source_tree| modules/]] to add your new code.&lt;br /&gt;
&lt;br /&gt;
# If you are adding a one-file module to the repository, just add its sources to the Modules.am in the same folder.&lt;br /&gt;
# If you are adding a bigger modules to the repository:&lt;br /&gt;
#* create a new directory&lt;br /&gt;
#* create a new Modules.am, inside that directory.&lt;br /&gt;
#* Add a corresponding Makefile line at the end of configure.ac for this new Modules.am.&lt;br /&gt;
&lt;br /&gt;
For example, the file {{VLCSourceFile|name=modules/video_filter/Modules.am}} tells the build system which source files go into which video filter module.&lt;br /&gt;
&lt;br /&gt;
Note that the indentation in Modules.am uses a tab (ASCII 0x09), not spaces.&lt;br /&gt;
&lt;br /&gt;
==== configure.ac ====&lt;br /&gt;
&lt;br /&gt;
To have the module built, you need to use &#039;&#039;VLC_ADD_PLUGIN&#039;&#039; or &#039;&#039;PKG_ENABLE_MODULES_VLC&#039;&#039; inside the {{VLCSourceFile|name=configure.ac}} with your new module name as argument. Look at other modules for guidelines on how to add build and linkage options.&lt;br /&gt;
&lt;br /&gt;
After changing {{VLCSourceFile|name=configure.ac}}, you will always need to rerun &lt;br /&gt;
 ./bootstrap &amp;amp;&amp;amp; ./configure&lt;br /&gt;
&lt;br /&gt;
=== Troubleshooting ===&lt;br /&gt;
&lt;br /&gt;
Sometimes, it doesn&#039;t work, because of some libtool bug.&lt;br /&gt;
&lt;br /&gt;
You probably need to go to the root of your VLC source tree, and do something akin to the following. The examples here assume the &#039;&#039;bash&#039;&#039; shell.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Medium version&#039;&#039;&#039; (try this first)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;find . -name .deps -exec rm -rf \{\} \;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;./bootstrap&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;./configure&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The dangerous-looking recursive &#039;&#039;rm -rf&#039;&#039; deletes the dependency caches in the source tree.&lt;br /&gt;
&lt;br /&gt;
This ensures that the build system finds your new files. Then you can go on as usual:&lt;br /&gt;
&amp;lt;pre&amp;gt;./compile&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And finally:&lt;br /&gt;
&amp;lt;pre&amp;gt;./vlc --reset-plugins-cache&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Mild version&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Sometimes &#039;&#039;config.status&#039;&#039; is enough:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;find . -name .deps -exec rm -rf \{\} \;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;./config.status&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;./compile&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;./vlc --reset-plugins-cache&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
...but not always, so it may save some headaches to always use the &amp;quot;medium version&amp;quot; above.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Extreme version&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the above didn&#039;t help, you can use this more extreme version:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;find . -name .deps -exec rm -rf \{\} \;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;find . -name .libs -exec rm -rf \{\} \;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;./bootstrap&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;./configure&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;./compile&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;./vlc --reset-plugins-cache&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
...which also deletes library caches. Note that when you do this, you &#039;&#039;&#039;must&#039;&#039;&#039; run &#039;&#039;configure&#039;&#039; and not just &#039;&#039;config.status&#039;&#039;, because &#039;&#039;config.status&#039;&#039; runs configure in &#039;&#039;--no-create&#039;&#039; mode, which will not re-create the .libs caches.&lt;br /&gt;
&lt;br /&gt;
==== Out of Tree Compile ====&lt;br /&gt;
&lt;br /&gt;
If you need to compile just a module, please read [[OutOfTreeCompile|out of tree compilation]].&lt;br /&gt;
&lt;br /&gt;
=== Loading your module ===&lt;br /&gt;
&lt;br /&gt;
VLC keeps the cache of its modules (in ~/.cache/vlc/ on Linux), you&#039;ll have to delete it (or use vlc --reset-plugins-cache) so that your module gets loaded.&lt;br /&gt;
&lt;br /&gt;
Then use&lt;br /&gt;
 vlc -vvv --color --list&lt;br /&gt;
to check that your plugin is seen by {{VLC}}.&lt;br /&gt;
&lt;br /&gt;
You should also see it in the plugins dialog of the [[Qt interface]] (Linux and Windows).&lt;br /&gt;
&lt;br /&gt;
== Example of an empty module  ==&lt;br /&gt;
&lt;br /&gt;
We will start with a small example, so you can understand it better. &lt;br /&gt;
&amp;lt;pre&amp;gt;/*****************************************************************************&lt;br /&gt;
 * Preamble&lt;br /&gt;
 *****************************************************************************/&lt;br /&gt;
&lt;br /&gt;
#ifdef HAVE_CONFIG_H&lt;br /&gt;
# include &amp;quot;config.h&amp;quot;&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
#include &amp;amp;lt;vlc_common.h&amp;amp;gt;&lt;br /&gt;
#include &amp;amp;lt;vlc_plugin.h&amp;amp;gt;&lt;br /&gt;
&lt;br /&gt;
/*****************************************************************************&lt;br /&gt;
* Local prototypes.&lt;br /&gt;
*****************************************************************************/&lt;br /&gt;
&lt;br /&gt;
static int  Open           ( vlc_object_t * );&lt;br /&gt;
static void Close          ( vlc_object_t * );&lt;br /&gt;
&lt;br /&gt;
/*****************************************************************************&lt;br /&gt;
 * Module descriptor&lt;br /&gt;
 *****************************************************************************/&lt;br /&gt;
&lt;br /&gt;
vlc_module_begin()&lt;br /&gt;
    set_shortname( _(&amp;quot;testmodule&amp;quot;) )&lt;br /&gt;
    set_description( _(&amp;quot;testmodle plug-in&amp;quot;) )&lt;br /&gt;
    set_capability( &amp;quot;testing&amp;quot;, 0 )&lt;br /&gt;
    set_callbacks( Open, Close )&lt;br /&gt;
    set_category( CAT_INTERFACE ) /* choose relevant category, default categories in vlc/include/vlc_configuration.h */&lt;br /&gt;
&lt;br /&gt;
    add_integer( &amp;quot;test-angle&amp;quot;, 1, &amp;quot;DVD Angle&amp;quot;, &amp;quot;Default DVD Angle&amp;quot;, false)&lt;br /&gt;
vlc_module_end ()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/*****************************************************************************&lt;br /&gt;
 * Open: initialize interface&lt;br /&gt;
 *****************************************************************************/&lt;br /&gt;
static int Open( vlc_object_t *p_this )&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/*****************************************************************************&lt;br /&gt;
 * Close: destroy interface&lt;br /&gt;
 *****************************************************************************/&lt;br /&gt;
static void Close( vlc_object_t *p_this )&lt;br /&gt;
{&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== How to write the module, aka Explanations about the empty module ==&lt;br /&gt;
&lt;br /&gt;
=== Module Descriptor  ===&lt;br /&gt;
&lt;br /&gt;
A {{VLC}} module &#039;&#039;&#039;must&#039;&#039;&#039; include a &#039;&#039;description&#039;&#039; of itself, and the &#039;&#039;parameters&#039;&#039; it accepts. &lt;br /&gt;
&lt;br /&gt;
The module descriptor begins with: &lt;br /&gt;
&amp;lt;pre&amp;gt;vlc_module_begin();&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
You should set some basic information about your module: &lt;br /&gt;
&amp;lt;pre&amp;gt;    set_shortname( _(&amp;quot;DVD without menus&amp;quot;) );&lt;br /&gt;
    set_description( _(&amp;quot;DVDRead Input&amp;quot;) );&lt;br /&gt;
    set_category( CAT_INPUT );&lt;br /&gt;
    set_subcategory( SUBCAT_INPUT_ACCESS );&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&#039;&#039;Note&#039;&#039; the use of _(&amp;quot;&amp;quot;) to create a string that needs to be translated. &lt;br /&gt;
&lt;br /&gt;
==== Capability and score ====&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The capability is key to the module loading&#039;&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
It defines the type of module we are dealing with, whether it is an access, a demux, a decoder or else... &lt;br /&gt;
&lt;br /&gt;
Now is the time to &#039;&#039;&#039;re-read [[Documentation:VLC Modules Loading#How_does_the_loading_of_modules_happens|how VLC loads modules]]&#039;&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*If VLC needs to load a specific name, it will load it by its name and VLC directly opens this module &lt;br /&gt;
*If VLC needs a type of modules (&amp;quot;I need a decoder&amp;quot;), VLC will load all modules matching this capability by decreasing score order until one modules&#039;s Open() function (see later) returns VLC_SUCCESS.&lt;br /&gt;
&lt;br /&gt;
See the major types of [[Documentation:VLC Modules Loading#Major_Capabilities_of_Modules|capabilities of VLC]]. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Score&#039;&#039;&#039; should be an integer, and related to other scores in the same category. Score 0 is a [[Documentation:VLC_Modules_Loading#Score_of_0|special case]].&lt;br /&gt;
&lt;br /&gt;
Definition &#039;&#039;&#039;Example&#039;&#039;&#039;: &lt;br /&gt;
&amp;lt;pre&amp;gt;   set_capability( &amp;quot;testing&amp;quot;, 10 )&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
This defines a module of &amp;quot;testing&amp;quot; capability and a score of 10.&lt;br /&gt;
&lt;br /&gt;
==== Configuration Categories and SubCategories  ====&lt;br /&gt;
&lt;br /&gt;
You should use &#039;&#039;&#039;one&#039;&#039;&#039; of the &#039;&#039;&#039;predefined categories&#039;&#039;&#039; for configuration. &lt;br /&gt;
&lt;br /&gt;
The Configuration Categories and Subcategories define &#039;&#039;&#039;where&#039;&#039;&#039; the module will appear in the &#039;&#039;&#039;preferences&#039;&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
The configuration categories include: &lt;br /&gt;
&lt;br /&gt;
*CAT_INTERFACE &lt;br /&gt;
*CAT_AUDIO &lt;br /&gt;
*CAT_VIDEO &lt;br /&gt;
*CAT_INPUT &lt;br /&gt;
*CAT_SOUT &lt;br /&gt;
*CAT_ADVANCED &lt;br /&gt;
*CAT_PLAYLIST&lt;br /&gt;
&lt;br /&gt;
You should use one of &#039;&#039;&#039;predefined sub-categories&#039;&#039;&#039; too. &lt;br /&gt;
&lt;br /&gt;
See {{VLCSourceFile|name=include/vlc_configuration.h}} for definition of all configuration categories and sub-categories. &lt;br /&gt;
&lt;br /&gt;
==== Configuration and Parameters Options  ====&lt;br /&gt;
&lt;br /&gt;
You will need options for your module. Defining new options is easy. &lt;br /&gt;
&lt;br /&gt;
All options definitions take the following argument list: &lt;br /&gt;
&amp;lt;pre&amp;gt; add_integer(name, value, text, longtext, advanced) &amp;lt;/pre&amp;gt; &lt;br /&gt;
*&#039;&#039;&#039;name&#039;&#039;&#039; is the string that identifies this parameter in the configuration. This name is used at the command prompt to set the configuration value. &lt;br /&gt;
*&#039;&#039;&#039;value&#039;&#039;&#039; is the default value for this parameter, &lt;br /&gt;
*&#039;&#039;&#039;text&#039;&#039;&#039; A short description of the parameter, use _(&amp;quot;&amp;quot;) to create a string that needs to be translated, &lt;br /&gt;
*&#039;&#039;&#039;longtext&#039;&#039;&#039; A complete description of the parameter, use _(&amp;quot;&amp;quot;) to create a string that needs to be translated,&lt;br /&gt;
*&#039;&#039;&#039;advanced&#039;&#039;&#039; Boolean, ADVanced Configuration. If TRUE, this parameter will only be displayed when using the --advanced flag. e.g.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt; You may add the following options/parameter types to your module: &lt;br /&gt;
&lt;br /&gt;
*add_integer, &lt;br /&gt;
*add_string, &lt;br /&gt;
*add_float, &lt;br /&gt;
*add_bool, &lt;br /&gt;
*add_key, &lt;br /&gt;
*add_file, &lt;br /&gt;
*add_directory,&lt;br /&gt;
&lt;br /&gt;
For complete definitions, see {{VLCSourceFile|name=include/vlc_plugin.h}}&lt;br /&gt;
&lt;br /&gt;
==== Callback  ====&lt;br /&gt;
&lt;br /&gt;
The opening and closing static functions, detailed afterwards, need to be defined in the descriptor, so VLC can discuss with the module.&lt;br /&gt;
&lt;br /&gt;
=== Open(vlc_object_t *)  ===&lt;br /&gt;
&lt;br /&gt;
The most important function of a module, is the opening: the usually-named Open() function. &lt;br /&gt;
&amp;lt;pre&amp;gt;static int  Open ( vlc_object_t * );&amp;lt;/pre&amp;gt; &lt;br /&gt;
The Open() function is called when the VLC core tries to open the module, and wants to load it. &lt;br /&gt;
&lt;br /&gt;
During Open(), setup of structures, devices or I/O, checks should be done. A working open should return VLC_SUCCESS. In all other cases, it will not be considered as loaded.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Open()&#039;&#039;&#039; function is expected to allocate private data (if any), and set up the private structure.&lt;br /&gt;
&lt;br /&gt;
If the Opening fails, you need to clean-up your own structures.&lt;br /&gt;
&lt;br /&gt;
=== Close(vlc_object_t *)  ===&lt;br /&gt;
The second most important function of a module, is the closing: the usually-named Close() function.&lt;br /&gt;
&amp;lt;pre&amp;gt;static int  Close ( vlc_object_t * );&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Close() function is called when the VLC core tries to close or unload an &#039;&#039;&#039;already-loaded&#039;&#039;&#039; module.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NB:&#039;&#039;&#039; If the Open() function failed, Close() will not get called.&lt;br /&gt;
&lt;br /&gt;
During Close(), close devices or I/O and cleaning of structures should be done. Do not leak memory here!&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Close()&#039;&#039;&#039; function should deallocate private data.&lt;br /&gt;
&lt;br /&gt;
== SubModules  ==&lt;br /&gt;
&lt;br /&gt;
Submodules, created in some modules with &lt;br /&gt;
&lt;br /&gt;
 add_submodule()&lt;br /&gt;
&lt;br /&gt;
work exactly the same way as modules. They are useful to parent modules, and to share code between modules.&lt;br /&gt;
&lt;br /&gt;
The submodules will be separated in the cache, and will be loaded by VLC in the exact same way as a module.&lt;br /&gt;
&lt;br /&gt;
== Modules types ==&lt;br /&gt;
&lt;br /&gt;
Depending on the module capability, you will need more information, about the necessary functions to implement.&lt;br /&gt;
&lt;br /&gt;
We will detail those here:&lt;br /&gt;
* [[Documentation:Hacker&#039;s_Guide/Access|Access]]&lt;br /&gt;
* [[Documentation:Hacker&#039;s_Guide/Demux|Demux]]&lt;br /&gt;
* [[Documentation:Hacker&#039;s_Guide/Access_Demux|Access_Demux]]&lt;br /&gt;
* Decoder&lt;br /&gt;
* Interface&lt;br /&gt;
* [[Documentation:Hacker&#039;s_Guide/Video_Filters|Video Filter]]&lt;br /&gt;
* [[Documentation:Hacker&#039;s_Guide/Audio_Filters|Audio Filter]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Documentation}} &lt;br /&gt;
&lt;br /&gt;
[[Category:Coding]]&lt;/div&gt;</summary>
		<author><name>Technologicat</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=Hacker_Guide/How_To_Write_a_Module&amp;diff=19147</id>
		<title>Hacker Guide/How To Write a Module</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=Hacker_Guide/How_To_Write_a_Module&amp;diff=19147"/>
		<updated>2011-05-16T13:29:26Z</updated>

		<summary type="html">&lt;p&gt;Technologicat: /* Troubleshooting */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction to modules writer guide ==&lt;br /&gt;
&lt;br /&gt;
VLC is based on many independent modules, like most multimedia frameworks. Each module introduces a new functionnality.&lt;br /&gt;
&lt;br /&gt;
You &#039;&#039;&#039;MUST&#039;&#039;&#039; &#039;&#039;&#039;read&#039;&#039;&#039; [[Documentation:Hacker%27s_Guide/Core#VLC_Pipeline_and_Modularity|VLC Core and Modules ]] and [[Documentation:VLC_Modules_Loading|How VLC loads modules]] &#039;&#039;&#039;before&#039;&#039;&#039; reading this howto.&lt;br /&gt;
&lt;br /&gt;
This is a description about how you can write a new module for VLC.&lt;br /&gt;
&lt;br /&gt;
== Git and Repository integration ==&lt;br /&gt;
&lt;br /&gt;
=== Git ===&lt;br /&gt;
If you plan to submit your work to VLC upstream, be sure to look at [[Git |the git introduction]] and check the [[Git#Submitting_patches_to_the_vlc-devel_or_x264-devel|send patches part]].&lt;br /&gt;
&lt;br /&gt;
=== Compiling your module ===&lt;br /&gt;
&lt;br /&gt;
==== Modules.am ====&lt;br /&gt;
First, find the right place under [[Modules_source_tree| modules/]] to add your new code.&lt;br /&gt;
&lt;br /&gt;
# If you are adding a one-file module to the repository, just add its sources to the Modules.am in the same folder.&lt;br /&gt;
# If you are adding a bigger modules to the repository:&lt;br /&gt;
#* create a new directory&lt;br /&gt;
#* create a new Modules.am, inside that directory.&lt;br /&gt;
#* Add a corresponding Makefile line at the end of configure.ac for this new Modules.am.&lt;br /&gt;
&lt;br /&gt;
For example, the file {{VLCSourceFile|name=modules/video_filter/Modules.am}} tells the build system which source files go into which video filter module.&lt;br /&gt;
&lt;br /&gt;
Note that the indentation in Modules.am uses a tab (ASCII 0x09), not spaces.&lt;br /&gt;
&lt;br /&gt;
==== configure.ac ====&lt;br /&gt;
&lt;br /&gt;
To have the module built, you need to use &#039;&#039;VLC_ADD_PLUGIN&#039;&#039; or &#039;&#039;PKG_ENABLE_MODULES_VLC&#039;&#039; inside the {{VLCSourceFile|name=configure.ac}} with your new module name as argument. Look at other modules for guidelines on how to add build and linkage options.&lt;br /&gt;
&lt;br /&gt;
After changing {{VLCSourceFile|name=configure.ac}}, you will always need to rerun &lt;br /&gt;
 ./bootstrap &amp;amp;&amp;amp; ./configure&lt;br /&gt;
&lt;br /&gt;
=== Troubleshooting ===&lt;br /&gt;
&lt;br /&gt;
Sometimes, it doesn&#039;t work, because of some libtool bug.&lt;br /&gt;
&lt;br /&gt;
You probably need to go to the root of your VLC source tree, and do something akin to the following. The examples here assume the &#039;&#039;bash&#039;&#039; shell.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Medium version&#039;&#039;&#039; (try this first)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;find . -name .deps -exec rm -rf \{\} \;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;./bootstrap&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;./configure&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The dangerous-looking recursive &#039;&#039;rm -rf&#039;&#039; deletes the dependency caches in the source tree.&lt;br /&gt;
&lt;br /&gt;
This ensures that the build system finds your new files. Then you can go on as usual:&lt;br /&gt;
&amp;lt;pre&amp;gt;./compile&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And finally:&lt;br /&gt;
&amp;lt;pre&amp;gt;./vlc --reset-plugins-cache&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Mild version&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Sometimes &#039;&#039;config.status&#039;&#039; is enough:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;find . -name .deps -exec rm -rf \{\} \;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;./config.status&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;./compile&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;./vlc --reset-plugins-cache&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
...but not always, so it may save some headaches to always use the &amp;quot;medium version&amp;quot; above.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Extreme version&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If the above didn&#039;t help, you can use this more extreme version:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;find . -name .deps -exec rm -rf \{\} \;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;find . -name .libs -exec rm -rf \{\} \;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;./bootstrap&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;./configure&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;./compile&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;./vlc --reset-plugins-cache&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
...which also deletes library caches. Note that when you do this, you &#039;&#039;&#039;must&#039;&#039;&#039; run &#039;&#039;configure&#039;&#039; and not just &#039;&#039;config.status&#039;&#039;, because &#039;&#039;config.status&#039;&#039; runs configure in &#039;&#039;--no-create&#039;&#039; mode, which will not re-create the .libs caches.&lt;br /&gt;
&lt;br /&gt;
==== Out of Tree Compile ====&lt;br /&gt;
&lt;br /&gt;
If you need to compile just a module, please read [[OutOfTreeCompile|out of tree compilation]].&lt;br /&gt;
&lt;br /&gt;
=== Loading your module ===&lt;br /&gt;
&lt;br /&gt;
VLC keeps the cache of its modules (in ~/.cache/vlc/ on Linux), you&#039;ll have to delete it (or use vlc --reset-plugins-cache) so that your module gets loaded.&lt;br /&gt;
&lt;br /&gt;
Then use&lt;br /&gt;
 vlc -vvv --color --list&lt;br /&gt;
to check that your plugin is seen by {{VLC}}.&lt;br /&gt;
&lt;br /&gt;
You should also see it in the plugins dialog of the [[Qt interface]] (Linux and Windows).&lt;br /&gt;
&lt;br /&gt;
== Example of an empty module  ==&lt;br /&gt;
&lt;br /&gt;
We will start with a small example, so you can understand it better. &lt;br /&gt;
&amp;lt;pre&amp;gt;/*****************************************************************************&lt;br /&gt;
 * Preamble&lt;br /&gt;
 *****************************************************************************/&lt;br /&gt;
&lt;br /&gt;
#ifdef HAVE_CONFIG_H&lt;br /&gt;
# include &amp;quot;config.h&amp;quot;&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
#include &amp;amp;lt;vlc_common.h&amp;amp;gt;&lt;br /&gt;
#include &amp;amp;lt;vlc_plugin.h&amp;amp;gt;&lt;br /&gt;
&lt;br /&gt;
/*****************************************************************************&lt;br /&gt;
* Local prototypes.&lt;br /&gt;
*****************************************************************************/&lt;br /&gt;
&lt;br /&gt;
static int  Open           ( vlc_object_t * );&lt;br /&gt;
static void Close          ( vlc_object_t * );&lt;br /&gt;
&lt;br /&gt;
/*****************************************************************************&lt;br /&gt;
 * Module descriptor&lt;br /&gt;
 *****************************************************************************/&lt;br /&gt;
&lt;br /&gt;
vlc_module_begin()&lt;br /&gt;
    set_shortname( _(&amp;quot;testmodule&amp;quot;) )&lt;br /&gt;
    set_description( _(&amp;quot;testmodle plug-in&amp;quot;) )&lt;br /&gt;
    set_capability( &amp;quot;testing&amp;quot;, 0 )&lt;br /&gt;
    set_callbacks( Open, Close )&lt;br /&gt;
    set_category( CAT_INTERFACE ) /* choose relevant category, default categories in vlc/include/vlc_configuration.h */&lt;br /&gt;
&lt;br /&gt;
    add_integer( &amp;quot;test-angle&amp;quot;, 1, &amp;quot;DVD Angle&amp;quot;, &amp;quot;Default DVD Angle&amp;quot;, false)&lt;br /&gt;
vlc_module_end ()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/*****************************************************************************&lt;br /&gt;
 * Open: initialize interface&lt;br /&gt;
 *****************************************************************************/&lt;br /&gt;
static int Open( vlc_object_t *p_this )&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/*****************************************************************************&lt;br /&gt;
 * Close: destroy interface&lt;br /&gt;
 *****************************************************************************/&lt;br /&gt;
static void Close( vlc_object_t *p_this )&lt;br /&gt;
{&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== How to write the module, aka Explanations about the empty module ==&lt;br /&gt;
&lt;br /&gt;
=== Module Descriptor  ===&lt;br /&gt;
&lt;br /&gt;
A {{VLC}} module &#039;&#039;&#039;must&#039;&#039;&#039; include a &#039;&#039;description&#039;&#039; of itself, and the &#039;&#039;parameters&#039;&#039; it accepts. &lt;br /&gt;
&lt;br /&gt;
The module descriptor begins with: &lt;br /&gt;
&amp;lt;pre&amp;gt;vlc_module_begin();&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
You should set some basic information about your module: &lt;br /&gt;
&amp;lt;pre&amp;gt;    set_shortname( _(&amp;quot;DVD without menus&amp;quot;) );&lt;br /&gt;
    set_description( _(&amp;quot;DVDRead Input&amp;quot;) );&lt;br /&gt;
    set_category( CAT_INPUT );&lt;br /&gt;
    set_subcategory( SUBCAT_INPUT_ACCESS );&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&#039;&#039;Note&#039;&#039; the use of _(&amp;quot;&amp;quot;) to create a string that needs to be translated. &lt;br /&gt;
&lt;br /&gt;
==== Capability and score ====&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The capability is key to the module loading&#039;&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
It defines the type of module we are dealing with, whether it is an access, a demux, a decoder or else... &lt;br /&gt;
&lt;br /&gt;
Now is the time to &#039;&#039;&#039;re-read [[Documentation:VLC Modules Loading#How_does_the_loading_of_modules_happens|how VLC loads modules]]&#039;&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*If VLC needs to load a specific name, it will load it by its name and VLC directly opens this module &lt;br /&gt;
*If VLC needs a type of modules (&amp;quot;I need a decoder&amp;quot;), VLC will load all modules matching this capability by decreasing score order until one modules&#039;s Open() function (see later) returns VLC_SUCCESS.&lt;br /&gt;
&lt;br /&gt;
See the major types of [[Documentation:VLC Modules Loading#Major_Capabilities_of_Modules|capabilities of VLC]]. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Score&#039;&#039;&#039; should be an integer, and related to other scores in the same category. Score 0 is a [[Documentation:VLC_Modules_Loading#Score_of_0|special case]].&lt;br /&gt;
&lt;br /&gt;
Definition &#039;&#039;&#039;Example&#039;&#039;&#039;: &lt;br /&gt;
&amp;lt;pre&amp;gt;   set_capability( &amp;quot;testing&amp;quot;, 10 )&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
This defines a module of &amp;quot;testing&amp;quot; capability and a score of 10.&lt;br /&gt;
&lt;br /&gt;
==== Configuration Categories and SubCategories  ====&lt;br /&gt;
&lt;br /&gt;
You should use &#039;&#039;&#039;one&#039;&#039;&#039; of the &#039;&#039;&#039;predefined categories&#039;&#039;&#039; for configuration. &lt;br /&gt;
&lt;br /&gt;
The Configuration Categories and Subcategories define &#039;&#039;&#039;where&#039;&#039;&#039; the module will appear in the &#039;&#039;&#039;preferences&#039;&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
The configuration categories include: &lt;br /&gt;
&lt;br /&gt;
*CAT_INTERFACE &lt;br /&gt;
*CAT_AUDIO &lt;br /&gt;
*CAT_VIDEO &lt;br /&gt;
*CAT_INPUT &lt;br /&gt;
*CAT_SOUT &lt;br /&gt;
*CAT_ADVANCED &lt;br /&gt;
*CAT_PLAYLIST&lt;br /&gt;
&lt;br /&gt;
You should use one of &#039;&#039;&#039;predefined sub-categories&#039;&#039;&#039; too. &lt;br /&gt;
&lt;br /&gt;
See {{VLCSourceFile|name=include/vlc_configuration.h}} for definition of all configuration categories and sub-categories. &lt;br /&gt;
&lt;br /&gt;
==== Configuration and Parameters Options  ====&lt;br /&gt;
&lt;br /&gt;
You will need options for your module. Defining new options is easy. &lt;br /&gt;
&lt;br /&gt;
All options definitions take the following argument list: &lt;br /&gt;
&amp;lt;pre&amp;gt; add_integer(name, value, text, longtext, advanced) &amp;lt;/pre&amp;gt; &lt;br /&gt;
*&#039;&#039;&#039;name&#039;&#039;&#039; is the string that identifies this parameter in the configuration. This name is used at the command prompt to set the configuration value. &lt;br /&gt;
*&#039;&#039;&#039;value&#039;&#039;&#039; is the default value for this parameter, &lt;br /&gt;
*&#039;&#039;&#039;text&#039;&#039;&#039; A short description of the parameter, use _(&amp;quot;&amp;quot;) to create a string that needs to be translated, &lt;br /&gt;
*&#039;&#039;&#039;longtext&#039;&#039;&#039; A complete description of the parameter, use _(&amp;quot;&amp;quot;) to create a string that needs to be translated,&lt;br /&gt;
*&#039;&#039;&#039;advanced&#039;&#039;&#039; Boolean, ADVanced Configuration. If TRUE, this parameter will only be displayed when using the --advanced flag. e.g.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt; You may add the following options/parameter types to your module: &lt;br /&gt;
&lt;br /&gt;
*add_integer, &lt;br /&gt;
*add_string, &lt;br /&gt;
*add_float, &lt;br /&gt;
*add_bool, &lt;br /&gt;
*add_key, &lt;br /&gt;
*add_file, &lt;br /&gt;
*add_directory,&lt;br /&gt;
&lt;br /&gt;
For complete definitions, see {{VLCSourceFile|name=include/vlc_plugin.h}}&lt;br /&gt;
&lt;br /&gt;
==== Callback  ====&lt;br /&gt;
&lt;br /&gt;
The opening and closing static functions, detailed afterwards, need to be defined in the descriptor, so VLC can discuss with the module.&lt;br /&gt;
&lt;br /&gt;
=== Open(vlc_object_t *)  ===&lt;br /&gt;
&lt;br /&gt;
The most important function of a module, is the opening: the usually-named Open() function. &lt;br /&gt;
&amp;lt;pre&amp;gt;static int  Open ( vlc_object_t * );&amp;lt;/pre&amp;gt; &lt;br /&gt;
The Open() function is called when the VLC core tries to open the module, and wants to load it. &lt;br /&gt;
&lt;br /&gt;
During Open(), setup of structures, devices or I/O, checks should be done. A working open should return VLC_SUCCESS. In all other cases, it will not be considered as loaded.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Open()&#039;&#039;&#039; function is expected to allocate private data (if any), and set up the private structure.&lt;br /&gt;
&lt;br /&gt;
If the Opening fails, you need to clean-up your own structures.&lt;br /&gt;
&lt;br /&gt;
=== Close(vlc_object_t *)  ===&lt;br /&gt;
The second most important function of a module, is the closing: the usually-named Close() function.&lt;br /&gt;
&amp;lt;pre&amp;gt;static int  Close ( vlc_object_t * );&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Close() function is called when the VLC core tries to close or unload an &#039;&#039;&#039;already-loaded&#039;&#039;&#039; module.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NB:&#039;&#039;&#039; If the Open() function failed, Close() will not get called.&lt;br /&gt;
&lt;br /&gt;
During Close(), close devices or I/O and cleaning of structures should be done. Do not leak memory here!&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Close()&#039;&#039;&#039; function should deallocate private data.&lt;br /&gt;
&lt;br /&gt;
== SubModules  ==&lt;br /&gt;
&lt;br /&gt;
Submodules, created in some modules with &lt;br /&gt;
&lt;br /&gt;
 add_submodule()&lt;br /&gt;
&lt;br /&gt;
work exactly the same way as modules. They are useful to parent modules, and to share code between modules.&lt;br /&gt;
&lt;br /&gt;
The submodules will be separated in the cache, and will be loaded by VLC in the exact same way as a module.&lt;br /&gt;
&lt;br /&gt;
== Modules types ==&lt;br /&gt;
&lt;br /&gt;
Depending on the module capability, you will need more information, about the necessary functions to implement.&lt;br /&gt;
&lt;br /&gt;
We will detail those here:&lt;br /&gt;
* [[Documentation:Hacker&#039;s_Guide/Access|Access]]&lt;br /&gt;
* [[Documentation:Hacker&#039;s_Guide/Demux|Demux]]&lt;br /&gt;
* [[Documentation:Hacker&#039;s_Guide/Access_Demux|Access_Demux]]&lt;br /&gt;
* Decoder&lt;br /&gt;
* Interface&lt;br /&gt;
* [[Documentation:Hacker&#039;s_Guide/Video_Filters|Video Filter]]&lt;br /&gt;
* [[Documentation:Hacker&#039;s_Guide/Audio_Filters|Audio Filter]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Documentation}} &lt;br /&gt;
&lt;br /&gt;
[[Category:Coding]]&lt;/div&gt;</summary>
		<author><name>Technologicat</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=Hacker_Guide/How_To_Write_a_Module&amp;diff=19146</id>
		<title>Hacker Guide/How To Write a Module</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=Hacker_Guide/How_To_Write_a_Module&amp;diff=19146"/>
		<updated>2011-05-16T13:26:27Z</updated>

		<summary type="html">&lt;p&gt;Technologicat: /* Troubleshooting */ note: bash&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction to modules writer guide ==&lt;br /&gt;
&lt;br /&gt;
VLC is based on many independent modules, like most multimedia frameworks. Each module introduces a new functionnality.&lt;br /&gt;
&lt;br /&gt;
You &#039;&#039;&#039;MUST&#039;&#039;&#039; &#039;&#039;&#039;read&#039;&#039;&#039; [[Documentation:Hacker%27s_Guide/Core#VLC_Pipeline_and_Modularity|VLC Core and Modules ]] and [[Documentation:VLC_Modules_Loading|How VLC loads modules]] &#039;&#039;&#039;before&#039;&#039;&#039; reading this howto.&lt;br /&gt;
&lt;br /&gt;
This is a description about how you can write a new module for VLC.&lt;br /&gt;
&lt;br /&gt;
== Git and Repository integration ==&lt;br /&gt;
&lt;br /&gt;
=== Git ===&lt;br /&gt;
If you plan to submit your work to VLC upstream, be sure to look at [[Git |the git introduction]] and check the [[Git#Submitting_patches_to_the_vlc-devel_or_x264-devel|send patches part]].&lt;br /&gt;
&lt;br /&gt;
=== Compiling your module ===&lt;br /&gt;
&lt;br /&gt;
==== Modules.am ====&lt;br /&gt;
First, find the right place under [[Modules_source_tree| modules/]] to add your new code.&lt;br /&gt;
&lt;br /&gt;
# If you are adding a one-file module to the repository, just add its sources to the Modules.am in the same folder.&lt;br /&gt;
# If you are adding a bigger modules to the repository:&lt;br /&gt;
#* create a new directory&lt;br /&gt;
#* create a new Modules.am, inside that directory.&lt;br /&gt;
#* Add a corresponding Makefile line at the end of configure.ac for this new Modules.am.&lt;br /&gt;
&lt;br /&gt;
For example, the file {{VLCSourceFile|name=modules/video_filter/Modules.am}} tells the build system which source files go into which video filter module.&lt;br /&gt;
&lt;br /&gt;
Note that the indentation in Modules.am uses a tab (ASCII 0x09), not spaces.&lt;br /&gt;
&lt;br /&gt;
==== configure.ac ====&lt;br /&gt;
&lt;br /&gt;
To have the module built, you need to use &#039;&#039;VLC_ADD_PLUGIN&#039;&#039; or &#039;&#039;PKG_ENABLE_MODULES_VLC&#039;&#039; inside the {{VLCSourceFile|name=configure.ac}} with your new module name as argument. Look at other modules for guidelines on how to add build and linkage options.&lt;br /&gt;
&lt;br /&gt;
After changing {{VLCSourceFile|name=configure.ac}}, you will always need to rerun &lt;br /&gt;
 ./bootstrap &amp;amp;&amp;amp; ./configure&lt;br /&gt;
&lt;br /&gt;
=== Troubleshooting ===&lt;br /&gt;
&lt;br /&gt;
Sometimes, it doesn&#039;t work, because of some libtool bug.&lt;br /&gt;
&lt;br /&gt;
You probably need to go to the root of your VLC source tree, and do something akin to the following. The examples here assume the &#039;&#039;bash&#039;&#039; shell.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Version 1&#039;&#039;&#039; (try this first)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;find . -name .deps -exec rm -rf \{\} \;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;./bootstrap&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;./configure&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The dangerous-looking recursive &#039;&#039;rm -rf&#039;&#039; deletes the dependency caches in the source tree.&lt;br /&gt;
&lt;br /&gt;
This ensures that the build system finds your new files. Then you can go on as usual:&lt;br /&gt;
&amp;lt;pre&amp;gt;./compile&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And finally:&lt;br /&gt;
&amp;lt;pre&amp;gt;./vlc --reset-plugins-cache&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Version 2&#039;&#039;&#039; (more extreme)&lt;br /&gt;
&lt;br /&gt;
If the above didn&#039;t help, you can use this more extreme version:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;find . -name .deps -exec rm -rf \{\} \;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;find . -name .libs -exec rm -rf \{\} \;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;./bootstrap&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;./configure&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;./compile&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;./vlc --reset-plugins-cache&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
...which also deletes library caches. Note that when you do this, you &#039;&#039;&#039;must&#039;&#039;&#039; run &#039;&#039;configure&#039;&#039; and not just &#039;&#039;config.status&#039;&#039;, because &#039;&#039;config.status&#039;&#039; runs configure in &#039;&#039;--no-create&#039;&#039; mode, which will not re-create the .libs caches.&lt;br /&gt;
&lt;br /&gt;
==== Out of Tree Compile ====&lt;br /&gt;
&lt;br /&gt;
If you need to compile just a module, please read [[OutOfTreeCompile|out of tree compilation]].&lt;br /&gt;
&lt;br /&gt;
=== Loading your module ===&lt;br /&gt;
&lt;br /&gt;
VLC keeps the cache of its modules (in ~/.cache/vlc/ on Linux), you&#039;ll have to delete it (or use vlc --reset-plugins-cache) so that your module gets loaded.&lt;br /&gt;
&lt;br /&gt;
Then use&lt;br /&gt;
 vlc -vvv --color --list&lt;br /&gt;
to check that your plugin is seen by {{VLC}}.&lt;br /&gt;
&lt;br /&gt;
You should also see it in the plugins dialog of the [[Qt interface]] (Linux and Windows).&lt;br /&gt;
&lt;br /&gt;
== Example of an empty module  ==&lt;br /&gt;
&lt;br /&gt;
We will start with a small example, so you can understand it better. &lt;br /&gt;
&amp;lt;pre&amp;gt;/*****************************************************************************&lt;br /&gt;
 * Preamble&lt;br /&gt;
 *****************************************************************************/&lt;br /&gt;
&lt;br /&gt;
#ifdef HAVE_CONFIG_H&lt;br /&gt;
# include &amp;quot;config.h&amp;quot;&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
#include &amp;amp;lt;vlc_common.h&amp;amp;gt;&lt;br /&gt;
#include &amp;amp;lt;vlc_plugin.h&amp;amp;gt;&lt;br /&gt;
&lt;br /&gt;
/*****************************************************************************&lt;br /&gt;
* Local prototypes.&lt;br /&gt;
*****************************************************************************/&lt;br /&gt;
&lt;br /&gt;
static int  Open           ( vlc_object_t * );&lt;br /&gt;
static void Close          ( vlc_object_t * );&lt;br /&gt;
&lt;br /&gt;
/*****************************************************************************&lt;br /&gt;
 * Module descriptor&lt;br /&gt;
 *****************************************************************************/&lt;br /&gt;
&lt;br /&gt;
vlc_module_begin()&lt;br /&gt;
    set_shortname( _(&amp;quot;testmodule&amp;quot;) )&lt;br /&gt;
    set_description( _(&amp;quot;testmodle plug-in&amp;quot;) )&lt;br /&gt;
    set_capability( &amp;quot;testing&amp;quot;, 0 )&lt;br /&gt;
    set_callbacks( Open, Close )&lt;br /&gt;
    set_category( CAT_INTERFACE ) /* choose relevant category, default categories in vlc/include/vlc_configuration.h */&lt;br /&gt;
&lt;br /&gt;
    add_integer( &amp;quot;test-angle&amp;quot;, 1, &amp;quot;DVD Angle&amp;quot;, &amp;quot;Default DVD Angle&amp;quot;, false)&lt;br /&gt;
vlc_module_end ()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/*****************************************************************************&lt;br /&gt;
 * Open: initialize interface&lt;br /&gt;
 *****************************************************************************/&lt;br /&gt;
static int Open( vlc_object_t *p_this )&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/*****************************************************************************&lt;br /&gt;
 * Close: destroy interface&lt;br /&gt;
 *****************************************************************************/&lt;br /&gt;
static void Close( vlc_object_t *p_this )&lt;br /&gt;
{&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== How to write the module, aka Explanations about the empty module ==&lt;br /&gt;
&lt;br /&gt;
=== Module Descriptor  ===&lt;br /&gt;
&lt;br /&gt;
A {{VLC}} module &#039;&#039;&#039;must&#039;&#039;&#039; include a &#039;&#039;description&#039;&#039; of itself, and the &#039;&#039;parameters&#039;&#039; it accepts. &lt;br /&gt;
&lt;br /&gt;
The module descriptor begins with: &lt;br /&gt;
&amp;lt;pre&amp;gt;vlc_module_begin();&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
You should set some basic information about your module: &lt;br /&gt;
&amp;lt;pre&amp;gt;    set_shortname( _(&amp;quot;DVD without menus&amp;quot;) );&lt;br /&gt;
    set_description( _(&amp;quot;DVDRead Input&amp;quot;) );&lt;br /&gt;
    set_category( CAT_INPUT );&lt;br /&gt;
    set_subcategory( SUBCAT_INPUT_ACCESS );&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&#039;&#039;Note&#039;&#039; the use of _(&amp;quot;&amp;quot;) to create a string that needs to be translated. &lt;br /&gt;
&lt;br /&gt;
==== Capability and score ====&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The capability is key to the module loading&#039;&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
It defines the type of module we are dealing with, whether it is an access, a demux, a decoder or else... &lt;br /&gt;
&lt;br /&gt;
Now is the time to &#039;&#039;&#039;re-read [[Documentation:VLC Modules Loading#How_does_the_loading_of_modules_happens|how VLC loads modules]]&#039;&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*If VLC needs to load a specific name, it will load it by its name and VLC directly opens this module &lt;br /&gt;
*If VLC needs a type of modules (&amp;quot;I need a decoder&amp;quot;), VLC will load all modules matching this capability by decreasing score order until one modules&#039;s Open() function (see later) returns VLC_SUCCESS.&lt;br /&gt;
&lt;br /&gt;
See the major types of [[Documentation:VLC Modules Loading#Major_Capabilities_of_Modules|capabilities of VLC]]. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Score&#039;&#039;&#039; should be an integer, and related to other scores in the same category. Score 0 is a [[Documentation:VLC_Modules_Loading#Score_of_0|special case]].&lt;br /&gt;
&lt;br /&gt;
Definition &#039;&#039;&#039;Example&#039;&#039;&#039;: &lt;br /&gt;
&amp;lt;pre&amp;gt;   set_capability( &amp;quot;testing&amp;quot;, 10 )&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
This defines a module of &amp;quot;testing&amp;quot; capability and a score of 10.&lt;br /&gt;
&lt;br /&gt;
==== Configuration Categories and SubCategories  ====&lt;br /&gt;
&lt;br /&gt;
You should use &#039;&#039;&#039;one&#039;&#039;&#039; of the &#039;&#039;&#039;predefined categories&#039;&#039;&#039; for configuration. &lt;br /&gt;
&lt;br /&gt;
The Configuration Categories and Subcategories define &#039;&#039;&#039;where&#039;&#039;&#039; the module will appear in the &#039;&#039;&#039;preferences&#039;&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
The configuration categories include: &lt;br /&gt;
&lt;br /&gt;
*CAT_INTERFACE &lt;br /&gt;
*CAT_AUDIO &lt;br /&gt;
*CAT_VIDEO &lt;br /&gt;
*CAT_INPUT &lt;br /&gt;
*CAT_SOUT &lt;br /&gt;
*CAT_ADVANCED &lt;br /&gt;
*CAT_PLAYLIST&lt;br /&gt;
&lt;br /&gt;
You should use one of &#039;&#039;&#039;predefined sub-categories&#039;&#039;&#039; too. &lt;br /&gt;
&lt;br /&gt;
See {{VLCSourceFile|name=include/vlc_configuration.h}} for definition of all configuration categories and sub-categories. &lt;br /&gt;
&lt;br /&gt;
==== Configuration and Parameters Options  ====&lt;br /&gt;
&lt;br /&gt;
You will need options for your module. Defining new options is easy. &lt;br /&gt;
&lt;br /&gt;
All options definitions take the following argument list: &lt;br /&gt;
&amp;lt;pre&amp;gt; add_integer(name, value, text, longtext, advanced) &amp;lt;/pre&amp;gt; &lt;br /&gt;
*&#039;&#039;&#039;name&#039;&#039;&#039; is the string that identifies this parameter in the configuration. This name is used at the command prompt to set the configuration value. &lt;br /&gt;
*&#039;&#039;&#039;value&#039;&#039;&#039; is the default value for this parameter, &lt;br /&gt;
*&#039;&#039;&#039;text&#039;&#039;&#039; A short description of the parameter, use _(&amp;quot;&amp;quot;) to create a string that needs to be translated, &lt;br /&gt;
*&#039;&#039;&#039;longtext&#039;&#039;&#039; A complete description of the parameter, use _(&amp;quot;&amp;quot;) to create a string that needs to be translated,&lt;br /&gt;
*&#039;&#039;&#039;advanced&#039;&#039;&#039; Boolean, ADVanced Configuration. If TRUE, this parameter will only be displayed when using the --advanced flag. e.g.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt; You may add the following options/parameter types to your module: &lt;br /&gt;
&lt;br /&gt;
*add_integer, &lt;br /&gt;
*add_string, &lt;br /&gt;
*add_float, &lt;br /&gt;
*add_bool, &lt;br /&gt;
*add_key, &lt;br /&gt;
*add_file, &lt;br /&gt;
*add_directory,&lt;br /&gt;
&lt;br /&gt;
For complete definitions, see {{VLCSourceFile|name=include/vlc_plugin.h}}&lt;br /&gt;
&lt;br /&gt;
==== Callback  ====&lt;br /&gt;
&lt;br /&gt;
The opening and closing static functions, detailed afterwards, need to be defined in the descriptor, so VLC can discuss with the module.&lt;br /&gt;
&lt;br /&gt;
=== Open(vlc_object_t *)  ===&lt;br /&gt;
&lt;br /&gt;
The most important function of a module, is the opening: the usually-named Open() function. &lt;br /&gt;
&amp;lt;pre&amp;gt;static int  Open ( vlc_object_t * );&amp;lt;/pre&amp;gt; &lt;br /&gt;
The Open() function is called when the VLC core tries to open the module, and wants to load it. &lt;br /&gt;
&lt;br /&gt;
During Open(), setup of structures, devices or I/O, checks should be done. A working open should return VLC_SUCCESS. In all other cases, it will not be considered as loaded.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Open()&#039;&#039;&#039; function is expected to allocate private data (if any), and set up the private structure.&lt;br /&gt;
&lt;br /&gt;
If the Opening fails, you need to clean-up your own structures.&lt;br /&gt;
&lt;br /&gt;
=== Close(vlc_object_t *)  ===&lt;br /&gt;
The second most important function of a module, is the closing: the usually-named Close() function.&lt;br /&gt;
&amp;lt;pre&amp;gt;static int  Close ( vlc_object_t * );&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Close() function is called when the VLC core tries to close or unload an &#039;&#039;&#039;already-loaded&#039;&#039;&#039; module.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NB:&#039;&#039;&#039; If the Open() function failed, Close() will not get called.&lt;br /&gt;
&lt;br /&gt;
During Close(), close devices or I/O and cleaning of structures should be done. Do not leak memory here!&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Close()&#039;&#039;&#039; function should deallocate private data.&lt;br /&gt;
&lt;br /&gt;
== SubModules  ==&lt;br /&gt;
&lt;br /&gt;
Submodules, created in some modules with &lt;br /&gt;
&lt;br /&gt;
 add_submodule()&lt;br /&gt;
&lt;br /&gt;
work exactly the same way as modules. They are useful to parent modules, and to share code between modules.&lt;br /&gt;
&lt;br /&gt;
The submodules will be separated in the cache, and will be loaded by VLC in the exact same way as a module.&lt;br /&gt;
&lt;br /&gt;
== Modules types ==&lt;br /&gt;
&lt;br /&gt;
Depending on the module capability, you will need more information, about the necessary functions to implement.&lt;br /&gt;
&lt;br /&gt;
We will detail those here:&lt;br /&gt;
* [[Documentation:Hacker&#039;s_Guide/Access|Access]]&lt;br /&gt;
* [[Documentation:Hacker&#039;s_Guide/Demux|Demux]]&lt;br /&gt;
* [[Documentation:Hacker&#039;s_Guide/Access_Demux|Access_Demux]]&lt;br /&gt;
* Decoder&lt;br /&gt;
* Interface&lt;br /&gt;
* [[Documentation:Hacker&#039;s_Guide/Video_Filters|Video Filter]]&lt;br /&gt;
* [[Documentation:Hacker&#039;s_Guide/Audio_Filters|Audio Filter]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Documentation}} &lt;br /&gt;
&lt;br /&gt;
[[Category:Coding]]&lt;/div&gt;</summary>
		<author><name>Technologicat</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=Hacker_Guide/How_To_Write_a_Module&amp;diff=19145</id>
		<title>Hacker Guide/How To Write a Module</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=Hacker_Guide/How_To_Write_a_Module&amp;diff=19145"/>
		<updated>2011-05-16T13:25:48Z</updated>

		<summary type="html">&lt;p&gt;Technologicat: /* Troubleshooting */ Added moar extreme version as alternative (delete .libs caches too; I needed this once)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction to modules writer guide ==&lt;br /&gt;
&lt;br /&gt;
VLC is based on many independent modules, like most multimedia frameworks. Each module introduces a new functionnality.&lt;br /&gt;
&lt;br /&gt;
You &#039;&#039;&#039;MUST&#039;&#039;&#039; &#039;&#039;&#039;read&#039;&#039;&#039; [[Documentation:Hacker%27s_Guide/Core#VLC_Pipeline_and_Modularity|VLC Core and Modules ]] and [[Documentation:VLC_Modules_Loading|How VLC loads modules]] &#039;&#039;&#039;before&#039;&#039;&#039; reading this howto.&lt;br /&gt;
&lt;br /&gt;
This is a description about how you can write a new module for VLC.&lt;br /&gt;
&lt;br /&gt;
== Git and Repository integration ==&lt;br /&gt;
&lt;br /&gt;
=== Git ===&lt;br /&gt;
If you plan to submit your work to VLC upstream, be sure to look at [[Git |the git introduction]] and check the [[Git#Submitting_patches_to_the_vlc-devel_or_x264-devel|send patches part]].&lt;br /&gt;
&lt;br /&gt;
=== Compiling your module ===&lt;br /&gt;
&lt;br /&gt;
==== Modules.am ====&lt;br /&gt;
First, find the right place under [[Modules_source_tree| modules/]] to add your new code.&lt;br /&gt;
&lt;br /&gt;
# If you are adding a one-file module to the repository, just add its sources to the Modules.am in the same folder.&lt;br /&gt;
# If you are adding a bigger modules to the repository:&lt;br /&gt;
#* create a new directory&lt;br /&gt;
#* create a new Modules.am, inside that directory.&lt;br /&gt;
#* Add a corresponding Makefile line at the end of configure.ac for this new Modules.am.&lt;br /&gt;
&lt;br /&gt;
For example, the file {{VLCSourceFile|name=modules/video_filter/Modules.am}} tells the build system which source files go into which video filter module.&lt;br /&gt;
&lt;br /&gt;
Note that the indentation in Modules.am uses a tab (ASCII 0x09), not spaces.&lt;br /&gt;
&lt;br /&gt;
==== configure.ac ====&lt;br /&gt;
&lt;br /&gt;
To have the module built, you need to use &#039;&#039;VLC_ADD_PLUGIN&#039;&#039; or &#039;&#039;PKG_ENABLE_MODULES_VLC&#039;&#039; inside the {{VLCSourceFile|name=configure.ac}} with your new module name as argument. Look at other modules for guidelines on how to add build and linkage options.&lt;br /&gt;
&lt;br /&gt;
After changing {{VLCSourceFile|name=configure.ac}}, you will always need to rerun &lt;br /&gt;
 ./bootstrap &amp;amp;&amp;amp; ./configure&lt;br /&gt;
&lt;br /&gt;
=== Troubleshooting ===&lt;br /&gt;
&lt;br /&gt;
Sometimes, it doesn&#039;t work, because of some libtool bug.&lt;br /&gt;
&lt;br /&gt;
You probably need to go to the root of your VLC source tree, and do something akin to the following.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Version 1&#039;&#039;&#039; (try this first)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;find . -name .deps -exec rm -rf \{\} \;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;./bootstrap&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;./configure&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The dangerous-looking recursive &#039;&#039;rm -rf&#039;&#039; deletes the dependency caches in the source tree.&lt;br /&gt;
&lt;br /&gt;
This ensures that the build system finds your new files. Then you can go on as usual:&lt;br /&gt;
&amp;lt;pre&amp;gt;./compile&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And finally:&lt;br /&gt;
&amp;lt;pre&amp;gt;./vlc --reset-plugins-cache&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Version 2&#039;&#039;&#039; (more extreme)&lt;br /&gt;
&lt;br /&gt;
If the above didn&#039;t help, you can use this more extreme version:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;find . -name .deps -exec rm -rf \{\} \;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;find . -name .libs -exec rm -rf \{\} \;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;./bootstrap&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;./configure&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;./compile&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;./vlc --reset-plugins-cache&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
...which also deletes library caches. Note that when you do this, you &#039;&#039;&#039;must&#039;&#039;&#039; run &#039;&#039;configure&#039;&#039; and not just &#039;&#039;config.status&#039;&#039;, because &#039;&#039;config.status&#039;&#039; runs configure in &#039;&#039;--no-create&#039;&#039; mode, which will not re-create the .libs caches.&lt;br /&gt;
&lt;br /&gt;
==== Out of Tree Compile ====&lt;br /&gt;
&lt;br /&gt;
If you need to compile just a module, please read [[OutOfTreeCompile|out of tree compilation]].&lt;br /&gt;
&lt;br /&gt;
=== Loading your module ===&lt;br /&gt;
&lt;br /&gt;
VLC keeps the cache of its modules (in ~/.cache/vlc/ on Linux), you&#039;ll have to delete it (or use vlc --reset-plugins-cache) so that your module gets loaded.&lt;br /&gt;
&lt;br /&gt;
Then use&lt;br /&gt;
 vlc -vvv --color --list&lt;br /&gt;
to check that your plugin is seen by {{VLC}}.&lt;br /&gt;
&lt;br /&gt;
You should also see it in the plugins dialog of the [[Qt interface]] (Linux and Windows).&lt;br /&gt;
&lt;br /&gt;
== Example of an empty module  ==&lt;br /&gt;
&lt;br /&gt;
We will start with a small example, so you can understand it better. &lt;br /&gt;
&amp;lt;pre&amp;gt;/*****************************************************************************&lt;br /&gt;
 * Preamble&lt;br /&gt;
 *****************************************************************************/&lt;br /&gt;
&lt;br /&gt;
#ifdef HAVE_CONFIG_H&lt;br /&gt;
# include &amp;quot;config.h&amp;quot;&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
#include &amp;amp;lt;vlc_common.h&amp;amp;gt;&lt;br /&gt;
#include &amp;amp;lt;vlc_plugin.h&amp;amp;gt;&lt;br /&gt;
&lt;br /&gt;
/*****************************************************************************&lt;br /&gt;
* Local prototypes.&lt;br /&gt;
*****************************************************************************/&lt;br /&gt;
&lt;br /&gt;
static int  Open           ( vlc_object_t * );&lt;br /&gt;
static void Close          ( vlc_object_t * );&lt;br /&gt;
&lt;br /&gt;
/*****************************************************************************&lt;br /&gt;
 * Module descriptor&lt;br /&gt;
 *****************************************************************************/&lt;br /&gt;
&lt;br /&gt;
vlc_module_begin()&lt;br /&gt;
    set_shortname( _(&amp;quot;testmodule&amp;quot;) )&lt;br /&gt;
    set_description( _(&amp;quot;testmodle plug-in&amp;quot;) )&lt;br /&gt;
    set_capability( &amp;quot;testing&amp;quot;, 0 )&lt;br /&gt;
    set_callbacks( Open, Close )&lt;br /&gt;
    set_category( CAT_INTERFACE ) /* choose relevant category, default categories in vlc/include/vlc_configuration.h */&lt;br /&gt;
&lt;br /&gt;
    add_integer( &amp;quot;test-angle&amp;quot;, 1, &amp;quot;DVD Angle&amp;quot;, &amp;quot;Default DVD Angle&amp;quot;, false)&lt;br /&gt;
vlc_module_end ()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/*****************************************************************************&lt;br /&gt;
 * Open: initialize interface&lt;br /&gt;
 *****************************************************************************/&lt;br /&gt;
static int Open( vlc_object_t *p_this )&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/*****************************************************************************&lt;br /&gt;
 * Close: destroy interface&lt;br /&gt;
 *****************************************************************************/&lt;br /&gt;
static void Close( vlc_object_t *p_this )&lt;br /&gt;
{&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== How to write the module, aka Explanations about the empty module ==&lt;br /&gt;
&lt;br /&gt;
=== Module Descriptor  ===&lt;br /&gt;
&lt;br /&gt;
A {{VLC}} module &#039;&#039;&#039;must&#039;&#039;&#039; include a &#039;&#039;description&#039;&#039; of itself, and the &#039;&#039;parameters&#039;&#039; it accepts. &lt;br /&gt;
&lt;br /&gt;
The module descriptor begins with: &lt;br /&gt;
&amp;lt;pre&amp;gt;vlc_module_begin();&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
You should set some basic information about your module: &lt;br /&gt;
&amp;lt;pre&amp;gt;    set_shortname( _(&amp;quot;DVD without menus&amp;quot;) );&lt;br /&gt;
    set_description( _(&amp;quot;DVDRead Input&amp;quot;) );&lt;br /&gt;
    set_category( CAT_INPUT );&lt;br /&gt;
    set_subcategory( SUBCAT_INPUT_ACCESS );&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&#039;&#039;Note&#039;&#039; the use of _(&amp;quot;&amp;quot;) to create a string that needs to be translated. &lt;br /&gt;
&lt;br /&gt;
==== Capability and score ====&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The capability is key to the module loading&#039;&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
It defines the type of module we are dealing with, whether it is an access, a demux, a decoder or else... &lt;br /&gt;
&lt;br /&gt;
Now is the time to &#039;&#039;&#039;re-read [[Documentation:VLC Modules Loading#How_does_the_loading_of_modules_happens|how VLC loads modules]]&#039;&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*If VLC needs to load a specific name, it will load it by its name and VLC directly opens this module &lt;br /&gt;
*If VLC needs a type of modules (&amp;quot;I need a decoder&amp;quot;), VLC will load all modules matching this capability by decreasing score order until one modules&#039;s Open() function (see later) returns VLC_SUCCESS.&lt;br /&gt;
&lt;br /&gt;
See the major types of [[Documentation:VLC Modules Loading#Major_Capabilities_of_Modules|capabilities of VLC]]. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Score&#039;&#039;&#039; should be an integer, and related to other scores in the same category. Score 0 is a [[Documentation:VLC_Modules_Loading#Score_of_0|special case]].&lt;br /&gt;
&lt;br /&gt;
Definition &#039;&#039;&#039;Example&#039;&#039;&#039;: &lt;br /&gt;
&amp;lt;pre&amp;gt;   set_capability( &amp;quot;testing&amp;quot;, 10 )&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
This defines a module of &amp;quot;testing&amp;quot; capability and a score of 10.&lt;br /&gt;
&lt;br /&gt;
==== Configuration Categories and SubCategories  ====&lt;br /&gt;
&lt;br /&gt;
You should use &#039;&#039;&#039;one&#039;&#039;&#039; of the &#039;&#039;&#039;predefined categories&#039;&#039;&#039; for configuration. &lt;br /&gt;
&lt;br /&gt;
The Configuration Categories and Subcategories define &#039;&#039;&#039;where&#039;&#039;&#039; the module will appear in the &#039;&#039;&#039;preferences&#039;&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
The configuration categories include: &lt;br /&gt;
&lt;br /&gt;
*CAT_INTERFACE &lt;br /&gt;
*CAT_AUDIO &lt;br /&gt;
*CAT_VIDEO &lt;br /&gt;
*CAT_INPUT &lt;br /&gt;
*CAT_SOUT &lt;br /&gt;
*CAT_ADVANCED &lt;br /&gt;
*CAT_PLAYLIST&lt;br /&gt;
&lt;br /&gt;
You should use one of &#039;&#039;&#039;predefined sub-categories&#039;&#039;&#039; too. &lt;br /&gt;
&lt;br /&gt;
See {{VLCSourceFile|name=include/vlc_configuration.h}} for definition of all configuration categories and sub-categories. &lt;br /&gt;
&lt;br /&gt;
==== Configuration and Parameters Options  ====&lt;br /&gt;
&lt;br /&gt;
You will need options for your module. Defining new options is easy. &lt;br /&gt;
&lt;br /&gt;
All options definitions take the following argument list: &lt;br /&gt;
&amp;lt;pre&amp;gt; add_integer(name, value, text, longtext, advanced) &amp;lt;/pre&amp;gt; &lt;br /&gt;
*&#039;&#039;&#039;name&#039;&#039;&#039; is the string that identifies this parameter in the configuration. This name is used at the command prompt to set the configuration value. &lt;br /&gt;
*&#039;&#039;&#039;value&#039;&#039;&#039; is the default value for this parameter, &lt;br /&gt;
*&#039;&#039;&#039;text&#039;&#039;&#039; A short description of the parameter, use _(&amp;quot;&amp;quot;) to create a string that needs to be translated, &lt;br /&gt;
*&#039;&#039;&#039;longtext&#039;&#039;&#039; A complete description of the parameter, use _(&amp;quot;&amp;quot;) to create a string that needs to be translated,&lt;br /&gt;
*&#039;&#039;&#039;advanced&#039;&#039;&#039; Boolean, ADVanced Configuration. If TRUE, this parameter will only be displayed when using the --advanced flag. e.g.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt; You may add the following options/parameter types to your module: &lt;br /&gt;
&lt;br /&gt;
*add_integer, &lt;br /&gt;
*add_string, &lt;br /&gt;
*add_float, &lt;br /&gt;
*add_bool, &lt;br /&gt;
*add_key, &lt;br /&gt;
*add_file, &lt;br /&gt;
*add_directory,&lt;br /&gt;
&lt;br /&gt;
For complete definitions, see {{VLCSourceFile|name=include/vlc_plugin.h}}&lt;br /&gt;
&lt;br /&gt;
==== Callback  ====&lt;br /&gt;
&lt;br /&gt;
The opening and closing static functions, detailed afterwards, need to be defined in the descriptor, so VLC can discuss with the module.&lt;br /&gt;
&lt;br /&gt;
=== Open(vlc_object_t *)  ===&lt;br /&gt;
&lt;br /&gt;
The most important function of a module, is the opening: the usually-named Open() function. &lt;br /&gt;
&amp;lt;pre&amp;gt;static int  Open ( vlc_object_t * );&amp;lt;/pre&amp;gt; &lt;br /&gt;
The Open() function is called when the VLC core tries to open the module, and wants to load it. &lt;br /&gt;
&lt;br /&gt;
During Open(), setup of structures, devices or I/O, checks should be done. A working open should return VLC_SUCCESS. In all other cases, it will not be considered as loaded.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Open()&#039;&#039;&#039; function is expected to allocate private data (if any), and set up the private structure.&lt;br /&gt;
&lt;br /&gt;
If the Opening fails, you need to clean-up your own structures.&lt;br /&gt;
&lt;br /&gt;
=== Close(vlc_object_t *)  ===&lt;br /&gt;
The second most important function of a module, is the closing: the usually-named Close() function.&lt;br /&gt;
&amp;lt;pre&amp;gt;static int  Close ( vlc_object_t * );&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Close() function is called when the VLC core tries to close or unload an &#039;&#039;&#039;already-loaded&#039;&#039;&#039; module.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NB:&#039;&#039;&#039; If the Open() function failed, Close() will not get called.&lt;br /&gt;
&lt;br /&gt;
During Close(), close devices or I/O and cleaning of structures should be done. Do not leak memory here!&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Close()&#039;&#039;&#039; function should deallocate private data.&lt;br /&gt;
&lt;br /&gt;
== SubModules  ==&lt;br /&gt;
&lt;br /&gt;
Submodules, created in some modules with &lt;br /&gt;
&lt;br /&gt;
 add_submodule()&lt;br /&gt;
&lt;br /&gt;
work exactly the same way as modules. They are useful to parent modules, and to share code between modules.&lt;br /&gt;
&lt;br /&gt;
The submodules will be separated in the cache, and will be loaded by VLC in the exact same way as a module.&lt;br /&gt;
&lt;br /&gt;
== Modules types ==&lt;br /&gt;
&lt;br /&gt;
Depending on the module capability, you will need more information, about the necessary functions to implement.&lt;br /&gt;
&lt;br /&gt;
We will detail those here:&lt;br /&gt;
* [[Documentation:Hacker&#039;s_Guide/Access|Access]]&lt;br /&gt;
* [[Documentation:Hacker&#039;s_Guide/Demux|Demux]]&lt;br /&gt;
* [[Documentation:Hacker&#039;s_Guide/Access_Demux|Access_Demux]]&lt;br /&gt;
* Decoder&lt;br /&gt;
* Interface&lt;br /&gt;
* [[Documentation:Hacker&#039;s_Guide/Video_Filters|Video Filter]]&lt;br /&gt;
* [[Documentation:Hacker&#039;s_Guide/Audio_Filters|Audio Filter]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Documentation}} &lt;br /&gt;
&lt;br /&gt;
[[Category:Coding]]&lt;/div&gt;</summary>
		<author><name>Technologicat</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=Hacker_Guide/How_To_Write_a_Module&amp;diff=19144</id>
		<title>Hacker Guide/How To Write a Module</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=Hacker_Guide/How_To_Write_a_Module&amp;diff=19144"/>
		<updated>2011-05-16T13:18:28Z</updated>

		<summary type="html">&lt;p&gt;Technologicat: /* Troubleshooting */ removed bullet points from pre items to be consistent with the rest of the page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction to modules writer guide ==&lt;br /&gt;
&lt;br /&gt;
VLC is based on many independent modules, like most multimedia frameworks. Each module introduces a new functionnality.&lt;br /&gt;
&lt;br /&gt;
You &#039;&#039;&#039;MUST&#039;&#039;&#039; &#039;&#039;&#039;read&#039;&#039;&#039; [[Documentation:Hacker%27s_Guide/Core#VLC_Pipeline_and_Modularity|VLC Core and Modules ]] and [[Documentation:VLC_Modules_Loading|How VLC loads modules]] &#039;&#039;&#039;before&#039;&#039;&#039; reading this howto.&lt;br /&gt;
&lt;br /&gt;
This is a description about how you can write a new module for VLC.&lt;br /&gt;
&lt;br /&gt;
== Git and Repository integration ==&lt;br /&gt;
&lt;br /&gt;
=== Git ===&lt;br /&gt;
If you plan to submit your work to VLC upstream, be sure to look at [[Git |the git introduction]] and check the [[Git#Submitting_patches_to_the_vlc-devel_or_x264-devel|send patches part]].&lt;br /&gt;
&lt;br /&gt;
=== Compiling your module ===&lt;br /&gt;
&lt;br /&gt;
==== Modules.am ====&lt;br /&gt;
First, find the right place under [[Modules_source_tree| modules/]] to add your new code.&lt;br /&gt;
&lt;br /&gt;
# If you are adding a one-file module to the repository, just add its sources to the Modules.am in the same folder.&lt;br /&gt;
# If you are adding a bigger modules to the repository:&lt;br /&gt;
#* create a new directory&lt;br /&gt;
#* create a new Modules.am, inside that directory.&lt;br /&gt;
#* Add a corresponding Makefile line at the end of configure.ac for this new Modules.am.&lt;br /&gt;
&lt;br /&gt;
For example, the file {{VLCSourceFile|name=modules/video_filter/Modules.am}} tells the build system which source files go into which video filter module.&lt;br /&gt;
&lt;br /&gt;
Note that the indentation in Modules.am uses a tab (ASCII 0x09), not spaces.&lt;br /&gt;
&lt;br /&gt;
==== configure.ac ====&lt;br /&gt;
&lt;br /&gt;
To have the module built, you need to use &#039;&#039;VLC_ADD_PLUGIN&#039;&#039; or &#039;&#039;PKG_ENABLE_MODULES_VLC&#039;&#039; inside the {{VLCSourceFile|name=configure.ac}} with your new module name as argument. Look at other modules for guidelines on how to add build and linkage options.&lt;br /&gt;
&lt;br /&gt;
After changing {{VLCSourceFile|name=configure.ac}}, you will always need to rerun &lt;br /&gt;
 ./bootstrap &amp;amp;&amp;amp; ./configure&lt;br /&gt;
&lt;br /&gt;
=== Troubleshooting ===&lt;br /&gt;
&lt;br /&gt;
Sometimes, it doesn&#039;t work, because of some libtool bug.&lt;br /&gt;
&lt;br /&gt;
You probably need to go to the root of your VLC source tree, and do something akin to the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;find . -name .deps -exec rm -rf \{\} \;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;./bootstrap&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;./configure&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This ensures that the build system finds your new files. Then you can go on as usual:&lt;br /&gt;
&amp;lt;pre&amp;gt;./compile&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Out of Tree Compile ====&lt;br /&gt;
&lt;br /&gt;
If you need to compile just a module, please read [[OutOfTreeCompile|out of tree compilation]].&lt;br /&gt;
&lt;br /&gt;
=== Loading your module ===&lt;br /&gt;
&lt;br /&gt;
VLC keeps the cache of its modules (in ~/.cache/vlc/ on Linux), you&#039;ll have to delete it (or use vlc --reset-plugins-cache) so that your module gets loaded.&lt;br /&gt;
&lt;br /&gt;
Then use&lt;br /&gt;
 vlc -vvv --color --list&lt;br /&gt;
to check that your plugin is seen by {{VLC}}.&lt;br /&gt;
&lt;br /&gt;
You should also see it in the plugins dialog of the [[Qt interface]] (Linux and Windows).&lt;br /&gt;
&lt;br /&gt;
== Example of an empty module  ==&lt;br /&gt;
&lt;br /&gt;
We will start with a small example, so you can understand it better. &lt;br /&gt;
&amp;lt;pre&amp;gt;/*****************************************************************************&lt;br /&gt;
 * Preamble&lt;br /&gt;
 *****************************************************************************/&lt;br /&gt;
&lt;br /&gt;
#ifdef HAVE_CONFIG_H&lt;br /&gt;
# include &amp;quot;config.h&amp;quot;&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
#include &amp;amp;lt;vlc_common.h&amp;amp;gt;&lt;br /&gt;
#include &amp;amp;lt;vlc_plugin.h&amp;amp;gt;&lt;br /&gt;
&lt;br /&gt;
/*****************************************************************************&lt;br /&gt;
* Local prototypes.&lt;br /&gt;
*****************************************************************************/&lt;br /&gt;
&lt;br /&gt;
static int  Open           ( vlc_object_t * );&lt;br /&gt;
static void Close          ( vlc_object_t * );&lt;br /&gt;
&lt;br /&gt;
/*****************************************************************************&lt;br /&gt;
 * Module descriptor&lt;br /&gt;
 *****************************************************************************/&lt;br /&gt;
&lt;br /&gt;
vlc_module_begin()&lt;br /&gt;
    set_shortname( _(&amp;quot;testmodule&amp;quot;) )&lt;br /&gt;
    set_description( _(&amp;quot;testmodle plug-in&amp;quot;) )&lt;br /&gt;
    set_capability( &amp;quot;testing&amp;quot;, 0 )&lt;br /&gt;
    set_callbacks( Open, Close )&lt;br /&gt;
    set_category( CAT_INTERFACE ) /* choose relevant category, default categories in vlc/include/vlc_configuration.h */&lt;br /&gt;
&lt;br /&gt;
    add_integer( &amp;quot;test-angle&amp;quot;, 1, &amp;quot;DVD Angle&amp;quot;, &amp;quot;Default DVD Angle&amp;quot;, false)&lt;br /&gt;
vlc_module_end ()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/*****************************************************************************&lt;br /&gt;
 * Open: initialize interface&lt;br /&gt;
 *****************************************************************************/&lt;br /&gt;
static int Open( vlc_object_t *p_this )&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/*****************************************************************************&lt;br /&gt;
 * Close: destroy interface&lt;br /&gt;
 *****************************************************************************/&lt;br /&gt;
static void Close( vlc_object_t *p_this )&lt;br /&gt;
{&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== How to write the module, aka Explanations about the empty module ==&lt;br /&gt;
&lt;br /&gt;
=== Module Descriptor  ===&lt;br /&gt;
&lt;br /&gt;
A {{VLC}} module &#039;&#039;&#039;must&#039;&#039;&#039; include a &#039;&#039;description&#039;&#039; of itself, and the &#039;&#039;parameters&#039;&#039; it accepts. &lt;br /&gt;
&lt;br /&gt;
The module descriptor begins with: &lt;br /&gt;
&amp;lt;pre&amp;gt;vlc_module_begin();&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
You should set some basic information about your module: &lt;br /&gt;
&amp;lt;pre&amp;gt;    set_shortname( _(&amp;quot;DVD without menus&amp;quot;) );&lt;br /&gt;
    set_description( _(&amp;quot;DVDRead Input&amp;quot;) );&lt;br /&gt;
    set_category( CAT_INPUT );&lt;br /&gt;
    set_subcategory( SUBCAT_INPUT_ACCESS );&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&#039;&#039;Note&#039;&#039; the use of _(&amp;quot;&amp;quot;) to create a string that needs to be translated. &lt;br /&gt;
&lt;br /&gt;
==== Capability and score ====&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The capability is key to the module loading&#039;&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
It defines the type of module we are dealing with, whether it is an access, a demux, a decoder or else... &lt;br /&gt;
&lt;br /&gt;
Now is the time to &#039;&#039;&#039;re-read [[Documentation:VLC Modules Loading#How_does_the_loading_of_modules_happens|how VLC loads modules]]&#039;&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*If VLC needs to load a specific name, it will load it by its name and VLC directly opens this module &lt;br /&gt;
*If VLC needs a type of modules (&amp;quot;I need a decoder&amp;quot;), VLC will load all modules matching this capability by decreasing score order until one modules&#039;s Open() function (see later) returns VLC_SUCCESS.&lt;br /&gt;
&lt;br /&gt;
See the major types of [[Documentation:VLC Modules Loading#Major_Capabilities_of_Modules|capabilities of VLC]]. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Score&#039;&#039;&#039; should be an integer, and related to other scores in the same category. Score 0 is a [[Documentation:VLC_Modules_Loading#Score_of_0|special case]].&lt;br /&gt;
&lt;br /&gt;
Definition &#039;&#039;&#039;Example&#039;&#039;&#039;: &lt;br /&gt;
&amp;lt;pre&amp;gt;   set_capability( &amp;quot;testing&amp;quot;, 10 )&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
This defines a module of &amp;quot;testing&amp;quot; capability and a score of 10.&lt;br /&gt;
&lt;br /&gt;
==== Configuration Categories and SubCategories  ====&lt;br /&gt;
&lt;br /&gt;
You should use &#039;&#039;&#039;one&#039;&#039;&#039; of the &#039;&#039;&#039;predefined categories&#039;&#039;&#039; for configuration. &lt;br /&gt;
&lt;br /&gt;
The Configuration Categories and Subcategories define &#039;&#039;&#039;where&#039;&#039;&#039; the module will appear in the &#039;&#039;&#039;preferences&#039;&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
The configuration categories include: &lt;br /&gt;
&lt;br /&gt;
*CAT_INTERFACE &lt;br /&gt;
*CAT_AUDIO &lt;br /&gt;
*CAT_VIDEO &lt;br /&gt;
*CAT_INPUT &lt;br /&gt;
*CAT_SOUT &lt;br /&gt;
*CAT_ADVANCED &lt;br /&gt;
*CAT_PLAYLIST&lt;br /&gt;
&lt;br /&gt;
You should use one of &#039;&#039;&#039;predefined sub-categories&#039;&#039;&#039; too. &lt;br /&gt;
&lt;br /&gt;
See {{VLCSourceFile|name=include/vlc_configuration.h}} for definition of all configuration categories and sub-categories. &lt;br /&gt;
&lt;br /&gt;
==== Configuration and Parameters Options  ====&lt;br /&gt;
&lt;br /&gt;
You will need options for your module. Defining new options is easy. &lt;br /&gt;
&lt;br /&gt;
All options definitions take the following argument list: &lt;br /&gt;
&amp;lt;pre&amp;gt; add_integer(name, value, text, longtext, advanced) &amp;lt;/pre&amp;gt; &lt;br /&gt;
*&#039;&#039;&#039;name&#039;&#039;&#039; is the string that identifies this parameter in the configuration. This name is used at the command prompt to set the configuration value. &lt;br /&gt;
*&#039;&#039;&#039;value&#039;&#039;&#039; is the default value for this parameter, &lt;br /&gt;
*&#039;&#039;&#039;text&#039;&#039;&#039; A short description of the parameter, use _(&amp;quot;&amp;quot;) to create a string that needs to be translated, &lt;br /&gt;
*&#039;&#039;&#039;longtext&#039;&#039;&#039; A complete description of the parameter, use _(&amp;quot;&amp;quot;) to create a string that needs to be translated,&lt;br /&gt;
*&#039;&#039;&#039;advanced&#039;&#039;&#039; Boolean, ADVanced Configuration. If TRUE, this parameter will only be displayed when using the --advanced flag. e.g.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt; You may add the following options/parameter types to your module: &lt;br /&gt;
&lt;br /&gt;
*add_integer, &lt;br /&gt;
*add_string, &lt;br /&gt;
*add_float, &lt;br /&gt;
*add_bool, &lt;br /&gt;
*add_key, &lt;br /&gt;
*add_file, &lt;br /&gt;
*add_directory,&lt;br /&gt;
&lt;br /&gt;
For complete definitions, see {{VLCSourceFile|name=include/vlc_plugin.h}}&lt;br /&gt;
&lt;br /&gt;
==== Callback  ====&lt;br /&gt;
&lt;br /&gt;
The opening and closing static functions, detailed afterwards, need to be defined in the descriptor, so VLC can discuss with the module.&lt;br /&gt;
&lt;br /&gt;
=== Open(vlc_object_t *)  ===&lt;br /&gt;
&lt;br /&gt;
The most important function of a module, is the opening: the usually-named Open() function. &lt;br /&gt;
&amp;lt;pre&amp;gt;static int  Open ( vlc_object_t * );&amp;lt;/pre&amp;gt; &lt;br /&gt;
The Open() function is called when the VLC core tries to open the module, and wants to load it. &lt;br /&gt;
&lt;br /&gt;
During Open(), setup of structures, devices or I/O, checks should be done. A working open should return VLC_SUCCESS. In all other cases, it will not be considered as loaded.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Open()&#039;&#039;&#039; function is expected to allocate private data (if any), and set up the private structure.&lt;br /&gt;
&lt;br /&gt;
If the Opening fails, you need to clean-up your own structures.&lt;br /&gt;
&lt;br /&gt;
=== Close(vlc_object_t *)  ===&lt;br /&gt;
The second most important function of a module, is the closing: the usually-named Close() function.&lt;br /&gt;
&amp;lt;pre&amp;gt;static int  Close ( vlc_object_t * );&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Close() function is called when the VLC core tries to close or unload an &#039;&#039;&#039;already-loaded&#039;&#039;&#039; module.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NB:&#039;&#039;&#039; If the Open() function failed, Close() will not get called.&lt;br /&gt;
&lt;br /&gt;
During Close(), close devices or I/O and cleaning of structures should be done. Do not leak memory here!&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Close()&#039;&#039;&#039; function should deallocate private data.&lt;br /&gt;
&lt;br /&gt;
== SubModules  ==&lt;br /&gt;
&lt;br /&gt;
Submodules, created in some modules with &lt;br /&gt;
&lt;br /&gt;
 add_submodule()&lt;br /&gt;
&lt;br /&gt;
work exactly the same way as modules. They are useful to parent modules, and to share code between modules.&lt;br /&gt;
&lt;br /&gt;
The submodules will be separated in the cache, and will be loaded by VLC in the exact same way as a module.&lt;br /&gt;
&lt;br /&gt;
== Modules types ==&lt;br /&gt;
&lt;br /&gt;
Depending on the module capability, you will need more information, about the necessary functions to implement.&lt;br /&gt;
&lt;br /&gt;
We will detail those here:&lt;br /&gt;
* [[Documentation:Hacker&#039;s_Guide/Access|Access]]&lt;br /&gt;
* [[Documentation:Hacker&#039;s_Guide/Demux|Demux]]&lt;br /&gt;
* [[Documentation:Hacker&#039;s_Guide/Access_Demux|Access_Demux]]&lt;br /&gt;
* Decoder&lt;br /&gt;
* Interface&lt;br /&gt;
* [[Documentation:Hacker&#039;s_Guide/Video_Filters|Video Filter]]&lt;br /&gt;
* [[Documentation:Hacker&#039;s_Guide/Audio_Filters|Audio Filter]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Documentation}} &lt;br /&gt;
&lt;br /&gt;
[[Category:Coding]]&lt;/div&gt;</summary>
		<author><name>Technologicat</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=Hacker_Guide/Video_Filters&amp;diff=19131</id>
		<title>Hacker Guide/Video Filters</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=Hacker_Guide/Video_Filters&amp;diff=19131"/>
		<updated>2011-05-09T14:41:05Z</updated>

		<summary type="html">&lt;p&gt;Technologicat: /* Some notes on video filter API */ mouse handler function notes v2&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is the [[Documentation:Hacker&#039;s_Guide|Hacker&#039;s Guide]] for video filters (&#039;&#039;&#039;video filter2&#039;&#039;&#039;, VLC 1.2).&lt;br /&gt;
&lt;br /&gt;
== Location in source tree, compilation ==&lt;br /&gt;
&lt;br /&gt;
The right place for video filter is in the {{VLCSourceFile|name=modules/video_filter/}} folder.&lt;br /&gt;
&lt;br /&gt;
See {{VLCSourceFile|name=modules/video_filter/Modules.am}} for a list of video filters currently in VLC, and which source files belong to which.&lt;br /&gt;
&lt;br /&gt;
See [[Documentation:Hacker&#039;s_Guide/How_To_Write_a_Module#Git_and_Repository_integration|new module integration]] for additional help on how to integrate a new module in the build-system.&lt;br /&gt;
&lt;br /&gt;
== Additional documentation ==&lt;br /&gt;
&lt;br /&gt;
Reading [[Documentation:Hacker&#039;s_Guide/How_To_Write_a_Module|How to write a module]] before is very advised.&lt;br /&gt;
&lt;br /&gt;
Some &#039;&#039;video filters&#039;&#039; may have their own [[Documentation:Hacker&#039;s Guide|Hacker&#039;s Guide]] sections.&lt;br /&gt;
&lt;br /&gt;
Currently, the &#039;&#039;&#039;deinterlace&#039;&#039;&#039; filter has both a [[Documentation:Hacker&#039;s Guide/Video Filters/Deinterlace|Hacker&#039;s Guide section]] and [[Deinterlace|user documentation]] with some useful additional  technical information.&lt;br /&gt;
&lt;br /&gt;
== Programming conventions and tips ==&lt;br /&gt;
&lt;br /&gt;
{{VLC}} [[video filters]] are usually written in C99, like the rest of VLC. Some use C++, like AtmoLight plugin.&lt;br /&gt;
&lt;br /&gt;
The usual stuff holds here too:&lt;br /&gt;
* Use &#039;&#039;&#039;assert()&#039;&#039;&#039; for checking conditions that, in presence of no bugs, always hold.&lt;br /&gt;
** &#039;&#039;Don&#039;t&#039;&#039; use &#039;&#039;&#039;assert()&#039;&#039;&#039; for checking stuff that may fail at runtime. Handle errors gracefully.&lt;br /&gt;
* Keep your code readable. Make private functions when it simplifies things.&lt;br /&gt;
* Prefer 80 characters per line at maximum, if possible.&lt;br /&gt;
&lt;br /&gt;
Particularly for video filters: keep in mind that this is low-level stuff and needs to be fast.&lt;br /&gt;
* How fast? Note that the source may be interlaced, and someone may have thrown a framerate doubler into the filter chain... this means that for a 60i signal, the entire processing chain from decode to render has about 16ms per output frame.&lt;br /&gt;
* Keep the required memory bandwidth down.&lt;br /&gt;
** Don&#039;t copy whole pictures unless you absolutely must. Moving pixels costs time.&lt;br /&gt;
** Allocate an output picture and render directly into it.&lt;br /&gt;
** If you need more than one pass, do in-place processing in the subsequent ones if possible.&lt;br /&gt;
** If your processing cannot avoid multiple passes, consider doing all passes for a picture line (or a few) at a time, instead of iterating over the whole picture separately for each pass. This will help to keep down the pressure on the CPU cache.&lt;br /&gt;
* Consider writing the inner processing loops in vectorized inline assembly, such as MMX. This can often gain a factor of 2-8x in speed, depending on how much and what kind of processing your algorithm needs.&lt;br /&gt;
&lt;br /&gt;
== Some notes on video filter API ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: See {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.c}} and {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.h}} for an example of everything discussed in this section. See also the [[Documentation:Hacker&#039;s Guide/Video Filters/Deinterlace|Deinterlace Hacker&#039;s Guide]] for some further details.&lt;br /&gt;
&lt;br /&gt;
The video filters use an object-based model. Calls to the filter will come with an instance pointer, so each filter instance can keep local data.&lt;br /&gt;
&lt;br /&gt;
Usually, each filter defines its own internal data structure called &#039;&#039;&#039;filter_sys_t&#039;&#039;&#039;. It is completely private to the filter.&lt;br /&gt;
&lt;br /&gt;
The API for video filters in VLC 1.2 is called &#039;&#039;&#039;video filter2&#039;&#039;&#039;. This requires the functions &#039;&#039;&#039;Open()&#039;&#039;&#039; and &#039;&#039;&#039;Close()&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Open()&#039;&#039;&#039; function is expected to allocate private data (if any), and set up the filter structure with pointers to a frame processing function (&#039;&#039;&#039;p_filter-&amp;gt;pf_video_filter&#039;&#039;&#039;, which is the actual filter), a flush function (&#039;&#039;&#039;p_filter-&amp;gt;pf_video_flush&#039;&#039;&#039;), and a mouse event function (&#039;&#039;&#039;p_filter-&amp;gt;pf_video_mouse&#039;&#039;&#039;). The relevant types are defined in {{VLCSourceFile|name=include/vlc_filter.h}}.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Close()&#039;&#039;&#039; function should deallocate private data.&lt;br /&gt;
&lt;br /&gt;
The mouse function should convert mouse events, from filter output format to filter input format (note the direction!). This is needed when doing scaling or geometrical distortions, so that the mouse position will map correctly. See {{VLCSourceFile|name=include/vlc_filter.h}} for the definition and &#039;&#039;&#039;Mouse()&#039;&#039;&#039; in {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.c}} for an example. If you do not need to remap mouse events, you can leave &#039;&#039;&#039;p_filter-&amp;gt;pf_video_mouse&#039;&#039;&#039; as &#039;&#039;&#039;NULL&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=== Filter work (frame processing function) ===&lt;br /&gt;
The frame processing function takes a frame as input (&#039;&#039;&#039;picture_t*&#039;&#039;&#039;, {{VLCSourceFile|name=include/vlc_picture.h}}), and optionally outputs one or more frames (&#039;&#039;&#039;picture_t*&#039;&#039;&#039;) as a linked list. The usual case is one frame in, one frame out, but this is not a requirement. (See framerate doublers and IVTC in the [[deinterlace]] module for counterexamples.)&lt;br /&gt;
&lt;br /&gt;
If you do not wish to output a frame at a particular call to your processing function, you can return &#039;&#039;&#039;NULL&#039;&#039;&#039;. If you wish to output several, make a linked list by using the &#039;&#039;&#039;p_next&#039;&#039;&#039; member of &#039;&#039;&#039;picture_t&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
You don&#039;t have to necessarily output the &#039;&#039;same&#039;&#039; frame (after processing) that just came in. You can keep a private input frame history in your &#039;&#039;&#039;filter_sys_t&#039;&#039;&#039;, pick the base frame for your output from that, and adjust the PTSs (presentation timestamps, member &#039;&#039;&#039;date&#039;&#039;&#039; in &#039;&#039;&#039;picture_t&#039;&#039;&#039;) of your output as you deem necessary. The deinterlacer provides an example of how to do this.&lt;br /&gt;
&lt;br /&gt;
Note however that there may be other filters in the chain that already set up an offset; this leaves less time (until the designated PTS) for the rest of the filters to do their processing.&lt;br /&gt;
&lt;br /&gt;
The input picture coming in to the processing function is considered as owned by the processing function, and should be released before returning. To do this, use&lt;br /&gt;
&amp;lt;pre&amp;gt;picture_Release( p_inpic );&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Frame allocation ===&lt;br /&gt;
Be sure to allocate your output pictures using &amp;lt;pre&amp;gt;picture_t *p_outpic = filter_NewPicture( p_filter );&amp;lt;/pre&amp;gt;&lt;br /&gt;
This function requests a new picture from the private pool (see {{VLCSourceFile|name=src/video_output/vout_wrapper.c}}). This is very important! Be aware that pictures created like&lt;br /&gt;
&amp;lt;pre&amp;gt;picture_t *p_temp = picture_NewFromFormat( &amp;amp;p_input_pic-&amp;gt;format );&amp;lt;/pre&amp;gt;&lt;br /&gt;
lack a shared memory context (in Linux; or the equivalent in other OS), and thus cannot be passed to the video output logic. If your filter attempts to do so, VLC will crash.&lt;br /&gt;
&lt;br /&gt;
If you need temporary pictures, you can allocate those using &#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;, but remember to &#039;&#039;always create output pictures using &#039;&#039;&#039;filter_NewPicture()&#039;&#039;&#039;&#039;&#039;. Here an &#039;&#039;output picture&#039;&#039; is defined as a picture which goes out from the filter to the caller.&lt;br /&gt;
&lt;br /&gt;
There is a limit to the number of simultaneous picture slots available in the private pool. Currently (&amp;lt;nowiki&amp;gt;[71992c5fbc75ee2c94cd2a3ab1aaca70bfc688a9]&amp;lt;/nowiki&amp;gt;) this is 3 pictures for the filter layer. See constant &#039;&#039;&#039;private_picture&#039;&#039;&#039; in {{VLCSourceFile|name=src/video_output/vout_wrapper.c}}. If you try to allocate more output pictures than this (during a single processing call), the allocation will fail.&lt;br /&gt;
&lt;br /&gt;
=== Notes ===&lt;br /&gt;
* In VLC 1.2, the video format (resolution, chroma) never changes on the fly. The whole filter chain is &#039;&#039;&#039;Close()&#039;&#039;&#039;d and then &#039;&#039;&#039;Open()&#039;&#039;&#039;ed again if the format changes.&lt;br /&gt;
&lt;br /&gt;
* Note that it &#039;&#039;is&#039;&#039; allowed to flush the filter without closing it. This actually happens under some circumstances, so &#039;&#039;don&#039;t deallocate stuff in your flush function&#039;&#039;. Rather, allocate dynamic resources in &#039;&#039;&#039;Open()&#039;&#039;&#039;, and deallocate them in &#039;&#039;&#039;Close()&#039;&#039;&#039; (or in private functions called from those).&lt;br /&gt;
&lt;br /&gt;
* Supported input and output formats are left up to each filter. The usual thing is to support YUV formats, e.g. I420, J420, YV12, I422 and J422. See {{VLCSourceFile|name=include/vlc_fourcc.h}}. The most important ones to support are I420 and I422.&lt;br /&gt;
&lt;br /&gt;
== Pitch, visible pitch, planes et al. ==&lt;br /&gt;
&lt;br /&gt;
=== Pitch and visible pitch ===&lt;br /&gt;
Important to know:&lt;br /&gt;
&lt;br /&gt;
* i_pitch = number of (macro)pixels on one line&lt;br /&gt;
* i_visible_pitch = number of (macro)pixels on one line, adjusted for memory alignment constraints etc. (see below)&lt;br /&gt;
&lt;br /&gt;
Note that the pitches may be different for each plane, and indeed in YUV formats the luma (&#039;&#039;&#039;Y_PLANE&#039;&#039;&#039;) and chroma (&#039;&#039;&#039;U_PLANE&#039;&#039;&#039;, &#039;&#039;&#039;V_PLANE&#039;&#039;&#039;) have different pitches due to chroma subsampling. (In 4:2:0 formats, the number of lines differs, too.)&lt;br /&gt;
&lt;br /&gt;
Pitches also tend to slightly differ depending on how the picture was allocated, even if the visible size is the same. The input picture to the filter may have one pitch, temporary pictures (&#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;) another, and output pictures (&#039;&#039;&#039;filter_NewPicture()&#039;&#039;&#039;) yet another.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Be sure to always use the correct pitch when you handle the pixels of a picture.&#039;&#039; That is, always use the &#039;&#039;&#039;i_pitch&#039;&#039;&#039; member of the actual &#039;&#039;&#039;plane_t&#039;&#039;&#039; you are working on.&lt;br /&gt;
&lt;br /&gt;
If you absolutely need matching pitches (e.g. if you are glueing in processing code from another GPL-compatible project which assumes this and you don&#039;t want to rewrite it...), consider making temporary copies with &#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;. See {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.c}} (the history mechanism &amp;lt;nowiki&amp;gt;pp_history[]&amp;lt;/nowiki&amp;gt;) and {{VLCSourceFile|name=modules/video_filter/deinterlace/algo_yadif.c}} (its usage) for an example.&lt;br /&gt;
&lt;br /&gt;
If you are processing pixels from one picture to another, the safe thing to do is to take the smallest &#039;&#039;&#039;i_visible_pitch&#039;&#039;&#039;, and loop from x = 0 until the visible pitch has been reached, but use the individual &#039;&#039;&#039;i_pitch&#039;&#039;&#039;es for computing the pixel locations. See {{VLCSourceFile|name=modules/video_filter/deinterlace/helpers.c}} for examples.&lt;br /&gt;
&lt;br /&gt;
=== Video_format_t vs. Plane_t ===&lt;br /&gt;
&lt;br /&gt;
In &#039;&#039;&#039;video_format_t&#039;&#039;&#039;, the &#039;&#039;&#039;i_visible_width&#039;&#039;&#039; and &#039;&#039;&#039;i_visible_height&#039;&#039;&#039; members go with &#039;&#039;&#039;i_x_offset&#039;&#039;&#039; and &#039;&#039;&#039;i_y_offset&#039;&#039;&#039;, but they are not related to &#039;&#039;&#039;plane_t::i_visible_*&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;plane_t::i_visible_*&#039;&#039;&#039; fields are there to know which part of the memory planes can at most be displayed. Usually these are different from the whole surface due to memory alignment constraints (like mod 16 for SSE2 or to be aligned on a macroblock). Those values are decided when the picture is allocated and they usually don&#039;t change for a given picture pointer (but they can change, like in direct3d buffers).&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;video_format_t:i_visible_width/height&#039;&#039;&#039; and &#039;&#039;&#039;i_x/y_offset&#039;&#039;&#039; are more a &#039;hint&#039; regarding what will be actually displayed. A filter should update &#039;&#039;&#039;filter_t::fmt_out&#039;&#039;&#039; if needed to ensure that the allocated pictures get the right value. A filter should, however, not limit its processing to this area, because VLC supports dynamic cropping.&lt;br /&gt;
&lt;br /&gt;
Thus, the correct thing to do in a filter is to process the whole picture area, or at least the first i_visible_* lines and pixels &#039;&#039;according to the &#039;&#039;&#039;plane_t&#039;&#039;&#039;s&#039;&#039;. Filters do not need to care about margin positioning or that there even exists such a thing as margins.&lt;br /&gt;
&lt;br /&gt;
== Disclaimer ==&lt;br /&gt;
&lt;br /&gt;
The information is mostly based on a few months&#039; hacking on the deinterlacer.&lt;br /&gt;
&lt;br /&gt;
This page is still a stub. Please add new relevant stuff.&lt;br /&gt;
&lt;br /&gt;
Also, the stuff that already exists could use better organization and formatting.&lt;br /&gt;
&lt;br /&gt;
{{Documentation}}&lt;/div&gt;</summary>
		<author><name>Technologicat</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=Hacker_Guide/Video_Filters&amp;diff=19130</id>
		<title>Hacker Guide/Video Filters</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=Hacker_Guide/Video_Filters&amp;diff=19130"/>
		<updated>2011-05-09T14:23:40Z</updated>

		<summary type="html">&lt;p&gt;Technologicat: /* Some notes on video filter API */ mouse handler function notes&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is the [[Documentation:Hacker&#039;s_Guide|Hacker&#039;s Guide]] for video filters (&#039;&#039;&#039;video filter2&#039;&#039;&#039;, VLC 1.2).&lt;br /&gt;
&lt;br /&gt;
== Location in source tree, compilation ==&lt;br /&gt;
&lt;br /&gt;
The right place for video filter is in the {{VLCSourceFile|name=modules/video_filter/}} folder.&lt;br /&gt;
&lt;br /&gt;
See {{VLCSourceFile|name=modules/video_filter/Modules.am}} for a list of video filters currently in VLC, and which source files belong to which.&lt;br /&gt;
&lt;br /&gt;
See [[Documentation:Hacker&#039;s_Guide/How_To_Write_a_Module#Git_and_Repository_integration|new module integration]] for additional help on how to integrate a new module in the build-system.&lt;br /&gt;
&lt;br /&gt;
== Additional documentation ==&lt;br /&gt;
&lt;br /&gt;
Reading [[Documentation:Hacker&#039;s_Guide/How_To_Write_a_Module|How to write a module]] before is very advised.&lt;br /&gt;
&lt;br /&gt;
Some &#039;&#039;video filters&#039;&#039; may have their own [[Documentation:Hacker&#039;s Guide|Hacker&#039;s Guide]] sections.&lt;br /&gt;
&lt;br /&gt;
Currently, the &#039;&#039;&#039;deinterlace&#039;&#039;&#039; filter has both a [[Documentation:Hacker&#039;s Guide/Video Filters/Deinterlace|Hacker&#039;s Guide section]] and [[Deinterlace|user documentation]] with some useful additional  technical information.&lt;br /&gt;
&lt;br /&gt;
== Programming conventions and tips ==&lt;br /&gt;
&lt;br /&gt;
{{VLC}} [[video filters]] are usually written in C99, like the rest of VLC. Some use C++, like AtmoLight plugin.&lt;br /&gt;
&lt;br /&gt;
The usual stuff holds here too:&lt;br /&gt;
* Use &#039;&#039;&#039;assert()&#039;&#039;&#039; for checking conditions that, in presence of no bugs, always hold.&lt;br /&gt;
** &#039;&#039;Don&#039;t&#039;&#039; use &#039;&#039;&#039;assert()&#039;&#039;&#039; for checking stuff that may fail at runtime. Handle errors gracefully.&lt;br /&gt;
* Keep your code readable. Make private functions when it simplifies things.&lt;br /&gt;
* Prefer 80 characters per line at maximum, if possible.&lt;br /&gt;
&lt;br /&gt;
Particularly for video filters: keep in mind that this is low-level stuff and needs to be fast.&lt;br /&gt;
* How fast? Note that the source may be interlaced, and someone may have thrown a framerate doubler into the filter chain... this means that for a 60i signal, the entire processing chain from decode to render has about 16ms per output frame.&lt;br /&gt;
* Keep the required memory bandwidth down.&lt;br /&gt;
** Don&#039;t copy whole pictures unless you absolutely must. Moving pixels costs time.&lt;br /&gt;
** Allocate an output picture and render directly into it.&lt;br /&gt;
** If you need more than one pass, do in-place processing in the subsequent ones if possible.&lt;br /&gt;
** If your processing cannot avoid multiple passes, consider doing all passes for a picture line (or a few) at a time, instead of iterating over the whole picture separately for each pass. This will help to keep down the pressure on the CPU cache.&lt;br /&gt;
* Consider writing the inner processing loops in vectorized inline assembly, such as MMX. This can often gain a factor of 2-8x in speed, depending on how much and what kind of processing your algorithm needs.&lt;br /&gt;
&lt;br /&gt;
== Some notes on video filter API ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: See {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.c}} and {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.h}} for an example of everything discussed in this section. See also the [[Documentation:Hacker&#039;s Guide/Video Filters/Deinterlace|Deinterlace Hacker&#039;s Guide]] for some further details.&lt;br /&gt;
&lt;br /&gt;
The video filters use an object-based model. Calls to the filter will come with an instance pointer, so each filter instance can keep local data.&lt;br /&gt;
&lt;br /&gt;
Usually, each filter defines its own internal data structure called &#039;&#039;&#039;filter_sys_t&#039;&#039;&#039;. It is completely private to the filter.&lt;br /&gt;
&lt;br /&gt;
The API for video filters in VLC 1.2 is called &#039;&#039;&#039;video filter2&#039;&#039;&#039;. This requires the functions &#039;&#039;&#039;Open()&#039;&#039;&#039; and &#039;&#039;&#039;Close()&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Open()&#039;&#039;&#039; function is expected to allocate private data (if any), and set up the filter structure with pointers to a frame processing function (&#039;&#039;&#039;p_filter-&amp;gt;pf_video_filter&#039;&#039;&#039;, which is the actual filter), a flush function (&#039;&#039;&#039;p_filter-&amp;gt;pf_video_flush&#039;&#039;&#039;), and a mouse event function (&#039;&#039;&#039;p_filter-&amp;gt;pf_video_mouse&#039;&#039;&#039;). The relevant types are defined in {{VLCSourceFile|name=include/vlc_filter.h}}.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Close()&#039;&#039;&#039; function should deallocate private data.&lt;br /&gt;
&lt;br /&gt;
The mouse function should convert mouse events, from filter output format to filter input format. This is needed when doing scaling or geometrical distortions, so that the mouse position will map correctly. See {{VLCSourceFile|name=include/vlc_filter.h}} for the definition and &#039;&#039;&#039;Mouse()&#039;&#039;&#039; in {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.c}} for an example.&lt;br /&gt;
&lt;br /&gt;
=== Filter work (frame processing function) ===&lt;br /&gt;
The frame processing function takes a frame as input (&#039;&#039;&#039;picture_t*&#039;&#039;&#039;, {{VLCSourceFile|name=include/vlc_picture.h}}), and optionally outputs one or more frames (&#039;&#039;&#039;picture_t*&#039;&#039;&#039;) as a linked list. The usual case is one frame in, one frame out, but this is not a requirement. (See framerate doublers and IVTC in the [[deinterlace]] module for counterexamples.)&lt;br /&gt;
&lt;br /&gt;
If you do not wish to output a frame at a particular call to your processing function, you can return &#039;&#039;&#039;NULL&#039;&#039;&#039;. If you wish to output several, make a linked list by using the &#039;&#039;&#039;p_next&#039;&#039;&#039; member of &#039;&#039;&#039;picture_t&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
You don&#039;t have to necessarily output the &#039;&#039;same&#039;&#039; frame (after processing) that just came in. You can keep a private input frame history in your &#039;&#039;&#039;filter_sys_t&#039;&#039;&#039;, pick the base frame for your output from that, and adjust the PTSs (presentation timestamps, member &#039;&#039;&#039;date&#039;&#039;&#039; in &#039;&#039;&#039;picture_t&#039;&#039;&#039;) of your output as you deem necessary. The deinterlacer provides an example of how to do this.&lt;br /&gt;
&lt;br /&gt;
Note however that there may be other filters in the chain that already set up an offset; this leaves less time (until the designated PTS) for the rest of the filters to do their processing.&lt;br /&gt;
&lt;br /&gt;
The input picture coming in to the processing function is considered as owned by the processing function, and should be released before returning. To do this, use&lt;br /&gt;
&amp;lt;pre&amp;gt;picture_Release( p_inpic );&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Frame allocation ===&lt;br /&gt;
Be sure to allocate your output pictures using &amp;lt;pre&amp;gt;picture_t *p_outpic = filter_NewPicture( p_filter );&amp;lt;/pre&amp;gt;&lt;br /&gt;
This function requests a new picture from the private pool (see {{VLCSourceFile|name=src/video_output/vout_wrapper.c}}). This is very important! Be aware that pictures created like&lt;br /&gt;
&amp;lt;pre&amp;gt;picture_t *p_temp = picture_NewFromFormat( &amp;amp;p_input_pic-&amp;gt;format );&amp;lt;/pre&amp;gt;&lt;br /&gt;
lack a shared memory context (in Linux; or the equivalent in other OS), and thus cannot be passed to the video output logic. If your filter attempts to do so, VLC will crash.&lt;br /&gt;
&lt;br /&gt;
If you need temporary pictures, you can allocate those using &#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;, but remember to &#039;&#039;always create output pictures using &#039;&#039;&#039;filter_NewPicture()&#039;&#039;&#039;&#039;&#039;. Here an &#039;&#039;output picture&#039;&#039; is defined as a picture which goes out from the filter to the caller.&lt;br /&gt;
&lt;br /&gt;
There is a limit to the number of simultaneous picture slots available in the private pool. Currently (&amp;lt;nowiki&amp;gt;[71992c5fbc75ee2c94cd2a3ab1aaca70bfc688a9]&amp;lt;/nowiki&amp;gt;) this is 3 pictures for the filter layer. See constant &#039;&#039;&#039;private_picture&#039;&#039;&#039; in {{VLCSourceFile|name=src/video_output/vout_wrapper.c}}. If you try to allocate more output pictures than this (during a single processing call), the allocation will fail.&lt;br /&gt;
&lt;br /&gt;
=== Notes ===&lt;br /&gt;
* In VLC 1.2, the video format (resolution, chroma) never changes on the fly. The whole filter chain is &#039;&#039;&#039;Close()&#039;&#039;&#039;d and then &#039;&#039;&#039;Open()&#039;&#039;&#039;ed again if the format changes.&lt;br /&gt;
&lt;br /&gt;
* Note that it &#039;&#039;is&#039;&#039; allowed to flush the filter without closing it. This actually happens under some circumstances, so &#039;&#039;don&#039;t deallocate stuff in your flush function&#039;&#039;. Rather, allocate dynamic resources in &#039;&#039;&#039;Open()&#039;&#039;&#039;, and deallocate them in &#039;&#039;&#039;Close()&#039;&#039;&#039; (or in private functions called from those).&lt;br /&gt;
&lt;br /&gt;
* Supported input and output formats are left up to each filter. The usual thing is to support YUV formats, e.g. I420, J420, YV12, I422 and J422. See {{VLCSourceFile|name=include/vlc_fourcc.h}}. The most important ones to support are I420 and I422.&lt;br /&gt;
&lt;br /&gt;
== Pitch, visible pitch, planes et al. ==&lt;br /&gt;
&lt;br /&gt;
=== Pitch and visible pitch ===&lt;br /&gt;
Important to know:&lt;br /&gt;
&lt;br /&gt;
* i_pitch = number of (macro)pixels on one line&lt;br /&gt;
* i_visible_pitch = number of (macro)pixels on one line, adjusted for memory alignment constraints etc. (see below)&lt;br /&gt;
&lt;br /&gt;
Note that the pitches may be different for each plane, and indeed in YUV formats the luma (&#039;&#039;&#039;Y_PLANE&#039;&#039;&#039;) and chroma (&#039;&#039;&#039;U_PLANE&#039;&#039;&#039;, &#039;&#039;&#039;V_PLANE&#039;&#039;&#039;) have different pitches due to chroma subsampling. (In 4:2:0 formats, the number of lines differs, too.)&lt;br /&gt;
&lt;br /&gt;
Pitches also tend to slightly differ depending on how the picture was allocated, even if the visible size is the same. The input picture to the filter may have one pitch, temporary pictures (&#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;) another, and output pictures (&#039;&#039;&#039;filter_NewPicture()&#039;&#039;&#039;) yet another.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Be sure to always use the correct pitch when you handle the pixels of a picture.&#039;&#039; That is, always use the &#039;&#039;&#039;i_pitch&#039;&#039;&#039; member of the actual &#039;&#039;&#039;plane_t&#039;&#039;&#039; you are working on.&lt;br /&gt;
&lt;br /&gt;
If you absolutely need matching pitches (e.g. if you are glueing in processing code from another GPL-compatible project which assumes this and you don&#039;t want to rewrite it...), consider making temporary copies with &#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;. See {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.c}} (the history mechanism &amp;lt;nowiki&amp;gt;pp_history[]&amp;lt;/nowiki&amp;gt;) and {{VLCSourceFile|name=modules/video_filter/deinterlace/algo_yadif.c}} (its usage) for an example.&lt;br /&gt;
&lt;br /&gt;
If you are processing pixels from one picture to another, the safe thing to do is to take the smallest &#039;&#039;&#039;i_visible_pitch&#039;&#039;&#039;, and loop from x = 0 until the visible pitch has been reached, but use the individual &#039;&#039;&#039;i_pitch&#039;&#039;&#039;es for computing the pixel locations. See {{VLCSourceFile|name=modules/video_filter/deinterlace/helpers.c}} for examples.&lt;br /&gt;
&lt;br /&gt;
=== Video_format_t vs. Plane_t ===&lt;br /&gt;
&lt;br /&gt;
In &#039;&#039;&#039;video_format_t&#039;&#039;&#039;, the &#039;&#039;&#039;i_visible_width&#039;&#039;&#039; and &#039;&#039;&#039;i_visible_height&#039;&#039;&#039; members go with &#039;&#039;&#039;i_x_offset&#039;&#039;&#039; and &#039;&#039;&#039;i_y_offset&#039;&#039;&#039;, but they are not related to &#039;&#039;&#039;plane_t::i_visible_*&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;plane_t::i_visible_*&#039;&#039;&#039; fields are there to know which part of the memory planes can at most be displayed. Usually these are different from the whole surface due to memory alignment constraints (like mod 16 for SSE2 or to be aligned on a macroblock). Those values are decided when the picture is allocated and they usually don&#039;t change for a given picture pointer (but they can change, like in direct3d buffers).&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;video_format_t:i_visible_width/height&#039;&#039;&#039; and &#039;&#039;&#039;i_x/y_offset&#039;&#039;&#039; are more a &#039;hint&#039; regarding what will be actually displayed. A filter should update &#039;&#039;&#039;filter_t::fmt_out&#039;&#039;&#039; if needed to ensure that the allocated pictures get the right value. A filter should, however, not limit its processing to this area, because VLC supports dynamic cropping.&lt;br /&gt;
&lt;br /&gt;
Thus, the correct thing to do in a filter is to process the whole picture area, or at least the first i_visible_* lines and pixels &#039;&#039;according to the &#039;&#039;&#039;plane_t&#039;&#039;&#039;s&#039;&#039;. Filters do not need to care about margin positioning or that there even exists such a thing as margins.&lt;br /&gt;
&lt;br /&gt;
== Disclaimer ==&lt;br /&gt;
&lt;br /&gt;
The information is mostly based on a few months&#039; hacking on the deinterlacer.&lt;br /&gt;
&lt;br /&gt;
This page is still a stub. Please add new relevant stuff.&lt;br /&gt;
&lt;br /&gt;
Also, the stuff that already exists could use better organization and formatting.&lt;br /&gt;
&lt;br /&gt;
{{Documentation}}&lt;/div&gt;</summary>
		<author><name>Technologicat</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=Hacker_Guide/Video_Filters&amp;diff=19129</id>
		<title>Hacker Guide/Video Filters</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=Hacker_Guide/Video_Filters&amp;diff=19129"/>
		<updated>2011-05-09T14:17:46Z</updated>

		<summary type="html">&lt;p&gt;Technologicat: /* Filter work (frame processing function) */ input picture ownership&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is the [[Documentation:Hacker&#039;s_Guide|Hacker&#039;s Guide]] for video filters (&#039;&#039;&#039;video filter2&#039;&#039;&#039;, VLC 1.2).&lt;br /&gt;
&lt;br /&gt;
== Location in source tree, compilation ==&lt;br /&gt;
&lt;br /&gt;
The right place for video filter is in the {{VLCSourceFile|name=modules/video_filter/}} folder.&lt;br /&gt;
&lt;br /&gt;
See {{VLCSourceFile|name=modules/video_filter/Modules.am}} for a list of video filters currently in VLC, and which source files belong to which.&lt;br /&gt;
&lt;br /&gt;
See [[Documentation:Hacker&#039;s_Guide/How_To_Write_a_Module#Git_and_Repository_integration|new module integration]] for additional help on how to integrate a new module in the build-system.&lt;br /&gt;
&lt;br /&gt;
== Additional documentation ==&lt;br /&gt;
&lt;br /&gt;
Reading [[Documentation:Hacker&#039;s_Guide/How_To_Write_a_Module|How to write a module]] before is very advised.&lt;br /&gt;
&lt;br /&gt;
Some &#039;&#039;video filters&#039;&#039; may have their own [[Documentation:Hacker&#039;s Guide|Hacker&#039;s Guide]] sections.&lt;br /&gt;
&lt;br /&gt;
Currently, the &#039;&#039;&#039;deinterlace&#039;&#039;&#039; filter has both a [[Documentation:Hacker&#039;s Guide/Video Filters/Deinterlace|Hacker&#039;s Guide section]] and [[Deinterlace|user documentation]] with some useful additional  technical information.&lt;br /&gt;
&lt;br /&gt;
== Programming conventions and tips ==&lt;br /&gt;
&lt;br /&gt;
{{VLC}} [[video filters]] are usually written in C99, like the rest of VLC. Some use C++, like AtmoLight plugin.&lt;br /&gt;
&lt;br /&gt;
The usual stuff holds here too:&lt;br /&gt;
* Use &#039;&#039;&#039;assert()&#039;&#039;&#039; for checking conditions that, in presence of no bugs, always hold.&lt;br /&gt;
** &#039;&#039;Don&#039;t&#039;&#039; use &#039;&#039;&#039;assert()&#039;&#039;&#039; for checking stuff that may fail at runtime. Handle errors gracefully.&lt;br /&gt;
* Keep your code readable. Make private functions when it simplifies things.&lt;br /&gt;
* Prefer 80 characters per line at maximum, if possible.&lt;br /&gt;
&lt;br /&gt;
Particularly for video filters: keep in mind that this is low-level stuff and needs to be fast.&lt;br /&gt;
* How fast? Note that the source may be interlaced, and someone may have thrown a framerate doubler into the filter chain... this means that for a 60i signal, the entire processing chain from decode to render has about 16ms per output frame.&lt;br /&gt;
* Keep the required memory bandwidth down.&lt;br /&gt;
** Don&#039;t copy whole pictures unless you absolutely must. Moving pixels costs time.&lt;br /&gt;
** Allocate an output picture and render directly into it.&lt;br /&gt;
** If you need more than one pass, do in-place processing in the subsequent ones if possible.&lt;br /&gt;
** If your processing cannot avoid multiple passes, consider doing all passes for a picture line (or a few) at a time, instead of iterating over the whole picture separately for each pass. This will help to keep down the pressure on the CPU cache.&lt;br /&gt;
* Consider writing the inner processing loops in vectorized inline assembly, such as MMX. This can often gain a factor of 2-8x in speed, depending on how much and what kind of processing your algorithm needs.&lt;br /&gt;
&lt;br /&gt;
== Some notes on video filter API ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: See {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.c}} and {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.h}} for an example of everything discussed in this section. See also the [[Documentation:Hacker&#039;s Guide/Video Filters/Deinterlace|Deinterlace Hacker&#039;s Guide]] for some further details.&lt;br /&gt;
&lt;br /&gt;
The video filters use an object-based model. Calls to the filter will come with an instance pointer, so each filter instance can keep local data.&lt;br /&gt;
&lt;br /&gt;
Usually, each filter defines its own internal data structure called &#039;&#039;&#039;filter_sys_t&#039;&#039;&#039;. It is completely private to the filter.&lt;br /&gt;
&lt;br /&gt;
The API for video filters in VLC 1.2 is called &#039;&#039;&#039;video filter2&#039;&#039;&#039;. This requires the functions &#039;&#039;&#039;Open()&#039;&#039;&#039; and &#039;&#039;&#039;Close()&#039;&#039;&#039;. The &#039;&#039;&#039;Open()&#039;&#039;&#039; function is expected to allocate private data (if any), and set up the filter structure with pointers to a frame processing function (&#039;&#039;&#039;p_filter-&amp;gt;pf_video_filter&#039;&#039;&#039;, which is the actual filter), a flush function (&#039;&#039;&#039;p_filter-&amp;gt;pf_video_flush&#039;&#039;&#039;), and a mouse event function (&#039;&#039;&#039;p_filter-&amp;gt;pf_video_mouse&#039;&#039;&#039;). The &#039;&#039;&#039;Close()&#039;&#039;&#039; function should deallocate private data.&lt;br /&gt;
&lt;br /&gt;
=== Filter work (frame processing function) ===&lt;br /&gt;
The frame processing function takes a frame as input (&#039;&#039;&#039;picture_t*&#039;&#039;&#039;, {{VLCSourceFile|name=include/vlc_picture.h}}), and optionally outputs one or more frames (&#039;&#039;&#039;picture_t*&#039;&#039;&#039;) as a linked list. The usual case is one frame in, one frame out, but this is not a requirement. (See framerate doublers and IVTC in the [[deinterlace]] module for counterexamples.)&lt;br /&gt;
&lt;br /&gt;
If you do not wish to output a frame at a particular call to your processing function, you can return &#039;&#039;&#039;NULL&#039;&#039;&#039;. If you wish to output several, make a linked list by using the &#039;&#039;&#039;p_next&#039;&#039;&#039; member of &#039;&#039;&#039;picture_t&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
You don&#039;t have to necessarily output the &#039;&#039;same&#039;&#039; frame (after processing) that just came in. You can keep a private input frame history in your &#039;&#039;&#039;filter_sys_t&#039;&#039;&#039;, pick the base frame for your output from that, and adjust the PTSs (presentation timestamps, member &#039;&#039;&#039;date&#039;&#039;&#039; in &#039;&#039;&#039;picture_t&#039;&#039;&#039;) of your output as you deem necessary. The deinterlacer provides an example of how to do this.&lt;br /&gt;
&lt;br /&gt;
Note however that there may be other filters in the chain that already set up an offset; this leaves less time (until the designated PTS) for the rest of the filters to do their processing.&lt;br /&gt;
&lt;br /&gt;
The input picture coming in to the processing function is considered as owned by the processing function, and should be released before returning. To do this, use&lt;br /&gt;
&amp;lt;pre&amp;gt;picture_Release( p_inpic );&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Frame allocation ===&lt;br /&gt;
Be sure to allocate your output pictures using &amp;lt;pre&amp;gt;picture_t *p_outpic = filter_NewPicture( p_filter );&amp;lt;/pre&amp;gt;&lt;br /&gt;
This function requests a new picture from the private pool (see {{VLCSourceFile|name=src/video_output/vout_wrapper.c}}). This is very important! Be aware that pictures created like&lt;br /&gt;
&amp;lt;pre&amp;gt;picture_t *p_temp = picture_NewFromFormat( &amp;amp;p_input_pic-&amp;gt;format );&amp;lt;/pre&amp;gt;&lt;br /&gt;
lack a shared memory context (in Linux; or the equivalent in other OS), and thus cannot be passed to the video output logic. If your filter attempts to do so, VLC will crash.&lt;br /&gt;
&lt;br /&gt;
If you need temporary pictures, you can allocate those using &#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;, but remember to &#039;&#039;always create output pictures using &#039;&#039;&#039;filter_NewPicture()&#039;&#039;&#039;&#039;&#039;. Here an &#039;&#039;output picture&#039;&#039; is defined as a picture which goes out from the filter to the caller.&lt;br /&gt;
&lt;br /&gt;
There is a limit to the number of simultaneous picture slots available in the private pool. Currently (&amp;lt;nowiki&amp;gt;[71992c5fbc75ee2c94cd2a3ab1aaca70bfc688a9]&amp;lt;/nowiki&amp;gt;) this is 3 pictures for the filter layer. See constant &#039;&#039;&#039;private_picture&#039;&#039;&#039; in {{VLCSourceFile|name=src/video_output/vout_wrapper.c}}. If you try to allocate more output pictures than this (during a single processing call), the allocation will fail.&lt;br /&gt;
&lt;br /&gt;
=== Notes ===&lt;br /&gt;
* In VLC 1.2, the video format (resolution, chroma) never changes on the fly. The whole filter chain is &#039;&#039;&#039;Close()&#039;&#039;&#039;d and then &#039;&#039;&#039;Open()&#039;&#039;&#039;ed again if the format changes.&lt;br /&gt;
&lt;br /&gt;
* Note that it &#039;&#039;is&#039;&#039; allowed to flush the filter without closing it. This actually happens under some circumstances, so &#039;&#039;don&#039;t deallocate stuff in your flush function&#039;&#039;. Rather, allocate dynamic resources in &#039;&#039;&#039;Open()&#039;&#039;&#039;, and deallocate them in &#039;&#039;&#039;Close()&#039;&#039;&#039; (or in private functions called from those).&lt;br /&gt;
&lt;br /&gt;
* Supported input and output formats are left up to each filter. The usual thing is to support YUV formats, e.g. I420, J420, YV12, I422 and J422. See {{VLCSourceFile|name=include/vlc_fourcc.h}}. The most important ones to support are I420 and I422.&lt;br /&gt;
&lt;br /&gt;
== Pitch, visible pitch, planes et al. ==&lt;br /&gt;
&lt;br /&gt;
=== Pitch and visible pitch ===&lt;br /&gt;
Important to know:&lt;br /&gt;
&lt;br /&gt;
* i_pitch = number of (macro)pixels on one line&lt;br /&gt;
* i_visible_pitch = number of (macro)pixels on one line, adjusted for memory alignment constraints etc. (see below)&lt;br /&gt;
&lt;br /&gt;
Note that the pitches may be different for each plane, and indeed in YUV formats the luma (&#039;&#039;&#039;Y_PLANE&#039;&#039;&#039;) and chroma (&#039;&#039;&#039;U_PLANE&#039;&#039;&#039;, &#039;&#039;&#039;V_PLANE&#039;&#039;&#039;) have different pitches due to chroma subsampling. (In 4:2:0 formats, the number of lines differs, too.)&lt;br /&gt;
&lt;br /&gt;
Pitches also tend to slightly differ depending on how the picture was allocated, even if the visible size is the same. The input picture to the filter may have one pitch, temporary pictures (&#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;) another, and output pictures (&#039;&#039;&#039;filter_NewPicture()&#039;&#039;&#039;) yet another.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Be sure to always use the correct pitch when you handle the pixels of a picture.&#039;&#039; That is, always use the &#039;&#039;&#039;i_pitch&#039;&#039;&#039; member of the actual &#039;&#039;&#039;plane_t&#039;&#039;&#039; you are working on.&lt;br /&gt;
&lt;br /&gt;
If you absolutely need matching pitches (e.g. if you are glueing in processing code from another GPL-compatible project which assumes this and you don&#039;t want to rewrite it...), consider making temporary copies with &#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;. See {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.c}} (the history mechanism &amp;lt;nowiki&amp;gt;pp_history[]&amp;lt;/nowiki&amp;gt;) and {{VLCSourceFile|name=modules/video_filter/deinterlace/algo_yadif.c}} (its usage) for an example.&lt;br /&gt;
&lt;br /&gt;
If you are processing pixels from one picture to another, the safe thing to do is to take the smallest &#039;&#039;&#039;i_visible_pitch&#039;&#039;&#039;, and loop from x = 0 until the visible pitch has been reached, but use the individual &#039;&#039;&#039;i_pitch&#039;&#039;&#039;es for computing the pixel locations. See {{VLCSourceFile|name=modules/video_filter/deinterlace/helpers.c}} for examples.&lt;br /&gt;
&lt;br /&gt;
=== Video_format_t vs. Plane_t ===&lt;br /&gt;
&lt;br /&gt;
In &#039;&#039;&#039;video_format_t&#039;&#039;&#039;, the &#039;&#039;&#039;i_visible_width&#039;&#039;&#039; and &#039;&#039;&#039;i_visible_height&#039;&#039;&#039; members go with &#039;&#039;&#039;i_x_offset&#039;&#039;&#039; and &#039;&#039;&#039;i_y_offset&#039;&#039;&#039;, but they are not related to &#039;&#039;&#039;plane_t::i_visible_*&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;plane_t::i_visible_*&#039;&#039;&#039; fields are there to know which part of the memory planes can at most be displayed. Usually these are different from the whole surface due to memory alignment constraints (like mod 16 for SSE2 or to be aligned on a macroblock). Those values are decided when the picture is allocated and they usually don&#039;t change for a given picture pointer (but they can change, like in direct3d buffers).&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;video_format_t:i_visible_width/height&#039;&#039;&#039; and &#039;&#039;&#039;i_x/y_offset&#039;&#039;&#039; are more a &#039;hint&#039; regarding what will be actually displayed. A filter should update &#039;&#039;&#039;filter_t::fmt_out&#039;&#039;&#039; if needed to ensure that the allocated pictures get the right value. A filter should, however, not limit its processing to this area, because VLC supports dynamic cropping.&lt;br /&gt;
&lt;br /&gt;
Thus, the correct thing to do in a filter is to process the whole picture area, or at least the first i_visible_* lines and pixels &#039;&#039;according to the &#039;&#039;&#039;plane_t&#039;&#039;&#039;s&#039;&#039;. Filters do not need to care about margin positioning or that there even exists such a thing as margins.&lt;br /&gt;
&lt;br /&gt;
== Disclaimer ==&lt;br /&gt;
&lt;br /&gt;
The information is mostly based on a few months&#039; hacking on the deinterlacer.&lt;br /&gt;
&lt;br /&gt;
This page is still a stub. Please add new relevant stuff.&lt;br /&gt;
&lt;br /&gt;
Also, the stuff that already exists could use better organization and formatting.&lt;br /&gt;
&lt;br /&gt;
{{Documentation}}&lt;/div&gt;</summary>
		<author><name>Technologicat</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=Hacker_Guide/Video_Filters&amp;diff=19128</id>
		<title>Hacker Guide/Video Filters</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=Hacker_Guide/Video_Filters&amp;diff=19128"/>
		<updated>2011-05-09T14:16:08Z</updated>

		<summary type="html">&lt;p&gt;Technologicat: /* Filter work (frame processing function) */ correct member name (p_next)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is the [[Documentation:Hacker&#039;s_Guide|Hacker&#039;s Guide]] for video filters (&#039;&#039;&#039;video filter2&#039;&#039;&#039;, VLC 1.2).&lt;br /&gt;
&lt;br /&gt;
== Location in source tree, compilation ==&lt;br /&gt;
&lt;br /&gt;
The right place for video filter is in the {{VLCSourceFile|name=modules/video_filter/}} folder.&lt;br /&gt;
&lt;br /&gt;
See {{VLCSourceFile|name=modules/video_filter/Modules.am}} for a list of video filters currently in VLC, and which source files belong to which.&lt;br /&gt;
&lt;br /&gt;
See [[Documentation:Hacker&#039;s_Guide/How_To_Write_a_Module#Git_and_Repository_integration|new module integration]] for additional help on how to integrate a new module in the build-system.&lt;br /&gt;
&lt;br /&gt;
== Additional documentation ==&lt;br /&gt;
&lt;br /&gt;
Reading [[Documentation:Hacker&#039;s_Guide/How_To_Write_a_Module|How to write a module]] before is very advised.&lt;br /&gt;
&lt;br /&gt;
Some &#039;&#039;video filters&#039;&#039; may have their own [[Documentation:Hacker&#039;s Guide|Hacker&#039;s Guide]] sections.&lt;br /&gt;
&lt;br /&gt;
Currently, the &#039;&#039;&#039;deinterlace&#039;&#039;&#039; filter has both a [[Documentation:Hacker&#039;s Guide/Video Filters/Deinterlace|Hacker&#039;s Guide section]] and [[Deinterlace|user documentation]] with some useful additional  technical information.&lt;br /&gt;
&lt;br /&gt;
== Programming conventions and tips ==&lt;br /&gt;
&lt;br /&gt;
{{VLC}} [[video filters]] are usually written in C99, like the rest of VLC. Some use C++, like AtmoLight plugin.&lt;br /&gt;
&lt;br /&gt;
The usual stuff holds here too:&lt;br /&gt;
* Use &#039;&#039;&#039;assert()&#039;&#039;&#039; for checking conditions that, in presence of no bugs, always hold.&lt;br /&gt;
** &#039;&#039;Don&#039;t&#039;&#039; use &#039;&#039;&#039;assert()&#039;&#039;&#039; for checking stuff that may fail at runtime. Handle errors gracefully.&lt;br /&gt;
* Keep your code readable. Make private functions when it simplifies things.&lt;br /&gt;
* Prefer 80 characters per line at maximum, if possible.&lt;br /&gt;
&lt;br /&gt;
Particularly for video filters: keep in mind that this is low-level stuff and needs to be fast.&lt;br /&gt;
* How fast? Note that the source may be interlaced, and someone may have thrown a framerate doubler into the filter chain... this means that for a 60i signal, the entire processing chain from decode to render has about 16ms per output frame.&lt;br /&gt;
* Keep the required memory bandwidth down.&lt;br /&gt;
** Don&#039;t copy whole pictures unless you absolutely must. Moving pixels costs time.&lt;br /&gt;
** Allocate an output picture and render directly into it.&lt;br /&gt;
** If you need more than one pass, do in-place processing in the subsequent ones if possible.&lt;br /&gt;
** If your processing cannot avoid multiple passes, consider doing all passes for a picture line (or a few) at a time, instead of iterating over the whole picture separately for each pass. This will help to keep down the pressure on the CPU cache.&lt;br /&gt;
* Consider writing the inner processing loops in vectorized inline assembly, such as MMX. This can often gain a factor of 2-8x in speed, depending on how much and what kind of processing your algorithm needs.&lt;br /&gt;
&lt;br /&gt;
== Some notes on video filter API ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: See {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.c}} and {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.h}} for an example of everything discussed in this section. See also the [[Documentation:Hacker&#039;s Guide/Video Filters/Deinterlace|Deinterlace Hacker&#039;s Guide]] for some further details.&lt;br /&gt;
&lt;br /&gt;
The video filters use an object-based model. Calls to the filter will come with an instance pointer, so each filter instance can keep local data.&lt;br /&gt;
&lt;br /&gt;
Usually, each filter defines its own internal data structure called &#039;&#039;&#039;filter_sys_t&#039;&#039;&#039;. It is completely private to the filter.&lt;br /&gt;
&lt;br /&gt;
The API for video filters in VLC 1.2 is called &#039;&#039;&#039;video filter2&#039;&#039;&#039;. This requires the functions &#039;&#039;&#039;Open()&#039;&#039;&#039; and &#039;&#039;&#039;Close()&#039;&#039;&#039;. The &#039;&#039;&#039;Open()&#039;&#039;&#039; function is expected to allocate private data (if any), and set up the filter structure with pointers to a frame processing function (&#039;&#039;&#039;p_filter-&amp;gt;pf_video_filter&#039;&#039;&#039;, which is the actual filter), a flush function (&#039;&#039;&#039;p_filter-&amp;gt;pf_video_flush&#039;&#039;&#039;), and a mouse event function (&#039;&#039;&#039;p_filter-&amp;gt;pf_video_mouse&#039;&#039;&#039;). The &#039;&#039;&#039;Close()&#039;&#039;&#039; function should deallocate private data.&lt;br /&gt;
&lt;br /&gt;
=== Filter work (frame processing function) ===&lt;br /&gt;
The frame processing function takes a frame as input (&#039;&#039;&#039;picture_t*&#039;&#039;&#039;, {{VLCSourceFile|name=include/vlc_picture.h}}), and optionally outputs one or more frames (&#039;&#039;&#039;picture_t*&#039;&#039;&#039;) as a linked list. The usual case is one frame in, one frame out, but this is not a requirement. (See framerate doublers and IVTC in the [[deinterlace]] module for counterexamples.)&lt;br /&gt;
&lt;br /&gt;
If you do not wish to output a frame at a particular call to your processing function, you can return &#039;&#039;&#039;NULL&#039;&#039;&#039;. If you wish to output several, make a linked list by using the &#039;&#039;&#039;p_next&#039;&#039;&#039; member of &#039;&#039;&#039;picture_t&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
You don&#039;t have to necessarily output the &#039;&#039;same&#039;&#039; frame (after processing) that just came in. You can keep a private input frame history in your &#039;&#039;&#039;filter_sys_t&#039;&#039;&#039;, pick the base frame for your output from that, and adjust the PTSs (presentation timestamps, member &#039;&#039;&#039;date&#039;&#039;&#039; in &#039;&#039;&#039;picture_t&#039;&#039;&#039;) of your output as you deem necessary. The deinterlacer provides an example of how to do this.&lt;br /&gt;
&lt;br /&gt;
Note however that there may be other filters in the chain that already set up an offset; this leaves less time (until the designated PTS) for the rest of the filters to do their processing.&lt;br /&gt;
&lt;br /&gt;
=== Frame allocation ===&lt;br /&gt;
Be sure to allocate your output pictures using &amp;lt;pre&amp;gt;picture_t *p_outpic = filter_NewPicture( p_filter );&amp;lt;/pre&amp;gt;&lt;br /&gt;
This function requests a new picture from the private pool (see {{VLCSourceFile|name=src/video_output/vout_wrapper.c}}). This is very important! Be aware that pictures created like&lt;br /&gt;
&amp;lt;pre&amp;gt;picture_t *p_temp = picture_NewFromFormat( &amp;amp;p_input_pic-&amp;gt;format );&amp;lt;/pre&amp;gt;&lt;br /&gt;
lack a shared memory context (in Linux; or the equivalent in other OS), and thus cannot be passed to the video output logic. If your filter attempts to do so, VLC will crash.&lt;br /&gt;
&lt;br /&gt;
If you need temporary pictures, you can allocate those using &#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;, but remember to &#039;&#039;always create output pictures using &#039;&#039;&#039;filter_NewPicture()&#039;&#039;&#039;&#039;&#039;. Here an &#039;&#039;output picture&#039;&#039; is defined as a picture which goes out from the filter to the caller.&lt;br /&gt;
&lt;br /&gt;
There is a limit to the number of simultaneous picture slots available in the private pool. Currently (&amp;lt;nowiki&amp;gt;[71992c5fbc75ee2c94cd2a3ab1aaca70bfc688a9]&amp;lt;/nowiki&amp;gt;) this is 3 pictures for the filter layer. See constant &#039;&#039;&#039;private_picture&#039;&#039;&#039; in {{VLCSourceFile|name=src/video_output/vout_wrapper.c}}. If you try to allocate more output pictures than this (during a single processing call), the allocation will fail.&lt;br /&gt;
&lt;br /&gt;
=== Notes ===&lt;br /&gt;
* In VLC 1.2, the video format (resolution, chroma) never changes on the fly. The whole filter chain is &#039;&#039;&#039;Close()&#039;&#039;&#039;d and then &#039;&#039;&#039;Open()&#039;&#039;&#039;ed again if the format changes.&lt;br /&gt;
&lt;br /&gt;
* Note that it &#039;&#039;is&#039;&#039; allowed to flush the filter without closing it. This actually happens under some circumstances, so &#039;&#039;don&#039;t deallocate stuff in your flush function&#039;&#039;. Rather, allocate dynamic resources in &#039;&#039;&#039;Open()&#039;&#039;&#039;, and deallocate them in &#039;&#039;&#039;Close()&#039;&#039;&#039; (or in private functions called from those).&lt;br /&gt;
&lt;br /&gt;
* Supported input and output formats are left up to each filter. The usual thing is to support YUV formats, e.g. I420, J420, YV12, I422 and J422. See {{VLCSourceFile|name=include/vlc_fourcc.h}}. The most important ones to support are I420 and I422.&lt;br /&gt;
&lt;br /&gt;
== Pitch, visible pitch, planes et al. ==&lt;br /&gt;
&lt;br /&gt;
=== Pitch and visible pitch ===&lt;br /&gt;
Important to know:&lt;br /&gt;
&lt;br /&gt;
* i_pitch = number of (macro)pixels on one line&lt;br /&gt;
* i_visible_pitch = number of (macro)pixels on one line, adjusted for memory alignment constraints etc. (see below)&lt;br /&gt;
&lt;br /&gt;
Note that the pitches may be different for each plane, and indeed in YUV formats the luma (&#039;&#039;&#039;Y_PLANE&#039;&#039;&#039;) and chroma (&#039;&#039;&#039;U_PLANE&#039;&#039;&#039;, &#039;&#039;&#039;V_PLANE&#039;&#039;&#039;) have different pitches due to chroma subsampling. (In 4:2:0 formats, the number of lines differs, too.)&lt;br /&gt;
&lt;br /&gt;
Pitches also tend to slightly differ depending on how the picture was allocated, even if the visible size is the same. The input picture to the filter may have one pitch, temporary pictures (&#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;) another, and output pictures (&#039;&#039;&#039;filter_NewPicture()&#039;&#039;&#039;) yet another.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Be sure to always use the correct pitch when you handle the pixels of a picture.&#039;&#039; That is, always use the &#039;&#039;&#039;i_pitch&#039;&#039;&#039; member of the actual &#039;&#039;&#039;plane_t&#039;&#039;&#039; you are working on.&lt;br /&gt;
&lt;br /&gt;
If you absolutely need matching pitches (e.g. if you are glueing in processing code from another GPL-compatible project which assumes this and you don&#039;t want to rewrite it...), consider making temporary copies with &#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;. See {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.c}} (the history mechanism &amp;lt;nowiki&amp;gt;pp_history[]&amp;lt;/nowiki&amp;gt;) and {{VLCSourceFile|name=modules/video_filter/deinterlace/algo_yadif.c}} (its usage) for an example.&lt;br /&gt;
&lt;br /&gt;
If you are processing pixels from one picture to another, the safe thing to do is to take the smallest &#039;&#039;&#039;i_visible_pitch&#039;&#039;&#039;, and loop from x = 0 until the visible pitch has been reached, but use the individual &#039;&#039;&#039;i_pitch&#039;&#039;&#039;es for computing the pixel locations. See {{VLCSourceFile|name=modules/video_filter/deinterlace/helpers.c}} for examples.&lt;br /&gt;
&lt;br /&gt;
=== Video_format_t vs. Plane_t ===&lt;br /&gt;
&lt;br /&gt;
In &#039;&#039;&#039;video_format_t&#039;&#039;&#039;, the &#039;&#039;&#039;i_visible_width&#039;&#039;&#039; and &#039;&#039;&#039;i_visible_height&#039;&#039;&#039; members go with &#039;&#039;&#039;i_x_offset&#039;&#039;&#039; and &#039;&#039;&#039;i_y_offset&#039;&#039;&#039;, but they are not related to &#039;&#039;&#039;plane_t::i_visible_*&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;plane_t::i_visible_*&#039;&#039;&#039; fields are there to know which part of the memory planes can at most be displayed. Usually these are different from the whole surface due to memory alignment constraints (like mod 16 for SSE2 or to be aligned on a macroblock). Those values are decided when the picture is allocated and they usually don&#039;t change for a given picture pointer (but they can change, like in direct3d buffers).&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;video_format_t:i_visible_width/height&#039;&#039;&#039; and &#039;&#039;&#039;i_x/y_offset&#039;&#039;&#039; are more a &#039;hint&#039; regarding what will be actually displayed. A filter should update &#039;&#039;&#039;filter_t::fmt_out&#039;&#039;&#039; if needed to ensure that the allocated pictures get the right value. A filter should, however, not limit its processing to this area, because VLC supports dynamic cropping.&lt;br /&gt;
&lt;br /&gt;
Thus, the correct thing to do in a filter is to process the whole picture area, or at least the first i_visible_* lines and pixels &#039;&#039;according to the &#039;&#039;&#039;plane_t&#039;&#039;&#039;s&#039;&#039;. Filters do not need to care about margin positioning or that there even exists such a thing as margins.&lt;br /&gt;
&lt;br /&gt;
== Disclaimer ==&lt;br /&gt;
&lt;br /&gt;
The information is mostly based on a few months&#039; hacking on the deinterlacer.&lt;br /&gt;
&lt;br /&gt;
This page is still a stub. Please add new relevant stuff.&lt;br /&gt;
&lt;br /&gt;
Also, the stuff that already exists could use better organization and formatting.&lt;br /&gt;
&lt;br /&gt;
{{Documentation}}&lt;/div&gt;</summary>
		<author><name>Technologicat</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=Hacker_Guide/How_To_Write_a_Module&amp;diff=19127</id>
		<title>Hacker Guide/How To Write a Module</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=Hacker_Guide/How_To_Write_a_Module&amp;diff=19127"/>
		<updated>2011-05-09T14:13:37Z</updated>

		<summary type="html">&lt;p&gt;Technologicat: /* Modules.am */ video filter example fixed&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction to modules writer guide ==&lt;br /&gt;
&lt;br /&gt;
VLC is based on many independent modules, like most multimedia frameworks. Each module introduces a new functionnality.&lt;br /&gt;
&lt;br /&gt;
You &#039;&#039;&#039;MUST&#039;&#039;&#039; &#039;&#039;&#039;read&#039;&#039;&#039; [[Documentation:Hacker%27s_Guide/Core#VLC_Pipeline_and_Modularity|VLC Core and Modules ]] and [[Documentation:VLC_Modules_Loading|How VLC loads modules]] &#039;&#039;&#039;before&#039;&#039;&#039; reading this howto.&lt;br /&gt;
&lt;br /&gt;
This is a description about how you can write a new module for VLC.&lt;br /&gt;
&lt;br /&gt;
== Git and Repository integration ==&lt;br /&gt;
&lt;br /&gt;
=== Git ===&lt;br /&gt;
If you plan to submit your work to VLC upstream, be sure to look at [[Git |the git introduction]] and check the [[Git#Submitting_patches_to_the_vlc-devel_or_x264-devel|send patches part]].&lt;br /&gt;
&lt;br /&gt;
=== Compiling your module ===&lt;br /&gt;
&lt;br /&gt;
==== Modules.am ====&lt;br /&gt;
First, find the right place under [[Modules_source_tree| modules/]] to add your new code.&lt;br /&gt;
&lt;br /&gt;
# If you are adding a one-file module to the repository, just add its sources to the Modules.am in the same folder.&lt;br /&gt;
# If you are adding a bigger modules to the repository:&lt;br /&gt;
#* create a new directory&lt;br /&gt;
#* create a new Modules.am, inside that directory.&lt;br /&gt;
#* Add a corresponding Makefile line at the end of configure.ac for this new Modules.am.&lt;br /&gt;
&lt;br /&gt;
For example, the file {{VLCSourceFile|name=modules/video_filter/Modules.am}} tells the build system which source files go into which video filter module.&lt;br /&gt;
&lt;br /&gt;
Note that the indentation in Modules.am uses a tab (ASCII 0x09), not spaces.&lt;br /&gt;
&lt;br /&gt;
==== configure.ac ====&lt;br /&gt;
&lt;br /&gt;
To have the module built, you need to use &#039;&#039;VLC_ADD_PLUGIN&#039;&#039; or &#039;&#039;PKG_ENABLE_MODULES_VLC&#039;&#039; inside the {{VLCSourceFile|name=configure.ac}} with your new module name as argument. Look at other modules for guidelines on how to add build and linkage options.&lt;br /&gt;
&lt;br /&gt;
After changing {{VLCSourceFile|name=configure.ac}}, you will always need to rerun &lt;br /&gt;
 ./bootstrap &amp;amp;&amp;amp; ./configure&lt;br /&gt;
&lt;br /&gt;
=== Troubleshooting ===&lt;br /&gt;
&lt;br /&gt;
Sometimes, it doesn&#039;t work, because of some libtool bug.&lt;br /&gt;
&lt;br /&gt;
You probably need to go to the root of your VLC source tree, and do something akin to the following:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;pre&amp;gt;find . -name .deps -exec rm -rf \{\} \;&amp;lt;/pre&amp;gt;&lt;br /&gt;
* &amp;lt;pre&amp;gt;./bootstrap&amp;lt;/pre&amp;gt;&lt;br /&gt;
* &amp;lt;pre&amp;gt;./configure&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This ensures that the build system finds your new files. Then you can go on as usual:&lt;br /&gt;
* &amp;lt;pre&amp;gt;./compile&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Out of Tree Compile ====&lt;br /&gt;
&lt;br /&gt;
If you need to compile just a module, please read [[OutOfTreeCompile|out of tree compilation]].&lt;br /&gt;
&lt;br /&gt;
=== Loading your module ===&lt;br /&gt;
&lt;br /&gt;
VLC keeps the cache of its modules (in ~/.cache/vlc/ on Linux), you&#039;ll have to delete it (or use vlc --reset-plugins-cache) so that your module gets loaded.&lt;br /&gt;
&lt;br /&gt;
Then use&lt;br /&gt;
 vlc -vvv --color --list&lt;br /&gt;
to check that your plugin is seen by {{VLC}}.&lt;br /&gt;
&lt;br /&gt;
You should also see it in the plugins dialog of the [[Qt interface]] (Linux and Windows).&lt;br /&gt;
&lt;br /&gt;
== Example of an empty module  ==&lt;br /&gt;
&lt;br /&gt;
We will start with a small example, so you can understand it better. &lt;br /&gt;
&amp;lt;pre&amp;gt;/*****************************************************************************&lt;br /&gt;
 * Preamble&lt;br /&gt;
 *****************************************************************************/&lt;br /&gt;
&lt;br /&gt;
#ifdef HAVE_CONFIG_H&lt;br /&gt;
# include &amp;quot;config.h&amp;quot;&lt;br /&gt;
#endif&lt;br /&gt;
&lt;br /&gt;
#include &amp;amp;lt;vlc_common.h&amp;amp;gt;&lt;br /&gt;
#include &amp;amp;lt;vlc_plugin.h&amp;amp;gt;&lt;br /&gt;
&lt;br /&gt;
/*****************************************************************************&lt;br /&gt;
* Local prototypes.&lt;br /&gt;
*****************************************************************************/&lt;br /&gt;
&lt;br /&gt;
static int  Open           ( vlc_object_t * );&lt;br /&gt;
static void Close          ( vlc_object_t * );&lt;br /&gt;
&lt;br /&gt;
/*****************************************************************************&lt;br /&gt;
 * Module descriptor&lt;br /&gt;
 *****************************************************************************/&lt;br /&gt;
&lt;br /&gt;
vlc_module_begin()&lt;br /&gt;
    set_shortname( _(&amp;quot;testmodule&amp;quot;) )&lt;br /&gt;
    set_description( _(&amp;quot;testmodle plug-in&amp;quot;) )&lt;br /&gt;
    set_capability( &amp;quot;testing&amp;quot;, 0 )&lt;br /&gt;
    set_callbacks( Open, Close )&lt;br /&gt;
    set_category( CAT_INTERFACE ) /* choose relevant category, default categories in vlc/include/vlc_configuration.h */&lt;br /&gt;
&lt;br /&gt;
    add_integer( &amp;quot;test-angle&amp;quot;, 1, &amp;quot;DVD Angle&amp;quot;, &amp;quot;Default DVD Angle&amp;quot;, false)&lt;br /&gt;
vlc_module_end ()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
/*****************************************************************************&lt;br /&gt;
 * Open: initialize interface&lt;br /&gt;
 *****************************************************************************/&lt;br /&gt;
static int Open( vlc_object_t *p_this )&lt;br /&gt;
{&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/*****************************************************************************&lt;br /&gt;
 * Close: destroy interface&lt;br /&gt;
 *****************************************************************************/&lt;br /&gt;
static void Close( vlc_object_t *p_this )&lt;br /&gt;
{&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== How to write the module, aka Explanations about the empty module ==&lt;br /&gt;
&lt;br /&gt;
=== Module Descriptor  ===&lt;br /&gt;
&lt;br /&gt;
A {{VLC}} module &#039;&#039;&#039;must&#039;&#039;&#039; include a &#039;&#039;description&#039;&#039; of itself, and the &#039;&#039;parameters&#039;&#039; it accepts. &lt;br /&gt;
&lt;br /&gt;
The module descriptor begins with: &lt;br /&gt;
&amp;lt;pre&amp;gt;vlc_module_begin();&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
You should set some basic information about your module: &lt;br /&gt;
&amp;lt;pre&amp;gt;    set_shortname( _(&amp;quot;DVD without menus&amp;quot;) );&lt;br /&gt;
    set_description( _(&amp;quot;DVDRead Input&amp;quot;) );&lt;br /&gt;
    set_category( CAT_INPUT );&lt;br /&gt;
    set_subcategory( SUBCAT_INPUT_ACCESS );&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
&#039;&#039;Note&#039;&#039; the use of _(&amp;quot;&amp;quot;) to create a string that needs to be translated. &lt;br /&gt;
&lt;br /&gt;
==== Capability and score ====&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;The capability is key to the module loading&#039;&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
It defines the type of module we are dealing with, whether it is an access, a demux, a decoder or else... &lt;br /&gt;
&lt;br /&gt;
Now is the time to &#039;&#039;&#039;re-read [[Documentation:VLC Modules Loading#How_does_the_loading_of_modules_happens|how VLC loads modules]]&#039;&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*If VLC needs to load a specific name, it will load it by its name and VLC directly opens this module &lt;br /&gt;
*If VLC needs a type of modules (&amp;quot;I need a decoder&amp;quot;), VLC will load all modules matching this capability by decreasing score order until one modules&#039;s Open() function (see later) returns VLC_SUCCESS.&lt;br /&gt;
&lt;br /&gt;
See the major types of [[Documentation:VLC Modules Loading#Major_Capabilities_of_Modules|capabilities of VLC]]. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Score&#039;&#039;&#039; should be an integer, and related to other scores in the same category. Score 0 is a [[Documentation:VLC_Modules_Loading#Score_of_0|special case]].&lt;br /&gt;
&lt;br /&gt;
Definition &#039;&#039;&#039;Example&#039;&#039;&#039;: &lt;br /&gt;
&amp;lt;pre&amp;gt;   set_capability( &amp;quot;testing&amp;quot;, 10 )&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
This defines a module of &amp;quot;testing&amp;quot; capability and a score of 10.&lt;br /&gt;
&lt;br /&gt;
==== Configuration Categories and SubCategories  ====&lt;br /&gt;
&lt;br /&gt;
You should use &#039;&#039;&#039;one&#039;&#039;&#039; of the &#039;&#039;&#039;predefined categories&#039;&#039;&#039; for configuration. &lt;br /&gt;
&lt;br /&gt;
The Configuration Categories and Subcategories define &#039;&#039;&#039;where&#039;&#039;&#039; the module will appear in the &#039;&#039;&#039;preferences&#039;&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
The configuration categories include: &lt;br /&gt;
&lt;br /&gt;
*CAT_INTERFACE &lt;br /&gt;
*CAT_AUDIO &lt;br /&gt;
*CAT_VIDEO &lt;br /&gt;
*CAT_INPUT &lt;br /&gt;
*CAT_SOUT &lt;br /&gt;
*CAT_ADVANCED &lt;br /&gt;
*CAT_PLAYLIST&lt;br /&gt;
&lt;br /&gt;
You should use one of &#039;&#039;&#039;predefined sub-categories&#039;&#039;&#039; too. &lt;br /&gt;
&lt;br /&gt;
See {{VLCSourceFile|name=include/vlc_configuration.h}} for definition of all configuration categories and sub-categories. &lt;br /&gt;
&lt;br /&gt;
==== Configuration and Parameters Options  ====&lt;br /&gt;
&lt;br /&gt;
You will need options for your module. Defining new options is easy. &lt;br /&gt;
&lt;br /&gt;
All options definitions take the following argument list: &lt;br /&gt;
&amp;lt;pre&amp;gt; add_integer(name, value, text, longtext, advanced) &amp;lt;/pre&amp;gt; &lt;br /&gt;
*&#039;&#039;&#039;name&#039;&#039;&#039; is the string that identifies this parameter in the configuration. This name is used at the command prompt to set the configuration value. &lt;br /&gt;
*&#039;&#039;&#039;value&#039;&#039;&#039; is the default value for this parameter, &lt;br /&gt;
*&#039;&#039;&#039;text&#039;&#039;&#039; A short description of the parameter, use _(&amp;quot;&amp;quot;) to create a string that needs to be translated, &lt;br /&gt;
*&#039;&#039;&#039;longtext&#039;&#039;&#039; A complete description of the parameter, use _(&amp;quot;&amp;quot;) to create a string that needs to be translated,&lt;br /&gt;
*&#039;&#039;&#039;advanced&#039;&#039;&#039; Boolean, ADVanced Configuration. If TRUE, this parameter will only be displayed when using the --advanced flag. e.g.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt; You may add the following options/parameter types to your module: &lt;br /&gt;
&lt;br /&gt;
*add_integer, &lt;br /&gt;
*add_string, &lt;br /&gt;
*add_float, &lt;br /&gt;
*add_bool, &lt;br /&gt;
*add_key, &lt;br /&gt;
*add_file, &lt;br /&gt;
*add_directory,&lt;br /&gt;
&lt;br /&gt;
For complete definitions, see {{VLCSourceFile|name=include/vlc_plugin.h}}&lt;br /&gt;
&lt;br /&gt;
==== Callback  ====&lt;br /&gt;
&lt;br /&gt;
The opening and closing static functions, detailed afterwards, need to be defined in the descriptor, so VLC can discuss with the module.&lt;br /&gt;
&lt;br /&gt;
=== Open(vlc_object_t *)  ===&lt;br /&gt;
&lt;br /&gt;
The most important function of a module, is the opening: the usually-named Open() function. &lt;br /&gt;
&amp;lt;pre&amp;gt;static int  Open ( vlc_object_t * );&amp;lt;/pre&amp;gt; &lt;br /&gt;
The Open() function is called when the VLC core tries to open the module, and wants to load it. &lt;br /&gt;
&lt;br /&gt;
During Open(), setup of structures, devices or I/O, checks should be done. A working open should return VLC_SUCCESS. In all other cases, it will not be considered as loaded.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Open()&#039;&#039;&#039; function is expected to allocate private data (if any), and set up the private structure.&lt;br /&gt;
&lt;br /&gt;
If the Opening fails, you need to clean-up your own structures.&lt;br /&gt;
&lt;br /&gt;
=== Close(vlc_object_t *)  ===&lt;br /&gt;
The second most important function of a module, is the closing: the usually-named Close() function.&lt;br /&gt;
&amp;lt;pre&amp;gt;static int  Close ( vlc_object_t * );&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Close() function is called when the VLC core tries to close or unload an &#039;&#039;&#039;already-loaded&#039;&#039;&#039; module.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NB:&#039;&#039;&#039; If the Open() function failed, Close() will not get called.&lt;br /&gt;
&lt;br /&gt;
During Close(), close devices or I/O and cleaning of structures should be done. Do not leak memory here!&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Close()&#039;&#039;&#039; function should deallocate private data.&lt;br /&gt;
&lt;br /&gt;
== SubModules  ==&lt;br /&gt;
&lt;br /&gt;
Submodules, created in some modules with &lt;br /&gt;
&lt;br /&gt;
 add_submodule()&lt;br /&gt;
&lt;br /&gt;
work exactly the same way as modules. They are useful to parent modules, and to share code between modules.&lt;br /&gt;
&lt;br /&gt;
The submodules will be separated in the cache, and will be loaded by VLC in the exact same way as a module.&lt;br /&gt;
&lt;br /&gt;
== Modules types ==&lt;br /&gt;
&lt;br /&gt;
Depending on the module capability, you will need more information, about the necessary functions to implement.&lt;br /&gt;
&lt;br /&gt;
We will detail those here:&lt;br /&gt;
* [[Documentation:Hacker&#039;s_Guide/Access|Access]]&lt;br /&gt;
* [[Documentation:Hacker&#039;s_Guide/Demux|Demux]]&lt;br /&gt;
* [[Documentation:Hacker&#039;s_Guide/Access_Demux|Access_Demux]]&lt;br /&gt;
* Decoder&lt;br /&gt;
* Interface&lt;br /&gt;
* [[Documentation:Hacker&#039;s_Guide/Video_Filters|Video Filter]]&lt;br /&gt;
* [[Documentation:Hacker&#039;s_Guide/Audio_Filters|Audio Filter]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{Documentation}} &lt;br /&gt;
&lt;br /&gt;
[[Category:Coding]]&lt;/div&gt;</summary>
		<author><name>Technologicat</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=Hacker_Guide/Video_Filters&amp;diff=19078</id>
		<title>Hacker Guide/Video Filters</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=Hacker_Guide/Video_Filters&amp;diff=19078"/>
		<updated>2011-05-09T02:13:15Z</updated>

		<summary type="html">&lt;p&gt;Technologicat: /* Individual filter docs */ highlight&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is the [[Documentation:Hacker&#039;s_Guide|Hacker&#039;s Guide]] for video filters (&#039;&#039;&#039;video filter2&#039;&#039;&#039;, VLC 1.2).&lt;br /&gt;
&lt;br /&gt;
== Location in source tree ==&lt;br /&gt;
&lt;br /&gt;
Look in {{VLCSourceFile|name=modules/video_filter/}}.&lt;br /&gt;
&lt;br /&gt;
See {{VLCSourceFile|name=modules/video_filter/Modules.am}} for a list of video filters currently in VLC, and which source files belong to which.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Adding new source files ==&lt;br /&gt;
&lt;br /&gt;
Want to develop a new filter or add new source files to an existing one?&lt;br /&gt;
&lt;br /&gt;
The file {{VLCSourceFile|name=modules/video_filter/Modules.am}} tells the build system which source files go into which filter, so go ahead and update it. Note that the indentation in the file uses a tab (ASCII 0x09), not spaces.&lt;br /&gt;
&lt;br /&gt;
When done, you&#039;ll probably need to go to the root of your VLC source tree, and do something akin to the following:&lt;br /&gt;
* &amp;lt;pre&amp;gt;find . -name .deps -exec rm -rf \{\} \;&amp;lt;/pre&amp;gt;&lt;br /&gt;
* &amp;lt;pre&amp;gt;./bootstrap&amp;lt;/pre&amp;gt;&lt;br /&gt;
* &amp;lt;pre&amp;gt;./configure&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This ensures that the build system finds your new files. Then you can go on as usual:&lt;br /&gt;
* &amp;lt;pre&amp;gt;./compile&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Individual filter docs ==&lt;br /&gt;
&lt;br /&gt;
Some filters may have their own [[Documentation:Hacker&#039;s Guide|Hacker&#039;s Guide]] sections.&lt;br /&gt;
&lt;br /&gt;
Currently, the &#039;&#039;&#039;deinterlace&#039;&#039;&#039; filter has both a [[Documentation:Hacker&#039;s Guide/Video Filters/Deinterlace|Hacker&#039;s Guide section]] and [[Deinterlace|user documentation]] with some useful technical information.&lt;br /&gt;
&lt;br /&gt;
== Programming conventions and tips ==&lt;br /&gt;
&lt;br /&gt;
VLC video filters are usually written in C99, like the rest of VLC. The AtmoLight plugin uses C++, though.&lt;br /&gt;
&lt;br /&gt;
The usual stuff holds here too:&lt;br /&gt;
* Use &#039;&#039;&#039;assert()&#039;&#039;&#039; for checking conditions that, in presence of no bugs, always hold.&lt;br /&gt;
** &#039;&#039;Don&#039;t&#039;&#039; use &#039;&#039;&#039;assert()&#039;&#039;&#039; for checking stuff that may fail at runtime. Handle errors gracefully.&lt;br /&gt;
* Keep your code readable. Make private functions when it simplifies things.&lt;br /&gt;
* Prefer 80 characters per line at maximum, if possible.&lt;br /&gt;
&lt;br /&gt;
Particularly for video filters: keep in mind that this is low-level stuff and needs to be fast.&lt;br /&gt;
* How fast? Note that the source may be interlaced, and someone may have thrown a framerate doubler into the filter chain... this means that for a 60i signal, the entire processing chain from decode to render has about 16ms per output frame.&lt;br /&gt;
* Keep the required memory bandwidth down.&lt;br /&gt;
** Don&#039;t copy whole pictures unless you absolutely must. Moving pixels costs time.&lt;br /&gt;
** Allocate an output picture and render directly into it.&lt;br /&gt;
** If you need more than one pass, do in-place processing in the subsequent ones if possible.&lt;br /&gt;
** If your processing cannot avoid multiple passes, consider doing all passes for a picture line (or a few) at a time, instead of iterating over the whole picture separately for each pass. This will help to keep down the pressure on the CPU cache.&lt;br /&gt;
* Consider writing the inner processing loops in vectorized inline assembly, such as MMX. This can often gain a factor of 2-8x in speed, depending on how much and what kind of processing your algorithm needs.&lt;br /&gt;
&lt;br /&gt;
== Some notes on the API ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: See {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.c}} and {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.h}} for an example of everything discussed in this section. See also the [[Documentation:Hacker&#039;s Guide/Video Filters/Deinterlace|Deinterlace Hacker&#039;s Guide]] for some further details.&lt;br /&gt;
&lt;br /&gt;
The video filters use an object-based model. Calls to the filter will come with an instance pointer, so each filter instance can keep local data.&lt;br /&gt;
&lt;br /&gt;
Usually, each filter defines its own internal data structure called &#039;&#039;&#039;filter_sys_t&#039;&#039;&#039;. It is completely private to the filter.&lt;br /&gt;
&lt;br /&gt;
The API for video filters in VLC 1.2 is called &#039;&#039;&#039;video filter2&#039;&#039;&#039;. This requires the functions &#039;&#039;&#039;Open()&#039;&#039;&#039; and &#039;&#039;&#039;Close()&#039;&#039;&#039;. The &#039;&#039;&#039;Open()&#039;&#039;&#039; function is expected to allocate private data (if any), and set up the filter structure with pointers to a frame processing function (&#039;&#039;&#039;p_filter-&amp;gt;pf_video_filter&#039;&#039;&#039;, which is the actual filter), a flush function (&#039;&#039;&#039;p_filter-&amp;gt;pf_video_flush&#039;&#039;&#039;), and a mouse event function (&#039;&#039;&#039;p_filter-&amp;gt;pf_video_mouse&#039;&#039;&#039;). The &#039;&#039;&#039;Close()&#039;&#039;&#039; function should deallocate private data.&lt;br /&gt;
&lt;br /&gt;
The frame processing function takes a frame as input (&#039;&#039;&#039;picture_t*&#039;&#039;&#039;, {{VLCSourceFile|name=include/vlc_picture.h}}), and optionally outputs one or more frames (&#039;&#039;&#039;picture_t*&#039;&#039;&#039;) as a linked list. The usual case is one frame in, one frame out, but this is not a requirement. (See framerate doublers and IVTC in the deinterlace module for counterexamples.)&lt;br /&gt;
&lt;br /&gt;
If you do not wish to output a frame at a particular call to your processing function, you can return &#039;&#039;&#039;NULL&#039;&#039;&#039;. If you wish to output several, make a linked list by using the &#039;&#039;&#039;next&#039;&#039;&#039; member of &#039;&#039;&#039;picture_t&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
You don&#039;t have to necessarily output the &#039;&#039;same&#039;&#039; frame (after processing) that just came in. You can keep a private input frame history in your &#039;&#039;&#039;filter_sys_t&#039;&#039;&#039;, pick the base frame for your output from that, and adjust the PTSs (presentation timestamps, member &#039;&#039;&#039;date&#039;&#039;&#039; in &#039;&#039;&#039;picture_t&#039;&#039;&#039;) of your output as you deem necessary. The deinterlacer provides an example of how to do this.&lt;br /&gt;
&lt;br /&gt;
Note however that there may be other filters in the chain that already set up an offset; this leaves less time (until the designated PTS) for the rest of the filters to do their processing.&lt;br /&gt;
&lt;br /&gt;
Be sure to allocate your output pictures using &amp;lt;pre&amp;gt;picture_t *p_outpic = filter_NewPicture( p_filter );&amp;lt;/pre&amp;gt;&lt;br /&gt;
This function requests a new picture from the private pool (see {{VLCSourceFile|name=src/video_output/vout_wrapper.c}}). This is very important! Be aware that pictures created like&lt;br /&gt;
&amp;lt;pre&amp;gt;picture_t *p_temp = picture_NewFromFormat( &amp;amp;p_input_pic-&amp;gt;format );&amp;lt;/pre&amp;gt;&lt;br /&gt;
lack a shared memory context (in Linux; or the equivalent in other OS), and thus cannot be passed to the video output logic. If your filter attempts to do so, VLC will crash.&lt;br /&gt;
&lt;br /&gt;
If you need temporary pictures, you can allocate those using &#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;, but remember to &#039;&#039;always create output pictures using &#039;&#039;&#039;filter_NewPicture()&#039;&#039;&#039;&#039;&#039;. Here an &#039;&#039;output picture&#039;&#039; is defined as a picture which goes out from the filter to the caller.&lt;br /&gt;
&lt;br /&gt;
There is a limit to the number of simultaneous picture slots available in the private pool. Currently (&amp;lt;nowiki&amp;gt;[71992c5fbc75ee2c94cd2a3ab1aaca70bfc688a9]&amp;lt;/nowiki&amp;gt;) this is 3 pictures for the filter layer. See constant &#039;&#039;&#039;private_picture&#039;&#039;&#039; in {{VLCSourceFile|name=src/video_output/vout_wrapper.c}}. If you try to allocate more output pictures than this (during a single processing call), the allocation will fail.&lt;br /&gt;
&lt;br /&gt;
In VLC 1.2, the video format (resolution, chroma) never changes on the fly. The whole filter chain is &#039;&#039;&#039;Close()&#039;&#039;&#039;d and then &#039;&#039;&#039;Open()&#039;&#039;&#039;ed again if the format changes.&lt;br /&gt;
&lt;br /&gt;
Note that it &#039;&#039;is&#039;&#039; allowed to flush the filter without closing it. This actually happens under some circumstances, so &#039;&#039;don&#039;t deallocate stuff in your flush function&#039;&#039;. Rather, allocate dynamic resources in &#039;&#039;&#039;Open()&#039;&#039;&#039;, and deallocate them in &#039;&#039;&#039;Close()&#039;&#039;&#039; (or in private functions called from those).&lt;br /&gt;
&lt;br /&gt;
Supported input and output formats are left up to each filter. The usual thing is to support YUV formats, e.g. I420, J420, YV12, I422 and J422. See {{VLCSourceFile|name=include/vlc_fourcc.h}}.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Pitch, visible pitch, et al. ==&lt;br /&gt;
&lt;br /&gt;
Important to know:&lt;br /&gt;
&lt;br /&gt;
* i_pitch = number of (macro)pixels on one line&lt;br /&gt;
* i_visible_pitch = number of (macro)pixels on one line, adjusted for memory alignment constraints etc. (see below)&lt;br /&gt;
&lt;br /&gt;
Note that the pitches may be different for each plane, and indeed in YUV formats the luma (&#039;&#039;&#039;Y_PLANE&#039;&#039;&#039;) and chroma (&#039;&#039;&#039;U_PLANE&#039;&#039;&#039;, &#039;&#039;&#039;V_PLANE&#039;&#039;&#039;) have different pitches due to chroma subsampling. (In 4:2:0 formats, the number of lines differs, too.)&lt;br /&gt;
&lt;br /&gt;
Pitches also tend to slightly differ depending on how the picture was allocated, even if the visible size is the same. The input picture to the filter may have one pitch, temporary pictures (&#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;) another, and output pictures (&#039;&#039;&#039;filter_NewPicture()&#039;&#039;&#039;) yet another.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Be sure to always use the correct pitch when you handle the pixels of a picture.&#039;&#039; That is, always use the &#039;&#039;&#039;i_pitch&#039;&#039;&#039; member of the actual &#039;&#039;&#039;plane_t&#039;&#039;&#039; you are working on.&lt;br /&gt;
&lt;br /&gt;
If you absolutely need matching pitches (e.g. if you are glueing in processing code from another GPL-compatible project which assumes this and you don&#039;t want to rewrite it...), consider making temporary copies with &#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;. See {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.c}} (the history mechanism &amp;lt;nowiki&amp;gt;pp_history[]&amp;lt;/nowiki&amp;gt;) and {{VLCSourceFile|name=modules/video_filter/deinterlace/algo_yadif.c}} (its usage) for an example.&lt;br /&gt;
&lt;br /&gt;
If you are processing pixels from one picture to another, the safe thing to do is to take the smallest &#039;&#039;&#039;i_visible_pitch&#039;&#039;&#039;, and loop from x = 0 until the visible pitch has been reached, but use the individual &#039;&#039;&#039;i_pitch&#039;&#039;&#039;es for computing the pixel locations. See {{VLCSourceFile|name=modules/video_filter/deinterlace/helpers.c}} for examples.&lt;br /&gt;
&lt;br /&gt;
=== video_format_t vs. plane_t ===&lt;br /&gt;
&lt;br /&gt;
In &#039;&#039;&#039;video_format_t&#039;&#039;&#039;, the &#039;&#039;&#039;i_visible_width&#039;&#039;&#039; and &#039;&#039;&#039;i_visible_height&#039;&#039;&#039; members go with &#039;&#039;&#039;i_x_offset&#039;&#039;&#039; and &#039;&#039;&#039;i_y_offset&#039;&#039;&#039;, but they are not related to &#039;&#039;&#039;plane_t::i_visible_*&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;plane_t::i_visible_*&#039;&#039;&#039; fields are there to know which part of the memory planes can at most be displayed. Usually these are different from the whole surface due to memory alignment constraints (like mod 16 for SSE2 or to be aligned on a macroblock). Those values are decided when the picture is allocated and they usually don&#039;t change for a given picture pointer (but they can change, like in direct3d buffers).&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;video_format_t:i_visible_width/height&#039;&#039;&#039; and &#039;&#039;&#039;i_x/y_offset&#039;&#039;&#039; are more a &#039;hint&#039; regarding what will be actually displayed. A filter should update &#039;&#039;&#039;filter_t::fmt_out&#039;&#039;&#039; if needed to ensure that the allocated pictures get the right value. A filter should, however, not limit its processing to this area, because VLC supports dynamic cropping.&lt;br /&gt;
&lt;br /&gt;
Thus, the correct thing to do in a filter is to process the whole picture area, or at least the first i_visible_* lines and pixels &#039;&#039;according to the &#039;&#039;&#039;plane_t&#039;&#039;&#039;s&#039;&#039;. Filters do not need to care about margin positioning or that there even exists such a thing as margins.&lt;br /&gt;
&lt;br /&gt;
== Disclaimer ==&lt;br /&gt;
&lt;br /&gt;
The information is mostly based on a few months&#039; hacking on the deinterlacer.&lt;br /&gt;
&lt;br /&gt;
This page is still a stub. Please add new relevant stuff.&lt;br /&gt;
&lt;br /&gt;
Also, the stuff that already exists could use better organization and formatting.&lt;br /&gt;
&lt;br /&gt;
{{Documentation}}&lt;/div&gt;</summary>
		<author><name>Technologicat</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=Hacker_Guide/Video_Filters&amp;diff=19077</id>
		<title>Hacker Guide/Video Filters</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=Hacker_Guide/Video_Filters&amp;diff=19077"/>
		<updated>2011-05-09T02:12:12Z</updated>

		<summary type="html">&lt;p&gt;Technologicat: /* Adding new source files */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is the [[Documentation:Hacker&#039;s_Guide|Hacker&#039;s Guide]] for video filters (&#039;&#039;&#039;video filter2&#039;&#039;&#039;, VLC 1.2).&lt;br /&gt;
&lt;br /&gt;
== Location in source tree ==&lt;br /&gt;
&lt;br /&gt;
Look in {{VLCSourceFile|name=modules/video_filter/}}.&lt;br /&gt;
&lt;br /&gt;
See {{VLCSourceFile|name=modules/video_filter/Modules.am}} for a list of video filters currently in VLC, and which source files belong to which.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Adding new source files ==&lt;br /&gt;
&lt;br /&gt;
Want to develop a new filter or add new source files to an existing one?&lt;br /&gt;
&lt;br /&gt;
The file {{VLCSourceFile|name=modules/video_filter/Modules.am}} tells the build system which source files go into which filter, so go ahead and update it. Note that the indentation in the file uses a tab (ASCII 0x09), not spaces.&lt;br /&gt;
&lt;br /&gt;
When done, you&#039;ll probably need to go to the root of your VLC source tree, and do something akin to the following:&lt;br /&gt;
* &amp;lt;pre&amp;gt;find . -name .deps -exec rm -rf \{\} \;&amp;lt;/pre&amp;gt;&lt;br /&gt;
* &amp;lt;pre&amp;gt;./bootstrap&amp;lt;/pre&amp;gt;&lt;br /&gt;
* &amp;lt;pre&amp;gt;./configure&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This ensures that the build system finds your new files. Then you can go on as usual:&lt;br /&gt;
* &amp;lt;pre&amp;gt;./compile&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Individual filter docs ==&lt;br /&gt;
&lt;br /&gt;
Some filters may have their own [[Documentation:Hacker&#039;s Guide|Hacker&#039;s Guide]] sections.&lt;br /&gt;
&lt;br /&gt;
Currently, the deinterlace filter has both a [[Documentation:Hacker&#039;s Guide/Video Filters/Deinterlace|Hacker&#039;s Guide section]] and [[Deinterlace|user documentation]] with some useful technical information.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Programming conventions and tips ==&lt;br /&gt;
&lt;br /&gt;
VLC video filters are usually written in C99, like the rest of VLC. The AtmoLight plugin uses C++, though.&lt;br /&gt;
&lt;br /&gt;
The usual stuff holds here too:&lt;br /&gt;
* Use &#039;&#039;&#039;assert()&#039;&#039;&#039; for checking conditions that, in presence of no bugs, always hold.&lt;br /&gt;
** &#039;&#039;Don&#039;t&#039;&#039; use &#039;&#039;&#039;assert()&#039;&#039;&#039; for checking stuff that may fail at runtime. Handle errors gracefully.&lt;br /&gt;
* Keep your code readable. Make private functions when it simplifies things.&lt;br /&gt;
* Prefer 80 characters per line at maximum, if possible.&lt;br /&gt;
&lt;br /&gt;
Particularly for video filters: keep in mind that this is low-level stuff and needs to be fast.&lt;br /&gt;
* How fast? Note that the source may be interlaced, and someone may have thrown a framerate doubler into the filter chain... this means that for a 60i signal, the entire processing chain from decode to render has about 16ms per output frame.&lt;br /&gt;
* Keep the required memory bandwidth down.&lt;br /&gt;
** Don&#039;t copy whole pictures unless you absolutely must. Moving pixels costs time.&lt;br /&gt;
** Allocate an output picture and render directly into it.&lt;br /&gt;
** If you need more than one pass, do in-place processing in the subsequent ones if possible.&lt;br /&gt;
** If your processing cannot avoid multiple passes, consider doing all passes for a picture line (or a few) at a time, instead of iterating over the whole picture separately for each pass. This will help to keep down the pressure on the CPU cache.&lt;br /&gt;
* Consider writing the inner processing loops in vectorized inline assembly, such as MMX. This can often gain a factor of 2-8x in speed, depending on how much and what kind of processing your algorithm needs.&lt;br /&gt;
&lt;br /&gt;
== Some notes on the API ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: See {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.c}} and {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.h}} for an example of everything discussed in this section. See also the [[Documentation:Hacker&#039;s Guide/Video Filters/Deinterlace|Deinterlace Hacker&#039;s Guide]] for some further details.&lt;br /&gt;
&lt;br /&gt;
The video filters use an object-based model. Calls to the filter will come with an instance pointer, so each filter instance can keep local data.&lt;br /&gt;
&lt;br /&gt;
Usually, each filter defines its own internal data structure called &#039;&#039;&#039;filter_sys_t&#039;&#039;&#039;. It is completely private to the filter.&lt;br /&gt;
&lt;br /&gt;
The API for video filters in VLC 1.2 is called &#039;&#039;&#039;video filter2&#039;&#039;&#039;. This requires the functions &#039;&#039;&#039;Open()&#039;&#039;&#039; and &#039;&#039;&#039;Close()&#039;&#039;&#039;. The &#039;&#039;&#039;Open()&#039;&#039;&#039; function is expected to allocate private data (if any), and set up the filter structure with pointers to a frame processing function (&#039;&#039;&#039;p_filter-&amp;gt;pf_video_filter&#039;&#039;&#039;, which is the actual filter), a flush function (&#039;&#039;&#039;p_filter-&amp;gt;pf_video_flush&#039;&#039;&#039;), and a mouse event function (&#039;&#039;&#039;p_filter-&amp;gt;pf_video_mouse&#039;&#039;&#039;). The &#039;&#039;&#039;Close()&#039;&#039;&#039; function should deallocate private data.&lt;br /&gt;
&lt;br /&gt;
The frame processing function takes a frame as input (&#039;&#039;&#039;picture_t*&#039;&#039;&#039;, {{VLCSourceFile|name=include/vlc_picture.h}}), and optionally outputs one or more frames (&#039;&#039;&#039;picture_t*&#039;&#039;&#039;) as a linked list. The usual case is one frame in, one frame out, but this is not a requirement. (See framerate doublers and IVTC in the deinterlace module for counterexamples.)&lt;br /&gt;
&lt;br /&gt;
If you do not wish to output a frame at a particular call to your processing function, you can return &#039;&#039;&#039;NULL&#039;&#039;&#039;. If you wish to output several, make a linked list by using the &#039;&#039;&#039;next&#039;&#039;&#039; member of &#039;&#039;&#039;picture_t&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
You don&#039;t have to necessarily output the &#039;&#039;same&#039;&#039; frame (after processing) that just came in. You can keep a private input frame history in your &#039;&#039;&#039;filter_sys_t&#039;&#039;&#039;, pick the base frame for your output from that, and adjust the PTSs (presentation timestamps, member &#039;&#039;&#039;date&#039;&#039;&#039; in &#039;&#039;&#039;picture_t&#039;&#039;&#039;) of your output as you deem necessary. The deinterlacer provides an example of how to do this.&lt;br /&gt;
&lt;br /&gt;
Note however that there may be other filters in the chain that already set up an offset; this leaves less time (until the designated PTS) for the rest of the filters to do their processing.&lt;br /&gt;
&lt;br /&gt;
Be sure to allocate your output pictures using &amp;lt;pre&amp;gt;picture_t *p_outpic = filter_NewPicture( p_filter );&amp;lt;/pre&amp;gt;&lt;br /&gt;
This function requests a new picture from the private pool (see {{VLCSourceFile|name=src/video_output/vout_wrapper.c}}). This is very important! Be aware that pictures created like&lt;br /&gt;
&amp;lt;pre&amp;gt;picture_t *p_temp = picture_NewFromFormat( &amp;amp;p_input_pic-&amp;gt;format );&amp;lt;/pre&amp;gt;&lt;br /&gt;
lack a shared memory context (in Linux; or the equivalent in other OS), and thus cannot be passed to the video output logic. If your filter attempts to do so, VLC will crash.&lt;br /&gt;
&lt;br /&gt;
If you need temporary pictures, you can allocate those using &#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;, but remember to &#039;&#039;always create output pictures using &#039;&#039;&#039;filter_NewPicture()&#039;&#039;&#039;&#039;&#039;. Here an &#039;&#039;output picture&#039;&#039; is defined as a picture which goes out from the filter to the caller.&lt;br /&gt;
&lt;br /&gt;
There is a limit to the number of simultaneous picture slots available in the private pool. Currently (&amp;lt;nowiki&amp;gt;[71992c5fbc75ee2c94cd2a3ab1aaca70bfc688a9]&amp;lt;/nowiki&amp;gt;) this is 3 pictures for the filter layer. See constant &#039;&#039;&#039;private_picture&#039;&#039;&#039; in {{VLCSourceFile|name=src/video_output/vout_wrapper.c}}. If you try to allocate more output pictures than this (during a single processing call), the allocation will fail.&lt;br /&gt;
&lt;br /&gt;
In VLC 1.2, the video format (resolution, chroma) never changes on the fly. The whole filter chain is &#039;&#039;&#039;Close()&#039;&#039;&#039;d and then &#039;&#039;&#039;Open()&#039;&#039;&#039;ed again if the format changes.&lt;br /&gt;
&lt;br /&gt;
Note that it &#039;&#039;is&#039;&#039; allowed to flush the filter without closing it. This actually happens under some circumstances, so &#039;&#039;don&#039;t deallocate stuff in your flush function&#039;&#039;. Rather, allocate dynamic resources in &#039;&#039;&#039;Open()&#039;&#039;&#039;, and deallocate them in &#039;&#039;&#039;Close()&#039;&#039;&#039; (or in private functions called from those).&lt;br /&gt;
&lt;br /&gt;
Supported input and output formats are left up to each filter. The usual thing is to support YUV formats, e.g. I420, J420, YV12, I422 and J422. See {{VLCSourceFile|name=include/vlc_fourcc.h}}.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Pitch, visible pitch, et al. ==&lt;br /&gt;
&lt;br /&gt;
Important to know:&lt;br /&gt;
&lt;br /&gt;
* i_pitch = number of (macro)pixels on one line&lt;br /&gt;
* i_visible_pitch = number of (macro)pixels on one line, adjusted for memory alignment constraints etc. (see below)&lt;br /&gt;
&lt;br /&gt;
Note that the pitches may be different for each plane, and indeed in YUV formats the luma (&#039;&#039;&#039;Y_PLANE&#039;&#039;&#039;) and chroma (&#039;&#039;&#039;U_PLANE&#039;&#039;&#039;, &#039;&#039;&#039;V_PLANE&#039;&#039;&#039;) have different pitches due to chroma subsampling. (In 4:2:0 formats, the number of lines differs, too.)&lt;br /&gt;
&lt;br /&gt;
Pitches also tend to slightly differ depending on how the picture was allocated, even if the visible size is the same. The input picture to the filter may have one pitch, temporary pictures (&#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;) another, and output pictures (&#039;&#039;&#039;filter_NewPicture()&#039;&#039;&#039;) yet another.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Be sure to always use the correct pitch when you handle the pixels of a picture.&#039;&#039; That is, always use the &#039;&#039;&#039;i_pitch&#039;&#039;&#039; member of the actual &#039;&#039;&#039;plane_t&#039;&#039;&#039; you are working on.&lt;br /&gt;
&lt;br /&gt;
If you absolutely need matching pitches (e.g. if you are glueing in processing code from another GPL-compatible project which assumes this and you don&#039;t want to rewrite it...), consider making temporary copies with &#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;. See {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.c}} (the history mechanism &amp;lt;nowiki&amp;gt;pp_history[]&amp;lt;/nowiki&amp;gt;) and {{VLCSourceFile|name=modules/video_filter/deinterlace/algo_yadif.c}} (its usage) for an example.&lt;br /&gt;
&lt;br /&gt;
If you are processing pixels from one picture to another, the safe thing to do is to take the smallest &#039;&#039;&#039;i_visible_pitch&#039;&#039;&#039;, and loop from x = 0 until the visible pitch has been reached, but use the individual &#039;&#039;&#039;i_pitch&#039;&#039;&#039;es for computing the pixel locations. See {{VLCSourceFile|name=modules/video_filter/deinterlace/helpers.c}} for examples.&lt;br /&gt;
&lt;br /&gt;
=== video_format_t vs. plane_t ===&lt;br /&gt;
&lt;br /&gt;
In &#039;&#039;&#039;video_format_t&#039;&#039;&#039;, the &#039;&#039;&#039;i_visible_width&#039;&#039;&#039; and &#039;&#039;&#039;i_visible_height&#039;&#039;&#039; members go with &#039;&#039;&#039;i_x_offset&#039;&#039;&#039; and &#039;&#039;&#039;i_y_offset&#039;&#039;&#039;, but they are not related to &#039;&#039;&#039;plane_t::i_visible_*&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;plane_t::i_visible_*&#039;&#039;&#039; fields are there to know which part of the memory planes can at most be displayed. Usually these are different from the whole surface due to memory alignment constraints (like mod 16 for SSE2 or to be aligned on a macroblock). Those values are decided when the picture is allocated and they usually don&#039;t change for a given picture pointer (but they can change, like in direct3d buffers).&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;video_format_t:i_visible_width/height&#039;&#039;&#039; and &#039;&#039;&#039;i_x/y_offset&#039;&#039;&#039; are more a &#039;hint&#039; regarding what will be actually displayed. A filter should update &#039;&#039;&#039;filter_t::fmt_out&#039;&#039;&#039; if needed to ensure that the allocated pictures get the right value. A filter should, however, not limit its processing to this area, because VLC supports dynamic cropping.&lt;br /&gt;
&lt;br /&gt;
Thus, the correct thing to do in a filter is to process the whole picture area, or at least the first i_visible_* lines and pixels &#039;&#039;according to the &#039;&#039;&#039;plane_t&#039;&#039;&#039;s&#039;&#039;. Filters do not need to care about margin positioning or that there even exists such a thing as margins.&lt;br /&gt;
&lt;br /&gt;
== Disclaimer ==&lt;br /&gt;
&lt;br /&gt;
The information is mostly based on a few months&#039; hacking on the deinterlacer.&lt;br /&gt;
&lt;br /&gt;
This page is still a stub. Please add new relevant stuff.&lt;br /&gt;
&lt;br /&gt;
Also, the stuff that already exists could use better organization and formatting.&lt;br /&gt;
&lt;br /&gt;
{{Documentation}}&lt;/div&gt;</summary>
		<author><name>Technologicat</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=Hacker_Guide/Video_Filters&amp;diff=19076</id>
		<title>Hacker Guide/Video Filters</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=Hacker_Guide/Video_Filters&amp;diff=19076"/>
		<updated>2011-05-09T02:10:33Z</updated>

		<summary type="html">&lt;p&gt;Technologicat: Added a lead-in sentence at the beginning&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is the [[Documentation:Hacker&#039;s_Guide|Hacker&#039;s Guide]] for video filters (&#039;&#039;&#039;video filter2&#039;&#039;&#039;, VLC 1.2).&lt;br /&gt;
&lt;br /&gt;
== Location in source tree ==&lt;br /&gt;
&lt;br /&gt;
Look in {{VLCSourceFile|name=modules/video_filter/}}.&lt;br /&gt;
&lt;br /&gt;
See {{VLCSourceFile|name=modules/video_filter/Modules.am}} for a list of video filters currently in VLC, and which source files belong to which.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Adding new source files ==&lt;br /&gt;
&lt;br /&gt;
Want to develop a new filter or add new source files to an existing one?&lt;br /&gt;
&lt;br /&gt;
The file {{VLCSourceFile|name=modules/video_filter/Modules.am}} tells the build system which source files go into which filter, so go ahead and update it.&lt;br /&gt;
&lt;br /&gt;
When done, you&#039;ll probably need to go to the root of your VLC source tree, and do something akin to the following:&lt;br /&gt;
* &amp;lt;pre&amp;gt;find . -name .deps -exec rm -rf \{\} \;&amp;lt;/pre&amp;gt;&lt;br /&gt;
* &amp;lt;pre&amp;gt;./bootstrap&amp;lt;/pre&amp;gt;&lt;br /&gt;
* &amp;lt;pre&amp;gt;./configure&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This ensures that the build system finds your new files. Then you can go on as usual:&lt;br /&gt;
* &amp;lt;pre&amp;gt;./compile&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Individual filter docs ==&lt;br /&gt;
&lt;br /&gt;
Some filters may have their own [[Documentation:Hacker&#039;s Guide|Hacker&#039;s Guide]] sections.&lt;br /&gt;
&lt;br /&gt;
Currently, the deinterlace filter has both a [[Documentation:Hacker&#039;s Guide/Video Filters/Deinterlace|Hacker&#039;s Guide section]] and [[Deinterlace|user documentation]] with some useful technical information.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Programming conventions and tips ==&lt;br /&gt;
&lt;br /&gt;
VLC video filters are usually written in C99, like the rest of VLC. The AtmoLight plugin uses C++, though.&lt;br /&gt;
&lt;br /&gt;
The usual stuff holds here too:&lt;br /&gt;
* Use &#039;&#039;&#039;assert()&#039;&#039;&#039; for checking conditions that, in presence of no bugs, always hold.&lt;br /&gt;
** &#039;&#039;Don&#039;t&#039;&#039; use &#039;&#039;&#039;assert()&#039;&#039;&#039; for checking stuff that may fail at runtime. Handle errors gracefully.&lt;br /&gt;
* Keep your code readable. Make private functions when it simplifies things.&lt;br /&gt;
* Prefer 80 characters per line at maximum, if possible.&lt;br /&gt;
&lt;br /&gt;
Particularly for video filters: keep in mind that this is low-level stuff and needs to be fast.&lt;br /&gt;
* How fast? Note that the source may be interlaced, and someone may have thrown a framerate doubler into the filter chain... this means that for a 60i signal, the entire processing chain from decode to render has about 16ms per output frame.&lt;br /&gt;
* Keep the required memory bandwidth down.&lt;br /&gt;
** Don&#039;t copy whole pictures unless you absolutely must. Moving pixels costs time.&lt;br /&gt;
** Allocate an output picture and render directly into it.&lt;br /&gt;
** If you need more than one pass, do in-place processing in the subsequent ones if possible.&lt;br /&gt;
** If your processing cannot avoid multiple passes, consider doing all passes for a picture line (or a few) at a time, instead of iterating over the whole picture separately for each pass. This will help to keep down the pressure on the CPU cache.&lt;br /&gt;
* Consider writing the inner processing loops in vectorized inline assembly, such as MMX. This can often gain a factor of 2-8x in speed, depending on how much and what kind of processing your algorithm needs.&lt;br /&gt;
&lt;br /&gt;
== Some notes on the API ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: See {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.c}} and {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.h}} for an example of everything discussed in this section. See also the [[Documentation:Hacker&#039;s Guide/Video Filters/Deinterlace|Deinterlace Hacker&#039;s Guide]] for some further details.&lt;br /&gt;
&lt;br /&gt;
The video filters use an object-based model. Calls to the filter will come with an instance pointer, so each filter instance can keep local data.&lt;br /&gt;
&lt;br /&gt;
Usually, each filter defines its own internal data structure called &#039;&#039;&#039;filter_sys_t&#039;&#039;&#039;. It is completely private to the filter.&lt;br /&gt;
&lt;br /&gt;
The API for video filters in VLC 1.2 is called &#039;&#039;&#039;video filter2&#039;&#039;&#039;. This requires the functions &#039;&#039;&#039;Open()&#039;&#039;&#039; and &#039;&#039;&#039;Close()&#039;&#039;&#039;. The &#039;&#039;&#039;Open()&#039;&#039;&#039; function is expected to allocate private data (if any), and set up the filter structure with pointers to a frame processing function (&#039;&#039;&#039;p_filter-&amp;gt;pf_video_filter&#039;&#039;&#039;, which is the actual filter), a flush function (&#039;&#039;&#039;p_filter-&amp;gt;pf_video_flush&#039;&#039;&#039;), and a mouse event function (&#039;&#039;&#039;p_filter-&amp;gt;pf_video_mouse&#039;&#039;&#039;). The &#039;&#039;&#039;Close()&#039;&#039;&#039; function should deallocate private data.&lt;br /&gt;
&lt;br /&gt;
The frame processing function takes a frame as input (&#039;&#039;&#039;picture_t*&#039;&#039;&#039;, {{VLCSourceFile|name=include/vlc_picture.h}}), and optionally outputs one or more frames (&#039;&#039;&#039;picture_t*&#039;&#039;&#039;) as a linked list. The usual case is one frame in, one frame out, but this is not a requirement. (See framerate doublers and IVTC in the deinterlace module for counterexamples.)&lt;br /&gt;
&lt;br /&gt;
If you do not wish to output a frame at a particular call to your processing function, you can return &#039;&#039;&#039;NULL&#039;&#039;&#039;. If you wish to output several, make a linked list by using the &#039;&#039;&#039;next&#039;&#039;&#039; member of &#039;&#039;&#039;picture_t&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
You don&#039;t have to necessarily output the &#039;&#039;same&#039;&#039; frame (after processing) that just came in. You can keep a private input frame history in your &#039;&#039;&#039;filter_sys_t&#039;&#039;&#039;, pick the base frame for your output from that, and adjust the PTSs (presentation timestamps, member &#039;&#039;&#039;date&#039;&#039;&#039; in &#039;&#039;&#039;picture_t&#039;&#039;&#039;) of your output as you deem necessary. The deinterlacer provides an example of how to do this.&lt;br /&gt;
&lt;br /&gt;
Note however that there may be other filters in the chain that already set up an offset; this leaves less time (until the designated PTS) for the rest of the filters to do their processing.&lt;br /&gt;
&lt;br /&gt;
Be sure to allocate your output pictures using &amp;lt;pre&amp;gt;picture_t *p_outpic = filter_NewPicture( p_filter );&amp;lt;/pre&amp;gt;&lt;br /&gt;
This function requests a new picture from the private pool (see {{VLCSourceFile|name=src/video_output/vout_wrapper.c}}). This is very important! Be aware that pictures created like&lt;br /&gt;
&amp;lt;pre&amp;gt;picture_t *p_temp = picture_NewFromFormat( &amp;amp;p_input_pic-&amp;gt;format );&amp;lt;/pre&amp;gt;&lt;br /&gt;
lack a shared memory context (in Linux; or the equivalent in other OS), and thus cannot be passed to the video output logic. If your filter attempts to do so, VLC will crash.&lt;br /&gt;
&lt;br /&gt;
If you need temporary pictures, you can allocate those using &#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;, but remember to &#039;&#039;always create output pictures using &#039;&#039;&#039;filter_NewPicture()&#039;&#039;&#039;&#039;&#039;. Here an &#039;&#039;output picture&#039;&#039; is defined as a picture which goes out from the filter to the caller.&lt;br /&gt;
&lt;br /&gt;
There is a limit to the number of simultaneous picture slots available in the private pool. Currently (&amp;lt;nowiki&amp;gt;[71992c5fbc75ee2c94cd2a3ab1aaca70bfc688a9]&amp;lt;/nowiki&amp;gt;) this is 3 pictures for the filter layer. See constant &#039;&#039;&#039;private_picture&#039;&#039;&#039; in {{VLCSourceFile|name=src/video_output/vout_wrapper.c}}. If you try to allocate more output pictures than this (during a single processing call), the allocation will fail.&lt;br /&gt;
&lt;br /&gt;
In VLC 1.2, the video format (resolution, chroma) never changes on the fly. The whole filter chain is &#039;&#039;&#039;Close()&#039;&#039;&#039;d and then &#039;&#039;&#039;Open()&#039;&#039;&#039;ed again if the format changes.&lt;br /&gt;
&lt;br /&gt;
Note that it &#039;&#039;is&#039;&#039; allowed to flush the filter without closing it. This actually happens under some circumstances, so &#039;&#039;don&#039;t deallocate stuff in your flush function&#039;&#039;. Rather, allocate dynamic resources in &#039;&#039;&#039;Open()&#039;&#039;&#039;, and deallocate them in &#039;&#039;&#039;Close()&#039;&#039;&#039; (or in private functions called from those).&lt;br /&gt;
&lt;br /&gt;
Supported input and output formats are left up to each filter. The usual thing is to support YUV formats, e.g. I420, J420, YV12, I422 and J422. See {{VLCSourceFile|name=include/vlc_fourcc.h}}.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Pitch, visible pitch, et al. ==&lt;br /&gt;
&lt;br /&gt;
Important to know:&lt;br /&gt;
&lt;br /&gt;
* i_pitch = number of (macro)pixels on one line&lt;br /&gt;
* i_visible_pitch = number of (macro)pixels on one line, adjusted for memory alignment constraints etc. (see below)&lt;br /&gt;
&lt;br /&gt;
Note that the pitches may be different for each plane, and indeed in YUV formats the luma (&#039;&#039;&#039;Y_PLANE&#039;&#039;&#039;) and chroma (&#039;&#039;&#039;U_PLANE&#039;&#039;&#039;, &#039;&#039;&#039;V_PLANE&#039;&#039;&#039;) have different pitches due to chroma subsampling. (In 4:2:0 formats, the number of lines differs, too.)&lt;br /&gt;
&lt;br /&gt;
Pitches also tend to slightly differ depending on how the picture was allocated, even if the visible size is the same. The input picture to the filter may have one pitch, temporary pictures (&#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;) another, and output pictures (&#039;&#039;&#039;filter_NewPicture()&#039;&#039;&#039;) yet another.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Be sure to always use the correct pitch when you handle the pixels of a picture.&#039;&#039; That is, always use the &#039;&#039;&#039;i_pitch&#039;&#039;&#039; member of the actual &#039;&#039;&#039;plane_t&#039;&#039;&#039; you are working on.&lt;br /&gt;
&lt;br /&gt;
If you absolutely need matching pitches (e.g. if you are glueing in processing code from another GPL-compatible project which assumes this and you don&#039;t want to rewrite it...), consider making temporary copies with &#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;. See {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.c}} (the history mechanism &amp;lt;nowiki&amp;gt;pp_history[]&amp;lt;/nowiki&amp;gt;) and {{VLCSourceFile|name=modules/video_filter/deinterlace/algo_yadif.c}} (its usage) for an example.&lt;br /&gt;
&lt;br /&gt;
If you are processing pixels from one picture to another, the safe thing to do is to take the smallest &#039;&#039;&#039;i_visible_pitch&#039;&#039;&#039;, and loop from x = 0 until the visible pitch has been reached, but use the individual &#039;&#039;&#039;i_pitch&#039;&#039;&#039;es for computing the pixel locations. See {{VLCSourceFile|name=modules/video_filter/deinterlace/helpers.c}} for examples.&lt;br /&gt;
&lt;br /&gt;
=== video_format_t vs. plane_t ===&lt;br /&gt;
&lt;br /&gt;
In &#039;&#039;&#039;video_format_t&#039;&#039;&#039;, the &#039;&#039;&#039;i_visible_width&#039;&#039;&#039; and &#039;&#039;&#039;i_visible_height&#039;&#039;&#039; members go with &#039;&#039;&#039;i_x_offset&#039;&#039;&#039; and &#039;&#039;&#039;i_y_offset&#039;&#039;&#039;, but they are not related to &#039;&#039;&#039;plane_t::i_visible_*&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;plane_t::i_visible_*&#039;&#039;&#039; fields are there to know which part of the memory planes can at most be displayed. Usually these are different from the whole surface due to memory alignment constraints (like mod 16 for SSE2 or to be aligned on a macroblock). Those values are decided when the picture is allocated and they usually don&#039;t change for a given picture pointer (but they can change, like in direct3d buffers).&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;video_format_t:i_visible_width/height&#039;&#039;&#039; and &#039;&#039;&#039;i_x/y_offset&#039;&#039;&#039; are more a &#039;hint&#039; regarding what will be actually displayed. A filter should update &#039;&#039;&#039;filter_t::fmt_out&#039;&#039;&#039; if needed to ensure that the allocated pictures get the right value. A filter should, however, not limit its processing to this area, because VLC supports dynamic cropping.&lt;br /&gt;
&lt;br /&gt;
Thus, the correct thing to do in a filter is to process the whole picture area, or at least the first i_visible_* lines and pixels &#039;&#039;according to the &#039;&#039;&#039;plane_t&#039;&#039;&#039;s&#039;&#039;. Filters do not need to care about margin positioning or that there even exists such a thing as margins.&lt;br /&gt;
&lt;br /&gt;
== Disclaimer ==&lt;br /&gt;
&lt;br /&gt;
The information is mostly based on a few months&#039; hacking on the deinterlacer.&lt;br /&gt;
&lt;br /&gt;
This page is still a stub. Please add new relevant stuff.&lt;br /&gt;
&lt;br /&gt;
Also, the stuff that already exists could use better organization and formatting.&lt;br /&gt;
&lt;br /&gt;
{{Documentation}}&lt;/div&gt;</summary>
		<author><name>Technologicat</name></author>
	</entry>
	<entry>
		<id>https://wiki.videolan.org/index.php?title=Hacker_Guide/Video_Filters&amp;diff=19075</id>
		<title>Hacker Guide/Video Filters</title>
		<link rel="alternate" type="text/html" href="https://wiki.videolan.org/index.php?title=Hacker_Guide/Video_Filters&amp;diff=19075"/>
		<updated>2011-05-09T01:51:12Z</updated>

		<summary type="html">&lt;p&gt;Technologicat: /* Pitch, visible pitch, et al. */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Location in source tree ==&lt;br /&gt;
&lt;br /&gt;
Look in {{VLCSourceFile|name=modules/video_filter/}}.&lt;br /&gt;
&lt;br /&gt;
See {{VLCSourceFile|name=modules/video_filter/Modules.am}} for a list of video filters currently in VLC, and which source files belong to which.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Adding new source files ==&lt;br /&gt;
&lt;br /&gt;
Want to develop a new filter or add new source files to an existing one?&lt;br /&gt;
&lt;br /&gt;
The file {{VLCSourceFile|name=modules/video_filter/Modules.am}} tells the build system which source files go into which filter, so go ahead and update it.&lt;br /&gt;
&lt;br /&gt;
When done, you&#039;ll probably need to go to the root of your VLC source tree, and do something akin to the following:&lt;br /&gt;
* &amp;lt;pre&amp;gt;find . -name .deps -exec rm -rf \{\} \;&amp;lt;/pre&amp;gt;&lt;br /&gt;
* &amp;lt;pre&amp;gt;./bootstrap&amp;lt;/pre&amp;gt;&lt;br /&gt;
* &amp;lt;pre&amp;gt;./configure&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This ensures that the build system finds your new files. Then you can go on as usual:&lt;br /&gt;
* &amp;lt;pre&amp;gt;./compile&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Individual filter docs ==&lt;br /&gt;
&lt;br /&gt;
Some filters may have their own [[Documentation:Hacker&#039;s Guide|Hacker&#039;s Guide]] sections.&lt;br /&gt;
&lt;br /&gt;
Currently, the deinterlace filter has both a [[Documentation:Hacker&#039;s Guide/Video Filters/Deinterlace|Hacker&#039;s Guide section]] and [[Deinterlace|user documentation]] with some useful technical information.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Programming conventions and tips ==&lt;br /&gt;
&lt;br /&gt;
VLC video filters are usually written in C99, like the rest of VLC. The AtmoLight plugin uses C++, though.&lt;br /&gt;
&lt;br /&gt;
The usual stuff holds here too:&lt;br /&gt;
* Use &#039;&#039;&#039;assert()&#039;&#039;&#039; for checking conditions that, in presence of no bugs, always hold.&lt;br /&gt;
** &#039;&#039;Don&#039;t&#039;&#039; use &#039;&#039;&#039;assert()&#039;&#039;&#039; for checking stuff that may fail at runtime. Handle errors gracefully.&lt;br /&gt;
* Keep your code readable. Make private functions when it simplifies things.&lt;br /&gt;
* Prefer 80 characters per line at maximum, if possible.&lt;br /&gt;
&lt;br /&gt;
Particularly for video filters: keep in mind that this is low-level stuff and needs to be fast.&lt;br /&gt;
* How fast? Note that the source may be interlaced, and someone may have thrown a framerate doubler into the filter chain... this means that for a 60i signal, the entire processing chain from decode to render has about 16ms per output frame.&lt;br /&gt;
* Keep the required memory bandwidth down.&lt;br /&gt;
** Don&#039;t copy whole pictures unless you absolutely must. Moving pixels costs time.&lt;br /&gt;
** Allocate an output picture and render directly into it.&lt;br /&gt;
** If you need more than one pass, do in-place processing in the subsequent ones if possible.&lt;br /&gt;
** If your processing cannot avoid multiple passes, consider doing all passes for a picture line (or a few) at a time, instead of iterating over the whole picture separately for each pass. This will help to keep down the pressure on the CPU cache.&lt;br /&gt;
* Consider writing the inner processing loops in vectorized inline assembly, such as MMX. This can often gain a factor of 2-8x in speed, depending on how much and what kind of processing your algorithm needs.&lt;br /&gt;
&lt;br /&gt;
== Some notes on the API ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: See {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.c}} and {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.h}} for an example of everything discussed in this section. See also the [[Documentation:Hacker&#039;s Guide/Video Filters/Deinterlace|Deinterlace Hacker&#039;s Guide]] for some further details.&lt;br /&gt;
&lt;br /&gt;
The video filters use an object-based model. Calls to the filter will come with an instance pointer, so each filter instance can keep local data.&lt;br /&gt;
&lt;br /&gt;
Usually, each filter defines its own internal data structure called &#039;&#039;&#039;filter_sys_t&#039;&#039;&#039;. It is completely private to the filter.&lt;br /&gt;
&lt;br /&gt;
The API for video filters in VLC 1.2 is called &#039;&#039;&#039;video filter2&#039;&#039;&#039;. This requires the functions &#039;&#039;&#039;Open()&#039;&#039;&#039; and &#039;&#039;&#039;Close()&#039;&#039;&#039;. The &#039;&#039;&#039;Open()&#039;&#039;&#039; function is expected to allocate private data (if any), and set up the filter structure with pointers to a frame processing function (&#039;&#039;&#039;p_filter-&amp;gt;pf_video_filter&#039;&#039;&#039;, which is the actual filter), a flush function (&#039;&#039;&#039;p_filter-&amp;gt;pf_video_flush&#039;&#039;&#039;), and a mouse event function (&#039;&#039;&#039;p_filter-&amp;gt;pf_video_mouse&#039;&#039;&#039;). The &#039;&#039;&#039;Close()&#039;&#039;&#039; function should deallocate private data.&lt;br /&gt;
&lt;br /&gt;
The frame processing function takes a frame as input (&#039;&#039;&#039;picture_t*&#039;&#039;&#039;, {{VLCSourceFile|name=include/vlc_picture.h}}), and optionally outputs one or more frames (&#039;&#039;&#039;picture_t*&#039;&#039;&#039;) as a linked list. The usual case is one frame in, one frame out, but this is not a requirement. (See framerate doublers and IVTC in the deinterlace module for counterexamples.)&lt;br /&gt;
&lt;br /&gt;
If you do not wish to output a frame at a particular call to your processing function, you can return &#039;&#039;&#039;NULL&#039;&#039;&#039;. If you wish to output several, make a linked list by using the &#039;&#039;&#039;next&#039;&#039;&#039; member of &#039;&#039;&#039;picture_t&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
You don&#039;t have to necessarily output the &#039;&#039;same&#039;&#039; frame (after processing) that just came in. You can keep a private input frame history in your &#039;&#039;&#039;filter_sys_t&#039;&#039;&#039;, pick the base frame for your output from that, and adjust the PTSs (presentation timestamps, member &#039;&#039;&#039;date&#039;&#039;&#039; in &#039;&#039;&#039;picture_t&#039;&#039;&#039;) of your output as you deem necessary. The deinterlacer provides an example of how to do this.&lt;br /&gt;
&lt;br /&gt;
Note however that there may be other filters in the chain that already set up an offset; this leaves less time (until the designated PTS) for the rest of the filters to do their processing.&lt;br /&gt;
&lt;br /&gt;
Be sure to allocate your output pictures using &amp;lt;pre&amp;gt;picture_t *p_outpic = filter_NewPicture( p_filter );&amp;lt;/pre&amp;gt;&lt;br /&gt;
This function requests a new picture from the private pool (see {{VLCSourceFile|name=src/video_output/vout_wrapper.c}}). This is very important! Be aware that pictures created like&lt;br /&gt;
&amp;lt;pre&amp;gt;picture_t *p_temp = picture_NewFromFormat( &amp;amp;p_input_pic-&amp;gt;format );&amp;lt;/pre&amp;gt;&lt;br /&gt;
lack a shared memory context (in Linux; or the equivalent in other OS), and thus cannot be passed to the video output logic. If your filter attempts to do so, VLC will crash.&lt;br /&gt;
&lt;br /&gt;
If you need temporary pictures, you can allocate those using &#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;, but remember to &#039;&#039;always create output pictures using &#039;&#039;&#039;filter_NewPicture()&#039;&#039;&#039;&#039;&#039;. Here an &#039;&#039;output picture&#039;&#039; is defined as a picture which goes out from the filter to the caller.&lt;br /&gt;
&lt;br /&gt;
There is a limit to the number of simultaneous picture slots available in the private pool. Currently (&amp;lt;nowiki&amp;gt;[71992c5fbc75ee2c94cd2a3ab1aaca70bfc688a9]&amp;lt;/nowiki&amp;gt;) this is 3 pictures for the filter layer. See constant &#039;&#039;&#039;private_picture&#039;&#039;&#039; in {{VLCSourceFile|name=src/video_output/vout_wrapper.c}}. If you try to allocate more output pictures than this (during a single processing call), the allocation will fail.&lt;br /&gt;
&lt;br /&gt;
In VLC 1.2, the video format (resolution, chroma) never changes on the fly. The whole filter chain is &#039;&#039;&#039;Close()&#039;&#039;&#039;d and then &#039;&#039;&#039;Open()&#039;&#039;&#039;ed again if the format changes.&lt;br /&gt;
&lt;br /&gt;
Note that it &#039;&#039;is&#039;&#039; allowed to flush the filter without closing it. This actually happens under some circumstances, so &#039;&#039;don&#039;t deallocate stuff in your flush function&#039;&#039;. Rather, allocate dynamic resources in &#039;&#039;&#039;Open()&#039;&#039;&#039;, and deallocate them in &#039;&#039;&#039;Close()&#039;&#039;&#039; (or in private functions called from those).&lt;br /&gt;
&lt;br /&gt;
Supported input and output formats are left up to each filter. The usual thing is to support YUV formats, e.g. I420, J420, YV12, I422 and J422. See {{VLCSourceFile|name=include/vlc_fourcc.h}}.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Pitch, visible pitch, et al. ==&lt;br /&gt;
&lt;br /&gt;
Important to know:&lt;br /&gt;
&lt;br /&gt;
* i_pitch = number of (macro)pixels on one line&lt;br /&gt;
* i_visible_pitch = number of (macro)pixels on one line, adjusted for memory alignment constraints etc. (see below)&lt;br /&gt;
&lt;br /&gt;
Note that the pitches may be different for each plane, and indeed in YUV formats the luma (&#039;&#039;&#039;Y_PLANE&#039;&#039;&#039;) and chroma (&#039;&#039;&#039;U_PLANE&#039;&#039;&#039;, &#039;&#039;&#039;V_PLANE&#039;&#039;&#039;) have different pitches due to chroma subsampling. (In 4:2:0 formats, the number of lines differs, too.)&lt;br /&gt;
&lt;br /&gt;
Pitches also tend to slightly differ depending on how the picture was allocated, even if the visible size is the same. The input picture to the filter may have one pitch, temporary pictures (&#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;) another, and output pictures (&#039;&#039;&#039;filter_NewPicture()&#039;&#039;&#039;) yet another.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Be sure to always use the correct pitch when you handle the pixels of a picture.&#039;&#039; That is, always use the &#039;&#039;&#039;i_pitch&#039;&#039;&#039; member of the actual &#039;&#039;&#039;plane_t&#039;&#039;&#039; you are working on.&lt;br /&gt;
&lt;br /&gt;
If you absolutely need matching pitches (e.g. if you are glueing in processing code from another GPL-compatible project which assumes this and you don&#039;t want to rewrite it...), consider making temporary copies with &#039;&#039;&#039;picture_NewFromFormat()&#039;&#039;&#039;. See {{VLCSourceFile|name=modules/video_filter/deinterlace/deinterlace.c}} (the history mechanism &amp;lt;nowiki&amp;gt;pp_history[]&amp;lt;/nowiki&amp;gt;) and {{VLCSourceFile|name=modules/video_filter/deinterlace/algo_yadif.c}} (its usage) for an example.&lt;br /&gt;
&lt;br /&gt;
If you are processing pixels from one picture to another, the safe thing to do is to take the smallest &#039;&#039;&#039;i_visible_pitch&#039;&#039;&#039;, and loop from x = 0 until the visible pitch has been reached, but use the individual &#039;&#039;&#039;i_pitch&#039;&#039;&#039;es for computing the pixel locations. See {{VLCSourceFile|name=modules/video_filter/deinterlace/helpers.c}} for examples.&lt;br /&gt;
&lt;br /&gt;
=== video_format_t vs. plane_t ===&lt;br /&gt;
&lt;br /&gt;
In &#039;&#039;&#039;video_format_t&#039;&#039;&#039;, the &#039;&#039;&#039;i_visible_width&#039;&#039;&#039; and &#039;&#039;&#039;i_visible_height&#039;&#039;&#039; members go with &#039;&#039;&#039;i_x_offset&#039;&#039;&#039; and &#039;&#039;&#039;i_y_offset&#039;&#039;&#039;, but they are not related to &#039;&#039;&#039;plane_t::i_visible_*&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;plane_t::i_visible_*&#039;&#039;&#039; fields are there to know which part of the memory planes can at most be displayed. Usually these are different from the whole surface due to memory alignment constraints (like mod 16 for SSE2 or to be aligned on a macroblock). Those values are decided when the picture is allocated and they usually don&#039;t change for a given picture pointer (but they can change, like in direct3d buffers).&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;video_format_t:i_visible_width/height&#039;&#039;&#039; and &#039;&#039;&#039;i_x/y_offset&#039;&#039;&#039; are more a &#039;hint&#039; regarding what will be actually displayed. A filter should update &#039;&#039;&#039;filter_t::fmt_out&#039;&#039;&#039; if needed to ensure that the allocated pictures get the right value. A filter should, however, not limit its processing to this area, because VLC supports dynamic cropping.&lt;br /&gt;
&lt;br /&gt;
Thus, the correct thing to do in a filter is to process the whole picture area, or at least the first i_visible_* lines and pixels &#039;&#039;according to the &#039;&#039;&#039;plane_t&#039;&#039;&#039;s&#039;&#039;. Filters do not need to care about margin positioning or that there even exists such a thing as margins.&lt;br /&gt;
&lt;br /&gt;
== Disclaimer ==&lt;br /&gt;
&lt;br /&gt;
The information is mostly based on a few months&#039; hacking on the deinterlacer.&lt;br /&gt;
&lt;br /&gt;
This page is still a stub. Please add new relevant stuff.&lt;br /&gt;
&lt;br /&gt;
Also, the stuff that already exists could use better organization and formatting.&lt;br /&gt;
&lt;br /&gt;
{{Documentation}}&lt;/div&gt;</summary>
		<author><name>Technologicat</name></author>
	</entry>
</feed>