diff --git a/debian/README.Debian b/debian/README.Debian new file mode 100644 index 0000000..ed9028b --- /dev/null +++ b/debian/README.Debian @@ -0,0 +1,112 @@ +--------------------- on debian-multimedia + +Christian Marillat offers many multimedia-related packages in his repository, +including, for example, 'mencoder' ; +so you may want to add in /etc/apt/sources.list the line + deb http://www.debian-multimedia.org etch main + +But! some packages are both in Debian and in that repository; +If the versions of packages from that repository are newer than +those in Debian, you will substitute them; and this is the case of +mplayer; so, if you do not wish this to happen, you may add +vvvvvvvvvvvv +Package: * +Pin: release o=Unofficial Multimedia Packages +Pin-Priority: 450 +^^^^^^^^^^ +into /etc/apt/preferences. (This is called "apt pinning"). This will +give preference to a Debian package. (If you want to give preference +to Christian's package, use Pin-Priority: 550 ) + + +To know if the above works, you can use the command +$ apt-cache policy mplayer + mplayer: + Installed : .... + Candidate : 1.0~rc1-8 + Table de version : + [version] [??] + 450 http://www.debian-multimedia.org etch main + *** [version] [??] + 500 http://ftp.de.debian.org ustable/main Packages + 100 /var/lib/dpkg/status + +Look where the *** are, and what "Candidate:..." says. +(But, do not trust the output [??] in that list: see bug 254820). + + +Unfortunately, currently (see bug 317186), the following + "apt package pinning" does not work +vvvvvvvvvvvv +Package: mplayer +Pin: release o=Unofficial Multimedia Packages +Pin-Priority: 450 +^^^^^^^^^^ + +a. + +---------------------- on performance + +Most options are autodetected or configured during compilation; thus +users get a better performance if they rebuild this package themselves. + +In case you would like to change the parameters passed to ./configure, +set variable DEB_BUILD_CONFIGURE. When this binary was compiled, the +variable was set to + +DEB_BUILD_CONFIGURE=@DEB_BUILD_CONFIGURE@ + +So, recommended method is running + +$ fakeroot debian/rules DEB_BUILD_CONFIGURE="" binary + +in the top directory of source code: this will reset that variable, +and will then optimize mplayer strictly for your CPU. + +Dariush Pietrzak Sat Jan 5 20:28:23 CET 2002 + +-------------------- on debugging + +if you need to debug this package, you may recompile it with + "debugging options" + +one way to do this is +$ DEB_BUILD_OPTIONS=debug debuild binary +this will compile the package passing '--enable-debug=-g3' : +so the sources will be compiled with CFLAGS + CFLAGS="-W -Wall -O2 -g3 ...arch.. ..cpu.. " +this is the "upstream preferred way" of debugging mplayer. + +I also implemented + DEB_BUILD_OPTIONS=noopt +that will compile without '-O2' , as is recommended by the policy + +Whereas DEB_BUILD_OPTIONS=nostrip will make sure that, in the final +package, all binaries will be unstripped + +One warning: the above requires a lot of disk space! the building tree +is ~380Mb , and the final mplayer is ~90Mb , so you need ~500Mb to +to a successfull debug building + +There is moreover a huge catch: some code in mplayer (particularly, +asm code for mmx/sse) does not compile on some +architectures when optimizations is disabled; see + http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11203 + http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13850 + +For this reason, I have hacked up workarounds +(reenabling optimization for files that fail w/o it) +but your mileage may vary) + +a. + +-------------- + +This binary conforms to + http://www.mplayerhq.hu/DOCS/tech/binary-packaging.txt +but for the following notes and exceptions: +*E* the GUI does not come as a separate package (it would save no disk space!) +*N* to avoid stripping, use DEB_BUILD_OPTIONS=nostrip + to enable debugging, use DEB_BUILD_OPTIONS=nostrip,debug + + -- A Mennucc , Fri, 15 Dec 2006 14:53:12 +0100 diff --git a/debian/README.Debian.free b/debian/README.Debian.free new file mode 100644 index 0000000..8f666c4 --- /dev/null +++ b/debian/README.Debian.free @@ -0,0 +1,64 @@ +#this part is conditionally added if the source was DFSG free + +------------- + +WARNING WARNING WARNING WARNING + +the mplayer*.tar.gz in Debian is different from @UPSTREAMSOURCE@ + + +* If the code is pulled from SVN, then tar.gz in Debian is +obtained by + debian/rules copy-orig-from-svn + debian/rules fix-orig-source +If the code is from an upstream .tar.gz , then tar.gz in Debian is +obtained by + debian/rules download-and-unpack-orig + debian/rules fix-orig-source + +* In particular, the mpdvdkit internal library was deleted: so + mplayer.deb is uncapable to play encrypted DVDs ; if you want to + play encrypted DVDs (i.e. almost all video DVDs), see the file + /usr/share/doc/libdvdread3/README.Debian. This file contains + up-to-date instructions on how to obtain libdvdcss2. + +* PLEASE DO NOT BOTHER UPSTREAM MPLAYER'S AUTHORS WITH BUGS AND REQUESTS + FOR FEATURES, but, send bugs to Debian: indeed, missing features + and/or bugs may be due to my butchering of the upstream code + +A. Mennucc + +-------------- on GPLv2 sec 2.a + +MPlayer contains source code from other GPL libraries, such as + FFMpeg - libavcodec + mp3lib + liba52 + ... + +See file 'Copyright'. + +During the flames in 2002-03 in debian-legal, it was pointed out +that mplayer may not be respecting the following section of the GPL v2: + +>2. You may modify your copy or copies of the Program or any portion of +>it, thus forming a work based on the Program, and copy and distribute +>such modifications or work under the terms of Section 1 above, provided +>that you also meet all of these conditions: +> +>a) You must cause the modified files to carry prominent notices stating +>that you changed the files and the date of any change. + +this issue is e.g. pointed out in + http://lists.debian.org/debian-legal/2003/debian-legal-200301/msg00231.html + +Currently mplayer ships many files such as + liba52/liba52_changes.diff libmpdvdkit2/libdvdread_changes.diff + libfaad2/local_changes.diff libmpeg2/libmpeg-0.4.0.diff + libmpdvdkit2/libdvdcss_changes.diff tremor/tremor.diff +to comply with this request. + +Moreover all changes to the code are documented +in the SVN public repository of MPlayer (that is publicly accessible). + +A. Mennucc diff --git a/debian/README.Debian.nonfree b/debian/README.Debian.nonfree new file mode 100644 index 0000000..6dad924 --- /dev/null +++ b/debian/README.Debian.nonfree @@ -0,0 +1,7 @@ +#this part is conditionally added if the source was not DFSG free + +This version of the mplayer binary and sources contains all the code +found in the original @UPSTREAMSOURCE@ + +For this reason, it is not fit for inclusion in the main Debian archive. + diff --git a/debian/README.debian b/debian/README.debian deleted file mode 100644 index 190211b..0000000 --- a/debian/README.debian +++ /dev/null @@ -1,16 +0,0 @@ -mplayer for Debian ----------------------- - - Most options are autodetected or configured during compilation thus - users are supposed to build this package themselves. - - Recommended method is running "fakeroot debian/rules binary" in the top - directory - - In case you would like to pass some parameters to ./configure, set variable - DEB_BUILD_OPTIONS like that: - - eyck@ghost$ DEB_BUILD_OPTIONS="--enable-streaming" fakeroot debian/rules binary - - -Dariush Pietrzak Sat Jan 5 20:28:23 CET 2002 diff --git a/debian/README.source b/debian/README.source new file mode 100644 index 0000000..c507f22 --- /dev/null +++ b/debian/README.source @@ -0,0 +1,7 @@ +hi + +mplayer source tree uses 'dpatch'. To see the code that is actually compiled, +run './debian/rules patch' + +moreover, the file debian/control is generated from debian/control.in +(by means of the command './debian/rules autocontrol' ) \ No newline at end of file diff --git a/debian/TODO.Debian b/debian/TODO.Debian deleted file mode 100644 index 4f73f9b..0000000 --- a/debian/TODO.Debian +++ /dev/null @@ -1 +0,0 @@ -- Figure out why /etc/mplayer/mplayer.config.1 gets created and fix this. diff --git a/debian/changelog b/debian/changelog index 990973a..cc1882a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,29 +1,675 @@ -mplayer (1.0svn) unstable; urgency=low +mplayer (1.0~rc2-20) unstable; urgency=low + + * use external libfaad : external libfaad is newer, and does not crash + on aac file in http://bugs.debian.org/407010 + + -- A Mennucc1 Thu, 18 Dec 2008 11:48:42 +0100 + +mplayer (1.0~rc2-19) unstable; urgency=high + + * SA33136: MPlayer TwinVQ Processing Buffer Overflow Vulnerability + Thanks to T. Klein, G. Iuculano, R. Döffinger (Closes: #508803). + + -- A Mennucc1 Mon, 15 Dec 2008 21:05:07 +0100 + +mplayer (1.0~rc2-18) unstable; urgency=high + + * fix oCERT-2008-013 Mplayer real demuxer heap. + Thanks to Felipe Andres Manzano, Andrea Barisani, + Steffen Joeris, Reimar Döffinger. (Closes: #500683). + * Clean lintian warnings: + build-depend on libgif-dev instead of libungif4-dev + build-depend on x11proto-core-dev instead of x-dev + depends on debconf | debconf-2.0 + * Up standard to 3.8.0.0 + support DEB_BUILD_OPTIONS="parallel=n" + + -- A Mennucc1 Mon, 22 Sep 2008 11:01:26 +0200 + +mplayer (1.0~rc2-17) unstable; urgency=low + + * fix bashism in binary_codecs.sh script, + thanks to Raphael Geissert (Closes: #489636). + * use proper name 'mplayer.xpm' for the icon, + thanks to Fernando Mitio Yamada (Closes: #483499). + * fix: show correct length of theora video (from svn27354), + thanks to Sam Morris and Reimar Döffinger (Closes: #464207). + * [INTL:sv] Swedish strings for mplayer debconf, + thanks to brother@bsnet.se (Closes: #491777). + + -- A Mennucc1 Sun, 27 Jul 2008 09:26:24 +0200 + +mplayer (1.0~rc2-16) unstable; urgency=high + + * fix FTBFS, build-depends against libdvdread-dev, + thanks to Bastian Blank (Closes: #491366). + * update lists of binary codecs and mirrors + + -- A Mennucc1 Sun, 20 Jul 2008 12:05:47 +0200 + +mplayer (1.0~rc2-15) unstable; urgency=low + + * build-depend on liblzo2-dev + * Bug fix: "mplayer segfaults on opening any *.flv file", thanks A LOT to + Ondrej Certik (Closes: #489291). + * Bug fix: "mplayer: crashes on playing a standalone aac file", thanks + to Michal Suchanek (Closes: #489419). + * Bug fix: "mplayer: crashes with "MPlayer interrupted by signal 11 + in module: demux_open" on FLV files", thanks to Paul Collins + (Closes: #487830). + * Bug fix: "mplayer: [INTL:it] debconf templates italian translation", + thanks to Alessandro Vietta (Closes: #481418). + + -- A Mennucc1 Sun, 06 Jul 2008 17:57:29 +0200 + +mplayer (1.0~rc2-14) unstable; urgency=low + + * Links with ffmpeg-free provided libraries (Closes: #395252). + * Uses libsvga1-dev in Build-Depends instead of svgalibg1-dev, + thanks to Guillem Jover (Closes: #483460). + * Build-depend on vstream-client-dev, + thanks to Paul Hedderly (Closes: #487291). + + -- A Mennucc1 Mon, 23 Jun 2008 13:20:34 +0200 + +mplayer (1.0~rc2-12) unstable; urgency=low + + * Conflicts on gcc-4.3 <= 4.3.0-3 to avoid bug 475153 . + * Sorry, 'DEB_BUILD_OPTIONS=noopt ./debian/rules build-arch' + is again broken in i386 . It is simply too difficult to build + mplayer on i386 w/o optimizing it a bit. For details, see + http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=402950#44 + and following. + * For this reason, and to help solving the strange bug 478731 + I have decided to build mplayer with 'configure --enable-debug' and + to create a 'mplayer-dbg' package, to ship debugging symbols. + + -- A Mennucc1 Thu, 01 May 2008 20:40:42 +0200 + +mplayer (1.0~rc2-11) unstable; urgency=low + + * avoid FTBFS bug introduced by dpkg-buildpackage setting of "CFLAGS + & al" in environment, + thanks to Lucas Nussbaum (Closes: #475973). + * set 'autodetect' to 'xv,x11' to avoid problems with xvmc and/or gmplayer, + thanks to Walter B. Rasmann (Closes: #473686). + thanks to Sam Morris (Closes: #475934). + thanks to Victor Hahn (Closes: #458786). + * fix bashism in /bin/sh maintainer script, + thanks to Raphael Geissert (Closes: #472232). + * renamed mplayer.xpm to mplayer in desktop file, + thanks to giggz (Closes: #472833). + * added debian/README.source + * add libmpcdec to build-dependencies + + -- A Mennucc1 Thu, 01 May 2008 12:16:08 +0200 + +mplayer (1.0~rc2-10) unstable; urgency=high + + * fix: CVE-2008-0073 remote code execution via crafted rtsp stream, + thanks to Nico Golde and Reimar Döffinger (Closes: #473056). + * use ALSA by default, thanks to Sam Morris (Closes: #470617). + + -- A Mennucc1 Sat, 29 Mar 2008 09:40:09 +0100 + +mplayer (1.0~rc2-9) unstable; urgency=low + + * fix: gmplayer wrong driver setting "vo_driver= xmga", thanks to + Siegfrid Brandstätter (Closes: #449041). + * added dependency libaudio-dev, libfribidi-dev, libopenal-dev; + this should make mplayer compiling less dependent on build environment + * and moreover I think I enabled almost everything around, thanks to + Fabian Greffrath (Closes: #419790). + * add BiDi support, thanks to Khaled Hosny (Closes: #462611). + * removed 'uploaders: Dariush Pietrzak ' + thanks to Lucas Nussbaum (Closes: #460031). + * fix missing newline from message displayed by postinst script, + thanks to Serafeim Zanikolas (Closes: #468059). + + -- A Mennucc1 Fri, 21 Mar 2008 16:14:55 +0100 + +mplayer (1.0~rc2-8) unstable; urgency=low + + * fix SVN25823 for + CVE-2008-0630, buffer overflow via crafted url , + thanks Niko Golde (closes: #464532) + * fix SVN25824 for + CVE-2008-0629, buffer overflow via crafted cddb title + thanks Niko Golde (closes: #464533) + * fix for CVE-2008-0485 Array index error in libmpdemux/demux_mov.c + a.k.a. CORE-2007-1218: MPlayer 1.0rc2 buffer overflow vulnerability + thanks Stefan Fritsch + * fix for CVE-2008-0486 Array index vulnerability in libmpdemux/demux_audio.c + a.k.a. CORE-2008-0122: MPlayer arbitrary pointer dereference + thanks Stefan Fritsch (closes: #464060) + + -- A Mennucc1 Fri, 8 Feb 2008 20:42:41 +0100 + +mplayer (1.0~rc2-7) unstable; urgency=low + + * fix segfault on GNU/kFreeBSD, by moving a patch from + debian/patches/25kFreeBDS.dpatch directly to debian/rules itself, + thanks to Petr Salinger (Closes: #457312). + * really remove /etc/init.d/mplayer and /etc/rc... files (used < + 1.0~rc2-1), thanks to Kumar Appaiah & piuparts (Closes: #454710). + * Avoid 'echo -e' bashism in postinst (now uses /bin/echo ), + thanks to Helmut Grohne (Closes: #451551). + * delete config.h config.mak from diff.gz, + thanks to Fabian Greffrath (Closes: #451381). + * [INTL:sk] Slovak po-debconf translation, + thanks to helix84@centrum.sk (Closes: #440717). + * enable jack support, thanks to Free Ekanayaka (Closes: #440461). + * Document 22disable-xscreensaver.dpatch + * Bump standard to 3.7.3.0 : + - menu for "/usr/bin/gmplayer" goes in section="Applications/Video" + - added Homepage and Vcs fields + + -- A Mennucc1 Sat, 29 Dec 2007 13:08:22 +0000 + +mplayer (1.0~rc2-6) unstable; urgency=low + + * created debhelper debian/compat '5' + * corrected mplayer.menu to section="Applications/Viewers" + * fix: cant open a file with spaces in the name through nautilus, + thanks to giggz (Closes: #449298) + * fix: 2xsai filter generates side-by-side double-height images on amd64, + thanks to Josh Triplett and Reimar Döffinger (Closes: #450999) + * clean up of 10configure-alpha.dpatch and 12configure-vidix-alpha.dpatch + * Debconf templates and debian/control reviewed by the + debian-l10n-english team as part of the Smith review project. + Thanks to Christian Perrier. + Closes: #447111, #448247, #412394, #414510, #448247 + [Debconf translation updates] + * Belarusian. Thanks Andrei Darashenka. Closes: #447115, #447305 + * Galician. Thanks Jacobo Tarrio. Closes: #447300 + * French Thanks Yves Rütschlé. Closes: #448844 + * Finnish. Thanks Esko Arajärvi. Closes: #447349 + * Spanish; Castilian. Thanks Javier Fernández-Sanguino Peña. Closes: #447416 + * Czech. Thanks Miroslav Kure. Closes: #447439 + * Portuguese. Thanks "traduz" Carlos Lisboa. Closes: #447800 + * Vietnamese. Thanks Clytie Siddall. Closes: #447873 + * Romanian. Thanks Eddy Petrișor. Closes: #447922 + * Dutch; Flemish. Thanks "cobaco". Closes: #448120 + * Italian. Thanks Luca Monducci. Closes: #448237 + * German. Thanks Helge Kreutzmann. Closes: #448246 + * Malayalam. Thanks Santhosh Thottingal. Closes: #448468 + * Russian. Thanks Sergey Alyoshin. Closes: #449000 + + -- A Mennucc1 Wed, 14 Nov 2007 15:49:04 +0100 + +mplayer (1.0~rc2-5) unstable; urgency=low + + * patch to play rtsp stream (hack to skip short packets) + thanks to Stefan Strasser, Reimar Döffinger (Closes: #410424). + * the bug "mplayer segfaults on ogg video" was actually a libtheora bug, + fixed in 1.0~beta1-1 or above: added dependency. + Thanks to Pierre Habouzit, Reimar Döffinger (Closes: #408071). + * Fix FTBFS on GNU/kFreeBSD, thanks to Petr Salinger (Closes: #448791). + + -- A Mennucc1 Sun, 04 Nov 2007 12:56:38 +0000 + +mplayer (1.0~rc2-4) unstable; urgency=low + + * fix: _vorbis_block_alloc() implicitly converted to pointer, + thanks to dann frazier (Closes: #447278). + + -- A Mennucc1 Fri, 19 Oct 2007 21:01:17 +0200 + +mplayer (1.0~rc2-3) unstable; urgency=low + + * vidix drivers cyberblade sis unichrome fail on alpha, and are probably + useless but in x86_32 and x86_64 archs + + -- A Mennucc1 Fri, 19 Oct 2007 18:10:59 +0200 + +mplayer (1.0~rc2-2) unstable; urgency=low + + * Runtime CPU detection only works for x86, x86-64 and PPC + + -- A Mennucc1 Fri, 19 Oct 2007 09:43:08 +0200 + +mplayer (1.0~rc2-1) unstable; urgency=low + + * New upstream version. + * Remove RTC debconf question and /etc/init.d/mplayer (Closes: #421363) + * Use dpatch. + + -- A Mennucc1 Wed, 18 Oct 2007 19:27:16 +0200 + +mplayer (1.0~rc1-16.1) unstable; urgency=high + + * Non-maintainer upload by testing security team. + * Check wLongsPerEntry in aviheader.c before using it to prevent + possible NULL pointer dereference (CVE-2007-4938) (Closes: #443478). + + -- Nico Golde Tue, 25 Sep 2007 12:39:15 +0200 + +mplayer (1.0~rc1-16) unstable; urgency=low + + * compile for --mcpu=ev5 on alpha; fixes "Illegal instruction on EV56", + thanks to Tom Evans & Ivan Jager (Closes: #431139). + * removed debian/patches (Closes: #409352). + * correct mplayer.config to respect font default, thanks Simon Ruggier. + * linked with liblivemedia, thanks to Hilmar Preusse (Closes: #440338). + + -- A Mennucc1 Sat, 01 Sep 2007 12:27:16 +0000 + +mplayer (1.0~rc1-15) unstable; urgency=low + + * Bug fix: "Depends on libconfhelper-perl, but this package has been + removed", thanks to David (Closes: #434509). + * Bug fix: "correction for binary_codecs.sh", thanks to nutzteil@web.de + (Closes: #431537). + + -- A Mennucc1 Wed, 1 Aug 2007 11:54:40 +0200 + +mplayer (1.0~rc1-14) unstable; urgency=high + + * fix for stack overflow in the code used to handle cddb queries, + CVE-2007-2948 and SAID 24302, thanks Stefan Cornelius of Secunia Research + * do not use libmad0, on request of upstream + * [INTL:ml] Malayalam debconf template translation + thanks to Santhosh Thottingal (Closes: #419527). + * [INTL:it] Italian debconf templates translation + thanks to Luca Monducci (Closes: #425259). + * [l10n:ro] Romanian debconf templates translation + thanks to Eddy Petrișor (Closes: #415368). + + -- A Mennucc1 Wed, 6 Jun 2007 10:17:22 +0200 + +mplayer (1.0~rc1-13) unstable; urgency=low + + * fix for CVE-2007-1246 and similar (Closes: #414075) + thanks Kees Cook & Moritz Jodeitand & R Togni + patches for files + loader/dmo/DMO_VideoDecoder.c from SVN 22204 + loader/dshow/DS_VideoDecoder.c from SVN 22205 + * [INTL] Japanese po-debconf templates translation, + thanks to Kobayashi Noritada (Closes: #413120). + * [INTL] Dutch po-debconf translation, thanks cobaco (Closes: #413880) + * [INTL] Russian po-debconf translation, thanks Yuri Kozlov (Closes: #414251) + * patch for ia64 unaligned access crash, + thanks to Bryan Stillwell for debugging & + Reimar Döffinger for the patch (Closes: #409431). + * mplayer-doc: add doc-base documentation indexes, + thanks to Martintxo (Closes: #405945). + * binary_codecs.sh: check MD5 on downloaded stuff (Closes: #405371). + * binary_codecs.sh: check if bzip2 is there, and bail out + graciously otherwise; if untarring fails, allow for retry. + Fixes "binary_codecs.sh doesn't install already downloaded codecs", + thanks to Ingo Bressler for problem analysis (Closes: #413063). + * binary_codecs.sh: do not use fping (my code lost part of URLs) (closes: #399144) + * binary_codecs.sh: warn that essential-ppc codecs need libstdc++5, thanks to + Bin Zhang (Closes: #404473) for pointing out. + * enable smb:// (Closes: #412079). + * mplayer.postinst: when vo=x11 or vo=fbdev, zoom=1 is set as well, + thanks to Robert Millan (Closes: #412252). + * -stop-xscreensaver option disables gnome-screensaver as well + (but only if cursor is inside mplayer window) , thanks Adam Tlałka + and Reimar Döffinger (Closes: #404975). + * [INTL] fix small typo in English template, thanks cobaco (closes: #414393) + * [INTL] devices.html -> video.html , thanks cobaco (closes: #414392) + * [INTL] True Type -> TrueType , thanks cobaco (closes: #414394) + * [INTL] ~/.mplayer/mplayer.conf -> ~/.mplayer/config , + thanks Jacobo Tarrio (closes: #408055) + + -- A Mennucc1 Sat, 10 Mar 2007 12:57:16 +0100 + +mplayer (1.0~rc1-12) unstable; urgency=medium + + * (possible) security fixes backported from SVN + 7585 7586 7591 for libavcodec/h264.c + 7640 7650 for libavformat/asf.c + all thanks to Michael Niedermeyer + * Czech debconf translation; thanks to Miroslav Kure (Closes: #408626). + * Portuguese debconf translation; thanks to Traduz! (Closes: #408449). + * Swedish debconf translation; thanks to Andreas Henriksson (Closes: #407864). + * binary_codecs.sh should specify umask; + thanks to Linas Žvirblis (Closes: #406346). + * clarify dependencies (do not pick up them randomly!), + thanks to EspeonEefi (Closes: #405170); + debian/rules: when configuring, disable also: arts , jack , aa , dv , smb + debian/control: depend on: lzo, speex, dts, ladspa, gl (mesa) + * the above adds opengl video output (Closes: #400934). + * forked processes cannot use GTK gui; this fixes bug in caching streams + in gmplayer (Closes: #396962) + thanks to martin f krafft and Reimar Döffinger for patch. + * added in debian/patches all patches that I applied or I am working on + + -- A Mennucc1 Wed, 31 Jan 2007 10:30:24 +0100 + +mplayer (1.0~rc1-11) unstable; urgency=high + + * fix for CVE-2006-6172 + * fixed "typo in the README.Debian", thanks to Aurelien + Jacobs (Closes: #403893). + * another (last?) fix for (Closes: #402950), thanks Sam Hocevar. + + -- A Mennucc1 Thu, 28 Dec 2006 23:03:42 +0100 + +mplayer (1.0~rc1-10) unstable; urgency=high + + * really apply patch for (Closes: #403379) + * many fixes to various codecs, to prevent crashes on + randomly altered streams + + -- A Mennucc1 Mon, 18 Dec 2006 11:46:35 +0100 + +mplayer (1.0~rc1-9) unstable; urgency=low + + * fix another segfault on (broken) MPEGs without I frames (Closes: #403379). + * fix: binary_codecs.sh failed to install essential-ppc + codecs, thanks to Bin Zhang (Closes: #403442). + + -- A Mennucc1 Sun, 17 Dec 2006 13:06:43 +0100 + +mplayer (1.0~rc1-8) unstable; urgency=low + + * fix segfault on (broken) MPEGs without I frames, (Closes: #402922). + * README.Debian: document apt pinning and debian-multimedia + * can be compiled with --enable-debug (Closes: #402920). + * supports DEB_BUILD_OPTIONS=nostrip/noopt (Closes: #402950) + (see README.Debian, though, for gory details) + * Spanish po-debconf translation", thanks + to Javier Fernández-Sanguino Peña (Closes: #402205). + * patch to compile in GNU/kFreeBSD, thanks to Petr Salinger (Closes: #402872). + + -- A Mennucc1 Fri, 15 Dec 2006 14:40:54 +0100 + +mplayer (1.0~rc1-7) unstable; urgency=low + + * Bug fix: "mplayer: FTBFS on AMD64", thanks to Emfox Zhou (Closes: + #401893). + + -- A Mennucc1 Thu, 7 Dec 2006 14:26:10 +0100 + +mplayer (1.0~rc1-6) unstable; urgency=low + + * debian/control : update mantainer fields + * debian/scripts/binary_codecs.sh : 'wget -c -N' -> 'wget -N' + * update debian/prefs/codecs_list and mirrors (closes: #399144) + * debian/rules : x86_64 -> amd64 (closes: #401697) + * applied patch (that should support codecs in amd64 ) + http://people.freedesktop.org/~jinghua/real64/mplayer-amd64-real-codecs.diff + * update french translation (closes: #400106) + * update german translation (closes: #400296) + * (again!) set --with-codecsdir to avoid broken default; thanks to Emfox Zhou + (Closes: #396017). + + -- A Mennucc1 Wed, 6 Dec 2006 10:56:02 +0100 + +mplayer (1.0~rc1-5) unreleased; urgency=low + + * this version was built with external ffmpeg 0.svn6767 + it is in http://tonelli.sns.it/pub/mplayer/experimental-shared + + -- A Mennucc Mon, 27 Nov 2006 15:03:02 +0100 + +mplayer (1.0~rc1-4) unstable; urgency=low + + * Depends on mplayer-skin + * Use fontconfig in /etc/mplayer/mplayer.conf , so that 'Sans' is + always a fallback; this solves: + "OSD missing numbers/letters", thanks to Sam Morris (Closes: #396531). + if fc-list is available, let the user choose between a huge list as well + * Bug fix: "mplayer: depends exclusively on debconf (debconf-2.0 should + be an alternative)", thanks to Eddy Petrișor (Closes: #397891). + * Patches from Diego Biurrun : + - README.jfdct.gz is already copied inside + libavcodec/jfdctfst.c libavcodec/jfdctint.c + - do not use external libdv (ffmpeg has internally a better one) + - rename win32codecs.sh to binary_codecs.sh, + * Bug fix: "mplayer: win32codecs.sh will not uninstall", thanks to Joey + Morris (Closes: #397867) and Diego for the patch. + * Applied some changes in debconf template, thanks to Helge + Kreutzmann (Closes: #397819). + * Supports caca (Closes: #397749). + * "Initial German debconf translation", + thanks to Helge Kreutzmann (Closes: #397822). + * "French program translation", thanks to Yves Rutschle (Closes: #398515). + * Bug fix: "FTBFS: bashisms in build scripts", thanks to + Florent Bayle (Closes: #396450). + + -- A Mennucc1 Sun, 19 Nov 2006 21:06:01 +0100 + +mplayer (1.0~rc1-3) unstable; urgency=low + + * Bug fix: "Outdated info in /usr/share/doc/mplayer/README.Debian", + thanks to Sam Morris (Closes: #396281). + * set --with-codecsdir to avoid broken default; thanks to Emfox Zhou + (Closes: #396017). + + -- A Mennucc1 Tue, 31 Oct 2006 09:13:32 +0100 + +mplayer (1.0~rc1-2) unstable; urgency=low + + * rewrote mplayer.{config,template,postinst} ; this also fixes + "mplayer: Strange contents of default config file", thanks to + Sam Morris (Closes: #395829). + * Reviewed description, thanks to Filipus Klutiero (Closes: #395540). + * Use po-debconf + [Diego suggested:] + * Don't install codecs.conf. If people fiddle w/ it, playback *will* break. + * --disable-bitmap-font, so no more + "annoying message on 'ttf doesn't look like a bitmap '", + thanks to Michael Piefel (Closes: #395325) and Diego + + -- A Mennucc1 Sat, 28 Oct 2006 17:49:41 +0200 + +mplayer (1.0~rc1-1) unstable; urgency=low + + * New upstream release + * -nortc is now default since -rtc has disadvantages with recent kernels + ( so the mplayer/rtc question is now low priority, defaults to false ) + * do not pass --enable-directfb (it fails) + * reorganized debian/rules file (Closes: #395238,#395240,#395303). + * reformat of scripts/win32codecs.sh + + -- A Mennucc1 Thu, 26 Oct 2006 12:55:33 +0200 + +mplayer (1.0~rc1~svn20199-1) unstable; urgency=low + + * code pulled from SVN + (and some dirs deleted : see 'debian/rules fix-orig-source') + * do not depend on xmms + * build libraries with -fPIC + * ship in examples dir: etc/menu.conf etc/input.conf etc/codecs.conf + + -- A Mennucc1 Fri, 13 Oct 2006 11:41:47 +0200 + +mplayer (1.0~rc1~svn19921) unstable; urgency=low + + * code pulled from SVN + (and some dirs deleted : see 'debian/rules fix-orig-source') + * better debian/copyright file + * fixed some lintian issues + * new debian/rules targets that build a tar from SVN + * updated various README.Debian files (regarding all the + upstream code not shipped into Debian) + * 'debian/rules autocontrol' ( generates control.in -> control ) + also adds dependencies for creating docs (if it is needed) + * in debconf, question on -vo is low priority, default is "autodetect" + (that is, no setting) + * mplayer init supports LSB + + -- A Mennucc1 Sun, 21 Sep 2006 10:08:27 +0200 + +mplayer (1.0pre8-1) unstable; urgency=low + + * New upstream release + * better debian/copyright file + * do not ship a skin + + -- A Mennucc1 Sun, 30 Jul 2006 12:25:14 +0200 + +mplayer (1.0pre7try2-1) unstable; urgency=low + + * New upstream release + * changed DEB_BUILD_OPTIONS to DEB_BUILD_CONFIGURE , + DEB_BUILD_OPTIONS is used as in debian policy + * use gcc-3.4 + * changed xlibs-dev to a long list of dependencies, for Debian/etch + * try to adhere to http://www.mplayerhq.hu/DOCS/tech/binary-packaging.txt + (see README.Debian for details) + * removed dependency on xlibmesa-dev, disabled opengl + + -- A Mennucc1 Mon, 16 Jan 2006 11:47:33 +0100 + +mplayer (1.0pre7-1) unstable; urgency=low + + * New upstream release + + -- A Mennucc1 Sun, 24 Apr 2005 19:34:33 +0200 + +mplayer (1.0pre6a-4) unstable; urgency=low + + * Simon McVittie wonderful work: + - Work around Debian bug #267442 (glibc's sys/uio.h and gcc's altivec.h have + conflicting uses for __vector) by re-ordering #includes + - Fix potential symlink attack in ./configure + - Disable support for binary codecs on platforms for which those codecs + aren't available; also disable the corresponding Debconf note when it's + inappropriate + - Changed Build-Depends: so it works in pbuilder + - Explicitly build-depend on libjpeg62-dev, libfontconfig1-dev, + libungif4-dev + - Tweak debian/rules to avoid certain errors being ignored + - Use --language=all + + -- A Mennucc1 Sat, 5 Mar 2005 22:24:57 +0100 + +mplayer (1.0pre6a-3) unstable; urgency=low + + * provide a target 'debian/rules get-orig-source' + that recreates the orig.tar.gz ; then use the above orig.tar.gz + * rewrote some parts of debian/rules + * don't clean and recompile docs if upstream ships them + * mplayer-doc was shipping too much stuff + * translated man pages where not installed properly + * compile with libdv4-dev + * correct README.Debian + + -- A Mennucc1 Tue, 20 Feb 2005 14:30:19 +0100 + +mplayer (1.0pre6a-2) unstable; urgency=low + + * Forgot build-dep on libtheora + * Must not depend on libxvidcore + + -- A Mennucc1 Mon, 14 Feb 2005 14:47:56 +0100 + +mplayer (1.0pre6a-1) unstable; urgency=low + + * New upstream release + + -- A Mennucc1 Fri, 11 Feb 2005 19:33:42 +0100 + +mplayer (1.0-cvs20030324-2) unstable; urgency=low + + * some corrections, as suggested Diego Biurrun + - binary codecs should go into /usr/lib/codecs (upstream default) + - better template 'mplayer/install_codecs' + - an empty 'font=' in mplayer.conf breaks mplayer: postinst corrected + * correction in 'mplayer/cfgnote' + * better mplayer.postinst and mplayer.config + + -- A Mennucc1 Sun, 18 Apr 2004 17:25:37 +0200 + +mplayer (1.0.cvs20030324-1) unstable; urgency=low + + * following the discussion started by Diego Biurrun + in debian-devel, I have prepared a new packaging of 'mplayer' + (with code that comes from CVS) + * the upstream tar.bz cannot be distributed by Debian, since it contains + CSS code; so I am repackaging it + * I have tried my best to address all known issues: + - the package contains the detailed Copyright made by Diego Biurrun + - the package does not contain CSS code, or AFAIK other code on which + there is active patent enforcement + - there is a script debian/cvs-changelog.sh that shows all changes + done to files included in this source. + This should comply with GPLv2 sec 2.a (in spirit if not in letter) + For this reason, the source code contains CVS directories. + * needs make (>= 3.80) for 'html-chunked-$(1)' in DOCS/xml/Makefile + + -- A Mennucc1 Wed, 30 Mar 2004 18:04:06 +0100 - * change version naming from cvs to svn. - - -- Aurelien Jacobs Tue, 20 Jun 2006 13:02:14 +0200 - -mplayer (1.0cvs) unstable; urgency=low - - * debian/rules: now compiled without --enable-runtime-cpudetection. - If you plan to install the target .deb on a wide variety of machines, - you may want to add that option to the configure command. - - -- Guillaume POIRIER Mon, 20 Nov 2005 22:56:40 +0100 +mplayer (0.90-3) unstable; urgency=low -mplayer (0.90cvs) unstable; urgency=low + * changed description to stress that the .tar.gz in Debian is different from + the upstream (following suggested by Edward Block) + * --enable-fbdirect in configure + * uploaded to Debian - * this is a placeholder message + -- A Mennucc1 Fri, 1 Aug 2003 16:21:50 +0200 - -- Gabucino Fri, 7 Feb 2003 23:43:55 +0100 +mplayer (0.90-2) unstable; urgency=low -mplayer (0.90rc4-0) unstable; urgency=low + * removed all CSS code. Now mplayer use lib dvdread - * new rc-release. + -- A Mennucc1 Fri, 25 Jul 2003 10:50:26 +0200 - -- Alex Beregszaszi Fri, 7 Feb 2003 23:43:55 +0100 +mplayer (0.90-1) unstable; urgency=low + * uploaded to Debian. The source code was scrutinized for + licenses and copyrights. Read copyright for a detailed discussion. + + -- A Mennucc1 Wed, 23 Jul 2003 09:45:41 +0200 + +mplayer (0.90) unstable; urgency=low + + * version bumped + + -- Gabucino Sun, 16 Feb 2003 11:02:51 +0100 + +mplayer (0.90rc4-1) unstable; urgency=low + + * new rc-release + + -- A Mennucc1 Mon, 24 Feb 2003 18:40:13 +0100 + +mplayer (0.90rc3-2) unstable; urgency=low + + * configure: --disable-dvdnav --enable-mpdvdkit --disable-aa --disable-ggi + on suggestions from author(s) + + -- A Mennucc1 Thu, 23 Jan 2003 14:12:50 +0100 + +mplayer (0.90rc3-1) unstable; urgency=low + + * show notes in config, not template + * default device in Debian is usually /dev/cdrom, not /dev/dvd + + -- A Mennucc1 Mon, 20 Jan 2003 15:54:57 +0100 + +mplayer (0.90rc2-5) unstable; urgency=low + + * ftp-installer: Please read README.Debian.2 + * other adjustments to debian/* + * notes in the templates were not showing, due to a missing go(); + + -- A Mennucc1 Thu, 16 Jan 2003 10:02:43 +0100 + +mplayer (0.90rc2-4) unstable; urgency=low + + * #DEBHELPER# in postinst was not working OK (not passing arguments) + * template mplayer/install_codecs was not showing + + -- Andrea Mennucc Tue, 14 Jan 2003 09:48:44 +0100 + +mplayer (0.90rc2-3) unstable; urgency=low + + * Thanks to Nagy for teaming up. His are mime and conffile and scripts. + + -- Andrea Mennucc Mon, 13 Jan 2003 16:46:22 +0100 + +mplayer (0.90rc2-2) unstable; urgency=low + + * pass control to debconf scripts in postinst and postrm + * purge debconf database on purge. + + -- Dariush Pietrzak Sun, 12 Jan 2003 15:01:38 +0100 + mplayer (0.90rc3-0) unstable; urgency=low * new release. diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +5 diff --git a/debian/config b/debian/config deleted file mode 100755 index ab3c8c1..0000000 --- a/debian/config +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/sh - -CONFIGFILE=/etc/mplayer/mplayer.conf - -set -e - -# Source debconf library. -. /usr/share/debconf/confmodule - -if test -r $CONFIGFILE && ! grep -q '### mplayer DEBCONF AREA' $CONFIGFILE -then - db_input medium 'mplayer/replace-existing-files' || true - db_go || true - if [ "$RET" != "true" ]; then - exit 0 - fi - db_get 'mplayer/replace-existing-files' || true -fi - -########################################## find fonts -#default font (if available) -BESTFONT=/usr/share/fonts/truetype/Arial.ttf -[ -r $BESTFONT ] || BESTFONT=/usr/share/fonts/truetype/freefont/FreeSans.ttf - -t=$(tempfile -p fonts ) -find /usr/share/fonts/ /?/?in*/?ont* -type f -iname '*.ttf' -maxdepth 3 2> /dev/null > $t || true - -if test -s $t -then - fonts=$( awk '{print a $0;a=", "}' $t || true ) - db_subst "mplayer/ttfont" ttfontchoices $fonts || true - ## suppose the question is skipped: give a default - a=$BESTFONT - [ -r $BESTFONT ] || a=$(head -1 $t) - db_subst "mplayer/ttfont" ttfontdefault $a || true - - db_input medium mplayer/ttfont || true - if [ "$?" = 30 ] ; then - db_set mplayer/ttfont $a || true - fi -else - db_input medium "mplayer/no-ttfont" || true -fi - -rm $t - -db_go || true - -############################################################ - - -exit 0 diff --git a/debian/config.augmenter b/debian/config.augmenter new file mode 100644 index 0000000..6268a0c --- /dev/null +++ b/debian/config.augmenter @@ -0,0 +1,50 @@ +#!/bin/sh + +set -e + +C=$1 + +vo=$(tempfile) + +vo_filter () { + grep '.' | \ + awk '{if(f){print}}/Available video output drivers:/{f=1}' | \ + sed 's/^\t//' +} + +if test -x ./mplayer ; then + if env -i ./mplayer -vo help 2> /dev/null | vo_filter >> $vo ; then + #fallback in case of crisis + grep -q 'x11' $vo || cp -v debian/mplayer.vo.help.fallback $vo + else + #maybe we are cross compiling + cp -v debian/mplayer.vo.help.fallback $vo + fi +else + #maybe it was not compiled + cp -v debian/mplayer.vo.help.fallback $vo +fi + +######### create automagic part +t=$(tempfile) +echo '#start automagic part' >> $t +echo 'cat_vo_complete_list () { cat << EOF' >> $t +cat $vo >> $t +echo 'EOF' >> $t +echo '}' >> $t +echo 'CONFIG_OF_MPLAYER_WAS_AUGMENTED=1' >> $t +echo '#end automagic part' >> $t +############# insert it +mv $C $C~ + +awk '{if(f==0){print}} +/#MPLAYER_AUTOMAGIC#/{f=1}' $C~ > $C + +cat $t >> $C + +awk '{if(f){print}} +/#MPLAYER_AUTOMAGIC#/{f=1}' $C~ >> $C + +rm $C~ $vo $t + +chmod +x $C diff --git a/debian/control b/debian/control index 30f00aa..dc77a12 100644 --- a/debian/control +++ b/debian/control @@ -1,31 +1,62 @@ Source: mplayer -Section: misc +Section: graphics Priority: optional -Maintainer: Diego Biurrun -Standards-Version: 3.2.1 -Build-Depends: libgtk1.2-dev | libgtk2.0-dev, libpng12-dev, zlib1g-dev, x11proto-core-dev, libx11-dev, libxext-dev, libxinerama-dev, libxv-dev, debhelper (>= 2) +Maintainer: A Mennucc1 +Standards-Version: 3.8.0.0 +Vcs-Browser: http://svn.mplayerhq.hu/mplayer/trunk/ +Vcs-Svn: svn://svn.mplayerhq.hu/mplayer +Homepage: http://www.mplayerhq.hu/ +Build-Depends-Indep: docbook-xml, docbook-xsl, xsltproc +Build-Conflicts: gcc-4.3 (<= 4.3.0-3) +Build-Depends: debhelper (>= 4), dpatch, make (>= 3.80), pkg-config, po-debconf, + libsdl1.2-dev | libsdl1.1-dev, libsvga1-dev [i386 amd64], + libdts-dev, ladspa-sdk, vstream-client-dev, + libpng-dev, libncurses5-dev, zlib1g-dev, libspeex-dev, libsmbclient-dev, + libtheora-dev (>= 1.0~beta1-1), libesd0-dev, liblzo2-dev, libgl1-mesa-dev, + libasound2-dev (>= 1.0.6-3) [!kfreebsd-i386 !kfreebsd-amd64 !hurd-i386], + libaudio-dev, libfribidi-dev, libopenal-dev, libmpcdec-dev, + libvorbis-dev, liblircclient-dev, libfreetype6-dev, libdvdread-dev, + libcdparanoia-dev, libfontconfig1-dev, libjpeg62-dev, libgif-dev, + libgtk2.0-dev, libdirectfb-dev, libcaca-dev, liblivemedia-dev, libjack-dev, + libavcodec-dev (>= 0.svn20080206), + libavdevice-dev, libavformat-dev, libavutil-dev, + libpostproc-dev, libswscale-dev, libx11-dev, libxext-dev, libxinerama-dev, libxv-dev, libxvmc-dev, libxxf86dga-dev, libxxf86vm-dev, x11proto-core-dev, Package: mplayer Architecture: any -Depends: ${shlibs:Depends},debconf,libconfhelper-perl -Description: The Ultimate Movie Player - MPlayer is a movie player for LINUX (runs on many other Unices, and non-x86 - CPUs, see the ports section). It plays most MPEG, VOB, AVI, OGG/OGM, VIVO, +Suggests: mplayer-doc, ttf-freefont, netselect | fping, bzip2, fontconfig +Depends: ${shlibs:Depends}, debconf | debconf-2.0, mplayer-skin +Description: movie player for Unix-like systems + MPlayer plays most MPEG, VOB, AVI, Ogg/OGM, VIVO, ASF/WMA/WMV, QT/MOV/MP4, FLI, RM, NuppelVideo, yuv4mpeg, FILM, RoQ, PVA files, - supported by many native, XAnim, RealPlayer, and Win32 DLL codecs. You can - watch VideoCD, SVCD, DVD, 3ivx, RealMedia, and DivX movies too (and you don't - need the avifile library at all!). + supported by many native, XAnim, RealPlayer, and Win32 DLL codecs. It can + also play VideoCD, SVCD, DVD, 3ivx, RealMedia, and DivX movies. . - Another big feature of MPlayer is the wide range of supported output drivers. - It works with X11, Xv, DGA, OpenGL, SVGAlib, fbdev, AAlib, DirectFB, but you - can also use GGI and SDL (and this way all their drivers) and some lowlevel - card-specific drivers (for Matrox, 3Dfx and Radeon, Mach64, Permedia3) too! - Most of them supports software or hardware scaling, so you can enjoy movies in - fullscreen. + Another big feature of MPlayer is the wide range of supported output + drivers. It works with X11, Xv, DGA, OpenGL, SVGAlib, fbdev, + DirectFB, but also SDL (plus all its drivers) and some + low level card-specific drivers (for Matrox, 3Dfx and Radeon, Mach64 + and Permedia3). Most of them support software or hardware scaling, + therefore allowing fullscreen display. MPlayer is also able + to use some hardware MPEG decoder boards, such as the DVB + and DXR3/Hollywood+. This version of MPlayer contains libdvdcss. . - MPlayer supports displaying through some hardware MPEG decoder boards, such as - the DVB and DXR3/Hollywood+. - . - And what about the nice big antialiased shaded subtitles (10 supported types) - with European/ISO 8859-1,2 (Hungarian, English, Czech, etc), Cyrillic, Korean - fonts, and the onscreen display (OSD)? + Not all of the upstream code is distributed in the source tarball. + See the README.Debian and copyright files for details. + +Package: mplayer-dbg +Architecture: any +Priority: extra +Depends: mplayer +Description: debugging symbols for MPlayer + This package contains the debugging symbols for MPlayer, a movie + player for Unix-like systems. You only need these if you want to + generate debugging backtraces. + +Package: mplayer-doc +Architecture: all +Recommends: mplayer +Section: doc +Description: documentation for MPlayer + This package contains the documentation for MPlayer, a movie player for + Unix-like systems. diff --git a/debian/control.in b/debian/control.in new file mode 100644 index 0000000..08d7170 --- /dev/null +++ b/debian/control.in @@ -0,0 +1,62 @@ +Source: @MPLAYER@ +Section: graphics +Priority: optional +Maintainer: A Mennucc1 +Standards-Version: 3.8.0.0 +Vcs-Browser: http://svn.mplayerhq.hu/mplayer/trunk/ +Vcs-Svn: svn://svn.mplayerhq.hu/mplayer +Homepage: http://www.mplayerhq.hu/ +Build-Depends-Indep: @DOCDEP@ +Build-Conflicts: gcc-4.3 (<= 4.3.0-3) +Build-Depends: debhelper (>= 4), dpatch, make (>= 3.80), pkg-config, po-debconf, + libsdl1.2-dev | libsdl1.1-dev, libsvga1-dev [i386 amd64], + libdts-dev, ladspa-sdk, vstream-client-dev, + libpng-dev, libncurses5-dev, zlib1g-dev, libspeex-dev, libsmbclient-dev, + libtheora-dev (>= 1.0~beta1-1), libesd0-dev, liblzo2-dev, libgl1-mesa-dev, + libasound2-dev (>= 1.0.6-3) [!kfreebsd-i386 !kfreebsd-amd64 !hurd-i386], + libaudio-dev, libfribidi-dev, libopenal-dev, libmpcdec-dev, + libvorbis-dev, liblircclient-dev, libfreetype6-dev, libdvdread-dev, + libcdparanoia-dev, libfontconfig1-dev, libjpeg62-dev, libgif-dev, + libgtk2.0-dev, libdirectfb-dev, libcaca-dev, liblivemedia-dev, libjack-dev, + libavcodec-dev (>= 0.svn20080206), + libavdevice-dev, libavformat-dev, libavutil-dev, + libpostproc-dev, libswscale-dev, @XLIBS@, @EXTRA_BUILDDEP@ + +Package: @MPLAYER@ +Architecture: any +Suggests: mplayer-doc, ttf-freefont, netselect | fping, bzip2, fontconfig +Depends: ${shlibs:Depends}, debconf | debconf-2.0, mplayer-skin +Description: movie player for Unix-like systems + MPlayer plays most MPEG, VOB, AVI, Ogg/OGM, VIVO, + ASF/WMA/WMV, QT/MOV/MP4, FLI, RM, NuppelVideo, yuv4mpeg, FILM, RoQ, PVA files, + supported by many native, XAnim, RealPlayer, and Win32 DLL codecs. It can + also play VideoCD, SVCD, DVD, 3ivx, RealMedia, and DivX movies. + . + Another big feature of MPlayer is the wide range of supported output + drivers. It works with X11, Xv, DGA, OpenGL, SVGAlib, fbdev, + DirectFB, but also SDL (plus all its drivers) and some + low level card-specific drivers (for Matrox, 3Dfx and Radeon, Mach64 + and Permedia3). Most of them support software or hardware scaling, + therefore allowing fullscreen display. MPlayer is also able + to use some hardware MPEG decoder boards, such as the DVB + and DXR3/Hollywood+. @DFSG@ + . + Not all of the upstream code is distributed in the source tarball. + See the README.Debian and copyright files for details. + +Package: @MPLAYER@-dbg +Architecture: any +Priority: extra +Depends: mplayer +Description: debugging symbols for MPlayer + This package contains the debugging symbols for MPlayer, a movie + player for Unix-like systems. You only need these if you want to + generate debugging backtraces. + +Package: @MPLAYER@-doc +Architecture: all +Recommends: mplayer +Section: doc +Description: documentation for MPlayer + This package contains the documentation for MPlayer, a movie player for + Unix-like systems. diff --git a/debian/copyright b/debian/copyright index 70645ee..e2cf1e3 100644 --- a/debian/copyright +++ b/debian/copyright @@ -1,8 +1,269 @@ -This package was debianized by * TeLeNiEkO * telenieko@telenieko.com on +----- Debian package + +This package was first debianized by * TeLeNiEkO * telenieko@telenieko.com on Mon, 26 Feb 2001 12:24:04 +0100. -Original source can be found at: http://www.mplayerHQ.hu/homepage/ +The current Debian Mantainer is: Dariush Pietrzak +sponsored by: A Mennucci + +Dariush Pietrzak and A Mennucci hold copyright (c) on the Debian +packaging, that is available under the terms of GNU GPL v2 (see below +for header). + +Original source can be found at: http://www.mplayerhq.hu/ +but (!) the orig.tar.gz contained in Debian is not the +upstream one. See README.Debian for details. + +MPlayer was originally written by Árpád Gereöffy and has been extended and +worked on by many more since then; see the AUTHORS file for an (incomplete) +list. + +----- Copyright of MPlayer + +MPlayer is nowadays copyrighted by the MPlayer team ; +this copyright applies to code written specifically for MPlayer +(see (*) below for the list exceptions). + +----- License of MPlayer + +MPlayer is licensed under the terms of GNU GPL v2 ;the licence header is: + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +On Debian systems, the complete text of the GNU General Public +License, version 2, can be found in /usr/share/common-licenses/GPL-2. + +This license applies to code written specifically for MPlayer; +(see (*) below for the list exceptions). + +---- (*) Other License and Copyright + +MPlayer includes code from several external sources; this is shipped +in subdirectories; (summarized) copyrights and licenses are as follows: + +Name: FFmpeg +Version: CVS snapshot +Homepage: http://www.ffmpeg.org +Directory: libavcodec, libavformat, libavutil, libpostproc +Copyright (c) The ffmpeg Project + (see individual files for other copyrights) +License: GNU Lesser General Public License, some parts GNU General Public + License, GNU General Public License when combined + +Name: FAAD2 +Version: 2.1 beta (20040915 CVS snapshot) + fixes and portability patches +Homepage: http://www.audiocoding.com +Directory: libfaad2 +Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +License: GNU General Public License + +Name: GSM 06.10 library +Version: patchlevel 10 +Homepage: http://kbs.cs.tu-berlin.de/~jutta/toast.html +Copyright 1992 by Jutta Degener and Carsten Bormann, Technische Universitaet Berlin +Directory: libmpcodecs/native/ +License: + Any use of this software is permitted provided that this notice is + not removed and that neither the authors nor the Technische + Universitaet Berlin are deemed to have made any representations as to + the suitability of this software for any purpose nor are held + responsible for any defects of this software. THERE IS ABSOLUTELY NO + WARRANTY FOR THIS SOFTWARE. + As a matter of courtesy, the authors request to be informed about + uses this software has found, about bugs in this software, and about + any improvements that may be of general interest. + +Name: miniLZO +Version: 1.07 +Homepage: http://www.oberhumer.com/opensource/lzo/#minilzo +File: libmpcodecs/native/minilzo.c libmpcodecs/native/minilzo.h +Copyright (C) 1996-2000 Markus Franz Xaver Johannes Oberhumer +License: GNU General Public License + +Name: liba52 +Version: 0.7.4 + patches +Homepage: http://liba52.sourceforge.net/ +Directory: liba52 +Copyright (C) 2000-2001 Michel Lespinasse +Copyright (C) 1999-2000 Aaron Holtzman +License: GNU General Public License + +Name: libmpeg2 +Version: 0.4.0b + patches +Homepage: http://libmpeg2.sourceforge.net/ +Directory: libmpeg2 +Copyright (C) 2000-2003 Michel Lespinasse +Copyright (C) 1999-2000 Aaron Holtzman +Copyright (C) 2003 David S. Miller +Copyright (c) 2002-2003 Falk Hueffner +License: GNU General Public License + +Name: mpg123 +Version: 0.59s + significant changes +Homepage: http://www.mpg123.de/ +Directory: mp3lib +Copyright (c) 1995 by Michael Hipp +License: GNU General Public License + +Name: Tremor +Version: 1.0 + parts CVS from December 2004 + patches +Homepage: http://xiph.org/ +Directory: tremor +Copyright (c) 2002, Xiph.org Foundation +License: BSD-like: + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + - Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + - Neither the name of the Xiph.org Foundation nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION + OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Name: avifile DLL loader +Version: 0.47 + patches + CVS updates +Homepage: http://avifile.sourceforge.net/ +Directory: loader/ +Copyright 1995 Alexandre Julliard +Copyright 1994 Eric Youndale & Erik Bos +Copyright 1996-98 Marcus Meissner +Copyright 1995 Thomas Sandford +Copyright 1996 Martin von Loewis +Copyright 1993 Robert J. Amstadt +Copyright 1995-1996 Alexandre Julliard +Copyright 2000-2001 Eugene Kuznetsov (divx@euro.ru) +License: GNU General Public License + +Name: dvbstream +Version: 0.4.3-pre3 (cvs checkout) +Homepage: http://www.linuxstb.org/dvbstream/ + now at http://prdownloads.sourceforge.net/dvbtools/ +File: libmpdemux/dvbin.h libmpdemux/dvbin.c libmpdemux/rtp.h +Copyright (C) 2002 the xine project +License: GNU General Public License + +Name: librtsp +Version: xine CVS 2003/04/10 + patches +Homepage: http://www.xinehq.de +Directory: stream/librtsp/ +Copyright (C) 2000-2002 the xine project +License: GNU General Public License + +Name: realrtsp +Version: xine CVS 2003/04/17 + patches +Homepage: http://www.xinehq.de +Directory: stream/realrtsp/ +Copyright (C) 2000-2002 the xine project +License: GNU General Public License + +Name: id3edit +Version: 1.9 + patches +Homepage: http://id3edit.sourceforge.net/ +Directory: libmpdemux/genres.h +Copyright (C) 2001 Jason Carter +License: GNU General Public License + +Name: matroxset +Version: 0.3 +Homepage: ftp://platan.vc.cvut.cz/pub/linux/matrox-latest/ +Directory: TOOLS/TVout/matroxset/ +License: GNU General Public License + +Name: unrarlib +Version: 0.4.0 + patches +Homepage: http://www.unrarlib.org/ +File: unrarlib.[ch] +Copyright (C) 2000-2002 by Christian Scheurer (www.ChristianScheurer.ch) + UNIX port copyright (c) 2000-2002 by Johannes Winkelmann (jw@tks6.net) +License: GNU General Public License / UniquE RAR File Library License + +File: mmx.h +Copyright: 1997-99 by H. Dietz and R. Fisher +License: + THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY + EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT + LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR ANY PARTICULAR PURPOSE. + +Name: uCIFS library +Version: development files as of september 2004 +Homepage: http://ubiqx.org/libcifs/ +Directory: libvo/md5sum.[ch] +License: GNU Lesser General Public License + +Name: FreeSDP +Version: 0.4.1 +Homepage: https://savannah.nongnu.org/projects/freesdp/ +Directory: stream/freesdp/ +Copyright (C) 2001,2002,2003 Federico Montesino Pouzols +License: GNU General Public License + +--- libmpdemux +libmpdemux is itself a collection of code from different sources + +File: libmpdemux/pnm.c libmpdemux/pnm.h +Copyright (C) 2000-2002 the xine project +License: GNU General Public License + +File: libmpdemux/demux_avs.c libmpdemux/demux_avs.h +Copyright (c) 2005 Gianluigi Tiesi +Copyright 2003 Kevin Atkinson +License: GNU General Public License + + +Name: lavtools +File: libmpdemux/yuv4mpeg.h +Home: mjpeg.sourceforge.net +Copyright (C) 2001 Matthew J. Marjanovic +License: GNU General Public License -Copyrighted by various authors. Licensed under the terms of GNU GPL. -See /usr/share/common-licenses/GPL for details. +Name: XMMS - Cross-platform multimedia player +File: libmpdemux/demux_xmms_plugin.h +Copyright (C) 1998-2000 Peter Alm, Mikael Alm, Olle Hallnas, Thomas Nilsson and 4Front Technologies +License: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. 2. + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. diff --git a/debian/dirs b/debian/dirs deleted file mode 100644 index 8d1744a..0000000 --- a/debian/dirs +++ /dev/null @@ -1,5 +0,0 @@ -usr/bin -usr/share/man/man1 -usr/share/mplayer -usr/lib/mplayer -usr/share/applications diff --git a/debian/menu b/debian/menu deleted file mode 100644 index 06a7c7f..0000000 --- a/debian/menu +++ /dev/null @@ -1,6 +0,0 @@ -?package(mplayer):\ - needs="X11"\ - section="Apps/Viewers"\ - title="MPlayer"\ - command="/usr/bin/gmplayer"\ - icon="/usr/share/pixmaps/mplayer.xpm" diff --git a/debian/mime b/debian/mime deleted file mode 100644 index 422c07e..0000000 --- a/debian/mime +++ /dev/null @@ -1,20 +0,0 @@ -application/x-ogg; mplayer %s; description="Ogg Stream" -application/ogg; mplayer %s; description="Ogg Stream" -audio/mpeg; mplayer %s; description="MPEG Audio" -audio/x-mpegurl; mplayer %s; description="Icecast Playlist" -audio/x-ms-wax; mplayer %s; description="Windows Media Audio" -audio/x-ms-wma; mplayer %s; description="Windows Media Audio" -audio/x-pls; mplayer %s; description="MP3 ShoutCast/IceCast Playlist" -audio/x-scpls; mplayer %s; description="Shoutcast Playlist" -audio/x-wav; mplayer %s; description="WAV Audio" -video/mpeg; mplayer %s; description="MPEG Video"; -video/quicktime; mplayer %s; description="Apple QuickTime Video"; -video/x-mpeg; mplayer %s; description="MPEG Video"; -video/x-mpeg2; mplayer %s; description="MPEG-2 Video"; -video/x-msvideo; mplayer %s; description="MS Video (AVI)"; -video/x-ms-afs; mplayer %s; description="Microsoft ASF Video"; -video/x-ms-asf; mplayer %s; description="Microsoft ASF Video"; -video/x-ms-wma; mplayer %s; description="Windows Media Audio"; -video/x-ms-wmv; mplayer %s; description="Windows Media Video"; -video/x-ms-wmx; mplayer %s; description="Windows Media Video"; -video/x-ms-wvx; mplayer %s; description="Windows Media Video"; diff --git a/debian/mplayer-dbg.links b/debian/mplayer-dbg.links new file mode 100644 index 0000000..1562cd1 --- /dev/null +++ b/debian/mplayer-dbg.links @@ -0,0 +1 @@ +/usr/lib/debug/usr/bin/mplayer /usr/lib/debug/usr/bin/gmplayer diff --git a/debian/mplayer-doc.doc-base.cs b/debian/mplayer-doc.doc-base.cs new file mode 100644 index 0000000..1040557 --- /dev/null +++ b/debian/mplayer-doc.doc-base.cs @@ -0,0 +1,11 @@ +Document: mplayer-cs +Title: MPlayer documentation (Czech) +Author: The MPlayer team +Abstract: This documentation describes the use of MPlayer. (Czech) + MPlayer is a movie player for GNU/Linux that supports a wide + range of audio and video formats, and output drivers. +Section: Sound + +Format: HTML +Index: /usr/share/doc/mplayer-doc/HTML/cs/index.html +Files: /usr/share/doc/mplayer-doc/HTML/cs/*.html diff --git a/debian/mplayer-doc.doc-base.de b/debian/mplayer-doc.doc-base.de new file mode 100644 index 0000000..74cbaf1 --- /dev/null +++ b/debian/mplayer-doc.doc-base.de @@ -0,0 +1,11 @@ +Document: mplayer-de +Title: MPlayer documentation (German) +Author: The MPlayer team +Abstract: This documentation describes the use of MPlayer. (German) + MPlayer is a movie player for GNU/Linux that supports a wide + range of audio and video formats, and output drivers. +Section: Sound + +Format: HTML +Index: /usr/share/doc/mplayer-doc/HTML/de/index.html +Files: /usr/share/doc/mplayer-doc/HTML/de/*.html diff --git a/debian/mplayer-doc.doc-base.en b/debian/mplayer-doc.doc-base.en new file mode 100644 index 0000000..a103af0 --- /dev/null +++ b/debian/mplayer-doc.doc-base.en @@ -0,0 +1,11 @@ +Document: mplayer-en +Title: MPlayer documentation (English) +Author: The MPlayer team +Abstract: This documentation describes the use of MPlayer. (English) + MPlayer is a movie player for GNU/Linux that supports a wide + range of audio and video formats, and output drivers. +Section: Sound + +Format: HTML +Index: /usr/share/doc/mplayer-doc/HTML/en/index.html +Files: /usr/share/doc/mplayer-doc/HTML/en/*.html diff --git a/debian/mplayer-doc.doc-base.es b/debian/mplayer-doc.doc-base.es new file mode 100644 index 0000000..fa3c1eb --- /dev/null +++ b/debian/mplayer-doc.doc-base.es @@ -0,0 +1,11 @@ +Document: mplayer-es +Title: MPlayer documentation (Spanish) +Author: The MPlayer team +Abstract: This documentation describes the use of MPlayer. (Spanish) + MPlayer is a movie player for GNU/Linux that supports a wide + range of audio and video formats, and output drivers. +Section: Sound + +Format: HTML +Index: /usr/share/doc/mplayer-doc/HTML/es/index.html +Files: /usr/share/doc/mplayer-doc/HTML/es/*.html diff --git a/debian/mplayer-doc.doc-base.fr b/debian/mplayer-doc.doc-base.fr new file mode 100644 index 0000000..55a10cc --- /dev/null +++ b/debian/mplayer-doc.doc-base.fr @@ -0,0 +1,11 @@ +Document: mplayer-fr +Title: MPlayer documentation (French) +Author: The MPlayer team +Abstract: This documentation describes the use of MPlayer. (French) + MPlayer is a movie player for GNU/Linux that supports a wide + range of audio and video formats, and output drivers. +Section: Sound + +Format: HTML +Index: /usr/share/doc/mplayer-doc/HTML/fr/index.html +Files: /usr/share/doc/mplayer-doc/HTML/fr/*.html diff --git a/debian/mplayer-doc.doc-base.hu b/debian/mplayer-doc.doc-base.hu new file mode 100644 index 0000000..a641b9a --- /dev/null +++ b/debian/mplayer-doc.doc-base.hu @@ -0,0 +1,11 @@ +Document: mplayer-hu +Title: MPlayer documentation (Hungarian) +Author: The MPlayer team +Abstract: This documentation describes the use of MPlayer. (Hungarian) + MPlayer is a movie player for GNU/Linux that supports a wide + range of audio and video formats, and output drivers. +Section: Sound + +Format: HTML +Index: /usr/share/doc/mplayer-doc/HTML/hu/index.html +Files: /usr/share/doc/mplayer-doc/HTML/hu/*.html diff --git a/debian/mplayer-doc.doc-base.pl b/debian/mplayer-doc.doc-base.pl new file mode 100644 index 0000000..42eb098 --- /dev/null +++ b/debian/mplayer-doc.doc-base.pl @@ -0,0 +1,11 @@ +Document: mplayer-pl +Title: MPlayer documentation (Polish) +Author: The MPlayer team +Abstract: This documentation describes the use of MPlayer. (Polish) + MPlayer is a movie player for GNU/Linux that supports a wide + range of audio and video formats, and output drivers. +Section: Sound + +Format: HTML +Index: /usr/share/doc/mplayer-doc/HTML/pl/index.html +Files: /usr/share/doc/mplayer-doc/HTML/pl/*.html diff --git a/debian/mplayer-doc.doc-base.ru b/debian/mplayer-doc.doc-base.ru new file mode 100644 index 0000000..d29061c --- /dev/null +++ b/debian/mplayer-doc.doc-base.ru @@ -0,0 +1,11 @@ +Document: mplayer-ru +Title: MPlayer documentation (Russian) +Author: The MPlayer team +Abstract: This documentation describes the use of MPlayer. (Russian) + MPlayer is a movie player for GNU/Linux that supports a wide + range of audio and video formats, and output drivers. +Section: Sound + +Format: HTML +Index: /usr/share/doc/mplayer-doc/HTML/ru/index.html +Files: /usr/share/doc/mplayer-doc/HTML/ru/*.html diff --git a/debian/mplayer.config b/debian/mplayer.config new file mode 100644 index 0000000..1ceaff8 --- /dev/null +++ b/debian/mplayer.config @@ -0,0 +1,177 @@ +#!/bin/sh +set -e + +if [ ! -e /usr/share/debconf/confmodule ]; then + exit +fi + +# Source debconf library. +. /usr/share/debconf/confmodule + +db_version 2.0 + +##db_capb backup ?! it was never implemented! + +#db_title MPlayer + +case "${1}" in + (configure|reconfigure) #will go on + ;; + (*) echo >&2 "${0##*/}: Called with unknown argument \`${1}'." + exit 1 + ;; +esac + + +case "$(dpkg --print-installation-architecture)" in + i386|powerpc|alpha) + db_input medium mplayer/install_codecs || true + ;; +esac + +#for questions related to creation of /etc/mplayer/mplayer.conf +CONFPRIORITY=medium +#mplayer conf +CONF=/etc/mplayer/mplayer.conf + +conf_has_nice_area () { + grep -q '^### mplayer DEBCONF AREA' $CONF \ + && grep -q '^### END OF DEBCONF AREA.' $CONF +} + +### test that we are not stomping the user feet here +if test -r $CONF && ! conf_has_nice_area +then + db_input $CONFPRIORITY 'mplayer/replace-existing-files' || true + db_go || true + db_get 'mplayer/replace-existing-files' || true + if [ "$RET" != "true" ] + then + db_input $CONFPRIORITY 'mplayer/replace-existing-files-bail' || true + db_go || true + exit 0 + #since we are bailing out, all code from here on must be related to $CONF + fi +fi + +db_go || true + +### OK, go on configuring $CONF + +#db_beginblock + +db_input $CONFPRIORITY mplayer/cfgnote || true + + +#db_endblock + +#db_go || true + + +########################################## dvd device + +db_input $CONFPRIORITY mplayer/dvd_device || true + + + +########################################## find fonts + +t=$(tempfile -p fonts ) + +echo Sans >> $t +echo Serif >> $t +#this command is in package 'fontconfig' +if test -x /usr/bin/fc-list ; then + fc-list : family | cut -d, -f1 >> $t +fi + +if test -s $t +then + fonts=$( awk '{printf("%s%s",a,$0) ; a=", "}' $t || true ) + db_subst "mplayer/ttfont" ttfontchoices $fonts || true + + # hack to work around set -e.. + db_input low mplayer/ttfont && ret=0 || ret=$? + if [ "$ret" = 30 ] ; then + db_set mplayer/ttfont Sans || true + fi +else + db_input $CONFPRIORITY "mplayer/no-ttfont" || true +fi + + +rm $t + +############################################################## + +#a list of mplayer -vo is added here automagically (see debian/config.augmenter) +#it is returned by a function cat_vo_complete_list +#MPLAYER_AUTOMAGIC# + +vo_filter () { + grep '.' | \ + awk '{if(f){print}}/Available video output drivers:/{f=1}' | \ + sed 's/^\t//' +} + +vo_grep () { + egrep -vw 'png|pgm|md5|tga|gif|jpeg|null|yuv4mpeg|gif89a' || true +} + + +cat_vo () { + if [ "$CONFIG_OF_MPLAYER_WAS_AUGMENTED" ]; then + cat_vo_complete_list | vo_grep + elif which mplayer 2>&1 > /dev/null ; then + # env -i is there to avoid locales + env -i mplayer -vo help 2> /dev/null | vo_filter | vo_grep + else + #emergency fall back + /bin/echo -e 'xv\tX11/Xv accelerated' + /bin/echo -e 'x11\tX11 not accelerated' + fi +} + + +vo_list () { + cat_vo |\ + tr -c 'a-zA-Z0-9.+"/()!\n'"'-" '_' | \ + awk '{print a $0 ; a=", ";}' || true +} + + +#restore default +#db_get 'mplayer/voutput' || true +#DEF="$RET" +#[ "$DEF" ] && DEF=$( vo_list | grep "^$DEF" | head -1 | tr -d '\n') +#[ "$DEF" ] || DEF=xv +#echo "$DEF" > /tmp/HACK + + + +db_subst "mplayer/voutput" vochoices autodetect, $( vo_list || true ) || true + +## now 'autodetect' is the default choice +#DEF=$( cat_vo | grep "^xv" | head -1 | tr -d '\n' || true) +#db_subst "mplayer/voutput" vodefault $DEF || true + +db_input low mplayer/voutput || true + +db_go || true + + +#if db_input $CONFPRIORITY mplayer/voutput ; then + #clean up answer to voutput + #db_get 'mplayer/voutput' || true + #RET=$(echo $RET | awk 'BEGIN{FS="_"};{print $1}') + ##fallback if I have messed up something + #[ "$RET" ] || RET=xv + #db_set 'mplayer/voutput' $RET || true +#fi +#db_go || true + + +############################################################ + + +exit 0 diff --git a/debian/mplayer.dirs b/debian/mplayer.dirs new file mode 100644 index 0000000..c2d7eef --- /dev/null +++ b/debian/mplayer.dirs @@ -0,0 +1,4 @@ +usr/bin +usr/share/man/man1 +usr/share/mplayer +usr/lib/mplayer diff --git a/debian/mplayer.files b/debian/mplayer.files new file mode 100644 index 0000000..e6a6064 --- /dev/null +++ b/debian/mplayer.files @@ -0,0 +1,2 @@ +mplayer_1.0-pre-cvs-2003-03-24_i386.deb graphics optional +mplayer-doc_1.0-pre-cvs-2003-03-24_i386.deb graphics optional diff --git a/debian/mplayer.menu b/debian/mplayer.menu new file mode 100644 index 0000000..1226152 --- /dev/null +++ b/debian/mplayer.menu @@ -0,0 +1 @@ +?package(mplayer):command="/usr/bin/gmplayer" section="Applications/Video" needs="X11" title="gmplayer" diff --git a/debian/mplayer.mime b/debian/mplayer.mime new file mode 100644 index 0000000..4bf2087 --- /dev/null +++ b/debian/mplayer.mime @@ -0,0 +1,21 @@ +application/x-ogg; /usr/bin/gmplayer %s; description="OggVorbis Audio" +application/ogg; /usr/bin/gmplayer %s; description="OggVorbis Audio" +audio/mpeg; /usr/bin/gmplayer %s; description="MPEG Audio Format" +audio/x-mpegurl; /usr/bin/gmplayer %s; description="Icecast Playlists" +audio/x-ms-wax; /usr/bin/gmplayer %s; description="Audio Format" +audio/x-ms-wma; /usr/bin/gmplayer %s; description="Audio Format" +audio/x-pls; /usr/bin/gmplayer %s; description="MP3 ShoutCast/IceCast Playlist" +audio/x-scpls; /usr/bin/gmplayer %s; description="Shoutcast Playlists" +audio/x-wav; /usr/bin/gmplayer %s; description="Waveform Microsoft Wave/RIFF" +video/mpeg; /usr/bin/gmplayer %s; description="MPEG Video Format"; test=test -n "$DISPLAY" +video/quicktime; /usr/bin/gmplayer %s; description="Apple Quicktime Video"; test=test -n "$DISPLAY" +video/x-mpeg2; /usr/bin/gmplayer %s; description="MPEG Video"; test=test -n "$DISPLAY" +video/x-mpeg; /usr/bin/gmplayer %s; description="MPEG 2 Video"; test=test -n "$DISPLAY" +video/mpeg; /usr/bin/gmplayer %s; description="MPEG 2 Video"; test=test -n "$DISPLAY" +video/x-ms-afs; /usr/bin/gmplayer %s; description="Audio Video Interleave - Microsoft"; test=test -n "$DISPLAY" +video/x-ms-asf; /usr/bin/gmplayer %s; description="MS ASF video"; test=test -n "$DISPLAY" +video/x-msvideo; /usr/bin/gmplayer %s; description="Audio Video Interleave - Microsoft"; test=test -n "$DISPLAY" +video/x-ms-wma; /usr/bin/gmplayer %s; description="Audio Video Interleave - Microsoft"; test=test -n "$DISPLAY" +video/x-ms-wmv; /usr/bin/gmplayer %s; description="Audio Video Interleave - Microsoft"; test=test -n "$DISPLAY" +video/x-ms-wmx; /usr/bin/gmplayer %s; description="Audio Video Interleave - Microsoft"; test=test -n "$DISPLAY" +video/x-ms-wvx; /usr/bin/gmplayer %s; description="Audio Video Interleave - Microsoft"; test=test -n "$DISPLAY" diff --git a/debian/mplayer.postinst b/debian/mplayer.postinst new file mode 100644 index 0000000..4ffcae4 --- /dev/null +++ b/debian/mplayer.postinst @@ -0,0 +1,125 @@ +#!/bin/sh +# mplayer postinst + +set -e + +myecho=echo +if [ "$BASH_VERSION" = "" ] ; then + myecho=/bin/echo +fi + +message () { + $myecho -n -e "$*" >&2 ; +} + + +if test ! -e /usr/share/debconf/confmodule ; then + exit +fi + +# Source debconf library. +. /usr/share/debconf/confmodule + +db_version 2.0 + +start="### mplayer DEBCONF AREA. DO NOT EDIT THIS AREA OR INSERT TEXT BEFORE IT." +end='### END OF DEBCONF AREA. PLACE YOUR EDITS BELOW; THEY WILL BE PRESERVED.' + +CONF="/etc/mplayer/mplayer.conf" + +conf_has_nice_area () { + grep -q '^### mplayer DEBCONF AREA' $CONF \ + && grep -q '^### END OF DEBCONF AREA.' $CONF +} + + +create_conf () { + #mark this question, so it will be asked again, if the user + #replaces the file /etc/mplayer/mplayer.conf + db_fset 'mplayer/replace-existing-files' 'seen' 'false' + + t=`tempfile -m 644` + + echo "$start" > $t + + db_get "mplayer/voutput" + vo=`echo "$RET" | sed 's/_.*//;s/\W.*//'` + if test "$RET" -a "$vo" != "" ; then + if test "$vo" = "autodetect" ; then + vo="xv,x11" + fi + echo "#video output driver" >> $t + echo "vo=$vo" >> $t + if test "$vo" = 'x11' -o "$vo" = 'fbdev' ; then + echo "#needed for vo=${vo}" >> $t + echo "zoom=1" >> $t + fi + fi + db_get "mplayer/dvd_device" + if test "$RET" ; then + echo "#device for dvd" >> $t + echo "dvd-device=${RET}" >> $t + test -r "$RET" || message "Mplayer warning: dvd device '$RET' does not exist!\n" + fi + + db_get "mplayer/ttfont" + if test "$RET" ; then + echo "#truetype font, using fontconfig" >> $t + echo "fontconfig=1" >> $t + echo "font='${RET}'" >> $t + fi + + echo "#if you do not like this default, override it by adding" >> $t + echo "# a ao= line below this debconf area" >> $t + echo "ao=alsa,oss" >> $t + + echo "$end" >> $t + if test -r $CONF ; then + awk 'BEGIN{a=0};//{if(a){print}};/### END OF DEBCONF AREA./{a=1};' $CONF >> $t + fi + mv -b $t $CONF + message "done\n" +} + +message "Configuring mplayer ..." + +if test -r $CONF ; then + if conf_has_nice_area ; then + create_conf + else + db_get 'mplayer/replace-existing-files' + if test "$RET" = 'true' ; then + message " generating new $CONF,\n moving previous to $CONF.debconf-old\n ..." + mv $CONF ${CONF}.debconf-old + create_conf + else + message " not modifying $CONF.\n" + fi + fi +else + create_conf +fi + +db_stop #using debconf + +## remove old init files +if [ -r /etc/init.d/mplayer ]; then + if echo 'a6c67e6132f7b9be6fd1b1d19b76946f /etc/init.d/mplayer' |\ + md5sum -c - >/dev/null ; then + rm /etc/init.d/mplayer + update-rc.d mplayer remove + else + echo "MPlayer warning: the script /etc/init.d/mplayer is now deprecated, but it was locally modified. Please consider deleting it (and run 'update-rc.d mplayer remove' as well)." + fi +fi + + + +########################### +# pass control to debhelper scripts.. +# + +#DEBHELPER# + +######################### + diff --git a/debian/mplayer.postrm b/debian/mplayer.postrm new file mode 100644 index 0000000..1b8e706 --- /dev/null +++ b/debian/mplayer.postrm @@ -0,0 +1,11 @@ +#!/bin/sh + +set -e + +if [ "$1" = "purge" ]; then + if [ -d /etc/mplayer/ ]; then + rm -rf /etc/mplayer/ + fi +fi + +#DEBHELPER# diff --git a/debian/mplayer.templates b/debian/mplayer.templates new file mode 100644 index 0000000..2cbb1be --- /dev/null +++ b/debian/mplayer.templates @@ -0,0 +1,80 @@ +Template: mplayer/cfgnote +Type: note +_Description: Detailed configuration needed for each user + The performance of MPlayer depends heavily on hardware; this means that + it may benefit from tweaking options for every single machine it's + installed on. + . + You should read the documentation provided by the + 'mplayer-doc' package. + . + Now, some configuration options will be set for the entire system in + /etc/mplayer/mplayer.conf which may be adapted later. Any user can also + refine options in ~/.mplayer/config. + +Template: mplayer/replace-existing-files +Type: boolean +Default: false +_Description: Replace existing configuration file? + An /etc/mplayer/mplayer.conf file already exists on the system and + does not contain an automatically-generated part. That file can be replaced + by a generated one (the old file will be moved to + /etc/mplayer/mplayer.conf.debconf-old). + +Template: mplayer/replace-existing-files-bail +Type: note +_Description: Old configuration file kept + You chose not to replace the existing /etc/mplayer/mplayer.conf + file. + . + That file can be generated automatically later by running + 'dpkg-reconfigure mplayer'. + +Template: mplayer/voutput +Type: select +Default: autodetect +Choices: ${vochoices} +_Description: MPlayer video output: + MPlayer can use a very wide range of video output drivers. + The needed driver may be detected automatically or chosen manually. + . + If you prefer choosing the driver yourself, you first should choose + an entry matching this system's video card. If none match and the + card supports 'XV', choose that option (the 'xvinfo' command may help). + . + Please read the /usr/share/doc/mplayer-doc/HTML/en/video.html file from + the 'mplayer-doc' package for more details. + +Template: mplayer/install_codecs +Type: note +_Description: Binary codecs download + MPlayer supports most video formats without additional software. + . + Additional video formats, such as Real 3.0/4.0, Windows Media 9, or Quicktime, + can be supported by using binary codecs. + . + As such codecs are not free software, they are not distributed with + this package but can be downloaded freely. The + '/usr/share/mplayer/scripts/binary_codecs.sh' script is provided in + this package to help downloading them from the MPlayer web site. + +Template: mplayer/dvd_device +Type: string +Default: /dev/cdrom +_Description: DVD device name: + Please enter the name of the device for your DVD player, if any. + +Template: mplayer/ttfont +Type: select +Choices: ${ttfontchoices} +Default: ${ttfontdefault} +_Description: Font for On Screen Display: + +Template: mplayer/no-ttfont +Type: error +_Description: No TrueType fonts found for On Screen Display + MPlayer needs at least one TrueType font for its 'On Screen Display' feature. + . + You should install a package providing such fonts (such as + 'ttf-freefont' or 'ttf-bitstream-vera' or 'msttcorefonts') + and reconfigure MPlayer (by running 'dpkg-reconfigure mplayer'). diff --git a/debian/mplayer.vo.help.fallback b/debian/mplayer.vo.help.fallback new file mode 100644 index 0000000..c905246 --- /dev/null +++ b/debian/mplayer.vo.help.fallback @@ -0,0 +1,26 @@ +xmga Matrox G200/G4x0/G550 overlay in X11 window (using /dev/mga_vid) +mga Matrox G200/G4x0/G550 overlay (/dev/mga_vid) +tdfxfb 3Dfx Banshee/Voodoo3/Voodoo5 +3dfx 3dfx (/dev/3dfx) +xv X11/Xv +x11 X11 ( XImage/Shm ) +xover General X11 driver for overlay capable video output drivers +dga DGA ( Direct Graphic Access V2.0 ) +sdl SDL YUV/RGB/BGR renderer (SDL v1.1.7+ only!) +fbdev Framebuffer Device +fbdev2 Framebuffer Device +svga SVGAlib +directfb Direct Framebuffer Device +dfbmga DirectFB / Matrox G200/G400/G450/G550 +xvidix X11 (VIDIX) +cvidix console VIDIX +null Null video output +xvmc XVideo Motion Compensation +mpegpes Mpeg-PES to DVB card +yuv4mpeg yuv4mpeg output for mjpegtools +png PNG file +jpeg JPEG file +gif89a animated GIF output +tga Targa output +pnm PPM/PGM/PGMYUV file +md5sum md5sum of each frame diff --git a/debian/patches/00list b/debian/patches/00list new file mode 100644 index 0000000..91e8e8e --- /dev/null +++ b/debian/patches/00list @@ -0,0 +1,22 @@ +#10configure-alpha.dpatch +#11configure-mktemp.dpatch +#12configure-vidix-alpha.dpatch +#22disable-xscreensaver.dpatch +#24mplayer.desktop.dpatch +#25mplayer-desktop.dpatch +#25kFreeBDS.dpatch +#30vorbis-block-alloc.dpatch +#40rtsp_demux.dpatch +#51xsai.dpatch +#CVE-2008-0630.diff +#CVE-2008-0629--stream_cddb.c.diff +#CVE-2008-0073--rtsp_fix.diff +#demux_mov_fix_20080129.diff +#demux_audio_fix_20080129.diff +#mplayer-debug-printf.dpatch +shared_linking_to_ffmpeg.dpatch +#to-ffmpeg-free-0.svn20080206.diff +#demux.patch +#theora_length_fix_svn27354.diff +#oCERT-2008-013--realfix.diff +#SA33136_demux_vqf.c.diff diff --git a/debian/patches/10configure-alpha.dpatch b/debian/patches/10configure-alpha.dpatch new file mode 100644 index 0000000..3b08d5f --- /dev/null +++ b/debian/patches/10configure-alpha.dpatch @@ -0,0 +1,64 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## 00alpha.dpatch by +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: ./configure --target=alpha_ev5-linux + +@DPATCH@ +diff -urNad mplayer-1.0~rc2~/configure mplayer-1.0~rc2/configure +--- mplayer-1.0~rc2~/configure 2007-10-07 21:49:33.000000000 +0200 ++++ mplayer-1.0~rc2/configure 2007-10-18 19:46:04.000000000 +0200 +@@ -146,7 +146,7 @@ + + alpha() { + case "$host_arch" in +- alpha) return 0;; ++ alpha*) return 0;; + *) return 1;; + esac + } +@@ -2126,14 +2126,20 @@ + + ;; + +- alpha) ++ alpha*) + _arch='ALPHA' + _target_arch='ARCH_ALPHA = yes' + iproc='alpha' + _march='' + + echocheck "CPU type" +- cat > $TMPC << EOF ++ if test "$_target" ; then ++ proc=`echo $_target | cut -d '-' -f 1 | cut -d '_' -f 2` ++ _mcpu="$cpuopt=$proc" ++ #it seems that there is a runtime detection for the MVI code ++ cpu_understands_mvi="1"; ++ else ++ cat > $TMPC << EOF + int main() { + unsigned long ver, mask; + asm ("implver %0" : "=r" (ver)); +@@ -2142,9 +2148,8 @@ + return 0; + } + EOF +- $_cc -o "$TMPEXE" "$TMPC" +- case `"$TMPEXE"` in +- ++ $_cc -o "$TMPEXE" "$TMPC" ++ case `"$TMPEXE"` in + 0-0) proc="ev4"; _mvi="0";; + 1-0) proc="ev5"; _mvi="0";; + 1-1) proc="ev56"; _mvi="0";; +@@ -2152,7 +2157,8 @@ + 2-303) proc="ev6"; _mvi="1";; + 2-307) proc="ev67"; _mvi="1";; + 2-1307) proc="ev68"; _mvi="1";; +- esac ++ esac ++ fi + echores "$proc" + + echocheck "GCC & CPU optimization abilities" diff --git a/debian/patches/11configure-mktemp.dpatch b/debian/patches/11configure-mktemp.dpatch new file mode 100644 index 0000000..7e52699 --- /dev/null +++ b/debian/patches/11configure-mktemp.dpatch @@ -0,0 +1,21 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## 01configure-mktemp.diff.dpatch by +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: use mktemp for temp files + +@DPATCH@ +diff -urNad mplayer-1.0~rc2~/configure mplayer-1.0~rc2/configure +--- mplayer-1.0~rc2~/configure ++++ mplayer-1.0~rc2/configure +@@ -1357,6 +1357,10 @@ + test "$I" && break + done + ++if which mktemp >/dev/null 2>/dev/null; then ++ # BSD/Debian/etc. mktemp avoids symlink attacks etc. ++ I=`mktemp -d "$I"/mplayer.XXXXXX` || exit 1 ++fi + + TMPLOG="configure.log" + TMPC="$I/mplayer-conf-$RANDOM-$$.c" diff --git a/debian/patches/12configure-vidix-alpha.dpatch b/debian/patches/12configure-vidix-alpha.dpatch new file mode 100644 index 0000000..4f4c04c --- /dev/null +++ b/debian/patches/12configure-vidix-alpha.dpatch @@ -0,0 +1,20 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## configure-vidix-alpha.dpatch by +## +## DP: vidix : cyberblade sis unichrome fail on alpha, and are probably +## DP: useless but in x86_32 and x86_64 archs + +@DPATCH@ +diff -urNad mplayer-1.0~rc2~/configure mplayer-1.0~rc2/configure +--- mplayer-1.0~rc2~/configure 2007-10-07 21:49:33.000000000 +0200 ++++ mplayer-1.0~rc2/configure 2007-10-19 18:04:20.000000000 +0200 +@@ -4238,7 +4238,7 @@ + test $_ivtv = "yes" || _vidix_drivers=`echo $_vidix_drivers | sed s/ivtv//` + +- # some vidix drivers are not meant to work on powerpc, discard them +- ppc && _vidix_drivers=`echo $_vidix_drivers | sed -e s/cyberblade// -e s/sis// -e s/unichrome//` ++ # some vidix drivers are not meant to work on !x86, discard them ++ x86 || _vidix_drivers=`echo $_vidix_drivers | sed -e s/cyberblade// -e s/sis// -e s/unichrome//` + + for driver in $_vidix_drivers ; do + uc_driver=`echo $driver | tr '[a-z]' '[A-Z]'` diff --git a/debian/patches/22disable-xscreensaver.dpatch b/debian/patches/22disable-xscreensaver.dpatch new file mode 100644 index 0000000..094180b --- /dev/null +++ b/debian/patches/22disable-xscreensaver.dpatch @@ -0,0 +1,72 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## 22disable-xscreensaver.dpatch by +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: This patch avoids xscreensaver from blanking onto your favorite movie ; it was made by me, based on code posted in mplayer-dev-eng by Adam Tlałka + +@DPATCH@ +diff -urNad mplayer-1.0~rc2~/libvo/x11_common.c mplayer-1.0~rc2/libvo/x11_common.c +--- mplayer-1.0~rc2~/libvo/x11_common.c 2007-10-07 21:49:28.000000000 +0200 ++++ mplayer-1.0~rc2/libvo/x11_common.c 2007-10-18 19:56:06.000000000 +0200 +@@ -161,6 +161,9 @@ + } + } + ++static int pointer_is_hidden = 0; ++ ++ + void vo_hidecursor(Display * disp, Window win) + { + Cursor no_ptr; +@@ -180,6 +183,7 @@ + bm_no = XCreateBitmapFromData(disp, win, bm_no_data, 8, 8); + no_ptr = XCreatePixmapCursor(disp, bm_no, bm_no, &black, &black, 0, 0); + XDefineCursor(disp, win, no_ptr); ++ pointer_is_hidden = 1; + XFreeCursor(disp, no_ptr); + if (bm_no != None) + XFreePixmap(disp, bm_no); +@@ -191,6 +195,7 @@ + if (WinID == 0) + return; + XDefineCursor(disp, win, 0); ++ pointer_is_hidden = 0; + } + + static int x11_errorhandler(Display * display, XErrorEvent * event) +@@ -1010,6 +1015,7 @@ + + static unsigned int mouse_timer; + static int mouse_waiting_hide; ++static int mouse_ignore_motion = 0; + + int vo_x11_check_events(Display * mydisplay) + { +@@ -1097,7 +1103,9 @@ + sprintf(cmd_str,"set_mouse_pos %i %i",Event.xmotion.x, Event.xmotion.y); + mp_input_queue_cmd(mp_input_parse_cmd(cmd_str)); + } +- ++ if (mouse_ignore_motion) ++ mouse_ignore_motion = 0; ++ else + if (vo_mouse_autohide) + { + vo_showcursor(mydisplay, vo_window); +@@ -1678,6 +1686,16 @@ + XSync(mDisplay, False); + XSetErrorHandler(old_handler); + } ++ ++ static unsigned int last_warp_time = 0; ++ static int fake_move_distance = 16; ++ if (mDisplay && vo_window && pointer_is_hidden && (time - last_warp_time ) > 10000) { ++ last_warp_time = time; ++ mouse_ignore_motion = 1; ++ XWarpPointer(mDisplay, vo_window, None, 0, 0, 0, 0, fake_move_distance, 0); ++ fake_move_distance = -fake_move_distance; ++ mp_msg(MSGT_VO, MSGL_DBG2, "Warping cursor to disable gnome-screensaver.\n"); ++ } + } + + static void xscreensaver_disable(Display * dpy) diff --git a/debian/patches/24mplayer.desktop.dpatch b/debian/patches/24mplayer.desktop.dpatch new file mode 100644 index 0000000..7ad325c --- /dev/null +++ b/debian/patches/24mplayer.desktop.dpatch @@ -0,0 +1,14 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## dpatch by +## +## DP: can't open a URI with encoded chars (like a space), bug 449298 + +@DPATCH@ +diff -urNad mplayer-1.0~rc2~/etc/mplayer.desktop mplayer-1.0~rc2/etc/mplayer.desktop +--- mplayer-1.0~rc2~/etc/mplayer.desktop 2007-11-14 14:59:15.000000000 +0100 ++++ mplayer-1.0~rc2/etc/mplayer.desktop 2007-10-07 21:49:33.000000000 +0200 +@@ -12,3 +12,3 @@ + TryExec=gmplayer +-Exec=gmplayer %U ++Exec=gmplayer %F + Terminal=false diff --git a/debian/patches/25kFreeBDS.dpatch b/debian/patches/25kFreeBDS.dpatch new file mode 100644 index 0000000..c5ee4ab --- /dev/null +++ b/debian/patches/25kFreeBDS.dpatch @@ -0,0 +1,29 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## 25kFreeBDS.dpatch by Petr Salinger +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: to build on GNU/kFreeBSD + +@DPATCH@ +diff -urNad mplayer-1.0~rc2~/configure mplayer-1.0~rc2/configure +--- mplayer-1.0~rc2~/configure 2007-10-07 19:49:33.000000000 +0000 ++++ mplayer-1.0~rc2/configure 2007-11-04 12:57:48.000000000 +0000 +@@ -6728,6 +6728,7 @@ + "dev/ic/bt8xx.h" ; do + cat > $TMPC < ++#include + #include <$file> + int main(void) { + ioctl(0, TVTUNER_GETFREQ, 0); +diff -urNad mplayer-1.0~rc2~/stream/tvi_bsdbt848.c mplayer-1.0~rc2/stream/tvi_bsdbt848.c +--- mplayer-1.0~rc2~/stream/tvi_bsdbt848.c 2007-10-07 19:49:26.000000000 +0000 ++++ mplayer-1.0~rc2/stream/tvi_bsdbt848.c 2007-11-04 12:57:48.000000000 +0000 +@@ -30,6 +30,7 @@ + #include + #include + #include ++#include + #include + #include + #include diff --git a/debian/patches/25mplayer-desktop.dpatch b/debian/patches/25mplayer-desktop.dpatch new file mode 100644 index 0000000..cae24fa --- /dev/null +++ b/debian/patches/25mplayer-desktop.dpatch @@ -0,0 +1,18 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## dpatch by +## +## DP: renamed mplayer.xpm to mplayer in desktop file, thanks to giggz (Closes: #472833). + +@DPATCH@ +diff -urNad mplayer-1.0~rc2.orig/etc/mplayer.desktop mplayer-1.0~rc2/etc/mplayer.desktop +--- mplayer-1.0~rc2.orig/etc/mplayer.desktop ++++ mplayer-1.0~rc2/etc/mplayer.desktop +@@ -8,7 +8,7 @@ + Comment[es]=Reproductor multimedia + Comment[fr]=Lecteur multimédia + Comment[it]=Lettore multimediale +-Icon=mplayer.xpm ++Icon=mplayer + TryExec=gmplayer + Exec=gmplayer %U + Terminal=false diff --git a/debian/patches/30vorbis-block-alloc.dpatch b/debian/patches/30vorbis-block-alloc.dpatch new file mode 100644 index 0000000..6b2a659 --- /dev/null +++ b/debian/patches/30vorbis-block-alloc.dpatch @@ -0,0 +1,89 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## 30vorbis-block-alloc.dpatch by dann frazier +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: fix: _vorbis_block_alloc() implicitly converted to pointer + +@DPATCH@ +diff -urNad mplayer-1.0~rc2~/tremor/block.c mplayer-1.0~rc2/tremor/block.c +--- mplayer-1.0~rc2~/tremor/block.c 2007-10-07 21:49:27.000000000 +0200 ++++ mplayer-1.0~rc2/tremor/block.c 2007-10-19 20:59:26.000000000 +0200 +@@ -25,6 +25,7 @@ + #include "window.h" + #include "registry.h" + #include "misc.h" ++#include "block.h" + + static int ilog(unsigned int v){ + int ret=0; +diff -urNad mplayer-1.0~rc2~/tremor/block.h mplayer-1.0~rc2/tremor/block.h +--- mplayer-1.0~rc2~/tremor/block.h 1970-01-01 01:00:00.000000000 +0100 ++++ mplayer-1.0~rc2/tremor/block.h 2007-10-19 20:57:44.000000000 +0200 +@@ -0,0 +1,23 @@ ++/******************************************************************** ++ * * ++ * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * ++ * * ++ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * ++ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * ++ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * ++ * * ++ * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * ++ * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * ++ * * ++ ******************************************************************** ++ ++ function: basic shared block operations ++ ++ ********************************************************************/ ++ ++#ifndef _V_BLOCK_H_ ++#define _V_BLOCK_H_ ++ ++void *_vorbis_block_alloc(vorbis_block *vb,long bytes); ++ ++#endif +diff -urNad mplayer-1.0~rc2~/tremor/floor0.c mplayer-1.0~rc2/tremor/floor0.c +--- mplayer-1.0~rc2~/tremor/floor0.c 2007-10-07 21:49:27.000000000 +0200 ++++ mplayer-1.0~rc2/tremor/floor0.c 2007-10-19 20:57:44.000000000 +0200 +@@ -25,6 +25,7 @@ + #include "codebook.h" + #include "misc.h" + #include "os.h" ++#include "block.h" + + #define LSP_FRACBITS 14 + +diff -urNad mplayer-1.0~rc2~/tremor/floor1.c mplayer-1.0~rc2/tremor/floor1.c +--- mplayer-1.0~rc2~/tremor/floor1.c 2007-10-07 21:49:27.000000000 +0200 ++++ mplayer-1.0~rc2/tremor/floor1.c 2007-10-19 20:57:44.000000000 +0200 +@@ -24,6 +24,7 @@ + #include "registry.h" + #include "codebook.h" + #include "misc.h" ++#include "block.h" + + #define floor1_rangedB 140 /* floor 1 fixed at -140dB to 0dB range */ + +diff -urNad mplayer-1.0~rc2~/tremor/res012.c mplayer-1.0~rc2/tremor/res012.c +--- mplayer-1.0~rc2~/tremor/res012.c 2007-10-07 21:49:27.000000000 +0200 ++++ mplayer-1.0~rc2/tremor/res012.c 2007-10-19 20:57:44.000000000 +0200 +@@ -25,6 +25,7 @@ + #include "codebook.h" + #include "misc.h" + #include "os.h" ++#include "block.h" + + typedef struct { + vorbis_info_residue0 *info; +diff -urNad mplayer-1.0~rc2~/tremor/synthesis.c mplayer-1.0~rc2/tremor/synthesis.c +--- mplayer-1.0~rc2~/tremor/synthesis.c 2007-10-07 21:49:27.000000000 +0200 ++++ mplayer-1.0~rc2/tremor/synthesis.c 2007-10-19 20:57:44.000000000 +0200 +@@ -23,6 +23,7 @@ + #include "registry.h" + #include "misc.h" + #include "os.h" ++#include "block.h" + + int vorbis_synthesis(vorbis_block *vb,ogg_packet *op){ + vorbis_dsp_state *vd=vb->vd; diff --git a/debian/patches/40rtsp_demux.dpatch b/debian/patches/40rtsp_demux.dpatch new file mode 100644 index 0000000..920d9ce --- /dev/null +++ b/debian/patches/40rtsp_demux.dpatch @@ -0,0 +1,19 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## 30vorbis-block-alloc.dpatch by Reimar Döffinger +## +## DP: skip short packets, fixes +## DP: http://bugzilla.mplayerhq.hu/show_bug.cgi?id=930 +## DP: http://bugs.debian.org/410424 + +@DPATCH@ +diff -urNad mplayer-1.0~rc2~/libmpdemux/demux_real.c mplayer-1.0~rc2/libmpdemux/demux_real.c +--- mplayer-1.0~rc2~/libmpdemux/demux_real.c (revision 24859) ++++ mplayer-1.0~rc2/libmpdemux/demux_real.c (working copy) +@@ -685,6 +686,7 @@ + free(sub_packet_lengths); + return 1; + } ++ if (len < 256) { stream_skip(demuxer->stream, len); continue; } + if ((priv->intl_id[stream_id] == mmioFOURCC('I', 'n', 't', '4')) || + (priv->intl_id[stream_id] == mmioFOURCC('g', 'e', 'n', 'r')) || + (priv->intl_id[stream_id] == mmioFOURCC('s', 'i', 'p', 'r'))) { diff --git a/debian/patches/51xsai.dpatch b/debian/patches/51xsai.dpatch new file mode 100644 index 0000000..97d7025 --- /dev/null +++ b/debian/patches/51xsai.dpatch @@ -0,0 +1,101 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## dpatch by Reimar Dffinger and mennucc1@debian.org +## +## DP: 2xsai filter generates side-by-side double-height images , bug 450999 + +@DPATCH@ +diff -urNad mplayer-1.0~rc2~/libmpcodecs/vf_2xsai.c mplayer-1.0~rc2/libmpcodecs/vf_2xsai.c +--- mplayer-1.0~rc2~/libmpcodecs/vf_2xsai.c 2007/11/12 20:40:13 25031 ++++ mplayer-1.0~rc2/libmpcodecs/vf_2xsai.c 2007/11/12 20:44:06 25032 +@@ -88,7 +88,7 @@ + uint32_t width, uint32_t height, int sbpp) { + + unsigned int x, y; +- unsigned long color[16]; ++ uint32_t color[16]; + + /* Point to the first 3 lines. */ + src_line[0] = src; +@@ -109,13 +109,13 @@ + color[12] = *sbp; color[13] = color[12]; color[14] = *(sbp + 1); color[15] = *(sbp + 2); + } + else { +- unsigned long *lbp; +- lbp = (unsigned long*)src_line[0]; ++ uint32_t *lbp; ++ lbp = (uint32_t*)src_line[0]; + color[0] = *lbp; color[1] = color[0]; color[2] = color[0]; color[3] = color[0]; + color[4] = color[0]; color[5] = color[0]; color[6] = *(lbp + 1); color[7] = *(lbp + 2); +- lbp = (unsigned long*)src_line[2]; ++ lbp = (uint32_t*)src_line[2]; + color[8] = *lbp; color[9] = color[8]; color[10] = *(lbp + 1); color[11] = *(lbp + 2); +- lbp = (unsigned long*)src_line[3]; ++ lbp = (uint32_t*)src_line[3]; + color[12] = *lbp; color[13] = color[12]; color[14] = *(lbp + 1); color[15] = *(lbp + 2); + } + +@@ -127,7 +127,7 @@ + /* Todo: x = width - 2, x = width - 1 */ + + for (x = 0; x < width; x++) { +- unsigned long product1a, product1b, product2a, product2b; ++ uint32_t product1a, product1b, product2a, product2b; + + //--------------------------------------- B0 B1 B2 B3 0 1 2 3 + // 4 5* 6 S2 -> 4 5* 6 7 +@@ -191,14 +191,14 @@ + product1a = color[5]; + + if (PixelsPerMask == 2) { +- *((unsigned long *) (&dst_line[0][x * 4])) = product1a | (product1b << 16); +- *((unsigned long *) (&dst_line[1][x * 4])) = product2a | (product2b << 16); ++ *((uint32_t *) (&dst_line[0][x * 4])) = product1a | (product1b << 16); ++ *((uint32_t *) (&dst_line[1][x * 4])) = product2a | (product2b << 16); + } + else { +- *((unsigned long *) (&dst_line[0][x * 8])) = product1a; +- *((unsigned long *) (&dst_line[0][x * 8 + 4])) = product1b; +- *((unsigned long *) (&dst_line[1][x * 8])) = product2a; +- *((unsigned long *) (&dst_line[1][x * 8 + 4])) = product2b; ++ *((uint32_t *) (&dst_line[0][x * 8])) = product1a; ++ *((uint32_t *) (&dst_line[0][x * 8 + 4])) = product1b; ++ *((uint32_t *) (&dst_line[1][x * 8])) = product2a; ++ *((uint32_t *) (&dst_line[1][x * 8 + 4])) = product2b; + } + + /* Move color matrix forward */ +@@ -215,10 +215,10 @@ + color[15] = *(((unsigned short*)src_line[3]) + x); + } + else { +- color[3] = *(((unsigned long*)src_line[0]) + x); +- color[7] = *(((unsigned long*)src_line[1]) + x); +- color[11] = *(((unsigned long*)src_line[2]) + x); +- color[15] = *(((unsigned long*)src_line[3]) + x); ++ color[3] = *(((uint32_t*)src_line[0]) + x); ++ color[7] = *(((uint32_t*)src_line[1]) + x); ++ color[11] = *(((uint32_t*)src_line[2]) + x); ++ color[15] = *(((uint32_t*)src_line[3]) + x); + } + x -= 3; + } +@@ -248,14 +248,14 @@ + color[12] = *sbp; color[13] = color[12]; color[14] = *(sbp + 1); color[15] = *(sbp + 2); + } + else { +- unsigned long *lbp; +- lbp = (unsigned long*)src_line[0]; ++ uint32_t *lbp; ++ lbp = (uint32_t*)src_line[0]; + color[0] = *lbp; color[1] = color[0]; color[2] = *(lbp + 1); color[3] = *(lbp + 2); +- lbp = (unsigned long*)src_line[1]; ++ lbp = (uint32_t*)src_line[1]; + color[4] = *lbp; color[5] = color[4]; color[6] = *(lbp + 1); color[7] = *(lbp + 2); +- lbp = (unsigned long*)src_line[2]; ++ lbp = (uint32_t*)src_line[2]; + color[8] = *lbp; color[9] = color[9]; color[10] = *(lbp + 1); color[11] = *(lbp + 2); +- lbp = (unsigned long*)src_line[3]; ++ lbp = (uint32_t*)src_line[3]; + color[12] = *lbp; color[13] = color[12]; color[14] = *(lbp + 1); color[15] = *(lbp + 2); + } + diff --git a/debian/patches/CVE-2008-0073--rtsp_fix.diff b/debian/patches/CVE-2008-0073--rtsp_fix.diff new file mode 100644 index 0000000..05aa78b --- /dev/null +++ b/debian/patches/CVE-2008-0073--rtsp_fix.diff @@ -0,0 +1,14 @@ +#!/bin/sh /usr/share/dpatch/dpatch-run +@DPATCH@ +--- trunk/stream/realrtsp/sdpplin.c (revision 26295) ++++ trunk/stream/realrtsp/sdpplin.c (working copy) +@@ -330,7 +330,8 @@ + + if(filter(data,"a=StreamCount:integer;",&buf)) { + desc->stream_count=(unsigned int)atoi(buf); +- desc->stream=malloc(sizeof(sdpplin_stream_t*)*desc->stream_count); ++ desc->stream=calloc(desc->stream_count, sizeof(sdpplin_stream_t*)); ++ if (!desc->stream) desc->stream_count = 0; + handled=1; + data=nl(data); + } diff --git a/debian/patches/CVE-2008-0629--stream_cddb.c.diff b/debian/patches/CVE-2008-0629--stream_cddb.c.diff new file mode 100644 index 0000000..d2f60f1 --- /dev/null +++ b/debian/patches/CVE-2008-0629--stream_cddb.c.diff @@ -0,0 +1,34 @@ +#!/bin/sh /usr/share/dpatch/dpatch-run +@DPATCH@ +--- trunk/stream/stream_cddb.c 2008/01/20 16:13:51 25820 ++++ trunk/stream/stream_cddb.c 2008/01/20 20:58:02 25824 +@@ -58,6 +58,7 @@ + #include "version.h" + #include "stream.h" + #include "network.h" ++#include "libavutil/common.h" + + #define DEFAULT_FREEDB_SERVER "freedb.freedb.org" + #define DEFAULT_CACHE_DIR "/.cddb/" +@@ -503,8 +504,9 @@ + } else { + len = ptr2-ptr+1; + } ++ len = FFMIN(sizeof(album_title) - 1, len); + strncpy(album_title, ptr, len); +- album_title[len-2]='\0'; ++ album_title[len]='\0'; + } + mp_msg(MSGT_DEMUX, MSGL_STATUS, MSGTR_MPDEMUX_CDDB_ParseOKFoundAlbumTitle, album_title); + return 0; +@@ -540,8 +542,9 @@ + } else { + len = ptr2-ptr+1; + } ++ len = FFMIN(sizeof(album_title) - 1, len); + strncpy(album_title, ptr, len); +- album_title[len-2]='\0'; ++ album_title[len]='\0'; + } + mp_msg(MSGT_DEMUX, MSGL_STATUS, MSGTR_MPDEMUX_CDDB_ParseOKFoundAlbumTitle, album_title); + return cddb_request_titles(cddb_data); diff --git a/debian/patches/CVE-2008-0630.diff b/debian/patches/CVE-2008-0630.diff new file mode 100644 index 0000000..17ba91e --- /dev/null +++ b/debian/patches/CVE-2008-0630.diff @@ -0,0 +1,12 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +@DPATCH@ +--- tmp/stream/url.c 2008-02-08 22:17:35.000000000 +0100 ++++ tmp/stream/url.c 2008-02-08 22:18:58.000000000 +0100 +@@ -328,6 +328,7 @@ + } + } + ++ tmp = NULL; + while(i < len) { + // look for the next char that must be kept + for (j=i;jsize=chunk_size=stream_read_dword(s); /* include itself */ + stream_read(s,chunk_id,4); ++ if (chunk_size < 8) return NULL; ++ chunk_size -= 8; + if(*((uint32_t *)&chunk_id[0])==mmioFOURCC('C','O','M','M')) + { +- char buf[chunk_size-8]; ++ char buf[BUFSIZ]; + unsigned i,subchunk_size; +- if(stream_read(s,buf,chunk_size-8)!=chunk_size-8) return NULL; ++ if (chunk_size > sizeof(buf) || chunk_size < 20) return NULL; ++ if(stream_read(s,buf,chunk_size)!=chunk_size) return NULL; + i=0; + subchunk_size=be2me_32(*((uint32_t *)&buf[0])); + hi->channelMode=be2me_32(*((uint32_t *)&buf[4])); +@@ -83,13 +86,15 @@ + sh_audio->samplesize = 4; + w->wBitsPerSample = 8*sh_audio->samplesize; + w->cbSize = 0; ++ if (subchunk_size > chunk_size - 4) continue; + i+=subchunk_size+4; +- while(i sizeof(sdata) - 1 || slen > chunk_size - i) break; + if(sid==mmioFOURCC('D','S','I','Z')) + { + hi->Dsiz=be2me_32(*((uint32_t *)&buf[i])); +@@ -141,7 +146,7 @@ + if(*((uint32_t *)&chunk_id[0])==mmioFOURCC('D','A','T','A')) + { + demuxer->movi_start=stream_tell(s); +- demuxer->movi_end=demuxer->movi_start+chunk_size-8; ++ demuxer->movi_end=demuxer->movi_start+chunk_size; + mp_msg(MSGT_DEMUX, MSGL_V, "Found data at %"PRIX64" size %"PRIu64"\n",demuxer->movi_start,demuxer->movi_end); + /* Done! play it */ + break; +@@ -149,7 +154,7 @@ + else + { + mp_msg(MSGT_DEMUX, MSGL_V, "Unhandled chunk '%c%c%c%c' %u bytes\n",((char *)&chunk_id)[0],((char *)&chunk_id)[1],((char *)&chunk_id)[2],((char *)&chunk_id)[3],chunk_size); +- stream_skip(s,chunk_size-8); /*unknown chunk type */ ++ stream_skip(s,chunk_size); /*unknown chunk type */ + } + } + diff --git a/debian/patches/demux.patch b/debian/patches/demux.patch new file mode 100644 index 0000000..77379b4 --- /dev/null +++ b/debian/patches/demux.patch @@ -0,0 +1,53 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## by Ondrej Certik +## +## DP: demux for newer ffmpeg 0.svn20080206 + +@DPATCH@ +Index: mplayer-1.0~rc2/libmpdemux/demux_lavf.c +=================================================================== +--- mplayer-1.0~rc2.orig/libmpdemux/demux_lavf.c 2008-07-05 12:41:23.000000000 +0200 ++++ mplayer-1.0~rc2/libmpdemux/demux_lavf.c 2008-07-05 12:41:36.000000000 +0200 +@@ -61,7 +61,7 @@ + typedef struct lavf_priv_t{ + AVInputFormat *avif; + AVFormatContext *avfc; +- ByteIOContext pb; ++ ByteIOContext *pb; + int audio_streams; + int video_streams; + int sub_streams; +@@ -288,9 +288,9 @@ + + url_fopen(&priv->pb, mp_filename, URL_RDONLY); + +- ((URLContext*)(priv->pb.opaque))->priv_data= demuxer->stream; ++ ((URLContext*)(priv->pb->opaque))->priv_data= demuxer->stream; + +- if(av_open_input_stream(&avfc, &priv->pb, mp_filename, priv->avif, &ap)<0){ ++ if(av_open_input_stream(&avfc, priv->pb, mp_filename, priv->avif, &ap)<0){ + mp_msg(MSGT_HEADER,MSGL_ERR,"LAVF_header: av_open_input_stream() failed\n"); + return NULL; + } +Index: mplayer-1.0~rc2/libmpdemux/muxer_lavf.c +=================================================================== +--- mplayer-1.0~rc2.orig/libmpdemux/muxer_lavf.c 2008-07-05 12:41:31.000000000 +0200 ++++ mplayer-1.0~rc2/libmpdemux/muxer_lavf.c 2008-07-05 12:41:36.000000000 +0200 +@@ -40,7 +40,7 @@ + typedef struct { + //AVInputFormat *avif; + AVFormatContext *oc; +- ByteIOContext pb; ++ ByteIOContext *pb; + int audio_streams; + int video_streams; + int64_t last_pts; +@@ -317,7 +317,7 @@ + av_freep(&(priv->oc->streams[i])); + } + +- url_fclose(&(priv->oc->pb)); ++ url_fclose(priv->oc->pb); + + av_free(priv->oc); + } diff --git a/debian/patches/demux_audio_fix_20080129.diff b/debian/patches/demux_audio_fix_20080129.diff new file mode 100644 index 0000000..8946bbc --- /dev/null +++ b/debian/patches/demux_audio_fix_20080129.diff @@ -0,0 +1,13 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +@DPATCH@ +--- trunk/libmpdemux/demux_audio.c (revision 24724) ++++ trunk/libmpdemux/demux_audio.c (working copy) +@@ -229,6 +229,8 @@ + ptr += 4; + + comment = ptr; ++ if (&comment[length] < comments || &comment[length] >= &comments[blk_len]) ++ return; + c = comment[length]; + comment[length] = 0; + diff --git a/debian/patches/demux_mov_fix_20080129.diff b/debian/patches/demux_mov_fix_20080129.diff new file mode 100644 index 0000000..224ae45 --- /dev/null +++ b/debian/patches/demux_mov_fix_20080129.diff @@ -0,0 +1,56 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +@DPATCH@ +--- trunk/libmpdemux/demux_mov.c (revision 24724) ++++ trunk/libmpdemux/demux_mov.c (working copy) +@@ -51,6 +51,8 @@ + #include + #endif + ++#include "libavutil/common.h" ++ + #define BE_16(x) (((unsigned char *)(x))[0] << 8 | \ + ((unsigned char *)(x))[1]) + #define BE_32(x) (((unsigned char *)(x))[0] << 24 | \ +@@ -171,11 +173,12 @@ + i=trak->chunkmap_size; + while(i>0){ + --i; +- for(j=trak->chunkmap[i].first;jchunkmap[i].first, 0); ++ for(;jchunks[j].desc=trak->chunkmap[i].sdid; + trak->chunks[j].size=trak->chunkmap[i].spc; + } +- last=trak->chunkmap[i].first; ++ last=FFMIN(trak->chunkmap[i].first, trak->chunks_size); + } + + #if 0 +@@ -235,6 +236,8 @@ + s=0; + for(j=0;jdurmap_size;j++){ + for(i=0;idurmap[j].num;i++){ ++ if (s >= trak->samples_size) ++ break; + trak->samples[s].pts=pts; + ++s; + pts+=trak->durmap[j].dur; +@@ -246,6 +249,8 @@ + for(j=0;jchunks_size;j++){ + off_t pos=trak->chunks[j].pos; + for(i=0;ichunks[j].size;i++){ ++ if (s >= trak->samples_size) ++ break; + trak->samples[s].pos=pos; + mp_msg(MSGT_DEMUX, MSGL_DBG3, "Sample %5d: pts=%8d off=0x%08X size=%d\n",s, + trak->samples[s].pts, +@@ -1568,8 +1573,7 @@ + if( udta_len>udta_size) + udta_len=udta_size; + { +- char dump[udta_len-4]; +- stream_read(demuxer->stream, (char *)&dump, udta_len-4-4); ++ stream_skip(demuxer->stream, udta_len-4-4); + udta_size -= udta_len; + } + } diff --git a/debian/patches/mplayer-debug-printf.dpatch b/debian/patches/mplayer-debug-printf.dpatch new file mode 100755 index 0000000..16d2b03 --- /dev/null +++ b/debian/patches/mplayer-debug-printf.dpatch @@ -0,0 +1,19 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## mplayer-debug-printf.dpatch by +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: on crash, warn that mplayer is compiled with --enable-debug, with symbols in mplayer-dbg + +@DPATCH@ +--- m/mplayer.c 2007-10-07 21:49:33.000000000 +0200 ++++ m/mplayer.c.new 2008-05-03 10:53:38.000000000 +0200 +@@ -764,6 +764,9 @@ + mp_msg(MSGT_CPLAYER,MSGL_FATAL,MSGTR_Exit_SIGSEGV_SIGFPE); + default: + mp_msg(MSGT_CPLAYER,MSGL_FATAL,MSGTR_Exit_SIGCRASH); ++ printf(" [ This binary of MPlayer in Debian is currently compiled with\n" ++ " '--enable-debug'; the debugging symbols are in the package\n" ++ " 'mplayer-dbg'.]\n"); + #ifdef CRASH_DEBUG + if (crash_debug) { + int gdb_pid; diff --git a/debian/patches/oCERT-2008-013--realfix.diff b/debian/patches/oCERT-2008-013--realfix.diff new file mode 100644 index 0000000..85e63b1 --- /dev/null +++ b/debian/patches/oCERT-2008-013--realfix.diff @@ -0,0 +1,28 @@ +#!/bin/sh /usr/share/dpatch/dpatch-run +@DPATCH@ +--- mplayer-1.0~rc2~/libmpdemux/demux_real.c (revision 27605) ++++ mplayer-1.0~rc2/libmpdemux/demux_real.c (working copy) +@@ -959,6 +959,7 @@ + // last fragment! + if(dp_hdr->len!=vpkg_length-vpkg_offset) + mp_msg(MSGT_DEMUX,MSGL_V,"warning! assembled.len=%d frag.len=%d total.len=%d \n",dp->len,vpkg_offset,vpkg_length-vpkg_offset); ++ if (vpkg_offset > dp->len - sizeof(dp_hdr_t) - dp_hdr->len) vpkg_offset = dp->len - sizeof(dp_hdr_t) - dp_hdr->len; + stream_read(demuxer->stream, dp_data+dp_hdr->len, vpkg_offset); + if((dp_data[dp_hdr->len]&0x20) && (sh_video->format==0x30335652)) --dp_hdr->chunks; else + dp_hdr->len+=vpkg_offset; +@@ -982,6 +982,7 @@ + // non-last fragment: + if(dp_hdr->len!=vpkg_offset) + mp_msg(MSGT_DEMUX,MSGL_V,"warning! assembled.len=%d offset=%d frag.len=%d total.len=%d \n",dp->len,vpkg_offset,len,vpkg_length); ++ if (len > dp->len - sizeof(dp_hdr_t) - dp_hdr->len) len = dp->len - sizeof(dp_hdr_t) - dp_hdr->len; + stream_read(demuxer->stream, dp_data+dp_hdr->len, len); + if((dp_data[dp_hdr->len]&0x20) && (sh_video->format==0x30335652)) --dp_hdr->chunks; else + dp_hdr->len+=len; +@@ -1004,6 +1004,7 @@ + extra[0]=1; extra[1]=0; // offset of the first chunk + if(0x00==(vpkg_header&0xc0)){ + // first fragment: ++ if (len > dp->len - sizeof(dp_hdr_t)) len = dp->len - sizeof(dp_hdr_t); + dp_hdr->len=len; + stream_read(demuxer->stream, dp_data, len); + ds->asf_packet=dp; diff --git a/debian/patches/shared_linking_to_ffmpeg.dpatch b/debian/patches/shared_linking_to_ffmpeg.dpatch new file mode 100755 index 0000000..7d97c11 --- /dev/null +++ b/debian/patches/shared_linking_to_ffmpeg.dpatch @@ -0,0 +1,26 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## shared_linking_to_ffmpeg.dpatch by +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: can link with ffmpeg-free + +@DPATCH@ +--- m/Makefile.orig 2009-03-02 21:58:01.000000000 +0000 ++++ m/Makefile 2009-03-02 21:58:35.000000000 +0000 +@@ -701,11 +701,11 @@ + SRCS_MENCODER += $(SRCS_MENCODER-yes) + SRCS_MPLAYER += $(SRCS_MPLAYER-yes) + +-COMMON_LIBS-$(LIBAVFORMAT_A) += libavformat/libavformat.a +-COMMON_LIBS-$(LIBAVCODEC_A) += libavcodec/libavcodec.a +-COMMON_LIBS-$(LIBAVUTIL_A) += libavutil/libavutil.a +-COMMON_LIBS-$(LIBPOSTPROC_A) += libpostproc/libpostproc.a +-COMMON_LIBS-$(LIBSWSCALE_A) += libswscale/libswscale.a ++COMMON_LIBS-$(LIBAVFORMAT_A) += /usr/lib/libavformat.so ++COMMON_LIBS-$(LIBAVCODEC_A) += /usr/lib/libavcodec.so ++COMMON_LIBS-$(LIBAVUTIL_A) += /usr/lib/libavutil.so ++COMMON_LIBS-$(LIBPOSTPROC_A) += /usr/lib/libpostproc.so ++COMMON_LIBS-$(LIBSWSCALE_A) += /usr/lib/libswscale.so + COMMON_LIBS += $(COMMON_LIBS-yes) + + OBJS_COMMON += $(addsuffix .o, $(basename $(SRCS_COMMON))) diff --git a/debian/patches/theora_length_fix_svn27354.diff b/debian/patches/theora_length_fix_svn27354.diff new file mode 100644 index 0000000..d95b5ac --- /dev/null +++ b/debian/patches/theora_length_fix_svn27354.diff @@ -0,0 +1,145 @@ +#!/bin/sh /usr/share/dpatch/dpatch-run +## dpatch by Reimar Döffinger (Closes: #464207). +## +## DP: Get rid of horrible code that relies on codec-set context variable, +## DP: it is useless anyway since all the necessary information is available anyway. +## DP: This also makes MPlayer display the correct length for Theora-in-Ogg-Videos. + +@DPATCH@ +--- trunk/libmpdemux/demux_ogg.c 2008/02/29 17:25:39 26116 ++++ trunk/libmpdemux/demux_ogg.c 2008/07/26 22:27:50 27354 +@@ -99,6 +99,7 @@ + float samplerate; /// granulpos 2 time + int64_t lastpos; + int32_t lastsize; ++ int keyframe_frequency_force; + + // Logical stream state + ogg_stream_state stream; +@@ -236,7 +237,7 @@ + + } + +-static unsigned char* demux_ogg_read_packet(ogg_stream_t* os,ogg_packet* pack,void *context,float* pts,int* flags, int samplesize) { ++static unsigned char* demux_ogg_read_packet(ogg_stream_t* os,ogg_packet* pack,float* pts,int* flags, int samplesize) { + unsigned char* data = pack->packet; + + *pts = 0; +@@ -273,10 +274,9 @@ + /* header packets begin on 1-bit: thus check (*data&0x80). We don't + have theora_state st, until all header packets were passed to the + decoder. */ +- if (context != NULL && !(*data&0x80)) ++ if (!(*data&0x80)) + { +- theora_info *thi = ((theora_struct_t*)context)->st.i; +- int keyframe_granule_shift=_ilog(thi->keyframe_frequency_force-1); ++ int keyframe_granule_shift=_ilog(os->keyframe_frequency_force-1); + int64_t iframemask = (1 << keyframe_granule_shift) - 1; + + if (pack->granulepos >= 0) +@@ -427,7 +427,6 @@ + unsigned char* data; + float pts = 0; + int flags = 0; +- void *context = NULL; + int samplesize = 1; + + // If packet is an comment header then we try to get comments at first +@@ -468,12 +467,9 @@ + // For vorbis packet the packet is the data, for other codec we must jump + // the header + if(ds == d->audio && ((sh_audio_t*)ds->sh)->format == FOURCC_VORBIS) { +- context = ((sh_audio_t *)ds->sh)->context; + samplesize = ((sh_audio_t *)ds->sh)->samplesize; + } +- if (ds == d->video && ((sh_audio_t*)ds->sh)->format == FOURCC_THEORA) +- context = ((sh_video_t *)ds->sh)->context; +- data = demux_ogg_read_packet(os,pack,context,&pts,&flags,samplesize); ++ data = demux_ogg_read_packet(os,pack,&pts,&flags,samplesize); + if (!data) + return 0; + +@@ -504,7 +500,6 @@ + ogg_stream_t* os; + ogg_packet op; + int np,sid,p,samplesize=1; +- void *context = NULL; + off_t pos, last_pos; + pos = last_pos = demuxer->movi_start; + +@@ -520,15 +515,10 @@ + // Get the serial number of the stream we use + if(demuxer->video->id >= 0) { + sid = demuxer->video->id; +- /* demux_ogg_read_packet needs decoder context for Theora streams */ +- if (((sh_video_t*)demuxer->video->sh)->format == FOURCC_THEORA) +- context = ((sh_video_t*)demuxer->video->sh)->context; + } + else if(demuxer->audio->id >= 0) { + sid = demuxer->audio->id; +- /* demux_ogg_read_packet needs decoder context for Vorbis streams */ + if(((sh_audio_t*)demuxer->audio->sh)->format == FOURCC_VORBIS) { +- context = ((sh_audio_t*)demuxer->audio->sh)->context; + samplesize = ((sh_audio_t*)demuxer->audio->sh)->samplesize; + } + } +@@ -566,7 +556,7 @@ + while(ogg_stream_packetout(oss,&op) == 1) { + float pts; + int flags; +- demux_ogg_read_packet(os,&op,context,&pts,&flags,samplesize); ++ demux_ogg_read_packet(os,&op,&pts,&flags,samplesize); + if(op.granulepos >= 0) ogg_d->final_granulepos = op.granulepos; + if(index_mode == 2 && (flags || (os->vorbis && op.granulepos >= 0))) { + if (ogg_d->num_syncpoint > SIZE_MAX / sizeof(ogg_syncpoint_t) - 1) break; +@@ -865,7 +855,6 @@ + { + sh_v = new_sh_video_vid(demuxer,ogg_d->num_sub, n_video); + +- sh_v->context = NULL; + sh_v->bih = calloc(1,sizeof(BITMAPINFOHEADER)); + sh_v->bih->biSize=sizeof(BITMAPINFOHEADER); + sh_v->bih->biCompression= sh_v->format = FOURCC_THEORA; +@@ -881,6 +870,7 @@ + sh_v->bih->biWidth*sh_v->bih->biHeight); + ogg_d->subs[ogg_d->num_sub].samplerate = sh_v->fps; + ogg_d->subs[ogg_d->num_sub].theora = 1; ++ ogg_d->subs[ogg_d->num_sub].keyframe_frequency_force = inf.keyframe_frequency_force; + ogg_d->subs[ogg_d->num_sub].id = n_video; + n_video++; + mp_msg(MSGT_DEMUX,MSGL_INFO, +@@ -1328,7 +1318,6 @@ + int i,sp,first,precision=1,do_seek=1; + vorbis_info* vi = NULL; + int64_t gp = 0, old_gp; +- void *context = NULL; + off_t pos, old_pos; + int np; + int is_gp_valid; +@@ -1339,16 +1328,10 @@ + + if(demuxer->video->id >= 0) { + ds = demuxer->video; +- /* demux_ogg_read_packet needs decoder context for Theora streams */ +- if (((sh_video_t*)demuxer->video->sh)->format == FOURCC_THEORA) +- context = ((sh_video_t*)demuxer->video->sh)->context; + rate = ogg_d->subs[ds->id].samplerate; + } else { + ds = demuxer->audio; + os = &ogg_d->subs[ds->id]; +- /* demux_ogg_read_packet needs decoder context for Vorbis streams */ +- if(((sh_audio_t*)demuxer->audio->sh)->format == FOURCC_VORBIS) +- context = ((sh_audio_t*)demuxer->audio->sh)->context; + vi = &(os->vi); + rate = (float)vi->rate; + samplesize = ((sh_audio_t*)ds->sh)->samplesize; +@@ -1455,7 +1438,7 @@ + } + is_gp_valid = (op.granulepos >= 0); + granulepos_orig=op.granulepos; +- demux_ogg_read_packet(os,&op,context,&pts,&is_keyframe,samplesize); ++ demux_ogg_read_packet(os,&op,&pts,&is_keyframe,samplesize); + if (precision && is_gp_valid) { + precision--; + if (abs(gp - op.granulepos) > rate && (op.granulepos != old_gp)) { diff --git a/debian/patches/to-ffmpeg-free-0.svn20080206.diff b/debian/patches/to-ffmpeg-free-0.svn20080206.diff new file mode 100644 index 0000000..d8ceafa --- /dev/null +++ b/debian/patches/to-ffmpeg-free-0.svn20080206.diff @@ -0,0 +1,35598 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## to-ffmpeg-free-0.svn20080206.diff by +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: update internal ffmpeg code to ffmpeg-free 0.svn20080206 + +@DPATCH@ +diff -u mplayer-1.0~rc2-12/libavcodec/4xm.c ffmpeg-free-0.svn20080206/libavcodec/4xm.c +--- mplayer-1.0~rc2-12/libavcodec/4xm.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/4xm.c 2008-03-20 19:10:57.000000000 +0100 +@@ -131,8 +131,8 @@ + AVFrame current_picture, last_picture; + GetBitContext pre_gb; ///< ac/dc prefix + GetBitContext gb; +- uint8_t *bytestream; +- uint16_t *wordstream; ++ const uint8_t *bytestream; ++ const uint16_t *wordstream; + int mv[256]; + VLC pre_vlc; + int last_dc; +@@ -301,7 +301,7 @@ + const int index= size2index[log2h][log2w]; + const int h= 1<gb, block_type_vlc[1-(f->version>1)][index].table, BLOCK_TYPE_VLC_BITS, 1); +- uint16_t *start= f->last_picture.data[0]; ++ uint16_t *start= (uint16_t*)f->last_picture.data[0]; + uint16_t *end= start + stride*(f->avctx->height-h+1) - (1<=0 && code<=6); +@@ -343,11 +343,7 @@ + } + } + +-static int get32(void *p){ +- return le2me_32(*(uint32_t*)p); +-} +- +-static int decode_p_frame(FourXContext *f, uint8_t *buf, int length){ ++static int decode_p_frame(FourXContext *f, const uint8_t *buf, int length){ + int x, y; + const int width= f->avctx->width; + const int height= f->avctx->height; +@@ -358,9 +354,9 @@ + + if(f->version>1){ + extra=20; +- bitstream_size= get32(buf+8); +- wordstream_size= get32(buf+12); +- bytestream_size= get32(buf+16); ++ bitstream_size= AV_RL32(buf+8); ++ wordstream_size= AV_RL32(buf+12); ++ bytestream_size= AV_RL32(buf+16); + }else{ + extra=0; + bitstream_size = AV_RL16(buf-4); +@@ -379,10 +375,10 @@ + } + + f->bitstream_buffer= av_fast_realloc(f->bitstream_buffer, &f->bitstream_buffer_size, bitstream_size + FF_INPUT_BUFFER_PADDING_SIZE); +- f->dsp.bswap_buf((uint32_t*)f->bitstream_buffer, (uint32_t*)(buf + extra), bitstream_size/4); ++ f->dsp.bswap_buf((uint32_t*)f->bitstream_buffer, (const uint32_t*)(buf + extra), bitstream_size/4); + init_get_bits(&f->gb, f->bitstream_buffer, 8*bitstream_size); + +- f->wordstream= (uint16_t*)(buf + extra + bitstream_size); ++ f->wordstream= (const uint16_t*)(buf + extra + bitstream_size); + f->bytestream= buf + extra + bitstream_size + wordstream_size; + + init_mv(f); +@@ -396,12 +392,12 @@ + } + + if( bitstream_size != (get_bits_count(&f->gb)+31)/32*4 +- || (((char*)f->wordstream - (char*)buf + 2)&~2) != extra + bitstream_size + wordstream_size +- || (((char*)f->bytestream - (char*)buf + 3)&~3) != extra + bitstream_size + wordstream_size + bytestream_size) ++ || (((const char*)f->wordstream - (const char*)buf + 2)&~2) != extra + bitstream_size + wordstream_size ++ || (((const char*)f->bytestream - (const char*)buf + 3)&~3) != extra + bitstream_size + wordstream_size + bytestream_size) + av_log(f->avctx, AV_LOG_ERROR, " %d %td %td bytes left\n", + bitstream_size - (get_bits_count(&f->gb)+31)/32*4, +- -(((char*)f->bytestream - (char*)buf + 3)&~3) + (extra + bitstream_size + wordstream_size + bytestream_size), +- -(((char*)f->wordstream - (char*)buf + 2)&~2) + (extra + bitstream_size + wordstream_size) ++ -(((const char*)f->bytestream - (const char*)buf + 3)&~3) + (extra + bitstream_size + wordstream_size + bytestream_size), ++ -(((const char*)f->wordstream - (const char*)buf + 2)&~2) + (extra + bitstream_size + wordstream_size) + ); + + return 0; +@@ -512,14 +508,14 @@ + return 0; + } + +-static uint8_t *read_huffman_tables(FourXContext *f, uint8_t * const buf){ ++static const uint8_t *read_huffman_tables(FourXContext *f, const uint8_t * const buf){ + int frequency[512]; + uint8_t flag[512]; + int up[512]; + uint8_t len_tab[257]; + int bits_tab[257]; + int start, end; +- uint8_t *ptr= buf; ++ const uint8_t *ptr= buf; + int j; + + memset(frequency, 0, sizeof(frequency)); +@@ -596,7 +592,7 @@ + return red/3*1024 + green/3*32 + blue/3; + } + +-static int decode_i2_frame(FourXContext *f, uint8_t *buf, int length){ ++static int decode_i2_frame(FourXContext *f, const uint8_t *buf, int length){ + int x, y, x2, y2; + const int width= f->avctx->width; + const int height= f->avctx->height; +@@ -632,16 +628,16 @@ + return 0; + } + +-static int decode_i_frame(FourXContext *f, uint8_t *buf, int length){ ++static int decode_i_frame(FourXContext *f, const uint8_t *buf, int length){ + int x, y; + const int width= f->avctx->width; + const int height= f->avctx->height; + uint16_t *dst= (uint16_t*)f->current_picture.data[0]; + const int stride= f->current_picture.linesize[0]>>1; +- const unsigned int bitstream_size= get32(buf); +- const int token_count av_unused = get32(buf + bitstream_size + 8); +- unsigned int prestream_size= 4*get32(buf + bitstream_size + 4); +- uint8_t *prestream= buf + bitstream_size + 12; ++ const unsigned int bitstream_size= AV_RL32(buf); ++ const int token_count av_unused = AV_RL32(buf + bitstream_size + 8); ++ unsigned int prestream_size= 4*AV_RL32(buf + bitstream_size + 4); ++ const uint8_t *prestream= buf + bitstream_size + 12; + + if(prestream_size + bitstream_size + 12 != length + || bitstream_size > (1<<26) +@@ -657,7 +653,7 @@ + prestream_size= length + buf - prestream; + + f->bitstream_buffer= av_fast_realloc(f->bitstream_buffer, &f->bitstream_buffer_size, prestream_size + FF_INPUT_BUFFER_PADDING_SIZE); +- f->dsp.bswap_buf((uint32_t*)f->bitstream_buffer, (uint32_t*)prestream, prestream_size/4); ++ f->dsp.bswap_buf((uint32_t*)f->bitstream_buffer, (const uint32_t*)prestream, prestream_size/4); + init_get_bits(&f->pre_gb, f->bitstream_buffer, 8*prestream_size); + + f->last_dc= 0*128*8*8; +@@ -680,23 +676,23 @@ + + static int decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + FourXContext * const f = avctx->priv_data; + AVFrame *picture = data; + AVFrame *p, temp; + int i, frame_4cc, frame_size; + +- frame_4cc= get32(buf); +- if(buf_size != get32(buf+4)+8 || buf_size < 20){ +- av_log(f->avctx, AV_LOG_ERROR, "size mismatch %d %d\n", buf_size, get32(buf+4)); ++ frame_4cc= AV_RL32(buf); ++ if(buf_size != AV_RL32(buf+4)+8 || buf_size < 20){ ++ av_log(f->avctx, AV_LOG_ERROR, "size mismatch %d %d\n", buf_size, AV_RL32(buf+4)); + } + + if(frame_4cc == ff_get_fourcc("cfrm")){ + int free_index=-1; + const int data_size= buf_size - 20; +- const int id= get32(buf+12); +- const int whole_size= get32(buf+16); ++ const int id= AV_RL32(buf+12); ++ const int whole_size= AV_RL32(buf+16); + CFrameBuffer *cfrm; + + for(i=0; ipriv_data; +- unsigned char *encoded = (unsigned char *)buf; ++ const unsigned char *encoded = buf; + unsigned char *pixptr, *pixptr_end; + unsigned int height = avctx->height; // Real image height + unsigned int dlen, p, row; +- unsigned char *lp, *dp; ++ const unsigned char *lp, *dp; + unsigned char count; + unsigned int px_inc; + unsigned int planes = c->planes; +@@ -97,7 +97,7 @@ + for(row = 0; row < height; row++) { + pixptr = c->pic.data[0] + row * c->pic.linesize[0] + planemap[p]; + pixptr_end = pixptr + c->pic.linesize[0]; +- dlen = be2me_16(*(unsigned short *)(lp+row*2)); ++ dlen = be2me_16(*(const unsigned short *)(lp+row*2)); + /* Decode a row of this plane */ + while(dlen > 0) { + if(dp + 1 >= buf+buf_size) return -1; +diff -u mplayer-1.0~rc2-12/libavcodec/aac_ac3_parser.c ffmpeg-free-0.svn20080206/libavcodec/aac_ac3_parser.c +--- mplayer-1.0~rc2-12/libavcodec/aac_ac3_parser.c 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/aac_ac3_parser.c 2008-03-20 19:10:57.000000000 +0100 +@@ -37,16 +37,18 @@ + + buf_ptr = buf; + while (buf_size > 0) { ++ int size_needed= s->frame_size ? s->frame_size : s->header_size; + len = s->inbuf_ptr - s->inbuf; +- if (s->frame_size == 0) { +- /* no header seen : find one. We need at least s->header_size +- bytes to parse it */ +- len = FFMIN(s->header_size - len, buf_size); + ++ if(leninbuf_ptr, buf_ptr, len); +- buf_ptr += len; ++ buf_ptr += len; + s->inbuf_ptr += len; +- buf_size -= len; ++ buf_size -= len; ++ } ++ ++ if (s->frame_size == 0) { + if ((s->inbuf_ptr - s->inbuf) == s->header_size) { + len = s->sync(s->inbuf, &channels, &sample_rate, &bit_rate, + &samples); +@@ -58,11 +60,13 @@ + s->frame_size = len; + /* update codec info */ + avctx->sample_rate = sample_rate; +- /* set channels,except if the user explicitly requests 1 or 2 channels, XXX/FIXME this is a bit ugly */ +- if(avctx->codec_id == CODEC_ID_AC3){ +- if(avctx->channels!=1 && avctx->channels!=2){ +- avctx->channels = channels; +- } ++ /* allow downmixing to stereo (or mono for AC3) */ ++ if(avctx->request_channels > 0 && ++ avctx->request_channels < channels && ++ (avctx->request_channels <= 2 || ++ (avctx->request_channels == 1 && ++ avctx->codec_id == CODEC_ID_AC3))) { ++ avctx->channels = avctx->request_channels; + } else { + avctx->channels = channels; + } +@@ -71,13 +75,6 @@ + } + } + } else { +- len = FFMIN(s->frame_size - len, buf_size); +- +- memcpy(s->inbuf_ptr, buf_ptr, len); +- buf_ptr += len; +- s->inbuf_ptr += len; +- buf_size -= len; +- + if(s->inbuf_ptr - s->inbuf == s->frame_size){ + *poutbuf = s->inbuf; + *poutbuf_size = s->frame_size; +diff -u mplayer-1.0~rc2-12/libavcodec/aac_ac3_parser.h ffmpeg-free-0.svn20080206/libavcodec/aac_ac3_parser.h +--- mplayer-1.0~rc2-12/libavcodec/aac_ac3_parser.h 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/aac_ac3_parser.h 2007-10-17 11:37:46.000000000 +0200 +@@ -20,8 +20,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef AAC_AC3_PARSER_H +-#define AAC_AC3_PARSER_H ++#ifndef FFMPEG_AAC_AC3_PARSER_H ++#define FFMPEG_AAC_AC3_PARSER_H + + #include + #include "avcodec.h" +@@ -40,4 +40,4 @@ + const uint8_t **poutbuf, int *poutbuf_size, + const uint8_t *buf, int buf_size); + +-#endif /* AAC_AC3_PARSER_H */ ++#endif /* FFMPEG_AAC_AC3_PARSER_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/aac_parser.c ffmpeg-free-0.svn20080206/libavcodec/aac_parser.c +--- mplayer-1.0~rc2-12/libavcodec/aac_parser.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/aac_parser.c 2008-03-20 19:10:57.000000000 +0100 +@@ -67,6 +67,9 @@ + skip_bits1(&bits); /* copyright_identification_bit */ + skip_bits1(&bits); /* copyright_identification_start */ + size = get_bits(&bits, 13); /* aac_frame_length */ ++ if(size < AAC_HEADER_SIZE) ++ return 0; ++ + skip_bits(&bits, 11); /* adts_buffer_fullness */ + rdb = get_bits(&bits, 2); /* number_of_raw_data_blocks_in_frame */ + +diff -u mplayer-1.0~rc2-12/libavcodec/aasc.c ffmpeg-free-0.svn20080206/libavcodec/aasc.c +--- mplayer-1.0~rc2-12/libavcodec/aasc.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/aasc.c 2008-03-20 19:10:57.000000000 +0100 +@@ -58,7 +58,7 @@ + + static int aasc_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + AascContext *s = avctx->priv_data; + int stream_ptr = 4; +diff -u mplayer-1.0~rc2-12/libavcodec/ac3.c ffmpeg-free-0.svn20080206/libavcodec/ac3.c +--- mplayer-1.0~rc2-12/libavcodec/ac3.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/ac3.c 2008-03-20 19:10:57.000000000 +0100 +@@ -28,8 +28,8 @@ + #include "ac3.h" + #include "bitstream.h" + +-static uint8_t bndtab[51]; +-static uint8_t masktab[253]; ++static uint8_t band_start_tab[51]; ++static uint8_t bin_to_band_tab[253]; + + static inline int calc_lowcomp1(int a, int b0, int b1, int c) + { +@@ -53,7 +53,7 @@ + } + + void ff_ac3_bit_alloc_calc_psd(int8_t *exp, int start, int end, int16_t *psd, +- int16_t *bndpsd) ++ int16_t *band_psd) + { + int bin, i, j, k, end1, v; + +@@ -64,26 +64,26 @@ + + /* PSD integration */ + j=start; +- k=masktab[start]; ++ k=bin_to_band_tab[start]; + do { + v=psd[j]; + j++; +- end1 = FFMIN(bndtab[k+1], end); ++ end1 = FFMIN(band_start_tab[k+1], end); + for(i=j;i> 1, 255); +- v = FFMAX(v, psd[j]) + ff_ac3_latab[adr]; ++ v = FFMAX(v, psd[j]) + ff_ac3_log_add_tab[adr]; + j++; + } +- bndpsd[k]=v; ++ band_psd[k]=v; + k++; +- } while (end > bndtab[k]); ++ } while (end > band_start_tab[k]); + } + +-void ff_ac3_bit_alloc_calc_mask(AC3BitAllocParameters *s, int16_t *bndpsd, +- int start, int end, int fgain, int is_lfe, +- int deltbae, int deltnseg, uint8_t *deltoffst, +- uint8_t *deltlen, uint8_t *deltba, ++void ff_ac3_bit_alloc_calc_mask(AC3BitAllocParameters *s, int16_t *band_psd, ++ int start, int end, int fast_gain, int is_lfe, ++ int dba_mode, int dba_nsegs, uint8_t *dba_offsets, ++ uint8_t *dba_lengths, uint8_t *dba_values, + int16_t *mask) + { + int16_t excite[50]; /* excitation */ +@@ -92,24 +92,24 @@ + int lowcomp, fastleak, slowleak; + + /* excitation function */ +- bndstrt = masktab[start]; +- bndend = masktab[end-1] + 1; ++ bndstrt = bin_to_band_tab[start]; ++ bndend = bin_to_band_tab[end-1] + 1; + + if (bndstrt == 0) { + lowcomp = 0; +- lowcomp = calc_lowcomp1(lowcomp, bndpsd[0], bndpsd[1], 384); +- excite[0] = bndpsd[0] - fgain - lowcomp; +- lowcomp = calc_lowcomp1(lowcomp, bndpsd[1], bndpsd[2], 384); +- excite[1] = bndpsd[1] - fgain - lowcomp; ++ lowcomp = calc_lowcomp1(lowcomp, band_psd[0], band_psd[1], 384); ++ excite[0] = band_psd[0] - fast_gain - lowcomp; ++ lowcomp = calc_lowcomp1(lowcomp, band_psd[1], band_psd[2], 384); ++ excite[1] = band_psd[1] - fast_gain - lowcomp; + begin = 7; + for (bin = 2; bin < 7; bin++) { + if (!(is_lfe && bin == 6)) +- lowcomp = calc_lowcomp1(lowcomp, bndpsd[bin], bndpsd[bin+1], 384); +- fastleak = bndpsd[bin] - fgain; +- slowleak = bndpsd[bin] - s->sgain; ++ lowcomp = calc_lowcomp1(lowcomp, band_psd[bin], band_psd[bin+1], 384); ++ fastleak = band_psd[bin] - fast_gain; ++ slowleak = band_psd[bin] - s->slow_gain; + excite[bin] = fastleak - lowcomp; + if (!(is_lfe && bin == 6)) { +- if (bndpsd[bin] <= bndpsd[bin+1]) { ++ if (band_psd[bin] <= band_psd[bin+1]) { + begin = bin + 1; + break; + } +@@ -121,10 +121,10 @@ + + for (bin = begin; bin < end1; bin++) { + if (!(is_lfe && bin == 6)) +- lowcomp = calc_lowcomp(lowcomp, bndpsd[bin], bndpsd[bin+1], bin); ++ lowcomp = calc_lowcomp(lowcomp, band_psd[bin], band_psd[bin+1], bin); + +- fastleak = FFMAX(fastleak - s->fdecay, bndpsd[bin] - fgain); +- slowleak = FFMAX(slowleak - s->sdecay, bndpsd[bin] - s->sgain); ++ fastleak = FFMAX(fastleak - s->fast_decay, band_psd[bin] - fast_gain); ++ slowleak = FFMAX(slowleak - s->slow_decay, band_psd[bin] - s->slow_gain); + excite[bin] = FFMAX(fastleak - lowcomp, slowleak); + } + begin = 22; +@@ -132,39 +132,39 @@ + /* coupling channel */ + begin = bndstrt; + +- fastleak = (s->cplfleak << 8) + 768; +- slowleak = (s->cplsleak << 8) + 768; ++ fastleak = (s->cpl_fast_leak << 8) + 768; ++ slowleak = (s->cpl_slow_leak << 8) + 768; + } + + for (bin = begin; bin < bndend; bin++) { +- fastleak = FFMAX(fastleak - s->fdecay, bndpsd[bin] - fgain); +- slowleak = FFMAX(slowleak - s->sdecay, bndpsd[bin] - s->sgain); ++ fastleak = FFMAX(fastleak - s->fast_decay, band_psd[bin] - fast_gain); ++ slowleak = FFMAX(slowleak - s->slow_decay, band_psd[bin] - s->slow_gain); + excite[bin] = FFMAX(fastleak, slowleak); + } + + /* compute masking curve */ + + for (bin = bndstrt; bin < bndend; bin++) { +- tmp = s->dbknee - bndpsd[bin]; ++ tmp = s->db_per_bit - band_psd[bin]; + if (tmp > 0) { + excite[bin] += tmp >> 2; + } +- mask[bin] = FFMAX(ff_ac3_hth[bin >> s->halfratecod][s->fscod], excite[bin]); ++ mask[bin] = FFMAX(ff_ac3_hearing_threshold_tab[bin >> s->sr_shift][s->sr_code], excite[bin]); + } + + /* delta bit allocation */ + +- if (deltbae == DBA_REUSE || deltbae == DBA_NEW) { ++ if (dba_mode == DBA_REUSE || dba_mode == DBA_NEW) { + int band, seg, delta; + band = 0; +- for (seg = 0; seg < deltnseg; seg++) { +- band += deltoffst[seg]; +- if (deltba[seg] >= 4) { +- delta = (deltba[seg] - 3) << 7; ++ for (seg = 0; seg < dba_nsegs; seg++) { ++ band += dba_offsets[seg]; ++ if (dba_values[seg] >= 4) { ++ delta = (dba_values[seg] - 3) << 7; + } else { +- delta = (deltba[seg] - 4) << 7; ++ delta = (dba_values[seg] - 4) << 7; + } +- for (k = 0; k < deltlen[seg]; k++) { ++ for (k = 0; k < dba_lengths[seg]; k++) { + mask[band] += delta; + band++; + } +@@ -173,49 +173,49 @@ + } + + void ff_ac3_bit_alloc_calc_bap(int16_t *mask, int16_t *psd, int start, int end, +- int snroffset, int floor, uint8_t *bap) ++ int snr_offset, int floor, uint8_t *bap) + { + int i, j, k, end1, v, address; + +- /* special case, if snroffset is -960, set all bap's to zero */ +- if(snroffset == -960) { ++ /* special case, if snr offset is -960, set all bap's to zero */ ++ if(snr_offset == -960) { + memset(bap, 0, 256); + return; + } + + i = start; +- j = masktab[start]; ++ j = bin_to_band_tab[start]; + do { +- v = (FFMAX(mask[j] - snroffset - floor, 0) & 0x1FE0) + floor; +- end1 = FFMIN(bndtab[j] + ff_ac3_bndsz[j], end); ++ v = (FFMAX(mask[j] - snr_offset - floor, 0) & 0x1FE0) + floor; ++ end1 = FFMIN(band_start_tab[j] + ff_ac3_critical_band_size_tab[j], end); + for (k = i; k < end1; k++) { + address = av_clip((psd[i] - v) >> 5, 0, 63); +- bap[i] = ff_ac3_baptab[address]; ++ bap[i] = ff_ac3_bap_tab[address]; + i++; + } +- } while (end > bndtab[j++]); ++ } while (end > band_start_tab[j++]); + } + + /* AC3 bit allocation. The algorithm is the one described in the AC3 + spec. */ + void ac3_parametric_bit_allocation(AC3BitAllocParameters *s, uint8_t *bap, + int8_t *exp, int start, int end, +- int snroffset, int fgain, int is_lfe, +- int deltbae,int deltnseg, +- uint8_t *deltoffst, uint8_t *deltlen, +- uint8_t *deltba) ++ int snr_offset, int fast_gain, int is_lfe, ++ int dba_mode, int dba_nsegs, ++ uint8_t *dba_offsets, uint8_t *dba_lengths, ++ uint8_t *dba_values) + { + int16_t psd[256]; /* scaled exponents */ +- int16_t bndpsd[50]; /* interpolated exponents */ ++ int16_t band_psd[50]; /* interpolated exponents */ + int16_t mask[50]; /* masking value */ + +- ff_ac3_bit_alloc_calc_psd(exp, start, end, psd, bndpsd); ++ ff_ac3_bit_alloc_calc_psd(exp, start, end, psd, band_psd); + +- ff_ac3_bit_alloc_calc_mask(s, bndpsd, start, end, fgain, is_lfe, +- deltbae, deltnseg, deltoffst, deltlen, deltba, ++ ff_ac3_bit_alloc_calc_mask(s, band_psd, start, end, fast_gain, is_lfe, ++ dba_mode, dba_nsegs, dba_offsets, dba_lengths, dba_values, + mask); + +- ff_ac3_bit_alloc_calc_bap(mask, psd, start, end, snroffset, s->floor, bap); ++ ff_ac3_bit_alloc_calc_bap(mask, psd, start, end, snr_offset, s->floor, bap); + } + + /** +@@ -230,10 +230,10 @@ + k = 0; + l = 0; + for(i=0;i<50;i++) { +- bndtab[i] = l; +- v = ff_ac3_bndsz[i]; +- for(j=0;j 0; j--) /* default to 100 iterations */ +- bessel = bessel * tmp / (j * j) + 1; +- sum += bessel; +- local_window[i] = sum; +- } +- +- sum++; +- for (i = 0; i < 256; i++) +- window[i] = sqrt(local_window[i] / sum); +-} +- +-/** + * Symmetrical Dequantization + * reference: Section 7.3.3 Expansion of Mantissas for Symmetrical Quantization + * Tables 7.19 to 7.23 +@@ -273,16 +247,8 @@ + reference: Section 7.7.1 Dynamic Range Control */ + for(i=0; i<256; i++) { + int v = (i >> 5) - ((i >> 7) << 3) - 5; +- dynrng_tab[i] = powf(2.0f, v) * ((i & 0x1F) | 0x20); +- } +- +- /* generate dialogue normalization table +- references: Section 5.4.2.8 dialnorm +- Section 7.6 Dialogue Normalization */ +- for(i=1; i<32; i++) { +- dialnorm_tab[i] = expf((i-31) * M_LN10 / 20.0f); ++ dynamic_range_tab[i] = powf(2.0f, v) * ((i & 0x1F) | 0x20); + } +- dialnorm_tab[0] = dialnorm_tab[31]; + + /* generate scale factors for exponents and asymmetrical dequantization + reference: Section 7.3.2 Expansion of Mantissas for Asymmetric Quantization */ +@@ -304,24 +270,31 @@ + */ + static int ac3_decode_init(AVCodecContext *avctx) + { +- AC3DecodeContext *ctx = avctx->priv_data; +- ctx->avctx = avctx; ++ AC3DecodeContext *s = avctx->priv_data; ++ s->avctx = avctx; + + ac3_common_init(); + ac3_tables_init(); +- ff_mdct_init(&ctx->imdct_256, 8, 1); +- ff_mdct_init(&ctx->imdct_512, 9, 1); +- ac3_window_init(ctx->window); +- dsputil_init(&ctx->dsp, avctx); +- av_init_random(0, &ctx->dith_state); ++ ff_mdct_init(&s->imdct_256, 8, 1); ++ ff_mdct_init(&s->imdct_512, 9, 1); ++ ff_kbd_window_init(s->window, 5.0, 256); ++ dsputil_init(&s->dsp, avctx); ++ av_init_random(0, &s->dith_state); + + /* set bias values for float to int16 conversion */ +- if(ctx->dsp.float_to_int16 == ff_float_to_int16_c) { +- ctx->add_bias = 385.0f; +- ctx->mul_bias = 1.0f; ++ if(s->dsp.float_to_int16 == ff_float_to_int16_c) { ++ s->add_bias = 385.0f; ++ s->mul_bias = 1.0f; + } else { +- ctx->add_bias = 0.0f; +- ctx->mul_bias = 32767.0f; ++ s->add_bias = 0.0f; ++ s->mul_bias = 32767.0f; ++ } ++ ++ /* allow downmixing to stereo or mono */ ++ if (avctx->channels > 0 && avctx->request_channels > 0 && ++ avctx->request_channels < avctx->channels && ++ avctx->request_channels <= 2) { ++ avctx->channels = avctx->request_channels; + } + + return 0; +@@ -332,118 +305,130 @@ + * GetBitContext within AC3DecodeContext must point to + * start of the synchronized ac3 bitstream. + */ +-static int ac3_parse_header(AC3DecodeContext *ctx) ++static int ac3_parse_header(AC3DecodeContext *s) + { + AC3HeaderInfo hdr; +- GetBitContext *gb = &ctx->gb; +- float cmixlev, surmixlev; ++ GetBitContext *gbc = &s->gbc; + int err, i; + +- err = ff_ac3_parse_header(gb->buffer, &hdr); ++ err = ff_ac3_parse_header(gbc->buffer, &hdr); + if(err) + return err; + ++ if(hdr.bitstream_id > 10) ++ return AC3_PARSE_ERROR_BSID; ++ + /* get decoding parameters from header info */ +- ctx->bit_alloc_params.fscod = hdr.fscod; +- ctx->acmod = hdr.acmod; +- cmixlev = gain_levels[clevs[hdr.cmixlev]]; +- surmixlev = gain_levels[slevs[hdr.surmixlev]]; +- ctx->dsurmod = hdr.dsurmod; +- ctx->lfeon = hdr.lfeon; +- ctx->bit_alloc_params.halfratecod = hdr.halfratecod; +- ctx->sampling_rate = hdr.sample_rate; +- ctx->bit_rate = hdr.bit_rate; +- ctx->nchans = hdr.channels; +- ctx->nfchans = ctx->nchans - ctx->lfeon; +- ctx->lfe_ch = ctx->nfchans + 1; +- ctx->frame_size = hdr.frame_size; ++ s->bit_alloc_params.sr_code = hdr.sr_code; ++ s->channel_mode = hdr.channel_mode; ++ s->lfe_on = hdr.lfe_on; ++ s->bit_alloc_params.sr_shift = hdr.sr_shift; ++ s->sample_rate = hdr.sample_rate; ++ s->bit_rate = hdr.bit_rate; ++ s->channels = hdr.channels; ++ s->fbw_channels = s->channels - s->lfe_on; ++ s->lfe_ch = s->fbw_channels + 1; ++ s->frame_size = hdr.frame_size; + + /* set default output to all source channels */ +- ctx->out_channels = ctx->nchans; +- ctx->output_mode = ctx->acmod; +- if(ctx->lfeon) +- ctx->output_mode |= AC3_OUTPUT_LFEON; ++ s->out_channels = s->channels; ++ s->output_mode = s->channel_mode; ++ if(s->lfe_on) ++ s->output_mode |= AC3_OUTPUT_LFEON; ++ ++ /* set default mix levels */ ++ s->center_mix_level = 3; // -4.5dB ++ s->surround_mix_level = 4; // -6.0dB + + /* skip over portion of header which has already been read */ +- skip_bits(gb, 16); // skip the sync_word +- skip_bits(gb, 16); // skip crc1 +- skip_bits(gb, 8); // skip fscod and frmsizecod +- skip_bits(gb, 11); // skip bsid, bsmod, and acmod +- if(ctx->acmod == AC3_ACMOD_STEREO) { +- skip_bits(gb, 2); // skip dsurmod ++ skip_bits(gbc, 16); // skip the sync_word ++ skip_bits(gbc, 16); // skip crc1 ++ skip_bits(gbc, 8); // skip fscod and frmsizecod ++ skip_bits(gbc, 11); // skip bsid, bsmod, and acmod ++ if(s->channel_mode == AC3_CHMODE_STEREO) { ++ skip_bits(gbc, 2); // skip dsurmod + } else { +- if((ctx->acmod & 1) && ctx->acmod != AC3_ACMOD_MONO) +- skip_bits(gb, 2); // skip cmixlev +- if(ctx->acmod & 4) +- skip_bits(gb, 2); // skip surmixlev ++ if((s->channel_mode & 1) && s->channel_mode != AC3_CHMODE_MONO) ++ s->center_mix_level = center_levels[get_bits(gbc, 2)]; ++ if(s->channel_mode & 4) ++ s->surround_mix_level = surround_levels[get_bits(gbc, 2)]; + } +- skip_bits1(gb); // skip lfeon ++ skip_bits1(gbc); // skip lfeon + + /* read the rest of the bsi. read twice for dual mono mode. */ +- i = !(ctx->acmod); ++ i = !(s->channel_mode); + do { +- ctx->dialnorm[i] = dialnorm_tab[get_bits(gb, 5)]; // dialogue normalization +- if (get_bits1(gb)) +- skip_bits(gb, 8); //skip compression +- if (get_bits1(gb)) +- skip_bits(gb, 8); //skip language code +- if (get_bits1(gb)) +- skip_bits(gb, 7); //skip audio production information ++ skip_bits(gbc, 5); // skip dialog normalization ++ if (get_bits1(gbc)) ++ skip_bits(gbc, 8); //skip compression ++ if (get_bits1(gbc)) ++ skip_bits(gbc, 8); //skip language code ++ if (get_bits1(gbc)) ++ skip_bits(gbc, 7); //skip audio production information + } while (i--); + +- skip_bits(gb, 2); //skip copyright bit and original bitstream bit ++ skip_bits(gbc, 2); //skip copyright bit and original bitstream bit + + /* skip the timecodes (or extra bitstream information for Alternate Syntax) + TODO: read & use the xbsi1 downmix levels */ +- if (get_bits1(gb)) +- skip_bits(gb, 14); //skip timecode1 / xbsi1 +- if (get_bits1(gb)) +- skip_bits(gb, 14); //skip timecode2 / xbsi2 ++ if (get_bits1(gbc)) ++ skip_bits(gbc, 14); //skip timecode1 / xbsi1 ++ if (get_bits1(gbc)) ++ skip_bits(gbc, 14); //skip timecode2 / xbsi2 + + /* skip additional bitstream info */ +- if (get_bits1(gb)) { +- i = get_bits(gb, 6); ++ if (get_bits1(gbc)) { ++ i = get_bits(gbc, 6); + do { +- skip_bits(gb, 8); ++ skip_bits(gbc, 8); + } while(i--); + } + +- /* set stereo downmixing coefficients +- reference: Section 7.8.2 Downmixing Into Two Channels */ +- for(i=0; infchans; i++) { +- ctx->downmix_coeffs[i][0] = gain_levels[ac3_default_coeffs[ctx->acmod][i][0]]; +- ctx->downmix_coeffs[i][1] = gain_levels[ac3_default_coeffs[ctx->acmod][i][1]]; +- } +- if(ctx->acmod > 1 && ctx->acmod & 1) { +- ctx->downmix_coeffs[1][0] = ctx->downmix_coeffs[1][1] = cmixlev; +- } +- if(ctx->acmod == AC3_ACMOD_2F1R || ctx->acmod == AC3_ACMOD_3F1R) { +- int nf = ctx->acmod - 2; +- ctx->downmix_coeffs[nf][0] = ctx->downmix_coeffs[nf][1] = surmixlev * LEVEL_MINUS_3DB; +- } +- if(ctx->acmod == AC3_ACMOD_2F2R || ctx->acmod == AC3_ACMOD_3F2R) { +- int nf = ctx->acmod - 4; +- ctx->downmix_coeffs[nf][0] = ctx->downmix_coeffs[nf+1][1] = surmixlev; +- } +- + return 0; + } + + /** ++ * Set stereo downmixing coefficients based on frame header info. ++ * reference: Section 7.8.2 Downmixing Into Two Channels ++ */ ++static void set_downmix_coeffs(AC3DecodeContext *s) ++{ ++ int i; ++ float cmix = gain_levels[s->center_mix_level]; ++ float smix = gain_levels[s->surround_mix_level]; ++ ++ for(i=0; ifbw_channels; i++) { ++ s->downmix_coeffs[i][0] = gain_levels[ac3_default_coeffs[s->channel_mode][i][0]]; ++ s->downmix_coeffs[i][1] = gain_levels[ac3_default_coeffs[s->channel_mode][i][1]]; ++ } ++ if(s->channel_mode > 1 && s->channel_mode & 1) { ++ s->downmix_coeffs[1][0] = s->downmix_coeffs[1][1] = cmix; ++ } ++ if(s->channel_mode == AC3_CHMODE_2F1R || s->channel_mode == AC3_CHMODE_3F1R) { ++ int nf = s->channel_mode - 2; ++ s->downmix_coeffs[nf][0] = s->downmix_coeffs[nf][1] = smix * LEVEL_MINUS_3DB; ++ } ++ if(s->channel_mode == AC3_CHMODE_2F2R || s->channel_mode == AC3_CHMODE_3F2R) { ++ int nf = s->channel_mode - 4; ++ s->downmix_coeffs[nf][0] = s->downmix_coeffs[nf+1][1] = smix; ++ } ++} ++ ++/** + * Decode the grouped exponents according to exponent strategy. + * reference: Section 7.1.3 Exponent Decoding + */ +-static void decode_exponents(GetBitContext *gb, int expstr, int ngrps, ++static void decode_exponents(GetBitContext *gbc, int exp_strategy, int ngrps, + uint8_t absexp, int8_t *dexps) + { +- int i, j, grp, grpsize; ++ int i, j, grp, group_size; + int dexp[256]; + int expacc, prevexp; + + /* unpack groups */ +- grpsize = expstr + (expstr == EXP_D45); ++ group_size = exp_strategy + (exp_strategy == EXP_D45); + for(grp=0,i=0; grpstartmant[CPL_CH]; +- for(bnd=0; bndncplbnd; bnd++) { ++ i = s->start_freq[CPL_CH]; ++ for(bnd=0; bndnum_cpl_bands; bnd++) { + do { + subbnd++; + for(j=0; j<12; j++) { +- for(ch=1; ch<=ctx->nfchans; ch++) { +- if(ctx->chincpl[ch]) +- ctx->transform_coeffs[ch][i] = ctx->transform_coeffs[CPL_CH][i] * ctx->cplco[ch][bnd] * 8.0f; ++ for(ch=1; ch<=s->fbw_channels; ch++) { ++ if(s->channel_in_cpl[ch]) { ++ s->transform_coeffs[ch][i] = s->transform_coeffs[CPL_CH][i] * s->cpl_coords[ch][bnd] * 8.0f; ++ if (ch == 2 && s->phase_flags[bnd]) ++ s->transform_coeffs[ch][i] = -s->transform_coeffs[ch][i]; ++ } + } + i++; + } +- } while(ctx->cplbndstrc[subbnd]); ++ } while(s->cpl_band_struct[subbnd]); + } + } + +@@ -500,30 +488,30 @@ + * Get the transform coefficients for a particular channel + * reference: Section 7.3 Quantization and Decoding of Mantissas + */ +-static int get_transform_coeffs_ch(AC3DecodeContext *ctx, int ch_index, mant_groups *m) ++static int get_transform_coeffs_ch(AC3DecodeContext *s, int ch_index, mant_groups *m) + { +- GetBitContext *gb = &ctx->gb; ++ GetBitContext *gbc = &s->gbc; + int i, gcode, tbap, start, end; + uint8_t *exps; + uint8_t *bap; + float *coeffs; + +- exps = ctx->dexps[ch_index]; +- bap = ctx->bap[ch_index]; +- coeffs = ctx->transform_coeffs[ch_index]; +- start = ctx->startmant[ch_index]; +- end = ctx->endmant[ch_index]; ++ exps = s->dexps[ch_index]; ++ bap = s->bap[ch_index]; ++ coeffs = s->transform_coeffs[ch_index]; ++ start = s->start_freq[ch_index]; ++ end = s->end_freq[ch_index]; + + for (i = start; i < end; i++) { + tbap = bap[i]; + switch (tbap) { + case 0: +- coeffs[i] = ((av_random(&ctx->dith_state) & 0xFFFF) / 65535.0f) - 0.5f; ++ coeffs[i] = ((av_random(&s->dith_state) & 0xFFFF) / 65535.0f) - 0.5f; + break; + + case 1: + if(m->b1ptr > 2) { +- gcode = get_bits(gb, 5); ++ gcode = get_bits(gbc, 5); + m->b1_mant[0] = b1_mantissas[gcode][0]; + m->b1_mant[1] = b1_mantissas[gcode][1]; + m->b1_mant[2] = b1_mantissas[gcode][2]; +@@ -534,7 +522,7 @@ + + case 2: + if(m->b2ptr > 2) { +- gcode = get_bits(gb, 7); ++ gcode = get_bits(gbc, 7); + m->b2_mant[0] = b2_mantissas[gcode][0]; + m->b2_mant[1] = b2_mantissas[gcode][1]; + m->b2_mant[2] = b2_mantissas[gcode][2]; +@@ -544,12 +532,12 @@ + break; + + case 3: +- coeffs[i] = b3_mantissas[get_bits(gb, 3)]; ++ coeffs[i] = b3_mantissas[get_bits(gbc, 3)]; + break; + + case 4: + if(m->b4ptr > 1) { +- gcode = get_bits(gb, 7); ++ gcode = get_bits(gbc, 7); + m->b4_mant[0] = b4_mantissas[gcode][0]; + m->b4_mant[1] = b4_mantissas[gcode][1]; + m->b4ptr = 0; +@@ -558,12 +546,12 @@ + break; + + case 5: +- coeffs[i] = b5_mantissas[get_bits(gb, 4)]; ++ coeffs[i] = b5_mantissas[get_bits(gbc, 4)]; + break; + + default: + /* asymmetric dequantization */ +- coeffs[i] = get_sbits(gb, qntztab[tbap]) * scale_factors[qntztab[tbap]-1]; ++ coeffs[i] = get_sbits(gbc, quantization_tab[tbap]) * scale_factors[quantization_tab[tbap]-1]; + break; + } + coeffs[i] *= scale_factors[exps[i]]; +@@ -576,28 +564,28 @@ + * Remove random dithering from coefficients with zero-bit mantissas + * reference: Section 7.3.4 Dither for Zero Bit Mantissas (bap=0) + */ +-static void remove_dithering(AC3DecodeContext *ctx) { ++static void remove_dithering(AC3DecodeContext *s) { + int ch, i; + int end=0; + float *coeffs; + uint8_t *bap; + +- for(ch=1; ch<=ctx->nfchans; ch++) { +- if(!ctx->dithflag[ch]) { +- coeffs = ctx->transform_coeffs[ch]; +- bap = ctx->bap[ch]; +- if(ctx->chincpl[ch]) +- end = ctx->startmant[CPL_CH]; ++ for(ch=1; ch<=s->fbw_channels; ch++) { ++ if(!s->dither_flag[ch]) { ++ coeffs = s->transform_coeffs[ch]; ++ bap = s->bap[ch]; ++ if(s->channel_in_cpl[ch]) ++ end = s->start_freq[CPL_CH]; + else +- end = ctx->endmant[ch]; ++ end = s->end_freq[ch]; + for(i=0; ichincpl[ch]) { +- bap = ctx->bap[CPL_CH]; +- for(; iendmant[CPL_CH]; i++) { +- if(bap[i] == 0) ++ if(s->channel_in_cpl[ch]) { ++ bap = s->bap[CPL_CH]; ++ for(; iend_freq[CPL_CH]; i++) { ++ if(!bap[i]) + coeffs[i] = 0.0f; + } + } +@@ -608,7 +596,7 @@ + /** + * Get the transform coefficients. + */ +-static int get_transform_coeffs(AC3DecodeContext * ctx) ++static int get_transform_coeffs(AC3DecodeContext *s) + { + int ch, end; + int got_cplchan = 0; +@@ -616,33 +604,33 @@ + + m.b1ptr = m.b2ptr = m.b4ptr = 3; + +- for (ch = 1; ch <= ctx->nchans; ch++) { ++ for (ch = 1; ch <= s->channels; ch++) { + /* transform coefficients for full-bandwidth channel */ +- if (get_transform_coeffs_ch(ctx, ch, &m)) ++ if (get_transform_coeffs_ch(s, ch, &m)) + return -1; + /* tranform coefficients for coupling channel come right after the + coefficients for the first coupled channel*/ +- if (ctx->chincpl[ch]) { ++ if (s->channel_in_cpl[ch]) { + if (!got_cplchan) { +- if (get_transform_coeffs_ch(ctx, CPL_CH, &m)) { +- av_log(ctx->avctx, AV_LOG_ERROR, "error in decoupling channels\n"); ++ if (get_transform_coeffs_ch(s, CPL_CH, &m)) { ++ av_log(s->avctx, AV_LOG_ERROR, "error in decoupling channels\n"); + return -1; + } +- uncouple_channels(ctx); ++ uncouple_channels(s); + got_cplchan = 1; + } +- end = ctx->endmant[CPL_CH]; ++ end = s->end_freq[CPL_CH]; + } else { +- end = ctx->endmant[ch]; ++ end = s->end_freq[ch]; + } + do +- ctx->transform_coeffs[ch][end] = 0; ++ s->transform_coeffs[ch][end] = 0; + while(++end < 256); + } + + /* if any channel doesn't use dithering, zero appropriate coefficients */ +- if(!ctx->dither_all) +- remove_dithering(ctx); ++ if(!s->dither_all) ++ remove_dithering(s); + + return 0; + } +@@ -651,22 +639,22 @@ + * Stereo rematrixing. + * reference: Section 7.5.4 Rematrixing : Decoding Technique + */ +-static void do_rematrixing(AC3DecodeContext *ctx) ++static void do_rematrixing(AC3DecodeContext *s) + { + int bnd, i; + int end, bndend; + float tmp0, tmp1; + +- end = FFMIN(ctx->endmant[1], ctx->endmant[2]); ++ end = FFMIN(s->end_freq[1], s->end_freq[2]); + +- for(bnd=0; bndnrematbnd; bnd++) { +- if(ctx->rematflg[bnd]) { ++ for(bnd=0; bndnum_rematrixing_bands; bnd++) { ++ if(s->rematrixing_flags[bnd]) { + bndend = FFMIN(end, rematrix_band_tab[bnd+1]); + for(i=rematrix_band_tab[bnd]; itransform_coeffs[1][i]; +- tmp1 = ctx->transform_coeffs[2][i]; +- ctx->transform_coeffs[1][i] = tmp0 + tmp1; +- ctx->transform_coeffs[2][i] = tmp0 - tmp1; ++ tmp0 = s->transform_coeffs[1][i]; ++ tmp1 = s->transform_coeffs[2][i]; ++ s->transform_coeffs[1][i] = tmp0 + tmp1; ++ s->transform_coeffs[2][i] = tmp0 - tmp1; + } + } + } +@@ -675,21 +663,21 @@ + /** + * Perform the 256-point IMDCT + */ +-static void do_imdct_256(AC3DecodeContext *ctx, int chindex) ++static void do_imdct_256(AC3DecodeContext *s, int chindex) + { + int i, k; + DECLARE_ALIGNED_16(float, x[128]); + FFTComplex z[2][64]; +- float *o_ptr = ctx->tmp_output; ++ float *o_ptr = s->tmp_output; + + for(i=0; i<2; i++) { + /* de-interleave coefficients */ + for(k=0; k<128; k++) { +- x[k] = ctx->transform_coeffs[chindex][2*k+i]; ++ x[k] = s->transform_coeffs[chindex][2*k+i]; + } + + /* run standard IMDCT */ +- ctx->imdct_256.fft.imdct_calc(&ctx->imdct_256, o_ptr, x, ctx->tmp_imdct); ++ s->imdct_256.fft.imdct_calc(&s->imdct_256, o_ptr, x, s->tmp_imdct); + + /* reverse the post-rotation & reordering from standard IMDCT */ + for(k=0; k<32; k++) { +@@ -718,59 +706,57 @@ + * Convert frequency domain coefficients to time-domain audio samples. + * reference: Section 7.9.4 Transformation Equations + */ +-static inline void do_imdct(AC3DecodeContext *ctx) ++static inline void do_imdct(AC3DecodeContext *s) + { + int ch; +- int nchans; ++ int channels; + + /* Don't perform the IMDCT on the LFE channel unless it's used in the output */ +- nchans = ctx->nfchans; +- if(ctx->output_mode & AC3_OUTPUT_LFEON) +- nchans++; +- +- for (ch=1; ch<=nchans; ch++) { +- if (ctx->blksw[ch]) { +- do_imdct_256(ctx, ch); ++ channels = s->fbw_channels; ++ if(s->output_mode & AC3_OUTPUT_LFEON) ++ channels++; ++ ++ for (ch=1; ch<=channels; ch++) { ++ if (s->block_switch[ch]) { ++ do_imdct_256(s, ch); + } else { +- ctx->imdct_512.fft.imdct_calc(&ctx->imdct_512, ctx->tmp_output, +- ctx->transform_coeffs[ch], +- ctx->tmp_imdct); ++ s->imdct_512.fft.imdct_calc(&s->imdct_512, s->tmp_output, ++ s->transform_coeffs[ch], s->tmp_imdct); + } + /* For the first half of the block, apply the window, add the delay + from the previous block, and send to output */ +- ctx->dsp.vector_fmul_add_add(ctx->output[ch-1], ctx->tmp_output, +- ctx->window, ctx->delay[ch-1], 0, 256, 1); ++ s->dsp.vector_fmul_add_add(s->output[ch-1], s->tmp_output, ++ s->window, s->delay[ch-1], 0, 256, 1); + /* For the second half of the block, apply the window and store the + samples to delay, to be combined with the next block */ +- ctx->dsp.vector_fmul_reverse(ctx->delay[ch-1], ctx->tmp_output+256, +- ctx->window, 256); ++ s->dsp.vector_fmul_reverse(s->delay[ch-1], s->tmp_output+256, ++ s->window, 256); + } + } + + /** + * Downmix the output to mono or stereo. + */ +-static void ac3_downmix(float samples[AC3_MAX_CHANNELS][256], int nfchans, +- int output_mode, float coef[AC3_MAX_CHANNELS][2]) ++static void ac3_downmix(AC3DecodeContext *s) + { + int i, j; + float v0, v1, s0, s1; + + for(i=0; i<256; i++) { + v0 = v1 = s0 = s1 = 0.0f; +- for(j=0; jfbw_channels; j++) { ++ v0 += s->output[j][i] * s->downmix_coeffs[j][0]; ++ v1 += s->output[j][i] * s->downmix_coeffs[j][1]; ++ s0 += s->downmix_coeffs[j][0]; ++ s1 += s->downmix_coeffs[j][1]; + } + v0 /= s0; + v1 /= s1; +- if(output_mode == AC3_ACMOD_MONO) { +- samples[0][i] = (v0 + v1) * LEVEL_MINUS_3DB; +- } else if(output_mode == AC3_ACMOD_STEREO) { +- samples[0][i] = v0; +- samples[1][i] = v1; ++ if(s->output_mode == AC3_CHMODE_MONO) { ++ s->output[0][i] = (v0 + v1) * LEVEL_MINUS_3DB; ++ } else if(s->output_mode == AC3_CHMODE_STEREO) { ++ s->output[0][i] = v0; ++ s->output[1][i] = v1; + } + } + } +@@ -778,305 +764,304 @@ + /** + * Parse an audio block from AC-3 bitstream. + */ +-static int ac3_parse_audio_block(AC3DecodeContext *ctx, int blk) ++static int ac3_parse_audio_block(AC3DecodeContext *s, int blk) + { +- int nfchans = ctx->nfchans; +- int acmod = ctx->acmod; ++ int fbw_channels = s->fbw_channels; ++ int channel_mode = s->channel_mode; + int i, bnd, seg, ch; +- GetBitContext *gb = &ctx->gb; ++ GetBitContext *gbc = &s->gbc; + uint8_t bit_alloc_stages[AC3_MAX_CHANNELS]; + + memset(bit_alloc_stages, 0, AC3_MAX_CHANNELS); + + /* block switch flags */ +- for (ch = 1; ch <= nfchans; ch++) +- ctx->blksw[ch] = get_bits1(gb); ++ for (ch = 1; ch <= fbw_channels; ch++) ++ s->block_switch[ch] = get_bits1(gbc); + + /* dithering flags */ +- ctx->dither_all = 1; +- for (ch = 1; ch <= nfchans; ch++) { +- ctx->dithflag[ch] = get_bits1(gb); +- if(!ctx->dithflag[ch]) +- ctx->dither_all = 0; ++ s->dither_all = 1; ++ for (ch = 1; ch <= fbw_channels; ch++) { ++ s->dither_flag[ch] = get_bits1(gbc); ++ if(!s->dither_flag[ch]) ++ s->dither_all = 0; + } + + /* dynamic range */ +- i = !(ctx->acmod); ++ i = !(s->channel_mode); + do { +- if(get_bits1(gb)) { +- ctx->dynrng[i] = dynrng_tab[get_bits(gb, 8)]; ++ if(get_bits1(gbc)) { ++ s->dynamic_range[i] = ((dynamic_range_tab[get_bits(gbc, 8)]-1.0) * ++ s->avctx->drc_scale)+1.0; + } else if(blk == 0) { +- ctx->dynrng[i] = 1.0f; ++ s->dynamic_range[i] = 1.0f; + } + } while(i--); + + /* coupling strategy */ +- if (get_bits1(gb)) { ++ if (get_bits1(gbc)) { + memset(bit_alloc_stages, 3, AC3_MAX_CHANNELS); +- ctx->cplinu = get_bits1(gb); +- if (ctx->cplinu) { ++ s->cpl_in_use = get_bits1(gbc); ++ if (s->cpl_in_use) { + /* coupling in use */ +- int cplbegf, cplendf; ++ int cpl_begin_freq, cpl_end_freq; + + /* determine which channels are coupled */ +- for (ch = 1; ch <= nfchans; ch++) +- ctx->chincpl[ch] = get_bits1(gb); ++ for (ch = 1; ch <= fbw_channels; ch++) ++ s->channel_in_cpl[ch] = get_bits1(gbc); + + /* phase flags in use */ +- if (acmod == AC3_ACMOD_STEREO) +- ctx->phsflginu = get_bits1(gb); ++ if (channel_mode == AC3_CHMODE_STEREO) ++ s->phase_flags_in_use = get_bits1(gbc); + + /* coupling frequency range and band structure */ +- cplbegf = get_bits(gb, 4); +- cplendf = get_bits(gb, 4); +- if (3 + cplendf - cplbegf < 0) { +- av_log(ctx->avctx, AV_LOG_ERROR, "cplendf = %d < cplbegf = %d\n", cplendf, cplbegf); ++ cpl_begin_freq = get_bits(gbc, 4); ++ cpl_end_freq = get_bits(gbc, 4); ++ if (3 + cpl_end_freq - cpl_begin_freq < 0) { ++ av_log(s->avctx, AV_LOG_ERROR, "3+cplendf = %d < cplbegf = %d\n", 3+cpl_end_freq, cpl_begin_freq); + return -1; + } +- ctx->ncplbnd = ctx->ncplsubnd = 3 + cplendf - cplbegf; +- ctx->startmant[CPL_CH] = cplbegf * 12 + 37; +- ctx->endmant[CPL_CH] = cplendf * 12 + 73; +- for (bnd = 0; bnd < ctx->ncplsubnd - 1; bnd++) { +- if (get_bits1(gb)) { +- ctx->cplbndstrc[bnd] = 1; +- ctx->ncplbnd--; ++ s->num_cpl_bands = s->num_cpl_subbands = 3 + cpl_end_freq - cpl_begin_freq; ++ s->start_freq[CPL_CH] = cpl_begin_freq * 12 + 37; ++ s->end_freq[CPL_CH] = cpl_end_freq * 12 + 73; ++ for (bnd = 0; bnd < s->num_cpl_subbands - 1; bnd++) { ++ if (get_bits1(gbc)) { ++ s->cpl_band_struct[bnd] = 1; ++ s->num_cpl_bands--; + } + } ++ s->cpl_band_struct[s->num_cpl_subbands-1] = 0; + } else { + /* coupling not in use */ +- for (ch = 1; ch <= nfchans; ch++) +- ctx->chincpl[ch] = 0; ++ for (ch = 1; ch <= fbw_channels; ch++) ++ s->channel_in_cpl[ch] = 0; + } + } + + /* coupling coordinates */ +- if (ctx->cplinu) { +- int cplcoe = 0; ++ if (s->cpl_in_use) { ++ int cpl_coords_exist = 0; + +- for (ch = 1; ch <= nfchans; ch++) { +- if (ctx->chincpl[ch]) { +- if (get_bits1(gb)) { +- int mstrcplco, cplcoexp, cplcomant; +- cplcoe = 1; +- mstrcplco = 3 * get_bits(gb, 2); +- for (bnd = 0; bnd < ctx->ncplbnd; bnd++) { +- cplcoexp = get_bits(gb, 4); +- cplcomant = get_bits(gb, 4); +- if (cplcoexp == 15) +- ctx->cplco[ch][bnd] = cplcomant / 16.0f; ++ for (ch = 1; ch <= fbw_channels; ch++) { ++ if (s->channel_in_cpl[ch]) { ++ if (get_bits1(gbc)) { ++ int master_cpl_coord, cpl_coord_exp, cpl_coord_mant; ++ cpl_coords_exist = 1; ++ master_cpl_coord = 3 * get_bits(gbc, 2); ++ for (bnd = 0; bnd < s->num_cpl_bands; bnd++) { ++ cpl_coord_exp = get_bits(gbc, 4); ++ cpl_coord_mant = get_bits(gbc, 4); ++ if (cpl_coord_exp == 15) ++ s->cpl_coords[ch][bnd] = cpl_coord_mant / 16.0f; + else +- ctx->cplco[ch][bnd] = (cplcomant + 16.0f) / 32.0f; +- ctx->cplco[ch][bnd] *= scale_factors[cplcoexp + mstrcplco]; ++ s->cpl_coords[ch][bnd] = (cpl_coord_mant + 16.0f) / 32.0f; ++ s->cpl_coords[ch][bnd] *= scale_factors[cpl_coord_exp + master_cpl_coord]; + } + } + } + } + /* phase flags */ +- if (acmod == AC3_ACMOD_STEREO && ctx->phsflginu && cplcoe) { +- for (bnd = 0; bnd < ctx->ncplbnd; bnd++) { +- if (get_bits1(gb)) +- ctx->cplco[2][bnd] = -ctx->cplco[2][bnd]; ++ if (channel_mode == AC3_CHMODE_STEREO && cpl_coords_exist) { ++ for (bnd = 0; bnd < s->num_cpl_bands; bnd++) { ++ s->phase_flags[bnd] = s->phase_flags_in_use? get_bits1(gbc) : 0; + } + } + } + + /* stereo rematrixing strategy and band structure */ +- if (acmod == AC3_ACMOD_STEREO) { +- ctx->rematstr = get_bits1(gb); +- if (ctx->rematstr) { +- ctx->nrematbnd = 4; +- if(ctx->cplinu && ctx->startmant[CPL_CH] <= 61) +- ctx->nrematbnd -= 1 + (ctx->startmant[CPL_CH] == 37); +- for(bnd=0; bndnrematbnd; bnd++) +- ctx->rematflg[bnd] = get_bits1(gb); ++ if (channel_mode == AC3_CHMODE_STEREO) { ++ if (get_bits1(gbc)) { ++ s->num_rematrixing_bands = 4; ++ if(s->cpl_in_use && s->start_freq[CPL_CH] <= 61) ++ s->num_rematrixing_bands -= 1 + (s->start_freq[CPL_CH] == 37); ++ for(bnd=0; bndnum_rematrixing_bands; bnd++) ++ s->rematrixing_flags[bnd] = get_bits1(gbc); + } + } + + /* exponent strategies for each channel */ +- ctx->expstr[CPL_CH] = EXP_REUSE; +- ctx->expstr[ctx->lfe_ch] = EXP_REUSE; +- for (ch = !ctx->cplinu; ch <= ctx->nchans; ch++) { +- if(ch == ctx->lfe_ch) +- ctx->expstr[ch] = get_bits(gb, 1); ++ s->exp_strategy[CPL_CH] = EXP_REUSE; ++ s->exp_strategy[s->lfe_ch] = EXP_REUSE; ++ for (ch = !s->cpl_in_use; ch <= s->channels; ch++) { ++ if(ch == s->lfe_ch) ++ s->exp_strategy[ch] = get_bits(gbc, 1); + else +- ctx->expstr[ch] = get_bits(gb, 2); +- if(ctx->expstr[ch] != EXP_REUSE) ++ s->exp_strategy[ch] = get_bits(gbc, 2); ++ if(s->exp_strategy[ch] != EXP_REUSE) + bit_alloc_stages[ch] = 3; + } + + /* channel bandwidth */ +- for (ch = 1; ch <= nfchans; ch++) { +- ctx->startmant[ch] = 0; +- if (ctx->expstr[ch] != EXP_REUSE) { +- int prev = ctx->endmant[ch]; +- if (ctx->chincpl[ch]) +- ctx->endmant[ch] = ctx->startmant[CPL_CH]; ++ for (ch = 1; ch <= fbw_channels; ch++) { ++ s->start_freq[ch] = 0; ++ if (s->exp_strategy[ch] != EXP_REUSE) { ++ int prev = s->end_freq[ch]; ++ if (s->channel_in_cpl[ch]) ++ s->end_freq[ch] = s->start_freq[CPL_CH]; + else { +- int chbwcod = get_bits(gb, 6); +- if (chbwcod > 60) { +- av_log(ctx->avctx, AV_LOG_ERROR, "chbwcod = %d > 60", chbwcod); ++ int bandwidth_code = get_bits(gbc, 6); ++ if (bandwidth_code > 60) { ++ av_log(s->avctx, AV_LOG_ERROR, "bandwidth code = %d > 60", bandwidth_code); + return -1; + } +- ctx->endmant[ch] = chbwcod * 3 + 73; ++ s->end_freq[ch] = bandwidth_code * 3 + 73; + } +- if(blk > 0 && ctx->endmant[ch] != prev) ++ if(blk > 0 && s->end_freq[ch] != prev) + memset(bit_alloc_stages, 3, AC3_MAX_CHANNELS); + } + } +- ctx->startmant[ctx->lfe_ch] = 0; +- ctx->endmant[ctx->lfe_ch] = 7; ++ s->start_freq[s->lfe_ch] = 0; ++ s->end_freq[s->lfe_ch] = 7; + + /* decode exponents for each channel */ +- for (ch = !ctx->cplinu; ch <= ctx->nchans; ch++) { +- if (ctx->expstr[ch] != EXP_REUSE) { +- int grpsize, ngrps; +- grpsize = 3 << (ctx->expstr[ch] - 1); ++ for (ch = !s->cpl_in_use; ch <= s->channels; ch++) { ++ if (s->exp_strategy[ch] != EXP_REUSE) { ++ int group_size, num_groups; ++ group_size = 3 << (s->exp_strategy[ch] - 1); + if(ch == CPL_CH) +- ngrps = (ctx->endmant[ch] - ctx->startmant[ch]) / grpsize; +- else if(ch == ctx->lfe_ch) +- ngrps = 2; ++ num_groups = (s->end_freq[ch] - s->start_freq[ch]) / group_size; ++ else if(ch == s->lfe_ch) ++ num_groups = 2; + else +- ngrps = (ctx->endmant[ch] + grpsize - 4) / grpsize; +- ctx->dexps[ch][0] = get_bits(gb, 4) << !ch; +- decode_exponents(gb, ctx->expstr[ch], ngrps, ctx->dexps[ch][0], +- &ctx->dexps[ch][ctx->startmant[ch]+!!ch]); +- if(ch != CPL_CH && ch != ctx->lfe_ch) +- skip_bits(gb, 2); /* skip gainrng */ ++ num_groups = (s->end_freq[ch] + group_size - 4) / group_size; ++ s->dexps[ch][0] = get_bits(gbc, 4) << !ch; ++ decode_exponents(gbc, s->exp_strategy[ch], num_groups, s->dexps[ch][0], ++ &s->dexps[ch][s->start_freq[ch]+!!ch]); ++ if(ch != CPL_CH && ch != s->lfe_ch) ++ skip_bits(gbc, 2); /* skip gainrng */ + } + } + + /* bit allocation information */ +- if (get_bits1(gb)) { +- ctx->bit_alloc_params.sdecay = ff_sdecaytab[get_bits(gb, 2)] >> ctx->bit_alloc_params.halfratecod; +- ctx->bit_alloc_params.fdecay = ff_fdecaytab[get_bits(gb, 2)] >> ctx->bit_alloc_params.halfratecod; +- ctx->bit_alloc_params.sgain = ff_sgaintab[get_bits(gb, 2)]; +- ctx->bit_alloc_params.dbknee = ff_dbkneetab[get_bits(gb, 2)]; +- ctx->bit_alloc_params.floor = ff_floortab[get_bits(gb, 3)]; +- for(ch=!ctx->cplinu; ch<=ctx->nchans; ch++) { ++ if (get_bits1(gbc)) { ++ s->bit_alloc_params.slow_decay = ff_ac3_slow_decay_tab[get_bits(gbc, 2)] >> s->bit_alloc_params.sr_shift; ++ s->bit_alloc_params.fast_decay = ff_ac3_fast_decay_tab[get_bits(gbc, 2)] >> s->bit_alloc_params.sr_shift; ++ s->bit_alloc_params.slow_gain = ff_ac3_slow_gain_tab[get_bits(gbc, 2)]; ++ s->bit_alloc_params.db_per_bit = ff_ac3_db_per_bit_tab[get_bits(gbc, 2)]; ++ s->bit_alloc_params.floor = ff_ac3_floor_tab[get_bits(gbc, 3)]; ++ for(ch=!s->cpl_in_use; ch<=s->channels; ch++) { + bit_alloc_stages[ch] = FFMAX(bit_alloc_stages[ch], 2); + } + } + + /* signal-to-noise ratio offsets and fast gains (signal-to-mask ratios) */ +- if (get_bits1(gb)) { ++ if (get_bits1(gbc)) { + int csnr; +- csnr = (get_bits(gb, 6) - 15) << 4; +- for (ch = !ctx->cplinu; ch <= ctx->nchans; ch++) { /* snr offset and fast gain */ +- ctx->snroffst[ch] = (csnr + get_bits(gb, 4)) << 2; +- ctx->fgain[ch] = ff_fgaintab[get_bits(gb, 3)]; ++ csnr = (get_bits(gbc, 6) - 15) << 4; ++ for (ch = !s->cpl_in_use; ch <= s->channels; ch++) { /* snr offset and fast gain */ ++ s->snr_offset[ch] = (csnr + get_bits(gbc, 4)) << 2; ++ s->fast_gain[ch] = ff_ac3_fast_gain_tab[get_bits(gbc, 3)]; + } + memset(bit_alloc_stages, 3, AC3_MAX_CHANNELS); + } + + /* coupling leak information */ +- if (ctx->cplinu && get_bits1(gb)) { +- ctx->bit_alloc_params.cplfleak = get_bits(gb, 3); +- ctx->bit_alloc_params.cplsleak = get_bits(gb, 3); ++ if (s->cpl_in_use && get_bits1(gbc)) { ++ s->bit_alloc_params.cpl_fast_leak = get_bits(gbc, 3); ++ s->bit_alloc_params.cpl_slow_leak = get_bits(gbc, 3); + bit_alloc_stages[CPL_CH] = FFMAX(bit_alloc_stages[CPL_CH], 2); + } + + /* delta bit allocation information */ +- if (get_bits1(gb)) { ++ if (get_bits1(gbc)) { + /* delta bit allocation exists (strategy) */ +- for (ch = !ctx->cplinu; ch <= nfchans; ch++) { +- ctx->deltbae[ch] = get_bits(gb, 2); +- if (ctx->deltbae[ch] == DBA_RESERVED) { +- av_log(ctx->avctx, AV_LOG_ERROR, "delta bit allocation strategy reserved\n"); ++ for (ch = !s->cpl_in_use; ch <= fbw_channels; ch++) { ++ s->dba_mode[ch] = get_bits(gbc, 2); ++ if (s->dba_mode[ch] == DBA_RESERVED) { ++ av_log(s->avctx, AV_LOG_ERROR, "delta bit allocation strategy reserved\n"); + return -1; + } + bit_alloc_stages[ch] = FFMAX(bit_alloc_stages[ch], 2); + } + /* channel delta offset, len and bit allocation */ +- for (ch = !ctx->cplinu; ch <= nfchans; ch++) { +- if (ctx->deltbae[ch] == DBA_NEW) { +- ctx->deltnseg[ch] = get_bits(gb, 3); +- for (seg = 0; seg <= ctx->deltnseg[ch]; seg++) { +- ctx->deltoffst[ch][seg] = get_bits(gb, 5); +- ctx->deltlen[ch][seg] = get_bits(gb, 4); +- ctx->deltba[ch][seg] = get_bits(gb, 3); ++ for (ch = !s->cpl_in_use; ch <= fbw_channels; ch++) { ++ if (s->dba_mode[ch] == DBA_NEW) { ++ s->dba_nsegs[ch] = get_bits(gbc, 3); ++ for (seg = 0; seg <= s->dba_nsegs[ch]; seg++) { ++ s->dba_offsets[ch][seg] = get_bits(gbc, 5); ++ s->dba_lengths[ch][seg] = get_bits(gbc, 4); ++ s->dba_values[ch][seg] = get_bits(gbc, 3); + } + } + } + } else if(blk == 0) { +- for(ch=0; ch<=ctx->nchans; ch++) { +- ctx->deltbae[ch] = DBA_NONE; ++ for(ch=0; ch<=s->channels; ch++) { ++ s->dba_mode[ch] = DBA_NONE; + } + } + + /* Bit allocation */ +- for(ch=!ctx->cplinu; ch<=ctx->nchans; ch++) { ++ for(ch=!s->cpl_in_use; ch<=s->channels; ch++) { + if(bit_alloc_stages[ch] > 2) { + /* Exponent mapping into PSD and PSD integration */ +- ff_ac3_bit_alloc_calc_psd(ctx->dexps[ch], +- ctx->startmant[ch], ctx->endmant[ch], +- ctx->psd[ch], ctx->bndpsd[ch]); ++ ff_ac3_bit_alloc_calc_psd(s->dexps[ch], ++ s->start_freq[ch], s->end_freq[ch], ++ s->psd[ch], s->band_psd[ch]); + } + if(bit_alloc_stages[ch] > 1) { + /* Compute excitation function, Compute masking curve, and + Apply delta bit allocation */ +- ff_ac3_bit_alloc_calc_mask(&ctx->bit_alloc_params, ctx->bndpsd[ch], +- ctx->startmant[ch], ctx->endmant[ch], +- ctx->fgain[ch], (ch == ctx->lfe_ch), +- ctx->deltbae[ch], ctx->deltnseg[ch], +- ctx->deltoffst[ch], ctx->deltlen[ch], +- ctx->deltba[ch], ctx->mask[ch]); ++ ff_ac3_bit_alloc_calc_mask(&s->bit_alloc_params, s->band_psd[ch], ++ s->start_freq[ch], s->end_freq[ch], ++ s->fast_gain[ch], (ch == s->lfe_ch), ++ s->dba_mode[ch], s->dba_nsegs[ch], ++ s->dba_offsets[ch], s->dba_lengths[ch], ++ s->dba_values[ch], s->mask[ch]); + } + if(bit_alloc_stages[ch] > 0) { + /* Compute bit allocation */ +- ff_ac3_bit_alloc_calc_bap(ctx->mask[ch], ctx->psd[ch], +- ctx->startmant[ch], ctx->endmant[ch], +- ctx->snroffst[ch], +- ctx->bit_alloc_params.floor, +- ctx->bap[ch]); ++ ff_ac3_bit_alloc_calc_bap(s->mask[ch], s->psd[ch], ++ s->start_freq[ch], s->end_freq[ch], ++ s->snr_offset[ch], ++ s->bit_alloc_params.floor, ++ s->bap[ch]); + } + } + + /* unused dummy data */ +- if (get_bits1(gb)) { +- int skipl = get_bits(gb, 9); ++ if (get_bits1(gbc)) { ++ int skipl = get_bits(gbc, 9); + while(skipl--) +- skip_bits(gb, 8); ++ skip_bits(gbc, 8); + } + + /* unpack the transform coefficients + this also uncouples channels if coupling is in use. */ +- if (get_transform_coeffs(ctx)) { +- av_log(ctx->avctx, AV_LOG_ERROR, "Error in routine get_transform_coeffs\n"); ++ if (get_transform_coeffs(s)) { ++ av_log(s->avctx, AV_LOG_ERROR, "Error in routine get_transform_coeffs\n"); + return -1; + } + + /* recover coefficients if rematrixing is in use */ +- if(ctx->acmod == AC3_ACMOD_STEREO) +- do_rematrixing(ctx); ++ if(s->channel_mode == AC3_CHMODE_STEREO) ++ do_rematrixing(s); + +- /* apply scaling to coefficients (headroom, dialnorm, dynrng) */ +- for(ch=1; ch<=ctx->nchans; ch++) { +- float gain = 2.0f * ctx->mul_bias; +- if(ctx->acmod == AC3_ACMOD_DUALMONO) { +- gain *= ctx->dialnorm[ch-1] * ctx->dynrng[ch-1]; ++ /* apply scaling to coefficients (headroom, dynrng) */ ++ for(ch=1; ch<=s->channels; ch++) { ++ float gain = 2.0f * s->mul_bias; ++ if(s->channel_mode == AC3_CHMODE_DUALMONO) { ++ gain *= s->dynamic_range[ch-1]; + } else { +- gain *= ctx->dialnorm[0] * ctx->dynrng[0]; ++ gain *= s->dynamic_range[0]; + } +- for(i=0; iendmant[ch]; i++) { +- ctx->transform_coeffs[ch][i] *= gain; ++ for(i=0; iend_freq[ch]; i++) { ++ s->transform_coeffs[ch][i] *= gain; + } + } + +- do_imdct(ctx); ++ do_imdct(s); + + /* downmix output if needed */ +- if(ctx->nchans != ctx->out_channels && !((ctx->output_mode & AC3_OUTPUT_LFEON) && +- ctx->nfchans == ctx->out_channels)) { +- ac3_downmix(ctx->output, ctx->nfchans, ctx->output_mode, +- ctx->downmix_coeffs); ++ if(s->channels != s->out_channels && !((s->output_mode & AC3_OUTPUT_LFEON) && ++ s->fbw_channels == s->out_channels)) { ++ ac3_downmix(s); + } + + /* convert float to 16-bit integer */ +- for(ch=0; chout_channels; ch++) { ++ for(ch=0; chout_channels; ch++) { + for(i=0; i<256; i++) { +- ctx->output[ch][i] += ctx->add_bias; ++ s->output[ch][i] += s->add_bias; + } +- ctx->dsp.float_to_int16(ctx->int_output[ch], ctx->output[ch], 256); ++ s->dsp.float_to_int16(s->int_output[ch], s->output[ch], 256); + } + + return 0; +@@ -1087,15 +1072,15 @@ + */ + static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size, uint8_t *buf, int buf_size) + { +- AC3DecodeContext *ctx = (AC3DecodeContext *)avctx->priv_data; ++ AC3DecodeContext *s = avctx->priv_data; + int16_t *out_samples = (int16_t *)data; + int i, blk, ch, err; + + /* initialize the GetBitContext with the start of valid AC-3 Frame */ +- init_get_bits(&ctx->gb, buf, buf_size * 8); ++ init_get_bits(&s->gbc, buf, buf_size * 8); + + /* parse the syncinfo */ +- err = ac3_parse_header(ctx); ++ err = ac3_parse_header(s); + if(err) { + switch(err) { + case AC3_PARSE_ERROR_SYNC: +@@ -1117,48 +1102,52 @@ + return -1; + } + +- avctx->sample_rate = ctx->sampling_rate; +- avctx->bit_rate = ctx->bit_rate; +- + /* check that reported frame size fits in input buffer */ +- if(ctx->frame_size > buf_size) { ++ if(s->frame_size > buf_size) { + av_log(avctx, AV_LOG_ERROR, "incomplete frame\n"); + return -1; + } + +- /* channel config */ +- ctx->out_channels = ctx->nchans; +- if (avctx->channels == 0) { +- avctx->channels = ctx->out_channels; +- } else if(ctx->out_channels < avctx->channels) { +- av_log(avctx, AV_LOG_ERROR, "Cannot upmix AC3 from %d to %d channels.\n", +- ctx->out_channels, avctx->channels); +- return -1; ++ /* check for crc mismatch */ ++ if(avctx->error_resilience >= FF_ER_CAREFUL) { ++ if(av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, &buf[2], s->frame_size-2)) { ++ av_log(avctx, AV_LOG_ERROR, "frame CRC mismatch\n"); ++ return -1; ++ } ++ /* TODO: error concealment */ + } +- if(avctx->channels == 2) { +- ctx->output_mode = AC3_ACMOD_STEREO; +- } else if(avctx->channels == 1) { +- ctx->output_mode = AC3_ACMOD_MONO; +- } else if(avctx->channels != ctx->out_channels) { +- av_log(avctx, AV_LOG_ERROR, "Cannot downmix AC3 from %d to %d channels.\n", +- ctx->out_channels, avctx->channels); +- return -1; ++ ++ avctx->sample_rate = s->sample_rate; ++ avctx->bit_rate = s->bit_rate; ++ ++ /* channel config */ ++ s->out_channels = s->channels; ++ if (avctx->request_channels > 0 && avctx->request_channels <= 2 && ++ avctx->request_channels < s->channels) { ++ s->out_channels = avctx->request_channels; ++ s->output_mode = avctx->request_channels == 1 ? AC3_CHMODE_MONO : AC3_CHMODE_STEREO; ++ } ++ avctx->channels = s->out_channels; ++ ++ /* set downmixing coefficients if needed */ ++ if(s->channels != s->out_channels && !((s->output_mode & AC3_OUTPUT_LFEON) && ++ s->fbw_channels == s->out_channels)) { ++ set_downmix_coeffs(s); + } +- ctx->out_channels = avctx->channels; + + /* parse the audio blocks */ + for (blk = 0; blk < NB_BLOCKS; blk++) { +- if (ac3_parse_audio_block(ctx, blk)) { ++ if (ac3_parse_audio_block(s, blk)) { + av_log(avctx, AV_LOG_ERROR, "error parsing the audio block\n"); + *data_size = 0; +- return ctx->frame_size; ++ return s->frame_size; + } + for (i = 0; i < 256; i++) +- for (ch = 0; ch < ctx->out_channels; ch++) +- *(out_samples++) = ctx->int_output[ch][i]; ++ for (ch = 0; ch < s->out_channels; ch++) ++ *(out_samples++) = s->int_output[ch][i]; + } + *data_size = NB_BLOCKS * 256 * avctx->channels * sizeof (int16_t); +- return ctx->frame_size; ++ return s->frame_size; + } + + /** +@@ -1166,9 +1155,9 @@ + */ + static int ac3_decode_end(AVCodecContext *avctx) + { +- AC3DecodeContext *ctx = (AC3DecodeContext *)avctx->priv_data; +- ff_mdct_end(&ctx->imdct_512); +- ff_mdct_end(&ctx->imdct_256); ++ AC3DecodeContext *s = avctx->priv_data; ++ ff_mdct_end(&s->imdct_512); ++ ff_mdct_end(&s->imdct_256); + + return 0; + } +diff -u mplayer-1.0~rc2-12/libavcodec/ac3enc.c ffmpeg-free-0.svn20080206/libavcodec/ac3enc.c +--- mplayer-1.0~rc2-12/libavcodec/ac3enc.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/ac3enc.c 2008-03-20 19:10:57.000000000 +0100 +@@ -37,34 +37,33 @@ + int lfe_channel; + int bit_rate; + unsigned int sample_rate; +- unsigned int bsid; ++ unsigned int bitstream_id; + unsigned int frame_size_min; /* minimum frame size in case rounding is necessary */ + unsigned int frame_size; /* current frame size in words */ + unsigned int bits_written; + unsigned int samples_written; +- int halfratecod; +- unsigned int frmsizecod; +- unsigned int fscod; /* frequency */ +- unsigned int acmod; ++ int sr_shift; ++ unsigned int frame_size_code; ++ unsigned int sr_code; /* frequency */ ++ unsigned int channel_mode; + int lfe; +- unsigned int bsmod; ++ unsigned int bitstream_mode; + short last_samples[AC3_MAX_CHANNELS][256]; + unsigned int chbwcod[AC3_MAX_CHANNELS]; + int nb_coefs[AC3_MAX_CHANNELS]; + + /* bitrate allocation control */ +- int sgaincod, sdecaycod, fdecaycod, dbkneecod, floorcod; ++ int slow_gain_code, slow_decay_code, fast_decay_code, db_per_bit_code, floor_code; + AC3BitAllocParameters bit_alloc; +- int csnroffst; +- int fgaincod[AC3_MAX_CHANNELS]; +- int fsnroffst[AC3_MAX_CHANNELS]; ++ int coarse_snr_offset; ++ int fast_gain_code[AC3_MAX_CHANNELS]; ++ int fine_snr_offset[AC3_MAX_CHANNELS]; + /* mantissa encoding */ + int mant1_cnt, mant2_cnt, mant4_cnt; + } AC3EncodeContext; + + static int16_t costab[64]; + static int16_t sintab[64]; +-static int16_t fft_rev[512]; + static int16_t xcos1[128]; + static int16_t xsin1[128]; + +@@ -74,8 +73,6 @@ + /* new exponents are sent if their Norm 1 exceed this number */ + #define EXP_DIFF_THRESHOLD 1000 + +-static void fft_init(int ln); +- + static inline int16_t fix15(float a) + { + int v; +@@ -93,7 +90,7 @@ + + static void fft_init(int ln) + { +- int i, j, m, n; ++ int i, n; + float alpha; + + n = 1 << ln; +@@ -103,14 +100,6 @@ + costab[i] = fix15(cos(alpha)); + sintab[i] = fix15(sin(alpha)); + } +- +- for(i=0;i> j) & 1) << (ln-j-1); +- } +- fft_rev[i]=m; +- } + } + + /* butter fly op */ +@@ -148,14 +137,9 @@ + + /* reverse */ + for(j=0;j> (8 - ln); ++ if (k < j) ++ FFSWAP(IComplex, z[k], z[j]); + } + + /* pass 0 */ +@@ -438,7 +422,7 @@ + int16_t mask[NB_BLOCKS][AC3_MAX_CHANNELS][50]) + { + int blk, ch; +- int16_t bndpsd[NB_BLOCKS][AC3_MAX_CHANNELS][50]; ++ int16_t band_psd[NB_BLOCKS][AC3_MAX_CHANNELS][50]; + + for(blk=0; blknb_all_channels;ch++) { +@@ -448,10 +432,10 @@ + } else { + ff_ac3_bit_alloc_calc_psd(encoded_exp[blk][ch], 0, + s->nb_coefs[ch], +- psd[blk][ch], bndpsd[blk][ch]); +- ff_ac3_bit_alloc_calc_mask(&s->bit_alloc, bndpsd[blk][ch], ++ psd[blk][ch], band_psd[blk][ch]); ++ ff_ac3_bit_alloc_calc_mask(&s->bit_alloc, band_psd[blk][ch], + 0, s->nb_coefs[ch], +- ff_fgaintab[s->fgaincod[ch]], ++ ff_ac3_fast_gain_tab[s->fast_gain_code[ch]], + ch == s->lfe_channel, + DBA_NONE, 0, NULL, NULL, NULL, + mask[blk][ch]); +@@ -464,12 +448,12 @@ + int16_t mask[NB_BLOCKS][AC3_MAX_CHANNELS][50], + int16_t psd[NB_BLOCKS][AC3_MAX_CHANNELS][N/2], + uint8_t bap[NB_BLOCKS][AC3_MAX_CHANNELS][N/2], +- int frame_bits, int csnroffst, int fsnroffst) ++ int frame_bits, int coarse_snr_offset, int fine_snr_offset) + { + int i, ch; +- int snroffset; ++ int snr_offset; + +- snroffset = (((csnroffst - 15) << 4) + fsnroffst) << 2; ++ snr_offset = (((coarse_snr_offset - 15) << 4) + fine_snr_offset) << 2; + + /* compute size */ + for(i=0;imant4_cnt = 0; + for(ch=0;chnb_all_channels;ch++) { + ff_ac3_bit_alloc_calc_bap(mask[i][ch], psd[i][ch], 0, +- s->nb_coefs[ch], snroffset, ++ s->nb_coefs[ch], snr_offset, + s->bit_alloc.floor, bap[i][ch]); + frame_bits += compute_mantissa_size(s, bap[i][ch], + s->nb_coefs[ch]); +@@ -486,7 +470,7 @@ + } + #if 0 + printf("csnr=%d fsnr=%d frame_bits=%d diff=%d\n", +- csnroffst, fsnroffst, frame_bits, ++ coarse_snr_offset, fine_snr_offset, frame_bits, + 16 * s->frame_size - ((frame_bits + 7) & ~7)); + #endif + return 16 * s->frame_size - frame_bits; +@@ -501,40 +485,40 @@ + int frame_bits) + { + int i, ch; +- int csnroffst, fsnroffst; ++ int coarse_snr_offset, fine_snr_offset; + uint8_t bap1[NB_BLOCKS][AC3_MAX_CHANNELS][N/2]; + int16_t psd[NB_BLOCKS][AC3_MAX_CHANNELS][N/2]; + int16_t mask[NB_BLOCKS][AC3_MAX_CHANNELS][50]; + static int frame_bits_inc[8] = { 0, 0, 2, 2, 2, 4, 2, 4 }; + + /* init default parameters */ +- s->sdecaycod = 2; +- s->fdecaycod = 1; +- s->sgaincod = 1; +- s->dbkneecod = 2; +- s->floorcod = 4; ++ s->slow_decay_code = 2; ++ s->fast_decay_code = 1; ++ s->slow_gain_code = 1; ++ s->db_per_bit_code = 2; ++ s->floor_code = 4; + for(ch=0;chnb_all_channels;ch++) +- s->fgaincod[ch] = 4; ++ s->fast_gain_code[ch] = 4; + + /* compute real values */ +- s->bit_alloc.fscod = s->fscod; +- s->bit_alloc.halfratecod = s->halfratecod; +- s->bit_alloc.sdecay = ff_sdecaytab[s->sdecaycod] >> s->halfratecod; +- s->bit_alloc.fdecay = ff_fdecaytab[s->fdecaycod] >> s->halfratecod; +- s->bit_alloc.sgain = ff_sgaintab[s->sgaincod]; +- s->bit_alloc.dbknee = ff_dbkneetab[s->dbkneecod]; +- s->bit_alloc.floor = ff_floortab[s->floorcod]; ++ s->bit_alloc.sr_code = s->sr_code; ++ s->bit_alloc.sr_shift = s->sr_shift; ++ s->bit_alloc.slow_decay = ff_ac3_slow_decay_tab[s->slow_decay_code] >> s->sr_shift; ++ s->bit_alloc.fast_decay = ff_ac3_fast_decay_tab[s->fast_decay_code] >> s->sr_shift; ++ s->bit_alloc.slow_gain = ff_ac3_slow_gain_tab[s->slow_gain_code]; ++ s->bit_alloc.db_per_bit = ff_ac3_db_per_bit_tab[s->db_per_bit_code]; ++ s->bit_alloc.floor = ff_ac3_floor_tab[s->floor_code]; + + /* header size */ + frame_bits += 65; +- // if (s->acmod == 2) ++ // if (s->channel_mode == 2) + // frame_bits += 2; +- frame_bits += frame_bits_inc[s->acmod]; ++ frame_bits += frame_bits_inc[s->channel_mode]; + + /* audio blocks */ + for(i=0;inb_channels * 2 + 2; /* blksw * c, dithflag * c, dynrnge, cplstre */ +- if (s->acmod == AC3_ACMOD_STEREO) { ++ if (s->channel_mode == AC3_CHMODE_STEREO) { + frame_bits++; /* rematstr */ + if(i==0) frame_bits += 4; + } +@@ -568,43 +552,43 @@ + /* now the big work begins : do the bit allocation. Modify the snr + offset until we can pack everything in the requested frame size */ + +- csnroffst = s->csnroffst; +- while (csnroffst >= 0 && +- bit_alloc(s, mask, psd, bap, frame_bits, csnroffst, 0) < 0) +- csnroffst -= SNR_INC1; +- if (csnroffst < 0) { +- av_log(NULL, AV_LOG_ERROR, "Bit allocation failed, try increasing the bitrate, -ab 384 for example!\n"); ++ coarse_snr_offset = s->coarse_snr_offset; ++ while (coarse_snr_offset >= 0 && ++ bit_alloc(s, mask, psd, bap, frame_bits, coarse_snr_offset, 0) < 0) ++ coarse_snr_offset -= SNR_INC1; ++ if (coarse_snr_offset < 0) { ++ av_log(NULL, AV_LOG_ERROR, "Bit allocation failed. Try increasing the bitrate.\n"); + return -1; + } +- while ((csnroffst + SNR_INC1) <= 63 && ++ while ((coarse_snr_offset + SNR_INC1) <= 63 && + bit_alloc(s, mask, psd, bap1, frame_bits, +- csnroffst + SNR_INC1, 0) >= 0) { +- csnroffst += SNR_INC1; ++ coarse_snr_offset + SNR_INC1, 0) >= 0) { ++ coarse_snr_offset += SNR_INC1; + memcpy(bap, bap1, sizeof(bap1)); + } +- while ((csnroffst + 1) <= 63 && +- bit_alloc(s, mask, psd, bap1, frame_bits, csnroffst + 1, 0) >= 0) { +- csnroffst++; ++ while ((coarse_snr_offset + 1) <= 63 && ++ bit_alloc(s, mask, psd, bap1, frame_bits, coarse_snr_offset + 1, 0) >= 0) { ++ coarse_snr_offset++; + memcpy(bap, bap1, sizeof(bap1)); + } + +- fsnroffst = 0; +- while ((fsnroffst + SNR_INC1) <= 15 && ++ fine_snr_offset = 0; ++ while ((fine_snr_offset + SNR_INC1) <= 15 && + bit_alloc(s, mask, psd, bap1, frame_bits, +- csnroffst, fsnroffst + SNR_INC1) >= 0) { +- fsnroffst += SNR_INC1; ++ coarse_snr_offset, fine_snr_offset + SNR_INC1) >= 0) { ++ fine_snr_offset += SNR_INC1; + memcpy(bap, bap1, sizeof(bap1)); + } +- while ((fsnroffst + 1) <= 15 && ++ while ((fine_snr_offset + 1) <= 15 && + bit_alloc(s, mask, psd, bap1, frame_bits, +- csnroffst, fsnroffst + 1) >= 0) { +- fsnroffst++; ++ coarse_snr_offset, fine_snr_offset + 1) >= 0) { ++ fine_snr_offset++; + memcpy(bap, bap1, sizeof(bap1)); + } + +- s->csnroffst = csnroffst; ++ s->coarse_snr_offset = coarse_snr_offset; + for(ch=0;chnb_all_channels;ch++) +- s->fsnroffst[ch] = fsnroffst; ++ s->fine_snr_offset[ch] = fine_snr_offset; + #if defined(DEBUG_BITALLOC) + { + int j; +@@ -632,7 +616,8 @@ + AC3EncodeContext *s = avctx->priv_data; + int i, j, ch; + float alpha; +- static const uint8_t acmod_defs[6] = { ++ int bw_code; ++ static const uint8_t channel_mode_defs[6] = { + 0x01, /* C */ + 0x02, /* L R */ + 0x03, /* L C R */ +@@ -648,7 +633,7 @@ + /* number of channels */ + if (channels < 1 || channels > 6) + return -1; +- s->acmod = acmod_defs[channels - 1]; ++ s->channel_mode = channel_mode_defs[channels - 1]; + s->lfe = (channels == 6) ? 1 : 0; + s->nb_all_channels = channels; + s->nb_channels = channels > 5 ? 5 : channels; +@@ -657,45 +642,53 @@ + /* frequency */ + for(i=0;i<3;i++) { + for(j=0;j<3;j++) +- if ((ff_ac3_freqs[j] >> i) == freq) ++ if ((ff_ac3_sample_rate_tab[j] >> i) == freq) + goto found; + } + return -1; + found: + s->sample_rate = freq; +- s->halfratecod = i; +- s->fscod = j; +- s->bsid = 8 + s->halfratecod; +- s->bsmod = 0; /* complete main audio service */ ++ s->sr_shift = i; ++ s->sr_code = j; ++ s->bitstream_id = 8 + s->sr_shift; ++ s->bitstream_mode = 0; /* complete main audio service */ + + /* bitrate & frame size */ +- bitrate /= 1000; + for(i=0;i<19;i++) { +- if ((ff_ac3_bitratetab[i] >> s->halfratecod) == bitrate) ++ if ((ff_ac3_bitrate_tab[i] >> s->sr_shift)*1000 == bitrate) + break; + } + if (i == 19) + return -1; + s->bit_rate = bitrate; +- s->frmsizecod = i << 1; +- s->frame_size_min = ff_ac3_frame_sizes[s->frmsizecod][s->fscod]; ++ s->frame_size_code = i << 1; ++ s->frame_size_min = ff_ac3_frame_size_tab[s->frame_size_code][s->sr_code]; + s->bits_written = 0; + s->samples_written = 0; + s->frame_size = s->frame_size_min; + + /* bit allocation init */ +- for(ch=0;chnb_channels;ch++) { +- /* bandwidth for each channel */ ++ if(avctx->cutoff) { ++ /* calculate bandwidth based on user-specified cutoff frequency */ ++ int cutoff = av_clip(avctx->cutoff, 1, s->sample_rate >> 1); ++ int fbw_coeffs = cutoff * 512 / s->sample_rate; ++ bw_code = av_clip((fbw_coeffs - 73) / 3, 0, 60); ++ } else { ++ /* use default bandwidth setting */ + /* XXX: should compute the bandwidth according to the frame + size, so that we avoid anoying high freq artefacts */ +- s->chbwcod[ch] = 50; /* sample bandwidth as mpeg audio layer 2 table 0 */ +- s->nb_coefs[ch] = ((s->chbwcod[ch] + 12) * 3) + 37; ++ bw_code = 50; ++ } ++ for(ch=0;chnb_channels;ch++) { ++ /* bandwidth for each channel */ ++ s->chbwcod[ch] = bw_code; ++ s->nb_coefs[ch] = bw_code * 3 + 73; + } + if (s->lfe) { + s->nb_coefs[s->lfe_channel] = 7; /* fixed */ + } + /* initial snr offset */ +- s->csnroffst = 40; ++ s->coarse_snr_offset = 40; + + /* mdct init */ + fft_init(MDCT_NBITS - 2); +@@ -718,16 +711,16 @@ + + put_bits(&s->pb, 16, 0x0b77); /* frame header */ + put_bits(&s->pb, 16, 0); /* crc1: will be filled later */ +- put_bits(&s->pb, 2, s->fscod); +- put_bits(&s->pb, 6, s->frmsizecod + (s->frame_size - s->frame_size_min)); +- put_bits(&s->pb, 5, s->bsid); +- put_bits(&s->pb, 3, s->bsmod); +- put_bits(&s->pb, 3, s->acmod); +- if ((s->acmod & 0x01) && s->acmod != AC3_ACMOD_MONO) ++ put_bits(&s->pb, 2, s->sr_code); ++ put_bits(&s->pb, 6, s->frame_size_code + (s->frame_size - s->frame_size_min)); ++ put_bits(&s->pb, 5, s->bitstream_id); ++ put_bits(&s->pb, 3, s->bitstream_mode); ++ put_bits(&s->pb, 3, s->channel_mode); ++ if ((s->channel_mode & 0x01) && s->channel_mode != AC3_CHMODE_MONO) + put_bits(&s->pb, 2, 1); /* XXX -4.5 dB */ +- if (s->acmod & 0x04) ++ if (s->channel_mode & 0x04) + put_bits(&s->pb, 2, 1); /* XXX -6 dB */ +- if (s->acmod == AC3_ACMOD_STEREO) ++ if (s->channel_mode == AC3_CHMODE_STEREO) + put_bits(&s->pb, 2, 0); /* surround not indicated */ + put_bits(&s->pb, 1, s->lfe); /* LFE */ + put_bits(&s->pb, 5, 31); /* dialog norm: -31 db */ +@@ -738,7 +731,7 @@ + put_bits(&s->pb, 1, 1); /* original bitstream */ + put_bits(&s->pb, 1, 0); /* no time code 1 */ + put_bits(&s->pb, 1, 0); /* no time code 2 */ +- put_bits(&s->pb, 1, 0); /* no addtional bit stream info */ ++ put_bits(&s->pb, 1, 0); /* no additional bit stream info */ + } + + /* symetric quantization on 'levels' levels */ +@@ -810,7 +803,7 @@ + put_bits(&s->pb, 1, 0); /* no new coupling strategy */ + } + +- if (s->acmod == AC3_ACMOD_STEREO) ++ if (s->channel_mode == AC3_CHMODE_STEREO) + { + if(block_num==0) + { +@@ -900,20 +893,20 @@ + baie = (block_num == 0); + put_bits(&s->pb, 1, baie); + if (baie) { +- put_bits(&s->pb, 2, s->sdecaycod); +- put_bits(&s->pb, 2, s->fdecaycod); +- put_bits(&s->pb, 2, s->sgaincod); +- put_bits(&s->pb, 2, s->dbkneecod); +- put_bits(&s->pb, 3, s->floorcod); ++ put_bits(&s->pb, 2, s->slow_decay_code); ++ put_bits(&s->pb, 2, s->fast_decay_code); ++ put_bits(&s->pb, 2, s->slow_gain_code); ++ put_bits(&s->pb, 2, s->db_per_bit_code); ++ put_bits(&s->pb, 3, s->floor_code); + } + + /* snr offset */ + put_bits(&s->pb, 1, baie); /* always present with bai */ + if (baie) { +- put_bits(&s->pb, 6, s->csnroffst); ++ put_bits(&s->pb, 6, s->coarse_snr_offset); + for(ch=0;chnb_all_channels;ch++) { +- put_bits(&s->pb, 4, s->fsnroffst[ch]); +- put_bits(&s->pb, 3, s->fgaincod[ch]); ++ put_bits(&s->pb, 4, s->fine_snr_offset[ch]); ++ put_bits(&s->pb, 3, s->fast_gain_code[ch]); + } + } + +@@ -1132,13 +1125,16 @@ + /* Now we must compute both crcs : this is not so easy for crc1 + because it is at the beginning of the data... */ + frame_size_58 = (frame_size >> 1) + (frame_size >> 3); +- crc1 = bswap_16(av_crc(av_crc8005, 0, frame + 4, 2 * frame_size_58 - 4)); ++ crc1 = bswap_16(av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, ++ frame + 4, 2 * frame_size_58 - 4)); + /* XXX: could precompute crc_inv */ + crc_inv = pow_poly((CRC16_POLY >> 1), (16 * frame_size_58) - 16, CRC16_POLY); + crc1 = mul_poly(crc_inv, crc1, CRC16_POLY); + AV_WB16(frame+2,crc1); + +- crc2 = bswap_16(av_crc(av_crc8005, 0, frame + 2 * frame_size_58, (frame_size - frame_size_58) * 2 - 2)); ++ crc2 = bswap_16(av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, ++ frame + 2 * frame_size_58, ++ (frame_size - frame_size_58) * 2 - 2)); + AV_WB16(frame+2*frame_size-2,crc2); + + // printf("n=%d frame_size=%d\n", n, frame_size); +@@ -1240,11 +1236,11 @@ + } + + /* adjust for fractional frame sizes */ +- while(s->bits_written >= s->bit_rate*1000 && s->samples_written >= s->sample_rate) { +- s->bits_written -= s->bit_rate*1000; ++ while(s->bits_written >= s->bit_rate && s->samples_written >= s->sample_rate) { ++ s->bits_written -= s->bit_rate; + s->samples_written -= s->sample_rate; + } +- s->frame_size = s->frame_size_min + (s->bits_written * s->sample_rate < s->samples_written * s->bit_rate*1000); ++ s->frame_size = s->frame_size_min + (s->bits_written * s->sample_rate < s->samples_written * s->bit_rate); + s->bits_written += s->frame_size * 16; + s->samples_written += AC3_FRAME_SIZE; + +diff -u mplayer-1.0~rc2-12/libavcodec/ac3.h ffmpeg-free-0.svn20080206/libavcodec/ac3.h +--- mplayer-1.0~rc2-12/libavcodec/ac3.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/ac3.h 2008-01-05 18:04:57.000000000 +0100 +@@ -24,8 +24,8 @@ + * Common code between AC3 encoder and decoder. + */ + +-#ifndef AC3_H +-#define AC3_H ++#ifndef FFMPEG_AC3_H ++#define FFMPEG_AC3_H + + #include "ac3tab.h" + +@@ -53,21 +53,21 @@ + + /** Channel mode (audio coding mode) */ + typedef enum { +- AC3_ACMOD_DUALMONO = 0, +- AC3_ACMOD_MONO, +- AC3_ACMOD_STEREO, +- AC3_ACMOD_3F, +- AC3_ACMOD_2F1R, +- AC3_ACMOD_3F1R, +- AC3_ACMOD_2F2R, +- AC3_ACMOD_3F2R ++ AC3_CHMODE_DUALMONO = 0, ++ AC3_CHMODE_MONO, ++ AC3_CHMODE_STEREO, ++ AC3_CHMODE_3F, ++ AC3_CHMODE_2F1R, ++ AC3_CHMODE_3F1R, ++ AC3_CHMODE_2F2R, ++ AC3_CHMODE_3F2R + } AC3ChannelMode; + + typedef struct AC3BitAllocParameters { +- int fscod; /* frequency */ +- int halfratecod; +- int sgain, sdecay, fdecay, dbknee, floor; +- int cplfleak, cplsleak; ++ int sr_code; ++ int sr_shift; ++ int slow_gain, slow_decay, fast_decay, db_per_bit, floor; ++ int cpl_fast_leak, cpl_slow_leak; + } AC3BitAllocParameters; + + /** +@@ -80,21 +80,16 @@ + */ + uint16_t sync_word; + uint16_t crc1; +- uint8_t fscod; +- uint8_t frmsizecod; +- uint8_t bsid; +- uint8_t bsmod; +- uint8_t acmod; +- uint8_t cmixlev; +- uint8_t surmixlev; +- uint8_t dsurmod; +- uint8_t lfeon; ++ uint8_t sr_code; ++ uint8_t bitstream_id; ++ uint8_t channel_mode; ++ uint8_t lfe_on; + /** @} */ + + /** @defgroup derived Derived values + * @{ + */ +- uint8_t halfratecod; ++ uint8_t sr_shift; + uint16_t sample_rate; + uint32_t bit_rate; + uint8_t channels; +@@ -117,10 +112,10 @@ + * @param[in] start starting bin location + * @param[in] end ending bin location + * @param[out] psd signal power for each frequency bin +- * @param[out] bndpsd signal power for each critical band ++ * @param[out] band_psd signal power for each critical band + */ + void ff_ac3_bit_alloc_calc_psd(int8_t *exp, int start, int end, int16_t *psd, +- int16_t *bndpsd); ++ int16_t *band_psd); + + /** + * Calculates the masking curve. +@@ -130,23 +125,23 @@ + * allocation information is provided, it is used for adjusting the masking + * curve, usually to give a closer match to a better psychoacoustic model. + * +- * @param[in] s adjustable bit allocation parameters +- * @param[in] bndpsd signal power for each critical band +- * @param[in] start starting bin location +- * @param[in] end ending bin location +- * @param[in] fgain fast gain (estimated signal-to-mask ratio) +- * @param[in] is_lfe whether or not the channel being processed is the LFE +- * @param[in] deltbae delta bit allocation exists (none, reuse, or new) +- * @param[in] deltnseg number of delta segments +- * @param[in] deltoffst location offsets for each segment +- * @param[in] deltlen length of each segment +- * @param[in] deltba delta bit allocation for each segment +- * @param[out] mask calculated masking curve ++ * @param[in] s adjustable bit allocation parameters ++ * @param[in] band_psd signal power for each critical band ++ * @param[in] start starting bin location ++ * @param[in] end ending bin location ++ * @param[in] fast_gain fast gain (estimated signal-to-mask ratio) ++ * @param[in] is_lfe whether or not the channel being processed is the LFE ++ * @param[in] dba_mode delta bit allocation mode (none, reuse, or new) ++ * @param[in] dba_nsegs number of delta segments ++ * @param[in] dba_offsets location offsets for each segment ++ * @param[in] dba_lengths length of each segment ++ * @param[in] dba_values delta bit allocation for each segment ++ * @param[out] mask calculated masking curve + */ +-void ff_ac3_bit_alloc_calc_mask(AC3BitAllocParameters *s, int16_t *bndpsd, +- int start, int end, int fgain, int is_lfe, +- int deltbae, int deltnseg, uint8_t *deltoffst, +- uint8_t *deltlen, uint8_t *deltba, ++void ff_ac3_bit_alloc_calc_mask(AC3BitAllocParameters *s, int16_t *band_psd, ++ int start, int end, int fast_gain, int is_lfe, ++ int dba_mode, int dba_nsegs, uint8_t *dba_offsets, ++ uint8_t *dba_lengths, uint8_t *dba_values, + int16_t *mask); + + /** +@@ -159,17 +154,18 @@ + * @param[in] psd signal power for each frequency bin + * @param[in] start starting bin location + * @param[in] end ending bin location +- * @param[in] snroffset SNR adjustment ++ * @param[in] snr_offset SNR adjustment + * @param[in] floor noise floor + * @param[out] bap bit allocation pointers + */ + void ff_ac3_bit_alloc_calc_bap(int16_t *mask, int16_t *psd, int start, int end, +- int snroffset, int floor, uint8_t *bap); ++ int snr_offset, int floor, uint8_t *bap); + + void ac3_parametric_bit_allocation(AC3BitAllocParameters *s, uint8_t *bap, + int8_t *exp, int start, int end, +- int snroffset, int fgain, int is_lfe, +- int deltbae,int deltnseg, +- uint8_t *deltoffst, uint8_t *deltlen, uint8_t *deltba); ++ int snr_offset, int fast_gain, int is_lfe, ++ int dba_mode, int dba_nsegs, ++ uint8_t *dba_offsets, uint8_t *dba_lengths, ++ uint8_t *dba_values); + +-#endif /* AC3_H */ ++#endif /* FFMPEG_AC3_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/ac3_parser.c ffmpeg-free-0.svn20080206/libavcodec/ac3_parser.c +--- mplayer-1.0~rc2-12/libavcodec/ac3_parser.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/ac3_parser.c 2008-03-20 19:10:57.000000000 +0100 +@@ -37,6 +37,8 @@ + int ff_ac3_parse_header(const uint8_t buf[7], AC3HeaderInfo *hdr) + { + GetBitContext gbc; ++ int frame_size_code; ++ int num_blocks; + + memset(hdr, 0, sizeof(*hdr)); + +@@ -46,40 +48,73 @@ + if(hdr->sync_word != 0x0B77) + return AC3_PARSE_ERROR_SYNC; + +- /* read ahead to bsid to make sure this is AC-3, not E-AC-3 */ +- hdr->bsid = show_bits_long(&gbc, 29) & 0x1F; +- if(hdr->bsid > 10) ++ /* read ahead to bsid to distinguish between AC-3 and E-AC-3 */ ++ hdr->bitstream_id = show_bits_long(&gbc, 29) & 0x1F; ++ if(hdr->bitstream_id > 16) + return AC3_PARSE_ERROR_BSID; + +- hdr->crc1 = get_bits(&gbc, 16); +- hdr->fscod = get_bits(&gbc, 2); +- if(hdr->fscod == 3) +- return AC3_PARSE_ERROR_SAMPLE_RATE; +- +- hdr->frmsizecod = get_bits(&gbc, 6); +- if(hdr->frmsizecod > 37) +- return AC3_PARSE_ERROR_FRAME_SIZE; +- +- skip_bits(&gbc, 5); // skip bsid, already got it +- +- hdr->bsmod = get_bits(&gbc, 3); +- hdr->acmod = get_bits(&gbc, 3); +- if((hdr->acmod & 1) && hdr->acmod != AC3_ACMOD_MONO) { +- hdr->cmixlev = get_bits(&gbc, 2); +- } +- if(hdr->acmod & 4) { +- hdr->surmixlev = get_bits(&gbc, 2); +- } +- if(hdr->acmod == AC3_ACMOD_STEREO) { +- hdr->dsurmod = get_bits(&gbc, 2); +- } +- hdr->lfeon = get_bits1(&gbc); ++ if(hdr->bitstream_id <= 10) { ++ /* Normal AC-3 */ ++ hdr->crc1 = get_bits(&gbc, 16); ++ hdr->sr_code = get_bits(&gbc, 2); ++ if(hdr->sr_code == 3) ++ return AC3_PARSE_ERROR_SAMPLE_RATE; ++ ++ frame_size_code = get_bits(&gbc, 6); ++ if(frame_size_code > 37) ++ return AC3_PARSE_ERROR_FRAME_SIZE; ++ ++ skip_bits(&gbc, 5); // skip bsid, already got it ++ ++ skip_bits(&gbc, 3); // skip bitstream mode ++ hdr->channel_mode = get_bits(&gbc, 3); ++ if((hdr->channel_mode & 1) && hdr->channel_mode != AC3_CHMODE_MONO) { ++ skip_bits(&gbc, 2); // skip center mix level ++ } ++ if(hdr->channel_mode & 4) { ++ skip_bits(&gbc, 2); // skip surround mix level ++ } ++ if(hdr->channel_mode == AC3_CHMODE_STEREO) { ++ skip_bits(&gbc, 2); // skip dolby surround mode ++ } ++ hdr->lfe_on = get_bits1(&gbc); + +- hdr->halfratecod = FFMAX(hdr->bsid, 8) - 8; +- hdr->sample_rate = ff_ac3_freqs[hdr->fscod] >> hdr->halfratecod; +- hdr->bit_rate = (ff_ac3_bitratetab[hdr->frmsizecod>>1] * 1000) >> hdr->halfratecod; +- hdr->channels = ff_ac3_channels[hdr->acmod] + hdr->lfeon; +- hdr->frame_size = ff_ac3_frame_sizes[hdr->frmsizecod][hdr->fscod] * 2; ++ hdr->sr_shift = FFMAX(hdr->bitstream_id, 8) - 8; ++ hdr->sample_rate = ff_ac3_sample_rate_tab[hdr->sr_code] >> hdr->sr_shift; ++ hdr->bit_rate = (ff_ac3_bitrate_tab[frame_size_code>>1] * 1000) >> hdr->sr_shift; ++ hdr->channels = ff_ac3_channels_tab[hdr->channel_mode] + hdr->lfe_on; ++ hdr->frame_size = ff_ac3_frame_size_tab[frame_size_code][hdr->sr_code] * 2; ++ } else { ++ /* Enhanced AC-3 */ ++ hdr->crc1 = 0; ++ skip_bits(&gbc, 2); // skip stream type ++ skip_bits(&gbc, 3); // skip substream id ++ ++ hdr->frame_size = (get_bits(&gbc, 11) + 1) << 1; ++ if(hdr->frame_size < AC3_HEADER_SIZE) ++ return AC3_PARSE_ERROR_FRAME_SIZE; ++ ++ hdr->sr_code = get_bits(&gbc, 2); ++ if (hdr->sr_code == 3) { ++ int sr_code2 = get_bits(&gbc, 2); ++ if(sr_code2 == 3) ++ return AC3_PARSE_ERROR_SAMPLE_RATE; ++ hdr->sample_rate = ff_ac3_sample_rate_tab[sr_code2] / 2; ++ hdr->sr_shift = 1; ++ num_blocks = 6; ++ } else { ++ num_blocks = eac3_blocks[get_bits(&gbc, 2)]; ++ hdr->sample_rate = ff_ac3_sample_rate_tab[hdr->sr_code]; ++ hdr->sr_shift = 0; ++ } ++ ++ hdr->channel_mode = get_bits(&gbc, 3); ++ hdr->lfe_on = get_bits1(&gbc); ++ ++ hdr->bit_rate = (uint32_t)(8.0 * hdr->frame_size * hdr->sample_rate / ++ (num_blocks * 256.0)); ++ hdr->channels = ff_ac3_channels_tab[hdr->channel_mode] + hdr->lfe_on; ++ } + + return 0; + } +@@ -88,59 +123,18 @@ + int *bit_rate, int *samples) + { + int err; +- unsigned int fscod, acmod, bsid, lfeon; +- unsigned int strmtyp, substreamid, frmsiz, fscod2, numblkscod; +- GetBitContext bits; + AC3HeaderInfo hdr; + + err = ff_ac3_parse_header(buf, &hdr); + +- if(err < 0 && err != -2) ++ if(err < 0) + return 0; + +- bsid = hdr.bsid; +- if(bsid <= 10) { /* Normal AC-3 */ +- *sample_rate = hdr.sample_rate; +- *bit_rate = hdr.bit_rate; +- *channels = hdr.channels; +- *samples = AC3_FRAME_SIZE; +- return hdr.frame_size; +- } else if (bsid > 10 && bsid <= 16) { /* Enhanced AC-3 */ +- init_get_bits(&bits, &buf[2], (AC3_HEADER_SIZE-2) * 8); +- strmtyp = get_bits(&bits, 2); +- substreamid = get_bits(&bits, 3); +- +- if (strmtyp != 0 || substreamid != 0) +- return 0; /* Currently don't support additional streams */ +- +- frmsiz = get_bits(&bits, 11) + 1; +- fscod = get_bits(&bits, 2); +- if (fscod == 3) { +- fscod2 = get_bits(&bits, 2); +- numblkscod = 3; +- +- if(fscod2 == 3) +- return 0; +- +- *sample_rate = ff_ac3_freqs[fscod2] / 2; +- } else { +- numblkscod = get_bits(&bits, 2); +- +- *sample_rate = ff_ac3_freqs[fscod]; +- } +- +- acmod = get_bits(&bits, 3); +- lfeon = get_bits1(&bits); +- +- *samples = eac3_blocks[numblkscod] * 256; +- *bit_rate = frmsiz * (*sample_rate) * 16 / (*samples); +- *channels = ff_ac3_channels[acmod] + lfeon; +- +- return frmsiz * 2; +- } +- +- /* Unsupported bitstream version */ +- return 0; ++ *sample_rate = hdr.sample_rate; ++ *bit_rate = hdr.bit_rate; ++ *channels = hdr.channels; ++ *samples = AC3_FRAME_SIZE; ++ return hdr.frame_size; + } + + static int ac3_parse_init(AVCodecParserContext *s1) +diff -u mplayer-1.0~rc2-12/libavcodec/ac3_parser.h ffmpeg-free-0.svn20080206/libavcodec/ac3_parser.h +--- mplayer-1.0~rc2-12/libavcodec/ac3_parser.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/ac3_parser.h 2007-10-17 11:37:46.000000000 +0200 +@@ -20,8 +20,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef AC3_PARSER_H +-#define AC3_PARSER_H ++#ifndef FFMPEG_AC3_PARSER_H ++#define FFMPEG_AC3_PARSER_H + + #include "ac3.h" + +@@ -44,4 +44,4 @@ + */ + int ff_ac3_parse_header(const uint8_t buf[7], AC3HeaderInfo *hdr); + +-#endif /* AC3_PARSER_H */ ++#endif /* FFMPEG_AC3_PARSER_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/ac3tab.c ffmpeg-free-0.svn20080206/libavcodec/ac3tab.c +--- mplayer-1.0~rc2-12/libavcodec/ac3tab.c 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/ac3tab.c 2008-03-20 19:10:57.000000000 +0100 +@@ -30,7 +30,7 @@ + * Possible frame sizes. + * from ATSC A/52 Table 5.18 Frame Size Code Table. + */ +-const uint16_t ff_ac3_frame_sizes[38][3] = { ++const uint16_t ff_ac3_frame_size_tab[38][3] = { + { 64, 69, 96 }, + { 64, 70, 96 }, + { 80, 87, 120 }, +@@ -75,15 +75,15 @@ + * Maps audio coding mode (acmod) to number of full-bandwidth channels. + * from ATSC A/52 Table 5.8 Audio Coding Mode + */ +-const uint8_t ff_ac3_channels[8] = { ++const uint8_t ff_ac3_channels_tab[8] = { + 2, 1, 2, 3, 3, 4, 4, 5 + }; + + /* possible frequencies */ +-const uint16_t ff_ac3_freqs[3] = { 48000, 44100, 32000 }; ++const uint16_t ff_ac3_sample_rate_tab[3] = { 48000, 44100, 32000 }; + + /* possible bitrates */ +-const uint16_t ff_ac3_bitratetab[19] = { ++const uint16_t ff_ac3_bitrate_tab[19] = { + 32, 40, 48, 56, 64, 80, 96, 112, 128, + 160, 192, 224, 256, 320, 384, 448, 512, 576, 640 + }; +@@ -126,7 +126,7 @@ + 32767,32767,32767,32767,32767,32767,32767,32767, + }; + +-const uint8_t ff_ac3_latab[260]= { ++const uint8_t ff_ac3_log_add_tab[260]= { + 0x40,0x3f,0x3e,0x3d,0x3c,0x3b,0x3a,0x39,0x38,0x37, + 0x36,0x35,0x34,0x34,0x33,0x32,0x31,0x30,0x2f,0x2f, + 0x2e,0x2d,0x2c,0x2c,0x2b,0x2a,0x29,0x29,0x28,0x27, +@@ -155,7 +155,7 @@ + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, + }; + +-const uint16_t ff_ac3_hth[50][3]= { ++const uint16_t ff_ac3_hearing_threshold_tab[50][3]= { + { 0x04d0,0x04f0,0x0580 }, + { 0x04d0,0x04f0,0x0580 }, + { 0x0440,0x0460,0x04b0 }, +@@ -208,7 +208,7 @@ + { 0x0840,0x0840,0x04e0 }, + }; + +-const uint8_t ff_ac3_baptab[64]= { ++const uint8_t ff_ac3_bap_tab[64]= { + 0, 1, 1, 1, 1, 1, 2, 2, 3, 3, + 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, + 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, +@@ -218,31 +218,31 @@ + 15, 15, 15, 15, + }; + +-const uint8_t ff_sdecaytab[4]={ ++const uint8_t ff_ac3_slow_decay_tab[4]={ + 0x0f, 0x11, 0x13, 0x15, + }; + +-const uint8_t ff_fdecaytab[4]={ ++const uint8_t ff_ac3_fast_decay_tab[4]={ + 0x3f, 0x53, 0x67, 0x7b, + }; + +-const uint16_t ff_sgaintab[4]= { ++const uint16_t ff_ac3_slow_gain_tab[4]= { + 0x540, 0x4d8, 0x478, 0x410, + }; + +-const uint16_t ff_dbkneetab[4]= { ++const uint16_t ff_ac3_db_per_bit_tab[4]= { + 0x000, 0x700, 0x900, 0xb00, + }; + +-const int16_t ff_floortab[8]= { ++const int16_t ff_ac3_floor_tab[8]= { + 0x2f0, 0x2b0, 0x270, 0x230, 0x1f0, 0x170, 0x0f0, 0xf800, + }; + +-const uint16_t ff_fgaintab[8]= { ++const uint16_t ff_ac3_fast_gain_tab[8]= { + 0x080, 0x100, 0x180, 0x200, 0x280, 0x300, 0x380, 0x400, + }; + +-const uint8_t ff_ac3_bndsz[50]={ ++const uint8_t ff_ac3_critical_band_size_tab[50]={ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, + 3, 6, 6, 6, 6, 6, 6, 12, 12, 12, 12, 24, 24, 24, 24, 24 +diff -u mplayer-1.0~rc2-12/libavcodec/ac3tab.h ffmpeg-free-0.svn20080206/libavcodec/ac3tab.h +--- mplayer-1.0~rc2-12/libavcodec/ac3tab.h 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/ac3tab.h 2007-12-09 04:21:33.000000000 +0100 +@@ -19,25 +19,25 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef AC3TAB_H +-#define AC3TAB_H ++#ifndef FFMPEG_AC3TAB_H ++#define FFMPEG_AC3TAB_H + + #include "common.h" + +-extern const uint16_t ff_ac3_frame_sizes[38][3]; +-extern const uint8_t ff_ac3_channels[8]; +-extern const uint16_t ff_ac3_freqs[3]; +-extern const uint16_t ff_ac3_bitratetab[19]; ++extern const uint16_t ff_ac3_frame_size_tab[38][3]; ++extern const uint8_t ff_ac3_channels_tab[8]; ++extern const uint16_t ff_ac3_sample_rate_tab[3]; ++extern const uint16_t ff_ac3_bitrate_tab[19]; + extern const int16_t ff_ac3_window[256]; +-extern const uint8_t ff_ac3_latab[260]; +-extern const uint16_t ff_ac3_hth[50][3]; +-extern const uint8_t ff_ac3_baptab[64]; +-extern const uint8_t ff_sdecaytab[4]; +-extern const uint8_t ff_fdecaytab[4]; +-extern const uint16_t ff_sgaintab[4]; +-extern const uint16_t ff_dbkneetab[4]; +-extern const int16_t ff_floortab[8]; +-extern const uint16_t ff_fgaintab[8]; +-extern const uint8_t ff_ac3_bndsz[50]; ++extern const uint8_t ff_ac3_log_add_tab[260]; ++extern const uint16_t ff_ac3_hearing_threshold_tab[50][3]; ++extern const uint8_t ff_ac3_bap_tab[64]; ++extern const uint8_t ff_ac3_slow_decay_tab[4]; ++extern const uint8_t ff_ac3_fast_decay_tab[4]; ++extern const uint16_t ff_ac3_slow_gain_tab[4]; ++extern const uint16_t ff_ac3_db_per_bit_tab[4]; ++extern const int16_t ff_ac3_floor_tab[8]; ++extern const uint16_t ff_ac3_fast_gain_tab[8]; ++extern const uint8_t ff_ac3_critical_band_size_tab[50]; + +-#endif /* AC3TAB_H */ ++#endif /* FFMPEG_AC3TAB_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/adpcm.c ffmpeg-free-0.svn20080206/libavcodec/adpcm.c +--- mplayer-1.0~rc2-12/libavcodec/adpcm.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/adpcm.c 2008-03-20 19:10:57.000000000 +0100 +@@ -30,6 +30,10 @@ + * by Mike Melanson (melanson@pcisys.net) + * CD-ROM XA ADPCM codec by BERO + * EA ADPCM decoder by Robin Kay (komadori@myrealbox.com) ++ * EA ADPCM R1/R2/R3 decoder by Peter Ross (pross@xvid.org) ++ * EA IMA EACS decoder by Peter Ross (pross@xvid.org) ++ * EA IMA SEAD decoder by Peter Ross (pross@xvid.org) ++ * EA ADPCM XAS decoder by Peter Ross (pross@xvid.org) + * THP ADPCM decoder by Marco Gerards (mgerards@xs4all.nl) + * + * Features and limitations: +@@ -144,8 +148,7 @@ + + typedef struct ADPCMContext { + int channel; /* for stereo MOVs, decode left, then decode right, then tell it's decoded */ +- ADPCMChannelStatus status[2]; +- short sample_buffer[32]; /* hold left samples while waiting for right samples */ ++ ADPCMChannelStatus status[6]; + } ADPCMContext; + + /* XXX: implement encoding */ +@@ -156,11 +159,6 @@ + if (avctx->channels > 2) + return -1; /* only stereo or mono =) */ + switch(avctx->codec->id) { +- case CODEC_ID_ADPCM_IMA_QT: +- av_log(avctx, AV_LOG_ERROR, "ADPCM: codec adpcm_ima_qt unsupported for encoding !\n"); +- avctx->frame_size = 64; /* XXX: can multiple of avctx->channels * 64 (left and right blocks are interleaved) */ +- return -1; +- break; + case CODEC_ID_ADPCM_IMA_WAV: + avctx->frame_size = (BLKSIZE - 4 * avctx->channels) * 8 / (4 * avctx->channels) + 1; /* each 16 bits sample gives one nibble */ + /* and we have 4 bytes per channel overhead */ +@@ -444,8 +442,6 @@ + /* n = (BLKSIZE - 4 * avctx->channels) / (2 * 8 * avctx->channels); */ + + switch(avctx->codec->id) { +- case CODEC_ID_ADPCM_IMA_QT: /* XXX: can't test until we get .mov writer */ +- break; + case CODEC_ID_ADPCM_IMA_WAV: + n = avctx->frame_size / 8; + c->status[0].prev_sample = (signed short)samples[0]; /* XXX */ +@@ -455,7 +451,7 @@ + *dst++ = 0; /* unknown */ + samples++; + if (avctx->channels == 2) { +- c->status[1].prev_sample = (signed short)samples[1]; ++ c->status[1].prev_sample = (signed short)samples[0]; + /* c->status[1].step_index = 0; */ + bytestream_put_le16(&dst, c->status[1].prev_sample); + *dst++ = (unsigned char)c->status[1].step_index; +@@ -483,17 +479,17 @@ + } + } else + for (; n>0; n--) { +- *dst = adpcm_ima_compress_sample(&c->status[0], samples[0]) & 0x0F; +- *dst |= (adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels]) << 4) & 0xF0; ++ *dst = adpcm_ima_compress_sample(&c->status[0], samples[0]); ++ *dst |= adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels]) << 4; + dst++; +- *dst = adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels * 2]) & 0x0F; +- *dst |= (adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels * 3]) << 4) & 0xF0; ++ *dst = adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels * 2]); ++ *dst |= adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels * 3]) << 4; + dst++; +- *dst = adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels * 4]) & 0x0F; +- *dst |= (adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels * 5]) << 4) & 0xF0; ++ *dst = adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels * 4]); ++ *dst |= adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels * 5]) << 4; + dst++; +- *dst = adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels * 6]) & 0x0F; +- *dst |= (adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels * 7]) << 4) & 0xF0; ++ *dst = adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels * 6]); ++ *dst |= adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels * 7]) << 4; + dst++; + /* right channel */ + if (avctx->channels == 2) { +@@ -544,9 +540,9 @@ + } + } else { + for (i=1; iframe_size; i++) { +- put_bits(&pb, 4, adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels*i]) & 0xF); ++ put_bits(&pb, 4, adpcm_ima_compress_sample(&c->status[0], samples[avctx->channels*i])); + if (avctx->channels == 2) +- put_bits(&pb, 4, adpcm_ima_compress_sample(&c->status[1], samples[2*i+1]) & 0xF); ++ put_bits(&pb, 4, adpcm_ima_compress_sample(&c->status[1], samples[2*i+1])); + } + } + flush_put_bits(&pb); +@@ -636,16 +632,19 @@ + static int adpcm_decode_init(AVCodecContext * avctx) + { + ADPCMContext *c = avctx->priv_data; ++ unsigned int max_channels = 2; + +- if(avctx->channels > 2U){ ++ switch(avctx->codec->id) { ++ case CODEC_ID_ADPCM_EA_R1: ++ case CODEC_ID_ADPCM_EA_R2: ++ case CODEC_ID_ADPCM_EA_R3: ++ max_channels = 6; ++ break; ++ } ++ if(avctx->channels > max_channels){ + return -1; + } + +- c->channel = 0; +- c->status[0].predictor = c->status[1].predictor = 0; +- c->status[0].step_index = c->status[1].step_index = 0; +- c->status[0].step = c->status[1].step = 0; +- + switch(avctx->codec->id) { + case CODEC_ID_ADPCM_CT: + c->status[0].step = c->status[1].step = 511; +@@ -842,7 +841,7 @@ + + static int adpcm_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + ADPCMContext *c = avctx->priv_data; + ADPCMChannelStatus *cs; +@@ -850,7 +849,7 @@ + int block_predictor[2]; + short *samples; + short *samples_end; +- uint8_t *src; ++ const uint8_t *src; + int st; /* stereo */ + + /* DK3 ADPCM accounting variables */ +@@ -937,11 +936,9 @@ + + for(i=0; ichannels; i++){ + cs = &(c->status[i]); +- cs->predictor = (int16_t)(src[0] + (src[1]<<8)); ++ cs->predictor = *samples++ = (int16_t)(src[0] + (src[1]<<8)); + src+=2; + +- // XXX: is this correct ??: *samples++ = cs->predictor; +- + cs->step_index = *src++; + if (cs->step_index > 88){ + av_log(avctx, AV_LOG_ERROR, "ERROR: step_index = %i\n", cs->step_index); +@@ -1124,8 +1121,6 @@ + } + break; + case CODEC_ID_ADPCM_XA: +- c->status[0].sample1 = c->status[0].sample2 = +- c->status[1].sample1 = c->status[1].sample2 = 0; + while (buf_size >= 128) { + xa_decode(samples, src, &c->status[0], &c->status[1], + avctx->channels); +@@ -1134,6 +1129,30 @@ + buf_size -= 128; + } + break; ++ case CODEC_ID_ADPCM_IMA_EA_EACS: ++ samples_in_chunk = bytestream_get_le32(&src) >> (1-st); ++ ++ if (samples_in_chunk > buf_size-4-(8<status[i].step_index = bytestream_get_le32(&src); ++ for (i=0; i<=st; i++) ++ c->status[i].predictor = bytestream_get_le32(&src); ++ ++ for (; samples_in_chunk; samples_in_chunk--, src++) { ++ *samples++ = adpcm_ima_expand_nibble(&c->status[0], *src>>4, 3); ++ *samples++ = adpcm_ima_expand_nibble(&c->status[st], *src&0x0F, 3); ++ } ++ break; ++ case CODEC_ID_ADPCM_IMA_EA_SEAD: ++ for (; src < buf+buf_size; src++) { ++ *samples++ = adpcm_ima_expand_nibble(&c->status[0], src[0] >> 4, 6); ++ *samples++ = adpcm_ima_expand_nibble(&c->status[st],src[0]&0x0F, 6); ++ } ++ break; + case CODEC_ID_ADPCM_EA: + samples_in_chunk = AV_RL32(src); + if (samples_in_chunk >= ((buf_size - 12) * 2)) { +@@ -1182,6 +1201,117 @@ + } + } + break; ++ case CODEC_ID_ADPCM_EA_R1: ++ case CODEC_ID_ADPCM_EA_R2: ++ case CODEC_ID_ADPCM_EA_R3: { ++ /* channel numbering ++ 2chan: 0=fl, 1=fr ++ 4chan: 0=fl, 1=rl, 2=fr, 3=rr ++ 6chan: 0=fl, 1=c, 2=fr, 3=rl, 4=rr, 5=sub */ ++ const int big_endian = avctx->codec->id == CODEC_ID_ADPCM_EA_R3; ++ int32_t previous_sample, current_sample, next_sample; ++ int32_t coeff1, coeff2; ++ uint8_t shift; ++ unsigned int channel; ++ uint16_t *samplesC; ++ const uint8_t *srcC; ++ ++ samples_in_chunk = (big_endian ? bytestream_get_be32(&src) ++ : bytestream_get_le32(&src)) / 28; ++ if (samples_in_chunk > UINT32_MAX/(28*avctx->channels) || ++ 28*samples_in_chunk*avctx->channels > samples_end-samples) { ++ src += buf_size - 4; ++ break; ++ } ++ ++ for (channel=0; channelchannels; channel++) { ++ srcC = src + (big_endian ? bytestream_get_be32(&src) ++ : bytestream_get_le32(&src)) ++ + (avctx->channels-channel-1) * 4; ++ samplesC = samples + channel; ++ ++ if (avctx->codec->id == CODEC_ID_ADPCM_EA_R1) { ++ current_sample = (int16_t)bytestream_get_le16(&srcC); ++ previous_sample = (int16_t)bytestream_get_le16(&srcC); ++ } else { ++ current_sample = c->status[channel].predictor; ++ previous_sample = c->status[channel].prev_sample; ++ } ++ ++ for (count1=0; count1channels; ++ } ++ } else { ++ coeff1 = ea_adpcm_table[ (*srcC>>4) & 0x0F ]; ++ coeff2 = ea_adpcm_table[((*srcC>>4) & 0x0F) + 4]; ++ shift = (*srcC++ & 0x0F) + 8; ++ ++ for (count2=0; count2<28; count2++) { ++ if (count2 & 1) ++ next_sample = ((*srcC++ & 0x0F) << 28) >> shift; ++ else ++ next_sample = ((*srcC & 0xF0) << 24) >> shift; ++ ++ next_sample += (current_sample * coeff1) + ++ (previous_sample * coeff2); ++ next_sample = av_clip_int16(next_sample >> 8); ++ ++ previous_sample = current_sample; ++ current_sample = next_sample; ++ *samplesC = current_sample; ++ samplesC += avctx->channels; ++ } ++ } ++ } ++ ++ if (avctx->codec->id != CODEC_ID_ADPCM_EA_R1) { ++ c->status[channel].predictor = current_sample; ++ c->status[channel].prev_sample = previous_sample; ++ } ++ } ++ ++ src = src + buf_size - (4 + 4*avctx->channels); ++ samples += 28 * samples_in_chunk * avctx->channels; ++ break; ++ } ++ case CODEC_ID_ADPCM_EA_XAS: ++ if (samples_end-samples < 32*4*avctx->channels ++ || buf_size < (4+15)*4*avctx->channels) { ++ src += buf_size; ++ break; ++ } ++ for (channel=0; channelchannels; channel++) { ++ int coeff[2][4], shift[4]; ++ short *s2, *s = &samples[channel]; ++ for (n=0; n<4; n++, s+=32*avctx->channels) { ++ for (i=0; i<2; i++) ++ coeff[i][n] = ea_adpcm_table[(src[0]&0x0F)+4*i]; ++ shift[n] = (src[2]&0x0F) + 8; ++ for (s2=s, i=0; i<2; i++, src+=2, s2+=avctx->channels) ++ s2[0] = (src[0]&0xF0) + (src[1]<<8); ++ } ++ ++ for (m=2; m<32; m+=2) { ++ s = &samples[m*avctx->channels + channel]; ++ for (n=0; n<4; n++, src++, s+=32*avctx->channels) { ++ for (s2=s, i=0; i<8; i+=4, s2+=avctx->channels) { ++ int level = ((*src & (0xF0>>i)) << (24+i)) >> shift[n]; ++ int pred = s2[-1*avctx->channels] * coeff[0][n] ++ + s2[-2*avctx->channels] * coeff[1][n]; ++ s2[0] = av_clip_int16((level + pred + 0x80) >> 8); ++ } ++ } ++ } ++ } ++ samples += 32*4*avctx->channels; ++ break; + case CODEC_ID_ADPCM_IMA_AMV: + case CODEC_ID_ADPCM_IMA_SMJPEG: + c->status[0].predictor = (int16_t)bytestream_get_le16(&src); +@@ -1446,23 +1576,27 @@ + #define ADPCM_CODEC(id, name) \ + ADPCM_ENCODER(id,name) ADPCM_DECODER(id,name) + +-ADPCM_CODEC(CODEC_ID_ADPCM_4XM, adpcm_4xm); +-ADPCM_CODEC(CODEC_ID_ADPCM_CT, adpcm_ct); +-ADPCM_CODEC(CODEC_ID_ADPCM_EA, adpcm_ea); +-ADPCM_CODEC(CODEC_ID_ADPCM_IMA_AMV, adpcm_ima_amv); +-ADPCM_CODEC(CODEC_ID_ADPCM_IMA_DK3, adpcm_ima_dk3); +-ADPCM_CODEC(CODEC_ID_ADPCM_IMA_DK4, adpcm_ima_dk4); +-ADPCM_CODEC(CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt); +-ADPCM_CODEC(CODEC_ID_ADPCM_IMA_SMJPEG, adpcm_ima_smjpeg); +-ADPCM_CODEC(CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav); +-ADPCM_CODEC(CODEC_ID_ADPCM_IMA_WS, adpcm_ima_ws); +-ADPCM_CODEC(CODEC_ID_ADPCM_MS, adpcm_ms); +-ADPCM_CODEC(CODEC_ID_ADPCM_SBPRO_4, adpcm_sbpro_4); +-ADPCM_CODEC(CODEC_ID_ADPCM_SBPRO_3, adpcm_sbpro_3); +-ADPCM_CODEC(CODEC_ID_ADPCM_SBPRO_2, adpcm_sbpro_2); +-ADPCM_CODEC(CODEC_ID_ADPCM_SWF, adpcm_swf); +-ADPCM_CODEC(CODEC_ID_ADPCM_THP, adpcm_thp); +-ADPCM_CODEC(CODEC_ID_ADPCM_XA, adpcm_xa); +-ADPCM_CODEC(CODEC_ID_ADPCM_YAMAHA, adpcm_yamaha); +- +-#undef ADPCM_CODEC ++ADPCM_DECODER(CODEC_ID_ADPCM_4XM, adpcm_4xm); ++ADPCM_DECODER(CODEC_ID_ADPCM_CT, adpcm_ct); ++ADPCM_DECODER(CODEC_ID_ADPCM_EA, adpcm_ea); ++ADPCM_DECODER(CODEC_ID_ADPCM_EA_R1, adpcm_ea_r1); ++ADPCM_DECODER(CODEC_ID_ADPCM_EA_R2, adpcm_ea_r2); ++ADPCM_DECODER(CODEC_ID_ADPCM_EA_R3, adpcm_ea_r3); ++ADPCM_DECODER(CODEC_ID_ADPCM_EA_XAS, adpcm_ea_xas); ++ADPCM_DECODER(CODEC_ID_ADPCM_IMA_AMV, adpcm_ima_amv); ++ADPCM_DECODER(CODEC_ID_ADPCM_IMA_DK3, adpcm_ima_dk3); ++ADPCM_DECODER(CODEC_ID_ADPCM_IMA_DK4, adpcm_ima_dk4); ++ADPCM_DECODER(CODEC_ID_ADPCM_IMA_EA_EACS, adpcm_ima_ea_eacs); ++ADPCM_DECODER(CODEC_ID_ADPCM_IMA_EA_SEAD, adpcm_ima_ea_sead); ++ADPCM_DECODER(CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt); ++ADPCM_DECODER(CODEC_ID_ADPCM_IMA_SMJPEG, adpcm_ima_smjpeg); ++ADPCM_CODEC (CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav); ++ADPCM_DECODER(CODEC_ID_ADPCM_IMA_WS, adpcm_ima_ws); ++ADPCM_CODEC (CODEC_ID_ADPCM_MS, adpcm_ms); ++ADPCM_DECODER(CODEC_ID_ADPCM_SBPRO_4, adpcm_sbpro_4); ++ADPCM_DECODER(CODEC_ID_ADPCM_SBPRO_3, adpcm_sbpro_3); ++ADPCM_DECODER(CODEC_ID_ADPCM_SBPRO_2, adpcm_sbpro_2); ++ADPCM_CODEC (CODEC_ID_ADPCM_SWF, adpcm_swf); ++ADPCM_DECODER(CODEC_ID_ADPCM_THP, adpcm_thp); ++ADPCM_DECODER(CODEC_ID_ADPCM_XA, adpcm_xa); ++ADPCM_CODEC (CODEC_ID_ADPCM_YAMAHA, adpcm_yamaha); +Only in mplayer-1.0~rc2-12/libavcodec: adx.c +Only in ffmpeg-free-0.svn20080206/libavcodec: adxdec.c +Only in ffmpeg-free-0.svn20080206/libavcodec: adxenc.c +Only in ffmpeg-free-0.svn20080206/libavcodec: adx.h +diff -u mplayer-1.0~rc2-12/libavcodec/alac.c ffmpeg-free-0.svn20080206/libavcodec/alac.c +--- mplayer-1.0~rc2-12/libavcodec/alac.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/alac.c 2008-03-20 19:10:57.000000000 +0100 +@@ -107,7 +107,7 @@ + + static int alac_set_info(ALACContext *alac) + { +- unsigned char *ptr = alac->avctx->extradata; ++ const unsigned char *ptr = alac->avctx->extradata; + + ptr += 4; /* size */ + ptr += 4; /* alac */ +@@ -325,15 +325,15 @@ + + #if 0 + /* 4 and 8 are very common cases (the only ones i've seen). these +- * should be unrolled and optimised ++ * should be unrolled and optimized + */ + if (predictor_coef_num == 4) { +- /* FIXME: optimised general case */ ++ /* FIXME: optimized general case */ + return; + } + + if (predictor_coef_table == 8) { +- /* FIXME: optimised general case */ ++ /* FIXME: optimized general case */ + return; + } + #endif +@@ -439,7 +439,7 @@ + + static int alac_decode_frame(AVCodecContext *avctx, + void *outbuffer, int *outputsize, +- uint8_t *inbuffer, int input_buffer_size) ++ const uint8_t *inbuffer, int input_buffer_size) + { + ALACContext *alac = avctx->priv_data; + +diff -u mplayer-1.0~rc2-12/libavcodec/allcodecs.c ffmpeg-free-0.svn20080206/libavcodec/allcodecs.c +--- mplayer-1.0~rc2-12/libavcodec/allcodecs.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/allcodecs.c 2008-03-20 19:10:57.000000000 +0100 +@@ -53,9 +53,9 @@ + */ + void avcodec_register_all(void) + { +- static int inited = 0; ++ static int inited; + +- if (inited != 0) ++ if (inited) + return; + inited = 1; + +@@ -73,7 +73,7 @@ + REGISTER_DECODER (CLJR, cljr); + REGISTER_DECODER (CSCD, cscd); + REGISTER_DECODER (CYUV, cyuv); +- REGISTER_DECODER (DNXHD, dnxhd); ++ REGISTER_ENCDEC (DNXHD, dnxhd); + REGISTER_DECODER (DSICINVIDEO, dsicinvideo); + REGISTER_ENCDEC (DVVIDEO, dvvideo); + REGISTER_DECODER (DXA, dxa); +@@ -86,10 +86,9 @@ + REGISTER_DECODER (FOURXM, fourxm); + REGISTER_DECODER (FRAPS, fraps); + REGISTER_ENCDEC (GIF, gif); +- REGISTER_ENCDEC (H261, h261); +- REGISTER_ENCDEC (H263, h263); ++ REGISTER_DECODER (H261, h261); ++ REGISTER_DECODER (H263, h263); + REGISTER_DECODER (H263I, h263i); +- REGISTER_ENCODER (H263P, h263p); + REGISTER_DECODER (H264, h264); + REGISTER_ENCDEC (HUFFYUV, huffyuv); + REGISTER_DECODER (IDCIN, idcin); +@@ -98,8 +97,6 @@ + REGISTER_DECODER (INTERPLAY_VIDEO, interplay_video); + REGISTER_ENCDEC (JPEGLS, jpegls); + REGISTER_DECODER (KMVC, kmvc); +- REGISTER_ENCODER (LIBX264, libx264); +- REGISTER_ENCODER (LIBXVID, libxvid); + REGISTER_ENCODER (LJPEG, ljpeg); + REGISTER_DECODER (LOCO, loco); + REGISTER_DECODER (MDEC, mdec); +@@ -108,18 +105,19 @@ + REGISTER_DECODER (MMVIDEO, mmvideo); + REGISTER_DECODER (MPEG_XVMC, mpeg_xvmc); + REGISTER_ENCDEC (MPEG1VIDEO, mpeg1video); +- REGISTER_ENCDEC (MPEG2VIDEO, mpeg2video); +- REGISTER_ENCDEC (MPEG4, mpeg4); ++ REGISTER_DECODER (MPEG2VIDEO, mpeg2video); ++ REGISTER_DECODER (MPEG4, mpeg4); + REGISTER_DECODER (MPEGVIDEO, mpegvideo); +- REGISTER_ENCDEC (MSMPEG4V1, msmpeg4v1); +- REGISTER_ENCDEC (MSMPEG4V2, msmpeg4v2); +- REGISTER_ENCDEC (MSMPEG4V3, msmpeg4v3); ++ REGISTER_DECODER (MSMPEG4V1, msmpeg4v1); ++ REGISTER_DECODER (MSMPEG4V2, msmpeg4v2); ++ REGISTER_DECODER (MSMPEG4V3, msmpeg4v3); + REGISTER_DECODER (MSRLE, msrle); + REGISTER_DECODER (MSVIDEO1, msvideo1); + REGISTER_DECODER (MSZH, mszh); + REGISTER_DECODER (NUV, nuv); + REGISTER_ENCODER (PAM, pam); + REGISTER_ENCODER (PBM, pbm); ++ REGISTER_DECODER (PCX, pcx); + REGISTER_ENCODER (PGM, pgm); + REGISTER_ENCODER (PGMYUV, pgmyuv); + REGISTER_ENCDEC (PNG, png); +@@ -138,6 +136,7 @@ + REGISTER_DECODER (SMC, smc); + REGISTER_ENCDEC (SNOW, snow); + REGISTER_DECODER (SP5X, sp5x); ++ REGISTER_DECODER (SUNRAST, sunrast); + REGISTER_ENCDEC (SVQ1, svq1); + REGISTER_DECODER (SVQ3, svq3); + REGISTER_ENCDEC (TARGA, targa); +@@ -150,6 +149,7 @@ + REGISTER_DECODER (TSCC, tscc); + REGISTER_DECODER (TXD, txd); + REGISTER_DECODER (ULTI, ulti); ++ REGISTER_DECODER (VB, vb); + REGISTER_DECODER (VC1, vc1); + REGISTER_DECODER (VCR1, vcr1); + REGISTER_DECODER (VMDVIDEO, vmdvideo); +@@ -181,17 +181,6 @@ + REGISTER_DECODER (DSICINAUDIO, dsicinaudio); + REGISTER_ENCDEC (FLAC, flac); + REGISTER_DECODER (IMC, imc); +- REGISTER_ENCDEC (LIBAMR_NB, libamr_nb); +- REGISTER_ENCDEC (LIBAMR_WB, libamr_wb); +- REGISTER_DECODER (LIBA52, liba52); +- REGISTER_ENCODER (LIBFAAC, libfaac); +- REGISTER_DECODER (LIBFAAD, libfaad); +- REGISTER_ENCDEC (LIBGSM, libgsm); +- REGISTER_ENCDEC (LIBGSM_MS, libgsm_ms); +- REGISTER_ENCODER (LIBMP3LAME, libmp3lame); +- REGISTER_ENCODER (LIBTHEORA, libtheora); +- if (!ENABLE_VORBIS_ENCODER) REGISTER_ENCODER (LIBVORBIS, libvorbis); +- if (!ENABLE_VORBIS_DECODER) REGISTER_DECODER (LIBVORBIS, libvorbis); + REGISTER_DECODER (MACE3, mace3); + REGISTER_DECODER (MACE6, mace6); + REGISTER_ENCDEC (MP2, mp2); +@@ -199,6 +188,8 @@ + REGISTER_DECODER (MP3ADU, mp3adu); + REGISTER_DECODER (MP3ON4, mp3on4); + REGISTER_DECODER (MPC7, mpc7); ++ REGISTER_DECODER (MPC8, mpc8); ++ REGISTER_DECODER (NELLYMOSER, nellymoser); + REGISTER_DECODER (QDM2, qdm2); + REGISTER_DECODER (RA_144, ra_144); + REGISTER_DECODER (RA_288, ra_288); +@@ -221,6 +212,7 @@ + REGISTER_ENCDEC (PCM_S8, pcm_s8); + REGISTER_ENCDEC (PCM_S16BE, pcm_s16be); + REGISTER_ENCDEC (PCM_S16LE, pcm_s16le); ++ REGISTER_DECODER (PCM_S16LE_PLANAR, pcm_s16le_planar); + REGISTER_ENCDEC (PCM_S24BE, pcm_s24be); + REGISTER_ENCDEC (PCM_S24DAUD, pcm_s24daud); + REGISTER_ENCDEC (PCM_S24LE, pcm_s24le); +@@ -242,31 +234,51 @@ + REGISTER_DECODER (XAN_DPCM, xan_dpcm); + + /* adpcm codecs */ +- REGISTER_ENCDEC (ADPCM_4XM, adpcm_4xm); ++ REGISTER_DECODER (ADPCM_4XM, adpcm_4xm); + REGISTER_ENCDEC (ADPCM_ADX, adpcm_adx); +- REGISTER_ENCDEC (ADPCM_CT, adpcm_ct); +- REGISTER_ENCDEC (ADPCM_EA, adpcm_ea); ++ REGISTER_DECODER (ADPCM_CT, adpcm_ct); ++ REGISTER_DECODER (ADPCM_EA, adpcm_ea); ++ REGISTER_DECODER (ADPCM_EA_R1, adpcm_ea_r1); ++ REGISTER_DECODER (ADPCM_EA_R2, adpcm_ea_r2); ++ REGISTER_DECODER (ADPCM_EA_R3, adpcm_ea_r3); ++ REGISTER_DECODER (ADPCM_EA_XAS, adpcm_ea_xas); + REGISTER_ENCDEC (ADPCM_G726, adpcm_g726); + REGISTER_DECODER (ADPCM_IMA_AMV, adpcm_ima_amv); +- REGISTER_ENCDEC (ADPCM_IMA_DK3, adpcm_ima_dk3); +- REGISTER_ENCDEC (ADPCM_IMA_DK4, adpcm_ima_dk4); +- REGISTER_ENCDEC (ADPCM_IMA_QT, adpcm_ima_qt); +- REGISTER_ENCDEC (ADPCM_IMA_SMJPEG, adpcm_ima_smjpeg); ++ REGISTER_DECODER (ADPCM_IMA_DK3, adpcm_ima_dk3); ++ REGISTER_DECODER (ADPCM_IMA_DK4, adpcm_ima_dk4); ++ REGISTER_DECODER (ADPCM_IMA_EA_EACS, adpcm_ima_ea_eacs); ++ REGISTER_DECODER (ADPCM_IMA_EA_SEAD, adpcm_ima_ea_sead); ++ REGISTER_DECODER (ADPCM_IMA_QT, adpcm_ima_qt); ++ REGISTER_DECODER (ADPCM_IMA_SMJPEG, adpcm_ima_smjpeg); + REGISTER_ENCDEC (ADPCM_IMA_WAV, adpcm_ima_wav); +- REGISTER_ENCDEC (ADPCM_IMA_WS, adpcm_ima_ws); ++ REGISTER_DECODER (ADPCM_IMA_WS, adpcm_ima_ws); + REGISTER_ENCDEC (ADPCM_MS, adpcm_ms); +- REGISTER_ENCDEC (ADPCM_SBPRO_2, adpcm_sbpro_2); +- REGISTER_ENCDEC (ADPCM_SBPRO_3, adpcm_sbpro_3); +- REGISTER_ENCDEC (ADPCM_SBPRO_4, adpcm_sbpro_4); ++ REGISTER_DECODER (ADPCM_SBPRO_2, adpcm_sbpro_2); ++ REGISTER_DECODER (ADPCM_SBPRO_3, adpcm_sbpro_3); ++ REGISTER_DECODER (ADPCM_SBPRO_4, adpcm_sbpro_4); + REGISTER_ENCDEC (ADPCM_SWF, adpcm_swf); + REGISTER_DECODER (ADPCM_THP, adpcm_thp); +- REGISTER_ENCDEC (ADPCM_XA, adpcm_xa); ++ REGISTER_DECODER (ADPCM_XA, adpcm_xa); + REGISTER_ENCDEC (ADPCM_YAMAHA, adpcm_yamaha); + + /* subtitles */ + REGISTER_ENCDEC (DVBSUB, dvbsub); + REGISTER_ENCDEC (DVDSUB, dvdsub); + ++ /* external libraries */ ++ REGISTER_DECODER (LIBA52, liba52); ++ REGISTER_ENCDEC (LIBAMR_NB, libamr_nb); ++ REGISTER_ENCDEC (LIBAMR_WB, libamr_wb); ++ REGISTER_ENCODER (LIBFAAC, libfaac); ++ REGISTER_DECODER (LIBFAAD, libfaad); ++ REGISTER_ENCDEC (LIBGSM, libgsm); ++ REGISTER_ENCDEC (LIBGSM_MS, libgsm_ms); ++ REGISTER_ENCODER (LIBMP3LAME, libmp3lame); ++ REGISTER_ENCODER (LIBTHEORA, libtheora); ++ REGISTER_ENCODER (LIBVORBIS, libvorbis); ++ REGISTER_ENCODER (LIBX264, libx264); ++ REGISTER_ENCODER (LIBXVID, libxvid); ++ + /* parsers */ + REGISTER_PARSER (AAC, aac); + REGISTER_PARSER (AC3, ac3); +@@ -278,6 +290,7 @@ + REGISTER_PARSER (H263, h263); + REGISTER_PARSER (H264, h264); + REGISTER_PARSER (MJPEG, mjpeg); ++ REGISTER_PARSER (MLP, mlp); + REGISTER_PARSER (MPEG4VIDEO, mpeg4video); + REGISTER_PARSER (MPEGAUDIO, mpegaudio); + REGISTER_PARSER (MPEGVIDEO, mpegvideo); +@@ -291,7 +304,9 @@ + REGISTER_BSF (MJPEGA_DUMP_HEADER, mjpega_dump_header); + REGISTER_BSF (MP3_HEADER_COMPRESS, mp3_header_compress); + REGISTER_BSF (MP3_HEADER_DECOMPRESS, mp3_header_decompress); ++ REGISTER_BSF (MOV2TEXTSUB, mov2textsub); + REGISTER_BSF (NOISE, noise); + REGISTER_BSF (REMOVE_EXTRADATA, remove_extradata); ++ REGISTER_BSF (TEXT2MOVSUB, text2movsub); + } + +Common subdirectories: mplayer-1.0~rc2-12/libavcodec/alpha and ffmpeg-free-0.svn20080206/libavcodec/alpha +diff -u mplayer-1.0~rc2-12/libavcodec/apedec.c ffmpeg-free-0.svn20080206/libavcodec/apedec.c +--- mplayer-1.0~rc2-12/libavcodec/apedec.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/apedec.c 2008-03-20 19:10:57.000000000 +0100 +@@ -154,8 +154,8 @@ + + uint8_t *data; ///< current frame data + uint8_t *data_end; ///< frame data end +- uint8_t *ptr; ///< current position in frame data +- uint8_t *last_ptr; ///< position where last 4608-sample block ended ++ const uint8_t *ptr; ///< current position in frame data ++ const uint8_t *last_ptr; ///< position where last 4608-sample block ended + } APEContext; + + // TODO: dsputilize +@@ -490,7 +490,7 @@ + /* Keep a count of the blocks decoded in this frame */ + ctx->blocksdecoded = 0; + +- /* Initialise the rice structs */ ++ /* Initialize the rice structs */ + ctx->riceX.k = 10; + ctx->riceX.ksum = (1 << ctx->riceX.k) * 16; + ctx->riceY.k = 10; +@@ -514,7 +514,7 @@ + memset(p->historybuffer, 0, PREDICTOR_SIZE * sizeof(int32_t)); + p->buf = p->historybuffer; + +- /* Initialise and zero the co-efficients */ ++ /* Initialize and zero the coefficients */ + memcpy(p->coeffsA[0], initial_coeffs, sizeof(initial_coeffs)); + memcpy(p->coeffsA[1], initial_coeffs, sizeof(initial_coeffs)); + memset(p->coeffsB, 0, sizeof(p->coeffsB)); +@@ -834,7 +834,7 @@ + + static int ape_decode_frame(AVCodecContext * avctx, + void *data, int *data_size, +- uint8_t * buf, int buf_size) ++ const uint8_t * buf, int buf_size) + { + APEContext *s = avctx->priv_data; + int16_t *samples = data; +@@ -856,7 +856,7 @@ + + if(!s->samples){ + s->data = av_realloc(s->data, (buf_size + 3) & ~3); +- s->dsp.bswap_buf(s->data, buf, buf_size >> 2); ++ s->dsp.bswap_buf((uint32_t*)s->data, (const uint32_t*)buf, buf_size >> 2); + s->ptr = s->last_ptr = s->data; + s->data_end = s->data + buf_size; + +Common subdirectories: mplayer-1.0~rc2-12/libavcodec/armv4l and ffmpeg-free-0.svn20080206/libavcodec/armv4l +diff -u mplayer-1.0~rc2-12/libavcodec/asv1.c ffmpeg-free-0.svn20080206/libavcodec/asv1.c +--- mplayer-1.0~rc2-12/libavcodec/asv1.c 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/asv1.c 2008-03-20 19:10:57.000000000 +0100 +@@ -387,7 +387,7 @@ + + static int decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + ASV1Context * const a = avctx->priv_data; + AVFrame *picture = data; +@@ -408,7 +408,7 @@ + a->bitstream_buffer= av_fast_realloc(a->bitstream_buffer, &a->bitstream_buffer_size, buf_size + FF_INPUT_BUFFER_PADDING_SIZE); + + if(avctx->codec_id == CODEC_ID_ASV1) +- a->dsp.bswap_buf((uint32_t*)a->bitstream_buffer, (uint32_t*)buf, buf_size/4); ++ a->dsp.bswap_buf((uint32_t*)a->bitstream_buffer, (const uint32_t*)buf, buf_size/4); + else{ + int i; + for(i=0; i> (off*8)) | (0x537F6103 << (32-(off*8)))); + bytes += 3 + off; + for (i = 0; i < bytes/4; i++) +@@ -868,7 +868,7 @@ + + static int atrac3_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) { ++ const uint8_t *buf, int buf_size) { + ATRAC3Context *q = avctx->priv_data; + int result = 0, i; + uint8_t* databuf; +@@ -919,7 +919,7 @@ + static int atrac3_decode_init(AVCodecContext *avctx) + { + int i; +- uint8_t *edata_ptr = avctx->extradata; ++ const uint8_t *edata_ptr = avctx->extradata; + ATRAC3Context *q = avctx->priv_data; + + /* Take data from the AVCodecContext (RM container). */ +diff -u mplayer-1.0~rc2-12/libavcodec/atrac3data.h ffmpeg-free-0.svn20080206/libavcodec/atrac3data.h +--- mplayer-1.0~rc2-12/libavcodec/atrac3data.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/atrac3data.h 2007-10-17 11:37:46.000000000 +0200 +@@ -25,8 +25,8 @@ + * Atrac 3 AKA RealAudio 8 compatible decoder data + */ + +-#ifndef AVCODEC_ATRAC3DATA_H +-#define AVCODEC_ATRAC3DATA_H ++#ifndef FFMPEG_ATRAC3DATA_H ++#define FFMPEG_ATRAC3DATA_H + + #include + +@@ -137,4 +137,4 @@ + /* joint stereo related tables */ + static const float matrixCoeffs[8] = {0.0, 2.0, 2.0, 2.0, 0.0, 0.0, 1.0, 1.0}; + +-#endif // AVCODEC_ATRAC3DATA_H ++#endif /* FFMPEG_ATRAC3DATA_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/avcodec.h ffmpeg-free-0.svn20080206/libavcodec/avcodec.h +--- mplayer-1.0~rc2-12/libavcodec/avcodec.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/avcodec.h 2008-06-18 12:09:30.000000000 +0200 +@@ -18,8 +18,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef AVCODEC_H +-#define AVCODEC_H ++#ifndef FFMPEG_AVCODEC_H ++#define FFMPEG_AVCODEC_H + + /** + * @file avcodec.h +@@ -30,11 +30,19 @@ + #include "avutil.h" + #include /* size_t */ + ++#if !defined INT64_C ++#if defined __WORDSIZE && __WORDSIZE == 64 ++#define INT64_C(c) c ## L ++#else ++#define INT64_C(c) c ## LL ++#endif ++#endif ++ + #define AV_STRINGIFY(s) AV_TOSTRING(s) + #define AV_TOSTRING(s) #s + +-#define LIBAVCODEC_VERSION_INT ((51<<16)+(44<<8)+0) +-#define LIBAVCODEC_VERSION 51.44.0 ++#define LIBAVCODEC_VERSION_INT ((51<<16)+(50<<8)+0) ++#define LIBAVCODEC_VERSION 51.50.0 + #define LIBAVCODEC_BUILD LIBAVCODEC_VERSION_INT + + #define LIBAVCODEC_IDENT "Lavc" AV_STRINGIFY(LIBAVCODEC_VERSION) +@@ -58,7 +66,7 @@ + enum CodecID { + CODEC_ID_NONE, + CODEC_ID_MPEG1VIDEO, +- CODEC_ID_MPEG2VIDEO, /* preferred ID for MPEG-1/2 video decoding */ ++ CODEC_ID_MPEG2VIDEO, ///< preferred ID for MPEG-1/2 video decoding + CODEC_ID_MPEG2VIDEO_XVMC, + CODEC_ID_H261, + CODEC_ID_H263, +@@ -168,6 +176,9 @@ + CODEC_ID_TXD, + CODEC_ID_VP6A, + CODEC_ID_AMV, ++ CODEC_ID_VB, ++ CODEC_ID_PCX, ++ CODEC_ID_SUNRAST, + + /* various PCM "codecs" */ + CODEC_ID_PCM_S16LE= 0x10000, +@@ -188,6 +199,7 @@ + CODEC_ID_PCM_U24BE, + CODEC_ID_PCM_S24DAUD, + CODEC_ID_PCM_ZORK, ++ CODEC_ID_PCM_S16LE_PLANAR, + + /* various ADPCM codecs */ + CODEC_ID_ADPCM_IMA_QT= 0x11000, +@@ -210,6 +222,12 @@ + CODEC_ID_ADPCM_SBPRO_2, + CODEC_ID_ADPCM_THP, + CODEC_ID_ADPCM_IMA_AMV, ++ CODEC_ID_ADPCM_EA_R1, ++ CODEC_ID_ADPCM_EA_R3, ++ CODEC_ID_ADPCM_EA_R2, ++ CODEC_ID_ADPCM_IMA_EA_SEAD, ++ CODEC_ID_ADPCM_IMA_EA_EACS, ++ CODEC_ID_ADPCM_EA_XAS, + + /* AMR */ + CODEC_ID_AMR_NB= 0x12000, +@@ -226,7 +244,7 @@ + CODEC_ID_SOL_DPCM, + + CODEC_ID_MP2= 0x15000, +- CODEC_ID_MP3, /* preferred ID for decoding MPEG audio layer 1, 2 or 3 */ ++ CODEC_ID_MP3, ///< preferred ID for decoding MPEG audio layer 1, 2 or 3 + CODEC_ID_AAC, + #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0) + CODEC_ID_MPEG4AAC, +@@ -248,7 +266,7 @@ + CODEC_ID_SHORTEN, + CODEC_ID_ALAC, + CODEC_ID_WESTWOOD_SND1, +- CODEC_ID_GSM, /* as in Berlin toast format */ ++ CODEC_ID_GSM, ///< as in Berlin toast format + CODEC_ID_QDM2, + CODEC_ID_COOK, + CODEC_ID_TRUESPEECH, +@@ -264,14 +282,21 @@ + CODEC_ID_ATRAC3, + CODEC_ID_VOXWARE, + CODEC_ID_APE, ++ CODEC_ID_NELLYMOSER, ++ CODEC_ID_MUSEPACK8, + + /* subtitle codecs */ + CODEC_ID_DVD_SUBTITLE= 0x17000, + CODEC_ID_DVB_SUBTITLE, +- CODEC_ID_TEXT, /* raw UTF-8 text */ ++ CODEC_ID_TEXT, ///< raw UTF-8 text + CODEC_ID_XSUB, ++ CODEC_ID_SSA, ++ CODEC_ID_MOV_TEXT, ++ ++ /* other specific kind of codecs (generaly used for attachments) */ ++ CODEC_ID_TTF= 0x18000, + +- CODEC_ID_MPEG2TS= 0x20000, /* _FAKE_ codec to indicate a raw MPEG-2 TS ++ CODEC_ID_MPEG2TS= 0x20000, /**< _FAKE_ codec to indicate a raw MPEG-2 TS + * stream (only used by libavformat) */ + }; + +@@ -287,11 +312,14 @@ + CODEC_TYPE_AUDIO, + CODEC_TYPE_DATA, + CODEC_TYPE_SUBTITLE, ++ CODEC_TYPE_ATTACHMENT, + CODEC_TYPE_NB + }; + +-/* Currently unused, may be used if 24/32 bits samples are ever supported. */ +-/* all in native-endian format */ ++/** ++ * Currently unused, may be used if 24/32 bits samples are ever supported. ++ * all in native-endian format ++ */ + enum SampleFormat { + SAMPLE_FMT_NONE = -1, + SAMPLE_FMT_U8, ///< unsigned 8 bits +@@ -319,17 +347,19 @@ + */ + #define FF_MIN_BUFFER_SIZE 16384 + +-/* motion estimation type, EPZS by default */ ++/** ++ * motion estimation type. ++ */ + enum Motion_Est_ID { +- ME_ZERO = 1, ++ ME_ZERO = 1, ///< no search, that is use 0,0 vector whenever one is needed + ME_FULL, + ME_LOG, + ME_PHODS, +- ME_EPZS, +- ME_X1, +- ME_HEX, +- ME_UMH, +- ME_ITER, ++ ME_EPZS, ///< enhanced predictive zonal search ++ ME_X1, ///< reserved for experiments ++ ME_HEX, ///< hexagon based search ++ ME_UMH, ///< uneven multi-hexagon search ++ ME_ITER, ///< iterative search + }; + + enum AVDiscard{ +@@ -363,9 +393,11 @@ + #define CODEC_FLAG_GMC 0x0020 ///< Use GMC. + #define CODEC_FLAG_MV0 0x0040 ///< Always try a MB with MV=<0,0>. + #define CODEC_FLAG_PART 0x0080 ///< Use data partitioning. +-/* The parent program guarantees that the input for B-frames containing ++/** ++ * The parent program guarantees that the input for B-frames containing + * streams is not written to for at least s->max_b_frames+1 frames, if +- * this is not set the input will be copied. */ ++ * this is not set the input will be copied. ++ */ + #define CODEC_FLAG_INPUT_PRESERVED 0x0100 + #define CODEC_FLAG_PASS1 0x0200 ///< Use internal 2pass ratecontrol in first pass mode. + #define CODEC_FLAG_PASS2 0x0400 ///< Use internal 2pass ratecontrol in second pass mode. +@@ -729,6 +761,12 @@ + + /** + * Audio Video Frame. ++ * New fields can be added to the end of FF_COMMON_FRAME with minor version ++ * bumps. ++ * Removal, reordering and changes to existing fields require a major ++ * version bump. No fields should be added into AVFrame before or after ++ * FF_COMMON_FRAME! ++ * sizeof(AVFrame) must not be used outside libav*. + */ + typedef struct AVFrame { + FF_COMMON_FRAME +@@ -737,7 +775,11 @@ + #define DEFAULT_FRAME_RATE_BASE 1001000 + + /** +- * main external API structure ++ * main external API structure. ++ * New fields can be added to the end with minor version bumps. ++ * Removal, reordering and changes to existing fields require a major ++ * version bump. ++ * sizeof(AVCodecContext) must not be used outside libav*. + */ + typedef struct AVCodecContext { + /** +@@ -1258,8 +1300,10 @@ + float dark_masking; + + ++#if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0) + /* for binary compatibility */ + int unused; ++#endif + + /** + * IDCT algorithm, see FF_IDCT_* below. +@@ -1286,6 +1330,7 @@ + #define FF_IDCT_SIMPLEARMV5TE 16 + #define FF_IDCT_SIMPLEARMV6 17 + #define FF_IDCT_SIMPLEVIS 18 ++#define FF_IDCT_WMV2 19 + + /** + * slice count +@@ -1320,15 +1365,15 @@ + unsigned dsp_mask; + #define FF_MM_FORCE 0x80000000 /* Force usage of selected flags (OR) */ + /* lower 16 bits - CPU features */ +-#define FF_MM_MMX 0x0001 /* standard MMX */ +-#define FF_MM_3DNOW 0x0004 /* AMD 3DNOW */ +-#define FF_MM_MMXEXT 0x0002 /* SSE integer functions or AMD MMX ext */ +-#define FF_MM_SSE 0x0008 /* SSE functions */ +-#define FF_MM_SSE2 0x0010 /* PIV SSE2 functions */ +-#define FF_MM_3DNOWEXT 0x0020 /* AMD 3DNowExt */ +-#define FF_MM_SSE3 0x0040 /* Prescott SSE3 functions */ +-#define FF_MM_SSSE3 0x0080 /* Conroe SSSE3 functions */ +-#define FF_MM_IWMMXT 0x0100 /* XScale IWMMXT */ ++#define FF_MM_MMX 0x0001 ///< standard MMX ++#define FF_MM_3DNOW 0x0004 ///< AMD 3DNOW ++#define FF_MM_MMXEXT 0x0002 ///< SSE integer functions or AMD MMX ext ++#define FF_MM_SSE 0x0008 ///< SSE functions ++#define FF_MM_SSE2 0x0010 ///< PIV SSE2 functions ++#define FF_MM_3DNOWEXT 0x0020 ///< AMD 3DNowExt ++#define FF_MM_SSE3 0x0040 ///< Prescott SSE3 functions ++#define FF_MM_SSSE3 0x0080 ///< Conroe SSSE3 functions ++#define FF_MM_IWMMXT 0x0100 ///< XScale IWMMXT + + /** + * bits per sample/pixel from the demuxer (needed for huffyuv). +@@ -2028,11 +2073,11 @@ + * - decoding: unused + */ + int partitions; +-#define X264_PART_I4X4 0x001 /* Analyse i4x4 */ +-#define X264_PART_I8X8 0x002 /* Analyse i8x8 (requires 8x8 transform) */ +-#define X264_PART_P8X8 0x010 /* Analyse p16x8, p8x16 and p8x8 */ +-#define X264_PART_P4X4 0x020 /* Analyse p8x4, p4x8, p4x4 */ +-#define X264_PART_B8X8 0x100 /* Analyse b16x8, b8x16 and b8x8 */ ++#define X264_PART_I4X4 0x001 /* Analyze i4x4 */ ++#define X264_PART_I8X8 0x002 /* Analyze i8x8 (requires 8x8 transform) */ ++#define X264_PART_P8X8 0x010 /* Analyze p16x8, p8x16 and p8x8 */ ++#define X264_PART_P4X4 0x020 /* Analyze p8x4, p4x8, p4x4 */ ++#define X264_PART_B8X8 0x100 /* Analyze b16x8, b8x16 and b8x8 */ + + /** + * direct MV prediction mode - 0 (none), 1 (spatial), 2 (temporal) +@@ -2042,7 +2087,7 @@ + int directpred; + + /** +- * Audio cutoff bandwidth (0 means "automatic"), currently used only by FAAC. ++ * Audio cutoff bandwidth (0 means "automatic") + * - encoding: Set by user. + * - decoding: unused + */ +@@ -2135,6 +2180,14 @@ + * - decoding: Set by user. + */ + int request_channels; ++ ++ /** ++ * Percentage of dynamic range compression to be applied by the decoder. ++ * The default value is 1.0, corresponding to full compression. ++ * - encoding: unused ++ * - decoding: Set by user. ++ */ ++ float drc_scale; + } AVCodecContext; + + /** +@@ -2155,7 +2208,7 @@ + int (*encode)(AVCodecContext *, uint8_t *buf, int buf_size, void *data); + int (*close)(AVCodecContext *); + int (*decode)(AVCodecContext *, void *outdata, int *outdata_size, +- uint8_t *buf, int buf_size); ++ const uint8_t *buf, int buf_size); + int capabilities; + struct AVCodec *next; + void (*flush)(AVCodecContext *); +@@ -2382,9 +2435,9 @@ + * Print in buf the string corresponding to the pixel format with + * number pix_fmt, or an header if pix_fmt is negative. + * +- * @param buf[in] the buffer where to write the string +- * @param buf_size[in] the size of buf +- * @param pix_fmt[in] the number of the pixel format to print the corresponding info string, or ++ * @param[in] buf the buffer where to write the string ++ * @param[in] buf_size the size of buf ++ * @param[in] pix_fmt the number of the pixel format to print the corresponding info string, or + * a negative value to print the corresponding header. + * Meaningful values for obtaining a pixel format info vary from 0 to PIX_FMT_NB -1. + */ +@@ -2417,7 +2470,10 @@ + + /* external high level API */ + ++#if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0) + extern AVCodec *first_avcodec; ++#endif ++AVCodec *av_codec_next(AVCodec *c); + + /* returns LIBAVCODEC_VERSION_INT constant */ + unsigned avcodec_version(void); +@@ -2435,7 +2491,7 @@ + void register_avcodec(AVCodec *format); + + /** +- * Finds an encoder with a matching codec ID. ++ * Finds a registered encoder with a matching codec ID. + * + * @param id CodecID of the requested encoder + * @return An encoder if one was found, NULL otherwise. +@@ -2443,7 +2499,7 @@ + AVCodec *avcodec_find_encoder(enum CodecID id); + + /** +- * Finds an encoder with the specified name. ++ * Finds a registered encoder with the specified name. + * + * @param name name of the requested encoder + * @return An encoder if one was found, NULL otherwise. +@@ -2451,7 +2507,7 @@ + AVCodec *avcodec_find_encoder_by_name(const char *name); + + /** +- * Finds a decoder with a matching codec ID. ++ * Finds a registered decoder with a matching codec ID. + * + * @param id CodecID of the requested decoder + * @return A decoder if one was found, NULL otherwise. +@@ -2459,7 +2515,7 @@ + AVCodec *avcodec_find_decoder(enum CodecID id); + + /** +- * Finds an decoder with the specified name. ++ * Finds a registered decoder with the specified name. + * + * @param name name of the requested decoder + * @return A decoder if one was found, NULL otherwise. +@@ -2563,7 +2619,7 @@ + */ + attribute_deprecated int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples, + int *frame_size_ptr, +- uint8_t *buf, int buf_size); ++ const uint8_t *buf, int buf_size); + + /** + * Decodes an audio frame from \p buf into \p samples. +@@ -2603,7 +2659,7 @@ + */ + int avcodec_decode_audio2(AVCodecContext *avctx, int16_t *samples, + int *frame_size_ptr, +- uint8_t *buf, int buf_size); ++ const uint8_t *buf, int buf_size); + + /** + * Decodes a video frame from \p buf into \p picture. +@@ -2638,7 +2694,7 @@ + */ + int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture, + int *got_picture_ptr, +- uint8_t *buf, int buf_size); ++ const uint8_t *buf, int buf_size); + + /* Decode a subtitle message. Return -1 if error, otherwise return the + * number of bytes used. If no subtitle could be decompressed, +@@ -2663,8 +2719,10 @@ + * @param[out] buf the output buffer + * @param[in] buf_size the output buffer size + * @param[in] samples the input buffer containing the samples +- * @return On error a negative value is returned, on succes zero or the number +- * of bytes used from the input buffer. ++ * The number of samples read from this buffer is frame_size*channels, ++ * both of which are defined in \p avctx. ++ * @return On error a negative value is returned, on success zero or the number ++ * of bytes used to encode the data read from the input buffer. + */ + int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size, + const short *samples); +@@ -2771,7 +2829,10 @@ + struct AVCodecParser *next; + } AVCodecParser; + ++#if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0) + extern AVCodecParser *av_first_parser; ++#endif ++AVCodecParser *av_parser_next(AVCodecParser *c); + + void av_register_codec_parser(AVCodecParser *parser); + AVCodecParserContext *av_parser_init(int codec_id); +@@ -2814,6 +2875,7 @@ + const uint8_t *buf, int buf_size, int keyframe); + void av_bitstream_filter_close(AVBitStreamFilterContext *bsf); + ++AVBitStreamFilter *av_bitstream_filter_next(AVBitStreamFilter *f); + + /* memory */ + +@@ -2932,4 +2994,4 @@ + #define AVERROR_NOENT AVERROR(ENOENT) /**< No such file or directory. */ + #define AVERROR_PATCHWELCOME -MKTAG('P','A','W','E') /**< Not yet implemented in FFmpeg. Patches welcome. */ + +-#endif /* AVCODEC_H */ ++#endif /* FFMPEG_AVCODEC_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/avs.c ffmpeg-free-0.svn20080206/libavcodec/avs.c +--- mplayer-1.0~rc2-12/libavcodec/avs.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/avs.c 2008-03-20 19:10:57.000000000 +0100 +@@ -44,12 +44,13 @@ + + static int + avs_decode_frame(AVCodecContext * avctx, +- void *data, int *data_size, uint8_t * buf, int buf_size) ++ void *data, int *data_size, const uint8_t * buf, int buf_size) + { + avs_context_t *const avs = avctx->priv_data; + AVFrame *picture = data; + AVFrame *const p = (AVFrame *) & avs->picture; +- uint8_t *table, *vect, *out; ++ const uint8_t *table, *vect; ++ uint8_t *out; + int i, j, x, y, stride, vect_w = 3, vect_h = 3; + int sub_type; + avs_block_type_t type; +diff -u mplayer-1.0~rc2-12/libavcodec/bethsoftvideo.c ffmpeg-free-0.svn20080206/libavcodec/bethsoftvideo.c +--- mplayer-1.0~rc2-12/libavcodec/bethsoftvideo.c 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/bethsoftvideo.c 2008-03-20 19:10:57.000000000 +0100 +@@ -46,7 +46,7 @@ + return 0; + } + +-static void set_palette(AVFrame * frame, uint8_t * palette_buffer) ++static void set_palette(AVFrame * frame, const uint8_t * palette_buffer) + { + uint32_t * palette = (uint32_t *)frame->data[1]; + int a; +@@ -58,7 +58,7 @@ + + static int bethsoftvid_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + BethsoftvidContext * vid = avctx->priv_data; + char block_type; +diff -u mplayer-1.0~rc2-12/libavcodec/bethsoftvideo.h ffmpeg-free-0.svn20080206/libavcodec/bethsoftvideo.h +--- mplayer-1.0~rc2-12/libavcodec/bethsoftvideo.h 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/bethsoftvideo.h 2007-10-17 11:37:46.000000000 +0200 +@@ -19,8 +19,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef AVCODEC_BETHSOFTVIDEO_H +-#define AVCODEC_BETHSOFTVIDEO_H ++#ifndef FFMPEG_BETHSOFTVIDEO_H ++#define FFMPEG_BETHSOFTVIDEO_H + + enum BethsoftVidBlockType + { +@@ -33,4 +33,4 @@ + EOF_BLOCK = 0x14, + }; + +-#endif // AVCODEC_BETHSOFTVIDEO_H ++#endif /* FFMPEG_BETHSOFTVIDEO_H */ +Common subdirectories: mplayer-1.0~rc2-12/libavcodec/bfin and ffmpeg-free-0.svn20080206/libavcodec/bfin +diff -u mplayer-1.0~rc2-12/libavcodec/bitstream.c ffmpeg-free-0.svn20080206/libavcodec/bitstream.c +--- mplayer-1.0~rc2-12/libavcodec/bitstream.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/bitstream.c 2008-03-20 19:10:57.000000000 +0100 +@@ -50,7 +50,7 @@ + #endif + } + +-void ff_put_string(PutBitContext * pbc, char *s, int put_zero) ++void ff_put_string(PutBitContext * pbc, const char *s, int put_zero) + { + while(*s){ + put_bits(pbc, 8, *s); +@@ -60,9 +60,9 @@ + put_bits(pbc, 8, 0); + } + +-void ff_copy_bits(PutBitContext *pb, uint8_t *src, int length) ++void ff_copy_bits(PutBitContext *pb, const uint8_t *src, int length) + { +- const uint16_t *srcw= (uint16_t*)src; ++ const uint16_t *srcw= (const uint16_t*)src; + int words= length>>4; + int bits= length&15; + int i; +diff -u mplayer-1.0~rc2-12/libavcodec/bitstream_filter.c ffmpeg-free-0.svn20080206/libavcodec/bitstream_filter.c +--- mplayer-1.0~rc2-12/libavcodec/bitstream_filter.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/bitstream_filter.c 2008-03-20 19:10:57.000000000 +0100 +@@ -22,6 +22,11 @@ + + AVBitStreamFilter *first_bitstream_filter= NULL; + ++AVBitStreamFilter *av_bitstream_filter_next(AVBitStreamFilter *f){ ++ if(f) return f->next; ++ else return first_bitstream_filter; ++} ++ + void av_register_bitstream_filter(AVBitStreamFilter *bsf){ + bsf->next = first_bitstream_filter; + first_bitstream_filter= bsf; +diff -u mplayer-1.0~rc2-12/libavcodec/bitstream.h ffmpeg-free-0.svn20080206/libavcodec/bitstream.h +--- mplayer-1.0~rc2-12/libavcodec/bitstream.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/bitstream.h 2008-02-04 01:49:14.000000000 +0100 +@@ -23,8 +23,8 @@ + * bitstream api header. + */ + +-#ifndef BITSTREAM_H +-#define BITSTREAM_H ++#ifndef FFMPEG_BITSTREAM_H ++#define FFMPEG_BITSTREAM_H + + #include + #include +@@ -137,8 +137,8 @@ + } + + void align_put_bits(PutBitContext *s); +-void ff_put_string(PutBitContext * pbc, char *s, int put_zero); +-void ff_copy_bits(PutBitContext *pb, uint8_t *src, int length); ++void ff_put_string(PutBitContext * pbc, const char *s, int put_zero); ++void ff_copy_bits(PutBitContext *pb, const uint8_t *src, int length); + + /* bit input */ + /* buffer, buffer_end and size_in_bits must be present and used by every reader */ +@@ -950,4 +950,11 @@ + return get_bits1(gb) + 1; + } + +-#endif /* BITSTREAM_H */ ++static inline int decode210(GetBitContext *gb){ ++ if (get_bits1(gb)) ++ return 0; ++ else ++ return 2 - get_bits1(gb); ++} ++ ++#endif /* FFMPEG_BITSTREAM_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/bmp.c ffmpeg-free-0.svn20080206/libavcodec/bmp.c +--- mplayer-1.0~rc2-12/libavcodec/bmp.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/bmp.c 2008-03-20 19:10:57.000000000 +0100 +@@ -34,7 +34,7 @@ + + static int bmp_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + BMPContext *s = avctx->priv_data; + AVFrame *picture = data; +@@ -48,7 +48,7 @@ + uint32_t rgb[3]; + uint8_t *ptr; + int dsize; +- uint8_t *buf0 = buf; ++ const uint8_t *buf0 = buf; + + if(buf_size < 14){ + av_log(avctx, AV_LOG_ERROR, "buf size too small (%d)\n", buf_size); +@@ -193,7 +193,7 @@ + break; + case 16: + for(i = 0; i < avctx->height; i++){ +- uint16_t *src = (uint16_t *) buf; ++ const uint16_t *src = (const uint16_t *) buf; + uint16_t *dst = (uint16_t *) ptr; + + for(j = 0; j < avctx->width; j++) +@@ -205,7 +205,7 @@ + break; + case 32: + for(i = 0; i < avctx->height; i++){ +- uint8_t *src = buf; ++ const uint8_t *src = buf; + uint8_t *dst = ptr; + + for(j = 0; j < avctx->width; j++){ +diff -u mplayer-1.0~rc2-12/libavcodec/bmp.h ffmpeg-free-0.svn20080206/libavcodec/bmp.h +--- mplayer-1.0~rc2-12/libavcodec/bmp.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/bmp.h 2007-10-17 11:37:46.000000000 +0200 +@@ -19,8 +19,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef AVCODEC_BMP_H +-#define AVCODEC_BMP_H ++#ifndef FFMPEG_BMP_H ++#define FFMPEG_BMP_H + + #include "avcodec.h" + +@@ -35,4 +35,4 @@ + BMP_BITFIELDS =3, + } BiCompression; + +-#endif // AVCODEC_BMP_H ++#endif /* FFMPEG_BMP_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/bytestream.h ffmpeg-free-0.svn20080206/libavcodec/bytestream.h +--- mplayer-1.0~rc2-12/libavcodec/bytestream.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/bytestream.h 2008-02-01 04:26:31.000000000 +0100 +@@ -25,7 +25,7 @@ + #include "common.h" + + #define DEF_T(type, name, bytes, read, write) \ +-static av_always_inline type bytestream_get_ ## name(uint8_t **b){\ ++static av_always_inline type bytestream_get_ ## name(const uint8_t **b){\ + (*b) += bytes;\ + return read(*b - bytes);\ + }\ +@@ -53,7 +53,7 @@ + #undef DEF64 + #undef DEF_T + +-static av_always_inline unsigned int bytestream_get_buffer(uint8_t **b, uint8_t *dst, unsigned int size) ++static av_always_inline unsigned int bytestream_get_buffer(const uint8_t **b, uint8_t *dst, unsigned int size) + { + memcpy(dst, *b, size); + (*b) += size; +diff -u mplayer-1.0~rc2-12/libavcodec/c93.c ffmpeg-free-0.svn20080206/libavcodec/c93.c +--- mplayer-1.0~rc2-12/libavcodec/c93.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/c93.c 2008-03-20 19:10:57.000000000 +0100 +@@ -113,7 +113,7 @@ + } + + static int decode_frame(AVCodecContext *avctx, void *data, +- int *data_size, uint8_t * buf, int buf_size) ++ int *data_size, const uint8_t * buf, int buf_size) + { + C93DecoderContext * const c93 = avctx->priv_data; + AVFrame * const newpic = &c93->pictures[c93->currentpic]; +@@ -144,7 +144,7 @@ + + if (*buf++ & C93_HAS_PALETTE) { + uint32_t *palette = (uint32_t *) newpic->data[1]; +- uint8_t *palbuf = buf + buf_size - 768 - 1; ++ const uint8_t *palbuf = buf + buf_size - 768 - 1; + for (i = 0; i < 256; i++) { + palette[i] = bytestream_get_be24(&palbuf); + } +diff -u mplayer-1.0~rc2-12/libavcodec/cabac.c ffmpeg-free-0.svn20080206/libavcodec/cabac.c +--- mplayer-1.0~rc2-12/libavcodec/cabac.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/cabac.c 2008-03-20 19:10:57.000000000 +0100 +@@ -178,13 +178,14 @@ + } + } + +-#if 0 //selftest ++#ifdef TEST + #undef random + #define SIZE 10240 + + #include "avcodec.h" ++#include "cabac.h" + +-int main(){ ++int main(void){ + CABACContext c; + uint8_t b[9*SIZE]; + uint8_t r[9*SIZE]; +@@ -192,7 +193,7 @@ + uint8_t state[10]= {0}; + + ff_init_cabac_encoder(&c, b, SIZE); +- ff_init_cabac_states(&c, ff_h264_lps_range, ff_h264_mps_state, ff_h264_lps_state, 64); ++ ff_init_cabac_states(&c); + + for(i=0; irange&0xC0) + *state]; + +@@ -259,6 +260,7 @@ + put_cabac_bypass(c, sign); + } + } ++#endif /* TEST */ + + static void refill(CABACContext *c){ + #if CABAC_BITS == 16 +@@ -270,6 +272,7 @@ + c->bytestream+= CABAC_BITS/8; + } + ++#if ! ( defined(ARCH_X86) && defined(HAVE_7REGS) && defined(HAVE_EBX_AVAILABLE) && !defined(BROKEN_RELOCATIONS) ) + static void refill2(CABACContext *c){ + int i, x; + +@@ -287,6 +290,7 @@ + c->low += x<bytestream+= CABAC_BITS/8; + } ++#endif + + static inline void renorm_cabac_decoder(CABACContext *c){ + while(c->range < 0x100){ +@@ -734,7 +738,7 @@ + return coeff_count; + } + +-static int decode_significance_8x8_x86(CABACContext *c, uint8_t *significant_coeff_ctx_base, int *index, uint8_t *sig_off){ ++static int decode_significance_8x8_x86(CABACContext *c, uint8_t *significant_coeff_ctx_base, int *index, const uint8_t *sig_off){ + int minusindex= 4-(int)index; + int coeff_count; + long last=0; +@@ -805,6 +809,7 @@ + } + } + ++#if 0 + /** + * Get (truncated) unary binarization. + */ +@@ -860,5 +865,6 @@ + }else + return i; + } ++#endif /* 0 */ + +-#endif /* CABAC_H */ ++#endif /* FFMPEG_CABAC_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/cavsdata.h ffmpeg-free-0.svn20080206/libavcodec/cavsdata.h +--- mplayer-1.0~rc2-12/libavcodec/cavsdata.h 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/cavsdata.h 2007-10-17 11:37:46.000000000 +0200 +@@ -19,8 +19,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef AVCODEC_CAVSDATA_H +-#define AVCODEC_CAVSDATA_H ++#ifndef FFMPEG_CAVSDATA_H ++#define FFMPEG_CAVSDATA_H + + #include "cavs.h" + +@@ -502,4 +502,4 @@ + const int_fast8_t ff_left_modifier_c[7] = { 5,-1, 2,-1, 6, 5, 6}; + const int_fast8_t ff_top_modifier_c[7] = { 4, 1,-1,-1, 4, 6, 6}; + +-#endif // AVCODEC_CAVSDATA_H ++#endif /* FFMPEG_CAVSDATA_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/cavsdec.c ffmpeg-free-0.svn20080206/libavcodec/cavsdec.c +--- mplayer-1.0~rc2-12/libavcodec/cavsdec.c 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/cavsdec.c 2008-03-20 19:10:57.000000000 +0100 +@@ -614,7 +614,7 @@ + } + + static int cavs_decode_frame(AVCodecContext * avctx,void *data, int *data_size, +- uint8_t * buf, int buf_size) { ++ const uint8_t * buf, int buf_size) { + AVSContext *h = avctx->priv_data; + MpegEncContext *s = &h->s; + int input_size; +diff -u mplayer-1.0~rc2-12/libavcodec/cavs.h ffmpeg-free-0.svn20080206/libavcodec/cavs.h +--- mplayer-1.0~rc2-12/libavcodec/cavs.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/cavs.h 2007-10-17 11:37:46.000000000 +0200 +@@ -19,8 +19,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef CAVS_H +-#define CAVS_H ++#ifndef FFMPEG_CAVS_H ++#define FFMPEG_CAVS_H + + #include "dsputil.h" + #include "mpegvideo.h" +@@ -311,4 +311,4 @@ + int ff_cavs_init(AVCodecContext *avctx); + int ff_cavs_end (AVCodecContext *avctx); + +-#endif /* CAVS_H */ ++#endif /* FFMPEG_CAVS_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/cinepak.c ffmpeg-free-0.svn20080206/libavcodec/cinepak.c +--- mplayer-1.0~rc2-12/libavcodec/cinepak.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/cinepak.c 2008-03-20 19:10:57.000000000 +0100 +@@ -59,7 +59,7 @@ + DSPContext dsp; + AVFrame frame; + +- unsigned char *data; ++ const unsigned char *data; + int size; + + int width, height; +@@ -72,9 +72,9 @@ + } CinepakContext; + + static void cinepak_decode_codebook (cvid_codebook_t *codebook, +- int chunk_id, int size, uint8_t *data) ++ int chunk_id, int size, const uint8_t *data) + { +- uint8_t *eod = (data + size); ++ const uint8_t *eod = (data + size); + uint32_t flag, mask; + int i, n; + +@@ -121,9 +121,9 @@ + } + + static int cinepak_decode_vectors (CinepakContext *s, cvid_strip_t *strip, +- int chunk_id, int size, uint8_t *data) ++ int chunk_id, int size, const uint8_t *data) + { +- uint8_t *eod = (data + size); ++ const uint8_t *eod = (data + size); + uint32_t flag, mask; + cvid_codebook_t *codebook; + unsigned int x, y; +@@ -264,9 +264,9 @@ + } + + static int cinepak_decode_strip (CinepakContext *s, +- cvid_strip_t *strip, uint8_t *data, int size) ++ cvid_strip_t *strip, const uint8_t *data, int size) + { +- uint8_t *eod = (data + size); ++ const uint8_t *eod = (data + size); + int chunk_id, chunk_size; + + /* coordinate sanity checks */ +@@ -317,7 +317,7 @@ + + static int cinepak_decode (CinepakContext *s) + { +- uint8_t *eod = (s->data + s->size); ++ const uint8_t *eod = (s->data + s->size); + int i, result, strip_size, frame_flags, num_strips; + int y0 = 0; + int encoded_buf_size; +@@ -414,7 +414,7 @@ + + static int cinepak_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + CinepakContext *s = avctx->priv_data; + +diff -u mplayer-1.0~rc2-12/libavcodec/cljr.c ffmpeg-free-0.svn20080206/libavcodec/cljr.c +--- mplayer-1.0~rc2-12/libavcodec/cljr.c 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/cljr.c 2008-03-20 19:10:57.000000000 +0100 +@@ -37,7 +37,7 @@ + + static int decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + CLJRContext * const a = avctx->priv_data; + AVFrame *picture = data; +diff -u mplayer-1.0~rc2-12/libavcodec/colorspace.h ffmpeg-free-0.svn20080206/libavcodec/colorspace.h +--- mplayer-1.0~rc2-12/libavcodec/colorspace.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/colorspace.h 2007-10-17 11:31:06.000000000 +0200 +@@ -24,6 +24,9 @@ + * Various defines for YUV<->RGB conversion + */ + ++#ifndef FFMPEG_COLORSPACE_H ++#define FFMPEG_COLORSPACE_H ++ + #define SCALEBITS 10 + #define ONE_HALF (1 << (SCALEBITS - 1)) + #define FIX(x) ((int) ((x) * (1<> (SCALEBITS + shift)) + 128) + ++#endif /* FFMPEG_COLORSPACE_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/cook.c ffmpeg-free-0.svn20080206/libavcodec/cook.c +--- mplayer-1.0~rc2-12/libavcodec/cook.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/cook.c 2008-03-20 19:10:57.000000000 +0100 +@@ -145,7 +145,7 @@ + float decode_buffer_2[1024]; + float decode_buffer_0[1060]; /* static allocation for joint decode */ + +- float *cplscales[5]; ++ const float *cplscales[5]; + } COOKContext; + + /* debug functions */ +@@ -264,7 +264,7 @@ + return 0; + } + +-static float *maybe_reformat_buffer32 (COOKContext *q, float *ptr, int n) ++static const float *maybe_reformat_buffer32 (COOKContext *q, const float *ptr, int n) + { + if (1) + return ptr; +@@ -301,10 +301,10 @@ + #define DECODE_BYTES_PAD1(bytes) (3 - ((bytes)+3) % 4) + #define DECODE_BYTES_PAD2(bytes) ((bytes) % 4 + DECODE_BYTES_PAD1(2 * (bytes))) + +-static inline int decode_bytes(uint8_t* inbuffer, uint8_t* out, int bytes){ ++static inline int decode_bytes(const uint8_t* inbuffer, uint8_t* out, int bytes){ + int i, off; + uint32_t c; +- uint32_t* buf; ++ const uint32_t* buf; + uint32_t* obuf = (uint32_t*) out; + /* FIXME: 64 bit platforms would be able to do 64 bits at a time. + * I'm too lazy though, should be something like +@@ -313,7 +313,7 @@ + * Buffer alignment needs to be checked. */ + + off = (int)((long)inbuffer & 3); +- buf = (uint32_t*) (inbuffer - off); ++ buf = (const uint32_t*) (inbuffer - off); + c = be2me_32((0x37c511f2 >> (off*8)) | (0x37c511f2 << (32-(off*8)))); + bytes += 3 + off; + for (i = 0; i < bytes/4; i++) +@@ -832,7 +832,7 @@ + float *decode_buffer = q->decode_buffer_0; + int idx, cpl_tmp; + float f1,f2; +- float* cplscale; ++ const float* cplscale; + + memset(decouple_tab, 0, sizeof(decouple_tab)); + memset(decode_buffer, 0, sizeof(decode_buffer)); +@@ -875,7 +875,7 @@ + */ + + static inline void +-decode_bytes_and_gain(COOKContext *q, uint8_t *inbuffer, ++decode_bytes_and_gain(COOKContext *q, const uint8_t *inbuffer, + cook_gains *gains_ptr) + { + int offset; +@@ -944,7 +944,7 @@ + */ + + +-static int decode_subpacket(COOKContext *q, uint8_t *inbuffer, ++static int decode_subpacket(COOKContext *q, const uint8_t *inbuffer, + int sub_packet_size, int16_t *outbuffer) { + /* packet dump */ + // for (i=0 ; ipriv_data; + + if (buf_size < avctx->block_align) +@@ -1038,7 +1038,7 @@ + static int cook_decode_init(AVCodecContext *avctx) + { + COOKContext *q = avctx->priv_data; +- uint8_t *edata_ptr = avctx->extradata; ++ const uint8_t *edata_ptr = avctx->extradata; + + /* Take care of the codec specific extradata. */ + if (avctx->extradata_size <= 0) { +diff -u mplayer-1.0~rc2-12/libavcodec/cookdata.h ffmpeg-free-0.svn20080206/libavcodec/cookdata.h +--- mplayer-1.0~rc2-12/libavcodec/cookdata.h 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/cookdata.h 2007-10-17 11:37:46.000000000 +0200 +@@ -25,8 +25,8 @@ + * Cook AKA RealAudio G2 compatible decoderdata + */ + +-#ifndef AVCODEC_COOKDATA_H +-#define AVCODEC_COOKDATA_H ++#ifndef FFMPEG_COOKDATA_H ++#define FFMPEG_COOKDATA_H + + #include + +@@ -562,4 +562,4 @@ + cplscale2, cplscale3, cplscale4, cplscale5, cplscale6, + }; + +-#endif // AVCODEC_COOKDATA_H ++#endif /* FFMPEG_COOKDATA_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/cscd.c ffmpeg-free-0.svn20080206/libavcodec/cscd.c +--- mplayer-1.0~rc2-12/libavcodec/cscd.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/cscd.c 2008-03-20 19:10:57.000000000 +0100 +@@ -35,7 +35,7 @@ + unsigned char* decomp_buf; + } CamStudioContext; + +-static void copy_frame_default(AVFrame *f, uint8_t *src, ++static void copy_frame_default(AVFrame *f, const uint8_t *src, + int linelen, int height) { + int i; + uint8_t *dst = f->data[0]; +@@ -47,7 +47,7 @@ + } + } + +-static void add_frame_default(AVFrame *f, uint8_t *src, ++static void add_frame_default(AVFrame *f, const uint8_t *src, + int linelen, int height) { + int i, j; + uint8_t *dst = f->data[0]; +@@ -65,7 +65,7 @@ + #define add_frame_16 add_frame_default + #define add_frame_32 add_frame_default + #else +-static void copy_frame_16(AVFrame *f, uint8_t *src, ++static void copy_frame_16(AVFrame *f, const uint8_t *src, + int linelen, int height) { + int i, j; + uint8_t *dst = f->data[0]; +@@ -81,7 +81,7 @@ + } + } + +-static void copy_frame_32(AVFrame *f, uint8_t *src, ++static void copy_frame_32(AVFrame *f, const uint8_t *src, + int linelen, int height) { + int i, j; + uint8_t *dst = f->data[0]; +@@ -99,7 +99,7 @@ + } + } + +-static void add_frame_16(AVFrame *f, uint8_t *src, ++static void add_frame_16(AVFrame *f, const uint8_t *src, + int linelen, int height) { + int i, j; + uint8_t *dst = f->data[0]; +@@ -115,7 +115,7 @@ + } + } + +-static void add_frame_32(AVFrame *f, uint8_t *src, ++static void add_frame_32(AVFrame *f, const uint8_t *src, + int linelen, int height) { + int i, j; + uint8_t *dst = f->data[0]; +@@ -135,7 +135,7 @@ + #endif + + static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, +- uint8_t *buf, int buf_size) { ++ const uint8_t *buf, int buf_size) { + CamStudioContext *c = avctx->priv_data; + AVFrame *picture = data; + +diff -u mplayer-1.0~rc2-12/libavcodec/cyuv.c ffmpeg-free-0.svn20080206/libavcodec/cyuv.c +--- mplayer-1.0~rc2-12/libavcodec/cyuv.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/cyuv.c 2008-03-20 19:10:57.000000000 +0100 +@@ -61,7 +61,7 @@ + + static int cyuv_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + CyuvDecodeContext *s=avctx->priv_data; + +@@ -73,9 +73,9 @@ + int v_ptr; + + /* prediction error tables (make it clear that they are signed values) */ +- signed char *y_table = (signed char*)buf + 0; +- signed char *u_table = (signed char*)buf + 16; +- signed char *v_table = (signed char*)buf + 32; ++ const signed char *y_table = (const signed char*)buf + 0; ++ const signed char *u_table = (const signed char*)buf + 16; ++ const signed char *v_table = (const signed char*)buf + 32; + + unsigned char y_pred, u_pred, v_pred; + int stream_ptr; +diff -u mplayer-1.0~rc2-12/libavcodec/dca.c ffmpeg-free-0.svn20080206/libavcodec/dca.c +--- mplayer-1.0~rc2-12/libavcodec/dca.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/dca.c 2008-03-20 19:10:57.000000000 +0100 +@@ -453,15 +453,15 @@ + } + + for (j = 0; j < s->prim_channels; j++) { +- uint32_t *scale_table; ++ const uint32_t *scale_table; + int scale_sum; + + memset(s->scale_factor[j], 0, s->subband_activity[j] * sizeof(s->scale_factor[0][0][0]) * 2); + + if (s->scalefactor_huffman[j] == 6) +- scale_table = (uint32_t *) scale_factor_quant7; ++ scale_table = scale_factor_quant7; + else +- scale_table = (uint32_t *) scale_factor_quant6; ++ scale_table = scale_factor_quant6; + + /* When huffman coded, only the difference is encoded */ + scale_sum = 0; +@@ -646,7 +646,7 @@ + float samples_in[32][8], float *samples_out, + float scale, float bias) + { +- float *prCoeff; ++ const float *prCoeff; + int i, j, k; + float praXin[33], *raXin = &praXin[1]; + +@@ -659,9 +659,9 @@ + + /* Select filter */ + if (!s->multirate_inter) /* Non-perfect reconstruction */ +- prCoeff = (float *) fir_32bands_nonperfect; ++ prCoeff = fir_32bands_nonperfect; + else /* Perfect reconstruction */ +- prCoeff = (float *) fir_32bands_perfect; ++ prCoeff = fir_32bands_perfect; + + /* Reconstructed channel sample index */ + for (subindex = 0; subindex < 8; subindex++) { +@@ -842,7 +842,7 @@ + int k, l; + int subsubframe = s->current_subsubframe; + +- float *quant_step_table; ++ const float *quant_step_table; + + /* FIXME */ + float subband_samples[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS][8]; +@@ -853,9 +853,9 @@ + + /* Select quantization step size table */ + if (s->bit_rate == 0x1f) +- quant_step_table = (float *) lossless_quant_d; ++ quant_step_table = lossless_quant_d; + else +- quant_step_table = (float *) lossy_quant_d; ++ quant_step_table = lossy_quant_d; + + for (k = 0; k < s->prim_channels; k++) { + for (l = 0; l < s->vq_start_subband[k]; l++) { +@@ -1001,7 +1001,7 @@ + s->lfe_data + lfe_samples + + 2 * s->lfe * subsubframe, + &s->samples[256 * i_channels], +- 8388608.0, s->bias); ++ 256.0, 0 /* s->bias */); + /* Outputs 20bits pcm samples */ + } + +@@ -1091,12 +1091,13 @@ + /** + * Convert bitstream to one representation based on sync marker + */ +-static int dca_convert_bitstream(uint8_t * src, int src_size, uint8_t * dst, ++static int dca_convert_bitstream(const uint8_t * src, int src_size, uint8_t * dst, + int max_size) + { + uint32_t mrk; + int i, tmp; +- uint16_t *ssrc = (uint16_t *) src, *sdst = (uint16_t *) dst; ++ const uint16_t *ssrc = (const uint16_t *) src; ++ uint16_t *sdst = (uint16_t *) dst; + PutBitContext pb; + + if((unsigned)src_size > (unsigned)max_size) { +@@ -1133,7 +1134,7 @@ + */ + static int dca_decode_frame(AVCodecContext * avctx, + void *data, int *data_size, +- uint8_t * buf, int buf_size) ++ const uint8_t * buf, int buf_size) + { + + int i, j, k; +@@ -1159,23 +1160,12 @@ + avctx->bit_rate = s->bit_rate; + + channels = s->prim_channels + !!s->lfe; +- avctx->channels = avctx->request_channels; +- if(avctx->channels == 0) { +- avctx->channels = channels; +- } else if(channels < avctx->channels) { +- av_log(avctx, AV_LOG_WARNING, "DTS source channels are less than " +- "specified: output to %d channels.\n", channels); +- avctx->channels = channels; +- } +- if(avctx->channels == 2) { ++ if(avctx->request_channels == 2 && s->prim_channels > 2) { ++ channels = 2; + s->output = DCA_STEREO; +- } else if(avctx->channels != channels) { +- av_log(avctx, AV_LOG_ERROR, "Cannot downmix DTS to %d channels.\n", +- avctx->channels); +- return -1; + } + +- channels = avctx->channels; ++ avctx->channels = channels; + if(*data_size < (s->sample_blocks / 8) * 256 * sizeof(int16_t) * channels) + return -1; + *data_size = 0; +@@ -1241,6 +1231,13 @@ + pre_calc_cosmod(s); + + dsputil_init(&s->dsp, avctx); ++ ++ /* allow downmixing to stereo */ ++ if (avctx->channels > 0 && avctx->request_channels < avctx->channels && ++ avctx->request_channels == 2) { ++ avctx->channels = avctx->request_channels; ++ } ++ + return 0; + } + +diff -u mplayer-1.0~rc2-12/libavcodec/dcadata.h ffmpeg-free-0.svn20080206/libavcodec/dcadata.h +--- mplayer-1.0~rc2-12/libavcodec/dcadata.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/dcadata.h 2007-12-02 23:04:21.000000000 +0100 +@@ -24,8 +24,8 @@ + * @file dcadata.c + */ + +-#ifndef AVCODEC_DCADATA_H +-#define AVCODEC_DCADATA_H ++#ifndef FFMPEG_DCADATA_H ++#define FFMPEG_DCADATA_H + + #include + +@@ -7314,7 +7314,7 @@ + +1.390191784E-007 + }; + +-//FIXME the coeffs are symetric ++//FIXME the coeffs are symmetric + static const float lfe_fir_64[] = + { + 2.6584343868307770E-004, +@@ -7831,7 +7831,7 @@ + 2.6584343868307770E-004 + }; + +-//FIXME the coeffs are symetric ++//FIXME the coeffs are symmetric + + static const float lfe_fir_128[] = + { +@@ -8349,7 +8349,7 @@ + 0.00053168571 + }; + +-/* 10^-(dB/20), with dB beeing a list of dB values rangeing from 0 to -72 */ ++/* 10^-(dB/20), with dB being a list of dB values ranging from 0 to -72 */ + /* do a 20*log10(dca_downmix_coeffs) to reconvert the values */ + + static const float dca_downmix_coeffs[65] = { +@@ -8471,4 +8471,4 @@ + + */ + +-#endif // AVCODEC_DCADATA_H ++#endif /* FFMPEG_DCADATA_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/dca.h ffmpeg-free-0.svn20080206/libavcodec/dca.h +--- mplayer-1.0~rc2-12/libavcodec/dca.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/dca.h 2007-10-17 11:37:46.000000000 +0200 +@@ -22,8 +22,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef AVCODEC_DCA_H +-#define AVCODEC_DCA_H ++#ifndef FFMPEG_DCA_H ++#define FFMPEG_DCA_H + + /** DCA syncwords, also used for bitstream type detection */ + #define DCA_MARKER_RAW_BE 0x7FFE8001 +@@ -31,4 +31,4 @@ + #define DCA_MARKER_14B_BE 0x1FFFE800 + #define DCA_MARKER_14B_LE 0xFF1F00E8 + +-#endif // AVCODEC_DCA_H ++#endif /* FFMPEG_DCA_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/dcahuff.h ffmpeg-free-0.svn20080206/libavcodec/dcahuff.h +--- mplayer-1.0~rc2-12/libavcodec/dcahuff.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/dcahuff.h 2007-10-17 11:37:46.000000000 +0200 +@@ -20,8 +20,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef AVCODEC_DCAHUFF_H +-#define AVCODEC_DCAHUFF_H ++#ifndef FFMPEG_DCAHUFF_H ++#define FFMPEG_DCAHUFF_H + + #include + #include +@@ -1073,4 +1073,4 @@ + bitalloc_129_bits_e, bitalloc_129_bits_f, bitalloc_129_bits_g, NULL } + }; + +-#endif // AVCODEC_DCAHUFF_H ++#endif /* FFMPEG_DCAHUFF_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/dct-test.c ffmpeg-free-0.svn20080206/libavcodec/dct-test.c +--- mplayer-1.0~rc2-12/libavcodec/dct-test.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/dct-test.c 2008-03-20 19:10:57.000000000 +0100 +@@ -91,7 +91,7 @@ + DCT_ERROR("IJG-LLM-INT", 0, ff_jpeg_fdct_islow, fdct, NO_PERM), + DCT_ERROR("REF-DBL", 1, idct, idct, NO_PERM), + DCT_ERROR("INT", 1, j_rev_dct, idct, MMX_PERM), +- DCT_ERROR("SIMPLE-C", 1, simple_idct, idct, NO_PERM), ++ DCT_ERROR("SIMPLE-C", 1, ff_simple_idct, idct, NO_PERM), + + #ifdef HAVE_MMX + DCT_ERROR("MMX", 0, ff_fdct_mmx, fdct, NO_PERM), +@@ -559,7 +559,7 @@ + printf("ffmpeg DCT/IDCT test\n"); + + if (test_248_dct) { +- idct248_error("SIMPLE-C", simple_idct248_put); ++ idct248_error("SIMPLE-C", ff_simple_idct248_put); + } else { + for (i=0;algos[i].name;i++) + if (algos[i].is_idct == test_idct) { +diff -u mplayer-1.0~rc2-12/libavcodec/dnxhddata.c ffmpeg-free-0.svn20080206/libavcodec/dnxhddata.c +--- mplayer-1.0~rc2-12/libavcodec/dnxhddata.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/dnxhddata.c 2008-03-20 19:10:57.000000000 +0100 +@@ -19,9 +19,10 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + ++#include "avcodec.h" + #include "dnxhddata.h" + +-static const uint8_t dnxhd_1237_luma_weigth[] = { ++static const uint8_t dnxhd_1237_luma_weight[] = { + 0, 32, 33, 34, 34, 36, 37, 36, + 36, 37, 38, 38, 38, 39, 41, 44, + 43, 41, 40, 41, 46, 49, 47, 46, +@@ -32,7 +33,7 @@ + 97, 100, 104, 102, 98, 98, 99, 99, + }; + +-static const uint8_t dnxhd_1237_chroma_weigth[] = { ++static const uint8_t dnxhd_1237_chroma_weight[] = { + 0, 32, 36, 39, 39, 38, 39, 41, + 45, 51, 57, 58, 53, 48, 47, 51, + 55, 58, 66, 75, 81, 83, 82, 78, +@@ -43,7 +44,7 @@ + 97, 100, 104, 102, 98, 98, 99, 99, + }; + +-static const uint8_t dnxhd_1238_luma_weigth[] = { ++static const uint8_t dnxhd_1238_luma_weight[] = { + 0, 32, 32, 33, 34, 33, 33, 33, + 33, 33, 33, 33, 33, 35, 37, 37, + 36, 36, 35, 36, 38, 38, 36, 35, +@@ -54,7 +55,7 @@ + 51, 53, 55, 57, 58, 59, 57, 57, + }; + +-static const uint8_t dnxhd_1238_chroma_weigth[] = { ++static const uint8_t dnxhd_1238_chroma_weight[] = { + 0, 32, 35, 35, 35, 34, 34, 35, + 39, 43, 45, 45, 41, 39, 40, 41, + 42, 44, 48, 55, 59, 63, 65, 59, +@@ -65,7 +66,29 @@ + 82, 77, 80, 86, 84, 82, 82, 82, + }; + +-static const uint8_t dnxhd_1242_luma_weigth[] = { ++static const uint8_t dnxhd_1241_luma_weight[] = { ++ 0, 32, 33, 34, 34, 35, 36, 37, ++ 36, 37, 38, 38, 38, 39, 39, 40, ++ 40, 38, 38, 39, 38, 37, 39, 41, ++ 41, 42, 43, 45, 45, 46, 47, 46, ++ 45, 43, 39, 37, 37, 40, 44, 45, ++ 45, 46, 46, 46, 47, 47, 46, 44, ++ 42, 43, 45, 47, 48, 49, 50, 49, ++ 48, 46, 47, 48, 48, 49, 49, 49, ++}; ++ ++static const uint8_t dnxhd_1241_chroma_weight[] = { ++ 0, 32, 36, 38, 37, 37, 40, 41, ++ 40, 40, 42, 42, 41, 41, 41, 41, ++ 42, 43, 44, 44, 45, 46, 46, 45, ++ 44, 45, 45, 45, 45, 46, 47, 46, ++ 45, 44, 42, 41, 43, 45, 45, 47, ++ 48, 48, 48, 46, 47, 47, 46, 47, ++ 46, 45, 45, 47, 48, 49, 50, 49, ++ 48, 46, 48, 49, 48, 49, 49, 49, ++}; ++ ++static const uint8_t dnxhd_1242_luma_weight[] = { + 0, 32, 33, 33, 34, 35, 36, 35, + 33, 33, 35, 36, 37, 37, 38, 37, + 37, 37, 36, 37, 37, 37, 38, 39, +@@ -76,7 +99,7 @@ + 49, 51, 52, 51, 49, 47, 47, 47, + }; + +-static const uint8_t dnxhd_1242_chroma_weigth[] = { ++static const uint8_t dnxhd_1242_chroma_weight[] = { + 0, 32, 37, 42, 45, 45, 45, 44, + 38, 37, 40, 42, 44, 49, 51, 47, + 41, 40, 43, 44, 46, 48, 51, 54, +@@ -87,7 +110,7 @@ + 55, 59, 63, 62, 60, 60, 60, 60, + }; + +-static const uint8_t dnxhd_1243_luma_weigth[] = { ++static const uint8_t dnxhd_1243_luma_weight[] = { + 0, 32, 32, 33, 33, 35, 35, 35, + 35, 35, 35, 35, 34, 35, 38, 40, + 39, 37, 37, 37, 36, 35, 36, 38, +@@ -98,7 +121,7 @@ + 46, 44, 45, 47, 47, 48, 47, 47, + }; + +-static const uint8_t dnxhd_1243_chroma_weigth[] = { ++static const uint8_t dnxhd_1243_chroma_weight[] = { + 0, 32, 36, 37, 36, 37, 39, 39, + 41, 43, 43, 42, 41, 41, 41, 42, + 43, 43, 43, 44, 44, 44, 46, 47, +@@ -109,6 +132,49 @@ + 46, 45, 46, 47, 47, 48, 47, 47, + }; + ++static const uint8_t dnxhd_1251_luma_weight[] = { ++ 0, 32, 32, 34, 34, 34, 34, 35, ++ 35, 35, 36, 37, 36, 36, 35, 36, ++ 38, 38, 38, 38, 38, 38, 38, 38, ++ 38, 38, 39, 41, 44, 43, 41, 40, ++ 40, 40, 40, 39, 40, 41, 40, 39, ++ 40, 43, 46, 46, 44, 44, 44, 42, ++ 41, 43, 46, 48, 50, 55, 58, 53, ++ 48, 50, 55, 58, 61, 62, 62, 62, ++}; ++ ++static const uint8_t dnxhd_1251_chroma_weight[] = { ++ 0, 32, 35, 36, 36, 35, 36, 39, ++ 41, 43, 45, 44, 41, 39, 40, 42, ++ 43, 43, 45, 48, 48, 48, 50, 50, ++ 50, 51, 51, 51, 51, 52, 53, 54, ++ 51, 49, 51, 52, 52, 56, 57, 55, ++ 54, 54, 55, 56, 55, 58, 58, 58, ++ 60, 61, 62, 62, 59, 57, 58, 58, ++ 61, 59, 59, 59, 61, 62, 62, 62, ++}; ++ ++static const uint8_t dnxhd_1252_luma_weight[] = { ++ 0, 32, 34, 35, 36, 36, 36, 37, ++ 36, 37, 39, 40, 41, 40, 40, 40, ++ 41, 41, 42, 41, 41, 43, 44, 44, ++ 45, 46, 48, 55, 60, 57, 52, 50, ++ 49, 49, 52, 52, 53, 55, 58, 62, ++ 65, 73, 82, 82, 80, 78, 73, 68, ++ 71, 82, 90, 90, 88, 87, 90, 95, ++ 100, 107, 103, 97, 95, 93, 99, 99, ++}; ++static const uint8_t dnxhd_1252_chroma_weight[] = { ++ 0, 32, 35, 36, 37, 37, 38, 40, ++ 42, 46, 49, 50, 50, 49, 49, 53, ++ 56, 56, 57, 58, 60, 62, 64, 65, ++ 63, 64, 64, 65, 66, 65, 67, 71, ++ 72, 74, 74, 74, 74, 77, 81, 78, ++ 72, 73, 82, 85, 89, 88, 84, 80, ++ 90, 100, 90, 90, 88, 87, 90, 95, ++ 114, 128, 125, 129, 134, 125, 116, 116, ++}; ++ + static const uint8_t dnxhd_1237_dc_codes[12] = { + 0, 12, 13, 1, 2, 3, 4, 5, 14, 30, 62, 63, + }; +@@ -189,31 +255,164 @@ + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 20, 21, 17, 18, 19, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, + }; + ++static const uint8_t dnxhd_1241_dc_codes[14] = { ++ 10, 62, 11, 12, 13, 0, 1, 2, 3, 4, 14, 30, 126, 127, ++}; ++ ++static const uint8_t dnxhd_1241_dc_bits[14] = { ++ 4, 6, 4, 4, 4, 3, 3, 3, 3, 3, 4, 5, 7, 7, ++}; ++static const uint16_t dnxhd_1241_ac_codes[257] = { ++ 0, 1, 4, 10, 11, 24, 25, 26, 54, 55, 56, 57, 116, 117, 118, 119, 240, 241, 242, 243, 244, 245, 492, 493, 494, 495, 496, 497, 498, 998, 999, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025, 2026, 4054, 4055, 4056, 4057, 4058, 4059, 4060, 4061, 4062, 4063, 4064, 4065, 4066, 4067, 4068, 4069, 8140, 8141, 8142, 8143, 8144, 8145, 8146, 8147, 8148, 8149, 8150, 8151, 8152, 8153, 8154, 8155, 8156, 8157, 16316, 16317, 16318, 16319, 16320, 16321, 16322, 16323, 16324, 16325, 16326, 16327, 16328, 16329, 16330, 16331, 16332, 16333, 16334, 16335, 16336, 16337, 32676, 32677, 32678, 32679, 32680, 32681, 32682, 32683, 32684, 32685, 32686, 32687, 32688, 32689, 32690, 32691, 32692, 32693, 32694, 32695, 32696, 32697, 32698, 32699, 32700, 32701, 32702, 32703, 32704, 32705, 32706, 32707, 32708, 65418, 65419, 65420, 65421, 65422, 65423, 65424, 65425, 65426, 65427, 65428, 65429, 65430, 65431, 65432, 65433, 65434, 65435, 65436, 65437, 65438, 65439, 65440, 65441, 65442, 65443, 65444, 65445, 65446, 65447, 65448, 65449, 65450, 65451, 65452, 65453, 65454, 65455, 65456, 65457, 65458, 65459, 65460, 65461, 65462, 65463, 65464, 65465, 65466, 65467, 65468, 65469, 65470, 65471, 65472, 65473, 65474, 65475, 65476, 65477, 65478, 65479, 65480, 65481, 65482, 65483, 65484, 65485, 65486, 65487, 65488, 65489, 65490, 65491, 65492, 65493, 65494, 65495, 65496, 65497, 65498, 65499, 65500, 65501, 65502, 65503, 65504, 65505, 65506, 65507, 65508, 65509, 65510, 65511, 65512, 65513, 65514, 65515, 65516, 65517, 65518, 65519, 65520, 65521, 65522, 65523, 65524, 65525, 65526, 65527, 65528, 65529, 65530, 65531, 65532, 65533, 65534, 65535, ++}; ++ ++static const uint8_t dnxhd_1241_ac_bits[257] = { ++ 2, 2, 3, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, ++}; ++ ++static const uint8_t dnxhd_1241_ac_level[257] = { ++ 1, 1, 2, 3, 0, 4, 5, 2, 6, 7, 8, 3, 9, 10, 11, 4, 12, 13, 14, 15, 16, 5, 17, 18, 19, 20, 21, 6, 7, 22, 23, 24, 25, 26, 27, 28, 29, 8, 9, 30, 31, 32, 33, 34, 35, 36, 37, 38, 10, 11, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 12, 13, 14, 15, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 1, 16, 17, 18, 19, 64, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 20, 21, 22, 23, 24, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 25, 26, 27, 28, 29, 30, 31, 32, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, ++}; ++ ++static const uint8_t dnxhd_1241_ac_run_flag[257] = { ++ 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ++}; ++ ++static const uint8_t dnxhd_1241_ac_index_flag[257] = { ++ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ++}; ++ ++static const uint16_t dnxhd_1241_run_codes[62] = { ++ 0, 4, 10, 11, 24, 25, 26, 27, 56, 57, 58, 59, 120, 242, 486, 487, 488, 489, 980, 981, 982, 983, 984, 985, 986, 987, 988, 989, 990, 991, 992, 993, 994, 995, 996, 997, 998, 999, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 1020, 1021, 1022, 1023, ++}; ++ ++static const uint8_t dnxhd_1241_run_bits[62] = { ++ 1, 3, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 7, 8, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, ++}; ++ ++static const uint8_t dnxhd_1241_run[62] = { ++ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 20, 17, 19, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, ++}; ++ ++static const uint8_t dnxhd_1251_dc_codes[12] = { ++ 0, 12, 13, 1, 2, 3, 4, 5, 14, 30, 62, 63, ++}; ++static const uint8_t dnxhd_1251_dc_bits[12] = { ++ 3, 4, 4, 3, 3, 3, 3, 3, 4, 5, 6, 6, ++}; ++static const uint16_t dnxhd_1251_ac_codes[257] = { ++ 0, 1, 4, 10, 11, 24, 25, 26, 54, 55, 56, 57, 116, 117, 118, 119, 240, 241, 242, 243, 244, 245, 492, 493, 494, 495, 496, 497, 996, 997, 998, 999, 1000, 1001, 1002, 1003, 1004, 1005, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025, 4052, 4053, 4054, 4055, 4056, 4057, 4058, 4059, 4060, 4061, 4062, 4063, 4064, 4065, 4066, 8134, 8135, 8136, 8137, 8138, 8139, 8140, 8141, 8142, 8143, 8144, 8145, 8146, 8147, 8148, 8149, 8150, 8151, 8152, 8153, 8154, 8155, 8156, 16314, 16315, 16316, 16317, 16318, 16319, 16320, 16321, 16322, 16323, 16324, 16325, 16326, 16327, 16328, 16329, 16330, 16331, 16332, 16333, 16334, 16335, 16336, 16337, 16338, 16339, 32680, 32681, 32682, 32683, 32684, 32685, 32686, 32687, 32688, 32689, 32690, 32691, 32692, 32693, 32694, 32695, 32696, 32697, 32698, 32699, 32700, 32701, 32702, 32703, 32704, 32705, 32706, 32707, 32708, 32709, 32710, 32711, 32712, 32713, 32714, 65430, 65431, 65432, 65433, 65434, 65435, 65436, 65437, 65438, 65439, 65440, 65441, 65442, 65443, 65444, 65445, 65446, 65447, 65448, 65449, 65450, 65451, 65452, 65453, 65454, 65455, 65456, 65457, 65458, 65459, 65460, 65461, 65462, 65463, 65464, 65465, 65466, 65467, 65468, 65469, 65470, 65471, 65472, 65473, 65474, 65475, 65476, 65477, 65478, 65479, 65480, 65481, 65482, 65483, 65484, 65485, 65486, 65487, 65488, 65489, 65490, 65491, 65492, 65493, 65494, 65495, 65496, 65497, 65498, 65499, 65500, 65501, 65502, 65503, 65504, 65505, 65506, 65507, 65508, 65509, 65510, 65511, 65512, 65513, 65514, 65515, 65516, 65517, 65518, 65519, 65520, 65521, 65522, 65523, 65524, 65525, 65526, 65527, 65528, 65529, 65530, 65531, 65532, 65533, 65534, 65535, ++}; ++static const uint8_t dnxhd_1251_ac_bits[257] = { ++ 2, 2, 3, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, ++}; ++static const uint8_t dnxhd_1251_ac_level[257] = { ++ 1, 1, 2, 3, 0, 4, 5, 2, 6, 7, 8, 3, 9, 10, 11, 4, 12, 13, 14, 15, 16, 5, 17, 18, 19, 20, 21, 6, 22, 23, 24, 25, 26, 27, 28, 29, 7, 8, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 9, 10, 11, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 12, 13, 14, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 1, 2, 3, 4, 5, 6, 7, 8, 15, 16, 17, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 18, 19, 20, 21, 22, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 23, 24, 25, 26, 27, 28, 59, 60, 61, 62, 63, 64, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, ++}; ++static const uint8_t dnxhd_1251_ac_run_flag[257] = { ++ 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ++}; ++static const uint8_t dnxhd_1251_ac_index_flag[257] = { ++ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ++}; ++static const uint16_t dnxhd_1251_run_codes[62] = { ++ 0, 4, 5, 12, 26, 27, 28, 58, 118, 119, 120, 242, 486, 487, 976, 977, 978, 979, 980, 981, 982, 983, 984, 985, 986, 987, 988, 989, 990, 991, 992, 993, 994, 995, 996, 997, 998, 999, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 1020, 1021, 1022, 1023, ++}; ++static const uint8_t dnxhd_1251_run_bits[62] = { ++ 1, 3, 3, 4, 5, 5, 5, 6, 7, 7, 7, 8, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, ++}; ++static const uint8_t dnxhd_1251_run[62] = { ++ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, ++}; ++ ++static const uint8_t dnxhd_1252_dc_codes[12] = { ++ 0, 12, 13, 1, 2, 3, 4, 5, 14, 30, 62, 63, ++}; ++static const uint8_t dnxhd_1252_dc_bits[12] = { ++ 3, 4, 4, 3, 3, 3, 3, 3, 4, 5, 6, 6, ++}; ++static const uint16_t dnxhd_1252_ac_codes[257] = { ++ 0, 1, 4, 10, 11, 12, 26, 27, 56, 57, 58, 118, 119, 120, 242, 243, 244, 245, 246, 247, 496, 497, 498, 499, 500, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 2020, 2021, 2022, 2023, 2024, 2025, 2026, 2027, 2028, 2029, 4060, 4061, 4062, 4063, 4064, 4065, 4066, 4067, 4068, 4069, 4070, 4071, 8144, 8145, 8146, 8147, 8148, 8149, 8150, 8151, 8152, 8153, 8154, 8155, 8156, 8157, 8158, 16318, 16319, 16320, 16321, 16322, 16323, 16324, 16325, 16326, 16327, 16328, 16329, 16330, 16331, 16332, 16333, 16334, 16335, 32672, 32673, 32674, 32675, 32676, 32677, 32678, 32679, 32680, 32681, 32682, 32683, 32684, 32685, 32686, 32687, 32688, 32689, 32690, 32691, 32692, 32693, 32694, 65390, 65391, 65392, 65393, 65394, 65395, 65396, 65397, 65398, 65399, 65400, 65401, 65402, 65403, 65404, 65405, 65406, 65407, 65408, 65409, 65410, 65411, 65412, 65413, 65414, 65415, 65416, 65417, 65418, 65419, 65420, 65421, 65422, 65423, 65424, 65425, 65426, 65427, 65428, 65429, 65430, 65431, 65432, 65433, 65434, 65435, 65436, 65437, 65438, 65439, 65440, 65441, 65442, 65443, 65444, 65445, 65446, 65447, 65448, 65449, 65450, 65451, 65452, 65453, 65454, 65455, 65456, 65457, 65458, 65459, 65460, 65461, 65462, 65463, 65464, 65465, 65466, 65467, 65468, 65469, 65470, 65471, 65472, 65473, 65474, 65475, 65476, 65477, 65478, 65479, 65480, 65481, 65482, 65483, 65484, 65485, 65486, 65487, 65488, 65489, 65490, 65491, 65492, 65493, 65494, 65495, 65496, 65497, 65498, 65499, 65500, 65501, 65502, 65503, 65504, 65505, 65506, 65507, 65508, 65509, 65510, 65511, 65512, 65513, 65514, 65515, 65516, 65517, 65518, 65519, 65520, 65521, 65522, 65523, 65524, 65525, 65526, 65527, 65528, 65529, 65530, 65531, 65532, 65533, 65534, 65535, ++}; ++static const uint8_t dnxhd_1252_ac_bits[257] = { ++ 2, 2, 3, 4, 4, 4, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, ++}; ++static const uint8_t dnxhd_1252_ac_level[257] = { ++ 1, 1, 2, 3, 2, 0, 4, 5, 6, 7, 3, 8, 9, 10, 11, 12, 13, 14, 4, 5, 15, 16, 17, 18, 6, 19, 20, 21, 22, 23, 24, 7, 8, 25, 26, 27, 28, 29, 30, 31, 32, 9, 10, 33, 34, 35, 36, 37, 38, 39, 40, 41, 11, 12, 13, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 14, 15, 16, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 1, 2, 3, 17, 18, 19, 20, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 21, 22, 23, 24, 25, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, ++}; ++static const uint8_t dnxhd_1252_ac_run_flag[257] = { ++ 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ++}; ++static const uint8_t dnxhd_1252_ac_index_flag[257] = { ++ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ++}; ++static const uint16_t dnxhd_1252_run_codes[62] = { ++ 0, 4, 5, 12, 26, 27, 28, 58, 118, 119, 120, 242, 486, 487, 976, 977, 978, 979, 980, 981, 982, 983, 984, 985, 986, 987, 988, 989, 990, 991, 992, 993, 994, 995, 996, 997, 998, 999, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 1020, 1021, 1022, 1023, ++}; ++static const uint8_t dnxhd_1252_run_bits[62] = { ++ 1, 3, 3, 4, 5, 5, 5, 6, 7, 7, 7, 8, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, ++}; ++static const uint8_t dnxhd_1252_run[62] = { ++ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, ++}; ++ + const CIDEntry ff_dnxhd_cid_table[] = { + { 1237, 1920, 1080, 0, 606208, 606208, 4, 8, +- dnxhd_1237_luma_weigth, dnxhd_1237_chroma_weigth, ++ dnxhd_1237_luma_weight, dnxhd_1237_chroma_weight, + dnxhd_1237_dc_codes, dnxhd_1237_dc_bits, + dnxhd_1237_ac_codes, dnxhd_1237_ac_bits, dnxhd_1237_ac_level, + dnxhd_1237_ac_run_flag, dnxhd_1237_ac_index_flag, +- dnxhd_1237_run_codes, dnxhd_1237_run_bits, dnxhd_1237_run }, ++ dnxhd_1237_run_codes, dnxhd_1237_run_bits, dnxhd_1237_run, ++ { 115, 120, 145, 240, 290 } }, + { 1238, 1920, 1080, 0, 917504, 917504, 4, 8, +- dnxhd_1238_luma_weigth, dnxhd_1238_chroma_weigth, ++ dnxhd_1238_luma_weight, dnxhd_1238_chroma_weight, + dnxhd_1238_dc_codes, dnxhd_1238_dc_bits, + dnxhd_1238_ac_codes, dnxhd_1238_ac_bits, dnxhd_1238_ac_level, + dnxhd_1238_ac_run_flag, dnxhd_1238_ac_index_flag, +- dnxhd_1238_run_codes, dnxhd_1238_run_bits, dnxhd_1238_run }, ++ dnxhd_1238_run_codes, dnxhd_1238_run_bits, dnxhd_1238_run, ++ { 175, 185, 220, 365, 440 } }, ++ { 1241, 1920, 1080, 1, 917504, 458752, 6, 10, ++ dnxhd_1241_luma_weight, dnxhd_1241_chroma_weight, ++ dnxhd_1241_dc_codes, dnxhd_1241_dc_bits, ++ dnxhd_1241_ac_codes, dnxhd_1241_ac_bits, dnxhd_1241_ac_level, ++ dnxhd_1241_ac_run_flag, dnxhd_1241_ac_index_flag, ++ dnxhd_1241_run_codes, dnxhd_1241_run_bits, dnxhd_1241_run, ++ { 185, 220 } }, + { 1242, 1920, 1080, 1, 606208, 303104, 4, 8, +- dnxhd_1242_luma_weigth, dnxhd_1242_chroma_weigth, ++ dnxhd_1242_luma_weight, dnxhd_1242_chroma_weight, + dnxhd_1237_dc_codes, dnxhd_1237_dc_bits, + dnxhd_1237_ac_codes, dnxhd_1237_ac_bits, dnxhd_1237_ac_level, + dnxhd_1237_ac_run_flag, dnxhd_1237_ac_index_flag, +- dnxhd_1237_run_codes, dnxhd_1237_run_bits, dnxhd_1237_run }, ++ dnxhd_1237_run_codes, dnxhd_1237_run_bits, dnxhd_1237_run, ++ { 120, 145 } }, + { 1243, 1920, 1080, 1, 917504, 458752, 4, 8, +- dnxhd_1243_luma_weigth, dnxhd_1243_chroma_weigth, ++ dnxhd_1243_luma_weight, dnxhd_1243_chroma_weight, + dnxhd_1238_dc_codes, dnxhd_1238_dc_bits, + dnxhd_1238_ac_codes, dnxhd_1238_ac_bits, dnxhd_1238_ac_level, + dnxhd_1238_ac_run_flag, dnxhd_1238_ac_index_flag, +- dnxhd_1238_run_codes, dnxhd_1238_run_bits, dnxhd_1238_run }, ++ dnxhd_1238_run_codes, dnxhd_1238_run_bits, dnxhd_1238_run, ++ { 185, 220 } }, ++ { 1251, 1280, 720, 0, 458752, 458752, 4, 8, ++ dnxhd_1251_luma_weight, dnxhd_1251_chroma_weight, ++ dnxhd_1251_dc_codes, dnxhd_1251_dc_bits, ++ dnxhd_1251_ac_codes, dnxhd_1251_ac_bits, dnxhd_1251_ac_level, ++ dnxhd_1251_ac_run_flag, dnxhd_1251_ac_index_flag, ++ dnxhd_1251_run_codes, dnxhd_1251_run_bits, dnxhd_1251_run, ++ { 90, 110, 175, 220 } }, ++ { 1252, 1280, 720, 0, 303104, 303104, 4, 8, ++ dnxhd_1252_luma_weight, dnxhd_1252_chroma_weight, ++ dnxhd_1252_dc_codes, dnxhd_1252_dc_bits, ++ dnxhd_1252_ac_codes, dnxhd_1252_ac_bits, dnxhd_1252_ac_level, ++ dnxhd_1252_ac_run_flag, dnxhd_1252_ac_index_flag, ++ dnxhd_1252_run_codes, dnxhd_1252_run_bits, dnxhd_1252_run, ++ { 60, 75, 115, 145 } }, ++ { 1253, 1920, 1080, 0, 188416, 188416, 4, 8, ++ dnxhd_1237_luma_weight, dnxhd_1237_chroma_weight, ++ dnxhd_1237_dc_codes, dnxhd_1237_dc_bits, ++ dnxhd_1237_ac_codes, dnxhd_1237_ac_bits, dnxhd_1237_ac_level, ++ dnxhd_1237_ac_run_flag, dnxhd_1237_ac_index_flag, ++ dnxhd_1237_run_codes, dnxhd_1237_run_bits, dnxhd_1237_run, ++ { 36, 45, 75, 90 } }, + }; + + int ff_dnxhd_get_cid_table(int cid) +@@ -224,3 +423,21 @@ + return i; + return -1; + } ++ ++int ff_dnxhd_find_cid(AVCodecContext *avctx) ++{ ++ int i, j; ++ int mbs = avctx->bit_rate/1000000; ++ for (i = 0; i < sizeof(ff_dnxhd_cid_table)/sizeof(CIDEntry); i++) { ++ const CIDEntry *cid = &ff_dnxhd_cid_table[i]; ++ if (cid->width == avctx->width && cid->height == avctx->height && ++ cid->interlaced == !!(avctx->flags & CODEC_FLAG_INTERLACED_DCT) && ++ cid->bit_depth == 8) { // until 10 bit is supported ++ for (j = 0; j < sizeof(cid->bit_rates); j++) { ++ if (cid->bit_rates[j] == mbs) ++ return cid->cid; ++ } ++ } ++ } ++ return 0; ++} +diff -u mplayer-1.0~rc2-12/libavcodec/dnxhddata.h ffmpeg-free-0.svn20080206/libavcodec/dnxhddata.h +--- mplayer-1.0~rc2-12/libavcodec/dnxhddata.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/dnxhddata.h 2007-12-18 14:52:07.000000000 +0100 +@@ -19,10 +19,11 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef AVCODEC_DNXHDDATA_H +-#define AVCODEC_DNXHDDATA_H ++#ifndef FFMPEG_DNXHDDATA_H ++#define FFMPEG_DNXHDDATA_H + + #include ++#include "avcodec.h" + + typedef struct { + int cid; +@@ -32,17 +33,19 @@ + unsigned int coding_unit_size; + int index_bits; + int bit_depth; +- const uint8_t *luma_weigth, *chroma_weigth; ++ const uint8_t *luma_weight, *chroma_weight; + const uint8_t *dc_codes, *dc_bits; + const uint16_t *ac_codes; + const uint8_t *ac_bits, *ac_level; + const uint8_t *ac_run_flag, *ac_index_flag; + const uint16_t *run_codes; + const uint8_t *run_bits, *run; ++ int bit_rates[5]; ///< Helpher to choose variants, rounded to nearest 5Mb/s + } CIDEntry; + + extern const CIDEntry ff_dnxhd_cid_table[]; + + int ff_dnxhd_get_cid_table(int cid); ++int ff_dnxhd_find_cid(AVCodecContext *avctx); + +-#endif // AVCODEC_DNXHDDATA_H ++#endif /* FFMPEG_DNXHDDATA_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/dnxhddec.c ffmpeg-free-0.svn20080206/libavcodec/dnxhddec.c +--- mplayer-1.0~rc2-12/libavcodec/dnxhddec.c 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/dnxhddec.c 2008-03-20 19:10:57.000000000 +0100 +@@ -46,7 +46,7 @@ + } DNXHDContext; + + #define DNXHD_VLC_BITS 9 +-#define DNXHD_DC_VLC_BITS 6 ++#define DNXHD_DC_VLC_BITS 7 + + static int dnxhd_decode_init(AVCodecContext *avctx) + { +@@ -72,7 +72,7 @@ + init_vlc(&ctx->ac_vlc, DNXHD_VLC_BITS, 257, + ctx->cid_table->ac_bits, 1, 1, + ctx->cid_table->ac_codes, 2, 2, 0); +- init_vlc(&ctx->dc_vlc, DNXHD_DC_VLC_BITS, 12, ++ init_vlc(&ctx->dc_vlc, DNXHD_DC_VLC_BITS, ctx->cid_table->bit_depth+4, + ctx->cid_table->dc_bits, 1, 1, + ctx->cid_table->dc_codes, 1, 1, 0); + init_vlc(&ctx->run_vlc, DNXHD_VLC_BITS, 62, +@@ -84,7 +84,7 @@ + return 0; + } + +-static int dnxhd_decode_header(DNXHDContext *ctx, uint8_t *buf, int buf_size, int first_field) ++static int dnxhd_decode_header(DNXHDContext *ctx, const uint8_t *buf, int buf_size, int first_field) + { + static const uint8_t header_prefix[] = { 0x00, 0x00, 0x02, 0x80, 0x01 }; + int i; +@@ -99,7 +99,7 @@ + if (buf[5] & 2) { /* interlaced */ + ctx->cur_field = buf[5] & 1; + ctx->picture.interlaced_frame = 1; +- ctx->picture.top_field_first = first_field && ctx->cur_field == 1; ++ ctx->picture.top_field_first = first_field ^ ctx->cur_field; + av_log(ctx->avctx, AV_LOG_DEBUG, "interlaced %d, cur field %d\n", buf[5] & 3, ctx->cur_field); + } + +@@ -108,7 +108,7 @@ + + dprintf(ctx->avctx, "width %d, heigth %d\n", ctx->width, ctx->height); + +- if (buf[0x21] & 0x80) { ++ if (buf[0x21] & 0x40) { + av_log(ctx->avctx, AV_LOG_ERROR, "10 bit per component\n"); + return -1; + } +@@ -161,10 +161,10 @@ + + if (n&2) { + component = 1 + (n&1); +- weigth_matrix = ctx->cid_table->chroma_weigth; ++ weigth_matrix = ctx->cid_table->chroma_weight; + } else { + component = 0; +- weigth_matrix = ctx->cid_table->luma_weigth; ++ weigth_matrix = ctx->cid_table->luma_weight; + } + + ctx->last_dc[component] += dnxhd_decode_dc(ctx); +@@ -189,22 +189,26 @@ + i += ctx->cid_table->run[index2]; + } + +- j = ctx->scantable.permutated[i]; +- //av_log(ctx->avctx, AV_LOG_DEBUG, "j %d\n", j); +- //av_log(ctx->avctx, AV_LOG_DEBUG, "level %d, weigth %d\n", level, weigth_matrix[i]); +- level = (2*level+1) * qscale * weigth_matrix[i]; +- if (weigth_matrix[i] != 32) // FIXME 10bit +- level += 32; +- level >>= 6; +- level = (level^sign) - sign; +- + if (i > 63) { + av_log(ctx->avctx, AV_LOG_ERROR, "ac tex damaged %d, %d\n", n, i); + return; + } + ++ j = ctx->scantable.permutated[i]; ++ //av_log(ctx->avctx, AV_LOG_DEBUG, "j %d\n", j); ++ //av_log(ctx->avctx, AV_LOG_DEBUG, "level %d, weigth %d\n", level, weigth_matrix[i]); ++ level = (2*level+1) * qscale * weigth_matrix[i]; ++ if (ctx->cid_table->bit_depth == 10) { ++ if (weigth_matrix[i] != 8) ++ level += 8; ++ level >>= 4; ++ } else { ++ if (weigth_matrix[i] != 32) ++ level += 32; ++ level >>= 6; ++ } + //av_log(NULL, AV_LOG_DEBUG, "i %d, j %d, end level %d\n", i, j, level); +- block[j] = level; ++ block[j] = (level^sign) - sign; + } + } + +@@ -259,13 +263,13 @@ + return 0; + } + +-static int dnxhd_decode_macroblocks(DNXHDContext *ctx, uint8_t *buf, int buf_size) ++static int dnxhd_decode_macroblocks(DNXHDContext *ctx, const uint8_t *buf, int buf_size) + { + int x, y; + for (y = 0; y < ctx->mb_height; y++) { + ctx->last_dc[0] = + ctx->last_dc[1] = +- ctx->last_dc[2] = 1024; // 1024 for levels +128 ++ ctx->last_dc[2] = 1<<(ctx->cid_table->bit_depth+2); // for levels +2^(bitdepth-1) + init_get_bits(&ctx->gb, buf + ctx->mb_scan_index[y], (buf_size - ctx->mb_scan_index[y]) << 3); + for (x = 0; x < ctx->mb_width; x++) { + //START_TIMER; +@@ -277,7 +281,7 @@ + } + + static int dnxhd_decode_frame(AVCodecContext *avctx, void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + DNXHDContext *ctx = avctx->priv_data; + AVFrame *picture = data; +Only in ffmpeg-free-0.svn20080206/libavcodec: dnxhdenc.c +diff -u mplayer-1.0~rc2-12/libavcodec/dpcm.c ffmpeg-free-0.svn20080206/libavcodec/dpcm.c +--- mplayer-1.0~rc2-12/libavcodec/dpcm.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/dpcm.c 2008-03-20 19:10:57.000000000 +0100 +@@ -159,7 +159,7 @@ + + static int dpcm_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + DPCMContext *s = avctx->priv_data; + int in, out = 0; +@@ -294,46 +294,19 @@ + return buf_size; + } + +-AVCodec roq_dpcm_decoder = { +- "roq_dpcm", +- CODEC_TYPE_AUDIO, +- CODEC_ID_ROQ_DPCM, +- sizeof(DPCMContext), +- dpcm_decode_init, +- NULL, +- NULL, +- dpcm_decode_frame, ++#define DPCM_DECODER(id, name) \ ++AVCodec name ## _decoder = { \ ++ #name, \ ++ CODEC_TYPE_AUDIO, \ ++ id, \ ++ sizeof(DPCMContext), \ ++ dpcm_decode_init, \ ++ NULL, \ ++ NULL, \ ++ dpcm_decode_frame, \ + }; + +-AVCodec interplay_dpcm_decoder = { +- "interplay_dpcm", +- CODEC_TYPE_AUDIO, +- CODEC_ID_INTERPLAY_DPCM, +- sizeof(DPCMContext), +- dpcm_decode_init, +- NULL, +- NULL, +- dpcm_decode_frame, +-}; +- +-AVCodec xan_dpcm_decoder = { +- "xan_dpcm", +- CODEC_TYPE_AUDIO, +- CODEC_ID_XAN_DPCM, +- sizeof(DPCMContext), +- dpcm_decode_init, +- NULL, +- NULL, +- dpcm_decode_frame, +-}; +- +-AVCodec sol_dpcm_decoder = { +- "sol_dpcm", +- CODEC_TYPE_AUDIO, +- CODEC_ID_SOL_DPCM, +- sizeof(DPCMContext), +- dpcm_decode_init, +- NULL, +- NULL, +- dpcm_decode_frame, +-}; ++DPCM_DECODER(CODEC_ID_INTERPLAY_DPCM, interplay_dpcm); ++DPCM_DECODER(CODEC_ID_ROQ_DPCM, roq_dpcm); ++DPCM_DECODER(CODEC_ID_SOL_DPCM, sol_dpcm); ++DPCM_DECODER(CODEC_ID_XAN_DPCM, xan_dpcm); +diff -u mplayer-1.0~rc2-12/libavcodec/dsicinav.c ffmpeg-free-0.svn20080206/libavcodec/dsicinav.c +--- mplayer-1.0~rc2-12/libavcodec/dsicinav.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/dsicinav.c 2008-03-20 19:10:57.000000000 +0100 +@@ -195,7 +195,7 @@ + + static int cinvideo_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + CinVideoContext *cin = avctx->priv_data; + int i, y, palette_type, palette_colors_count, bitmap_frame_type, bitmap_frame_size; +@@ -311,10 +311,10 @@ + + static int cinaudio_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + CinAudioContext *cin = avctx->priv_data; +- uint8_t *src = buf; ++ const uint8_t *src = buf; + int16_t *samples = (int16_t *)data; + + buf_size = FFMIN(buf_size, *data_size/2); +diff -u mplayer-1.0~rc2-12/libavcodec/dsputil.c ffmpeg-free-0.svn20080206/libavcodec/dsputil.c +--- mplayer-1.0~rc2-12/libavcodec/dsputil.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/dsputil.c 2008-03-20 19:10:57.000000000 +0100 +@@ -214,7 +214,7 @@ + return s; + } + +-static void bswap_buf(uint32_t *dst, uint32_t *src, int w){ ++static void bswap_buf(uint32_t *dst, const uint32_t *src, int w){ + int i; + + for(i=0; i+8<=w; i+=8){ +@@ -1440,12 +1440,22 @@ + \ + assert(x<8 && y<8 && x>=0 && y>=0);\ + \ +- for(i=0; i=0 && y>=0);\ + \ +- for(i=0; i=0 && y>=0);\ + \ +- for(i=0; iblock_last_index[0/*FIXME*/]= s->fast_dct_quantize(s, temp, 0/*FIXME*/, s->qscale, &i); + s->dct_unquantize_inter(s, temp, 0, s->qscale); +- simple_idct(temp); //FIXME ++ ff_simple_idct(temp); //FIXME + + for(i=0; i<64; i++) + sum+= (temp[i]-bak[i])*(temp[i]-bak[i]); +@@ -3714,16 +3752,16 @@ + return score; + } + +-WARPER8_16_SQ(hadamard8_diff8x8_c, hadamard8_diff16_c) +-WARPER8_16_SQ(hadamard8_intra8x8_c, hadamard8_intra16_c) +-WARPER8_16_SQ(dct_sad8x8_c, dct_sad16_c) ++WRAPPER8_16_SQ(hadamard8_diff8x8_c, hadamard8_diff16_c) ++WRAPPER8_16_SQ(hadamard8_intra8x8_c, hadamard8_intra16_c) ++WRAPPER8_16_SQ(dct_sad8x8_c, dct_sad16_c) + #ifdef CONFIG_GPL +-WARPER8_16_SQ(dct264_sad8x8_c, dct264_sad16_c) ++WRAPPER8_16_SQ(dct264_sad8x8_c, dct264_sad16_c) + #endif +-WARPER8_16_SQ(dct_max8x8_c, dct_max16_c) +-WARPER8_16_SQ(quant_psnr8x8_c, quant_psnr16_c) +-WARPER8_16_SQ(rd8x8_c, rd16_c) +-WARPER8_16_SQ(bit8x8_c, bit16_c) ++WRAPPER8_16_SQ(dct_max8x8_c, dct_max16_c) ++WRAPPER8_16_SQ(quant_psnr8x8_c, quant_psnr16_c) ++WRAPPER8_16_SQ(rd8x8_c, rd16_c) ++WRAPPER8_16_SQ(bit8x8_c, bit16_c) + + static void vector_fmul_c(float *dst, const float *src, int len){ + int i; +@@ -3747,7 +3785,7 @@ + void ff_float_to_int16_c(int16_t *dst, const float *src, int len){ + int i; + for(i=0; i>31; + // is this faster on some gcc/cpu combinations? +@@ -3758,8 +3796,90 @@ + } + } + ++#define W0 2048 ++#define W1 2841 /* 2048*sqrt (2)*cos (1*pi/16) */ ++#define W2 2676 /* 2048*sqrt (2)*cos (2*pi/16) */ ++#define W3 2408 /* 2048*sqrt (2)*cos (3*pi/16) */ ++#define W4 2048 /* 2048*sqrt (2)*cos (4*pi/16) */ ++#define W5 1609 /* 2048*sqrt (2)*cos (5*pi/16) */ ++#define W6 1108 /* 2048*sqrt (2)*cos (6*pi/16) */ ++#define W7 565 /* 2048*sqrt (2)*cos (7*pi/16) */ ++ ++static void wmv2_idct_row(short * b) ++{ ++ int s1,s2; ++ int a0,a1,a2,a3,a4,a5,a6,a7; ++ /*step 1*/ ++ a1 = W1*b[1]+W7*b[7]; ++ a7 = W7*b[1]-W1*b[7]; ++ a5 = W5*b[5]+W3*b[3]; ++ a3 = W3*b[5]-W5*b[3]; ++ a2 = W2*b[2]+W6*b[6]; ++ a6 = W6*b[2]-W2*b[6]; ++ a0 = W0*b[0]+W0*b[4]; ++ a4 = W0*b[0]-W0*b[4]; ++ /*step 2*/ ++ s1 = (181*(a1-a5+a7-a3)+128)>>8;//1,3,5,7, ++ s2 = (181*(a1-a5-a7+a3)+128)>>8; ++ /*step 3*/ ++ b[0] = (a0+a2+a1+a5 + (1<<7))>>8; ++ b[1] = (a4+a6 +s1 + (1<<7))>>8; ++ b[2] = (a4-a6 +s2 + (1<<7))>>8; ++ b[3] = (a0-a2+a7+a3 + (1<<7))>>8; ++ b[4] = (a0-a2-a7-a3 + (1<<7))>>8; ++ b[5] = (a4-a6 -s2 + (1<<7))>>8; ++ b[6] = (a4+a6 -s1 + (1<<7))>>8; ++ b[7] = (a0+a2-a1-a5 + (1<<7))>>8; ++} ++static void wmv2_idct_col(short * b) ++{ ++ int s1,s2; ++ int a0,a1,a2,a3,a4,a5,a6,a7; ++ /*step 1, with extended precision*/ ++ a1 = (W1*b[8*1]+W7*b[8*7] + 4)>>3; ++ a7 = (W7*b[8*1]-W1*b[8*7] + 4)>>3; ++ a5 = (W5*b[8*5]+W3*b[8*3] + 4)>>3; ++ a3 = (W3*b[8*5]-W5*b[8*3] + 4)>>3; ++ a2 = (W2*b[8*2]+W6*b[8*6] + 4)>>3; ++ a6 = (W6*b[8*2]-W2*b[8*6] + 4)>>3; ++ a0 = (W0*b[8*0]+W0*b[8*4] )>>3; ++ a4 = (W0*b[8*0]-W0*b[8*4] )>>3; ++ /*step 2*/ ++ s1 = (181*(a1-a5+a7-a3)+128)>>8; ++ s2 = (181*(a1-a5-a7+a3)+128)>>8; ++ /*step 3*/ ++ b[8*0] = (a0+a2+a1+a5 + (1<<13))>>14; ++ b[8*1] = (a4+a6 +s1 + (1<<13))>>14; ++ b[8*2] = (a4-a6 +s2 + (1<<13))>>14; ++ b[8*3] = (a0-a2+a7+a3 + (1<<13))>>14; ++ ++ b[8*4] = (a0-a2-a7-a3 + (1<<13))>>14; ++ b[8*5] = (a4-a6 -s2 + (1<<13))>>14; ++ b[8*6] = (a4+a6 -s1 + (1<<13))>>14; ++ b[8*7] = (a0+a2-a1-a5 + (1<<13))>>14; ++} ++void ff_wmv2_idct_c(short * block){ ++ int i; ++ ++ for(i=0;i<64;i+=8){ ++ wmv2_idct_row(block+i); ++ } ++ for(i=0;i<8;i++){ ++ wmv2_idct_col(block+i); ++ } ++} + /* XXX: those functions should be suppressed ASAP when all IDCTs are + converted */ ++static void ff_wmv2_idct_put_c(uint8_t *dest, int line_size, DCTELEM *block) ++{ ++ ff_wmv2_idct_c(block); ++ put_pixels_clamped_c(block, dest, line_size); ++} ++static void ff_wmv2_idct_add_c(uint8_t *dest, int line_size, DCTELEM *block) ++{ ++ ff_wmv2_idct_c(block); ++ add_pixels_clamped_c(block, dest, line_size); ++} + static void ff_jref_idct_put(uint8_t *dest, int line_size, DCTELEM *block) + { + j_rev_dct (block); +@@ -3899,10 +4019,15 @@ + c->idct_add= ff_vp3_idct_add_c; + c->idct = ff_vp3_idct_c; + c->idct_permutation_type= FF_NO_IDCT_PERM; ++ }else if(avctx->idct_algo==FF_IDCT_WMV2){ ++ c->idct_put= ff_wmv2_idct_put_c; ++ c->idct_add= ff_wmv2_idct_add_c; ++ c->idct = ff_wmv2_idct_c; ++ c->idct_permutation_type= FF_NO_IDCT_PERM; + }else{ //accurate/default +- c->idct_put= simple_idct_put; +- c->idct_add= simple_idct_add; +- c->idct = simple_idct; ++ c->idct_put= ff_simple_idct_put; ++ c->idct_add= ff_simple_idct_add; ++ c->idct = ff_simple_idct; + c->idct_permutation_type= FF_NO_IDCT_PERM; + } + } +@@ -4056,6 +4181,9 @@ + #if defined(CONFIG_VC1_DECODER) || defined(CONFIG_WMV3_DECODER) + ff_vc1dsp_init(c,avctx); + #endif ++#if defined(CONFIG_WMV2_DECODER) || defined(CONFIG_VC1_DECODER) || defined(CONFIG_WMV3_DECODER) ++ ff_intrax8dsp_init(c,avctx); ++#endif + #if defined(CONFIG_H264_ENCODER) + ff_h264dspenc_init(c,avctx); + #endif +diff -u mplayer-1.0~rc2-12/libavcodec/dsputil.h ffmpeg-free-0.svn20080206/libavcodec/dsputil.h +--- mplayer-1.0~rc2-12/libavcodec/dsputil.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/dsputil.h 2008-02-01 14:49:15.000000000 +0100 +@@ -27,8 +27,8 @@ + * absolutely necessary to call emms_c() between dsp & float/double code + */ + +-#ifndef DSPUTIL_H +-#define DSPUTIL_H ++#ifndef FFMPEG_DSPUTIL_H ++#define FFMPEG_DSPUTIL_H + + #include "avcodec.h" + +@@ -48,6 +48,7 @@ + void j_rev_dct4 (DCTELEM *data); + void j_rev_dct2 (DCTELEM *data); + void j_rev_dct1 (DCTELEM *data); ++void ff_wmv2_idct_c(DCTELEM *data); + + void ff_fdct_mmx(DCTELEM *block); + void ff_fdct_mmx2(DCTELEM *block); +@@ -309,7 +310,7 @@ + * note, this might read from src1[-1], src2[-1] + */ + void (*sub_hfyu_median_prediction)(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w, int *left, int *left_top); +- void (*bswap_buf)(uint32_t *dst, uint32_t *src, int w); ++ void (*bswap_buf)(uint32_t *dst, const uint32_t *src, int w); + + void (*h264_v_loop_filter_luma)(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0); + void (*h264_h_loop_filter_luma)(uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0); +@@ -326,6 +327,9 @@ + + void (*h261_loop_filter)(uint8_t *src, int stride); + ++ void (*x8_v_loop_filter)(uint8_t *src, int stride, int qscale); ++ void (*x8_h_loop_filter)(uint8_t *src, int stride, int qscale); ++ + /* assume len is a multiple of 4, and arrays are 16-byte aligned */ + void (*vorbis_inverse_coupling)(float *mag, float *ang, int blocksize); + /* no alignment needed */ +@@ -403,15 +407,21 @@ + + /* vc1 functions */ + void (*vc1_inv_trans_8x8)(DCTELEM *b); +- void (*vc1_inv_trans_8x4)(DCTELEM *b, int n); +- void (*vc1_inv_trans_4x8)(DCTELEM *b, int n); +- void (*vc1_inv_trans_4x4)(DCTELEM *b, int n); ++ void (*vc1_inv_trans_8x4)(uint8_t *dest, int line_size, DCTELEM *block); ++ void (*vc1_inv_trans_4x8)(uint8_t *dest, int line_size, DCTELEM *block); ++ void (*vc1_inv_trans_4x4)(uint8_t *dest, int line_size, DCTELEM *block); + void (*vc1_v_overlap)(uint8_t* src, int stride); + void (*vc1_h_overlap)(uint8_t* src, int stride); + /* put 8x8 block with bicubic interpolation and quarterpel precision + * last argument is actually round value instead of height + */ + op_pixels_func put_vc1_mspel_pixels_tab[16]; ++ ++ /* intrax8 functions */ ++ void (*x8_spatial_compensation[12])(uint8_t *src , uint8_t *dst, int linesize); ++ void (*x8_setup_spatial_compensation)(uint8_t *src, uint8_t *dst, int linesize, ++ int * range, int * sum, int edges); ++ + } DSPContext; + + void dsputil_static_init(void); +@@ -635,6 +645,14 @@ + FFTContext fft; + } MDCTContext; + ++/** ++ * Generate a Kaiser-Bessel Derived Window. ++ * @param window pointer to half window ++ * @param alpha determines window shape ++ * @param n size of half window ++ */ ++void ff_kbd_window_init(float *window, float alpha, int n); ++ + int ff_mdct_init(MDCTContext *s, int nbits, int inverse); + void ff_imdct_calc(MDCTContext *s, FFTSample *output, + const FFTSample *input, FFTSample *tmp); +@@ -646,13 +664,13 @@ + const FFTSample *input, FFTSample *tmp); + void ff_mdct_end(MDCTContext *s); + +-#define WARPER8_16(name8, name16)\ ++#define WRAPPER8_16(name8, name16)\ + static int name16(void /*MpegEncContext*/ *s, uint8_t *dst, uint8_t *src, int stride, int h){\ + return name8(s, dst , src , stride, h)\ + +name8(s, dst+8 , src+8 , stride, h);\ + } + +-#define WARPER8_16_SQ(name8, name16)\ ++#define WRAPPER8_16_SQ(name8, name16)\ + static int name16(void /*MpegEncContext*/ *s, uint8_t *dst, uint8_t *src, int stride, int h){\ + int score=0;\ + score +=name8(s, dst , src , stride, 8);\ +@@ -743,4 +761,4 @@ + } + } + +-#endif ++#endif /* FFMPEG_DSPUTIL_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/dvbsub.c ffmpeg-free-0.svn20080206/libavcodec/dvbsub.c +--- mplayer-1.0~rc2-12/libavcodec/dvbsub.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/dvbsub.c 2008-03-20 19:10:57.000000000 +0100 +@@ -390,16 +390,6 @@ + return q - outbuf; + } + +-static int dvbsub_init_decoder(AVCodecContext *avctx) +-{ +- return 0; +-} +- +-static int dvbsub_close_decoder(AVCodecContext *avctx) +-{ +- return 0; +-} +- + static int dvbsub_encode(AVCodecContext *avctx, + unsigned char *buf, int buf_size, void *data) + { +@@ -416,7 +406,6 @@ + CODEC_TYPE_SUBTITLE, + CODEC_ID_DVB_SUBTITLE, + sizeof(DVBSubtitleContext), +- dvbsub_init_decoder, ++ NULL, + dvbsub_encode, +- dvbsub_close_decoder, + }; +diff -u mplayer-1.0~rc2-12/libavcodec/dvbsubdec.c ffmpeg-free-0.svn20080206/libavcodec/dvbsubdec.c +--- mplayer-1.0~rc2-12/libavcodec/dvbsubdec.c 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/dvbsubdec.c 2008-03-20 19:10:58.000000000 +0100 +@@ -102,7 +102,7 @@ + char fname[40], fname2[40]; + char command[1024]; + +- snprintf(fname, 40, "%s.ppm", filename); ++ snprintf(fname, sizeof(fname), "%s.ppm", filename); + + f = fopen(fname, "w"); + if (!f) { +@@ -124,7 +124,7 @@ + fclose(f); + + +- snprintf(fname2, 40, "%s-a.pgm", filename); ++ snprintf(fname2, sizeof(fname2), "%s-a.pgm", filename); + + f = fopen(fname2, "w"); + if (!f) { +@@ -143,10 +143,10 @@ + } + fclose(f); + +- snprintf(command, 1024, "pnmtopng -alpha %s %s > %s.png 2> /dev/null", fname2, fname, filename); ++ snprintf(command, sizeof(command), "pnmtopng -alpha %s %s > %s.png 2> /dev/null", fname2, fname, filename); + system(command); + +- snprintf(command, 1024, "rm %s %s", fname, fname2); ++ snprintf(command, sizeof(command), "rm %s %s", fname, fname2); + system(command); + } + #endif +@@ -172,8 +172,8 @@ + int x_pos; + int y_pos; + +- int fgcolour; +- int bgcolour; ++ int fgcolor; ++ int bgcolor; + + struct DVBSubObjectDisplay *region_list_next; + struct DVBSubObjectDisplay *object_list_next; +@@ -206,7 +206,7 @@ + int depth; + + int clut; +- int bgcolour; ++ int bgcolor; + + uint8_t *pbuf; + int buf_size; +@@ -234,7 +234,7 @@ + { + DVBSubObject *ptr = ctx->object_list; + +- while (ptr != NULL && ptr->id != object_id) { ++ while (ptr && ptr->id != object_id) { + ptr = ptr->next; + } + +@@ -245,7 +245,7 @@ + { + DVBSubCLUT *ptr = ctx->clut_list; + +- while (ptr != NULL && ptr->id != clut_id) { ++ while (ptr && ptr->id != clut_id) { + ptr = ptr->next; + } + +@@ -256,7 +256,7 @@ + { + DVBSubRegion *ptr = ctx->region_list; + +- while (ptr != NULL && ptr->id != region_id) { ++ while (ptr && ptr->id != region_id) { + ptr = ptr->next; + } + +@@ -268,16 +268,16 @@ + DVBSubObject *object, *obj2, **obj2_ptr; + DVBSubObjectDisplay *display, *obj_disp, **obj_disp_ptr; + +- while (region->display_list != NULL) { ++ while (region->display_list) { + display = region->display_list; + + object = get_object(ctx, display->object_id); + +- if (object != NULL) { ++ if (object) { + obj_disp = object->display_list; + obj_disp_ptr = &object->display_list; + +- while (obj_disp != NULL && obj_disp != display) { ++ while (obj_disp && obj_disp != display) { + obj_disp_ptr = &obj_disp->object_list_next; + obj_disp = obj_disp->object_list_next; + } +@@ -285,11 +285,11 @@ + if (obj_disp) { + *obj_disp_ptr = obj_disp->object_list_next; + +- if (object->display_list == NULL) { ++ if (!object->display_list) { + obj2 = ctx->object_list; + obj2_ptr = &ctx->object_list; + +- while (obj2 != NULL && obj2 != object) { ++ while (obj2 && obj2 != object) { + obj2_ptr = &obj2->next; + obj2 = obj2->next; + } +@@ -313,21 +313,19 @@ + DVBSubRegion *region; + DVBSubCLUT *clut; + +- while (ctx->region_list != NULL) +- { ++ while (ctx->region_list) { + region = ctx->region_list; + + ctx->region_list = region->next; + + delete_region_display_list(ctx, region); +- if (region->pbuf != NULL) ++ if (region->pbuf) + av_free(region->pbuf); + + av_free(region); + } + +- while (ctx->clut_list != NULL) +- { ++ while (ctx->clut_list) { + clut = ctx->clut_list; + + ctx->clut_list = clut->next; +@@ -336,7 +334,7 @@ + } + + /* Should already be null */ +- if (ctx->object_list != NULL) ++ if (ctx->object_list) + av_log(0, AV_LOG_ERROR, "Memory deallocation error!\n"); + } + +@@ -420,8 +418,7 @@ + + delete_state(ctx); + +- while (ctx->display_list != NULL) +- { ++ while (ctx->display_list) { + display = ctx->display_list; + ctx->display_list = display->next; + +@@ -432,7 +429,7 @@ + } + + static int dvbsub_read_2bit_string(uint8_t *destbuf, int dbuf_len, +- uint8_t **srcbuf, int buf_size, ++ const uint8_t **srcbuf, int buf_size, + int non_mod, uint8_t *map_table) + { + GetBitContext gb; +@@ -446,9 +443,9 @@ + while (get_bits_count(&gb) < (buf_size << 8) && pixels_read < dbuf_len) { + bits = get_bits(&gb, 2); + +- if (bits != 0) { ++ if (bits) { + if (non_mod != 1 || bits != 1) { +- if (map_table != NULL) ++ if (map_table) + *destbuf++ = map_table[bits]; + else + *destbuf++ = bits; +@@ -463,7 +460,7 @@ + if (non_mod == 1 && bits == 1) + pixels_read += run_length; + else { +- if (map_table != NULL) ++ if (map_table) + bits = map_table[bits]; + while (run_length-- > 0 && pixels_read < dbuf_len) { + *destbuf++ = bits; +@@ -481,7 +478,7 @@ + if (non_mod == 1 && bits == 1) + pixels_read += run_length; + else { +- if (map_table != NULL) ++ if (map_table) + bits = map_table[bits]; + while (run_length-- > 0 && pixels_read < dbuf_len) { + *destbuf++ = bits; +@@ -495,7 +492,7 @@ + if (non_mod == 1 && bits == 1) + pixels_read += run_length; + else { +- if (map_table != NULL) ++ if (map_table) + bits = map_table[bits]; + while (run_length-- > 0 && pixels_read < dbuf_len) { + *destbuf++ = bits; +@@ -504,7 +501,7 @@ + } + } else if (bits == 1) { + pixels_read += 2; +- if (map_table != NULL) ++ if (map_table) + bits = map_table[0]; + else + bits = 0; +@@ -517,7 +514,7 @@ + return pixels_read; + } + } else { +- if (map_table != NULL) ++ if (map_table) + bits = map_table[0]; + else + bits = 0; +@@ -528,7 +525,7 @@ + } + } + +- if (get_bits(&gb, 6) != 0) ++ if (get_bits(&gb, 6)) + av_log(0, AV_LOG_ERROR, "DVBSub error: line overflow\n"); + + (*srcbuf) += (get_bits_count(&gb) + 7) >> 3; +@@ -537,7 +534,7 @@ + } + + static int dvbsub_read_4bit_string(uint8_t *destbuf, int dbuf_len, +- uint8_t **srcbuf, int buf_size, ++ const uint8_t **srcbuf, int buf_size, + int non_mod, uint8_t *map_table) + { + GetBitContext gb; +@@ -551,9 +548,9 @@ + while (get_bits_count(&gb) < (buf_size << 8) && pixels_read < dbuf_len) { + bits = get_bits(&gb, 4); + +- if (bits != 0) { ++ if (bits) { + if (non_mod != 1 || bits != 1) { +- if (map_table != NULL) ++ if (map_table) + *destbuf++ = map_table[bits]; + else + *destbuf++ = bits; +@@ -571,7 +568,7 @@ + + run_length += 2; + +- if (map_table != NULL) ++ if (map_table) + bits = map_table[0]; + else + bits = 0; +@@ -589,7 +586,7 @@ + if (non_mod == 1 && bits == 1) + pixels_read += run_length; + else { +- if (map_table != NULL) ++ if (map_table) + bits = map_table[bits]; + while (run_length-- > 0 && pixels_read < dbuf_len) { + *destbuf++ = bits; +@@ -605,7 +602,7 @@ + if (non_mod == 1 && bits == 1) + pixels_read += run_length; + else { +- if (map_table != NULL) ++ if (map_table) + bits = map_table[bits]; + while (run_length-- > 0 && pixels_read < dbuf_len) { + *destbuf++ = bits; +@@ -619,7 +616,7 @@ + if (non_mod == 1 && bits == 1) + pixels_read += run_length; + else { +- if (map_table != NULL) ++ if (map_table) + bits = map_table[bits]; + while (run_length-- > 0 && pixels_read < dbuf_len) { + *destbuf++ = bits; +@@ -628,7 +625,7 @@ + } + } else if (bits == 1) { + pixels_read += 2; +- if (map_table != NULL) ++ if (map_table) + bits = map_table[0]; + else + bits = 0; +@@ -637,7 +634,7 @@ + *destbuf++ = bits; + } + } else { +- if (map_table != NULL) ++ if (map_table) + bits = map_table[0]; + else + bits = 0; +@@ -649,7 +646,7 @@ + } + } + +- if (get_bits(&gb, 8) != 0) ++ if (get_bits(&gb, 8)) + av_log(0, AV_LOG_ERROR, "DVBSub error: line overflow\n"); + + (*srcbuf) += (get_bits_count(&gb) + 7) >> 3; +@@ -658,10 +655,10 @@ + } + + static int dvbsub_read_8bit_string(uint8_t *destbuf, int dbuf_len, +- uint8_t **srcbuf, int buf_size, ++ const uint8_t **srcbuf, int buf_size, + int non_mod, uint8_t *map_table) + { +- uint8_t *sbuf_end = (*srcbuf) + buf_size; ++ const uint8_t *sbuf_end = (*srcbuf) + buf_size; + int bits; + int run_length; + int pixels_read = 0; +@@ -669,9 +666,9 @@ + while (*srcbuf < sbuf_end && pixels_read < dbuf_len) { + bits = *(*srcbuf)++; + +- if (bits != 0) { ++ if (bits) { + if (non_mod != 1 || bits != 1) { +- if (map_table != NULL) ++ if (map_table) + *destbuf++ = map_table[bits]; + else + *destbuf++ = bits; +@@ -685,7 +682,7 @@ + return pixels_read; + } + +- if (map_table != NULL) ++ if (map_table) + bits = map_table[0]; + else + bits = 0; +@@ -698,7 +695,7 @@ + + if (non_mod == 1 && bits == 1) + pixels_read += run_length; +- if (map_table != NULL) ++ if (map_table) + bits = map_table[bits]; + else while (run_length-- > 0 && pixels_read < dbuf_len) { + *destbuf++ = bits; +@@ -708,7 +705,7 @@ + } + } + +- if (*(*srcbuf)++ != 0) ++ if (*(*srcbuf)++) + av_log(0, AV_LOG_ERROR, "DVBSub error: line overflow\n"); + + return pixels_read; +@@ -717,12 +714,12 @@ + + + static void dvbsub_parse_pixel_data_block(AVCodecContext *avctx, DVBSubObjectDisplay *display, +- uint8_t *buf, int buf_size, int top_bottom, int non_mod) ++ const uint8_t *buf, int buf_size, int top_bottom, int non_mod) + { + DVBSubContext *ctx = (DVBSubContext*) avctx->priv_data; + + DVBSubRegion *region = get_region(ctx, display->region_id); +- uint8_t *buf_end = buf + buf_size; ++ const uint8_t *buf_end = buf + buf_size; + uint8_t *pbuf; + int x_pos, y_pos; + int i; +@@ -739,8 +736,7 @@ + #endif + + #ifdef DEBUG_PACKET_CONTENTS +- for (i = 0; i < buf_size; i++) +- { ++ for (i = 0; i < buf_size; i++) { + if (i % 16 == 0) + av_log(avctx, AV_LOG_INFO, "0x%08p: ", buf+i); + +@@ -749,7 +745,7 @@ + av_log(avctx, AV_LOG_INFO, "\n"); + } + +- if (i % 16 != 0) ++ if (i % 16) + av_log(avctx, AV_LOG_INFO, "\n"); + + #endif +@@ -837,18 +833,18 @@ + } + + static void dvbsub_parse_object_segment(AVCodecContext *avctx, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + DVBSubContext *ctx = (DVBSubContext*) avctx->priv_data; + +- uint8_t *buf_end = buf + buf_size; +- uint8_t *block; ++ const uint8_t *buf_end = buf + buf_size; ++ const uint8_t *block; + int object_id; + DVBSubObject *object; + DVBSubObjectDisplay *display; + int top_field_len, bottom_field_len; + +- int coding_method, non_modifying_colour; ++ int coding_method, non_modifying_color; + + object_id = AV_RB16(buf); + buf += 2; +@@ -859,7 +855,7 @@ + return; + + coding_method = ((*buf) >> 2) & 3; +- non_modifying_colour = ((*buf++) >> 1) & 1; ++ non_modifying_color = ((*buf++) >> 1) & 1; + + if (coding_method == 0) { + top_field_len = AV_RB16(buf); +@@ -872,11 +868,11 @@ + return; + } + +- for (display = object->display_list; display != 0; display = display->object_list_next) { ++ for (display = object->display_list; display; display = display->object_list_next) { + block = buf; + + dvbsub_parse_pixel_data_block(avctx, display, block, top_field_len, 0, +- non_modifying_colour); ++ non_modifying_color); + + if (bottom_field_len > 0) + block = buf + top_field_len; +@@ -884,7 +880,7 @@ + bottom_field_len = top_field_len; + + dvbsub_parse_pixel_data_block(avctx, display, block, bottom_field_len, 1, +- non_modifying_colour); ++ non_modifying_color); + } + + /* } else if (coding_method == 1) {*/ +@@ -896,11 +892,11 @@ + } + + static void dvbsub_parse_clut_segment(AVCodecContext *avctx, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + DVBSubContext *ctx = (DVBSubContext*) avctx->priv_data; + +- uint8_t *buf_end = buf + buf_size; ++ const uint8_t *buf_end = buf + buf_size; + int clut_id; + DVBSubCLUT *clut; + int entry_id, depth , full_range; +@@ -912,14 +908,13 @@ + + av_log(avctx, AV_LOG_INFO, "DVB clut packet:\n"); + +- for (i=0; i < buf_size; i++) +- { ++ for (i=0; i < buf_size; i++) { + av_log(avctx, AV_LOG_INFO, "%02x ", buf[i]); + if (i % 16 == 15) + av_log(avctx, AV_LOG_INFO, "\n"); + } + +- if (i % 16 != 0) ++ if (i % 16) + av_log(avctx, AV_LOG_INFO, "\n"); + + #endif +@@ -929,7 +924,7 @@ + + clut = get_clut(ctx, clut_id); + +- if (clut == NULL) { ++ if (!clut) { + clut = av_malloc(sizeof(DVBSubCLUT)); + + memcpy(clut, &default_clut, sizeof(DVBSubCLUT)); +@@ -940,8 +935,7 @@ + ctx->clut_list = clut; + } + +- while (buf + 4 < buf_end) +- { ++ while (buf + 4 < buf_end) { + entry_id = *buf++; + + depth = (*buf) & 0xe0; +@@ -988,11 +982,11 @@ + + + static void dvbsub_parse_region_segment(AVCodecContext *avctx, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + DVBSubContext *ctx = (DVBSubContext*) avctx->priv_data; + +- uint8_t *buf_end = buf + buf_size; ++ const uint8_t *buf_end = buf + buf_size; + int region_id, object_id; + DVBSubRegion *region; + DVBSubObject *object; +@@ -1006,8 +1000,7 @@ + + region = get_region(ctx, region_id); + +- if (region == NULL) +- { ++ if (!region) { + region = av_mallocz(sizeof(DVBSubRegion)); + + region->id = region_id; +@@ -1024,7 +1017,7 @@ + buf += 2; + + if (region->width * region->height != region->buf_size) { +- if (region->pbuf != 0) ++ if (region->pbuf) + av_free(region->pbuf); + + region->buf_size = region->width * region->height; +@@ -1035,17 +1028,21 @@ + } + + region->depth = 1 << (((*buf++) >> 2) & 7); ++ if(region->depth<2 || region->depth>8){ ++ av_log(avctx, AV_LOG_ERROR, "region depth %d is invalid\n", region->depth); ++ region->depth= 4; ++ } + region->clut = *buf++; + + if (region->depth == 8) +- region->bgcolour = *buf++; ++ region->bgcolor = *buf++; + else { + buf += 1; + + if (region->depth == 4) +- region->bgcolour = (((*buf++) >> 4) & 15); ++ region->bgcolor = (((*buf++) >> 4) & 15); + else +- region->bgcolour = (((*buf++) >> 2) & 3); ++ region->bgcolor = (((*buf++) >> 2) & 3); + } + + #ifdef DEBUG +@@ -1053,9 +1050,9 @@ + #endif + + if (fill) { +- memset(region->pbuf, region->bgcolour, region->buf_size); ++ memset(region->pbuf, region->bgcolor, region->buf_size); + #ifdef DEBUG +- av_log(avctx, AV_LOG_INFO, "Fill region (%d)\n", region->bgcolour); ++ av_log(avctx, AV_LOG_INFO, "Fill region (%d)\n", region->bgcolor); + #endif + } + +@@ -1067,7 +1064,7 @@ + + object = get_object(ctx, object_id); + +- if (object == NULL) { ++ if (!object) { + object = av_mallocz(sizeof(DVBSubObject)); + + object->id = object_id; +@@ -1088,8 +1085,8 @@ + buf += 2; + + if ((object->type == 1 || object->type == 2) && buf+1 < buf_end) { +- display->fgcolour = *buf++; +- display->bgcolour = *buf++; ++ display->fgcolor = *buf++; ++ display->bgcolor = *buf++; + } + + display->region_list_next = region->display_list; +@@ -1101,13 +1098,13 @@ + } + + static void dvbsub_parse_page_segment(AVCodecContext *avctx, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + DVBSubContext *ctx = (DVBSubContext*) avctx->priv_data; + DVBSubRegionDisplay *display; + DVBSubRegionDisplay *tmp_display_list, **tmp_ptr; + +- uint8_t *buf_end = buf + buf_size; ++ const uint8_t *buf_end = buf + buf_size; + int region_id; + int page_state; + +@@ -1121,8 +1118,7 @@ + av_log(avctx, AV_LOG_INFO, "Page time out %ds, state %d\n", ctx->time_out, page_state); + #endif + +- if (page_state == 2) +- { ++ if (page_state == 2) { + delete_state(ctx); + } + +@@ -1137,12 +1133,12 @@ + display = tmp_display_list; + tmp_ptr = &tmp_display_list; + +- while (display != NULL && display->region_id != region_id) { ++ while (display && display->region_id != region_id) { + tmp_ptr = &display->next; + display = display->next; + } + +- if (display == NULL) ++ if (!display) + display = av_mallocz(sizeof(DVBSubRegionDisplay)); + + display->region_id = region_id; +@@ -1163,7 +1159,7 @@ + #endif + } + +- while (tmp_display_list != 0) { ++ while (tmp_display_list) { + display = tmp_display_list; + + tmp_display_list = display->next; +@@ -1192,7 +1188,7 @@ + width = 0; + height = 0; + +- for (display = ctx->display_list; display != NULL; display = display->next) { ++ for (display = ctx->display_list; display; display = display->next) { + region = get_region(ctx, display->region_id); + + if (x_pos == -1) { +@@ -1225,7 +1221,7 @@ + + pbuf = av_malloc(width * height * 4); + +- for (display = ctx->display_list; display != NULL; display = display->next) { ++ for (display = ctx->display_list; display; display = display->next) { + region = get_region(ctx, display->region_id); + + x_off = display->x_pos - x_pos; +@@ -1258,7 +1254,7 @@ + + } + +- snprintf(filename, 32, "dvbs.%d", fileno_index); ++ snprintf(filename, sizeof(filename), "dvbs.%d", fileno_index); + + png_save2(filename, pbuf, width, height); + +@@ -1269,7 +1265,7 @@ + } + #endif + +-static int dvbsub_display_end_segment(AVCodecContext *avctx, uint8_t *buf, ++static int dvbsub_display_end_segment(AVCodecContext *avctx, const uint8_t *buf, + int buf_size, AVSubtitle *sub) + { + DVBSubContext *ctx = (DVBSubContext*) avctx->priv_data; +@@ -1293,11 +1289,11 @@ + + i = 0; + +- for (display = ctx->display_list; display != NULL; display = display->next) { ++ for (display = ctx->display_list; display; display = display->next) { + region = get_region(ctx, display->region_id); + rect = &sub->rects[i]; + +- if (region == NULL) ++ if (!region) + continue; + + rect->x = display->x_pos; +@@ -1309,7 +1305,7 @@ + + clut = get_clut(ctx, region->clut); + +- if (clut == NULL) ++ if (!clut) + clut = &default_clut; + + switch (region->depth) { +@@ -1345,11 +1341,11 @@ + + static int dvbsub_decode(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + DVBSubContext *ctx = (DVBSubContext*) avctx->priv_data; + AVSubtitle *sub = (AVSubtitle*) data; +- uint8_t *p, *p_end; ++ const uint8_t *p, *p_end; + int segment_type; + int page_id; + int segment_length; +@@ -1359,14 +1355,13 @@ + + av_log(avctx, AV_LOG_INFO, "DVB sub packet:\n"); + +- for (i=0; i < buf_size; i++) +- { ++ for (i=0; i < buf_size; i++) { + av_log(avctx, AV_LOG_INFO, "%02x ", buf[i]); + if (i % 16 == 15) + av_log(avctx, AV_LOG_INFO, "\n"); + } + +- if (i % 16 != 0) ++ if (i % 16) + av_log(avctx, AV_LOG_INFO, "\n"); + + #endif +@@ -1377,8 +1372,7 @@ + p = buf; + p_end = buf + buf_size; + +- while (p < p_end && *p == 0x0f) +- { ++ while (p < p_end && *p == 0x0f) { + p += 1; + segment_type = *p++; + page_id = AV_RB16(p); +@@ -1415,8 +1409,7 @@ + p += segment_length; + } + +- if (p != p_end) +- { ++ if (p != p_end) { + #ifdef DEBUG + av_log(avctx, AV_LOG_INFO, "Junk at end of packet\n"); + #endif +diff -u mplayer-1.0~rc2-12/libavcodec/dv.c ffmpeg-free-0.svn20080206/libavcodec/dv.c +--- mplayer-1.0~rc2-12/libavcodec/dv.c 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/dv.c 2008-03-20 19:10:57.000000000 +0100 +@@ -225,7 +225,7 @@ + + /* 248DCT setup */ + s->fdct[1] = dsp.fdct248; +- s->idct_put[1] = simple_idct248_put; // FIXME: need to add it to DSP ++ s->idct_put[1] = ff_simple_idct248_put; // FIXME: need to add it to DSP + if(avctx->lowres){ + for (i=0; i<64; i++){ + int j= ff_zigzag248_direct[i]; +@@ -363,7 +363,7 @@ + + /* mb_x and mb_y are in units of 8 pixels */ + static inline void dv_decode_video_segment(DVVideoContext *s, +- uint8_t *buf_ptr1, ++ const uint8_t *buf_ptr1, + const uint16_t *mb_pos_ptr) + { + int quant, dc, dct_mode, class1, j; +@@ -372,7 +372,7 @@ + int c_offset; + uint8_t *y_ptr; + void (*idct_put)(uint8_t *dest, int line_size, DCTELEM *block); +- uint8_t *buf_ptr; ++ const uint8_t *buf_ptr; + PutBitContext pb, vs_pb; + GetBitContext gb; + BlockInfo mb_data[5 * 6], *mb, *mb1; +@@ -1031,7 +1031,7 @@ + 144000 bytes for PAL - or twice those for 50Mbps) */ + static int dvvideo_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + DVVideoContext *s = avctx->priv_data; + +diff -u mplayer-1.0~rc2-12/libavcodec/dvdata.h ffmpeg-free-0.svn20080206/libavcodec/dvdata.h +--- mplayer-1.0~rc2-12/libavcodec/dvdata.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/dvdata.h 2008-02-01 16:08:55.000000000 +0100 +@@ -24,8 +24,8 @@ + * Constants for DV codec. + */ + +-#ifndef AVCODEC_DVDATA_H +-#define AVCODEC_DVDATA_H ++#ifndef FFMPEG_DVDATA_H ++#define FFMPEG_DVDATA_H + + #include "avcodec.h" + #include "rational.h" +@@ -335,7 +335,7 @@ + + static const uint8_t dv_quant_offset[4] = { 6, 3, 0, 1 }; + +-/* NOTE: I prefer hardcoding the positionning of dv blocks, it is ++/* NOTE: I prefer hardcoding the positioning of dv blocks, it is + simpler :-) */ + + static const uint16_t dv_place_420[1620] = { +@@ -2661,7 +2661,7 @@ + /* largest possible DV frame, in bytes (PAL 50Mbps) */ + #define DV_MAX_FRAME_SIZE 288000 + +-static inline const DVprofile* dv_frame_profile(uint8_t* frame) ++static inline const DVprofile* dv_frame_profile(const uint8_t* frame) + { + if ((frame[3] & 0x80) == 0) { /* DSF flag */ + /* it's an NTSC format */ +@@ -2729,4 +2729,4 @@ + return 3; + } + +-#endif // AVCODEC_DVDATA_H ++#endif /* FFMPEG_DVDATA_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/dvdsubdec.c ffmpeg-free-0.svn20080206/libavcodec/dvdsubdec.c +--- mplayer-1.0~rc2-12/libavcodec/dvdsubdec.c 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/dvdsubdec.c 2008-03-20 19:10:58.000000000 +0100 +@@ -42,11 +42,6 @@ + } + } + +-static int dvdsub_init_decoder(AVCodecContext *avctx) +-{ +- return 0; +-} +- + static int decode_run_2bit(GetBitContext *gb, int *color) + { + unsigned int v, t; +@@ -443,11 +438,6 @@ + return 1; + } + +-static int dvdsub_close_decoder(AVCodecContext *avctx) +-{ +- return 0; +-} +- + #ifdef DEBUG + #undef fprintf + static void ppm_save(const char *filename, uint8_t *bitmap, int w, int h, +@@ -479,7 +469,7 @@ + + static int dvdsub_decode(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + AVSubtitle *sub = (void *)data; + int is_menu; +@@ -512,8 +502,8 @@ + CODEC_TYPE_SUBTITLE, + CODEC_ID_DVD_SUBTITLE, + 0, +- dvdsub_init_decoder, + NULL, +- dvdsub_close_decoder, ++ NULL, ++ NULL, + dvdsub_decode, + }; +diff -u mplayer-1.0~rc2-12/libavcodec/dvdsubenc.c ffmpeg-free-0.svn20080206/libavcodec/dvdsubenc.c +--- mplayer-1.0~rc2-12/libavcodec/dvdsubenc.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/dvdsubenc.c 2008-03-20 19:10:58.000000000 +0100 +@@ -204,16 +204,6 @@ + return q - outbuf; + } + +-static int dvdsub_init_encoder(AVCodecContext *avctx) +-{ +- return 0; +-} +- +-static int dvdsub_close_encoder(AVCodecContext *avctx) +-{ +- return 0; +-} +- + static int dvdsub_encode(AVCodecContext *avctx, + unsigned char *buf, int buf_size, void *data) + { +@@ -230,11 +220,6 @@ + CODEC_TYPE_SUBTITLE, + CODEC_ID_DVD_SUBTITLE, + 0, +- dvdsub_init_encoder, ++ NULL, + dvdsub_encode, +- dvdsub_close_encoder, + }; +- +-/* Local Variables: */ +-/* c-basic-offset:4 */ +-/* End: */ +diff -u mplayer-1.0~rc2-12/libavcodec/dxa.c ffmpeg-free-0.svn20080206/libavcodec/dxa.c +--- mplayer-1.0~rc2-12/libavcodec/dxa.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/dxa.c 2008-03-20 19:10:58.000000000 +0100 +@@ -187,7 +187,7 @@ + return 0; + } + +-static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8_t *buf, int buf_size) ++static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, const uint8_t *buf, int buf_size) + { + DxaDecContext * const c = avctx->priv_data; + uint8_t *outptr, *srcptr, *tmpptr; +diff -u mplayer-1.0~rc2-12/libavcodec/elbg.h ffmpeg-free-0.svn20080206/libavcodec/elbg.h +--- mplayer-1.0~rc2-12/libavcodec/elbg.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/elbg.h 2007-10-17 11:37:46.000000000 +0200 +@@ -18,8 +18,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef AVCODEC_ELBG_H +-#define AVCODEC_ELBG_H ++#ifndef FFMPEG_ELBG_H ++#define FFMPEG_ELBG_H + + #include "random.h" + +@@ -52,4 +52,4 @@ + int numCB, int num_steps, int *closest_cb, + AVRandomState *rand_state); + +-#endif // AVCODEC_ELBG_H ++#endif /* FFMPEG_ELBG_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/eval.c ffmpeg-free-0.svn20080206/libavcodec/eval.c +--- mplayer-1.0~rc2-12/libavcodec/eval.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/eval.c 2008-03-20 19:10:58.000000000 +0100 +@@ -55,7 +55,7 @@ + double (**func2)(void *, double a, double b); // NULL terminated + char **func2_name; // NULL terminated + void *opaque; +- char **error; ++ const char **error; + #define VARS 10 + double var[VARS]; + } Parser; +@@ -379,7 +379,7 @@ + AVEvalExpr * ff_parse(char *s, const char **const_name, + double (**func1)(void *, double), const char **func1_name, + double (**func2)(void *, double, double), char **func2_name, +- char **error){ ++ const char **error){ + Parser p; + AVEvalExpr * e; + char w[strlen(s) + 1], * wp = w; +@@ -416,7 +416,7 @@ + double ff_eval2(char *s, double *const_value, const char **const_name, + double (**func1)(void *, double), const char **func1_name, + double (**func2)(void *, double, double), char **func2_name, +- void *opaque, char **error){ ++ void *opaque, const char **error){ + AVEvalExpr * e = ff_parse(s, const_name, func1, func1_name, func2, func2_name, error); + double d; + if (!e) return NAN; +@@ -430,7 +430,7 @@ + double (**func1)(void *, double), const char **func1_name, + double (**func2)(void *, double, double), char **func2_name, + void *opaque){ +- char *error=NULL; ++ const char *error=NULL; + double ret; + ret = ff_eval2(s, const_value, const_name, func1, func1_name, func2, func2_name, opaque, &error); + if (error) +@@ -451,7 +451,7 @@ + "E", + 0 + }; +-main(){ ++int main(void){ + int i; + printf("%f == 12.7\n", ff_eval("1+(5-2)^(3-1)+1/2+sin(PI)-max(-2.2,-3.1)", const_values, const_names, NULL, NULL, NULL, NULL, NULL)); + printf("%f == 0.931322575\n", ff_eval("80G/80Gi", const_values, const_names, NULL, NULL, NULL, NULL, NULL)); +@@ -461,5 +461,6 @@ + ff_eval("1+(5-2)^(3-1)+1/2+sin(PI)-max(-2.2,-3.1)", const_values, const_names, NULL, NULL, NULL, NULL, NULL); + STOP_TIMER("ff_eval") + } ++ return 0; + } + #endif +diff -u mplayer-1.0~rc2-12/libavcodec/eval.h ffmpeg-free-0.svn20080206/libavcodec/eval.h +--- mplayer-1.0~rc2-12/libavcodec/eval.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/eval.h 2008-02-04 00:25:35.000000000 +0100 +@@ -25,8 +25,8 @@ + * eval header. + */ + +-#ifndef AVCODEC_EVAL_H +-#define AVCODEC_EVAL_H ++#ifndef FFMPEG_EVAL_H ++#define FFMPEG_EVAL_H + + #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0) + /** +@@ -55,7 +55,7 @@ + double ff_eval2(char *s, double *const_value, const char **const_name, + double (**func1)(void *, double), const char **func1_name, + double (**func2)(void *, double, double), char **func2_name, +- void *opaque, char **error); ++ void *opaque, const char **error); + + typedef struct ff_expr_s AVEvalExpr; + +@@ -74,7 +74,7 @@ + AVEvalExpr * ff_parse(char *s, const char **const_name, + double (**func1)(void *, double), const char **func1_name, + double (**func2)(void *, double, double), char **func2_name, +- char **error); ++ const char **error); + /** + * Evaluates a previously parsed expression. + * @param const_value a zero terminated array of values for the identifers from ff_parse const_name +@@ -84,4 +84,4 @@ + double ff_parse_eval(AVEvalExpr * e, double *const_value, void *opaque); + void ff_eval_free(AVEvalExpr * e); + +-#endif /* AVCODEC_EVAL_H */ ++#endif /* FFMPEG_EVAL_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/faandct.h ffmpeg-free-0.svn20080206/libavcodec/faandct.h +--- mplayer-1.0~rc2-12/libavcodec/faandct.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/faandct.h 2007-10-17 11:37:46.000000000 +0200 +@@ -26,8 +26,8 @@ + * @author Michael Niedermayer + */ + +-#ifndef AVCODEC_FAANDCT_H +-#define AVCODEC_FAANDCT_H ++#ifndef FFMPEG_FAANDCT_H ++#define FFMPEG_FAANDCT_H + + #include "dsputil.h" + +@@ -36,4 +36,4 @@ + void ff_faandct(DCTELEM * data); + void ff_faandct248(DCTELEM * data); + +-#endif // AVCODEC_FAANDCT_H ++#endif /* FFMPEG_FAANDCT_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/ffv1.c ffmpeg-free-0.svn20080206/libavcodec/ffv1.c +--- mplayer-1.0~rc2-12/libavcodec/ffv1.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/ffv1.c 2008-03-20 19:10:58.000000000 +0100 +@@ -936,7 +936,7 @@ + return 0; + } + +-static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8_t *buf, int buf_size){ ++static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, const uint8_t *buf, int buf_size){ + FFV1Context *f = avctx->priv_data; + RangeCoder * const c= &f->c; + const int width= f->width; +diff -u mplayer-1.0~rc2-12/libavcodec/flac.c ffmpeg-free-0.svn20080206/libavcodec/flac.c +--- mplayer-1.0~rc2-12/libavcodec/flac.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/flac.c 2008-03-20 19:10:58.000000000 +0100 +@@ -217,7 +217,7 @@ + int sample = 0, samples; + + method_type = get_bits(&s->gb, 2); +- if (method_type != 0){ ++ if (method_type > 1){ + av_log(s->avctx, AV_LOG_DEBUG, "illegal residual coding method %d\n", method_type); + return -1; + } +@@ -234,8 +234,8 @@ + i= pred_order; + for (partition = 0; partition < (1 << rice_order); partition++) + { +- tmp = get_bits(&s->gb, 4); +- if (tmp == 15) ++ tmp = get_bits(&s->gb, method_type == 0 ? 4 : 5); ++ if (tmp == (method_type == 0 ? 15 : 31)) + { + av_log(s->avctx, AV_LOG_DEBUG, "fixed len partition\n"); + tmp = get_bits(&s->gb, 5); +@@ -558,7 +558,8 @@ + } + + skip_bits(&s->gb, 8); +- crc8= av_crc(av_crc07, 0, s->gb.buffer, get_bits_count(&s->gb)/8); ++ crc8 = av_crc(av_crc_get_table(AV_CRC_8_ATM), 0, ++ s->gb.buffer, get_bits_count(&s->gb)/8); + if(crc8){ + av_log(s->avctx, AV_LOG_ERROR, "header crc mismatch crc=%2X\n", crc8); + return -1; +@@ -589,7 +590,7 @@ + + static int flac_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + FLACContext *s = avctx->priv_data; + int tmp = 0, i, j = 0, input_buf_size = 0; +@@ -628,9 +629,9 @@ + if (!metadata_parse(s)) + { + tmp = show_bits(&s->gb, 16); +- if(tmp != 0xFFF8){ ++ if((tmp & 0xFFFE) != 0xFFF8){ + av_log(s->avctx, AV_LOG_ERROR, "FRAME HEADER not here\n"); +- while(get_bits_count(&s->gb)/8+2 < buf_size && show_bits(&s->gb, 16) != 0xFFF8) ++ while(get_bits_count(&s->gb)/8+2 < buf_size && (show_bits(&s->gb, 16) & 0xFFFE) != 0xFFF8) + skip_bits(&s->gb, 8); + goto end; // we may not have enough bits left to decode a frame, so try next time + } +diff -u mplayer-1.0~rc2-12/libavcodec/flacenc.c ffmpeg-free-0.svn20080206/libavcodec/flacenc.c +--- mplayer-1.0~rc2-12/libavcodec/flacenc.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/flacenc.c 2008-03-20 19:10:58.000000000 +0100 +@@ -474,16 +474,15 @@ + uint32_t all_bits; + + part = (1 << porder); +- all_bits = 0; ++ all_bits = 4 * part; + + cnt = (n >> porder) - pred_order; + for(i=0; i> porder); + k = find_optimal_param(sums[i], cnt); + rc->params[i] = k; + all_bits += rice_encode_count(sums[i], cnt, k); ++ cnt = n >> porder; + } +- all_bits += (4 * part); + + rc->porder = porder; + +@@ -1284,7 +1283,8 @@ + put_bits(&s->pb, 16, s->sr_code[1]); + } + flush_put_bits(&s->pb); +- crc = av_crc(av_crc07, 0, s->pb.buf, put_bits_count(&s->pb)>>3); ++ crc = av_crc(av_crc_get_table(AV_CRC_8_ATM), 0, ++ s->pb.buf, put_bits_count(&s->pb)>>3); + put_bits(&s->pb, 8, crc); + } + +@@ -1426,7 +1426,8 @@ + { + int crc; + flush_put_bits(&s->pb); +- crc = bswap_16(av_crc(av_crc8005, 0, s->pb.buf, put_bits_count(&s->pb)>>3)); ++ crc = bswap_16(av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, ++ s->pb.buf, put_bits_count(&s->pb)>>3)); + put_bits(&s->pb, 16, crc); + flush_put_bits(&s->pb); + } +diff -u mplayer-1.0~rc2-12/libavcodec/flashsv.c ffmpeg-free-0.svn20080206/libavcodec/flashsv.c +--- mplayer-1.0~rc2-12/libavcodec/flashsv.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/flashsv.c 2008-03-20 19:10:58.000000000 +0100 +@@ -102,7 +102,7 @@ + + static int flashsv_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + FlashSVContext *s = avctx->priv_data; + int h_blocks, v_blocks, h_part, v_part, i, j; +diff -u mplayer-1.0~rc2-12/libavcodec/flicvideo.c ffmpeg-free-0.svn20080206/libavcodec/flicvideo.c +--- mplayer-1.0~rc2-12/libavcodec/flicvideo.c 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/flicvideo.c 2008-03-20 19:10:58.000000000 +0100 +@@ -127,7 +127,7 @@ + + static int flic_decode_frame_8BPP(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + FlicDecodeContext *s = avctx->priv_data; + +@@ -427,7 +427,7 @@ + + static int flic_decode_frame_15_16BPP(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + /* Note, the only difference between the 15Bpp and 16Bpp */ + /* Format is the pixel format, the packets are processed the same. */ +@@ -692,7 +692,7 @@ + + static int flic_decode_frame_24BPP(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + av_log(avctx, AV_LOG_ERROR, "24Bpp FLC Unsupported due to lack of test files.\n"); + return -1; +@@ -700,7 +700,7 @@ + + static int flic_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + if (avctx->pix_fmt == PIX_FMT_PAL8) { + return flic_decode_frame_8BPP(avctx, data, data_size, +diff -u mplayer-1.0~rc2-12/libavcodec/fraps.c ffmpeg-free-0.svn20080206/libavcodec/fraps.c +--- mplayer-1.0~rc2-12/libavcodec/fraps.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/fraps.c 2008-03-20 19:10:58.000000000 +0100 +@@ -33,30 +33,18 @@ + + #include "avcodec.h" + #include "bitstream.h" ++#include "huffman.h" ++#include "bytestream.h" + #include "dsputil.h" + + #define FPS_TAG MKTAG('F', 'P', 'S', 'x') + +-/* symbol for Huffman tree node */ +-#define HNODE -1 +- +-/** +- * Huffman node +- * FIXME one day this should belong to one general framework +- */ +-typedef struct Node{ +- int16_t sym; +- int16_t n0; +- int count; +-}Node; +- + /** + * local variable storage + */ + typedef struct FrapsContext{ + AVCodecContext *avctx; + AVFrame frame; +- Node nodes[512]; + uint8_t *tmpbuf; + DSPContext dsp; + } FrapsContext; +@@ -92,82 +80,22 @@ + return (a->count - b->count)*256 + a->sym - b->sym; + } + +-static void get_tree_codes(uint32_t *bits, int16_t *lens, uint8_t *xlat, Node *nodes, int node, uint32_t pfx, int pl, int *pos) +-{ +- int s; +- +- s = nodes[node].sym; +- if(s != HNODE || !nodes[node].count){ +- bits[*pos] = pfx; +- lens[*pos] = pl; +- xlat[*pos] = s; +- (*pos)++; +- }else{ +- pfx <<= 1; +- pl++; +- get_tree_codes(bits, lens, xlat, nodes, nodes[node].n0, pfx, pl, pos); +- pfx |= 1; +- get_tree_codes(bits, lens, xlat, nodes, nodes[node].n0+1, pfx, pl, pos); +- } +-} +- +-static int build_huff_tree(VLC *vlc, Node *nodes, uint8_t *xlat) +-{ +- uint32_t bits[256]; +- int16_t lens[256]; +- int pos = 0; +- +- get_tree_codes(bits, lens, xlat, nodes, 510, 0, 0, &pos); +- return init_vlc(vlc, 9, pos, lens, 2, 2, bits, 4, 4, 0); +-} +- +- + /** + * decode Fraps v2 packed plane + */ + static int fraps2_decode_plane(FrapsContext *s, uint8_t *dst, int stride, int w, +- int h, uint8_t *src, int size, int Uoff) ++ int h, const uint8_t *src, int size, int Uoff) + { + int i, j; +- int cur_node; + GetBitContext gb; + VLC vlc; +- int64_t sum = 0; +- uint8_t recode[256]; ++ Node nodes[512]; + +- for(i = 0; i < 256; i++){ +- s->nodes[i].sym = i; +- s->nodes[i].count = AV_RL32(src); +- s->nodes[i].n0 = -2; +- if(s->nodes[i].count < 0) { +- av_log(s->avctx, AV_LOG_ERROR, "Symbol count < 0\n"); +- return -1; +- } +- src += 4; +- sum += s->nodes[i].count; +- } ++ for(i = 0; i < 256; i++) ++ nodes[i].count = bytestream_get_le32(&src); + size -= 1024; +- +- if(sum >> 31) { +- av_log(s->avctx, AV_LOG_ERROR, "Too high symbol frequencies. Tree construction is not possible\n"); +- return -1; +- } +- qsort(s->nodes, 256, sizeof(Node), huff_cmp); +- cur_node = 256; +- for(i = 0; i < 511; i += 2){ +- s->nodes[cur_node].sym = HNODE; +- s->nodes[cur_node].count = s->nodes[i].count + s->nodes[i+1].count; +- s->nodes[cur_node].n0 = i; +- for(j = cur_node; j > 0; j--){ +- if(s->nodes[j].count >= s->nodes[j - 1].count) break; +- FFSWAP(Node, s->nodes[j], s->nodes[j - 1]); +- } +- cur_node++; +- } +- if(build_huff_tree(&vlc, s->nodes, recode) < 0){ +- av_log(s->avctx, AV_LOG_ERROR, "Error building tree\n"); ++ if (ff_huff_build_tree(s->avctx, &vlc, 256, nodes, huff_cmp, 0) < 0) + return -1; +- } + /* we have built Huffman table and are ready to decode plane */ + + /* convert bits so they may be used by standard bitreader */ +@@ -176,7 +104,7 @@ + init_get_bits(&gb, s->tmpbuf, size * 8); + for(j = 0; j < h; j++){ + for(i = 0; i < w; i++){ +- dst[i] = recode[get_vlc2(&gb, vlc.table, 9, 3)]; ++ dst[i] = get_vlc2(&gb, vlc.table, 9, 3); + /* lines are stored as deltas between previous lines + * and we need to add 0x80 to the first lines of chroma planes + */ +@@ -200,7 +128,7 @@ + */ + static int decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + FrapsContext * const s = avctx->priv_data; + AVFrame *frame = data; +@@ -208,7 +136,7 @@ + uint32_t header; + unsigned int version,header_size; + unsigned int x, y; +- uint32_t *buf32; ++ const uint32_t *buf32; + uint32_t *luma1,*luma2,*cb,*cr; + uint32_t offs[4]; + int i, is_chroma, planes; +@@ -262,7 +190,7 @@ + f->key_frame = f->pict_type == FF_I_TYPE; + + if (f->pict_type == FF_I_TYPE) { +- buf32=(uint32_t*)buf; ++ buf32=(const uint32_t*)buf; + for(y=0; yheight/2; y++){ + luma1=(uint32_t*)&f->data[0][ y*2*f->linesize[0] ]; + luma2=(uint32_t*)&f->data[0][ (y*2+1)*f->linesize[0] ]; +diff -u mplayer-1.0~rc2-12/libavcodec/g726.c ffmpeg-free-0.svn20080206/libavcodec/g726.c +--- mplayer-1.0~rc2-12/libavcodec/g726.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/g726.c 2008-03-20 19:10:58.000000000 +0100 +@@ -64,14 +64,14 @@ + + typedef struct G726Tables { + int bits; /**< bits per sample */ +- int* quant; /**< quantization table */ +- int* iquant; /**< inverse quantization table */ +- int* W; /**< special table #1 ;-) */ +- int* F; /**< special table #2 */ ++ const int* quant; /**< quantization table */ ++ const int* iquant; /**< inverse quantization table */ ++ const int* W; /**< special table #1 ;-) */ ++ const int* F; /**< special table #2 */ + } G726Tables; + + typedef struct G726Context { +- G726Tables* tbls; /**< static tables needed for computation */ ++ const G726Tables* tbls; /**< static tables needed for computation */ + + Float11 sr[2]; /**< prev. reconstructed samples */ + Float11 dq[6]; /**< prev. difference */ +@@ -91,53 +91,53 @@ + int y; /**< quantizer scaling factor for the next iteration */ + } G726Context; + +-static int quant_tbl16[] = /**< 16kbit/s 2bits per sample */ ++static const int quant_tbl16[] = /**< 16kbit/s 2bits per sample */ + { 260, INT_MAX }; +-static int iquant_tbl16[] = ++static const int iquant_tbl16[] = + { 116, 365, 365, 116 }; +-static int W_tbl16[] = ++static const int W_tbl16[] = + { -22, 439, 439, -22 }; +-static int F_tbl16[] = ++static const int F_tbl16[] = + { 0, 7, 7, 0 }; + +-static int quant_tbl24[] = /**< 24kbit/s 3bits per sample */ ++static const int quant_tbl24[] = /**< 24kbit/s 3bits per sample */ + { 7, 217, 330, INT_MAX }; +-static int iquant_tbl24[] = ++static const int iquant_tbl24[] = + { INT_MIN, 135, 273, 373, 373, 273, 135, INT_MIN }; +-static int W_tbl24[] = ++static const int W_tbl24[] = + { -4, 30, 137, 582, 582, 137, 30, -4 }; +-static int F_tbl24[] = ++static const int F_tbl24[] = + { 0, 1, 2, 7, 7, 2, 1, 0 }; + +-static int quant_tbl32[] = /**< 32kbit/s 4bits per sample */ ++static const int quant_tbl32[] = /**< 32kbit/s 4bits per sample */ + { -125, 79, 177, 245, 299, 348, 399, INT_MAX }; +-static int iquant_tbl32[] = ++static const int iquant_tbl32[] = + { INT_MIN, 4, 135, 213, 273, 323, 373, 425, + 425, 373, 323, 273, 213, 135, 4, INT_MIN }; +-static int W_tbl32[] = ++static const int W_tbl32[] = + { -12, 18, 41, 64, 112, 198, 355, 1122, + 1122, 355, 198, 112, 64, 41, 18, -12}; +-static int F_tbl32[] = ++static const int F_tbl32[] = + { 0, 0, 0, 1, 1, 1, 3, 7, 7, 3, 1, 1, 1, 0, 0, 0 }; + +-static int quant_tbl40[] = /**< 40kbit/s 5bits per sample */ ++static const int quant_tbl40[] = /**< 40kbit/s 5bits per sample */ + { -122, -16, 67, 138, 197, 249, 297, 338, + 377, 412, 444, 474, 501, 527, 552, INT_MAX }; +-static int iquant_tbl40[] = ++static const int iquant_tbl40[] = + { INT_MIN, -66, 28, 104, 169, 224, 274, 318, + 358, 395, 429, 459, 488, 514, 539, 566, + 566, 539, 514, 488, 459, 429, 395, 358, + 318, 274, 224, 169, 104, 28, -66, INT_MIN }; +-static int W_tbl40[] = ++static const int W_tbl40[] = + { 14, 14, 24, 39, 40, 41, 58, 100, + 141, 179, 219, 280, 358, 440, 529, 696, + 696, 529, 440, 358, 280, 219, 179, 141, + 100, 58, 41, 40, 39, 24, 14, 14 }; +-static int F_tbl40[] = ++static const int F_tbl40[] = + { 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 6, + 6, 6, 5, 4, 3, 2, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 }; + +-static G726Tables G726Tables_pool[] = ++static const G726Tables G726Tables_pool[] = + {{ 2, quant_tbl16, iquant_tbl16, W_tbl16, F_tbl16 }, + { 3, quant_tbl24, iquant_tbl24, W_tbl24, F_tbl24 }, + { 4, quant_tbl32, iquant_tbl32, W_tbl32, F_tbl32 }, +@@ -373,7 +373,7 @@ + + static int g726_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + AVG726Context *c = avctx->priv_data; + short *samples = data; +diff -u mplayer-1.0~rc2-12/libavcodec/gif.c ffmpeg-free-0.svn20080206/libavcodec/gif.c +--- mplayer-1.0~rc2-12/libavcodec/gif.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/gif.c 2008-03-20 19:10:58.000000000 +0100 +@@ -136,7 +136,7 @@ + + //printf("bitbuf = %08x\n", bit_buf); + if (s->buf_ptr >= s->buf_end) +- puts("bit buffer overflow !!"); // should never happen ! who got rid of the callback ??? ++ abort(); + // flush_buffer_rev(s); + bit_cnt=bit_cnt + n - 32; + if (bit_cnt == 0) { +diff -u mplayer-1.0~rc2-12/libavcodec/gifdec.c ffmpeg-free-0.svn20080206/libavcodec/gifdec.c +--- mplayer-1.0~rc2-12/libavcodec/gifdec.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/gifdec.c 2008-03-20 19:10:58.000000000 +0100 +@@ -47,8 +47,8 @@ + int gce_delay; + + /* LZW compatible decoder */ +- uint8_t *bytestream; +- uint8_t *bytestream_end; ++ const uint8_t *bytestream; ++ const uint8_t *bytestream_end; + LZWState *lzw; + + /* aux buffers */ +@@ -285,7 +285,7 @@ + return 0; + } + +-static int gif_decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8_t *buf, int buf_size) ++static int gif_decode_frame(AVCodecContext *avctx, void *data, int *data_size, const uint8_t *buf, int buf_size) + { + GifState *s = avctx->priv_data; + AVFrame *picture = data; +diff -u mplayer-1.0~rc2-12/libavcodec/golomb.h ffmpeg-free-0.svn20080206/libavcodec/golomb.h +--- mplayer-1.0~rc2-12/libavcodec/golomb.h 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/golomb.h 2007-10-17 11:37:46.000000000 +0200 +@@ -27,8 +27,8 @@ + * @author Michael Niedermayer and Alex Beregszaszi + */ + +-#ifndef AVCODEC_GOLOMB_H +-#define AVCODEC_GOLOMB_H ++#ifndef FFMPEG_GOLOMB_H ++#define FFMPEG_GOLOMB_H + + #include + #include "bitstream.h" +@@ -504,4 +504,4 @@ + set_ur_golomb_jpegls(pb, v, k, limit, esc_len); + } + +-#endif // AVCODEC_GOLOMB_H ++#endif /* FFMPEG_GOLOMB_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/h261data.h ffmpeg-free-0.svn20080206/libavcodec/h261data.h +--- mplayer-1.0~rc2-12/libavcodec/h261data.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/h261data.h 2007-10-17 11:37:46.000000000 +0200 +@@ -24,8 +24,8 @@ + * H.261 tables. + */ + +-#ifndef AVCODEC_H261DATA_H +-#define AVCODEC_H261DATA_H ++#ifndef FFMPEG_H261DATA_H ++#define FFMPEG_H261DATA_H + + #include + #include "h261.h" +@@ -161,4 +161,4 @@ + h261_tcoeff_level, + }; + +-#endif // AVCODEC_H261DATA_H ++#endif /* FFMPEG_H261DATA_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/h261dec.c ffmpeg-free-0.svn20080206/libavcodec/h261dec.c +--- mplayer-1.0~rc2-12/libavcodec/h261dec.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/h261dec.c 2008-03-20 19:10:58.000000000 +0100 +@@ -540,7 +540,7 @@ + + static int h261_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + H261Context *h= avctx->priv_data; + MpegEncContext *s = &h->s; +diff -u mplayer-1.0~rc2-12/libavcodec/h261enc.c ffmpeg-free-0.svn20080206/libavcodec/h261enc.c +--- mplayer-1.0~rc2-12/libavcodec/h261enc.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/h261enc.c 2008-03-20 19:10:58.000000000 +0100 +@@ -321,14 +321,4 @@ + } + } + +-AVCodec h261_encoder = { +- "h261", +- CODEC_TYPE_VIDEO, +- CODEC_ID_H261, +- sizeof(H261Context), +- MPV_encode_init, +- MPV_encode_picture, +- MPV_encode_end, +- .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1}, +-}; + +diff -u mplayer-1.0~rc2-12/libavcodec/h261.h ffmpeg-free-0.svn20080206/libavcodec/h261.h +--- mplayer-1.0~rc2-12/libavcodec/h261.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/h261.h 2007-10-17 11:37:46.000000000 +0200 +@@ -25,8 +25,8 @@ + * h261codec. + */ + +-#ifndef AVCODEC_H261_H +-#define AVCODEC_H261_H ++#ifndef FFMPEG_H261_H ++#define FFMPEG_H261_H + + #include "mpegvideo.h" + +@@ -48,4 +48,4 @@ + + #define MB_TYPE_H261_FIL 0x800000 + +-#endif /* AVCODEC_H261_H */ ++#endif /* FFMPEG_H261_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/h263.c ffmpeg-free-0.svn20080206/libavcodec/h263.c +--- mplayer-1.0~rc2-12/libavcodec/h263.c 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/h263.c 2008-03-20 19:10:58.000000000 +0100 +@@ -4754,26 +4754,26 @@ + i = -1; + ff_mpeg4_pred_dc(s, n, 0, &dc_pred_dir, 0); + } +- if (!coded) +- goto not_coded; ++ if (!coded) ++ goto not_coded; + +- if(rvlc){ +- rl = &rvlc_rl_intra; +- rl_vlc = rvlc_rl_intra.rl_vlc[0]; +- }else{ +- rl = &rl_intra; +- rl_vlc = rl_intra.rl_vlc[0]; +- } +- if (s->ac_pred) { +- if (dc_pred_dir == 0) +- scan_table = s->intra_v_scantable.permutated; /* left */ +- else +- scan_table = s->intra_h_scantable.permutated; /* top */ +- } else { ++ if(rvlc){ ++ rl = &rvlc_rl_intra; ++ rl_vlc = rvlc_rl_intra.rl_vlc[0]; ++ }else{ ++ rl = &rl_intra; ++ rl_vlc = rl_intra.rl_vlc[0]; ++ } ++ if (s->ac_pred) { ++ if (dc_pred_dir == 0) ++ scan_table = s->intra_v_scantable.permutated; /* left */ ++ else ++ scan_table = s->intra_h_scantable.permutated; /* top */ ++ } else { + scan_table = s->intra_scantable.permutated; +- } +- qmul=1; +- qadd=0; ++ } ++ qmul=1; ++ qadd=0; + } else { + i = -1; + if (!coded) { +diff -u mplayer-1.0~rc2-12/libavcodec/h263data.h ffmpeg-free-0.svn20080206/libavcodec/h263data.h +--- mplayer-1.0~rc2-12/libavcodec/h263data.h 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/h263data.h 2007-10-17 11:37:46.000000000 +0200 +@@ -26,8 +26,8 @@ + * H.263 tables. + */ + +-#ifndef AVCODEC_H263DATA_H +-#define AVCODEC_H263DATA_H ++#ifndef FFMPEG_H263DATA_H ++#define FFMPEG_H263DATA_H + + #include + #include "mpegvideo.h" +@@ -311,4 +311,4 @@ + 0, 1, 1, 2, 2, 3, 3, 4, 4, 4, 5, 5, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9,10,10,10,11,11,11,12,12,12 + }; + +-#endif // AVCODEC_H263DATA_H ++#endif /* FFMPEG_H263DATA_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/h263dec.c ffmpeg-free-0.svn20080206/libavcodec/h263dec.c +--- mplayer-1.0~rc2-12/libavcodec/h263dec.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/h263dec.c 2008-03-20 19:10:58.000000000 +0100 +@@ -322,7 +322,7 @@ + + int ff_h263_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + MpegEncContext *s = avctx->priv_data; + int ret; +@@ -623,9 +623,10 @@ + + //the second part of the wmv2 header contains the MB skip bits which are stored in current_picture->mb_type + //which is not available before MPV_frame_start() +- if (s->msmpeg4_version==5){ +- if(!ENABLE_WMV2_DECODER || ff_wmv2_decode_secondary_picture_header(s) < 0) +- return -1; ++ if (ENABLE_WMV2_DECODER && s->msmpeg4_version==5){ ++ ret = ff_wmv2_decode_secondary_picture_header(s); ++ if(ret<0) return ret; ++ if(ret==1) goto intrax8_decoded; + } + + /* decode each macroblock */ +@@ -682,6 +683,7 @@ + } + } + ++intrax8_decoded: + ff_er_frame_end(s); + + MPV_frame_end(s); +@@ -700,7 +702,7 @@ + } + + /* Return the Picture timestamp as the frame number */ +- /* we substract 1 because it is added on utils.c */ ++ /* we subtract 1 because it is added on utils.c */ + avctx->frame_number = s->picture_number - 1; + + #ifdef PRINT_FRAME_TIME +diff -u mplayer-1.0~rc2-12/libavcodec/h263.h ffmpeg-free-0.svn20080206/libavcodec/h263.h +--- mplayer-1.0~rc2-12/libavcodec/h263.h 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/h263.h 2007-10-17 11:37:46.000000000 +0200 +@@ -19,8 +19,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef AVCODEC_H263_H +-#define AVCODEC_H263_H ++#ifndef FFMPEG_H263_H ++#define FFMPEG_H263_H + + #include "config.h" + #include "msmpeg4.h" +@@ -43,4 +43,4 @@ + ENABLE_WMV_ENCODER) + #define ENABLE_ANY_H263 (ENABLE_ANY_H263_DECODER || ENABLE_ANY_H263_ENCODER) + +-#endif /* AVCODEC_H263_H */ ++#endif /* FFMPEG_H263_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/h263_parser.c ffmpeg-free-0.svn20080206/libavcodec/h263_parser.c +--- mplayer-1.0~rc2-12/libavcodec/h263_parser.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/h263_parser.c 2008-03-20 19:10:58.000000000 +0100 +@@ -77,7 +77,7 @@ + return buf_size; + } + +- *poutbuf = (uint8_t *)buf; ++ *poutbuf = buf; + *poutbuf_size = buf_size; + return next; + } +diff -u mplayer-1.0~rc2-12/libavcodec/h263_parser.h ffmpeg-free-0.svn20080206/libavcodec/h263_parser.h +--- mplayer-1.0~rc2-12/libavcodec/h263_parser.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/h263_parser.h 2007-10-17 11:37:46.000000000 +0200 +@@ -19,11 +19,11 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef AVCODEC_H263_PARSER_H +-#define AVCODEC_H263_PARSER_H ++#ifndef FFMPEG_H263_PARSER_H ++#define FFMPEG_H263_PARSER_H + + #include "parser.h" + + int ff_h263_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size); + +-#endif // AVCODEC_H263_PARSER_H ++#endif /* FFMPEG_H263_PARSER_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/h264.c ffmpeg-free-0.svn20080206/libavcodec/h264.c +--- mplayer-1.0~rc2-12/libavcodec/h264.c 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/h264.c 2008-03-20 19:10:58.000000000 +0100 +@@ -32,6 +32,7 @@ + #include "h264data.h" + #include "h264_parser.h" + #include "golomb.h" ++#include "rectangle.h" + + #include "cabac.h" + +@@ -75,109 +76,23 @@ + }; + + +-/** +- * fill a rectangle. +- * @param h height of the rectangle, should be a constant +- * @param w width of the rectangle, should be a constant +- * @param size the size of val (1 or 4), should be a constant +- */ +-static av_always_inline void fill_rectangle(void *vp, int w, int h, int stride, uint32_t val, int size){ +- uint8_t *p= (uint8_t*)vp; +- assert(size==1 || size==4); +- assert(w<=4); +- +- w *= size; +- stride *= size; +- +- assert((((long)vp)&(FFMIN(w, STRIDE_ALIGN)-1)) == 0); +- assert((stride&(w-1))==0); +- if(w==2){ +- const uint16_t v= size==4 ? val : val*0x0101; +- *(uint16_t*)(p + 0*stride)= v; +- if(h==1) return; +- *(uint16_t*)(p + 1*stride)= v; +- if(h==2) return; +- *(uint16_t*)(p + 2*stride)= v; +- *(uint16_t*)(p + 3*stride)= v; +- }else if(w==4){ +- const uint32_t v= size==4 ? val : val*0x01010101; +- *(uint32_t*)(p + 0*stride)= v; +- if(h==1) return; +- *(uint32_t*)(p + 1*stride)= v; +- if(h==2) return; +- *(uint32_t*)(p + 2*stride)= v; +- *(uint32_t*)(p + 3*stride)= v; +- }else if(w==8){ +- //gcc can't optimize 64bit math on x86_32 +-#if defined(ARCH_X86_64) || (defined(MP_WORDSIZE) && MP_WORDSIZE >= 64) +- const uint64_t v= val*0x0100000001ULL; +- *(uint64_t*)(p + 0*stride)= v; +- if(h==1) return; +- *(uint64_t*)(p + 1*stride)= v; +- if(h==2) return; +- *(uint64_t*)(p + 2*stride)= v; +- *(uint64_t*)(p + 3*stride)= v; +- }else if(w==16){ +- const uint64_t v= val*0x0100000001ULL; +- *(uint64_t*)(p + 0+0*stride)= v; +- *(uint64_t*)(p + 8+0*stride)= v; +- *(uint64_t*)(p + 0+1*stride)= v; +- *(uint64_t*)(p + 8+1*stride)= v; +- if(h==2) return; +- *(uint64_t*)(p + 0+2*stride)= v; +- *(uint64_t*)(p + 8+2*stride)= v; +- *(uint64_t*)(p + 0+3*stride)= v; +- *(uint64_t*)(p + 8+3*stride)= v; +-#else +- *(uint32_t*)(p + 0+0*stride)= val; +- *(uint32_t*)(p + 4+0*stride)= val; +- if(h==1) return; +- *(uint32_t*)(p + 0+1*stride)= val; +- *(uint32_t*)(p + 4+1*stride)= val; +- if(h==2) return; +- *(uint32_t*)(p + 0+2*stride)= val; +- *(uint32_t*)(p + 4+2*stride)= val; +- *(uint32_t*)(p + 0+3*stride)= val; +- *(uint32_t*)(p + 4+3*stride)= val; +- }else if(w==16){ +- *(uint32_t*)(p + 0+0*stride)= val; +- *(uint32_t*)(p + 4+0*stride)= val; +- *(uint32_t*)(p + 8+0*stride)= val; +- *(uint32_t*)(p +12+0*stride)= val; +- *(uint32_t*)(p + 0+1*stride)= val; +- *(uint32_t*)(p + 4+1*stride)= val; +- *(uint32_t*)(p + 8+1*stride)= val; +- *(uint32_t*)(p +12+1*stride)= val; +- if(h==2) return; +- *(uint32_t*)(p + 0+2*stride)= val; +- *(uint32_t*)(p + 4+2*stride)= val; +- *(uint32_t*)(p + 8+2*stride)= val; +- *(uint32_t*)(p +12+2*stride)= val; +- *(uint32_t*)(p + 0+3*stride)= val; +- *(uint32_t*)(p + 4+3*stride)= val; +- *(uint32_t*)(p + 8+3*stride)= val; +- *(uint32_t*)(p +12+3*stride)= val; +-#endif +- }else +- assert(0); +- assert(h==4); +-} +- + static void fill_caches(H264Context *h, int mb_type, int for_deblock){ + MpegEncContext * const s = &h->s; + const int mb_xy= s->mb_x + s->mb_y*s->mb_stride; + int topleft_xy, top_xy, topright_xy, left_xy[2]; + int topleft_type, top_type, topright_type, left_type[2]; + int left_block[8]; ++ int topleft_partition= -1; + int i; + ++ top_xy = mb_xy - (s->mb_stride << FIELD_PICTURE); ++ + //FIXME deblocking could skip the intra and nnz parts. +- if(for_deblock && (h->slice_num == 1 || h->slice_table[mb_xy] == h->slice_table[mb_xy-s->mb_stride]) && !FRAME_MBAFF) ++ if(for_deblock && (h->slice_num == 1 || h->slice_table[mb_xy] == h->slice_table[top_xy]) && !FRAME_MBAFF) + return; + + //wow what a mess, why didn't they simplify the interlacing&intra stuff, i can't imagine that these complex rules are worth it + +- top_xy = mb_xy - (s->mb_stride << FIELD_PICTURE); + topleft_xy = top_xy - 1; + topright_xy= top_xy + 1; + left_xy[1] = left_xy[0] = mb_xy-1; +@@ -212,6 +127,10 @@ + : (!curr_mb_frame_flag && !topleft_mb_frame_flag) // top macroblock + ) { + topleft_xy -= s->mb_stride; ++ } else if(bottom && curr_mb_frame_flag && !left_mb_frame_flag) { ++ topleft_xy += s->mb_stride; ++ // take topleft mv from the middle of the mb, as opposed to all other modes which use the bottom-right partition ++ topleft_partition = 0; + } + if (bottom + ? !curr_mb_frame_flag // bottom macroblock +@@ -489,8 +408,8 @@ + continue; + + if(USES_LIST(topleft_type, list)){ +- const int b_xy = h->mb2b_xy[topleft_xy] + 3 + 3*h->b_stride; +- const int b8_xy= h->mb2b8_xy[topleft_xy] + 1 + h->b8_stride; ++ const int b_xy = h->mb2b_xy[topleft_xy] + 3 + h->b_stride + (topleft_partition & 2*h->b_stride); ++ const int b8_xy= h->mb2b8_xy[topleft_xy] + 1 + (topleft_partition & h->b8_stride); + *(uint32_t*)h->mv_cache[list][scan8[0] - 1 - 1*8]= *(uint32_t*)s->current_picture.motion_val[list][b_xy]; + h->ref_cache[list][scan8[0] - 1 - 1*8]= s->current_picture.ref_index[list][b8_xy]; + }else{ +@@ -787,7 +706,7 @@ + #define SET_DIAG_MV(MV_OP, REF_OP, X4, Y4)\ + const int x4 = X4, y4 = Y4;\ + const int mb_type = mb_types[(x4>>2)+(y4>>2)*s->mb_stride];\ +- if(!USES_LIST(mb_type,list) && !IS_8X8(mb_type))\ ++ if(!USES_LIST(mb_type,list))\ + return LIST_NOT_USED;\ + mv = s->current_picture_ptr->motion_val[list][x4 + y4*h->b_stride];\ + h->mv_cache[list][scan8[0]-2][0] = mv[0];\ +@@ -808,7 +727,7 @@ + && !IS_INTERLACED(mb_types[h->left_mb_xy[0]]) + && i >= scan8[0]+8){ + // leftshift will turn LIST_NOT_USED into PART_NOT_AVAILABLE, but that's ok. +- SET_DIAG_MV(>>1, <<1, s->mb_x*4-1, (s->mb_y&~1)*4 - 1 + ((i-scan8[0])>>3)*2); ++ SET_DIAG_MV(/2, <<1, s->mb_x*4-1, (s->mb_y&~1)*4 - 1 + ((i-scan8[0])>>3)*2); + } + } + #undef SET_DIAG_MV +@@ -1103,14 +1022,76 @@ + } + + if(ref[1] < 0){ +- *mb_type &= ~MB_TYPE_P0L1; +- sub_mb_type &= ~MB_TYPE_P0L1; ++ if(!is_b8x8) ++ *mb_type &= ~MB_TYPE_L1; ++ sub_mb_type &= ~MB_TYPE_L1; + }else if(ref[0] < 0){ +- *mb_type &= ~MB_TYPE_P0L0; +- sub_mb_type &= ~MB_TYPE_P0L0; ++ if(!is_b8x8) ++ *mb_type &= ~MB_TYPE_L0; ++ sub_mb_type &= ~MB_TYPE_L0; + } + +- if(IS_16X16(*mb_type)){ ++ if(IS_INTERLACED(*mb_type) != IS_INTERLACED(mb_type_col)){ ++ int pair_xy = s->mb_x + (s->mb_y&~1)*s->mb_stride; ++ int mb_types_col[2]; ++ int b8_stride = h->b8_stride; ++ int b4_stride = h->b_stride; ++ ++ *mb_type = (*mb_type & ~MB_TYPE_16x16) | MB_TYPE_8x8; ++ ++ if(IS_INTERLACED(*mb_type)){ ++ mb_types_col[0] = h->ref_list[1][0].mb_type[pair_xy]; ++ mb_types_col[1] = h->ref_list[1][0].mb_type[pair_xy+s->mb_stride]; ++ if(s->mb_y&1){ ++ l1ref0 -= 2*b8_stride; ++ l1ref1 -= 2*b8_stride; ++ l1mv0 -= 4*b4_stride; ++ l1mv1 -= 4*b4_stride; ++ } ++ b8_stride *= 3; ++ b4_stride *= 6; ++ }else{ ++ int cur_poc = s->current_picture_ptr->poc; ++ int *col_poc = h->ref_list[1]->field_poc; ++ int col_parity = FFABS(col_poc[0] - cur_poc) >= FFABS(col_poc[1] - cur_poc); ++ int dy = 2*col_parity - (s->mb_y&1); ++ mb_types_col[0] = ++ mb_types_col[1] = h->ref_list[1][0].mb_type[pair_xy + col_parity*s->mb_stride]; ++ l1ref0 += dy*b8_stride; ++ l1ref1 += dy*b8_stride; ++ l1mv0 += 2*dy*b4_stride; ++ l1mv1 += 2*dy*b4_stride; ++ b8_stride = 0; ++ } ++ ++ for(i8=0; i8<4; i8++){ ++ int x8 = i8&1; ++ int y8 = i8>>1; ++ int xy8 = x8+y8*b8_stride; ++ int xy4 = 3*x8+y8*b4_stride; ++ int a=0, b=0; ++ ++ if(is_b8x8 && !IS_DIRECT(h->sub_mb_type[i8])) ++ continue; ++ h->sub_mb_type[i8] = sub_mb_type; ++ ++ fill_rectangle(&h->ref_cache[0][scan8[i8*4]], 2, 2, 8, (uint8_t)ref[0], 1); ++ fill_rectangle(&h->ref_cache[1][scan8[i8*4]], 2, 2, 8, (uint8_t)ref[1], 1); ++ if(!IS_INTRA(mb_types_col[y8]) ++ && ( (l1ref0[xy8] == 0 && FFABS(l1mv0[xy4][0]) <= 1 && FFABS(l1mv0[xy4][1]) <= 1) ++ || (l1ref0[xy8] < 0 && l1ref1[xy8] == 0 && FFABS(l1mv1[xy4][0]) <= 1 && FFABS(l1mv1[xy4][1]) <= 1))){ ++ if(ref[0] > 0) ++ a= pack16to32(mv[0][0],mv[0][1]); ++ if(ref[1] > 0) ++ b= pack16to32(mv[1][0],mv[1][1]); ++ }else{ ++ a= pack16to32(mv[0][0],mv[0][1]); ++ b= pack16to32(mv[1][0],mv[1][1]); ++ } ++ fill_rectangle(&h->mv_cache[0][scan8[i8*4]], 2, 2, 8, a, 4); ++ fill_rectangle(&h->mv_cache[1][scan8[i8*4]], 2, 2, 8, b, 4); ++ } ++ }else if(IS_16X16(*mb_type)){ + int a=0, b=0; + + fill_rectangle(&h->ref_cache[0][scan8[0]], 4, 4, 8, (uint8_t)ref[0], 1); +@@ -1394,7 +1375,7 @@ + * @param dst_length is the number of decoded bytes FIXME here or a decode rbsp tailing? + * @returns decoded bytes, might be src+1 if no escapes + */ +-static uint8_t *decode_nal(H264Context *h, uint8_t *src, int *dst_length, int *consumed, int length){ ++static const uint8_t *decode_nal(H264Context *h, const uint8_t *src, int *dst_length, int *consumed, int length){ + int i, si, di; + uint8_t *dst; + int bufidx; +@@ -1461,7 +1442,7 @@ + * identifies the exact end of the bitstream + * @return the length of the trailing, or 0 if damaged + */ +-static int decode_rbsp_trailing(H264Context *h, uint8_t *src){ ++static int decode_rbsp_trailing(H264Context *h, const uint8_t *src){ + int v= *src; + int r; + +@@ -1703,7 +1684,7 @@ + const int full_mx= mx>>2; + const int full_my= my>>2; + const int pic_width = 16*s->mb_width; +- const int pic_height = 16*s->mb_height >> (MB_MBAFF || FIELD_PICTURE); ++ const int pic_height = 16*s->mb_height >> MB_FIELD; + + if(!pic->data[0]) //FIXME this is unacceptable, some senseable error concealment must be done for missing reference frames + return; +@@ -1727,9 +1708,9 @@ + + if(ENABLE_GRAY && s->flags&CODEC_FLAG_GRAY) return; + +- if(MB_MBAFF || FIELD_PICTURE){ ++ if(MB_FIELD){ + // chroma offset when predicting from a field of opposite parity +- my += 2 * ((s->mb_y & 1) - (h->ref_cache[list][scan8[n]] & 1)); ++ my += 2 * ((s->mb_y & 1) - (pic->reference - 1)); + emu |= (my>>3) < 0 || (my>>3) + 8 >= (pic_height>>1); + } + src_cb= pic->data[1] + (mx>>3) + (my>>3)*h->mb_uvlinesize; +@@ -1762,7 +1743,7 @@ + dest_cb += x_offset + y_offset*h->mb_uvlinesize; + dest_cr += x_offset + y_offset*h->mb_uvlinesize; + x_offset += 8*s->mb_x; +- y_offset += 8*(s->mb_y >> (MB_MBAFF || FIELD_PICTURE)); ++ y_offset += 8*(s->mb_y >> MB_FIELD); + + if(list0){ + Picture *ref= &h->ref_list[0][ h->ref_cache[0][ scan8[n] ] ]; +@@ -1795,7 +1776,7 @@ + dest_cb += x_offset + y_offset*h->mb_uvlinesize; + dest_cr += x_offset + y_offset*h->mb_uvlinesize; + x_offset += 8*s->mb_x; +- y_offset += 8*(s->mb_y >> (MB_MBAFF || FIELD_PICTURE)); ++ y_offset += 8*(s->mb_y >> MB_FIELD); + + if(list0 && list1){ + /* don't optimize for luma-only case, since B-frames usually +@@ -2037,7 +2018,6 @@ + av_freep(&hx->top_borders[1]); + av_freep(&hx->top_borders[0]); + av_freep(&hx->s.obmc_scratchpad); +- av_freep(&hx->s.allocated_edge_emu_buffer); + } + } + +@@ -2121,12 +2101,10 @@ + CHECKED_ALLOCZ(h->slice_table_base , (big_mb_num+s->mb_stride) * sizeof(uint8_t)) + CHECKED_ALLOCZ(h->cbp_table, big_mb_num * sizeof(uint16_t)) + +- if( h->pps.cabac ) { +- CHECKED_ALLOCZ(h->chroma_pred_mode_table, big_mb_num * sizeof(uint8_t)) +- CHECKED_ALLOCZ(h->mvd_table[0], 32*big_mb_num * sizeof(uint16_t)); +- CHECKED_ALLOCZ(h->mvd_table[1], 32*big_mb_num * sizeof(uint16_t)); +- CHECKED_ALLOCZ(h->direct_table, 32*big_mb_num * sizeof(uint8_t)); +- } ++ CHECKED_ALLOCZ(h->chroma_pred_mode_table, big_mb_num * sizeof(uint8_t)) ++ CHECKED_ALLOCZ(h->mvd_table[0], 32*big_mb_num * sizeof(uint16_t)); ++ CHECKED_ALLOCZ(h->mvd_table[1], 32*big_mb_num * sizeof(uint16_t)); ++ CHECKED_ALLOCZ(h->direct_table, 32*big_mb_num * sizeof(uint8_t)); + + memset(h->slice_table_base, -1, (big_mb_num+s->mb_stride) * sizeof(uint8_t)); + h->slice_table= h->slice_table_base + s->mb_stride*2 + 1; +@@ -2179,15 +2157,9 @@ + * Allocate buffers which are not shared amongst multiple threads. + */ + static int context_init(H264Context *h){ +- MpegEncContext * const s = &h->s; +- + CHECKED_ALLOCZ(h->top_borders[0], h->s.mb_width * (16+8+8) * sizeof(uint8_t)) + CHECKED_ALLOCZ(h->top_borders[1], h->s.mb_width * (16+8+8) * sizeof(uint8_t)) + +- // edge emu needs blocksize + filter length - 1 (=17x17 for halfpel / 21x21 for h264) +- CHECKED_ALLOCZ(s->allocated_edge_emu_buffer, +- (s->width+64)*2*21*2); //(width + edge + align)*interlaced*MBsize*tolerance +- s->edge_emu_buffer= s->allocated_edge_emu_buffer + (s->width+64)*2*21; + return 0; + fail: + return -1; // free_tables will clean up for us +@@ -2496,13 +2468,13 @@ + continue; + if(IS_16X16(mb_type)){ + int8_t *ref = &h->ref_cache[list][scan8[0]]; +- fill_rectangle(ref, 4, 4, 8, 16+*ref^(s->mb_y&1), 1); ++ fill_rectangle(ref, 4, 4, 8, (16+*ref)^(s->mb_y&1), 1); + }else{ + for(i=0; i<16; i+=4){ + //FIXME can refs be smaller than 8x8 when !direct_8x8_inference ? + int ref = h->ref_cache[list][scan8[i]]; + if(ref >= 0) +- fill_rectangle(&h->ref_cache[list][scan8[i]], 2, 2, 8, 16+ref^(s->mb_y&1), 1); ++ fill_rectangle(&h->ref_cache[list][scan8[i]], 2, 2, 8, (16+ref)^(s->mb_y&1), 1); + } + } + } +@@ -2764,11 +2736,12 @@ + else hl_decode_mb_simple(h); + } + +-static void pic_as_field(Picture *pic, const int bottom){ ++static void pic_as_field(Picture *pic, const int parity){ + int i; + for (i = 0; i < 4; ++i) { +- if (bottom) ++ if (parity == PICT_BOTTOM_FIELD) + pic->data[i] += pic->linesize[i]; ++ pic->reference = parity; + pic->linesize[i] *= 2; + } + } +@@ -2779,7 +2752,7 @@ + + if (match) { + *dest = *src; +- pic_as_field(dest, parity == PICT_BOTTOM_FIELD); ++ pic_as_field(dest, parity); + dest->pic_id *= 2; + dest->pic_id += id_add; + } +@@ -2949,15 +2922,6 @@ + frame_list[ list ][index++].pic_id= i;; + } + len[list] = index; +- +- if(list && (smallest_poc_greater_than_current<=0 || smallest_poc_greater_than_current>=h->short_ref_count) && (1 < index)){ +- // swap the two first elements of L1 when +- // L0 and L1 are identical +- Picture temp= frame_list[1][0]; +- frame_list[1][0] = frame_list[1][1]; +- frame_list[1][1] = temp; +- } +- + } + + for(list=0; list<2; list++){ +@@ -2969,6 +2933,14 @@ + s->picture_structure, + short_len[list]); + ++ // swap the two first elements of L1 when L0 and L1 are identical ++ if(list && len[0] > 1 && len[0] == len[1]) ++ for(i=0; h->default_ref_list[0][i].data[0] == h->default_ref_list[1][i].data[0]; i++) ++ if(i == len[0]){ ++ FFSWAP(Picture, h->default_ref_list[1][0], h->default_ref_list[1][1]); ++ break; ++ } ++ + if(len[list] < h->ref_count[ list ]) + memset(&h->default_ref_list[list][len[list]], 0, sizeof(Picture)*(h->ref_count[ list ] - len[list])); + } +@@ -3009,7 +2981,7 @@ + } + if(h->slice_type==B_TYPE){ + for (i=0; iref_count[1]; i++) { +- tprintf(h->s.avctx, "List1: %s fn:%d 0x%p\n", (h->default_ref_list[1][i].long_ref ? "LT" : "ST"), h->default_ref_list[1][i].pic_id, h->default_ref_list[0][i].data[0]); ++ tprintf(h->s.avctx, "List1: %s fn:%d 0x%p\n", (h->default_ref_list[1][i].long_ref ? "LT" : "ST"), h->default_ref_list[1][i].pic_id, h->default_ref_list[1][i].data[0]); + } + } + #endif +@@ -3076,7 +3048,7 @@ + const unsigned int abs_diff_pic_num= get_ue_golomb(&s->gb) + 1; + int frame_num; + +- if(abs_diff_pic_num >= h->max_pic_num){ ++ if(abs_diff_pic_num > h->max_pic_num){ + av_log(h->s.avctx, AV_LOG_ERROR, "abs_diff_pic_num overflow\n"); + return -1; + } +@@ -3133,8 +3105,7 @@ + } + h->ref_list[list][index]= *ref; + if (FIELD_PICTURE){ +- int bot = pic_structure == PICT_BOTTOM_FIELD; +- pic_as_field(&h->ref_list[list][index], bot); ++ pic_as_field(&h->ref_list[list][index], pic_structure); + } + } + }else{ +@@ -3166,9 +3137,11 @@ + field[0] = *frame; + for(j=0; j<3; j++) + field[0].linesize[j] <<= 1; ++ field[0].reference = PICT_TOP_FIELD; + field[1] = field[0]; + for(j=0; j<3; j++) + field[1].data[j] += frame->linesize[j]; ++ field[1].reference = PICT_BOTTOM_FIELD; + + h->luma_weight[list][16+2*i] = h->luma_weight[list][16+2*i+1] = h->luma_weight[list][i]; + h->luma_offset[list][16+2*i] = h->luma_offset[list][16+2*i+1] = h->luma_offset[list][i]; +@@ -3339,6 +3312,8 @@ + idr(h); + if(h->s.current_picture_ptr) + h->s.current_picture_ptr->reference= 0; ++ h->s.first_field= 0; ++ ff_mpeg_flush(avctx); + } + + /** +@@ -3465,42 +3440,80 @@ + av_log(h->s.avctx, AV_LOG_DEBUG, "no mmco here\n"); + + for(i=0; iavctx->debug&FF_DEBUG_MMCO) + av_log(h->s.avctx, AV_LOG_DEBUG, "mmco:%d %d %d\n", h->mmco[i].opcode, h->mmco[i].short_pic_num, h->mmco[i].long_arg); + + switch(mmco[i].opcode){ + case MMCO_SHORT2UNUSED: +- pic= remove_short(h, mmco[i].short_pic_num); +- if(pic) +- unreference_pic(h, pic, 0); +- else if(s->avctx->debug&FF_DEBUG_MMCO) +- av_log(h->s.avctx, AV_LOG_DEBUG, "mmco: remove_short() failure\n"); ++ if(s->avctx->debug&FF_DEBUG_MMCO) ++ av_log(h->s.avctx, AV_LOG_DEBUG, "mmco: unref short %d count %d\n", h->mmco[i].short_pic_num, h->short_ref_count); ++ frame_num = pic_num_extract(h, mmco[i].short_pic_num, &structure); ++ pic = find_short(h, frame_num, &j); ++ if (pic) { ++ if (unreference_pic(h, pic, structure ^ PICT_FRAME)) ++ remove_short_at_index(h, j); ++ } else if(s->avctx->debug&FF_DEBUG_MMCO) ++ av_log(h->s.avctx, AV_LOG_DEBUG, "mmco: unref short failure\n"); + break; + case MMCO_SHORT2LONG: +- pic= remove_long(h, mmco[i].long_arg); +- if(pic) unreference_pic(h, pic, 0); ++ if (FIELD_PICTURE && mmco[i].long_arg < h->long_ref_count && ++ h->long_ref[mmco[i].long_arg]->frame_num == ++ mmco[i].short_pic_num / 2) { ++ /* do nothing, we've already moved this field pair. */ ++ } else { ++ int frame_num = mmco[i].short_pic_num >> FIELD_PICTURE; + +- h->long_ref[ mmco[i].long_arg ]= remove_short(h, mmco[i].short_pic_num); +- if (h->long_ref[ mmco[i].long_arg ]){ +- h->long_ref[ mmco[i].long_arg ]->long_ref=1; +- h->long_ref_count++; ++ pic= remove_long(h, mmco[i].long_arg); ++ if(pic) unreference_pic(h, pic, 0); ++ ++ h->long_ref[ mmco[i].long_arg ]= remove_short(h, frame_num); ++ if (h->long_ref[ mmco[i].long_arg ]){ ++ h->long_ref[ mmco[i].long_arg ]->long_ref=1; ++ h->long_ref_count++; ++ } + } + break; + case MMCO_LONG2UNUSED: +- pic= remove_long(h, mmco[i].long_arg); +- if(pic) +- unreference_pic(h, pic, 0); +- else if(s->avctx->debug&FF_DEBUG_MMCO) +- av_log(h->s.avctx, AV_LOG_DEBUG, "mmco: remove_long() failure\n"); ++ j = pic_num_extract(h, mmco[i].long_arg, &structure); ++ pic = h->long_ref[j]; ++ if (pic) { ++ if (unreference_pic(h, pic, structure ^ PICT_FRAME)) ++ remove_long_at_index(h, j); ++ } else if(s->avctx->debug&FF_DEBUG_MMCO) ++ av_log(h->s.avctx, AV_LOG_DEBUG, "mmco: unref long failure\n"); + break; + case MMCO_LONG: +- pic= remove_long(h, mmco[i].long_arg); +- if(pic) unreference_pic(h, pic, 0); ++ unref_pic = 1; ++ if (FIELD_PICTURE && !s->first_field) { ++ if (h->long_ref[mmco[i].long_arg] == s->current_picture_ptr) { ++ /* Just mark second field as referenced */ ++ unref_pic = 0; ++ } else if (s->current_picture_ptr->reference) { ++ /* First field in pair is in short term list or ++ * at a different long term index. ++ * This is not allowed; see 7.4.3, notes 2 and 3. ++ * Report the problem and keep the pair where it is, ++ * and mark this field valid. ++ */ ++ av_log(h->s.avctx, AV_LOG_ERROR, ++ "illegal long term reference assignment for second " ++ "field in complementary field pair (first field is " ++ "short term or has non-matching long index)\n"); ++ unref_pic = 0; ++ } ++ } ++ ++ if (unref_pic) { ++ pic= remove_long(h, mmco[i].long_arg); ++ if(pic) unreference_pic(h, pic, 0); + +- h->long_ref[ mmco[i].long_arg ]= s->current_picture_ptr; +- h->long_ref[ mmco[i].long_arg ]->long_ref=1; +- h->long_ref_count++; ++ h->long_ref[ mmco[i].long_arg ]= s->current_picture_ptr; ++ h->long_ref[ mmco[i].long_arg ]->long_ref=1; ++ h->long_ref_count++; ++ } + ++ s->current_picture_ptr->reference |= s->picture_structure; + current_ref_assigned=1; + break; + case MMCO_SET_MAX_LONG: +@@ -3525,6 +3538,34 @@ + } + } + ++ if (!current_ref_assigned && FIELD_PICTURE && ++ !s->first_field && s->current_picture_ptr->reference) { ++ ++ /* Second field of complementary field pair; the first field of ++ * which is already referenced. If short referenced, it ++ * should be first entry in short_ref. If not, it must exist ++ * in long_ref; trying to put it on the short list here is an ++ * error in the encoded bit stream (ref: 7.4.3, NOTE 2 and 3). ++ */ ++ if (h->short_ref_count && h->short_ref[0] == s->current_picture_ptr) { ++ /* Just mark the second field valid */ ++ s->current_picture_ptr->reference = PICT_FRAME; ++ } else if (s->current_picture_ptr->long_ref) { ++ av_log(h->s.avctx, AV_LOG_ERROR, "illegal short term reference " ++ "assignment for second field " ++ "in complementary field pair " ++ "(first field is long term)\n"); ++ } else { ++ /* ++ * First field in reference, but not in any sensible place on our ++ * reference lists. This shouldn't happen unless reference ++ * handling somewhere else is wrong. ++ */ ++ assert(0); ++ } ++ current_ref_assigned = 1; ++ } ++ + if(!current_ref_assigned){ + pic= remove_short(h, s->current_picture_ptr->frame_num); + if(pic){ +@@ -3538,6 +3579,32 @@ + h->short_ref[0]= s->current_picture_ptr; + h->short_ref[0]->long_ref=0; + h->short_ref_count++; ++ s->current_picture_ptr->reference |= s->picture_structure; ++ } ++ ++ if (h->long_ref_count + h->short_ref_count > h->sps.ref_frame_count){ ++ ++ /* We have too many reference frames, probably due to corrupted ++ * stream. Need to discard one frame. Prevents overrun of the ++ * short_ref and long_ref buffers. ++ */ ++ av_log(h->s.avctx, AV_LOG_ERROR, ++ "number of reference frames exceeds max (probably " ++ "corrupt input), discarding one\n"); ++ ++ if (h->long_ref_count) { ++ for (i = 0; i < 16; ++i) ++ if (h->long_ref[i]) ++ break; ++ ++ assert(i < 16); ++ pic = h->long_ref[i]; ++ remove_long_at_index(h, i); ++ } else { ++ pic = h->short_ref[h->short_ref_count - 1]; ++ remove_short_at_index(h, h->short_ref_count - 1); ++ } ++ unreference_pic(h, pic, 0); + } + + print_short_term(h); +@@ -3591,7 +3658,7 @@ + }else{ + assert(h->long_ref_count + h->short_ref_count <= h->sps.ref_frame_count); + +- if(h->long_ref_count + h->short_ref_count == h->sps.ref_frame_count && ++ if(h->short_ref_count && h->long_ref_count + h->short_ref_count == h->sps.ref_frame_count && + !(FIELD_PICTURE && !s->first_field && s->current_picture_ptr->reference)) { + h->mmco[0].opcode= MMCO_SHORT2UNUSED; + h->mmco[0].short_pic_num= h->short_ref[ h->short_ref_count - 1 ]->frame_num; +@@ -3697,8 +3764,10 @@ + s->current_picture_ptr->field_poc[1]= field_poc[1]; + s->current_picture_ptr->poc = field_poc[1]; + } +- if(!FIELD_PICTURE || !s->first_field) +- s->current_picture_ptr->poc= FFMIN(field_poc[0], field_poc[1]); ++ if(!FIELD_PICTURE || !s->first_field) { ++ Picture *cur = s->current_picture_ptr; ++ cur->poc= FFMIN(cur->field_poc[0], cur->field_poc[1]); ++ } + + return 0; + } +@@ -3763,6 +3832,7 @@ + dst->s.current_picture = src->s.current_picture; + dst->s.linesize = src->s.linesize; + dst->s.uvlinesize = src->s.uvlinesize; ++ dst->s.first_field = src->s.first_field; + + dst->prev_poc_msb = src->prev_poc_msb; + dst->prev_poc_lsb = src->prev_poc_lsb; +@@ -3790,20 +3860,31 @@ + */ + static int decode_slice_header(H264Context *h, H264Context *h0){ + MpegEncContext * const s = &h->s; ++ MpegEncContext * const s0 = &h0->s; + unsigned int first_mb_in_slice; + unsigned int pps_id; + int num_ref_idx_active_override_flag; + static const uint8_t slice_type_map[5]= {P_TYPE, B_TYPE, I_TYPE, SP_TYPE, SI_TYPE}; + unsigned int slice_type, tmp, i; + int default_ref_list_done = 0; ++ int last_pic_structure; + + s->dropable= h->nal_ref_idc == 0; + ++ if((s->avctx->flags2 & CODEC_FLAG2_FAST) && !h->nal_ref_idc){ ++ s->me.qpel_put= s->dsp.put_2tap_qpel_pixels_tab; ++ s->me.qpel_avg= s->dsp.avg_2tap_qpel_pixels_tab; ++ }else{ ++ s->me.qpel_put= s->dsp.put_h264_qpel_pixels_tab; ++ s->me.qpel_avg= s->dsp.avg_h264_qpel_pixels_tab; ++ } ++ + first_mb_in_slice= get_ue_golomb(&s->gb); + + if((s->flags2 & CODEC_FLAG2_CHUNKS) && first_mb_in_slice == 0){ + h0->current_slice = 0; +- s->current_picture_ptr= NULL; ++ if (!s0->first_field) ++ s->current_picture_ptr= NULL; + } + + slice_type= get_ue_golomb(&s->gb); +@@ -3825,6 +3906,11 @@ + h->slice_type= slice_type; + + s->pict_type= h->slice_type; // to make a few old func happy, it's wrong though ++ if (s->pict_type == B_TYPE && s0->last_picture_ptr == NULL) { ++ av_log(h->s.avctx, AV_LOG_ERROR, ++ "B picture before any references, skipping\n"); ++ return -1; ++ } + + pps_id= get_ue_golomb(&s->gb); + if(pps_id>=MAX_PPS_COUNT){ +@@ -3872,6 +3958,7 @@ + return -1; // we cant (re-)initialize context during parallel decoding + if (MPV_common_init(s) < 0) + return -1; ++ s->first_field = 0; + + init_scan_tables(h); + alloc_tables(h); +@@ -3879,7 +3966,7 @@ + for(i = 1; i < s->avctx->thread_count; i++) { + H264Context *c; + c = h->thread_context[i] = av_malloc(sizeof(H264Context)); +- memcpy(c, h, sizeof(MpegEncContext)); ++ memcpy(c, h->s.thread_context[i], sizeof(MpegEncContext)); + memset(&c->s + 1, 0, sizeof(H264Context) - sizeof(MpegEncContext)); + c->sps = h->sps; + c->pps = h->pps; +@@ -3910,12 +3997,12 @@ + + h->mb_mbaff = 0; + h->mb_aff_frame = 0; ++ last_pic_structure = s0->picture_structure; + if(h->sps.frame_mbs_only_flag){ + s->picture_structure= PICT_FRAME; + }else{ + if(get_bits1(&s->gb)) { //field_pic_flag + s->picture_structure= PICT_TOP_FIELD + get_bits1(&s->gb); //bottom_field_flag +- av_log(h->s.avctx, AV_LOG_ERROR, "PAFF interlacing is not implemented\n"); + } else { + s->picture_structure= PICT_FRAME; + h->mb_aff_frame = h->sps.mb_aff; +@@ -3923,8 +4010,50 @@ + } + + if(h0->current_slice == 0){ +- if(frame_start(h) < 0) ++ /* See if we have a decoded first field looking for a pair... */ ++ if (s0->first_field) { ++ assert(s0->current_picture_ptr); ++ assert(s0->current_picture_ptr->data[0]); ++ assert(s0->current_picture_ptr->reference != DELAYED_PIC_REF); ++ ++ /* figure out if we have a complementary field pair */ ++ if (!FIELD_PICTURE || s->picture_structure == last_pic_structure) { ++ /* ++ * Previous field is unmatched. Don't display it, but let it ++ * remain for reference if marked as such. ++ */ ++ s0->current_picture_ptr = NULL; ++ s0->first_field = FIELD_PICTURE; ++ ++ } else { ++ if (h->nal_ref_idc && ++ s0->current_picture_ptr->reference && ++ s0->current_picture_ptr->frame_num != h->frame_num) { ++ /* ++ * This and previous field were reference, but had ++ * different frame_nums. Consider this field first in ++ * pair. Throw away previous field except for reference ++ * purposes. ++ */ ++ s0->first_field = 1; ++ s0->current_picture_ptr = NULL; ++ ++ } else { ++ /* Second field in complementary pair */ ++ s0->first_field = 0; ++ } ++ } ++ ++ } else { ++ /* Frame or first field in a potentially complementary pair */ ++ assert(!s0->current_picture_ptr); ++ s0->first_field = FIELD_PICTURE; ++ } ++ ++ if((!FIELD_PICTURE || s0->first_field) && frame_start(h) < 0) { ++ s0->first_field = 0; + return -1; ++ } + } + if(h != h0) + clone_slice(h, h0); +@@ -3983,8 +4112,6 @@ + if(h->slice_type == P_TYPE || h->slice_type == SP_TYPE || h->slice_type == B_TYPE){ + if(h->slice_type == B_TYPE){ + h->direct_spatial_mv_pred= get_bits1(&s->gb); +- if(h->sps.mb_aff && h->direct_spatial_mv_pred) +- av_log(h->s.avctx, AV_LOG_ERROR, "MBAFF + spatial direct mode is not implemented\n"); + } + num_ref_idx_active_override_flag= get_bits1(&s->gb); + +@@ -4081,7 +4208,7 @@ + if(h->deblocking_filter == 1 && h0->max_contexts > 1) { + if(s->avctx->flags2 & CODEC_FLAG2_FAST) { + /* Cheat slightly for speed: +- Dont bother to deblock across slices */ ++ Do not bother to deblock across slices. */ + h->deblocking_filter = 2; + } else { + h0->max_contexts = 1; +@@ -4121,14 +4248,6 @@ + ); + } + +- if((s->avctx->flags2 & CODEC_FLAG2_FAST) && !h->nal_ref_idc){ +- s->me.qpel_put= s->dsp.put_2tap_qpel_pixels_tab; +- s->me.qpel_avg= s->dsp.avg_2tap_qpel_pixels_tab; +- }else{ +- s->me.qpel_put= s->dsp.put_h264_qpel_pixels_tab; +- s->me.qpel_avg= s->dsp.avg_h264_qpel_pixels_tab; +- } +- + return 0; + } + +@@ -5241,7 +5360,7 @@ + return ctx + 4 * cat; + } + +-static const attribute_used uint8_t last_coeff_flag_offset_8x8[63] = { ++DECLARE_ASM_CONST(1, const uint8_t, last_coeff_flag_offset_8x8[63]) = { + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, +@@ -6252,12 +6371,13 @@ + + static void filter_mb_fast( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize) { + MpegEncContext * const s = &h->s; ++ int mb_y_firstrow = s->picture_structure == PICT_BOTTOM_FIELD; + int mb_xy, mb_type; + int qp, qp0, qp1, qpc, qpc0, qpc1, qp_thresh; + + mb_xy = mb_x + mb_y*s->mb_stride; + +- if(mb_x==0 || mb_y==0 || !s->dsp.h264_loop_filter_strength || h->pps.chroma_qp_diff || ++ if(mb_x==0 || mb_y==mb_y_firstrow || !s->dsp.h264_loop_filter_strength || h->pps.chroma_qp_diff || + (h->deblocking_filter == 2 && (h->slice_table[mb_xy] != h->slice_table[h->top_mb_xy] || + h->slice_table[mb_xy] != h->slice_table[mb_xy - 1]))) { + filter_mb(h, mb_x, mb_y, img_y, img_cb, img_cr, linesize, uvlinesize); +@@ -6284,17 +6404,18 @@ + if( IS_INTRA(mb_type) ) { + int16_t bS4[4] = {4,4,4,4}; + int16_t bS3[4] = {3,3,3,3}; ++ int16_t *bSH = FIELD_PICTURE ? bS3 : bS4; + if( IS_8x8DCT(mb_type) ) { + filter_mb_edgev( h, &img_y[4*0], linesize, bS4, qp0 ); + filter_mb_edgev( h, &img_y[4*2], linesize, bS3, qp ); +- filter_mb_edgeh( h, &img_y[4*0*linesize], linesize, bS4, qp1 ); ++ filter_mb_edgeh( h, &img_y[4*0*linesize], linesize, bSH, qp1 ); + filter_mb_edgeh( h, &img_y[4*2*linesize], linesize, bS3, qp ); + } else { + filter_mb_edgev( h, &img_y[4*0], linesize, bS4, qp0 ); + filter_mb_edgev( h, &img_y[4*1], linesize, bS3, qp ); + filter_mb_edgev( h, &img_y[4*2], linesize, bS3, qp ); + filter_mb_edgev( h, &img_y[4*3], linesize, bS3, qp ); +- filter_mb_edgeh( h, &img_y[4*0*linesize], linesize, bS4, qp1 ); ++ filter_mb_edgeh( h, &img_y[4*0*linesize], linesize, bSH, qp1 ); + filter_mb_edgeh( h, &img_y[4*1*linesize], linesize, bS3, qp ); + filter_mb_edgeh( h, &img_y[4*2*linesize], linesize, bS3, qp ); + filter_mb_edgeh( h, &img_y[4*3*linesize], linesize, bS3, qp ); +@@ -6303,9 +6424,9 @@ + filter_mb_edgecv( h, &img_cb[2*2], uvlinesize, bS3, qpc ); + filter_mb_edgecv( h, &img_cr[2*0], uvlinesize, bS4, qpc0 ); + filter_mb_edgecv( h, &img_cr[2*2], uvlinesize, bS3, qpc ); +- filter_mb_edgech( h, &img_cb[2*0*uvlinesize], uvlinesize, bS4, qpc1 ); ++ filter_mb_edgech( h, &img_cb[2*0*uvlinesize], uvlinesize, bSH, qpc1 ); + filter_mb_edgech( h, &img_cb[2*2*uvlinesize], uvlinesize, bS3, qpc ); +- filter_mb_edgech( h, &img_cr[2*0*uvlinesize], uvlinesize, bS4, qpc1 ); ++ filter_mb_edgech( h, &img_cr[2*0*uvlinesize], uvlinesize, bSH, qpc1 ); + filter_mb_edgech( h, &img_cr[2*2*uvlinesize], uvlinesize, bS3, qpc ); + return; + } else { +@@ -6329,7 +6450,7 @@ + if( IS_INTRA(s->current_picture.mb_type[mb_xy-1]) ) + bSv[0][0] = 0x0004000400040004ULL; + if( IS_INTRA(s->current_picture.mb_type[h->top_mb_xy]) ) +- bSv[1][0] = 0x0004000400040004ULL; ++ bSv[1][0] = FIELD_PICTURE ? 0x0003000300030003ULL : 0x0004000400040004ULL; + + #define FILTER(hv,dir,edge)\ + if(bSv[dir][edge]) {\ +@@ -7082,8 +7203,9 @@ + } + + tmp= get_ue_golomb(&s->gb); +- if(tmp > MAX_PICTURE_COUNT-2){ ++ if(tmp > MAX_PICTURE_COUNT-2 || tmp >= 32){ + av_log(h->s.avctx, AV_LOG_ERROR, "too many reference frames\n"); ++ return -1; + } + sps->ref_frame_count= tmp; + sps->gaps_in_frame_num_allowed_flag= get_bits1(&s->gb); +@@ -7295,13 +7417,15 @@ + hx = h->thread_context[context_count - 1]; + s->mb_x = hx->s.mb_x; + s->mb_y = hx->s.mb_y; ++ s->dropable = hx->s.dropable; ++ s->picture_structure = hx->s.picture_structure; + for(i = 1; i < context_count; i++) + h->s.error_count += h->thread_context[i]->s.error_count; + } + } + + +-static int decode_nal_units(H264Context *h, uint8_t *buf, int buf_size){ ++static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){ + MpegEncContext * const s = &h->s; + AVCodecContext * const avctx= s->avctx; + int buf_index=0; +@@ -7317,14 +7441,15 @@ + #endif + if(!(s->flags2 & CODEC_FLAG2_CHUNKS)){ + h->current_slice = 0; +- s->current_picture_ptr= NULL; ++ if (!s->first_field) ++ s->current_picture_ptr= NULL; + } + + for(;;){ + int consumed; + int dst_length; + int bit_length; +- uint8_t *ptr; ++ const uint8_t *ptr; + int i, nalsize = 0; + int err; + +@@ -7502,7 +7627,7 @@ + + static int decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + H264Context *h = avctx->priv_data; + MpegEncContext *s = &h->s; +@@ -7614,86 +7739,109 @@ + + h->prev_frame_num_offset= h->frame_num_offset; + h->prev_frame_num= h->frame_num; +- if(s->current_picture_ptr->reference & s->picture_structure){ ++ if(!s->dropable) { + h->prev_poc_msb= h->poc_msb; + h->prev_poc_lsb= h->poc_lsb; + execute_ref_pic_marking(h, h->mmco, h->mmco_index); + } + +- ff_er_frame_end(s); ++ /* ++ * FIXME: Error handling code does not seem to support interlaced ++ * when slices span multiple rows ++ * The ff_er_add_slice calls don't work right for bottom ++ * fields; they cause massive erroneous error concealing ++ * Error marking covers both fields (top and bottom). ++ * This causes a mismatched s->error_count ++ * and a bad error table. Further, the error count goes to ++ * INT_MAX when called for bottom field, because mb_y is ++ * past end by one (callers fault) and resync_mb_y != 0 ++ * causes problems for the first MB line, too. ++ */ ++ if (!FIELD_PICTURE) ++ ff_er_frame_end(s); + + MPV_frame_end(s); + +- //FIXME do something with unavailable reference frames +- +-#if 0 //decode order +- *data_size = sizeof(AVFrame); +-#else +- /* Sort B-frames into display order */ +- +- if(h->sps.bitstream_restriction_flag +- && s->avctx->has_b_frames < h->sps.num_reorder_frames){ +- s->avctx->has_b_frames = h->sps.num_reorder_frames; +- s->low_delay = 0; +- } +- +- pics = 0; +- while(h->delayed_pic[pics]) pics++; ++ if (s->first_field) { ++ /* Wait for second field. */ ++ *data_size = 0; + +- assert(pics+1 < sizeof(h->delayed_pic) / sizeof(h->delayed_pic[0])); ++ } else { ++ cur->interlaced_frame = FIELD_OR_MBAFF_PICTURE; ++ /* Derive top_field_first from field pocs. */ ++ cur->top_field_first = cur->field_poc[0] < cur->field_poc[1]; + +- h->delayed_pic[pics++] = cur; +- if(cur->reference == 0) +- cur->reference = DELAYED_PIC_REF; ++ //FIXME do something with unavailable reference frames + +- cross_idr = 0; +- for(i=0; h->delayed_pic[i]; i++) +- if(h->delayed_pic[i]->key_frame || h->delayed_pic[i]->poc==0) +- cross_idr = 1; ++#if 0 //decode order ++ *data_size = sizeof(AVFrame); ++#else ++ /* Sort B-frames into display order */ + +- out = h->delayed_pic[0]; +- out_idx = 0; +- for(i=1; h->delayed_pic[i] && !h->delayed_pic[i]->key_frame; i++) +- if(h->delayed_pic[i]->poc < out->poc){ +- out = h->delayed_pic[i]; +- out_idx = i; ++ if(h->sps.bitstream_restriction_flag ++ && s->avctx->has_b_frames < h->sps.num_reorder_frames){ ++ s->avctx->has_b_frames = h->sps.num_reorder_frames; ++ s->low_delay = 0; ++ } ++ ++ pics = 0; ++ while(h->delayed_pic[pics]) pics++; ++ ++ assert(pics+1 < sizeof(h->delayed_pic) / sizeof(h->delayed_pic[0])); ++ ++ h->delayed_pic[pics++] = cur; ++ if(cur->reference == 0) ++ cur->reference = DELAYED_PIC_REF; ++ ++ cross_idr = 0; ++ for(i=0; h->delayed_pic[i]; i++) ++ if(h->delayed_pic[i]->key_frame || h->delayed_pic[i]->poc==0) ++ cross_idr = 1; ++ ++ out = h->delayed_pic[0]; ++ out_idx = 0; ++ for(i=1; h->delayed_pic[i] && !h->delayed_pic[i]->key_frame; i++) ++ if(h->delayed_pic[i]->poc < out->poc){ ++ out = h->delayed_pic[i]; ++ out_idx = i; ++ } ++ ++ out_of_order = !cross_idr && prev && out->poc < prev->poc; ++ if(h->sps.bitstream_restriction_flag && s->avctx->has_b_frames >= h->sps.num_reorder_frames) ++ { } ++ else if(prev && pics <= s->avctx->has_b_frames) ++ out = prev; ++ else if((out_of_order && pics-1 == s->avctx->has_b_frames && pics < 15) ++ || (s->low_delay && ++ ((!cross_idr && prev && out->poc > prev->poc + 2) ++ || cur->pict_type == B_TYPE))) ++ { ++ s->low_delay = 0; ++ s->avctx->has_b_frames++; ++ out = prev; ++ } ++ else if(out_of_order) ++ out = prev; ++ ++ if(out_of_order || pics > s->avctx->has_b_frames){ ++ for(i=out_idx; h->delayed_pic[i]; i++) ++ h->delayed_pic[i] = h->delayed_pic[i+1]; + } + +- out_of_order = !cross_idr && prev && out->poc < prev->poc; +- if(h->sps.bitstream_restriction_flag && s->avctx->has_b_frames >= h->sps.num_reorder_frames) +- { } +- else if(prev && pics <= s->avctx->has_b_frames) +- out = prev; +- else if((out_of_order && pics-1 == s->avctx->has_b_frames && pics < 15) +- || (s->low_delay && +- ((!cross_idr && prev && out->poc > prev->poc + 2) +- || cur->pict_type == B_TYPE))) +- { +- s->low_delay = 0; +- s->avctx->has_b_frames++; +- out = prev; +- } +- else if(out_of_order) +- out = prev; +- +- if(out_of_order || pics > s->avctx->has_b_frames){ +- for(i=out_idx; h->delayed_pic[i]; i++) +- h->delayed_pic[i] = h->delayed_pic[i+1]; +- } +- +- if(prev == out) +- *data_size = 0; +- else +- *data_size = sizeof(AVFrame); +- if(prev && prev != out && prev->reference == DELAYED_PIC_REF) +- prev->reference = 0; +- h->delayed_output_pic = out; ++ if(prev == out) ++ *data_size = 0; ++ else ++ *data_size = sizeof(AVFrame); ++ if(prev && prev != out && prev->reference == DELAYED_PIC_REF) ++ prev->reference = 0; ++ h->delayed_output_pic = out; + #endif + +- if(out) +- *pict= *(AVFrame*)out; +- else +- av_log(avctx, AV_LOG_DEBUG, "no picture\n"); ++ if(out) ++ *pict= *(AVFrame*)out; ++ else ++ av_log(avctx, AV_LOG_DEBUG, "no picture\n"); ++ } + } + + assert(pict->data[0] || !*data_size); +@@ -7702,7 +7850,7 @@ + #if 0 //? + + /* Return the Picture timestamp as the frame number */ +- /* we substract 1 because it is added on utils.c */ ++ /* we subtract 1 because it is added on utils.c */ + avctx->frame_number = s->picture_number - 1; + #endif + return get_consumed_bytes(s, buf_index, buf_size); +@@ -7727,11 +7875,12 @@ + } + #endif + +-#if 0 //selftest ++#ifdef TEST ++#undef printf + #undef random + #define COUNT 8000 + #define SIZE (COUNT*40) +-int main(){ ++int main(void){ + int i; + uint8_t temp[SIZE]; + PutBitContext pb; +@@ -7791,6 +7940,7 @@ + STOP_TIMER("get_se_golomb"); + } + ++#if 0 + printf("testing 4x4 (I)DCT\n"); + + DCTELEM block[16]; +@@ -7830,14 +7980,12 @@ + } + } + printf("error=%f max_error=%d\n", ((float)error)/COUNT/16, (int)max_error ); +-#if 0 + printf("testing quantizer\n"); + for(qp=0; qp<52; qp++){ + for(i=0; i<16; i++) + src1_block[i]= src2_block[i]= random()%255; + + } +-#endif + printf("Testing NAL layer\n"); + + uint8_t bitstream[COUNT]; +@@ -7893,13 +8041,14 @@ + return -1; + } + } ++#endif + + printf("Testing RBSP\n"); + + + return 0; + } +-#endif ++#endif /* TEST */ + + + static int decode_end(AVCodecContext *avctx) +diff -u mplayer-1.0~rc2-12/libavcodec/h264data.h ffmpeg-free-0.svn20080206/libavcodec/h264data.h +--- mplayer-1.0~rc2-12/libavcodec/h264data.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/h264data.h 2007-10-17 11:37:46.000000000 +0200 +@@ -26,8 +26,8 @@ + * @author Michael Niedermayer + */ + +-#ifndef AVCODEC_H264DATA_H +-#define AVCODEC_H264DATA_H ++#ifndef FFMPEG_H264DATA_H ++#define FFMPEG_H264DATA_H + + #include + #include "mpegvideo.h" +@@ -1305,4 +1305,4 @@ + } + }; + +-#endif // AVCODEC_H264DATA_H ++#endif /* FFMPEG_H264DATA_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/h264.h ffmpeg-free-0.svn20080206/libavcodec/h264.h +--- mplayer-1.0~rc2-12/libavcodec/h264.h 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/h264.h 2008-02-03 08:05:11.000000000 +0100 +@@ -25,8 +25,8 @@ + * @author Michael Niedermayer + */ + +-#ifndef H264_H +-#define H264_H ++#ifndef FFMPEG_H264_H ++#define FFMPEG_H264_H + + #include "dsputil.h" + #include "cabac.h" +@@ -59,7 +59,7 @@ + #define MB_MBAFF h->mb_mbaff + #define MB_FIELD h->mb_field_decoding_flag + #define FRAME_MBAFF h->mb_aff_frame +-#define FIELD_PICTURE 0 ++#define FIELD_PICTURE (s->picture_structure != PICT_FRAME) + #else + #define MB_MBAFF 0 + #define MB_FIELD 0 +@@ -348,7 +348,7 @@ + GetBitContext *intra_gb_ptr; + GetBitContext *inter_gb_ptr; + +- DECLARE_ALIGNED_8(DCTELEM, mb[16*24]); ++ DECLARE_ALIGNED_16(DCTELEM, mb[16*24]); + DCTELEM mb_padding[256]; ///< as mb is addressed by scantable[i] and scantable is uint8_t we can either check that i is not to large or ensure that there is some unused stuff after mb + + /** +@@ -416,4 +416,4 @@ + + }H264Context; + +-#endif /* H264_H */ ++#endif /* FFMPEG_H264_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/h264_mp4toannexb_bsf.c ffmpeg-free-0.svn20080206/libavcodec/h264_mp4toannexb_bsf.c +--- mplayer-1.0~rc2-12/libavcodec/h264_mp4toannexb_bsf.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/h264_mp4toannexb_bsf.c 2008-03-20 19:10:58.000000000 +0100 +@@ -41,8 +41,8 @@ + if (!offset) + AV_WB32(*poutbuf+sps_pps_size, 1); + else { +- (*poutbuf+offset)[0] = (*poutbuf+offset)[1] = 0; +- (*poutbuf+offset)[2] = 1; ++ (*poutbuf+offset+sps_pps_size)[0] = (*poutbuf+offset+sps_pps_size)[1] = 0; ++ (*poutbuf+offset+sps_pps_size)[2] = 1; + } + } + +diff -u mplayer-1.0~rc2-12/libavcodec/h264_parser.h ffmpeg-free-0.svn20080206/libavcodec/h264_parser.h +--- mplayer-1.0~rc2-12/libavcodec/h264_parser.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/h264_parser.h 2007-10-17 11:37:46.000000000 +0200 +@@ -25,8 +25,8 @@ + * @author Michael Niedermayer + */ + +-#ifndef H264_PARSER_H +-#define H264_PARSER_H ++#ifndef FFMPEG_H264_PARSER_H ++#define FFMPEG_H264_PARSER_H + + #include "h264.h" + +@@ -36,4 +36,4 @@ + */ + int ff_h264_find_frame_end(H264Context *h, const uint8_t *buf, int buf_size); + +-#endif /* H264_PARSER_H */ ++#endif /* FFMPEG_H264_PARSER_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/h264pred.c ffmpeg-free-0.svn20080206/libavcodec/h264pred.c +--- mplayer-1.0~rc2-12/libavcodec/h264pred.c 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/h264pred.c 2008-03-20 19:10:58.000000000 +0100 +@@ -288,10 +288,10 @@ + src[3+3*stride]=(t4 + 2*t5 + t6 + 2)>>2; + } + +-static void pred4x4_vertical_left_rv40_c(uint8_t *src, uint8_t *topright, int stride){ ++static void pred4x4_vertical_left_rv40(uint8_t *src, uint8_t *topright, int stride, ++ const int l0, const int l1, const int l2, const int l3, const int l4){ + LOAD_TOP_EDGE + LOAD_TOP_RIGHT_EDGE +- LOAD_LEFT_EDGE + + src[0+0*stride]=(2*t0 + 2*t1 + l1 + 2*l2 + l3 + 4)>>3; + src[1+0*stride]= +@@ -301,7 +301,7 @@ + src[3+0*stride]= + src[2+2*stride]=(t3 + t4+ 1)>>1; + src[3+2*stride]=(t4 + t5+ 1)>>1; +- src[0+1*stride]=(t0 + 2*t1 + t2 + l2 + 2*l3 + l3 + 4)>>3; ++ src[0+1*stride]=(t0 + 2*t1 + t2 + l2 + 2*l3 + l4 + 4)>>3; + src[1+1*stride]= + src[0+3*stride]=(t1 + 2*t2 + t3 + 2)>>2; + src[2+1*stride]= +@@ -311,6 +311,19 @@ + src[3+3*stride]=(t4 + 2*t5 + t6 + 2)>>2; + } + ++static void pred4x4_vertical_left_rv40_c(uint8_t *src, uint8_t *topright, int stride){ ++ LOAD_LEFT_EDGE ++ LOAD_DOWN_LEFT_EDGE ++ ++ pred4x4_vertical_left_rv40(src, topright, stride, l0, l1, l2, l3, l4); ++} ++ ++static void pred4x4_vertical_left_rv40_nodown_c(uint8_t *src, uint8_t *topright, int stride){ ++ LOAD_LEFT_EDGE ++ ++ pred4x4_vertical_left_rv40(src, topright, stride, l0, l1, l2, l3, l3); ++} ++ + static void pred4x4_horizontal_up_c(uint8_t *src, uint8_t *topright, int stride){ + LOAD_LEFT_EDGE + +@@ -1010,6 +1023,7 @@ + h->pred4x4[DC_128_PRED ]= pred4x4_128_dc_c; + h->pred4x4[DIAG_DOWN_LEFT_PRED_RV40_NODOWN]= pred4x4_down_left_rv40_nodown_c; + h->pred4x4[HOR_UP_PRED_RV40_NODOWN]= pred4x4_horizontal_up_rv40_nodown_c; ++ h->pred4x4[VERT_LEFT_PRED_RV40_NODOWN]= pred4x4_vertical_left_rv40_nodown_c; + } + + h->pred8x8l[VERT_PRED ]= pred8x8l_vertical_c; +diff -u mplayer-1.0~rc2-12/libavcodec/h264pred.h ffmpeg-free-0.svn20080206/libavcodec/h264pred.h +--- mplayer-1.0~rc2-12/libavcodec/h264pred.h 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/h264pred.h 2007-12-17 19:43:34.000000000 +0100 +@@ -25,8 +25,8 @@ + * @author Michael Niedermayer + */ + +-#ifndef H264PRED_H +-#define H264PRED_H ++#ifndef FFMPEG_H264PRED_H ++#define FFMPEG_H264PRED_H + + #include "common.h" + +@@ -50,6 +50,7 @@ + + #define DIAG_DOWN_LEFT_PRED_RV40_NODOWN 12 + #define HOR_UP_PRED_RV40_NODOWN 13 ++#define VERT_LEFT_PRED_RV40_NODOWN 14 + + #define DC_PRED8x8 0 + #define HOR_PRED8x8 1 +@@ -65,7 +66,7 @@ + * Context for storing H.264 prediction functions + */ + typedef struct H264PredContext{ +- void (*pred4x4 [9+3+2])(uint8_t *src, uint8_t *topright, int stride);//FIXME move to dsp? ++ void (*pred4x4 [9+3+3])(uint8_t *src, uint8_t *topright, int stride);//FIXME move to dsp? + void (*pred8x8l [9+3])(uint8_t *src, int topleft, int topright, int stride); + void (*pred8x8 [4+3])(uint8_t *src, int stride); + void (*pred16x16[4+3])(uint8_t *src, int stride); +@@ -73,4 +74,4 @@ + + void ff_h264_pred_init(H264PredContext *h, int codec_id); + +-#endif /* H264PRED_H */ ++#endif /* FFMPEG_H264PRED_H */ +Only in ffmpeg-free-0.svn20080206/libavcodec: huffman.c +Only in ffmpeg-free-0.svn20080206/libavcodec: huffman.h +diff -u mplayer-1.0~rc2-12/libavcodec/huffyuv.c ffmpeg-free-0.svn20080206/libavcodec/huffyuv.c +--- mplayer-1.0~rc2-12/libavcodec/huffyuv.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/huffyuv.c 2008-03-20 19:10:58.000000000 +0100 +@@ -959,7 +959,7 @@ + s->last_slice_end= y + h; + } + +-static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8_t *buf, int buf_size){ ++static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, const uint8_t *buf, int buf_size){ + HYuvContext *s = avctx->priv_data; + const int width= s->width; + const int width2= s->width>>1; +@@ -972,7 +972,7 @@ + + s->bitstream_buffer= av_fast_realloc(s->bitstream_buffer, &s->bitstream_buffer_size, buf_size + FF_INPUT_BUFFER_PADDING_SIZE); + +- s->dsp.bswap_buf((uint32_t*)s->bitstream_buffer, (uint32_t*)buf, buf_size/4); ++ s->dsp.bswap_buf((uint32_t*)s->bitstream_buffer, (const uint32_t*)buf, buf_size/4); + + if(p->data[0]) + avctx->release_buffer(avctx, p); +Common subdirectories: mplayer-1.0~rc2-12/libavcodec/i386 and ffmpeg-free-0.svn20080206/libavcodec/i386 +diff -u mplayer-1.0~rc2-12/libavcodec/idcinvideo.c ffmpeg-free-0.svn20080206/libavcodec/idcinvideo.c +--- mplayer-1.0~rc2-12/libavcodec/idcinvideo.c 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/idcinvideo.c 2008-03-20 19:10:58.000000000 +0100 +@@ -69,7 +69,7 @@ + DSPContext dsp; + AVFrame frame; + +- unsigned char *buf; ++ const unsigned char *buf; + int size; + + hnode_t huff_nodes[256][HUF_TOKENS*2]; +@@ -212,7 +212,7 @@ + + static int idcin_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + IdcinContext *s = avctx->priv_data; + AVPaletteControl *palette_control = avctx->palctrl; +diff -u mplayer-1.0~rc2-12/libavcodec/imc.c ffmpeg-free-0.svn20080206/libavcodec/imc.c +--- mplayer-1.0~rc2-12/libavcodec/imc.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/imc.c 2008-03-20 19:10:58.000000000 +0100 +@@ -41,6 +41,7 @@ + + #include "imcdata.h" + ++#define IMC_BLOCK_SIZE 64 + #define IMC_FRAME_ID 0x21 + #define BANDS 32 + #define COEFFS 256 +@@ -625,7 +626,7 @@ + + static int imc_decode_frame(AVCodecContext * avctx, + void *data, int *data_size, +- uint8_t * buf, int buf_size) ++ const uint8_t * buf, int buf_size) + { + + IMCContext *q = avctx->priv_data; +@@ -635,13 +636,16 @@ + int flag; + int bits, summer; + int counter, bitscount; +- uint16_t *buf16 = (uint16_t *) buf; ++ uint16_t buf16[IMC_BLOCK_SIZE / 2]; + +- /* FIXME: input should not be modified */ +- for(i = 0; i < FFMIN(buf_size, avctx->block_align) / 2; i++) +- buf16[i] = bswap_16(buf16[i]); ++ if (buf_size < IMC_BLOCK_SIZE) { ++ av_log(avctx, AV_LOG_ERROR, "imc frame too small!\n"); ++ return -1; ++ } ++ for(i = 0; i < IMC_BLOCK_SIZE / 2; i++) ++ buf16[i] = bswap_16(((const uint16_t*)buf)[i]); + +- init_get_bits(&q->gb, buf, 512); ++ init_get_bits(&q->gb, (const uint8_t*)buf16, IMC_BLOCK_SIZE * 8); + + /* Check the frame header */ + imc_hdr = get_bits(&q->gb, 9); +@@ -788,7 +792,7 @@ + + *data_size = COEFFS * sizeof(int16_t); + +- return avctx->block_align; ++ return IMC_BLOCK_SIZE; + } + + +diff -u mplayer-1.0~rc2-12/libavcodec/imcdata.h ffmpeg-free-0.svn20080206/libavcodec/imcdata.h +--- mplayer-1.0~rc2-12/libavcodec/imcdata.h 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/imcdata.h 2007-10-17 11:37:46.000000000 +0200 +@@ -21,8 +21,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef AVCODEC_IMCDATA_H +-#define AVCODEC_IMCDATA_H ++#ifndef FFMPEG_IMCDATA_H ++#define FFMPEG_IMCDATA_H + + #include + +@@ -166,4 +166,4 @@ + } + }; + +-#endif // AVCODEC_IMCDATA_H ++#endif /* FFMPEG_IMCDATA_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/imgconvert.c ffmpeg-free-0.svn20080206/libavcodec/imgconvert.c +--- mplayer-1.0~rc2-12/libavcodec/imgconvert.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/imgconvert.c 2008-06-18 12:09:30.000000000 +0200 +@@ -1901,9 +1901,9 @@ + { + int x, y, src_wrap, dst_wrap; + uint16_t *s, *d; +- s = src->data[0]; ++ s = (uint16_t*)src->data[0]; + src_wrap = (src->linesize[0] - width * 2)/2; +- d = dst->data[0]; ++ d = (uint16_t*)dst->data[0]; + dst_wrap = (dst->linesize[0] - width * 2)/2; + for(y=0; ydata[i], dst->linesize[i], +diff -u mplayer-1.0~rc2-12/libavcodec/imgconvert_template.h ffmpeg-free-0.svn20080206/libavcodec/imgconvert_template.h +--- mplayer-1.0~rc2-12/libavcodec/imgconvert_template.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/imgconvert_template.h 2007-12-01 23:21:04.000000000 +0100 +@@ -19,6 +19,10 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + ++/* This header intentionally has no multiple inclusion guards. It is meant to ++ * be included multiple times and generates different code depending on the ++ * value of certain #defines. */ ++ + #ifndef RGB_OUT + #define RGB_OUT(d, r, g, b) RGBA_OUT(d, r, g, b, 0xff) + #endif +@@ -410,7 +414,7 @@ + } + } + +-// RGB24 has optimised routines ++// RGB24 has optimized routines + #if !defined(FMT_RGB32) && !defined(FMT_RGB24) + /* alpha support */ + +diff -u mplayer-1.0~rc2-12/libavcodec/imgresample.c ffmpeg-free-0.svn20080206/libavcodec/imgresample.c +--- mplayer-1.0~rc2-12/libavcodec/imgresample.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/imgresample.c 2008-06-18 12:09:30.000000000 +0200 +@@ -285,7 +285,7 @@ + } + #endif /* HAVE_MMX */ + +-/* slow version to handle limit cases. Does not need optimisation */ ++/* slow version to handle limit cases. Does not need optimization */ + static void h_resample_slow(uint8_t *dst, int dst_width, + const uint8_t *src, int src_width, + int src_start, int src_incr, int16_t *filters) +@@ -391,7 +391,7 @@ + h_resample(new_line, owidth, + src_line, iwidth, - FCENTER * POS_FRAC, s->h_incr, + &s->h_filters[0][0]); +- /* handle ring buffer wraping */ ++ /* handle ring buffer wrapping */ + if (ring_y >= LINE_BUF_HEIGHT) { + memcpy(s->line_buf + (ring_y - LINE_BUF_HEIGHT) * owidth, + new_line, owidth); +@@ -512,6 +512,12 @@ + av_free(s); + } + ++/* ++ * the following symbols are provided by libswscale. Disable them in ++ * libavcodec so that applications can actually link against both ++ * avcodec and libswscale. ++ */ ++#if 0 + struct SwsContext *sws_getContext(int srcW, int srcH, int srcFormat, + int dstW, int dstH, int dstFormat, + int flags, SwsFilter *srcFilter, +@@ -688,7 +694,7 @@ + av_free(buf2); + return res; + } +- ++#endif + + #ifdef TEST + #include +diff -u mplayer-1.0~rc2-12/libavcodec/indeo2.c ffmpeg-free-0.svn20080206/libavcodec/indeo2.c +--- mplayer-1.0~rc2-12/libavcodec/indeo2.c 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/indeo2.c 2008-03-20 19:10:58.000000000 +0100 +@@ -136,7 +136,7 @@ + + static int ir2_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + Ir2Context * const s = avctx->priv_data; + AVFrame *picture = data; +diff -u mplayer-1.0~rc2-12/libavcodec/indeo2data.h ffmpeg-free-0.svn20080206/libavcodec/indeo2data.h +--- mplayer-1.0~rc2-12/libavcodec/indeo2data.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/indeo2data.h 2007-10-17 11:37:46.000000000 +0200 +@@ -19,8 +19,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef AVCODEC_INDEO2DATA_H +-#define AVCODEC_INDEO2DATA_H ++#ifndef FFMPEG_INDEO2DATA_H ++#define FFMPEG_INDEO2DATA_H + + #include + +@@ -138,4 +138,4 @@ + 0x3F, 0x94, 0xD9, 0xD9, 0x27, 0x27, 0x80, 0x80 + }; + +-#endif // AVCODEC_INDEO2DATA_H ++#endif /* FFMPEG_INDEO2DATA_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/indeo3.c ffmpeg-free-0.svn20080206/libavcodec/indeo3.c +--- mplayer-1.0~rc2-12/libavcodec/indeo3.c 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/indeo3.c 2008-03-20 19:10:58.000000000 +0100 +@@ -27,6 +27,7 @@ + #include "avcodec.h" + #include "dsputil.h" + #include "mpegvideo.h" ++#include "bytestream.h" + + #include "indeo3data.h" + +@@ -54,13 +55,13 @@ + unsigned short *corrector_type; + } Indeo3DecodeContext; + +-static int corrector_type_0[24] = { ++static const int corrector_type_0[24] = { + 195, 159, 133, 115, 101, 93, 87, 77, + 195, 159, 133, 115, 101, 93, 87, 77, + 128, 79, 79, 79, 79, 79, 79, 79 + }; + +-static int corrector_type_2[8] = { 9, 7, 6, 8, 5, 4, 3, 2 }; ++static const int corrector_type_2[8] = { 9, 7, 6, 8, 5, 4, 3, 2 }; + + static void build_modpred(Indeo3DecodeContext *s) + { +@@ -92,9 +93,9 @@ + } + + static void iv_Decode_Chunk(Indeo3DecodeContext *s, unsigned char *cur, +- unsigned char *ref, int width, int height, unsigned char *buf1, +- long fflags2, unsigned char *hdr, +- unsigned char *buf2, int min_width_160); ++ unsigned char *ref, int width, int height, const unsigned char *buf1, ++ long fflags2, const unsigned char *hdr, ++ const unsigned char *buf2, int min_width_160); + + /* ---------------------------------------------------------------------- */ + static void iv_alloc_frames(Indeo3DecodeContext *s) +@@ -176,38 +177,32 @@ + + /* ---------------------------------------------------------------------- */ + static unsigned long iv_decode_frame(Indeo3DecodeContext *s, +- unsigned char *buf, int buf_size) ++ const unsigned char *buf, int buf_size) + { + unsigned int hdr_width, hdr_height, + chroma_width, chroma_height; + unsigned long fflags1, fflags2, fflags3, offs1, offs2, offs3, offs; +- unsigned char *hdr_pos, *buf_pos; ++ const unsigned char *hdr_pos, *buf_pos; + + buf_pos = buf; + buf_pos += 18; + +- fflags1 = le2me_16(*(uint16_t *)buf_pos); +- buf_pos += 2; +- fflags3 = le2me_32(*(uint32_t *)buf_pos); +- buf_pos += 4; ++ fflags1 = bytestream_get_le16(&buf_pos); ++ fflags3 = bytestream_get_le32(&buf_pos); + fflags2 = *buf_pos++; + buf_pos += 3; +- hdr_height = le2me_16(*(uint16_t *)buf_pos); +- buf_pos += 2; +- hdr_width = le2me_16(*(uint16_t *)buf_pos); ++ hdr_height = bytestream_get_le16(&buf_pos); ++ hdr_width = bytestream_get_le16(&buf_pos); + + if(avcodec_check_dimensions(NULL, hdr_width, hdr_height)) + return -1; + +- buf_pos += 2; + chroma_height = ((hdr_height >> 2) + 3) & 0x7ffc; + chroma_width = ((hdr_width >> 2) + 3) & 0x7ffc; +- offs1 = le2me_32(*(uint32_t *)buf_pos); +- buf_pos += 4; +- offs2 = le2me_32(*(uint32_t *)buf_pos); ++ offs1 = bytestream_get_le32(&buf_pos); ++ offs2 = bytestream_get_le32(&buf_pos); ++ offs3 = bytestream_get_le32(&buf_pos); + buf_pos += 4; +- offs3 = le2me_32(*(uint32_t *)buf_pos); +- buf_pos += 8; + hdr_pos = buf_pos; + if(fflags3 == 0x80) return 4; + +@@ -220,8 +215,7 @@ + } + + buf_pos = buf + 16 + offs1; +- offs = le2me_32(*(uint32_t *)buf_pos); +- buf_pos += 4; ++ offs = bytestream_get_le32(&buf_pos); + + iv_Decode_Chunk(s, s->cur_frame->Ybuf, s->ref_frame->Ybuf, hdr_width, + hdr_height, buf_pos + offs * 2, fflags2, hdr_pos, buf_pos, +@@ -231,16 +225,14 @@ + { + + buf_pos = buf + 16 + offs2; +- offs = le2me_32(*(uint32_t *)buf_pos); +- buf_pos += 4; ++ offs = bytestream_get_le32(&buf_pos); + + iv_Decode_Chunk(s, s->cur_frame->Vbuf, s->ref_frame->Vbuf, chroma_width, + chroma_height, buf_pos + offs * 2, fflags2, hdr_pos, buf_pos, + FFMIN(chroma_width, 40)); + + buf_pos = buf + 16 + offs3; +- offs = le2me_32(*(uint32_t *)buf_pos); +- buf_pos += 4; ++ offs = bytestream_get_le32(&buf_pos); + + iv_Decode_Chunk(s, s->cur_frame->Ubuf, s->ref_frame->Ubuf, chroma_width, + chroma_height, buf_pos + offs * 2, fflags2, hdr_pos, buf_pos, +@@ -307,13 +299,13 @@ + + static void iv_Decode_Chunk(Indeo3DecodeContext *s, + unsigned char *cur, unsigned char *ref, int width, int height, +- unsigned char *buf1, long fflags2, unsigned char *hdr, +- unsigned char *buf2, int min_width_160) ++ const unsigned char *buf1, long fflags2, const unsigned char *hdr, ++ const unsigned char *buf2, int min_width_160) + { + unsigned char bit_buf; + unsigned long bit_pos, lv, lv1, lv2; + long *width_tbl, width_tbl_arr[10]; +- signed char *ref_vectors; ++ const signed char *ref_vectors; + unsigned char *cur_frm_pos, *ref_frm_pos, *cp, *cp2; + uint32_t *cur_lp, *ref_lp; + const uint32_t *correction_lp[2], *correctionloworder_lp[2], *correctionhighorder_lp[2]; +@@ -378,7 +370,7 @@ + } else if(cmd == 3) { + if(strip->usl7 == 0) { + strip->usl7 = 1; +- ref_vectors = (signed char*)buf2 + (*buf1 * 2); ++ ref_vectors = (const signed char*)buf2 + (*buf1 * 2); + buf1++; + continue; + } +@@ -1074,7 +1066,7 @@ + + static int indeo3_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- unsigned char *buf, int buf_size) ++ const unsigned char *buf, int buf_size) + { + Indeo3DecodeContext *s=avctx->priv_data; + unsigned char *src, *dest; +diff -u mplayer-1.0~rc2-12/libavcodec/indeo3data.h ffmpeg-free-0.svn20080206/libavcodec/indeo3data.h +--- mplayer-1.0~rc2-12/libavcodec/indeo3data.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/indeo3data.h 2007-10-17 11:37:46.000000000 +0200 +@@ -19,8 +19,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef AVCODEC_INDEO3DATA_H +-#define AVCODEC_INDEO3DATA_H ++#ifndef FFMPEG_INDEO3DATA_H ++#define FFMPEG_INDEO3DATA_H + + #include + +@@ -2339,4 +2339,4 @@ + 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000 + }; + +-#endif // AVCODEC_INDEO3DATA_H ++#endif /* FFMPEG_INDEO3DATA_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/interplayvideo.c ffmpeg-free-0.svn20080206/libavcodec/interplayvideo.c +--- mplayer-1.0~rc2-12/libavcodec/interplayvideo.c 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/interplayvideo.c 2008-03-20 19:10:58.000000000 +0100 +@@ -60,14 +60,14 @@ + AVFrame second_last_frame; + AVFrame last_frame; + AVFrame current_frame; +- unsigned char *decoding_map; ++ const unsigned char *decoding_map; + int decoding_map_size; + +- unsigned char *buf; ++ const unsigned char *buf; + int size; + +- unsigned char *stream_ptr; +- unsigned char *stream_end; ++ const unsigned char *stream_ptr; ++ const unsigned char *stream_end; + unsigned char *pixel_ptr; + int line_inc; + int stride; +@@ -879,7 +879,7 @@ + + static int ipvideo_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + IpvideoContext *s = avctx->priv_data; + AVPaletteControl *palette_control = avctx->palctrl; +Only in ffmpeg-free-0.svn20080206/libavcodec: intrax8.c +Only in ffmpeg-free-0.svn20080206/libavcodec: intrax8dsp.c +Only in ffmpeg-free-0.svn20080206/libavcodec: intrax8.h +Only in ffmpeg-free-0.svn20080206/libavcodec: intrax8huf.h +diff -u mplayer-1.0~rc2-12/libavcodec/jpeglsdec.h ffmpeg-free-0.svn20080206/libavcodec/jpeglsdec.h +--- mplayer-1.0~rc2-12/libavcodec/jpeglsdec.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/jpeglsdec.h 2007-10-17 11:37:46.000000000 +0200 +@@ -25,8 +25,8 @@ + * JPEG-LS decoder. + */ + +-#ifndef JPEGLSDEC_H +-#define JPEGLSDEC_H ++#ifndef FFMPEG_JPEGLSDEC_H ++#define FFMPEG_JPEGLSDEC_H + + #include "mjpeg.h" + #include "mjpegdec.h" +@@ -38,4 +38,4 @@ + + int ff_jpegls_decode_picture(MJpegDecodeContext *s, int near, int point_transform, int ilv); + +-#endif /* JPEGLSDEC_H */ ++#endif /* FFMPEG_JPEGLSDEC_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/jpegls.h ffmpeg-free-0.svn20080206/libavcodec/jpegls.h +--- mplayer-1.0~rc2-12/libavcodec/jpegls.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/jpegls.h 2007-10-17 11:37:46.000000000 +0200 +@@ -25,8 +25,8 @@ + * JPEG-LS common code. + */ + +-#ifndef JPEGLS_H +-#define JPEGLS_H ++#ifndef FFMPEG_JPEGLS_H ++#define FFMPEG_JPEGLS_H + + #include "avcodec.h" + +@@ -108,4 +108,4 @@ + #define R(a, i ) (bits == 8 ? ((uint8_t*)(a))[i] : ((uint16_t*)(a))[i] ) + #define W(a, i, v) (bits == 8 ? (((uint8_t*)(a))[i]=v) : (((uint16_t*)(a))[i]=v)) + +-#endif /* JPEGLS_H */ ++#endif /* FFMPEG_JPEGLS_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/kmvc.c ffmpeg-free-0.svn20080206/libavcodec/kmvc.c +--- mplayer-1.0~rc2-12/libavcodec/kmvc.c 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/kmvc.c 2008-03-20 19:10:58.000000000 +0100 +@@ -67,7 +67,7 @@ + } \ + } + +-static void kmvc_decode_intra_8x8(KmvcContext * ctx, uint8_t * src, int w, int h) ++static void kmvc_decode_intra_8x8(KmvcContext * ctx, const uint8_t * src, int w, int h) + { + BitBuf bb; + int res, val; +@@ -142,7 +142,7 @@ + } + } + +-static void kmvc_decode_inter_8x8(KmvcContext * ctx, uint8_t * src, int w, int h) ++static void kmvc_decode_inter_8x8(KmvcContext * ctx, const uint8_t * src, int w, int h) + { + BitBuf bb; + int res, val; +@@ -224,7 +224,7 @@ + } + } + +-static int decode_frame(AVCodecContext * avctx, void *data, int *data_size, uint8_t * buf, ++static int decode_frame(AVCodecContext * avctx, void *data, int *data_size, const uint8_t * buf, + int buf_size) + { + KmvcContext *const ctx = avctx->priv_data; +diff -u mplayer-1.0~rc2-12/libavcodec/lcldec.c ffmpeg-free-0.svn20080206/libavcodec/lcldec.c +--- mplayer-1.0~rc2-12/libavcodec/lcldec.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/lcldec.c 2008-03-20 19:10:58.000000000 +0100 +@@ -161,7 +161,7 @@ + * Decode a frame + * + */ +-static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8_t *buf, int buf_size) ++static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, const uint8_t *buf, int buf_size) + { + LclDecContext * const c = avctx->priv_data; + unsigned char *encoded = (unsigned char *)buf; +diff -u mplayer-1.0~rc2-12/libavcodec/lcl.h ffmpeg-free-0.svn20080206/libavcodec/lcl.h +--- mplayer-1.0~rc2-12/libavcodec/lcl.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/lcl.h 2007-10-17 11:37:46.000000000 +0200 +@@ -19,8 +19,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef AVCODEC_LCL_H +-#define AVCODEC_LCL_H ++#ifndef FFMPEG_LCL_H ++#define FFMPEG_LCL_H + + #define BMPTYPE_YUV 1 + #define BMPTYPE_RGB 2 +@@ -46,4 +46,4 @@ + #define CODEC_MSZH 1 + #define CODEC_ZLIB 3 + +-#endif /* AVCODEC_LCL_H */ ++#endif /* FFMPEG_LCL_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/liba52.c ffmpeg-free-0.svn20080206/libavcodec/liba52.c +--- mplayer-1.0~rc2-12/libavcodec/liba52.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/liba52.c 2008-03-20 19:10:58.000000000 +0100 +@@ -117,6 +117,13 @@ + s->inbuf_ptr = s->inbuf; + s->frame_size = 0; + ++ /* allow downmixing to stereo or mono */ ++ if (avctx->channels > 0 && avctx->request_channels > 0 && ++ avctx->request_channels < avctx->channels && ++ avctx->request_channels <= 2) { ++ avctx->channels = avctx->request_channels; ++ } ++ + return 0; + } + +@@ -179,11 +186,11 @@ + s->channels = ac3_channels[s->flags & 7]; + if (s->flags & A52_LFE) + s->channels++; +- if (avctx->channels == 0) +- /* No specific number of channel requested */ +- avctx->channels = s->channels; +- else if (s->channels < avctx->channels) { +- av_log(avctx, AV_LOG_ERROR, "ac3dec: AC3 Source channels are less than specified: output to %d channels.. (frmsize: %d)\n", s->channels, len); ++ if (avctx->request_channels > 0 && ++ avctx->request_channels <= 2 && ++ avctx->request_channels < s->channels) { ++ avctx->channels = avctx->request_channels; ++ } else { + avctx->channels = s->channels; + } + avctx->bit_rate = bit_rate; +diff -u mplayer-1.0~rc2-12/libavcodec/libamr.c ffmpeg-free-0.svn20080206/libavcodec/libamr.c +--- mplayer-1.0~rc2-12/libavcodec/libamr.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/libamr.c 2008-03-20 19:10:58.000000000 +0100 +@@ -523,7 +523,7 @@ + #ifdef CONFIG_LIBAMR_WB + + #ifdef _TYPEDEF_H +-//To avoid duplicate typedefs from typdef in amr-nb ++//To avoid duplicate typedefs from typedef in amr-nb + #define typedef_h + #endif + +diff -u mplayer-1.0~rc2-12/libavcodec/libfaad.c ffmpeg-free-0.svn20080206/libavcodec/libfaad.c +--- mplayer-1.0~rc2-12/libavcodec/libfaad.c 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/libfaad.c 2008-03-20 19:10:58.000000000 +0100 +@@ -42,7 +42,7 @@ + + #ifdef CONFIG_LIBFAADBIN + #include +-static const char* libfaadname = "libfaad.so.0"; ++static const char* libfaadname = "libfaad.so"; + #else + #define dlopen(a) + #define dlclose(a) +@@ -58,36 +58,36 @@ + faacDecHandle FAADAPI (*faacDecOpen)(void); + faacDecConfigurationPtr FAADAPI (*faacDecGetCurrentConfiguration)(faacDecHandle hDecoder); + #ifndef FAAD2_VERSION +- int FAADAPI (*faacDecSetConfiguration)(faacDecHandle hDecoder, ++ int FAADAPI (*faacDecSetConfiguration)(faacDecHandle hDecoder, + faacDecConfigurationPtr config); +- int FAADAPI (*faacDecInit)(faacDecHandle hDecoder, +- unsigned char *buffer, +- unsigned long *samplerate, +- unsigned long *channels); +- int FAADAPI (*faacDecInit2)(faacDecHandle hDecoder, unsigned char *pBuffer, ++ int FAADAPI (*faacDecInit)(faacDecHandle hDecoder, ++ unsigned char *buffer, ++ unsigned long *samplerate, ++ unsigned long *channels); ++ int FAADAPI (*faacDecInit2)(faacDecHandle hDecoder, unsigned char *pBuffer, + unsigned long SizeOfDecoderSpecificInfo, + unsigned long *samplerate, unsigned long *channels); +- int FAADAPI (*faacDecDecode)(faacDecHandle hDecoder, +- unsigned char *buffer, +- unsigned long *bytesconsumed, +- short *sample_buffer, +- unsigned long *samples); ++ int FAADAPI (*faacDecDecode)(faacDecHandle hDecoder, ++ unsigned char *buffer, ++ unsigned long *bytesconsumed, ++ short *sample_buffer, ++ unsigned long *samples); + #else +- unsigned char FAADAPI (*faacDecSetConfiguration)(faacDecHandle hDecoder, ++ unsigned char FAADAPI (*faacDecSetConfiguration)(faacDecHandle hDecoder, + faacDecConfigurationPtr config); +- long FAADAPI (*faacDecInit)(faacDecHandle hDecoder, +- unsigned char *buffer, +- unsigned long buffer_size, +- unsigned long *samplerate, +- unsigned char *channels); +- char FAADAPI (*faacDecInit2)(faacDecHandle hDecoder, unsigned char *pBuffer, ++ long FAADAPI (*faacDecInit)(faacDecHandle hDecoder, ++ unsigned char *buffer, ++ unsigned long buffer_size, ++ unsigned long *samplerate, ++ unsigned char *channels); ++ char FAADAPI (*faacDecInit2)(faacDecHandle hDecoder, unsigned char *pBuffer, + unsigned long SizeOfDecoderSpecificInfo, + unsigned long *samplerate, unsigned char *channels); +- void *FAADAPI (*faacDecDecode)(faacDecHandle hDecoder, +- faacDecFrameInfo *hInfo, +- unsigned char *buffer, +- unsigned long buffer_size); +- char* FAADAPI (*faacDecGetErrorMessage)(unsigned char errcode); ++ void *FAADAPI (*faacDecDecode)(faacDecHandle hDecoder, ++ faacDecFrameInfo *hInfo, ++ unsigned char *buffer, ++ unsigned long buffer_size); ++ char* FAADAPI (*faacDecGetErrorMessage)(unsigned char errcode); + #endif + + void FAADAPI (*faacDecClose)(faacDecHandle hDecoder); +@@ -101,6 +101,21 @@ + 24000, 22050, 16000, 12000, 11025, 8000 + }; + ++static void channel_setup(AVCodecContext *avctx) ++{ ++#ifdef FAAD2_VERSION ++ FAACContext *s = avctx->priv_data; ++ if (avctx->request_channels > 0 && avctx->request_channels == 2 && ++ avctx->request_channels < avctx->channels) { ++ faacDecConfigurationPtr faac_cfg; ++ avctx->channels = 2; ++ faac_cfg = s->faacDecGetCurrentConfiguration(s->faac_handle); ++ faac_cfg->downMatrix = 1; ++ s->faacDecSetConfiguration(s->faac_handle, faac_cfg); ++ } ++#endif ++} ++ + static int faac_init_mp4(AVCodecContext *avctx) + { + FAACContext *s = avctx->priv_data; +@@ -123,6 +138,7 @@ + } else { + avctx->sample_rate = samplerate; + avctx->channels = channels; ++ channel_setup(avctx); + s->init = 1; + } + } +@@ -170,6 +186,7 @@ + } + avctx->sample_rate = srate; + avctx->channels = channels; ++ channel_setup(avctx); + s->init = 1; + } + +@@ -177,7 +194,7 @@ + + if (frame_info.error > 0) { + av_log(avctx, AV_LOG_ERROR, "faac: frame decoding failed: %s\n", +- s->faacDecGetErrorMessage(frame_info.error)); ++ s->faacDecGetErrorMessage(frame_info.error)); + return -1; + } + +@@ -214,54 +231,39 @@ + if (!s->handle) + { + av_log(avctx, AV_LOG_ERROR, "FAAD library: %s could not be opened! \n%s\n", +- libfaadname, dlerror()); ++ libfaadname, dlerror()); + return -1; + } +-#define dfaac(a, b) \ +- do { static const char* n = "faacDec" #a; \ +- if ((s->faacDec ## a = b dlsym( s->handle, n )) == NULL) { err = n; break; } } while(0) +- for(;;) { ++ ++#define dfaac(a) do { \ ++ const char* n = AV_STRINGIFY(faacDec ## a); \ ++ if (!err && !(s->faacDec ## a = dlsym(s->handle, n))) { \ ++ err = n; \ ++ } \ ++ } while(0) + #else /* !CONFIG_LIBFAADBIN */ +-#define dfaac(a, b) s->faacDec ## a = faacDec ## a ++#define dfaac(a) s->faacDec ## a = faacDec ## a + #endif /* CONFIG_LIBFAADBIN */ + +- // resolve all needed function calls +- dfaac(Open, (faacDecHandle FAADAPI (*)(void))); +- dfaac(Close, (void FAADAPI (*)(faacDecHandle hDecoder))); +- dfaac(GetCurrentConfiguration, (faacDecConfigurationPtr +- FAADAPI (*)(faacDecHandle))); +-#ifndef FAAD2_VERSION +- dfaac(SetConfiguration, (int FAADAPI (*)(faacDecHandle, +- faacDecConfigurationPtr))); +- +- dfaac(Init, (int FAADAPI (*)(faacDecHandle, unsigned char*, +- unsigned long*, unsigned long*))); +- dfaac(Init2, (int FAADAPI (*)(faacDecHandle, unsigned char*, +- unsigned long, unsigned long*, +- unsigned long*))); +- dfaac(Decode, (int FAADAPI (*)(faacDecHandle, unsigned char*, +- unsigned long*, short*, unsigned long*))); +-#else +- dfaac(SetConfiguration, (unsigned char FAADAPI (*)(faacDecHandle, +- faacDecConfigurationPtr))); +- dfaac(Init, (long FAADAPI (*)(faacDecHandle, unsigned char*, +- unsigned long, unsigned long*, unsigned char*))); +- dfaac(Init2, (char FAADAPI (*)(faacDecHandle, unsigned char*, +- unsigned long, unsigned long*, +- unsigned char*))); +- dfaac(Decode, (void *FAADAPI (*)(faacDecHandle, faacDecFrameInfo*, +- unsigned char*, unsigned long))); +- dfaac(GetErrorMessage, (char* FAADAPI (*)(unsigned char))); ++ // resolve all needed function calls ++ dfaac(Open); ++ dfaac(Close); ++ dfaac(GetCurrentConfiguration); ++ dfaac(SetConfiguration); ++ dfaac(Init); ++ dfaac(Init2); ++ dfaac(Decode); ++#ifdef FAAD2_VERSION ++ dfaac(GetErrorMessage); + #endif +-#undef dfacc ++ ++#undef dfaac + + #ifdef CONFIG_LIBFAADBIN +- break; +- } + if (err) { + dlclose(s->handle); + av_log(avctx, AV_LOG_ERROR, "FAAD library: cannot resolve %s in %s!\n", +- err, libfaadname); ++ err, libfaadname); + return -1; + } + #endif +@@ -308,6 +310,9 @@ + + faac_init_mp4(avctx); + ++ if(!s->init && avctx->channels > 0) ++ channel_setup(avctx); ++ + return 0; + } + +diff -u mplayer-1.0~rc2-12/libavcodec/libvorbis.c ffmpeg-free-0.svn20080206/libavcodec/libvorbis.c +--- mplayer-1.0~rc2-12/libavcodec/libvorbis.c 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/libvorbis.c 2008-03-20 19:10:58.000000000 +0100 +@@ -218,160 +218,3 @@ + oggvorbis_encode_close, + .capabilities= CODEC_CAP_DELAY, + } ; +- +-static int oggvorbis_decode_init(AVCodecContext *avccontext) { +- OggVorbisContext *context = avccontext->priv_data ; +- uint8_t *p= avccontext->extradata; +- int i, hsizes[3]; +- unsigned char *headers[3], *extradata = avccontext->extradata; +- +- vorbis_info_init(&context->vi) ; +- vorbis_comment_init(&context->vc) ; +- +- if(! avccontext->extradata_size || ! p) { +- av_log(avccontext, AV_LOG_ERROR, "vorbis extradata absent\n"); +- return -1; +- } +- +- if(p[0] == 0 && p[1] == 30) { +- for(i = 0; i < 3; i++){ +- hsizes[i] = bytestream_get_be16(&p); +- headers[i] = p; +- p += hsizes[i]; +- } +- } else if(*p == 2) { +- unsigned int offset = 1; +- p++; +- for(i=0; i<2; i++) { +- hsizes[i] = 0; +- while((*p == 0xFF) && (offset < avccontext->extradata_size)) { +- hsizes[i] += 0xFF; +- offset++; +- p++; +- } +- if(offset >= avccontext->extradata_size - 1) { +- av_log(avccontext, AV_LOG_ERROR, +- "vorbis header sizes damaged\n"); +- return -1; +- } +- hsizes[i] += *p; +- offset++; +- p++; +- } +- hsizes[2] = avccontext->extradata_size - hsizes[0]-hsizes[1]-offset; +-#if 0 +- av_log(avccontext, AV_LOG_DEBUG, +- "vorbis header sizes: %d, %d, %d, / extradata_len is %d \n", +- hsizes[0], hsizes[1], hsizes[2], avccontext->extradata_size); +-#endif +- headers[0] = extradata + offset; +- headers[1] = extradata + offset + hsizes[0]; +- headers[2] = extradata + offset + hsizes[0] + hsizes[1]; +- } else { +- av_log(avccontext, AV_LOG_ERROR, +- "vorbis initial header len is wrong: %d\n", *p); +- return -1; +- } +- +- for(i=0; i<3; i++){ +- context->op.b_o_s= i==0; +- context->op.bytes = hsizes[i]; +- context->op.packet = headers[i]; +- if(vorbis_synthesis_headerin(&context->vi, &context->vc, &context->op)<0){ +- av_log(avccontext, AV_LOG_ERROR, "%d. vorbis header damaged\n", i+1); +- return -1; +- } +- } +- +- avccontext->channels = context->vi.channels; +- avccontext->sample_rate = context->vi.rate; +- avccontext->time_base= (AVRational){1, avccontext->sample_rate}; +- +- vorbis_synthesis_init(&context->vd, &context->vi); +- vorbis_block_init(&context->vd, &context->vb); +- +- return 0 ; +-} +- +- +-static inline int conv(int samples, float **pcm, char *buf, int channels) { +- int i, j; +- ogg_int16_t *ptr, *data = (ogg_int16_t*)buf ; +- float *mono ; +- +- for(i = 0 ; i < channels ; i++){ +- ptr = &data[i]; +- mono = pcm[i] ; +- +- for(j = 0 ; j < samples ; j++) { +- *ptr = av_clip_int16(mono[j] * 32767.f); +- ptr += channels; +- } +- } +- +- return 0 ; +-} +- +- +-static int oggvorbis_decode_frame(AVCodecContext *avccontext, +- void *data, int *data_size, +- uint8_t *buf, int buf_size) +-{ +- OggVorbisContext *context = avccontext->priv_data ; +- float **pcm ; +- ogg_packet *op= &context->op; +- int samples, total_samples, total_bytes; +- +- if(!buf_size){ +- //FIXME flush +- return 0; +- } +- +- op->packet = buf; +- op->bytes = buf_size; +- +-// av_log(avccontext, AV_LOG_DEBUG, "%d %d %d %"PRId64" %"PRId64" %d %d\n", op->bytes, op->b_o_s, op->e_o_s, op->granulepos, op->packetno, buf_size, context->vi.rate); +- +-/* for(i=0; ibytes; i++) +- av_log(avccontext, AV_LOG_DEBUG, "%02X ", op->packet[i]); +- av_log(avccontext, AV_LOG_DEBUG, "\n");*/ +- +- if(vorbis_synthesis(&context->vb, op) == 0) +- vorbis_synthesis_blockin(&context->vd, &context->vb) ; +- +- total_samples = 0 ; +- total_bytes = 0 ; +- +- while((samples = vorbis_synthesis_pcmout(&context->vd, &pcm)) > 0) { +- conv(samples, pcm, (char*)data + total_bytes, context->vi.channels) ; +- total_bytes += samples * 2 * context->vi.channels ; +- total_samples += samples ; +- vorbis_synthesis_read(&context->vd, samples) ; +- } +- +- *data_size = total_bytes ; +- return buf_size ; +-} +- +- +-static int oggvorbis_decode_close(AVCodecContext *avccontext) { +- OggVorbisContext *context = avccontext->priv_data ; +- +- vorbis_info_clear(&context->vi) ; +- vorbis_comment_clear(&context->vc) ; +- +- return 0 ; +-} +- +- +-AVCodec libvorbis_decoder = { +- "libvorbis", +- CODEC_TYPE_AUDIO, +- CODEC_ID_VORBIS, +- sizeof(OggVorbisContext), +- oggvorbis_decode_init, +- NULL, +- oggvorbis_decode_close, +- oggvorbis_decode_frame, +- .capabilities= CODEC_CAP_DELAY, +-} ; +diff -u mplayer-1.0~rc2-12/libavcodec/libxvid_internal.h ffmpeg-free-0.svn20080206/libavcodec/libxvid_internal.h +--- mplayer-1.0~rc2-12/libavcodec/libxvid_internal.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/libxvid_internal.h 2007-10-17 11:37:46.000000000 +0200 +@@ -18,8 +18,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef XVID_INTERNAL_H +-#define XVID_INTERNAL_H ++#ifndef FFMPEG_LIBXVID_INTERNAL_H ++#define FFMPEG_LIBXVID_INTERNAL_H + + /** + * @file libxvid_internal.h +@@ -29,4 +29,4 @@ + + int av_tempfile(char *prefix, char **filename); + +-#endif /* XVID_INTERNAL_H */ ++#endif /* FFMPEG_LIBXVID_INTERNAL_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/loco.c ffmpeg-free-0.svn20080206/libavcodec/loco.c +--- mplayer-1.0~rc2-12/libavcodec/loco.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/loco.c 2008-03-20 19:10:58.000000000 +0100 +@@ -116,7 +116,7 @@ + } + + static int loco_decode_plane(LOCOContext *l, uint8_t *data, int width, int height, +- int stride, uint8_t *buf, int buf_size, int step) ++ int stride, const uint8_t *buf, int buf_size, int step) + { + RICEContext rc; + int val; +@@ -157,7 +157,7 @@ + + static int decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + LOCOContext * const l = avctx->priv_data; + AVFrame * const p= (AVFrame*)&l->pic; +diff -u mplayer-1.0~rc2-12/libavcodec/lzw.c ffmpeg-free-0.svn20080206/libavcodec/lzw.c +--- mplayer-1.0~rc2-12/libavcodec/lzw.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/lzw.c 2008-03-20 19:10:58.000000000 +0100 +@@ -42,7 +42,7 @@ + }; + + struct LZWState { +- uint8_t *pbuf, *ebuf; ++ const uint8_t *pbuf, *ebuf; + int bbits; + unsigned int bbuf; + +@@ -91,7 +91,7 @@ + return c & s->curmask; + } + +-uint8_t* ff_lzw_cur_ptr(LZWState *p) ++const uint8_t* ff_lzw_cur_ptr(LZWState *p) + { + return ((struct LZWState*)p)->pbuf; + } +@@ -127,7 +127,7 @@ + * @param buf_size input data size + * @param mode decoder working mode - either GIF or TIFF + */ +-int ff_lzw_decode_init(LZWState *p, int csize, uint8_t *buf, int buf_size, int mode) ++int ff_lzw_decode_init(LZWState *p, int csize, const uint8_t *buf, int buf_size, int mode) + { + struct LZWState *s = (struct LZWState *)p; + +diff -u mplayer-1.0~rc2-12/libavcodec/lzw.h ffmpeg-free-0.svn20080206/libavcodec/lzw.h +--- mplayer-1.0~rc2-12/libavcodec/lzw.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/lzw.h 2008-02-01 04:26:31.000000000 +0100 +@@ -27,8 +27,8 @@ + * Modified for use in TIFF by Konstantin Shishkov + */ + +-#ifndef LZW_H +-#define LZW_H ++#ifndef FFMPEG_LZW_H ++#define FFMPEG_LZW_H + + #include "bitstream.h" + +@@ -43,9 +43,9 @@ + /* first two functions de/allocate memory for LZWState */ + void ff_lzw_decode_open(LZWState **p); + void ff_lzw_decode_close(LZWState **p); +-int ff_lzw_decode_init(LZWState *s, int csize, uint8_t *buf, int buf_size, int mode); ++int ff_lzw_decode_init(LZWState *s, int csize, const uint8_t *buf, int buf_size, int mode); + int ff_lzw_decode(LZWState *s, uint8_t *buf, int len); +-uint8_t* ff_lzw_cur_ptr(LZWState *lzw); ++const uint8_t* ff_lzw_cur_ptr(LZWState *lzw); + void ff_lzw_decode_tail(LZWState *lzw); + + /** LZW encode state */ +@@ -56,4 +56,4 @@ + int ff_lzw_encode(struct LZWEncodeState * s, const uint8_t * inbuf, int insize); + int ff_lzw_encode_flush(struct LZWEncodeState * s); + +-#endif ++#endif /* FFMPEG_LZW_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/mace.c ffmpeg-free-0.svn20080206/libavcodec/mace.c +--- mplayer-1.0~rc2-12/libavcodec/mace.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/mace.c 2008-03-20 19:10:58.000000000 +0100 +@@ -263,7 +263,7 @@ + + /* /// "Exp1to3()" */ + static void Exp1to3(MACEContext *ctx, +- uint8_t *inBuffer, ++ const uint8_t *inBuffer, + void *outBuffer, + uint32_t cnt, + uint32_t numChannels, +@@ -347,7 +347,7 @@ + + /* /// "Exp1to6()" */ + static void Exp1to6(MACEContext *ctx, +- uint8_t *inBuffer, ++ const uint8_t *inBuffer, + void *outBuffer, + uint32_t cnt, + uint32_t numChannels, +@@ -401,7 +401,7 @@ + + static int mace_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + short *samples; + MACEContext *c = avctx->priv_data; +@@ -409,18 +409,14 @@ + samples = (short *)data; + switch (avctx->codec->id) { + case CODEC_ID_MACE3: +-#ifdef DEBUG +-puts("mace_decode_frame[3]()"); +-#endif ++ dprintf(avctx, "mace_decode_frame[3]()"); + Exp1to3(c, buf, samples, buf_size / 2 / avctx->channels, avctx->channels, 1); + if (avctx->channels == 2) + Exp1to3(c, buf, samples+1, buf_size / 2 / 2, 2, 2); + *data_size = 2 * 3 * buf_size; + break; + case CODEC_ID_MACE6: +-#ifdef DEBUG +-puts("mace_decode_frame[6]()"); +-#endif ++ dprintf(avctx, "mace_decode_frame[6]()"); + Exp1to6(c, buf, samples, buf_size / avctx->channels, avctx->channels, 1); + if (avctx->channels == 2) + Exp1to6(c, buf, samples+1, buf_size / 2, 2, 2); +diff -u mplayer-1.0~rc2-12/libavcodec/Makefile ffmpeg-free-0.svn20080206/libavcodec/Makefile +--- mplayer-1.0~rc2-12/libavcodec/Makefile 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/Makefile 2008-06-18 12:09:30.000000000 +0200 +@@ -18,7 +18,8 @@ + jrevdct.o \ + jfdctfst.o \ + jfdctint.o\ +- mpeg12.o mpeg12data.o \ ++ mpeg12.o \ ++ mpeg12data.o \ + mpegvideo.o \ + opt.o \ + parser.o \ +@@ -56,8 +57,9 @@ + OBJS-$(CONFIG_CYUV_DECODER) += cyuv.o + OBJS-$(CONFIG_DCA_DECODER) += dca.o + OBJS-$(CONFIG_DNXHD_DECODER) += dnxhddec.o dnxhddata.o +-OBJS-$(CONFIG_DSICINVIDEO_DECODER) += dsicinav.o ++OBJS-$(CONFIG_DNXHD_ENCODER) += dnxhdenc.o dnxhddata.o mpegvideo_enc.o motion_est.o ratecontrol.o + OBJS-$(CONFIG_DSICINAUDIO_DECODER) += dsicinav.o ++OBJS-$(CONFIG_DSICINVIDEO_DECODER) += dsicinav.o + OBJS-$(CONFIG_DVBSUB_DECODER) += dvbsubdec.o + OBJS-$(CONFIG_DVBSUB_ENCODER) += dvbsub.o + OBJS-$(CONFIG_DVDSUB_DECODER) += dvdsubdec.o +@@ -78,7 +80,7 @@ + OBJS-$(CONFIG_FLV_DECODER) += h263dec.o h263.o + OBJS-$(CONFIG_FLV_ENCODER) += mpegvideo_enc.o motion_est.o ratecontrol.o h263.o + OBJS-$(CONFIG_FOURXM_DECODER) += 4xm.o +-OBJS-$(CONFIG_FRAPS_DECODER) += fraps.o ++OBJS-$(CONFIG_FRAPS_DECODER) += fraps.o huffman.o + OBJS-$(CONFIG_GIF_DECODER) += gifdec.o lzw.o + OBJS-$(CONFIG_GIF_ENCODER) += gif.o + OBJS-$(CONFIG_H261_DECODER) += h261dec.o h261.o +@@ -95,8 +97,8 @@ + OBJS-$(CONFIG_IMC_DECODER) += imc.o mdct.o fft.o + OBJS-$(CONFIG_INDEO2_DECODER) += indeo2.o + OBJS-$(CONFIG_INDEO3_DECODER) += indeo3.o +-OBJS-$(CONFIG_INTERPLAY_VIDEO_DECODER) += interplayvideo.o + OBJS-$(CONFIG_INTERPLAY_DPCM_DECODER) += dpcm.o ++OBJS-$(CONFIG_INTERPLAY_VIDEO_DECODER) += interplayvideo.o + OBJS-$(CONFIG_JPEGLS_DECODER) += jpeglsdec.o jpegls.o mjpegdec.o mjpeg.o golomb.o + OBJS-$(CONFIG_JPEGLS_ENCODER) += jpeglsenc.o jpegls.o golomb.o + OBJS-$(CONFIG_KMVC_DECODER) += kmvc.o +@@ -113,7 +115,8 @@ + OBJS-$(CONFIG_MP3_DECODER) += mpegaudiodec.o mpegaudiodecheader.o mpegaudio.o mpegaudiodata.o + OBJS-$(CONFIG_MP3ADU_DECODER) += mpegaudiodec.o mpegaudiodecheader.o mpegaudio.o mpegaudiodata.o + OBJS-$(CONFIG_MP3ON4_DECODER) += mpegaudiodec.o mpegaudiodecheader.o mpegaudio.o mpegaudiodata.o +-OBJS-$(CONFIG_MPC7_DECODER) += mpc.o mpegaudiodec.o mpegaudiodecheader.o mpegaudio.o mpegaudiodata.o ++OBJS-$(CONFIG_MPC7_DECODER) += mpc7.o mpc.o mpegaudiodec.o mpegaudiodecheader.o mpegaudio.o mpegaudiodata.o ++OBJS-$(CONFIG_MPC8_DECODER) += mpc8.o mpc.o mpegaudiodec.o mpegaudiodecheader.o mpegaudio.o mpegaudiodata.o + OBJS-$(CONFIG_MPEG1VIDEO_ENCODER) += mpeg12enc.o mpeg12data.o mpegvideo_enc.o motion_est.o ratecontrol.o + OBJS-$(CONFIG_MPEG2VIDEO_ENCODER) += mpeg12enc.o mpeg12data.o mpegvideo_enc.o motion_est.o ratecontrol.o + OBJS-$(CONFIG_MPEG4_DECODER) += h263dec.o h263.o +@@ -127,9 +130,11 @@ + OBJS-$(CONFIG_MSRLE_DECODER) += msrle.o + OBJS-$(CONFIG_MSVIDEO1_DECODER) += msvideo1.o + OBJS-$(CONFIG_MSZH_DECODER) += lcldec.o ++OBJS-$(CONFIG_NELLYMOSER_DECODER) += nellymoserdec.o mdct.o fft.o + OBJS-$(CONFIG_NUV_DECODER) += nuv.o rtjpeg.o + OBJS-$(CONFIG_PAM_ENCODER) += pnmenc.o pnm.o + OBJS-$(CONFIG_PBM_ENCODER) += pnmenc.o pnm.o ++OBJS-$(CONFIG_PCX_DECODER) += pcx.o + OBJS-$(CONFIG_PGM_ENCODER) += pnmenc.o pnm.o + OBJS-$(CONFIG_PGMYUV_ENCODER) += pnmenc.o pnm.o + OBJS-$(CONFIG_PNG_DECODER) += png.o pngdec.o +@@ -167,6 +172,7 @@ + OBJS-$(CONFIG_SONIC_ENCODER) += sonic.o golomb.o + OBJS-$(CONFIG_SONIC_LS_ENCODER) += sonic.o golomb.o + OBJS-$(CONFIG_SP5X_DECODER) += sp5xdec.o mjpegdec.o mjpeg.o ++OBJS-$(CONFIG_SUNRAST_DECODER) += sunrast.o + OBJS-$(CONFIG_SVQ1_DECODER) += svq1dec.o svq1.o h263.o + OBJS-$(CONFIG_SVQ1_ENCODER) += svq1enc.o svq1.o motion_est.o h263.o + OBJS-$(CONFIG_SVQ3_DECODER) += h264.o h264idct.o h264pred.o cabac.o golomb.o +@@ -184,7 +190,8 @@ + OBJS-$(CONFIG_TTA_DECODER) += tta.o + OBJS-$(CONFIG_TXD_DECODER) += txd.o s3tc.o + OBJS-$(CONFIG_ULTI_DECODER) += ulti.o +-OBJS-$(CONFIG_VC1_DECODER) += vc1.o vc1data.o vc1dsp.o msmpeg4data.o ++OBJS-$(CONFIG_VB_DECODER) += vb.o ++OBJS-$(CONFIG_VC1_DECODER) += vc1.o vc1data.o vc1dsp.o msmpeg4data.o intrax8.o intrax8dsp.o + OBJS-$(CONFIG_VCR1_DECODER) += vcr1.o + OBJS-$(CONFIG_VCR1_ENCODER) += vcr1.o + OBJS-$(CONFIG_VMDAUDIO_DECODER) += vmdav.o +@@ -194,18 +201,19 @@ + OBJS-$(CONFIG_VORBIS_ENCODER) += vorbis_enc.o vorbis.o vorbis_data.o mdct.o fft.o + OBJS-$(CONFIG_VP3_DECODER) += vp3.o vp3dsp.o + OBJS-$(CONFIG_VP5_DECODER) += vp5.o vp56.o vp56data.o vp3dsp.o +-OBJS-$(CONFIG_VP6_DECODER) += vp6.o vp56.o vp56data.o vp3dsp.o +-OBJS-$(CONFIG_VP6F_DECODER) += vp6.o vp56.o vp56data.o vp3dsp.o ++OBJS-$(CONFIG_VP6_DECODER) += vp6.o vp56.o vp56data.o vp3dsp.o huffman.o ++OBJS-$(CONFIG_VP6A_DECODER) += vp6.o vp56.o vp56data.o vp3dsp.o huffman.o ++OBJS-$(CONFIG_VP6F_DECODER) += vp6.o vp56.o vp56data.o vp3dsp.o huffman.o + OBJS-$(CONFIG_VQA_DECODER) += vqavideo.o + OBJS-$(CONFIG_WAVPACK_DECODER) += wavpack.o + OBJS-$(CONFIG_WMAV1_DECODER) += wmadec.o wma.o mdct.o fft.o +-OBJS-$(CONFIG_WMAV2_DECODER) += wmadec.o wma.o mdct.o fft.o + OBJS-$(CONFIG_WMAV1_ENCODER) += wmaenc.o wma.o mdct.o fft.o ++OBJS-$(CONFIG_WMAV2_DECODER) += wmadec.o wma.o mdct.o fft.o + OBJS-$(CONFIG_WMAV2_ENCODER) += wmaenc.o wma.o mdct.o fft.o + OBJS-$(CONFIG_WMV1_DECODER) += h263dec.o h263.o + OBJS-$(CONFIG_WMV1_ENCODER) += mpegvideo_enc.o motion_est.o ratecontrol.o h263.o +-OBJS-$(CONFIG_WMV2_DECODER) += msmpeg4.o msmpeg4data.o h263dec.o h263.o +-OBJS-$(CONFIG_WMV2_ENCODER) += msmpeg4.o msmpeg4data.o mpegvideo_enc.o motion_est.o ratecontrol.o h263.o ++OBJS-$(CONFIG_WMV2_DECODER) += wmv2dec.o wmv2.o msmpeg4.o msmpeg4data.o h263dec.o h263.o intrax8.o intrax8dsp.o ++OBJS-$(CONFIG_WMV2_ENCODER) += wmv2enc.o wmv2.o msmpeg4.o msmpeg4data.o mpegvideo_enc.o motion_est.o ratecontrol.o h263.o + OBJS-$(CONFIG_WMV3_DECODER) += vc1.o vc1data.o vc1dsp.o + OBJS-$(CONFIG_WNV1_DECODER) += wnv1.o + OBJS-$(CONFIG_WS_SND1_DECODER) += ws-snd1.o +@@ -219,26 +227,27 @@ + OBJS-$(CONFIG_ZMBV_DECODER) += zmbv.o + OBJS-$(CONFIG_ZMBV_ENCODER) += zmbvenc.o + +-OBJS-$(CONFIG_PCM_S32LE_DECODER) += pcm.o +-OBJS-$(CONFIG_PCM_S32LE_ENCODER) += pcm.o + OBJS-$(CONFIG_PCM_S32BE_DECODER) += pcm.o + OBJS-$(CONFIG_PCM_S32BE_ENCODER) += pcm.o +-OBJS-$(CONFIG_PCM_U32LE_DECODER) += pcm.o +-OBJS-$(CONFIG_PCM_U32LE_ENCODER) += pcm.o ++OBJS-$(CONFIG_PCM_S32LE_DECODER) += pcm.o ++OBJS-$(CONFIG_PCM_S32LE_ENCODER) += pcm.o + OBJS-$(CONFIG_PCM_U32BE_DECODER) += pcm.o + OBJS-$(CONFIG_PCM_U32BE_ENCODER) += pcm.o +-OBJS-$(CONFIG_PCM_S24LE_DECODER) += pcm.o +-OBJS-$(CONFIG_PCM_S24LE_ENCODER) += pcm.o ++OBJS-$(CONFIG_PCM_U32LE_DECODER) += pcm.o ++OBJS-$(CONFIG_PCM_U32LE_ENCODER) += pcm.o + OBJS-$(CONFIG_PCM_S24BE_DECODER) += pcm.o + OBJS-$(CONFIG_PCM_S24BE_ENCODER) += pcm.o +-OBJS-$(CONFIG_PCM_U24LE_DECODER) += pcm.o +-OBJS-$(CONFIG_PCM_U24LE_ENCODER) += pcm.o ++OBJS-$(CONFIG_PCM_S24LE_DECODER) += pcm.o ++OBJS-$(CONFIG_PCM_S24LE_ENCODER) += pcm.o + OBJS-$(CONFIG_PCM_U24BE_DECODER) += pcm.o + OBJS-$(CONFIG_PCM_U24BE_ENCODER) += pcm.o ++OBJS-$(CONFIG_PCM_U24LE_DECODER) += pcm.o ++OBJS-$(CONFIG_PCM_U24LE_ENCODER) += pcm.o + OBJS-$(CONFIG_PCM_S24DAUD_DECODER) += pcm.o + OBJS-$(CONFIG_PCM_S24DAUD_ENCODER) += pcm.o + OBJS-$(CONFIG_PCM_S16LE_DECODER) += pcm.o + OBJS-$(CONFIG_PCM_S16LE_ENCODER) += pcm.o ++OBJS-$(CONFIG_PCM_S16LE_PLANAR_DECODER)+= pcm.o + OBJS-$(CONFIG_PCM_S16BE_DECODER) += pcm.o + OBJS-$(CONFIG_PCM_S16BE_ENCODER) += pcm.o + OBJS-$(CONFIG_PCM_U16LE_DECODER) += pcm.o +@@ -253,49 +262,50 @@ + OBJS-$(CONFIG_PCM_ALAW_ENCODER) += pcm.o + OBJS-$(CONFIG_PCM_MULAW_DECODER) += pcm.o + OBJS-$(CONFIG_PCM_MULAW_ENCODER) += pcm.o ++OBJS-$(CONFIG_PCM_ZORK_DECODER) += pcm.o ++OBJS-$(CONFIG_PCM_ZORK_ENCODER) += pcm.o + + OBJS-$(CONFIG_ADPCM_4XM_DECODER) += adpcm.o +-OBJS-$(CONFIG_ADPCM_4XM_ENCODER) += adpcm.o +-OBJS-$(CONFIG_ADPCM_ADX_DECODER) += adx.o +-OBJS-$(CONFIG_ADPCM_ADX_ENCODER) += adx.o ++OBJS-$(CONFIG_ADPCM_ADX_DECODER) += adxdec.o ++OBJS-$(CONFIG_ADPCM_ADX_ENCODER) += adxenc.o + OBJS-$(CONFIG_ADPCM_CT_DECODER) += adpcm.o +-OBJS-$(CONFIG_ADPCM_CT_ENCODER) += adpcm.o + OBJS-$(CONFIG_ADPCM_EA_DECODER) += adpcm.o +-OBJS-$(CONFIG_ADPCM_EA_ENCODER) += adpcm.o ++OBJS-$(CONFIG_ADPCM_EA_R1_DECODER) += adpcm.o ++OBJS-$(CONFIG_ADPCM_EA_R2_DECODER) += adpcm.o ++OBJS-$(CONFIG_ADPCM_EA_R3_DECODER) += adpcm.o ++OBJS-$(CONFIG_ADPCM_EA_XAS_DECODER) += adpcm.o + OBJS-$(CONFIG_ADPCM_G726_DECODER) += g726.o + OBJS-$(CONFIG_ADPCM_G726_ENCODER) += g726.o + OBJS-$(CONFIG_ADPCM_IMA_AMV_DECODER) += adpcm.o + OBJS-$(CONFIG_ADPCM_IMA_DK3_DECODER) += adpcm.o +-OBJS-$(CONFIG_ADPCM_IMA_DK3_ENCODER) += adpcm.o + OBJS-$(CONFIG_ADPCM_IMA_DK4_DECODER) += adpcm.o +-OBJS-$(CONFIG_ADPCM_IMA_DK4_ENCODER) += adpcm.o ++OBJS-$(CONFIG_ADPCM_IMA_EA_EACS_DECODER) += adpcm.o ++OBJS-$(CONFIG_ADPCM_IMA_EA_SEAD_DECODER) += adpcm.o + OBJS-$(CONFIG_ADPCM_IMA_QT_DECODER) += adpcm.o +-OBJS-$(CONFIG_ADPCM_IMA_QT_ENCODER) += adpcm.o + OBJS-$(CONFIG_ADPCM_IMA_SMJPEG_DECODER) += adpcm.o +-OBJS-$(CONFIG_ADPCM_IMA_SMJPEG_ENCODER) += adpcm.o + OBJS-$(CONFIG_ADPCM_IMA_WAV_DECODER) += adpcm.o + OBJS-$(CONFIG_ADPCM_IMA_WAV_ENCODER) += adpcm.o + OBJS-$(CONFIG_ADPCM_IMA_WS_DECODER) += adpcm.o +-OBJS-$(CONFIG_ADPCM_IMA_WS_ENCODER) += adpcm.o + OBJS-$(CONFIG_ADPCM_MS_DECODER) += adpcm.o + OBJS-$(CONFIG_ADPCM_MS_ENCODER) += adpcm.o + OBJS-$(CONFIG_ADPCM_SBPRO_2_DECODER) += adpcm.o +-OBJS-$(CONFIG_ADPCM_SBPRO_2_ENCODER) += adpcm.o + OBJS-$(CONFIG_ADPCM_SBPRO_3_DECODER) += adpcm.o +-OBJS-$(CONFIG_ADPCM_SBPRO_3_ENCODER) += adpcm.o + OBJS-$(CONFIG_ADPCM_SBPRO_4_DECODER) += adpcm.o +-OBJS-$(CONFIG_ADPCM_SBPRO_4_ENCODER) += adpcm.o + OBJS-$(CONFIG_ADPCM_SWF_DECODER) += adpcm.o + OBJS-$(CONFIG_ADPCM_SWF_ENCODER) += adpcm.o + OBJS-$(CONFIG_ADPCM_THP_DECODER) += adpcm.o + OBJS-$(CONFIG_ADPCM_XA_DECODER) += adpcm.o +-OBJS-$(CONFIG_ADPCM_XA_ENCODER) += adpcm.o + OBJS-$(CONFIG_ADPCM_YAMAHA_DECODER) += adpcm.o + OBJS-$(CONFIG_ADPCM_YAMAHA_ENCODER) += adpcm.o + ++# libavformat dependencies ++OBJS-$(CONFIG_MATROSKA_MUXER) += xiph.o ++OBJS-$(CONFIG_OGG_MUXER) += xiph.o ++ + # external codec libraries + OBJS-$(CONFIG_LIBA52) += liba52.o +-OBJS-$(CONFIG_LIBAMR) += libamr.o ++OBJS-$(CONFIG_LIBAMR_NB) += libamr.o ++OBJS-$(CONFIG_LIBAMR_WB) += libamr.o + OBJS-$(CONFIG_LIBFAAC) += libfaac.o + OBJS-$(CONFIG_LIBFAAD) += libfaad.o + OBJS-$(CONFIG_LIBGSM) += libgsm.o +@@ -316,6 +326,7 @@ + OBJS-$(CONFIG_H263_PARSER) += h263_parser.o + OBJS-$(CONFIG_H264_PARSER) += h264_parser.o + OBJS-$(CONFIG_MJPEG_PARSER) += mjpeg_parser.o ++OBJS-$(CONFIG_MLP_PARSER) += mlp_parser.o + OBJS-$(CONFIG_MPEG4VIDEO_PARSER) += mpeg4video_parser.o h263.o + OBJS-$(CONFIG_MPEGAUDIO_PARSER) += mpegaudio_parser.o mpegaudiodecheader.o mpegaudiodata.o + OBJS-$(CONFIG_MPEGVIDEO_PARSER) += mpegvideo_parser.o +@@ -326,10 +337,12 @@ + OBJS-$(CONFIG_H264_MP4TOANNEXB_BSF) += h264_mp4toannexb_bsf.o + OBJS-$(CONFIG_IMX_DUMP_HEADER_BSF) += imx_dump_header_bsf.o + OBJS-$(CONFIG_MJPEGA_DUMP_HEADER_BSF) += mjpega_dump_header_bsf.o ++OBJS-$(CONFIG_MOV2TEXTSUB_BSF) += movsub_bsf.o + OBJS-$(CONFIG_MP3_HEADER_COMPRESS_BSF) += mp3_header_compress_bsf.o + OBJS-$(CONFIG_MP3_HEADER_DECOMPRESS_BSF) += mp3_header_decompress_bsf.o mpegaudiodata.o + OBJS-$(CONFIG_NOISE_BSF) += noise_bsf.o + OBJS-$(CONFIG_REMOVE_EXTRADATA_BSF) += remove_extradata_bsf.o ++OBJS-$(CONFIG_TEXT2MOVSUB_BSF) += movsub_bsf.o + + OBJS-$(HAVE_BEOSTHREADS) += beosthread.o + OBJS-$(HAVE_OS2THREADS) += os2thread.o +@@ -338,9 +351,7 @@ + + OBJS-$(HAVE_XVMC_ACCEL) += xvmcvideo.o + +-ifneq ($(CONFIG_SWSCALER),yes) + OBJS += imgresample.o +-endif + + # processor-specific code + ifeq ($(HAVE_MMX),yes) +@@ -358,11 +369,15 @@ + OBJS-$(CONFIG_GPL) += i386/idct_mmx.o + + OBJS-$(CONFIG_CAVS_DECODER) += i386/cavsdsp_mmx.o ++OBJS-$(CONFIG_FLAC_ENCODER) += i386/flacdsp_mmx.o + OBJS-$(CONFIG_SNOW_DECODER) += i386/snowdsp_mmx.o ++OBJS-$(CONFIG_VC1_DECODER) += i386/vc1dsp_mmx.o + OBJS-$(CONFIG_VP3_DECODER) += i386/vp3dsp_mmx.o i386/vp3dsp_sse2.o + OBJS-$(CONFIG_VP5_DECODER) += i386/vp3dsp_mmx.o i386/vp3dsp_sse2.o + OBJS-$(CONFIG_VP6_DECODER) += i386/vp3dsp_mmx.o i386/vp3dsp_sse2.o ++OBJS-$(CONFIG_VP6A_DECODER) += i386/vp3dsp_mmx.o i386/vp3dsp_sse2.o + OBJS-$(CONFIG_VP6F_DECODER) += i386/vp3dsp_mmx.o i386/vp3dsp_sse2.o ++OBJS-$(CONFIG_WMV3_DECODER) += i386/vc1dsp_mmx.o + endif + + ASM_OBJS-$(ARCH_ARMV4L) += armv4l/jrevdct_arm.o \ +@@ -439,6 +454,11 @@ + LIBVERSION=$(LAVCVERSION) + LIBMAJOR=$(LAVCMAJOR) + ++TESTS = $(addsuffix -test$(EXESUF), cabac dct eval fft h264 imgresample rangecoder snow) ++ifeq ($(ARCH_X86),yes) ++TESTS += cpuid-test$(EXESUF) motion-test$(EXESUF) ++endif ++ + include ../common.mak + + clean:: +@@ -452,27 +472,10 @@ + ps2/*.o ps2/*~ \ + sh4/*.o sh4/*~ \ + sparc/*.o sparc/*~ \ +- apiexample $(TESTS) +- +-TESTS= imgresample-test fft-test dct-test +-ifeq ($(ARCH_X86),yes) +-TESTS+= cpuid-test motion-test +-endif +- +-tests: apiexample $(TESTS) +- +-apiexample: apiexample.o $(LIB) +- +-cpuid-test: i386/cputest.c +- $(CC) $(CFLAGS) -DTEST -o $@ $< +- +-dct-test: dct-test.o fdctref.o $(LIB) +- +-fft-test: fft-test.o $(LIB) +- +-imgresample-test: imgresample.c $(LIB) +- $(CC) $(CFLAGS) -DTEST -o $@ $^ $(EXTRALIBS) +- +-motion-test: motion-test.o $(LIB) ++ apiexample$(EXESUF) + +-.PHONY: tests ++cpuid-test$(EXESUF): i386/cputest.c ++apiexample$(EXESUF): apiexample.o $(LIBNAME) ++dct-test$(EXESUF): dct-test.o fdctref.o $(LIBNAME) ++fft-test$(EXESUF): fft-test.o $(LIBNAME) ++motion-test$(EXESUF): motion-test.o $(LIBNAME) +diff -u mplayer-1.0~rc2-12/libavcodec/mathops.h ffmpeg-free-0.svn20080206/libavcodec/mathops.h +--- mplayer-1.0~rc2-12/libavcodec/mathops.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/mathops.h 2007-10-17 11:37:46.000000000 +0200 +@@ -19,8 +19,8 @@ + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +-#ifndef MATHOPS_H +-#define MATHOPS_H ++#ifndef FFMPEG_MATHOPS_H ++#define FFMPEG_MATHOPS_H + + #include "common.h" + +@@ -71,5 +71,5 @@ + # define MUL16(ra, rb) ((ra) * (rb)) + #endif + +-#endif //MATHOPS_H ++#endif /* FFMPEG_MATHOPS_H */ + +diff -u mplayer-1.0~rc2-12/libavcodec/mdct.c ffmpeg-free-0.svn20080206/libavcodec/mdct.c +--- mplayer-1.0~rc2-12/libavcodec/mdct.c 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/mdct.c 2008-03-20 19:10:58.000000000 +0100 +@@ -25,6 +25,29 @@ + * MDCT/IMDCT transforms. + */ + ++// Generate a Kaiser-Bessel Derived Window. ++#define BESSEL_I0_ITER 50 // default: 50 iterations of Bessel I0 approximation ++void ff_kbd_window_init(float *window, float alpha, int n) ++{ ++ int i, j; ++ double sum = 0.0, bessel, tmp; ++ double local_window[n]; ++ double alpha2 = (alpha * M_PI / n) * (alpha * M_PI / n); ++ ++ for (i = 0; i < n; i++) { ++ tmp = i * (n - i) * alpha2; ++ bessel = 1.0; ++ for (j = BESSEL_I0_ITER; j > 0; j--) ++ bessel = bessel * tmp / (j * j) + 1; ++ sum += bessel; ++ local_window[i] = sum; ++ } ++ ++ sum++; ++ for (i = 0; i < n; i++) ++ window[i] = sqrt(local_window[i] / sum); ++} ++ + /** + * init MDCT or IMDCT computation. + */ +diff -u mplayer-1.0~rc2-12/libavcodec/mdec.c ffmpeg-free-0.svn20080206/libavcodec/mdec.c +--- mplayer-1.0~rc2-12/libavcodec/mdec.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/mdec.c 2008-03-20 19:10:58.000000000 +0100 +@@ -158,7 +158,7 @@ + + static int decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + MDECContext * const a = avctx->priv_data; + AVFrame *picture = data; +@@ -175,9 +175,6 @@ + } + p->pict_type= I_TYPE; + p->key_frame= 1; +- a->last_dc[0]= +- a->last_dc[1]= +- a->last_dc[2]= 0; + + a->bitstream_buffer= av_fast_realloc(a->bitstream_buffer, &a->bitstream_buffer_size, buf_size + FF_INPUT_BUFFER_PADDING_SIZE); + for(i=0; iqscale= get_bits(&a->gb, 16); + a->version= get_bits(&a->gb, 16); + ++ a->last_dc[0]= ++ a->last_dc[1]= ++ a->last_dc[2]= 128; ++ + // printf("qscale:%d (0x%X), version:%d (0x%X)\n", a->qscale, a->qscale, a->version, a->version); + + for(a->mb_x=0; a->mb_xmb_width; a->mb_x++){ +diff -u mplayer-1.0~rc2-12/libavcodec/mjpegbdec.c ffmpeg-free-0.svn20080206/libavcodec/mjpegbdec.c +--- mplayer-1.0~rc2-12/libavcodec/mjpegbdec.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/mjpegbdec.c 2008-03-20 19:10:58.000000000 +0100 +@@ -31,10 +31,10 @@ + + static int mjpegb_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + MJpegDecodeContext *s = avctx->priv_data; +- uint8_t *buf_end, *buf_ptr; ++ const uint8_t *buf_end, *buf_ptr; + AVFrame *picture = data; + GetBitContext hgb; /* for the header */ + uint32_t dqt_offs, dht_offs, sof_offs, sos_offs, second_field_offs; +@@ -109,7 +109,7 @@ + if (s->interlaced) { + s->bottom_field ^= 1; + /* if not bottom field, do not output image yet */ +- if (s->bottom_field && second_field_offs) ++ if (s->bottom_field != s->interlace_polarity && second_field_offs) + { + buf_ptr = buf + second_field_offs; + second_field_offs = 0; +diff -u mplayer-1.0~rc2-12/libavcodec/mjpegdec.c ffmpeg-free-0.svn20080206/libavcodec/mjpegdec.c +--- mplayer-1.0~rc2-12/libavcodec/mjpegdec.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/mjpegdec.c 2008-03-20 19:10:58.000000000 +0100 +@@ -671,7 +671,8 @@ + linesize[c]=s->linesize[c]; + if(s->avctx->codec->id==CODEC_ID_AMV) { + //picture should be flipped upside-down for this codec +- data[c] += (linesize[c] * (s->v_scount[i] * 8 * s->mb_height - 1)); ++ assert(!(s->avctx->flags & CODEC_FLAG_EMU_EDGE)); ++ data[c] += (linesize[c] * (s->v_scount[i] * (8 * s->mb_height -((s->height/s->v_max)&7)) - 1 )); + linesize[c] *= -1; + } + } +@@ -1072,9 +1073,9 @@ + + /* return the 8 bit start code value and update the search + state. Return -1 if no start code found */ +-static int find_marker(uint8_t **pbuf_ptr, uint8_t *buf_end) ++static int find_marker(const uint8_t **pbuf_ptr, const uint8_t *buf_end) + { +- uint8_t *buf_ptr; ++ const uint8_t *buf_ptr; + unsigned int v, v2; + int val; + #ifdef DEBUG +@@ -1104,10 +1105,10 @@ + + int ff_mjpeg_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + MJpegDecodeContext *s = avctx->priv_data; +- uint8_t *buf_end, *buf_ptr; ++ const uint8_t *buf_end, *buf_ptr; + int start_code; + AVFrame *picture = data; + +@@ -1135,7 +1136,7 @@ + /* unescape buffer of SOS, use special treatment for JPEG-LS */ + if (start_code == SOS && !s->ls) + { +- uint8_t *src = buf_ptr; ++ const uint8_t *src = buf_ptr; + uint8_t *dst = s->buffer; + + while (srcbuffer)); + } + else if(start_code == SOS && s->ls){ +- uint8_t *src = buf_ptr; ++ const uint8_t *src = buf_ptr; + uint8_t *dst = s->buffer; + int bit_count = 0; + int t = 0, b = 0; +diff -u mplayer-1.0~rc2-12/libavcodec/mjpegdec.h ffmpeg-free-0.svn20080206/libavcodec/mjpegdec.h +--- mplayer-1.0~rc2-12/libavcodec/mjpegdec.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/mjpegdec.h 2008-02-01 04:40:46.000000000 +0100 +@@ -26,8 +26,8 @@ + * MJPEG decoder. + */ + +-#ifndef MJPEGDEC_H +-#define MJPEGDEC_H ++#ifndef FFMPEG_MJPEGDEC_H ++#define FFMPEG_MJPEGDEC_H + + #include "avcodec.h" + #include "bitstream.h" +@@ -103,10 +103,10 @@ + int ff_mjpeg_decode_end(AVCodecContext *avctx); + int ff_mjpeg_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size); ++ const uint8_t *buf, int buf_size); + int ff_mjpeg_decode_dqt(MJpegDecodeContext *s); + int ff_mjpeg_decode_dht(MJpegDecodeContext *s); + int ff_mjpeg_decode_sof(MJpegDecodeContext *s); + int ff_mjpeg_decode_sos(MJpegDecodeContext *s); + +-#endif /* MJPEGDEC_H */ ++#endif /* FFMPEG_MJPEGDEC_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/mjpegenc.h ffmpeg-free-0.svn20080206/libavcodec/mjpegenc.h +--- mplayer-1.0~rc2-12/libavcodec/mjpegenc.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/mjpegenc.h 2007-10-17 11:37:46.000000000 +0200 +@@ -30,8 +30,8 @@ + * MJPEG encoder. + */ + +-#ifndef MJPEGENC_H +-#define MJPEGENC_H ++#ifndef FFMPEG_MJPEGENC_H ++#define FFMPEG_MJPEGENC_H + + #include "dsputil.h" + #include "mpegvideo.h" +@@ -57,4 +57,4 @@ + uint8_t *huff_size, uint16_t *huff_code); + void ff_mjpeg_encode_mb(MpegEncContext *s, DCTELEM block[6][64]); + +-#endif /* MJPEGENC_H */ ++#endif /* FFMPEG_MJPEGENC_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/mjpeg.h ffmpeg-free-0.svn20080206/libavcodec/mjpeg.h +--- mplayer-1.0~rc2-12/libavcodec/mjpeg.h 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/mjpeg.h 2007-10-17 11:37:46.000000000 +0200 +@@ -30,8 +30,8 @@ + * MJPEG encoder and decoder. + */ + +-#ifndef MJPEG_H +-#define MJPEG_H ++#ifndef FFMPEG_MJPEG_H ++#define FFMPEG_MJPEG_H + + #include "avcodec.h" + #include "bitstream.h" +@@ -153,4 +153,4 @@ + const uint8_t *bits_table, + const uint8_t *val_table); + +-#endif /* MJPEG_H */ ++#endif /* FFMPEG_MJPEG_H */ +Common subdirectories: mplayer-1.0~rc2-12/libavcodec/mlib and ffmpeg-free-0.svn20080206/libavcodec/mlib +Only in ffmpeg-free-0.svn20080206/libavcodec: mlp_parser.c +Only in ffmpeg-free-0.svn20080206/libavcodec: mlp_parser.h +diff -u mplayer-1.0~rc2-12/libavcodec/mmvideo.c ffmpeg-free-0.svn20080206/libavcodec/mmvideo.c +--- mplayer-1.0~rc2-12/libavcodec/mmvideo.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/mmvideo.c 2008-03-20 19:10:58.000000000 +0100 +@@ -150,7 +150,7 @@ + + static int mm_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + MmContext *s = avctx->priv_data; + AVPaletteControl *palette_control = avctx->palctrl; +diff -u mplayer-1.0~rc2-12/libavcodec/motion-test.c ffmpeg-free-0.svn20080206/libavcodec/motion-test.c +--- mplayer-1.0~rc2-12/libavcodec/motion-test.c 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/motion-test.c 2008-03-20 19:10:58.000000000 +0100 +@@ -112,7 +112,7 @@ + } + } + emms_c(); +- dummy = d1; /* avoid optimisation */ ++ dummy = d1; /* avoid optimization */ + ti = gettime() - ti; + + printf(" %0.0f kop/s\n", +Only in ffmpeg-free-0.svn20080206/libavcodec: movsub_bsf.c +Only in ffmpeg-free-0.svn20080206/libavcodec: mpc7.c +Only in ffmpeg-free-0.svn20080206/libavcodec: mpc7data.h +Only in ffmpeg-free-0.svn20080206/libavcodec: mpc8.c +Only in ffmpeg-free-0.svn20080206/libavcodec: mpc8data.h +Only in ffmpeg-free-0.svn20080206/libavcodec: mpc8huff.h +diff -u mplayer-1.0~rc2-12/libavcodec/mpc.c ffmpeg-free-0.svn20080206/libavcodec/mpc.c +--- mplayer-1.0~rc2-12/libavcodec/mpc.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/mpc.c 2008-03-20 19:10:58.000000000 +0100 +@@ -1,5 +1,5 @@ + /* +- * Musepack decoder ++ * Musepack decoder core + * Copyright (c) 2006 Konstantin Shishkov + * + * This file is part of FFmpeg. +@@ -20,7 +20,7 @@ + */ + + /** +- * @file mpc.c Musepack decoder ++ * @file mpc.c Musepack decoder core + * MPEG Audio Layer 1/2 -like codec with frames of 1152 samples + * divided into 32 subbands. + */ +@@ -35,108 +35,18 @@ + #endif + #include "mpegaudio.h" + ++#include "mpc.h" + #include "mpcdata.h" + +-#define BANDS 32 +-#define SAMPLES_PER_BAND 36 +-#define MPC_FRAME_SIZE (BANDS * SAMPLES_PER_BAND) +- +-static VLC scfi_vlc, dscf_vlc, hdr_vlc, quant_vlc[MPC7_QUANT_VLC_TABLES][2]; +- + static DECLARE_ALIGNED_16(MPA_INT, mpa_window[512]); + +-typedef struct { +- DSPContext dsp; +- int IS, MSS, gapless; +- int lastframelen, bands; +- int oldDSCF[2][BANDS]; +- AVRandomState rnd; +- int frames_to_skip; +- /* for synthesis */ +- DECLARE_ALIGNED_16(MPA_INT, synth_buf[MPA_MAX_CHANNELS][512*2]); +- int synth_buf_offset[MPA_MAX_CHANNELS]; +- DECLARE_ALIGNED_16(int32_t, sb_samples[MPA_MAX_CHANNELS][36][SBLIMIT]); +-} MPCContext; +- +-/** Subband structure - hold all variables for each subband */ +-typedef struct { +- int msf; ///< mid-stereo flag +- int res[2]; +- int scfi[2]; +- int scf_idx[2][3]; +- int Q[2]; +-}Band; +- +-static int mpc7_decode_init(AVCodecContext * avctx) ++void ff_mpc_init() + { +- int i, j; +- MPCContext *c = avctx->priv_data; +- GetBitContext gb; +- uint8_t buf[16]; +- static int vlc_inited = 0; +- +- if(avctx->extradata_size < 16){ +- av_log(avctx, AV_LOG_ERROR, "Too small extradata size (%i)!\n", avctx->extradata_size); +- return -1; +- } +- memset(c->oldDSCF, 0, sizeof(c->oldDSCF)); +- av_init_random(0xDEADBEEF, &c->rnd); +- dsputil_init(&c->dsp, avctx); +- c->dsp.bswap_buf(buf, avctx->extradata, 4); + ff_mpa_synth_init(mpa_window); +- init_get_bits(&gb, buf, 128); +- +- c->IS = get_bits1(&gb); +- c->MSS = get_bits1(&gb); +- c->bands = get_bits(&gb, 6); +- if(c->bands >= BANDS){ +- av_log(avctx, AV_LOG_ERROR, "Too many bands: %i\n", c->bands); +- return -1; +- } +- skip_bits(&gb, 88); +- c->gapless = get_bits1(&gb); +- c->lastframelen = get_bits(&gb, 11); +- av_log(avctx, AV_LOG_DEBUG, "IS: %d, MSS: %d, TG: %d, LFL: %d, bands: %d\n", +- c->IS, c->MSS, c->gapless, c->lastframelen, c->bands); +- c->frames_to_skip = 0; +- +- if(vlc_inited) return 0; +- av_log(avctx, AV_LOG_DEBUG, "Initing VLC\n"); +- if(init_vlc(&scfi_vlc, MPC7_SCFI_BITS, MPC7_SCFI_SIZE, +- &mpc7_scfi[1], 2, 1, +- &mpc7_scfi[0], 2, 1, INIT_VLC_USE_STATIC)){ +- av_log(avctx, AV_LOG_ERROR, "Cannot init SCFI VLC\n"); +- return -1; +- } +- if(init_vlc(&dscf_vlc, MPC7_DSCF_BITS, MPC7_DSCF_SIZE, +- &mpc7_dscf[1], 2, 1, +- &mpc7_dscf[0], 2, 1, INIT_VLC_USE_STATIC)){ +- av_log(avctx, AV_LOG_ERROR, "Cannot init DSCF VLC\n"); +- return -1; +- } +- if(init_vlc(&hdr_vlc, MPC7_HDR_BITS, MPC7_HDR_SIZE, +- &mpc7_hdr[1], 2, 1, +- &mpc7_hdr[0], 2, 1, INIT_VLC_USE_STATIC)){ +- av_log(avctx, AV_LOG_ERROR, "Cannot init HDR VLC\n"); +- return -1; +- } +- for(i = 0; i < MPC7_QUANT_VLC_TABLES; i++){ +- for(j = 0; j < 2; j++){ +- if(init_vlc(&quant_vlc[i][j], 9, mpc7_quant_vlc_sizes[i], +- &mpc7_quant_vlc[i][j][1], 4, 2, +- &mpc7_quant_vlc[i][j][0], 4, 2, INIT_VLC_USE_STATIC)){ +- av_log(avctx, AV_LOG_ERROR, "Cannot init QUANT VLC %i,%i\n",i,j); +- return -1; +- } +- } +- } +- vlc_inited = 1; +- return 0; + } + + /** + * Process decoded Musepack data and produce PCM +- * @todo make it available for MPC8 and MPC6 + */ + static void mpc_synth(MPCContext *c, int16_t *out) + { +@@ -158,147 +68,29 @@ + *out++=samples[i]; + } + +-/** +- * Fill samples for given subband +- */ +-static inline void idx_to_quant(MPCContext *c, GetBitContext *gb, int idx, int *dst) ++void ff_mpc_dequantize_and_synth(MPCContext * c, int maxband, void *data) + { +- int i, i1, t; +- switch(idx){ +- case -1: +- for(i = 0; i < SAMPLES_PER_BAND; i++){ +- *dst++ = (av_random(&c->rnd) & 0x3FC) - 510; +- } +- break; +- case 1: +- i1 = get_bits1(gb); +- for(i = 0; i < SAMPLES_PER_BAND/3; i++){ +- t = get_vlc2(gb, quant_vlc[0][i1].table, 9, 2); +- *dst++ = mpc_idx30[t]; +- *dst++ = mpc_idx31[t]; +- *dst++ = mpc_idx32[t]; +- } +- break; +- case 2: +- i1 = get_bits1(gb); +- for(i = 0; i < SAMPLES_PER_BAND/2; i++){ +- t = get_vlc2(gb, quant_vlc[1][i1].table, 9, 2); +- *dst++ = mpc_idx50[t]; +- *dst++ = mpc_idx51[t]; +- } +- break; +- case 3: case 4: case 5: case 6: case 7: +- i1 = get_bits1(gb); +- for(i = 0; i < SAMPLES_PER_BAND; i++) +- *dst++ = get_vlc2(gb, quant_vlc[idx-1][i1].table, 9, 2) - mpc7_quant_vlc_off[idx-1]; +- break; +- case 8: case 9: case 10: case 11: case 12: +- case 13: case 14: case 15: case 16: case 17: +- t = (1 << (idx - 2)) - 1; +- for(i = 0; i < SAMPLES_PER_BAND; i++) +- *dst++ = get_bits(gb, idx - 1) - t; +- break; +- default: // case 0 and -2..-17 +- return; +- } +-} +- +-static int mpc7_decode_frame(AVCodecContext * avctx, +- void *data, int *data_size, +- uint8_t * buf, int buf_size) +-{ +- MPCContext *c = avctx->priv_data; +- GetBitContext gb; +- uint8_t *bits; +- int i, j, ch, t; +- int mb = -1; +- Band bands[BANDS]; +- int Q[2][MPC_FRAME_SIZE]; ++ int i, j, ch; ++ Band *bands = c->bands; + int off; + float mul; +- int bits_used, bits_avail; +- +- memset(bands, 0, sizeof(bands)); +- if(buf_size <= 4){ +- av_log(avctx, AV_LOG_ERROR, "Too small buffer passed (%i bytes)\n", buf_size); +- } + +- bits = av_malloc(((buf_size - 1) & ~3) + FF_INPUT_BUFFER_PADDING_SIZE); +- c->dsp.bswap_buf(bits, buf + 4, (buf_size - 4) >> 2); +- init_get_bits(&gb, bits, (buf_size - 4)* 8); +- skip_bits(&gb, buf[0]); +- +- /* read subband indexes */ +- for(i = 0; i <= c->bands; i++){ +- for(ch = 0; ch < 2; ch++){ +- if(i) t = get_vlc2(&gb, hdr_vlc.table, MPC7_HDR_BITS, 1) - 5; +- if(!i || (t == 4)) bands[i].res[ch] = get_bits(&gb, 4); +- else bands[i].res[ch] = bands[i-1].res[ch] + t; +- } +- +- if(bands[i].res[0] || bands[i].res[1]){ +- mb = i; +- if(c->MSS) bands[i].msf = get_bits1(&gb); +- } +- } +- /* get scale indexes coding method */ +- for(i = 0; i <= mb; i++) +- for(ch = 0; ch < 2; ch++) +- if(bands[i].res[ch]) bands[i].scfi[ch] = get_vlc2(&gb, scfi_vlc.table, MPC7_SCFI_BITS, 1); +- /* get scale indexes */ +- for(i = 0; i <= mb; i++){ +- for(ch = 0; ch < 2; ch++){ +- if(bands[i].res[ch]){ +- bands[i].scf_idx[ch][2] = c->oldDSCF[ch][i]; +- t = get_vlc2(&gb, dscf_vlc.table, MPC7_DSCF_BITS, 1) - 7; +- bands[i].scf_idx[ch][0] = (t == 8) ? get_bits(&gb, 6) : (bands[i].scf_idx[ch][2] + t); +- switch(bands[i].scfi[ch]){ +- case 0: +- t = get_vlc2(&gb, dscf_vlc.table, MPC7_DSCF_BITS, 1) - 7; +- bands[i].scf_idx[ch][1] = (t == 8) ? get_bits(&gb, 6) : (bands[i].scf_idx[ch][0] + t); +- t = get_vlc2(&gb, dscf_vlc.table, MPC7_DSCF_BITS, 1) - 7; +- bands[i].scf_idx[ch][2] = (t == 8) ? get_bits(&gb, 6) : (bands[i].scf_idx[ch][1] + t); +- break; +- case 1: +- t = get_vlc2(&gb, dscf_vlc.table, MPC7_DSCF_BITS, 1) - 7; +- bands[i].scf_idx[ch][1] = (t == 8) ? get_bits(&gb, 6) : (bands[i].scf_idx[ch][0] + t); +- bands[i].scf_idx[ch][2] = bands[i].scf_idx[ch][1]; +- break; +- case 2: +- bands[i].scf_idx[ch][1] = bands[i].scf_idx[ch][0]; +- t = get_vlc2(&gb, dscf_vlc.table, MPC7_DSCF_BITS, 1) - 7; +- bands[i].scf_idx[ch][2] = (t == 8) ? get_bits(&gb, 6) : (bands[i].scf_idx[ch][1] + t); +- break; +- case 3: +- bands[i].scf_idx[ch][2] = bands[i].scf_idx[ch][1] = bands[i].scf_idx[ch][0]; +- break; +- } +- c->oldDSCF[ch][i] = bands[i].scf_idx[ch][2]; +- } +- } +- } +- /* get quantizers */ +- memset(Q, 0, sizeof(Q)); +- off = 0; +- for(i = 0; i < BANDS; i++, off += SAMPLES_PER_BAND) +- for(ch = 0; ch < 2; ch++) +- idx_to_quant(c, &gb, bands[i].res[ch], Q[ch] + off); + /* dequantize */ + memset(c->sb_samples, 0, sizeof(c->sb_samples)); + off = 0; +- for(i = 0; i <= mb; i++, off += SAMPLES_PER_BAND){ ++ for(i = 0; i <= maxband; i++, off += SAMPLES_PER_BAND){ + for(ch = 0; ch < 2; ch++){ + if(bands[i].res[ch]){ + j = 0; +- mul = mpc_CC[bands[i].res[ch]] * mpc7_SCF[bands[i].scf_idx[ch][0]]; ++ mul = mpc_CC[bands[i].res[ch]] * mpc_SCF[bands[i].scf_idx[ch][0]]; + for(; j < 12; j++) +- c->sb_samples[ch][j][i] = mul * Q[ch][j + off]; +- mul = mpc_CC[bands[i].res[ch]] * mpc7_SCF[bands[i].scf_idx[ch][1]]; ++ c->sb_samples[ch][j][i] = mul * c->Q[ch][j + off]; ++ mul = mpc_CC[bands[i].res[ch]] * mpc_SCF[bands[i].scf_idx[ch][1]]; + for(; j < 24; j++) +- c->sb_samples[ch][j][i] = mul * Q[ch][j + off]; +- mul = mpc_CC[bands[i].res[ch]] * mpc7_SCF[bands[i].scf_idx[ch][2]]; ++ c->sb_samples[ch][j][i] = mul * c->Q[ch][j + off]; ++ mul = mpc_CC[bands[i].res[ch]] * mpc_SCF[bands[i].scf_idx[ch][2]]; + for(; j < 36; j++) +- c->sb_samples[ch][j][i] = mul * Q[ch][j + off]; ++ c->sb_samples[ch][j][i] = mul * c->Q[ch][j + off]; + } + } + if(bands[i].msf){ +@@ -313,41 +105,4 @@ + } + + mpc_synth(c, data); +- +- av_free(bits); +- +- bits_used = get_bits_count(&gb); +- bits_avail = (buf_size - 4) * 8; +- if(!buf[1] && ((bits_avail < bits_used) || (bits_used + 32 <= bits_avail))){ +- av_log(NULL,0, "Error decoding frame: used %i of %i bits\n", bits_used, bits_avail); +- return -1; +- } +- if(c->frames_to_skip){ +- c->frames_to_skip--; +- *data_size = 0; +- return buf_size; +- } +- *data_size = (buf[1] ? c->lastframelen : MPC_FRAME_SIZE) * 4; +- +- return buf_size; + } +- +-static void mpc7_decode_flush(AVCodecContext *avctx) +-{ +- MPCContext *c = avctx->priv_data; +- +- memset(c->oldDSCF, 0, sizeof(c->oldDSCF)); +- c->frames_to_skip = 32; +-} +- +-AVCodec mpc7_decoder = { +- "mpc sv7", +- CODEC_TYPE_AUDIO, +- CODEC_ID_MUSEPACK7, +- sizeof(MPCContext), +- mpc7_decode_init, +- NULL, +- NULL, +- mpc7_decode_frame, +- .flush = mpc7_decode_flush, +-}; +diff -u mplayer-1.0~rc2-12/libavcodec/mpcdata.h ffmpeg-free-0.svn20080206/libavcodec/mpcdata.h +--- mplayer-1.0~rc2-12/libavcodec/mpcdata.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/mpcdata.h 2007-11-02 07:40:42.000000000 +0100 +@@ -19,162 +19,18 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef AVCODEC_MPCDATA_H +-#define AVCODEC_MPCDATA_H ++#ifndef FFMPEG_MPCDATA_H ++#define FFMPEG_MPCDATA_H + + #include + +-static const int8_t mpc_idx30[] = { -1, 0, 1,-1, 0, 1,-1, 0, 1,-1, 0, 1,-1, 0, 1,-1, 0, 1,-1, 0, 1,-1, 0, 1,-1, 0, 1}; +-static const int8_t mpc_idx31[] = { -1,-1,-1, 0, 0, 0, 1, 1, 1,-1,-1,-1, 0, 0, 0, 1, 1, 1,-1,-1,-1, 0, 0, 0, 1, 1, 1}; +-static const int8_t mpc_idx32[] = { -1,-1,-1,-1,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1}; +-static const int8_t mpc_idx50[] = { -2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2}; +-static const int8_t mpc_idx51[] = { -2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2}; +- + static const float mpc_CC[18] = { + 65536.0000, 21845.3333, 13107.2000, 9362.2857, 7281.7778, 4369.0667, 2114.0645, + 1040.2539, 516.0315, 257.0039, 128.2505, 64.0626, 32.0156, 16.0039, 8.0010, + 4.0002, 2.0001, 1.0000 + }; + +-#define MPC7_SCFI_SIZE 4 +-#define MPC7_SCFI_BITS 3 +-static const uint8_t mpc7_scfi[MPC7_SCFI_SIZE * 2] = { +- 0x2, 3, 0x1, 1, 0x3, 3, 0x0, 2 +-}; +- +-#define MPC7_DSCF_SIZE 16 +-#define MPC7_DSCF_BITS 6 +-static const uint8_t mpc7_dscf[MPC7_DSCF_SIZE * 2] = { +- 0x20, 6, 0x04, 5, 0x11, 5, 0x1E, 5, 0x0D, 4, 0x00, 3, 0x03, 3, 0x09, 4, +- 0x05, 3, 0x02, 3, 0x0E, 4, 0x03, 4, 0x1F, 5, 0x05, 5, 0x21, 6, 0x0C, 4 +-}; +- +-#define MPC7_HDR_SIZE 10 +-#define MPC7_HDR_BITS 9 +-static const uint8_t mpc7_hdr[MPC7_HDR_SIZE * 2] = { +- 0x5C, 8, 0x2F, 7, 0x0A, 5, 0x04, 4, 0x00, 2, +- 0x01, 1, 0x03, 3, 0x16, 6, 0xBB, 9, 0xBA, 9 +-}; +- +-#define MPC7_QUANT_VLC_TABLES 7 +-static const uint8_t mpc7_quant_vlc_sizes[MPC7_QUANT_VLC_TABLES * 2] = { +- 27, 25, 7, 9, 15, 31, 63 +-}; +- +-static const uint8_t mpc7_quant_vlc_off[MPC7_QUANT_VLC_TABLES] = { +- 0, 0, 3, 4, 7, 15, 31 +-}; +- +-static const uint16_t mpc7_quant_vlc[MPC7_QUANT_VLC_TABLES][2][64 * 2] = { +-{ +- { +- 0x0036, 6, 0x0009, 5, 0x0020, 6, 0x0005, 5, 0x000A, 4, 0x0007, 5, +- 0x0034, 6, 0x0000, 5, 0x0023, 6, 0x000A, 5, 0x0006, 4, 0x0004, 5, +- 0x000B, 4, 0x0007, 3, 0x000C, 4, 0x0003, 5, 0x0007, 4, 0x000B, 5, +- 0x0022, 6, 0x0001, 5, 0x0035, 6, 0x0006, 5, 0x0009, 4, 0x0002, 5, +- 0x0021, 6, 0x0008, 5, 0x0037, 6 +- }, +- { +- 0x0067, 8, 0x003E, 7, 0x00E1, 9, 0x0037, 7, 0x0003, 4, 0x0034, 7, +- 0x0065, 8, 0x003C, 7, 0x00E3, 9, 0x0018, 6, 0x0000, 4, 0x003D, 7, +- 0x0004, 4, 0x0001, 1, 0x0005, 4, 0x003F, 7, 0x0001, 4, 0x003B, 7, +- 0x00E2, 9, 0x0039, 7, 0x0064, 8, 0x0035, 7, 0x0002, 4, 0x0036, 7, +- 0x00E0, 9, 0x003A, 7, 0x0066, 8 +- } +-}, +-{ +- { +- 0x0059, 7, 0x002F, 6, 0x000F, 5, 0x0000, 5, 0x005B, 7, 0x0004, 5, +- 0x0006, 4, 0x000D, 4, 0x0004, 4, 0x0005, 5, 0x0014, 5, 0x000C, 4, +- 0x0004, 3, 0x000F, 4, 0x000E, 5, 0x0003, 5, 0x0003, 4, 0x000E, 4, +- 0x0005, 4, 0x0001, 5, 0x005A, 7, 0x0002, 5, 0x0015, 5, 0x002E, 6, +- 0x0058, 7 +- }, +- { +- 0x0399, 10, 0x0071, 7, 0x0033, 6, 0x00E7, 8, 0x039A, 10, 0x0068, 7, +- 0x001E, 5, 0x0000, 3, 0x001D, 5, 0x0069, 7, 0x0032, 6, 0x0001, 3, +- 0x0002, 2, 0x0003, 3, 0x0031, 6, 0x006B, 7, 0x001B, 5, 0x0002, 3, +- 0x001F, 5, 0x0070, 7, 0x0398, 10, 0x006A, 7, 0x0030, 6, 0x0072, 7, +- 0x039B, 10 +- } +-}, +-{ +- { +- 0x000C, 4, 0x0004, 3, 0x0000, 2, 0x0001, 2, 0x0007, 3, 0x0005, 3, 0x000D, 4 +- }, +- { +- 0x0004, 5, 0x0003, 4, 0x0002, 2, 0x0003, 2, 0x0001, 2, 0x0000, 3, 0x0005, 5 +- } +-}, +-{ +- { +- 0x0005, 4, 0x0000, 3, 0x0004, 3, 0x0006, 3, 0x0007, 3, 0x0005, 3, 0x0003, 3, 0x0001, 3, 0x0004, 4 +- }, +- { +- 0x0009, 5, 0x000C, 4, 0x0003, 3, 0x0000, 2, 0x0002, 2, 0x0007, 3, 0x000D, 4, 0x0005, 4, 0x0008, 5 +- } +-}, +-{ +- { +- 0x0039, 6, 0x0017, 5, 0x0008, 4, 0x000A, 4, 0x000D, 4, 0x0000, 3, +- 0x0002, 3, 0x0003, 3, 0x0001, 3, 0x000F, 4, 0x000C, 4, 0x0009, 4, +- 0x001D, 5, 0x0016, 5, 0x0038, 6, +- }, +- { +- 0x00E5, 8, 0x0038, 6, 0x0007, 5, 0x0002, 4, 0x0000, 3, 0x0003, 3, +- 0x0005, 3, 0x0006, 3, 0x0004, 3, 0x0002, 3, 0x000F, 4, 0x001D, 5, +- 0x0006, 5, 0x0073, 7, 0x00E4, 8, +- }, +-}, +-{ +- { +- 0x0041, 7, 0x0006, 6, 0x002C, 6, 0x002D, 6, 0x003B, 6, 0x000D, 5, +- 0x0011, 5, 0x0013, 5, 0x0017, 5, 0x0015, 5, 0x001A, 5, 0x001E, 5, +- 0x0000, 4, 0x0002, 4, 0x0005, 4, 0x0007, 4, 0x0003, 4, 0x0004, 4, +- 0x001F, 5, 0x001C, 5, 0x0019, 5, 0x001B, 5, 0x0018, 5, 0x0014, 5, +- 0x0012, 5, 0x000C, 5, 0x0002, 5, 0x003A, 6, 0x0021, 6, 0x0007, 6, +- 0x0040, 7 +- }, +- { +- 0x1948, 13, 0x194A, 13, 0x0328, 10, 0x0195, 9, 0x00CB, 8, 0x0066, 7, +- 0x0031, 6, 0x0009, 5, 0x000F, 5, 0x001F, 5, 0x0002, 4, 0x0006, 4, +- 0x0008, 4, 0x000B, 4, 0x000D, 4, 0x0000, 3, 0x000E, 4, 0x000A, 4, +- 0x0009, 4, 0x0005, 4, 0x0003, 4, 0x001E, 5, 0x000E, 5, 0x0008, 5, +- 0x0030, 6, 0x0067, 7, 0x00C9, 8, 0x00C8, 8, 0x0653, 11, 0x1949, 13, +- 0x194B, 13 +- } +-}, +-{ +- { +- 0x0067, 8, 0x0099, 8, 0x00B5, 8, 0x00E9, 8, 0x0040, 7, 0x0041, 7, +- 0x004D, 7, 0x0051, 7, 0x005B, 7, 0x0071, 7, 0x0070, 7, 0x0018, 6, +- 0x001D, 6, 0x0023, 6, 0x0025, 6, 0x0029, 6, 0x002C, 6, 0x002E, 6, +- 0x0033, 6, 0x0031, 6, 0x0036, 6, 0x0037, 6, 0x0039, 6, 0x003C, 6, +- 0x0000, 5, 0x0002, 5, 0x000A, 5, 0x0005, 5, 0x0009, 5, 0x0006, 5, +- 0x000D, 5, 0x0007, 5, 0x000B, 5, 0x000F, 5, 0x0008, 5, 0x0004, 5, +- 0x0003, 5, 0x0001, 5, 0x003F, 6, 0x003E, 6, 0x003D, 6, 0x0035, 6, +- 0x003B, 6, 0x0034, 6, 0x0030, 6, 0x002F, 6, 0x002B, 6, 0x002A, 6, +- 0x0027, 6, 0x0024, 6, 0x0021, 6, 0x001C, 6, 0x0075, 7, 0x0065, 7, +- 0x0064, 7, 0x0050, 7, 0x0045, 7, 0x0044, 7, 0x0032, 7, 0x00E8, 8, +- 0x00B4, 8, 0x0098, 8, 0x0066, 8 +- }, +- { +- 0x37A4, 14, 0x37AD, 14, 0x37A6, 14, 0x37AE, 14, 0x0DEA, 12, 0x02F0, 10, +- 0x02F1, 10, 0x00A0, 9, 0x00A2, 9, 0x01BC, 9, 0x007A, 8, 0x00DF, 8, +- 0x003C, 7, 0x0049, 7, 0x006E, 7, 0x000E, 6, 0x0018, 6, 0x0019, 6, +- 0x0022, 6, 0x0025, 6, 0x0036, 6, 0x0003, 5, 0x0009, 5, 0x000B, 5, +- 0x0010, 5, 0x0013, 5, 0x0015, 5, 0x0018, 5, 0x001A, 5, 0x001D, 5, +- 0x001F, 5, 0x0002, 4, 0x0000, 4, 0x001E, 5, 0x001C, 5, 0x0019, 5, +- 0x0016, 5, 0x0014, 5, 0x000E, 5, 0x000D, 5, 0x0008, 5, 0x0006, 5, +- 0x0002, 5, 0x002E, 6, 0x0023, 6, 0x001F, 6, 0x0015, 6, 0x000F, 6, +- 0x005F, 7, 0x0048, 7, 0x0029, 7, 0x00BD, 8, 0x007B, 8, 0x0179, 9, +- 0x00A1, 9, 0x037B, 10, 0x0147, 10, 0x0146, 10, 0x0DE8, 12, 0x37AF, 14, +- 0x37A7, 14, 0x37AC, 14, 0x37A5, 14 +- } +-} +-}; +- +-static const float mpc7_SCF[128] = { ++static const float mpc_SCF[128] = { + 307.330047607421875000, 255.999984741210937500, 213.243041992187500000, 177.627334594726562500, + 147.960128784179687500, 123.247924804687500000, 102.663139343261718750, 85.516410827636718750, + 71.233520507812500000, 59.336143493652343750, 49.425861358642578125, 41.170787811279296875, +@@ -209,4 +65,4 @@ + 0.000000044293003043, 0.000000036895215771, 0.000000030733001921, 0.000000025599996789 + }; + +-#endif // AVCODEC_MPCDATA_H ++#endif /* FFMPEG_MPCDATA_H */ +Only in ffmpeg-free-0.svn20080206/libavcodec: mpc.h +diff -u mplayer-1.0~rc2-12/libavcodec/mpeg12.c ffmpeg-free-0.svn20080206/libavcodec/mpeg12.c +--- mplayer-1.0~rc2-12/libavcodec/mpeg12.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/mpeg12.c 2008-03-20 19:10:58.000000000 +0100 +@@ -2220,7 +2220,7 @@ + /* handle buffering and image synchronisation */ + static int mpeg_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + Mpeg1Context *s = avctx->priv_data; + const uint8_t *buf_end; +@@ -2239,7 +2239,7 @@ + + *data_size = sizeof(AVFrame); + } +- return 0; ++ return buf_size; + } + + if(s2->flags&CODEC_FLAG_TRUNCATED){ +@@ -2329,8 +2329,10 @@ + if(s2->last_picture_ptr==NULL){ + /* Skip B-frames if we do not have reference frames. */ + if(s2->pict_type==B_TYPE) break; ++ } ++ if(s2->next_picture_ptr==NULL){ + /* Skip P-frames if we do not have reference frame no valid header. */ +-// if(s2->pict_type==P_TYPE && s2->first_field && !s2->first_slice) break; ++ if(s2->pict_type==P_TYPE && (s2->first_field || s2->picture_structure==PICT_FRAME)) break; + } + /* Skip B-frames if we are in a hurry. */ + if(avctx->hurry_up && s2->pict_type==B_TYPE) break; +diff -u mplayer-1.0~rc2-12/libavcodec/mpeg12data.h ffmpeg-free-0.svn20080206/libavcodec/mpeg12data.h +--- mplayer-1.0~rc2-12/libavcodec/mpeg12data.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/mpeg12data.h 2007-10-17 11:37:46.000000000 +0200 +@@ -25,8 +25,8 @@ + * MPEG1/2 tables. + */ + +-#ifndef AVCODEC_MPEG12DATA_H +-#define AVCODEC_MPEG12DATA_H ++#ifndef FFMPEG_MPEG12DATA_H ++#define FFMPEG_MPEG12DATA_H + + #include + #include "mpegvideo.h" +@@ -47,4 +47,4 @@ + extern const float ff_mpeg1_aspect[16]; + extern const AVRational ff_mpeg2_aspect[16]; + +-#endif // AVCODEC_MPEG12DATA_H ++#endif /* FFMPEG_MPEG12DATA_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/mpeg12decdata.h ffmpeg-free-0.svn20080206/libavcodec/mpeg12decdata.h +--- mplayer-1.0~rc2-12/libavcodec/mpeg12decdata.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/mpeg12decdata.h 2007-10-17 11:37:46.000000000 +0200 +@@ -25,8 +25,8 @@ + * MPEG1/2 decoder tables. + */ + +-#ifndef AVCODEC_MPEG12DECDATA_H +-#define AVCODEC_MPEG12DECDATA_H ++#ifndef FFMPEG_MPEG12DECDATA_H ++#define FFMPEG_MPEG12DECDATA_H + + #include + #include "mpegvideo.h" +@@ -121,4 +121,4 @@ + mpeg2_dc_scale_table3, + }; + +-#endif // AVCODEC_MPEG12DECDATA_H ++#endif /* FFMPEG_MPEG12DECDATA_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/mpeg12enc.c ffmpeg-free-0.svn20080206/libavcodec/mpeg12enc.c +--- mplayer-1.0~rc2-12/libavcodec/mpeg12enc.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/mpeg12enc.c 2008-03-20 19:10:58.000000000 +0100 +@@ -940,15 +940,3 @@ + .capabilities= CODEC_CAP_DELAY, + }; + +-AVCodec mpeg2video_encoder = { +- "mpeg2video", +- CODEC_TYPE_VIDEO, +- CODEC_ID_MPEG2VIDEO, +- sizeof(MpegEncContext), +- encode_init, +- MPV_encode_picture, +- MPV_encode_end, +- .supported_framerates= ff_frame_rate_tab+1, +- .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_YUV422P, -1}, +- .capabilities= CODEC_CAP_DELAY, +-}; +diff -u mplayer-1.0~rc2-12/libavcodec/mpeg12.h ffmpeg-free-0.svn20080206/libavcodec/mpeg12.h +--- mplayer-1.0~rc2-12/libavcodec/mpeg12.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/mpeg12.h 2007-10-17 11:37:46.000000000 +0200 +@@ -19,8 +19,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef AVCODEC_MPEG12_H +-#define AVCODEC_MPEG12_H ++#ifndef FFMPEG_MPEG12_H ++#define FFMPEG_MPEG12_H + + #include "mpegvideo.h" + +@@ -28,4 +28,4 @@ + + void ff_mpeg12_common_init(MpegEncContext *s); + +-#endif /* AVCODEC_MPEG12_H */ ++#endif /* FFMPEG_MPEG12_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/mpeg4data.h ffmpeg-free-0.svn20080206/libavcodec/mpeg4data.h +--- mplayer-1.0~rc2-12/libavcodec/mpeg4data.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/mpeg4data.h 2007-10-17 11:37:46.000000000 +0200 +@@ -25,8 +25,8 @@ + * mpeg4 tables. + */ + +-#ifndef AVCODEC_MPEG4DATA_H +-#define AVCODEC_MPEG4DATA_H ++#ifndef FFMPEG_MPEG4DATA_H ++#define FFMPEG_MPEG4DATA_H + + #include + #include "mpegvideo.h" +@@ -429,4 +429,4 @@ + 99, 13, 15, 17, 19, 21, 23, 0 + }; + +-#endif // AVCODEC_MPEG4DATA_H ++#endif /* FFMPEG_MPEG4DATA_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/mpeg4video_parser.h ffmpeg-free-0.svn20080206/libavcodec/mpeg4video_parser.h +--- mplayer-1.0~rc2-12/libavcodec/mpeg4video_parser.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/mpeg4video_parser.h 2007-10-17 11:37:46.000000000 +0200 +@@ -20,8 +20,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef MPEG4VIDEO_PARSER_H +-#define MPEG4VIDEO_PARSER_H ++#ifndef FFMPEG_MPEG4VIDEO_PARSER_H ++#define FFMPEG_MPEG4VIDEO_PARSER_H + + #include "parser.h" + +@@ -31,4 +31,4 @@ + */ + int ff_mpeg4_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size); + +-#endif /* MPEG4VIDEO_PARSER_H */ ++#endif /* FFMPEG_MPEG4VIDEO_PARSER_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/mpegaudiodata.h ffmpeg-free-0.svn20080206/libavcodec/mpegaudiodata.h +--- mplayer-1.0~rc2-12/libavcodec/mpegaudiodata.h 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/mpegaudiodata.h 2007-11-08 11:53:32.000000000 +0100 +@@ -24,11 +24,14 @@ + * mpeg audio layer common tables. + */ + +-#ifndef MPEGAUDIODATA_H +-#define MPEGAUDIODATA_H ++#ifndef FFMPEG_MPEGAUDIODATA_H ++#define FFMPEG_MPEGAUDIODATA_H + + #include "common.h" + ++#define MODE_EXT_MS_STEREO 2 ++#define MODE_EXT_I_STEREO 1 ++ + extern const uint16_t ff_mpa_bitrate_tab[2][3][15]; + extern const uint16_t ff_mpa_freq_tab[3]; + extern const int32_t ff_mpa_enwindow[257]; +@@ -37,4 +40,4 @@ + extern const int ff_mpa_quant_bits[17]; + extern const unsigned char *ff_mpa_alloc_tables[5]; + +-#endif /* MPEGAUDIODATA_H */ ++#endif /* FFMPEG_MPEGAUDIODATA_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/mpegaudiodec.c ffmpeg-free-0.svn20080206/libavcodec/mpegaudiodec.c +--- mplayer-1.0~rc2-12/libavcodec/mpegaudiodec.c 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/mpegaudiodec.c 2008-03-20 19:10:58.000000000 +0100 +@@ -85,9 +85,6 @@ + int32_t sb_hybrid[SBLIMIT * 18]; /* 576 samples */ + } GranuleDef; + +-#define MODE_EXT_MS_STEREO 2 +-#define MODE_EXT_I_STEREO 1 +- + #include "mpegaudiodata.h" + #include "mpegaudiodectab.h" + +@@ -129,6 +126,68 @@ + + static DECLARE_ALIGNED_16(MPA_INT, window[512]); + ++/** ++ * Convert region offsets to region sizes and truncate ++ * size to big_values. ++ */ ++void ff_region_offset2size(GranuleDef *g){ ++ int i, k, j=0; ++ g->region_size[2] = (576 / 2); ++ for(i=0;i<3;i++) { ++ k = FFMIN(g->region_size[i], g->big_values); ++ g->region_size[i] = k - j; ++ j = k; ++ } ++} ++ ++void ff_init_short_region(MPADecodeContext *s, GranuleDef *g){ ++ if (g->block_type == 2) ++ g->region_size[0] = (36 / 2); ++ else { ++ if (s->sample_rate_index <= 2) ++ g->region_size[0] = (36 / 2); ++ else if (s->sample_rate_index != 8) ++ g->region_size[0] = (54 / 2); ++ else ++ g->region_size[0] = (108 / 2); ++ } ++ g->region_size[1] = (576 / 2); ++} ++ ++void ff_init_long_region(MPADecodeContext *s, GranuleDef *g, int ra1, int ra2){ ++ int l; ++ g->region_size[0] = ++ band_index_long[s->sample_rate_index][ra1 + 1] >> 1; ++ /* should not overflow */ ++ l = FFMIN(ra1 + ra2 + 2, 22); ++ g->region_size[1] = ++ band_index_long[s->sample_rate_index][l] >> 1; ++} ++ ++void ff_compute_band_indexes(MPADecodeContext *s, GranuleDef *g){ ++ if (g->block_type == 2) { ++ if (g->switch_point) { ++ /* if switched mode, we handle the 36 first samples as ++ long blocks. For 8000Hz, we handle the 48 first ++ exponents as long blocks (XXX: check this!) */ ++ if (s->sample_rate_index <= 2) ++ g->long_end = 8; ++ else if (s->sample_rate_index != 8) ++ g->long_end = 6; ++ else ++ g->long_end = 4; /* 8000 Hz */ ++ ++ g->short_start = 2 + (s->sample_rate_index != 8); ++ } else { ++ g->long_end = 0; ++ g->short_start = 0; ++ } ++ } else { ++ g->short_start = 13; ++ g->long_end = 22; ++ } ++} ++ + /* layer 1 unscaling */ + /* n = number of bits of the mantissa minus 1 */ + static inline int l1_unscale(int n, int mant, int scale_factor) +@@ -2011,20 +2070,9 @@ + g->table_select[i] = get_bits(&s->gb, 5); + for(i=0;i<3;i++) + g->subblock_gain[i] = get_bits(&s->gb, 3); +- /* compute huffman coded region sizes */ +- if (g->block_type == 2) +- g->region_size[0] = (36 / 2); +- else { +- if (s->sample_rate_index <= 2) +- g->region_size[0] = (36 / 2); +- else if (s->sample_rate_index != 8) +- g->region_size[0] = (54 / 2); +- else +- g->region_size[0] = (108 / 2); +- } +- g->region_size[1] = (576 / 2); ++ ff_init_short_region(s, g); + } else { +- int region_address1, region_address2, l; ++ int region_address1, region_address2; + g->block_type = 0; + g->switch_point = 0; + for(i=0;i<3;i++) +@@ -2034,47 +2082,10 @@ + region_address2 = get_bits(&s->gb, 3); + dprintf(s->avctx, "region1=%d region2=%d\n", + region_address1, region_address2); +- g->region_size[0] = +- band_index_long[s->sample_rate_index][region_address1 + 1] >> 1; +- l = region_address1 + region_address2 + 2; +- /* should not overflow */ +- if (l > 22) +- l = 22; +- g->region_size[1] = +- band_index_long[s->sample_rate_index][l] >> 1; +- } +- /* convert region offsets to region sizes and truncate +- size to big_values */ +- g->region_size[2] = (576 / 2); +- j = 0; +- for(i=0;i<3;i++) { +- k = FFMIN(g->region_size[i], g->big_values); +- g->region_size[i] = k - j; +- j = k; +- } +- +- /* compute band indexes */ +- if (g->block_type == 2) { +- if (g->switch_point) { +- /* if switched mode, we handle the 36 first samples as +- long blocks. For 8000Hz, we handle the 48 first +- exponents as long blocks (XXX: check this!) */ +- if (s->sample_rate_index <= 2) +- g->long_end = 8; +- else if (s->sample_rate_index != 8) +- g->long_end = 6; +- else +- g->long_end = 4; /* 8000 Hz */ +- +- g->short_start = 2 + (s->sample_rate_index != 8); +- } else { +- g->long_end = 0; +- g->short_start = 0; +- } +- } else { +- g->short_start = 13; +- g->long_end = 22; ++ ff_init_long_region(s, g, region_address1, region_address2); + } ++ ff_region_offset2size(g); ++ ff_compute_band_indexes(s, g); + + g->preflag = 0; + if (!s->lsf) +@@ -2356,7 +2367,7 @@ + + static int decode_frame(AVCodecContext * avctx, + void *data, int *data_size, +- uint8_t * buf, int buf_size) ++ const uint8_t * buf, int buf_size) + { + MPADecodeContext *s = avctx->priv_data; + uint32_t header; +@@ -2420,13 +2431,14 @@ + + static void flush(AVCodecContext *avctx){ + MPADecodeContext *s = avctx->priv_data; ++ memset(s->synth_buf, 0, sizeof(s->synth_buf)); + s->last_buf_size= 0; + } + + #ifdef CONFIG_MP3ADU_DECODER + static int decode_frame_adu(AVCodecContext * avctx, + void *data, int *data_size, +- uint8_t * buf, int buf_size) ++ const uint8_t * buf, int buf_size) + { + MPADecodeContext *s = avctx->priv_data; + uint32_t header; +@@ -2552,7 +2564,7 @@ + + static int decode_frame_mp3on4(AVCodecContext * avctx, + void *data, int *data_size, +- uint8_t * buf, int buf_size) ++ const uint8_t * buf, int buf_size) + { + MP3On4DecodeContext *s = avctx->priv_data; + MPADecodeContext *m; +@@ -2562,7 +2574,7 @@ + OUT_INT decoded_buf[MPA_FRAME_SIZE * MPA_MAX_CHANNELS]; + OUT_INT *outptr, *bp; + int fsize; +- unsigned char *start2 = buf, *start; ++ const unsigned char *start2 = buf, *start; + int fr, i, j, n; + int off = avctx->channels; + int *coff = chan_offset[s->chan_cfg]; +@@ -2645,6 +2657,7 @@ + NULL, + decode_frame, + CODEC_CAP_PARSE_ONLY, ++ .flush= flush, + }; + #endif + #ifdef CONFIG_MP3_DECODER +diff -u mplayer-1.0~rc2-12/libavcodec/mpegaudiodecheader.h ffmpeg-free-0.svn20080206/libavcodec/mpegaudiodecheader.h +--- mplayer-1.0~rc2-12/libavcodec/mpegaudiodecheader.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/mpegaudiodecheader.h 2007-10-17 11:37:46.000000000 +0200 +@@ -24,8 +24,8 @@ + * MPEG Audio header decoder. + */ + +-#ifndef MPEGAUDIODECHEADER_H +-#define MPEGAUDIODECHEADER_H ++#ifndef FFMPEG_MPEGAUDIODECHEADER_H ++#define FFMPEG_MPEGAUDIODECHEADER_H + + #include "common.h" + #include "mpegaudio.h" +@@ -36,4 +36,4 @@ + that the frame size must be computed externally */ + int ff_mpegaudio_decode_header(MPADecodeContext *s, uint32_t header); + +-#endif /* MPEGAUDIODECHEADER_H */ ++#endif /* FFMPEG_MPEGAUDIODECHEADER_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/mpegaudiodectab.h ffmpeg-free-0.svn20080206/libavcodec/mpegaudiodectab.h +--- mplayer-1.0~rc2-12/libavcodec/mpegaudiodectab.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/mpegaudiodectab.h 2007-10-17 11:37:46.000000000 +0200 +@@ -24,8 +24,8 @@ + * mpeg audio layer decoder tables. + */ + +-#ifndef AVCODEC_MPEGAUDIODECTAB_H +-#define AVCODEC_MPEGAUDIODECTAB_H ++#ifndef FFMPEG_MPEGAUDIODECTAB_H ++#define FFMPEG_MPEGAUDIODECTAB_H + + #include + #include "mpegaudio.h" +@@ -603,4 +603,4 @@ + -0.6, -0.535, -0.33, -0.185, -0.095, -0.041, -0.0142, -0.0037, + }; + +-#endif // AVCODEC_MPEGAUDIODECTAB_H ++#endif /* FFMPEG_MPEGAUDIODECTAB_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/mpegaudio.h ffmpeg-free-0.svn20080206/libavcodec/mpegaudio.h +--- mplayer-1.0~rc2-12/libavcodec/mpegaudio.h 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/mpegaudio.h 2007-10-17 11:37:46.000000000 +0200 +@@ -23,8 +23,8 @@ + * mpeg audio declarations for both encoder and decoder. + */ + +-#ifndef MPEGAUDIO_H +-#define MPEGAUDIO_H ++#ifndef FFMPEG_MPEGAUDIO_H ++#define FFMPEG_MPEGAUDIO_H + + #include "avcodec.h" + #include "bitstream.h" +@@ -152,4 +152,4 @@ + return 0; + } + +-#endif /* MPEGAUDIO_H */ ++#endif /* FFMPEG_MPEGAUDIO_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/mpegaudiotab.h ffmpeg-free-0.svn20080206/libavcodec/mpegaudiotab.h +--- mplayer-1.0~rc2-12/libavcodec/mpegaudiotab.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/mpegaudiotab.h 2007-10-17 11:37:46.000000000 +0200 +@@ -27,8 +27,8 @@ + * Most of them come from the mpeg audio specification. + */ + +-#ifndef AVCODEC_MPEGAUDIOTAB_H +-#define AVCODEC_MPEGAUDIOTAB_H ++#ifndef FFMPEG_MPEGAUDIOTAB_H ++#define FFMPEG_MPEGAUDIOTAB_H + + #include + #include "mpegaudio.h" +@@ -115,4 +115,4 @@ + + static const unsigned char nb_scale_factors[4] = { 3, 2, 1, 2 }; + +-#endif // AVCODEC_MPEGAUDIOTAB_H ++#endif /* FFMPEG_MPEGAUDIOTAB_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/mpegvideo.c ffmpeg-free-0.svn20080206/libavcodec/mpegvideo.c +--- mplayer-1.0~rc2-12/libavcodec/mpegvideo.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/mpegvideo.c 2008-03-20 19:10:58.000000000 +0100 +@@ -130,7 +130,7 @@ + } + + /* init common dct for both encoder and decoder */ +-static int DCT_common_init(MpegEncContext *s) ++int ff_dct_common_init(MpegEncContext *s) + { + s->dct_unquantize_h263_intra = dct_unquantize_h263_intra_c; + s->dct_unquantize_h263_inter = dct_unquantize_h263_inter_c; +@@ -229,8 +229,8 @@ + + CHECKED_ALLOCZ(pic->mbskip_table , mb_array_size * sizeof(uint8_t)+2) //the +2 is for the slice end check + CHECKED_ALLOCZ(pic->qscale_table , mb_array_size * sizeof(uint8_t)) +- CHECKED_ALLOCZ(pic->mb_type_base , big_mb_num * sizeof(uint32_t)) +- pic->mb_type= pic->mb_type_base + s->mb_stride+1; ++ CHECKED_ALLOCZ(pic->mb_type_base , (big_mb_num + s->mb_stride) * sizeof(uint32_t)) ++ pic->mb_type= pic->mb_type_base + 2*s->mb_stride+1; + if(s->out_format == FMT_H264){ + for(i=0; i<2; i++){ + CHECKED_ALLOCZ(pic->motion_val_base[i], 2 * (b4_array_size+4) * sizeof(int16_t)) +@@ -431,7 +431,7 @@ + return -1; + + dsputil_init(&s->dsp, s->avctx); +- DCT_common_init(s); ++ ff_dct_common_init(s); + + s->flags= s->avctx->flags; + s->flags2= s->avctx->flags2; +@@ -587,9 +587,7 @@ + s->context_initialized = 1; + + s->thread_context[0]= s; +- /* h264 does thread context setup itself, but it needs context[0] +- * to be fully initialized for the error resilience code */ +- threads = s->codec_id == CODEC_ID_H264 ? 1 : s->avctx->thread_count; ++ threads = s->avctx->thread_count; + + for(i=1; ithread_context[i]= av_malloc(sizeof(MpegEncContext)); +@@ -842,7 +840,19 @@ + } + } + +- assert(0); ++ av_log(s->avctx, AV_LOG_FATAL, "Internal error, picture buffer overflow\n"); ++ /* We could return -1, but the codec would crash trying to draw into a ++ * non-existing frame anyway. This is safer than waiting for a random crash. ++ * Also the return of this is never useful, an encoder must only allocate ++ * as much as allowed in the specification. This has no relationship to how ++ * much libavcodec could allocate (and MAX_PICTURE_COUNT is always large ++ * enough for such valid streams). ++ * Plus, a decoder has to check stream validity and remove frames if too ++ * many reference frames are around. Waiting for "OOM" is not correct at ++ * all. Similarly, missing reference frames have to be replaced by ++ * interpolated/MC frames, anything else is a bug in the codec ... ++ */ ++ abort(); + return -1; + } + +@@ -954,7 +964,7 @@ + + assert(s->pict_type == I_TYPE || (s->last_picture_ptr && s->last_picture_ptr->data[0])); + +- if(s->picture_structure!=PICT_FRAME){ ++ if(s->picture_structure!=PICT_FRAME && s->out_format != FMT_H264){ + int i; + for(i=0; i<4; i++){ + if(s->picture_structure == PICT_BOTTOM_FIELD){ +diff -u mplayer-1.0~rc2-12/libavcodec/mpegvideo_common.h ffmpeg-free-0.svn20080206/libavcodec/mpegvideo_common.h +--- mplayer-1.0~rc2-12/libavcodec/mpegvideo_common.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/mpegvideo_common.h 2007-10-17 11:37:46.000000000 +0200 +@@ -27,8 +27,8 @@ + * The simplest mpeg encoder (well, it was the simplest!). + */ + +-#ifndef MPEGVIDEO_COMMON_H +-#define MPEGVIDEO_COMMON_H ++#ifndef FFMPEG_MPEGVIDEO_COMMON_H ++#define FFMPEG_MPEGVIDEO_COMMON_H + + #include "avcodec.h" + #include "dsputil.h" +@@ -833,4 +833,4 @@ + } + } + +-#endif /* MPEGVIDEO_COMMON_H */ ++#endif /* FFMPEG_MPEGVIDEO_COMMON_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/mpegvideo_enc.c ffmpeg-free-0.svn20080206/libavcodec/mpegvideo_enc.c +--- mplayer-1.0~rc2-12/libavcodec/mpegvideo_enc.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/mpegvideo_enc.c 2008-03-20 19:10:58.000000000 +0100 +@@ -64,9 +64,7 @@ + static uint8_t default_mv_penalty[MAX_FCODE+1][MAX_MV*2+1]; + static uint8_t default_fcode_tab[MAX_MV*2+1]; + +-enum PixelFormat ff_yuv420p_list[2]= {PIX_FMT_YUV420P, -1}; +- +-static void convert_matrix(DSPContext *dsp, int (*qmat)[64], uint16_t (*qmat16)[2][64], ++void ff_convert_matrix(DSPContext *dsp, int (*qmat)[64], uint16_t (*qmat16)[2][64], + const uint16_t *quant_matrix, int bias, int qmin, int qmax, int intra) + { + int qscale; +@@ -716,9 +714,9 @@ + /* precompute matrix */ + /* for mjpeg, we do include qscale in the matrix */ + if (s->out_format != FMT_MJPEG) { +- convert_matrix(&s->dsp, s->q_intra_matrix, s->q_intra_matrix16, ++ ff_convert_matrix(&s->dsp, s->q_intra_matrix, s->q_intra_matrix16, + s->intra_matrix, s->intra_quant_bias, avctx->qmin, 31, 1); +- convert_matrix(&s->dsp, s->q_inter_matrix, s->q_inter_matrix16, ++ ff_convert_matrix(&s->dsp, s->q_inter_matrix, s->q_inter_matrix16, + s->inter_matrix, s->inter_quant_bias, avctx->qmin, 31, 0); + } + +@@ -1422,7 +1420,7 @@ + av_log(s->avctx, AV_LOG_INFO, "warning, clipping %d dct coefficients to %d..%d\n", overflow, minlevel, maxlevel); + } + +-static void get_vissual_weight(int16_t *weight, uint8_t *ptr, int stride){ ++static void get_visual_weight(int16_t *weight, uint8_t *ptr, int stride){ + int x, y; + //FIXME optimize + for(y=0; y<8; y++){ +@@ -1626,15 +1624,15 @@ + } + + if(s->avctx->quantizer_noise_shaping){ +- if(!skip_dct[0]) get_vissual_weight(weight[0], ptr_y , wrap_y); +- if(!skip_dct[1]) get_vissual_weight(weight[1], ptr_y + 8, wrap_y); +- if(!skip_dct[2]) get_vissual_weight(weight[2], ptr_y + dct_offset , wrap_y); +- if(!skip_dct[3]) get_vissual_weight(weight[3], ptr_y + dct_offset + 8, wrap_y); +- if(!skip_dct[4]) get_vissual_weight(weight[4], ptr_cb , wrap_c); +- if(!skip_dct[5]) get_vissual_weight(weight[5], ptr_cr , wrap_c); ++ if(!skip_dct[0]) get_visual_weight(weight[0], ptr_y , wrap_y); ++ if(!skip_dct[1]) get_visual_weight(weight[1], ptr_y + 8, wrap_y); ++ if(!skip_dct[2]) get_visual_weight(weight[2], ptr_y + dct_offset , wrap_y); ++ if(!skip_dct[3]) get_visual_weight(weight[3], ptr_y + dct_offset + 8, wrap_y); ++ if(!skip_dct[4]) get_visual_weight(weight[4], ptr_cb , wrap_c); ++ if(!skip_dct[5]) get_visual_weight(weight[5], ptr_cr , wrap_c); + if(!s->chroma_y_shift){ /* 422 */ +- if(!skip_dct[6]) get_vissual_weight(weight[6], ptr_cb + (dct_offset>>1), wrap_c); +- if(!skip_dct[7]) get_vissual_weight(weight[7], ptr_cr + (dct_offset>>1), wrap_c); ++ if(!skip_dct[6]) get_visual_weight(weight[6], ptr_cb + (dct_offset>>1), wrap_c); ++ if(!skip_dct[7]) get_visual_weight(weight[7], ptr_cr + (dct_offset>>1), wrap_c); + } + memcpy(orig[0], s->block[0], sizeof(DCTELEM)*64*mb_block_count); + } +@@ -1769,6 +1767,8 @@ + d->mb_skipped= 0; + d->qscale= s->qscale; + d->dquant= s->dquant; ++ ++ d->esc3_level_length= s->esc3_level_length; + } + + static inline void copy_context_after_encode(MpegEncContext *d, MpegEncContext *s, int type){ +@@ -1806,6 +1806,8 @@ + d->block_last_index[i]= s->block_last_index[i]; + d->interlaced_dct= s->interlaced_dct; + d->qscale= s->qscale; ++ ++ d->esc3_level_length= s->esc3_level_length; + } + + static inline void encode_mb_hq(MpegEncContext *s, MpegEncContext *backup, MpegEncContext *best, int type, +@@ -2861,7 +2863,7 @@ + + s->intra_matrix[j] = av_clip_uint8((ff_mpeg1_default_intra_matrix[i] * s->qscale) >> 3); + } +- convert_matrix(&s->dsp, s->q_intra_matrix, s->q_intra_matrix16, ++ ff_convert_matrix(&s->dsp, s->q_intra_matrix, s->q_intra_matrix16, + s->intra_matrix, s->intra_quant_bias, 8, 8, 1); + s->qscale= 8; + } +@@ -3714,27 +3716,7 @@ + return last_non_zero; + } + +-AVCodec h263_encoder = { +- "h263", +- CODEC_TYPE_VIDEO, +- CODEC_ID_H263, +- sizeof(MpegEncContext), +- MPV_encode_init, +- MPV_encode_picture, +- MPV_encode_end, +- .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1}, +-}; + +-AVCodec h263p_encoder = { +- "h263p", +- CODEC_TYPE_VIDEO, +- CODEC_ID_H263P, +- sizeof(MpegEncContext), +- MPV_encode_init, +- MPV_encode_picture, +- MPV_encode_end, +- .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1}, +-}; + + AVCodec flv_encoder = { + "flv", +@@ -3769,50 +3751,9 @@ + .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1}, + }; + +-AVCodec mpeg4_encoder = { +- "mpeg4", +- CODEC_TYPE_VIDEO, +- CODEC_ID_MPEG4, +- sizeof(MpegEncContext), +- MPV_encode_init, +- MPV_encode_picture, +- MPV_encode_end, +- .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1}, +- .capabilities= CODEC_CAP_DELAY, +-}; + +-AVCodec msmpeg4v1_encoder = { +- "msmpeg4v1", +- CODEC_TYPE_VIDEO, +- CODEC_ID_MSMPEG4V1, +- sizeof(MpegEncContext), +- MPV_encode_init, +- MPV_encode_picture, +- MPV_encode_end, +- .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1}, +-}; + +-AVCodec msmpeg4v2_encoder = { +- "msmpeg4v2", +- CODEC_TYPE_VIDEO, +- CODEC_ID_MSMPEG4V2, +- sizeof(MpegEncContext), +- MPV_encode_init, +- MPV_encode_picture, +- MPV_encode_end, +- .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1}, +-}; + +-AVCodec msmpeg4v3_encoder = { +- "msmpeg4", +- CODEC_TYPE_VIDEO, +- CODEC_ID_MSMPEG4V3, +- sizeof(MpegEncContext), +- MPV_encode_init, +- MPV_encode_picture, +- MPV_encode_end, +- .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1}, +-}; + + AVCodec wmv1_encoder = { + "wmv1", +diff -u mplayer-1.0~rc2-12/libavcodec/mpegvideo.h ffmpeg-free-0.svn20080206/libavcodec/mpegvideo.h +--- mplayer-1.0~rc2-12/libavcodec/mpegvideo.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/mpegvideo.h 2008-02-03 18:54:30.000000000 +0100 +@@ -25,8 +25,8 @@ + * mpegvideo header. + */ + +-#ifndef AVCODEC_MPEGVIDEO_H +-#define AVCODEC_MPEGVIDEO_H ++#ifndef FFMPEG_MPEGVIDEO_H ++#define FFMPEG_MPEGVIDEO_H + + #include "dsputil.h" + #include "bitstream.h" +@@ -94,7 +94,7 @@ + uint8_t permutated[64]; + uint8_t raster_end[64]; + #ifdef ARCH_POWERPC +- /** Used by dct_quantise_alitvec to find last-non-zero */ ++ /** Used by dct_quantize_altivec to find last-non-zero */ + DECLARE_ALIGNED_8(uint8_t, inverse[64]); + #endif + } ScanTable; +@@ -111,7 +111,7 @@ + uint8_t *interpolated[3]; + int16_t (*motion_val_base[2])[2]; + uint32_t *mb_type_base; +-#define MB_TYPE_INTRA MB_TYPE_INTRA4x4 //default mb_type if theres just one type ++#define MB_TYPE_INTRA MB_TYPE_INTRA4x4 //default mb_type if there is just one type + #define IS_INTRA4x4(a) ((a)&MB_TYPE_INTRA4x4) + #define IS_INTRA16x16(a) ((a)&MB_TYPE_INTRA16x16) + #define IS_PCM(a) ((a)&MB_TYPE_INTRA_PCM) +@@ -723,8 +723,9 @@ + void ff_er_frame_end(MpegEncContext *s); + void ff_er_add_slice(MpegEncContext *s, int startx, int starty, int endx, int endy, int status); + +- +-extern enum PixelFormat ff_yuv420p_list[2]; ++int ff_dct_common_init(MpegEncContext *s); ++void ff_convert_matrix(DSPContext *dsp, int (*qmat)[64], uint16_t (*qmat16)[2][64], ++ const uint16_t *quant_matrix, int bias, int qmin, int qmax, int intra); + + void ff_init_block_index(MpegEncContext *s); + +@@ -770,10 +771,10 @@ + int16_t (*mv_table)[2], int f_code, int type, int truncate); + void ff_init_me(MpegEncContext *s); + int ff_pre_estimate_p_frame_motion(MpegEncContext * s, int mb_x, int mb_y); +-inline int ff_epzs_motion_search(MpegEncContext * s, int *mx_ptr, int *my_ptr, ++int ff_epzs_motion_search(MpegEncContext * s, int *mx_ptr, int *my_ptr, + int P[10][2], int src_index, int ref_index, int16_t (*last_mv)[2], + int ref_mv_scale, int size, int h); +-inline int ff_get_mb_score(MpegEncContext * s, int mx, int my, int src_index, ++int ff_get_mb_score(MpegEncContext * s, int mx, int my, int src_index, + int ref_index, int size, int h, int add_rate); + + /* mpeg12.c */ +@@ -816,7 +817,7 @@ + int ff_h263_decode_init(AVCodecContext *avctx); + int ff_h263_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size); ++ const uint8_t *buf, int buf_size); + int ff_h263_decode_end(AVCodecContext *avctx); + void h263_encode_mb(MpegEncContext *s, + DCTELEM block[6][64], +@@ -895,5 +896,5 @@ + DCTELEM block[6][64], + int motion_x, int motion_y); + +-#endif /* AVCODEC_MPEGVIDEO_H */ ++#endif /* FFMPEG_MPEGVIDEO_H */ + +diff -u mplayer-1.0~rc2-12/libavcodec/msmpeg4.c ffmpeg-free-0.svn20080206/libavcodec/msmpeg4.c +--- mplayer-1.0~rc2-12/libavcodec/msmpeg4.c 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/msmpeg4.c 2008-03-20 19:10:58.000000000 +0100 +@@ -30,6 +30,7 @@ + #include "avcodec.h" + #include "dsputil.h" + #include "mpegvideo.h" ++#include "msmpeg4.h" + + /* + * You can also call this codec : MPEG4 with a twist ! +@@ -42,7 +43,6 @@ + + #define DC_VLC_BITS 9 + #define CBPY_VLC_BITS 6 +-#define INTER_INTRA_VLC_BITS 3 + #define V1_INTRA_CBPC_VLC_BITS 6 + #define V1_INTER_CBPC_VLC_BITS 6 + #define V2_INTRA_CBPC_VLC_BITS 3 +@@ -50,8 +50,6 @@ + #define MV_VLC_BITS 9 + #define V2_MV_VLC_BITS 9 + #define TEX_VLC_BITS 9 +-#define MB_NON_INTRA_VLC_BITS 9 +-#define MB_INTRA_VLC_BITS 9 + + #define II_BITRATE 128*1024 + #define MBAC_BITRATE 50*1024 +@@ -61,12 +59,7 @@ + static uint32_t v2_dc_lum_table[512][2]; + static uint32_t v2_dc_chroma_table[512][2]; + +-void ff_msmpeg4_encode_block(MpegEncContext * s, DCTELEM * block, int n); +-static inline int msmpeg4_decode_block(MpegEncContext * s, DCTELEM * block, +- int n, int coded, const uint8_t *scantable); + static int msmpeg4_decode_dc(MpegEncContext * s, int n, int *dir_ptr); +-static int msmpeg4_decode_motion(MpegEncContext * s, +- int *mx_ptr, int *my_ptr); + static void init_h263_dc_for_msmpeg4(void); + static inline void msmpeg4_memsetw(short *tab, int val, int n); + #ifdef CONFIG_ENCODERS +@@ -75,10 +68,9 @@ + #endif //CONFIG_ENCODERS + static int msmpeg4v12_decode_mb(MpegEncContext *s, DCTELEM block[6][64]); + static int msmpeg4v34_decode_mb(MpegEncContext *s, DCTELEM block[6][64]); +-static int wmv2_decode_mb(MpegEncContext *s, DCTELEM block[6][64]); + + /* vc1 externs */ +-extern uint8_t wmv3_dc_scale_table[32]; ++extern const uint8_t wmv3_dc_scale_table[32]; + + #ifdef DEBUG + int intra_count = 0; +@@ -161,7 +153,7 @@ + } + } + +-void ff_code012(PutBitContext *pb, int n) ++void ff_msmpeg4_code012(PutBitContext *pb, int n) + { + if (n == 0) { + put_bits(pb, 1, 0); +@@ -347,8 +339,8 @@ + + if(s->msmpeg4_version>2){ + if(!s->per_mb_rl_table){ +- ff_code012(&s->pb, s->rl_chroma_table_index); +- ff_code012(&s->pb, s->rl_table_index); ++ ff_msmpeg4_code012(&s->pb, s->rl_chroma_table_index); ++ ff_msmpeg4_code012(&s->pb, s->rl_table_index); + } + + put_bits(&s->pb, 1, s->dc_table_index); +@@ -361,7 +353,7 @@ + + if(s->msmpeg4_version>2){ + if(!s->per_mb_rl_table) +- ff_code012(&s->pb, s->rl_table_index); ++ ff_msmpeg4_code012(&s->pb, s->rl_table_index); + + put_bits(&s->pb, 1, s->dc_table_index); + +@@ -393,7 +385,7 @@ + #endif //CONFIG_ENCODERS + + /* predict coded block */ +-static inline int coded_block_pred(MpegEncContext * s, int n, uint8_t **coded_block_ptr) ++int ff_msmpeg4_coded_block_pred(MpegEncContext * s, int n, uint8_t **coded_block_ptr) + { + int xy, wrap, pred, a, b, c; + +@@ -421,7 +413,7 @@ + + #ifdef CONFIG_ENCODERS + +-static void msmpeg4_encode_motion(MpegEncContext * s, ++void ff_msmpeg4_encode_motion(MpegEncContext * s, + int mx, int my) + { + int code; +@@ -459,7 +451,7 @@ + } + } + +-static inline void handle_slices(MpegEncContext *s){ ++void ff_msmpeg4_handle_slices(MpegEncContext *s){ + if (s->mb_x == 0) { + if (s->slice_height && (s->mb_y % s->slice_height) == 0) { + if(s->msmpeg4_version < 4){ +@@ -480,7 +472,7 @@ + int pred_x, pred_y; + uint8_t *coded_block; + +- handle_slices(s); ++ ff_msmpeg4_handle_slices(s); + + if (!s->mb_intra) { + /* compute cbp */ +@@ -526,7 +518,7 @@ + + /* motion vector */ + h263_pred_motion(s, 0, 0, &pred_x, &pred_y); +- msmpeg4_encode_motion(s, motion_x - pred_x, ++ ff_msmpeg4_encode_motion(s, motion_x - pred_x, + motion_y - pred_y); + } + +@@ -546,7 +538,7 @@ + cbp |= val << (5 - i); + if (i < 4) { + /* predict value for close blocks only for luma */ +- pred = coded_block_pred(s, i, &coded_block); ++ pred = ff_msmpeg4_coded_block_pred(s, i, &coded_block); + *coded_block = val; + val = val ^ pred; + } +@@ -990,7 +982,7 @@ + /****************************************/ + /* decoding stuff */ + +-static VLC mb_non_intra_vlc[4]; ++VLC ff_mb_non_intra_vlc[4]; + static VLC v2_dc_lum_vlc; + static VLC v2_dc_chroma_vlc; + static VLC cbpy_vlc; +@@ -999,7 +991,7 @@ + static VLC v2_mv_vlc; + static VLC v1_intra_cbpc_vlc; + static VLC v1_inter_cbpc_vlc; +-static VLC inter_intra_vlc; ++VLC ff_inter_intra_vlc; + + /* This table is practically identical to the one from h263 + * except that it is inverted. */ +@@ -1114,7 +1106,7 @@ + &mvtab[0][0], 2, 1, 1); + + for(i=0; i<4; i++){ +- init_vlc(&mb_non_intra_vlc[i], MB_NON_INTRA_VLC_BITS, 128, ++ init_vlc(&ff_mb_non_intra_vlc[i], MB_NON_INTRA_VLC_BITS, 128, + &wmv2_inter_table[i][0][1], 8, 4, + &wmv2_inter_table[i][0][0], 8, 4, 1); //FIXME name? + } +@@ -1130,7 +1122,7 @@ + inter_MCBPC_bits, 1, 1, + inter_MCBPC_code, 1, 1, 1); + +- init_vlc(&inter_intra_vlc, INTER_INTRA_VLC_BITS, 4, ++ init_vlc(&ff_inter_intra_vlc, INTER_INTRA_VLC_BITS, 4, + &table_inter_intra[0][1], 2, 1, + &table_inter_intra[0][0], 2, 1, 1); + } +@@ -1145,7 +1137,8 @@ + s->decode_mb= msmpeg4v34_decode_mb; + break; + case 5: +- s->decode_mb= wmv2_decode_mb; ++ if (ENABLE_WMV2_DECODER) ++ s->decode_mb= ff_wmv2_decode_mb; + case 6: + //FIXME + TODO VC1 decode mb + break; +@@ -1508,7 +1501,7 @@ + + s->dsp.clear_blocks(s->block[0]); + for (i = 0; i < 6; i++) { +- if (msmpeg4_decode_block(s, block[i], i, (cbp >> (5 - i)) & 1, NULL) < 0) ++ if (ff_msmpeg4_decode_block(s, block[i], i, (cbp >> (5 - i)) & 1, NULL) < 0) + { + av_log(s->avctx, AV_LOG_ERROR, "\nerror while decoding block: %d x %d (%d)\n", s->mb_x, s->mb_y, i); + return -1; +@@ -1541,7 +1534,7 @@ + } + } + +- code = get_vlc2(&s->gb, mb_non_intra_vlc[DEFAULT_INTER_INDEX].table, MB_NON_INTRA_VLC_BITS, 3); ++ code = get_vlc2(&s->gb, ff_mb_non_intra_vlc[DEFAULT_INTER_INDEX].table, MB_NON_INTRA_VLC_BITS, 3); + if (code < 0) + return -1; + //s->mb_intra = (code & 0x40) ? 0 : 1; +@@ -1558,7 +1551,7 @@ + for(i=0;i<6;i++) { + int val = ((code >> (5 - i)) & 1); + if (i < 4) { +- int pred = coded_block_pred(s, i, &coded_val); ++ int pred = ff_msmpeg4_coded_block_pred(s, i, &coded_val); + val = val ^ pred; + *coded_val = val; + } +@@ -1574,7 +1567,7 @@ + s->rl_chroma_table_index = s->rl_table_index; + } + h263_pred_motion(s, 0, 0, &mx, &my); +- if (msmpeg4_decode_motion(s, &mx, &my) < 0) ++ if (ff_msmpeg4_decode_motion(s, &mx, &my) < 0) + return -1; + s->mv_dir = MV_DIR_FORWARD; + s->mv_type = MV_TYPE_16X16; +@@ -1586,7 +1579,7 @@ + s->ac_pred = get_bits1(&s->gb); + *mb_type_ptr = MB_TYPE_INTRA; + if(s->inter_intra_pred){ +- s->h263_aic_dir= get_vlc2(&s->gb, inter_intra_vlc.table, INTER_INTRA_VLC_BITS, 1); ++ s->h263_aic_dir= get_vlc2(&s->gb, ff_inter_intra_vlc.table, INTER_INTRA_VLC_BITS, 1); + // printf("%d%d %d %d/", s->ac_pred, s->h263_aic_dir, s->mb_x, s->mb_y); + } + if(s->per_mb_rl_table && cbp){ +@@ -1597,7 +1590,7 @@ + + s->dsp.clear_blocks(s->block[0]); + for (i = 0; i < 6; i++) { +- if (msmpeg4_decode_block(s, block[i], i, (cbp >> (5 - i)) & 1, NULL) < 0) ++ if (ff_msmpeg4_decode_block(s, block[i], i, (cbp >> (5 - i)) & 1, NULL) < 0) + { + av_log(s->avctx, AV_LOG_ERROR, "\nerror while decoding block: %d x %d (%d)\n", s->mb_x, s->mb_y, i); + return -1; +@@ -1607,7 +1600,7 @@ + return 0; + } + //#define ERROR_DETAILS +-static inline int msmpeg4_decode_block(MpegEncContext * s, DCTELEM * block, ++int ff_msmpeg4_decode_block(MpegEncContext * s, DCTELEM * block, + int n, int coded, const uint8_t *scan_table) + { + int level, i, last, run, run_diff; +@@ -1911,7 +1904,7 @@ + return level; + } + +-static int msmpeg4_decode_motion(MpegEncContext * s, ++int ff_msmpeg4_decode_motion(MpegEncContext * s, + int *mx_ptr, int *my_ptr) + { + MVTable *mv; +@@ -1949,9 +1942,3 @@ + *my_ptr = my; + return 0; + } +- +-/* cleanest way to support it +- * there is too much shared between versions so that we cant have 1 file per version & 1 common +- * as allmost everything would be in the common file +- */ +-#include "wmv2.c" +diff -u mplayer-1.0~rc2-12/libavcodec/msmpeg4data.c ffmpeg-free-0.svn20080206/libavcodec/msmpeg4data.c +--- mplayer-1.0~rc2-12/libavcodec/msmpeg4data.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/msmpeg4data.c 2008-03-20 19:10:58.000000000 +0100 +@@ -1828,53 +1828,47 @@ + 0, 8, 8, 8, 8, 9, 9,10,10,11,11,12,12,13,13,14,14,15,15,16,16,17,17,18,18,19,19,20,20,21,21,22 + }; + +- +-static const uint8_t wmv1_scantable00[64]= { +-0x00, 0x08, 0x01, 0x02, 0x09, 0x10, 0x18, 0x11, +-0x0A, 0x03, 0x04, 0x0B, 0x12, 0x19, 0x20, 0x28, +-0x30, 0x38, 0x29, 0x21, 0x1A, 0x13, 0x0C, 0x05, +-0x06, 0x0D, 0x14, 0x1B, 0x22, 0x31, 0x39, 0x3A, +-0x32, 0x2A, 0x23, 0x1C, 0x15, 0x0E, 0x07, 0x0F, +-0x16, 0x1D, 0x24, 0x2B, 0x33, 0x3B, 0x3C, 0x34, +-0x2C, 0x25, 0x1E, 0x17, 0x1F, 0x26, 0x2D, 0x35, +-0x3D, 0x3E, 0x36, 0x2E, 0x27, 0x2F, 0x37, 0x3F, +-}; +-static const uint8_t wmv1_scantable01[64]= { +-0x00, 0x08, 0x01, 0x02, 0x09, 0x10, 0x18, 0x11, +-0x0A, 0x03, 0x04, 0x0B, 0x12, 0x19, 0x20, 0x28, +-0x21, 0x30, 0x1A, 0x13, 0x0C, 0x05, 0x06, 0x0D, +-0x14, 0x1B, 0x22, 0x29, 0x38, 0x31, 0x39, 0x2A, +-0x23, 0x1C, 0x15, 0x0E, 0x07, 0x0F, 0x16, 0x1D, +-0x24, 0x2B, 0x32, 0x3A, 0x33, 0x3B, 0x2C, 0x25, +-0x1E, 0x17, 0x1F, 0x26, 0x2D, 0x34, 0x3C, 0x35, +-0x3D, 0x2E, 0x27, 0x2F, 0x36, 0x3E, 0x37, 0x3F, +-}; +-static const uint8_t wmv1_scantable02[64]= { +-0x00, 0x01, 0x08, 0x02, 0x03, 0x09, 0x10, 0x18, +-0x11, 0x0A, 0x04, 0x05, 0x0B, 0x12, 0x19, 0x20, +-0x28, 0x30, 0x21, 0x1A, 0x13, 0x0C, 0x06, 0x07, +-0x0D, 0x14, 0x1B, 0x22, 0x29, 0x38, 0x31, 0x39, +-0x2A, 0x23, 0x1C, 0x15, 0x0E, 0x0F, 0x16, 0x1D, +-0x24, 0x2B, 0x32, 0x3A, 0x33, 0x2C, 0x25, 0x1E, +-0x17, 0x1F, 0x26, 0x2D, 0x34, 0x3B, 0x3C, 0x35, +-0x2E, 0x27, 0x2F, 0x36, 0x3D, 0x3E, 0x37, 0x3F, +-}; +-static const uint8_t wmv1_scantable03[64]= { +-0x00, 0x08, 0x10, 0x01, 0x18, 0x20, 0x28, 0x09, +-0x02, 0x03, 0x0A, 0x11, 0x19, 0x30, 0x38, 0x29, +-0x21, 0x1A, 0x12, 0x0B, 0x04, 0x05, 0x0C, 0x13, +-0x1B, 0x22, 0x31, 0x39, 0x32, 0x2A, 0x23, 0x1C, +-0x14, 0x0D, 0x06, 0x07, 0x0E, 0x15, 0x1D, 0x24, +-0x2B, 0x33, 0x3A, 0x3B, 0x34, 0x2C, 0x25, 0x1E, +-0x16, 0x0F, 0x17, 0x1F, 0x26, 0x2D, 0x3C, 0x35, +-0x2E, 0x27, 0x2F, 0x36, 0x3D, 0x3E, 0x37, 0x3F, +-}; +- +-const uint8_t *wmv1_scantable[WMV1_SCANTABLE_COUNT+1]={ +- wmv1_scantable00, +- wmv1_scantable01, +- wmv1_scantable02, +- wmv1_scantable03, ++const uint8_t wmv1_scantable[WMV1_SCANTABLE_COUNT][64]={ ++ { ++ 0x00, 0x08, 0x01, 0x02, 0x09, 0x10, 0x18, 0x11, ++ 0x0A, 0x03, 0x04, 0x0B, 0x12, 0x19, 0x20, 0x28, ++ 0x30, 0x38, 0x29, 0x21, 0x1A, 0x13, 0x0C, 0x05, ++ 0x06, 0x0D, 0x14, 0x1B, 0x22, 0x31, 0x39, 0x3A, ++ 0x32, 0x2A, 0x23, 0x1C, 0x15, 0x0E, 0x07, 0x0F, ++ 0x16, 0x1D, 0x24, 0x2B, 0x33, 0x3B, 0x3C, 0x34, ++ 0x2C, 0x25, 0x1E, 0x17, 0x1F, 0x26, 0x2D, 0x35, ++ 0x3D, 0x3E, 0x36, 0x2E, 0x27, 0x2F, 0x37, 0x3F, ++ }, ++ { ++ 0x00, 0x08, 0x01, 0x02, 0x09, 0x10, 0x18, 0x11, ++ 0x0A, 0x03, 0x04, 0x0B, 0x12, 0x19, 0x20, 0x28, ++ 0x21, 0x30, 0x1A, 0x13, 0x0C, 0x05, 0x06, 0x0D, ++ 0x14, 0x1B, 0x22, 0x29, 0x38, 0x31, 0x39, 0x2A, ++ 0x23, 0x1C, 0x15, 0x0E, 0x07, 0x0F, 0x16, 0x1D, ++ 0x24, 0x2B, 0x32, 0x3A, 0x33, 0x3B, 0x2C, 0x25, ++ 0x1E, 0x17, 0x1F, 0x26, 0x2D, 0x34, 0x3C, 0x35, ++ 0x3D, 0x2E, 0x27, 0x2F, 0x36, 0x3E, 0x37, 0x3F, ++ }, ++ { ++ 0x00, 0x01, 0x08, 0x02, 0x03, 0x09, 0x10, 0x18, ++ 0x11, 0x0A, 0x04, 0x05, 0x0B, 0x12, 0x19, 0x20, ++ 0x28, 0x30, 0x21, 0x1A, 0x13, 0x0C, 0x06, 0x07, ++ 0x0D, 0x14, 0x1B, 0x22, 0x29, 0x38, 0x31, 0x39, ++ 0x2A, 0x23, 0x1C, 0x15, 0x0E, 0x0F, 0x16, 0x1D, ++ 0x24, 0x2B, 0x32, 0x3A, 0x33, 0x2C, 0x25, 0x1E, ++ 0x17, 0x1F, 0x26, 0x2D, 0x34, 0x3B, 0x3C, 0x35, ++ 0x2E, 0x27, 0x2F, 0x36, 0x3D, 0x3E, 0x37, 0x3F, ++ }, ++ { ++ 0x00, 0x08, 0x10, 0x01, 0x18, 0x20, 0x28, 0x09, ++ 0x02, 0x03, 0x0A, 0x11, 0x19, 0x30, 0x38, 0x29, ++ 0x21, 0x1A, 0x12, 0x0B, 0x04, 0x05, 0x0C, 0x13, ++ 0x1B, 0x22, 0x31, 0x39, 0x32, 0x2A, 0x23, 0x1C, ++ 0x14, 0x0D, 0x06, 0x07, 0x0E, 0x15, 0x1D, 0x24, ++ 0x2B, 0x33, 0x3A, 0x3B, 0x34, 0x2C, 0x25, 0x1E, ++ 0x16, 0x0F, 0x17, 0x1F, 0x26, 0x2D, 0x3C, 0x35, ++ 0x2E, 0x27, 0x2F, 0x36, 0x3D, 0x3E, 0x37, 0x3F, ++ } + }; + + const uint8_t table_inter_intra[4][2]={ +diff -u mplayer-1.0~rc2-12/libavcodec/msmpeg4data.h ffmpeg-free-0.svn20080206/libavcodec/msmpeg4data.h +--- mplayer-1.0~rc2-12/libavcodec/msmpeg4data.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/msmpeg4data.h 2008-01-07 13:47:14.000000000 +0100 +@@ -27,8 +27,8 @@ + * MSMPEG4 data tables. + */ + +-#ifndef MSMPEG4DATA_H +-#define MSMPEG4DATA_H ++#ifndef FFMPEG_MSMPEG4DATA_H ++#define FFMPEG_MSMPEG4DATA_H + + #include "common.h" + #include "bitstream.h" +@@ -67,7 +67,7 @@ + + #define WMV1_SCANTABLE_COUNT 4 + +-extern const uint8_t *wmv1_scantable[WMV1_SCANTABLE_COUNT+1]; ++extern const uint8_t wmv1_scantable[WMV1_SCANTABLE_COUNT][64]; + + #define NB_RL_TABLES 6 + +@@ -97,4 +97,4 @@ + extern const uint8_t wmv2_scantableA[64]; + extern const uint8_t wmv2_scantableB[64]; + +-#endif /* MSMPEG4DATA_H */ ++#endif /* FFMPEG_MSMPEG4DATA_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/msmpeg4.h ffmpeg-free-0.svn20080206/libavcodec/msmpeg4.h +--- mplayer-1.0~rc2-12/libavcodec/msmpeg4.h 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/msmpeg4.h 2007-11-08 00:41:39.000000000 +0100 +@@ -23,10 +23,31 @@ + * @file msmpeg4.h + */ + +-#ifndef MSMPEG4_H +-#define MSMPEG4_H ++#ifndef FFMPEG_MSMPEG4_H ++#define FFMPEG_MSMPEG4_H + + #include "config.h" ++#include "avcodec.h" ++#include "dsputil.h" ++#include "mpegvideo.h" ++ ++#define INTER_INTRA_VLC_BITS 3 ++#define MB_NON_INTRA_VLC_BITS 9 ++#define MB_INTRA_VLC_BITS 9 ++ ++extern VLC ff_mb_non_intra_vlc[4]; ++extern VLC ff_inter_intra_vlc; ++ ++void ff_msmpeg4_code012(PutBitContext *pb, int n); ++void ff_msmpeg4_encode_block(MpegEncContext * s, DCTELEM * block, int n); ++void ff_msmpeg4_handle_slices(MpegEncContext *s); ++void ff_msmpeg4_encode_motion(MpegEncContext * s, int mx, int my); ++int ff_msmpeg4_coded_block_pred(MpegEncContext * s, int n, ++ uint8_t **coded_block_ptr); ++int ff_msmpeg4_decode_motion(MpegEncContext * s, int *mx_ptr, int *my_ptr); ++int ff_msmpeg4_decode_block(MpegEncContext * s, DCTELEM * block, ++ int n, int coded, const uint8_t *scan_table); ++int ff_wmv2_decode_mb(MpegEncContext *s, DCTELEM block[6][64]); + + #define ENABLE_MSMPEG4_DECODER (ENABLE_MSMPEG4V1_DECODER || \ + ENABLE_MSMPEG4V2_DECODER || \ +@@ -41,4 +62,4 @@ + #define ENABLE_WMV_DECODER (ENABLE_WMV1_DECODER || ENABLE_WMV2_DECODER) + #define ENABLE_WMV_ENCODER (ENABLE_WMV1_ENCODER || ENABLE_WMV2_ENCODER) + +-#endif /* MSMPEG4_H */ ++#endif /* FFMPEG_MSMPEG4_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/msrle.c ffmpeg-free-0.svn20080206/libavcodec/msrle.c +--- mplayer-1.0~rc2-12/libavcodec/msrle.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/msrle.c 2008-03-20 19:10:58.000000000 +0100 +@@ -43,7 +43,7 @@ + AVCodecContext *avctx; + AVFrame frame; + +- unsigned char *buf; ++ const unsigned char *buf; + int size; + + } MsrleContext; +@@ -250,7 +250,7 @@ + + static int msrle_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + MsrleContext *s = avctx->priv_data; + +diff -u mplayer-1.0~rc2-12/libavcodec/msvideo1.c ffmpeg-free-0.svn20080206/libavcodec/msvideo1.c +--- mplayer-1.0~rc2-12/libavcodec/msvideo1.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/msvideo1.c 2008-03-20 19:10:59.000000000 +0100 +@@ -52,7 +52,7 @@ + DSPContext dsp; + AVFrame frame; + +- unsigned char *buf; ++ const unsigned char *buf; + int size; + + int mode_8bit; /* if it's not 8-bit, it's 16-bit */ +@@ -297,7 +297,7 @@ + + static int msvideo1_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + Msvideo1Context *s = avctx->priv_data; + +Only in ffmpeg-free-0.svn20080206/libavcodec: nellymoserdec.c +diff -u mplayer-1.0~rc2-12/libavcodec/noise_bsf.c ffmpeg-free-0.svn20080206/libavcodec/noise_bsf.c +--- mplayer-1.0~rc2-12/libavcodec/noise_bsf.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/noise_bsf.c 2008-03-20 19:10:59.000000000 +0100 +@@ -24,8 +24,8 @@ + static int noise(AVBitStreamFilterContext *bsfc, AVCodecContext *avctx, const char *args, + uint8_t **poutbuf, int *poutbuf_size, + const uint8_t *buf, int buf_size, int keyframe){ +- int amount= args ? atoi(args) : 10000; + unsigned int *state= bsfc->priv_data; ++ int amount= args ? atoi(args) : (*state % 10001+1); + int i; + + *poutbuf= av_malloc(buf_size + FF_INPUT_BUFFER_PADDING_SIZE); +diff -u mplayer-1.0~rc2-12/libavcodec/nuv.c ffmpeg-free-0.svn20080206/libavcodec/nuv.c +--- mplayer-1.0~rc2-12/libavcodec/nuv.c 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/nuv.c 2008-03-20 19:10:59.000000000 +0100 +@@ -69,7 +69,7 @@ + * \param width width of the video frame + * \param height height of the video frame + */ +-static void copy_frame(AVFrame *f, uint8_t *src, ++static void copy_frame(AVFrame *f, const uint8_t *src, + int width, int height) { + AVPicture pic; + avpicture_fill(&pic, src, PIX_FMT_YUV420P, width, height); +@@ -80,7 +80,7 @@ + * \brief extract quantization tables from codec data into our context + */ + static int get_quant(AVCodecContext *avctx, NuvContext *c, +- uint8_t *buf, int size) { ++ const uint8_t *buf, int size) { + int i; + if (size < 2 * 64 * 4) { + av_log(avctx, AV_LOG_ERROR, "insufficient rtjpeg quant data\n"); +@@ -129,7 +129,7 @@ + } + + static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, +- uint8_t *buf, int buf_size) { ++ const uint8_t *buf, int buf_size) { + NuvContext *c = avctx->priv_data; + AVFrame *picture = data; + int orig_size = buf_size; +diff -u mplayer-1.0~rc2-12/libavcodec/opt.c ffmpeg-free-0.svn20080206/libavcodec/opt.c +--- mplayer-1.0~rc2-12/libavcodec/opt.c 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/opt.c 2008-03-20 19:10:59.000000000 +0100 +@@ -69,6 +69,7 @@ + case FF_OPT_TYPE_RATIONAL: + if((int)num == num) *(AVRational*)dst= (AVRational){num*intnum, den}; + else *(AVRational*)dst= av_d2q(num*intnum/den, 1<<24); ++ break; + default: + return NULL; + } +@@ -107,6 +108,13 @@ + 0 + }; + ++static int hexchar2int(char c) { ++ if (c >= '0' && c <= '9') return c - '0'; ++ if (c >= 'a' && c <= 'f') return c - 'a' + 10; ++ if (c >= 'A' && c <= 'F') return c - 'A' + 10; ++ return -1; ++} ++ + const AVOption *av_set_string(void *obj, const char *name, const char *val){ + const AVOption *o= av_find_opt(obj, name, NULL, 0, 0); + if(o && o->offset==0 && o->type == FF_OPT_TYPE_CONST && o->unit){ +@@ -114,6 +122,29 @@ + } + if(!o || !val || o->offset<=0) + return NULL; ++ if(o->type == FF_OPT_TYPE_BINARY){ ++ uint8_t **dst = (uint8_t **)(((uint8_t*)obj) + o->offset); ++ int *lendst = (int *)(dst + 1); ++ uint8_t *bin, *ptr; ++ int len = strlen(val); ++ av_freep(dst); ++ *lendst = 0; ++ if (len & 1) return NULL; ++ len /= 2; ++ ptr = bin = av_malloc(len); ++ while (*val) { ++ int a = hexchar2int(*val++); ++ int b = hexchar2int(*val++); ++ if (a < 0 || b < 0) { ++ av_free(bin); ++ return NULL; ++ } ++ *ptr++ = (a << 4) | b; ++ } ++ *dst = bin; ++ *lendst = len; ++ return o; ++ } + if(o->type != FF_OPT_TYPE_STRING){ + for(;;){ + int i; +@@ -159,7 +190,7 @@ + return NULL; + } + +- memcpy(((uint8_t*)obj) + o->offset, val, sizeof(val)); ++ memcpy(((uint8_t*)obj) + o->offset, &val, sizeof(val)); + return o; + } + +@@ -183,6 +214,8 @@ + const char *av_get_string(void *obj, const char *name, const AVOption **o_out, char *buf, int buf_len){ + const AVOption *o= av_find_opt(obj, name, NULL, 0, 0); + void *dst; ++ uint8_t *bin; ++ int len, i; + if(!o || o->offset<=0) + return NULL; + if(o->type != FF_OPT_TYPE_STRING && (!buf || !buf_len)) +@@ -191,9 +224,6 @@ + dst= ((uint8_t*)obj) + o->offset; + if(o_out) *o_out= o; + +- if(o->type == FF_OPT_TYPE_STRING) +- return dst; +- + switch(o->type){ + case FF_OPT_TYPE_FLAGS: snprintf(buf, buf_len, "0x%08X",*(int *)dst);break; + case FF_OPT_TYPE_INT: snprintf(buf, buf_len, "%d" , *(int *)dst);break; +@@ -201,6 +231,13 @@ + case FF_OPT_TYPE_FLOAT: snprintf(buf, buf_len, "%f" , *(float *)dst);break; + case FF_OPT_TYPE_DOUBLE: snprintf(buf, buf_len, "%f" , *(double *)dst);break; + case FF_OPT_TYPE_RATIONAL: snprintf(buf, buf_len, "%d/%d", ((AVRational*)dst)->num, ((AVRational*)dst)->den);break; ++ case FF_OPT_TYPE_STRING: return *(void**)dst; ++ case FF_OPT_TYPE_BINARY: ++ len = *(int*)(((uint8_t *)dst) + sizeof(uint8_t *)); ++ if(len >= (buf_len + 1)/2) return NULL; ++ bin = *(uint8_t**)dst; ++ for(i = 0; i < len; i++) snprintf(buf + i*2, 3, "%02X", bin[i]); ++ break; + default: return NULL; + } + return buf; +@@ -307,6 +344,9 @@ + case FF_OPT_TYPE_RATIONAL: + av_log( av_log_obj, AV_LOG_INFO, "%-7s ", "" ); + break; ++ case FF_OPT_TYPE_BINARY: ++ av_log( av_log_obj, AV_LOG_INFO, "%-7s ", "" ); ++ break; + case FF_OPT_TYPE_CONST: + default: + av_log( av_log_obj, AV_LOG_INFO, "%-7s ", "" ); +@@ -374,6 +414,7 @@ + } + break; + case FF_OPT_TYPE_STRING: ++ case FF_OPT_TYPE_BINARY: + /* Cannot set default for string as default_val is of type * double */ + break; + default: +diff -u mplayer-1.0~rc2-12/libavcodec/opt.h ffmpeg-free-0.svn20080206/libavcodec/opt.h +--- mplayer-1.0~rc2-12/libavcodec/opt.h 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/opt.h 2007-12-17 18:41:24.000000000 +0100 +@@ -19,8 +19,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef AVOPT_H +-#define AVOPT_H ++#ifndef FFMPEG_OPT_H ++#define FFMPEG_OPT_H + + /** + * @file opt.h +@@ -37,6 +37,7 @@ + FF_OPT_TYPE_FLOAT, + FF_OPT_TYPE_STRING, + FF_OPT_TYPE_RATIONAL, ++ FF_OPT_TYPE_BINARY, ///< offset must point to a pointer immediately followed by an int for the length + FF_OPT_TYPE_CONST=128, + }; + +@@ -84,4 +85,4 @@ + void av_opt_set_defaults(void *s); + void av_opt_set_defaults2(void *s, int mask, int flags); + +-#endif ++#endif /* FFMPEG_OPT_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/parser.c ffmpeg-free-0.svn20080206/libavcodec/parser.c +--- mplayer-1.0~rc2-12/libavcodec/parser.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/parser.c 2008-03-20 19:10:59.000000000 +0100 +@@ -24,6 +24,11 @@ + + AVCodecParser *av_first_parser = NULL; + ++AVCodecParser* av_parser_next(AVCodecParser *p){ ++ if(p) return p->next; ++ else return av_first_parser; ++} ++ + void av_register_codec_parser(AVCodecParser *parser) + { + parser->next = av_first_parser; +diff -u mplayer-1.0~rc2-12/libavcodec/parser.h ffmpeg-free-0.svn20080206/libavcodec/parser.h +--- mplayer-1.0~rc2-12/libavcodec/parser.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/parser.h 2007-10-17 11:21:52.000000000 +0200 +@@ -59,4 +59,4 @@ + void ff_parse_close(AVCodecParserContext *s); + void ff_parse1_close(AVCodecParserContext *s); + +-#endif /* !FFMPEG_PARSER_H */ ++#endif /* FFMPEG_PARSER_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/pcm.c ffmpeg-free-0.svn20080206/libavcodec/pcm.c +--- mplayer-1.0~rc2-12/libavcodec/pcm.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/pcm.c 2008-03-20 19:10:59.000000000 +0100 +@@ -28,6 +28,8 @@ + #include "bitstream.h" // for ff_reverse + #include "bytestream.h" + ++#define MAX_CHANNELS 64 ++ + /* from g711.c by SUN microsystems (unrestricted use) */ + + #define SIGN_BIT (0x80) /* Sign bit for a A-law byte. */ +@@ -353,7 +355,7 @@ + * \param src_len number of bytes in src + */ + static inline void decode_to16(int bps, int le, int us, +- uint8_t **src, short **samples, int src_len) ++ const uint8_t **src, short **samples, int src_len) + { + int usum = us ? -0x8000 : 0; + register int n = src_len / bps; +@@ -371,12 +373,12 @@ + + static int pcm_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + PCMDecode *s = avctx->priv_data; +- int n; ++ int c, n; + short *samples; +- uint8_t *src; ++ const uint8_t *src, *src2[MAX_CHANNELS]; + + samples = data; + src = buf; +@@ -386,10 +388,18 @@ + av_log(avctx, AV_LOG_ERROR, "invalid PCM packet\n"); + return -1; + } ++ if(avctx->channels <= 0 || avctx->channels > MAX_CHANNELS){ ++ av_log(avctx, AV_LOG_ERROR, "PCM channels out of bounds\n"); ++ return -1; ++ } + + buf_size= FFMIN(buf_size, *data_size/2); + *data_size=0; + ++ n = buf_size/avctx->channels; ++ for(c=0;cchannels;c++) ++ src2[c] = &src[c*n]; ++ + switch(avctx->codec->id) { + case CODEC_ID_PCM_S32LE: + decode_to16(4, 1, 0, &src, &samples, buf_size); +@@ -430,6 +440,12 @@ + *samples++ = bytestream_get_le16(&src); + } + break; ++ case CODEC_ID_PCM_S16LE_PLANAR: ++ for(n>>=1;n>0;n--) ++ for(c=0;cchannels;c++) ++ *samples++ = bytestream_get_le16(&src2[c]); ++ src = src2[avctx->channels-1]; ++ break; + case CODEC_ID_PCM_S16BE: + n = buf_size >> 1; + for(;n>0;n--) { +@@ -483,7 +499,8 @@ + return src - buf; + } + +-#define PCM_CODEC(id, name) \ ++#ifdef CONFIG_ENCODERS ++#define PCM_ENCODER(id,name) \ + AVCodec name ## _encoder = { \ + #name, \ + CODEC_TYPE_AUDIO, \ +@@ -493,7 +510,13 @@ + pcm_encode_frame, \ + pcm_encode_close, \ + NULL, \ +-}; \ ++}; ++#else ++#define PCM_ENCODER(id,name) ++#endif ++ ++#ifdef CONFIG_DECODERS ++#define PCM_DECODER(id,name) \ + AVCodec name ## _decoder = { \ + #name, \ + CODEC_TYPE_AUDIO, \ +@@ -503,25 +526,30 @@ + NULL, \ + NULL, \ + pcm_decode_frame, \ +-} ++}; ++#else ++#define PCM_DECODER(id,name) ++#endif + +-PCM_CODEC(CODEC_ID_PCM_S32LE, pcm_s32le); +-PCM_CODEC(CODEC_ID_PCM_S32BE, pcm_s32be); +-PCM_CODEC(CODEC_ID_PCM_U32LE, pcm_u32le); +-PCM_CODEC(CODEC_ID_PCM_U32BE, pcm_u32be); +-PCM_CODEC(CODEC_ID_PCM_S24LE, pcm_s24le); +-PCM_CODEC(CODEC_ID_PCM_S24BE, pcm_s24be); +-PCM_CODEC(CODEC_ID_PCM_U24LE, pcm_u24le); +-PCM_CODEC(CODEC_ID_PCM_U24BE, pcm_u24be); +-PCM_CODEC(CODEC_ID_PCM_S24DAUD, pcm_s24daud); +-PCM_CODEC(CODEC_ID_PCM_S16LE, pcm_s16le); +-PCM_CODEC(CODEC_ID_PCM_S16BE, pcm_s16be); +-PCM_CODEC(CODEC_ID_PCM_U16LE, pcm_u16le); +-PCM_CODEC(CODEC_ID_PCM_U16BE, pcm_u16be); +-PCM_CODEC(CODEC_ID_PCM_S8, pcm_s8); +-PCM_CODEC(CODEC_ID_PCM_U8, pcm_u8); +-PCM_CODEC(CODEC_ID_PCM_ALAW, pcm_alaw); +-PCM_CODEC(CODEC_ID_PCM_MULAW, pcm_mulaw); +-PCM_CODEC(CODEC_ID_PCM_ZORK, pcm_zork); ++#define PCM_CODEC(id, name) \ ++PCM_ENCODER(id,name) PCM_DECODER(id,name) + +-#undef PCM_CODEC ++PCM_CODEC (CODEC_ID_PCM_S32LE, pcm_s32le); ++PCM_CODEC (CODEC_ID_PCM_S32BE, pcm_s32be); ++PCM_CODEC (CODEC_ID_PCM_U32LE, pcm_u32le); ++PCM_CODEC (CODEC_ID_PCM_U32BE, pcm_u32be); ++PCM_CODEC (CODEC_ID_PCM_S24LE, pcm_s24le); ++PCM_CODEC (CODEC_ID_PCM_S24BE, pcm_s24be); ++PCM_CODEC (CODEC_ID_PCM_U24LE, pcm_u24le); ++PCM_CODEC (CODEC_ID_PCM_U24BE, pcm_u24be); ++PCM_CODEC (CODEC_ID_PCM_S24DAUD, pcm_s24daud); ++PCM_CODEC (CODEC_ID_PCM_S16LE, pcm_s16le); ++PCM_DECODER(CODEC_ID_PCM_S16LE_PLANAR, pcm_s16le_planar); ++PCM_CODEC (CODEC_ID_PCM_S16BE, pcm_s16be); ++PCM_CODEC (CODEC_ID_PCM_U16LE, pcm_u16le); ++PCM_CODEC (CODEC_ID_PCM_U16BE, pcm_u16be); ++PCM_CODEC (CODEC_ID_PCM_S8, pcm_s8); ++PCM_CODEC (CODEC_ID_PCM_U8, pcm_u8); ++PCM_CODEC (CODEC_ID_PCM_ALAW, pcm_alaw); ++PCM_CODEC (CODEC_ID_PCM_MULAW, pcm_mulaw); ++PCM_CODEC (CODEC_ID_PCM_ZORK, pcm_zork); +Only in ffmpeg-free-0.svn20080206/libavcodec: pcx.c +diff -u mplayer-1.0~rc2-12/libavcodec/pngdec.c ffmpeg-free-0.svn20080206/libavcodec/pngdec.c +--- mplayer-1.0~rc2-12/libavcodec/pngdec.c 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/pngdec.c 2008-03-20 19:10:59.000000000 +0100 +@@ -31,9 +31,9 @@ + //#define DEBUG + + typedef struct PNGDecContext { +- uint8_t *bytestream; +- uint8_t *bytestream_start; +- uint8_t *bytestream_end; ++ const uint8_t *bytestream; ++ const uint8_t *bytestream_start; ++ const uint8_t *bytestream_end; + AVFrame picture; + + int state; +@@ -312,7 +312,7 @@ + + static int decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + PNGDecContext * const s = avctx->priv_data; + AVFrame *picture = data; +diff -u mplayer-1.0~rc2-12/libavcodec/pngenc.c ffmpeg-free-0.svn20080206/libavcodec/pngenc.c +--- mplayer-1.0~rc2-12/libavcodec/pngenc.c 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/pngenc.c 2008-03-20 19:10:59.000000000 +0100 +@@ -144,6 +144,7 @@ + AVFrame * const p= (AVFrame*)&s->picture; + int bit_depth, color_type, y, len, row_size, ret, is_progressive; + int bits_per_pixel, pass_row_size; ++ int compression_level; + uint8_t *ptr; + uint8_t *crow_buf = NULL; + uint8_t *tmp_buf = NULL; +@@ -187,7 +188,10 @@ + s->zstream.zalloc = ff_png_zalloc; + s->zstream.zfree = ff_png_zfree; + s->zstream.opaque = NULL; +- ret = deflateInit2(&s->zstream, Z_DEFAULT_COMPRESSION, ++ compression_level = avctx->compression_level == FF_COMPRESSION_DEFAULT ? ++ Z_DEFAULT_COMPRESSION : ++ av_clip(avctx->compression_level, 0, 9); ++ ret = deflateInit2(&s->zstream, compression_level, + Z_DEFLATED, 15, 8, Z_DEFAULT_STRATEGY); + if (ret != Z_OK) + return -1; +diff -u mplayer-1.0~rc2-12/libavcodec/png.h ffmpeg-free-0.svn20080206/libavcodec/png.h +--- mplayer-1.0~rc2-12/libavcodec/png.h 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/png.h 2007-10-17 11:37:46.000000000 +0200 +@@ -19,8 +19,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef AVCODEC_PNG_H +-#define AVCODEC_PNG_H ++#ifndef FFMPEG_PNG_H ++#define FFMPEG_PNG_H + + #include + +@@ -71,4 +71,4 @@ + /* compute the row size of an interleaved pass */ + extern int ff_png_pass_row_size(int pass, int bits_per_pixel, int width); + +-#endif ++#endif /* FFMPEG_PNG_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/pnmenc.c ffmpeg-free-0.svn20080206/libavcodec/pnmenc.c +--- mplayer-1.0~rc2-12/libavcodec/pnmenc.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/pnmenc.c 2008-03-20 19:10:59.000000000 +0100 +@@ -34,7 +34,7 @@ + + static int pnm_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + PNMContext * const s = avctx->priv_data; + AVFrame *picture = data; +diff -u mplayer-1.0~rc2-12/libavcodec/pnm.h ffmpeg-free-0.svn20080206/libavcodec/pnm.h +--- mplayer-1.0~rc2-12/libavcodec/pnm.h 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/pnm.h 2007-10-17 11:37:46.000000000 +0200 +@@ -19,8 +19,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef PNM_H +-#define PNM_H ++#ifndef FFMPEG_PNM_H ++#define FFMPEG_PNM_H + + #include "avcodec.h" + +@@ -34,4 +34,4 @@ + + int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * const s); + +-#endif /* PNM_H */ ++#endif /* FFMPEG_PNM_H */ +Common subdirectories: mplayer-1.0~rc2-12/libavcodec/ppc and ffmpeg-free-0.svn20080206/libavcodec/ppc +Common subdirectories: mplayer-1.0~rc2-12/libavcodec/ps2 and ffmpeg-free-0.svn20080206/libavcodec/ps2 +diff -u mplayer-1.0~rc2-12/libavcodec/ptx.c ffmpeg-free-0.svn20080206/libavcodec/ptx.c +--- mplayer-1.0~rc2-12/libavcodec/ptx.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/ptx.c 2008-03-20 19:10:59.000000000 +0100 +@@ -28,18 +28,17 @@ + static int ptx_init(AVCodecContext *avctx) { + PTXContext *s = avctx->priv_data; + +- avcodec_get_frame_defaults((AVFrame*)&s->picture); +- avctx->coded_frame= (AVFrame*)&s->picture; +- s->picture.data[0] = NULL; ++ avcodec_get_frame_defaults(&s->picture); ++ avctx->coded_frame= &s->picture; + + return 0; + } + + static int ptx_decode_frame(AVCodecContext *avctx, void *data, int *data_size, +- uint8_t *buf, int buf_size) { ++ const uint8_t *buf, int buf_size) { + PTXContext * const s = avctx->priv_data; + AVFrame *picture = data; +- AVFrame * const p = (AVFrame *)&s->picture; ++ AVFrame * const p = &s->picture; + unsigned int offset, w, h, y, stride, bytes_per_pixel; + uint8_t *ptr; + +@@ -89,7 +88,7 @@ + buf += w*bytes_per_pixel; + } + +- *picture = *(AVFrame *)&s->picture; ++ *picture = s->picture; + *data_size = sizeof(AVPicture); + + return offset + w*h*bytes_per_pixel; +diff -u mplayer-1.0~rc2-12/libavcodec/qdm2.c ffmpeg-free-0.svn20080206/libavcodec/qdm2.c +--- mplayer-1.0~rc2-12/libavcodec/qdm2.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/qdm2.c 2008-03-20 19:10:59.000000000 +0100 +@@ -97,16 +97,16 @@ + /** + * A node in the subpacket list + */ +-typedef struct _QDM2SubPNode { ++typedef struct QDM2SubPNode { + QDM2SubPacket *packet; ///< packet +- struct _QDM2SubPNode *next; ///< pointer to next packet in the list, NULL if leaf node ++ struct QDM2SubPNode *next; ///< pointer to next packet in the list, NULL if leaf node + } QDM2SubPNode; + + typedef struct { + float level; + float *samples_im; + float *samples_re; +- float *table; ++ const float *table; + int phase; + int phase_shift; + int duration; +@@ -176,7 +176,7 @@ + QDM2FFT fft; + + /// I/O data +- uint8_t *compressed_data; ++ const uint8_t *compressed_data; + int compressed_size; + float output_buffer[1024]; + +@@ -404,7 +404,7 @@ + * + * @return 0 if checksum is OK + */ +-static uint16_t qdm2_packet_checksum (uint8_t *data, int length, int value) { ++static uint16_t qdm2_packet_checksum (const uint8_t *data, int length, int value) { + int i; + + for (i=0; i < length; i++) +@@ -1598,7 +1598,7 @@ + tone.level = (q->fft_coefs[j].exp < 0) ? 0.0 : fft_tone_level_table[q->superblocktype_2_3 ? 0 : 1][q->fft_coefs[j].exp & 63]; + tone.samples_im = &q->fft.samples_im[ch][offset]; + tone.samples_re = &q->fft.samples_re[ch][offset]; +- tone.table = (float*)fft_tone_sample_table[i][q->fft_coefs[j].offset - (offset << four_i)]; ++ tone.table = fft_tone_sample_table[i][q->fft_coefs[j].offset - (offset << four_i)]; + tone.phase = 64 * q->fft_coefs[j].phase - (offset << 8) - 128; + tone.phase_shift = (2 * q->fft_coefs[j].offset + 1) << (7 - four_i); + tone.duration = i; +@@ -1943,7 +1943,7 @@ + } + + +-static void qdm2_decode (QDM2Context *q, uint8_t *in, int16_t *out) ++static void qdm2_decode (QDM2Context *q, const uint8_t *in, int16_t *out) + { + int ch, i; + const int frame_size = (q->frame_size * q->channels); +@@ -2005,7 +2005,7 @@ + + static int qdm2_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + QDM2Context *s = avctx->priv_data; + +diff -u mplayer-1.0~rc2-12/libavcodec/qdm2data.h ffmpeg-free-0.svn20080206/libavcodec/qdm2data.h +--- mplayer-1.0~rc2-12/libavcodec/qdm2data.h 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/qdm2data.h 2007-10-17 11:37:46.000000000 +0200 +@@ -27,8 +27,8 @@ + * Various QDM2 tables. + */ + +-#ifndef QDM2DATA_H +-#define QDM2DATA_H ++#ifndef FFMPEG_QDM2DATA_H ++#define FFMPEG_QDM2DATA_H + + #include + +@@ -528,4 +528,4 @@ + 0.138071194291115f,0.333333343267441f,0.60947573184967f,1.0f,0.0f, + }; + +-#endif /* QDM2DATA_H */ ++#endif /* FFMPEG_QDM2DATA_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/qdrw.c ffmpeg-free-0.svn20080206/libavcodec/qdrw.c +--- mplayer-1.0~rc2-12/libavcodec/qdrw.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/qdrw.c 2008-03-20 19:10:59.000000000 +0100 +@@ -34,7 +34,7 @@ + + static int decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + QdrawContext * const a = avctx->priv_data; + AVFrame * const p= (AVFrame*)&a->pic; +@@ -90,7 +90,7 @@ + buf += 18; /* skip unneeded data */ + for (i = 0; i < avctx->height; i++) { + int size, left, code, pix; +- uint8_t *next; ++ const uint8_t *next; + uint8_t *out; + int tsize = 0; + +diff -u mplayer-1.0~rc2-12/libavcodec/qpeg.c ffmpeg-free-0.svn20080206/libavcodec/qpeg.c +--- mplayer-1.0~rc2-12/libavcodec/qpeg.c 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/qpeg.c 2008-03-20 19:10:59.000000000 +0100 +@@ -33,7 +33,7 @@ + uint8_t *refdata; + } QpegContext; + +-static void qpeg_decode_intra(uint8_t *src, uint8_t *dst, int size, ++static void qpeg_decode_intra(const uint8_t *src, uint8_t *dst, int size, + int stride, int width, int height) + { + int i; +@@ -115,9 +115,9 @@ + { 0x00, 0x20, 0x18, 0x08, 0x18, 0x10, 0x20, 0x10, 0x08, 0x10, 0x20, 0x20, 0x08, 0x10, 0x18, 0x04}; + + /* Decodes delta frames */ +-static void qpeg_decode_inter(uint8_t *src, uint8_t *dst, int size, ++static void qpeg_decode_inter(const uint8_t *src, uint8_t *dst, int size, + int stride, int width, int height, +- int delta, uint8_t *ctable, uint8_t *refdata) ++ int delta, const uint8_t *ctable, uint8_t *refdata) + { + int i, j; + int code; +@@ -249,7 +249,7 @@ + + static int decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + QpegContext * const a = avctx->priv_data; + AVFrame * const p= (AVFrame*)&a->pic; +diff -u mplayer-1.0~rc2-12/libavcodec/qtrle.c ffmpeg-free-0.svn20080206/libavcodec/qtrle.c +--- mplayer-1.0~rc2-12/libavcodec/qtrle.c 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/qtrle.c 2008-03-20 19:10:59.000000000 +0100 +@@ -45,7 +45,7 @@ + DSPContext dsp; + AVFrame frame; + +- unsigned char *buf; ++ const unsigned char *buf; + int size; + + } QtrleContext; +@@ -530,7 +530,7 @@ + + static int qtrle_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + QtrleContext *s = avctx->priv_data; + +diff -u mplayer-1.0~rc2-12/libavcodec/qtrleenc.c ffmpeg-free-0.svn20080206/libavcodec/qtrleenc.c +--- mplayer-1.0~rc2-12/libavcodec/qtrleenc.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/qtrleenc.c 2008-03-20 19:10:59.000000000 +0100 +@@ -254,7 +254,7 @@ + + bytestream_put_be32(&buf, 0); // CHUNK SIZE, patched later + +- if (start_line == 0 && end_line == s->avctx->height || start_line == s->avctx->height) ++ if ((start_line == 0 && end_line == s->avctx->height) || start_line == s->avctx->height) + bytestream_put_be16(&buf, 0); // header + else { + bytestream_put_be16(&buf, 8); // header +diff -u mplayer-1.0~rc2-12/libavcodec/ra144.c ffmpeg-free-0.svn20080206/libavcodec/ra144.c +--- mplayer-1.0~rc2-12/libavcodec/ra144.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/ra144.c 2008-03-20 19:10:59.000000000 +0100 +@@ -251,7 +251,7 @@ + } + + /* Decode 20-byte input */ +-static void unpack_input(unsigned char *input, unsigned int *output) ++static void unpack_input(const unsigned char *input, unsigned int *output) + { + unsigned int outbuffer[28]; + unsigned short inbuffer[10]; +@@ -427,7 +427,7 @@ + /* Uncompress one block (20 bytes -> 160*2 bytes) */ + static int ra144_decode_frame(AVCodecContext * avctx, + void *vdata, int *data_size, +- uint8_t * buf, int buf_size) ++ const uint8_t * buf, int buf_size) + { + unsigned int a,b,c; + signed short *shptr; +diff -u mplayer-1.0~rc2-12/libavcodec/ra144.h ffmpeg-free-0.svn20080206/libavcodec/ra144.h +--- mplayer-1.0~rc2-12/libavcodec/ra144.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/ra144.h 2007-10-17 11:37:46.000000000 +0200 +@@ -19,8 +19,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef RA144TABLES_H +-#define RA144TABLES_H ++#ifndef FFMPEG_RA144_H ++#define FFMPEG_RA144_H + + /* 14.4 data tables */ + static const unsigned short sqrt_table[4096]={ +@@ -2425,4 +2425,4 @@ + decodetable6,decodetable7,decodetable8,decodetable9,decodetable10, + decodetable11}; + +-#endif /* RA144TABLES_H */ ++#endif /* FFMPEG_RA144_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/ra288.c ffmpeg-free-0.svn20080206/libavcodec/ra288.c +--- mplayer-1.0~rc2-12/libavcodec/ra288.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/ra288.c 2008-03-20 19:10:59.000000000 +0100 +@@ -49,7 +49,7 @@ + + + /* initial decode */ +-static void unpack(unsigned short *tgt, unsigned char *src, unsigned int len) ++static void unpack(unsigned short *tgt, const unsigned char *src, unsigned int len) + { + int x,y,z; + int n,temp; +@@ -208,7 +208,7 @@ + } + } + +-static void * decode_block(AVCodecContext * avctx, unsigned char *in, signed short int *out,unsigned len) ++static void * decode_block(AVCodecContext * avctx, const unsigned char *in, signed short int *out,unsigned len) + { + int x,y; + Real288_internal *glob=avctx->priv_data; +@@ -228,7 +228,7 @@ + /* Decode a block (celp) */ + static int ra288_decode_frame(AVCodecContext * avctx, + void *data, int *data_size, +- uint8_t * buf, int buf_size) ++ const uint8_t * buf, int buf_size) + { + void *datao; + +diff -u mplayer-1.0~rc2-12/libavcodec/ra288.h ffmpeg-free-0.svn20080206/libavcodec/ra288.h +--- mplayer-1.0~rc2-12/libavcodec/ra288.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/ra288.h 2007-10-17 11:37:46.000000000 +0200 +@@ -19,8 +19,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef RA288TABLES_H +-#define RA288TABLES_H ++#ifndef FFMPEG_RA288_H ++#define FFMPEG_RA288_H + + static const float amptable[8]={ 0.515625, 0.90234375, 1.57910156, 2.76342773, + -0.515625,-0.90234375,-1.57910156,-2.76342773 }; +@@ -202,4 +202,4 @@ + 0.553955078, 0.50201416, 0.454956055, 0.41229248, 0.373657227 + }; + +-#endif /* RA288TABLES_H */ ++#endif /* FFMPEG_RA288_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/rangecoder.c ffmpeg-free-0.svn20080206/libavcodec/rangecoder.c +--- mplayer-1.0~rc2-12/libavcodec/rangecoder.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/rangecoder.c 2008-03-20 19:10:59.000000000 +0100 +@@ -109,9 +109,10 @@ + return c->bytestream - c->bytestream_start; + } + +-#if 0 //selftest ++#ifdef TEST + #define SIZE 10240 +-int main(){ ++#undef random ++int main(void){ + RangeCoder c; + uint8_t b[9*SIZE]; + uint8_t r[9*SIZE]; +@@ -133,7 +134,7 @@ + STOP_TIMER("put_rac") + } + +- ff_put_rac_terminate(&c); ++ ff_rac_terminate(&c); + + ff_init_range_decoder(&c, b, SIZE); + +@@ -148,4 +149,4 @@ + + return 0; + } +-#endif ++#endif /* TEST */ +diff -u mplayer-1.0~rc2-12/libavcodec/rangecoder.h ffmpeg-free-0.svn20080206/libavcodec/rangecoder.h +--- mplayer-1.0~rc2-12/libavcodec/rangecoder.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/rangecoder.h 2007-10-17 11:37:46.000000000 +0200 +@@ -24,8 +24,8 @@ + * Range coder. + */ + +-#ifndef AVCODEC_RANGECODER_H +-#define AVCODEC_RANGECODER_H ++#ifndef FFMPEG_RANGECODER_H ++#define FFMPEG_RANGECODER_H + + #include + #include +@@ -138,4 +138,4 @@ + #endif + } + +-#endif // AVCODEC_RANGECODER_H ++#endif /* FFMPEG_RANGECODER_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/ratecontrol.c ffmpeg-free-0.svn20080206/libavcodec/ratecontrol.c +--- mplayer-1.0~rc2-12/libavcodec/ratecontrol.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/ratecontrol.c 2008-03-20 19:10:59.000000000 +0100 +@@ -138,7 +138,7 @@ + i+= s->max_b_frames; + if(i<=0 || i>=INT_MAX / sizeof(RateControlEntry)) + return -1; +- rcc->entry = (RateControlEntry*)av_mallocz(i*sizeof(RateControlEntry)); ++ rcc->entry = av_mallocz(i*sizeof(RateControlEntry)); + rcc->num_entries= i; + + /* init all to skipped p frames (with b frames we might have a not encoded frame at the end FIXME) */ +diff -u mplayer-1.0~rc2-12/libavcodec/ratecontrol.h ffmpeg-free-0.svn20080206/libavcodec/ratecontrol.h +--- mplayer-1.0~rc2-12/libavcodec/ratecontrol.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/ratecontrol.h 2007-10-17 11:37:46.000000000 +0200 +@@ -20,8 +20,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef AVCODEC_RATECONTROL_H +-#define AVCODEC_RATECONTROL_H ++#ifndef FFMPEG_RATECONTROL_H ++#define FFMPEG_RATECONTROL_H + + /** + * @file ratecontrol.h +@@ -101,5 +101,5 @@ + void ff_xvid_rate_control_uninit(struct MpegEncContext *s); + float ff_xvid_rate_estimate_qscale(struct MpegEncContext *s, int dry_run); + +-#endif /* AVCODEC_RATECONTROL_H */ ++#endif /* FFMPEG_RATECONTROL_H */ + +diff -u mplayer-1.0~rc2-12/libavcodec/rawdec.c ffmpeg-free-0.svn20080206/libavcodec/rawdec.c +--- mplayer-1.0~rc2-12/libavcodec/rawdec.c 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/rawdec.c 2008-03-20 19:10:59.000000000 +0100 +@@ -96,7 +96,7 @@ + + static int raw_decode(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + RawVideoContext *context = avctx->priv_data; + +diff -u mplayer-1.0~rc2-12/libavcodec/raw.h ffmpeg-free-0.svn20080206/libavcodec/raw.h +--- mplayer-1.0~rc2-12/libavcodec/raw.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/raw.h 2007-10-17 11:37:46.000000000 +0200 +@@ -24,8 +24,8 @@ + * Raw Video Codec + */ + +-#ifndef AVCODEC_RAW_H +-#define AVCODEC_RAW_H ++#ifndef FFMPEG_RAW_H ++#define FFMPEG_RAW_H + + #include "avcodec.h" + +@@ -36,4 +36,4 @@ + + extern const PixelFormatTag ff_raw_pixelFormatTags[]; + +-#endif /* AVCODEC_RAW_H */ ++#endif /* FFMPEG_RAW_H */ +Only in ffmpeg-free-0.svn20080206/libavcodec: rectangle.h +diff -u mplayer-1.0~rc2-12/libavcodec/resample.c ffmpeg-free-0.svn20080206/libavcodec/resample.c +--- mplayer-1.0~rc2-12/libavcodec/resample.c 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/resample.c 2008-03-20 19:10:59.000000000 +0100 +@@ -133,14 +133,14 @@ + + if ( input_channels > 2) + { +- av_log(NULL, AV_LOG_ERROR, "Resampling with input channels greater than 2 unsupported."); ++ av_log(NULL, AV_LOG_ERROR, "Resampling with input channels greater than 2 unsupported.\n"); + return NULL; + } + + s = av_mallocz(sizeof(ReSampleContext)); + if (!s) + { +- av_log(NULL, AV_LOG_ERROR, "Can't allocate memory for resample context."); ++ av_log(NULL, AV_LOG_ERROR, "Can't allocate memory for resample context.\n"); + return NULL; + } + +@@ -185,15 +185,15 @@ + + /* XXX: move those malloc to resample init code */ + for(i=0; ifilter_channels; i++){ +- bufin[i]= (short*) av_malloc( (nb_samples + s->temp_len) * sizeof(short) ); ++ bufin[i]= av_malloc( (nb_samples + s->temp_len) * sizeof(short) ); + memcpy(bufin[i], s->temp[i], s->temp_len * sizeof(short)); + buftmp2[i] = bufin[i] + s->temp_len; + } + + /* make some zoom to avoid round pb */ +- lenout= (int)(4*nb_samples * s->ratio) + 16; +- bufout[0]= (short*) av_malloc( lenout * sizeof(short) ); +- bufout[1]= (short*) av_malloc( lenout * sizeof(short) ); ++ lenout= 4*nb_samples * s->ratio + 16; ++ bufout[0]= av_malloc( lenout * sizeof(short) ); ++ bufout[1]= av_malloc( lenout * sizeof(short) ); + + if (s->input_channels == 2 && + s->output_channels == 1) { +diff -u mplayer-1.0~rc2-12/libavcodec/rle.h ffmpeg-free-0.svn20080206/libavcodec/rle.h +--- mplayer-1.0~rc2-12/libavcodec/rle.h 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/rle.h 2007-10-17 11:37:46.000000000 +0200 +@@ -18,8 +18,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef RLE_H +-#define RLE_H ++#ifndef FFMPEG_RLE_H ++#define FFMPEG_RLE_H + + #include + +@@ -36,4 +36,4 @@ + int ff_rle_encode(uint8_t *outbuf, int out_size, const uint8_t *inbuf, int bpp, int w, + int add_rep, int xor_rep, int add_raw, int xor_raw); + +-#endif /* RLE_H */ ++#endif /* FFMPEG_RLE_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/rl.h ffmpeg-free-0.svn20080206/libavcodec/rl.h +--- mplayer-1.0~rc2-12/libavcodec/rl.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/rl.h 2007-10-17 11:37:46.000000000 +0200 +@@ -24,8 +24,8 @@ + * rl header. + */ + +-#ifndef AVCODEC_RL_H +-#define AVCODEC_RL_H ++#ifndef FFMPEG_RL_H ++#define FFMPEG_RL_H + + #include + #include "bitstream.h" +@@ -64,4 +64,4 @@ + return index + level - 1; + } + +-#endif ++#endif /* FFMPEG_RL_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/roqvideodec.c ffmpeg-free-0.svn20080206/libavcodec/roqvideodec.c +--- mplayer-1.0~rc2-12/libavcodec/roqvideodec.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/roqvideodec.c 2008-03-20 19:10:59.000000000 +0100 +@@ -43,8 +43,8 @@ + int vqid, bpos, xpos, ypos, xp, yp, x, y, mx, my; + int frame_stats[2][4] = {{0},{0}}; + roq_qcell *qcell; +- unsigned char *buf = ri->buf; +- unsigned char *buf_end = ri->buf + ri->size; ++ const unsigned char *buf = ri->buf; ++ const unsigned char *buf_end = ri->buf + ri->size; + + while (buf < buf_end) { + chunk_id = bytestream_get_le16(&buf); +@@ -171,7 +171,7 @@ + + static int roq_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + RoqContext *s = avctx->priv_data; + int copy= !s->current_frame->data[0]; +diff -u mplayer-1.0~rc2-12/libavcodec/roqvideo.h ffmpeg-free-0.svn20080206/libavcodec/roqvideo.h +--- mplayer-1.0~rc2-12/libavcodec/roqvideo.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/roqvideo.h 2008-02-02 22:55:56.000000000 +0100 +@@ -19,8 +19,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef AVCODEC_ROQVIDEO_H +-#define AVCODEC_ROQVIDEO_H ++#ifndef FFMPEG_ROQVIDEO_H ++#define FFMPEG_ROQVIDEO_H + + #include "avcodec.h" + #include "dsputil.h" +@@ -51,7 +51,7 @@ + roq_cell cb2x2[256]; + roq_qcell cb4x4[256]; + +- unsigned char *buf; ++ const unsigned char *buf; + int size; + int width, height; + +@@ -89,4 +89,4 @@ + + void ff_apply_motion_8x8(RoqContext *ri, int x, int y, int deltax, int deltay); + +-#endif // AVCODEC_ROQVIDEO_H ++#endif /* FFMPEG_ROQVIDEO_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/rpza.c ffmpeg-free-0.svn20080206/libavcodec/rpza.c +--- mplayer-1.0~rc2-12/libavcodec/rpza.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/rpza.c 2008-03-20 19:10:59.000000000 +0100 +@@ -48,7 +48,7 @@ + DSPContext dsp; + AVFrame frame; + +- unsigned char *buf; ++ const unsigned char *buf; + int size; + + } RpzaContext; +@@ -243,7 +243,7 @@ + + static int rpza_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + RpzaContext *s = avctx->priv_data; + +diff -u mplayer-1.0~rc2-12/libavcodec/rtjpeg.c ffmpeg-free-0.svn20080206/libavcodec/rtjpeg.c +--- mplayer-1.0~rc2-12/libavcodec/rtjpeg.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/rtjpeg.c 2008-03-20 19:10:59.000000000 +0100 +@@ -43,8 +43,8 @@ + * aligned this could be done faster in a different way, e.g. as it is done + * in MPlayer libmpcodecs/native/RTjpegN.c + */ +-static inline int get_block(GetBitContext *gb, DCTELEM *block, uint8_t *scan, +- uint32_t *quant) { ++static inline int get_block(GetBitContext *gb, DCTELEM *block, const uint8_t *scan, ++ const uint32_t *quant) { + int coeff, i, n; + int8_t ac; + uint8_t dc = get_bits(gb, 8); +@@ -97,7 +97,7 @@ + * \return number of bytes consumed from the input buffer + */ + int rtjpeg_decode_frame_yuv420(RTJpegContext *c, AVFrame *f, +- uint8_t *buf, int buf_size) { ++ const uint8_t *buf, int buf_size) { + DECLARE_ALIGNED_16(DCTELEM, block[64]); + GetBitContext gb; + int w = c->w / 16, h = c->h / 16; +@@ -147,7 +147,7 @@ + */ + void rtjpeg_decode_init(RTJpegContext *c, DSPContext *dsp, + int width, int height, +- uint32_t *lquant, uint32_t *cquant) { ++ const uint32_t *lquant, const uint32_t *cquant) { + int i; + c->dsp = dsp; + for (i = 0; i < 64; i++) { +diff -u mplayer-1.0~rc2-12/libavcodec/rtjpeg.h ffmpeg-free-0.svn20080206/libavcodec/rtjpeg.h +--- mplayer-1.0~rc2-12/libavcodec/rtjpeg.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/rtjpeg.h 2008-02-01 17:20:27.000000000 +0100 +@@ -19,8 +19,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef RTJPEG_H +-#define RTJPEG_H ++#ifndef FFMPEG_RTJPEG_H ++#define FFMPEG_RTJPEG_H + + #include + #include +@@ -35,8 +35,8 @@ + + void rtjpeg_decode_init(RTJpegContext *c, DSPContext *dsp, + int width, int height, +- uint32_t *lquant, uint32_t *cquant); ++ const uint32_t *lquant, const uint32_t *cquant); + + int rtjpeg_decode_frame_yuv420(RTJpegContext *c, AVFrame *f, +- uint8_t *buf, int buf_size); +-#endif ++ const uint8_t *buf, int buf_size); ++#endif /* FFMPEG_RTJPEG_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/rv10.c ffmpeg-free-0.svn20080206/libavcodec/rv10.c +--- mplayer-1.0~rc2-12/libavcodec/rv10.c 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/rv10.c 2008-03-20 19:10:59.000000000 +0100 +@@ -597,7 +597,7 @@ + } + + static int rv10_decode_packet(AVCodecContext *avctx, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + MpegEncContext *s = avctx->priv_data; + int mb_count, mb_pos, left, start_mb_x; +@@ -711,13 +711,21 @@ + return buf_size; + } + ++static int get_slice_offset(AVCodecContext *avctx, const uint8_t *buf, int n) ++{ ++ if(avctx->slice_count) return avctx->slice_offset[n]; ++ else return AV_RL32(buf + n*8); ++} ++ + static int rv10_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + MpegEncContext *s = avctx->priv_data; + int i; + AVFrame *pict = data; ++ int slice_count; ++ const uint8_t *slices_hdr = NULL; + + #ifdef DEBUG + av_log(avctx, AV_LOG_DEBUG, "*****frame %d size=%d\n", avctx->frame_number, buf_size); +@@ -728,20 +736,23 @@ + return 0; + } + +- if(avctx->slice_count){ +- for(i=0; islice_count; i++){ +- int offset= avctx->slice_offset[i]; +- int size; +- +- if(i+1 == avctx->slice_count) +- size= buf_size - offset; +- else +- size= avctx->slice_offset[i+1] - offset; ++ if(!avctx->slice_count){ ++ slice_count = (*buf++) + 1; ++ slices_hdr = buf + 4; ++ buf += 8 * slice_count; ++ }else ++ slice_count = avctx->slice_count; ++ ++ for(i=0; icurrent_picture_ptr != NULL && s->mb_y>=s->mb_height){ +Only in ffmpeg-free-0.svn20080206/libavcodec: rv30.c +Only in ffmpeg-free-0.svn20080206/libavcodec: rv30data.h +Only in ffmpeg-free-0.svn20080206/libavcodec: rv30dsp.c +Only in ffmpeg-free-0.svn20080206/libavcodec: rv34.c +Only in ffmpeg-free-0.svn20080206/libavcodec: rv34data.h +Only in ffmpeg-free-0.svn20080206/libavcodec: rv34.h +Only in ffmpeg-free-0.svn20080206/libavcodec: rv34vlc.h +Only in ffmpeg-free-0.svn20080206/libavcodec: rv40.c +Only in ffmpeg-free-0.svn20080206/libavcodec: rv40data.h +Only in ffmpeg-free-0.svn20080206/libavcodec: rv40vlc2.h +diff -u mplayer-1.0~rc2-12/libavcodec/s3tc.c ffmpeg-free-0.svn20080206/libavcodec/s3tc.c +--- mplayer-1.0~rc2-12/libavcodec/s3tc.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/s3tc.c 2008-03-20 19:10:59.000000000 +0100 +@@ -31,8 +31,8 @@ + unsigned int rb0, rb1, rb2, rb3, g0, g1, g2, g3; + uint32_t colors[4], pixels; + +- c0 = le2me_16(*(uint16_t *)(s)); +- c1 = le2me_16(*(uint16_t *)(s+2)); ++ c0 = AV_RL16(s); ++ c1 = AV_RL16(s+2); + + rb0 = (c0<<3 | c0<<8) & 0xf800f8; + rb1 = (c1<<3 | c1<<8) & 0xf800f8; +@@ -60,7 +60,7 @@ + + colors[2] = rb2 + g2 + a; + +- pixels = le2me_32(*(uint32_t *)(s+4)); ++ pixels = AV_RL32(s+4); + for (y=0; y<4; y++) { + for (x=0; x<4; x++) { + a = (alpha & 0x0f) << 28; +diff -u mplayer-1.0~rc2-12/libavcodec/s3tc.h ffmpeg-free-0.svn20080206/libavcodec/s3tc.h +--- mplayer-1.0~rc2-12/libavcodec/s3tc.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/s3tc.h 2007-10-17 11:37:46.000000000 +0200 +@@ -19,8 +19,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef FF_S3TC_H +-#define FF_S3TC_H ++#ifndef FFMPEG_S3TC_H ++#define FFMPEG_S3TC_H + + #include + +@@ -50,4 +50,4 @@ + const unsigned int w, const unsigned int h, + const unsigned int stride); + +-#endif ++#endif /* FFMPEG_S3TC_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/sgidec.c ffmpeg-free-0.svn20080206/libavcodec/sgidec.c +--- mplayer-1.0~rc2-12/libavcodec/sgidec.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/sgidec.c 2008-03-20 19:10:59.000000000 +0100 +@@ -40,7 +40,7 @@ + * @param pixelstride pixel stride of input buffer + * @return size of output in bytes, -1 if buffer overflows + */ +-static int expand_rle_row(uint8_t *in_buf, uint8_t* in_end, ++static int expand_rle_row(const uint8_t *in_buf, const uint8_t* in_end, + unsigned char *out_buf, uint8_t* out_end, int pixelstride) + { + unsigned char pixel, count; +@@ -80,12 +80,12 @@ + * @param s the current image state + * @return 0 if no error, else return error number. + */ +-static int read_rle_sgi(unsigned char* out_buf, uint8_t *in_buf, +- uint8_t *in_end, SgiState* s) ++static int read_rle_sgi(unsigned char* out_buf, const uint8_t *in_buf, ++ const uint8_t *in_end, SgiState* s) + { + uint8_t *dest_row; + unsigned int len = s->height * s->depth * 4; +- uint8_t *start_table = in_buf; ++ const uint8_t *start_table = in_buf; + unsigned int y, z; + unsigned int start_offset; + +@@ -121,10 +121,10 @@ + * @return 0 if read success, otherwise return -1. + */ + static int read_uncompressed_sgi(unsigned char* out_buf, uint8_t* out_end, +- uint8_t *in_buf, uint8_t *in_end, SgiState* s) ++ const uint8_t *in_buf, const uint8_t *in_end, SgiState* s) + { + int x, y, z; +- uint8_t *ptr; ++ const uint8_t *ptr; + unsigned int offset = s->height * s->width; + + /* Test buffer size. */ +@@ -147,12 +147,12 @@ + + static int decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *in_buf, int buf_size) ++ const uint8_t *in_buf, int buf_size) + { + SgiState *s = avctx->priv_data; + AVFrame *picture = data; + AVFrame *p = &s->picture; +- uint8_t *in_end = in_buf + buf_size; ++ const uint8_t *in_end = in_buf + buf_size; + unsigned int dimension, bytes_per_channel, rle; + int ret = 0; + uint8_t *out_buf, *out_end; +diff -u mplayer-1.0~rc2-12/libavcodec/sgi.h ffmpeg-free-0.svn20080206/libavcodec/sgi.h +--- mplayer-1.0~rc2-12/libavcodec/sgi.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/sgi.h 2007-10-17 11:37:46.000000000 +0200 +@@ -19,8 +19,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef SGI_H +-#define SGI_H ++#ifndef FFMPEG_SGI_H ++#define FFMPEG_SGI_H + + /** + * SGI image file signature +@@ -33,5 +33,4 @@ + #define SGI_RGB 3 + #define SGI_RGBA 4 + +-#endif +- ++#endif /* FFMPEG_SGI_H */ +Common subdirectories: mplayer-1.0~rc2-12/libavcodec/sh4 and ffmpeg-free-0.svn20080206/libavcodec/sh4 +diff -u mplayer-1.0~rc2-12/libavcodec/shorten.c ffmpeg-free-0.svn20080206/libavcodec/shorten.c +--- mplayer-1.0~rc2-12/libavcodec/shorten.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/shorten.c 2008-03-20 19:10:59.000000000 +0100 +@@ -268,7 +268,7 @@ + + static int shorten_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + ShortenContext *s = avctx->priv_data; + int i, input_buf_size = 0; +@@ -345,7 +345,7 @@ + s->lpcqoffset = V2LPCQOFFSET; + + if (get_ur_golomb_shorten(&s->gb, FNSIZE) != FN_VERBATIM) { +- av_log(s->avctx, AV_LOG_ERROR, "missing verbatim section at begining of stream\n"); ++ av_log(s->avctx, AV_LOG_ERROR, "missing verbatim section at beginning of stream\n"); + return -1; + } + +diff -u mplayer-1.0~rc2-12/libavcodec/simple_idct.c ffmpeg-free-0.svn20080206/libavcodec/simple_idct.c +--- mplayer-1.0~rc2-12/libavcodec/simple_idct.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/simple_idct.c 2008-03-20 19:10:59.000000000 +0100 +@@ -387,7 +387,7 @@ + col[56] = ((a0 - b0) >> COL_SHIFT); + } + +-void simple_idct_put(uint8_t *dest, int line_size, DCTELEM *block) ++void ff_simple_idct_put(uint8_t *dest, int line_size, DCTELEM *block) + { + int i; + for(i=0; i<8; i++) +@@ -397,7 +397,7 @@ + idctSparseColPut(dest + i, line_size, block + i); + } + +-void simple_idct_add(uint8_t *dest, int line_size, DCTELEM *block) ++void ff_simple_idct_add(uint8_t *dest, int line_size, DCTELEM *block) + { + int i; + for(i=0; i<8; i++) +@@ -407,7 +407,7 @@ + idctSparseColAdd(dest + i, line_size, block + i); + } + +-void simple_idct(DCTELEM *block) ++void ff_simple_idct(DCTELEM *block) + { + int i; + for(i=0; i<8; i++) +@@ -428,7 +428,7 @@ + and the butterfly must be multiplied by 0.5 * sqrt(2.0) */ + #define C_SHIFT (4+1+12) + +-static inline void idct4col(uint8_t *dest, int line_size, const DCTELEM *col) ++static inline void idct4col_put(uint8_t *dest, int line_size, const DCTELEM *col) + { + int c0, c1, c2, c3, a0, a1, a2, a3; + const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; +@@ -465,7 +465,7 @@ + /* XXX: I think a 1.0/sqrt(2) normalization should be needed to + compensate the extra butterfly stage - I don't have the full DV + specification */ +-void simple_idct248_put(uint8_t *dest, int line_size, DCTELEM *block) ++void ff_simple_idct248_put(uint8_t *dest, int line_size, DCTELEM *block) + { + int i; + DCTELEM *ptr; +@@ -491,8 +491,8 @@ + + /* IDCT4 and store */ + for(i=0;i<8;i++) { +- idct4col(dest + i, 2 * line_size, block + i); +- idct4col(dest + line_size + i, 2 * line_size, block + 8 + i); ++ idct4col_put(dest + i, 2 * line_size, block + i); ++ idct4col_put(dest + line_size + i, 2 * line_size, block + 8 + i); + } + } + +@@ -555,7 +555,7 @@ + row[3]= (c0 - c1) >> R_SHIFT; + } + +-void simple_idct84_add(uint8_t *dest, int line_size, DCTELEM *block) ++void ff_simple_idct84_add(uint8_t *dest, int line_size, DCTELEM *block) + { + int i; + +@@ -570,7 +570,7 @@ + } + } + +-void simple_idct48_add(uint8_t *dest, int line_size, DCTELEM *block) ++void ff_simple_idct48_add(uint8_t *dest, int line_size, DCTELEM *block) + { + int i; + +@@ -585,3 +585,17 @@ + } + } + ++void ff_simple_idct44_add(uint8_t *dest, int line_size, DCTELEM *block) ++{ ++ int i; ++ ++ /* IDCT4 on each line */ ++ for(i=0; i<4; i++) { ++ idct4row(block + i*8); ++ } ++ ++ /* IDCT4 and store */ ++ for(i=0; i<4; i++){ ++ idct4col_add(dest + i, line_size, block + i); ++ } ++} +diff -u mplayer-1.0~rc2-12/libavcodec/simple_idct.h ffmpeg-free-0.svn20080206/libavcodec/simple_idct.h +--- mplayer-1.0~rc2-12/libavcodec/simple_idct.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/simple_idct.h 2007-12-09 06:54:59.000000000 +0100 +@@ -25,22 +25,23 @@ + * simple idct header. + */ + +-#ifndef AVCODEC_SIMPLE_IDCT_H +-#define AVCODEC_SIMPLE_IDCT_H ++#ifndef FFMPEG_SIMPLE_IDCT_H ++#define FFMPEG_SIMPLE_IDCT_H + + #include + #include "dsputil.h" + +-void simple_idct_put(uint8_t *dest, int line_size, DCTELEM *block); +-void simple_idct_add(uint8_t *dest, int line_size, DCTELEM *block); ++void ff_simple_idct_put(uint8_t *dest, int line_size, DCTELEM *block); ++void ff_simple_idct_add(uint8_t *dest, int line_size, DCTELEM *block); + void ff_simple_idct_mmx(int16_t *block); + void ff_simple_idct_add_mmx(uint8_t *dest, int line_size, int16_t *block); + void ff_simple_idct_put_mmx(uint8_t *dest, int line_size, int16_t *block); +-void simple_idct(DCTELEM *block); ++void ff_simple_idct(DCTELEM *block); + +-void simple_idct248_put(uint8_t *dest, int line_size, DCTELEM *block); ++void ff_simple_idct248_put(uint8_t *dest, int line_size, DCTELEM *block); + +-void simple_idct84_add(uint8_t *dest, int line_size, DCTELEM *block); +-void simple_idct48_add(uint8_t *dest, int line_size, DCTELEM *block); ++void ff_simple_idct84_add(uint8_t *dest, int line_size, DCTELEM *block); ++void ff_simple_idct48_add(uint8_t *dest, int line_size, DCTELEM *block); ++void ff_simple_idct44_add(uint8_t *dest, int line_size, DCTELEM *block); + +-#endif // AVCODEC_SIMPLE_IDCT_H ++#endif /* FFMPEG_SIMPLE_IDCT_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/smacker.c ffmpeg-free-0.svn20080206/libavcodec/smacker.c +--- mplayer-1.0~rc2-12/libavcodec/smacker.c 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/smacker.c 2008-03-20 19:10:59.000000000 +0100 +@@ -35,6 +35,7 @@ + + #define ALT_BITSTREAM_READER_LE + #include "bitstream.h" ++#include "bytestream.h" + + #define SMKTREE_BITS 9 + #define SMK_NODE 0x80000000 +@@ -344,7 +345,7 @@ + return v; + } + +-static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8_t *buf, int buf_size) ++static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, const uint8_t *buf, int buf_size) + { + SmackVContext * const smk = avctx->priv_data; + uint8_t *out; +@@ -354,7 +355,7 @@ + int i; + int stride; + +- if(buf_size == 769) ++ if(buf_size <= 769) + return 0; + if(smk->pic.data[0]) + avctx->release_buffer(avctx, &smk->pic); +@@ -367,7 +368,6 @@ + } + + /* make the palette available on the way out */ +- out = buf + 1; + pal = (uint32_t*)smk->pic.data[1]; + smk->pic.palette_has_changed = buf[0] & 1; + smk->pic.key_frame = !!(buf[0] & 2); +@@ -376,19 +376,16 @@ + else + smk->pic.pict_type = FF_P_TYPE; + +- for(i = 0; i < 256; i++) { +- int r, g, b; +- r = *out++; +- g = *out++; +- b = *out++; +- *pal++ = (r << 16) | (g << 8) | b; +- } ++ buf++; ++ for(i = 0; i < 256; i++) ++ *pal++ = bytestream_get_be24(&buf); ++ buf_size -= 769; + + last_reset(smk->mmap_tbl, smk->mmap_last); + last_reset(smk->mclr_tbl, smk->mclr_last); + last_reset(smk->full_tbl, smk->full_last); + last_reset(smk->type_tbl, smk->type_last); +- init_get_bits(&gb, buf + 769, (buf_size - 769) * 8); ++ init_get_bits(&gb, buf, buf_size * 8); + + blk = 0; + bw = avctx->width >> 2; +@@ -567,7 +564,7 @@ + /** + * Decode Smacker audio data + */ +-static int smka_decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8_t *buf, int buf_size) ++static int smka_decode_frame(AVCodecContext *avctx, void *data, int *data_size, const uint8_t *buf, int buf_size) + { + GetBitContext gb; + HuffContext h[4]; +diff -u mplayer-1.0~rc2-12/libavcodec/smc.c ffmpeg-free-0.svn20080206/libavcodec/smc.c +--- mplayer-1.0~rc2-12/libavcodec/smc.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/smc.c 2008-03-20 19:10:59.000000000 +0100 +@@ -48,7 +48,7 @@ + DSPContext dsp; + AVFrame frame; + +- unsigned char *buf; ++ const unsigned char *buf; + int size; + + /* SMC color tables */ +@@ -443,7 +443,7 @@ + + static int smc_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + SmcContext *s = avctx->priv_data; + +diff -u mplayer-1.0~rc2-12/libavcodec/snow.c ffmpeg-free-0.svn20080206/libavcodec/snow.c +--- mplayer-1.0~rc2-12/libavcodec/snow.c 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/snow.c 2008-03-20 19:10:59.000000000 +0100 +@@ -339,7 +339,7 @@ + 0, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, + //error:0.000022 + }; +-#endif ++#endif /* 0 */ + + //linear *64 + static const uint8_t obmc8[64]={ +@@ -657,7 +657,7 @@ + if(is_signed) + put_rac(c, state+11 + FFMIN(e,10), v < 0); //11..21 + } +-#endif ++#endif /* 1 */ + }else{ + put_rac(c, state+0, 1); + } +@@ -1078,7 +1078,7 @@ + #else + inv_lift(temp , b , b+w2, 1, 1, 1, width, 1, 2, 2, 0, 1); + inv_lift(temp+w2, b+w2, temp, 1, 1, 1, width, -1, 0, 1, 1, 1); +-#endif ++#endif /* 0 */ + for(x=0; xy += 2; + } + +-static void spatial_compose53i(IDWTELEM *buffer, int width, int height, int stride){ ++static void av_unused spatial_compose53i(IDWTELEM *buffer, int width, int height, int stride){ + dwt_compose_t cs; + spatial_compose53i_init(&cs, buffer, height, stride); + while(cs.y <= height) +@@ -1310,7 +1310,7 @@ + cs->y += 2; + } + +-static void spatial_compose97i(IDWTELEM *buffer, int width, int height, int stride){ ++static void av_unused spatial_compose97i(IDWTELEM *buffer, int width, int height, int stride){ + dwt_compose_t cs; + spatial_compose97i_init(&cs, buffer, height, stride); + while(cs.y <= height) +@@ -2193,7 +2193,7 @@ + uint8_t tmp2t[3][stride*(32+HTAPS_MAX)]; + int16_t *tmpI= tmpIt; + uint8_t *tmp2= tmp2t[0]; +- uint8_t *hpel[11]; ++ const uint8_t *hpel[11]; + START_TIMER + assert(dx<16 && dy<16); + r= brane[dx + 16*dy]&15; +@@ -2302,10 +2302,10 @@ + hpel[10]= hpel[8] + 1; + + if(b==15){ +- uint8_t *src1= hpel[dx/8 + dy/8*4 ]; +- uint8_t *src2= hpel[dx/8 + dy/8*4+1]; +- uint8_t *src3= hpel[dx/8 + dy/8*4+4]; +- uint8_t *src4= hpel[dx/8 + dy/8*4+5]; ++ const uint8_t *src1= hpel[dx/8 + dy/8*4 ]; ++ const uint8_t *src2= hpel[dx/8 + dy/8*4+1]; ++ const uint8_t *src3= hpel[dx/8 + dy/8*4+4]; ++ const uint8_t *src4= hpel[dx/8 + dy/8*4+5]; + dx&=7; + dy&=7; + for(y=0; y < b_h; y++){ +@@ -2320,8 +2320,8 @@ + dst +=stride; + } + }else{ +- uint8_t *src1= hpel[l]; +- uint8_t *src2= hpel[r]; ++ const uint8_t *src1= hpel[l]; ++ const uint8_t *src2= hpel[r]; + int a= weight[((dx&7) + (8*(dy&7)))]; + int b= 8-a; + for(y=0; y < b_h; y++){ +@@ -2410,7 +2410,7 @@ + // assert(b_w == b_h || 2*b_w == b_h || b_w == 2*b_h); + // assert(!(b_w&(b_w-1))); + assert(b_w>1 && b_h>1); +- assert(tab_index>=0 && tab_index<4 || b_w==32); ++ assert((tab_index>=0 && tab_index<4) || b_w==32); + if((dx&3) || (dy&3) || !(b_w == b_h || 2*b_w == b_h || b_w == 2*b_h) || (b_w&(b_w-1)) || !s->plane[plane_index].fast_mc ) + mc_block(&s->plane[plane_index], dst, src, tmp, stride, b_w, b_h, dx, dy); + else if(b_w==32){ +@@ -2621,7 +2621,7 @@ + } + } + } +-#endif ++#endif /* 0 */ + } + + static av_always_inline void predict_slice_buffered(SnowContext *s, slice_buffer * sb, IDWTELEM * old_buffer, int plane_index, int add, int mb_y){ +@@ -3583,10 +3583,6 @@ + put_symbol(&s->c, s->header_state, p->htaps/2-1, 0); + for(i= p->htaps/2; i; i--) + put_symbol(&s->c, s->header_state, FFABS(p->hcoeff[i]), 0); +- +- p->last_diag_mc= p->diag_mc; +- p->last_htaps= p->htaps; +- memcpy(p->last_hcoeff, p->hcoeff, sizeof(p->hcoeff)); + } + } + if(s->last_spatial_decomposition_count != s->spatial_decomposition_count){ +@@ -3603,6 +3599,20 @@ + put_symbol(&s->c, s->header_state, s->qbias - s->last_qbias , 1); + put_symbol(&s->c, s->header_state, s->block_max_depth - s->last_block_max_depth, 1); + ++} ++ ++static void update_last_header_values(SnowContext *s){ ++ int plane_index; ++ ++ if(!s->keyframe){ ++ for(plane_index=0; plane_index<2; plane_index++){ ++ Plane *p= &s->plane[plane_index]; ++ p->last_diag_mc= p->diag_mc; ++ p->last_htaps = p->htaps; ++ memcpy(p->last_hcoeff, p->hcoeff, sizeof(p->hcoeff)); ++ } ++ } ++ + s->last_spatial_decomposition_type= s->spatial_decomposition_type; + s->last_qlog = s->qlog; + s->last_qbias = s->qbias; +@@ -3665,7 +3675,7 @@ + if(!s->keyframe){ + if(get_rac(&s->c, s->header_state)){ + for(plane_index=0; plane_index<2; plane_index++){ +- int htaps, i, sum=0, absum=0; ++ int htaps, i, sum=0; + Plane *p= &s->plane[plane_index]; + p->diag_mc= get_rac(&s->c, s->header_state); + htaps= get_symbol(&s->c, s->header_state, 0)*2 + 2; +@@ -3895,7 +3905,7 @@ + return delta_qlog; + } + +-static void calculate_vissual_weight(SnowContext *s, Plane *p){ ++static void calculate_visual_weight(SnowContext *s, Plane *p){ + int width = p->width; + int height= p->height; + int level, orientation, x, y; +@@ -4037,7 +4047,7 @@ + memcpy(s->spatial_idwt_buffer, best_dequant, height * stride * sizeof(IDWTELEM)); //FIXME work with that directly insteda of copy at the end + } + +-#endif ++#endif /* QUANTIZE2==1 */ + + static int encode_init(AVCodecContext *avctx) + { +@@ -4115,7 +4125,7 @@ + s->colorspace= 1; + break;*/ + default: +- av_log(avctx, AV_LOG_ERROR, "format not supported\n"); ++ av_log(avctx, AV_LOG_ERROR, "pixel format not supported\n"); + return -1; + } + // avcodec_get_chroma_sub_sample(avctx->pix_fmt, &s->chroma_h_shift, &s->chroma_v_shift); +@@ -4139,6 +4149,8 @@ + return 0; + } + ++#define USE_HALFPEL_PLANE 0 ++ + static void halfpel_interpol(SnowContext *s, uint8_t *halfpel[4][4], AVFrame *frame){ + int p,x,y; + +@@ -4197,10 +4209,8 @@ + tmp= s->last_picture[s->max_ref_frames-1]; + memmove(s->last_picture+1, s->last_picture, (s->max_ref_frames-1)*sizeof(AVFrame)); + memmove(s->halfpel_plane+1, s->halfpel_plane, (s->max_ref_frames-1)*sizeof(void*)*4*4); +-#ifdef USE_HALFPEL_PLANE +- if(s->current_picture.data[0]) ++ if(USE_HALFPEL_PLANE && s->current_picture.data[0]) + halfpel_interpol(s, s->halfpel_plane[0], &s->current_picture); +-#endif + s->last_picture[0]= s->current_picture; + s->current_picture= tmp; + +@@ -4338,7 +4348,7 @@ + + if(s->last_spatial_decomposition_count != s->spatial_decomposition_count){ + for(plane_index=0; plane_index<3; plane_index++){ +- calculate_vissual_weight(s, &s->plane[plane_index]); ++ calculate_visual_weight(s, &s->plane[plane_index]); + } + } + +@@ -4473,6 +4483,8 @@ + } + } + ++ update_last_header_values(s); ++ + if(s->last_picture[s->max_ref_frames-1].data[0]){ + avctx->release_buffer(avctx, &s->last_picture[s->max_ref_frames-1]); + for(i=0; i<9; i++) +@@ -4548,8 +4560,6 @@ + + static int decode_init(AVCodecContext *avctx) + { +- SnowContext *s = avctx->priv_data; +- + avctx->pix_fmt= PIX_FMT_YUV420P; + + common_init(avctx); +@@ -4557,7 +4567,7 @@ + return 0; + } + +-static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8_t *buf, int buf_size){ ++static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, const uint8_t *buf, int buf_size){ + SnowContext *s = avctx->priv_data; + RangeCoder * const c= &s->c; + int bytes_read; +@@ -4765,13 +4775,13 @@ + #endif + + +-#if 0 ++#ifdef TEST + #undef malloc + #undef free + #undef printf + #undef random + +-int main(){ ++int main(void){ + int width=256; + int height=256; + int buffer[2][width*height]; +@@ -4873,9 +4883,8 @@ + printf("};\n"); + { + int level=2; +- int orientation=3; + int w= width >> (s.spatial_decomposition_count-level); +- int h= height >> (s.spatial_decomposition_count-level); ++ //int h= height >> (s.spatial_decomposition_count-level); + int stride= width << (s.spatial_decomposition_count-level); + DWTELEM *buf= buffer[0]; + int64_t error=0; +@@ -4914,5 +4923,4 @@ + } + return 0; + } +-#endif +- ++#endif /* TEST */ +diff -u mplayer-1.0~rc2-12/libavcodec/snow.h ffmpeg-free-0.svn20080206/libavcodec/snow.h +--- mplayer-1.0~rc2-12/libavcodec/snow.h 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/snow.h 2007-10-17 11:37:46.000000000 +0200 +@@ -19,8 +19,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef SNOW_H +-#define SNOW_H ++#ifndef FFMPEG_SNOW_H ++#define FFMPEG_SNOW_H + + #include "dsputil.h" + +@@ -171,4 +171,4 @@ + } + } + +-#endif ++#endif /* FFMPEG_SNOW_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/sonic.c ffmpeg-free-0.svn20080206/libavcodec/sonic.c +--- mplayer-1.0~rc2-12/libavcodec/sonic.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/sonic.c 2008-03-20 19:10:59.000000000 +0100 +@@ -851,7 +851,7 @@ + + static int sonic_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + SonicContext *s = avctx->priv_data; + GetBitContext gb; +diff -u mplayer-1.0~rc2-12/libavcodec/sp5xdec.c ffmpeg-free-0.svn20080206/libavcodec/sp5xdec.c +--- mplayer-1.0~rc2-12/libavcodec/sp5xdec.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/sp5xdec.c 2008-03-20 19:10:59.000000000 +0100 +@@ -32,13 +32,14 @@ + + static int sp5x_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + #if 0 + MJpegDecodeContext *s = avctx->priv_data; + #endif + const int qscale = 5; +- uint8_t *buf_ptr, *buf_end, *recoded; ++ const uint8_t *buf_ptr, *buf_end; ++ uint8_t *recoded; + int i = 0, j = 0; + + if (!avctx->width || !avctx->height) +@@ -87,6 +88,7 @@ + recoded[j++] = 0xFF; + recoded[j++] = 0xD9; + ++ avctx->flags &= ~CODEC_FLAG_EMU_EDGE; + i = ff_mjpeg_decode_frame(avctx, data, data_size, recoded, j); + + av_free(recoded); +@@ -207,6 +209,5 @@ + ff_mjpeg_decode_init, + NULL, + ff_mjpeg_decode_end, +- sp5x_decode_frame, +- CODEC_CAP_DR1 ++ sp5x_decode_frame + }; +diff -u mplayer-1.0~rc2-12/libavcodec/sp5x.h ffmpeg-free-0.svn20080206/libavcodec/sp5x.h +--- mplayer-1.0~rc2-12/libavcodec/sp5x.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/sp5x.h 2007-10-17 11:37:46.000000000 +0200 +@@ -19,8 +19,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef SP5X_H +-#define SP5X_H ++#ifndef FFMPEG_SP5X_H ++#define FFMPEG_SP5X_H + + #include + +@@ -331,4 +331,4 @@ + }; + #endif + +-#endif /* SP5X_H */ ++#endif /* FFMPEG_SP5X_H */ +Common subdirectories: mplayer-1.0~rc2-12/libavcodec/sparc and ffmpeg-free-0.svn20080206/libavcodec/sparc +Only in ffmpeg-free-0.svn20080206/libavcodec: sunrast.c +diff -u mplayer-1.0~rc2-12/libavcodec/svq1.c ffmpeg-free-0.svn20080206/libavcodec/svq1.c +--- mplayer-1.0~rc2-12/libavcodec/svq1.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/svq1.c 2008-03-20 19:10:59.000000000 +0100 +@@ -37,7 +37,7 @@ + #include "svq1_vlc.h" + + /* standard video sizes */ +-svq1_frame_size_t ff_svq1_frame_size_table[8] = { ++const svq1_frame_size_t ff_svq1_frame_size_table[8] = { + { 160, 120 }, { 128, 96 }, { 176, 144 }, { 352, 288 }, + { 704, 576 }, { 240, 180 }, { 320, 240 }, { -1, -1 } + }; +diff -u mplayer-1.0~rc2-12/libavcodec/svq1_cb.h ffmpeg-free-0.svn20080206/libavcodec/svq1_cb.h +--- mplayer-1.0~rc2-12/libavcodec/svq1_cb.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/svq1_cb.h 2007-10-17 11:37:46.000000000 +0200 +@@ -28,8 +28,8 @@ + * svq1 code books. + */ + +-#ifndef AVCODEC_SVQ1_CB_H +-#define AVCODEC_SVQ1_CB_H ++#ifndef FFMPEG_SVQ1_CB_H ++#define FFMPEG_SVQ1_CB_H + + #include + #include +@@ -1520,4 +1520,4 @@ + NULL, NULL, + }; + +-#endif // AVCODEC_SVQ1_CB_H ++#endif /* FFMPEG_SVQ1_CB_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/svq1dec.c ffmpeg-free-0.svn20080206/libavcodec/svq1dec.c +--- mplayer-1.0~rc2-12/libavcodec/svq1dec.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/svq1dec.c 2008-03-20 19:10:59.000000000 +0100 +@@ -540,7 +540,7 @@ + return result; + } + +-static uint16_t svq1_packet_checksum (uint8_t *data, int length, int value) { ++static uint16_t svq1_packet_checksum (const uint8_t *data, const int length, int value) { + int i; + + for (i=0; i < length; i++) { +@@ -581,7 +581,7 @@ + if (s->f_code == 0x50 || s->f_code == 0x60) { + int csum = get_bits (bitbuf, 16); + +- csum = svq1_packet_checksum ((uint8_t *)bitbuf->buffer, bitbuf->size_in_bits>>3, csum); ++ csum = svq1_packet_checksum (bitbuf->buffer, bitbuf->size_in_bits>>3, csum); + + // av_log(s->avctx, AV_LOG_INFO, "%s checksum (%02x) for packet data\n", + // (csum == 0) ? "correct" : "incorrect", csum); +@@ -641,7 +641,7 @@ + + static int svq1_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + MpegEncContext *s=avctx->priv_data; + uint8_t *current, *previous; +diff -u mplayer-1.0~rc2-12/libavcodec/svq1enc_cb.h ffmpeg-free-0.svn20080206/libavcodec/svq1enc_cb.h +--- mplayer-1.0~rc2-12/libavcodec/svq1enc_cb.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/svq1enc_cb.h 2007-10-17 11:37:46.000000000 +0200 +@@ -24,8 +24,8 @@ + * svq1 code books. + */ + +-#ifndef AVCODEC_SVQ1ENC_CB_H +-#define AVCODEC_SVQ1ENC_CB_H ++#ifndef FFMPEG_SVQ1ENC_CB_H ++#define FFMPEG_SVQ1ENC_CB_H + + #include + +@@ -93,4 +93,4 @@ + } + }; + +-#endif /* AVCODEC_SVQ1ENC_CB_H */ ++#endif /* FFMPEG_SVQ1ENC_CB_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/svq1.h ffmpeg-free-0.svn20080206/libavcodec/svq1.h +--- mplayer-1.0~rc2-12/libavcodec/svq1.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/svq1.h 2008-01-07 13:48:42.000000000 +0100 +@@ -32,8 +32,8 @@ + * http://www.pcisys.net/~melanson/codecs/ + */ + +-#ifndef AVCODEC_SVQ1_H +-#define AVCODEC_SVQ1_H ++#ifndef FFMPEG_SVQ1_H ++#define FFMPEG_SVQ1_H + + #include + +@@ -56,6 +56,6 @@ + extern const uint16_t ff_svq1_intra_mean_vlc[256][2]; + extern const uint16_t ff_svq1_inter_mean_vlc[512][2]; + +-extern svq1_frame_size_t ff_svq1_frame_size_table[8]; ++extern const svq1_frame_size_t ff_svq1_frame_size_table[8]; + +-#endif /* AVCODEC_SVQ1_H */ ++#endif /* FFMPEG_SVQ1_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/svq1_vlc.h ffmpeg-free-0.svn20080206/libavcodec/svq1_vlc.h +--- mplayer-1.0~rc2-12/libavcodec/svq1_vlc.h 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/svq1_vlc.h 2007-10-17 11:37:46.000000000 +0200 +@@ -18,8 +18,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef SVQ1_VLC_H +-#define SVQ1_VLC_H ++#ifndef FFMPEG_SVQ1_VLC_H ++#define FFMPEG_SVQ1_VLC_H + + #include + +@@ -280,4 +280,4 @@ + { 0x3, 22 }, { 0x2, 22 }, { 0x1, 22 }, { 0x0, 22 } + }; + +-#endif ++#endif /* FFMPEG_SVQ1_VLC_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/svq3.c ffmpeg-free-0.svn20080206/libavcodec/svq3.c +--- mplayer-1.0~rc2-12/libavcodec/svq3.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/svq3.c 2008-03-20 19:10:59.000000000 +0100 +@@ -760,7 +760,7 @@ + + static int svq3_decode_frame (AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) { ++ const uint8_t *buf, int buf_size) { + MpegEncContext *const s = avctx->priv_data; + H264Context *const h = avctx->priv_data; + int m, mb_type; +diff -u mplayer-1.0~rc2-12/libavcodec/targa.c ffmpeg-free-0.svn20080206/libavcodec/targa.c +--- mplayer-1.0~rc2-12/libavcodec/targa.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/targa.c 2008-03-20 19:10:59.000000000 +0100 +@@ -37,7 +37,7 @@ + int compression_type; + } TargaContext; + +-static void targa_decode_rle(AVCodecContext *avctx, TargaContext *s, uint8_t *src, uint8_t *dst, int w, int h, int stride, int bpp) ++static void targa_decode_rle(AVCodecContext *avctx, TargaContext *s, const uint8_t *src, uint8_t *dst, int w, int h, int stride, int bpp) + { + int i, x, y; + int depth = (bpp + 1) >> 3; +@@ -89,7 +89,7 @@ + + static int decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + TargaContext * const s = avctx->priv_data; + AVFrame *picture = data; +diff -u mplayer-1.0~rc2-12/libavcodec/tiertexseqv.c ffmpeg-free-0.svn20080206/libavcodec/tiertexseqv.c +--- mplayer-1.0~rc2-12/libavcodec/tiertexseqv.c 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/tiertexseqv.c 2008-03-20 19:10:59.000000000 +0100 +@@ -37,7 +37,7 @@ + } SeqVideoContext; + + +-static unsigned char *seq_unpack_rle_block(unsigned char *src, unsigned char *dst, int dst_size) ++static const unsigned char *seq_unpack_rle_block(const unsigned char *src, unsigned char *dst, int dst_size) + { + int i, len, sz; + GetBitContext gb; +@@ -67,9 +67,9 @@ + return src; + } + +-static unsigned char *seq_decode_op1(SeqVideoContext *seq, unsigned char *src, unsigned char *dst) ++static const unsigned char *seq_decode_op1(SeqVideoContext *seq, const unsigned char *src, unsigned char *dst) + { +- unsigned char *color_table; ++ const unsigned char *color_table; + int b, i, len, bits; + GetBitContext gb; + +@@ -107,7 +107,7 @@ + return src; + } + +-static unsigned char *seq_decode_op2(SeqVideoContext *seq, unsigned char *src, unsigned char *dst) ++static const unsigned char *seq_decode_op2(SeqVideoContext *seq, const unsigned char *src, unsigned char *dst) + { + int i; + +@@ -120,7 +120,7 @@ + return src; + } + +-static unsigned char *seq_decode_op3(SeqVideoContext *seq, unsigned char *src, unsigned char *dst) ++static const unsigned char *seq_decode_op3(SeqVideoContext *seq, const unsigned char *src, unsigned char *dst) + { + int pos, offset; + +@@ -133,7 +133,7 @@ + return src; + } + +-static void seqvideo_decode(SeqVideoContext *seq, unsigned char *data, int data_size) ++static void seqvideo_decode(SeqVideoContext *seq, const unsigned char *data, int data_size) + { + GetBitContext gb; + int flags, i, j, x, y, op; +@@ -187,7 +187,7 @@ + + static int seqvideo_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + + SeqVideoContext *seq = avctx->priv_data; +diff -u mplayer-1.0~rc2-12/libavcodec/tiff.c ffmpeg-free-0.svn20080206/libavcodec/tiff.c +--- mplayer-1.0~rc2-12/libavcodec/tiff.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/tiff.c 2008-03-20 19:10:59.000000000 +0100 +@@ -44,25 +44,25 @@ + + int strips, rps; + int sot; +- uint8_t* stripdata; +- uint8_t* stripsizes; ++ const uint8_t* stripdata; ++ const uint8_t* stripsizes; + int stripsize, stripoff; + LZWState *lzw; + } TiffContext; + +-static int tget_short(uint8_t **p, int le){ ++static int tget_short(const uint8_t **p, int le){ + int v = le ? AV_RL16(*p) : AV_RB16(*p); + *p += 2; + return v; + } + +-static int tget_long(uint8_t **p, int le){ ++static int tget_long(const uint8_t **p, int le){ + int v = le ? AV_RL32(*p) : AV_RB32(*p); + *p += 4; + return v; + } + +-static int tget(uint8_t **p, int type, int le){ ++static int tget(const uint8_t **p, int type, int le){ + switch(type){ + case TIFF_BYTE : return *(*p)++; + case TIFF_SHORT: return tget_short(p, le); +@@ -71,9 +71,9 @@ + } + } + +-static int tiff_unpack_strip(TiffContext *s, uint8_t* dst, int stride, uint8_t *src, int size, int lines){ ++static int tiff_unpack_strip(TiffContext *s, uint8_t* dst, int stride, const uint8_t *src, int size, int lines){ + int c, line, pixels, code; +- uint8_t *ssrc = src; ++ const uint8_t *ssrc = src; + int width = s->width * (s->bpp / 8); + #ifdef CONFIG_ZLIB + uint8_t *zbuf; unsigned long outlen; +@@ -150,13 +150,14 @@ + } + + +-static int tiff_decode_tag(TiffContext *s, uint8_t *start, uint8_t *buf, uint8_t *end_buf, AVFrame *pic) ++static int tiff_decode_tag(TiffContext *s, const uint8_t *start, const uint8_t *buf, const uint8_t *end_buf, AVFrame *pic) + { + int tag, type, count, off, value = 0; +- uint8_t *src, *dst; ++ const uint8_t *src; ++ uint8_t *dst; + int i, j, ssize, soff, stride; + uint32_t *pal; +- uint8_t *rp, *gp, *bp; ++ const uint8_t *rp, *gp, *bp; + + tag = tget_short(&buf, s->le); + type = tget_short(&buf, s->le); +@@ -346,14 +347,14 @@ + return -1; + } + if(value == 2){ +- src = pic->data[0]; ++ dst = pic->data[0]; + stride = pic->linesize[0]; + soff = s->bpp >> 3; + ssize = s->width * soff; + for(i = 0; i < s->height; i++) { + for(j = soff; j < ssize; j++) +- src[j] += src[j - soff]; +- src += stride; ++ dst[j] += dst[j - soff]; ++ dst += stride; + } + } + break; +@@ -403,12 +404,12 @@ + + static int decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + TiffContext * const s = avctx->priv_data; + AVFrame *picture = data; + AVFrame * const p= (AVFrame*)&s->picture; +- uint8_t *orig_buf = buf, *end_buf = buf + buf_size; ++ const uint8_t *orig_buf = buf, *end_buf = buf + buf_size; + int id, le, off; + int i, entries; + +@@ -422,6 +423,7 @@ + } + s->le = le; + s->invert = 0; ++ s->compr = TIFF_RAW; + // As TIFF 6.0 specification puts it "An arbitrary but carefully chosen number + // that further identifies the file as a TIFF file" + if(tget_short(&buf, le) != 42){ +diff -u mplayer-1.0~rc2-12/libavcodec/tiffenc.c ffmpeg-free-0.svn20080206/libavcodec/tiffenc.c +--- mplayer-1.0~rc2-12/libavcodec/tiffenc.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/tiffenc.c 2008-03-20 19:10:59.000000000 +0100 +@@ -133,7 +133,7 @@ + enum TiffTags tag, enum TiffTypes type, int val){ + uint16_t w = val; + uint32_t dw= val; +- add_entry(s, tag, type, 1, type == TIFF_SHORT ? &w : &dw); ++ add_entry(s, tag, type, 1, type == TIFF_SHORT ? (void *)&w : (void *)&dw); + } + + /** +diff -u mplayer-1.0~rc2-12/libavcodec/tiff.h ffmpeg-free-0.svn20080206/libavcodec/tiff.h +--- mplayer-1.0~rc2-12/libavcodec/tiff.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/tiff.h 2007-10-17 11:37:46.000000000 +0200 +@@ -24,8 +24,8 @@ + * @file tiff.h + * @author Konstantin Shishkov + */ +-#ifndef TIFF_H +-#define TIFF_H ++#ifndef FFMPEG_TIFF_H ++#define FFMPEG_TIFF_H + + #include + +@@ -83,4 +83,4 @@ + 0, 1, 100, 2, 4, 8 + }; + +-#endif /* TIFF_H */ ++#endif /* FFMPEG_TIFF_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/truemotion1.c ffmpeg-free-0.svn20080206/libavcodec/truemotion1.c +--- mplayer-1.0~rc2-12/libavcodec/truemotion1.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/truemotion1.c 2008-03-20 19:10:59.000000000 +0100 +@@ -43,12 +43,12 @@ + AVCodecContext *avctx; + AVFrame frame; + +- uint8_t *buf; ++ const uint8_t *buf; + int size; + +- uint8_t *mb_change_bits; ++ const uint8_t *mb_change_bits; + int mb_change_bits_row_size; +- uint8_t *index_stream; ++ const uint8_t *index_stream; + int index_stream_size; + + int flags; +@@ -603,7 +603,7 @@ + int keyframe = s->flags & FLAG_KEYFRAME; + + /* these variables are for managing the stream of macroblock change bits */ +- unsigned char *mb_change_bits = s->mb_change_bits; ++ const unsigned char *mb_change_bits = s->mb_change_bits; + unsigned char mb_change_byte; + unsigned char mb_change_byte_mask; + int mb_change_index; +@@ -729,7 +729,7 @@ + int keyframe = s->flags & FLAG_KEYFRAME; + + /* these variables are for managing the stream of macroblock change bits */ +- unsigned char *mb_change_bits = s->mb_change_bits; ++ const unsigned char *mb_change_bits = s->mb_change_bits; + unsigned char mb_change_byte; + unsigned char mb_change_byte_mask; + int mb_change_index; +@@ -846,7 +846,7 @@ + + static int truemotion1_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + TrueMotion1Context *s = avctx->priv_data; + +diff -u mplayer-1.0~rc2-12/libavcodec/truemotion1data.h ffmpeg-free-0.svn20080206/libavcodec/truemotion1data.h +--- mplayer-1.0~rc2-12/libavcodec/truemotion1data.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/truemotion1data.h 2007-10-17 11:37:46.000000000 +0200 +@@ -22,8 +22,8 @@ + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +-#ifndef TRUEMOTION1DATA_H +-#define TRUEMOTION1DATA_H ++#ifndef FFMPEG_TRUEMOTION1DATA_H ++#define FFMPEG_TRUEMOTION1DATA_H + + #include + #include +@@ -829,4 +829,5 @@ + }; + + static const uint8_t *tables[] = { pc_tbl2, pc_tbl3, pc_tbl4 }; +-#endif ++ ++#endif /* FFMPEG_TRUEMOTION1DATA_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/truemotion2.c ffmpeg-free-0.svn20080206/libavcodec/truemotion2.c +--- mplayer-1.0~rc2-12/libavcodec/truemotion2.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/truemotion2.c 2008-03-20 19:10:59.000000000 +0100 +@@ -198,10 +198,10 @@ + return code->recode[val]; + } + +-static inline int tm2_read_header(TM2Context *ctx, uint8_t *buf) ++static inline int tm2_read_header(TM2Context *ctx, const uint8_t *buf) + { + uint32_t magic; +- uint8_t *obuf; ++ const uint8_t *obuf; + int length; + + obuf = buf; +@@ -260,7 +260,7 @@ + return 0; + } + +-static int tm2_read_stream(TM2Context *ctx, uint8_t *buf, int stream_id) { ++static int tm2_read_stream(TM2Context *ctx, const uint8_t *buf, int stream_id) { + int i; + int cur = 0; + int skip = 0; +@@ -759,7 +759,7 @@ + + static int decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + TM2Context * const l = avctx->priv_data; + AVFrame * const p= (AVFrame*)&l->pic; +@@ -772,7 +772,7 @@ + return -1; + } + +- l->dsp.bswap_buf((uint32_t*)buf, (uint32_t*)buf, buf_size >> 2); ++ l->dsp.bswap_buf((uint32_t*)buf, (const uint32_t*)buf, buf_size >> 2); //FIXME SERIOUS BUG + skip = tm2_read_header(l, buf); + + if(skip == -1) +diff -u mplayer-1.0~rc2-12/libavcodec/truespeech.c ffmpeg-free-0.svn20080206/libavcodec/truespeech.c +--- mplayer-1.0~rc2-12/libavcodec/truespeech.c 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/truespeech.c 2008-03-20 19:10:59.000000000 +0100 +@@ -57,7 +57,7 @@ + return 0; + } + +-static void truespeech_read_frame(TSContext *dec, uint8_t *input) ++static void truespeech_read_frame(TSContext *dec, const uint8_t *input) + { + uint32_t t; + +@@ -329,7 +329,7 @@ + + static int truespeech_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + TSContext *c = avctx->priv_data; + +diff -u mplayer-1.0~rc2-12/libavcodec/truespeech_data.h ffmpeg-free-0.svn20080206/libavcodec/truespeech_data.h +--- mplayer-1.0~rc2-12/libavcodec/truespeech_data.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/truespeech_data.h 2007-10-17 11:37:46.000000000 +0200 +@@ -19,8 +19,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef TRUESPEECH_DATA_H +-#define TRUESPEECH_DATA_H ++#ifndef FFMPEG_TRUESPEECH_DATA_H ++#define FFMPEG_TRUESPEECH_DATA_H + + #include + +@@ -156,4 +156,4 @@ + static const int16_t ts_5F2[8] = + { 0x6000, 0x4800, 0x3600, 0x2880, 0x1E60, 0x16C8, 0x1116, 0x0CD1 }; + +-#endif /* TRUESPEECH_DATA_H */ ++#endif /* FFMPEG_TRUESPEECH_DATA_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/tscc.c ffmpeg-free-0.svn20080206/libavcodec/tscc.c +--- mplayer-1.0~rc2-12/libavcodec/tscc.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/tscc.c 2008-03-20 19:10:59.000000000 +0100 +@@ -182,10 +182,10 @@ + * Decode a frame + * + */ +-static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8_t *buf, int buf_size) ++static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, const uint8_t *buf, int buf_size) + { + CamtasiaContext * const c = avctx->priv_data; +- unsigned char *encoded = (unsigned char *)buf; ++ const unsigned char *encoded = buf; + unsigned char *outptr; + #ifdef CONFIG_ZLIB + int zret; // Zlib return code +diff -u mplayer-1.0~rc2-12/libavcodec/tta.c ffmpeg-free-0.svn20080206/libavcodec/tta.c +--- mplayer-1.0~rc2-12/libavcodec/tta.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/tta.c 2008-03-20 19:10:59.000000000 +0100 +@@ -287,7 +287,7 @@ + + static int tta_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + TTAContext *s = avctx->priv_data; + int i; +diff -u mplayer-1.0~rc2-12/libavcodec/txd.c ffmpeg-free-0.svn20080206/libavcodec/txd.c +--- mplayer-1.0~rc2-12/libavcodec/txd.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/txd.c 2008-03-20 19:10:59.000000000 +0100 +@@ -33,20 +33,21 @@ + + avcodec_get_frame_defaults(&s->picture); + avctx->coded_frame = &s->picture; +- s->picture.data[0] = NULL; + + return 0; + } + + static int txd_decode_frame(AVCodecContext *avctx, void *data, int *data_size, +- uint8_t *buf, int buf_size) { ++ const uint8_t *buf, int buf_size) { + TXDContext * const s = avctx->priv_data; + AVFrame *picture = data; + AVFrame * const p = &s->picture; + unsigned int version, w, h, d3d_format, depth, stride, mipmap_count, flags; + unsigned int y, v; +- uint8_t *ptr, *cur = buf; +- uint32_t *palette = (uint32_t *)(cur + 88), *pal; ++ uint8_t *ptr; ++ const uint8_t *cur = buf; ++ const uint32_t *palette = (const uint32_t *)(cur + 88); ++ uint32_t *pal; + + version = AV_RL32(cur); + d3d_format = AV_RL32(cur+76); +diff -u mplayer-1.0~rc2-12/libavcodec/ulti.c ffmpeg-free-0.svn20080206/libavcodec/ulti.c +--- mplayer-1.0~rc2-12/libavcodec/ulti.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/ulti.c 2008-03-20 19:10:59.000000000 +0100 +@@ -200,7 +200,7 @@ + + static int ulti_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + UltimotionDecodeContext *s=avctx->priv_data; + int modifier = 0; +diff -u mplayer-1.0~rc2-12/libavcodec/ulti_cb.h ffmpeg-free-0.svn20080206/libavcodec/ulti_cb.h +--- mplayer-1.0~rc2-12/libavcodec/ulti_cb.h 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/ulti_cb.h 2007-10-17 11:37:46.000000000 +0200 +@@ -19,8 +19,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef AVCODEC_ULTI_CB_H +-#define AVCODEC_ULTI_CB_H ++#ifndef FFMPEG_ULTI_CB_H ++#define FFMPEG_ULTI_CB_H + + static const unsigned char ulti_codebook[16384]={ + 0x00, 0x01, 0x01, 0x02, +@@ -4121,4 +4121,4 @@ + 0x3D, 0x3E, 0x3E, 0x3F + }; + +-#endif // AVCODEC_ULTI_CB_H ++#endif /* FFMPEG_ULTI_CB_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/unary.h ffmpeg-free-0.svn20080206/libavcodec/unary.h +--- mplayer-1.0~rc2-12/libavcodec/unary.h 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/unary.h 2007-10-17 11:37:46.000000000 +0200 +@@ -18,8 +18,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef AVCODEC_UNARY_H +-#define AVCODEC_UNARY_H ++#ifndef FFMPEG_UNARY_H ++#define FFMPEG_UNARY_H + + #include "bitstream.h" + +@@ -53,4 +53,4 @@ + return get_unary(gb, 0, 9); + } + +-#endif /* AVCODEC_UNARY_H */ ++#endif /* FFMPEG_UNARY_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/utils.c ffmpeg-free-0.svn20080206/libavcodec/utils.c +--- mplayer-1.0~rc2-12/libavcodec/utils.c 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/utils.c 2008-03-20 19:10:59.000000000 +0100 +@@ -126,6 +126,11 @@ + /* encoder management */ + AVCodec *first_avcodec = NULL; + ++AVCodec *av_codec_next(AVCodec *c){ ++ if(c) return c->next; ++ else return first_avcodec; ++} ++ + void register_avcodec(AVCodec *format) + { + AVCodec **p; +@@ -559,7 +564,7 @@ + {"rc_eq", "set rate control equation", OFFSET(rc_eq), FF_OPT_TYPE_STRING, DEFAULT, CHAR_MIN, CHAR_MAX, V|E}, + {"maxrate", "set max video bitrate tolerance (in bits/s)", OFFSET(rc_max_rate), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E}, + {"minrate", "set min video bitrate tolerance (in bits/s)", OFFSET(rc_min_rate), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E}, +-{"bufsize", "set ratecontrol buffer size (in bits)", OFFSET(rc_buffer_size), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E}, ++{"bufsize", "set ratecontrol buffer size (in bits)", OFFSET(rc_buffer_size), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, A|V|E}, + {"rc_buf_aggressivity", "currently useless", OFFSET(rc_buffer_aggressivity), FF_OPT_TYPE_FLOAT, 1.0, FLT_MIN, FLT_MAX, V|E}, + {"i_qfactor", "qp factor between p and i frames", OFFSET(i_quant_factor), FF_OPT_TYPE_FLOAT, -0.8, -FLT_MAX, FLT_MAX, V|E}, + {"i_qoffset", "qp offset between p and i frames", OFFSET(i_quant_offset), FF_OPT_TYPE_FLOAT, 0.0, -FLT_MAX, FLT_MAX, V|E}, +@@ -756,6 +761,7 @@ + {"drop_frame_timecode", NULL, 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_DROP_FRAME_TIMECODE, INT_MIN, INT_MAX, V|E, "flags2"}, + {"non_linear_q", "use non linear quantizer", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_NON_LINEAR_QUANT, INT_MIN, INT_MAX, V|E, "flags2"}, + {"request_channels", "set desired number of audio channels", OFFSET(request_channels), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, A|D}, ++{"drc_scale", "percentage of dynamic range compression to apply", OFFSET(drc_scale), FF_OPT_TYPE_FLOAT, 1.0, 0.0, 1.0, A|D}, + {NULL}, + }; + +@@ -842,7 +848,7 @@ + goto end; + } + +- if(avctx->codec) ++ if(avctx->codec || !codec) + goto end; + + if (codec->priv_data_size > 0) { +@@ -928,7 +934,7 @@ + + int attribute_align_arg avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture, + int *got_picture_ptr, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + int ret; + +@@ -951,7 +957,7 @@ + + int attribute_align_arg avcodec_decode_audio2(AVCodecContext *avctx, int16_t *samples, + int *frame_size_ptr, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + int ret; + +@@ -980,7 +986,7 @@ + #if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0) + int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples, + int *frame_size_ptr, +- uint8_t *buf, int buf_size){ ++ const uint8_t *buf, int buf_size){ + *frame_size_ptr= AVCODEC_MAX_AUDIO_FRAME_SIZE; + return avcodec_decode_audio2(avctx, samples, frame_size_ptr, buf, buf_size); + } +@@ -994,7 +1000,7 @@ + + *got_sub_ptr = 0; + ret = avctx->codec->decode(avctx, sub, got_sub_ptr, +- (uint8_t *)buf, buf_size); ++ buf, buf_size); + if (*got_sub_ptr) + avctx->frame_number++; + return ret; +@@ -1075,6 +1081,7 @@ + char buf1[32]; + char channels_str[100]; + int bitrate; ++ AVRational display_aspect_ratio; + + if (encode) + p = avcodec_find_encoder(enc->codec_id); +@@ -1125,7 +1132,15 @@ + snprintf(buf + strlen(buf), buf_size - strlen(buf), + ", %dx%d", + enc->width, enc->height); +- if(av_log_level >= AV_LOG_DEBUG){ ++ av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den, ++ enc->width*enc->sample_aspect_ratio.num, ++ enc->height*enc->sample_aspect_ratio.den, ++ 1024*1024); ++ snprintf(buf + strlen(buf), buf_size - strlen(buf), ++ " [PAR %d:%d DAR %d:%d]", ++ enc->sample_aspect_ratio.num, enc->sample_aspect_ratio.den, ++ display_aspect_ratio.num, display_aspect_ratio.den); ++ if(av_log_get_level() >= AV_LOG_DEBUG){ + int g= ff_gcd(enc->time_base.num, enc->time_base.den); + snprintf(buf + strlen(buf), buf_size - strlen(buf), + ", %d/%d", +@@ -1180,6 +1195,7 @@ + break; + case CODEC_ID_PCM_S16LE: + case CODEC_ID_PCM_S16BE: ++ case CODEC_ID_PCM_S16LE_PLANAR: + case CODEC_ID_PCM_U16LE: + case CODEC_ID_PCM_U16BE: + bitrate = enc->sample_rate * enc->channels * 16; +@@ -1203,6 +1219,10 @@ + snprintf(buf, buf_size, "Subtitle: %s", codec_name); + bitrate = enc->bit_rate; + break; ++ case CODEC_TYPE_ATTACHMENT: ++ snprintf(buf, buf_size, "Attachment: %s", codec_name); ++ bitrate = enc->bit_rate; ++ break; + default: + snprintf(buf, buf_size, "Invalid Codec type %d", enc->codec_type); + return; +@@ -1231,17 +1251,6 @@ + return LIBAVCODEC_BUILD; + } + +-static void init_crcs(void){ +-#if LIBAVUTIL_VERSION_INT < (50<<16) +- av_crc04C11DB7= av_mallocz_static(sizeof(AVCRC) * 257); +- av_crc8005 = av_mallocz_static(sizeof(AVCRC) * 257); +- av_crc07 = av_mallocz_static(sizeof(AVCRC) * 257); +-#endif +- av_crc_init(av_crc04C11DB7, 0, 32, AV_CRC_32_IEEE, sizeof(AVCRC)*257); +- av_crc_init(av_crc8005 , 0, 16, AV_CRC_16 , sizeof(AVCRC)*257); +- av_crc_init(av_crc07 , 0, 8, AV_CRC_8_ATM , sizeof(AVCRC)*257); +-} +- + void avcodec_init(void) + { + static int inited = 0; +@@ -1251,7 +1260,6 @@ + inited = 1; + + dsputil_static_init(); +- init_crcs(); + } + + void avcodec_flush_buffers(AVCodecContext *avctx) +@@ -1305,6 +1313,7 @@ + return 8; + case CODEC_ID_PCM_S16BE: + case CODEC_ID_PCM_S16LE: ++ case CODEC_ID_PCM_S16LE_PLANAR: + case CODEC_ID_PCM_U16BE: + case CODEC_ID_PCM_U16LE: + return 16; +Only in ffmpeg-free-0.svn20080206/libavcodec: vb.c +diff -u mplayer-1.0~rc2-12/libavcodec/vc1acdata.h ffmpeg-free-0.svn20080206/libavcodec/vc1acdata.h +--- mplayer-1.0~rc2-12/libavcodec/vc1acdata.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/vc1acdata.h 2007-10-17 11:37:46.000000000 +0200 +@@ -19,8 +19,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef AVCODEC_VC1ACDATA_H +-#define AVCODEC_VC1ACDATA_H ++#ifndef FFMPEG_VC1ACDATA_H ++#define FFMPEG_VC1ACDATA_H + + #include + +@@ -589,4 +589,4 @@ + } + }; + +-#endif // AVCODEC_VC1ACDATA_H ++#endif /* FFMPEG_VC1ACDATA_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/vc1.c ffmpeg-free-0.svn20080206/libavcodec/vc1.c +--- mplayer-1.0~rc2-12/libavcodec/vc1.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/vc1.c 2008-03-20 19:10:59.000000000 +0100 +@@ -33,6 +33,7 @@ + #include "vc1acdata.h" + #include "msmpeg4data.h" + #include "unary.h" ++#include "simple_idct.h" + + #undef NDEBUG + #include +@@ -43,13 +44,6 @@ + static const uint16_t table_mb_intra[64][2]; + + +-static inline int decode210(GetBitContext *gb){ +- if (get_bits1(gb)) +- return 0; +- else +- return 2 - get_bits1(gb); +-} +- + /** + * Init VC-1 specific tables and VC1Context members + * @param v The VC1Context to initialize +@@ -783,10 +777,14 @@ + + if (v->profile == PROFILE_ADVANCED) + { ++ v->zz_8x4 = ff_vc1_adv_progressive_8x4_zz; ++ v->zz_4x8 = ff_vc1_adv_progressive_4x8_zz; + return decode_sequence_header_adv(v, gb); + } + else + { ++ v->zz_8x4 = ff_vc1_simple_progressive_8x4_zz; ++ v->zz_4x8 = ff_vc1_simple_progressive_4x8_zz; + v->res_sm = get_bits(gb, 2); //reserved + if (v->res_sm) + { +@@ -808,19 +806,14 @@ + } + + v->res_x8 = get_bits1(gb); //reserved +- if (v->res_x8) +- { +- av_log(avctx, AV_LOG_ERROR, +- "1 for reserved RES_X8 is forbidden\n"); +- //return -1; +- } + v->multires = get_bits1(gb); + v->res_fasttx = get_bits1(gb); + if (!v->res_fasttx) + { +- av_log(avctx, AV_LOG_ERROR, +- "0 for reserved RES_FASTTX is forbidden\n"); +- //return -1; ++ v->s.dsp.vc1_inv_trans_8x8 = ff_simple_idct; ++ v->s.dsp.vc1_inv_trans_8x4 = ff_simple_idct84_add; ++ v->s.dsp.vc1_inv_trans_4x8 = ff_simple_idct48_add; ++ v->s.dsp.vc1_inv_trans_4x4 = ff_simple_idct44_add; + } + + v->fastuvmc = get_bits1(gb); //common +@@ -1072,6 +1065,7 @@ + + /* Quantizer stuff */ + pqindex = get_bits(gb, 5); ++ if(!pqindex) return -1; + if (v->quantizer_mode == QUANT_FRAME_IMPLICIT) + v->pq = ff_vc1_pquant_table[0][pqindex]; + else +@@ -1101,8 +1095,8 @@ + if (v->multires && v->s.pict_type != B_TYPE) v->respic = get_bits(gb, 2); + + if(v->res_x8 && (v->s.pict_type == I_TYPE || v->s.pict_type == BI_TYPE)){ +- if(get_bits1(gb))return -1; +- } ++ v->x8_type = get_bits1(gb); ++ }else v->x8_type = 0; + //av_log(v->s.avctx, AV_LOG_INFO, "%c Frame: QP=[%i]%i (+%i/2) %i\n", + // (v->s.pict_type == P_TYPE) ? 'P' : ((v->s.pict_type == I_TYPE) ? 'I' : 'B'), pqindex, v->pq, v->halfpq, v->rangeredfrm); + +@@ -1235,14 +1229,17 @@ + break; + } + +- /* AC Syntax */ +- v->c_ac_table_index = decode012(gb); +- if (v->s.pict_type == I_TYPE || v->s.pict_type == BI_TYPE) ++ if(!v->x8_type) + { +- v->y_ac_table_index = decode012(gb); ++ /* AC Syntax */ ++ v->c_ac_table_index = decode012(gb); ++ if (v->s.pict_type == I_TYPE || v->s.pict_type == BI_TYPE) ++ { ++ v->y_ac_table_index = decode012(gb); ++ } ++ /* DC Syntax */ ++ v->s.dc_table_index = get_bits1(gb); + } +- /* DC Syntax */ +- v->s.dc_table_index = get_bits1(gb); + + if(v->s.pict_type == BI_TYPE) { + v->s.pict_type = B_TYPE; +@@ -1305,6 +1302,7 @@ + } + } + pqindex = get_bits(gb, 5); ++ if(!pqindex) return -1; + v->pqindex = pqindex; + if (v->quantizer_mode == QUANT_FRAME_IMPLICIT) + v->pq = ff_vc1_pquant_table[0][pqindex]; +@@ -2888,7 +2886,8 @@ + + /** Decode P block + */ +-static int vc1_decode_p_block(VC1Context *v, DCTELEM block[64], int n, int mquant, int ttmb, int first_block) ++static int vc1_decode_p_block(VC1Context *v, DCTELEM block[64], int n, int mquant, int ttmb, int first_block, ++ uint8_t *dst, int linesize, int skip_block) + { + MpegEncContext *s = &v->s; + GetBitContext *gb = &s->gb; +@@ -2934,7 +2933,10 @@ + if(!v->pquantizer) + block[idx] += (block[idx] < 0) ? -mquant : mquant; + } +- s->dsp.vc1_inv_trans_8x8(block); ++ if(!skip_block){ ++ s->dsp.vc1_inv_trans_8x8(block); ++ s->dsp.add_pixels_clamped(block, dst, linesize); ++ } + break; + case TT_4X4: + for(j = 0; j < 4; j++) { +@@ -2951,8 +2953,8 @@ + if(!v->pquantizer) + block[idx + off] += (block[idx + off] < 0) ? -mquant : mquant; + } +- if(!(subblkpat & (1 << (3 - j)))) +- s->dsp.vc1_inv_trans_4x4(block, j); ++ if(!(subblkpat & (1 << (3 - j))) && !skip_block) ++ s->dsp.vc1_inv_trans_4x4(dst + (j&1)*4 + (j&2)*2*linesize, linesize, block + off); + } + break; + case TT_8X4: +@@ -2965,16 +2967,13 @@ + i += skip; + if(i > 31) + break; +- if(v->profile < PROFILE_ADVANCED) +- idx = ff_vc1_simple_progressive_8x4_zz[i++]; +- else +- idx = ff_vc1_adv_progressive_8x4_zz[i++]; +- block[idx + off] = value * scale; ++ idx = v->zz_8x4[i++]+off; ++ block[idx] = value * scale; + if(!v->pquantizer) +- block[idx + off] += (block[idx + off] < 0) ? -mquant : mquant; ++ block[idx] += (block[idx] < 0) ? -mquant : mquant; + } +- if(!(subblkpat & (1 << (1 - j)))) +- s->dsp.vc1_inv_trans_8x4(block, j); ++ if(!(subblkpat & (1 << (1 - j))) && !skip_block) ++ s->dsp.vc1_inv_trans_8x4(dst + j*4*linesize, linesize, block + off); + } + break; + case TT_4X8: +@@ -2987,16 +2986,13 @@ + i += skip; + if(i > 31) + break; +- if(v->profile < PROFILE_ADVANCED) +- idx = ff_vc1_simple_progressive_4x8_zz[i++]; +- else +- idx = ff_vc1_adv_progressive_4x8_zz[i++]; +- block[idx + off] = value * scale; ++ idx = v->zz_4x8[i++]+off; ++ block[idx] = value * scale; + if(!v->pquantizer) +- block[idx + off] += (block[idx + off] < 0) ? -mquant : mquant; ++ block[idx] += (block[idx] < 0) ? -mquant : mquant; + } +- if(!(subblkpat & (1 << (1 - j)))) +- s->dsp.vc1_inv_trans_4x8(block, j); ++ if(!(subblkpat & (1 << (1 - j))) && !skip_block) ++ s->dsp.vc1_inv_trans_4x8(dst + j*4, linesize, block + off); + } + break; + } +@@ -3097,9 +3093,7 @@ + if((i>3) && (s->flags & CODEC_FLAG_GRAY)) continue; + s->dsp.vc1_inv_trans_8x8(s->block[i]); + if(v->rangeredfrm) for(j = 0; j < 64; j++) s->block[i][j] <<= 1; +- for(j = 0; j < 64; j++) s->block[i][j] += 128; +- if(!v->res_fasttx && v->res_x8) for(j = 0; j < 64; j++) s->block[i][j] += 16; +- s->dsp.put_pixels_clamped(s->block[i], s->dest[dst_idx] + off, s->linesize >> ((i & 4) >> 2)); ++ s->dsp.put_signed_pixels_clamped(s->block[i], s->dest[dst_idx] + off, s->linesize >> ((i & 4) >> 2)); + if(v->pq >= 9 && v->overlap) { + if(v->c_avail) + s->dsp.vc1_h_overlap(s->dest[dst_idx] + off, s->linesize >> ((i & 4) >> 2)); +@@ -3107,11 +3101,9 @@ + s->dsp.vc1_v_overlap(s->dest[dst_idx] + off, s->linesize >> ((i & 4) >> 2)); + } + } else if(val) { +- vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, first_block); ++ vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, first_block, s->dest[dst_idx] + off, (i&4)?s->uvlinesize:s->linesize, (i&4) && (s->flags & CODEC_FLAG_GRAY)); + if(!v->ttmbf && ttmb < 8) ttmb = -1; + first_block = 0; +- if((i<4) || !(s->flags & CODEC_FLAG_GRAY)) +- s->dsp.add_pixels_clamped(s->block[i], s->dest[dst_idx] + off, (i&4)?s->uvlinesize:s->linesize); + } + } + } +@@ -3201,9 +3193,7 @@ + if((i>3) && (s->flags & CODEC_FLAG_GRAY)) continue; + s->dsp.vc1_inv_trans_8x8(s->block[i]); + if(v->rangeredfrm) for(j = 0; j < 64; j++) s->block[i][j] <<= 1; +- for(j = 0; j < 64; j++) s->block[i][j] += 128; +- if(!v->res_fasttx && v->res_x8) for(j = 0; j < 64; j++) s->block[i][j] += 16; +- s->dsp.put_pixels_clamped(s->block[i], s->dest[dst_idx] + off, (i&4)?s->uvlinesize:s->linesize); ++ s->dsp.put_signed_pixels_clamped(s->block[i], s->dest[dst_idx] + off, (i&4)?s->uvlinesize:s->linesize); + if(v->pq >= 9 && v->overlap) { + if(v->c_avail) + s->dsp.vc1_h_overlap(s->dest[dst_idx] + off, s->linesize >> ((i & 4) >> 2)); +@@ -3211,11 +3201,9 @@ + s->dsp.vc1_v_overlap(s->dest[dst_idx] + off, s->linesize >> ((i & 4) >> 2)); + } + } else if(is_coded[i]) { +- status = vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, first_block); ++ status = vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, first_block, s->dest[dst_idx] + off, (i&4)?s->uvlinesize:s->linesize, (i&4) && (s->flags & CODEC_FLAG_GRAY)); + if(!v->ttmbf && ttmb < 8) ttmb = -1; + first_block = 0; +- if((i<4) || !(s->flags & CODEC_FLAG_GRAY)) +- s->dsp.add_pixels_clamped(s->block[i], s->dest[dst_idx] + off, (i&4)?s->uvlinesize:s->linesize); + } + } + return status; +@@ -3383,14 +3371,11 @@ + if((i>3) && (s->flags & CODEC_FLAG_GRAY)) continue; + s->dsp.vc1_inv_trans_8x8(s->block[i]); + if(v->rangeredfrm) for(j = 0; j < 64; j++) s->block[i][j] <<= 1; +- for(j = 0; j < 64; j++) s->block[i][j] += 128; +- s->dsp.put_pixels_clamped(s->block[i], s->dest[dst_idx] + off, s->linesize >> ((i & 4) >> 2)); ++ s->dsp.put_signed_pixels_clamped(s->block[i], s->dest[dst_idx] + off, s->linesize >> ((i & 4) >> 2)); + } else if(val) { +- vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, first_block); ++ vc1_decode_p_block(v, s->block[i], i, mquant, ttmb, first_block, s->dest[dst_idx] + off, (i&4)?s->uvlinesize:s->linesize, (i&4) && (s->flags & CODEC_FLAG_GRAY)); + if(!v->ttmbf && ttmb < 8) ttmb = -1; + first_block = 0; +- if((i<4) || !(s->flags & CODEC_FLAG_GRAY)) +- s->dsp.add_pixels_clamped(s->block[i], s->dest[dst_idx] + off, (i&4)?s->uvlinesize:s->linesize); + } + } + } +@@ -3466,7 +3451,6 @@ + vc1_decode_i_block(v, s->block[k], k, val, (k<4)? v->codingset : v->codingset2); + + s->dsp.vc1_inv_trans_8x8(s->block[k]); +- if(!v->res_fasttx && !v->res_x8) for(j = 0; j < 64; j++) s->block[k][j] -= 16; + if(v->pq >= 9 && v->overlap) { + for(j = 0; j < 64; j++) s->block[k][j] += 128; + } +@@ -3759,36 +3743,40 @@ + { + + v->s.esc3_level_length = 0; ++ if(v->x8_type){ ++ ff_intrax8_decode_picture(&v->x8, 2*v->pq+v->halfpq, v->pq*(!v->pquantizer) ); ++ }else{ + +- switch(v->s.pict_type) { +- case I_TYPE: +- if(v->profile == PROFILE_ADVANCED) +- vc1_decode_i_blocks_adv(v); +- else +- vc1_decode_i_blocks(v); +- break; +- case P_TYPE: +- if(v->p_frame_skipped) +- vc1_decode_skip_blocks(v); +- else +- vc1_decode_p_blocks(v); +- break; +- case B_TYPE: +- if(v->bi_type){ ++ switch(v->s.pict_type) { ++ case I_TYPE: + if(v->profile == PROFILE_ADVANCED) + vc1_decode_i_blocks_adv(v); + else + vc1_decode_i_blocks(v); +- }else +- vc1_decode_b_blocks(v); +- break; ++ break; ++ case P_TYPE: ++ if(v->p_frame_skipped) ++ vc1_decode_skip_blocks(v); ++ else ++ vc1_decode_p_blocks(v); ++ break; ++ case B_TYPE: ++ if(v->bi_type){ ++ if(v->profile == PROFILE_ADVANCED) ++ vc1_decode_i_blocks_adv(v); ++ else ++ vc1_decode_i_blocks(v); ++ }else ++ vc1_decode_b_blocks(v); ++ break; ++ } + } + } + + /** Find VC-1 marker in buffer + * @return position where next marker starts or end of buffer if no marker found + */ +-static av_always_inline uint8_t* find_next_marker(uint8_t *src, uint8_t *end) ++static av_always_inline const uint8_t* find_next_marker(const uint8_t *src, const uint8_t *end) + { + uint32_t mrk = 0xFFFFFFFF; + +@@ -3801,7 +3789,7 @@ + return end; + } + +-static av_always_inline int vc1_unescape_buffer(uint8_t *src, int size, uint8_t *dst) ++static av_always_inline int vc1_unescape_buffer(const uint8_t *src, int size, uint8_t *dst) + { + int dsize = 0, i; + +@@ -3839,6 +3827,10 @@ + avctx->flags |= CODEC_FLAG_EMU_EDGE; + v->s.flags |= CODEC_FLAG_EMU_EDGE; + ++ if(avctx->idct_algo==FF_IDCT_AUTO){ ++ avctx->idct_algo=FF_IDCT_WMV2; ++ } ++ + if(ff_h263_decode_init(avctx) < 0) + return -1; + if (vc1_init_common(v) < 0) return -1; +@@ -3870,8 +3862,10 @@ + av_log(avctx, AV_LOG_INFO, "Read %i bits in overflow\n", -count); + } + } else { // VC1/WVC1 +- uint8_t *start = avctx->extradata, *end = avctx->extradata + avctx->extradata_size; +- uint8_t *next; int size, buf2_size; ++ const uint8_t *start = avctx->extradata; ++ uint8_t *end = avctx->extradata + avctx->extradata_size; ++ const uint8_t *next; ++ int size, buf2_size; + uint8_t *buf2 = NULL; + int seq_inited = 0, ep_inited = 0; + +@@ -3939,6 +3933,7 @@ + // return -1; + } + ++ ff_intrax8_common_init(&v->x8,s); + return 0; + } + +@@ -3948,7 +3943,7 @@ + */ + static int vc1_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + VC1Context *v = avctx->priv_data; + MpegEncContext *s = &v->s; +@@ -3981,7 +3976,7 @@ + buf2 = av_mallocz(buf_size + FF_INPUT_BUFFER_PADDING_SIZE); + + if(IS_MARKER(AV_RB32(buf))){ /* frame starts with marker and needs to be parsed */ +- uint8_t *start, *end, *next; ++ const uint8_t *start, *end, *next; + int size; + + next = buf; +@@ -4005,7 +4000,7 @@ + } + } + }else if(v->interlace && ((buf[0] & 0xC0) == 0xC0)){ /* WVC1 interlaced stores both fields divided by marker */ +- uint8_t *divider; ++ const uint8_t *divider; + + divider = find_next_marker(buf, buf + buf_size); + if((divider == (buf + buf_size)) || AV_RB32(divider) != VC1_CODE_FIELD){ +@@ -4103,7 +4098,7 @@ + } + + /* Return the Picture timestamp as the frame number */ +- /* we substract 1 because it is added on utils.c */ ++ /* we subtract 1 because it is added on utils.c */ + avctx->frame_number = s->picture_number - 1; + + av_free(buf2); +@@ -4126,6 +4121,7 @@ + av_freep(&v->acpred_plane); + av_freep(&v->over_flags_plane); + av_freep(&v->mb_type_base); ++ ff_intrax8_common_end(&v->x8); + return 0; + } + +diff -u mplayer-1.0~rc2-12/libavcodec/vc1data.h ffmpeg-free-0.svn20080206/libavcodec/vc1data.h +--- mplayer-1.0~rc2-12/libavcodec/vc1data.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/vc1data.h 2007-10-17 11:37:46.000000000 +0200 +@@ -25,8 +25,8 @@ + * VC-1 tables. + */ + +-#ifndef VC1DATA_H +-#define VC1DATA_H ++#ifndef FFMPEG_VC1DATA_H ++#define FFMPEG_VC1DATA_H + + #include + #include "bitstream.h" +@@ -160,4 +160,4 @@ + /* DQScale as specified in 8.1.3.9 - almost identical to 0x40000/i */ + extern const int32_t ff_vc1_dqscale[63]; + +-#endif /* VC1DATA_H */ ++#endif /* FFMPEG_VC1DATA_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/vc1dsp.c ffmpeg-free-0.svn20080206/libavcodec/vc1dsp.c +--- mplayer-1.0~rc2-12/libavcodec/vc1dsp.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/vc1dsp.c 2008-03-20 19:10:59.000000000 +0100 +@@ -90,8 +90,8 @@ + src = block; + dst = block; + for(i = 0; i < 8; i++){ +- t1 = 12 * (src[0] + src[4]); +- t2 = 12 * (src[0] - src[4]); ++ t1 = 12 * (src[0] + src[4]) + 4; ++ t2 = 12 * (src[0] - src[4]) + 4; + t3 = 16 * src[2] + 6 * src[6]; + t4 = 6 * src[2] - 16 * src[6]; + +@@ -105,14 +105,14 @@ + t3 = 9 * src[1] - 16 * src[3] + 4 * src[5] + 15 * src[7]; + t4 = 4 * src[1] - 9 * src[3] + 15 * src[5] - 16 * src[7]; + +- dst[0] = (t5 + t1 + 4) >> 3; +- dst[1] = (t6 + t2 + 4) >> 3; +- dst[2] = (t7 + t3 + 4) >> 3; +- dst[3] = (t8 + t4 + 4) >> 3; +- dst[4] = (t8 - t4 + 4) >> 3; +- dst[5] = (t7 - t3 + 4) >> 3; +- dst[6] = (t6 - t2 + 4) >> 3; +- dst[7] = (t5 - t1 + 4) >> 3; ++ dst[0] = (t5 + t1) >> 3; ++ dst[1] = (t6 + t2) >> 3; ++ dst[2] = (t7 + t3) >> 3; ++ dst[3] = (t8 + t4) >> 3; ++ dst[4] = (t8 - t4) >> 3; ++ dst[5] = (t7 - t3) >> 3; ++ dst[6] = (t6 - t2) >> 3; ++ dst[7] = (t5 - t1) >> 3; + + src += 8; + dst += 8; +@@ -121,8 +121,8 @@ + src = block; + dst = block; + for(i = 0; i < 8; i++){ +- t1 = 12 * (src[ 0] + src[32]); +- t2 = 12 * (src[ 0] - src[32]); ++ t1 = 12 * (src[ 0] + src[32]) + 64; ++ t2 = 12 * (src[ 0] - src[32]) + 64; + t3 = 16 * src[16] + 6 * src[48]; + t4 = 6 * src[16] - 16 * src[48]; + +@@ -136,14 +136,14 @@ + t3 = 9 * src[ 8] - 16 * src[24] + 4 * src[40] + 15 * src[56]; + t4 = 4 * src[ 8] - 9 * src[24] + 15 * src[40] - 16 * src[56]; + +- dst[ 0] = (t5 + t1 + 64) >> 7; +- dst[ 8] = (t6 + t2 + 64) >> 7; +- dst[16] = (t7 + t3 + 64) >> 7; +- dst[24] = (t8 + t4 + 64) >> 7; +- dst[32] = (t8 - t4 + 64 + 1) >> 7; +- dst[40] = (t7 - t3 + 64 + 1) >> 7; +- dst[48] = (t6 - t2 + 64 + 1) >> 7; +- dst[56] = (t5 - t1 + 64 + 1) >> 7; ++ dst[ 0] = (t5 + t1) >> 7; ++ dst[ 8] = (t6 + t2) >> 7; ++ dst[16] = (t7 + t3) >> 7; ++ dst[24] = (t8 + t4) >> 7; ++ dst[32] = (t8 - t4 + 1) >> 7; ++ dst[40] = (t7 - t3 + 1) >> 7; ++ dst[48] = (t6 - t2 + 1) >> 7; ++ dst[56] = (t5 - t1 + 1) >> 7; + + src++; + dst++; +@@ -152,19 +152,18 @@ + + /** Do inverse transform on 8x4 part of block + */ +-static void vc1_inv_trans_8x4_c(DCTELEM block[64], int n) ++static void vc1_inv_trans_8x4_c(uint8_t *dest, int linesize, DCTELEM *block) + { + int i; + register int t1,t2,t3,t4,t5,t6,t7,t8; + DCTELEM *src, *dst; +- int off; ++ const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; + +- off = n * 32; +- src = block + off; +- dst = block + off; ++ src = block; ++ dst = block; + for(i = 0; i < 4; i++){ +- t1 = 12 * (src[0] + src[4]); +- t2 = 12 * (src[0] - src[4]); ++ t1 = 12 * (src[0] + src[4]) + 4; ++ t2 = 12 * (src[0] - src[4]) + 4; + t3 = 16 * src[2] + 6 * src[6]; + t4 = 6 * src[2] - 16 * src[6]; + +@@ -178,73 +177,66 @@ + t3 = 9 * src[1] - 16 * src[3] + 4 * src[5] + 15 * src[7]; + t4 = 4 * src[1] - 9 * src[3] + 15 * src[5] - 16 * src[7]; + +- dst[0] = (t5 + t1 + 4) >> 3; +- dst[1] = (t6 + t2 + 4) >> 3; +- dst[2] = (t7 + t3 + 4) >> 3; +- dst[3] = (t8 + t4 + 4) >> 3; +- dst[4] = (t8 - t4 + 4) >> 3; +- dst[5] = (t7 - t3 + 4) >> 3; +- dst[6] = (t6 - t2 + 4) >> 3; +- dst[7] = (t5 - t1 + 4) >> 3; ++ dst[0] = (t5 + t1) >> 3; ++ dst[1] = (t6 + t2) >> 3; ++ dst[2] = (t7 + t3) >> 3; ++ dst[3] = (t8 + t4) >> 3; ++ dst[4] = (t8 - t4) >> 3; ++ dst[5] = (t7 - t3) >> 3; ++ dst[6] = (t6 - t2) >> 3; ++ dst[7] = (t5 - t1) >> 3; + + src += 8; + dst += 8; + } + +- src = block + off; +- dst = block + off; ++ src = block; + for(i = 0; i < 8; i++){ +- t1 = 17 * (src[ 0] + src[16]); +- t2 = 17 * (src[ 0] - src[16]); +- t3 = 22 * src[ 8]; +- t4 = 22 * src[24]; +- t5 = 10 * src[ 8]; +- t6 = 10 * src[24]; +- +- dst[ 0] = (t1 + t3 + t6 + 64) >> 7; +- dst[ 8] = (t2 - t4 + t5 + 64) >> 7; +- dst[16] = (t2 + t4 - t5 + 64) >> 7; +- dst[24] = (t1 - t3 - t6 + 64) >> 7; ++ t1 = 17 * (src[ 0] + src[16]) + 64; ++ t2 = 17 * (src[ 0] - src[16]) + 64; ++ t3 = 22 * src[ 8] + 10 * src[24]; ++ t4 = 22 * src[24] - 10 * src[ 8]; ++ ++ dest[0*linesize] = cm[dest[0*linesize] + ((t1 + t3) >> 7)]; ++ dest[1*linesize] = cm[dest[1*linesize] + ((t2 - t4) >> 7)]; ++ dest[2*linesize] = cm[dest[2*linesize] + ((t2 + t4) >> 7)]; ++ dest[3*linesize] = cm[dest[3*linesize] + ((t1 - t3) >> 7)]; + + src ++; +- dst ++; ++ dest++; + } + } + + /** Do inverse transform on 4x8 parts of block + */ +-static void vc1_inv_trans_4x8_c(DCTELEM block[64], int n) ++static void vc1_inv_trans_4x8_c(uint8_t *dest, int linesize, DCTELEM *block) + { + int i; + register int t1,t2,t3,t4,t5,t6,t7,t8; + DCTELEM *src, *dst; +- int off; ++ const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; + +- off = n * 4; +- src = block + off; +- dst = block + off; ++ src = block; ++ dst = block; + for(i = 0; i < 8; i++){ +- t1 = 17 * (src[0] + src[2]); +- t2 = 17 * (src[0] - src[2]); +- t3 = 22 * src[1]; +- t4 = 22 * src[3]; +- t5 = 10 * src[1]; +- t6 = 10 * src[3]; +- +- dst[0] = (t1 + t3 + t6 + 4) >> 3; +- dst[1] = (t2 - t4 + t5 + 4) >> 3; +- dst[2] = (t2 + t4 - t5 + 4) >> 3; +- dst[3] = (t1 - t3 - t6 + 4) >> 3; ++ t1 = 17 * (src[0] + src[2]) + 4; ++ t2 = 17 * (src[0] - src[2]) + 4; ++ t3 = 22 * src[1] + 10 * src[3]; ++ t4 = 22 * src[3] - 10 * src[1]; ++ ++ dst[0] = (t1 + t3) >> 3; ++ dst[1] = (t2 - t4) >> 3; ++ dst[2] = (t2 + t4) >> 3; ++ dst[3] = (t1 - t3) >> 3; + + src += 8; + dst += 8; + } + +- src = block + off; +- dst = block + off; ++ src = block; + for(i = 0; i < 4; i++){ +- t1 = 12 * (src[ 0] + src[32]); +- t2 = 12 * (src[ 0] - src[32]); ++ t1 = 12 * (src[ 0] + src[32]) + 64; ++ t2 = 12 * (src[ 0] - src[32]) + 64; + t3 = 16 * src[16] + 6 * src[48]; + t4 = 6 * src[16] - 16 * src[48]; + +@@ -258,66 +250,60 @@ + t3 = 9 * src[ 8] - 16 * src[24] + 4 * src[40] + 15 * src[56]; + t4 = 4 * src[ 8] - 9 * src[24] + 15 * src[40] - 16 * src[56]; + +- dst[ 0] = (t5 + t1 + 64) >> 7; +- dst[ 8] = (t6 + t2 + 64) >> 7; +- dst[16] = (t7 + t3 + 64) >> 7; +- dst[24] = (t8 + t4 + 64) >> 7; +- dst[32] = (t8 - t4 + 64 + 1) >> 7; +- dst[40] = (t7 - t3 + 64 + 1) >> 7; +- dst[48] = (t6 - t2 + 64 + 1) >> 7; +- dst[56] = (t5 - t1 + 64 + 1) >> 7; ++ dest[0*linesize] = cm[dest[0*linesize] + ((t5 + t1) >> 7)]; ++ dest[1*linesize] = cm[dest[1*linesize] + ((t6 + t2) >> 7)]; ++ dest[2*linesize] = cm[dest[2*linesize] + ((t7 + t3) >> 7)]; ++ dest[3*linesize] = cm[dest[3*linesize] + ((t8 + t4) >> 7)]; ++ dest[4*linesize] = cm[dest[4*linesize] + ((t8 - t4 + 1) >> 7)]; ++ dest[5*linesize] = cm[dest[5*linesize] + ((t7 - t3 + 1) >> 7)]; ++ dest[6*linesize] = cm[dest[6*linesize] + ((t6 - t2 + 1) >> 7)]; ++ dest[7*linesize] = cm[dest[7*linesize] + ((t5 - t1 + 1) >> 7)]; + +- src++; +- dst++; ++ src ++; ++ dest++; + } + } + + /** Do inverse transform on 4x4 part of block + */ +-static void vc1_inv_trans_4x4_c(DCTELEM block[64], int n) ++static void vc1_inv_trans_4x4_c(uint8_t *dest, int linesize, DCTELEM *block) + { + int i; +- register int t1,t2,t3,t4,t5,t6; ++ register int t1,t2,t3,t4; + DCTELEM *src, *dst; +- int off; ++ const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; + +- off = (n&1) * 4 + (n&2) * 16; +- src = block + off; +- dst = block + off; ++ src = block; ++ dst = block; + for(i = 0; i < 4; i++){ +- t1 = 17 * (src[0] + src[2]); +- t2 = 17 * (src[0] - src[2]); +- t3 = 22 * src[1]; +- t4 = 22 * src[3]; +- t5 = 10 * src[1]; +- t6 = 10 * src[3]; +- +- dst[0] = (t1 + t3 + t6 + 4) >> 3; +- dst[1] = (t2 - t4 + t5 + 4) >> 3; +- dst[2] = (t2 + t4 - t5 + 4) >> 3; +- dst[3] = (t1 - t3 - t6 + 4) >> 3; ++ t1 = 17 * (src[0] + src[2]) + 4; ++ t2 = 17 * (src[0] - src[2]) + 4; ++ t3 = 22 * src[1] + 10 * src[3]; ++ t4 = 22 * src[3] - 10 * src[1]; ++ ++ dst[0] = (t1 + t3) >> 3; ++ dst[1] = (t2 - t4) >> 3; ++ dst[2] = (t2 + t4) >> 3; ++ dst[3] = (t1 - t3) >> 3; + + src += 8; + dst += 8; + } + +- src = block + off; +- dst = block + off; ++ src = block; + for(i = 0; i < 4; i++){ +- t1 = 17 * (src[ 0] + src[16]); +- t2 = 17 * (src[ 0] - src[16]); +- t3 = 22 * src[ 8]; +- t4 = 22 * src[24]; +- t5 = 10 * src[ 8]; +- t6 = 10 * src[24]; +- +- dst[ 0] = (t1 + t3 + t6 + 64) >> 7; +- dst[ 8] = (t2 - t4 + t5 + 64) >> 7; +- dst[16] = (t2 + t4 - t5 + 64) >> 7; +- dst[24] = (t1 - t3 - t6 + 64) >> 7; ++ t1 = 17 * (src[ 0] + src[16]) + 64; ++ t2 = 17 * (src[ 0] - src[16]) + 64; ++ t3 = 22 * src[ 8] + 10 * src[24]; ++ t4 = 22 * src[24] - 10 * src[ 8]; ++ ++ dest[0*linesize] = cm[dest[0*linesize] + ((t1 + t3) >> 7)]; ++ dest[1*linesize] = cm[dest[1*linesize] + ((t2 - t4) >> 7)]; ++ dest[2*linesize] = cm[dest[2*linesize] + ((t2 + t4) >> 7)]; ++ dest[3*linesize] = cm[dest[3*linesize] + ((t1 - t3) >> 7)]; + + src ++; +- dst ++; ++ dest++; + } + } + +diff -u mplayer-1.0~rc2-12/libavcodec/vc1.h ffmpeg-free-0.svn20080206/libavcodec/vc1.h +--- mplayer-1.0~rc2-12/libavcodec/vc1.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/vc1.h 2008-01-14 07:10:02.000000000 +0100 +@@ -20,11 +20,12 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef AVCODEC_VC1_H +-#define AVCODEC_VC1_H ++#ifndef FFMPEG_VC1_H ++#define FFMPEG_VC1_H + + #include "avcodec.h" + #include "mpegvideo.h" ++#include "intrax8.h" + + /** Markers used in VC-1 AP frame data */ + //@{ +@@ -156,6 +157,7 @@ + */ + typedef struct VC1Context{ + MpegEncContext s; ++ IntraX8Context x8; + + int bits; + +@@ -214,6 +216,8 @@ + int k_y; ///< Number of bits for MVs (depends on MV range) + int range_x, range_y; ///< MV range + uint8_t pq, altpq; ///< Current/alternate frame quantizer scale ++ const uint8_t* zz_8x4;///< Zigzag scan table for TT_8x4 coding mode ++ const uint8_t* zz_4x8;///< Zigzag scan table for TT_4x8 coding mode + /** pquant parameters */ + //@{ + uint8_t dquantfrm; +@@ -302,6 +306,7 @@ + + int p_frame_skipped; + int bi_type; ++ int x8_type; + } VC1Context; + +-#endif // AVCODEC_VC1_H ++#endif /* FFMPEG_VC1_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/vcr1.c ffmpeg-free-0.svn20080206/libavcodec/vcr1.c +--- mplayer-1.0~rc2-12/libavcodec/vcr1.c 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/vcr1.c 2008-03-20 19:10:59.000000000 +0100 +@@ -39,12 +39,12 @@ + + static int decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + VCR1Context * const a = avctx->priv_data; + AVFrame *picture = data; + AVFrame * const p= (AVFrame*)&a->picture; +- uint8_t *bytestream= buf; ++ const uint8_t *bytestream= buf; + int i, x, y; + + if(p->data[0]) +diff -u mplayer-1.0~rc2-12/libavcodec/vmdav.c ffmpeg-free-0.svn20080206/libavcodec/vmdav.c +--- mplayer-1.0~rc2-12/libavcodec/vmdav.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/vmdav.c 2008-03-20 19:10:59.000000000 +0100 +@@ -61,7 +61,7 @@ + AVFrame frame; + AVFrame prev_frame; + +- unsigned char *buf; ++ const unsigned char *buf; + int size; + + unsigned char palette[PALETTE_COUNT * 4]; +@@ -74,9 +74,9 @@ + #define QUEUE_SIZE 0x1000 + #define QUEUE_MASK 0x0FFF + +-static void lz_unpack(unsigned char *src, unsigned char *dest, int dest_len) ++static void lz_unpack(const unsigned char *src, unsigned char *dest, int dest_len) + { +- unsigned char *s; ++ const unsigned char *s; + unsigned char *d; + unsigned char *d_end; + unsigned char queue[QUEUE_SIZE]; +@@ -144,10 +144,10 @@ + } + } + +-static int rle_unpack(unsigned char *src, unsigned char *dest, ++static int rle_unpack(const unsigned char *src, unsigned char *dest, + int src_len, int dest_len) + { +- unsigned char *ps; ++ const unsigned char *ps; + unsigned char *pd; + int i, l; + unsigned char *dest_end = dest + dest_len; +@@ -190,9 +190,9 @@ + unsigned char r, g, b; + + /* point to the start of the encoded data */ +- unsigned char *p = s->buf + 16; ++ const unsigned char *p = s->buf + 16; + +- unsigned char *pb; ++ const unsigned char *pb; + unsigned char meth; + unsigned char *dp; /* pointer to current frame */ + unsigned char *pp; /* pointer to previous frame */ +@@ -368,7 +368,7 @@ + + static int vmdvideo_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + VmdVideoContext *s = avctx->priv_data; + +@@ -457,7 +457,7 @@ + } + + static void vmdaudio_decode_audio(VmdAudioContext *s, unsigned char *data, +- uint8_t *buf, int stereo) ++ const uint8_t *buf, int stereo) + { + int i; + int chan = 0; +@@ -475,7 +475,7 @@ + } + + static int vmdaudio_loadsound(VmdAudioContext *s, unsigned char *data, +- uint8_t *buf, int silence) ++ const uint8_t *buf, int silence) + { + int bytes_decoded = 0; + int i; +@@ -522,13 +522,13 @@ + + static int vmdaudio_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + VmdAudioContext *s = avctx->priv_data; + unsigned char *output_samples = (unsigned char *)data; + + /* point to the start of the encoded data */ +- unsigned char *p = buf + 16; ++ const unsigned char *p = buf + 16; + + if (buf_size < 16) + return buf_size; +diff -u mplayer-1.0~rc2-12/libavcodec/vmnc.c ffmpeg-free-0.svn20080206/libavcodec/vmnc.c +--- mplayer-1.0~rc2-12/libavcodec/vmnc.c 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/vmnc.c 2008-03-20 19:10:59.000000000 +0100 +@@ -70,7 +70,7 @@ + } VmncContext; + + /* read pixel value from stream */ +-static av_always_inline int vmnc_get_pixel(uint8_t* buf, int bpp, int be) { ++static av_always_inline int vmnc_get_pixel(const uint8_t* buf, int bpp, int be) { + switch(bpp * 2 + be) { + case 2: + case 3: return *buf; +@@ -82,7 +82,7 @@ + } + } + +-static void load_cursor(VmncContext *c, uint8_t *src) ++static void load_cursor(VmncContext *c, const uint8_t *src) + { + int i, j, p; + const int bpp = c->bpp2; +@@ -169,7 +169,7 @@ + } + } + +-/* fill rectangle with given colour */ ++/* fill rectangle with given color */ + static av_always_inline void paint_rect(uint8_t *dst, int dx, int dy, int w, int h, int color, int bpp, int stride) + { + int i, j; +@@ -200,7 +200,7 @@ + } + } + +-static av_always_inline void paint_raw(uint8_t *dst, int w, int h, uint8_t* src, int bpp, int be, int stride) ++static av_always_inline void paint_raw(uint8_t *dst, int w, int h, const uint8_t* src, int bpp, int be, int stride) + { + int i, j, p; + for(j = 0; j < h; j++) { +@@ -223,14 +223,14 @@ + } + } + +-static int decode_hextile(VmncContext *c, uint8_t* dst, uint8_t* src, int ssize, int w, int h, int stride) ++static int decode_hextile(VmncContext *c, uint8_t* dst, const uint8_t* src, int ssize, int w, int h, int stride) + { + int i, j, k; + int bg = 0, fg = 0, rects, color, flags, xy, wh; + const int bpp = c->bpp2; + uint8_t *dst2; + int bw = 16, bh = 16; +- uint8_t *ssrc=src; ++ const uint8_t *ssrc=src; + + for(j = 0; j < h; j += 16) { + dst2 = dst; +@@ -283,11 +283,11 @@ + return src - ssrc; + } + +-static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8_t *buf, int buf_size) ++static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, const uint8_t *buf, int buf_size) + { + VmncContext * const c = avctx->priv_data; + uint8_t *outptr; +- uint8_t *src = buf; ++ const uint8_t *src = buf; + int dx, dy, w, h, depth, enc, chunks, res, size_left; + + c->pic.reference = 1; +diff -u mplayer-1.0~rc2-12/libavcodec/vorbis_dec.c ffmpeg-free-0.svn20080206/libavcodec/vorbis_dec.c +--- mplayer-1.0~rc2-12/libavcodec/vorbis_dec.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/vorbis_dec.c 2008-03-20 19:10:59.000000000 +0100 +@@ -237,9 +237,9 @@ + + AV_DEBUG(" Codebooks: %d \n", vc->codebook_count); + +- vc->codebooks=(vorbis_codebook *)av_mallocz(vc->codebook_count * sizeof(vorbis_codebook)); +- tmp_vlc_bits=(uint8_t *)av_mallocz(V_MAX_VLCS * sizeof(uint8_t)); +- tmp_vlc_codes=(uint32_t *)av_mallocz(V_MAX_VLCS * sizeof(uint32_t)); ++ vc->codebooks=av_mallocz(vc->codebook_count * sizeof(vorbis_codebook)); ++ tmp_vlc_bits =av_mallocz(V_MAX_VLCS * sizeof(uint8_t)); ++ tmp_vlc_codes=av_mallocz(V_MAX_VLCS * sizeof(uint32_t)); + + for(cb=0;cbcodebook_count;++cb) { + vorbis_codebook *codebook_setup=&vc->codebooks[cb]; +@@ -351,7 +351,7 @@ + } + + // Weed out unused vlcs and build codevector vector +- codebook_setup->codevectors=used_entries ? (float *)av_mallocz(used_entries*codebook_setup->dimensions * sizeof(float)) : NULL; ++ codebook_setup->codevectors=used_entries ? av_mallocz(used_entries*codebook_setup->dimensions * sizeof(float)) : NULL; + for(j=0, i=0;idimensions; + +@@ -459,7 +459,7 @@ + + vc->floor_count=get_bits(gb, 6)+1; + +- vc->floors=(vorbis_floor *)av_mallocz(vc->floor_count * sizeof(vorbis_floor)); ++ vc->floors=av_mallocz(vc->floor_count * sizeof(vorbis_floor)); + + for (i=0;ifloor_count;++i) { + vorbis_floor *floor_setup=&vc->floors[i]; +@@ -517,7 +517,7 @@ + floor_setup->data.t1.x_list_dim+=floor_setup->data.t1.class_dimensions[floor_setup->data.t1.partition_class[j]]; + } + +- floor_setup->data.t1.list=(floor1_entry_t *)av_mallocz(floor_setup->data.t1.x_list_dim * sizeof(floor1_entry_t)); ++ floor_setup->data.t1.list=av_mallocz(floor_setup->data.t1.x_list_dim * sizeof(floor1_entry_t)); + + + rangebits=get_bits(gb, 4); +@@ -623,7 +623,7 @@ + uint_fast8_t i, j, k; + + vc->residue_count=get_bits(gb, 6)+1; +- vc->residues=(vorbis_residue *)av_mallocz(vc->residue_count * sizeof(vorbis_residue)); ++ vc->residues=av_mallocz(vc->residue_count * sizeof(vorbis_residue)); + + AV_DEBUG(" There are %d residues. \n", vc->residue_count); + +@@ -684,7 +684,7 @@ + uint_fast8_t i, j; + + vc->mapping_count=get_bits(gb, 6)+1; +- vc->mappings=(vorbis_mapping *)av_mallocz(vc->mapping_count * sizeof(vorbis_mapping)); ++ vc->mappings=av_mallocz(vc->mapping_count * sizeof(vorbis_mapping)); + + AV_DEBUG(" There are %d mappings. \n", vc->mapping_count); + +@@ -703,8 +703,8 @@ + + if (get_bits1(gb)) { + mapping_setup->coupling_steps=get_bits(gb, 8)+1; +- mapping_setup->magnitude=(uint_fast8_t *)av_mallocz(mapping_setup->coupling_steps * sizeof(uint_fast8_t)); +- mapping_setup->angle=(uint_fast8_t *)av_mallocz(mapping_setup->coupling_steps * sizeof(uint_fast8_t)); ++ mapping_setup->magnitude=av_mallocz(mapping_setup->coupling_steps * sizeof(uint_fast8_t)); ++ mapping_setup->angle =av_mallocz(mapping_setup->coupling_steps * sizeof(uint_fast8_t)); + for(j=0;jcoupling_steps;++j) { + mapping_setup->magnitude[j]=get_bits(gb, ilog(vc->audio_channels-1)); + mapping_setup->angle[j]=get_bits(gb, ilog(vc->audio_channels-1)); +@@ -722,7 +722,7 @@ + } + + if (mapping_setup->submaps>1) { +- mapping_setup->mux=(uint_fast8_t *)av_mallocz(vc->audio_channels * sizeof(uint_fast8_t)); ++ mapping_setup->mux=av_mallocz(vc->audio_channels * sizeof(uint_fast8_t)); + for(j=0;jaudio_channels;++j) { + mapping_setup->mux[j]=get_bits(gb, 4); + } +@@ -784,7 +784,7 @@ + uint_fast8_t i; + + vc->mode_count=get_bits(gb, 6)+1; +- vc->modes=(vorbis_mode *)av_mallocz(vc->mode_count * sizeof(vorbis_mode)); ++ vc->modes=av_mallocz(vc->mode_count * sizeof(vorbis_mode)); + + AV_DEBUG(" There are %d modes.\n", vc->mode_count); + +@@ -897,12 +897,12 @@ + return 2; + } + +- vc->channel_residues=(float *)av_malloc((vc->blocksize[1]/2)*vc->audio_channels * sizeof(float)); +- vc->channel_floors=(float *)av_malloc((vc->blocksize[1]/2)*vc->audio_channels * sizeof(float)); +- vc->saved=(float *)av_malloc((vc->blocksize[1]/2)*vc->audio_channels * sizeof(float)); +- vc->ret=(float *)av_malloc((vc->blocksize[1]/2)*vc->audio_channels * sizeof(float)); +- vc->buf=(float *)av_malloc(vc->blocksize[1] * sizeof(float)); +- vc->buf_tmp=(float *)av_malloc(vc->blocksize[1] * sizeof(float)); ++ vc->channel_residues= av_malloc((vc->blocksize[1]/2)*vc->audio_channels * sizeof(float)); ++ vc->channel_floors = av_malloc((vc->blocksize[1]/2)*vc->audio_channels * sizeof(float)); ++ vc->saved = av_mallocz((vc->blocksize[1]/2)*vc->audio_channels * sizeof(float)); ++ vc->ret = av_malloc((vc->blocksize[1]/2)*vc->audio_channels * sizeof(float)); ++ vc->buf = av_malloc( vc->blocksize[1] * sizeof(float)); ++ vc->buf_tmp = av_malloc( vc->blocksize[1] * sizeof(float)); + vc->saved_start=0; + + ff_mdct_init(&vc->mdct[0], bl0, 1); +@@ -1006,6 +1006,7 @@ + if ( book_idx >= vf->num_books ) { + av_log( vc->avccontext, AV_LOG_ERROR, + "floor0 dec: booknumber too high!\n" ); ++ book_idx= 0; + //FIXME: look above + } + AV_DEBUG( "floor0 dec: booknumber: %u\n", book_idx ); +@@ -1578,7 +1579,7 @@ + + static int vorbis_decode_frame(AVCodecContext *avccontext, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + vorbis_context *vc = avccontext->priv_data ; + GetBitContext *gb = &(vc->gb); +diff -u mplayer-1.0~rc2-12/libavcodec/vorbis_enc_data.h ffmpeg-free-0.svn20080206/libavcodec/vorbis_enc_data.h +--- mplayer-1.0~rc2-12/libavcodec/vorbis_enc_data.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/vorbis_enc_data.h 2007-10-17 11:37:46.000000000 +0200 +@@ -18,8 +18,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef AVCODEC_VORBIS_ENC_DATA_H +-#define AVCODEC_VORBIS_ENC_DATA_H ++#ifndef FFMPEG_VORBIS_ENC_DATA_H ++#define FFMPEG_VORBIS_ENC_DATA_H + + #include + +@@ -502,4 +502,4 @@ + { 3, 2, 3, (const int[]){ -1, 12, 13, 14 } }, + }; + +-#endif // AVCODEC_VORBIS_ENC_DATA_H ++#endif /* FFMPEG_VORBIS_ENC_DATA_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/vorbis.h ffmpeg-free-0.svn20080206/libavcodec/vorbis.h +--- mplayer-1.0~rc2-12/libavcodec/vorbis.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/vorbis.h 2007-10-17 11:37:46.000000000 +0200 +@@ -18,8 +18,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef VORBIS_H +-#define VORBIS_H ++#ifndef FFMPEG_VORBIS_H ++#define FFMPEG_VORBIS_H + + #include "avcodec.h" + +@@ -40,4 +40,4 @@ + + #define ilog(i) av_log2(2*(i)) + +-#endif ++#endif /* FFMPEG_VORBIS_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/vp3.c ffmpeg-free-0.svn20080206/libavcodec/vp3.c +--- mplayer-1.0~rc2-12/libavcodec/vp3.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/vp3.c 2008-03-20 19:10:59.000000000 +0100 +@@ -2126,7 +2126,7 @@ + */ + static int vp3_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + Vp3DecodeContext *s = avctx->priv_data; + GetBitContext gb; +diff -u mplayer-1.0~rc2-12/libavcodec/vp3data.h ffmpeg-free-0.svn20080206/libavcodec/vp3data.h +--- mplayer-1.0~rc2-12/libavcodec/vp3data.h 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/vp3data.h 2007-10-17 11:37:46.000000000 +0200 +@@ -18,8 +18,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef VP3DATA_H +-#define VP3DATA_H ++#ifndef FFMPEG_VP3DATA_H ++#define FFMPEG_VP3DATA_H + + #include + #include +@@ -3178,4 +3178,4 @@ + } + }; + +-#endif /* VP3DATA_H */ ++#endif /* FFMPEG_VP3DATA_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/vp56.c ffmpeg-free-0.svn20080206/libavcodec/vp56.c +--- mplayer-1.0~rc2-12/libavcodec/vp56.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/vp56.c 2008-03-20 19:10:59.000000000 +0100 +@@ -495,7 +495,7 @@ + } + + int vp56_decode_frame(AVCodecContext *avctx, void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + vp56_context_t *s = avctx->priv_data; + AVFrame *const p = s->framep[VP56_FRAME_CURRENT]; +diff -u mplayer-1.0~rc2-12/libavcodec/vp56data.c ffmpeg-free-0.svn20080206/libavcodec/vp56data.c +--- mplayer-1.0~rc2-12/libavcodec/vp56data.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/vp56data.c 2008-03-20 19:10:59.000000000 +0100 +@@ -62,5 +62,5 @@ + { 2,10}, {-4}, {-5}, + }; + +-const uint8_t vp56_coeff_bias[] = { 5, 7, 11, 19, 35, 67 }; ++const uint8_t vp56_coeff_bias[] = { 0, 1, 2, 3, 4, 5, 7, 11, 19, 35, 67 }; + const uint8_t vp56_coeff_bit_length[] = { 0, 1, 2, 3, 4, 10 }; +diff -u mplayer-1.0~rc2-12/libavcodec/vp56data.h ffmpeg-free-0.svn20080206/libavcodec/vp56data.h +--- mplayer-1.0~rc2-12/libavcodec/vp56data.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/vp56data.h 2007-10-17 11:37:46.000000000 +0200 +@@ -21,8 +21,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef VP56DATA_H +-#define VP56DATA_H ++#ifndef FFMPEG_VP56DATA_H ++#define FFMPEG_VP56DATA_H + + #include "common.h" + +@@ -248,4 +248,4 @@ + { 2, -2 }, + }; + +-#endif /* VP56DATA */ ++#endif /* FFMPEG_VP56DATA_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/vp56.h ffmpeg-free-0.svn20080206/libavcodec/vp56.h +--- mplayer-1.0~rc2-12/libavcodec/vp56.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/vp56.h 2008-02-01 17:16:40.000000000 +0100 +@@ -21,8 +21,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef VP56_H +-#define VP56_H ++#ifndef FFMPEG_VP56_H ++#define FFMPEG_VP56_H + + #include "vp56data.h" + #include "dsputil.h" +@@ -43,13 +43,13 @@ + typedef void (*vp56_default_models_init_t)(vp56_context_t *s); + typedef void (*vp56_parse_vector_models_t)(vp56_context_t *s); + typedef void (*vp56_parse_coeff_models_t)(vp56_context_t *s); +-typedef int (*vp56_parse_header_t)(vp56_context_t *s, uint8_t *buf, ++typedef int (*vp56_parse_header_t)(vp56_context_t *s, const uint8_t *buf, + int buf_size, int *golden_frame); + + typedef struct { + int high; + int bits; +- uint8_t *buffer; ++ const uint8_t *buffer; + unsigned long code_word; + } vp56_range_coder_t; + +@@ -157,6 +157,14 @@ + + vp56_model_t *modelp; + vp56_model_t models[2]; ++ ++ /* huffman decoding */ ++ int use_huffman; ++ GetBitContext gb; ++ VLC dccv_vlc[2]; ++ VLC runv_vlc[2]; ++ VLC ract_vlc[2][3][6]; ++ unsigned int nb_null[2][2]; /* number of consecutive NULL DC/AC */ + }; + + +@@ -164,7 +172,7 @@ + int vp56_free(AVCodecContext *avctx); + void vp56_init_dequant(vp56_context_t *s, int quantizer); + int vp56_decode_frame(AVCodecContext *avctx, void *data, int *data_size, +- uint8_t *buf, int buf_size); ++ const uint8_t *buf, int buf_size); + + + /** +@@ -172,7 +180,7 @@ + */ + + static inline void vp56_init_range_decoder(vp56_range_coder_t *c, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + c->high = 255; + c->bits = 8; +@@ -257,4 +265,4 @@ + return -tree->val; + } + +-#endif /* VP56_H */ ++#endif /* FFMPEG_VP56_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/vp5.c ffmpeg-free-0.svn20080206/libavcodec/vp5.c +--- mplayer-1.0~rc2-12/libavcodec/vp5.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/vp5.c 2008-03-20 19:10:59.000000000 +0100 +@@ -34,7 +34,7 @@ + #include "vp5data.h" + + +-static int vp5_parse_header(vp56_context_t *s, uint8_t *buf, int buf_size, ++static int vp5_parse_header(vp56_context_t *s, const uint8_t *buf, int buf_size, + int *golden_frame) + { + vp56_range_coder_t *c = &s->c; +@@ -205,7 +205,7 @@ + s->coeff_ctx[vp56_b6to4[b]][coeff_idx] = 4; + idx = vp56_rac_get_tree(c, vp56_pc_tree, model1); + sign = vp56_rac_get(c); +- coeff = vp56_coeff_bias[idx]; ++ coeff = vp56_coeff_bias[idx+5]; + for (i=vp56_coeff_bit_length[idx]; i>=0; i--) + coeff += vp56_rac_get_prob(c, vp56_coeff_parse_table[idx][i]) << i; + } else { +diff -u mplayer-1.0~rc2-12/libavcodec/vp5data.h ffmpeg-free-0.svn20080206/libavcodec/vp5data.h +--- mplayer-1.0~rc2-12/libavcodec/vp5data.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/vp5data.h 2007-10-17 11:37:46.000000000 +0200 +@@ -21,8 +21,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef VP5DATA_H +-#define VP5DATA_H ++#ifndef FFMPEG_VP5DATA_H ++#define FFMPEG_VP5DATA_H + + #include + +@@ -172,4 +172,4 @@ + + static const uint8_t vp5_coord_div[] = { 2, 2, 2, 2, 4, 4 }; + +-#endif /* VP5DATA_H */ ++#endif /* FFMPEG_VP5DATA_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/vp6.c ffmpeg-free-0.svn20080206/libavcodec/vp6.c +--- mplayer-1.0~rc2-12/libavcodec/vp6.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/vp6.c 2008-03-20 19:10:59.000000000 +0100 +@@ -30,6 +30,7 @@ + #include "avcodec.h" + #include "dsputil.h" + #include "bitstream.h" ++#include "huffman.h" + #include "mpegvideo.h" + + #include "vp56.h" +@@ -37,7 +38,10 @@ + #include "vp6data.h" + + +-static int vp6_parse_header(vp56_context_t *s, uint8_t *buf, int buf_size, ++static void vp6_parse_coeff(vp56_context_t *s); ++static void vp6_parse_coeff_huffman(vp56_context_t *s); ++ ++static int vp6_parse_header(vp56_context_t *s, const uint8_t *buf, int buf_size, + int *golden_frame) + { + vp56_range_coder_t *c = &s->c; +@@ -126,14 +130,19 @@ + s->filter_selection = 16; + } + +- if (vp56_rac_get(c)) +- av_log(s->avctx, AV_LOG_WARNING, +- "alternative entropy decoding not supported\n"); ++ s->use_huffman = vp56_rac_get(c); + ++ s->parse_coeff = vp6_parse_coeff; + if (coeff_offset) { +- vp56_init_range_decoder(&s->cc, buf+coeff_offset, +- buf_size-coeff_offset); +- s->ccp = &s->cc; ++ buf += coeff_offset; ++ buf_size -= coeff_offset; ++ if (s->use_huffman) { ++ s->parse_coeff = vp6_parse_coeff_huffman; ++ init_get_bits(&s->gb, buf, buf_size<<3); ++ } else { ++ vp56_init_range_decoder(&s->cc, buf, buf_size); ++ s->ccp = &s->cc; ++ } + } else { + s->ccp = &s->c; + } +@@ -194,6 +203,31 @@ + model->vector_fdv[comp][node] = vp56_rac_gets_nn(c, 7); + } + ++static int vp6_huff_cmp(const void *va, const void *vb) ++{ ++ const Node *a = va, *b = vb; ++ return a->count >= b->count; ++} ++ ++static void vp6_build_huff_tree(vp56_context_t *s, uint8_t coeff_model[], ++ const uint8_t *map, unsigned size, VLC *vlc) ++{ ++ Node nodes[2*size], *tmp = &nodes[size]; ++ int a, b, i; ++ ++ /* first compute probabilities from model */ ++ tmp[0].count = 256; ++ for (i=0; i> 8; ++ b = tmp[i].count * (255 - coeff_model[i]) >> 8; ++ nodes[map[2*i ]].count = a + !a; ++ nodes[map[2*i+1]].count = b + !b; ++ } ++ ++ /* then build the huffman tree accodring to probabilities */ ++ ff_huff_build_tree(s->avctx, vlc, size, nodes, vp6_huff_cmp, 1); ++} ++ + static void vp6_parse_coeff_models(vp56_context_t *s) + { + vp56_range_coder_t *c = &s->c; +@@ -237,11 +271,26 @@ + model->coeff_ract[pt][ct][cg][node] = def_prob[node]; + } + ++ if (s->use_huffman) { ++ for (pt=0; pt<2; pt++) { ++ vp6_build_huff_tree(s, model->coeff_dccv[pt], ++ vp6_huff_coeff_map, 12, &s->dccv_vlc[pt]); ++ vp6_build_huff_tree(s, model->coeff_runv[pt], ++ vp6_huff_run_map, 9, &s->runv_vlc[pt]); ++ for (ct=0; ct<3; ct++) ++ for (cg = 0; cg < 6; cg++) ++ vp6_build_huff_tree(s, model->coeff_ract[pt][ct][cg], ++ vp6_huff_coeff_map, 12, ++ &s->ract_vlc[pt][ct][cg]); ++ } ++ memset(s->nb_null, 0, sizeof(s->nb_null)); ++ } else { + /* coeff_dcct is a linear combination of coeff_dccv */ + for (pt=0; pt<2; pt++) + for (ctx=0; ctx<3; ctx++) + for (node=0; node<5; node++) + model->coeff_dcct[pt][ctx][node] = av_clip(((model->coeff_dccv[pt][node] * vp6_dccv_lc[ctx][node][0] + 128) >> 8) + vp6_dccv_lc[ctx][node][1], 1, 255); ++ } + } + + static void vp6_parse_vector_adjustment(vp56_context_t *s, vp56_mv_t *vect) +@@ -282,6 +331,77 @@ + } + } + ++/** ++ * Read number of consecutive blocks with null DC or AC. ++ * This value is < 74. ++ */ ++static unsigned vp6_get_nb_null(vp56_context_t *s) ++{ ++ unsigned val = get_bits(&s->gb, 2); ++ if (val == 2) ++ val += get_bits(&s->gb, 2); ++ else if (val == 3) { ++ val = get_bits1(&s->gb) << 2; ++ val = 6+val + get_bits(&s->gb, 2+val); ++ } ++ return val; ++} ++ ++static void vp6_parse_coeff_huffman(vp56_context_t *s) ++{ ++ vp56_model_t *model = s->modelp; ++ uint8_t *permute = s->scantable.permutated; ++ VLC *vlc_coeff; ++ int coeff, sign, coeff_idx; ++ int b, cg, idx; ++ int pt = 0; /* plane type (0 for Y, 1 for U or V) */ ++ ++ for (b=0; b<6; b++) { ++ int ct = 0; /* code type */ ++ if (b > 3) pt = 1; ++ vlc_coeff = &s->dccv_vlc[pt]; ++ ++ for (coeff_idx=0; coeff_idx<64; ) { ++ int run = 1; ++ if (coeff_idx<2 && s->nb_null[coeff_idx][pt]) { ++ s->nb_null[coeff_idx][pt]--; ++ if (coeff_idx) ++ break; ++ } else { ++ coeff = get_vlc2(&s->gb, vlc_coeff->table, 9, 3); ++ if (coeff == 0) { ++ if (coeff_idx) { ++ int pt = (coeff_idx >= 6); ++ run += get_vlc2(&s->gb, s->runv_vlc[pt].table, 9, 3); ++ if (run >= 9) ++ run += get_bits(&s->gb, 6); ++ } else ++ s->nb_null[0][pt] = vp6_get_nb_null(s); ++ ct = 0; ++ } else if (coeff == 11) { /* end of block */ ++ if (coeff_idx == 1) /* first AC coeff ? */ ++ s->nb_null[1][pt] = vp6_get_nb_null(s); ++ break; ++ } else { ++ int coeff2 = vp56_coeff_bias[coeff]; ++ if (coeff > 4) ++ coeff2 += get_bits(&s->gb, coeff <= 9 ? coeff - 4 : 11); ++ ct = 1 + (coeff2 > 1); ++ sign = get_bits1(&s->gb); ++ coeff2 = (coeff2 ^ -sign) + sign; ++ if (coeff_idx) ++ coeff2 *= s->dequant_ac; ++ idx = model->coeff_index_to_pos[coeff_idx]; ++ s->block_coeff[b][permute[idx]] = coeff2; ++ } ++ } ++ coeff_idx+=run; ++ cg = FFMIN(vp6_coeff_groups[coeff_idx], 3); ++ vlc_coeff = &s->ract_vlc[pt][ct][cg]; ++ } ++ } ++} ++ + static void vp6_parse_coeff(vp56_context_t *s) + { + vp56_range_coder_t *c = s->ccp; +@@ -309,7 +429,7 @@ + if (vp56_rac_get_prob(c, model2[2])) { + if (vp56_rac_get_prob(c, model2[3])) { + idx = vp56_rac_get_tree(c, vp56_pc_tree, model1); +- coeff = vp56_coeff_bias[idx]; ++ coeff = vp56_coeff_bias[idx+5]; + for (i=vp56_coeff_bit_length[idx]; i>=0; i--) + coeff += vp56_rac_get_prob(c, vp56_coeff_parse_table[idx][i]) << i; + } else { +@@ -500,7 +620,6 @@ + s->parse_vector_adjustment = vp6_parse_vector_adjustment; + s->adjust = vp6_adjust; + s->filter = vp6_filter; +- s->parse_coeff = vp6_parse_coeff; + s->default_models_init = vp6_default_models_init; + s->parse_vector_models = vp6_parse_vector_models; + s->parse_coeff_models = vp6_parse_coeff_models; +diff -u mplayer-1.0~rc2-12/libavcodec/vp6data.h ffmpeg-free-0.svn20080206/libavcodec/vp6data.h +--- mplayer-1.0~rc2-12/libavcodec/vp6data.h 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/vp6data.h 2007-10-17 11:37:46.000000000 +0200 +@@ -21,8 +21,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef VP6DATA_H +-#define VP6DATA_H ++#ifndef FFMPEG_VP6DATA_H ++#define FFMPEG_VP6DATA_H + + #include "vp56data.h" + +@@ -297,4 +297,12 @@ + + static const uint8_t vp6_coord_div[] = { 4, 4, 4, 4, 8, 8 }; + +-#endif /* VP6DATA_H */ ++static const uint8_t vp6_huff_coeff_map[] = { ++ 13, 14, 11, 0, 1, 15, 16, 18, 2, 17, 3, 4, 19, 20, 5, 6, 21, 22, 7, 8, 9, 10 ++}; ++ ++static const uint8_t vp6_huff_run_map[] = { ++ 10, 13, 11, 12, 0, 1, 2, 3, 14, 8, 15, 16, 4, 5, 6, 7 ++}; ++ ++#endif /* FFMPEG_VP6DATA_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/vqavideo.c ffmpeg-free-0.svn20080206/libavcodec/vqavideo.c +--- mplayer-1.0~rc2-12/libavcodec/vqavideo.c 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/vqavideo.c 2008-03-20 19:10:59.000000000 +0100 +@@ -104,7 +104,7 @@ + DSPContext dsp; + AVFrame frame; + +- unsigned char *buf; ++ const unsigned char *buf; + int size; + + uint32_t palette[PALETTE_COUNT]; +@@ -202,7 +202,7 @@ + return; \ + } + +-static void decode_format80(unsigned char *src, int src_size, ++static void decode_format80(const unsigned char *src, int src_size, + unsigned char *dest, int dest_size, int check_size) { + + int src_index = 0; +@@ -567,7 +567,7 @@ + + static int vqa_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + VqaContext *s = avctx->priv_data; + +diff -u mplayer-1.0~rc2-12/libavcodec/wavpack.c ffmpeg-free-0.svn20080206/libavcodec/wavpack.c +--- mplayer-1.0~rc2-12/libavcodec/wavpack.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/wavpack.c 2008-03-20 19:10:59.000000000 +0100 +@@ -364,22 +364,15 @@ + return 0; + } + +-static int wavpack_decode_close(AVCodecContext *avctx) +-{ +-// WavpackContext *s = avctx->priv_data; +- +- return 0; +-} +- + static int wavpack_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + WavpackContext *s = avctx->priv_data; + int16_t *samples = data; + int samplecount; + int got_terms = 0, got_weights = 0, got_samples = 0, got_entropy = 0, got_bs = 0; +- uint8_t* buf_end = buf + buf_size; ++ const uint8_t* buf_end = buf + buf_size; + int i, j, id, size, ssize, weights, t; + + if (buf_size == 0){ +@@ -587,6 +580,6 @@ + sizeof(WavpackContext), + wavpack_decode_init, + NULL, +- wavpack_decode_close, ++ NULL, + wavpack_decode_frame, + }; +diff -u mplayer-1.0~rc2-12/libavcodec/wmadata.h ffmpeg-free-0.svn20080206/libavcodec/wmadata.h +--- mplayer-1.0~rc2-12/libavcodec/wmadata.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/wmadata.h 2007-10-17 11:37:46.000000000 +0200 +@@ -24,8 +24,8 @@ + * Various WMA tables. + */ + +-#ifndef AVCODEC_WMADATA_H +-#define AVCODEC_WMADATA_H ++#ifndef FFMPEG_WMADATA_H ++#define FFMPEG_WMADATA_H + + #include + #include "wma.h" +@@ -1438,4 +1438,4 @@ + }, + }; + +-#endif // AVCODEC_WMADATA_H ++#endif /* FFMPEG_WMADATA_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/wmadec.c ffmpeg-free-0.svn20080206/libavcodec/wmadec.c +--- mplayer-1.0~rc2-12/libavcodec/wmadec.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/wmadec.c 2008-03-20 19:10:59.000000000 +0100 +@@ -755,7 +755,7 @@ + + static int wma_decode_superframe(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + WMACodecContext *s = avctx->priv_data; + int nb_frames, bit_offset, i, pos, len; +@@ -768,6 +768,9 @@ + s->last_superframe_len = 0; + return 0; + } ++ if (buf_size < s->block_align) ++ return 0; ++ buf_size = s->block_align; + + samples = data; + +diff -u mplayer-1.0~rc2-12/libavcodec/wmaenc.c ffmpeg-free-0.svn20080206/libavcodec/wmaenc.c +--- mplayer-1.0~rc2-12/libavcodec/wmaenc.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/wmaenc.c 2008-03-20 19:10:59.000000000 +0100 +@@ -178,7 +178,7 @@ + } + + for(ch = 0; ch < s->nb_channels; ch++) { +- if (s->channel_coded[ch]= 1) { //FIXME ++ if (s->channel_coded[ch]= 1) { //FIXME only set channel_coded when needed, instead of always + init_exp(s, ch, fixed_exp); + } + } +diff -u mplayer-1.0~rc2-12/libavcodec/wma.h ffmpeg-free-0.svn20080206/libavcodec/wma.h +--- mplayer-1.0~rc2-12/libavcodec/wma.h 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/wma.h 2007-10-17 11:37:46.000000000 +0200 +@@ -19,8 +19,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef WMA_H +-#define WMA_H ++#ifndef FFMPEG_WMA_H ++#define FFMPEG_WMA_H + + #include "bitstream.h" + #include "dsputil.h" +@@ -147,4 +147,4 @@ + int ff_wma_total_gain_to_bits(int total_gain); + int ff_wma_end(AVCodecContext *avctx); + +-#endif ++#endif /* FFMPEG_WMA_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/wmv2.c ffmpeg-free-0.svn20080206/libavcodec/wmv2.c +--- mplayer-1.0~rc2-12/libavcodec/wmv2.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/wmv2.c 2008-03-20 19:10:59.000000000 +0100 +@@ -18,572 +18,20 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-/** +- * @file wmv2.c +- * wmv2 codec. +- */ +- ++#include "avcodec.h" ++#include "mpegvideo.h" ++#include "msmpeg4data.h" + #include "simple_idct.h" ++#include "wmv2.h" + +-#define SKIP_TYPE_NONE 0 +-#define SKIP_TYPE_MPEG 1 +-#define SKIP_TYPE_ROW 2 +-#define SKIP_TYPE_COL 3 +- +- +-typedef struct Wmv2Context{ +- MpegEncContext s; +- int j_type_bit; +- int j_type; +- int abt_flag; +- int abt_type; +- int abt_type_table[6]; +- int per_mb_abt; +- int per_block_abt; +- int mspel_bit; +- int cbp_table_index; +- int top_left_mv_flag; +- int per_mb_rl_bit; +- int skip_type; +- int hshift; +- +- ScanTable abt_scantable[2]; +- DECLARE_ALIGNED_8(DCTELEM, abt_block2[6][64]); +-}Wmv2Context; + +-static void wmv2_common_init(Wmv2Context * w){ ++void ff_wmv2_common_init(Wmv2Context * w){ + MpegEncContext * const s= &w->s; + + ff_init_scantable(s->dsp.idct_permutation, &w->abt_scantable[0], wmv2_scantableA); + ff_init_scantable(s->dsp.idct_permutation, &w->abt_scantable[1], wmv2_scantableB); + } + +-#ifdef CONFIG_WMV2_ENCODER +- +-static int encode_ext_header(Wmv2Context *w){ +- MpegEncContext * const s= &w->s; +- PutBitContext pb; +- int code; +- +- init_put_bits(&pb, s->avctx->extradata, s->avctx->extradata_size); +- +- put_bits(&pb, 5, s->avctx->time_base.den / s->avctx->time_base.num); //yes 29.97 -> 29 +- put_bits(&pb, 11, FFMIN(s->bit_rate/1024, 2047)); +- +- put_bits(&pb, 1, w->mspel_bit=1); +- put_bits(&pb, 1, s->loop_filter); +- put_bits(&pb, 1, w->abt_flag=1); +- put_bits(&pb, 1, w->j_type_bit=1); +- put_bits(&pb, 1, w->top_left_mv_flag=0); +- put_bits(&pb, 1, w->per_mb_rl_bit=1); +- put_bits(&pb, 3, code=1); +- +- flush_put_bits(&pb); +- +- s->slice_height = s->mb_height / code; +- +- return 0; +-} +- +-static int wmv2_encode_init(AVCodecContext *avctx){ +- Wmv2Context * const w= avctx->priv_data; +- +- if(MPV_encode_init(avctx) < 0) +- return -1; +- +- wmv2_common_init(w); +- +- avctx->extradata_size= 4; +- avctx->extradata= av_mallocz(avctx->extradata_size + 10); +- encode_ext_header(w); +- +- return 0; +-} +- +-#if 0 /* unused, remove? */ +-static int wmv2_encode_end(AVCodecContext *avctx){ +- +- if(MPV_encode_end(avctx) < 0) +- return -1; +- +- avctx->extradata_size= 0; +- av_freep(&avctx->extradata); +- +- return 0; +-} +-#endif +- +-int ff_wmv2_encode_picture_header(MpegEncContext * s, int picture_number) +-{ +- Wmv2Context * const w= (Wmv2Context*)s; +- +- put_bits(&s->pb, 1, s->pict_type - 1); +- if(s->pict_type == I_TYPE){ +- put_bits(&s->pb, 7, 0); +- } +- put_bits(&s->pb, 5, s->qscale); +- +- s->dc_table_index = 1; +- s->mv_table_index = 1; /* only if P frame */ +-// s->use_skip_mb_code = 1; /* only if P frame */ +- s->per_mb_rl_table = 0; +- s->mspel= 0; +- w->per_mb_abt=0; +- w->abt_type=0; +- w->j_type=0; +- +- assert(s->flipflop_rounding); +- +- if (s->pict_type == I_TYPE) { +- assert(s->no_rounding==1); +- if(w->j_type_bit) put_bits(&s->pb, 1, w->j_type); +- +- if(w->per_mb_rl_bit) put_bits(&s->pb, 1, s->per_mb_rl_table); +- +- if(!s->per_mb_rl_table){ +- ff_code012(&s->pb, s->rl_chroma_table_index); +- ff_code012(&s->pb, s->rl_table_index); +- } +- +- put_bits(&s->pb, 1, s->dc_table_index); +- +- s->inter_intra_pred= 0; +- }else{ +- int cbp_index; +- +- put_bits(&s->pb, 2, SKIP_TYPE_NONE); +- +- ff_code012(&s->pb, cbp_index=0); +- if(s->qscale <= 10){ +- int map[3]= {0,2,1}; +- w->cbp_table_index= map[cbp_index]; +- }else if(s->qscale <= 20){ +- int map[3]= {1,0,2}; +- w->cbp_table_index= map[cbp_index]; +- }else{ +- int map[3]= {2,1,0}; +- w->cbp_table_index= map[cbp_index]; +- } +- +- if(w->mspel_bit) put_bits(&s->pb, 1, s->mspel); +- +- if(w->abt_flag){ +- put_bits(&s->pb, 1, w->per_mb_abt^1); +- if(!w->per_mb_abt){ +- ff_code012(&s->pb, w->abt_type); +- } +- } +- +- if(w->per_mb_rl_bit) put_bits(&s->pb, 1, s->per_mb_rl_table); +- +- if(!s->per_mb_rl_table){ +- ff_code012(&s->pb, s->rl_table_index); +- s->rl_chroma_table_index = s->rl_table_index; +- } +- put_bits(&s->pb, 1, s->dc_table_index); +- put_bits(&s->pb, 1, s->mv_table_index); +- +- s->inter_intra_pred= 0;//(s->width*s->height < 320*240 && s->bit_rate<=II_BITRATE); +- } +- s->esc3_level_length= 0; +- s->esc3_run_length= 0; +- +- return 0; +-} +- +-/* Nearly identical to wmv1 but that is just because we do not use the +- * useless M$ crap features. It is duplicated here in case someone wants +- * to add support for these crap features. */ +-void ff_wmv2_encode_mb(MpegEncContext * s, +- DCTELEM block[6][64], +- int motion_x, int motion_y) +-{ +- Wmv2Context * const w= (Wmv2Context*)s; +- int cbp, coded_cbp, i; +- int pred_x, pred_y; +- uint8_t *coded_block; +- +- handle_slices(s); +- +- if (!s->mb_intra) { +- /* compute cbp */ +- cbp = 0; +- for (i = 0; i < 6; i++) { +- if (s->block_last_index[i] >= 0) +- cbp |= 1 << (5 - i); +- } +- +- put_bits(&s->pb, +- wmv2_inter_table[w->cbp_table_index][cbp + 64][1], +- wmv2_inter_table[w->cbp_table_index][cbp + 64][0]); +- +- /* motion vector */ +- h263_pred_motion(s, 0, 0, &pred_x, &pred_y); +- msmpeg4_encode_motion(s, motion_x - pred_x, +- motion_y - pred_y); +- } else { +- /* compute cbp */ +- cbp = 0; +- coded_cbp = 0; +- for (i = 0; i < 6; i++) { +- int val, pred; +- val = (s->block_last_index[i] >= 1); +- cbp |= val << (5 - i); +- if (i < 4) { +- /* predict value for close blocks only for luma */ +- pred = coded_block_pred(s, i, &coded_block); +- *coded_block = val; +- val = val ^ pred; +- } +- coded_cbp |= val << (5 - i); +- } +-#if 0 +- if (coded_cbp) +- printf("cbp=%x %x\n", cbp, coded_cbp); +-#endif +- +- if (s->pict_type == I_TYPE) { +- put_bits(&s->pb, +- ff_msmp4_mb_i_table[coded_cbp][1], ff_msmp4_mb_i_table[coded_cbp][0]); +- } else { +- put_bits(&s->pb, +- wmv2_inter_table[w->cbp_table_index][cbp][1], +- wmv2_inter_table[w->cbp_table_index][cbp][0]); +- } +- put_bits(&s->pb, 1, 0); /* no AC prediction yet */ +- if(s->inter_intra_pred){ +- s->h263_aic_dir=0; +- put_bits(&s->pb, table_inter_intra[s->h263_aic_dir][1], table_inter_intra[s->h263_aic_dir][0]); +- } +- } +- +- for (i = 0; i < 6; i++) { +- ff_msmpeg4_encode_block(s, block[i], i); +- } +-} +-#endif //CONFIG_WMV2_ENCODER +- +-static void parse_mb_skip(Wmv2Context * w){ +- int mb_x, mb_y; +- MpegEncContext * const s= &w->s; +- uint32_t * const mb_type= s->current_picture_ptr->mb_type; +- +- w->skip_type= get_bits(&s->gb, 2); +- switch(w->skip_type){ +- case SKIP_TYPE_NONE: +- for(mb_y=0; mb_ymb_height; mb_y++){ +- for(mb_x=0; mb_xmb_width; mb_x++){ +- mb_type[mb_y*s->mb_stride + mb_x]= MB_TYPE_16x16 | MB_TYPE_L0; +- } +- } +- break; +- case SKIP_TYPE_MPEG: +- for(mb_y=0; mb_ymb_height; mb_y++){ +- for(mb_x=0; mb_xmb_width; mb_x++){ +- mb_type[mb_y*s->mb_stride + mb_x]= (get_bits1(&s->gb) ? MB_TYPE_SKIP : 0) | MB_TYPE_16x16 | MB_TYPE_L0; +- } +- } +- break; +- case SKIP_TYPE_ROW: +- for(mb_y=0; mb_ymb_height; mb_y++){ +- if(get_bits1(&s->gb)){ +- for(mb_x=0; mb_xmb_width; mb_x++){ +- mb_type[mb_y*s->mb_stride + mb_x]= MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0; +- } +- }else{ +- for(mb_x=0; mb_xmb_width; mb_x++){ +- mb_type[mb_y*s->mb_stride + mb_x]= (get_bits1(&s->gb) ? MB_TYPE_SKIP : 0) | MB_TYPE_16x16 | MB_TYPE_L0; +- } +- } +- } +- break; +- case SKIP_TYPE_COL: +- for(mb_x=0; mb_xmb_width; mb_x++){ +- if(get_bits1(&s->gb)){ +- for(mb_y=0; mb_ymb_height; mb_y++){ +- mb_type[mb_y*s->mb_stride + mb_x]= MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_L0; +- } +- }else{ +- for(mb_y=0; mb_ymb_height; mb_y++){ +- mb_type[mb_y*s->mb_stride + mb_x]= (get_bits1(&s->gb) ? MB_TYPE_SKIP : 0) | MB_TYPE_16x16 | MB_TYPE_L0; +- } +- } +- } +- break; +- } +-} +- +-static int decode_ext_header(Wmv2Context *w){ +- MpegEncContext * const s= &w->s; +- GetBitContext gb; +- int fps; +- int code; +- +- if(s->avctx->extradata_size<4) return -1; +- +- init_get_bits(&gb, s->avctx->extradata, s->avctx->extradata_size*8); +- +- fps = get_bits(&gb, 5); +- s->bit_rate = get_bits(&gb, 11)*1024; +- w->mspel_bit = get_bits1(&gb); +- s->loop_filter = get_bits1(&gb); +- w->abt_flag = get_bits1(&gb); +- w->j_type_bit = get_bits1(&gb); +- w->top_left_mv_flag= get_bits1(&gb); +- w->per_mb_rl_bit = get_bits1(&gb); +- code = get_bits(&gb, 3); +- +- if(code==0) return -1; +- +- s->slice_height = s->mb_height / code; +- +- if(s->avctx->debug&FF_DEBUG_PICT_INFO){ +- av_log(s->avctx, AV_LOG_DEBUG, "fps:%d, br:%d, qpbit:%d, abt_flag:%d, j_type_bit:%d, tl_mv_flag:%d, mbrl_bit:%d, code:%d, loop_filter:%d, slices:%d\n", +- fps, s->bit_rate, w->mspel_bit, w->abt_flag, w->j_type_bit, w->top_left_mv_flag, w->per_mb_rl_bit, code, s->loop_filter, +- code); +- } +- return 0; +-} +- +-int ff_wmv2_decode_picture_header(MpegEncContext * s) +-{ +- Wmv2Context * const w= (Wmv2Context*)s; +- int code; +- +-#if 0 +-{ +-int i; +-for(i=0; igb.size*8; i++) +- printf("%d", get_bits1(&s->gb)); +-// get_bits1(&s->gb); +-printf("END\n"); +-return -1; +-} +-#endif +- if(s->picture_number==0) +- decode_ext_header(w); +- +- s->pict_type = get_bits1(&s->gb) + 1; +- if(s->pict_type == I_TYPE){ +- code = get_bits(&s->gb, 7); +- av_log(s->avctx, AV_LOG_DEBUG, "I7:%X/\n", code); +- } +- s->chroma_qscale= s->qscale = get_bits(&s->gb, 5); +- if(s->qscale < 0) +- return -1; +- +- return 0; +-} +- +-int ff_wmv2_decode_secondary_picture_header(MpegEncContext * s) +-{ +- Wmv2Context * const w= (Wmv2Context*)s; +- +- if (s->pict_type == I_TYPE) { +- if(w->j_type_bit) w->j_type= get_bits1(&s->gb); +- else w->j_type= 0; //FIXME check +- +- if(!w->j_type){ +- if(w->per_mb_rl_bit) s->per_mb_rl_table= get_bits1(&s->gb); +- else s->per_mb_rl_table= 0; +- +- if(!s->per_mb_rl_table){ +- s->rl_chroma_table_index = decode012(&s->gb); +- s->rl_table_index = decode012(&s->gb); +- } +- +- s->dc_table_index = get_bits1(&s->gb); +- } +- s->inter_intra_pred= 0; +- s->no_rounding = 1; +- if(s->avctx->debug&FF_DEBUG_PICT_INFO){ +- av_log(s->avctx, AV_LOG_DEBUG, "qscale:%d rlc:%d rl:%d dc:%d mbrl:%d j_type:%d \n", +- s->qscale, +- s->rl_chroma_table_index, +- s->rl_table_index, +- s->dc_table_index, +- s->per_mb_rl_table, +- w->j_type); +- } +- }else{ +- int cbp_index; +- w->j_type=0; +- +- parse_mb_skip(w); +- cbp_index= decode012(&s->gb); +- if(s->qscale <= 10){ +- int map[3]= {0,2,1}; +- w->cbp_table_index= map[cbp_index]; +- }else if(s->qscale <= 20){ +- int map[3]= {1,0,2}; +- w->cbp_table_index= map[cbp_index]; +- }else{ +- int map[3]= {2,1,0}; +- w->cbp_table_index= map[cbp_index]; +- } +- +- if(w->mspel_bit) s->mspel= get_bits1(&s->gb); +- else s->mspel= 0; //FIXME check +- +- if(w->abt_flag){ +- w->per_mb_abt= get_bits1(&s->gb)^1; +- if(!w->per_mb_abt){ +- w->abt_type= decode012(&s->gb); +- } +- } +- +- if(w->per_mb_rl_bit) s->per_mb_rl_table= get_bits1(&s->gb); +- else s->per_mb_rl_table= 0; +- +- if(!s->per_mb_rl_table){ +- s->rl_table_index = decode012(&s->gb); +- s->rl_chroma_table_index = s->rl_table_index; +- } +- +- s->dc_table_index = get_bits1(&s->gb); +- s->mv_table_index = get_bits1(&s->gb); +- +- s->inter_intra_pred= 0;//(s->width*s->height < 320*240 && s->bit_rate<=II_BITRATE); +- s->no_rounding ^= 1; +- +- if(s->avctx->debug&FF_DEBUG_PICT_INFO){ +- av_log(s->avctx, AV_LOG_DEBUG, "rl:%d rlc:%d dc:%d mv:%d mbrl:%d qp:%d mspel:%d per_mb_abt:%d abt_type:%d cbp:%d ii:%d\n", +- s->rl_table_index, +- s->rl_chroma_table_index, +- s->dc_table_index, +- s->mv_table_index, +- s->per_mb_rl_table, +- s->qscale, +- s->mspel, +- w->per_mb_abt, +- w->abt_type, +- w->cbp_table_index, +- s->inter_intra_pred); +- } +- } +- s->esc3_level_length= 0; +- s->esc3_run_length= 0; +- +-s->picture_number++; //FIXME ? +- +- +-// if(w->j_type) +-// return wmv2_decode_j_picture(w); //FIXME +- +- if(w->j_type){ +- av_log(s->avctx, AV_LOG_ERROR, "J-type picture is not supported\n"); +- return -1; +- } +- +- return 0; +-} +- +-static inline int wmv2_decode_motion(Wmv2Context *w, int *mx_ptr, int *my_ptr){ +- MpegEncContext * const s= &w->s; +- int ret; +- +- ret= msmpeg4_decode_motion(s, mx_ptr, my_ptr); +- +- if(ret<0) return -1; +- +- if((((*mx_ptr)|(*my_ptr)) & 1) && s->mspel) +- w->hshift= get_bits1(&s->gb); +- else +- w->hshift= 0; +- +-//printf("%d %d ", *mx_ptr, *my_ptr); +- +- return 0; +-} +- +-static int16_t *wmv2_pred_motion(Wmv2Context *w, int *px, int *py){ +- MpegEncContext * const s= &w->s; +- int xy, wrap, diff, type; +- int16_t *A, *B, *C, *mot_val; +- +- wrap = s->b8_stride; +- xy = s->block_index[0]; +- +- mot_val = s->current_picture.motion_val[0][xy]; +- +- A = s->current_picture.motion_val[0][xy - 1]; +- B = s->current_picture.motion_val[0][xy - wrap]; +- C = s->current_picture.motion_val[0][xy + 2 - wrap]; +- +- if(s->mb_x && !s->first_slice_line && !s->mspel && w->top_left_mv_flag) +- diff= FFMAX(FFABS(A[0] - B[0]), FFABS(A[1] - B[1])); +- else +- diff=0; +- +- if(diff >= 8) +- type= get_bits1(&s->gb); +- else +- type= 2; +- +- if(type == 0){ +- *px= A[0]; +- *py= A[1]; +- }else if(type == 1){ +- *px= B[0]; +- *py= B[1]; +- }else{ +- /* special case for first (slice) line */ +- if (s->first_slice_line) { +- *px = A[0]; +- *py = A[1]; +- } else { +- *px = mid_pred(A[0], B[0], C[0]); +- *py = mid_pred(A[1], B[1], C[1]); +- } +- } +- +- return mot_val; +-} +- +-static inline int wmv2_decode_inter_block(Wmv2Context *w, DCTELEM *block, int n, int cbp){ +- MpegEncContext * const s= &w->s; +- static const int sub_cbp_table[3]= {2,3,1}; +- int sub_cbp; +- +- if(!cbp){ +- s->block_last_index[n] = -1; +- +- return 0; +- } +- +- if(w->per_block_abt) +- w->abt_type= decode012(&s->gb); +-#if 0 +- if(w->per_block_abt) +- printf("B%d", w->abt_type); +-#endif +- w->abt_type_table[n]= w->abt_type; +- +- if(w->abt_type){ +-// const uint8_t *scantable= w->abt_scantable[w->abt_type-1].permutated; +- const uint8_t *scantable= w->abt_scantable[w->abt_type-1].scantable; +-// const uint8_t *scantable= w->abt_type-1 ? w->abt_scantable[1].permutated : w->abt_scantable[0].scantable; +- +- sub_cbp= sub_cbp_table[ decode012(&s->gb) ]; +-// printf("S%d", sub_cbp); +- +- if(sub_cbp&1){ +- if (msmpeg4_decode_block(s, block, n, 1, scantable) < 0) +- return -1; +- } +- +- if(sub_cbp&2){ +- if (msmpeg4_decode_block(s, w->abt_block2[n], n, 1, scantable) < 0) +- return -1; +- } +- s->block_last_index[n] = 63; +- +- return 0; +- }else{ +- return msmpeg4_decode_block(s, block, n, 1, s->inter_scantable.permutated); +- } +-} +- + static void wmv2_add_block(Wmv2Context *w, DCTELEM *block1, uint8_t *dst, int stride, int n){ + MpegEncContext * const s= &w->s; + +@@ -593,13 +41,13 @@ + s->dsp.idct_add (dst, stride, block1); + break; + case 1: +- simple_idct84_add(dst , stride, block1); +- simple_idct84_add(dst + 4*stride, stride, w->abt_block2[n]); ++ ff_simple_idct84_add(dst , stride, block1); ++ ff_simple_idct84_add(dst + 4*stride, stride, w->abt_block2[n]); + memset(w->abt_block2[n], 0, 64*sizeof(DCTELEM)); + break; + case 2: +- simple_idct48_add(dst , stride, block1); +- simple_idct48_add(dst + 4 , stride, w->abt_block2[n]); ++ ff_simple_idct48_add(dst , stride, block1); ++ ff_simple_idct48_add(dst + 4 , stride, w->abt_block2[n]); + memset(w->abt_block2[n], 0, 64*sizeof(DCTELEM)); + break; + default: +@@ -709,153 +157,3 @@ + } + pix_op[1][dxy](dest_cr, ptr, uvlinesize, h >> 1); + } +- +- +-static int wmv2_decode_mb(MpegEncContext *s, DCTELEM block[6][64]) +-{ +- Wmv2Context * const w= (Wmv2Context*)s; +- int cbp, code, i; +- uint8_t *coded_val; +- +- if(w->j_type) return 0; +- +- if (s->pict_type == P_TYPE) { +- if(IS_SKIP(s->current_picture.mb_type[s->mb_y * s->mb_stride + s->mb_x])){ +- /* skip mb */ +- s->mb_intra = 0; +- for(i=0;i<6;i++) +- s->block_last_index[i] = -1; +- s->mv_dir = MV_DIR_FORWARD; +- s->mv_type = MV_TYPE_16X16; +- s->mv[0][0][0] = 0; +- s->mv[0][0][1] = 0; +- s->mb_skipped = 1; +- w->hshift=0; +- return 0; +- } +- +- code = get_vlc2(&s->gb, mb_non_intra_vlc[w->cbp_table_index].table, MB_NON_INTRA_VLC_BITS, 3); +- if (code < 0) +- return -1; +- s->mb_intra = (~code & 0x40) >> 6; +- +- cbp = code & 0x3f; +- } else { +- s->mb_intra = 1; +- code = get_vlc2(&s->gb, ff_msmp4_mb_i_vlc.table, MB_INTRA_VLC_BITS, 2); +- if (code < 0){ +- av_log(s->avctx, AV_LOG_ERROR, "II-cbp illegal at %d %d\n", s->mb_x, s->mb_y); +- return -1; +- } +- /* predict coded block pattern */ +- cbp = 0; +- for(i=0;i<6;i++) { +- int val = ((code >> (5 - i)) & 1); +- if (i < 4) { +- int pred = coded_block_pred(s, i, &coded_val); +- val = val ^ pred; +- *coded_val = val; +- } +- cbp |= val << (5 - i); +- } +- } +- +- if (!s->mb_intra) { +- int mx, my; +-//printf("P at %d %d\n", s->mb_x, s->mb_y); +- wmv2_pred_motion(w, &mx, &my); +- +- if(cbp){ +- s->dsp.clear_blocks(s->block[0]); +- if(s->per_mb_rl_table){ +- s->rl_table_index = decode012(&s->gb); +- s->rl_chroma_table_index = s->rl_table_index; +- } +- +- if(w->abt_flag && w->per_mb_abt){ +- w->per_block_abt= get_bits1(&s->gb); +- if(!w->per_block_abt) +- w->abt_type= decode012(&s->gb); +- }else +- w->per_block_abt=0; +- } +- +- if (wmv2_decode_motion(w, &mx, &my) < 0) +- return -1; +- +- s->mv_dir = MV_DIR_FORWARD; +- s->mv_type = MV_TYPE_16X16; +- s->mv[0][0][0] = mx; +- s->mv[0][0][1] = my; +- +- for (i = 0; i < 6; i++) { +- if (wmv2_decode_inter_block(w, block[i], i, (cbp >> (5 - i)) & 1) < 0) +- { +- av_log(s->avctx, AV_LOG_ERROR, "\nerror while decoding inter block: %d x %d (%d)\n", s->mb_x, s->mb_y, i); +- return -1; +- } +- } +- } else { +-//if(s->pict_type==P_TYPE) +-// printf("%d%d ", s->inter_intra_pred, cbp); +-//printf("I at %d %d %d %06X\n", s->mb_x, s->mb_y, ((cbp&3)? 1 : 0) +((cbp&0x3C)? 2 : 0), show_bits(&s->gb, 24)); +- s->ac_pred = get_bits1(&s->gb); +- if(s->inter_intra_pred){ +- s->h263_aic_dir= get_vlc2(&s->gb, inter_intra_vlc.table, INTER_INTRA_VLC_BITS, 1); +-// printf("%d%d %d %d/", s->ac_pred, s->h263_aic_dir, s->mb_x, s->mb_y); +- } +- if(s->per_mb_rl_table && cbp){ +- s->rl_table_index = decode012(&s->gb); +- s->rl_chroma_table_index = s->rl_table_index; +- } +- +- s->dsp.clear_blocks(s->block[0]); +- for (i = 0; i < 6; i++) { +- if (msmpeg4_decode_block(s, block[i], i, (cbp >> (5 - i)) & 1, NULL) < 0) +- { +- av_log(s->avctx, AV_LOG_ERROR, "\nerror while decoding intra block: %d x %d (%d)\n", s->mb_x, s->mb_y, i); +- return -1; +- } +- } +- } +- +- return 0; +-} +- +-static int wmv2_decode_init(AVCodecContext *avctx){ +- Wmv2Context * const w= avctx->priv_data; +- +- if(ff_h263_decode_init(avctx) < 0) +- return -1; +- +- wmv2_common_init(w); +- +- return 0; +-} +- +-#ifdef CONFIG_WMV2_DECODER +-AVCodec wmv2_decoder = { +- "wmv2", +- CODEC_TYPE_VIDEO, +- CODEC_ID_WMV2, +- sizeof(Wmv2Context), +- wmv2_decode_init, +- NULL, +- ff_h263_decode_end, +- ff_h263_decode_frame, +- CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1, +-}; +-#endif +- +-#ifdef CONFIG_WMV2_ENCODER +-AVCodec wmv2_encoder = { +- "wmv2", +- CODEC_TYPE_VIDEO, +- CODEC_ID_WMV2, +- sizeof(Wmv2Context), +- wmv2_encode_init, +- MPV_encode_picture, +- MPV_encode_end, +- .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, -1}, +-}; +-#endif +Only in ffmpeg-free-0.svn20080206/libavcodec: wmv2dec.c +Only in ffmpeg-free-0.svn20080206/libavcodec: wmv2enc.c +Only in ffmpeg-free-0.svn20080206/libavcodec: wmv2.h +diff -u mplayer-1.0~rc2-12/libavcodec/ws-snd1.c ffmpeg-free-0.svn20080206/libavcodec/ws-snd1.c +--- mplayer-1.0~rc2-12/libavcodec/ws-snd1.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/ws-snd1.c 2008-03-20 19:10:59.000000000 +0100 +@@ -45,7 +45,7 @@ + + static int ws_snd_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + // WSSNDContext *c = avctx->priv_data; + +diff -u mplayer-1.0~rc2-12/libavcodec/xan.c ffmpeg-free-0.svn20080206/libavcodec/xan.c +--- mplayer-1.0~rc2-12/libavcodec/xan.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/xan.c 2008-03-20 19:10:59.000000000 +0100 +@@ -41,7 +41,7 @@ + AVFrame last_frame; + AVFrame current_frame; + +- unsigned char *buf; ++ const unsigned char *buf; + int size; + + /* scratch space */ +@@ -87,7 +87,7 @@ + * memcpy doesn't like that; it's not uncommon, for example, for + * dest = src+1, to turn byte A into pattern AAAAAAAA. + * This was originally repz movsb in Intel x86 ASM. */ +-static inline void bytecopy(unsigned char *dest, unsigned char *src, int count) ++static inline void bytecopy(unsigned char *dest, const unsigned char *src, int count) + { + int i; + +@@ -95,12 +95,12 @@ + dest[i] = src[i]; + } + +-static int xan_huffman_decode(unsigned char *dest, unsigned char *src, ++static int xan_huffman_decode(unsigned char *dest, const unsigned char *src, + int dest_len) + { + unsigned char byte = *src++; + unsigned char ival = byte + 0x16; +- unsigned char * ptr = src + byte*2; ++ const unsigned char * ptr = src + byte*2; + unsigned char val = ival; + int counter = 0; + unsigned char *dest_end = dest + dest_len; +@@ -129,7 +129,7 @@ + return 0; + } + +-static void xan_unpack(unsigned char *dest, unsigned char *src, int dest_len) ++static void xan_unpack(unsigned char *dest, const unsigned char *src, int dest_len) + { + unsigned char opcode; + int size; +@@ -206,7 +206,7 @@ + } + + static inline void xan_wc3_output_pixel_run(XanContext *s, +- unsigned char *pixel_buffer, int x, int y, int pixel_count) ++ const unsigned char *pixel_buffer, int x, int y, int pixel_count) + { + int stride; + int line_inc; +@@ -284,14 +284,13 @@ + + unsigned char *opcode_buffer = s->buffer1; + int opcode_buffer_size = s->buffer1_size; +- unsigned char *imagedata_buffer = s->buffer2; +- int imagedata_buffer_size = s->buffer2_size; ++ const unsigned char *imagedata_buffer = s->buffer2; + + /* pointers to segments inside the compressed chunk */ +- unsigned char *huffman_segment; +- unsigned char *size_segment; +- unsigned char *vector_segment; +- unsigned char *imagedata_segment; ++ const unsigned char *huffman_segment; ++ const unsigned char *size_segment; ++ const unsigned char *vector_segment; ++ const unsigned char *imagedata_segment; + + huffman_segment = s->buf + AV_RL16(&s->buf[0]); + size_segment = s->buf + AV_RL16(&s->buf[2]); +@@ -301,8 +300,7 @@ + xan_huffman_decode(opcode_buffer, huffman_segment, opcode_buffer_size); + + if (imagedata_segment[0] == 2) +- xan_unpack(imagedata_buffer, &imagedata_segment[1], +- imagedata_buffer_size); ++ xan_unpack(s->buffer2, &imagedata_segment[1], s->buffer2_size); + else + imagedata_buffer = &imagedata_segment[1]; + +@@ -406,7 +404,7 @@ + + static int xan_decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + XanContext *s = avctx->priv_data; + AVPaletteControl *palette_control = avctx->palctrl; +diff -u mplayer-1.0~rc2-12/libavcodec/xiph.h ffmpeg-free-0.svn20080206/libavcodec/xiph.h +--- mplayer-1.0~rc2-12/libavcodec/xiph.h 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/xiph.h 2007-10-17 11:37:46.000000000 +0200 +@@ -18,8 +18,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef AVCODEC_XIPH_H +-#define AVCODEC_XIPH_H ++#ifndef FFMPEG_XIPH_H ++#define FFMPEG_XIPH_H + + #include "common.h" + +@@ -40,4 +40,4 @@ + int first_header_size, uint8_t *header_start[3], + int header_len[3]); + +-#endif // AVCODEC_XIPH_H ++#endif /* FFMPEG_XIPH_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/xl.c ffmpeg-free-0.svn20080206/libavcodec/xl.c +--- mplayer-1.0~rc2-12/libavcodec/xl.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/xl.c 2008-03-20 19:10:59.000000000 +0100 +@@ -40,7 +40,7 @@ + + static int decode_frame(AVCodecContext *avctx, + void *data, int *data_size, +- uint8_t *buf, int buf_size) ++ const uint8_t *buf, int buf_size) + { + VideoXLContext * const a = avctx->priv_data; + AVFrame * const p= (AVFrame*)&a->pic; +diff -u mplayer-1.0~rc2-12/libavcodec/xsubdec.c ffmpeg-free-0.svn20080206/libavcodec/xsubdec.c +--- mplayer-1.0~rc2-12/libavcodec/xsubdec.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/xsubdec.c 2008-03-20 19:10:59.000000000 +0100 +@@ -30,7 +30,7 @@ + static const uint8_t tc_offsets[9] = { 0, 1, 3, 4, 6, 7, 9, 10, 11 }; + static const uint8_t tc_muls[9] = { 10, 6, 10, 6, 10, 6, 10, 10, 1 }; + +-static uint64_t parse_timecode(uint8_t *buf) { ++static uint64_t parse_timecode(const uint8_t *buf) { + int i; + int64_t ms = 0; + if (buf[2] != ':' || buf[5] != ':' || buf[8] != '.') +@@ -44,9 +44,9 @@ + } + + static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, +- uint8_t *buf, int buf_size) { ++ const uint8_t *buf, int buf_size) { + AVSubtitle *sub = data; +- uint8_t *buf_end = buf + buf_size; ++ const uint8_t *buf_end = buf + buf_size; + uint8_t *bitmap; + int w, h, x, y, rlelen, i; + GetBitContext gb; +@@ -108,11 +108,11 @@ + for (x = 0; x < w; ) { + int log2 = ff_log2_tab[show_bits(&gb, 8)]; + int run = get_bits(&gb, 14 - 4 * (log2 >> 1)); +- int colour = get_bits(&gb, 2); ++ int color = get_bits(&gb, 2); + run = FFMIN(run, w - x); + // run length 0 means till end of row + if (!run) run = w - x; +- memset(bitmap, colour, run); ++ memset(bitmap, color, run); + bitmap += run; + x += run; + } +diff -u mplayer-1.0~rc2-12/libavcodec/xvmc_render.h ffmpeg-free-0.svn20080206/libavcodec/xvmc_render.h +--- mplayer-1.0~rc2-12/libavcodec/xvmc_render.h 2007-10-07 21:49:36.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/xvmc_render.h 2007-10-17 11:37:46.000000000 +0200 +@@ -18,8 +18,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef AVCODEC_XVMC_RENDER_H +-#define AVCODEC_XVMC_RENDER_H ++#ifndef FFMPEG_XVMC_RENDER_H ++#define FFMPEG_XVMC_RENDER_H + + #include + #include +@@ -72,4 +72,4 @@ + + } xvmc_render_state_t; + +-#endif // AVCODEC_XVMC_RENDER_H ++#endif /* FFMPEG_XVMC_RENDER_H */ +diff -u mplayer-1.0~rc2-12/libavcodec/zmbv.c ffmpeg-free-0.svn20080206/libavcodec/zmbv.c +--- mplayer-1.0~rc2-12/libavcodec/zmbv.c 2007-10-07 21:49:37.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavcodec/zmbv.c 2008-03-20 19:10:59.000000000 +0100 +@@ -391,7 +391,7 @@ + return 0; + } + +-static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8_t *buf, int buf_size) ++static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, const uint8_t *buf, int buf_size) + { + ZmbvContext * const c = avctx->priv_data; + uint8_t *outptr; +diff -u mplayer-1.0~rc2-12/libavformat/4xm.c ffmpeg-free-0.svn20080206/libavformat/4xm.c +--- mplayer-1.0~rc2-12/libavformat/4xm.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/4xm.c 2007-11-21 08:41:00.000000000 +0100 +@@ -92,7 +92,7 @@ + static int fourxm_read_header(AVFormatContext *s, + AVFormatParameters *ap) + { +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + unsigned int fourcc_tag; + unsigned int size; + int header_size; +@@ -224,7 +224,7 @@ + AVPacket *pkt) + { + FourxmDemuxContext *fourxm = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + unsigned int fourcc_tag; + unsigned int size, out_size; + int ret = 0; +@@ -235,7 +235,7 @@ + + while (!packet_read) { + +- if ((ret = get_buffer(&s->pb, header, 8)) < 0) ++ if ((ret = get_buffer(s->pb, header, 8)) < 0) + return ret; + fourcc_tag = AV_RL32(&header[0]); + size = AV_RL32(&header[4]); +@@ -265,9 +265,9 @@ + return AVERROR(EIO); + pkt->stream_index = fourxm->video_stream_index; + pkt->pts = fourxm->video_pts; +- pkt->pos = url_ftell(&s->pb); ++ pkt->pos = url_ftell(s->pb); + memcpy(pkt->data, header, 8); +- ret = get_buffer(&s->pb, &pkt->data[8], size); ++ ret = get_buffer(s->pb, &pkt->data[8], size); + + if (ret < 0) + av_free_packet(pkt); +@@ -282,7 +282,7 @@ + size-=8; + + if (track_number == fourxm->selected_track) { +- ret= av_get_packet(&s->pb, pkt, size); ++ ret= av_get_packet(s->pb, pkt, size); + if(ret<0) + return AVERROR(EIO); + pkt->stream_index = +diff -u mplayer-1.0~rc2-12/libavformat/adtsenc.c ffmpeg-free-0.svn20080206/libavformat/adtsenc.c +--- mplayer-1.0~rc2-12/libavformat/adtsenc.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/adtsenc.c 2007-11-21 08:41:00.000000000 +0100 +@@ -84,7 +84,7 @@ + put_bits(&pb, 2, 0); /* number_of_raw_data_blocks_in_frame */ + + flush_put_bits(&pb); +- put_buffer(&s->pb, buf, ADTS_HEADER_SIZE); ++ put_buffer(s->pb, buf, ADTS_HEADER_SIZE); + + return 0; + } +@@ -92,7 +92,7 @@ + static int adts_write_packet(AVFormatContext *s, AVPacket *pkt) + { + ADTSContext *adts = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + + if (!pkt->size) + return 0; +diff -u mplayer-1.0~rc2-12/libavformat/aiff.c ffmpeg-free-0.svn20080206/libavformat/aiff.c +--- mplayer-1.0~rc2-12/libavformat/aiff.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/aiff.c 2007-11-21 08:41:00.000000000 +0100 +@@ -161,7 +161,7 @@ + static int aiff_write_header(AVFormatContext *s) + { + AIFFOutputContext *aiff = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + AVCodecContext *enc = s->streams[0]->codec; + AVExtFloat sample_rate; + int aifc = 0; +@@ -231,14 +231,14 @@ + + static int aiff_write_packet(AVFormatContext *s, AVPacket *pkt) + { +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + put_buffer(pb, pkt->data, pkt->size); + return 0; + } + + static int aiff_write_trailer(AVFormatContext *s) + { +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + AIFFOutputContext *aiff = s->priv_data; + AVCodecContext *enc = s->streams[0]->codec; + +@@ -250,7 +250,7 @@ + end_size++; + } + +- if (!url_is_streamed(&s->pb)) { ++ if (!url_is_streamed(s->pb)) { + /* File length */ + url_fseek(pb, aiff->form, SEEK_SET); + put_be32(pb, (uint32_t)(file_size - aiff->form - 4)); +@@ -293,7 +293,7 @@ + offset_t offset = 0; + uint32_t tag; + unsigned version = AIFF_C_VERSION1; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + AVStream * st = s->streams[0]; + + /* check FORM header */ +@@ -399,11 +399,11 @@ + int res; + + /* End of stream may be reached */ +- if (url_feof(&s->pb)) ++ if (url_feof(s->pb)) + return AVERROR(EIO); + + /* Now for that packet */ +- res = av_get_packet(&s->pb, pkt, (MAX_SIZE / st->codec->block_align) * st->codec->block_align); ++ res = av_get_packet(s->pb, pkt, (MAX_SIZE / st->codec->block_align) * st->codec->block_align); + if (res < 0) + return res; + +diff -u mplayer-1.0~rc2-12/libavformat/allformats.c ffmpeg-free-0.svn20080206/libavformat/allformats.c +--- mplayer-1.0~rc2-12/libavformat/allformats.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/allformats.c 2008-01-29 10:25:49.000000000 +0100 +@@ -21,9 +21,6 @@ + #include "avformat.h" + #include "rtp_internal.h" + +-/* rtp.c */ +-void av_register_rtp_dynamic_payload_handlers(void); +- + #define REGISTER_MUXER(X,x) { \ + extern AVOutputFormat x##_muxer; \ + if(ENABLE_##X##_MUXER) av_register_output_format(&x##_muxer); } +@@ -43,15 +40,16 @@ + */ + void av_register_all(void) + { +- static int inited = 0; ++ static int inited; + +- if (inited != 0) ++ if (inited) + return; + inited = 1; + + avcodec_init(); + avcodec_register_all(); + ++ /* (de)muxers */ + REGISTER_DEMUXER (AAC, aac); + REGISTER_MUXDEMUX (AC3, ac3); + REGISTER_MUXER (ADTS, adts); +@@ -62,21 +60,20 @@ + REGISTER_MUXDEMUX (ASF, asf); + REGISTER_MUXER (ASF_STREAM, asf_stream); + REGISTER_MUXDEMUX (AU, au); +- REGISTER_MUXDEMUX (AUDIO_BEOS, audio_beos); + REGISTER_MUXDEMUX (AVI, avi); + REGISTER_DEMUXER (AVISYNTH, avisynth); ++ REGISTER_MUXER (AVM2, avm2); + REGISTER_DEMUXER (AVS, avs); + REGISTER_DEMUXER (BETHSOFTVID, bethsoftvid); +- REGISTER_DEMUXER (BKTR, bktr); + REGISTER_DEMUXER (C93, c93); + REGISTER_MUXER (CRC, crc); + REGISTER_DEMUXER (DAUD, daud); + REGISTER_DEMUXER (DSICIN, dsicin); + REGISTER_DEMUXER (DTS, dts); + REGISTER_MUXDEMUX (DV, dv); +- REGISTER_DEMUXER (DV1394, dv1394); + REGISTER_DEMUXER (DXA, dxa); + REGISTER_DEMUXER (EA, ea); ++ REGISTER_DEMUXER (EA_CDATA, ea_cdata); + REGISTER_MUXDEMUX (FFM, ffm); + REGISTER_MUXDEMUX (FLAC, flac); + REGISTER_DEMUXER (FLIC, flic); +@@ -93,9 +90,7 @@ + REGISTER_MUXDEMUX (IMAGE2PIPE, image2pipe); + REGISTER_DEMUXER (INGENIENT, ingenient); + REGISTER_DEMUXER (IPMOVIE, ipmovie); +- REGISTER_DEMUXER (LIBDC1394, libdc1394); +- if (!ENABLE_NUT_DEMUXER) REGISTER_DEMUXER (LIBNUT, libnut); +- if (!ENABLE_NUT_MUXER) REGISTER_MUXER (LIBNUT, libnut); ++ REGISTER_DEMUXER (LMLM4, lmlm4); + REGISTER_MUXDEMUX (M4V, m4v); + REGISTER_MUXDEMUX (MATROSKA, matroska); + REGISTER_MUXER (MATROSKA_AUDIO, matroska_audio); +@@ -107,6 +102,7 @@ + REGISTER_MUXDEMUX (MP3, mp3); + REGISTER_MUXER (MP4, mp4); + REGISTER_DEMUXER (MPC, mpc); ++ REGISTER_DEMUXER (MPC8, mpc8); + REGISTER_MUXER (MPEG1SYSTEM, mpeg1system); + REGISTER_MUXER (MPEG1VCD, mpeg1vcd); + REGISTER_MUXER (MPEG1VIDEO, mpeg1video); +@@ -126,7 +122,6 @@ + REGISTER_MUXDEMUX (NUT, nut); + REGISTER_DEMUXER (NUV, nuv); + REGISTER_MUXDEMUX (OGG, ogg); +- REGISTER_MUXDEMUX (OSS, oss); + REGISTER_MUXDEMUX (PCM_ALAW, pcm_alaw); + REGISTER_MUXDEMUX (PCM_MULAW, pcm_mulaw); + REGISTER_MUXDEMUX (PCM_S16BE, pcm_s16be); +@@ -136,6 +131,7 @@ + REGISTER_MUXDEMUX (PCM_U16LE, pcm_u16le); + REGISTER_MUXDEMUX (PCM_U8, pcm_u8); + REGISTER_MUXER (PSP, psp); ++ REGISTER_DEMUXER (PVA, pva); + REGISTER_MUXDEMUX (RAWVIDEO, rawvideo); + REGISTER_MUXDEMUX (RM, rm); + REGISTER_MUXDEMUX (ROQ, roq); +@@ -143,11 +139,12 @@ + REGISTER_MUXER (RTP, rtp); + REGISTER_DEMUXER (RTSP, rtsp); + REGISTER_DEMUXER (SDP, sdp); +-#ifdef CONFIG_RTP_MUXER ++#ifdef CONFIG_SDP_DEMUXER + av_register_rtp_dynamic_payload_handlers(); + #endif + REGISTER_DEMUXER (SEGAFILM, segafilm); + REGISTER_DEMUXER (SHORTEN, shorten); ++ REGISTER_DEMUXER (SIFF, siff); + REGISTER_DEMUXER (SMACKER, smacker); + REGISTER_DEMUXER (SOL, sol); + REGISTER_DEMUXER (STR, str); +@@ -158,9 +155,8 @@ + REGISTER_DEMUXER (TIERTEXSEQ, tiertexseq); + REGISTER_DEMUXER (TTA, tta); + REGISTER_DEMUXER (TXD, txd); +- REGISTER_DEMUXER (V4L2, v4l2); +- REGISTER_DEMUXER (V4L, v4l); + REGISTER_DEMUXER (VC1, vc1); ++ REGISTER_DEMUXER (VC1T, vc1t); + REGISTER_DEMUXER (VMD, vmd); + REGISTER_MUXDEMUX (VOC, voc); + REGISTER_MUXDEMUX (WAV, wav); +@@ -168,9 +164,12 @@ + REGISTER_DEMUXER (WSAUD, wsaud); + REGISTER_DEMUXER (WSVQA, wsvqa); + REGISTER_DEMUXER (WV, wv); +- REGISTER_DEMUXER (X11_GRAB_DEVICE, x11_grab_device); + REGISTER_MUXDEMUX (YUV4MPEGPIPE, yuv4mpegpipe); + ++ /* external libraries */ ++ REGISTER_MUXDEMUX (LIBNUT, libnut); ++ ++ /* protocols */ + REGISTER_PROTOCOL (FILE, file); + REGISTER_PROTOCOL (HTTP, http); + REGISTER_PROTOCOL (PIPE, pipe); +diff -u mplayer-1.0~rc2-12/libavformat/amr.c ffmpeg-free-0.svn20080206/libavformat/amr.c +--- mplayer-1.0~rc2-12/libavformat/amr.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/amr.c 2007-11-21 08:41:00.000000000 +0100 +@@ -33,7 +33,7 @@ + #ifdef CONFIG_MUXERS + static int amr_write_header(AVFormatContext *s) + { +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + AVCodecContext *enc = s->streams[0]->codec; + + s->priv_data = NULL; +@@ -56,8 +56,8 @@ + + static int amr_write_packet(AVFormatContext *s, AVPacket *pkt) + { +- put_buffer(&s->pb, pkt->data, pkt->size); +- put_flush_packet(&s->pb); ++ put_buffer(s->pb, pkt->data, pkt->size); ++ put_flush_packet(s->pb); + return 0; + } + #endif /* CONFIG_MUXERS */ +@@ -78,7 +78,7 @@ + static int amr_read_header(AVFormatContext *s, + AVFormatParameters *ap) + { +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + AVStream *st; + uint8_t header[9]; + +@@ -120,13 +120,13 @@ + AVCodecContext *enc = s->streams[0]->codec; + int read, size = 0, toc, mode; + +- if (url_feof(&s->pb)) ++ if (url_feof(s->pb)) + { + return AVERROR(EIO); + } + + //FIXME this is wrong, this should rather be in a AVParset +- toc=get_byte(&s->pb); ++ toc=get_byte(s->pb); + mode = (toc >> 3) & 0x0F; + + if (enc->codec_id == CODEC_ID_AMR_NB) +@@ -152,10 +152,10 @@ + } + + pkt->stream_index = 0; +- pkt->pos= url_ftell(&s->pb); ++ pkt->pos= url_ftell(s->pb); + pkt->data[0]=toc; + pkt->duration= enc->codec_id == CODEC_ID_AMR_NB ? 160 : 320; +- read = get_buffer(&s->pb, pkt->data+1, size-1); ++ read = get_buffer(s->pb, pkt->data+1, size-1); + + if (read != size-1) + { +diff -u mplayer-1.0~rc2-12/libavformat/apc.c ffmpeg-free-0.svn20080206/libavformat/apc.c +--- mplayer-1.0~rc2-12/libavformat/apc.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/apc.c 2007-11-21 08:41:00.000000000 +0100 +@@ -32,7 +32,7 @@ + + static int apc_read_header(AVFormatContext *s, AVFormatParameters *ap) + { +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + AVStream *st; + + get_le32(pb); /* CRYO */ +@@ -74,7 +74,7 @@ + + static int apc_read_packet(AVFormatContext *s, AVPacket *pkt) + { +- if (av_get_packet(&s->pb, pkt, MAX_READ_SIZE) <= 0) ++ if (av_get_packet(s->pb, pkt, MAX_READ_SIZE) <= 0) + return AVERROR(EIO); + pkt->stream_index = 0; + return 0; +diff -u mplayer-1.0~rc2-12/libavformat/ape.c ffmpeg-free-0.svn20080206/libavformat/ape.c +--- mplayer-1.0~rc2-12/libavformat/ape.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/ape.c 2008-02-04 01:42:27.000000000 +0100 +@@ -50,7 +50,7 @@ + #define TAG(name, field) {name, offsetof(AVFormatContext, field), sizeof(((AVFormatContext *)0)->field)} + + static const struct { +- char *name; ++ const char *name; + int offset; + int size; + } tags[] = { +@@ -110,7 +110,7 @@ + + static void ape_tag_read_field(AVFormatContext *s) + { +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + uint8_t buf[1024]; + uint32_t size; + int i; +@@ -143,7 +143,7 @@ + + static void ape_parse_tag(AVFormatContext *s) + { +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + int file_size = url_fsize(pb); + uint32_t val, fields, tag_bytes; + uint8_t buf[8]; +@@ -270,7 +270,7 @@ + + static int ape_read_header(AVFormatContext * s, AVFormatParameters * ap) + { +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + APEContext *ape = s->priv_data; + AVStream *st; + uint32_t tag; +@@ -456,12 +456,12 @@ + APEContext *ape = s->priv_data; + uint32_t extra_size = 8; + +- if (url_feof(&s->pb)) ++ if (url_feof(s->pb)) + return AVERROR_IO; + if (ape->currentframe > ape->totalframes) + return AVERROR_IO; + +- url_fseek (&s->pb, ape->frames[ape->currentframe].pos, SEEK_SET); ++ url_fseek (s->pb, ape->frames[ape->currentframe].pos, SEEK_SET); + + /* Calculate how many blocks there are in this frame */ + if (ape->currentframe == (ape->totalframes - 1)) +@@ -474,7 +474,7 @@ + + AV_WL32(pkt->data , nblocks); + AV_WL32(pkt->data + 4, ape->frames[ape->currentframe].skip); +- ret = get_buffer(&s->pb, pkt->data + extra_size, ape->frames[ape->currentframe].size); ++ ret = get_buffer(s->pb, pkt->data + extra_size, ape->frames[ape->currentframe].size); + + pkt->pts = ape->frames[ape->currentframe].pts; + pkt->stream_index = 0; +diff -u mplayer-1.0~rc2-12/libavformat/asf.c ffmpeg-free-0.svn20080206/libavformat/asf.c +--- mplayer-1.0~rc2-12/libavformat/asf.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/asf.c 2008-02-03 12:18:53.000000000 +0100 +@@ -23,6 +23,9 @@ + #include "mpegaudio.h" + #include "asf.h" + #include "common.h" ++#include "asfcrypt.h" ++ ++extern void ff_mms_set_stream_selection(URLContext *h, AVFormatContext *format); + + #undef NDEBUG + #include +@@ -84,7 +87,7 @@ + static void get_guid(ByteIOContext *s, GUID *g) + { + assert(sizeof(*g) == 16); +- get_buffer(s, g, sizeof(*g)); ++ get_buffer(s, *g, sizeof(*g)); + } + + #if 0 +@@ -139,7 +142,7 @@ + { + ASFContext *asf = s->priv_data; + GUID g; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + AVStream *st; + ASFStream *asf_st; + int size, i; +@@ -390,6 +393,11 @@ + { + if (!strcmp(name,"WM/AlbumTitle")) get_str16_nolen(pb, value_len, s->album, sizeof(s->album)); + else if(!strcmp(name,"WM/Genre" )) get_str16_nolen(pb, value_len, s->genre, sizeof(s->genre)); ++ else if(!strcmp(name,"WM/Year" )) { ++ char year[8]; ++ get_str16_nolen(pb, value_len, year, sizeof(year)); ++ s->year = atoi(year); ++ } + else if(!strcmp(name,"WM/Track") && s->track == 0) { + char track[8]; + get_str16_nolen(pb, value_len, track, sizeof(track)); +@@ -562,12 +570,12 @@ + static int asf_get_packet(AVFormatContext *s) + { + ASFContext *asf = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + uint32_t packet_length, padsize; + int rsize = 8; + int c, d, e, off; + +- off= (url_ftell(&s->pb) - s->data_offset) % asf->packet_size + 3; ++ off= (url_ftell(s->pb) - s->data_offset) % asf->packet_size + 3; + + c=d=e=-1; + while(off-- > 0){ +@@ -638,7 +646,7 @@ + */ + static int asf_read_frame_header(AVFormatContext *s){ + ASFContext *asf = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + int rsize = 1; + int num = get_byte(pb); + int64_t ts0, ts1; +@@ -674,7 +682,7 @@ + url_fskip(pb, asf->packet_replic_size - 8); + rsize += asf->packet_replic_size; // FIXME - check validity + } else if (asf->packet_replic_size==1){ +- // multipacket - frag_offset is begining timestamp ++ // multipacket - frag_offset is beginning timestamp + asf->packet_time_start = asf->packet_frag_offset; + asf->packet_frag_offset = 0; + asf->packet_frag_timestamp = asf->packet_timestamp; +@@ -711,7 +719,7 @@ + { + ASFContext *asf = s->priv_data; + ASFStream *asf_st = 0; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + //static int pc = 0; + for (;;) { + if(url_feof(pb)) +@@ -725,7 +733,7 @@ + /* fail safe */ + url_fskip(pb, ret); + +- asf->packet_pos= url_ftell(&s->pb); ++ asf->packet_pos= url_ftell(s->pb); + if (asf->data_object_size != (uint64_t)-1 && + (asf->packet_pos - asf->data_object_offset >= asf->data_object_size)) + return AVERROR(EIO); /* Do not exceed the size of the data object */ +@@ -758,7 +766,7 @@ + asf_st = asf->asf_st; + + if (asf->packet_replic_size == 1) { +- // frag_offset is here used as the begining timestamp ++ // frag_offset is here used as the beginning timestamp + asf->packet_frag_timestamp = asf->packet_time_start; + asf->packet_time_start += asf->packet_time_delta; + asf->packet_obj_size = asf->packet_frag_size = get_byte(pb); +@@ -823,6 +831,9 @@ + + get_buffer(pb, asf_st->pkt.data + asf->packet_frag_offset, + asf->packet_frag_size); ++ if (s->key && s->keylen == 20) ++ ff_asfcrypt_dec(s->key, asf_st->pkt.data + asf->packet_frag_offset, ++ asf->packet_frag_size); + asf_st->frag_offset += asf->packet_frag_size; + /* test if whole packet is read */ + if (asf_st->frag_offset == asf_st->pkt.size) { +@@ -878,18 +889,6 @@ + return 0; + } + +-static int asf_read_close(AVFormatContext *s) +-{ +- int i; +- +- for(i=0;inb_streams;i++) { +- AVStream *st = s->streams[i]; +- av_free(st->priv_data); +- av_free(st->codec->palctrl); +- } +- return 0; +-} +- + // Added to support seeking after packets have been read + // If information is not reset, read_packet fails due to + // leftover information from previous reads +@@ -928,6 +927,19 @@ + asf->asf_st= NULL; + } + ++static int asf_read_close(AVFormatContext *s) ++{ ++ int i; ++ ++ asf_reset_header(s); ++ for(i=0;inb_streams;i++) { ++ AVStream *st = s->streams[i]; ++ av_free(st->priv_data); ++ av_free(st->codec->palctrl); ++ } ++ return 0; ++} ++ + static int64_t asf_read_pts(AVFormatContext *s, int stream_index, int64_t *ppos, int64_t pos_limit) + { + ASFContext *asf = s->priv_data; +@@ -944,7 +956,7 @@ + + pos= (pos+asf->packet_size-1-s->data_offset)/asf->packet_size*asf->packet_size+ s->data_offset; + *ppos= pos; +- url_fseek(&s->pb, pos, SEEK_SET); ++ url_fseek(s->pb, pos, SEEK_SET); + + //printf("asf_read_pts\n"); + asf_reset_header(s); +@@ -988,21 +1000,21 @@ + int i; + int pct,ict; + +- current_pos = url_ftell(&s->pb); ++ current_pos = url_ftell(s->pb); + +- url_fseek(&s->pb, asf->data_object_offset + asf->data_object_size, SEEK_SET); +- get_guid(&s->pb, &g); ++ url_fseek(s->pb, asf->data_object_offset + asf->data_object_size, SEEK_SET); ++ get_guid(s->pb, &g); + if (!memcmp(&g, &index_guid, sizeof(GUID))) { +- gsize = get_le64(&s->pb); +- get_guid(&s->pb, &g); +- itime=get_le64(&s->pb); +- pct=get_le32(&s->pb); +- ict=get_le32(&s->pb); ++ gsize = get_le64(s->pb); ++ get_guid(s->pb, &g); ++ itime=get_le64(s->pb); ++ pct=get_le32(s->pb); ++ ict=get_le32(s->pb); + av_log(NULL, AV_LOG_DEBUG, "itime:0x%"PRIx64", pct:%d, ict:%d\n",itime,pct,ict); + + for (i=0;ipb); +- int pktct =get_le16(&s->pb); ++ int pktnum=get_le32(s->pb); ++ int pktct =get_le16(s->pb); + av_log(NULL, AV_LOG_DEBUG, "pktnum:%d, pktct:%d\n", pktnum, pktct); + + pos=s->data_offset + asf->packet_size*(int64_t)pktnum; +@@ -1012,7 +1024,7 @@ + } + asf->index_read= 1; + } +- url_fseek(&s->pb, current_pos, SEEK_SET); ++ url_fseek(s->pb, current_pos, SEEK_SET); + } + + static int asf_read_seek(AVFormatContext *s, int stream_index, int64_t pts, int flags) +@@ -1025,6 +1037,15 @@ + if (asf->packet_size <= 0) + return -1; + ++ /* Try using the protocol's read_seek if available */ ++ if(s->pb) { ++ int ret = av_url_read_fseek(s->pb, stream_index, pts, flags); ++ if(ret >= 0) ++ asf_reset_header(s); ++ if (ret != AVERROR(ENOSYS)) ++ return ret; ++ } ++ + if (!asf->index_read) + asf_build_simple_index(s, stream_index); + +@@ -1042,10 +1063,10 @@ + + // various attempts to find key frame have failed so far + // asf_reset_header(s); +- // url_fseek(&s->pb, pos, SEEK_SET); ++ // url_fseek(s->pb, pos, SEEK_SET); + // key_pos = pos; + // for(i=0;i<16;i++){ +- // pos = url_ftell(&s->pb); ++ // pos = url_ftell(s->pb); + // if (av_read_frame(s, &pkt) < 0){ + // av_log(s, AV_LOG_INFO, "seek failed\n"); + // return -1; +@@ -1063,7 +1084,7 @@ + + /* do the seek */ + av_log(NULL, AV_LOG_DEBUG, "SEEKTO: %"PRId64"\n", pos); +- url_fseek(&s->pb, pos, SEEK_SET); ++ url_fseek(s->pb, pos, SEEK_SET); + } + asf_reset_header(s); + return 0; +Only in ffmpeg-free-0.svn20080206/libavformat: asfcrypt.c +Only in ffmpeg-free-0.svn20080206/libavformat: asfcrypt.h +diff -u mplayer-1.0~rc2-12/libavformat/asf-enc.c ffmpeg-free-0.svn20080206/libavformat/asf-enc.c +--- mplayer-1.0~rc2-12/libavformat/asf-enc.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/asf-enc.c 2008-01-31 01:34:22.000000000 +0100 +@@ -199,7 +199,7 @@ + static void put_guid(ByteIOContext *s, const GUID *g) + { + assert(sizeof(*g) == 16); +- put_buffer(s, g, sizeof(*g)); ++ put_buffer(s, *g, sizeof(*g)); + } + + static void put_str16_nolen(ByteIOContext *s, const char *tag); +@@ -244,7 +244,7 @@ + static void put_chunk(AVFormatContext *s, int type, int payload_length, int flags) + { + ASFContext *asf = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + int length; + + length = payload_length + 8; +@@ -270,7 +270,7 @@ + static int asf_write_header1(AVFormatContext *s, int64_t file_size, int64_t data_chunk_size) + { + ASFContext *asf = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + int header_size, n, extra_size, extra_size2, wav_extra_size, file_time; + int has_title; + AVCodecContext *enc; +@@ -493,17 +493,20 @@ + asf->nb_packets = 0; + + asf->last_indexed_pts = 0; +- asf->index_ptr = (ASFIndex*)av_malloc( sizeof(ASFIndex) * ASF_INDEX_BLOCK ); ++ asf->index_ptr = av_malloc( sizeof(ASFIndex) * ASF_INDEX_BLOCK ); + asf->nb_index_memory_alloc = ASF_INDEX_BLOCK; + asf->nb_index_count = 0; + asf->maximum_packet = 0; + +- if (asf_write_header1(s, 0, 0) < 0) { ++ /* the data-chunk-size has to be 50, which is data_size - asf->data_offset ++ * at the moment this function is done. It is needed to use asf as ++ * streamable format. */ ++ if (asf_write_header1(s, 0, 50) < 0) { + //av_free(asf); + return -1; + } + +- put_flush_packet(&s->pb); ++ put_flush_packet(s->pb); + + asf->packet_nb_payloads = 0; + asf->packet_timestamp_start = -1; +@@ -532,7 +535,7 @@ + ) + { + ASFContext *asf = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + int ppi_size, i; + int64_t start= url_ftell(pb); + +@@ -581,6 +584,8 @@ + ASFContext *asf = s->priv_data; + int packet_hdr_size, packet_filled_size; + ++ assert(asf->packet_timestamp_end >= asf->packet_timestamp_start); ++ + if (asf->is_streamed) { + put_chunk(s, 0x4424, asf->packet_size, 0); + } +@@ -597,9 +602,9 @@ + assert(packet_hdr_size <= asf->packet_size_left); + memset(asf->packet_buf + packet_filled_size, 0, asf->packet_size_left); + +- put_buffer(&s->pb, asf->packet_buf, asf->packet_size - packet_hdr_size); ++ put_buffer(s->pb, asf->packet_buf, asf->packet_size - packet_hdr_size); + +- put_flush_packet(&s->pb); ++ put_flush_packet(s->pb); + asf->nb_packets++; + asf->packet_nb_payloads = 0; + asf->packet_timestamp_start = -1; +@@ -677,8 +682,6 @@ + // multi payloads + frag_len1 = asf->packet_size_left - PAYLOAD_HEADER_SIZE_MULTIPLE_PAYLOADS - PACKET_HEADER_MIN_SIZE - 1; + +- asf->packet_timestamp_start = timestamp; +- + if(frag_len1 < payload_len && avst->codec->codec_type == CODEC_TYPE_AUDIO){ + flush_packet(s); + continue; +@@ -763,7 +766,7 @@ + // + static int asf_write_index(AVFormatContext *s, ASFIndex *index, uint16_t max, uint32_t count) + { +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + int i; + + put_guid(pb, &simple_index_header); +@@ -790,22 +793,22 @@ + flush_packet(s); + + /* write index */ +- data_size = url_ftell(&s->pb); ++ data_size = url_ftell(s->pb); + if ((!asf->is_streamed) && (asf->nb_index_count != 0)) { + asf_write_index(s, asf->index_ptr, asf->maximum_packet, asf->nb_index_count); + } +- put_flush_packet(&s->pb); ++ put_flush_packet(s->pb); + +- if (asf->is_streamed || url_is_streamed(&s->pb)) { ++ if (asf->is_streamed || url_is_streamed(s->pb)) { + put_chunk(s, 0x4524, 0, 0); /* end of stream */ + } else { + /* rewrite an updated header */ +- file_size = url_ftell(&s->pb); +- url_fseek(&s->pb, 0, SEEK_SET); ++ file_size = url_ftell(s->pb); ++ url_fseek(s->pb, 0, SEEK_SET); + asf_write_header1(s, file_size, data_size - asf->data_offset); + } + +- put_flush_packet(&s->pb); ++ put_flush_packet(s->pb); + av_free(asf->index_ptr); + return 0; + } +diff -u mplayer-1.0~rc2-12/libavformat/asf.h ffmpeg-free-0.svn20080206/libavformat/asf.h +--- mplayer-1.0~rc2-12/libavformat/asf.h 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/asf.h 2007-12-23 22:01:09.000000000 +0100 +@@ -18,8 +18,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef AVFORMAT_ASF_H +-#define AVFORMAT_ASF_H ++#ifndef FFMPEG_ASF_H ++#define FFMPEG_ASF_H + + #include + #include "avformat.h" +@@ -56,7 +56,7 @@ + uint64_t send_time; /**< time to send file, in 100-nanosecond units + * invalid if broadcasting (could be ignored) */ + uint32_t preroll; /**< timestamp of the first packet, in milliseconds +- * if nonzero - substract from time */ ++ * if nonzero - subtract from time */ + uint32_t ignore; ///< preroll is 64bit - but let's just ignore it + uint32_t flags; /**< 0x01 - broadcast + * 0x02 - seekable +@@ -97,7 +97,7 @@ + uint8_t packet_buf[PACKET_SIZE]; + ByteIOContext pb; + /* only for reading */ +- uint64_t data_offset; ///< begining of the first data packet ++ uint64_t data_offset; ///< beginning of the first data packet + uint64_t data_object_offset; ///< data object offset (excl. GUID & size) + uint64_t data_object_size; ///< size of the data object + int index_read; +@@ -286,4 +286,4 @@ + + #define ASF_PL_FLAG_KEY_FRAME 0x80 //1000 0000 + +-#endif // AVFORMAT_ASF_H ++#endif /* FFMPEG_ASF_H */ +diff -u mplayer-1.0~rc2-12/libavformat/au.c ffmpeg-free-0.svn20080206/libavformat/au.c +--- mplayer-1.0~rc2-12/libavformat/au.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/au.c 2008-01-13 16:08:33.000000000 +0100 +@@ -37,6 +37,7 @@ + /* The ffmpeg codecs we support, and the IDs they have in the file */ + static const AVCodecTag codec_au_tags[] = { + { CODEC_ID_PCM_MULAW, 1 }, ++ { CODEC_ID_PCM_S8, 2 }, + { CODEC_ID_PCM_S16BE, 3 }, + { CODEC_ID_PCM_ALAW, 27 }, + { 0, 0 }, +@@ -59,7 +60,7 @@ + + static int au_write_header(AVFormatContext *s) + { +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + + s->priv_data = NULL; + +@@ -75,17 +76,17 @@ + + static int au_write_packet(AVFormatContext *s, AVPacket *pkt) + { +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + put_buffer(pb, pkt->data, pkt->size); + return 0; + } + + static int au_write_trailer(AVFormatContext *s) + { +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + offset_t file_size; + +- if (!url_is_streamed(&s->pb)) { ++ if (!url_is_streamed(s->pb)) { + + /* update file size */ + file_size = url_ftell(pb); +@@ -116,7 +117,7 @@ + { + int size; + unsigned int tag; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + unsigned int id, codec, channels, rate; + AVStream *st; + +@@ -158,9 +159,9 @@ + { + int ret; + +- if (url_feof(&s->pb)) ++ if (url_feof(s->pb)) + return AVERROR(EIO); +- ret= av_get_packet(&s->pb, pkt, MAX_SIZE); ++ ret= av_get_packet(s->pb, pkt, MAX_SIZE); + if (ret < 0) + return AVERROR(EIO); + pkt->stream_index = 0; +Only in mplayer-1.0~rc2-12/libavformat: audio.c +Only in ffmpeg-free-0.svn20080206/libavformat: avc.c +Only in ffmpeg-free-0.svn20080206/libavformat: avc.h +diff -u mplayer-1.0~rc2-12/libavformat/avformat.h ffmpeg-free-0.svn20080206/libavformat/avformat.h +--- mplayer-1.0~rc2-12/libavformat/avformat.h 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/avformat.h 2008-01-29 10:25:49.000000000 +0100 +@@ -18,11 +18,11 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef AVFORMAT_H +-#define AVFORMAT_H ++#ifndef FFMPEG_AVFORMAT_H ++#define FFMPEG_AVFORMAT_H + +-#define LIBAVFORMAT_VERSION_INT ((51<<16)+(14<<8)+0) +-#define LIBAVFORMAT_VERSION 51.14.0 ++#define LIBAVFORMAT_VERSION_INT ((52<<16)+(7<<8)+0) ++#define LIBAVFORMAT_VERSION 52.7.0 + #define LIBAVFORMAT_BUILD LIBAVFORMAT_VERSION_INT + + #define LIBAVFORMAT_IDENT "Lavf" AV_STRINGIFY(LIBAVFORMAT_VERSION) +@@ -136,9 +136,6 @@ + int height; + enum PixelFormat pix_fmt; + int channel; /**< used to select dv channel */ +-#if LIBAVFORMAT_VERSION_INT < (52<<16) +- const char *device; /**< video, audio or DV device */ +-#endif + const char *standard; /**< tv standard, NTSC, PAL, SECAM */ + int mpeg2ts_raw:1; /**< force raw MPEG2 transport stream output, if possible */ + int mpeg2ts_compute_pcr:1; /**< compute exact PCR for each transport +@@ -147,8 +144,10 @@ + int initial_pause:1; /**< do not begin to play the stream + immediately (RTSP only) */ + int prealloced_context:1; ++#if LIBAVFORMAT_VERSION_INT < (53<<16) + enum CodecID video_codec_id; + enum CodecID audio_codec_id; ++#endif + } AVFormatParameters; + + //! demuxer will use url_fopen, no opened file should be provided by the caller +@@ -198,9 +197,9 @@ + /** size of private data so that it can be allocated in the wrapper */ + int priv_data_size; + /** +- * tell if a given file has a chance of being parsed by this format. +- * The buffer provided is guranteed to be AVPROBE_PADDING_SIZE bytes big +- * so you dont have to check for that unless you need more. ++ * Tell if a given file has a chance of being parsed by this format. ++ * The buffer provided is guaranteed to be AVPROBE_PADDING_SIZE bytes ++ * big so you do not have to check for that unless you need more. + */ + int (*read_probe)(AVProbeData *); + /** read the format header and initialize the AVFormatContext +@@ -227,7 +226,8 @@ + int (*read_seek)(struct AVFormatContext *, + int stream_index, int64_t timestamp, int flags); + /** +- * gets the next timestamp in AV_TIME_BASE units. ++ * gets the next timestamp in stream[stream_index].time_base units. ++ * @return the timestamp or AV_NOPTS_VALUE if an error occured + */ + int64_t (*read_timestamp)(struct AVFormatContext *s, int stream_index, + int64_t *pos, int64_t pos_limit); +@@ -270,33 +270,37 @@ + int min_distance; /**< min distance between this and the previous keyframe, used to avoid unneeded searching */ + } AVIndexEntry; + ++/** ++ * Stream structure. ++ * New fields can be added to the end with minor version bumps. ++ * Removal, reordering and changes to existing fields require a major ++ * version bump. ++ * sizeof(AVStream) must not be used outside libav*. ++ */ + typedef struct AVStream { + int index; /**< stream index in AVFormatContext */ + int id; /**< format specific stream id */ + AVCodecContext *codec; /**< codec context */ + /** +- * real base frame rate of the stream. +- * this is the lowest framerate with which all timestamps can be ++ * Real base frame rate of the stream. ++ * This is the lowest frame rate with which all timestamps can be + * represented accurately (it is the least common multiple of all +- * framerates in the stream), Note, this value is just a guess! +- * for example if the timebase is 1/90000 and all frames have either +- * approximately 3600 or 1800 timer ticks then r_frame_rate will be 50/1 ++ * frame rates in the stream), Note, this value is just a guess! ++ * For example if the timebase is 1/90000 and all frames have either ++ * approximately 3600 or 1800 timer ticks then r_frame_rate will be 50/1. + */ + AVRational r_frame_rate; + void *priv_data; + + /* internal data used in av_find_stream_info() */ + int64_t first_dts; +-#if LIBAVFORMAT_VERSION_INT < (52<<16) +- int codec_info_nb_frames; +-#endif + /** encoding: PTS generation when outputing stream */ + struct AVFrac pts; + + /** +- * this is the fundamental unit of time (in seconds) in terms +- * of which frame timestamps are represented. for fixed-fps content, +- * timebase should be 1/framerate and timestamp increments should be ++ * This is the fundamental unit of time (in seconds) in terms ++ * of which frame timestamps are represented. For fixed-fps content, ++ * timebase should be 1/frame rate and timestamp increments should be + * identically 1. + */ + AVRational time_base; +@@ -309,16 +313,16 @@ + * MN: dunno if that is the right place for it */ + float quality; + /** +- * decoding: pts of the first frame of the stream, in stream time base. +- * only set this if you are absolutely 100% sure that the value you set +- * it to really is the pts of the first frame ++ * Decoding: pts of the first frame of the stream, in stream time base. ++ * Only set this if you are absolutely 100% sure that the value you set ++ * it to really is the pts of the first frame. + * This may be undefined (AV_NOPTS_VALUE). +- * @note the ASF header does NOT contain a correct start_time the ASF +- * demuxer must NOT set this ++ * @note The ASF header does NOT contain a correct start_time the ASF ++ * demuxer must NOT set this. + */ + int64_t start_time; + /** +- * decoding: duration of the stream, in stream time base. ++ * Decoding: duration of the stream, in stream time base. + * If a source file does not specify a duration, but does specify + * a bitrate, this value will be estimates from bit rate and file size. + */ +@@ -343,16 +347,26 @@ + + #define MAX_REORDER_DELAY 4 + int64_t pts_buffer[MAX_REORDER_DELAY+1]; ++ ++ char *filename; /**< source filename of the stream */ + } AVStream; + + #define AV_PROGRAM_RUNNING 1 + ++/** ++ * New fields can be added to the end with minor version bumps. ++ * Removal, reordering and changes to existing fields require a major ++ * version bump. ++ * sizeof(AVProgram) must not be used outside libav*. ++ */ + typedef struct AVProgram { + int id; + char *provider_name; ///< Network name for DVB streams + char *name; ///< Service name for DVB streams + int flags; + enum AVDiscard discard; ///< selects which program to discard and which to feed to the caller ++ unsigned int *stream_index; ++ unsigned int nb_stream_indexes; + } AVProgram; + + #define AVFMTCTX_NOHEADER 0x0001 /**< signal that no header is present +@@ -360,14 +374,20 @@ + + #define MAX_STREAMS 20 + +-/* format I/O context */ ++/** ++ * format I/O context. ++ * New fields can be added to the end with minor version bumps. ++ * Removal, reordering and changes to existing fields require a major ++ * version bump. ++ * sizeof(AVFormatContext) must not be used outside libav*. ++ */ + typedef struct AVFormatContext { + const AVClass *av_class; /**< set by av_alloc_format_context */ + /* can only be iformat or oformat, not both at the same time */ + struct AVInputFormat *iformat; + struct AVOutputFormat *oformat; + void *priv_data; +- ByteIOContext pb; ++ ByteIOContext *pb; + unsigned int nb_streams; + AVStream *streams[MAX_STREAMS]; + char filename[1024]; /**< input or output filename */ +@@ -443,6 +463,34 @@ + + unsigned int nb_programs; + AVProgram **programs; ++ ++ /** ++ * Forced video codec_id. ++ * demuxing: set by user ++ */ ++ enum CodecID video_codec_id; ++ /** ++ * Forced audio codec_id. ++ * demuxing: set by user ++ */ ++ enum CodecID audio_codec_id; ++ /** ++ * Forced subtitle codec_id. ++ * demuxing: set by user ++ */ ++ enum CodecID subtitle_codec_id; ++ ++ /** ++ * Maximum amount of memory in bytes to use per stream for the index. ++ * If the needed index exceeds this size entries will be discarded as ++ * needed to maintain a smaller size. This can lead to slower or less ++ * accurate seeking (depends on demuxer). ++ * Demuxers for which a full in memory index is mandatory will ignore ++ * this. ++ * muxing : unused ++ * demuxing: set by user ++ */ ++ unsigned int max_index_size; + } AVFormatContext; + + typedef struct AVPacketList { +@@ -450,18 +498,19 @@ + struct AVPacketList *next; + } AVPacketList; + ++#if LIBAVFORMAT_VERSION_INT < (53<<16) + extern AVInputFormat *first_iformat; + extern AVOutputFormat *first_oformat; ++#endif ++ ++AVInputFormat *av_iformat_next(AVInputFormat *f); ++AVOutputFormat *av_oformat_next(AVOutputFormat *f); + + enum CodecID av_guess_image2_codec(const char *filename); + + /* XXX: use automatic init with either ELF sections or C file parser */ + /* modules */ + +-#include "rtp.h" +- +-#include "rtsp.h" +- + /* utils.c */ + void av_register_input_format(AVInputFormat *format); + void av_register_output_format(AVOutputFormat *format); +@@ -566,7 +615,11 @@ + AVInputFormat *fmt, + int buf_size, + AVFormatParameters *ap); +-/** no av_open for output, so applications will need this: */ ++/** ++ * Allocate an AVFormatContext. ++ * Can be freed with av_free() but do not forget to free everything you ++ * explicitly allocated as well! ++ */ + AVFormatContext *av_alloc_format_context(void); + + /** +@@ -579,7 +632,7 @@ + * + * @param ic media file handle + * @return >=0 if OK. AVERROR_xxx if error. +- * @todo Let user decide somehow what information is needed so we do not waste time geting stuff the user does not need. ++ * @todo Let user decide somehow what information is needed so we do not waste time getting stuff the user does not need. + */ + int av_find_stream_info(AVFormatContext *ic); + +@@ -643,6 +696,12 @@ + int av_read_pause(AVFormatContext *s); + + /** ++ * Free a AVFormatContext allocated by av_open_input_stream. ++ * @param s context to free ++ */ ++void av_close_input_stream(AVFormatContext *s); ++ ++/** + * Close a media file (but not its codecs). + * + * @param s media file handle +@@ -691,6 +750,15 @@ + int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags); + + /** ++ * Ensures the index uses less memory than the maximum specified in ++ * AVFormatContext.max_index_size, by discarding entries if it grows ++ * too large. ++ * This function is not part of the public API and should only be called ++ * by demuxers. ++ */ ++void ff_reduce_index(AVFormatContext *s, int stream_index); ++ ++/** + * Add a index entry into a sorted list updateing if it is already there. + * + * @param timestamp timestamp in the timebase of the given stream +@@ -828,7 +896,7 @@ + * @endcode + * Returns the number of microseconds contained in a time interval + * with the specified duration or INT64_MIN if \p datestr cannot be +- * succesfully parsed. ++ * successfully parsed. + * @param duration Flag which tells how to interpret \p datestr, if + * not zero \p datestr is interpreted as a duration, otherwise as a + * date. +@@ -860,7 +928,7 @@ + * @param buf destination buffer + * @param buf_size destination buffer size + * @param path numbered sequence string +- * @number frame number ++ * @param number frame number + * @return 0 if OK, -1 if format error. + */ + int av_get_frame_filename(char *buf, int buf_size, +@@ -892,8 +960,6 @@ + + #ifdef HAVE_AV_CONFIG_H + +-#include "os_support.h" +- + void __dynarray_add(unsigned long **tab_ptr, int *nb_ptr, unsigned long elem); + + #ifdef __GNUC__ +@@ -930,5 +996,4 @@ + + #endif /* HAVE_AV_CONFIG_H */ + +-#endif /* AVFORMAT_H */ +- ++#endif /* FFMPEG_AVFORMAT_H */ +diff -u mplayer-1.0~rc2-12/libavformat/avidec.c ffmpeg-free-0.svn20080206/libavformat/avidec.c +--- mplayer-1.0~rc2-12/libavformat/avidec.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/avidec.c 2008-01-01 23:05:51.000000000 +0100 +@@ -106,7 +106,7 @@ + + static int read_braindead_odml_indx(AVFormatContext *s, int frame_num){ + AVIContext *avi = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + int longs_pre_entry= get_le16(pb); + int index_sub_type = get_byte(pb); + int index_type = get_byte(pb); +@@ -118,7 +118,7 @@ + AVIStream *ast; + int i; + int64_t last_pos= -1; +- int64_t filesize= url_fsize(&s->pb); ++ int64_t filesize= url_fsize(s->pb); + + #ifdef DEBUG_SEEK + av_log(s, AV_LOG_ERROR, "longs_pre_entry:%d index_type:%d entries_in_use:%d chunk_id:%X base:%16"PRIX64"\n", +@@ -225,7 +225,7 @@ + static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap) + { + AVIContext *avi = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + uint32_t tag, tag1, handler; + int codec_type, stream_index, frame_period, bit_rate; + unsigned int size, nb_frames; +@@ -523,6 +523,31 @@ + } + url_fseek(pb, i+size, SEEK_SET); + break; ++ case MKTAG('v', 'p', 'r', 'p'): ++ if(stream_index < (unsigned)s->nb_streams && size > 9*4){ ++ AVRational active, active_aspect; ++ ++ st = s->streams[stream_index]; ++ get_le32(pb); ++ get_le32(pb); ++ get_le32(pb); ++ get_le32(pb); ++ get_le32(pb); ++ ++ active_aspect.num= get_le16(pb); ++ active_aspect.den= get_le16(pb); ++ active.num = get_le32(pb); ++ active.den = get_le32(pb); ++ get_le32(pb); //nbFieldsPerFrame ++ ++ if(active_aspect.num && active_aspect.den && active.num && active.den){ ++ st->codec->sample_aspect_ratio= av_div_q(active_aspect, active); ++//av_log(s, AV_LOG_ERROR, "vprp %d/%d %d/%d\n", active_aspect.num, active_aspect.den, active.num, active.den); ++ } ++ size -= 9*4; ++ } ++ url_fseek(pb, size, SEEK_CUR); ++ break; + case MKTAG('I', 'N', 'A', 'M'): + avi_read_tag(pb, s->title, sizeof(s->title), size); + break; +@@ -583,7 +608,7 @@ + static int avi_read_packet(AVFormatContext *s, AVPacket *pkt) + { + AVIContext *avi = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + int n, d[8], size; + offset_t i, sync; + void* dstr; +@@ -628,7 +653,7 @@ + if(i>=0){ + int64_t pos= best_st->index_entries[i].pos; + pos += best_ast->packet_size - best_ast->remaining; +- url_fseek(&s->pb, pos + 8, SEEK_SET); ++ url_fseek(s->pb, pos + 8, SEEK_SET); + // av_log(NULL, AV_LOG_DEBUG, "pos=%"PRId64"\n", pos); + + assert(best_ast->remaining <= best_ast->packet_size); +@@ -819,7 +844,7 @@ + static int avi_read_idx1(AVFormatContext *s, int size) + { + AVIContext *avi = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + int nb_index_entries, i; + AVStream *st; + AVIStream *ast; +@@ -890,7 +915,7 @@ + static int avi_load_index(AVFormatContext *s) + { + AVIContext *avi = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + uint32_t tag, size; + offset_t pos= url_ftell(pb); + +@@ -965,7 +990,7 @@ + /* DV demux so it can synth correct timestamps */ + dv_offset_reset(avi->dv_demux, timestamp); + +- url_fseek(&s->pb, pos, SEEK_SET); ++ url_fseek(s->pb, pos, SEEK_SET); + avi->stream_index= -1; + return 0; + } +@@ -1005,7 +1030,7 @@ + } + + /* do the seek */ +- url_fseek(&s->pb, pos, SEEK_SET); ++ url_fseek(s->pb, pos, SEEK_SET); + avi->stream_index= -1; + return 0; + } +diff -u mplayer-1.0~rc2-12/libavformat/avienc.c ffmpeg-free-0.svn20080206/libavformat/avienc.c +--- mplayer-1.0~rc2-12/libavformat/avienc.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/avienc.c 2007-11-21 08:41:00.000000000 +0100 +@@ -105,7 +105,7 @@ + + static int avi_write_counters(AVFormatContext* s, int riff_id) + { +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + AVIContext *avi = s->priv_data; + int n, au_byterate, au_ssize, au_scale, nb_frames = 0; + offset_t file_size; +@@ -138,7 +138,7 @@ + static int avi_write_header(AVFormatContext *s) + { + AVIContext *avi = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + int bitrate, n, i, nb_frames, au_byterate, au_ssize, au_scale; + AVCodecContext *stream, *video_enc; + offset_t list1, list2, strh, strf; +@@ -332,7 +332,7 @@ + + static int avi_write_ix(AVFormatContext *s) + { +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + AVIContext *avi = s->priv_data; + char tag[5]; + char ix_tag[] = "ix00"; +@@ -389,7 +389,7 @@ + + static int avi_write_idx1(AVFormatContext *s) + { +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + AVIContext *avi = s->priv_data; + offset_t idx_chunk; + int i; +@@ -435,7 +435,7 @@ + static int avi_write_packet(AVFormatContext *s, AVPacket *pkt) + { + AVIContext *avi = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + unsigned char tag[5]; + unsigned int flags=0; + const int stream_index= pkt->stream_index; +@@ -476,7 +476,7 @@ + avi->audio_strm_length[stream_index] += size; + } + +- if (!url_is_streamed(&s->pb)) { ++ if (!url_is_streamed(s->pb)) { + AVIIndex* idx = &avi->indexes[stream_index]; + int cl = idx->entry / AVI_INDEX_CLUSTER_SIZE; + int id = idx->entry % AVI_INDEX_CLUSTER_SIZE; +@@ -509,7 +509,7 @@ + static int avi_write_trailer(AVFormatContext *s) + { + AVIContext *avi = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + int res = 0; + int i, j, n, nb_frames; + offset_t file_size; +diff -u mplayer-1.0~rc2-12/libavformat/aviobuf.c ffmpeg-free-0.svn20080206/libavformat/aviobuf.c +--- mplayer-1.0~rc2-12/libavformat/aviobuf.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/aviobuf.c 2008-01-05 00:09:58.000000000 +0100 +@@ -20,6 +20,7 @@ + */ + #include "avformat.h" + #include "avio.h" ++#include "crc.h" + #include + + #define IO_BUFFER_SIZE 32768 +@@ -38,11 +39,7 @@ + s->buffer = buffer; + s->buffer_size = buffer_size; + s->buf_ptr = buffer; +- s->write_flag = write_flag; +- if (!s->write_flag) +- s->buf_end = buffer; +- else +- s->buf_end = buffer + buffer_size; ++ url_resetbuf(s, write_flag ? URL_WRONLY : URL_RDONLY); + s->opaque = opaque; + s->write_packet = write_packet; + s->read_packet = read_packet; +@@ -58,9 +55,25 @@ + s->pos = buffer_size; + s->buf_end = s->buffer + buffer_size; + } ++ s->read_pause = NULL; ++ s->read_seek = NULL; + return 0; + } + ++ByteIOContext *av_alloc_put_byte( ++ unsigned char *buffer, ++ int buffer_size, ++ int write_flag, ++ void *opaque, ++ int (*read_packet)(void *opaque, uint8_t *buf, int buf_size), ++ int (*write_packet)(void *opaque, uint8_t *buf, int buf_size), ++ offset_t (*seek)(void *opaque, offset_t offset, int whence)) { ++ ByteIOContext *s = av_mallocz(sizeof(ByteIOContext)); ++ init_put_byte(s, buffer, buffer_size, write_flag, opaque, ++ read_packet, write_packet, seek); ++ return s; ++} ++ + static void flush_buffer(ByteIOContext *s) + { + if (s->buf_ptr > s->buffer) { +@@ -114,7 +127,12 @@ + offset_t url_fseek(ByteIOContext *s, offset_t offset, int whence) + { + offset_t offset1; +- offset_t pos= s->pos - (s->write_flag ? 0 : (s->buf_end - s->buffer)); ++ offset_t pos; ++ ++ if(!s) ++ return AVERROR(EINVAL); ++ ++ pos = s->pos - (s->write_flag ? 0 : (s->buf_end - s->buffer)); + + if (whence != SEEK_CUR && whence != SEEK_SET) + return AVERROR(EINVAL); +@@ -134,6 +152,8 @@ + offset1 >= 0 && offset1 < (s->buf_end - s->buffer) + (1<<16)){ + while(s->pos < offset && !s->eof_reached) + fill_buffer(s); ++ if (s->eof_reached) ++ return AVERROR(EPIPE); + s->buf_ptr = s->buf_end + offset - s->pos; + } else { + offset_t res = AVERROR(EPIPE); +@@ -170,6 +190,9 @@ + { + offset_t size; + ++ if(!s) ++ return AVERROR(EINVAL); ++ + if (!s->seek) + return AVERROR(EPIPE); + size = s->seek(s->opaque, 0, AVSEEK_SIZE); +@@ -184,11 +207,15 @@ + + int url_feof(ByteIOContext *s) + { ++ if(!s) ++ return 0; + return s->eof_reached; + } + + int url_ferror(ByteIOContext *s) + { ++ if(!s) ++ return 0; + return s->error; + } + +@@ -290,6 +317,10 @@ + } + } + ++unsigned long ff_crc04C11DB7_update(unsigned long checksum, const uint8_t *buf, unsigned int len){ ++ return av_crc(av_crc_get_table(AV_CRC_32_IEEE), checksum, buf, len); ++} ++ + unsigned long get_checksum(ByteIOContext *s){ + s->checksum= s->update_checksum(s->checksum, s->checksum_ptr, s->buf_ptr - s->checksum_ptr); + s->update_checksum= NULL; +@@ -471,32 +502,18 @@ + return val; + } + +-/* link with avio functions */ +- +-#ifdef CONFIG_MUXERS +-static int url_write_packet(void *opaque, uint8_t *buf, int buf_size) +-{ +- URLContext *h = opaque; +- return url_write(h, buf, buf_size); +-} +-#else +-#define url_write_packet NULL +-#endif //CONFIG_MUXERS +- +-static int url_read_packet(void *opaque, uint8_t *buf, int buf_size) +-{ +- URLContext *h = opaque; +- return url_read(h, buf, buf_size); +-} +- +-static offset_t url_seek_packet(void *opaque, offset_t offset, int whence) +-{ +- URLContext *h = opaque; +- return url_seek(h, offset, whence); +- //return 0; ++uint64_t ff_get_v(ByteIOContext *bc){ ++ uint64_t val = 0; ++ int tmp; ++ ++ do{ ++ tmp = get_byte(bc); ++ val= (val<<7) + (tmp&127); ++ }while(tmp&128); ++ return val; + } + +-int url_fdopen(ByteIOContext *s, URLContext *h) ++int url_fdopen(ByteIOContext **s, URLContext *h) + { + uint8_t *buffer; + int buffer_size, max_packet_size; +@@ -512,14 +529,25 @@ + if (!buffer) + return AVERROR(ENOMEM); + +- if (init_put_byte(s, buffer, buffer_size, ++ *s = av_mallocz(sizeof(ByteIOContext)); ++ if(!*s) { ++ av_free(buffer); ++ return AVERROR(ENOMEM); ++ } ++ ++ if (init_put_byte(*s, buffer, buffer_size, + (h->flags & URL_WRONLY || h->flags & URL_RDWR), h, +- url_read_packet, url_write_packet, url_seek_packet) < 0) { ++ url_read, url_write, url_seek) < 0) { + av_free(buffer); ++ av_freep(s); + return AVERROR(EIO); + } +- s->is_streamed = h->is_streamed; +- s->max_packet_size = max_packet_size; ++ (*s)->is_streamed = h->is_streamed; ++ (*s)->max_packet_size = max_packet_size; ++ if(h->prot) { ++ (*s)->read_pause = (int (*)(void *, int))h->prot->url_read_pause; ++ (*s)->read_seek = (offset_t (*)(void *, int, int64_t, int))h->prot->url_read_seek; ++ } + return 0; + } + +@@ -534,14 +562,27 @@ + s->buffer = buffer; + s->buffer_size = buf_size; + s->buf_ptr = buffer; +- if (!s->write_flag) +- s->buf_end = buffer; +- else +- s->buf_end = buffer + buf_size; ++ url_resetbuf(s, s->write_flag ? URL_WRONLY : URL_RDONLY); ++ return 0; ++} ++ ++int url_resetbuf(ByteIOContext *s, int flags) ++{ ++ URLContext *h = s->opaque; ++ if ((flags & URL_RDWR) || (h && h->flags != flags && !h->flags & URL_RDWR)) ++ return AVERROR(EINVAL); ++ ++ if (flags & URL_WRONLY) { ++ s->buf_end = s->buffer + s->buffer_size; ++ s->write_flag = 1; ++ } else { ++ s->buf_end = s->buffer; ++ s->write_flag = 0; ++ } + return 0; + } + +-int url_fopen(ByteIOContext *s, const char *filename, int flags) ++int url_fopen(ByteIOContext **s, const char *filename, int flags) + { + URLContext *h; + int err; +@@ -562,7 +603,7 @@ + URLContext *h = s->opaque; + + av_free(s->buffer); +- memset(s, 0, sizeof(ByteIOContext)); ++ av_free(s); + return url_close(h); + } + +@@ -612,15 +653,44 @@ + return s->max_packet_size; + } + ++int av_url_read_fpause(ByteIOContext *s, int pause) ++{ ++ if (!s->read_pause) ++ return AVERROR(ENOSYS); ++ return s->read_pause(s->opaque, pause); ++} ++ ++offset_t av_url_read_fseek(ByteIOContext *s, ++ int stream_index, int64_t timestamp, int flags) ++{ ++ URLContext *h = s->opaque; ++ offset_t ret; ++ if (!s->read_seek) ++ return AVERROR(ENOSYS); ++ ret = s->read_seek(h, stream_index, timestamp, flags); ++ if(ret >= 0) { ++ s->buf_ptr = s->buf_end; // Flush buffer ++ s->pos = s->seek(h, 0, SEEK_CUR); ++ } ++ return ret; ++} ++ + /* url_open_dyn_buf and url_close_dyn_buf are used in rtp.c to send a response + * back to the server even if CONFIG_MUXERS is not set. */ + #if defined(CONFIG_MUXERS) || defined(CONFIG_NETWORK) + /* buffer handling */ +-int url_open_buf(ByteIOContext *s, uint8_t *buf, int buf_size, int flags) ++int url_open_buf(ByteIOContext **s, uint8_t *buf, int buf_size, int flags) + { +- return init_put_byte(s, buf, buf_size, +- (flags & URL_WRONLY || flags & URL_RDWR), +- NULL, NULL, NULL, NULL); ++ int ret; ++ *s = av_mallocz(sizeof(ByteIOContext)); ++ if(!*s) ++ return AVERROR(ENOMEM); ++ ret = init_put_byte(*s, buf, buf_size, ++ (flags & URL_WRONLY || flags & URL_RDWR), ++ NULL, NULL, NULL, NULL); ++ if(ret != 0) ++ av_freep(s); ++ return ret; + } + + int url_close_buf(ByteIOContext *s) +@@ -700,7 +770,7 @@ + return 0; + } + +-static int url_open_dyn_buf_internal(ByteIOContext *s, int max_packet_size) ++static int url_open_dyn_buf_internal(ByteIOContext **s, int max_packet_size) + { + DynBuffer *d; + int io_buffer_size, ret; +@@ -715,27 +785,35 @@ + d = av_malloc(sizeof(DynBuffer) + io_buffer_size); + if (!d) + return -1; ++ *s = av_mallocz(sizeof(ByteIOContext)); ++ if(!*s) { ++ av_free(d); ++ return AVERROR(ENOMEM); ++ } + d->io_buffer_size = io_buffer_size; + d->buffer = NULL; + d->pos = 0; + d->size = 0; + d->allocated_size = 0; +- ret = init_put_byte(s, d->io_buffer, io_buffer_size, ++ ret = init_put_byte(*s, d->io_buffer, io_buffer_size, + 1, d, NULL, + max_packet_size ? dyn_packet_buf_write : dyn_buf_write, + max_packet_size ? NULL : dyn_buf_seek); + if (ret == 0) { +- s->max_packet_size = max_packet_size; ++ (*s)->max_packet_size = max_packet_size; ++ } else { ++ av_free(d); ++ av_freep(s); + } + return ret; + } + +-int url_open_dyn_buf(ByteIOContext *s) ++int url_open_dyn_buf(ByteIOContext **s) + { + return url_open_dyn_buf_internal(s, 0); + } + +-int url_open_dyn_packet_buf(ByteIOContext *s, int max_packet_size) ++int url_open_dyn_packet_buf(ByteIOContext **s, int max_packet_size) + { + if (max_packet_size <= 0) + return -1; +@@ -752,6 +830,7 @@ + *pbuffer = d->buffer; + size = d->size; + av_free(d); ++ av_free(s); + return size; + } + #endif /* CONFIG_MUXERS || CONFIG_NETWORK */ +diff -u mplayer-1.0~rc2-12/libavformat/avio.c ffmpeg-free-0.svn20080206/libavformat/avio.c +--- mplayer-1.0~rc2-12/libavformat/avio.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/avio.c 2008-01-08 23:07:59.000000000 +0100 +@@ -26,6 +26,12 @@ + URLProtocol *first_protocol = NULL; + URLInterruptCB *url_interrupt_cb = default_interrupt_cb; + ++URLProtocol *av_protocol_next(URLProtocol *p) ++{ ++ if(p) return p->next; ++ else return first_protocol; ++} ++ + int register_protocol(URLProtocol *protocol) + { + URLProtocol **p; +@@ -76,9 +82,7 @@ + err = AVERROR(ENOMEM); + goto fail; + } +-#if LIBAVFORMAT_VERSION_INT >= (52<<16) + uc->filename = (char *) &uc[1]; +-#endif + strcpy(uc->filename, filename); + uc->prot = up; + uc->flags = flags; +@@ -106,7 +110,6 @@ + return ret; + } + +-#if defined(CONFIG_MUXERS) || defined(CONFIG_PROTOCOLS) + int url_write(URLContext *h, unsigned char *buf, int size) + { + int ret; +@@ -118,7 +121,6 @@ + ret = h->prot->url_write(h, buf, size); + return ret; + } +-#endif //CONFIG_MUXERS || CONFIG_PROTOCOLS + + offset_t url_seek(URLContext *h, offset_t pos, int whence) + { +@@ -132,9 +134,11 @@ + + int url_close(URLContext *h) + { +- int ret; ++ int ret = 0; ++ if (!h) return 0; /* can happen when url_open fails */ + +- ret = h->prot->url_close(h); ++ if (h->prot->url_close) ++ ret = h->prot->url_close(h); + av_free(h); + return ret; + } +@@ -185,3 +189,18 @@ + interrupt_cb = default_interrupt_cb; + url_interrupt_cb = interrupt_cb; + } ++ ++int av_url_read_pause(URLContext *h, int pause) ++{ ++ if (!h->prot->url_read_pause) ++ return AVERROR(ENOSYS); ++ return h->prot->url_read_pause(h, pause); ++} ++ ++offset_t av_url_read_seek(URLContext *h, ++ int stream_index, int64_t timestamp, int flags) ++{ ++ if (!h->prot->url_read_seek) ++ return AVERROR(ENOSYS); ++ return h->prot->url_read_seek(h, stream_index, timestamp, flags); ++} +diff -u mplayer-1.0~rc2-12/libavformat/avio.h ffmpeg-free-0.svn20080206/libavformat/avio.h +--- mplayer-1.0~rc2-12/libavformat/avio.h 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/avio.h 2007-12-22 17:18:07.000000000 +0100 +@@ -18,8 +18,8 @@ + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +-#ifndef AVIO_H +-#define AVIO_H ++#ifndef FFMPEG_AVIO_H ++#define FFMPEG_AVIO_H + + #include + +@@ -29,17 +29,20 @@ + + /* unbuffered I/O */ + ++/** ++ * URL Context. ++ * New fields can be added to the end with minor version bumps. ++ * Removal, reordering and changes to existing fields require a major ++ * version bump. ++ * sizeof(URLContext) must not be used outside libav*. ++ */ + struct URLContext { + struct URLProtocol *prot; + int flags; + int is_streamed; /**< true if streamed (no seek possible), default = false */ + int max_packet_size; /**< if non zero, the stream is packetized with this max packet size */ + void *priv_data; +-#if LIBAVFORMAT_VERSION_INT >= (52<<16) + char *filename; /**< specified filename */ +-#else +- char filename[1]; /**< specified filename */ +-#endif + }; + + typedef struct URLContext URLContext; +@@ -66,7 +69,7 @@ + + /** + * Return the maximum packet size associated to packetized file +- * handle. If the file is not packetized (stream like http or file on ++ * handle. If the file is not packetized (stream like HTTP or file on + * disk), then 0 is returned. + * + * @param h file handle +@@ -76,10 +79,10 @@ + void url_get_filename(URLContext *h, char *buf, int buf_size); + + /** +- * the callback is called in blocking functions to test regulary if ++ * The callback is called in blocking functions to test regulary if + * asynchronous interruption is needed. AVERROR(EINTR) is returned + * in this case by the interrupted function. 'NULL' means no interrupt +- * callback is given. i ++ * callback is given. + */ + void url_set_interrupt_cb(URLInterruptCB *interrupt_cb); + +@@ -87,6 +90,33 @@ + int url_poll(URLPollEntry *poll_table, int n, int timeout); + + /** ++ * Pause and resume playing - only meaningful if using a network streaming ++ * protocol (e.g. MMS). ++ * @param pause 1 for pause, 0 for resume ++ */ ++int av_url_read_pause(URLContext *h, int pause); ++ ++/** ++ * Seek to a given timestamp relative to some component stream. ++ * Only meaningful if using a network streaming protocol (e.g. MMS.). ++ * @param stream_index The stream index that the timestamp is relative to. ++ * If stream_index is (-1) the timestamp should be in AV_TIME_BASE ++ * units from the beginning of the presentation. ++ * If a stream_index >= 0 is used and the protocol does not support ++ * seeking based on component streams, the call will fail with ENOTSUP. ++ * @param timestamp timestamp in AVStream.time_base units ++ * or if there is no stream specified then in AV_TIME_BASE units. ++ * @param flags Optional combination of AVSEEK_FLAG_BACKWARD, AVSEEK_FLAG_BYTE ++ * and AVSEEK_FLAG_ANY. The protocol may silently ignore ++ * AVSEEK_FLAG_BACKWARD and AVSEEK_FLAG_ANY, but AVSEEK_FLAG_BYTE will ++ * fail with ENOTSUP if used and not supported. ++ * @return >= 0 on success ++ * @see AVInputFormat::read_seek ++ */ ++offset_t av_url_read_seek(URLContext *h, ++ int stream_index, int64_t timestamp, int flags); ++ ++/** + * Passing this as the "whence" parameter to a seek function causes it to + * return the filesize without seeking anywhere. Supporting this is optional. + * If it is not supported then the seek function will return <0. +@@ -101,13 +131,25 @@ + offset_t (*url_seek)(URLContext *h, offset_t pos, int whence); + int (*url_close)(URLContext *h); + struct URLProtocol *next; ++ int (*url_read_pause)(URLContext *h, int pause); ++ offset_t (*url_read_seek)(URLContext *h, ++ int stream_index, int64_t timestamp, int flags); + } URLProtocol; + + extern URLProtocol *first_protocol; + extern URLInterruptCB *url_interrupt_cb; + ++URLProtocol *av_protocol_next(URLProtocol *p); ++ + int register_protocol(URLProtocol *protocol); + ++/** ++ * Bytestream IO Context. ++ * New fields can be added to the end with minor version bumps. ++ * Removal, reordering and changes to existing fields require a major ++ * version bump. ++ * sizeof(ByteIOContext) must not be used outside libav*. ++ */ + typedef struct { + unsigned char *buffer; + int buffer_size; +@@ -126,6 +168,9 @@ + unsigned char *checksum_ptr; + unsigned long (*update_checksum)(unsigned long checksum, const uint8_t *buf, unsigned int size); + int error; ///< contains the error code or 0 if no error happened ++ int (*read_pause)(void *opaque, int pause); ++ offset_t (*read_seek)(void *opaque, ++ int stream_index, int64_t timestamp, int flags); + } ByteIOContext; + + int init_put_byte(ByteIOContext *s, +@@ -136,6 +181,14 @@ + int (*read_packet)(void *opaque, uint8_t *buf, int buf_size), + int (*write_packet)(void *opaque, uint8_t *buf, int buf_size), + offset_t (*seek)(void *opaque, offset_t offset, int whence)); ++ByteIOContext *av_alloc_put_byte( ++ unsigned char *buffer, ++ int buffer_size, ++ int write_flag, ++ void *opaque, ++ int (*read_packet)(void *opaque, uint8_t *buf, int buf_size), ++ int (*write_packet)(void *opaque, uint8_t *buf, int buf_size), ++ offset_t (*seek)(void *opaque, offset_t offset, int whence)); + + void put_byte(ByteIOContext *s, int b); + void put_buffer(ByteIOContext *s, const unsigned char *buf, int size); +@@ -158,6 +211,10 @@ + int url_feof(ByteIOContext *s); + int url_ferror(ByteIOContext *s); + ++int av_url_read_fpause(ByteIOContext *h, int pause); ++offset_t av_url_read_fseek(ByteIOContext *h, ++ int stream_index, int64_t timestamp, int flags); ++ + #define URL_EOF (-1) + /** @note return URL_EOF (-1) if EOF */ + int url_fgetc(ByteIOContext *s); +@@ -192,6 +249,8 @@ + unsigned int get_be32(ByteIOContext *s); + uint64_t get_be64(ByteIOContext *s); + ++uint64_t ff_get_v(ByteIOContext *bc); ++ + static inline int url_is_streamed(ByteIOContext *s) + { + return s->is_streamed; +@@ -199,14 +258,19 @@ + + /** @note when opened as read/write, the buffers are only used for + writing */ +-int url_fdopen(ByteIOContext *s, URLContext *h); ++int url_fdopen(ByteIOContext **s, URLContext *h); + + /** @warning must be called before any I/O */ + int url_setbufsize(ByteIOContext *s, int buf_size); ++/** Reset the buffer for reading or writing. ++ * @note Will drop any data currently in the buffer without transmitting it. ++ * @param flags URL_RDONLY to set up the buffer for reading, or URL_WRONLY ++ * to set up the buffer for writing. */ ++int url_resetbuf(ByteIOContext *s, int flags); + + /** @note when opened as read/write, the buffers are only used for + writing */ +-int url_fopen(ByteIOContext *s, const char *filename, int flags); ++int url_fopen(ByteIOContext **s, const char *filename, int flags); + int url_fclose(ByteIOContext *s); + URLContext *url_fileno(ByteIOContext *s); + +@@ -215,12 +279,12 @@ + * handle. If the file is not packetized (stream like http or file on + * disk), then 0 is returned. + * +- * @param h buffered file handle ++ * @param s buffered file handle + * @return maximum packet size in bytes + */ + int url_fget_max_packet_size(ByteIOContext *s); + +-int url_open_buf(ByteIOContext *s, uint8_t *buf, int buf_size, int flags); ++int url_open_buf(ByteIOContext **s, uint8_t *buf, int buf_size, int flags); + + /** return the written or read size */ + int url_close_buf(ByteIOContext *s); +@@ -231,7 +295,7 @@ + * @param s new IO context + * @return zero if no error. + */ +-int url_open_dyn_buf(ByteIOContext *s); ++int url_open_dyn_buf(ByteIOContext **s); + + /** + * Open a write only packetized memory stream with a maximum packet +@@ -242,17 +306,18 @@ + * @param max_packet_size maximum packet size (must be > 0) + * @return zero if no error. + */ +-int url_open_dyn_packet_buf(ByteIOContext *s, int max_packet_size); ++int url_open_dyn_packet_buf(ByteIOContext **s, int max_packet_size); + + /** + * Return the written size and a pointer to the buffer. The buffer + * must be freed with av_free(). + * @param s IO context +- * @param pointer to a byte buffer ++ * @param pbuffer pointer to a byte buffer + * @return the length of the byte buffer + */ + int url_close_dyn_buf(ByteIOContext *s, uint8_t **pbuffer); + ++unsigned long ff_crc04C11DB7_update(unsigned long checksum, const uint8_t *buf, unsigned int len); + unsigned long get_checksum(ByteIOContext *s); + void init_checksum(ByteIOContext *s, unsigned long (*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len), unsigned long checksum); + +@@ -261,5 +326,4 @@ + int udp_get_local_port(URLContext *h); + int udp_get_file_handle(URLContext *h); + +-#endif +- ++#endif /* FFMPEG_AVIO_H */ +diff -u mplayer-1.0~rc2-12/libavformat/avs.c ffmpeg-free-0.svn20080206/libavformat/avs.c +--- mplayer-1.0~rc2-12/libavformat/avs.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/avs.c 2007-11-21 08:41:00.000000000 +0100 +@@ -60,12 +60,12 @@ + + s->ctx_flags |= AVFMTCTX_NOHEADER; + +- url_fskip(&s->pb, 4); +- avs->width = get_le16(&s->pb); +- avs->height = get_le16(&s->pb); +- avs->bits_per_sample = get_le16(&s->pb); +- avs->fps = get_le16(&s->pb); +- avs->nb_frames = get_le32(&s->pb); ++ url_fskip(s->pb, 4); ++ avs->width = get_le16(s->pb); ++ avs->height = get_le16(s->pb); ++ avs->bits_per_sample = get_le16(s->pb); ++ avs->fps = get_le16(s->pb); ++ avs->nb_frames = get_le32(s->pb); + avs->remaining_frame_size = 0; + avs->remaining_audio_size = 0; + +@@ -103,7 +103,7 @@ + pkt->data[palette_size + 1] = type; + pkt->data[palette_size + 2] = size & 0xFF; + pkt->data[palette_size + 3] = (size >> 8) & 0xFF; +- ret = get_buffer(&s->pb, pkt->data + palette_size + 4, size - 4) + 4; ++ ret = get_buffer(s->pb, pkt->data + palette_size + 4, size - 4) + 4; + if (ret < size) { + av_free_packet(pkt); + return AVERROR(EIO); +@@ -122,9 +122,9 @@ + avs_format_t *avs = s->priv_data; + int ret, size; + +- size = url_ftell(&s->pb); ++ size = url_ftell(s->pb); + ret = voc_get_packet(s, pkt, avs->st_audio, avs->remaining_audio_size); +- size = url_ftell(&s->pb) - size; ++ size = url_ftell(s->pb) - size; + avs->remaining_audio_size -= size; + + if (ret == AVERROR(EIO)) +@@ -153,20 +153,20 @@ + + while (1) { + if (avs->remaining_frame_size <= 0) { +- if (!get_le16(&s->pb)) /* found EOF */ ++ if (!get_le16(s->pb)) /* found EOF */ + return AVERROR(EIO); +- avs->remaining_frame_size = get_le16(&s->pb) - 4; ++ avs->remaining_frame_size = get_le16(s->pb) - 4; + } + + while (avs->remaining_frame_size > 0) { +- sub_type = get_byte(&s->pb); +- type = get_byte(&s->pb); +- size = get_le16(&s->pb); ++ sub_type = get_byte(s->pb); ++ type = get_byte(s->pb); ++ size = get_le16(s->pb); + avs->remaining_frame_size -= size; + + switch (type) { + case AVS_PALETTE: +- ret = get_buffer(&s->pb, palette, size - 4); ++ ret = get_buffer(s->pb, palette, size - 4); + if (ret < size - 4) + return AVERROR(EIO); + palette_size = size; +@@ -203,7 +203,7 @@ + break; + + default: +- url_fskip(&s->pb, size - 4); ++ url_fskip(s->pb, size - 4); + } + } + } +Only in mplayer-1.0~rc2-12/libavformat: beosaudio.cpp +diff -u mplayer-1.0~rc2-12/libavformat/bethsoftvid.c ffmpeg-free-0.svn20080206/libavformat/bethsoftvid.c +--- mplayer-1.0~rc2-12/libavformat/bethsoftvid.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/bethsoftvid.c 2007-11-21 08:41:00.000000000 +0100 +@@ -59,7 +59,7 @@ + AVFormatParameters *ap) + { + BVID_DemuxContext *vid = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + AVStream *stream; + + /* load main header. Contents: +@@ -173,7 +173,7 @@ + AVPacket *pkt) + { + BVID_DemuxContext *vid = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + unsigned char block_type; + int audio_length; + int ret_value; +Only in mplayer-1.0~rc2-12/libavformat: bktr.c +diff -u mplayer-1.0~rc2-12/libavformat/c93.c ffmpeg-free-0.svn20080206/libavformat/c93.c +--- mplayer-1.0~rc2-12/libavformat/c93.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/c93.c 2007-11-21 08:41:00.000000000 +0100 +@@ -56,7 +56,7 @@ + AVFormatParameters *ap) + { + AVStream *video; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + C93DemuxContext *c93 = s->priv_data; + int i; + int framecount = 0; +@@ -101,7 +101,7 @@ + + static int read_packet(AVFormatContext *s, AVPacket *pkt) + { +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + C93DemuxContext *c93 = s->priv_data; + C93BlockRecord *br = &c93->block_records[c93->current_block]; + int datasize; +Only in mplayer-1.0~rc2-12/libavformat: crc.c +Only in ffmpeg-free-0.svn20080206/libavformat: crcenc.c +diff -u mplayer-1.0~rc2-12/libavformat/daud.c ffmpeg-free-0.svn20080206/libavformat/daud.c +--- mplayer-1.0~rc2-12/libavformat/daud.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/daud.c 2007-11-21 08:41:00.000000000 +0100 +@@ -34,7 +34,7 @@ + } + + static int daud_packet(AVFormatContext *s, AVPacket *pkt) { +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + int ret, size; + if (url_feof(pb)) + return AVERROR(EIO); +diff -u mplayer-1.0~rc2-12/libavformat/dsicin.c ffmpeg-free-0.svn20080206/libavformat/dsicin.c +--- mplayer-1.0~rc2-12/libavformat/dsicin.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/dsicin.c 2007-11-21 08:41:00.000000000 +0100 +@@ -94,7 +94,7 @@ + int rc; + CinDemuxContext *cin = s->priv_data; + CinFileHeader *hdr = &cin->file_header; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + AVStream *st; + + rc = cin_read_file_header(cin, pb); +@@ -158,7 +158,7 @@ + static int cin_read_packet(AVFormatContext *s, AVPacket *pkt) + { + CinDemuxContext *cin = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + CinFrameHeader *hdr = &cin->frame_header; + int rc, palette_type, pkt_size; + +Only in mplayer-1.0~rc2-12/libavformat: dv1394.c +Only in mplayer-1.0~rc2-12/libavformat: dv1394.h +diff -u mplayer-1.0~rc2-12/libavformat/dv.c ffmpeg-free-0.svn20080206/libavformat/dv.c +--- mplayer-1.0~rc2-12/libavformat/dv.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/dv.c 2007-11-21 08:41:00.000000000 +0100 +@@ -347,7 +347,7 @@ + // FIXME: sys may be wrong if last dv_read_packet() failed (buffer is junk) + const DVprofile* sys = dv_codec_profile(c->vst->codec); + int64_t offset; +- int64_t size = url_fsize(&s->pb); ++ int64_t size = url_fsize(s->pb); + int64_t max_offset = ((size-1) / sys->frame_size) * sys->frame_size; + + offset = sys->frame_size * timestamp; +@@ -386,8 +386,8 @@ + if (!c->dv_demux) + return -1; + +- if (get_buffer(&s->pb, c->buf, DV_PROFILE_BYTES) <= 0 || +- url_fseek(&s->pb, -DV_PROFILE_BYTES, SEEK_CUR) < 0) ++ if (get_buffer(s->pb, c->buf, DV_PROFILE_BYTES) <= 0 || ++ url_fseek(s->pb, -DV_PROFILE_BYTES, SEEK_CUR) < 0) + return AVERROR(EIO); + + c->dv_demux->sys = dv_frame_profile(c->buf); +@@ -408,7 +408,7 @@ + + if (size < 0) { + size = c->dv_demux->sys->frame_size; +- if (get_buffer(&s->pb, c->buf, size) <= 0) ++ if (get_buffer(s->pb, c->buf, size) <= 0) + return AVERROR(EIO); + + size = dv_produce_packet(c->dv_demux, pkt, c->buf, size); +@@ -426,7 +426,7 @@ + + dv_offset_reset(c, offset / c->sys->frame_size); + +- offset = url_fseek(&s->pb, offset, SEEK_SET); ++ offset = url_fseek(s->pb, offset, SEEK_SET); + return (offset < 0)?offset:0; + } + +diff -u mplayer-1.0~rc2-12/libavformat/dvenc.c ffmpeg-free-0.svn20080206/libavformat/dvenc.c +--- mplayer-1.0~rc2-12/libavformat/dvenc.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/dvenc.c 2007-11-21 08:41:00.000000000 +0100 +@@ -380,8 +380,8 @@ + fsize = dv_assemble_frame(s->priv_data, s->streams[pkt->stream_index], + pkt->data, pkt->size, &frame); + if (fsize > 0) { +- put_buffer(&s->pb, frame, fsize); +- put_flush_packet(&s->pb); ++ put_buffer(s->pb, frame, fsize); ++ put_flush_packet(s->pb); + } + return 0; + } +diff -u mplayer-1.0~rc2-12/libavformat/dv.h ffmpeg-free-0.svn20080206/libavformat/dv.h +--- mplayer-1.0~rc2-12/libavformat/dv.h 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/dv.h 2007-10-17 11:37:46.000000000 +0200 +@@ -25,8 +25,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef AVFORMAT_DV_H +-#define AVFORMAT_DV_H ++#ifndef FFMPEG_DV_H ++#define FFMPEG_DV_H + + #include "avformat.h" + +@@ -41,4 +41,4 @@ + int dv_assemble_frame(DVMuxContext *c, AVStream*, const uint8_t*, int, uint8_t**); + void dv_delete_mux(DVMuxContext*); + +-#endif // AVFORMAT_DV_H ++#endif /* FFMPEG_DV_H */ +diff -u mplayer-1.0~rc2-12/libavformat/dxa.c ffmpeg-free-0.svn20080206/libavformat/dxa.c +--- mplayer-1.0~rc2-12/libavformat/dxa.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/dxa.c 2007-11-21 08:41:00.000000000 +0100 +@@ -45,7 +45,7 @@ + + static int dxa_read_header(AVFormatContext *s, AVFormatParameters *ap) + { +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + DXAContext *c = s->priv_data; + AVStream *st, *ast; + uint32_t tag; +@@ -144,19 +144,19 @@ + + if(!c->readvid && c->has_sound && c->bytes_left){ + c->readvid = 1; +- url_fseek(&s->pb, c->wavpos, SEEK_SET); ++ url_fseek(s->pb, c->wavpos, SEEK_SET); + size = FFMIN(c->bytes_left, c->bpc); +- ret = av_get_packet(&s->pb, pkt, size); ++ ret = av_get_packet(s->pb, pkt, size); + pkt->stream_index = 1; + if(ret != size) + return AVERROR(EIO); + c->bytes_left -= size; +- c->wavpos = url_ftell(&s->pb); ++ c->wavpos = url_ftell(s->pb); + return 0; + } +- url_fseek(&s->pb, c->vidpos, SEEK_SET); +- while(!url_feof(&s->pb) && c->frames){ +- get_buffer(&s->pb, buf, 4); ++ url_fseek(s->pb, c->vidpos, SEEK_SET); ++ while(!url_feof(s->pb) && c->frames){ ++ get_buffer(s->pb, buf, 4); + switch(AV_RL32(buf)){ + case MKTAG('N', 'U', 'L', 'L'): + if(av_new_packet(pkt, 4 + pal_size) < 0) +@@ -165,16 +165,16 @@ + if(pal_size) memcpy(pkt->data, pal, pal_size); + memcpy(pkt->data + pal_size, buf, 4); + c->frames--; +- c->vidpos = url_ftell(&s->pb); ++ c->vidpos = url_ftell(s->pb); + c->readvid = 0; + return 0; + case MKTAG('C', 'M', 'A', 'P'): + pal_size = 768+4; + memcpy(pal, buf, 4); +- get_buffer(&s->pb, pal + 4, 768); ++ get_buffer(s->pb, pal + 4, 768); + break; + case MKTAG('F', 'R', 'A', 'M'): +- get_buffer(&s->pb, buf + 4, DXA_EXTRA_SIZE - 4); ++ get_buffer(s->pb, buf + 4, DXA_EXTRA_SIZE - 4); + size = AV_RB32(buf + 5); + if(size > 0xFFFFFF){ + av_log(s, AV_LOG_ERROR, "Frame size is too big: %d\n", size); +@@ -183,7 +183,7 @@ + if(av_new_packet(pkt, size + DXA_EXTRA_SIZE + pal_size) < 0) + return AVERROR(ENOMEM); + memcpy(pkt->data + pal_size, buf, DXA_EXTRA_SIZE); +- ret = get_buffer(&s->pb, pkt->data + DXA_EXTRA_SIZE + pal_size, size); ++ ret = get_buffer(s->pb, pkt->data + DXA_EXTRA_SIZE + pal_size, size); + if(ret != size){ + av_free_packet(pkt); + return AVERROR(EIO); +@@ -191,7 +191,7 @@ + if(pal_size) memcpy(pkt->data, pal, pal_size); + pkt->stream_index = 0; + c->frames--; +- c->vidpos = url_ftell(&s->pb); ++ c->vidpos = url_ftell(s->pb); + c->readvid = 0; + return 0; + default: +Only in ffmpeg-free-0.svn20080206/libavformat: eacdata.c +diff -u mplayer-1.0~rc2-12/libavformat/electronicarts.c ffmpeg-free-0.svn20080206/libavformat/electronicarts.c +--- mplayer-1.0~rc2-12/libavformat/electronicarts.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/electronicarts.c 2007-11-25 17:32:47.000000000 +0100 +@@ -27,33 +27,42 @@ + #include "avformat.h" + + #define SCHl_TAG MKTAG('S', 'C', 'H', 'l') ++#define SEAD_TAG MKTAG('S', 'E', 'A', 'D') /* Sxxx header */ ++#define SNDC_TAG MKTAG('S', 'N', 'D', 'C') /* Sxxx data */ ++#define SEND_TAG MKTAG('S', 'E', 'N', 'D') /* Sxxx end */ ++#define ISNh_TAG MKTAG('1', 'S', 'N', 'h') /* 1SNx header */ ++#define EACS_TAG MKTAG('E', 'A', 'C', 'S') ++#define ISNd_TAG MKTAG('1', 'S', 'N', 'd') /* 1SNx data */ ++#define ISNe_TAG MKTAG('1', 'S', 'N', 'e') /* 1SNx end */ + #define PT00_TAG MKTAG('P', 'T', 0x0, 0x0) ++#define GSTR_TAG MKTAG('G', 'S', 'T', 'R') + #define SCDl_TAG MKTAG('S', 'C', 'D', 'l') +-#define pIQT_TAG MKTAG('p', 'I', 'Q', 'T') + #define SCEl_TAG MKTAG('S', 'C', 'E', 'l') +-#define _TAG MKTAG('', '', '', '') +- +-#define EA_SAMPLE_RATE 22050 +-#define EA_BITS_PER_SAMPLE 16 +-#define EA_PREAMBLE_SIZE 8 ++#define kVGT_TAG MKTAG('k', 'V', 'G', 'T') /* TGV i-frame */ ++#define MADk_TAG MKTAG('M', 'A', 'D', 'k') /* MAD i-frame */ ++#define MPCh_TAG MKTAG('M', 'P', 'C', 'h') /* MPEG2 */ ++#define MVhd_TAG MKTAG('M', 'V', 'h', 'd') ++#define MV0K_TAG MKTAG('M', 'V', '0', 'K') ++#define MV0F_TAG MKTAG('M', 'V', '0', 'F') ++#define MVIh_TAG MKTAG('M', 'V', 'I', 'h') /* CMV header */ + + typedef struct EaDemuxContext { +- int width; +- int height; ++ int big_endian; ++ ++ int video_codec; ++ AVRational time_base; + int video_stream_index; +- int track_count; + ++ int audio_codec; + int audio_stream_index; + int audio_frame_counter; + + int64_t audio_pts; +- int64_t video_pts; +- int video_pts_inc; +- float fps; + ++ int bytes; ++ int sample_rate; + int num_channels; + int num_samples; +- int compression_type; + } EaDemuxContext; + + static uint32_t read_arbitary(ByteIOContext *pb) { +@@ -74,40 +83,24 @@ + } + + /* +- * Process WVE file header +- * Returns 1 if the WVE file is valid and successfully opened, 0 otherwise ++ * Process PT/GSTR sound header ++ * return 1 if success, 0 if invalid format, otherwise AVERROR_xxx + */ +-static int process_ea_header(AVFormatContext *s) { +- int inHeader; +- uint32_t blockid, size; ++static int process_audio_header_elements(AVFormatContext *s) ++{ ++ int inHeader = 1; + EaDemuxContext *ea = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; ++ int compression_type = -1, revision = -1, revision2 = -1; + +- if (get_buffer(pb, (void*)&blockid, 4) != 4) { +- return 0; +- } +- if (le2me_32(blockid) != SCHl_TAG) { +- return 0; +- } +- +- if (get_buffer(pb, (void*)&size, 4) != 4) { +- return 0; +- } +- size = le2me_32(size); ++ ea->bytes = 2; ++ ea->sample_rate = -1; ++ ea->num_channels = 1; + +- if (get_buffer(pb, (void*)&blockid, 4) != 4) { +- return 0; +- } +- if (le2me_32(blockid) != PT00_TAG) { +- av_log (s, AV_LOG_ERROR, "PT header missing\n"); +- return 0; +- } +- +- inHeader = 1; + while (inHeader) { + int inSubheader; + uint8_t byte; +- byte = get_byte(pb) & 0xFF; ++ byte = get_byte(pb); + + switch (byte) { + case 0xFD: +@@ -115,16 +108,24 @@ + inSubheader = 1; + while (inSubheader) { + uint8_t subbyte; +- subbyte = get_byte(pb) & 0xFF; ++ subbyte = get_byte(pb); + + switch (subbyte) { ++ case 0x80: ++ revision = read_arbitary(pb); ++ av_log (s, AV_LOG_INFO, "revision (element 0x80) set to 0x%08x\n", revision); ++ break; + case 0x82: + ea->num_channels = read_arbitary(pb); + av_log (s, AV_LOG_INFO, "num_channels (element 0x82) set to 0x%08x\n", ea->num_channels); + break; + case 0x83: +- ea->compression_type = read_arbitary(pb); +- av_log (s, AV_LOG_INFO, "compression_type (element 0x83) set to 0x%08x\n", ea->compression_type); ++ compression_type = read_arbitary(pb); ++ av_log (s, AV_LOG_INFO, "compression_type (element 0x83) set to 0x%08x\n", compression_type); ++ break; ++ case 0x84: ++ ea->sample_rate = read_arbitary(pb); ++ av_log (s, AV_LOG_INFO, "sample_rate (element 0x84) set to %i\n", ea->sample_rate); + break; + case 0x85: + ea->num_samples = read_arbitary(pb); +@@ -135,6 +136,15 @@ + av_log (s, AV_LOG_INFO, "exited audio subheader\n"); + inSubheader = 0; + break; ++ case 0xA0: ++ revision2 = read_arbitary(pb); ++ av_log (s, AV_LOG_INFO, "revision2 (element 0xA0) set to 0x%08x\n", revision2); ++ break; ++ case 0xFF: ++ av_log (s, AV_LOG_INFO, "end of header block reached (within audio subheader)\n"); ++ inSubheader = 0; ++ inHeader = 0; ++ break; + default: + av_log (s, AV_LOG_INFO, "element 0x%02x set to 0x%08x\n", subbyte, read_arbitary(pb)); + break; +@@ -151,24 +161,177 @@ + } + } + +- if ((ea->num_channels != 2) || (ea->compression_type != 7)) { +- av_log (s, AV_LOG_ERROR, "unsupported stream type\n"); ++ switch (compression_type) { ++ case 0: ea->audio_codec = CODEC_ID_PCM_S16LE; break; ++ case 7: ea->audio_codec = CODEC_ID_ADPCM_EA; break; ++ case -1: ++ switch (revision) { ++ case 1: ea->audio_codec = CODEC_ID_ADPCM_EA_R1; break; ++ case 2: ea->audio_codec = CODEC_ID_ADPCM_EA_R2; break; ++ case 3: ea->audio_codec = CODEC_ID_ADPCM_EA_R3; break; ++ case -1: break; ++ default: ++ av_log(s, AV_LOG_ERROR, "unsupported stream type; revision=%i\n", revision); ++ return 0; ++ } ++ switch (revision2) { ++ case 8: ea->audio_codec = CODEC_ID_PCM_S16LE_PLANAR; break; ++ default: ++ av_log(s, AV_LOG_ERROR, "unsupported stream type; revision2=%i\n", revision2); ++ return 0; ++ } ++ break; ++ default: ++ av_log(s, AV_LOG_ERROR, "unsupported stream type; compression_type=%i\n", compression_type); + return 0; + } + +- /* skip to the start of the data */ +- url_fseek(pb, size, SEEK_SET); ++ if (ea->sample_rate == -1) ++ ea->sample_rate = revision==3 ? 48000 : 22050; + + return 1; + } + ++/* ++ * Process EACS sound header ++ * return 1 if success, 0 if invalid format, otherwise AVERROR_xxx ++ */ ++static int process_audio_header_eacs(AVFormatContext *s) ++{ ++ EaDemuxContext *ea = s->priv_data; ++ ByteIOContext *pb = s->pb; ++ int compression_type; ++ ++ ea->sample_rate = ea->big_endian ? get_be32(pb) : get_le32(pb); ++ ea->bytes = get_byte(pb); /* 1=8-bit, 2=16-bit */ ++ ea->num_channels = get_byte(pb); ++ compression_type = get_byte(pb); ++ url_fskip(pb, 13); ++ ++ switch (compression_type) { ++ case 0: ++ switch (ea->bytes) { ++ case 1: ea->audio_codec = CODEC_ID_PCM_S8; break; ++ case 2: ea->audio_codec = CODEC_ID_PCM_S16LE; break; ++ } ++ break; ++ case 1: ea->audio_codec = CODEC_ID_PCM_MULAW; ea->bytes = 1; break; ++ case 2: ea->audio_codec = CODEC_ID_ADPCM_IMA_EA_EACS; break; ++ default: ++ av_log (s, AV_LOG_ERROR, "unsupported stream type; audio compression_type=%i\n", compression_type); ++ } + +-static int ea_probe(AVProbeData *p) ++ return 1; ++} ++ ++/* ++ * Process SEAD sound header ++ * return 1 if success, 0 if invalid format, otherwise AVERROR_xxx ++ */ ++static int process_audio_header_sead(AVFormatContext *s) + { +- if (AV_RL32(&p->buf[0]) != SCHl_TAG) +- return 0; ++ EaDemuxContext *ea = s->priv_data; ++ ByteIOContext *pb = s->pb; + +- return AVPROBE_SCORE_MAX; ++ ea->sample_rate = get_le32(pb); ++ ea->bytes = get_le32(pb); /* 1=8-bit, 2=16-bit */ ++ ea->num_channels = get_le32(pb); ++ ea->audio_codec = CODEC_ID_ADPCM_IMA_EA_SEAD; ++ ++ return 1; ++} ++ ++static int process_video_header_vp6(AVFormatContext *s) ++{ ++ EaDemuxContext *ea = s->priv_data; ++ ByteIOContext *pb = s->pb; ++ ++ url_fskip(pb, 16); ++ ea->time_base.den = get_le32(pb); ++ ea->time_base.num = get_le32(pb); ++ ea->video_codec = CODEC_ID_VP6; ++ ++ return 1; ++} ++ ++/* ++ * Process EA file header ++ * Returns 1 if the EA file is valid and successfully opened, 0 otherwise ++ */ ++static int process_ea_header(AVFormatContext *s) { ++ uint32_t blockid, size = 0; ++ EaDemuxContext *ea = s->priv_data; ++ ByteIOContext *pb = s->pb; ++ int i; ++ ++ for (i=0; i<5 && (!ea->audio_codec || !ea->video_codec); i++) { ++ unsigned int startpos = url_ftell(pb); ++ int err = 0; ++ ++ blockid = get_le32(pb); ++ size = get_le32(pb); ++ if (i == 0) ++ ea->big_endian = size > 0x000FFFFF; ++ if (ea->big_endian) ++ size = bswap_32(size); ++ ++ switch (blockid) { ++ case ISNh_TAG: ++ if (get_le32(pb) != EACS_TAG) { ++ av_log (s, AV_LOG_ERROR, "unknown 1SNh headerid\n"); ++ return 0; ++ } ++ err = process_audio_header_eacs(s); ++ break; ++ ++ case SCHl_TAG : ++ blockid = get_le32(pb); ++ if (blockid == GSTR_TAG) { ++ url_fskip(pb, 4); ++ } else if (blockid != PT00_TAG) { ++ av_log (s, AV_LOG_ERROR, "unknown SCHl headerid\n"); ++ return 0; ++ } ++ err = process_audio_header_elements(s); ++ break; ++ ++ case SEAD_TAG: ++ err = process_audio_header_sead(s); ++ break; ++ ++ case MVhd_TAG : ++ err = process_video_header_vp6(s); ++ break; ++ } ++ ++ if (err < 0) { ++ av_log(s, AV_LOG_ERROR, "error parsing header: %i\n", err); ++ return err; ++ } ++ ++ url_fseek(pb, startpos + size, SEEK_SET); ++ } ++ ++ url_fseek(pb, 0, SEEK_SET); ++ ++ return 1; ++} ++ ++ ++static int ea_probe(AVProbeData *p) ++{ ++ switch (AV_RL32(&p->buf[0])) { ++ case ISNh_TAG: ++ case SCHl_TAG: ++ case SEAD_TAG: ++ case kVGT_TAG: ++ case MADk_TAG: ++ case MPCh_TAG: ++ case MVhd_TAG: ++ case MVIh_TAG: ++ return AVPROBE_SCORE_MAX; ++ } ++ return 0; + } + + static int ea_read_header(AVFormatContext *s, +@@ -180,35 +343,36 @@ + if (!process_ea_header(s)) + return AVERROR(EIO); + +-#if 0 +- /* initialize the video decoder stream */ +- st = av_new_stream(s, 0); +- if (!st) +- return AVERROR(ENOMEM); +- av_set_pts_info(st, 33, 1, 90000); +- ea->video_stream_index = st->index; +- st->codec->codec_type = CODEC_TYPE_VIDEO; +- st->codec->codec_id = CODEC_ID_EA_MJPEG; +- st->codec->codec_tag = 0; /* no fourcc */ +-#endif +- +- /* initialize the audio decoder stream */ +- st = av_new_stream(s, 0); +- if (!st) +- return AVERROR(ENOMEM); +- av_set_pts_info(st, 33, 1, EA_SAMPLE_RATE); +- st->codec->codec_type = CODEC_TYPE_AUDIO; +- st->codec->codec_id = CODEC_ID_ADPCM_EA; +- st->codec->codec_tag = 0; /* no tag */ +- st->codec->channels = ea->num_channels; +- st->codec->sample_rate = EA_SAMPLE_RATE; +- st->codec->bits_per_sample = EA_BITS_PER_SAMPLE; +- st->codec->bit_rate = st->codec->channels * st->codec->sample_rate * +- st->codec->bits_per_sample / 4; +- st->codec->block_align = st->codec->channels * st->codec->bits_per_sample; ++ if (ea->video_codec) { ++ /* initialize the video decoder stream */ ++ st = av_new_stream(s, 0); ++ if (!st) ++ return AVERROR(ENOMEM); ++ ea->video_stream_index = st->index; ++ st->codec->codec_type = CODEC_TYPE_VIDEO; ++ st->codec->codec_id = ea->video_codec; ++ st->codec->codec_tag = 0; /* no fourcc */ ++ st->codec->time_base = ea->time_base; ++ } + +- ea->audio_stream_index = st->index; +- ea->audio_frame_counter = 0; ++ if (ea->audio_codec) { ++ /* initialize the audio decoder stream */ ++ st = av_new_stream(s, 0); ++ if (!st) ++ return AVERROR(ENOMEM); ++ av_set_pts_info(st, 33, 1, ea->sample_rate); ++ st->codec->codec_type = CODEC_TYPE_AUDIO; ++ st->codec->codec_id = ea->audio_codec; ++ st->codec->codec_tag = 0; /* no tag */ ++ st->codec->channels = ea->num_channels; ++ st->codec->sample_rate = ea->sample_rate; ++ st->codec->bits_per_sample = ea->bytes * 8; ++ st->codec->bit_rate = st->codec->channels * st->codec->sample_rate * ++ st->codec->bits_per_sample / 4; ++ st->codec->block_align = st->codec->channels*st->codec->bits_per_sample; ++ ea->audio_stream_index = st->index; ++ ea->audio_frame_counter = 0; ++ } + + return 1; + } +@@ -217,22 +381,32 @@ + AVPacket *pkt) + { + EaDemuxContext *ea = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + int ret = 0; + int packet_read = 0; +- unsigned char preamble[EA_PREAMBLE_SIZE]; + unsigned int chunk_type, chunk_size; ++ int key = 0; + + while (!packet_read) { +- +- if (get_buffer(pb, preamble, EA_PREAMBLE_SIZE) != EA_PREAMBLE_SIZE) +- return AVERROR(EIO); +- chunk_type = AV_RL32(&preamble[0]); +- chunk_size = AV_RL32(&preamble[4]) - EA_PREAMBLE_SIZE; ++ chunk_type = get_le32(pb); ++ chunk_size = (ea->big_endian ? get_be32(pb) : get_le32(pb)) - 8; + + switch (chunk_type) { + /* audio data */ ++ case ISNh_TAG: ++ /* header chunk also contains data; skip over the header portion*/ ++ url_fskip(pb, 32); ++ chunk_size -= 32; ++ case ISNd_TAG: + case SCDl_TAG: ++ case SNDC_TAG: ++ if (!ea->audio_codec) { ++ url_fskip(pb, chunk_size); ++ break; ++ } else if (ea->audio_codec == CODEC_ID_PCM_S16LE_PLANAR) { ++ url_fskip(pb, 12); /* planar header */ ++ chunk_size -= 12; ++ } + ret = av_get_packet(pb, pkt, chunk_size); + if (ret != chunk_size) + ret = AVERROR(EIO); +@@ -240,43 +414,55 @@ + pkt->stream_index = ea->audio_stream_index; + pkt->pts = 90000; + pkt->pts *= ea->audio_frame_counter; +- pkt->pts /= EA_SAMPLE_RATE; ++ pkt->pts /= ea->sample_rate; + ++ switch (ea->audio_codec) { ++ case CODEC_ID_ADPCM_EA: + /* 2 samples/byte, 1 or 2 samples per frame depending + * on stereo; chunk also has 12-byte header */ + ea->audio_frame_counter += ((chunk_size - 12) * 2) / + ea->num_channels; ++ break; ++ default: ++ ea->audio_frame_counter += chunk_size / ++ (ea->bytes * ea->num_channels); ++ } + } + + packet_read = 1; + break; + + /* ending tag */ ++ case 0: ++ case ISNe_TAG: + case SCEl_TAG: ++ case SEND_TAG: + ret = AVERROR(EIO); + packet_read = 1; + break; + ++ case MV0K_TAG: ++ key = PKT_FLAG_KEY; ++ case MV0F_TAG: ++ ret = av_get_packet(pb, pkt, chunk_size); ++ if (ret != chunk_size) ++ ret = AVERROR_IO; ++ else { ++ pkt->stream_index = ea->video_stream_index; ++ pkt->flags |= key; ++ } ++ packet_read = 1; ++ break; ++ + default: + url_fseek(pb, chunk_size, SEEK_CUR); + break; + } +- +- /* ending packet */ +- if (chunk_type == SCEl_TAG) { +- } + } + + return ret; + } + +-static int ea_read_close(AVFormatContext *s) +-{ +-// EaDemuxContext *ea = s->priv_data; +- +- return 0; +-} +- + AVInputFormat ea_demuxer = { + "ea", + "Electronic Arts Multimedia Format", +@@ -284,5 +470,4 @@ + ea_probe, + ea_read_header, + ea_read_packet, +- ea_read_close, + }; +diff -u mplayer-1.0~rc2-12/libavformat/ffm.c ffmpeg-free-0.svn20080206/libavformat/ffm.c +--- mplayer-1.0~rc2-12/libavformat/ffm.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/ffm.c 2008-01-09 00:08:51.000000000 +0100 +@@ -64,7 +64,7 @@ + { + FFMContext *ffm = s->priv_data; + int fill_size, h; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + + fill_size = ffm->packet_end - ffm->packet_ptr; + memset(ffm->packet_ptr, 0, fill_size); +@@ -128,7 +128,7 @@ + FFMContext *ffm = s->priv_data; + AVStream *st; + FFMStream *fst; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + AVCodecContext *codec; + int bit_rate, i; + +@@ -278,7 +278,7 @@ + + static int ffm_write_trailer(AVFormatContext *s) + { +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + FFMContext *ffm = s->priv_data; + + /* flush packets */ +@@ -314,7 +314,7 @@ + if (size <= len) + return 1; + } +- pos = url_ftell(&s->pb); ++ pos = url_ftell(s->pb); + if (pos == ffm->write_index) { + /* exactly at the end of stream */ + return 0; +@@ -335,7 +335,7 @@ + uint8_t *buf, int size, int first) + { + FFMContext *ffm = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + int len, fill_size, size1, frame_offset; + + size1 = size; +@@ -393,7 +393,7 @@ + static void adjust_write_index(AVFormatContext *s) + { + FFMContext *ffm = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + int64_t pts; + //offset_t orig_write_index = ffm->write_index; + offset_t pos_min, pos_max; +@@ -452,7 +452,7 @@ + FFMContext *ffm = s->priv_data; + AVStream *st; + FFMStream *fst; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + AVCodecContext *codec; + int i, nb_streams; + uint32_t tag; +@@ -585,7 +585,7 @@ + } + #if 0 + printf("pos=%08"PRIx64" spos=%"PRIx64", write_index=%"PRIx64" size=%"PRIx64"\n", +- url_ftell(&s->pb), s->pb.pos, ffm->write_index, ffm->file_size); ++ url_ftell(s->pb), s->pb.pos, ffm->write_index, ffm->file_size); + #endif + if (ffm_read_data(s, ffm->header, FRAME_HEADER_SIZE, 1) != + FRAME_HEADER_SIZE) +@@ -610,7 +610,7 @@ + + av_new_packet(pkt, size); + pkt->stream_index = ffm->header[0]; +- pkt->pos = url_ftell(&s->pb); ++ pkt->pos = url_ftell(s->pb); + if (ffm->header[1] & FLAG_KEY_FRAME) + pkt->flags |= PKT_FLAG_KEY; + +@@ -638,7 +638,7 @@ + static void ffm_seek1(AVFormatContext *s, offset_t pos1) + { + FFMContext *ffm = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + offset_t pos; + + pos = pos1 + ffm->write_index; +@@ -652,7 +652,7 @@ + + static int64_t get_pts(AVFormatContext *s, offset_t pos) + { +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + int64_t pts; + + ffm_seek1(s, pos); +@@ -665,7 +665,7 @@ + } + + /* seek to a given time in the file. The file read pointer is +- positionned at or before pts. XXX: the following code is quite ++ positioned at or before pts. XXX: the following code is quite + approximative */ + static int ffm_seek(AVFormatContext *s, int stream_index, int64_t wanted_pts, int flags) + { +diff -u mplayer-1.0~rc2-12/libavformat/file.c ffmpeg-free-0.svn20080206/libavformat/file.c +--- mplayer-1.0~rc2-12/libavformat/file.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/file.c 2007-11-22 03:27:39.000000000 +0100 +@@ -24,6 +24,7 @@ + #include + #include + #include ++#include "os_support.h" + + + /* standard file protocol */ +@@ -110,16 +111,9 @@ + return 0; + } + +-static int pipe_close(URLContext *h) +-{ +- return 0; +-} +- + URLProtocol pipe_protocol = { + "pipe", + pipe_open, + file_read, + file_write, +- NULL, +- pipe_close, + }; +diff -u mplayer-1.0~rc2-12/libavformat/flic.c ffmpeg-free-0.svn20080206/libavformat/flic.c +--- mplayer-1.0~rc2-12/libavformat/flic.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/flic.c 2007-11-21 08:41:00.000000000 +0100 +@@ -67,7 +67,7 @@ + AVFormatParameters *ap) + { + FlicDemuxContext *flic = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + unsigned char header[FLIC_HEADER_SIZE]; + AVStream *st; + int speed; +@@ -142,7 +142,7 @@ + AVPacket *pkt) + { + FlicDemuxContext *flic = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + int packet_read = 0; + unsigned int size; + int magic; +diff -u mplayer-1.0~rc2-12/libavformat/flvdec.c ffmpeg-free-0.svn20080206/libavformat/flvdec.c +--- mplayer-1.0~rc2-12/libavformat/flvdec.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/flvdec.c 2007-12-20 12:22:39.000000000 +0100 +@@ -50,6 +50,8 @@ + case FLV_CODECID_NELLYMOSER_8HZ_MONO: + acodec->sample_rate = 8000; //in case metadata does not otherwise declare samplerate + case FLV_CODECID_NELLYMOSER: ++ acodec->codec_id = CODEC_ID_NELLYMOSER; ++ break; + default: + av_log(s, AV_LOG_INFO, "Unsupported audio codec (%x)\n", flv_codecid >> FLV_AUDIO_CODECID_OFFSET); + acodec->codec_tag = flv_codecid >> FLV_AUDIO_CODECID_OFFSET; +@@ -69,7 +71,7 @@ + vcodec->extradata_size = 1; + vcodec->extradata = av_malloc(1); + } +- vcodec->extradata[0] = get_byte(&s->pb); ++ vcodec->extradata[0] = get_byte(s->pb); + return 1; // 1 byte body size adjustment for flv_read_packet() + default: + av_log(s, AV_LOG_INFO, "Unsupported video codec (%x)\n", flv_codecid); +@@ -101,7 +103,7 @@ + double num_val; + + num_val = 0; +- ioc = &s->pb; ++ ioc = s->pb; + + amf_type = get_byte(ioc); + +@@ -177,12 +179,14 @@ + } + else if(!strcmp(key, "audiosamplerate") && acodec && num_val >= 0) { + //some tools, like FLVTool2, write consistently approximate metadata sample rates +- switch((int)num_val) { +- case 44000: acodec->sample_rate = 44100 ; break; +- case 22000: acodec->sample_rate = 22050 ; break; +- case 11000: acodec->sample_rate = 11025 ; break; +- case 5000 : acodec->sample_rate = 5512 ; break; +- default : acodec->sample_rate = num_val; ++ if (!acodec->sample_rate) { ++ switch((int)num_val) { ++ case 44000: acodec->sample_rate = 44100 ; break; ++ case 22000: acodec->sample_rate = 22050 ; break; ++ case 11000: acodec->sample_rate = 11025 ; break; ++ case 5000 : acodec->sample_rate = 5512 ; break; ++ default : acodec->sample_rate = num_val; ++ } + } + } + } +@@ -201,7 +205,7 @@ + astream = NULL; + vstream = NULL; + keylen = 0; +- ioc = &s->pb; ++ ioc = s->pb; + + //first object needs to be "onMetaData" string + type = get_byte(ioc); +@@ -222,14 +226,22 @@ + return 0; + } + ++static AVStream *create_stream(AVFormatContext *s, int is_audio){ ++ AVStream *st = av_new_stream(s, is_audio); ++ if (!st) ++ return NULL; ++ st->codec->codec_type = is_audio ? CODEC_TYPE_AUDIO : CODEC_TYPE_VIDEO; ++ av_set_pts_info(st, 24, 1, 1000); /* 24 bit pts in ms */ ++ return st; ++} ++ + static int flv_read_header(AVFormatContext *s, + AVFormatParameters *ap) + { + int offset, flags; +- AVStream *st; + +- url_fskip(&s->pb, 4); +- flags = get_byte(&s->pb); ++ url_fskip(s->pb, 4); ++ flags = get_byte(s->pb); + /* old flvtool cleared this field */ + /* FIXME: better fix needed */ + if (!flags) { +@@ -238,22 +250,16 @@ + } + + if(flags & FLV_HEADER_FLAG_HASVIDEO){ +- st = av_new_stream(s, 0); +- if (!st) ++ if(!create_stream(s, 0)) + return AVERROR(ENOMEM); +- st->codec->codec_type = CODEC_TYPE_VIDEO; +- av_set_pts_info(st, 24, 1, 1000); /* 24 bit pts in ms */ + } + if(flags & FLV_HEADER_FLAG_HASAUDIO){ +- st = av_new_stream(s, 1); +- if (!st) ++ if(!create_stream(s, 1)) + return AVERROR(ENOMEM); +- st->codec->codec_type = CODEC_TYPE_AUDIO; +- av_set_pts_info(st, 24, 1, 1000); /* 24 bit pts in ms */ + } + +- offset = get_be32(&s->pb); +- url_fseek(&s->pb, offset, SEEK_SET); ++ offset = get_be32(s->pb); ++ url_fseek(s->pb, offset, SEEK_SET); + + s->start_time = 0; + +@@ -266,34 +272,35 @@ + AVStream *st = NULL; + + for(;;){ +- pos = url_ftell(&s->pb); +- url_fskip(&s->pb, 4); /* size of previous packet */ +- type = get_byte(&s->pb); +- size = get_be24(&s->pb); +- pts = get_be24(&s->pb); ++ pos = url_ftell(s->pb); ++ url_fskip(s->pb, 4); /* size of previous packet */ ++ type = get_byte(s->pb); ++ size = get_be24(s->pb); ++ pts = get_be24(s->pb); ++ pts |= get_byte(s->pb) << 24; + // av_log(s, AV_LOG_DEBUG, "type:%d, size:%d, pts:%d\n", type, size, pts); +- if (url_feof(&s->pb)) ++ if (url_feof(s->pb)) + return AVERROR(EIO); +- url_fskip(&s->pb, 4); /* reserved */ ++ url_fskip(s->pb, 3); /* stream id, always 0 */ + flags = 0; + + if(size == 0) + continue; + +- next= size + url_ftell(&s->pb); ++ next= size + url_ftell(s->pb); + + if (type == FLV_TAG_TYPE_AUDIO) { + is_audio=1; +- flags = get_byte(&s->pb); ++ flags = get_byte(s->pb); + } else if (type == FLV_TAG_TYPE_VIDEO) { + is_audio=0; +- flags = get_byte(&s->pb); ++ flags = get_byte(s->pb); + } else { + if (type == FLV_TAG_TYPE_META && size > 13+1+4) + flv_read_metabody(s, next); + else /* skip packet */ + av_log(s, AV_LOG_ERROR, "skipping flv packet: type %d, size %d, flags %d\n", type, size, flags); +- url_fseek(&s->pb, next, SEEK_SET); ++ url_fseek(s->pb, next, SEEK_SET); + continue; + } + +@@ -305,15 +312,14 @@ + } + if(i == s->nb_streams){ + av_log(NULL, AV_LOG_ERROR, "invalid stream\n"); +- url_fseek(&s->pb, next, SEEK_SET); +- continue; ++ st= create_stream(s, is_audio); + } + // av_log(NULL, AV_LOG_DEBUG, "%d %X %d \n", is_audio, flags, st->discard); + if( (st->discard >= AVDISCARD_NONKEY && !((flags & FLV_VIDEO_FRAMETYPE_MASK) == FLV_FRAME_KEY || is_audio)) + ||(st->discard >= AVDISCARD_BIDIR && ((flags & FLV_VIDEO_FRAMETYPE_MASK) == FLV_FRAME_DISP_INTER && !is_audio)) + || st->discard >= AVDISCARD_ALL + ){ +- url_fseek(&s->pb, next, SEEK_SET); ++ url_fseek(s->pb, next, SEEK_SET); + continue; + } + if ((flags & FLV_VIDEO_FRAMETYPE_MASK) == FLV_FRAME_KEY) +@@ -322,17 +328,17 @@ + } + + // if not streamed and no duration from metadata then seek to end to find the duration from the timestamps +- if(!url_is_streamed(&s->pb) && s->duration==AV_NOPTS_VALUE){ ++ if(!url_is_streamed(s->pb) && s->duration==AV_NOPTS_VALUE){ + int size; +- const int pos= url_ftell(&s->pb); +- const int fsize= url_fsize(&s->pb); +- url_fseek(&s->pb, fsize-4, SEEK_SET); +- size= get_be32(&s->pb); +- url_fseek(&s->pb, fsize-3-size, SEEK_SET); +- if(size == get_be24(&s->pb) + 11){ +- s->duration= get_be24(&s->pb) * (int64_t)AV_TIME_BASE / 1000; ++ const int pos= url_ftell(s->pb); ++ const int fsize= url_fsize(s->pb); ++ url_fseek(s->pb, fsize-4, SEEK_SET); ++ size= get_be32(s->pb); ++ url_fseek(s->pb, fsize-3-size, SEEK_SET); ++ if(size == get_be24(s->pb) + 11){ ++ s->duration= get_be24(s->pb) * (int64_t)AV_TIME_BASE / 1000; + } +- url_fseek(&s->pb, pos, SEEK_SET); ++ url_fseek(s->pb, pos, SEEK_SET); + } + + if(is_audio){ +@@ -349,7 +355,7 @@ + size -= flv_set_video_codec(s, st, flags & FLV_VIDEO_CODECID_MASK); + } + +- ret= av_get_packet(&s->pb, pkt, size - 1); ++ ret= av_get_packet(s->pb, pkt, size - 1); + if (ret <= 0) { + return AVERROR(EIO); + } +@@ -376,7 +382,7 @@ + int index = av_index_search_timestamp(st, timestamp, flags); + if (index < 0) + return -1; +- url_fseek(&s->pb, st->index_entries[index].pos, SEEK_SET); ++ url_fseek(s->pb, st->index_entries[index].pos, SEEK_SET); + + return 0; + } +diff -u mplayer-1.0~rc2-12/libavformat/flvenc.c ffmpeg-free-0.svn20080206/libavformat/flvenc.c +--- mplayer-1.0~rc2-12/libavformat/flvenc.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/flvenc.c 2007-11-21 08:41:00.000000000 +0100 +@@ -66,8 +66,10 @@ + break; + case 8000: //nellymoser only + case 5512: //not mp3 +- flags |= FLV_SAMPLERATE_SPECIAL; +- break; ++ if(enc->codec_id != CODEC_ID_MP3){ ++ flags |= FLV_SAMPLERATE_SPECIAL; ++ break; ++ } + default: + av_log(enc, AV_LOG_ERROR, "flv does not support that sample rate, choose from (44100, 22050, 11025).\n"); + return -1; +@@ -124,7 +126,7 @@ + + static int flv_write_header(AVFormatContext *s) + { +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + FLVContext *flv = s->priv_data; + int i, width, height, samplerate, samplesize, channels, audiocodecid, videocodecid; + double framerate = 0.0; +@@ -254,7 +256,7 @@ + { + int64_t file_size; + +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + FLVContext *flv = s->priv_data; + + file_size = url_ftell(pb); +@@ -271,7 +273,7 @@ + + static int flv_write_packet(AVFormatContext *s, AVPacket *pkt) + { +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + AVCodecContext *enc = s->streams[pkt->stream_index]->codec; + FLVContext *flv = s->priv_data; + int size= pkt->size; +@@ -305,7 +307,8 @@ + + put_be24(pb,size + flags_size); + put_be24(pb,pkt->pts); +- put_be32(pb,flv->reserved); ++ put_byte(pb,pkt->pts >> 24); ++ put_be24(pb,flv->reserved); + put_byte(pb,flags); + if (enc->codec_id == CODEC_ID_VP6) + put_byte(pb,0); +@@ -328,7 +331,7 @@ + #ifdef CONFIG_LIBMP3LAME + CODEC_ID_MP3, + #else // CONFIG_LIBMP3LAME +- CODEC_ID_NONE, ++ CODEC_ID_ADPCM_SWF, + #endif // CONFIG_LIBMP3LAME + CODEC_ID_FLV1, + flv_write_header, +diff -u mplayer-1.0~rc2-12/libavformat/flv.h ffmpeg-free-0.svn20080206/libavformat/flv.h +--- mplayer-1.0~rc2-12/libavformat/flv.h 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/flv.h 2007-10-17 11:37:46.000000000 +0200 +@@ -21,8 +21,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef FLV_H +-#define FLV_H ++#ifndef FFMPEG_FLV_H ++#define FFMPEG_FLV_H + + /* offsets for packed values */ + #define FLV_AUDIO_SAMPLESSIZE_OFFSET 1 +@@ -107,4 +107,4 @@ + AMF_DATA_TYPE_UNSUPPORTED = 0x0d, + } AMFDataType; + +-#endif /* FLV_H */ ++#endif /* FFMPEG_FLV_H */ +Only in ffmpeg-free-0.svn20080206/libavformat: framecrcenc.c +diff -u mplayer-1.0~rc2-12/libavformat/framehook.c ffmpeg-free-0.svn20080206/libavformat/framehook.c +--- mplayer-1.0~rc2-12/libavformat/framehook.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/framehook.c 2008-01-06 17:02:55.000000000 +0100 +@@ -28,8 +28,8 @@ + #endif + + +-typedef struct _FrameHookEntry { +- struct _FrameHookEntry *next; ++typedef struct FrameHookEntry { ++ struct FrameHookEntry *next; + FrameHookConfigureFn Configure; + FrameHookProcessFn Process; + FrameHookReleaseFn Release; +diff -u mplayer-1.0~rc2-12/libavformat/framehook.h ffmpeg-free-0.svn20080206/libavformat/framehook.h +--- mplayer-1.0~rc2-12/libavformat/framehook.h 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/framehook.h 2008-01-03 03:12:08.000000000 +0100 +@@ -19,10 +19,10 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef FRAMEHOOK_H +-#define FRAMEHOOK_H ++#ifndef FFMPEG_FRAMEHOOK_H ++#define FFMPEG_FRAMEHOOK_H + +-#warning VHOOK is deprecated. Please help porting libmpcodecs or a better filter system to FFmpeg instead of wasting your time writing new filters for this crappy one. ++#warning VHOOK is deprecated. Please help finishing libavfilter instead of wasting your time writing new filters for this crappy filter system. + + /* + * Prototypes for interface to .so that implement a video processing hook +@@ -49,4 +49,4 @@ + extern void frame_hook_process(struct AVPicture *pict, enum PixelFormat pix_fmt, int width, int height, int64_t pts); + extern void frame_hook_release(void); + +-#endif ++#endif /* FFMPEG_FRAMEHOOK_H */ +diff -u mplayer-1.0~rc2-12/libavformat/gif.c ffmpeg-free-0.svn20080206/libavformat/gif.c +--- mplayer-1.0~rc2-12/libavformat/gif.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/gif.c 2008-01-17 01:12:04.000000000 +0100 +@@ -137,7 +137,7 @@ + //printf("bitbuf = %08x\n", bit_buf); + s->buf_ptr+=4; + if (s->buf_ptr >= s->buf_end) +- puts("bit buffer overflow !!"); // should never happen ! who got rid of the callback ??? ++ abort(); + // flush_buffer_rev(s); + bit_cnt=bit_cnt + n - 32; + if (bit_cnt == 0) { +@@ -313,7 +313,7 @@ + static int gif_write_header(AVFormatContext *s) + { + GIFContext *gif = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + AVCodecContext *enc, *video_enc; + int i, width, height, loop_count /*, rate*/; + +@@ -348,14 +348,14 @@ + + gif_image_write_header(pb, width, height, loop_count, NULL); + +- put_flush_packet(&s->pb); ++ put_flush_packet(s->pb); + return 0; + } + + static int gif_write_video(AVFormatContext *s, + AVCodecContext *enc, const uint8_t *buf, int size) + { +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + GIFContext *gif = s->priv_data; + int jiffies; + int64_t delay; +@@ -383,7 +383,7 @@ + gif_image_write_image(pb, 0, 0, enc->width, enc->height, + buf, enc->width * 3, PIX_FMT_RGB24); + +- put_flush_packet(&s->pb); ++ put_flush_packet(s->pb); + return 0; + } + +@@ -398,10 +398,10 @@ + + static int gif_write_trailer(AVFormatContext *s) + { +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + + put_byte(pb, 0x3b); +- put_flush_packet(&s->pb); ++ put_flush_packet(s->pb); + return 0; + } + +diff -u mplayer-1.0~rc2-12/libavformat/gifdec.c ffmpeg-free-0.svn20080206/libavformat/gifdec.c +--- mplayer-1.0~rc2-12/libavformat/gifdec.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/gifdec.c 2007-11-21 08:41:00.000000000 +0100 +@@ -526,7 +526,7 @@ + AVFormatParameters * ap) + { + GifState *s = s1->priv_data; +- ByteIOContext *f = &s1->pb; ++ ByteIOContext *f = s1->pb; + AVStream *st; + + s->f = f; +diff -u mplayer-1.0~rc2-12/libavformat/gxf.c ffmpeg-free-0.svn20080206/libavformat/gxf.c +--- mplayer-1.0~rc2-12/libavformat/gxf.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/gxf.c 2007-11-21 08:41:00.000000000 +0100 +@@ -228,7 +228,7 @@ + * \brief read index from FLT packet into stream 0 av_index + */ + static void gxf_read_index(AVFormatContext *s, int pkt_len) { +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + AVStream *st = s->streams[0]; + uint32_t fields_per_map = get_le32(pb); + uint32_t map_cnt = get_le32(pb); +@@ -252,7 +252,7 @@ + } + + static int gxf_header(AVFormatContext *s, AVFormatParameters *ap) { +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + pkt_type_t pkt_type; + int map_len; + int len; +@@ -378,7 +378,7 @@ + int cur_track; + int64_t cur_timestamp = AV_NOPTS_VALUE; + int len; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + pkt_type_t type; + tmp = get_be32(pb); + start: +@@ -408,7 +408,7 @@ + } + + static int gxf_packet(AVFormatContext *s, AVPacket *pkt) { +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + pkt_type_t pkt_type; + int pkt_len; + while (!url_feof(pb)) { +@@ -466,7 +466,7 @@ + if (idx < st->nb_index_entries - 2) + maxlen = st->index_entries[idx + 2].pos - pos; + maxlen = FFMAX(maxlen, 200 * 1024); +- url_fseek(&s->pb, pos, SEEK_SET); ++ url_fseek(s->pb, pos, SEEK_SET); + found = gxf_resync_media(s, maxlen, -1, timestamp); + if (FFABS(found - timestamp) > 4) + return -1; +@@ -475,7 +475,7 @@ + + static int64_t gxf_read_timestamp(AVFormatContext *s, int stream_index, + int64_t *pos, int64_t pos_limit) { +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + int64_t res; + url_fseek(pb, *pos, SEEK_SET); + res = gxf_resync_media(s, pos_limit - *pos, -1, -1); +diff -u mplayer-1.0~rc2-12/libavformat/gxfenc.c ffmpeg-free-0.svn20080206/libavformat/gxfenc.c +--- mplayer-1.0~rc2-12/libavformat/gxfenc.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/gxfenc.c 2007-11-21 08:41:00.000000000 +0100 +@@ -576,7 +576,7 @@ + + static int gxf_write_header(AVFormatContext *s) + { +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + GXFContext *gxf = s->priv_data; + int i; + +@@ -671,7 +671,7 @@ + + static int gxf_write_trailer(AVFormatContext *s) + { +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + GXFContext *gxf = s->priv_data; + offset_t end; + int i; +@@ -763,8 +763,8 @@ + { + GXFContext *gxf = s->priv_data; + +- gxf_write_media_packet(&s->pb, gxf, pkt); +- put_flush_packet(&s->pb); ++ gxf_write_media_packet(s->pb, gxf, pkt); ++ put_flush_packet(s->pb); + return 0; + } + +diff -u mplayer-1.0~rc2-12/libavformat/http.c ffmpeg-free-0.svn20080206/libavformat/http.c +--- mplayer-1.0~rc2-12/libavformat/http.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/http.c 2008-02-02 23:03:01.000000000 +0100 +@@ -21,6 +21,7 @@ + #include "avformat.h" + #include + #include "network.h" ++#include "os_support.h" + + #include "base64.h" + #include "avstring.h" +@@ -218,7 +219,7 @@ + /* send http header */ + post = h->flags & URL_WRONLY; + auth_b64 = av_malloc(auth_b64_len); +- av_base64_encode(auth_b64, auth_b64_len, (uint8_t *)auth, strlen(auth)); ++ av_base64_encode(auth_b64, auth_b64_len, auth, strlen(auth)); + snprintf(s->buffer, sizeof(s->buffer), + "%s %s HTTP/1.1\r\n" + "User-Agent: %s\r\n" +@@ -246,7 +247,6 @@ + s->off = 0; + s->filesize = -1; + if (post) { +- usleep(1000*1000); + return 0; + } + +diff -u mplayer-1.0~rc2-12/libavformat/idcin.c ffmpeg-free-0.svn20080206/libavformat/idcin.c +--- mplayer-1.0~rc2-12/libavformat/idcin.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/idcin.c 2007-11-21 08:41:00.000000000 +0100 +@@ -136,7 +136,7 @@ + static int idcin_read_header(AVFormatContext *s, + AVFormatParameters *ap) + { +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + IdcinDemuxContext *idcin = s->priv_data; + AVStream *st; + unsigned int width, height; +@@ -215,13 +215,13 @@ + unsigned int command; + unsigned int chunk_size; + IdcinDemuxContext *idcin = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + int i; + int palette_scale; + unsigned char r, g, b; + unsigned char palette_buffer[768]; + +- if (url_feof(&s->pb)) ++ if (url_feof(s->pb)) + return AVERROR(EIO); + + if (idcin->next_chunk_is_video) { +diff -u mplayer-1.0~rc2-12/libavformat/idroq.c ffmpeg-free-0.svn20080206/libavformat/idroq.c +--- mplayer-1.0~rc2-12/libavformat/idroq.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/idroq.c 2007-11-21 08:41:00.000000000 +0100 +@@ -69,7 +69,7 @@ + AVFormatParameters *ap) + { + RoqDemuxContext *roq = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + AVStream *st; + unsigned char preamble[RoQ_CHUNK_PREAMBLE_SIZE]; + int i; +@@ -174,7 +174,7 @@ + AVPacket *pkt) + { + RoqDemuxContext *roq = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + int ret = 0; + unsigned int chunk_size; + unsigned int chunk_type; +@@ -185,7 +185,7 @@ + + while (!packet_read) { + +- if (url_feof(&s->pb)) ++ if (url_feof(s->pb)) + return AVERROR(EIO); + + /* get the next chunk preamble */ +diff -u mplayer-1.0~rc2-12/libavformat/img2.c ffmpeg-free-0.svn20080206/libavformat/img2.c +--- mplayer-1.0~rc2-12/libavformat/img2.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/img2.c 2007-12-28 14:07:43.000000000 +0100 +@@ -57,6 +57,14 @@ + { CODEC_ID_TIFF , "tiff"}, + { CODEC_ID_SGI , "sgi"}, + { CODEC_ID_PTX , "ptx"}, ++ { CODEC_ID_PCX , "pcx"}, ++ { CODEC_ID_SUNRAST , "sun"}, ++ { CODEC_ID_SUNRAST , "ras"}, ++ { CODEC_ID_SUNRAST , "rs"}, ++ { CODEC_ID_SUNRAST , "im1"}, ++ { CODEC_ID_SUNRAST , "im8"}, ++ { CODEC_ID_SUNRAST , "im24"}, ++ { CODEC_ID_SUNRAST , "sunras"}, + {0, NULL} + }; + +@@ -239,7 +247,7 @@ + char filename[1024]; + int i; + int size[3]={0}, ret[3]={0}; +- ByteIOContext f1[3], *f[3]= {&f1[0], &f1[1], &f1[2]}; ++ ByteIOContext *f[3]; + AVCodecContext *codec= s1->streams[0]->codec; + + if (!s->is_pipe) { +@@ -251,7 +259,7 @@ + s->path, s->img_number)<0 && s->img_number > 1) + return AVERROR(EIO); + for(i=0; i<3; i++){ +- if (url_fopen(f[i], filename, URL_RDONLY) < 0) ++ if (url_fopen(&f[i], filename, URL_RDONLY) < 0) + return AVERROR(EIO); + size[i]= url_fsize(f[i]); + +@@ -263,7 +271,7 @@ + if(codec->codec_id == CODEC_ID_RAWVIDEO && !codec->width) + infer_size(&codec->width, &codec->height, size[0]); + } else { +- f[0] = &s1->pb; ++ f[0] = s1->pb; + if (url_feof(f[0])) + return AVERROR(EIO); + size[0]= 4096; +@@ -322,7 +330,7 @@ + static int img_write_packet(AVFormatContext *s, AVPacket *pkt) + { + VideoData *img = s->priv_data; +- ByteIOContext pb1[3], *pb[3]= {&pb1[0], &pb1[1], &pb1[2]}; ++ ByteIOContext *pb[3]; + char filename[1024]; + AVCodecContext *codec= s->streams[ pkt->stream_index ]->codec; + int i; +@@ -332,7 +340,7 @@ + img->path, img->img_number) < 0 && img->img_number>1) + return AVERROR(EIO); + for(i=0; i<3; i++){ +- if (url_fopen(pb[i], filename, URL_WRONLY) < 0) ++ if (url_fopen(&pb[i], filename, URL_WRONLY) < 0) + return AVERROR(EIO); + + if(codec->codec_id != CODEC_ID_RAWVIDEO) +@@ -340,7 +348,7 @@ + filename[ strlen(filename) - 1 ]= 'U' + i; + } + } else { +- pb[0] = &s->pb; ++ pb[0] = s->pb; + } + + if(codec->codec_id == CODEC_ID_RAWVIDEO){ +diff -u mplayer-1.0~rc2-12/libavformat/ipmovie.c ffmpeg-free-0.svn20080206/libavformat/ipmovie.c +--- mplayer-1.0~rc2-12/libavformat/ipmovie.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/ipmovie.c 2007-11-21 08:41:00.000000000 +0100 +@@ -517,7 +517,7 @@ + AVFormatParameters *ap) + { + IPMVEContext *ipmovie = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + AVPacket pkt; + AVStream *st; + unsigned char chunk_preamble[CHUNK_PREAMBLE_SIZE]; +@@ -589,7 +589,7 @@ + AVPacket *pkt) + { + IPMVEContext *ipmovie = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + int ret; + + ret = process_ipmovie_chunk(ipmovie, pb, pkt); +diff -u mplayer-1.0~rc2-12/libavformat/isom.c ffmpeg-free-0.svn20080206/libavformat/isom.c +--- mplayer-1.0~rc2-12/libavformat/isom.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/isom.c 2008-01-29 23:37:07.000000000 +0100 +@@ -26,12 +26,13 @@ + #include "isom.h" + + /* http://www.mp4ra.org */ ++/* ordered by muxing preference */ + const AVCodecTag ff_mp4_obj_type[] = { + { CODEC_ID_MPEG4 , 32 }, + { CODEC_ID_H264 , 33 }, + { CODEC_ID_AAC , 64 }, +- { CODEC_ID_MPEG2VIDEO, 96 }, /* MPEG2 Simple */ + { CODEC_ID_MPEG2VIDEO, 97 }, /* MPEG2 Main */ ++ { CODEC_ID_MPEG2VIDEO, 96 }, /* MPEG2 Simple */ + { CODEC_ID_MPEG2VIDEO, 98 }, /* MPEG2 SNR */ + { CODEC_ID_MPEG2VIDEO, 99 }, /* MPEG2 Spatial */ + { CODEC_ID_MPEG2VIDEO, 100 }, /* MPEG2 High */ +@@ -39,22 +40,16 @@ + { CODEC_ID_AAC , 102 }, /* MPEG2 AAC Main */ + { CODEC_ID_AAC , 103 }, /* MPEG2 AAC Low */ + { CODEC_ID_AAC , 104 }, /* MPEG2 AAC SSR */ ++ { CODEC_ID_MP3 , 107 }, /* 11172-3 */ + { CODEC_ID_MP3 , 105 }, /* 13818-3 */ + { CODEC_ID_MPEG1VIDEO, 106 }, /* 11172-2 */ +- { CODEC_ID_MP3 , 107 }, /* 11172-3 */ + { CODEC_ID_MJPEG , 108 }, /* 10918-1 */ + { CODEC_ID_PNG , 109 }, + { CODEC_ID_JPEG2000 , 110 }, /* 15444-1 */ + { CODEC_ID_VC1 , 163 }, +- { CODEC_ID_VORBIS , 221 }, +- { CODEC_ID_PCM_S16LE , 224 }, ++ { CODEC_ID_VORBIS , 221 }, /* non standard, gpac uses it */ ++ { CODEC_ID_DVD_SUBTITLE, 224 }, /* non standard, see unsupported-embedded-subs-2.mp4 */ + { CODEC_ID_QCELP , 225 }, +- { CODEC_ID_AC3 , 226 }, +- { CODEC_ID_PCM_ALAW , 227 }, +- { CODEC_ID_PCM_MULAW , 228 }, +- { CODEC_ID_PCM_S16BE , 230 }, +- { CODEC_ID_H263 , 242 }, +- { CODEC_ID_H261 , 243 }, + { 0, 0 }, + }; + +@@ -174,6 +169,12 @@ + { CODEC_ID_NONE, 0 }, + }; + ++const AVCodecTag ff_codec_movsubtitle_tags[] = { ++ { CODEC_ID_MOV_TEXT, MKTAG('t', 'e', 'x', 't') }, ++ { CODEC_ID_MOV_TEXT, MKTAG('t', 'x', '3', 'g') }, ++ { CODEC_ID_NONE, 0 }, ++}; ++ + /* map numeric codes from mdhd atom to ISO 639 */ + /* cf. QTFileFormat.pdf p253, qtff.pdf p205 */ + /* http://developer.apple.com/documentation/mac/Text/Text-368.html */ +diff -u mplayer-1.0~rc2-12/libavformat/isom.h ffmpeg-free-0.svn20080206/libavformat/isom.h +--- mplayer-1.0~rc2-12/libavformat/isom.h 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/isom.h 2008-01-26 21:30:03.000000000 +0100 +@@ -30,6 +30,7 @@ + extern const AVCodecTag ff_mp4_obj_type[]; + extern const AVCodecTag codec_movvideo_tags[]; + extern const AVCodecTag codec_movaudio_tags[]; ++extern const AVCodecTag ff_codec_movsubtitle_tags[]; + + int ff_mov_iso639_to_lang(const char *lang, int mp4); + int ff_mov_lang_to_iso639(int code, char *to); +Only in mplayer-1.0~rc2-12/libavformat: libdc1394.c +diff -u mplayer-1.0~rc2-12/libavformat/libnut.c ffmpeg-free-0.svn20080206/libavformat/libnut.c +--- mplayer-1.0~rc2-12/libavformat/libnut.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/libnut.c 2007-11-21 08:41:00.000000000 +0100 +@@ -54,7 +54,7 @@ + + static int nut_write_header(AVFormatContext * avf) { + NUTContext * priv = avf->priv_data; +- ByteIOContext * bc = &avf->pb; ++ ByteIOContext * bc = avf->pb; + nut_muxer_opts_t mopts = { + .output = { + .priv = bc, +@@ -137,7 +137,7 @@ + } + + static int nut_write_trailer(AVFormatContext * avf) { +- ByteIOContext * bc = &avf->pb; ++ ByteIOContext * bc = avf->pb; + NUTContext * priv = avf->priv_data; + int i; + +@@ -151,7 +151,7 @@ + } + + AVOutputFormat libnut_muxer = { +- "nut", ++ "libnut", + "nut format", + "video/x-nut", + "nut", +@@ -187,7 +187,7 @@ + + static int nut_read_header(AVFormatContext * avf, AVFormatParameters * ap) { + NUTContext * priv = avf->priv_data; +- ByteIOContext * bc = &avf->pb; ++ ByteIOContext * bc = avf->pb; + nut_demuxer_opts_t dopts = { + .input = { + .priv = bc, +@@ -272,7 +272,7 @@ + if (pd.flags & NUT_FLAG_KEY) pkt->flags |= PKT_FLAG_KEY; + pkt->pts = pd.pts; + pkt->stream_index = pd.stream; +- pkt->pos = url_ftell(&avf->pb); ++ pkt->pos = url_ftell(avf->pb); + + ret = nut_read_frame(priv->nut, &pd.len, pkt->data); + +Only in ffmpeg-free-0.svn20080206/libavformat: lmlm4.c +diff -u mplayer-1.0~rc2-12/libavformat/Makefile ffmpeg-free-0.svn20080206/libavformat/Makefile +--- mplayer-1.0~rc2-12/libavformat/Makefile 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/Makefile 2008-01-29 10:25:49.000000000 +0100 +@@ -8,7 +8,7 @@ + + OBJS = allformats.o cutils.o os_support.o sdp.o utils.o + +-HEADERS = avformat.h avio.h rtp.h rtsp.h rtspcodes.h ++HEADERS = avformat.h avio.h rtsp.h rtspcodes.h + + # muxers/demuxers + OBJS-$(CONFIG_AAC_DEMUXER) += raw.o +@@ -21,7 +21,7 @@ + OBJS-$(CONFIG_AMR_MUXER) += amr.o + OBJS-$(CONFIG_APC_DEMUXER) += apc.o + OBJS-$(CONFIG_APE_DEMUXER) += ape.o +-OBJS-$(CONFIG_ASF_DEMUXER) += asf.o riff.o ++OBJS-$(CONFIG_ASF_DEMUXER) += asf.o asfcrypt.o riff.o + OBJS-$(CONFIG_ASF_MUXER) += asf-enc.o riff.o + OBJS-$(CONFIG_ASF_STREAM_MUXER) += asf-enc.o riff.o + OBJS-$(CONFIG_AU_DEMUXER) += au.o raw.o +@@ -29,18 +29,18 @@ + OBJS-$(CONFIG_AVI_DEMUXER) += avidec.o riff.o + OBJS-$(CONFIG_AVI_MUXER) += avienc.o riff.o + OBJS-$(CONFIG_AVISYNTH) += avisynth.o ++OBJS-$(CONFIG_AVM2_MUXER) += swf.o + OBJS-$(CONFIG_AVS_DEMUXER) += avs.o vocdec.o voc.o + OBJS-$(CONFIG_BETHSOFTVID_DEMUXER) += bethsoftvid.o +-OBJS-$(CONFIG_BKTR_DEMUXER) += bktr.o + OBJS-$(CONFIG_C93_DEMUXER) += c93.o vocdec.o voc.o +-OBJS-$(CONFIG_CRC_MUXER) += crc.o ++OBJS-$(CONFIG_CRC_MUXER) += crcenc.o + OBJS-$(CONFIG_DAUD_DEMUXER) += daud.o + OBJS-$(CONFIG_DSICIN_DEMUXER) += dsicin.o + OBJS-$(CONFIG_DTS_DEMUXER) += raw.o + OBJS-$(CONFIG_DV_DEMUXER) += dv.o + OBJS-$(CONFIG_DV_MUXER) += dvenc.o +-OBJS-$(CONFIG_DV1394_DEMUXER) += dv1394.o dv.o + OBJS-$(CONFIG_DXA_DEMUXER) += dxa.o riff.o ++OBJS-$(CONFIG_EA_CDATA_DEMUXER) += eacdata.o + OBJS-$(CONFIG_EA_DEMUXER) += electronicarts.o + OBJS-$(CONFIG_FFM_DEMUXER) += ffm.o + OBJS-$(CONFIG_FFM_MUXER) += ffm.o +@@ -50,7 +50,7 @@ + OBJS-$(CONFIG_FLV_DEMUXER) += flvdec.o + OBJS-$(CONFIG_FLV_MUXER) += flvenc.o + OBJS-$(CONFIG_FOURXM_DEMUXER) += 4xm.o +-OBJS-$(CONFIG_FRAMECRC_MUXER) += crc.o ++OBJS-$(CONFIG_FRAMECRC_MUXER) += framecrcenc.o + OBJS-$(CONFIG_GIF_MUXER) += gif.o + OBJS-$(CONFIG_GIF_DEMUXER) += gifdec.o + OBJS-$(CONFIG_GXF_DEMUXER) += gxf.o +@@ -68,23 +68,25 @@ + OBJS-$(CONFIG_IMAGE2PIPE_MUXER) += img2.o + OBJS-$(CONFIG_INGENIENT_DEMUXER) += raw.o + OBJS-$(CONFIG_IPMOVIE_DEMUXER) += ipmovie.o ++OBJS-$(CONFIG_LMLM4_DEMUXER) += lmlm4.o + OBJS-$(CONFIG_M4V_DEMUXER) += raw.o + OBJS-$(CONFIG_M4V_MUXER) += raw.o +-OBJS-$(CONFIG_MATROSKA_AUDIO_MUXER) += matroskaenc.o matroska.o riff.o ++OBJS-$(CONFIG_MATROSKA_AUDIO_MUXER) += matroskaenc.o matroska.o riff.o avc.o + OBJS-$(CONFIG_MATROSKA_DEMUXER) += matroskadec.o matroska.o riff.o +-OBJS-$(CONFIG_MATROSKA_MUXER) += matroskaenc.o matroska.o riff.o ++OBJS-$(CONFIG_MATROSKA_MUXER) += matroskaenc.o matroska.o riff.o avc.o + OBJS-$(CONFIG_MJPEG_DEMUXER) += raw.o + OBJS-$(CONFIG_MJPEG_MUXER) += raw.o + OBJS-$(CONFIG_MM_DEMUXER) += mm.o + OBJS-$(CONFIG_MMF_DEMUXER) += mmf.o raw.o + OBJS-$(CONFIG_MMF_MUXER) += mmf.o riff.o + OBJS-$(CONFIG_MOV_DEMUXER) += mov.o riff.o isom.o +-OBJS-$(CONFIG_MOV_MUXER) += movenc.o riff.o isom.o ++OBJS-$(CONFIG_MOV_MUXER) += movenc.o riff.o isom.o avc.o + OBJS-$(CONFIG_MP2_MUXER) += mp3.o + OBJS-$(CONFIG_MP3_DEMUXER) += mp3.o + OBJS-$(CONFIG_MP3_MUXER) += mp3.o +-OBJS-$(CONFIG_MP4_MUXER) += movenc.o riff.o isom.o ++OBJS-$(CONFIG_MP4_MUXER) += movenc.o riff.o isom.o avc.o + OBJS-$(CONFIG_MPC_DEMUXER) += mpc.o ++OBJS-$(CONFIG_MPC8_DEMUXER) += mpc8.o + OBJS-$(CONFIG_MPEG1SYSTEM_MUXER) += mpegenc.o + OBJS-$(CONFIG_MPEG1VCD_MUXER) += mpegenc.o + OBJS-$(CONFIG_MPEG2DVD_MUXER) += mpegenc.o +@@ -105,16 +107,31 @@ + OBJS-$(CONFIG_NUT_DEMUXER) += nutdec.o nut.o riff.o + OBJS-$(CONFIG_NUT_MUXER) += nutenc.o nut.o riff.o + OBJS-$(CONFIG_NUV_DEMUXER) += nuv.o riff.o +-OBJS-$(CONFIG_OGG_DEMUXER) += ogg2.o \ +- oggparsevorbis.o \ +- oggparsetheora.o \ ++OBJS-$(CONFIG_OGG_DEMUXER) += oggdec.o \ + oggparseflac.o \ + oggparseogm.o \ ++ oggparsetheora.o \ ++ oggparsevorbis.o \ + riff.o +-OBJS-$(CONFIG_OGG_MUXER) += ogg.o +-OBJS-$(CONFIG_OSS_DEMUXER) += audio.o +-OBJS-$(CONFIG_OSS_MUXER) += audio.o +-OBJS-$(CONFIG_PSP_MUXER) += movenc.o riff.o isom.o ++OBJS-$(CONFIG_OGG_MUXER) += oggenc.o ++OBJS-$(CONFIG_PCM_ALAW_DEMUXER) += raw.o ++OBJS-$(CONFIG_PCM_ALAW_MUXER) += raw.o ++OBJS-$(CONFIG_PCM_MULAW_DEMUXER) += raw.o ++OBJS-$(CONFIG_PCM_MULAW_MUXER) += raw.o ++OBJS-$(CONFIG_PCM_S16BE_DEMUXER) += raw.o ++OBJS-$(CONFIG_PCM_S16BE_MUXER) += raw.o ++OBJS-$(CONFIG_PCM_S16LE_DEMUXER) += raw.o ++OBJS-$(CONFIG_PCM_S16LE_MUXER) += raw.o ++OBJS-$(CONFIG_PCM_S8_DEMUXER) += raw.o ++OBJS-$(CONFIG_PCM_S8_MUXER) += raw.o ++OBJS-$(CONFIG_PCM_U16BE_DEMUXER) += raw.o ++OBJS-$(CONFIG_PCM_U16BE_MUXER) += raw.o ++OBJS-$(CONFIG_PCM_U16LE_DEMUXER) += raw.o ++OBJS-$(CONFIG_PCM_U16LE_MUXER) += raw.o ++OBJS-$(CONFIG_PCM_U8_DEMUXER) += raw.o ++OBJS-$(CONFIG_PCM_U8_MUXER) += raw.o ++OBJS-$(CONFIG_PSP_MUXER) += movenc.o riff.o isom.o avc.o ++OBJS-$(CONFIG_PVA_DEMUXER) += pva.o + OBJS-$(CONFIG_RAWVIDEO_DEMUXER) += raw.o + OBJS-$(CONFIG_RAWVIDEO_MUXER) += raw.o + OBJS-$(CONFIG_REDIR_DEMUXER) += rtsp.o +@@ -122,25 +139,30 @@ + OBJS-$(CONFIG_RM_MUXER) += rmenc.o + OBJS-$(CONFIG_ROQ_DEMUXER) += idroq.o + OBJS-$(CONFIG_ROQ_MUXER) += raw.o +-OBJS-$(CONFIG_RTP_MUXER) += rtp.o rtp_h264.o rtp_mpv.o rtp_aac.o ++OBJS-$(CONFIG_RTP_MUXER) += rtp.o \ ++ rtpenc.o \ ++ rtp_mpv.o \ ++ rtp_aac.o \ ++ rtpenc_h264.o \ ++ avc.o + OBJS-$(CONFIG_RTSP_DEMUXER) += rtsp.o +-OBJS-$(CONFIG_SDP_DEMUXER) += rtsp.o ++OBJS-$(CONFIG_SDP_DEMUXER) += rtsp.o rtp.o rtpdec.o rtp_h264.o + OBJS-$(CONFIG_SEGAFILM_DEMUXER) += segafilm.o + OBJS-$(CONFIG_SHORTEN_DEMUXER) += raw.o ++OBJS-$(CONFIG_SIFF_DEMUXER) += siff.o + OBJS-$(CONFIG_SMACKER_DEMUXER) += smacker.o + OBJS-$(CONFIG_SOL_DEMUXER) += sol.o raw.o + OBJS-$(CONFIG_STR_DEMUXER) += psxstr.o + OBJS-$(CONFIG_SWF_DEMUXER) += swf.o + OBJS-$(CONFIG_SWF_MUXER) += swf.o +-OBJS-$(CONFIG_TG2_MUXER) += movenc.o riff.o isom.o +-OBJS-$(CONFIG_TGP_MUXER) += movenc.o riff.o isom.o ++OBJS-$(CONFIG_TG2_MUXER) += movenc.o riff.o isom.o avc.o ++OBJS-$(CONFIG_TGP_MUXER) += movenc.o riff.o isom.o avc.o + OBJS-$(CONFIG_THP_DEMUXER) += thp.o + OBJS-$(CONFIG_TIERTEXSEQ_DEMUXER) += tiertexseq.o + OBJS-$(CONFIG_TTA_DEMUXER) += tta.o + OBJS-$(CONFIG_TXD_DEMUXER) += txd.o +-OBJS-$(CONFIG_V4L2_DEMUXER) += v4l2.o +-OBJS-$(CONFIG_V4L_DEMUXER) += v4l.o + OBJS-$(CONFIG_VC1_DEMUXER) += raw.o ++OBJS-$(CONFIG_VC1T_DEMUXER) += vc1test.o + OBJS-$(CONFIG_VMD_DEMUXER) += sierravmd.o + OBJS-$(CONFIG_VOC_DEMUXER) += vocdec.o voc.o + OBJS-$(CONFIG_VOC_MUXER) += vocenc.o voc.o +@@ -150,22 +172,17 @@ + OBJS-$(CONFIG_WSAUD_DEMUXER) += westwood.o + OBJS-$(CONFIG_WSVQA_DEMUXER) += westwood.o + OBJS-$(CONFIG_WV_DEMUXER) += wv.o +-OBJS-$(CONFIG_X11_GRAB_DEVICE_DEMUXER) += x11grab.o + OBJS-$(CONFIG_YUV4MPEGPIPE_MUXER) += yuv4mpeg.o + OBJS-$(CONFIG_YUV4MPEGPIPE_DEMUXER) += yuv4mpeg.o + + # external libraries +-OBJS-$(CONFIG_LIBDC1394_DEMUXER) += libdc1394.o + OBJS-$(CONFIG_LIBNUT_DEMUXER) += libnut.o riff.o + OBJS-$(CONFIG_LIBNUT_MUXER) += libnut.o riff.o + + OBJS-$(CONFIG_VHOOK) += framehook.o + +-EXTRALIBS := -L$(BUILD_ROOT)/libavutil -lavutil$(BUILDSUF) \ +- -lavcodec$(BUILDSUF) -L$(BUILD_ROOT)/libavcodec $(EXTRALIBS) +- +-CPPOBJS-$(CONFIG_AUDIO_BEOS_DEMUXER) += beosaudio.o +-CPPOBJS-$(CONFIG_AUDIO_BEOS_MUXER) += beosaudio.o ++EXTRALIBS := -L$(BUILD_ROOT)/libavcodec -lavcodec$(BUILDSUF) \ ++ -L$(BUILD_ROOT)/libavutil -lavutil$(BUILDSUF) $(EXTRALIBS) + + # protocols I/O + OBJS+= avio.o aviobuf.o +diff -u mplayer-1.0~rc2-12/libavformat/matroska.c ffmpeg-free-0.svn20080206/libavformat/matroska.c +--- mplayer-1.0~rc2-12/libavformat/matroska.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/matroska.c 2008-01-27 16:43:17.000000000 +0100 +@@ -21,7 +21,7 @@ + + #include "matroska.h" + +-CodecTags ff_mkv_codec_tags[]={ ++const CodecTags ff_mkv_codec_tags[]={ + // {"V_MS/VFW/FOURCC" , CODEC_ID_NONE}, + {"V_UNCOMPRESSED" , CODEC_ID_RAWVIDEO}, + {"V_MPEG4/ISO/ASP" , CODEC_ID_MPEG4}, +@@ -62,12 +62,24 @@ + + {"S_TEXT/UTF8" , CODEC_ID_TEXT}, + {"S_TEXT/ASCII" , CODEC_ID_TEXT}, +- {"S_TEXT/ASS" , CODEC_ID_TEXT}, +- {"S_TEXT/SSA" , CODEC_ID_TEXT}, +- {"S_ASS" , CODEC_ID_TEXT}, +- {"S_SSA" , CODEC_ID_TEXT}, ++ {"S_TEXT/ASS" , CODEC_ID_SSA}, ++ {"S_TEXT/SSA" , CODEC_ID_SSA}, ++ {"S_ASS" , CODEC_ID_SSA}, ++ {"S_SSA" , CODEC_ID_SSA}, + {"S_VOBSUB" , CODEC_ID_DVD_SUBTITLE}, + +- {NULL , CODEC_ID_NONE} ++ {"" , CODEC_ID_NONE} + /* TODO: AC3-9/10 (?), Real, Musepack, Quicktime */ + }; ++ ++const CodecMime ff_mkv_mime_tags[] = { ++ {"text/plain" , CODEC_ID_TEXT}, ++ {"image/gif" , CODEC_ID_GIF}, ++ {"image/jpeg" , CODEC_ID_MJPEG}, ++ {"image/png" , CODEC_ID_PNG}, ++ {"image/tiff" , CODEC_ID_TIFF}, ++ {"application/x-truetype-font", CODEC_ID_TTF}, ++ {"application/x-font" , CODEC_ID_TTF}, ++ ++ {"" , CODEC_ID_NONE} ++}; +diff -u mplayer-1.0~rc2-12/libavformat/matroskadec.c ffmpeg-free-0.svn20080206/libavformat/matroskadec.c +--- mplayer-1.0~rc2-12/libavformat/matroskadec.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/matroskadec.c 2008-02-04 02:04:27.000000000 +0100 +@@ -94,8 +94,6 @@ + + typedef struct MatroskaSubtitleTrack { + MatroskaTrack track; +- +- int ass; + //.. + } MatroskaSubtitleTrack; + +@@ -176,7 +174,7 @@ + static int + ebml_read_element_level_up (MatroskaDemuxContext *matroska) + { +- ByteIOContext *pb = &matroska->ctx->pb; ++ ByteIOContext *pb = matroska->ctx->pb; + offset_t pos = url_ftell(pb); + int num = 0; + +@@ -208,7 +206,7 @@ + int max_size, + uint64_t *number) + { +- ByteIOContext *pb = &matroska->ctx->pb; ++ ByteIOContext *pb = matroska->ctx->pb; + int len_mask = 0x80, read = 1, n = 1; + int64_t total = 0; + +@@ -325,7 +323,7 @@ + ebml_read_seek (MatroskaDemuxContext *matroska, + offset_t offset) + { +- ByteIOContext *pb = &matroska->ctx->pb; ++ ByteIOContext *pb = matroska->ctx->pb; + + /* clear ID cache, if any */ + matroska->peek_id = 0; +@@ -341,7 +339,7 @@ + static int + ebml_read_skip (MatroskaDemuxContext *matroska) + { +- ByteIOContext *pb = &matroska->ctx->pb; ++ ByteIOContext *pb = matroska->ctx->pb; + uint32_t id; + uint64_t length; + int res; +@@ -365,7 +363,7 @@ + uint32_t *id, + uint64_t *num) + { +- ByteIOContext *pb = &matroska->ctx->pb; ++ ByteIOContext *pb = matroska->ctx->pb; + int n = 0, size, res; + uint64_t rlength; + +@@ -399,7 +397,7 @@ + uint32_t *id, + int64_t *num) + { +- ByteIOContext *pb = &matroska->ctx->pb; ++ ByteIOContext *pb = matroska->ctx->pb; + int size, n = 1, negative = 0, res; + uint64_t rlength; + +@@ -438,7 +436,7 @@ + uint32_t *id, + double *num) + { +- ByteIOContext *pb = &matroska->ctx->pb; ++ ByteIOContext *pb = matroska->ctx->pb; + int size, res; + uint64_t rlength; + +@@ -472,7 +470,7 @@ + uint32_t *id, + char **str) + { +- ByteIOContext *pb = &matroska->ctx->pb; ++ ByteIOContext *pb = matroska->ctx->pb; + int size, res; + uint64_t rlength; + +@@ -534,7 +532,7 @@ + ebml_read_master (MatroskaDemuxContext *matroska, + uint32_t *id) + { +- ByteIOContext *pb = &matroska->ctx->pb; ++ ByteIOContext *pb = matroska->ctx->pb; + uint64_t length; + MatroskaLevel *level; + int res; +@@ -569,7 +567,7 @@ + uint8_t **binary, + int *size) + { +- ByteIOContext *pb = &matroska->ctx->pb; ++ ByteIOContext *pb = matroska->ctx->pb; + uint64_t rlength; + int res; + +@@ -846,6 +844,24 @@ + matroska->num_packets++; + } + ++/* ++ * Free all packets in our internal queue. ++ */ ++static void ++matroska_clear_queue (MatroskaDemuxContext *matroska) ++{ ++ if (matroska->packets) { ++ int n; ++ for (n = 0; n < matroska->num_packets; n++) { ++ av_free_packet(matroska->packets[n]); ++ av_free(matroska->packets[n]); ++ } ++ av_free(matroska->packets); ++ matroska->packets = NULL; ++ matroska->num_packets = 0; ++ } ++} ++ + + /* + * Autodetecting... +@@ -1199,9 +1215,9 @@ + break; + } + +- /* colourspace (only matters for raw video) ++ /* colorspace (only matters for raw video) + * fourcc */ +- case MATROSKA_ID_VIDEOCOLOURSPACE: { ++ case MATROSKA_ID_VIDEOCOLORSPACE: { + uint64_t num; + if ((res = ebml_read_uint(matroska, &id, + &num)) < 0) +@@ -1748,7 +1764,7 @@ + + /* remember the peeked ID and the current position */ + peek_id_cache = matroska->peek_id; +- before_pos = url_ftell(&matroska->ctx->pb); ++ before_pos = url_ftell(matroska->ctx->pb); + + /* seek */ + if ((res = ebml_read_seek(matroska, seek_pos + +@@ -1788,14 +1804,14 @@ + switch (id) { + case MATROSKA_ID_CUES: + if (!(res = matroska_parse_index(matroska)) || +- url_feof(&matroska->ctx->pb)) { ++ url_feof(matroska->ctx->pb)) { + matroska->index_parsed = 1; + res = 0; + } + break; + case MATROSKA_ID_TAGS: + if (!(res = matroska_parse_metadata(matroska)) || +- url_feof(&matroska->ctx->pb)) { ++ url_feof(matroska->ctx->pb)) { + matroska->metadata_parsed = 1; + res = 0; + } +@@ -1849,6 +1865,119 @@ + return res; + } + ++static int ++matroska_parse_attachments(AVFormatContext *s) ++{ ++ MatroskaDemuxContext *matroska = s->priv_data; ++ int res = 0; ++ uint32_t id; ++ ++ av_log(matroska->ctx, AV_LOG_DEBUG, "parsing attachments...\n"); ++ ++ while (res == 0) { ++ if (!(id = ebml_peek_id(matroska, &matroska->level_up))) { ++ res = AVERROR(EIO); ++ break; ++ } else if (matroska->level_up) { ++ matroska->level_up--; ++ break; ++ } ++ ++ switch (id) { ++ case MATROSKA_ID_ATTACHEDFILE: { ++ char* name = NULL; ++ char* mime = NULL; ++ uint8_t* data = NULL; ++ int i, data_size = 0; ++ AVStream *st; ++ ++ if ((res = ebml_read_master(matroska, &id)) < 0) ++ break; ++ ++ while (res == 0) { ++ if (!(id = ebml_peek_id(matroska, &matroska->level_up))) { ++ res = AVERROR(EIO); ++ break; ++ } else if (matroska->level_up) { ++ matroska->level_up--; ++ break; ++ } ++ ++ switch (id) { ++ case MATROSKA_ID_FILENAME: ++ res = ebml_read_utf8 (matroska, &id, &name); ++ break; ++ ++ case MATROSKA_ID_FILEMIMETYPE: ++ res = ebml_read_ascii (matroska, &id, &mime); ++ break; ++ ++ case MATROSKA_ID_FILEDATA: ++ res = ebml_read_binary(matroska, &id, &data, &data_size); ++ break; ++ ++ default: ++ av_log(matroska->ctx, AV_LOG_INFO, ++ "Unknown attachedfile ID 0x%x\n", id); ++ case EBML_ID_VOID: ++ res = ebml_read_skip(matroska); ++ break; ++ } ++ ++ if (matroska->level_up) { ++ matroska->level_up--; ++ break; ++ } ++ } ++ ++ if (!(name && mime && data && data_size > 0)) { ++ av_log(matroska->ctx, AV_LOG_ERROR, "incomplete attachment\n"); ++ break; ++ } ++ ++ st = av_new_stream(s, matroska->num_streams++); ++ if (st == NULL) ++ return AVERROR(ENOMEM); ++ st->filename = av_strdup(name); ++ st->codec->codec_id = CODEC_ID_NONE; ++ st->codec->codec_type = CODEC_TYPE_ATTACHMENT; ++ st->codec->extradata = av_malloc(data_size); ++ if(st->codec->extradata == NULL) ++ return AVERROR(ENOMEM); ++ st->codec->extradata_size = data_size; ++ memcpy(st->codec->extradata, data, data_size); ++ ++ for (i=0; ff_mkv_mime_tags[i].id != CODEC_ID_NONE; i++) { ++ if (!strncmp(ff_mkv_mime_tags[i].str, mime, ++ strlen(ff_mkv_mime_tags[i].str))) { ++ st->codec->codec_id = ff_mkv_mime_tags[i].id; ++ break; ++ } ++ } ++ ++ av_log(matroska->ctx, AV_LOG_DEBUG, "new attachment: %s, %s, size %d \n", name, mime, data_size); ++ break; ++ } ++ ++ default: ++ av_log(matroska->ctx, AV_LOG_INFO, ++ "Unknown attachments ID 0x%x\n", id); ++ /* fall-through */ ++ ++ case EBML_ID_VOID: ++ res = ebml_read_skip(matroska); ++ break; ++ } ++ ++ if (matroska->level_up) { ++ matroska->level_up--; ++ break; ++ } ++ } ++ ++ return res; ++} ++ + #define ARRAY_SIZE(x) (sizeof(x)/sizeof(*x)) + + static int +@@ -1931,7 +2060,7 @@ + * after the segment ID/length. */ + if ((res = ebml_read_master(matroska, &id)) < 0) + return res; +- matroska->segment_start = url_ftell(&s->pb); ++ matroska->segment_start = url_ftell(s->pb); + + matroska->time_scale = 1000000; + /* we've found our segment, start reading the different contents in here */ +@@ -1991,6 +2120,13 @@ + break; + } + ++ case MATROSKA_ID_ATTACHMENTS: { ++ if ((res = ebml_read_master(matroska, &id)) < 0) ++ break; ++ res = matroska_parse_attachments(s); ++ break; ++ } ++ + case MATROSKA_ID_CLUSTER: { + /* Do not read the master - this will be done in the next + * call to matroska_read_packet. */ +@@ -2032,7 +2168,7 @@ + if (track->codec_id == NULL) + continue; + +- for(j=0; ff_mkv_codec_tags[j].str; j++){ ++ for(j=0; ff_mkv_codec_tags[j].id != CODEC_ID_NONE; j++){ + if(!strncmp(ff_mkv_codec_tags[j].str, track->codec_id, + strlen(ff_mkv_codec_tags[j].str))){ + codec_id= ff_mkv_codec_tags[j].id; +@@ -2098,7 +2234,7 @@ + return AVERROR(ENOMEM); + init_put_byte(&b, extradata, extradata_size, 1, + NULL, NULL, NULL, NULL); +- put_buffer(&b, (uint8_t *) "TTA1", 4); ++ put_buffer(&b, "TTA1", 4); + put_le16(&b, 1); + put_le16(&b, audiotrack->channels); + put_le16(&b, audiotrack->bitdepth); +@@ -2110,7 +2246,6 @@ + codec_id == CODEC_ID_RV30 || codec_id == CODEC_ID_RV40) { + extradata_offset = 26; + track->codec_priv_size -= extradata_offset; +- track->flags |= MATROSKA_TRACK_REAL_V; + } + + else if (codec_id == CODEC_ID_RA_144) { +@@ -2144,15 +2279,6 @@ + } + } + +- else if (codec_id == CODEC_ID_TEXT) { +- MatroskaSubtitleTrack *subtrack=(MatroskaSubtitleTrack *)track; +- if (!strcmp(track->codec_id, "S_TEXT/ASS") || +- !strcmp(track->codec_id, "S_TEXT/SSA") || +- !strcmp(track->codec_id, "S_ASS") || +- !strcmp(track->codec_id, "S_SSA")) +- subtrack->ass = 1; +- } +- + if (codec_id == CODEC_ID_NONE) { + av_log(matroska->ctx, AV_LOG_INFO, + "Unknown/unsupported CodecID %s.\n", +@@ -2237,12 +2363,6 @@ + return res; + } + +-static inline int +-rv_offset(uint8_t *data, int slice, int slices) +-{ +- return AV_RL32(data+8*slice+4) + 8*slices; +-} +- + static int + matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data, int size, + int64_t pos, uint64_t cluster_time, uint64_t duration, +@@ -2275,8 +2395,10 @@ + av_free(origdata); + return res; + } +- if (matroska->tracks[track]->stream_index < 0) ++ if (matroska->tracks[track]->stream_index < 0) { ++ av_free(origdata); + return res; ++ } + st = matroska->ctx->streams[matroska->tracks[track]->stream_index]; + if (st->discard >= AVDISCARD_ALL) { + av_free(origdata); +@@ -2294,8 +2416,10 @@ + is_keyframe = flags & 0x80 ? PKT_FLAG_KEY : 0; + + if (matroska->skip_to_keyframe) { +- if (!is_keyframe || st != matroska->skip_to_stream) ++ if (!is_keyframe || st != matroska->skip_to_stream) { ++ av_free(origdata); + return res; ++ } + matroska->skip_to_keyframe = 0; + } + +@@ -2379,7 +2503,6 @@ + } + + if (res == 0) { +- int real_v = matroska->tracks[track]->flags & MATROSKA_TRACK_REAL_V; + uint64_t timecode = AV_NOPTS_VALUE; + + if (cluster_time != (uint64_t)-1 +@@ -2387,91 +2510,66 @@ + timecode = cluster_time + block_time; + + for (n = 0; n < laces; n++) { +- int slice, slices = 1; +- +- if (real_v) { +- slices = *data++ + 1; +- lace_size[n]--; +- } +- +- for (slice=0; slicecodec->codec_id == CODEC_ID_RA_288 || +- st->codec->codec_id == CODEC_ID_COOK || +- st->codec->codec_id == CODEC_ID_ATRAC3) { +- MatroskaAudioTrack *audiotrack = (MatroskaAudioTrack *)matroska->tracks[track]; +- int a = st->codec->block_align; +- int sps = audiotrack->sub_packet_size; +- int cfs = audiotrack->coded_framesize; +- int h = audiotrack->sub_packet_h; +- int y = audiotrack->sub_packet_cnt; +- int w = audiotrack->frame_size; +- int x; +- +- if (!audiotrack->pkt_cnt) { +- if (st->codec->codec_id == CODEC_ID_RA_288) +- for (x=0; xbuf+x*2*w+y*cfs, +- data+x*cfs, cfs); +- else +- for (x=0; xbuf+sps*(h*x+((h+1)/2)*(y&1)+(y>>1)), data+x*sps, sps); +- +- if (++audiotrack->sub_packet_cnt >= h) { +- audiotrack->sub_packet_cnt = 0; +- audiotrack->pkt_cnt = h*w / a; +- } +- } +- while (audiotrack->pkt_cnt) { +- pkt = av_mallocz(sizeof(AVPacket)); +- av_new_packet(pkt, a); +- memcpy(pkt->data, audiotrack->buf +- + a * (h*w / a - audiotrack->pkt_cnt--), a); +- pkt->pos = pos; +- pkt->stream_index = matroska->tracks[track]->stream_index; +- matroska_queue_packet(matroska, pkt); +- } +- } else { +- int offset = 0; +- +- if (st->codec->codec_id == CODEC_ID_TEXT +- && ((MatroskaSubtitleTrack *)(matroska->tracks[track]))->ass) { +- int i; +- for (i=0; i<8 && data[slice_offset+offset]; offset++) +- if (data[slice_offset+offset] == ',') +- i++; ++ if (st->codec->codec_id == CODEC_ID_RA_288 || ++ st->codec->codec_id == CODEC_ID_COOK || ++ st->codec->codec_id == CODEC_ID_ATRAC3) { ++ MatroskaAudioTrack *audiotrack = (MatroskaAudioTrack *)matroska->tracks[track]; ++ int a = st->codec->block_align; ++ int sps = audiotrack->sub_packet_size; ++ int cfs = audiotrack->coded_framesize; ++ int h = audiotrack->sub_packet_h; ++ int y = audiotrack->sub_packet_cnt; ++ int w = audiotrack->frame_size; ++ int x; ++ ++ if (!audiotrack->pkt_cnt) { ++ if (st->codec->codec_id == CODEC_ID_RA_288) ++ for (x=0; xbuf+x*2*w+y*cfs, ++ data+x*cfs, cfs); ++ else ++ for (x=0; xbuf+sps*(h*x+((h+1)/2)*(y&1)+(y>>1)), data+x*sps, sps); ++ ++ if (++audiotrack->sub_packet_cnt >= h) { ++ audiotrack->sub_packet_cnt = 0; ++ audiotrack->pkt_cnt = h*w / a; + } +- ++ } ++ while (audiotrack->pkt_cnt) { + pkt = av_mallocz(sizeof(AVPacket)); +- /* XXX: prevent data copy... */ +- if (av_new_packet(pkt, slice_size-offset) < 0) { +- res = AVERROR(ENOMEM); +- n = laces-1; +- break; +- } +- memcpy (pkt->data, data+slice_offset+offset, slice_size-offset); +- +- if (n == 0) +- pkt->flags = is_keyframe; +- pkt->stream_index = matroska->tracks[track]->stream_index; +- +- pkt->pts = timecode; ++ av_new_packet(pkt, a); ++ memcpy(pkt->data, audiotrack->buf ++ + a * (h*w / a - audiotrack->pkt_cnt--), a); + pkt->pos = pos; +- pkt->duration = duration; +- ++ pkt->stream_index = matroska->tracks[track]->stream_index; + matroska_queue_packet(matroska, pkt); + } ++ } else { ++ int offset = 0; ++ ++ pkt = av_mallocz(sizeof(AVPacket)); ++ /* XXX: prevent data copy... */ ++ if (av_new_packet(pkt, lace_size[n]-offset) < 0) { ++ res = AVERROR(ENOMEM); ++ n = laces-1; ++ break; ++ } ++ memcpy (pkt->data, data+offset, lace_size[n]-offset); ++ ++ if (n == 0) ++ pkt->flags = is_keyframe; ++ pkt->stream_index = matroska->tracks[track]->stream_index; + +- if (timecode != AV_NOPTS_VALUE) +- timecode = duration ? timecode + duration : AV_NOPTS_VALUE; ++ pkt->pts = timecode; ++ pkt->pos = pos; ++ pkt->duration = duration; ++ ++ matroska_queue_packet(matroska, pkt); + } ++ ++ if (timecode != AV_NOPTS_VALUE) ++ timecode = duration ? timecode + duration : AV_NOPTS_VALUE; + data += lace_size[n]; + } + } +@@ -2510,7 +2608,7 @@ + * of the harder things, so this code is a bit complicated. + * See http://www.matroska.org/ for documentation. */ + case MATROSKA_ID_BLOCK: { +- pos = url_ftell(&matroska->ctx->pb); ++ pos = url_ftell(matroska->ctx->pb); + res = ebml_read_binary(matroska, &id, &data, &size); + break; + } +@@ -2572,7 +2670,7 @@ + int size; + + av_log(matroska->ctx, AV_LOG_DEBUG, +- "parsing cluster at %"PRId64"\n", url_ftell(&matroska->ctx->pb)); ++ "parsing cluster at %"PRId64"\n", url_ftell(matroska->ctx->pb)); + + while (res == 0) { + if (!(id = ebml_peek_id(matroska, &matroska->level_up))) { +@@ -2601,7 +2699,7 @@ + break; + + case MATROSKA_ID_SIMPLEBLOCK: +- pos = url_ftell(&matroska->ctx->pb); ++ pos = url_ftell(matroska->ctx->pb); + res = ebml_read_binary(matroska, &id, &data, &size); + if (res == 0) + res = matroska_parse_block(matroska, data, size, pos, +@@ -2692,11 +2790,12 @@ + if (index < 0) + return 0; + ++ matroska_clear_queue(matroska); ++ + /* do the seek */ +- url_fseek(&s->pb, st->index_entries[index].pos, SEEK_SET); ++ url_fseek(s->pb, st->index_entries[index].pos, SEEK_SET); + matroska->skip_to_keyframe = !(flags & AVSEEK_FLAG_ANY); + matroska->skip_to_stream = st; +- matroska->num_packets = 0; + matroska->peek_id = 0; + return 0; + } +@@ -2711,13 +2810,7 @@ + av_free(matroska->muxing_app); + av_free(matroska->index); + +- if (matroska->packets != NULL) { +- for (n = 0; n < matroska->num_packets; n++) { +- av_free_packet(matroska->packets[n]); +- av_free(matroska->packets[n]); +- } +- av_free(matroska->packets); +- } ++ matroska_clear_queue(matroska); + + for (n = 0; n < matroska->num_tracks; n++) { + MatroskaTrack *track = matroska->tracks[n]; +diff -u mplayer-1.0~rc2-12/libavformat/matroskaenc.c ffmpeg-free-0.svn20080206/libavformat/matroskaenc.c +--- mplayer-1.0~rc2-12/libavformat/matroskaenc.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/matroskaenc.c 2008-01-12 01:15:05.000000000 +0100 +@@ -24,6 +24,7 @@ + #include "riff.h" + #include "xiph.h" + #include "matroska.h" ++#include "avc.h" + + typedef struct ebml_master { + offset_t pos; ///< absolute offset in the file where the master's elements start +@@ -196,7 +197,8 @@ + put_ebml_num(pb, size-1, 0); + else + put_ebml_num(pb, size-9, 8); +- url_fseek(pb, currentpos + size, SEEK_SET); ++ while(url_ftell(pb) < currentpos + size) ++ put_byte(pb, 0); + } + + static ebml_master start_ebml_master(ByteIOContext *pb, unsigned int elementid, uint64_t expectedsize) +@@ -466,19 +468,23 @@ + + static int mkv_write_codecprivate(AVFormatContext *s, ByteIOContext *pb, AVCodecContext *codec, int native_id) + { +- ByteIOContext dyn_cp; ++ ByteIOContext *dyn_cp; + uint8_t *codecpriv; +- int ret = 0, codecpriv_size; ++ int ret, codecpriv_size; + +- url_open_dyn_buf(&dyn_cp); ++ ret = url_open_dyn_buf(&dyn_cp); ++ if(ret < 0) ++ return ret; + + if (native_id) { + if (codec->codec_id == CODEC_ID_VORBIS || codec->codec_id == CODEC_ID_THEORA) +- ret = put_xiph_codecpriv(s, &dyn_cp, codec); ++ ret = put_xiph_codecpriv(s, dyn_cp, codec); + else if (codec->codec_id == CODEC_ID_FLAC) +- ret = put_flac_codecpriv(s, &dyn_cp, codec); ++ ret = put_flac_codecpriv(s, dyn_cp, codec); ++ else if (codec->codec_id == CODEC_ID_H264) ++ ret = ff_isom_write_avcc(dyn_cp, codec->extradata, codec->extradata_size); + else if (codec->extradata_size) +- put_buffer(&dyn_cp, codec->extradata, codec->extradata_size); ++ put_buffer(dyn_cp, codec->extradata, codec->extradata_size); + } else if (codec->codec_type == CODEC_TYPE_VIDEO) { + if (!codec->codec_tag) + codec->codec_tag = codec_get_tag(codec_bmp_tags, codec->codec_id); +@@ -487,7 +493,7 @@ + ret = -1; + } + +- put_bmp_header(&dyn_cp, codec, codec_bmp_tags, 0); ++ put_bmp_header(dyn_cp, codec, codec_bmp_tags, 0); + + } else if (codec->codec_type == CODEC_TYPE_AUDIO) { + if (!codec->codec_tag) +@@ -497,10 +503,10 @@ + ret = -1; + } + +- put_wav_header(&dyn_cp, codec); ++ put_wav_header(dyn_cp, codec); + } + +- codecpriv_size = url_close_dyn_buf(&dyn_cp, &codecpriv); ++ codecpriv_size = url_close_dyn_buf(dyn_cp, &codecpriv); + if (codecpriv_size) + put_ebml_binary(pb, MATROSKA_ID_CODECPRIVATE, codecpriv, codecpriv_size); + av_free(codecpriv); +@@ -510,7 +516,7 @@ + static int mkv_write_tracks(AVFormatContext *s) + { + MatroskaMuxContext *mkv = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + ebml_master tracks; + int i, j, ret; + +@@ -613,7 +619,7 @@ + static int mkv_write_header(AVFormatContext *s) + { + MatroskaMuxContext *mkv = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + ebml_master ebml_header, segment_info; + int ret; + +@@ -703,7 +709,7 @@ + static void mkv_write_block(AVFormatContext *s, unsigned int blockid, AVPacket *pkt, int flags) + { + MatroskaMuxContext *mkv = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + + av_log(s, AV_LOG_DEBUG, "Writing block at offset %" PRIu64 ", size %d, " + "pts %" PRId64 ", dts %" PRId64 ", duration %d, flags %d\n", +@@ -719,7 +725,7 @@ + static int mkv_write_packet(AVFormatContext *s, AVPacket *pkt) + { + MatroskaMuxContext *mkv = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + AVCodecContext *codec = s->streams[pkt->stream_index]->codec; + int keyframe = !!(pkt->flags & PKT_FLAG_KEY); + int ret; +@@ -740,6 +746,16 @@ + av_md5_update(mkv->md5_ctx, pkt->data, FFMIN(200, pkt->size)); + } + ++ if (codec->codec_id == CODEC_ID_H264 && ++ codec->extradata_size > 0 && AV_RB32(codec->extradata) == 0x00000001) { ++ /* from x264 or from bytestream h264 */ ++ /* nal reformating needed */ ++ int ret = ff_avc_parse_nal_units(pkt->data, &pkt->data, &pkt->size); ++ if (ret < 0) ++ return ret; ++ assert(pkt->size); ++ } ++ + if (codec->codec_type != CODEC_TYPE_SUBTITLE) { + mkv_write_block(s, MATROSKA_ID_SIMPLEBLOCK, pkt, keyframe << 7); + } else { +@@ -761,7 +777,7 @@ + static int mkv_write_trailer(AVFormatContext *s) + { + MatroskaMuxContext *mkv = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + offset_t currentpos, second_seekhead, cuespos; + int ret; + +diff -u mplayer-1.0~rc2-12/libavformat/matroska.h ffmpeg-free-0.svn20080206/libavformat/matroska.h +--- mplayer-1.0~rc2-12/libavformat/matroska.h 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/matroska.h 2008-01-27 16:43:17.000000000 +0100 +@@ -19,8 +19,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef MATROSKA_H +-#define MATROSKA_H ++#ifndef FFMPEG_MATROSKA_H ++#define FFMPEG_MATROSKA_H + + #include "avcodec.h" + +@@ -55,6 +55,7 @@ + #define MATROSKA_ID_CUES 0x1C53BB6B + #define MATROSKA_ID_TAGS 0x1254C367 + #define MATROSKA_ID_SEEKHEAD 0x114D9B74 ++#define MATROSKA_ID_ATTACHMENTS 0x1941A469 + #define MATROSKA_ID_CLUSTER 0x1F43B675 + + /* IDs in the info master */ +@@ -98,7 +99,7 @@ + #define MATROSKA_ID_VIDEOFLAGINTERLACED 0x9A + #define MATROSKA_ID_VIDEOSTEREOMODE 0x53B9 + #define MATROSKA_ID_VIDEOASPECTRATIO 0x54B3 +-#define MATROSKA_ID_VIDEOCOLOURSPACE 0x2EB524 ++#define MATROSKA_ID_VIDEOCOLORSPACE 0x2EB524 + + /* IDs in the trackaudio master */ + #define MATROSKA_ID_AUDIOSAMPLINGFREQ 0xB5 +@@ -138,6 +139,13 @@ + #define MATROSKA_ID_BLOCKDURATION 0x9B + #define MATROSKA_ID_BLOCKREFERENCE 0xFB + ++/* IDs in the attachments master */ ++#define MATROSKA_ID_ATTACHEDFILE 0x61A7 ++#define MATROSKA_ID_FILENAME 0x466E ++#define MATROSKA_ID_FILEMIMETYPE 0x4660 ++#define MATROSKA_ID_FILEDATA 0x465C ++#define MATROSKA_ID_FILEUID 0x46AE ++ + typedef enum { + MATROSKA_TRACK_TYPE_VIDEO = 0x1, + MATROSKA_TRACK_TYPE_AUDIO = 0x2, +@@ -169,7 +177,6 @@ + MATROSKA_TRACK_ENABLED = (1<<0), + MATROSKA_TRACK_DEFAULT = (1<<1), + MATROSKA_TRACK_LACING = (1<<2), +- MATROSKA_TRACK_REAL_V = (1<<4), + MATROSKA_TRACK_SHIFT = (1<<16) + } MatroskaTrackFlags; + +@@ -182,16 +189,22 @@ + */ + + typedef struct CodecTags{ +- const char *str; ++ char str[16]; + enum CodecID id; + }CodecTags; + ++typedef struct CodecMime{ ++ char str[32]; ++ enum CodecID id; ++}CodecMime; ++ + #define MATROSKA_CODEC_ID_VIDEO_VFW_FOURCC "V_MS/VFW/FOURCC" + #define MATROSKA_CODEC_ID_AUDIO_ACM "A_MS/ACM" + + /* max. depth in the EBML tree structure */ + #define EBML_MAX_DEPTH 16 + +-extern CodecTags ff_mkv_codec_tags[]; ++extern const CodecTags ff_mkv_codec_tags[]; ++extern const CodecMime ff_mkv_mime_tags[]; + +-#endif /* MATROSKA_H */ ++#endif /* FFMPEG_MATROSKA_H */ +diff -u mplayer-1.0~rc2-12/libavformat/mm.c ffmpeg-free-0.svn20080206/libavformat/mm.c +--- mplayer-1.0~rc2-12/libavformat/mm.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/mm.c 2007-11-21 08:41:00.000000000 +0100 +@@ -72,7 +72,7 @@ + AVFormatParameters *ap) + { + MmDemuxContext *mm = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + AVStream *st; + + unsigned int type, length; +@@ -127,7 +127,7 @@ + AVPacket *pkt) + { + MmDemuxContext *mm = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + unsigned char preamble[MM_PREAMBLE_SIZE]; + unsigned char pal[MM_PALETTE_SIZE]; + unsigned int type, length; +@@ -178,7 +178,7 @@ + return 0; + + case MM_TYPE_AUDIO : +- if (av_get_packet(&s->pb, pkt, length)<0) ++ if (av_get_packet(s->pb, pkt, length)<0) + return AVERROR(ENOMEM); + pkt->size = length; + pkt->stream_index = 1; +diff -u mplayer-1.0~rc2-12/libavformat/mmf.c ffmpeg-free-0.svn20080206/libavformat/mmf.c +--- mplayer-1.0~rc2-12/libavformat/mmf.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/mmf.c 2007-11-21 08:41:00.000000000 +0100 +@@ -60,7 +60,7 @@ + static int mmf_write_header(AVFormatContext *s) + { + MMFContext *mmf = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + offset_t pos; + int rate; + +@@ -108,7 +108,7 @@ + + static int mmf_write_packet(AVFormatContext *s, AVPacket *pkt) + { +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + put_buffer(pb, pkt->data, pkt->size); + return 0; + } +@@ -127,12 +127,12 @@ + + static int mmf_write_trailer(AVFormatContext *s) + { +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + MMFContext *mmf = s->priv_data; + offset_t pos, size; + int gatetime; + +- if (!url_is_streamed(&s->pb)) { ++ if (!url_is_streamed(s->pb)) { + /* Fill in length fields */ + end_tag_be(pb, mmf->awapos); + end_tag_be(pb, mmf->atrpos); +@@ -183,7 +183,7 @@ + { + MMFContext *mmf = s->priv_data; + unsigned int tag; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + AVStream *st; + offset_t file_size, size; + int rate, params; +@@ -265,7 +265,7 @@ + AVStream *st; + int ret, size; + +- if (url_feof(&s->pb)) ++ if (url_feof(s->pb)) + return AVERROR(EIO); + st = s->streams[0]; + +@@ -280,7 +280,7 @@ + return AVERROR(EIO); + pkt->stream_index = 0; + +- ret = get_buffer(&s->pb, pkt->data, pkt->size); ++ ret = get_buffer(s->pb, pkt->data, pkt->size); + if (ret < 0) + av_free_packet(pkt); + +diff -u mplayer-1.0~rc2-12/libavformat/mov.c ffmpeg-free-0.svn20080206/libavformat/mov.c +--- mplayer-1.0~rc2-12/libavformat/mov.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/mov.c 2008-01-27 20:57:04.000000000 +0100 +@@ -107,6 +107,7 @@ + unsigned int bytes_per_frame; + unsigned int samples_per_frame; + int dv_audio_container; ++ int pseudo_stream_id; + } MOVStreamContext; + + typedef struct MOVContext { +@@ -115,13 +116,6 @@ + int64_t duration; /* duration of the longest track */ + int found_moov; /* when both 'moov' and 'mdat' sections has been found */ + int found_mdat; /* we suppose we have enough data to read the file */ +- int64_t mdat_offset; +- int total_streams; +- MOVStreamContext *streams[MAX_STREAMS]; +- +- const struct MOVParseTableEntry *parse_table; /* could be eventually used to change the table */ +- /* NOTE: for recursion save to/ restore from local variable! */ +- + AVPaletteControl palette_control; + MOV_mdat_t *mdat_list; + int mdat_count; +@@ -139,14 +133,14 @@ + 0: continue to parse next atom + -1: error occured, exit + */ +-typedef int (*mov_parse_function)(MOVContext *ctx, ByteIOContext *pb, MOV_atom_t atom); +- + /* links atom IDs to parse functions */ + typedef struct MOVParseTableEntry { + uint32_t type; +- mov_parse_function func; ++ int (*parse)(MOVContext *ctx, ByteIOContext *pb, MOV_atom_t atom); + } MOVParseTableEntry; + ++static const MOVParseTableEntry mov_default_parse_table[]; ++ + static int mov_read_default(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) + { + int64_t total_size = 0; +@@ -160,14 +154,15 @@ + atom.size = INT64_MAX; + while(((total_size + 8) < atom.size) && !url_feof(pb) && !err) { + a.size = atom.size; +- a.type=0L; ++ a.type=0; + if(atom.size >= 8) { + a.size = get_be32(pb); + a.type = get_le32(pb); + } + total_size += 8; + a.offset += 8; +- dprintf(c->fc, "type: %08x %.4s sz: %"PRIx64" %"PRIx64" %"PRIx64"\n", a.type, (char*)&a.type, a.size, atom.size, total_size); ++ dprintf(c->fc, "type: %08x %.4s sz: %"PRIx64" %"PRIx64" %"PRIx64"\n", ++ a.type, (char*)&a.type, a.size, atom.size, total_size); + if (a.size == 1) { /* 64 bit extended size */ + a.size = get_be64(pb) - 8; + a.offset += 8; +@@ -179,19 +174,22 @@ + break; + } + a.size -= 8; +- if(a.size < 0 || a.size > atom.size - total_size) ++ if(a.size < 0) + break; ++ a.size = FFMIN(a.size, atom.size - total_size); + +- for (i = 0; c->parse_table[i].type != 0L +- && c->parse_table[i].type != a.type; i++) ++ for (i = 0; mov_default_parse_table[i].type != 0 ++ && mov_default_parse_table[i].type != a.type; i++) + /* empty */; + +- if (c->parse_table[i].type == 0) { /* skip leaf atoms data */ ++ if (mov_default_parse_table[i].type == 0) { /* skip leaf atoms data */ + url_fskip(pb, a.size); + } else { + offset_t start_pos = url_ftell(pb); + int64_t left; +- err = (c->parse_table[i].func)(c, pb, a); ++ err = mov_default_parse_table[i].parse(c, pb, a); ++ if (c->found_moov && c->found_mdat) ++ break; + left = a.size - url_ftell(pb) + start_pos; + if (left > 0) /* skip garbage at atom end */ + url_fskip(pb, left); +@@ -221,8 +219,10 @@ + ctype = get_le32(pb); + type = get_le32(pb); /* component subtype */ + +- dprintf(c->fc, "ctype= %c%c%c%c (0x%08x)\n", *((char *)&ctype), ((char *)&ctype)[1], ((char *)&ctype)[2], ((char *)&ctype)[3], (int) ctype); +- dprintf(c->fc, "stype= %c%c%c%c\n", *((char *)&type), ((char *)&type)[1], ((char *)&type)[2], ((char *)&type)[3]); ++ dprintf(c->fc, "ctype= %c%c%c%c (0x%08x)\n", *((char *)&ctype), ((char *)&ctype)[1], ++ ((char *)&ctype)[2], ((char *)&ctype)[3], (int) ctype); ++ dprintf(c->fc, "stype= %c%c%c%c\n", ++ *((char *)&type), ((char *)&type)[1], ((char *)&type)[2], ((char *)&type)[3]); + if(!ctype) + c->isom = 1; + if(type == MKTAG('v', 'i', 'd', 'e')) +@@ -233,7 +233,6 @@ + st->codec->codec_id = CODEC_ID_MP2; + else if(type == MKTAG('s', 'u', 'b', 'p')) { + st->codec->codec_type = CODEC_TYPE_SUBTITLE; +- st->codec->codec_id = CODEC_ID_DVD_SUBTITLE; + } + get_be32(pb); /* component manufacture */ + get_be32(pb); /* component flags */ +@@ -322,7 +321,6 @@ + c->mdat_list[c->mdat_count].size = atom.size; + c->mdat_count++; + c->found_mdat=1; +- c->mdat_offset = atom.offset; + if(c->found_moov) + return 1; /* found both, just go */ + url_fskip(pb, atom.size); +@@ -344,9 +342,8 @@ + /* this atom should contain all header atoms */ + static int mov_read_moov(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) + { +- int err; +- +- err = mov_read_default(c, pb, atom); ++ if (mov_read_default(c, pb, atom) < 0) ++ return -1; + /* we parsed the 'moov' atom, we can terminate the parsing as soon as we find the 'mdat' */ + /* so we don't parse the whole file if over a network */ + c->found_moov=1; +@@ -470,16 +467,19 @@ + static int mov_read_extradata(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) + { + AVStream *st = c->fc->streams[c->fc->nb_streams-1]; +- if((uint64_t)atom.size > (1<<30)) +- return -1; +- av_free(st->codec->extradata); +- st->codec->extradata_size = atom.size + 8; +- st->codec->extradata = av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); +- if (st->codec->extradata) { +- AV_WL32(st->codec->extradata + 4, atom.type); +- get_buffer(pb, st->codec->extradata + 8, atom.size); +- } else +- url_fskip(pb, atom.size); ++ uint64_t size= (uint64_t)st->codec->extradata_size + atom.size + 8 + FF_INPUT_BUFFER_PADDING_SIZE; ++ uint8_t *buf; ++ if(size > INT_MAX || (uint64_t)atom.size > INT_MAX) ++ return -1; ++ buf= av_realloc(st->codec->extradata, size); ++ if(!buf) ++ return -1; ++ st->codec->extradata= buf; ++ buf+= st->codec->extradata_size; ++ st->codec->extradata_size= size - FF_INPUT_BUFFER_PADDING_SIZE; ++ AV_WB32( buf , atom.size + 8); ++ AV_WL32( buf + 4, atom.type); ++ get_buffer(pb, buf + 8, atom.size); + return 0; + } + +@@ -501,13 +501,18 @@ + } else + url_fskip(pb, atom.size); + } else if (atom.size > 8) { /* to read frma, esds atoms */ +- mov_read_default(c, pb, atom); ++ if (mov_read_default(c, pb, atom) < 0) ++ return -1; + } else + url_fskip(pb, atom.size); + return 0; + } + +-static int mov_read_avcC(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) ++/** ++ * This function reads atom content and puts data in extradata without tag ++ * nor size unlike mov_read_extradata. ++ */ ++static int mov_read_glbl(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) + { + AVStream *st = c->fc->streams[c->fc->nb_streams-1]; + +@@ -568,15 +573,15 @@ + uint8_t codec_name[32]; + + /* for palette traversal */ +- int color_depth; +- int color_start; +- int color_count; +- int color_end; ++ unsigned int color_depth; ++ unsigned int color_start; ++ unsigned int color_count; ++ unsigned int color_end; + int color_index; + int color_dec; + int color_greyscale; +- unsigned char *color_table; +- int j; ++ const uint8_t *color_table; ++ int j, pseudo_stream_id; + unsigned char r, g, b; + + get_byte(pb); /* version */ +@@ -584,7 +589,7 @@ + + entries = get_be32(pb); + +- while(entries--) { //Parsing Sample description table ++ for(pseudo_stream_id=0; pseudo_stream_idcodec->codec_tag) { +- /* multiple fourcc, just skip for now */ ++ if (st->codec->codec_tag && st->codec->codec_tag != MKTAG('j', 'p', 'e', 'g')) { ++ /* multiple fourcc, we skip jpeg, this isnt correct, we should export it as ++ seperate AVStream but this needs a few changes in the mov demuxer, patch ++ welcome */ + url_fskip(pb, size - (url_ftell(pb) - start_pos)); + continue; + } ++ sc->pseudo_stream_id= pseudo_stream_id; + + st->codec->codec_tag = format; + id = codec_get_id(codec_movaudio_tags, format); +@@ -615,12 +623,16 @@ + id = codec_get_id(codec_bmp_tags, format); + if (id > 0) + st->codec->codec_type = CODEC_TYPE_VIDEO; ++ else if(st->codec->codec_type == CODEC_TYPE_DATA){ ++ id = codec_get_id(ff_codec_movsubtitle_tags, format); ++ if(id > 0) ++ st->codec->codec_type = CODEC_TYPE_SUBTITLE; ++ } + } + +- dprintf(c->fc, "size=%d 4CC= %c%c%c%c codec_type=%d\n", +- size, +- (format >> 0) & 0xff, (format >> 8) & 0xff, (format >> 16) & 0xff, (format >> 24) & 0xff, +- st->codec->codec_type); ++ dprintf(c->fc, "size=%d 4CC= %c%c%c%c codec_type=%d\n", size, ++ (format >> 0) & 0xff, (format >> 8) & 0xff, (format >> 16) & 0xff, ++ (format >> 24) & 0xff, st->codec->codec_type); + + if(st->codec->codec_type==CODEC_TYPE_VIDEO) { + st->codec->codec_id = id; +@@ -628,7 +640,7 @@ + get_be16(pb); /* revision level */ + get_be32(pb); /* vendor */ + get_be32(pb); /* temporal quality */ +- get_be32(pb); /* spacial quality */ ++ get_be32(pb); /* spatial quality */ + + st->codec->width = get_be16(pb); /* width */ + st->codec->height = get_be16(pb); /* height */ +@@ -656,9 +668,7 @@ + /* if the depth is 2, 4, or 8 bpp, file is palettized */ + if ((color_depth == 2) || (color_depth == 4) || + (color_depth == 8)) { +- + if (color_greyscale) { +- + /* compute the greyscale palette */ + color_count = 1 << color_depth; + color_index = 255; +@@ -671,9 +681,7 @@ + if (color_index < 0) + color_index = 0; + } +- + } else if (st->codec->color_table_id & 0x08) { +- + /* if flag bit 3 is set, use the default palette */ + color_count = 1 << color_depth; + if (color_depth == 2) +@@ -690,30 +698,30 @@ + c->palette_control.palette[j] = + (r << 16) | (g << 8) | (b); + } +- + } else { +- + /* load the palette from the file */ + color_start = get_be32(pb); + color_count = get_be16(pb); + color_end = get_be16(pb); +- for (j = color_start; j <= color_end; j++) { +- /* each R, G, or B component is 16 bits; +- * only use the top 8 bits; skip alpha bytes +- * up front */ +- get_byte(pb); +- get_byte(pb); +- r = get_byte(pb); +- get_byte(pb); +- g = get_byte(pb); +- get_byte(pb); +- b = get_byte(pb); +- get_byte(pb); +- c->palette_control.palette[j] = +- (r << 16) | (g << 8) | (b); ++ if ((color_start <= 255) && ++ (color_end <= 255)) { ++ for (j = color_start; j <= color_end; j++) { ++ /* each R, G, or B component is 16 bits; ++ * only use the top 8 bits; skip alpha bytes ++ * up front */ ++ get_byte(pb); ++ get_byte(pb); ++ r = get_byte(pb); ++ get_byte(pb); ++ g = get_byte(pb); ++ get_byte(pb); ++ b = get_byte(pb); ++ get_byte(pb); ++ c->palette_control.palette[j] = ++ (r << 16) | (g << 8) | (b); ++ } + } + } +- + st->codec->palctrl = &c->palette_control; + st->codec->palctrl->palette_changed = 1; + } else +@@ -779,15 +787,18 @@ + st->codec->bits_per_sample = bits_per_sample; + sc->sample_size = (bits_per_sample >> 3) * st->codec->channels; + } ++ } else if(st->codec->codec_type==CODEC_TYPE_SUBTITLE){ ++ st->codec->codec_id= id; + } else { + /* other codec type, just skip (rtp, mp4s, tmcd ...) */ + url_fskip(pb, size - (url_ftell(pb) - start_pos)); + } + /* this will read extra atoms at the end (wave, alac, damr, avcC, SMI ...) */ + a.size = size - (url_ftell(pb) - start_pos); +- if (a.size > 8) +- mov_read_default(c, pb, a); +- else if (a.size > 0) ++ if (a.size > 8) { ++ if (mov_read_default(c, pb, a) < 0) ++ return -1; ++ } else if (a.size > 0) + url_fskip(pb, a.size); + } + +@@ -959,7 +970,8 @@ + + sc->stts_count = entries; + sc->stts_data = av_malloc(entries * sizeof(MOV_stts_t)); +- ++ if (!sc->stts_data) ++ return -1; + dprintf(c->fc, "track[%i].stts.entries = %i\n", c->fc->nb_streams-1, entries); + + sc->time_rate=0; +@@ -1001,7 +1013,8 @@ + + sc->ctts_count = entries; + sc->ctts_data = av_malloc(entries * sizeof(MOV_stts_t)); +- ++ if (!sc->ctts_data) ++ return -1; + dprintf(c->fc, "track[%i].ctts.entries = %i\n", c->fc->nb_streams-1, entries); + + for(i=0; ipriv_data = sc; + st->codec->codec_type = CODEC_TYPE_DATA; + st->start_time = 0; /* XXX: check */ +- c->streams[c->fc->nb_streams-1] = sc; + + return mov_read_default(c, pb, atom); + } +@@ -1206,18 +1218,19 @@ + /* edit list atom */ + static int mov_read_elst(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom) + { ++ MOVStreamContext *sc = c->fc->streams[c->fc->nb_streams-1]->priv_data; + int i, edit_count; + + get_byte(pb); /* version */ + get_byte(pb); get_byte(pb); get_byte(pb); /* flags */ +- edit_count= c->streams[c->fc->nb_streams-1]->edit_count = get_be32(pb); /* entries */ ++ edit_count= sc->edit_count = get_be32(pb); /* entries */ + + for(i=0; ifc, "track[%i].edit_count = %i\n", c->fc->nb_streams-1, c->streams[c->fc->nb_streams-1]->edit_count); ++ dprintf(c->fc, "track[%i].edit_count = %i\n", c->fc->nb_streams-1, sc->edit_count); + return 0; + } + +@@ -1230,6 +1243,7 @@ + { MKTAG( 'e', 'n', 'd', 'a' ), mov_read_enda }, + { MKTAG( 'f', 'i', 'e', 'l' ), mov_read_extradata }, + { MKTAG( 'f', 't', 'y', 'p' ), mov_read_ftyp }, ++{ MKTAG( 'g', 'l', 'b', 'l' ), mov_read_glbl }, + { MKTAG( 'h', 'd', 'l', 'r' ), mov_read_hdlr }, + { MKTAG( 'j', 'p', '2', 'h' ), mov_read_extradata }, + { MKTAG( 'm', 'd', 'a', 't' ), mov_read_mdat }, +@@ -1240,7 +1254,7 @@ + { MKTAG( 'm', 'v', 'h', 'd' ), mov_read_mvhd }, + { MKTAG( 'S', 'M', 'I', ' ' ), mov_read_smi }, /* Sorenson extension ??? */ + { MKTAG( 'a', 'l', 'a', 'c' ), mov_read_extradata }, /* alac specific atom */ +-{ MKTAG( 'a', 'v', 'c', 'C' ), mov_read_avcC }, ++{ MKTAG( 'a', 'v', 'c', 'C' ), mov_read_glbl }, + { MKTAG( 's', 't', 'b', 'l' ), mov_read_default }, + { MKTAG( 's', 't', 'c', 'o' ), mov_read_stco }, + { MKTAG( 's', 't', 's', 'c' ), mov_read_stsc }, +@@ -1255,7 +1269,7 @@ + { MKTAG( 'e', 's', 'd', 's' ), mov_read_esds }, + { MKTAG( 'w', 'i', 'd', 'e' ), mov_read_wide }, /* place holder */ + { MKTAG( 'c', 'm', 'o', 'v' ), mov_read_cmov }, +-{ 0L, NULL } ++{ 0, NULL } + }; + + /* XXX: is it sufficient ? */ +@@ -1321,7 +1335,8 @@ + st->nb_frames = sc->sample_count; + for (i = 0; i < sc->chunk_count; i++) { + current_offset = sc->chunk_offsets[i]; +- if (stsc_index + 1 < sc->sample_to_chunk_sz && i + 1 == sc->sample_to_chunk[stsc_index + 1].first) ++ if (stsc_index + 1 < sc->sample_to_chunk_sz && ++ i + 1 == sc->sample_to_chunk[stsc_index + 1].first) + stsc_index++; + for (j = 0; j < sc->sample_to_chunk[stsc_index].count; j++) { + if (current_sample >= sc->sample_count) { +@@ -1335,9 +1350,12 @@ + stss_index++; + } + sample_size = sc->sample_size > 0 ? sc->sample_size : sc->sample_sizes[current_sample]; +- dprintf(mov->fc, "AVIndex stream %d, sample %d, offset %"PRIx64", dts %"PRId64", size %d, distance %d, keyframe %d\n", +- st->index, current_sample, current_offset, current_dts, sample_size, distance, keyframe); +- av_add_index_entry(st, current_offset, current_dts, sample_size, distance, keyframe ? AVINDEX_KEYFRAME : 0); ++ dprintf(mov->fc, "AVIndex stream %d, sample %d, offset %"PRIx64", dts %"PRId64", " ++ "size %d, distance %d, keyframe %d\n", st->index, current_sample, ++ current_offset, current_dts, sample_size, distance, keyframe); ++ if(sc->sample_to_chunk[stsc_index].id - 1 == sc->pseudo_stream_id) ++ av_add_index_entry(st, current_offset, current_dts, sample_size, distance, ++ keyframe ? AVINDEX_KEYFRAME : 0); + current_offset += sample_size; + assert(sc->stts_data[stts_index].duration % sc->time_rate == 0); + current_dts += sc->stts_data[stts_index].duration / sc->time_rate; +@@ -1352,24 +1370,26 @@ + } + } else { /* read whole chunk */ + unsigned int chunk_samples, chunk_size, chunk_duration; +- + for (i = 0; i < sc->chunk_count; i++) { + current_offset = sc->chunk_offsets[i]; +- if (stsc_index + 1 < sc->sample_to_chunk_sz && i + 1 == sc->sample_to_chunk[stsc_index + 1].first) ++ if (stsc_index + 1 < sc->sample_to_chunk_sz && ++ i + 1 == sc->sample_to_chunk[stsc_index + 1].first) + stsc_index++; + chunk_samples = sc->sample_to_chunk[stsc_index].count; + /* get chunk size */ +- if (sc->sample_size > 1 || st->codec->codec_id == CODEC_ID_PCM_U8 || st->codec->codec_id == CODEC_ID_PCM_S8) ++ if (sc->sample_size > 1 || ++ st->codec->codec_id == CODEC_ID_PCM_U8 || st->codec->codec_id == CODEC_ID_PCM_S8) + chunk_size = chunk_samples * sc->sample_size; +- else if (sc->samples_per_frame > 0 && (chunk_samples * sc->bytes_per_frame % sc->samples_per_frame == 0)) ++ else if (sc->samples_per_frame > 0 && ++ (chunk_samples * sc->bytes_per_frame % sc->samples_per_frame == 0)) + chunk_size = chunk_samples * sc->bytes_per_frame / sc->samples_per_frame; + else { /* workaround to find nearest next chunk offset */ + chunk_size = INT_MAX; +- for (j = 0; j < mov->total_streams; j++) { +- MOVStreamContext *msc = mov->streams[j]; +- ++ for (j = 0; j < mov->fc->nb_streams; j++) { ++ MOVStreamContext *msc = mov->fc->streams[j]->priv_data; + for (k = msc->next_chunk; k < msc->chunk_count; k++) { +- if (msc->chunk_offsets[k] > current_offset && msc->chunk_offsets[k] - current_offset < chunk_size) { ++ if (msc->chunk_offsets[k] > current_offset && ++ msc->chunk_offsets[k] - current_offset < chunk_size) { + chunk_size = msc->chunk_offsets[k] - current_offset; + msc->next_chunk = k; + break; +@@ -1381,12 +1401,14 @@ + for (j = 0; j < mov->mdat_count; j++) { + dprintf(mov->fc, "mdat %d, offset %"PRIx64", size %"PRId64", current offset %"PRIx64"\n", + j, mov->mdat_list[j].offset, mov->mdat_list[j].size, current_offset); +- if (mov->mdat_list[j].offset <= current_offset && mov->mdat_list[j].offset + mov->mdat_list[j].size > current_offset) ++ if (mov->mdat_list[j].offset <= current_offset && ++ mov->mdat_list[j].offset + mov->mdat_list[j].size > current_offset) + chunk_size = mov->mdat_list[j].offset + mov->mdat_list[j].size - current_offset; + } + assert(chunk_size != INT_MAX); +- for (j = 0; j < mov->total_streams; j++) { +- mov->streams[j]->next_chunk = 0; ++ for (j = 0; j < mov->fc->nb_streams; j++) { ++ MOVStreamContext *msc = mov->fc->streams[j]->priv_data; ++ msc->next_chunk = 0; + } + } + av_add_index_entry(st, current_offset, current_dts, chunk_size, 0, AVINDEX_KEYFRAME); +@@ -1405,8 +1427,8 @@ + } + } + } +- dprintf(mov->fc, "AVIndex stream %d, chunk %d, offset %"PRIx64", dts %"PRId64", size %d, duration %d\n", +- st->index, i, current_offset, current_dts, chunk_size, chunk_duration); ++ dprintf(mov->fc, "AVIndex stream %d, chunk %d, offset %"PRIx64", dts %"PRId64", size %d, " ++ "duration %d\n", st->index, i, current_offset, current_dts, chunk_size, chunk_duration); + assert(chunk_duration % sc->time_rate == 0); + current_dts += chunk_duration / sc->time_rate; + } +@@ -1419,12 +1441,11 @@ + static int mov_read_header(AVFormatContext *s, AVFormatParameters *ap) + { + MOVContext *mov = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + int i, err; + MOV_atom_t atom = { 0, 0, 0 }; + + mov->fc = s; +- mov->parse_table = mov_default_parse_table; + + if(!url_is_streamed(pb)) /* .mov and .mp4 aren't streamable anyway (only progressive download if moov is before mdat) */ + atom.size = url_fsize(pb); +@@ -1440,15 +1461,9 @@ + } + dprintf(mov->fc, "on_parse_exit_offset=%d\n", (int) url_ftell(pb)); + +- /* some cleanup : make sure we are on the mdat atom */ +- if(!url_is_streamed(pb) && (url_ftell(pb) != mov->mdat_offset)) +- url_fseek(pb, mov->mdat_offset, SEEK_SET); +- +- mov->total_streams = s->nb_streams; +- +- for(i=0; itotal_streams; i++) { +- MOVStreamContext *sc = mov->streams[i]; ++ for(i=0; inb_streams; i++) { + AVStream *st = s->streams[i]; ++ MOVStreamContext *sc = st->priv_data; + /* sanity checks */ + if(!sc->stts_count || !sc->chunk_count || !sc->sample_to_chunk_sz || + (!sc->sample_size && !sc->sample_count)){ +@@ -1473,13 +1488,14 @@ + mov_build_index(mov, st); + } + +- for(i=0; itotal_streams; i++) { ++ for(i=0; inb_streams; i++) { ++ MOVStreamContext *sc = s->streams[i]->priv_data; + /* Do not need those anymore. */ +- av_freep(&mov->streams[i]->chunk_offsets); +- av_freep(&mov->streams[i]->sample_to_chunk); +- av_freep(&mov->streams[i]->sample_sizes); +- av_freep(&mov->streams[i]->keyframes); +- av_freep(&mov->streams[i]->stts_data); ++ av_freep(&sc->chunk_offsets); ++ av_freep(&sc->sample_to_chunk); ++ av_freep(&sc->sample_sizes); ++ av_freep(&sc->keyframes); ++ av_freep(&sc->stts_data); + } + av_freep(&mov->mdat_list); + return 0; +@@ -1493,15 +1509,18 @@ + int64_t best_dts = INT64_MAX; + int i; + +- for (i = 0; i < mov->total_streams; i++) { +- MOVStreamContext *msc = mov->streams[i]; +- +- if (s->streams[i]->discard != AVDISCARD_ALL && msc->current_sample < msc->sample_count) { +- AVIndexEntry *current_sample = &s->streams[i]->index_entries[msc->current_sample]; +- int64_t dts = av_rescale(current_sample->timestamp * (int64_t)msc->time_rate, AV_TIME_BASE, msc->time_scale); +- ++ for (i = 0; i < s->nb_streams; i++) { ++ AVStream *st = s->streams[i]; ++ MOVStreamContext *msc = st->priv_data; ++ if (st->discard != AVDISCARD_ALL && msc->current_sample < msc->sample_count) { ++ AVIndexEntry *current_sample = &st->index_entries[msc->current_sample]; ++ int64_t dts = av_rescale(current_sample->timestamp * (int64_t)msc->time_rate, ++ AV_TIME_BASE, msc->time_scale); + dprintf(s, "stream %d, sample %d, dts %"PRId64"\n", i, msc->current_sample, dts); +- if (dts < best_dts) { ++ if (!sample || (url_is_streamed(s->pb) && current_sample->pos < sample->pos) || ++ (!url_is_streamed(s->pb) && ++ ((FFABS(best_dts - dts) <= AV_TIME_BASE && current_sample->pos < sample->pos) || ++ (FFABS(best_dts - dts) > AV_TIME_BASE && dts < best_dts)))) { + sample = current_sample; + best_dts = dts; + sc = msc; +@@ -1512,8 +1531,9 @@ + return -1; + /* must be done just before reading, to avoid infinite loop on sample */ + sc->current_sample++; +- if (sample->pos >= url_fsize(&s->pb)) { +- av_log(mov->fc, AV_LOG_ERROR, "stream %d, offset 0x%"PRIx64": partial file\n", sc->ffindex, sample->pos); ++ if (url_fseek(s->pb, sample->pos, SEEK_SET) != sample->pos) { ++ av_log(mov->fc, AV_LOG_ERROR, "stream %d, offset 0x%"PRIx64": partial file\n", ++ sc->ffindex, sample->pos); + return -1; + } + #ifdef CONFIG_DV_DEMUXER +@@ -1522,8 +1542,7 @@ + dprintf(s, "dv audio pkt size %d\n", pkt->size); + } else { + #endif +- url_fseek(&s->pb, sample->pos, SEEK_SET); +- av_get_packet(&s->pb, pkt, sample->size); ++ av_get_packet(s->pb, pkt, sample->size); + #ifdef CONFIG_DV_DEMUXER + if (mov->dv_demux) { + void *pkt_destruct_func = pkt->destruct; +@@ -1539,7 +1558,8 @@ + pkt->pts = pkt->dts + sc->ctts_data[sc->sample_to_ctime_index].duration / sc->time_rate; + /* update ctts context */ + sc->sample_to_ctime_sample++; +- if (sc->sample_to_ctime_index < sc->ctts_count && sc->ctts_data[sc->sample_to_ctime_index].count == sc->sample_to_ctime_sample) { ++ if (sc->sample_to_ctime_index < sc->ctts_count && ++ sc->ctts_data[sc->sample_to_ctime_index].count == sc->sample_to_ctime_sample) { + sc->sample_to_ctime_index++; + sc->sample_to_ctime_sample = 0; + } +@@ -1548,7 +1568,8 @@ + } + pkt->flags |= sample->flags & AVINDEX_KEYFRAME ? PKT_FLAG_KEY : 0; + pkt->pos = sample->pos; +- dprintf(s, "stream %d, pts %"PRId64", dts %"PRId64", pos 0x%"PRIx64", duration %d\n", pkt->stream_index, pkt->pts, pkt->dts, pkt->pos, pkt->duration); ++ dprintf(s, "stream %d, pts %"PRId64", dts %"PRId64", pos 0x%"PRIx64", duration %d\n", ++ pkt->stream_index, pkt->pts, pkt->dts, pkt->pos, pkt->duration); + return 0; + } + +@@ -1613,9 +1634,9 @@ + { + int i; + MOVContext *mov = s->priv_data; +- for(i=0; itotal_streams; i++) { +- av_freep(&mov->streams[i]->ctts_data); +- av_freep(&mov->streams[i]); ++ for(i=0; inb_streams; i++) { ++ MOVStreamContext *sc = s->streams[i]->priv_data; ++ av_freep(&sc->ctts_data); + } + if(mov->dv_demux){ + for(i=0; idv_fctx->nb_streams; i++){ +diff -u mplayer-1.0~rc2-12/libavformat/movenc.c ffmpeg-free-0.svn20080206/libavformat/movenc.c +--- mplayer-1.0~rc2-12/libavformat/movenc.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/movenc.c 2008-02-04 02:06:04.000000000 +0100 +@@ -23,6 +23,7 @@ + #include "riff.h" + #include "avio.h" + #include "isom.h" ++#include "avc.h" + + #undef NDEBUG + #include +@@ -59,7 +60,7 @@ + int hasBframes; + int language; + int trackID; +- int tag; ++ int tag; ///< stsd fourcc + AVCodecContext *enc; + + int vosLen; +@@ -322,6 +323,14 @@ + return updateSize (pb, pos); + } + ++static int mov_write_glbl_tag(ByteIOContext *pb, MOVTrack* track) ++{ ++ put_be32(pb, track->vosLen+8); ++ put_tag(pb, "glbl"); ++ put_buffer(pb, track->vosData, track->vosLen); ++ return 8+track->vosLen; ++} ++ + static int mov_write_audio_tag(ByteIOContext *pb, MOVTrack* track) + { + offset_t pos = url_ftell(pb); +@@ -372,10 +381,12 @@ + track->enc->codec_id == CODEC_ID_PCM_S24LE || + track->enc->codec_id == CODEC_ID_PCM_S32LE)) + mov_write_wave_tag(pb, track); +- else if(track->enc->codec_id == CODEC_ID_AAC) ++ else if(track->tag == MKTAG('m','p','4','a')) + mov_write_esds_tag(pb, track); + else if(track->enc->codec_id == CODEC_ID_AMR_NB) + mov_write_amr_tag(pb, track); ++ else if(track->vosLen > 0) ++ mov_write_glbl_tag(pb, track); + + return updateSize (pb, pos); + } +@@ -405,170 +416,128 @@ + return 0x15; + } + +-static uint8_t *avc_find_startcode( uint8_t *p, uint8_t *end ) +-{ +- uint8_t *a = p + 4 - ((long)p & 3); +- +- for( end -= 3; p < a && p < end; p++ ) { +- if( p[0] == 0 && p[1] == 0 && p[2] == 1 ) +- return p; +- } +- +- for( end -= 3; p < end; p += 4 ) { +- uint32_t x = *(uint32_t*)p; +-// if( (x - 0x01000100) & (~x) & 0x80008000 ) // little endian +-// if( (x - 0x00010001) & (~x) & 0x00800080 ) // big endian +- if( (x - 0x01010101) & (~x) & 0x80808080 ) { // generic +- if( p[1] == 0 ) { +- if( p[0] == 0 && p[2] == 1 ) +- return p-1; +- if( p[2] == 0 && p[3] == 1 ) +- return p; +- } +- if( p[3] == 0 ) { +- if( p[2] == 0 && p[4] == 1 ) +- return p+1; +- if( p[4] == 0 && p[5] == 1 ) +- return p+2; +- } +- } +- } +- +- for( end += 3; p < end; p++ ) { +- if( p[0] == 0 && p[1] == 0 && p[2] == 1 ) +- return p; +- } +- +- return end + 3; +-} +- +-static void avc_parse_nal_units(uint8_t **buf, int *size) +-{ +- ByteIOContext pb; +- uint8_t *p = *buf; +- uint8_t *end = p + *size; +- uint8_t *nal_start, *nal_end; +- +- url_open_dyn_buf(&pb); +- nal_start = avc_find_startcode(p, end); +- while (nal_start < end) { +- while(!*(nal_start++)); +- nal_end = avc_find_startcode(nal_start, end); +- put_be32(&pb, nal_end - nal_start); +- put_buffer(&pb, nal_start, nal_end - nal_start); +- nal_start = nal_end; +- } +- av_freep(buf); +- *size = url_close_dyn_buf(&pb, buf); +-} +- + static int mov_write_avcc_tag(ByteIOContext *pb, MOVTrack *track) + { + offset_t pos = url_ftell(pb); + + put_be32(pb, 0); + put_tag(pb, "avcC"); +- if (track->vosLen > 6) { +- /* check for h264 start code */ +- if (AV_RB32(track->vosData) == 0x00000001) { +- uint8_t *buf, *end; +- uint32_t sps_size=0, pps_size=0; +- uint8_t *sps=0, *pps=0; +- +- avc_parse_nal_units(&track->vosData, &track->vosLen); +- buf = track->vosData; +- end = track->vosData + track->vosLen; +- +- /* look for sps and pps */ +- while (buf < end) { +- unsigned int size; +- uint8_t nal_type; +- size = AV_RB32(buf); +- nal_type = buf[4] & 0x1f; +- if (nal_type == 7) { /* SPS */ +- sps = buf + 4; +- sps_size = size; +- } else if (nal_type == 8) { /* PPS */ +- pps = buf + 4; +- pps_size = size; +- } +- buf += size + 4; +- } +- assert(sps); +- assert(pps); +- +- put_byte(pb, 1); /* version */ +- put_byte(pb, sps[1]); /* profile */ +- put_byte(pb, sps[2]); /* profile compat */ +- put_byte(pb, sps[3]); /* level */ +- put_byte(pb, 0xff); /* 6 bits reserved (111111) + 2 bits nal size length - 1 (11) */ +- put_byte(pb, 0xe1); /* 3 bits reserved (111) + 5 bits number of sps (00001) */ +- +- put_be16(pb, sps_size); +- put_buffer(pb, sps, sps_size); +- put_byte(pb, 1); /* number of pps */ +- put_be16(pb, pps_size); +- put_buffer(pb, pps, pps_size); +- } else { +- put_buffer(pb, track->vosData, track->vosLen); +- } +- } ++ ff_isom_write_avcc(pb, track->vosData, track->vosLen); + return updateSize(pb, pos); + } + +-static int mov_find_video_codec_tag(AVFormatContext *s, MOVTrack *track) ++/* also used by all avid codecs (dv, imx, meridien) and their variants */ ++static int mov_write_avid_tag(ByteIOContext *pb, MOVTrack *track) + { +- int tag = track->enc->codec_tag; +- if (!tag) { +- if (track->enc->codec_id == CODEC_ID_DVVIDEO) { +- if (track->enc->height == 480) { /* NTSC */ +- if (track->enc->pix_fmt == PIX_FMT_YUV422P) +- tag = MKTAG('d', 'v', '5', 'n'); +- else +- tag = MKTAG('d', 'v', 'c', ' '); +- } else { /* assume PAL */ +- if (track->enc->pix_fmt == PIX_FMT_YUV422P) +- tag = MKTAG('d', 'v', '5', 'p'); +- else if (track->enc->pix_fmt == PIX_FMT_YUV420P) +- tag = MKTAG('d', 'v', 'c', 'p'); +- else +- tag = MKTAG('d', 'v', 'p', 'p'); +- } +- } else if (track->enc->codec_id == CODEC_ID_H263) { +- if (track->mode == MODE_MOV) +- tag = MKTAG('h', '2', '6', '3'); +- else +- tag = MKTAG('s', '2', '6', '3'); +- } else { +- tag = codec_get_tag(codec_movvideo_tags, track->enc->codec_id); +- } +- } +- // if no mac fcc found, try with Microsoft tags +- if (!tag) { +- tag = codec_get_tag(codec_bmp_tags, track->enc->codec_id); +- if (tag) { +- av_log(s, AV_LOG_INFO, "Warning, using MS style video codec tag, the file may be unplayable!\n"); +- } ++ int i; ++ put_be32(pb, 24); /* size */ ++ put_tag(pb, "ACLR"); ++ put_tag(pb, "ACLR"); ++ put_tag(pb, "0001"); ++ put_be32(pb, 1); /* yuv 1 / rgb 2 ? */ ++ put_be32(pb, 0); /* unknown */ ++ ++ put_be32(pb, 24); /* size */ ++ put_tag(pb, "APRG"); ++ put_tag(pb, "APRG"); ++ put_tag(pb, "0001"); ++ put_be32(pb, 1); /* unknown */ ++ put_be32(pb, 0); /* unknown */ ++ ++ put_be32(pb, 120); /* size */ ++ put_tag(pb, "ARES"); ++ put_tag(pb, "ARES"); ++ put_tag(pb, "0001"); ++ put_be32(pb, AV_RB32(track->vosData + 0x28)); /* dnxhd cid, some id ? */ ++ put_be32(pb, track->enc->width); ++ /* values below are based on samples created with quicktime and avid codecs */ ++ if (track->vosData[5] & 2) { // interlaced ++ put_be32(pb, track->enc->height/2); ++ put_be32(pb, 2); /* unknown */ ++ put_be32(pb, 0); /* unknown */ ++ put_be32(pb, 4); /* unknown */ ++ } else { ++ put_be32(pb, track->enc->height); ++ put_be32(pb, 1); /* unknown */ ++ put_be32(pb, 0); /* unknown */ ++ if (track->enc->height == 1080) ++ put_be32(pb, 5); /* unknown */ ++ else ++ put_be32(pb, 6); /* unknown */ + } +- assert(tag); +- return tag; ++ /* padding */ ++ for (i = 0; i < 10; i++) ++ put_be64(pb, 0); ++ ++ /* extra padding for stsd needed */ ++ put_be32(pb, 0); ++ return 0; + } + +-static int mov_find_audio_codec_tag(AVFormatContext *s, MOVTrack *track) ++static const AVCodecTag codec_3gp_tags[] = { ++ { CODEC_ID_H263, MKTAG('s','2','6','3') }, ++ { CODEC_ID_H264, MKTAG('a','v','c','1') }, ++ { CODEC_ID_MPEG4, MKTAG('m','p','4','v') }, ++ { CODEC_ID_AAC, MKTAG('m','p','4','a') }, ++ { CODEC_ID_AMR_NB, MKTAG('s','a','m','r') }, ++ { CODEC_ID_AMR_WB, MKTAG('s','a','w','b') }, ++}; ++ ++static const AVCodecTag mov_pix_fmt_tags[] = { ++ { PIX_FMT_YUYV422, MKTAG('y','u','v','s') }, ++ { PIX_FMT_UYVY422, MKTAG('2','v','u','y') }, ++ { PIX_FMT_BGR555, MKTAG('r','a','w',' ') }, ++ { PIX_FMT_RGB24, MKTAG('r','a','w',' ') }, ++ { PIX_FMT_BGR32_1, MKTAG('r','a','w',' ') }, ++}; ++ ++static int mov_find_codec_tag(AVFormatContext *s, MOVTrack *track) + { + int tag = track->enc->codec_tag; +- if (!tag) { +- tag = codec_get_tag(codec_movaudio_tags, track->enc->codec_id); +- } +- // if no mac fcc found, try with Microsoft tags +- if (!tag) { +- int ms_tag = codec_get_tag(codec_wav_tags, track->enc->codec_id); +- if (ms_tag) { +- tag = MKTAG('m', 's', ((ms_tag >> 8) & 0xff), (ms_tag & 0xff)); +- av_log(s, AV_LOG_INFO, "Warning, using MS style audio codec tag, the file may be unplayable!\n"); ++ if (track->mode == MODE_MP4 || track->mode == MODE_PSP) { ++ if (!codec_get_tag(ff_mp4_obj_type, track->enc->codec_id)) ++ return 0; ++ if (track->enc->codec_id == CODEC_ID_H264) tag = MKTAG('a','v','c','1'); ++ else if (track->enc->codec_type == CODEC_TYPE_VIDEO) tag = MKTAG('m','p','4','v'); ++ else if (track->enc->codec_type == CODEC_TYPE_AUDIO) tag = MKTAG('m','p','4','a'); ++ } else if (track->mode == MODE_3GP || track->mode == MODE_3G2) { ++ tag = codec_get_tag(codec_3gp_tags, track->enc->codec_id); ++ } else if (!tag || (track->enc->strict_std_compliance >= FF_COMPLIANCE_NORMAL && ++ (tag == MKTAG('d','v','c','p') || ++ track->enc->codec_id == CODEC_ID_RAWVIDEO))) { ++ if (track->enc->codec_id == CODEC_ID_DVVIDEO) { ++ if (track->enc->height == 480) /* NTSC */ ++ if (track->enc->pix_fmt == PIX_FMT_YUV422P) tag = MKTAG('d','v','5','n'); ++ else tag = MKTAG('d','v','c',' '); ++ else if (track->enc->pix_fmt == PIX_FMT_YUV422P) tag = MKTAG('d','v','5','p'); ++ else if (track->enc->pix_fmt == PIX_FMT_YUV420P) tag = MKTAG('d','v','c','p'); ++ else tag = MKTAG('d','v','p','p'); ++ } else if (track->enc->codec_id == CODEC_ID_RAWVIDEO) { ++ tag = codec_get_tag(mov_pix_fmt_tags, track->enc->pix_fmt); ++ if (!tag) // restore tag ++ tag = track->enc->codec_tag; ++ } else { ++ if (track->enc->codec_type == CODEC_TYPE_VIDEO) { ++ tag = codec_get_tag(codec_movvideo_tags, track->enc->codec_id); ++ if (!tag) { // if no mac fcc found, try with Microsoft tags ++ tag = codec_get_tag(codec_bmp_tags, track->enc->codec_id); ++ if (tag) ++ av_log(s, AV_LOG_INFO, "Warning, using MS style video codec tag, " ++ "the file may be unplayable!\n"); ++ } ++ } else if (track->enc->codec_type == CODEC_TYPE_AUDIO) { ++ tag = codec_get_tag(codec_movaudio_tags, track->enc->codec_id); ++ if (!tag) { // if no mac fcc found, try with Microsoft tags ++ int ms_tag = codec_get_tag(codec_wav_tags, track->enc->codec_id); ++ if (ms_tag) { ++ tag = MKTAG('m', 's', ((ms_tag >> 8) & 0xff), (ms_tag & 0xff)); ++ av_log(s, AV_LOG_INFO, "Warning, using MS style audio codec tag, " ++ "the file may be unplayable!\n"); ++ } ++ } ++ } + } + } +- assert(tag); + return tag; + } + +@@ -613,9 +582,12 @@ + put_byte(pb, strlen(compressor_name)); + put_buffer(pb, compressor_name, 31); + +- put_be16(pb, 0x18); /* Reserved */ ++ if (track->mode == MODE_MOV && track->enc->bits_per_sample) ++ put_be16(pb, track->enc->bits_per_sample); ++ else ++ put_be16(pb, 0x18); /* Reserved */ + put_be16(pb, 0xffff); /* Reserved */ +- if(track->enc->codec_id == CODEC_ID_MPEG4) ++ if(track->tag == MKTAG('m','p','4','v')) + mov_write_esds_tag(pb, track); + else if(track->enc->codec_id == CODEC_ID_H263) + mov_write_d263_tag(pb); +@@ -623,6 +595,10 @@ + mov_write_svq3_tag(pb); + else if(track->enc->codec_id == CODEC_ID_H264) + mov_write_avcc_tag(pb, track); ++ else if(track->enc->codec_id == CODEC_ID_DNXHD) ++ mov_write_avid_tag(pb, track); ++ else if(track->vosLen > 0) ++ mov_write_glbl_tag(pb, track); + + return updateSize (pb, pos); + } +@@ -1173,40 +1149,52 @@ + static int mov_write_udta_tag(ByteIOContext *pb, MOVContext* mov, + AVFormatContext *s) + { +- offset_t pos = url_ftell(pb); +- int i; +- +- put_be32(pb, 0); /* size */ +- put_tag(pb, "udta"); ++ int i, req = 0; + +- /* iTunes meta data */ +- mov_write_meta_tag(pb, mov, s); +- +- if(mov->mode == MODE_MOV){ // the title field breaks gtkpod with mp4 and my suspicion is that stuff is not valid in mp4 + /* Requirements */ + for (i=0; inb_streams; i++) { + if(mov->tracks[i].entry <= 0) continue; + if (mov->tracks[i].enc->codec_id == CODEC_ID_AAC || + mov->tracks[i].enc->codec_id == CODEC_ID_MPEG4) { +- mov_write_string_tag(pb, "\251req", "QuickTime 6.0 or greater", 0); ++ req = 1; + break; + } + } + +- mov_write_string_tag(pb, "\251nam", s->title , 0); +- mov_write_string_tag(pb, "\251aut", s->author , 0); +- mov_write_string_tag(pb, "\251alb", s->album , 0); +- mov_write_day_tag(pb, s->year, 0); +- if(mov->tracks[0].enc && !(mov->tracks[0].enc->flags & CODEC_FLAG_BITEXACT)) +- mov_write_string_tag(pb, "\251enc", LIBAVFORMAT_IDENT, 0); +- mov_write_string_tag(pb, "\251des", s->comment , 0); +- mov_write_string_tag(pb, "\251gen", s->genre , 0); +- } ++ if (s->title[0] || s->author[0] || s->album[0] || s->year || ++ s->comment[0] || s->genre[0] || s->track || ++ (mov->mode == MODE_MOV && ++ ((mov->tracks[0].enc && !mov->tracks[0].enc->flags & CODEC_FLAG_BITEXACT) || req))) { ++ offset_t pos = url_ftell(pb); + +- return updateSize(pb, pos); ++ put_be32(pb, 0); /* size */ ++ put_tag(pb, "udta"); ++ ++ /* iTunes meta data */ ++ mov_write_meta_tag(pb, mov, s); ++ ++ if(mov->mode == MODE_MOV){ // the title field breaks gtkpod with mp4 and my suspicion is that stuff is not valid in mp4 ++ /* Requirements */ ++ if (req) ++ mov_write_string_tag(pb, "\251req", "QuickTime 6.0 or greater", 0); ++ ++ mov_write_string_tag(pb, "\251nam", s->title , 0); ++ mov_write_string_tag(pb, "\251aut", s->author , 0); ++ mov_write_string_tag(pb, "\251alb", s->album , 0); ++ mov_write_day_tag(pb, s->year, 0); ++ if(mov->tracks[0].enc && !(mov->tracks[0].enc->flags & CODEC_FLAG_BITEXACT)) ++ mov_write_string_tag(pb, "\251enc", LIBAVFORMAT_IDENT, 0); ++ mov_write_string_tag(pb, "\251des", s->comment , 0); ++ mov_write_string_tag(pb, "\251gen", s->genre , 0); ++ } ++ ++ return updateSize(pb, pos); ++ } ++ ++ return 0; + } + +-static int utf8len(uint8_t *b){ ++static int utf8len(const uint8_t *b){ + int len=0; + int val; + while(*b){ +@@ -1216,7 +1204,7 @@ + return len; + } + +-static int ascii_to_wc (ByteIOContext *pb, uint8_t *b) ++static int ascii_to_wc (ByteIOContext *pb, const uint8_t *b) + { + int val; + while(*b){ +@@ -1336,7 +1324,7 @@ + + if (mov->mode == MODE_PSP) + mov_write_uuidusmt_tag(pb, s); +- else ++ else if (mov->mode != MODE_3GP && mov->mode != MODE_3G2) + mov_write_udta_tag(pb, mov, s); + + return updateSize(pb, pos); +@@ -1449,11 +1437,11 @@ + + static int mov_write_header(AVFormatContext *s) + { +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + MOVContext *mov = s->priv_data; + int i; + +- if (url_is_streamed(&s->pb)) { ++ if (url_is_streamed(s->pb)) { + av_log(s, AV_LOG_ERROR, "muxer does not support non seekable output\n"); + return -1; + } +@@ -1484,17 +1472,20 @@ + track->enc = st->codec; + track->language = ff_mov_iso639_to_lang(st->language, mov->mode != MODE_MOV); + track->mode = mov->mode; ++ track->tag = mov_find_codec_tag(s, track); ++ if (!track->tag) { ++ av_log(s, AV_LOG_ERROR, "track %d: could not find tag for codec\n", i); ++ return -1; ++ } + if(st->codec->codec_type == CODEC_TYPE_VIDEO){ +- track->tag = mov_find_video_codec_tag(s, track); + track->timescale = st->codec->time_base.den; + av_set_pts_info(st, 64, 1, st->codec->time_base.den); +- if (track->timescale > 100000) +- av_log(NULL, AV_LOG_WARNING, ++ if (track->mode == MODE_MOV && track->timescale > 100000) ++ av_log(s, AV_LOG_WARNING, + "WARNING codec timebase is very high. If duration is too long,\n" + "file may not be playable by quicktime. Specify a shorter timebase\n" + "or choose different container.\n"); + }else if(st->codec->codec_type == CODEC_TYPE_AUDIO){ +- track->tag = mov_find_audio_codec_tag(s, track); + track->timescale = st->codec->sample_rate; + av_set_pts_info(st, 64, 1, st->codec->sample_rate); + if(!st->codec->frame_size){ +@@ -1520,13 +1511,13 @@ + static int mov_write_packet(AVFormatContext *s, AVPacket *pkt) + { + MOVContext *mov = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + MOVTrack *trk = &mov->tracks[pkt->stream_index]; + AVCodecContext *enc = trk->enc; + unsigned int samplesInChunk = 0; + int size= pkt->size; + +- if (url_is_streamed(&s->pb)) return 0; /* Can't handle that */ ++ if (url_is_streamed(s->pb)) return 0; /* Can't handle that */ + if (!size) return 0; /* Discard 0 sized packets */ + + if (enc->codec_id == CODEC_ID_AMR_NB) { +@@ -1558,9 +1549,18 @@ + if (enc->codec_id == CODEC_ID_H264 && trk->vosLen > 0 && *(uint8_t *)trk->vosData != 1) { + /* from x264 or from bytestream h264 */ + /* nal reformating needed */ +- avc_parse_nal_units(&pkt->data, &pkt->size); ++ int ret = ff_avc_parse_nal_units(pkt->data, &pkt->data, &pkt->size); ++ if (ret < 0) ++ return ret; + assert(pkt->size); + size = pkt->size; ++ } else if (enc->codec_id == CODEC_ID_DNXHD && !trk->vosLen) { ++ /* copy frame header to create needed atoms */ ++ if (size < 640) ++ return -1; ++ trk->vosLen = 640; ++ trk->vosData = av_malloc(trk->vosLen); ++ memcpy(trk->vosData, pkt->data, 640); + } + + if (!(trk->entry % MOV_INDEX_CLUSTER_SIZE)) { +@@ -1597,7 +1597,7 @@ + static int mov_write_trailer(AVFormatContext *s) + { + MOVContext *mov = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + int res = 0; + int i; + +@@ -1643,6 +1643,7 @@ + mov_write_packet, + mov_write_trailer, + .flags = AVFMT_GLOBALHEADER, ++ .codec_tag = (const AVCodecTag*[]){codec_movvideo_tags, codec_movaudio_tags, 0}, + }; + #endif + #ifdef CONFIG_TGP_MUXER +@@ -1658,6 +1659,7 @@ + mov_write_packet, + mov_write_trailer, + .flags = AVFMT_GLOBALHEADER, ++ .codec_tag = (const AVCodecTag*[]){codec_3gp_tags, 0}, + }; + #endif + #ifdef CONFIG_MP4_MUXER +@@ -1673,6 +1675,7 @@ + mov_write_packet, + mov_write_trailer, + .flags = AVFMT_GLOBALHEADER, ++ .codec_tag = (const AVCodecTag*[]){ff_mp4_obj_type, 0}, + }; + #endif + #ifdef CONFIG_PSP_MUXER +@@ -1688,6 +1691,7 @@ + mov_write_packet, + mov_write_trailer, + .flags = AVFMT_GLOBALHEADER, ++ .codec_tag = (const AVCodecTag*[]){ff_mp4_obj_type, 0}, + }; + #endif + #ifdef CONFIG_TG2_MUXER +@@ -1703,5 +1707,6 @@ + mov_write_packet, + mov_write_trailer, + .flags = AVFMT_GLOBALHEADER, ++ .codec_tag = (const AVCodecTag*[]){codec_3gp_tags, 0}, + }; + #endif +diff -u mplayer-1.0~rc2-12/libavformat/mp3.c ffmpeg-free-0.svn20080206/libavformat/mp3.c +--- mplayer-1.0~rc2-12/libavformat/mp3.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/mp3.c 2008-02-04 02:01:52.000000000 +0100 +@@ -21,6 +21,7 @@ + #include "avformat.h" + #include "mpegaudio.h" + #include "avstring.h" ++#include "mpegaudiodecheader.h" + + #define ID3v2_HEADER_SIZE 10 + #define ID3v1_TAG_SIZE 128 +@@ -189,20 +190,20 @@ + taglen--; /* account for encoding type byte */ + dstlen--; /* Leave space for zero terminator */ + +- switch(get_byte(&s->pb)) { /* encoding type */ ++ switch(get_byte(s->pb)) { /* encoding type */ + + case 0: /* ISO-8859-1 (0 - 255 maps directly into unicode) */ + q = dst; + while(taglen--) { + uint8_t tmp; +- PUT_UTF8(get_byte(&s->pb), tmp, if (q - dst < dstlen - 1) *q++ = tmp;) ++ PUT_UTF8(get_byte(s->pb), tmp, if (q - dst < dstlen - 1) *q++ = tmp;) + } + *q = '\0'; + break; + + case 3: /* UTF-8 */ + len = FFMIN(taglen, dstlen); +- get_buffer(&s->pb, dst, len); ++ get_buffer(s->pb, dst, len); + dst[len] = 0; + break; + } +@@ -251,23 +252,23 @@ + } + + if(isv34 && flags & 0x40) /* Extended header present, just skip over it */ +- url_fskip(&s->pb, id3v2_get_size(&s->pb, 4)); ++ url_fskip(s->pb, id3v2_get_size(s->pb, 4)); + + while(len >= taghdrlen) { + if(isv34) { +- tag = get_be32(&s->pb); +- tlen = id3v2_get_size(&s->pb, 4); +- get_be16(&s->pb); /* flags */ ++ tag = get_be32(s->pb); ++ tlen = id3v2_get_size(s->pb, 4); ++ get_be16(s->pb); /* flags */ + } else { +- tag = get_be24(&s->pb); +- tlen = id3v2_get_size(&s->pb, 3); ++ tag = get_be24(s->pb); ++ tlen = id3v2_get_size(s->pb, 3); + } + len -= taghdrlen + tlen; + + if(len < 0) + break; + +- next = url_ftell(&s->pb) + tlen; ++ next = url_ftell(s->pb) + tlen; + + switch(tag) { + case MKBETAG('T', 'I', 'T', '2'): +@@ -297,21 +298,21 @@ + break; + case 0: + /* padding, skip to end */ +- url_fskip(&s->pb, len); ++ url_fskip(s->pb, len); + len = 0; + continue; + } + /* Skip to end of tag */ +- url_fseek(&s->pb, next, SEEK_SET); ++ url_fseek(s->pb, next, SEEK_SET); + } + + if(version == 4 && flags & 0x10) /* Footer preset, always 10 bytes, skip over it */ +- url_fskip(&s->pb, 10); ++ url_fskip(s->pb, 10); + return; + + error: + av_log(s, AV_LOG_INFO, "ID3v2.%d tag skipped, cannot handle %s\n", version, reason); +- url_fskip(&s->pb, len); ++ url_fskip(s->pb, len); + } + + static void id3v1_get_string(char *str, int str_size, +@@ -402,9 +403,9 @@ + + max_frames = 0; + buf = p->buf; +- end = buf + FFMIN(4096, p->buf_size - sizeof(uint32_t)); ++ end = buf + p->buf_size - sizeof(uint32_t); + +- for(; buf < end; buf++) { ++ for(; buf < end; buf= buf2+1) { + buf2 = buf; + + for(frames = 0; buf2 < end; frames++) { +@@ -419,17 +420,66 @@ + first_frames= frames; + } + if (first_frames>=3) return AVPROBE_SCORE_MAX/2+1; ++ else if(max_frames>500)return AVPROBE_SCORE_MAX/2; + else if(max_frames>=3) return AVPROBE_SCORE_MAX/4; + else if(max_frames>=1) return 1; + else return 0; + } + ++/** ++ * Try to find Xing/Info/VBRI tags and compute duration from info therein ++ */ ++static void mp3_parse_vbr_tags(AVFormatContext *s, AVStream *st, offset_t base) ++{ ++ uint32_t v, spf; ++ int frames = -1; /* Total number of frames in file */ ++ const offset_t xing_offtbl[2][2] = {{32, 17}, {17,9}}; ++ MPADecodeContext c; ++ ++ v = get_be32(s->pb); ++ if(ff_mpa_check_header(v) < 0) ++ return; ++ ++ ff_mpegaudio_decode_header(&c, v); ++ if(c.layer != 3) ++ return; ++ ++ /* Check for Xing / Info tag */ ++ url_fseek(s->pb, xing_offtbl[c.lsf == 1][c.nb_channels == 1], SEEK_CUR); ++ v = get_be32(s->pb); ++ if(v == MKBETAG('X', 'i', 'n', 'g') || v == MKBETAG('I', 'n', 'f', 'o')) { ++ v = get_be32(s->pb); ++ if(v & 0x1) ++ frames = get_be32(s->pb); ++ } ++ ++ /* Check for VBRI tag (always 32 bytes after end of mpegaudio header) */ ++ url_fseek(s->pb, base + 4 + 32, SEEK_SET); ++ v = get_be32(s->pb); ++ if(v == MKBETAG('V', 'B', 'R', 'I')) { ++ /* Check tag version */ ++ if(get_be16(s->pb) == 1) { ++ /* skip delay, quality and total bytes */ ++ url_fseek(s->pb, 8, SEEK_CUR); ++ frames = get_be32(s->pb); ++ } ++ } ++ ++ if(frames < 0) ++ return; ++ ++ spf = c.lsf ? 576 : 1152; /* Samples per frame, layer 3 */ ++ st->duration = av_rescale_q(frames, (AVRational){spf, c.sample_rate}, ++ st->time_base); ++} ++ + static int mp3_read_header(AVFormatContext *s, + AVFormatParameters *ap) + { + AVStream *st; + uint8_t buf[ID3v1_TAG_SIZE]; + int len, ret, filesize; ++ offset_t off; + + st = av_new_stream(s, 0); + if (!st) +@@ -438,23 +488,24 @@ + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_id = CODEC_ID_MP3; + st->need_parsing = AVSTREAM_PARSE_FULL; ++ st->start_time = 0; + + /* try to get the TAG */ +- if (!url_is_streamed(&s->pb)) { ++ if (!url_is_streamed(s->pb)) { + /* XXX: change that */ +- filesize = url_fsize(&s->pb); ++ filesize = url_fsize(s->pb); + if (filesize > 128) { +- url_fseek(&s->pb, filesize - 128, SEEK_SET); +- ret = get_buffer(&s->pb, buf, ID3v1_TAG_SIZE); ++ url_fseek(s->pb, filesize - 128, SEEK_SET); ++ ret = get_buffer(s->pb, buf, ID3v1_TAG_SIZE); + if (ret == ID3v1_TAG_SIZE) { + id3v1_parse_tag(s, buf); + } +- url_fseek(&s->pb, 0, SEEK_SET); ++ url_fseek(s->pb, 0, SEEK_SET); + } + } + + /* if ID3v2 header found, skip it */ +- ret = get_buffer(&s->pb, buf, ID3v2_HEADER_SIZE); ++ ret = get_buffer(s->pb, buf, ID3v2_HEADER_SIZE); + if (ret != ID3v2_HEADER_SIZE) + return -1; + if (id3v2_match(buf)) { +@@ -465,9 +516,13 @@ + (buf[9] & 0x7f); + id3v2_parse(s, len, buf[3], buf[5]); + } else { +- url_fseek(&s->pb, 0, SEEK_SET); ++ url_fseek(s->pb, 0, SEEK_SET); + } + ++ off = url_ftell(s->pb); ++ mp3_parse_vbr_tags(s, st, off); ++ url_fseek(s->pb, off, SEEK_SET); ++ + /* the parameters will be extracted from the compressed bitstream */ + return 0; + } +@@ -481,7 +536,7 @@ + + size= MP3_PACKET_SIZE; + +- ret= av_get_packet(&s->pb, pkt, size); ++ ret= av_get_packet(s->pb, pkt, size); + + pkt->stream_index = 0; + if (ret <= 0) { +@@ -503,20 +558,20 @@ + + static void id3v2_put_size(AVFormatContext *s, int size) + { +- put_byte(&s->pb, size >> 21 & 0x7f); +- put_byte(&s->pb, size >> 14 & 0x7f); +- put_byte(&s->pb, size >> 7 & 0x7f); +- put_byte(&s->pb, size & 0x7f); ++ put_byte(s->pb, size >> 21 & 0x7f); ++ put_byte(s->pb, size >> 14 & 0x7f); ++ put_byte(s->pb, size >> 7 & 0x7f); ++ put_byte(s->pb, size & 0x7f); + } + +-static void id3v2_put_ttag(AVFormatContext *s, char *string, uint32_t tag) ++static void id3v2_put_ttag(AVFormatContext *s, const char *string, uint32_t tag) + { + int len = strlen(string); +- put_be32(&s->pb, tag); ++ put_be32(s->pb, tag); + id3v2_put_size(s, len + 1); +- put_be16(&s->pb, 0); +- put_byte(&s->pb, 3); /* UTF-8 */ +- put_buffer(&s->pb, string, len); ++ put_be16(s->pb, 0); ++ put_byte(s->pb, 3); /* UTF-8 */ ++ put_buffer(s->pb, string, len); + } + + +@@ -528,9 +583,12 @@ + { + int totlen = 0; + char tracktxt[10]; ++ char yeartxt[10]; + + if(s->track) +- snprintf(tracktxt, sizeof(tracktxt) - 1, "%d", s->track); ++ snprintf(tracktxt, sizeof(tracktxt), "%d", s->track); ++ if(s->year) ++ snprintf( yeartxt, sizeof(yeartxt) , "%d", s->year ); + + if(s->title[0]) totlen += 11 + strlen(s->title); + if(s->author[0]) totlen += 11 + strlen(s->author); +@@ -538,15 +596,16 @@ + if(s->genre[0]) totlen += 11 + strlen(s->genre); + if(s->copyright[0]) totlen += 11 + strlen(s->copyright); + if(s->track) totlen += 11 + strlen(tracktxt); ++ if(s->year) totlen += 11 + strlen(yeartxt); + if(!(s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT)) + totlen += strlen(LIBAVFORMAT_IDENT) + 11; + + if(totlen == 0) + return 0; + +- put_be32(&s->pb, MKBETAG('I', 'D', '3', 0x04)); /* ID3v2.4 */ +- put_byte(&s->pb, 0); +- put_byte(&s->pb, 0); /* flags */ ++ put_be32(s->pb, MKBETAG('I', 'D', '3', 0x04)); /* ID3v2.4 */ ++ put_byte(s->pb, 0); ++ put_byte(s->pb, 0); /* flags */ + + id3v2_put_size(s, totlen); + +@@ -556,6 +615,7 @@ + if(s->genre[0]) id3v2_put_ttag(s, s->genre, MKBETAG('T', 'C', 'O', 'N')); + if(s->copyright[0]) id3v2_put_ttag(s, s->copyright, MKBETAG('T', 'C', 'O', 'P')); + if(s->track) id3v2_put_ttag(s, tracktxt, MKBETAG('T', 'R', 'C', 'K')); ++ if(s->year) id3v2_put_ttag(s, yeartxt, MKBETAG('T', 'Y', 'E', 'R')); + if(!(s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT)) + id3v2_put_ttag(s, LIBAVFORMAT_IDENT, MKBETAG('T', 'E', 'N', 'C')); + return 0; +@@ -563,8 +623,8 @@ + + static int mp3_write_packet(struct AVFormatContext *s, AVPacket *pkt) + { +- put_buffer(&s->pb, pkt->data, pkt->size); +- put_flush_packet(&s->pb); ++ put_buffer(s->pb, pkt->data, pkt->size); ++ put_flush_packet(s->pb); + return 0; + } + +@@ -575,8 +635,8 @@ + /* write the id3v1 tag */ + if (s->title[0] != '\0') { + id3v1_create_tag(s, buf); +- put_buffer(&s->pb, buf, ID3v1_TAG_SIZE); +- put_flush_packet(&s->pb); ++ put_buffer(s->pb, buf, ID3v1_TAG_SIZE); ++ put_flush_packet(s->pb); + } + return 0; + } +Only in ffmpeg-free-0.svn20080206/libavformat: mpc8.c +diff -u mplayer-1.0~rc2-12/libavformat/mpc.c ffmpeg-free-0.svn20080206/libavformat/mpc.c +--- mplayer-1.0~rc2-12/libavformat/mpc.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/mpc.c 2007-11-21 08:41:00.000000000 +0100 +@@ -55,31 +55,31 @@ + AVStream *st; + int t; + +- t = get_le24(&s->pb); ++ t = get_le24(s->pb); + if(t != MKTAG('M', 'P', '+', 0)){ + if(t != MKTAG('I', 'D', '3', 0)){ + av_log(s, AV_LOG_ERROR, "Not a Musepack file\n"); + return -1; + } + /* skip ID3 tags and try again */ +- url_fskip(&s->pb, 3); +- t = get_byte(&s->pb) << 21; +- t |= get_byte(&s->pb) << 14; +- t |= get_byte(&s->pb) << 7; +- t |= get_byte(&s->pb); ++ url_fskip(s->pb, 3); ++ t = get_byte(s->pb) << 21; ++ t |= get_byte(s->pb) << 14; ++ t |= get_byte(s->pb) << 7; ++ t |= get_byte(s->pb); + av_log(s, AV_LOG_DEBUG, "Skipping %d(%X) bytes of ID3 data\n", t, t); +- url_fskip(&s->pb, t); +- if(get_le24(&s->pb) != MKTAG('M', 'P', '+', 0)){ ++ url_fskip(s->pb, t); ++ if(get_le24(s->pb) != MKTAG('M', 'P', '+', 0)){ + av_log(s, AV_LOG_ERROR, "Not a Musepack file\n"); + return -1; + } + } +- c->ver = get_byte(&s->pb); ++ c->ver = get_byte(s->pb); + if(c->ver != 0x07 && c->ver != 0x17){ + av_log(s, AV_LOG_ERROR, "Can demux Musepack SV7, got version %02X\n", c->ver); + return -1; + } +- c->fcount = get_le32(&s->pb); ++ c->fcount = get_le32(s->pb); + if((int64_t)c->fcount * sizeof(MPCFrame) >= UINT_MAX){ + av_log(s, AV_LOG_ERROR, "Too many frames, seeking is not possible\n"); + return -1; +@@ -100,7 +100,7 @@ + + st->codec->extradata_size = 16; + st->codec->extradata = av_mallocz(st->codec->extradata_size+FF_INPUT_BUFFER_PADDING_SIZE); +- get_buffer(&s->pb, st->codec->extradata, 16); ++ get_buffer(s->pb, st->codec->extradata, 16); + st->codec->sample_rate = mpc_rate[st->codec->extradata[2] & 3]; + av_set_pts_info(st, 32, MPC_FRAMESIZE, st->codec->sample_rate); + /* scan for seekpoints */ +@@ -120,22 +120,22 @@ + return -1; + + if(c->curframe != c->lastframe + 1){ +- url_fseek(&s->pb, c->frames[c->curframe].pos, SEEK_SET); ++ url_fseek(s->pb, c->frames[c->curframe].pos, SEEK_SET); + c->curbits = c->frames[c->curframe].skip; + } + c->lastframe = c->curframe; + c->curframe++; + curbits = c->curbits; +- pos = url_ftell(&s->pb); +- tmp = get_le32(&s->pb); ++ pos = url_ftell(s->pb); ++ tmp = get_le32(s->pb); + if(curbits <= 12){ + size2 = (tmp >> (12 - curbits)) & 0xFFFFF; + }else{ +- tmp = (tmp << 32) | get_le32(&s->pb); ++ tmp = (tmp << 32) | get_le32(s->pb); + size2 = (tmp >> (44 - curbits)) & 0xFFFFF; + } + curbits += 20; +- url_fseek(&s->pb, pos, SEEK_SET); ++ url_fseek(s->pb, pos, SEEK_SET); + + size = ((size2 + curbits + 31) & ~31) >> 3; + if(cur == c->frames_noted){ +@@ -155,9 +155,9 @@ + + pkt->stream_index = 0; + pkt->pts = cur; +- ret = get_buffer(&s->pb, pkt->data + 4, size); ++ ret = get_buffer(s->pb, pkt->data + 4, size); + if(c->curbits) +- url_fseek(&s->pb, -4, SEEK_CUR); ++ url_fseek(s->pb, -4, SEEK_CUR); + if(ret < size){ + av_free_packet(pkt); + return AVERROR(EIO); +diff -u mplayer-1.0~rc2-12/libavformat/mpeg.c ffmpeg-free-0.svn20080206/libavformat/mpeg.c +--- mplayer-1.0~rc2-12/libavformat/mpeg.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/mpeg.c 2008-01-14 17:11:08.000000000 +0100 +@@ -32,47 +32,56 @@ + + #define MAX_SYNC_SIZE 100000 + +-static int cdxa_probe(AVProbeData *p) +-{ +- /* check file header */ +- if (p->buf[0] == 'R' && p->buf[1] == 'I' && +- p->buf[2] == 'F' && p->buf[3] == 'F' && +- p->buf[8] == 'C' && p->buf[9] == 'D' && +- p->buf[10] == 'X' && p->buf[11] == 'A') +- return AVPROBE_SCORE_MAX; +- else +- return 0; ++static int check_pes(uint8_t *p, uint8_t *end){ ++ int pes1; ++ int pes2= (p[3] & 0xC0) == 0x80 ++ && (p[4] & 0xC0) != 0x40 ++ &&((p[4] & 0xC0) == 0x00 || (p[4]&0xC0)>>2 == (p[6]&0xF0)); ++ ++ for(p+=3; p 0) return score; +- +- /* Search for MPEG stream */ + for(i=0; ibuf_size; i++){ + code = (code<<8) + p->buf[i]; + if ((code & 0xffffff00) == 0x100) { ++ int pes= check_pes(p->buf+i, p->buf+p->buf_size); ++ + if(code == SYSTEM_HEADER_START_CODE) sys++; + else if(code == PRIVATE_STREAM_1) priv1++; + else if(code == PACK_START_CODE) pspack++; +- else if((code & 0xf0) == VIDEO_ID) vid++; +- else if((code & 0xe0) == AUDIO_ID) audio++; ++ else if((code & 0xf0) == VIDEO_ID && pes) vid++; ++ else if((code & 0xe0) == AUDIO_ID && pes) audio++; ++ ++ else if((code & 0xf0) == VIDEO_ID && !pes) invalid++; ++ else if((code & 0xe0) == AUDIO_ID && !pes) invalid++; + } + } + +- if(vid || audio) /* invalid VDR files nd short PES streams */ ++ if(vid+audio > invalid) /* invalid VDR files nd short PES streams */ + score= AVPROBE_SCORE_MAX/4; + + //av_log(NULL, AV_LOG_ERROR, "%d %d %d %d %d len:%d\n", sys, priv1, pspack,vid, audio, p->buf_size); +- if(sys && sys*9 <= pspack*10) ++ if(sys>invalid && sys*9 <= pspack*10) + return AVPROBE_SCORE_MAX/2+2; // +1 for .mpg +- if((priv1 || vid || audio) && (priv1+vid+audio)*9 <= pspack*10) ++ if(priv1 + vid + audio > invalid && (priv1+vid+audio)*9 <= pspack*10) + return AVPROBE_SCORE_MAX/2+2; // +1 for .mpg + if((!!vid ^ !!audio) && (audio+vid > 1) && !sys && !pspack && p->buf_size>2048) /* PES stream */ + return AVPROBE_SCORE_MAX/2+2; +@@ -85,32 +94,38 @@ + typedef struct MpegDemuxContext { + int32_t header_state; + unsigned char psm_es_type[256]; ++ int sofdec; + } MpegDemuxContext; + + static int mpegps_read_header(AVFormatContext *s, + AVFormatParameters *ap) + { + MpegDemuxContext *m = s->priv_data; ++ const char *sofdec = "Sofdec"; ++ int v, i = 0; ++ + m->header_state = 0xff; + s->ctx_flags |= AVFMTCTX_NOHEADER; + ++ m->sofdec = -1; ++ do { ++ v = get_byte(s->pb); ++ m->header_state = m->header_state << 8 | v; ++ m->sofdec++; ++ } while (v == sofdec[i] && i++ < 6); ++ + /* no need to do more */ + return 0; + } + + static int64_t get_pts(ByteIOContext *pb, int c) + { +- int64_t pts; +- int val; ++ uint8_t buf[5]; + +- if (c < 0) +- c = get_byte(pb); +- pts = (int64_t)((c >> 1) & 0x07) << 30; +- val = get_be16(pb); +- pts |= (int64_t)(val >> 1) << 15; +- val = get_be16(pb); +- pts |= (int64_t)(val >> 1); +- return pts; ++ buf[0] = c<0 ? get_byte(pb) : c; ++ get_buffer(pb, buf+1, 4); ++ ++ return ff_parse_pes_pts(buf); + } + + static int find_next_start_code(ByteIOContext *pb, int *size_ptr, +@@ -220,32 +235,46 @@ + int len, size, startcode, c, flags, header_len; + int pes_ext, ext2_len, id_ext, skip; + int64_t pts, dts; +- int64_t last_sync= url_ftell(&s->pb); ++ int64_t last_sync= url_ftell(s->pb); + + error_redo: +- url_fseek(&s->pb, last_sync, SEEK_SET); ++ url_fseek(s->pb, last_sync, SEEK_SET); + redo: + /* next start code (should be immediately after) */ + m->header_state = 0xff; + size = MAX_SYNC_SIZE; +- startcode = find_next_start_code(&s->pb, &size, &m->header_state); +- last_sync = url_ftell(&s->pb); +- //printf("startcode=%x pos=0x%"PRIx64"\n", startcode, url_ftell(&s->pb)); ++ startcode = find_next_start_code(s->pb, &size, &m->header_state); ++ last_sync = url_ftell(s->pb); ++ //printf("startcode=%x pos=0x%"PRIx64"\n", startcode, url_ftell(s->pb)); + if (startcode < 0) + return AVERROR(EIO); + if (startcode == PACK_START_CODE) + goto redo; + if (startcode == SYSTEM_HEADER_START_CODE) + goto redo; +- if (startcode == PADDING_STREAM || +- startcode == PRIVATE_STREAM_2) { +- /* skip them */ +- len = get_be16(&s->pb); +- url_fskip(&s->pb, len); ++ if (startcode == PADDING_STREAM) { ++ url_fskip(s->pb, get_be16(s->pb)); ++ goto redo; ++ } ++ if (startcode == PRIVATE_STREAM_2) { ++ len = get_be16(s->pb); ++ if (!m->sofdec) { ++ while (len-- >= 6) { ++ if (get_byte(s->pb) == 'S') { ++ uint8_t buf[5]; ++ get_buffer(s->pb, buf, sizeof(buf)); ++ m->sofdec = !memcmp(buf, "ofdec", 5); ++ len -= sizeof(buf); ++ break; ++ } ++ } ++ m->sofdec -= !m->sofdec; ++ } ++ url_fskip(s->pb, len); + goto redo; + } + if (startcode == PROGRAM_STREAM_MAP) { +- mpegps_psm_parse(m, &s->pb); ++ mpegps_psm_parse(m, s->pb); + goto redo; + } + +@@ -255,16 +284,16 @@ + (startcode == 0x1bd) || (startcode == 0x1fd))) + goto redo; + if (ppos) { +- *ppos = url_ftell(&s->pb) - 4; ++ *ppos = url_ftell(s->pb) - 4; + } +- len = get_be16(&s->pb); ++ len = get_be16(s->pb); + pts = + dts = AV_NOPTS_VALUE; + /* stuffing */ + for(;;) { + if (len < 1) + goto error_redo; +- c = get_byte(&s->pb); ++ c = get_byte(s->pb); + len--; + /* XXX: for mpeg1, should test only bit 7 */ + if (c != 0xff) +@@ -272,15 +301,15 @@ + } + if ((c & 0xc0) == 0x40) { + /* buffer scale & size */ +- get_byte(&s->pb); +- c = get_byte(&s->pb); ++ get_byte(s->pb); ++ c = get_byte(s->pb); + len -= 2; + } + if ((c & 0xe0) == 0x20) { +- dts = pts = get_pts(&s->pb, c); ++ dts = pts = get_pts(s->pb, c); + len -= 4; + if (c & 0x10){ +- dts = get_pts(&s->pb, -1); ++ dts = get_pts(s->pb, -1); + len -= 5; + } + } else if ((c & 0xc0) == 0x80) { +@@ -291,22 +320,22 @@ + goto redo; + } + #endif +- flags = get_byte(&s->pb); +- header_len = get_byte(&s->pb); ++ flags = get_byte(s->pb); ++ header_len = get_byte(s->pb); + len -= 2; + if (header_len > len) + goto error_redo; + len -= header_len; + if (flags & 0x80) { +- dts = pts = get_pts(&s->pb, -1); ++ dts = pts = get_pts(s->pb, -1); + header_len -= 5; + if (flags & 0x40) { +- dts = get_pts(&s->pb, -1); ++ dts = get_pts(s->pb, -1); + header_len -= 5; + } + } + if (flags & 0x01) { /* PES extension */ +- pes_ext = get_byte(&s->pb); ++ pes_ext = get_byte(s->pb); + header_len--; + if (pes_ext & 0x40) { /* pack header - should be zero in PS */ + goto error_redo; +@@ -314,14 +343,14 @@ + /* Skip PES private data, program packet sequence counter and P-STD buffer */ + skip = (pes_ext >> 4) & 0xb; + skip += skip & 0x9; +- url_fskip(&s->pb, skip); ++ url_fskip(s->pb, skip); + header_len -= skip; + + if (pes_ext & 0x01) { /* PES extension 2 */ +- ext2_len = get_byte(&s->pb); ++ ext2_len = get_byte(s->pb); + header_len--; + if ((ext2_len & 0x7f) > 0) { +- id_ext = get_byte(&s->pb); ++ id_ext = get_byte(s->pb); + if ((id_ext & 0x80) == 0) + startcode = ((startcode & 0xff) << 8) | id_ext; + header_len--; +@@ -330,23 +359,23 @@ + } + if(header_len < 0) + goto error_redo; +- url_fskip(&s->pb, header_len); ++ url_fskip(s->pb, header_len); + } + else if( c!= 0xf ) + goto redo; + + if (startcode == PRIVATE_STREAM_1 && !m->psm_es_type[startcode & 0xff]) { +- startcode = get_byte(&s->pb); ++ startcode = get_byte(s->pb); + len--; + if (startcode >= 0x80 && startcode <= 0xcf) { + /* audio: skip header */ +- get_byte(&s->pb); +- get_byte(&s->pb); +- get_byte(&s->pb); ++ get_byte(s->pb); ++ get_byte(s->pb); ++ get_byte(s->pb); + len -= 3; + if (startcode >= 0xb0 && startcode <= 0xbf) { + /* MLP/TrueHD audio has a 4-byte header */ +- get_byte(&s->pb); ++ get_byte(s->pb); + len--; + } + } +@@ -356,7 +385,9 @@ + if(dts != AV_NOPTS_VALUE && ppos){ + int i; + for(i=0; inb_streams; i++){ +- if(startcode == s->streams[i]->id) { ++ if(startcode == s->streams[i]->id && ++ !url_is_streamed(s->pb) /* index useless on streams anyway */) { ++ ff_reduce_index(s, i); + av_add_index_entry(s->streams[i], *ppos, dts, 0, 0, AVINDEX_KEYFRAME /* FIXME keyframe? */); + } + } +@@ -418,8 +449,8 @@ + } else if (startcode >= 0x1e0 && startcode <= 0x1ef) { + static const unsigned char avs_seqh[4] = { 0, 0, 1, 0xb0 }; + unsigned char buf[8]; +- get_buffer(&s->pb, buf, 8); +- url_fseek(&s->pb, -8, SEEK_CUR); ++ get_buffer(s->pb, buf, 8); ++ url_fseek(s->pb, -8, SEEK_CUR); + if(!memcmp(buf, avs_seqh, 4) && (buf[6] != 0 || buf[7] != 1)) + codec_id = CODEC_ID_CAVS; + else +@@ -427,7 +458,7 @@ + type = CODEC_TYPE_VIDEO; + } else if (startcode >= 0x1c0 && startcode <= 0x1df) { + type = CODEC_TYPE_AUDIO; +- codec_id = CODEC_ID_MP2; ++ codec_id = m->sofdec > 0 ? CODEC_ID_ADPCM_ADX : CODEC_ID_MP2; + } else if (startcode >= 0x80 && startcode <= 0x87) { + type = CODEC_TYPE_AUDIO; + codec_id = CODEC_ID_AC3; +@@ -455,7 +486,7 @@ + } else { + skip: + /* skip packet */ +- url_fskip(&s->pb, len); ++ url_fskip(s->pb, len); + goto redo; + } + /* no stream found: add a new stream */ +@@ -476,9 +507,9 @@ + audio data */ + if (len <= 3) + goto skip; +- get_byte(&s->pb); /* emphasis (1), muse(1), reserved(1), frame number(5) */ +- b1 = get_byte(&s->pb); /* quant (2), freq(2), reserved(1), channels(3) */ +- get_byte(&s->pb); /* dynamic range control (0x80 = off) */ ++ get_byte(s->pb); /* emphasis (1), muse(1), reserved(1), frame number(5) */ ++ b1 = get_byte(s->pb); /* quant (2), freq(2), reserved(1), channels(3) */ ++ get_byte(s->pb); /* dynamic range control (0x80 = off) */ + len -= 3; + freq = (b1 >> 4) & 3; + st->codec->sample_rate = lpcm_freq_tab[freq]; +@@ -486,7 +517,7 @@ + st->codec->bit_rate = st->codec->channels * st->codec->sample_rate * 2; + } + av_new_packet(pkt, len); +- get_buffer(&s->pb, pkt->data, pkt->size); ++ get_buffer(s->pb, pkt->data, pkt->size); + pkt->pts = pts; + pkt->dts = dts; + pkt->stream_index = st->index; +@@ -513,7 +544,7 @@ + #ifdef DEBUG_SEEK + printf("read_dts: pos=0x%"PRIx64" next=%d -> ", pos, find_next); + #endif +- url_fseek(&s->pb, pos, SEEK_SET); ++ url_fseek(s->pb, pos, SEEK_SET); + for(;;) { + len = mpegps_read_pes_header(s, &pos, &startcode, &pts, &dts); + if (len < 0) { +@@ -526,7 +557,7 @@ + dts != AV_NOPTS_VALUE) { + break; + } +- url_fskip(&s->pb, len); ++ url_fskip(s->pb, len); + } + #ifdef DEBUG_SEEK + printf("pos=0x%"PRIx64" dts=0x%"PRIx64" %0.3f\n", pos, dts, dts / 90000.0); +diff -u mplayer-1.0~rc2-12/libavformat/mpegenc.c ffmpeg-free-0.svn20080206/libavformat/mpegenc.c +--- mplayer-1.0~rc2-12/libavformat/mpegenc.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/mpegenc.c 2008-01-31 01:27:51.000000000 +0100 +@@ -299,9 +299,9 @@ + s->packet_number = 0; + s->is_vcd = (ENABLE_MPEG1VCD_MUXER && ctx->oformat == &mpeg1vcd_muxer); + s->is_svcd = (ENABLE_MPEG2SVCD_MUXER && ctx->oformat == &mpeg2svcd_muxer); +- s->is_mpeg2 = (ENABLE_MPEG2VOB_MUXER && ctx->oformat == &mpeg2vob_muxer || +- ENABLE_MPEG2DVD_MUXER && ctx->oformat == &mpeg2dvd_muxer || +- ENABLE_MPEG2SVCD_MUXER && ctx->oformat == &mpeg2svcd_muxer); ++ s->is_mpeg2 = ((ENABLE_MPEG2VOB_MUXER && ctx->oformat == &mpeg2vob_muxer) || ++ (ENABLE_MPEG2DVD_MUXER && ctx->oformat == &mpeg2dvd_muxer) || ++ (ENABLE_MPEG2SVCD_MUXER && ctx->oformat == &mpeg2svcd_muxer)); + s->is_dvd = (ENABLE_MPEG2DVD_MUXER && ctx->oformat == &mpeg2dvd_muxer); + + if(ctx->packet_size) +@@ -690,19 +690,19 @@ + size = put_system_header(ctx, buf_ptr, 0); + buf_ptr += size; + size = buf_ptr - buffer; +- put_buffer(&ctx->pb, buffer, size); ++ put_buffer(ctx->pb, buffer, size); + +- put_be32(&ctx->pb, PRIVATE_STREAM_2); +- put_be16(&ctx->pb, 0x03d4); // length +- put_byte(&ctx->pb, 0x00); // substream ID, 00=PCI ++ put_be32(ctx->pb, PRIVATE_STREAM_2); ++ put_be16(ctx->pb, 0x03d4); // length ++ put_byte(ctx->pb, 0x00); // substream ID, 00=PCI + for (i = 0; i < 979; i++) +- put_byte(&ctx->pb, 0x00); ++ put_byte(ctx->pb, 0x00); + +- put_be32(&ctx->pb, PRIVATE_STREAM_2); +- put_be16(&ctx->pb, 0x03fa); // length +- put_byte(&ctx->pb, 0x01); // substream ID, 01=DSI ++ put_be32(ctx->pb, PRIVATE_STREAM_2); ++ put_be16(ctx->pb, 0x03fa); // length ++ put_byte(ctx->pb, 0x01); // substream ID, 01=DSI + for (i = 0; i < 1017; i++) +- put_byte(&ctx->pb, 0x00); ++ put_byte(ctx->pb, 0x00); + + memset(buffer, 0, 128); + buf_ptr = buffer; +@@ -725,7 +725,7 @@ + } + } + size = buf_ptr - buffer; +- put_buffer(&ctx->pb, buffer, size); ++ put_buffer(ctx->pb, buffer, size); + + packet_size = s->packet_size - size; + +@@ -830,16 +830,16 @@ + + nb_frames= get_nb_frames(ctx, stream, payload_size - stuffing_size); + +- put_be32(&ctx->pb, startcode); ++ put_be32(ctx->pb, startcode); + +- put_be16(&ctx->pb, packet_size); ++ put_be16(ctx->pb, packet_size); + + if (!s->is_mpeg2) + for(i=0;ipb, 0xff); ++ put_byte(ctx->pb, 0xff); + + if (s->is_mpeg2) { +- put_byte(&ctx->pb, 0x80); /* mpeg2 id */ ++ put_byte(ctx->pb, 0x80); /* mpeg2 id */ + + pes_flags=0; + +@@ -856,64 +856,64 @@ + if (stream->packet_number == 0) + pes_flags |= 0x01; + +- put_byte(&ctx->pb, pes_flags); /* flags */ +- put_byte(&ctx->pb, header_len - 3 + stuffing_size); ++ put_byte(ctx->pb, pes_flags); /* flags */ ++ put_byte(ctx->pb, header_len - 3 + stuffing_size); + + if (pes_flags & 0x80) /*write pts*/ +- put_timestamp(&ctx->pb, (pes_flags & 0x40) ? 0x03 : 0x02, pts); ++ put_timestamp(ctx->pb, (pes_flags & 0x40) ? 0x03 : 0x02, pts); + if (pes_flags & 0x40) /*write dts*/ +- put_timestamp(&ctx->pb, 0x01, dts); ++ put_timestamp(ctx->pb, 0x01, dts); + + if (pes_flags & 0x01) { /*write pes extension*/ +- put_byte(&ctx->pb, 0x10); /* flags */ ++ put_byte(ctx->pb, 0x10); /* flags */ + + /* P-STD buffer info */ + if (id == AUDIO_ID) +- put_be16(&ctx->pb, 0x4000 | stream->max_buffer_size/128); ++ put_be16(ctx->pb, 0x4000 | stream->max_buffer_size/128); + else +- put_be16(&ctx->pb, 0x6000 | stream->max_buffer_size/1024); ++ put_be16(ctx->pb, 0x6000 | stream->max_buffer_size/1024); + } + + } else { + if (pts != AV_NOPTS_VALUE) { + if (dts != pts) { +- put_timestamp(&ctx->pb, 0x03, pts); +- put_timestamp(&ctx->pb, 0x01, dts); ++ put_timestamp(ctx->pb, 0x03, pts); ++ put_timestamp(ctx->pb, 0x01, dts); + } else { +- put_timestamp(&ctx->pb, 0x02, pts); ++ put_timestamp(ctx->pb, 0x02, pts); + } + } else { +- put_byte(&ctx->pb, 0x0f); ++ put_byte(ctx->pb, 0x0f); + } + } + + if (s->is_mpeg2) { + /* special stuffing byte that is always written + to prevent accidental generation of start codes. */ +- put_byte(&ctx->pb, 0xff); ++ put_byte(ctx->pb, 0xff); + + for(i=0;ipb, 0xff); ++ put_byte(ctx->pb, 0xff); + } + + if (startcode == PRIVATE_STREAM_1) { +- put_byte(&ctx->pb, id); ++ put_byte(ctx->pb, id); + if (id >= 0xa0) { + /* LPCM (XXX: check nb_frames) */ +- put_byte(&ctx->pb, 7); +- put_be16(&ctx->pb, 4); /* skip 3 header bytes */ +- put_byte(&ctx->pb, stream->lpcm_header[0]); +- put_byte(&ctx->pb, stream->lpcm_header[1]); +- put_byte(&ctx->pb, stream->lpcm_header[2]); ++ put_byte(ctx->pb, 7); ++ put_be16(ctx->pb, 4); /* skip 3 header bytes */ ++ put_byte(ctx->pb, stream->lpcm_header[0]); ++ put_byte(ctx->pb, stream->lpcm_header[1]); ++ put_byte(ctx->pb, stream->lpcm_header[2]); + } else if (id >= 0x40) { + /* AC3 */ +- put_byte(&ctx->pb, nb_frames); +- put_be16(&ctx->pb, trailer_size+1); ++ put_byte(ctx->pb, nb_frames); ++ put_be16(ctx->pb, trailer_size+1); + } + } + + /* output data */ +- if(av_fifo_generic_read(&stream->fifo, payload_size - stuffing_size, &put_buffer, &ctx->pb) < 0) ++ if(av_fifo_generic_read(&stream->fifo, payload_size - stuffing_size, &put_buffer, ctx->pb) < 0) + return -1; + stream->bytes_to_iframe -= payload_size - stuffing_size; + }else{ +@@ -922,12 +922,12 @@ + } + + if (pad_packet_bytes > 0) +- put_padding_packet(ctx,&ctx->pb, pad_packet_bytes); ++ put_padding_packet(ctx,ctx->pb, pad_packet_bytes); + + for(i=0;ipb, 0x00); ++ put_byte(ctx->pb, 0x00); + +- put_flush_packet(&ctx->pb); ++ put_flush_packet(ctx->pb); + + s->packet_number++; + +@@ -952,11 +952,11 @@ + int i; + + for(i=0;ipacket_size;i++) +- put_byte(&ctx->pb, 0); ++ put_byte(ctx->pb, 0); + + s->vcd_padding_bytes_written += s->packet_size; + +- put_flush_packet(&ctx->pb); ++ put_flush_packet(ctx->pb); + + /* increasing the packet number is correct. The SCR of the following packs + is calculated from the packet_number and it has to include the padding +@@ -1019,7 +1019,7 @@ + MpegMuxContext *s = ctx->priv_data; + AVStream *st; + StreamInfo *stream; +- int i, avail_space, es_size, trailer_size; ++ int i, avail_space=0, es_size, trailer_size; + int best_i= -1; + int best_score= INT_MIN; + int ignore_constraints=0; +@@ -1206,8 +1206,8 @@ + /* End header according to MPEG1 systems standard. We do not write + it as it is usually not needed by decoders and because it + complicates MPEG stream concatenation. */ +- //put_be32(&ctx->pb, ISO_11172_END_CODE); +- //put_flush_packet(&ctx->pb); ++ //put_be32(ctx->pb, ISO_11172_END_CODE); ++ //put_flush_packet(ctx->pb); + + for(i=0;inb_streams;i++) { + stream = ctx->streams[i]->priv_data; +diff -u mplayer-1.0~rc2-12/libavformat/mpeg.h ffmpeg-free-0.svn20080206/libavformat/mpeg.h +--- mplayer-1.0~rc2-12/libavformat/mpeg.h 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/mpeg.h 2008-01-08 00:32:57.000000000 +0100 +@@ -19,8 +19,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef AVFORMAT_MPEG_H +-#define AVFORMAT_MPEG_H ++#ifndef FFMPEG_MPEG_H ++#define FFMPEG_MPEG_H + + #define PACK_START_CODE ((unsigned int)0x000001ba) + #define SYSTEM_HEADER_START_CODE ((unsigned int)0x000001bb) +@@ -57,4 +57,13 @@ + + static const int lpcm_freq_tab[4] = { 48000, 96000, 44100, 32000 }; + +-#endif /* AVFORMAT_MPEG_H */ ++/** ++ * Parse MPEG-PES five-byte timestamp ++ */ ++static inline int64_t ff_parse_pes_pts(uint8_t *buf) { ++ return (int64_t)(*buf & 0x0e) << 29 | ++ (AV_RB16(buf+1) >> 1) << 15 | ++ AV_RB16(buf+3) >> 1; ++} ++ ++#endif /* FFMPEG_MPEG_H */ +diff -u mplayer-1.0~rc2-12/libavformat/mpegts.c ffmpeg-free-0.svn20080206/libavformat/mpegts.c +--- mplayer-1.0~rc2-12/libavformat/mpegts.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/mpegts.c 2008-01-05 00:09:58.000000000 +0100 +@@ -37,6 +37,7 @@ + static PESContext* add_pes_stream(MpegTSContext *ts, int pid, int pcr_pid, int stream_type); + static AVStream* new_pes_av_stream(PESContext *pes, uint32_t code); + extern void av_set_program_name(AVProgram *program, char *provider_name, char *name); ++extern void av_program_add_stream_index(AVFormatContext *ac, int progid, unsigned int idx); + + enum MpegTSFilterType { + MPEGTS_PES, +@@ -261,7 +262,8 @@ + if (tss->section_h_size != -1 && tss->section_index >= tss->section_h_size) { + tss->end_of_section_reached = 1; + if (!tss->check_crc || +- av_crc(av_crc04C11DB7, -1, tss->section_buf, tss->section_h_size) == 0) ++ av_crc(av_crc_get_table(AV_CRC_32_IEEE), -1, ++ tss->section_buf, tss->section_h_size) == 0) + tss->section_cb(tss1, tss->section_buf, tss->section_h_size); + } + } +@@ -587,16 +589,18 @@ + case STREAM_TYPE_AUDIO_AC3: + case STREAM_TYPE_AUDIO_DTS: + case STREAM_TYPE_SUBTITLE_DVB: +- if(ts->pids[pid]){ +- assert(ts->pids[pid]->type == MPEGTS_PES); ++ if(ts->pids[pid] && ts->pids[pid]->type == MPEGTS_PES){ + pes= ts->pids[pid]->u.pes_filter.opaque; + st= pes->st; + }else{ ++ if (ts->pids[pid]) mpegts_close_filter(ts, ts->pids[pid]); //wrongly added sdt filter probably + pes = add_pes_stream(ts, pid, pcr_pid, stream_type); + if (pes) + st = new_pes_av_stream(pes, 0); + } + add_pid_to_pmt(ts, h->id, pid); ++ if(st) ++ av_program_add_stream_index(ts->stream, h->id, st->index); + break; + default: + /* we ignore the other streams */ +@@ -1095,7 +1099,7 @@ + static int handle_packets(MpegTSContext *ts, int nb_packets) + { + AVFormatContext *s = ts->stream; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + uint8_t packet[TS_PACKET_SIZE]; + int packet_num, ret; + +@@ -1177,7 +1181,7 @@ + AVFormatParameters *ap) + { + MpegTSContext *ts = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + uint8_t buf[1024]; + int len; + int64_t pos; +@@ -1240,7 +1244,7 @@ + nb_pcrs = 0; + nb_packets = 0; + for(;;) { +- ret = read_packet(&s->pb, packet, ts->raw_packet_size); ++ ret = read_packet(s->pb, packet, ts->raw_packet_size); + if (ret < 0) + return -1; + pid = AV_RB16(packet + 1) & 0x1fff; +@@ -1288,8 +1292,8 @@ + + if (av_new_packet(pkt, TS_PACKET_SIZE) < 0) + return AVERROR(ENOMEM); +- pkt->pos= url_ftell(&s->pb); +- ret = read_packet(&s->pb, pkt->data, ts->raw_packet_size); ++ pkt->pos= url_ftell(s->pb); ++ ret = read_packet(s->pb, pkt->data, ts->raw_packet_size); + if (ret < 0) { + av_free_packet(pkt); + return ret; +@@ -1298,10 +1302,10 @@ + /* compute exact PCR for each packet */ + if (parse_pcr(&pcr_h, &pcr_l, pkt->data) == 0) { + /* we read the next PCR (XXX: optimize it by using a bigger buffer */ +- pos = url_ftell(&s->pb); ++ pos = url_ftell(s->pb); + for(i = 0; i < MAX_PACKET_READAHEAD; i++) { +- url_fseek(&s->pb, pos + i * ts->raw_packet_size, SEEK_SET); +- get_buffer(&s->pb, pcr_buf, 12); ++ url_fseek(s->pb, pos + i * ts->raw_packet_size, SEEK_SET); ++ get_buffer(s->pb, pcr_buf, 12); + if (parse_pcr(&next_pcr_h, &next_pcr_l, pcr_buf) == 0) { + /* XXX: not precise enough */ + ts->pcr_incr = ((next_pcr_h - pcr_h) * 300 + (next_pcr_l - pcr_l)) / +@@ -1309,7 +1313,7 @@ + break; + } + } +- url_fseek(&s->pb, pos, SEEK_SET); ++ url_fseek(s->pb, pos, SEEK_SET); + /* no next PCR found: we use previous increment */ + ts->cur_pcr = pcr_h * 300 + pcr_l; + } +@@ -1351,8 +1355,8 @@ + pos = ((*ppos + ts->raw_packet_size - 1) / ts->raw_packet_size) * ts->raw_packet_size; + if (find_next) { + for(;;) { +- url_fseek(&s->pb, pos, SEEK_SET); +- if (get_buffer(&s->pb, buf, TS_PACKET_SIZE) != TS_PACKET_SIZE) ++ url_fseek(s->pb, pos, SEEK_SET); ++ if (get_buffer(s->pb, buf, TS_PACKET_SIZE) != TS_PACKET_SIZE) + return AV_NOPTS_VALUE; + if ((pcr_pid < 0 || (AV_RB16(buf + 1) & 0x1fff) == pcr_pid) && + parse_pcr(×tamp, &pcr_l, buf) == 0) { +@@ -1365,8 +1369,8 @@ + pos -= ts->raw_packet_size; + if (pos < 0) + return AV_NOPTS_VALUE; +- url_fseek(&s->pb, pos, SEEK_SET); +- if (get_buffer(&s->pb, buf, TS_PACKET_SIZE) != TS_PACKET_SIZE) ++ url_fseek(s->pb, pos, SEEK_SET); ++ if (get_buffer(s->pb, buf, TS_PACKET_SIZE) != TS_PACKET_SIZE) + return AV_NOPTS_VALUE; + if ((pcr_pid < 0 || (AV_RB16(buf + 1) & 0x1fff) == pcr_pid) && + parse_pcr(×tamp, &pcr_l, buf) == 0) { +@@ -1387,17 +1391,17 @@ + if(av_seek_frame_binary(s, stream_index, target_ts, flags) < 0) + return -1; + +- pos= url_ftell(&s->pb); ++ pos= url_ftell(s->pb); + + for(;;) { +- url_fseek(&s->pb, pos, SEEK_SET); +- if (get_buffer(&s->pb, buf, TS_PACKET_SIZE) != TS_PACKET_SIZE) ++ url_fseek(s->pb, pos, SEEK_SET); ++ if (get_buffer(s->pb, buf, TS_PACKET_SIZE) != TS_PACKET_SIZE) + return -1; + // pid = AV_RB16(buf + 1) & 0x1fff; + if(buf[1] & 0x40) break; + pos += ts->raw_packet_size; + } +- url_fseek(&s->pb, pos, SEEK_SET); ++ url_fseek(s->pb, pos, SEEK_SET); + + return 0; + } +diff -u mplayer-1.0~rc2-12/libavformat/mpegtsenc.c ffmpeg-free-0.svn20080206/libavformat/mpegtsenc.c +--- mplayer-1.0~rc2-12/libavformat/mpegtsenc.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/mpegtsenc.c 2008-01-05 00:09:58.000000000 +0100 +@@ -43,7 +43,7 @@ + unsigned char *q; + int first, b, len1, left; + +- crc = bswap_32(av_crc(av_crc04C11DB7, -1, buf, len - 4)); ++ crc = bswap_32(av_crc(av_crc_get_table(AV_CRC_32_IEEE), -1, buf, len - 4)); + buf[len - 4] = (crc >> 24) & 0xff; + buf[len - 3] = (crc >> 16) & 0xff; + buf[len - 2] = (crc >> 8) & 0xff; +@@ -353,7 +353,7 @@ + static void section_write_packet(MpegTSSection *s, const uint8_t *packet) + { + AVFormatContext *ctx = s->opaque; +- put_buffer(&ctx->pb, packet, TS_PACKET_SIZE); ++ put_buffer(ctx->pb, packet, TS_PACKET_SIZE); + } + + static int mpegts_write_header(AVFormatContext *s) +@@ -431,7 +431,7 @@ + for(i = 0; i < ts->nb_services; i++) { + mpegts_write_pmt(s, ts->services[i]); + } +- put_flush_packet(&s->pb); ++ put_flush_packet(s->pb); + + return 0; + +@@ -608,9 +608,9 @@ + memcpy(buf + TS_PACKET_SIZE - len, payload, len); + payload += len; + payload_size -= len; +- put_buffer(&s->pb, buf, TS_PACKET_SIZE); ++ put_buffer(s->pb, buf, TS_PACKET_SIZE); + } +- put_flush_packet(&s->pb); ++ put_flush_packet(s->pb); + } + + static int mpegts_write_packet(AVFormatContext *s, AVPacket *pkt) +@@ -668,7 +668,7 @@ + ts_st->payload_pts, ts_st->payload_dts); + } + } +- put_flush_packet(&s->pb); ++ put_flush_packet(s->pb); + + for(i = 0; i < ts->nb_services; i++) { + service = ts->services[i]; +diff -u mplayer-1.0~rc2-12/libavformat/mpegts.h ffmpeg-free-0.svn20080206/libavformat/mpegts.h +--- mplayer-1.0~rc2-12/libavformat/mpegts.h 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/mpegts.h 2007-10-17 11:37:46.000000000 +0200 +@@ -19,8 +19,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef AVFORMAT_MPEGTS_H +-#define AVFORMAT_MPEGTS_H ++#ifndef FFMPEG_MPEGTS_H ++#define FFMPEG_MPEGTS_H + + #include "avformat.h" + +@@ -65,4 +65,4 @@ + const uint8_t *buf, int len); + void mpegts_parse_close(MpegTSContext *ts); + +-#endif /* AVFORMAT_MPEGTS_H */ ++#endif /* FFMPEG_MPEGTS_H */ +diff -u mplayer-1.0~rc2-12/libavformat/mpjpeg.c ffmpeg-free-0.svn20080206/libavformat/mpjpeg.c +--- mplayer-1.0~rc2-12/libavformat/mpjpeg.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/mpjpeg.c 2007-11-21 08:41:00.000000000 +0100 +@@ -29,8 +29,8 @@ + uint8_t buf1[256]; + + snprintf(buf1, sizeof(buf1), "--%s\n", BOUNDARY_TAG); +- put_buffer(&s->pb, buf1, strlen(buf1)); +- put_flush_packet(&s->pb); ++ put_buffer(s->pb, buf1, strlen(buf1)); ++ put_flush_packet(s->pb); + return 0; + } + +@@ -39,12 +39,12 @@ + uint8_t buf1[256]; + + snprintf(buf1, sizeof(buf1), "Content-type: image/jpeg\n\n"); +- put_buffer(&s->pb, buf1, strlen(buf1)); +- put_buffer(&s->pb, pkt->data, pkt->size); ++ put_buffer(s->pb, buf1, strlen(buf1)); ++ put_buffer(s->pb, pkt->data, pkt->size); + + snprintf(buf1, sizeof(buf1), "\n--%s\n", BOUNDARY_TAG); +- put_buffer(&s->pb, buf1, strlen(buf1)); +- put_flush_packet(&s->pb); ++ put_buffer(s->pb, buf1, strlen(buf1)); ++ put_flush_packet(s->pb); + return 0; + } + +diff -u mplayer-1.0~rc2-12/libavformat/mtv.c ffmpeg-free-0.svn20080206/libavformat/mtv.c +--- mplayer-1.0~rc2-12/libavformat/mtv.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/mtv.c 2007-11-21 08:41:00.000000000 +0100 +@@ -65,7 +65,7 @@ + static int mtv_read_header(AVFormatContext *s, AVFormatParameters *ap) + { + MTVDemuxContext *mtv = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + AVStream *st; + + +@@ -131,7 +131,7 @@ + static int mtv_read_packet(AVFormatContext *s, AVPacket *pkt) + { + MTVDemuxContext *mtv = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + int ret; + #ifndef WORDS_BIGENDIAN + int i; +diff -u mplayer-1.0~rc2-12/libavformat/mxf.c ffmpeg-free-0.svn20080206/libavformat/mxf.c +--- mplayer-1.0~rc2-12/libavformat/mxf.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/mxf.c 2008-02-01 15:58:35.000000000 +0100 +@@ -67,7 +67,6 @@ + typedef struct { + UID uid; + enum MXFMetadataSetType type; +- UID context_uid; + UID source_container_ul; + } MXFCryptoContext; + +@@ -140,6 +139,8 @@ + int metadata_sets_count; + AVFormatContext *fc; + struct AVAES *aesc; ++ uint8_t *local_tags; ++ int local_tags_count; + } MXFContext; + + typedef struct { +@@ -155,8 +156,8 @@ + + typedef struct { + UID uid; ++ unsigned matching_len; + enum CodecID id; +- enum MXFWrappingScheme wrapping; + } MXFCodecUL; + + typedef struct { +@@ -176,8 +177,10 @@ + static const uint8_t mxf_essence_element_key[] = { 0x06,0x0e,0x2b,0x34,0x01,0x02,0x01,0x01,0x0d,0x01,0x03,0x01 }; + static const uint8_t mxf_klv_key[] = { 0x06,0x0e,0x2b,0x34 }; + /* complete keys to match */ ++static const uint8_t mxf_crypto_source_container_ul[] = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x09,0x06,0x01,0x01,0x02,0x02,0x00,0x00,0x00 }; + static const uint8_t mxf_encrypted_triplet_key[] = { 0x06,0x0e,0x2b,0x34,0x02,0x04,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x7e,0x01,0x00 }; + static const uint8_t mxf_encrypted_essence_container[] = { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x0b,0x01,0x00 }; ++static const uint8_t mxf_sony_mpeg4_extradata[] = { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0e,0x06,0x06,0x02,0x02,0x01,0x00,0x00 }; + + #define IS_KLV_KEY(x, y) (!memcmp(x, y, sizeof(y))) + +@@ -241,7 +244,8 @@ + static int mxf_get_d10_aes3_packet(ByteIOContext *pb, AVStream *st, AVPacket *pkt, int64_t length) + { + uint8_t buffer[61444]; +- uint8_t *buf_ptr, *end_ptr, *data_ptr; ++ const uint8_t *buf_ptr, *end_ptr; ++ uint8_t *data_ptr; + int i; + + if (length > 61444) /* worst case PAL 1920 samples 8 channels */ +@@ -269,7 +273,7 @@ + { + static const uint8_t checkv[16] = {0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b, 0x43, 0x48, 0x55, 0x4b}; + MXFContext *mxf = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + offset_t end = url_ftell(pb) + klv->length; + uint64_t size; + uint64_t orig_size; +@@ -280,6 +284,8 @@ + + if (!mxf->aesc && s->key && s->keylen == 16) { + mxf->aesc = av_malloc(av_aes_size); ++ if (!mxf->aesc) ++ return -1; + av_aes_init(mxf->aesc, s->key, 128, 1); + } + // crypto context +@@ -326,8 +332,8 @@ + { + KLVPacket klv; + +- while (!url_feof(&s->pb)) { +- if (klv_read_packet(&klv, &s->pb) < 0) ++ while (!url_feof(s->pb)) { ++ if (klv_read_packet(&klv, s->pb) < 0) + return -1; + #ifdef DEBUG + PRINT_KEY(s, "read packet", klv.key); +@@ -344,48 +350,66 @@ + int index = mxf_get_stream_index(s, &klv); + if (index < 0) { + av_log(s, AV_LOG_ERROR, "error getting stream index\n"); +- url_fskip(&s->pb, klv.length); ++ url_fskip(s->pb, klv.length); + return -1; + } + /* check for 8 channels AES3 element */ + if (klv.key[12] == 0x06 && klv.key[13] == 0x01 && klv.key[14] == 0x10) { +- if (mxf_get_d10_aes3_packet(&s->pb, s->streams[index], pkt, klv.length) < 0) { ++ if (mxf_get_d10_aes3_packet(s->pb, s->streams[index], pkt, klv.length) < 0) { + av_log(s, AV_LOG_ERROR, "error reading D-10 aes3 frame\n"); + return -1; + } + } else +- av_get_packet(&s->pb, pkt, klv.length); ++ av_get_packet(s->pb, pkt, klv.length); + pkt->stream_index = index; + pkt->pos = klv.offset; + return 0; + } else +- url_fskip(&s->pb, klv.length); ++ url_fskip(s->pb, klv.length); + } + return AVERROR(EIO); + } + ++static int mxf_read_primer_pack(MXFContext *mxf) ++{ ++ ByteIOContext *pb = mxf->fc->pb; ++ int item_num = get_be32(pb); ++ int item_len = get_be32(pb); ++ ++ if (item_len != 18) { ++ av_log(mxf->fc, AV_LOG_ERROR, "unsupported primer pack item length\n"); ++ return -1; ++ } ++ if (item_num > UINT_MAX / item_len) ++ return -1; ++ mxf->local_tags_count = item_num; ++ mxf->local_tags = av_malloc(item_num*item_len); ++ if (!mxf->local_tags) ++ return -1; ++ get_buffer(pb, mxf->local_tags, item_num*item_len); ++ return 0; ++} ++ + static int mxf_add_metadata_set(MXFContext *mxf, void *metadata_set) + { + mxf->metadata_sets = av_realloc(mxf->metadata_sets, (mxf->metadata_sets_count + 1) * sizeof(*mxf->metadata_sets)); ++ if (!mxf->metadata_sets) ++ return -1; + mxf->metadata_sets[mxf->metadata_sets_count] = metadata_set; + mxf->metadata_sets_count++; + return 0; + } + +-static int mxf_read_metadata_cryptographic_context(MXFCryptoContext *cryptocontext, ByteIOContext *pb, int tag) ++static int mxf_read_cryptographic_context(MXFCryptoContext *cryptocontext, ByteIOContext *pb, int tag, int size, UID uid) + { +- switch(tag) { +- case 0xFFFE: +- get_buffer(pb, cryptocontext->context_uid, 16); +- break; +- case 0xFFFD: ++ if (size != 16) ++ return -1; ++ if (IS_KLV_KEY(uid, mxf_crypto_source_container_ul)) + get_buffer(pb, cryptocontext->source_container_ul, 16); +- break; +- } + return 0; + } + +-static int mxf_read_metadata_content_storage(MXFContext *mxf, ByteIOContext *pb, int tag) ++static int mxf_read_content_storage(MXFContext *mxf, ByteIOContext *pb, int tag) + { + switch (tag) { + case 0x1901: +@@ -393,6 +417,8 @@ + if (mxf->packages_count >= UINT_MAX / sizeof(UID)) + return -1; + mxf->packages_refs = av_malloc(mxf->packages_count * sizeof(UID)); ++ if (!mxf->packages_refs) ++ return -1; + url_fskip(pb, 4); /* useless size of objects, always 16 according to specs */ + get_buffer(pb, (uint8_t *)mxf->packages_refs, mxf->packages_count * sizeof(UID)); + break; +@@ -400,7 +426,7 @@ + return 0; + } + +-static int mxf_read_metadata_source_clip(MXFStructuralComponent *source_clip, ByteIOContext *pb, int tag) ++static int mxf_read_source_clip(MXFStructuralComponent *source_clip, ByteIOContext *pb, int tag) + { + switch(tag) { + case 0x0202: +@@ -421,7 +447,7 @@ + return 0; + } + +-static int mxf_read_metadata_material_package(MXFPackage *package, ByteIOContext *pb, int tag) ++static int mxf_read_material_package(MXFPackage *package, ByteIOContext *pb, int tag) + { + switch(tag) { + case 0x4403: +@@ -429,6 +455,8 @@ + if (package->tracks_count >= UINT_MAX / sizeof(UID)) + return -1; + package->tracks_refs = av_malloc(package->tracks_count * sizeof(UID)); ++ if (!package->tracks_refs) ++ return -1; + url_fskip(pb, 4); /* useless size of objects, always 16 according to specs */ + get_buffer(pb, (uint8_t *)package->tracks_refs, package->tracks_count * sizeof(UID)); + break; +@@ -436,7 +464,7 @@ + return 0; + } + +-static int mxf_read_metadata_track(MXFTrack *track, ByteIOContext *pb, int tag) ++static int mxf_read_track(MXFTrack *track, ByteIOContext *pb, int tag) + { + switch(tag) { + case 0x4801: +@@ -456,7 +484,7 @@ + return 0; + } + +-static int mxf_read_metadata_sequence(MXFSequence *sequence, ByteIOContext *pb, int tag) ++static int mxf_read_sequence(MXFSequence *sequence, ByteIOContext *pb, int tag) + { + switch(tag) { + case 0x0202: +@@ -470,6 +498,8 @@ + if (sequence->structural_components_count >= UINT_MAX / sizeof(UID)) + return -1; + sequence->structural_components_refs = av_malloc(sequence->structural_components_count * sizeof(UID)); ++ if (!sequence->structural_components_refs) ++ return -1; + url_fskip(pb, 4); /* useless size of objects, always 16 according to specs */ + get_buffer(pb, (uint8_t *)sequence->structural_components_refs, sequence->structural_components_count * sizeof(UID)); + break; +@@ -477,7 +507,7 @@ + return 0; + } + +-static int mxf_read_metadata_source_package(MXFPackage *package, ByteIOContext *pb, int tag) ++static int mxf_read_source_package(MXFPackage *package, ByteIOContext *pb, int tag) + { + switch(tag) { + case 0x4403: +@@ -485,6 +515,8 @@ + if (package->tracks_count >= UINT_MAX / sizeof(UID)) + return -1; + package->tracks_refs = av_malloc(package->tracks_count * sizeof(UID)); ++ if (!package->tracks_refs) ++ return -1; + url_fskip(pb, 4); /* useless size of objects, always 16 according to specs */ + get_buffer(pb, (uint8_t *)package->tracks_refs, package->tracks_count * sizeof(UID)); + break; +@@ -500,7 +532,7 @@ + return 0; + } + +-static void mxf_read_metadata_pixel_layout(ByteIOContext *pb, MXFDescriptor *descriptor) ++static void mxf_read_pixel_layout(ByteIOContext *pb, MXFDescriptor *descriptor) + { + int code; + +@@ -523,7 +555,7 @@ + } while (code != 0); /* SMPTE 377M E.2.46 */ + } + +-static int mxf_read_metadata_generic_descriptor(MXFDescriptor *descriptor, ByteIOContext *pb, int tag, int size) ++static int mxf_read_generic_descriptor(MXFDescriptor *descriptor, ByteIOContext *pb, int tag, int size, UID uid) + { + switch(tag) { + case 0x3F01: +@@ -531,6 +563,8 @@ + if (descriptor->sub_descriptors_count >= UINT_MAX / sizeof(UID)) + return -1; + descriptor->sub_descriptors_refs = av_malloc(descriptor->sub_descriptors_count * sizeof(UID)); ++ if (!descriptor->sub_descriptors_refs) ++ return -1; + url_fskip(pb, 4); /* useless size of objects, always 16 according to specs */ + get_buffer(pb, (uint8_t *)descriptor->sub_descriptors_refs, descriptor->sub_descriptors_count * sizeof(UID)); + break; +@@ -567,12 +601,17 @@ + descriptor->bits_per_sample = get_be32(pb); + break; + case 0x3401: +- mxf_read_metadata_pixel_layout(pb, descriptor); ++ mxf_read_pixel_layout(pb, descriptor); + break; +- case 0x8201: /* Private tag used by SONY C0023S01.mxf */ +- descriptor->extradata = av_malloc(size); +- descriptor->extradata_size = size; +- get_buffer(pb, descriptor->extradata, size); ++ default: ++ /* Private uid used by SONY C0023S01.mxf */ ++ if (IS_KLV_KEY(uid, mxf_sony_mpeg4_extradata)) { ++ descriptor->extradata = av_malloc(size); ++ if (!descriptor->extradata) ++ return -1; ++ descriptor->extradata_size = size; ++ get_buffer(pb, descriptor->extradata, size); ++ } + break; + } + return 0; +@@ -588,64 +627,36 @@ + + static const MXFCodecUL mxf_codec_uls[] = { + /* PictureEssenceCoding */ +- { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x03,0x04,0x01,0x02,0x02,0x01,0x01,0x11,0x00 }, CODEC_ID_MPEG2VIDEO, Frame }, /* MP@ML Long GoP */ +- +- { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x01,0x02,0x01,0x05 }, CODEC_ID_MPEG2VIDEO, Frame }, /* D-10 30Mbps PAL */ +- { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x01,0x02,0x01,0x03 }, CODEC_ID_MPEG2VIDEO, Frame }, /* D-10 40Mbps PAL */ +- { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x01,0x02,0x01,0x01 }, CODEC_ID_MPEG2VIDEO, Frame }, /* D-10 50Mbps PAL */ +- { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x01,0x02,0x01,0x06 }, CODEC_ID_MPEG2VIDEO, Frame }, /* D-10 30Mbps NTSC */ +- { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x01,0x02,0x01,0x04 }, CODEC_ID_MPEG2VIDEO, Frame }, /* D-10 40Mbps NTSC */ +- { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x01,0x02,0x01,0x02 }, CODEC_ID_MPEG2VIDEO, Frame }, /* D-10 50Mbps NTSC */ +- +- { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x03,0x04,0x01,0x02,0x02,0x01,0x02,0x02,0x00 }, CODEC_ID_MPEG2VIDEO, Frame }, /* 422P@ML I-Frame */ +- { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x03,0x04,0x01,0x02,0x02,0x01,0x02,0x03,0x00 }, CODEC_ID_MPEG2VIDEO, Frame }, /* 422P@ML Long GoP */ +- +- { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x03,0x04,0x01,0x02,0x02,0x01,0x03,0x03,0x00 }, CODEC_ID_MPEG2VIDEO, Frame }, /* MP@HL Long GoP */ +- +- { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x03,0x04,0x01,0x02,0x02,0x01,0x04,0x02,0x00 }, CODEC_ID_MPEG2VIDEO, Frame }, /* 422P@HL I-Frame */ +- { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x03,0x04,0x01,0x02,0x02,0x01,0x04,0x03,0x00 }, CODEC_ID_MPEG2VIDEO, Frame }, /* 422P@HL Long GoP */ +- +- { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x03,0x04,0x01,0x02,0x02,0x01,0x20,0x02,0x03 }, CODEC_ID_MPEG4, Frame }, /* XDCAM proxy_pal030926.mxf */ +- { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x03,0x04,0x01,0x02,0x02,0x01,0x20,0x02,0x04 }, CODEC_ID_MPEG4, Frame }, /* XDCAM Proxy C0023S01.mxf */ +- +- { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x02,0x01,0x02,0x00 }, CODEC_ID_DVVIDEO, Frame }, /* DV25 IEC PAL */ +- { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x02,0x02,0x02,0x00 }, CODEC_ID_DVVIDEO, Frame }, /* DVCPRO25 PAL */ +- { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x02,0x02,0x04,0x00 }, CODEC_ID_DVVIDEO, Frame }, /* DVCPRO50 PAL */ +- +- { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x07,0x04,0x01,0x02,0x02,0x03,0x01,0x01,0x00 }, CODEC_ID_JPEG2000, Frame }, /* JPEG2000 Codestream */ +- +- { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x01,0x7F,0x00,0x00,0x00 }, CODEC_ID_RAWVIDEO, Frame }, /* Uncompressed */ ++ { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x03,0x04,0x01,0x02,0x02,0x01,0x01,0x11,0x00 }, 14, CODEC_ID_MPEG2VIDEO }, /* MP@ML Long GoP */ ++ { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x01,0x02,0x01,0x01 }, 14, CODEC_ID_MPEG2VIDEO }, /* D-10 50Mbps PAL */ ++ { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x03,0x04,0x01,0x02,0x02,0x01,0x03,0x03,0x00 }, 14, CODEC_ID_MPEG2VIDEO }, /* MP@HL Long GoP */ ++ { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x03,0x04,0x01,0x02,0x02,0x01,0x04,0x02,0x00 }, 14, CODEC_ID_MPEG2VIDEO }, /* 422P@HL I-Frame */ ++ { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x03,0x04,0x01,0x02,0x02,0x01,0x20,0x02,0x03 }, 14, CODEC_ID_MPEG4 }, /* XDCAM proxy_pal030926.mxf */ ++ { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x02,0x01,0x02,0x00 }, 13, CODEC_ID_DVVIDEO }, /* DV25 IEC PAL */ ++ { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x07,0x04,0x01,0x02,0x02,0x03,0x01,0x01,0x00 }, 14, CODEC_ID_JPEG2000 }, /* JPEG2000 Codestream */ ++ { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x01,0x7F,0x00,0x00,0x00 }, 13, CODEC_ID_RAWVIDEO }, /* Uncompressed */ + /* SoundEssenceCompression */ +- { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x02,0x02,0x01,0x00,0x00,0x00,0x00 }, CODEC_ID_PCM_S16LE, Frame }, /* Uncompressed */ +- { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x02,0x02,0x01,0x7F,0x00,0x00,0x00 }, CODEC_ID_PCM_S16LE, Frame }, +- { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x07,0x04,0x02,0x02,0x01,0x7E,0x00,0x00,0x00 }, CODEC_ID_PCM_S16BE, Frame }, /* From Omneon MXF file */ +- { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x04,0x04,0x02,0x02,0x02,0x03,0x01,0x01,0x00 }, CODEC_ID_PCM_ALAW, Frame }, /* XDCAM Proxy C0023S01.mxf */ +- { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x02,0x02,0x02,0x03,0x02,0x01,0x00 }, CODEC_ID_AC3, Frame }, +- { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x02,0x02,0x02,0x03,0x02,0x05,0x00 }, CODEC_ID_MP2, Frame }, /* MP2 or MP3 */ +- //{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x02,0x02,0x02,0x03,0x02,0x1C,0x00 }, CODEC_ID_DOLBY_E, Frame }, /* Dolby-E */ +- { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, CODEC_ID_NONE, Frame }, ++ { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x02,0x02,0x01,0x00,0x00,0x00,0x00 }, 13, CODEC_ID_PCM_S16LE }, /* Uncompressed */ ++ { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x02,0x02,0x01,0x7F,0x00,0x00,0x00 }, 13, CODEC_ID_PCM_S16LE }, ++ { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x07,0x04,0x02,0x02,0x01,0x7E,0x00,0x00,0x00 }, 13, CODEC_ID_PCM_S16BE }, /* From Omneon MXF file */ ++ { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x04,0x04,0x02,0x02,0x02,0x03,0x01,0x01,0x00 }, 15, CODEC_ID_PCM_ALAW }, /* XDCAM Proxy C0023S01.mxf */ ++ { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x02,0x02,0x02,0x03,0x02,0x01,0x00 }, 15, CODEC_ID_AC3 }, ++ { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x02,0x02,0x02,0x03,0x02,0x05,0x00 }, 15, CODEC_ID_MP2 }, /* MP2 or MP3 */ ++ //{ { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x02,0x02,0x02,0x03,0x02,0x1C,0x00 }, 15, CODEC_ID_DOLBY_E }, /* Dolby-E */ ++ { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0, CODEC_ID_NONE }, + }; + + static const MXFCodecUL mxf_picture_essence_container_uls[] = { +- { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x02,0x0D,0x01,0x03,0x01,0x02,0x04,0x60,0x01 }, CODEC_ID_MPEG2VIDEO, Frame }, /* MPEG-ES Frame wrapped */ +- { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x02,0x0D,0x01,0x03,0x01,0x02,0x04,0xe0,0x02 }, CODEC_ID_MPEG2VIDEO, Clip }, /* MPEG-ES Clip wrapped, 0xe0 MPV stream id */ +- { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x04,0x61,0x07 }, CODEC_ID_MPEG2VIDEO, Clip }, /* MPEG-ES Custom wrapped, 0x61 ??? stream id */ +- { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, CODEC_ID_NONE, Frame }, ++ { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x02,0x0D,0x01,0x03,0x01,0x02,0x04,0x60,0x01 }, 14, CODEC_ID_MPEG2VIDEO }, /* MPEG-ES Frame wrapped */ ++ { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x02,0x41,0x01 }, 14, CODEC_ID_DVVIDEO }, /* DV 625 25mbps */ ++ { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0, CODEC_ID_NONE }, + }; + + static const MXFCodecUL mxf_sound_essence_container_uls[] = { +- { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x06,0x01,0x00 }, CODEC_ID_PCM_S16LE, Frame }, /* BWF Frame wrapped */ +- { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x06,0x03,0x00 }, CODEC_ID_PCM_S16LE, Frame }, /* AES Frame wrapped */ +- { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x02,0x0D,0x01,0x03,0x01,0x02,0x04,0x40,0x01 }, CODEC_ID_MP2, Frame }, /* MPEG-ES Frame wrapped, 0x40 ??? stream id */ +- { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x02,0x0D,0x01,0x03,0x01,0x02,0x04,0xc0,0x01 }, CODEC_ID_MP2, Frame }, /* MPEG-ES Frame wrapped, 0xc0 MPA stream id */ +- { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x02,0x0D,0x01,0x03,0x01,0x02,0x04,0xc0,0x02 }, CODEC_ID_MP2, Clip }, /* MPEG-ES Clip wrapped, 0xc0 MPA stream id */ +- { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x01,0x05,0x01 }, CODEC_ID_PCM_S16LE, Frame }, /* D-10 Mapping 30Mbps PAL Extended Template */ +- { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x01,0x03,0x01 }, CODEC_ID_PCM_S16LE, Frame }, /* D-10 Mapping 40Mbps PAL Extended Template */ +- { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x01,0x01,0x01 }, CODEC_ID_PCM_S16LE, Frame }, /* D-10 Mapping 50Mbps PAL Extended Template */ +- { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x01,0x06,0x01 }, CODEC_ID_PCM_S16LE, Frame }, /* D-10 Mapping 30Mbps NTSC Extended Template */ +- { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x01,0x04,0x01 }, CODEC_ID_PCM_S16LE, Frame }, /* D-10 Mapping 40Mbps NTSC Extended Template */ +- { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x01,0x02,0x01 }, CODEC_ID_PCM_S16LE, Frame }, /* D-10 Mapping 50Mbps NTSC Extended Template */ +- { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, CODEC_ID_NONE, Frame }, ++ { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x06,0x01,0x00 }, 14, CODEC_ID_PCM_S16LE }, /* BWF Frame wrapped */ ++ { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x02,0x0D,0x01,0x03,0x01,0x02,0x04,0x40,0x01 }, 14, CODEC_ID_MP2 }, /* MPEG-ES Frame wrapped, 0x40 ??? stream id */ ++ { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x0D,0x01,0x03,0x01,0x02,0x01,0x01,0x01 }, 14, CODEC_ID_PCM_S16LE }, /* D-10 Mapping 50Mbps PAL Extended Template */ ++ { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, 0, CODEC_ID_NONE }, + }; + + /* +@@ -665,7 +676,7 @@ + static const MXFCodecUL *mxf_get_codec_ul(const MXFCodecUL *uls, UID *uid) + { + while (uls->id != CODEC_ID_NONE) { +- if(mxf_match_uid(uls->uid, *uid, 16)) ++ if(mxf_match_uid(uls->uid, *uid, uls->matching_len)) + break; + uls++; + } +@@ -775,6 +786,10 @@ + continue; + + st = av_new_stream(mxf->fc, source_track->track_id); ++ if (!st) { ++ av_log(mxf->fc, AV_LOG_ERROR, "could not allocate stream\n"); ++ return -1; ++ } + st->priv_data = source_track; + st->duration = component->duration; + if (st->duration == -1) +@@ -868,8 +883,8 @@ + st->need_parsing = AVSTREAM_PARSE_FULL; + } + } +- if (container_ul && container_ul->wrapping == Clip) { +- dprintf(mxf->fc, "stream %d: clip wrapped essence\n", st->index); ++ if (st->codec->codec_type != CODEC_TYPE_DATA && (*essence_container_ul)[15] > 0x01) { ++ av_log(mxf->fc, AV_LOG_WARNING, "only frame wrapped mappings are correctly supported\n"); + st->need_parsing = AVSTREAM_PARSE_FULL; + } + } +@@ -877,43 +892,60 @@ + } + + static const MXFMetadataReadTableEntry mxf_metadata_read_table[] = { +- { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x18,0x00 }, mxf_read_metadata_content_storage, 0, AnyType }, +- { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x37,0x00 }, mxf_read_metadata_source_package, sizeof(MXFPackage), SourcePackage }, +- { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x36,0x00 }, mxf_read_metadata_material_package, sizeof(MXFPackage), MaterialPackage }, +- { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x0F,0x00 }, mxf_read_metadata_sequence, sizeof(MXFSequence), Sequence }, +- { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x11,0x00 }, mxf_read_metadata_source_clip, sizeof(MXFStructuralComponent), SourceClip }, +- { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x44,0x00 }, mxf_read_metadata_generic_descriptor, sizeof(MXFDescriptor), MultipleDescriptor }, +- { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x42,0x00 }, mxf_read_metadata_generic_descriptor, sizeof(MXFDescriptor), Descriptor }, /* Generic Sound */ +- { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x28,0x00 }, mxf_read_metadata_generic_descriptor, sizeof(MXFDescriptor), Descriptor }, /* CDCI */ +- { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x29,0x00 }, mxf_read_metadata_generic_descriptor, sizeof(MXFDescriptor), Descriptor }, /* RGBA */ +- { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x51,0x00 }, mxf_read_metadata_generic_descriptor, sizeof(MXFDescriptor), Descriptor }, /* MPEG 2 Video */ +- { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x48,0x00 }, mxf_read_metadata_generic_descriptor, sizeof(MXFDescriptor), Descriptor }, /* Wave */ +- { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x47,0x00 }, mxf_read_metadata_generic_descriptor, sizeof(MXFDescriptor), Descriptor }, /* AES3 */ +- { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x3A,0x00 }, mxf_read_metadata_track, sizeof(MXFTrack), Track }, /* Static Track */ +- { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x3B,0x00 }, mxf_read_metadata_track, sizeof(MXFTrack), Track }, /* Generic Track */ +- { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x04,0x01,0x02,0x02,0x00,0x00 }, mxf_read_metadata_cryptographic_context, sizeof(MXFCryptoContext), CryptoContext }, ++ { { 0x06,0x0E,0x2B,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x05,0x01,0x00 }, mxf_read_primer_pack }, ++ { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x18,0x00 }, mxf_read_content_storage, 0, AnyType }, ++ { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x37,0x00 }, mxf_read_source_package, sizeof(MXFPackage), SourcePackage }, ++ { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x36,0x00 }, mxf_read_material_package, sizeof(MXFPackage), MaterialPackage }, ++ { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x0F,0x00 }, mxf_read_sequence, sizeof(MXFSequence), Sequence }, ++ { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x11,0x00 }, mxf_read_source_clip, sizeof(MXFStructuralComponent), SourceClip }, ++ { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x44,0x00 }, mxf_read_generic_descriptor, sizeof(MXFDescriptor), MultipleDescriptor }, ++ { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x42,0x00 }, mxf_read_generic_descriptor, sizeof(MXFDescriptor), Descriptor }, /* Generic Sound */ ++ { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x28,0x00 }, mxf_read_generic_descriptor, sizeof(MXFDescriptor), Descriptor }, /* CDCI */ ++ { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x29,0x00 }, mxf_read_generic_descriptor, sizeof(MXFDescriptor), Descriptor }, /* RGBA */ ++ { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x51,0x00 }, mxf_read_generic_descriptor, sizeof(MXFDescriptor), Descriptor }, /* MPEG 2 Video */ ++ { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x48,0x00 }, mxf_read_generic_descriptor, sizeof(MXFDescriptor), Descriptor }, /* Wave */ ++ { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x47,0x00 }, mxf_read_generic_descriptor, sizeof(MXFDescriptor), Descriptor }, /* AES3 */ ++ { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x3A,0x00 }, mxf_read_track, sizeof(MXFTrack), Track }, /* Static Track */ ++ { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x3B,0x00 }, mxf_read_track, sizeof(MXFTrack), Track }, /* Generic Track */ ++ { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x04,0x01,0x02,0x02,0x00,0x00 }, mxf_read_cryptographic_context, sizeof(MXFCryptoContext), CryptoContext }, + { { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, NULL, 0, AnyType }, + }; + + static int mxf_read_local_tags(MXFContext *mxf, KLVPacket *klv, int (*read_child)(), int ctx_size, enum MXFMetadataSetType type) + { +- ByteIOContext *pb = &mxf->fc->pb; ++ ByteIOContext *pb = mxf->fc->pb; + MXFMetadataSet *ctx = ctx_size ? av_mallocz(ctx_size) : mxf; +- uint64_t klv_end= url_ftell(pb) + klv->length; ++ uint64_t klv_end = url_ftell(pb) + klv->length; + ++ if (!ctx) ++ return -1; + while (url_ftell(pb) + 4 < klv_end) { + int tag = get_be16(pb); + int size = get_be16(pb); /* KLV specified by 0x53 */ +- uint64_t next= url_ftell(pb) + size; ++ uint64_t next = url_ftell(pb) + size; ++ UID uid = {0}; + + if (!size) { /* ignore empty tag, needed for some files with empty UMID tag */ + av_log(mxf->fc, AV_LOG_ERROR, "local tag 0x%04X with 0 size\n", tag); + continue; + } +- if(ctx_size && tag == 0x3C0A) ++ if (tag > 0x7FFF) { /* dynamic tag */ ++ int i; ++ for (i = 0; i < mxf->local_tags_count; i++) { ++ int local_tag = AV_RB16(mxf->local_tags+i*18); ++ if (local_tag == tag) { ++ memcpy(uid, mxf->local_tags+i*18+2, 16); ++ dprintf(mxf->fc, "local tag 0x%04X\n", local_tag); ++#ifdef DEBUG ++ PRINT_KEY(mxf->fc, "uid", uid); ++#endif ++ } ++ } ++ } ++ if (ctx_size && tag == 0x3C0A) + get_buffer(pb, ctx->uid, 16); +- else +- read_child(ctx, pb, tag, size); ++ else if (read_child(ctx, pb, tag, size, uid) < 0) ++ return -1; + + url_fseek(pb, next, SEEK_SET); + } +@@ -926,16 +958,16 @@ + MXFContext *mxf = s->priv_data; + KLVPacket klv; + +- if (!mxf_read_sync(&s->pb, mxf_header_partition_pack_key, 14)) { ++ if (!mxf_read_sync(s->pb, mxf_header_partition_pack_key, 14)) { + av_log(s, AV_LOG_ERROR, "could not find header partition pack key\n"); + return -1; + } +- url_fseek(&s->pb, -14, SEEK_CUR); ++ url_fseek(s->pb, -14, SEEK_CUR); + mxf->fc = s; +- while (!url_feof(&s->pb)) { ++ while (!url_feof(s->pb)) { + const MXFMetadataReadTableEntry *metadata; + +- if (klv_read_packet(&klv, &s->pb) < 0) ++ if (klv_read_packet(&klv, s->pb) < 0) + return -1; + #ifdef DEBUG + PRINT_KEY(s, "read header", klv.key); +@@ -943,13 +975,14 @@ + if (IS_KLV_KEY(klv.key, mxf_encrypted_triplet_key) || + IS_KLV_KEY(klv.key, mxf_essence_element_key)) { + /* FIXME avoid seek */ +- url_fseek(&s->pb, klv.offset, SEEK_SET); ++ url_fseek(s->pb, klv.offset, SEEK_SET); + break; + } + + for (metadata = mxf_metadata_read_table; metadata->read; metadata++) { + if (IS_KLV_KEY(klv.key, metadata->key)) { +- if (mxf_read_local_tags(mxf, &klv, metadata->read, metadata->ctx_size, metadata->type) < 0) { ++ int (*read)() = klv.key[5] == 0x53 ? mxf_read_local_tags : metadata->read; ++ if (read(mxf, &klv, metadata->read, metadata->ctx_size, metadata->type) < 0) { + av_log(s, AV_LOG_ERROR, "error reading header metadata\n"); + return -1; + } +@@ -957,7 +990,7 @@ + } + } + if (!metadata->read) +- url_fskip(&s->pb, klv.length); ++ url_fskip(s->pb, klv.length); + } + return mxf_parse_structural_metadata(mxf); + } +@@ -987,6 +1020,7 @@ + } + av_freep(&mxf->metadata_sets); + av_freep(&mxf->aesc); ++ av_freep(&mxf->local_tags); + return 0; + } + +@@ -1018,7 +1052,7 @@ + if (sample_time < 0) + sample_time = 0; + seconds = av_rescale(sample_time, st->time_base.num, st->time_base.den); +- url_fseek(&s->pb, (s->bit_rate * seconds) >> 3, SEEK_SET); ++ url_fseek(s->pb, (s->bit_rate * seconds) >> 3, SEEK_SET); + av_update_cur_dts(s, st, sample_time); + return 0; + } +diff -u mplayer-1.0~rc2-12/libavformat/network.h ffmpeg-free-0.svn20080206/libavformat/network.h +--- mplayer-1.0~rc2-12/libavformat/network.h 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/network.h 2007-10-17 11:37:46.000000000 +0200 +@@ -18,8 +18,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef NETWORK_H +-#define NETWORK_H ++#ifndef FFMPEG_NETWORK_H ++#define FFMPEG_NETWORK_H + + #ifdef HAVE_WINSOCK2_H + #include +@@ -66,4 +66,4 @@ + int inet_aton (const char * str, struct in_addr * add); + #endif + +-#endif ++#endif /* FFMPEG_NETWORK_H */ +diff -u mplayer-1.0~rc2-12/libavformat/nsvdec.c ffmpeg-free-0.svn20080206/libavformat/nsvdec.c +--- mplayer-1.0~rc2-12/libavformat/nsvdec.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/nsvdec.c 2007-11-21 08:41:00.000000000 +0100 +@@ -228,7 +228,7 @@ + static int nsv_resync(AVFormatContext *s) + { + NSVContext *nsv = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + uint32_t v = 0; + int i; + +@@ -275,7 +275,7 @@ + static int nsv_parse_NSVf_header(AVFormatContext *s, AVFormatParameters *ap) + { + NSVContext *nsv = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + unsigned int file_size, size; + int64_t duration; + int strings_size; +@@ -394,7 +394,7 @@ + static int nsv_parse_NSVs_header(AVFormatContext *s, AVFormatParameters *ap) + { + NSVContext *nsv = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + uint32_t vtag, atag; + uint16_t vwidth, vheight; + AVRational framerate; +@@ -533,7 +533,7 @@ + static int nsv_read_chunk(AVFormatContext *s, int fill_header) + { + NSVContext *nsv = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + AVStream *st[2] = {NULL, NULL}; + NSVStream *nst; + AVPacket *pkt; +diff -u mplayer-1.0~rc2-12/libavformat/nut.c ffmpeg-free-0.svn20080206/libavformat/nut.c +--- mplayer-1.0~rc2-12/libavformat/nut.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/nut.c 2008-02-04 11:27:32.000000000 +0100 +@@ -22,15 +22,11 @@ + #include "nut.h" + #include "tree.h" + +-unsigned long av_crc04C11DB7_update(unsigned long checksum, const uint8_t *buf, unsigned int len){ +- return av_crc(av_crc04C11DB7, checksum, buf, len); +-} +- + void ff_nut_reset_ts(NUTContext *nut, AVRational time_base, int64_t val){ + int i; + for(i=0; iavf->nb_streams; i++){ + nut->stream[i].last_pts= av_rescale_rnd( +- val / nut->time_base_count, ++ val, + time_base.num * (int64_t)nut->stream[i].time_base->den, + time_base.den * (int64_t)nut->stream[i].time_base->num, + AV_ROUND_DOWN); +@@ -44,20 +40,23 @@ + } + + int ff_nut_sp_pos_cmp(syncpoint_t *a, syncpoint_t *b){ +- return (a->pos - b->pos>>32) - (b->pos - a->pos>>32); ++ return ((a->pos - b->pos) >> 32) - ((b->pos - a->pos) >> 32); + } + + int ff_nut_sp_pts_cmp(syncpoint_t *a, syncpoint_t *b){ +- return (a->ts - b->ts>>32) - (b->ts - a->ts>>32); ++ return ((a->ts - b->ts) >> 32) - ((b->ts - a->ts) >> 32); + } + + void ff_nut_add_sp(NUTContext *nut, int64_t pos, int64_t back_ptr, int64_t ts){ +- syncpoint_t *sp2, *sp= av_mallocz(sizeof(syncpoint_t)); ++ syncpoint_t *sp= av_mallocz(sizeof(syncpoint_t)); ++ struct AVTreeNode *node= av_mallocz(av_tree_node_size); + + sp->pos= pos; + sp->back_ptr= back_ptr; + sp->ts= ts; +- sp2= av_tree_insert(&nut->syncpoints, sp, ff_nut_sp_pos_cmp); +- if(sp2 && sp2 != sp) ++ av_tree_insert(&nut->syncpoints, sp, ff_nut_sp_pos_cmp, &node); ++ if(node){ + av_free(sp); ++ av_free(node); ++ } + } +diff -u mplayer-1.0~rc2-12/libavformat/nutdec.c ffmpeg-free-0.svn20080206/libavformat/nutdec.c +--- mplayer-1.0~rc2-12/libavformat/nutdec.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/nutdec.c 2008-02-04 11:30:38.000000000 +0100 +@@ -27,19 +27,8 @@ + #undef NDEBUG + #include + +-static uint64_t get_v(ByteIOContext *bc){ +- uint64_t val = 0; +- int tmp; +- +- do{ +- tmp = get_byte(bc); +- val= (val<<7) + (tmp&127); +- }while(tmp&128); +- return val; +-} +- + static int get_str(ByteIOContext *bc, char *string, unsigned int maxlen){ +- unsigned int len= get_v(bc); ++ unsigned int len= ff_get_v(bc); + + if(len && maxlen) + get_buffer(bc, string, FFMIN(len, maxlen)); +@@ -58,14 +47,14 @@ + } + + static int64_t get_s(ByteIOContext *bc){ +- int64_t v = get_v(bc) + 1; ++ int64_t v = ff_get_v(bc) + 1; + + if (v&1) return -(v>>1); + else return (v>>1); + } + + static uint64_t get_fourcc(ByteIOContext *bc){ +- unsigned int len= get_v(bc); ++ unsigned int len= ff_get_v(bc); + + if (len==2) return get_le16(bc); + else if(len==4) return get_le32(bc); +@@ -74,7 +63,7 @@ + + #ifdef TRACE + static inline uint64_t get_v_trace(ByteIOContext *bc, char *file, char *func, int line){ +- uint64_t v= get_v(bc); ++ uint64_t v= ff_get_v(bc); + + av_log(NULL, AV_LOG_DEBUG, "get_v %5"PRId64" / %"PRIX64" in %s %s:%d\n", v, v, file, func, line); + return v; +@@ -93,7 +82,7 @@ + av_log(NULL, AV_LOG_DEBUG, "get_vb %5"PRId64" / %"PRIX64" in %s %s:%d\n", v, v, file, func, line); + return v; + } +-#define get_v(bc) get_v_trace(bc, __FILE__, __PRETTY_FUNCTION__, __LINE__) ++#define ff_get_v(bc) get_v_trace(bc, __FILE__, __PRETTY_FUNCTION__, __LINE__) + #define get_s(bc) get_s_trace(bc, __FILE__, __PRETTY_FUNCTION__, __LINE__) + #define get_vb(bc) get_vb_trace(bc, __FILE__, __PRETTY_FUNCTION__, __LINE__) + #endif +@@ -104,16 +93,16 @@ + // start= url_ftell(bc) - 8; + + startcode= be2me_64(startcode); +- startcode= av_crc04C11DB7_update(0, &startcode, 8); ++ startcode= ff_crc04C11DB7_update(0, &startcode, 8); + +- init_checksum(bc, av_crc04C11DB7_update, startcode); +- size= get_v(bc); ++ init_checksum(bc, ff_crc04C11DB7_update, startcode); ++ size= ff_get_v(bc); + if(size > 4096) + get_be32(bc); + if(get_checksum(bc) && size > 4096) + return -1; + +- init_checksum(bc, calculate_checksum ? av_crc04C11DB7_update : NULL, 0); ++ init_checksum(bc, calculate_checksum ? ff_crc04C11DB7_update : NULL, 0); + + return size; + } +@@ -171,7 +160,7 @@ + } + + #define GET_V(dst, check) \ +- tmp= get_v(bc);\ ++ tmp= ff_get_v(bc);\ + if(!(check)){\ + av_log(s, AV_LOG_ERROR, "Error " #dst " is (%"PRId64")\n", tmp);\ + return -1;\ +@@ -192,7 +181,7 @@ + + static int decode_main_header(NUTContext *nut){ + AVFormatContext *s= nut->avf; +- ByteIOContext *bc = &s->pb; ++ ByteIOContext *bc = s->pb; + uint64_t tmp, end; + unsigned int stream_count; + int i, j, tmp_stream, tmp_mul, tmp_pts, tmp_size, count, tmp_res; +@@ -203,7 +192,7 @@ + GET_V(tmp , tmp >=2 && tmp <= 3) + GET_V(stream_count , tmp > 0 && tmp <=MAX_STREAMS) + +- nut->max_distance = get_v(bc); ++ nut->max_distance = ff_get_v(bc); + if(nut->max_distance > 65536){ + av_log(s, AV_LOG_DEBUG, "max_distance %d\n", nut->max_distance); + nut->max_distance= 65536; +@@ -224,20 +213,20 @@ + tmp_mul=1; + tmp_stream=0; + for(i=0; i<256;){ +- int tmp_flags = get_v(bc); +- int tmp_fields= get_v(bc); ++ int tmp_flags = ff_get_v(bc); ++ int tmp_fields= ff_get_v(bc); + if(tmp_fields>0) tmp_pts = get_s(bc); +- if(tmp_fields>1) tmp_mul = get_v(bc); +- if(tmp_fields>2) tmp_stream= get_v(bc); +- if(tmp_fields>3) tmp_size = get_v(bc); ++ if(tmp_fields>1) tmp_mul = ff_get_v(bc); ++ if(tmp_fields>2) tmp_stream= ff_get_v(bc); ++ if(tmp_fields>3) tmp_size = ff_get_v(bc); + else tmp_size = 0; +- if(tmp_fields>4) tmp_res = get_v(bc); ++ if(tmp_fields>4) tmp_res = ff_get_v(bc); + else tmp_res = 0; +- if(tmp_fields>5) count = get_v(bc); ++ if(tmp_fields>5) count = ff_get_v(bc); + else count = tmp_mul - tmp_size; + + while(tmp_fields-- > 6) +- get_v(bc); ++ ff_get_v(bc); + + if(count == 0 || i+count > 256){ + av_log(s, AV_LOG_ERROR, "illegal count %d at %d\n", count, i); +@@ -279,7 +268,7 @@ + + static int decode_stream_header(NUTContext *nut){ + AVFormatContext *s= nut->avf; +- ByteIOContext *bc = &s->pb; ++ ByteIOContext *bc = s->pb; + StreamContext *stc; + int class, stream_id; + uint64_t tmp, end; +@@ -295,7 +284,7 @@ + if (!st) + return AVERROR(ENOMEM); + +- class = get_v(bc); ++ class = ff_get_v(bc); + tmp = get_fourcc(bc); + st->codec->codec_tag= tmp; + switch(class) +@@ -324,10 +313,10 @@ + } + GET_V(stc->time_base_id , tmp < nut->time_base_count); + GET_V(stc->msb_pts_shift , tmp < 16); +- stc->max_pts_distance= get_v(bc); ++ stc->max_pts_distance= ff_get_v(bc); + GET_V(stc->decode_delay , tmp < 1000); //sanity limit, raise this if Moore's law is true + st->codec->has_b_frames= stc->decode_delay; +- get_v(bc); //stream flags ++ ff_get_v(bc); //stream flags + + GET_V(st->codec->extradata_size, tmp < (1<<30)); + if(st->codec->extradata_size){ +@@ -338,20 +327,16 @@ + if (st->codec->codec_type == CODEC_TYPE_VIDEO){ + GET_V(st->codec->width , tmp > 0) + GET_V(st->codec->height, tmp > 0) +- st->codec->sample_aspect_ratio.num= get_v(bc); +- st->codec->sample_aspect_ratio.den= get_v(bc); ++ st->codec->sample_aspect_ratio.num= ff_get_v(bc); ++ st->codec->sample_aspect_ratio.den= ff_get_v(bc); + if((!st->codec->sample_aspect_ratio.num) != (!st->codec->sample_aspect_ratio.den)){ +- av_log(s, AV_LOG_ERROR, "invalid aspect ratio\n"); ++ av_log(s, AV_LOG_ERROR, "invalid aspect ratio %d/%d\n", st->codec->sample_aspect_ratio.num, st->codec->sample_aspect_ratio.den); + return -1; + } +- get_v(bc); /* csp type */ ++ ff_get_v(bc); /* csp type */ + }else if (st->codec->codec_type == CODEC_TYPE_AUDIO){ + GET_V(st->codec->sample_rate , tmp > 0) +- tmp= get_v(bc); // samplerate_den +- if(tmp > st->codec->sample_rate){ +- av_log(s, AV_LOG_ERROR, "Bleh, libnut muxed this ;)\n"); +- st->codec->sample_rate= tmp; +- } ++ ff_get_v(bc); // samplerate_den + GET_V(st->codec->channels, tmp > 0) + } + if(skip_reserved(bc, end) || get_checksum(bc)){ +@@ -365,21 +350,22 @@ + + static int decode_info_header(NUTContext *nut){ + AVFormatContext *s= nut->avf; +- ByteIOContext *bc = &s->pb; ++ ByteIOContext *bc = s->pb; + uint64_t tmp; + unsigned int stream_id_plus1, chapter_start, chapter_len, count; + int chapter_id, i; + int64_t value, end; +- char name[256], str_value[1024], type_str[256], *type= type_str; ++ char name[256], str_value[1024], type_str[256]; ++ const char *type; + + end= get_packetheader(nut, bc, 1, INFO_STARTCODE); + end += url_ftell(bc); + + GET_V(stream_id_plus1, tmp <= s->nb_streams) + chapter_id = get_s(bc); +- chapter_start= get_v(bc); +- chapter_len = get_v(bc); +- count = get_v(bc); ++ chapter_start= ff_get_v(bc); ++ chapter_len = ff_get_v(bc); ++ count = ff_get_v(bc); + for(i=0; iavf; +- ByteIOContext *bc = &s->pb; ++ ByteIOContext *bc = s->pb; + int64_t end, tmp; + + nut->last_syncpoint_pos= url_ftell(bc)-8; +@@ -431,12 +418,12 @@ + end= get_packetheader(nut, bc, 1, SYNCPOINT_STARTCODE); + end += url_ftell(bc); + +- tmp= get_v(bc); +- *back_ptr= nut->last_syncpoint_pos - 16*get_v(bc); ++ tmp= ff_get_v(bc); ++ *back_ptr= nut->last_syncpoint_pos - 16*ff_get_v(bc); + if(*back_ptr < 0) + return -1; + +- ff_nut_reset_ts(nut, nut->time_base[tmp % nut->time_base_count], tmp); ++ ff_nut_reset_ts(nut, nut->time_base[tmp % nut->time_base_count], tmp / nut->time_base_count); + + if(skip_reserved(bc, end) || get_checksum(bc)){ + av_log(s, AV_LOG_ERROR, "sync point checksum mismatch\n"); +@@ -451,7 +438,7 @@ + + static int find_and_decode_index(NUTContext *nut){ + AVFormatContext *s= nut->avf; +- ByteIOContext *bc = &s->pb; ++ ByteIOContext *bc = s->pb; + uint64_t tmp, end; + int i, j, syncpoint_count; + int64_t filesize= url_fsize(bc); +@@ -468,7 +455,7 @@ + end= get_packetheader(nut, bc, 1, INDEX_STARTCODE); + end += url_ftell(bc); + +- get_v(bc); //max_pts ++ ff_get_v(bc); //max_pts + GET_V(syncpoint_count, tmp < INT_MAX/8 && tmp > 0) + syncpoints= av_malloc(sizeof(int64_t)*syncpoint_count); + has_keyframe= av_malloc(sizeof(int8_t)*(syncpoint_count+1)); +@@ -481,7 +468,7 @@ + for(i=0; inb_streams; i++){ + int64_t last_pts= -1; + for(j=0; j>=1; +@@ -510,12 +497,12 @@ + return -1; + } + assert(n<=syncpoint_count+1); +- for(; jpriv_data; +- ByteIOContext *bc = &s->pb; ++ ByteIOContext *bc = s->pb; + int64_t pos; + int inited_stream_count; + +@@ -603,7 +590,7 @@ + + static int decode_frame_header(NUTContext *nut, int64_t *pts, int *stream_id, int frame_code){ + AVFormatContext *s= nut->avf; +- ByteIOContext *bc = &s->pb; ++ ByteIOContext *bc = s->pb; + StreamContext *stc; + int size, flags, size_mul, pts_delta, i, reserved_count; + uint64_t tmp; +@@ -623,13 +610,13 @@ + if(flags & FLAG_INVALID) + return -1; + if(flags & FLAG_CODED) +- flags ^= get_v(bc); ++ flags ^= ff_get_v(bc); + if(flags & FLAG_STREAM_ID){ + GET_V(*stream_id, tmp < s->nb_streams) + } + stc= &nut->stream[*stream_id]; + if(flags&FLAG_CODED_PTS){ +- int coded_pts= get_v(bc); ++ int coded_pts= ff_get_v(bc); + //FIXME check last_pts validity? + if(coded_pts < (1<msb_pts_shift)){ + *pts=ff_lsb2full(stc, coded_pts); +@@ -638,12 +625,12 @@ + }else + *pts= stc->last_pts + pts_delta; + if(flags&FLAG_SIZE_MSB){ +- size += size_mul*get_v(bc); ++ size += size_mul*ff_get_v(bc); + } + if(flags&FLAG_RESERVED) +- reserved_count= get_v(bc); ++ reserved_count= ff_get_v(bc); + for(i=0; i 2*nut->max_distance || FFABS(stc->last_pts - *pts) > stc->max_pts_distance){ +@@ -659,7 +646,7 @@ + + static int decode_frame(NUTContext *nut, AVPacket *pkt, int frame_code){ + AVFormatContext *s= nut->avf; +- ByteIOContext *bc = &s->pb; ++ ByteIOContext *bc = s->pb; + int size, stream_id, discard; + int64_t pts, last_IP_pts; + StreamContext *stc; +@@ -695,7 +682,7 @@ + static int nut_read_packet(AVFormatContext *s, AVPacket *pkt) + { + NUTContext *nut = s->priv_data; +- ByteIOContext *bc = &s->pb; ++ ByteIOContext *bc = s->pb; + int i, frame_code=0, ret, skip; + int64_t ts, back_ptr; + +@@ -751,7 +738,7 @@ + + static int64_t nut_read_timestamp(AVFormatContext *s, int stream_index, int64_t *pos_arg, int64_t pos_limit){ + NUTContext *nut = s->priv_data; +- ByteIOContext *bc = &s->pb; ++ ByteIOContext *bc = s->pb; + int64_t pos, pts, back_ptr; + av_log(s, AV_LOG_DEBUG, "read_timestamp(X,%d,%"PRId64",%"PRId64")\n", stream_index, *pos_arg, pos_limit); + +@@ -814,8 +801,8 @@ + pos2= sp->back_ptr - 15; + } + av_log(NULL, AV_LOG_DEBUG, "SEEKTO: %"PRId64"\n", pos2); +- pos= find_startcode(&s->pb, SYNCPOINT_STARTCODE, pos2); +- url_fseek(&s->pb, pos, SEEK_SET); ++ pos= find_startcode(s->pb, SYNCPOINT_STARTCODE, pos2); ++ url_fseek(s->pb, pos, SEEK_SET); + av_log(NULL, AV_LOG_DEBUG, "SP: %"PRId64"\n", pos); + if(pos2 > pos || pos2 + 15 < pos){ + av_log(NULL, AV_LOG_ERROR, "no syncpoint at backptr pos\n"); +diff -u mplayer-1.0~rc2-12/libavformat/nutenc.c ffmpeg-free-0.svn20080206/libavformat/nutenc.c +--- mplayer-1.0~rc2-12/libavformat/nutenc.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/nutenc.c 2008-02-04 11:48:41.000000000 +0100 +@@ -196,14 +196,14 @@ + int forw_ptr= dyn_size + 4*calculate_checksum; + + if(forw_ptr > 4096) +- init_checksum(bc, av_crc04C11DB7_update, 0); ++ init_checksum(bc, ff_crc04C11DB7_update, 0); + put_be64(bc, startcode); + put_v(bc, forw_ptr); + if(forw_ptr > 4096) + put_le32(bc, get_checksum(bc)); + + if(calculate_checksum) +- init_checksum(bc, av_crc04C11DB7_update, 0); ++ init_checksum(bc, ff_crc04C11DB7_update, 0); + put_buffer(bc, dyn_buf, dyn_size); + if(calculate_checksum) + put_le32(bc, get_checksum(bc)); +@@ -216,7 +216,7 @@ + + put_v(bc, 3); /* version */ + put_v(bc, nut->avf->nb_streams); +- put_v(bc, MAX_DISTANCE); ++ put_v(bc, nut->max_distance); + put_v(bc, nut->time_base_count); + + for(i=0; itime_base_count; i++){ +@@ -317,26 +317,27 @@ + return 0; + } + +-static int add_info(ByteIOContext *bc, char *type, char *value){ ++static int add_info(ByteIOContext *bc, const char *type, const char *value){ + put_str(bc, type); + put_s(bc, -1); + put_str(bc, value); + return 1; + } + +-static void write_globalinfo(NUTContext *nut, ByteIOContext *bc){ ++static int write_globalinfo(NUTContext *nut, ByteIOContext *bc){ + AVFormatContext *s= nut->avf; +- ByteIOContext dyn_bc; ++ ByteIOContext *dyn_bc; + uint8_t *dyn_buf=NULL; + int count=0, dyn_size; +- +- url_open_dyn_buf(&dyn_bc); +- +- if(s->title [0]) count+= add_info(&dyn_bc, "Title" , s->title); +- if(s->author [0]) count+= add_info(&dyn_bc, "Author" , s->author); +- if(s->copyright[0]) count+= add_info(&dyn_bc, "Copyright", s->copyright); ++ int ret = url_open_dyn_buf(&dyn_bc); ++ if(ret < 0) ++ return ret; ++ ++ if(s->title [0]) count+= add_info(dyn_bc, "Title" , s->title); ++ if(s->author [0]) count+= add_info(dyn_bc, "Author" , s->author); ++ if(s->copyright[0]) count+= add_info(dyn_bc, "Copyright", s->copyright); + if(!(s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT)) +- count+= add_info(&dyn_bc, "Encoder" , LIBAVFORMAT_IDENT); ++ count+= add_info(dyn_bc, "Encoder" , LIBAVFORMAT_IDENT); + + put_v(bc, 0); //stream_if_plus1 + put_v(bc, 0); //chapter_id +@@ -345,38 +346,46 @@ + + put_v(bc, count); + +- dyn_size= url_close_dyn_buf(&dyn_bc, &dyn_buf); ++ dyn_size= url_close_dyn_buf(dyn_bc, &dyn_buf); + put_buffer(bc, dyn_buf, dyn_size); + av_free(dyn_buf); ++ return 0; + } + +-static void write_headers(NUTContext *nut, ByteIOContext *bc){ +- ByteIOContext dyn_bc; +- int i; +- +- url_open_dyn_buf(&dyn_bc); +- write_mainheader(nut, &dyn_bc); +- put_packet(nut, bc, &dyn_bc, 1, MAIN_STARTCODE); ++static int write_headers(NUTContext *nut, ByteIOContext *bc){ ++ ByteIOContext *dyn_bc; ++ int i, ret; ++ ++ ret = url_open_dyn_buf(&dyn_bc); ++ if(ret < 0) ++ return ret; ++ write_mainheader(nut, dyn_bc); ++ put_packet(nut, bc, dyn_bc, 1, MAIN_STARTCODE); + + for (i=0; i < nut->avf->nb_streams; i++){ + AVCodecContext *codec = nut->avf->streams[i]->codec; + +- url_open_dyn_buf(&dyn_bc); +- write_streamheader(nut, &dyn_bc, codec, i); +- put_packet(nut, bc, &dyn_bc, 1, STREAM_STARTCODE); ++ ret = url_open_dyn_buf(&dyn_bc); ++ if(ret < 0) ++ return ret; ++ write_streamheader(nut, dyn_bc, codec, i); ++ put_packet(nut, bc, dyn_bc, 1, STREAM_STARTCODE); + } + +- url_open_dyn_buf(&dyn_bc); +- write_globalinfo(nut, &dyn_bc); +- put_packet(nut, bc, &dyn_bc, 1, INFO_STARTCODE); ++ ret = url_open_dyn_buf(&dyn_bc); ++ if(ret < 0) ++ return ret; ++ write_globalinfo(nut, dyn_bc); ++ put_packet(nut, bc, dyn_bc, 1, INFO_STARTCODE); + + nut->last_syncpoint_pos= INT_MIN; + nut->header_count++; ++ return 0; + } + + static int write_header(AVFormatContext *s){ + NUTContext *nut = s->priv_data; +- ByteIOContext *bc = &s->pb; ++ ByteIOContext *bc = s->pb; + int i, j; + + nut->avf= s; +@@ -409,6 +418,7 @@ + nut->stream[i].max_pts_distance= FFMAX(1/av_q2d(time_base), 1); + } + ++ nut->max_distance = MAX_DISTANCE; + build_frame_code(s); + assert(nut->frame_code['N'].flags == FLAG_INVALID); + +@@ -441,17 +451,18 @@ + static int write_packet(AVFormatContext *s, AVPacket *pkt){ + NUTContext *nut = s->priv_data; + StreamContext *nus= &nut->stream[pkt->stream_index]; +- ByteIOContext *bc = &s->pb, dyn_bc; ++ ByteIOContext *bc = s->pb, *dyn_bc; + FrameCode *fc; + int64_t coded_pts; + int best_length, frame_code, flags, needed_flags, i; + int key_frame = !!(pkt->flags & PKT_FLAG_KEY); + int store_sp=0; ++ int ret; + + if(1LL<<(20+3*nut->header_count) <= url_ftell(bc)) + write_headers(nut, bc); + +- if(key_frame && !!(nus->last_flags & FLAG_KEY)) ++ if(key_frame && !(nus->last_flags & FLAG_KEY)) + store_sp= 1; + + if(pkt->size + 30/*FIXME check*/ + url_ftell(bc) >= nut->last_syncpoint_pos + nut->max_distance) +@@ -465,17 +476,24 @@ + ff_nut_reset_ts(nut, *nus->time_base, pkt->dts); + for(i=0; inb_streams; i++){ + AVStream *st= s->streams[i]; +- int index= av_index_search_timestamp(st, pkt->dts, AVSEEK_FLAG_BACKWARD); +- if(index<0) dummy.pos=0; +- else dummy.pos= FFMIN(dummy.pos, st->index_entries[index].pos); ++ int64_t dts_tb = av_rescale_rnd(pkt->dts, ++ nus->time_base->num * (int64_t)nut->stream[i].time_base->den, ++ nus->time_base->den * (int64_t)nut->stream[i].time_base->num, ++ AV_ROUND_DOWN); ++ int index= av_index_search_timestamp(st, dts_tb, AVSEEK_FLAG_BACKWARD); ++ if(index>=0) dummy.pos= FFMIN(dummy.pos, st->index_entries[index].pos); + } ++ if(dummy.pos == INT64_MAX) ++ dummy.pos= 0; + sp= av_tree_find(nut->syncpoints, &dummy, ff_nut_sp_pos_cmp, NULL); + + nut->last_syncpoint_pos= url_ftell(bc); +- url_open_dyn_buf(&dyn_bc); +- put_t(nut, nus, &dyn_bc, pkt->dts); +- put_v(&dyn_bc, sp ? (nut->last_syncpoint_pos - sp->pos)>>4 : 0); +- put_packet(nut, bc, &dyn_bc, 1, SYNCPOINT_STARTCODE); ++ ret = url_open_dyn_buf(&dyn_bc); ++ if(ret < 0) ++ return ret; ++ put_t(nut, nus, dyn_bc, pkt->dts); ++ put_v(dyn_bc, sp ? (nut->last_syncpoint_pos - sp->pos)>>4 : 0); ++ put_packet(nut, bc, dyn_bc, 1, SYNCPOINT_STARTCODE); + + ff_nut_add_sp(nut, nut->last_syncpoint_pos, 0/*unused*/, pkt->dts); + } +@@ -535,7 +553,7 @@ + flags= fc->flags; + needed_flags= get_needed_flags(nut, nus, fc, pkt); + +- init_checksum(bc, av_crc04C11DB7_update, 0); ++ init_checksum(bc, ff_crc04C11DB7_update, 0); + put_byte(bc, frame_code); + if(flags & FLAG_CODED){ + put_v(bc, (flags^needed_flags) & ~(FLAG_CODED)); +@@ -566,7 +584,7 @@ + + static int write_trailer(AVFormatContext *s){ + NUTContext *nut= s->priv_data; +- ByteIOContext *bc= &s->pb; ++ ByteIOContext *bc= s->pb; + + while(nut->header_count<3) + write_headers(nut, bc); +diff -u mplayer-1.0~rc2-12/libavformat/nut.h ffmpeg-free-0.svn20080206/libavformat/nut.h +--- mplayer-1.0~rc2-12/libavformat/nut.h 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/nut.h 2007-10-30 01:01:25.000000000 +0100 +@@ -19,12 +19,11 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef AVFORMAT_NUT_H +-#define AVFORMAT_NUT_H ++#ifndef FFMPEG_NUT_H ++#define FFMPEG_NUT_H + + //#include + #include "avformat.h" +-#include "crc.h" + //#include "mpegaudio.h" + #include "riff.h" + //#include "adler32.h" +@@ -93,11 +92,10 @@ + struct AVTreeNode *syncpoints; + } NUTContext; + +-unsigned long av_crc04C11DB7_update(unsigned long checksum, const uint8_t *buf, unsigned int len); + void ff_nut_reset_ts(NUTContext *nut, AVRational time_base, int64_t val); + int64_t ff_lsb2full(StreamContext *stream, int64_t lsb); + int ff_nut_sp_pos_cmp(syncpoint_t *a, syncpoint_t *b); + int ff_nut_sp_pts_cmp(syncpoint_t *a, syncpoint_t *b); + void ff_nut_add_sp(NUTContext *nut, int64_t pos, int64_t back_ptr, int64_t ts); + +-#endif /* AVFORMAT_NUT_H */ ++#endif /* FFMPEG_NUT_H */ +diff -u mplayer-1.0~rc2-12/libavformat/nuv.c ffmpeg-free-0.svn20080206/libavformat/nuv.c +--- mplayer-1.0~rc2-12/libavformat/nuv.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/nuv.c 2007-11-21 08:41:00.000000000 +0100 +@@ -120,7 +120,7 @@ + + static int nuv_header(AVFormatContext *s, AVFormatParameters *ap) { + NUVContext *ctx = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + char id_string[12], version_string[5]; + double aspect, fps; + int is_mythtv, width, height, v_packs, a_packs; +@@ -183,7 +183,7 @@ + + static int nuv_packet(AVFormatContext *s, AVPacket *pkt) { + NUVContext *ctx = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + uint8_t hdr[HDRSIZE]; + frametype_t frametype; + int ret, size; +Only in mplayer-1.0~rc2-12/libavformat: ogg2.c +Only in mplayer-1.0~rc2-12/libavformat: ogg2.h +Only in mplayer-1.0~rc2-12/libavformat: ogg.c +Only in ffmpeg-free-0.svn20080206/libavformat: oggdec.c +Only in ffmpeg-free-0.svn20080206/libavformat: oggdec.h +Only in ffmpeg-free-0.svn20080206/libavformat: oggenc.c +diff -u mplayer-1.0~rc2-12/libavformat/oggparseflac.c ffmpeg-free-0.svn20080206/libavformat/oggparseflac.c +--- mplayer-1.0~rc2-12/libavformat/oggparseflac.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/oggparseflac.c 2007-11-07 21:22:32.000000000 +0100 +@@ -21,7 +21,7 @@ + #include + #include "avformat.h" + #include "bitstream.h" +-#include "ogg2.h" ++#include "oggdec.h" + + #define FLAC_STREAMINFO_SIZE 0x22 + +diff -u mplayer-1.0~rc2-12/libavformat/oggparseogm.c ffmpeg-free-0.svn20080206/libavformat/oggparseogm.c +--- mplayer-1.0~rc2-12/libavformat/oggparseogm.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/oggparseogm.c 2008-02-01 16:17:43.000000000 +0100 +@@ -27,7 +27,7 @@ + #include "bitstream.h" + #include "bytestream.h" + #include "intreadwrite.h" +-#include "ogg2.h" ++#include "oggdec.h" + #include "riff.h" + + static int +@@ -36,7 +36,7 @@ + ogg_t *ogg = s->priv_data; + ogg_stream_t *os = ogg->streams + idx; + AVStream *st = s->streams[idx]; +- uint8_t *p = os->buf + os->pstart; ++ const uint8_t *p = os->buf + os->pstart; + uint64_t time_unit; + uint64_t spu; + uint32_t default_len; +@@ -55,6 +55,10 @@ + tag = bytestream_get_le32(&p); + st->codec->codec_id = codec_get_id(codec_bmp_tags, tag); + st->codec->codec_tag = tag; ++ } else if (*p == 't') { ++ st->codec->codec_type = CODEC_TYPE_SUBTITLE; ++ st->codec->codec_id = CODEC_ID_TEXT; ++ p += 12; + } else { + uint8_t acid[5]; + int cid; +@@ -134,6 +138,9 @@ + uint8_t *p = os->buf + os->pstart; + int lb; + ++ if(*p & 8) ++ os->pflags |= PKT_FLAG_KEY; ++ + lb = ((*p & 2) << 1) | ((*p >> 6) & 3); + os->pstart += lb + 1; + os->psize -= lb + 1; +@@ -155,6 +162,13 @@ + .packet = ogm_packet + }; + ++ogg_codec_t ogm_text_codec = { ++ .magic = "\001text", ++ .magicsize = 5, ++ .header = ogm_header, ++ .packet = ogm_packet ++}; ++ + ogg_codec_t ogm_old_codec = { + .magic = "\001Direct Show Samples embedded in Ogg", + .magicsize = 35, +diff -u mplayer-1.0~rc2-12/libavformat/oggparsetheora.c ffmpeg-free-0.svn20080206/libavformat/oggparsetheora.c +--- mplayer-1.0~rc2-12/libavformat/oggparsetheora.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/oggparsetheora.c 2007-11-11 22:56:18.000000000 +0100 +@@ -26,7 +26,7 @@ + #include "avformat.h" + #include "bitstream.h" + #include "bswap.h" +-#include "ogg2.h" ++#include "oggdec.h" + + typedef struct theora_params { + int gpshift; +@@ -124,6 +124,9 @@ + uint64_t iframe = gp >> thp->gpshift; + uint64_t pframe = gp & thp->gpmask; + ++ if(!pframe) ++ os->pflags |= PKT_FLAG_KEY; ++ + return iframe + pframe; + } + +diff -u mplayer-1.0~rc2-12/libavformat/oggparsevorbis.c ffmpeg-free-0.svn20080206/libavformat/oggparsevorbis.c +--- mplayer-1.0~rc2-12/libavformat/oggparsevorbis.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/oggparsevorbis.c 2008-02-01 16:17:32.000000000 +0100 +@@ -25,47 +25,41 @@ + #include + #include "avformat.h" + #include "bitstream.h" ++#include "bytestream.h" + #include "bswap.h" +-#include "ogg2.h" ++#include "oggdec.h" + #include "avstring.h" + + extern int + vorbis_comment(AVFormatContext * as, uint8_t *buf, int size) + { +- char *p = buf; +- int s, n, j; ++ const uint8_t *p = buf; ++ const uint8_t *end = buf + size; ++ unsigned s, n, j; + +- if (size < 4) ++ if (size < 8) /* must have vendor_length and user_comment_list_length */ + return -1; + +- s = AV_RL32(p); +- p += 4; +- size -= 4; ++ s = bytestream_get_le32(&p); + +- if (size < s + 4) ++ if (end - p < s) + return -1; + + p += s; +- size -= s; + +- n = AV_RL32(p); +- p += 4; +- size -= 4; ++ n = bytestream_get_le32(&p); + +- while (size >= 4) { +- char *t, *v; ++ while (p < end && n > 0) { ++ const char *t, *v; + int tl, vl; + +- s = AV_RL32(p); +- p += 4; +- size -= 4; ++ s = bytestream_get_le32(&p); + +- if (size < s) ++ if (end - p < s) + break; + + t = p; + p += s; +- size -= s; + n--; + + v = memchr(t, '=', s); +@@ -102,15 +96,11 @@ + as->track = atoi(ct); + else if (!strcmp(tt, "ALBUM")) + av_strlcpy(as->album, ct, sizeof(as->album)); +- else if (!strcmp(tt, "GENRE")) +- av_strlcpy(as->genre, ct, sizeof(as->genre)); +- else if (!strcmp(tt, "DESCRIPTION")) +- av_strlcpy(as->comment, ct, sizeof(as->comment)); + } + } + +- if (size > 0) +- av_log(as, AV_LOG_INFO, "%i bytes of comment header remain\n", size); ++ if (p != end) ++ av_log(as, AV_LOG_INFO, "%ti bytes of comment header remain\n", p-end); + if (n > 0) + av_log(as, AV_LOG_INFO, + "truncated comment header, %i comments not found\n", n); +@@ -178,16 +168,40 @@ + return 0; + } + ++ if (os->psize < 1) ++ return -1; ++ + priv = os->private; + priv->len[os->seq] = os->psize; + priv->packet[os->seq] = av_mallocz(os->psize); + memcpy(priv->packet[os->seq], os->buf + os->pstart, os->psize); + if (os->buf[os->pstart] == 1) { +- uint8_t *p = os->buf + os->pstart + 11; //skip up to the audio channels +- st->codec->channels = *p++; +- st->codec->sample_rate = AV_RL32(p); +- p += 8; //skip maximum and and nominal bitrate +- st->codec->bit_rate = AV_RL32(p); //Minimum bitrate ++ const uint8_t *p = os->buf + os->pstart + 7; /* skip "\001vorbis" tag */ ++ unsigned blocksize, bs0, bs1; ++ ++ if (os->psize != 30) ++ return -1; ++ ++ if (bytestream_get_le32(&p) != 0) /* vorbis_version */ ++ return -1; ++ ++ st->codec->channels = bytestream_get_byte(&p); ++ st->codec->sample_rate = bytestream_get_le32(&p); ++ p += 4; // skip maximum bitrate ++ st->codec->bit_rate = bytestream_get_le32(&p); // nominal bitrate ++ p += 4; // skip minimum bitrate ++ ++ blocksize = bytestream_get_byte(&p); ++ bs0 = blocksize & 15; ++ bs1 = blocksize >> 4; ++ ++ if (bs0 > bs1) ++ return -1; ++ if (bs0 < 6 || bs1 > 13) ++ return -1; ++ ++ if (bytestream_get_byte(&p) != 1) /* framing_flag */ ++ return -1; + + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_id = CODEC_ID_VORBIS; +@@ -195,7 +209,8 @@ + st->time_base.num = 1; + st->time_base.den = st->codec->sample_rate; + } else if (os->buf[os->pstart] == 3) { +- vorbis_comment (s, os->buf + os->pstart + 7, os->psize - 8); ++ if (os->psize > 8) ++ vorbis_comment (s, os->buf + os->pstart + 7, os->psize - 8); + } else { + st->codec->extradata_size = + fixup_vorbis_headers(s, priv, &st->codec->extradata); +diff -u mplayer-1.0~rc2-12/libavformat/os_support.c ffmpeg-free-0.svn20080206/libavformat/os_support.c +--- mplayer-1.0~rc2-12/libavformat/os_support.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/os_support.c 2007-12-27 02:38:50.000000000 +0100 +@@ -23,16 +23,17 @@ + #include "avformat.h" + #include + #include ++#include "os_support.h" + ++#ifdef CONFIG_NETWORK + #ifndef HAVE_SYS_POLL_H + #ifdef HAVE_WINSOCK2_H + #include +-#else ++#elif defined (HAVE_SYS_SELECT_H) + #include + #endif + #endif + +-#ifdef CONFIG_NETWORK + #include "network.h" + + #if !defined(HAVE_INET_ATON) +diff -u mplayer-1.0~rc2-12/libavformat/os_support.h ffmpeg-free-0.svn20080206/libavformat/os_support.h +--- mplayer-1.0~rc2-12/libavformat/os_support.h 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/os_support.h 2008-01-01 23:54:35.000000000 +0100 +@@ -19,21 +19,15 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef OS_SUPPORT_H +-#define OS_SUPPORT_H ++#ifndef FFMPEG_OS_SUPPORT_H ++#define FFMPEG_OS_SUPPORT_H + + /** + * @file os_support.h + * miscellaneous OS support macros and functions. +- * +- * - socklen_t typedef (BeOS, Innotek libc) +- * - usleep() (Win32, BeOS) +- * - lseek() (Win32) +- * - closesocket() +- * - poll() (BeOS, MinGW) + */ + +-#if defined(__BEOS__) || defined(__INNOTEK_LIBC__) ++#ifndef HAVE_SOCKLEN_T + typedef int socklen_t; + #endif + +@@ -96,4 +90,4 @@ + #endif /* HAVE_SYS_POLL_H */ + #endif /* CONFIG_FFSERVER */ + +-#endif /* OS_SUPPORT_H */ ++#endif /* FFMPEG_OS_SUPPORT_H */ +diff -u mplayer-1.0~rc2-12/libavformat/psxstr.c ffmpeg-free-0.svn20080206/libavformat/psxstr.c +--- mplayer-1.0~rc2-12/libavformat/psxstr.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/psxstr.c 2007-11-21 08:41:00.000000000 +0100 +@@ -125,7 +125,7 @@ + static int str_read_header(AVFormatContext *s, + AVFormatParameters *ap) + { +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + StrDemuxContext *str = s->priv_data; + AVStream *st; + unsigned char sector[RAW_CD_SECTOR_SIZE]; +@@ -249,7 +249,7 @@ + static int str_read_packet(AVFormatContext *s, + AVPacket *ret_pkt) + { +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + StrDemuxContext *str = s->priv_data; + unsigned char sector[RAW_CD_SECTOR_SIZE]; + int channel; +Only in ffmpeg-free-0.svn20080206/libavformat: pva.c +diff -u mplayer-1.0~rc2-12/libavformat/qtpalette.h ffmpeg-free-0.svn20080206/libavformat/qtpalette.h +--- mplayer-1.0~rc2-12/libavformat/qtpalette.h 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/qtpalette.h 2007-12-03 13:46:20.000000000 +0100 +@@ -20,17 +20,19 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef QTPALETTE_H +-#define QTPALETTE_H ++#ifndef FFMPEG_QTPALETTE_H ++#define FFMPEG_QTPALETTE_H + +-unsigned char ff_qt_default_palette_4[4 * 4] = { ++#include ++ ++static const uint8_t ff_qt_default_palette_4[4 * 4] = { + 0x93, 0x65, 0x5E, 0x00, + 0xFF, 0xFF, 0xFF, 0x00, + 0xDF, 0xD0, 0xAB, 0x00, + 0x00, 0x00, 0x00, 0x00 + }; + +-unsigned char ff_qt_default_palette_16[16 * 4] = { ++static const uint8_t ff_qt_default_palette_16[16 * 4] = { + 0xFF, 0xFB, 0xFF, 0x00, + 0xEF, 0xD9, 0xBB, 0x00, + 0xE8, 0xC9, 0xB1, 0x00, +@@ -49,7 +51,7 @@ + 0x00, 0x00, 0x00, 0x00 + }; + +-unsigned char ff_qt_default_palette_256[256 * 4] = { ++static const uint8_t ff_qt_default_palette_256[256 * 4] = { + /* 0, 0x00 */ 0xFF, 0xFF, 0xFF, 0x00, + /* 1, 0x01 */ 0xFF, 0xFF, 0xCC, 0x00, + /* 2, 0x02 */ 0xFF, 0xFF, 0x99, 0x00, +@@ -308,4 +310,4 @@ + /* 255, 0xFF */ 0x00, 0x00, 0x00, 0x00 + }; + +-#endif ++#endif /* FFMPEG_QTPALETTE_H */ +diff -u mplayer-1.0~rc2-12/libavformat/raw.c ffmpeg-free-0.svn20080206/libavformat/raw.c +--- mplayer-1.0~rc2-12/libavformat/raw.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/raw.c 2008-01-12 01:24:10.000000000 +0100 +@@ -33,8 +33,8 @@ + uint8_t *streaminfo = s->streams[0]->codec->extradata; + int len = s->streams[0]->codec->extradata_size; + if(streaminfo != NULL && len > 0) { +- put_buffer(&s->pb, header, 8); +- put_buffer(&s->pb, streaminfo, len); ++ put_buffer(s->pb, header, 8); ++ put_buffer(s->pb, streaminfo, len); + } + return 0; + } +@@ -46,16 +46,16 @@ + 0x84, 0x10, 0xFF, 0xFF, 0xFF, 0xFF, 0x1E, 0x00 + }; + +- put_buffer(&s->pb, header, 8); +- put_flush_packet(&s->pb); ++ put_buffer(s->pb, header, 8); ++ put_flush_packet(s->pb); + + return 0; + } + + static int raw_write_packet(struct AVFormatContext *s, AVPacket *pkt) + { +- put_buffer(&s->pb, pkt->data, pkt->size); +- put_flush_packet(&s->pb); ++ put_buffer(s->pb, pkt->data, pkt->size); ++ put_flush_packet(s->pb); + return 0; + } + #endif //CONFIG_MUXERS +@@ -85,7 +85,10 @@ + av_set_pts_info(st, 64, 1, st->codec->sample_rate); + break; + case CODEC_TYPE_VIDEO: +- av_set_pts_info(st, 64, ap->time_base.num, ap->time_base.den); ++ if(ap->time_base.num) ++ av_set_pts_info(st, 64, ap->time_base.num, ap->time_base.den); ++ else ++ av_set_pts_info(st, 64, 1, 25); + st->codec->width = ap->width; + st->codec->height = ap->height; + st->codec->pix_fmt = ap->pix_fmt; +@@ -102,12 +105,12 @@ + + static int raw_read_packet(AVFormatContext *s, AVPacket *pkt) + { +- int ret, size; ++ int ret, size, bps; + // AVStream *st = s->streams[0]; + + size= RAW_PACKET_SIZE; + +- ret= av_get_packet(&s->pb, pkt, size); ++ ret= av_get_packet(s->pb, pkt, size); + + pkt->stream_index = 0; + if (ret <= 0) { +@@ -116,6 +119,12 @@ + /* note: we need to modify the packet size here to handle the last + packet */ + pkt->size = ret; ++ ++ bps= av_get_bits_per_sample(s->streams[0]->codec->codec_id); ++ assert(bps); // if false there IS a bug elsewhere (NOT in this function) ++ pkt->dts= ++ pkt->pts= pkt->pos*8 / (bps * s->streams[0]->codec->channels); ++ + return ret; + } + +@@ -128,9 +137,9 @@ + if (av_new_packet(pkt, size) < 0) + return AVERROR(EIO); + +- pkt->pos= url_ftell(&s->pb); ++ pkt->pos= url_ftell(s->pb); + pkt->stream_index = 0; +- ret = get_partial_buffer(&s->pb, pkt->data, size); ++ ret = get_partial_buffer(s->pb, pkt->data, size); + if (ret <= 0) { + av_free_packet(pkt); + return AVERROR(EIO); +@@ -144,19 +153,19 @@ + { + int ret, size, w, h, unk1, unk2; + +- if (get_le32(&s->pb) != MKTAG('M', 'J', 'P', 'G')) ++ if (get_le32(s->pb) != MKTAG('M', 'J', 'P', 'G')) + return AVERROR(EIO); // FIXME + +- size = get_le32(&s->pb); ++ size = get_le32(s->pb); + +- w = get_le16(&s->pb); +- h = get_le16(&s->pb); ++ w = get_le16(s->pb); ++ h = get_le16(s->pb); + +- url_fskip(&s->pb, 8); // zero + size (padded?) +- url_fskip(&s->pb, 2); +- unk1 = get_le16(&s->pb); +- unk2 = get_le16(&s->pb); +- url_fskip(&s->pb, 22); // ascii timestamp ++ url_fskip(s->pb, 8); // zero + size (padded?) ++ url_fskip(s->pb, 2); ++ unk1 = get_le16(s->pb); ++ unk2 = get_le16(s->pb); ++ url_fskip(s->pb, 22); // ascii timestamp + + av_log(NULL, AV_LOG_DEBUG, "Ingenient packet: size=%d, width=%d, height=%d, unk1=%d unk2=%d\n", + size, w, h, unk1, unk2); +@@ -164,9 +173,9 @@ + if (av_new_packet(pkt, size) < 0) + return AVERROR(EIO); + +- pkt->pos = url_ftell(&s->pb); ++ pkt->pos = url_ftell(s->pb); + pkt->stream_index = 0; +- ret = get_buffer(&s->pb, pkt->data, size); ++ ret = get_buffer(s->pb, pkt->data, size); + if (ret <= 0) { + av_free_packet(pkt); + return AVERROR(EIO); +@@ -206,7 +215,7 @@ + + /* recompute exact position */ + st->cur_dts = av_rescale(pos, st->time_base.den, byte_rate * (int64_t)st->time_base.num); +- url_fseek(&s->pb, pos + s->data_offset, SEEK_SET); ++ url_fseek(s->pb, pos + s->data_offset, SEEK_SET); + return 0; + } + +@@ -843,7 +852,9 @@ + if (packet_size < 0) + return -1; + +- ret= av_get_packet(&s->pb, pkt, packet_size); ++ ret= av_get_packet(s->pb, pkt, packet_size); ++ pkt->pts= ++ pkt->dts= pkt->pos / packet_size; + + pkt->stream_index = 0; + if (ret != packet_size) { +diff -u mplayer-1.0~rc2-12/libavformat/raw.h ffmpeg-free-0.svn20080206/libavformat/raw.h +--- mplayer-1.0~rc2-12/libavformat/raw.h 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/raw.h 2007-10-17 11:37:46.000000000 +0200 +@@ -19,12 +19,12 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef AVFORMAT_RAW_H +-#define AVFORMAT_RAW_H ++#ifndef FFMPEG_RAW_H ++#define FFMPEG_RAW_H + + #include "avformat.h" + + int pcm_read_seek(AVFormatContext *s, + int stream_index, int64_t timestamp, int flags); + +-#endif /* AVFORMAT_RAW_H */ ++#endif /* FFMPEG_RAW_H */ +diff -u mplayer-1.0~rc2-12/libavformat/riff.c ffmpeg-free-0.svn20080206/libavformat/riff.c +--- mplayer-1.0~rc2-12/libavformat/riff.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/riff.c 2008-02-04 13:18:00.000000000 +0100 +@@ -87,6 +87,7 @@ + { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 'h', 'd') }, + { CODEC_ID_DVVIDEO, MKTAG('d', 'v', 's', 'l') }, + { CODEC_ID_DVVIDEO, MKTAG('d', 'v', '2', '5') }, ++ { CODEC_ID_DVVIDEO, MKTAG('d', 'v', '5', '0') }, + { CODEC_ID_MPEG1VIDEO, MKTAG('m', 'p', 'g', '1') }, + { CODEC_ID_MPEG1VIDEO, MKTAG('m', 'p', 'g', '2') }, + { CODEC_ID_MPEG2VIDEO, MKTAG('m', 'p', 'g', '2') }, +diff -u mplayer-1.0~rc2-12/libavformat/riff.h ffmpeg-free-0.svn20080206/libavformat/riff.h +--- mplayer-1.0~rc2-12/libavformat/riff.h 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/riff.h 2007-10-17 11:37:46.000000000 +0200 +@@ -25,8 +25,8 @@ + * do NOT include this in end user applications + */ + +-#ifndef FF_RIFF_H +-#define FF_RIFF_H ++#ifndef FFMPEG_RIFF_H ++#define FFMPEG_RIFF_H + + #include "avcodec.h" + #include "avio.h" +@@ -51,4 +51,4 @@ + enum CodecID codec_get_id(const AVCodecTag *tags, unsigned int tag); + void ff_parse_specific_params(AVCodecContext *stream, int *au_rate, int *au_ssize, int *au_scale); + +-#endif ++#endif /* FFMPEG_RIFF_H */ +diff -u mplayer-1.0~rc2-12/libavformat/rmdec.c ffmpeg-free-0.svn20080206/libavformat/rmdec.c +--- mplayer-1.0~rc2-12/libavformat/rmdec.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/rmdec.c 2008-01-17 21:48:07.000000000 +0100 +@@ -50,7 +50,7 @@ + int read_all) + { + RMContext *rm = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + char buf[256]; + uint32_t version; + int i; +@@ -188,6 +188,74 @@ + return 0; + } + ++int ++ff_rm_read_mdpr_codecdata (AVFormatContext *s, AVStream *st) ++{ ++ ByteIOContext *pb = s->pb; ++ unsigned int v; ++ int codec_data_size, size; ++ int64_t codec_pos; ++ ++ codec_data_size = get_be32(pb); ++ codec_pos = url_ftell(pb); ++ v = get_be32(pb); ++ if (v == MKTAG(0xfd, 'a', 'r', '.')) { ++ /* ra type header */ ++ if (rm_read_audio_stream_info(s, st, 0)) ++ return -1; ++ } else { ++ int fps, fps2; ++ if (get_le32(pb) != MKTAG('V', 'I', 'D', 'O')) { ++ fail1: ++ av_log(st->codec, AV_LOG_ERROR, "Unsupported video codec\n"); ++ goto skip; ++ } ++ st->codec->codec_tag = get_le32(pb); ++// av_log(NULL, AV_LOG_DEBUG, "%X %X\n", st->codec->codec_tag, MKTAG('R', 'V', '2', '0')); ++ if ( st->codec->codec_tag != MKTAG('R', 'V', '1', '0') ++ && st->codec->codec_tag != MKTAG('R', 'V', '2', '0') ++ && st->codec->codec_tag != MKTAG('R', 'V', '3', '0') ++ && st->codec->codec_tag != MKTAG('R', 'V', '4', '0')) ++ goto fail1; ++ st->codec->width = get_be16(pb); ++ st->codec->height = get_be16(pb); ++ st->codec->time_base.num= 1; ++ fps= get_be16(pb); ++ st->codec->codec_type = CODEC_TYPE_VIDEO; ++ get_be32(pb); ++ fps2= get_be16(pb); ++ get_be16(pb); ++ ++ st->codec->extradata_size= codec_data_size - (url_ftell(pb) - codec_pos); ++ ++ if(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE <= (unsigned)st->codec->extradata_size){ ++ //check is redundant as get_buffer() will catch this ++ av_log(s, AV_LOG_ERROR, "st->codec->extradata_size too large\n"); ++ return -1; ++ } ++ st->codec->extradata= av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); ++ get_buffer(pb, st->codec->extradata, st->codec->extradata_size); ++ ++// av_log(NULL, AV_LOG_DEBUG, "fps= %d fps2= %d\n", fps, fps2); ++ st->codec->time_base.den = fps * st->codec->time_base.num; ++ switch(((uint8_t*)st->codec->extradata)[4]>>4){ ++ case 1: st->codec->codec_id = CODEC_ID_RV10; break; ++ case 2: st->codec->codec_id = CODEC_ID_RV20; break; ++ case 3: st->codec->codec_id = CODEC_ID_RV30; break; ++ case 4: st->codec->codec_id = CODEC_ID_RV40; break; ++ default: goto fail1; ++ } ++ } ++ ++skip: ++ /* skip codec info */ ++ size = url_ftell(pb) - codec_pos; ++ url_fskip(pb, codec_data_size - size); ++ ++ return 0; ++} ++ ++ + static int rm_read_header_old(AVFormatContext *s, AVFormatParameters *ap) + { + RMContext *rm = s->priv_data; +@@ -204,10 +272,9 @@ + { + RMContext *rm = s->priv_data; + AVStream *st; +- ByteIOContext *pb = &s->pb; +- unsigned int tag, v; +- int tag_size, size, codec_data_size, i; +- int64_t codec_pos; ++ ByteIOContext *pb = s->pb; ++ unsigned int tag; ++ int tag_size, i; + unsigned int start_time, duration; + char buf[128]; + int flags = 0; +@@ -279,63 +346,10 @@ + st->duration = duration; + get_str8(pb, buf, sizeof(buf)); /* desc */ + get_str8(pb, buf, sizeof(buf)); /* mimetype */ +- codec_data_size = get_be32(pb); +- codec_pos = url_ftell(pb); + st->codec->codec_type = CODEC_TYPE_DATA; + av_set_pts_info(st, 64, 1, 1000); +- +- v = get_be32(pb); +- if (v == MKTAG(0xfd, 'a', 'r', '.')) { +- /* ra type header */ +- if (rm_read_audio_stream_info(s, st, 0)) +- return -1; +- } else { +- int fps, fps2; +- if (get_le32(pb) != MKTAG('V', 'I', 'D', 'O')) { +- fail1: +- av_log(st->codec, AV_LOG_ERROR, "Unsupported video codec\n"); +- goto skip; +- } +- st->codec->codec_tag = get_le32(pb); +-// av_log(NULL, AV_LOG_DEBUG, "%X %X\n", st->codec->codec_tag, MKTAG('R', 'V', '2', '0')); +- if ( st->codec->codec_tag != MKTAG('R', 'V', '1', '0') +- && st->codec->codec_tag != MKTAG('R', 'V', '2', '0') +- && st->codec->codec_tag != MKTAG('R', 'V', '3', '0') +- && st->codec->codec_tag != MKTAG('R', 'V', '4', '0')) +- goto fail1; +- st->codec->width = get_be16(pb); +- st->codec->height = get_be16(pb); +- st->codec->time_base.num= 1; +- fps= get_be16(pb); +- st->codec->codec_type = CODEC_TYPE_VIDEO; +- get_be32(pb); +- fps2= get_be16(pb); +- get_be16(pb); +- +- st->codec->extradata_size= codec_data_size - (url_ftell(pb) - codec_pos); +- +- if(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE <= (unsigned)st->codec->extradata_size){ +- //check is redundant as get_buffer() will catch this +- av_log(s, AV_LOG_ERROR, "st->codec->extradata_size too large\n"); +- return -1; +- } +- st->codec->extradata= av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE); +- get_buffer(pb, st->codec->extradata, st->codec->extradata_size); +- +-// av_log(NULL, AV_LOG_DEBUG, "fps= %d fps2= %d\n", fps, fps2); +- st->codec->time_base.den = fps * st->codec->time_base.num; +- switch(((uint8_t*)st->codec->extradata)[4]>>4){ +- case 1: st->codec->codec_id = CODEC_ID_RV10; break; +- case 2: st->codec->codec_id = CODEC_ID_RV20; break; +- case 3: st->codec->codec_id = CODEC_ID_RV30; break; +- case 4: st->codec->codec_id = CODEC_ID_RV40; break; +- default: goto fail1; +- } +- } +-skip: +- /* skip codec info */ +- size = url_ftell(pb) - codec_pos; +- url_fskip(pb, codec_data_size - size); ++ if (ff_rm_read_mdpr_codecdata(s, st) < 0) ++ return -1; + break; + case MKTAG('D', 'A', 'T', 'A'): + goto header_end; +@@ -350,6 +364,7 @@ + if (!rm->nb_packets && (flags & 4)) + rm->nb_packets = 3600 * 25; + get_be32(pb); /* next data header */ ++ rm->curpic_num = -1; + return 0; + + fail: +@@ -365,6 +380,7 @@ + + n = get_be16(pb); + (*len)-=2; ++ n &= 0x7FFF; + if (n >= 0x4000) { + return n - 0x4000; + } else { +@@ -379,7 +395,7 @@ + + static int sync(AVFormatContext *s, int64_t *timestamp, int *flags, int *stream_index, int64_t *pos){ + RMContext *rm = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + int len, num, res, i; + AVStream *st; + uint32_t state=0xFFFFFFFF; +@@ -433,30 +449,235 @@ + return -1; + } + ++static int rm_assemble_video_frame(AVFormatContext *s, RMContext *rm, AVPacket *pkt, int len) ++{ ++ ByteIOContext *pb = s->pb; ++ int hdr, seq, pic_num, len2, pos; ++ int type; ++ ++ hdr = get_byte(pb); len--; ++ type = hdr >> 6; ++ switch(type){ ++ case 0: // slice ++ case 2: // last slice ++ seq = get_byte(pb); len--; ++ len2 = get_num(pb, &len); ++ pos = get_num(pb, &len); ++ pic_num = get_byte(pb); len--; ++ rm->remaining_len = len; ++ break; ++ case 1: //whole frame ++ seq = get_byte(pb); len--; ++ if(av_new_packet(pkt, len + 9) < 0) ++ return AVERROR(EIO); ++ pkt->data[0] = 0; ++ AV_WL32(pkt->data + 1, 1); ++ AV_WL32(pkt->data + 5, 0); ++ get_buffer(pb, pkt->data + 9, len); ++ rm->remaining_len = 0; ++ return 0; ++ case 3: //frame as a part of packet ++ len2 = get_num(pb, &len); ++ pos = get_num(pb, &len); ++ pic_num = get_byte(pb); len--; ++ rm->remaining_len = len - len2; ++ if(av_new_packet(pkt, len2 + 9) < 0) ++ return AVERROR(EIO); ++ pkt->data[0] = 0; ++ AV_WL32(pkt->data + 1, 1); ++ AV_WL32(pkt->data + 5, 0); ++ get_buffer(pb, pkt->data + 9, len2); ++ return 0; ++ } ++ //now we have to deal with single slice ++ ++ if((seq & 0x7F) == 1 || rm->curpic_num != pic_num){ ++ rm->slices = ((hdr & 0x3F) << 1) + 1; ++ rm->videobufsize = len2 + 8*rm->slices + 1; ++ av_free(rm->videobuf); ++ if(!(rm->videobuf = av_malloc(rm->videobufsize))) ++ return AVERROR(ENOMEM); ++ rm->videobufpos = 8*rm->slices + 1; ++ rm->cur_slice = 0; ++ rm->curpic_num = pic_num; ++ rm->pktpos = url_ftell(pb); ++ } ++ if(type == 2) ++ len = FFMIN(len, pos); ++ ++ if(++rm->cur_slice > rm->slices) ++ return 1; ++ AV_WL32(rm->videobuf - 7 + 8*rm->cur_slice, 1); ++ AV_WL32(rm->videobuf - 3 + 8*rm->cur_slice, rm->videobufpos - 8*rm->slices - 1); ++ if(rm->videobufpos + len > rm->videobufsize) ++ return 1; ++ if (get_buffer(pb, rm->videobuf + rm->videobufpos, len) != len) ++ return AVERROR(EIO); ++ rm->videobufpos += len; ++ rm->remaining_len-= len; ++ ++ if(type == 2 || (rm->videobufpos) == rm->videobufsize){ ++ rm->videobuf[0] = rm->cur_slice-1; ++ if(av_new_packet(pkt, rm->videobufpos - 8*(rm->slices - rm->cur_slice)) < 0) ++ return AVERROR(ENOMEM); ++ memcpy(pkt->data, rm->videobuf, 1 + 8*rm->cur_slice); ++ memcpy(pkt->data + 1 + 8*rm->cur_slice, rm->videobuf + 1 + 8*rm->slices, ++ rm->videobufpos - 1 - 8*rm->slices); ++ pkt->pts = AV_NOPTS_VALUE; ++ pkt->pos = rm->pktpos; ++ return 0; ++ } ++ ++ return 1; ++} ++ ++static inline void ++rm_ac3_swap_bytes (AVStream *st, AVPacket *pkt) ++{ ++ uint8_t *ptr; ++ int j; ++ ++ if (st->codec->codec_id == CODEC_ID_AC3) { ++ ptr = pkt->data; ++ for (j=0;jsize;j+=2) { ++ FFSWAP(int, ptr[0], ptr[1]); ++ ptr += 2; ++ } ++ } ++} ++ ++int ++ff_rm_parse_packet (AVFormatContext *s, AVStream *st, int len, AVPacket *pkt, ++ int *seq, int *flags, int64_t *timestamp) ++{ ++ ByteIOContext *pb = s->pb; ++ RMContext *rm = s->priv_data; ++ ++ if (st->codec->codec_type == CODEC_TYPE_VIDEO) { ++ rm->current_stream= st->id; ++ if(rm_assemble_video_frame(s, rm, pkt, len) == 1) ++ return -1; //got partial frame ++ } else if (st->codec->codec_type == CODEC_TYPE_AUDIO) { ++ if ((st->codec->codec_id == CODEC_ID_RA_288) || ++ (st->codec->codec_id == CODEC_ID_COOK) || ++ (st->codec->codec_id == CODEC_ID_ATRAC3)) { ++ int x; ++ int sps = rm->sub_packet_size; ++ int cfs = rm->coded_framesize; ++ int h = rm->sub_packet_h; ++ int y = rm->sub_packet_cnt; ++ int w = rm->audio_framesize; ++ ++ if (*flags & 2) ++ y = rm->sub_packet_cnt = 0; ++ if (!y) ++ rm->audiotimestamp = *timestamp; ++ ++ switch(st->codec->codec_id) { ++ case CODEC_ID_RA_288: ++ for (x = 0; x < h/2; x++) ++ get_buffer(pb, rm->audiobuf+x*2*w+y*cfs, cfs); ++ break; ++ case CODEC_ID_ATRAC3: ++ case CODEC_ID_COOK: ++ for (x = 0; x < w/sps; x++) ++ get_buffer(pb, rm->audiobuf+sps*(h*x+((h+1)/2)*(y&1)+(y>>1)), sps); ++ break; ++ } ++ ++ if (++(rm->sub_packet_cnt) < h) ++ return -1; ++ else { ++ rm->sub_packet_cnt = 0; ++ rm->audio_stream_num = st->index; ++ rm->audio_pkt_cnt = h * w / st->codec->block_align - 1; ++ // Release first audio packet ++ av_new_packet(pkt, st->codec->block_align); ++ memcpy(pkt->data, rm->audiobuf, st->codec->block_align); ++ *timestamp = rm->audiotimestamp; ++ *flags = 2; // Mark first packet as keyframe ++ } ++ } else if (st->codec->codec_id == CODEC_ID_AAC) { ++ int x; ++ rm->audio_stream_num = st->index; ++ rm->sub_packet_cnt = (get_be16(pb) & 0xf0) >> 4; ++ if (rm->sub_packet_cnt) { ++ for (x = 0; x < rm->sub_packet_cnt; x++) ++ rm->sub_packet_lengths[x] = get_be16(pb); ++ // Release first audio packet ++ rm->audio_pkt_cnt = rm->sub_packet_cnt - 1; ++ av_get_packet(pb, pkt, rm->sub_packet_lengths[0]); ++ *flags = 2; // Mark first packet as keyframe ++ } ++ } else { ++ av_get_packet(pb, pkt, len); ++ rm_ac3_swap_bytes(st, pkt); ++ } ++ } else ++ av_get_packet(pb, pkt, len); ++ ++ if( (st->discard >= AVDISCARD_NONKEY && !(*flags&2)) ++ || st->discard >= AVDISCARD_ALL){ ++ av_free_packet(pkt); ++ return -1; ++ } ++ ++ pkt->stream_index = st->index; ++ ++#if 0 ++ if (st->codec->codec_type == CODEC_TYPE_VIDEO) { ++ if(st->codec->codec_id == CODEC_ID_RV20){ ++ int seq= 128*(pkt->data[2]&0x7F) + (pkt->data[3]>>1); ++ av_log(NULL, AV_LOG_DEBUG, "%d %"PRId64" %d\n", *timestamp, *timestamp*512LL/25, seq); ++ ++ seq |= (*timestamp&~0x3FFF); ++ if(seq - *timestamp > 0x2000) seq -= 0x4000; ++ if(seq - *timestamp < -0x2000) seq += 0x4000; ++ } ++ } ++#endif ++ ++ pkt->pts= *timestamp; ++ if (*flags & 2) ++ pkt->flags |= PKT_FLAG_KEY; ++ ++ return 0; ++} ++ ++void ++ff_rm_retrieve_cache (AVFormatContext *s, AVStream *st, AVPacket *pkt) ++{ ++ ByteIOContext *pb = s->pb; ++ RMContext *rm = s->priv_data; ++ ++ assert (rm->audio_pkt_cnt > 0); ++ ++ if (st->codec->codec_id == CODEC_ID_AAC) ++ av_get_packet(pb, pkt, rm->sub_packet_lengths[rm->sub_packet_cnt - rm->audio_pkt_cnt]); ++ else { ++ av_new_packet(pkt, st->codec->block_align); ++ memcpy(pkt->data, rm->audiobuf + st->codec->block_align * ++ (rm->sub_packet_h * rm->audio_framesize / st->codec->block_align - rm->audio_pkt_cnt), ++ st->codec->block_align); ++ } ++ rm->audio_pkt_cnt--; ++ pkt->flags = 0; ++ pkt->stream_index = st->index; ++} ++ + static int rm_read_packet(AVFormatContext *s, AVPacket *pkt) + { + RMContext *rm = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + AVStream *st; +- int i, len, j; ++ int i, len; + int64_t timestamp, pos; +- uint8_t *ptr; + int flags; + + if (rm->audio_pkt_cnt) { + // If there are queued audio packet return them first + st = s->streams[rm->audio_stream_num]; +- if (st->codec->codec_id == CODEC_ID_AAC) +- av_get_packet(pb, pkt, rm->sub_packet_lengths[rm->sub_packet_cnt - rm->audio_pkt_cnt]); +- else { +- av_new_packet(pkt, st->codec->block_align); +- memcpy(pkt->data, rm->audiobuf + st->codec->block_align * +- (rm->sub_packet_h * rm->audio_framesize / st->codec->block_align - rm->audio_pkt_cnt), +- st->codec->block_align); +- } +- rm->audio_pkt_cnt--; +- pkt->flags = 0; +- pkt->stream_index = rm->audio_stream_num; ++ ff_rm_retrieve_cache(s, st, pkt); + } else if (rm->old_format) { + st = s->streams[0]; + if (st->codec->codec_id == CODEC_ID_RA_288) { +@@ -483,6 +704,7 @@ + } + pkt->size = len; + } ++ rm_ac3_swap_bytes(st, pkt); + } else { + int seq=1; + resync: +@@ -491,127 +713,13 @@ + return AVERROR(EIO); + st = s->streams[i]; + +- if (st->codec->codec_type == CODEC_TYPE_VIDEO) { +- int h, pic_num, len2, pos; +- +- h= get_byte(pb); len--; +- if(!(h & 0x40)){ +- seq = get_byte(pb); len--; +- } +- +- if((h & 0xc0) == 0x40){ +- len2= pos= 0; +- }else{ +- len2 = get_num(pb, &len); +- pos = get_num(pb, &len); +- } +- /* picture number */ +- pic_num= get_byte(pb); len--; +- rm->remaining_len= len; +- rm->current_stream= st->id; +- +-// av_log(NULL, AV_LOG_DEBUG, "%X len:%d pos:%d len2:%d pic_num:%d\n",h, len, pos, len2, pic_num); +- if((h & 0xc0) == 0x80) +- len=pos; +- if(len2 && len2remaining_len-= len; +- av_get_packet(pb, pkt, len); +- +- } else if (st->codec->codec_type == CODEC_TYPE_AUDIO) { +- if ((st->codec->codec_id == CODEC_ID_RA_288) || +- (st->codec->codec_id == CODEC_ID_COOK) || +- (st->codec->codec_id == CODEC_ID_ATRAC3)) { +- int x; +- int sps = rm->sub_packet_size; +- int cfs = rm->coded_framesize; +- int h = rm->sub_packet_h; +- int y = rm->sub_packet_cnt; +- int w = rm->audio_framesize; +- +- if (flags & 2) +- y = rm->sub_packet_cnt = 0; +- if (!y) +- rm->audiotimestamp = timestamp; +- +- switch(st->codec->codec_id) { +- case CODEC_ID_RA_288: +- for (x = 0; x < h/2; x++) +- get_buffer(pb, rm->audiobuf+x*2*w+y*cfs, cfs); +- break; +- case CODEC_ID_ATRAC3: +- case CODEC_ID_COOK: +- for (x = 0; x < w/sps; x++) +- get_buffer(pb, rm->audiobuf+sps*(h*x+((h+1)/2)*(y&1)+(y>>1)), sps); +- break; +- } +- +- if (++(rm->sub_packet_cnt) < h) +- goto resync; +- else { +- rm->sub_packet_cnt = 0; +- rm->audio_stream_num = i; +- rm->audio_pkt_cnt = h * w / st->codec->block_align - 1; +- // Release first audio packet +- av_new_packet(pkt, st->codec->block_align); +- memcpy(pkt->data, rm->audiobuf, st->codec->block_align); +- timestamp = rm->audiotimestamp; +- flags = 2; // Mark first packet as keyframe +- } +- } else if (st->codec->codec_id == CODEC_ID_AAC) { +- int x; +- rm->audio_stream_num = i; +- rm->sub_packet_cnt = (get_be16(pb) & 0xf0) >> 4; +- if (rm->sub_packet_cnt) { +- for (x = 0; x < rm->sub_packet_cnt; x++) +- rm->sub_packet_lengths[x] = get_be16(pb); +- // Release first audio packet +- rm->audio_pkt_cnt = rm->sub_packet_cnt - 1; +- av_get_packet(pb, pkt, rm->sub_packet_lengths[0]); +- flags = 2; // Mark first packet as keyframe +- } +- } else +- av_get_packet(pb, pkt, len); +- +- } else +- av_get_packet(pb, pkt, len); +- +- if( (st->discard >= AVDISCARD_NONKEY && !(flags&2)) +- || st->discard >= AVDISCARD_ALL){ +- av_free_packet(pkt); ++ if (ff_rm_parse_packet (s, st, len, pkt, &seq, &flags, ×tamp) < 0) + goto resync; +- } +- +- pkt->stream_index = i; + +-#if 0 +- if (st->codec->codec_type == CODEC_TYPE_VIDEO) { +- if(st->codec->codec_id == CODEC_ID_RV20){ +- int seq= 128*(pkt->data[2]&0x7F) + (pkt->data[3]>>1); +- av_log(NULL, AV_LOG_DEBUG, "%d %"PRId64" %d\n", timestamp, timestamp*512LL/25, seq); +- +- seq |= (timestamp&~0x3FFF); +- if(seq - timestamp > 0x2000) seq -= 0x4000; +- if(seq - timestamp < -0x2000) seq += 0x4000; +- } +- } +-#endif +- pkt->pts= timestamp; +- if(flags&2){ +- pkt->flags |= PKT_FLAG_KEY; +- if((seq&0x7F) == 1) +- av_add_index_entry(st, pos, timestamp, 0, 0, AVINDEX_KEYFRAME); +- } ++ if((flags&2) && (seq&0x7F) == 1) ++ av_add_index_entry(st, pos, timestamp, 0, 0, AVINDEX_KEYFRAME); + } + +- /* for AC3, needs to swap bytes */ +- if (st->codec->codec_id == CODEC_ID_AC3) { +- ptr = pkt->data; +- for(j=0;jsize;j+=2) { +- FFSWAP(int, ptr[0], ptr[1]); +- ptr += 2; +- } +- } + return 0; + } + +@@ -620,6 +728,7 @@ + RMContext *rm = s->priv_data; + + av_free(rm->audiobuf); ++ av_free(rm->videobuf); + return 0; + } + +@@ -648,7 +757,7 @@ + if(rm->old_format) + return AV_NOPTS_VALUE; + +- url_fseek(&s->pb, pos, SEEK_SET); ++ url_fseek(s->pb, pos, SEEK_SET); + rm->remaining_len=0; + for(;;){ + int seq=1; +@@ -660,9 +769,9 @@ + + st = s->streams[stream_index2]; + if (st->codec->codec_type == CODEC_TYPE_VIDEO) { +- h= get_byte(&s->pb); len--; ++ h= get_byte(s->pb); len--; + if(!(h & 0x40)){ +- seq = get_byte(&s->pb); len--; ++ seq = get_byte(s->pb); len--; + } + } + +@@ -673,7 +782,7 @@ + break; + } + +- url_fskip(&s->pb, len); ++ url_fskip(s->pb, len); + } + *ppos = pos; + return dts; +diff -u mplayer-1.0~rc2-12/libavformat/rmenc.c ffmpeg-free-0.svn20080206/libavformat/rmenc.c +--- mplayer-1.0~rc2-12/libavformat/rmenc.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/rmenc.c 2007-12-02 18:51:05.000000000 +0100 +@@ -45,7 +45,7 @@ + int data_size, int index_pos) + { + RMContext *rm = ctx->priv_data; +- ByteIOContext *s = &ctx->pb; ++ ByteIOContext *s = ctx->pb; + StreamInfo *stream; + unsigned char *data_offset_ptr, *start_ptr; + const char *desc, *mimetype; +@@ -253,7 +253,7 @@ + int length, int key_frame) + { + int timestamp; +- ByteIOContext *s = &ctx->pb; ++ ByteIOContext *s = ctx->pb; + + stream->nb_packets++; + stream->packet_total_size += length; +@@ -308,7 +308,7 @@ + } + + rv10_write_header(s, 0, 0); +- put_flush_packet(&s->pb); ++ put_flush_packet(s->pb); + return 0; + } + +@@ -316,7 +316,7 @@ + { + uint8_t *buf1; + RMContext *rm = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + StreamInfo *stream = rm->audio_stream; + int i; + +@@ -340,7 +340,7 @@ + static int rm_write_video(AVFormatContext *s, const uint8_t *buf, int size, int flags) + { + RMContext *rm = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + StreamInfo *stream = rm->video_stream; + int key_frame = !!(flags & PKT_FLAG_KEY); + +@@ -349,7 +349,7 @@ + /* Well, I spent some time finding the meaning of these bits. I am + not sure I understood everything, but it works !! */ + #if 1 +- write_packet_header(s, stream, size + 7, key_frame); ++ write_packet_header(s, stream, size + 7 + (size >= 0x4000)*4, key_frame); + /* bit 7: '1' if final packet of a frame converted in several packets */ + put_byte(pb, 0x81); + /* bit 7: '1' if I frame. bits 6..0 : sequence number in current +@@ -359,8 +359,13 @@ + } else { + put_byte(pb, 0x01); + } +- put_be16(pb, 0x4000 + (size)); /* total frame size */ +- put_be16(pb, 0x4000 + (size)); /* offset from the start or the end */ ++ if(size >= 0x4000){ ++ put_be32(pb, size); /* total frame size */ ++ put_be32(pb, size); /* offset from the start or the end */ ++ }else{ ++ put_be16(pb, 0x4000 | size); /* total frame size */ ++ put_be16(pb, 0x4000 | size); /* offset from the start or the end */ ++ } + #else + /* full frame */ + write_packet_header(s, size + 6); +@@ -390,9 +395,9 @@ + { + RMContext *rm = s->priv_data; + int data_size, index_pos, i; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + +- if (!url_is_streamed(&s->pb)) { ++ if (!url_is_streamed(s->pb)) { + /* end of file: finish to write header */ + index_pos = url_fseek(pb, 0, SEEK_CUR); + data_size = index_pos - rm->data_pos; +diff -u mplayer-1.0~rc2-12/libavformat/rm.h ffmpeg-free-0.svn20080206/libavformat/rm.h +--- mplayer-1.0~rc2-12/libavformat/rm.h 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/rm.h 2008-01-04 14:00:47.000000000 +0100 +@@ -19,8 +19,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef RM_H +-#define RM_H ++#ifndef FFMPEG_RM_H ++#define FFMPEG_RM_H + + #include "avformat.h" + +@@ -46,6 +46,12 @@ + int old_format; + int current_stream; + int remaining_len; ++ uint8_t *videobuf; ///< place to store merged video frame ++ int videobufsize; ///< current assembled frame size ++ int videobufpos; ///< position for the next slice in the video buffer ++ int curpic_num; ///< picture number of current frame ++ int cur_slice, slices; ++ int64_t pktpos; ///< first slice position in file + /// Audio descrambling matrix parameters + uint8_t *audiobuf; ///< place to store reordered audio data + int64_t audiotimestamp; ///< Audio packet timestamp +@@ -57,4 +63,46 @@ + int sub_packet_lengths[16]; /// Length of each aac subpacket + } RMContext; + +-#endif /* RM_H */ ++/** ++ * Read the MDPR chunk, which contains stream-specific codec initialization ++ * parameters. ++ * ++ * @param s context containing RMContext and ByteIOContext for stream reading ++ * @param st the stream that the MDPR chunk belongs to and where to store the ++ * parameters read from the chunk into ++ * @return 0 on success, errno codes on error ++ */ ++int ff_rm_read_mdpr_codecdata (AVFormatContext *s, AVStream *st); ++ ++/** ++ * Parse one rm-stream packet from the input bytestream. ++ * ++ * @param s context containing RMContext and ByteIOContext for stream reading ++ * @param st stream to which the packet to be read belongs ++ * @param len packet length to read from the input ++ * @param pkt packet location to store the parsed packet data ++ * @param seq pointer to an integer containing the sequence number, may be ++ * updated ++ * @param flags pointer to an integer containing the packet flags, may be ++ updated ++ * @param ts pointer to timestamp, may be updated ++ * @return 0 on success, errno codes on error ++ */ ++int ff_rm_parse_packet (AVFormatContext *s, AVStream *st, int len, ++ AVPacket *pkt, int *seq, int *flags, int64_t *ts); ++ ++/** ++ * Retrieve one cached packet from the rm-context. The real container can ++ * store several packets (as interpreted by the codec) in a single container ++ * packet, which means the demuxer holds some back when the first container ++ * packet is parsed and returned. The result is that rm->audio_pkt_cnt is ++ * a positive number, the amount of cached packets. Using this function, each ++ * of those packets can be retrieved sequentially. ++ * ++ * @param s context containing RMContext and ByteIOContext for stream reading ++ * @param st stream that this packet belongs to ++ * @param pkt location to store the packet data ++ */ ++void ff_rm_retrieve_cache (AVFormatContext *s, AVStream *st, AVPacket *pkt); ++ ++#endif /* FFMPEG_RM_H */ +diff -u mplayer-1.0~rc2-12/libavformat/rtp_aac.h ffmpeg-free-0.svn20080206/libavformat/rtp_aac.h +--- mplayer-1.0~rc2-12/libavformat/rtp_aac.h 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/rtp_aac.h 2007-11-24 11:08:02.000000000 +0100 +@@ -17,9 +17,11 @@ + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +-#ifndef RTP_AAC_H +-#define RTP_AAC_H ++#ifndef FFMPEG_RTP_AAC_H ++#define FFMPEG_RTP_AAC_H ++ ++#include "avformat.h" + + void ff_rtp_send_aac(AVFormatContext *s1, const uint8_t *buff, int size); + +-#endif /* RTP_AAC_H */ ++#endif /* FFMPEG_RTP_AAC_H */ +diff -u mplayer-1.0~rc2-12/libavformat/rtp.c ffmpeg-free-0.svn20080206/libavformat/rtp.c +--- mplayer-1.0~rc2-12/libavformat/rtp.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/rtp.c 2008-01-06 11:00:04.000000000 +0100 +@@ -19,31 +19,25 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + #include "avformat.h" +-#include "mpegts.h" + #include "bitstream.h" + + #include + #include "network.h" + + #include "rtp_internal.h" +-#include "rtp_h264.h" +-#include "rtp_mpv.h" +-#include "rtp_aac.h" + + //#define DEBUG + +- +-/* TODO: - add RTCP statistics reporting (should be optional). +- +- - add support for h263/mpeg4 packetized output : IDEA: send a +- buffer to 'rtp_write_packet' contains all the packets for ONE +- frame. Each packet should have a four byte header containing +- the length in big endian format (same trick as +- 'url_open_dyn_packet_buf') +-*/ +- + /* from http://www.iana.org/assignments/rtp-parameters last updated 05 January 2005 */ +-AVRtpPayloadType_t AVRtpPayloadTypes[]= ++static const struct ++{ ++ int pt; ++ const char enc_name[50]; /* XXX: why 50 ? */ ++ enum CodecType codec_type; ++ enum CodecID codec_id; ++ int clock_rate; ++ int audio_channels; ++} AVRtpPayloadTypes[]= + { + {0, "PCMU", CODEC_TYPE_AUDIO, CODEC_ID_PCM_MULAW, 8000, 1}, + {1, "Reserved", CODEC_TYPE_UNKNOWN, CODEC_ID_NONE, -1, -1}, +@@ -78,6 +72,7 @@ + {30, "unassigned", CODEC_TYPE_VIDEO, CODEC_ID_NONE, -1, -1}, + {31, "H261", CODEC_TYPE_VIDEO, CODEC_ID_H261, 90000, -1}, + {32, "MPV", CODEC_TYPE_VIDEO, CODEC_ID_MPEG1VIDEO, 90000, -1}, ++ {32, "MPV", CODEC_TYPE_VIDEO, CODEC_ID_MPEG2VIDEO, 90000, -1}, + {33, "MP2T", CODEC_TYPE_DATA, CODEC_ID_MPEG2TS, 90000, -1}, + {34, "H263", CODEC_TYPE_VIDEO, CODEC_ID_H263, 90000, -1}, + {35, "unassigned", CODEC_TYPE_UNKNOWN, CODEC_ID_NONE, -1, -1}, +@@ -176,36 +171,22 @@ + {-1, "", CODEC_TYPE_UNKNOWN, CODEC_ID_NONE, -1, -1} + }; + +-/* statistics functions */ +-RTPDynamicProtocolHandler *RTPFirstDynamicPayloadHandler= NULL; +- +-static RTPDynamicProtocolHandler mp4v_es_handler= {"MP4V-ES", CODEC_TYPE_VIDEO, CODEC_ID_MPEG4}; +-static RTPDynamicProtocolHandler mpeg4_generic_handler= {"mpeg4-generic", CODEC_TYPE_AUDIO, CODEC_ID_AAC}; +- +-static void register_dynamic_payload_handler(RTPDynamicProtocolHandler *handler) +-{ +- handler->next= RTPFirstDynamicPayloadHandler; +- RTPFirstDynamicPayloadHandler= handler; +-} +- +-void av_register_rtp_dynamic_payload_handlers(void) +-{ +- register_dynamic_payload_handler(&mp4v_es_handler); +- register_dynamic_payload_handler(&mpeg4_generic_handler); +- register_dynamic_payload_handler(&ff_h264_dynamic_handler); +-} +- + int rtp_get_codec_info(AVCodecContext *codec, int payload_type) + { +- if (AVRtpPayloadTypes[payload_type].codec_id != CODEC_ID_NONE) { +- codec->codec_type = AVRtpPayloadTypes[payload_type].codec_type; +- codec->codec_id = AVRtpPayloadTypes[payload_type].codec_id; +- if (AVRtpPayloadTypes[payload_type].audio_channels > 0) +- codec->channels = AVRtpPayloadTypes[payload_type].audio_channels; +- if (AVRtpPayloadTypes[payload_type].clock_rate > 0) +- codec->sample_rate = AVRtpPayloadTypes[payload_type].clock_rate; +- return 0; +- } ++ int i = 0; ++ ++ for (i = 0; AVRtpPayloadTypes[i].pt >= 0; i++) ++ if (AVRtpPayloadTypes[i].pt == payload_type) { ++ if (AVRtpPayloadTypes[i].codec_id != CODEC_ID_NONE) { ++ codec->codec_type = AVRtpPayloadTypes[i].codec_type; ++ codec->codec_id = AVRtpPayloadTypes[i].codec_id; ++ if (AVRtpPayloadTypes[i].audio_channels > 0) ++ codec->channels = AVRtpPayloadTypes[i].audio_channels; ++ if (AVRtpPayloadTypes[i].clock_rate > 0) ++ codec->sample_rate = AVRtpPayloadTypes[i].clock_rate; ++ return 0; ++ } ++ } + return -1; + } + +@@ -224,814 +205,26 @@ + return payload_type; + } + +-static int rtcp_parse_packet(RTPDemuxContext *s, const unsigned char *buf, int len) +-{ +- if (buf[1] != 200) +- return -1; +- s->last_rtcp_ntp_time = AV_RB64(buf + 8); +- if (s->first_rtcp_ntp_time == AV_NOPTS_VALUE) +- s->first_rtcp_ntp_time = s->last_rtcp_ntp_time; +- s->last_rtcp_timestamp = AV_RB32(buf + 16); +- return 0; +-} +- +-#define RTP_SEQ_MOD (1<<16) +- +-/** +-* called on parse open packet +-*/ +-static void rtp_init_statistics(RTPStatistics *s, uint16_t base_sequence) // called on parse open packet. +-{ +- memset(s, 0, sizeof(RTPStatistics)); +- s->max_seq= base_sequence; +- s->probation= 1; +-} +- +-/** +-* called whenever there is a large jump in sequence numbers, or when they get out of probation... +-*/ +-static void rtp_init_sequence(RTPStatistics *s, uint16_t seq) +-{ +- s->max_seq= seq; +- s->cycles= 0; +- s->base_seq= seq -1; +- s->bad_seq= RTP_SEQ_MOD + 1; +- s->received= 0; +- s->expected_prior= 0; +- s->received_prior= 0; +- s->jitter= 0; +- s->transit= 0; +-} +- +-/** +-* returns 1 if we should handle this packet. +-*/ +-static int rtp_valid_packet_in_sequence(RTPStatistics *s, uint16_t seq) +-{ +- uint16_t udelta= seq - s->max_seq; +- const int MAX_DROPOUT= 3000; +- const int MAX_MISORDER = 100; +- const int MIN_SEQUENTIAL = 2; +- +- /* source not valid until MIN_SEQUENTIAL packets with sequence seq. numbers have been received */ +- if(s->probation) +- { +- if(seq==s->max_seq + 1) { +- s->probation--; +- s->max_seq= seq; +- if(s->probation==0) { +- rtp_init_sequence(s, seq); +- s->received++; +- return 1; +- } +- } else { +- s->probation= MIN_SEQUENTIAL - 1; +- s->max_seq = seq; +- } +- } else if (udelta < MAX_DROPOUT) { +- // in order, with permissible gap +- if(seq < s->max_seq) { +- //sequence number wrapped; count antother 64k cycles +- s->cycles += RTP_SEQ_MOD; +- } +- s->max_seq= seq; +- } else if (udelta <= RTP_SEQ_MOD - MAX_MISORDER) { +- // sequence made a large jump... +- if(seq==s->bad_seq) { +- // two sequential packets-- assume that the other side restarted without telling us; just resync. +- rtp_init_sequence(s, seq); +- } else { +- s->bad_seq= (seq + 1) & (RTP_SEQ_MOD-1); +- return 0; +- } +- } else { +- // duplicate or reordered packet... +- } +- s->received++; +- return 1; +-} +- +-#if 0 +-/** +-* This function is currently unused; without a valid local ntp time, I don't see how we could calculate the +-* difference between the arrival and sent timestamp. As a result, the jitter and transit statistics values +-* never change. I left this in in case someone else can see a way. (rdm) +-*/ +-static void rtcp_update_jitter(RTPStatistics *s, uint32_t sent_timestamp, uint32_t arrival_timestamp) +-{ +- uint32_t transit= arrival_timestamp - sent_timestamp; +- int d; +- s->transit= transit; +- d= FFABS(transit - s->transit); +- s->jitter += d - ((s->jitter + 8)>>4); +-} +-#endif +- +-int rtp_check_and_send_back_rr(RTPDemuxContext *s, int count) +-{ +- ByteIOContext pb; +- uint8_t *buf; +- int len; +- int rtcp_bytes; +- RTPStatistics *stats= &s->statistics; +- uint32_t lost; +- uint32_t extended_max; +- uint32_t expected_interval; +- uint32_t received_interval; +- uint32_t lost_interval; +- uint32_t expected; +- uint32_t fraction; +- uint64_t ntp_time= s->last_rtcp_ntp_time; // TODO: Get local ntp time? +- +- if (!s->rtp_ctx || (count < 1)) +- return -1; +- +- /* TODO: I think this is way too often; RFC 1889 has algorithm for this */ +- /* XXX: mpeg pts hardcoded. RTCP send every 0.5 seconds */ +- s->octet_count += count; +- rtcp_bytes = ((s->octet_count - s->last_octet_count) * RTCP_TX_RATIO_NUM) / +- RTCP_TX_RATIO_DEN; +- rtcp_bytes /= 50; // mmu_man: that's enough for me... VLC sends much less btw !? +- if (rtcp_bytes < 28) +- return -1; +- s->last_octet_count = s->octet_count; +- +- if (url_open_dyn_buf(&pb) < 0) +- return -1; +- +- // Receiver Report +- put_byte(&pb, (RTP_VERSION << 6) + 1); /* 1 report block */ +- put_byte(&pb, 201); +- put_be16(&pb, 7); /* length in words - 1 */ +- put_be32(&pb, s->ssrc); // our own SSRC +- put_be32(&pb, s->ssrc); // XXX: should be the server's here! +- // some placeholders we should really fill... +- // RFC 1889/p64 +- extended_max= stats->cycles + stats->max_seq; +- expected= extended_max - stats->base_seq + 1; +- lost= expected - stats->received; +- lost= FFMIN(lost, 0xffffff); // clamp it since it's only 24 bits... +- expected_interval= expected - stats->expected_prior; +- stats->expected_prior= expected; +- received_interval= stats->received - stats->received_prior; +- stats->received_prior= stats->received; +- lost_interval= expected_interval - received_interval; +- if (expected_interval==0 || lost_interval<=0) fraction= 0; +- else fraction = (lost_interval<<8)/expected_interval; +- +- fraction= (fraction<<24) | lost; +- +- put_be32(&pb, fraction); /* 8 bits of fraction, 24 bits of total packets lost */ +- put_be32(&pb, extended_max); /* max sequence received */ +- put_be32(&pb, stats->jitter>>4); /* jitter */ +- +- if(s->last_rtcp_ntp_time==AV_NOPTS_VALUE) +- { +- put_be32(&pb, 0); /* last SR timestamp */ +- put_be32(&pb, 0); /* delay since last SR */ +- } else { +- uint32_t middle_32_bits= s->last_rtcp_ntp_time>>16; // this is valid, right? do we need to handle 64 bit values special? +- uint32_t delay_since_last= ntp_time - s->last_rtcp_ntp_time; +- +- put_be32(&pb, middle_32_bits); /* last SR timestamp */ +- put_be32(&pb, delay_since_last); /* delay since last SR */ +- } +- +- // CNAME +- put_byte(&pb, (RTP_VERSION << 6) + 1); /* 1 report block */ +- put_byte(&pb, 202); +- len = strlen(s->hostname); +- put_be16(&pb, (6 + len + 3) / 4); /* length in words - 1 */ +- put_be32(&pb, s->ssrc); +- put_byte(&pb, 0x01); +- put_byte(&pb, len); +- put_buffer(&pb, s->hostname, len); +- // padding +- for (len = (6 + len) % 4; len % 4; len++) { +- put_byte(&pb, 0); +- } +- +- put_flush_packet(&pb); +- len = url_close_dyn_buf(&pb, &buf); +- if ((len > 0) && buf) { +- int result; +-#if defined(DEBUG) +- printf("sending %d bytes of RR\n", len); +-#endif +- result= url_write(s->rtp_ctx, buf, len); +-#if defined(DEBUG) +- printf("result from url_write: %d\n", result); +-#endif +- av_free(buf); +- } +- return 0; +-} +- +-/** +- * open a new RTP parse context for stream 'st'. 'st' can be NULL for +- * MPEG2TS streams to indicate that they should be demuxed inside the +- * rtp demux (otherwise CODEC_ID_MPEG2TS packets are returned) +- * TODO: change this to not take rtp_payload data, and use the new dynamic payload system. +- */ +-RTPDemuxContext *rtp_parse_open(AVFormatContext *s1, AVStream *st, URLContext *rtpc, int payload_type, rtp_payload_data_t *rtp_payload_data) +-{ +- RTPDemuxContext *s; +- +- s = av_mallocz(sizeof(RTPDemuxContext)); +- if (!s) +- return NULL; +- s->payload_type = payload_type; +- s->last_rtcp_ntp_time = AV_NOPTS_VALUE; +- s->first_rtcp_ntp_time = AV_NOPTS_VALUE; +- s->ic = s1; +- s->st = st; +- s->rtp_payload_data = rtp_payload_data; +- rtp_init_statistics(&s->statistics, 0); // do we know the initial sequence from sdp? +- if (!strcmp(AVRtpPayloadTypes[payload_type].enc_name, "MP2T")) { +- s->ts = mpegts_parse_open(s->ic); +- if (s->ts == NULL) { +- av_free(s); +- return NULL; +- } +- } else { +- switch(st->codec->codec_id) { +- case CODEC_ID_MPEG1VIDEO: +- case CODEC_ID_MPEG2VIDEO: +- case CODEC_ID_MP2: +- case CODEC_ID_MP3: +- case CODEC_ID_MPEG4: +- case CODEC_ID_H264: +- st->need_parsing = AVSTREAM_PARSE_FULL; +- break; +- default: +- break; +- } +- } +- // needed to send back RTCP RR in RTSP sessions +- s->rtp_ctx = rtpc; +- gethostname(s->hostname, sizeof(s->hostname)); +- return s; +-} +- +-static int rtp_parse_mp4_au(RTPDemuxContext *s, const uint8_t *buf) +-{ +- int au_headers_length, au_header_size, i; +- GetBitContext getbitcontext; +- rtp_payload_data_t *infos; +- +- infos = s->rtp_payload_data; +- +- if (infos == NULL) +- return -1; +- +- /* decode the first 2 bytes where are stored the AUHeader sections +- length in bits */ +- au_headers_length = AV_RB16(buf); +- +- if (au_headers_length > RTP_MAX_PACKET_LENGTH) +- return -1; +- +- infos->au_headers_length_bytes = (au_headers_length + 7) / 8; +- +- /* skip AU headers length section (2 bytes) */ +- buf += 2; +- +- init_get_bits(&getbitcontext, buf, infos->au_headers_length_bytes * 8); +- +- /* XXX: Wrong if optionnal additional sections are present (cts, dts etc...) */ +- au_header_size = infos->sizelength + infos->indexlength; +- if (au_header_size <= 0 || (au_headers_length % au_header_size != 0)) +- return -1; +- +- infos->nb_au_headers = au_headers_length / au_header_size; +- infos->au_headers = av_malloc(sizeof(struct AUHeaders) * infos->nb_au_headers); +- +- /* XXX: We handle multiple AU Section as only one (need to fix this for interleaving) +- In my test, the FAAD decoder does not behave correctly when sending each AU one by one +- but does when sending the whole as one big packet... */ +- infos->au_headers[0].size = 0; +- infos->au_headers[0].index = 0; +- for (i = 0; i < infos->nb_au_headers; ++i) { +- infos->au_headers[0].size += get_bits_long(&getbitcontext, infos->sizelength); +- infos->au_headers[0].index = get_bits_long(&getbitcontext, infos->indexlength); +- } +- +- infos->nb_au_headers = 1; +- +- return 0; +-} +- +-/** +- * This was the second switch in rtp_parse packet. Normalizes time, if required, sets stream_index, etc. +- */ +-static void finalize_packet(RTPDemuxContext *s, AVPacket *pkt, uint32_t timestamp) +-{ +- switch(s->st->codec->codec_id) { +- case CODEC_ID_MP2: +- case CODEC_ID_MPEG1VIDEO: +- if (s->last_rtcp_ntp_time != AV_NOPTS_VALUE) { +- int64_t addend; +- +- int delta_timestamp; +- /* XXX: is it really necessary to unify the timestamp base ? */ +- /* compute pts from timestamp with received ntp_time */ +- delta_timestamp = timestamp - s->last_rtcp_timestamp; +- /* convert to 90 kHz without overflow */ +- addend = (s->last_rtcp_ntp_time - s->first_rtcp_ntp_time) >> 14; +- addend = (addend * 5625) >> 14; +- pkt->pts = addend + delta_timestamp; +- } +- break; +- case CODEC_ID_AAC: +- case CODEC_ID_H264: +- case CODEC_ID_MPEG4: +- pkt->pts = timestamp; +- break; +- default: +- /* no timestamp info yet */ +- break; +- } +- pkt->stream_index = s->st->index; +-} +- +-/** +- * Parse an RTP or RTCP packet directly sent as a buffer. +- * @param s RTP parse context. +- * @param pkt returned packet +- * @param buf input buffer or NULL to read the next packets +- * @param len buffer len +- * @return 0 if a packet is returned, 1 if a packet is returned and more can follow +- * (use buf as NULL to read the next). -1 if no packet (error or no more packet). +- */ +-int rtp_parse_packet(RTPDemuxContext *s, AVPacket *pkt, +- const uint8_t *buf, int len) +-{ +- unsigned int ssrc, h; +- int payload_type, seq, ret; +- AVStream *st; +- uint32_t timestamp; +- int rv= 0; +- +- if (!buf) { +- /* return the next packets, if any */ +- if(s->st && s->parse_packet) { +- timestamp= 0; ///< Should not be used if buf is NULL, but should be set to the timestamp of the packet returned.... +- rv= s->parse_packet(s, pkt, ×tamp, NULL, 0); +- finalize_packet(s, pkt, timestamp); +- return rv; +- } else { +- // TODO: Move to a dynamic packet handler (like above) +- if (s->read_buf_index >= s->read_buf_size) +- return -1; +- ret = mpegts_parse_packet(s->ts, pkt, s->buf + s->read_buf_index, +- s->read_buf_size - s->read_buf_index); +- if (ret < 0) +- return -1; +- s->read_buf_index += ret; +- if (s->read_buf_index < s->read_buf_size) +- return 1; +- else +- return 0; +- } +- } +- +- if (len < 12) +- return -1; +- +- if ((buf[0] & 0xc0) != (RTP_VERSION << 6)) +- return -1; +- if (buf[1] >= 200 && buf[1] <= 204) { +- rtcp_parse_packet(s, buf, len); +- return -1; +- } +- payload_type = buf[1] & 0x7f; +- seq = AV_RB16(buf + 2); +- timestamp = AV_RB32(buf + 4); +- ssrc = AV_RB32(buf + 8); +- /* store the ssrc in the RTPDemuxContext */ +- s->ssrc = ssrc; +- +- /* NOTE: we can handle only one payload type */ +- if (s->payload_type != payload_type) +- return -1; +- +- st = s->st; +- // only do something with this if all the rtp checks pass... +- if(!rtp_valid_packet_in_sequence(&s->statistics, seq)) +- { +- av_log(st?st->codec:NULL, AV_LOG_ERROR, "RTP: PT=%02x: bad cseq %04x expected=%04x\n", +- payload_type, seq, ((s->seq + 1) & 0xffff)); +- return -1; +- } +- +- s->seq = seq; +- len -= 12; +- buf += 12; +- +- if (!st) { +- /* specific MPEG2TS demux support */ +- ret = mpegts_parse_packet(s->ts, pkt, buf, len); +- if (ret < 0) +- return -1; +- if (ret < len) { +- s->read_buf_size = len - ret; +- memcpy(s->buf, buf + ret, s->read_buf_size); +- s->read_buf_index = 0; +- return 1; +- } +- } else { +- // at this point, the RTP header has been stripped; This is ASSUMING that there is only 1 CSRC, which in't wise. +- switch(st->codec->codec_id) { +- case CODEC_ID_MP2: +- /* better than nothing: skip mpeg audio RTP header */ +- if (len <= 4) +- return -1; +- h = AV_RB32(buf); +- len -= 4; +- buf += 4; +- av_new_packet(pkt, len); +- memcpy(pkt->data, buf, len); +- break; +- case CODEC_ID_MPEG1VIDEO: +- /* better than nothing: skip mpeg video RTP header */ +- if (len <= 4) +- return -1; +- h = AV_RB32(buf); +- buf += 4; +- len -= 4; +- if (h & (1 << 26)) { +- /* mpeg2 */ +- if (len <= 4) +- return -1; +- buf += 4; +- len -= 4; +- } +- av_new_packet(pkt, len); +- memcpy(pkt->data, buf, len); +- break; +- // moved from below, verbatim. this is because this section handles packets, and the lower switch handles +- // timestamps. +- // TODO: Put this into a dynamic packet handler... +- case CODEC_ID_AAC: +- if (rtp_parse_mp4_au(s, buf)) +- return -1; +- { +- rtp_payload_data_t *infos = s->rtp_payload_data; +- if (infos == NULL) +- return -1; +- buf += infos->au_headers_length_bytes + 2; +- len -= infos->au_headers_length_bytes + 2; +- +- /* XXX: Fixme we only handle the case where rtp_parse_mp4_au define +- one au_header */ +- av_new_packet(pkt, infos->au_headers[0].size); +- memcpy(pkt->data, buf, infos->au_headers[0].size); +- buf += infos->au_headers[0].size; +- len -= infos->au_headers[0].size; +- } +- s->read_buf_size = len; +- rv= 0; +- break; +- default: +- if(s->parse_packet) { +- rv= s->parse_packet(s, pkt, ×tamp, buf, len); +- } else { +- av_new_packet(pkt, len); +- memcpy(pkt->data, buf, len); +- } +- break; +- } +- +- // now perform timestamp things.... +- finalize_packet(s, pkt, timestamp); +- } +- return rv; +-} +- +-void rtp_parse_close(RTPDemuxContext *s) +-{ +- // TODO: fold this into the protocol specific data fields. +- if (!strcmp(AVRtpPayloadTypes[s->payload_type].enc_name, "MP2T")) { +- mpegts_parse_close(s->ts); +- } +- av_free(s); +-} +- +-/* rtp output */ +- +-static int rtp_write_header(AVFormatContext *s1) +-{ +- RTPDemuxContext *s = s1->priv_data; +- int payload_type, max_packet_size, n; +- AVStream *st; +- +- if (s1->nb_streams != 1) +- return -1; +- st = s1->streams[0]; +- +- payload_type = rtp_get_payload_type(st->codec); +- if (payload_type < 0) +- payload_type = RTP_PT_PRIVATE; /* private payload type */ +- s->payload_type = payload_type; +- +-// following 2 FIXMies could be set based on the current time, theres normaly no info leak, as rtp will likely be transmitted immedeatly +- s->base_timestamp = 0; /* FIXME: was random(), what should this be? */ +- s->timestamp = s->base_timestamp; +- s->cur_timestamp = 0; +- s->ssrc = 0; /* FIXME: was random(), what should this be? */ +- s->first_packet = 1; +- s->first_rtcp_ntp_time = AV_NOPTS_VALUE; +- +- max_packet_size = url_fget_max_packet_size(&s1->pb); +- if (max_packet_size <= 12) +- return AVERROR(EIO); +- s->max_payload_size = max_packet_size - 12; +- +- s->max_frames_per_packet = 0; +- if (s1->max_delay) { +- if (st->codec->codec_type == CODEC_TYPE_AUDIO) { +- if (st->codec->frame_size == 0) { +- av_log(s1, AV_LOG_ERROR, "Cannot respect max delay: frame size = 0\n"); +- } else { +- s->max_frames_per_packet = av_rescale_rnd(s1->max_delay, st->codec->sample_rate, AV_TIME_BASE * st->codec->frame_size, AV_ROUND_DOWN); +- } +- } +- if (st->codec->codec_type == CODEC_TYPE_VIDEO) { +- /* FIXME: We should round down here... */ +- s->max_frames_per_packet = av_rescale_q(s1->max_delay, AV_TIME_BASE_Q, st->codec->time_base); +- } +- } +- +- av_set_pts_info(st, 32, 1, 90000); +- switch(st->codec->codec_id) { +- case CODEC_ID_MP2: +- case CODEC_ID_MP3: +- s->buf_ptr = s->buf + 4; +- break; +- case CODEC_ID_MPEG1VIDEO: +- break; +- case CODEC_ID_MPEG2TS: +- n = s->max_payload_size / TS_PACKET_SIZE; +- if (n < 1) +- n = 1; +- s->max_payload_size = n * TS_PACKET_SIZE; +- s->buf_ptr = s->buf; +- break; +- case CODEC_ID_AAC: +- s->read_buf_index = 0; +- default: +- if (st->codec->codec_type == CODEC_TYPE_AUDIO) { +- av_set_pts_info(st, 32, 1, st->codec->sample_rate); +- } +- s->buf_ptr = s->buf; +- break; +- } +- +- return 0; +-} +- +-/* send an rtcp sender report packet */ +-static void rtcp_send_sr(AVFormatContext *s1, int64_t ntp_time) ++const char *ff_rtp_enc_name(int payload_type) + { +- RTPDemuxContext *s = s1->priv_data; +- uint32_t rtp_ts; +- +-#if defined(DEBUG) +- printf("RTCP: %02x %"PRIx64" %x\n", s->payload_type, ntp_time, s->timestamp); +-#endif +- +- if (s->first_rtcp_ntp_time == AV_NOPTS_VALUE) s->first_rtcp_ntp_time = ntp_time; +- rtp_ts = av_rescale_q(ntp_time - s->first_rtcp_ntp_time, AV_TIME_BASE_Q, +- s1->streams[0]->time_base) + s->base_timestamp; +- put_byte(&s1->pb, (RTP_VERSION << 6)); +- put_byte(&s1->pb, 200); +- put_be16(&s1->pb, 6); /* length in words - 1 */ +- put_be32(&s1->pb, s->ssrc); +- put_be32(&s1->pb, ntp_time / 1000000); +- put_be32(&s1->pb, ((ntp_time % 1000000) << 32) / 1000000); +- put_be32(&s1->pb, rtp_ts); +- put_be32(&s1->pb, s->packet_count); +- put_be32(&s1->pb, s->octet_count); +- put_flush_packet(&s1->pb); +-} ++ int i; + +-/* send an rtp packet. sequence number is incremented, but the caller +- must update the timestamp itself */ +-void ff_rtp_send_data(AVFormatContext *s1, const uint8_t *buf1, int len, int m) +-{ +- RTPDemuxContext *s = s1->priv_data; +- +-#ifdef DEBUG +- printf("rtp_send_data size=%d\n", len); +-#endif +- +- /* build the RTP header */ +- put_byte(&s1->pb, (RTP_VERSION << 6)); +- put_byte(&s1->pb, (s->payload_type & 0x7f) | ((m & 0x01) << 7)); +- put_be16(&s1->pb, s->seq); +- put_be32(&s1->pb, s->timestamp); +- put_be32(&s1->pb, s->ssrc); +- +- put_buffer(&s1->pb, buf1, len); +- put_flush_packet(&s1->pb); +- +- s->seq++; +- s->octet_count += len; +- s->packet_count++; +-} +- +-/* send an integer number of samples and compute time stamp and fill +- the rtp send buffer before sending. */ +-static void rtp_send_samples(AVFormatContext *s1, +- const uint8_t *buf1, int size, int sample_size) +-{ +- RTPDemuxContext *s = s1->priv_data; +- int len, max_packet_size, n; +- +- max_packet_size = (s->max_payload_size / sample_size) * sample_size; +- /* not needed, but who nows */ +- if ((size % sample_size) != 0) +- av_abort(); +- n = 0; +- while (size > 0) { +- s->buf_ptr = s->buf; +- len = FFMIN(max_packet_size, size); +- +- /* copy data */ +- memcpy(s->buf_ptr, buf1, len); +- s->buf_ptr += len; +- buf1 += len; +- size -= len; +- s->timestamp = s->cur_timestamp + n / sample_size; +- ff_rtp_send_data(s1, s->buf, s->buf_ptr - s->buf, 0); +- n += (s->buf_ptr - s->buf); +- } +-} +- +-/* NOTE: we suppose that exactly one frame is given as argument here */ +-/* XXX: test it */ +-static void rtp_send_mpegaudio(AVFormatContext *s1, +- const uint8_t *buf1, int size) +-{ +- RTPDemuxContext *s = s1->priv_data; +- int len, count, max_packet_size; +- +- max_packet_size = s->max_payload_size; +- +- /* test if we must flush because not enough space */ +- len = (s->buf_ptr - s->buf); +- if ((len + size) > max_packet_size) { +- if (len > 4) { +- ff_rtp_send_data(s1, s->buf, s->buf_ptr - s->buf, 0); +- s->buf_ptr = s->buf + 4; ++ for (i = 0; AVRtpPayloadTypes[i].pt >= 0; i++) ++ if (AVRtpPayloadTypes[i].pt == payload_type) { ++ return AVRtpPayloadTypes[i].enc_name; + } +- } +- if (s->buf_ptr == s->buf + 4) { +- s->timestamp = s->cur_timestamp; +- } +- +- /* add the packet */ +- if (size > max_packet_size) { +- /* big packet: fragment */ +- count = 0; +- while (size > 0) { +- len = max_packet_size - 4; +- if (len > size) +- len = size; +- /* build fragmented packet */ +- s->buf[0] = 0; +- s->buf[1] = 0; +- s->buf[2] = count >> 8; +- s->buf[3] = count; +- memcpy(s->buf + 4, buf1, len); +- ff_rtp_send_data(s1, s->buf, len + 4, 0); +- size -= len; +- buf1 += len; +- count += len; +- } +- } else { +- if (s->buf_ptr == s->buf + 4) { +- /* no fragmentation possible */ +- s->buf[0] = 0; +- s->buf[1] = 0; +- s->buf[2] = 0; +- s->buf[3] = 0; +- } +- memcpy(s->buf_ptr, buf1, size); +- s->buf_ptr += size; +- } +-} + +-static void rtp_send_raw(AVFormatContext *s1, +- const uint8_t *buf1, int size) +-{ +- RTPDemuxContext *s = s1->priv_data; +- int len, max_packet_size; +- +- max_packet_size = s->max_payload_size; +- +- while (size > 0) { +- len = max_packet_size; +- if (len > size) +- len = size; +- +- s->timestamp = s->cur_timestamp; +- ff_rtp_send_data(s1, buf1, len, (len == size)); +- +- buf1 += len; +- size -= len; +- } ++ return ""; + } + +-/* NOTE: size is assumed to be an integer multiple of TS_PACKET_SIZE */ +-static void rtp_send_mpegts_raw(AVFormatContext *s1, +- const uint8_t *buf1, int size) ++enum CodecID ff_rtp_codec_id(const char *buf, enum CodecType codec_type) + { +- RTPDemuxContext *s = s1->priv_data; +- int len, out_len; ++ int i; + +- while (size >= TS_PACKET_SIZE) { +- len = s->max_payload_size - (s->buf_ptr - s->buf); +- if (len > size) +- len = size; +- memcpy(s->buf_ptr, buf1, len); +- buf1 += len; +- size -= len; +- s->buf_ptr += len; +- +- out_len = s->buf_ptr - s->buf; +- if (out_len >= s->max_payload_size) { +- ff_rtp_send_data(s1, s->buf, out_len, 0); +- s->buf_ptr = s->buf; ++ for (i = 0; AVRtpPayloadTypes[i].pt >= 0; i++) ++ if (!strcmp(buf, AVRtpPayloadTypes[i].enc_name) && (codec_type == AVRtpPayloadTypes[i].codec_type)){ ++ return AVRtpPayloadTypes[i].codec_id; + } +- } +-} + +-/* write an RTP packet. 'buf1' must contain a single specific frame. */ +-static int rtp_write_packet(AVFormatContext *s1, AVPacket *pkt) +-{ +- RTPDemuxContext *s = s1->priv_data; +- AVStream *st = s1->streams[0]; +- int rtcp_bytes; +- int size= pkt->size; +- uint8_t *buf1= pkt->data; +- +-#ifdef DEBUG +- printf("%d: write len=%d\n", pkt->stream_index, size); +-#endif +- +- /* XXX: mpeg pts hardcoded. RTCP send every 0.5 seconds */ +- rtcp_bytes = ((s->octet_count - s->last_octet_count) * RTCP_TX_RATIO_NUM) / +- RTCP_TX_RATIO_DEN; +- if (s->first_packet || rtcp_bytes >= 28) { +- rtcp_send_sr(s1, av_gettime()); +- s->last_octet_count = s->octet_count; +- s->first_packet = 0; +- } +- s->cur_timestamp = s->base_timestamp + pkt->pts; +- +- switch(st->codec->codec_id) { +- case CODEC_ID_PCM_MULAW: +- case CODEC_ID_PCM_ALAW: +- case CODEC_ID_PCM_U8: +- case CODEC_ID_PCM_S8: +- rtp_send_samples(s1, buf1, size, 1 * st->codec->channels); +- break; +- case CODEC_ID_PCM_U16BE: +- case CODEC_ID_PCM_U16LE: +- case CODEC_ID_PCM_S16BE: +- case CODEC_ID_PCM_S16LE: +- rtp_send_samples(s1, buf1, size, 2 * st->codec->channels); +- break; +- case CODEC_ID_MP2: +- case CODEC_ID_MP3: +- rtp_send_mpegaudio(s1, buf1, size); +- break; +- case CODEC_ID_MPEG1VIDEO: +- ff_rtp_send_mpegvideo(s1, buf1, size); +- break; +- case CODEC_ID_AAC: +- ff_rtp_send_aac(s1, buf1, size); +- break; +- case CODEC_ID_MPEG2TS: +- rtp_send_mpegts_raw(s1, buf1, size); +- break; +- default: +- /* better than nothing : send the codec raw data */ +- rtp_send_raw(s1, buf1, size); +- break; +- } +- return 0; ++ return CODEC_ID_NONE; + } +- +-AVOutputFormat rtp_muxer = { +- "rtp", +- "RTP output format", +- NULL, +- NULL, +- sizeof(RTPDemuxContext), +- CODEC_ID_PCM_MULAW, +- CODEC_ID_NONE, +- rtp_write_header, +- rtp_write_packet, +-}; +Only in ffmpeg-free-0.svn20080206/libavformat: rtpdec.c +Only in ffmpeg-free-0.svn20080206/libavformat: rtpenc.c +Only in ffmpeg-free-0.svn20080206/libavformat: rtpenc_h264.c +diff -u mplayer-1.0~rc2-12/libavformat/rtp.h ffmpeg-free-0.svn20080206/libavformat/rtp.h +--- mplayer-1.0~rc2-12/libavformat/rtp.h 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/rtp.h 2008-01-06 11:00:04.000000000 +0100 +@@ -18,8 +18,8 @@ + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +-#ifndef RTP_H +-#define RTP_H ++#ifndef FFMPEG_RTP_H ++#define FFMPEG_RTP_H + + #include "avcodec.h" + #include "avformat.h" +@@ -27,7 +27,6 @@ + #define RTP_MIN_PACKET_LENGTH 12 + #define RTP_MAX_PACKET_LENGTH 1500 /* XXX: suppress this define */ + +-int rtp_init(void); + int rtp_get_codec_info(AVCodecContext *codec, int payload_type); + + /** return < 0 if unknown payload type */ +@@ -86,16 +85,6 @@ + int cur_au_index; + } rtp_payload_data_t; + +-typedef struct AVRtpPayloadType_s +-{ +- int pt; +- const char enc_name[50]; /* XXX: why 50 ? */ +- enum CodecType codec_type; +- enum CodecID codec_id; +- int clock_rate; +- int audio_channels; +-} AVRtpPayloadType_t; +- + #if 0 + typedef enum { + RTCP_SR = 200, +@@ -121,5 +110,4 @@ + } rtcp_sdes_type_t; + #endif + +-extern AVRtpPayloadType_t AVRtpPayloadTypes[]; +-#endif /* RTP_H */ ++#endif /* FFMPEG_RTP_H */ +diff -u mplayer-1.0~rc2-12/libavformat/rtp_h264.c ffmpeg-free-0.svn20080206/libavformat/rtp_h264.c +--- mplayer-1.0~rc2-12/libavformat/rtp_h264.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/rtp_h264.c 2008-01-18 21:48:32.000000000 +0100 +@@ -163,9 +163,11 @@ + AVPacket * pkt, + uint32_t * timestamp, + const uint8_t * buf, +- int len) ++ int len, int flags) + { ++#ifdef DEBUG + h264_rtp_extra_data *data = s->dynamic_protocol_context; ++#endif + uint8_t nal = buf[0]; + uint8_t type = (nal & 0x1f); + int result= 0; +diff -u mplayer-1.0~rc2-12/libavformat/rtp_h264.h ffmpeg-free-0.svn20080206/libavformat/rtp_h264.h +--- mplayer-1.0~rc2-12/libavformat/rtp_h264.h 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/rtp_h264.h 2008-01-21 15:01:57.000000000 +0100 +@@ -19,10 +19,12 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef RTP_H264_H +-#define RTP_H264_H ++#ifndef FFMPEG_RTP_H264_H ++#define FFMPEG_RTP_H264_H + + #include "rtp_internal.h" + + extern RTPDynamicProtocolHandler ff_h264_dynamic_handler; +-#endif /* RTP_H264_H */ ++void ff_rtp_send_h264(AVFormatContext *s1, uint8_t *buf1, int size); ++ ++#endif /* FFMPEG_RTP_H264_H */ +diff -u mplayer-1.0~rc2-12/libavformat/rtp_internal.h ffmpeg-free-0.svn20080206/libavformat/rtp_internal.h +--- mplayer-1.0~rc2-12/libavformat/rtp_internal.h 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/rtp_internal.h 2008-01-18 21:48:32.000000000 +0100 +@@ -20,8 +20,8 @@ + */ + + // this is a bit of a misnomer, because rtp & rtsp internal structures and prototypes are in here. +-#ifndef RTP_INTERNAL_H +-#define RTP_INTERNAL_H ++#ifndef FFMPEG_RTP_INTERNAL_H ++#define FFMPEG_RTP_INTERNAL_H + + #include + #include "avcodec.h" +@@ -41,12 +41,21 @@ + uint32_t jitter; ///< estimated jitter. + } RTPStatistics; + +- ++/** ++ * Packet parsing for "private" payloads in the RTP specs. ++ * ++ * @param s stream context ++ * @param pkt packet in which to write the parsed data ++ * @param timestamp pointer in which to write the timestamp of this RTP packet ++ * @param buf pointer to raw RTP packet data ++ * @param len length of buf ++ * @param flags flags from the RTP packet header (PKT_FLAG_*) ++ */ + typedef int (*DynamicPayloadPacketHandlerProc) (struct RTPDemuxContext * s, + AVPacket * pkt, + uint32_t *timestamp, + const uint8_t * buf, +- int len); ++ int len, int flags); + + typedef struct RTPDynamicProtocolHandler_s { + // fields from AVRtpDynamicPayloadType_s +@@ -113,8 +122,10 @@ + int rtsp_next_attr_and_value(const char **p, char *attr, int attr_size, char *value, int value_size); ///< from rtsp.c, but used by rtp dynamic protocol handlers. + + void ff_rtp_send_data(AVFormatContext *s1, const uint8_t *buf1, int len, int m); ++const char *ff_rtp_enc_name(int payload_type); ++enum CodecID ff_rtp_codec_id(const char *buf, enum CodecType codec_type); + + void av_register_rtp_dynamic_payload_handlers(void); + +-#endif /* RTP_INTERNAL_H */ ++#endif /* FFMPEG_RTP_INTERNAL_H */ + +diff -u mplayer-1.0~rc2-12/libavformat/rtp_mpv.h ffmpeg-free-0.svn20080206/libavformat/rtp_mpv.h +--- mplayer-1.0~rc2-12/libavformat/rtp_mpv.h 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/rtp_mpv.h 2007-11-24 11:08:02.000000000 +0100 +@@ -17,9 +17,11 @@ + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +-#ifndef RTP_MPV_H +-#define RTP_MPV_H ++#ifndef FFMPEG_RTP_MPV_H ++#define FFMPEG_RTP_MPV_H ++ ++#include "avformat.h" + + void ff_rtp_send_mpegvideo(AVFormatContext *s1, const uint8_t *buf1, int size); + +-#endif /* RTP_MPV_H */ ++#endif /* FFMPEG_RTP_MPV_H */ +diff -u mplayer-1.0~rc2-12/libavformat/rtpproto.c ffmpeg-free-0.svn20080206/libavformat/rtpproto.c +--- mplayer-1.0~rc2-12/libavformat/rtpproto.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/rtpproto.c 2007-11-27 12:42:09.000000000 +0100 +@@ -24,6 +24,7 @@ + #include + #include + #include "network.h" ++#include "os_support.h" + #include + + #define RTP_TX_BUF_SIZE (64 * 1024) +diff -u mplayer-1.0~rc2-12/libavformat/rtsp.c ffmpeg-free-0.svn20080206/libavformat/rtsp.c +--- mplayer-1.0~rc2-12/libavformat/rtsp.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/rtsp.c 2008-01-02 20:40:43.000000000 +0100 +@@ -24,6 +24,7 @@ + #include /* for select() prototype */ + #include "network.h" + #include "avstring.h" ++#include "rtsp.h" + + #include "rtp_internal.h" + +@@ -76,7 +77,9 @@ + /* XXX: currently, the only way to change the protocols consists in + changing this variable */ + ++#if LIBAVFORMAT_VERSION_INT < (53 << 16) + int rtsp_default_protocols = (1 << RTSP_PROTOCOL_RTP_UDP); ++#endif + + static int rtsp_probe(AVProbeData *p) + { +@@ -166,11 +169,7 @@ + } else { + /* We are in a standard case ( from http://www.iana.org/assignments/rtp-parameters) */ + /* search into AVRtpPayloadTypes[] */ +- for (i = 0; AVRtpPayloadTypes[i].pt >= 0; ++i) +- if (!strcmp(buf, AVRtpPayloadTypes[i].enc_name) && (codec->codec_type == AVRtpPayloadTypes[i].codec_type)){ +- codec->codec_id = AVRtpPayloadTypes[i].codec_id; +- break; +- } ++ codec->codec_id = ff_rtp_codec_id(buf, codec->codec_type); + } + + c = avcodec_find_decoder(codec->codec_id); +@@ -442,7 +441,7 @@ + get_word(buf1, sizeof(buf1), &p); /* format list */ + rtsp_st->sdp_payload_type = atoi(buf1); + +- if (!strcmp(AVRtpPayloadTypes[rtsp_st->sdp_payload_type].enc_name, "MP2T")) { ++ if (!strcmp(ff_rtp_enc_name(rtsp_st->sdp_payload_type), "MP2T")) { + /* no corresponding stream */ + } else { + st = av_new_stream(s, 0); +@@ -607,12 +606,19 @@ + "/", &p); + if (*p == '/') + p++; +- get_word_sep(profile, sizeof(profile), "/;,", &p); +- lower_transport[0] = '\0'; +- if (*p == '/') { +- p++; +- get_word_sep(lower_transport, sizeof(lower_transport), +- ";,", &p); ++ if (!strcasecmp (transport_protocol, "rtp")) { ++ get_word_sep(profile, sizeof(profile), "/;,", &p); ++ lower_transport[0] = '\0'; ++ /* rtp/avp/ */ ++ if (*p == '/') { ++ p++; ++ get_word_sep(lower_transport, sizeof(lower_transport), ++ ";,", &p); ++ } ++ } else if (!strcasecmp (transport_protocol, "x-pn-tng")) { ++ /* x-pn-tng/ */ ++ get_word_sep(lower_transport, sizeof(lower_transport), "/;,", &p); ++ profile[0] = '\0'; + } + if (!strcasecmp(lower_transport, "TCP")) + th->protocol = RTSP_PROTOCOL_RTP_TCP; +@@ -932,9 +938,9 @@ + /* first try in specified port range */ + if (RTSP_RTP_PORT_MIN != 0) { + while(j <= RTSP_RTP_PORT_MAX) { +- snprintf(buf, sizeof(buf), "rtp://?localport=%d", j); ++ snprintf(buf, sizeof(buf), "rtp://%s?localport=%d", host, j); ++ j += 2; /* we will use two port by rtp stream (rtp and rtcp) */ + if (url_open(&rtsp_st->rtp_handle, buf, URL_RDWR) == 0) { +- j += 2; /* we will use two port by rtp stream (rtp and rtcp) */ + goto rtp_opened; + } + } +@@ -1133,7 +1139,7 @@ + + for(;;) { + if (url_interrupt_cb()) +- return -1; ++ return AVERROR(EINTR); + FD_ZERO(&rfds); + fd_max = -1; + for(i = 0; i < rt->nb_rtsp_streams; i++) { +@@ -1199,7 +1205,7 @@ + break; + } + if (len < 0) +- return AVERROR(EIO); ++ return len; + ret = rtp_parse_packet(rtsp_st->rtp_ctx, pkt, buf, len); + if (ret < 0) + goto redo; +@@ -1354,7 +1360,7 @@ + /* read the whole sdp file */ + /* XXX: better loading */ + content = av_malloc(SDP_MAX_SIZE); +- size = get_buffer(&s->pb, content, SDP_MAX_SIZE - 1); ++ size = get_buffer(s->pb, content, SDP_MAX_SIZE - 1); + if (size <= 0) { + av_free(content); + return AVERROR_INVALIDDATA; +@@ -1438,12 +1444,12 @@ + return 0; + } + +-/* called from utils.c */ +-int redir_open(AVFormatContext **ic_ptr, ByteIOContext *f) ++static int redir_read_header(AVFormatContext *s, AVFormatParameters *ap) + { + char buf[4096], *q; + int c; + AVFormatContext *ic = NULL; ++ ByteIOContext *f = s->pb; + + /* parse each URL and try to open it */ + c = url_fgetc(f); +@@ -1471,11 +1477,13 @@ + if (av_open_input_file(&ic, buf, NULL, 0, NULL) == 0) + break; + } +- *ic_ptr = ic; + if (!ic) + return AVERROR(EIO); +- else +- return 0; ++ ++ *s = *ic; ++ url_fclose(f); ++ ++ return 0; + } + + AVInputFormat redir_demuxer = { +@@ -1483,7 +1491,7 @@ + "Redirector format", + 0, + redir_probe, +- NULL, ++ redir_read_header, + NULL, + NULL, + }; +diff -u mplayer-1.0~rc2-12/libavformat/rtspcodes.h ffmpeg-free-0.svn20080206/libavformat/rtspcodes.h +--- mplayer-1.0~rc2-12/libavformat/rtspcodes.h 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/rtspcodes.h 2007-10-17 11:37:46.000000000 +0200 +@@ -19,8 +19,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef AVFORMAT_RTSPCODES_H +-#define AVFORMAT_RTSPCODES_H ++#ifndef FFMPEG_RTSPCODES_H ++#define FFMPEG_RTSPCODES_H + + /** RTSP handling */ + enum RTSPStatusCode { +@@ -37,4 +37,4 @@ + RTSP_STATUS_VERSION =505, /**< RTSP Version not supported */ + }; + +-#endif // AVFORMAT_RTSPCODES_H ++#endif /* FFMPEG_RTSPCODES_H */ +diff -u mplayer-1.0~rc2-12/libavformat/rtsp.h ffmpeg-free-0.svn20080206/libavformat/rtsp.h +--- mplayer-1.0~rc2-12/libavformat/rtsp.h 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/rtsp.h 2008-01-02 20:40:43.000000000 +0100 +@@ -18,8 +18,8 @@ + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +-#ifndef RTSP_H +-#define RTSP_H ++#ifndef FFMPEG_RTSP_H ++#define FFMPEG_RTSP_H + + #include + #include "avformat.h" +@@ -81,11 +81,13 @@ + int rtsp_init(void); + void rtsp_parse_line(RTSPHeader *reply, const char *buf); + ++#if LIBAVFORMAT_VERSION_INT < (53 << 16) + extern int rtsp_default_protocols; ++#endif + extern int rtsp_rtp_port_min; + extern int rtsp_rtp_port_max; + + int rtsp_pause(AVFormatContext *s); + int rtsp_resume(AVFormatContext *s); + +-#endif /* RTSP_H */ ++#endif /* FFMPEG_RTSP_H */ +diff -u mplayer-1.0~rc2-12/libavformat/sdp.c ffmpeg-free-0.svn20080206/libavformat/sdp.c +--- mplayer-1.0~rc2-12/libavformat/sdp.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/sdp.c 2008-01-21 15:28:58.000000000 +0100 +@@ -20,6 +20,9 @@ + + #include "avstring.h" + #include "avformat.h" ++#include "avc.h" ++#include "base64.h" ++#include "rtp.h" + + #ifdef CONFIG_RTP_MUXER + #define MAX_EXTRADATA_SIZE ((INT_MAX - 10) / 2) +@@ -89,6 +92,49 @@ + return port; + } + ++#define MAX_PSET_SIZE 1024 ++static char *extradata2psets(AVCodecContext *c) ++{ ++ char *psets, *p; ++ uint8_t *r; ++ const char *pset_string = "; sprop-parameter-sets="; ++ ++ if (c->extradata_size > MAX_EXTRADATA_SIZE) { ++ av_log(c, AV_LOG_ERROR, "Too many extra data!\n"); ++ ++ return NULL; ++ } ++ ++ psets = av_mallocz(MAX_PSET_SIZE); ++ if (psets == NULL) { ++ av_log(c, AV_LOG_ERROR, "Cannot allocate memory for the parameter sets\n"); ++ return NULL; ++ } ++ memcpy(psets, pset_string, strlen(pset_string)); ++ p = psets + strlen(pset_string); ++ r = ff_avc_find_startcode(c->extradata, c->extradata + c->extradata_size); ++ while (r < c->extradata + c->extradata_size) { ++ uint8_t *r1; ++ ++ while (!*(r++)); ++ r1 = ff_avc_find_startcode(r, c->extradata + c->extradata_size); ++ if (p != (psets + strlen(pset_string))) { ++ *p = ','; ++ p++; ++ } ++ if (av_base64_encode(p, MAX_PSET_SIZE - (p - psets), r, r1 - r) == NULL) { ++ av_log(c, AV_LOG_ERROR, "Cannot BASE64 encode %d %d!\n", MAX_PSET_SIZE - (p - psets), r1 - r); ++ av_free(psets); ++ ++ return NULL; ++ } ++ p += strlen(p); ++ r = r1; ++ } ++ ++ return psets; ++} ++ + static void digit_to_char(char *dst, uint8_t src) + { + if (src < 10) { +@@ -110,23 +156,23 @@ + return buff; + } + +-static char *extradata2config(const uint8_t *extradata, int extradata_size) ++static char *extradata2config(AVCodecContext *c) + { + char *config; + +- if (extradata_size > MAX_EXTRADATA_SIZE) { +- av_log(NULL, AV_LOG_ERROR, "Too many extra data!\n"); ++ if (c->extradata_size > MAX_EXTRADATA_SIZE) { ++ av_log(c, AV_LOG_ERROR, "Too many extra data!\n"); + + return NULL; + } +- config = av_malloc(10 + extradata_size * 2); ++ config = av_malloc(10 + c->extradata_size * 2); + if (config == NULL) { +- av_log(NULL, AV_LOG_ERROR, "Cannot allocate memory for the config info\n"); ++ av_log(c, AV_LOG_ERROR, "Cannot allocate memory for the config info\n"); + return NULL; + } + memcpy(config, "; config=", 9); +- data_to_hex(config + 9, extradata, extradata_size); +- config[9 + extradata_size * 2] = 0; ++ data_to_hex(config + 9, c->extradata, c->extradata_size); ++ config[9 + c->extradata_size * 2] = 0; + + return config; + } +@@ -136,9 +182,18 @@ + char *config = NULL; + + switch (c->codec_id) { ++ case CODEC_ID_H264: ++ if (c->extradata_size) { ++ config = extradata2psets(c); ++ } ++ av_strlcatf(buff, size, "a=rtpmap:%d H264/90000\r\n" ++ "a=fmtp:%d packetization-mode=1%s\r\n", ++ payload_type, ++ payload_type, config ? config : ""); ++ break; + case CODEC_ID_MPEG4: + if (c->extradata_size) { +- config = extradata2config(c->extradata, c->extradata_size); ++ config = extradata2config(c); + } + av_strlcatf(buff, size, "a=rtpmap:%d MP4V-ES/90000\r\n" + "a=fmtp:%d profile-level-id=1%s\r\n", +@@ -147,12 +202,12 @@ + break; + case CODEC_ID_AAC: + if (c->extradata_size) { +- config = extradata2config(c->extradata, c->extradata_size); ++ config = extradata2config(c); + } else { + /* FIXME: maybe we can forge config information based on the + * codec parameters... + */ +- av_log(NULL, AV_LOG_ERROR, "AAC with no global headers is currently not supported\n"); ++ av_log(c, AV_LOG_ERROR, "AAC with no global headers is currently not supported\n"); + return NULL; + } + if (config == NULL) { +@@ -165,6 +220,24 @@ + payload_type, c->sample_rate, c->channels, + payload_type, config); + break; ++ case CODEC_ID_PCM_S16BE: ++ if (payload_type >= 96) ++ av_strlcatf(buff, size, "a=rtpmap:%d L16/%d/%d\r\n", ++ payload_type, ++ c->sample_rate, c->channels); ++ break; ++ case CODEC_ID_PCM_MULAW: ++ if (payload_type >= 96) ++ av_strlcatf(buff, size, "a=rtpmap:%d PCMU/%d/%d\r\n", ++ payload_type, ++ c->sample_rate, c->channels); ++ break; ++ case CODEC_ID_PCM_ALAW: ++ if (payload_type >= 96) ++ av_strlcatf(buff, size, "a=rtpmap:%d PCMA/%d/%d\r\n", ++ payload_type, ++ c->sample_rate, c->channels); ++ break; + default: + /* Nothing special to do, here... */ + break; +diff -u mplayer-1.0~rc2-12/libavformat/segafilm.c ffmpeg-free-0.svn20080206/libavformat/segafilm.c +--- mplayer-1.0~rc2-12/libavformat/segafilm.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/segafilm.c 2007-11-21 08:41:00.000000000 +0100 +@@ -76,7 +76,7 @@ + AVFormatParameters *ap) + { + FilmDemuxContext *film = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + AVStream *st; + unsigned char scratch[256]; + int i; +@@ -204,7 +204,7 @@ + AVPacket *pkt) + { + FilmDemuxContext *film = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + film_sample_t *sample; + int ret = 0; + int i; +diff -u mplayer-1.0~rc2-12/libavformat/sierravmd.c ffmpeg-free-0.svn20080206/libavformat/sierravmd.c +--- mplayer-1.0~rc2-12/libavformat/sierravmd.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/sierravmd.c 2008-02-04 13:13:09.000000000 +0100 +@@ -72,8 +72,8 @@ + AVFormatParameters *ap) + { + VmdDemuxContext *vmd = s->priv_data; +- ByteIOContext *pb = &s->pb; +- AVStream *st, *vst; ++ ByteIOContext *pb = s->pb; ++ AVStream *st = NULL, *vst; + unsigned int toc_offset; + unsigned char *raw_frame_table; + int raw_frame_table_size; +@@ -181,6 +181,7 @@ + continue; + switch(type) { + case 1: /* Audio Chunk */ ++ if (!st) break; + /* first audio chunk contains several audio buffers */ + if(current_audio_pts){ + vmd->frame_table[total_frames].frame_offset = current_offset; +@@ -245,7 +246,7 @@ + AVPacket *pkt) + { + VmdDemuxContext *vmd = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + int ret = 0; + vmd_frame_t *frame; + +Only in ffmpeg-free-0.svn20080206/libavformat: siff.c +diff -u mplayer-1.0~rc2-12/libavformat/smacker.c ffmpeg-free-0.svn20080206/libavformat/smacker.c +--- mplayer-1.0~rc2-12/libavformat/smacker.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/smacker.c 2007-11-21 08:41:00.000000000 +0100 +@@ -98,7 +98,7 @@ + + static int smacker_read_header(AVFormatContext *s, AVFormatParameters *ap) + { +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + SmackerContext *smk = s->priv_data; + AVStream *st, *ast[7]; + int i, ret; +@@ -226,35 +226,35 @@ + int palchange = 0; + int pos; + +- if (url_feof(&s->pb) || smk->cur_frame >= smk->frames) ++ if (url_feof(s->pb) || smk->cur_frame >= smk->frames) + return AVERROR(EIO); + + /* if we demuxed all streams, pass another frame */ + if(smk->curstream < 0) { +- url_fseek(&s->pb, smk->nextpos, 0); ++ url_fseek(s->pb, smk->nextpos, 0); + frame_size = smk->frm_size[smk->cur_frame] & (~3); + flags = smk->frm_flags[smk->cur_frame]; + /* handle palette change event */ +- pos = url_ftell(&s->pb); ++ pos = url_ftell(s->pb); + if(flags & SMACKER_PAL){ + int size, sz, t, off, j, pos; + uint8_t *pal = smk->pal; + uint8_t oldpal[768]; + + memcpy(oldpal, pal, 768); +- size = get_byte(&s->pb); ++ size = get_byte(s->pb); + size = size * 4 - 1; + frame_size -= size; + frame_size--; + sz = 0; +- pos = url_ftell(&s->pb) + size; ++ pos = url_ftell(s->pb) + size; + while(sz < 256){ +- t = get_byte(&s->pb); ++ t = get_byte(s->pb); + if(t & 0x80){ /* skip palette entries */ + sz += (t & 0x7F) + 1; + pal += ((t & 0x7F) + 1) * 3; + } else if(t & 0x40){ /* copy with offset */ +- off = get_byte(&s->pb) * 3; ++ off = get_byte(s->pb) * 3; + j = (t & 0x3F) + 1; + while(j-- && sz < 256) { + *pal++ = oldpal[off + 0]; +@@ -265,12 +265,12 @@ + } + } else { /* new entries */ + *pal++ = smk_pal[t]; +- *pal++ = smk_pal[get_byte(&s->pb) & 0x3F]; +- *pal++ = smk_pal[get_byte(&s->pb) & 0x3F]; ++ *pal++ = smk_pal[get_byte(s->pb) & 0x3F]; ++ *pal++ = smk_pal[get_byte(s->pb) & 0x3F]; + sz++; + } + } +- url_fseek(&s->pb, pos, 0); ++ url_fseek(s->pb, pos, 0); + palchange |= 1; + } + flags >>= 1; +@@ -279,13 +279,13 @@ + for(i = 0; i < 7; i++) { + if(flags & 1) { + int size; +- size = get_le32(&s->pb) - 4; ++ size = get_le32(s->pb) - 4; + frame_size -= size; + frame_size -= 4; + smk->curstream++; + smk->bufs[smk->curstream] = av_realloc(smk->bufs[smk->curstream], size); + smk->buf_sizes[smk->curstream] = size; +- ret = get_buffer(&s->pb, smk->bufs[smk->curstream], size); ++ ret = get_buffer(s->pb, smk->bufs[smk->curstream], size); + if(ret != size) + return AVERROR(EIO); + smk->stream_id[smk->curstream] = smk->indexes[i]; +@@ -298,13 +298,13 @@ + palchange |= 2; + pkt->data[0] = palchange; + memcpy(pkt->data + 1, smk->pal, 768); +- ret = get_buffer(&s->pb, pkt->data + 769, frame_size); ++ ret = get_buffer(s->pb, pkt->data + 769, frame_size); + if(ret != frame_size) + return AVERROR(EIO); + pkt->stream_index = smk->videoindex; + pkt->size = ret + 769; + smk->cur_frame++; +- smk->nextpos = url_ftell(&s->pb); ++ smk->nextpos = url_ftell(s->pb); + } else { + if (av_new_packet(pkt, smk->buf_sizes[smk->curstream])) + return AVERROR(ENOMEM); +diff -u mplayer-1.0~rc2-12/libavformat/sol.c ffmpeg-free-0.svn20080206/libavformat/sol.c +--- mplayer-1.0~rc2-12/libavformat/sol.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/sol.c 2007-11-21 08:41:00.000000000 +0100 +@@ -88,7 +88,7 @@ + { + int size; + unsigned int magic,tag; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + unsigned int id, codec, channels, rate, type; + AVStream *st; + +@@ -130,9 +130,9 @@ + { + int ret; + +- if (url_feof(&s->pb)) ++ if (url_feof(s->pb)) + return AVERROR(EIO); +- ret= av_get_packet(&s->pb, pkt, MAX_SIZE); ++ ret= av_get_packet(s->pb, pkt, MAX_SIZE); + pkt->stream_index = 0; + + /* note: we need to modify the packet size here to handle the last +diff -u mplayer-1.0~rc2-12/libavformat/swf.c ffmpeg-free-0.svn20080206/libavformat/swf.c +--- mplayer-1.0~rc2-12/libavformat/swf.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/swf.c 2008-01-21 14:43:40.000000000 +0100 +@@ -40,6 +40,7 @@ + #define TAG_STREAMHEAD2 45 + #define TAG_VIDEOSTREAM 60 + #define TAG_VIDEOFRAME 61 ++#define TAG_FILEATTRIBUTES 69 + + #define TAG_LONG 0x100 + +@@ -96,7 +97,7 @@ + static void put_swf_tag(AVFormatContext *s, int tag) + { + SWFContext *swf = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + + swf->tag_pos = url_ftell(pb); + swf->tag = tag; +@@ -112,7 +113,7 @@ + static void put_swf_end_tag(AVFormatContext *s) + { + SWFContext *swf = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + offset_t pos; + int tag_len, tag; + +@@ -244,11 +245,12 @@ + static int swf_write_header(AVFormatContext *s) + { + SWFContext *swf = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + AVCodecContext *enc, *audio_enc, *video_enc; + PutBitContext p; + uint8_t buf1[256]; + int i, width, height, rate, rate_base; ++ int is_avm2; + + swf->audio_in_pos = 0; + swf->sound_samples = 0; +@@ -305,8 +307,12 @@ + swf->samples_per_frame = (audio_enc->sample_rate * rate_base) / rate; + } + ++ is_avm2 = !strcmp("avm2", s->oformat->name); ++ + put_tag(pb, "FWS"); +- if (video_enc && video_enc->codec_id == CODEC_ID_VP6F) { ++ if (is_avm2) { ++ put_byte(pb, 9); ++ } else if (video_enc && video_enc->codec_id == CODEC_ID_VP6F) { + put_byte(pb, 8); /* version (version 8 and above support VP6 codec) */ + } else if (video_enc && video_enc->codec_id == CODEC_ID_FLV1) { + put_byte(pb, 6); /* version (version 6 and above support FLV1 codec) */ +@@ -321,6 +327,13 @@ + swf->duration_pos = url_ftell(pb); + put_le16(pb, (uint16_t)(DUMMY_DURATION * (int64_t)rate / rate_base)); /* frame count */ + ++ /* avm2/swf v9 (also v8?) files require a file attribute tag */ ++ if (is_avm2) { ++ put_swf_tag(s, TAG_FILEATTRIBUTES); ++ put_le32(pb, 1<<3); /* set ActionScript v3/AVM2 flag */ ++ put_swf_end_tag(s); ++ } ++ + /* define a shape with the jpeg inside */ + if (video_enc && (video_enc->codec_id == CODEC_ID_VP6F || + video_enc->codec_id == CODEC_ID_FLV1)) { +@@ -392,16 +405,16 @@ + v |= 0x02; /* 16 bit playback */ + if (audio_enc->channels == 2) + v |= 0x01; /* stereo playback */ +- put_byte(&s->pb, v); ++ put_byte(s->pb, v); + v |= 0x20; /* mp3 compressed */ +- put_byte(&s->pb, v); +- put_le16(&s->pb, swf->samples_per_frame); /* avg samples per frame */ +- put_le16(&s->pb, 0); ++ put_byte(s->pb, v); ++ put_le16(s->pb, swf->samples_per_frame); /* avg samples per frame */ ++ put_le16(s->pb, 0); + + put_swf_end_tag(s); + } + +- put_flush_packet(&s->pb); ++ put_flush_packet(s->pb); + return 0; + } + +@@ -409,7 +422,7 @@ + AVCodecContext *enc, const uint8_t *buf, int size) + { + SWFContext *swf = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + + /* Flash Player limit */ + if (swf->swf_frame_number == 16000) { +@@ -516,7 +529,7 @@ + put_swf_tag(s, TAG_SHOWFRAME); + put_swf_end_tag(s); + +- put_flush_packet(&s->pb); ++ put_flush_packet(s->pb); + + return 0; + } +@@ -560,7 +573,7 @@ + static int swf_write_trailer(AVFormatContext *s) + { + SWFContext *swf = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + AVCodecContext *enc, *video_enc; + int file_size, i; + +@@ -574,10 +587,10 @@ + put_swf_tag(s, TAG_END); + put_swf_end_tag(s); + +- put_flush_packet(&s->pb); ++ put_flush_packet(s->pb); + + /* patch file size and number of frames if not streamed */ +- if (!url_is_streamed(&s->pb) && video_enc) { ++ if (!url_is_streamed(s->pb) && video_enc) { + file_size = url_ftell(pb); + url_fseek(pb, 4, SEEK_SET); + put_le32(pb, file_size); +@@ -628,7 +641,7 @@ + static int swf_read_header(AVFormatContext *s, AVFormatParameters *ap) + { + SWFContext *swf = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + int nbits, len, tag; + + tag = get_be32(pb) & 0xffffff00; +@@ -655,7 +668,7 @@ + static int swf_read_packet(AVFormatContext *s, AVPacket *pkt) + { + SWFContext *swf = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + AVStream *vst = NULL, *ast = NULL, *st = 0; + int tag, len, i, frame, v; + +@@ -671,6 +684,8 @@ + get_byte(pb); + /* Check for FLV1 */ + vst = av_new_stream(s, ch_id); ++ if (!vst) ++ return -1; + vst->codec->codec_type = CODEC_TYPE_VIDEO; + vst->codec->codec_id = codec_get_id(swf_codec_tags, get_byte(pb)); + av_set_pts_info(vst, 64, 256, swf->frame_rate); +@@ -683,6 +698,8 @@ + v = get_byte(pb); + swf->samples_per_frame = get_le16(pb); + ast = av_new_stream(s, -1); /* -1 to avoid clash with video stream ch_id */ ++ if (!ast) ++ return -1; + swf->audio_stream_index = ast->index; + ast->codec->channels = 1 + (v&1); + ast->codec->codec_type = CODEC_TYPE_AUDIO; +@@ -725,6 +742,8 @@ + } + if (i == s->nb_streams) { + vst = av_new_stream(s, -2); /* -2 to avoid clash with video stream and audio stream */ ++ if (!vst) ++ return -1; + vst->codec->codec_type = CODEC_TYPE_VIDEO; + vst->codec->codec_id = CODEC_ID_MJPEG; + av_set_pts_info(vst, 64, 256, swf->frame_rate); +@@ -781,3 +800,17 @@ + swf_write_trailer, + }; + #endif ++#ifdef CONFIG_AVM2_MUXER ++AVOutputFormat avm2_muxer = { ++ "avm2", ++ "Flash 9 (AVM2) format", ++ "application/x-shockwave-flash", ++ NULL, ++ sizeof(SWFContext), ++ CODEC_ID_MP3, ++ CODEC_ID_FLV1, ++ swf_write_header, ++ swf_write_packet, ++ swf_write_trailer, ++}; ++#endif +diff -u mplayer-1.0~rc2-12/libavformat/tcp.c ffmpeg-free-0.svn20080206/libavformat/tcp.c +--- mplayer-1.0~rc2-12/libavformat/tcp.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/tcp.c 2007-11-21 17:33:06.000000000 +0100 +@@ -21,6 +21,7 @@ + #include "avformat.h" + #include + #include "network.h" ++#include "os_support.h" + #include + + typedef struct TCPContext { +diff -u mplayer-1.0~rc2-12/libavformat/thp.c ffmpeg-free-0.svn20080206/libavformat/thp.c +--- mplayer-1.0~rc2-12/libavformat/thp.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/thp.c 2007-11-21 08:41:00.000000000 +0100 +@@ -57,7 +57,7 @@ + { + ThpDemuxContext *thp = s->priv_data; + AVStream *st; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + int i; + + /* Read the file header. */ +@@ -140,7 +140,7 @@ + AVPacket *pkt) + { + ThpDemuxContext *thp = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + int size; + int ret; + +diff -u mplayer-1.0~rc2-12/libavformat/tiertexseq.c ffmpeg-free-0.svn20080206/libavformat/tiertexseq.c +--- mplayer-1.0~rc2-12/libavformat/tiertexseq.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/tiertexseq.c 2007-11-21 08:41:00.000000000 +0100 +@@ -184,7 +184,7 @@ + { + int i, rc; + SeqDemuxContext *seq = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + AVStream *st; + + /* init internal buffers */ +@@ -241,7 +241,7 @@ + { + int rc; + SeqDemuxContext *seq = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + + if (!seq->audio_buffer_full) { + rc = seq_parse_frame_data(seq, pb); +diff -u mplayer-1.0~rc2-12/libavformat/tta.c ffmpeg-free-0.svn20080206/libavformat/tta.c +--- mplayer-1.0~rc2-12/libavformat/tta.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/tta.c 2007-11-21 08:41:00.000000000 +0100 +@@ -40,25 +40,25 @@ + int i, channels, bps, samplerate, datalen, framelen; + uint64_t framepos; + +- if (get_le32(&s->pb) != ff_get_fourcc("TTA1")) ++ if (get_le32(s->pb) != ff_get_fourcc("TTA1")) + return -1; // not tta file + +- url_fskip(&s->pb, 2); // FIXME: flags +- channels = get_le16(&s->pb); +- bps = get_le16(&s->pb); +- samplerate = get_le32(&s->pb); ++ url_fskip(s->pb, 2); // FIXME: flags ++ channels = get_le16(s->pb); ++ bps = get_le16(s->pb); ++ samplerate = get_le32(s->pb); + if(samplerate <= 0 || samplerate > 1000000){ + av_log(s, AV_LOG_ERROR, "nonsense samplerate\n"); + return -1; + } + +- datalen = get_le32(&s->pb); ++ datalen = get_le32(s->pb); + if(datalen < 0){ + av_log(s, AV_LOG_ERROR, "nonsense datalen\n"); + return -1; + } + +- url_fskip(&s->pb, 4); // header crc ++ url_fskip(s->pb, 4); // header crc + + framelen = samplerate*256/245; + c->totalframes = datalen / framelen + ((datalen % framelen) ? 1 : 0); +@@ -77,14 +77,14 @@ + st->start_time = 0; + st->duration = datalen; + +- framepos = url_ftell(&s->pb) + 4*c->totalframes + 4; ++ framepos = url_ftell(s->pb) + 4*c->totalframes + 4; + + for (i = 0; i < c->totalframes; i++) { +- uint32_t size = get_le32(&s->pb); ++ uint32_t size = get_le32(s->pb); + av_add_index_entry(st, framepos, i*framelen, size, 0, AVINDEX_KEYFRAME); + framepos += size; + } +- url_fskip(&s->pb, 4); // seektable crc ++ url_fskip(s->pb, 4); // seektable crc + + st->codec->codec_type = CODEC_TYPE_AUDIO; + st->codec->codec_id = CODEC_ID_TTA; +@@ -92,15 +92,15 @@ + st->codec->sample_rate = samplerate; + st->codec->bits_per_sample = bps; + +- st->codec->extradata_size = url_ftell(&s->pb); ++ st->codec->extradata_size = url_ftell(s->pb); + if(st->codec->extradata_size+FF_INPUT_BUFFER_PADDING_SIZE <= (unsigned)st->codec->extradata_size){ + //this check is redundant as get_buffer should fail + av_log(s, AV_LOG_ERROR, "extradata_size too large\n"); + return -1; + } + st->codec->extradata = av_mallocz(st->codec->extradata_size+FF_INPUT_BUFFER_PADDING_SIZE); +- url_fseek(&s->pb, 0, SEEK_SET); +- get_buffer(&s->pb, st->codec->extradata, st->codec->extradata_size); ++ url_fseek(s->pb, 0, SEEK_SET); ++ get_buffer(s->pb, st->codec->extradata, st->codec->extradata_size); + + return 0; + } +@@ -117,7 +117,7 @@ + + size = st->index_entries[c->currentframe].size; + +- ret = av_get_packet(&s->pb, pkt, size); ++ ret = av_get_packet(s->pb, pkt, size); + pkt->dts = st->index_entries[c->currentframe++].timestamp; + return ret; + } +@@ -131,7 +131,7 @@ + return -1; + + c->currentframe = index; +- url_fseek(&s->pb, st->index_entries[index].pos, SEEK_SET); ++ url_fseek(s->pb, st->index_entries[index].pos, SEEK_SET); + + return 0; + } +diff -u mplayer-1.0~rc2-12/libavformat/txd.c ffmpeg-free-0.svn20080206/libavformat/txd.c +--- mplayer-1.0~rc2-12/libavformat/txd.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/txd.c 2007-11-21 08:41:00.000000000 +0100 +@@ -51,7 +51,7 @@ + } + + static int txd_read_packet(AVFormatContext *s, AVPacket *pkt) { +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + unsigned int id, chunk_size, marker; + int ret; + +@@ -60,7 +60,7 @@ + chunk_size = get_le32(pb); + marker = get_le32(pb); + +- if (url_feof(&s->pb)) ++ if (url_feof(s->pb)) + return AVERROR(EIO); + if (marker != TXD_MARKER && marker != TXD_MARKER2) { + av_log(NULL, AV_LOG_ERROR, "marker does not match\n"); +@@ -72,7 +72,7 @@ + if (chunk_size > 100) + break; + case TXD_EXTRA: +- url_fskip(&s->pb, chunk_size); ++ url_fskip(s->pb, chunk_size); + case TXD_FILE: + case TXD_TEXTURE: + goto next_chunk; +@@ -81,7 +81,7 @@ + return AVERROR(EIO); + } + +- ret = av_get_packet(&s->pb, pkt, chunk_size); ++ ret = av_get_packet(s->pb, pkt, chunk_size); + pkt->stream_index = 0; + + return ret <= 0 ? AVERROR(EIO) : ret; +diff -u mplayer-1.0~rc2-12/libavformat/udp.c ffmpeg-free-0.svn20080206/libavformat/udp.c +--- mplayer-1.0~rc2-12/libavformat/udp.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/udp.c 2007-11-21 17:33:06.000000000 +0100 +@@ -21,6 +21,7 @@ + #include "avformat.h" + #include + #include "network.h" ++#include "os_support.h" + + #ifndef IPV6_ADD_MEMBERSHIP + #define IPV6_ADD_MEMBERSHIP IPV6_JOIN_GROUP +@@ -34,84 +35,98 @@ + int local_port; + int reuse_socket; + #ifndef CONFIG_IPV6 +- struct ip_mreq mreq; + struct sockaddr_in dest_addr; + #else + struct sockaddr_storage dest_addr; +- size_t dest_addr_len; + #endif ++ size_t dest_addr_len; + } UDPContext; + + #define UDP_TX_BUF_SIZE 32768 + #define UDP_MAX_PKT_SIZE 65536 + +-#ifdef CONFIG_IPV6 +- +-static int udp_ipv6_set_multicast_ttl(int sockfd, int mcastTTL, struct sockaddr *addr) { ++static int udp_set_multicast_ttl(int sockfd, int mcastTTL, struct sockaddr *addr) { ++#ifdef IP_MULTICAST_TTL + if (addr->sa_family == AF_INET) { + if (setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, &mcastTTL, sizeof(mcastTTL)) < 0) { +- perror("setsockopt(IP_MULTICAST_TTL)"); ++ av_log(NULL, AV_LOG_ERROR, "setsockopt(IP_MULTICAST_TTL): %s\n", strerror(errno)); + return -1; + } + } ++#endif ++#ifdef CONFIG_IPV6 + if (addr->sa_family == AF_INET6) { + if (setsockopt(sockfd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, &mcastTTL, sizeof(mcastTTL)) < 0) { +- perror("setsockopt(IPV6_MULTICAST_HOPS)"); ++ av_log(NULL, AV_LOG_ERROR, "setsockopt(IPV6_MULTICAST_HOPS): %s\n", strerror(errno)); + return -1; + } + } ++#endif + return 0; + } + +-static int udp_ipv6_join_multicast_group(int sockfd, struct sockaddr *addr) { +- struct ip_mreq mreq; +- struct ipv6_mreq mreq6; ++static int udp_join_multicast_group(int sockfd, struct sockaddr *addr) { ++#ifdef IP_ADD_MEMBERSHIP + if (addr->sa_family == AF_INET) { ++ struct ip_mreq mreq; ++ + mreq.imr_multiaddr.s_addr = ((struct sockaddr_in *)addr)->sin_addr.s_addr; + mreq.imr_interface.s_addr= INADDR_ANY; + if (setsockopt(sockfd, IPPROTO_IP, IP_ADD_MEMBERSHIP, (const void *)&mreq, sizeof(mreq)) < 0) { +- perror("setsockopt(IP_ADD_MEMBERSHIP)"); ++ av_log(NULL, AV_LOG_ERROR, "setsockopt(IP_ADD_MEMBERSHIP): %s\n", strerror(errno)); + return -1; + } + } ++#endif ++#ifdef CONFIG_IPV6 + if (addr->sa_family == AF_INET6) { ++ struct ipv6_mreq mreq6; ++ + memcpy(&mreq6.ipv6mr_multiaddr, &(((struct sockaddr_in6 *)addr)->sin6_addr), sizeof(struct in6_addr)); + mreq6.ipv6mr_interface= 0; + if (setsockopt(sockfd, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, &mreq6, sizeof(mreq6)) < 0) { +- perror("setsockopt(IPV6_ADD_MEMBERSHIP)"); ++ av_log(NULL, AV_LOG_ERROR, "setsockopt(IPV6_ADD_MEMBERSHIP): %s\n", strerror(errno)); + return -1; + } + } ++#endif + return 0; + } + +-static int udp_ipv6_leave_multicast_group(int sockfd, struct sockaddr *addr) { +- struct ip_mreq mreq; +- struct ipv6_mreq mreq6; ++static int udp_leave_multicast_group(int sockfd, struct sockaddr *addr) { ++#ifdef IP_DROP_MEMBERSHIP + if (addr->sa_family == AF_INET) { ++ struct ip_mreq mreq; ++ + mreq.imr_multiaddr.s_addr = ((struct sockaddr_in *)addr)->sin_addr.s_addr; + mreq.imr_interface.s_addr= INADDR_ANY; + if (setsockopt(sockfd, IPPROTO_IP, IP_DROP_MEMBERSHIP, (const void *)&mreq, sizeof(mreq)) < 0) { +- perror("setsockopt(IP_DROP_MEMBERSHIP)"); ++ av_log(NULL, AV_LOG_ERROR, "setsockopt(IP_DROP_MEMBERSHIP): %s\n", strerror(errno)); + return -1; + } + } ++#endif ++#ifdef CONFIG_IPV6 + if (addr->sa_family == AF_INET6) { ++ struct ipv6_mreq mreq6; ++ + memcpy(&mreq6.ipv6mr_multiaddr, &(((struct sockaddr_in6 *)addr)->sin6_addr), sizeof(struct in6_addr)); + mreq6.ipv6mr_interface= 0; + if (setsockopt(sockfd, IPPROTO_IPV6, IPV6_DROP_MEMBERSHIP, &mreq6, sizeof(mreq6)) < 0) { +- perror("setsockopt(IPV6_DROP_MEMBERSHIP)"); ++ av_log(NULL, AV_LOG_ERROR, "setsockopt(IPV6_DROP_MEMBERSHIP): %s\n", strerror(errno)); + return -1; + } + } ++#endif + return 0; + } + ++#ifdef CONFIG_IPV6 + static struct addrinfo* udp_ipv6_resolve_host(const char *hostname, int port, int type, int family, int flags) { + struct addrinfo hints, *res = 0; + int error; + char sport[16]; +- const char *node = 0, *service = 0; ++ const char *node = 0, *service = "0"; + + if (port > 0) { + snprintf(sport, sizeof(sport), "%d", port); +@@ -120,80 +135,54 @@ + if ((hostname) && (hostname[0] != '\0') && (hostname[0] != '?')) { + node = hostname; + } +- if ((node) || (service)) { +- memset(&hints, 0, sizeof(hints)); +- hints.ai_socktype = type; +- hints.ai_family = family; +- hints.ai_flags = flags; +- if ((error = getaddrinfo(node, service, &hints, &res))) { +- av_log(NULL, AV_LOG_ERROR, "udp_ipv6_resolve_host: %s\n", gai_strerror(error)); +- } ++ memset(&hints, 0, sizeof(hints)); ++ hints.ai_socktype = type; ++ hints.ai_family = family; ++ hints.ai_flags = flags; ++ if ((error = getaddrinfo(node, service, &hints, &res))) { ++ av_log(NULL, AV_LOG_ERROR, "udp_ipv6_resolve_host: %s\n", gai_strerror(error)); + } ++ + return res; + } + +-static int udp_ipv6_set_remote_url(URLContext *h, const char *uri) { +- UDPContext *s = h->priv_data; +- char hostname[256]; +- int port; ++static int udp_set_url(struct sockaddr_storage *addr, const char *hostname, int port) { + struct addrinfo *res0; +- url_split(NULL, 0, NULL, 0, hostname, sizeof(hostname), &port, NULL, 0, uri); ++ int addr_len; ++ + res0 = udp_ipv6_resolve_host(hostname, port, SOCK_DGRAM, AF_UNSPEC, 0); + if (res0 == 0) return AVERROR(EIO); +- memcpy(&s->dest_addr, res0->ai_addr, res0->ai_addrlen); +- s->dest_addr_len = res0->ai_addrlen; ++ memcpy(addr, res0->ai_addr, res0->ai_addrlen); ++ addr_len = res0->ai_addrlen; + freeaddrinfo(res0); +- return 0; ++ ++ return addr_len; + } + +-static int udp_ipv6_set_local(URLContext *h) { +- UDPContext *s = h->priv_data; ++static int udp_socket_create(UDPContext *s, struct sockaddr_storage *addr, int *addr_len) ++{ + int udp_fd = -1; +- struct sockaddr_storage clientaddr; +- socklen_t addrlen; +- char sbuf[NI_MAXSERV]; +- char hbuf[NI_MAXHOST]; + struct addrinfo *res0 = NULL, *res = NULL; ++ int family = AF_UNSPEC; + +- if (s->local_port != 0) { +- res0 = udp_ipv6_resolve_host(0, s->local_port, SOCK_DGRAM, AF_UNSPEC, AI_PASSIVE); +- if (res0 == 0) +- goto fail; +- for (res = res0; res; res=res->ai_next) { +- udp_fd = socket(res->ai_family, SOCK_DGRAM, 0); +- if (udp_fd > 0) break; +- perror("socket"); +- } +- } else { +- udp_fd = socket(s->dest_addr.ss_family, SOCK_DGRAM, 0); +- if (udp_fd < 0) +- perror("socket"); +- } +- +- if (udp_fd < 0) ++ if (((struct sockaddr *) &s->dest_addr)->sa_family) ++ family = ((struct sockaddr *) &s->dest_addr)->sa_family; ++ res0 = udp_ipv6_resolve_host(0, s->local_port, SOCK_DGRAM, family, AI_PASSIVE); ++ if (res0 == 0) + goto fail; +- +- if (s->local_port != 0) { +- if (bind(udp_fd, res0->ai_addr, res0->ai_addrlen) < 0) { +- perror("bind"); +- goto fail; +- } +- freeaddrinfo(res0); +- res0 = NULL; ++ for (res = res0; res; res=res->ai_next) { ++ udp_fd = socket(res->ai_family, SOCK_DGRAM, 0); ++ if (udp_fd > 0) break; ++ av_log(NULL, AV_LOG_ERROR, "socket: %s\n", strerror(errno)); + } + +- addrlen = sizeof(clientaddr); +- if (getsockname(udp_fd, (struct sockaddr *)&clientaddr, &addrlen) < 0) { +- perror("getsockname"); ++ if (udp_fd < 0) + goto fail; +- } + +- if (getnameinfo((struct sockaddr *)&clientaddr, addrlen, hbuf, sizeof(hbuf), sbuf, sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV) != 0) { +- perror("getnameinfo"); +- goto fail; +- } ++ memcpy(addr, res->ai_addr, res->ai_addrlen); ++ *addr_len = res->ai_addrlen; + +- s->local_port = strtol(sbuf, NULL, 10); ++ freeaddrinfo(res0); + + return udp_fd; + +@@ -205,6 +194,52 @@ + return -1; + } + ++static int udp_port(struct sockaddr_storage *addr, int addr_len) ++{ ++ char sbuf[NI_MAXSERV]; ++ char hbuf[NI_MAXHOST]; ++ ++ if (getnameinfo((struct sockaddr *)addr, addr_len, hbuf, sizeof(hbuf), sbuf, sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV) != 0) { ++ av_log(NULL, AV_LOG_ERROR, "getnameinfo: %s\n", strerror(errno)); ++ return -1; ++ } ++ ++ return strtol(sbuf, NULL, 10); ++} ++ ++#else ++ ++static int udp_set_url(struct sockaddr_in *addr, const char *hostname, int port) ++{ ++ /* set the destination address */ ++ if (resolve_host(&addr->sin_addr, hostname) < 0) ++ return AVERROR(EIO); ++ addr->sin_family = AF_INET; ++ addr->sin_port = htons(port); ++ ++ return sizeof(struct sockaddr_in); ++} ++ ++static int udp_socket_create(UDPContext *s, struct sockaddr_in *addr, int *addr_len) ++{ ++ int fd; ++ ++ fd = socket(AF_INET, SOCK_DGRAM, 0); ++ if (fd < 0) ++ return -1; ++ ++ addr->sin_family = AF_INET; ++ addr->sin_addr.s_addr = htonl (INADDR_ANY); ++ addr->sin_port = htons(s->local_port); ++ *addr_len = sizeof(struct sockaddr_in); ++ ++ return fd; ++} ++ ++static int udp_port(struct sockaddr_in *addr, int len) ++{ ++ return ntohs(addr->sin_port); ++} + #endif /* CONFIG_IPV6 */ + + +@@ -226,9 +261,6 @@ + */ + int udp_set_remote_url(URLContext *h, const char *uri) + { +-#ifdef CONFIG_IPV6 +- return udp_ipv6_set_remote_url(h, uri); +-#else + UDPContext *s = h->priv_data; + char hostname[256]; + int port; +@@ -236,12 +268,12 @@ + url_split(NULL, 0, NULL, 0, hostname, sizeof(hostname), &port, NULL, 0, uri); + + /* set the destination address */ +- if (resolve_host(&s->dest_addr.sin_addr, hostname) < 0) ++ s->dest_addr_len = udp_set_url(&s->dest_addr, hostname, port); ++ if (s->dest_addr_len < 0) { + return AVERROR(EIO); +- s->dest_addr.sin_family = AF_INET; +- s->dest_addr.sin_port = htons(port); ++ } ++ + return 0; +-#endif + } + + /** +@@ -277,24 +309,23 @@ + const char *p; + char buf[256]; + #ifndef CONFIG_IPV6 +- struct sockaddr_in my_addr, my_addr1; +- int len; ++ struct sockaddr_in my_addr; ++#else ++ struct sockaddr_storage my_addr; + #endif ++ int len; + + h->is_streamed = 1; + h->max_packet_size = 1472; + + is_output = (flags & URL_WRONLY); + +- s = av_malloc(sizeof(UDPContext)); ++ s = av_mallocz(sizeof(UDPContext)); + if (!s) + return AVERROR(ENOMEM); + + h->priv_data = s; + s->ttl = 16; +- s->is_multicast = 0; +- s->local_port = 0; +- s->reuse_socket = 0; + p = strchr(uri, '?'); + if (p) { + s->is_multicast = find_info_tag(buf, sizeof(buf), "multicast", p); +@@ -325,76 +356,41 @@ + if(!ff_network_init()) + return AVERROR(EIO); + +-#ifndef CONFIG_IPV6 +- udp_fd = socket(AF_INET, SOCK_DGRAM, 0); ++ if (s->is_multicast && !(h->flags & URL_WRONLY)) ++ s->local_port = port; ++ udp_fd = udp_socket_create(s, &my_addr, &len); + if (udp_fd < 0) + goto fail; + +- my_addr.sin_family = AF_INET; +- my_addr.sin_addr.s_addr = htonl (INADDR_ANY); +- if (s->is_multicast && !(h->flags & URL_WRONLY)) { +- /* special case: the bind must be done on the multicast address port */ +- my_addr.sin_port = s->dest_addr.sin_port; +- } else { +- my_addr.sin_port = htons(s->local_port); +- } +- + if (s->reuse_socket) + if (setsockopt (udp_fd, SOL_SOCKET, SO_REUSEADDR, &(s->reuse_socket), sizeof(s->reuse_socket)) != 0) + goto fail; + + /* the bind is needed to give a port to the socket now */ +- if (bind(udp_fd,(struct sockaddr *)&my_addr, sizeof(my_addr)) < 0) ++ if (bind(udp_fd,(struct sockaddr *)&my_addr, len) < 0) + goto fail; + +- len = sizeof(my_addr1); +- getsockname(udp_fd, (struct sockaddr *)&my_addr1, &len); +- s->local_port = ntohs(my_addr1.sin_port); ++ len = sizeof(my_addr); ++ getsockname(udp_fd, (struct sockaddr *)&my_addr, &len); ++ s->local_port = udp_port(&my_addr, len); + +-#ifdef IP_MULTICAST_TTL + if (s->is_multicast) { + if (h->flags & URL_WRONLY) { + /* output */ +- if (setsockopt(udp_fd, IPPROTO_IP, IP_MULTICAST_TTL, +- &s->ttl, sizeof(s->ttl)) < 0) { +- perror("IP_MULTICAST_TTL"); ++ if (udp_set_multicast_ttl(udp_fd, s->ttl, (struct sockaddr *)&s->dest_addr) < 0) + goto fail; +- } + } else { + /* input */ +- memset(&s->mreq, 0, sizeof(s->mreq)); +- s->mreq.imr_multiaddr = s->dest_addr.sin_addr; +- s->mreq.imr_interface.s_addr = htonl (INADDR_ANY); +- if (setsockopt(udp_fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, +- &s->mreq, sizeof(s->mreq)) < 0) { +- perror("rtp: IP_ADD_MEMBERSHIP"); +- goto fail; +- } +- } +- } +-#endif +-#else +- if (s->is_multicast && !(h->flags & URL_WRONLY)) +- s->local_port = port; +- udp_fd = udp_ipv6_set_local(h); +- if (udp_fd < 0) +- goto fail; +- if (s->is_multicast) { +- if (h->flags & URL_WRONLY) { +- if (udp_ipv6_set_multicast_ttl(udp_fd, s->ttl, (struct sockaddr *)&s->dest_addr) < 0) +- goto fail; +- } else { +- if (udp_ipv6_join_multicast_group(udp_fd, (struct sockaddr *)&s->dest_addr) < 0) ++ if (udp_join_multicast_group(udp_fd, (struct sockaddr *)&s->dest_addr) < 0) + goto fail; + } + } +-#endif /* CONFIG_IPV6 */ + + if (is_output) { + /* limit the tx buf size to limit latency */ + tmp = UDP_TX_BUF_SIZE; + if (setsockopt(udp_fd, SOL_SOCKET, SO_SNDBUF, &tmp, sizeof(tmp)) < 0) { +- perror("setsockopt sndbuf"); ++ av_log(NULL, AV_LOG_ERROR, "setsockopt(SO_SNDBUF): %s\n", strerror(errno)); + goto fail; + } + } else { +@@ -416,18 +412,10 @@ + static int udp_read(URLContext *h, uint8_t *buf, int size) + { + UDPContext *s = h->priv_data; +-#ifndef CONFIG_IPV6 +- struct sockaddr_in from; +-#else +- struct sockaddr_storage from; +-#endif +- socklen_t from_len; + int len; + + for(;;) { +- from_len = sizeof(from); +- len = recvfrom (s->udp_fd, buf, size, 0, +- (struct sockaddr *)&from, &from_len); ++ len = recv(s->udp_fd, buf, size, 0); + if (len < 0) { + if (ff_neterrno() != FF_NETERROR(EAGAIN) && + ff_neterrno() != FF_NETERROR(EINTR)) +@@ -447,11 +435,7 @@ + for(;;) { + ret = sendto (s->udp_fd, buf, size, 0, + (struct sockaddr *) &s->dest_addr, +-#ifndef CONFIG_IPV6 +- sizeof (s->dest_addr)); +-#else + s->dest_addr_len); +-#endif + if (ret < 0) { + if (ff_neterrno() != FF_NETERROR(EINTR) && + ff_neterrno() != FF_NETERROR(EAGAIN)) +@@ -467,19 +451,8 @@ + { + UDPContext *s = h->priv_data; + +-#ifndef CONFIG_IPV6 +-#ifdef IP_DROP_MEMBERSHIP +- if (s->is_multicast && !(h->flags & URL_WRONLY)) { +- if (setsockopt(s->udp_fd, IPPROTO_IP, IP_DROP_MEMBERSHIP, +- &s->mreq, sizeof(s->mreq)) < 0) { +- perror("IP_DROP_MEMBERSHIP"); +- } +- } +-#endif +-#else + if (s->is_multicast && !(h->flags & URL_WRONLY)) +- udp_ipv6_leave_multicast_group(s->udp_fd, (struct sockaddr *)&s->dest_addr); +-#endif ++ udp_leave_multicast_group(s->udp_fd, (struct sockaddr *)&s->dest_addr); + closesocket(s->udp_fd); + ff_network_close(); + av_free(s); +diff -u mplayer-1.0~rc2-12/libavformat/utils.c ffmpeg-free-0.svn20080206/libavformat/utils.c +--- mplayer-1.0~rc2-12/libavformat/utils.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/utils.c 2008-02-02 23:55:58.000000000 +0100 +@@ -1,5 +1,5 @@ + /* +- * Various utilities for ffmpeg system ++ * various utility functions for use within FFmpeg + * Copyright (c) 2000, 2001, 2002 Fabrice Bellard + * + * This file is part of FFmpeg. +@@ -30,17 +30,29 @@ + + /** + * @file libavformat/utils.c +- * Various utility functions for using ffmpeg library. ++ * various utility functions for use within FFmpeg + */ + + static void av_frac_init(AVFrac *f, int64_t val, int64_t num, int64_t den); + static void av_frac_add(AVFrac *f, int64_t incr); + +-/** head of registered input format linked list. */ ++/** head of registered input format linked list */ + AVInputFormat *first_iformat = NULL; +-/** head of registered output format linked list. */ ++/** head of registered output format linked list */ + AVOutputFormat *first_oformat = NULL; + ++AVInputFormat *av_iformat_next(AVInputFormat *f) ++{ ++ if(f) return f->next; ++ else return first_iformat; ++} ++ ++AVOutputFormat *av_oformat_next(AVOutputFormat *f) ++{ ++ if(f) return f->next; ++ else return first_oformat; ++} ++ + void av_register_input_format(AVInputFormat *format) + { + AVInputFormat **p; +@@ -100,7 +112,7 @@ + return guess_format("image2", NULL, NULL); + } + #endif +- /* find the proper file type */ ++ /* Find the proper file type. */ + fmt_found = NULL; + score_max = 0; + fmt = first_oformat; +@@ -229,8 +241,7 @@ + { + if (pkt->destruct != av_destruct_packet) { + uint8_t *data; +- /* we duplicate the packet and don't forget to put the padding +- again */ ++ /* We duplicate the packet and don't forget to add the padding again. */ + if((unsigned)pkt->size > (unsigned)pkt->size + FF_INPUT_BUFFER_PADDING_SIZE) + return AVERROR(ENOMEM); + data = av_malloc(pkt->size + FF_INPUT_BUFFER_PADDING_SIZE); +@@ -311,6 +322,8 @@ + {"track", " set the track number", OFFSET(track), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, E}, + {"year", "set the year", OFFSET(year), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, E}, + {"analyzeduration", "how many microseconds are analyzed to estimate duration", OFFSET(max_analyze_duration), FF_OPT_TYPE_INT, 3*AV_TIME_BASE, 0, INT_MAX, D}, ++{"cryptokey", "decryption key", OFFSET(key), FF_OPT_TYPE_BINARY, 0, 0, 0, D}, ++{"indexmem", "max memory used for timestamp index (per stream)", OFFSET(max_index_size), FF_OPT_TYPE_INT, INT_MAX, 0, INT_MAX, D}, + {NULL}, + }; + +@@ -361,8 +374,7 @@ + goto fail; + } + ic->iformat = fmt; +- if (pb) +- ic->pb = *pb; ++ ic->pb = pb; + ic->duration = AV_NOPTS_VALUE; + ic->start_time = AV_NOPTS_VALUE; + av_strlcpy(ic->filename, filename, sizeof(ic->filename)); +@@ -383,7 +395,7 @@ + goto fail; + + if (pb && !ic->data_offset) +- ic->data_offset = url_ftell(&ic->pb); ++ ic->data_offset = url_ftell(ic->pb); + + *ic_ptr = ic; + return 0; +@@ -396,7 +408,7 @@ + return err; + } + +-/** Size of probe buffer, for guessing file type from file contents. */ ++/** size of probe buffer, for guessing file type from file contents */ + #define PROBE_BUF_MIN 2048 + #define PROBE_BUF_MAX (1<<20) + +@@ -405,11 +417,10 @@ + int buf_size, + AVFormatParameters *ap) + { +- int err, must_open_file, file_opened, probe_size; ++ int err, probe_size; + AVProbeData probe_data, *pd = &probe_data; +- ByteIOContext pb1, *pb = &pb1; ++ ByteIOContext *pb = NULL; + +- file_opened = 0; + pd->filename = ""; + if (filename) + pd->filename = filename; +@@ -417,24 +428,17 @@ + pd->buf_size = 0; + + if (!fmt) { +- /* guess format if no file can be opened */ ++ /* guess format if no file can be opened */ + fmt = av_probe_input_format(pd, 0); + } + +- /* do not open file if the format does not need it. XXX: specific ++ /* Do not open file if the format does not need it. XXX: specific + hack needed to handle RTSP/TCP */ +- must_open_file = 1; +- if (fmt && (fmt->flags & AVFMT_NOFILE)) { +- must_open_file = 0; +- pb= NULL; //FIXME this or memset(pb, 0, sizeof(ByteIOContext)); otherwise it is uninitialized +- } +- +- if (!fmt || must_open_file) { ++ if (!fmt || !(fmt->flags & AVFMT_NOFILE)) { + /* if no file needed do not try to open one */ +- if ((err=url_fopen(pb, filename, URL_RDONLY)) < 0) { ++ if ((err=url_fopen(&pb, filename, URL_RDONLY)) < 0) { + goto fail; + } +- file_opened = 1; + if (buf_size > 0) { + url_setbufsize(pb, buf_size); + } +@@ -447,8 +451,8 @@ + memset(pd->buf+pd->buf_size, 0, AVPROBE_PADDING_SIZE); + if (url_fseek(pb, 0, SEEK_SET) < 0) { + url_fclose(pb); +- if (url_fopen(pb, filename, URL_RDONLY) < 0) { +- file_opened = 0; ++ if (url_fopen(&pb, filename, URL_RDONLY) < 0) { ++ pb = NULL; + err = AVERROR(EIO); + goto fail; + } +@@ -465,17 +469,7 @@ + goto fail; + } + +- /* XXX: suppress this hack for redirectors */ +-#ifdef CONFIG_REDIR_DEMUXER +- if (!strcmp(fmt->name, "redir")) { +- int redir_open(AVFormatContext **ic_ptr, ByteIOContext *f); +- err = redir_open(ic_ptr, pb); +- url_fclose(pb); +- return err; +- } +-#endif +- +- /* check filename in case of an image number is expected */ ++ /* check filename in case an image number is expected */ + if (fmt->flags & AVFMT_NEEDNUMBER) { + if (!av_filename_number_test(filename)) { + err = AVERROR_NUMEXPECTED; +@@ -488,7 +482,7 @@ + return 0; + fail: + av_freep(&pd->buf); +- if (file_opened) ++ if (pb) + url_fclose(pb); + *ic_ptr = NULL; + return err; +@@ -499,14 +493,33 @@ + + int av_read_packet(AVFormatContext *s, AVPacket *pkt) + { ++ int ret; ++ AVStream *st; + av_init_packet(pkt); +- return s->iformat->read_packet(s, pkt); ++ ret= s->iformat->read_packet(s, pkt); ++ if (ret < 0) ++ return ret; ++ st= s->streams[pkt->stream_index]; ++ ++ switch(st->codec->codec_type){ ++ case CODEC_TYPE_VIDEO: ++ if(s->video_codec_id) st->codec->codec_id= s->video_codec_id; ++ break; ++ case CODEC_TYPE_AUDIO: ++ if(s->audio_codec_id) st->codec->codec_id= s->audio_codec_id; ++ break; ++ case CODEC_TYPE_SUBTITLE: ++ if(s->subtitle_codec_id)st->codec->codec_id= s->subtitle_codec_id; ++ break; ++ } ++ ++ return ret; + } + + /**********************************************************/ + + /** +- * Get the number of samples of an audio frame. Return (-1) if error. ++ * Get the number of samples of an audio frame. Return -1 on error. + */ + static int get_audio_frame_size(AVCodecContext *enc, int size) + { +@@ -533,7 +546,7 @@ + + + /** +- * Return the frame duration in seconds, return 0 if not available. ++ * Return the frame duration in seconds. Return 0 if not available. + */ + static void compute_frame_duration(int *pnum, int *pden, AVStream *st, + AVCodecParserContext *pc, AVPacket *pkt) +@@ -637,7 +650,8 @@ + } + } + +- /* correct timestamps with byte offset if demuxers only have timestamps on packet boundaries */ ++ /* correct timestamps with byte offset if demuxers only have timestamps ++ on packet boundaries */ + if(pc && st->need_parsing == AVSTREAM_PARSE_TIMESTAMPS && pkt->size){ + /* this will estimate bitrate based on this frame's duration and size */ + offset = av_rescale(pc->offset, pkt->duration, pkt->size); +@@ -647,10 +661,7 @@ + pkt->dts += offset; + } + +- if(is_intra_only(st->codec)) +- pkt->flags |= PKT_FLAG_KEY; +- +- /* do we have a video B frame ? */ ++ /* do we have a video B-frame ? */ + delay= st->codec->has_b_frames; + presentation_delayed = 0; + /* XXX: need has_b_frame, but cannot get it if the codec is +@@ -670,8 +681,8 @@ + /* interpolate PTS and DTS if they are not present */ + if(delay <=1){ + if (presentation_delayed) { +- /* DTS = decompression time stamp */ +- /* PTS = presentation time stamp */ ++ /* DTS = decompression timestamp */ ++ /* PTS = presentation timestamp */ + if (pkt->dts == AV_NOPTS_VALUE) + pkt->dts = st->last_IP_pts; + update_initial_timestamps(s, pkt->stream_index, pkt->dts, pkt->pts); +@@ -679,14 +690,14 @@ + pkt->dts = st->cur_dts; + + /* this is tricky: the dts must be incremented by the duration +- of the frame we are displaying, i.e. the last I or P frame */ ++ of the frame we are displaying, i.e. the last I- or P-frame */ + if (st->last_IP_duration == 0) + st->last_IP_duration = pkt->duration; + st->cur_dts = pkt->dts + st->last_IP_duration; + st->last_IP_duration = pkt->duration; + st->last_IP_pts= pkt->pts; + /* cannot compute PTS if not present (we can compute it only +- by knowing the futur */ ++ by knowing the future */ + } else if(pkt->pts != AV_NOPTS_VALUE || pkt->dts != AV_NOPTS_VALUE || pkt->duration){ + if(pkt->pts != AV_NOPTS_VALUE && pkt->duration){ + int64_t old_diff= FFABS(st->cur_dts - pkt->duration - pkt->pts); +@@ -726,9 +737,11 @@ + // av_log(NULL, AV_LOG_ERROR, "OUTdelayed:%d/%d pts:%"PRId64", dts:%"PRId64" cur_dts:%"PRId64"\n", presentation_delayed, delay, pkt->pts, pkt->dts, st->cur_dts); + + /* update flags */ +- if (pc) { ++ if(is_intra_only(st->codec)) ++ pkt->flags |= PKT_FLAG_KEY; ++ else if (pc) { + pkt->flags = 0; +- /* key frame computation */ ++ /* keyframe computation */ + if (pc->pict_type == FF_I_TYPE) + pkt->flags |= PKT_FLAG_KEY; + } +@@ -779,6 +792,7 @@ + compute_pkt_fields(s, st, st->parser, pkt); + + if((s->iformat->flags & AVFMT_GENERIC_INDEX) && pkt->flags & PKT_FLAG_KEY){ ++ ff_reduce_index(s, st->index); + av_add_index_entry(st, st->parser->frame_offset, pkt->dts, + 0, 0, AVINDEX_KEYFRAME); + } +@@ -808,7 +822,7 @@ + goto got_packet; + } + } +- /* no more packets: really terminates parsing */ ++ /* no more packets: really terminate parsing */ + return ret; + } + +@@ -826,7 +840,7 @@ + if (st->need_parsing && !st->parser) { + st->parser = av_parser_init(st->codec->codec_id); + if (!st->parser) { +- /* no parser available : just output the raw packets */ ++ /* no parser available: just output the raw packets */ + st->need_parsing = AVSTREAM_PARSE_NONE; + }else if(st->need_parsing == AVSTREAM_PARSE_HEADERS){ + st->parser->flags |= PARSER_FLAG_COMPLETE_FRAMES; +@@ -996,6 +1010,19 @@ + } + } + ++void ff_reduce_index(AVFormatContext *s, int stream_index) ++{ ++ AVStream *st= s->streams[stream_index]; ++ unsigned int max_entries= s->max_index_size / sizeof(AVIndexEntry); ++ ++ if((unsigned)st->nb_index_entries >= max_entries){ ++ int i; ++ for(i=0; 2*inb_index_entries; i++) ++ st->index_entries[i]= st->index_entries[2*i]; ++ st->nb_index_entries= i; ++ } ++} ++ + int av_add_index_entry(AVStream *st, + int64_t pos, int64_t timestamp, int size, int distance, int flags) + { +@@ -1096,7 +1123,7 @@ + if(st->index_entries){ + AVIndexEntry *e; + +- index= av_index_search_timestamp(st, target_ts, flags | AVSEEK_FLAG_BACKWARD); //FIXME whole func must be checked for non keyframe entries in index case, especially read_timestamp() ++ index= av_index_search_timestamp(st, target_ts, flags | AVSEEK_FLAG_BACKWARD); //FIXME whole func must be checked for non-keyframe entries in index case, especially read_timestamp() + index= FFMAX(index, 0); + e= &st->index_entries[index]; + +@@ -1131,7 +1158,7 @@ + return -1; + + /* do the seek */ +- url_fseek(&s->pb, pos, SEEK_SET); ++ url_fseek(s->pb, pos, SEEK_SET); + + av_update_cur_dts(s, st, ts); + +@@ -1156,7 +1183,7 @@ + + if(ts_max == AV_NOPTS_VALUE){ + int step= 1024; +- filesize = url_fsize(&s->pb); ++ filesize = url_fsize(s->pb); + pos_max = filesize - 1; + do{ + pos_max -= step; +@@ -1203,7 +1230,8 @@ + // bisection, if interpolation failed to change min or max pos last time + pos = (pos_min + pos_limit)>>1; + }else{ +- // linear search if bisection failed, can only happen if there are very few or no keframes between min/max ++ /* linear search if bisection failed, can only happen if there ++ are very few or no keyframes between min/max */ + pos=pos_min; + } + if(pos <= pos_min) +@@ -1262,12 +1290,12 @@ + #endif + + pos_min = s->data_offset; +- pos_max = url_fsize(&s->pb) - 1; ++ pos_max = url_fsize(s->pb) - 1; + + if (pos < pos_min) pos= pos_min; + else if(pos > pos_max) pos= pos_max; + +- url_fseek(&s->pb, pos, SEEK_SET); ++ url_fseek(s->pb, pos, SEEK_SET); + + #if 0 + av_update_cur_dts(s, st, ts); +@@ -1292,10 +1320,10 @@ + + if(st->index_entries && st->nb_index_entries){ + ie= &st->index_entries[st->nb_index_entries-1]; +- url_fseek(&s->pb, ie->pos, SEEK_SET); ++ url_fseek(s->pb, ie->pos, SEEK_SET); + av_update_cur_dts(s, st, ie->timestamp); + }else +- url_fseek(&s->pb, 0, SEEK_SET); ++ url_fseek(s->pb, 0, SEEK_SET); + + for(i=0;; i++) { + int ret = av_read_frame(s, &pkt); +@@ -1318,7 +1346,7 @@ + return 0; + } + ie = &st->index_entries[index]; +- url_fseek(&s->pb, ie->pos, SEEK_SET); ++ url_fseek(s->pb, ie->pos, SEEK_SET); + + av_update_cur_dts(s, st, ie->timestamp); + +@@ -1398,7 +1426,7 @@ + duration = INT64_MIN; + for(i = 0;i < ic->nb_streams; i++) { + st = ic->streams[i]; +- if (st->start_time != AV_NOPTS_VALUE) { ++ if (st->start_time != AV_NOPTS_VALUE && st->time_base.den) { + start_time1= av_rescale_q(st->start_time, st->time_base, AV_TIME_BASE_Q); + if (start_time1 < start_time) + start_time = start_time1; +@@ -1425,7 +1453,7 @@ + if (duration != INT64_MIN) { + ic->duration = duration; + if (ic->file_size > 0) { +- /* compute the bit rate */ ++ /* compute the bitrate */ + ic->bit_rate = (double)ic->file_size * 8.0 * AV_TIME_BASE / + (double)ic->duration; + } +@@ -1510,7 +1538,7 @@ + + /* we read the first packets to get the first PTS (not fully + accurate, but it is enough now) */ +- url_fseek(&ic->pb, 0, SEEK_SET); ++ url_fseek(ic->pb, 0, SEEK_SET); + read_size = 0; + for(;;) { + if (read_size >= DURATION_MAX_READ_SIZE) +@@ -1543,7 +1571,7 @@ + if (offset < 0) + offset = 0; + +- url_fseek(&ic->pb, offset, SEEK_SET); ++ url_fseek(ic->pb, offset, SEEK_SET); + read_size = 0; + for(;;) { + if (read_size >= DURATION_MAX_READ_SIZE) +@@ -1569,7 +1597,7 @@ + + fill_all_stream_timings(ic); + +- url_fseek(&ic->pb, old_offset, SEEK_SET); ++ url_fseek(ic->pb, old_offset, SEEK_SET); + for(i=0; inb_streams; i++){ + st= ic->streams[i]; + st->cur_dts= st->first_dts; +@@ -1585,7 +1613,7 @@ + if (ic->iformat->flags & AVFMT_NOFILE) { + file_size = 0; + } else { +- file_size = url_fsize(&ic->pb); ++ file_size = url_fsize(ic->pb); + if (file_size < 0) + file_size = 0; + } +@@ -1593,15 +1621,15 @@ + + if ((!strcmp(ic->iformat->name, "mpeg") || + !strcmp(ic->iformat->name, "mpegts")) && +- file_size && !ic->pb.is_streamed) { ++ file_size && !url_is_streamed(ic->pb)) { + /* get accurate estimate from the PTSes */ + av_estimate_timings_from_pts(ic, old_offset); + } else if (av_has_duration(ic)) { +- /* at least one components has timings - we use them for all ++ /* at least one component has timings - we use them for all + the components */ + fill_all_stream_timings(ic); + } else { +- /* less precise: use bit rate info */ ++ /* less precise: use bitrate info */ + av_estimate_timings_from_bit_rate(ic); + } + av_update_stream_timings(ic); +@@ -1661,7 +1689,7 @@ + switch(st->codec->codec_type) { + case CODEC_TYPE_VIDEO: + ret = avcodec_decode_video(st->codec, &picture, +- &got_picture, (uint8_t *)data, size); ++ &got_picture, data, size); + break; + case CODEC_TYPE_AUDIO: + data_size = FFMAX(size, AVCODEC_MAX_AUDIO_FRAME_SIZE); +@@ -1669,7 +1697,7 @@ + if (!samples) + goto fail; + ret = avcodec_decode_audio2(st->codec, samples, +- &data_size, (uint8_t *)data, size); ++ &data_size, data, size); + av_free(samples); + break; + default: +@@ -1750,6 +1778,24 @@ + else return ((int[]){24,30,60,12,15})[i-60*12]*1000*12; + } + ++/* ++ * Is the time base unreliable. ++ * This is a heuristic to balance between quick acceptance of the values in ++ * the headers vs. some extra checks. ++ * Old DivX and Xvid often have nonsense timebases like 1fps or 2fps. ++ * MPEG-2 commonly misuses field repeat flags to store different framerates. ++ * And there are "variable" fps files this needs to detect as well. ++ */ ++static int tb_unreliable(AVCodecContext *c){ ++ if( c->time_base.den >= 101L*c->time_base.num ++ || c->time_base.den < 5L*c->time_base.num ++/* || c->codec_tag == ff_get_fourcc("DIVX") ++ || c->codec_tag == ff_get_fourcc("XVID")*/ ++ || c->codec_id == CODEC_ID_MPEG2VIDEO) ++ return 1; ++ return 0; ++} ++ + int av_find_stream_info(AVFormatContext *ic) + { + int i, count, ret, read_size, j; +@@ -1758,7 +1804,7 @@ + int64_t last_dts[MAX_STREAMS]; + int duration_count[MAX_STREAMS]={0}; + double (*duration_error)[MAX_STD_TIMEBASES]; +- offset_t old_offset = url_ftell(&ic->pb); ++ offset_t old_offset = url_ftell(ic->pb); + int64_t codec_info_duration[MAX_STREAMS]={0}; + int codec_info_nb_frames[MAX_STREAMS]={0}; + AVProbeData probe_data[MAX_STREAMS]; +@@ -1798,7 +1844,7 @@ + if (!has_codec_parameters(st->codec)) + break; + /* variable fps and no guess at the real fps */ +- if( (st->codec->time_base.den >= 101LL*st->codec->time_base.num || st->codec->codec_id == CODEC_ID_MPEG2VIDEO) ++ if( tb_unreliable(st->codec) + && duration_count[i]<20 && st->codec->codec_type == CODEC_TYPE_VIDEO) + break; + if(st->parser && st->parser->parser->split && !st->codec->extradata) +@@ -1896,8 +1942,8 @@ + + /* if still no information, we try to open the codec and to + decompress the frame. We try to avoid that in most cases as +- it takes longer and uses more memory. For MPEG4, we need to +- decompress for Quicktime. */ ++ it takes longer and uses more memory. For MPEG-4, we need to ++ decompress for QuickTime. */ + if (!has_codec_parameters(st->codec) /*&& + (st->codec->codec_id == CODEC_ID_FLV1 || + st->codec->codec_id == CODEC_ID_H264 || +@@ -1934,8 +1980,8 @@ + st->codec->codec_tag= avcodec_pix_fmt_to_codec_tag(st->codec->pix_fmt); + + if(duration_count[i] +- && (st->codec->time_base.num*101LL <= st->codec->time_base.den || st->codec->codec_id == CODEC_ID_MPEG2VIDEO) /*&& +- //FIXME we should not special case mpeg2, but this needs testing with non mpeg2 ... ++ && tb_unreliable(st->codec) /*&& ++ //FIXME we should not special-case MPEG-2, but this needs testing with non-MPEG-2 ... + st->time_base.num*duration_sum[i]/duration_count[i]*101LL > st->time_base.den*/){ + double best_error= 2*av_q2d(st->time_base); + best_error= best_error*best_error*duration_count[i]*1000*12*30; +@@ -1990,11 +2036,11 @@ + } + st->cur_dts= st->first_dts; + } +- url_fseek(&ic->pb, ic->data_offset, SEEK_SET); ++ url_fseek(ic->pb, ic->data_offset, SEEK_SET); + } + + #if 0 +- /* correct DTS for b frame streams with no timestamps */ ++ /* correct DTS for B-frame streams with no timestamps */ + for(i=0;inb_streams;i++) { + st = ic->streams[i]; + if (st->codec->codec_type == CODEC_TYPE_VIDEO) { +@@ -2030,21 +2076,25 @@ + + int av_read_play(AVFormatContext *s) + { +- if (!s->iformat->read_play) +- return AVERROR(ENOSYS); +- return s->iformat->read_play(s); ++ if (s->iformat->read_play) ++ return s->iformat->read_play(s); ++ if (s->pb) ++ return av_url_read_fpause(s->pb, 0); ++ return AVERROR(ENOSYS); + } + + int av_read_pause(AVFormatContext *s) + { +- if (!s->iformat->read_pause) +- return AVERROR(ENOSYS); +- return s->iformat->read_pause(s); ++ if (s->iformat->read_pause) ++ return s->iformat->read_pause(s); ++ if (s->pb) ++ return av_url_read_fpause(s->pb, 1); ++ return AVERROR(ENOSYS); + } + +-void av_close_input_file(AVFormatContext *s) ++void av_close_input_stream(AVFormatContext *s) + { +- int i, must_open_file; ++ int i; + AVStream *st; + + /* free previous packet */ +@@ -2062,25 +2112,28 @@ + av_free(st->index_entries); + av_free(st->codec->extradata); + av_free(st->codec); ++ av_free(st->filename); + av_free(st); + } + for(i=s->nb_programs-1; i>=0; i--) { + av_freep(&s->programs[i]->provider_name); + av_freep(&s->programs[i]->name); ++ av_freep(&s->programs[i]->stream_index); + av_freep(&s->programs[i]); + } + flush_packet_queue(s); +- must_open_file = 1; +- if (s->iformat->flags & AVFMT_NOFILE) { +- must_open_file = 0; +- } +- if (must_open_file) { +- url_fclose(&s->pb); +- } + av_freep(&s->priv_data); + av_free(s); + } + ++void av_close_input_file(AVFormatContext *s) ++{ ++ ByteIOContext *pb = s->iformat->flags & AVFMT_NOFILE ? NULL : s->pb; ++ av_close_input_stream(s); ++ if (pb) ++ url_fclose(pb); ++} ++ + AVStream *av_new_stream(AVFormatContext *s, int id) + { + AVStream *st; +@@ -2105,7 +2158,7 @@ + st->cur_dts = AV_NOPTS_VALUE; + st->first_dts = AV_NOPTS_VALUE; + +- /* default pts settings is MPEG like */ ++ /* default pts setting is MPEG-like */ + av_set_pts_info(st, 33, 1, 90000); + st->last_IP_pts = AV_NOPTS_VALUE; + for(i=0; icodec->codec_tag){ + //FIXME + //check that tag + id is in the table +- //if neither is in the table -> ok ++ //if neither is in the table -> OK + //if tag is in the table with another id -> FAIL + //if id is in the table with another tag -> FAIL unless strict < ? + }else +@@ -2304,8 +2357,9 @@ + case CODEC_TYPE_AUDIO: + frame_size = get_audio_frame_size(st->codec, pkt->size); + +- /* HACK/FIXME, we skip the initial 0-size packets as they are most likely equal to the encoder delay, +- but it would be better if we had the real timestamps from the encoder */ ++ /* HACK/FIXME, we skip the initial 0 size packets as they are most ++ likely equal to the encoder delay, but it would be better if we ++ had the real timestamps from the encoder */ + if (frame_size >= 0 && (pkt->size || st->pts.num!=st->pts.den>>1 || st->pts.val)) { + av_frac_add(&st->pts, (int64_t)st->time_base.den * frame_size); + } +@@ -2323,7 +2377,7 @@ + int64_t pts_mask = (2LL << (st->pts_wrap_bits-1)) - 1; + + // if(pkt->dts < 0) +-// pkt->dts= 0; //this happens for low_delay=0 and b frames, FIXME, needs further invstigation about what we should do here ++// pkt->dts= 0; //this happens for low_delay=0 and B-frames, FIXME, needs further investigation about what we should do here + + if (pkt->pts != AV_NOPTS_VALUE) + pkt->pts &= pts_mask; +@@ -2343,7 +2397,7 @@ + + ret= s->oformat->write_packet(s, pkt); + if(!ret) +- ret= url_ferror(&s->pb); ++ ret= url_ferror(s->pb); + return ret; + } + +@@ -2360,7 +2414,7 @@ + this_pktl = av_mallocz(sizeof(AVPacketList)); + this_pktl->pkt= *pkt; + if(pkt->destruct == av_destruct_packet) +- pkt->destruct= NULL; // non shared -> must keep original from being freed ++ pkt->destruct= NULL; // not shared -> must keep original from being freed + else + av_dup_packet(&this_pktl->pkt); //shared -> must dup + +@@ -2401,7 +2455,7 @@ + } + + /** +- * Interleaves a AVPacket correctly so it can be muxed. ++ * Interleaves an AVPacket correctly so it can be muxed. + * @param out the interleaved packet will be output here + * @param in the input packet + * @param flush 1 if no further packets are available as input and all +@@ -2444,8 +2498,8 @@ + + if(ret<0) + return ret; +- if(url_ferror(&s->pb)) +- return url_ferror(&s->pb); ++ if(url_ferror(s->pb)) ++ return url_ferror(s->pb); + } + } + +@@ -2468,7 +2522,7 @@ + + if(ret<0) + goto fail; +- if(url_ferror(&s->pb)) ++ if(url_ferror(s->pb)) + goto fail; + } + +@@ -2476,22 +2530,70 @@ + ret = s->oformat->write_trailer(s); + fail: + if(ret == 0) +- ret=url_ferror(&s->pb); ++ ret=url_ferror(s->pb); + for(i=0;inb_streams;i++) + av_freep(&s->streams[i]->priv_data); + av_freep(&s->priv_data); + return ret; + } + ++void av_program_add_stream_index(AVFormatContext *ac, int progid, unsigned int idx) ++{ ++ int i, j; ++ AVProgram *program=NULL; ++ void *tmp; ++ ++ for(i=0; inb_programs; i++){ ++ if(ac->programs[i]->id != progid) ++ continue; ++ program = ac->programs[i]; ++ for(j=0; jnb_stream_indexes; j++) ++ if(program->stream_index[j] == idx) ++ return; ++ ++ tmp = av_realloc(program->stream_index, sizeof(unsigned int)*(program->nb_stream_indexes+1)); ++ if(!tmp) ++ return; ++ program->stream_index = tmp; ++ program->stream_index[program->nb_stream_indexes++] = idx; ++ return; ++ } ++} ++ + /* "user interface" functions */ ++static void dump_stream_format(AVFormatContext *ic, int i, int index, int is_output) ++{ ++ char buf[256]; ++ int flags = (is_output ? ic->oformat->flags : ic->iformat->flags); ++ AVStream *st = ic->streams[i]; ++ int g = ff_gcd(st->time_base.num, st->time_base.den); ++ avcodec_string(buf, sizeof(buf), st->codec, is_output); ++ av_log(NULL, AV_LOG_INFO, " Stream #%d.%d", index, i); ++ /* the pid is an important information, so we display it */ ++ /* XXX: add a generic system */ ++ if (flags & AVFMT_SHOW_IDS) ++ av_log(NULL, AV_LOG_INFO, "[0x%x]", st->id); ++ if (strlen(st->language) > 0) ++ av_log(NULL, AV_LOG_INFO, "(%s)", st->language); ++ av_log(NULL, AV_LOG_DEBUG, ", %d/%d", st->time_base.num/g, st->time_base.den/g); ++ av_log(NULL, AV_LOG_INFO, ": %s", buf); ++ if(st->codec->codec_type == CODEC_TYPE_VIDEO){ ++ if(st->r_frame_rate.den && st->r_frame_rate.num) ++ av_log(NULL, AV_LOG_INFO, ", %5.2f tb(r)", av_q2d(st->r_frame_rate)); ++/* else if(st->time_base.den && st->time_base.num) ++ av_log(NULL, AV_LOG_INFO, ", %5.2f tb(m)", 1/av_q2d(st->time_base));*/ ++ else ++ av_log(NULL, AV_LOG_INFO, ", %5.2f tb(c)", 1/av_q2d(st->codec->time_base)); ++ } ++ av_log(NULL, AV_LOG_INFO, "\n"); ++} + + void dump_format(AVFormatContext *ic, + int index, + const char *url, + int is_output) + { +- int i, flags; +- char buf[256]; ++ int i; + + av_log(NULL, AV_LOG_INFO, "%s #%d, %s, %s '%s':\n", + is_output ? "Output" : "Input", +@@ -2529,35 +2631,17 @@ + } + av_log(NULL, AV_LOG_INFO, "\n"); + } +- for(i=0;inb_streams;i++) { +- AVStream *st = ic->streams[i]; +- int g= ff_gcd(st->time_base.num, st->time_base.den); +- avcodec_string(buf, sizeof(buf), st->codec, is_output); +- av_log(NULL, AV_LOG_INFO, " Stream #%d.%d", index, i); +- /* the pid is an important information, so we display it */ +- /* XXX: add a generic system */ +- if (is_output) +- flags = ic->oformat->flags; +- else +- flags = ic->iformat->flags; +- if (flags & AVFMT_SHOW_IDS) { +- av_log(NULL, AV_LOG_INFO, "[0x%x]", st->id); +- } +- if (strlen(st->language) > 0) { +- av_log(NULL, AV_LOG_INFO, "(%s)", st->language); +- } +- av_log(NULL, AV_LOG_DEBUG, ", %d/%d", st->time_base.num/g, st->time_base.den/g); +- av_log(NULL, AV_LOG_INFO, ": %s", buf); +- if(st->codec->codec_type == CODEC_TYPE_VIDEO){ +- if(st->r_frame_rate.den && st->r_frame_rate.num) +- av_log(NULL, AV_LOG_INFO, ", %5.2f fps(r)", av_q2d(st->r_frame_rate)); +-/* else if(st->time_base.den && st->time_base.num) +- av_log(NULL, AV_LOG_INFO, ", %5.2f fps(m)", 1/av_q2d(st->time_base));*/ +- else +- av_log(NULL, AV_LOG_INFO, ", %5.2f fps(c)", 1/av_q2d(st->codec->time_base)); +- } +- av_log(NULL, AV_LOG_INFO, "\n"); +- } ++ if(ic->nb_programs) { ++ int j, k; ++ for(j=0; jnb_programs; j++) { ++ av_log(NULL, AV_LOG_INFO, " Program %d %s\n", ic->programs[j]->id, ++ ic->programs[j]->name ? ic->programs[j]->name : ""); ++ for(k=0; kprograms[j]->nb_stream_indexes; k++) ++ dump_stream_format(ic, ic->programs[j]->stream_index[k], index, is_output); ++ } ++ } else ++ for(i=0;inb_streams;i++) ++ dump_stream_format(ic, i, index, is_output); + } + + int parse_image_size(int *width_ptr, int *height_ptr, const char *str) +@@ -2575,7 +2659,7 @@ + } + + /** +- * gets the current time in micro seconds. ++ * Gets the current time in microseconds. + */ + int64_t av_gettime(void) + { +@@ -2845,7 +2929,7 @@ + PRINT("N/A"); + else + PRINT("%0.3f", (double)pkt->dts / AV_TIME_BASE); +- /* PTS may be not known if B frames are present */ ++ /* PTS may not be known if B-frames are present. */ + PRINT(" pts="); + if (pkt->pts == AV_NOPTS_VALUE) + PRINT("N/A"); +@@ -2896,7 +2980,10 @@ + } + + /* separate path from hostname */ +- if ((ls = strchr(p, '/'))) ++ ls = strchr(p, '/'); ++ if(!ls) ++ ls = strchr(p, '?'); ++ if(ls) + av_strlcpy(path, ls, path_size); + else + ls = &p[strlen(p)]; // XXX +@@ -2959,7 +3046,7 @@ + } + + /** +- * Fractionnal addition to f: f = f + (incr / f->den). ++ * Fractional addition to f: f = f + (incr / f->den). + * + * @param f fractional number + * @param incr increment, can be positive or negative +Only in mplayer-1.0~rc2-12/libavformat: v4l2.c +Only in mplayer-1.0~rc2-12/libavformat: v4l.c +Only in ffmpeg-free-0.svn20080206/libavformat: vc1test.c +diff -u mplayer-1.0~rc2-12/libavformat/vocdec.c ffmpeg-free-0.svn20080206/libavformat/vocdec.c +--- mplayer-1.0~rc2-12/libavformat/vocdec.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/vocdec.c 2007-11-21 08:41:00.000000000 +0100 +@@ -39,7 +39,7 @@ + static int voc_read_header(AVFormatContext *s, AVFormatParameters *ap) + { + voc_dec_context_t *voc = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + int header_size; + AVStream *st; + +@@ -64,7 +64,7 @@ + { + voc_dec_context_t *voc = s->priv_data; + AVCodecContext *dec = st->codec; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + voc_type_t type; + int size; + int sample_rate = 0; +diff -u mplayer-1.0~rc2-12/libavformat/vocenc.c ffmpeg-free-0.svn20080206/libavformat/vocenc.c +--- mplayer-1.0~rc2-12/libavformat/vocenc.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/vocenc.c 2007-11-21 08:41:00.000000000 +0100 +@@ -28,7 +28,7 @@ + + static int voc_write_header(AVFormatContext *s) + { +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + const int header_size = 26; + const int version = 0x0114; + +@@ -48,7 +48,7 @@ + { + voc_enc_context_t *voc = s->priv_data; + AVCodecContext *enc = s->streams[0]->codec; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + + if (!voc->param_written) { + if (enc->codec_tag > 0xFF) { +@@ -84,7 +84,7 @@ + + static int voc_write_trailer(AVFormatContext *s) + { +- put_byte(&s->pb, 0); ++ put_byte(s->pb, 0); + return 0; + } + +diff -u mplayer-1.0~rc2-12/libavformat/voc.h ffmpeg-free-0.svn20080206/libavformat/voc.h +--- mplayer-1.0~rc2-12/libavformat/voc.h 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/voc.h 2007-10-17 11:37:46.000000000 +0200 +@@ -19,8 +19,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef VOC_H +-#define VOC_H ++#ifndef FFMPEG_VOC_H ++#define FFMPEG_VOC_H + + #include "avformat.h" + #include "riff.h" /* for CodecTag */ +@@ -48,4 +48,4 @@ + int voc_get_packet(AVFormatContext *s, AVPacket *pkt, + AVStream *st, int max_size); + +-#endif ++#endif /* FFMPEG_VOC_H */ +diff -u mplayer-1.0~rc2-12/libavformat/wav.c ffmpeg-free-0.svn20080206/libavformat/wav.c +--- mplayer-1.0~rc2-12/libavformat/wav.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/wav.c 2007-11-21 08:41:00.000000000 +0100 +@@ -34,7 +34,7 @@ + static int wav_write_header(AVFormatContext *s) + { + WAVContext *wav = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + offset_t fmt, fact; + + put_tag(pb, "RIFF"); +@@ -50,7 +50,7 @@ + end_tag(pb, fmt); + + if(s->streams[0]->codec->codec_tag != 0x01 /* hence for all other than PCM */ +- && !url_is_streamed(&s->pb)) { ++ && !url_is_streamed(s->pb)) { + fact = start_tag(pb, "fact"); + put_le32(pb, 0); + end_tag(pb, fact); +@@ -70,7 +70,7 @@ + + static int wav_write_packet(AVFormatContext *s, AVPacket *pkt) + { +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + WAVContext *wav = s->priv_data; + put_buffer(pb, pkt->data, pkt->size); + if(pkt->pts != AV_NOPTS_VALUE) { +@@ -84,11 +84,11 @@ + + static int wav_write_trailer(AVFormatContext *s) + { +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + WAVContext *wav = s->priv_data; + offset_t file_size; + +- if (!url_is_streamed(&s->pb)) { ++ if (!url_is_streamed(s->pb)) { + end_tag(pb, wav->data); + + /* update file size */ +@@ -156,7 +156,7 @@ + { + int size; + unsigned int tag; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + AVStream *st; + WAVContext *wav = s->priv_data; + +@@ -199,17 +199,17 @@ + AVStream *st; + WAVContext *wav = s->priv_data; + +- if (url_feof(&s->pb)) ++ if (url_feof(s->pb)) + return AVERROR(EIO); + st = s->streams[0]; + +- left= wav->data_end - url_ftell(&s->pb); ++ left= wav->data_end - url_ftell(s->pb); + if(left <= 0){ +- left = find_tag(&(s->pb), MKTAG('d', 'a', 't', 'a')); ++ left = find_tag(s->pb, MKTAG('d', 'a', 't', 'a')); + if (left < 0) { + return AVERROR(EIO); + } +- wav->data_end= url_ftell(&s->pb) + left; ++ wav->data_end= url_ftell(s->pb) + left; + } + + size = MAX_SIZE; +@@ -219,7 +219,7 @@ + size = (size / st->codec->block_align) * st->codec->block_align; + } + size= FFMIN(size, left); +- ret= av_get_packet(&s->pb, pkt, size); ++ ret= av_get_packet(s->pb, pkt, size); + if (ret <= 0) + return AVERROR(EIO); + pkt->stream_index = 0; +diff -u mplayer-1.0~rc2-12/libavformat/wc3movie.c ffmpeg-free-0.svn20080206/libavformat/wc3movie.c +--- mplayer-1.0~rc2-12/libavformat/wc3movie.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/wc3movie.c 2007-12-01 01:07:51.000000000 +0100 +@@ -33,7 +33,7 @@ + + #define FORM_TAG MKTAG('F', 'O', 'R', 'M') + #define MOVE_TAG MKTAG('M', 'O', 'V', 'E') +-#define _PC__TAG MKTAG('_', 'P', 'C', '_') ++#define PC__TAG MKTAG('_', 'P', 'C', '_') + #define SOND_TAG MKTAG('S', 'O', 'N', 'D') + #define BNAM_TAG MKTAG('B', 'N', 'A', 'M') + #define SIZE_TAG MKTAG('S', 'I', 'Z', 'E') +@@ -126,7 +126,7 @@ + AVFormatParameters *ap) + { + Wc3DemuxContext *wc3 = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + unsigned int fourcc_tag; + unsigned int size; + AVStream *st; +@@ -165,7 +165,7 @@ + url_fseek(pb, size, SEEK_CUR); + break; + +- case _PC__TAG: ++ case PC__TAG: + /* need the number of palettes */ + url_fseek(pb, 8, SEEK_CUR); + if ((ret = get_buffer(pb, preamble, 4)) != 4) +@@ -272,7 +272,7 @@ + AVPacket *pkt) + { + Wc3DemuxContext *wc3 = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + unsigned int fourcc_tag; + unsigned int size; + int packet_read = 0; +diff -u mplayer-1.0~rc2-12/libavformat/westwood.c ffmpeg-free-0.svn20080206/libavformat/westwood.c +--- mplayer-1.0~rc2-12/libavformat/westwood.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/westwood.c 2007-11-21 08:41:00.000000000 +0100 +@@ -118,7 +118,7 @@ + AVFormatParameters *ap) + { + WsAudDemuxContext *wsaud = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + AVStream *st; + unsigned char header[AUD_HEADER_SIZE]; + +@@ -160,7 +160,7 @@ + AVPacket *pkt) + { + WsAudDemuxContext *wsaud = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + unsigned char preamble[AUD_CHUNK_PREAMBLE_SIZE]; + unsigned int chunk_size; + int ret = 0; +@@ -213,7 +213,7 @@ + AVFormatParameters *ap) + { + WsVqaDemuxContext *wsvqa = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + AVStream *st; + unsigned char *header; + unsigned char scratch[VQA_PREAMBLE_SIZE]; +@@ -315,7 +315,7 @@ + AVPacket *pkt) + { + WsVqaDemuxContext *wsvqa = s->priv_data; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + int ret = -1; + unsigned char preamble[VQA_PREAMBLE_SIZE]; + unsigned int chunk_type; +diff -u mplayer-1.0~rc2-12/libavformat/wv.c ffmpeg-free-0.svn20080206/libavformat/wv.c +--- mplayer-1.0~rc2-12/libavformat/wv.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/wv.c 2007-11-21 08:41:00.000000000 +0100 +@@ -135,7 +135,7 @@ + static int wv_read_header(AVFormatContext *s, + AVFormatParameters *ap) + { +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + WVContext *wc = s->priv_data; + AVStream *st; + +@@ -164,17 +164,17 @@ + WVContext *wc = s->priv_data; + int ret; + +- if (url_feof(&s->pb)) ++ if (url_feof(s->pb)) + return AVERROR(EIO); + if(wc->block_parsed){ +- if(wv_read_block_header(s, &s->pb) < 0) ++ if(wv_read_block_header(s, s->pb) < 0) + return -1; + } + + if(av_new_packet(pkt, wc->blksize + WV_EXTRA_SIZE) < 0) + return AVERROR(ENOMEM); + memcpy(pkt->data, wc->extra, WV_EXTRA_SIZE); +- ret = get_buffer(&s->pb, pkt->data + WV_EXTRA_SIZE, wc->blksize); ++ ret = get_buffer(s->pb, pkt->data + WV_EXTRA_SIZE, wc->blksize); + if(ret != wc->blksize){ + av_free_packet(pkt); + return AVERROR(EIO); +@@ -204,18 +204,18 @@ + /* if found, seek there */ + if (index >= 0){ + wc->block_parsed = 1; +- url_fseek(&s->pb, st->index_entries[index].pos, SEEK_SET); ++ url_fseek(s->pb, st->index_entries[index].pos, SEEK_SET); + return 0; + } + /* if timestamp is out of bounds, return error */ + if(timestamp < 0 || timestamp >= s->duration) + return -1; + +- pos = url_ftell(&s->pb); ++ pos = url_ftell(s->pb); + do{ + ret = av_read_frame(s, pkt); + if (ret < 0){ +- url_fseek(&s->pb, pos, SEEK_SET); ++ url_fseek(s->pb, pos, SEEK_SET); + return -1; + } + pts = pkt->pts; +Only in mplayer-1.0~rc2-12/libavformat: x11grab.c +diff -u mplayer-1.0~rc2-12/libavformat/yuv4mpeg.c ffmpeg-free-0.svn20080206/libavformat/yuv4mpeg.c +--- mplayer-1.0~rc2-12/libavformat/yuv4mpeg.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavformat/yuv4mpeg.c 2007-11-21 08:41:00.000000000 +0100 +@@ -87,7 +87,7 @@ + static int yuv4_write_packet(AVFormatContext *s, AVPacket *pkt) + { + AVStream *st = s->streams[pkt->stream_index]; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + AVPicture *picture; + int* first_pkt = s->priv_data; + int width, height, h_chroma_shift, v_chroma_shift; +@@ -190,7 +190,7 @@ + char header[MAX_YUV4_HEADER+10]; // Include headroom for the longest option + char *tokstart,*tokend,*header_end; + int i; +- ByteIOContext *pb = &s->pb; ++ ByteIOContext *pb = s->pb; + int width=-1, height=-1, raten=0, rated=0, aspectn=0, aspectd=0; + enum PixelFormat pix_fmt=PIX_FMT_NONE,alt_pix_fmt=PIX_FMT_NONE; + AVStream *st; +@@ -344,7 +344,7 @@ + struct frame_attributes *s1 = s->priv_data; + + for (i=0; ipb); ++ header[i] = get_byte(s->pb); + if (header[i] == '\n') { + header[i+1] = 0; + break; +@@ -360,7 +360,7 @@ + if (packet_size < 0) + return -1; + +- if (av_get_packet(&s->pb, pkt, packet_size) != packet_size) ++ if (av_get_packet(s->pb, pkt, packet_size) != packet_size) + return AVERROR(EIO); + + if (s->streams[0]->codec->coded_frame) { +diff -u mplayer-1.0~rc2-12/libavutil/adler32.c ffmpeg-free-0.svn20080206/libavutil/adler32.c +--- mplayer-1.0~rc2-12/libavutil/adler32.c 2007-10-07 21:49:34.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavutil/adler32.c 2008-01-10 11:35:37.000000000 +0100 +@@ -54,7 +54,7 @@ + #include "log.h" + #define LEN 7001 + volatile int checksum; +-int main(){ ++int main(void){ + int i; + char data[LEN]; + av_log_level = AV_LOG_DEBUG; +@@ -66,5 +66,6 @@ + STOP_TIMER("adler") + } + av_log(NULL, AV_LOG_DEBUG, "%X == 50E6E508\n", checksum); ++ return 0; + } + #endif +diff -u mplayer-1.0~rc2-12/libavutil/adler32.h ffmpeg-free-0.svn20080206/libavutil/adler32.h +--- mplayer-1.0~rc2-12/libavutil/adler32.h 2007-10-07 21:49:34.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavutil/adler32.h 2007-10-17 11:37:46.000000000 +0200 +@@ -18,12 +18,12 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef ADLER32_H +-#define ADLER32_H ++#ifndef FFMPEG_ADLER32_H ++#define FFMPEG_ADLER32_H + + #include + + unsigned long av_adler32_update(unsigned long adler, const uint8_t *buf, + unsigned int len); + +-#endif ++#endif /* FFMPEG_ADLER32_H */ +diff -u mplayer-1.0~rc2-12/libavutil/aes.c ffmpeg-free-0.svn20080206/libavutil/aes.c +--- mplayer-1.0~rc2-12/libavutil/aes.c 2007-10-07 21:49:34.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavutil/aes.c 2008-01-08 23:40:25.000000000 +0100 +@@ -194,7 +194,9 @@ + #ifdef TEST + #include "log.h" + +-int main(){ ++#undef random ++ ++int main(void){ + int i,j; + AVAES ae, ad, b; + uint8_t rkey[2][16]= { +diff -u mplayer-1.0~rc2-12/libavutil/aes.h ffmpeg-free-0.svn20080206/libavutil/aes.h +--- mplayer-1.0~rc2-12/libavutil/aes.h 2007-10-07 21:49:34.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavutil/aes.h 2007-10-17 11:37:46.000000000 +0200 +@@ -18,8 +18,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef AES_H +-#define AES_H ++#ifndef FFMPEG_AES_H ++#define FFMPEG_AES_H + + #include + +@@ -44,4 +44,4 @@ + */ + void av_aes_crypt(struct AVAES *a, uint8_t *dst, uint8_t *src, int count, uint8_t *iv, int decrypt); + +-#endif /* AES_H */ ++#endif /* FFMPEG_AES_H */ +diff -u mplayer-1.0~rc2-12/libavutil/avstring.h ffmpeg-free-0.svn20080206/libavutil/avstring.h +--- mplayer-1.0~rc2-12/libavutil/avstring.h 2007-10-07 21:49:34.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavutil/avstring.h 2007-10-17 11:37:46.000000000 +0200 +@@ -18,8 +18,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef AVUTIL_STRING_H +-#define AVUTIL_STRING_H ++#ifndef FFMPEG_AVSTRING_H ++#define FFMPEG_AVSTRING_H + + #include + +@@ -87,4 +87,4 @@ + */ + size_t av_strlcatf(char *dst, size_t size, const char *fmt, ...); + +-#endif /* AVUTIL_STRING_H */ ++#endif /* FFMPEG_AVSTRING_H */ +diff -u mplayer-1.0~rc2-12/libavutil/avutil.h ffmpeg-free-0.svn20080206/libavutil/avutil.h +--- mplayer-1.0~rc2-12/libavutil/avutil.h 2007-10-07 21:49:34.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavutil/avutil.h 2008-01-28 18:23:57.000000000 +0100 +@@ -18,8 +18,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef AVUTIL_H +-#define AVUTIL_H ++#ifndef FFMPEG_AVUTIL_H ++#define FFMPEG_AVUTIL_H + + /** + * @file avutil.h +@@ -30,8 +30,8 @@ + #define AV_STRINGIFY(s) AV_TOSTRING(s) + #define AV_TOSTRING(s) #s + +-#define LIBAVUTIL_VERSION_INT ((49<<16)+(5<<8)+0) +-#define LIBAVUTIL_VERSION 49.5.0 ++#define LIBAVUTIL_VERSION_INT ((49<<16)+(6<<8)+0) ++#define LIBAVUTIL_VERSION 49.6.0 + #define LIBAVUTIL_BUILD LIBAVUTIL_VERSION_INT + + #define LIBAVUTIL_IDENT "Lavu" AV_STRINGIFY(LIBAVUTIL_VERSION) +@@ -40,7 +40,6 @@ + #include "common.h" + #include "mathematics.h" + #include "rational.h" +-#include "integer.h" + #include "intfloat_readwrite.h" + #include "log.h" + +@@ -129,4 +128,4 @@ + #define PIX_FMT_YUV422 PIX_FMT_YUYV422 + #endif + +-#endif /* AVUTIL_H */ ++#endif /* FFMPEG_AVUTIL_H */ +diff -u mplayer-1.0~rc2-12/libavutil/base64.c ffmpeg-free-0.svn20080206/libavutil/base64.c +--- mplayer-1.0~rc2-12/libavutil/base64.c 2007-10-07 21:49:34.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavutil/base64.c 2008-01-14 23:10:19.000000000 +0100 +@@ -29,7 +29,7 @@ + #include "base64.h" + + /* ---------------- private code */ +-static uint8_t map2[] = ++static const uint8_t map2[] = + { + 0x3e, 0xff, 0xff, 0xff, 0x3f, 0x34, 0x35, 0x36, + 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0xff, +@@ -70,7 +70,7 @@ + * fixed edge cases and made it work from data (vs. strings) by ryan. + *****************************************************************************/ + +-char *av_base64_encode(char * buf, int buf_len, uint8_t * src, int len) ++char *av_base64_encode(char * buf, int buf_len, const uint8_t * src, int len) + { + static const char b64[] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; +@@ -83,20 +83,18 @@ + buf_len < len * 4 / 3 + 12) + return NULL; + ret = dst = buf; +- if (len) { // special edge case, what should we really do here? +- while (bytes_remaining) { +- i_bits = (i_bits << 8) + *src++; +- bytes_remaining--; +- i_shift += 8; +- +- do { +- *dst++ = b64[(i_bits << 6 >> i_shift) & 0x3f]; +- i_shift -= 6; +- } while (i_shift > 6 || (bytes_remaining == 0 && i_shift > 0)); +- } +- while ((dst - ret) & 3) +- *dst++ = '='; ++ while (bytes_remaining) { ++ i_bits = (i_bits << 8) + *src++; ++ bytes_remaining--; ++ i_shift += 8; ++ ++ do { ++ *dst++ = b64[(i_bits << 6 >> i_shift) & 0x3f]; ++ i_shift -= 6; ++ } while (i_shift > 6 || (bytes_remaining == 0 && i_shift > 0)); + } ++ while ((dst - ret) & 3) ++ *dst++ = '='; + *dst = '\0'; + + return ret; +diff -u mplayer-1.0~rc2-12/libavutil/base64.h ffmpeg-free-0.svn20080206/libavutil/base64.h +--- mplayer-1.0~rc2-12/libavutil/base64.h 2007-10-07 21:49:34.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavutil/base64.h 2007-10-30 16:32:52.000000000 +0100 +@@ -19,8 +19,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef AVUTIL_BASE64_H +-#define AVUTIL_BASE64_H ++#ifndef FFMPEG_BASE64_H ++#define FFMPEG_BASE64_H + + #include + +@@ -35,6 +35,6 @@ + * @param src data, not a string + * @param buf output string + */ +-char *av_base64_encode(char * buf, int buf_len, uint8_t * src, int len); ++char *av_base64_encode(char * buf, int buf_len, const uint8_t * src, int len); + +-#endif // AVUTIL_BASE64_H ++#endif /* FFMPEG_BASE64_H */ +diff -u mplayer-1.0~rc2-12/libavutil/bswap.h ffmpeg-free-0.svn20080206/libavutil/bswap.h +--- mplayer-1.0~rc2-12/libavutil/bswap.h 2007-10-07 21:49:34.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavutil/bswap.h 2007-10-17 11:37:46.000000000 +0200 +@@ -23,8 +23,8 @@ + * byte swap. + */ + +-#ifndef BSWAP_H +-#define BSWAP_H ++#ifndef FFMPEG_BSWAP_H ++#define FFMPEG_BSWAP_H + + #include + #include "common.h" +@@ -138,4 +138,4 @@ + #define le2me_64(x) (x) + #endif + +-#endif /* BSWAP_H */ ++#endif /* FFMPEG_BSWAP_H */ +diff -u mplayer-1.0~rc2-12/libavutil/common.h ffmpeg-free-0.svn20080206/libavutil/common.h +--- mplayer-1.0~rc2-12/libavutil/common.h 2007-10-07 21:49:34.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavutil/common.h 2008-02-01 02:33:49.000000000 +0100 +@@ -23,8 +23,8 @@ + * common internal and external api header. + */ + +-#ifndef COMMON_H +-#define COMMON_H ++#ifndef FFMPEG_COMMON_H ++#define FFMPEG_COMMON_H + + #include + +@@ -96,9 +96,7 @@ + + static inline int av_log2(unsigned int v) + { +- int n; +- +- n = 0; ++ int n = 0; + if (v & 0xffff0000) { + v >>= 16; + n += 16; +@@ -114,9 +112,7 @@ + + static inline int av_log2_16bit(unsigned int v) + { +- int n; +- +- n = 0; ++ int n = 0; + if (v & 0xff00) { + v >>= 8; + n += 8; +@@ -366,4 +362,4 @@ + #define STOP_TIMER(id) {} + #endif + +-#endif /* COMMON_H */ ++#endif /* FFMPEG_COMMON_H */ +diff -u mplayer-1.0~rc2-12/libavutil/crc.c ffmpeg-free-0.svn20080206/libavutil/crc.c +--- mplayer-1.0~rc2-12/libavutil/crc.c 2007-10-07 21:49:34.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavutil/crc.c 2008-02-01 02:33:16.000000000 +0100 +@@ -21,16 +21,21 @@ + #include "common.h" + #include "crc.h" + +-#if LIBAVUTIL_VERSION_INT < (50<<16) +-AVCRC *av_crcEDB88320; +-AVCRC *av_crc04C11DB7; +-AVCRC *av_crc8005 ; +-AVCRC *av_crc07 ; ++#ifdef CONFIG_HARDCODED_TABLES ++#include "crc_data.h" + #else +-AVCRC av_crcEDB88320[257]; +-AVCRC av_crc04C11DB7[257]; +-AVCRC av_crc8005 [257]; +-AVCRC av_crc07 [257]; ++static struct { ++ uint8_t le; ++ uint8_t bits; ++ uint32_t poly; ++} av_crc_table_params[AV_CRC_MAX] = { ++ [AV_CRC_8_ATM] = { 0, 8, 0x07 }, ++ [AV_CRC_16_ANSI] = { 0, 16, 0x8005 }, ++ [AV_CRC_16_CCITT] = { 0, 16, 0x1021 }, ++ [AV_CRC_32_IEEE] = { 0, 32, 0x04C11DB7 }, ++ [AV_CRC_32_IEEE_LE] = { 1, 32, 0xEDB88320 }, ++}; ++static AVCRC av_crc_table[AV_CRC_MAX][257]; + #endif + + /** +@@ -80,6 +85,24 @@ + } + + /** ++ * Get an initialized standard CRC table. ++ * @param crc_id ID of a standard CRC ++ * @return a pointer to the CRC table or NULL on failure ++ */ ++const AVCRC *av_crc_get_table(AVCRCId crc_id){ ++#ifndef CONFIG_HARDCODED_TABLES ++ if (!av_crc_table[crc_id][sizeof(av_crc_table[crc_id])/sizeof(av_crc_table[crc_id][0])-1]) ++ if (av_crc_init(av_crc_table[crc_id], ++ av_crc_table_params[crc_id].le, ++ av_crc_table_params[crc_id].bits, ++ av_crc_table_params[crc_id].poly, ++ sizeof(av_crc_table[crc_id])) < 0) ++ return NULL; ++#endif ++ return av_crc_table[crc_id]; ++} ++ ++/** + * Calculate the CRC of a block + * @param crc CRC of previous blocks if any or initial value for CRC. + * @return CRC updated with the data from the given block +@@ -92,7 +115,7 @@ + #ifndef CONFIG_SMALL + if(!ctx[256]) + while(buffer>8 )&0xFF)] + ^ctx[1*256 + ((crc>>16)&0xFF)] +@@ -107,21 +130,22 @@ + + #ifdef TEST + #undef printf +-main(){ ++int main(void){ + uint8_t buf[1999]; + int i; +- int p[4][4]={{1, 32, AV_CRC_32_IEEE_LE, 0x3D5CDD04}, +- {0, 32, AV_CRC_32_IEEE , 0xC0F5BAE0}, +- {0, 16, AV_CRC_16 , 0x1FBB }, +- {0, 8, AV_CRC_8_ATM , 0xE3 },}; +- AVCRC ctx[1 ? 1024:257]; ++ int p[4][3]={{AV_CRC_32_IEEE_LE, 0xEDB88320, 0x3D5CDD04}, ++ {AV_CRC_32_IEEE , 0x04C11DB7, 0xC0F5BAE0}, ++ {AV_CRC_16_ANSI , 0x8005, 0x1FBB }, ++ {AV_CRC_8_ATM , 0x07, 0xE3 },}; ++ const AVCRC *ctx; + + for(i=0; i + #include + + typedef uint32_t AVCRC; + +-#define AV_CRC_8_ATM 0x07 +-#define AV_CRC_16 0x8005 +-#define AV_CRC_16_CCITT 0x1021 +-#define AV_CRC_32_IEEE 0x04C11DB7L +-//! reversed bitorder version of AV_CRC_32_IEEE +-#define AV_CRC_32_IEEE_LE 0xEDB88320L +- +-#if LIBAVUTIL_VERSION_INT < (50<<16) +-extern AVCRC *av_crcEDB88320; +-extern AVCRC *av_crc04C11DB7; +-extern AVCRC *av_crc8005 ; +-extern AVCRC *av_crc07 ; +-#else +-extern AVCRC av_crcEDB88320[]; +-extern AVCRC av_crc04C11DB7[]; +-extern AVCRC av_crc8005 []; +-extern AVCRC av_crc07 []; +-#endif ++typedef enum { ++ AV_CRC_8_ATM, ++ AV_CRC_16_ANSI, ++ AV_CRC_16_CCITT, ++ AV_CRC_32_IEEE, ++ AV_CRC_32_IEEE_LE, /*< reversed bitorder version of AV_CRC_32_IEEE */ ++ AV_CRC_MAX, /*< not part of public API! don't use outside lavu */ ++}AVCRCId; + + int av_crc_init(AVCRC *ctx, int le, int bits, uint32_t poly, int ctx_size); ++const AVCRC *av_crc_get_table(AVCRCId crc_id); + uint32_t av_crc(const AVCRC *ctx, uint32_t start_crc, const uint8_t *buffer, size_t length); + +-#endif /* CRC_H */ ++#endif /* FFMPEG_CRC_H */ + +Only in ffmpeg-free-0.svn20080206/libavutil: des.c +Only in ffmpeg-free-0.svn20080206/libavutil: des.h +diff -u mplayer-1.0~rc2-12/libavutil/fifo.h ffmpeg-free-0.svn20080206/libavutil/fifo.h +--- mplayer-1.0~rc2-12/libavutil/fifo.h 2007-10-07 21:49:34.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavutil/fifo.h 2007-10-17 11:37:46.000000000 +0200 +@@ -21,8 +21,8 @@ + * A very simple circular buffer FIFO implementation. + */ + +-#ifndef FIFO_H +-#define FIFO_H ++#ifndef FFMPEG_FIFO_H ++#define FFMPEG_FIFO_H + + #include + +@@ -99,4 +99,4 @@ + ptr -= f->end - f->buffer; + return *ptr; + } +-#endif /* FIFO_H */ ++#endif /* FFMPEG_FIFO_H */ +diff -u mplayer-1.0~rc2-12/libavutil/integer.c ffmpeg-free-0.svn20080206/libavutil/integer.c +--- mplayer-1.0~rc2-12/libavutil/integer.c 2007-10-07 21:49:34.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavutil/integer.c 2008-01-10 11:35:37.000000000 +0100 +@@ -156,7 +156,7 @@ + return out; + } + +-#if 0 ++#ifdef TEST + #undef NDEBUG + #include + +@@ -171,7 +171,7 @@ + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7 + }; + +-main(){ ++int main(void){ + int64_t a,b; + + for(a=7; a<256*256*256; a+=13215){ +@@ -192,5 +192,6 @@ + assert(av_i2int(av_div_i(ai,bi)) == a/b); + } + } ++ return 0; + } + #endif +diff -u mplayer-1.0~rc2-12/libavutil/integer.h ffmpeg-free-0.svn20080206/libavutil/integer.h +--- mplayer-1.0~rc2-12/libavutil/integer.h 2007-10-07 21:49:34.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavutil/integer.h 2007-10-17 11:37:46.000000000 +0200 +@@ -25,8 +25,8 @@ + * @author Michael Niedermayer + */ + +-#ifndef INTEGER_H +-#define INTEGER_H ++#ifndef FFMPEG_INTEGER_H ++#define FFMPEG_INTEGER_H + + #include + +@@ -80,4 +80,4 @@ + */ + int64_t av_i2int(AVInteger a); + +-#endif // INTEGER_H ++#endif /* FFMPEG_INTEGER_H */ +diff -u mplayer-1.0~rc2-12/libavutil/internal.h ffmpeg-free-0.svn20080206/libavutil/internal.h +--- mplayer-1.0~rc2-12/libavutil/internal.h 2007-10-07 21:49:34.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavutil/internal.h 2008-01-21 14:33:18.000000000 +0100 +@@ -23,8 +23,8 @@ + * common internal api header. + */ + +-#ifndef INTERNAL_H +-#define INTERNAL_H ++#ifndef FFMPEG_INTERNAL_H ++#define FFMPEG_INTERNAL_H + + #if !defined(DEBUG) && !defined(NDEBUG) + # define NDEBUG +@@ -118,7 +118,7 @@ + #endif + + // Use rip-relative addressing if compiling PIC code on x86-64. +-#if defined(__MINGW32__) || defined(__CYGWIN__) || \ ++#if defined(__MINGW32__) || defined(__CYGWIN__) || defined(__DJGPP__) || \ + defined(__OS2__) || (defined (__OpenBSD__) && !defined(__ELF__)) + # if defined(ARCH_X86_64) && defined(PIC) + # define MANGLE(a) "_" #a"(%%rip)" +@@ -178,24 +178,28 @@ + # define FASTDIV(a,b) ((a)/(b)) + #endif + +-extern const uint8_t ff_sqrt_tab[128]; ++extern const uint8_t ff_sqrt_tab[256]; + +-static inline int ff_sqrt(int a) +-{ +- int ret=0; +- int s, b; ++static inline int av_log2_16bit(unsigned int v); + +- if(a<128) return ff_sqrt_tab[a]; ++static inline unsigned int ff_sqrt(unsigned int a) ++{ ++ unsigned int b; + +- for(s=30; s>=0; s-=2){ +- ret+=ret; +- b= (1+2*ret)<>4; ++ else if(a<(1<<12)) b= ff_sqrt_tab[a>>4 ]>>2; ++#ifndef CONFIG_SMALL ++ else if(a<(1<<14)) b= ff_sqrt_tab[a>>6 ]>>1; ++ else if(a<(1<<16)) b= ff_sqrt_tab[a>>8 ] ; ++#endif ++ else{ ++ int s= av_log2_16bit(a>>16)>>1; ++ unsigned int c= a>>(s+2); ++ b= ff_sqrt_tab[c>>(s+8)]; ++ b= FASTDIV(c,b) + (b< 0) ? floor(x + 0.5) : ceil(x - 0.5); ++} ++#endif /* HAVE_ROUND */ ++ ++#ifndef HAVE_ROUNDF ++static av_always_inline float roundf(float x) ++{ ++ return (x > 0) ? floor(x + 0.5) : ceil(x - 0.5); ++} ++#endif /* HAVE_ROUNDF */ ++ ++#endif /* FFMPEG_INTERNAL_H */ +diff -u mplayer-1.0~rc2-12/libavutil/intfloat_readwrite.h ffmpeg-free-0.svn20080206/libavutil/intfloat_readwrite.h +--- mplayer-1.0~rc2-12/libavutil/intfloat_readwrite.h 2007-10-07 21:49:34.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavutil/intfloat_readwrite.h 2007-10-17 11:37:46.000000000 +0200 +@@ -18,8 +18,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef INTFLOAT_READWRITE_H +-#define INTFLOAT_READWRITE_H ++#ifndef FFMPEG_INTFLOAT_READWRITE_H ++#define FFMPEG_INTFLOAT_READWRITE_H + + #include "common.h" + +@@ -36,4 +36,4 @@ + int32_t av_flt2int(float d); + AVExtFloat av_dbl2ext(double d); + +-#endif /* INTFLOAT_READWRITE_H */ ++#endif /* FFMPEG_INTFLOAT_READWRITE_H */ +diff -u mplayer-1.0~rc2-12/libavutil/intreadwrite.h ffmpeg-free-0.svn20080206/libavutil/intreadwrite.h +--- mplayer-1.0~rc2-12/libavutil/intreadwrite.h 2007-10-07 21:49:34.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavutil/intreadwrite.h 2008-02-01 04:14:50.000000000 +0100 +@@ -16,8 +16,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef INTREADWRITE_H +-#define INTREADWRITE_H ++#ifndef FFMPEG_INTREADWRITE_H ++#define FFMPEG_INTREADWRITE_H + + #include + #include "bswap.h" +@@ -38,9 +38,9 @@ + + #else /* __GNUC__ */ + +-#define AV_RN16(a) (*((uint16_t*)(a))) +-#define AV_RN32(a) (*((uint32_t*)(a))) +-#define AV_RN64(a) (*((uint64_t*)(a))) ++#define AV_RN16(a) (*((const uint16_t*)(a))) ++#define AV_RN32(a) (*((const uint32_t*)(a))) ++#define AV_RN64(a) (*((const uint64_t*)(a))) + + #define AV_WN16(a, b) *((uint16_t*)(a)) = (b) + #define AV_WN32(a, b) *((uint32_t*)(a)) = (b) +@@ -49,7 +49,7 @@ + #endif /* !__GNUC__ */ + + /* endian macros */ +-#define AV_RB8(x) (((uint8_t*)(x))[0]) ++#define AV_RB8(x) (((const uint8_t*)(x))[0]) + #define AV_WB8(p, d) do { ((uint8_t*)(p))[0] = (d); } while(0) + + #define AV_RL8(x) AV_RB8(x) +@@ -70,29 +70,29 @@ + # define AV_WL16(p, d) AV_WN16(p, d) + # endif + #else /* HAVE_FAST_UNALIGNED */ +-#define AV_RB16(x) ((((uint8_t*)(x))[0] << 8) | ((uint8_t*)(x))[1]) ++#define AV_RB16(x) ((((const uint8_t*)(x))[0] << 8) | ((const uint8_t*)(x))[1]) + #define AV_WB16(p, d) do { \ + ((uint8_t*)(p))[1] = (d); \ + ((uint8_t*)(p))[0] = (d)>>8; } while(0) + +-#define AV_RL16(x) ((((uint8_t*)(x))[1] << 8) | \ +- ((uint8_t*)(x))[0]) ++#define AV_RL16(x) ((((const uint8_t*)(x))[1] << 8) | \ ++ ((const uint8_t*)(x))[0]) + #define AV_WL16(p, d) do { \ + ((uint8_t*)(p))[0] = (d); \ + ((uint8_t*)(p))[1] = (d)>>8; } while(0) + #endif + +-#define AV_RB24(x) ((((uint8_t*)(x))[0] << 16) | \ +- (((uint8_t*)(x))[1] << 8) | \ +- ((uint8_t*)(x))[2]) ++#define AV_RB24(x) ((((const uint8_t*)(x))[0] << 16) | \ ++ (((const uint8_t*)(x))[1] << 8) | \ ++ ((const uint8_t*)(x))[2]) + #define AV_WB24(p, d) do { \ + ((uint8_t*)(p))[2] = (d); \ + ((uint8_t*)(p))[1] = (d)>>8; \ + ((uint8_t*)(p))[0] = (d)>>16; } while(0) + +-#define AV_RL24(x) ((((uint8_t*)(x))[2] << 16) | \ +- (((uint8_t*)(x))[1] << 8) | \ +- ((uint8_t*)(x))[0]) ++#define AV_RL24(x) ((((const uint8_t*)(x))[2] << 16) | \ ++ (((const uint8_t*)(x))[1] << 8) | \ ++ ((const uint8_t*)(x))[0]) + #define AV_WL24(p, d) do { \ + ((uint8_t*)(p))[0] = (d); \ + ((uint8_t*)(p))[1] = (d)>>8; \ +@@ -113,20 +113,20 @@ + # define AV_WL32(p, d) AV_WN32(p, d) + # endif + #else /* HAVE_FAST_UNALIGNED */ +-#define AV_RB32(x) ((((uint8_t*)(x))[0] << 24) | \ +- (((uint8_t*)(x))[1] << 16) | \ +- (((uint8_t*)(x))[2] << 8) | \ +- ((uint8_t*)(x))[3]) ++#define AV_RB32(x) ((((const uint8_t*)(x))[0] << 24) | \ ++ (((const uint8_t*)(x))[1] << 16) | \ ++ (((const uint8_t*)(x))[2] << 8) | \ ++ ((const uint8_t*)(x))[3]) + #define AV_WB32(p, d) do { \ + ((uint8_t*)(p))[3] = (d); \ + ((uint8_t*)(p))[2] = (d)>>8; \ + ((uint8_t*)(p))[1] = (d)>>16; \ + ((uint8_t*)(p))[0] = (d)>>24; } while(0) + +-#define AV_RL32(x) ((((uint8_t*)(x))[3] << 24) | \ +- (((uint8_t*)(x))[2] << 16) | \ +- (((uint8_t*)(x))[1] << 8) | \ +- ((uint8_t*)(x))[0]) ++#define AV_RL32(x) ((((const uint8_t*)(x))[3] << 24) | \ ++ (((const uint8_t*)(x))[2] << 16) | \ ++ (((const uint8_t*)(x))[1] << 8) | \ ++ ((const uint8_t*)(x))[0]) + #define AV_WL32(p, d) do { \ + ((uint8_t*)(p))[0] = (d); \ + ((uint8_t*)(p))[1] = (d)>>8; \ +@@ -149,14 +149,14 @@ + # define AV_WL64(p, d) AV_WN64(p, d) + # endif + #else /* HAVE_FAST_UNALIGNED */ +-#define AV_RB64(x) (((uint64_t)((uint8_t*)(x))[0] << 56) | \ +- ((uint64_t)((uint8_t*)(x))[1] << 48) | \ +- ((uint64_t)((uint8_t*)(x))[2] << 40) | \ +- ((uint64_t)((uint8_t*)(x))[3] << 32) | \ +- ((uint64_t)((uint8_t*)(x))[4] << 24) | \ +- ((uint64_t)((uint8_t*)(x))[5] << 16) | \ +- ((uint64_t)((uint8_t*)(x))[6] << 8) | \ +- (uint64_t)((uint8_t*)(x))[7]) ++#define AV_RB64(x) (((uint64_t)((const uint8_t*)(x))[0] << 56) | \ ++ ((uint64_t)((const uint8_t*)(x))[1] << 48) | \ ++ ((uint64_t)((const uint8_t*)(x))[2] << 40) | \ ++ ((uint64_t)((const uint8_t*)(x))[3] << 32) | \ ++ ((uint64_t)((const uint8_t*)(x))[4] << 24) | \ ++ ((uint64_t)((const uint8_t*)(x))[5] << 16) | \ ++ ((uint64_t)((const uint8_t*)(x))[6] << 8) | \ ++ (uint64_t)((const uint8_t*)(x))[7]) + #define AV_WB64(p, d) do { \ + ((uint8_t*)(p))[7] = (d); \ + ((uint8_t*)(p))[6] = (d)>>8; \ +@@ -167,14 +167,14 @@ + ((uint8_t*)(p))[1] = (d)>>48; \ + ((uint8_t*)(p))[0] = (d)>>56; } while(0) + +-#define AV_RL64(x) (((uint64_t)((uint8_t*)(x))[7] << 56) | \ +- ((uint64_t)((uint8_t*)(x))[6] << 48) | \ +- ((uint64_t)((uint8_t*)(x))[5] << 40) | \ +- ((uint64_t)((uint8_t*)(x))[4] << 32) | \ +- ((uint64_t)((uint8_t*)(x))[3] << 24) | \ +- ((uint64_t)((uint8_t*)(x))[2] << 16) | \ +- ((uint64_t)((uint8_t*)(x))[1] << 8) | \ +- (uint64_t)((uint8_t*)(x))[0]) ++#define AV_RL64(x) (((uint64_t)((const uint8_t*)(x))[7] << 56) | \ ++ ((uint64_t)((const uint8_t*)(x))[6] << 48) | \ ++ ((uint64_t)((const uint8_t*)(x))[5] << 40) | \ ++ ((uint64_t)((const uint8_t*)(x))[4] << 32) | \ ++ ((uint64_t)((const uint8_t*)(x))[3] << 24) | \ ++ ((uint64_t)((const uint8_t*)(x))[2] << 16) | \ ++ ((uint64_t)((const uint8_t*)(x))[1] << 8) | \ ++ (uint64_t)((const uint8_t*)(x))[0]) + #define AV_WL64(p, d) do { \ + ((uint8_t*)(p))[0] = (d); \ + ((uint8_t*)(p))[1] = (d)>>8; \ +@@ -186,4 +186,4 @@ + ((uint8_t*)(p))[7] = (d)>>56; } while(0) + #endif + +-#endif /* INTREADWRITE_H */ ++#endif /* FFMPEG_INTREADWRITE_H */ +diff -u mplayer-1.0~rc2-12/libavutil/lls.c ffmpeg-free-0.svn20080206/libavutil/lls.c +--- mplayer-1.0~rc2-12/libavutil/lls.c 2007-10-07 21:49:34.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavutil/lls.c 2008-01-31 21:52:14.000000000 +0100 +@@ -53,8 +53,8 @@ + + void av_solve_lls(LLSModel *m, double threshold, int min_order){ + int i,j,k; +- double (*factor)[MAX_VARS+1]= &m->covariance[1][0]; +- double (*covar )[MAX_VARS+1]= &m->covariance[1][1]; ++ double (*factor)[MAX_VARS+1]= (void*)&m->covariance[1][0]; ++ double (*covar )[MAX_VARS+1]= (void*)&m->covariance[1][1]; + double *covar_y = m->covariance[0]; + int count= m->indep_count; + +@@ -113,7 +113,7 @@ + #include + #include + +-int main(){ ++int main(void){ + LLSModel m; + int i, order; + +@@ -121,7 +121,7 @@ + + for(i=0; i<100; i++){ + double var[4]; +- double eval, variance; ++ double eval; + #if 0 + var[1] = rand() / (double)RAND_MAX; + var[2] = rand() / (double)RAND_MAX; +diff -u mplayer-1.0~rc2-12/libavutil/lls.h ffmpeg-free-0.svn20080206/libavutil/lls.h +--- mplayer-1.0~rc2-12/libavutil/lls.h 2007-10-07 21:49:34.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavutil/lls.h 2007-10-17 11:37:46.000000000 +0200 +@@ -20,8 +20,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef LLS_H +-#define LLS_H ++#ifndef FFMPEG_LLS_H ++#define FFMPEG_LLS_H + + #define MAX_VARS 32 + +@@ -42,4 +42,4 @@ + void av_solve_lls(LLSModel *m, double threshold, int min_order); + double av_evaluate_lls(LLSModel *m, double *param, int order); + +-#endif ++#endif /* FFMPEG_LLS_H */ +diff -u mplayer-1.0~rc2-12/libavutil/log.c ffmpeg-free-0.svn20080206/libavutil/log.c +--- mplayer-1.0~rc2-12/libavutil/log.c 2007-10-07 21:49:34.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavutil/log.c 2007-12-12 22:48:50.000000000 +0100 +@@ -45,11 +45,7 @@ + vfprintf(stderr, fmt, vl); + } + +-#if LIBAVUTIL_VERSION_INT < (50<<16) + static void (*av_log_callback)(void*, int, const char*, va_list) = av_log_default_callback; +-#else +-void (*av_vlog)(void*, int, const char*, va_list) = av_log_default_callback; +-#endif + + void av_log(void* avcl, int level, const char *fmt, ...) + { +@@ -59,7 +55,6 @@ + va_end(vl); + } + +-#if LIBAVUTIL_VERSION_INT < (50<<16) + void av_vlog(void* avcl, int level, const char *fmt, va_list vl) + { + av_log_callback(avcl, level, fmt, vl); +@@ -79,4 +74,3 @@ + { + av_log_callback = callback; + } +-#endif +diff -u mplayer-1.0~rc2-12/libavutil/log.h ffmpeg-free-0.svn20080206/libavutil/log.h +--- mplayer-1.0~rc2-12/libavutil/log.h 2007-10-07 21:49:34.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavutil/log.h 2007-12-12 22:48:50.000000000 +0100 +@@ -18,8 +18,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef LOG_H +-#define LOG_H ++#ifndef FFMPEG_LOG_H ++#define FFMPEG_LOG_H + + #include + +@@ -81,7 +81,10 @@ + */ + #define AV_LOG_DEBUG 48 + #endif ++ ++#if LIBAVUTIL_VERSION_INT < (50<<16) + extern int av_log_level; ++#endif + + /** + * Send the specified message to the log if the level is less than or equal to +@@ -103,14 +106,10 @@ + extern void av_log(void*, int level, const char *fmt, ...); + #endif + +-#if LIBAVUTIL_VERSION_INT < (50<<16) + extern void av_vlog(void*, int level, const char *fmt, va_list); + extern int av_log_get_level(void); + extern void av_log_set_level(int); + extern void av_log_set_callback(void (*)(void*, int, const char*, va_list)); + extern void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl); +-#else +-extern void (*av_vlog)(void*, int, const char*, va_list); +-#endif + +-#endif /* LOG_H */ ++#endif /* FFMPEG_LOG_H */ +diff -u mplayer-1.0~rc2-12/libavutil/lzo.c ffmpeg-free-0.svn20080206/libavutil/lzo.c +--- mplayer-1.0~rc2-12/libavutil/lzo.c 2007-10-07 21:49:34.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavutil/lzo.c 2008-02-01 17:30:51.000000000 +0100 +@@ -29,7 +29,7 @@ + //! define if we may read up to 8 bytes beyond the input buffer + #define INBUF_PADDED 1 + typedef struct LZOContext { +- uint8_t *in, *in_end; ++ const uint8_t *in, *in_end; + uint8_t *out_start, *out, *out_end; + int error; + } LZOContext; +@@ -84,7 +84,7 @@ + * \param cnt number of bytes to copy, must be >= 0 + */ + static inline void copy(LZOContext *c, int cnt) { +- register uint8_t *src = c->in; ++ register const uint8_t *src = c->in; + register uint8_t *dst = c->out; + if (cnt > c->in_end - src) { + cnt = FFMAX(c->in_end - src, 0); +@@ -115,7 +115,7 @@ + * thus creating a repeating pattern with a period length of back. + */ + static inline void copy_backptr(LZOContext *c, int back, int cnt) { +- register uint8_t *src = &c->out[-back]; ++ register const uint8_t *src = &c->out[-back]; + register uint8_t *dst = c->out; + if (src < c->out_start || src > dst) { + c->error |= LZO_INVALID_BACKPTR; +@@ -171,12 +171,12 @@ + * make sure all buffers are appropriately padded, in must provide + * LZO_INPUT_PADDING, out must provide LZO_OUTPUT_PADDING additional bytes + */ +-int lzo1x_decode(void *out, int *outlen, void *in, int *inlen) { ++int lzo1x_decode(void *out, int *outlen, const void *in, int *inlen) { + int state= 0; + int x; + LZOContext c; + c.in = in; +- c.in_end = (uint8_t *)in + *inlen; ++ c.in_end = (const uint8_t *)in + *inlen; + c.out = c.out_start = out; + c.out_end = (uint8_t *)out + * outlen; + c.error = 0; +diff -u mplayer-1.0~rc2-12/libavutil/lzo.h ffmpeg-free-0.svn20080206/libavutil/lzo.h +--- mplayer-1.0~rc2-12/libavutil/lzo.h 2007-10-07 21:49:34.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavutil/lzo.h 2008-02-01 17:30:51.000000000 +0100 +@@ -19,8 +19,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef LZO_H +-#define LZO_H ++#ifndef FFMPEG_LZO_H ++#define FFMPEG_LZO_H + + #define LZO_INPUT_DEPLETED 1 + #define LZO_OUTPUT_FULL 2 +@@ -30,6 +30,6 @@ + #define LZO_INPUT_PADDING 8 + #define LZO_OUTPUT_PADDING 12 + +-int lzo1x_decode(void *out, int *outlen, void *in, int *inlen); ++int lzo1x_decode(void *out, int *outlen, const void *in, int *inlen); + +-#endif ++#endif /* FFMPEG_LZO_H */ +diff -u mplayer-1.0~rc2-12/libavutil/Makefile ffmpeg-free-0.svn20080206/libavutil/Makefile +--- mplayer-1.0~rc2-12/libavutil/Makefile 2007-10-07 21:49:34.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavutil/Makefile 2008-01-28 00:28:56.000000000 +0100 +@@ -4,8 +4,9 @@ + aes.o \ + base64.o \ + crc.o \ +- intfloat_readwrite.o \ ++ des.o \ + fifo.o \ ++ intfloat_readwrite.o \ + lls.o \ + log.o \ + lzo.o \ +@@ -14,6 +15,8 @@ + mem.o \ + random.o \ + rational.o \ ++ rc4.o \ ++ sha1.o \ + string.o \ + tree.o \ + +@@ -22,8 +25,8 @@ + avutil.h \ + base64.h \ + common.h \ ++ crc.h \ + fifo.h \ +- integer.h \ + intfloat_readwrite.h \ + log.h \ + lzo.h \ +@@ -32,9 +35,18 @@ + mem.h \ + random.h \ + rational.h \ ++ sha1.h + + NAME=avutil + LIBVERSION=$(LAVUVERSION) + LIBMAJOR=$(LAVUMAJOR) + ++TESTS = $(addsuffix -test$(EXESUF), adler32 aes crc des lls md5 sha1 softfloat tree) ++ + include ../common.mak ++ ++lzo-test$(EXESUF): lzo.c $(LIBNAME) ++ $(CC) $(CFLAGS) $(LDFLAGS) -DTEST -o $@ $^ $(EXTRALIBS) -llzo2 ++ ++clean:: ++ rm -f lzo-test$(EXESUF) +diff -u mplayer-1.0~rc2-12/libavutil/mathematics.c ffmpeg-free-0.svn20080206/libavutil/mathematics.c +--- mplayer-1.0~rc2-12/libavutil/mathematics.c 2007-10-07 21:49:34.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavutil/mathematics.c 2008-01-21 14:33:18.000000000 +0100 +@@ -26,11 +26,15 @@ + #include "common.h" + #include "mathematics.h" + +-const uint8_t ff_sqrt_tab[128]={ +- 0, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, +- 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, +- 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, +- 9, 9, 9, 9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11 ++const uint8_t ff_sqrt_tab[256]={ ++ 0, 16, 23, 28, 32, 36, 40, 43, 46, 48, 51, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 77, 79, 80, 82, 84, 85, 87, 88, 90, ++ 91, 92, 94, 95, 96, 98, 99,100,102,103,104,105,107,108,109,110,111,112,114,115,116,117,118,119,120,121,122,123,124,125,126,127, ++128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,144,145,146,147,148,149,150,151,151,152,153,154,155,156,156, ++157,158,159,160,160,161,162,163,164,164,165,166,167,168,168,169,170,171,171,172,173,174,174,175,176,176,177,178,179,179,180,181, ++182,182,183,184,184,185,186,186,187,188,188,189,190,190,191,192,192,193,194,194,195,196,196,197,198,198,199,200,200,201,202,202, ++203,204,204,205,205,206,207,207,208,208,209,210,210,211,212,212,213,213,214,215,215,216,216,217,218,218,219,219,220,220,221,222, ++222,223,223,224,224,225,226,226,227,227,228,228,229,230,230,231,231,232,232,233,233,234,235,235,236,236,237,237,238,238,239,239, ++240,240,241,242,242,243,243,244,244,245,245,246,246,247,247,248,248,249,249,250,250,251,251,252,252,253,253,254,254,255,255,255 + }; + + const uint8_t ff_log2_tab[256]={ +@@ -110,10 +114,11 @@ + int64_t c= cq.num * (int64_t)bq.den; + return av_rescale_rnd(a, b, c, AV_ROUND_NEAR_INF); + } +-#if 0 ++ ++#ifdef TEST + #include "integer.h" + #undef printf +-main(){ ++int main(void){ + int64_t a,b,c,d,e; + + for(a=7; a<(1LL<<62); a+=a/3+1){ +@@ -135,5 +140,6 @@ + } + } + } ++ return 0; + } + #endif +diff -u mplayer-1.0~rc2-12/libavutil/mathematics.h ffmpeg-free-0.svn20080206/libavutil/mathematics.h +--- mplayer-1.0~rc2-12/libavutil/mathematics.h 2007-10-07 21:49:34.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavutil/mathematics.h 2007-10-17 11:37:46.000000000 +0200 +@@ -18,8 +18,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef MATHEMATICS_H +-#define MATHEMATICS_H ++#ifndef FFMPEG_MATHEMATICS_H ++#define FFMPEG_MATHEMATICS_H + + #include "rational.h" + +@@ -48,4 +48,4 @@ + */ + int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq); + +-#endif /* MATHEMATICS_H */ ++#endif /* FFMPEG_MATHEMATICS_H */ +diff -u mplayer-1.0~rc2-12/libavutil/md5.c ffmpeg-free-0.svn20080206/libavutil/md5.c +--- mplayer-1.0~rc2-12/libavutil/md5.c 2007-10-07 21:49:34.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavutil/md5.c 2008-01-30 05:50:09.000000000 +0100 +@@ -147,7 +147,7 @@ + while((ctx->len & 63)<56) + av_md5_update(ctx, "", 1); + +- av_md5_update(ctx, &finalcount, 8); ++ av_md5_update(ctx, (uint8_t*)&finalcount, 8); + + for(i=0; i<4; i++) + ((uint32_t*)dst)[i]= le2me_32(ctx->ABCD[3-i]); +@@ -164,7 +164,7 @@ + #ifdef TEST + #include + #undef printf +-main(){ ++int main(void){ + uint64_t md5val; + int i; + uint8_t in[1000]; +@@ -176,5 +176,7 @@ + av_md5_sum( (uint8_t*)&md5val, in, 65); printf("%"PRId64"\n", md5val); + for(i=0; i<1000; i++) in[i]= i % 127; + av_md5_sum( (uint8_t*)&md5val, in, 999); printf("%"PRId64"\n", md5val); ++ ++ return 0; + } + #endif +diff -u mplayer-1.0~rc2-12/libavutil/md5.h ffmpeg-free-0.svn20080206/libavutil/md5.h +--- mplayer-1.0~rc2-12/libavutil/md5.h 2007-10-07 21:49:34.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavutil/md5.h 2007-10-17 11:37:46.000000000 +0200 +@@ -18,8 +18,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef MD5_H +-#define MD5_H ++#ifndef FFMPEG_MD5_H ++#define FFMPEG_MD5_H + + #include + +@@ -32,5 +32,5 @@ + void av_md5_final(struct AVMD5 *ctx, uint8_t *dst); + void av_md5_sum(uint8_t *dst, const uint8_t *src, const int len); + +-#endif /* MD5_H */ ++#endif /* FFMPEG_MD5_H */ + +diff -u mplayer-1.0~rc2-12/libavutil/mem.h ffmpeg-free-0.svn20080206/libavutil/mem.h +--- mplayer-1.0~rc2-12/libavutil/mem.h 2007-10-07 21:49:34.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavutil/mem.h 2008-01-27 21:50:16.000000000 +0100 +@@ -23,50 +23,77 @@ + * Memory handling functions. + */ + +-#ifndef AV_MEM_H +-#define AV_MEM_H ++#ifndef FFMPEG_MEM_H ++#define FFMPEG_MEM_H + + #ifdef __GNUC__ + #define DECLARE_ALIGNED(n,t,v) t v __attribute__ ((aligned (n))) ++ #define DECLARE_ASM_CONST(n,t,v) static const t v attribute_used __attribute__ ((aligned (n))) + #else + #define DECLARE_ALIGNED(n,t,v) __declspec(align(n)) t v ++ #define DECLARE_ASM_CONST(n,t,v) __declspec(align(n)) static const t v + #endif + + /** +- * Memory allocation of size byte with alignment suitable for all +- * memory accesses (including vectors if available on the +- * CPU). av_malloc(0) must return a non NULL pointer. ++ * Allocate a block of \p size bytes with alignment suitable for all ++ * memory accesses (including vectors if available on the CPU). ++ * @param size Size in bytes for the memory block to be allocated. ++ * @return Pointer to the allocated block, NULL if it cannot allocate ++ * it. ++ * @see av_mallocz() + */ + void *av_malloc(unsigned int size); + + /** +- * av_realloc semantics (same as glibc): if ptr is NULL and size > 0, +- * identical to malloc(size). If size is zero, it is identical to +- * free(ptr) and NULL is returned. ++ * Allocate or reallocate a block of memory. ++ * If \p ptr is NULL and \p size > 0, allocate a new block. If \p ++ * size is zero, free the memory block pointed by \p ptr. ++ * @param size Size in bytes for the memory block to be allocated or ++ * reallocated. ++ * @param ptr Pointer to a memory block already allocated with ++ * av_malloc(z)() or av_realloc() or NULL. ++ * @return Pointer to a newly reallocated block or NULL if it cannot ++ * reallocate or the function is used to free the memory block. ++ * @see av_fast_realloc() + */ + void *av_realloc(void *ptr, unsigned int size); + + /** +- * Free memory which has been allocated with av_malloc(z)() or av_realloc(). +- * NOTE: ptr = NULL is explicetly allowed +- * Note2: it is recommended that you use av_freep() instead ++ * Free a memory block which has been allocated with av_malloc(z)() or ++ * av_realloc(). ++ * @param ptr Pointer to the memory block which should be freed. ++ * @note ptr = NULL is explicitly allowed. ++ * @note It is recommended that you use av_freep() instead. ++ * @see av_freep() + */ + void av_free(void *ptr); + ++/** ++ * Allocate a block of \p size bytes with alignment suitable for all ++ * memory accesses (including vectors if available on the CPU) and ++ * set to zeroes all the bytes of the block. ++ * @param size Size in bytes for the memory block to be allocated. ++ * @return Pointer to the allocated block, NULL if it cannot allocate ++ * it. ++ * @see av_malloc() ++ */ + void *av_mallocz(unsigned int size); + + /** +- * Duplicates the string \p s. ++ * Duplicate the string \p s. + * @param s String to be duplicated. + * @return Pointer to a newly allocated string containing a +- * copy of \p s or NULL if it cannot allocate it. ++ * copy of \p s or NULL if it cannot be allocated. + */ + char *av_strdup(const char *s); + + /** +- * Frees memory and sets the pointer to NULL. +- * @param ptr pointer to the pointer which should be freed ++ * Free a memory block which has been allocated with av_malloc(z)() or ++ * av_realloc() and set to NULL the pointer to it. ++ * @param ptr Pointer to the pointer to the memory block which should ++ * be freed. ++ * @see av_free() + */ + void av_freep(void *ptr); + +-#endif /* AV_MEM_H */ ++#endif /* FFMPEG_MEM_H */ +diff -u mplayer-1.0~rc2-12/libavutil/random.h ffmpeg-free-0.svn20080206/libavutil/random.h +--- mplayer-1.0~rc2-12/libavutil/random.h 2007-10-07 21:49:34.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavutil/random.h 2007-10-17 11:37:46.000000000 +0200 +@@ -21,8 +21,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef AV_RANDOM_H +-#define AV_RANDOM_H ++#ifndef FFMPEG_RANDOM_H ++#define FFMPEG_RANDOM_H + + #define AV_RANDOM_N 624 + +@@ -65,5 +65,5 @@ + + // only available if DEBUG is defined in the .c file + void av_benchmark_random(void); +-#endif // AV_RANDOM_H + ++#endif /* FFMPEG_RANDOM_H */ +diff -u mplayer-1.0~rc2-12/libavutil/rational.h ffmpeg-free-0.svn20080206/libavutil/rational.h +--- mplayer-1.0~rc2-12/libavutil/rational.h 2007-10-07 21:49:34.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavutil/rational.h 2007-10-17 11:37:46.000000000 +0200 +@@ -25,8 +25,8 @@ + * @author Michael Niedermayer + */ + +-#ifndef RATIONAL_H +-#define RATIONAL_H ++#ifndef FFMPEG_RATIONAL_H ++#define FFMPEG_RATIONAL_H + + #include + +@@ -112,4 +112,4 @@ + */ + AVRational av_d2q(double d, int max); + +-#endif // RATIONAL_H ++#endif /* FFMPEG_RATIONAL_H */ +Only in ffmpeg-free-0.svn20080206/libavutil: rc4.c +Only in ffmpeg-free-0.svn20080206/libavutil: rc4.h +diff -u mplayer-1.0~rc2-12/libavutil/sha1.c ffmpeg-free-0.svn20080206/libavutil/sha1.c +--- mplayer-1.0~rc2-12/libavutil/sha1.c 2007-10-07 21:49:34.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavutil/sha1.c 2008-02-03 22:56:13.000000000 +0100 +@@ -29,10 +29,12 @@ + uint32_t state[5]; + } AVSHA1; + ++const int av_sha1_size = sizeof(AVSHA1); ++ + #define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits)))) + + /* (R0+R1), R2, R3, R4 are the different operations used in SHA1 */ +-#define blk0(i) (block[i] = be2me_32(((uint32_t*)buffer)[i])) ++#define blk0(i) (block[i] = be2me_32(((const uint32_t*)buffer)[i])) + #define blk(i) (block[i] = rol(block[i-3]^block[i-8]^block[i-14]^block[i-16],1)) + + #define R0(v,w,x,y,z,i) z+=((w&(x^y))^y) +blk0(i)+0x5A827999+rol(v,5);w=rol(w,30); +@@ -43,7 +45,7 @@ + + /* Hash a single 512-bit block. This is the core of the algorithm. */ + +-static void transform(uint32_t state[5], uint8_t buffer[64]){ ++static void transform(uint32_t state[5], const uint8_t buffer[64]){ + uint32_t block[80]; + unsigned int i, a, b, c, d, e; + +@@ -103,7 +105,7 @@ + ctx->count = 0; + } + +-void av_sha1_update(AVSHA1* ctx, uint8_t* data, unsigned int len){ ++void av_sha1_update(AVSHA1* ctx, const uint8_t* data, unsigned int len){ + unsigned int i, j; + + j = ctx->count & 63; +@@ -138,7 +140,7 @@ + while ((ctx->count & 63) != 56) { + av_sha1_update(ctx, "", 1); + } +- av_sha1_update(ctx, &finalcount, 8); /* Should cause a transform() */ ++ av_sha1_update(ctx, (uint8_t *)&finalcount, 8); /* Should cause a transform() */ + for(i=0; i<5; i++) + ((uint32_t*)digest)[i]= be2me_32(ctx->state[i]); + } +@@ -149,7 +151,7 @@ + #include + #undef printf + +-int main(){ ++int main(void){ + int i, k; + AVSHA1 ctx; + unsigned char digest[20]; +diff -u mplayer-1.0~rc2-12/libavutil/sha1.h ffmpeg-free-0.svn20080206/libavutil/sha1.h +--- mplayer-1.0~rc2-12/libavutil/sha1.h 2007-10-07 21:49:34.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavutil/sha1.h 2008-02-03 22:56:13.000000000 +0100 +@@ -18,8 +18,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef AV_SHA1_H +-#define AV_SHA1_H ++#ifndef FFMPEG_SHA1_H ++#define FFMPEG_SHA1_H + + #include + +@@ -28,6 +28,7 @@ + struct AVSHA1; + + void av_sha1_init(struct AVSHA1* context); +-void av_sha1_update(struct AVSHA1* context, uint8_t* data, unsigned int len); ++void av_sha1_update(struct AVSHA1* context, const uint8_t* data, unsigned int len); + void av_sha1_final(struct AVSHA1* context, uint8_t digest[20]); +-#endif ++ ++#endif /* FFMPEG_SHA1_H */ +diff -u mplayer-1.0~rc2-12/libavutil/softfloat.c ffmpeg-free-0.svn20080206/libavutil/softfloat.c +--- mplayer-1.0~rc2-12/libavutil/softfloat.c 2007-10-07 21:49:34.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavutil/softfloat.c 2007-11-23 01:52:56.000000000 +0100 +@@ -27,7 +27,7 @@ + + #undef printf + +-int main(){ ++int main(void){ + SoftFloat one= av_int2sf(1, 0); + SoftFloat sf1, sf2; + double d1, d2; +diff -u mplayer-1.0~rc2-12/libavutil/softfloat.h ffmpeg-free-0.svn20080206/libavutil/softfloat.h +--- mplayer-1.0~rc2-12/libavutil/softfloat.h 2007-10-07 21:49:34.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavutil/softfloat.h 2007-10-17 11:37:46.000000000 +0200 +@@ -18,8 +18,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef AVUTIL_SOFTFLOAT_H +-#define AVUTIL_SOFTFLOAT_H ++#ifndef FFMPEG_SOFTFLOAT_H ++#define FFMPEG_SOFTFLOAT_H + + #include + +@@ -125,4 +125,4 @@ + else return v.mant >>(-v.exp); + } + +-#endif // AVUTIL_SOFTFLOAT_H ++#endif /* FFMPEG_SOFTFLOAT_H */ +diff -u mplayer-1.0~rc2-12/libavutil/tree.c ffmpeg-free-0.svn20080206/libavutil/tree.c +--- mplayer-1.0~rc2-12/libavutil/tree.c 2007-10-07 21:49:34.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavutil/tree.c 2008-01-23 22:03:21.000000000 +0100 +@@ -28,58 +28,97 @@ + int state; + }AVTreeNode; + ++const int av_tree_node_size = sizeof(AVTreeNode); ++ + void *av_tree_find(const AVTreeNode *t, void *key, int (*cmp)(void *key, const void *b), void *next[2]){ + if(t){ +- unsigned int v= cmp(t->elem, key); ++ unsigned int v= cmp(key, t->elem); + if(v){ +- if(next) next[(v>>31)^1]= t->elem; +- return av_tree_find(t->child[v>>31], key, cmp, next); ++ if(next) next[v>>31]= t->elem; ++ return av_tree_find(t->child[(v>>31)^1], key, cmp, next); + }else{ ++ if(next){ ++ av_tree_find(t->child[0], key, cmp, next); ++ av_tree_find(t->child[1], key, cmp, next); ++ } + return t->elem; + } + } + return NULL; + } + +-void *av_tree_insert(AVTreeNode **tp, void *key, int (*cmp)(void *key, const void *b)){ ++void *av_tree_insert(AVTreeNode **tp, void *key, int (*cmp)(void *key, const void *b), AVTreeNode **next){ + AVTreeNode *t= *tp; + if(t){ + unsigned int v= cmp(t->elem, key); +- if(v){ +- int i= v>>31; ++ void *ret; ++ if(!v){ ++ if(*next) ++ return t->elem; ++ else if(t->child[0]||t->child[1]){ ++ int i= !t->child[0]; ++ void *next_elem[2]; ++ av_tree_find(t->child[i], key, cmp, next_elem); ++ key= t->elem= next_elem[i]; ++ v= -i; ++ }else{ ++ *next= t; ++ *tp=NULL; ++ return NULL; ++ } ++ } ++ ret= av_tree_insert(&t->child[v>>31], key, cmp, next); ++ if(!ret){ ++ int i= (v>>31) ^ !!*next; + AVTreeNode **child= &t->child[i]; +- void *ret= av_tree_insert(child, key, cmp); +- if(!ret){ +- t->state -= ((int)v>>31)|1; +- if(!(t->state&1)){ +- if(t->state){ +- if((*child)->state*2 == t->state){ +- *tp= *child; +- *child= (*child)->child[i^1]; +- (*tp)->child[i^1]= t; +- t->state= 0; +- }else{ +- *tp= (*child)->child[i^1]; +- (*child)->child[i^1]= (*tp)->child[i]; +- (*tp)->child[i]= *child; +- *child= (*tp)->child[i^1]; +- (*tp)->child[i^1]= t; +- +- i= (*tp)->state > 0; +- (*tp)->child[i ]->state= 0; +- (*tp)->child[i^1]->state= -(*tp)->state; +- } ++ t->state += 2*i - 1; ++ ++ if(!(t->state&1)){ ++ if(t->state){ ++ /* The following code is equivalent to ++ if((*child)->state*2 == -t->state) ++ rotate(child, i^1); ++ rotate(tp, i); ++ ++ with rotate(): ++ static void rotate(AVTreeNode **tp, int i){ ++ AVTreeNode *t= *tp; ++ ++ *tp= t->child[i]; ++ t->child[i]= t->child[i]->child[i^1]; ++ (*tp)->child[i^1]= t; ++ i= 4*t->state + 2*(*tp)->state + 12; ++ t ->state= ((0x614586 >> i) & 3)-1; ++ (*tp)->state= ((*tp)->state>>1) + ((0x400EEA >> i) & 3)-1; ++ } ++ but such a rotate function is both bigger and slower ++ */ ++ if((*child)->state*2 == -t->state){ ++ *tp= (*child)->child[i^1]; ++ (*child)->child[i^1]= (*tp)->child[i]; ++ (*tp)->child[i]= *child; ++ *child= (*tp)->child[i^1]; ++ (*tp)->child[i^1]= t; ++ ++ (*tp)->child[0]->state= -((*tp)->state>0); ++ (*tp)->child[1]->state= (*tp)->state<0 ; + (*tp)->state=0; ++ }else{ ++ *tp= *child; ++ *child= (*child)->child[i^1]; ++ (*tp)->child[i^1]= t; ++ if((*tp)->state) t->state = 0; ++ else t->state>>= 1; ++ (*tp)->state= -t->state; + } +- return key; + } + } +- return ret; +- }else{ +- return t->elem; ++ if(!(*tp)->state ^ !!*next) ++ return key; + } ++ return ret; + }else{ +- *tp= av_mallocz(sizeof(AVTreeNode)); ++ *tp= *next; *next= NULL; + (*tp)->elem= key; + return NULL; + } +@@ -100,7 +139,7 @@ + #endif + + #ifdef TEST +- ++#undef random + static int check(AVTreeNode *t){ + if(t){ + int left= check(t->child[0]); +@@ -132,19 +171,32 @@ + return a-b; + } + +-int main(){ +- int i,j,k; +- AVTreeNode *root= NULL; ++int main(void){ ++ int i,k; ++ AVTreeNode *root= NULL, *node=NULL; + + for(i=0; i<10000; i++){ +- int j= (random()%863294); ++ int j= (random()%86294); + if(check(root) > 999){ + av_log(NULL, AV_LOG_ERROR, "FATAL error %d\n", i); + print(root, 0); + return -1; + } + av_log(NULL, AV_LOG_ERROR, "inserting %4d\n", j); +- av_tree_insert(&root, (void*)(j+1), cmp); ++ if(!node) ++ node= av_mallocz(av_tree_node_size); ++ av_tree_insert(&root, (void*)(j+1), cmp, &node); ++ ++ j= (random()%86294); ++ k= av_tree_find(root, (void*)(j+1), cmp, NULL); ++ if(k){ ++ AVTreeNode *node2=NULL; ++ av_log(NULL, AV_LOG_ERROR, "removing %4d\n", j); ++ av_tree_insert(&root, (void*)(j+1), cmp, &node2); ++ k= av_tree_find(root, (void*)(j+1), cmp, NULL); ++ if(k) ++ av_log(NULL, AV_LOG_ERROR, "removial failure %d\n", i); ++ } + } + return 0; + } +diff -u mplayer-1.0~rc2-12/libavutil/tree.h ffmpeg-free-0.svn20080206/libavutil/tree.h +--- mplayer-1.0~rc2-12/libavutil/tree.h 2007-10-07 21:49:34.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavutil/tree.h 2008-01-04 19:55:14.000000000 +0100 +@@ -21,13 +21,16 @@ + /** + * @file tree.h + * A tree container. ++ * Insertion, Removial, Finding equal, largest which is smaller than and ++ * smallest which is larger than all have O(log n) worst case time. + * @author Michael Niedermayer + */ + +-#ifndef TREE_H +-#define TREE_H ++#ifndef FFMPEG_TREE_H ++#define FFMPEG_TREE_H + + struct AVTreeNode; ++extern const int av_tree_node_size; + + /** + * Finds an element. +@@ -41,18 +44,39 @@ + void *av_tree_find(const struct AVTreeNode *root, void *key, int (*cmp)(void *key, const void *b), void *next[2]); + + /** +- * Finds a element for which cmp(key, elem)==0, if no such element is found key +- * is inserted into the tree. ++ * Inserts or removes an element. ++ * If *next is NULL then the element supplied will be removed, if no such ++ * element exists behavior is undefined. ++ * If *next is not NULL then the element supplied will be inserted, unless ++ * it already exists in the tree. + * @param rootp A pointer to a pointer to the root node of the tree. Note that + * the root node can change during insertions, this is required + * to keep the tree balanced. ++ * @param next Used to allocate and free AVTreeNodes. For insertion the user ++ * must set it to an allocated and zeroed object of at least ++ * av_tree_node_size bytes size. av_tree_insert() will set it to ++ * NULL if it has been consumed. ++ * For deleting elements *next is set to NULL by the user and ++ * av_tree_node_size() will set it to the AVTreeNode which was ++ * used for the removed element. ++ * This allows the use of flat arrays, which have ++ * lower overhead compared to many malloced elements. ++ * You might want to define a function like: ++ * void *tree_insert(struct AVTreeNode **rootp, void *key, int (*cmp)(void *key, const void *b), AVTreeNode **next){ ++ * if(!*next) *next= av_mallocz(av_tree_node_size); ++ * return av_tree_insert(rootp, key, cmp, next); ++ * } ++ * void *tree_remove(struct AVTreeNode **rootp, void *key, int (*cmp)(void *key, const void *b, AVTreeNode **next)){ ++ * if(*next) av_freep(next); ++ * return av_tree_insert(rootp, key, cmp, next); ++ * } + * + * @return If no insertion happened, the found element. +- * If an insertion happened, then either key or NULL will be returned. ++ * If an insertion or removial happened, then either key or NULL will be returned. + * Which one it is depends on the tree state and the implementation. You + * should make no assumptions that it's one or the other in the code. + */ +-void *av_tree_insert(struct AVTreeNode **rootp, void *key, int (*cmp)(void *key, const void *b)); ++void *av_tree_insert(struct AVTreeNode **rootp, void *key, int (*cmp)(void *key, const void *b), struct AVTreeNode **next); + void av_tree_destroy(struct AVTreeNode *t); + +-#endif /* TREE_H */ ++#endif /* FFMPEG_TREE_H */ +diff -u mplayer-1.0~rc2-12/libavutil/x86_cpu.h ffmpeg-free-0.svn20080206/libavutil/x86_cpu.h +--- mplayer-1.0~rc2-12/libavutil/x86_cpu.h 2007-10-07 21:49:34.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libavutil/x86_cpu.h 2007-10-17 11:37:46.000000000 +0200 +@@ -18,8 +18,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef AVUTIL_X86CPU_H +-#define AVUTIL_X86CPU_H ++#ifndef FFMPEG_X86CPU_H ++#define FFMPEG_X86CPU_H + + #ifdef ARCH_X86_64 + # define REG_a "rax" +@@ -65,4 +65,4 @@ + # define BROKEN_RELOCATIONS 1 + #endif + +-#endif /* AVUTIL_X86CPU_H */ ++#endif /* FFMPEG_X86CPU_H */ +diff -u mplayer-1.0~rc2-12/libpostproc/Makefile ffmpeg-free-0.svn20080206/libpostproc/Makefile +--- mplayer-1.0~rc2-12/libpostproc/Makefile 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libpostproc/Makefile 2008-01-14 15:42:29.000000000 +0100 +@@ -10,17 +10,11 @@ + LIBVERSION=$(SPPVERSION) + LIBMAJOR=$(SPPMAJOR) + +-STATIC_OBJS=postprocess.o +-SHARED_OBJS=postprocess_pic.o +- + HEADERS = postprocess.h + +-include ../common.mak +- +-depend dep: postprocess.c ++OBJS = postprocess.o + +-postprocess_pic.o: postprocess.c +- $(CC) -c $(CFLAGS) -fomit-frame-pointer -fPIC -DPIC -o $@ $< ++include ../common.mak + + uninstall-headers:: + -rmdir "$(prefix)/include/postproc" +diff -u mplayer-1.0~rc2-12/libpostproc/postprocess_altivec_template.c ffmpeg-free-0.svn20080206/libpostproc/postprocess_altivec_template.c +--- mplayer-1.0~rc2-12/libpostproc/postprocess_altivec_template.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libpostproc/postprocess_altivec_template.c 2007-12-01 23:21:04.000000000 +0100 +@@ -194,7 +194,7 @@ + One could remove the recomputation of the perm + vector by assuming (stride % 16) == 0, unfortunately + this is not always true. Quite a lot of load/stores +- can be removed by assuming proper alignement of ++ can be removed by assuming proper alignment of + src & stride :-( + */ + uint8_t *src2 = src; +@@ -382,7 +382,7 @@ + One could remove the recomputation of the perm + vector by assuming (stride % 16) == 0, unfortunately + this is not always true. Quite a lot of load/stores +- can be removed by assuming proper alignement of ++ can be removed by assuming proper alignment of + src & stride :-( + */ + uint8_t *src2 = src; +@@ -469,7 +469,7 @@ + const vector signed short dornotd = vec_sel((vector signed short)zero, + dclampedfinal, + vec_cmplt(absmE, vqp)); +- /* add/substract to l4 and l5 */ ++ /* add/subtract to l4 and l5 */ + const vector signed short vb4minusd = vec_sub(vb4, dornotd); + const vector signed short vb5plusd = vec_add(vb5, dornotd); + /* finally, stores */ +@@ -506,7 +506,7 @@ + One could remove the recomputation of the perm + vector by assuming (stride % 16) == 0, unfortunately + this is not always true. Quite a lot of load/stores +- can be removed by assuming proper alignement of ++ can be removed by assuming proper alignment of + src & stride :-( + */ + uint8_t *srcCopy = src; +diff -u mplayer-1.0~rc2-12/libpostproc/postprocess.c ffmpeg-free-0.svn20080206/libpostproc/postprocess.c +--- mplayer-1.0~rc2-12/libpostproc/postprocess.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libpostproc/postprocess.c 2008-02-02 22:24:54.000000000 +0100 +@@ -101,20 +101,17 @@ + //#define NUM_BLOCKS_AT_ONCE 16 //not used yet + + #if defined(ARCH_X86) +-static DECLARE_ALIGNED(8, uint64_t attribute_used, w05)= 0x0005000500050005LL; +-static DECLARE_ALIGNED(8, uint64_t attribute_used, w04)= 0x0004000400040004LL; +-static DECLARE_ALIGNED(8, uint64_t attribute_used, w20)= 0x0020002000200020LL; +-static DECLARE_ALIGNED(8, uint64_t attribute_used, b00)= 0x0000000000000000LL; +-static DECLARE_ALIGNED(8, uint64_t attribute_used, b01)= 0x0101010101010101LL; +-static DECLARE_ALIGNED(8, uint64_t attribute_used, b02)= 0x0202020202020202LL; +-static DECLARE_ALIGNED(8, uint64_t attribute_used, b08)= 0x0808080808080808LL; +-static DECLARE_ALIGNED(8, uint64_t attribute_used, b80)= 0x8080808080808080LL; ++DECLARE_ASM_CONST(8, uint64_t, w05)= 0x0005000500050005LL; ++DECLARE_ASM_CONST(8, uint64_t, w04)= 0x0004000400040004LL; ++DECLARE_ASM_CONST(8, uint64_t, w20)= 0x0020002000200020LL; ++DECLARE_ASM_CONST(8, uint64_t, b00)= 0x0000000000000000LL; ++DECLARE_ASM_CONST(8, uint64_t, b01)= 0x0101010101010101LL; ++DECLARE_ASM_CONST(8, uint64_t, b02)= 0x0202020202020202LL; ++DECLARE_ASM_CONST(8, uint64_t, b08)= 0x0808080808080808LL; ++DECLARE_ASM_CONST(8, uint64_t, b80)= 0x8080808080808080LL; + #endif + +-static uint8_t clip_table[3*256]; +-static uint8_t * const clip_tab= clip_table + 256; +- +-static const int attribute_used deringThreshold= 20; ++DECLARE_ASM_CONST(8, int, deringThreshold)= 20; + + + static struct PPFilter filters[]= +@@ -142,11 +139,11 @@ + + static const char *replaceTable[]= + { +- "default", "hdeblock:a,vdeblock:a,dering:a", +- "de", "hdeblock:a,vdeblock:a,dering:a", +- "fast", "x1hdeblock:a,x1vdeblock:a,dering:a", +- "fa", "x1hdeblock:a,x1vdeblock:a,dering:a", +- "ac", "ha:a:128:7,va:a,dering:a", ++ "default", "hb:a,vb:a,dr:a", ++ "de", "hb:a,vb:a,dr:a", ++ "fast", "h1:a,v1:a,dr:a", ++ "fa", "h1:a,v1:a,dr:a", ++ "ac", "ha:a:128:7,va:a,dr:a", + NULL //End Marker + }; + +@@ -646,8 +643,8 @@ + + // minor note: the HAVE_xyz is messed up after that line so do not use it. + +-static inline void postProcess(uint8_t src[], int srcStride, uint8_t dst[], int dstStride, int width, int height, +- QP_STORE_T QPs[], int QPStride, int isColor, pp_mode_t *vm, pp_context_t *vc) ++static inline void postProcess(const uint8_t src[], int srcStride, uint8_t dst[], int dstStride, int width, int height, ++ const QP_STORE_T QPs[], int QPStride, int isColor, pp_mode_t *vm, pp_context_t *vc) + { + PPContext *c= (PPContext *)vc; + PPMode *ppMode= (PPMode *)vm; +@@ -697,7 +694,11 @@ + + /* -pp Command line Help + */ +-char *pp_help= ++#if LIBPOSTPROC_VERSION_INT < (52<<16) ++const char *const pp_help= ++#else ++const char pp_help[] = ++#endif + "Available postprocessing filters:\n" + "Filters Options\n" + "short long name short long option Description\n" +@@ -741,12 +742,12 @@ + "\n" + ; + +-pp_mode_t *pp_get_mode_by_name_and_quality(char *name, int quality) ++pp_mode_t *pp_get_mode_by_name_and_quality(const char *name, int quality) + { + char temp[GET_MODE_BUFFER_SIZE]; + char *p= temp; +- const char *filterDelimiters= ",/"; +- const char *optionDelimiters= ":"; ++ static const char filterDelimiters[] = ",/"; ++ static const char optionDelimiters[] = ":"; + struct PPMode *ppMode; + char *filterToken; + +@@ -970,27 +971,17 @@ + reallocAlign((void **)&c->forcedQPTable, 8, mbWidth*sizeof(QP_STORE_T)); + } + +-static void global_init(void){ +- int i; +- memset(clip_table, 0, 256); +- for(i=256; i<512; i++) +- clip_table[i]= i; +- memset(clip_table+512, 0, 256); +-} +- + static const char * context_to_name(void * ptr) { + return "postproc"; + } + +-static AVClass av_codec_context_class = { "Postproc", context_to_name, NULL }; ++static const AVClass av_codec_context_class = { "Postproc", context_to_name, NULL }; + + pp_context_t *pp_get_context(int width, int height, int cpuCaps){ + PPContext *c= av_malloc(sizeof(PPContext)); + int stride= (width+15)&(~15); //assumed / will realloc if needed + int qpStride= (width+15)/16 + 2; //assumed / will realloc if needed + +- global_init(); +- + memset(c, 0, sizeof(PPContext)); + c->av_class = &av_codec_context_class; + c->cpuCaps= cpuCaps; +@@ -1030,10 +1021,10 @@ + av_free(c); + } + +-void pp_postprocess(uint8_t * src[3], int srcStride[3], +- uint8_t * dst[3], int dstStride[3], ++void pp_postprocess(const uint8_t * src[3], const int srcStride[3], ++ uint8_t * dst[3], const int dstStride[3], + int width, int height, +- QP_STORE_T *QP_store, int QPStride, ++ const QP_STORE_T *QP_store, int QPStride, + pp_mode_t *vm, void *vc, int pict_type) + { + int mbWidth = (width+15)>>4; +@@ -1055,16 +1046,16 @@ + QP_store= c->forcedQPTable; + absQPStride = QPStride = 0; + if(mode->lumMode & FORCE_QUANT) +- for(i=0; iforcedQuant; ++ for(i=0; iforcedQPTable[i]= mode->forcedQuant; + else +- for(i=0; iforcedQPTable[i]= 1; + } + + if(pict_type & PP_PICT_TYPE_QP2){ + int i; + const int count= mbHeight * absQPStride; + for(i=0; i<(count>>2); i++){ +- ((uint32_t*)c->stdQPTable)[i] = (((uint32_t*)QP_store)[i]>>1) & 0x7F7F7F7F; ++ ((uint32_t*)c->stdQPTable)[i] = (((const uint32_t*)QP_store)[i]>>1) & 0x7F7F7F7F; + } + for(i<<=2; istdQPTable[i] = QP_store[i]>>1; +@@ -1090,7 +1081,7 @@ + int i; + const int count= mbHeight * QPStride; + for(i=0; i<(count>>2); i++){ +- ((uint32_t*)c->nonBQPTable)[i] = ((uint32_t*)QP_store)[i] & 0x3F3F3F3F; ++ ((uint32_t*)c->nonBQPTable)[i] = ((const uint32_t*)QP_store)[i] & 0x3F3F3F3F; + } + for(i<<=2; inonBQPTable[i] = QP_store[i] & 0x3F; +diff -u mplayer-1.0~rc2-12/libpostproc/postprocess.h ffmpeg-free-0.svn20080206/libpostproc/postprocess.h +--- mplayer-1.0~rc2-12/libpostproc/postprocess.h 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libpostproc/postprocess.h 2008-02-02 22:24:54.000000000 +0100 +@@ -18,8 +18,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef NEWPOSTPROCESS_H +-#define NEWPOSTPROCESS_H ++#ifndef FFMPEG_POSTPROCESS_H ++#define FFMPEG_POSTPROCESS_H + + /** + * @file postprocess.h +@@ -42,12 +42,16 @@ + typedef void pp_context_t; + typedef void pp_mode_t; + +-extern char *pp_help; ///< a simple help text ++#if LIBPOSTPROC_VERSION_INT < (52<<16) ++extern const char *const pp_help; ///< a simple help text ++#else ++extern const char pp_help[]; ///< a simple help text ++#endif + +-void pp_postprocess(uint8_t * src[3], int srcStride[3], +- uint8_t * dst[3], int dstStride[3], ++void pp_postprocess(const uint8_t * src[3], const int srcStride[3], ++ uint8_t * dst[3], const int dstStride[3], + int horizontalSize, int verticalSize, +- QP_STORE_T *QP_store, int QP_stride, ++ const QP_STORE_T *QP_store, int QP_stride, + pp_mode_t *mode, pp_context_t *ppContext, int pict_type); + + +@@ -56,7 +60,7 @@ + * name is the string after "-pp" on the command line + * quality is a number from 0 to PP_QUALITY_MAX + */ +-pp_mode_t *pp_get_mode_by_name_and_quality(char *name, int quality); ++pp_mode_t *pp_get_mode_by_name_and_quality(const char *name, int quality); + void pp_free_mode(pp_mode_t *mode); + + pp_context_t *pp_get_context(int width, int height, int flags); +@@ -75,4 +79,4 @@ + + #define PP_PICT_TYPE_QP2 0x00000010 ///< MPEG2 style QScale + +-#endif ++#endif /* FFMPEG_POSTPROCESS_H */ +diff -u mplayer-1.0~rc2-12/libpostproc/postprocess_internal.h ffmpeg-free-0.svn20080206/libpostproc/postprocess_internal.h +--- mplayer-1.0~rc2-12/libpostproc/postprocess_internal.h 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libpostproc/postprocess_internal.h 2008-02-02 18:13:40.000000000 +0100 +@@ -23,8 +23,8 @@ + * internal api header. + */ + +-#ifndef POSTPROCESS_INTERNAL_H +-#define POSTPROCESS_INTERNAL_H ++#ifndef FFMPEG_POSTPROCESS_INTERNAL_H ++#define FFMPEG_POSTPROCESS_INTERNAL_H + + #include "avutil.h" + #include "postprocess.h" +@@ -66,27 +66,16 @@ + #define TEMP_NOISE_FILTER 0x100000 + #define FORCE_QUANT 0x200000 + +-#if ( defined(__PIC__) || defined(__pic__) ) && ! defined(PIC) +-# define PIC +-#endif +- + //use if you want a faster postprocessing code + //cannot differentiate between chroma & luma filters (both on or both off) + //obviously the -pp option on the command line has no effect except turning the here selected + //filters on + //#define COMPILE_TIME_MODE 0x77 + +-#if 1 + static inline int CLIP(int a){ + if(a&256) return ((a)>>31)^(-1); + else return a; + } +-//#define CLIP(a) (((a)&256) ? ((a)>>31)^(-1) : (a)) +-#elif 0 +-#define CLIP(a) clip_tab[a] +-#else +-#define CLIP(a) (a) +-#endif + /** + * Postprocessng filter. + */ +@@ -126,7 +115,7 @@ + /** + * info on struct for av_log + */ +- AVClass *av_class; ++ const AVClass *av_class; + + uint8_t *tempBlocks; /// 0) { + memcpy(dest, src, lines*stride); + } else { +- memcpy(dest+(lines-1)*stride, src+(lines-1)*stride, -lines*stride); ++ memcpy((uint8_t*)dest+(lines-1)*stride, (const uint8_t*)src+(lines-1)*stride, -lines*stride); + } + } + +-#endif // POSTPROCESS_INTERNAL_H ++#endif /* FFMPEG_POSTPROCESS_INTERNAL_H */ +diff -u mplayer-1.0~rc2-12/libpostproc/postprocess_template.c ffmpeg-free-0.svn20080206/libpostproc/postprocess_template.c +--- mplayer-1.0~rc2-12/libpostproc/postprocess_template.c 2007-10-07 21:49:38.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libpostproc/postprocess_template.c 2008-02-02 22:24:54.000000000 +0100 +@@ -3180,8 +3180,8 @@ + } + #endif //HAVE_MMX + +-static void RENAME(postProcess)(uint8_t src[], int srcStride, uint8_t dst[], int dstStride, int width, int height, +- QP_STORE_T QPs[], int QPStride, int isColor, PPContext *c); ++static void RENAME(postProcess)(const uint8_t src[], int srcStride, uint8_t dst[], int dstStride, int width, int height, ++ const QP_STORE_T QPs[], int QPStride, int isColor, PPContext *c); + + /** + * Copies a block from src to dst and fixes the blacklevel. +@@ -3189,7 +3189,7 @@ + */ + #undef SCALED_CPY + +-static inline void RENAME(blockCopy)(uint8_t dst[], int dstStride, uint8_t src[], int srcStride, ++static inline void RENAME(blockCopy)(uint8_t dst[], int dstStride, const uint8_t src[], int srcStride, + int levelFix, int64_t *packedOffsetAndScale) + { + #ifndef HAVE_MMX +@@ -3346,8 +3346,8 @@ + /** + * Filters array of bytes (Y or U or V values) + */ +-static void RENAME(postProcess)(uint8_t src[], int srcStride, uint8_t dst[], int dstStride, int width, int height, +- QP_STORE_T QPs[], int QPStride, int isColor, PPContext *c2) ++static void RENAME(postProcess)(const uint8_t src[], int srcStride, uint8_t dst[], int dstStride, int width, int height, ++ const QP_STORE_T QPs[], int QPStride, int isColor, PPContext *c2) + { + DECLARE_ALIGNED(8, PPContext, c)= *c2; //copy to stack for faster access + int x,y; +@@ -3462,7 +3462,7 @@ + /* copy & deinterlace first row of blocks */ + y=-BLOCK_SIZE; + { +- uint8_t *srcBlock= &(src[y*srcStride]); ++ const uint8_t *srcBlock= &(src[y*srcStride]); + uint8_t *dstBlock= tempDst + dstStride; + + // From this point on it is guaranteed that we can read and write 16 lines downward +@@ -3545,13 +3545,13 @@ + for(y=0; y>qpVShift)*QPStride]; ++ const int8_t *QPptr= &QPs[(y>>qpVShift)*QPStride]; + int8_t *nonBQPptr= &c.nonBQPTable[(y>>qpVShift)*FFABS(QPStride)]; + int QP=0; + /* can we mess with a 8x16 block from srcBlock/dstBlock downwards and 1 line upwards +diff -u mplayer-1.0~rc2-12/libswscale/Makefile ffmpeg-free-0.svn20080206/libswscale/Makefile +--- mplayer-1.0~rc2-12/libswscale/Makefile 2007-10-07 21:49:31.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libswscale/Makefile 2007-10-18 11:35:02.000000000 +0200 +@@ -21,9 +21,9 @@ + + include ../common.mak + +-cs_test: cs_test.o $(LIB) ++cs_test: cs_test.o $(LIBNAME) + +-swscale-example: swscale-example.o $(LIB) ++swscale-example: swscale-example.o $(LIBNAME) + swscale-example: EXTRALIBS += -lm + + clean:: +diff -u mplayer-1.0~rc2-12/libswscale/rgb2rgb.c ffmpeg-free-0.svn20080206/libswscale/rgb2rgb.c +--- mplayer-1.0~rc2-12/libswscale/rgb2rgb.c 2007-10-07 21:49:31.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libswscale/rgb2rgb.c 2008-01-29 15:58:10.000000000 +0100 +@@ -35,18 +35,18 @@ + + #define FAST_BGR2YV12 // use 7 bit coeffs instead of 15bit + +-void (*rgb24to32)(const uint8_t *src,uint8_t *dst,long src_size); +-void (*rgb24to16)(const uint8_t *src,uint8_t *dst,long src_size); +-void (*rgb24to15)(const uint8_t *src,uint8_t *dst,long src_size); +-void (*rgb32to24)(const uint8_t *src,uint8_t *dst,long src_size); +-void (*rgb32to16)(const uint8_t *src,uint8_t *dst,long src_size); +-void (*rgb32to15)(const uint8_t *src,uint8_t *dst,long src_size); +-void (*rgb15to16)(const uint8_t *src,uint8_t *dst,long src_size); +-void (*rgb15to24)(const uint8_t *src,uint8_t *dst,long src_size); +-void (*rgb15to32)(const uint8_t *src,uint8_t *dst,long src_size); +-void (*rgb16to15)(const uint8_t *src,uint8_t *dst,long src_size); +-void (*rgb16to24)(const uint8_t *src,uint8_t *dst,long src_size); +-void (*rgb16to32)(const uint8_t *src,uint8_t *dst,long src_size); ++void (*rgb24to32)(const uint8_t *src, uint8_t *dst, long src_size); ++void (*rgb24to16)(const uint8_t *src, uint8_t *dst, long src_size); ++void (*rgb24to15)(const uint8_t *src, uint8_t *dst, long src_size); ++void (*rgb32to24)(const uint8_t *src, uint8_t *dst, long src_size); ++void (*rgb32to16)(const uint8_t *src, uint8_t *dst, long src_size); ++void (*rgb32to15)(const uint8_t *src, uint8_t *dst, long src_size); ++void (*rgb15to16)(const uint8_t *src, uint8_t *dst, long src_size); ++void (*rgb15to24)(const uint8_t *src, uint8_t *dst, long src_size); ++void (*rgb15to32)(const uint8_t *src, uint8_t *dst, long src_size); ++void (*rgb16to15)(const uint8_t *src, uint8_t *dst, long src_size); ++void (*rgb16to24)(const uint8_t *src, uint8_t *dst, long src_size); ++void (*rgb16to32)(const uint8_t *src, uint8_t *dst, long src_size); + //void (*rgb24tobgr32)(const uint8_t *src, uint8_t *dst, long src_size); + void (*rgb24tobgr24)(const uint8_t *src, uint8_t *dst, long src_size); + void (*rgb24tobgr16)(const uint8_t *src, uint8_t *dst, long src_size); +@@ -88,52 +88,39 @@ + long srcStride3, long dstStride); + + #if defined(ARCH_X86) && defined(CONFIG_GPL) +-static const uint64_t mmx_null __attribute__((aligned(8))) = 0x0000000000000000ULL; +-static const uint64_t mmx_one __attribute__((aligned(8))) = 0xFFFFFFFFFFFFFFFFULL; +-static const uint64_t mask32b attribute_used __attribute__((aligned(8))) = 0x000000FF000000FFULL; +-static const uint64_t mask32g attribute_used __attribute__((aligned(8))) = 0x0000FF000000FF00ULL; +-static const uint64_t mask32r attribute_used __attribute__((aligned(8))) = 0x00FF000000FF0000ULL; +-static const uint64_t mask32 __attribute__((aligned(8))) = 0x00FFFFFF00FFFFFFULL; +-static const uint64_t mask3216br __attribute__((aligned(8))) = 0x00F800F800F800F8ULL; +-static const uint64_t mask3216g __attribute__((aligned(8))) = 0x0000FC000000FC00ULL; +-static const uint64_t mask3215g __attribute__((aligned(8))) = 0x0000F8000000F800ULL; +-static const uint64_t mul3216 __attribute__((aligned(8))) = 0x2000000420000004ULL; +-static const uint64_t mul3215 __attribute__((aligned(8))) = 0x2000000820000008ULL; +-static const uint64_t mask24b attribute_used __attribute__((aligned(8))) = 0x00FF0000FF0000FFULL; +-static const uint64_t mask24g attribute_used __attribute__((aligned(8))) = 0xFF0000FF0000FF00ULL; +-static const uint64_t mask24r attribute_used __attribute__((aligned(8))) = 0x0000FF0000FF0000ULL; +-static const uint64_t mask24l __attribute__((aligned(8))) = 0x0000000000FFFFFFULL; +-static const uint64_t mask24h __attribute__((aligned(8))) = 0x0000FFFFFF000000ULL; +-static const uint64_t mask24hh __attribute__((aligned(8))) = 0xffff000000000000ULL; +-static const uint64_t mask24hhh __attribute__((aligned(8))) = 0xffffffff00000000ULL; +-static const uint64_t mask24hhhh __attribute__((aligned(8))) = 0xffffffffffff0000ULL; +-static const uint64_t mask15b __attribute__((aligned(8))) = 0x001F001F001F001FULL; /* 00000000 00011111 xxB */ +-static const uint64_t mask15rg __attribute__((aligned(8))) = 0x7FE07FE07FE07FE0ULL; /* 01111111 11100000 RGx */ +-static const uint64_t mask15s __attribute__((aligned(8))) = 0xFFE0FFE0FFE0FFE0ULL; +-static const uint64_t mask15g __attribute__((aligned(8))) = 0x03E003E003E003E0ULL; +-static const uint64_t mask15r __attribute__((aligned(8))) = 0x7C007C007C007C00ULL; ++DECLARE_ASM_CONST(8, uint64_t, mmx_null) = 0x0000000000000000ULL; ++DECLARE_ASM_CONST(8, uint64_t, mmx_one) = 0xFFFFFFFFFFFFFFFFULL; ++DECLARE_ASM_CONST(8, uint64_t, mask32b) = 0x000000FF000000FFULL; ++DECLARE_ASM_CONST(8, uint64_t, mask32g) = 0x0000FF000000FF00ULL; ++DECLARE_ASM_CONST(8, uint64_t, mask32r) = 0x00FF000000FF0000ULL; ++DECLARE_ASM_CONST(8, uint64_t, mask32) = 0x00FFFFFF00FFFFFFULL; ++DECLARE_ASM_CONST(8, uint64_t, mask3216br) = 0x00F800F800F800F8ULL; ++DECLARE_ASM_CONST(8, uint64_t, mask3216g) = 0x0000FC000000FC00ULL; ++DECLARE_ASM_CONST(8, uint64_t, mask3215g) = 0x0000F8000000F800ULL; ++DECLARE_ASM_CONST(8, uint64_t, mul3216) = 0x2000000420000004ULL; ++DECLARE_ASM_CONST(8, uint64_t, mul3215) = 0x2000000820000008ULL; ++DECLARE_ASM_CONST(8, uint64_t, mask24b) = 0x00FF0000FF0000FFULL; ++DECLARE_ASM_CONST(8, uint64_t, mask24g) = 0xFF0000FF0000FF00ULL; ++DECLARE_ASM_CONST(8, uint64_t, mask24r) = 0x0000FF0000FF0000ULL; ++DECLARE_ASM_CONST(8, uint64_t, mask24l) = 0x0000000000FFFFFFULL; ++DECLARE_ASM_CONST(8, uint64_t, mask24h) = 0x0000FFFFFF000000ULL; ++DECLARE_ASM_CONST(8, uint64_t, mask24hh) = 0xffff000000000000ULL; ++DECLARE_ASM_CONST(8, uint64_t, mask24hhh) = 0xffffffff00000000ULL; ++DECLARE_ASM_CONST(8, uint64_t, mask24hhhh) = 0xffffffffffff0000ULL; ++DECLARE_ASM_CONST(8, uint64_t, mask15b) = 0x001F001F001F001FULL; /* 00000000 00011111 xxB */ ++DECLARE_ASM_CONST(8, uint64_t, mask15rg) = 0x7FE07FE07FE07FE0ULL; /* 01111111 11100000 RGx */ ++DECLARE_ASM_CONST(8, uint64_t, mask15s) = 0xFFE0FFE0FFE0FFE0ULL; ++DECLARE_ASM_CONST(8, uint64_t, mask15g) = 0x03E003E003E003E0ULL; ++DECLARE_ASM_CONST(8, uint64_t, mask15r) = 0x7C007C007C007C00ULL; + #define mask16b mask15b +-static const uint64_t mask16g __attribute__((aligned(8))) = 0x07E007E007E007E0ULL; +-static const uint64_t mask16r __attribute__((aligned(8))) = 0xF800F800F800F800ULL; +-static const uint64_t red_16mask __attribute__((aligned(8))) = 0x0000f8000000f800ULL; +-static const uint64_t green_16mask __attribute__((aligned(8))) = 0x000007e0000007e0ULL; +-static const uint64_t blue_16mask __attribute__((aligned(8))) = 0x0000001f0000001fULL; +-static const uint64_t red_15mask __attribute__((aligned(8))) = 0x00007c0000007c00ULL; +-static const uint64_t green_15mask __attribute__((aligned(8))) = 0x000003e0000003e0ULL; +-static const uint64_t blue_15mask __attribute__((aligned(8))) = 0x0000001f0000001fULL; +- +-#ifdef FAST_BGR2YV12 +-static const uint64_t bgr2YCoeff attribute_used __attribute__((aligned(8))) = 0x000000210041000DULL; +-static const uint64_t bgr2UCoeff attribute_used __attribute__((aligned(8))) = 0x0000FFEEFFDC0038ULL; +-static const uint64_t bgr2VCoeff attribute_used __attribute__((aligned(8))) = 0x00000038FFD2FFF8ULL; +-#else +-static const uint64_t bgr2YCoeff attribute_used __attribute__((aligned(8))) = 0x000020E540830C8BULL; +-static const uint64_t bgr2UCoeff attribute_used __attribute__((aligned(8))) = 0x0000ED0FDAC23831ULL; +-static const uint64_t bgr2VCoeff attribute_used __attribute__((aligned(8))) = 0x00003831D0E6F6EAULL; +-#endif +-static const uint64_t bgr2YOffset attribute_used __attribute__((aligned(8))) = 0x1010101010101010ULL; +-static const uint64_t bgr2UVOffset attribute_used __attribute__((aligned(8))) = 0x8080808080808080ULL; +-static const uint64_t w1111 attribute_used __attribute__((aligned(8))) = 0x0001000100010001ULL; ++DECLARE_ASM_CONST(8, uint64_t, mask16g) = 0x07E007E007E007E0ULL; ++DECLARE_ASM_CONST(8, uint64_t, mask16r) = 0xF800F800F800F800ULL; ++DECLARE_ASM_CONST(8, uint64_t, red_16mask) = 0x0000f8000000f800ULL; ++DECLARE_ASM_CONST(8, uint64_t, green_16mask) = 0x000007e0000007e0ULL; ++DECLARE_ASM_CONST(8, uint64_t, blue_16mask) = 0x0000001f0000001fULL; ++DECLARE_ASM_CONST(8, uint64_t, red_15mask) = 0x00007c0000007c00ULL; ++DECLARE_ASM_CONST(8, uint64_t, green_15mask) = 0x000003e0000003e0ULL; ++DECLARE_ASM_CONST(8, uint64_t, blue_15mask) = 0x0000001f0000001fULL; + + #if 0 + static volatile uint64_t __attribute__((aligned(8))) b5Dither; +@@ -231,20 +218,20 @@ + + /* + for (i=0; i + +@@ -143,4 +143,4 @@ + + void sws_rgb2rgb_init(int flags); + +-#endif ++#endif /* FFMPEG_RGB2RGB_H */ +diff -u mplayer-1.0~rc2-12/libswscale/rgb2rgb_template.c ffmpeg-free-0.svn20080206/libswscale/rgb2rgb_template.c +--- mplayer-1.0~rc2-12/libswscale/rgb2rgb_template.c 2007-10-07 21:49:31.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libswscale/rgb2rgb_template.c 2008-01-29 15:58:10.000000000 +0100 +@@ -23,15 +23,15 @@ + * along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * +- * the C code (not assembly, mmx, ...) of this file can be used +- * under the LGPL license too ++ * The C code (not assembly, mmx, ...) of this file can be used ++ * under the LGPL license. + */ + + #include + #include /* for __WORDSIZE */ + + #ifndef __WORDSIZE +-// #warning You have misconfigured system and probably will lose performance! ++// #warning You have a misconfigured system and will probably lose performance! + #define __WORDSIZE MP_WORDSIZE + #endif + +@@ -53,7 +53,7 @@ + #define PREFETCH "prefetch" + #define PREFETCHW "prefetchw" + #define PAVGB "pavgusb" +-#elif defined ( HAVE_MMX2 ) ++#elif defined (HAVE_MMX2) + #define PREFETCH "prefetchnta" + #define PREFETCHW "prefetcht0" + #define PAVGB "pavgb" +@@ -68,7 +68,7 @@ + #endif + + #ifdef HAVE_3DNOW +-/* On K6 femms is faster of emms. On K7 femms is directly mapped on emms. */ ++/* On K6 femms is faster than emms. On K7 femms is directly mapped on emms. */ + #define EMMS "femms" + #else + #define EMMS "emms" +@@ -82,7 +82,7 @@ + #define SFENCE " # nop" + #endif + +-static inline void RENAME(rgb24to32)(const uint8_t *src,uint8_t *dst,long src_size) ++static inline void RENAME(rgb24to32)(const uint8_t *src, uint8_t *dst, long src_size) + { + uint8_t *dest = dst; + const uint8_t *s = src; +@@ -142,7 +142,7 @@ + } + } + +-static inline void RENAME(rgb32to24)(const uint8_t *src,uint8_t *dst,long src_size) ++static inline void RENAME(rgb32to24)(const uint8_t *src, uint8_t *dst, long src_size) + { + uint8_t *dest = dst; + const uint8_t *s = src; +@@ -232,9 +232,9 @@ + Original by Strepto/Astral + ported to gcc & bugfixed : A'rpi + MMX2, 3DNOW optimization by Nick Kurshev +- 32bit c version, and and&add trick by Michael Niedermayer ++ 32 bit C version, and and&add trick by Michael Niedermayer + */ +-static inline void RENAME(rgb15to16)(const uint8_t *src,uint8_t *dst,long src_size) ++static inline void RENAME(rgb15to16)(const uint8_t *src, uint8_t *dst, long src_size) + { + register const uint8_t* s=src; + register uint8_t* d=dst; +@@ -283,7 +283,7 @@ + } + } + +-static inline void RENAME(rgb16to15)(const uint8_t *src,uint8_t *dst,long src_size) ++static inline void RENAME(rgb16to15)(const uint8_t *src, uint8_t *dst, long src_size) + { + register const uint8_t* s=src; + register uint8_t* d=dst; +@@ -350,7 +350,7 @@ + end = s + src_size; + #ifdef HAVE_MMX + mm_end = end - 15; +-#if 1 //is faster only if multiplies are reasonable fast (FIXME figure out on which CPUs this is faster, on Athlon it is slightly faster) ++#if 1 //is faster only if multiplies are reasonably fast (FIXME figure out on which CPUs this is faster, on Athlon it is slightly faster) + asm volatile( + "movq %3, %%mm5 \n\t" + "movq %4, %%mm6 \n\t" +@@ -509,7 +509,7 @@ + end = s + src_size; + #ifdef HAVE_MMX + mm_end = end - 15; +-#if 1 //is faster only if multiplies are reasonable fast (FIXME figure out on which CPUs this is faster, on Athlon it is slightly faster) ++#if 1 //is faster only if multiplies are reasonably fast (FIXME figure out on which CPUs this is faster, on Athlon it is slightly faster) + asm volatile( + "movq %3, %%mm5 \n\t" + "movq %4, %%mm6 \n\t" +@@ -910,12 +910,10 @@ + } + + /* +- I use here less accurate approximation by simply +- left-shifting the input +- value and filling the low order bits with +- zeroes. This method improves png's +- compression but this scheme cannot reproduce white exactly, since it does not +- generate an all-ones maximum value; the net effect is to darken the ++ I use less accurate approximation here by simply left-shifting the input ++ value and filling the low order bits with zeroes. This method improves PNG ++ compression but this scheme cannot reproduce white exactly, since it does ++ not generate an all-ones maximum value; the net effect is to darken the + image slightly. + + The better method should be "left bit replication": +@@ -1271,7 +1269,7 @@ + #endif + while (s < end) + { +-#if 0 //slightly slower on athlon ++#if 0 //slightly slower on Athlon + int bgr= *s++; + *((uint32_t*)d)++ = ((bgr&0x1F)<<3) + ((bgr&0x3E0)<<6) + ((bgr&0x7C00)<<9); + #else +@@ -1507,7 +1505,7 @@ + for (y=0; yyuy2 ++//FIXME adapt the Alpha ASM code from yv12->yuy2 + + #if __WORDSIZE >= 64 + int i; +@@ -1730,7 +1727,7 @@ + } + #endif + #endif +- if ((y&(vertLumPerChroma-1))==(vertLumPerChroma-1) ) ++ if ((y&(vertLumPerChroma-1)) == vertLumPerChroma-1) + { + usrc += chromStride; + vsrc += chromStride; +@@ -1746,9 +1743,8 @@ + } + + /** +- * +- * height should be a multiple of 2 and width should be a multiple of 16 (if this is a +- * problem for anyone then tell me, and ill fix it) ++ * Height should be a multiple of 2 and width should be a multiple of 16 (if ++ * this is a problem for anyone then tell me, and I will fix it). + */ + static inline void RENAME(yv12touyvy)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst, + long width, long height, +@@ -1759,8 +1755,7 @@ + } + + /** +- * +- * width should be a multiple of 16 ++ * Width should be a multiple of 16. + */ + static inline void RENAME(yuv422ptoyuy2)(const uint8_t *ysrc, const uint8_t *usrc, const uint8_t *vsrc, uint8_t *dst, + long width, long height, +@@ -1770,9 +1765,8 @@ + } + + /** +- * +- * height should be a multiple of 2 and width should be a multiple of 16 (if this is a +- * problem for anyone then tell me, and ill fix it) ++ * Height should be a multiple of 2 and width should be a multiple of 16 (if ++ * this is a problem for anyone then tell me, and I will fix it). + */ + static inline void RENAME(yuy2toyv12)(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst, + long width, long height, +@@ -2007,10 +2001,10 @@ + } + + /** +- * +- * height should be a multiple of 2 and width should be a multiple of 16 (if this is a +- * problem for anyone then tell me, and ill fix it) +- * chrominance data is only taken from every secound line others are ignored FIXME write HQ version ++ * Height should be a multiple of 2 and width should be a multiple of 16 (if ++ * this is a problem for anyone then tell me, and I will fix it). ++ * Chrominance data is only taken from every secound line, others are ignored. ++ * FIXME: Write HQ version. + */ + static inline void RENAME(uyvytoyv12)(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst, + long width, long height, +@@ -2133,10 +2127,11 @@ + } + + /** +- * +- * height should be a multiple of 2 and width should be a multiple of 2 (if this is a +- * problem for anyone then tell me, and ill fix it) +- * chrominance data is only taken from every secound line others are ignored in the C version FIXME write HQ version ++ * Height should be a multiple of 2 and width should be a multiple of 2 (if ++ * this is a problem for anyone then tell me, and I will fix it). ++ * Chrominance data is only taken from every secound line, ++ * others are ignored in the C version. ++ * FIXME: Write HQ version. + */ + static inline void RENAME(rgb24toyv12)(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst, + long width, long height, +@@ -2152,8 +2147,8 @@ + { + asm volatile( + "mov %2, %%"REG_a" \n\t" +- "movq "MANGLE(bgr2YCoeff)", %%mm6 \n\t" +- "movq "MANGLE(w1111)", %%mm5 \n\t" ++ "movq "MANGLE(ff_bgr2YCoeff)", %%mm6 \n\t" ++ "movq "MANGLE(ff_w1111)", %%mm5 \n\t" + "pxor %%mm7, %%mm7 \n\t" + "lea (%%"REG_a", %%"REG_a", 2), %%"REG_d" \n\t" + ASMALIGN(4) +@@ -2211,7 +2206,7 @@ + "psraw $7, %%mm4 \n\t" + + "packuswb %%mm4, %%mm0 \n\t" +- "paddusb "MANGLE(bgr2YOffset)", %%mm0 \n\t" ++ "paddusb "MANGLE(ff_bgr2YOffset)", %%mm0 \n\t" + + MOVNTQ" %%mm0, (%1, %%"REG_a") \n\t" + "add $8, %%"REG_a" \n\t" +@@ -2225,8 +2220,8 @@ + src -= srcStride*2; + asm volatile( + "mov %4, %%"REG_a" \n\t" +- "movq "MANGLE(w1111)", %%mm5 \n\t" +- "movq "MANGLE(bgr2UCoeff)", %%mm6 \n\t" ++ "movq "MANGLE(ff_w1111)", %%mm5 \n\t" ++ "movq "MANGLE(ff_bgr2UCoeff)", %%mm6 \n\t" + "pxor %%mm7, %%mm7 \n\t" + "lea (%%"REG_a", %%"REG_a", 2), %%"REG_d" \n\t" + "add %%"REG_d", %%"REG_d" \n\t" +@@ -2275,8 +2270,8 @@ + "psrlw $2, %%mm0 \n\t" + "psrlw $2, %%mm2 \n\t" + #endif +- "movq "MANGLE(bgr2VCoeff)", %%mm1 \n\t" +- "movq "MANGLE(bgr2VCoeff)", %%mm3 \n\t" ++ "movq "MANGLE(ff_bgr2VCoeff)", %%mm1 \n\t" ++ "movq "MANGLE(ff_bgr2VCoeff)", %%mm3 \n\t" + + "pmaddwd %%mm0, %%mm1 \n\t" + "pmaddwd %%mm2, %%mm3 \n\t" +@@ -2333,12 +2328,12 @@ + "paddw %%mm1, %%mm5 \n\t" + "paddw %%mm3, %%mm2 \n\t" + "paddw %%mm5, %%mm2 \n\t" +- "movq "MANGLE(w1111)", %%mm5 \n\t" ++ "movq "MANGLE(ff_w1111)", %%mm5 \n\t" + "psrlw $2, %%mm4 \n\t" + "psrlw $2, %%mm2 \n\t" + #endif +- "movq "MANGLE(bgr2VCoeff)", %%mm1 \n\t" +- "movq "MANGLE(bgr2VCoeff)", %%mm3 \n\t" ++ "movq "MANGLE(ff_bgr2VCoeff)", %%mm1 \n\t" ++ "movq "MANGLE(ff_bgr2VCoeff)", %%mm3 \n\t" + + "pmaddwd %%mm4, %%mm1 \n\t" + "pmaddwd %%mm2, %%mm3 \n\t" +@@ -2362,7 +2357,7 @@ + "punpckldq %%mm4, %%mm0 \n\t" + "punpckhdq %%mm4, %%mm1 \n\t" + "packsswb %%mm1, %%mm0 \n\t" +- "paddb "MANGLE(bgr2UVOffset)", %%mm0 \n\t" ++ "paddb "MANGLE(ff_bgr2UVOffset)", %%mm0 \n\t" + "movd %%mm0, (%2, %%"REG_a") \n\t" + "punpckhdq %%mm0, %%mm0 \n\t" + "movd %%mm0, (%3, %%"REG_a") \n\t" +diff -u mplayer-1.0~rc2-12/libswscale/swscale_altivec_template.c ffmpeg-free-0.svn20080206/libswscale/swscale_altivec_template.c +--- mplayer-1.0~rc2-12/libswscale/swscale_altivec_template.c 2007-10-07 21:49:31.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libswscale/swscale_altivec_template.c 2008-01-17 12:07:27.000000000 +0100 +@@ -27,10 +27,10 @@ + altivec_packIntArrayToCharArray(int *val, uint8_t* dest, int dstW) { + register int i; + vector unsigned int altivec_vectorShiftInt19 = +- vec_add(vec_splat_u32(10),vec_splat_u32(9)); ++ vec_add(vec_splat_u32(10), vec_splat_u32(9)); + if ((unsigned long)dest % 16) { +- /* badly aligned store, we force store alignement */ +- /* and will handle load misalignement on val w/ vec_perm */ ++ /* badly aligned store, we force store alignment */ ++ /* and will handle load misalignment on val w/ vec_perm */ + vector unsigned char perm1; + vector signed int v1; + for (i = 0 ; (i < dstW) && +@@ -46,10 +46,10 @@ + vector signed int v3 = vec_ld(offset + 32, val); + vector signed int v4 = vec_ld(offset + 48, val); + vector signed int v5 = vec_ld(offset + 64, val); +- vector signed int v12 = vec_perm(v1,v2,perm1); +- vector signed int v23 = vec_perm(v2,v3,perm1); +- vector signed int v34 = vec_perm(v3,v4,perm1); +- vector signed int v45 = vec_perm(v4,v5,perm1); ++ vector signed int v12 = vec_perm(v1, v2, perm1); ++ vector signed int v23 = vec_perm(v2, v3, perm1); ++ vector signed int v34 = vec_perm(v3, v4, perm1); ++ vector signed int v45 = vec_perm(v4, v5, perm1); + + vector signed int vA = vec_sra(v12, altivec_vectorShiftInt19); + vector signed int vB = vec_sra(v23, altivec_vectorShiftInt19); +@@ -137,7 +137,7 @@ + val[i] += lumSrc[j][i] * lumFilter[j]; + } + } +- altivec_packIntArrayToCharArray(val,dest,dstW); ++ altivec_packIntArrayToCharArray(val, dest, dstW); + } + if (uDest != 0) { + int __attribute__ ((aligned (16))) u[chrDstW]; +@@ -203,8 +203,8 @@ + v[i] += chrSrc[j][i + 2048] * chrFilter[j]; + } + } +- altivec_packIntArrayToCharArray(u,uDest,chrDstW); +- altivec_packIntArrayToCharArray(v,vDest,chrDstW); ++ altivec_packIntArrayToCharArray(u, uDest, chrDstW); ++ altivec_packIntArrayToCharArray(v, vDest, chrDstW); + } + } + +@@ -252,9 +252,9 @@ + // and we're going to use vec_mule, so we chose + // carefully how to "unpack" the elements into the even slots + if ((i << 3) % 16) +- filter_v = vec_mergel(filter_v,(vector signed short)vzero); ++ filter_v = vec_mergel(filter_v, (vector signed short)vzero); + else +- filter_v = vec_mergeh(filter_v,(vector signed short)vzero); ++ filter_v = vec_mergeh(filter_v, (vector signed short)vzero); + + val_vEven = vec_mule(src_v, filter_v); + val_s = vec_sums(val_vEven, vzero); +@@ -354,7 +354,7 @@ + src_v0 = src_v1; + } + +- if (j < (filterSize-7)) { ++ if (j < filterSize-7) { + // loading src_v0 is useless, it's already done above + //vector unsigned char src_v0 = vec_ld(srcPos + j, src); + vector unsigned char src_v1, src_vF; +@@ -387,7 +387,7 @@ + static inline int yv12toyuy2_unscaled_altivec(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, + int srcSliceH, uint8_t* dstParam[], int dstStride_a[]) { + uint8_t *dst=dstParam[0] + dstStride_a[0]*srcSliceY; +- // yv12toyuy2( src[0],src[1],src[2],dst,c->srcW,srcSliceH,srcStride[0],srcStride[1],dstStride[0] ); ++ // yv12toyuy2(src[0], src[1], src[2], dst, c->srcW, srcSliceH, srcStride[0], srcStride[1], dstStride[0]); + uint8_t *ysrc = src[0]; + uint8_t *usrc = src[1]; + uint8_t *vsrc = src[2]; +@@ -401,7 +401,7 @@ + register unsigned int y; + + if (width&15) { +- yv12toyuy2( ysrc, usrc, vsrc, dst,c->srcW,srcSliceH, lumStride, chromStride, dstStride); ++ yv12toyuy2(ysrc, usrc, vsrc, dst, c->srcW, srcSliceH, lumStride, chromStride, dstStride); + return srcSliceH; + } + +@@ -450,7 +450,7 @@ + vec_st(v_yuy2_0, (i << 1), dst); + vec_st(v_yuy2_1, (i << 1) + 16, dst); + } +- if ( (y&(vertLumPerChroma-1))==(vertLumPerChroma-1) ) { ++ if ((y&(vertLumPerChroma-1)) == vertLumPerChroma-1) { + usrc += chromStride; + vsrc += chromStride; + } +@@ -464,7 +464,7 @@ + static inline int yv12touyvy_unscaled_altivec(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, + int srcSliceH, uint8_t* dstParam[], int dstStride_a[]) { + uint8_t *dst=dstParam[0] + dstStride_a[0]*srcSliceY; +- // yv12toyuy2( src[0],src[1],src[2],dst,c->srcW,srcSliceH,srcStride[0],srcStride[1],dstStride[0] ); ++ // yv12toyuy2(src[0], src[1], src[2], dst, c->srcW, srcSliceH, srcStride[0], srcStride[1], dstStride[0]); + uint8_t *ysrc = src[0]; + uint8_t *usrc = src[1]; + uint8_t *vsrc = src[2]; +@@ -478,7 +478,7 @@ + register unsigned int y; + + if (width&15) { +- yv12touyvy( ysrc, usrc, vsrc, dst,c->srcW,srcSliceH, lumStride, chromStride, dstStride); ++ yv12touyvy(ysrc, usrc, vsrc, dst, c->srcW, srcSliceH, lumStride, chromStride, dstStride); + return srcSliceH; + } + +@@ -527,7 +527,7 @@ + vec_st(v_uyvy_0, (i << 1), dst); + vec_st(v_uyvy_1, (i << 1) + 16, dst); + } +- if ( (y&(vertLumPerChroma-1))==(vertLumPerChroma-1) ) { ++ if ((y&(vertLumPerChroma-1)) == vertLumPerChroma-1) { + usrc += chromStride; + vsrc += chromStride; + } +diff -u mplayer-1.0~rc2-12/libswscale/swscale.c ffmpeg-free-0.svn20080206/libswscale/swscale.c +--- mplayer-1.0~rc2-12/libswscale/swscale.c 2007-10-07 21:49:31.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libswscale/swscale.c 2008-06-18 12:09:30.000000000 +0200 +@@ -180,14 +180,14 @@ + */ + + #if defined(ARCH_X86) && defined (CONFIG_GPL) +-static uint64_t attribute_used __attribute__((aligned(8))) bF8= 0xF8F8F8F8F8F8F8F8LL; +-static uint64_t attribute_used __attribute__((aligned(8))) bFC= 0xFCFCFCFCFCFCFCFCLL; +-static uint64_t __attribute__((aligned(8))) w10= 0x0010001000100010LL; +-static uint64_t attribute_used __attribute__((aligned(8))) w02= 0x0002000200020002LL; +-static uint64_t attribute_used __attribute__((aligned(8))) bm00001111=0x00000000FFFFFFFFLL; +-static uint64_t attribute_used __attribute__((aligned(8))) bm00000111=0x0000000000FFFFFFLL; +-static uint64_t attribute_used __attribute__((aligned(8))) bm11111000=0xFFFFFFFFFF000000LL; +-static uint64_t attribute_used __attribute__((aligned(8))) bm01010101=0x00FF00FF00FF00FFLL; ++DECLARE_ASM_CONST(8, uint64_t, bF8)= 0xF8F8F8F8F8F8F8F8LL; ++DECLARE_ASM_CONST(8, uint64_t, bFC)= 0xFCFCFCFCFCFCFCFCLL; ++DECLARE_ASM_CONST(8, uint64_t, w10)= 0x0010001000100010LL; ++DECLARE_ASM_CONST(8, uint64_t, w02)= 0x0002000200020002LL; ++DECLARE_ASM_CONST(8, uint64_t, bm00001111)=0x00000000FFFFFFFFLL; ++DECLARE_ASM_CONST(8, uint64_t, bm00000111)=0x0000000000FFFFFFLL; ++DECLARE_ASM_CONST(8, uint64_t, bm11111000)=0xFFFFFFFFFF000000LL; ++DECLARE_ASM_CONST(8, uint64_t, bm01010101)=0x00FF00FF00FF00FFLL; + + static volatile uint64_t attribute_used __attribute__((aligned(8))) b5Dither; + static volatile uint64_t attribute_used __attribute__((aligned(8))) g5Dither; +@@ -202,29 +202,29 @@ + 0x0602060206020602LL, + 0x0004000400040004LL,}; + +-static uint64_t __attribute__((aligned(8))) b16Mask= 0x001F001F001F001FLL; +-static uint64_t attribute_used __attribute__((aligned(8))) g16Mask= 0x07E007E007E007E0LL; +-static uint64_t attribute_used __attribute__((aligned(8))) r16Mask= 0xF800F800F800F800LL; +-static uint64_t __attribute__((aligned(8))) b15Mask= 0x001F001F001F001FLL; +-static uint64_t attribute_used __attribute__((aligned(8))) g15Mask= 0x03E003E003E003E0LL; +-static uint64_t attribute_used __attribute__((aligned(8))) r15Mask= 0x7C007C007C007C00LL; +- +-static uint64_t attribute_used __attribute__((aligned(8))) M24A= 0x00FF0000FF0000FFLL; +-static uint64_t attribute_used __attribute__((aligned(8))) M24B= 0xFF0000FF0000FF00LL; +-static uint64_t attribute_used __attribute__((aligned(8))) M24C= 0x0000FF0000FF0000LL; ++DECLARE_ASM_CONST(8, uint64_t, b16Mask)= 0x001F001F001F001FLL; ++DECLARE_ASM_CONST(8, uint64_t, g16Mask)= 0x07E007E007E007E0LL; ++DECLARE_ASM_CONST(8, uint64_t, r16Mask)= 0xF800F800F800F800LL; ++DECLARE_ASM_CONST(8, uint64_t, b15Mask)= 0x001F001F001F001FLL; ++DECLARE_ASM_CONST(8, uint64_t, g15Mask)= 0x03E003E003E003E0LL; ++DECLARE_ASM_CONST(8, uint64_t, r15Mask)= 0x7C007C007C007C00LL; ++ ++DECLARE_ALIGNED(8, const uint64_t, ff_M24A) = 0x00FF0000FF0000FFLL; ++DECLARE_ALIGNED(8, const uint64_t, ff_M24B) = 0xFF0000FF0000FF00LL; ++DECLARE_ALIGNED(8, const uint64_t, ff_M24C) = 0x0000FF0000FF0000LL; + + #ifdef FAST_BGR2YV12 +-static const uint64_t bgr2YCoeff attribute_used __attribute__((aligned(8))) = 0x000000210041000DULL; +-static const uint64_t bgr2UCoeff attribute_used __attribute__((aligned(8))) = 0x0000FFEEFFDC0038ULL; +-static const uint64_t bgr2VCoeff attribute_used __attribute__((aligned(8))) = 0x00000038FFD2FFF8ULL; ++DECLARE_ALIGNED(8, const uint64_t, ff_bgr2YCoeff) = 0x000000210041000DULL; ++DECLARE_ALIGNED(8, const uint64_t, ff_bgr2UCoeff) = 0x0000FFEEFFDC0038ULL; ++DECLARE_ALIGNED(8, const uint64_t, ff_bgr2VCoeff) = 0x00000038FFD2FFF8ULL; + #else +-static const uint64_t bgr2YCoeff attribute_used __attribute__((aligned(8))) = 0x000020E540830C8BULL; +-static const uint64_t bgr2UCoeff attribute_used __attribute__((aligned(8))) = 0x0000ED0FDAC23831ULL; +-static const uint64_t bgr2VCoeff attribute_used __attribute__((aligned(8))) = 0x00003831D0E6F6EAULL; ++DECLARE_ALIGNED(8, const uint64_t, ff_bgr2YCoeff) = 0x000020E540830C8BULL; ++DECLARE_ALIGNED(8, const uint64_t, ff_bgr2UCoeff) = 0x0000ED0FDAC23831ULL; ++DECLARE_ALIGNED(8, const uint64_t, ff_bgr2VCoeff) = 0x00003831D0E6F6EAULL; + #endif /* FAST_BGR2YV12 */ +-static const uint64_t bgr2YOffset attribute_used __attribute__((aligned(8))) = 0x1010101010101010ULL; +-static const uint64_t bgr2UVOffset attribute_used __attribute__((aligned(8))) = 0x8080808080808080ULL; +-static const uint64_t w1111 attribute_used __attribute__((aligned(8))) = 0x0001000100010001ULL; ++DECLARE_ALIGNED(8, const uint64_t, ff_bgr2YOffset) = 0x1010101010101010ULL; ++DECLARE_ALIGNED(8, const uint64_t, ff_bgr2UVOffset) = 0x8080808080808080ULL; ++DECLARE_ALIGNED(8, const uint64_t, ff_w1111) = 0x0001000100010001ULL; + #endif /* defined(ARCH_X86) */ + + // clipping helper table for C implementations: +@@ -367,7 +367,7 @@ + { + volatile int i= bF8+bFC+w10+ + bm00001111+bm00000111+bm11111000+b16Mask+g16Mask+r16Mask+b15Mask+g15Mask+r15Mask+ +- M24A+M24B+M24C+w02 + b5Dither+g5Dither+r5Dither+g6Dither+dither4[0]+dither8[0]+bm01010101; ++ ff_M24A+ff_M24B+ff_M24C+w02 + b5Dither+g5Dither+r5Dither+g6Dither+dither4[0]+dither8[0]+bm01010101; + if (i) i=0; + } + #endif +@@ -388,7 +388,7 @@ + dest[i]= av_clip_uint8(val>>19); + } + +- if (uDest != NULL) ++ if (uDest) + for (i=0; i>19); + } + +- if (uDest == NULL) ++ if (!uDest) + return; + + if (dstFormat == PIX_FMT_NV12) +@@ -1357,7 +1357,7 @@ + return 0; + } + +-#ifdef COMPILE_MMX2 ++#if defined (COMPILE_MMX2) && !defined(ARCH_X86_64) + static void initMMX2HScaler(int dstW, int xInc, uint8_t *funnyCode, int16_t *filter, int32_t *filterPos, int numSplits) + { + uint8_t *fragmentA; +@@ -1543,7 +1543,7 @@ + + #if defined(RUNTIME_CPUDETECT) && defined (CONFIG_GPL) + #if defined(ARCH_X86) +- // ordered per speed fasterst first ++ // ordered per speed fastest first + if (flags & SWS_CPU_CAPS_MMX2) + return swScale_MMX2; + else if (flags & SWS_CPU_CAPS_3DNOW) +@@ -1597,9 +1597,9 @@ + } + dst = dstParam[1] + dstStride[1]*srcSliceY/2; + if (c->dstFormat == PIX_FMT_NV12) +- interleaveBytes( src[1],src[2],dst,c->srcW/2,srcSliceH/2,srcStride[1],srcStride[2],dstStride[0] ); ++ interleaveBytes(src[1], src[2], dst, c->srcW/2, srcSliceH/2, srcStride[1], srcStride[2], dstStride[0]); + else +- interleaveBytes( src[2],src[1],dst,c->srcW/2,srcSliceH/2,srcStride[2],srcStride[1],dstStride[0] ); ++ interleaveBytes(src[2], src[1], dst, c->srcW/2, srcSliceH/2, srcStride[2], srcStride[1], dstStride[0]); + + return srcSliceH; + } +@@ -1608,7 +1608,7 @@ + int srcSliceH, uint8_t* dstParam[], int dstStride[]){ + uint8_t *dst=dstParam[0] + dstStride[0]*srcSliceY; + +- yv12toyuy2( src[0],src[1],src[2],dst,c->srcW,srcSliceH,srcStride[0],srcStride[1],dstStride[0] ); ++ yv12toyuy2(src[0], src[1], src[2], dst, c->srcW, srcSliceH, srcStride[0], srcStride[1], dstStride[0]); + + return srcSliceH; + } +@@ -1617,7 +1617,7 @@ + int srcSliceH, uint8_t* dstParam[], int dstStride[]){ + uint8_t *dst=dstParam[0] + dstStride[0]*srcSliceY; + +- yv12touyvy( src[0],src[1],src[2],dst,c->srcW,srcSliceH,srcStride[0],srcStride[1],dstStride[0] ); ++ yv12touyvy(src[0], src[1], src[2], dst, c->srcW, srcSliceH, srcStride[0], srcStride[1], dstStride[0]); + + return srcSliceH; + } +@@ -1681,7 +1681,7 @@ + + if(conv) + { +- if (dstStride[0]*srcBpp == srcStride[0]*dstBpp) ++ if (dstStride[0]*srcBpp == srcStride[0]*dstBpp && srcStride[0] > 0) + conv(src[0], dst[0] + dstStride[0]*srcSliceY, srcSliceH*srcStride[0]); + else + { +@@ -2050,7 +2050,7 @@ + #endif + #endif /* RUNTIME_CPUDETECT */ + if (clip_table[512] != 255) globalInit(); +- if (rgb15to16 == NULL) sws_rgb2rgb_init(flags); ++ if (!rgb15to16) sws_rgb2rgb_init(flags); + + unscaled = (srcW == dstW && srcH == dstH); + needsDither= (isBGR(dstFormat) || isRGB(dstFormat)) +@@ -2097,14 +2097,14 @@ + c->vRounder= 4* 0x0001000100010001ULL; + + usesHFilter= usesVFilter= 0; +- if (dstFilter->lumV!=NULL && dstFilter->lumV->length>1) usesVFilter=1; +- if (dstFilter->lumH!=NULL && dstFilter->lumH->length>1) usesHFilter=1; +- if (dstFilter->chrV!=NULL && dstFilter->chrV->length>1) usesVFilter=1; +- if (dstFilter->chrH!=NULL && dstFilter->chrH->length>1) usesHFilter=1; +- if (srcFilter->lumV!=NULL && srcFilter->lumV->length>1) usesVFilter=1; +- if (srcFilter->lumH!=NULL && srcFilter->lumH->length>1) usesHFilter=1; +- if (srcFilter->chrV!=NULL && srcFilter->chrV->length>1) usesVFilter=1; +- if (srcFilter->chrH!=NULL && srcFilter->chrH->length>1) usesHFilter=1; ++ if (dstFilter->lumV && dstFilter->lumV->length>1) usesVFilter=1; ++ if (dstFilter->lumH && dstFilter->lumH->length>1) usesHFilter=1; ++ if (dstFilter->chrV && dstFilter->chrV->length>1) usesVFilter=1; ++ if (dstFilter->chrH && dstFilter->chrH->length>1) usesHFilter=1; ++ if (srcFilter->lumV && srcFilter->lumV->length>1) usesVFilter=1; ++ if (srcFilter->lumH && srcFilter->lumH->length>1) usesHFilter=1; ++ if (srcFilter->chrV && srcFilter->chrV->length>1) usesVFilter=1; ++ if (srcFilter->chrH && srcFilter->chrH->length>1) usesHFilter=1; + + getSubSampleFactors(&c->chrSrcHSubSample, &c->chrSrcVSubSample, srcFormat); + getSubSampleFactors(&c->chrDstHSubSample, &c->chrDstVSubSample, dstFormat); +@@ -2158,7 +2158,7 @@ + } + #endif + +- if ( srcFormat==PIX_FMT_YUV410P && dstFormat==PIX_FMT_YUV420P ) ++ if (srcFormat==PIX_FMT_YUV410P && dstFormat==PIX_FMT_YUV420P) + { + c->swScale= yvu9toyv12Wrapper; + } +@@ -2214,7 +2214,7 @@ + /* simple copy */ + if ( srcFormat == dstFormat + || (isPlanarYUV(srcFormat) && isGray(dstFormat)) +- || (isPlanarYUV(dstFormat) && isGray(srcFormat)) ) ++ || (isPlanarYUV(dstFormat) && isGray(srcFormat))) + { + c->swScale= simpleCopy; + } +@@ -2300,7 +2300,7 @@ + srcFilter->chrH, dstFilter->chrH, c->param); + + #define MAX_FUNNY_CODE_SIZE 10000 +-#if defined(COMPILE_MMX2) ++#if defined (COMPILE_MMX2) && !defined(ARCH_X86_64) + // can't downscale !!! + if (c->canMMX2BeUsed && (flags & SWS_FAST_BILINEAR)) + { +@@ -2373,7 +2373,7 @@ + nextSlice>>= c->chrSrcVSubSample; + nextSlice<<= c->chrSrcVSubSample; + if (c->vLumFilterPos[i ] + c->vLumBufSize < nextSlice) +- c->vLumBufSize= nextSlice - c->vLumFilterPos[i ]; ++ c->vLumBufSize= nextSlice - c->vLumFilterPos[i]; + if (c->vChrFilterPos[chrI] + c->vChrBufSize < (nextSlice>>c->chrSrcVSubSample)) + c->vChrBufSize= (nextSlice>>c->chrSrcVSubSample) - c->vChrFilterPos[chrI]; + } +@@ -2489,7 +2489,7 @@ + { + if (c->vLumFilterSize==1 && c->vChrFilterSize==2) + av_log(c, AV_LOG_VERBOSE, "SwScaler: using 1-tap %s \"scaler\" for vertical luminance scaling (BGR)\n" +- "SwScaler: 2-tap scaler for vertical chrominance scaling (BGR)\n",(flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C"); ++ "SwScaler: 2-tap scaler for vertical chrominance scaling (BGR)\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C"); + else if (c->vLumFilterSize==2 && c->vChrFilterSize==2) + av_log(c, AV_LOG_VERBOSE, "SwScaler: using 2-tap linear %s scaler for vertical scaling (BGR)\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C"); + else +@@ -2521,7 +2521,7 @@ + } + + /** +- * swscale warper, so we don't need to export the SwsContext. ++ * swscale wrapper, so we don't need to export the SwsContext. + * assumes planar YUV to be in YUV order instead of YVU + */ + int sws_scale(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, +@@ -2575,7 +2575,7 @@ + } + + /** +- * swscale warper, so we don't need to export the SwsContext ++ * swscale wrapper, so we don't need to export the SwsContext + */ + int sws_scale_ordered(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, + int srcSliceH, uint8_t* dst[], int dstStride[]){ +@@ -2657,7 +2657,7 @@ + for (i=0; isrcW != srcW) || (context->srcH != srcH) || +- (context->srcFormat != srcFormat) || +- (context->dstW != dstW) || (context->dstH != dstH) || +- (context->dstFormat != dstFormat) || (context->flags != flags) || +- (context->param != param)) ++ static const double default_param[2] = {SWS_PARAM_DEFAULT, SWS_PARAM_DEFAULT}; ++ ++ if (!param) ++ param = default_param; ++ ++ if (context) { ++ if (context->srcW != srcW || context->srcH != srcH || ++ context->srcFormat != srcFormat || ++ context->dstW != dstW || context->dstH != dstH || ++ context->dstFormat != dstFormat || context->flags != flags || ++ context->param[0] != param[0] || context->param[1] != param[1]) + { + sws_freeContext(context); + context = NULL; + } + } +- if (context == NULL) { ++ if (!context) { + return sws_getContext(srcW, srcH, srcFormat, + dstW, dstH, dstFormat, flags, + srcFilter, dstFilter, param); +diff -u mplayer-1.0~rc2-12/libswscale/swscale-example.c ffmpeg-free-0.svn20080206/libswscale/swscale-example.c +--- mplayer-1.0~rc2-12/libswscale/swscale-example.c 2007-10-07 21:49:31.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libswscale/swscale-example.c 2008-01-17 16:49:31.000000000 +0100 +@@ -76,7 +76,7 @@ + src[i]= (uint8_t*) malloc(srcStride[i]*srcH); + dst[i]= (uint8_t*) malloc(dstStride[i]*dstH); + out[i]= (uint8_t*) malloc(refStride[i]*h); +- if ((src[i] == NULL) || (dst[i] == NULL) || (out[i] == NULL)) { ++ if (!src[i] || !dst[i] || !out[i]) { + perror("Malloc"); + res = -1; + +@@ -86,7 +86,7 @@ + + dstContext = outContext = NULL; + srcContext= sws_getContext(w, h, PIX_FMT_YUV420P, srcW, srcH, srcFormat, flags, NULL, NULL, NULL); +- if (srcContext == NULL) { ++ if (!srcContext) { + fprintf(stderr, "Failed to get %s ---> %s\n", + sws_format_name(PIX_FMT_YUV420P), + sws_format_name(srcFormat)); +@@ -95,7 +95,7 @@ + goto end; + } + dstContext= sws_getContext(srcW, srcH, srcFormat, dstW, dstH, dstFormat, flags, NULL, NULL, NULL); +- if (dstContext == NULL) { ++ if (!dstContext) { + fprintf(stderr, "Failed to get %s ---> %s\n", + sws_format_name(srcFormat), + sws_format_name(dstFormat)); +@@ -104,7 +104,7 @@ + goto end; + } + outContext= sws_getContext(dstW, dstH, dstFormat, w, h, PIX_FMT_YUV420P, flags, NULL, NULL, NULL); +- if (outContext == NULL) { ++ if (!outContext) { + fprintf(stderr, "Failed to get %s ---> %s\n", + sws_format_name(dstFormat), + sws_format_name(PIX_FMT_YUV420P)); +@@ -217,13 +217,13 @@ + #else + sws_rgb2rgb_init(0); + #endif +- sws_scale(sws, rgb_src, rgb_stride, 0, H , src, stride); ++ sws_scale(sws, rgb_src, rgb_stride, 0, H, src, stride); + + #if defined(ARCH_X86) + asm volatile ("emms\n\t"); + #endif + +- selfTest(src, stride, W, H); ++ selfTest(src, stride, W, H); + + return 123; + } +diff -u mplayer-1.0~rc2-12/libswscale/swscale.h ffmpeg-free-0.svn20080206/libswscale/swscale.h +--- mplayer-1.0~rc2-12/libswscale/swscale.h 2007-10-07 21:49:31.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libswscale/swscale.h 2007-10-18 11:30:33.000000000 +0200 +@@ -18,8 +18,8 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef SWSCALE_H +-#define SWSCALE_H ++#ifndef FFMPEG_SWSCALE_H ++#define FFMPEG_SWSCALE_H + + /** + * @file swscale.h +@@ -138,4 +138,4 @@ + int dstW, int dstH, int dstFormat, int flags, + SwsFilter *srcFilter, SwsFilter *dstFilter, double *param); + +-#endif ++#endif /* FFMPEG_SWSCALE_H */ +diff -u mplayer-1.0~rc2-12/libswscale/swscale_internal.h ffmpeg-free-0.svn20080206/libswscale/swscale_internal.h +--- mplayer-1.0~rc2-12/libswscale/swscale_internal.h 2007-10-07 21:49:31.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libswscale/swscale_internal.h 2007-12-21 12:47:09.000000000 +0100 +@@ -18,8 +18,10 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef SWSCALE_INTERNAL_H +-#define SWSCALE_INTERNAL_H ++#ifndef FFMPEG_SWSCALE_INTERNAL_H ++#define FFMPEG_SWSCALE_INTERNAL_H ++ ++#include "config.h" + + #ifdef HAVE_ALTIVEC_H + #include +@@ -40,8 +42,8 @@ + AVClass *av_class; + + /** +- * +- * Note the src,dst,srcStride,dstStride will be copied, in the sws_scale() warper so they can freely be modified here ++ * Note that src, dst, srcStride, dstStride will be copied in the ++ * sws_scale() wrapper so they can be freely modified here. + */ + SwsFunc swScale; + int srcW, srcH, dstH; +@@ -181,6 +183,13 @@ + SwsFunc yuv2rgb_get_func_ptr (SwsContext *c); + int yuv2rgb_c_init_tables (SwsContext *c, const int inv_table[4], int fullRange, int brightness, int contrast, int saturation); + ++void yuv2rgb_altivec_init_tables (SwsContext *c, const int inv_table[4],int brightness,int contrast, int saturation); ++SwsFunc yuv2rgb_init_altivec (SwsContext *c); ++void altivec_yuv2packedX (SwsContext *c, ++ int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize, ++ int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize, ++ uint8_t *dest, int dstW, int dstY); ++ + char *sws_format_name(int format); + + //FIXME replace this with something faster +@@ -263,4 +272,4 @@ + } + } + +-#endif ++#endif /* FFMPEG_SWSCALE_INTERNAL_H */ +diff -u mplayer-1.0~rc2-12/libswscale/swscale_template.c ffmpeg-free-0.svn20080206/libswscale/swscale_template.c +--- mplayer-1.0~rc2-12/libswscale/swscale_template.c 2007-10-07 21:49:31.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libswscale/swscale_template.c 2008-01-29 15:58:10.000000000 +0100 +@@ -39,7 +39,7 @@ + #ifdef HAVE_3DNOW + #define PREFETCH "prefetch" + #define PREFETCHW "prefetchw" +-#elif defined ( HAVE_MMX2 ) ++#elif defined (HAVE_MMX2) + #define PREFETCH "prefetchnta" + #define PREFETCHW "prefetcht0" + #else +@@ -855,8 +855,8 @@ + + #define WRITEBGR24MMX2(dst, dstw, index) \ + /* mm2=B, %%mm4=G, %%mm5=R, %%mm7=0 */\ +- "movq "MANGLE(M24A)", %%mm0 \n\t"\ +- "movq "MANGLE(M24C)", %%mm7 \n\t"\ ++ "movq "MANGLE(ff_M24A)", %%mm0 \n\t"\ ++ "movq "MANGLE(ff_M24C)", %%mm7 \n\t"\ + "pshufw $0x50, %%mm2, %%mm1 \n\t" /* B3 B2 B3 B2 B1 B0 B1 B0 */\ + "pshufw $0x50, %%mm4, %%mm3 \n\t" /* G3 G2 G3 G2 G1 G0 G1 G0 */\ + "pshufw $0x00, %%mm5, %%mm6 \n\t" /* R1 R0 R1 R0 R1 R0 R1 R0 */\ +@@ -875,7 +875,7 @@ + "pshufw $0x55, %%mm4, %%mm3 \n\t" /* G4 G3 G4 G3 G4 G3 G4 G3 */\ + "pshufw $0xA5, %%mm5, %%mm6 \n\t" /* R5 R4 R5 R4 R3 R2 R3 R2 */\ + \ +- "pand "MANGLE(M24B)", %%mm1 \n\t" /* B5 B4 B3 */\ ++ "pand "MANGLE(ff_M24B)", %%mm1 \n\t" /* B5 B4 B3 */\ + "pand %%mm7, %%mm3 \n\t" /* G4 G3 */\ + "pand %%mm0, %%mm6 \n\t" /* R4 R3 R2 */\ + \ +@@ -889,7 +889,7 @@ + \ + "pand %%mm7, %%mm1 \n\t" /* B7 B6 */\ + "pand %%mm0, %%mm3 \n\t" /* G7 G6 G5 */\ +- "pand "MANGLE(M24B)", %%mm6 \n\t" /* R7 R6 R5 */\ ++ "pand "MANGLE(ff_M24B)", %%mm6 \n\t" /* R7 R6 R5 */\ + \ + "por %%mm1, %%mm3 \n\t"\ + "por %%mm3, %%mm6 \n\t"\ +@@ -957,7 +957,7 @@ + chrFilter, chrSrc, chrFilterSize, + dest, uDest, vDest, dstW, chrDstW); + #endif //!HAVE_ALTIVEC +-#endif ++#endif /* HAVE_MMX */ + } + + static inline void RENAME(yuv2nv12X)(SwsContext *c, int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize, +@@ -973,7 +973,7 @@ + uint8_t *dest, uint8_t *uDest, uint8_t *vDest, long dstW, long chrDstW) + { + #ifdef HAVE_MMX +- if (uDest != NULL) ++ if (uDest) + { + asm volatile( + YSCALEYUV2YV121 +@@ -1010,7 +1010,7 @@ + dest[i]= val; + } + +- if (uDest != NULL) ++ if (uDest) + for (i=0; i>7; +@@ -1161,7 +1161,7 @@ + return; + } + } +-#endif ++#endif /* HAVE_MMX */ + #ifdef HAVE_ALTIVEC + /* The following list of supported dstFormat values should + match what's found in the body of altivec_yuv2packedX() */ +@@ -1333,7 +1333,7 @@ + : "%"REG_a + ); + break; +-#endif ++#endif /* HAVE_MMX */ + case PIX_FMT_BGR32: + #ifndef HAVE_MMX + case PIX_FMT_RGB32: +@@ -1513,7 +1513,7 @@ + } + + #ifdef HAVE_MMX +- if ( uvalpha < 2048 ) // note this is not correct (shifts chrominance by 0.5 pixels) but it is a bit faster ++ if (uvalpha < 2048) // note this is not correct (shifts chrominance by 0.5 pixels) but it is a bit faster + { + switch(dstFormat) + { +@@ -1691,8 +1691,8 @@ + return; + } + } +-#endif +- if ( uvalpha < 2048 ) ++#endif /* HAVE_MMX */ ++ if (uvalpha < 2048) + { + YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGB1_C, YSCALE_YUV_2_PACKED1_C) + }else{ +@@ -1831,7 +1831,7 @@ + int g= (((uint32_t*)src)[i]>>8)&0xFF; + int r= (((uint32_t*)src)[i]>>16)&0xFF; + +- dst[i]= ((RY*r + GY*g + BY*b + (33<<(RGB2YUV_SHIFT-1)) )>>RGB2YUV_SHIFT); ++ dst[i]= ((RY*r + GY*g + BY*b + (33<<(RGB2YUV_SHIFT-1)))>>RGB2YUV_SHIFT); + } + } + +@@ -1859,8 +1859,8 @@ + #ifdef HAVE_MMX + asm volatile( + "mov %2, %%"REG_a" \n\t" +- "movq "MANGLE(bgr2YCoeff)", %%mm6 \n\t" +- "movq "MANGLE(w1111)", %%mm5 \n\t" ++ "movq "MANGLE(ff_bgr2YCoeff)", %%mm6 \n\t" ++ "movq "MANGLE(ff_w1111)", %%mm5 \n\t" + "pxor %%mm7, %%mm7 \n\t" + "lea (%%"REG_a", %%"REG_a", 2), %%"REG_d" \n\t" + ASMALIGN(4) +@@ -1918,7 +1918,7 @@ + "psraw $7, %%mm4 \n\t" + + "packuswb %%mm4, %%mm0 \n\t" +- "paddusb "MANGLE(bgr2YOffset)", %%mm0 \n\t" ++ "paddusb "MANGLE(ff_bgr2YOffset)", %%mm0 \n\t" + + "movq %%mm0, (%1, %%"REG_a") \n\t" + "add $8, %%"REG_a" \n\t" +@@ -1934,9 +1934,9 @@ + int g= src[i*3+1]; + int r= src[i*3+2]; + +- dst[i]= ((RY*r + GY*g + BY*b + (33<<(RGB2YUV_SHIFT-1)) )>>RGB2YUV_SHIFT); ++ dst[i]= ((RY*r + GY*g + BY*b + (33<<(RGB2YUV_SHIFT-1)))>>RGB2YUV_SHIFT); + } +-#endif ++#endif /* HAVE_MMX */ + } + + static inline void RENAME(bgr24ToUV)(uint8_t *dstU, uint8_t *dstV, uint8_t *src1, uint8_t *src2, long width) +@@ -1944,8 +1944,8 @@ + #ifdef HAVE_MMX + asm volatile( + "mov %3, %%"REG_a" \n\t" +- "movq "MANGLE(w1111)", %%mm5 \n\t" +- "movq "MANGLE(bgr2UCoeff)", %%mm6 \n\t" ++ "movq "MANGLE(ff_w1111)", %%mm5 \n\t" ++ "movq "MANGLE(ff_bgr2UCoeff)", %%mm6 \n\t" + "pxor %%mm7, %%mm7 \n\t" + "lea (%%"REG_a", %%"REG_a", 2), %%"REG_d" \n\t" + "add %%"REG_d", %%"REG_d" \n\t" +@@ -1977,8 +1977,8 @@ + "psrlw $1, %%mm0 \n\t" + "psrlw $1, %%mm2 \n\t" + #endif +- "movq "MANGLE(bgr2VCoeff)", %%mm1 \n\t" +- "movq "MANGLE(bgr2VCoeff)", %%mm3 \n\t" ++ "movq "MANGLE(ff_bgr2VCoeff)", %%mm1 \n\t" ++ "movq "MANGLE(ff_bgr2VCoeff)", %%mm3 \n\t" + + "pmaddwd %%mm0, %%mm1 \n\t" + "pmaddwd %%mm2, %%mm3 \n\t" +@@ -2019,12 +2019,12 @@ + "punpcklbw %%mm7, %%mm5 \n\t" + "punpcklbw %%mm7, %%mm2 \n\t" + "paddw %%mm5, %%mm2 \n\t" +- "movq "MANGLE(w1111)", %%mm5 \n\t" ++ "movq "MANGLE(ff_w1111)", %%mm5 \n\t" + "psrlw $2, %%mm4 \n\t" + "psrlw $2, %%mm2 \n\t" + #endif +- "movq "MANGLE(bgr2VCoeff)", %%mm1 \n\t" +- "movq "MANGLE(bgr2VCoeff)", %%mm3 \n\t" ++ "movq "MANGLE(ff_bgr2VCoeff)", %%mm1 \n\t" ++ "movq "MANGLE(ff_bgr2VCoeff)", %%mm3 \n\t" + + "pmaddwd %%mm4, %%mm1 \n\t" + "pmaddwd %%mm2, %%mm3 \n\t" +@@ -2048,7 +2048,7 @@ + "punpckldq %%mm4, %%mm0 \n\t" + "punpckhdq %%mm4, %%mm1 \n\t" + "packsswb %%mm1, %%mm0 \n\t" +- "paddb "MANGLE(bgr2UVOffset)", %%mm0 \n\t" ++ "paddb "MANGLE(ff_bgr2UVOffset)", %%mm0 \n\t" + + "movd %%mm0, (%1, %%"REG_a") \n\t" + "punpckhdq %%mm0, %%mm0 \n\t" +@@ -2069,11 +2069,11 @@ + dstU[i]= ((RU*r + GU*g + BU*b)>>(RGB2YUV_SHIFT+1)) + 128; + dstV[i]= ((RV*r + GV*g + BV*b)>>(RGB2YUV_SHIFT+1)) + 128; + } +-#endif ++#endif /* HAVE_MMX */ + assert(src1 == src2); + } + +-static inline void RENAME(bgr16ToY)(uint8_t *dst, uint8_t *src, int width) ++static inline void RENAME(rgb16ToY)(uint8_t *dst, uint8_t *src, int width) + { + int i; + for (i=0; i>8)&0xFF; + int b= (((uint32_t*)src)[i]>>16)&0xFF; + +- dst[i]= ((RY*r + GY*g + BY*b + (33<<(RGB2YUV_SHIFT-1)) )>>RGB2YUV_SHIFT); ++ dst[i]= ((RY*r + GY*g + BY*b + (33<<(RGB2YUV_SHIFT-1)))>>RGB2YUV_SHIFT); + } + } + +@@ -2187,7 +2187,7 @@ + int g= src[i*3+1]; + int b= src[i*3+2]; + +- dst[i]= ((RY*r + GY*g + BY*b + (33<<(RGB2YUV_SHIFT-1)) )>>RGB2YUV_SHIFT); ++ dst[i]= ((RY*r + GY*g + BY*b + (33<<(RGB2YUV_SHIFT-1)))>>RGB2YUV_SHIFT); + } + } + +@@ -2206,7 +2206,7 @@ + } + } + +-static inline void RENAME(rgb16ToY)(uint8_t *dst, uint8_t *src, int width) ++static inline void RENAME(bgr16ToY)(uint8_t *dst, uint8_t *src, int width) + { + int i; + for (i=0; i>7, 0, (1<<15)-1); // the cubic equation does overflow ... + //dst[i] = val>>7; + } +-#endif +-#endif ++#endif /* HAVE_ALTIVEC */ ++#endif /* HAVE_MMX */ + } + // *** horizontal scale Y line to temp buffer + static inline void RENAME(hyscale)(uint16_t *dst, long dstWidth, uint8_t *src, int srcW, int xInc, +@@ -2594,7 +2594,7 @@ + "add %%"REG_a", %%"REG_D" \n\t"\ + "xor %%"REG_a", %%"REG_a" \n\t"\ + +-#endif ++#endif /* ARCH_X86_64 */ + + FUNNY_Y_CODE + FUNNY_Y_CODE +@@ -2622,7 +2622,7 @@ + } + else + { +-#endif ++#endif /* HAVE_MMX2 */ + long xInc_shr16 = xInc >> 16; + uint16_t xInc_mask = xInc & 0xffff; + //NO MMX just normal asm ... +@@ -2678,7 +2678,7 @@ + dst[i]= (src[xx]<<7) + (src[xx+1] - src[xx])*xalpha; + xpos+=xInc; + } +-#endif ++#endif /* defined(ARCH_X86) */ + } + } + +@@ -2812,7 +2812,7 @@ + "add %%"REG_a", %%"REG_D" \n\t"\ + "xor %%"REG_a", %%"REG_a" \n\t"\ + +-#endif ++#endif /* ARCH_X86_64 */ + + FUNNY_UV_CODE + FUNNY_UV_CODE +@@ -2853,7 +2853,7 @@ + } + else + { +-#endif ++#endif /* HAVE_MMX2 */ + long xInc_shr16 = (long) (xInc >> 16); + uint16_t xInc_mask = xInc & 0xffff; + asm volatile( +@@ -2891,7 +2891,7 @@ + + /* GCC-3.3 makes MPlayer crash on IA-32 machines when using "g" operand here, + which is needed to support GCC-4.0 */ +-#if defined(ARCH_X86_64) && ((__GNUC__ > 3) || ( __GNUC__ == 3 && __GNUC_MINOR__ >= 4)) ++#if defined(ARCH_X86_64) && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) + :: "m" (src1), "m" (dst), "g" ((long)dstWidth), "m" (xInc_shr16), "m" (xInc_mask), + #else + :: "m" (src1), "m" (dst), "m" ((long)dstWidth), "m" (xInc_shr16), "m" (xInc_mask), +@@ -2917,7 +2917,7 @@ + */ + xpos+=xInc; + } +-#endif ++#endif /* defined(ARCH_X86) */ + } + } + +@@ -3077,8 +3077,8 @@ + lastInChrBuf++; + } + //wrap buf index around to stay inside the ring buffer +- if (lumBufIndex >= vLumBufSize ) lumBufIndex-= vLumBufSize; +- if (chrBufIndex >= vChrBufSize ) chrBufIndex-= vChrBufSize; ++ if (lumBufIndex >= vLumBufSize) lumBufIndex-= vLumBufSize; ++ if (chrBufIndex >= vChrBufSize) chrBufIndex-= vChrBufSize; + } + else // not enough lines left in this slice -> load the rest in the buffer + { +@@ -3118,8 +3118,8 @@ + lastInChrBuf++; + } + //wrap buf index around to stay inside the ring buffer +- if (lumBufIndex >= vLumBufSize ) lumBufIndex-= vLumBufSize; +- if (chrBufIndex >= vChrBufSize ) chrBufIndex-= vChrBufSize; ++ if (lumBufIndex >= vLumBufSize) lumBufIndex-= vLumBufSize; ++ if (chrBufIndex >= vChrBufSize) chrBufIndex-= vChrBufSize; + break; //we can't output a dstY line so let's try with the next slice + } + +diff -u mplayer-1.0~rc2-12/libswscale/yuv2rgb_altivec.c ffmpeg-free-0.svn20080206/libswscale/yuv2rgb_altivec.c +--- mplayer-1.0~rc2-12/libswscale/yuv2rgb_altivec.c 2007-10-07 21:49:31.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libswscale/yuv2rgb_altivec.c 2008-01-17 09:57:15.000000000 +0100 +@@ -762,7 +762,7 @@ + vector signed short vec; + } buf; + +- buf.tmp[0] = ( (0xffffLL) * contrast>>8 )>>9; //cy ++ buf.tmp[0] = ((0xffffLL) * contrast>>8)>>9; //cy + buf.tmp[1] = -256*brightness; //oy + buf.tmp[2] = (inv_table[0]>>3) *(contrast>>16)*(saturation>>16); //crv + buf.tmp[3] = (inv_table[1]>>3) *(contrast>>16)*(saturation>>16); //cbu +diff -u mplayer-1.0~rc2-12/libswscale/yuv2rgb_bfin.c ffmpeg-free-0.svn20080206/libswscale/yuv2rgb_bfin.c +--- mplayer-1.0~rc2-12/libswscale/yuv2rgb_bfin.c 2007-10-07 21:49:31.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libswscale/yuv2rgb_bfin.c 2008-01-17 11:24:14.000000000 +0100 +@@ -110,12 +110,12 @@ + + for (i=0;ioy); ++ lcscf (py, pu, pv, op, w, &c->oy); + + py += instrides[0]; + op += outstrides[0]; + +- lcscf (py,pu,pv,op,w,&c->oy); ++ lcscf (py, pu, pv, op, w, &c->oy); + + py += instrides[0]; + pu += instrides[1]; +@@ -132,7 +132,7 @@ + int srcSliceY, int srcSliceH, + uint8_t **oplanes, int *outstrides) + { +- return core_yuv420_rgb (c,in,instrides,srcSliceY,srcSliceH,oplanes,outstrides, ++ return core_yuv420_rgb (c, in, instrides, srcSliceY, srcSliceH, oplanes, outstrides, + ff_bfin_yuv2rgb555_line, 1, 555); + } + +@@ -141,7 +141,7 @@ + int srcSliceY, int srcSliceH, + uint8_t **oplanes, int *outstrides) + { +- return core_yuv420_rgb (c,in,instrides,srcSliceY,srcSliceH,oplanes,outstrides, ++ return core_yuv420_rgb (c, in, instrides, srcSliceY, srcSliceH, oplanes, outstrides, + ff_bfin_yuv2rgb555_line, 0, 555); + } + +@@ -150,7 +150,7 @@ + int srcSliceY, int srcSliceH, + uint8_t **oplanes, int *outstrides) + { +- return core_yuv420_rgb (c,in,instrides,srcSliceY,srcSliceH,oplanes,outstrides, ++ return core_yuv420_rgb (c, in, instrides, srcSliceY, srcSliceH, oplanes, outstrides, + ff_bfin_yuv2rgb24_line, 1, 888); + } + +@@ -159,7 +159,7 @@ + int srcSliceY, int srcSliceH, + uint8_t **oplanes, int *outstrides) + { +- return core_yuv420_rgb (c,in,instrides,srcSliceY,srcSliceH,oplanes,outstrides, ++ return core_yuv420_rgb (c, in, instrides, srcSliceY, srcSliceH, oplanes, outstrides, + ff_bfin_yuv2rgb24_line, 0, 888); + } + +@@ -168,7 +168,7 @@ + int srcSliceY, int srcSliceH, + uint8_t **oplanes, int *outstrides) + { +- return core_yuv420_rgb (c,in,instrides,srcSliceY,srcSliceH,oplanes,outstrides, ++ return core_yuv420_rgb (c, in, instrides, srcSliceY, srcSliceH, oplanes, outstrides, + ff_bfin_yuv2rgb565_line, 1, 565); + } + +@@ -177,7 +177,7 @@ + int srcSliceY, int srcSliceH, + uint8_t **oplanes, int *outstrides) + { +- return core_yuv420_rgb (c,in,instrides,srcSliceY,srcSliceH,oplanes,outstrides, ++ return core_yuv420_rgb (c, in, instrides, srcSliceY, srcSliceH, oplanes, outstrides, + ff_bfin_yuv2rgb565_line, 0, 565); + } + +diff -u mplayer-1.0~rc2-12/libswscale/yuv2rgb.c ffmpeg-free-0.svn20080206/libswscale/yuv2rgb.c +--- mplayer-1.0~rc2-12/libswscale/yuv2rgb.c 2007-10-07 21:49:31.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libswscale/yuv2rgb.c 2008-01-29 15:58:10.000000000 +0100 +@@ -159,13 +159,9 @@ + #ifdef HAVE_MMX + + /* hope these constant values are cache line aligned */ +-static uint64_t attribute_used __attribute__((aligned(8))) mmx_00ffw = 0x00ff00ff00ff00ffULL; +-static uint64_t attribute_used __attribute__((aligned(8))) mmx_redmask = 0xf8f8f8f8f8f8f8f8ULL; +-static uint64_t attribute_used __attribute__((aligned(8))) mmx_grnmask = 0xfcfcfcfcfcfcfcfcULL; +- +-static uint64_t attribute_used __attribute__((aligned(8))) M24A= 0x00FF0000FF0000FFULL; +-static uint64_t attribute_used __attribute__((aligned(8))) M24B= 0xFF0000FF0000FF00ULL; +-static uint64_t attribute_used __attribute__((aligned(8))) M24C= 0x0000FF0000FF0000ULL; ++DECLARE_ASM_CONST(8, uint64_t, mmx_00ffw) = 0x00ff00ff00ff00ffULL; ++DECLARE_ASM_CONST(8, uint64_t, mmx_redmask) = 0xf8f8f8f8f8f8f8f8ULL; ++DECLARE_ASM_CONST(8, uint64_t, mmx_grnmask) = 0xfcfcfcfcfcfcfcfcULL; + + // the volatile is required because gcc otherwise optimizes some writes away not knowing that these + // are read in the asm block +diff -u mplayer-1.0~rc2-12/libswscale/yuv2rgb_template.c ffmpeg-free-0.svn20080206/libswscale/yuv2rgb_template.c +--- mplayer-1.0~rc2-12/libswscale/yuv2rgb_template.c 2007-10-07 21:49:31.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libswscale/yuv2rgb_template.c 2008-01-29 15:58:10.000000000 +0100 +@@ -338,8 +338,8 @@ + YUV2RGB + /* mm0=B, %%mm2=G, %%mm1=R */ + #ifdef HAVE_MMX2 +- "movq "MANGLE(M24A)", %%mm4 \n\t" +- "movq "MANGLE(M24C)", %%mm7 \n\t" ++ "movq "MANGLE(ff_M24A)", %%mm4 \n\t" ++ "movq "MANGLE(ff_M24C)", %%mm7 \n\t" + "pshufw $0x50, %%mm0, %%mm5 \n\t" /* B3 B2 B3 B2 B1 B0 B1 B0 */ + "pshufw $0x50, %%mm2, %%mm3 \n\t" /* G3 G2 G3 G2 G1 G0 G1 G0 */ + "pshufw $0x00, %%mm1, %%mm6 \n\t" /* R1 R0 R1 R0 R1 R0 R1 R0 */ +@@ -358,7 +358,7 @@ + "pshufw $0x55, %%mm2, %%mm3 \n\t" /* G4 G3 G4 G3 G4 G3 G4 G3 */ + "pshufw $0xA5, %%mm1, %%mm6 \n\t" /* R5 R4 R5 R4 R3 R2 R3 R2 */ + +- "pand "MANGLE(M24B)", %%mm5 \n\t" /* B5 B4 B3 */ ++ "pand "MANGLE(ff_M24B)", %%mm5 \n\t" /* B5 B4 B3 */ + "pand %%mm7, %%mm3 \n\t" /* G4 G3 */ + "pand %%mm4, %%mm6 \n\t" /* R4 R3 R2 */ + +@@ -373,7 +373,7 @@ + + "pand %%mm7, %%mm5 \n\t" /* B7 B6 */ + "pand %%mm4, %%mm3 \n\t" /* G7 G6 G5 */ +- "pand "MANGLE(M24B)", %%mm6 \n\t" /* R7 R6 R5 */ ++ "pand "MANGLE(ff_M24B)", %%mm6 \n\t" /* R7 R6 R5 */ + "movd 4 (%3, %0), %%mm1;" /* Load 4 Cr 00 00 00 00 v3 v2 v1 v0 */ + \ + "por %%mm5, %%mm3 \n\t" +diff -u mplayer-1.0~rc2-12/libswscale/yuv2rgb_vis.c ffmpeg-free-0.svn20080206/libswscale/yuv2rgb_vis.c +--- mplayer-1.0~rc2-12/libswscale/yuv2rgb_vis.c 2007-10-07 21:49:31.000000000 +0200 ++++ ffmpeg-free-0.svn20080206/libswscale/yuv2rgb_vis.c 2008-01-17 11:24:14.000000000 +0100 +@@ -188,7 +188,7 @@ + c->sparc_coeffs[8]=c->ubCoeff; + c->sparc_coeffs[9]=c->ugCoeff; + +- c->sparc_coeffs[0]=(((int16_t)c->yOffset*(int16_t)c->yCoeff>>11) & 0xffff) * 0x0001000100010001ULL; ++ c->sparc_coeffs[0]=(((int16_t)c->yOffset*(int16_t)c->yCoeff >>11) & 0xffff) * 0x0001000100010001ULL; + c->sparc_coeffs[1]=(((int16_t)c->uOffset*(int16_t)c->ubCoeff>>11) & 0xffff) * 0x0001000100010001ULL; + c->sparc_coeffs[2]=(((int16_t)c->uOffset*(int16_t)c->ugCoeff>>11) & 0xffff) * 0x0001000100010001ULL; + c->sparc_coeffs[3]=(((int16_t)c->vOffset*(int16_t)c->vgCoeff>>11) & 0xffff) * 0x0001000100010001ULL; diff --git a/debian/po/POTFILES.in b/debian/po/POTFILES.in new file mode 100644 index 0000000..03156d1 --- /dev/null +++ b/debian/po/POTFILES.in @@ -0,0 +1 @@ +[type: gettext/rfc822deb] mplayer.templates diff --git a/debian/po/be.po b/debian/po/be.po new file mode 100644 index 0000000..1bd0483 --- /dev/null +++ b/debian/po/be.po @@ -0,0 +1,217 @@ +# translation of mplayer1.0-rc1-17.po to Belarusian +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# +# Pavel Piatruk , 2007. +# Paul Petruk , 2007. +msgid "" +msgstr "" +"Project-Id-Version: mplayer1.0-rc1-17\n" +"Report-Msgid-Bugs-To: mennucc1@debian.org\n" +"POT-Creation-Date: 2007-10-18 10:01+0200\n" +"PO-Revision-Date: 2007-10-19 20:03+0300\n" +"Last-Translator: Paul Petruk \n" +"Language-Team: Belarusian \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: KBabel 1.11.4\n" + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "Detailed configuration needed for each user" +msgstr "Падрабязная наладка для кожнага карыстальніка" + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "" +"The performance of MPlayer depends heavily on hardware; this means that it " +"may benefit from tweaking options for every single machine it's installed on." +msgstr "" +"Прадуктыўнасць MPlayer залежыць пераважна ад апаратнага забеспячэння - " +"значыць, ён патрабуе рэгулявання налад для кожнай машыны, куды ўсталяваны." + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "" +"You should read the documentation provided by the 'mplayer-doc' package." +msgstr "" +"Вы маеце пажадаць прачытаць дакументацыю, што пастаўляецца ў пакеце'mplayer-" +"doc'." + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "" +"Now, some configuration options will be set for the entire system in /etc/" +"mplayer/mplayer.conf which may be adapted later. Any user can also refine " +"options in ~/.mplayer/config." +msgstr "" +"Зараз некалькі налады будуць вызначаны для сістэмы агулам ў файле /etc/" +"mplayer/mplayer.conf, які можа быць зменены пазней. Любы карыстальнік можа " +"пакінуць налады ў сваім файле ~/.mplayer/config." + +#. Type: boolean +#. Description +#: ../mplayer.templates:3001 +msgid "Replace existing configuration file?" +msgstr "Ці замяніць існы файл наладаў?" + +#. Type: boolean +#. Description +#: ../mplayer.templates:3001 +msgid "" +"An /etc/mplayer/mplayer.conf file already exists on the system and does not " +"contain an automatically-generated part. That file can be replaced by a " +"generated one (the old file will be moved to /etc/mplayer/mplayer.conf." +"debconf-old)." +msgstr "" +"Файл /etc/mplayer/mplayer.conf ужо існуе, але ён не змяшчае аўтаматычна " +"згенераванай часткі. Гэты файл можа быць заменены згенераваным новым (стары " +"будзе перамешчаны ў /etc/mplayer/mplayer.conf.debconf-old)." + +#. Type: note +#. Description +#: ../mplayer.templates:4001 +msgid "Old configuration file kept" +msgstr "Стары файл наладаў пакінуты" + +#. Type: note +#. Description +#: ../mplayer.templates:4001 +msgid "You chose not to replace the existing /etc/mplayer/mplayer.conf file." +msgstr "Вы выбралі не змяняць файла /etc/mplayer/mplayer.conf." + +#. Type: note +#. Description +#: ../mplayer.templates:4001 +msgid "" +"That file can be generated automatically later by running 'dpkg-reconfigure " +"mplayer'." +msgstr "" +"Файл можа быць аўтаматычна створаны пазней запускам 'dpkg-reconfigure " +"mplayer'." + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "MPlayer video output:" +msgstr "Вывад відэа MPlayer:" + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "" +"MPlayer can use a very wide range of video output drivers. The needed driver " +"may be detected automatically or chosen manually." +msgstr "" +"MPlayer можа выводзіць відэа праз шмат якія драйверы. Патрэбны драйвер можа " +"быць вызначаны аўтаматычна або выбраны ўручную." + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "" +"If you prefer choosing the driver yourself, you first should choose an entry " +"matching this system's video card. If none match and the card supports 'XV', " +"choose that option (the 'xvinfo' command may help)." +msgstr "" +"Калі хочаце выбраць драйвер самі, спярша выберыце пункт, што адпавядае " +"відэакартцы ў вашай сістэме. Калі не знойдзеце адпаведнасцяў, а картка " +"падтрымлівае 'XV', выберыце пункт 'XV' (каманда 'xvinfo' мусіць дапамагчы)." + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "" +"Please read the /usr/share/doc/mplayer-doc/HTML/en/video.html file from the " +"'mplayer-doc' package for more details." +msgstr "" +"Калі ласка, для падрабязнасцей прачытайце файл /usr/share/doc/mplayer-doc/" +"HTML/en/video.html з пакета 'mplayer-doc'." + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "Binary codecs download" +msgstr "Спампоўванне двайковых кодэкаў" + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "MPlayer supports most video formats without additional software." +msgstr "" +"MPlayer падтрымлівае большасць відэафарматаў адразу без дадатковых " +"праграмных сродкаў." + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "" +"Additional video formats, such as Real 3.0/4.0, Windows Media 9, or " +"Quicktime, can be supported by using binary codecs." +msgstr "" +"Дадатковыя фарматы відэа (Real 3.0/4.0, Windows Media 9, Quicktime і іншыя) " +"могуць быць прайграны з дапамогай двайковых кодэкаў." + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "" +"As such codecs are not free software, they are not distributed with this " +"package but can be downloaded freely. The '/usr/share/mplayer/scripts/" +"binary_codecs.sh' script is provided in this package to help downloading " +"them from the MPlayer web site." +msgstr "" +"Такія кодэкі не ўключаны ў гэты пакет, таму што яны не падлягаюць вольнаму " +"распаўсюджванню. Аднак яны могуць быць свабодна спампаваны. Скрыпт '/usr/" +"share/mplayer/scripts/binary_codecs.sh' дапаможа спампаваць іх з web-сайта " +"MPlayer." + +#. Type: string +#. Description +#: ../mplayer.templates:7001 +msgid "DVD device name:" +msgstr "Назва прылады DVD:" + +#. Type: string +#. Description +#: ../mplayer.templates:7001 +msgid "Please enter the name of the device for your DVD player, if any." +msgstr "Увядзіце назву вашай прылады DVD, калі ёсць." + +#. Type: select +#. Description +#: ../mplayer.templates:8001 +msgid "Font for On Screen Display:" +msgstr "Шрыфт для On Screen Display:" + +#. Type: error +#. Description +#: ../mplayer.templates:9001 +msgid "No TrueType fonts found for On Screen Display" +msgstr "Няма шрыфтоў True Type для On Screen Display" + +#. Type: error +#. Description +#: ../mplayer.templates:9001 +msgid "" +"MPlayer needs at least one TrueType font for its 'On Screen Display' feature." +msgstr "" +"MPlayer патрабуе прынамсі адзін шрыфт True Type для функцыі On Screen " +"Display." + +#. Type: error +#. Description +#: ../mplayer.templates:9001 +msgid "" +"You should install a package providing such fonts (such as 'ttf-freefont' or " +"'ttf-bitstream-vera' or 'msttcorefonts') and reconfigure MPlayer (by running " +"'dpkg-reconfigure mplayer')." +msgstr "" +"Вы маеце ўстанавіць пакет, што прадастаўляе шрыфты truetype (такія, як 'ttf-" +"freefont', ці 'ttf-bitstream-vera', ці 'msttcorefonts' ) і пераналадзьце " +"MPlayer (камандай \"dpkg-reconfigure mplayer\")" diff --git a/debian/po/cs.po b/debian/po/cs.po new file mode 100644 index 0000000..fc21790 --- /dev/null +++ b/debian/po/cs.po @@ -0,0 +1,255 @@ +# Czech translation of mplayer debconf messages. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the mplayer package. +# Miroslav Kure , 2007. +# +msgid "" +msgstr "" +"Project-Id-Version: mplayer\n" +"Report-Msgid-Bugs-To: mennucc1@debian.org\n" +"POT-Creation-Date: 2007-10-18 10:01+0200\n" +"PO-Revision-Date: 2007-10-21 10:35+0200\n" +"Last-Translator: Miroslav Kure \n" +"Language-Team: Czech \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "Detailed configuration needed for each user" +msgstr "Jemnější nastavení pro každého uživatele" + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "" +"The performance of MPlayer depends heavily on hardware; this means that it " +"may benefit from tweaking options for every single machine it's installed on." +msgstr "" +"Výkonnost MPlayeru silně závisí na hardwaru, což znamená, že může těžit z " +"vyladění pro každý konkrétní počítač, na kterém je nainstalovaný." + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "" +"You should read the documentation provided by the 'mplayer-doc' package." +msgstr "Měli byste si přečíst dokumentaci poskytovanou balíkem „mplayer-doc“." + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "" +"Now, some configuration options will be set for the entire system in /etc/" +"mplayer/mplayer.conf which may be adapted later. Any user can also refine " +"options in ~/.mplayer/config." +msgstr "" +"Nyní se nastaví některé konfigurační možnosti do celosystémového souboru /" +"etc/mplayer/mplayer.conf. Nastavení můžete později upravit a také jednotliví " +"uživatelé si mohou konfiguraci doladit dle potřeb v soukromém konfiguračním " +"souboru ~/.mplayer/config." + +#. Type: boolean +#. Description +#: ../mplayer.templates:3001 +msgid "Replace existing configuration file?" +msgstr "Nahradit stávající konfigurační soubor?" + +#. Type: boolean +#. Description +#: ../mplayer.templates:3001 +msgid "" +"An /etc/mplayer/mplayer.conf file already exists on the system and does not " +"contain an automatically-generated part. That file can be replaced by a " +"generated one (the old file will be moved to /etc/mplayer/mplayer.conf." +"debconf-old)." +msgstr "" +"Soubor /etc/mplayer/mplayer.conf již v systému existuje, ovšem neobsahuje " +"automaticky vygenerovanou část. Tento soubor může být nahrazen novějším " +"(původní soubor bude zazálohován jako /etc/mplayer/mplayer.conf.debconf-old)." + +#. Type: note +#. Description +#: ../mplayer.templates:4001 +msgid "Old configuration file kept" +msgstr "Stávající konfigurační soubor byl ponechán" + +#. Type: note +#. Description +#: ../mplayer.templates:4001 +msgid "You chose not to replace the existing /etc/mplayer/mplayer.conf file." +msgstr "" +"Zvolili jste, že se stávající konfigurační soubor /etc/mplayer/mplayer.conf " +"nemá nahradit." + +#. Type: note +#. Description +#: ../mplayer.templates:4001 +msgid "" +"That file can be generated automatically later by running 'dpkg-reconfigure " +"mplayer'." +msgstr "" +"Změníte-li později názor, můžete jej nahradit automaticky vygenerovanou " +"verzí spuštěním příkazu „dpkg-reconfigure mplayer“." + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "MPlayer video output:" +msgstr "Video výstup MPlayeru:" + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "" +"MPlayer can use a very wide range of video output drivers. The needed driver " +"may be detected automatically or chosen manually." +msgstr "" +"MPlayer umí využít širokou škálu výstupních ovladačů. Vhodný ovladač může " +"být rozpoznán automaticky, nebo jej můžete zvolit ručně." + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "" +"If you prefer choosing the driver yourself, you first should choose an entry " +"matching this system's video card. If none match and the card supports 'XV', " +"choose that option (the 'xvinfo' command may help)." +msgstr "" +"Chcete-li si ovladač vybrat sami, měli byste si nejprve vybrat záznam " +"odpovídající vaší video kartě. Pokud takový záznam nemůžete najít a vaše " +"video karta podporuje rozšíření „XV“, zvolte to. (Podporu XV zjistíte " +"příkazem xvinfo.)" + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "" +"Please read the /usr/share/doc/mplayer-doc/HTML/en/video.html file from the " +"'mplayer-doc' package for more details." +msgstr "" +"Podrobnosti naleznete v souboru /usr/share/doc/mplayer-doc/HTML/en/video." +"html (součást balíku „mplayer-doc“)." + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "Binary codecs download" +msgstr "Stažení binárních kodeků" + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "MPlayer supports most video formats without additional software." +msgstr "" +"MPlayer podporuje přímo bez dodatečného softwaru většinu většinu formátů " +"videa." + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "" +"Additional video formats, such as Real 3.0/4.0, Windows Media 9, or " +"Quicktime, can be supported by using binary codecs." +msgstr "" +"Podporu dodatečných formátů videa jako Real 3.0/4.0, Windows Media 9 nebo " +"Quicktime mohou zajistit binární kodeky." + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "" +"As such codecs are not free software, they are not distributed with this " +"package but can be downloaded freely. The '/usr/share/mplayer/scripts/" +"binary_codecs.sh' script is provided in this package to help downloading " +"them from the MPlayer web site." +msgstr "" +"Tyto kodeky nejsou svobodným softwarem a Debian je proto nemůže " +"distribuovat. Můžete si je však stáhnout z domovské stránky MPlayeru sami. " +"Se stažením pomůže přibalený skript „/usr/share/mplayer/scripts/" +"binary_codecs.sh“." + +#. Type: string +#. Description +#: ../mplayer.templates:7001 +msgid "DVD device name:" +msgstr "Jméno DVD zařízení:" + +#. Type: string +#. Description +#: ../mplayer.templates:7001 +msgid "Please enter the name of the device for your DVD player, if any." +msgstr "Zadejte prosím jméno zařízení vašeho DVD přehrávače (pokud existuje)." + +#. Type: select +#. Description +#: ../mplayer.templates:8001 +msgid "Font for On Screen Display:" +msgstr "Font pro On Screen Display:" + +#. Type: error +#. Description +#: ../mplayer.templates:9001 +msgid "No TrueType fonts found for On Screen Display" +msgstr "Žádné True Type fonty pro On Screen Display nenalezeny" + +#. Type: error +#. Description +#: ../mplayer.templates:9001 +msgid "" +"MPlayer needs at least one TrueType font for its 'On Screen Display' feature." +msgstr "MPlayer vyžaduje pro On Screen Display alespoň jeden True Typový font." + +#. Type: error +#. Description +#: ../mplayer.templates:9001 +msgid "" +"You should install a package providing such fonts (such as 'ttf-freefont' or " +"'ttf-bitstream-vera' or 'msttcorefonts') and reconfigure MPlayer (by running " +"'dpkg-reconfigure mplayer')." +msgstr "" +"Měli byste nainstalovat balík, který poskytuje True Typové fonty (např. „ttf-" +"freefont“ nebo „ttf-dejavu“) a znovu spustit konfiguraci MPlayeru příkazem " +"„dpkg-reconfigure mplayer“." + +#~ msgid "" +#~ "Performance of MPlayer depends heavily on hardware - this means that it " +#~ "may benefit from tweaking options, for every single machine it's " +#~ "installed to. You may wish to read the documentation (it is in the " +#~ "package 'mplayer-doc', under /usr/share/doc/mplayer-doc/). This DebConf " +#~ "interface will help you setup just a few main features; you may wish to " +#~ "add to /etc/mplayer/mplayer.conf some more refined options (to enable " +#~ "multichannel audio, or video postprocessing, etc etc); and any user " +#~ "similarly may customize MPlayer using the file ~/.mplayer/config" +#~ msgstr "" +#~ "Výkonnost MPlayeru silně závisí na hardwaru, což znamená, že může těžit z " +#~ "vyladění na každý konkrétní počítač, na kterém je nainstalovaný. Veškeré " +#~ "podrobnosti zjistíte z dokumentace v adresáři /usr/share/doc/mplayer-doc/ " +#~ "z balíku 'mplayer-doc'. Tento průvodce vám pomůže nastavit několik " +#~ "základních vlastností. Možná pak budete chtít upravit pokročilejší " +#~ "možnosti (vícekanálový zvuk, postprocesing videa, atd.) v konfiguračním " +#~ "souboru /etc/mplayer/mplayer.conf. Podobně si mohou MPlayer upravit " +#~ "jednotliví uživatelé v soukromém konfiguračním souboru ~/.mplayer/config" + +#~ msgid "Enable access to RTC?" +#~ msgstr "Povolit přístup k RTC?" + +#~ msgid "" +#~ "On older kernels MPlayer can use the RTC (Real Time Clock) to provide " +#~ "better timing in reproduction, with less CPU cost; to this end, though, " +#~ "the device /dev/rtc must be accessible to group audio, and the default " +#~ "max-user-freq must be raised to 1024. Any needed change must be done by " +#~ "root. If you wish, MPlayer will automatically do this at boot, so that " +#~ "any user can enjoy this feature. Note that there may be security issues " +#~ "with this (although none are known now)." +#~ msgstr "" +#~ "Na starších jádrech může MPlayer využít hodiny reálného času (RTC) a " +#~ "poskytovat tak při reprodukci lepší časování a ještě šetřit výkon CPU. " +#~ "Aby to fungovalo, musí být zařízení /dev/rtc přístupné skupině audio a " +#~ "výchozí max-user-freq musí být zvýšena na 1024. Tyto změny musí provést " +#~ "uživatel root. Pokud si budete přát, MPlayer to umí nastavit při zavádění " +#~ "systému automaticky, takže z toho budou těžit všichni uživatelé. " +#~ "Pamatujte, že z toho mohou plynout bezpečnostní rizika (i když žádná " +#~ "zatím nejsou známa)." diff --git a/debian/po/de.po b/debian/po/de.po new file mode 100644 index 0000000..125ac88 --- /dev/null +++ b/debian/po/de.po @@ -0,0 +1,320 @@ +# Translation of mplayer debconf templates to German +# Copyright (C) Helge Kreutzmann , 2006. +# This file is distributed under the same license as the mplayer package. +# +msgid "" +msgstr "" +"Project-Id-Version: mplayer 1.0~rc1-17\n" +"Report-Msgid-Bugs-To: mennucc1@debian.org\n" +"POT-Creation-Date: 2007-10-18 10:01+0200\n" +"PO-Revision-Date: 2007-10-27 15:25+0200\n" +"Last-Translator: Helge Kreutzmann \n" +"Language-Team: German \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=ISO-8859-15\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "Detailed configuration needed for each user" +msgstr "Fr jeden Benutzer wird eine detaillierte Konfiguration bentigt" + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "" +"The performance of MPlayer depends heavily on hardware; this means that it " +"may benefit from tweaking options for every single machine it's installed on." +msgstr "" +"Die Leistung von MPlayer hngt stark von der Hardware ab; das bedeutet, das " +"MPlayer von der Anpassung auf jeder einzelnen Maschine profitiert, auf der " +"es installiert ist." + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "" +"You should read the documentation provided by the 'mplayer-doc' package." +msgstr "Sie sollten die im Paket mplayer-doc enthaltene Dokumentation lesen." + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "" +"Now, some configuration options will be set for the entire system in /etc/" +"mplayer/mplayer.conf which may be adapted later. Any user can also refine " +"options in ~/.mplayer/config." +msgstr "" +"Jetzt werden einige Konfigurationsoptionen fr das gesamte System in /etc/" +"mplayer/mplayer.conf gesetzt, die spter angepasst werden knnen. Jeder " +"Benutzer kann die Optionen auch in ~/.mplayer/config anpassen." + +#. Type: boolean +#. Description +#: ../mplayer.templates:3001 +msgid "Replace existing configuration file?" +msgstr "Vorhandene Konfigurationsdatei ersetzen?" + +#. Type: boolean +#. Description +#: ../mplayer.templates:3001 +msgid "" +"An /etc/mplayer/mplayer.conf file already exists on the system and does not " +"contain an automatically-generated part. That file can be replaced by a " +"generated one (the old file will be moved to /etc/mplayer/mplayer.conf." +"debconf-old)." +msgstr "" +"Eine Datei /etc/mplayer/mplayer.conf existiert bereits auf diesem System, " +"die keinen automatisch erstellten Teil enthlt. Diese Datei kann durch eine " +"generierte ersetzt werden (die alte Datei wird in /etc/mplayer/mplayer.conf." +"debconf-old umbenannt)." + +#. Type: note +#. Description +#: ../mplayer.templates:4001 +msgid "Old configuration file kept" +msgstr "Alte Konfigurationsdatei beibehalten" + +#. Type: note +#. Description +#: ../mplayer.templates:4001 +msgid "You chose not to replace the existing /etc/mplayer/mplayer.conf file." +msgstr "" +"Sie haben sich entschieden, die existierende Datei /etc/mplayer/mplayer.conf " +"zu behalten." + +#. Type: note +#. Description +#: ../mplayer.templates:4001 +msgid "" +"That file can be generated automatically later by running 'dpkg-reconfigure " +"mplayer'." +msgstr "" +"Diese Datei kann spter automatisch generiert werden, indem dpkg-" +"reconfigure mplayer ausgefhrt wird." + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "MPlayer video output:" +msgstr "Videoausgabe von MPlayer:" + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "" +"MPlayer can use a very wide range of video output drivers. The needed driver " +"may be detected automatically or chosen manually." +msgstr "" +"MPlayer kann eine sehr groe Anzahl von Video-Ausgabegerten verwenden. Die " +"bentigten Treiber knnen automatisch erkannt oder manuell ausgewhlt werden." + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "" +"If you prefer choosing the driver yourself, you first should choose an entry " +"matching this system's video card. If none match and the card supports 'XV', " +"choose that option (the 'xvinfo' command may help)." +msgstr "" +"Falls Sie den Treiber lieber selbst auswhlen mchten, sollten Sie zuerst " +"einen Eintrag auswhlen, der zu der Grafikkarte dieses Systems passt. Falls " +"keiner passt und die Karte XV untersttzt, whlen Sie diese Option " +"(hierbei kann der Befehl xvinfo helfen)." + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "" +"Please read the /usr/share/doc/mplayer-doc/HTML/en/video.html file from the " +"'mplayer-doc' package for more details." +msgstr "" +"Bitte lesen Sie die Datei /usr/share/doc/mplayer-doc/HTML/en/video.html im " +"Paket mplayer-doc fr weitere Details." + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "Binary codecs download" +msgstr "Download von binren Codecs" + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "MPlayer supports most video formats without additional software." +msgstr "" +"MPlayer untersttzt die meisten Videoformate ohne zustzliche Software." + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "" +"Additional video formats, such as Real 3.0/4.0, Windows Media 9, or " +"Quicktime, can be supported by using binary codecs." +msgstr "" +"Zustzliche Videoformate, wie Real 3.0/4.0, Windows Media 9 oder Quicktime " +"knnen durch den Einsatz von binren Codecs untersttzt werden." + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "" +"As such codecs are not free software, they are not distributed with this " +"package but can be downloaded freely. The '/usr/share/mplayer/scripts/" +"binary_codecs.sh' script is provided in this package to help downloading " +"them from the MPlayer web site." +msgstr "" +"Da solche Codecs keine Freie Software sind, werden sie nicht mit diesem " +"Paket vertrieben, knnen aber kostenfrei heruntergeladen werden. In diesem " +"Paket wird das Skript /usr/share/mplayer/scripts/binary_codecs.sh " +"bereitgestellt, um beim Herunterladen von der MPlayer-Website zu helfen." + +#. Type: string +#. Description +#: ../mplayer.templates:7001 +msgid "DVD device name:" +msgstr "DVD-Gertename:" + +#. Type: string +#. Description +#: ../mplayer.templates:7001 +msgid "Please enter the name of the device for your DVD player, if any." +msgstr "" +"Bitte geben Sie - falls vorhanden - den Namen des Gertes Ihres DVD-Spielers " +"an." + +#. Type: select +#. Description +#: ../mplayer.templates:8001 +msgid "Font for On Screen Display:" +msgstr "Schriften fr eingeblendeten Text:" + +#. Type: error +#. Description +#: ../mplayer.templates:9001 +msgid "No TrueType fonts found for On Screen Display" +msgstr "Fr eingeblendeten Text konnte keine TrueType-Schrift gefunden werden" + +#. Type: error +#. Description +#: ../mplayer.templates:9001 +msgid "" +"MPlayer needs at least one TrueType font for its 'On Screen Display' feature." +msgstr "" +"MPlayer bentigt mindestens eine TrueType-Schrift fr seine Funktionalitt " +"eingeblendeten Text (On Screen Display)." + +#. Type: error +#. Description +#: ../mplayer.templates:9001 +msgid "" +"You should install a package providing such fonts (such as 'ttf-freefont' or " +"'ttf-bitstream-vera' or 'msttcorefonts') and reconfigure MPlayer (by running " +"'dpkg-reconfigure mplayer')." +msgstr "" +"Sie sollten ein Paket installieren, das solche Schriften enthlt (wie ttf-" +"freefont oder ttf-bitstream-vera oder msttcorefonts) und MPlayer " +"rekonfigurieren (durch die Ausfhrung von dpkg-reconfigure mplayer)." + +#~ msgid "Create your ~/.mplayer/config file" +#~ msgstr "Erstelle Ihre ~/.mplayer/config-Datei" + +#~ msgid "" +#~ "Performance of MPlayer depends heavily on hardware - this means that it " +#~ "may benefit from tweaking options, for every single machine it's " +#~ "installed to. You may wish to read the documentation (it is in the " +#~ "package 'mplayer-doc', under /usr/share/doc/mplayer-doc/). This DebConf " +#~ "interface will help you setup just a few main features; you may wish to " +#~ "add to /etc/mplayer/mplayer.conf some more refined options (to enable " +#~ "multichannel audio, or video postprocessing, etc etc); and any user " +#~ "similarly may customize MPlayer using the file ~/.mplayer/config" +#~ msgstr "" +#~ "Die Leistung von MPlayer hngt stark von der Hardware ab - das bedeutet, " +#~ "dass sie von der Feineinstellung von Optionen auf jeder einzelnen " +#~ "Maschine abhngen kann. Hierzu steht vieles in der Dokumentation (diese " +#~ "ist im Paket mplayer-doc enthalten und unter /share/doc/mplayer-doc/ zu " +#~ "finden). Diese DebConf-Schnittstelle wird Ihnen nur dabei helfen, die " +#~ "wichtigsten Funktionen einzustellen; detailliertere Optionen knnen Sie /" +#~ "etc/mplayer/mplayer.conf hinzufgen (um Mehrkanalton oder " +#~ "Videonachbearbeitung usw. usf. einzustellen). hnlich kann jeder Benutzer " +#~ "mit der Datei ~/.mplayer/config MPlayer anpassen." + +#~ msgid "Enable access to RTC?" +#~ msgstr "Zugriff auf RTC ermglichen?" + +#~ msgid "" +#~ "On older kernels MPlayer can use the RTC (Real Time Clock) to provide " +#~ "better timing in reproduction, with less CPU cost; to this end, though, " +#~ "the device /dev/rtc must be accessible to group audio, and the default " +#~ "max-user-freq must be raised to 1024. Any needed change must be done by " +#~ "root. If you wish, MPlayer will automatically do this at boot, so that " +#~ "any user can enjoy this feature. Note that there may be security issues " +#~ "with this (although none are known now)." +#~ msgstr "" +#~ "Auf lteren Kerneln kann MPlayer die RTC (Echtzeituhr) verwenden, um " +#~ "bessere Zeitkoordination bei der Wiedergabe mit geringerer CPU-Belastung " +#~ "bereitzustellen; um dies zu erreichen, muss allerdings das Gert /dev/rtc " +#~ "fr die Gruppe audio zugreifbar sein; die Standard max-user-freq muss auf " +#~ "1024 erhht werden. Smtliche bentigten nderungen mssen von root " +#~ "durchgefhrt werden. Falls Sie dies mchten, wird MPlayer diese " +#~ "automatisch beim Systemstart durchfhren, so dass jeder Benutzer diese " +#~ "Funktionalitten genieen kann. Beachten Sie, dass es hiermit " +#~ "Sicherheitsprobleme geben kann (allerdings sind derzeit keine bekannt)." + +#~ msgid "Files not replaced" +#~ msgstr "Dateien nicht ersetzt" + +#~ msgid "" +#~ "It seems that you don't want to replace your existing configuration file /" +#~ "etc/mplayer/mplayer.conf. If you change your mind later, you can run " +#~ "\"dpkg-reconfigure mplayer\"." +#~ msgstr "" +#~ "Es scheint, dass Sie Ihre existierende Konfigurationsdatei /etc/mplayer/" +#~ "mplayer.conf nicht ersetzen wollen. Falls Sie Ihre Meinung spter andern, " +#~ "knnen Sie dpkg-reconfigure mplayer ausfhren." + +#~ msgid "" +#~ "MPlayer can use a very wide range of video output drivers; it will try to " +#~ "autodetect the best one, but you may choose a preferred one. Here is a " +#~ "guide to the choice (in decreasing order of speed): (1) if you see an " +#~ "entry that matches your video card, choose that; (2) if your video card " +#~ "supports 'XV', choose that (use 'xvinfo' to know). You should read /usr/" +#~ "share/doc/mplayer-doc/HTML/en/video.html (it is in package 'mplayer-doc')." +#~ msgstr "" +#~ "MPlayer kann eine groe Bandbreite an Video-Ausgabegerten verwenden; es " +#~ "versucht, das beste Gert zu erkennen, aber Sie knnen auch ein " +#~ "bevorzugtes auswhlen. Hier ist ein Ratgeber fr die Wahl (in Reihenfolge " +#~ "absteigender Geschwindigkeit): (1) falls Sie einen Eintrag sehen, der zu " +#~ "Ihrer Videokarte passt, whlen Sie diesen; (2) falls Ihre Videokarte XV " +#~ "untersttzt (mit xvinfo finden Sie dies heraus), verwenden Sie dies. " +#~ "Sie sollten /usr/share/doc/mplayer-doc/HTML/de/video.html (aus dem Paket " +#~ "mplayer-doc) lesen." + +#~ msgid "How to download binary codecs" +#~ msgstr "Wie binrer Codecs heruntergeladen werden" + +#~ msgid "" +#~ "MPlayer supports most codecs out of the box and the rest with the help of " +#~ "binary codecs. Binary codecs are only necessary for Real 3.0 and 4.0, " +#~ "Windows Media 9, QuickTime audio and some very obscure codecs. Debian " +#~ "cannot distribute these codecs, but these are available on the internet " +#~ "for download. Run the script `/usr/share/mplayer/scripts/binary_codecs." +#~ "sh' to install those made available from MPlayer web site." +#~ msgstr "" +#~ "MPlayer untersttzt die meisten Kodierungen von Werk aus und den Rest mit " +#~ "der Hilfe von binren Codecs. Binre Codecs werden nur fr Real 3.0 und " +#~ "4.0, Windows Media 9, QuickTime Audio und einige sehr unbedeutende " +#~ "Kodierungen bentigt. Debian kann diese Codes nicht vertreiben, aber sie " +#~ "sind im Internet zum Download erhltlich. Fhren Sie das Skript /usr/" +#~ "share/mplayer/scripts/binary_codecs.sh aus, um diejenigen zu " +#~ "installieren, die von der MPlayer-Website bereitgestellt werden." + +#~ msgid "What is the name of your DVD device (if any):" +#~ msgstr "Wie lautet der Name Ihres DVD-Gerts (falls vorhanden):" + +#~ msgid "MPlayer OSD font:" +#~ msgstr "MPlayer OSD-Schrift" + +#~ msgid "MPlayer cannot find TrueType Fonts" +#~ msgstr "MPlayer kann keine TrueType-Schriften finden" diff --git a/debian/po/es.po b/debian/po/es.po new file mode 100644 index 0000000..7d1a5d1 --- /dev/null +++ b/debian/po/es.po @@ -0,0 +1,355 @@ +# mplayer po-debconf translation to spanish +# Copyright (C) 2005 Software in the Public Interest, SPI Inc. +# This file is distributed under the same license as the mplayer package. +# +# Changes: +# - Initial translation +# Javier Fernndez-Sanguino , 2005 +# +# +# Traductores, si no conoce el formato PO, merece la pena leer la +# documentacin de gettext, especialmente las secciones dedicadas a este +# formato, por ejemplo ejecutando: +# info -n '(gettext)PO Files' +# info -n '(gettext)Header Entry' +# +# Equipo de traduccin al espaol, por favor lean antes de traducir +# los siguientes documentos: +# +# - El proyecto de traduccin de Debian al espaol +# http://www.debian.org/intl/spanish/ +# especialmente las notas y normas de traduccin en +# http://www.debian.org/intl/spanish/notas +# +# - La gua de traduccin de po's de debconf: +# /usr/share/doc/po-debconf/README-trans +# o http://www.debian.org/intl/l10n/po-debconf/README-trans +# +# Si tiene dudas o consultas sobre esta traduccin consulte con el ltimo +# traductor (campo Last-Translator) y ponga en copia a la lista de +# traduccin de Debian al espaol () +# +# +msgid "" +msgstr "" +"Project-Id-Version: mplayer 1.0~rc1-4\n" +"Report-Msgid-Bugs-To: mennucc1@debian.org\n" +"POT-Creation-Date: 2007-10-18 10:01+0200\n" +"PO-Revision-Date: 2007-10-21 02:34+0200\n" +"Last-Translator: Javier Fernndez-Sanguino \n" +"Language-Team: Debian l10n Spanish \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=ISO-8859-15\n" +"Content-Transfer-Encoding: 8bit\n" +"X-POFile-SpellExtra: old bitstream share video vd ttf xvinfo Screen\n" +"X-POFile-SpellExtra: Quicktime html usr config On freefont msttcorefonts\n" +"X-POFile-SpellExtra: MPlayer scripts XV Display dpkg TrueType doc\n" +"X-POFile-SpellExtra: binarycodecs sh mplayer debconf conf\n" + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "Detailed configuration needed for each user" +msgstr "Es necesaria una configuracin detallada por cada usuario" + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "" +"The performance of MPlayer depends heavily on hardware; this means that it " +"may benefit from tweaking options for every single machine it's installed on." +msgstr "" +"El rendimiento de MPlayer dependen en gran medida del hardware, lo que " +"significa que puede beneficiarse del ajuste de algunas opciones en cada " +"equipo que se instale." + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "" +"You should read the documentation provided by the 'mplayer-doc' package." +msgstr "" +"Debera consultar la documentacin que se incluye en el paquete mplayer-" +"doc." + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "" +"Now, some configuration options will be set for the entire system in /etc/" +"mplayer/mplayer.conf which may be adapted later. Any user can also refine " +"options in ~/.mplayer/config." +msgstr "" +"Se definirn algunas opciones de configuracin para todo el sistema en /etc/" +"mplayer/mplayer.conf que podr adaptar ms adelante. Los usuarios pueden " +"refinar las opciones en ~/.mplayer/config." + +#. Type: boolean +#. Description +#: ../mplayer.templates:3001 +msgid "Replace existing configuration file?" +msgstr "Desea reemplazar el fichero de configuracin actual?" + +#. Type: boolean +#. Description +#: ../mplayer.templates:3001 +msgid "" +"An /etc/mplayer/mplayer.conf file already exists on the system and does not " +"contain an automatically-generated part. That file can be replaced by a " +"generated one (the old file will be moved to /etc/mplayer/mplayer.conf." +"debconf-old)." +msgstr "" +"Ya existe un fichero /etc/mplayer/mplayer.conf, pero no contiene la zona " +"que se genera de forma automtica. Este fichero puede reemplazarse por uno " +"nuevo generado automticamente (el antiguo se mover a /etc/mplayer/mplayer." +"conf.debconf-old)." + +#. Type: note +#. Description +#: ../mplayer.templates:4001 +msgid "Old configuration file kept" +msgstr "Antiguo fichero de configuracin mantenido" + +#. Type: note +#. Description +#: ../mplayer.templates:4001 +msgid "You chose not to replace the existing /etc/mplayer/mplayer.conf file." +msgstr "" +"Escogi no reemplazar el fichero /etc/mplayer/mplayer.conf existente." + +#. Type: note +#. Description +#: ../mplayer.templates:4001 +msgid "" +"That file can be generated automatically later by running 'dpkg-reconfigure " +"mplayer'." +msgstr "" +"Se puede generar el fichero automticamente ms adelante ejecutando dpkg-" +"reconfigure mplayer." + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "MPlayer video output:" +msgstr "Salida de vdeo de MPlayer:" + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "" +"MPlayer can use a very wide range of video output drivers. The needed driver " +"may be detected automatically or chosen manually." +msgstr "" +"MPlayer puede utilizar un amplio rango de dispositivos de vdeo para la " +"salida. El dispositivo a utilizar se puede escoger manualmente o detectar " +"automticamente." + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "" +"If you prefer choosing the driver yourself, you first should choose an entry " +"matching this system's video card. If none match and the card supports 'XV', " +"choose that option (the 'xvinfo' command may help)." +msgstr "" +"Debera escoger primero una entrada que se ajuste a la tarjeta de vdeo del " +"sistema si decide elegirla vd. mismo. Si no encuentra ninguna que " +"corresponda a su tarjeta y sta soporta XV escoja esta opcin (puede " +"ayudarle la orden xvinfo)." + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "" +"Please read the /usr/share/doc/mplayer-doc/HTML/en/video.html file from the " +"'mplayer-doc' package for more details." +msgstr "" +"Consulte el archivo /usr/share/doc/mplayer-doc/HTML/en/video.html en el " +"paquete mplayer-doc para ms informacin." + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "Binary codecs download" +msgstr "Descarga de codificadores binarios" + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "MPlayer supports most video formats without additional software." +msgstr "" +"MPlayer soporta la mayora de los formatos de vdeo sin necesidad de " +"programas adicionales." + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "" +"Additional video formats, such as Real 3.0/4.0, Windows Media 9, or " +"Quicktime, can be supported by using binary codecs." +msgstr "" +"Puede obtener soporte de formatos de vdeo adicionales, como Real 3.0/4.0, " +"Windows Media 9 o Quicktime, a travs de codificadores binarios." + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "" +"As such codecs are not free software, they are not distributed with this " +"package but can be downloaded freely. The '/usr/share/mplayer/scripts/" +"binary_codecs.sh' script is provided in this package to help downloading " +"them from the MPlayer web site." +msgstr "" +"Estos codificadores no son software libre, no se incluyen en este paquete " +"pero pueden descargarse. Este paquete incluye el programa /usr/share/" +"mplayer/scripts/binary_codecs.sh para ayudar a la descarga de estos " +"programas del sitio web de MPlayer." + +#. Type: string +#. Description +#: ../mplayer.templates:7001 +msgid "DVD device name:" +msgstr "Nombre de dispositivo DVD:" + +#. Type: string +#. Description +#: ../mplayer.templates:7001 +msgid "Please enter the name of the device for your DVD player, if any." +msgstr "" +"Introduzca un nombre para el dispositivo de su reproductor de DVD, si lo " +"tiene." + +#. Type: select +#. Description +#: ../mplayer.templates:8001 +msgid "Font for On Screen Display:" +msgstr "Tipografa para On Screen Display:" + +#. Type: error +#. Description +#: ../mplayer.templates:9001 +msgid "No TrueType fonts found for On Screen Display" +msgstr "No se han encontrado tipografas TrueType para On Screen Display." + +#. Type: error +#. Description +#: ../mplayer.templates:9001 +msgid "" +"MPlayer needs at least one TrueType font for its 'On Screen Display' feature." +msgstr "" +"MPlayer necesita al menos una tipografa TrueType para su funcin On Screen " +"Display." + +#. Type: error +#. Description +#: ../mplayer.templates:9001 +msgid "" +"You should install a package providing such fonts (such as 'ttf-freefont' or " +"'ttf-bitstream-vera' or 'msttcorefonts') and reconfigure MPlayer (by running " +"'dpkg-reconfigure mplayer')." +msgstr "" +"Debera instalar un paquete que contenga esas tipografas (como ttf-" +"freefont, ttf-bitstream-vera o msttcorefonts) y reconfigurar MPlayer " +"(con la orden dpkg-reconfigure mplayer)." + +#~ msgid "Create your ~/.mplayer/config file" +#~ msgstr "Crear su archivo ~/.mplayer/config" + +#~ msgid "" +#~ "Performance of MPlayer depends heavily on hardware - this means that it " +#~ "may benefit from tweaking options, for every single machine it's " +#~ "installed to. You may wish to read the documentation (it is in the " +#~ "package 'mplayer-doc', under /usr/share/doc/mplayer-doc/). This DebConf " +#~ "interface will help you setup just a few main features; you may wish to " +#~ "add to /etc/mplayer/mplayer.conf some more refined options (to enable " +#~ "multichannel audio, or video postprocessing, etc etc); and any user " +#~ "similarly may customize MPlayer using the file ~/.mplayer/config" +#~ msgstr "" +#~ "El rendimiento de MPlayer depende en gran medida del hardware, lo que " +#~ "significa que puede beneficiarse de distintos ajustes en las opciones en " +#~ "cada equipo en el que se instale. Quizs desee leer la documentacin " +#~ "(est disponible en el paquete mplayer-doc, en /usr/share/doc/mplayer-" +#~ "doc/). Esta interfaz DebConf le asistir a configurar slo algunas de " +#~ "las funcionalidades principales. Puede que desee aadir a /etc/mplayer/" +#~ "mplayer.conf algunas opciones ms especficas (como el posprocesado de " +#~ "vdeo o la activacin de audio multicanal). Cualquier usuario puede " +#~ "ajustar MPlayer utilizando el archivo ~/.mplayer/config." + +#~ msgid "Enable access to RTC?" +#~ msgstr "Habilitar el acceso al RTC?" + +#~ msgid "" +#~ "On older kernels MPlayer can use the RTC (Real Time Clock) to provide " +#~ "better timing in reproduction, with less CPU cost; to this end, though, " +#~ "the device /dev/rtc must be accessible to group audio, and the default " +#~ "max-user-freq must be raised to 1024. Any needed change must be done by " +#~ "root. If you wish, MPlayer will automatically do this at boot, so that " +#~ "any user can enjoy this feature. Note that there may be security issues " +#~ "with this (although none are known now)." +#~ msgstr "" +#~ "MPlayer puede utilizar el RTC (Real Time Clock o reloj de tiempo real) " +#~ "en ncleos antiguos para permitir un mejor ajuste de la reproduccin con " +#~ "menor consumo de CPU. Para poder hacer esto es necesario que el grupo " +#~ "audio pueda acceder al dispositivo /dev/rtc, y se debe incrementar el " +#~ "valor de max-user-freq, por omisin a 1024. Cualquiera de estos cambios " +#~ "debe hacerse como superusuario. Si lo desea, MPlayer har estos cambios " +#~ "de forma automtica en el arranque para que todos los usuarios puedan " +#~ "beneficiarse de esta funcionalidad. Tenga en cuenta que puede haber un " +#~ "riesgo de seguridad al habilitar sto (aunque de momento no se conoce " +#~ "ningn problema)." + +#~ msgid "Files not replaced" +#~ msgstr "No se reemplazaron los archivos" + +#~ msgid "" +#~ "It seems that you don't want to replace your existing configuration file /" +#~ "etc/mplayer/mplayer.conf. If you change your mind later, you can run " +#~ "\"dpkg-reconfigure mplayer\"." +#~ msgstr "" +#~ "Parece que no desea reemplazar su fichero de configuracin /etc/mplayer/" +#~ "mplayer.conf. Si cambia de opinin ms adelante, puede hacerlo " +#~ "ejecutando dpkg-reconfigure mplayer." + +#~ msgid "" +#~ "MPlayer can use a very wide range of video output drivers; it will try to " +#~ "autodetect the best one, but you may choose a preferred one. Here is a " +#~ "guide to the choice (in decreasing order of speed): (1) if you see an " +#~ "entry that matches your video card, choose that; (2) if your video card " +#~ "supports 'XV', choose that (use 'xvinfo' to know). You should read /usr/" +#~ "share/doc/mplayer-doc/HTML/en/video.html (it is in package 'mplayer-doc')." +#~ msgstr "" +#~ "MPlayer puede usar un conjunto muy amplio de dispositivos de salida de " +#~ "vdeo. Se intentar autodetectar el ms apropiado, pero puede tambin " +#~ "elegir el que prefiere. sta es una gua para hacer la eleccin (en orden " +#~ "de velocidad decreciente): (1) si ve una entrada que coincida con su " +#~ "tarjeta de vdeo, seleccinela, (2) si su tarjeta de vdeo tiene soporte " +#~ "de XV, escgala (utilice xvinfo para confirmarlo). Debera leer /usr/" +#~ "share/doc/mplayer-doc/HTML/es/video.html (en el paquete mplayer-doc)." + +#~ msgid "How to download binary codecs" +#~ msgstr "Cmo se deben descargar los codecs binarios?" + +#~ msgid "" +#~ "MPlayer supports most codecs out of the box and the rest with the help of " +#~ "binary codecs. Binary codecs are only necessary for Real 3.0 and 4.0, " +#~ "Windows Media 9, QuickTime audio and some very obscure codecs. Debian " +#~ "cannot distribute these codecs, but these are available on the internet " +#~ "for download. Run the script `/usr/share/mplayer/scripts/binary_codecs." +#~ "sh' to install those made available from MPlayer web site." +#~ msgstr "" +#~ "MPlayer tiene soporte para la mayora de los codecs en una instalacin " +#~ "normal y para el resto utiliza codecs binarios. Slo necesita codecs " +#~ "binarios para archivos Real 3.0 y 4.0, Windows Media 9, audio Quicktime y " +#~ "para otros codecs muy raros. El proyecto Debian no puede distribuir estos " +#~ "codecs pero estn disponibles en Internet y pueden descargarse. Ejecute " +#~ "el programa /usr/share/mplayer/scripts/binary_codecs.sh si desea " +#~ "instalar los codecs disponibles en el sitio web de MPlayer." + +#~ msgid "What is the name of your DVD device (if any):" +#~ msgstr "Cul es el nombre de su dispositivo DVD? (si lo tiene):" + +#~ msgid "MPlayer OSD font:" +#~ msgstr "Tipografa OSD para MPlayer:" + +#~ msgid "MPlayer cannot find TrueType Fonts" +#~ msgstr "MPlayer no puede encontrar tipografas TrueType" diff --git a/debian/po/fi.po b/debian/po/fi.po new file mode 100644 index 0000000..76a45ec --- /dev/null +++ b/debian/po/fi.po @@ -0,0 +1,210 @@ +msgid "" +msgstr "" +"Project-Id-Version: mplayer\n" +"Report-Msgid-Bugs-To: mennucc1@debian.org\n" +"POT-Creation-Date: 2007-10-18 10:01+0200\n" +"PO-Revision-Date: 2007-10-20 14:41+0200\n" +"Last-Translator: Esko Arajärvi \n" +"Language-Team: Finnish \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Poedit-Language: Finnish\n" +"X-Poedit-Country: FINLAND\n" + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "Detailed configuration needed for each user" +msgstr "Jokaiselle käyttäjälle tarvitaan yksityiskohtaiset asetukset" + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "" +"The performance of MPlayer depends heavily on hardware; this means that it " +"may benefit from tweaking options for every single machine it's installed on." +msgstr "" +"MPlayerin suorituskyky riippuu vahvasti laitteistosta. Tämä tarkoittaa, että " +"se saattaa hyötyä kunkin tietokoneen paranteluominaisuuksista." + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "" +"You should read the documentation provided by the 'mplayer-doc' package." +msgstr "Lue paketin ”mplayer-doc” tarjoama (englanninkielinen) dokumentaatio." + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "" +"Now, some configuration options will be set for the entire system in /etc/" +"mplayer/mplayer.conf which may be adapted later. Any user can also refine " +"options in ~/.mplayer/config." +msgstr "" +"Joitain asetuksia asetetaan järjestelmän laajuisesti tiedostossa /etc/" +"mplayer/mplayer.conf, jota voidaan mukauttaa myöhemmin. Kukin käyttäjä voi " +"myös parannella asetuksia tiedostossa ~/.mplayer/config." + +#. Type: boolean +#. Description +#: ../mplayer.templates:3001 +msgid "Replace existing configuration file?" +msgstr "Korvataanko olemassa oleva asetustiedosto?" + +#. Type: boolean +#. Description +#: ../mplayer.templates:3001 +msgid "" +"An /etc/mplayer/mplayer.conf file already exists on the system and does not " +"contain an automatically-generated part. That file can be replaced by a " +"generated one (the old file will be moved to /etc/mplayer/mplayer.conf." +"debconf-old)." +msgstr "" +"Järjestelmässä on jo tiedosto /etc/mplayer/mplayer.conf, joka ei sisällä " +"automaattisesti luotua osaa. Kyseinen tiedosto voidaan korvata luodulla " +"(vanha siirretään nimelle /etc/mplayer/mplayer.conf.debconf-old)." + +#. Type: note +#. Description +#: ../mplayer.templates:4001 +msgid "Old configuration file kept" +msgstr "Vanha asetustiedosto säilytetty" + +#. Type: note +#. Description +#: ../mplayer.templates:4001 +msgid "You chose not to replace the existing /etc/mplayer/mplayer.conf file." +msgstr "" +"Valitsit, että olemassa olevaa tiedostoa /etc/mplayer/mplayer.conf ei " +"korvata." + +#. Type: note +#. Description +#: ../mplayer.templates:4001 +msgid "" +"That file can be generated automatically later by running 'dpkg-reconfigure " +"mplayer'." +msgstr "" +"Kyseinen tiedosto voidaan luoda automaattisesti myöhemmin käskyllä ”dpkg-" +"reconfigure mplayer”." + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "MPlayer video output:" +msgstr "Mplayerin videoulostulo:" + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "" +"MPlayer can use a very wide range of video output drivers. The needed driver " +"may be detected automatically or chosen manually." +msgstr "" +"MPlayer voi käyttää erittäin laajaa kirjoa videoulostuloajureita. Tarvittava " +"ajuri voidaan etsiä automaattisesti tai valita käsin." + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "" +"If you prefer choosing the driver yourself, you first should choose an entry " +"matching this system's video card. If none match and the card supports 'XV', " +"choose that option (the 'xvinfo' command may help)." +msgstr "" +"Jos suosit ajurin valitsemista käsin, sinun tulisi ensin valita kohta, joka " +"vastaa järjestelmän näyttökorttia. Jos mikään ei sovi ja kortti tukee ”XV”:" +"tä, valitse tuo vaihtoehto (komento ”xvinfo” saattaa auttaa)." + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "" +"Please read the /usr/share/doc/mplayer-doc/HTML/en/video.html file from the " +"'mplayer-doc' package for more details." +msgstr "" +"Lisätietoja englanniksi löytyy paketin ”mplayer-doc” tiedostosta /usr/share/" +"doc/mplayer-doc/HTML/en/video.html." + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "Binary codecs download" +msgstr "Binäärikoodekkien lataus" + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "MPlayer supports most video formats without additional software." +msgstr "MPlayer tukee useimpia videomuotoja ilman lisäohjelmia." + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "" +"Additional video formats, such as Real 3.0/4.0, Windows Media 9, or " +"Quicktime, can be supported by using binary codecs." +msgstr "" +"Lisävideomuotoja, kuten Real 3.0/4.0, Windows Media 9 ja Quicktime voidaan " +"tukea käyttämällä binäärikoodekkeja." + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "" +"As such codecs are not free software, they are not distributed with this " +"package but can be downloaded freely. The '/usr/share/mplayer/scripts/" +"binary_codecs.sh' script is provided in this package to help downloading " +"them from the MPlayer web site." +msgstr "" +"Koodekit eivät sinänsä ole vapaita ohjelmistoja, eikä niitä levitetä tämän " +"paketin mukana, mutta ne voi ladata ilmaiseksi. Paketin mukana toimitettu " +"komentotiedosto ”/usr/share/mplayer/scripts/binary_codecs.sh” auttaa niiden " +"lataamisessa MPlayerin verkkosivulta." + +#. Type: string +#. Description +#: ../mplayer.templates:7001 +msgid "DVD device name:" +msgstr "DVD-laitteen nimi:" + +#. Type: string +#. Description +#: ../mplayer.templates:7001 +msgid "Please enter the name of the device for your DVD player, if any." +msgstr "Anna DVD-soittimen laitenimi, jos järjestelmässä on sellainen." + +#. Type: select +#. Description +#: ../mplayer.templates:8001 +msgid "Font for On Screen Display:" +msgstr "Ruudulle piirrossa käytettävä fontti:" + +#. Type: error +#. Description +#: ../mplayer.templates:9001 +msgid "No TrueType fonts found for On Screen Display" +msgstr "Ruudulle piirtoon käytettäväksi ei löytynyt yhtään TrueType-fonttia." + +#. Type: error +#. Description +#: ../mplayer.templates:9001 +msgid "" +"MPlayer needs at least one TrueType font for its 'On Screen Display' feature." +msgstr "" +"Mplayer tarvitsee vähintään yhden TrueType-fontin sen ”ruudulle piirto” (”On " +"Screen Display”) -ominaisuutta varten." + +#. Type: error +#. Description +#: ../mplayer.templates:9001 +msgid "" +"You should install a package providing such fonts (such as 'ttf-freefont' or " +"'ttf-bitstream-vera' or 'msttcorefonts') and reconfigure MPlayer (by running " +"'dpkg-reconfigure mplayer')." +msgstr "" +"Sinun tulisi asentaa tällaisia fontteja tarjoava paketti (kuten ”ttf-" +"freefont”, ”ttf-bitstream-vera” tai ”msttcorefonts”) ja tehdä MPlayerin " +"asetukset uudelleen (komennolla ”dpkg-reconfigure mplayer”)." diff --git a/debian/po/fr.po b/debian/po/fr.po new file mode 100644 index 0000000..3deb056 --- /dev/null +++ b/debian/po/fr.po @@ -0,0 +1,218 @@ +# Translation of mplayer debconf templates to French +# Copyright (C) 2006 Yves Rütschlé +# This file is distributed under the same license as the mplayer package. +# +msgid "" +msgstr "" +"Project-Id-Version: mplayer\n" +"Report-Msgid-Bugs-To: mennucc1@debian.org\n" +"POT-Creation-Date: 2007-10-28 09:36+0100\n" +"PO-Revision-Date: 2007-10-29 21:12+0100\n" +"Last-Translator: Yves Rütschlé \n" +"Language-Team: French \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "Detailed configuration needed for each user" +msgstr "Configuration détaillée par utilisateur" + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "" +"The performance of MPlayer depends heavily on hardware; this means that it " +"may benefit from tweaking options for every single machine it's installed on." +msgstr "" +"Les performances de MPlayer dépendent énormément du matériel. Jouer sur les " +"options pour chaque machine peut donc les améliorer." + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "" +"You should read the documentation provided by the 'mplayer-doc' package." +msgstr "" +"Vous devriez lire la documentation qui est fournie dans le paquet « mplayer-" +"doc »." + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "" +"Now, some configuration options will be set for the entire system in /etc/" +"mplayer/mplayer.conf which may be adapted later. Any user can also refine " +"options in ~/.mplayer/config." +msgstr "" +"Certaines options globales au système vont être réglées dans le fichier /etc/" +"mplayer/mplayer.conf, et pourront être adaptées par la suite. Chaque " +"utilisateur peut également établir des réglages personnels dans ~/.mplayer/" +"config." + +#. Type: boolean +#. Description +#: ../mplayer.templates:3001 +msgid "Replace existing configuration file?" +msgstr "Faut-il remplacer le fichier de configuration existant ?" + +#. Type: boolean +#. Description +#: ../mplayer.templates:3001 +msgid "" +"An /etc/mplayer/mplayer.conf file already exists on the system and does not " +"contain an automatically-generated part. That file can be replaced by a " +"generated one (the old file will be moved to /etc/mplayer/mplayer.conf." +"debconf-old)." +msgstr "" +"Un fichier /etc/mplayer/mplayer.conf existe déjà, mais il ne contient pas de " +"section créée automatiquement. Il est possible de créer automatiquement un " +"nouveau fichier. L'ancien fichier sera alors renommé /etc/mplayer/mplayer." +"conf.debconf-old." + +#. Type: note +#. Description +#: ../mplayer.templates:4001 +msgid "Old configuration file kept" +msgstr "Conservation du fichier de configuration existant" + +#. Type: note +#. Description +#: ../mplayer.templates:4001 +msgid "You chose not to replace the existing /etc/mplayer/mplayer.conf file." +msgstr "" +"Vous avez choisi de remplacer le fichier /etc/mplayer/mplayer.conf existant." + +#. Type: note +#. Description +#: ../mplayer.templates:4001 +msgid "" +"That file can be generated automatically later by running 'dpkg-reconfigure " +"mplayer'." +msgstr "" +"Ce fichier peut être créé automatiquement avec la commande « dpkg-" +"reconfigure mplayer »." + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "MPlayer video output:" +msgstr "Sortie vidéo de MPlayer :" + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "" +"MPlayer can use a very wide range of video output drivers. The needed driver " +"may be detected automatically or chosen manually." +msgstr "" +"MPlayer peut utiliser de nombreux pilotes de sortie vidéo. Les pilotes " +"requis peuvent être détectés automatiquement ou choisis manuellement." + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "" +"If you prefer choosing the driver yourself, you first should choose an entry " +"matching this system's video card. If none match and the card supports 'XV', " +"choose that option (the 'xvinfo' command may help)." +msgstr "" +"Si vous préférez choisir le pilote, vous devez le choisir parmi les pilotes " +"correspondant à la carte vidéo du système. Si aucun ne correspond et que la " +"carte gère « XV », choisissez cette option. La commande « xvinfo » peut être " +"utile pour identifier cette fonctionnalité." + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "" +"Please read the /usr/share/doc/mplayer-doc/HTML/en/video.html file from the " +"'mplayer-doc' package for more details." +msgstr "" +"Veuillez lire le fichier /usr/share/doc/mplayer-doc/HTML/en/video.html du " +"paquet « mplayer-doc » pour plus de détails." + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "Binary codecs download" +msgstr "Téléchargement de codecs binaires" + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "MPlayer supports most video formats without additional software." +msgstr "MPlayer gère la plupart des formats vidéos sans logiciel additionnel." + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "" +"Additional video formats, such as Real 3.0/4.0, Windows Media 9, or " +"Quicktime, can be supported by using binary codecs." +msgstr "" +"Certains formats vidéos, tels que Real 3.0 et 4.0, Windows Media 9 ou encore " +"Quicktime, peuvent être gérés en utilisant des « codecs » binaires." + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "" +"As such codecs are not free software, they are not distributed with this " +"package but can be downloaded freely. The '/usr/share/mplayer/scripts/" +"binary_codecs.sh' script is provided in this package to help downloading " +"them from the MPlayer web site." +msgstr "" +"Comme ces « codecs » ne sont pas libres, ils ne sont pas distribués dans ce " +"paquet, mais ils peuvent être téléchargés gratuitement. Le script « /usr/" +"share/mplayer/scripts/binary_codecs.sh » est fourni pour aider au " +"téléchargement sur le site de MPlayer." + +#. Type: string +#. Description +#: ../mplayer.templates:7001 +msgid "DVD device name:" +msgstr "Nom du fichier de périphérique DVD :" + +#. Type: string +#. Description +#: ../mplayer.templates:7001 +msgid "Please enter the name of the device for your DVD player, if any." +msgstr "" +"Veuillez indiquer le nom de périphérique de votre lecteur DVD, s'il en " +"existe un." + +#. Type: select +#. Description +#: ../mplayer.templates:8001 +msgid "Font for On Screen Display:" +msgstr "Police pour l'affichage OSD :" + +#. Type: error +#. Description +#: ../mplayer.templates:9001 +msgid "No TrueType fonts found for On Screen Display" +msgstr "Pas de police TrueType pour l'affichage à l'écran" + +#. Type: error +#. Description +#: ../mplayer.templates:9001 +msgid "" +"MPlayer needs at least one TrueType font for its 'On Screen Display' feature." +msgstr "" +"Au moins une police TrueType doit être installée pour que la fonction " +"d'affichage à l'écran (OSD : « On Screen Display ») fonctionne." + +#. Type: error +#. Description +#: ../mplayer.templates:9001 +msgid "" +"You should install a package providing such fonts (such as 'ttf-freefont' or " +"'ttf-bitstream-vera' or 'msttcorefonts') and reconfigure MPlayer (by running " +"'dpkg-reconfigure mplayer')." +msgstr "" +"Vous devriez installer un paquet contenant des polices TrueType, tel que " +"« ttf-freefont », « ttf-bitstream-vera » ou « msttcorefonts », avant de " +"reconfigurer MPlayer avec la commande « dpkg-reconfigure mplayer »." diff --git a/debian/po/gl.po b/debian/po/gl.po new file mode 100644 index 0000000..3378946 --- /dev/null +++ b/debian/po/gl.po @@ -0,0 +1,217 @@ +# Galician translation of mplayer's debconf templates +# This file is distributed under the same license as the mplayer package. +# Jacobo Tarrio , 2007. +# +msgid "" +msgstr "" +"Project-Id-Version: mplayer\n" +"Report-Msgid-Bugs-To: mennucc1@debian.org\n" +"POT-Creation-Date: 2007-10-18 10:01+0200\n" +"PO-Revision-Date: 2007-10-19 22:07+0100\n" +"Last-Translator: Jacobo Tarrio \n" +"Language-Team: Galician \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "Detailed configuration needed for each user" +msgstr "Precísase dunha configuración detallada para cada usuario" + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "" +"The performance of MPlayer depends heavily on hardware; this means that it " +"may benefit from tweaking options for every single machine it's installed on." +msgstr "" +"O rendemento de MPlayer depende fortemente do hardware; isto quere dicir que " +"pode mellorar axustando as opcións para cada máquina na que se instala." + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "" +"You should read the documentation provided by the 'mplayer-doc' package." +msgstr "" +"Debería consultar a documentación fornecida polo paquete \"mplayer-doc\"." + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "" +"Now, some configuration options will be set for the entire system in /etc/" +"mplayer/mplayer.conf which may be adapted later. Any user can also refine " +"options in ~/.mplayer/config." +msgstr "" +"Agora ben, hanse establecer algunhas opcións de configuración para todo o " +"sistema no ficheiro /etc/mplayer/mplayer.conf, que se poden adaptar máis " +"adiante. Os usuarios tamén poden refinar as opcións no ficheiro ~/.mplayer/" +"config." + +#. Type: boolean +#. Description +#: ../mplayer.templates:3001 +msgid "Replace existing configuration file?" +msgstr "¿Substituír o ficheiro de configuración existente?" + +#. Type: boolean +#. Description +#: ../mplayer.templates:3001 +msgid "" +"An /etc/mplayer/mplayer.conf file already exists on the system and does not " +"contain an automatically-generated part. That file can be replaced by a " +"generated one (the old file will be moved to /etc/mplayer/mplayer.conf." +"debconf-old)." +msgstr "" +"Xa existe un ficheiro /etc/mplayer/mplayer.conf no sistema, e non contén " +"unha parte xerada automaticamente. Este ficheiro pódese substituír por un " +"xerado (hase trasladar o ficheiro antigo a /etc/mplayer/mplayer.conf.debconf-" +"old)." + +#. Type: note +#. Description +#: ../mplayer.templates:4001 +msgid "Old configuration file kept" +msgstr "Consérvase o ficheiro de configuración antigo" + +#. Type: note +#. Description +#: ../mplayer.templates:4001 +msgid "You chose not to replace the existing /etc/mplayer/mplayer.conf file." +msgstr "Decidiu non substituír o ficheiro /etc/mplayer/mplayer.conf existente." + +#. Type: note +#. Description +#: ../mplayer.templates:4001 +msgid "" +"That file can be generated automatically later by running 'dpkg-reconfigure " +"mplayer'." +msgstr "" +"Ese ficheiro pódese xerar automaticamente máis adiante executando \"dpkg-" +"reconfigure mplayer\"." + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "MPlayer video output:" +msgstr "Saída de vídeo de MPlayer:" + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "" +"MPlayer can use a very wide range of video output drivers. The needed driver " +"may be detected automatically or chosen manually." +msgstr "" +"MPlayer pode empregar unha grande cantidade de controladores de saída de " +"vídeo. Pódese detectar automaticamente ou escoller manualmente o controlador " +"necesario." + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "" +"If you prefer choosing the driver yourself, you first should choose an entry " +"matching this system's video card. If none match and the card supports 'XV', " +"choose that option (the 'xvinfo' command may help)." +msgstr "" +"Se prefire escoller o controlador vostede mesmo, debería escoller unha " +"entrada que coincida coa tarxeta gráfica deste sistema. Se ningunha coincide " +"e a tarxeta ten soporte para \"XV\", escolla esa opción (a orde \"xvinfo\" " +"pode axudar)." + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "" +"Please read the /usr/share/doc/mplayer-doc/HTML/en/video.html file from the " +"'mplayer-doc' package for more details." +msgstr "" +"Consulte o ficheiro /usr/share/doc/mplayer-doc/HTML/en/video.html do paquete " +"\"mplayer-doc\" para ter máis detalles." + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "Binary codecs download" +msgstr "Descarga de códecs binarios" + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "MPlayer supports most video formats without additional software." +msgstr "" +"MPlayer soporta a maioría dos formatos de vídeo sen precisar de software " +"adicional." + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "" +"Additional video formats, such as Real 3.0/4.0, Windows Media 9, or " +"Quicktime, can be supported by using binary codecs." +msgstr "" +"Pódense soportar formatos de vídeo adicionais, coma Real 3.0/4.0, Windows " +"Media 9 ou Quicktime, empregando códecs binarios." + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "" +"As such codecs are not free software, they are not distributed with this " +"package but can be downloaded freely. The '/usr/share/mplayer/scripts/" +"binary_codecs.sh' script is provided in this package to help downloading " +"them from the MPlayer web site." +msgstr "" +"Como eses códecs non son software libre, non se distribúen con este paquete, " +"pero pódense descargar libremente. Fornécese o script \"/usr/share/mplayer/" +"scripts/binary_codecs.sh\" neste paquete para axudarlle a descargalos desde " +"a páxina web de MPlayer." + +#. Type: string +#. Description +#: ../mplayer.templates:7001 +msgid "DVD device name:" +msgstr "Nome do dispositivo do DVD:" + +#. Type: string +#. Description +#: ../mplayer.templates:7001 +msgid "Please enter the name of the device for your DVD player, if any." +msgstr "Introduza o nome do dispositivo do reproductor de DVD, se ten un." + +#. Type: select +#. Description +#: ../mplayer.templates:8001 +msgid "Font for On Screen Display:" +msgstr "Tipo de letra para a sobreimpresión de textos:" + +#. Type: error +#. Description +#: ../mplayer.templates:9001 +msgid "No TrueType fonts found for On Screen Display" +msgstr "Non se atopou ningún tipo TrueType para a sobreimpresión de textos." + +#. Type: error +#. Description +#: ../mplayer.templates:9001 +msgid "" +"MPlayer needs at least one TrueType font for its 'On Screen Display' feature." +msgstr "" +"MPlayer precisa de alomenos un tipo TrueType para a súa función de " +"sobreimpresión de textos." + +#. Type: error +#. Description +#: ../mplayer.templates:9001 +msgid "" +"You should install a package providing such fonts (such as 'ttf-freefont' or " +"'ttf-bitstream-vera' or 'msttcorefonts') and reconfigure MPlayer (by running " +"'dpkg-reconfigure mplayer')." +msgstr "" +"Debería instalar un paquete que conteña un deses tipos (tal coma \"ttf-" +"freefont\", \"ttf-bitstream-vera\" ou \"msttcorefonts\") e reconfigurar " +"MPlayer (executando \"dpkg-reconfigure mplayer\")." diff --git a/debian/po/it.po b/debian/po/it.po new file mode 100644 index 0000000..1646bb4 --- /dev/null +++ b/debian/po/it.po @@ -0,0 +1,185 @@ +# translation of mplayer_1.0~rc2-12_templates.po to Italian +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# +# Alex , 2008. +msgid "" +msgstr "" +"Project-Id-Version: mplayer_1.0~rc2-12_templates\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2008-05-05 04:32+0200\n" +"PO-Revision-Date: 2008-05-15 23:02+0200\n" +"Last-Translator: Alex \n" +"Language-Team: Italian \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: KBabel 1.11.4\n" + +#. Type: note +#. Description +#: ../mplayer.templates:1001 +msgid "Detailed configuration needed for each user" +msgstr "Necessaria una configurazione specifica per ogni utilizzatore" + +#. Type: note +#. Description +#: ../mplayer.templates:1001 +msgid "" +"The performance of MPlayer depends heavily on hardware; this means that it " +"may benefit from tweaking options for every single machine it's installed on." +msgstr "Le prestazioni di MPlayer dipendono fortemente dall'hardware; si potrebbero ottenere miglioramenti modificando le sue impostazioni, adattandole dettagliatamente ad ogni macchina su cui è installato." + +#. Type: note +#. Description +#: ../mplayer.templates:1001 +msgid "You should read the documentation provided by the 'mplayer-doc' package." +msgstr "Leggere la documentazione fornita dal pacchetto 'mplayer-doc'." + +#. Type: note +#. Description +#: ../mplayer.templates:1001 +msgid "" +"Now, some configuration options will be set for the entire system in /etc/" +"mplayer/mplayer.conf which may be adapted later. Any user can also refine " +"options in ~/.mplayer/config." +msgstr "Ora saranno salvate nel file /etc/mplayer/mplayer.conf alcune impostazioni valide per l'intero sistema; sarà possibile modificarle in seguito. Ogni utente ha la possibilità di adattarle alle proprie necessità in ~/.mplayer/config." + +#. Type: boolean +#. Description +#: ../mplayer.templates:2001 +msgid "Replace existing configuration file?" +msgstr "Sovrascrivere i file di configurazione esistenti?" + +#. Type: boolean +#. Description +#: ../mplayer.templates:2001 +msgid "" +"An /etc/mplayer/mplayer.conf file already exists on the system and does not " +"contain an automatically-generated part. That file can be replaced by a " +"generated one (the old file will be moved to /etc/mplayer/mplayer.conf." +"debconf-old)." +msgstr "Il file /etc/mplayer/mplayer.conf è già presente nel sistema e contiene parti che non sono state generate automaticamente. É possibile sostituire questo file con uno creato automaticamente (il vecchio file sarà rinominato in /etc/mplayer/mplayer.conf.debconf-old)." + +#. Type: note +#. Description +#: ../mplayer.templates:3001 +msgid "Old configuration file kept" +msgstr "Il file obsoleto è stato mantenuto" + +#. Type: note +#. Description +#: ../mplayer.templates:3001 +msgid "You chose not to replace the existing /etc/mplayer/mplayer.conf file." +msgstr "Si è scelto di non sostituire il file /etc/mplayer/mplayer.conf esistente." + +#. Type: note +#. Description +#: ../mplayer.templates:3001 +msgid "" +"That file can be generated automatically later by running 'dpkg-reconfigure " +"mplayer'." +msgstr "Questo file potrà essere creato automaticamente in seguito eseguendo 'dpkg-reconfigure mplayer'." + +#. Type: select +#. Description +#: ../mplayer.templates:4001 +msgid "MPlayer video output:" +msgstr "Uscita video di MPlayer:" + +#. Type: select +#. Description +#: ../mplayer.templates:4001 +msgid "" +"MPlayer can use a very wide range of video output drivers. The needed driver " +"may be detected automatically or chosen manually." +msgstr "MPlayer dispone di una raccolta estremamente ampia di driver per l'uscita video. Il driver di cui si necessita può essere determinato automaticamente od impostato manualmente." + +#. Type: select +#. Description +#: ../mplayer.templates:4001 +msgid "" +"If you prefer choosing the driver yourself, you first should choose an entry " +"matching this system's video card. If none match and the card supports 'XV', " +"choose that option (the 'xvinfo' command may help)." +msgstr "Se si preferisce la scelta manuale, si dovrebbe selezionare una voce corrisponente alla scheda video di questo computer. Se nessuna corrisponde e la scheda supporta 'XV' si dovrebbe scegliere questa opzione (Il comando 'xvinfo' potrebbe fornire informazioni)." + +#. Type: select +#. Description +#: ../mplayer.templates:4001 +msgid "" +"Please read the /usr/share/doc/mplayer-doc/HTML/en/video.html file from the " +"'mplayer-doc' package for more details." +msgstr "Leggere il file /usr/share/doc/mplayer-doc/HTML/it/video.html, contenuto nel pacchetto 'mplayer-doc', per maggiori dettagli." + +#. Type: note +#. Description +#: ../mplayer.templates:5001 +msgid "Binary codecs download" +msgstr "Download di codec binari" + +#. Type: note +#. Description +#: ../mplayer.templates:5001 +msgid "MPlayer supports most video formats without additional software." +msgstr "MPlayer supporta molti formati video senza la necessità di software addizionale." + +#. Type: note +#. Description +#: ../mplayer.templates:5001 +msgid "" +"Additional video formats, such as Real 3.0/4.0, Windows Media 9, or " +"Quicktime, can be supported by using binary codecs." +msgstr "Formati video aggiuntivi, come Real 3.0/4.0, Windows Media 9, o Quicktime, possono essere visualizzati utilizzando codec binari." + +#. Type: note +#. Description +#: ../mplayer.templates:5001 +msgid "" +"As such codecs are not free software, they are not distributed with this " +"package but can be downloaded freely. The '/usr/share/mplayer/scripts/" +"binary_codecs.sh' script is provided in this package to help downloading " +"them from the MPlayer web site." +msgstr "" +"Questi codec non sono software libero quindi questo pacchetto non li contiene, ma si possono scaricare liberamente. Questo pacchetto fornisce lo script '/usr/share/mplayer/scripts/" +"binary_codecs.sh' che permette di scaricarli dal sito di MPlayer." + +#. Type: string +#. Description +#: ../mplayer.templates:6001 +msgid "DVD device name:" +msgstr "Nome del device DVD:" + +#. Type: string +#. Description +#: ../mplayer.templates:6001 +msgid "Please enter the name of the device for your DVD player, if any." +msgstr "Inserire il nome del device associato al lettore DVD (se presente)." + +#. Type: select +#. Description +#: ../mplayer.templates:7001 +msgid "Font for On Screen Display:" +msgstr "Font per il display sovraimpresso (On Screen Display):" + +#. Type: error +#. Description +#: ../mplayer.templates:8001 +msgid "No TrueType fonts found for On Screen Display" +msgstr "Assenti font TrueType da utilizzare per l'On Screen Display" + +#. Type: error +#. Description +#: ../mplayer.templates:8001 +msgid "MPlayer needs at least one TrueType font for its 'On Screen Display' feature." +msgstr "MPlayer necessita di almeno un font TrueType per attivare la funzionalità 'On Screen Display'." + +#. Type: error +#. Description +#: ../mplayer.templates:8001 +msgid "" +"You should install a package providing such fonts (such as 'ttf-freefont' or " +"'ttf-bitstream-vera' or 'msttcorefonts') and reconfigure MPlayer (by running " +"'dpkg-reconfigure mplayer')." +msgstr "Installare un pacchetto che provvede questi font (come 'ttf-freefont' o 'ttf-bitstream-vera' o 'msttcorefonts') e riconfigurate MPlayer (eseguendo 'dpkg-reconfigure mplayer')." + diff --git a/debian/po/ja.po b/debian/po/ja.po new file mode 100644 index 0000000..483f26c --- /dev/null +++ b/debian/po/ja.po @@ -0,0 +1,324 @@ +# Japanese debconf templates translation for mplayer. +# Copyright (C) 2007 Noritada Kobayashi +# This file is distributed under the same license as the mplayer package. +# +msgid "" +msgstr "" +"Project-Id-Version: mplayer (debconf) 1.0~rc1-12\n" +"Report-Msgid-Bugs-To: mennucc1@debian.org\n" +"POT-Creation-Date: 2007-10-18 10:01+0200\n" +"PO-Revision-Date: 2007-03-02 22:19+0900\n" +"Last-Translator: Noritada Kobayashi \n" +"Language-Team: Japanese \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "Detailed configuration needed for each user" +msgstr "" + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "" +"The performance of MPlayer depends heavily on hardware; this means that it " +"may benefit from tweaking options for every single machine it's installed on." +msgstr "" + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "" +"You should read the documentation provided by the 'mplayer-doc' package." +msgstr "" + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "" +"Now, some configuration options will be set for the entire system in /etc/" +"mplayer/mplayer.conf which may be adapted later. Any user can also refine " +"options in ~/.mplayer/config." +msgstr "" + +#. Type: boolean +#. Description +#: ../mplayer.templates:3001 +msgid "Replace existing configuration file?" +msgstr "既存の設定ファイルを置き換えますか?" + +#. Type: boolean +#. Description +#: ../mplayer.templates:3001 +#, fuzzy +#| msgid "" +#| "There is already a file /etc/mplayer/mplayer.conf, but it does not " +#| "contain an automatically generated part. This script may generate a new " +#| "file (the old file will be moved to /etc/mplayer/mplayer.conf.debconf-" +#| "old)." +msgid "" +"An /etc/mplayer/mplayer.conf file already exists on the system and does not " +"contain an automatically-generated part. That file can be replaced by a " +"generated one (the old file will be moved to /etc/mplayer/mplayer.conf." +"debconf-old)." +msgstr "" +"ファイル /etc/mplayer/mplayer.conf が既に存在しますが、このファイルには自動生" +"成された部分が含まれていません。本スクリプトの実行により新しいファイルが生成" +"される可能性があります (古いファイルは /etc/mplayer/mplayer.conf.debconf-old " +"に移動します)。" + +#. Type: note +#. Description +#: ../mplayer.templates:4001 +#, fuzzy +#| msgid "Replace existing configuration file?" +msgid "Old configuration file kept" +msgstr "既存の設定ファイルを置き換えますか?" + +#. Type: note +#. Description +#: ../mplayer.templates:4001 +msgid "You chose not to replace the existing /etc/mplayer/mplayer.conf file." +msgstr "" + +#. Type: note +#. Description +#: ../mplayer.templates:4001 +msgid "" +"That file can be generated automatically later by running 'dpkg-reconfigure " +"mplayer'." +msgstr "" + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "MPlayer video output:" +msgstr "MPlayer ビデオ出力:" + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "" +"MPlayer can use a very wide range of video output drivers. The needed driver " +"may be detected automatically or chosen manually." +msgstr "" + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "" +"If you prefer choosing the driver yourself, you first should choose an entry " +"matching this system's video card. If none match and the card supports 'XV', " +"choose that option (the 'xvinfo' command may help)." +msgstr "" + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "" +"Please read the /usr/share/doc/mplayer-doc/HTML/en/video.html file from the " +"'mplayer-doc' package for more details." +msgstr "" + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "Binary codecs download" +msgstr "" + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "MPlayer supports most video formats without additional software." +msgstr "" + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "" +"Additional video formats, such as Real 3.0/4.0, Windows Media 9, or " +"Quicktime, can be supported by using binary codecs." +msgstr "" + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "" +"As such codecs are not free software, they are not distributed with this " +"package but can be downloaded freely. The '/usr/share/mplayer/scripts/" +"binary_codecs.sh' script is provided in this package to help downloading " +"them from the MPlayer web site." +msgstr "" + +#. Type: string +#. Description +#: ../mplayer.templates:7001 +msgid "DVD device name:" +msgstr "DVD デバイス名:" + +#. Type: string +#. Description +#: ../mplayer.templates:7001 +msgid "Please enter the name of the device for your DVD player, if any." +msgstr "" + +#. Type: select +#. Description +#: ../mplayer.templates:8001 +msgid "Font for On Screen Display:" +msgstr "" + +# FIXME: TrueType should be TrueType. +#. Type: error +#. Description +#: ../mplayer.templates:9001 +#, fuzzy +#| msgid "" +#| " MPlayer needs True Type fonts for On Screen Display. Choose your " +#| "favorite." +msgid "No TrueType fonts found for On Screen Display" +msgstr "" +"MPlayer ではオンスクリーンディスプレイ (OSD) に TrueType フォントが必要となり" +"ます。好みのものを選択してください。" + +# FIXME: TrueType should be TrueType. +#. Type: error +#. Description +#: ../mplayer.templates:9001 +#, fuzzy +#| msgid "" +#| " MPlayer needs True Type fonts for On Screen Display. Choose your " +#| "favorite." +msgid "" +"MPlayer needs at least one TrueType font for its 'On Screen Display' feature." +msgstr "" +"MPlayer ではオンスクリーンディスプレイ (OSD) に TrueType フォントが必要となり" +"ます。好みのものを選択してください。" + +# FIXME: "truetype" should be "TrueType". +# FIXME: Remove white spaces after "such as" and "'ttf-bitstream-vera' or". +#. Type: error +#. Description +#: ../mplayer.templates:9001 +#, fuzzy +#| msgid "" +#| "You should install a package providing truetype fonts (such as 'ttf-" +#| "freefont' or 'ttf-bitstream-vera' or 'msttcorefonts' ) and reconfigure " +#| "MPlayer (with the command \"dpkg-reconfigure mplayer\")" +msgid "" +"You should install a package providing such fonts (such as 'ttf-freefont' or " +"'ttf-bitstream-vera' or 'msttcorefonts') and reconfigure MPlayer (by running " +"'dpkg-reconfigure mplayer')." +msgstr "" +"TrueType フォントを提供しているパッケージ ('ttf-freefont' や 'ttf-bitstream-" +"vera'、'msttcorefonts' など) をインストールし、その上で、(コマンド \"dpkg-" +"reconfigure mplayer\" で) MPlayer を再設定してください。" + +#~ msgid "Create your ~/.mplayer/config file" +#~ msgstr "~/.mplayer/config ファイルを作成してください" + +#~ msgid "" +#~ "Performance of MPlayer depends heavily on hardware - this means that it " +#~ "may benefit from tweaking options, for every single machine it's " +#~ "installed to. You may wish to read the documentation (it is in the " +#~ "package 'mplayer-doc', under /usr/share/doc/mplayer-doc/). This DebConf " +#~ "interface will help you setup just a few main features; you may wish to " +#~ "add to /etc/mplayer/mplayer.conf some more refined options (to enable " +#~ "multichannel audio, or video postprocessing, etc etc); and any user " +#~ "similarly may customize MPlayer using the file ~/.mplayer/config" +#~ msgstr "" +#~ "MPlayer の実行性能はハードウェアに強く依存します。つまり、インストールされ" +#~ "ている各マシンでオプションを微調整すると MPlayer がより好ましい動作をする" +#~ "可能性があります。そのために付属文書を読む必要があるかもしれません (付属文" +#~ "書は 'mplayer-doc' パッケージの /usr/share/doc/mplayer-doc/ 以下にありま" +#~ "す)。この DebConf インタフェースは、いくつかの主要な機能の設定を手助けする" +#~ "だけです。(マルチチャンネルオーディオや映像の後処理などを有効にするため" +#~ "に) いくつかのさらに細かいオプションを /etc/mplayer/mplayer.conf に追加す" +#~ "る必要があるかもしれません。また、同様にどのユーザもファイル ~/.mplayer/" +#~ "config を使用して MPlayer をカスタマイズできます。" + +#~ msgid "Enable access to RTC?" +#~ msgstr "RTC へのアクセスを可能にしますか?" + +#~ msgid "" +#~ "On older kernels MPlayer can use the RTC (Real Time Clock) to provide " +#~ "better timing in reproduction, with less CPU cost; to this end, though, " +#~ "the device /dev/rtc must be accessible to group audio, and the default " +#~ "max-user-freq must be raised to 1024. Any needed change must be done by " +#~ "root. If you wish, MPlayer will automatically do this at boot, so that " +#~ "any user can enjoy this feature. Note that there may be security issues " +#~ "with this (although none are known now)." +#~ msgstr "" +#~ "古いカーネル上で動かす場合、MPlayer は、再生時に RTC (リアルタイムクロッ" +#~ "ク) を使用し、より少ない CPU 消費でよりよい同期をすることが可能です。しか" +#~ "しそのためには、デバイス /dev/rtc を audio グループからアクセス可能にし、" +#~ "max-user-freq のデフォルト値を 1024 に上げなければなりません。必要な変更は" +#~ "すべて root で行わなければなりません。お望みなら、起動時に MPlayer が自動" +#~ "的にこれらの変更を行うようにして、すべてのユーザがこの機能を楽しめるように" +#~ "できます。このオプションを有効にすると、(今のところは知られていませんが) " +#~ "セキュリティ上の問題点ができるかもしれないことに注意してください。" + +#~ msgid "Files not replaced" +#~ msgstr "ファイルは置き換えられませんでした" + +#~ msgid "" +#~ "It seems that you don't want to replace your existing configuration file /" +#~ "etc/mplayer/mplayer.conf. If you change your mind later, you can run " +#~ "\"dpkg-reconfigure mplayer\"." +#~ msgstr "" +#~ "既存の設定ファイル /etc/mplayer/mplayer.conf を置き換えることを望まないよ" +#~ "うですね。後で気が変わった場合は \"dpkg-reconfigure mplayer\" を実行してく" +#~ "ださい。" + +# TRANSLATION-FIXME: Use "ja" instead of "en", if available +#~ msgid "" +#~ "MPlayer can use a very wide range of video output drivers; it will try to " +#~ "autodetect the best one, but you may choose a preferred one. Here is a " +#~ "guide to the choice (in decreasing order of speed): (1) if you see an " +#~ "entry that matches your video card, choose that; (2) if your video card " +#~ "supports 'XV', choose that (use 'xvinfo' to know). You should read /usr/" +#~ "share/doc/mplayer-doc/HTML/en/video.html (it is in package 'mplayer-doc')." +#~ msgstr "" +#~ "MPlayer は非常に多様なビデオ出力ドライバを使用できます。MPlayer は最良のド" +#~ "ライバを自動検出しようとしますが、使用したいものを自分で選択することも可能" +#~ "です。ここに選択の指針を示します (スピードの速い順です)。(1) ビデオカード" +#~ "にマッチするエントリがある場合、それを選択してください。(2) ビデオカード" +#~ "が 'XV' をサポートしている場合、それを選択してください ('xvinfo' を使用す" +#~ "るとわかるでしょう)。/usr/share/doc/mplayer-doc/HTML/en/video.html も参照" +#~ "してください (このファイルは 'mplayer-doc' パッケージに含まれています)。" + +#~ msgid "How to download binary codecs" +#~ msgstr "バイナリコーデックのダウンロード方法" + +# FIXME: Remove white spaces after "Real 3.0" and "those". +# FIXME: "QuickTime audio" should be "QuickTime Audio". +# FIXME: Capitalize "internet". +#~ msgid "" +#~ "MPlayer supports most codecs out of the box and the rest with the help of " +#~ "binary codecs. Binary codecs are only necessary for Real 3.0 and 4.0, " +#~ "Windows Media 9, QuickTime audio and some very obscure codecs. Debian " +#~ "cannot distribute these codecs, but these are available on the internet " +#~ "for download. Run the script `/usr/share/mplayer/scripts/binary_codecs." +#~ "sh' to install those made available from MPlayer web site." +#~ msgstr "" +#~ "MPlayer は、大半のコーデックについては最初からサポートしており、残りのコー" +#~ "デックについてもバイナリコーデックの助けを借りてサポートしています。バイナ" +#~ "リコーデックは、Real 3.0 と 4.0、Windows Media 9、QuickTime Audio やいくつ" +#~ "かの非常に無名のコーデックについてのみ必要となります。これらのコーデック" +#~ "は Debian では配布できませんが、インターネットからダウンロードして利用でき" +#~ "ます。スクリプト `/usr/share/mplayer/scripts/binary_codecs.sh' を実行し、" +#~ "MPlayer のウェブサイトから入手可能になっているこれらのコーデックをインス" +#~ "トールしてください。" + +#~ msgid "What is the name of your DVD device (if any):" +#~ msgstr "(DVD デバイスがある場合は) デバイスの名前を入力してください:" + +#~ msgid "MPlayer OSD font:" +#~ msgstr "MPlayer OSD フォント:" + +# FIXME: Decapitalize "Fonts". +#~ msgid "MPlayer cannot find TrueType Fonts" +#~ msgstr "Mplayer は TrueType フォントを見つけることができません" diff --git a/debian/po/ml.po b/debian/po/ml.po new file mode 100644 index 0000000..91ca7a3 --- /dev/null +++ b/debian/po/ml.po @@ -0,0 +1,208 @@ +# translation of mplayer_1.0~rc1-17_ml.po to malayalam +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# +# Santhosh Thottingal , 2007. +# Reviewed by Praveen|പ്രവീണ്‍ A|എ , 2007. +msgid "" +msgstr "" +"Project-Id-Version: mplayer_1.0~rc1-13_ml\n" +"Report-Msgid-Bugs-To: mennucc1@debian.org\n" +"POT-Creation-Date: 2007-10-18 10:01+0200\n" +"PO-Revision-Date: 2007-04-08 15:21-0400\n" +"Last-Translator: Santhosh Thottingal \n" +"Language-Team: Swathanthra|സ്വതന്ത്ര Malayalam|മലയാളം Computing|കമ്പ്യൂട്ടിങ്ങ് \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: KBabel 1.11.4\n" + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "Detailed configuration needed for each user" +msgstr "ഓരോ ഉപയോക്താവിനും വിശദമായ സജ്ജീകരണം ആവശ്യമാണ്." + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "" +"The performance of MPlayer depends heavily on hardware; this means that it " +"may benefit from tweaking options for every single machine it's installed on." +msgstr "" +"എംപ്ലയറിന്റെ പ്രകടനം പ്രധാനമായും ഹാര്‍ഡ്‌വെയറിനെ ആശ്രയിച്ചിരിക്കുന്നു. ഇതിനര്‍ത്ഥം അത് " +"ഇന്‍സ്റ്റാള്‍ ചെയ്യുന്ന ഓരൊ മെഷീനിലേയും ഹാര്‍ഡ്‌വെയര്‍ പരുവപ്പെടുത്തലുകളെ നന്നായി ഉപയോഗിക്കും എന്നാണ്." + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "" +"You should read the documentation provided by the 'mplayer-doc' package." +msgstr "" +"ഇതിന്റെ വിവരണങ്ങള്‍ 'mplayer-doc' എന്ന പാക്കേജില്‍ നിന്ന് നിങ്ങള്‍ക്ക് വായിക്കാവുന്നതാണ്." + + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "" +"Now, some configuration options will be set for the entire system in /etc/" +"mplayer/mplayer.conf which may be adapted later. Any user can also refine " +"options in ~/.mplayer/config." +msgstr "മുഴുവന്‍ സിസ്റ്റത്തിന്റേയും സജ്ജീകരണം /etc/mplayer/mplayer.conf എന്ന ഫയലിലാണുള്ളത്." +"ഉപയോക്താക്കള്‍ക്ക് ~/.mplayer/config എന്ന ഫയല്‍ ഉപയോഗിച്ച് ഇത് ഭേദപ്പെടുത്താവുന്നതാണ്." + + +#. Type: boolean +#. Description +#: ../mplayer.templates:3001 +msgid "Replace existing configuration file?" +msgstr "ഇപ്പോഴുള്ള സജ്ജീകരണ ഫയല്‍ മാറ്റിയെഴുതട്ടെ?" + +#. Type: boolean +#. Description +#: ../mplayer.templates:3001 +msgid "" +"An /etc/mplayer/mplayer.conf file already exists on the system and does not " +"contain an automatically-generated part. That file can be replaced by a " +"generated one (the old file will be moved to /etc/mplayer/mplayer.conf." +"debconf-old)." +msgstr "" +"/etc/mplayer/mplayer.conf എന്ന ഫയല്‍ ഇപ്പോള്‍തന്നെ ഉണ്ട്. പക്ഷെ, അതില്‍ ഓട്ടോമാറ്റിക്‌ ആയി " +"ഉണ്ടായ ഭാഗങ്ങള്‍ ഇല്ല. ഈ സ്ക്രിപ്റ്റ് ഒരു പുതിയ ഫയല്‍ ഉണ്ടാക്കും(പഴയ ഫയല്‍ /etc/mplayer/" +"mplayer.conf.debconf-old എന്ന പേരിലേക്ക് മാറ്റപ്പെടും)." + +#. Type: note +#. Description +#: ../mplayer.templates:4001 +msgid "Old configuration file kept" +msgstr "പഴയ സജ്ജീകരണ ഫയല്‍ അങ്ങനെത്തന്നെ വെച്ചു" + +#. Type: note +#. Description +#: ../mplayer.templates:4001 +msgid "You chose not to replace the existing /etc/mplayer/mplayer.conf file." +msgstr "നിലവിലുള്ള /etc/mplayer/mplayer.conf ഫയല്‍ മാറ്റിയെഴുതേണ്ടെന്ന് തീരുമാനിച്ചു." + +#. Type: note +#. Description +#: ../mplayer.templates:4001 +msgid "" +"That file can be generated automatically later by running 'dpkg-reconfigure " +"mplayer'." +msgstr "ആ ഫയല്‍ പിന്നീട് 'dpkg-reconfigure mplayer' എന്ന ആജ്ഞ ഉപയോഗിച്ച് " +"ഉണ്ടാക്കാവുന്നതാണ്." + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "MPlayer video output:" +msgstr "എംപ്ലയര്‍ ദൃശ്യ ഔട്ട്പുട്ട്:" + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "" +"MPlayer can use a very wide range of video output drivers. The needed driver " +"may be detected automatically or chosen manually." +msgstr "" +"എംപ്ലയറിന്‌ വീഡിയോ ഔട്ട്പുട്ട് പ്രവര്‍ത്തകങ്ങളുടെ ഒരു വലിയ നിരതന്നെ ഉപയോഗിക്കാന്‍ കഴിയും. ആവശ്യമുള്ള ഡ്രൈവര്‍ സ്വയം കണ്ടുപിടിക്കുകയോ നിങ്ങള്‍ക്ക് സജ്ജീകരിക്കുകയോ ചെയ്യാം" + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "" +"If you prefer choosing the driver yourself, you first should choose an entry " +"matching this system's video card. If none match and the card supports 'XV', " +"choose that option (the 'xvinfo' command may help)." +msgstr "ഡ്രൈവര്‍ നിങ്ങള്‍ സ്വയം തിരഞ്ഞെടുക്കുകയാണെങ്കില്‍, നിങ്ങളുടെ വീഡിയോ കാര്‍ഡിനനുയോജ്യമായ ഒന്ന് തിരഞ്ഞെടുക്കണം. ഒന്നും യോജ്യമല്ലാതെ വരികയും നിങ്ങളുടെ കാര്‍ഡ് 'XV' പിന്തുണക്കുകയും ചെയ്യുന്നുണ്ടെങ്കില്‍ അത് തിരഞ്ഞെടുക്കുക(xvinfo എന്ന ആജ്ഞ സഹായിച്ചേക്കാം)." + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "" +"Please read the /usr/share/doc/mplayer-doc/HTML/en/video.html file from the " +"'mplayer-doc' package for more details." +msgstr "" +"കൂടുതല്‍ വിവരങ്ങള്‍ക്ക് 'mplayer-doc' എന്ന പാക്കേജിലെ /usr/share/doc/mplayer-doc/HTML/en/video.html എന്ന ഫയല്‍ വായിക്കുക." + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "Binary codecs download" +msgstr "ബൈനറി കൊഡെക്കുകളുടെ ഡൗണ്‍‌ലോഡ്" + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "MPlayer supports most video formats without additional software." +msgstr "എംപ്ലയറിന്, പ്രത്യേകിച്ച് സോഫ്റ്റുവെയറുകള്‍ ഇല്ലെങ്കിലും മിക്ക വീഡിയോ ഫോര്‍മാറ്റുകളും പിന്തുണക്കാന്‍ കഴിയും." + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "" +"Additional video formats, such as Real 3.0/4.0, Windows Media 9, or " +"Quicktime, can be supported by using binary codecs." +msgstr "" +"റിയല്‍ 3.0/4.0, വിന്‍ഡോസ് മീഡിയ 9, ക്വിക്ക് ടൈം, എന്നിവ ബൈനറി കോഡെക്കുകള്‍" +"ഉപയോഗിച്ച് പിന്തുണയ്ക്കാവുന്നതാണ്." + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "" +"As such codecs are not free software, they are not distributed with this " +"package but can be downloaded freely. The '/usr/share/mplayer/scripts/" +"binary_codecs.sh' script is provided in this package to help downloading " +"them from the MPlayer web site." +msgstr "അവ സ്വതന്ത്ര സോഫ്റ്റ്‌വെയറുകളല്ലാത്തതിനാല്‍, ഈ പാക്കേജിനൊപ്പം വിതരണം ചെയ്തിട്ടില്ല." +"പക്ഷേ, സൗജന്യമായി അവ ഡൗണ്‍‌ലോഡ് ചെയ്യാവുന്നതാണ്. ഈ പാക്കേജിനോടൊപ്പം ഉള്ള" +"'/usr/share/mplayer/scripts/binary_codecs.sh' എന്ന സ്ക്രിപ്റ്റ് എംപ്ലേയറിന്റെ വെബ്സൈറ്റില്‍ നിന്ന് അവ" +"ഡൗണ്‍‌ലോഡ് ചെയ്യാന്‍ സഹായിക്കും" + +#. Type: string +#. Description +#: ../mplayer.templates:7001 +msgid "DVD device name:" +msgstr "ഡി.വി.ഡി ഉപകരണനാമം:" + +#. Type: string +#. Description +#: ../mplayer.templates:7001 +msgid "Please enter the name of the device for your DVD player, if any." +msgstr "നിങ്ങളുടെ ഡി.വി.ഡി ഉപകരണത്തിന്റെ പേരെന്താണ് (ഉണ്ടെങ്കില്‍ മാത്രം):" + +#. Type: select +#. Description +#: ../mplayer.templates:8001 +msgid "Font for On Screen Display:" +msgstr "സ്ക്രീനിലെ പ്രദര്‍ശനത്തിനായുള്ള അക്ഷരരൂപം:" + +#. Type: error +#. Description +#: ../mplayer.templates:9001 +msgid "No TrueType fonts found for On Screen Display" +msgstr "ട്രൂടൈപ്പ് അക്ഷരരൂപങ്ങള്‍ ഒന്നും കണ്ടുപിടിയ്ക്കാന്‍ കഴിഞ്ഞില്ല." + +#. Type: error +#. Description +#: ../mplayer.templates:9001 +msgid "" +"MPlayer needs at least one TrueType font for its 'On Screen Display' feature." +msgstr "" +"എംപ്ലയറിന്‌ സ്ക്രീനിലെ പ്രദര്‍ശനത്തിന്‌ ട്രൂടൈപ്പ് അക്ഷരരൂപങ്ങള്‍ ആവശ്യമാണ്‌. നിങ്ങളുടെ പ്രിയപ്പെട്ടവ " +"തിരഞ്ഞെടുക്കുക." + +#. Type: error +#. Description +#: ../mplayer.templates:9001 +msgid "" +"You should install a package providing such fonts (such as 'ttf-freefont' or " +"'ttf-bitstream-vera' or 'msttcorefonts') and reconfigure MPlayer (by running " +"'dpkg-reconfigure mplayer')." +msgstr "" +"ട്രൂടൈപ്പ് അക്ഷരരൂപങ്ങള്‍ ('ttf-dejavu' , 'ttf-bitstream-vera' , 'msttcorefonts' " +"എന്നിവ പോലത്തെ ) ഉള്ള ഒരു പാക്കേജ് നിങ്ങള്‍ ഇന്‍സ്റ്റാള്‍ ചെയ്തതിനു ശേഷം എംപ്ലയര്‍ " +"പുനഃക്രമീകരിയ്ക്കുക (\"dpkg-reconfigure mplayer\"എന്ന ആജ്ഞ ഉപയോഗിച്ച്)" + diff --git a/debian/po/nl.po b/debian/po/nl.po new file mode 100644 index 0000000..3cf4044 --- /dev/null +++ b/debian/po/nl.po @@ -0,0 +1,326 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: mplayer\n" +"Report-Msgid-Bugs-To: mennucc1@debian.org\n" +"POT-Creation-Date: 2007-10-18 10:01+0200\n" +"PO-Revision-Date: 2007-10-19 18:33+0100\n" +"Last-Translator: Bart Cornelis \n" +"Language-Team: debian-l10n-dutch \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Poedit-Language: Dutch\n" + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "Detailed configuration needed for each user" +msgstr "Gedetailleerde configuratie nodig voor elke gebruiker" + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "" +"The performance of MPlayer depends heavily on hardware; this means that it " +"may benefit from tweaking options for every single machine it's installed on." +msgstr "" +"De performantie van MPlayer hangt sterk af van de hardware; het bijstellen " +"van de opties voor de specifieke machine waarop geïnstalleerd wordt kan " +"hierdoor flink voordeel opleveren." + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "" +"You should read the documentation provided by the 'mplayer-doc' package." +msgstr "" +"U kunt best de documentatie voorzien in het pakket 'mplayer-doc' nalezen." + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "" +"Now, some configuration options will be set for the entire system in /etc/" +"mplayer/mplayer.conf which may be adapted later. Any user can also refine " +"options in ~/.mplayer/config." +msgstr "" +"Nu worden sommige configuratie-opties systeemwijd ingesteld in /etc/mplayer/" +"mplayer.conf, deze kunnen later aangepast worden. Gebruikers kunnen opties " +"ook verfijnen via ~/.mplayer/config ." + +#. Type: boolean +#. Description +#: ../mplayer.templates:3001 +msgid "Replace existing configuration file?" +msgstr "Wilt u het bestaand configuratiebestand vervangen?" + +#. Type: boolean +#. Description +#: ../mplayer.templates:3001 +msgid "" +"An /etc/mplayer/mplayer.conf file already exists on the system and does not " +"contain an automatically-generated part. That file can be replaced by a " +"generated one (the old file will be moved to /etc/mplayer/mplayer.conf." +"debconf-old)." +msgstr "" +"Er bestaat reeds een bestand '/etc/mplayer/mplayer.conf' op dit systeem, " +"helaas bevat dit geen automatisch gegenereerd deel. Het bestaande bestand " +"kan vervangen worden door een automatisch gegenereerd bestand (het oude " +"bestand wordt dan verplaatst naar '/etc/mplayer/mplayer.conf.debconf-old). " + +#. Type: note +#. Description +#: ../mplayer.templates:4001 +msgid "Old configuration file kept" +msgstr "Het oude configuratiebestand wordt behouden" + +#. Type: note +#. Description +#: ../mplayer.templates:4001 +msgid "You chose not to replace the existing /etc/mplayer/mplayer.conf file." +msgstr "" +"U heeft ervoor gekozen om het bestaande /etc/mplayer/mplayer.conf bestand " +"niet te vervangen." + +#. Type: note +#. Description +#: ../mplayer.templates:4001 +msgid "" +"That file can be generated automatically later by running 'dpkg-reconfigure " +"mplayer'." +msgstr "" +"U kunt dit bestand later automatisch laten genereren via het commando 'dpkg-" +"reconfigure mplayer'." + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "MPlayer video output:" +msgstr "MPlayer-video-uitvoer:" + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "" +"MPlayer can use a very wide range of video output drivers. The needed driver " +"may be detected automatically or chosen manually." +msgstr "" +"MPlayer kan een groot aantal video-uitvoer-stuurprogramma's gebruiken. Het " +"benodigde stuurprogramma kan automatisch gedetecteerd of handmatig ingesteld " +"worden." + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "" +"If you prefer choosing the driver yourself, you first should choose an entry " +"matching this system's video card. If none match and the card supports 'XV', " +"choose that option (the 'xvinfo' command may help)." +msgstr "" +"Als u verkiest om het stuurprogramma zelf in te stellen dient u eerst een " +"ingang die overeenkomt met de beeldkaart van dit systeem te kiezen. Als u " +"geen overeenkomstige ingang vindt en de kaart 'XV' ondersteund, dient u die " +"optie te kiezen (het commando 'xvinfo' kan uitsluitsel over geven)." + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "" +"Please read the /usr/share/doc/mplayer-doc/HTML/en/video.html file from the " +"'mplayer-doc' package for more details." +msgstr "" +"Meer informatie vindt u in het bestand /usr/share/doc/mplayer-doc/HTML/en/" +"video.html uit het pakket 'mplayer-doc'." + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "Binary codecs download" +msgstr "Ophalen binaire codecs" + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "MPlayer supports most video formats without additional software." +msgstr "" +"MPlayer ondersteund de meeste videoformaten zonder aanvullende software." + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "" +"Additional video formats, such as Real 3.0/4.0, Windows Media 9, or " +"Quicktime, can be supported by using binary codecs." +msgstr "" +"Andere videoformaten zoals Real 3.0/4.0, Windows Media 9, en Quicktime " +"kunnen enkel ondersteund worden via binaire codecs." + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "" +"As such codecs are not free software, they are not distributed with this " +"package but can be downloaded freely. The '/usr/share/mplayer/scripts/" +"binary_codecs.sh' script is provided in this package to help downloading " +"them from the MPlayer web site." +msgstr "" +"Aangezien deze codecs geen vrije software zijn worden ze niet met dit pakket " +"meegeleverd. Ze kunnen wel vrij gedownload worden van de MPlayer website, " +"hiertoe voorziet dit pakket het script '/usr/share/mplayer/scripts/" +"binary_codecs.sh'." + +#. Type: string +#. Description +#: ../mplayer.templates:7001 +msgid "DVD device name:" +msgstr "DVD-apparaatnaam:" + +#. Type: string +#. Description +#: ../mplayer.templates:7001 +msgid "Please enter the name of the device for your DVD player, if any." +msgstr "Wat is de naam van het DVD-afspeelapparaat? (als dit aanwezig is)" + +#. Type: select +#. Description +#: ../mplayer.templates:8001 +msgid "Font for On Screen Display:" +msgstr "Font voor 'Op het scherm weergave':" + +#. Type: error +#. Description +#: ../mplayer.templates:9001 +msgid "No TrueType fonts found for On Screen Display" +msgstr "Er zijn geen 'TrueType'-lettertypes voor 'Op het scherm weergave'." + +#. Type: error +#. Description +#: ../mplayer.templates:9001 +msgid "" +"MPlayer needs at least one TrueType font for its 'On Screen Display' feature." +msgstr "" +"MPlayer heeft minstens één 'TrueType'-lettertype nodig voor de 'Op het " +"scherm weergave'." + +#. Type: error +#. Description +#: ../mplayer.templates:9001 +msgid "" +"You should install a package providing such fonts (such as 'ttf-freefont' or " +"'ttf-bitstream-vera' or 'msttcorefonts') and reconfigure MPlayer (by running " +"'dpkg-reconfigure mplayer')." +msgstr "" +"U kunt best een pakket met 'TrueType'-lettertypes installeren (bv. 'ttf-" +"freefont' of 'ttf-bitstream-vera' of 'msttcorefonts') en daarna MPlayer " +"herconfigureren (via het commando 'dpkg-reconfigure mplayer')." + +#~ msgid "Create your ~/.mplayer/config file" +#~ msgstr "Uw '~/.mplayer/config' bestand aanmaken" + +#~ msgid "" +#~ "Performance of MPlayer depends heavily on hardware - this means that it " +#~ "may benefit from tweaking options, for every single machine it's " +#~ "installed to. You may wish to read the documentation (it is in the " +#~ "package 'mplayer-doc', under /usr/share/doc/mplayer-doc/). This DebConf " +#~ "interface will help you setup just a few main features; you may wish to " +#~ "add to /etc/mplayer/mplayer.conf some more refined options (to enable " +#~ "multichannel audio, or video postprocessing, etc etc); and any user " +#~ "similarly may customize MPlayer using the file ~/.mplayer/config" +#~ msgstr "" +#~ "Performantie van MPlayer is sterk afhankelijk van de hardware. Dit " +#~ "betekend ook dat er groot voordeel te halen is van het specifiek " +#~ "aanpassen van de opties voor elke machine waarop u dit pakket " +#~ "installeert. U kunt best de docemtatie nalezen (deze vindt u na " +#~ "installatie van het 'mplayer-doc'-pakket in de map /usr/share/doc/mplayer-" +#~ "doc). Deze debconf-interface helpt u alleen met het instellen van enkele " +#~ "van de meest belangrijke features; het is dus denkelijk dat u de opties " +#~ "in /etc/mplayer/mplayer.conf verder wilt verfijnen (om bijvoorbeel " +#~ "multikanaal audio, of video postprocessing, of ... te activeren). Elke " +#~ "gebruiker kan MPlayer verder aanpassen via het bestand ~/.mplayer/config ." + +#~ msgid "Enable access to RTC?" +#~ msgstr "Toegang tot de RTC (Real Time Clock) activeren?" + +#~ msgid "" +#~ "On older kernels MPlayer can use the RTC (Real Time Clock) to provide " +#~ "better timing in reproduction, with less CPU cost; to this end, though, " +#~ "the device /dev/rtc must be accessible to group audio, and the default " +#~ "max-user-freq must be raised to 1024. Any needed change must be done by " +#~ "root. If you wish, MPlayer will automatically do this at boot, so that " +#~ "any user can enjoy this feature. Note that there may be security issues " +#~ "with this (although none are known now)." +#~ msgstr "" +#~ "Voor oudere kernels kan MPlayer de RTC (Real Time Clock) gebruiken voor " +#~ "bettere getimede reproductie, aan minder grote CPU-kost. Opdat dit " +#~ "mogelijk zou zijn dient het apparaat /dev/rtc toegankelijk te zijn voor " +#~ "de 'audio'-groep, en dient de max-user-freq opgehoogt te worden naar " +#~ "1024. Deze benodigde aanpassingen dienen door root uitgevoerd te worden. " +#~ "Als u dit wenst kan MPlayer dit automatisch tijdens het opstarten doen. " +#~ "Opgelet! Dit kan beveiliginsproblemen opleveren (hoewel er momenteel geen " +#~ "beveiligins problemen bekend zijn)." + +#~ msgid "Files not replaced" +#~ msgstr "Bestanden zijn niet vervangen" + +#~ msgid "" +#~ "It seems that you don't want to replace your existing configuration file /" +#~ "etc/mplayer/mplayer.conf. If you change your mind later, you can run " +#~ "\"dpkg-reconfigure mplayer\"." +#~ msgstr "" +#~ "U geeft aan dat u het bestaande configuratiebestand niet wilt vervangen. " +#~ "Als u later van gedacht vervanderd kunt u dit alsnog laten doen via het " +#~ "commando 'dpkg-reconfigure mplayer'." + +#~ msgid "" +#~ "MPlayer can use a very wide range of video output drivers; it will try to " +#~ "autodetect the best one, but you may choose a preferred one. Here is a " +#~ "guide to the choice (in decreasing order of speed): (1) if you see an " +#~ "entry that matches your video card, choose that; (2) if your video card " +#~ "supports 'XV', choose that (use 'xvinfo' to know). You should read /usr/" +#~ "share/doc/mplayer-doc/HTML/en/video.html (it is in package 'mplayer-doc')." +#~ msgstr "" +#~ "MPlayer kan een erg veel verschillende video-uitvoerstuurprogramma's " +#~ "gebruiken; het probeert om het beste beschikbare stuurprogramma te " +#~ "gebruiken, maar u kunt het door u verkozen altijd kiezen. Hou voor deze " +#~ "keuze het volgende in gedachten:\n" +#~ "(1) Als u een ingang ziet die overeenkomt met uw beeldkaart, dan kiest u " +#~ "deze normaal ook.\n" +#~ "(2) Als uw beeldkaart 'XV' ondersteund, kiest u best die optie (u kunt " +#~ "dit nagaan met het commando 'xvinfo').\n" +#~ "Meer informatie vindt u in het bestand '/usr/share/doc/mplayer-doc/HTML/" +#~ "en/video.html (hiervoor dient u het pakket 'mplayer-doc' geïnstalleerd te " +#~ "hebben." + +#~ msgid "How to download binary codecs" +#~ msgstr "Hoe binaire codecs te downloaden:" + +#~ msgid "" +#~ "MPlayer supports most codecs out of the box and the rest with the help of " +#~ "binary codecs. Binary codecs are only necessary for Real 3.0 and 4.0, " +#~ "Windows Media 9, QuickTime audio and some very obscure codecs. Debian " +#~ "cannot distribute these codecs, but these are available on the internet " +#~ "for download. Run the script `/usr/share/mplayer/scripts/binary_codecs." +#~ "sh' to install those made available from MPlayer web site." +#~ msgstr "" +#~ "MPlayer ondersteund de meeste codecs meteen na installatie, voor " +#~ "ondersteuning van andere codecs zijn binaire codecs nodig. Binaire codecs " +#~ "zijn normaal enkel nodig voor Real 3.0, Real 4.0, Windows Media 9, " +#~ "Quicktime audio, en sommige heel obscure codecs. Debian kan deze codecs " +#~ "om legale redenen niet aanbieden, maar daar deze codecs wel beschikbaar " +#~ "zijn op het internet bevat dit pakket het script '/usr/share/mplayer/" +#~ "scripts/binary_codecs.sh'. Dit script haalt de codecs voor u op van " +#~ "internet en zet ze op de juiste plek neer." + +#~ msgid "What is the name of your DVD device (if any):" +#~ msgstr "Wat is de naam van uw DVD-apparaat (indien aanwezig):" + +#~ msgid "MPlayer OSD font:" +#~ msgstr "Lettertype voor MPlayer 'Op het scherm'-weergave:" + +#~ msgid "MPlayer cannot find TrueType Fonts" +#~ msgstr "MPlayer kan geen 'TrueType'-lettertype vinden" diff --git a/debian/po/pt.po b/debian/po/pt.po new file mode 100644 index 0000000..f392583 --- /dev/null +++ b/debian/po/pt.po @@ -0,0 +1,215 @@ +# Portuguese translation of mplayer's debconf messages. +# Copyright (C) 2007 Carlos Lisboa +# This file is distributed under the same license as the mplayer package. +# Carlos Lisboa , 2007. +# +msgid "" +msgstr "" +"Project-Id-Version: mplayer\n" +"Report-Msgid-Bugs-To: mennucc1@debian.org\n" +"POT-Creation-Date: 2007-10-18 10:01+0200\n" +"PO-Revision-Date: 2007-10-23 21:08+0100\n" +"Last-Translator: Carlos Lisboa \n" +"Language-Team: Portuguese \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "Detailed configuration needed for each user" +msgstr "Configuração detalhada necessária para cada utilizador" + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "" +"The performance of MPlayer depends heavily on hardware; this means that it " +"may benefit from tweaking options for every single machine it's installed on." +msgstr "" +"O desempenho do MPlayer depende muito do hardware; isto significa que poderá " +"beneficiar de opções afinadas para cada máquina onde esteja instalado. " + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "" +"You should read the documentation provided by the 'mplayer-doc' package." +msgstr "Deverá ler a documentação disponibilizada pelo pacote 'mplayer-doc'." + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "" +"Now, some configuration options will be set for the entire system in /etc/" +"mplayer/mplayer.conf which may be adapted later. Any user can also refine " +"options in ~/.mplayer/config." +msgstr "" +"Agora, algumas opções de configuração serão activadas para todo o sistema " +"em /etc/mplayer/mplayer.conf que poderão ser adaptadas mais tarde. Qualquer " +"utilizador pode refinar as opções em ~/.mplayer/config." + +#. Type: boolean +#. Description +#: ../mplayer.templates:3001 +msgid "Replace existing configuration file?" +msgstr "Substituir o ficheiro de configuração existente?" + +#. Type: boolean +#. Description +#: ../mplayer.templates:3001 +msgid "" +"An /etc/mplayer/mplayer.conf file already exists on the system and does not " +"contain an automatically-generated part. That file can be replaced by a " +"generated one (the old file will be moved to /etc/mplayer/mplayer.conf." +"debconf-old)." +msgstr "" +"Já existe o ficheiro /etc/mplayer/mplayer.conf no sistema e não contém uma " +"secção gerada automaticamente. Esse ficheiro pode ser substituído por um " +"gerado (o ficheiro antigo será movido para /etc/mplayer/mplayer.conf.debconf-" +"old)." + +#. Type: note +#. Description +#: ../mplayer.templates:4001 +msgid "Old configuration file kept" +msgstr "Ficheiro de configuração antigo mantido" + +#. Type: note +#. Description +#: ../mplayer.templates:4001 +msgid "You chose not to replace the existing /etc/mplayer/mplayer.conf file." +msgstr "" +"Escolheu não substituir o ficheiro existente /etc/mplayer/mplayer.conf." + +#. Type: note +#. Description +#: ../mplayer.templates:4001 +msgid "" +"That file can be generated automatically later by running 'dpkg-reconfigure " +"mplayer'." +msgstr "" +"O ficheiro pode ser gerado automaticamente mais tarde correndo 'dpkg-" +"reconfigure mplayer'." + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "MPlayer video output:" +msgstr "Saída de vídeo do Mplayer:" + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "" +"MPlayer can use a very wide range of video output drivers. The needed driver " +"may be detected automatically or chosen manually." +msgstr "" +"O MPlayer pode usar uma variedade enorme de controladores de saída de vídeo. " +"O controlador necessário pode ser detectado automaticamente ou escolhido " +"manualmente." + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "" +"If you prefer choosing the driver yourself, you first should choose an entry " +"matching this system's video card. If none match and the card supports 'XV', " +"choose that option (the 'xvinfo' command may help)." +msgstr "" +"Se preferir escolher o controlador, deverá primeiro escolher a entrada que " +"coincida com a placa gráfica deste sistema. Se nenhum coincidir e a placa " +"suportar 'XV', escolha esta opção (o comando 'xvinfo' pode ajudar)." + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "" +"Please read the /usr/share/doc/mplayer-doc/HTML/en/video.html file from the " +"'mplayer-doc' package for more details." +msgstr "" +"Por favor leia o ficheiro /usr/share/doc/mplayer-doc/HTML/en/video.html do " +"pacote 'mplayer-doc' para mais detalhes." + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "Binary codecs download" +msgstr "Download de codecs binários" + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "MPlayer supports most video formats without additional software." +msgstr "" +"MPlayer suporta grande parte de formatos vídeo sem software adicional. " + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "" +"Additional video formats, such as Real 3.0/4.0, Windows Media 9, or " +"Quicktime, can be supported by using binary codecs." +msgstr "" +"Formatos de vídeo adicionais, como o Real 3.0/4.0, Windows Media 9, ou " +"Quicktime, pode ser suportados usando codecs binários." + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "" +"As such codecs are not free software, they are not distributed with this " +"package but can be downloaded freely. The '/usr/share/mplayer/scripts/" +"binary_codecs.sh' script is provided in this package to help downloading " +"them from the MPlayer web site." +msgstr "" +"Como tais codecs não são software livre, não são distribuidos com este " +"pacote mas podem ser descarregados gratuitamente. O script '/usr/share/" +"mplayer/scripts/binary_codecs.sh' é disponibilizado por este pacote para " +"ajudar a descarregá-los do site do MPlayer." + +#. Type: string +#. Description +#: ../mplayer.templates:7001 +msgid "DVD device name:" +msgstr "Nome do dispositivo de DVD:" + +#. Type: string +#. Description +#: ../mplayer.templates:7001 +msgid "Please enter the name of the device for your DVD player, if any." +msgstr "Introduza o nome do dispositivo do leitor DVD, se existir." + +#. Type: select +#. Description +#: ../mplayer.templates:8001 +msgid "Font for On Screen Display:" +msgstr "Fonte para 'On Screen Display':" + +#. Type: error +#. Description +#: ../mplayer.templates:9001 +msgid "No TrueType fonts found for On Screen Display" +msgstr "Nenhumas fontes TrueType encontradas para 'On Screen Display'" + +#. Type: error +#. Description +#: ../mplayer.templates:9001 +msgid "" +"MPlayer needs at least one TrueType font for its 'On Screen Display' feature." +msgstr "" +"O Mplayer necessita de pelo menos uma Fonte TrueType para o 'On Screen " +"Display'." + +#. Type: error +#. Description +#: ../mplayer.templates:9001 +msgid "" +"You should install a package providing such fonts (such as 'ttf-freefont' or " +"'ttf-bitstream-vera' or 'msttcorefonts') and reconfigure MPlayer (by running " +"'dpkg-reconfigure mplayer')." +msgstr "" +"Deverá instalar o pacote que disponibiliza as fontes (tal como a 'ttf-" +"freefont' ou 'ttf-bitstream-vera' ou 'msttcorefonts' ) e reconfigurar o " +"Mplayer (com o comando 'dpkg-reconfigure mplayer')." diff --git a/debian/po/ro.po b/debian/po/ro.po new file mode 100644 index 0000000..76de5a7 --- /dev/null +++ b/debian/po/ro.po @@ -0,0 +1,325 @@ +# translation of ro.po to Romanian +# Romanian translations for PACKAGE package +# Traducerea în limba română pentru pachetul PACKAGE. +# Copyright (C) 2007 THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# +# Eddy Petrisor , 2007. +# Eddy Petrișor , 2007. +msgid "" +msgstr "" +"Project-Id-Version: ro\n" +"Report-Msgid-Bugs-To: mennucc1@debian.org\n" +"POT-Creation-Date: 2007-10-18 10:01+0200\n" +"PO-Revision-Date: 2007-10-24 23:13+0300\n" +"Last-Translator: Eddy Petrișor \n" +"Language-Team: Romanian \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=3; plural=n==1 ? 0 : (n==0 || (n%100 > 0 && n%100 < " +"20)) ? 1 : 2;\n" +"X-Generator: KBabel 1.11.4\n" + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "Detailed configuration needed for each user" +msgstr "Este necesară o configurare detaliată pentru fiecare utilizator" + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "" +"The performance of MPlayer depends heavily on hardware; this means that it " +"may benefit from tweaking options for every single machine it's installed on." +msgstr "" +"Performanța lui MPlayer depinde foarte mult de componentele calculatorului; " +"acest lucru înseamnă că ar putea beneficia de pe urma ajustărilor opțiunilor " +"pentru fiecare sistem pe care este instalat." + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "" +"You should read the documentation provided by the 'mplayer-doc' package." +msgstr "Ar trebui să citiți documentația furnizată în pachetul „mplayer-doc”." + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "" +"Now, some configuration options will be set for the entire system in /etc/" +"mplayer/mplayer.conf which may be adapted later. Any user can also refine " +"options in ~/.mplayer/config." +msgstr "" +"Pentru moment câteva opțiuni de configurare vor fi definite pentru tot " +"sistemul în /etc/mplayer/mplayer.conf, acestea putând fi adaptate mai " +"târziu. Orice utilizator poate rafina opțiunile în ~/.mplayer/config." + +#. Type: boolean +#. Description +#: ../mplayer.templates:3001 +msgid "Replace existing configuration file?" +msgstr "Se înlocuiesc fișierele de configurare existente?" + +#. Type: boolean +#. Description +#: ../mplayer.templates:3001 +msgid "" +"An /etc/mplayer/mplayer.conf file already exists on the system and does not " +"contain an automatically-generated part. That file can be replaced by a " +"generated one (the old file will be moved to /etc/mplayer/mplayer.conf." +"debconf-old)." +msgstr "" +"Există deja un fișier /etc/mplayer/mplayer.conf care nu conține o parte " +"generată automat. Acel fișier poate fi înlocuit de un fișier generat (cel " +"vechi va fi redenumit ca /etc/mplayer/mplayer.conf.debconf-old)." + +#. Type: note +#. Description +#: ../mplayer.templates:4001 +msgid "Old configuration file kept" +msgstr "Fișierul de configurare vechi este păstrat" + +#. Type: note +#. Description +#: ../mplayer.templates:4001 +msgid "You chose not to replace the existing /etc/mplayer/mplayer.conf file." +msgstr "Ați ales să nu înlocuiți fișierul existent /etc/mplayer/mplayer.conf." + +#. Type: note +#. Description +#: ../mplayer.templates:4001 +msgid "" +"That file can be generated automatically later by running 'dpkg-reconfigure " +"mplayer'." +msgstr "" +"Acel fișier poate fi generat automat la un moment ulterior prin rularea " +"comenzii „dpkg-reconfigure mplayer”." + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "MPlayer video output:" +msgstr "Ieșire video a lui MPlayer:" + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "" +"MPlayer can use a very wide range of video output drivers. The needed driver " +"may be detected automatically or chosen manually." +msgstr "" +"MPlayer este capabil să folosească o gamă variată de driver-e video. Driver-" +"ul necesar poate fi detectat automat sau poate fi ales manual." + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "" +"If you prefer choosing the driver yourself, you first should choose an entry " +"matching this system's video card. If none match and the card supports 'XV', " +"choose that option (the 'xvinfo' command may help)." +msgstr "" +"Dacă preferați să alegeți personal driver-ul, va trebui ca mai întâi să " +"alegeți o intrare care se potrivește cu placa video a acestui sistem. Dacă " +"nu se potrivește nici una și placa video suportă „XV”, alegeți acea opțiune " +"(comanda „xvinfo” ar putea fi de ajutor)." + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "" +"Please read the /usr/share/doc/mplayer-doc/HTML/en/video.html file from the " +"'mplayer-doc' package for more details." +msgstr "" +"Pentru mai multe detalii, citiți fișierul /usr/share/doc/mplayer-doc/HTML/en/" +"video.html din pachetul „mplayer-doc”." + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "Binary codecs download" +msgstr "Descărcare de codec-uri binare" + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "MPlayer supports most video formats without additional software." +msgstr "MPlayer suportă majoritatea formatelor video fără software adițional." + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "" +"Additional video formats, such as Real 3.0/4.0, Windows Media 9, or " +"Quicktime, can be supported by using binary codecs." +msgstr "" +"Formate video adițioanle precum Real 3.0/4.0, Windows Media 9, sau Quicktime " +"pot fi suportate prin intermediul codec-urilor binare." + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "" +"As such codecs are not free software, they are not distributed with this " +"package but can be downloaded freely. The '/usr/share/mplayer/scripts/" +"binary_codecs.sh' script is provided in this package to help downloading " +"them from the MPlayer web site." +msgstr "" +"Deoarece asemenea codec-uri nu sunt software liber, nu sunt distribuite cu " +"acest pachet însă pot fi descărcate. Script-ul „/usr/share/mplayer/scripts/" +"binary_codecs.sh” este furnizat pentru a fi de ajutor la descărcarea lor de " +"pe pagina de internet a lui MPlayer." + +#. Type: string +#. Description +#: ../mplayer.templates:7001 +msgid "DVD device name:" +msgstr "Numele dispozitivului DVD" + +#. Type: string +#. Description +#: ../mplayer.templates:7001 +msgid "Please enter the name of the device for your DVD player, if any." +msgstr "" +"Introduceți numele dispozitivului pentru player-ul DVD al dumneavoastră, " +"dacă aveți unul." + +#. Type: select +#. Description +#: ../mplayer.templates:8001 +msgid "Font for On Screen Display:" +msgstr "Fontul pentru afișarea pe ecran:" + +# nu cred că treducerea lui OSD e mare problemă +#. Type: error +#. Description +#: ../mplayer.templates:9001 +msgid "No TrueType fonts found for On Screen Display" +msgstr "N-a fost găsit nici un font „True Type” pentru afișarea pe ecran" + +# nu cred că treducerea lui OSD e mare problemă +#. Type: error +#. Description +#: ../mplayer.templates:9001 +msgid "" +"MPlayer needs at least one TrueType font for its 'On Screen Display' feature." +msgstr "" +"MPlayer are nevoie decel puțin un font „True Type” pentru afișarea pe ecran." + +# am preferat ttf-dejavu pentru că e potrivit pentru limba română +#. Type: error +#. Description +#: ../mplayer.templates:9001 +msgid "" +"You should install a package providing such fonts (such as 'ttf-freefont' or " +"'ttf-bitstream-vera' or 'msttcorefonts') and reconfigure MPlayer (by running " +"'dpkg-reconfigure mplayer')." +msgstr "" +"Ar trebui să instalați un pachet care furnizează fonturi truetype (cum ar fi " +"„ttf-dejavu”, „ttf-freefont” sau „msttcorefonts”) și să reconfigurați " +"MPlayer-ul (cu comanda „dpkg-reconfigure mplayer”)." + +#~ msgid "" +#~ "Performance of MPlayer depends heavily on hardware - this means that it " +#~ "may benefit from tweaking options, for every single machine it's " +#~ "installed to. You may wish to read the documentation (it is in the " +#~ "package 'mplayer-doc', under /usr/share/doc/mplayer-doc/). This DebConf " +#~ "interface will help you setup just a few main features; you may wish to " +#~ "add to /etc/mplayer/mplayer.conf some more refined options (to enable " +#~ "multichannel audio, or video postprocessing, etc etc); and any user " +#~ "similarly may customize MPlayer using the file ~/.mplayer/config" +#~ msgstr "" +#~ "Performanța lui MPlayer depinde foarte mult de componentele " +#~ "calculatorului - acest lucru înseamnă că poate beneficia din reglarea " +#~ "fină a opțiunilor, dependent de mașina pe care este instalat. Dacă doriți " +#~ "să citiți documentația (este în pachetul „mplayer-doc” în directorul /usr/" +#~ "share/doc/mplayer-doc/). Acestă interfață DebConf vă va ajuta să ajustați " +#~ "doar câteva facilități; probail veți dori să adăugați la /etc/mplayer/" +#~ "mplayer.conf câteva rafinamente ale opțiunilor (activarea ieșirea multi-" +#~ "canal a sunetului sau post-procesarea video, etc.); oricare utilizator " +#~ "poate particulariza în mod similar MPlayer-ul folosind fișierul ~/." +#~ "mplayer/config" + +#~ msgid "Enable access to RTC?" +#~ msgstr "Se activează accesul la RTC?" + +#~ msgid "" +#~ "On older kernels MPlayer can use the RTC (Real Time Clock) to provide " +#~ "better timing in reproduction, with less CPU cost; to this end, though, " +#~ "the device /dev/rtc must be accessible to group audio, and the default " +#~ "max-user-freq must be raised to 1024. Any needed change must be done by " +#~ "root. If you wish, MPlayer will automatically do this at boot, so that " +#~ "any user can enjoy this feature. Note that there may be security issues " +#~ "with this (although none are known now)." +#~ msgstr "" +#~ "Pe nuclee mai vechi, MPlayer pote folosi Ceasul de timp real (abrev. eng. " +#~ "RTC) pentru o mai bună sincronizare la redare, cu costuri reduse la nivel " +#~ "de procesor; pentru aceasta, însă, dispozitivul /dev/rtc trebuie să fie " +#~ "accesibil pentru grupul audio, iar valoarea implicită max-user-freq " +#~ "trebuie să fie ridicată la 1024. Schimbările necesare trebuiesc făcute de " +#~ "utilizatorul root. Dacă doriți, MPlayer va face acest lucru automat la " +#~ "pornire pentru ca orice utilizator să se poată bucura de această " +#~ "facilitate. A se reține că ar putea exista probleme de securitate legate " +#~ "de aceasta (deși acum nu se cunoaște nici una)." + +#~ msgid "Files not replaced" +#~ msgstr "Fișiere neînlocuite" + +#~ msgid "" +#~ "It seems that you don't want to replace your existing configuration file /" +#~ "etc/mplayer/mplayer.conf. If you change your mind later, you can run " +#~ "\"dpkg-reconfigure mplayer\"." +#~ msgstr "" +#~ "Se pare că nu doriți să înlocuiți fișierul /etc/mplayer/mplayer.conf deja " +#~ "existent. Dacă vă răzgândiți ulterior, puteți rula „dpkg-reconfigure " +#~ "mplayer”." + +#~ msgid "" +#~ "MPlayer can use a very wide range of video output drivers; it will try to " +#~ "autodetect the best one, but you may choose a preferred one. Here is the " +#~ "a guide to the choice (in decreasing order of speed): (1) if you see an " +#~ "entry that matches your video card, choose that; (2) if your video card " +#~ "supports 'XV', choose that (use 'xvinfo' to know). You should read /usr/" +#~ "share/doc/mplayer-doc/HTML/en/devices.html (it is in package 'mplayer-" +#~ "doc')." +#~ msgstr "" +#~ "MPlayer poste folosi o gamă largă de module de ieșire video; va încerca " +#~ "să-l detecteze automat pe cel mai bun, dar puteți să alegeți unul pe care-" +#~ "l preferați. Iată un mic ghid care vă poate ajuta să alegeți (în ordinea " +#~ "descrescătoare a vitezei): (1) dacă vedeti vreo intrare care poartă " +#~ "numele plăcii video, alegeți-o pe aceea; (2) dacă placa video suportă " +#~ "'XV', alegeți acea opțiune (folosiți „xvinfo” pentru a afla). Ar trebui " +#~ "să citiți /usr/share/doc/mplayer-doc/HTML/en/devices.html (din pachetul " +#~ "„mplayer-doc”)." + +#~ msgid "How to download binary codecs" +#~ msgstr "Cum se descarcă codec-urile binare" + +#~ msgid "" +#~ "MPlayer supports most codecs out of the box and the rest with the help of " +#~ "binary codecs. Binary codecs are only necessary for Real 3.0 and 4.0, " +#~ "Windows Media 9, QuickTime audio and some very obscure codecs. Debian " +#~ "cannot distribute these codecs, but these are available on the internet " +#~ "for download. Run the script `/usr/share/mplayer/scripts/binary_codecs." +#~ "sh' to install those made available from MPlayer web site." +#~ msgstr "" +#~ "MPlayer suportă cele mai multe codec-uri în mod implicit iar pe restul " +#~ "prin intermediul codec-urilor binare. Codec-urile binare sunt necesare " +#~ "doar pentru Real 3.0 și 4,0, Windows Media 9, QuickTime audio și unele " +#~ "codec-uri foarte obscure. Debian nu poate distribui aceste codec-uri, " +#~ "însă acestea sunt disponibile pe internet și pot fi descărcate. Rulați " +#~ "script-ul „/usr/share/mplayer/scripts/binary_codecs.sh” pentru a le " +#~ "instala pe acelea care sunt disponibile pe situl MPlayer." + +#~ msgid "What is the name of your DVD device (if any):" +#~ msgstr "Care este numele dispozitivului DVD (dacă e cazul):" + +# nu cred că treducerea lui OSD e mare problemă +#~ msgid "MPlayer OSD font:" +#~ msgstr "Fontul folosit de MPlayer pentru afișarea pe ecran:" + +#~ msgid "MPlayer cannot find TrueType Fonts" +#~ msgstr "Mplayer nu poate găsi fonturi „TrueType”" diff --git a/debian/po/ru.po b/debian/po/ru.po new file mode 100644 index 0000000..8ce5364 --- /dev/null +++ b/debian/po/ru.po @@ -0,0 +1,221 @@ +# translation of ru-new.po to Russian +# Translation of mplayer debconf templates to Russian +# Copyright (C) Sergey V. Mironov , 2007. +# This file is distributed under the same license as the mplayer package. +# +# Sergey V. Mironov , 2007. +# Yuri Kozlov , 2007. +msgid "" +msgstr "" +"Project-Id-Version: mplayer_1.0rc1-17_ru\n" +"Report-Msgid-Bugs-To: mennucc1@debian.org\n" +"POT-Creation-Date: 2007-10-28 09:36+0100\n" +"PO-Revision-Date: 2007-10-25 20:56+0400\n" +"Last-Translator: Yuri Kozlov \n" +"Language-Team: Russian \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: KBabel 1.11.4\n" +"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%" +"10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "Detailed configuration needed for each user" +msgstr "Более точная настройка" + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "" +"The performance of MPlayer depends heavily on hardware; this means that it " +"may benefit from tweaking options for every single machine it's installed on." +msgstr "" +"Производительность MPlayer'а сильно зависит от оборудования. Это означает, " +"что можно получить бОльшую производительность, настроив параметры под " +"конкретную систему, на котором он установлен." + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "" +"You should read the documentation provided by the 'mplayer-doc' package." +msgstr "" +"Вам следует ознакомиться с документацией поставляемой пакетом 'mplayer-doc'." + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "" +"Now, some configuration options will be set for the entire system in /etc/" +"mplayer/mplayer.conf which may be adapted later. Any user can also refine " +"options in ~/.mplayer/config." +msgstr "" +"Сейчас будут установлены общесистемные настройки в файл /etc/mplayer/mplayer." +"conf, которые позже можно изменить. Также любой пользователь может изменять " +"эти параметры, редактируя свой файл ~/.mplayer/config." + +#. Type: boolean +#. Description +#: ../mplayer.templates:3001 +msgid "Replace existing configuration file?" +msgstr "Заменить существующий файл конфигурации?" + +#. Type: boolean +#. Description +#: ../mplayer.templates:3001 +msgid "" +"An /etc/mplayer/mplayer.conf file already exists on the system and does not " +"contain an automatically-generated part. That file can be replaced by a " +"generated one (the old file will be moved to /etc/mplayer/mplayer.conf." +"debconf-old)." +msgstr "" +"Файл /etc/mplayer/mplayer.conf уже существует, но не содержит автоматически " +"сгенерированной части. Этот файл может быть заменён сгенерированным " +"(существующий файл будет переименован в /etc/mplayer/mplayer.conf.debconf-" +"old)." + +#. Type: note +#. Description +#: ../mplayer.templates:4001 +msgid "Old configuration file kept" +msgstr "Будет использоваться существующий файл конфигурации" + +#. Type: note +#. Description +#: ../mplayer.templates:4001 +msgid "You chose not to replace the existing /etc/mplayer/mplayer.conf file." +msgstr "Вы выбрали не заменять существующий файл /etc/mplayer/mplayer.conf." + +#. Type: note +#. Description +#: ../mplayer.templates:4001 +msgid "" +"That file can be generated automatically later by running 'dpkg-reconfigure " +"mplayer'." +msgstr "" +"Позже этот файл может быть сгенерирован автоматически выполнением 'dpkg-" +"reconfigure mplayer'." + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "MPlayer video output:" +msgstr "Видео вывод MPlayer:" + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "" +"MPlayer can use a very wide range of video output drivers. The needed driver " +"may be detected automatically or chosen manually." +msgstr "" +"MPlayer может использовать очень широкий диапазон драйверов видео вывода. " +"Необходимый драйвер может быть определён автоматически или указан вручную." + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "" +"If you prefer choosing the driver yourself, you first should choose an entry " +"matching this system's video card. If none match and the card supports 'XV', " +"choose that option (the 'xvinfo' command may help)." +msgstr "" +"Если вы предпочитаете сами выбирать драйвер, то для начала укажите видео " +"карту, соответствующую этой системе. Если её в списке нет и видео карта " +"поддерживает 'XV', выберите этот пункт (команда 'xvinfo' может оказаться " +"полезной)." + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "" +"Please read the /usr/share/doc/mplayer-doc/HTML/en/video.html file from the " +"'mplayer-doc' package for more details." +msgstr "" +"Подробности ищите в файле /usr/share/doc/mplayer-doc/HTML/en/video.html из " +"пакета 'mplayer-doc'." + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "Binary codecs download" +msgstr "Загрузка бинарных кодеков" + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "MPlayer supports most video formats without additional software." +msgstr "" +"MPlayer поддерживает большинство видео форматов без дополнительного " +"программного обеспечения." + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "" +"Additional video formats, such as Real 3.0/4.0, Windows Media 9, or " +"Quicktime, can be supported by using binary codecs." +msgstr "" +"Поддержка дополнительных видео форматов, таких как Real 3.0/4.0, Windows " +"Media 9 или Quicktime, может быть осуществлена посредством использования " +"бинарных кодеков." + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "" +"As such codecs are not free software, they are not distributed with this " +"package but can be downloaded freely. The '/usr/share/mplayer/scripts/" +"binary_codecs.sh' script is provided in this package to help downloading " +"them from the MPlayer web site." +msgstr "" +"Так как бинарные кодеки не являются свободным программным обеспечением, они " +"не входят в этот пакет, но могут быть свободно загружены. Для загрузки " +"бинарных кодеков с веб-сайта MPlayer в пакет добавлен скрипт '/usr/share/" +"mplayer/scripts/binary_codecs.sh'" + +#. Type: string +#. Description +#: ../mplayer.templates:7001 +msgid "DVD device name:" +msgstr "Имя DVD-устройства:" + +#. Type: string +#. Description +#: ../mplayer.templates:7001 +msgid "Please enter the name of the device for your DVD player, if any." +msgstr "Пожалуйста, введите имя устройства вашего DVD-плеера, если есть." + +#. Type: select +#. Description +#: ../mplayer.templates:8001 +msgid "Font for On Screen Display:" +msgstr "Шрифт для OSD (отображение текста на экране):" + +#. Type: error +#. Description +#: ../mplayer.templates:9001 +msgid "No TrueType fonts found for On Screen Display" +msgstr "Не найдены TrueType-шрифты для OSD (отображения текста на экране)" + +#. Type: error +#. Description +#: ../mplayer.templates:9001 +msgid "" +"MPlayer needs at least one TrueType font for its 'On Screen Display' feature." +msgstr "Для отображения текста на экране MPlayer требуются шрифты TrueType." + +#. Type: error +#. Description +#: ../mplayer.templates:9001 +msgid "" +"You should install a package providing such fonts (such as 'ttf-freefont' or " +"'ttf-bitstream-vera' or 'msttcorefonts') and reconfigure MPlayer (by running " +"'dpkg-reconfigure mplayer')." +msgstr "" +"Вам нужно установить пакет со шрифтами TrueType (например, 'ttf-freefont', " +"'ttf-bitstream-vera' или 'msttcorefonts') и переконфигурировать MPlayer " +"(выполнив 'dpkg-reconfigure mplayer')." diff --git a/debian/po/sk.po b/debian/po/sk.po new file mode 100644 index 0000000..ea2d4c2 --- /dev/null +++ b/debian/po/sk.po @@ -0,0 +1,241 @@ +# Ivan Masár , 2007. +# +msgid "" +msgstr "" +"Project-Id-Version: mplayer 1.0~rc1-15\n" +"Report-Msgid-Bugs-To: mennucc1@debian.org\n" +"POT-Creation-Date: 2007-10-28 09:36+0100\n" +"PO-Revision-Date: 2007-12-01 17:43+0100\n" +"Last-Translator: Ivan Masár \n" +"Language-Team: Slovak \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "Detailed configuration needed for each user" +msgstr "Podrobná konfigurácia nutná pre každého používateľa" + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "The performance of MPlayer depends heavily on hardware; this means that it may benefit from tweaking options for every single machine it's installed on." +msgstr "Výkon aplikácie MPlayer veľmi závisí na hardvéri; to znamená, že dolaďovanie volieb môže zvýšiť výkon na každom stroji." + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "You should read the documentation provided by the 'mplayer-doc' package." +msgstr "Mali by ste si prečítať dokumentáciu poskytovanú v balíku „mplayer-doc“." + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "Now, some configuration options will be set for the entire system in /etc/mplayer/mplayer.conf which may be adapted later. Any user can also refine options in ~/.mplayer/config." +msgstr "Teraz sa nastavia nietoré konfiguračné voľby pre celý systém v súbore „/etc/mplayer/mplayer.conf“. Neskôr bude možné ich upraviť. Každý používateľ si ich môže prispôsobiť v súbore „~/.mplayer/config“." + +#. Type: boolean +#. Description +#: ../mplayer.templates:3001 +msgid "Replace existing configuration file?" +msgstr "Nahradiť súčasný konfiguračný súbor?" + +#. Type: boolean +#. Description +#: ../mplayer.templates:3001 +msgid "An /etc/mplayer/mplayer.conf file already exists on the system and does not contain an automatically-generated part. That file can be replaced by a generated one (the old file will be moved to /etc/mplayer/mplayer.conf.debconf-old)." +msgstr "Súbor /etc/mplayer/mplayer.conf už existuje, ale neobsahuje automaticky vytvorenú časť. Tento skript môže vytvoriť nový súbor (starý súbor sa presunie do /etc/mplayer/mplayer.conf.debconf-old)." + +#. Type: note +#. Description +#: ../mplayer.templates:4001 +msgid "Old configuration file kept" +msgstr "Starý konfiguračný súbor bol zachovaný" + +#. Type: note +#. Description +#: ../mplayer.templates:4001 +msgid "You chose not to replace the existing /etc/mplayer/mplayer.conf file." +msgstr "Zvolili ste nenahrádzať existujúci súbor „/etc/mplayer/mplayer.conf“." + +#. Type: note +#. Description +#: ../mplayer.templates:4001 +msgid "That file can be generated automatically later by running 'dpkg-reconfigure mplayer'." +msgstr "Tento súbor je možné neskôr automaticky vygenerovať spustením príkazu „dpkg-reconfigure mplayer“." + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "MPlayer video output:" +msgstr "MPlayer výstup videa:" + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "MPlayer can use a very wide range of video output drivers. The needed driver may be detected automatically or chosen manually." +msgstr "MPlayer dokáže využiť široké spektrum výstupných grafických ovládačov. Potrebný ovládač je možné automaticky detekovať alebo zvoliť ručne." + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "If you prefer choosing the driver yourself, you first should choose an entry matching this system's video card. If none match and the card supports 'XV', choose that option (the 'xvinfo' command may help)." +msgstr "Ak uprednostňujete zvoliť si ovládač sami, najprv by ste mali vybrať položku zodpovedajúcu grafickej karte tohto systému. Ak žiadne zo zoznamu nezodpovedajú a karta podporuje „XV“, zvoľte túto voľbu (príkaz „xvinfo“ môže pomôcť)." + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "Please read the /usr/share/doc/mplayer-doc/HTML/en/video.html file from the 'mplayer-doc' package for more details." +msgstr "Prosím, prečítajte si podrobnosti v súbore „/usr/share/doc/mplayer-doc/HTML/en/video.html“ z balíka „mplayer-doc“." + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "Binary codecs download" +msgstr "Stiahnutie binárnych kodekov" + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "MPlayer supports most video formats without additional software." +msgstr "MPlayer podporuje väčšinu videoformátov bez toho aby vyžadoval dodatočný softvér." + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "Additional video formats, such as Real 3.0/4.0, Windows Media 9, or Quicktime, can be supported by using binary codecs." +msgstr "Ďalšie videoformáty ako Real 3.0/4.0, Windows Media 9 a Quicktime sú podporované za použitia binárnych kodekov." + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "As such codecs are not free software, they are not distributed with this package but can be downloaded freely. The '/usr/share/mplayer/scripts/binary_codecs.sh' script is provided in this package to help downloading them from the MPlayer web site." +msgstr "Kodeky ako také nie sú slobodný softvér. Nie sú distribuované spolu s týmto balíkom, ale je možné ich zadarmo stiahnuť. Skript „/usr/share/mplayer/scripts/binary_codecs.sh“ obsiahnutý v tomto balíku slúži na stiahnutie kodekov z webstránky MPlayer." + +#. Type: string +#. Description +#: ../mplayer.templates:7001 +msgid "DVD device name:" +msgstr "Názov DVD zariadenia:" + +#. Type: string +#. Description +#: ../mplayer.templates:7001 +msgid "Please enter the name of the device for your DVD player, if any." +msgstr "Prosím, zadajte názov zariadenia vášho prehrávača DVD, ak nejaký máte." + +#. Type: select +#. Description +#: ../mplayer.templates:8001 +msgid "Font for On Screen Display:" +msgstr "Písmo pre funkciu „On Screen Display“:" + +#. Type: error +#. Description +#: ../mplayer.templates:9001 +msgid "No TrueType fonts found for On Screen Display" +msgstr "Pre funkciu „On Screen Display“ neboli nájdené žiadne True Type písma" + +#. Type: error +#. Description +#: ../mplayer.templates:9001 +msgid "MPlayer needs at least one TrueType font for its 'On Screen Display' feature." +msgstr "MPlayer potrebuje na funkciu „On Screen Display“ aspoň jedno True Type písmo." + +#. Type: error +#. Description +#: ../mplayer.templates:9001 +msgid "You should install a package providing such fonts (such as 'ttf-freefont' or 'ttf-bitstream-vera' or 'msttcorefonts') and reconfigure MPlayer (by running 'dpkg-reconfigure mplayer')." +msgstr "Mali by ste nainštalovať balík poskytujúci takéto písma (ako „ttf-freefont“ alebo „ttf-bitstream-vera“ alebo „msttcorefonts“) a rekonfigurovať MPlayer (príkazom „dpkg-reconfigure mplayer“)" + +#~ msgid "Create your ~/.mplayer/config file" +#~ msgstr "Vytvorte svoj súbor ~/.mplayer/config" +#~ msgid "" +#~ "Performance of MPlayer depends heavily on hardware - this means that it " +#~ "may benefit from tweaking options, for every single machine it's " +#~ "installed to. You may wish to read the documentation (it is in the " +#~ "package 'mplayer-doc', under /usr/share/doc/mplayer-doc/). This DebConf " +#~ "interface will help you setup just a few main features; you may wish to " +#~ "add to /etc/mplayer/mplayer.conf some more refined options (to enable " +#~ "multichannel audio, or video postprocessing, etc etc); and any user " +#~ "similarly may customize MPlayer using the file ~/.mplayer/config" +#~ msgstr "" +#~ "Výkonnosť aplikácie MPlayer závisí prevažne na hardvéri - to znamená, že " +#~ "mu môžu pomôcť ladiace voľby pre každú jednodtlivú stanicu, kde je " +#~ "nainštalovaný. Možno si budete chcieť prečítať dokumentáciu (je v balíku " +#~ "„mplayer-doc“, v adresári /usr/share/doc/mplayer-doc/). Toto rozhranie " +#~ "DebConf pomôže nastaviť iba niekoľko hlavných volieb; možno budete chcieť " +#~ "do /etc/mplayer/mplayer.conf pridať nejaké ďalšie voľby (napr. na " +#~ "zapnutie viackanálovho zvuku, pre postprocesing videa atď atď.); a " +#~ "podobne ktorýkoľvek používateľ si môže prispôsobiť MPlayer pomocou súboru " +#~ "~/.mplayer/config" +#~ msgid "Enable access to RTC?" +#~ msgstr "Zapnúť prístup k RTC?" +#~ msgid "" +#~ "On older kernels MPlayer can use the RTC (Real Time Clock) to provide " +#~ "better timing in reproduction, with less CPU cost; to this end, though, " +#~ "the device /dev/rtc must be accessible to group audio, and the default " +#~ "max-user-freq must be raised to 1024. Any needed change must be done by " +#~ "root. If you wish, MPlayer will automatically do this at boot, so that " +#~ "any user can enjoy this feature. Note that there may be security issues " +#~ "with this (although none are known now)." +#~ msgstr "" +#~ "Na starších jadrách môže MPlayer využiť RTC (hodiny reálneho času) pre " +#~ "lepšie časovanie reprodukcie pri menšej záťaži CPU; aby to však bolo " +#~ "možné, musí byť zariadenie /dev/rtc prístupné skupine audio štandardnú " +#~ "hodnotu max-user-freq treba zvýšiť na 1024. Akúkoľvek potrebnú zmenu musí " +#~ "vykonať root. Ak si želáte, MPlayer to automaticky urobí pri spustení, " +#~ "takže túto schopnopsť môže využívať ktorýkoľvek používateľ. Majte na " +#~ "pamäti, že to môže byť spojené s bezpečnostnými rizikami (hoci žiadne " +#~ "momentálne nie sú známe)." +#~ msgid "Files not replaced" +#~ msgstr "Súbor nebol nahradený" +#~ msgid "" +#~ "It seems that you don't want to replace your existing configuration file /" +#~ "etc/mplayer/mplayer.conf. If you change your mind later, you can run " +#~ "\"dpkg-reconfigure mplayer\"." +#~ msgstr "" +#~ "Zdá sa, že nechcete nahradiť váš súčasný konfiguračný súbor /etc/mplayer/" +#~ "mplayer.conf. Ak si to neskôr rozmyslíte, môžete spustiť „dpkg-" +#~ "reconfigure mplayer“." +#~ msgid "" +#~ "MPlayer can use a very wide range of video output drivers; it will try to " +#~ "autodetect the best one, but you may choose a preferred one. Here is a " +#~ "guide to the choice (in decreasing order of speed): (1) if you see an " +#~ "entry that matches your video card, choose that; (2) if your video card " +#~ "supports 'XV', choose that (use 'xvinfo' to know). You should read /usr/" +#~ "share/doc/mplayer-doc/HTML/en/video.html (it is in package 'mplayer-doc')." +#~ msgstr "" +#~ "MPlayer dokáže používať množstvo ovládačov pre výstup videa; pokúsi sa o " +#~ "automatickú detekciu najlepšieho z nich, ale môžete si zvoliť, ktorý " +#~ "uprednostňujete. Tu je návod, ako by ste mali vyberať (v poradí od 1): " +#~ "(1) ak vidíte nejaký, ktorý zodpovedá vašej grafickej karte, zvoľte ho; " +#~ "(2) ak vaša grafické karta podporuje „XV“, zvoľte ho (na zistenie použite " +#~ "„xvinfo“). Mali by ste si prečítať /usr/share/doc/mplayer-doc/HTML/en/" +#~ "video.html (je v balíku „mplayer-doc“)." +#~ msgid "How to download binary codecs" +#~ msgstr "Ako stiahnuť binárne kodeky" +#~ msgid "" +#~ "MPlayer supports most codecs out of the box and the rest with the help of " +#~ "binary codecs. Binary codecs are only necessary for Real 3.0 and 4.0, " +#~ "Windows Media 9, QuickTime audio and some very obscure codecs. Debian " +#~ "cannot distribute these codecs, but these are available on the internet " +#~ "for download. Run the script `/usr/share/mplayer/scripts/binary_codecs." +#~ "sh' to install those made available from MPlayer web site." +#~ msgstr "" +#~ "MPlayer podporuje v štandardnom zostavení väčšinu kodekov a zvyšok " +#~ "pomocou binárnych kodekov. Binárne kodeky sú potrebné iba pre Real 3.0 a " +#~ "4.0, Windows Media 9, QuickTime audio a niektoré veľmi exotické kodeky. " +#~ "Debian nemôže tieto kodeky distribuovať, ale sú dostupné na stiahnutie na " +#~ "internete. Tie, ktoré sú dostupné z webstránky MPlayer môžete " +#~ "nainštalovať spustením skriptu „/usr/share/mplayer/scripts/binary_codecs." +#~ "sh“." +#~ msgid "What is the name of your DVD device (if any):" +#~ msgstr "Ako sa volá vaše DVD zariadenie (ak nejaké máte):" +#~ msgid "MPlayer OSD font:" +#~ msgstr "MPlayer OSD písmo:" +#~ msgid "MPlayer cannot find TrueType Fonts" +#~ msgstr "MPlayer nenašiel TrueType písma" + diff --git a/debian/po/sv.po b/debian/po/sv.po new file mode 100644 index 0000000..4547687 --- /dev/null +++ b/debian/po/sv.po @@ -0,0 +1,247 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: MPlayer 1.0~rc1-11\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2008-07-08 04:35+0200\n" +"PO-Revision-Date: 2008-07-21 19:10+0100\n" +"Last-Translator: Martin Bagge \n" +"Language-Team: Swedish \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Poedit-Language: Swedish\n" +"X-Poedit-Country: SWEDEN\n" + +#. Type: note +#. Description +#: ../mplayer.templates:1001 +msgid "Detailed configuration needed for each user" +msgstr "Detaljerad konfiguration krävs för alla användare" + +#. Type: note +#. Description +#: ../mplayer.templates:1001 +msgid "The performance of MPlayer depends heavily on hardware; this means that it may benefit from tweaking options for every single machine it's installed on." +msgstr "Hur MPlayer fungerar beror i hög grad på hårdvaran i maskinen och det betyder att man kan vinna mycket på att ändra i inställningar vid varje installation." + +#. Type: note +#. Description +#: ../mplayer.templates:1001 +msgid "You should read the documentation provided by the 'mplayer-doc' package." +msgstr "Du bör läsa dokumentationen i paketet 'mplayer-doc'." + +#. Type: note +#. Description +#: ../mplayer.templates:1001 +msgid "Now, some configuration options will be set for the entire system in /etc/mplayer/mplayer.conf which may be adapted later. Any user can also refine options in ~/.mplayer/config." +msgstr "En del standarduppsättning med inställningar placeras i /etc/mplayer/mplayer.conf, användare kan ha egna inställningar i ~/.mplayer/config." + +#. Type: boolean +#. Description +#: ../mplayer.templates:2001 +msgid "Replace existing configuration file?" +msgstr "Ersätt existerande konfigurationsfil?" + +#. Type: boolean +#. Description +#: ../mplayer.templates:2001 +msgid "An /etc/mplayer/mplayer.conf file already exists on the system and does not contain an automatically-generated part. That file can be replaced by a generated one (the old file will be moved to /etc/mplayer/mplayer.conf.debconf-old)." +msgstr "Det finns redan en fil /etc/mplayer/mplayer.conf, men den innehåller ingen automatiskt genererard del. Detta skript kan generera en ny fil (den gamla filen kommer då flyttas till /etc/mplayer/mplayer.conf.debconf-old)." + +#. Type: note +#. Description +#: ../mplayer.templates:3001 +msgid "Old configuration file kept" +msgstr "Den äldre inställningsfilen sparades." + +#. Type: note +#. Description +#: ../mplayer.templates:3001 +msgid "You chose not to replace the existing /etc/mplayer/mplayer.conf file." +msgstr "Du valde att inte ersätta /etc/mplayer/mplayer.conf." + +#. Type: note +#. Description +#: ../mplayer.templates:3001 +msgid "That file can be generated automatically later by running 'dpkg-reconfigure mplayer'." +msgstr "Filen kan skapas vid ett senare tillfälle genom att köra 'dpkg-reconfigure mplayer'." + +#. Type: select +#. Description +#: ../mplayer.templates:4001 +msgid "MPlayer video output:" +msgstr "MPlayer video ut-system:" + +#. Type: select +#. Description +#: ../mplayer.templates:4001 +msgid "MPlayer can use a very wide range of video output drivers. The needed driver may be detected automatically or chosen manually." +msgstr "MPlayer kan använda en mängd olika drivrutiner för utdata. Drivrutinerna kan upptäckas automatiskt eller anges manuellt." + +#. Type: select +#. Description +#: ../mplayer.templates:4001 +msgid "If you prefer choosing the driver yourself, you first should choose an entry matching this system's video card. If none match and the card supports 'XV', choose that option (the 'xvinfo' command may help)." +msgstr "Om du föredrar att välja drivrutinen manuellt ska du först ange maskinens grafik-/videokort. Om du inte hittar något passande och ditt kort stöder 'XV' så anger du det (se även information från kommandot 'xvinfo')." + +#. Type: select +#. Description +#: ../mplayer.templates:4001 +msgid "Please read the /usr/share/doc/mplayer-doc/HTML/en/video.html file from the 'mplayer-doc' package for more details." +msgstr "Läs även /usr/share/doc/mplayer-doc/HTML/en/video.html från paketet 'mplayer-doc' för mer detaljerade alternativ." + +#. Type: note +#. Description +#: ../mplayer.templates:5001 +msgid "Binary codecs download" +msgstr "Binära kodek/omvandlare har laddats hem." + +#. Type: note +#. Description +#: ../mplayer.templates:5001 +msgid "MPlayer supports most video formats without additional software." +msgstr "MPlayer stödjer de flesta videoformaten utan särskilda tilläggsprogram." + +#. Type: note +#. Description +#: ../mplayer.templates:5001 +msgid "Additional video formats, such as Real 3.0/4.0, Windows Media 9, or Quicktime, can be supported by using binary codecs." +msgstr "Tilläggsprogram kan hämtas för att ge möjlighet att visa ytterligare videoformat som Real 3.0/4.0, Windows Media 9 eller Quicktime." + +#. Type: note +#. Description +#: ../mplayer.templates:5001 +msgid "As such codecs are not free software, they are not distributed with this package but can be downloaded freely. The '/usr/share/mplayer/scripts/binary_codecs.sh' script is provided in this package to help downloading them from the MPlayer web site." +msgstr "Dessa kodek är inte fri programvara och distribueras där med inte med detta paketet men kan laddas hem fritt. Scriptet '/usr/share/mplayer/scripts/binary_codecs.sh' finns tillgängligt för att hämta dessa från MPlayers webbplats." + +#. Type: string +#. Description +#: ../mplayer.templates:6001 +msgid "DVD device name:" +msgstr "DVD-enhetens namn:" + +#. Type: string +#. Description +#: ../mplayer.templates:6001 +msgid "Please enter the name of the device for your DVD player, if any." +msgstr "Ange enhetsnamnet för din DVD-spelare, om du har någon." + +#. Type: select +#. Description +#: ../mplayer.templates:7001 +msgid "Font for On Screen Display:" +msgstr "Teckensnitt för skärminformation:" + +#. Type: error +#. Description +#: ../mplayer.templates:8001 +msgid "No TrueType fonts found for On Screen Display" +msgstr "Hittade inga TrueType teckensnitt för skärminformation." + +#. Type: error +#. Description +#: ../mplayer.templates:8001 +msgid "MPlayer needs at least one TrueType font for its 'On Screen Display' feature." +msgstr "MPlayer behöver åtminstone ett TrueType teckensnitt för funktionen skärminformation." + +#. Type: error +#. Description +#: ../mplayer.templates:8001 +msgid "You should install a package providing such fonts (such as 'ttf-freefont' or 'ttf-bitstream-vera' or 'msttcorefonts') and reconfigure MPlayer (by running 'dpkg-reconfigure mplayer')." +msgstr "Du bör installera ett paket som tillhandahåller TrueType-teckensnitt (så som 'ttf-freefont', 'ttf-bitstream-vera' eller 'msttcorefonts') och omkonfigurera MPlayer (med kommandot \"dpkg-reconfigure mplayer\")" + +#~ msgid "Create your ~/.mplayer/config file" +#~ msgstr "Skapa din ~/.mplayer/config fil" +#~ msgid "" +#~ "Performance of MPlayer depends heavily on hardware - this means that it " +#~ "may benefit from tweaking options, for every single machine it's " +#~ "installed to. You may wish to read the documentation (it is in the " +#~ "package 'mplayer-doc', under /usr/share/doc/mplayer-doc/). This DebConf " +#~ "interface will help you setup just a few main features; you may wish to " +#~ "add to /etc/mplayer/mplayer.conf some more refined options (to enable " +#~ "multichannel audio, or video postprocessing, etc etc); and any user " +#~ "similarly may customize MPlayer using the file ~/.mplayer/config" +#~ msgstr "" +#~ "Prestandan hos MPlayer beror kraftigt på hårdvaran - detta betyder att " +#~ "det kan vara förmånligt att justera inställningar, för varje enskild " +#~ "maskin som det installerats på. Det kan vara så att du vill läsa " +#~ "dokumentationen (som finns i paketet 'mplayer-doc', under /usr/share/doc/" +#~ "mplayer-doc/). Detta DebConf-gränssnitt kommer hjälpa dig att konfigurera " +#~ "endast ett par grundläggande funktioner; det kan vara så att du vill " +#~ "lägga till fler finjusterade inställningar till /etc/mplayer/mplayer.conf " +#~ "(för att slå på multikanals-ljud, video efterbehandling, etc.); och " +#~ "godtyckliga användare kan konfigurera MPlayer genom filen ~/.mplayer/" +#~ "config" +#~ msgid "Enable access to RTC?" +#~ msgstr "Aktivera tillgång till realtidsklockan (RTC)?" +#~ msgid "" +#~ "On older kernels MPlayer can use the RTC (Real Time Clock) to provide " +#~ "better timing in reproduction, with less CPU cost; to this end, though, " +#~ "the device /dev/rtc must be accessible to group audio, and the default " +#~ "max-user-freq must be raised to 1024. Any needed change must be done by " +#~ "root. If you wish, MPlayer will automatically do this at boot, so that " +#~ "any user can enjoy this feature. Note that there may be security issues " +#~ "with this (although none are known now)." +#~ msgstr "" +#~ "På äldre kärnor kan MPlayer använda RTC (realtidsklockan) för att förse " +#~ "bättre tidspressicion i reproduktion, med lägre CPU-kostnad; för detta " +#~ "ändamål måste dock enheten /dev/rtc vara tillgänglig för gruppen audio, " +#~ "om standard-värdet för max-user-freq måste höjjas till 1024. Någon begärd " +#~ "ändring måste göras av root. Om du önskar kan MPlayer automatiskt göra " +#~ "detta vid systemets uppstart, så att alla användare kan åtnjuta denna " +#~ "funktion. Notera att det kan finnas säkerhets-betänkligheter med detta " +#~ "(även om ingen är känd för tillfället)." +#~ msgid "Files not replaced" +#~ msgstr "Filer ersattes ej" +#~ msgid "" +#~ "It seems that you don't want to replace your existing configuration file /" +#~ "etc/mplayer/mplayer.conf. If you change your mind later, you can run " +#~ "\"dpkg-reconfigure mplayer\"." +#~ msgstr "" +#~ "Det verkar som du inte vill ersätta din existerande konfigurationsfil /" +#~ "etc/mplayer/mplayer.conf. Om du ändrar dig vid senare tillfälle kan du då " +#~ "köra \"dpkg-reconfigure mplayer\"." +#~ msgid "" +#~ "MPlayer can use a very wide range of video output drivers; it will try to " +#~ "autodetect the best one, but you may choose a preferred one. Here is a " +#~ "guide to the choice (in decreasing order of speed): (1) if you see an " +#~ "entry that matches your video card, choose that; (2) if your video card " +#~ "supports 'XV', choose that (use 'xvinfo' to know). You should read /usr/" +#~ "share/doc/mplayer-doc/HTML/en/video.html (it is in package 'mplayer-doc')." +#~ msgstr "" +#~ "MPlayer kan använda en väldigt bred rad av video utmatnings-system; den " +#~ "bästa kommer försöka automatiskt hittas, men du kan vilja välja en du " +#~ "föredrar. Här är en guide till valet (i avtagande ordning av fart): (1) " +#~ "om du ser något val som matchar ditt grafikkort välj det; (2) om ditt " +#~ "video-kort stödjer 'XV', välj det (använda 'xvinfo' för att kontrollera). " +#~ "Du bör läsa /usr/share/doc/mplayer-doc/HTML/en/video.html (som finns i " +#~ "paketet 'mplayer-doc')." +#~ msgid "How to download binary codecs" +#~ msgstr "Hur man laddar ner binära codecs" +#~ msgid "" +#~ "MPlayer supports most codecs out of the box and the rest with the help of " +#~ "binary codecs. Binary codecs are only necessary for Real 3.0 and 4.0, " +#~ "Windows Media 9, QuickTime audio and some very obscure codecs. Debian " +#~ "cannot distribute these codecs, but these are available on the internet " +#~ "for download. Run the script `/usr/share/mplayer/scripts/binary_codecs." +#~ "sh' to install those made available from MPlayer web site." +#~ msgstr "" +#~ "MPlayer stödjer de flesta codecs direkt från start och resten med hjälp " +#~ "av binära codecs. Binära codecs är endast nödvändiga för Real 3.0 och " +#~ "4.0, Windows Media 9, QuickTime audio och några väldigt obskyra codecs. " +#~ "Debian kan inte distribuera dessa codecs, men de finns tillgängliga på " +#~ "Internet för nerladdning, Kör skriptet `/usr/share/mplayer/scripts/" +#~ "binary_codecs.sh' för att installera de som gjorts tillgängliga på " +#~ "MPlayers webbplats." +#~ msgid "What is the name of your DVD device (if any):" +#~ msgstr "Vad är namnet på din DVD-enhet (om någon):" +#~ msgid "MPlayer OSD font:" +#~ msgstr "MPlayer OSD typsnitt:" +#~ msgid "MPlayer cannot find TrueType Fonts" +#~ msgstr "MPlayer kan inte hitta TrueType-teckensnitten" + diff --git a/debian/po/templates.pot b/debian/po/templates.pot new file mode 100644 index 0000000..9084876 --- /dev/null +++ b/debian/po/templates.pot @@ -0,0 +1,184 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: mennucc1@debian.org\n" +"POT-Creation-Date: 2007-10-28 09:36+0100\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "Detailed configuration needed for each user" +msgstr "" + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "" +"The performance of MPlayer depends heavily on hardware; this means that it " +"may benefit from tweaking options for every single machine it's installed on." +msgstr "" + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "" +"You should read the documentation provided by the 'mplayer-doc' package." +msgstr "" + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "" +"Now, some configuration options will be set for the entire system in /etc/" +"mplayer/mplayer.conf which may be adapted later. Any user can also refine " +"options in ~/.mplayer/config." +msgstr "" + +#. Type: boolean +#. Description +#: ../mplayer.templates:3001 +msgid "Replace existing configuration file?" +msgstr "" + +#. Type: boolean +#. Description +#: ../mplayer.templates:3001 +msgid "" +"An /etc/mplayer/mplayer.conf file already exists on the system and does not " +"contain an automatically-generated part. That file can be replaced by a " +"generated one (the old file will be moved to /etc/mplayer/mplayer.conf." +"debconf-old)." +msgstr "" + +#. Type: note +#. Description +#: ../mplayer.templates:4001 +msgid "Old configuration file kept" +msgstr "" + +#. Type: note +#. Description +#: ../mplayer.templates:4001 +msgid "You chose not to replace the existing /etc/mplayer/mplayer.conf file." +msgstr "" + +#. Type: note +#. Description +#: ../mplayer.templates:4001 +msgid "" +"That file can be generated automatically later by running 'dpkg-reconfigure " +"mplayer'." +msgstr "" + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "MPlayer video output:" +msgstr "" + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "" +"MPlayer can use a very wide range of video output drivers. The needed driver " +"may be detected automatically or chosen manually." +msgstr "" + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "" +"If you prefer choosing the driver yourself, you first should choose an entry " +"matching this system's video card. If none match and the card supports 'XV', " +"choose that option (the 'xvinfo' command may help)." +msgstr "" + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "" +"Please read the /usr/share/doc/mplayer-doc/HTML/en/video.html file from the " +"'mplayer-doc' package for more details." +msgstr "" + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "Binary codecs download" +msgstr "" + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "MPlayer supports most video formats without additional software." +msgstr "" + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "" +"Additional video formats, such as Real 3.0/4.0, Windows Media 9, or " +"Quicktime, can be supported by using binary codecs." +msgstr "" + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "" +"As such codecs are not free software, they are not distributed with this " +"package but can be downloaded freely. The '/usr/share/mplayer/scripts/" +"binary_codecs.sh' script is provided in this package to help downloading " +"them from the MPlayer web site." +msgstr "" + +#. Type: string +#. Description +#: ../mplayer.templates:7001 +msgid "DVD device name:" +msgstr "" + +#. Type: string +#. Description +#: ../mplayer.templates:7001 +msgid "Please enter the name of the device for your DVD player, if any." +msgstr "" + +#. Type: select +#. Description +#: ../mplayer.templates:8001 +msgid "Font for On Screen Display:" +msgstr "" + +#. Type: error +#. Description +#: ../mplayer.templates:9001 +msgid "No TrueType fonts found for On Screen Display" +msgstr "" + +#. Type: error +#. Description +#: ../mplayer.templates:9001 +msgid "" +"MPlayer needs at least one TrueType font for its 'On Screen Display' feature." +msgstr "" + +#. Type: error +#. Description +#: ../mplayer.templates:9001 +msgid "" +"You should install a package providing such fonts (such as 'ttf-freefont' or " +"'ttf-bitstream-vera' or 'msttcorefonts') and reconfigure MPlayer (by running " +"'dpkg-reconfigure mplayer')." +msgstr "" diff --git a/debian/po/vi.po b/debian/po/vi.po new file mode 100644 index 0000000..bb7bde3 --- /dev/null +++ b/debian/po/vi.po @@ -0,0 +1,216 @@ +# Vietnamese translation for MPlayer. +# Copyright © 2007 Free Software Foundation, Inc. +# Clytie Siddall , 2007 +# +msgid "" +msgstr "" +"Project-Id-Version: mplayer\n" +"Report-Msgid-Bugs-To: mennucc1@debian.org\n" +"POT-Creation-Date: 2007-10-18 10:01+0200\n" +"PO-Revision-Date: 2007-10-24 22:10+0930\n" +"Last-Translator: Clytie Siddall \n" +"Language-Team: Vietnamese \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=1; plural=0;\n" +"X-Generator: LocFactoryEditor 1.7b1\n" + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "Detailed configuration needed for each user" +msgstr "Cấu hình chi tiết cần thiết cho mỗi người dùng" + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "" +"The performance of MPlayer depends heavily on hardware; this means that it " +"may benefit from tweaking options for every single machine it's installed on." +msgstr "" +"Hiệu suất của MPlayer phụ thuộc nặng vào phần cứng: có nghĩa là nó có thể " +"lợi dụng điều chỉnh các tùy chọn cho từng máy riêng rẽ trên đó nó đã cài đặt." + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "" +"You should read the documentation provided by the 'mplayer-doc' package." +msgstr "Khuyên bạn đọc tài liệu hướng dẫn có sẵn trong gói « mplayer-doc »." + +#. Type: note +#. Description +#: ../mplayer.templates:2001 +msgid "" +"Now, some configuration options will be set for the entire system in /etc/" +"mplayer/mplayer.conf which may be adapted later. Any user can also refine " +"options in ~/.mplayer/config." +msgstr "" +"Lúc này một số tùy chọn cấu hình sẽ được đặt cho toàn hệ thống trong tập tin " +"« /etc/mplayer/mplayer.conf » mà cũng có thể sửa đổi sau. Bất cứ người dùng " +"nào cũng có thể điều chỉnh các tùy chọn riêng trong « ~/.mplayer/config »." + +#. Type: boolean +#. Description +#: ../mplayer.templates:3001 +msgid "Replace existing configuration file?" +msgstr "Thay thế tập tin cấu hình đã tồn tại không?" + +#. Type: boolean +#. Description +#: ../mplayer.templates:3001 +msgid "" +"An /etc/mplayer/mplayer.conf file already exists on the system and does not " +"contain an automatically-generated part. That file can be replaced by a " +"generated one (the old file will be moved to /etc/mplayer/mplayer.conf." +"debconf-old)." +msgstr "" +"Một tập tin « /etc/mplayer/mplayer.conf » đã có trên hệ thống, và không chứa " +"phần được tạo ra tự động. Có thể thay thế tập tin đó bằng tập tin đã tạo ra " +"(tập tin cũ sẽ bị di chuyển sang « /etc/mplayer/mplayer.conf.debconf-old »)." + +#. Type: note +#. Description +#: ../mplayer.templates:4001 +msgid "Old configuration file kept" +msgstr "Vẫn giữ tập tin cấu hình cũ" + +#. Type: note +#. Description +#: ../mplayer.templates:4001 +msgid "You chose not to replace the existing /etc/mplayer/mplayer.conf file." +msgstr "" +"Bạn đã chọn không thay thế tập tin « /etc/mplayer/mplayer.conf » đã có." + +#. Type: note +#. Description +#: ../mplayer.templates:4001 +msgid "" +"That file can be generated automatically later by running 'dpkg-reconfigure " +"mplayer'." +msgstr "" +"Vẫn còn có thể tạo ra tự động tập tin đó về sau bằng cách chạy lệnh cấu hình " +"lại gói « dpkg-reconfigure mplayer »." + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "MPlayer video output:" +msgstr "Ảnh động MPlayer xuất ra:" + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "" +"MPlayer can use a very wide range of video output drivers. The needed driver " +"may be detected automatically or chosen manually." +msgstr "" +"MPlayer có khả năng sử dụng rất nhiều trình điều khiển kết xuất ảnh động " +"khác nhau. Nó có thể phát hiện tự động trình điều khiển cần thiết, hoặc bạn " +"có thể tự chọn." + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "" +"If you prefer choosing the driver yourself, you first should choose an entry " +"matching this system's video card. If none match and the card supports 'XV', " +"choose that option (the 'xvinfo' command may help)." +msgstr "" +"Muốn tự chọn thì bạn đầu tiên nên chọn mục nhập tương ứng với bo mạch ảnh " +"động của hệ thống. Không có, và bo mạch hỗ trợ « XV » thì bật tùy chọn đó " +"(câu lệnh thông tin « xvinfo » có thể giúp)." + +#. Type: select +#. Description +#: ../mplayer.templates:5001 +msgid "" +"Please read the /usr/share/doc/mplayer-doc/HTML/en/video.html file from the " +"'mplayer-doc' package for more details." +msgstr "" +"Vui lòng đọc tập tin « /usr/share/doc/mplayer-doc/HTML/en/video.html » có " +"sẵn trong gói tài liệu « mplayer-doc » để tìm thêm chi tiết." + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "Binary codecs download" +msgstr "Tải xuống codec nhị phân" + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "MPlayer supports most video formats without additional software." +msgstr "" +"MPlayer hỗ trợ phần lớn định dạng ảnh động, không cần phần mềm bổ sung." + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "" +"Additional video formats, such as Real 3.0/4.0, Windows Media 9, or " +"Quicktime, can be supported by using binary codecs." +msgstr "" +"Các định dạng ảnh động thêm, như Real 3.0/4.0, Windows Media 9, hoặc " +"Quicktime, cũng hỗ trợ được bằng cách sử dụng codec nhị phân." + +#. Type: note +#. Description +#: ../mplayer.templates:6001 +msgid "" +"As such codecs are not free software, they are not distributed with this " +"package but can be downloaded freely. The '/usr/share/mplayer/scripts/" +"binary_codecs.sh' script is provided in this package to help downloading " +"them from the MPlayer web site." +msgstr "" +"Vì các codec như vậy không phải là phần mềm tự do, chúng không được phân " +"phối cùng với gói này, nhưng vẫn có thể tải xuống miễn phí. Văn lệnh « usr/" +"share/mplayer/scripts/binary_codecs.sh » được cung cấp trong gói này để giúp " +"tải chúng xuống địa chỉ Web của MPlayer." + +#. Type: string +#. Description +#: ../mplayer.templates:7001 +msgid "DVD device name:" +msgstr "Tên thiết bị DVD:" + +#. Type: string +#. Description +#: ../mplayer.templates:7001 +msgid "Please enter the name of the device for your DVD player, if any." +msgstr "Hãy gõ tên của thiết bị ổ đĩa DVD, nếu có." + +#. Type: select +#. Description +#: ../mplayer.templates:8001 +msgid "Font for On Screen Display:" +msgstr "Phông để hiển thị trên màn hình:" + +#. Type: error +#. Description +#: ../mplayer.templates:9001 +msgid "No TrueType fonts found for On Screen Display" +msgstr "Không tìm thấy phông TrueType để hiển thị trên màn hình" + +#. Type: error +#. Description +#: ../mplayer.templates:9001 +msgid "" +"MPlayer needs at least one TrueType font for its 'On Screen Display' feature." +msgstr "" +"MPlayer yêu cầu ít nhất một phông TrueType (.ttf) cho tính năng « Hiển thị " +"trên màn hình » của nó." + +#. Type: error +#. Description +#: ../mplayer.templates:9001 +msgid "" +"You should install a package providing such fonts (such as 'ttf-freefont' or " +"'ttf-bitstream-vera' or 'msttcorefonts') and reconfigure MPlayer (by running " +"'dpkg-reconfigure mplayer')." +msgstr "" +"Bạn nên cài đặt một gói phông .ttf (v.d. URWVN [http://freshmeat.net/" +"projects/urwvn/] hay DejaVu [http://dejavu.sourceforge.net/wiki/index.php/" +"Main_Page], cả hai hiển thị đúng tiếng Việt UTF-8), rồi cấu hình lại MPlayer " +"bằng cách chạy lệnh « dpkg-reconfigure mplayer »." diff --git a/debian/postinst b/debian/postinst deleted file mode 100755 index e8fb636..0000000 --- a/debian/postinst +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/perl -w - -# mplayer postinst - -require ConfHelper; - -use Debconf::Client::ConfModule qw(:all); -use IO::Handle; -use Fcntl; -my $version = version(2.0); -my $didupgrade = 0; - -dealwithupgrades(); - -my $mcfg = new ConfHelper('mplayer', "/etc/mplayer/mplayer.conf"); - - - -my $dcarea = "" ; -my $font = scalar(get("mplayer/ttfont")) ; - $dcarea .= "#truetype font\nfont=" . $font . "\n" if $font; -$mcfg->setconfarea($dcarea); - - - -sub dealwithupgrades { - open(OLDCONF, "hasconfarea()); - undef $mconf; - - if ((get('mplayer/replace-existing-files') eq 'true') && - (fget('mplayer/replace-existing-files', 'isdefault') eq 'false')) { - $didupgrade = 1; - for my $file ("/etc/mplayer/mplayer.conf" ) { - debug("Moving away $file"); - rename($file,$file . ".old"); - } - } else { - debug("Upgrade refused, exiting"); - exit 0; - } -} - -sub debug { - print STDERR @_, "\n"; -} - - -# pass control to debhelper scripts.. -# -my $temp="set -e\nset -- @ARGV\n" . << 'DEBHELPER_EOF_'; -#DEBHELPER# -DEBHELPER_EOF_ -system ($temp) / 256 == 0 - or die "Problem with debhelper scripts: $!"; diff --git a/debian/postrm b/debian/postrm deleted file mode 100644 index 5cfa18c..0000000 --- a/debian/postrm +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -set -e - -if [ "$1" = "purge" ]; then - if [ -e /usr/share/debconf/confmodule ]; then - # Source debconf library. - . /usr/share/debconf/confmodule - # Remove my changes to the db. - db_purge - fi - - if [ -d /etc/mplayer/ ]; then - rm -rf /etc/mplayer/ - fi -fi - -#DEBHELPER# diff --git a/debian/prefs/MD5SUMS b/debian/prefs/MD5SUMS new file mode 100644 index 0000000..0ae19c0 --- /dev/null +++ b/debian/prefs/MD5SUMS @@ -0,0 +1,34 @@ +cb4bb06ebc804f5dc4ec0ed516dc20d9 all-20061022.tar.bz2 +0407e8ad132e37ccd3f932448ca201c5 all-20071007.tar.bz2 +c71cbf23c9ac84b85a15801af6fe5fa4 all-alpha-20061028.tar.bz2 +7918b605cca3df7e2c34784f1328e494 all-ppc-20061022.tar.bz2 +abcf4a3abc16cf88c9df7e0a77e9b941 essential-20061022.tar.bz2 +4ea9c2dbd0945c83af1a8d0dd363993c essential-20071007.tar.bz2 +96fe3d614650531dda6675124f986a13 essential-alpha-20061028.tar.bz2 +af409ba2918dc8f639dded805102fc76 essential-amd64-20061203.tar.bz2 +8e1ceeec51469f5baac65e56fac709e8 essential-amd64-20071007.tar.bz2 +df9ec99d9fa7ef0ab6a633cfb421d637 essential-ppc-20061022.tar.bz2 +6682d5013a91bb80fdde87a516f6a8af essential-ppc-20071007.tar.bz2 +1f5b8e9d9e31f898b1207a0b3bd70f32 qt5dlls-20040626.tar.bz2 +dbb2e77156a69179473b86f7498e9b29 qt63dlls-20050115.tar.bz2 +9fb88417aef157e2f1f5b7be57eaed7b qt65dlls-20040704.tar.bz2 +c8cc10f2c9f109fa44fc4dddb91571c4 qt6dlls-20040626.tar.bz2 +a7e750afda31796d322395d77c4184d0 qtextras-20041107.tar.bz2 +c9ae3969ba1e73a8cbeef38f5803fd2e rp8codecs-20040626.tar.bz2 +32919658c4bdfb3454173e3d64d26dc2 rp8codecs-alpha-20050115.tar.bz2 +4cc9a6270f9aa834b4fef49d71b9faf9 rp8codecs-ppc-20050115.tar.bz2 +534658c867abb81c38e0c05bccc79a79 rp8codecs-win32-20040626.tar.bz2 +a32f4fa1f77593536a57e4b662fde7aa rp9codecs-20050115.tar.bz2 +6b56c1c127f5ac0c4c8a9878f24477ca rp9codecs-win32-20050115.tar.bz2 +4558d3690e9479b06df16d0a15b35f9d unsupported-20040809.tar.bz2 +90ba6a76ded2f9fd9f865024bd8de3d3 win32codecs-20040703.tar.bz2 +58ce4d68001d4f39c3e84d52834fb3ef win32codecs-essential-20040703.tar.bz2 +a7c980a1a94fbac6ebd34c7485a1891d xanimdlls-20040626.tar.bz2 +0b4877ac52eb7e84eb3031e6d7a3f65d xanimdlls-alpha-20061028.tar.bz2 +8965e5f67f39530f293fc6c594bca19a xanimdlls-ppc-20040626.tar.bz2 +1e409d500336a8318cbe2a67bbf9d9ca essential-macosx-x86-20060611.zip +788cf4940280fd787c0a2141d88ce3c7 rp9codecs-macosx-20041107.pkg.zip +1323e8d46bfc7b8d1d6d172018222e9c windows-all-20061022.zip +f96557eeddb4ea9d286a89ff8c91750a windows-all-20071007.zip +0cc375cebb4f7820ad82bc2802171193 windows-essential-20061022.zip +e32bdc9970f0df7da8eb23d2b254b866 windows-essential-20071007.zip diff --git a/debian/prefs/codecs_list b/debian/prefs/codecs_list new file mode 100644 index 0000000..959b33f --- /dev/null +++ b/debian/prefs/codecs_list @@ -0,0 +1,10 @@ +i386 @MAINSITE@ releases/codecs essential-20071007.tar.bz2 +powerpc @MAINSITE@ releases/codecs essential-ppc-20071007.tar.bz2 +amd64 @MAINSITE@ releases/codecs essential-amd64-20071007.tar.bz2 +alpha @MAINSITE@ releases/codecs essential-alpha-20061028.tar.bz2 + + + + + + diff --git a/debian/prefs/mirrors b/debian/prefs/mirrors new file mode 100644 index 0000000..d3e0fac --- /dev/null +++ b/debian/prefs/mirrors @@ -0,0 +1,7 @@ +http://www1.mplayerhq.hu/MPlayer/ +http://www2.mplayerhq.hu/MPlayer/ +http://www3.mplayerhq.hu/MPlayer/ +http://www4.mplayerhq.hu/MPlayer/ +http://www5.mplayerhq.hu/MPlayer/ +http://www7.mplayerhq.hu/MPlayer/ +http://www8.mplayerhq.hu/MPlayer/ diff --git a/debian/rules b/debian/rules index b2173e6..43e5a3b 100755 --- a/debian/rules +++ b/debian/rules @@ -1,80 +1,343 @@ #!/usr/bin/make -f -# Made with the aid of debmake, by Christoph Lameter, -# based on the sample debian/rules file for GNU hello by Ian Jackson. +########### +## this snippet comes from debhelper-5.0.40/examples/rules.multi2 +# +# Based on a sample debian/rules that uses debhelper. +# (That file is public domain software, originally written by Joey Hess.) +# +# This version is for a multibinary package. It also allows you to build any +# of the binary packages independantly, via binary- targets. + +# Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 -# This is the debhelper compatability version to use. -export DH_COMPAT=4 + +# This has to be exported to make some magic below work. +export DH_OPTIONS + +############ package := mplayer -prefix := $(shell pwd)/debian/$(package) -arch := $(shell dpkg --print-architecture) +## The Subversion revision is not autodetected in some targets! +upstreamversion := 1.0rc2 + +## We add a ~ to it. +debian_version := 1.0~rc2 + + + +svn_revision := $(shell if test -r .svn ; then LC_ALL=C svn info 2> /dev/null | grep Revision | cut -d' ' -f2 ; elif test -r revision.svn ; then cat revision.svn ; fi ) + +CC_version := $(shell $(CC) -dumpversion) + +UPSTREAMSOURCE := upstream SVN repository +#UPSTREAMSOURCE := http://www1.mplayerhq.hu/MPlayer/releases/MPlayer-1.0rc1.tar.bz2 + +#Was troublesome stuff removed ? +# See target "fix-orig-source" in this makefile. +DFSG := $(shell test -d libdvdcss && echo 'This version of MPlayer contains libdvdcss.' ) + +ifeq ($(DFSG),) +extraversion := DFSG-free +else +extraversion := DFSG-nonfree +endif + + + +ifeq ($(shell cat /etc/debian_version),3.1) #AKA Sarge +XLIBS := xlibs-dev +else +XLIBS := libx11-dev, libxext-dev, libxinerama-dev, libxv-dev, libxvmc-dev, libxxf86dga-dev, libxxf86vm-dev, x11proto-core-dev +endif + +ifeq ($(wildcard DOCS/.upstream_ships_docs),DOCS/.upstream_ships_docs) +DOCDEP := +else +DOCDEP := docbook-xml, docbook-xsl, xsltproc +endif + +destdir := $(shell pwd)/debian/$(package) + +arch := $(shell dpkg-architecture -qDEB_HOST_ARCH) +#FIXME: How shall this be used? MPlayer has a non-autoconf configure script. +DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) +DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) +DEB_HOST_ARCH_OS ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_OS) +DEB_HOST_ARCH_CPU ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_CPU) + + +# hi dpkg-buildpackage. nice to see you make the game tougher +CLEAN_ENV=env -u CFLAGS -u CPPFLAGS -u LDFLAGS -u FFLAGS -u CXXFLAGS + + +## This can be overridden from the command line, see README.Debian. +DEB_BUILD_CONFIGURE=--disable-bitmap-font --disable-ggi --disable-xvid --language=all --disable-xmms --disable-arts --disable-aa --disable-mad --disable-libdv --enable-libavutil_so --enable-libavcodec_so --enable-libavformat_so --enable-libpostproc_so --disable-faad-internal $(archconf) -configure: configure-stamp -configure-stamp: +# Choose whether we want binary codec support (default on unknown archs: no). +with_real_and_xanim = false +with_win32 = false + +ifeq ($(arch),i386) +#Avoid high optimization through gcc. + archconf += --target=i586-linux + with_real_and_xanim = true + with_win32 = true + DEB_BUILD_CONFIGURE += --enable-runtime-cpudetection +endif +ifeq ($(arch),amd64) + #this needs the patch + # http://people.freedesktop.org/~jinghua/real64/mplayer-amd64-real-codecs.diff + with_real_and_xanim = true + #this does not compile, though : with_win32 = true + DEB_BUILD_CONFIGURE += --enable-runtime-cpudetection +endif +ifeq ($(arch),kfreebsd-i386) + with_real_and_xanim = true + DEB_BUILD_CONFIGURE += --enable-runtime-cpudetection +endif +ifeq ($(arch),kfreebsd-amd64) + with_real_and_xanim = true + DEB_BUILD_CONFIGURE += --enable-runtime-cpudetection +endif +ifeq ($(arch),powerpc) + with_real_and_xanim = true + DEB_BUILD_CONFIGURE += --enable-runtime-cpudetection +endif +ifeq ($(arch),alpha) +#Avoid high optimization through gcc. +# see http://permalink.gmane.org/gmane.linux.debian.ports.alpha/7295 + archconf += --target=alpha_ev5-linux + with_real_and_xanim = true +endif +ifeq ($(with_win32),false) + archconf += --disable-win32dll +else + archconf += --enable-win32dll +endif +ifeq ($(with_real_and_xanim),false) + archconf += --disable-real --disable-xanim +else + archconf += --enable-real --enable-xanim +endif + + + + +ifeq ($(DFSG),) +DEB_BUILD_CONFIGURE += --disable-libdvdcss-internal --disable-dvdread-internal --disable-mencoder +endif + +#generate debugging symbols for mplayer-dbg +DEB_BUILD_CONFIGURE += --enable-debug + +#ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) +#DEB_BUILD_CONFIGURE += --enable-debug +##some other stuff below +#else +#ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS))) +#DEB_BUILD_CONFIGURE += --enable-debug=3 +#endif +#endif + + +ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS))) + NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS))) + MAKEFLAGS += -j$(NUMJOBS) +endif + + +ifeq (linux,$(DEB_HOST_ARCH_OS)) + DEB_BUILD_CONFIGURE += --enable-tv-v4l2 --enable-xmga --enable-mga --enable-3dfx --enable-tdfxfb --enable-fbdev +endif +ifeq (kfreebsd,$(DEB_HOST_ARCH_OS)) + DEB_BUILD_CONFIGURE += --enable-tv-bsdbt848 --disable-directfb +endif + + + +#DEB_BUILD_CONFIGURE += --enable-libavutil_so --enable-libavformat_so --enable-libavcodec_so --enable-libpostproc_so +#EXTRA_BUILDDEP += libavcodec-dev (>= 0.svn6767), libavformat-dev (>= 0.svn6767), libpostproc-dev (>= 0.svn6767) + +########### build + +patch: patch-stamp +patch-stamp: + dpatch apply-all + dpatch cat-all >patch-stamp +unpatch: + dpatch deapply-all + rm -rf patch-stamp debian/patched + +####### build-arch + +configure: configure-arch-stamp +configure-arch-stamp: patch-stamp dh_testdir - # Add here commands to configure the package. - $(checkdir) - # If you plan to install the target .deb on a wide variety of machines, - # you may want to add the "--enable-runtime-cpudetection" option to - # the line below, but beware: the resulting binary will run slower - ./configure --prefix=/usr --confdir=/etc/mplayer $(DEB_BUILD_OPTIONS) + #Check consistency between debian/control and what we are compiling. + grep -x 'Source: $(package)' debian/control + grep -x 'Package: $(package)' debian/control + # Add commands to configure the package here. + ${CLEAN_ENV} ./configure --prefix=/usr --confdir=/etc/mplayer \ + --datadir=/usr/share/mplayer --codecsdir=/usr/lib/codecs \ + --enable-xvmc --enable-sdl --enable-ossaudio \ + --enable-lirc --enable-gui --enable-freetype --enable-menu \ + --enable-largefiles $(DEB_BUILD_CONFIGURE) + # + if test "$(svn_revision)" ; then echo "#define VERSION \"dev-SVN-r$(svn_revision)-$(CC_version)-$(extraversion)\"" > version.h ; else sh version.sh $(CC_version)-$(extraversion) ; fi + - touch configure-stamp + #tweak config.mak on request +ifneq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS))) + mv config.mak config.mak~~ + sed 's/STRIPBINARIES.*/STRIPBINARIES = no/' config.mak~~ > config.mak + #dh_strip does(n't) the rest of the job +endif +ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) + mv config.mak config.mak~~ + sed '/FLAGS/s/ -O[0-9] / /' config.mak~~ > config.mak +endif + #workaround for gcc bug 475153 (hopefully) +ifeq (powerpc,$(DEB_HOST_ARCH_CPU)) + mv config.mak config.mak~~ + sed '/FLAGS/s/ -O[0-9] / -O /' config.mak~~ > config.mak +endif + touch configure-arch-stamp -build: configure-stamp build-stamp -build-stamp: +# commands to compile the package +build-arch: build-arch-stamp +build-arch-stamp: configure-arch-stamp dh_testdir +ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) +ifeq ($(arch),i386) + echo SORRY THIS DOES NOT WORK CURRENTLY + cd libvo && ${CLEAN_ENV} ${MAKE} CC='gcc -O' osd.o + cd libavcodec && ${CLEAN_ENV} ${MAKE} i386/dsputil_mmx.o cabac.o OPTFLAGS=" -O2 -ffast-math -fomit-frame-pointer" + cd libpostproc && ${CLEAN_ENV} ${MAKE} postprocess.o OPTFLAGS=" -O2 -ffast-math -fomit-frame-pointer" + cd mp3lib && ${CLEAN_ENV} ${MAKE} dct64_sse.o OPTFLAGS=" -I.. -O2 -ffast-math -fomit-frame-pointer" + cd liba52 && ${CLEAN_ENV} ${MAKE} imdct.o OPTFLAGS=" -I.. -O2 -ffast-math -fomit-frame-pointer" +endif +endif + #workaround for 478731 (hopefully) + #cd gui && ${CLEAN_ENV} ${MAKE} skin/skin.o skin/font.o OPTFLAGS=" -I. -I.. -g -Wall" - # commands to compile the package. - ${MAKE} + ${CLEAN_ENV} ${MAKE} + touch build-arch-stamp - touch build-stamp +###### build-indep -clean: +# commands to compile the docs +build-indep: configure build-indep-stamp +build-indep-stamp: dh_testdir - dh_testroot - rm -f build-stamp configure-stamp + #Configure the independent part (not in a separate block: it is fast!). + [ -r DOCS/.upstream_ships_docs ] || { cd DOCS/xml && ./configure ; } + # + [ -r DOCS/.upstream_ships_docs ] || ${CLEAN_ENV} ${MAKE} -C DOCS/xml html-chunked + touch build-indep-stamp - # commands to clean up after the build process. - -$(MAKE) distclean - rm -f help_mp.h config.h config.mak - dh_clean -# Build architecture-independent files here. -binary-indep: build -# We have nothing to do by default. +build: build-indep build-arch -# Build architecture-dependent files here. -binary-arch: build + +################ clean + +clean: clean-patched + +clean-patched: unpatch dh_testdir dh_testroot - dh_clean -k - dh_installdirs + # commands to clean up after the build process + -[ -r DOCS/.upstream_ships_docs ] || ${MAKE} -C DOCS/xml distclean + - $(MAKE) distclean + #- $(MAKE) -C Gui distclean + # + rm -f config.h config.mak build-arch-stamp build-indep-stamp configure-arch-stamp configure.log + #some leftovers + find -name '*.o' -or -name '*.a' -or -name '*~' \ + -or -name semantic.cache -print0 |\ + xargs -r0 rm -v + # + dh_clean + + +##################### install + +manlangs := $(notdir $(wildcard DOCS/man/*) ) + +install-arch: build-arch + dh_testdir + dh_clean -a -k +# scripts + chmod a+x debian/scripts/* + dh_install debian/scripts usr/share/mplayer/ + dh_install debian/prefs var/lib/mplayer/ + +# commands to install the package into debian/ + ${MAKE} prefix=$(destdir)/usr BINDIR=$(destdir)/usr/bin CONFDIR=$(destdir)/etc/mplayer LIBDIR=$(destdir)/usr/lib DATADIR=$(destdir)/usr/share/mplayer MANDIR=$(destdir)/usr/share/man install + + dh_link usr/bin/mplayer usr/bin/gmplayer + dh_link usr/share/man/man1/mplayer.1.gz usr/share/man/man1/gmplayer.1.gz - # commands to install the package into debian/ - $(MAKE) prefix=$(prefix)/usr BINDIR=$(prefix)/usr/bin CONFDIR=$(prefix)/etc/mplayer LIBDIR=$(prefix)/usr/lib DATADIR=$(prefix)/usr/share/mplayer MANDIR=$(prefix)/usr/share/man install +# Install man pages. + set -e && for i in $(manlangs) ; do mkdir -p $(destdir)/usr/share/man/$$i/man1/ && cp DOCS/man/$$i/mplayer.1 $(destdir)/usr/share/man/$$i/man1/ && dh_link usr/share/man/$$i/man1/mplayer.1.gz usr/share/man/$$i/man1/gmplayer.1.gz ; done - dh_link usr/bin/mplayer usr/bin/gmplayer \ - usr/share/man/man1/mplayer.1.gz usr/share/man/man1/gmplayer.1.gz + dh_installdebconf -p $(package) + dh_installdocs -p $(package) Copyright + dh_installexamples etc/example.conf etc/menu.conf etc/input.conf - dh_installdebconf - dh_installdocs -X.svn -Xmplayer.1 DOCS/* - dh_installexamples etc/example.conf etc/dvb-menu.conf etc/input.conf etc/menu.conf + + + +install-indep: build-indep + dh_testdir + dh_clean -i -k + dh_installdocs -p mplayer-doc Copyright DOCS/HTML DOCS/tech + + + + +##################################################### +## this snippet again comes from debhelper-5.0.40/examples/rules.multi2 + +# This single target is used to build all the packages, all at once, or +# one at a time. So keep in mind: any options passed to commands here will +# affect _all_ packages. Anything you want to only affect one package +# should be put in another target, such as the install target. +binary-common: + dh_testdir + dh_testroot + dh_installchangelogs + dh_installdocs + dh_installexamples dh_installmenu + dh_installdebconf dh_installmime - dh_installinfo - dh_installchangelogs - #ChangeLog + dh_installinit + dh_installman +# dh_installcron +# dh_installinfo +# dh_undocumented + dh_strip --dbg-package=${package}-dbg dh_link - dh_strip +###### non-orthodox mungling +# Add automatic vo list. + if test -r debian/$(THISPACKAGE)/DEBIAN/config ; then sh -e debian/config.augmenter debian/$(THISPACKAGE)/DEBIAN/config ; fi +# Rewrite README.Debian and add free or non-free statement. +ifeq ($(DFSG),) + tail -n +2 debian/README.Debian.free | sed 's!@UPSTREAMSOURCE@!$(UPSTREAMSOURCE)!' > debian/$(THISPACKAGE)/usr/share/doc/$(THISPACKAGE)/README.Debian +else + tail -n +2 debian/README.Debian.nonfree | sed 's!@UPSTREAMSOURCE@!$(UPSTREAMSOURCE)!' > debian/$(THISPACKAGE)/usr/share/doc/$(THISPACKAGE)/README.Debian +endif + sed 's!@DEB_BUILD_CONFIGURE@!$(DEB_BUILD_CONFIGURE)!' < debian/README.Debian >> debian/$(THISPACKAGE)/usr/share/doc/$(THISPACKAGE)/README.Debian + +######## dh_compress dh_fixperms dh_makeshlibs dh_installdeb - dh_perl dh_shlibdeps dh_gencontrol dh_md5sums @@ -82,21 +345,86 @@ binary-arch: build -#binary-arch: checkroot build -# $(checkdir) -# -rm -rf debian/tmp -# install -d debian/tmp -# cd debian/tmp && install -d `cat ../dirs` - +# Build architecture-independent packages using the common target. +binary-indep: install-indep + $(MAKE) -f debian/rules DH_OPTIONS=-i THISPACKAGE=mplayer-doc binary-common -# Must have debmake installed for this to work. Otherwise please copy -# /usr/bin/debstd into the debian directory and change debstd to debian/debstd -# debstd -# dpkg-gencontrol -isp -# chown -R root.root debian/tmp -# chmod -R go=rX debian/tmp -# dpkg --build debian/tmp .. +# Build architecture-dependent packages using the common target. +binary-arch: install-arch + $(MAKE) -f debian/rules DH_OPTIONS=-a THISPACKAGE=mplayer binary-common binary: binary-indep binary-arch -.PHONY: binary binary-arch binary-indep clean checkroot +##################################################### +##This target generates debian/control. It is not automatically invoked. +autocontrol: + mv -b debian/control debian/control.bak + sed 's/@MPLAYER@/$(package)/;s/@XLIBS@/$(XLIBS)/;s/@EXTRA_BUILDDEP@/$(EXTRA_BUILDDEP)/;s/@DFSG@/$(DFSG)/;s/@DOCDEP@/$(DOCDEP)/' < debian/control.in > debian/control + #Enjoy the difference. + ! diff -u debian/control.bak debian/control || echo NO CHANGES + +############################################### +##These targets generate the DFSG-free tar.gz. +## They are not automatically invoked. + +##temporary dir +D := temp_dir_to_debianize_mplayer + +##What we expect to find in a tar.bz2 from upstream. +M := MPlayer-$(upstreamversion) + + +download-and-unpack-orig: + mkdir $(D) + ###Darn, this does not work in any dir (as requested by policy). + # $(dirname ??)/scripts/binary_codecs.sh download MPlayer-$(upstreamversion).tar.bz2 + ### Download file, or link it if available. + if [ -r $(M).tar.bz2 ] ; then ln -s ../$(M).tar.bz2 $(D)/. ; elif [ -r ../$(M).tar.bz2 ] ; then ln -s ../../$(M).tar.bz2 $(D)/. ; else cd $(D) && wget -N $(UPSTREAMSOURCE) ; fi + cd $(D) && tar xjf $(M).tar.bz2 && rm $(M).tar.bz2 + +copy-orig-from-svn: ../mplayer/.svn /usr/bin/svn + mkdir $(D) + cp -al ../mplayer $(D)/$(M) + cd $(D)/$(M) && LC_ALL=C svn info 2> /dev/null | grep Revision | cut -d' ' -f2 > revision.svn + find $(D)/$(M) -type d -name .svn | xargs rm -r + +##Part of the source that is not shipped with Debian. +E := mplayer-non-DFSG-$(debian_version) + +##Part of the source that is shipped with Debian. +S := mplayer-$(debian_version) + + +fix-orig-source: $(D)/$(M) + mkdir $(D)/$(E) + # This contains the dreaded DVD decryption code. We can live without it + # by using libdvdread3 (and the optional library installed by + # http://www.debian-unofficial.org/ :-) + cd $(D) && mv $(M)/libdvdcss $(E) + # Well this may seem a bit excessive... But this code is not useful + # for building the package, and most of it does not correctly state + # author-license-copyright: So I throw out the baby and the bath... + # When and if someone needs this stuff, I will carefully scrutinize + # it and add what is suitable. + cd $(D) && mv $(M)/TOOLS $(E) + #Check if upstream includes DOCS and then don't rebuild them. + cd $(D)/$(M)/DOCS && if [ -r HTML ] ; then touch .upstream_ships_docs; fi + # My debian dir is too different. + cd $(D)/$(M) && mv debian debian_upstream + # Do not support encoding in any way. + cd $(D) && mv $(M)/mencoder.c $(E) + # OK, let's repackage. + cd $(D) && mv MPlayer-$(upstreamversion) $(S) && tar czf ../mplayer_$(debian_version).orig.tar.gz $(S) && rm -r $(S) + + cd $(D) && tar czf mplayer-non-DFSG_$(debian_version).tar.gz $(E) && gpg --passphrase yes -c mplayer-non-DFSG_$(debian_version).tar.gz && mv mplayer-non-DFSG_$(debian_version).tar.gz.gpg .. && rm -r $(E) mplayer-non-DFSG_$(debian_version).tar.gz + rmdir $(D) + +#unfix-orig-source: debian/mplayer.menu +# if [ -r $(M).tar.bz2 ] ; then ln -s ../$(M).tar.bz2 $(D)/. ; elif [ -r ../$(M).tar.bz2 ] ; then ln -s ../../$(M).tar.bz2 $(D)/. ; else cd $(D) && wget -N $(UPSTREAMSOURCE) ; fi +# cd $(D) && tar xjf $(M).tar.bz2 && rm $(M).tar.bz2 + + +# This will fail for Subversion-derived sources. +get-orig-source : download-and-unpack-orig fix-orig-source + +.PHONY: build clean binary-indep binary-arch binary-common binary install binary binary-arch binary-indep clean checkroot get-orig-source autocontrol fix-orig-source copy-orig-from-svn download-and-unpack-orig diff --git a/debian/scripts/binary_codecs.sh b/debian/scripts/binary_codecs.sh new file mode 100644 index 0000000..63587b6 --- /dev/null +++ b/debian/scripts/binary_codecs.sh @@ -0,0 +1,220 @@ +#!/bin/sh +set -e +umask 0022 + +# This script will download binary codecs for MPlayer unto a Debian system. + +# Author: thuglife, mennucc1 +# + +CODECDIR=/usr/lib/codecs +PREFDIR=/var/lib/mplayer/prefs +MYSITE='http://people.debian.org/~mennucc1/mplayer' + +dpkgarch=$(dpkg --print-installation-architecture) + +[ -d $PREFDIR ] || mkdir -v $PREFDIR +[ -d $CODECDIR ] || mkdir -v $CODECDIR +cd $CODECDIR +[ -d mplayer_binary_codecs ] || mkdir -v mplayer_binary_codecs + + +choosemirror () +{ + cd $PREFDIR + + #if [ ! -r mirrors ] || find mirrors -mtime +20 ; then + echo Downloading mirrors list.. + wget -nv -N $MYSITE/mirrors || true + #fi + if [ ! -r bestsites ] || [ mirrors -nt bestsites ] || \ + find bestsites -mtime +20 | grep -q bestsites ; then + if which netselect > /dev/null ; then + echo Choosing best mirrors using netselect.... + netselect -s 5 -t 5 $( cat mirrors ) | awk '{print $2}' > bestsites + elif which fping > /dev/null ; then + fping -C 1 $( sed 's#.*//##;s#/.*##' mirrors ) 2>&1 | \ + egrep -v 'bytes.*loss' | sort -n -k3 | \ + grep -v ': *-' | awk '/:/{print $1}' | head -5 | ( while read mainsite ; do + grep $mainsite $PREFDIR/mirrors ; done ) > bestsites + else + echo "(If you install 'netselect' or 'fping', it will select the best mirror for you" + echo " you may wish to stop this script and rerun after installation)" + sleep 3 + head -3 mirrors > bestsites + fi + fi +} + + + +INSTALL () { + filename="$3" + dir="$2" + url="$1" + + cd $CODECDIR/mplayer_binary_codecs + + if [ -r $filename ] ; then + cp $filename $filename.bak + fi + + if [ "$url" = @MAINSITE@ ] ; then + cat $PREFDIR/bestsites | while read mainsite ; do + echo Downloading $filename from $mainsite ... + wget -c -N $mainsite/$dir/$filename || true + if [ -r "$filename" ] ; then + UNPACK "$filename" + return 0 + fi + done + else + wget -c -N $url/$dir/$filename || true + if [ -r "$filename" ] ; then + UNPACK "$filename" + return 0 + fi + fi +} + + + + +UNPACK () +{ + filename="$1" + if [ -r $filename.bak ] && cmp $filename.bak $filename && [ -r $filename.list ] ; then + echo It appears that $filename was already succesfully installed + [ -r $filename.bak ] && rm $filename.bak + else + if grep -q " $filename$" $PREFDIR/MD5SUMS ; then + echo Checking MD5 for $filename + grep " $filename$" $PREFDIR/MD5SUMS | md5sum -c - + else + echo Warning: no MD5 for $filename were found. Hit enter to continue. + read dummy + fi + echo Installing $filename ... + if [ -r $filename.list ] ; then + tr '\n' '\000' < $filename.list | xargs -r0 rm || true + UNLINK $filename.list + rm $filename.list + fi + + tarfail () { echo FAILED $filename ; rm $filename.list ; exit 1 ; } + + case "$filename" in + *.tar.gz) + tar xvzf $filename > $filename.list || tarfail + #rm $filename + ;; + *.tgz) + tar xvzf $filename > $filename.list || tarfail + #rm $filename + ;; + *.tar.bz2) + tar --bzip2 -xvf $filename > $filename.list || tarfail + #rm $filename + ;; + esac + [ -r $filename.bak ] && rm $filename.bak + LINK $filename.list + echo "Installed $filename Succesfully!" + fi +} + +LINK () { + cd $CODECDIR/ + cat $CODECDIR/mplayer_binary_codecs/$1 | while read f ; do + ln -sbf mplayer_binary_codecs/"$f" . + done +} + +UNLINK () { +### FIXME +# cd $CODECDIR +# cat $CODECDIR/mplayer_binary_codecs/$1 | while f do +# ln -sbf mplayer_binary_codecs/"$f" +# done + if which symlinks > /dev/null ; then + symlinks -d $CODECDIR + fi +} + +if [ `whoami` != root ]; then + echo "You must be 'root' to use this script. Login as root first!" + exit 1 +fi + +case "$1" in + install) + if test -x /bin/bzip2 || test -x /usr/bin/bzip2 ; then : ; else + echo You need to install bzip2 + exit 1 + fi + choosemirror + cd $PREFDIR + #if [ ! -r codecs_list ] || find codecs_list -mtime +20 ; then + echo 'Getting codecs list ...' + wget -nv -N $MYSITE/codecs_list || true + #fi + + cd $PREFDIR + echo Downloading MD5 sums from main site + [ -r MD5SUMS ] && mv MD5SUMS MD5SUMS.bak + if wget -nv -N http://www.mplayerhq.hu/MPlayer/releases/codecs/MD5SUMS ; then + [ -r MD5SUMS.bak ] && rm MD5SUMS.bak + else + echo failed... + if [ -r MD5SUMS.bak ] ; then + echo trying to use backup ... ; + mv MD5SUMS.bak MD5SUMS + fi + fi + + if grep -q "^$dpkgarch" $PREFDIR/codecs_list ; then + egrep -v "^[[:space:]]*(#|$)" $PREFDIR/codecs_list | \ + while read arch url dir file info ; do + if [ "$dpkgarch" = "$arch" ]; then + echo Downloading and installing $file $info... + INSTALL "$url" "$dir" "$file" + fi + done + if test "$dpkgarch" = powerpc && ! test -r /usr/lib/libstdc++.so.5 ; then + echo 'Warning: you need to install libstdc++ 5 libraries' + echo -n 'Do it now? ' + read R + case $R in + y*) apt-get install libstdc++5 ;; + *) echo 'If you change your mind, use the command' + echo ' apt-get install libstdc++5' ;; + esac + fi + else + echo "Sorry, no codecs for your arch '$dpkgarch'. Sorry dude :(" + exit 1 + fi + ;; + + uninstall) + cd $CODECDIR/ + rm -rf mplayer_binary_codecs + #FIXME we need a better clean system + if which symlinks > /dev/null ; then + symlinks -d . + else + echo "please install the package 'symlinks' and run 'symlinks -d $CODECDIR' " + fi + echo "Uninstalled Succesfully!" + ;; + + *) + echo "Usage: {install|uninstall}" + echo "This program will install binary codecs for MPlayer." + exit 1 + ;; + +esac + + +exit 0 diff --git a/debian/templates b/debian/templates deleted file mode 100644 index 8fc8ca0..0000000 --- a/debian/templates +++ /dev/null @@ -1,26 +0,0 @@ -Template: mplayer/replace-existing-files -Type: boolean -Default: true -Description: Upgrade existing system? - It looks like you've configured MPlayer already. If you'd like to - configure it with this program, the old configuration - /etc/mplayer/mplayer.conf will be deleted. Do you want to continue - configuration with this program? If you say "Yes", your old - configuration will be deleted and you can create it anew with this - program. If you say "No" your existing files will be kept. If you - change your mind later, you can run 'dpkg-reconfigure mplayer'. - -Template: mplayer/ttfont -Type: select -Choices: ${ttfontchoices} -Default: ${ttfontdefault} -Description: MPlayer fonts - MPlayer can use TrueType fonts to render the OSD and subtitles. - Choose your favorite. - -Template: mplayer/no-ttfont -Type: note -Description: MPlayer cannot find TrueType fonts - You should install a package providing TrueType fonts (such as - 'ttf-freefont' or 'ttf-bitstream-vera' or 'msttcorefonts' ) - and reconfigure mplayer. diff --git a/debian/watch b/debian/watch deleted file mode 100644 index f02e397..0000000 --- a/debian/watch +++ /dev/null @@ -1,3 +0,0 @@ -# Site Directory Pattern Version Script -version=2 -http://www.mplayerhq.hu /MPlayer/releases/ MPlayer-(.*)\.tar\.bz2 debian uupdate diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c new file mode 100644 index 0000000..1fb057b --- /dev/null +++ b/libavcodec/allcodecs.c @@ -0,0 +1,335 @@ +/* + * Provides registration of all codecs, parsers and bitstream filters for libavcodec. + * Copyright (c) 2002 Fabrice Bellard + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file libavcodec/allcodecs.c + * Provides registration of all codecs, parsers and bitstream filters for libavcodec. + */ + +#include "avcodec.h" + +#define REGISTER_ENCODER(X,x) { \ + extern AVCodec x##_encoder; \ + if(CONFIG_##X##_ENCODER) register_avcodec(&x##_encoder); } +#define REGISTER_DECODER(X,x) { \ + extern AVCodec x##_decoder; \ + if(CONFIG_##X##_DECODER) register_avcodec(&x##_decoder); } +#define REGISTER_ENCDEC(X,x) REGISTER_ENCODER(X,x); REGISTER_DECODER(X,x) + +#define REGISTER_PARSER(X,x) { \ + extern AVCodecParser x##_parser; \ + if(CONFIG_##X##_PARSER) av_register_codec_parser(&x##_parser); } +#define REGISTER_BSF(X,x) { \ + extern AVBitStreamFilter x##_bsf; \ + if(CONFIG_##X##_BSF) av_register_bitstream_filter(&x##_bsf); } + +void avcodec_register_all(void) +{ + static int initialized; + + if (initialized) + return; + initialized = 1; + + /* video codecs */ + REGISTER_DECODER (AASC, aasc); + REGISTER_DECODER (AMV, amv); + REGISTER_ENCDEC (ASV1, asv1); + REGISTER_ENCDEC (ASV2, asv2); + REGISTER_DECODER (AVS, avs); + REGISTER_DECODER (BETHSOFTVID, bethsoftvid); + REGISTER_DECODER (BFI, bfi); + REGISTER_ENCDEC (BMP, bmp); + REGISTER_DECODER (C93, c93); + REGISTER_DECODER (CAVS, cavs); + REGISTER_DECODER (CINEPAK, cinepak); + REGISTER_DECODER (CLJR, cljr); + REGISTER_DECODER (CSCD, cscd); + REGISTER_DECODER (CYUV, cyuv); + REGISTER_ENCDEC (DNXHD, dnxhd); + REGISTER_DECODER (DSICINVIDEO, dsicinvideo); + REGISTER_ENCDEC (DVVIDEO, dvvideo); + REGISTER_DECODER (DXA, dxa); + REGISTER_DECODER (EACMV, eacmv); + REGISTER_DECODER (EATGQ, eatgq); + REGISTER_DECODER (EATGV, eatgv); + REGISTER_DECODER (EIGHTBPS, eightbps); + REGISTER_DECODER (EIGHTSVX_EXP, eightsvx_exp); + REGISTER_DECODER (EIGHTSVX_FIB, eightsvx_fib); + REGISTER_DECODER (ESCAPE124, escape124); + REGISTER_ENCDEC (FFV1, ffv1); + REGISTER_ENCDEC (FFVHUFF, ffvhuff); + REGISTER_ENCDEC (FLASHSV, flashsv); + REGISTER_DECODER (FLIC, flic); + REGISTER_ENCDEC (FLV, flv); + REGISTER_DECODER (FOURXM, fourxm); + REGISTER_DECODER (FRAPS, fraps); + REGISTER_ENCDEC (GIF, gif); + REGISTER_ENCDEC (H261, h261); + REGISTER_DECODER (H263, h263); + REGISTER_DECODER (H263I, h263i); + REGISTER_DECODER (H264, h264); + REGISTER_DECODER (H264_VDPAU, h264_vdpau); + REGISTER_ENCDEC (HUFFYUV, huffyuv); + REGISTER_DECODER (IDCIN, idcin); + REGISTER_DECODER (INDEO2, indeo2); + REGISTER_DECODER (INDEO3, indeo3); + REGISTER_DECODER (INTERPLAY_VIDEO, interplay_video); + REGISTER_ENCDEC (JPEGLS, jpegls); + REGISTER_DECODER (KMVC, kmvc); + REGISTER_ENCODER (LJPEG, ljpeg); + REGISTER_DECODER (LOCO, loco); + REGISTER_DECODER (MDEC, mdec); + REGISTER_DECODER (MIMIC, mimic); + REGISTER_ENCDEC (MJPEG, mjpeg); + REGISTER_DECODER (MJPEGB, mjpegb); + REGISTER_DECODER (MMVIDEO, mmvideo); + REGISTER_DECODER (MOTIONPIXELS, motionpixels); + REGISTER_DECODER (MPEG_XVMC, mpeg_xvmc); + REGISTER_ENCDEC (MPEG1VIDEO, mpeg1video); + REGISTER_DECODER (MPEG2VIDEO, mpeg2video); + REGISTER_DECODER (MPEG4, mpeg4); + REGISTER_DECODER (MPEGVIDEO, mpegvideo); + REGISTER_DECODER (MPEG_VDPAU, mpeg_vdpau); + REGISTER_DECODER (MPEG1_VDPAU, mpeg1_vdpau); + REGISTER_DECODER (MSMPEG4V1, msmpeg4v1); + REGISTER_DECODER (MSMPEG4V2, msmpeg4v2); + REGISTER_DECODER (MSMPEG4V3, msmpeg4v3); + REGISTER_DECODER (MSRLE, msrle); + REGISTER_DECODER (MSVIDEO1, msvideo1); + REGISTER_DECODER (MSZH, mszh); + REGISTER_DECODER (NUV, nuv); + REGISTER_ENCODER (PAM, pam); + REGISTER_ENCODER (PBM, pbm); + REGISTER_DECODER (PCX, pcx); + REGISTER_ENCODER (PGM, pgm); + REGISTER_ENCODER (PGMYUV, pgmyuv); + REGISTER_ENCDEC (PNG, png); + REGISTER_ENCODER (PPM, ppm); + REGISTER_DECODER (PTX, ptx); + REGISTER_DECODER (QDRAW, qdraw); + REGISTER_DECODER (QPEG, qpeg); + REGISTER_ENCDEC (QTRLE, qtrle); + REGISTER_ENCDEC (RAWVIDEO, rawvideo); + REGISTER_DECODER (RL2, rl2); + REGISTER_ENCDEC (ROQ, roq); + REGISTER_DECODER (RPZA, rpza); + REGISTER_ENCDEC (RV10, rv10); + REGISTER_ENCDEC (RV20, rv20); + REGISTER_DECODER (RV30, rv30); + REGISTER_DECODER (RV40, rv40); + REGISTER_ENCDEC (SGI, sgi); + REGISTER_DECODER (SMACKER, smacker); + REGISTER_DECODER (SMC, smc); + REGISTER_ENCDEC (SNOW, snow); + REGISTER_DECODER (SP5X, sp5x); + REGISTER_DECODER (SUNRAST, sunrast); + REGISTER_ENCDEC (SVQ1, svq1); + REGISTER_DECODER (SVQ3, svq3); + REGISTER_ENCDEC (TARGA, targa); + REGISTER_DECODER (THEORA, theora); + REGISTER_DECODER (THP, thp); + REGISTER_DECODER (TIERTEXSEQVIDEO, tiertexseqvideo); + REGISTER_ENCDEC (TIFF, tiff); + REGISTER_DECODER (TRUEMOTION1, truemotion1); + REGISTER_DECODER (TRUEMOTION2, truemotion2); + REGISTER_DECODER (TSCC, tscc); + REGISTER_DECODER (TXD, txd); + REGISTER_DECODER (ULTI, ulti); + REGISTER_DECODER (VB, vb); + REGISTER_DECODER (VC1, vc1); + REGISTER_DECODER (VC1_VDPAU, vc1_vdpau); + REGISTER_DECODER (VCR1, vcr1); + REGISTER_DECODER (VMDVIDEO, vmdvideo); + REGISTER_DECODER (VMNC, vmnc); + REGISTER_DECODER (VP3, vp3); + REGISTER_DECODER (VP5, vp5); + REGISTER_DECODER (VP6, vp6); + REGISTER_DECODER (VP6A, vp6a); + REGISTER_DECODER (VP6F, vp6f); + REGISTER_DECODER (VQA, vqa); + REGISTER_ENCDEC (WMV1, wmv1); + REGISTER_ENCDEC (WMV2, wmv2); + REGISTER_DECODER (WMV3, wmv3); + REGISTER_DECODER (WMV3_VDPAU, wmv3_vdpau); + REGISTER_DECODER (WNV1, wnv1); + REGISTER_DECODER (XAN_WC3, xan_wc3); + REGISTER_DECODER (XL, xl); + REGISTER_ENCDEC (ZLIB, zlib); + REGISTER_ENCDEC (ZMBV, zmbv); + + /* audio codecs */ + REGISTER_DECODER (AAC, aac); + REGISTER_ENCDEC (AC3, ac3); + REGISTER_ENCDEC (ALAC, alac); + REGISTER_DECODER (APE, ape); + REGISTER_DECODER (ATRAC3, atrac3); + REGISTER_DECODER (COOK, cook); + REGISTER_DECODER (DCA, dca); + REGISTER_DECODER (DSICINAUDIO, dsicinaudio); + REGISTER_DECODER (EAC3, eac3); + REGISTER_ENCDEC (FLAC, flac); + REGISTER_DECODER (IMC, imc); + REGISTER_DECODER (MACE3, mace3); + REGISTER_DECODER (MACE6, mace6); + REGISTER_DECODER (MLP, mlp); + REGISTER_DECODER (MP1, mp1); + REGISTER_ENCDEC (MP2, mp2); + REGISTER_DECODER (MP3, mp3); + REGISTER_DECODER (MP3ADU, mp3adu); + REGISTER_DECODER (MP3ON4, mp3on4); + REGISTER_DECODER (MPC7, mpc7); + REGISTER_DECODER (MPC8, mpc8); + REGISTER_ENCDEC (NELLYMOSER, nellymoser); + REGISTER_DECODER (QCELP, qcelp); + REGISTER_DECODER (QDM2, qdm2); + REGISTER_DECODER (RA_144, ra_144); + REGISTER_DECODER (RA_288, ra_288); + REGISTER_DECODER (SHORTEN, shorten); + REGISTER_DECODER (SMACKAUD, smackaud); + REGISTER_ENCDEC (SONIC, sonic); + REGISTER_ENCODER (SONIC_LS, sonic_ls); + REGISTER_DECODER (TRUESPEECH, truespeech); + REGISTER_DECODER (TTA, tta); + REGISTER_DECODER (VMDAUDIO, vmdaudio); + REGISTER_ENCDEC (VORBIS, vorbis); + REGISTER_DECODER (WAVPACK, wavpack); + REGISTER_ENCDEC (WMAV1, wmav1); + REGISTER_ENCDEC (WMAV2, wmav2); + REGISTER_DECODER (WS_SND1, ws_snd1); + + /* PCM codecs */ + REGISTER_ENCDEC (PCM_ALAW, pcm_alaw); + REGISTER_DECODER (PCM_DVD, pcm_dvd); + REGISTER_ENCDEC (PCM_F32BE, pcm_f32be); + REGISTER_ENCDEC (PCM_F32LE, pcm_f32le); + REGISTER_ENCDEC (PCM_F64BE, pcm_f64be); + REGISTER_ENCDEC (PCM_F64LE, pcm_f64le); + REGISTER_ENCDEC (PCM_MULAW, pcm_mulaw); + REGISTER_ENCDEC (PCM_S8, pcm_s8); + REGISTER_ENCDEC (PCM_S16BE, pcm_s16be); + REGISTER_ENCDEC (PCM_S16LE, pcm_s16le); + REGISTER_DECODER (PCM_S16LE_PLANAR, pcm_s16le_planar); + REGISTER_ENCDEC (PCM_S24BE, pcm_s24be); + REGISTER_ENCDEC (PCM_S24DAUD, pcm_s24daud); + REGISTER_ENCDEC (PCM_S24LE, pcm_s24le); + REGISTER_ENCDEC (PCM_S32BE, pcm_s32be); + REGISTER_ENCDEC (PCM_S32LE, pcm_s32le); + REGISTER_ENCDEC (PCM_U8, pcm_u8); + REGISTER_ENCDEC (PCM_U16BE, pcm_u16be); + REGISTER_ENCDEC (PCM_U16LE, pcm_u16le); + REGISTER_ENCDEC (PCM_U24BE, pcm_u24be); + REGISTER_ENCDEC (PCM_U24LE, pcm_u24le); + REGISTER_ENCDEC (PCM_U32BE, pcm_u32be); + REGISTER_ENCDEC (PCM_U32LE, pcm_u32le); + REGISTER_ENCDEC (PCM_ZORK , pcm_zork); + + /* DPCM codecs */ + REGISTER_DECODER (INTERPLAY_DPCM, interplay_dpcm); + REGISTER_ENCDEC (ROQ_DPCM, roq_dpcm); + REGISTER_DECODER (SOL_DPCM, sol_dpcm); + REGISTER_DECODER (XAN_DPCM, xan_dpcm); + + /* ADPCM codecs */ + REGISTER_DECODER (ADPCM_4XM, adpcm_4xm); + REGISTER_ENCDEC (ADPCM_ADX, adpcm_adx); + REGISTER_DECODER (ADPCM_CT, adpcm_ct); + REGISTER_DECODER (ADPCM_EA, adpcm_ea); + REGISTER_DECODER (ADPCM_EA_MAXIS_XA, adpcm_ea_maxis_xa); + REGISTER_DECODER (ADPCM_EA_R1, adpcm_ea_r1); + REGISTER_DECODER (ADPCM_EA_R2, adpcm_ea_r2); + REGISTER_DECODER (ADPCM_EA_R3, adpcm_ea_r3); + REGISTER_DECODER (ADPCM_EA_XAS, adpcm_ea_xas); + REGISTER_ENCDEC (ADPCM_G726, adpcm_g726); + REGISTER_DECODER (ADPCM_IMA_AMV, adpcm_ima_amv); + REGISTER_DECODER (ADPCM_IMA_DK3, adpcm_ima_dk3); + REGISTER_DECODER (ADPCM_IMA_DK4, adpcm_ima_dk4); + REGISTER_DECODER (ADPCM_IMA_EA_EACS, adpcm_ima_ea_eacs); + REGISTER_DECODER (ADPCM_IMA_EA_SEAD, adpcm_ima_ea_sead); + REGISTER_DECODER (ADPCM_IMA_ISS, adpcm_ima_iss); + REGISTER_ENCDEC (ADPCM_IMA_QT, adpcm_ima_qt); + REGISTER_DECODER (ADPCM_IMA_SMJPEG, adpcm_ima_smjpeg); + REGISTER_ENCDEC (ADPCM_IMA_WAV, adpcm_ima_wav); + REGISTER_DECODER (ADPCM_IMA_WS, adpcm_ima_ws); + REGISTER_ENCDEC (ADPCM_MS, adpcm_ms); + REGISTER_DECODER (ADPCM_SBPRO_2, adpcm_sbpro_2); + REGISTER_DECODER (ADPCM_SBPRO_3, adpcm_sbpro_3); + REGISTER_DECODER (ADPCM_SBPRO_4, adpcm_sbpro_4); + REGISTER_ENCDEC (ADPCM_SWF, adpcm_swf); + REGISTER_DECODER (ADPCM_THP, adpcm_thp); + REGISTER_DECODER (ADPCM_XA, adpcm_xa); + REGISTER_ENCDEC (ADPCM_YAMAHA, adpcm_yamaha); + + /* subtitles */ + REGISTER_ENCDEC (DVBSUB, dvbsub); + REGISTER_ENCDEC (DVDSUB, dvdsub); + REGISTER_DECODER (XSUB, xsub); + + /* external libraries */ + REGISTER_ENCDEC (LIBAMR_NB, libamr_nb); + REGISTER_ENCDEC (LIBAMR_WB, libamr_wb); + REGISTER_ENCDEC (LIBDIRAC, libdirac); + REGISTER_ENCODER (LIBFAAC, libfaac); + REGISTER_DECODER (LIBFAAD, libfaad); + REGISTER_ENCDEC (LIBGSM, libgsm); + REGISTER_ENCDEC (LIBGSM_MS, libgsm_ms); + REGISTER_ENCODER (LIBMP3LAME, libmp3lame); + REGISTER_ENCDEC (LIBSCHROEDINGER, libschroedinger); + REGISTER_DECODER (LIBSPEEX, libspeex); + REGISTER_ENCODER (LIBTHEORA, libtheora); + REGISTER_ENCODER (LIBVORBIS, libvorbis); + REGISTER_ENCODER (LIBX264, libx264); + REGISTER_ENCODER (LIBXVID, libxvid); + + /* parsers */ + REGISTER_PARSER (AAC, aac); + REGISTER_PARSER (AC3, ac3); + REGISTER_PARSER (CAVSVIDEO, cavsvideo); + REGISTER_PARSER (DCA, dca); + REGISTER_PARSER (DIRAC, dirac); + REGISTER_PARSER (DNXHD, dnxhd); + REGISTER_PARSER (DVBSUB, dvbsub); + REGISTER_PARSER (DVDSUB, dvdsub); + REGISTER_PARSER (H261, h261); + REGISTER_PARSER (H263, h263); + REGISTER_PARSER (H264, h264); + REGISTER_PARSER (MJPEG, mjpeg); + REGISTER_PARSER (MLP, mlp); + REGISTER_PARSER (MPEG4VIDEO, mpeg4video); + REGISTER_PARSER (MPEGAUDIO, mpegaudio); + REGISTER_PARSER (MPEGVIDEO, mpegvideo); + REGISTER_PARSER (PNM, pnm); + REGISTER_PARSER (VC1, vc1); + REGISTER_PARSER (VP3, vp3); + + /* bitstream filters */ + REGISTER_BSF (DUMP_EXTRADATA, dump_extradata); + REGISTER_BSF (H264_MP4TOANNEXB, h264_mp4toannexb); + REGISTER_BSF (IMX_DUMP_HEADER, imx_dump_header); + REGISTER_BSF (MJPEGA_DUMP_HEADER, mjpega_dump_header); + REGISTER_BSF (MP3_HEADER_COMPRESS, mp3_header_compress); + REGISTER_BSF (MP3_HEADER_DECOMPRESS, mp3_header_decompress); + REGISTER_BSF (MOV2TEXTSUB, mov2textsub); + REGISTER_BSF (NOISE, noise); + REGISTER_BSF (REMOVE_EXTRADATA, remove_extradata); + REGISTER_BSF (TEXT2MOVSUB, text2movsub); +} + diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h new file mode 100644 index 0000000..b078bc9 --- /dev/null +++ b/libavcodec/avcodec.h @@ -0,0 +1,3347 @@ +/* + * copyright (c) 2001 Fabrice Bellard + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_AVCODEC_H +#define AVCODEC_AVCODEC_H + +/** + * @file libavcodec/avcodec.h + * external API header + */ + +#include +#include "libavutil/avutil.h" + +#define LIBAVCODEC_VERSION_MAJOR 52 +#define LIBAVCODEC_VERSION_MINOR 20 +#define LIBAVCODEC_VERSION_MICRO 0 + +#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ + LIBAVCODEC_VERSION_MINOR, \ + LIBAVCODEC_VERSION_MICRO) +#define LIBAVCODEC_VERSION AV_VERSION(LIBAVCODEC_VERSION_MAJOR, \ + LIBAVCODEC_VERSION_MINOR, \ + LIBAVCODEC_VERSION_MICRO) +#define LIBAVCODEC_BUILD LIBAVCODEC_VERSION_INT + +#define LIBAVCODEC_IDENT "Lavc" AV_STRINGIFY(LIBAVCODEC_VERSION) + +#define AV_NOPTS_VALUE INT64_C(0x8000000000000000) +#define AV_TIME_BASE 1000000 +#define AV_TIME_BASE_Q (AVRational){1, AV_TIME_BASE} + +/** + * Identifies the syntax and semantics of the bitstream. + * The principle is roughly: + * Two decoders with the same ID can decode the same streams. + * Two encoders with the same ID can encode compatible streams. + * There may be slight deviations from the principle due to implementation + * details. + * + * If you add a codec ID to this list, add it so that + * 1. no value of a existing codec ID changes (that would break ABI), + * 2. it is as close as possible to similar codecs. + */ +enum CodecID { + CODEC_ID_NONE, + + /* video codecs */ + CODEC_ID_MPEG1VIDEO, + CODEC_ID_MPEG2VIDEO, ///< preferred ID for MPEG-1/2 video decoding + CODEC_ID_MPEG2VIDEO_XVMC, + CODEC_ID_H261, + CODEC_ID_H263, + CODEC_ID_RV10, + CODEC_ID_RV20, + CODEC_ID_MJPEG, + CODEC_ID_MJPEGB, + CODEC_ID_LJPEG, + CODEC_ID_SP5X, + CODEC_ID_JPEGLS, + CODEC_ID_MPEG4, + CODEC_ID_RAWVIDEO, + CODEC_ID_MSMPEG4V1, + CODEC_ID_MSMPEG4V2, + CODEC_ID_MSMPEG4V3, + CODEC_ID_WMV1, + CODEC_ID_WMV2, + CODEC_ID_H263P, + CODEC_ID_H263I, + CODEC_ID_FLV1, + CODEC_ID_SVQ1, + CODEC_ID_SVQ3, + CODEC_ID_DVVIDEO, + CODEC_ID_HUFFYUV, + CODEC_ID_CYUV, + CODEC_ID_H264, + CODEC_ID_INDEO3, + CODEC_ID_VP3, + CODEC_ID_THEORA, + CODEC_ID_ASV1, + CODEC_ID_ASV2, + CODEC_ID_FFV1, + CODEC_ID_4XM, + CODEC_ID_VCR1, + CODEC_ID_CLJR, + CODEC_ID_MDEC, + CODEC_ID_ROQ, + CODEC_ID_INTERPLAY_VIDEO, + CODEC_ID_XAN_WC3, + CODEC_ID_XAN_WC4, + CODEC_ID_RPZA, + CODEC_ID_CINEPAK, + CODEC_ID_WS_VQA, + CODEC_ID_MSRLE, + CODEC_ID_MSVIDEO1, + CODEC_ID_IDCIN, + CODEC_ID_8BPS, + CODEC_ID_SMC, + CODEC_ID_FLIC, + CODEC_ID_TRUEMOTION1, + CODEC_ID_VMDVIDEO, + CODEC_ID_MSZH, + CODEC_ID_ZLIB, + CODEC_ID_QTRLE, + CODEC_ID_SNOW, + CODEC_ID_TSCC, + CODEC_ID_ULTI, + CODEC_ID_QDRAW, + CODEC_ID_VIXL, + CODEC_ID_QPEG, + CODEC_ID_XVID, + CODEC_ID_PNG, + CODEC_ID_PPM, + CODEC_ID_PBM, + CODEC_ID_PGM, + CODEC_ID_PGMYUV, + CODEC_ID_PAM, + CODEC_ID_FFVHUFF, + CODEC_ID_RV30, + CODEC_ID_RV40, + CODEC_ID_VC1, + CODEC_ID_WMV3, + CODEC_ID_LOCO, + CODEC_ID_WNV1, + CODEC_ID_AASC, + CODEC_ID_INDEO2, + CODEC_ID_FRAPS, + CODEC_ID_TRUEMOTION2, + CODEC_ID_BMP, + CODEC_ID_CSCD, + CODEC_ID_MMVIDEO, + CODEC_ID_ZMBV, + CODEC_ID_AVS, + CODEC_ID_SMACKVIDEO, + CODEC_ID_NUV, + CODEC_ID_KMVC, + CODEC_ID_FLASHSV, + CODEC_ID_CAVS, + CODEC_ID_JPEG2000, + CODEC_ID_VMNC, + CODEC_ID_VP5, + CODEC_ID_VP6, + CODEC_ID_VP6F, + CODEC_ID_TARGA, + CODEC_ID_DSICINVIDEO, + CODEC_ID_TIERTEXSEQVIDEO, + CODEC_ID_TIFF, + CODEC_ID_GIF, + CODEC_ID_FFH264, + CODEC_ID_DXA, + CODEC_ID_DNXHD, + CODEC_ID_THP, + CODEC_ID_SGI, + CODEC_ID_C93, + CODEC_ID_BETHSOFTVID, + CODEC_ID_PTX, + CODEC_ID_TXD, + CODEC_ID_VP6A, + CODEC_ID_AMV, + CODEC_ID_VB, + CODEC_ID_PCX, + CODEC_ID_SUNRAST, + CODEC_ID_INDEO4, + CODEC_ID_INDEO5, + CODEC_ID_MIMIC, + CODEC_ID_RL2, + CODEC_ID_8SVX_EXP, + CODEC_ID_8SVX_FIB, + CODEC_ID_ESCAPE124, + CODEC_ID_DIRAC, + CODEC_ID_BFI, + CODEC_ID_CMV, + CODEC_ID_MOTIONPIXELS, + CODEC_ID_TGV, + CODEC_ID_TGQ, + CODEC_ID_TQI, + + /* various PCM "codecs" */ + CODEC_ID_PCM_S16LE= 0x10000, + CODEC_ID_PCM_S16BE, + CODEC_ID_PCM_U16LE, + CODEC_ID_PCM_U16BE, + CODEC_ID_PCM_S8, + CODEC_ID_PCM_U8, + CODEC_ID_PCM_MULAW, + CODEC_ID_PCM_ALAW, + CODEC_ID_PCM_S32LE, + CODEC_ID_PCM_S32BE, + CODEC_ID_PCM_U32LE, + CODEC_ID_PCM_U32BE, + CODEC_ID_PCM_S24LE, + CODEC_ID_PCM_S24BE, + CODEC_ID_PCM_U24LE, + CODEC_ID_PCM_U24BE, + CODEC_ID_PCM_S24DAUD, + CODEC_ID_PCM_ZORK, + CODEC_ID_PCM_S16LE_PLANAR, + CODEC_ID_PCM_DVD, + CODEC_ID_PCM_F32BE, + CODEC_ID_PCM_F32LE, + CODEC_ID_PCM_F64BE, + CODEC_ID_PCM_F64LE, + + /* various ADPCM codecs */ + CODEC_ID_ADPCM_IMA_QT= 0x11000, + CODEC_ID_ADPCM_IMA_WAV, + CODEC_ID_ADPCM_IMA_DK3, + CODEC_ID_ADPCM_IMA_DK4, + CODEC_ID_ADPCM_IMA_WS, + CODEC_ID_ADPCM_IMA_SMJPEG, + CODEC_ID_ADPCM_MS, + CODEC_ID_ADPCM_4XM, + CODEC_ID_ADPCM_XA, + CODEC_ID_ADPCM_ADX, + CODEC_ID_ADPCM_EA, + CODEC_ID_ADPCM_G726, + CODEC_ID_ADPCM_CT, + CODEC_ID_ADPCM_SWF, + CODEC_ID_ADPCM_YAMAHA, + CODEC_ID_ADPCM_SBPRO_4, + CODEC_ID_ADPCM_SBPRO_3, + CODEC_ID_ADPCM_SBPRO_2, + CODEC_ID_ADPCM_THP, + CODEC_ID_ADPCM_IMA_AMV, + CODEC_ID_ADPCM_EA_R1, + CODEC_ID_ADPCM_EA_R3, + CODEC_ID_ADPCM_EA_R2, + CODEC_ID_ADPCM_IMA_EA_SEAD, + CODEC_ID_ADPCM_IMA_EA_EACS, + CODEC_ID_ADPCM_EA_XAS, + CODEC_ID_ADPCM_EA_MAXIS_XA, + CODEC_ID_ADPCM_IMA_ISS, + + /* AMR */ + CODEC_ID_AMR_NB= 0x12000, + CODEC_ID_AMR_WB, + + /* RealAudio codecs*/ + CODEC_ID_RA_144= 0x13000, + CODEC_ID_RA_288, + + /* various DPCM codecs */ + CODEC_ID_ROQ_DPCM= 0x14000, + CODEC_ID_INTERPLAY_DPCM, + CODEC_ID_XAN_DPCM, + CODEC_ID_SOL_DPCM, + + /* audio codecs */ + CODEC_ID_MP2= 0x15000, + CODEC_ID_MP3, ///< preferred ID for decoding MPEG audio layer 1, 2 or 3 + CODEC_ID_AAC, + CODEC_ID_AC3, + CODEC_ID_DTS, + CODEC_ID_VORBIS, + CODEC_ID_DVAUDIO, + CODEC_ID_WMAV1, + CODEC_ID_WMAV2, + CODEC_ID_MACE3, + CODEC_ID_MACE6, + CODEC_ID_VMDAUDIO, + CODEC_ID_SONIC, + CODEC_ID_SONIC_LS, + CODEC_ID_FLAC, + CODEC_ID_MP3ADU, + CODEC_ID_MP3ON4, + CODEC_ID_SHORTEN, + CODEC_ID_ALAC, + CODEC_ID_WESTWOOD_SND1, + CODEC_ID_GSM, ///< as in Berlin toast format + CODEC_ID_QDM2, + CODEC_ID_COOK, + CODEC_ID_TRUESPEECH, + CODEC_ID_TTA, + CODEC_ID_SMACKAUDIO, + CODEC_ID_QCELP, + CODEC_ID_WAVPACK, + CODEC_ID_DSICINAUDIO, + CODEC_ID_IMC, + CODEC_ID_MUSEPACK7, + CODEC_ID_MLP, + CODEC_ID_GSM_MS, /* as found in WAV */ + CODEC_ID_ATRAC3, + CODEC_ID_VOXWARE, + CODEC_ID_APE, + CODEC_ID_NELLYMOSER, + CODEC_ID_MUSEPACK8, + CODEC_ID_SPEEX, + CODEC_ID_WMAVOICE, + CODEC_ID_WMAPRO, + CODEC_ID_WMALOSSLESS, + CODEC_ID_ATRAC3P, + CODEC_ID_EAC3, + CODEC_ID_SIPR, + CODEC_ID_MP1, + + /* subtitle codecs */ + CODEC_ID_DVD_SUBTITLE= 0x17000, + CODEC_ID_DVB_SUBTITLE, + CODEC_ID_TEXT, ///< raw UTF-8 text + CODEC_ID_XSUB, + CODEC_ID_SSA, + CODEC_ID_MOV_TEXT, + + /* other specific kind of codecs (generally used for attachments) */ + CODEC_ID_TTF= 0x18000, + + CODEC_ID_PROBE= 0x19000, ///< codec_id is not known (like CODEC_ID_NONE) but lavf should attempt to identify it + + CODEC_ID_MPEG2TS= 0x20000, /**< _FAKE_ codec to indicate a raw MPEG-2 TS + * stream (only used by libavformat) */ +}; + +enum CodecType { + CODEC_TYPE_UNKNOWN = -1, + CODEC_TYPE_VIDEO, + CODEC_TYPE_AUDIO, + CODEC_TYPE_DATA, + CODEC_TYPE_SUBTITLE, + CODEC_TYPE_ATTACHMENT, + CODEC_TYPE_NB +}; + +/** + * all in native-endian format + */ +enum SampleFormat { + SAMPLE_FMT_NONE = -1, + SAMPLE_FMT_U8, ///< unsigned 8 bits + SAMPLE_FMT_S16, ///< signed 16 bits + SAMPLE_FMT_S32, ///< signed 32 bits + SAMPLE_FMT_FLT, ///< float + SAMPLE_FMT_DBL, ///< double + SAMPLE_FMT_NB ///< Number of sample formats. DO NOT USE if dynamically linking to libavcodec +}; + +/* Audio channel masks */ +#define CH_FRONT_LEFT 0x00000001 +#define CH_FRONT_RIGHT 0x00000002 +#define CH_FRONT_CENTER 0x00000004 +#define CH_LOW_FREQUENCY 0x00000008 +#define CH_BACK_LEFT 0x00000010 +#define CH_BACK_RIGHT 0x00000020 +#define CH_FRONT_LEFT_OF_CENTER 0x00000040 +#define CH_FRONT_RIGHT_OF_CENTER 0x00000080 +#define CH_BACK_CENTER 0x00000100 +#define CH_SIDE_LEFT 0x00000200 +#define CH_SIDE_RIGHT 0x00000400 +#define CH_TOP_CENTER 0x00000800 +#define CH_TOP_FRONT_LEFT 0x00001000 +#define CH_TOP_FRONT_CENTER 0x00002000 +#define CH_TOP_FRONT_RIGHT 0x00004000 +#define CH_TOP_BACK_LEFT 0x00008000 +#define CH_TOP_BACK_CENTER 0x00010000 +#define CH_TOP_BACK_RIGHT 0x00020000 +#define CH_STEREO_LEFT 0x20000000 ///< Stereo downmix. +#define CH_STEREO_RIGHT 0x40000000 ///< See CH_STEREO_LEFT. + +/* Audio channel convenience macros */ +#define CH_LAYOUT_MONO (CH_FRONT_CENTER) +#define CH_LAYOUT_STEREO (CH_FRONT_LEFT|CH_FRONT_RIGHT) +#define CH_LAYOUT_SURROUND (CH_LAYOUT_STEREO|CH_FRONT_CENTER) +#define CH_LAYOUT_QUAD (CH_LAYOUT_STEREO|CH_BACK_LEFT|CH_BACK_RIGHT) +#define CH_LAYOUT_5POINT0 (CH_LAYOUT_SURROUND|CH_SIDE_LEFT|CH_SIDE_RIGHT) +#define CH_LAYOUT_5POINT1 (CH_LAYOUT_5POINT0|CH_LOW_FREQUENCY) +#define CH_LAYOUT_7POINT1 (CH_LAYOUT_5POINT1|CH_BACK_LEFT|CH_BACK_RIGHT) +#define CH_LAYOUT_7POINT1_WIDE (CH_LAYOUT_SURROUND|CH_LOW_FREQUENCY|\ + CH_BACK_LEFT|CH_BACK_RIGHT|\ + CH_FRONT_LEFT_OF_CENTER|CH_FRONT_RIGHT_OF_CENTER) +#define CH_LAYOUT_STEREO_DOWNMIX (CH_STEREO_LEFT|CH_STEREO_RIGHT) + +/* in bytes */ +#define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000 // 1 second of 48khz 32bit audio + +/** + * Required number of additionally allocated bytes at the end of the input bitstream for decoding. + * This is mainly needed because some optimized bitstream readers read + * 32 or 64 bit at once and could read over the end.
+ * Note: If the first 23 bits of the additional bytes are not 0, then damaged + * MPEG bitstreams could cause overread and segfault. + */ +#define FF_INPUT_BUFFER_PADDING_SIZE 8 + +/** + * minimum encoding buffer size + * Used to avoid some checks during header writing. + */ +#define FF_MIN_BUFFER_SIZE 16384 + + +/** + * motion estimation type. + */ +enum Motion_Est_ID { + ME_ZERO = 1, ///< no search, that is use 0,0 vector whenever one is needed + ME_FULL, + ME_LOG, + ME_PHODS, + ME_EPZS, ///< enhanced predictive zonal search + ME_X1, ///< reserved for experiments + ME_HEX, ///< hexagon based search + ME_UMH, ///< uneven multi-hexagon search + ME_ITER, ///< iterative search + ME_TESA, ///< transformed exhaustive search algorithm +}; + +enum AVDiscard{ + /* We leave some space between them for extensions (drop some + * keyframes for intra-only or drop just some bidir frames). */ + AVDISCARD_NONE =-16, ///< discard nothing + AVDISCARD_DEFAULT= 0, ///< discard useless packets like 0 size packets in avi + AVDISCARD_NONREF = 8, ///< discard all non reference + AVDISCARD_BIDIR = 16, ///< discard all bidirectional frames + AVDISCARD_NONKEY = 32, ///< discard all frames except keyframes + AVDISCARD_ALL = 48, ///< discard all +}; + +typedef struct RcOverride{ + int start_frame; + int end_frame; + int qscale; // If this is 0 then quality_factor will be used instead. + float quality_factor; +} RcOverride; + +#define FF_MAX_B_FRAMES 16 + +/* encoding support + These flags can be passed in AVCodecContext.flags before initialization. + Note: Not everything is supported yet. +*/ + +#define CODEC_FLAG_QSCALE 0x0002 ///< Use fixed qscale. +#define CODEC_FLAG_4MV 0x0004 ///< 4 MV per MB allowed / advanced prediction for H.263. +#define CODEC_FLAG_QPEL 0x0010 ///< Use qpel MC. +#define CODEC_FLAG_GMC 0x0020 ///< Use GMC. +#define CODEC_FLAG_MV0 0x0040 ///< Always try a MB with MV=<0,0>. +#define CODEC_FLAG_PART 0x0080 ///< Use data partitioning. +/** + * The parent program guarantees that the input for B-frames containing + * streams is not written to for at least s->max_b_frames+1 frames, if + * this is not set the input will be copied. + */ +#define CODEC_FLAG_INPUT_PRESERVED 0x0100 +#define CODEC_FLAG_PASS1 0x0200 ///< Use internal 2pass ratecontrol in first pass mode. +#define CODEC_FLAG_PASS2 0x0400 ///< Use internal 2pass ratecontrol in second pass mode. +#define CODEC_FLAG_EXTERN_HUFF 0x1000 ///< Use external Huffman table (for MJPEG). +#define CODEC_FLAG_GRAY 0x2000 ///< Only decode/encode grayscale. +#define CODEC_FLAG_EMU_EDGE 0x4000 ///< Don't draw edges. +#define CODEC_FLAG_PSNR 0x8000 ///< error[?] variables will be set during encoding. +#define CODEC_FLAG_TRUNCATED 0x00010000 /** Input bitstream might be truncated at a random + location instead of only at frame boundaries. */ +#define CODEC_FLAG_NORMALIZE_AQP 0x00020000 ///< Normalize adaptive quantization. +#define CODEC_FLAG_INTERLACED_DCT 0x00040000 ///< Use interlaced DCT. +#define CODEC_FLAG_LOW_DELAY 0x00080000 ///< Force low delay. +#define CODEC_FLAG_ALT_SCAN 0x00100000 ///< Use alternate scan. +#define CODEC_FLAG_GLOBAL_HEADER 0x00400000 ///< Place global headers in extradata instead of every keyframe. +#define CODEC_FLAG_BITEXACT 0x00800000 ///< Use only bitexact stuff (except (I)DCT). +/* Fx : Flag for h263+ extra options */ +#define CODEC_FLAG_AC_PRED 0x01000000 ///< H.263 advanced intra coding / MPEG-4 AC prediction +#define CODEC_FLAG_H263P_UMV 0x02000000 ///< unlimited motion vector +#define CODEC_FLAG_CBP_RD 0x04000000 ///< Use rate distortion optimization for cbp. +#define CODEC_FLAG_QP_RD 0x08000000 ///< Use rate distortion optimization for qp selectioon. +#define CODEC_FLAG_H263P_AIV 0x00000008 ///< H.263 alternative inter VLC +#define CODEC_FLAG_OBMC 0x00000001 ///< OBMC +#define CODEC_FLAG_LOOP_FILTER 0x00000800 ///< loop filter +#define CODEC_FLAG_H263P_SLICE_STRUCT 0x10000000 +#define CODEC_FLAG_INTERLACED_ME 0x20000000 ///< interlaced motion estimation +#define CODEC_FLAG_SVCD_SCAN_OFFSET 0x40000000 ///< Will reserve space for SVCD scan offset user data. +#define CODEC_FLAG_CLOSED_GOP 0x80000000 +#define CODEC_FLAG2_FAST 0x00000001 ///< Allow non spec compliant speedup tricks. +#define CODEC_FLAG2_STRICT_GOP 0x00000002 ///< Strictly enforce GOP size. +#define CODEC_FLAG2_NO_OUTPUT 0x00000004 ///< Skip bitstream encoding. +#define CODEC_FLAG2_LOCAL_HEADER 0x00000008 ///< Place global headers at every keyframe instead of in extradata. +#define CODEC_FLAG2_BPYRAMID 0x00000010 ///< H.264 allow B-frames to be used as references. +#define CODEC_FLAG2_WPRED 0x00000020 ///< H.264 weighted biprediction for B-frames +#define CODEC_FLAG2_MIXED_REFS 0x00000040 ///< H.264 one reference per partition, as opposed to one reference per macroblock +#define CODEC_FLAG2_8X8DCT 0x00000080 ///< H.264 high profile 8x8 transform +#define CODEC_FLAG2_FASTPSKIP 0x00000100 ///< H.264 fast pskip +#define CODEC_FLAG2_AUD 0x00000200 ///< H.264 access unit delimiters +#define CODEC_FLAG2_BRDO 0x00000400 ///< B-frame rate-distortion optimization +#define CODEC_FLAG2_INTRA_VLC 0x00000800 ///< Use MPEG-2 intra VLC table. +#define CODEC_FLAG2_MEMC_ONLY 0x00001000 ///< Only do ME/MC (I frames -> ref, P frame -> ME+MC). +#define CODEC_FLAG2_DROP_FRAME_TIMECODE 0x00002000 ///< timecode is in drop frame format. +#define CODEC_FLAG2_SKIP_RD 0x00004000 ///< RD optimal MB level residual skipping +#define CODEC_FLAG2_CHUNKS 0x00008000 ///< Input bitstream might be truncated at a packet boundaries instead of only at frame boundaries. +#define CODEC_FLAG2_NON_LINEAR_QUANT 0x00010000 ///< Use MPEG-2 nonlinear quantizer. +#define CODEC_FLAG2_BIT_RESERVOIR 0x00020000 ///< Use a bit reservoir when encoding if possible + +/* Unsupported options : + * Syntax Arithmetic coding (SAC) + * Reference Picture Selection + * Independent Segment Decoding */ +/* /Fx */ +/* codec capabilities */ + +#define CODEC_CAP_DRAW_HORIZ_BAND 0x0001 ///< Decoder can use draw_horiz_band callback. +/** + * Codec uses get_buffer() for allocating buffers. + * direct rendering method 1 + */ +#define CODEC_CAP_DR1 0x0002 +/* If 'parse_only' field is true, then avcodec_parse_frame() can be used. */ +#define CODEC_CAP_PARSE_ONLY 0x0004 +#define CODEC_CAP_TRUNCATED 0x0008 +/* Codec can export data for HW decoding (XvMC). */ +#define CODEC_CAP_HWACCEL 0x0010 +/** + * Codec has a nonzero delay and needs to be fed with NULL at the end to get the delayed data. + * If this is not set, the codec is guaranteed to never be fed with NULL data. + */ +#define CODEC_CAP_DELAY 0x0020 +/** + * Codec can be fed a final frame with a smaller size. + * This can be used to prevent truncation of the last audio samples. + */ +#define CODEC_CAP_SMALL_LAST_FRAME 0x0040 +/** + * Codec can export data for HW decoding (VDPAU). + */ +#define CODEC_CAP_HWACCEL_VDPAU 0x0080 + +//The following defines may change, don't expect compatibility if you use them. +#define MB_TYPE_INTRA4x4 0x0001 +#define MB_TYPE_INTRA16x16 0x0002 //FIXME H.264-specific +#define MB_TYPE_INTRA_PCM 0x0004 //FIXME H.264-specific +#define MB_TYPE_16x16 0x0008 +#define MB_TYPE_16x8 0x0010 +#define MB_TYPE_8x16 0x0020 +#define MB_TYPE_8x8 0x0040 +#define MB_TYPE_INTERLACED 0x0080 +#define MB_TYPE_DIRECT2 0x0100 //FIXME +#define MB_TYPE_ACPRED 0x0200 +#define MB_TYPE_GMC 0x0400 +#define MB_TYPE_SKIP 0x0800 +#define MB_TYPE_P0L0 0x1000 +#define MB_TYPE_P1L0 0x2000 +#define MB_TYPE_P0L1 0x4000 +#define MB_TYPE_P1L1 0x8000 +#define MB_TYPE_L0 (MB_TYPE_P0L0 | MB_TYPE_P1L0) +#define MB_TYPE_L1 (MB_TYPE_P0L1 | MB_TYPE_P1L1) +#define MB_TYPE_L0L1 (MB_TYPE_L0 | MB_TYPE_L1) +#define MB_TYPE_QUANT 0x00010000 +#define MB_TYPE_CBP 0x00020000 +//Note bits 24-31 are reserved for codec specific use (h264 ref0, mpeg1 0mv, ...) + +/** + * Pan Scan area. + * This specifies the area which should be displayed. + * Note there may be multiple such areas for one frame. + */ +typedef struct AVPanScan{ + /** + * id + * - encoding: Set by user. + * - decoding: Set by libavcodec. + */ + int id; + + /** + * width and height in 1/16 pel + * - encoding: Set by user. + * - decoding: Set by libavcodec. + */ + int width; + int height; + + /** + * position of the top left corner in 1/16 pel for up to 3 fields/frames + * - encoding: Set by user. + * - decoding: Set by libavcodec. + */ + int16_t position[3][2]; +}AVPanScan; + +#define FF_COMMON_FRAME \ + /**\ + * pointer to the picture planes.\ + * This might be different from the first allocated byte\ + * - encoding: \ + * - decoding: \ + */\ + uint8_t *data[4];\ + int linesize[4];\ + /**\ + * pointer to the first allocated byte of the picture. Can be used in get_buffer/release_buffer.\ + * This isn't used by libavcodec unless the default get/release_buffer() is used.\ + * - encoding: \ + * - decoding: \ + */\ + uint8_t *base[4];\ + /**\ + * 1 -> keyframe, 0-> not\ + * - encoding: Set by libavcodec.\ + * - decoding: Set by libavcodec.\ + */\ + int key_frame;\ +\ + /**\ + * Picture type of the frame, see ?_TYPE below.\ + * - encoding: Set by libavcodec. for coded_picture (and set by user for input).\ + * - decoding: Set by libavcodec.\ + */\ + int pict_type;\ +\ + /**\ + * presentation timestamp in time_base units (time when frame should be shown to user)\ + * If AV_NOPTS_VALUE then frame_rate = 1/time_base will be assumed.\ + * - encoding: MUST be set by user.\ + * - decoding: Set by libavcodec.\ + */\ + int64_t pts;\ +\ + /**\ + * picture number in bitstream order\ + * - encoding: set by\ + * - decoding: Set by libavcodec.\ + */\ + int coded_picture_number;\ + /**\ + * picture number in display order\ + * - encoding: set by\ + * - decoding: Set by libavcodec.\ + */\ + int display_picture_number;\ +\ + /**\ + * quality (between 1 (good) and FF_LAMBDA_MAX (bad)) \ + * - encoding: Set by libavcodec. for coded_picture (and set by user for input).\ + * - decoding: Set by libavcodec.\ + */\ + int quality; \ +\ + /**\ + * buffer age (1->was last buffer and dint change, 2->..., ...).\ + * Set to INT_MAX if the buffer has not been used yet.\ + * - encoding: unused\ + * - decoding: MUST be set by get_buffer().\ + */\ + int age;\ +\ + /**\ + * is this picture used as reference\ + * The values for this are the same as the MpegEncContext.picture_structure\ + * variable, that is 1->top field, 2->bottom field, 3->frame/both fields.\ + * Set to 4 for delayed, non-reference frames.\ + * - encoding: unused\ + * - decoding: Set by libavcodec. (before get_buffer() call)).\ + */\ + int reference;\ +\ + /**\ + * QP table\ + * - encoding: unused\ + * - decoding: Set by libavcodec.\ + */\ + int8_t *qscale_table;\ + /**\ + * QP store stride\ + * - encoding: unused\ + * - decoding: Set by libavcodec.\ + */\ + int qstride;\ +\ + /**\ + * mbskip_table[mb]>=1 if MB didn't change\ + * stride= mb_width = (width+15)>>4\ + * - encoding: unused\ + * - decoding: Set by libavcodec.\ + */\ + uint8_t *mbskip_table;\ +\ + /**\ + * motion vector table\ + * @code\ + * example:\ + * int mv_sample_log2= 4 - motion_subsample_log2;\ + * int mb_width= (width+15)>>4;\ + * int mv_stride= (mb_width << mv_sample_log2) + 1;\ + * motion_val[direction][x + y*mv_stride][0->mv_x, 1->mv_y];\ + * @endcode\ + * - encoding: Set by user.\ + * - decoding: Set by libavcodec.\ + */\ + int16_t (*motion_val[2])[2];\ +\ + /**\ + * macroblock type table\ + * mb_type_base + mb_width + 2\ + * - encoding: Set by user.\ + * - decoding: Set by libavcodec.\ + */\ + uint32_t *mb_type;\ +\ + /**\ + * log2 of the size of the block which a single vector in motion_val represents: \ + * (4->16x16, 3->8x8, 2-> 4x4, 1-> 2x2)\ + * - encoding: unused\ + * - decoding: Set by libavcodec.\ + */\ + uint8_t motion_subsample_log2;\ +\ + /**\ + * for some private data of the user\ + * - encoding: unused\ + * - decoding: Set by user.\ + */\ + void *opaque;\ +\ + /**\ + * error\ + * - encoding: Set by libavcodec. if flags&CODEC_FLAG_PSNR.\ + * - decoding: unused\ + */\ + uint64_t error[4];\ +\ + /**\ + * type of the buffer (to keep track of who has to deallocate data[*])\ + * - encoding: Set by the one who allocates it.\ + * - decoding: Set by the one who allocates it.\ + * Note: User allocated (direct rendering) & internal buffers cannot coexist currently.\ + */\ + int type;\ + \ + /**\ + * When decoding, this signals how much the picture must be delayed.\ + * extra_delay = repeat_pict / (2*fps)\ + * - encoding: unused\ + * - decoding: Set by libavcodec.\ + */\ + int repeat_pict;\ + \ + /**\ + * \ + */\ + int qscale_type;\ + \ + /**\ + * The content of the picture is interlaced.\ + * - encoding: Set by user.\ + * - decoding: Set by libavcodec. (default 0)\ + */\ + int interlaced_frame;\ + \ + /**\ + * If the content is interlaced, is top field displayed first.\ + * - encoding: Set by user.\ + * - decoding: Set by libavcodec.\ + */\ + int top_field_first;\ + \ + /**\ + * Pan scan.\ + * - encoding: Set by user.\ + * - decoding: Set by libavcodec.\ + */\ + AVPanScan *pan_scan;\ + \ + /**\ + * Tell user application that palette has changed from previous frame.\ + * - encoding: ??? (no palette-enabled encoder yet)\ + * - decoding: Set by libavcodec. (default 0).\ + */\ + int palette_has_changed;\ + \ + /**\ + * codec suggestion on buffer type if != 0\ + * - encoding: unused\ + * - decoding: Set by libavcodec. (before get_buffer() call)).\ + */\ + int buffer_hints;\ +\ + /**\ + * DCT coefficients\ + * - encoding: unused\ + * - decoding: Set by libavcodec.\ + */\ + short *dct_coeff;\ +\ + /**\ + * motion referece frame index\ + * - encoding: Set by user.\ + * - decoding: Set by libavcodec.\ + */\ + int8_t *ref_index[2];\ +\ + /**\ + * reordered opaque 64bit number (generally a PTS) from AVCodecContext.reordered_opaque\ + * output in AVFrame.reordered_opaque\ + * - encoding: unused\ + * - decoding: Read by user.\ + */\ + int64_t reordered_opaque;\ + + +#define FF_QSCALE_TYPE_MPEG1 0 +#define FF_QSCALE_TYPE_MPEG2 1 +#define FF_QSCALE_TYPE_H264 2 + +#define FF_BUFFER_TYPE_INTERNAL 1 +#define FF_BUFFER_TYPE_USER 2 ///< direct rendering buffers (image is (de)allocated by user) +#define FF_BUFFER_TYPE_SHARED 4 ///< Buffer from somewhere else; don't deallocate image (data/base), all other tables are not shared. +#define FF_BUFFER_TYPE_COPY 8 ///< Just a (modified) copy of some other buffer, don't deallocate anything. + + +#define FF_I_TYPE 1 ///< Intra +#define FF_P_TYPE 2 ///< Predicted +#define FF_B_TYPE 3 ///< Bi-dir predicted +#define FF_S_TYPE 4 ///< S(GMC)-VOP MPEG4 +#define FF_SI_TYPE 5 ///< Switching Intra +#define FF_SP_TYPE 6 ///< Switching Predicted +#define FF_BI_TYPE 7 + +#define FF_BUFFER_HINTS_VALID 0x01 // Buffer hints value is meaningful (if 0 ignore). +#define FF_BUFFER_HINTS_READABLE 0x02 // Codec will read from buffer. +#define FF_BUFFER_HINTS_PRESERVE 0x04 // User must not alter buffer content. +#define FF_BUFFER_HINTS_REUSABLE 0x08 // Codec will reuse the buffer (update). + +/** + * Audio Video Frame. + * New fields can be added to the end of FF_COMMON_FRAME with minor version + * bumps. + * Removal, reordering and changes to existing fields require a major + * version bump. No fields should be added into AVFrame before or after + * FF_COMMON_FRAME! + * sizeof(AVFrame) must not be used outside libav*. + */ +typedef struct AVFrame { + FF_COMMON_FRAME +} AVFrame; + +/** + * main external API structure. + * New fields can be added to the end with minor version bumps. + * Removal, reordering and changes to existing fields require a major + * version bump. + * sizeof(AVCodecContext) must not be used outside libav*. + */ +typedef struct AVCodecContext { + /** + * information on struct for av_log + * - set by avcodec_alloc_context + */ + const AVClass *av_class; + /** + * the average bitrate + * - encoding: Set by user; unused for constant quantizer encoding. + * - decoding: Set by libavcodec. 0 or some bitrate if this info is available in the stream. + */ + int bit_rate; + + /** + * number of bits the bitstream is allowed to diverge from the reference. + * the reference can be CBR (for CBR pass1) or VBR (for pass2) + * - encoding: Set by user; unused for constant quantizer encoding. + * - decoding: unused + */ + int bit_rate_tolerance; + + /** + * CODEC_FLAG_*. + * - encoding: Set by user. + * - decoding: Set by user. + */ + int flags; + + /** + * Some codecs need additional format info. It is stored here. + * If any muxer uses this then ALL demuxers/parsers AND encoders for the + * specific codec MUST set it correctly otherwise stream copy breaks. + * In general use of this field by muxers is not recommanded. + * - encoding: Set by libavcodec. + * - decoding: Set by libavcodec. (FIXME: Is this OK?) + */ + int sub_id; + + /** + * Motion estimation algorithm used for video coding. + * 1 (zero), 2 (full), 3 (log), 4 (phods), 5 (epzs), 6 (x1), 7 (hex), + * 8 (umh), 9 (iter), 10 (tesa) [7, 8, 10 are x264 specific, 9 is snow specific] + * - encoding: MUST be set by user. + * - decoding: unused + */ + int me_method; + + /** + * some codecs need / can use extradata like Huffman tables. + * mjpeg: Huffman tables + * rv10: additional flags + * mpeg4: global headers (they can be in the bitstream or here) + * The allocated memory should be FF_INPUT_BUFFER_PADDING_SIZE bytes larger + * than extradata_size to avoid prolems if it is read with the bitstream reader. + * The bytewise contents of extradata must not depend on the architecture or CPU endianness. + * - encoding: Set/allocated/freed by libavcodec. + * - decoding: Set/allocated/freed by user. + */ + uint8_t *extradata; + int extradata_size; + + /** + * This is the fundamental unit of time (in seconds) in terms + * of which frame timestamps are represented. For fixed-fps content, + * timebase should be 1/framerate and timestamp increments should be + * identically 1. + * - encoding: MUST be set by user. + * - decoding: Set by libavcodec. + */ + AVRational time_base; + + /* video only */ + /** + * picture width / height. + * - encoding: MUST be set by user. + * - decoding: Set by libavcodec. + * Note: For compatibility it is possible to set this instead of + * coded_width/height before decoding. + */ + int width, height; + +#define FF_ASPECT_EXTENDED 15 + + /** + * the number of pictures in a group of pictures, or 0 for intra_only + * - encoding: Set by user. + * - decoding: unused + */ + int gop_size; + + /** + * Pixel format, see PIX_FMT_xxx. + * - encoding: Set by user. + * - decoding: Set by libavcodec. + */ + enum PixelFormat pix_fmt; + + /** + * Frame rate emulation. If not zero, the lower layer (i.e. format handler) + * has to read frames at native frame rate. + * - encoding: Set by user. + * - decoding: unused + */ + int rate_emu; + + /** + * If non NULL, 'draw_horiz_band' is called by the libavcodec + * decoder to draw a horizontal band. It improves cache usage. Not + * all codecs can do that. You must check the codec capabilities + * beforehand. + * The function is also used by hardware acceleration APIs. + * It is called at least once during frame decoding to pass + * the data needed for hardware render. + * In that mode instead of pixel data, AVFrame points to + * a structure specific to the acceleration API. The application + * reads the structure and can change some fields to indicate progress + * or mark state. + * - encoding: unused + * - decoding: Set by user. + * @param height the height of the slice + * @param y the y position of the slice + * @param type 1->top field, 2->bottom field, 3->frame + * @param offset offset into the AVFrame.data from which the slice should be read + */ + void (*draw_horiz_band)(struct AVCodecContext *s, + const AVFrame *src, int offset[4], + int y, int type, int height); + + /* audio only */ + int sample_rate; ///< samples per second + int channels; ///< number of audio channels + + /** + * audio sample format + * - encoding: Set by user. + * - decoding: Set by libavcodec. + */ + enum SampleFormat sample_fmt; ///< sample format, currently unused + + /* The following data should not be initialized. */ + /** + * Samples per packet, initialized when calling 'init'. + */ + int frame_size; + int frame_number; ///< audio or video frame number + int real_pict_num; ///< Returns the real picture number of previous encoded frame. + + /** + * Number of frames the decoded output will be delayed relative to + * the encoded input. + * - encoding: Set by libavcodec. + * - decoding: unused + */ + int delay; + + /* - encoding parameters */ + float qcompress; ///< amount of qscale change between easy & hard scenes (0.0-1.0) + float qblur; ///< amount of qscale smoothing over time (0.0-1.0) + + /** + * minimum quantizer + * - encoding: Set by user. + * - decoding: unused + */ + int qmin; + + /** + * maximum quantizer + * - encoding: Set by user. + * - decoding: unused + */ + int qmax; + + /** + * maximum quantizer difference between frames + * - encoding: Set by user. + * - decoding: unused + */ + int max_qdiff; + + /** + * maximum number of B-frames between non-B-frames + * Note: The output will be delayed by max_b_frames+1 relative to the input. + * - encoding: Set by user. + * - decoding: unused + */ + int max_b_frames; + + /** + * qscale factor between IP and B-frames + * If > 0 then the last P-frame quantizer will be used (q= lastp_q*factor+offset). + * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset). + * - encoding: Set by user. + * - decoding: unused + */ + float b_quant_factor; + + /** obsolete FIXME remove */ + int rc_strategy; +#define FF_RC_STRATEGY_XVID 1 + + int b_frame_strategy; + + /** + * hurry up amount + * - encoding: unused + * - decoding: Set by user. 1-> Skip B-frames, 2-> Skip IDCT/dequant too, 5-> Skip everything except header + * @deprecated Deprecated in favor of skip_idct and skip_frame. + */ + int hurry_up; + + struct AVCodec *codec; + + void *priv_data; + + int rtp_payload_size; /* The size of the RTP payload: the coder will */ + /* do its best to deliver a chunk with size */ + /* below rtp_payload_size, the chunk will start */ + /* with a start code on some codecs like H.263. */ + /* This doesn't take account of any particular */ + /* headers inside the transmitted RTP payload. */ + + + /* The RTP callback: This function is called */ + /* every time the encoder has a packet to send. */ + /* It depends on the encoder if the data starts */ + /* with a Start Code (it should). H.263 does. */ + /* mb_nb contains the number of macroblocks */ + /* encoded in the RTP payload. */ + void (*rtp_callback)(struct AVCodecContext *avctx, void *data, int size, int mb_nb); + + /* statistics, used for 2-pass encoding */ + int mv_bits; + int header_bits; + int i_tex_bits; + int p_tex_bits; + int i_count; + int p_count; + int skip_count; + int misc_bits; + + /** + * number of bits used for the previously encoded frame + * - encoding: Set by libavcodec. + * - decoding: unused + */ + int frame_bits; + + /** + * Private data of the user, can be used to carry app specific stuff. + * - encoding: Set by user. + * - decoding: Set by user. + */ + void *opaque; + + char codec_name[32]; + enum CodecType codec_type; /* see CODEC_TYPE_xxx */ + enum CodecID codec_id; /* see CODEC_ID_xxx */ + + /** + * fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A'). + * This is used to work around some encoder bugs. + * A demuxer should set this to what is stored in the field used to identify the codec. + * If there are multiple such fields in a container then the demuxer should choose the one + * which maximizes the information about the used codec. + * If the codec tag field in a container is larger then 32 bits then the demuxer should + * remap the longer ID to 32 bits with a table or other structure. Alternatively a new + * extra_codec_tag + size could be added but for this a clear advantage must be demonstrated + * first. + * - encoding: Set by user, if not then the default based on codec_id will be used. + * - decoding: Set by user, will be converted to uppercase by libavcodec during init. + */ + unsigned int codec_tag; + + /** + * Work around bugs in encoders which sometimes cannot be detected automatically. + * - encoding: Set by user + * - decoding: Set by user + */ + int workaround_bugs; +#define FF_BUG_AUTODETECT 1 ///< autodetection +#define FF_BUG_OLD_MSMPEG4 2 +#define FF_BUG_XVID_ILACE 4 +#define FF_BUG_UMP4 8 +#define FF_BUG_NO_PADDING 16 +#define FF_BUG_AMV 32 +#define FF_BUG_AC_VLC 0 ///< Will be removed, libavcodec can now handle these non-compliant files by default. +#define FF_BUG_QPEL_CHROMA 64 +#define FF_BUG_STD_QPEL 128 +#define FF_BUG_QPEL_CHROMA2 256 +#define FF_BUG_DIRECT_BLOCKSIZE 512 +#define FF_BUG_EDGE 1024 +#define FF_BUG_HPEL_CHROMA 2048 +#define FF_BUG_DC_CLIP 4096 +#define FF_BUG_MS 8192 ///< Work around various bugs in Microsoft's broken decoders. +//#define FF_BUG_FAKE_SCALABILITY 16 //Autodetection should work 100%. + + /** + * luma single coefficient elimination threshold + * - encoding: Set by user. + * - decoding: unused + */ + int luma_elim_threshold; + + /** + * chroma single coeff elimination threshold + * - encoding: Set by user. + * - decoding: unused + */ + int chroma_elim_threshold; + + /** + * strictly follow the standard (MPEG4, ...). + * - encoding: Set by user. + * - decoding: Set by user. + * Setting this to STRICT or higher means the encoder and decoder will + * generally do stupid things. While setting it to inofficial or lower + * will mean the encoder might use things that are not supported by all + * spec compliant decoders. Decoders make no difference between normal, + * inofficial and experimental, that is they always try to decode things + * when they can unless they are explicitly asked to behave stupid + * (=strictly conform to the specs) + */ + int strict_std_compliance; +#define FF_COMPLIANCE_VERY_STRICT 2 ///< Strictly conform to a older more strict version of the spec or reference software. +#define FF_COMPLIANCE_STRICT 1 ///< Strictly conform to all the things in the spec no matter what consequences. +#define FF_COMPLIANCE_NORMAL 0 +#define FF_COMPLIANCE_INOFFICIAL -1 ///< Allow inofficial extensions. +#define FF_COMPLIANCE_EXPERIMENTAL -2 ///< Allow nonstandardized experimental things. + + /** + * qscale offset between IP and B-frames + * - encoding: Set by user. + * - decoding: unused + */ + float b_quant_offset; + + /** + * Error recognization; higher values will detect more errors but may + * misdetect some more or less valid parts as errors. + * - encoding: unused + * - decoding: Set by user. + */ + int error_recognition; +#define FF_ER_CAREFUL 1 +#define FF_ER_COMPLIANT 2 +#define FF_ER_AGGRESSIVE 3 +#define FF_ER_VERY_AGGRESSIVE 4 + + /** + * Called at the beginning of each frame to get a buffer for it. + * If pic.reference is set then the frame will be read later by libavcodec. + * avcodec_align_dimensions() should be used to find the required width and + * height, as they normally need to be rounded up to the next multiple of 16. + * - encoding: unused + * - decoding: Set by libavcodec., user can override. + */ + int (*get_buffer)(struct AVCodecContext *c, AVFrame *pic); + + /** + * Called to release buffers which were allocated with get_buffer. + * A released buffer can be reused in get_buffer(). + * pic.data[*] must be set to NULL. + * - encoding: unused + * - decoding: Set by libavcodec., user can override. + */ + void (*release_buffer)(struct AVCodecContext *c, AVFrame *pic); + + /** + * Size of the frame reordering buffer in the decoder. + * For MPEG-2 it is 1 IPB or 0 low delay IP. + * - encoding: Set by libavcodec. + * - decoding: Set by libavcodec. + */ + int has_b_frames; + + /** + * number of bytes per packet if constant and known or 0 + * Used by some WAV based audio codecs. + */ + int block_align; + + int parse_only; /* - decoding only: If true, only parsing is done + (function avcodec_parse_frame()). The frame + data is returned. Only MPEG codecs support this now. */ + + /** + * 0-> h263 quant 1-> mpeg quant + * - encoding: Set by user. + * - decoding: unused + */ + int mpeg_quant; + + /** + * pass1 encoding statistics output buffer + * - encoding: Set by libavcodec. + * - decoding: unused + */ + char *stats_out; + + /** + * pass2 encoding statistics input buffer + * Concatenated stuff from stats_out of pass1 should be placed here. + * - encoding: Allocated/set/freed by user. + * - decoding: unused + */ + char *stats_in; + + /** + * ratecontrol qmin qmax limiting method + * 0-> clipping, 1-> use a nice continous function to limit qscale wthin qmin/qmax. + * - encoding: Set by user. + * - decoding: unused + */ + float rc_qsquish; + + float rc_qmod_amp; + int rc_qmod_freq; + + /** + * ratecontrol override, see RcOverride + * - encoding: Allocated/set/freed by user. + * - decoding: unused + */ + RcOverride *rc_override; + int rc_override_count; + + /** + * rate control equation + * - encoding: Set by user + * - decoding: unused + */ + const char *rc_eq; + + /** + * maximum bitrate + * - encoding: Set by user. + * - decoding: unused + */ + int rc_max_rate; + + /** + * minimum bitrate + * - encoding: Set by user. + * - decoding: unused + */ + int rc_min_rate; + + /** + * decoder bitstream buffer size + * - encoding: Set by user. + * - decoding: unused + */ + int rc_buffer_size; + float rc_buffer_aggressivity; + + /** + * qscale factor between P and I-frames + * If > 0 then the last p frame quantizer will be used (q= lastp_q*factor+offset). + * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset). + * - encoding: Set by user. + * - decoding: unused + */ + float i_quant_factor; + + /** + * qscale offset between P and I-frames + * - encoding: Set by user. + * - decoding: unused + */ + float i_quant_offset; + + /** + * initial complexity for pass1 ratecontrol + * - encoding: Set by user. + * - decoding: unused + */ + float rc_initial_cplx; + + /** + * DCT algorithm, see FF_DCT_* below + * - encoding: Set by user. + * - decoding: unused + */ + int dct_algo; +#define FF_DCT_AUTO 0 +#define FF_DCT_FASTINT 1 +#define FF_DCT_INT 2 +#define FF_DCT_MMX 3 +#define FF_DCT_MLIB 4 +#define FF_DCT_ALTIVEC 5 +#define FF_DCT_FAAN 6 + + /** + * luminance masking (0-> disabled) + * - encoding: Set by user. + * - decoding: unused + */ + float lumi_masking; + + /** + * temporary complexity masking (0-> disabled) + * - encoding: Set by user. + * - decoding: unused + */ + float temporal_cplx_masking; + + /** + * spatial complexity masking (0-> disabled) + * - encoding: Set by user. + * - decoding: unused + */ + float spatial_cplx_masking; + + /** + * p block masking (0-> disabled) + * - encoding: Set by user. + * - decoding: unused + */ + float p_masking; + + /** + * darkness masking (0-> disabled) + * - encoding: Set by user. + * - decoding: unused + */ + float dark_masking; + + /** + * IDCT algorithm, see FF_IDCT_* below. + * - encoding: Set by user. + * - decoding: Set by user. + */ + int idct_algo; +#define FF_IDCT_AUTO 0 +#define FF_IDCT_INT 1 +#define FF_IDCT_SIMPLE 2 +#define FF_IDCT_SIMPLEMMX 3 +#define FF_IDCT_LIBMPEG2MMX 4 +#define FF_IDCT_PS2 5 +#define FF_IDCT_MLIB 6 +#define FF_IDCT_ARM 7 +#define FF_IDCT_ALTIVEC 8 +#define FF_IDCT_SH4 9 +#define FF_IDCT_SIMPLEARM 10 +#define FF_IDCT_H264 11 +#define FF_IDCT_VP3 12 +#define FF_IDCT_IPP 13 +#define FF_IDCT_XVIDMMX 14 +#define FF_IDCT_CAVS 15 +#define FF_IDCT_SIMPLEARMV5TE 16 +#define FF_IDCT_SIMPLEARMV6 17 +#define FF_IDCT_SIMPLEVIS 18 +#define FF_IDCT_WMV2 19 +#define FF_IDCT_FAAN 20 +#define FF_IDCT_EA 21 +#define FF_IDCT_SIMPLENEON 22 +#define FF_IDCT_SIMPLEALPHA 23 + + /** + * slice count + * - encoding: Set by libavcodec. + * - decoding: Set by user (or 0). + */ + int slice_count; + /** + * slice offsets in the frame in bytes + * - encoding: Set/allocated by libavcodec. + * - decoding: Set/allocated by user (or NULL). + */ + int *slice_offset; + + /** + * error concealment flags + * - encoding: unused + * - decoding: Set by user. + */ + int error_concealment; +#define FF_EC_GUESS_MVS 1 +#define FF_EC_DEBLOCK 2 + + /** + * dsp_mask could be add used to disable unwanted CPU features + * CPU features (i.e. MMX, SSE. ...) + * + * With the FORCE flag you may instead enable given CPU features. + * (Dangerous: Usable in case of misdetection, improper usage however will + * result into program crash.) + */ + unsigned dsp_mask; +#define FF_MM_FORCE 0x80000000 /* Force usage of selected flags (OR) */ + /* lower 16 bits - CPU features */ +#define FF_MM_MMX 0x0001 ///< standard MMX +#define FF_MM_3DNOW 0x0004 ///< AMD 3DNOW +#define FF_MM_MMXEXT 0x0002 ///< SSE integer functions or AMD MMX ext +#define FF_MM_SSE 0x0008 ///< SSE functions +#define FF_MM_SSE2 0x0010 ///< PIV SSE2 functions +#define FF_MM_3DNOWEXT 0x0020 ///< AMD 3DNowExt +#define FF_MM_SSE3 0x0040 ///< Prescott SSE3 functions +#define FF_MM_SSSE3 0x0080 ///< Conroe SSSE3 functions +#define FF_MM_IWMMXT 0x0100 ///< XScale IWMMXT +#define FF_MM_ALTIVEC 0x0001 ///< standard AltiVec + + /** + * bits per sample/pixel from the demuxer (needed for huffyuv). + * - encoding: Set by libavcodec. + * - decoding: Set by user. + */ + int bits_per_coded_sample; + + /** + * prediction method (needed for huffyuv) + * - encoding: Set by user. + * - decoding: unused + */ + int prediction_method; +#define FF_PRED_LEFT 0 +#define FF_PRED_PLANE 1 +#define FF_PRED_MEDIAN 2 + + /** + * sample aspect ratio (0 if unknown) + * That is the width of a pixel divided by the height of the pixel. + * Numerator and denominator must be relatively prime and smaller than 256 for some video standards. + * - encoding: Set by user. + * - decoding: Set by libavcodec. + */ + AVRational sample_aspect_ratio; + + /** + * the picture in the bitstream + * - encoding: Set by libavcodec. + * - decoding: Set by libavcodec. + */ + AVFrame *coded_frame; + + /** + * debug + * - encoding: Set by user. + * - decoding: Set by user. + */ + int debug; +#define FF_DEBUG_PICT_INFO 1 +#define FF_DEBUG_RC 2 +#define FF_DEBUG_BITSTREAM 4 +#define FF_DEBUG_MB_TYPE 8 +#define FF_DEBUG_QP 16 +#define FF_DEBUG_MV 32 +#define FF_DEBUG_DCT_COEFF 0x00000040 +#define FF_DEBUG_SKIP 0x00000080 +#define FF_DEBUG_STARTCODE 0x00000100 +#define FF_DEBUG_PTS 0x00000200 +#define FF_DEBUG_ER 0x00000400 +#define FF_DEBUG_MMCO 0x00000800 +#define FF_DEBUG_BUGS 0x00001000 +#define FF_DEBUG_VIS_QP 0x00002000 +#define FF_DEBUG_VIS_MB_TYPE 0x00004000 +#define FF_DEBUG_BUFFERS 0x00008000 + + /** + * debug + * - encoding: Set by user. + * - decoding: Set by user. + */ + int debug_mv; +#define FF_DEBUG_VIS_MV_P_FOR 0x00000001 //visualize forward predicted MVs of P frames +#define FF_DEBUG_VIS_MV_B_FOR 0x00000002 //visualize forward predicted MVs of B frames +#define FF_DEBUG_VIS_MV_B_BACK 0x00000004 //visualize backward predicted MVs of B frames + + /** + * error + * - encoding: Set by libavcodec if flags&CODEC_FLAG_PSNR. + * - decoding: unused + */ + uint64_t error[4]; + + /** + * minimum MB quantizer + * - encoding: unused + * - decoding: unused + */ + int mb_qmin; + + /** + * maximum MB quantizer + * - encoding: unused + * - decoding: unused + */ + int mb_qmax; + + /** + * motion estimation comparison function + * - encoding: Set by user. + * - decoding: unused + */ + int me_cmp; + /** + * subpixel motion estimation comparison function + * - encoding: Set by user. + * - decoding: unused + */ + int me_sub_cmp; + /** + * macroblock comparison function (not supported yet) + * - encoding: Set by user. + * - decoding: unused + */ + int mb_cmp; + /** + * interlaced DCT comparison function + * - encoding: Set by user. + * - decoding: unused + */ + int ildct_cmp; +#define FF_CMP_SAD 0 +#define FF_CMP_SSE 1 +#define FF_CMP_SATD 2 +#define FF_CMP_DCT 3 +#define FF_CMP_PSNR 4 +#define FF_CMP_BIT 5 +#define FF_CMP_RD 6 +#define FF_CMP_ZERO 7 +#define FF_CMP_VSAD 8 +#define FF_CMP_VSSE 9 +#define FF_CMP_NSSE 10 +#define FF_CMP_W53 11 +#define FF_CMP_W97 12 +#define FF_CMP_DCTMAX 13 +#define FF_CMP_DCT264 14 +#define FF_CMP_CHROMA 256 + + /** + * ME diamond size & shape + * - encoding: Set by user. + * - decoding: unused + */ + int dia_size; + + /** + * amount of previous MV predictors (2a+1 x 2a+1 square) + * - encoding: Set by user. + * - decoding: unused + */ + int last_predictor_count; + + /** + * prepass for motion estimation + * - encoding: Set by user. + * - decoding: unused + */ + int pre_me; + + /** + * motion estimation prepass comparison function + * - encoding: Set by user. + * - decoding: unused + */ + int me_pre_cmp; + + /** + * ME prepass diamond size & shape + * - encoding: Set by user. + * - decoding: unused + */ + int pre_dia_size; + + /** + * subpel ME quality + * - encoding: Set by user. + * - decoding: unused + */ + int me_subpel_quality; + + /** + * callback to negotiate the pixelFormat + * @param fmt is the list of formats which are supported by the codec, + * it is terminated by -1 as 0 is a valid format, the formats are ordered by quality. + * The first is always the native one. + * @return the chosen format + * - encoding: unused + * - decoding: Set by user, if not set the native format will be chosen. + */ + enum PixelFormat (*get_format)(struct AVCodecContext *s, const enum PixelFormat * fmt); + + /** + * DTG active format information (additional aspect ratio + * information only used in DVB MPEG-2 transport streams) + * 0 if not set. + * + * - encoding: unused + * - decoding: Set by decoder. + */ + int dtg_active_format; +#define FF_DTG_AFD_SAME 8 +#define FF_DTG_AFD_4_3 9 +#define FF_DTG_AFD_16_9 10 +#define FF_DTG_AFD_14_9 11 +#define FF_DTG_AFD_4_3_SP_14_9 13 +#define FF_DTG_AFD_16_9_SP_14_9 14 +#define FF_DTG_AFD_SP_4_3 15 + + /** + * maximum motion estimation search range in subpel units + * If 0 then no limit. + * + * - encoding: Set by user. + * - decoding: unused + */ + int me_range; + + /** + * intra quantizer bias + * - encoding: Set by user. + * - decoding: unused + */ + int intra_quant_bias; +#define FF_DEFAULT_QUANT_BIAS 999999 + + /** + * inter quantizer bias + * - encoding: Set by user. + * - decoding: unused + */ + int inter_quant_bias; + + /** + * color table ID + * - encoding: unused + * - decoding: Which clrtable should be used for 8bit RGB images. + * Tables have to be stored somewhere. FIXME + */ + int color_table_id; + + /** + * internal_buffer count + * Don't touch, used by libavcodec default_get_buffer(). + */ + int internal_buffer_count; + + /** + * internal_buffers + * Don't touch, used by libavcodec default_get_buffer(). + */ + void *internal_buffer; + +#define FF_LAMBDA_SHIFT 7 +#define FF_LAMBDA_SCALE (1< ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A'). + * This is used to work around some encoder bugs. + * - encoding: unused + * - decoding: Set by user, will be converted to uppercase by libavcodec during init. + */ + unsigned int stream_codec_tag; + + /** + * scene change detection threshold + * 0 is default, larger means fewer detected scene changes. + * - encoding: Set by user. + * - decoding: unused + */ + int scenechange_threshold; + + /** + * minimum Lagrange multipler + * - encoding: Set by user. + * - decoding: unused + */ + int lmin; + + /** + * maximum Lagrange multipler + * - encoding: Set by user. + * - decoding: unused + */ + int lmax; + + /** + * palette control structure + * - encoding: ??? (no palette-enabled encoder yet) + * - decoding: Set by user. + */ + struct AVPaletteControl *palctrl; + + /** + * noise reduction strength + * - encoding: Set by user. + * - decoding: unused + */ + int noise_reduction; + + /** + * Called at the beginning of a frame to get cr buffer for it. + * Buffer type (size, hints) must be the same. libavcodec won't check it. + * libavcodec will pass previous buffer in pic, function should return + * same buffer or new buffer with old frame "painted" into it. + * If pic.data[0] == NULL must behave like get_buffer(). + * - encoding: unused + * - decoding: Set by libavcodec., user can override + */ + int (*reget_buffer)(struct AVCodecContext *c, AVFrame *pic); + + /** + * Number of bits which should be loaded into the rc buffer before decoding starts. + * - encoding: Set by user. + * - decoding: unused + */ + int rc_initial_buffer_occupancy; + + /** + * + * - encoding: Set by user. + * - decoding: unused + */ + int inter_threshold; + + /** + * CODEC_FLAG2_* + * - encoding: Set by user. + * - decoding: Set by user. + */ + int flags2; + + /** + * Simulates errors in the bitstream to test error concealment. + * - encoding: Set by user. + * - decoding: unused + */ + int error_rate; + + /** + * MP3 antialias algorithm, see FF_AA_* below. + * - encoding: unused + * - decoding: Set by user. + */ + int antialias_algo; +#define FF_AA_AUTO 0 +#define FF_AA_FASTINT 1 //not implemented yet +#define FF_AA_INT 2 +#define FF_AA_FLOAT 3 + /** + * quantizer noise shaping + * - encoding: Set by user. + * - decoding: unused + */ + int quantizer_noise_shaping; + + /** + * thread count + * is used to decide how many independent tasks should be passed to execute() + * - encoding: Set by user. + * - decoding: Set by user. + */ + int thread_count; + + /** + * The codec may call this to execute several independent things. + * It will return only after finishing all tasks. + * The user may replace this with some multithreaded implementation, + * the default implementation will execute the parts serially. + * @param count the number of things to execute + * - encoding: Set by libavcodec, user can override. + * - decoding: Set by libavcodec, user can override. + */ + int (*execute)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg), void *arg2, int *ret, int count, int size); + + /** + * thread opaque + * Can be used by execute() to store some per AVCodecContext stuff. + * - encoding: set by execute() + * - decoding: set by execute() + */ + void *thread_opaque; + + /** + * Motion estimation threshold below which no motion estimation is + * performed, but instead the user specified motion vectors are used. + * + * - encoding: Set by user. + * - decoding: unused + */ + int me_threshold; + + /** + * Macroblock threshold below which the user specified macroblock types will be used. + * - encoding: Set by user. + * - decoding: unused + */ + int mb_threshold; + + /** + * precision of the intra DC coefficient - 8 + * - encoding: Set by user. + * - decoding: unused + */ + int intra_dc_precision; + + /** + * noise vs. sse weight for the nsse comparsion function + * - encoding: Set by user. + * - decoding: unused + */ + int nsse_weight; + + /** + * Number of macroblock rows at the top which are skipped. + * - encoding: unused + * - decoding: Set by user. + */ + int skip_top; + + /** + * Number of macroblock rows at the bottom which are skipped. + * - encoding: unused + * - decoding: Set by user. + */ + int skip_bottom; + + /** + * profile + * - encoding: Set by user. + * - decoding: Set by libavcodec. + */ + int profile; +#define FF_PROFILE_UNKNOWN -99 +#define FF_PROFILE_AAC_MAIN 0 +#define FF_PROFILE_AAC_LOW 1 +#define FF_PROFILE_AAC_SSR 2 +#define FF_PROFILE_AAC_LTP 3 + + /** + * level + * - encoding: Set by user. + * - decoding: Set by libavcodec. + */ + int level; +#define FF_LEVEL_UNKNOWN -99 + + /** + * low resolution decoding, 1-> 1/2 size, 2->1/4 size + * - encoding: unused + * - decoding: Set by user. + */ + int lowres; + + /** + * Bitstream width / height, may be different from width/height if lowres + * or other things are used. + * - encoding: unused + * - decoding: Set by user before init if known. Codec should override / dynamically change if needed. + */ + int coded_width, coded_height; + + /** + * frame skip threshold + * - encoding: Set by user. + * - decoding: unused + */ + int frame_skip_threshold; + + /** + * frame skip factor + * - encoding: Set by user. + * - decoding: unused + */ + int frame_skip_factor; + + /** + * frame skip exponent + * - encoding: Set by user. + * - decoding: unused + */ + int frame_skip_exp; + + /** + * frame skip comparison function + * - encoding: Set by user. + * - decoding: unused + */ + int frame_skip_cmp; + + /** + * Border processing masking, raises the quantizer for mbs on the borders + * of the picture. + * - encoding: Set by user. + * - decoding: unused + */ + float border_masking; + + /** + * minimum MB lagrange multipler + * - encoding: Set by user. + * - decoding: unused + */ + int mb_lmin; + + /** + * maximum MB lagrange multipler + * - encoding: Set by user. + * - decoding: unused + */ + int mb_lmax; + + /** + * + * - encoding: Set by user. + * - decoding: unused + */ + int me_penalty_compensation; + + /** + * + * - encoding: unused + * - decoding: Set by user. + */ + enum AVDiscard skip_loop_filter; + + /** + * + * - encoding: unused + * - decoding: Set by user. + */ + enum AVDiscard skip_idct; + + /** + * + * - encoding: unused + * - decoding: Set by user. + */ + enum AVDiscard skip_frame; + + /** + * + * - encoding: Set by user. + * - decoding: unused + */ + int bidir_refine; + + /** + * + * - encoding: Set by user. + * - decoding: unused + */ + int brd_scale; + + /** + * constant rate factor - quality-based VBR - values ~correspond to qps + * - encoding: Set by user. + * - decoding: unused + */ + float crf; + + /** + * constant quantization parameter rate control method + * - encoding: Set by user. + * - decoding: unused + */ + int cqp; + + /** + * minimum GOP size + * - encoding: Set by user. + * - decoding: unused + */ + int keyint_min; + + /** + * number of reference frames + * - encoding: Set by user. + * - decoding: Set by lavc. + */ + int refs; + + /** + * chroma qp offset from luma + * - encoding: Set by user. + * - decoding: unused + */ + int chromaoffset; + + /** + * Influences how often B-frames are used. + * - encoding: Set by user. + * - decoding: unused + */ + int bframebias; + + /** + * trellis RD quantization + * - encoding: Set by user. + * - decoding: unused + */ + int trellis; + + /** + * Reduce fluctuations in qp (before curve compression). + * - encoding: Set by user. + * - decoding: unused + */ + float complexityblur; + + /** + * in-loop deblocking filter alphac0 parameter + * alpha is in the range -6...6 + * - encoding: Set by user. + * - decoding: unused + */ + int deblockalpha; + + /** + * in-loop deblocking filter beta parameter + * beta is in the range -6...6 + * - encoding: Set by user. + * - decoding: unused + */ + int deblockbeta; + + /** + * macroblock subpartition sizes to consider - p8x8, p4x4, b8x8, i8x8, i4x4 + * - encoding: Set by user. + * - decoding: unused + */ + int partitions; +#define X264_PART_I4X4 0x001 /* Analyze i4x4 */ +#define X264_PART_I8X8 0x002 /* Analyze i8x8 (requires 8x8 transform) */ +#define X264_PART_P8X8 0x010 /* Analyze p16x8, p8x16 and p8x8 */ +#define X264_PART_P4X4 0x020 /* Analyze p8x4, p4x8, p4x4 */ +#define X264_PART_B8X8 0x100 /* Analyze b16x8, b8x16 and b8x8 */ + + /** + * direct MV prediction mode - 0 (none), 1 (spatial), 2 (temporal), 3 (auto) + * - encoding: Set by user. + * - decoding: unused + */ + int directpred; + + /** + * Audio cutoff bandwidth (0 means "automatic") + * - encoding: Set by user. + * - decoding: unused + */ + int cutoff; + + /** + * Multiplied by qscale for each frame and added to scene_change_score. + * - encoding: Set by user. + * - decoding: unused + */ + int scenechange_factor; + + /** + * + * Note: Value depends upon the compare function used for fullpel ME. + * - encoding: Set by user. + * - decoding: unused + */ + int mv0_threshold; + + /** + * Adjusts sensitivity of b_frame_strategy 1. + * - encoding: Set by user. + * - decoding: unused + */ + int b_sensitivity; + + /** + * - encoding: Set by user. + * - decoding: unused + */ + int compression_level; +#define FF_COMPRESSION_DEFAULT -1 + + /** + * Sets whether to use LPC mode - used by FLAC encoder. + * - encoding: Set by user. + * - decoding: unused + */ + int use_lpc; + + /** + * LPC coefficient precision - used by FLAC encoder + * - encoding: Set by user. + * - decoding: unused + */ + int lpc_coeff_precision; + + /** + * - encoding: Set by user. + * - decoding: unused + */ + int min_prediction_order; + + /** + * - encoding: Set by user. + * - decoding: unused + */ + int max_prediction_order; + + /** + * search method for selecting prediction order + * - encoding: Set by user. + * - decoding: unused + */ + int prediction_order_method; + + /** + * - encoding: Set by user. + * - decoding: unused + */ + int min_partition_order; + + /** + * - encoding: Set by user. + * - decoding: unused + */ + int max_partition_order; + + /** + * GOP timecode frame start number, in non drop frame format + * - encoding: Set by user. + * - decoding: unused + */ + int64_t timecode_frame_start; + +#if LIBAVCODEC_VERSION_MAJOR < 53 + /** + * Decoder should decode to this many channels if it can (0 for default) + * - encoding: unused + * - decoding: Set by user. + * @deprecated Deprecated in favor of request_channel_layout. + */ + int request_channels; +#endif + + /** + * Percentage of dynamic range compression to be applied by the decoder. + * The default value is 1.0, corresponding to full compression. + * - encoding: unused + * - decoding: Set by user. + */ + float drc_scale; + + /** + * opaque 64bit number (generally a PTS) that will be reordered and + * output in AVFrame.reordered_opaque + * - encoding: unused + * - decoding: Set by user. + */ + int64_t reordered_opaque; + + /** + * Bits per sample/pixel of internal libavcodec pixel/sample format. + * This field is applicable only when sample_fmt is SAMPLE_FMT_S32. + * - encoding: set by user. + * - decoding: set by libavcodec. + */ + int bits_per_raw_sample; + + /** + * Audio channel layout. + * - encoding: set by user. + * - decoding: set by libavcodec. + */ + int64_t channel_layout; + + /** + * Request decoder to use this channel layout if it can (0 for default) + * - encoding: unused + * - decoding: Set by user. + */ + int64_t request_channel_layout; + + /** + * Ratecontrol attempt to use, at maximum, of what can be used without an underflow. + * - encoding: Set by user. + * - decoding: unused. + */ + float rc_max_available_vbv_use; + + /** + * Ratecontrol attempt to use, at least, times the amount needed to prevent a vbv overflow. + * - encoding: Set by user. + * - decoding: unused. + */ + float rc_min_vbv_overflow_use; + + /** + * Hardware accelerator in use + * - encoding: unused. + * - decoding: Set by libavcodec + */ + struct AVHWAccel *hwaccel; + + /** + * For some codecs, the time base is closer to the field rate than the frame rate. + * Most notably, H.264 and MPEG-2 specify time_base as half of frame duration + * if no telecine is used ... + * + * Set to time_base ticks per frame. Default 1, e.g., H.264/MPEG-2 set it to 2. + */ + int ticks_per_frame; +} AVCodecContext; + +/** + * AVCodec. + */ +typedef struct AVCodec { + /** + * Name of the codec implementation. + * The name is globally unique among encoders and among decoders (but an + * encoder and a decoder can share the same name). + * This is the primary way to find a codec from the user perspective. + */ + const char *name; + enum CodecType type; + enum CodecID id; + int priv_data_size; + int (*init)(AVCodecContext *); + int (*encode)(AVCodecContext *, uint8_t *buf, int buf_size, void *data); + int (*close)(AVCodecContext *); + int (*decode)(AVCodecContext *, void *outdata, int *outdata_size, + const uint8_t *buf, int buf_size); + /** + * Codec capabilities. + * see CODEC_CAP_* + */ + int capabilities; + struct AVCodec *next; + /** + * Flush buffers. + * Will be called when seeking + */ + void (*flush)(AVCodecContext *); + const AVRational *supported_framerates; ///< array of supported framerates, or NULL if any, array is terminated by {0,0} + const enum PixelFormat *pix_fmts; ///< array of supported pixel formats, or NULL if unknown, array is terminated by -1 + /** + * Descriptive name for the codec, meant to be more human readable than \p name. + * You \e should use the NULL_IF_CONFIG_SMALL() macro to define it. + */ + const char *long_name; + const int *supported_samplerates; ///< array of supported audio samplerates, or NULL if unknown, array is terminated by 0 + const enum SampleFormat *sample_fmts; ///< array of supported sample formats, or NULL if unknown, array is terminated by -1 + const int64_t *channel_layouts; ///< array of support channel layouts, or NULL if unknown. array is terminated by 0 +} AVCodec; + +/** + * AVHWAccel. + */ +typedef struct AVHWAccel { + /** + * Name of the hardware accelerated codec. + * The name is globally unique among encoders and among decoders (but an + * encoder and a decoder can share the same name). + */ + const char *name; + + /** + * Type of codec implemented by the hardware accelerator. + * + * See CODEC_TYPE_xxx + */ + enum CodecType type; + + /** + * Codec implemented by the hardware accelerator. + * + * See CODEC_ID_xxx + */ + enum CodecID id; + + /** + * Supported pixel format. + * + * Only hardware accelerated formats are supported here. + */ + enum PixelFormat pix_fmt; + + /** + * Hardware accelerated codec capabilities. + * see FF_HWACCEL_CODEC_CAP_* + */ + int capabilities; + + struct AVHWAccel *next; + + /** + * Called at the beginning of each frame or field picture. + * + * Meaningful frame information (codec specific) is guaranteed to + * be parsed at this point. This function is mandatory. + * + * Note that \p buf can be NULL along with \p buf_size set to 0. + * Otherwise, this means the whole frame is available at this point. + * + * @param avctx the codec context + * @param buf the frame data buffer base + * @param buf_size the size of the frame in bytes + * @return zero if successful, a negative value otherwise + */ + int (*start_frame)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size); + + /** + * Callback for each slice. + * + * Meaningful slice information (codec specific) is guaranteed to + * be parsed at this point. This function is mandatory. + * + * @param avctx the codec context + * @param buf the slice data buffer base + * @param buf_size the size of the slice in bytes + * @return zero if successful, a negative value otherwise + */ + int (*decode_slice)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size); + + /** + * Called at the end of each frame or field picture. + * + * The whole picture is parsed at this point and can now be sent + * to the hardware accelerator. This function is mandatory. + * + * @param avctx the codec context + * @return zero if successful, a negative value otherwise + */ + int (*end_frame)(AVCodecContext *avctx); +} AVHWAccel; + +/** + * four components are given, that's all. + * the last component is alpha + */ +typedef struct AVPicture { + uint8_t *data[4]; + int linesize[4]; ///< number of bytes per line +} AVPicture; + +/** + * AVPaletteControl + * This structure defines a method for communicating palette changes + * between and demuxer and a decoder. + * + * @deprecated Use AVPacket to send palette changes instead. + * This is totally broken. + */ +#define AVPALETTE_SIZE 1024 +#define AVPALETTE_COUNT 256 +typedef struct AVPaletteControl { + + /* Demuxer sets this to 1 to indicate the palette has changed; + * decoder resets to 0. */ + int palette_changed; + + /* 4-byte ARGB palette entries, stored in native byte order; note that + * the individual palette components should be on a 8-bit scale; if + * the palette data comes from an IBM VGA native format, the component + * data is probably 6 bits in size and needs to be scaled. */ + unsigned int palette[AVPALETTE_COUNT]; + +} AVPaletteControl attribute_deprecated; + +enum AVSubtitleType { + SUBTITLE_NONE, + + SUBTITLE_BITMAP, ///< A bitmap, pict will be set + + /** + * Plain text, the text field must be set by the decoder and is + * authoritative. ass and pict fields may contain approximations. + */ + SUBTITLE_TEXT, + + /** + * Formatted text, the ass field must be set by the decoder and is + * authoritative. pict and text fields may contain approximations. + */ + SUBTITLE_ASS, +}; + +typedef struct AVSubtitleRect { + int x; ///< top left corner of pict, undefined when pict is not set + int y; ///< top left corner of pict, undefined when pict is not set + int w; ///< width of pict, undefined when pict is not set + int h; ///< height of pict, undefined when pict is not set + int nb_colors; ///< number of colors in pict, undefined when pict is not set + + /** + * data+linesize for the bitmap of this subtitle. + * can be set for text/ass as well once they where rendered + */ + AVPicture pict; + enum AVSubtitleType type; + + char *text; ///< 0 terminated plain UTF-8 text + + /** + * 0 terminated ASS/SSA compatible event line. + * The pressentation of this is unaffected by the other values in this + * struct. + */ + char *ass; +} AVSubtitleRect; + +typedef struct AVSubtitle { + uint16_t format; /* 0 = graphics */ + uint32_t start_display_time; /* relative to packet pts, in ms */ + uint32_t end_display_time; /* relative to packet pts, in ms */ + unsigned num_rects; + AVSubtitleRect **rects; +} AVSubtitle; + + +/* resample.c */ + +struct ReSampleContext; +struct AVResampleContext; + +typedef struct ReSampleContext ReSampleContext; + +#if LIBAVCODEC_VERSION_MAJOR < 53 +/** + * @deprecated Use av_audio_resample_init() instead. + */ +attribute_deprecated ReSampleContext *audio_resample_init(int output_channels, int input_channels, + int output_rate, int input_rate); +#endif +/** + * Initializes audio resampling context + * + * @param output_channels number of output channels + * @param input_channels number of input channels + * @param output_rate output sample rate + * @param input_rate input sample rate + * @param sample_fmt_out requested output sample format + * @param sample_fmt_in input sample format + * @param filter_length length of each FIR filter in the filterbank relative to the cutoff freq + * @param log2_phase_count log2 of the number of entries in the polyphase filterbank + * @param linear If 1 then the used FIR filter will be linearly interpolated + between the 2 closest, if 0 the closest will be used + * @param cutoff cutoff frequency, 1.0 corresponds to half the output sampling rate + * @return allocated ReSampleContext, NULL if error occured + */ +ReSampleContext *av_audio_resample_init(int output_channels, int input_channels, + int output_rate, int input_rate, + enum SampleFormat sample_fmt_out, + enum SampleFormat sample_fmt_in, + int filter_length, int log2_phase_count, + int linear, double cutoff); + +int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples); +void audio_resample_close(ReSampleContext *s); + + +/** + * Initializes an audio resampler. + * Note, if either rate is not an integer then simply scale both rates up so they are. + * @param filter_length length of each FIR filter in the filterbank relative to the cutoff freq + * @param log2_phase_count log2 of the number of entries in the polyphase filterbank + * @param linear If 1 then the used FIR filter will be linearly interpolated + between the 2 closest, if 0 the closest will be used + * @param cutoff cutoff frequency, 1.0 corresponds to half the output sampling rate + */ +struct AVResampleContext *av_resample_init(int out_rate, int in_rate, int filter_length, int log2_phase_count, int linear, double cutoff); + +/** + * resamples. + * @param src an array of unconsumed samples + * @param consumed the number of samples of src which have been consumed are returned here + * @param src_size the number of unconsumed samples available + * @param dst_size the amount of space in samples available in dst + * @param update_ctx If this is 0 then the context will not be modified, that way several channels can be resampled with the same context. + * @return the number of samples written in dst or -1 if an error occurred + */ +int av_resample(struct AVResampleContext *c, short *dst, short *src, int *consumed, int src_size, int dst_size, int update_ctx); + + +/** + * Compensates samplerate/timestamp drift. The compensation is done by changing + * the resampler parameters, so no audible clicks or similar distortions occur + * @param compensation_distance distance in output samples over which the compensation should be performed + * @param sample_delta number of output samples which should be output less + * + * example: av_resample_compensate(c, 10, 500) + * here instead of 510 samples only 500 samples would be output + * + * note, due to rounding the actual compensation might be slightly different, + * especially if the compensation_distance is large and the in_rate used during init is small + */ +void av_resample_compensate(struct AVResampleContext *c, int sample_delta, int compensation_distance); +void av_resample_close(struct AVResampleContext *c); + +/** + * Allocate memory for a picture. Call avpicture_free to free it. + * + * @param picture the picture to be filled in + * @param pix_fmt the format of the picture + * @param width the width of the picture + * @param height the height of the picture + * @return zero if successful, a negative value if not + */ +int avpicture_alloc(AVPicture *picture, int pix_fmt, int width, int height); + +/** + * Free a picture previously allocated by avpicture_alloc(). + * + * @param picture the AVPicture to be freed + */ +void avpicture_free(AVPicture *picture); + +/** + * Fill in the AVPicture fields. + * The fields of the given AVPicture are filled in by using the 'ptr' address + * which points to the image data buffer. Depending on the specified picture + * format, one or multiple image data pointers and line sizes will be set. + * If a planar format is specified, several pointers will be set pointing to + * the different picture planes and the line sizes of the different planes + * will be stored in the lines_sizes array. + * + * @param picture AVPicture whose fields are to be filled in + * @param ptr Buffer which will contain or contains the actual image data + * @param pix_fmt The format in which the picture data is stored. + * @param width the width of the image in pixels + * @param height the height of the image in pixels + * @return size of the image data in bytes + */ +int avpicture_fill(AVPicture *picture, uint8_t *ptr, + int pix_fmt, int width, int height); +int avpicture_layout(const AVPicture* src, int pix_fmt, int width, int height, + unsigned char *dest, int dest_size); + +/** + * Calculate the size in bytes that a picture of the given width and height + * would occupy if stored in the given picture format. + * + * @param pix_fmt the given picture format + * @param width the width of the image + * @param height the height of the image + * @return Image data size in bytes + */ +int avpicture_get_size(int pix_fmt, int width, int height); +void avcodec_get_chroma_sub_sample(int pix_fmt, int *h_shift, int *v_shift); +const char *avcodec_get_pix_fmt_name(int pix_fmt); +void avcodec_set_dimensions(AVCodecContext *s, int width, int height); +enum PixelFormat avcodec_get_pix_fmt(const char* name); +unsigned int avcodec_pix_fmt_to_codec_tag(enum PixelFormat p); + +#define FF_LOSS_RESOLUTION 0x0001 /**< loss due to resolution change */ +#define FF_LOSS_DEPTH 0x0002 /**< loss due to color depth change */ +#define FF_LOSS_COLORSPACE 0x0004 /**< loss due to color space conversion */ +#define FF_LOSS_ALPHA 0x0008 /**< loss of alpha bits */ +#define FF_LOSS_COLORQUANT 0x0010 /**< loss due to color quantization */ +#define FF_LOSS_CHROMA 0x0020 /**< loss of chroma (e.g. RGB to gray conversion) */ + +/** + * Computes what kind of losses will occur when converting from one specific + * pixel format to another. + * When converting from one pixel format to another, information loss may occur. + * For example, when converting from RGB24 to GRAY, the color information will + * be lost. Similarly, other losses occur when converting from some formats to + * other formats. These losses can involve loss of chroma, but also loss of + * resolution, loss of color depth, loss due to the color space conversion, loss + * of the alpha bits or loss due to color quantization. + * avcodec_get_fix_fmt_loss() informs you about the various types of losses + * which will occur when converting from one pixel format to another. + * + * @param[in] dst_pix_fmt destination pixel format + * @param[in] src_pix_fmt source pixel format + * @param[in] has_alpha Whether the source pixel format alpha channel is used. + * @return Combination of flags informing you what kind of losses will occur. + */ +int avcodec_get_pix_fmt_loss(int dst_pix_fmt, int src_pix_fmt, + int has_alpha); + +/** + * Finds the best pixel format to convert to given a certain source pixel + * format. When converting from one pixel format to another, information loss + * may occur. For example, when converting from RGB24 to GRAY, the color + * information will be lost. Similarly, other losses occur when converting from + * some formats to other formats. avcodec_find_best_pix_fmt() searches which of + * the given pixel formats should be used to suffer the least amount of loss. + * The pixel formats from which it chooses one, are determined by the + * \p pix_fmt_mask parameter. + * + * @code + * src_pix_fmt = PIX_FMT_YUV420P; + * pix_fmt_mask = (1 << PIX_FMT_YUV422P) || (1 << PIX_FMT_RGB24); + * dst_pix_fmt = avcodec_find_best_pix_fmt(pix_fmt_mask, src_pix_fmt, alpha, &loss); + * @endcode + * + * @param[in] pix_fmt_mask bitmask determining which pixel format to choose from + * @param[in] src_pix_fmt source pixel format + * @param[in] has_alpha Whether the source pixel format alpha channel is used. + * @param[out] loss_ptr Combination of flags informing you what kind of losses will occur. + * @return The best pixel format to convert to or -1 if none was found. + */ +int avcodec_find_best_pix_fmt(int64_t pix_fmt_mask, int src_pix_fmt, + int has_alpha, int *loss_ptr); + + +/** + * Print in buf the string corresponding to the pixel format with + * number pix_fmt, or an header if pix_fmt is negative. + * + * @param[in] buf the buffer where to write the string + * @param[in] buf_size the size of buf + * @param[in] pix_fmt the number of the pixel format to print the corresponding info string, or + * a negative value to print the corresponding header. + * Meaningful values for obtaining a pixel format info vary from 0 to PIX_FMT_NB -1. + */ +void avcodec_pix_fmt_string (char *buf, int buf_size, int pix_fmt); + +#define FF_ALPHA_TRANSP 0x0001 /* image has some totally transparent pixels */ +#define FF_ALPHA_SEMI_TRANSP 0x0002 /* image has some transparent pixels */ + +/** + * Tell if an image really has transparent alpha values. + * @return ored mask of FF_ALPHA_xxx constants + */ +int img_get_alpha_info(const AVPicture *src, + int pix_fmt, int width, int height); + +/* deinterlace a picture */ +/* deinterlace - if not supported return -1 */ +int avpicture_deinterlace(AVPicture *dst, const AVPicture *src, + int pix_fmt, int width, int height); + +/* external high level API */ + +/** + * If c is NULL, returns the first registered codec, + * if c is non-NULL, returns the next registered codec after c, + * or NULL if c is the last one. + */ +AVCodec *av_codec_next(AVCodec *c); + +/** + * Returns the LIBAVCODEC_VERSION_INT constant. + */ +unsigned avcodec_version(void); + +/** + * Initializes libavcodec. + * + * @warning This function \e must be called before any other libavcodec + * function. + */ +void avcodec_init(void); + +#if LIBAVCODEC_VERSION_MAJOR < 53 +/** + * @deprecated Deprecated in favor of avcodec_register(). + */ +attribute_deprecated void register_avcodec(AVCodec *codec); +#endif + +/** + * Register the codec \p codec and initialize libavcodec. + * + * @see avcodec_init() + */ +void avcodec_register(AVCodec *codec); + +/** + * Finds a registered encoder with a matching codec ID. + * + * @param id CodecID of the requested encoder + * @return An encoder if one was found, NULL otherwise. + */ +AVCodec *avcodec_find_encoder(enum CodecID id); + +/** + * Finds a registered encoder with the specified name. + * + * @param name name of the requested encoder + * @return An encoder if one was found, NULL otherwise. + */ +AVCodec *avcodec_find_encoder_by_name(const char *name); + +/** + * Finds a registered decoder with a matching codec ID. + * + * @param id CodecID of the requested decoder + * @return A decoder if one was found, NULL otherwise. + */ +AVCodec *avcodec_find_decoder(enum CodecID id); + +/** + * Finds a registered decoder with the specified name. + * + * @param name name of the requested decoder + * @return A decoder if one was found, NULL otherwise. + */ +AVCodec *avcodec_find_decoder_by_name(const char *name); +void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode); + +/** + * Sets the fields of the given AVCodecContext to default values. + * + * @param s The AVCodecContext of which the fields should be set to default values. + */ +void avcodec_get_context_defaults(AVCodecContext *s); + +/** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API! + * we WILL change its arguments and name a few times! */ +void avcodec_get_context_defaults2(AVCodecContext *s, enum CodecType); + +/** + * Allocates an AVCodecContext and sets its fields to default values. The + * resulting struct can be deallocated by simply calling av_free(). + * + * @return An AVCodecContext filled with default values or NULL on failure. + * @see avcodec_get_context_defaults + */ +AVCodecContext *avcodec_alloc_context(void); + +/** THIS FUNCTION IS NOT YET PART OF THE PUBLIC API! + * we WILL change its arguments and name a few times! */ +AVCodecContext *avcodec_alloc_context2(enum CodecType); + +/** + * Sets the fields of the given AVFrame to default values. + * + * @param pic The AVFrame of which the fields should be set to default values. + */ +void avcodec_get_frame_defaults(AVFrame *pic); + +/** + * Allocates an AVFrame and sets its fields to default values. The resulting + * struct can be deallocated by simply calling av_free(). + * + * @return An AVFrame filled with default values or NULL on failure. + * @see avcodec_get_frame_defaults + */ +AVFrame *avcodec_alloc_frame(void); + +int avcodec_default_get_buffer(AVCodecContext *s, AVFrame *pic); +void avcodec_default_release_buffer(AVCodecContext *s, AVFrame *pic); +int avcodec_default_reget_buffer(AVCodecContext *s, AVFrame *pic); +void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height); + +/** + * Checks if the given dimension of a picture is valid, meaning that all + * bytes of the picture can be addressed with a signed int. + * + * @param[in] w Width of the picture. + * @param[in] h Height of the picture. + * @return Zero if valid, a negative value if invalid. + */ +int avcodec_check_dimensions(void *av_log_ctx, unsigned int w, unsigned int h); +enum PixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum PixelFormat * fmt); + +int avcodec_thread_init(AVCodecContext *s, int thread_count); +void avcodec_thread_free(AVCodecContext *s); +int avcodec_thread_execute(AVCodecContext *s, int (*func)(AVCodecContext *c2, void *arg2),void *arg, int *ret, int count, int size); +int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2),void *arg, int *ret, int count, int size); +//FIXME func typedef + +/** + * Initializes the AVCodecContext to use the given AVCodec. Prior to using this + * function the context has to be allocated. + * + * The functions avcodec_find_decoder_by_name(), avcodec_find_encoder_by_name(), + * avcodec_find_decoder() and avcodec_find_encoder() provide an easy way for + * retrieving a codec. + * + * @warning This function is not thread safe! + * + * @code + * avcodec_register_all(); + * codec = avcodec_find_decoder(CODEC_ID_H264); + * if (!codec) + * exit(1); + * + * context = avcodec_alloc_context(); + * + * if (avcodec_open(context, codec) < 0) + * exit(1); + * @endcode + * + * @param avctx The context which will be set up to use the given codec. + * @param codec The codec to use within the context. + * @return zero on success, a negative value on error + * @see avcodec_alloc_context, avcodec_find_decoder, avcodec_find_encoder + */ +int avcodec_open(AVCodecContext *avctx, AVCodec *codec); + +/** + * Decodes an audio frame from \p buf into \p samples. + * The avcodec_decode_audio2() function decodes an audio frame from the input + * buffer \p buf of size \p buf_size. To decode it, it makes use of the + * audio codec which was coupled with \p avctx using avcodec_open(). The + * resulting decoded frame is stored in output buffer \p samples. If no frame + * could be decompressed, \p frame_size_ptr is zero. Otherwise, it is the + * decompressed frame size in \e bytes. + * + * @warning You \e must set \p frame_size_ptr to the allocated size of the + * output buffer before calling avcodec_decode_audio2(). + * + * @warning The input buffer must be \c FF_INPUT_BUFFER_PADDING_SIZE larger than + * the actual read bytes because some optimized bitstream readers read 32 or 64 + * bits at once and could read over the end. + * + * @warning The end of the input buffer \p buf should be set to 0 to ensure that + * no overreading happens for damaged MPEG streams. + * + * @note You might have to align the input buffer \p buf and output buffer \p + * samples. The alignment requirements depend on the CPU: On some CPUs it isn't + * necessary at all, on others it won't work at all if not aligned and on others + * it will work but it will have an impact on performance. In practice, the + * bitstream should have 4 byte alignment at minimum and all sample data should + * be 16 byte aligned unless the CPU doesn't need it (AltiVec and SSE do). If + * the linesize is not a multiple of 16 then there's no sense in aligning the + * start of the buffer to 16. + * + * @param avctx the codec context + * @param[out] samples the output buffer + * @param[in,out] frame_size_ptr the output buffer size in bytes + * @param[in] buf the input buffer + * @param[in] buf_size the input buffer size in bytes + * @return On error a negative value is returned, otherwise the number of bytes + * used or zero if no frame could be decompressed. + */ +int avcodec_decode_audio2(AVCodecContext *avctx, int16_t *samples, + int *frame_size_ptr, + const uint8_t *buf, int buf_size); + +/** + * Decodes a video frame from \p buf into \p picture. + * The avcodec_decode_video() function decodes a video frame from the input + * buffer \p buf of size \p buf_size. To decode it, it makes use of the + * video codec which was coupled with \p avctx using avcodec_open(). The + * resulting decoded frame is stored in \p picture. + * + * @warning The input buffer must be \c FF_INPUT_BUFFER_PADDING_SIZE larger than + * the actual read bytes because some optimized bitstream readers read 32 or 64 + * bits at once and could read over the end. + * + * @warning The end of the input buffer \p buf should be set to 0 to ensure that + * no overreading happens for damaged MPEG streams. + * + * @note You might have to align the input buffer \p buf and output buffer \p + * samples. The alignment requirements depend on the CPU: on some CPUs it isn't + * necessary at all, on others it won't work at all if not aligned and on others + * it will work but it will have an impact on performance. In practice, the + * bitstream should have 4 byte alignment at minimum and all sample data should + * be 16 byte aligned unless the CPU doesn't need it (AltiVec and SSE do). If + * the linesize is not a multiple of 16 then there's no sense in aligning the + * start of the buffer to 16. + * + * @note Some codecs have a delay between input and output, these need to be + * feeded with buf=NULL, buf_size=0 at the end to return the remaining frames. + * + * @param avctx the codec context + * @param[out] picture The AVFrame in which the decoded video frame will be stored. + * @param[in] buf the input buffer + * @param[in] buf_size the size of the input buffer in bytes + * @param[in,out] got_picture_ptr Zero if no frame could be decompressed, otherwise, it is nonzero. + * @return On error a negative value is returned, otherwise the number of bytes + * used or zero if no frame could be decompressed. + */ +int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture, + int *got_picture_ptr, + const uint8_t *buf, int buf_size); + +/* Decode a subtitle message. Return -1 if error, otherwise return the + * number of bytes used. If no subtitle could be decompressed, + * got_sub_ptr is zero. Otherwise, the subtitle is stored in *sub. */ +int avcodec_decode_subtitle(AVCodecContext *avctx, AVSubtitle *sub, + int *got_sub_ptr, + const uint8_t *buf, int buf_size); +int avcodec_parse_frame(AVCodecContext *avctx, uint8_t **pdata, + int *data_size_ptr, + uint8_t *buf, int buf_size); + +/** + * Encodes an audio frame from \p samples into \p buf. + * The avcodec_encode_audio() function encodes an audio frame from the input + * buffer \p samples. To encode it, it makes use of the audio codec which was + * coupled with \p avctx using avcodec_open(). The resulting encoded frame is + * stored in output buffer \p buf. + * + * @note The output buffer should be at least \c FF_MIN_BUFFER_SIZE bytes large. + * + * @param avctx the codec context + * @param[out] buf the output buffer + * @param[in] buf_size the output buffer size + * @param[in] samples the input buffer containing the samples + * The number of samples read from this buffer is frame_size*channels, + * both of which are defined in \p avctx. + * For PCM audio the number of samples read from \p samples is equal to + * \p buf_size * input_sample_size / output_sample_size. + * @return On error a negative value is returned, on success zero or the number + * of bytes used to encode the data read from the input buffer. + */ +int avcodec_encode_audio(AVCodecContext *avctx, uint8_t *buf, int buf_size, + const short *samples); + +/** + * Encodes a video frame from \p pict into \p buf. + * The avcodec_encode_video() function encodes a video frame from the input + * \p pict. To encode it, it makes use of the video codec which was coupled with + * \p avctx using avcodec_open(). The resulting encoded bytes representing the + * frame are stored in the output buffer \p buf. The input picture should be + * stored using a specific format, namely \c avctx.pix_fmt. + * + * @param avctx the codec context + * @param[out] buf the output buffer for the bitstream of encoded frame + * @param[in] buf_size the size of the output buffer in bytes + * @param[in] pict the input picture to encode + * @return On error a negative value is returned, on success zero or the number + * of bytes used from the output buffer. + */ +int avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf, int buf_size, + const AVFrame *pict); +int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size, + const AVSubtitle *sub); + +int avcodec_close(AVCodecContext *avctx); + +/** + * Register all the codecs, parsers and bitstream filters which were enabled at + * configuration time. If you do not call this function you can select exactly + * which formats you want to support, by using the individual registration + * functions. + * + * @see avcodec_register + * @see av_register_codec_parser + * @see av_register_bitstream_filter + */ +void avcodec_register_all(void); + +/** + * Flush buffers, should be called when seeking or when switching to a different stream. + */ +void avcodec_flush_buffers(AVCodecContext *avctx); + +void avcodec_default_free_buffers(AVCodecContext *s); + +/* misc useful functions */ + +/** + * Returns a single letter to describe the given picture type \p pict_type. + * + * @param[in] pict_type the picture type + * @return A single character representing the picture type. + */ +char av_get_pict_type_char(int pict_type); + +/** + * Returns codec bits per sample. + * + * @param[in] codec_id the codec + * @return Number of bits per sample or zero if unknown for the given codec. + */ +int av_get_bits_per_sample(enum CodecID codec_id); + +/** + * Returns sample format bits per sample. + * + * @param[in] sample_fmt the sample format + * @return Number of bits per sample or zero if unknown for the given sample format. + */ +int av_get_bits_per_sample_format(enum SampleFormat sample_fmt); + +/* frame parsing */ +typedef struct AVCodecParserContext { + void *priv_data; + struct AVCodecParser *parser; + int64_t frame_offset; /* offset of the current frame */ + int64_t cur_offset; /* current offset + (incremented by each av_parser_parse()) */ + int64_t next_frame_offset; /* offset of the next frame */ + /* video info */ + int pict_type; /* XXX: Put it back in AVCodecContext. */ + /** + * This field is used for proper frame duration computation in lavf. + * It signals, how much longer the frame duration of the current frame + * is compared to normal frame duration. + * + * frame_duration = (1 + repeat_pict) * time_base + * + * It is used by codecs like H.264 to display telecined material. + */ + int repeat_pict; /* XXX: Put it back in AVCodecContext. */ + int64_t pts; /* pts of the current frame */ + int64_t dts; /* dts of the current frame */ + + /* private data */ + int64_t last_pts; + int64_t last_dts; + int fetch_timestamp; + +#define AV_PARSER_PTS_NB 4 + int cur_frame_start_index; + int64_t cur_frame_offset[AV_PARSER_PTS_NB]; + int64_t cur_frame_pts[AV_PARSER_PTS_NB]; + int64_t cur_frame_dts[AV_PARSER_PTS_NB]; + + int flags; +#define PARSER_FLAG_COMPLETE_FRAMES 0x0001 + + int64_t offset; ///< byte offset from starting packet start + int64_t cur_frame_end[AV_PARSER_PTS_NB]; + + /*! + * Set by parser to 1 for key frames and 0 for non-key frames. + * It is initialized to -1, so if the parser doesn't set this flag, + * old-style fallback using FF_I_TYPE picture type as key frames + * will be used. + */ + int key_frame; + + /** + * Time difference in stream time base units from the pts of this + * packet to the point at which the output from the decoder has converged + * independent from the availability of previous frames. That is, the + * frames are virtually identical no matter if decoding started from + * the very first frame or from this keyframe. + * Is AV_NOPTS_VALUE if unknown. + * This field is not the display duration of the current frame. + * + * The purpose of this field is to allow seeking in streams that have no + * keyframes in the conventional sense. It corresponds to the + * recovery point SEI in H.264 and match_time_delta in NUT. It is also + * essential for some types of subtitle streams to ensure that all + * subtitles are correctly displayed after seeking. + */ + int64_t convergence_duration; + + // Timestamp generation support: + /** + * Synchronization point for start of timestamp generation. + * + * Set to >0 for sync point, 0 for no sync point and <0 for undefined + * (default). + * + * For example, this corresponds to presence of H.264 buffering period + * SEI message. + */ + int dts_sync_point; + + /** + * Offset of the current timestamp against last timestamp sync point in + * units of AVCodecContext.time_base. + * + * Set to INT_MIN when dts_sync_point unused. Otherwise, it must + * contain a valid timestamp offset. + * + * Note that the timestamp of sync point has usually a nonzero + * dts_ref_dts_delta, which refers to the previous sync point. Offset of + * the next frame after timestamp sync point will be usually 1. + * + * For example, this corresponds to H.264 cpb_removal_delay. + */ + int dts_ref_dts_delta; + + /** + * Presentation delay of current frame in units of AVCodecContext.time_base. + * + * Set to INT_MIN when dts_sync_point unused. Otherwise, it must + * contain valid non-negative timestamp delta (presentation time of a frame + * must not lie in the past). + * + * This delay represents the difference between decoding and presentation + * time of the frame. + * + * For example, this corresponds to H.264 dpb_output_delay. + */ + int pts_dts_delta; +} AVCodecParserContext; + +typedef struct AVCodecParser { + int codec_ids[5]; /* several codec IDs are permitted */ + int priv_data_size; + int (*parser_init)(AVCodecParserContext *s); + int (*parser_parse)(AVCodecParserContext *s, + AVCodecContext *avctx, + const uint8_t **poutbuf, int *poutbuf_size, + const uint8_t *buf, int buf_size); + void (*parser_close)(AVCodecParserContext *s); + int (*split)(AVCodecContext *avctx, const uint8_t *buf, int buf_size); + struct AVCodecParser *next; +} AVCodecParser; + +AVCodecParser *av_parser_next(AVCodecParser *c); + +void av_register_codec_parser(AVCodecParser *parser); +AVCodecParserContext *av_parser_init(int codec_id); +int av_parser_parse(AVCodecParserContext *s, + AVCodecContext *avctx, + uint8_t **poutbuf, int *poutbuf_size, + const uint8_t *buf, int buf_size, + int64_t pts, int64_t dts); +int av_parser_change(AVCodecParserContext *s, + AVCodecContext *avctx, + uint8_t **poutbuf, int *poutbuf_size, + const uint8_t *buf, int buf_size, int keyframe); +void av_parser_close(AVCodecParserContext *s); + + +typedef struct AVBitStreamFilterContext { + void *priv_data; + struct AVBitStreamFilter *filter; + AVCodecParserContext *parser; + struct AVBitStreamFilterContext *next; +} AVBitStreamFilterContext; + + +typedef struct AVBitStreamFilter { + const char *name; + int priv_data_size; + int (*filter)(AVBitStreamFilterContext *bsfc, + AVCodecContext *avctx, const char *args, + uint8_t **poutbuf, int *poutbuf_size, + const uint8_t *buf, int buf_size, int keyframe); + void (*close)(AVBitStreamFilterContext *bsfc); + struct AVBitStreamFilter *next; +} AVBitStreamFilter; + +void av_register_bitstream_filter(AVBitStreamFilter *bsf); +AVBitStreamFilterContext *av_bitstream_filter_init(const char *name); +int av_bitstream_filter_filter(AVBitStreamFilterContext *bsfc, + AVCodecContext *avctx, const char *args, + uint8_t **poutbuf, int *poutbuf_size, + const uint8_t *buf, int buf_size, int keyframe); +void av_bitstream_filter_close(AVBitStreamFilterContext *bsf); + +AVBitStreamFilter *av_bitstream_filter_next(AVBitStreamFilter *f); + +/* memory */ + +/** + * Reallocates the given block if it is not large enough, otherwise it + * does nothing. + * + * @see av_realloc + */ +void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size); + +/** + * Copy image 'src' to 'dst'. + */ +void av_picture_copy(AVPicture *dst, const AVPicture *src, + int pix_fmt, int width, int height); + +/** + * Crop image top and left side. + */ +int av_picture_crop(AVPicture *dst, const AVPicture *src, + int pix_fmt, int top_band, int left_band); + +/** + * Pad image. + */ +int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width, int pix_fmt, + int padtop, int padbottom, int padleft, int padright, int *color); + +unsigned int av_xiphlacing(unsigned char *s, unsigned int v); + +/** + * Parses \p str and put in \p width_ptr and \p height_ptr the detected values. + * + * @return 0 in case of a successful parsing, a negative value otherwise + * @param[in] str the string to parse: it has to be a string in the format + * x or a valid video frame size abbreviation. + * @param[in,out] width_ptr pointer to the variable which will contain the detected + * frame width value + * @param[in,out] height_ptr pointer to the variable which will contain the detected + * frame height value + */ +int av_parse_video_frame_size(int *width_ptr, int *height_ptr, const char *str); + +/** + * Parses \p str and put in \p frame_rate the detected values. + * + * @return 0 in case of a successful parsing, a negative value otherwise + * @param[in] str the string to parse: it has to be a string in the format + * /, a float number or a valid video rate abbreviation + * @param[in,out] frame_rate pointer to the AVRational which will contain the detected + * frame rate + */ +int av_parse_video_frame_rate(AVRational *frame_rate, const char *str); + +/* error handling */ +#if EINVAL > 0 +#define AVERROR(e) (-(e)) /**< Returns a negative error code from a POSIX error code, to return from library functions. */ +#define AVUNERROR(e) (-(e)) /**< Returns a POSIX error code from a library function error return value. */ +#else +/* Some platforms have E* and errno already negated. */ +#define AVERROR(e) (e) +#define AVUNERROR(e) (e) +#endif +#define AVERROR_UNKNOWN AVERROR(EINVAL) /**< unknown error */ +#define AVERROR_IO AVERROR(EIO) /**< I/O error */ +#define AVERROR_NUMEXPECTED AVERROR(EDOM) /**< Number syntax expected in filename. */ +#define AVERROR_INVALIDDATA AVERROR(EINVAL) /**< invalid data found */ +#define AVERROR_NOMEM AVERROR(ENOMEM) /**< not enough memory */ +#define AVERROR_NOFMT AVERROR(EILSEQ) /**< unknown format */ +#define AVERROR_NOTSUPP AVERROR(ENOSYS) /**< Operation not supported. */ +#define AVERROR_NOENT AVERROR(ENOENT) /**< No such file or directory. */ +#define AVERROR_EOF AVERROR(EPIPE) /**< End of file. */ +#define AVERROR_PATCHWELCOME -MKTAG('P','A','W','E') /**< Not yet implemented in FFmpeg. Patches welcome. */ + +/** + * Registers the hardware accelerator \p hwaccel. + */ +void av_register_hwaccel(AVHWAccel *hwaccel); + +/** + * If hwaccel is NULL, returns the first registered hardware accelerator, + * if hwaccel is non-NULL, returns the next registered hardware accelerator + * after hwaccel, or NULL if hwaccel is the last one. + */ +AVHWAccel *av_hwaccel_next(AVHWAccel *hwaccel); + +#endif /* AVCODEC_AVCODEC_H */ diff --git a/libavcodec/xvmc.h b/libavcodec/xvmc.h new file mode 100644 index 0000000..12da4bf --- /dev/null +++ b/libavcodec/xvmc.h @@ -0,0 +1,172 @@ +/* + * Copyright (C) 2003 Ivan Kalvachev + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_XVMC_H +#define AVCODEC_XVMC_H + +#include + +#include "avcodec.h" + +#if LIBAVCODEC_VERSION_MAJOR < 53 +#define AV_XVMC_STATE_DISPLAY_PENDING 1 /** the surface should be shown, the video driver manipulates this */ +#define AV_XVMC_STATE_PREDICTION 2 /** the surface is needed for prediction, the codec manipulates this */ +#define AV_XVMC_STATE_OSD_SOURCE 4 /** the surface is needed for subpicture rendering */ +#endif +#define AV_XVMC_ID 0x1DC711C0 /**< special value to ensure that regular pixel routines haven't corrupted the struct + the number is 1337 speak for the letters IDCT MCo (motion compensation) */ + +struct xvmc_pix_fmt { + /** The field contains the special constant value AV_XVMC_ID. + It is used as a test that the application correctly uses the API, + and that there is no corruption caused by pixel routines. + - application - set during initialization + - libavcodec - unchanged + */ + int xvmc_id; + + /** Pointer to the block array allocated by XvMCCreateBlocks(). + The array has to be freed by XvMCDestroyBlocks(). + Each group of 64 values represents one data block of differential + pixel information (in MoCo mode) or coefficients for IDCT. + - application - set the pointer during initialization + - libavcodec - fills coefficients/pixel data into the array + */ + short* data_blocks; + + /** Pointer to the macroblock description array allocated by + XvMCCreateMacroBlocks() and freed by XvMCDestroyMacroBlocks(). + - application - set the pointer during initialization + - libavcodec - fills description data into the array + */ + XvMCMacroBlock* mv_blocks; + + /** Number of macroblock descriptions that can be stored in the mv_blocks + array. + - application - set during initialization + - libavcodec - unchanged + */ + int allocated_mv_blocks; + + /** Number of blocks that can be stored at once in the data_blocks array. + - application - set during initialization + - libavcodec - unchanged + */ + int allocated_data_blocks; + + /** Indicates that the hardware would interpret data_blocks as IDCT + coefficients and perform IDCT on them. + - application - set during initialization + - libavcodec - unchanged + */ + int idct; + + /** In MoCo mode it indicates that intra macroblocks are assumed to be in + unsigned format; same as the XVMC_INTRA_UNSIGNED flag. + - application - set during initialization + - libavcodec - unchanged + */ + int unsigned_intra; + + /** Pointer to the surface allocated by XvMCCreateSurface(). + It has to be freed by XvMCDestroySurface() on application exit. + It identifies the frame and its state on the video hardware. + - application - set during initialization + - libavcodec - unchanged + */ + XvMCSurface* p_surface; + +/** Set by the decoder before calling ff_draw_horiz_band(), + needed by the XvMCRenderSurface function. */ +//@{ + /** Pointer to the surface used as past reference + - application - unchanged + - libavcodec - set + */ + XvMCSurface* p_past_surface; + + /** Pointer to the surface used as future reference + - application - unchanged + - libavcodec - set + */ + XvMCSurface* p_future_surface; + + /** top/bottom field or frame + - application - unchanged + - libavcodec - set + */ + unsigned int picture_structure; + + /** XVMC_SECOND_FIELD - 1st or 2nd field in the sequence + - application - unchanged + - libavcodec - set + */ + unsigned int flags; +//}@ + + /** Number of macroblock descriptions in the mv_blocks array + that have already been passed to the hardware. + - application - zeroes it on get_buffer(). + A successful ff_draw_horiz_band() may increment it + with filled_mb_block_num or zero both. + - libavcodec - unchanged + */ + int start_mv_blocks_num; + + /** Number of new macroblock descriptions in the mv_blocks array (after + start_mv_blocks_num) that are filled by libavcodec and have to be + passed to the hardware. + - application - zeroes it on get_buffer() or after successful + ff_draw_horiz_band(). + - libavcodec - increment with one of each stored MB + */ + int filled_mv_blocks_num; + + /** Number of the the next free data block; one data block consists of + 64 short values in the data_blocks array. + All blocks before this one are already claimed by filling their number + into the corresponding blocks description structure field, + that are hold in mv_blocks array. + - application - zeroes it on get_buffer(). + A successful ff_draw_horiz_band() may zero it together + with start_mb_blocks_num. + - libavcodec - each decoded macroblock increases it by the number + of coded blocks it contains. + */ + int next_free_data_block_num; + +/** extensions may be placed here */ +#if LIBAVCODEC_VERSION_MAJOR < 53 +//@{ + /** State flags used to work around limitations in the MPlayer video system. + 0 - Surface is not used. + 1 - Surface is still held in application to be displayed or is + still visible. + 2 - Surface is still held in libavcodec buffer for prediction. + */ + int state; + + /** pointer to the surface where the subpicture is rendered */ + void* p_osd_target_surface_render; +//}@ +#endif +}; + +#endif /* AVCODEC_XVMC_H */ diff --git a/libavformat/allformats.c b/libavformat/allformats.c new file mode 100644 index 0000000..a8183c2 --- /dev/null +++ b/libavformat/allformats.c @@ -0,0 +1,206 @@ +/* + * Register all the formats and protocols + * Copyright (c) 2000, 2001, 2002 Fabrice Bellard + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +#include "avformat.h" +#include "rtp.h" +#include "rdt.h" + +#define REGISTER_MUXER(X,x) { \ + extern AVOutputFormat x##_muxer; \ + if(CONFIG_##X##_MUXER) av_register_output_format(&x##_muxer); } + +#define REGISTER_DEMUXER(X,x) { \ + extern AVInputFormat x##_demuxer; \ + if(CONFIG_##X##_DEMUXER) av_register_input_format(&x##_demuxer); } + +#define REGISTER_MUXDEMUX(X,x) REGISTER_MUXER(X,x); REGISTER_DEMUXER(X,x) + +#define REGISTER_PROTOCOL(X,x) { \ + extern URLProtocol x##_protocol; \ + if(CONFIG_##X##_PROTOCOL) register_protocol(&x##_protocol); } + +void av_register_all(void) +{ + static int initialized; + + if (initialized) + return; + initialized = 1; + + avcodec_register_all(); + + /* (de)muxers */ + REGISTER_DEMUXER (AAC, aac); + REGISTER_MUXDEMUX (AC3, ac3); + REGISTER_MUXER (ADTS, adts); + REGISTER_MUXDEMUX (AIFF, aiff); + REGISTER_MUXDEMUX (AMR, amr); + REGISTER_DEMUXER (APC, apc); + REGISTER_DEMUXER (APE, ape); + REGISTER_MUXDEMUX (ASF, asf); + REGISTER_MUXDEMUX (ASS, ass); + REGISTER_MUXER (ASF_STREAM, asf_stream); + REGISTER_MUXDEMUX (AU, au); + REGISTER_MUXDEMUX (AVI, avi); + REGISTER_DEMUXER (AVISYNTH, avisynth); + REGISTER_MUXER (AVM2, avm2); + REGISTER_DEMUXER (AVS, avs); + REGISTER_DEMUXER (BETHSOFTVID, bethsoftvid); + REGISTER_DEMUXER (BFI, bfi); + REGISTER_DEMUXER (C93, c93); + REGISTER_MUXER (CRC, crc); + REGISTER_MUXDEMUX (DAUD, daud); + REGISTER_MUXDEMUX (DIRAC, dirac); + REGISTER_MUXDEMUX (DNXHD, dnxhd); + REGISTER_DEMUXER (DSICIN, dsicin); + REGISTER_MUXDEMUX (DTS, dts); + REGISTER_MUXDEMUX (DV, dv); + REGISTER_DEMUXER (DXA, dxa); + REGISTER_DEMUXER (EA, ea); + REGISTER_DEMUXER (EA_CDATA, ea_cdata); + REGISTER_MUXDEMUX (EAC3, eac3); + REGISTER_MUXDEMUX (FFM, ffm); + REGISTER_MUXDEMUX (FLAC, flac); + REGISTER_DEMUXER (FLIC, flic); + REGISTER_MUXDEMUX (FLV, flv); + REGISTER_DEMUXER (FOURXM, fourxm); + REGISTER_MUXER (FRAMECRC, framecrc); + REGISTER_MUXER (GIF, gif); + REGISTER_DEMUXER (GSM, gsm); + REGISTER_MUXDEMUX (GXF, gxf); + REGISTER_MUXDEMUX (H261, h261); + REGISTER_MUXDEMUX (H263, h263); + REGISTER_MUXDEMUX (H264, h264); + REGISTER_DEMUXER (IDCIN, idcin); + REGISTER_DEMUXER (IFF, iff); + REGISTER_MUXDEMUX (IMAGE2, image2); + REGISTER_MUXDEMUX (IMAGE2PIPE, image2pipe); + REGISTER_DEMUXER (INGENIENT, ingenient); + REGISTER_DEMUXER (IPMOVIE, ipmovie); + REGISTER_MUXER (IPOD, ipod); + REGISTER_DEMUXER (ISS, iss); + REGISTER_DEMUXER (LMLM4, lmlm4); + REGISTER_MUXDEMUX (M4V, m4v); + REGISTER_MUXDEMUX (MATROSKA, matroska); + REGISTER_MUXER (MATROSKA_AUDIO, matroska_audio); + REGISTER_MUXDEMUX (MJPEG, mjpeg); + REGISTER_DEMUXER (MLP, mlp); + REGISTER_DEMUXER (MM, mm); + REGISTER_MUXDEMUX (MMF, mmf); + REGISTER_MUXDEMUX (MOV, mov); + REGISTER_MUXER (MP2, mp2); + REGISTER_MUXDEMUX (MP3, mp3); + REGISTER_MUXER (MP4, mp4); + REGISTER_DEMUXER (MPC, mpc); + REGISTER_DEMUXER (MPC8, mpc8); + REGISTER_MUXER (MPEG1SYSTEM, mpeg1system); + REGISTER_MUXER (MPEG1VCD, mpeg1vcd); + REGISTER_MUXER (MPEG1VIDEO, mpeg1video); + REGISTER_MUXER (MPEG2DVD, mpeg2dvd); + REGISTER_MUXER (MPEG2SVCD, mpeg2svcd); + REGISTER_MUXER (MPEG2VIDEO, mpeg2video); + REGISTER_MUXER (MPEG2VOB, mpeg2vob); + REGISTER_DEMUXER (MPEGPS, mpegps); + REGISTER_MUXDEMUX (MPEGTS, mpegts); + REGISTER_DEMUXER (MPEGTSRAW, mpegtsraw); + REGISTER_DEMUXER (MPEGVIDEO, mpegvideo); + REGISTER_MUXER (MPJPEG, mpjpeg); + REGISTER_DEMUXER (MSNWC_TCP, msnwc_tcp); + REGISTER_DEMUXER (MTV, mtv); + REGISTER_DEMUXER (MVI, mvi); + REGISTER_MUXDEMUX (MXF, mxf); + REGISTER_DEMUXER (NSV, nsv); + REGISTER_MUXER (NULL, null); + REGISTER_MUXDEMUX (NUT, nut); + REGISTER_DEMUXER (NUV, nuv); + REGISTER_MUXDEMUX (OGG, ogg); + REGISTER_DEMUXER (OMA, oma); + REGISTER_MUXDEMUX (PCM_ALAW, pcm_alaw); + REGISTER_MUXDEMUX (PCM_MULAW, pcm_mulaw); + REGISTER_MUXDEMUX (PCM_F64BE, pcm_f64be); + REGISTER_MUXDEMUX (PCM_F64LE, pcm_f64le); + REGISTER_MUXDEMUX (PCM_F32BE, pcm_f32be); + REGISTER_MUXDEMUX (PCM_F32LE, pcm_f32le); + REGISTER_MUXDEMUX (PCM_S32BE, pcm_s32be); + REGISTER_MUXDEMUX (PCM_S32LE, pcm_s32le); + REGISTER_MUXDEMUX (PCM_S24BE, pcm_s24be); + REGISTER_MUXDEMUX (PCM_S24LE, pcm_s24le); + REGISTER_MUXDEMUX (PCM_S16BE, pcm_s16be); + REGISTER_MUXDEMUX (PCM_S16LE, pcm_s16le); + REGISTER_MUXDEMUX (PCM_S8, pcm_s8); + REGISTER_MUXDEMUX (PCM_U32BE, pcm_u32be); + REGISTER_MUXDEMUX (PCM_U32LE, pcm_u32le); + REGISTER_MUXDEMUX (PCM_U24BE, pcm_u24be); + REGISTER_MUXDEMUX (PCM_U24LE, pcm_u24le); + REGISTER_MUXDEMUX (PCM_U16BE, pcm_u16be); + REGISTER_MUXDEMUX (PCM_U16LE, pcm_u16le); + REGISTER_MUXDEMUX (PCM_U8, pcm_u8); + REGISTER_MUXER (PSP, psp); + REGISTER_DEMUXER (PVA, pva); + REGISTER_DEMUXER (R3D, r3d); + REGISTER_MUXDEMUX (RAWVIDEO, rawvideo); + REGISTER_DEMUXER (REDIR, redir); + REGISTER_DEMUXER (RL2, rl2); + REGISTER_MUXDEMUX (RM, rm); + REGISTER_MUXDEMUX (ROQ, roq); + REGISTER_DEMUXER (RPL, rpl); + REGISTER_MUXER (RTP, rtp); + REGISTER_DEMUXER (RTSP, rtsp); + REGISTER_DEMUXER (SDP, sdp); +#if CONFIG_SDP_DEMUXER + av_register_rtp_dynamic_payload_handlers(); + av_register_rdt_dynamic_payload_handlers(); +#endif + REGISTER_DEMUXER (SEGAFILM, segafilm); + REGISTER_DEMUXER (SHORTEN, shorten); + REGISTER_DEMUXER (SIFF, siff); + REGISTER_DEMUXER (SMACKER, smacker); + REGISTER_DEMUXER (SOL, sol); + REGISTER_DEMUXER (STR, str); + REGISTER_MUXDEMUX (SWF, swf); + REGISTER_MUXER (TG2, tg2); + REGISTER_MUXER (TGP, tgp); + REGISTER_DEMUXER (THP, thp); + REGISTER_DEMUXER (TIERTEXSEQ, tiertexseq); + REGISTER_DEMUXER (TTA, tta); + REGISTER_DEMUXER (TXD, txd); + REGISTER_DEMUXER (VC1, vc1); + REGISTER_MUXDEMUX (VC1T, vc1t); + REGISTER_DEMUXER (VMD, vmd); + REGISTER_MUXDEMUX (VOC, voc); + REGISTER_MUXDEMUX (WAV, wav); + REGISTER_DEMUXER (WC3, wc3); + REGISTER_DEMUXER (WSAUD, wsaud); + REGISTER_DEMUXER (WSVQA, wsvqa); + REGISTER_DEMUXER (WV, wv); + REGISTER_DEMUXER (XA, xa); + REGISTER_MUXDEMUX (YUV4MPEGPIPE, yuv4mpegpipe); + + /* external libraries */ + REGISTER_MUXDEMUX (LIBNUT, libnut); + + /* protocols */ + REGISTER_PROTOCOL (FILE, file); + REGISTER_PROTOCOL (HTTP, http); + REGISTER_PROTOCOL (PIPE, pipe); + REGISTER_PROTOCOL (RTP, rtp); + REGISTER_PROTOCOL (TCP, tcp); + REGISTER_PROTOCOL (UDP, udp); +} diff --git a/libavformat/avio.h b/libavformat/avio.h new file mode 100644 index 0000000..d154911 --- /dev/null +++ b/libavformat/avio.h @@ -0,0 +1,394 @@ +/* + * copyright (c) 2001 Fabrice Bellard + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +#ifndef AVFORMAT_AVIO_H +#define AVFORMAT_AVIO_H + +/** + * @file libavformat/avio.h + * unbuffered I/O operations + * + * @warning This file has to be considered an internal but installed + * header, so it should not be directly included in your projects. + */ + +#include + +#include "libavutil/common.h" + +/* unbuffered I/O */ + +/** + * URL Context. + * New fields can be added to the end with minor version bumps. + * Removal, reordering and changes to existing fields require a major + * version bump. + * sizeof(URLContext) must not be used outside libav*. + */ +struct URLContext { +#if LIBAVFORMAT_VERSION_MAJOR >= 53 + const AVClass *av_class; ///< information for av_log(). Set by url_open(). +#endif + struct URLProtocol *prot; + int flags; + int is_streamed; /**< true if streamed (no seek possible), default = false */ + int max_packet_size; /**< if non zero, the stream is packetized with this max packet size */ + void *priv_data; + char *filename; /**< specified filename */ +}; + +typedef struct URLContext URLContext; + +typedef struct URLPollEntry { + URLContext *handle; + int events; + int revents; +} URLPollEntry; + +#define URL_RDONLY 0 +#define URL_WRONLY 1 +#define URL_RDWR 2 + +typedef int URLInterruptCB(void); + +int url_open_protocol (URLContext **puc, struct URLProtocol *up, + const char *filename, int flags); +int url_open(URLContext **h, const char *filename, int flags); +int url_read(URLContext *h, unsigned char *buf, int size); +int url_write(URLContext *h, unsigned char *buf, int size); +int64_t url_seek(URLContext *h, int64_t pos, int whence); +int url_close(URLContext *h); +int url_exist(const char *filename); +int64_t url_filesize(URLContext *h); + +/** + * Return the maximum packet size associated to packetized file + * handle. If the file is not packetized (stream like HTTP or file on + * disk), then 0 is returned. + * + * @param h file handle + * @return maximum packet size in bytes + */ +int url_get_max_packet_size(URLContext *h); +void url_get_filename(URLContext *h, char *buf, int buf_size); + +/** + * The callback is called in blocking functions to test regulary if + * asynchronous interruption is needed. AVERROR(EINTR) is returned + * in this case by the interrupted function. 'NULL' means no interrupt + * callback is given. + */ +void url_set_interrupt_cb(URLInterruptCB *interrupt_cb); + +/* not implemented */ +int url_poll(URLPollEntry *poll_table, int n, int timeout); + +/** + * Pause and resume playing - only meaningful if using a network streaming + * protocol (e.g. MMS). + * @param pause 1 for pause, 0 for resume + */ +int av_url_read_pause(URLContext *h, int pause); + +/** + * Seek to a given timestamp relative to some component stream. + * Only meaningful if using a network streaming protocol (e.g. MMS.). + * @param stream_index The stream index that the timestamp is relative to. + * If stream_index is (-1) the timestamp should be in AV_TIME_BASE + * units from the beginning of the presentation. + * If a stream_index >= 0 is used and the protocol does not support + * seeking based on component streams, the call will fail with ENOTSUP. + * @param timestamp timestamp in AVStream.time_base units + * or if there is no stream specified then in AV_TIME_BASE units. + * @param flags Optional combination of AVSEEK_FLAG_BACKWARD, AVSEEK_FLAG_BYTE + * and AVSEEK_FLAG_ANY. The protocol may silently ignore + * AVSEEK_FLAG_BACKWARD and AVSEEK_FLAG_ANY, but AVSEEK_FLAG_BYTE will + * fail with ENOTSUP if used and not supported. + * @return >= 0 on success + * @see AVInputFormat::read_seek + */ +int64_t av_url_read_seek(URLContext *h, int stream_index, + int64_t timestamp, int flags); + +/** + * Passing this as the "whence" parameter to a seek function causes it to + * return the filesize without seeking anywhere. Supporting this is optional. + * If it is not supported then the seek function will return <0. + */ +#define AVSEEK_SIZE 0x10000 + +typedef struct URLProtocol { + const char *name; + int (*url_open)(URLContext *h, const char *filename, int flags); + int (*url_read)(URLContext *h, unsigned char *buf, int size); + int (*url_write)(URLContext *h, unsigned char *buf, int size); + int64_t (*url_seek)(URLContext *h, int64_t pos, int whence); + int (*url_close)(URLContext *h); + struct URLProtocol *next; + int (*url_read_pause)(URLContext *h, int pause); + int64_t (*url_read_seek)(URLContext *h, int stream_index, + int64_t timestamp, int flags); +} URLProtocol; + +#if LIBAVFORMAT_VERSION_MAJOR < 53 +extern URLProtocol *first_protocol; +#endif + +extern URLInterruptCB *url_interrupt_cb; + +/** + * If protocol is NULL, returns the first registered protocol, + * if protocol is non-NULL, returns the next registered protocol after protocol, + * or NULL if protocol is the last one. + */ +URLProtocol *av_protocol_next(URLProtocol *p); + +#if LIBAVFORMAT_VERSION_MAJOR < 53 +/** + * @deprecated Use av_register_protocol() instead. + */ +attribute_deprecated int register_protocol(URLProtocol *protocol); +#endif + +int av_register_protocol(URLProtocol *protocol); + +/** + * Bytestream IO Context. + * New fields can be added to the end with minor version bumps. + * Removal, reordering and changes to existing fields require a major + * version bump. + * sizeof(ByteIOContext) must not be used outside libav*. + */ +typedef struct { + unsigned char *buffer; + int buffer_size; + unsigned char *buf_ptr, *buf_end; + void *opaque; + int (*read_packet)(void *opaque, uint8_t *buf, int buf_size); + int (*write_packet)(void *opaque, uint8_t *buf, int buf_size); + int64_t (*seek)(void *opaque, int64_t offset, int whence); + int64_t pos; /**< position in the file of the current buffer */ + int must_flush; /**< true if the next seek should flush */ + int eof_reached; /**< true if eof reached */ + int write_flag; /**< true if open for writing */ + int is_streamed; + int max_packet_size; + unsigned long checksum; + unsigned char *checksum_ptr; + unsigned long (*update_checksum)(unsigned long checksum, const uint8_t *buf, unsigned int size); + int error; ///< contains the error code or 0 if no error happened + int (*read_pause)(void *opaque, int pause); + int64_t (*read_seek)(void *opaque, int stream_index, + int64_t timestamp, int flags); +} ByteIOContext; + +int init_put_byte(ByteIOContext *s, + unsigned char *buffer, + int buffer_size, + int write_flag, + void *opaque, + int (*read_packet)(void *opaque, uint8_t *buf, int buf_size), + int (*write_packet)(void *opaque, uint8_t *buf, int buf_size), + int64_t (*seek)(void *opaque, int64_t offset, int whence)); +ByteIOContext *av_alloc_put_byte( + unsigned char *buffer, + int buffer_size, + int write_flag, + void *opaque, + int (*read_packet)(void *opaque, uint8_t *buf, int buf_size), + int (*write_packet)(void *opaque, uint8_t *buf, int buf_size), + int64_t (*seek)(void *opaque, int64_t offset, int whence)); + +void put_byte(ByteIOContext *s, int b); +void put_buffer(ByteIOContext *s, const unsigned char *buf, int size); +void put_le64(ByteIOContext *s, uint64_t val); +void put_be64(ByteIOContext *s, uint64_t val); +void put_le32(ByteIOContext *s, unsigned int val); +void put_be32(ByteIOContext *s, unsigned int val); +void put_le24(ByteIOContext *s, unsigned int val); +void put_be24(ByteIOContext *s, unsigned int val); +void put_le16(ByteIOContext *s, unsigned int val); +void put_be16(ByteIOContext *s, unsigned int val); +void put_tag(ByteIOContext *s, const char *tag); + +void put_strz(ByteIOContext *s, const char *buf); + +/** + * fseek() equivalent for ByteIOContext. + * @return new position or AVERROR. + */ +int64_t url_fseek(ByteIOContext *s, int64_t offset, int whence); + +/** + * Skip given number of bytes forward. + * @param offset number of bytes + */ +void url_fskip(ByteIOContext *s, int64_t offset); + +/** + * ftell() equivalent for ByteIOContext. + * @return position or AVERROR. + */ +int64_t url_ftell(ByteIOContext *s); + +/** + * Gets the filesize. + * @return filesize or AVERROR + */ +int64_t url_fsize(ByteIOContext *s); + +/** + * feof() equivalent for ByteIOContext. + * @return non zero if and only if end of file + */ +int url_feof(ByteIOContext *s); + +int url_ferror(ByteIOContext *s); + +int av_url_read_fpause(ByteIOContext *h, int pause); +int64_t av_url_read_fseek(ByteIOContext *h, int stream_index, + int64_t timestamp, int flags); + +#define URL_EOF (-1) +/** @note return URL_EOF (-1) if EOF */ +int url_fgetc(ByteIOContext *s); + +/** @warning currently size is limited */ +#ifdef __GNUC__ +int url_fprintf(ByteIOContext *s, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 2, 3))); +#else +int url_fprintf(ByteIOContext *s, const char *fmt, ...); +#endif + +/** @note unlike fgets, the EOL character is not returned and a whole + line is parsed. return NULL if first char read was EOF */ +char *url_fgets(ByteIOContext *s, char *buf, int buf_size); + +void put_flush_packet(ByteIOContext *s); + + +/** + * Reads size bytes from ByteIOContext into buf. + * @returns number of bytes read or AVERROR + */ +int get_buffer(ByteIOContext *s, unsigned char *buf, int size); + +/** + * Reads size bytes from ByteIOContext into buf. + * This reads at most 1 packet. If that is not enough fewer bytes will be + * returned. + * @returns number of bytes read or AVERROR + */ +int get_partial_buffer(ByteIOContext *s, unsigned char *buf, int size); + +/** @note return 0 if EOF, so you cannot use it if EOF handling is + necessary */ +int get_byte(ByteIOContext *s); +unsigned int get_le24(ByteIOContext *s); +unsigned int get_le32(ByteIOContext *s); +uint64_t get_le64(ByteIOContext *s); +unsigned int get_le16(ByteIOContext *s); + +char *get_strz(ByteIOContext *s, char *buf, int maxlen); +unsigned int get_be16(ByteIOContext *s); +unsigned int get_be24(ByteIOContext *s); +unsigned int get_be32(ByteIOContext *s); +uint64_t get_be64(ByteIOContext *s); + +uint64_t ff_get_v(ByteIOContext *bc); + +static inline int url_is_streamed(ByteIOContext *s) +{ + return s->is_streamed; +} + +/** @note when opened as read/write, the buffers are only used for + writing */ +int url_fdopen(ByteIOContext **s, URLContext *h); + +/** @warning must be called before any I/O */ +int url_setbufsize(ByteIOContext *s, int buf_size); +/** Reset the buffer for reading or writing. + * @note Will drop any data currently in the buffer without transmitting it. + * @param flags URL_RDONLY to set up the buffer for reading, or URL_WRONLY + * to set up the buffer for writing. */ +int url_resetbuf(ByteIOContext *s, int flags); + +/** @note when opened as read/write, the buffers are only used for + writing */ +int url_fopen(ByteIOContext **s, const char *filename, int flags); +int url_fclose(ByteIOContext *s); +URLContext *url_fileno(ByteIOContext *s); + +/** + * Return the maximum packet size associated to packetized buffered file + * handle. If the file is not packetized (stream like http or file on + * disk), then 0 is returned. + * + * @param s buffered file handle + * @return maximum packet size in bytes + */ +int url_fget_max_packet_size(ByteIOContext *s); + +int url_open_buf(ByteIOContext **s, uint8_t *buf, int buf_size, int flags); + +/** return the written or read size */ +int url_close_buf(ByteIOContext *s); + +/** + * Open a write only memory stream. + * + * @param s new IO context + * @return zero if no error. + */ +int url_open_dyn_buf(ByteIOContext **s); + +/** + * Open a write only packetized memory stream with a maximum packet + * size of 'max_packet_size'. The stream is stored in a memory buffer + * with a big endian 4 byte header giving the packet size in bytes. + * + * @param s new IO context + * @param max_packet_size maximum packet size (must be > 0) + * @return zero if no error. + */ +int url_open_dyn_packet_buf(ByteIOContext **s, int max_packet_size); + +/** + * Return the written size and a pointer to the buffer. The buffer + * must be freed with av_free(). + * @param s IO context + * @param pbuffer pointer to a byte buffer + * @return the length of the byte buffer + */ +int url_close_dyn_buf(ByteIOContext *s, uint8_t **pbuffer); + +unsigned long ff_crc04C11DB7_update(unsigned long checksum, const uint8_t *buf, + unsigned int len); +unsigned long get_checksum(ByteIOContext *s); +void init_checksum(ByteIOContext *s, + unsigned long (*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len), + unsigned long checksum); + +/* udp.c */ +int udp_set_remote_url(URLContext *h, const char *uri); +int udp_get_local_port(URLContext *h); +int udp_get_file_handle(URLContext *h); + +#endif /* AVFORMAT_AVIO_H */ diff --git a/libavformat/riff.h b/libavformat/riff.h new file mode 100644 index 0000000..d287929 --- /dev/null +++ b/libavformat/riff.h @@ -0,0 +1,54 @@ +/* + * RIFF codec tags + * copyright (c) 2000 Fabrice Bellard + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file libavformat/riff.h + * internal header for RIFF based (de)muxers + * do NOT include this in end user applications + */ + +#ifndef AVFORMAT_RIFF_H +#define AVFORMAT_RIFF_H + +#include "libavcodec/avcodec.h" +#include "avio.h" + +int64_t start_tag(ByteIOContext *pb, const char *tag); +void end_tag(ByteIOContext *pb, int64_t start); + +typedef struct AVCodecTag { + int id; + unsigned int tag; +} AVCodecTag; + +void put_bmp_header(ByteIOContext *pb, AVCodecContext *enc, const AVCodecTag *tags, int for_asf); +int put_wav_header(ByteIOContext *pb, AVCodecContext *enc); +enum CodecID wav_codec_get_id(unsigned int tag, int bps); +void get_wav_header(ByteIOContext *pb, AVCodecContext *codec, int size); + +extern const AVCodecTag codec_bmp_tags[]; +extern const AVCodecTag codec_wav_tags[]; + +unsigned int codec_get_tag(const AVCodecTag *tags, int id); +enum CodecID codec_get_id(const AVCodecTag *tags, unsigned int tag); +void ff_parse_specific_params(AVCodecContext *stream, int *au_rate, int *au_ssize, int *au_scale); + +#endif /* AVFORMAT_RIFF_H */ diff --git a/libavutil/bswap.h b/libavutil/bswap.h new file mode 100644 index 0000000..cf68c43 --- /dev/null +++ b/libavutil/bswap.h @@ -0,0 +1,99 @@ +/* + * copyright (c) 2006 Michael Niedermayer + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file libavutil/bswap.h + * byte swapping routines + */ + +#ifndef AVUTIL_BSWAP_H +#define AVUTIL_BSWAP_H + +#include +#include "config.h" +#include "common.h" + +#if ARCH_ARM +# include "arm/bswap.h" +#elif ARCH_BFIN +# include "bfin/bswap.h" +#elif ARCH_SH4 +# include "sh4/bswap.h" +#elif ARCH_X86 +# include "x86/bswap.h" +#endif + +#ifndef bswap_16 +static av_always_inline av_const uint16_t bswap_16(uint16_t x) +{ + x= (x>>8) | (x<<8); + return x; +} +#endif + +#ifndef bswap_32 +static av_always_inline av_const uint32_t bswap_32(uint32_t x) +{ + x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF); + x= (x>>16) | (x<<16); + return x; +} +#endif + +#ifndef bswap_64 +static inline uint64_t av_const bswap_64(uint64_t x) +{ +#if 0 + x= ((x<< 8)&0xFF00FF00FF00FF00ULL) | ((x>> 8)&0x00FF00FF00FF00FFULL); + x= ((x<<16)&0xFFFF0000FFFF0000ULL) | ((x>>16)&0x0000FFFF0000FFFFULL); + return (x>>32) | (x<<32); +#else + union { + uint64_t ll; + uint32_t l[2]; + } w, r; + w.ll = x; + r.l[0] = bswap_32 (w.l[1]); + r.l[1] = bswap_32 (w.l[0]); + return r.ll; +#endif +} +#endif + +// be2me ... big-endian to machine-endian +// le2me ... little-endian to machine-endian + +#ifdef WORDS_BIGENDIAN +#define be2me_16(x) (x) +#define be2me_32(x) (x) +#define be2me_64(x) (x) +#define le2me_16(x) bswap_16(x) +#define le2me_32(x) bswap_32(x) +#define le2me_64(x) bswap_64(x) +#else +#define be2me_16(x) bswap_16(x) +#define be2me_32(x) bswap_32(x) +#define be2me_64(x) bswap_64(x) +#define le2me_16(x) (x) +#define le2me_32(x) (x) +#define le2me_64(x) (x) +#endif + +#endif /* AVUTIL_BSWAP_H */ diff --git a/libavutil/common.h b/libavutil/common.h new file mode 100644 index 0000000..3005b96 --- /dev/null +++ b/libavutil/common.h @@ -0,0 +1,266 @@ +/* + * copyright (c) 2006 Michael Niedermayer + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file libavutil/common.h + * common internal and external API header + */ + +#ifndef AVUTIL_COMMON_H +#define AVUTIL_COMMON_H + +#include +#include +#include +#include +#include +#include +#include +#include + +#define AV_GCC_VERSION_AT_LEAST(x,y) (defined(__GNUC__) && (__GNUC__ > x || __GNUC__ == x && __GNUC_MINOR__ >= y)) + +#ifndef av_always_inline +#if AV_GCC_VERSION_AT_LEAST(3,1) +# define av_always_inline __attribute__((always_inline)) inline +#else +# define av_always_inline inline +#endif +#endif + +#ifndef av_noinline +#if AV_GCC_VERSION_AT_LEAST(3,1) +# define av_noinline __attribute__((noinline)) +#else +# define av_noinline +#endif +#endif + +#ifndef av_pure +#if AV_GCC_VERSION_AT_LEAST(3,1) +# define av_pure __attribute__((pure)) +#else +# define av_pure +#endif +#endif + +#ifndef av_const +#if AV_GCC_VERSION_AT_LEAST(2,6) +# define av_const __attribute__((const)) +#else +# define av_const +#endif +#endif + +#ifndef av_cold +#if (!defined(__ICC) || __ICC > 1100) && AV_GCC_VERSION_AT_LEAST(4,3) +# define av_cold __attribute__((cold)) +#else +# define av_cold +#endif +#endif + +#ifndef attribute_deprecated +#if AV_GCC_VERSION_AT_LEAST(3,1) +# define attribute_deprecated __attribute__((deprecated)) +#else +# define attribute_deprecated +#endif +#endif + +#ifndef av_unused +#if defined(__GNUC__) +# define av_unused __attribute__((unused)) +#else +# define av_unused +#endif +#endif + +//rounded division & shift +#define RSHIFT(a,b) ((a) > 0 ? ((a) + ((1<<(b))>>1))>>(b) : ((a) + ((1<<(b))>>1)-1)>>(b)) +/* assume b>0 */ +#define ROUNDED_DIV(a,b) (((a)>0 ? (a) + ((b)>>1) : (a) - ((b)>>1))/(b)) +#define FFABS(a) ((a) >= 0 ? (a) : (-(a))) +#define FFSIGN(a) ((a) > 0 ? 1 : -1) + +#define FFMAX(a,b) ((a) > (b) ? (a) : (b)) +#define FFMAX3(a,b,c) FFMAX(FFMAX(a,b),c) +#define FFMIN(a,b) ((a) > (b) ? (b) : (a)) +#define FFMIN3(a,b,c) FFMIN(FFMIN(a,b),c) + +#define FFSWAP(type,a,b) do{type SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0) +#define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0])) + +/* misc math functions */ +extern const uint8_t ff_log2_tab[256]; + +static inline av_const int av_log2(unsigned int v) +{ + int n = 0; + if (v & 0xffff0000) { + v >>= 16; + n += 16; + } + if (v & 0xff00) { + v >>= 8; + n += 8; + } + n += ff_log2_tab[v]; + + return n; +} + +static inline av_const int av_log2_16bit(unsigned int v) +{ + int n = 0; + if (v & 0xff00) { + v >>= 8; + n += 8; + } + n += ff_log2_tab[v]; + + return n; +} + +/** + * Clips a signed integer value into the amin-amax range. + * @param a value to clip + * @param amin minimum value of the clip range + * @param amax maximum value of the clip range + * @return clipped value + */ +static inline av_const int av_clip(int a, int amin, int amax) +{ + if (a < amin) return amin; + else if (a > amax) return amax; + else return a; +} + +/** + * Clips a signed integer value into the 0-255 range. + * @param a value to clip + * @return clipped value + */ +static inline av_const uint8_t av_clip_uint8(int a) +{ + if (a&(~255)) return (-a)>>31; + else return a; +} + +/** + * Clips a signed integer value into the -32768,32767 range. + * @param a value to clip + * @return clipped value + */ +static inline av_const int16_t av_clip_int16(int a) +{ + if ((a+32768) & ~65535) return (a>>31) ^ 32767; + else return a; +} + +/** + * Clips a float value into the amin-amax range. + * @param a value to clip + * @param amin minimum value of the clip range + * @param amax maximum value of the clip range + * @return clipped value + */ +static inline av_const float av_clipf(float a, float amin, float amax) +{ + if (a < amin) return amin; + else if (a > amax) return amax; + else return a; +} + +#define MKTAG(a,b,c,d) (a | (b << 8) | (c << 16) | (d << 24)) +#define MKBETAG(a,b,c,d) (d | (c << 8) | (b << 16) | (a << 24)) + +/*! + * \def GET_UTF8(val, GET_BYTE, ERROR) + * Converts a UTF-8 character (up to 4 bytes long) to its 32-bit UCS-4 encoded form + * \param val is the output and should be of type uint32_t. It holds the converted + * UCS-4 character and should be a left value. + * \param GET_BYTE gets UTF-8 encoded bytes from any proper source. It can be + * a function or a statement whose return value or evaluated value is of type + * uint8_t. It will be executed up to 4 times for values in the valid UTF-8 range, + * and up to 7 times in the general case. + * \param ERROR action that should be taken when an invalid UTF-8 byte is returned + * from GET_BYTE. It should be a statement that jumps out of the macro, + * like exit(), goto, return, break, or continue. + */ +#define GET_UTF8(val, GET_BYTE, ERROR)\ + val= GET_BYTE;\ + {\ + int ones= 7 - av_log2(val ^ 255);\ + if(ones==1)\ + ERROR\ + val&= 127>>ones;\ + while(--ones > 0){\ + int tmp= GET_BYTE - 128;\ + if(tmp>>6)\ + ERROR\ + val= (val<<6) + tmp;\ + }\ + } + +/*! + * \def PUT_UTF8(val, tmp, PUT_BYTE) + * Converts a 32-bit Unicode character to its UTF-8 encoded form (up to 4 bytes long). + * \param val is an input-only argument and should be of type uint32_t. It holds + * a UCS-4 encoded Unicode character that is to be converted to UTF-8. If + * val is given as a function it is executed only once. + * \param tmp is a temporary variable and should be of type uint8_t. It + * represents an intermediate value during conversion that is to be + * output by PUT_BYTE. + * \param PUT_BYTE writes the converted UTF-8 bytes to any proper destination. + * It could be a function or a statement, and uses tmp as the input byte. + * For example, PUT_BYTE could be "*output++ = tmp;" PUT_BYTE will be + * executed up to 4 times for values in the valid UTF-8 range and up to + * 7 times in the general case, depending on the length of the converted + * Unicode character. + */ +#define PUT_UTF8(val, tmp, PUT_BYTE)\ + {\ + int bytes, shift;\ + uint32_t in = val;\ + if (in < 0x80) {\ + tmp = in;\ + PUT_BYTE\ + } else {\ + bytes = (av_log2(in) + 4) / 5;\ + shift = (bytes - 1) * 6;\ + tmp = (256 - (256 >> bytes)) | (in >> shift);\ + PUT_BYTE\ + while (shift >= 6) {\ + shift -= 6;\ + tmp = 0x80 | ((in >> shift) & 0x3f);\ + PUT_BYTE\ + }\ + }\ + } + +#include "mem.h" + +#ifdef HAVE_AV_CONFIG_H +# include "config.h" +# include "internal.h" +#endif /* HAVE_AV_CONFIG_H */ + +#endif /* AVUTIL_COMMON_H */ diff --git a/libavutil/internal.h b/libavutil/internal.h new file mode 100644 index 0000000..f5f769e --- /dev/null +++ b/libavutil/internal.h @@ -0,0 +1,328 @@ +/* + * copyright (c) 2006 Michael Niedermayer + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file libavutil/internal.h + * common internal API header + */ + +#ifndef AVUTIL_INTERNAL_H +#define AVUTIL_INTERNAL_H + +#if !defined(DEBUG) && !defined(NDEBUG) +# define NDEBUG +#endif + +#include +#include +#include +#include +#include "config.h" +#include "common.h" +#include "mem.h" +#include "timer.h" + +#ifndef attribute_align_arg +#if (!defined(__ICC) || __ICC > 1100) && AV_GCC_VERSION_AT_LEAST(4,2) +# define attribute_align_arg __attribute__((force_align_arg_pointer)) +#else +# define attribute_align_arg +#endif +#endif + +#ifndef attribute_used +#if AV_GCC_VERSION_AT_LEAST(3,1) +# define attribute_used __attribute__((used)) +#else +# define attribute_used +#endif +#endif + +#ifndef INT16_MIN +#define INT16_MIN (-0x7fff-1) +#endif + +#ifndef INT16_MAX +#define INT16_MAX 0x7fff +#endif + +#ifndef INT32_MIN +#define INT32_MIN (-0x7fffffff-1) +#endif + +#ifndef INT32_MAX +#define INT32_MAX 0x7fffffff +#endif + +#ifndef UINT32_MAX +#define UINT32_MAX 0xffffffff +#endif + +#ifndef INT64_MIN +#define INT64_MIN (-0x7fffffffffffffffLL-1) +#endif + +#ifndef INT64_MAX +#define INT64_MAX INT64_C(9223372036854775807) +#endif + +#ifndef UINT64_MAX +#define UINT64_MAX UINT64_C(0xFFFFFFFFFFFFFFFF) +#endif + +#ifndef INT_BIT +# define INT_BIT (CHAR_BIT * sizeof(int)) +#endif + +#if ( defined(__PIC__) || defined(__pic__) ) && ! defined(PIC) +# define PIC +#endif + +#ifndef offsetof +# define offsetof(T,F) ((unsigned int)((char *)&((T *)0)->F)) +#endif + +// Use rip-relative addressing if compiling PIC code on x86-64. +#if ARCH_X86_64 && defined(PIC) +# define LOCAL_MANGLE(a) #a "(%%rip)" +#else +# define LOCAL_MANGLE(a) #a +#endif + +#define MANGLE(a) EXTERN_PREFIX LOCAL_MANGLE(a) + +/* debug stuff */ + +/* dprintf macros */ +#ifdef DEBUG +# define dprintf(pctx, ...) av_log(pctx, AV_LOG_DEBUG, __VA_ARGS__) +#else +# define dprintf(pctx, ...) +#endif + +#define av_abort() do { av_log(NULL, AV_LOG_ERROR, "Abort at %s:%d\n", __FILE__, __LINE__); abort(); } while (0) + +/* math */ + +extern const uint32_t ff_inverse[256]; + +#if ARCH_X86 +# define FASTDIV(a,b) \ + ({\ + int ret,dmy;\ + __asm__ volatile(\ + "mull %3"\ + :"=d"(ret),"=a"(dmy)\ + :"1"(a),"g"(ff_inverse[b])\ + );\ + ret;\ + }) +#elif HAVE_ARMV6 +static inline av_const int FASTDIV(int a, int b) +{ + int r, t; + __asm__ volatile("cmp %3, #2 \n\t" + "ldr %1, [%4, %3, lsl #2] \n\t" + "lsrle %0, %2, #1 \n\t" + "smmulgt %0, %1, %2 \n\t" + : "=&r"(r), "=&r"(t) : "r"(a), "r"(b), "r"(ff_inverse)); + return r; +} +#elif ARCH_ARM +static inline av_const int FASTDIV(int a, int b) +{ + int r, t; + __asm__ volatile ("umull %1, %0, %2, %3" + : "=&r"(r), "=&r"(t) : "r"(a), "r"(ff_inverse[b])); + return r; +} +#elif CONFIG_FASTDIV +# define FASTDIV(a,b) ((uint32_t)((((uint64_t)a)*ff_inverse[b])>>32)) +#else +# define FASTDIV(a,b) ((a)/(b)) +#endif + +extern const uint8_t ff_sqrt_tab[256]; + +static inline av_const unsigned int ff_sqrt(unsigned int a) +{ + unsigned int b; + + if(a<255) return (ff_sqrt_tab[a+1]-1)>>4; + else if(a<(1<<12)) b= ff_sqrt_tab[a>>4 ]>>2; +#if !CONFIG_SMALL + else if(a<(1<<14)) b= ff_sqrt_tab[a>>6 ]>>1; + else if(a<(1<<16)) b= ff_sqrt_tab[a>>8 ] ; +#endif + else{ + int s= av_log2_16bit(a>>16)>>1; + unsigned int c= a>>(s+2); + b= ff_sqrt_tab[c>>(s+8)]; + b= FASTDIV(c,b) + (b<>31;\ + level= (level^mask)-mask; +#endif + +#if HAVE_CMOV +#define COPY3_IF_LT(x,y,a,b,c,d)\ +__asm__ volatile (\ + "cmpl %0, %3 \n\t"\ + "cmovl %3, %0 \n\t"\ + "cmovl %4, %1 \n\t"\ + "cmovl %5, %2 \n\t"\ + : "+&r" (x), "+&r" (a), "+r" (c)\ + : "r" (y), "r" (b), "r" (d)\ +); +#else +#define COPY3_IF_LT(x,y,a,b,c,d)\ +if((y)<(x)){\ + (x)=(y);\ + (a)=(b);\ + (c)=(d);\ +} +#endif + +/* avoid usage of dangerous/inappropriate system functions */ +#undef malloc +#define malloc please_use_av_malloc +#undef free +#define free please_use_av_free +#undef realloc +#define realloc please_use_av_realloc +#undef time +#define time time_is_forbidden_due_to_security_issues +#undef rand +#define rand rand_is_forbidden_due_to_state_trashing_use_av_random +#undef srand +#define srand srand_is_forbidden_due_to_state_trashing_use_av_random_init +#undef random +#define random random_is_forbidden_due_to_state_trashing_use_av_random +#undef sprintf +#define sprintf sprintf_is_forbidden_due_to_security_issues_use_snprintf +#undef strcat +#define strcat strcat_is_forbidden_due_to_security_issues_use_av_strlcat +#undef exit +#define exit exit_is_forbidden +#ifndef LIBAVFORMAT_BUILD +#undef printf +#define printf please_use_av_log_instead_of_printf +#undef fprintf +#define fprintf please_use_av_log_instead_of_fprintf +#undef puts +#define puts please_use_av_log_instead_of_puts +#undef perror +#define perror please_use_av_log_instead_of_perror +#endif + +#define CHECKED_ALLOCZ(p, size)\ +{\ + p= av_mallocz(size);\ + if(p==NULL && (size)!=0){\ + av_log(NULL, AV_LOG_ERROR, "Cannot allocate memory.");\ + goto fail;\ + }\ +} + +#if defined(__ICC) || defined(__SUNPRO_C) + #define DECLARE_ALIGNED(n,t,v) t v __attribute__ ((aligned (n))) + #define DECLARE_ASM_CONST(n,t,v) const t __attribute__ ((aligned (n))) v +#elif defined(__GNUC__) + #define DECLARE_ALIGNED(n,t,v) t v __attribute__ ((aligned (n))) + #define DECLARE_ASM_CONST(n,t,v) static const t v attribute_used __attribute__ ((aligned (n))) +#elif defined(_MSC_VER) + #define DECLARE_ALIGNED(n,t,v) __declspec(align(n)) t v + #define DECLARE_ASM_CONST(n,t,v) __declspec(align(n)) static const t v +#elif HAVE_INLINE_ASM + #error The asm code needs alignment, but we do not know how to do it for this compiler. +#else + #define DECLARE_ALIGNED(n,t,v) t v + #define DECLARE_ASM_CONST(n,t,v) static const t v +#endif + + +#if !HAVE_LLRINT +static av_always_inline av_const long long llrint(double x) +{ + return rint(x); +} +#endif /* HAVE_LLRINT */ + +#if !HAVE_LRINT +static av_always_inline av_const long int lrint(double x) +{ + return rint(x); +} +#endif /* HAVE_LRINT */ + +#if !HAVE_LRINTF +static av_always_inline av_const long int lrintf(float x) +{ + return (int)(rint(x)); +} +#endif /* HAVE_LRINTF */ + +#if !HAVE_ROUND +static av_always_inline av_const double round(double x) +{ + return (x > 0) ? floor(x + 0.5) : ceil(x - 0.5); +} +#endif /* HAVE_ROUND */ + +#if !HAVE_ROUNDF +static av_always_inline av_const float roundf(float x) +{ + return (x > 0) ? floor(x + 0.5) : ceil(x - 0.5); +} +#endif /* HAVE_ROUNDF */ + +#if !HAVE_TRUNCF +static av_always_inline av_const float truncf(float x) +{ + return (x > 0) ? floor(x) : ceil(x); +} +#endif /* HAVE_TRUNCF */ + +/** + * Returns NULL if CONFIG_SMALL is true, otherwise the argument + * without modification. Used to disable the definition of strings + * (for example AVCodec long_names). + */ +#if CONFIG_SMALL +# define NULL_IF_CONFIG_SMALL(x) NULL +#else +# define NULL_IF_CONFIG_SMALL(x) x +#endif + +#endif /* AVUTIL_INTERNAL_H */ diff --git a/libavutil/intreadwrite.h b/libavutil/intreadwrite.h new file mode 100644 index 0000000..7c5909e --- /dev/null +++ b/libavutil/intreadwrite.h @@ -0,0 +1,192 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_INTREADWRITE_H +#define AVUTIL_INTREADWRITE_H + +#include +#include "config.h" +#include "bswap.h" + +#ifdef __GNUC__ + +struct unaligned_64 { uint64_t l; } __attribute__((packed)); +struct unaligned_32 { uint32_t l; } __attribute__((packed)); +struct unaligned_16 { uint16_t l; } __attribute__((packed)); + +#define AV_RN16(a) (((const struct unaligned_16 *) (a))->l) +#define AV_RN32(a) (((const struct unaligned_32 *) (a))->l) +#define AV_RN64(a) (((const struct unaligned_64 *) (a))->l) + +#define AV_WN16(a, b) (((struct unaligned_16 *) (a))->l) = (b) +#define AV_WN32(a, b) (((struct unaligned_32 *) (a))->l) = (b) +#define AV_WN64(a, b) (((struct unaligned_64 *) (a))->l) = (b) + +#elif defined(__DECC) + +#define AV_RN16(a) (*((const __unaligned uint16_t*)(a))) +#define AV_RN32(a) (*((const __unaligned uint32_t*)(a))) +#define AV_RN64(a) (*((const __unaligned uint64_t*)(a))) + +#define AV_WN16(a, b) *((__unaligned uint16_t*)(a)) = (b) +#define AV_WN32(a, b) *((__unaligned uint32_t*)(a)) = (b) +#define AV_WN64(a, b) *((__unaligned uint64_t*)(a)) = (b) + +#else + +#define AV_RN16(a) (*((const uint16_t*)(a))) +#define AV_RN32(a) (*((const uint32_t*)(a))) +#define AV_RN64(a) (*((const uint64_t*)(a))) + +#define AV_WN16(a, b) *((uint16_t*)(a)) = (b) +#define AV_WN32(a, b) *((uint32_t*)(a)) = (b) +#define AV_WN64(a, b) *((uint64_t*)(a)) = (b) + +#endif /* !__GNUC__ */ + +/* endian macros */ +#define AV_RB8(x) (((const uint8_t*)(x))[0]) +#define AV_WB8(p, d) do { ((uint8_t*)(p))[0] = (d); } while(0) + +#define AV_RL8(x) AV_RB8(x) +#define AV_WL8(p, d) AV_WB8(p, d) + +#if HAVE_FAST_UNALIGNED +# ifdef WORDS_BIGENDIAN +# define AV_RB16(x) AV_RN16(x) +# define AV_WB16(p, d) AV_WN16(p, d) + +# define AV_RL16(x) bswap_16(AV_RN16(x)) +# define AV_WL16(p, d) AV_WN16(p, bswap_16(d)) + +# define AV_RB32(x) AV_RN32(x) +# define AV_WB32(p, d) AV_WN32(p, d) + +# define AV_RL32(x) bswap_32(AV_RN32(x)) +# define AV_WL32(p, d) AV_WN32(p, bswap_32(d)) + +# define AV_RB64(x) AV_RN64(x) +# define AV_WB64(p, d) AV_WN64(p, d) + +# define AV_RL64(x) bswap_64(AV_RN64(x)) +# define AV_WL64(p, d) AV_WN64(p, bswap_64(d)) +# else /* WORDS_BIGENDIAN */ +# define AV_RB16(x) bswap_16(AV_RN16(x)) +# define AV_WB16(p, d) AV_WN16(p, bswap_16(d)) + +# define AV_RL16(x) AV_RN16(x) +# define AV_WL16(p, d) AV_WN16(p, d) + +# define AV_RB32(x) bswap_32(AV_RN32(x)) +# define AV_WB32(p, d) AV_WN32(p, bswap_32(d)) + +# define AV_RL32(x) AV_RN32(x) +# define AV_WL32(p, d) AV_WN32(p, d) + +# define AV_RB64(x) bswap_64(AV_RN64(x)) +# define AV_WB64(p, d) AV_WN64(p, bswap_64(d)) + +# define AV_RL64(x) AV_RN64(x) +# define AV_WL64(p, d) AV_WN64(p, d) +# endif +#else /* HAVE_FAST_UNALIGNED */ +#define AV_RB16(x) ((((const uint8_t*)(x))[0] << 8) | ((const uint8_t*)(x))[1]) +#define AV_WB16(p, d) do { \ + ((uint8_t*)(p))[1] = (d); \ + ((uint8_t*)(p))[0] = (d)>>8; } while(0) + +#define AV_RL16(x) ((((const uint8_t*)(x))[1] << 8) | \ + ((const uint8_t*)(x))[0]) +#define AV_WL16(p, d) do { \ + ((uint8_t*)(p))[0] = (d); \ + ((uint8_t*)(p))[1] = (d)>>8; } while(0) + +#define AV_RB32(x) ((((const uint8_t*)(x))[0] << 24) | \ + (((const uint8_t*)(x))[1] << 16) | \ + (((const uint8_t*)(x))[2] << 8) | \ + ((const uint8_t*)(x))[3]) +#define AV_WB32(p, d) do { \ + ((uint8_t*)(p))[3] = (d); \ + ((uint8_t*)(p))[2] = (d)>>8; \ + ((uint8_t*)(p))[1] = (d)>>16; \ + ((uint8_t*)(p))[0] = (d)>>24; } while(0) + +#define AV_RL32(x) ((((const uint8_t*)(x))[3] << 24) | \ + (((const uint8_t*)(x))[2] << 16) | \ + (((const uint8_t*)(x))[1] << 8) | \ + ((const uint8_t*)(x))[0]) +#define AV_WL32(p, d) do { \ + ((uint8_t*)(p))[0] = (d); \ + ((uint8_t*)(p))[1] = (d)>>8; \ + ((uint8_t*)(p))[2] = (d)>>16; \ + ((uint8_t*)(p))[3] = (d)>>24; } while(0) + +#define AV_RB64(x) (((uint64_t)((const uint8_t*)(x))[0] << 56) | \ + ((uint64_t)((const uint8_t*)(x))[1] << 48) | \ + ((uint64_t)((const uint8_t*)(x))[2] << 40) | \ + ((uint64_t)((const uint8_t*)(x))[3] << 32) | \ + ((uint64_t)((const uint8_t*)(x))[4] << 24) | \ + ((uint64_t)((const uint8_t*)(x))[5] << 16) | \ + ((uint64_t)((const uint8_t*)(x))[6] << 8) | \ + (uint64_t)((const uint8_t*)(x))[7]) +#define AV_WB64(p, d) do { \ + ((uint8_t*)(p))[7] = (d); \ + ((uint8_t*)(p))[6] = (d)>>8; \ + ((uint8_t*)(p))[5] = (d)>>16; \ + ((uint8_t*)(p))[4] = (d)>>24; \ + ((uint8_t*)(p))[3] = (d)>>32; \ + ((uint8_t*)(p))[2] = (d)>>40; \ + ((uint8_t*)(p))[1] = (d)>>48; \ + ((uint8_t*)(p))[0] = (d)>>56; } while(0) + +#define AV_RL64(x) (((uint64_t)((const uint8_t*)(x))[7] << 56) | \ + ((uint64_t)((const uint8_t*)(x))[6] << 48) | \ + ((uint64_t)((const uint8_t*)(x))[5] << 40) | \ + ((uint64_t)((const uint8_t*)(x))[4] << 32) | \ + ((uint64_t)((const uint8_t*)(x))[3] << 24) | \ + ((uint64_t)((const uint8_t*)(x))[2] << 16) | \ + ((uint64_t)((const uint8_t*)(x))[1] << 8) | \ + (uint64_t)((const uint8_t*)(x))[0]) +#define AV_WL64(p, d) do { \ + ((uint8_t*)(p))[0] = (d); \ + ((uint8_t*)(p))[1] = (d)>>8; \ + ((uint8_t*)(p))[2] = (d)>>16; \ + ((uint8_t*)(p))[3] = (d)>>24; \ + ((uint8_t*)(p))[4] = (d)>>32; \ + ((uint8_t*)(p))[5] = (d)>>40; \ + ((uint8_t*)(p))[6] = (d)>>48; \ + ((uint8_t*)(p))[7] = (d)>>56; } while(0) +#endif /* HAVE_FAST_UNALIGNED */ + +#define AV_RB24(x) ((((const uint8_t*)(x))[0] << 16) | \ + (((const uint8_t*)(x))[1] << 8) | \ + ((const uint8_t*)(x))[2]) +#define AV_WB24(p, d) do { \ + ((uint8_t*)(p))[2] = (d); \ + ((uint8_t*)(p))[1] = (d)>>8; \ + ((uint8_t*)(p))[0] = (d)>>16; } while(0) + +#define AV_RL24(x) ((((const uint8_t*)(x))[2] << 16) | \ + (((const uint8_t*)(x))[1] << 8) | \ + ((const uint8_t*)(x))[0]) +#define AV_WL24(p, d) do { \ + ((uint8_t*)(p))[0] = (d); \ + ((uint8_t*)(p))[1] = (d)>>8; \ + ((uint8_t*)(p))[2] = (d)>>16; } while(0) + +#endif /* AVUTIL_INTREADWRITE_H */ diff --git a/libavutil/mem.h b/libavutil/mem.h new file mode 100644 index 0000000..e50553a --- /dev/null +++ b/libavutil/mem.h @@ -0,0 +1,104 @@ +/* + * copyright (c) 2006 Michael Niedermayer + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file libavutil/mem.h + * memory handling functions + */ + +#ifndef AVUTIL_MEM_H +#define AVUTIL_MEM_H + +#include "common.h" + +#if AV_GCC_VERSION_AT_LEAST(3,1) + #define av_malloc_attrib __attribute__((__malloc__)) +#else + #define av_malloc_attrib +#endif + +#if (!defined(__ICC) || __ICC > 1100) && AV_GCC_VERSION_AT_LEAST(4,3) + #define av_alloc_size(n) __attribute__((alloc_size(n))) +#else + #define av_alloc_size(n) +#endif + +/** + * Allocates a block of \p size bytes with alignment suitable for all + * memory accesses (including vectors if available on the CPU). + * @param size Size in bytes for the memory block to be allocated. + * @return Pointer to the allocated block, NULL if the block cannot + * be allocated. + * @see av_mallocz() + */ +void *av_malloc(unsigned int size) av_malloc_attrib av_alloc_size(1); + +/** + * Allocates or reallocates a block of memory. + * If \p ptr is NULL and \p size > 0, allocates a new block. If \p + * size is zero, frees the memory block pointed to by \p ptr. + * @param size Size in bytes for the memory block to be allocated or + * reallocated. + * @param ptr Pointer to a memory block already allocated with + * av_malloc(z)() or av_realloc() or NULL. + * @return Pointer to a newly reallocated block or NULL if the block + * cannot be reallocated or the function is used to free the memory block. + * @see av_fast_realloc() + */ +void *av_realloc(void *ptr, unsigned int size) av_alloc_size(2); + +/** + * Frees a memory block which has been allocated with av_malloc(z)() or + * av_realloc(). + * @param ptr Pointer to the memory block which should be freed. + * @note ptr = NULL is explicitly allowed. + * @note It is recommended that you use av_freep() instead. + * @see av_freep() + */ +void av_free(void *ptr); + +/** + * Allocates a block of \p size bytes with alignment suitable for all + * memory accesses (including vectors if available on the CPU) and + * zeroes all the bytes of the block. + * @param size Size in bytes for the memory block to be allocated. + * @return Pointer to the allocated block, NULL if it cannot be allocated. + * @see av_malloc() + */ +void *av_mallocz(unsigned int size) av_malloc_attrib av_alloc_size(1); + +/** + * Duplicates the string \p s. + * @param s string to be duplicated + * @return Pointer to a newly allocated string containing a + * copy of \p s or NULL if the string cannot be allocated. + */ +char *av_strdup(const char *s) av_malloc_attrib; + +/** + * Frees a memory block which has been allocated with av_malloc(z)() or + * av_realloc() and set the pointer pointing to it to NULL. + * @param ptr Pointer to the pointer to the memory block which should + * be freed. + * @see av_free() + */ +void av_freep(void *ptr); + +#endif /* AVUTIL_MEM_H */ diff --git a/libavutil/timer.h b/libavutil/timer.h new file mode 100644 index 0000000..709e12f --- /dev/null +++ b/libavutil/timer.h @@ -0,0 +1,104 @@ +/** + * @file libavutil/timer.h + * high precision timer, useful to profile code + * + * copyright (c) 2006 Michael Niedermayer + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_TIMER_H +#define AVUTIL_TIMER_H + +#include +#include +#include "config.h" + +#if ARCH_X86 || ARCH_PPC || ARCH_BFIN +#define AV_READ_TIME read_time +#if ARCH_X86 +static inline uint64_t read_time(void) +{ + uint32_t a, d; + __asm__ volatile("rdtsc\n\t" + : "=a" (a), "=d" (d)); + return ((uint64_t)d << 32) + a; +} +#elif ARCH_BFIN +static inline uint64_t read_time(void) +{ + union { + struct { + unsigned lo; + unsigned hi; + } p; + unsigned long long c; + } t; + __asm__ volatile ("%0=cycles; %1=cycles2;" : "=d" (t.p.lo), "=d" (t.p.hi)); + return t.c; +} +#else //FIXME check ppc64 +static inline uint64_t read_time(void) +{ + uint32_t tbu, tbl, temp; + + /* from section 2.2.1 of the 32-bit PowerPC PEM */ + __asm__ volatile( + "1:\n" + "mftbu %2\n" + "mftb %0\n" + "mftbu %1\n" + "cmpw %2,%1\n" + "bne 1b\n" + : "=r"(tbl), "=r"(tbu), "=r"(temp) + : + : "cc"); + + return (((uint64_t)tbu)<<32) | (uint64_t)tbl; +} +#endif +#elif HAVE_GETHRTIME +#define AV_READ_TIME gethrtime +#endif + +#ifdef AV_READ_TIME +#define START_TIMER \ +uint64_t tend;\ +uint64_t tstart= AV_READ_TIME();\ + +#define STOP_TIMER(id) \ +tend= AV_READ_TIME();\ +{\ + static uint64_t tsum=0;\ + static int tcount=0;\ + static int tskip_count=0;\ + if(tcount<2 || tend - tstart < 8*tsum/tcount || tend - tstart < 2000){\ + tsum+= tend - tstart;\ + tcount++;\ + }else\ + tskip_count++;\ + if(((tcount+tskip_count)&(tcount+tskip_count-1))==0){\ + av_log(NULL, AV_LOG_ERROR, "%"PRIu64" dezicycles in %s, %d runs, %d skips\n",\ + tsum*10/tcount, id, tcount, tskip_count);\ + }\ +} +#else +#define START_TIMER +#define STOP_TIMER(id) {} +#endif + +#endif /* AVUTIL_TIMER_H */ diff --git a/libavutil/x86/bswap.h b/libavutil/x86/bswap.h new file mode 100644 index 0000000..3eeb5a4 --- /dev/null +++ b/libavutil/x86/bswap.h @@ -0,0 +1,61 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file libavutil/x86/bswap.h + * byte swapping routines + */ + +#ifndef AVUTIL_X86_BSWAP_H +#define AVUTIL_X86_BSWAP_H + +#include +#include "config.h" +#include "libavutil/common.h" + +#define bswap_16 bswap_16 +static av_always_inline av_const uint16_t bswap_16(uint16_t x) +{ + __asm__("rorw $8, %0" : "+r"(x)); + return x; +} + +#define bswap_32 bswap_32 +static av_always_inline av_const uint32_t bswap_32(uint32_t x) +{ +#if HAVE_BSWAP + __asm__("bswap %0" : "+r" (x)); +#else + __asm__("rorw $8, %w0 \n\t" + "rorl $16, %0 \n\t" + "rorw $8, %w0" + : "+r"(x)); +#endif + return x; +} + +#if ARCH_X86_64 +#define bswap_64 bswap_64 +static inline uint64_t av_const bswap_64(uint64_t x) +{ + __asm__("bswap %0": "=r" (x) : "0" (x)); + return x; +} +#endif + +#endif /* AVUTIL_X86_BSWAP_H */ diff --git a/libdvdcss/bsdi_dvd.h b/libdvdcss/bsdi_dvd.h deleted file mode 100644 index f4c8b89..0000000 --- a/libdvdcss/bsdi_dvd.h +++ /dev/null @@ -1,344 +0,0 @@ -/* - * $Id$ -*/ - -#ifndef DVDCSS_DVD_H -#define DVDCSS_DVD_H - -#include -#include -#include - -__BEGIN_DECLS -int dvd_cdrom_ioctl(int, unsigned long, void *); -int cdrom_blocksize(int, int); -void dvd_cdrom_debug(int); -__END_DECLS - -#define ioctl(a,b,c) dvd_cdrom_ioctl((a),(b),(c)) - -typedef unsigned char __u8; -typedef unsigned short __u16; -typedef unsigned int __u32; - -#define DVD_READ_STRUCT 0x5390 /* Read structure */ -#define DVD_WRITE_STRUCT 0x5391 /* Write structure */ -#define DVD_AUTH 0x5392 /* Authentication */ - -#define DVD_STRUCT_PHYSICAL 0x00 -#define DVD_STRUCT_COPYRIGHT 0x01 -#define DVD_STRUCT_DISCKEY 0x02 -#define DVD_STRUCT_BCA 0x03 -#define DVD_STRUCT_MANUFACT 0x04 - -struct dvd_layer { - __u8 book_version : 4; - __u8 book_type : 4; - __u8 min_rate : 4; - __u8 disc_size : 4; - __u8 layer_type : 4; - __u8 track_path : 1; - __u8 nlayers : 2; - __u8 track_density : 4; - __u8 linear_density : 4; - __u8 bca : 1; - __u32 start_sector; - __u32 end_sector; - __u32 end_sector_l0; -}; - -struct dvd_physical { - __u8 type; - __u8 layer_num; - struct dvd_layer layer[4]; -}; - -struct dvd_copyright { - __u8 type; - - __u8 layer_num; - __u8 cpst; - __u8 rmi; -}; - -struct dvd_disckey { - __u8 type; - - unsigned agid : 2; - __u8 value[2048]; -}; - -struct dvd_bca { - __u8 type; - - int len; - __u8 value[188]; -}; - -struct dvd_manufact { - __u8 type; - - __u8 layer_num; - int len; - __u8 value[2048]; -}; - -typedef union { - __u8 type; - - struct dvd_physical physical; - struct dvd_copyright copyright; - struct dvd_disckey disckey; - struct dvd_bca bca; - struct dvd_manufact manufact; -} dvd_struct; - -/* - * DVD authentication ioctl - */ - -/* Authentication states */ -#define DVD_LU_SEND_AGID 0 -#define DVD_HOST_SEND_CHALLENGE 1 -#define DVD_LU_SEND_KEY1 2 -#define DVD_LU_SEND_CHALLENGE 3 -#define DVD_HOST_SEND_KEY2 4 - -/* Termination states */ -#define DVD_AUTH_ESTABLISHED 5 -#define DVD_AUTH_FAILURE 6 - -/* Other functions */ -#define DVD_LU_SEND_TITLE_KEY 7 -#define DVD_LU_SEND_ASF 8 -#define DVD_INVALIDATE_AGID 9 -#define DVD_LU_SEND_RPC_STATE 10 -#define DVD_HOST_SEND_RPC_STATE 11 - -/* State data */ -typedef __u8 dvd_key[5]; /* 40-bit value, MSB is first elem. */ -typedef __u8 dvd_challenge[10]; /* 80-bit value, MSB is first elem. */ - -struct dvd_lu_send_agid { - __u8 type; - unsigned agid : 2; -}; - -struct dvd_host_send_challenge { - __u8 type; - unsigned agid : 2; - - dvd_challenge chal; -}; - -struct dvd_send_key { - __u8 type; - unsigned agid : 2; - - dvd_key key; -}; - -struct dvd_lu_send_challenge { - __u8 type; - unsigned agid : 2; - - dvd_challenge chal; -}; - -#define DVD_CPM_NO_COPYRIGHT 0 -#define DVD_CPM_COPYRIGHTED 1 - -#define DVD_CP_SEC_NONE 0 -#define DVD_CP_SEC_EXIST 1 - -#define DVD_CGMS_UNRESTRICTED 0 -#define DVD_CGMS_SINGLE 2 -#define DVD_CGMS_RESTRICTED 3 - -struct dvd_lu_send_title_key { - __u8 type; - unsigned agid : 2; - - dvd_key title_key; - int lba; - unsigned cpm : 1; - unsigned cp_sec : 1; - unsigned cgms : 2; -}; - -struct dvd_lu_send_asf { - __u8 type; - unsigned agid : 2; - - unsigned asf : 1; -}; - -struct dvd_host_send_rpcstate { - __u8 type; - __u8 pdrc; -}; - -struct dvd_lu_send_rpcstate { - __u8 type : 2; - __u8 vra : 3; - __u8 ucca : 3; - __u8 region_mask; - __u8 rpc_scheme; -}; - -typedef union { - __u8 type; - - struct dvd_lu_send_agid lsa; - struct dvd_host_send_challenge hsc; - struct dvd_send_key lsk; - struct dvd_lu_send_challenge lsc; - struct dvd_send_key hsk; - struct dvd_lu_send_title_key lstk; - struct dvd_lu_send_asf lsasf; - struct dvd_host_send_rpcstate hrpcs; - struct dvd_lu_send_rpcstate lrpcs; -} dvd_authinfo; - - -typedef struct { - __u16 report_key_length; - __u8 reserved1; - __u8 reserved2; -#if BYTE_ORDER == BIG_ENDIAN - __u8 type_code : 2; - __u8 vra : 3; - __u8 ucca : 3; -#elif BYTE_ORDER == LITTLE_ENDIAN - __u8 ucca : 3; - __u8 vra : 3; - __u8 type_code : 2; -#endif - __u8 region_mask; - __u8 rpc_scheme; - __u8 reserved3; -} rpc_state_t; - -/* - * Stuff for the CDROM ioctls -*/ - -#define CDROMREADTOCHDR 0x5305 /* Read TOC header (cdrom_tochdr) */ -#define CDROMREADTOCENTRY 0x5306 /* Read TOC entry (cdrom_tocentry) */ -#define CDROMEJECT 0x5309 /* Ejects the cdrom media */ -#define CDROMCLOSETRAY 0x5319 /* Reverse of CDROMEJECT */ -#define CDROM_DRIVE_STATUS 0x5326 /* Get tray position, etc. */ -#define CDROM_DISC_STATUS 0x5327 /* Get disc type, etc. */ -#define CDROMREADMODE2 0x530c /* Read CDROM mode 2 data (2336 Bytes) */ -#define CDROMREADMODE1 0x530d /* Read CDROM mode 1 data (2048 Bytes) */ -#define CDROMREADRAW 0x5314 /* read data in raw mode (2352 bytes) */ - -#define CD_MINS 74 /* max. minutes per CD, not really a limit */ -#define CD_SECS 60 /* seconds per minute */ -#define CD_FRAMES 75 /* frames per second */ -#define CD_MSF_OFFSET 150 /* MSF numbering offset of first frame */ - -#define CD_HEAD_SIZE 4 /* header (address) bytes per raw data frame */ -#define CD_SYNC_SIZE 12 /* 12 sync bytes per raw data frame */ -#define CD_FRAMESIZE 2048 /* bytes per frame, "cooked" mode */ -#define CD_FRAMESIZE_RAW 2352 /* bytes per frame, "raw" mode */ -#define CD_FRAMESIZE_RAW0 (CD_FRAMESIZE_RAW-CD_SYNC_SIZE-CD_HEAD_SIZE) /*2336*/ -#define CD_FRAMESIZE_RAW1 (CD_FRAMESIZE_RAW-CD_SYNC_SIZE) /*2340*/ - -/* CD-ROM address types (cdrom_tocentry.cdte_format) */ -#define CDROM_LBA 0x01 /* logical block: first frame is #0 */ -#define CDROM_MSF 0x02 /* minute-second-frame: binary. not bcd here!*/ - -/* bit to tell whether track is data or audio (cdrom_tocentry.cdte_ctrl) */ -#define CDROM_DATA_TRACK 0x04 - -/* The leadout track is always 0xAA, regardless of # of tracks on disc */ -#define CDROM_LEADOUT 0xAA - -/* drive status returned by CDROM_DRIVE_STATUS ioctl */ -#define CDS_NO_INFO 0 /* if not implemented */ -#define CDS_NO_DISC 1 -#define CDS_TRAY_OPEN 2 -#define CDS_DRIVE_NOT_READY 3 -#define CDS_DISC_OK 4 - -/* - * Return values for CDROM_DISC_STATUS ioctl. - * Can also return CDS_NO_INFO and CDS_NO_DISC from above -*/ -#define CDS_AUDIO 100 -#define CDS_DATA_1 101 -#define CDS_DATA_2 102 -#define CDS_XA_2_1 103 -#define CDS_XA_2_2 104 -#define CDS_MIXED 105 - -/* For compile compatibility only - we don't support changers */ -#define CDSL_NONE ((int) (~0U>>1)-1) -#define CDSL_CURRENT ((int) (~0U>>1)) - -struct cdrom_msf -{ - __u8 cdmsf_min0; /* start minute */ - __u8 cdmsf_sec0; /* start second */ - __u8 cdmsf_frame0; /* start frame */ - __u8 cdmsf_min1; /* end minute */ - __u8 cdmsf_sec1; /* end second */ - __u8 cdmsf_frame1; /* end frame */ -}; - -struct cdrom_tochdr - { - __u8 cdth_trk0; /* start track */ - __u8 cdth_trk1; /* end track */ - }; - -struct cdrom_msf0 -{ - __u8 minute; - __u8 second; - __u8 frame; -}; - -union cdrom_addr -{ - struct cdrom_msf0 msf; - int lba; -}; - -struct cdrom_tocentry -{ - __u8 cdte_track; - __u8 cdte_adr :4; - __u8 cdte_ctrl :4; - __u8 cdte_format; - union cdrom_addr cdte_addr; - __u8 cdte_datamode; -}; - -struct modesel_head -{ - __u8 reserved1; - __u8 medium; - __u8 reserved2; - __u8 block_desc_length; - __u8 density; - __u8 number_of_blocks_hi; - __u8 number_of_blocks_med; - __u8 number_of_blocks_lo; - __u8 reserved3; - __u8 block_length_hi; - __u8 block_length_med; - __u8 block_length_lo; -}; - -typedef struct -{ - int data; - int audio; - int cdi; - int xa; - int error; -} tracktype; - -#endif /* DVDCSS_DVD_H */ diff --git a/libdvdcss/common.h b/libdvdcss/common.h deleted file mode 100644 index aff5ccb..0000000 --- a/libdvdcss/common.h +++ /dev/null @@ -1,81 +0,0 @@ -/***************************************************************************** - * common.h: common definitions - * Collection of useful common types and macros definitions - ***************************************************************************** - * Copyright (C) 1998, 1999, 2000 VideoLAN - * $Id$ - * - * Authors: Sam Hocevar - * Vincent Seguin - * Gildas Bazin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. - *****************************************************************************/ - -/***************************************************************************** - * Basic types definitions - *****************************************************************************/ -#if defined( HAVE_STDINT_H ) -# include -#elif defined( HAVE_INTTYPES_H ) -# include -#elif defined( SYS_CYGWIN ) -# include - /* Cygwin only defines half of these... */ - typedef u_int8_t uint8_t; - typedef u_int32_t uint32_t; -#else - /* Fallback types (very x86-centric, sorry) */ - typedef unsigned char uint8_t; - typedef signed char int8_t; - typedef unsigned int uint32_t; - typedef signed int int32_t; -#endif - -#if defined( WIN32 ) - -# ifndef PATH_MAX -# define PATH_MAX MAX_PATH -# endif - -/* several type definitions */ -# if defined( __MINGW32__ ) -# define lseek _lseeki64 -# if !defined( _OFF_T_ ) -typedef long long _off_t; -typedef _off_t off_t; -# define _OFF_T_ -# else -# define off_t long long -# endif -# endif - -# if defined( _MSC_VER ) -# define lseek _lseeki64 -# if !defined( _OFF_T_DEFINED ) -typedef __int64 off_t; -# define _OFF_T_DEFINED -# else -# define off_t __int64 -# endif -# define stat _stati64 -# endif - -# ifndef snprintf -# define snprintf _snprintf /* snprintf not defined in mingw32 (bug?) */ -# endif - -#endif - diff --git a/libdvdcss/css.c b/libdvdcss/css.c deleted file mode 100644 index 4e24bbf..0000000 --- a/libdvdcss/css.c +++ /dev/null @@ -1,1696 +0,0 @@ -/***************************************************************************** - * css.c: Functions for DVD authentication and descrambling - ***************************************************************************** - * Copyright (C) 1999-2008 VideoLAN - * $Id$ - * - * Authors: Stéphane Borel - * Håkan Hjort - * - * based on: - * - css-auth by Derek Fawcus - * - DVD CSS ioctls example program by Andrew T. Veliath - * - The Divide and conquer attack by Frank A. Stevenson - * (see http://www-2.cs.cmu.edu/~dst/DeCSS/FrankStevenson/index.html) - * - DeCSSPlus by Ethan Hawke - * - DecVOB - * see http://www.lemuria.org/DeCSS/ by Tom Vogt for more information. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. - *****************************************************************************/ - -/***************************************************************************** - * Preamble - *****************************************************************************/ -#include "config.h" - -#include -#include -#include -#include -#include -#ifdef HAVE_SYS_PARAM_H -# include -#endif -#ifdef HAVE_UNISTD_H -# include -#endif -#include - -#ifdef HAVE_LIMITS_H -# include -#endif - -#include "dvdcss/dvdcss.h" - -#include "common.h" -#include "css.h" -#include "libdvdcss.h" -#include "csstables.h" -#include "ioctl.h" -#include "device.h" - -/***************************************************************************** - * Local prototypes - *****************************************************************************/ -static void PrintKey ( dvdcss_t, char *, uint8_t const * ); - -static int GetBusKey ( dvdcss_t ); -static int GetASF ( dvdcss_t ); - -static void CryptKey ( int, int, uint8_t const *, uint8_t * ); -static void DecryptKey ( uint8_t, - uint8_t const *, uint8_t const *, uint8_t * ); - -static int DecryptDiscKey ( dvdcss_t, uint8_t const *, dvd_key_t ); -static int CrackDiscKey ( dvdcss_t, uint8_t * ); - -static void DecryptTitleKey ( dvd_key_t, dvd_key_t ); -static int RecoverTitleKey ( int, uint8_t const *, - uint8_t const *, uint8_t const *, uint8_t * ); -static int CrackTitleKey ( dvdcss_t, int, int, dvd_key_t ); - -static int AttackPattern ( uint8_t const[], int, uint8_t * ); -#if 0 -static int AttackPadding ( uint8_t const[], int, uint8_t * ); -#endif - -/***************************************************************************** - * _dvdcss_test: check if the disc is encrypted or not - *****************************************************************************/ -int _dvdcss_test( dvdcss_t dvdcss ) -{ - int i_ret, i_copyright; - - i_ret = ioctl_ReadCopyright( dvdcss->i_fd, 0 /* i_layer */, &i_copyright ); - -#ifdef WIN32 - if( i_ret < 0 ) - { - /* Maybe we didn't have enough privileges to read the copyright - * (see ioctl_ReadCopyright comments). - * Apparently, on unencrypted DVDs _dvdcss_disckey() always fails, so - * we can check this as a workaround. */ - i_ret = 0; - i_copyright = 1; - if( _dvdcss_disckey( dvdcss ) < 0 ) - { - i_copyright = 0; - } - } -#endif - - if( i_ret < 0 ) - { - /* Since it's the first ioctl we try to issue, we add a notice */ - print_error( dvdcss, "css error: ioctl_ReadCopyright failed, " - "make sure there is a DVD in the drive, and that " - "you have used the correct device node." ); - - return i_ret; - } - - return i_copyright; -} - -/***************************************************************************** - * _dvdcss_title: crack or decrypt the current title key if needed - ***************************************************************************** - * This function should only be called by dvdcss->pf_seek and should eventually - * not be external if possible. - *****************************************************************************/ -int _dvdcss_title ( dvdcss_t dvdcss, int i_block ) -{ - dvd_title_t *p_title; - dvd_title_t *p_newtitle; - dvd_key_t p_title_key; - int i_fd, i_ret = -1, b_cache = 0; - - if( ! dvdcss->b_scrambled ) - { - return 0; - } - - /* Check if we've already cracked this key */ - p_title = dvdcss->p_titles; - while( p_title != NULL - && p_title->p_next != NULL - && p_title->p_next->i_startlb <= i_block ) - { - p_title = p_title->p_next; - } - - if( p_title != NULL - && p_title->i_startlb == i_block ) - { - /* We've already cracked this key, nothing to do */ - memcpy( dvdcss->css.p_title_key, p_title->p_key, sizeof(dvd_key_t) ); - return 0; - } - - /* Check whether the key is in our disk cache */ - if( dvdcss->psz_cachefile[0] ) - { - /* XXX: be careful, we use sprintf and not snprintf */ - sprintf( dvdcss->psz_block, "%.10x", i_block ); - i_fd = open( dvdcss->psz_cachefile, O_RDONLY ); - b_cache = 1; - - if( i_fd >= 0 ) - { - char psz_key[KEY_SIZE * 3]; - unsigned int k0, k1, k2, k3, k4; - - psz_key[KEY_SIZE * 3 - 1] = '\0'; - - if( read( i_fd, psz_key, KEY_SIZE * 3 - 1 ) == KEY_SIZE * 3 - 1 - && sscanf( psz_key, "%x:%x:%x:%x:%x", - &k0, &k1, &k2, &k3, &k4 ) == 5 ) - { - p_title_key[0] = k0; - p_title_key[1] = k1; - p_title_key[2] = k2; - p_title_key[3] = k3; - p_title_key[4] = k4; - PrintKey( dvdcss, "title key found in cache ", p_title_key ); - - /* Don't try to save it again */ - b_cache = 0; - i_ret = 1; - } - - close( i_fd ); - } - } - - /* Crack or decrypt CSS title key for current VTS */ - if( i_ret < 0 ) - { - i_ret = _dvdcss_titlekey( dvdcss, i_block, p_title_key ); - - if( i_ret < 0 ) - { - print_error( dvdcss, "fatal error in vts css key" ); - return i_ret; - } - - if( i_ret == 0 ) - { - print_debug( dvdcss, "unencrypted title" ); - /* We cache this anyway, so we don't need to check again. */ - } - } - - /* Key is valid, we store it on disk. */ - if( dvdcss->psz_cachefile[0] && b_cache ) - { - i_fd = open( dvdcss->psz_cachefile, O_RDWR|O_CREAT, 0644 ); - if( i_fd >= 0 ) - { - char psz_key[KEY_SIZE * 3 + 2]; - - sprintf( psz_key, "%02x:%02x:%02x:%02x:%02x\r\n", - p_title_key[0], p_title_key[1], p_title_key[2], - p_title_key[3], p_title_key[4] ); - - write( i_fd, psz_key, KEY_SIZE * 3 + 1 ); - close( i_fd ); - } - } - - /* Find our spot in the list */ - p_newtitle = NULL; - p_title = dvdcss->p_titles; - while( ( p_title != NULL ) && ( p_title->i_startlb < i_block ) ) - { - p_newtitle = p_title; - p_title = p_title->p_next; - } - - /* Save the found title */ - p_title = p_newtitle; - - /* Write in the new title and its key */ - p_newtitle = malloc( sizeof( dvd_title_t ) ); - p_newtitle->i_startlb = i_block; - memcpy( p_newtitle->p_key, p_title_key, KEY_SIZE ); - - /* Link it at the head of the (possibly empty) list */ - if( p_title == NULL ) - { - p_newtitle->p_next = dvdcss->p_titles; - dvdcss->p_titles = p_newtitle; - } - /* Link the new title inside the list */ - else - { - p_newtitle->p_next = p_title->p_next; - p_title->p_next = p_newtitle; - } - - memcpy( dvdcss->css.p_title_key, p_title_key, KEY_SIZE ); - return 0; -} - -/***************************************************************************** - * _dvdcss_disckey: get disc key. - ***************************************************************************** - * This function should only be called if DVD ioctls are present. - * It will set dvdcss->i_method = DVDCSS_METHOD_TITLE if it fails to find - * a valid disc key. - * Two decryption methods are offered: - * -disc key hash crack, - * -decryption with player keys if they are available. - *****************************************************************************/ -int _dvdcss_disckey( dvdcss_t dvdcss ) -{ - unsigned char p_buffer[ DVD_DISCKEY_SIZE ]; - dvd_key_t p_disc_key; - int i; - - if( GetBusKey( dvdcss ) < 0 ) - { - return -1; - } - - /* Get encrypted disc key */ - if( ioctl_ReadDiscKey( dvdcss->i_fd, &dvdcss->css.i_agid, p_buffer ) < 0 ) - { - print_error( dvdcss, "ioctl ReadDiscKey failed" ); - return -1; - } - - /* This should have invaidated the AGID and got us ASF=1. */ - if( GetASF( dvdcss ) != 1 ) - { - /* Region mismatch (or region not set) is the most likely source. */ - print_error( dvdcss, - "ASF not 1 after reading disc key (region mismatch?)" ); - ioctl_InvalidateAgid( dvdcss->i_fd, &dvdcss->css.i_agid ); - return -1; - } - - /* Shuffle disc key using bus key */ - for( i = 0 ; i < DVD_DISCKEY_SIZE ; i++ ) - { - p_buffer[ i ] ^= dvdcss->css.p_bus_key[ 4 - (i % KEY_SIZE) ]; - } - - /* Decrypt disc key */ - switch( dvdcss->i_method ) - { - case DVDCSS_METHOD_KEY: - - /* Decrypt disc key with player key. */ - PrintKey( dvdcss, "decrypting disc key ", p_buffer ); - if( ! DecryptDiscKey( dvdcss, p_buffer, p_disc_key ) ) - { - PrintKey( dvdcss, "decrypted disc key is ", p_disc_key ); - break; - } - print_debug( dvdcss, "failed to decrypt the disc key, " - "faulty drive/kernel? " - "cracking title keys instead" ); - - /* Fallback, but not to DISC as the disc key might be faulty */ - memset( p_disc_key, 0, KEY_SIZE ); - dvdcss->i_method = DVDCSS_METHOD_TITLE; - break; - - case DVDCSS_METHOD_DISC: - - /* Crack Disc key to be able to use it */ - memcpy( p_disc_key, p_buffer, KEY_SIZE ); - PrintKey( dvdcss, "cracking disc key ", p_disc_key ); - if( ! CrackDiscKey( dvdcss, p_disc_key ) ) - { - PrintKey( dvdcss, "cracked disc key is ", p_disc_key ); - break; - } - print_debug( dvdcss, "failed to crack the disc key" ); - memset( p_disc_key, 0, KEY_SIZE ); - dvdcss->i_method = DVDCSS_METHOD_TITLE; - break; - - default: - - print_debug( dvdcss, "disc key needs not be decrypted" ); - memset( p_disc_key, 0, KEY_SIZE ); - break; - } - - memcpy( dvdcss->css.p_disc_key, p_disc_key, KEY_SIZE ); - - return 0; -} - - -/***************************************************************************** - * _dvdcss_titlekey: get title key. - *****************************************************************************/ -int _dvdcss_titlekey( dvdcss_t dvdcss, int i_pos, dvd_key_t p_title_key ) -{ - static uint8_t p_garbage[ DVDCSS_BLOCK_SIZE ]; /* we never read it back */ - uint8_t p_key[ KEY_SIZE ]; - int i, i_ret = 0; - - if( dvdcss->b_ioctls && ( dvdcss->i_method == DVDCSS_METHOD_KEY || - dvdcss->i_method == DVDCSS_METHOD_DISC ) ) - { - /* We have a decrypted Disc key and the ioctls are available, - * read the title key and decrypt it. - */ - - print_debug( dvdcss, "getting title key at block %i the classic way", - i_pos ); - - /* We need to authenticate again every time to get a new session key */ - if( GetBusKey( dvdcss ) < 0 ) - { - return -1; - } - - /* Get encrypted title key */ - if( ioctl_ReadTitleKey( dvdcss->i_fd, &dvdcss->css.i_agid, - i_pos, p_key ) < 0 ) - { - print_debug( dvdcss, - "ioctl ReadTitleKey failed (region mismatch?)" ); - i_ret = -1; - } - - /* Test ASF, it will be reset to 0 if we got a Region error */ - switch( GetASF( dvdcss ) ) - { - case -1: - /* An error getting the ASF status, something must be wrong. */ - print_debug( dvdcss, "lost ASF requesting title key" ); - ioctl_InvalidateAgid( dvdcss->i_fd, &dvdcss->css.i_agid ); - i_ret = -1; - break; - - case 0: - /* This might either be a title that has no key, - * or we encountered a region error. */ - print_debug( dvdcss, "lost ASF requesting title key" ); - break; - - case 1: - /* Drive status is ok. */ - /* If the title key request failed, but we did not loose ASF, - * we might stil have the AGID. Other code assume that we - * will not after this so invalidate it(?). */ - if( i_ret < 0 ) - { - ioctl_InvalidateAgid( dvdcss->i_fd, &dvdcss->css.i_agid ); - } - break; - } - - if( !( i_ret < 0 ) ) - { - /* Decrypt title key using the bus key */ - for( i = 0 ; i < KEY_SIZE ; i++ ) - { - p_key[ i ] ^= dvdcss->css.p_bus_key[ 4 - (i % KEY_SIZE) ]; - } - - /* If p_key is all zero then there really wasn't any key present - * even though we got to read it without an error. */ - if( !( p_key[0] | p_key[1] | p_key[2] | p_key[3] | p_key[4] ) ) - { - i_ret = 0; - } - else - { - PrintKey( dvdcss, "initial disc key ", dvdcss->css.p_disc_key ); - DecryptTitleKey( dvdcss->css.p_disc_key, p_key ); - PrintKey( dvdcss, "decrypted title key ", p_key ); - i_ret = 1; - } - - /* All went well either there wasn't a key or we have it now. */ - memcpy( p_title_key, p_key, KEY_SIZE ); - PrintKey( dvdcss, "title key is ", p_title_key ); - - return i_ret; - } - - /* The title key request failed */ - print_debug( dvdcss, "resetting drive and cracking title key" ); - - /* Read an unscrambled sector and reset the drive */ - dvdcss->pf_seek( dvdcss, 0 ); - dvdcss->pf_read( dvdcss, p_garbage, 1 ); - dvdcss->pf_seek( dvdcss, 0 ); - _dvdcss_disckey( dvdcss ); - - /* Fallback */ - } - - /* METHOD is TITLE, we can't use the ioctls or requesting the title key - * failed above. For these cases we try to crack the key instead. */ - - /* For now, the read limit is 9Gb / 2048 = 4718592 sectors. */ - i_ret = CrackTitleKey( dvdcss, i_pos, 4718592, p_key ); - - memcpy( p_title_key, p_key, KEY_SIZE ); - PrintKey( dvdcss, "title key is ", p_title_key ); - - return i_ret; -} - -/***************************************************************************** - * _dvdcss_unscramble: does the actual descrambling of data - ***************************************************************************** - * sec : sector to unscramble - * key : title key for this sector - *****************************************************************************/ -int _dvdcss_unscramble( dvd_key_t p_key, uint8_t *p_sec ) -{ - unsigned int i_t1, i_t2, i_t3, i_t4, i_t5, i_t6; - uint8_t *p_end = p_sec + DVDCSS_BLOCK_SIZE; - - /* PES_scrambling_control */ - if( !(p_sec[0x14] & 0x30) ) - { - return 0; - } - - i_t1 = (p_key[0] ^ p_sec[0x54]) | 0x100; - i_t2 = p_key[1] ^ p_sec[0x55]; - i_t3 = (p_key[2] | (p_key[3] << 8) | - (p_key[4] << 16)) ^ (p_sec[0x56] | - (p_sec[0x57] << 8) | (p_sec[0x58] << 16)); - i_t4 = i_t3 & 7; - i_t3 = i_t3 * 2 + 8 - i_t4; - p_sec += 0x80; - i_t5 = 0; - - while( p_sec != p_end ) - { - i_t4 = p_css_tab2[i_t2] ^ p_css_tab3[i_t1]; - i_t2 = i_t1>>1; - i_t1 = ( ( i_t1 & 1 ) << 8 ) ^ i_t4; - i_t4 = p_css_tab5[i_t4]; - i_t6 = ((((((( i_t3 >> 3 ) ^ i_t3 ) >> 1 ) ^ - i_t3 ) >> 8 ) ^ i_t3 ) >> 5 ) & 0xff; - i_t3 = (i_t3 << 8 ) | i_t6; - i_t6 = p_css_tab4[i_t6]; - i_t5 += i_t6 + i_t4; - *p_sec = p_css_tab1[*p_sec] ^ ( i_t5 & 0xff ); - p_sec++; - i_t5 >>= 8; - } - - return 0; -} - -/* Following functions are local */ - -/***************************************************************************** - * GetBusKey : Go through the CSS Authentication process - ***************************************************************************** - * It simulates the mutual authentication between logical unit and host, - * and stops when a session key (called bus key) has been established. - * Always do the full auth sequence. Some drives seem to lie and always - * respond with ASF=1. For instance the old DVD roms on Compaq Armada says - * that ASF=1 from the start and then later fail with a 'read of scrambled - * block without authentication' error. - *****************************************************************************/ -static int GetBusKey( dvdcss_t dvdcss ) -{ - uint8_t p_buffer[10]; - uint8_t p_challenge[2*KEY_SIZE]; - dvd_key_t p_key1; - dvd_key_t p_key2; - dvd_key_t p_key_check; - uint8_t i_variant = 0; - int i_ret = -1; - int i; - - print_debug( dvdcss, "requesting AGID" ); - i_ret = ioctl_ReportAgid( dvdcss->i_fd, &dvdcss->css.i_agid ); - - /* We might have to reset hung authentication processes in the drive - * by invalidating the corresponding AGID'. As long as we haven't got - * an AGID, invalidate one (in sequence) and try again. */ - for( i = 0; i_ret == -1 && i < 4 ; ++i ) - { - print_debug( dvdcss, "ioctl ReportAgid failed, " - "invalidating AGID %d", i ); - - /* This is really _not good_, should be handled by the OS. - * Invalidating an AGID could make another process fail somewhere - * in its authentication process. */ - dvdcss->css.i_agid = i; - ioctl_InvalidateAgid( dvdcss->i_fd, &dvdcss->css.i_agid ); - - print_debug( dvdcss, "requesting AGID" ); - i_ret = ioctl_ReportAgid( dvdcss->i_fd, &dvdcss->css.i_agid ); - } - - /* Unable to authenticate without AGID */ - if( i_ret == -1 ) - { - print_error( dvdcss, "ioctl ReportAgid failed, fatal" ); - return -1; - } - - /* Setup a challenge, any values should work */ - for( i = 0 ; i < 10; ++i ) - { - p_challenge[i] = i; - } - - /* Get challenge from host */ - for( i = 0 ; i < 10 ; ++i ) - { - p_buffer[9-i] = p_challenge[i]; - } - - /* Send challenge to LU */ - if( ioctl_SendChallenge( dvdcss->i_fd, - &dvdcss->css.i_agid, p_buffer ) < 0 ) - { - print_error( dvdcss, "ioctl SendChallenge failed" ); - ioctl_InvalidateAgid( dvdcss->i_fd, &dvdcss->css.i_agid ); - return -1; - } - - /* Get key1 from LU */ - if( ioctl_ReportKey1( dvdcss->i_fd, &dvdcss->css.i_agid, p_buffer ) < 0) - { - print_error( dvdcss, "ioctl ReportKey1 failed" ); - ioctl_InvalidateAgid( dvdcss->i_fd, &dvdcss->css.i_agid ); - return -1; - } - - /* Send key1 to host */ - for( i = 0 ; i < KEY_SIZE ; i++ ) - { - p_key1[i] = p_buffer[4-i]; - } - - for( i = 0 ; i < 32 ; ++i ) - { - CryptKey( 0, i, p_challenge, p_key_check ); - - if( memcmp( p_key_check, p_key1, KEY_SIZE ) == 0 ) - { - print_debug( dvdcss, "drive authenticated, using variant %d", i ); - i_variant = i; - break; - } - } - - if( i == 32 ) - { - print_error( dvdcss, "drive would not authenticate" ); - ioctl_InvalidateAgid( dvdcss->i_fd, &dvdcss->css.i_agid ); - return -1; - } - - /* Get challenge from LU */ - if( ioctl_ReportChallenge( dvdcss->i_fd, - &dvdcss->css.i_agid, p_buffer ) < 0 ) - { - print_error( dvdcss, "ioctl ReportKeyChallenge failed" ); - ioctl_InvalidateAgid( dvdcss->i_fd, &dvdcss->css.i_agid ); - return -1; - } - - /* Send challenge to host */ - for( i = 0 ; i < 10 ; ++i ) - { - p_challenge[i] = p_buffer[9-i]; - } - - CryptKey( 1, i_variant, p_challenge, p_key2 ); - - /* Get key2 from host */ - for( i = 0 ; i < KEY_SIZE ; ++i ) - { - p_buffer[4-i] = p_key2[i]; - } - - /* Send key2 to LU */ - if( ioctl_SendKey2( dvdcss->i_fd, &dvdcss->css.i_agid, p_buffer ) < 0 ) - { - print_error( dvdcss, "ioctl SendKey2 failed" ); - ioctl_InvalidateAgid( dvdcss->i_fd, &dvdcss->css.i_agid ); - return -1; - } - - /* The drive has accepted us as authentic. */ - print_debug( dvdcss, "authentication established" ); - - memcpy( p_challenge, p_key1, KEY_SIZE ); - memcpy( p_challenge + KEY_SIZE, p_key2, KEY_SIZE ); - - CryptKey( 2, i_variant, p_challenge, dvdcss->css.p_bus_key ); - - return 0; -} - -/***************************************************************************** - * PrintKey : debug function that dumps a key value - *****************************************************************************/ -static void PrintKey( dvdcss_t dvdcss, char *prefix, uint8_t const *data ) -{ - print_debug( dvdcss, "%s%02x:%02x:%02x:%02x:%02x", prefix, - data[0], data[1], data[2], data[3], data[4] ); -} - -/***************************************************************************** - * GetASF : Get Authentication success flag - ***************************************************************************** - * Returns : - * -1 on ioctl error, - * 0 if the device needs to be authenticated, - * 1 either. - *****************************************************************************/ -static int GetASF( dvdcss_t dvdcss ) -{ - int i_asf = 0; - - if( ioctl_ReportASF( dvdcss->i_fd, NULL, &i_asf ) != 0 ) - { - /* The ioctl process has failed */ - print_error( dvdcss, "GetASF fatal error" ); - return -1; - } - - if( i_asf ) - { - print_debug( dvdcss, "GetASF authenticated, ASF=1" ); - } - else - { - print_debug( dvdcss, "GetASF not authenticated, ASF=0" ); - } - - return i_asf; -} - -/***************************************************************************** - * CryptKey : shuffles bits and unencrypt keys. - ***************************************************************************** - * Used during authentication and disc key negociation in GetBusKey. - * i_key_type : 0->key1, 1->key2, 2->buskey. - * i_variant : between 0 and 31. - *****************************************************************************/ -static void CryptKey( int i_key_type, int i_variant, - uint8_t const *p_challenge, uint8_t *p_key ) -{ - /* Permutation table for challenge */ - uint8_t pp_perm_challenge[3][10] = - { { 1, 3, 0, 7, 5, 2, 9, 6, 4, 8 }, - { 6, 1, 9, 3, 8, 5, 7, 4, 0, 2 }, - { 4, 0, 3, 5, 7, 2, 8, 6, 1, 9 } }; - - /* Permutation table for variant table for key2 and buskey */ - uint8_t pp_perm_variant[2][32] = - { { 0x0a, 0x08, 0x0e, 0x0c, 0x0b, 0x09, 0x0f, 0x0d, - 0x1a, 0x18, 0x1e, 0x1c, 0x1b, 0x19, 0x1f, 0x1d, - 0x02, 0x00, 0x06, 0x04, 0x03, 0x01, 0x07, 0x05, - 0x12, 0x10, 0x16, 0x14, 0x13, 0x11, 0x17, 0x15 }, - { 0x12, 0x1a, 0x16, 0x1e, 0x02, 0x0a, 0x06, 0x0e, - 0x10, 0x18, 0x14, 0x1c, 0x00, 0x08, 0x04, 0x0c, - 0x13, 0x1b, 0x17, 0x1f, 0x03, 0x0b, 0x07, 0x0f, - 0x11, 0x19, 0x15, 0x1d, 0x01, 0x09, 0x05, 0x0d } }; - - uint8_t p_variants[32] = - { 0xB7, 0x74, 0x85, 0xD0, 0xCC, 0xDB, 0xCA, 0x73, - 0x03, 0xFE, 0x31, 0x03, 0x52, 0xE0, 0xB7, 0x42, - 0x63, 0x16, 0xF2, 0x2A, 0x79, 0x52, 0xFF, 0x1B, - 0x7A, 0x11, 0xCA, 0x1A, 0x9B, 0x40, 0xAD, 0x01 }; - - /* The "secret" key */ - uint8_t p_secret[5] = { 0x55, 0xD6, 0xC4, 0xC5, 0x28 }; - - uint8_t p_bits[30], p_scratch[10], p_tmp1[5], p_tmp2[5]; - uint8_t i_lfsr0_o; /* 1 bit used */ - uint8_t i_lfsr1_o; /* 1 bit used */ - uint8_t i_css_variant, i_cse, i_index, i_combined, i_carry; - uint8_t i_val = 0; - uint32_t i_lfsr0, i_lfsr1; - int i_term = 0; - int i_bit; - int i; - - for (i = 9; i >= 0; --i) - p_scratch[i] = p_challenge[pp_perm_challenge[i_key_type][i]]; - - i_css_variant = ( i_key_type == 0 ) ? i_variant : - pp_perm_variant[i_key_type-1][i_variant]; - - /* - * This encryption engine implements one of 32 variations - * one the same theme depending upon the choice in the - * variant parameter (0 - 31). - * - * The algorithm itself manipulates a 40 bit input into - * a 40 bit output. - * The parameter 'input' is 80 bits. It consists of - * the 40 bit input value that is to be encrypted followed - * by a 40 bit seed value for the pseudo random number - * generators. - */ - - /* Feed the secret into the input values such that - * we alter the seed to the LFSR's used above, then - * generate the bits to play with. - */ - for( i = 5 ; --i >= 0 ; ) - { - p_tmp1[i] = p_scratch[5 + i] ^ p_secret[i] ^ p_crypt_tab2[i]; - } - - /* - * We use two LFSR's (seeded from some of the input data bytes) to - * generate two streams of pseudo-random bits. These two bit streams - * are then combined by simply adding with carry to generate a final - * sequence of pseudo-random bits which is stored in the buffer that - * 'output' points to the end of - len is the size of this buffer. - * - * The first LFSR is of degree 25, and has a polynomial of: - * x^13 + x^5 + x^4 + x^1 + 1 - * - * The second LSFR is of degree 17, and has a (primitive) polynomial of: - * x^15 + x^1 + 1 - * - * I don't know if these polynomials are primitive modulo 2, and thus - * represent maximal-period LFSR's. - * - * - * Note that we take the output of each LFSR from the new shifted in - * bit, not the old shifted out bit. Thus for ease of use the LFSR's - * are implemented in bit reversed order. - * - */ - - /* In order to ensure that the LFSR works we need to ensure that the - * initial values are non-zero. Thus when we initialise them from - * the seed, we ensure that a bit is set. - */ - i_lfsr0 = ( p_tmp1[0] << 17 ) | ( p_tmp1[1] << 9 ) | - (( p_tmp1[2] & ~7 ) << 1 ) | 8 | ( p_tmp1[2] & 7 ); - i_lfsr1 = ( p_tmp1[3] << 9 ) | 0x100 | p_tmp1[4]; - - i_index = sizeof(p_bits); - i_carry = 0; - - do - { - for( i_bit = 0, i_val = 0 ; i_bit < 8 ; ++i_bit ) - { - - i_lfsr0_o = ( ( i_lfsr0 >> 24 ) ^ ( i_lfsr0 >> 21 ) ^ - ( i_lfsr0 >> 20 ) ^ ( i_lfsr0 >> 12 ) ) & 1; - i_lfsr0 = ( i_lfsr0 << 1 ) | i_lfsr0_o; - - i_lfsr1_o = ( ( i_lfn; -} - -/***************************************************************************** - * DecryptKey: decrypt p_crypted with p_key. - ***************************************************************************** - * Used to decrypt the disc key, with a player key, after requesting it - * in _dvdcss_disckey and to decrypt title keys, with a disc key, requested - * in _dvdcss_titlekey. - * The player keys and the resulting disc key are only used as KEKs - * (key encryption keys). - * Decryption is slightly dependant on the type of key: - * -for disc key, invert is 0x00, - * -for title key, invert if 0xff. - *****************************************************************************/ -static void DecryptKey( uint8_t invert, uint8_t const *p_key, - uint8_t const *p_crypted, uint8_t *p_result ) -{ - unsigned int i_lfsr1_lo; - unsigned int i_lfsr1_hi; - unsigned int i_lfsr0; - unsigned int i_combined; - uint8_t o_lfsr0; - uint8_t o_lfsr1; - uint8_t k[5]; - int i; - - i_lfsr1_lo = p_key[0] | 0x100; - i_lfsr1_hi = p_key[1]; - - i_lfsr0 = ( ( p_key[4] << 17 ) - | ( p_key[3] << 9 ) - | ( p_key[2] << 1 ) ) - + 8 - ( p_key[2] & 7 ); - i_lfsr0 =3sr1 >> 16 ) ^ ( i_lfsr1 >> 2 ) ) & 1; - i_lfsr1 = ( i_lfsr1 << 1 ) | i_lfsr1_o; - - i_combined = !i_lfsr1_o + i_carry + !i_lfsr0_o; - /* taking bit 1 */ - i_carry = ( i_combined >> 1 ) & 1; - i_val |= ( i_combined & 1 ) << i_bit; - } - - p_bits[--i_index] = i_val; - } while( i_index > 0 ); - - /* This term is used throughout the following to - * select one of 32 different variations on the - * algorithm. - */ - i_cse = p_variants[i_css_variant] ^ p_crypt_tab2[i_css_variant]; - - /* Now the actual blocks doing the encryption. Each - * of these works on 40 bits at a time and are quite - * similar. - */ - i_index = 0; - for( i = 5, i_term = 0 ; --i >= 0 ; i_term = p_scratch[i] ) - { - i_index = p_bits[25 + i] ^ p_scratch[i]; - i_index = p_crypt_tab1[i_index] ^ ~p_crypt_tab2[i_index] ^ i_cse; - - p_tmp1[i] = p_crypt_tab2[i_index] ^ p_crypt_tab3[i_index] ^ i_term; - } - p_tmp1[4] ^= p_tmp1[0]; - - for( i = 5, i_term = 0 ; --i >= 0 ; i_term = p_tmp1[i] ) - { - i_index = p_bits[20 + i] ^ p_tmp1[i]; - i_index = p_crypt_tab1[i_index] ^ ~p_crypt_tab2[i_index] ^ i_cse; - - p_tmp2[i] = p_crypt_tab2[i_index] ^ p_crypt_tab3[i_index] ^ i_term; - } - p_tmp2[4] ^= p_tmp2[0]; - - for( i = 5, i_term = 0 ; --i >= 0 ; i_term = p_tmp2[i] ) - { - i_index = p_bits[15 + i] ^ p_tmp2[i]; - i_index = p_crypt_tab1[i_index] ^ ~p_crypt_tab2[i_index] ^ i_cse; - i_index = p_crypt_tab2[i_index] ^ p_crypt_tab3[i_index] ^ i_term; - - p_tmp1[i] = p_crypt_tab0[i_index] ^ p_crypt_tab2[i_index]; - } - p_tmp1[4] ^= p_tmp1[0]; - - for( i = 5, i_term = 0 ; --i >= 0 ; i_term = p_tmp1[i] ) - { - i_index = p_bits[10 + i] ^ p_tmp1[i]; - i_index = p_crypt_tab1[i_index] ^ ~p_crypt_tab2[i_index] ^ i_cse; - - i_index = p_crypt_tab2[i_index] ^ p_crypt_tab3[i_index] ^ i_term; - - p_tmp2[i] = p_crypt_tab0[i_index] ^ p_crypt_tab2[i_index]; - } - p_tmp2[4] ^= p_tmp2[0]; - - for( i = 5, i_term = 0 ; --i >= 0 ; i_term = p_tmp2[i] ) - { - i_index = p_bits[5 + i] ^ p_tmp2[i]; - i_index = p_crypt_tab1[i_index] ^ ~p_crypt_tab2[i_index] ^ i_cse; - - p_tmp1[i] = p_crypt_tab2[i_index] ^ p_crypt_tab3[i_index] ^ i_term; - } - p_tmp1[4] ^= p_tmp1[0]; - - for(i = 5, i_term = 0 ; --i >= 0 ; i_term = p_tmp1[i] ) - { - i_index = p_bits[i] ^ p_tmp1[i]; - i_index = p_crypt_tab1[i_index] ^ ~p_crypt_tab2[i_index] ^ i_cse; - - p_key[i] = p_crypt_tab2[i_index] ^ p_crypt_tab3[i_index] ^ i_term; - } - - returD ( p_css_tab4[i_lfsr0 & 0xff] << 24 ) | - ( p_css_tab4[( i_lfsr0 >> 8 ) & 0xff] << 16 ) | - ( p_css_tab4[( i_lfsr0 >> 16 ) & 0xff] << 8 ) | - p_css_tab4[( i_lfsr0 >> 24 ) & 0xff]; - - i_combined = 0; - for( i = 0 ; i < KEY_SIZE ; ++i ) - { - o_lfsr1 = p_css_tab2[i_lfsr1_hi] ^ p_css_tab3[i_lfsr1_lo]; - i_lfsr1_hi = i_lfsr1_lo >> 1; - i_lfsr1_lo = ( ( i_lfsr1_lo & 1 ) << 8 ) ^ o_lfsr1; - o_lfsr1 = p_css_tab4[o_lfsr1]; - - o_lfsr0 = ((((((( i_lfsr0 >> 8 ) ^ i_lfsr0 ) >> 1 ) - ^ i_lfsr0 ) >> 3 ) ^ i_lfsr0 ) >> 7 ); - i_lfsr0 = ( i_lfsr0 >> 8 ) | ( o_lfsr0 << 24 ); - - i_combined += ( o_lfsr0 ^ invert ) + o_lfsr1; - k[i] = i_combined & 0xff; - i_combined >>= 8; - } - - p_result[4] = k[4] ^ p_css_tab1[p_crypted[4]] ^ p_crypted[3]; - p_result[3] = k[3] ^ p_css_tab1[p_crypted[3]] ^ p_crypted[2]; - p_result[2] = k[2] ^ p_css_tab1[p_crypted[2]] ^ p_crypted[1]; - p_result[1] = k[1] ^ p_css_tab1[p_crypted[1]] ^ p_crypted[0]; - p_result[0] = k[0] ^ p_css_tab1[p_crypted[0]] ^ p_result[4]; - - p_result[4] = k[4] ^ p_css_tab1[p_result[4]] ^ p_result[3]; - p_result[3] = k[3] ^ p_css_tab1[p_result[3]] ^ p_result[2]; - p_result[2] = k[2] ^ p_css_tab1[p_result[2]] ^ p_result[1]; - p_result[1] = k[1] ^ p_css_tab1[p_result[1]] ^ p_result[0]; - p_result[0] = k[0] ^ p_css_tab1[p_result[0]]; - - return; -} - -/***************************************************************************** - * player_keys: alternate DVD player keys - ***************************************************************************** - * These player keys were generated using Frank A. Stevenson's PlayerKey - * cracker. A copy of his article can be found here: - * http://www-2.cs.cmu.edu/~dst/DeCSS/FrankStevenson/mail2.txt - *****************************************************************************/ -static const dvd_key_t player_keys[] = -{ - { 0x01, 0xaf, 0xe3, 0x12, 0x80 }, - { 0x12, 0x11, 0xca, 0x04, 0x3b }, - { 0x14, 0x0c, 0x9e, 0xd0, 0x09 }, - { 0x14, 0x71, 0x35, 0xba, 0xe2 }, - { 0x1a, 0xa4, 0x33, 0x21, 0xa6 }, - { 0x26, 0xec, 0xc4, 0xa7, 0x4e }, - { 0x2c, 0xb2, 0xc1, 0x09, 0xee }, - { 0x2f, 0x25, 0x9e, 0x96, 0xdd }, - { 0x33, 0x2f, 0x49, 0x6c, 0xe0 }, - { 0x35, 0x5b, 0xc1, 0x31, 0x0f }, - { 0x36, 0x67, 0xb2, 0xe3, 0x85 }, - { 0x39, 0x3d, 0xf1, 0xf1, 0xbd }, - { 0x3b, 0x31, 0x34, 0x0d, 0x91 }, - { 0x45, 0xed, 0x28, 0xeb, 0xd3 }, - { 0x48, 0xb7, 0x6c, 0xce, 0x69 }, - { 0x4b, 0x65, 0x0d, 0xc1, 0xee }, - { 0x4c, 0xbb, 0xf5, 0x5b, 0x23 }, - { 0x51, 0x67, 0x67, 0xc5, 0xe0 }, - { 0x53, 0x94, 0xe1, 0x75, 0xbf }, - { 0x57, 0x2c, 0x8b, 0x31, 0xae }, - { 0x63, 0xdb, 0x4c, 0x5b, 0x4a }, - { 0x7b, 0x1e, 0x5e, 0x2b, 0x57 }, - { 0x85, 0xf3, 0x85, 0xa0, 0xe0 }, - { 0xab, 0x1e, 0xe7, 0x7b, 0x72 }, - { 0xab, 0x36, 0xe3, 0xeb, 0x76 }, - { 0xb1, 0xb8, 0xf9, 0x38, 0x03 }, - { 0xb8, 0x5d, 0xd8, 0x53, 0xbd }, - { 0xbf, 0x92, 0xc3, 0xb0, 0xe2 }, - { 0xcf, 0x1a, 0xb2, 0xf8, 0x0a }, - { 0xec, 0xa0, 0xcf, 0xb3, 0xff }, - { 0xfc, 0x95, 0xa9, 0x87, 0x35 } -}; - -/***************************************************************************** - * DecryptDiscKey - ***************************************************************************** - * Decryption of the disc key with player keys: try to decrypt the disc key - * from every position with every player key. - * p_struct_disckey: the 2048 byte DVD_STRUCT_DISCKEY data - * p_disc_key: result, the 5 byte disc key - *****************************************************************************/ -static int DecryptDiscKey( dvdcss_t dvdcss, uint8_t const *p_struct_disckey, - dvd_key_t p_disc_key ) -{ - uint8_t p_verify[KEY_SIZE]; - unsigned int i, n = 0; - - /* Decrypt disc key with the above player keys */ - for( n = 0; n < sizeof(player_keys) / sizeof(dvd_key_t); n++ ) - { - PrintKey( dvdcss, "trying player key ", player_keys[n] ); - - for( i = 1; i < 409; i++ ) - { - /* Check if player key n is the right key for position i. */ - DecryptKey( 0, player_keys[n], p_struct_disckey + 5 * i, - p_disc_key ); - - /* The first part in the struct_disckey block is the - * 'disc key' encrypted with itself. Using this we - * can check if we decrypted the correct key. */ - DecryptKey( 0, p_disc_key, p_struct_disckey, p_verify ); - - /* If the position / player key pair worked then return. */ - if( memcmp( p_disc_key, p_verify, KEY_SIZE ) == 0 ) - { - return 0; - } - } - } - - /* Have tried all combinations of positions and keys, - * and we still didn't succeed. */ - memset( p_disc_key, 0, KEY_SIZE ); - return -1; -} - -/***************************************************************************** - * DecryptTitleKey - ***************************************************************************** - * Decrypt the title key using the disc key. - * p_disc_key: result, the 5 byte disc key - * p_titlekey: the encrypted title key, gets overwritten by the decrypted key - *****************************************************************************/ -static void DecryptTitleKey( dvd_key_t p_disc_key, dvd_key_t p_titlekey ) -{ - DecryptKey( 0xff, p_disc_key, p_titlekey, p_titlekey ); -} - -/***************************************************************************** - * CrackDiscKey: brute force disc key - * CSS hash reversal function designed by Frank Stevenson - ***************************************************************************** - * This function uses a big amount of memory to crack the disc key from the - * disc key hash, if player keys are not available. - *****************************************************************************/ -#define K1TABLEWIDTH 10 - -/* - * Simple function to test if a candidate key produces the given hash - */ -static int investigate( unsigned char *hash, unsigned char *ckey ) -{ - unsigned char key[KEY_SIZE]; - - DecryptKey( 0, ckey, hash, key ); - - return memcmp( key, ckey, KEY_SIZE ); -} - -static int CrackDiscKey( dvdcss_t dvdcss, uint8_t *p_disc_key ) -{ - unsigned char B[5] = { 0,0,0,0,0 }; /* Second Stage of mangle cipher */ - unsigned char C[5] = { 0,0,0,0,0 }; /* Output Stage of mangle cipher - * IntermediateKey */ - unsigned char k[5] = { 0,0,0,0,0 }; /* Mangling cipher key - * Also output from CSS( C ) */ - unsigned char out1[5]; /* five first output bytes of LFSR1 */ - unsigned char out2[5]; /* five first output bytes of LFSR2 */ - unsigned int lfsr1a; /* upper 9 bits of LFSR1 */ - unsigned int lfsr1b; /* lower 8 bits of LFSR1 */ - unsigned int tmp, tmp2, tmp3, tmp4,tmp5; - int i,j; - unsigned int nStepA; /* iterator for LFSR1 start state */ - unsigned int nStepB; /* iterator for possible B[0] */ - unsigned int nTry; /* iterator for K[1] possibilities */ - unsigned int nPossibleK1; /* #of possible K[1] values */ - unsigned char* K1table; /* Lookup table for possible K[1] */ - unsigned int* BigTable; /* LFSR2 startstate indexed by - * 1,2,5 output byte */ - - /* - * Prepare tables for hash reversal - */ - - /* initialize lookup tables for k[1] */ - K1table = malloc( 65536 * K1TABLEWIDTH ); - memset( K1table, 0 , 65536 * K1TABLEWIDTH ); - if( K1table == NULL ) - { - return -1; - } - - tmp = p_disc_key[0] ^ p_css_tab1[ p_disc_key[1] ]; - for( i = 0 ; i < 256 ; i++ ) /* k[1] */ - { - tmp2 = p_css_tab1[ tmp ^ i ]; /* p_css_tab1[ B[1] ]*/ - - for( j = 0 ; j < 256 ; j++ ) /* B[0] */ - { - tmp3 = j ^ tmp2 ^ i; /* C[1] */ - tmp4 = K1table[ K1TABLEWIDTH * ( 256 * j + tmp3 ) ]; /* count of entries here */ - tmp4++; -/* - if( tmp4 == K1TABLEWIDTH ) - { - print_debug( dvdcss, "Table disaster %d", tmp4 ); - } -*/ - if( tmp4 < K1TABLEWIDTH ) - { - K1table[ K1TABLEWIDTH * ( 256 * j + tmp3 ) + tmp4 ] = i; - } - K1table[ K1TABLEWIDTH * ( 256 * j + tmp3 ) ] = tmp4; - } - } - - /* Initing our Really big table */ - BigTable = malloc( 16777216 * sizeof(int) ); - memset( BigTable, 0 , 16777216 * sizeof(int) ); - if( BigTable == NULL ) - { - return -1; - } - - tmp3 = 0; - - print_debug( dvdcss, "initializing the big table" ); - - for( i = 0 ; i < 16777216 ; i++ ) - { - tmp = (( i + i ) & 0x1fffff0 ) | 0x8 | ( i & 0x7 ); - - for( j = 0 ; j < 5 ; j++ ) - { - tmp2=((((((( tmp >> 3 ) ^ tmp ) >> 1 ) ^ tmp ) >> 8 ) - ^ tmp ) >> 5 ) & 0xff; - tmp = ( tmp << 8) | tmp2; - out2[j] = p_css_tab4[ tmp2 ]; - } - - j = ( out2[0] << 16 ) | ( out2[1] << 8 ) | out2[4]; - BigTable[j] = i; - } - - /* - * We are done initing, now reverse hash - */ - tmp5 = p_disc_key[0] ^ p_css_tab1[ p_disc_key[1] ]; - - for( nStepA = 0 ; nStepA < 65536 ; nStepA ++ ) - { - lfsr1a = 0x100 | ( nStepA >> 8 ); - lfsr1b = nStepA & 0xff; - - /* Generate 5 first output bytes from lfsr1 */ - for( i = 0 ; i < 5 ; i++ ) - { - tmp = p_css_tab2[ lfsr1b ] ^ p_css_tab3[ lfsr1a ]; - lfsr1b = lfsr1a >> 1; - lfsr1a = ((lfsr1a&1)<<8) ^ tmp; - out1[ i ] = p_css_tab4[ tmp ]; - } - - /* cumpute and cache some variables */ - C[0] = nStepA >> 8; - C[1] = nStepA & 0xff; - tmp = p_disc_key[3] ^ p_css_tab1[ p_disc_key[4] ]; - tmp2 = p_css_tab1[ p_disc_key[0] ]; - - /* Search through all possible B[0] */ - for( nStepB = 0 ; nStepB < 256 ; nStepB++ ) - { - /* reverse parts of the mangling cipher */ - B[0] = nStepB; - k[0] = p_css_tab1[ B[0] ] ^ C[0]; - B[4] = B[0] ^ k[0] ^ tmp2; - k[4] = B[4] ^ tmp; - nPossibleK1 = K1table[ K1TABLEWIDTH * (256 * B[0] + C[1]) ]; - - /* Try out all possible values for k[1] */ - for( nTry = 0 ; nTry < nPossibleK1 ; nTry++ ) - { - k[1] = K1table[ K1TABLEWIDTH * (256 * B[0] + C[1]) + nTry + 1 ]; - B[1] = tmp5 ^ k[1]; - - /* reconstruct output from LFSR2 */ - tmp3 = ( 0x100 + k[0] - out1[0] ); - out2[0] = tmp3 & 0xff; - tmp3 = tmp3 & 0x100 ? 0x100 : 0xff; - tmp3 = ( tmp3 + k[1] - out1[1] ); - out2[1] = tmp3 & 0xff; - tmp3 = ( 0x100 + k[4] - out1[4] ); - out2[4] = tmp3 & 0xff; /* Can be 1 off */ - - /* test first possible out2[4] */ - tmp4 = ( out2[0] << 16 ) | ( out2[1] << 8 ) | out2[4]; - tmp4 = BigTable[ tmp4 ]; - C[2] = tmp4 & 0xff; - C[3] = ( tmp4 >> 8 ) & 0xff; - C[4] = ( tmp4 >> 16 ) & 0xff; - B[3] = p_css_tab1[ B[4] ] ^ k[4] ^ C[4]; - k[3] = p_disc_key[2] ^ p_css_tab1[ p_disc_key[3] ] ^ B[3]; - B[2] = p_css_tab1[ B[3] ] ^ k[3] ^ C[3]; - k[2] = p_disc_key[1] ^ p_css_tab1[ p_disc_key[2] ] ^ B[2]; - - if( ( B[1] ^ p_css_tab1[ B[2] ] ^ k[ 2 ] ) == C[ 2 ] ) - { - if( ! investigate( &p_disc_key[0] , &C[0] ) ) - { - goto end; - } - } - - /* Test second possible out2[4] */ - out2[4] = ( out2[4] + 0xff ) & 0xff; - tmp4 = ( out2[0] << 16 ) | ( out2[1] << 8 ) | out2[4]; - tmp4 = BigTable[ tmp4 ]; - C[2] = tmp4 & 0xff; - C[3] = ( tmp4 >> 8 ) & 0xff; - C[4] = ( tmp4 >> 16 ) & 0xff; - B[3] = p_css_tab1[ B[4] ] ^ k[4] ^ C[4]; - k[3] = p_disc_key[2] ^ p_css_tab1[ p_disc_key[3] ] ^ B[3]; - B[2] = p_css_tab1[ B[3] ] ^ k[3] ^ C[3]; - k[2] = p_disc_key[1] ^ p_css_tab1[ p_disc_key[2] ] ^ B[2]; - - if( ( B[1] ^ p_css_tab1[ B[2] ] ^ k[ 2 ] ) == C[ 2 ] ) - { - if( ! investigate( &p_disc_key[0] , &C[0] ) ) - { - goto end; - } - } - } - } - } - -end: - - memcpy( p_disc_key, &C[0], KEY_SIZE ); - - free( K1table ); - free( BigTable ); - - return 0; -} - -/***************************************************************************** - * RecoverTitleKey: (title) key recovery from cipher and plain text - * Function designed by Frank Stevenson - ***************************************************************************** - * Called from Attack* which are in turn called by CrackTitleKey. Given - * a guessed(?) plain text and the cipher text. Returns -1 on failure. - *****************************************************************************/ -static int RecoverTitleKey( int i_start, uint8_t const *p_crypted, - uint8_t const *p_decrypted, - uint8_t const *p_sector_seed, uint8_t *p_key ) -{ - uint8_t p_buffer[10]; - unsigned int i_t1, i_t2, i_t3, i_t4, i_t5, i_t6; - unsigned int i_try; - unsigned int i_candidate; - unsigned int i, j; - int i_exit = -1; - - for( i = 0 ; i < 10 ; i++ ) - { - p_buffer[i] = p_css_tab1[p_crypted[i]] ^ p_decrypted[i]; - } - - for( i_try = i_start ; i_try < 0x10000 ; i_try++ ) - { - i_t1 = i_try >> 8 | 0x100; - i_t2 = i_try & 0xff; - i_t3 = 0; /* not needed */ - i_t5 = 0; - - /* iterate cipher 4 times to reconstruct LFSR2 */ - for( i = 0 ; i < 4 ; i++ ) - { - /* advance LFSR1 normaly */ - i_t4 = p_css_tab2[i_t2] ^ p_css_tab3[i_t1]; - i_t2 = i_t1 >> 1; - i_t1 = ( ( i_t1 & 1 ) << 8 ) ^ i_t4; - i_t4 = p_css_tab5[i_t4]; - /* deduce i_t6 & i_t5 */ - i_t6 = p_buffer[i]; - if( i_t5 ) - { - i_t6 = ( i_t6 + 0xff ) & 0x0ff; - } - if( i_t6 < i_t4 ) - { - i_t6 += 0x100; - } - i_t6 -= i_t4; - i_t5 += i_t6 + i_t4; - i_t6 = p_css_tab4[ i_t6 ]; - /* feed / advance i_t3 / i_t5 */ - i_t3 = ( i_t3 << 8 ) | i_t6; - i_t5 >>= 8; - } - - i_candidate = i_t3; - - /* iterate 6 more times to validate candidate key */ - for( ; i < 10 ; i++ ) - { - i_t4 = p_css_tab2[i_t2] ^ p_css_tab3[i_t1]; - i_t2 = i_t1 >> 1; - i_t1 = ( ( i_t1 & 1 ) << 8 ) ^ i_t4; - i_t4 = p_css_tab5[i_t4]; - i_t6 = ((((((( i_t3 >> 3 ) ^ i_t3 ) >> 1 ) ^ - i_t3 ) >> 8 ) ^ i_t3 ) >> 5 ) & 0xff; - i_t3 = ( i_t3 << 8 ) | i_t6; - i_t6 = p_css_tab4[i_t6]; - i_t5 += i_t6 + i_t4; - if( ( i_t5 & 0xff ) != p_buffer[i] ) - { - break; - } - - i_t5 >>= 8; - } - - if( i == 10 ) - { - /* Do 4 backwards steps of iterating t3 to deduce initial state */ - i_t3 = i_candidate; - for( i = 0 ; i < 4 ; i++ ) - { - i_t1 = i_t3 & 0xff; - i_t3 = ( i_t3 >> 8 ); - /* easy to code, and fast enough bruteforce - * search for byte shifted in */ - for( j = 0 ; j < 256 ; j++ ) - { - i_t3 = ( i_t3 & 0x1ffff ) | ( j << 17 ); - i_t6 = ((((((( i_t3 >> 3 ) ^ i_t3 ) >> 1 ) ^ - i_t3 ) >> 8 ) ^ i_t3 ) >> 5 ) & 0xff; - if( i_t6 == i_t1 ) - { - break; - } - } - } - - i_t4 = ( i_t3 >> 1 ) - 4; - for( i_t5 = 0 ; i_t5 < 8; i_t5++ ) - { - if( ( ( i_t4 + i_t5 ) * 2 + 8 - ( (i_t4 + i_t5 ) & 7 ) ) - == i_t3 ) - { - p_key[0] = i_try>>8; - p_key[1] = i_try & 0xFF; - p_key[2] = ( ( i_t4 + i_t5 ) >> 0 ) & 0xFF; - p_key[3] = ( ( i_t4 + i_t5 ) >> 8 ) & 0xFF; - p_key[4] = ( ( i_t4 + i_t5 ) >> 16 ) & 0xFF; - i_exit = i_try + 1; - } - } - } - } - - if( i_exit >= 0 ) - { - p_key[0] ^= p_sector_seed[0]; - p_key[1] ^= p_sector_seed[1]; - p_key[2] ^= p_sector_seed[2]; - p_key[3] ^= p_sector_seed[3]; - p_key[4] ^= p_sector_seed[4]; - } - - return i_exit; -} - - -/****************************************************************************** - * Various pieces for the title crack engine. - ****************************************************************************** - * The length of the PES packet is located at 0x12-0x13. - * The the copyrigth protection bits are located at 0x14 (bits 0x20 and 0x10). - * The data of the PES packet begins at 0x15 (if there isn't any PTS/DTS) - * or at 0x?? if there are both PTS and DTS's. - * The seed value used with the unscrambling key is the 5 bytes at 0x54-0x58. - * The scrabled part of a sector begins at 0x80. - *****************************************************************************/ - -/* Statistics */ -static int i_tries = 0, i_success = 0; - -/***************************************************************************** - * CrackTitleKey: try to crack title key from the contents of a VOB. - ***************************************************************************** - * This function is called by _dvdcss_titlekey to find a title key, if we've - * chosen to crack title key instead of decrypting it with the disc key. - * The DVD should have been opened and be in an authenticated state. - * i_pos is the starting sector, i_len is the maximum number of sectors to read - *****************************************************************************/ -static int CrackTitleKey( dvdcss_t dvdcss, int i_pos, int i_len, - dvd_key_t p_titlekey ) -{ - uint8_t p_buf[ DVDCSS_BLOCK_SIZE ]; - const uint8_t p_packstart[4] = { 0x00, 0x00, 0x01, 0xba }; - int i_reads = 0; - int i_encrypted = 0; - int b_stop_scanning = 0; - int b_read_error = 0; - int i_ret; - - print_debug( dvdcss, "cracking title key at block %i", i_pos ); - - i_tries = 0; - i_success = 0; - - do - { - i_ret = dvdcss->pf_seek( dvdcss, i_pos ); - - if( i_ret != i_pos ) - { - print_error( dvdcss, "seek failed" ); - } - - i_ret = dvdcss_read( dvdcss, p_buf, 1, DVDCSS_NOFLAGS ); - - /* Either we are at the end of the physical device or the auth - * have failed / were not done and we got a read error. */ - if( i_ret <= 0 ) - { - if( i_ret == 0 ) - { - print_debug( dvdcss, "read returned 0 (end of device?)" ); - } - else if( !b_read_error ) - { - print_debug( dvdcss, "read error at block %i, resorting to " - "secret arcanes to recover", i_pos ); - - /* Reset the drive before trying to continue */ - _dvdcss_close( dvdcss ); - _dvdcss_open( dvdcss ); - - b_read_error = 1; - continue; - } - break; - } - - /* Stop when we find a non MPEG stream block. - * (We must have reached the end of the stream). - * For now, allow all blocks that begin with a start code. */ - if( memcmp( p_buf, p_packstart, 3 ) ) - { - print_debug( dvdcss, "non MPEG block found at block %i " - "(end of title)", i_pos ); - break; - } - - if( p_buf[0x0d] & 0x07 ) - print_debug( dvdcss, "stuffing in pack header" ); - - /* PES_scrambling_control does not exist in a system_header, - * a padding_stream or a private_stream2 (and others?). */ - if( p_buf[0x14] & 0x30 && ! ( p_buf[0x11] == 0xbb - || p_buf[0x11] == 0xbe - || p_buf[0x11] == 0xbf ) ) - { - i_encrypted++; - - if( AttackPattern(p_buf, i_reads, p_titlekey) > 0 ) - { - b_stop_scanning = 1; - } -#if 0 - if( AttackPadding(p_buf, i_reads, p_titlekey) > 0 ) - { - b_stop_scanning = 1; - } -#endif - } - - i_pos++; - i_len--; - i_reads++; - - /* Emit a progress indication now and then. */ - if( !( i_reads & 0xfff ) ) - { - print_debug( dvdcss, "at block %i, still cracking...", i_pos ); - } - - /* Stop after 2000 blocks if we haven't seen any encrypted blocks. */ - if( i_reads >= 2000 && i_encrypted == 0 ) break; - - } while( !b_stop_scanning && i_len > 0); - - if( !b_stop_scanning ) - { - print_debug( dvdcss, "end of title reached" ); - } - - /* Print some statistics. */ - print_debug( dvdcss, "successful attempts %d/%d, scrambled blocks %d/%d", - i_success, i_tries, i_encrypted, i_reads ); - - if( i_success > 0 /* b_stop_scanning */ ) - { - print_debug( dvdcss, "vts key initialized" ); - return 1; - } - - if( i_encrypted == 0 && i_reads > 0 ) - { - memset( p_titlekey, 0, KEY_SIZE ); - print_debug( dvdcss, "no scrambled sectors found" ); - return 0; - } - - memset( p_titlekey, 0, KEY_SIZE ); - return -1; -} - - -/****************************************************************************** - * The original Ethan Hawke (DeCSSPlus) attack (modified). - ****************************************************************************** - * Tries to find a repeating pattern just before the encrypted part starts. - * Then it guesses that the plain text for first encrypted bytes are - * a contiuation of that pattern. - *****************************************************************************/ -static int AttackPattern( uint8_t const p_sec[ DVDCSS_BLOCK_SIZE ], - int i_pos, uint8_t *p_key ) -{ - unsigned int i_best_plen = 0; - unsigned int i_best_p = 0; - unsigned int i, j; - - /* For all cycle length from 2 to 48 */ - for( i = 2 ; i < 0x30 ; i++ ) - { - /* Find the number of bytes that repeats in cycles. */ - for( j = i + 1; - j < 0x80 && ( p_sec[0x7F - (j%i)] == p_sec[0x7F - j] ); - j++ ) - { - /* We have found j repeating bytes with a cycle length i. */ - if( j > i_best_plen ) - { - i_best_plen = j; - i_best_p = i; - } - } - } - - /* We need at most 10 plain text bytes?, so a make sure that we - * have at least 20 repeated bytes and that they have cycled at - * least one time. */ - if( ( i_best_plen > 3 ) && ( i_best_plen / i_best_p >= 2) ) - { - int res; - - i_tries++; - memset( p_key, 0, KEY_SIZE ); - res = RecoverTitleKey( 0, &p_sec[0x80], - &p_sec[ 0x80 - (i_best_plen / i_best_p) * i_best_p ], - &p_sec[0x54] /* key_seed */, p_key ); - i_success += ( res >= 0 ); -#if 0 - if( res >= 0 ) - { - fprintf( stderr, "key is %02x:%02x:%02x:%02x:%02x ", - p_key[0], p_key[1], p_key[2], p_key[3], p_key[4] ); - fprintf( stderr, "at block %5d pattern len %3d period %3d %s\n", - i_pos, i_best_plen, i_best_p, (res>=0?"y":"n") ); - } -#endif - return ( res >= 0 ); - } - - return 0; -} - - -#if 0 -/****************************************************************************** - * Encrypted Padding_stream attack. - ****************************************************************************** - * DVD specifies that there must only be one type of data in every sector. - * Every sector is one pack and so must obviously be 2048 bytes long. - * For the last pice of video data before a VOBU boundary there might not - * be exactly the right amount of data to fill a sector. Then one has to - * pad the pack to 2048 bytes. For just a few bytes this is done in the - * header but for any large amount you insert a PES packet from the - * Padding stream. This looks like 0x00 00 01 be xx xx ff ff ... - * where xx xx is the length of the padding stream. - *****************************************************************************/ -static int AttackPadding( uint8_t const p_sec[ DVDCSS_BLOCK_SIZE ], - int i_pos, uint8_t *p_key ) -{ - unsigned int i_pes_length; - /*static int i_tries = 0, i_success = 0;*/ - - i_pes_length = (p_sec[0x12]<<8) | p_sec[0x13]; - - /* Coverd by the test below but usfull for debuging. */ - if( i_pes_length == DVDCSS_BLOCK_SIZE - 0x14 ) return 0; - - /* There must be room for at least 4? bytes of padding stream, - * and it must be encrypted. - * sector size - pack/pes header - padding startcode - padding length */ - if( ( DVDCSS_BLOCK_SIZE - 0x14 - 4 - 2 - i_pes_length < 4 ) || - ( p_sec[0x14 + i_pes_length + 0] == 0x00 && - p_sec[0x14 + i_pes_length + 1] == 0x00 && - p_sec[0x14 + i_pes_length + 2] == 0x01 ) ) - { - fprintf( stderr, "plain %d %02x:%02x:%02x:%02x (type %02x sub %02x)\n", - DVDCSS_BLOCK_SIZE - 0x14 - 4 - 2 - i_pes_length, - p_sec[0x14 + i_pes_length + 0], - p_sec[0x14 + i_pes_length + 1], - p_sec[0x14 + i_pes_length + 2], - p_sec[0x14 + i_pes_length + 3], - p_sec[0x11], p_sec[0x17 + p_sec[0x16]]); - return 0; - } - - /* If we are here we know that there is a where in the pack a - encrypted PES header is (startcode + length). It's never more - than two packets in the pack, so we 'know' the length. The - plaintext at offset (0x14 + i_pes_length) will then be - 00 00 01 e0/bd/be xx xx, in the case of be the following bytes - are also known. */ - - /* An encrypted SPU PES packet with another encrypted PES packet following. - Normaly if the following was a padding stream that would be in plain - text. So it will be another SPU PES packet. */ - if( p_sec[0x11] == 0xbd && - p_sec[0x17 + p_sec[0x16]] >= 0x20 && - p_sec[0x17 + p_sec[0x16]] <= 0x3f ) - { - i_tries++; - } - - /* A Video PES packet with another encrypted PES packet following. - * No reason execpt for time stamps to break the data into two packets. - * So it's likely that the following PES packet is a padding stream. */ - if( p_sec[0x11] == 0xe0 ) - { - i_tries++; - } - - if( 1 ) - { - /*fprintf( stderr, "key is %02x:%02x:%02x:%02x:%02x ", - p_key[0], p_key[1], p_key[2], p_key[3], p_key[4] );*/ - fprintf( stderr, "at block %5d padding len %4d " - "type %02x sub %02x\n", i_pos, i_pes_length, - p_sec[0x11], p_sec[0x17 + p_sec[0x16]]); - } - - return 0; -} -#endif diff --git a/libdvdcss/css.h b/libdvdcss/css.h deleted file mode 100644 index 03becda..0000000 --- a/libdvdcss/css.h +++ /dev/null @@ -1,56 +0,0 @@ -/***************************************************************************** - * css.h: Structures for DVD authentication and unscrambling - ***************************************************************************** - * Copyright (C) 1999-2001 VideoLAN - * $Id$ - * - * Author: Stéphane Borel - * - * based on: - * - css-auth by Derek Fawcus - * - DVD CSS ioctls example program by Andrew T. Veliath - * - DeCSSPlus by Ethan Hawke - * - The Divide and conquer attack by Frank A. Stevenson - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. - *****************************************************************************/ -#define KEY_SIZE 5 - -typedef uint8_t dvd_key_t[KEY_SIZE]; - -typedef struct dvd_title_s -{ - int i_startlb; - dvd_key_t p_key; - struct dvd_title_s *p_next; -} dvd_title_t; - -typedef struct css_s -{ - int i_agid; /* Current Authenication Grant ID. */ - dvd_key_t p_bus_key; /* Current session key. */ - dvd_key_t p_disc_key; /* This DVD disc's key. */ - dvd_key_t p_title_key; /* Current title key. */ -} css_t; - -/***************************************************************************** - * Prototypes in css.c - *****************************************************************************/ -int _dvdcss_test ( dvdcss_t ); -int _dvdcss_title ( dvdcss_t, int ); -int _dvdcss_disckey ( dvdcss_t ); -int _dvdcss_titlekey ( dvdcss_t, int , dvd_key_t ); -int _dvdcss_unscramble ( uint8_t *, uint8_t * ); - diff --git a/libdvdcss/csstables.h b/libdvdcss/csstables.h deleted file mode 100644 index bd0fc3a..0000000 --- a/libdvdcss/csstables.h +++ /dev/null @@ -1,392 +0,0 @@ -/***************************************************************************** - * csstables.h: CSS Tables for DVD unscrambling - ***************************************************************************** - * Copyright (C) 1999-2001 VideoLAN - * $Id$ - * - * Author: Stéphane Borel - * - * based on: - * - css-auth by Derek Fawcus - * - DVD CSS ioctls example program by Andrew T. Veliath - * - The Divide and conquer attack by Frank A. Stevenson - * - DeCSSPlus by Ethan Hawke - * - DecVOB - * see http://www.lemuria.org/DeCSS/ by Tom Vogt for more information. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. - *****************************************************************************/ - - -static uint8_t p_css_tab1[ 256 ] = -{ - 0x33, 0x73, 0x3b, 0x26, 0x63, 0x23, 0x6b, 0x76, - 0x3e, 0x7e, 0x36, 0x2b, 0x6e, 0x2e, 0x66, 0x7b, - 0xd3, 0x93, 0xdb, 0x06, 0x43, 0x03, 0x4b, 0x96, - 0xde, 0x9e, 0xd6, 0x0b, 0x4e, 0x0e, 0x46, 0x9b, - 0x57, 0x17, 0x5f, 0x82, 0xc7, 0x87, 0xcf, 0x12, - 0x5a, 0x1a, 0x52, 0x8f, 0xca, 0x8a, 0xc2, 0x1f, - 0xd9, 0x99, 0xd1, 0x00, 0x49, 0x09, 0x41, 0x90, - 0xd8, 0x98, 0xd0, 0x01, 0x48, 0x08, 0x40, 0x91, - 0x3d, 0x7d, 0x35, 0x24, 0x6d, 0x2d, 0x65, 0x74, - 0x3c, 0x7c, 0x34, 0x25, 0x6c, 0x2c, 0x64, 0x75, - 0xdd, 0x9d, 0xd5, 0x04, 0x4d, 0x0d, 0x45, 0x94, - 0xdc, 0x9c, 0xd4, 0x05, 0x4c, 0x0c, 0x44, 0x95, - 0x59, 0x19, 0x51, 0x80, 0xc9, 0x89, 0xc1, 0x10, - 0x58, 0x18, 0x50, 0x81, 0xc8, 0x88, 0xc0, 0x11, - 0xd7, 0x97, 0xdf, 0x02, 0x47, 0x07, 0x4f, 0x92, - 0xda, 0x9a, 0xd2, 0x0f, 0x4a, 0x0a, 0x42, 0x9f, - 0x53, 0x13, 0x5b, 0x86, 0xc3, 0x83, 0xcb, 0x16, - 0x5e, 0x1e, 0x56, 0x8b, 0xce, 0x8e, 0xc6, 0x1b, - 0xb3, 0xf3, 0xbb, 0xa6, 0xe3, 0xa3, 0xeb, 0xf6, - 0xbe, 0xfe, 0xb6, 0xab, 0xee, 0xae, 0xe6, 0xfb, - 0x37, 0x77, 0x3f, 0x22, 0x67, 0x27, 0x6f, 0x72, - 0x3a, 0x7a, 0x32, 0x2f, 0x6a, 0x2a, 0x62, 0x7f, - 0xb9, 0xf9, 0xb1, 0xa0, 0xe9, 0xa9, 0xe1, 0xf0, - 0xb8, 0xf8, 0xb0, 0xa1, 0xe8, 0xa8, 0xe0, 0xf1, - 0x5d, 0x1d, 0x55, 0x84, 0xcd, 0x8d, 0xc5, 0x14, - 0x5c, 0x1c, 0x54, 0x85, 0xcc, 0x8c, 0xc4, 0x15, - 0xbd, 0xfd, 0xb5, 0xa4, 0xed, 0xad, 0xe5, 0xf4, - 0xbc, 0xfc, 0xb4, 0xa5, 0xec, 0xac, 0xe4, 0xf5, - 0x39, 0x79, 0x31, 0x20, 0x69, 0x29, 0x61, 0x70, - 0x38, 0x78, 0x30, 0x21, 0x68, 0x28, 0x60, 0x71, - 0xb7, 0xf7, 0xbf, 0xa2, 0xe7, 0xa7, 0xef, 0xf2, - 0xba, 0xfa, 0xb2, 0xaf, 0xea, 0xaa, 0xe2, 0xff -}; - -static uint8_t p_css_tab2[ 256 ] = -{ - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x09, 0x08, 0x0b, 0x0a, 0x0d, 0x0c, 0x0f, 0x0e, - 0x12, 0x13, 0x10, 0x11, 0x16, 0x17, 0x14, 0x15, - 0x1b, 0x1a, 0x19, 0x18, 0x1f, 0x1e, 0x1d, 0x1c, - 0x24, 0x25, 0x26, 0x27, 0x20, 0x21, 0x22, 0x23, - 0x2d, 0x2c, 0x2f, 0x2e, 0x29, 0x28, 0x2b, 0x2a, - 0x36, 0x37, 0x34, 0x35, 0x32, 0x33, 0x30, 0x31, - 0x3f, 0x3e, 0x3d, 0x3c, 0x3b, 0x3a, 0x39, 0x38, - 0x49, 0x48, 0x4b, 0x4a, 0x4d, 0x4c, 0x4f, 0x4e, - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, - 0x5b, 0x5a, 0x59, 0x58, 0x5f, 0x5e, 0x5d, 0x5c, - 0x52, 0x53, 0x50, 0x51, 0x56, 0x57, 0x54, 0x55, - 0x6d, 0x6c, 0x6f, 0x6e, 0x69, 0x68, 0x6b, 0x6a, - 0x64, 0x65, 0x66, 0x67, 0x60, 0x61, 0x62, 0x63, - 0x7f, 0x7e, 0x7d, 0x7c, 0x7b, 0x7a, 0x79, 0x78, - 0x76, 0x77, 0x74, 0x75, 0x72, 0x73, 0x70, 0x71, - 0x92, 0x93, 0x90, 0x91, 0x96, 0x97, 0x94, 0x95, - 0x9b, 0x9a, 0x99, 0x98, 0x9f, 0x9e, 0x9d, 0x9c, - 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, - 0x89, 0x88, 0x8b, 0x8a, 0x8d, 0x8c, 0x8f, 0x8e, - 0xb6, 0xb7, 0xb4, 0xb5, 0xb2, 0xb3, 0xb0, 0xb1, - 0xbf, 0xbe, 0xbd, 0xbc, 0xbb, 0xba, 0xb9, 0xb8, - 0xa4, 0xa5, 0xa6, 0xa7, 0xa0, 0xa1, 0xa2, 0xa3, - 0xad, 0xac, 0xaf, 0xae, 0xa9, 0xa8, 0xab, 0xaa, - 0xdb, 0xda, 0xd9, 0xd8, 0xdf, 0xde, 0xdd, 0xdc, - 0xd2, 0xd3, 0xd0, 0xd1, 0xd6, 0xd7, 0xd4, 0xd5, - 0xc9, 0xc8, 0xcb, 0xca, 0xcd, 0xcc, 0xcf, 0xce, - 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, - 0xff, 0xfe, 0xfd, 0xfc, 0xfb, 0xfa, 0xf9, 0xf8, - 0xf6, 0xf7, 0xf4, 0xf5, 0xf2, 0xf3, 0xf0, 0xf1, - 0xed, 0xec, 0xef, 0xee, 0xe9, 0xe8, 0xeb, 0xea, - 0xe4, 0xe5, 0xe6, 0xe7, 0xe0, 0xe1, 0xe2, 0xe3 -}; - -static uint8_t p_css_tab3[ 512 ] = -{ - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, - 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff -}; - -static uint8_t p_css_tab4[ 256 ] = -{ - 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, - 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, - 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8, - 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, - 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4, - 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, - 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, - 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, - 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, - 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, - 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, - 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa, - 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, - 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, - 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, - 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, - 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1, - 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, - 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, - 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, - 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, - 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, - 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, - 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd, - 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, - 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, - 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, - 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, - 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7, - 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, - 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, - 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff -}; - -static uint8_t p_css_tab5[ 256 ] = -{ - 0xff, 0x7f, 0xbf, 0x3f, 0xdf, 0x5f, 0x9f, 0x1f, - 0xef, 0x6f, 0xaf, 0x2f, 0xcf, 0x4f, 0x8f, 0x0f, - 0xf7, 0x77, 0xb7, 0x37, 0xd7, 0x57, 0x97, 0x17, - 0xe7, 0x67, 0xa7, 0x27, 0xc7, 0x47, 0x87, 0x07, - 0xfb, 0x7b, 0xbb, 0x3b, 0xdb, 0x5b, 0x9b, 0x1b, - 0xeb, 0x6b, 0xab, 0x2b, 0xcb, 0x4b, 0x8b, 0x0b, - 0xf3, 0x73, 0xb3, 0x33, 0xd3, 0x53, 0x93, 0x13, - 0xe3, 0x63, 0xa3, 0x23, 0xc3, 0x43, 0x83, 0x03, - 0xfd, 0x7d, 0xbd, 0x3d, 0xdd, 0x5d, 0x9d, 0x1d, - 0xed, 0x6d, 0xad, 0x2d, 0xcd, 0x4d, 0x8d, 0x0d, - 0xf5, 0x75, 0xb5, 0x35, 0xd5, 0x55, 0x95, 0x15, - 0xe5, 0x65, 0xa5, 0x25, 0xc5, 0x45, 0x85, 0x05, - 0xf9, 0x79, 0xb9, 0x39, 0xd9, 0x59, 0x99, 0x19, - 0xe9, 0x69, 0xa9, 0x29, 0xc9, 0x49, 0x89, 0x09, - 0xf1, 0x71, 0xb1, 0x31, 0xd1, 0x51, 0x91, 0x11, - 0xe1, 0x61, 0xa1, 0x21, 0xc1, 0x41, 0x81, 0x01, - 0xfe, 0x7e, 0xbe, 0x3e, 0xde, 0x5e, 0x9e, 0x1e, - 0xee, 0x6e, 0xae, 0x2e, 0xce, 0x4e, 0x8e, 0x0e, - 0xf6, 0x76, 0xb6, 0x36, 0xd6, 0x56, 0x96, 0x16, - 0xe6, 0x66, 0xa6, 0x26, 0xc6, 0x46, 0x86, 0x06, - 0xfa, 0x7a, 0xba, 0x3a, 0xda, 0x5a, 0x9a, 0x1a, - 0xea, 0x6a, 0xaa, 0x2a, 0xca, 0x4a, 0x8a, 0x0a, - 0xf2, 0x72, 0xb2, 0x32, 0xd2, 0x52, 0x92, 0x12, - 0xe2, 0x62, 0xa2, 0x22, 0xc2, 0x42, 0x82, 0x02, - 0xfc, 0x7c, 0xbc, 0x3c, 0xdc, 0x5c, 0x9c, 0x1c, - 0xec, 0x6c, 0xac, 0x2c, 0xcc, 0x4c, 0x8c, 0x0c, - 0xf4, 0x74, 0xb4, 0x34, 0xd4, 0x54, 0x94, 0x14, - 0xe4, 0x64, 0xa4, 0x24, 0xc4, 0x44, 0x84, 0x04, - 0xf8, 0x78, 0xb8, 0x38, 0xd8, 0x58, 0x98, 0x18, - 0xe8, 0x68, 0xa8, 0x28, 0xc8, 0x48, 0x88, 0x08, - 0xf0, 0x70, 0xb0, 0x30, 0xd0, 0x50, 0x90, 0x10, - 0xe0, 0x60, 0xa0, 0x20, 0xc0, 0x40, 0x80, 0x00 -}; - -static uint8_t p_crypt_tab0[ 256 ] = -{ - 0xB7, 0xF4, 0x82, 0x57, 0xDA, 0x4D, 0xDB, 0xE2, - 0x2F, 0x52, 0x1A, 0xA8, 0x68, 0x5A, 0x8A, 0xFF, - 0xFB, 0x0E, 0x6D, 0x35, 0xF7, 0x5C, 0x76, 0x12, - 0xCE, 0x25, 0x79, 0x29, 0x39, 0x62, 0x08, 0x24, - 0xA5, 0x85, 0x7B, 0x56, 0x01, 0x23, 0x68, 0xCF, - 0x0A, 0xE2, 0x5A, 0xED, 0x3D, 0x59, 0xB0, 0xA9, - 0xB0, 0x2C, 0xF2, 0xB8, 0xEF, 0x32, 0xA9, 0x40, - 0x80, 0x71, 0xAF, 0x1E, 0xDE, 0x8F, 0x58, 0x88, - 0xB8, 0x3A, 0xD0, 0xFC, 0xC4, 0x1E, 0xB5, 0xA0, - 0xBB, 0x3B, 0x0F, 0x01, 0x7E, 0x1F, 0x9F, 0xD9, - 0xAA, 0xB8, 0x3D, 0x9D, 0x74, 0x1E, 0x25, 0xDB, - 0x37, 0x56, 0x8F, 0x16, 0xBA, 0x49, 0x2B, 0xAC, - 0xD0, 0xBD, 0x95, 0x20, 0xBE, 0x7A, 0x28, 0xD0, - 0x51, 0x64, 0x63, 0x1C, 0x7F, 0x66, 0x10, 0xBB, - 0xC4, 0x56, 0x1A, 0x04, 0x6E, 0x0A, 0xEC, 0x9C, - 0xD6, 0xE8, 0x9A, 0x7A, 0xCF, 0x8C, 0xDB, 0xB1, - 0xEF, 0x71, 0xDE, 0x31, 0xFF, 0x54, 0x3E, 0x5E, - 0x07, 0x69, 0x96, 0xB0, 0xCF, 0xDD, 0x9E, 0x47, - 0xC7, 0x96, 0x8F, 0xE4, 0x2B, 0x59, 0xC6, 0xEE, - 0xB9, 0x86, 0x9A, 0x64, 0x84, 0x72, 0xE2, 0x5B, - 0xA2, 0x96, 0x58, 0x99, 0x50, 0x03, 0xF5, 0x38, - 0x4D, 0x02, 0x7D, 0xE7, 0x7D, 0x75, 0xA7, 0xB8, - 0x67, 0x87, 0x84, 0x3F, 0x1D, 0x11, 0xE5, 0xFC, - 0x1E, 0xD3, 0x83, 0x16, 0xA5, 0x29, 0xF6, 0xC7, - 0x15, 0x61, 0x29, 0x1A, 0x43, 0x4F, 0x9B, 0xAF, - 0xC5, 0x87, 0x34, 0x6C, 0x0F, 0x3B, 0xA8, 0x1D, - 0x45, 0x58, 0x25, 0xDC, 0xA8, 0xA3, 0x3B, 0xD1, - 0x79, 0x1B, 0x48, 0xF2, 0xE9, 0x93, 0x1F, 0xFC, - 0xDB, 0x2A, 0x90, 0xA9, 0x8A, 0x3D, 0x39, 0x18, - 0xA3, 0x8E, 0x58, 0x6C, 0xE0, 0x12, 0xBB, 0x25, - 0xCD, 0x71, 0x22, 0xA2, 0x64, 0xC6, 0xE7, 0xFB, - 0xAD, 0x94, 0x77, 0x04, 0x9A, 0x39, 0xCF, 0x7C -}; - -static uint8_t p_crypt_tab1[ 256 ] = -{ - 0x8C, 0x47, 0xB0, 0xE1, 0xEB, 0xFC, 0xEB, 0x56, - 0x10, 0xE5, 0x2C, 0x1A, 0x5D, 0xEF, 0xBE, 0x4F, - 0x08, 0x75, 0x97, 0x4B, 0x0E, 0x25, 0x8E, 0x6E, - 0x39, 0x5A, 0x87, 0x53, 0xC4, 0x1F, 0xF4, 0x5C, - 0x4E, 0xE6, 0x99, 0x30, 0xE0, 0x42, 0x88, 0xAB, - 0xE5, 0x85, 0xBC, 0x8F, 0xD8, 0x3C, 0x54, 0xC9, - 0x53, 0x47, 0x18, 0xD6, 0x06, 0x5B, 0x41, 0x2C, - 0x67, 0x1E, 0x41, 0x74, 0x33, 0xE2, 0xB4, 0xE0, - 0x23, 0x29, 0x42, 0xEA, 0x55, 0x0F, 0x25, 0xB4, - 0x24, 0x2C, 0x99, 0x13, 0xEB, 0x0A, 0x0B, 0xC9, - 0xF9, 0x63, 0x67, 0x43, 0x2D, 0xC7, 0x7D, 0x07, - 0x60, 0x89, 0xD1, 0xCC, 0xE7, 0x94, 0x77, 0x74, - 0x9B, 0x7E, 0xD7, 0xE6, 0xFF, 0xBB, 0x68, 0x14, - 0x1E, 0xA3, 0x25, 0xDE, 0x3A, 0xA3, 0x54, 0x7B, - 0x87, 0x9D, 0x50, 0xCA, 0x27, 0xC3, 0xA4, 0x50, - 0x91, 0x27, 0xD4, 0xB0, 0x82, 0x41, 0x97, 0x79, - 0x94, 0x82, 0xAC, 0xC7, 0x8E, 0xA5, 0x4E, 0xAA, - 0x78, 0x9E, 0xE0, 0x42, 0xBA, 0x28, 0xEA, 0xB7, - 0x74, 0xAD, 0x35, 0xDA, 0x92, 0x60, 0x7E, 0xD2, - 0x0E, 0xB9, 0x24, 0x5E, 0x39, 0x4F, 0x5E, 0x63, - 0x09, 0xB5, 0xFA, 0xBF, 0xF1, 0x22, 0x55, 0x1C, - 0xE2, 0x25, 0xDB, 0xC5, 0xD8, 0x50, 0x03, 0x98, - 0xC4, 0xAC, 0x2E, 0x11, 0xB4, 0x38, 0x4D, 0xD0, - 0xB9, 0xFC, 0x2D, 0x3C, 0x08, 0x04, 0x5A, 0xEF, - 0xCE, 0x32, 0xFB, 0x4C, 0x92, 0x1E, 0x4B, 0xFB, - 0x1A, 0xD0, 0xE2, 0x3E, 0xDA, 0x6E, 0x7C, 0x4D, - 0x56, 0xC3, 0x3F, 0x42, 0xB1, 0x3A, 0x23, 0x4D, - 0x6E, 0x84, 0x56, 0x68, 0xF4, 0x0E, 0x03, 0x64, - 0xD0, 0xA9, 0x92, 0x2F, 0x8B, 0xBC, 0x39, 0x9C, - 0xAC, 0x09, 0x5E, 0xEE, 0xE5, 0x97, 0xBF, 0xA5, - 0xCE, 0xFA, 0x28, 0x2C, 0x6D, 0x4F, 0xEF, 0x77, - 0xAA, 0x1B, 0x79, 0x8E, 0x97, 0xB4, 0xC3, 0xF4 -}; - -static uint8_t p_crypt_tab2[ 256 ] = -{ - 0xB7, 0x75, 0x81, 0xD5, 0xDC, 0xCA, 0xDE, 0x66, - 0x23, 0xDF, 0x15, 0x26, 0x62, 0xD1, 0x83, 0x77, - 0xE3, 0x97, 0x76, 0xAF, 0xE9, 0xC3, 0x6B, 0x8E, - 0xDA, 0xB0, 0x6E, 0xBF, 0x2B, 0xF1, 0x19, 0xB4, - 0x95, 0x34, 0x48, 0xE4, 0x37, 0x94, 0x5D, 0x7B, - 0x36, 0x5F, 0x65, 0x53, 0x07, 0xE2, 0x89, 0x11, - 0x98, 0x85, 0xD9, 0x12, 0xC1, 0x9D, 0x84, 0xEC, - 0xA4, 0xD4, 0x88, 0xB8, 0xFC, 0x2C, 0x79, 0x28, - 0xD8, 0xDB, 0xB3, 0x1E, 0xA2, 0xF9, 0xD0, 0x44, - 0xD7, 0xD6, 0x60, 0xEF, 0x14, 0xF4, 0xF6, 0x31, - 0xD2, 0x41, 0x46, 0x67, 0x0A, 0xE1, 0x58, 0x27, - 0x43, 0xA3, 0xF8, 0xE0, 0xC8, 0xBA, 0x5A, 0x5C, - 0x80, 0x6C, 0xC6, 0xF2, 0xE8, 0xAD, 0x7D, 0x04, - 0x0D, 0xB9, 0x3C, 0xC2, 0x25, 0xBD, 0x49, 0x63, - 0x8C, 0x9F, 0x51, 0xCE, 0x20, 0xC5, 0xA1, 0x50, - 0x92, 0x2D, 0xDD, 0xBC, 0x8D, 0x4F, 0x9A, 0x71, - 0x2F, 0x30, 0x1D, 0x73, 0x39, 0x13, 0xFB, 0x1A, - 0xCB, 0x24, 0x59, 0xFE, 0x05, 0x96, 0x57, 0x0F, - 0x1F, 0xCF, 0x54, 0xBE, 0xF5, 0x06, 0x1B, 0xB2, - 0x6D, 0xD3, 0x4D, 0x32, 0x56, 0x21, 0x33, 0x0B, - 0x52, 0xE7, 0xAB, 0xEB, 0xA6, 0x74, 0x00, 0x4C, - 0xB1, 0x7F, 0x82, 0x99, 0x87, 0x0E, 0x5E, 0xC0, - 0x8F, 0xEE, 0x6F, 0x55, 0xF3, 0x7E, 0x08, 0x90, - 0xFA, 0xB6, 0x64, 0x70, 0x47, 0x4A, 0x17, 0xA7, - 0xB5, 0x40, 0x8A, 0x38, 0xE5, 0x68, 0x3E, 0x8B, - 0x69, 0xAA, 0x9B, 0x42, 0xA5, 0x10, 0x01, 0x35, - 0xFD, 0x61, 0x9E, 0xE6, 0x16, 0x9C, 0x86, 0xED, - 0xCD, 0x2E, 0xFF, 0xC4, 0x5B, 0xA0, 0xAE, 0xCC, - 0x4B, 0x3B, 0x03, 0xBB, 0x1C, 0x2A, 0xAC, 0x0C, - 0x3F, 0x93, 0xC7, 0x72, 0x7A, 0x09, 0x22, 0x3D, - 0x45, 0x78, 0xA9, 0xA8, 0xEA, 0xC9, 0x6A, 0xF7, - 0x29, 0x91, 0xF0, 0x02, 0x18, 0x3A, 0x4E, 0x7C -}; - -static uint8_t p_crypt_tab3[ 288 ] = -{ - 0x73, 0x51, 0x95, 0xE1, 0x12, 0xE4, 0xC0, 0x58, - 0xEE, 0xF2, 0x08, 0x1B, 0xA9, 0xFA, 0x98, 0x4C, - 0xA7, 0x33, 0xE2, 0x1B, 0xA7, 0x6D, 0xF5, 0x30, - 0x97, 0x1D, 0xF3, 0x02, 0x60, 0x5A, 0x82, 0x0F, - 0x91, 0xD0, 0x9C, 0x10, 0x39, 0x7A, 0x83, 0x85, - 0x3B, 0xB2, 0xB8, 0xAE, 0x0C, 0x09, 0x52, 0xEA, - 0x1C, 0xE1, 0x8D, 0x66, 0x4F, 0xF3, 0xDA, 0x92, - 0x29, 0xB9, 0xD5, 0xC5, 0x77, 0x47, 0x22, 0x53, - 0x14, 0xF7, 0xAF, 0x22, 0x64, 0xDF, 0xC6, 0x72, - 0x12, 0xF3, 0x75, 0xDA, 0xD7, 0xD7, 0xE5, 0x02, - 0x9E, 0xED, 0xDA, 0xDB, 0x4C, 0x47, 0xCE, 0x91, - 0x06, 0x06, 0x6D, 0x55, 0x8B, 0x19, 0xC9, 0xEF, - 0x8C, 0x80, 0x1A, 0x0E, 0xEE, 0x4B, 0xAB, 0xF2, - 0x08, 0x5C, 0xE9, 0x37, 0x26, 0x5E, 0x9A, 0x90, - 0x00, 0xF3, 0x0D, 0xB2, 0xA6, 0xA3, 0xF7, 0x26, - 0x17, 0x48, 0x88, 0xC9, 0x0E, 0x2C, 0xC9, 0x02, - 0xE7, 0x18, 0x05, 0x4B, 0xF3, 0x39, 0xE1, 0x20, - 0x02, 0x0D, 0x40, 0xC7, 0xCA, 0xB9, 0x48, 0x30, - 0x57, 0x67, 0xCC, 0x06, 0xBF, 0xAC, 0x81, 0x08, - 0x24, 0x7A, 0xD4, 0x8B, 0x19, 0x8E, 0xAC, 0xB4, - 0x5A, 0x0F, 0x73, 0x13, 0xAC, 0x9E, 0xDA, 0xB6, - 0xB8, 0x96, 0x5B, 0x60, 0x88, 0xE1, 0x81, 0x3F, - 0x07, 0x86, 0x37, 0x2D, 0x79, 0x14, 0x52, 0xEA, - 0x73, 0xDF, 0x3D, 0x09, 0xC8, 0x25, 0x48, 0xD8, - 0x75, 0x60, 0x9A, 0x08, 0x27, 0x4A, 0x2C, 0xB9, - 0xA8, 0x8B, 0x8A, 0x73, 0x62, 0x37, 0x16, 0x02, - 0xBD, 0xC1, 0x0E, 0x56, 0x54, 0x3E, 0x14, 0x5F, - 0x8C, 0x8F, 0x6E, 0x75, 0x1C, 0x07, 0x39, 0x7B, - 0x4B, 0xDB, 0xD3, 0x4B, 0x1E, 0xC8, 0x7E, 0xFE, - 0x3E, 0x72, 0x16, 0x83, 0x7D, 0xEE, 0xF5, 0xCA, - 0xC5, 0x18, 0xF9, 0xD8, 0x68, 0xAB, 0x38, 0x85, - 0xA8, 0xF0, 0xA1, 0x73, 0x9F, 0x5D, 0x19, 0x0B, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x33, 0x72, 0x39, 0x25, 0x67, 0x26, 0x6D, 0x71, - 0x36, 0x77, 0x3C, 0x20, 0x62, 0x23, 0x68, 0x74, - 0xC3, 0x82, 0xC9, 0x15, 0x57, 0x16, 0x5D, 0x81 -}; - diff --git a/libdvdcss/device.c b/libdvdcss/device.c deleted file mode 100644 index 0d8e4a0..0000000 --- a/libdvdcss/device.c +++ /dev/null @@ -1,973 +0,0 @@ -/***************************************************************************** - * device.h: DVD device access - ***************************************************************************** - * Copyright (C) 1998-2006 VideoLAN - * $Id$ - * - * Authors: Stéphane Borel - * Sam Hocevar - * Håkan Hjort - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. - *****************************************************************************/ - -/***************************************************************************** - * Preamble - *****************************************************************************/ -#include "config.h" - -#include -#include -#include -#ifdef HAVE_ERRNO_H -# include -#endif -#include -#include -#ifdef HAVE_SYS_PARAM_H -# include -#endif -#include - -#ifdef HAVE_UNISTD_H -# include -#endif - -#ifdef HAVE_LIMITS_H -# include -#endif - -#if defined( WIN32 ) && !defined( SYS_CYGWIN ) -# include /* read() */ -#else -# include /* struct iovec */ -#endif - -#ifdef DARWIN_DVD_IOCTL -# include -# include -# include -# include -# include -# include -# include -#endif - -#include "dvdcss/dvdcss.h" - -#include "common.h" -#include "css.h" -#include "libdvdcss.h" -#include "ioctl.h" -#include "device.h" - -/***************************************************************************** - * Device reading prototypes - *****************************************************************************/ -static int libc_open ( dvdcss_t, char const * ); -static int libc_seek ( dvdcss_t, int ); -static int libc_read ( dvdcss_t, void *, int ); -static int libc_readv ( dvdcss_t, struct iovec *, int ); - -#ifdef WIN32 -static int win2k_open ( dvdcss_t, char const * ); -static int aspi_open ( dvdcss_t, char const * ); -static int win2k_seek ( dvdcss_t, int ); -static int aspi_seek ( dvdcss_t, int ); -static int win2k_read ( dvdcss_t, void *, int ); -static int aspi_read ( dvdcss_t, void *, int ); -static int win_readv ( dvdcss_t, struct iovec *, int ); - -static int aspi_read_internal ( int, void *, int ); -#endif - -int _dvdcss_use_ioctls( dvdcss_t dvdcss ) -{ -#if defined( WIN32 ) - if( dvdcss->b_file ) - { - return 0; - } - - /* FIXME: implement this for Windows */ - if( WIN2K ) - { - return 1; - } - else - { - return 1; - } -#else - struct stat fileinfo; - int ret; - - ret = fstat( dvdcss->i_fd, &fileinfo ); - if( ret < 0 ) - { - return 1; /* What to do? Be conservative and try to use the ioctls */ - } - - /* Complete this list and check that we test for the right things - * (I've assumed for all OSs that 'r', (raw) device, are char devices - * and those that don't contain/use an 'r' in the name are block devices) - * - * Linux needs a block device - * Solaris needs a char device - * Darwin needs a char device - * OpenBSD needs a char device - * NetBSD needs a char device - * FreeBSD can use either the block or the char device - * BSD/OS can use either the block or the char device - */ - - /* Check if this is a block/char device */ - if( S_ISBLK( fileinfo.st_mode ) || - S_ISCHR( fileinfo.st_mode ) ) - { - return 1; - } - else - { - return 0; - } -#endif -} - -void _dvdcss_check ( dvdcss_t dvdcss ) -{ -#if defined( WIN32 ) - DWORD drives; - int i; -#elif defined( DARWIN_DVD_IOCTL ) - io_object_t next_media; - mach_port_t master_port; - kern_return_t kern_result; - io_iterator_t media_iterator; - CFMutableDictionaryRef classes_to_match; -#else - char *ppsz_devices[] = { "/dev/dvd", "/dev/cdrom", "/dev/hdc", NULL }; - int i, i_fd; -#endif - - /* If the device name is non-null, return */ - if( dvdcss->psz_device[0] ) - { - return; - } - -#if defined( WIN32 ) - drives = GetLogicalDrives(); - - for( i = 0; drives; i++ ) - { - char psz_device[5]; - DWORD cur = 1 << i; - UINT i_ret; - - if( (drives & cur) == 0 ) - { - continue; - } - drives &= ~cur; - - sprintf( psz_device, "%c:\\", 'A' + i ); - i_ret = GetDriveType( psz_device ); - if( i_ret != DRIVE_CDROM ) - { - continue; - } - - /* Remove trailing backslash */ - psz_device[2] = '\0'; - - /* FIXME: we want to differenciate between CD and DVD drives - * using DeviceIoControl() */ - print_debug( dvdcss, "defaulting to drive `%s'", psz_device ); - free( dvdcss->psz_device ); - dvdcss->psz_device = strdup( psz_device ); - return; - } -#elif defined( DARWIN_DVD_IOCTL ) - - kern_result = IOMasterPort( MACH_PORT_NULL, &master_port ); - if( kern_result != KERN_SUCCESS ) - { - return; - } - - classes_to_match = IOServiceMatching( kIODVDMediaClass ); - if( classes_to_match == NULL ) - { - return; - } - - CFDictionarySetValue( classes_to_match, CFSTR( kIOMediaEjectableKey ), - kCFBooleanTrue ); - - kern_result = IOServiceGetMatchingServices( master_port, classes_to_match, - &media_iterator ); - if( kern_result != KERN_SUCCESS ) - { - return; - } - - next_media = IOIteratorNext( media_iterator ); - for( ; ; ) - { - char psz_buf[0x32]; - size_t i_pathlen; - CFTypeRef psz_path; - - next_media = IOIteratorNext( media_iterator ); - if( next_media == 0 ) - { - break; - } - - psz_path = IORegistryEntryCreateCFProperty( next_media, - CFSTR( kIOBSDNameKey ), - kCFAllocatorDefault, - 0 ); - if( psz_path == NULL ) - { - IOObjectRelease( next_media ); - continue; - } - - snprintf( psz_buf, sizeof(psz_buf), "%s%c", _PATH_DEV, 'r' ); - i_pathlen = strlen( psz_buf ); - - if( CFStringGetCString( psz_path, - (char*)&psz_buf + i_pathlen, - sizeof(psz_buf) - i_pathlen, - kCFStringEncodingASCII ) ) - { - print_debug( dvdcss, "defaulting to drive `%s'", psz_buf ); - CFRelease( psz_path ); - IOObjectRelease( next_media ); - IOObjectRelease( media_iterator ); - free( dvdcss->psz_device ); - dvdcss->psz_device = strdup( psz_buf ); - return; - } - - CFRelease( psz_path ); - - IOObjectRelease( next_media ); - } - - IOObjectRelease( media_iterator ); -#else - for( i = 0; ppsz_devices[i]; i++ ) - { - i_fd = open( ppsz_devices[i], 0 ); - if( i_fd != -1 ) - { - print_debug( dvdcss, "defaulting to drive `%s'", ppsz_devices[i] ); - close( i_fd ); - free( dvdcss->psz_device ); - dvdcss->psz_device = strdup( ppsz_devices[i] ); - return; - } - } -#endif - - print_error( dvdcss, "could not find a suitable default drive" ); -} - -int _dvdcss_open ( dvdcss_t dvdcss ) -{ - char const *psz_device = dvdcss->psz_device; - - print_debug( dvdcss, "opening target `%s'", psz_device ); - -#if defined( WIN32 ) - dvdcss->b_file = 1; - /* If device is "X:" or "X:\", we are not actually opening a file. */ - if (psz_device[0] && psz_device[1] == ':' && - (!psz_device[2] || (psz_device[2] == '\\' && !psz_device[3]))) - dvdcss->b_file = 0; - - /* Initialize readv temporary buffer */ - dvdcss->p_readv_buffer = NULL; - dvdcss->i_readv_buf_size = 0; - - if( !dvdcss->b_file && WIN2K ) - { - print_debug( dvdcss, "using Win2K API for access" ); - dvdcss->pf_seek = win2k_seek; - dvdcss->pf_read = win2k_read; - dvdcss->pf_readv = win_readv; - return win2k_open( dvdcss, psz_device ); - } - else if( !dvdcss->b_file ) - { - print_debug( dvdcss, "using ASPI for access" ); - dvdcss->pf_seek = aspi_seek; - dvdcss->pf_read = aspi_read; - dvdcss->pf_readv = win_readv; - return aspi_open( dvdcss, psz_device ); - } - else -#endif - { - print_debug( dvdcss, "using libc for access" ); - dvdcss->pf_seek = libc_seek; - dvdcss->pf_read = libc_read; - dvdcss->pf_readv = libc_readv; - return libc_open( dvdcss, psz_device ); - } -} - -#ifndef WIN32 -int _dvdcss_raw_open ( dvdcss_t dvdcss, char const *psz_device ) -{ - dvdcss->i_raw_fd = open( psz_device, 0 ); - - if( dvdcss->i_raw_fd == -1 ) - { - print_debug( dvdcss, "cannot open %s (%s)", - psz_device, strerror(errno) ); - print_error( dvdcss, "failed to open raw device, but continuing" ); - return -1; - } - else - { - dvdcss->i_read_fd = dvdcss->i_raw_fd; - } - - return 0; -} -#endif - -int _dvdcss_close ( dvdcss_t dvdcss ) -{ -#if defined( WIN32 ) - if( dvdcss->b_file ) - { - close( dvdcss->i_fd ); - } - else if( WIN2K ) - { - CloseHandle( (HANDLE) dvdcss->i_fd ); - } - else /* ASPI */ - { - struct w32_aspidev *fd = (struct w32_aspidev *) dvdcss->i_fd; - - /* Unload aspi and free w32_aspidev structure */ - FreeLibrary( (HMODULE) fd->hASPI ); - free( (void*) dvdcss->i_fd ); - } - - /* Free readv temporary buffer */ - if( dvdcss->p_readv_buffer ) - { - free( dvdcss->p_readv_buffer ); - dvdcss->p_readv_buffer = NULL; - dvdcss->i_readv_buf_size = 0; - } - - return 0; -#else - close( dvdcss->i_fd ); - - if( dvdcss->i_raw_fd >= 0 ) - { - close( dvdcss->i_raw_fd ); - dvdcss->i_raw_fd = -1; - } - - return 0; -#endif -} - -/* Following functions are local */ - -/***************************************************************************** - * Open commands. - *****************************************************************************/ -static int libc_open ( dvdcss_t dvdcss, char const *psz_device ) -{ -#if !defined( WIN32 ) - dvdcss->i_fd = dvdcss->i_read_fd = open( psz_device, 0 ); -#else - dvdcss->i_fd = dvdcss->i_read_fd = open( psz_device, O_BINARY ); -#endif - - if( dvdcss->i_fd == -1 ) - { - print_debug( dvdcss, "cannot open %s (%s)", - psz_device, strerror(errno) ); - print_error( dvdcss, "failed to open device" ); - return -1; - } - - dvdcss->i_pos = 0; - - return 0; -} - -#if defined( WIN32 ) -static int win2k_open ( dvdcss_t dvdcss, char const *psz_device ) -{ - char psz_dvd[7]; - _snprintf( psz_dvd, 7, "\\\\.\\%c:", psz_device[0] ); - - /* To work around an M$ bug in IOCTL_DVD_READ_STRUCTURE, we need read - * _and_ write access to the device (so we can make SCSI Pass Through - * Requests). Unfortunately this is only allowed if you have - * administrator priviledges so we allow for a fallback method with - * only read access to the device (in this case ioctl_ReadCopyright() - * won't send back the right result). - * (See Microsoft Q241374: Read and Write Access Required for SCSI - * Pass Through Requests) */ - dvdcss->i_fd = (int) - CreateFile( psz_dvd, GENERIC_READ | GENERIC_WRITE, - FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, OPEN_EXISTING, - FILE_FLAG_RANDOM_ACCESS, NULL ); - - if( (HANDLE) dvdcss->i_fd == INVALID_HANDLE_VALUE ) - dvdcss->i_fd = (int) - CreateFile( psz_dvd, GENERIC_READ, FILE_SHARE_READ, - NULL, OPEN_EXISTING, - FILE_FLAG_RANDOM_ACCESS, NULL ); - - if( (HANDLE) dvdcss->i_fd == INVALID_HANDLE_VALUE ) - { - print_error( dvdcss, "failed opening device" ); - return -1; - } - - dvdcss->i_pos = 0; - - return 0; -} - -static int aspi_open( dvdcss_t dvdcss, char const * psz_device ) -{ - HMODULE hASPI; - DWORD dwSupportInfo; - struct w32_aspidev *fd; - int i, j, i_hostadapters; - GETASPI32SUPPORTINFO lpGetSupport; - SENDASPI32COMMAND lpSendCommand; - char c_drive = psz_device[0]; - - /* load aspi and init w32_aspidev structure */ - hASPI = LoadLibrary( "wnaspi32.dll" ); - if( hASPI == NULL ) - { - print_error( dvdcss, "unable to load wnaspi32.dll" ); - return -1; - } - - lpGetSupport = (GETASPI32SUPPORTINFO) GetProcAddress( hASPI, "GetASPI32SupportInfo" ); - lpSendCommand = (SENDASPI32COMMAND) GetProcAddress( hASPI, "SendASPI32Command" ); - - if(lpGetSupport == NULL || lpSendCommand == NULL ) - { - print_error( dvdcss, "unable to get aspi function pointers" ); - FreeLibrary( hASPI ); - return -1; - } - - dwSupportInfo = lpGetSupport(); - - if( HIBYTE( LOWORD ( dwSupportInfo ) ) == SS_NO_ADAPTERS ) - { - print_error( dvdcss, "no ASPI adapters found" ); - FreeLibrary( hASPI ); - return -1; - } - - if( HIBYTE( LOWORD ( dwSupportInfo ) ) != SS_COMP ) - { - print_error( dvdcss, "unable to initalize aspi layer" ); - FreeLibrary( hASPI ); - return -1; - } - - i_hostadapters = LOBYTE( LOWORD( dwSupportInfo ) ); - if( i_hostadapters == 0 ) - { - print_error( dvdcss, "no ASPI adapters ready" ); - FreeLibrary( hASPI ); - return -1; - } - - fd = malloc( sizeof( struct w32_aspidev ) ); - if( fd == NULL ) - { - print_error( dvdcss, "not enough memory" ); - FreeLibrary( hASPI ); - return -1; - } - - fd->i_blocks = 0; - fd->hASPI = (long) hASPI; - fd->lpSendCommand = lpSendCommand; - - c_drive = c_drive > 'Z' ? c_drive - 'a' : c_drive - 'A'; - - for( i = 0; i < i_hostadapters; i++ ) - { - for( j = 0; j < 15; j++ ) - { - struct SRB_GetDiskInfo srbDiskInfo; - - srbDiskInfo.SRB_Cmd = SC_GET_DISK_INFO; - srbDiskInfo.SRB_HaId = i; - srbDiskInfo.SRB_Flags = 0; - srbDiskInfo.SRB_Hdr_Rsvd = 0; - srbDiskInfo.SRB_Target = j; - srbDiskInfo.SRB_Lun = 0; - - lpSendCommand( (void*) &srbDiskInfo ); - - if( (srbDiskInfo.SRB_Status == SS_COMP) && - (srbDiskInfo.SRB_Int13HDriveInfo == c_drive) ) - { - /* Make sure this is a cdrom device */ - struct SRB_GDEVBlock srbGDEVBlock; - - memset( &srbGDEVBlock, 0, sizeof(struct SRB_GDEVBlock) ); - srbGDEVBlock.SRB_Cmd = SC_GET_DEV_TYPE; - srbGDEVBlock.SRB_HaId = i; - srbGDEVBlock.SRB_Target = j; - - lpSendCommand( (void*) &srbGDEVBlock ); - - if( ( srbGDEVBlock.SRB_Status == SS_COMP ) && - ( srbGDEVBlock.SRB_DeviceType == DTYPE_CDROM ) ) - { - fd->i_sid = MAKEWORD( i, j ); - dvdcss->i_fd = (int) fd; - dvdcss->i_pos = 0; - return 0; - } - else - { - free( (void*) fd ); - FreeLibrary( hASPI ); - print_error( dvdcss,"this is not a cdrom drive" ); - return -1; - } - } - } - } - - free( (void*) fd ); - FreeLibrary( hASPI ); - print_error( dvdcss, "unable to get haid and target (aspi)" ); - return -1; -} -#endif - -/***************************************************************************** - * Seek commands. - *****************************************************************************/ -static int libc_seek( dvdcss_t dvdcss, int i_blocks ) -{ - off_t i_seek; - - if( dvdcss->i_pos == i_blocks ) - { - /* We are already in position */ - return i_blocks; - } - - i_seek = (off_t)i_blocks * (off_t)DVDCSS_BLOCK_SIZE; - i_seek = lseek( dvdcss->i_read_fd, i_seek, SEEK_SET ); - - if( i_seek < 0 ) - { - print_error( dvdcss, "seek error" ); - dvdcss->i_pos = -1; - return i_seek; - } - - dvdcss->i_pos = i_seek / DVDCSS_BLOCK_SIZE; - - return dvdcss->i_pos; -} - -#if defined( WIN32 ) -static int win2k_seek( dvdcss_t dvdcss, int i_blocks ) -{ - LARGE_INTEGER li_seek; - -#ifndef INVALID_SET_FILE_POINTER -# define INVALID_SET_FILE_POINTER ((DWORD)-1) -#endif - - if( dvdcss->i_pos == i_blocks ) - { - /* We are already in position */ - return i_blocks; - } - - li_seek.QuadPart = (LONGLONG)i_blocks * DVDCSS_BLOCK_SIZE; - - li_seek.LowPart = SetFilePointer( (HANDLE) dvdcss->i_fd, - li_seek.LowPart, - &li_seek.HighPart, FILE_BEGIN ); - if( (li_seek.LowPart == INVALID_SET_FILE_POINTER) - && GetLastError() != NO_ERROR) - { - dvdcss->i_pos = -1; - return -1; - } - - dvdcss->i_pos = li_seek.QuadPart / DVDCSS_BLOCK_SIZE; - - return dvdcss->i_pos; -} - -static int aspi_seek( dvdcss_t dvdcss, int i_blocks ) -{ - int i_old_blocks; - char sz_buf[ DVDCSS_BLOCK_SIZE ]; - struct w32_aspidev *fd = (struct w32_aspidev *) dvdcss->i_fd; - - if( dvdcss->i_pos == i_blocks ) - { - /* We are already in position */ - return i_blocks; - } - - i_old_blocks = fd->i_blocks; - fd->i_blocks = i_blocks; - - if( aspi_read_internal( dvdcss->i_fd, sz_buf, 1 ) == -1 ) - { - fd->i_blocks = i_old_blocks; - dvdcss->i_pos = -1; - return -1; - } - - (fd->i_blocks)--; - - dvdcss->i_pos = fd->i_blocks; - - return dvdcss->i_pos; -} -#endif - -/***************************************************************************** - * Read commands. - *****************************************************************************/ -static int libc_read ( dvdcss_t dvdcss, void *p_buffer, int i_blocks ) -{ - off_t i_size, i_ret; - - i_size = (off_t)i_blocks * (off_t)DVDCSS_BLOCK_SIZE; - i_ret = read( dvdcss->i_read_fd, p_buffer, i_size ); - - if( i_ret < 0 ) - { - print_error( dvdcss, "read error" ); - dvdcss->i_pos = -1; - return i_ret; - } - - /* Handle partial reads */ - if( i_ret != i_size ) - { - int i_seek; - - dvdcss->i_pos = -1; - i_seek = libc_seek( dvdcss, i_ret / DVDCSS_BLOCK_SIZE ); - if( i_seek < 0 ) - { - return i_seek; - } - - /* We have to return now so that i_pos isn't clobbered */ - return i_ret / DVDCSS_BLOCK_SIZE; - } - - dvdcss->i_pos += i_ret / DVDCSS_BLOCK_SIZE; - return i_ret / DVDCSS_BLOCK_SIZE; -} - -#if defined( WIN32 ) -static int win2k_read ( dvdcss_t dvdcss, void *p_buffer, int i_blocks ) -{ - int i_bytes; - - if( !ReadFile( (HANDLE) dvdcss->i_fd, p_buffer, - i_blocks * DVDCSS_BLOCK_SIZE, - (LPDWORD)&i_bytes, NULL ) ) - { - dvdcss->i_pos = -1; - return -1; - } - - dvdcss->i_pos += i_bytes / DVDCSS_BLOCK_SIZE; - return i_bytes / DVDCSS_BLOCK_SIZE; -} - -static int aspi_read ( dvdcss_t dvdcss, void *p_buffer, int i_blocks ) -{ - int i_read = aspi_read_internal( dvdcss->i_fd, p_buffer, i_blocks ); - - if( i_read < 0 ) - { - dvdcss->i_pos = -1; - return i_read; - } - - dvdcss->i_pos += i_read; - return i_read; -} -#endif - -/***************************************************************************** - * Readv commands. - *****************************************************************************/ -static int libc_readv ( dvdcss_t dvdcss, struct iovec *p_iovec, int i_blocks ) -{ -#if defined( WIN32 ) - int i_index, i_len, i_total = 0; - unsigned char *p_base; - int i_bytes; - - for( i_index = i_blocks; - i_index; - i_index--, p_iovec++ ) - { - i_len = p_iovec->iov_len; - p_base = p_iovec->iov_base; - - if( i_len <= 0 ) - { - continue; - } - - i_bytes = read( dvdcss->i_fd, p_base, i_len ); - - if( i_bytes < 0 ) - { - /* One of the reads failed, too bad. - * We won't even bother returning the reads that went ok, - * and as in the posix spec the file postition is left - * unspecified after a failure */ - dvdcss->i_pos = -1; - return -1; - } - - i_total += i_bytes; - - if( i_bytes != i_len ) - { - /* We reached the end of the file or a signal interrupted - * the read. Return a partial read. */ - int i_seek; - - dvdcss->i_pos = -1; - i_seek = libc_seek( dvdcss, i_total / DVDCSS_BLOCK_SIZE ); - if( i_seek < 0 ) - { - return i_seek; - } - - /* We have to return now so that i_pos isn't clobbered */ - return i_total / DVDCSS_BLOCK_SIZE; - } - } - - dvdcss->i_pos += i_total / DVDCSS_BLOCK_SIZE; - return i_total / DVDCSS_BLOCK_SIZE; -#else - int i_read = readv( dvdcss->i_read_fd, p_iovec, i_blocks ); - - if( i_read < 0 ) - { - dvdcss->i_pos = -1; - return i_read; - } - - dvdcss->i_pos += i_read / DVDCSS_BLOCK_SIZE; - return i_read / DVDCSS_BLOCK_SIZE; -#endif -} - -#if defined( WIN32 ) -/***************************************************************************** - * win_readv: vectored read using ReadFile for Win2K and ASPI for win9x - *****************************************************************************/ -static int win_readv ( dvdcss_t dvdcss, struct iovec *p_iovec, int i_blocks ) -{ - int i_index; - int i_blocks_read, i_blocks_total = 0; - - /* Check the size of the readv temp buffer, just in case we need to - * realloc something bigger */ - if( dvdcss->i_readv_buf_size < i_blocks * DVDCSS_BLOCK_SIZE ) - { - dvdcss->i_readv_buf_size = i_blocks * DVDCSS_BLOCK_SIZE; - - if( dvdcss->p_readv_buffer ) free( dvdcss->p_readv_buffer ); - - /* Allocate a buffer which will be used as a temporary storage - * for readv */ - dvdcss->p_readv_buffer = malloc( dvdcss->i_readv_buf_size ); - if( !dvdcss->p_readv_buffer ) - { - print_error( dvdcss, " failed (readv)" ); - dvdcss->i_pos = -1; - return -1; - } - } - - for( i_index = i_blocks; i_index; i_index-- ) - { - i_blocks_total += p_iovec[i_index-1].iov_len; - } - - if( i_blocks_total <= 0 ) return 0; - - i_blocks_total /= DVDCSS_BLOCK_SIZE; - - if( WIN2K ) - { - unsigned long int i_bytes; - if( !ReadFile( (HANDLE)dvdcss->i_fd, dvdcss->p_readv_buffer, - i_blocks_total * DVDCSS_BLOCK_SIZE, &i_bytes, NULL ) ) - { - /* The read failed... too bad. - * As in the posix spec the file postition is left - * unspecified after a failure */ - dvdcss->i_pos = -1; - return -1; - } - i_blocks_read = i_bytes / DVDCSS_BLOCK_SIZE; - } - else /* Win9x */ - { - i_blocks_read = aspi_read_internal( dvdcss->i_fd, - dvdcss->p_readv_buffer, - i_blocks_total ); - if( i_blocks_read < 0 ) - { - /* See above */ - dvdcss->i_pos = -1; - return -1; - } - } - - /* We just have to copy the content of the temp buffer into the iovecs */ - for( i_index = 0, i_blocks_total = i_blocks_read; - i_blocks_total > 0; - i_index++ ) - { - memcpy( p_iovec[i_index].iov_base, - dvdcss->p_readv_buffer + (i_blocks_read - i_blocks_total) - * DVDCSS_BLOCK_SIZE, - p_iovec[i_index].iov_len ); - /* if we read less blocks than asked, we'll just end up copying - * garbage, this isn't an issue as we return the number of - * blocks actually read */ - i_blocks_total -= ( p_iovec[i_index].iov_len / DVDCSS_BLOCK_SIZE ); - } - - dvdcss->i_pos += i_blocks_read; - return i_blocks_read; -} - -static int aspi_read_internal( int i_fd, void *p_data, int i_blocks ) -{ - HANDLE hEvent; - struct SRB_ExecSCSICmd ssc; - struct w32_aspidev *fd = (struct w32_aspidev *) i_fd; - - /* Create the transfer completion event */ - hEvent = CreateEvent( NULL, TRUE, FALSE, NULL ); - if( hEvent == NULL ) - { - return -1; - } - - memset( &ssc, 0, sizeof( ssc ) ); - - ssc.SRB_Cmd = SC_EXEC_SCSI_CMD; - ssc.SRB_Flags = SRB_DIR_IN | SRB_EVENT_NOTIFY; - ssc.SRB_HaId = LOBYTE( fd->i_sid ); - ssc.SRB_Target = HIBYTE( fd->i_sid ); - ssc.SRB_SenseLen = SENSE_LEN; - - ssc.SRB_PostProc = (LPVOID) hEvent; - ssc.SRB_BufPointer = p_data; - ssc.SRB_CDBLen = 12; - - ssc.CDBByte[0] = 0xA8; /* RAW */ - ssc.CDBByte[2] = (UCHAR) (fd->i_blocks >> 24); - ssc.CDBByte[3] = (UCHAR) (fd->i_blocks >> 16) & 0xff; - ssc.CDBByte[4] = (UCHAR) (fd->i_blocks >> 8) & 0xff; - ssc.CDBByte[5] = (UCHAR) (fd->i_blocks) & 0xff; - - /* We have to break down the reads into 64kb pieces (ASPI restriction) */ - if( i_blocks > 32 ) - { - ssc.SRB_BufLen = 32 * DVDCSS_BLOCK_SIZE; - ssc.CDBByte[9] = 32; - fd->i_blocks += 32; - - /* Initiate transfer */ - ResetEvent( hEvent ); - fd->lpSendCommand( (void*) &ssc ); - - /* transfer the next 64kb (aspi_read_internal is called recursively) - * We need to check the status of the read on return */ - if( aspi_read_internal( i_fd, - (uint8_t*) p_data + 32 * DVDCSS_BLOCK_SIZE, - i_blocks - 32) < 0 ) - { - return -1; - } - } - else - { - /* This is the last transfer */ - ssc.SRB_BufLen = i_blocks * DVDCSS_BLOCK_SIZE; - ssc.CDBByte[9] = (UCHAR) i_blocks; - fd->i_blocks += i_blocks; - - /* Initiate transfer */ - ResetEvent( hEvent ); - fd->lpSendCommand( (void*) &ssc ); - - } - - /* If the command has still not been processed, wait until it's finished */ - if( ssc.SRB_Status == SS_PENDING ) - { - WaitForSingleObject( hEvent, INFINITE ); - } - CloseHandle( hEvent ); - - /* check that the transfer went as planned */ - if( ssc.SRB_Status != SS_COMP ) - { - return -1; - } - - return i_blocks; -} -#endif - diff --git a/libdvdcss/device.h b/libdvdcss/device.h deleted file mode 100644 index d8a73f0..0000000 --- a/libdvdcss/device.h +++ /dev/null @@ -1,58 +0,0 @@ -/***************************************************************************** - * device.h: DVD device access - ***************************************************************************** - * Copyright (C) 1998-2002 VideoLAN - * $Id$ - * - * Authors: Stéphane Borel - * Sam Hocevar - * Håkan Hjort - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. - *****************************************************************************/ - -/***************************************************************************** - * iovec structure: vectored data entry - *****************************************************************************/ -#if defined( WIN32 ) && !defined( SYS_CYGWIN ) -# include /* read() */ -#else -# include -# include /* struct iovec */ -#endif - -#if defined( WIN32 ) && !defined( SYS_CYGWIN ) -struct iovec -{ - void *iov_base; /* Pointer to data. */ - size_t iov_len; /* Length of data. */ -}; -#endif - -/***************************************************************************** - * Device reading prototypes - *****************************************************************************/ -int _dvdcss_use_ioctls ( dvdcss_t ); -void _dvdcss_check ( dvdcss_t ); -int _dvdcss_open ( dvdcss_t ); -int _dvdcss_close ( dvdcss_t ); - -/***************************************************************************** - * Device reading prototypes, raw-device specific - *****************************************************************************/ -#ifndef WIN32 -int _dvdcss_raw_open ( dvdcss_t, char const * ); -#endif - diff --git a/libdvdcss/dvdcss/dvdcss.h b/libdvdcss/dvdcss/dvdcss.h deleted file mode 100644 index c97f996..0000000 --- a/libdvdcss/dvdcss/dvdcss.h +++ /dev/null @@ -1,107 +0,0 @@ -/** - * \file dvdcss.h - * \author Stéphane Borel - * \author Sam Hocevar - * \brief The \e libdvdcss public header. - * - * This header contains the public types and functions that applications - * using \e libdvdcss may use. - */ - -/* - * Copyright (C) 1998-2008 VideoLAN - * $Id$ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. - */ - -#ifndef DVDCSS_DVDCSS_H -#ifndef _DOXYGEN_SKIP_ME -#define DVDCSS_DVDCSS_H 1 -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/** Library instance handle, to be used for each library call. */ -typedef struct dvdcss_s* dvdcss_t; - - -/** The block size of a DVD. */ -#define DVDCSS_BLOCK_SIZE 2048 - -/** The default flag to be used by \e libdvdcss functions. */ -#define DVDCSS_NOFLAGS 0 - -/** Flag to ask dvdcss_read() to decrypt the data it reads. */ -#define DVDCSS_READ_DECRYPT (1 << 0) - -/** Flag to tell dvdcss_seek() it is seeking in MPEG data. */ -#define DVDCSS_SEEK_MPEG (1 << 0) - -/** Flag to ask dvdcss_seek() to check the current title key. */ -#define DVDCSS_SEEK_KEY (1 << 1) - - -#if defined(LIBDVDCSS_EXPORTS) -#define LIBDVDCSS_EXPORT __declspec(dllexport) extern -#elif defined(LIBDVDCSS_IMPORTS) -#define LIBDVDCSS_EXPORT __declspec(dllimport) extern -#else -#define LIBDVDCSS_EXPORT extern -#endif - -/* - * Our version number. The variable name contains the interface version. - */ -LIBDVDCSS_EXPORT char * dvdcss_interface_2; - - -/* - * Exported prototypes. - */ -LIBDVDCSS_EXPORT dvdcss_t dvdcss_open ( char *psz_target ); -LIBDVDCSS_EXPORT int dvdcss_close ( dvdcss_t ); -LIBDVDCSS_EXPORT int dvdcss_seek ( dvdcss_t, - int i_blocks, - int i_flags ); -LIBDVDCSS_EXPORT int dvdcss_read ( dvdcss_t, - void *p_buffer, - int i_blocks, - int i_flags ); -LIBDVDCSS_EXPORT int dvdcss_readv ( dvdcss_t, - void *p_iovec, - int i_blocks, - int i_flags ); -LIBDVDCSS_EXPORT char * dvdcss_error ( dvdcss_t ); - -LIBDVDCSS_EXPORT int dvdcss_is_scrambled ( dvdcss_t ); - - -/* - * Deprecated stuff. - */ -#ifndef _DOXYGEN_SKIP_ME -#define dvdcss_title(a,b) dvdcss_seek(a,b,DVDCSS_SEEK_KEY) -#define dvdcss_handle dvdcss_t -#endif - - -#ifdef __cplusplus -} -#endif - -#endif /* DVDCSS_DVDCSS_H */ diff --git a/libdvdcss/error.c b/libdvdcss/error.c deleted file mode 100644 index 66d2b67..0000000 --- a/libdvdcss/error.c +++ /dev/null @@ -1,68 +0,0 @@ -/***************************************************************************** - * error.c: error management functions - ***************************************************************************** - * Copyright (C) 1998-2002 VideoLAN - * $Id$ - * - * Author: Sam Hocevar - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. - *****************************************************************************/ - -#include "config.h" - -#include -#include - -#ifdef HAVE_SYS_PARAM_H -# include -#endif - -#ifdef HAVE_LIMITS_H -# include -#endif - -#include "dvdcss/dvdcss.h" - -#include "common.h" -#include "css.h" -#include "libdvdcss.h" - -/***************************************************************************** - * Error messages - *****************************************************************************/ -void _print_error( dvdcss_t dvdcss, char *psz_string ) -{ - if( dvdcss->b_errors ) - { - fprintf( stderr, "libdvdcss error: %s\n", psz_string ); - } - - dvdcss->psz_error = psz_string; -} - -/***************************************************************************** - * Debug messages - *****************************************************************************/ -#if 0 -void _print_debug( dvdcss_t dvdcss, char *psz_string ) -{ - if( dvdcss->b_debug ) - { - fprintf( stderr, "libdvdcss debug: %s\n", psz_string ); - } -} -#endif - diff --git a/libdvdcss/ioctl.c b/libdvdcss/ioctl.c deleted file mode 100644 index d090399..0000000 --- a/libdvdcss/ioctl.c +++ /dev/null @@ -1,2123 +0,0 @@ -/***************************************************************************** - * ioctl.c: DVD ioctl replacement function - ***************************************************************************** - * Copyright (C) 1999-2001 VideoLAN - * $Id$ - * - * Authors: Markus Kuespert - * Sam Hocevar - * Jon Lech Johansen - * Håkan Hjort - * Eugenio Jarosiewicz - * David Siebörger - * Alex Strelnikov - * Gildas Bazin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. - *****************************************************************************/ - -/***************************************************************************** - * Preamble - *****************************************************************************/ -#include "config.h" - -#include - -#include /* memcpy(), memset() */ -#include - -#if defined( WIN32 ) -# include -# include -#elif defined ( SYS_OS2 ) -# define INCL_DOSFILEMGR -# define INCL_DOSDEVICES -# define INCL_DOSDEVIOCTL -# define INCL_DOSERRORS -# include -# include -#else -# include -# include -#endif - -#ifdef DVD_STRUCT_IN_SYS_CDIO_H -# include -#endif -#ifdef DVD_STRUCT_IN_SYS_DVDIO_H -# include -#endif -#ifdef DVD_STRUCT_IN_LINUX_CDROM_H -# include -#endif -#ifdef DVD_STRUCT_IN_DVD_H -# include -#endif -#ifdef DVD_STRUCT_IN_BSDI_DVDIOCTL_DVD_H -# include "bsdi_dvd.h" -#endif -#ifdef SYS_BEOS -# include -# include -#endif -#ifdef HPUX_SCTL_IO -# include -#endif -#ifdef SOLARIS_USCSI -# include -# include -# include -# include -# include -#endif -#ifdef DARWIN_DVD_IOCTL -# include -#endif -#ifdef __QNXNTO__ -# include -# include -#endif - -#include "common.h" - -#include "ioctl.h" - -/***************************************************************************** - * Local prototypes, BeOS specific - *****************************************************************************/ -#if defined( SYS_BEOS ) -static void BeInitRDC ( raw_device_command *, int ); -#endif - -/***************************************************************************** - * Local prototypes, HP-UX specific - *****************************************************************************/ -#if defined( HPUX_SCTL_IO ) -static void HPUXInitSCTL ( struct sctl_io *sctl_io, int i_type ); -#endif - -/***************************************************************************** - * Local prototypes, Solaris specific - *****************************************************************************/ -#if defined( SOLARIS_USCSI ) -static void SolarisInitUSCSI( struct uscsi_cmd *p_sc, int i_type ); -static int SolarisSendUSCSI( int fd, struct uscsi_cmd *p_sc ); -#endif - -/***************************************************************************** - * Local prototypes, win32 (aspi) specific - *****************************************************************************/ -#if defined( WIN32 ) -static void WinInitSPTD ( SCSI_PASS_THROUGH_DIRECT *, int ); -static void WinInitSSC ( struct SRB_ExecSCSICmd *, int ); -static int WinSendSSC ( int, struct SRB_ExecSCSICmd * ); -#endif - -/***************************************************************************** - * Local prototypes, QNX specific - *****************************************************************************/ -#if defined( __QNXNTO__ ) -static void QNXInitCPT ( CAM_PASS_THRU *, int ); -#endif - -/***************************************************************************** - * Local prototypes, OS2 specific - *****************************************************************************/ -#if defined( SYS_OS2 ) -static void OS2InitSDC( struct OS2_ExecSCSICmd *, int ); -#endif - -/***************************************************************************** - * ioctl_ReadCopyright: check whether the disc is encrypted or not - *****************************************************************************/ -int ioctl_ReadCopyright( int i_fd, int i_layer, int *pi_copyright ) -{ - int i_ret; - -#if defined( HAVE_LINUX_DVD_STRUCT ) - dvd_struct dvd; - - memset( &dvd, 0, sizeof( dvd ) ); - dvd.type = DVD_STRUCT_COPYRIGHT; - dvd.copyright.layer_num = i_layer; - - i_ret = ioctl( i_fd, DVD_READ_STRUCT, &dvd ); - - *pi_copyright = dvd.copyright.cpst; - -#elif defined( HAVE_BSD_DVD_STRUCT ) - struct dvd_struct dvd; - - memset( &dvd, 0, sizeof( dvd ) ); - dvd.format = DVD_STRUCT_COPYRIGHT; - dvd.layer_num = i_layer; - - i_ret = ioctl( i_fd, DVDIOCREADSTRUCTURE, &dvd ); - - *pi_copyright = dvd.cpst; - -#elif defined( SYS_BEOS ) - INIT_RDC( GPCMD_READ_DVD_STRUCTURE, 8 ); - - rdc.command[ 6 ] = i_layer; - rdc.command[ 7 ] = DVD_STRUCT_COPYRIGHT; - - i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) ); - - *pi_copyright = p_buffer[ 4 ]; - -#elif defined( HPUX_SCTL_IO ) - INIT_SCTL_IO( GPCMD_READ_DVD_STRUCTURE, 8 ); - - sctl_io.cdb[ 6 ] = i_layer; - sctl_io.cdb[ 7 ] = DVD_STRUCT_COPYRIGHT; - - i_ret = ioctl( i_fd, SIOC_IO, &sctl_io ); - - *pi_copyright = p_buffer[ 4 ]; - -#elif defined( SOLARIS_USCSI ) - INIT_USCSI( GPCMD_READ_DVD_STRUCTURE, 8 ); - - rs_cdb.cdb_opaque[ 6 ] = i_layer; - rs_cdb.cdb_opaque[ 7 ] = DVD_STRUCT_COPYRIGHT; - - i_ret = SolarisSendUSCSI(i_fd, &sc); - - if( i_ret < 0 || sc.uscsi_status ) { - i_ret = -1; - } - - *pi_copyright = p_buffer[ 4 ]; - /* s->copyright.rmi = p_buffer[ 5 ]; */ - -#elif defined( DARWIN_DVD_IOCTL ) - INIT_DVDIOCTL( dk_dvd_read_structure_t, DVDCopyrightInfo, - kDVDStructureFormatCopyrightInfo ); - - dvd.layer = i_layer; - - i_ret = ioctl( i_fd, DKIOCDVDREADSTRUCTURE, &dvd ); - - *pi_copyright = dvdbs.copyrightProtectionSystemType; - -#elif defined( WIN32 ) - if( WIN2K ) /* NT/2k/XP */ - { - INIT_SPTD( GPCMD_READ_DVD_STRUCTURE, 8 ); - - /* When using IOCTL_DVD_READ_STRUCTURE and - DVD_COPYRIGHT_DESCRIPTOR, CopyrightProtectionType - seems to be always 6 ??? - To work around this MS bug we try to send a raw scsi command - instead (if we've got enough privileges to do so). */ - - sptd.Cdb[ 6 ] = i_layer; - sptd.Cdb[ 7 ] = DVD_STRUCT_COPYRIGHT; - - i_ret = SEND_SPTD( i_fd, &sptd, &tmp ); - - if( i_ret == 0 ) - { - *pi_copyright = p_buffer[ 4 ]; - } - } - else - { - INIT_SSC( GPCMD_READ_DVD_STRUCTURE, 8 ); - - ssc.CDBByte[ 6 ] = i_layer; - ssc.CDBByte[ 7 ] = DVD_STRUCT_COPYRIGHT; - - i_ret = WinSendSSC( i_fd, &ssc ); - - *pi_copyright = p_buffer[ 4 ]; - } - -#elif defined( __QNXNTO__ ) - - INIT_CPT( GPCMD_READ_DVD_STRUCTURE, 8 ); - - p_cpt->cam_cdb[ 6 ] = i_layer; - p_cpt->cam_cdb[ 7 ] = DVD_STRUCT_COPYRIGHT; - - i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL); - - *pi_copyright = p_buffer[4]; - -#elif defined( SYS_OS2 ) - INIT_SSC( GPCMD_READ_DVD_STRUCTURE, 8 ); - - sdc.command[ 6 ] = i_layer; - sdc.command[ 7 ] = DVD_STRUCT_COPYRIGHT; - - i_ret = DosDevIOCtl(i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD, - &sdc, sizeof(sdc), &ulParamLen, - p_buffer, sizeof(p_buffer), &ulDataLen); - - *pi_copyright = p_buffer[ 4 ]; - -#else -# error "DVD ioctls are unavailable on this system" - -#endif - return i_ret; -} - -/***************************************************************************** - * ioctl_ReadDiscKey: get the disc key - *****************************************************************************/ -int ioctl_ReadDiscKey( int i_fd, int *pi_agid, uint8_t *p_key ) -{ - int i_ret; - -#if defined( HAVE_LINUX_DVD_STRUCT ) - dvd_struct dvd; - - memset( &dvd, 0, sizeof( dvd ) ); - dvd.type = DVD_STRUCT_DISCKEY; - dvd.disckey.agid = *pi_agid; - memset( dvd.disckey.value, 0, DVD_DISCKEY_SIZE ); - - i_ret = ioctl( i_fd, DVD_READ_STRUCT, &dvd ); - - if( i_ret < 0 ) - { - return i_ret; - } - - memcpy( p_key, dvd.disckey.value, DVD_DISCKEY_SIZE ); - -#elif defined( HAVE_BSD_DVD_STRUCT ) - struct dvd_struct dvd; - - memset( &dvd, 0, sizeof( dvd ) ); - dvd.format = DVD_STRUCT_DISCKEY; - dvd.agid = *pi_agid; - memset( dvd.data, 0, DVD_DISCKEY_SIZE ); - - i_ret = ioctl( i_fd, DVDIOCREADSTRUCTURE, &dvd ); - - if( i_ret < 0 ) - { - return i_ret; - } - - memcpy( p_key, dvd.data, DVD_DISCKEY_SIZE ); - -#elif defined( SYS_BEOS ) - INIT_RDC( GPCMD_READ_DVD_STRUCTURE, DVD_DISCKEY_SIZE + 4 ); - - rdc.command[ 7 ] = DVD_STRUCT_DISCKEY; - rdc.command[ 10 ] = *pi_agid << 6; - - i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) ); - - if( i_ret < 0 ) - { - return i_ret; - } - - memcpy( p_key, p_buffer + 4, DVD_DISCKEY_SIZE ); - -#elif defined( HPUX_SCTL_IO ) - INIT_SCTL_IO( GPCMD_READ_DVD_STRUCTURE, DVD_DISCKEY_SIZE + 4 ); - - sctl_io.cdb[ 7 ] = DVD_STRUCT_DISCKEY; - sctl_io.cdb[ 10 ] = *pi_agid << 6; - - i_ret = ioctl( i_fd, SIOC_IO, &sctl_io ); - - if( i_ret < 0 ) - { - return i_ret; - } - - memcpy( p_key, p_buffer + 4, DVD_DISCKEY_SIZE ); - -#elif defined( SOLARIS_USCSI ) - INIT_USCSI( GPCMD_READ_DVD_STRUCTURE, DVD_DISCKEY_SIZE + 4 ); - - rs_cdb.cdb_opaque[ 7 ] = DVD_STRUCT_DISCKEY; - rs_cdb.cdb_opaque[ 10 ] = *pi_agid << 6; - - i_ret = SolarisSendUSCSI( i_fd, &sc ); - - if( i_ret < 0 || sc.uscsi_status ) - { - i_ret = -1; - return i_ret; - } - - memcpy( p_key, p_buffer + 4, DVD_DISCKEY_SIZE ); - -#elif defined( DARWIN_DVD_IOCTL ) - INIT_DVDIOCTL( dk_dvd_read_structure_t, DVDDiscKeyInfo, - kDVDStructureFormatDiscKeyInfo ); - - dvd.grantID = *pi_agid; - - i_ret = ioctl( i_fd, DKIOCDVDREADSTRUCTURE, &dvd ); - - memcpy( p_key, dvdbs.discKeyStructures, DVD_DISCKEY_SIZE ); - -#elif defined( WIN32 ) - if( WIN2K ) /* NT/2k/XP */ - { - DWORD tmp; - uint8_t buffer[DVD_DISK_KEY_LENGTH]; - PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer; - - memset( &buffer, 0, sizeof( buffer ) ); - - key->KeyLength = DVD_DISK_KEY_LENGTH; - key->SessionId = *pi_agid; - key->KeyType = DvdDiskKey; - key->KeyFlags = 0; - - i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key, - key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1; - - if( i_ret < 0 ) - { - return i_ret; - } - - memcpy( p_key, key->KeyData, DVD_DISCKEY_SIZE ); - } - else - { - INIT_SSC( GPCMD_READ_DVD_STRUCTURE, DVD_DISCKEY_SIZE + 4 ); - - ssc.CDBByte[ 7 ] = DVD_STRUCT_DISCKEY; - ssc.CDBByte[ 10 ] = *pi_agid << 6; - - i_ret = WinSendSSC( i_fd, &ssc ); - - if( i_ret < 0 ) - { - return i_ret; - } - - memcpy( p_key, p_buffer + 4, DVD_DISCKEY_SIZE ); - } - -#elif defined( __QNXNTO__ ) - - INIT_CPT( GPCMD_READ_DVD_STRUCTURE, DVD_DISCKEY_SIZE + 4 ); - - p_cpt->cam_cdb[ 7 ] = DVD_STRUCT_DISCKEY; - p_cpt->cam_cdb[ 10 ] = *pi_agid << 6; - - i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL); - - memcpy( p_key, p_buffer + 4, DVD_DISCKEY_SIZE ); - -#elif defined ( SYS_OS2 ) - INIT_SSC( GPCMD_READ_DVD_STRUCTURE, DVD_DISCKEY_SIZE + 4 ); - - sdc.command[ 7 ] = DVD_STRUCT_DISCKEY; - sdc.command[ 10 ] = *pi_agid << 6; - - i_ret = DosDevIOCtl(i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD, - &sdc, sizeof(sdc), &ulParamLen, - p_buffer, sizeof(p_buffer), &ulDataLen); - - if( i_ret < 0 ) - { - return i_ret; - } - - memcpy( p_key, p_buffer + 4, DVD_DISCKEY_SIZE ); - -#else -# error "DVD ioctls are unavailable on this system" - -#endif - return i_ret; -} - -/***************************************************************************** - * ioctl_ReadTitleKey: get the title key - *****************************************************************************/ -int ioctl_ReadTitleKey( int i_fd, int *pi_agid, int i_pos, uint8_t *p_key ) -{ - int i_ret; - -#if defined( HAVE_LINUX_DVD_STRUCT ) - dvd_authinfo auth_info; - - memset( &auth_info, 0, sizeof( auth_info ) ); - auth_info.type = DVD_LU_SEND_TITLE_KEY; - auth_info.lstk.agid = *pi_agid; - auth_info.lstk.lba = i_pos; - - i_ret = ioctl( i_fd, DVD_AUTH, &auth_info ); - - memcpy( p_key, auth_info.lstk.title_key, DVD_KEY_SIZE ); - -#elif defined( HAVE_BSD_DVD_STRUCT ) - struct dvd_authinfo auth_info; - - memset( &auth_info, 0, sizeof( auth_info ) ); - auth_info.format = DVD_REPORT_TITLE_KEY; - auth_info.agid = *pi_agid; - auth_info.lba = i_pos; - - i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info ); - - memcpy( p_key, auth_info.keychal, DVD_KEY_SIZE ); - -#elif defined( SYS_BEOS ) - INIT_RDC( GPCMD_REPORT_KEY, 12 ); - - rdc.command[ 2 ] = ( i_pos >> 24 ) & 0xff; - rdc.command[ 3 ] = ( i_pos >> 16 ) & 0xff; - rdc.command[ 4 ] = ( i_pos >> 8 ) & 0xff; - rdc.command[ 5 ] = ( i_pos ) & 0xff; - rdc.command[ 10 ] = DVD_REPORT_TITLE_KEY | (*pi_agid << 6); - - i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) ); - - memcpy( p_key, p_buffer + 5, DVD_KEY_SIZE ); - -#elif defined( HPUX_SCTL_IO ) - INIT_SCTL_IO( GPCMD_REPORT_KEY, 12 ); - - sctl_io.cdb[ 2 ] = ( i_pos >> 24 ) & 0xff; - sctl_io.cdb[ 3 ] = ( i_pos >> 16 ) & 0xff; - sctl_io.cdb[ 4 ] = ( i_pos >> 8 ) & 0xff; - sctl_io.cdb[ 5 ] = ( i_pos ) & 0xff; - sctl_io.cdb[ 10 ] = DVD_REPORT_TITLE_KEY | (*pi_agid << 6); - - i_ret = ioctl( i_fd, SIOC_IO, &sctl_io ); - - memcpy( p_key, p_buffer + 5, DVD_KEY_SIZE ); - -#elif defined( SOLARIS_USCSI ) - INIT_USCSI( GPCMD_REPORT_KEY, 12 ); - - rs_cdb.cdb_opaque[ 2 ] = ( i_pos >> 24 ) & 0xff; - rs_cdb.cdb_opaque[ 3 ] = ( i_pos >> 16 ) & 0xff; - rs_cdb.cdb_opaque[ 4 ] = ( i_pos >> 8 ) & 0xff; - rs_cdb.cdb_opaque[ 5 ] = ( i_pos ) & 0xff; - rs_cdb.cdb_opaque[ 10 ] = DVD_REPORT_TITLE_KEY | (*pi_agid << 6); - - i_ret = SolarisSendUSCSI( i_fd, &sc ); - - if( i_ret < 0 || sc.uscsi_status ) - { - i_ret = -1; - } - - /* Do we want to return the cp_sec flag perhaps? */ - /* a->lstk.cpm = (buf[ 4 ] >> 7) & 1; */ - /* a->lstk.cp_sec = (buf[ 4 ] >> 6) & 1; */ - /* a->lstk.cgms = (buf[ 4 ] >> 4) & 3; */ - - memcpy( p_key, p_buffer + 5, DVD_KEY_SIZE ); - -#elif defined( DARWIN_DVD_IOCTL ) - INIT_DVDIOCTL( dk_dvd_report_key_t, DVDTitleKeyInfo, - kDVDKeyFormatTitleKey ); - - dvd.address = i_pos; - dvd.grantID = *pi_agid; - dvd.keyClass = kDVDKeyClassCSS_CPPM_CPRM; - - i_ret = ioctl( i_fd, DKIOCDVDREPORTKEY, &dvd ); - - memcpy( p_key, dvdbs.titleKeyValue, DVD_KEY_SIZE ); - -#elif defined( WIN32 ) - if( WIN2K ) /* NT/2k/XP */ - { - DWORD tmp; - uint8_t buffer[DVD_TITLE_KEY_LENGTH]; - PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer; - - memset( &buffer, 0, sizeof( buffer ) ); - - key->KeyLength = DVD_TITLE_KEY_LENGTH; - key->SessionId = *pi_agid; - key->KeyType = DvdTitleKey; - key->KeyFlags = 0; - key->Parameters.TitleOffset.QuadPart = (LONGLONG) i_pos * - 2048 /*DVDCSS_BLOCK_SIZE*/; - - i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key, - key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1; - - memcpy( p_key, key->KeyData, DVD_KEY_SIZE ); - } - else - { - INIT_SSC( GPCMD_REPORT_KEY, 12 ); - - ssc.CDBByte[ 2 ] = ( i_pos >> 24 ) & 0xff; - ssc.CDBByte[ 3 ] = ( i_pos >> 16 ) & 0xff; - ssc.CDBByte[ 4 ] = ( i_pos >> 8 ) & 0xff; - ssc.CDBByte[ 5 ] = ( i_pos ) & 0xff; - ssc.CDBByte[ 10 ] = DVD_REPORT_TITLE_KEY | (*pi_agid << 6); - - i_ret = WinSendSSC( i_fd, &ssc ); - - memcpy( p_key, p_buffer + 5, DVD_KEY_SIZE ); - } - -#elif defined( __QNXNTO__ ) - - INIT_CPT( GPCMD_REPORT_KEY, 12 ); - - p_cpt->cam_cdb[ 2 ] = ( i_pos >> 24 ) & 0xff; - p_cpt->cam_cdb[ 3 ] = ( i_pos >> 16 ) & 0xff; - p_cpt->cam_cdb[ 4 ] = ( i_pos >> 8 ) & 0xff; - p_cpt->cam_cdb[ 5 ] = ( i_pos ) & 0xff; - p_cpt->cam_cdb[ 10 ] = DVD_REPORT_TITLE_KEY | (*pi_agid << 6); - - i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL); - - memcpy( p_key, p_buffer + 5, DVD_KEY_SIZE ); - -#elif defined( SYS_OS2 ) - INIT_SSC( GPCMD_REPORT_KEY, 12 ); - - sdc.command[ 2 ] = ( i_pos >> 24 ) & 0xff; - sdc.command[ 3 ] = ( i_pos >> 16 ) & 0xff; - sdc.command[ 4 ] = ( i_pos >> 8 ) & 0xff; - sdc.command[ 5 ] = ( i_pos ) & 0xff; - sdc.command[ 10 ] = DVD_REPORT_TITLE_KEY | (*pi_agid << 6); - - i_ret = DosDevIOCtl(i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD, - &sdc, sizeof(sdc), &ulParamLen, - p_buffer, sizeof(p_buffer), &ulDataLen); - - memcpy( p_key, p_buffer + 5, DVD_KEY_SIZE ); - -#else -# error "DVD ioctls are unavailable on this system" - -#endif - - return i_ret; -} - - -/***************************************************************************** - * ioctl_ReportAgid: get AGID from the drive - *****************************************************************************/ -int ioctl_ReportAgid( int i_fd, int *pi_agid ) -{ - int i_ret; - -#if defined( HAVE_LINUX_DVD_STRUCT ) - dvd_authinfo auth_info; - - memset( &auth_info, 0, sizeof( auth_info ) ); - auth_info.type = DVD_LU_SEND_AGID; - auth_info.lsa.agid = *pi_agid; - - i_ret = ioctl( i_fd, DVD_AUTH, &auth_info ); - - *pi_agid = auth_info.lsa.agid; - -#elif defined( HAVE_BSD_DVD_STRUCT ) - struct dvd_authinfo auth_info; - - memset( &auth_info, 0, sizeof( auth_info ) ); - auth_info.format = DVD_REPORT_AGID; - auth_info.agid = *pi_agid; - - i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info ); - - *pi_agid = auth_info.agid; - -#elif defined( SYS_BEOS ) - INIT_RDC( GPCMD_REPORT_KEY, 8 ); - - rdc.command[ 10 ] = DVD_REPORT_AGID | (*pi_agid << 6); - - i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) ); - - *pi_agid = p_buffer[ 7 ] >> 6; - -#elif defined( HPUX_SCTL_IO ) - INIT_SCTL_IO( GPCMD_REPORT_KEY, 8 ); - - sctl_io.cdb[ 10 ] = DVD_REPORT_AGID | (*pi_agid << 6); - - i_ret = ioctl( i_fd, SIOC_IO, &sctl_io ); - - *pi_agid = p_buffer[ 7 ] >> 6; - -#elif defined( SOLARIS_USCSI ) - INIT_USCSI( GPCMD_REPORT_KEY, 8 ); - - rs_cdb.cdb_opaque[ 10 ] = DVD_REPORT_AGID | (*pi_agid << 6); - - i_ret = SolarisSendUSCSI( i_fd, &sc ); - - if( i_ret < 0 || sc.uscsi_status ) - { - i_ret = -1; - } - - *pi_agid = p_buffer[ 7 ] >> 6; - -#elif defined( DARWIN_DVD_IOCTL ) - INIT_DVDIOCTL( dk_dvd_report_key_t, DVDAuthenticationGrantIDInfo, - kDVDKeyFormatAGID_CSS ); - - dvd.grantID = *pi_agid; - dvd.keyClass = kDVDKeyClassCSS_CPPM_CPRM; - - i_ret = ioctl( i_fd, DKIOCDVDREPORTKEY, &dvd ); - - *pi_agid = dvdbs.grantID; - -#elif defined( WIN32 ) - if( WIN2K ) /* NT/2k/XP */ - { - ULONG id; - DWORD tmp; - - i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_START_SESSION, - &tmp, 4, &id, sizeof( id ), &tmp, NULL ) ? 0 : -1; - - *pi_agid = id; - } - else - { - INIT_SSC( GPCMD_REPORT_KEY, 8 ); - - ssc.CDBByte[ 10 ] = DVD_REPORT_AGID | (*pi_agid << 6); - - i_ret = WinSendSSC( i_fd, &ssc ); - - *pi_agid = p_buffer[ 7 ] >> 6; - } - -#elif defined( __QNXNTO__ ) - - INIT_CPT( GPCMD_REPORT_KEY, 8 ); - - p_cpt->cam_cdb[ 10 ] = DVD_REPORT_AGID | (*pi_agid << 6); - - i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL); - - *pi_agid = p_buffer[ 7 ] >> 6; - -#elif defined( SYS_OS2 ) - INIT_SSC( GPCMD_REPORT_KEY, 8 ); - - sdc.command[ 10 ] = DVD_REPORT_AGID | (*pi_agid << 6); - - i_ret = DosDevIOCtl(i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD, - &sdc, sizeof(sdc), &ulParamLen, - p_buffer, sizeof(p_buffer), &ulDataLen); - - *pi_agid = p_buffer[ 7 ] >> 6; - -#else -# error "DVD ioctls are unavailable on this system" - -#endif - return i_ret; -} - -/***************************************************************************** - * ioctl_ReportChallenge: get challenge from the drive - *****************************************************************************/ -int ioctl_ReportChallenge( int i_fd, int *pi_agid, uint8_t *p_challenge ) -{ - int i_ret; - -#if defined( HAVE_LINUX_DVD_STRUCT ) - dvd_authinfo auth_info; - - memset( &auth_info, 0, sizeof( auth_info ) ); - auth_info.type = DVD_LU_SEND_CHALLENGE; - auth_info.lsc.agid = *pi_agid; - - i_ret = ioctl( i_fd, DVD_AUTH, &auth_info ); - - memcpy( p_challenge, auth_info.lsc.chal, DVD_CHALLENGE_SIZE ); - -#elif defined( HAVE_BSD_DVD_STRUCT ) - struct dvd_authinfo auth_info; - - memset( &auth_info, 0, sizeof( auth_info ) ); - auth_info.format = DVD_REPORT_CHALLENGE; - auth_info.agid = *pi_agid; - - i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info ); - - memcpy( p_challenge, auth_info.keychal, DVD_CHALLENGE_SIZE ); - -#elif defined( SYS_BEOS ) - INIT_RDC( GPCMD_REPORT_KEY, 16 ); - - rdc.command[ 10 ] = DVD_REPORT_CHALLENGE | (*pi_agid << 6); - - i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) ); - - memcpy( p_challenge, p_buffer + 4, DVD_CHALLENGE_SIZE ); - -#elif defined( HPUX_SCTL_IO ) - INIT_SCTL_IO( GPCMD_REPORT_KEY, 16 ); - - sctl_io.cdb[ 10 ] = DVD_REPORT_CHALLENGE | (*pi_agid << 6); - - i_ret = ioctl( i_fd, SIOC_IO, &sctl_io ); - - memcpy( p_challenge, p_buffer + 4, DVD_CHALLENGE_SIZE ); - -#elif defined( SOLARIS_USCSI ) - INIT_USCSI( GPCMD_REPORT_KEY, 16 ); - - rs_cdb.cdb_opaque[ 10 ] = DVD_REPORT_CHALLENGE | (*pi_agid << 6); - - i_ret = SolarisSendUSCSI( i_fd, &sc ); - - if( i_ret < 0 || sc.uscsi_status ) - { - i_ret = -1; - } - - memcpy( p_challenge, p_buffer + 4, DVD_CHALLENGE_SIZE ); - -#elif defined( DARWIN_DVD_IOCTL ) - INIT_DVDIOCTL( dk_dvd_report_key_t, DVDChallengeKeyInfo, - kDVDKeyFormatChallengeKey ); - - dvd.grantID = *pi_agid; - - i_ret = ioctl( i_fd, DKIOCDVDREPORTKEY, &dvd ); - - memcpy( p_challenge, dvdbs.challengeKeyValue, DVD_CHALLENGE_SIZE ); - -#elif defined( WIN32 ) - if( WIN2K ) /* NT/2k/XP */ - { - DWORD tmp; - uint8_t buffer[DVD_CHALLENGE_KEY_LENGTH]; - PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer; - - memset( &buffer, 0, sizeof( buffer ) ); - - key->KeyLength = DVD_CHALLENGE_KEY_LENGTH; - key->SessionId = *pi_agid; - key->KeyType = DvdChallengeKey; - key->KeyFlags = 0; - - i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key, - key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1; - - if( i_ret < 0 ) - { - return i_ret; - } - - memcpy( p_challenge, key->KeyData, DVD_CHALLENGE_SIZE ); - } - else - { - INIT_SSC( GPCMD_REPORT_KEY, 16 ); - - ssc.CDBByte[ 10 ] = DVD_REPORT_CHALLENGE | (*pi_agid << 6); - - i_ret = WinSendSSC( i_fd, &ssc ); - - memcpy( p_challenge, p_buffer + 4, DVD_CHALLENGE_SIZE ); - } - -#elif defined( __QNXNTO__ ) - - INIT_CPT( GPCMD_REPORT_KEY, 16 ); - - p_cpt->cam_cdb[ 10 ] = DVD_REPORT_CHALLENGE | (*pi_agid << 6); - - i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL); - - memcpy( p_challenge, p_buffer + 4, DVD_CHALLENGE_SIZE ); - -#elif defined( SYS_OS2 ) - INIT_SSC( GPCMD_REPORT_KEY, 16 ); - - sdc.command[ 10 ] = DVD_REPORT_CHALLENGE | (*pi_agid << 6); - - i_ret = DosDevIOCtl(i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD, - &sdc, sizeof(sdc), &ulParamLen, - p_buffer, sizeof(p_buffer), &ulDataLen); - - memcpy( p_challenge, p_buffer + 4, DVD_CHALLENGE_SIZE ); - -#else -# error "DVD ioctls are unavailable on this system" - -#endif - return i_ret; -} - -/***************************************************************************** - * ioctl_ReportASF: get ASF from the drive - *****************************************************************************/ -int ioctl_ReportASF( int i_fd, int *pi_remove_me, int *pi_asf ) -{ - int i_ret; - -#if defined( HAVE_LINUX_DVD_STRUCT ) - dvd_authinfo auth_info; - - memset( &auth_info, 0, sizeof( auth_info ) ); - auth_info.type = DVD_LU_SEND_ASF; - auth_info.lsasf.asf = *pi_asf; - - i_ret = ioctl( i_fd, DVD_AUTH, &auth_info ); - - *pi_asf = auth_info.lsasf.asf; - -#elif defined( HAVE_BSD_DVD_STRUCT ) - struct dvd_authinfo auth_info; - - memset( &auth_info, 0, sizeof( auth_info ) ); - auth_info.format = DVD_REPORT_ASF; - auth_info.asf = *pi_asf; - - i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info ); - - *pi_asf = auth_info.asf; - -#elif defined( SYS_BEOS ) - INIT_RDC( GPCMD_REPORT_KEY, 8 ); - - rdc.command[ 10 ] = DVD_REPORT_ASF; - - i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) ); - - *pi_asf = p_buffer[ 7 ] & 1; - -#elif defined( HPUX_SCTL_IO ) - INIT_SCTL_IO( GPCMD_REPORT_KEY, 8 ); - - sctl_io.cdb[ 10 ] = DVD_REPORT_ASF; - - i_ret = ioctl( i_fd, SIOC_IO, &sctl_io ); - - *pi_asf = p_buffer[ 7 ] & 1; - -#elif defined( SOLARIS_USCSI ) - INIT_USCSI( GPCMD_REPORT_KEY, 8 ); - - rs_cdb.cdb_opaque[ 10 ] = DVD_REPORT_ASF; - - i_ret = SolarisSendUSCSI( i_fd, &sc ); - - if( i_ret < 0 || sc.uscsi_status ) - { - i_ret = -1; - } - - *pi_asf = p_buffer[ 7 ] & 1; - -#elif defined( DARWIN_DVD_IOCTL ) - INIT_DVDIOCTL( dk_dvd_report_key_t, DVDAuthenticationSuccessFlagInfo, - kDVDKeyFormatASF ); - - i_ret = ioctl( i_fd, DKIOCDVDREPORTKEY, &dvd ); - - *pi_asf = dvdbs.successFlag; - -#elif defined( WIN32 ) - if( WIN2K ) /* NT/2k/XP */ - { - DWORD tmp; - uint8_t buffer[DVD_ASF_LENGTH]; - PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer; - - memset( &buffer, 0, sizeof( buffer ) ); - - key->KeyLength = DVD_ASF_LENGTH; - key->KeyType = DvdAsf; - key->KeyFlags = 0; - - ((PDVD_ASF)key->KeyData)->SuccessFlag = *pi_asf; - - i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key, - key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1; - - if( i_ret < 0 ) - { - return i_ret; - } - - *pi_asf = ((PDVD_ASF)key->KeyData)->SuccessFlag; - } - else - { - INIT_SSC( GPCMD_REPORT_KEY, 8 ); - - ssc.CDBByte[ 10 ] = DVD_REPORT_ASF; - - i_ret = WinSendSSC( i_fd, &ssc ); - - *pi_asf = p_buffer[ 7 ] & 1; - } - -#elif defined( __QNXNTO__ ) - - INIT_CPT( GPCMD_REPORT_KEY, 8 ); - - p_cpt->cam_cdb[ 10 ] = DVD_REPORT_ASF; - - i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL); - - *pi_asf = p_buffer[ 7 ] & 1; - -#elif defined( SYS_OS2 ) - INIT_SSC( GPCMD_REPORT_KEY, 8 ); - - sdc.command[ 10 ] = DVD_REPORT_ASF; - - i_ret = DosDevIOCtl(i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD, - &sdc, sizeof(sdc), &ulParamLen, - p_buffer, sizeof(p_buffer), &ulDataLen); - - *pi_asf = p_buffer[ 7 ] & 1; - -#else -# error "DVD ioctls are unavailable on this system" - -#endif - return i_ret; -} - -/***************************************************************************** - * ioctl_ReportKey1: get the first key from the drive - *****************************************************************************/ -int ioctl_ReportKey1( int i_fd, int *pi_agid, uint8_t *p_key ) -{ - int i_ret; - -#if defined( HAVE_LINUX_DVD_STRUCT ) - dvd_authinfo auth_info; - - memset( &auth_info, 0, sizeof( auth_info ) ); - auth_info.type = DVD_LU_SEND_KEY1; - auth_info.lsk.agid = *pi_agid; - - i_ret = ioctl( i_fd, DVD_AUTH, &auth_info ); - - memcpy( p_key, auth_info.lsk.key, DVD_KEY_SIZE ); - -#elif defined( HAVE_BSD_DVD_STRUCT ) - struct dvd_authinfo auth_info; - - memset( &auth_info, 0, sizeof( auth_info ) ); - auth_info.format = DVD_REPORT_KEY1; - auth_info.agid = *pi_agid; - - i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info ); - - memcpy( p_key, auth_info.keychal, DVD_KEY_SIZE ); - -#elif defined( SYS_BEOS ) - INIT_RDC( GPCMD_REPORT_KEY, 12 ); - - rdc.command[ 10 ] = DVD_REPORT_KEY1 | (*pi_agid << 6); - - i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) ); - - memcpy( p_key, p_buffer + 4, DVD_KEY_SIZE ); - -#elif defined( HPUX_SCTL_IO ) - INIT_SCTL_IO( GPCMD_REPORT_KEY, 12 ); - - sctl_io.cdb[ 10 ] = DVD_REPORT_KEY1 | (*pi_agid << 6); - - i_ret = ioctl( i_fd, SIOC_IO, &sctl_io ); - - memcpy( p_key, p_buffer + 4, DVD_KEY_SIZE ); - -#elif defined( SOLARIS_USCSI ) - INIT_USCSI( GPCMD_REPORT_KEY, 12 ); - - rs_cdb.cdb_opaque[ 10 ] = DVD_REPORT_KEY1 | (*pi_agid << 6); - - i_ret = SolarisSendUSCSI( i_fd, &sc ); - - if( i_ret < 0 || sc.uscsi_status ) - { - i_ret = -1; - } - - memcpy( p_key, p_buffer + 4, DVD_KEY_SIZE ); - -#elif defined( DARWIN_DVD_IOCTL ) - INIT_DVDIOCTL( dk_dvd_report_key_t, DVDKey1Info, - kDVDKeyFormatKey1 ); - - dvd.grantID = *pi_agid; - - i_ret = ioctl( i_fd, DKIOCDVDREPORTKEY, &dvd ); - - memcpy( p_key, dvdbs.key1Value, DVD_KEY_SIZE ); - -#elif defined( WIN32 ) - if( WIN2K ) /* NT/2k/XP */ - { - DWORD tmp; - uint8_t buffer[DVD_BUS_KEY_LENGTH]; - PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer; - - memset( &buffer, 0, sizeof( buffer ) ); - - key->KeyLength = DVD_BUS_KEY_LENGTH; - key->SessionId = *pi_agid; - key->KeyType = DvdBusKey1; - key->KeyFlags = 0; - - i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key, - key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1; - - memcpy( p_key, key->KeyData, DVD_KEY_SIZE ); - } - else - { - INIT_SSC( GPCMD_REPORT_KEY, 12 ); - - ssc.CDBByte[ 10 ] = DVD_REPORT_KEY1 | (*pi_agid << 6); - - i_ret = WinSendSSC( i_fd, &ssc ); - - memcpy( p_key, p_buffer + 4, DVD_KEY_SIZE ); - } - -#elif defined( __QNXNTO__ ) - - INIT_CPT( GPCMD_REPORT_KEY, 12 ); - - p_cpt->cam_cdb[ 10 ] = DVD_REPORT_KEY1 | (*pi_agid << 6); - - i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL); - - memcpy( p_key, p_buffer + 4, DVD_KEY_SIZE ); - -#elif defined( SYS_OS2 ) - INIT_SSC( GPCMD_REPORT_KEY, 12 ); - - sdc.command[ 10 ] = DVD_REPORT_KEY1 | (*pi_agid << 6); - - i_ret = DosDevIOCtl(i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD, - &sdc, sizeof(sdc), &ulParamLen, - p_buffer, sizeof(p_buffer), &ulDataLen); - - memcpy( p_key, p_buffer + 4, DVD_KEY_SIZE ); - -#else -# error "DVD ioctls are unavailable on this system" - -#endif - return i_ret; -} - -/***************************************************************************** - * ioctl_InvalidateAgid: invalidate the current AGID - *****************************************************************************/ -int ioctl_InvalidateAgid( int i_fd, int *pi_agid ) -{ - int i_ret; - -#if defined( HAVE_LINUX_DVD_STRUCT ) - dvd_authinfo auth_info; - - memset( &auth_info, 0, sizeof( auth_info ) ); - auth_info.type = DVD_INVALIDATE_AGID; - auth_info.lsa.agid = *pi_agid; - - i_ret = ioctl( i_fd, DVD_AUTH, &auth_info ); - -#elif defined( HAVE_BSD_DVD_STRUCT ) - struct dvd_authinfo auth_info; - - memset( &auth_info, 0, sizeof( auth_info ) ); - auth_info.format = DVD_INVALIDATE_AGID; - auth_info.agid = *pi_agid; - - i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info ); - -#elif defined( SYS_BEOS ) - INIT_RDC( GPCMD_REPORT_KEY, 0 ); - - rdc.command[ 10 ] = DVD_INVALIDATE_AGID | (*pi_agid << 6); - - i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) ); - -#elif defined( HPUX_SCTL_IO ) - INIT_SCTL_IO( GPCMD_REPORT_KEY, 0 ); - - sctl_io.cdb[ 10 ] = DVD_INVALIDATE_AGID | (*pi_agid << 6); - - i_ret = ioctl( i_fd, SIOC_IO, &sctl_io ); - -#elif defined( SOLARIS_USCSI ) - INIT_USCSI( GPCMD_REPORT_KEY, 0 ); - - rs_cdb.cdb_opaque[ 10 ] = DVD_INVALIDATE_AGID | (*pi_agid << 6); - - i_ret = SolarisSendUSCSI( i_fd, &sc ); - - if( i_ret < 0 || sc.uscsi_status ) - { - i_ret = -1; - } - -#elif defined( DARWIN_DVD_IOCTL ) - INIT_DVDIOCTL( dk_dvd_send_key_t, DVDAuthenticationGrantIDInfo, - kDVDKeyFormatAGID_Invalidate ); - - dvd.grantID = *pi_agid; - - i_ret = ioctl( i_fd, DKIOCDVDSENDKEY, &dvd ); - -#elif defined( WIN32 ) - if( WIN2K ) /* NT/2k/XP */ - { - DWORD tmp; - - i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_END_SESSION, - pi_agid, sizeof( *pi_agid ), NULL, 0, &tmp, NULL ) ? 0 : -1; - } - else - { -#if defined( __MINGW32__ ) - INIT_SSC( GPCMD_REPORT_KEY, 0 ); -#else - INIT_SSC( GPCMD_REPORT_KEY, 1 ); - - ssc.SRB_BufLen = 0; - ssc.CDBByte[ 8 ] = 0; - ssc.CDBByte[ 9 ] = 0; -#endif - - ssc.CDBByte[ 10 ] = DVD_INVALIDATE_AGID | (*pi_agid << 6); - - i_ret = WinSendSSC( i_fd, &ssc ); - } - -#elif defined( __QNXNTO__ ) - - INIT_CPT( GPCMD_REPORT_KEY, 0 ); - - p_cpt->cam_cdb[ 10 ] = DVD_INVALIDATE_AGID | (*pi_agid << 6); - - i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL); - -#elif defined( SYS_OS2 ) - INIT_SSC( GPCMD_REPORT_KEY, 1 ); - - sdc.data_length = 0; - sdc.command[ 8 ] = 0; - sdc.command[ 9 ] = 0; - - sdc.command[ 10 ] = DVD_INVALIDATE_AGID | (*pi_agid << 6); - - i_ret = DosDevIOCtl(i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD, - &sdc, sizeof(sdc), &ulParamLen, - NULL, 0, &ulDataLen); -#else -# error "DVD ioctls are unavailable on this system" - -#endif - return i_ret; -} - -/***************************************************************************** - * ioctl_SendChallenge: send challenge to the drive - *****************************************************************************/ -int ioctl_SendChallenge( int i_fd, int *pi_agid, uint8_t *p_challenge ) -{ - int i_ret; - -#if defined( HAVE_LINUX_DVD_STRUCT ) - dvd_authinfo auth_info; - - memset( &auth_info, 0, sizeof( auth_info ) ); - auth_info.type = DVD_HOST_SEND_CHALLENGE; - auth_info.hsc.agid = *pi_agid; - - memcpy( auth_info.hsc.chal, p_challenge, DVD_CHALLENGE_SIZE ); - - i_ret = ioctl( i_fd, DVD_AUTH, &auth_info ); - -#elif defined( HAVE_BSD_DVD_STRUCT ) - struct dvd_authinfo auth_info; - - memset( &auth_info, 0, sizeof( auth_info ) ); - auth_info.format = DVD_SEND_CHALLENGE; - auth_info.agid = *pi_agid; - - memcpy( auth_info.keychal, p_challenge, DVD_CHALLENGE_SIZE ); - - i_ret = ioctl( i_fd, DVDIOCSENDKEY, &auth_info ); - -#elif defined( SYS_BEOS ) - INIT_RDC( GPCMD_SEND_KEY, 16 ); - - rdc.command[ 10 ] = DVD_SEND_CHALLENGE | (*pi_agid << 6); - - p_buffer[ 1 ] = 0xe; - memcpy( p_buffer + 4, p_challenge, DVD_CHALLENGE_SIZE ); - - i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) ); - -#elif defined( HPUX_SCTL_IO ) - INIT_SCTL_IO( GPCMD_SEND_KEY, 16 ); - - sctl_io.cdb[ 10 ] = DVD_SEND_CHALLENGE | (*pi_agid << 6); - - p_buffer[ 1 ] = 0xe; - memcpy( p_buffer + 4, p_challenge, DVD_CHALLENGE_SIZE ); - - i_ret = ioctl( i_fd, SIOC_IO, &sctl_io ); - -#elif defined( SOLARIS_USCSI ) - INIT_USCSI( GPCMD_SEND_KEY, 16 ); - - rs_cdb.cdb_opaque[ 10 ] = DVD_SEND_CHALLENGE | (*pi_agid << 6); - - p_buffer[ 1 ] = 0xe; - memcpy( p_buffer + 4, p_challenge, DVD_CHALLENGE_SIZE ); - - if( SolarisSendUSCSI( i_fd, &sc ) < 0 || sc.uscsi_status ) - { - return -1; - } - - i_ret = 0; - -#elif defined( DARWIN_DVD_IOCTL ) - INIT_DVDIOCTL( dk_dvd_send_key_t, DVDChallengeKeyInfo, - kDVDKeyFormatChallengeKey ); - - dvd.grantID = *pi_agid; - dvd.keyClass = kDVDKeyClassCSS_CPPM_CPRM; - - dvdbs.dataLength[ 1 ] = 0xe; - memcpy( dvdbs.challengeKeyValue, p_challenge, DVD_CHALLENGE_SIZE ); - - i_ret = ioctl( i_fd, DKIOCDVDSENDKEY, &dvd ); - -#elif defined( WIN32 ) - if( WIN2K ) /* NT/2k/XP */ - { - DWORD tmp; - uint8_t buffer[DVD_CHALLENGE_KEY_LENGTH]; - PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer; - - memset( &buffer, 0, sizeof( buffer ) ); - - key->KeyLength = DVD_CHALLENGE_KEY_LENGTH; - key->SessionId = *pi_agid; - key->KeyType = DvdChallengeKey; - key->KeyFlags = 0; - - memcpy( key->KeyData, p_challenge, DVD_CHALLENGE_SIZE ); - - i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_SEND_KEY, key, - key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1; - } - else - { - INIT_SSC( GPCMD_SEND_KEY, 16 ); - - ssc.CDBByte[ 10 ] = DVD_SEND_CHALLENGE | (*pi_agid << 6); - - p_buffer[ 1 ] = 0xe; - memcpy( p_buffer + 4, p_challenge, DVD_CHALLENGE_SIZE ); - - i_ret = WinSendSSC( i_fd, &ssc ); - } - -#elif defined( __QNXNTO__ ) - - INIT_CPT( GPCMD_SEND_KEY, 16 ); - - p_cpt->cam_cdb[ 10 ] = DVD_SEND_CHALLENGE | (*pi_agid << 6); - - p_buffer[ 1 ] = 0xe; - memcpy( p_buffer + 4, p_challenge, DVD_CHALLENGE_SIZE ); - - i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL); - -#elif defined( SYS_OS2 ) - INIT_SSC( GPCMD_SEND_KEY, 16 ); - - sdc.command[ 10 ] = DVD_SEND_CHALLENGE | (*pi_agid << 6); - - p_buffer[ 1 ] = 0xe; - memcpy( p_buffer + 4, p_challenge, DVD_CHALLENGE_SIZE ); - - i_ret = DosDevIOCtl( i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD, - &sdc, sizeof(sdc), &ulParamLen, - p_buffer, sizeof(p_buffer), &ulDataLen ); - -#else -# error "DVD ioctls are unavailable on this system" - -#endif - return i_ret; -} - -/***************************************************************************** - * ioctl_SendKey2: send the second key to the drive - *****************************************************************************/ -int ioctl_SendKey2( int i_fd, int *pi_agid, uint8_t *p_key ) -{ - int i_ret; - -#if defined( HAVE_LINUX_DVD_STRUCT ) - dvd_authinfo auth_info; - - memset( &auth_info, 0, sizeof( auth_info ) ); - auth_info.type = DVD_HOST_SEND_KEY2; - auth_info.hsk.agid = *pi_agid; - - memcpy( auth_info.hsk.key, p_key, DVD_KEY_SIZE ); - - i_ret = ioctl( i_fd, DVD_AUTH, &auth_info ); - -#elif defined( HAVE_BSD_DVD_STRUCT ) - struct dvd_authinfo auth_info; - - memset( &auth_info, 0, sizeof( auth_info ) ); - auth_info.format = DVD_SEND_KEY2; - auth_info.agid = *pi_agid; - - memcpy( auth_info.keychal, p_key, DVD_KEY_SIZE ); - - i_ret = ioctl( i_fd, DVDIOCSENDKEY, &auth_info ); - -#elif defined( SYS_BEOS ) - INIT_RDC( GPCMD_SEND_KEY, 12 ); - - rdc.command[ 10 ] = DVD_SEND_KEY2 | (*pi_agid << 6); - - p_buffer[ 1 ] = 0xa; - memcpy( p_buffer + 4, p_key, DVD_KEY_SIZE ); - - i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) ); - -#elif defined( HPUX_SCTL_IO ) - INIT_SCTL_IO( GPCMD_SEND_KEY, 12 ); - - sctl_io.cdb[ 10 ] = DVD_SEND_KEY2 | (*pi_agid << 6); - - p_buffer[ 1 ] = 0xa; - memcpy( p_buffer + 4, p_key, DVD_KEY_SIZE ); - - i_ret = ioctl( i_fd, SIOC_IO, &sctl_io ); - -#elif defined( SOLARIS_USCSI ) - INIT_USCSI( GPCMD_SEND_KEY, 12 ); - - rs_cdb.cdb_opaque[ 10 ] = DVD_SEND_KEY2 | (*pi_agid << 6); - - p_buffer[ 1 ] = 0xa; - memcpy( p_buffer + 4, p_key, DVD_KEY_SIZE ); - - if( SolarisSendUSCSI( i_fd, &sc ) < 0 || sc.uscsi_status ) - { - return -1; - } - - i_ret = 0; - -#elif defined( DARWIN_DVD_IOCTL ) - INIT_DVDIOCTL( dk_dvd_send_key_t, DVDKey2Info, - kDVDKeyFormatKey2 ); - - dvd.grantID = *pi_agid; - dvd.keyClass = kDVDKeyClassCSS_CPPM_CPRM; - - dvdbs.dataLength[ 1 ] = 0xa; - memcpy( dvdbs.key2Value, p_key, DVD_KEY_SIZE ); - - i_ret = ioctl( i_fd, DKIOCDVDSENDKEY, &dvd ); - -#elif defined( WIN32 ) - if( WIN2K ) /* NT/2k/XP */ - { - DWORD tmp; - uint8_t buffer[DVD_BUS_KEY_LENGTH]; - PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer; - - memset( &buffer, 0, sizeof( buffer ) ); - - key->KeyLength = DVD_BUS_KEY_LENGTH; - key->SessionId = *pi_agid; - key->KeyType = DvdBusKey2; - key->KeyFlags = 0; - - memcpy( key->KeyData, p_key, DVD_KEY_SIZE ); - - i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_SEND_KEY, key, - key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1; - } - else - { - INIT_SSC( GPCMD_SEND_KEY, 12 ); - - ssc.CDBByte[ 10 ] = DVD_SEND_KEY2 | (*pi_agid << 6); - - p_buffer[ 1 ] = 0xa; - memcpy( p_buffer + 4, p_key, DVD_KEY_SIZE ); - - i_ret = WinSendSSC( i_fd, &ssc ); - } - -#elif defined( __QNXNTO__ ) - - INIT_CPT( GPCMD_SEND_KEY, 12 ); - - p_cpt->cam_cdb[ 10 ] = DVD_SEND_KEY2 | (*pi_agid << 6); - - p_buffer[ 1 ] = 0xa; - memcpy( p_buffer + 4, p_key, DVD_KEY_SIZE ); - - i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL); - -#elif defined( SYS_OS2 ) - INIT_SSC( GPCMD_SEND_KEY, 12 ); - - sdc.command[ 10 ] = DVD_SEND_KEY2 | (*pi_agid << 6); - - p_buffer[ 1 ] = 0xa; - memcpy( p_buffer + 4, p_key, DVD_KEY_SIZE ); - - i_ret = DosDevIOCtl( i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD, - &sdc, sizeof(sdc), &ulParamLen, - p_buffer, sizeof(p_buffer), &ulDataLen ); - -#else -# error "DVD ioctls are unavailable on this system" - -#endif - return i_ret; -} - -/***************************************************************************** - * ioctl_ReportRPC: get RPC status for the drive - *****************************************************************************/ -int ioctl_ReportRPC( int i_fd, int *p_type, int *p_mask, int *p_scheme ) -{ - int i_ret; - -#if defined( HAVE_LINUX_DVD_STRUCT ) && defined( DVD_LU_SEND_RPC_STATE ) - dvd_authinfo auth_info; - - memset( &auth_info, 0, sizeof( auth_info ) ); - auth_info.type = DVD_LU_SEND_RPC_STATE; - - i_ret = ioctl( i_fd, DVD_AUTH, &auth_info ); - - *p_type = auth_info.lrpcs.type; - *p_mask = auth_info.lrpcs.region_mask; - *p_scheme = auth_info.lrpcs.rpc_scheme; - -#elif defined( HAVE_LINUX_DVD_STRUCT ) - /* FIXME: OpenBSD doesn't know this */ - i_ret = -1; - -#elif defined( HAVE_BSD_DVD_STRUCT ) - struct dvd_authinfo auth_info; - - memset( &auth_info, 0, sizeof( auth_info ) ); - auth_info.format = DVD_REPORT_RPC; - - i_ret = ioctl( i_fd, DVDIOCREPORTKEY, &auth_info ); - - *p_type = auth_info.reg_type; - *p_mask = auth_info.region; // ?? - *p_scheme = auth_info.rpc_scheme; - -#elif defined( SYS_BEOS ) - INIT_RDC( GPCMD_REPORT_KEY, 8 ); - - rdc.command[ 10 ] = DVD_REPORT_RPC; - - i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) ); - - *p_type = p_buffer[ 4 ] >> 6; - *p_mask = p_buffer[ 5 ]; - *p_scheme = p_buffer[ 6 ]; - -#elif defined( HPUX_SCTL_IO ) - INIT_SCTL_IO( GPCMD_REPORT_KEY, 8 ); - - sctl_io.cdb[ 10 ] = DVD_REPORT_RPC; - - i_ret = ioctl( i_fd, SIOC_IO, &sctl_io ); - - *p_type = p_buffer[ 4 ] >> 6; - *p_mask = p_buffer[ 5 ]; - *p_scheme = p_buffer[ 6 ]; - -#elif defined( SOLARIS_USCSI ) - INIT_USCSI( GPCMD_REPORT_KEY, 8 ); - - rs_cdb.cdb_opaque[ 10 ] = DVD_REPORT_RPC; - - i_ret = SolarisSendUSCSI( i_fd, &sc ); - - if( i_ret < 0 || sc.uscsi_status ) - { - i_ret = -1; - } - - *p_type = p_buffer[ 4 ] >> 6; - *p_mask = p_buffer[ 5 ]; - *p_scheme = p_buffer[ 6 ]; - -#elif defined( DARWIN_DVD_IOCTL ) - INIT_DVDIOCTL( dk_dvd_report_key_t, DVDRegionPlaybackControlInfo, - kDVDKeyFormatRegionState ); - - dvd.keyClass = kDVDKeyClassCSS_CPPM_CPRM; - - i_ret = ioctl( i_fd, DKIOCDVDREPORTKEY, &dvd ); - - *p_type = dvdbs.typeCode; - *p_mask = dvdbs.driveRegion; - *p_scheme = dvdbs.rpcScheme; - -#elif defined( WIN32 ) - if( WIN2K ) /* NT/2k/XP */ - { - DWORD tmp; - uint8_t buffer[DVD_RPC_KEY_LENGTH]; - PDVD_COPY_PROTECT_KEY key = (PDVD_COPY_PROTECT_KEY) &buffer; - - memset( &buffer, 0, sizeof( buffer ) ); - - key->KeyLength = DVD_RPC_KEY_LENGTH; - key->KeyType = DvdGetRpcKey; - key->KeyFlags = 0; - - i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_READ_KEY, key, - key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1; - - if( i_ret < 0 ) - { - return i_ret; - } - - *p_type = ((PDVD_RPC_KEY)key->KeyData)->TypeCode; - *p_mask = ((PDVD_RPC_KEY)key->KeyData)->RegionMask; - *p_scheme = ((PDVD_RPC_KEY)key->KeyData)->RpcScheme; - } - else - { - INIT_SSC( GPCMD_REPORT_KEY, 8 ); - - ssc.CDBByte[ 10 ] = DVD_REPORT_RPC; - - i_ret = WinSendSSC( i_fd, &ssc ); - - *p_type = p_buffer[ 4 ] >> 6; - *p_mask = p_buffer[ 5 ]; - *p_scheme = p_buffer[ 6 ]; - } - -#elif defined( __QNXNTO__ ) - - INIT_CPT( GPCMD_REPORT_KEY, 8 ); - - p_cpt->cam_cdb[ 10 ] = DVD_REPORT_RPC; - - i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL); - - *p_type = p_buffer[ 4 ] >> 6; - *p_mask = p_buffer[ 5 ]; - *p_scheme = p_buffer[ 6 ]; - -#elif defined( SYS_OS2 ) - INIT_SSC( GPCMD_REPORT_KEY, 8 ); - - sdc.command[ 10 ] = DVD_REPORT_RPC; - - i_ret = DosDevIOCtl(i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD, - &sdc, sizeof(sdc), &ulParamLen, - p_buffer, sizeof(p_buffer), &ulDataLen); - - *p_type = p_buffer[ 4 ] >> 6; - *p_mask = p_buffer[ 5 ]; - *p_scheme = p_buffer[ 6 ]; - -#else -# error "DVD ioctls are unavailable on this system" - -#endif - return i_ret; -} - -/***************************************************************************** - * ioctl_SendRPC: set RPC status for the drive - *****************************************************************************/ -int ioctl_SendRPC( int i_fd, int i_pdrc ) -{ - int i_ret; - -#if defined( HAVE_LINUX_DVD_STRUCT ) && defined( DVD_HOST_SEND_RPC_STATE ) - dvd_authinfo auth_info; - - memset( &auth_info, 0, sizeof( auth_info ) ); - auth_info.type = DVD_HOST_SEND_RPC_STATE; - auth_info.hrpcs.pdrc = i_pdrc; - - i_ret = ioctl( i_fd, DVD_AUTH, &auth_info ); - -#elif defined( HAVE_LINUX_DVD_STRUCT ) - /* FIXME: OpenBSD doesn't know this */ - i_ret = -1; - -#elif defined( HAVE_BSD_DVD_STRUCT ) - struct dvd_authinfo auth_info; - - memset( &auth_info, 0, sizeof( auth_info ) ); - auth_info.format = DVD_SEND_RPC; - auth_info.region = i_pdrc; - - i_ret = ioctl( i_fd, DVDIOCSENDKEY, &auth_info ); - -#elif defined( SYS_BEOS ) - INIT_RDC( GPCMD_SEND_KEY, 8 ); - - rdc.command[ 10 ] = DVD_SEND_RPC; - - p_buffer[ 1 ] = 6; - p_buffer[ 4 ] = i_pdrc; - - i_ret = ioctl( i_fd, B_RAW_DEVICE_COMMAND, &rdc, sizeof(rdc) ); - -#elif defined( HPUX_SCTL_IO ) - INIT_SCTL_IO( GPCMD_SEND_KEY, 8 ); - - sctl_io.cdb[ 10 ] = DVD_SEND_RPC; - - p_buffer[ 1 ] = 6; - p_buffer[ 4 ] = i_pdrc; - - i_ret = ioctl( i_fd, SIOC_IO, &sctl_io ); - -#elif defined( SOLARIS_USCSI ) - INIT_USCSI( GPCMD_SEND_KEY, 8 ); - - rs_cdb.cdb_opaque[ 10 ] = DVD_SEND_RPC; - - p_buffer[ 1 ] = 6; - p_buffer[ 4 ] = i_pdrc; - - i_ret = SolarisSendUSCSI( i_fd, &sc ); - - if( i_ret < 0 || sc.uscsi_status ) - { - i_ret = -1; - } - -#elif defined( DARWIN_DVD_IOCTL ) - INIT_DVDIOCTL( dk_dvd_send_key_t, DVDRegionPlaybackControlInfo, - kDVDKeyFormatSetRegion ); - - dvd.keyClass = kDVDKeyClassCSS_CPPM_CPRM; - dvdbs.driveRegion = i_pdrc; - - i_ret = ioctl( i_fd, DKIOCDVDSENDKEY, &dvd ); - -#elif defined( WIN32 ) - if( WIN2K ) /* NT/2k/XP */ - { - INIT_SPTD( GPCMD_SEND_KEY, 8 ); - - sptd.Cdb[ 10 ] = DVD_SEND_RPC; - - p_buffer[ 1 ] = 6; - p_buffer[ 4 ] = i_pdrc; - - i_ret = SEND_SPTD( i_fd, &sptd, &tmp ); - } - else - { - INIT_SSC( GPCMD_SEND_KEY, 8 ); - - ssc.CDBByte[ 10 ] = DVD_SEND_RPC; - - p_buffer[ 1 ] = 6; - p_buffer[ 4 ] = i_pdrc; - - i_ret = WinSendSSC( i_fd, &ssc ); - } - -#elif defined( __QNXNTO__ ) - - INIT_CPT( GPCMD_SEND_KEY, 8 ); - - p_cpt->cam_cdb[ 10 ] = DVD_SEND_RPC; - - p_buffer[ 1 ] = 6; - p_buffer[ 4 ] = i_pdrc; - - i_ret = devctl(i_fd, DCMD_CAM_PASS_THRU, p_cpt, structSize, NULL); - -#elif defined( SYS_OS2 ) - INIT_SSC( GPCMD_SEND_KEY, 8 ); - - sdc.command[ 10 ] = DVD_SEND_RPC; - - p_buffer[ 1 ] = 6; - p_buffer[ 4 ] = i_pdrc; - - i_ret = DosDevIOCtl( i_fd, IOCTL_CDROMDISK, CDROMDISK_EXECMD, - &sdc, sizeof(sdc), &ulParamLen, - p_buffer, sizeof(p_buffer), &ulDataLen ); - -#else -# error "DVD ioctls are unavailable on this system" - -#endif - return i_ret; -} - -/* Local prototypes */ - -#if defined( SYS_BEOS ) -/***************************************************************************** - * BeInitRDC: initialize a RDC structure for the BeOS kernel - ***************************************************************************** - * This function initializes a BeOS raw device command structure for future - * use, either a read command or a write command. - *****************************************************************************/ -static void BeInitRDC( raw_device_command *p_rdc, int i_type ) -{ - memset( p_rdc->data, 0, p_rdc->data_length ); - - switch( i_type ) - { - case GPCMD_SEND_KEY: - /* leave the flags to 0 */ - break; - - case GPCMD_READ_DVD_STRUCTURE: case GPCMD_REPORT_KEY: - p_rdc->flags = B_RAW_DEVICE_DATA_IN; break; } - - p_rdc->command[ 0 ] = i_type; - - p_rdc->command[ 8 ] = (p_rdc->data_length >> 8) & 0xff; - p_rdc->command[ 9 ] = p_rdc->data_length & 0xff; - p_rdc->command_length = 12; - - p_rdc->sense_data = NULL; - p_rdc->sense_data_length = 0; - - p_rdc->timeout = 1000000; -} -#endif - -#if defined( HPUX_SCTL_IO ) -/***************************************************************************** - * HPUXInitSCTL: initialize a sctl_io structure for the HP-UX kernel - ***************************************************************************** - * This function initializes a HP-UX command structure for future - * use, either a read command or a write command. - *****************************************************************************/ -static void HPUXInitSCTL( struct sctl_io *sctl_io, int i_type ) -{ - memset( sctl_io->data, 0, sctl_io->data_length ); - - switch( i_type ) - { - case GPCMD_SEND_KEY: - /* leave the flags to 0 */ - break; - - case GPCMD_READ_DVD_STRUCTURE: - case GPCMD_REPORT_KEY: - sctl_io->flags = SCTL_READ; - break; - } - - sctl_io->cdb[ 0 ] = i_type; - - sctl_io->cdb[ 8 ] = (sctl_io->data_length >> 8) & 0xff; - sctl_io->cdb[ 9 ] = sctl_io->data_length & 0xff; - sctl_io->cdb_length = 12; - - sctl_io->max_msecs = 1000000; -} -#endif - -#if defined( SOLARIS_USCSI ) -/***************************************************************************** - * SolarisInitUSCSI: initialize a USCSICMD structure for the Solaris kernel - ***************************************************************************** - * This function initializes a Solaris userspace scsi command structure for - * future use, either a read command or a write command. - *****************************************************************************/ -static void SolarisInitUSCSI( struct uscsi_cmd *p_sc, int i_type ) -{ - union scsi_cdb *rs_cdb; - memset( p_sc->uscsi_cdb, 0, sizeof( union scsi_cdb ) ); - memset( p_sc->uscsi_bufaddr, 0, p_sc->uscsi_buflen ); - - switch( i_type ) - { - case GPCMD_SEND_KEY: - p_sc->uscsi_flags = USCSI_ISOLATE | USCSI_WRITE; - break; - - case GPCMD_READ_DVD_STRUCTURE: - case GPCMD_REPORT_KEY: - p_sc->uscsi_flags = USCSI_ISOLATE | USCSI_READ; - break; - } - - rs_cdb = (union scsi_cdb *)p_sc->uscsi_cdb; - - rs_cdb->scc_cmd = i_type; - - rs_cdb->cdb_opaque[ 8 ] = (p_sc->uscsi_buflen >> 8) & 0xff; - rs_cdb->cdb_opaque[ 9 ] = p_sc->uscsi_buflen & 0xff; - p_sc->uscsi_cdblen = 12; - - USCSI_TIMEOUT( p_sc, 15 ); -} - -/***************************************************************************** - * SolarisSendUSCSI: send a USCSICMD structure to the Solaris kernel - * for execution - ***************************************************************************** - * When available, this function uses the function smedia_uscsi_cmd() - * from Solaris' libsmedia library (Solaris 9 or newer) to execute the - * USCSI command. smedia_uscsi_cmd() allows USCSI commands for - * non-root users on removable media devices on Solaris 9; sending the - * USCSI command directly to the device using the USCSICMD ioctl fails - * with an EPERM error on Solaris 9. - * - * The code will fall back to the USCSICMD ioctl method, when - * libsmedia.so is not available or does not export the - * smedia_uscsi_cmd() function (on Solaris releases upto and including - * Solaris 8). Fortunatelly, on these old releases non-root users are - * allowed to perform USCSICMD ioctls on removable media devices. - *****************************************************************************/ -static int SolarisSendUSCSI( int i_fd, struct uscsi_cmd *p_sc ) -{ - void *p_handle; - - /* We use static variables to keep track of the libsmedia symbols, which - * is harmless even in a multithreaded program because the library and - * its symbols will always be mapped at the same address. */ - static int b_tried = 0; - static int b_have_sm = 0; - static void * (*p_get_handle) ( int32_t ); - static int (*p_uscsi_cmd) ( void *, struct uscsi_cmd * ); - static int (*p_release_handle) ( void * ); - - if( !b_tried ) - { - void *p_lib; - - p_lib = dlopen( "libsmedia.so", RTLD_NOW ); - if( p_lib ) - { - p_get_handle = dlsym( p_lib, "smedia_get_handle" ); - p_uscsi_cmd = dlsym( p_lib, "smedia_uscsi_cmd" ); - p_release_handle = dlsym( p_lib, "smedia_release_handle" ); - - if( p_get_handle && p_uscsi_cmd && p_release_handle ) - { - b_have_sm = 1; - } - else - { - dlclose( p_lib ); - } - } - - b_tried = 1; - } - - if( b_have_sm && (p_handle = p_get_handle(i_fd)) ) - { - int i_ret = p_uscsi_cmd( p_handle, p_sc ); - p_release_handle( p_handle ); - return i_ret; - } - - return ioctl( i_fd, USCSICMD, p_sc ); -} -#endif - -#if defined( WIN32 ) -/***************************************************************************** - * WinInitSPTD: initialize a sptd structure - ***************************************************************************** - * This function initializes a SCSI pass through command structure for future - * use, either a read command or a write command. - *****************************************************************************/ -static void WinInitSPTD( SCSI_PASS_THROUGH_DIRECT *p_sptd, int i_type ) -{ - memset( p_sptd->DataBuffer, 0, p_sptd->DataTransferLength ); - - switch( i_type ) - { - case GPCMD_SEND_KEY: - p_sptd->DataIn = SCSI_IOCTL_DATA_OUT; - break; - - case GPCMD_READ_DVD_STRUCTURE: - case GPCMD_REPORT_KEY: - p_sptd->DataIn = SCSI_IOCTL_DATA_IN; - break; - } - - p_sptd->Cdb[ 0 ] = i_type; - p_sptd->Cdb[ 8 ] = (uint8_t)(p_sptd->DataTransferLength >> 8) & 0xff; - p_sptd->Cdb[ 9 ] = (uint8_t) p_sptd->DataTransferLength & 0xff; - p_sptd->CdbLength = 12; - - p_sptd->TimeOutValue = 2; -} - -/***************************************************************************** - * WinInitSSC: initialize a ssc structure for the win32 aspi layer - ***************************************************************************** - * This function initializes a ssc raw device command structure for future - * use, either a read command or a write command. - *****************************************************************************/ -static void WinInitSSC( struct SRB_ExecSCSICmd *p_ssc, int i_type ) -{ - memset( p_ssc->SRB_BufPointer, 0, p_ssc->SRB_BufLen ); - - switch( i_type ) - { - case GPCMD_SEND_KEY: - p_ssc->SRB_Flags = SRB_DIR_OUT; - break; - - case GPCMD_READ_DVD_STRUCTURE: - case GPCMD_REPORT_KEY: - p_ssc->SRB_Flags = SRB_DIR_IN; - break; - } - - p_ssc->SRB_Cmd = SC_EXEC_SCSI_CMD; - p_ssc->SRB_Flags |= SRB_EVENT_NOTIFY; - - p_ssc->CDBByte[ 0 ] = i_type; - - p_ssc->CDBByte[ 8 ] = (uint8_t)(p_ssc->SRB_BufLen >> 8) & 0xff; - p_ssc->CDBByte[ 9 ] = (uint8_t) p_ssc->SRB_BufLen & 0xff; - p_ssc->SRB_CDBLen = 12; - - p_ssc->SRB_SenseLen = SENSE_LEN; -} - -/***************************************************************************** - * WinSendSSC: send a ssc structure to the aspi layer - *****************************************************************************/ -static int WinSendSSC( int i_fd, struct SRB_ExecSCSICmd *p_ssc ) -{ - HANDLE hEvent = NULL; - struct w32_aspidev *fd = (struct w32_aspidev *) i_fd; - - hEvent = CreateEvent( NULL, TRUE, FALSE, NULL ); - if( hEvent == NULL ) - { - return -1; - } - - p_ssc->SRB_PostProc = hEvent; - p_ssc->SRB_HaId = LOBYTE( fd->i_sid ); - p_ssc->SRB_Target = HIBYTE( fd->i_sid ); - - ResetEvent( hEvent ); - if( fd->lpSendCommand( (void*) p_ssc ) == SS_PENDING ) - WaitForSingleObject( hEvent, INFINITE ); - - CloseHandle( hEvent ); - - return p_ssc->SRB_Status == SS_COMP ? 0 : -1; -} -#endif - -#if defined( __QNXNTO__ ) -/***************************************************************************** - * QNXInitCPT: initialize a CPT structure for QNX Neutrino - ***************************************************************************** - * This function initializes a cpt command structure for future use, - * either a read command or a write command. - *****************************************************************************/ -static void QNXInitCPT( CAM_PASS_THRU * p_cpt, int i_type ) -{ - switch( i_type ) - { - case GPCMD_SEND_KEY: - p_cpt->cam_flags = CAM_DIR_OUT; - break; - - case GPCMD_READ_DVD_STRUCTURE: - case GPCMD_REPORT_KEY: - p_cpt->cam_flags = CAM_DIR_IN; - break; - } - - p_cpt->cam_cdb[0] = i_type; - - p_cpt->cam_cdb[ 8 ] = (p_cpt->cam_dxfer_len >> 8) & 0xff; - p_cpt->cam_cdb[ 9 ] = p_cpt->cam_dxfer_len & 0xff; - p_cpt->cam_cdb_len = 12; - - p_cpt->cam_timeout = CAM_TIME_DEFAULT; -} -#endif - -#if defined( SYS_OS2 ) -/***************************************************************************** - * OS2InitSDC: initialize a SDC structure for the Execute SCSI-command - ***************************************************************************** - * This function initializes a OS2 'execute SCSI command' structure for - * future use, either a read command or a write command. - *****************************************************************************/ -static void OS2InitSDC( struct OS2_ExecSCSICmd *p_sdc, int i_type ) -{ - switch( i_type ) - { - case GPCMD_SEND_KEY: - p_sdc->flags = 0; - break; - - case GPCMD_READ_DVD_STRUCTURE: - case GPCMD_REPORT_KEY: - p_sdc->flags = EX_DIRECTION_IN; - break; - } - - p_sdc->command[ 0 ] = i_type; - p_sdc->command[ 8 ] = (p_sdc->data_length >> 8) & 0xff; - p_sdc->command[ 9 ] = p_sdc->data_length & 0xff; - p_sdc->id_code = 0x31304443; // 'CD01' - p_sdc->cmd_length = 12; -} -#endif diff --git a/libdvdcss/ioctl.h b/libdvdcss/ioctl.h deleted file mode 100644 index 16f51d2..0000000 --- a/libdvdcss/ioctl.h +++ /dev/null @@ -1,429 +0,0 @@ -/***************************************************************************** - * ioctl.h: DVD ioctl replacement function - ***************************************************************************** - * Copyright (C) 1999-2001 VideoLAN - * $Id$ - * - * Authors: Sam Hocevar - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. - *****************************************************************************/ - -int ioctl_ReadCopyright ( int, int, int * ); -int ioctl_ReadDiscKey ( int, int *, uint8_t * ); -int ioctl_ReadTitleKey ( int, int *, int, uint8_t * ); -int ioctl_ReportAgid ( int, int * ); -int ioctl_ReportChallenge ( int, int *, uint8_t * ); -int ioctl_ReportKey1 ( int, int *, uint8_t * ); -int ioctl_ReportASF ( int, int *, int * ); -int ioctl_InvalidateAgid ( int, int * ); -int ioctl_SendChallenge ( int, int *, uint8_t * ); -int ioctl_SendKey2 ( int, int *, uint8_t * ); -int ioctl_ReportRPC ( int, int *, int *, int * ); -int ioctl_SendRPC ( int, int ); - -#define DVD_KEY_SIZE 5 -#define DVD_CHALLENGE_SIZE 10 -#define DVD_DISCKEY_SIZE 2048 - -/***************************************************************************** - * Common macro, BeOS specific - *****************************************************************************/ -#if defined( SYS_BEOS ) -#define INIT_RDC( TYPE, SIZE ) \ - raw_device_command rdc; \ - uint8_t p_buffer[ (SIZE)+1 ]; \ - memset( &rdc, 0, sizeof( raw_device_command ) ); \ - rdc.data = (char *)p_buffer; \ - rdc.data_length = (SIZE); \ - BeInitRDC( &rdc, (TYPE) ); -#endif - -/***************************************************************************** - * Common macro, HP-UX specific - *****************************************************************************/ -#if defined( HPUX_SCTL_IO ) -#define INIT_SCTL_IO( TYPE, SIZE ) \ - struct sctl_io sctl_io; \ - uint8_t p_buffer[ (SIZE)+1 ]; \ - memset( &sctl_io, 0, sizeof( sctl_io ) ); \ - sctl_io.data = (void *)p_buffer; \ - sctl_io.data_length = (SIZE); \ - HPUXInitSCTL( &sctl_io, (TYPE) ); -#endif - -/***************************************************************************** - * Common macro, Solaris specific - *****************************************************************************/ -#if defined( SOLARIS_USCSI ) -#define USCSI_TIMEOUT( SC, TO ) ( (SC)->uscsi_timeout = (TO) ) -#define USCSI_RESID( SC ) ( (SC)->uscsi_resid ) -#define INIT_USCSI( TYPE, SIZE ) \ - struct uscsi_cmd sc; \ - union scsi_cdb rs_cdb; \ - uint8_t p_buffer[ (SIZE)+1 ]; \ - memset( &sc, 0, sizeof( struct uscsi_cmd ) ); \ - sc.uscsi_cdb = (caddr_t)&rs_cdb; \ - sc.uscsi_bufaddr = (caddr_t)p_buffer; \ - sc.uscsi_buflen = (SIZE); \ - SolarisInitUSCSI( &sc, (TYPE) ); -#endif - -/***************************************************************************** - * Common macro, Darwin specific - *****************************************************************************/ -#if defined( DARWIN_DVD_IOCTL ) -#define INIT_DVDIOCTL( DKDVD_TYPE, BUFFER_TYPE, FORMAT ) \ - DKDVD_TYPE dvd; \ - BUFFER_TYPE dvdbs; \ - memset( &dvd, 0, sizeof(dvd) ); \ - memset( &dvdbs, 0, sizeof(dvdbs) ); \ - dvd.format = FORMAT; \ - dvd.buffer = &dvdbs; \ - dvd.bufferLength = sizeof(dvdbs); -#endif - -/***************************************************************************** - * Common macro, win32 specific - *****************************************************************************/ -#if defined( WIN32 ) -#define INIT_SPTD( TYPE, SIZE ) \ - DWORD tmp; \ - SCSI_PASS_THROUGH_DIRECT sptd; \ - uint8_t p_buffer[ (SIZE) ]; \ - memset( &sptd, 0, sizeof( SCSI_PASS_THROUGH_DIRECT ) ); \ - sptd.Length = sizeof( SCSI_PASS_THROUGH_DIRECT ); \ - sptd.DataBuffer = p_buffer; \ - sptd.DataTransferLength = (SIZE); \ - WinInitSPTD( &sptd, (TYPE) ); -#define SEND_SPTD( DEV, SPTD, TMP ) \ - (DeviceIoControl( (HANDLE)(DEV), IOCTL_SCSI_PASS_THROUGH_DIRECT, \ - (SPTD), sizeof( SCSI_PASS_THROUGH_DIRECT ), \ - (SPTD), sizeof( SCSI_PASS_THROUGH_DIRECT ), \ - (TMP), NULL ) ? 0 : -1) -#define INIT_SSC( TYPE, SIZE ) \ - struct SRB_ExecSCSICmd ssc; \ - uint8_t p_buffer[ (SIZE)+1 ]; \ - memset( &ssc, 0, sizeof( struct SRB_ExecSCSICmd ) ); \ - ssc.SRB_BufPointer = (char *)p_buffer; \ - ssc.SRB_BufLen = (SIZE); \ - WinInitSSC( &ssc, (TYPE) ); -#endif - -/***************************************************************************** - * Common macro, QNX specific - *****************************************************************************/ -#if defined( __QNXNTO__ ) -#define INIT_CPT( TYPE, SIZE ) \ - CAM_PASS_THRU * p_cpt; \ - uint8_t * p_buffer; \ - int structSize = sizeof( CAM_PASS_THRU ) + (SIZE); \ - p_cpt = (CAM_PASS_THRU *) malloc ( structSize ); \ - p_buffer = (uint8_t *) p_cpt + sizeof( CAM_PASS_THRU ); \ - memset( p_cpt, 0, structSize ); \ - p_cpt->cam_data_ptr = sizeof( CAM_PASS_THRU ); \ - p_cpt->cam_dxfer_len = (SIZE); \ - QNXInitCPT( p_cpt, (TYPE) ); -#endif - -/***************************************************************************** - * Common macro, OS2 specific - *****************************************************************************/ -#if defined( SYS_OS2 ) -#define INIT_SSC( TYPE, SIZE ) \ - struct OS2_ExecSCSICmd sdc; \ - uint8_t p_buffer[ (SIZE)+1 ]; \ - unsigned long ulParamLen; \ - unsigned long ulDataLen; \ - memset( &sdc, 0, sizeof( OS2_ExecSCSICmd ) ); \ - memset( &p_buffer, 0, SIZE ); \ - sdc.data_length = (SIZE); \ - ulParamLen = sizeof(sdc); \ - OS2InitSDC( &sdc, (TYPE) ) -#endif - -/***************************************************************************** - * Additional types, OpenBSD specific - *****************************************************************************/ -#if defined( HAVE_OPENBSD_DVD_STRUCT ) -typedef union dvd_struct dvd_struct; -typedef union dvd_authinfo dvd_authinfo; -#endif - -/***************************************************************************** - * Various DVD I/O tables - *****************************************************************************/ -#if defined( SYS_BEOS ) || defined( WIN32 ) || defined ( SOLARIS_USCSI ) || defined ( HPUX_SCTL_IO ) || defined ( __QNXNTO__ ) || defined ( SYS_OS2 ) - /* The generic packet command opcodes for CD/DVD Logical Units, - * From Table 57 of the SFF8090 Ver. 3 (Mt. Fuji) draft standard. */ -# define GPCMD_READ_DVD_STRUCTURE 0xad -# define GPCMD_REPORT_KEY 0xa4 -# define GPCMD_SEND_KEY 0xa3 - /* DVD struct types */ -# define DVD_STRUCT_PHYSICAL 0x00 -# define DVD_STRUCT_COPYRIGHT 0x01 -# define DVD_STRUCT_DISCKEY 0x02 -# define DVD_STRUCT_BCA 0x03 -# define DVD_STRUCT_MANUFACT 0x04 - /* Key formats */ -# define DVD_REPORT_AGID 0x00 -# define DVD_REPORT_CHALLENGE 0x01 -# define DVD_SEND_CHALLENGE 0x01 -# define DVD_REPORT_KEY1 0x02 -# define DVD_SEND_KEY2 0x03 -# define DVD_REPORT_TITLE_KEY 0x04 -# define DVD_REPORT_ASF 0x05 -# define DVD_SEND_RPC 0x06 -# define DVD_REPORT_RPC 0x08 -# define DVD_INVALIDATE_AGID 0x3f -#endif - -/***************************************************************************** - * win32 ioctl specific - *****************************************************************************/ -#if defined( WIN32 ) - -#define WIN32_LEAN_AND_MEAN -#include - -#define IOCTL_DVD_START_SESSION CTL_CODE(FILE_DEVICE_DVD, 0x0400, METHOD_BUFFERED, FILE_READ_ACCESS) -#define IOCTL_DVD_READ_KEY CTL_CODE(FILE_DEVICE_DVD, 0x0401, METHOD_BUFFERED, FILE_READ_ACCESS) -#define IOCTL_DVD_SEND_KEY CTL_CODE(FILE_DEVICE_DVD, 0x0402, METHOD_BUFFERED, FILE_READ_ACCESS) -#define IOCTL_DVD_END_SESSION CTL_CODE(FILE_DEVICE_DVD, 0x0403, METHOD_BUFFERED, FILE_READ_ACCESS) -#define IOCTL_DVD_GET_REGION CTL_CODE(FILE_DEVICE_DVD, 0x0405, METHOD_BUFFERED, FILE_READ_ACCESS) -#define IOCTL_DVD_SEND_KEY2 CTL_CODE(FILE_DEVICE_DVD, 0x0406, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) -#define IOCTL_DVD_READ_STRUCTURE CTL_CODE(FILE_DEVICE_DVD, 0x0450, METHOD_BUFFERED, FILE_READ_ACCESS) -#define IOCTL_SCSI_PASS_THROUGH_DIRECT CTL_CODE(FILE_DEVICE_CONTROLLER, 0x0405, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) - -#define DVD_CHALLENGE_KEY_LENGTH (12 + sizeof(DVD_COPY_PROTECT_KEY)) -#define DVD_BUS_KEY_LENGTH (8 + sizeof(DVD_COPY_PROTECT_KEY)) -#define DVD_TITLE_KEY_LENGTH (8 + sizeof(DVD_COPY_PROTECT_KEY)) -#define DVD_DISK_KEY_LENGTH (2048 + sizeof(DVD_COPY_PROTECT_KEY)) -#define DVD_RPC_KEY_LENGTH (sizeof(DVD_RPC_KEY) + sizeof(DVD_COPY_PROTECT_KEY)) -#define DVD_ASF_LENGTH (sizeof(DVD_ASF) + sizeof(DVD_COPY_PROTECT_KEY)) - -#define DVD_COPYRIGHT_MASK 0x00000040 -#define DVD_NOT_COPYRIGHTED 0x00000000 -#define DVD_COPYRIGHTED 0x00000040 - -#define DVD_SECTOR_PROTECT_MASK 0x00000020 -#define DVD_SECTOR_NOT_PROTECTED 0x00000000 -#define DVD_SECTOR_PROTECTED 0x00000020 - -#define SCSI_IOCTL_DATA_OUT 0 -#define SCSI_IOCTL_DATA_IN 1 - -typedef ULONG DVD_SESSION_ID, *PDVD_SESSION_ID; - -typedef enum DVD_STRUCTURE_FORMAT { - DvdPhysicalDescriptor, - DvdCopyrightDescriptor, - DvdDiskKeyDescriptor, - DvdBCADescriptor, - DvdManufacturerDescriptor, - DvdMaxDescriptor -} DVD_STRUCTURE_FORMAT, *PDVD_STRUCTURE_FORMAT; - -typedef struct DVD_READ_STRUCTURE { - LARGE_INTEGER BlockByteOffset; - DVD_STRUCTURE_FORMAT Format; - DVD_SESSION_ID SessionId; - UCHAR LayerNumber; -} DVD_READ_STRUCTURE, *PDVD_READ_STRUCTURE; - -typedef struct DVD_COPYRIGHT_DESCRIPTOR { - UCHAR CopyrightProtectionType; - UCHAR RegionManagementInformation; - USHORT Reserved; -} DVD_COPYRIGHT_DESCRIPTOR, *PDVD_COPYRIGHT_DESCRIPTOR; - -typedef enum -{ - DvdChallengeKey = 0x01, - DvdBusKey1, - DvdBusKey2, - DvdTitleKey, - DvdAsf, - DvdSetRpcKey = 0x6, - DvdGetRpcKey = 0x8, - DvdDiskKey = 0x80, - DvdInvalidateAGID = 0x3f -} DVD_KEY_TYPE; - -typedef struct DVD_COPY_PROTECT_KEY -{ - ULONG KeyLength; - DVD_SESSION_ID SessionId; - DVD_KEY_TYPE KeyType; - ULONG KeyFlags; - union - { - struct - { - ULONG FileHandle; - ULONG Reserved; // used for NT alignment - }; - LARGE_INTEGER TitleOffset; - } Parameters; - UCHAR KeyData[0]; -} DVD_COPY_PROTECT_KEY, *PDVD_COPY_PROTECT_KEY; - -typedef struct DVD_ASF -{ - UCHAR Reserved0[3]; - UCHAR SuccessFlag:1; - UCHAR Reserved1:7; -} DVD_ASF, * PDVD_ASF; - -typedef struct DVD_RPC_KEY -{ - UCHAR UserResetsAvailable:3; - UCHAR ManufacturerResetsAvailable:3; - UCHAR TypeCode:2; - UCHAR RegionMask; - UCHAR RpcScheme; - UCHAR Reserved2[1]; -} DVD_RPC_KEY, * PDVD_RPC_KEY; - -typedef struct SCSI_PASS_THROUGH_DIRECT -{ - USHORT Length; - UCHAR ScsiStatus; - UCHAR PathId; - UCHAR TargetId; - UCHAR Lun; - UCHAR CdbLength; - UCHAR SenseInfoLength; - UCHAR DataIn; - ULONG DataTransferLength; - ULONG TimeOutValue; - PVOID DataBuffer; - ULONG SenseInfoOffset; - UCHAR Cdb[16]; -} SCSI_PASS_THROUGH_DIRECT, *PSCSI_PASS_THROUGH_DIRECT; - -/***************************************************************************** - * win32 aspi specific - *****************************************************************************/ - -typedef DWORD (CALLBACK *GETASPI32SUPPORTINFO)(VOID); -typedef DWORD (CALLBACK *SENDASPI32COMMAND)(LPVOID); - -#define WIN2K ( GetVersion() < 0x80000000 ) -#define ASPI_HAID 0 -#define ASPI_TARGET 0 -#define DTYPE_CDROM 0x05 - -#define SENSE_LEN 0x0E -#define SC_GET_DEV_TYPE 0x01 -#define SC_EXEC_SCSI_CMD 0x02 -#define SC_GET_DISK_INFO 0x06 -#define SS_COMP 0x01 -#define SS_PENDING 0x00 -#define SS_NO_ADAPTERS 0xE8 -#define SRB_DIR_IN 0x08 -#define SRB_DIR_OUT 0x10 -#define SRB_EVENT_NOTIFY 0x40 - -struct w32_aspidev -{ - long hASPI; - short i_sid; - int i_blocks; - SENDASPI32COMMAND lpSendCommand; -}; - -#pragma pack(1) - -struct SRB_GetDiskInfo -{ - unsigned char SRB_Cmd; - unsigned char SRB_Status; - unsigned char SRB_HaId; - unsigned char SRB_Flags; - unsigned long SRB_Hdr_Rsvd; - unsigned char SRB_Target; - unsigned char SRB_Lun; - unsigned char SRB_DriveFlags; - unsigned char SRB_Int13HDriveInfo; - unsigned char SRB_Heads; - unsigned char SRB_Sectors; - unsigned char SRB_Rsvd1[22]; -}; - -struct SRB_GDEVBlock -{ - unsigned char SRB_Cmd; - unsigned char SRB_Status; - unsigned char SRB_HaId; - unsigned char SRB_Flags; - unsigned long SRB_Hdr_Rsvd; - unsigned char SRB_Target; - unsigned char SRB_Lun; - unsigned char SRB_DeviceType; - unsigned char SRB_Rsvd1; -}; - -struct SRB_ExecSCSICmd -{ - unsigned char SRB_Cmd; - unsigned char SRB_Status; - unsigned char SRB_HaId; - unsigned char SRB_Flags; - unsigned long SRB_Hdr_Rsvd; - unsigned char SRB_Target; - unsigned char SRB_Lun; - unsigned short SRB_Rsvd1; - unsigned long SRB_BufLen; - unsigned char *SRB_BufPointer; - unsigned char SRB_SenseLen; - unsigned char SRB_CDBLen; - unsigned char SRB_HaStat; - unsigned char SRB_TargStat; - unsigned long *SRB_PostProc; - unsigned char SRB_Rsvd2[20]; - unsigned char CDBByte[16]; - unsigned char SenseArea[SENSE_LEN+2]; -}; - -#pragma pack() - -#endif - -/***************************************************************************** - * OS2 ioctl specific - *****************************************************************************/ -#if defined( SYS_OS2 ) - -#define CDROMDISK_EXECMD 0x7A - -#define EX_DIRECTION_IN 0x01 -#define EX_PLAYING_CHK 0x02 - -#pragma pack(1) - -struct OS2_ExecSCSICmd -{ - unsigned long id_code; // 'CD01' - unsigned short data_length; // length of the Data Packet - unsigned short cmd_length; // length of the Command Buffer - unsigned short flags; // flags - unsigned char command[16]; // Command Buffer for SCSI command - -} OS2_ExecSCSICmd; - -#pragma pack() - -#endif diff --git a/libdvdcss/libdvdcss.c b/libdvdcss/libdvdcss.c deleted file mode 100644 index 1be814f..0000000 --- a/libdvdcss/libdvdcss.c +++ /dev/null @@ -1,811 +0,0 @@ -/* libdvdcss.c: DVD reading library. - * - * Authors: Stéphane Borel - * Sam Hocevar - * Håkan Hjort - * - * Copyright (C) 1998-2008 VideoLAN - * $Id$ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. - */ - -/** - * \mainpage libdvdcss developer documentation - * - * \section intro Introduction - * - * \e libdvdcss is a simple library designed for accessing DVDs like a block - * device without having to bother about the decryption. The important features - * are: - * \li portability: currently supported platforms are GNU/Linux, FreeBSD, - * NetBSD, OpenBSD, BSD/OS, BeOS, Windows 95/98, Windows NT/2000, MacOS X, - * Solaris, HP-UX and OS/2. - * \li adaptability: unlike most similar projects, libdvdcss doesn't require - * the region of your drive to be set and will try its best to read from - * the disc even in the case of a region mismatch. - * \li simplicity: a DVD player can be built around the \e libdvdcss API using - * no more than 4 or 5 library calls. - * - * \e libdvdcss is free software, released under the General Public License. - * This ensures that \e libdvdcss remains free and used only with free - * software. - * - * \section api The libdvdcss API - * - * The complete \e libdvdcss programming interface is documented in the - * dvdcss.h file. - * - * \section env Environment variables - * - * Some environment variables can be used to change the behaviour of - * \e libdvdcss without having to modify the program which uses it. These - * variables are: - * - * \li \b DVDCSS_VERBOSE: sets the verbosity level. - * - \c 0 outputs no messages at all. - * - \c 1 outputs error messages to stderr. - * - \c 2 outputs error messages and debug messages to stderr. - * - * \li \b DVDCSS_METHOD: sets the authentication and decryption method - * that \e libdvdcss will use to read scrambled discs. Can be one - * of \c title, \c key or \c disc. - * - \c key is the default method. \e libdvdcss will use a set of - * calculated player keys to try and get the disc key. This can fail - * if the drive does not recognize any of the player keys. - * - \c disc is a fallback method when \c key has failed. Instead of - * using player keys, \e libdvdcss will crack the disc key using - * a brute force algorithm. This process is CPU intensive and requires - * 64 MB of memory to store temporary data. - * - \c title is the fallback when all other methods have failed. It does - * not rely on a key exchange with the DVD drive, but rather uses a - * crypto attack to guess the title key. On rare cases this may fail - * because there is not enough encrypted data on the disc to perform - * a statistical attack, but in the other hand it is the only way to - * decrypt a DVD stored on a hard disc, or a DVD with the wrong region - * on an RPC2 drive. - * - * \li \b DVDCSS_RAW_DEVICE: specify the raw device to use. Exact usage will - * depend on your operating system, the Linux utility to set up raw devices - * is \c raw(8) for instance. Please note that on most operating systems, - * using a raw device requires highly aligned buffers: Linux requires a - * 2048 bytes alignment (which is the size of a DVD sector). - * - * \li \b DVDCSS_CACHE: specify a directory in which to store title key - * values. This will speed up descrambling of DVDs which are in the - * cache. The DVDCSS_CACHE directory is created if it does not exist, - * and a subdirectory is created named after the DVD's title or - * manufacturing date. If DVDCSS_CACHE is not set or is empty, \e libdvdcss - * will use the default value which is "${HOME}/.dvdcss/" under Unix and - * "C:\Documents and Settings\$USER\Application Data\dvdcss\" under Win32. - * The special value "off" disables caching. - */ - -/* - * Preamble - */ -#include "config.h" - -#include -#include -#include -#include -#include -#ifdef HAVE_SYS_PARAM_H -# include -#endif -#ifdef HAVE_PWD_H -# include -#endif -#include -#include - -#ifdef HAVE_UNISTD_H -# include -#endif - -#ifdef HAVE_LIMITS_H -# include -#endif - -#ifdef HAVE_DIRECT_H -# include -#endif - -#include "dvdcss/dvdcss.h" - -#include "common.h" -#include "css.h" -#include "libdvdcss.h" -#include "ioctl.h" -#include "device.h" - -/** - * \brief Symbol for version checks. - * - * The name of this symbol contains the library major number, which makes it - * easy to check which \e libdvdcss development headers are installed on the - * system with tools such as autoconf. - * - * The variable itself contains the exact version number of the library, - * which can be useful for specific feature needs. - */ -char * dvdcss_interface_2 = VERSION; - -/** - * \brief Open a DVD device or directory and return a dvdcss instance. - * - * \param psz_target a string containing the target name, for instance - * "/dev/hdc" or "E:". - * \return a handle to a dvdcss instance or NULL on error. - * - * Initialize the \e libdvdcss library and open the requested DVD device or - * directory. \e libdvdcss checks whether ioctls can be performed on the disc, - * and when possible, the disc key is retrieved. - * - * dvdcss_open() returns a handle to be used for all subsequent \e libdvdcss - * calls. If an error occurred, NULL is returned. - */ -LIBDVDCSS_EXPORT dvdcss_t dvdcss_open ( char *psz_target ) -{ - char psz_buffer[PATH_MAX]; - int i_ret; - - char *psz_method = getenv( "DVDCSS_METHOD" ); - char *psz_verbose = getenv( "DVDCSS_VERBOSE" ); - char *psz_cache = getenv( "DVDCSS_CACHE" ); -#ifndef WIN32 - char *psz_raw_device = getenv( "DVDCSS_RAW_DEVICE" ); -#endif - - dvdcss_t dvdcss; - - /* - * Allocate the library structure - */ - dvdcss = malloc( sizeof( struct dvdcss_s ) ); - if( dvdcss == NULL ) - { - return NULL; - } - - /* - * Initialize structure with default values - */ -#ifndef WIN32 - dvdcss->i_raw_fd = -1; -#endif - dvdcss->p_titles = NULL; - dvdcss->psz_device = (char *)strdup( psz_target ); - dvdcss->psz_error = "no error"; - dvdcss->i_method = DVDCSS_METHOD_KEY; - dvdcss->psz_cachefile[0] = '\0'; - dvdcss->b_debug = 0; - dvdcss->b_errors = 0; - - /* - * Find verbosity from DVDCSS_VERBOSE environment variable - */ - if( psz_verbose != NULL ) - { - int i = atoi( psz_verbose ); - - if( i >= 2 ) dvdcss->b_debug = i; - if( i >= 1 ) dvdcss->b_errors = 1; - } - - /* - * Find method from DVDCSS_METHOD environment variable - */ - if( psz_method != NULL ) - { - if( !strncmp( psz_method, "key", 4 ) ) - { - dvdcss->i_method = DVDCSS_METHOD_KEY; - } - else if( !strncmp( psz_method, "disc", 5 ) ) - { - dvdcss->i_method = DVDCSS_METHOD_DISC; - } - else if( !strncmp( psz_method, "title", 5 ) ) - { - dvdcss->i_method = DVDCSS_METHOD_TITLE; - } - else - { - print_error( dvdcss, "unknown decrypt method, please choose " - "from 'title', 'key' or 'disc'" ); - free( dvdcss->psz_device ); - free( dvdcss ); - return NULL; - } - } - - /* - * If DVDCSS_CACHE was not set, try to guess a default value - */ - if( psz_cache == NULL || psz_cache[0] == '\0' ) - { -#ifdef HAVE_DIRECT_H - typedef HRESULT( WINAPI *SHGETFOLDERPATH ) - ( HWND, int, HANDLE, DWORD, LPTSTR ); - -# define CSIDL_FLAG_CREATE 0x8000 -# define CSIDL_APPDATA 0x1A -# define SHGFP_TYPE_CURRENT 0 - - char psz_home[MAX_PATH]; - HINSTANCE p_dll; - SHGETFOLDERPATH p_getpath; - - *psz_home = '\0'; - - /* Load the shfolder dll to retrieve SHGetFolderPath */ - p_dll = LoadLibrary( "shfolder.dll" ); - if( p_dll ) - { - p_getpath = (void*)GetProcAddress( p_dll, "SHGetFolderPathA" ); - if( p_getpath ) - { - /* Get the "Application Data" folder for the current user */ - if( p_getpath( NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE, - NULL, SHGFP_TYPE_CURRENT, psz_home ) == S_OK ) - { - FreeLibrary( p_dll ); - } - else - { - *psz_home = '\0'; - } - } - FreeLibrary( p_dll ); - } - - /* Cache our keys in - * C:\Documents and Settings\$USER\Application Data\dvdcss\ */ - if( *psz_home ) - { - snprintf( psz_buffer, PATH_MAX, "%s/dvdcss", psz_home ); - psz_buffer[PATH_MAX-1] = '\0'; - psz_cache = psz_buffer; - } -#else - char *psz_home = NULL; -# ifdef HAVE_PWD_H - struct passwd *p_pwd; - - /* Try looking in password file for home dir. */ - p_pwd = getpwuid(getuid()); - if( p_pwd ) - { - psz_home = p_pwd->pw_dir; - } -# endif - - if( psz_home == NULL ) - { - psz_home = getenv( "HOME" ); - } - if( psz_home == NULL ) - { - psz_home = getenv( "USERPROFILE" ); - } - - /* Cache our keys in ${HOME}/.dvdcss/ */ - if( psz_home ) - { - snprintf( psz_buffer, PATH_MAX, "%s/.dvdcss", psz_home ); - psz_buffer[PATH_MAX-1] = '\0'; - psz_cache = psz_buffer; - } -#endif - } - - /* - * Find cache dir from the DVDCSS_CACHE environment variable - */ - if( psz_cache != NULL ) - { - if( psz_cache[0] == '\0' || !strcmp( psz_cache, "off" ) ) - { - psz_cache = NULL; - } - /* Check that we can add the ID directory and the block filename */ - else if( strlen( psz_cache ) + 1 + 32 + 1 + (KEY_SIZE * 2) + 10 + 1 - > PATH_MAX ) - { - print_error( dvdcss, "cache directory name is too long" ); - psz_cache = NULL; - } - } - - /* - * Open device - */ - _dvdcss_check( dvdcss ); - i_ret = _dvdcss_open( dvdcss ); - if( i_ret < 0 ) - { - free( dvdcss->psz_device ); - free( dvdcss ); - return NULL; - } - - dvdcss->b_scrambled = 1; /* Assume the worst */ - dvdcss->b_ioctls = _dvdcss_use_ioctls( dvdcss ); - - if( dvdcss->b_ioctls ) - { - i_ret = _dvdcss_test( dvdcss ); - if( i_ret < 0 ) - { - /* Disable the CSS ioctls and hope that it works? */ - print_debug( dvdcss, - "could not check whether the disc was scrambled" ); - dvdcss->b_ioctls = 0; - } - else - { - print_debug( dvdcss, i_ret ? "disc is scrambled" - : "disc is unscrambled" ); - dvdcss->b_scrambled = i_ret; - } - } - - /* If disc is CSS protected and the ioctls work, authenticate the drive */ - if( dvdcss->b_scrambled && dvdcss->b_ioctls ) - { - i_ret = _dvdcss_disckey( dvdcss ); - - if( i_ret < 0 ) - { - print_debug( dvdcss, "could not get disc key" ); - } - } - else - { - memset( dvdcss->css.p_disc_key, 0, KEY_SIZE ); - } - - /* If the cache is enabled, write the cache directory tag */ - if( psz_cache ) - { - char *psz_tag = "Signature: 8a477f597d28d172789f06886806bc55\r\n" - "# This file is a cache directory tag created by libdvdcss.\r\n" - "# For information about cache directory tags, see:\r\n" - "# http://www.brynosaurus.com/cachedir/\r\n"; - char psz_tagfile[PATH_MAX + 1 + 12 + 1]; - int i_fd; - - sprintf( psz_tagfile, "%s/CACHEDIR.TAG", psz_cache ); - i_fd = open( psz_tagfile, O_RDWR|O_CREAT, 0644 ); - if( i_fd >= 0 ) - { - write( i_fd, psz_tag, strlen(psz_tag) ); - close( i_fd ); - } - } - - /* If the cache is enabled, extract a unique disc ID */ - if( psz_cache ) - { - uint8_t p_sector[DVDCSS_BLOCK_SIZE]; - char psz_debug[PATH_MAX + 30]; - char psz_key[1 + KEY_SIZE * 2 + 1]; - char *psz_title; - uint8_t *psz_serial; - int i; - - /* We read sector 0. If it starts with 0x000001ba (BE), we are - * reading a VOB file, and we should not cache anything. */ - - i_ret = dvdcss->pf_seek( dvdcss, 0 ); - if( i_ret != 0 ) - { - goto nocache; - } - - i_ret = dvdcss->pf_read( dvdcss, p_sector, 1 ); - if( i_ret != 1 ) - { - goto nocache; - } - - if( p_sector[0] == 0x00 && p_sector[1] == 0x00 - && p_sector[2] == 0x01 && p_sector[3] == 0xba ) - { - goto nocache; - } - - /* The data we are looking for is at sector 16 (32768 bytes): - * - offset 40: disc title (32 uppercase chars) - * - offset 813: manufacturing date + serial no (16 digits) */ - - i_ret = dvdcss->pf_seek( dvdcss, 16 ); - if( i_ret != 16 ) - { - goto nocache; - } - - i_ret = dvdcss->pf_read( dvdcss, p_sector, 1 ); - if( i_ret != 1 ) - { - goto nocache; - } - - /* Get the disc title */ - psz_title = (char *)p_sector + 40; - psz_title[32] = '\0'; - - for( i = 0 ; i < 32 ; i++ ) - { - if( psz_title[i] <= ' ' ) - { - psz_title[i] = '\0'; - break; - } - else if( psz_title[i] == '/' || psz_title[i] == '\\' ) - { - psz_title[i] = '-'; - } - } - - /* Get the date + serial */ - psz_serial = p_sector + 813; - psz_serial[16] = '\0'; - - /* Check that all characters are digits, otherwise convert. */ - for( i = 0 ; i < 16 ; i++ ) - { - if( psz_serial[i] < '0' || psz_serial[i] > '9' ) - { - char psz_tmp[16 + 1]; - sprintf( psz_tmp, - "%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x", - psz_serial[0], psz_serial[1], psz_serial[2], - psz_serial[3], psz_serial[4], psz_serial[5], - psz_serial[6], psz_serial[7] ); - memcpy( psz_serial, psz_tmp, 16 ); - break; - } - } - - /* Get disk key, since some discs have got same title, manufacturing - * date and serial number, but different keys */ - if( dvdcss->b_scrambled ) - { - psz_key[0] = '-'; - for( i = 0; i < KEY_SIZE; i++ ) - { - sprintf( &psz_key[1+i*2], "%.2x", dvdcss->css.p_disc_key[i] ); - } - psz_key[1 + KEY_SIZE * 2] = '\0'; - } - else - { - psz_key[0] = 0; - } - - /* We have a disc name or ID, we can create the cache dir */ - i = sprintf( dvdcss->psz_cachefile, "%s", psz_cache ); -#if !defined( WIN32 ) || defined( SYS_CYGWIN ) - i_ret = mkdir( dvdcss->psz_cachefile, 0755 ); -#else - i_ret = mkdir( dvdcss->psz_cachefile ); -#endif - if( i_ret < 0 && errno != EEXIST ) - { - print_error( dvdcss, "failed creating cache directory" ); - dvdcss->psz_cachefile[0] = '\0'; - goto nocache; - } - - i += sprintf( dvdcss->psz_cachefile + i, "/%s-%s%s", psz_title, - psz_serial, psz_key ); -#if !defined( WIN32 ) || defined( SYS_CYGWIN ) - i_ret = mkdir( dvdcss->psz_cachefile, 0755 ); -#else - i_ret = mkdir( dvdcss->psz_cachefile ); -#endif - if( i_ret < 0 && errno != EEXIST ) - { - print_error( dvdcss, "failed creating cache subdirectory" ); - dvdcss->psz_cachefile[0] = '\0'; - goto nocache; - } - i += sprintf( dvdcss->psz_cachefile + i, "/"); - - /* Pointer to the filename we will use. */ - dvdcss->psz_block = dvdcss->psz_cachefile + i; - - sprintf( psz_debug, "using CSS key cache dir: %s", - dvdcss->psz_cachefile ); - print_debug( dvdcss, psz_debug ); - } - nocache: - -#ifndef WIN32 - if( psz_raw_device != NULL ) - { - _dvdcss_raw_open( dvdcss, psz_raw_device ); - } -#endif - - /* Seek at the beginning, just for safety. */ - dvdcss->pf_seek( dvdcss, 0 ); - - return dvdcss; -} - -/** - * \brief Return a string containing the latest error that occurred in the - * given \e libdvdcss instance. - * - * \param dvdcss a \e libdvdcss instance. - * \return a null-terminated string containing the latest error message. - * - * This function returns a constant string containing the latest error that - * occurred in \e libdvdcss. It can be used to format error messages at your - * convenience in your application. - */ -LIBDVDCSS_EXPORT char * dvdcss_error ( dvdcss_t dvdcss ) -{ - return dvdcss->psz_error; -} - -/** - * \brief Seek in the disc and change the current key if requested. - * - * \param dvdcss a \e libdvdcss instance. - * \param i_blocks an absolute block offset to seek to. - * \param i_flags #DVDCSS_NOFLAGS, optionally ored with one of #DVDCSS_SEEK_KEY - * or #DVDCSS_SEEK_MPEG. - * \return the new position in blocks, or a negative value in case an error - * happened. - * - * This function seeks to the requested position, in logical blocks. - * - * You typically set \p i_flags to #DVDCSS_NOFLAGS when seeking in a .IFO. - * - * If #DVDCSS_SEEK_MPEG is specified in \p i_flags and if \e libdvdcss finds it - * reasonable to do so (ie, if the dvdcss method is not "title"), the current - * title key will be checked and a new one will be calculated if necessary. - * This flag is typically used when reading data from a VOB. - * - * If #DVDCSS_SEEK_KEY is specified, the title key will be always checked, - * even with the "title" method. This is equivalent to using the now - * deprecated dvdcss_title() call. This flag is typically used when seeking - * in a new title. - */ -LIBDVDCSS_EXPORT int dvdcss_seek ( dvdcss_t dvdcss, int i_blocks, int i_flags ) -{ - /* title cracking method is too slow to be used at each seek */ - if( ( ( i_flags & DVDCSS_SEEK_MPEG ) - && ( dvdcss->i_method != DVDCSS_METHOD_TITLE ) ) - || ( i_flags & DVDCSS_SEEK_KEY ) ) - { - /* check the title key */ - if( _dvdcss_title( dvdcss, i_blocks ) ) - { - return -1; - } - } - - return dvdcss->pf_seek( dvdcss, i_blocks ); -} - -/** - * \brief Read from the disc and decrypt data if requested. - * - * \param dvdcss a \e libdvdcss instance. - * \param p_buffer a buffer that will contain the data read from the disc. - * \param i_blocks the amount of blocks to read. - * \param i_flags #DVDCSS_NOFLAGS, optionally ored with #DVDCSS_READ_DECRYPT. - * \return the amount of blocks read, or a negative value in case an - * error happened. - * - * This function reads \p i_blocks logical blocks from the DVD. - * - * You typically set \p i_flags to #DVDCSS_NOFLAGS when reading data from a - * .IFO file on the DVD. - * - * If #DVDCSS_READ_DECRYPT is specified in \p i_flags, dvdcss_read() will - * automatically decrypt scrambled sectors. This flag is typically used when - * reading data from a .VOB file on the DVD. It has no effect on unscrambled - * discs or unscrambled sectors, and can be safely used on those. - * - * \warning dvdcss_read() expects to be able to write \p i_blocks * - * #DVDCSS_BLOCK_SIZE bytes in \p p_buffer. - */ -LIBDVDCSS_EXPORT int dvdcss_read ( dvdcss_t dvdcss, void *p_buffer, - int i_blocks, - int i_flags ) -{ - int i_ret, i_index; - - i_ret = dvdcss->pf_read( dvdcss, p_buffer, i_blocks ); - - if( i_ret <= 0 - || !dvdcss->b_scrambled - || !(i_flags & DVDCSS_READ_DECRYPT) ) - { - return i_ret; - } - - if( ! memcmp( dvdcss->css.p_title_key, "\0\0\0\0\0", 5 ) ) - { - /* For what we believe is an unencrypted title, - * check that there are no encrypted blocks */ - for( i_index = i_ret; i_index; i_index-- ) - { - if( ((uint8_t*)p_buffer)[0x14] & 0x30 ) - { - print_error( dvdcss, "no key but found encrypted block" ); - /* Only return the initial range of unscrambled blocks? */ - /* or fail completely? return 0; */ - break; - } - p_buffer = (void *) ((uint8_t *)p_buffer + DVDCSS_BLOCK_SIZE); - } - } - else - { - /* Decrypt the blocks we managed to read */ - for( i_index = i_ret; i_index; i_index-- ) - { - _dvdcss_unscramble( dvdcss->css.p_title_key, p_buffer ); - ((uint8_t*)p_buffer)[0x14] &= 0x8f; - p_buffer = (void *) ((uint8_t *)p_buffer + DVDCSS_BLOCK_SIZE); - } - } - - return i_ret; -} - -/** - * \brief Read from the disc into multiple buffers and decrypt data if - * requested. - * - * \param dvdcss a \e libdvdcss instance. - * \param p_iovec a pointer to an array of iovec structures that will contain - * the data read from the disc. - * \param i_blocks the amount of blocks to read. - * \param i_flags #DVDCSS_NOFLAGS, optionally ored with #DVDCSS_READ_DECRYPT. - * \return the amount of blocks read, or a negative value in case an - * error happened. - * - * This function reads \p i_blocks logical blocks from the DVD and writes them - * to an array of iovec structures. - * - * You typically set \p i_flags to #DVDCSS_NOFLAGS when reading data from a - * .IFO file on the DVD. - * - * If #DVDCSS_READ_DECRYPT is specified in \p i_flags, dvdcss_readv() will - * automatically decrypt scrambled sectors. This flag is typically used when - * reading data from a .VOB file on the DVD. It has no effect on unscrambled - * discs or unscrambled sectors, and can be safely used on those. - * - * \warning dvdcss_readv() expects to be able to write \p i_blocks * - * #DVDCSS_BLOCK_SIZE bytes in the buffers pointed by \p p_iovec. - * Moreover, all iov_len members of the iovec structures should be - * multiples of #DVDCSS_BLOCK_SIZE. - */ -LIBDVDCSS_EXPORT int dvdcss_readv ( dvdcss_t dvdcss, void *p_iovec, - int i_blocks, - int i_flags ) -{ - struct iovec *_p_iovec = (struct iovec *)p_iovec; - int i_ret, i_index; - void *iov_base; - size_t iov_len; - - i_ret = dvdcss->pf_readv( dvdcss, _p_iovec, i_blocks ); - - if( i_ret <= 0 - || !dvdcss->b_scrambled - || !(i_flags & DVDCSS_READ_DECRYPT) ) - { - return i_ret; - } - - /* Initialize loop for decryption */ - iov_base = _p_iovec->iov_base; - iov_len = _p_iovec->iov_len; - - /* Decrypt the blocks we managed to read */ - for( i_index = i_ret; i_index; i_index-- ) - { - /* Check that iov_len is a multiple of 2048 */ - if( iov_len & 0x7ff ) - { - return -1; - } - - while( iov_len == 0 ) - { - _p_iovec++; - iov_base = _p_iovec->iov_base; - iov_len = _p_iovec->iov_len; - } - - _dvdcss_unscramble( dvdcss->css.p_title_key, iov_base ); - ((uint8_t*)iov_base)[0x14] &= 0x8f; - - iov_base = (void *) ((uint8_t*)iov_base + DVDCSS_BLOCK_SIZE); - iov_len -= DVDCSS_BLOCK_SIZE; - } - - return i_ret; -} - -/** - * \brief Close the DVD and clean up the library. - * - * \param dvdcss a \e libdvdcss instance. - * \return zero in case of success, a negative value otherwise. - * - * This function closes the DVD device and frees all the memory allocated - * by \e libdvdcss. On return, the #dvdcss_t is invalidated and may not be - * used again. - */ -LIBDVDCSS_EXPORT int dvdcss_close ( dvdcss_t dvdcss ) -{ - dvd_title_t *p_title; - int i_ret; - - /* Free our list of keys */ - p_title = dvdcss->p_titles; - while( p_title ) - { - dvd_title_t *p_tmptitle = p_title->p_next; - free( p_title ); - p_title = p_tmptitle; - } - - i_ret = _dvdcss_close( dvdcss ); - - if( i_ret < 0 ) - { - return i_ret; - } - - free( dvdcss->psz_device ); - free( dvdcss ); - - return 0; -} - -/* - * Deprecated. See dvdcss_seek(). - */ -#undef dvdcss_title -LIBDVDCSS_EXPORT int dvdcss_title ( dvdcss_t dvdcss, int i_block ) -{ - return _dvdcss_title( dvdcss, i_block ); -} - -/** - * \brief Return 1 if the DVD is scrambled, 0 otherwise. - * - * \param dvdcss a \e libdvdcss instance. - * \return 1 if the DVD is scrambled, 0 otherwise. - * - * This function returns whether the DVD is scrambled. - */ -LIBDVDCSS_EXPORT int dvdcss_is_scrambled ( dvdcss_t dvdcss ) -{ - return dvdcss->b_scrambled; -} - diff --git a/libdvdcss/libdvdcss.h b/libdvdcss/libdvdcss.h deleted file mode 100644 index 80f78c3..0000000 --- a/libdvdcss/libdvdcss.h +++ /dev/null @@ -1,104 +0,0 @@ -/***************************************************************************** - * libdvdcss.h: private DVD reading library data - ***************************************************************************** - * Copyright (C) 1998-2001 VideoLAN - * $Id$ - * - * Authors: Stéphane Borel - * Sam Hocevar - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. - *****************************************************************************/ - -struct iovec; - -/***************************************************************************** - * The libdvdcss structure - *****************************************************************************/ -struct dvdcss_s -{ - /* File descriptor */ - char * psz_device; - int i_fd; - int i_read_fd; - int i_pos; - - /* File handling */ - int ( * pf_seek ) ( dvdcss_t, int ); - int ( * pf_read ) ( dvdcss_t, void *, int ); - int ( * pf_readv ) ( dvdcss_t, struct iovec *, int ); - - /* Decryption stuff */ - int i_method; - css_t css; - int b_ioctls; - int b_scrambled; - dvd_title_t *p_titles; - - /* Key cache directory and pointer to the filename */ - char psz_cachefile[PATH_MAX]; - char * psz_block; - - /* Error management */ - char * psz_error; - int b_errors; - int b_debug; - -#ifdef WIN32 - int b_file; - char * p_readv_buffer; - int i_readv_buf_size; -#endif - -#ifndef WIN32 - int i_raw_fd; -#endif -}; - -/***************************************************************************** - * libdvdcss method: used like init flags - *****************************************************************************/ -#define DVDCSS_METHOD_KEY 0 -#define DVDCSS_METHOD_DISC 1 -#define DVDCSS_METHOD_TITLE 2 - -/***************************************************************************** - * Functions used across the library - *****************************************************************************/ -#define print_error(dvdcss,msg) _print_error(dvdcss,msg) -#if defined( _MSC_VER ) -#include -__forceinline void print_debug(dvdcss_t dvdcss, const char *msg,...) -{ - va_list args; - - fprintf( stderr, "libdvdcss debug: " ); - va_start( args, msg ); - vfprintf( stderr, msg, args ); - va_end( args ); - fprintf( stderr, "\n" ); -} -#else -#define print_debug(dvdcss,msg,args...) \ - if( dvdcss->b_debug ) \ - { \ - fprintf( stderr, "libdvdcss debug: " ); \ - fprintf( stderr, msg, ##args ); \ - fprintf( stderr, "\n" ); \ - } -#endif - -void _print_error ( dvdcss_t, char * ); -