Merge tag 'n0.5.10' of /tmp/ffmpeg into ap

(Conflicts resolved exactly how jkardatzke did it separately, so the
resulting tree is identical.)

There are quite a few divergences between our tree and upstream n0.5.10 that
don't look intentional (especially in documentation files as opposed to
code).  To reduce merge conflicts in the future, it would be helpful to
first minimize the spurious differences before attemping a merge.  You can
go through them like this:

   git checkout -p origin/upstream

(where 'origin' is the name of the git server you're using).  git will go
through each place we differ from upstream and ask if you want to revert it.
You can pick the parts you want to revert and commit the result.  git will
understand the result and avoid conflicts in future merges automatically.

Note that the 0.5.x branch of ffmpeg has also diverged from mainstream
development.  To merge the next 0.5.x release:

	git checkout origin/upstream
	git fetch git://source.ffmpeg.org/ffmpeg.git n0.5.x
	git merge FETCH_HEAD
	  # should be no conflicts
	git push origin HEAD:upstream

	git checkout master
	git merge upstream
	  # resolve conflicts
	git commit
	git push origin HEAD:refs/for/master

To switch to the mainline branch is slightly different since ffmpeg itself
has conflicts between 0.5.x and mainline.  We can assume everything in 0.5.x
is already in their mainline, though, so:
	git checkout origin/upstream
	git fetch git://source.ffmpeg.org/ffmpeg.git HEAD
	git merge -s theirs FETCH_HEAD
	  # should be no conflicts since "-s theirs" always picks
	  # the new upstream version
	git push origin HEAD:upstream

	...then 'git checkout master' etc as above.

(Leaving these notes here in the commit log for the benefit of whoever
searches for it when doing the next merge :))

* tag 'n0.5.10' of /tmp/ffmpeg:
  update for 0.5.10
  wmv1: check that the input buffer is large enough
  truemotion1: Check index, fix out of array read
  Release notes for 0.5.9
  ...

Change-Id: If650704cafe58abb119cffc52dab093e42cbf5af
diff --git a/COPYING.GPLv2 b/COPYING.GPL
old mode 100644
new mode 100755
similarity index 100%
rename from COPYING.GPLv2
rename to COPYING.GPL
diff --git a/COPYING.GPLv3 b/COPYING.GPLv3
deleted file mode 100644
index 94a9ed0..0000000
--- a/COPYING.GPLv3
+++ /dev/null
@@ -1,674 +0,0 @@
-                    GNU GENERAL PUBLIC LICENSE
-                       Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-                            Preamble
-
-  The GNU General Public License is a free, copyleft license for
-software and other kinds of works.
-
-  The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works.  By contrast,
-the GNU General Public License is intended to guarantee your freedom to
-share and change all versions of a program--to make sure it remains free
-software for all its users.  We, the Free Software Foundation, use the
-GNU General Public License for most of our software; it applies also to
-any other work released this way by its authors.  You can apply it to
-your programs, too.
-
-  When we speak of free software, we are referring to freedom, not
-price.  Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-them if you wish), that you receive source code or can get it if you
-want it, that you can change the software or use pieces of it in new
-free programs, and that you know you can do these things.
-
-  To protect your rights, we need to prevent others from denying you
-these rights or asking you to surrender the rights.  Therefore, you have
-certain responsibilities if you distribute copies of the software, or if
-you modify it: responsibilities to respect the freedom of others.
-
-  For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must pass on to the recipients the same
-freedoms that you received.  You must make sure that they, too, receive
-or can get the source code.  And you must show them these terms so they
-know their rights.
-
-  Developers that use the GNU GPL protect your rights with two steps:
-(1) assert copyright on the software, and (2) offer you this License
-giving you legal permission to copy, distribute and/or modify it.
-
-  For the developers' and authors' protection, the GPL clearly explains
-that there is no warranty for this free software.  For both users' and
-authors' sake, the GPL requires that modified versions be marked as
-changed, so that their problems will not be attributed erroneously to
-authors of previous versions.
-
-  Some devices are designed to deny users access to install or run
-modified versions of the software inside them, although the manufacturer
-can do so.  This is fundamentally incompatible with the aim of
-protecting users' freedom to change the software.  The systematic
-pattern of such abuse occurs in the area of products for individuals to
-use, which is precisely where it is most unacceptable.  Therefore, we
-have designed this version of the GPL to prohibit the practice for those
-products.  If such problems arise substantially in other domains, we
-stand ready to extend this provision to those domains in future versions
-of the GPL, as needed to protect the freedom of users.
-
-  Finally, every program is threatened constantly by software patents.
-States should not allow patents to restrict development and use of
-software on general-purpose computers, but in those that do, we wish to
-avoid the special danger that patents applied to a free program could
-make it effectively proprietary.  To prevent this, the GPL assures that
-patents cannot be used to render the program non-free.
-
-  The precise terms and conditions for copying, distribution and
-modification follow.
-
-                       TERMS AND CONDITIONS
-
-  0. Definitions.
-
-  "This License" refers to version 3 of the GNU General Public License.
-
-  "Copyright" also means copyright-like laws that apply to other kinds of
-works, such as semiconductor masks.
-
-  "The Program" refers to any copyrightable work licensed under this
-License.  Each licensee is addressed as "you".  "Licensees" and
-"recipients" may be individuals or organizations.
-
-  To "modify" a work means to copy from or adapt all or part of the work
-in a fashion requiring copyright permission, other than the making of an
-exact copy.  The resulting work is called a "modified version" of the
-earlier work or a work "based on" the earlier work.
-
-  A "covered work" means either the unmodified Program or a work based
-on the Program.
-
-  To "propagate" a work means to do anything with it that, without
-permission, would make you directly or secondarily liable for
-infringement under applicable copyright law, except executing it on a
-computer or modifying a private copy.  Propagation includes copying,
-distribution (with or without modification), making available to the
-public, and in some countries other activities as well.
-
-  To "convey" a work means any kind of propagation that enables other
-parties to make or receive copies.  Mere interaction with a user through
-a computer network, with no transfer of a copy, is not conveying.
-
-  An interactive user interface displays "Appropriate Legal Notices"
-to the extent that it includes a convenient and prominently visible
-feature that (1) displays an appropriate copyright notice, and (2)
-tells the user that there is no warranty for the work (except to the
-extent that warranties are provided), that licensees may convey the
-work under this License, and how to view a copy of this License.  If
-the interface presents a list of user commands or options, such as a
-menu, a prominent item in the list meets this criterion.
-
-  1. Source Code.
-
-  The "source code" for a work means the preferred form of the work
-for making modifications to it.  "Object code" means any non-source
-form of a work.
-
-  A "Standard Interface" means an interface that either is an official
-standard defined by a recognized standards body, or, in the case of
-interfaces specified for a particular programming language, one that
-is widely used among developers working in that language.
-
-  The "System Libraries" of an executable work include anything, other
-than the work as a whole, that (a) is included in the normal form of
-packaging a Major Component, but which is not part of that Major
-Component, and (b) serves only to enable use of the work with that
-Major Component, or to implement a Standard Interface for which an
-implementation is available to the public in source code form.  A
-"Major Component", in this context, means a major essential component
-(kernel, window system, and so on) of the specific operating system
-(if any) on which the executable work runs, or a compiler used to
-produce the work, or an object code interpreter used to run it.
-
-  The "Corresponding Source" for a work in object code form means all
-the source code needed to generate, install, and (for an executable
-work) run the object code and to modify the work, including scripts to
-control those activities.  However, it does not include the work's
-System Libraries, or general-purpose tools or generally available free
-programs which are used unmodified in performing those activities but
-which are not part of the work.  For example, Corresponding Source
-includes interface definition files associated with source files for
-the work, and the source code for shared libraries and dynamically
-linked subprograms that the work is specifically designed to require,
-such as by intimate data communication or control flow between those
-subprograms and other parts of the work.
-
-  The Corresponding Source need not include anything that users
-can regenerate automatically from other parts of the Corresponding
-Source.
-
-  The Corresponding Source for a work in source code form is that
-same work.
-
-  2. Basic Permissions.
-
-  All rights granted under this License are granted for the term of
-copyright on the Program, and are irrevocable provided the stated
-conditions are met.  This License explicitly affirms your unlimited
-permission to run the unmodified Program.  The output from running a
-covered work is covered by this License only if the output, given its
-content, constitutes a covered work.  This License acknowledges your
-rights of fair use or other equivalent, as provided by copyright law.
-
-  You may make, run and propagate covered works that you do not
-convey, without conditions so long as your license otherwise remains
-in force.  You may convey covered works to others for the sole purpose
-of having them make modifications exclusively for you, or provide you
-with facilities for running those works, provided that you comply with
-the terms of this License in conveying all material for which you do
-not control copyright.  Those thus making or running the covered works
-for you must do so exclusively on your behalf, under your direction
-and control, on terms that prohibit them from making any copies of
-your copyrighted material outside their relationship with you.
-
-  Conveying under any other circumstances is permitted solely under
-the conditions stated below.  Sublicensing is not allowed; section 10
-makes it unnecessary.
-
-  3. Protecting Users' Legal Rights From Anti-Circumvention Law.
-
-  No covered work shall be deemed part of an effective technological
-measure under any applicable law fulfilling obligations under article
-11 of the WIPO copyright treaty adopted on 20 December 1996, or
-similar laws prohibiting or restricting circumvention of such
-measures.
-
-  When you convey a covered work, you waive any legal power to forbid
-circumvention of technological measures to the extent such circumvention
-is effected by exercising rights under this License with respect to
-the covered work, and you disclaim any intention to limit operation or
-modification of the work as a means of enforcing, against the work's
-users, your or third parties' legal rights to forbid circumvention of
-technological measures.
-
-  4. Conveying Verbatim Copies.
-
-  You may convey verbatim copies of the Program's source code as you
-receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice;
-keep intact all notices stating that this License and any
-non-permissive terms added in accord with section 7 apply to the code;
-keep intact all notices of the absence of any warranty; and give all
-recipients a copy of this License along with the Program.
-
-  You may charge any price or no price for each copy that you convey,
-and you may offer support or warranty protection for a fee.
-
-  5. Conveying Modified Source Versions.
-
-  You may convey a work based on the Program, or the modifications to
-produce it from the Program, in the form of source code under the
-terms of section 4, provided that you also meet all of these conditions:
-
-    a) The work must carry prominent notices stating that you modified
-    it, and giving a relevant date.
-
-    b) The work must carry prominent notices stating that it is
-    released under this License and any conditions added under section
-    7.  This requirement modifies the requirement in section 4 to
-    "keep intact all notices".
-
-    c) You must license the entire work, as a whole, under this
-    License to anyone who comes into possession of a copy.  This
-    License will therefore apply, along with any applicable section 7
-    additional terms, to the whole of the work, and all its parts,
-    regardless of how they are packaged.  This License gives no
-    permission to license the work in any other way, but it does not
-    invalidate such permission if you have separately received it.
-
-    d) If the work has interactive user interfaces, each must display
-    Appropriate Legal Notices; however, if the Program has interactive
-    interfaces that do not display Appropriate Legal Notices, your
-    work need not make them do so.
-
-  A compilation of a covered work with other separate and independent
-works, which are not by their nature extensions of the covered work,
-and which are not combined with it such as to form a larger program,
-in or on a volume of a storage or distribution medium, is called an
-"aggregate" if the compilation and its resulting copyright are not
-used to limit the access or legal rights of the compilation's users
-beyond what the individual works permit.  Inclusion of a covered work
-in an aggregate does not cause this License to apply to the other
-parts of the aggregate.
-
-  6. Conveying Non-Source Forms.
-
-  You may convey a covered work in object code form under the terms
-of sections 4 and 5, provided that you also convey the
-machine-readable Corresponding Source under the terms of this License,
-in one of these ways:
-
-    a) Convey the object code in, or embodied in, a physical product
-    (including a physical distribution medium), accompanied by the
-    Corresponding Source fixed on a durable physical medium
-    customarily used for software interchange.
-
-    b) Convey the object code in, or embodied in, a physical product
-    (including a physical distribution medium), accompanied by a
-    written offer, valid for at least three years and valid for as
-    long as you offer spare parts or customer support for that product
-    model, to give anyone who possesses the object code either (1) a
-    copy of the Corresponding Source for all the software in the
-    product that is covered by this License, on a durable physical
-    medium customarily used for software interchange, for a price no
-    more than your reasonable cost of physically performing this
-    conveying of source, or (2) access to copy the
-    Corresponding Source from a network server at no charge.
-
-    c) Convey individual copies of the object code with a copy of the
-    written offer to provide the Corresponding Source.  This
-    alternative is allowed only occasionally and noncommercially, and
-    only if you received the object code with such an offer, in accord
-    with subsection 6b.
-
-    d) Convey the object code by offering access from a designated
-    place (gratis or for a charge), and offer equivalent access to the
-    Corresponding Source in the same way through the same place at no
-    further charge.  You need not require recipients to copy the
-    Corresponding Source along with the object code.  If the place to
-    copy the object code is a network server, the Corresponding Source
-    may be on a different server (operated by you or a third party)
-    that supports equivalent copying facilities, provided you maintain
-    clear directions next to the object code saying where to find the
-    Corresponding Source.  Regardless of what server hosts the
-    Corresponding Source, you remain obligated to ensure that it is
-    available for as long as needed to satisfy these requirements.
-
-    e) Convey the object code using peer-to-peer transmission, provided
-    you inform other peers where the object code and Corresponding
-    Source of the work are being offered to the general public at no
-    charge under subsection 6d.
-
-  A separable portion of the object code, whose source code is excluded
-from the Corresponding Source as a System Library, need not be
-included in conveying the object code work.
-
-  A "User Product" is either (1) a "consumer product", which means any
-tangible personal property which is normally used for personal, family,
-or household purposes, or (2) anything designed or sold for incorporation
-into a dwelling.  In determining whether a product is a consumer product,
-doubtful cases shall be resolved in favor of coverage.  For a particular
-product received by a particular user, "normally used" refers to a
-typical or common use of that class of product, regardless of the status
-of the particular user or of the way in which the particular user
-actually uses, or expects or is expected to use, the product.  A product
-is a consumer product regardless of whether the product has substantial
-commercial, industrial or non-consumer uses, unless such uses represent
-the only significant mode of use of the product.
-
-  "Installation Information" for a User Product means any methods,
-procedures, authorization keys, or other information required to install
-and execute modified versions of a covered work in that User Product from
-a modified version of its Corresponding Source.  The information must
-suffice to ensure that the continued functioning of the modified object
-code is in no case prevented or interfered with solely because
-modification has been made.
-
-  If you convey an object code work under this section in, or with, or
-specifically for use in, a User Product, and the conveying occurs as
-part of a transaction in which the right of possession and use of the
-User Product is transferred to the recipient in perpetuity or for a
-fixed term (regardless of how the transaction is characterized), the
-Corresponding Source conveyed under this section must be accompanied
-by the Installation Information.  But this requirement does not apply
-if neither you nor any third party retains the ability to install
-modified object code on the User Product (for example, the work has
-been installed in ROM).
-
-  The requirement to provide Installation Information does not include a
-requirement to continue to provide support service, warranty, or updates
-for a work that has been modified or installed by the recipient, or for
-the User Product in which it has been modified or installed.  Access to a
-network may be denied when the modification itself materially and
-adversely affects the operation of the network or violates the rules and
-protocols for communication across the network.
-
-  Corresponding Source conveyed, and Installation Information provided,
-in accord with this section must be in a format that is publicly
-documented (and with an implementation available to the public in
-source code form), and must require no special password or key for
-unpacking, reading or copying.
-
-  7. Additional Terms.
-
-  "Additional permissions" are terms that supplement the terms of this
-License by making exceptions from one or more of its conditions.
-Additional permissions that are applicable to the entire Program shall
-be treated as though they were included in this License, to the extent
-that they are valid under applicable law.  If additional permissions
-apply only to part of the Program, that part may be used separately
-under those permissions, but the entire Program remains governed by
-this License without regard to the additional permissions.
-
-  When you convey a copy of a covered work, you may at your option
-remove any additional permissions from that copy, or from any part of
-it.  (Additional permissions may be written to require their own
-removal in certain cases when you modify the work.)  You may place
-additional permissions on material, added by you to a covered work,
-for which you have or can give appropriate copyright permission.
-
-  Notwithstanding any other provision of this License, for material you
-add to a covered work, you may (if authorized by the copyright holders of
-that material) supplement the terms of this License with terms:
-
-    a) Disclaiming warranty or limiting liability differently from the
-    terms of sections 15 and 16 of this License; or
-
-    b) Requiring preservation of specified reasonable legal notices or
-    author attributions in that material or in the Appropriate Legal
-    Notices displayed by works containing it; or
-
-    c) Prohibiting misrepresentation of the origin of that material, or
-    requiring that modified versions of such material be marked in
-    reasonable ways as different from the original version; or
-
-    d) Limiting the use for publicity purposes of names of licensors or
-    authors of the material; or
-
-    e) Declining to grant rights under trademark law for use of some
-    trade names, trademarks, or service marks; or
-
-    f) Requiring indemnification of licensors and authors of that
-    material by anyone who conveys the material (or modified versions of
-    it) with contractual assumptions of liability to the recipient, for
-    any liability that these contractual assumptions directly impose on
-    those licensors and authors.
-
-  All other non-permissive additional terms are considered "further
-restrictions" within the meaning of section 10.  If the Program as you
-received it, or any part of it, contains a notice stating that it is
-governed by this License along with a term that is a further
-restriction, you may remove that term.  If a license document contains
-a further restriction but permits relicensing or conveying under this
-License, you may add to a covered work material governed by the terms
-of that license document, provided that the further restriction does
-not survive such relicensing or conveying.
-
-  If you add terms to a covered work in accord with this section, you
-must place, in the relevant source files, a statement of the
-additional terms that apply to those files, or a notice indicating
-where to find the applicable terms.
-
-  Additional terms, permissive or non-permissive, may be stated in the
-form of a separately written license, or stated as exceptions;
-the above requirements apply either way.
-
-  8. Termination.
-
-  You may not propagate or modify a covered work except as expressly
-provided under this License.  Any attempt otherwise to propagate or
-modify it is void, and will automatically terminate your rights under
-this License (including any patent licenses granted under the third
-paragraph of section 11).
-
-  However, if you cease all violation of this License, then your
-license from a particular copyright holder is reinstated (a)
-provisionally, unless and until the copyright holder explicitly and
-finally terminates your license, and (b) permanently, if the copyright
-holder fails to notify you of the violation by some reasonable means
-prior to 60 days after the cessation.
-
-  Moreover, your license from a particular copyright holder is
-reinstated permanently if the copyright holder notifies you of the
-violation by some reasonable means, this is the first time you have
-received notice of violation of this License (for any work) from that
-copyright holder, and you cure the violation prior to 30 days after
-your receipt of the notice.
-
-  Termination of your rights under this section does not terminate the
-licenses of parties who have received copies or rights from you under
-this License.  If your rights have been terminated and not permanently
-reinstated, you do not qualify to receive new licenses for the same
-material under section 10.
-
-  9. Acceptance Not Required for Having Copies.
-
-  You are not required to accept this License in order to receive or
-run a copy of the Program.  Ancillary propagation of a covered work
-occurring solely as a consequence of using peer-to-peer transmission
-to receive a copy likewise does not require acceptance.  However,
-nothing other than this License grants you permission to propagate or
-modify any covered work.  These actions infringe copyright if you do
-not accept this License.  Therefore, by modifying or propagating a
-covered work, you indicate your acceptance of this License to do so.
-
-  10. Automatic Licensing of Downstream Recipients.
-
-  Each time you convey a covered work, the recipient automatically
-receives a license from the original licensors, to run, modify and
-propagate that work, subject to this License.  You are not responsible
-for enforcing compliance by third parties with this License.
-
-  An "entity transaction" is a transaction transferring control of an
-organization, or substantially all assets of one, or subdividing an
-organization, or merging organizations.  If propagation of a covered
-work results from an entity transaction, each party to that
-transaction who receives a copy of the work also receives whatever
-licenses to the work the party's predecessor in interest had or could
-give under the previous paragraph, plus a right to possession of the
-Corresponding Source of the work from the predecessor in interest, if
-the predecessor has it or can get it with reasonable efforts.
-
-  You may not impose any further restrictions on the exercise of the
-rights granted or affirmed under this License.  For example, you may
-not impose a license fee, royalty, or other charge for exercise of
-rights granted under this License, and you may not initiate litigation
-(including a cross-claim or counterclaim in a lawsuit) alleging that
-any patent claim is infringed by making, using, selling, offering for
-sale, or importing the Program or any portion of it.
-
-  11. Patents.
-
-  A "contributor" is a copyright holder who authorizes use under this
-License of the Program or a work on which the Program is based.  The
-work thus licensed is called the contributor's "contributor version".
-
-  A contributor's "essential patent claims" are all patent claims
-owned or controlled by the contributor, whether already acquired or
-hereafter acquired, that would be infringed by some manner, permitted
-by this License, of making, using, or selling its contributor version,
-but do not include claims that would be infringed only as a
-consequence of further modification of the contributor version.  For
-purposes of this definition, "control" includes the right to grant
-patent sublicenses in a manner consistent with the requirements of
-this License.
-
-  Each contributor grants you a non-exclusive, worldwide, royalty-free
-patent license under the contributor's essential patent claims, to
-make, use, sell, offer for sale, import and otherwise run, modify and
-propagate the contents of its contributor version.
-
-  In the following three paragraphs, a "patent license" is any express
-agreement or commitment, however denominated, not to enforce a patent
-(such as an express permission to practice a patent or covenant not to
-sue for patent infringement).  To "grant" such a patent license to a
-party means to make such an agreement or commitment not to enforce a
-patent against the party.
-
-  If you convey a covered work, knowingly relying on a patent license,
-and the Corresponding Source of the work is not available for anyone
-to copy, free of charge and under the terms of this License, through a
-publicly available network server or other readily accessible means,
-then you must either (1) cause the Corresponding Source to be so
-available, or (2) arrange to deprive yourself of the benefit of the
-patent license for this particular work, or (3) arrange, in a manner
-consistent with the requirements of this License, to extend the patent
-license to downstream recipients.  "Knowingly relying" means you have
-actual knowledge that, but for the patent license, your conveying the
-covered work in a country, or your recipient's use of the covered work
-in a country, would infringe one or more identifiable patents in that
-country that you have reason to believe are valid.
-
-  If, pursuant to or in connection with a single transaction or
-arrangement, you convey, or propagate by procuring conveyance of, a
-covered work, and grant a patent license to some of the parties
-receiving the covered work authorizing them to use, propagate, modify
-or convey a specific copy of the covered work, then the patent license
-you grant is automatically extended to all recipients of the covered
-work and works based on it.
-
-  A patent license is "discriminatory" if it does not include within
-the scope of its coverage, prohibits the exercise of, or is
-conditioned on the non-exercise of one or more of the rights that are
-specifically granted under this License.  You may not convey a covered
-work if you are a party to an arrangement with a third party that is
-in the business of distributing software, under which you make payment
-to the third party based on the extent of your activity of conveying
-the work, and under which the third party grants, to any of the
-parties who would receive the covered work from you, a discriminatory
-patent license (a) in connection with copies of the covered work
-conveyed by you (or copies made from those copies), or (b) primarily
-for and in connection with specific products or compilations that
-contain the covered work, unless you entered into that arrangement,
-or that patent license was granted, prior to 28 March 2007.
-
-  Nothing in this License shall be construed as excluding or limiting
-any implied license or other defenses to infringement that may
-otherwise be available to you under applicable patent law.
-
-  12. No Surrender of Others' Freedom.
-
-  If conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License.  If you cannot convey a
-covered work so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you may
-not convey it at all.  For example, if you agree to terms that obligate you
-to collect a royalty for further conveying from those to whom you convey
-the Program, the only way you could satisfy both those terms and this
-License would be to refrain entirely from conveying the Program.
-
-  13. Use with the GNU Affero General Public License.
-
-  Notwithstanding any other provision of this License, you have
-permission to link or combine any covered work with a work licensed
-under version 3 of the GNU Affero General Public License into a single
-combined work, and to convey the resulting work.  The terms of this
-License will continue to apply to the part which is the covered work,
-but the special requirements of the GNU Affero General Public License,
-section 13, concerning interaction through a network will apply to the
-combination as such.
-
-  14. Revised Versions of this License.
-
-  The Free Software Foundation may publish revised and/or new versions of
-the GNU General Public License from time to time.  Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-  Each version is given a distinguishing version number.  If the
-Program specifies that a certain numbered version of the GNU General
-Public License "or any later version" applies to it, you have the
-option of following the terms and conditions either of that numbered
-version or of any later version published by the Free Software
-Foundation.  If the Program does not specify a version number of the
-GNU General Public License, you may choose any version ever published
-by the Free Software Foundation.
-
-  If the Program specifies that a proxy can decide which future
-versions of the GNU General Public License can be used, that proxy's
-public statement of acceptance of a version permanently authorizes you
-to choose that version for the Program.
-
-  Later license versions may give you additional or different
-permissions.  However, no additional obligations are imposed on any
-author or copyright holder as a result of your choosing to follow a
-later version.
-
-  15. Disclaimer of Warranty.
-
-  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
-APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
-HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
-OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
-IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
-ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
-  16. Limitation of Liability.
-
-  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
-THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
-GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
-USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
-DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
-PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
-EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGES.
-
-  17. Interpretation of Sections 15 and 16.
-
-  If the disclaimer of warranty and limitation of liability provided
-above cannot be given local legal effect according to their terms,
-reviewing courts shall apply local law that most closely approximates
-an absolute waiver of all civil liability in connection with the
-Program, unless a warranty or assumption of liability accompanies a
-copy of the Program in return for a fee.
-
-                     END OF TERMS AND CONDITIONS
-
-            How to Apply These Terms to Your New Programs
-
-  If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
-  To do so, attach the following notices to the program.  It is safest
-to attach them to the start of each source file to most effectively
-state the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
-    <one line to give the program's name and a brief idea of what it does.>
-    Copyright (C) <year>  <name of author>
-
-    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 3 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, see <http://www.gnu.org/licenses/>.
-
-Also add information on how to contact you by electronic and paper mail.
-
-  If the program does terminal interaction, make it output a short
-notice like this when it starts in an interactive mode:
-
-    <program>  Copyright (C) <year>  <name of author>
-    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
-    This is free software, and you are welcome to redistribute it
-    under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License.  Of course, your program's commands
-might be different; for a GUI interface, you would use an "about box".
-
-  You should also get your employer (if you work as a programmer) or school,
-if any, to sign a "copyright disclaimer" for the program, if necessary.
-For more information on this, and how to apply and follow the GNU GPL, see
-<http://www.gnu.org/licenses/>.
-
-  The GNU General Public License does not permit incorporating your program
-into proprietary programs.  If your program is a subroutine library, you
-may consider it more useful to permit linking proprietary applications with
-the library.  If this is what you want to do, use the GNU Lesser General
-Public License instead of this License.  But first, please read
-<http://www.gnu.org/philosophy/why-not-lgpl.html>.
diff --git a/COPYING.LGPLv2.1 b/COPYING.LGPL
old mode 100644
new mode 100755
similarity index 100%
rename from COPYING.LGPLv2.1
rename to COPYING.LGPL
diff --git a/COPYING.LGPLv3 b/COPYING.LGPLv3
deleted file mode 100644
index 65c5ca8..0000000
--- a/COPYING.LGPLv3
+++ /dev/null
@@ -1,165 +0,0 @@
-                   GNU LESSER GENERAL PUBLIC LICENSE
-                       Version 3, 29 June 2007
-
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-
-  This version of the GNU Lesser General Public License incorporates
-the terms and conditions of version 3 of the GNU General Public
-License, supplemented by the additional permissions listed below.
-
-  0. Additional Definitions.
-
-  As used herein, "this License" refers to version 3 of the GNU Lesser
-General Public License, and the "GNU GPL" refers to version 3 of the GNU
-General Public License.
-
-  "The Library" refers to a covered work governed by this License,
-other than an Application or a Combined Work as defined below.
-
-  An "Application" is any work that makes use of an interface provided
-by the Library, but which is not otherwise based on the Library.
-Defining a subclass of a class defined by the Library is deemed a mode
-of using an interface provided by the Library.
-
-  A "Combined Work" is a work produced by combining or linking an
-Application with the Library.  The particular version of the Library
-with which the Combined Work was made is also called the "Linked
-Version".
-
-  The "Minimal Corresponding Source" for a Combined Work means the
-Corresponding Source for the Combined Work, excluding any source code
-for portions of the Combined Work that, considered in isolation, are
-based on the Application, and not on the Linked Version.
-
-  The "Corresponding Application Code" for a Combined Work means the
-object code and/or source code for the Application, including any data
-and utility programs needed for reproducing the Combined Work from the
-Application, but excluding the System Libraries of the Combined Work.
-
-  1. Exception to Section 3 of the GNU GPL.
-
-  You may convey a covered work under sections 3 and 4 of this License
-without being bound by section 3 of the GNU GPL.
-
-  2. Conveying Modified Versions.
-
-  If you modify a copy of the Library, and, in your modifications, a
-facility refers to a function or data to be supplied by an Application
-that uses the facility (other than as an argument passed when the
-facility is invoked), then you may convey a copy of the modified
-version:
-
-   a) under this License, provided that you make a good faith effort to
-   ensure that, in the event an Application does not supply the
-   function or data, the facility still operates, and performs
-   whatever part of its purpose remains meaningful, or
-
-   b) under the GNU GPL, with none of the additional permissions of
-   this License applicable to that copy.
-
-  3. Object Code Incorporating Material from Library Header Files.
-
-  The object code form of an Application may incorporate material from
-a header file that is part of the Library.  You may convey such object
-code under terms of your choice, provided that, if the incorporated
-material is not limited to numerical parameters, data structure
-layouts and accessors, or small macros, inline functions and templates
-(ten or fewer lines in length), you do both of the following:
-
-   a) Give prominent notice with each copy of the object code that the
-   Library is used in it and that the Library and its use are
-   covered by this License.
-
-   b) Accompany the object code with a copy of the GNU GPL and this license
-   document.
-
-  4. Combined Works.
-
-  You may convey a Combined Work under terms of your choice that,
-taken together, effectively do not restrict modification of the
-portions of the Library contained in the Combined Work and reverse
-engineering for debugging such modifications, if you also do each of
-the following:
-
-   a) Give prominent notice with each copy of the Combined Work that
-   the Library is used in it and that the Library and its use are
-   covered by this License.
-
-   b) Accompany the Combined Work with a copy of the GNU GPL and this license
-   document.
-
-   c) For a Combined Work that displays copyright notices during
-   execution, include the copyright notice for the Library among
-   these notices, as well as a reference directing the user to the
-   copies of the GNU GPL and this license document.
-
-   d) Do one of the following:
-
-       0) Convey the Minimal Corresponding Source under the terms of this
-       License, and the Corresponding Application Code in a form
-       suitable for, and under terms that permit, the user to
-       recombine or relink the Application with a modified version of
-       the Linked Version to produce a modified Combined Work, in the
-       manner specified by section 6 of the GNU GPL for conveying
-       Corresponding Source.
-
-       1) Use a suitable shared library mechanism for linking with the
-       Library.  A suitable mechanism is one that (a) uses at run time
-       a copy of the Library already present on the user's computer
-       system, and (b) will operate properly with a modified version
-       of the Library that is interface-compatible with the Linked
-       Version.
-
-   e) Provide Installation Information, but only if you would otherwise
-   be required to provide such information under section 6 of the
-   GNU GPL, and only to the extent that such information is
-   necessary to install and execute a modified version of the
-   Combined Work produced by recombining or relinking the
-   Application with a modified version of the Linked Version. (If
-   you use option 4d0, the Installation Information must accompany
-   the Minimal Corresponding Source and Corresponding Application
-   Code. If you use option 4d1, you must provide the Installation
-   Information in the manner specified by section 6 of the GNU GPL
-   for conveying Corresponding Source.)
-
-  5. Combined Libraries.
-
-  You may place library facilities that are a work based on the
-Library side by side in a single library together with other library
-facilities that are not Applications and are not covered by this
-License, and convey such a combined library under terms of your
-choice, if you do both of the following:
-
-   a) Accompany the combined library with a copy of the same work based
-   on the Library, uncombined with any other library facilities,
-   conveyed under the terms of this License.
-
-   b) Give prominent notice with the combined library that part of it
-   is a work based on the Library, and explaining where to find the
-   accompanying uncombined form of the same work.
-
-  6. Revised Versions of the GNU Lesser General Public License.
-
-  The Free Software Foundation may publish revised and/or new versions
-of the GNU Lesser General Public License from time to time. Such new
-versions will be similar in spirit to the present version, but may
-differ in detail to address new problems or concerns.
-
-  Each version is given a distinguishing version number. If the
-Library as you received it specifies that a certain numbered version
-of the GNU Lesser General Public License "or any later version"
-applies to it, you have the option of following the terms and
-conditions either of that published version or of any later version
-published by the Free Software Foundation. If the Library as you
-received it does not specify a version number of the GNU Lesser
-General Public License, you may choose any version of the GNU Lesser
-General Public License ever published by the Free Software Foundation.
-
-  If the Library as you received it specifies that a proxy can decide
-whether future versions of the GNU Lesser General Public License shall
-apply, that proxy's public statement of acceptance of any version is
-permanent authorization for you to choose that version for the
-Library.
diff --git a/CREDITS b/CREDITS
old mode 100644
new mode 100755
diff --git a/Changelog b/Changelog
index 3a66ab0..58b00db 100644
--- a/Changelog
+++ b/Changelog
@@ -1,127 +1,17 @@
-Entries are sorted chronologically from oldest to youngest within each release,
-releases are sorted from youngest to oldest.
+version <next>:
 
-
-version 0.5.9:
-- dpcm: ignore extra unpaired bytes in stereo streams (CVE-2011-3951)
-- h264: Add check for invalid chroma_format_idc (CVE-2012-0851)
-- adpcm: ADPCM Electronic Arts has always two channels (CVE-2012-0852)
-- kmvc: Check palsize (CVE-2011-3952)
-- qdm2: clip array indices returned by qdm2_get_vlc()
-- configure: properly check for mingw-w64 through installed headers
-- Replace every usage of -lvfw32 with what is particularly necessary for that case
-- mingw32: properly check if vfw capture is supported by the system headers
-- mingw32: merge checks for mingw-w64 and mingw32-runtime >= 3.15 into one
-- vfwcap: Include windows.h before vfw.h since the latter requires defines from the former
-- ea: check chunk_size for validity
-- eatqi: move "block" variable into context to ensure sufficient alignment for idct_put
-- tqi: Pass errors from the MB decoder
-- png: check bit depth for PAL8/Y400A pixel formats.
-
-
-version 0.5.8:
-
-- id3v2: fix skipping extended header in id3v2.4
-- nsvdec: Several bugfixes related to CVE-2011-3940
-- dv: check stype
-- dv: Fix null pointer dereference due to ach=0
-- dv: Fix small stack overread related to CVE-2011-3929 and CVE-2011-3936.
-- atrac3: Fix crash in tonal component decoding, fixes CVE-2012-0853
-- mjpegbdec: Fix overflow in SOS, fixes CVE-2011-3947
-- motionpixels: Clip YUV values after applying a gradient.
-- vqavideo: return error if image size is not a multiple of block size,
-  fixes CVE-2012-0947.
-
-
-version 0.5.7:
-- vorbis: An additional defense in the Vorbis codec. (CVE-2011-3895)
-- vorbisdec: Fix decoding bug with channel handling.
-- matroskadec: Fix a bug where a pointer was cached to an array that might
-  later move due to a realloc(). (CVE-2011-3893)
-- vorbis: Avoid some out-of-bounds reads. (CVE-2011-3893)
-- vp3: fix oob read for negative tokens and memleaks on error, (CVE-2011-3892)
-- vp3: fix streams with non-zero last coefficient.
-
-
-version 0.5.6:
-- svq1dec: call avcodec_set_dimensions() after dimensions changed. (NGS00148, CVE-2011-4579)
-- vmd: fix segfaults on corruped streams (CVE-2011-4364)
-- commits related to CVE-2011-4353:
-  - vp6: partially propagate huffman tree building errors during coeff model parsing and fix misspelling
-  - Plug some memory leaks in the VP6 decoder
-  - vp6: Reset the internal state when aborting key frames header parsing
-  - vp6: Fix illegal read.
-  - vp6: Fix illegal read.
-  - Fix out of bound reads in the QDM2 decoder.
-- commits related to CVE-2011-4351:
-  - Check for out of bound writes in the QDM2 decoder.
-  - qdm2: check output buffer size before decoding
-  - Fix qdm2 decoder packet handling to match the api
-
-
-version 0.5.5:
-
-- Fix memory (re)allocation in matroskadec.c (MSVR11-011/CVE-2011-3504)
-- Fix some crashes with invalid bitstreams in the CAVS decoder
-  (CVE-2011-3362, CVE-2011-3973, CVE-2011-3974)
-- Compilation fixes for gcc-4.6, testsuite now passes again
-- Detect and handle overreads in the MJPEG decoder.
-- multiple other security fixes.
-
-
-
-version 0.5.4:
-
-- Fix memory corruption in WMV parsing (addresses CVE-2010-3908)
-- Fix heap corruption crashes (addresses CVE-2011-0722)
-- Fix crashes in Vorbis decoding found by zzuf (addresses CVE-2010-4704)
-- Fix another crash in Vorbis decoding (addresses CVE-2011-0480, Chrome issue 68115)
-- Fix invalid reads in VC-1 decoding (related to CVE-2011-0723)
-- Do not attempt to decode APE file with no frames
-  (adresses http://packetstorm.linuxsecurity.com/1103-exploits/vlc105-dos.txt)
-
-
-
-version 0.5.3:
-
-- build system improvements
-- performance fix for seekable HTTP
-- fix several potentially exploitable issues in the FLIC decoder
-  (addresses CVE-2010-3429)
-
-
-
-version 0.5.2:
-
-- Hurd support
-- PowerPC without AltiVec compilation issues
-- validate channels and samplerate in the Vorbis decoder
-
-
-
-version 0.5.1:
-
-- build system updates
-- documentation updates
-- libswscale now is LGPL except for x86 optimizations
-- fix for GPL code in libswscale that was erroneously activated
-- AltiVec code in libswscale is now LGPL
-- remaining GPL parts in AC-3 decoder converted to LGPL
-- (L)GPL license upgrade support
-- AMR-NB decoding/encoding, AMR-WB decoding via OpenCORE libraries
-- enable symbol versioning by default for linkers that support it
-- backport av_lockmgr_register(), see doc/APIchanges for details
-- security fixes for:
-  - ASF, Ogg and MOV demuxers
-  - FFv1, H.264, HuffYUV, MLP, MPEG audio and Snow decoders
+- PB-frame decoding for H.263
+- deprecated vhook subsystem removed
+- deprecated old scaler removed
+- VQF demuxer
+- Alpha channel scaler
+- PCX encoder
 
 
 
 version 0.5:
 
-- The "device" muxers and demuxers are now in a new libavdevice library
 - DV50 AKA DVCPRO50 encoder, decoder, muxer and demuxer
-- DV100 AKA DVCPRO HD decoder and demuxer
 - TechSmith Camtasia (TSCC) video decoder
 - IBM Ultimotion (ULTI) video decoder
 - Sierra Online audio file demuxer and decoder
@@ -141,7 +31,7 @@
 - Fraps FPS1 video decoder
 - Snow video encoder/decoder
 - Sonic audio encoder/decoder
-- Vorbis audio encoder/decoder
+- Vorbis audio decoder
 - Macromedia ADPCM decoder
 - Duck TrueMotion 2 video decoder
 - support for decoding FLX and DTA extensions in FLIC files
@@ -152,18 +42,19 @@
 - TrueSpeech audio decoder
 - WMA2 audio decoder fixed, now all files should play correctly
 - RealAudio 14.4 and 28.8 decoders fixed
-- JPEG-LS encoder and decoder
-- CamStudio video decoder
+- JPEG-LS decoder
 - build system improvements
 - tabs and trailing whitespace removed from the codebase
+- CamStudio video decoder
 - AIFF/AIFF-C audio format, encoding and decoding
 - ADTS AAC file reading and writing
 - Creative VOC file reading and writing
 - American Laser Games multimedia (*.mm) playback system
-- Zip Blocks Motion Video decoder and encoder
+- Zip Motion Blocks Video decoder
 - improved Theora/VP3 decoder
 - True Audio (TTA) decoder
 - AVS demuxer and video decoder
+- JPEG-LS encoder
 - Smacker demuxer and decoder
 - NuppelVideo/MythTV demuxer and RTjpeg decoder
 - KMVC decoder
@@ -182,12 +73,14 @@
 - VP6 video decoder
 - WavPack lossless audio decoder
 - Targa (.TGA) picture decoder
+- Vorbis audio encoder
 - Delphine Software .cin demuxer/audio and video decoder
 - Tiertex .seq demuxer/video decoder
 - MTV demuxer
 - TIFF picture encoder and decoder
 - GIF picture decoder
 - Intel Music Coder decoder
+- Zip Motion Blocks Video encoder
 - Musepack decoder
 - Flash Screen Video encoder
 - Theora encoding via libtheora
@@ -214,10 +107,10 @@
 - OS/2 support removed and restored again
 - AC-3 decoder
 - NUT muxer
+- additional SPARC (VIS) optimizations
 - Matroska muxer
 - slice-based parallel H.264 decoding
 - Monkey's Audio demuxer and decoder
-- additional SPARC (VIS) optimizations
 - AMV audio and video decoder
 - DNxHD encoder
 - H.264 PAFF decoding
@@ -226,6 +119,7 @@
 - libvorbis Vorbis decoding removed in favor of native decoder
 - IntraX8 (J-Frame) subdecoder for WMV2 and VC-1
 - Ogg (Theora, Vorbis and FLAC) muxer
+- The "device" muxers and demuxers are now in a new libavdevice library
 - PC Paintbrush PCX decoder
 - Sun Rasterfile decoder
 - TechnoTrend PVA demuxer
@@ -255,6 +149,7 @@
 - AAC decoder
 - floating point PCM encoder/decoder
 - MXF muxer
+- DV100 AKA DVCPRO HD decoder and demuxer
 - E-AC-3 support added to AC-3 decoder
 - Nellymoser ASAO encoder
 - ASS and SSA demuxer and muxer
@@ -262,8 +157,9 @@
 - SVQ3 watermark decoding support
 - Speex decoding via libspeex
 - Electronic Arts TGQ decoder
-- RV30 and RV40 decoder
+- RV40 decoder
 - QCELP / PureVoice decoder
+- RV30 decoder
 - hybrid WavPack support
 - R3D REDCODE demuxer
 - ALSA support for playback and record
@@ -275,6 +171,7 @@
 - generic metadata API
 
 
+
 version 0.4.9-pre1:
 
 - DV encoder, DV muxer
@@ -358,6 +255,8 @@
 - many optimizations and bugfixes
 - FunCom ISS audio file demuxer and according ADPCM decoding
 
+
+
 version 0.4.8:
 
 - MPEG-2 video encoding (Michael)
@@ -368,6 +267,8 @@
 - Interplay MVE playback subsystem (Mike Melanson)
 - Duck DK3 and DK4 ADPCM audio decoders (Mike Melanson)
 
+
+
 version 0.4.7:
 
 - RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders. Author unknown, code from mplayerhq
@@ -408,6 +309,8 @@
 
 .. And lots more new enhancements and fixes.
 
+
+
 version 0.4.6:
 
 - completely new integer only MPEG audio layer 1/2/3 decoder rewritten
@@ -444,6 +347,8 @@
 - simple stats output (Juanjo)
 - 16-bit and 15-bit RGB/BGR/GBR support (Bisqwit)
 
+
+
 version 0.4.5:
 
 - some header fixes (Zdenek Kabelac <kabi at informatics.muni.cz>)
@@ -474,6 +379,8 @@
 - added MJPEG raw format (input/ouput)
 - added JPEG image format support (input/output)
 
+
+
 version 0.4.4:
 
 - fixed some std header definitions (Bjorn Lindgren
@@ -498,6 +405,8 @@
 - codecs are no longer searched by read_header() (should fix ffserver
   segfault)
 
+
+
 version 0.4.3:
 
 - BGR24 patch (initial patch by Jeroen Vreeken <pe1rxq at amsat.org>)
@@ -518,6 +427,8 @@
   <lists at reserv.at>, but changed completely since we use a format
   instead of a protocol)
 
+
+
 version 0.4.2:
 
 - added H.263/MPEG-4/MSMPEG4 decoding support. MPEG-4 decoding support
@@ -534,6 +445,7 @@
 - added file overwrite confirmation (can be disabled with -y)
 - added custom size picture to H.263 using H.263+ (Juanjo)
 
+
 version 0.4.1:
 
 - added MSMPEG4 (aka DivX) compatible encoder. Changed default codec
@@ -546,6 +458,8 @@
 - improved dct_quantize speed
 - factorized some motion estimation code
 
+
+
 version 0.4.0:
 
 - removing grab code from ffserver and moved it to ffmpeg. Added
@@ -573,10 +487,14 @@
 - changed directories: libav for format handling, libavcodec for
   codecs
 
+
+
 version 0.3.4:
 
 - added stereo in MPEG audio encoder
 
+
+
 version 0.3.3:
 
 - added 'high quality' mode which use motion vectors. It can be used in
@@ -584,15 +502,21 @@
 - fixed rounding problems which caused quality problems at high
   bitrates and large GOP size
 
+
+
 version 0.3.2: small fixes
 
 - ASF fixes
 - put_seek bug fix
 
+
+
 version 0.3.1: added avi/divx support
 
 - added AVI support
 - added MPEG-4 codec compatible with OpenDivX. It is based on the H.263 codec
 - added sound for flash format (not tested)
 
+
+
 version 0.3: initial public release
diff --git a/Doxyfile b/Doxyfile
old mode 100644
new mode 100755
diff --git a/INSTALL b/INSTALL
old mode 100644
new mode 100755
diff --git a/LICENSE b/LICENSE
index 8dc2c89..8c74356 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,50 +1,37 @@
-FFmpeg:
--------
-
 Most files in FFmpeg are under the GNU Lesser General Public License version 2.1
-or later (LGPL v2.1+). Read the file COPYING.LGPLv2.1 for details. Some other
-files have MIT/X11/BSD-style licenses. In combination the LGPL v2.1+ applies to
+or later (LGPL v2.1+). Read the file COPYING.LGPL for details. Some other files
+have a MIT/X11/BSD-style license. In combination the LGPL v2.1+ applies to
 FFmpeg.
 
 Some optional parts of FFmpeg are licensed under the GNU General Public License
-version 2 or later (GPL v2+). See the file COPYING.GPLv2 for details. None of
+version 2 or later (GPL v2+). See the file COPYING.GPL for details. None of
 these parts are used by default, you have to explicitly pass --enable-gpl to
 configure to activate them. In this case, FFmpeg's license changes to GPL v2+.
 
 Specifically, the GPL parts of FFmpeg are
 
 - libpostproc
-- some x86 optimizations in libswscale
+- some x86 and AltiVec optimizations in libswscale
 - optional x86 optimizations in the files
   libavcodec/x86/h264_deblock_sse2.asm
   libavcodec/x86/h264_idct_sse2.asm
   libavcodec/x86/idct_mmx.c
+- the AC-3 decoder in libavcodec/ac3dec.c
 - the X11 grabber in libavdevice/x11grab.c
 
+Some external libraries, e.g. libx264, are under GPL and can be used in
+conjunction with FFmpeg. They require --enable-gpl to be passed to configure
+as well.
+
+The nonfree external libraries libamrnb and libamrwb can be hooked up in FFmpeg.
+You need to pass --enable-nonfree to configure to enable them. Employ this
+option with care as FFmpeg then becomes nonfree and unredistributable.
+
 There are a handful of files under other licensing terms, namely:
 
 * The files libavcodec/jfdctfst.c, libavcodec/jfdctint.c, libavcodec/jrevdct.c
   are taken from libjpeg, see the top of the files for licensing details.
 
-Should you, for whatever reason, prefer to use version 3 of the (L)GPL, then
-the configure parameter --enable-version3 will activate this licensing option
-for you. Read the file COPYING.LGPLv3 or, if you have enabled GPL parts,
-COPYING.GPLv3 to learn the exact legal terms that apply in this case.
-
-
-external libraries:
--------------------
-
-Some external libraries, e.g. libx264, are under GPL and can be used in
-conjunction with FFmpeg. They require --enable-gpl to be passed to configure
-as well.
-
-The OpenCORE external libraries are under the Apache License 2.0. That license
-is incompatible with the LGPL v2.1 and the GPL v2, but not with version 3 of
-those licenses. So to combine the OpenCORE libraries with FFmpeg, the license
-version needs to be upgraded by passing --enable-version3 to configure.
-
-The nonfree external libraries libamrnb, libamrwb and libfaac can be hooked up
-in FFmpeg. You need to pass --enable-nonfree to configure to enable them. Employ
-this option with care as FFmpeg then becomes nonfree and unredistributable.
-Note that libfaac claims to be LGPL, but is not.
+* The file libavcodec/fdctref.c is copyrighted by the MPEG Software Simulation
+  Group with all rights reserved. It is only used to create a DCT test program
+  and not compiled into libavcodec.
diff --git a/MAINTAINERS b/MAINTAINERS
old mode 100644
new mode 100755
index 6b9baa2..95d9145
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -18,15 +18,6 @@
 ffmpeg:
   ffmpeg.c                              Michael Niedermayer
 
-  Video Hooks:
-    vhook
-    vhook/watermark.c                   Marcus Engene
-    vhook/ppm.c
-    vhook/drawtext.c
-    vhook/fish.c
-    vhook/null.c
-    vhook/imlib2.c
-
 ffplay:
   ffplay.c                              Michael Niedermayer
 
@@ -49,7 +40,6 @@
 project server                          Diego Biurrun, Mans Rullgard
 mailinglists                            Michael Niedermayer, Baptiste Coudurier
 presets                                 Robert Swain
-release management                      Diego Biurrun, Reinhard Tartler
 
 
 libavutil
@@ -133,8 +123,7 @@
   dv.c                                  Roman Shaposhnik
   eacmv*, eaidct*, eat*                 Peter Ross
   ffv1.c                                Michael Niedermayer
-  flacdec.c                             Alex Beregszaszi, Justin Ruggles
-  flacenc.c                             Justin Ruggles
+  flac*                                 Justin Ruggles
   flashsv*                              Benjamin Larsson
   flicvideo.c                           Mike Melanson
   g726.c                                Roman Shaposhnik
@@ -183,6 +172,7 @@
   rv3*                                  Kostya Shishkov
   rv4*                                  Kostya Shishkov
   s3tc*                                 Ivo van Poorten
+  smacker.c                             Kostya Shishkov
   smc.c                                 Mike Melanson
   snow.c                                Michael Niedermayer, Loren Merritt
   sonic.c                               Alex Beregszaszi
@@ -276,22 +266,23 @@
   nsvdec.c                              Francois Revol
   nut.c                                 Michael Niedermayer
   nuv.c                                 Reimar Doeffinger
-  oggdec.c, oggdec.h                    Mans Rullgard
+  oggdec.c, oggdec.h                    David Conrad
   oggenc.c                              Baptiste Coudurier
-  oggparsevorbis.c                      Mans Rullgard
-  oggparseogm.c                         Mans Rullgard
+  oggparse*.c                           David Conrad
   psxstr.c                              Mike Melanson
   pva.c                                 Ivo van Poorten
   r3d.c                                 Baptiste Coudurier
   raw.c                                 Michael Niedermayer
+  rdt.c                                 Ronald S. Bultje
   rl2.c                                 Sascha Sommer
-  rm.c                                  Roberto Togni
+  rmdec.c, rmenc.c                      Ronald S. Bultje, Kostya Shishkov
   rtp.c, rtpenc.c                       Luca Abeni
   rtp_mpv.*, rtp_aac.*                  Luca Abeni
   rtsp.c                                Luca Barbato
   sdp.c                                 Luca Abeni
   segafilm.c                            Mike Melanson
   siff.c                                Kostya Shishkov
+  smacker.c                             Kostya Shishkov
   swf.c                                 Baptiste Coudurier
   tta.c                                 Alex Beregszaszi
   txd.c                                 Ivo van Poorten
@@ -324,12 +315,14 @@
 GnuPG Fingerprints of maintainers and others who have svn write access
 ======================================================================
 
+Attila Kinali                 11F0 F9A6 A1D2 11F6 C745 D10C 6520 BCDD F2DF E765
 Benoit Fouet                  B22A 4F4F 43EF 636B BB66 FCDC 0023 AE1E 2985 49C8
+Baptiste Coudurier            8D77 134D 20CC 9220 201F C5DB 0AC9 325C 5C1A BAAA
 Diego Biurrun                 8227 1E31 B6D9 4994 7427 E220 9CAE D6CC 4757 FCC5
 Loren Merritt                 ABD9 08F4 C920 3F65 D8BE 35D7 1540 DAA7 060F 56DE
 Michael Niedermayer           9FF2 128B 147E F673 0BAD F133 611E C787 040B 0FAB
+Panagiotis Issaris            515C E262 10A8 FDCE 5481 7B9C 3AD7 D9A5 071D B3A9
 Peter Ross                    A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B
 Reimar Döffinger              C61D 16E5 9E2C D10C 8958 38A4 0899 A2B9 06D4 D9C7
-Reinhard Tartler              9300 5DC2 7E87 6C37 ED7B CA9A 9808 3544 9453 48A4
 Reynaldo H. Verdejo Pinochet  6E27 CD34 170C C78E 4D4F 5F40 C18E 077F 3114 452A
 Sascha Sommer                 38A0 F88B 868E 9D3A 97D4 D6A0 E823 706F 1E07 0D3C
diff --git a/Makefile b/Makefile
old mode 100644
new mode 100755
index 5e42841..3beecfb
--- a/Makefile
+++ b/Makefile
@@ -20,22 +20,21 @@
 
 FFLIBS-$(CONFIG_AVFILTER) += avfilter
 FFLIBS-$(CONFIG_POSTPROC) += postproc
-FFLIBS-$(CONFIG_SWSCALE)  += swscale
 
-FFLIBS := avdevice avformat avcodec avutil
+FFLIBS := avdevice avformat avcodec avutil swscale
 
 DATA_FILES := $(wildcard $(SRC_DIR)/ffpresets/*.ffpreset)
 
+EXAMPLES = output_example$(EXESUF)
+
 include common.mak
 
 FF_LDFLAGS   := $(FFLDFLAGS)
 FF_EXTRALIBS := $(FFEXTRALIBS)
 FF_DEP_LIBS  := $(DEP_LIBS)
 
-ALL_TARGETS-$(CONFIG_VHOOK) += videohook
 ALL_TARGETS-$(BUILD_DOC)    += documentation
 
-INSTALL_TARGETS-$(CONFIG_VHOOK) += install-vhook
 ifneq ($(PROGS),)
 INSTALL_TARGETS-yes             += install-progs install-data
 INSTALL_TARGETS-$(BUILD_DOC)    += install-man
@@ -48,7 +47,8 @@
 	cp -p $< $@
 	$(STRIP) $@
 
-SUBDIR_VARS := OBJS FFLIBS CLEANFILES DIRS TESTS
+SUBDIR_VARS := OBJS FFLIBS CLEANFILES DIRS TESTPROGS EXAMPLES \
+               ALTIVEC-OBJS MMX-OBJS YASM-OBJS-FFT YASM-OBJS
 
 define RESET
 $(1) :=
@@ -81,41 +81,8 @@
 
 alltools: $(addsuffix $(EXESUF),$(addprefix tools/, cws2fws pktdumper qt-faststart trasher))
 
-VHOOKCFLAGS += $(filter-out -mdynamic-no-pic,$(CFLAGS))
-
-BASEHOOKS = fish null watermark
-ALLHOOKS = $(BASEHOOKS) drawtext imlib2 ppm
-ALLHOOKS_SRCS = $(addprefix vhook/, $(addsuffix .c, $(ALLHOOKS)))
-
-HOOKS-$(HAVE_FORK)      += ppm
-HOOKS-$(HAVE_IMLIB2)    += imlib2
-HOOKS-$(HAVE_FREETYPE2) += drawtext
-
-HOOKS = $(addprefix vhook/, $(addsuffix $(SLIBSUF), $(BASEHOOKS) $(HOOKS-yes)))
-
-VHOOKCFLAGS-$(HAVE_IMLIB2) += `imlib2-config --cflags`
-LIBS_imlib2$(SLIBSUF)       = `imlib2-config --libs`
-
-VHOOKCFLAGS-$(HAVE_FREETYPE2) += `freetype-config --cflags`
-LIBS_drawtext$(SLIBSUF)        = `freetype-config --libs`
-
-VHOOKCFLAGS += $(VHOOKCFLAGS-yes)
-
-vhook/%.o vhook/%.d: CFLAGS:=$(VHOOKCFLAGS)
-
-# vhooks compile fine without libav*, but need them nonetheless.
-videohook: $(FF_DEP_LIBS) $(HOOKS)
-
-$(eval VHOOKSHFLAGS=$(VHOOKSHFLAGS))
-vhook/%$(SLIBSUF): vhook/%.o
-	$(CC) $(LDFLAGS) -o $@ $(VHOOKSHFLAGS) $< $(VHOOKLIBS) $(LIBS_$(@F))
-
-VHOOK_DEPS = $(HOOKS:$(SLIBSUF)=.d)
-depend dep: $(VHOOK_DEPS)
-
 documentation: $(addprefix doc/, ffmpeg-doc.html faq.html ffserver-doc.html \
-                                 ffplay-doc.html general.html hooks.html \
-                                 $(ALLMANPAGES))
+                                 ffplay-doc.html general.html $(ALLMANPAGES))
 
 doc/%.html: doc/%.texi
 	texi2html -monolithic -number $<
@@ -141,11 +108,7 @@
 	install -d "$(MANDIR)/man1"
 	install -m 644 $(MANPAGES) "$(MANDIR)/man1"
 
-install-vhook: videohook
-	install -d "$(SHLIBDIR)/vhook"
-	install -m 755 $(HOOKS) "$(SHLIBDIR)/vhook"
-
-uninstall: uninstall-progs uninstall-data uninstall-man uninstall-vhook
+uninstall: uninstall-progs uninstall-data uninstall-man
 
 uninstall-progs:
 	rm -f $(addprefix "$(BINDIR)/", $(ALLPROGS))
@@ -156,22 +119,18 @@
 uninstall-man:
 	rm -f $(addprefix "$(MANDIR)/man1/",$(ALLMANPAGES))
 
-uninstall-vhook:
-	rm -f $(addprefix "$(SHLIBDIR)/",$(ALLHOOKS_SRCS:.c=$(SLIBSUF)))
-	-rmdir "$(SHLIBDIR)/vhook/"
-
 testclean:
 	rm -rf tests/vsynth1 tests/vsynth2 tests/data tests/asynth1.sw tests/*~
 
 clean:: testclean
-	rm -f $(ALLPROGS) $(ALLPROGS_G) output_example$(EXESUF)
+	rm -f $(ALLPROGS) $(ALLPROGS_G)
 	rm -f doc/*.html doc/*.pod doc/*.1
-	rm -f $(addprefix tests/,$(addsuffix $(EXESUF),audiogen videogen rotozoom seek_test tiny_psnr))
+	rm -f tests/seek_test$(EXESUF)
+	rm -f $(addprefix tests/,$(addsuffix $(HOSTEXESUF),audiogen videogen rotozoom tiny_psnr))
 	rm -f $(addprefix tools/,$(addsuffix $(EXESUF),cws2fws pktdumper qt-faststart trasher))
-	rm -f vhook/*.o vhook/*~ vhook/*.so vhook/*.dylib vhook/*.dll
 
 distclean::
-	rm -f version.h config.* vhook/*.d
+	rm -f version.h config.*
 
 # regression tests
 
@@ -237,6 +196,7 @@
         asf                                     \
         rm                                      \
         mpg                                     \
+        mxf                                     \
         ts                                      \
         swf                                     \
         ffm                                     \
@@ -267,6 +227,7 @@
         voc                                     \
         ogg                                     \
         pixfmt                                  \
+        pcx                                     \
     )
 
 REGFILES = $(addprefix tests/data/,$(addsuffix .$(1),$(2:regtest-%=%)))
@@ -280,15 +241,6 @@
 ROTOZOOM_REG = tests/data/rotozoom.regression
 VSYNTH_REG   = tests/data/vsynth.regression
 
-ifneq ($(CONFIG_SWSCALE),yes)
-servertest codectest $(CODEC_TESTS) libavtest: swscale-error
-swscale-error:
-	@echo
-	@echo "This regression test requires --enable-swscale."
-	@echo
-	@exit 1
-endif
-
 ifneq ($(CONFIG_ZLIB),yes)
 regtest-flashsv codectest: zlib-error
 endif
@@ -320,7 +272,7 @@
 
 regtest-ref: ffmpeg$(EXESUF) tests/vsynth1/00.pgm tests/vsynth2/00.pgm tests/asynth1.sw
 
-$(CODEC_TESTS) regtest-ref: tests/tiny_psnr$(EXESUF)
+$(CODEC_TESTS) regtest-ref: tests/tiny_psnr$(HOSTEXESUF)
 	$(SRC_PATH)/tests/regression.sh $@ vsynth   tests/vsynth1 a "$(TARGET_EXEC)" "$(TARGET_PATH)"
 	$(SRC_PATH)/tests/regression.sh $@ rotozoom tests/vsynth2 a "$(TARGET_EXEC)" "$(TARGET_PATH)"
 
@@ -337,24 +289,22 @@
 	@echo
 	$(SRC_PATH)/tests/server-regression.sh $(FFSERVER_REFFILE) $(SRC_PATH)/tests/test.conf
 
-tests/vsynth1/00.pgm: tests/videogen$(EXESUF)
+tests/vsynth1/00.pgm: tests/videogen$(HOSTEXESUF)
 	mkdir -p tests/vsynth1
 	$(BUILD_ROOT)/$< 'tests/vsynth1/'
 
-tests/vsynth2/00.pgm: tests/rotozoom$(EXESUF)
+tests/vsynth2/00.pgm: tests/rotozoom$(HOSTEXESUF)
 	mkdir -p tests/vsynth2
 	$(BUILD_ROOT)/$< 'tests/vsynth2/' $(SRC_PATH)/tests/lena.pnm
 
-tests/asynth1.sw: tests/audiogen$(EXESUF)
+tests/asynth1.sw: tests/audiogen$(HOSTEXESUF)
 	$(BUILD_ROOT)/$< $@
 
-tests/%$(EXESUF): tests/%.c
+tests/%$(HOSTEXESUF): tests/%.c
 	$(HOSTCC) $(HOSTCFLAGS) $(HOSTLDFLAGS) -o $@ $< $(HOSTLIBS)
 
 tests/seek_test$(EXESUF): tests/seek_test.c $(FF_DEP_LIBS)
 	$(CC) $(FF_LDFLAGS) $(CFLAGS) -o $@ $< $(FF_EXTRALIBS)
 
 
-.PHONY: lib videohook documentation *test regtest-* swscale-error zlib-error alltools check
-
--include $(VHOOK_DEPS)
+.PHONY: documentation *test regtest-* zlib-error alltools check
diff --git a/README b/README
old mode 100644
new mode 100755
diff --git a/RELEASE b/RELEASE
deleted file mode 100644
index c934528..0000000
--- a/RELEASE
+++ /dev/null
@@ -1,234 +0,0 @@
-Release Notes
-=============
-
-* 0.5 "Bike Shed World Domination" March 3, 2009
-
-General notes
--------------
-
-It has been so long since the last release that this should be considered the
-first FFmpeg release of recent times. Because of the way things have unfolded to
-date, the notes for this version cannot be entirely conventional.
-
-See the Changelog file for a list of significant changes.
-
-Please note that our policy on bug reports has not changed. We still only accept
-bug reports against HEAD of the FFmpeg trunk repository. If you are experiencing
-any issues with any formally released version of FFmpeg, please try a current
-version of the development code to check if the issue still exists. If it does,
-make your report against the development code following the usual bug reporting
-guidelines.
-
-API notes
----------
-
-In the next release, it is intended to remove a number of deprecated APIs. We
-decided to put out a release that includes said APIs for the benefit of third
-party software.
-
-As such, this release:
-- provides a sync point for said APIs
-- increases awareness of API changes
-- allows the next release to detail how to transition from the old to the new
-
-The deprecated APIs to be removed are:
-- imgconvert (to be replaced by libswscale)
-- vhook (to be replaced by libavfilter)
-
-If at all possible, do not use the deprecated APIs. All notes on API changes
-should appear in doc/APIchanges.
-
-
-
-* 0.5.1 March 2, 2010
-
-General notes
--------------
-
-This point release includes some minor updates to make the 0.5 release series
-usable for users that need to retain the existing behavior as closely as
-possible. The changes follow below:
-
-Security fixes
---------------
-
-Various programming errors in container and codec implementations
-may lead to denial of service or the execution of arbitrary code
-if the user is tricked into opening a malformed media file or stream.
-
-Affected and updated have been the implementations of the following
-codecs and container formats:
-
- - the Vorbis audio codec
- - the FF Video 1 codec
- - the MPEG audio codec
- - the H264 video codec
- - the MLP codec
- - the HuffYUV codec
- - the ASF demuxer
- - the Ogg container implementation
- - the MOV container implementation
-
-Symbol Versioning enabled
--------------------------
-
-The backported symbol versioning change is enabled on platforms that support
-it. This allows users to upgrade from 0.5.1 to the upcoming 0.6 release
-without having to recompile their applications. Please note that distributors
-have to recompile applications against 0.5.1 before upgrading to 0.6.
-
-libx264.c backport
-------------------
-
-This release includes a backport to the libx264 wrapper that allows FFmpeg to
-be compiled against newer versions of libx264 up to API version 85.
-
-licensing changes
------------------
-
-Previously both libswscale and our AC-3 decoder had GPLed parts. These have
-been replaced by fresh LGPL code. x86 optimizations for libswscale remain GPL,
-but the C code is fully functional. Optimizations for other architectures have
-been relicensed to LGPL.
-
-AMR-NB decoding/encoding and AMR-WB decoding is now possible through the free
-software OpenCORE libraries as an alternative to the non-free libamr libraries.
-
-We found out that libfaac contains non-free parts and is not LGPL as previously
-claimed. We have changed configure to reflect this. You now have to pass the
---enable-nonfree option if you wish to compile with libfaac support enabled.
-
-Furthermore the non-free bits in libavcodec/fdctref.c have been rewritten. Note
-well that they were only used in a test program and never compiled into any
-FFmpeg library.
-
-
-
-* 0.5.2 May 25, 2010
-
-General notes
--------------
-
-This is a maintenance-only release that addresses a small number of security
-and portability issues. Distributors and system integrators are encouraged
-to update and share their patches against this branch.
-
-
-
-* 0.5.3 Oct 18, 2010
-
-General notes
--------------
-
-This is (again) another maintenance-only release that addresses a fix
-for seekable HTTP and an exploitable bug in the FLIC decoder
-(cf. CVE-2010-3429 for details). Distributors and system integrators are
-encouraged to update and share their patches against this branch.
-
-
-
-* 0.5.4 Mar 17, 2011
-
-General notes
--------------
-
-This is the first release that we cut after git migration. It is another
-maintenance-only release that addresses several security issues that were
-brought to our attention. In detail, fixes for RV30/40, WMV, Vorbis and
-VC-1 have been backported from trunk. Distributors and system integrators
-are encouraged to update and share their patches against this branch.
-
-
-
-* 0.5.5 Nov 6, 2011
-
-General notes
--------------
-
-This maintenance-only release addresses several security issues that
-were brought to our attention. In detail, fixes for the MJPEG decoder,
-the CAVS decoder (CVE-2011-3362, CVE-2011-3973, CVE-2011-3974), and the
-Matroska decoder (MSVR11-011/CVE-2011-3504) and many others have been
-corrected. Additional, this release contains fixes for compilation with
-gcc-4.6. Distributors and system integrators are encouraged to update
-and share their patches against this branch.
-
-
-
-* 0.5.6 Nov 21, 2011
-
-General notes
--------------
-
-This maintenance-only release addresses several security issues that
-were brought to our attention.
-
-
-
-* 0.5.7 Dec 25, 2011
-
-General notes
--------------
-
-This maintenance-only release addresses several security issues that
-were brought to our attention. In details, it features fixes for the
-QDM2 decoder (CVE-2011-4351), DoS in the VP5/VP6 decoders
-(CVE-2011-4353), and a buffer overflow in the Sierra VMD decoder
-CVE-2011-4364, and a safety fix in the SVQ1 decoder (CVE-2011-4579).
-CVE-2011-4352, a bug in the VP3 decoder, is not known to affect this
-release.
-
-Distributors and system integrators are encouraged to update and share
-their patches against this branch.
-
-
-
-* 0.5.8 Jan 12, 2012
-
-General notes
--------------
-
-This mostly maintenance-only release that addresses a number a number of
-bugs such as security and compilation issues that have been brought to
-our attention. Among other (rather minor) fixes, this release features
-fixes for the VP3 decoder (CVE-2011-3892), vorbis decoder, and matroska
-demuxer (CVE-2011-3893 and CVE-2011-3895).
-
-Distributors and system integrators are encouraged
-to update and share their patches against this branch.  For a full list
-of changes please see the Changelog file.
-
-
-
-* 0.5.9 May 11, 2012
-
-General notes
--------------
-
-This maintenance-only release that addresses a number a number of
-security issues that have been brought to our attention. Among other
-(rather minor) fixes, this release features fixes for the DV decoder
-(CVE-2011-3929 and CVE-2011-3936), nsvdec (CVE-2011-3940), Atrac3
-(CVE-2012-0853), mjpegdec (CVE-2011-3947) and the VQA video decoder
-(CVE-2012-0947).
-
-Distributors and system integrators are encouraged
-to update and share their patches against this branch.  For a full list
-of changes please see the Changelog file.
-
-
-
-* 0.5.10 Jun 09, 2012
-
-General notes
--------------
-
-This mostly maintenance-only release addresses a number a number of bugs
-such as security and compilation issues that have been brought to our
-attention. Among other fixes, this release features includes security
-updates for the DPCM codecs (CVE-2011-3951), H.264 (CVE-2012-0851),
-ADPCM (CVE-2012-0852), and the KMVC decoder (CVE-2011-3952).
-
-Distributors and system integrators are encouraged
-to update and share their patches against this branch.  For a full list
-of changes please see the Changelog file or the git commit history.
diff --git a/VERSION b/VERSION
deleted file mode 100644
index 50c76ef..0000000
--- a/VERSION
+++ /dev/null
@@ -1 +0,0 @@
-0.5.10
diff --git a/cmdutils.c b/cmdutils.c
old mode 100644
new mode 100755
index f1e5352..9fc4fc6
--- a/cmdutils.c
+++ b/cmdutils.c
@@ -280,9 +280,7 @@
 #if CONFIG_AVFILTER
     PRINT_LIB_VERSION(outstream, avfilter, AVFILTER, indent);
 #endif
-#if CONFIG_SWSCALE
     PRINT_LIB_VERSION(outstream, swscale,  SWSCALE,  indent);
-#endif
 #if CONFIG_POSTPROC
     PRINT_LIB_VERSION(outstream, postproc, POSTPROC, indent);
 #endif
@@ -290,7 +288,7 @@
 
 void show_banner(void)
 {
-    fprintf(stderr, "%s version " FFMPEG_VERSION ", Copyright (c) %d-%d Fabrice Bellard, et al.\n",
+    fprintf(stderr, "%s version: " FFMPEG_VERSION ", Copyright (c) %d-%d Fabrice Bellard, et al.\n",
             program_name, program_birth_year, this_year);
     fprintf(stderr, "  configuration: " FFMPEG_CONFIGURATION "\n");
     print_all_lib_versions(stderr, 1);
@@ -309,26 +307,14 @@
 
 void show_license(void)
 {
-    printf(
 #if CONFIG_NONFREE
+    printf(
     "This version of %s has nonfree parts compiled in.\n"
     "Therefore it is not legally redistributable.\n",
     program_name
-#elif CONFIG_GPLV3
-    "%s is free software; you can redistribute it and/or modify\n"
-    "it under the terms of the GNU General Public License as published by\n"
-    "the Free Software Foundation; either version 3 of the License, or\n"
-    "(at your option) any later version.\n"
-    "\n"
-    "%s is distributed in the hope that it will be useful,\n"
-    "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
-    "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n"
-    "GNU General Public License for more details.\n"
-    "\n"
-    "You should have received a copy of the GNU General Public License\n"
-    "along with %s.  If not, see <http://www.gnu.org/licenses/>.\n",
-    program_name, program_name, program_name
+    );
 #elif CONFIG_GPL
+    printf(
     "%s is free software; you can redistribute it and/or modify\n"
     "it under the terms of the GNU General Public License as published by\n"
     "the Free Software Foundation; either version 2 of the License, or\n"
@@ -343,21 +329,9 @@
     "along with %s; if not, write to the Free Software\n"
     "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n",
     program_name, program_name, program_name
-#elif CONFIG_LGPLV3
-    "%s is free software; you can redistribute it and/or modify\n"
-    "it under the terms of the GNU Lesser General Public License as published by\n"
-    "the Free Software Foundation; either version 3 of the License, or\n"
-    "(at your option) any later version.\n"
-    "\n"
-    "%s is distributed in the hope that it will be useful,\n"
-    "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
-    "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n"
-    "GNU Lesser General Public License for more details.\n"
-    "\n"
-    "You should have received a copy of the GNU Lesser General Public License\n"
-    "along with %s.  If not, see <http://www.gnu.org/licenses/>.\n",
-    program_name, program_name, program_name
+    );
 #else
+    printf(
     "%s is free software; you can redistribute it and/or\n"
     "modify it under the terms of the GNU Lesser General Public\n"
     "License as published by the Free Software Foundation; either\n"
@@ -372,8 +346,8 @@
     "License along with %s; if not, write to the Free Software\n"
     "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n",
     program_name, program_name, program_name
-#endif
     );
+#endif
 }
 
 void show_formats(void)
@@ -498,3 +472,14 @@
 "decoder corresponds to the h263 and h263p encoders, for file formats it is even\n"
 "worse.\n");
 }
+
+int read_yesno(void)
+{
+    int c = getchar();
+    int yesno = (toupper(c) == 'Y');
+
+    while (c != '\n' && c != EOF)
+        c = getchar();
+
+    return yesno;
+}
diff --git a/cmdutils.h b/cmdutils.h
old mode 100644
new mode 100755
index 26ab63f..607df6a
--- a/cmdutils.h
+++ b/cmdutils.h
@@ -152,4 +152,10 @@
  */
 void show_formats(void);
 
+/**
+ * Returns a positive value if reads from standard input a line
+ * starting with [yY], otherwise returns 0.
+ */
+int read_yesno(void);
+
 #endif /* FFMPEG_CMDUTILS_H */
diff --git a/common.mak b/common.mak
old mode 100644
new mode 100755
index a98ccd7..83f2dbb
--- a/common.mak
+++ b/common.mak
@@ -5,11 +5,10 @@
 all: # make "all" default target
 
 ifndef SUBDIR
-vpath %.c $(SRC_DIR)
-vpath %.h $(SRC_DIR)
-vpath %.S $(SRC_DIR)
+vpath %.c   $(SRC_DIR)
+vpath %.h   $(SRC_DIR)
+vpath %.S   $(SRC_DIR)
 vpath %.asm $(SRC_DIR)
-vpath %.v   $(SRC_DIR)
 
 ifeq ($(SRC_DIR),$(SRC_PATH_BARE))
 BUILD_ROOT_REL = .
@@ -19,14 +18,13 @@
 
 ALLFFLIBS = avcodec avdevice avfilter avformat avutil postproc swscale
 
-CFLAGS := -DHAVE_AV_CONFIG_H -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE \
-          -I$(BUILD_ROOT_REL) -I$(SRC_PATH) $(OPTFLAGS)
+CFLAGS := -DHAVE_AV_CONFIG_H -I$(BUILD_ROOT_REL) -I$(SRC_PATH) $(OPTFLAGS)
 
 %.o: %.c
 	$(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
 
 %.o: %.S
-	$(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
+	$(AS) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
 
 %.ho: %.h
 	$(CC) $(CFLAGS) $(LIBOBJFLAGS) -Wno-unused -c -o $@ -x c $<
@@ -44,36 +42,34 @@
 
 %$(EXESUF): %.c
 
-%.ver: %.v
-	sed 's/$$MAJOR/$($(basename $(@F))_VERSION_MAJOR)/' $^ > $@
-
 SVN_ENTRIES = $(SRC_PATH_BARE)/.svn/entries
 ifeq ($(wildcard $(SVN_ENTRIES)),$(SVN_ENTRIES))
 $(BUILD_ROOT_REL)/version.h: $(SVN_ENTRIES)
 endif
 
-$(BUILD_ROOT_REL)/version.h: $(SRC_PATH_BARE)/version.sh
+$(BUILD_ROOT_REL)/version.h: $(SRC_PATH_BARE)/version.sh config.mak
 	$< $(SRC_PATH) $@ $(EXTRA_VERSION)
 
 install: install-libs install-headers
 
 uninstall: uninstall-libs uninstall-headers
 
-.PHONY: all depend dep clean distclean install* uninstall* tests
+.PHONY: all depend dep *clean install* uninstall* examples testprogs
 endif
 
-CFLAGS   += $(CFLAGS-yes)
-OBJS     += $(OBJS-yes)
-FFLIBS   := $(FFLIBS-yes) $(FFLIBS)
-TESTS    += $(TESTS-yes)
+CFLAGS    += $(CFLAGS-yes)
+OBJS      += $(OBJS-yes)
+FFLIBS    := $(FFLIBS-yes) $(FFLIBS)
+TESTPROGS += $(TESTPROGS-yes)
 
 FFEXTRALIBS := $(addprefix -l,$(addsuffix $(BUILDSUF),$(FFLIBS))) $(EXTRALIBS)
 FFLDFLAGS   := $(addprefix -L$(BUILD_ROOT)/lib,$(FFLIBS)) $(LDFLAGS)
 
-OBJS  := $(addprefix $(SUBDIR),$(OBJS))
-TESTS := $(addprefix $(SUBDIR),$(TESTS))
+EXAMPLES  := $(addprefix $(SUBDIR),$(EXAMPLES))
+OBJS      := $(addprefix $(SUBDIR),$(OBJS))
+TESTPROGS := $(addprefix $(SUBDIR),$(addsuffix -test$(EXESUF),$(TESTPROGS)))
 
-DEP_LIBS:=$(foreach NAME,$(FFLIBS),lib$(NAME)/$($(BUILD_SHARED:yes=S)LIBNAME))
+DEP_LIBS := $(foreach NAME,$(FFLIBS),lib$(NAME)/$($(BUILD_SHARED:yes=S)LIBNAME))
 
 ALLHEADERS := $(subst $(SRC_DIR)/,$(SUBDIR),$(wildcard $(SRC_DIR)/*.h $(SRC_DIR)/$(ARCH)/*.h))
 checkheaders: $(filter-out %_template.ho,$(ALLHEADERS:.h=.ho))
@@ -81,9 +77,9 @@
 DEPS := $(OBJS:.o=.d)
 depend dep: $(DEPS)
 
-CLEANSUFFIXES = *.o *~ *.ho *.ver
-LIBSUFFIXES   = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a *.exp *.map
+CLEANSUFFIXES     = *.o *~ *.ho
 DISTCLEANSUFFIXES = *.d *.pc
+LIBSUFFIXES       = *.a *.lib *.so *.so.* *.dylib *.dll *.def *.dll.a *.exp *.map
 
 define RULES
 $(SUBDIR)%$(EXESUF): $(SUBDIR)%.o
@@ -102,7 +98,7 @@
 	$(YASM) $(YASMFLAGS) -I $$(<D)/ -M -o $$(@:%.d=%.o) $$< > $$@
 
 clean::
-	rm -f $(TESTS) $(addprefix $(SUBDIR),$(CLEANFILES) $(CLEANSUFFIXES) $(LIBSUFFIXES)) \
+	rm -f $(EXAMPLES) $(addprefix $(SUBDIR),*-test$(EXESUF) $(CLEANFILES) $(CLEANSUFFIXES) $(LIBSUFFIXES)) \
 	    $(addprefix $(SUBDIR), $(foreach suffix,$(CLEANSUFFIXES),$(addsuffix /$(suffix),$(DIRS))))
 
 distclean:: clean
@@ -112,6 +108,7 @@
 
 $(eval $(RULES))
 
-tests: $(TESTS)
+examples: $(EXAMPLES)
+testprogs: $(TESTPROGS)
 
 -include $(DEPS)
diff --git a/configure b/configure
index 67cc2f6..6bf86f9 100755
--- a/configure
+++ b/configure
@@ -75,35 +75,31 @@
   echo "  --enable-shared          build shared libraries [no]"
   echo "  --enable-gpl             allow use of GPL code, the resulting libs"
   echo "                           and binaries will be under GPL [no]"
-  echo "  --enable-version3        upgrade (L)GPL to version 3 [no]"
   echo "  --enable-nonfree         allow use of nonfree code, the resulting libs"
   echo "                           and binaries will be unredistributable [no]"
   echo "  --disable-ffmpeg         disable ffmpeg build"
   echo "  --disable-ffplay         disable ffplay build"
   echo "  --disable-ffserver       disable ffserver build"
   echo "  --enable-postproc        enable GPLed postprocessing support [no]"
-  echo "  --enable-swscale         enable software scaler support [no]"
-  echo "  --enable-avfilter        video filter support (replaces vhook) [no]"
+  echo "  --enable-avfilter        video filter support [no]"
   echo "  --enable-avfilter-lavf   video filters dependent on avformat [no]"
-  echo "  --disable-vhook          disable video hooking support"
   echo "  --enable-beosthreads     use BeOS threads [no]"
   echo "  --enable-os2threads      use OS/2 threads [no]"
   echo "  --enable-pthreads        use pthreads [no]"
   echo "  --enable-w32threads      use Win32 threads [no]"
   echo "  --enable-x11grab         enable X11 grabbing [no]"
-  echo "  --enable-vdpau           enable VDPAU support [no]"
   echo "  --disable-network        disable network support [no]"
   echo "  --disable-ipv6           disable IPv6 support [no]"
   echo "  --disable-mpegaudio-hp   faster (but less accurate) MPEG audio decoding [no]"
   echo "  --enable-gray            enable full grayscale support (slower color)"
-  echo "  --enable-fastdiv         enable table-based division"
+  echo "  --disable-swscale-alpha  disable alpha channel support in swscale"
+  echo "  --disable-fastdiv        disable table-based division"
   echo "  --enable-small           optimize for size instead of speed"
   echo "  --disable-aandct         disable AAN DCT code"
   echo "  --disable-fft            disable FFT code"
   echo "  --disable-golomb         disable Golomb code"
   echo "  --disable-mdct           disable MDCT code"
   echo "  --disable-rdft           disable RDFT code"
-  echo "  --enable-runtime-cpudetect detect cpu capabilities at runtime (bigger binary)"
   echo "  --enable-hardcoded-tables use hardcoded tables instead of runtime generation"
   echo "  --enable-memalign-hack   emulate memalign, interferes with memory debuggers"
   echo "  --enable-beos-netserver  enable BeOS netserver"
@@ -150,8 +146,6 @@
   echo "  --enable-bzlib           enable bzlib [autodetect]"
   echo "  --enable-libamr-nb       enable libamr-nb floating point audio codec [no]"
   echo "  --enable-libamr-wb       enable libamr-wb floating point audio codec [no]"
-  echo "  --enable-libopencore-amrnb enable AMR-NB de/encoding via libopencore-amrnb [no]"
-  echo "  --enable-libopencore-amrwb enable AMR-WB decoding via libopencore-amrwb [no]"
   echo "  --enable-libdc1394       enable IIDC-1394 grabbing using libdc1394"
   echo "                           and libraw1394 [no]"
   echo "  --enable-libdirac        enable Dirac support via libdirac [no]"
@@ -184,6 +178,7 @@
   echo "  --target-exec=CMD        command to run executables on target"
   echo "  --target-path=DIR        path to view of build directory on target"
   echo "  --nm=NM                  use nm tool"
+  echo "  --as=AS                  use assembler AS [$as_default]"
   echo "  --cc=CC                  use C compiler CC [$cc_default]"
   echo "  --host-cc=HOSTCC         use host C compiler HOSTCC"
   echo "  --host-cflags=HCFLAGS    use HCFLAGS when compiling for host"
@@ -446,7 +441,7 @@
     makefile=$3
     shift 3
     for cfg; do
-        ucname="`toupper $cfg`"
+        ucname="$(toupper $cfg)"
         if enabled $cfg; then
             echo "#define ${pfx}${ucname} 1" >> $header
             echo "${pfx}${ucname}=yes" >> $makefile
@@ -530,12 +525,19 @@
     check_cmd $cc $CFLAGS "$@" -E -o $TMPO $TMPC
 }
 
+check_as(){
+    log check_as "$@"
+    cat > $TMPC
+    log_file $TMPC
+    check_cmd $as $CFLAGS "$@" -c -o $TMPO $TMPC
+}
+
 check_asm(){
     log check_asm "$@"
     name="$1"
     asm="$2"
     shift 2
-    check_cc "$@" <<EOF && enable $name || disable $name
+    check_as "$@" <<EOF && enable $name || disable $name
 void foo(void){ __asm__ volatile($asm); }
 EOF
 }
@@ -566,16 +568,11 @@
 EOF
 }
 
-test_ldflags(){
-    log test_ldflags "$@"
-    check_ld "$@" <<EOF
-int main(void){ return 0; }
-EOF
-}
-
 check_ldflags(){
     log check_ldflags "$@"
-    test_ldflags "$@" && add_ldflags "$@"
+    check_ld "$@" <<EOF && add_ldflags "$@"
+int main(void){ return 0; }
+EOF
 }
 
 check_header(){
@@ -661,7 +658,7 @@
 }
 
 check_exec_crash(){
-    code=`cat`
+    code=$(cat)
 
     # exit() is not async signal safe.  _Exit (C99) and _exit (POSIX)
     # are safe but may not be available everywhere.  Thus we use
@@ -729,8 +726,8 @@
     check_cmd ${pkg}-config --version
     err=$?
     if test "$err" = 0; then
-        temp_cflags `${pkg}-config --cflags`
-        temp_extralibs `${pkg}-config --libs`
+        temp_cflags $(${pkg}-config --cflags)
+        temp_extralibs $(${pkg}-config --libs)
         check_lib "$@" $header $func && enable $cfg
     fi
     return $err
@@ -787,8 +784,6 @@
     libgsm
     libmp3lame
     libnut
-    libopencore_amrnb
-    libopencore_amrwb
     libopenjpeg
     libschroedinger
     libspeex
@@ -805,14 +800,10 @@
     postproc
     powerpc_perf
     rdft
-    runtime_cpudetect
     shared
     small
     static
-    swscale
-    vdpau
-    vhook
-    version3
+    swscale_alpha
     x11grab
     zlib
 "
@@ -886,11 +877,9 @@
     fast_cmov
     fast_unaligned
     fork
-    freetype2
     gethrtime
     GetProcessTimes
     getrusage
-    imlib2
     inet_aton
     inline_asm
     libdc1394_1
@@ -923,15 +912,13 @@
     termios_h
     threads
     truncf
+    VirtualAlloc
     winsock2_h
     yasm
 "
 
 # options emitted with CONFIG_ prefix but not available on command line
 CONFIG_EXTRA="
-    gplv3
-    lgplv3
-    oldscaler
 "
 
 CMDLINE_SELECT="
@@ -960,6 +947,7 @@
 CMDLINE_SET="
     $PATHS_LIST
     arch
+    as
     build_suffix
     cc
     cpu
@@ -969,6 +957,7 @@
     host_cflags
     host_ldflags
     host_libs
+    host_os
     logfile
     nm
     source_path
@@ -999,11 +988,9 @@
 ssse3_deps="sse"
 vis_deps="sparc"
 
-# common features
-oldscaler_deps="!swscale"
-
 # decoders / encoders
 aac_decoder_select="fft mdct"
+ac3_decoder_deps="gpl"
 ac3_decoder_select="fft mdct"
 atrac3_decoder_select="fft mdct"
 cavs_decoder_select="golomb"
@@ -1012,6 +999,7 @@
 dca_decoder_select="fft mdct"
 dnxhd_encoder_select="aandct"
 dxa_decoder_select="zlib"
+eac3_decoder_deps="gpl"
 eac3_decoder_select="fft mdct"
 eatgq_decoder_select="aandct"
 eatqi_decoder_select="aandct"
@@ -1025,7 +1013,7 @@
 h263_encoder_select="aandct"
 h263p_encoder_select="aandct"
 h264_decoder_select="golomb"
-h264_vdpau_decoder_deps="vdpau"
+h264_vdpau_decoder_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
 imc_decoder_select="fft mdct"
 jpegls_decoder_select="golomb"
 jpegls_encoder_select="golomb"
@@ -1035,8 +1023,8 @@
 mpeg1video_encoder_select="aandct"
 mpeg2video_encoder_select="aandct"
 mpeg4_encoder_select="aandct"
-mpeg_vdpau_decoder_deps="vdpau"
-mpeg1_vdpau_decoder_deps="vdpau"
+mpeg_vdpau_decoder_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
+mpeg1_vdpau_decoder_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
 mpeg_xvmc_decoder_deps="X11_extensions_XvMClib_h"
 msmpeg4v1_encoder_select="aandct"
 msmpeg4v2_encoder_select="aandct"
@@ -1059,7 +1047,7 @@
 tiff_decoder_suggest="zlib"
 tiff_encoder_suggest="zlib"
 tscc_decoder_select="zlib"
-vc1_vdpau_decoder_deps="vdpau"
+vc1_vdpau_decoder_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
 vorbis_decoder_select="fft mdct"
 vorbis_encoder_select="fft mdct"
 wmav1_decoder_select="fft mdct"
@@ -1068,7 +1056,7 @@
 wmav2_encoder_select="fft mdct"
 wmv1_encoder_select="aandct"
 wmv2_encoder_select="aandct"
-wmv3_vdpau_decoder_deps="vdpau"
+wmv3_vdpau_decoder_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
 zlib_decoder_select="zlib"
 zlib_encoder_select="zlib"
 zmbv_decoder_select="zlib"
@@ -1089,9 +1077,6 @@
 libgsm_ms_decoder_deps="libgsm"
 libgsm_ms_encoder_deps="libgsm"
 libmp3lame_encoder_deps="libmp3lame"
-libopencore_amrnb_decoder_deps="libopencore_amrnb"
-libopencore_amrnb_encoder_deps="libopencore_amrnb"
-libopencore_amrwb_decoder_deps="libopencore_amrwb"
 libopenjpeg_decoder_deps="libopenjpeg"
 libschroedinger_decoder_deps="libschroedinger"
 libschroedinger_encoder_deps="libschroedinger"
@@ -1100,8 +1085,6 @@
 libvorbis_encoder_deps="libvorbis"
 libx264_encoder_deps="libx264"
 libxvid_encoder_deps="libxvid"
-mpeg4aac_decoder_deps="libfaad"
-vdpau_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
 
 # demuxers / muxers
 ac3_demuxer_deps="ac3_parser"
@@ -1131,8 +1114,8 @@
 sdp_demuxer_deps="rtp_protocol mpegts_demuxer"
 v4l_demuxer_deps="linux_videodev_h"
 v4l2_demuxer_deps_any="linux_videodev2_h sys_videoio_h"
-vfwcap_demuxer_deps="capCreateCaptureWindow vfwcap_defines"
-vfwcap_demuxer_extralibs="-lavicap32"
+vfwcap_demuxer_deps="capCreateCaptureWindow"
+vfwcap_demuxer_extralibs="-lvfw32"
 x11_grab_device_demuxer_deps="x11grab XShmCreateImage"
 x11_grab_device_demuxer_extralibs="-lX11 -lXext"
 
@@ -1150,7 +1133,6 @@
 ffplay_deps="sdl"
 ffserver_deps="ffm_muxer rtp_protocol rtsp_demuxer"
 ffserver_extralibs='$ldl'
-vhook_extralibs='$ldl'
 
 
 # default parameters
@@ -1178,31 +1160,31 @@
 yasmexe="yasm"
 
 # machine
-arch=`uname -m`
+arch=$(uname -m)
 cpu="generic"
 
 # OS
 target_os=$(tolower $(uname -s))
+host_os=$target_os
 
 # configurable options
 enable debug
+enable fastdiv
 enable ffmpeg
 enable ffplay
 enable ffserver
 enable ipv6
 enable mpegaudio_hp
 enable network
-enable oldscaler
 enable optimizations
 enable protocols
 enable static
 enable stripping
-vhook="default"
+enable swscale_alpha
 
 # build settings
 add_cflags -D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112
 SHFLAGS='-shared -Wl,-soname,$$(@F)'
-VHOOKSHFLAGS='-shared -Wl,-soname,$$(@F)'
 FFSERVERLDFLAGS=-Wl,-E
 LIBPREF="lib"
 LIBSUF=".a"
@@ -1225,18 +1207,20 @@
 DEPEND_CMD='$(CC) $(CFLAGS) -MM $< | sed -e "/^\#.*/d" -e "s,^[[:space:]]*$(*F)\\.o,$(@D)/$(*F).o,"'
 
 # find source path
-source_path="`dirname \"$0\"`"
+source_path="$(dirname "$0")"
 enable source_path_used
 if test -z "$source_path" -o "$source_path" = "." ; then
-    source_path="`pwd`"
+    source_path="$(pwd)"
     disable source_path_used
 else
-    source_path="`cd \"$source_path\"; pwd`"
+    source_path="$(cd "$source_path"; pwd)"
     echo "$source_path" | grep -q '[[:blank:]]' &&
         die "Out of tree builds are impossible with whitespace in source path."
+    test -e "$source_path/config.h" &&
+        die "Out of tree builds are impossible with config.h in source dir."
 fi
 
-FFMPEG_CONFIGURATION="$@"
+FFMPEG_CONFIGURATION=`echo "$@" | sed -e 's,\",\\\",g'`
 
 find_things(){
     thing=$1
@@ -1295,14 +1279,14 @@
     --enable-debug=*) debuglevel="$optval"
     ;;
     --enable-*=*|--disable-*=*)
-    eval `echo "$opt" | sed 's/=/-/;s/--/action=/;s/-/ thing=/;s/-/ name=/'`
+    eval $(echo "$opt" | sed 's/=/-/;s/--/action=/;s/-/ thing=/;s/-/ name=/')
     case "$thing" in
         encoder|decoder|muxer|demuxer|parser|bsf|protocol|filter) $action ${optval}_${thing} ;;
         *) die_unknown "$opt" ;;
     esac
     ;;
     --enable-?*|--disable-?*)
-    eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'`
+    eval $(echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g')
     if is_in $option $COMPONENT_LIST; then
         eval $action \$$(toupper ${option%s})_LIST
     elif is_in $option $CMDLINE_SELECT; then
@@ -1345,19 +1329,24 @@
 sysinclude_default="${sysroot}/usr/include"
 
 set_default cc nm sysinclude
+as_default=$cc
 enabled cross_compile || host_cc_default=$cc
 set_default host_cc
 
-case $target_os in
-    mingw32*|cygwin*|*-dos|freedos|opendos|os/2*) EXESUF=.exe ;;
-esac
+exesuf() {
+    case $1 in
+        mingw32*|cygwin*|*-dos|freedos|opendos|os/2*) echo .exe ;;
+    esac
+}
+
+EXESUF=$(exesuf $target_os)
+HOSTEXESUF=$(exesuf $host_os)
 
 # set temporary file name
 : ${TMPDIR:=$TEMPDIR}
 : ${TMPDIR:=$TMP}
 : ${TMPDIR:=/tmp}
 
-
 if ! check_cmd type mktemp; then
     # simple replacement for missing mktemp
     # NOT SAFE FOR GENERAL USE
@@ -1366,7 +1355,6 @@
     }
 fi
 
-
 tmpfile(){
     tmp=$(mktemp -u "${TMPDIR}/ffconf.XXXXXXXX")$2 &&
         (set -C; exec > $tmp) 2>/dev/null ||
@@ -1383,7 +1371,6 @@
 tmpfile TMPH  .h
 tmpfile TMPO  .o
 tmpfile TMPS  .S
-tmpfile TMPV  .ver
 tmpfile TMPSH .sh
 
 unset -f mktemp
@@ -1410,11 +1397,25 @@
 elif $cc -V 2>/dev/null | grep -q Compaq; then
     cc_type=ccc
     DEPEND_CMD='$(CC) $(CFLAGS) -M $< | sed -e "/^\#.*/d" -e "s,^[[:space:]]*$(*F)\\.o,$(@D)/$(*F).o,"'
+    debuglevel=3
     add_ldflags -Wl,-z,now # calls to libots crash without this
+elif $cc --vsn 2>/dev/null | grep -q RVCT; then
+    test -d "$sysroot" || die "No valid sysroot specified."
+    cc_type=armcc
+    armcc_conf="$PWD/armcc.conf"
+    $cc --arm_linux_configure                 \
+        --arm_linux_config_file="$armcc_conf" \
+        --configure_sysroot="$sysroot"        \
+        --configure_cpp_headers="$sysinclude" >>$logfile 2>&1 ||
+        die "Error creating armcc configuration file."
+    cc="$cc --arm_linux_config_file=$armcc_conf --translate_gcc"
+    as_default="${cross_prefix}gcc"
 fi
 
 test -n "$cc_type" && enable $cc_type || echolog "Unknown C compiler $cc"
 
+set_default as
+
 if test -n "$sysroot"; then
     case "$cc_type" in
         gcc)
@@ -1438,6 +1439,12 @@
 fi
 
 check_cflags -std=c99
+check_cc -D_FILE_OFFSET_BITS=64 <<EOF && add_cflags -D_FILE_OFFSET_BITS=64
+#include <stdlib.h>
+EOF
+check_cc -D_LARGEFILE_SOURCE <<EOF && add_cflags -D_LARGEFILE_SOURCE
+#include <stdlib.h>
+EOF
 
 case "$arch" in
     alpha)
@@ -1526,7 +1533,7 @@
         # helps building libavcodec
         add_cflags -DPIC -fomit-frame-pointer
         # 3 gcc releases known for BeOS, each with ugly bugs
-        gcc_version="`$cc -v 2>&1 | grep version | cut -d ' ' -f3-`"
+        gcc_version="$($cc -v 2>&1 | grep version | cut -d ' ' -f3-)"
         case "$gcc_version" in
           2.9-beos-991026*|2.9-beos-000224*) echo "R5/GG gcc"
             disable mmx
@@ -1574,7 +1581,6 @@
     darwin)
         disable need_memalign
         SHFLAGS='-dynamiclib -Wl,-single_module -Wl,-install_name,$(SHLIBDIR)/$(SLIBNAME),-current_version,$(LIBVERSION),-compatibility_version,$(LIBMAJOR) -Wl,-read_only_relocs,suppress'
-        VHOOKSHFLAGS='-dynamiclib -Wl,-single_module -flat_namespace -undefined suppress -Wl,-install_name,$(SHLIBDIR)/vhook/$$(@F)'
         strip="strip -x"
         FFLDFLAGS="-Wl,-dynamic,-search_paths_first"
         SLIBSUF=".dylib"
@@ -1592,38 +1598,29 @@
             LIBTARGET=x64
         fi
         shlibdir_default="$bindir_default"
-        VHOOKSHFLAGS='-shared -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil'
-        VHOOKLIBS='-lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)'
-        if enabled swscale; then
-            VHOOKSHFLAGS="$VHOOKSHFLAGS -L\$(BUILD_ROOT)/libswscale"
-            VHOOKLIBS="$VHOOKLIBS -lswscale\$(BUILDSUF)"
-        fi
         disable ffserver
         SLIBPREF=""
         SLIBSUF=".dll"
         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
         SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
-        SLIB_EXTRA_CMD='-lib /machine:$(LIBTARGET) /def:$$(@:$(SLIBSUF)=.def) /out:$(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)'
+        SLIB_EXTRA_CMD='-lib.exe /machine:$(LIBTARGET) /def:$$(@:$(SLIBSUF)=.def) /out:$(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)'
         SLIB_INSTALL_EXTRA_CMD='-install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"; \
             install -m 644 $(SUBDIR)$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib) "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR:$(SLIBSUF)=.lib)"'
         SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(SHLIBDIR)/$(SLIBNAME:$(SLIBSUF)=.lib)"'
         SHFLAGS='-shared -Wl,--output-def,$$(@:$(SLIBSUF)=.def) -Wl,--enable-runtime-pseudo-reloc -Wl,--enable-auto-image-base'
         objformat="win32"
         enable dos_paths
-        check_cflags -fno-common
-        check_cpp_condition _mingw.h "defined (__MINGW64_VERSION_MAJOR) || (__MINGW32_MAJOR_VERSION > 3) \
-                                      || (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" ||
+        if ! enabled x86_64; then
+            check_cpp_condition _mingw.h "(__MINGW32_MAJOR_VERSION > 3) || (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" ||
                 die "ERROR: MinGW runtime version must be >= 3.15."
+            enabled_any avisynth vfwcap_demuxer &&
+                { check_cpp_condition w32api.h "(__W32API_MAJOR_VERSION > 3) || (__W32API_MAJOR_VERSION == 3 && __W32API_MINOR_VERSION >= 13)" ||
+                  die "ERROR: avisynth and vfwcap_demuxer require w32api version 3.13 or later."; }
+            fi
         ;;
     cygwin*)
         target_os=cygwin
         shlibdir_default="$bindir_default"
-        VHOOKSHFLAGS='-shared -L$(BUILD_ROOT)/libavformat -L$(BUILD_ROOT)/libavcodec -L$(BUILD_ROOT)/libavutil'
-        VHOOKLIBS='-lavformat$(BUILDSUF) -lavcodec$(BUILDSUF) -lavutil$(BUILDSUF) $(EXTRALIBS)'
-        if enabled swscale; then
-            VHOOKSHFLAGS="$VHOOKSHFLAGS -L\$(BUILD_ROOT)/libswscale"
-            VHOOKLIBS="$VHOOKLIBS -lswscale\$(BUILDSUF)"
-        fi
         SLIBPREF="cyg"
         SLIBSUF=".dll"
         SLIBNAME_WITH_VERSION='$(SLIBPREF)$(FULLNAME)-$(LIBVERSION)$(SLIBSUF)'
@@ -1631,10 +1628,9 @@
         SHFLAGS='-shared -Wl,--enable-auto-image-base'
         objformat="win32"
         enable dos_paths
-        check_cflags -fno-common
         ;;
     *-dos|freedos|opendos)
-        disable ffplay ffserver vhook
+        disable ffplay ffserver
         disable $INDEV_LIST $OUTDEV_LIST
         network_extralibs="-lsocket"
         objformat="coff"
@@ -1668,17 +1664,8 @@
           emximp -o $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib $(SUBDIR)$(NAME).def;'
         SLIB_INSTALL_EXTRA_CMD='install -m 644 $(SUBDIR)$(LIBPREF)$(NAME)_dll.a $(SUBDIR)$(LIBPREF)$(NAME)_dll.lib "$(LIBDIR)"'
         SLIB_UNINSTALL_EXTRA_CMD='rm -f "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.a "$(LIBDIR)"/$(LIBPREF)$(NAME)_dll.lib'
-        disable vhook
         enable dos_paths
         ;;
-    interix)
-        disable vhook
-        ;;
-    gnu/kfreebsd)
-        ;;
-    gnu)
-        disable dv1394
-        ;;
 
     *)
         die "Unknown OS '$target_os'."
@@ -1721,24 +1708,22 @@
 fi
 
 
-die_license_disabled() {
-    enabled $1 || { enabled $2 && die "$2 is $1 and --enable-$1 is not specified."; }
-}
+if ! enabled gpl; then
+    die_gpl_disabled(){
+        name=$1
+        shift
+        enabled_any $@ && die "$name is under GPL and --enable-gpl is not specified."
+    }
+    die_gpl_disabled "The Postprocessing code" postproc
+    die_gpl_disabled "libx264"                 libx264
+    die_gpl_disabled "libxvidcore"             libxvid
+    die_gpl_disabled "FAAD2"                   libfaad2
+    die_gpl_disabled "The X11 grabber"         x11grab
+fi
 
-die_license_disabled gpl libfaad2
-die_license_disabled gpl libx264
-die_license_disabled gpl libxvid
-die_license_disabled gpl postproc
-die_license_disabled gpl x11grab
-
-die_license_disabled nonfree libamr_nb
-die_license_disabled nonfree libamr_wb
-die_license_disabled nonfree libfaac
-
-die_license_disabled version3 libopencore_amrnb
-die_license_disabled version3 libopencore_amrwb
-
-enabled version3 && { enabled gpl && enable gplv3 || enable lgplv3; }
+if ! enabled nonfree && enabled_any libamr_nb libamr_wb; then
+    die "libamr is nonfree and --enable-nonfree is not specified."
+fi
 
 check_deps $ARCH_EXT_LIST
 
@@ -1843,7 +1828,9 @@
 sym=$($nm -P -g $TMPO | grep ff_extern)
 extern_prefix=${sym%%ff_extern*}
 
-check_asm inline_asm '""'
+check_cc <<EOF && enable inline_asm
+void foo(void) { __asm__ volatile ("" ::); }
+EOF
 
 if enabled x86; then
     # check whether EBP is available on x86
@@ -1875,7 +1862,7 @@
 
     # check whether binutils is new enough to compile SSSE3/MMX2
     enabled ssse3 && check_asm ssse3 '"pabsw %xmm0, %xmm0"'
-    enabled mmx2  && check_asm mmx2  '"movss %xmm0, %xmm0"'
+    enabled mmx2  && check_asm mmx2  '"pmaxub %mm0, %mm1"'
 
     check_asm bswap '"bswap %%eax" ::: "%eax"'
 
@@ -1961,6 +1948,7 @@
 check_func  posix_memalign
 check_func_headers io.h setmode
 check_func_headers windows.h GetProcessTimes
+check_func_headers windows.h VirtualAlloc
 
 check_header conio.h
 check_header dlfcn.h
@@ -2009,6 +1997,7 @@
 
 check_lib math.h sin -lm
 
+
 # test for C99 functions in math.h
 for func in llrint lrint lrintf round roundf truncf; do
     check_exec <<EOF && enable $func || disable $func
@@ -2018,7 +2007,7 @@
 done
 
 # these are off by default, so fail if requested and not available
-enabled avisynth   && require2 vfw32 "windows.h vfw.h" AVIFileInit -lavifil32
+enabled avisynth   && require2 vfw32 "windows.h vfw.h" AVIFileInit -lvfw32
 enabled libamr_nb  && require  libamrnb amrnb/interf_dec.h Speech_Decode_Frame_init -lamrnb -lm
 enabled libamr_wb  && require  libamrwb amrwb/dec_if.h D_IF_init -lamrwb -lm
 enabled libdirac   && add_cflags $(pkg-config --cflags dirac) &&
@@ -2029,20 +2018,21 @@
 enabled libgsm     && require  libgsm gsm.h gsm_create -lgsm
 enabled libmp3lame && require  libmp3lame lame/lame.h lame_init -lmp3lame -lm
 enabled libnut     && require  libnut libnut.h nut_demuxer_init -lnut
-enabled libopencore_amrnb  && require libopencore_amrnb opencore-amrnb/interf_dec.h Decoder_Interface_init -lopencore-amrnb -lm
-enabled libopencore_amrwb  && require libopencore_amrwb opencore-amrwb/dec_if.h D_IF_init -lopencore-amrwb -lm
 enabled libopenjpeg && require libopenjpeg openjpeg.h opj_version -lopenjpeg
 enabled libschroedinger && add_cflags $(pkg-config --cflags schroedinger-1.0) &&
                            require libschroedinger schroedinger/schro.h schro_init $(pkg-config --libs schroedinger-1.0)
 enabled libspeex   && require  libspeex speex/speex.h speex_decoder_init -lspeex
 enabled libtheora  && require  libtheora theora/theora.h theora_info_init -ltheora -logg
 enabled libvorbis  && require  libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
-enabled libx264    && require  libx264 x264.h x264_encoder_encode -lx264 -lm &&
+enabled libx264    && require  libx264 x264.h x264_encoder_open -lx264 -lm &&
                       { check_cpp_condition x264.h "X264_BUILD >= 65" ||
                         die "ERROR: libx264 version must be >= 0.65."; }
 enabled libxvid    && require  libxvid xvid.h xvid_global -lxvidcore
 enabled mlib       && require  mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
 
+# disable oggivorbis decoder if it's not available
+disabled oggivorbis_decoder || check_header ivorbiscodec.h || disable oggivorbis_decoder
+
 # libdc1394 check
 if enabled libdc1394; then
     { check_lib dc1394/dc1394.h dc1394_new -ldc1394 -lraw1394 &&
@@ -2060,24 +2050,6 @@
 EOF
 done
 
-test "$vhook" = "default" && vhook="$dlopen"
-
-if test "$target_os" = cygwin -o "$target_os" = mingw32 && enabled_all static vhook ; then
-    disable vhook
-    echo
-    echo "At the moment vhooks don't work on Cygwin or MinGW static builds."
-    echo "Patches welcome."
-    echo
-fi
-
-if enabled vhook; then
-    check_ldflags -rdynamic
-    check_ldflags -export-dynamic
-fi
-
-check_foo_config imlib2 imlib2 Imlib2.h imlib_load_font
-check_foo_config freetype2 freetype ft2build.h FT_Init_FreeType
-
 ##########################################
 # SDL check
 
@@ -2085,11 +2057,11 @@
 disable sdl
 SDL_CONFIG="${cross_prefix}sdl-config"
 if "${SDL_CONFIG}" --version > /dev/null 2>&1; then
-    sdl_cflags=`"${SDL_CONFIG}" --cflags`
+    sdl_cflags=$("${SDL_CONFIG}" --cflags)
     temp_cflags $sdl_cflags
-    temp_extralibs `"${SDL_CONFIG}" --libs`
+    temp_extralibs $("${SDL_CONFIG}" --libs)
     if check_lib2 SDL.h SDL_Init; then
-        _sdlversion=`"${SDL_CONFIG}" --version | sed 's/[^0-9]//g'`
+        _sdlversion=$("${SDL_CONFIG}" --version | sed 's/[^0-9]//g')
         if test "$_sdlversion" -lt 121 ; then
             enable sdl_too_old
         else
@@ -2145,10 +2117,7 @@
 check_header linux/videodev2.h
 check_header sys/videoio.h
 
-check_func_headers "windows.h vfw.h" capCreateCaptureWindow -lavicap32
-# check that WM_CAP_DRIVER_CONNECT is defined to the proper value
-# w32api 3.12 had it defined wrong
-check_cpp_condition vfw.h "WM_CAP_DRIVER_CONNECT > WM_USER" && enable vfwcap_defines
+check_func_headers "windows.h vfw.h" capCreateCaptureWindow -lvfw32
 
 # check for ioctl_meteor.h, ioctl_bt848.h and alternatives
 { check_header dev/bktr/ioctl_meteor.h &&
@@ -2193,10 +2162,6 @@
 check_ldflags '-Wl,-rpath-link,\$(BUILD_ROOT)/libpostproc -Wl,-rpath-link,\$(BUILD_ROOT)/libswscale -Wl,-rpath-link,\$(BUILD_ROOT)/libavfilter -Wl,-rpath-link,\$(BUILD_ROOT)/libavdevice -Wl,-rpath-link,\$(BUILD_ROOT)/libavformat -Wl,-rpath-link,\$(BUILD_ROOT)/libavcodec -Wl,-rpath-link,\$(BUILD_ROOT)/libavutil'
 check_ldflags -Wl,-Bsymbolic
 
-echo "X{};" > $TMPV
-test_ldflags -Wl,--version-script,$TMPV &&
-    append SHFLAGS '-Wl,--version-script,\$(SUBDIR)lib\$(NAME).ver'
-
 if enabled small; then
     check_cflags -Os            # not all compilers support -Os
     optimizations="small"
@@ -2227,6 +2192,8 @@
     check_ldflags -wd10156,11030
     # Allow to compile with optimizations
     check_ldflags -march=$cpu
+    # icc 11.0 and 11.1 work with ebp_available, but don't pass the test
+    enable ebp_available
 elif enabled ccc; then
     # disable some annoying warnings
     add_cflags -msg_disable cvtu32to64
@@ -2242,7 +2209,7 @@
     # LIBOBJFLAGS may have already been set in the OS configuration
     if test -z "$LIBOBJFLAGS" ; then
         case "${subarch-$arch}" in
-            x86_64|ia64|alpha|sparc*|ppc|power*|parisc*|mips*) LIBOBJFLAGS='$(PIC)' ;;
+            x86_64|ia64|alpha|sparc*|power*|parisc*|mips*) LIBOBJFLAGS='$(PIC)' ;;
         esac
     fi
 fi
@@ -2252,8 +2219,6 @@
     add_ldflags -p
 fi
 
-VHOOKCFLAGS="-fPIC"
-
 # Find out if the .align argument is a power of two or not.
 check_asm asmalign_pot '".align 3"'
 
@@ -2295,7 +2260,6 @@
     echo "version string suffix     $extra_version"
 fi
 echo "big-endian                ${bigendian-no}"
-echo "runtime cpu detection     ${runtime_cpudetect-no}"
 if enabled x86; then
     echo "yasm                      ${yasm-no}"
     echo "MMX enabled               ${mmx-no}"
@@ -2337,14 +2301,8 @@
 echo "static                    ${static-no}"
 echo "shared                    ${shared-no}"
 echo "postprocessing support    ${postproc-no}"
-echo "software scaler enabled   ${swscale-no}"
 echo "new filter support        ${avfilter-no}"
 echo "filters using lavformat   ${avfilter_lavf-no}"
-echo "video hooking             ${vhook-no}"
-if enabled vhook; then
-    echo "Imlib2 support            ${imlib2-no}"
-    echo "FreeType support          ${freetype2-no}"
-fi
 echo "network support           ${network-no}"
 if enabled network; then
     echo "IPv6 support              ${ipv6-no}"
@@ -2366,8 +2324,6 @@
 echo "libgsm enabled            ${libgsm-no}"
 echo "libmp3lame enabled        ${libmp3lame-no}"
 echo "libnut enabled            ${libnut-no}"
-echo "libopencore-amrnb support ${libopencore_amrnb-no}"
-echo "libopencore-amrwb support ${libopencore_amrwb-no}"
 echo "libopenjpeg enabled       ${libopenjpeg-no}"
 echo "libschroedinger enabled   ${libschroedinger-no}"
 echo "libspeex enabled          ${libspeex-no}"
@@ -2375,7 +2331,6 @@
 echo "libvorbis enabled         ${libvorbis-no}"
 echo "libx264 enabled           ${libx264-no}"
 echo "libxvid enabled           ${libxvid-no}"
-echo "vdpau enabled             ${vdpau-no}"
 echo "zlib enabled              ${zlib-no}"
 echo "bzlib enabled             ${bzlib-no}"
 echo
@@ -2389,15 +2344,11 @@
     echo
 done
 
-license="LGPL version 2.1 or later"
+license="LGPL"
 if enabled nonfree; then
-    license="nonfree and unredistributable"
-elif enabled gplv3; then
-    license="GPL version 3 or later"
-elif enabled lgplv3; then
-    license="LGPL version 3 or later"
+    license="unredistributable"
 elif enabled gpl; then
-    license="GPL version 2 or later"
+    license="GPL"
 fi
 
 echo "License: $license"
@@ -2419,7 +2370,11 @@
 echo "BINDIR=\$(DESTDIR)$bindir" >> config.mak
 echo "DATADIR=\$(DESTDIR)$datadir" >> config.mak
 echo "MANDIR=\$(DESTDIR)$mandir" >> config.mak
+echo "SRC_PATH=\"$source_path\"" >> config.mak
+echo "SRC_PATH_BARE=$source_path" >> config.mak
+echo "BUILD_ROOT=\"$PWD\"" >> config.mak
 echo "CC=$cc" >> config.mak
+echo "AS=$as" >> config.mak
 echo "YASM=$yasmexe" >> config.mak
 echo "AR=$ar" >> config.mak
 echo "RANLIB=$ranlib" >> config.mak
@@ -2429,13 +2384,10 @@
     echo "STRIP=echo ignoring strip" >> config.mak
 
 echo "OPTFLAGS=$CFLAGS" >> config.mak
-echo "VHOOKCFLAGS=$VHOOKCFLAGS" >> config.mak
 echo "LDFLAGS=$LDFLAGS" >> config.mak
 echo "FFSERVERLDFLAGS=$FFSERVERLDFLAGS" >> config.mak
 echo "SHFLAGS=$SHFLAGS" >> config.mak
 echo "YASMFLAGS=$YASMFLAGS" >> config.mak
-echo "VHOOKSHFLAGS=$VHOOKSHFLAGS" >> config.mak
-echo "VHOOKLIBS=$VHOOKLIBS" >> config.mak
 echo "LIBOBJFLAGS=$LIBOBJFLAGS" >> config.mak
 echo "BUILD_STATIC=$static" >> config.mak
 echo "BUILDSUF=$build_suffix" >> config.mak
@@ -2450,6 +2402,7 @@
 echo "DEPEND_CMD=$DEPEND_CMD" >> config.mak
 echo "HOSTCC=$host_cc" >> config.mak
 echo "HOSTCFLAGS=$host_cflags" >> config.mak
+echo "HOSTEXESUF=$HOSTEXESUF" >> config.mak
 echo "HOSTLDFLAGS=$host_ldflags" >> config.mak
 echo "HOSTLIBS=$host_libs" >> config.mak
 echo "TARGET_EXEC=$target_exec" >> config.mak
@@ -2461,8 +2414,8 @@
 fi
 
 if enabled sdl; then
-    echo "SDL_LIBS=`"${SDL_CONFIG}" --libs`" >> config.mak
-    echo "SDL_CFLAGS=`"${SDL_CONFIG}" --cflags`" >> config.mak
+    echo "SDL_LIBS=$("${SDL_CONFIG}" --libs)" >> config.mak
+    echo "SDL_CFLAGS=$("${SDL_CONFIG}" --cflags)" >> config.mak
 fi
 if enabled texi2html; then
     echo "BUILD_DOC=yes" >> config.mak
@@ -2524,9 +2477,6 @@
     echo "#define av_always_inline"  >> $TMPH
 fi
 
-echo "SRC_PATH=\"$source_path\"" >> config.mak
-echo "SRC_PATH_BARE=$source_path" >> config.mak
-echo "BUILD_ROOT=\"$PWD\"" >> config.mak
 
 # Apparently it's not possible to portably echo a backslash.
 enabled asmalign_pot &&
@@ -2561,9 +2511,13 @@
         libavutil         \
         libpostproc       \
         libswscale        \
+        libswscale/bfin   \
+        libswscale/mlib   \
+        libswscale/ppc    \
+        libswscale/sparc  \
+        libswscale/x86    \
         tests             \
         tools             \
-        vhook             \
         "
     FILES="\
         Makefile             \
@@ -2636,9 +2590,4 @@
     pkgconfig_generate libavfilter "FFmpeg video filtering library" "$LIBAVFILTER_VERSION" "$extralibs" "libavutil = $LIBAVUTIL_VERSION"
 enabled postproc &&
     pkgconfig_generate libpostproc "FFmpeg post processing library" "$LIBPOSTPROC_VERSION"
-if enabled swscale; then
-    pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "" "libavutil = $LIBAVUTIL_VERSION"
-else
-    pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "" "libavcodec = $LIBAVCODEC_VERSION"
-    apply libswscale/libswscale.pc sed s/^Libs:.*$/Libs:/
-fi
+pkgconfig_generate libswscale "FFmpeg image rescaling library" "$LIBSWSCALE_VERSION" "" "libavutil = $LIBAVUTIL_VERSION"
diff --git a/doc/APIchanges b/doc/APIchanges
index db7e245..2d93dd7 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -1,15 +1,36 @@
-20090601 - r19025 - lavc 52.30.0 - av_lockmgr_register()
-  av_lockmgr_register() can be used to register a callback function
-  that lavc (and in the future, libraries that depend on lavc) can use
-  to implement mutexes. The application should provide a callback function
-  the implements the AV_LOCK_* operations described in avcodec.h.
-  When the lock manager is registered FFmpeg is guaranteed to behave
-  correct also in a multi-threaded application.
+Never assume the API of libav* to be stable unless at least 1 week has passed since
+the last major version increase.
+The last version increases were:
+libavcodec:  ?
+libavdevice: ?
+libavfilter: ?
+libavformat: ?
+libpostproc: ?
+libswscale:  ?
+libavutil:   2009-03-08
 
-20090301 - r17682 - lavf 52.31.0 - Generic metadata API
-  This version introduce a new metadata API (see av_metadata_get() and friends).
-  The old API is now deprecated and shouldn't be used anymore. This especially
-  include the following structure fields:
+
+API changes, most recent first:
+
+2009-03-21 - r18116 - lavu 50.2.0  - av_random*
+  The Mersenne Twister PRNG implemented through the av_random* functions
+  was removed. Use the lagged Fibonacci PRNG through the av_lfg* functions
+  instead.
+
+
+2009-03-08 - r17869 - lavu 50.0.0  - AVFifoBuffer
+  av_fifo_init, av_fifo_read, av_fifo_write and av_fifo_realloc were dropped
+  and replaced by av_fifo_alloc, av_fifo_generic_read, av_fifo_generic_write
+  and av_fifo_realloc2.
+  In addition, the order of the function arguments of av_fifo_generic_read
+  were changed to match av_fifo_generic_write.
+  The AVFifoBuffer/struct AVFifoBuffer may only be used in an opaque way by
+  applications, they may not use sizeof() or directly access members.
+
+2009-03-01 - r17682 - lavf 52.31.0 - Generic metadata API
+  Introduce a new metadata API (see av_metadata_get() and friends).
+  The old API is now deprecated and should not be used anymore. This especially
+  includes the following structure fields:
     - AVFormatContext.title
     - AVFormatContext.author
     - AVFormatContext.copyright
diff --git a/doc/TODO b/doc/TODO
old mode 100644
new mode 100755
index f03270e..6c0a824
--- a/doc/TODO
+++ b/doc/TODO
@@ -81,6 +81,7 @@
 - add support for using mplayers video filters to ffmpeg
 - H264 encoder
 - per MB ratecontrol (so VCD and such do work better)
+- replace/rewrite libavcodec/fdctref.c
 - write a script which iteratively changes all functions between always_inline and noinline and benchmarks the result to find the best set of inlined functions
 - convert all the non SIMD asm into small asm vs. C testcases and submit them to the gcc devels so they can improve gcc
 - generic audio mixing API
diff --git a/doc/avutil.txt b/doc/avutil.txt
old mode 100644
new mode 100755
diff --git a/doc/ffmpeg-doc.texi b/doc/ffmpeg-doc.texi
index 536e0fa..b111450 100644
--- a/doc/ffmpeg-doc.texi
+++ b/doc/ffmpeg-doc.texi
@@ -282,16 +282,29 @@
 Specifying a positive offset means that the corresponding
 streams are delayed by 'offset' seconds.
 
+@item -title @var{string}
+Set the title.
+
 @item -timestamp @var{time}
 Set the timestamp.
 
-@item -metadata @var{key}=@var{value}
-Set a metadata key/value pair.
+@item -author @var{string}
+Set the author.
 
-For example, for setting the title in the output file:
-@example
-ffmpeg -i in.avi -metadata title="my title" out.flv
-@end example
+@item -copyright @var{string}
+Set the copyright.
+
+@item -comment @var{string}
+Set the comment.
+
+@item -album @var{string}
+Set the album.
+
+@item -track @var{number}
+Set the track.
+
+@item -year @var{number}
+Set the year.
 
 @item -v @var{number}
 Set the logging verbosity level.
@@ -653,9 +666,6 @@
 Dump video coding statistics to @file{vstats_HHMMSS.log}.
 @item -vstats_file @var{file}
 Dump video coding statistics to @var{file}.
-@item -vhook @var{module}
-Insert video processing @var{module}. @var{module} contains the module
-name and its parameters separated by spaces.
 @item -top @var{n}
 top=1/bottom=0/auto=-1 field first
 @item -dc @var{precision}
@@ -680,8 +690,6 @@
 Set the audio sampling frequency (default = 44100 Hz).
 @item -ab @var{bitrate}
 Set the audio bitrate in bit/s (default = 64k).
-@item -aq @var{q}
-Set the audio quality (codec-specific, VBR).
 @item -ac @var{channels}
 Set the number of audio channels (default = 1).
 @item -an
@@ -723,8 +731,6 @@
 Add a new subtitle stream to the current output stream.
 @item -slang @var{code}
 Set the ISO 639 language code (3 letters) of the current subtitle stream.
-@item -sn
-Disable subtitle recording.
 @item -sbsf @var{bitstream_filter}
 Bitstream filters available are "mov2textsub", "text2movsub".
 @example
diff --git a/doc/ffmpeg_powerpc_performance_evaluation_howto.txt b/doc/ffmpeg_powerpc_performance_evaluation_howto.txt
old mode 100644
new mode 100755
diff --git a/doc/ffplay-doc.texi b/doc/ffplay-doc.texi
old mode 100644
new mode 100755
diff --git a/doc/ffserver-doc.texi b/doc/ffserver-doc.texi
old mode 100644
new mode 100755
diff --git a/doc/ffserver.conf b/doc/ffserver.conf
old mode 100644
new mode 100755
diff --git a/doc/general.texi b/doc/general.texi
index fc7b06d..6a14b17 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -18,22 +18,7 @@
 
 AMR comes in two different flavors, wideband and narrowband. FFmpeg can make
 use of the AMR wideband (floating-point mode) and the AMR narrowband
-(floating-point mode) reference decoders and encoders (libamr) as well as
-the OpenCORE libraries for AMR-NB decoding/encoding and AMR-WB decoding.
-
-@subsection OpenCORE
-
-Go to @url{http://gitorious.org/opencore-amr/} and follow the instructions for
-installing the libraries. Then pass @code{--enable-libopencore-amrnb} and/or
-@code{--enable-libopencore-amrwb} to configure to enable the libraries.
-
-Note that OpenCORE is under the Apache License 2.0 (see
-@url{http://www.apache.org/licenses/LICENSE-2.0} for details), which is
-incompatible with the LGPL version 2.1 and GPL version 2. You have to
-upgrade FFmpeg's license to LGPL version 3 (or if you have enabled
-GPL components, GPL version 3) to use it.
-
-@subsection libamr
+(floating-point mode) reference decoders and encoders.
 
 Go to @url{http://www.penguin.cz/~utx/amr} and follow the instructions for
 installing the libraries. Then pass @code{--enable-libamr-nb} and/or
@@ -144,6 +129,8 @@
     @tab SMPTE 386M, D-10/IMX Mapping.
 @item NC camera feed            @tab   @tab X
     @tab NC (AVIP NC4600) camera streams
+@item NTT TwinVQ (VQF)          @tab   @tab X
+    @tab Nippon Telegraph and Telephone Corporation TwinVQ.
 @item Nullsoft Streaming Video  @tab   @tab X
 @item NuppelVideo               @tab   @tab X
 @item NUT                       @tab X @tab X
@@ -175,6 +162,7 @@
 @item raw video                 @tab X @tab X
 @item raw id RoQ                @tab X @tab
 @item raw Shorten               @tab   @tab X
+@item raw TrueHD                @tab X @tab X
 @item raw VC-1                  @tab   @tab X
 @item raw PCM A-law             @tab X @tab X
 @item raw PCM mu-law            @tab X @tab X
@@ -263,7 +251,7 @@
     @tab PAM is a PNM extension with alpha support.
 @item PBM          @tab X @tab X
     @tab Portable BitMap image
-@item PCX          @tab   @tab X
+@item PCX          @tab X @tab X
     @tab PC Paintbrush
 @item PGM          @tab X @tab X
     @tab Portable GrayMap image
@@ -526,10 +514,9 @@
     @tab Used in Westwood Studios games like Command and Conquer.
 @item ADPCM Yamaha           @tab  X  @tab  X
 @item AMR-NB                 @tab  E  @tab  E
-    @tab supported through external libraries libamrnb and libopencore-amrnb
+    @tab supported through external library libamrnb
 @item AMR-WB                 @tab  E  @tab  E
-    @tab decoding supported through external libraries libamrwb and libopencore-amrwb,
-         encoding supported through external library libamrwb
+    @tab supported through external library libamrwb
 @item Apple lossless audio   @tab  X  @tab  X
     @tab QuickTime fourcc 'alac'
 @item Atrac 3                @tab     @tab  X
@@ -558,8 +545,8 @@
 @item IMC (Intel Music Coder)  @tab     @tab  X
 @item MACE (Macintosh Audio Compression/Expansion) 3:1  @tab     @tab  X
 @item MACE (Macintosh Audio Compression/Expansion) 6:1  @tab     @tab  X
-@item MLP(Meridian Lossless Packing)/TrueHD  @tab     @tab  X
-    @tab Used in DVD-Audio and Blu-Ray discs.
+@item MLP (Meridian Lossless Packing)  @tab     @tab  X
+    @tab Used in DVD-Audio discs.
 @item Monkey's Audio         @tab     @tab  X
     @tab Only versions 3.97-3.99 are supported.
 @item MP1 (MPEG audio layer 1)  @tab     @tab IX
@@ -612,6 +599,8 @@
 @item Speex                  @tab     @tab  E
     @tab supported through external library libspeex
 @item True Audio (TTA)       @tab     @tab  X
+@item TrueHD                 @tab     @tab  X
+    @tab Used in HD-DVD and Blu-Ray discs.
 @item Vorbis                 @tab  E  @tab  X
     @ A native but very primitive encoder exists.
 @item WavPack                @tab     @tab  X
@@ -630,7 +619,7 @@
 
 @section Subtitle Formats
 
-@multitable @columnfractions .4 .1 .1 .1 .1 .1
+@multitable @columnfractions .4 .1 .1 .1 .1
 @item Name @tab Muxing @tab Demuxing @tab Encoding @tab Decoding
 @item SSA/ASS      @tab X @tab X
 @item DVB          @tab X @tab X @tab X @tab X
@@ -642,7 +631,7 @@
 
 @section Network Protocols
 
-@multitable @columnfractions .4 .1 .1 .1 .1 .1
+@multitable @columnfractions .4 .1
 @item Name         @tab Support
 @item file         @tab X
 @item Gopher       @tab X
@@ -656,6 +645,25 @@
 @code{X} means that the protocol is supported.
 
 
+@section Input/Output Devices
+
+@multitable @columnfractions .4 .1 .1
+@item Name              @tab Input  @tab Output
+@item ALSA              @tab X      @tab X
+@item BEOS audio        @tab X      @tab X
+@item BKTR              @tab X      @tab
+@item DV1394            @tab X      @tab
+@item LIBDC1394         @tab X      @tab
+@item OSS               @tab X      @tab X
+@item Video4Linux       @tab X      @tab
+@item Video4Linux2      @tab X      @tab
+@item VfW capture       @tab X      @tab
+@item X11 grabbing      @tab X      @tab
+@end multitable
+
+@code{X} means that input/output is supported.
+
+
 @chapter Platform Specific information
 
 @section BSD
@@ -707,10 +715,6 @@
 
 @itemize
 
-@item In order to compile vhooks, you must have a POSIX-compliant libdl in
-your MinGW system. Get dlfcn-win32 from
-@url{http://code.google.com/p/dlfcn-win32}.
-
 @item In order to compile FFplay, you must have the MinGW development library
 of SDL. Get it from @url{http://www.libsdl.org}.
 Edit the @file{bin/sdl-config} script so that it points to the correct prefix
diff --git a/doc/hooks.texi b/doc/hooks.texi
deleted file mode 100644
index c410f1c..0000000
--- a/doc/hooks.texi
+++ /dev/null
@@ -1,299 +0,0 @@
-\input texinfo @c -*- texinfo -*-
-
-@settitle Video Hook Documentation
-@titlepage
-@sp 7
-@center @titlefont{Video Hook Documentation}
-@sp 3
-@end titlepage
-
-
-@chapter Introduction
-
-@var{Please be aware that vhook is deprecated, and hence its development is
-frozen (bug fixes are still accepted).
-The substitute will be 'libavfilter', the result of our 'Video Filter API'
-Google Summer of Code project. You may monitor its progress by subscribing to
-the ffmpeg-soc mailing list at
-@url{http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-soc}.}
-
-The video hook functionality is designed (mostly) for live video. It allows
-the video to be modified or examined between the decoder and the encoder.
-
-Any number of hook modules can be placed inline, and they are run in the
-order that they were specified on the ffmpeg command line.
-
-The video hook modules are provided for use as a base for your own modules,
-and are described below.
-
-Modules are loaded using the -vhook option to ffmpeg. The value of this parameter
-is a space separated list of arguments. The first is the module name, and the rest
-are passed as arguments to the Configure function of the module.
-
-The modules are dynamic libraries: They have different suffixes (.so, .dll, .dylib)
-depending on your platform. And your platform dictates if they need to be
-somewhere in your PATH, or in your LD_LIBRARY_PATH. Otherwise you will need to
-specify the full path of the vhook file that you are using.
-
-@section null.c
-
-This does nothing. Actually it converts the input image to RGB24 and then converts
-it back again. This is meant as a sample that you can use to test your setup.
-
-@section fish.c
-
-This implements a 'fish detector'. Essentially it converts the image into HSV
-space and tests whether more than a certain percentage of the pixels fall into
-a specific HSV cuboid. If so, then the image is saved into a file for processing
-by other bits of code.
-
-Why use HSV? It turns out that HSV cuboids represent a more compact range of
-colors than would an RGB cuboid.
-
-@section imlib2.c
-
-This module implements a text overlay for a video image. Currently it
-supports a fixed overlay or reading the text from a file. The string
-is passed through strftime() so that it is easy to imprint the date and
-time onto the image.
-
-This module depends on the external library imlib2, available on
-Sourceforge, among other places, if it is not already installed on
-your system.
-
-You may also overlay an image (even semi-transparent) like TV stations do.
-You may move either the text or the image around your video to create
-scrolling credits, for example.
-
-The font file used is looked for in a FONTPATH environment variable, and
-prepended to the point size as a command line option and can be specified
-with the full path to the font file, as in:
-@example
--F /usr/X11R6/lib/X11/fonts/TTF/VeraBd.ttf/20
-@end example
-where 20 is the point size.
-
-You can specify the filename to read RGB color names from. If it is not
-specified, these defaults are used: @file{/usr/share/X11/rgb.txt} and
-@file{/usr/lib/X11/rgb.txt}
-
-Options:
-@multitable @columnfractions .2 .8
-@item @option{-C <rgb.txt>}   @tab The filename to read RGB color names from
-@item @option{-c <color>}     @tab The color of the text
-@item @option{-F <fontname>}  @tab The font face and size
-@item @option{-t <text>}      @tab The text
-@item @option{-f <filename>}  @tab The filename to read text from
-@item @option{-x <expression>}@tab x coordinate of text or image
-@item @option{-y <expression>}@tab y coordinate of text or image
-@item @option{-i <filename>}  @tab The filename to read a image from
-@item @option{-R <expression>}@tab Value for R color
-@item @option{-G <expression>}@tab Value for G color
-@item @option{-B <expression>}@tab Value for B color
-@item @option{-A <expression>}@tab Value for Alpha channel
-@end multitable
-
-Expressions are functions of these variables:
-@multitable @columnfractions .2 .8
-@item @var{N} @tab frame number (starting at zero)
-@item @var{H} @tab frame height
-@item @var{W} @tab frame width
-@item @var{h} @tab image height
-@item @var{w} @tab image width
-@item @var{X} @tab previous x coordinate of text or image
-@item @var{Y} @tab previous y coordinate of text or image
-@end multitable
-
-You may also use the constants @var{PI}, @var{E}, and the math functions available at the
-FFmpeg formula evaluator at (@url{ffmpeg-doc.html#SEC13}), except @var{bits2qp(bits)}
-and @var{qp2bits(qp)}.
-
-Usage examples:
-
-@example
-   # Remember to set the path to your fonts
-   FONTPATH="/cygdrive/c/WINDOWS/Fonts/"
-   FONTPATH="$FONTPATH:/usr/share/imlib2/data/fonts/"
-   FONTPATH="$FONTPATH:/usr/X11R6/lib/X11/fonts/TTF/"
-   export FONTPATH
-
-   # Bulb dancing in a Lissajous pattern
-   ffmpeg -i input.avi -vhook \
-     'vhook/imlib2.dll -x W*(0.5+0.25*sin(N/47*PI))-w/2 -y H*(0.5+0.50*cos(N/97*PI))-h/2 -i /usr/share/imlib2/data/images/bulb.png' \
-     -acodec copy -sameq output.avi
-
-   # Text scrolling
-   ffmpeg -i input.avi -vhook \
-     'vhook/imlib2.dll -c red -F Vera.ttf/20 -x 150+0.5*N -y 70+0.25*N -t Hello' \
-     -acodec copy -sameq output.avi
-
-   # Date and time stamp, security-camera style:
-   ffmpeg -r 29.97 -s 320x256 -f video4linux -i /dev/video0 \
-     -vhook 'vhook/imlib2.so -x 0 -y 0 -i black-260x20.png' \
-     -vhook 'vhook/imlib2.so -c white -F VeraBd.ttf/12 -x 0 -y 0 -t %A-%D-%T' \
-     output.avi
-
-     In this example the video is captured from the first video capture card as a
-     320x256 AVI, and a black 260 by 20 pixel PNG image is placed in the upper
-     left corner, with the day, date and time overlaid on it in Vera Bold 12
-     point font. A simple black PNG file 260 pixels wide and 20 pixels tall
-     was created in the GIMP for this purpose.
-
-   # Scrolling credits from a text file
-   ffmpeg -i input.avi -vhook \
-     'vhook/imlib2.so -c white -F VeraBd.ttf/16 -x 100 -y -1.0*N -f credits.txt' \
-     -sameq output.avi
-
-     In this example, the text is stored in a file, and is positioned 100
-     pixels from the left hand edge of the video. The text is scrolled from the
-     bottom up. Making the y factor positive will scroll from the top down.
-     Increasing the magnitude of the y factor makes the text scroll faster,
-     decreasing it makes it scroll slower. Hint: Blank lines containing only
-     a newline are treated as end-of-file. To create blank lines, use lines
-     that consist of space characters only.
-
-   # Scrolling credits with custom color from a text file
-   ffmpeg -i input.avi -vhook \
-     'vhook/imlib2.so -C rgb.txt -c CustomColor1 -F VeraBd.ttf/16 -x 100 -y -1.0*N -f credits.txt' \
-     -sameq output.avi
-
-     This example does the same as the one above, but specifies an rgb.txt file
-     to be used, which has a custom-made color in it.
-
-   # Variable colors
-   ffmpeg -i input.avi -vhook \
-     'vhook/imlib2.so -t Hello -R abs(255*sin(N/47*PI)) -G abs(255*sin(N/47*PI)) -B abs(255*sin(N/47*PI))' \
-     -sameq output.avi
-
-     In this example, the color for the text goes up and down from black to
-     white.
-
-   # Text fade-out
-   ffmpeg -i input.avi -vhook \
-     'vhook/imlib2.so -t Hello -A max(0,255-exp(N/47))' \
-     -sameq output.avi
-
-     In this example, the text fades out in about 10 seconds for a 25 fps input
-     video file.
-
-   # scrolling credits from a graphics file
-   ffmpeg -sameq -i input.avi \
-     -vhook 'vhook/imlib2.so -x 0 -y -1.0*N -i credits.png' output.avi
-
-     In this example, a transparent PNG file the same width as the video
-     (e.g. 320 pixels), but very long, (e.g. 3000 pixels), was created, and
-     text, graphics, brushstrokes, etc, were added to the image. The image
-     is then scrolled up, from the bottom of the frame.
-
-@end example
-
-@section ppm.c
-
-It's basically a launch point for a PPM pipe, so you can use any
-executable (or script) which consumes a PPM on stdin and produces a PPM
-on stdout (and flushes each frame). The Netpbm utilities are a series of
-such programs.
-
-A list of them is here:
-
-@url{http://netpbm.sourceforge.net/doc/directory.html}
-
-Usage example:
-
-@example
-ffmpeg -i input -vhook "/path/to/ppm.so some-ppm-filter args" output
-@end example
-
-@section drawtext.c
-
-This module implements a text overlay for a video image. Currently it
-supports a fixed overlay or reading the text from a file. The string
-is passed through strftime() so that it is easy to imprint the date and
-time onto the image.
-
-Features:
-@itemize @minus
-@item TrueType, Type1 and others via the FreeType2 library
-@item Font kerning (better output)
-@item Line Wrap (put the text that doesn't fit one line on the next line)
-@item Background box (currently in development)
-@item Outline
-@end itemize
-
-Options:
-@multitable @columnfractions .2 .8
-@item @option{-c <color>}          @tab Foreground color of the text ('internet' way) <#RRGGBB> [default #FFFFFF]
-@item @option{-C <color>}          @tab Background color of the text ('internet' way) <#RRGGBB> [default #000000]
-@item @option{-f <font-filename>}  @tab font file to use
-@item @option{-t <text>}           @tab text to display
-@item @option{-T <filename>}       @tab file to read text from
-@item @option{-x <pos>}            @tab x coordinate of the start of the text
-@item @option{-y <pos>}            @tab y coordinate of the start of the text
-@end multitable
-
-Text fonts are being looked for in a FONTPATH environment variable.
-If the FONTPATH environment variable is not available, or is not checked by
-your target (i.e. Cygwin), then specify the full path to the font file as in:
-@example
--f /usr/X11R6/lib/X11/fonts/TTF/VeraBd.ttf
-@end example
-
-Usage Example:
-@example
-   # Remember to set the path to your fonts
-   FONTPATH="/cygdrive/c/WINDOWS/Fonts/"
-   FONTPATH="$FONTPATH:/usr/share/imlib2/data/fonts/"
-   FONTPATH="$FONTPATH:/usr/X11R6/lib/X11/fonts/TTF/"
-   export FONTPATH
-
-   # Time and date display
-   ffmpeg -f video4linux2 -i /dev/video0 \
-   -vhook 'vhook/drawtext.so -f VeraBd.ttf -t %A-%D-%T' movie.mpg
-
-     This example grabs video from the first capture card and outputs it to an
-     MPEG video, and places "Weekday-dd/mm/yy-hh:mm:ss" at the top left of the
-     frame, updated every second, using the Vera Bold TrueType Font, which
-     should exist in: /usr/X11R6/lib/X11/fonts/TTF/
-@end example
-
-Check the man page for strftime() for all the various ways you can format
-the date and time.
-
-@section watermark.c
-
-Command Line options:
-@multitable @columnfractions .2 .8
-@item @option{-m [0|1]}            @tab Mode (default: 0, see below)
-@item @option{-t 000000 - FFFFFF}  @tab Threshold, six digit hex number
-@item @option{-f <filename>}       @tab Watermark image filename, must be specified!
-@end multitable
-
-MODE 0:
- The watermark picture works like this (assuming color intensities 0..0xFF):
- Per color do this:
- If mask color is 0x80, no change to the original frame.
- If mask color is < 0x80 the absolute difference is subtracted from the
- frame. If result < 0, result = 0.
- If mask color is > 0x80 the absolute difference is added to the
- frame. If result > 0xFF, result = 0xFF.
-
- You can override the 0x80 level with the -t flag. E.g. if threshold is
- 000000 the color value of watermark is added to the destination.
-
- This way a mask that is visible both in light and dark pictures can be made
- (e.g. by using a picture generated by the Gimp and the bump map tool).
-
- An example watermark file is at:
- @url{http://engene.se/ffmpeg_watermark.gif}
-
-MODE 1:
- Per color do this:
- If mask color > threshold color then the watermark pixel is used.
-
-Example usage:
-@example
-   ffmpeg -i infile -vhook '/path/watermark.so -f wm.gif' -an out.mov
-   ffmpeg -i infile -vhook '/path/watermark.so -f wm.gif -m 1 -t 222222' -an out.mov
-@end example
-
-@bye
diff --git a/doc/optimization.txt b/doc/optimization.txt
old mode 100644
new mode 100755
diff --git a/doc/rate_distortion.txt b/doc/rate_distortion.txt
new file mode 100644
index 0000000..5f19b0d
--- /dev/null
+++ b/doc/rate_distortion.txt
@@ -0,0 +1,59 @@
+A Quick Description Of Rate Distortion Theory.
+
+We want to encode a video, picture or piece of music optimally. What does
+"optimally" really mean? It means that we want to get the best quality at a
+given filesize OR we want to get the smallest filesize at a given quality
+(in practice, these 2 goals are usually the same).
+
+Solving this directly is not practical; trying all byte sequences 1
+megabyte in length and selecting the "best looking" sequence will yield
+256^1000000 cases to try.
+
+But first, a word about quality, which is also called distortion.
+Distortion can be quantified by almost any quality measurement one chooses.
+Commonly, the sum of squared differences is used but more complex methods
+that consider psychovisual effects can be used as well. It makes no
+difference in this discussion.
+
+
+First step: that rate distortion factor called lambda...
+Let's consider the problem of minimizing:
+
+  distortion + lambda*rate
+
+For a fixed lambda, rate would represent the filesize, while distortion is
+the quality. Is this equivalent to finding the best quality for a given max
+filesize? The answer is yes. For each filesize limit there is some lambda
+factor for which minimizing above will get you the best quality (using your
+chosen quality measurement) at the desired (or lower) filesize.
+
+
+Second step: splitting the problem.
+Directly splitting the problem of finding the best quality at a given
+filesize is hard because we do not know how many bits from the total
+filesize should be allocated to each of the subproblems. But the formula
+from above:
+
+  distortion + lambda*rate
+
+can be trivially split. Consider:
+
+  (distortion0 + distortion1) + lambda*(rate0 + rate1)
+
+This creates a problem made of 2 independent subproblems. The subproblems
+might be 2 16x16 macroblocks in a frame of 32x16 size. To minimize:
+
+  (distortion0 + distortion1) + lambda*(rate0 + rate1)
+
+we just have to minimize:
+
+  distortion0 + lambda*rate0
+
+and
+
+  distortion1 + lambda*rate1
+
+I.e, the 2 problems can be solved independently.
+
+Author: Michael Niedermayer
+Copyright: LGPL
diff --git a/doc/snow.txt b/doc/snow.txt
old mode 100644
new mode 100755
diff --git a/doc/soc.txt b/doc/soc.txt
old mode 100644
new mode 100755
diff --git a/doc/viterbi.txt b/doc/viterbi.txt
new file mode 100644
index 0000000..d9d924f
--- /dev/null
+++ b/doc/viterbi.txt
@@ -0,0 +1,110 @@
+This is a quick description of the viterbi aka dynamic programing
+algorthm.
+
+Its reason for existence is that wikipedia has become very poor on
+describing algorithms in a way that makes it useable for understanding
+them or anything else actually. It tends now to describe the very same
+algorithm under 50 different names and pages with few understandable
+by even people who fully understand the algorithm and the theory behind.
+
+Problem description: (that is what it can solve)
+assume we have a 2d table, or you could call it a graph or matrix if you
+prefer
+
+    O   O   O   O   O   O   O
+
+    O   O   O   O   O   O   O
+
+    O   O   O   O   O   O   O
+
+    O   O   O   O   O   O   O
+
+
+That table has edges connecting points from each column to the next column
+and each edge has a score like: (only some edge and scores shown to keep it
+readable)
+
+
+    O--5--O-----O-----O-----O-----O
+     2   / 7   / \   / \   / \   /
+      \ /   \ /   \ /   \ /   \ /
+    O7-/--O--/--O--/--O--/--O--/--O
+     \/ \/ 1/ \/ \/ \/ \/ \/ \/ \/
+     /\ /\ 2\ /\ /\ /\ /\ /\ /\ /\
+    O3-/--O--/--O--/--O--/--O--/--O
+      / \   / \   / \   / \   / \
+     1   \ 9   \ /   \ /   \ /   \
+    O--2--O--1--O--5--O--3--O--8--O
+
+
+
+Our goal is to find a path from left to right through it which
+minimizes the sum of the score of all edges.
+(and of course left/right is just a convention here it could be top down too)
+Similarly the minimum could be the maximum by just fliping the sign,
+Example of a path with scores:
+
+    O   O   O   O   O   O   O
+
+>---O.  O   O  .O-2-O   O   O
+      5.     .7      .
+    O   O-1-O   O   O 8 O   O
+                       .
+    O   O   O   O   O   O-1-O---> (sum here is 24)
+
+
+The viterbi algorthm now solves this simply column by column
+For the previous column each point has a best path and a associated
+score:
+
+    O-----5     O
+     \
+      \
+    O  \  1     O
+        \/
+        /\
+    O  /  2     O
+      /
+     /
+    O-----2     O
+
+
+To move one column forward we just need to find the best path and associated
+scores for the next column
+here are some edges we could choose from:
+
+
+    O-----5--3--O
+     \      \8
+      \       \
+    O  \  1--9--O
+        \/  \3
+        /\     \
+    O  /  2--1--O
+      /     \2
+     /        \
+    O-----2--4--O
+
+Finding the new best pathes and scores for each point of our new column is
+trivial given we know the previous column best pathes and scores:
+
+    O-----0-----8
+     \
+      \
+    O  \  0----10
+        \/
+        /\
+    O  /  0-----3
+      /     \
+     /        \
+    O     0     4
+
+
+the viterbi algorthm continues exactly like this column for column until the
+end and then just picks the path with the best score (above that would be the
+one with score 3)
+
+
+Author: Michael niedermayer
+Copyright LGPL
+
diff --git a/ffmpeg-svn-revisions.txt b/ffmpeg-svn-revisions.txt
new file mode 100644
index 0000000..b00e298
--- /dev/null
+++ b/ffmpeg-svn-revisions.txt
@@ -0,0 +1,1023 @@
+            18196    18196 diego        .
+X                                       libswscale
+?                                       ffmpeg-svn-revisions.txt
+M           18196    18191 ramiro       configure
+            18196    16798 diego        Doxyfile
+M           18196    18063 bcoudurier   ffmpeg.c
+            18196    18077 cehoyos      Changelog
+            18196    18194 diego        libavutil
+            18196    18194 diego        libavutil/arm
+            18196    17830 mru          libavutil/arm/bswap.h
+            18196    17903 diego        libavutil/mathematics.c
+            18196    14670 stefano      libavutil/utils.c
+            18196    15120 stefano      libavutil/adler32.h
+            18196    15120 stefano      libavutil/sha1.h
+            18196    18043 michael      libavutil/x86_cpu.h
+            18196    16912 diego        libavutil/integer.h
+            18196    16849 diego        libavutil/avstring.h
+            18196    16844 diego        libavutil/mathematics.h
+            18196    15120 stefano      libavutil/crc_data.h
+            18196    16849 diego        libavutil/crc.c
+            18196    18112 diego        libavutil/lfg.c
+            18196    18163 stefano      libavutil/avutil.h
+            18196    16840 diego        libavutil/crc.h
+            18196    18174 stefano      libavutil/pixfmt.h
+            18196    16840 diego        libavutil/lfg.h
+            18196    18194 diego        libavutil/sh4
+            18196    16912 diego        libavutil/sh4/bswap.h
+            18196    17868 bcoudurier   libavutil/random_seed.c
+            18196    16840 diego        libavutil/md5.c
+            18196    17989 stefano      libavutil/random_seed.h
+M           18196    16912 diego        libavutil/intfloat_readwrite.c
+            18196    18068 diego        libavutil/lls.c
+            18196    15120 stefano      libavutil/md5.h
+            18196    15120 stefano      libavutil/intfloat_readwrite.h
+            18196    18193 diego        libavutil/Makefile
+            18196    15120 stefano      libavutil/lls.h
+            18196    18070 diego        libavutil/tree.c
+            18196    18056 diego        libavutil/softfloat.c
+            18196    18070 diego        libavutil/pca.c
+            18196    17876 reimar       libavutil/lzo.c
+            18196    16912 diego        libavutil/tree.h
+            18196    18194 diego        libavutil/x86
+            18196    16912 diego        libavutil/x86/bswap.h
+            18196    16590 aurel        libavutil/intreadwrite.h
+            18196    16840 diego        libavutil/softfloat.h
+            18196    18070 diego        libavutil/aes.c
+            18196    16912 diego        libavutil/pca.h
+            18196    16950 reimar       libavutil/lzo.h
+            18196    16912 diego        libavutil/rational.c
+            18196    17875 reimar       libavutil/des.c
+            18196    16847 reimar       libavutil/aes.h
+M           18196    17495 diego        libavutil/mem.c
+            18196    16912 diego        libavutil/rational.h
+            18196    16971 reimar       libavutil/des.h
+            18196    17531 michael      libavutil/log.c
+            18196    18114 diego        libavutil/internal.h
+            18196    16912 diego        libavutil/bswap.h
+            18196    17914 reimar       libavutil/fifo.c
+M           18196    16912 diego        libavutil/mem.h
+            18196    17072 stefano      libavutil/base64.c
+            18196    16912 diego        libavutil/timer.h
+            18196    17903 diego        libavutil/log.h
+            18196    17914 reimar       libavutil/fifo.h
+            18196    17876 reimar       libavutil/rc4.c
+            18196    17074 stefano      libavutil/base64.h
+            18196    18040 diego        libavutil/adler32.c
+            18196    16840 diego        libavutil/sha1.c
+            18196    16912 diego        libavutil/integer.c
+            18196    18194 diego        libavutil/bfin
+            18196    16912 diego        libavutil/bfin/bswap.h
+            18196    17508 mru          libavutil/common.h
+            18196    16970 reimar       libavutil/rc4.h
+            18196    16853 diego        libavutil/avstring.c
+            18196    18194 diego        libavcodec
+?                                       libavcodec/latmaac.c
+?                                       libavcodec/latm_parser.c
+?                                       libavcodec/mp3table.h
+?                                       libavcodec/imgresample.c
+?                                       libavcodec/oggivorbis.c
+            18196    17974 kostya       libavcodec/rv34.c
+            18196    17526 stefano      libavcodec/libdiracenc.c
+            18196    18152 stefano      libavcodec/pixdesc.c
+            18196    16684 diego        libavcodec/dvbsubdec.c
+            18196    16912 diego        libavcodec/mjpeg.c
+            18196    17526 stefano      libavcodec/dvdsub_parser.c
+            18196    17170 diego        libavcodec/dvdsubdec.c
+            18196    16912 diego        libavcodec/rv34.h
+            18196    17477 mru          libavcodec/alpha
+            18196    15120 stefano      libavcodec/alpha/regdef.h
+            18196    16668 mru          libavcodec/alpha/simple_idct_alpha.c
+            18196    16661 mru          libavcodec/alpha/mpegvideo_alpha.c
+            18196    17477 mru          libavcodec/alpha/asm.h
+            18196    13098 diego        libavcodec/alpha/motion_est_alpha.c
+            18196    16675 mru          libavcodec/alpha/dsputil_alpha.c
+            18196    16590 aurel        libavcodec/alpha/dsputil_alpha_asm.S
+            18196    16675 mru          libavcodec/alpha/motion_est_mvi_asm.S
+            18196    18152 stefano      libavcodec/pixdesc.h
+            18196    15120 stefano      libavcodec/intrax8huf.h
+            18196    18078 banan        libavcodec/nellymoserdec.c
+            18196    16912 diego        libavcodec/mjpeg.h
+            18196    15499 conrad       libavcodec/vp3data.h
+            18196    17559 stefang      libavcodec/cavsdec.c
+            18196    17807 reimar       libavcodec/nuv.c
+            18196    17526 stefano      libavcodec/roqaudioenc.c
+            18196    17083 diego        libavcodec/vcr1.c
+            18196    16912 diego        libavcodec/libxvidff.c
+            18196    18027 ramiro       libavcodec/atrac3.c
+            18196    16912 diego        libavcodec/vqavideo.c
+            18196    16912 diego        libavcodec/indeo2.c
+            18196    17792 stefano      libavcodec/libfaad.c
+            18196    16684 diego        libavcodec/ac3dec.c
+            18196    17526 stefano      libavcodec/libdiracdec.c
+            18196    18111 kostya       libavcodec/smacker.c
+            18196    17447 jbr          libavcodec/aac_ac3_parser.c
+            18196    17398 diego        libavcodec/ac3dec.h
+            18196    17097 diego        libavcodec/sparc
+            18196    17097 diego        libavcodec/sparc/dsputil_vis.c
+            18196    17097 diego        libavcodec/sparc/vis.h
+            18196    16042 diego        libavcodec/sparc/simple_idct_vis.c
+            18196    17081 diego        libavcodec/cljr.c
+            18196    16912 diego        libavcodec/cookdata.h
+            18196    17848 jbr          libavcodec/pnm.c
+            18196    17526 stefano      libavcodec/libvorbis.c
+            18196    17447 jbr          libavcodec/aac_ac3_parser.h
+            18196    16590 aurel        libavcodec/dnxhdenc.c
+            18196    16980 alexc        libavcodec/intrax8.c
+            18196    16912 diego        libavcodec/h264pred.c
+            18196    18089 jbr          libavcodec/flacdata.c
+            18196    16684 diego        libavcodec/pnm.h
+            18196    16072 bcoudurier   libavcodec/dnxhdenc.h
+            18196    15120 stefano      libavcodec/intrax8.h
+            18196    17716 diego        libavcodec/adxenc.c
+            18196    16912 diego        libavcodec/opt.c
+            18196    16912 diego        libavcodec/qdm2data.h
+            18196    16912 diego        libavcodec/h264pred.h
+            18196    15120 stefano      libavcodec/svq1_vlc.h
+            18196    18089 jbr          libavcodec/flacdata.h
+            18196    16912 diego        libavcodec/opt.h
+M           18196    18170 benoit       libavcodec/resample.c
+            18196    17469 romansh      libavcodec/dv.c
+            18196    16684 diego        libavcodec/pngenc.c
+            18196    17517 iive         libavcodec/mpegvideo_xvmc.c
+            18196    16912 diego        libavcodec/idcinvideo.c
+            18196    16912 diego        libavcodec/rawenc.c
+            18196    16912 diego        libavcodec/h263data.h
+            18196    16684 diego        libavcodec/dnxhddec.c
+            18196    18070 diego        libavcodec/motion-test.c
+            18196    16912 diego        libavcodec/huffman.c
+            18196    16684 diego        libavcodec/wma.c
+            18196    16994 diego        libavcodec/mdct.c
+            18196    13759 stefano      libavcodec/escape124.c
+            18196    16912 diego        libavcodec/rv40vlc2.h
+            18196    17716 diego        libavcodec/adxdec.c
+            18196    17564 michael      libavcodec/rv10.c
+            18196    16912 diego        libavcodec/huffman.h
+            18196    16684 diego        libavcodec/wma.h
+            18196    17716 diego        libavcodec/motionpixels.c
+            18196    16641 stefang      libavcodec/cavsdata.h
+            18196    16912 diego        libavcodec/qpeg.c
+            18196    15120 stefano      libavcodec/g729.h
+            18196    16912 diego        libavcodec/mpegaudioenc.c
+            18196    16684 diego        libavcodec/pngdec.c
+            18196    18136 gb           libavcodec/vaapi.c
+            18196    16912 diego        libavcodec/rv40dsp.c
+            18196    16912 diego        libavcodec/vmnc.c
+            18196    18045 ramiro       libavcodec/mlp_parser.c
+            18196    16912 diego        libavcodec/mpegaudiodata.c
+            18196    16912 diego        libavcodec/bethsoftvideo.c
+            18196    17481 michael      libavcodec/rawdec.c
+            18196    18136 gb           libavcodec/vaapi.h
+            18196    17533 michael      libavcodec/vc1_parser.c
+            18196    16912 diego        libavcodec/jfdctfst.c
+            18196    16912 diego        libavcodec/mlp_parser.h
+            18196    16912 diego        libavcodec/mpegaudiodata.h
+            18196    15120 stefano      libavcodec/bethsoftvideo.h
+            18196    16912 diego        libavcodec/vp6data.h
+            18196    17218 jbr          libavcodec/lpc.c
+            18196    16912 diego        libavcodec/h264dspenc.c
+            18196    16912 diego        libavcodec/motion_est.c
+            18196    17464 alexc        libavcodec/indeo3.c
+M           18196    18192 ramiro       libavcodec/h263.c
+            18196    14487 benoit       libavcodec/rle.c
+            18196    15202 vitor        libavcodec/lpc.h
+            18196     9065 aurel        libavcodec/remove_extradata_bsf.c
+M           18196    17526 stefano      libavcodec/mpegaudiodec.c
+M           18196    18070 diego        libavcodec/snow.c
+            18196    16600 aurel        libavcodec/h263.h
+            18196    15120 stefano      libavcodec/rle.h
+            18196    16590 aurel        libavcodec/snow.h
+            18196    16912 diego        libavcodec/ac3tab.c
+            18196    17391 diego        libavcodec/mimic.c
+            18196    16912 diego        libavcodec/kmvc.c
+            18196    16684 diego        libavcodec/ac3tab.h
+            18196    15804 romansh      libavcodec/w32thread.c
+            18196    16912 diego        libavcodec/flicvideo.c
+            18196    16912 diego        libavcodec/zmbvenc.c
+            18196    12370 diego        libavcodec/faanidct.c
+            18196    16912 diego        libavcodec/asv1.c
+            18196    16912 diego        libavcodec/mpegaudio.c
+            18196    17546 vitor        libavcodec/celp_filters.c
+            18196    16912 diego        libavcodec/mjpeg_parser.c
+            18196    15120 stefano      libavcodec/faanidct.h
+            18196    16912 diego        libavcodec/mpegaudio.h
+            18196    15758 diego        libavcodec/celp_filters.h
+            18196    15120 stefano      libavcodec/ulti_cb.h
+            18196    16912 diego        libavcodec/qtrle.c
+            18196    18067 diego        libavcodec/nellymoser.c
+            18196    17635 benoit       libavcodec/error_resilience.c
+            18196    17986 reimar       libavcodec/options.c
+            18196    16912 diego        libavcodec/h261_parser.c
+            18196    17808 reimar       libavcodec/interplayvideo.c
+            18196    16912 diego        libavcodec/nellymoser.h
+            18196    16912 diego        libavcodec/rdft.c
+M           18196    18048 reimar       libavcodec/utils.c
+            18196    16912 diego        libavcodec/libschroedinger.c
+            18196    15120 stefano      libavcodec/unary.h
+            18196    15120 stefano      libavcodec/imcdata.h
+            18196    16912 diego        libavcodec/truespeech.c
+            18196    16912 diego        libavcodec/libschroedinger.h
+            18196    17133 stefang      libavcodec/cavs_parser.c
+            18196    16912 diego        libavcodec/8bps.c
+            18196    15680 diego        libavcodec/acelp_filters.c
+            18196    17526 stefano      libavcodec/msmpeg4.c
+            18196    16912 diego        libavcodec/libdirac.h
+            18196    16912 diego        libavcodec/golomb.c
+            18196    18077 cehoyos      libavcodec/pcxenc.c
+            18196    16699 cehoyos      libavcodec/vdpau_internal.h
+            18196    15680 diego        libavcodec/acelp_filters.h
+            18196    16912 diego        libavcodec/msmpeg4.h
+M           18196    17949 michael      libavcodec/h264.c
+            18196    16912 diego        libavcodec/tiertexseqv.c
+            18196    17550 mru          libavcodec/golomb.h
+            18196    16684 diego        libavcodec/png.c
+            18196    18176 superdump    libavcodec/apiexample.c
+            18196    17811 schreter     libavcodec/h264.h
+            18196    16860 diego        libavcodec/mlp.c
+            18196    16684 diego        libavcodec/png.h
+            18196    17716 diego        libavcodec/eacmv.c
+            18196    15804 romansh      libavcodec/os2thread.c
+            18196    18070 diego        libavcodec/fft-test.c
+M           18196    18190 diego        libavcodec/Makefile
+            18196    18072 ramiro       libavcodec/mlp.h
+            18196    16912 diego        libavcodec/jrevdct.c
+            18196    16684 diego        libavcodec/mlib
+            18196    16684 diego        libavcodec/mlib/dsputil_mlib.c
+            18196    17135 stefang      libavcodec/cavsdsp.c
+M           18196    17716 diego        libavcodec/mpegvideo_enc.c
+            18196    15120 stefano      libavcodec/mpc7data.h
+            18196    16912 diego        libavcodec/mpegaudiotab.h
+            18196    16912 diego        libavcodec/mdec.c
+            18196    16912 diego        libavcodec/8svx.c
+            18196    16912 diego        libavcodec/aacenc.c
+            18196    17881 vitor        libavcodec/roqvideoenc.c
+            18196    16912 diego        libavcodec/h261data.h
+            18196    17593 diego        libavcodec/internal.h
+            18196    17800 reynaldo     libavcodec/qcelp_lsp.c
+            18196    16912 diego        libavcodec/smc.c
+            18196    16912 diego        libavcodec/tiff.c
+            18196    16912 diego        libavcodec/raw.c
+            18196    13759 stefano      libavcodec/pcx.c
+            18196    18092 jbr          libavcodec/flacenc.c
+            18196    15761 mmu_man      libavcodec/celp_math.c
+            18196     9066 aurel        libavcodec/dump_extradata_bsf.c
+            18196    16912 diego        libavcodec/mpegvideo_common.h
+            18196    17823 schreter     libavcodec/parser.c
+M           18196    16912 diego        libavcodec/ratecontrol.c
+            18196    16912 diego        libavcodec/tiff.h
+            18196    15921 mru          libavcodec/lsp.c
+            18196    16912 diego        libavcodec/h263_parser.c
+            18196    13759 stefano      libavcodec/c93.c
+            18196    16912 diego        libavcodec/raw.h
+            18196    16912 diego        libavcodec/colorspace.h
+            18196    17108 aurel        libavcodec/vp56.c
+            18196    16391 reynaldo     libavcodec/celp_math.h
+            18196    16684 diego        libavcodec/parser.h
+M           18196    16912 diego        libavcodec/ratecontrol.h
+            18196    16912 diego        libavcodec/libxvid_internal.h
+M           18196    17110 cehoyos      libavcodec/audioconvert.c
+            18196    15120 stefano      libavcodec/lsp.h
+            18196    15120 stefano      libavcodec/h263_parser.h
+            18196    17954 cehoyos      libavcodec/bmpenc.c
+            18196    16912 diego        libavcodec/roqvideodec.c
+            18196    18092 jbr          libavcodec/flac.c
+            18196    16912 diego        libavcodec/vp56.h
+            18196    17880 kostya       libavcodec/mpc7.c
+            18196    16912 diego        libavcodec/audioconvert.h
+            18196    11458 michael      libavcodec/noise_bsf.c
+            18196    13759 stefano      libavcodec/sgienc.c
+            18196    18175 jbr          libavcodec/flac.h
+            18196    16912 diego        libavcodec/cinepak.c
+            18196    16912 diego        libavcodec/dxa.c
+            18196    16503 mru          libavcodec/sh4
+            18196    15878 mru          libavcodec/sh4/dsputil_align.c
+            18196    15897 mru          libavcodec/sh4/idct_sh4.c
+            18196    15886 mru          libavcodec/sh4/qpel.c
+            18196    15990 diego        libavcodec/sh4/dsputil_sh4.c
+            18196    16503 mru          libavcodec/sh4/sh4.h
+            18196    17880 kostya       libavcodec/mpc.c
+            18196    18179 jbr          libavcodec/flacdec.c
+            18196    16915 kostya       libavcodec/msrle.c
+            18196    17111 aurel        libavcodec/vp6dsp.c
+            18196    17721 diego        libavcodec/dpcm.c
+            18196    17880 kostya       libavcodec/mpc.h
+            18196    13990 aurel        libavcodec/vp3_parser.c
+            18196    17084 diego        libavcodec/libspeexdec.c
+M           18196    16912 diego        libavcodec/dca.c
+            18196    16912 diego        libavcodec/mjpegenc.c
+            18196    16912 diego        libavcodec/rv30data.h
+            18196    17698 mru          libavcodec/ra144.c
+            18196    15951 kostya       libavcodec/dca.h
+            18196    16912 diego        libavcodec/ws-snd1.c
+            18196    16912 diego        libavcodec/mjpegenc.h
+            18196    15444 superdump    libavcodec/vorbis_data.c
+            18196    13759 stefano      libavcodec/sgidec.c
+            18196    15274 vitor        libavcodec/ra144.h
+            18196    18136 gb           libavcodec/vaapi_internal.h
+            18196    17800 reynaldo     libavcodec/qcelpdata.h
+            18196    16912 diego        libavcodec/mace.c
+            18196    17716 diego        libavcodec/eatgv.c
+            18196    16915 kostya       libavcodec/aasc.c
+            18196    16912 diego        libavcodec/mpeg4data.h
+            18196    16912 diego        libavcodec/ulti.c
+            18196    16912 diego        libavcodec/vmdav.c
+            18196    16912 diego        libavcodec/mjpegdec.c
+            18196    17280 diego        libavcodec/xvmc_internal.h
+            18196    15120 stefano      libavcodec/indeo2data.h
+            18196    16912 diego        libavcodec/vp3dsp.c
+            18196    16912 diego        libavcodec/mjpegbdec.c
+            18196    16912 diego        libavcodec/h264data.h
+            18196    16912 diego        libavcodec/rl.h
+            18196    16912 diego        libavcodec/mjpegdec.h
+            18196    17564 michael      libavcodec/rv30.c
+            18196    17731 michael      libavcodec/mpegvideo_parser.c
+            18196    17097 diego        libavcodec/bfin
+            18196    12125 diego        libavcodec/bfin/fdct_bfin.S
+            18196    17097 diego        libavcodec/bfin/mathops.h
+            18196    12125 diego        libavcodec/bfin/idct_bfin.S
+            18196    15990 diego        libavcodec/bfin/dsputil_bfin.c
+            18196     9019 gpoirier     libavcodec/bfin/pixels_bfin.S
+            18196    15990 diego        libavcodec/bfin/vp3_bfin.c
+            18196    15120 stefano      libavcodec/bfin/dsputil_bfin.h
+            18196    17097 diego        libavcodec/bfin/config_bfin.h
+            18196    12125 diego        libavcodec/bfin/vp3_idct_bfin.S
+            18196    15990 diego        libavcodec/bfin/mpegvideo_bfin.c
+            18196    17526 stefano      libavcodec/bfi.c
+            18196    16684 diego        libavcodec/dvbsub_parser.c
+            18196    16912 diego        libavcodec/ffv1.c
+            18196    16912 diego        libavcodec/flashsv.c
+            18196    17880 kostya       libavcodec/mpc8.c
+            18196    16912 diego        libavcodec/jpeglsenc.c
+            18196    17180 superdump    libavcodec/aactab.c
+            18196    16912 diego        libavcodec/zmbv.c
+            18196    16912 diego        libavcodec/faxcompr.c
+            18196    17854 cehoyos      libavcodec/vdpau.c
+            18196    16912 diego        libavcodec/aactab.h
+            18196    16912 diego        libavcodec/mpegaudiodectab.h
+            18196    16912 diego        libavcodec/vc1data.c
+            18196    16912 diego        libavcodec/wmadata.h
+            18196    16912 diego        libavcodec/faxcompr.h
+            18196    18169 alexc        libavcodec/aac.c
+            18196    16780 diego        libavcodec/bytestream.h
+            18196    17225 diego        libavcodec/vdpau.h
+            18196    16866 stefang      libavcodec/truemotion1data.h
+            18196    15513 diego        libavcodec/g729data.h
+            18196    16912 diego        libavcodec/vc1data.h
+            18196    16067 aurel        libavcodec/avs.c
+            18196    18031 alexc        libavcodec/aac.h
+            18196    16912 diego        libavcodec/libdirac_libschro.c
+            18196    15548 lu_zero      libavcodec/bitstream_filter.c
+            18196    16556 diego        libavcodec/sunrast.c
+            18196    16912 diego        libavcodec/jpeglsdec.c
+            18196    16912 diego        libavcodec/libdirac_libschro.h
+            18196    16912 diego        libavcodec/jpeglsdec.h
+            18196    17526 stefano      libavcodec/libamr.c
+            18196    16912 diego        libavcodec/rv34vlc.h
+            18196    17526 stefano      libavcodec/vp3.c
+            18196    16556 diego        libavcodec/ptx.c
+            18196    16912 diego        libavcodec/sonic.c
+            18196    16912 diego        libavcodec/lzw.c
+            18196     9063 aurel        libavcodec/mp3_header_compress_bsf.c
+            18196    16912 diego        libavcodec/libgsm.c
+            18196    16912 diego        libavcodec/qdrw.c
+            18196    17155 diego        libavcodec/qtrleenc.c
+            18196    15120 stefano      libavcodec/mpcdata.h
+M           18196    18071 gb           libavcodec/mpegvideo.c
+            18196    16912 diego        libavcodec/svq1enc.c
+            18196    16912 diego        libavcodec/lzw.h
+            18196    16912 diego        libavcodec/dnxhd_parser.c
+            18196    16912 diego        libavcodec/shorten.c
+            18196    16921 kostya       libavcodec/xl.c
+            18196    16912 diego        libavcodec/imx_dump_header_bsf.c
+            18196    17731 michael      libavcodec/mpegvideo.h
+            18196    16556 diego        libavcodec/targaenc.c
+            18196    16912 diego        libavcodec/dcadata.h
+            18196    16912 diego        libavcodec/truemotion1.c
+            18196    18070 diego        libavcodec/cabac.c
+            18196    16912 diego        libavcodec/mjpega_dump_header_bsf.c
+            18196    15612 benoit       libavcodec/libx264.c
+            18196    17731 michael      libavcodec/mpeg12.c
+            18196    17180 superdump    libavcodec/aacdectab.h
+            18196    17716 diego        libavcodec/h263dec.c
+            18196    16912 diego        libavcodec/cabac.h
+            18196    18139 bcoudurier   libavcodec/mpeg4audio.c
+            18196    17544 alexc        libavcodec/aac_parser.c
+            18196    17000 pross        libavcodec/mpeg12.h
+            18196    17984 diego        libavcodec/ppc
+            18196    16590 aurel        libavcodec/ppc/gcc_fixes.h
+            18196    15990 diego        libavcodec/ppc/dsputil_altivec.h
+            18196    16912 diego        libavcodec/ppc/int_altivec.c
+            18196    13098 diego        libavcodec/ppc/vc1dsp_altivec.c
+            18196    16459 gpoirier     libavcodec/ppc/float_altivec.c
+            18196    14316 diego        libavcodec/ppc/gmc_altivec.c
+            18196    16357 lu_zero      libavcodec/ppc/types_altivec.h
+            18196    16769 diego        libavcodec/ppc/mathops.h
+            18196    16912 diego        libavcodec/ppc/check_altivec.c
+            18196    17962 diego        libavcodec/ppc/h264_template_altivec.c
+            18196    15990 diego        libavcodec/ppc/mpegvideo_altivec.c
+            18196    16755 diego        libavcodec/ppc/dsputil_ppc.c
+            18196    16684 diego        libavcodec/ppc/fft_altivec.c
+            18196    17984 diego        libavcodec/ppc/fdct_altivec.c
+            18196    16912 diego        libavcodec/ppc/util_altivec.h
+            18196    16590 aurel        libavcodec/ppc/idct_altivec.c
+            18196    17962 diego        libavcodec/ppc/h264_altivec.c
+            18196    16769 diego        libavcodec/ppc/dsputil_ppc.h
+            18196    16600 aurel        libavcodec/ppc/dsputil_altivec.c
+            18196    14316 diego        libavcodec/ppc/snow_altivec.c
+            18196    18034 alexc        libavcodec/mpeg4audio.h
+            18196    16485 superdump    libavcodec/aac_parser.h
+            18196    16912 diego        libavcodec/svq1dec.c
+            18196    16912 diego        libavcodec/rpza.c
+            18196    17526 stefano      libavcodec/mpeg4video_parser.c
+            18196    16912 diego        libavcodec/apedec.c
+            18196    16684 diego        libavcodec/mpeg4video_parser.h
+            18196    18070 diego        libavcodec/dct-test.c
+            18196    17706 jbr          libavcodec/tta.c
+            18196    16912 diego        libavcodec/iirfilter.c
+            18196    17916 reynaldo     libavcodec/acelp_vectors.c
+            18196    16391 reynaldo     libavcodec/acelp_pitch_delay.c
+            18196    16912 diego        libavcodec/svq1.c
+            18196    17564 michael      libavcodec/rv40.c
+            18196    16912 diego        libavcodec/flashsvenc.c
+            18196    17138 stefang      libavcodec/cavs.c
+            18196    16912 diego        libavcodec/simple_idct.c
+            18196    17129 diego        libavcodec/libopenjpeg.c
+            18196    16912 diego        libavcodec/iirfilter.h
+            18196    17916 reynaldo     libavcodec/acelp_vectors.h
+            18196    16391 reynaldo     libavcodec/acelp_pitch_delay.h
+            18196    16912 diego        libavcodec/rl2.c
+            18196    16912 diego        libavcodec/svq1.h
+            18196    16912 diego        libavcodec/mmvideo.c
+            18196    17138 stefang      libavcodec/cavs.h
+            18196    16912 diego        libavcodec/simple_idct.h
+            18196    17043 bcoudurier   libavcodec/eatqi.c
+            18196    15679 diego        libavcodec/g729dec.c
+            18196    17391 diego        libavcodec/mpc8data.h
+            18196    16912 diego        libavcodec/msmpeg4data.c
+            18196    16912 diego        libavcodec/rectangle.h
+            18196    16912 diego        libavcodec/fraps.c
+            18196    16912 diego        libavcodec/msmpeg4data.h
+            18196    16912 diego        libavcodec/sp5xdec.c
+            18196    16912 diego        libavcodec/atrac3data.h
+            18196    16946 reimar       libavcodec/cscd.c
+            18196    16556 diego        libavcodec/s3tc.c
+            18196    17363 kostya       libavcodec/bmp.c
+            18196    17738 mru          libavcodec/mathops.h
+            18196    16912 diego        libavcodec/aandcttab.c
+            18196    16912 diego        libavcodec/mpeg12enc.c
+            18196    15120 stefano      libavcodec/s3tc.h
+            18196    15120 stefano      libavcodec/bmp.h
+            18196    16684 diego        libavcodec/ps2
+            18196    16684 diego        libavcodec/ps2/mpegvideo_mmi.c
+            18196    15627 flameeyes    libavcodec/ps2/idct_mmi.c
+            18196    16684 diego        libavcodec/ps2/dsputil_mmi.c
+            18196    15627 flameeyes    libavcodec/ps2/mmi.h
+            18196    16912 diego        libavcodec/jpegls.c
+M           18196    18192 ramiro       libavcodec/dsputil.c
+            18196    16684 diego        libavcodec/g726.c
+            18196    16912 diego        libavcodec/aandcttab.h
+            18196    16912 diego        libavcodec/xan.c
+            18196    18021 jbr          libavcodec/eac3dec.c
+            18196    16912 diego        libavcodec/eval.c
+            18196    16918 kostya       libavcodec/truemotion2.c
+            18196    16912 diego        libavcodec/jpegls.h
+M           18196    18164 diego        libavcodec/allcodecs.c
+            18196    17446 romansh      libavcodec/dsputil.h
+            18196    13098 diego        libavcodec/rtjpeg.c
+            18196    16684 diego        libavcodec/wmv2.c
+            18196    16912 diego        libavcodec/eval.h
+            18196    15120 stefano      libavcodec/vc1acdata.h
+            18196    17170 diego        libavcodec/xsubdec.c
+            18196    16912 diego        libavcodec/dirac_parser.c
+            18196    16684 diego        libavcodec/dnxhddata.c
+            18196    16912 diego        libavcodec/lclenc.c
+            18196    15120 stefano      libavcodec/rtjpeg.h
+            18196    16684 diego        libavcodec/wmv2.h
+            18196    16912 diego        libavcodec/rv30dsp.c
+            18196    16684 diego        libavcodec/dnxhddata.h
+            18196    15120 stefano      libavcodec/truespeech_data.h
+            18196    16684 diego        libavcodec/pnm_parser.c
+            18196    16912 diego        libavcodec/dvdata.h
+            18196    16556 diego        libavcodec/xiph.c
+            18196    17926 vitor        libavcodec/elbg.c
+            18196    18070 diego        libavcodec/rangecoder.c
+            18196    16912 diego        libavcodec/vp5data.h
+            18196    16912 diego        libavcodec/motion_est_template.c
+            18196    15120 stefano      libavcodec/xiph.h
+            18196    18113 diego        libavcodec/elbg.h
+            18196    16912 diego        libavcodec/rangecoder.h
+            18196    16912 diego        libavcodec/adx.h
+            18196    17472 jbr          libavcodec/ac3_parser.c
+            18196    16912 diego        libavcodec/libmp3lame.c
+            18196    16912 diego        libavcodec/mpeg12data.c
+            18196    16912 diego        libavcodec/lcldec.c
+            18196    16684 diego        libavcodec/ac3_parser.h
+            18196    16912 diego        libavcodec/roqvideo.c
+            18196    16912 diego        libavcodec/eaidct.c
+            18196    16912 diego        libavcodec/mpeg12data.h
+            18196    16912 diego        libavcodec/vp56data.c
+            18196    17881 vitor        libavcodec/roqvideo.h
+            18196    16556 diego        libavcodec/txd.c
+            18196    16912 diego        libavcodec/vp56data.h
+            18196    17744 jbr          libavcodec/alac.c
+            18196    16912 diego        libavcodec/faandct.c
+            18196    17716 diego        libavcodec/eatgq.c
+M           18196    16912 diego        libavcodec/dca_parser.c
+            18196    15120 stefano      libavcodec/sp5x.h
+            18196    16912 diego        libavcodec/faandct.h
+            18196    16912 diego        libavcodec/ac3.c
+            18196    16912 diego        libavcodec/imc.c
+            18196    17526 stefano      libavcodec/4xm.c
+M           18196    18163 stefano      libavcodec/avcodec.h
+            18196    16912 diego        libavcodec/vp5.c
+            18196    16912 diego        libavcodec/ac3.h
+            18196    18163 stefano      libavcodec/imgconvert.c
+            18196    15120 stefano      libavcodec/lcl.h
+            18196    15120 stefano      libavcodec/indeo3data.h
+            18196    16912 diego        libavcodec/aacpsy.c
+            18196    17917 reynaldo     libavcodec/qcelpdec.c
+            18196    16684 diego        libavcodec/wmv2enc.c
+            18196    18129 stefano      libavcodec/imgconvert.h
+            18196    17960 diego        libavcodec/xvmc.h
+            18196    15552 diego        libavcodec/aacpsy.h
+            18196    17759 benoit       libavcodec/alacenc.c
+            18196    16912 diego        libavcodec/ljpegenc.c
+            18196    17132 diego        libavcodec/libschroedingerenc.c
+            18196    18135 gb           libavcodec/vc1.c
+            18196    16912 diego        libavcodec/vorbis_enc.c
+            18196    18110 diego        libavcodec/bitstream.c
+            18196    16912 diego        libavcodec/rv40data.h
+            18196    18172 gb           libavcodec/vaapi_mpeg2.c
+            18196    18079 banan        libavcodec/cook.c
+            18196    16920 kostya       libavcodec/wnv1.c
+            18196    18194 diego        libavcodec/arm
+            18196    16590 aurel        libavcodec/arm/asm.S
+            18196    16868 mru          libavcodec/arm/dsputil_neon.c
+            18196    16868 mru          libavcodec/arm/dsputil_neon_s.S
+            18196    16684 diego        libavcodec/arm/simple_idct_arm.S
+            18196    16590 aurel        libavcodec/arm/mpegvideo_arm.c
+            18196    16179 mru          libavcodec/arm/simple_idct_armv5te.S
+            18196    16590 aurel        libavcodec/arm/dsputil_vfp.S
+            18196    16590 aurel        libavcodec/arm/float_arm_vfp.c
+            18196    16179 mru          libavcodec/arm/jrevdct_arm.S
+            18196    17831 mru          libavcodec/arm/mathops.h
+            18196    16179 mru          libavcodec/arm/mpegvideo_armv5te.c
+            18196    16684 diego        libavcodec/arm/dsputil_arm.c
+            18196    16179 mru          libavcodec/arm/mpegvideo_iwmmxt.c
+            18196    16179 mru          libavcodec/arm/mpegvideo_armv5te_s.S
+            18196    16824 mru          libavcodec/arm/dsputil_arm_s.S
+            18196    16395 mru          libavcodec/arm/h264idct_neon.S
+            18196    16179 mru          libavcodec/arm/dsputil_iwmmxt_rnd_template.c
+            18196    16570 mru          libavcodec/arm/simple_idct_armv6.S
+            18196    17657 mru          libavcodec/arm/h264dsp_neon.S
+            18196    16179 mru          libavcodec/arm/dsputil_iwmmxt.c
+            18196    16395 mru          libavcodec/arm/simple_idct_neon.S
+            18196    17156 diego        libavcodec/msrledec.c
+            18196    16859 kostya       libavcodec/vc1.h
+            18196    17526 stefano      libavcodec/libtheoraenc.c
+            18196    17740 jbr          libavcodec/bitstream.h
+            18196    16912 diego        libavcodec/mpegaudiodecheader.c
+            18196    16912 diego        libavcodec/dsicinav.c
+            18196    18006 benoit       libavcodec/lzwenc.c
+            18196    15356 kostya       libavcodec/msrledec.h
+            18196    17526 stefano      libavcodec/qdm2.c
+            18196    16912 diego        libavcodec/svq1_cb.h
+            18196    16912 diego        libavcodec/intrax8dsp.c
+            18196    18074 ramiro       libavcodec/mlpdec.c
+            18196    16912 diego        libavcodec/mpegaudiodecheader.h
+            18196    16912 diego        libavcodec/vorbis.c
+            18196    15733 banan        libavcodec/dcahuff.h
+            18196    16556 diego        libavcodec/movsub_bsf.c
+            18196    17564 michael      libavcodec/wmv2dec.c
+            18196    15937 diego        libavcodec/h264enc.c
+            18196    16076 ods15        libavcodec/vorbis.h
+            18196    17459 michael      libavcodec/wmaenc.c
+            18196    16912 diego        libavcodec/fdctref.c
+            18196    16912 diego        libavcodec/tiffenc.c
+            18196    17526 stefano      libavcodec/libschroedingerdec.c
+            18196    17997 conrad       libavcodec/fft.c
+            18196    16912 diego        libavcodec/vorbis_dec.c
+            18196    16912 diego        libavcodec/h261.c
+            18196    16912 diego        libavcodec/libfaac.c
+            18196    16912 diego        libavcodec/h261.h
+            18196    16912 diego        libavcodec/cyuv.c
+            18196    17526 stefano      libavcodec/mpegaudio_parser.c
+            18196    16684 diego        libavcodec/pthread.c
+            18196    16912 diego        libavcodec/svq1enc_cb.h
+            18196    16912 diego        libavcodec/loco.c
+            18196    17526 stefano      libavcodec/huffyuv.c
+            18196    17680 mru          libavcodec/svq3.c
+            18196    16915 kostya       libavcodec/tscc.c
+            18196    16912 diego        libavcodec/rv34data.h
+            18196    16556 diego        libavcodec/targa.c
+M           18196    18020 cehoyos      libavcodec/h264_parser.c
+            18196    16912 diego        libavcodec/vc1dsp.c
+            18196    16912 diego        libavcodec/wmadec.c
+            18196    16912 diego        libavcodec/h264_parser.h
+            18196    17562 vitor        libavcodec/ra288.c
+            18196    18194 diego        libavcodec/x86
+            18196    15627 flameeyes    libavcodec/x86/idct_mmx_xvid.c
+            18196    17197 astrange     libavcodec/x86/fft_mmx.asm
+            18196    16684 diego        libavcodec/x86/motion_est_mmx.c
+            18196    15819 bcoudurier   libavcodec/x86/fdct_mmx.c
+            18196    15627 flameeyes    libavcodec/x86/dsputil_h264_template_ssse3.c
+            18196    16419 cehoyos      libavcodec/x86/dsputil_h264_template_mmx.c
+            18196    17194 aurel        libavcodec/x86/vp6dsp_mmx.c
+            18196    17543 zuxy         libavcodec/x86/cpuid.c
+            18196    15627 flameeyes    libavcodec/x86/fft_3dn2.c
+            18196    16270 diego        libavcodec/x86/mmx.h
+            18196    17194 aurel        libavcodec/x86/vp6dsp_mmx.h
+            18196    16912 diego        libavcodec/x86/idct_sse2_xvid.c
+            18196    16912 diego        libavcodec/x86/vp3dsp_sse2.c
+            18196    16436 diego        libavcodec/x86/simple_idct_mmx.c
+            18196    17195 aurel        libavcodec/x86/vp6dsp_sse2.c
+            18196    18054 cehoyos      libavcodec/x86/snowdsp_mmx.c
+            18196    16270 diego        libavcodec/x86/vp3dsp_sse2.h
+            18196    17524 darkshikari  libavcodec/x86/h264_idct_sse2.asm
+            18196    15627 flameeyes    libavcodec/x86/vc1dsp_mmx.c
+            18196    17195 aurel        libavcodec/x86/vp6dsp_sse2.h
+            18196    14698 lorenm       libavcodec/x86/fft_3dn.c
+            18196    17192 aurel        libavcodec/x86/cavsdsp_mmx.c
+            18196    16072 bcoudurier   libavcodec/x86/dnxhd_mmx.c
+            18196    16590 aurel        libavcodec/x86/mpegvideo_mmx_template.c
+            18196    16684 diego        libavcodec/x86/dsputil_mmx_avg_template.c
+            18196    15627 flameeyes    libavcodec/x86/flacdsp_mmx.c
+            18196    16912 diego        libavcodec/x86/vp3dsp_mmx.c
+            18196    17524 darkshikari  libavcodec/x86/h264_deblock_sse2.asm
+            18196    16684 diego        libavcodec/x86/mpegvideo_mmx.c
+            18196    16912 diego        libavcodec/x86/h264_i386.h
+            18196    16684 diego        libavcodec/x86/dsputil_mmx_rnd_template.c
+            18196    15585 diego        libavcodec/x86/idct_mmx.c
+            18196    17195 aurel        libavcodec/x86/dsputil_mmx.c
+            18196    16270 diego        libavcodec/x86/vp3dsp_mmx.h
+            18196    17192 aurel        libavcodec/x86/dsputil_mmx.h
+            18196    17046 bcoudurier   libavcodec/x86/h264dsp_mmx.c
+            18196    17059 lorenm       libavcodec/x86/dsputil_yasm.asm
+M           18196    16234 darkshikari  libavcodec/x86/x86inc.asm
+            18196    17058 lorenm       libavcodec/x86/mathops.h
+            18196    16178 diego        libavcodec/x86/dsputil_mmx_qns_template.c
+            18196    17158 diego        libavcodec/x86/x86util.asm
+            18196    16912 diego        libavcodec/x86/idct_xvid.h
+            18196    16419 cehoyos      libavcodec/x86/rv40dsp_mmx.c
+            18196    16590 aurel        libavcodec/x86/fft_sse.c
+            18196    16684 diego        libavcodec/x86/dsputilenc_mmx.c
+            18196    16912 diego        libavcodec/jfdctint.c
+            18196    17096 bcoudurier   libavcodec/gif.c
+            18196    16912 diego        libavcodec/h261enc.c
+            18196    16912 diego        libavcodec/mpeg12decdata.h
+            18196    16912 diego        libavcodec/vb.c
+            18196    15552 diego        libavcodec/ra288.h
+            18196    16912 diego        libavcodec/ac3dec_data.c
+            18196    17111 aurel        libavcodec/vp6.c
+            18196    16684 diego        libavcodec/dvdsubenc.c
+            18196    17716 diego        libavcodec/nellymoserenc.c
+M           18196    17719 diego        libavcodec/pcm.c
+            18196    15804 romansh      libavcodec/beosthread.c
+            18196    15818 jbr          libavcodec/ac3dec_data.h
+            18196    18164 diego        libavcodec/pnmenc.c
+            18196    16684 diego        libavcodec/gifdec.c
+            18196    17720 diego        libavcodec/adpcm.c
+            18196    13465 diego        libavcodec/libxvid_rc.c
+            18196    16684 diego        libavcodec/dvbsub.c
+            18196     9289 diego        libavcodec/mp3_header_decompress_bsf.c
+            18196    15120 stefano      libavcodec/mpc8huff.h
+            18196    16912 diego        libavcodec/h264idct.c
+            18196    16912 diego        libavcodec/msvideo1.c
+            18196    15120 stefano      libavcodec/sgi.h
+            18196    15120 stefano      libavcodec/vorbis_enc_data.h
+            18196    18170 benoit       libavcodec/resample2.c
+            18196    16556 diego        libavcodec/h264_mp4toannexb_bsf.c
+            18196    16912 diego        libavcodec/h261dec.c
+            18196    17832 diego        libavcodec/ac3enc.c
+            18196    16912 diego        libavcodec/wavpack.c
+            18196    17428 benoit       output_example.c
+            18196    16959 aurel        CREDITS
+            18196    17836 diego        version.sh
+            18196    18143 diego        subdir.mak
+            18196    18194 diego        tools
+            18196     9741 benoit       tools/cws2fws.c
+            18196     9634 mru          tools/unwrap-diff
+            18196    17943 alexc        tools/patcheck
+            18196     9634 mru          tools/build_avopt
+            18196     9634 mru          tools/clean-diff
+            18196    18178 diego        tools/trasher.c
+            18196    14868 diego        tools/pktdumper.c
+            18196    13199 melanson     tools/qt-faststart.c
+            18196    18194 diego        libpostproc
+            18196    16912 diego        libpostproc/postprocess_template.c
+            18196    16912 diego        libpostproc/postprocess.c
+            18196    16990 diego        libpostproc/postprocess_internal.h
+            18196    17963 diego        libpostproc/postprocess_altivec_template.c
+            18196    16990 diego        libpostproc/postprocess.h
+            18196    12760 mru          libpostproc/Makefile
+            18196    18195 benoit       tests
+            18196    18098 bcoudurier   tests/seek.regression.ref
+            18196    17454 diego        tests/videogen.c
+            18196    18119 rbultje      tests/rotozoom.regression.ref
+            18196    18119 rbultje      tests/libav.regression.ref
+            18196    18077 cehoyos      tests/regression.sh
+            18196    13631 mru          tests/server-regression.sh
+            18196    18119 rbultje      tests/ffmpeg.regression.ref
+            18196    15915 mru          tests/seek_test.sh
+            18196    13720 bcoudurier   tests/test.conf
+            18196    14374 michael      tests/tiny_psnr.c
+            18196    18195 benoit       tests/seek_test.c
+            18196     1755 michaelni    tests/lena.pnm
+            18196    17454 diego        tests/rotozoom.c
+            18196    17454 diego        tests/audiogen.c
+            18196    18105 bcoudurier   tests/ffserver.regression.ref
+            18196     9610 diego        COPYING.LGPL
+            18196    18037 stefano      cmdutils.c
+            18196    18183 diego        doc
+            18196    16590 aurel        doc/faq.texi
+            18196    17955 stefano      doc/ffmpeg-doc.texi
+            18196    15358 diego        doc/swscale.txt
+            18196    16177 diego        doc/issue_tracker.txt
+            18196    17772 michael      doc/viterbi.txt
+            18196     9289 diego        doc/avutil.txt
+            18196    18077 cehoyos      doc/general.texi
+            18196    17801 melanson     doc/rate_distortion.txt
+            18196    17694 stefano      doc/ffplay-doc.texi
+            18196    15613 benoit       doc/ffserver-doc.texi
+            18196    18183 diego        doc/APIchanges
+            18196     5942 diego        doc/soc.txt
+            18196    16310 diego        doc/optimization.txt
+            18196    11880 melanson     doc/snow.txt
+            18196    12860 michael      doc/TODO
+            18196    15182 stefano      doc/ffserver.conf
+            18196     4842 diego        doc/texi2pod.pl
+            18196     6174 gpoirier     doc/ffmpeg_powerpc_performance_evaluation_howto.txt
+            18196    15796 diego        INSTALL
+            18196    18037 stefano      cmdutils.h
+            18196    18194 diego        libavdevice
+            18196    16600 aurel        libavdevice/libdc1394.c
+            18196    17097 diego        libavdevice/dv1394.h
+            18196    16684 diego        libavdevice/bktr.c
+            18196    16684 diego        libavdevice/v4l.c
+            18196    16912 diego        libavdevice/x11grab.c
+            18196    17863 lucabe       libavdevice/alsa-audio-common.c
+            18196    16912 diego        libavdevice/alsa-audio-dec.c
+            18196    16684 diego        libavdevice/beosaudio.cpp
+            18196    16800 benoit       libavdevice/alldevices.c
+            18196    16912 diego        libavdevice/alsa-audio-enc.c
+            18196    16933 diego        libavdevice/alsa-audio.h
+            18196    16707 benoit       libavdevice/oss_audio.c
+            18196    16684 diego        libavdevice/vfwcap.c
+            18196    17325 lucabe       libavdevice/v4l2.c
+            18196    14761 diego        libavdevice/dv1394.c
+            18196    15120 stefano      libavdevice/avdevice.h
+            18196    16800 benoit       libavdevice/Makefile
+            18196    18196 diego        Makefile
+            18196    18186 diego        LICENSE
+            18196     9610 diego        COPYING.GPL
+            18196    18185 diego        README
+            18196    18193 diego        common.mak
+            18196    16788 superdump    ffpresets
+            18196    16478 superdump    ffpresets/libx264-lossless_slow.ffpreset
+            18196    16478 superdump    ffpresets/libx264-lossless_max.ffpreset
+            18196    16629 superdump    ffpresets/libx264-ipod320.ffpreset
+            18196    16584 superdump    ffpresets/libx264-baseline.ffpreset
+            18196    16477 superdump    ffpresets/libx264-slowfirstpass.ffpreset
+            18196    16788 superdump    ffpresets/libx264-default.ffpreset
+            18196    16478 superdump    ffpresets/libx264-lossless_fast.ffpreset
+            18196    16584 superdump    ffpresets/libx264-main.ffpreset
+            18196    16629 superdump    ffpresets/libx264-ipod640.ffpreset
+            18196    16476 superdump    ffpresets/libx264-max.ffpreset
+            18196    16476 superdump    ffpresets/libx264-normal.ffpreset
+            18196    16476 superdump    ffpresets/libx264-fastfirstpass.ffpreset
+            18196    16478 superdump    ffpresets/libx264-lossless_ultrafast.ffpreset
+            18196    16478 superdump    ffpresets/libx264-lossless_slower.ffpreset
+            18196    16478 superdump    ffpresets/libx264-lossless_medium.ffpreset
+            18196    16476 superdump    ffpresets/libx264-hq.ffpreset
+            18196    18171 benoit       ffplay.c
+            18196    18194 diego        libavfilter
+            18196    17623 stefano      libavfilter/avfiltergraph.c
+            18196    17624 stefano      libavfilter/graphparser.c
+            18196    16600 aurel        libavfilter/allfilters.c
+            18196    17547 stefano      libavfilter/avfilter.h
+            18196    17623 stefano      libavfilter/avfiltergraph.h
+            18196    17624 stefano      libavfilter/graphparser.h
+            18196    16554 stefano      libavfilter/defaults.c
+            18196    12173 michael      libavfilter/formats.c
+            18196    17786 michael      libavfilter/Makefile
+            18196    16566 stefano      libavfilter/avfilter.c
+            18196    18109 bcoudurier   ffserver.c
+            18196    18194 diego        libavformat
+?                                       libavformat/stv.c
+            18196    16912 diego        libavformat/iss.c
+            18196    18077 cehoyos      libavformat/img2.c
+            18196    16912 diego        libavformat/bfi.c
+            18196    17602 jbr          libavformat/oggenc.c
+            18196    15262 michael      libavformat/mpc8.c
+            18196    17606 jbr          libavformat/matroskaenc.c
+M           18196    17611 aurel        libavformat/isom.c
+            18196    17966 reimar       libavformat/nuv.c
+            18196    17639 reimar       libavformat/ipmovie.c
+            18196    18192 ramiro       libavformat/avc.c
+            18196    17969 bcoudurier   libavformat/swfdec.c
+            18196    17976 bcoudurier   libavformat/isom.h
+            18196    16684 diego        libavformat/ffm.h
+            18196    16625 bcoudurier   libavformat/avc.h
+            18196    14731 diego        libavformat/vc1testenc.c
+            18196    17859 alexc        libavformat/adtsenc.c
+            18196    17157 diego        libavformat/electronicarts.c
+            18196    17183 diego        libavformat/mpjpeg.c
+            18196    18111 kostya       libavformat/smacker.c
+            18196    13649 diego        libavformat/pva.c
+            18196    16684 diego        libavformat/siff.c
+M           18196    17227 pross        libavformat/oggdec.c
+            18196    16067 aurel        libavformat/avs.c
+            18196    18011 rbultje      libavformat/rdt.c
+            18196    17779 rbultje      libavformat/rtpproto.c
+            18196    16970 reimar       libavformat/asfcrypt.c
+            18196    17364 lucabe       libavformat/rtpenc.c
+            18196    17188 jbr          libavformat/oggparsevorbis.c
+            18196    16767 jbr          libavformat/oggparseflac.c
+            18196    18100 conrad       libavformat/oggdec.h
+M           18196    17671 aurel        libavformat/matroskadec.c
+            18196    16747 diego        libavformat/network.h
+            18196    18063 bcoudurier   libavformat/ffmenc.c
+            18196    17016 lucabe       libavformat/rdt.h
+M           18196    18137 bcoudurier   libavformat/mpegts.c
+            18196    18032 reimar       libavformat/asfenc.c
+            18196    15120 stefano      libavformat/asfcrypt.h
+            18196    17022 lucabe       libavformat/rtpenc.h
+M           18196    16684 diego        libavformat/mpegts.h
+            18196    16686 diego        libavformat/avisynth.c
+            18196    17390 lucabe       libavformat/rtp.c
+            18196    16912 diego        libavformat/mtv.c
+            18196    17607 bcoudurier   libavformat/dv.c
+            18196    17898 bcoudurier   libavformat/gxfenc.c
+            18196    17666 lucabe       libavformat/rtp.h
+            18196    16912 diego        libavformat/oma.c
+            18196    16684 diego        libavformat/dv.h
+            18196    17396 aurel        libavformat/rm.c
+M           18196    17681 aurel        libavformat/metadata.c
+            18196    18061 rbultje      libavformat/rtpdec.c
+            18196    18009 rbultje      libavformat/rm.h
+            18196    18099 bcoudurier   libavformat/ffmdec.c
+            18196    17670 aurel        libavformat/metadata.h
+            18196    16556 diego        libavformat/lmlm4.c
+M           18196    18032 reimar       libavformat/asfdec.c
+            18196    17779 rbultje      libavformat/rtpdec.h
+            18196    17016 lucabe       libavformat/rtp_mpv.c
+            18196    16912 diego        libavformat/libnut.c
+            18196    16684 diego        libavformat/crcenc.c
+            18196    18061 rbultje      libavformat/rtp_asf.c
+M           18196    18181 bcoudurier   libavformat/mov.c
+            18196    18061 rbultje      libavformat/rtp_asf.h
+            18196    17968 bcoudurier   libavformat/swf.h
+            18196    17554 michael      libavformat/avienc.c
+            18196    17394 aurel        libavformat/ape.c
+            18196    17380 benoit       libavformat/mm.c
+            18196    15785 mru          libavformat/oggparsetheora.c
+            18196    15784 mru          libavformat/oggparseogm.c
+            18196    17075 vitor        libavformat/ncdec.c
+            18196    15430 michael      libavformat/assenc.c
+            18196    16944 benoit       libavformat/flvenc.c
+            18196    17914 reimar       libavformat/audiointerleave.c
+            18196    16912 diego        libavformat/bethsoftvid.c
+            18196    17608 aurel        libavformat/metadata_compat.c
+            18196    17869 michael      libavformat/audiointerleave.h
+            18196    16654 aurel        libavformat/tta.c
+M           18196    18052 bcoudurier   libavformat/avidec.c
+            18196    16684 diego        libavformat/wv.c
+            18196    17183 diego        libavformat/rl2.c
+            18196    17230 michael      libavformat/assdec.c
+M           18196    17783 michael      libavformat/flvdec.c
+            18196    16912 diego        libavformat/xa.c
+            18196    15120 stefano      libavformat/rtspcodes.h
+            18196    18102 conrad       libavformat/oggparsespeex.c
+            18196    17184 diego        libavformat/mmf.c
+            18196    16590 aurel        libavformat/amr.c
+            18196    17971 bcoudurier   libavformat/mxfenc.c
+M           18196    18049 ramiro       libavformat/avformat.h
+            18196    18141 kostya       libavformat/riff.c
+            18196    16688 alexc        libavformat/id3v2.c
+            18196    17686 aurel        libavformat/r3d.c
+            18196    18177 rbultje      libavformat/rtsp.c
+            18196    17690 aurel        libavformat/options.c
+            18196    16912 diego        libavformat/riff.h
+            18196    16688 alexc        libavformat/id3v2.h
+            18196    17866 vitor        libavformat/vqf.c
+            18196    18120 rbultje      libavformat/rtsp.h
+            18196    17016 lucabe       libavformat/rtpenc_h264.c
+M           18196    18051 bcoudurier   libavformat/utils.c
+            18196    16986 ramiro       libavformat/cutils.c
+            18196    18119 rbultje      libavformat/rmenc.c
+            18196    16057 michael      libavformat/nut.c
+            18196    18088 bcoudurier   libavformat/mxfdec.c
+            18196    16912 diego        libavformat/dsicin.c
+            18196    16105 diego        libavformat/nut.h
+            18196    16590 aurel        libavformat/os_support.c
+            18196    17946 reimar       libavformat/idroq.c
+            18196    17779 rbultje      libavformat/http.c
+            18196    17671 aurel        libavformat/matroska.c
+            18196    16912 diego        libavformat/os_support.h
+            18196    15120 stefano      libavformat/avi.h
+            18196    17159 diego        libavformat/gopher.c
+            18196    16684 diego        libavformat/gxf.c
+            18196    17671 aurel        libavformat/matroska.h
+            18196    17364 lucabe       libavformat/sdp.c
+            18196    17779 rbultje      libavformat/udp.c
+            18196    16112 reimar       libavformat/gxf.h
+            18196    16912 diego        libavformat/vc1test.c
+            18196    17042 bcoudurier   libavformat/mxf.c
+            18196    18142 rbultje      libavformat/rmdec.c
+            18196    15262 michael      libavformat/mvi.c
+            18196    16684 diego        libavformat/thp.c
+M           18196    18189 diego        libavformat/Makefile
+            18196    16912 diego        libavformat/flv.h
+            18196    13649 diego        libavformat/msnwc_tcp.c
+            18196    17629 aurel        libavformat/rpl.c
+            18196    17042 bcoudurier   libavformat/mxf.h
+            18196    18145 aurel        libavformat/mp3.c
+            18196    17869 michael      libavformat/dvenc.c
+            18196    17775 benoit       libavformat/txd.c
+            18196    18144 rbultje      libavformat/qtpalette.h
+            18196    16912 diego        libavformat/4xm.c
+M           18196    18032 reimar       libavformat/asf.c
+            18196    17020 lucabe       libavformat/rtp_aac.c
+            18196    16067 aurel        libavformat/vocenc.c
+M           18196    18032 reimar       libavformat/asf.h
+            18196    16684 diego        libavformat/yuv4mpeg.c
+            18196    17113 aurel        libavformat/internal.h
+            18196    17407 aurel        libavformat/nsvdec.c
+            18196    17779 rbultje      libavformat/tcp.c
+            18196    18140 bcoudurier   libavformat/movenc.c
+M           18196    18045 ramiro       libavformat/mpeg.c
+M           18196    18049 ramiro       libavformat/raw.c
+            18196    17606 jbr          libavformat/flacenc.c
+            18196    17373 benoit       libavformat/sierravmd.c
+            18196    17802 melanson     libavformat/wc3movie.c
+M           18196    16684 diego        libavformat/mpeg.h
+            18196    16684 diego        libavformat/sol.c
+            18196    17779 rbultje      libavformat/avio.c
+            18196    16067 aurel        libavformat/c93.c
+            18196    17660 jbr          libavformat/raw.h
+            18196    17606 jbr          libavformat/flacenc.h
+            18196    16912 diego        libavformat/psxstr.c
+M           18196    17779 rbultje      libavformat/avio.h
+            18196    15262 michael      libavformat/apc.c
+            18196    16556 diego        libavformat/vocdec.c
+            18196    16912 diego        libavformat/iff.c
+            18196    17858 michael      libavformat/timefilter.c
+            18196    16684 diego        libavformat/au.c
+            18196    16966 aurel        libavformat/aiff.c
+            18196    17767 rbultje      libavformat/rtp_h264.c
+            18196    17858 michael      libavformat/timefilter.h
+            18196    16912 diego        libavformat/westwood.c
+            18196    16684 diego        libavformat/dxa.c
+            18196    16590 aurel        libavformat/daud.c
+            18196    16912 diego        libavformat/flic.c
+            18196    17016 lucabe       libavformat/rtp_h264.h
+M           18196    17914 reimar       libavformat/mpegenc.c
+            18196    16688 alexc        libavformat/mpc.c
+M           18196    18086 jbr          libavformat/flacdec.c
+            18196    17406 aurel        libavformat/mpegtsenc.c
+            18196    16912 diego        libavformat/segafilm.c
+            18196    17653 aurel        libavformat/nutenc.c
+            18196    16912 diego        libavformat/tiertexseq.c
+M           18196    18049 ramiro       libavformat/allformats.c
+            18196    16684 diego        libavformat/gif.c
+            18196    16684 diego        libavformat/framecrcenc.c
+M           18196    18192 ramiro       libavformat/file.c
+            18196    17652 aurel        libavformat/nutdec.c
+            18196    16912 diego        libavformat/eacdata.c
+            18196    17914 reimar       libavformat/swfenc.c
+            18196    17184 diego        libavformat/idcin.c
+            18196    14945 aurel        libavformat/voc.c
+M           18196    16639 reimar       libavformat/aviobuf.c
+            18196    16067 aurel        libavformat/voc.h
+            18196    16684 diego        libavformat/wav.c
+            18196    10765 diego        ffserver.h
+            18196    18115 kostya       MAINTAINERS
+
+Performing status on external item at 'libswscale'
+            29067    29067 diego        libswscale
+            29067    28981 diego        libswscale/swscale_bfin.c
+            29067    29063 ramiro       libswscale/yuv2rgb.c
+            29067    29065 diego        libswscale/ppc
+            29067    29063 ramiro       libswscale/ppc/yuv2rgb_altivec.c
+            29067    29048 sdrik        libswscale/swscale.c
+            29067    29065 diego        libswscale/mlib
+            29067    29063 ramiro       libswscale/mlib/yuv2rgb_mlib.c
+            29067    29063 ramiro       libswscale/swscale_internal.h
+            29067    28556 kostya       libswscale/swscale_altivec_template.c
+            29067    29065 diego        libswscale/x86
+            29067    29063 ramiro       libswscale/x86/yuv2rgb_mmx.c
+            29067    29063 ramiro       libswscale/x86/yuv2rgb_template.c
+            29067    28700 kostya       libswscale/swscale.h
+            29067    29067 diego        libswscale/colorspace-test.c
+            29067    27592 michael      libswscale/swscale_avoption.c
+            29067    29030 michael      libswscale/rgb2rgb_template.c
+            29067    29065 diego        libswscale/sparc
+            29067    29063 ramiro       libswscale/sparc/yuv2rgb_vis.c
+            29067    28997 michael      libswscale/rgb2rgb.c
+            29067    29017 benoit       libswscale/swscale-example.c
+            29067    27190 diego        libswscale/internal_bfin.S
+            29067    29016 reimar       libswscale/swscale_template.c
+            29067    28997 michael      libswscale/rgb2rgb.h
+            29067    29067 diego        libswscale/Makefile
+            29067    29065 diego        libswscale/bfin
+            29067    29063 ramiro       libswscale/bfin/yuv2rgb_bfin.c
diff --git a/ffmpeg.c b/ffmpeg.c
index 05699bc..63813e4 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -34,7 +34,6 @@
 #include "libavformat/avformat.h"
 #include "libavdevice/avdevice.h"
 #include "libswscale/swscale.h"
-#include "libavformat/framehook.h"
 #include "libavcodec/opt.h"
 #include "libavcodec/audioconvert.h"
 #include "libavutil/fifo.h"
@@ -46,6 +45,11 @@
 #include <sys/resource.h>
 #elif HAVE_GETPROCESSTIMES
 #include <windows.h>
+#define	SIGHUP	1	/* hangup */
+#define	SIGQUIT	3	/* quit */
+#define	SIGKILL	9	/* kill (cannot be caught or ignored) */
+#define	SIGBUS	10	/* bus error */
+#define	SIGPIPE	13	/* broken pipe */
 #endif
 
 #if HAVE_SYS_SELECT_H
@@ -163,6 +167,7 @@
 static int subtitle_disable = 0;
 static char *subtitle_codec_name = NULL;
 static char *subtitle_language = NULL;
+static int subtitle_codec_tag = 0;
 
 static float mux_preload= 0.5;
 static float mux_max_delay= 0.7;
@@ -188,7 +193,13 @@
 static float audio_drift_threshold= 0.1;
 static int copy_ts= 0;
 static int opt_shortest = 0;
+static int active_file = 0;
 static int video_global_header = 0;
+static int stdin_ctrl = 0;
+static int dump_metadata = 0;
+static int min_pix_energy = 0;
+static int min_pix_var = 0;
+static int min_pix_frames_left = 0;
 static char *vstats_filename;
 static FILE *vstats_file;
 static int opt_programid = 0;
@@ -203,7 +214,6 @@
 
 static int exit_on_error = 0;
 static int using_stdin = 0;
-static int using_vhook = 0;
 static int verbose = 1;
 static int thread_count= 1;
 static int q_pressed = 0;
@@ -228,6 +238,8 @@
 static AVBitStreamFilterContext *subtitle_bitstream_filters=NULL;
 static AVBitStreamFilterContext *bitstream_filters[MAX_FILES][MAX_STREAMS];
 
+int bug_broken_dts = 0;
+
 #define DEFAULT_PASS_LOGFILENAME_PREFIX "ffmpeg2pass"
 
 struct AVInputStream;
@@ -265,7 +277,7 @@
     ReSampleContext *resample; /* for audio resampling */
     int reformat_pair;
     AVAudioConvert *reformat_ctx;
-    AVFifoBuffer fifo;     /* for compression: one audio fifo per codec */
+    AVFifoBuffer *fifo;     /* for compression: one audio fifo per codec */
     FILE *logfile;
 } AVOutputStream;
 
@@ -291,6 +303,12 @@
     int nb_streams;       /* nb streams we are aware of */
 } AVInputFile;
 
+static int calc_pixel_stats(AVInputStream *ist, AVFrame *picture, int* average, int* variance);
+
+#define CMD_READ_BUF_SIZE 64
+static int cmdReadBufPos = 0;
+static char cmdReadBuf[CMD_READ_BUF_SIZE];
+
 #if HAVE_TERMIOS_H
 
 /* init terminal so that we can grab keys */
@@ -332,7 +350,7 @@
 
     tcsetattr (0, TCSANOW, &tty);
     signal(SIGQUIT, sigterm_handler); /* Quit (POSIX).  */
-#endif
+//#endif
 
     signal(SIGINT , sigterm_handler); /* Interrupt (ANSI).  */
     signal(SIGTERM, sigterm_handler); /* Termination (ANSI).  */
@@ -343,12 +361,13 @@
 #if CONFIG_BEOS_NETSERVER
     fcntl(0, F_SETFL, fcntl(0, F_GETFL) | O_NONBLOCK);
 #endif
+#endif
 }
 
 /* read a key without blocking */
+#if HAVE_TERMIOS_H
 static int read_key(void)
 {
-#if HAVE_TERMIOS_H
     int n = 1;
     unsigned char ch;
 #if !CONFIG_BEOS_NETSERVER
@@ -362,19 +381,200 @@
     n = select(1, &rfds, NULL, NULL, &tv);
 #endif
     if (n > 0) {
+		if (stdin_ctrl)
+		{
+			int readcount=0;
+			if(cmdReadBufPos >= CMD_READ_BUF_SIZE)
+			{
+				memset(cmdReadBuf,0,CMD_READ_BUF_SIZE);
+				cmdReadBufPos = 0; // reset buffer if we fill it
+			}
+			if((readcount=read(0, &cmdReadBuf[cmdReadBufPos], CMD_READ_BUF_SIZE - cmdReadBufPos))==-1)
+				return -1;
+			cmdReadBufPos += readcount;
+			while (1)
+			{
+				char *eolPos,*eolPos2;
+				int currCmdLen;
+				cmdReadBuf[ (CMD_READ_BUF_SIZE - 1) > cmdReadBufPos ? 
+				cmdReadBufPos : (CMD_READ_BUF_SIZE - 1) ] = 0;
+				eolPos = strchr(cmdReadBuf, '\n');
+				eolPos2 = strchr(cmdReadBuf, '\r');
+				if (!eolPos && !eolPos2)
+					return -1;
+				if(eolPos==0) eolPos=eolPos2;
+				// We've got a command in the buffer, see what it is and deal with it
+				if (strstr(cmdReadBuf, "inactivefile") == cmdReadBuf)
+				{
+					if (active_file)
+					{
+						int i;
+						active_file = 0;
+						// Inactive file command received, update us accordingly.
+						for (i = 0; i < nb_input_files; i++)
+						{
+							URLContext *uc = input_files[i]->pb->opaque;
+							uc->flags&=~URL_ACTIVEFILE;
+						}
+						fprintf(stderr, "Inactive file message has been processed\n");
+					}
+				}
+				else if (strstr(cmdReadBuf, "videorateadapt") == cmdReadBuf)
+				{
+					// Parse the amount we want to adjust the video bitrate by
+					int videoRateAdjust = atoi(cmdReadBuf + strlen("videorateadapt") + 1) * 1000;
+					//fprintf(stderr, "Got video rate adjustment of %d\n", videoRateAdjust);
+					int i, j;
+					for(i=0;i<nb_output_files;i++)
+					{
+						AVFormatContext *avctx = output_files[i];
+						for (j = 0; j < avctx->nb_streams; j++)
+						{
+							AVStream *st = avctx->streams[j];
+							if(st->codec->codec_type == CODEC_TYPE_VIDEO)
+							st->codec->bit_rate = st->codec->bit_rate + videoRateAdjust;
+						}
+					}
+				}
+				*eolPos = 0;
+				currCmdLen = strlen(cmdReadBuf) + 1;
+				if (currCmdLen < cmdReadBufPos)
+				{
+					strcpy(cmdReadBuf, eolPos + 1);
+					cmdReadBufPos -= currCmdLen;
+					memset(&cmdReadBuf[cmdReadBufPos],0,CMD_READ_BUF_SIZE-cmdReadBufPos);
+				}
+				else
+				{
+					cmdReadBufPos = 0;
+					memset(cmdReadBuf,0,CMD_READ_BUF_SIZE);
+				}
+			}
+			return -1;
+		}
+		else
+		{
         n = read(0, &ch, 1);
         if (n == 1)
             return ch;
 
         return n;
     }
-#elif HAVE_CONIO_H
-    if(kbhit())
-        return(getch());
-#endif
+//#elif HAVE_CONIO_H
+//    if(kbhit())
+//        return(getch());
+	}
     return -1;
 }
 
+#else
+struct {
+	char* name;
+	int prio;
+} priority_presets_defs[] = {
+	{ "realtime", REALTIME_PRIORITY_CLASS},
+	{ "high", HIGH_PRIORITY_CLASS},
+#ifdef ABOVE_NORMAL_PRIORITY_CLASS
+	{ "abovenormal", ABOVE_NORMAL_PRIORITY_CLASS},
+#endif
+	{ "normal", NORMAL_PRIORITY_CLASS},
+#ifdef BELOW_NORMAL_PRIORITY_CLASS
+	{ "belownormal", BELOW_NORMAL_PRIORITY_CLASS},
+#endif
+	{ "idle", IDLE_PRIORITY_CLASS},
+	{ NULL, NORMAL_PRIORITY_CLASS} /* default */
+};
+	
+static int read_key(void)
+{
+	unsigned char ch;
+	DWORD retval;
+	char* eolPos;
+	int i,j;
+	int videoRateAdjust;
+	int currCmdLen;
+	
+	HANDLE mystdin = GetStdHandle(STD_INPUT_HANDLE);
+	
+	if(!PeekNamedPipe(mystdin, NULL, 1, &retval, NULL, NULL) || !retval){
+		return -1;
+	}
+
+	if (stdin_ctrl)
+	{
+		if (cmdReadBufPos >= CMD_READ_BUF_SIZE)
+		{
+			memset(cmdReadBuf,0,CMD_READ_BUF_SIZE);
+			cmdReadBufPos = 0; // reset buffer if we fill it
+		}
+		if (!ReadFile(mystdin, &(cmdReadBuf[cmdReadBufPos]), CMD_READ_BUF_SIZE - cmdReadBufPos, &retval, NULL))
+			return -1;
+		cmdReadBufPos += retval;
+		while (1)
+		{
+			cmdReadBuf[min(CMD_READ_BUF_SIZE - 1, cmdReadBufPos)] = 0;
+			eolPos = strchr(cmdReadBuf, '\n');
+			if (!eolPos)
+				return -1;
+			// We've got a command in the buffer, see what it is and deal with it
+			if (strstr(cmdReadBuf, "inactivefile") == cmdReadBuf)
+			{
+				if (active_file)
+				{
+					active_file = 0;
+					// Inactive file command received, update us accordingly.
+					for (i = 0; i < nb_input_files; i++)
+					{
+						URLContext *uc = input_files[i]->pb->opaque;
+						uc->flags&=~URL_ACTIVEFILE;
+					}
+					fprintf(stderr, "Inactive file message has been processed\n");
+				}
+			}
+			else if (strstr(cmdReadBuf, "videorateadapt") == cmdReadBuf)
+			{
+				// Parse the amount we want to adjust the video bitrate by
+				videoRateAdjust = atoi(cmdReadBuf + strlen("videorateadapt") + 1) * 1000;
+				//fprintf(stderr, "Got video rate adjustment of %d\n", videoRateAdjust);
+				for(i=0;i<nb_output_files;i++)
+				{
+					AVFormatContext *avctx = output_files[i];
+					for (j = 0; j < avctx->nb_streams; j++)
+					{
+						AVStream *st = avctx->streams[j];
+						if(st->codec->codec_type == CODEC_TYPE_VIDEO)
+						st->codec->bit_rate = st->codec->bit_rate + videoRateAdjust;
+					}
+				}
+			}
+			*eolPos = 0;
+			currCmdLen = strlen(cmdReadBuf) + 1;
+			if (currCmdLen < cmdReadBufPos)
+			{
+				strcpy(cmdReadBuf, eolPos + 1);
+				cmdReadBufPos -= currCmdLen;
+				memset(&cmdReadBuf[cmdReadBufPos],0,CMD_READ_BUF_SIZE-cmdReadBufPos);
+			}
+			else
+			{
+				cmdReadBufPos = 0;
+				memset(cmdReadBuf,0,CMD_READ_BUF_SIZE);
+			}
+		}
+		return -1;
+	}
+	else
+	{
+		if (ReadFile(mystdin, &ch, 1, &retval, NULL) && retval)
+			return ch;
+		else
+			return -1;
+	}
+}
+ 
+#endif
+
+// DrD: leave this in since it's used if FFMPEG detects if stdin is a TTY
 static int decode_interrupt_cb(void)
 {
     return q_pressed || (q_pressed = read_key() == 'q');
@@ -439,6 +639,55 @@
     return ret;
 }
 
+// returns NULL if the given filename should be used
+static char *indirect_filename_buffer = NULL;
+static char *get_real_filename(const char *filename)
+{
+	int ii;
+	const char *ext;
+	
+	if(!filename) return NULL;
+	if(!strlen(filename)) return NULL;
+	
+	ext = filename + strlen(filename) - 1;
+	
+	for(ii = strlen(filename) - 1; ii > 0; ii--) {
+		if(filename[ii] == '.') {
+			ext = &filename[ii]+1; // skip the dot
+			break;
+		}
+	}
+	
+	if(!strcmp(ext,"txt")) { // FIXME: should use .url instead?
+		FILE *fnf;
+		size_t count;
+		
+		if(!indirect_filename_buffer) {
+			indirect_filename_buffer = (char*)av_malloc(PATH_MAX);
+			if(!indirect_filename_buffer)
+				return NULL;
+		}
+		
+		fnf = fopen(filename, "r");
+		if(!fnf) {
+			av_log(NULL, AV_LOG_ERROR, "Unable to open \"%s\" for reading.\n", filename);
+			return NULL;
+		}
+		
+		count = fread(indirect_filename_buffer, 1, PATH_MAX, fnf);
+		fclose(fnf);
+		if(count <= 0) {
+			av_log(NULL, AV_LOG_ERROR, "Error reading filename from intermediate file.\n");
+			return NULL;
+		} else {
+			indirect_filename_buffer[count] = '\0'; // make sure it's NULL terminated
+			return indirect_filename_buffer;
+		}
+	}
+	
+	return NULL;
+}
+
 static int read_ffserver_streams(AVFormatContext *s, const char *filename)
 {
     int i, err;
@@ -587,7 +836,7 @@
 
     if(audio_sync_method){
         double delta = get_sync_ipts(ost) * enc->sample_rate - ost->sync_opts
-                - av_fifo_size(&ost->fifo)/(ost->st->codec->channels * 2);
+                - av_fifo_size(ost->fifo)/(ost->st->codec->channels * 2);
         double idelta= delta*ist->st->codec->sample_rate / enc->sample_rate;
         int byte_delta= ((int)idelta)*2*ist->st->codec->channels;
 
@@ -624,13 +873,13 @@
                 assert(ost->audio_resample);
                 if(verbose > 2)
                     fprintf(stderr, "compensating audio timestamp drift:%f compensation:%d in:%d\n", delta, comp, enc->sample_rate);
-//                fprintf(stderr, "drift:%f len:%d opts:%"PRId64" ipts:%"PRId64" fifo:%d\n", delta, -1, ost->sync_opts, (int64_t)(get_sync_ipts(ost) * enc->sample_rate), av_fifo_size(&ost->fifo)/(ost->st->codec->channels * 2));
+//                fprintf(stderr, "drift:%f len:%d opts:%"PRId64" ipts:%"PRId64" fifo:%d\n", delta, -1, ost->sync_opts, (int64_t)(get_sync_ipts(ost) * enc->sample_rate), av_fifo_size(ost->fifo)/(ost->st->codec->channels * 2));
                 av_resample_compensate(*(struct AVResampleContext**)ost->resample, comp, enc->sample_rate);
             }
         }
     }else
         ost->sync_opts= lrintf(get_sync_ipts(ost) * enc->sample_rate)
-                        - av_fifo_size(&ost->fifo)/(ost->st->codec->channels * 2); //FIXME wrong
+                        - av_fifo_size(ost->fifo)/(ost->st->codec->channels * 2); //FIXME wrong
 
     if (ost->audio_resample) {
         buftmp = audio_buf;
@@ -662,19 +911,19 @@
     /* now encode as many frames as possible */
     if (enc->frame_size > 1) {
         /* output resampled raw samples */
-        if (av_fifo_realloc2(&ost->fifo, av_fifo_size(&ost->fifo) + size_out) < 0) {
+        if (av_fifo_realloc2(ost->fifo, av_fifo_size(ost->fifo) + size_out) < 0) {
             fprintf(stderr, "av_fifo_realloc2() failed\n");
             av_exit(1);
         }
-        av_fifo_generic_write(&ost->fifo, buftmp, size_out, NULL);
+        av_fifo_generic_write(ost->fifo, buftmp, size_out, NULL);
 
         frame_bytes = enc->frame_size * osize * enc->channels;
 
-        while (av_fifo_size(&ost->fifo) >= frame_bytes) {
+        while (av_fifo_size(ost->fifo) >= frame_bytes) {
             AVPacket pkt;
             av_init_packet(&pkt);
 
-            av_fifo_read(&ost->fifo, audio_buf, frame_bytes);
+            av_fifo_generic_read(ost->fifo, audio_buf, frame_bytes, NULL);
 
             //FIXME pass ost->sync_opts as AVFrame.pts in avcodec_encode_audio()
 
@@ -736,7 +985,7 @@
     dec = ist->st->codec;
 
     /* deinterlace : must be done before any resize */
-    if (do_deinterlace || using_vhook) {
+    if (do_deinterlace) {
         int size;
 
         /* create temporary picture */
@@ -764,15 +1013,107 @@
         picture2 = picture;
     }
 
-    if (CONFIG_VHOOK)
-        frame_hook_process(picture2, dec->pix_fmt, dec->width, dec->height,
-                           1000000 * ist->pts / AV_TIME_BASE);
-
     if (picture != picture2)
         *picture = *picture2;
     *bufp = buf;
 }
 
+// return 0 on success, anything else on failure
+static int calc_pixel_stats(AVInputStream *ist, AVFrame *picture, int* average, int* variance)
+{
+	// To get the energy we use the luminace value of each pixel. If it's YUV, that's easy. If it's RGB then we average the 3 components together.
+	int yuvspace = 0;
+	int ychannel = 0;
+	int packed = 0;
+	int pixbytes = 0;
+	enum PixelFormat pixFmt = ist->st->codec->pix_fmt;
+	int width = ist->st->codec->width;
+	int height = ist->st->codec->height;
+	switch (pixFmt)
+	{
+		case PIX_FMT_YUV420P:
+		case PIX_FMT_YUV422P:
+		case PIX_FMT_YUV444P:
+		case PIX_FMT_YUV410P:
+		case PIX_FMT_YUV411P:
+		case PIX_FMT_YUVJ420P:
+		case PIX_FMT_YUVJ422P:
+		case PIX_FMT_YUVJ444P:
+			yuvspace = 1;
+			ychannel = 0;
+			packed = 0;
+			pixbytes = 1;
+			break;
+		case PIX_FMT_YUYV422:
+			yuvspace = 1;
+			ychannel = 0;
+			packed = 1;
+			pixbytes = 2;
+			break;
+		case PIX_FMT_UYVY422:
+			yuvspace = 1;
+			ychannel = 1;
+			packed = 1;
+			pixbytes = 2;
+			break;
+		case PIX_FMT_BGR24:
+		case PIX_FMT_RGB24:
+			yuvspace = 0;
+			packed = 1;
+			pixbytes = 3;
+			break;
+		case PIX_FMT_RGB32:
+		case PIX_FMT_BGR32:
+			yuvspace = 0;
+			packed = 1;
+			pixbytes = 4;
+			break;
+		default:
+            av_log(NULL, AV_LOG_ERROR, "Unsupported colorspace for image energy calculations\n");
+			return 1; // we don't deal with this colorspace
+	}
+	if (yuvspace)
+	{
+		if (packed)
+		{
+            av_log(NULL, AV_LOG_ERROR, "TEMP: Unsupported colorspace for image energy calculations\n");
+			return 1; // we don't deal with this colorspace
+		}
+		else
+		{
+			int avgEnergy,avgVariance;
+			double totalEnergy = 0;
+			double totalVariance = 0;
+			uint8_t* currData = picture->data[ychannel];
+			int y = 0, x = 0;
+			for (y = 0; y < height; y++, currData += picture->linesize[ychannel])
+			{
+				for (x = 0; x < width; x++)
+				{
+					int currVal = currData[x*pixbytes];
+					totalEnergy += currVal;
+					totalVariance += currVal*currVal;
+				}
+			}
+			avgEnergy = (int)(totalEnergy/(width*height));
+			//av_log(NULL, AV_LOG_INFO, "Pixel average value is %d\n", avgEnergy);
+			avgVariance = (int)(totalVariance/(width*height) - avgEnergy*avgEnergy);
+			//av_log(NULL, AV_LOG_INFO, "Pixel variance value is %d\n", avgVariance);
+			if (average)
+				*average = avgEnergy;
+			if (variance)
+				*variance = avgVariance;
+			return 0;
+
+		}
+	}
+	else
+	{
+        av_log(NULL, AV_LOG_ERROR, "TEMP: Unsupported colorspace for image energy calculations\n");
+		return 1; // we don't deal with this colorspace
+	}
+}
+
 /* we begin to correct av delay at this threshold */
 #define AV_DELAY_MAX 0.100
 
@@ -868,7 +1209,8 @@
             ost->sync_opts= lrintf(get_sync_ipts(ost) / av_q2d(enc->time_base));
         }else if (vdelta > 1.1)
             nb_frames = lrintf(vdelta);
-//fprintf(stderr, "vdelta:%f, ost->sync_opts:%"PRId64", ost->sync_ipts:%f nb_frames:%d\n", vdelta, ost->sync_opts, get_sync_ipts(ost), nb_frames);
+//fprintf(stderr, "vdelta:%lf (sync_ipts %lld, tb %d:%d), ost->sync_opts:%"PRId64", ost->sync_ipts:%f nb_frames:%d\n",
+//		vdelta, (long long)get_sync_ipts(ost), enc->time_base.num, enc->time_base.den, ost->sync_opts, get_sync_ipts(ost), nb_frames);
         if (nb_frames == 0){
             ++nb_frames_drop;
             if (verbose>2)
@@ -881,6 +1223,30 @@
     }else
         ost->sync_opts= lrintf(get_sync_ipts(ost) / av_q2d(enc->time_base));
 
+	if (min_pix_energy > 0 || min_pix_var > 0)
+	{
+		// Check this frame for image quality and skip it if it's not good enough (optmized thumbnail generation)
+		static int saw_key_frame = 0; // FIXME: I don't like embedded static vars...
+		int average, variance;
+		
+//		fprintf(stderr, "pic info: type %d, qual %d, keyframe %d, skf %d\n", in_picture->pict_type, in_picture->quality, in_picture->key_frame, saw_key_frame);
+		if (!saw_key_frame && !in_picture->key_frame)
+			return;
+		saw_key_frame = 1;
+		
+		if (!calc_pixel_stats(ist, in_picture, &average, &variance))
+		{
+//			fprintf(stderr, "pixel stats: average %d, variance %d, frames left %d\n", average, variance, min_pix_frames_left);
+			// Calculation succeeded, do the check
+			if ((min_pix_frames_left != 1) && ((min_pix_energy > 0 && average < min_pix_energy) || (min_pix_var > 0 && variance < min_pix_var)))
+			{
+				min_pix_frames_left--;
+				//av_log(NULL, AV_LOG_INFO, "Skipping encoding of video frame due to energy/variance constraints\n");
+				return;
+			}
+		}
+	}
+
     nb_frames= FFMIN(nb_frames, max_frames[CODEC_TYPE_VIDEO] - ost->frame_number);
     if (nb_frames <= 0)
         return;
@@ -974,10 +1340,11 @@
             ret = avcodec_encode_video(enc,
                                        bit_buffer, bit_buffer_size,
                                        &big_picture);
-            if (ret < 0) {
+// NARFLEX: I disabled this because it can still work even if this happens so there's no reason to bail!
+/*            if (ret < 0) {
                 fprintf(stderr, "Video encoding failed\n");
                 av_exit(1);
-            }
+            }*/
             //enc->frame_number = enc->real_pict_num;
             if(ret>0){
                 pkt.data= bit_buffer;
@@ -1252,6 +1619,7 @@
 
                     ret = avcodec_decode_video(ist->st->codec,
                                                &picture, &got_picture, ptr, len);
+//if (got_picture) fprintf(stderr, "   -- got picture, pts = %lld\n", picture.pts);
                     ist->st->quality= picture.quality;
                     if (ret < 0)
                         goto fail_decode;
@@ -1341,6 +1709,10 @@
                     os = output_files[ost->file_index];
 
 #if 0
+if (ost->st->codec->codec_type == CODEC_TYPE_VIDEO && pkt && ist)
+	fprintf(stderr, "  -- video pts = %lld, picture pts = %lld, pkt pts = %lld\n", av_rescale(ist->pts, 90000, AV_TIME_BASE), picture.pts, pkt->pts);
+if (ost->st->codec->codec_type == CODEC_TYPE_AUDIO && pkt && ist)
+	fprintf(stderr, "  -- audio pts = %lld, pkt pts = %lld\n", av_rescale(ist->pts, 90000, AV_TIME_BASE), pkt->pts);
                     printf("%d: got pts=%0.3f %0.3f\n", i,
                            (double)pkt->pts / AV_TIME_BASE,
                            ((double)ist->pts / AV_TIME_BASE) -
@@ -1452,13 +1824,13 @@
 
                         switch(ost->st->codec->codec_type) {
                         case CODEC_TYPE_AUDIO:
-                            fifo_bytes = av_fifo_size(&ost->fifo);
+                            fifo_bytes = av_fifo_size(ost->fifo);
                             ret = 0;
                             /* encode any samples remaining in fifo */
                             if(fifo_bytes > 0 && enc->codec->capabilities & CODEC_CAP_SMALL_LAST_FRAME) {
                                 int fs_tmp = enc->frame_size;
                                 enc->frame_size = fifo_bytes / (2 * enc->channels);
-                                av_fifo_read(&ost->fifo, (uint8_t *)samples, fifo_bytes);
+                                av_fifo_generic_read(ost->fifo, samples, fifo_bytes, NULL);
                                     ret = avcodec_encode_audio(enc, bit_buffer, bit_buffer_size, samples);
                                 enc->frame_size = fs_tmp;
                             }
@@ -1551,14 +1923,17 @@
                      int nb_input_files,
                      AVStreamMap *stream_maps, int nb_stream_maps)
 {
-    int ret, i, j, k, n, nb_istreams = 0, nb_ostreams = 0;
+    int ret = 0, i, j, k, n, nb_istreams = 0, nb_ostreams = 0;
     AVFormatContext *is, *os;
     AVCodecContext *codec, *icodec;
     AVOutputStream *ost, **ost_table = NULL;
     AVInputStream *ist, **ist_table = NULL;
     AVInputFile *file_table;
+    char error[1024];
     int key;
     int want_sdp = 1;
+    uint8_t no_packet[MAX_FILES]={0};
+    int no_packet_count=0;
 
     file_table= av_mallocz(nb_input_files * sizeof(AVInputFile));
     if (!file_table)
@@ -1772,10 +2147,6 @@
                     codec->block_align= 0;
                 break;
             case CODEC_TYPE_VIDEO:
-                if(using_vhook) {
-                    fprintf(stderr,"-vcodec copy and -vhook are incompatible (frames are not decoded)\n");
-                    av_exit(1);
-                }
                 codec->pix_fmt = icodec->pix_fmt;
                 codec->width = icodec->width;
                 codec->height = icodec->height;
@@ -1791,7 +2162,8 @@
         } else {
             switch(codec->codec_type) {
             case CODEC_TYPE_AUDIO:
-                if (av_fifo_init(&ost->fifo, 1024))
+                ost->fifo= av_fifo_alloc(1024);
+                if(!ost->fifo)
                     goto fail;
                 ost->reformat_pair = MAKE_SFMT_PAIR(SAMPLE_FMT_NONE,SAMPLE_FMT_NONE);
                 ost->audio_resample = codec->sample_rate != icodec->sample_rate || audio_sync_method > 1;
@@ -1906,31 +2278,9 @@
 
     if (!bit_buffer)
         bit_buffer = av_malloc(bit_buffer_size);
-    if (!bit_buffer)
+    if (!bit_buffer) {
+        ret = AVERROR(ENOMEM);
         goto fail;
-
-    /* dump the file output parameters - cannot be done before in case
-       of stream copy */
-    for(i=0;i<nb_output_files;i++) {
-        dump_format(output_files[i], i, output_files[i]->filename, 1);
-    }
-
-    /* dump the stream mapping */
-    if (verbose >= 0) {
-        fprintf(stderr, "Stream mapping:\n");
-        for(i=0;i<nb_ostreams;i++) {
-            ost = ost_table[i];
-            fprintf(stderr, "  Stream #%d.%d -> #%d.%d",
-                    ist_table[ost->source_index]->file_index,
-                    ist_table[ost->source_index]->index,
-                    ost->file_index,
-                    ost->index);
-            if (ost->sync_ist != ist_table[ost->source_index])
-                fprintf(stderr, " [sync #%d.%d]",
-                        ost->sync_ist->file_index,
-                        ost->sync_ist->index);
-            fprintf(stderr, "\n");
-        }
     }
 
     /* open each encoder */
@@ -1941,14 +2291,16 @@
             if (!codec)
                 codec = avcodec_find_encoder(ost->st->codec->codec_id);
             if (!codec) {
-                fprintf(stderr, "Unsupported codec for output stream #%d.%d\n",
+                snprintf(error, sizeof(error), "Unsupported codec for output stream #%d.%d",
                         ost->file_index, ost->index);
-                av_exit(1);
+                ret = AVERROR(EINVAL);
+                goto dump_format;
             }
             if (avcodec_open(ost->st->codec, codec) < 0) {
-                fprintf(stderr, "Error while opening codec for output stream #%d.%d - maybe incorrect parameters such as bit_rate, rate, width or height\n",
+                snprintf(error, sizeof(error), "Error while opening codec for output stream #%d.%d - maybe incorrect parameters such as bit_rate, rate, width or height",
                         ost->file_index, ost->index);
-                av_exit(1);
+                ret = AVERROR(EINVAL);
+                goto dump_format;
             }
             extra_size += ost->st->codec->extradata_size;
         }
@@ -1962,14 +2314,16 @@
             if (!codec)
                 codec = avcodec_find_decoder(ist->st->codec->codec_id);
             if (!codec) {
-                fprintf(stderr, "Unsupported codec (id=%d) for input stream #%d.%d\n",
+                snprintf(error, sizeof(error), "Unsupported codec (id=%d) for input stream #%d.%d",
                         ist->st->codec->codec_id, ist->file_index, ist->index);
-                av_exit(1);
+                ret = AVERROR(EINVAL);
+                goto dump_format;
             }
             if (avcodec_open(ist->st->codec, codec) < 0) {
-                fprintf(stderr, "Error while opening codec for input stream #%d.%d\n",
+                snprintf(error, sizeof(error), "Error while opening codec for input stream #%d.%d",
                         ist->file_index, ist->index);
-                av_exit(1);
+                ret = AVERROR(EINVAL);
+                goto dump_format;
             }
             //if (ist->st->codec->codec_type == CODEC_TYPE_VIDEO)
             //    ist->st->codec->flags |= CODEC_FLAG_REPEAT_FIELD;
@@ -1994,14 +2348,16 @@
         int out_file_index = meta_data_maps[i].out_file;
         int in_file_index = meta_data_maps[i].in_file;
         if (out_file_index < 0 || out_file_index >= nb_output_files) {
-            fprintf(stderr, "Invalid output file index %d map_meta_data(%d,%d)\n", out_file_index, out_file_index, in_file_index);
+            snprintf(error, sizeof(error), "Invalid output file index %d map_meta_data(%d,%d)",
+                     out_file_index, out_file_index, in_file_index);
             ret = AVERROR(EINVAL);
-            goto fail;
+            goto dump_format;
         }
         if (in_file_index < 0 || in_file_index >= nb_input_files) {
-            fprintf(stderr, "Invalid input file index %d map_meta_data(%d,%d)\n", in_file_index, out_file_index, in_file_index);
+            snprintf(error, sizeof(error), "Invalid input file index %d map_meta_data(%d,%d)",
+                     in_file_index, out_file_index, in_file_index);
             ret = AVERROR(EINVAL);
-            goto fail;
+            goto dump_format;
         }
 
         out_file = output_files[out_file_index];
@@ -2019,22 +2375,53 @@
     for(i=0;i<nb_output_files;i++) {
         os = output_files[i];
         if (av_write_header(os) < 0) {
-            fprintf(stderr, "Could not write header for output file #%d (incorrect codec parameters ?)\n", i);
+            snprintf(error, sizeof(error), "Could not write header for output file #%d (incorrect codec parameters ?)", i);
             ret = AVERROR(EINVAL);
-            goto fail;
+            goto dump_format;
         }
         if (strcmp(output_files[i]->oformat->name, "rtp")) {
             want_sdp = 0;
         }
     }
+
+ dump_format:
+    /* dump the file output parameters - cannot be done before in case
+       of stream copy */
+    for(i=0;i<nb_output_files;i++) {
+        dump_format(output_files[i], i, output_files[i]->filename, 1);
+    }
+
+    /* dump the stream mapping */
+    if (verbose >= 0) {
+        fprintf(stderr, "Stream mapping:\n");
+        for(i=0;i<nb_ostreams;i++) {
+            ost = ost_table[i];
+            fprintf(stderr, "  Stream #%d.%d -> #%d.%d",
+                    ist_table[ost->source_index]->file_index,
+                    ist_table[ost->source_index]->index,
+                    ost->file_index,
+                    ost->index);
+            if (ost->sync_ist != ist_table[ost->source_index])
+                fprintf(stderr, " [sync #%d.%d]",
+                        ost->sync_ist->file_index,
+                        ost->sync_ist->index);
+            fprintf(stderr, "\n");
+        }
+    }
+
+    if (ret) {
+        fprintf(stderr, "%s\n", error);
+        goto fail;
+    }
+
     if (want_sdp) {
         print_sdp(output_files, nb_output_files);
     }
 
-    if (!using_stdin && verbose >= 0) {
+/*    if (!using_stdin && verbose >= 0) {
         fprintf(stderr, "Press [q] to stop encoding\n");
         url_set_interrupt_cb(decode_interrupt_cb);
-    }
+    } */
     term_init();
 
     key = -1;
@@ -2067,6 +2454,8 @@
             ost = ost_table[i];
             os = output_files[ost->file_index];
             ist = ist_table[ost->source_index];
+            if(no_packet[ist->file_index])
+                continue;
             if(ost->st->codec->codec_type == CODEC_TYPE_VIDEO)
                 opts = ost->sync_opts * av_q2d(ost->st->codec->time_base);
             else
@@ -2089,6 +2478,12 @@
         }
         /* if none, if is finished */
         if (file_index < 0) {
+            if(no_packet_count){
+                no_packet_count=0;
+                memset(no_packet, 0, sizeof(no_packet));
+                usleep(10000);
+                continue;
+            }
             break;
         }
 
@@ -2102,7 +2497,13 @@
 
         /* read a frame from it and output it in the fifo */
         is = input_files[file_index];
-        if (av_read_frame(is, &pkt) < 0) {
+        ret= av_read_frame(is, &pkt);
+        if(ret == AVERROR(EAGAIN)){
+            no_packet[file_index]=1;
+            no_packet_count++;
+            continue;
+        }
+        if (ret < 0) {
             file_table[file_index].eof_reached = 1;
             if (opt_shortest)
                 break;
@@ -2110,6 +2511,9 @@
                 continue;
         }
 
+        no_packet_count=0;
+        memset(no_packet, 0, sizeof(no_packet));
+
         if (do_pkt_dump) {
             av_pkt_dump_log(NULL, AV_LOG_DEBUG, &pkt, do_hex_dump);
         }
@@ -2134,7 +2538,7 @@
                 pkt.dts *= input_files_ts_scale[file_index][pkt.stream_index];
         }
 
-//        fprintf(stderr, "next:%"PRId64" dts:%"PRId64" off:%"PRId64" %d\n", ist->next_pts, pkt.dts, input_files_ts_offset[ist->file_index], ist->st->codec->codec_type);
+//        fprintf(stderr, "next %d:%"PRId64" dts:%"PRId64" off:%"PRId64" %d\n", ist->st->codec->codec_type, ist->next_pts, pkt.dts, input_files_ts_offset[ist->file_index], ist->st->codec->codec_type);
         if (pkt.dts != AV_NOPTS_VALUE && ist->next_pts != AV_NOPTS_VALUE
             && (is->iformat->flags & AVFMT_TS_DISCONT)) {
             int64_t pkt_dts= av_rescale_q(pkt.dts, ist->st->time_base, AV_TIME_BASE_Q);
@@ -2205,9 +2609,9 @@
     }
 
     /* finished ! */
-
     ret = 0;
- fail1:
+
+ fail:
     av_freep(&bit_buffer);
     av_free(file_table);
 
@@ -2226,7 +2630,7 @@
                     fclose(ost->logfile);
                     ost->logfile = NULL;
                 }
-                av_fifo_free(&ost->fifo); /* works even if fifo is not
+                av_fifo_free(ost->fifo); /* works even if fifo is not
                                              initialized but set to zero */
                 av_free(ost->pict_tmp.data[0]);
                 if (ost->video_resample)
@@ -2241,9 +2645,6 @@
         av_free(ost_table);
     }
     return ret;
- fail:
-    ret = AVERROR(ENOMEM);
-    goto fail1;
 }
 
 #if 0
@@ -2297,10 +2698,16 @@
     return 0;
 }
 
+static void opt_loglevel(const char *opt, const char *arg)
+{
+    int level = parse_number_or_die(opt, arg, OPT_INT, INT_MIN, INT_MAX);
+    av_log_set_level(level);
+}
+
 static int opt_verbose(const char *opt, const char *arg)
 {
     verbose = parse_number_or_die(opt, arg, OPT_INT64, -10, 10);
-    av_log_set_level(verbose);
+	if (verbose >= 2) av_log_set_level(50);
     return 0;
 }
 
@@ -2507,9 +2914,13 @@
 
 static void opt_frame_pix_fmt(const char *arg)
 {
-    if (strcmp(arg, "list"))
+    if (strcmp(arg, "list")) {
         frame_pix_fmt = avcodec_get_pix_fmt(arg);
-    else {
+        if (frame_pix_fmt == PIX_FMT_NONE) {
+            fprintf(stderr, "Unknown pixel format requested: %s\n", arg);
+            av_exit(1);
+        }
+    } else {
         list_fmts(avcodec_pix_fmt_string, PIX_FMT_NB);
         av_exit(0);
     }
@@ -2648,29 +3059,6 @@
         video_codec_tag= arg[0] + (arg[1]<<8) + (arg[2]<<16) + (arg[3]<<24);
 }
 
-#if CONFIG_VHOOK
-static void add_frame_hooker(const char *arg)
-{
-    int argc = 0;
-    char *argv[64];
-    int i;
-    char *args = av_strdup(arg);
-
-    using_vhook = 1;
-
-    argv[0] = strtok(args, " ");
-    while (argc < 62 && (argv[++argc] = strtok(NULL, " "))) {
-    }
-
-    i = frame_hook_add(argc, argv);
-
-    if (i != 0) {
-        fprintf(stderr, "Failed to add video hook function: %s\n", arg);
-        av_exit(1);
-    }
-}
-#endif
-
 static void opt_video_codec(const char *arg)
 {
     opt_codec(&video_stream_copy, &video_codec_name, CODEC_TYPE_VIDEO, arg);
@@ -2681,6 +3069,15 @@
     opt_codec(&subtitle_stream_copy, &subtitle_codec_name, CODEC_TYPE_SUBTITLE, arg);
 }
 
+static void opt_subtitle_tag(const char *arg)
+{
+    char *tail;
+    subtitle_codec_tag= strtol(arg, &tail, 0);
+
+    if(!tail || *tail)
+        subtitle_codec_tag= arg[0] + (arg[1]<<8) + (arg[2]<<16) + (arg[3]<<24);
+}
+
 static void opt_map(const char *arg)
 {
     AVStreamMap *m;
@@ -2742,6 +3139,19 @@
     return 0;
 }
 
+#ifdef __MINGW32__
+static void opt_priority(const char *arg)
+{
+	int i;
+   	for(i=0; priority_presets_defs[i].name; i++)
+	{
+   		if(strcasecmp(priority_presets_defs[i].name, arg) == 0)
+			break;
+	}
+	SetPriorityClass(GetCurrentProcess(), priority_presets_defs[i].prio);
+}
+#endif
+
 static int opt_start_time(const char *opt, const char *arg)
 {
     start_time = parse_time_or_die(opt, arg, 1);
@@ -2787,6 +3197,12 @@
     AVFormatParameters params, *ap = &params;
     int err, i, ret, rfps, rfps_base;
     int64_t timestamp;
+	char *real_filename = get_real_filename(filename);
+	
+	if(real_filename) {
+		opt_input_file(real_filename);
+		return;
+	}
 
     if (!strcmp(filename, "-"))
         filename = "pipe:";
@@ -2819,6 +3235,7 @@
     ic->video_codec_id   = find_codec_or_die(video_codec_name   , CODEC_TYPE_VIDEO   , 0);
     ic->audio_codec_id   = find_codec_or_die(audio_codec_name   , CODEC_TYPE_AUDIO   , 0);
     ic->subtitle_codec_id= find_codec_or_die(subtitle_codec_name, CODEC_TYPE_SUBTITLE, 0);
+    ic->flags |= AVFMT_FLAG_NONBLOCK;
 
     /* open the input file with generic libav function */
     err = av_open_input_file(&ic, filename, file_iformat, 0, ap);
@@ -2835,6 +3252,12 @@
 
     ic->loop_input = loop_input;
 
+	if (active_file)
+	{
+		URLContext *uc = ic->pb->opaque;
+		uc->flags|=URL_ACTIVEFILE;
+	}
+
     /* If not enough info to get the stream parameters, we decode the
        first frames to get it. (used in mpeg case for example) */
     ret = av_find_stream_info(ic);
@@ -2929,7 +3352,11 @@
 
     input_files[nb_input_files] = ic;
     input_files_ts_offset[nb_input_files] = input_ts_offset - (copy_ts ? 0 : timestamp);
-    /* dump the file content */
+	
+	/* dump metadata */
+	if (dump_metadata)
+		av_metadata_dump(ic);
+	/* dump the file content */
     if (verbose >= 0)
         dump_format(ic, nb_input_files, filename, 0);
 
@@ -3221,6 +3648,10 @@
 
     subtitle_enc = st->codec;
     subtitle_enc->codec_type = CODEC_TYPE_SUBTITLE;
+
+    if(subtitle_codec_tag)
+        subtitle_enc->codec_tag= subtitle_codec_tag;
+
     if (subtitle_stream_copy) {
         st->stream_copy = 1;
     } else {
@@ -3280,6 +3711,12 @@
     int use_video, use_audio, use_subtitle;
     int input_has_video, input_has_audio, input_has_subtitle;
     AVFormatParameters params, *ap = &params;
+	char *real_filename = get_real_filename(filename);
+	
+	if(real_filename) {
+		opt_output_file(real_filename);
+		return;
+	}
 
     if (!strcmp(filename, "-"))
         filename = "pipe:";
@@ -3374,13 +3811,10 @@
              filename[1] == ':' ||
              av_strstart(filename, "file:", NULL))) {
             if (url_exist(filename)) {
-                int c;
-
                 if (!using_stdin) {
                     fprintf(stderr,"File '%s' already exists. Overwrite ? [y/N] ", filename);
                     fflush(stderr);
-                    c = getchar();
-                    if (toupper(c) != 'Y') {
+                    if (!read_yesno()) {
                         fprintf(stderr, "Not overwriting - exiting\n");
                         av_exit(1);
                     }
@@ -3409,6 +3843,7 @@
     oc->preload= (int)(mux_preload*AV_TIME_BASE);
     oc->max_delay= (int)(mux_max_delay*AV_TIME_BASE);
     oc->loop_output = loop_output;
+    oc->flags |= AVFMT_FLAG_NONBLOCK;
 
     set_context_opts(oc, avformat_opts, AV_OPT_FLAG_ENCODING_PARAM);
 
@@ -3790,7 +4225,8 @@
     { "re", OPT_BOOL | OPT_EXPERT, {(void*)&rate_emu}, "read input at native frame rate", "" },
     { "loop_input", OPT_BOOL | OPT_EXPERT, {(void*)&loop_input}, "loop (current only works with images)" },
     { "loop_output", HAS_ARG | OPT_INT | OPT_EXPERT, {(void*)&loop_output}, "number of times to loop output in formats that support looping (0 loops forever)", "" },
-    { "v", HAS_ARG | OPT_FUNC2, {(void*)opt_verbose}, "set the logging verbosity level", "number" },
+    { "v", HAS_ARG | OPT_FUNC2, {(void*)opt_verbose}, "set ffmpeg verbosity level", "number" },
+    { "loglevel", HAS_ARG | OPT_FUNC2, {(void*)opt_loglevel}, "set libav* logging level", "number" },
     { "target", HAS_ARG, {(void*)opt_target}, "specify target file type (\"vcd\", \"svcd\", \"dvd\", \"dv\", \"dv50\", \"pal-vcd\", \"ntsc-svcd\", ...)", "type" },
     { "threads", OPT_FUNC2 | HAS_ARG | OPT_EXPERT, {(void*)opt_thread_count}, "thread count", "count" },
     { "vsync", HAS_ARG | OPT_INT | OPT_EXPERT, {(void*)&video_sync_method}, "video sync method", "" },
@@ -3800,6 +4236,16 @@
     { "copyts", OPT_BOOL | OPT_EXPERT, {(void*)&copy_ts}, "copy timestamps" },
     { "shortest", OPT_BOOL | OPT_EXPERT, {(void*)&opt_shortest}, "finish encoding within shortest input" }, //
     { "dts_delta_threshold", HAS_ARG | OPT_FLOAT | OPT_EXPERT, {(void*)&dts_delta_threshold}, "timestamp discontinuity delta threshold", "threshold" },
+    { "activefile", OPT_BOOL | OPT_EXPERT, {(void*)&active_file}, "active file" },
+    { "stdinctrl", OPT_BOOL | OPT_EXPERT, {(void*)&stdin_ctrl}, "accept control commands through stdin (inactivefile, rateadjust)" },
+	{ "dumpmetadata", OPT_BOOL | OPT_EXPERT, {(void*)&dump_metadata}, "dump metadata information to stderr" },
+	{ "minpixenergy", HAS_ARG | OPT_INT, {(void*)&min_pix_energy}, "min pixel energy for thumb", "" },
+	{ "minpixvar", HAS_ARG | OPT_INT, {(void*)&min_pix_var}, "min pixel variance for thumb", "" },
+	{ "minpixnumframes", HAS_ARG | OPT_INT, {(void*)&min_pix_frames_left}, "max num frames to check for min pix req.", "" },
+	{ "brokendts", OPT_BOOL | OPT_EXPERT, {(void*)&bug_broken_dts}, "Ignores DTS values in some streams that are broken" },
+#ifdef __MINGW32__
+	{ "priority", HAS_ARG, {(void*)opt_priority}, "set process priority (Win32)", "priority" },
+#endif
     { "programid", HAS_ARG | OPT_INT | OPT_EXPERT, {(void*)&opt_programid}, "desired program number", "" },
     { "xerror", OPT_BOOL, {(void*)&exit_on_error}, "exit on error", "error" },
     { "copyinkf", OPT_BOOL | OPT_EXPERT, {(void*)&copy_initial_nonkeyframes}, "copy initial non-keyframes" },
@@ -3837,9 +4283,6 @@
     { "psnr", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, {(void*)&do_psnr}, "calculate PSNR of compressed frames" },
     { "vstats", OPT_EXPERT | OPT_VIDEO, {(void*)&opt_vstats}, "dump video coding statistics to file" },
     { "vstats_file", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_vstats_file}, "dump video coding statistics to file", "file" },
-#if CONFIG_VHOOK
-    { "vhook", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)add_frame_hooker}, "insert video processing module", "module" },
-#endif
     { "intra_matrix", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_intra_matrix}, "specify intra matrix coeffs", "matrix" },
     { "inter_matrix", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_inter_matrix}, "specify inter matrix coeffs", "matrix" },
     { "top", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_top_field_first}, "top=1/bottom=0/auto=-1 field first", "" },
@@ -3868,6 +4311,7 @@
     { "scodec", HAS_ARG | OPT_SUBTITLE, {(void*)opt_subtitle_codec}, "force subtitle codec ('copy' to copy stream)", "codec" },
     { "newsubtitle", OPT_SUBTITLE, {(void*)opt_new_subtitle_stream}, "add a new subtitle stream to the current output stream" },
     { "slang", HAS_ARG | OPT_STRING | OPT_SUBTITLE, {(void *)&subtitle_language}, "set the ISO 639 language code (3 letters) of the current subtitle stream" , "code" },
+    { "stag", HAS_ARG | OPT_EXPERT | OPT_SUBTITLE, {(void*)opt_subtitle_tag}, "force subtitle tag/fourcc", "fourcc/tag" },
 
     /* grab options */
     { "vc", HAS_ARG | OPT_EXPERT | OPT_VIDEO | OPT_GRAB, {(void*)opt_video_channel}, "set video grab channel (DV1394 only)", "channel" },
@@ -3890,11 +4334,51 @@
     { NULL, },
 };
 
+static void exit_sighandler(int x){
+    static int sig_count=0;
+    ++sig_count;
+    if(sig_count==5)
+    {
+        /* We're crashing bad and can't uninit cleanly :( 
+         * by popular request, we make one last (dirty) 
+         * effort to restore the user's 
+         * terminal. */
+//      getch2_disable();
+        exit(1);
+    }
+    if(sig_count==6) exit(1);
+    if(sig_count>6){
+        // can't stop :(
+#ifndef __MINGW32__
+        kill(getpid(),SIGKILL);
+#endif
+    }
+    av_log(NULL, AV_LOG_ERROR, "FFMPEG has crashed with signal %d !!!\n", x);
+    exit(1);
+}
+
 int main(int argc, char **argv)
 {
     int i;
     int64_t ti;
 
+    //========= Catch terminate signals: ================
+    // terminate requests:
+    signal(SIGTERM,exit_sighandler); // kill
+    signal(SIGHUP,exit_sighandler);  // kill -HUP  /  xterm closed
+    
+    signal(SIGINT,exit_sighandler);  // Interrupt from keyboard
+    
+    signal(SIGQUIT,exit_sighandler); // Quit from keyboard
+    signal(SIGPIPE,exit_sighandler); // Some window managers cause this
+    
+    // fatal errors:
+    signal(SIGBUS,exit_sighandler);  // bus error
+    signal(SIGSEGV,exit_sighandler); // segfault
+    signal(SIGILL,exit_sighandler);  // illegal instruction
+    signal(SIGFPE,exit_sighandler);  // floating point exc.
+    signal(SIGABRT,exit_sighandler); // abort()
+ 
     avcodec_register_all();
     avdevice_register_all();
     av_register_all();
diff --git a/ffplay.c b/ffplay.c
old mode 100644
new mode 100755
index 9551561..5383861
--- a/ffplay.c
+++ b/ffplay.c
@@ -110,6 +110,7 @@
     int seek_req;
     int seek_flags;
     int64_t seek_pos;
+    int64_t seek_rel;
     AVFormatContext *ic;
     int dtg_active_format;
 
@@ -984,11 +985,11 @@
 }
 
 /* seek in the stream */
-static void stream_seek(VideoState *is, int64_t pos, int rel)
+static void stream_seek(VideoState *is, int64_t pos, int64_t rel)
 {
     if (!is->seek_req) {
         is->seek_pos = pos;
-        is->seek_flags = rel < 0 ? AVSEEK_FLAG_BACKWARD : 0;
+        is->seek_rel = rel;
         if (seek_by_bytes)
             is->seek_flags |= AVSEEK_FLAG_BYTE;
         is->seek_req = 1;
@@ -1226,7 +1227,6 @@
 {
     VideoPicture *vp;
     int dst_pix_fmt;
-    AVPicture pict;
     static struct SwsContext *img_convert_ctx;
 
     /* wait until we have space to put a new picture */
@@ -1269,10 +1269,13 @@
 
     /* if the frame is not skipped, then display it */
     if (vp->bmp) {
+        AVPicture pict;
+
         /* get a pointer on the bitmap */
         SDL_LockYUVOverlay (vp->bmp);
 
         dst_pix_fmt = PIX_FMT_YUV420P;
+        memset(&pict,0,sizeof(AVPicture));
         pict.data[0] = vp->bmp->pixels[0];
         pict.data[1] = vp->bmp->pixels[2];
         pict.data[2] = vp->bmp->pixels[1];
@@ -1962,7 +1965,7 @@
         /* add the stream start time */
         if (ic->start_time != AV_NOPTS_VALUE)
             timestamp += ic->start_time;
-        ret = av_seek_frame(ic, -1, timestamp, AVSEEK_FLAG_BACKWARD);
+        ret = avformat_seek_file(ic, -1, INT64_MIN, timestamp, INT64_MAX, 0);
         if (ret < 0) {
             fprintf(stderr, "%s: could not seek to position %0.3f\n",
                     is->filename, (double)timestamp / AV_TIME_BASE);
@@ -2035,18 +2038,13 @@
         }
 #endif
         if (is->seek_req) {
-            int stream_index= -1;
             int64_t seek_target= is->seek_pos;
+            int64_t seek_min= is->seek_rel > 0 ? seek_target - is->seek_rel + 2: INT64_MIN;
+            int64_t seek_max= is->seek_rel < 0 ? seek_target - is->seek_rel - 2: INT64_MAX;
+//FIXME the +-2 is due to rounding being not done in the correct direction in generation
+//      of the seek_pos/seek_rel variables
 
-            if     (is->   video_stream >= 0) stream_index= is->   video_stream;
-            else if(is->   audio_stream >= 0) stream_index= is->   audio_stream;
-            else if(is->subtitle_stream >= 0) stream_index= is->subtitle_stream;
-
-            if(stream_index>=0){
-                seek_target= av_rescale_q(seek_target, AV_TIME_BASE_Q, ic->streams[stream_index]->time_base);
-            }
-
-            ret = av_seek_frame(is->ic, stream_index, seek_target, is->seek_flags);
+            ret = avformat_seek_file(is->ic, -1, seek_min, seek_target, seek_max, is->seek_flags);
             if (ret < 0) {
                 fprintf(stderr, "%s: error while seeking\n", is->ic->filename);
             }else{
@@ -2346,7 +2344,7 @@
                     } else {
                         pos = get_master_clock(cur_stream);
                         pos += incr;
-                        stream_seek(cur_stream, (int64_t)(pos * AV_TIME_BASE), incr);
+                        stream_seek(cur_stream, (int64_t)(pos * AV_TIME_BASE), (int64_t)(incr * AV_TIME_BASE));
                     }
                 }
                 break;
diff --git a/ffpresets/libx264-baseline.ffpreset b/ffpresets/libx264-baseline.ffpreset
index a23b746..4766418 100644
--- a/ffpresets/libx264-baseline.ffpreset
+++ b/ffpresets/libx264-baseline.ffpreset
@@ -1,4 +1,3 @@
 coder=0
 bf=0
-flags2=-wpred-dct8x8+mbtree
-wpredp=0
+flags2=-wpred-dct8x8
diff --git a/ffpresets/libx264-default.ffpreset b/ffpresets/libx264-default.ffpreset
index a10c633..ec20174 100644
--- a/ffpresets/libx264-default.ffpreset
+++ b/ffpresets/libx264-default.ffpreset
@@ -3,7 +3,7 @@
 cmp=+chroma
 partitions=+parti8x8+parti4x4+partp8x8+partb8x8
 me_method=hex
-subq=7
+subq=6
 me_range=16
 g=250
 keyint_min=25
@@ -14,9 +14,5 @@
 qmin=10
 qmax=51
 qdiff=4
-bf=3
-refs=3
 directpred=1
-trellis=1
-flags2=+mixed_refs+wpred+dct8x8+fastpskip+mbtree
-wpredp=2
+flags2=+fastpskip
diff --git a/ffpresets/libx264-fastfirstpass.ffpreset b/ffpresets/libx264-fastfirstpass.ffpreset
index 7cf6faa..aaad461 100644
--- a/ffpresets/libx264-fastfirstpass.ffpreset
+++ b/ffpresets/libx264-fastfirstpass.ffpreset
@@ -3,7 +3,7 @@
 cmp=+chroma
 partitions=-parti8x8-parti4x4-partp8x8-partp4x4-partb8x8
 me_method=dia
-subq=2
+subq=1
 me_range=16
 g=250
 keyint_min=25
@@ -14,9 +14,8 @@
 qmin=10
 qmax=51
 qdiff=4
-bf=3
+bf=4
 refs=1
 directpred=3
 trellis=0
-flags2=-bpyramid-wpred-mixed_refs-dct8x8+fastpskip+mbtree
-wpredp=2
+flags2=-bpyramid-wpred-mixed_refs-dct8x8+fastpskip
diff --git a/ffpresets/libx264-hq.ffpreset b/ffpresets/libx264-hq.ffpreset
index eafc52e..cdf67eb 100644
--- a/ffpresets/libx264-hq.ffpreset
+++ b/ffpresets/libx264-hq.ffpreset
@@ -14,9 +14,8 @@
 qmin=10
 qmax=51
 qdiff=4
-bf=3
+bf=4
 refs=4
 directpred=3
 trellis=1
-flags2=+wpred+mixed_refs+dct8x8+fastpskip+mbtree
-wpredp=2
+flags2=+bpyramid+wpred+mixed_refs+dct8x8+fastpskip
diff --git a/ffpresets/libx264-ipod320.ffpreset b/ffpresets/libx264-ipod320.ffpreset
index b102050..89441c7 100644
--- a/ffpresets/libx264-ipod320.ffpreset
+++ b/ffpresets/libx264-ipod320.ffpreset
@@ -1,7 +1,6 @@
 coder=0
 bf=0
-flags2=-wpred-dct8x8+mbtree
+flags2=-wpred-dct8x8
 level=13
 maxrate=768000
 bufsize=3000000
-wpredp=0
diff --git a/ffpresets/libx264-ipod640.ffpreset b/ffpresets/libx264-ipod640.ffpreset
index aa731dc..fd58e2a 100644
--- a/ffpresets/libx264-ipod640.ffpreset
+++ b/ffpresets/libx264-ipod640.ffpreset
@@ -1,8 +1,7 @@
 coder=0
 bf=0
 refs=1
-flags2=-wpred-dct8x8+mbtree
+flags2=-wpred-dct8x8
 level=30
 maxrate=10000000
 bufsize=10000000
-wpredp=0
diff --git a/ffpresets/libx264-lossless_fast.ffpreset b/ffpresets/libx264-lossless_fast.ffpreset
index 9bbabf5..dcf418a 100644
--- a/ffpresets/libx264-lossless_fast.ffpreset
+++ b/ffpresets/libx264-lossless_fast.ffpreset
@@ -15,6 +15,5 @@
 qmax=51
 qdiff=4
 directpred=1
-flags2=+fastpskip+mbtree
+flags2=+fastpskip
 cqp=0
-wpredp=0
diff --git a/ffpresets/libx264-lossless_max.ffpreset b/ffpresets/libx264-lossless_max.ffpreset
index d4ba018..b8506c2 100644
--- a/ffpresets/libx264-lossless_max.ffpreset
+++ b/ffpresets/libx264-lossless_max.ffpreset
@@ -16,6 +16,5 @@
 qdiff=4
 refs=16
 directpred=1
-flags2=+mixed_refs+dct8x8+fastpskip+mbtree
+flags2=+mixed_refs+dct8x8+fastpskip
 cqp=0
-wpredp=2
diff --git a/ffpresets/libx264-lossless_medium.ffpreset b/ffpresets/libx264-lossless_medium.ffpreset
index c4133c2..99fb6b9 100644
--- a/ffpresets/libx264-lossless_medium.ffpreset
+++ b/ffpresets/libx264-lossless_medium.ffpreset
@@ -15,6 +15,5 @@
 qmax=51
 qdiff=4
 directpred=1
-flags2=+fastpskip+mbtree
+flags2=+fastpskip
 cqp=0
-wpredp=2
diff --git a/ffpresets/libx264-lossless_slow.ffpreset b/ffpresets/libx264-lossless_slow.ffpreset
index 1421b95..2ecb55b 100644
--- a/ffpresets/libx264-lossless_slow.ffpreset
+++ b/ffpresets/libx264-lossless_slow.ffpreset
@@ -16,6 +16,5 @@
 qdiff=4
 refs=2
 directpred=1
-flags2=+dct8x8+fastpskip+mbtree
+flags2=+dct8x8+fastpskip
 cqp=0
-wpredp=2
diff --git a/ffpresets/libx264-lossless_slower.ffpreset b/ffpresets/libx264-lossless_slower.ffpreset
index 9424459..dd499c7 100644
--- a/ffpresets/libx264-lossless_slower.ffpreset
+++ b/ffpresets/libx264-lossless_slower.ffpreset
@@ -16,6 +16,5 @@
 qdiff=4
 refs=4
 directpred=1
-flags2=+mixed_refs+dct8x8+fastpskip+mbtree
+flags2=+mixed_refs+dct8x8+fastpskip
 cqp=0
-wpredp=2
diff --git a/ffpresets/libx264-lossless_ultrafast.ffpreset b/ffpresets/libx264-lossless_ultrafast.ffpreset
index 3c44488..1c429f2 100644
--- a/ffpresets/libx264-lossless_ultrafast.ffpreset
+++ b/ffpresets/libx264-lossless_ultrafast.ffpreset
@@ -15,5 +15,5 @@
 qmax=51
 qdiff=4
 directpred=1
-flags2=+fastpskip+mbtree
+flags2=+fastpskip
 cqp=0
diff --git a/ffpresets/libx264-main.ffpreset b/ffpresets/libx264-main.ffpreset
index 0868c53..d1dc7dd 100644
--- a/ffpresets/libx264-main.ffpreset
+++ b/ffpresets/libx264-main.ffpreset
@@ -1 +1 @@
-flags2=-dct8x8+mbtree
+flags2=-dct8x8
diff --git a/ffpresets/libx264-max.ffpreset b/ffpresets/libx264-max.ffpreset
index 4289ab5..afdde53 100644
--- a/ffpresets/libx264-max.ffpreset
+++ b/ffpresets/libx264-max.ffpreset
@@ -3,8 +3,8 @@
 cmp=+chroma
 partitions=+parti8x8+parti4x4+partp8x8+partp4x4+partb8x8
 me_method=tesa
-subq=10
-me_range=24
+subq=9
+me_range=32
 g=250
 keyint_min=25
 sc_threshold=40
@@ -14,9 +14,8 @@
 qmin=10
 qmax=51
 qdiff=4
-bf=3
+bf=4
 refs=16
 directpred=3
 trellis=2
-flags2=+wpred+mixed_refs+dct8x8-fastpskip+mbtree
-wpredp=2
+flags2=+bpyramid+wpred+mixed_refs+dct8x8-fastpskip
diff --git a/ffpresets/libx264-normal.ffpreset b/ffpresets/libx264-normal.ffpreset
index dd7991b..99ac2e3 100644
--- a/ffpresets/libx264-normal.ffpreset
+++ b/ffpresets/libx264-normal.ffpreset
@@ -14,9 +14,8 @@
 qmin=10
 qmax=51
 qdiff=4
-bf=3
+bf=4
 refs=2
 directpred=3
 trellis=0
-flags2=+wpred+dct8x8+fastpskip+mbtree
-wpredp=2
+flags2=+bpyramid+wpred+dct8x8+fastpskip
diff --git a/ffpresets/libx264-slowfirstpass.ffpreset b/ffpresets/libx264-slowfirstpass.ffpreset
index ba49065..7358d44 100644
--- a/ffpresets/libx264-slowfirstpass.ffpreset
+++ b/ffpresets/libx264-slowfirstpass.ffpreset
@@ -14,9 +14,8 @@
 qmin=10
 qmax=51
 qdiff=4
-bf=3
+bf=4
 refs=1
 directpred=3
 trellis=0
-flags2=+wpred+dct8x8+fastpskip+mbtree
-wpredp=2
+flags2=+bpyramid+wpred+dct8x8+fastpskip
diff --git a/ffserver.c b/ffserver.c
index bfdd188..61ecf20 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -35,7 +35,8 @@
 #include "libavformat/rtpdec.h"
 #include "libavformat/rtsp.h"
 #include "libavutil/avstring.h"
-#include "libavutil/random.h"
+#include "libavutil/lfg.h"
+#include "libavutil/random_seed.h"
 #include "libavutil/intreadwrite.h"
 #include "libavcodec/opt.h"
 #include <stdarg.h>
@@ -236,6 +237,7 @@
     int feed_opened;     /* true if someone is writing to the feed */
     int is_feed;         /* true if it is a feed */
     int readonly;        /* True if writing is prohibited to the file */
+    int truncate;        /* True if feeder connection truncate the feed file */
     int conns_served;
     int64_t bytes_served;
     int64_t feed_max_size;      /* maximum storage size, zero means unlimited */
@@ -309,7 +311,7 @@
 
 static int64_t cur_time;           // Making this global saves on passing it around everywhere
 
-static AVRandomState random_state;
+static AVLFG random_state;
 
 static FILE *logfile = NULL;
 
@@ -354,7 +356,7 @@
 {
     static int print_prefix = 1;
     AVClass *avc = ptr ? *(AVClass**)ptr : NULL;
-    if (level > av_log_level)
+    if (level > av_log_get_level())
         return;
     if (print_prefix && avc)
         http_log("[%s @ %p]", avc->item_name(ptr), ptr);
@@ -503,7 +505,7 @@
         if (stream->is_multicast) {
             /* open the RTP connection */
             snprintf(session_id, sizeof(session_id), "%08x%08x",
-                     av_random(&random_state), av_random(&random_state));
+                     av_lfg_get(&random_state), av_lfg_get(&random_state));
 
             /* choose a port if none given */
             if (stream->multicast_port == 0) {
@@ -699,6 +701,22 @@
     }
 }
 
+static void http_send_too_busy_reply(int fd)
+{
+    char buffer[300];
+    int len = snprintf(buffer, sizeof(buffer),
+                       "HTTP/1.0 200 Server too busy\r\n"
+                       "Content-type: text/html\r\n"
+                       "\r\n"
+                       "<html><head><title>Too busy</title></head><body>\r\n"
+                       "<p>The server is too busy to serve your request at this time.</p>\r\n"
+                       "<p>The number of current connections is %d, and this exceeds the limit of %d.</p>\r\n"
+                       "</body></html>\r\n",
+                       nb_connections, nb_max_connections);
+    send(fd, buffer, len, 0);
+}
+
+
 static void new_connection(int server_fd, int is_rtsp)
 {
     struct sockaddr_in from_addr;
@@ -714,10 +732,10 @@
     }
     ff_socket_nonblock(fd, 1);
 
-    /* XXX: should output a warning page when coming
-       close to the connection limit */
-    if (nb_connections >= nb_max_connections)
+    if (nb_connections >= nb_max_connections) {
+        http_send_too_busy_reply(fd);
         goto fail;
+    }
 
     /* add a new connection */
     c = av_mallocz(sizeof(HTTPContext));
@@ -1263,7 +1281,7 @@
     av_strlcpy(c->protocol, protocol, sizeof(c->protocol));
 
     if (ffserver_debug)
-        http_log("New connection: %s %s\n", cmd, url);
+        http_log("%s - - New connection: %s %s\n", inet_ntoa(c->from_addr.sin_addr), cmd, url);
 
     /* find the filename and the optional info string in the request */
     p = strchr(url, '?');
@@ -1320,6 +1338,7 @@
     }
     if (stream == NULL) {
         snprintf(msg, sizeof(msg), "File '%s' not found", url);
+        http_log("File '%s' not found\n", url);
         goto send_error;
     }
 
@@ -1361,7 +1380,7 @@
     /* If already streaming this feed, do not let start another feeder. */
     if (stream->feed_opened) {
         snprintf(msg, sizeof(msg), "This feed is already being received.");
-        http_log("feed %s already being received\n", stream->feed_filename);
+        http_log("Feed '%s' already being received\n", stream->feed_filename);
         goto send_error;
     }
 
@@ -1599,7 +1618,7 @@
     if (!strcmp(c->stream->fmt->name,"asf_stream")) {
         /* Need to allocate a client id */
 
-        c->wmp_client_id = av_random(&random_state) & 0x7fffffff;
+        c->wmp_client_id = av_lfg_get(&random_state);
 
         q += snprintf(q, q - (char *) c->buffer + c->buffer_size, "Server: Cougar 4.1.0.3923\r\nCache-Control: no-cache\r\nPragma: client-id=%d\r\nPragma: features=\"broadcast\"\r\n", c->wmp_client_id);
     }
@@ -1984,7 +2003,11 @@
     }
     s->flags |= AVFMT_FLAG_GENPTS;
     c->fmt_in = s;
-    av_find_stream_info(c->fmt_in);
+    if (strcmp(s->iformat->name, "ffm") && av_find_stream_info(c->fmt_in) < 0) {
+        http_log("Could not find stream info '%s'\n", input_filename);
+        av_close_input_file(s);
+        return -1;
+    }
 
     /* open each parser */
     for(i=0;i<s->nb_streams;i++)
@@ -2409,10 +2432,19 @@
     }
     c->feed_fd = fd;
 
-    if ((c->stream->feed_write_index = ffm_read_write_index(fd)) < 0) {
-        http_log("Error reading write index from feed file: %s\n", strerror(errno));
-        return -1;
+    if (c->stream->truncate) {
+        /* truncate feed file */
+        ffm_write_write_index(c->feed_fd, FFM_PACKET_SIZE);
+        ftruncate(c->feed_fd, FFM_PACKET_SIZE);
+        http_log("Truncating feed file '%s'\n", c->stream->feed_filename);
+    } else {
+        if ((c->stream->feed_write_index = ffm_read_write_index(fd)) < 0) {
+            http_log("Error reading write index from feed file: %s\n", strerror(errno));
+            return -1;
+        }
     }
+
+    c->stream->feed_write_index = FFMAX(ffm_read_write_index(fd), FFM_PACKET_SIZE);
     c->stream->feed_size = lseek(fd, 0, SEEK_END);
     lseek(fd, 0, SEEK_SET);
 
@@ -2513,6 +2545,8 @@
             if (s->nb_streams != feed->nb_streams) {
                 av_close_input_stream(s);
                 av_free(pb);
+                http_log("Feed '%s' stream number does not match registered feed\n",
+                         c->stream->feed_filename);
                 goto fail;
             }
 
@@ -2867,7 +2901,7 @@
     /* generate session id if needed */
     if (h->session_id[0] == '\0')
         snprintf(h->session_id, sizeof(h->session_id), "%08x%08x",
-                 av_random(&random_state), av_random(&random_state));
+                 av_lfg_get(&random_state), av_lfg_get(&random_state));
 
     /* find rtp session, and create it if none found */
     rtp_c = find_rtp_session(h->session_id);
@@ -3380,9 +3414,10 @@
                 stream->ap_in->mpeg2ts_compute_pcr = 1;
             }
 
+            http_log("Opening file '%s'\n", stream->feed_filename);
             if ((ret = av_open_input_file(&infile, stream->feed_filename,
                                           stream->ifmt, 0, stream->ap_in)) < 0) {
-                http_log("could not open %s: %d\n", stream->feed_filename, ret);
+                http_log("Could not open '%s': %d\n", stream->feed_filename, ret);
                 /* remove stream (no need to spend more time on it) */
             fail:
                 remove_stream(stream);
@@ -3551,7 +3586,7 @@
             exit(1);
         }
 
-        feed->feed_write_index = ffm_read_write_index(fd);
+        feed->feed_write_index = FFMAX(ffm_read_write_index(fd), FFM_PACKET_SIZE);
         feed->feed_size = lseek(fd, 0, SEEK_END);
         /* ensure that we do not wrap before the end of file */
         if (feed->feed_max_size && feed->feed_max_size < feed->feed_size)
@@ -3757,7 +3792,7 @@
     const char *p;
     int val, errors, line_num;
     FFStream **last_stream, *stream, *redirect;
-    FFStream **last_feed, *feed;
+    FFStream **last_feed, *feed, *s;
     AVCodecContext audio_enc, video_enc;
     enum CodecID audio_id, video_id;
 
@@ -3865,17 +3900,19 @@
                         filename, line_num);
             } else {
                 feed = av_mallocz(sizeof(FFStream));
-                /* add in stream list */
-                *last_stream = feed;
-                last_stream = &feed->next;
-                /* add in feed list */
-                *last_feed = feed;
-                last_feed = &feed->next_feed;
-
                 get_arg(feed->filename, sizeof(feed->filename), &p);
                 q = strrchr(feed->filename, '>');
                 if (*q)
                     *q = '\0';
+
+                for (s = first_feed; s; s = s->next) {
+                    if (!strcmp(feed->filename, s->filename)) {
+                        fprintf(stderr, "%s:%d: Feed '%s' already registered\n",
+                                filename, line_num, s->filename);
+                        errors++;
+                    }
+                }
+
                 feed->fmt = guess_format("ffm", NULL, NULL);
                 /* defaut feed file */
                 snprintf(feed->feed_filename, sizeof(feed->feed_filename),
@@ -3883,6 +3920,13 @@
                 feed->feed_max_size = 5 * 1024 * 1024;
                 feed->is_feed = 1;
                 feed->feed = feed; /* self feeding :-) */
+
+                /* add in stream list */
+                *last_stream = feed;
+                last_stream = &feed->next;
+                /* add in feed list */
+                *last_feed = feed;
+                last_feed = &feed->next_feed;
             }
         } else if (!strcasecmp(cmd, "Launch")) {
             if (feed) {
@@ -3918,6 +3962,11 @@
                 get_arg(feed->feed_filename, sizeof(feed->feed_filename), &p);
             } else if (stream)
                 get_arg(stream->feed_filename, sizeof(stream->feed_filename), &p);
+        } else if (!strcasecmp(cmd, "Truncate")) {
+            if (feed) {
+                get_arg(arg, sizeof(arg), &p);
+                feed->truncate = strtod(arg, NULL);
+            }
         } else if (!strcasecmp(cmd, "FileMaxSize")) {
             if (feed) {
                 char *p1;
@@ -3938,6 +3987,11 @@
                     break;
                 }
                 feed->feed_max_size = (int64_t)fsize;
+                if (feed->feed_max_size < FFM_PACKET_SIZE*4) {
+                    fprintf(stderr, "%s:%d: Feed max file size is too small, "
+                            "must be at least %d\n", filename, line_num, FFM_PACKET_SIZE*4);
+                    errors++;
+                }
             }
         } else if (!strcasecmp(cmd, "</Feed>")) {
             if (!feed) {
@@ -3954,15 +4008,22 @@
                 fprintf(stderr, "%s:%d: Already in a tag\n",
                         filename, line_num);
             } else {
+                FFStream *s;
                 const AVClass *class;
                 stream = av_mallocz(sizeof(FFStream));
-                *last_stream = stream;
-                last_stream = &stream->next;
-
                 get_arg(stream->filename, sizeof(stream->filename), &p);
                 q = strrchr(stream->filename, '>');
                 if (*q)
                     *q = '\0';
+
+                for (s = first_stream; s; s = s->next) {
+                    if (!strcmp(stream->filename, s->filename)) {
+                        fprintf(stderr, "%s:%d: Stream '%s' already registered\n",
+                                filename, line_num, s->filename);
+                        errors++;
+                    }
+                }
+
                 stream->fmt = guess_stream_format(NULL, stream->filename, NULL);
                 /* fetch avclass so AVOption works
                  * FIXME try to use avcodec_get_context_defaults2
@@ -3979,6 +4040,9 @@
                     audio_id = stream->fmt->audio_codec;
                     video_id = stream->fmt->video_codec;
                 }
+
+                *last_stream = stream;
+                last_stream = &stream->next;
             }
         } else if (!strcasecmp(cmd, "Feed")) {
             get_arg(arg, sizeof(arg), &p);
@@ -4488,7 +4552,7 @@
 
     unsetenv("http_proxy");             /* Kill the http_proxy */
 
-    av_random_init(&random_state, av_gettime() + (getpid() << 16));
+    av_lfg_init(&random_state, ff_random_get_seed());
 
     memset(&sigact, 0, sizeof(sigact));
     sigact.sa_handler = handle_child_exit;
diff --git a/ffserver.h b/ffserver.h
old mode 100644
new mode 100755
diff --git a/libavcodec/4xm.c b/libavcodec/4xm.c
old mode 100644
new mode 100755
diff --git a/libavcodec/8bps.c b/libavcodec/8bps.c
old mode 100644
new mode 100755
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index cf742d1..6a8e8d2 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -29,13 +29,13 @@
 OBJS-$(CONFIG_FFT)                     += fft.o
 OBJS-$(CONFIG_GOLOMB)                  += golomb.o
 OBJS-$(CONFIG_MDCT)                    += mdct.o
-OBJS-$(CONFIG_OLDSCALER)               += imgresample.o
 OBJS-$(CONFIG_RDFT)                    += rdft.o
 
 # decoders/encoders
 OBJS-$(CONFIG_AAC_DECODER)             += aac.o aactab.o mpeg4audio.o aac_parser.o aac_ac3_parser.o
 OBJS-$(CONFIG_AASC_DECODER)            += aasc.o msrledec.o
 OBJS-$(CONFIG_AC3_DECODER)             += eac3dec.o ac3dec.o ac3tab.o ac3dec_data.o ac3.o
+OBJS-$(CONFIG_AC3DUMMY_DECODER)        += ac3decdummy.o
 OBJS-$(CONFIG_AC3_ENCODER)             += ac3enc.o ac3tab.o ac3.o
 OBJS-$(CONFIG_ALAC_DECODER)            += alac.o
 OBJS-$(CONFIG_ALAC_ENCODER)            += alacenc.o lpc.o
@@ -84,8 +84,8 @@
 OBJS-$(CONFIG_FFV1_ENCODER)            += ffv1.o rangecoder.o
 OBJS-$(CONFIG_FFVHUFF_DECODER)         += huffyuv.o
 OBJS-$(CONFIG_FFVHUFF_ENCODER)         += huffyuv.o
-OBJS-$(CONFIG_FLAC_DECODER)            += flacdec.o
-OBJS-$(CONFIG_FLAC_ENCODER)            += flacenc.o lpc.o
+OBJS-$(CONFIG_FLAC_DECODER)            += flacdec.o flacdata.o flac.o
+OBJS-$(CONFIG_FLAC_ENCODER)            += flacenc.o flacdata.o flac.o lpc.o
 OBJS-$(CONFIG_FLASHSV_DECODER)         += flashsv.o
 OBJS-$(CONFIG_FLASHSV_ENCODER)         += flashsvenc.o
 OBJS-$(CONFIG_FLIC_DECODER)            += flicvideo.o
@@ -141,6 +141,7 @@
 OBJS-$(CONFIG_MPEGVIDEO_DECODER)       += mpeg12.o mpeg12data.o mpegvideo.o error_resilience.o
 OBJS-$(CONFIG_MPEG1VIDEO_DECODER)      += mpeg12.o mpeg12data.o mpegvideo.o error_resilience.o
 OBJS-$(CONFIG_MPEG1VIDEO_ENCODER)      += mpeg12enc.o mpeg12data.o mpegvideo_enc.o motion_est.o ratecontrol.o mpeg12.o mpeg12data.o mpegvideo.o error_resilience.o
+OBJS-$(CONFIG_MPEG2_VAAPI_HWACCEL)     += mpeg12.o mpeg12data.o mpegvideo.o error_resilience.o vaapi.o vaapi_mpeg2.o
 OBJS-$(CONFIG_MPEG2VIDEO_DECODER)      += mpeg12.o mpeg12data.o mpegvideo.o error_resilience.o
 OBJS-$(CONFIG_MPEG2VIDEO_ENCODER)      += mpeg12enc.o mpeg12data.o mpegvideo_enc.o motion_est.o ratecontrol.o mpeg12.o mpeg12data.o mpegvideo.o error_resilience.o
 OBJS-$(CONFIG_MPEG4_DECODER)           += h263dec.o h263.o mpeg4video_parser.o mpeg12data.o mpegvideo.o error_resilience.o
@@ -157,16 +158,23 @@
 OBJS-$(CONFIG_NELLYMOSER_DECODER)      += nellymoserdec.o nellymoser.o
 OBJS-$(CONFIG_NELLYMOSER_ENCODER)      += nellymoserenc.o nellymoser.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_PAM_DECODER)             += pnmenc.o pnm.o
+OBJS-$(CONFIG_PAM_ENCODER)             += pnmenc.o
+OBJS-$(CONFIG_PBM_DECODER)             += pnmenc.o pnm.o
+OBJS-$(CONFIG_PBM_ENCODER)             += pnmenc.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_PCX_ENCODER)             += pcxenc.o
+OBJS-$(CONFIG_PGM_DECODER)             += pnmenc.o pnm.o
+OBJS-$(CONFIG_PGM_ENCODER)             += pnmenc.o
+OBJS-$(CONFIG_PGSSUB_DECODER)          += pgssubdec.o
+OBJS-$(CONFIG_PGMYUV_DECODER)          += pnmenc.o pnm.o
+OBJS-$(CONFIG_PGMYUV_ENCODER)          += pnmenc.o
 OBJS-$(CONFIG_PNG_DECODER)             += png.o pngdec.o
 OBJS-$(CONFIG_PNG_ENCODER)             += png.o pngenc.o
-OBJS-$(CONFIG_PPM_ENCODER)             += pnmenc.o pnm.o
+OBJS-$(CONFIG_PPM_DECODER)             += pnmenc.o pnm.o
+OBJS-$(CONFIG_PPM_ENCODER)             += pnmenc.o
 OBJS-$(CONFIG_PTX_DECODER)             += ptx.o
-OBJS-$(CONFIG_QCELP_DECODER)           += qcelpdec.o qcelp_lsp.o celp_math.o celp_filters.o
+OBJS-$(CONFIG_QCELP_DECODER)           += qcelpdec.o qcelp_lsp.o celp_math.o celp_filters.o acelp_vectors.o
 OBJS-$(CONFIG_QDM2_DECODER)            += qdm2.o mpegaudiodec.o mpegaudiodecheader.o mpegaudio.o mpegaudiodata.o
 OBJS-$(CONFIG_QDRAW_DECODER)           += qdrw.o
 OBJS-$(CONFIG_QPEG_DECODER)            += qpeg.o
@@ -212,6 +220,7 @@
 OBJS-$(CONFIG_TIERTEXSEQVIDEO_DECODER) += tiertexseqv.o
 OBJS-$(CONFIG_TIFF_DECODER)            += tiff.o lzw.o faxcompr.o
 OBJS-$(CONFIG_TIFF_ENCODER)            += tiffenc.o rle.o lzwenc.o
+OBJS-$(CONFIG_TRUEHD_DECODER)          += mlpdec.o mlp_parser.o mlp.o
 OBJS-$(CONFIG_TRUEMOTION1_DECODER)     += truemotion1.o
 OBJS-$(CONFIG_TRUEMOTION2_DECODER)     += truemotion2.o
 OBJS-$(CONFIG_TRUESPEECH_DECODER)      += truespeech.o
@@ -229,6 +238,7 @@
 OBJS-$(CONFIG_VMNC_DECODER)            += vmnc.o
 OBJS-$(CONFIG_VORBIS_DECODER)          += vorbis_dec.o vorbis.o vorbis_data.o xiph.o
 OBJS-$(CONFIG_VORBIS_ENCODER)          += vorbis_enc.o vorbis.o vorbis_data.o
+OBJS-$(CONFIG_OGGIVORBIS_DECODER)      += oggivorbis.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 vp6dsp.o huffman.o
@@ -306,6 +316,7 @@
 OBJS-$(CONFIG_PCM_U32LE_ENCODER)          += pcm.o
 OBJS-$(CONFIG_PCM_ZORK_DECODER)           += pcm.o
 OBJS-$(CONFIG_PCM_ZORK_ENCODER)           += pcm.o
+OBJS-$(CONFIG_PCM_BD_DECODER)             += pcm.o
 
 OBJS-$(CONFIG_ADPCM_4XM_DECODER)          += adpcm.o
 OBJS-$(CONFIG_ADPCM_ADX_DECODER)          += adxdec.o
@@ -345,16 +356,17 @@
 
 # libavformat dependencies
 OBJS-$(CONFIG_EAC3_DEMUXER)            += ac3_parser.o ac3tab.o aac_ac3_parser.o
-OBJS-$(CONFIG_FLAC_MUXER)              += flacdec.o
+OBJS-$(CONFIG_FLAC_DEMUXER)            += flacdec.o flacdata.o flac.o
+OBJS-$(CONFIG_FLAC_MUXER)              += flacdec.o flacdata.o flac.o
 OBJS-$(CONFIG_GXF_DEMUXER)             += mpeg12data.o
-OBJS-$(CONFIG_MATROSKA_AUDIO_MUXER)    += xiph.o mpeg4audio.o flacdec.o
+OBJS-$(CONFIG_MATROSKA_AUDIO_MUXER)    += xiph.o mpeg4audio.o flacdec.o flacdata.o flac.o
 OBJS-$(CONFIG_MATROSKA_DEMUXER)        += mpeg4audio.o
-OBJS-$(CONFIG_MATROSKA_MUXER)          += xiph.o mpeg4audio.o flacdec.o
+OBJS-$(CONFIG_MATROSKA_MUXER)          += xiph.o mpeg4audio.o flacdec.o flacdata.o flac.o
 OBJS-$(CONFIG_MOV_DEMUXER)             += mpeg4audio.o mpegaudiodata.o
 OBJS-$(CONFIG_MPEGTS_MUXER)            += mpegvideo.o
 OBJS-$(CONFIG_NUT_MUXER)               += mpegaudiodata.o
-OBJS-$(CONFIG_OGG_DEMUXER)             += flacdec.o
-OBJS-$(CONFIG_OGG_MUXER)               += xiph.o flacdec.o
+OBJS-$(CONFIG_OGG_DEMUXER)             += flacdec.o flacdata.o flac.o
+OBJS-$(CONFIG_OGG_MUXER)               += xiph.o flacdec.o flacdata.o flac.o
 OBJS-$(CONFIG_RTP_MUXER)               += mpegvideo.o
 
 # external codec libraries
@@ -363,11 +375,9 @@
 OBJS-$(CONFIG_LIBDIRAC_DECODER)        += libdiracdec.o
 OBJS-$(CONFIG_LIBDIRAC_ENCODER)        += libdiracenc.o libdirac_libschro.o
 OBJS-$(CONFIG_LIBFAAC)                 += libfaac.o
-OBJS-$(CONFIG_LIBFAAD)                 += libfaad.o
+OBJS-$(CONFIG_LIBFAAD)                 += libfaad.o latmaac.o
 OBJS-$(CONFIG_LIBGSM)                  += libgsm.o
 OBJS-$(CONFIG_LIBMP3LAME)              += libmp3lame.o
-OBJS-$(CONFIG_LIBOPENCORE_AMRNB)       += libopencore-amr.o
-OBJS-$(CONFIG_LIBOPENCORE_AMRWB)       += libopencore-amr.o
 OBJS-$(CONFIG_LIBOPENJPEG)             += libopenjpeg.o
 OBJS-$(CONFIG_LIBSCHROEDINGER_DECODER) += libschroedingerdec.o libschroedinger.o libdirac_libschro.o
 OBJS-$(CONFIG_LIBSCHROEDINGER_ENCODER) += libschroedingerenc.o libschroedinger.o libdirac_libschro.o
@@ -378,7 +388,7 @@
 OBJS-$(CONFIG_LIBXVID)                 += libxvidff.o libxvid_rc.o
 
 # parsers
-OBJS-$(CONFIG_AAC_PARSER)              += aac_parser.o aac_ac3_parser.o mpeg4audio.o
+OBJS-$(CONFIG_AAC_PARSER)              += aac_parser.o aac_ac3_parser.o mpeg4audio.o latm_parser.o
 OBJS-$(CONFIG_AC3_PARSER)              += ac3_parser.o ac3tab.o aac_ac3_parser.o
 OBJS-$(CONFIG_CAVSVIDEO_PARSER)        += cavs_parser.o
 OBJS-$(CONFIG_DCA_PARSER)              += dca_parser.o
@@ -496,7 +506,6 @@
 OBJS-$(ARCH_PPC)                       += ppc/dsputil_ppc.o             \
 
 ALTIVEC-OBJS-$(CONFIG_H264_DECODER)    += ppc/h264_altivec.o
-ALTIVEC-OBJS-$(CONFIG_OLDSCALER)       += ppc/imgresample_altivec.o
 ALTIVEC-OBJS-$(CONFIG_SNOW_DECODER)    += ppc/snow_altivec.o
 ALTIVEC-OBJS-$(CONFIG_VC1_DECODER)     += ppc/vc1dsp_altivec.o
 ALTIVEC-OBJS-$(CONFIG_WMV3_DECODER)    += ppc/vc1dsp_altivec.o
@@ -526,13 +535,14 @@
                                           sparc/simple_idct_vis.o       \
 
 
-TESTS = $(addsuffix -test$(EXESUF), cabac dct eval fft h264 rangecoder snow)
-TESTS-$(CONFIG_OLDSCALER) += imgresample-test$(EXESUF)
-TESTS-$(ARCH_X86) += x86/cpuid-test$(EXESUF) motion-test$(EXESUF)
+EXAMPLES = apiexample$(EXESUF)
 
-CLEANFILES = apiexample$(EXESUF)
+TESTPROGS = cabac dct eval fft h264 rangecoder snow
+TESTPROGS-$(ARCH_X86) += x86/cpuid
+TESTPROGS-$(HAVE_MMX) += motion
+
 DIRS = alpha arm bfin mlib ppc ps2 sh4 sparc x86
 
 include $(SUBDIR)../subdir.mak
 
-$(SUBDIR)dct-test$(EXESUF): $(SUBDIR)dctref.o $(SUBDIR)aandcttab.o
+$(SUBDIR)dct-test$(EXESUF): $(SUBDIR)fdctref.o $(SUBDIR)aandcttab.o
diff --git a/libavcodec/aac.h b/libavcodec/aac.h
index 32e7224..fb84c59 100644
--- a/libavcodec/aac.h
+++ b/libavcodec/aac.h
@@ -48,36 +48,6 @@
 
 #define TNS_MAX_ORDER 20
 
-enum AudioObjectType {
-    AOT_NULL,
-                               // Support?                Name
-    AOT_AAC_MAIN,              ///< Y                       Main
-    AOT_AAC_LC,                ///< Y                       Low Complexity
-    AOT_AAC_SSR,               ///< N (code in SoC repo)    Scalable Sample Rate
-    AOT_AAC_LTP,               ///< N (code in SoC repo)    Long Term Prediction
-    AOT_SBR,                   ///< N (in progress)         Spectral Band Replication
-    AOT_AAC_SCALABLE,          ///< N                       Scalable
-    AOT_TWINVQ,                ///< N                       Twin Vector Quantizer
-    AOT_CELP,                  ///< N                       Code Excited Linear Prediction
-    AOT_HVXC,                  ///< N                       Harmonic Vector eXcitation Coding
-    AOT_TTSI             = 12, ///< N                       Text-To-Speech Interface
-    AOT_MAINSYNTH,             ///< N                       Main Synthesis
-    AOT_WAVESYNTH,             ///< N                       Wavetable Synthesis
-    AOT_MIDI,                  ///< N                       General MIDI
-    AOT_SAFX,                  ///< N                       Algorithmic Synthesis and Audio Effects
-    AOT_ER_AAC_LC,             ///< N                       Error Resilient Low Complexity
-    AOT_ER_AAC_LTP       = 19, ///< N                       Error Resilient Long Term Prediction
-    AOT_ER_AAC_SCALABLE,       ///< N                       Error Resilient Scalable
-    AOT_ER_TWINVQ,             ///< N                       Error Resilient Twin Vector Quantizer
-    AOT_ER_BSAC,               ///< N                       Error Resilient Bit-Sliced Arithmetic Coding
-    AOT_ER_AAC_LD,             ///< N                       Error Resilient Low Delay
-    AOT_ER_CELP,               ///< N                       Error Resilient Code Excited Linear Prediction
-    AOT_ER_HVXC,               ///< N                       Error Resilient Harmonic Vector eXcitation Coding
-    AOT_ER_HILN,               ///< N                       Error Resilient Harmonic and Individual Lines plus Noise
-    AOT_ER_PARAM,              ///< N                       Error Resilient Parametric
-    AOT_SSC,                   ///< N                       SinuSoidal Coding
-};
-
 enum RawDataBlockType {
     TYPE_SCE,
     TYPE_CPE,
diff --git a/libavcodec/aac_ac3_parser.c b/libavcodec/aac_ac3_parser.c
old mode 100644
new mode 100755
diff --git a/libavcodec/aac_ac3_parser.h b/libavcodec/aac_ac3_parser.h
old mode 100644
new mode 100755
diff --git a/libavcodec/aac_parser.c b/libavcodec/aac_parser.c
old mode 100644
new mode 100755
diff --git a/libavcodec/aacpsy.c b/libavcodec/aacpsy.c
old mode 100644
new mode 100755
diff --git a/libavcodec/aasc.c b/libavcodec/aasc.c
old mode 100644
new mode 100755
diff --git a/libavcodec/ac3.c b/libavcodec/ac3.c
old mode 100644
new mode 100755
diff --git a/libavcodec/ac3.h b/libavcodec/ac3.h
old mode 100644
new mode 100755
diff --git a/libavcodec/ac3_parser.c b/libavcodec/ac3_parser.c
old mode 100644
new mode 100755
diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index 7a2042c..03f8f8c 100644
--- a/libavcodec/ac3dec.c
+++ b/libavcodec/ac3dec.c
@@ -511,7 +511,7 @@
                 /* Shift mantissa and sign-extend it. */
                 mantissa = (mantissa << (32-quantization_tab[bap]))>>8;
                 break;
-        }
+            }
         coeffs[freq] = mantissa >> exps[freq];
     }
 }
diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c
old mode 100644
new mode 100755
diff --git a/libavcodec/ac3tab.c b/libavcodec/ac3tab.c
old mode 100644
new mode 100755
diff --git a/libavcodec/ac3tab.h b/libavcodec/ac3tab.h
old mode 100644
new mode 100755
diff --git a/libavcodec/acelp_filters.c b/libavcodec/acelp_filters.c
old mode 100644
new mode 100755
diff --git a/libavcodec/acelp_filters.h b/libavcodec/acelp_filters.h
old mode 100644
new mode 100755
diff --git a/libavcodec/acelp_pitch_delay.c b/libavcodec/acelp_pitch_delay.c
old mode 100644
new mode 100755
diff --git a/libavcodec/acelp_pitch_delay.h b/libavcodec/acelp_pitch_delay.h
old mode 100644
new mode 100755
diff --git a/libavcodec/acelp_vectors.c b/libavcodec/acelp_vectors.c
old mode 100644
new mode 100755
index cae6318..5443006
--- a/libavcodec/acelp_vectors.c
+++ b/libavcodec/acelp_vectors.c
@@ -145,3 +145,13 @@
                  in_b[i] * weight_coeff_b +
                  rounder) >> shift);
 }
+
+void ff_weighted_vector_sumf(float *out, const float *in_a, const float *in_b,
+                             float weight_coeff_a, float weight_coeff_b, int length)
+{
+    int i;
+
+    for(i=0; i<length; i++)
+        out[i] = weight_coeff_a * in_a[i]
+               + weight_coeff_b * in_b[i];
+}
diff --git a/libavcodec/acelp_vectors.h b/libavcodec/acelp_vectors.h
old mode 100644
new mode 100755
index a5e71fc..3a47a7b
--- a/libavcodec/acelp_vectors.h
+++ b/libavcodec/acelp_vectors.h
@@ -150,4 +150,18 @@
         int shift,
         int length);
 
+/**
+ * float implementation of weighted sum of two vectors.
+ * @param out [out] result of addition
+ * @param in_a first vector
+ * @param in_b second vector
+ * @param weight_coeff_a first vector weight coefficient
+ * @param weight_coeff_a second vector weight coefficient
+ * @param length vectors length
+ *
+ * @note It is safe to pass the same buffer for out and in_a or in_b.
+ */
+void ff_weighted_vector_sumf(float *out, const float *in_a, const float *in_b,
+                             float weight_coeff_a, float weight_coeff_b, int length);
+
 #endif /* AVCODEC_ACELP_VECTORS_H */
diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c
old mode 100644
new mode 100755
diff --git a/libavcodec/adx.h b/libavcodec/adx.h
old mode 100644
new mode 100755
diff --git a/libavcodec/adxdec.c b/libavcodec/adxdec.c
old mode 100644
new mode 100755
diff --git a/libavcodec/adxenc.c b/libavcodec/adxenc.c
old mode 100644
new mode 100755
diff --git a/libavcodec/alac.c b/libavcodec/alac.c
old mode 100644
new mode 100755
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 4a6cbc0..739b69e 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -26,6 +26,10 @@
 
 #include "avcodec.h"
 
+#define REGISTER_HWACCEL(X,x) { \
+          extern AVHWAccel x##_hwaccel; \
+          if(CONFIG_##X##_HWACCEL) av_register_hwaccel(&x##_hwaccel); }
+
 #define REGISTER_ENCODER(X,x) { \
           extern AVCodec x##_encoder; \
           if(CONFIG_##X##_ENCODER)  avcodec_register(&x##_encoder); }
@@ -49,6 +53,8 @@
         return;
     initialized = 1;
 
+    /* hardware accelerators */
+
     /* video codecs */
     REGISTER_DECODER (AASC, aasc);
     REGISTER_DECODER (AMV, amv);
@@ -119,13 +125,13 @@
     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  (PAM, pam);
+    REGISTER_ENCDEC  (PBM, pbm);
+    REGISTER_ENCDEC  (PCX, pcx);
+    REGISTER_ENCDEC  (PGM, pgm);
+    REGISTER_ENCDEC  (PGMYUV, pgmyuv);
     REGISTER_ENCDEC  (PNG, png);
-    REGISTER_ENCODER (PPM, ppm);
+    REGISTER_ENCDEC  (PPM, ppm);
     REGISTER_DECODER (PTX, ptx);
     REGISTER_DECODER (QDRAW, qdraw);
     REGISTER_DECODER (QPEG, qpeg);
@@ -181,11 +187,16 @@
     /* audio codecs */
     REGISTER_DECODER (AAC, aac);
     REGISTER_ENCDEC  (AC3, ac3);
+#ifdef EM8622
+    REGISTER_DECODER  (AC3DUMMY, ac3);
+#endif
     REGISTER_ENCDEC  (ALAC, alac);
     REGISTER_DECODER (APE, ape);
     REGISTER_DECODER (ATRAC3, atrac3);
     REGISTER_DECODER (COOK, cook);
     REGISTER_DECODER (DCA, dca);
+	REGISTER_DECODER (DTS_HD, dts_hd);
+	REGISTER_DECODER (DTS_MA, dts_ma);
     REGISTER_DECODER (DSICINAUDIO, dsicinaudio);
     REGISTER_DECODER (EAC3, eac3);
     REGISTER_ENCDEC  (FLAC, flac);
@@ -209,6 +220,7 @@
     REGISTER_DECODER (SMACKAUD, smackaud);
     REGISTER_ENCDEC  (SONIC, sonic);
     REGISTER_ENCODER (SONIC_LS, sonic_ls);
+    REGISTER_DECODER (TRUEHD, truehd);
     REGISTER_DECODER (TRUESPEECH, truespeech);
     REGISTER_DECODER (TTA, tta);
     REGISTER_DECODER (VMDAUDIO, vmdaudio);
@@ -243,6 +255,7 @@
     REGISTER_ENCDEC  (PCM_U32BE, pcm_u32be);
     REGISTER_ENCDEC  (PCM_U32LE, pcm_u32le);
     REGISTER_ENCDEC  (PCM_ZORK , pcm_zork);
+    REGISTER_DECODER (PCM_BD, pcm_bd);
 
     /* DPCM codecs */
     REGISTER_DECODER (INTERPLAY_DPCM, interplay_dpcm);
@@ -284,6 +297,7 @@
     REGISTER_ENCDEC  (DVBSUB, dvbsub);
     REGISTER_ENCDEC  (DVDSUB, dvdsub);
     REGISTER_DECODER (XSUB, xsub);
+    REGISTER_DECODER  (PGSSUB, pgssub);
 
     /* external libraries */
     REGISTER_ENCDEC  (LIBAMR_NB, libamr_nb);
@@ -291,21 +305,24 @@
     REGISTER_ENCDEC  (LIBDIRAC, libdirac);
     REGISTER_ENCODER (LIBFAAC, libfaac);
     REGISTER_DECODER (LIBFAAD, libfaad);
+    REGISTER_DECODER (LIBFAAD, libfaad2);
     REGISTER_ENCDEC  (LIBGSM, libgsm);
     REGISTER_ENCDEC  (LIBGSM_MS, libgsm_ms);
     REGISTER_ENCODER (LIBMP3LAME, libmp3lame);
-    REGISTER_ENCDEC  (LIBOPENCORE_AMRNB, libopencore_amrnb);
-    REGISTER_DECODER (LIBOPENCORE_AMRWB, libopencore_amrwb);
     REGISTER_DECODER (LIBOPENJPEG, libopenjpeg);
     REGISTER_ENCDEC  (LIBSCHROEDINGER, libschroedinger);
     REGISTER_DECODER (LIBSPEEX, libspeex);
     REGISTER_ENCODER (LIBTHEORA, libtheora);
     REGISTER_ENCODER (LIBVORBIS, libvorbis);
+#ifdef EM8622
+	REGISTER_DECODER (OGGIVORBIS, oggivorbis);
+#endif
     REGISTER_ENCODER (LIBX264, libx264);
     REGISTER_ENCODER (LIBXVID, libxvid);
 
     /* parsers */
     REGISTER_PARSER  (AAC, aac);
+    REGISTER_PARSER  (AAC, aac_latm);
     REGISTER_PARSER  (AC3, ac3);
     REGISTER_PARSER  (CAVSVIDEO, cavsvideo);
     REGISTER_PARSER  (DCA, dca);
diff --git a/libavcodec/alpha/asm.h b/libavcodec/alpha/asm.h
old mode 100644
new mode 100755
diff --git a/libavcodec/alpha/dsputil_alpha.c b/libavcodec/alpha/dsputil_alpha.c
old mode 100644
new mode 100755
diff --git a/libavcodec/alpha/dsputil_alpha_asm.S b/libavcodec/alpha/dsputil_alpha_asm.S
old mode 100644
new mode 100755
diff --git a/libavcodec/alpha/motion_est_alpha.c b/libavcodec/alpha/motion_est_alpha.c
old mode 100644
new mode 100755
diff --git a/libavcodec/alpha/motion_est_mvi_asm.S b/libavcodec/alpha/motion_est_mvi_asm.S
old mode 100644
new mode 100755
diff --git a/libavcodec/alpha/mpegvideo_alpha.c b/libavcodec/alpha/mpegvideo_alpha.c
old mode 100644
new mode 100755
diff --git a/libavcodec/alpha/regdef.h b/libavcodec/alpha/regdef.h
old mode 100644
new mode 100755
diff --git a/libavcodec/alpha/simple_idct_alpha.c b/libavcodec/alpha/simple_idct_alpha.c
old mode 100644
new mode 100755
diff --git a/libavcodec/apiexample.c b/libavcodec/apiexample.c
old mode 100644
new mode 100755
diff --git a/libavcodec/arm/dsputil_arm_s.S b/libavcodec/arm/dsputil_arm_s.S
index f10d616..5da4b54 100644
--- a/libavcodec/arm/dsputil_arm_s.S
+++ b/libavcodec/arm/dsputil_arm_s.S
@@ -722,5 +722,9 @@
         bne             1b
 
         pop             {r4-r10}
+#if HAVE_ARM5VTE
         bx              lr
+#else
+        mov             pc, lr
+#endif
         .endfunc
diff --git a/libavcodec/arm/mathops.h b/libavcodec/arm/mathops.h
index 0d8e044..2da9c1c 100644
--- a/libavcodec/arm/mathops.h
+++ b/libavcodec/arm/mathops.h
@@ -25,6 +25,8 @@
 #include <stdint.h>
 #include "libavutil/common.h"
 
+#if HAVE_INLINE_ASM
+
 #   define MULL MULL
 static inline av_const int MULL(int a, int b, unsigned shift)
 {
@@ -108,4 +110,6 @@
     return m;
 }
 
+#endif /* HAVE_INLINE_ASM */
+
 #endif /* AVCODEC_ARM_MATHOPS_H */
diff --git a/libavcodec/asv1.c b/libavcodec/asv1.c
old mode 100644
new mode 100755
diff --git a/libavcodec/audioconvert.c b/libavcodec/audioconvert.c
index 2f2ad8c..e22e29d 100644
--- a/libavcodec/audioconvert.c
+++ b/libavcodec/audioconvert.c
@@ -181,7 +181,6 @@
                      const void * const  in[6], const int  in_stride[6], int len)
 {
     int ch;
-
     //FIXME optimize common cases
 
     for(ch=0; ch<ctx->out_channels; ch++){
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 19ac4ec..89a787d 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -30,8 +30,8 @@
 #include "libavutil/avutil.h"
 
 #define LIBAVCODEC_VERSION_MAJOR 52
-#define LIBAVCODEC_VERSION_MINOR 20
-#define LIBAVCODEC_VERSION_MICRO  1
+#define LIBAVCODEC_VERSION_MINOR 22
+#define LIBAVCODEC_VERSION_MICRO  3
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
                                                LIBAVCODEC_VERSION_MINOR, \
@@ -191,6 +191,8 @@
     CODEC_ID_TGV,
     CODEC_ID_TGQ,
     CODEC_ID_TQI,
+    CODEC_ID_AURA,
+    CODEC_ID_AURA2,
 
     /* various PCM "codecs" */
     CODEC_ID_PCM_S16LE= 0x10000,
@@ -217,6 +219,7 @@
     CODEC_ID_PCM_F32LE,
     CODEC_ID_PCM_F64BE,
     CODEC_ID_PCM_F64LE,
+    CODEC_ID_PCM_BD,
 
     /* various ADPCM codecs */
     CODEC_ID_ADPCM_IMA_QT= 0x11000,
@@ -266,6 +269,7 @@
     CODEC_ID_MP2= 0x15000,
     CODEC_ID_MP3, ///< preferred ID for decoding MPEG audio layer 1, 2 or 3
     CODEC_ID_AAC,
+    CODEC_ID_AAC_LATM,
     CODEC_ID_AC3,
     CODEC_ID_DTS,
     CODEC_ID_VORBIS,
@@ -309,7 +313,13 @@
     CODEC_ID_EAC3,
     CODEC_ID_SIPR,
     CODEC_ID_MP1,
+    CODEC_ID_TWINVQ,
+    CODEC_ID_TRUEHD,
 
+	/* STV: HD audio codecs for detection purposes (not fully decoded) */
+	CODEC_ID_DTS_HD,
+	CODEC_ID_DTS_MA,
+	
     /* subtitle codecs */
     CODEC_ID_DVD_SUBTITLE= 0x17000,
     CODEC_ID_DVB_SUBTITLE,
@@ -317,6 +327,7 @@
     CODEC_ID_XSUB,
     CODEC_ID_SSA,
     CODEC_ID_MOV_TEXT,
+    CODEC_ID_HDMV_PGS_SUBTITLE,
 
     /* other specific kind of codecs (generally used for attachments) */
     CODEC_ID_TTF= 0x18000,
@@ -807,6 +818,13 @@
      * - decoding: Read by user.\
      */\
     int64_t reordered_opaque;\
+\
+    /**\
+     * hardware accelerator private data (FFmpeg allocated)\
+     * - encoding: unused\
+     * - decoding: Set by libavcodec\
+     */\
+    void *hwaccel_picture_private;\
 
 
 #define FF_QSCALE_TYPE_MPEG1 0
@@ -2071,6 +2089,13 @@
     int bidir_refine;
 
     /**
+	 * If it's a video stream, this is 1 if its interlaced. This is actually a per-frame
+	 * condition, but we want it for streams quite often and this is the only way to handle
+	 * the deallocation of the frame data.
+	 */
+	int interlaced;
+	
+    /**
      *
      * - encoding: Set by user.
      * - decoding: unused
@@ -2335,6 +2360,18 @@
     int ticks_per_frame;
 
     /**
+     * Hardware accelerator context.
+     * For some hardware accelerators, a global context needs to be
+     * provided by the user. In that case, this holds display-dependent
+     * data FFmpeg cannot instantiate itself. Please refer to the
+     * FFmpeg HW accelerator documentation to know how to fill this
+     * is. e.g. for VA API, this is a struct vaapi_context.
+     * - encoding: unused
+     * - decoding: Set by user
+     */
+    void *hwaccel_context;
+
+	/**
      * explicit P-frame weighted prediction analysis method
      * 0: off
      * 1: fast blind weighting (one reference duplicate with -1 offset)
@@ -2466,6 +2503,15 @@
      * @return zero if successful, a negative value otherwise
      */
     int (*end_frame)(AVCodecContext *avctx);
+
+    /**
+     * Size of HW accelerator private data.
+     *
+     * Private data is allocated with av_mallocz() before
+     * AVCodecContext.get_buffer() and deallocated after
+     * AVCodecContext.release_buffer().
+     */
+    int priv_data_size;
 } AVHWAccel;
 
 /**
@@ -2477,6 +2523,7 @@
     int linesize[4];       ///< number of bytes per line
 } AVPicture;
 
+#if LIBAVCODEC_VERSION_MAJOR < 53
 /**
  * AVPaletteControl
  * This structure defines a method for communicating palette changes
@@ -2500,6 +2547,7 @@
     unsigned int palette[AVPALETTE_COUNT];
 
 } AVPaletteControl attribute_deprecated;
+#endif
 
 enum AVSubtitleType {
     SUBTITLE_NONE,
@@ -2640,7 +2688,7 @@
  * @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);
+int avpicture_alloc(AVPicture *picture, enum PixelFormat pix_fmt, int width, int height);
 
 /**
  * Free a picture previously allocated by avpicture_alloc().
@@ -2657,6 +2705,7 @@
  * 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.
+ * Call with ptr == NULL to get the required size for the ptr buffer.
  *
  * @param picture AVPicture whose fields are to be filled in
  * @param ptr Buffer which will contain or contains the actual image data
@@ -2667,22 +2716,37 @@
  */
 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,
+int avpicture_layout(const AVPicture* src, enum PixelFormat 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.
+ * Note that this returns the size of a compact representation as generated
+ * by avpicture_layout, which can be smaller than the size required for e.g.
+ * avpicture_fill.
  *
  * @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
+ * @return Image data size in bytes or -1 on error (e.g. too large dimensions).
  */
-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);
+int avpicture_get_size(enum PixelFormat pix_fmt, int width, int height);
+void avcodec_get_chroma_sub_sample(enum PixelFormat pix_fmt, int *h_shift, int *v_shift);
+const char *avcodec_get_pix_fmt_name(enum PixelFormat pix_fmt);
 void avcodec_set_dimensions(AVCodecContext *s, int width, int height);
+
+/**
+ * Returns the pixel format corresponding to the name \p name.
+ *
+ * If there is no pixel format with name \p name, then looks for a
+ * pixel format with the name corresponding to the native endian
+ * format of \p name.
+ * For example in a little-endian system, first looks for "gray16",
+ * then for "gray16le".
+ *
+ * Finally if no pixel format has been found, returns \c PIX_FMT_NONE.
+ */
 enum PixelFormat avcodec_get_pix_fmt(const char* name);
 unsigned int avcodec_pix_fmt_to_codec_tag(enum PixelFormat p);
 
@@ -2710,7 +2774,7 @@
  * @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 avcodec_get_pix_fmt_loss(enum PixelFormat dst_pix_fmt, enum PixelFormat src_pix_fmt,
                              int has_alpha);
 
 /**
@@ -2735,7 +2799,7 @@
  * @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,
+enum PixelFormat avcodec_find_best_pix_fmt(int64_t pix_fmt_mask, enum PixelFormat src_pix_fmt,
                               int has_alpha, int *loss_ptr);
 
 
@@ -2749,7 +2813,7 @@
  * 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);
+void avcodec_pix_fmt_string (char *buf, int buf_size, enum PixelFormat pix_fmt);
 
 #define FF_ALPHA_TRANSP       0x0001 /* image has some totally transparent pixels */
 #define FF_ALPHA_SEMI_TRANSP  0x0002 /* image has some transparent pixels */
@@ -2759,12 +2823,12 @@
  * @return ored mask of FF_ALPHA_xxx constants
  */
 int img_get_alpha_info(const AVPicture *src,
-                       int pix_fmt, int width, int height);
+                       enum PixelFormat 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);
+                          enum PixelFormat pix_fmt, int width, int height);
 
 /* external high level API */
 
@@ -3209,6 +3273,34 @@
      * For example, this corresponds to H.264 dpb_output_delay.
      */
     int pts_dts_delta;
+
+    /**
+     * Position of the packet in file.
+     *
+     * Analogous to cur_frame_pts/dts
+     */
+    int64_t cur_frame_pos[AV_PARSER_PTS_NB];
+
+    /**
+     * Byte position of currently parsed frame in stream.
+     */
+    int64_t pos;
+
+    /**
+     * Previous frame byte position.
+     */
+    int64_t last_pos;
+
+    /**
+     * Normally, parsed container frames contain a complete video frame.
+     * However, for some formats (e.g., H.264), it is possible that a frame
+     * contains only a field. As fields have just half the duration of normal
+     * frame, frame rate detection would detect 2*fps instead of fps.
+     * By setting this field, frame rate detection will detect correct fps.
+     *
+     * Default 0, set to 1 by parser, if a frame containing single field detected.
+     */
+    int field_frame_flag;
 } AVCodecParserContext;
 
 typedef struct AVCodecParser {
@@ -3228,11 +3320,51 @@
 
 void av_register_codec_parser(AVCodecParser *parser);
 AVCodecParserContext *av_parser_init(int codec_id);
+
+#if LIBAVCODEC_VERSION_MAJOR < 53
+attribute_deprecated
 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);
+#endif
+
+/**
+ * Parse a packet.
+ *
+ * @param s             parser context.
+ * @param avctx         codec context.
+ * @param poutbuf       set to pointer to parsed buffer or NULL if not yet finished.
+ * @param poutbuf_size  set to size of parsed buffer or zero if not yet finished.
+ * @param buf           input buffer.
+ * @param buf_size      input length, to signal EOF, this should be 0 (so that the last frame can be output).
+ * @param pts           input presentation timestamp.
+ * @param dts           input decoding timestamp.
+ * @param pos           input byte position in stream.
+ * @return the number of bytes of the input bitstream used.
+ *
+ * Example:
+ * @code
+ *   while(in_len){
+ *       len = av_parser_parse2(myparser, AVCodecContext, &data, &size,
+ *                                        in_data, in_len,
+ *                                        pts, dts, pos);
+ *       in_data += len;
+ *       in_len  -= len;
+ *
+ *       if(size)
+ *          decode_frame(data, size);
+ *   }
+ * @endcode
+ */
+int av_parser_parse2(AVCodecParserContext *s,
+                     AVCodecContext *avctx,
+                     uint8_t **poutbuf, int *poutbuf_size,
+                     const uint8_t *buf, int buf_size,
+                     int64_t pts, int64_t dts,
+                     int64_t pos);
+
 int av_parser_change(AVCodecParserContext *s,
                      AVCodecContext *avctx,
                      uint8_t **poutbuf, int *poutbuf_size,
@@ -3280,21 +3412,36 @@
 void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size);
 
 /**
+* Allocate a buffer, reusing the given one if large enough.
+*
+* Contrary to av_fast_realloc the current buffer contents might not be
+* preserved and on error the old buffer is freed, thus no special
+* handling to avoid memleaks is necessary.
+*
+* @param ptr pointer to pointer to already allocated buffer, overwritten with pointer to new buffer
+* @param size size of the buffer *ptr points to
+* @param min_size minimum size of *ptr buffer after returning, *ptr will be NULL and
+*                 *size 0 if an error occurred.
+*/
+
+void av_fast_malloc(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);
+                     enum PixelFormat 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);
+                    enum PixelFormat 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 av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width, enum PixelFormat pix_fmt,
             int padtop, int padbottom, int padleft, int padright, int *color);
 
 unsigned int av_xiphlacing(unsigned char *s, unsigned int v);
@@ -3355,30 +3502,4 @@
  */
 AVHWAccel *av_hwaccel_next(AVHWAccel *hwaccel);
 
-
-/**
- * Lock operation used by lockmgr
- */
-enum AVLockOp {
-  AV_LOCK_CREATE,  ///< Create a mutex
-  AV_LOCK_OBTAIN,  ///< Lock the mutex
-  AV_LOCK_RELEASE, ///< Unlock the mutex
-  AV_LOCK_DESTROY, ///< Free mutex resources
-};
-
-/**
- * Register a user provided lock manager supporting the operations
- * specified by AVLockOp. \p mutex points to a (void *) where the
- * lockmgr should store/get a pointer to a user allocated mutex. It's
- * NULL upon AV_LOCK_CREATE and != NULL for all other ops.
- *
- * @param cb User defined callback. Note: FFmpeg may invoke calls to this
- *           callback during the call to av_lockmgr_register().
- *           Thus, the application must be prepared to handle that.
- *           If cb is set to NULL the lockmgr will be unregistered.
- *           Also note that during unregistration the previously registered
- *           lockmgr callback may also be invoked.
- */
-int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op));
-
 #endif /* AVCODEC_AVCODEC_H */
diff --git a/libavcodec/avs.c b/libavcodec/avs.c
old mode 100644
new mode 100755
diff --git a/libavcodec/beosthread.c b/libavcodec/beosthread.c
old mode 100644
new mode 100755
diff --git a/libavcodec/bethsoftvideo.c b/libavcodec/bethsoftvideo.c
old mode 100644
new mode 100755
diff --git a/libavcodec/bfi.c b/libavcodec/bfi.c
old mode 100644
new mode 100755
diff --git a/libavcodec/bfin/fdct_bfin.S b/libavcodec/bfin/fdct_bfin.S
old mode 100644
new mode 100755
diff --git a/libavcodec/bfin/idct_bfin.S b/libavcodec/bfin/idct_bfin.S
old mode 100644
new mode 100755
diff --git a/libavcodec/bfin/pixels_bfin.S b/libavcodec/bfin/pixels_bfin.S
old mode 100644
new mode 100755
diff --git a/libavcodec/bfin/vp3_idct_bfin.S b/libavcodec/bfin/vp3_idct_bfin.S
old mode 100644
new mode 100755
diff --git a/libavcodec/bitstream.c b/libavcodec/bitstream.c
old mode 100644
new mode 100755
index 57dd93e..d48a97a
--- a/libavcodec/bitstream.c
+++ b/libavcodec/bitstream.c
@@ -37,6 +37,7 @@
  8, 9,10,11,12,13,14,15
 };
 
+#if LIBAVCODEC_VERSION_MAJOR < 53
 /**
  * Same as av_mallocz_static(), but does a realloc.
  *
@@ -53,6 +54,7 @@
 {
     return av_realloc(ptr, size);
 }
+#endif
 
 void align_put_bits(PutBitContext *s)
 {
diff --git a/libavcodec/bitstream.h b/libavcodec/bitstream.h
old mode 100644
new mode 100755
index 8941da2..0ba0bd3
--- a/libavcodec/bitstream.h
+++ b/libavcodec/bitstream.h
@@ -33,6 +33,7 @@
 #include "libavutil/common.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/log.h"
+#include "mathops.h"
 
 #if defined(ALT_BITSTREAM_READER_LE) && !defined(ALT_BITSTREAM_READER)
 #   define ALT_BITSTREAM_READER
@@ -707,6 +708,13 @@
 }
 
 /**
+ * reads 0-32 bits as a signed integer.
+ */
+static inline int get_sbits_long(GetBitContext *s, int n) {
+    return sign_extend(get_bits_long(s, n), n);
+}
+
+/**
  * shows 0-32 bits.
  */
 static inline unsigned int show_bits_long(GetBitContext *s, int n){
diff --git a/libavcodec/bmp.c b/libavcodec/bmp.c
old mode 100644
new mode 100755
diff --git a/libavcodec/bmpenc.c b/libavcodec/bmpenc.c
old mode 100644
new mode 100755
index a54355c..578813a
--- a/libavcodec/bmpenc.c
+++ b/libavcodec/bmpenc.c
@@ -1,6 +1,7 @@
 /*
  * BMP image format encoder
  * Copyright (c) 2006, 2007 Michel Bardiaux
+ * Copyright (c) 2009 Daniel Verkamp <daniel at drv.nu>
  *
  * This file is part of FFmpeg.
  *
@@ -23,6 +24,9 @@
 #include "bytestream.h"
 #include "bmp.h"
 
+static const uint32_t monoblack_pal[] = { 0x000000, 0xFFFFFF };
+static const uint32_t rgb565_masks[]  = { 0xF800, 0x07E0, 0x001F };
+
 static av_cold int bmp_encode_init(AVCodecContext *avctx){
     BMPContext *s = avctx->priv_data;
 
@@ -37,19 +41,52 @@
     AVFrame *pict = data;
     AVFrame * const p= (AVFrame*)&s->picture;
     int n_bytes_image, n_bytes_per_row, n_bytes, i, n, hsize;
+    const uint32_t *pal = NULL;
+    int pad_bytes_per_row, bit_count, pal_entries = 0, compression = BMP_RGB;
     uint8_t *ptr;
     unsigned char* buf0 = buf;
     *p = *pict;
     p->pict_type= FF_I_TYPE;
     p->key_frame= 1;
-    n_bytes_per_row = (avctx->width*3 + 3) & ~3;
-    n_bytes_image = avctx->height*n_bytes_per_row;
+    switch (avctx->pix_fmt) {
+    case PIX_FMT_BGR24:
+        bit_count = 24;
+        break;
+    case PIX_FMT_RGB555:
+        bit_count = 16;
+        break;
+    case PIX_FMT_RGB565:
+        bit_count = 16;
+        compression = BMP_BITFIELDS;
+        pal = rgb565_masks; // abuse pal to hold color masks
+        pal_entries = 3;
+        break;
+    case PIX_FMT_RGB8:
+    case PIX_FMT_BGR8:
+    case PIX_FMT_RGB4_BYTE:
+    case PIX_FMT_BGR4_BYTE:
+    case PIX_FMT_GRAY8:
+    case PIX_FMT_PAL8:
+        bit_count = 8;
+        pal = (uint32_t *)p->data[1];
+        break;
+    case PIX_FMT_MONOBLACK:
+        bit_count = 1;
+        pal = monoblack_pal;
+        break;
+    default:
+        return -1;
+    }
+    if (pal && !pal_entries) pal_entries = 1 << bit_count;
+    n_bytes_per_row = ((int64_t)avctx->width * (int64_t)bit_count + 7LL) >> 3LL;
+    pad_bytes_per_row = (4 - n_bytes_per_row) & 3;
+    n_bytes_image = avctx->height * (n_bytes_per_row + pad_bytes_per_row);
 
     // STRUCTURE.field refer to the MSVC documentation for BITMAPFILEHEADER
     // and related pages.
 #define SIZE_BITMAPFILEHEADER 14
 #define SIZE_BITMAPINFOHEADER 40
-    hsize = SIZE_BITMAPFILEHEADER + SIZE_BITMAPINFOHEADER;
+    hsize = SIZE_BITMAPFILEHEADER + SIZE_BITMAPINFOHEADER + (pal_entries << 2);
     n_bytes = n_bytes_image + hsize;
     if(n_bytes>buf_size) {
         av_log(avctx, AV_LOG_ERROR, "buf size too small (need %d, got %d)\n", n_bytes, buf_size);
@@ -65,22 +102,30 @@
     bytestream_put_le32(&buf, avctx->width);          // BITMAPINFOHEADER.biWidth
     bytestream_put_le32(&buf, avctx->height);         // BITMAPINFOHEADER.biHeight
     bytestream_put_le16(&buf, 1);                     // BITMAPINFOHEADER.biPlanes
-    bytestream_put_le16(&buf, 24);                    // BITMAPINFOHEADER.biBitCount
-    bytestream_put_le32(&buf, BMP_RGB);               // BITMAPINFOHEADER.biCompression
+    bytestream_put_le16(&buf, bit_count);             // BITMAPINFOHEADER.biBitCount
+    bytestream_put_le32(&buf, compression);           // BITMAPINFOHEADER.biCompression
     bytestream_put_le32(&buf, n_bytes_image);         // BITMAPINFOHEADER.biSizeImage
     bytestream_put_le32(&buf, 0);                     // BITMAPINFOHEADER.biXPelsPerMeter
     bytestream_put_le32(&buf, 0);                     // BITMAPINFOHEADER.biYPelsPerMeter
     bytestream_put_le32(&buf, 0);                     // BITMAPINFOHEADER.biClrUsed
     bytestream_put_le32(&buf, 0);                     // BITMAPINFOHEADER.biClrImportant
+    for (i = 0; i < pal_entries; i++)
+        bytestream_put_le32(&buf, pal[i] & 0xFFFFFF);
     // BMP files are bottom-to-top so we start from the end...
     ptr = p->data[0] + (avctx->height - 1) * p->linesize[0];
     buf = buf0 + hsize;
     for(i = 0; i < avctx->height; i++) {
-        n = 3*avctx->width;
-        memcpy(buf, ptr, n);
-        buf += n;
-        memset(buf, 0, n_bytes_per_row-n);
-        buf += n_bytes_per_row-n;
+        if (bit_count == 16) {
+            const uint16_t *src = (const uint16_t *) ptr;
+            uint16_t *dst = (uint16_t *) buf;
+            for(n = 0; n < avctx->width; n++)
+                AV_WL16(dst + n, src[n]);
+        } else {
+            memcpy(buf, ptr, n_bytes_per_row);
+        }
+        buf += n_bytes_per_row;
+        memset(buf, 0, pad_bytes_per_row);
+        buf += pad_bytes_per_row;
         ptr -= p->linesize[0]; // ... and go back
     }
     return n_bytes;
@@ -94,6 +139,11 @@
     bmp_encode_init,
     bmp_encode_frame,
     NULL, //encode_end,
-    .pix_fmts= (enum PixelFormat[]){PIX_FMT_BGR24, PIX_FMT_NONE},
+    .pix_fmts = (enum PixelFormat[]){
+        PIX_FMT_BGR24,
+        PIX_FMT_RGB555, PIX_FMT_RGB565,
+        PIX_FMT_RGB8, PIX_FMT_BGR8, PIX_FMT_RGB4_BYTE, PIX_FMT_BGR4_BYTE, PIX_FMT_GRAY8, PIX_FMT_PAL8,
+        PIX_FMT_MONOBLACK,
+        PIX_FMT_NONE},
     .long_name = NULL_IF_CONFIG_SMALL("BMP image"),
 };
diff --git a/libavcodec/c93.c b/libavcodec/c93.c
old mode 100644
new mode 100755
diff --git a/libavcodec/cabac.c b/libavcodec/cabac.c
old mode 100644
new mode 100755
index c2a7f8a..c3b3429
--- a/libavcodec/cabac.c
+++ b/libavcodec/cabac.c
@@ -179,9 +179,9 @@
 }
 
 #ifdef TEST
-#undef random
 #define SIZE 10240
 
+#include "libavutil/lfg.h"
 #include "avcodec.h"
 #include "cabac.h"
 
@@ -191,12 +191,14 @@
     uint8_t r[9*SIZE];
     int i;
     uint8_t state[10]= {0};
+    AVLFG prn;
 
+    av_lfg_init(&prn, 1);
     ff_init_cabac_encoder(&c, b, SIZE);
     ff_init_cabac_states(&c);
 
     for(i=0; i<SIZE; i++){
-        r[i]= random()%7;
+        r[i] = av_lfg_get(&prn) % 7;
     }
 
     for(i=0; i<SIZE; i++){
diff --git a/libavcodec/cabac.h b/libavcodec/cabac.h
old mode 100644
new mode 100755
diff --git a/libavcodec/cavs_parser.c b/libavcodec/cavs_parser.c
old mode 100644
new mode 100755
diff --git a/libavcodec/cavsdsp.c b/libavcodec/cavsdsp.c
old mode 100644
new mode 100755
diff --git a/libavcodec/cinepak.c b/libavcodec/cinepak.c
old mode 100644
new mode 100755
diff --git a/libavcodec/cljr.c b/libavcodec/cljr.c
old mode 100644
new mode 100755
diff --git a/libavcodec/colorspace.h b/libavcodec/colorspace.h
old mode 100644
new mode 100755
diff --git a/libavcodec/cook.c b/libavcodec/cook.c
old mode 100644
new mode 100755
index 3e7ffcf..0c72b7d
--- a/libavcodec/cook.c
+++ b/libavcodec/cook.c
@@ -46,7 +46,8 @@
 #include <stddef.h>
 #include <stdio.h>
 
-#include "libavutil/random.h"
+#include "libavutil/lfg.h"
+#include "libavutil/random_seed.h"
 #include "avcodec.h"
 #include "bitstream.h"
 #include "dsputil.h"
@@ -61,6 +62,7 @@
 #define MC_COOK         0x2000000   //multichannel Cook, not supported
 
 #define SUBBAND_SIZE    20
+#define MAX_SUBPACKETS   5
 //#define COOKDEBUG
 
 typedef struct {
@@ -91,6 +93,7 @@
 
     void (* saturate_output) (struct cook *q, int chan, int16_t *out);
 
+    AVCodecContext*     avctx;
     GetBitContext       gb;
     /* stream data */
     int                 nb_channels;
@@ -108,7 +111,7 @@
     int                 bits_per_subpacket;
     int                 cookversion;
     /* states */
-    AVRandomState       random_state;
+    AVLFG               random_state;
 
     /* transform data */
     MDCTContext         mdct_ctx;
@@ -211,7 +214,7 @@
             envelope_quant_index_huffbits[i], 1, 1,
             envelope_quant_index_huffcodes[i], 2, 2, 0);
     }
-    av_log(NULL,AV_LOG_DEBUG,"sqvh VLC init\n");
+    av_log(q->avctx,AV_LOG_DEBUG,"sqvh VLC init\n");
     for (i=0 ; i<7 ; i++) {
         result |= init_vlc (&q->sqvh[i], vhvlcsize_tab[i], vhsize_tab[i],
             cvh_huffbits[i], 1, 1,
@@ -222,10 +225,10 @@
         result |= init_vlc (&q->ccpl, 6, (1<<q->js_vlc_bits)-1,
             ccpl_huffbits[q->js_vlc_bits-2], 1, 1,
             ccpl_huffcodes[q->js_vlc_bits-2], 2, 2, 0);
-        av_log(NULL,AV_LOG_DEBUG,"Joint-stereo VLC used.\n");
+        av_log(q->avctx,AV_LOG_DEBUG,"Joint-stereo VLC used.\n");
     }
 
-    av_log(NULL,AV_LOG_DEBUG,"VLC tables initialized.\n");
+    av_log(q->avctx,AV_LOG_DEBUG,"VLC tables initialized.\n");
     return result;
 }
 
@@ -246,7 +249,7 @@
       av_free(q->mlt_window);
       return -1;
     }
-    av_log(NULL,AV_LOG_DEBUG,"MDCT initialized, order = %d.\n",
+    av_log(q->avctx,AV_LOG_DEBUG,"MDCT initialized, order = %d.\n",
            av_log2(mlt_size)+1);
 
     return 0;
@@ -338,7 +341,7 @@
         free_vlc(&q->ccpl);
     }
 
-    av_log(NULL,AV_LOG_DEBUG,"Memory deallocated.\n");
+    av_log(avctx,AV_LOG_DEBUG,"Memory deallocated.\n");
 
     return 0;
 }
@@ -419,7 +422,7 @@
     if(bits_left > q->samples_per_channel) {
         bits_left = q->samples_per_channel +
                     ((bits_left - q->samples_per_channel)*5)/8;
-        //av_log(NULL, AV_LOG_ERROR, "bits_left = %d\n",bits_left);
+        //av_log(q->avctx, AV_LOG_ERROR, "bits_left = %d\n",bits_left);
     }
 
     memset(&exp_index1,0,102*sizeof(int));
@@ -539,7 +542,7 @@
         } else {
             /* noise coding if subband_coef_index[i] == 0 */
             f1 = dither_tab[index];
-            if (av_random(&q->random_state) < 0x80000000) f1 = -f1;
+            if (av_lfg_get(&q->random_state) < 0x80000000) f1 = -f1;
         }
         mlt_p[i] = f1 * rootpow2tab[quant_index+63];
     }
@@ -935,9 +938,9 @@
                             int sub_packet_size, int16_t *outbuffer) {
     /* packet dump */
 //    for (i=0 ; i<sub_packet_size ; i++) {
-//        av_log(NULL, AV_LOG_ERROR, "%02x", inbuffer[i]);
+//        av_log(q->avctx, AV_LOG_ERROR, "%02x", inbuffer[i]);
 //    }
-//    av_log(NULL, AV_LOG_ERROR, "\n");
+//    av_log(q->avctx, AV_LOG_ERROR, "\n");
 
     decode_bytes_and_gain(q, inbuffer, &q->gains1);
 
@@ -994,14 +997,14 @@
 static void dump_cook_context(COOKContext *q)
 {
     //int i=0;
-#define PRINT(a,b) av_log(NULL,AV_LOG_ERROR," %s = %d\n", a, b);
-    av_log(NULL,AV_LOG_ERROR,"COOKextradata\n");
-    av_log(NULL,AV_LOG_ERROR,"cookversion=%x\n",q->cookversion);
+#define PRINT(a,b) av_log(q->avctx,AV_LOG_ERROR," %s = %d\n", a, b);
+    av_log(q->avctx,AV_LOG_ERROR,"COOKextradata\n");
+    av_log(q->avctx,AV_LOG_ERROR,"cookversion=%x\n",q->cookversion);
     if (q->cookversion > STEREO) {
         PRINT("js_subband_start",q->js_subband_start);
         PRINT("js_vlc_bits",q->js_vlc_bits);
     }
-    av_log(NULL,AV_LOG_ERROR,"COOKContext\n");
+    av_log(q->avctx,AV_LOG_ERROR,"COOKContext\n");
     PRINT("nb_channels",q->nb_channels);
     PRINT("bit_rate",q->bit_rate);
     PRINT("sample_rate",q->sample_rate);
@@ -1016,6 +1019,16 @@
 }
 #endif
 
+static av_cold int cook_count_channels(unsigned int mask){
+    int i;
+    int channels = 0;
+    for(i = 0;i<32;i++){
+        if(mask & (1<<i))
+            ++channels;
+    }
+    return channels;
+}
+
 /**
  * Cook initialization
  *
@@ -1026,6 +1039,7 @@
 {
     COOKContext *q = avctx->priv_data;
     const uint8_t *edata_ptr = avctx->extradata;
+    q->avctx = avctx;
 
     /* Take care of the codec specific extradata. */
     if (avctx->extradata_size <= 0) {
@@ -1053,7 +1067,7 @@
     q->bit_rate = avctx->bit_rate;
 
     /* Initialize RNG. */
-    av_random_init(&q->random_state, 1);
+    av_lfg_init(&q->random_state, ff_random_get_seed());
 
     /* Initialize extradata related variables. */
     q->samples_per_channel = q->samples_per_frame / q->nb_channels;
@@ -1064,7 +1078,7 @@
     q->total_subbands = q->subbands;
 
     /* Initialize version-dependent variables */
-    av_log(NULL,AV_LOG_DEBUG,"q->cookversion=%x\n",q->cookversion);
+    av_log(avctx,AV_LOG_DEBUG,"q->cookversion=%x\n",q->cookversion);
     q->joint_stereo = 0;
     switch (q->cookversion) {
         case MONO:
diff --git a/libavcodec/cookdata.h b/libavcodec/cookdata.h
old mode 100644
new mode 100755
diff --git a/libavcodec/cscd.c b/libavcodec/cscd.c
old mode 100644
new mode 100755
diff --git a/libavcodec/cyuv.c b/libavcodec/cyuv.c
old mode 100644
new mode 100755
diff --git a/libavcodec/dca.c b/libavcodec/dca.c
index 3bc895b..b650158 100644
--- a/libavcodec/dca.c
+++ b/libavcodec/dca.c
@@ -303,11 +303,12 @@
     static const float adj_table[4] = { 1.0, 1.1250, 1.2500, 1.4375 };
     static const int bitlen[11] = { 0, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3 };
     static const int thr[11] = { 0, 1, 3, 3, 3, 3, 7, 7, 7, 7, 7 };
-
+	uint32_t syncword = 0;
+	
     init_get_bits(&s->gb, s->dca_buffer, s->dca_buffer_size * 8);
 
     /* Sync code */
-    get_bits(&s->gb, 32);
+    syncword = get_bits(&s->gb, 32);
 
     /* Frame header */
     s->frame_type        = get_bits(&s->gb, 1);
@@ -904,7 +905,7 @@
     if (code == 0)
         return 0;
     else {
-        av_log(NULL, AV_LOG_ERROR, "ERROR: block code look-up failed\n");
+//        av_log(NULL, AV_LOG_ERROR, "ERROR: block code look-up failed\n");
         return -1;
     }
 }
@@ -1216,6 +1217,7 @@
     int16_t *samples = data;
     DCAContext *s = avctx->priv_data;
     int channels;
+    uint32_t mrk=0;
 
 
     s->dca_buffer_size = dca_convert_bitstream(buf, buf_size, s->dca_buffer, DCA_MAX_FRAME_SIZE);
@@ -1233,6 +1235,8 @@
     //set AVCodec values with parsed data
     avctx->sample_rate = s->sample_rate;
     avctx->bit_rate = s->bit_rate;
+    // JFT, so we only look at 1 frame when looking for DTS-HD/DTS-MA
+    avctx->frame_size = s->sample_blocks*32;
 
     channels = s->prim_channels + !!s->lfe;
 
@@ -1273,6 +1277,37 @@
         samples += 256 * channels;
     }
 
+    // See if there is a HD extension
+
+    /* extensions start at 32-bit boundaries into bitstream */
+    skip_bits_long(&s->gb, (-get_bits_count(&s->gb)) & 31);
+    /*align_get_bits(&s->gb);
+    while(get_bits_count(&s->gb)<(s->dca_buffer_size * 8))
+    {
+        mrk=get_bits_long(&s->gb, 8);
+        if(mrk!=0)
+        {
+            mrk=(mrk<<24)|get_bits_long(&s->gb, 24);
+            break;
+        }
+    }
+    av_log(avctx, AV_LOG_ERROR, "Marker %X\n",mrk);
+    if(mrk==DCA_HD_MARKER)
+    {
+        avctx->codec_id=CODEC_ID_DTS_MA;
+    }*/
+    while(get_bits_count(&s->gb)<(s->dca_buffer_size * 8-31))
+    {
+        uint32_t bits = get_bits_long(&s->gb, 32);
+        switch(bits) {
+        case DCA_HD_MARKER:
+            avctx->codec_id=CODEC_ID_DTS_MA;
+            break;
+        }
+
+        skip_bits_long(&s->gb, (-get_bits_count(&s->gb)) & 31);
+    }
+
     return buf_size;
 }
 
@@ -1334,3 +1369,25 @@
     .close = dca_decode_end,
     .long_name = NULL_IF_CONFIG_SMALL("DCA (DTS Coherent Acoustics)"),
 };
+
+AVCodec dts_hd_decoder = {
+	.name = "dts_hd",
+	.type = CODEC_TYPE_AUDIO,
+	.id = CODEC_ID_DTS_HD,
+	.priv_data_size = sizeof(DCAContext),
+	.init = dca_decode_init,
+	.decode = dca_decode_frame,
+	.close = dca_decode_end,
+	.long_name = NULL_IF_CONFIG_SMALL("DTS-HD"),
+};
+
+AVCodec dts_ma_decoder = {
+	.name = "dts_ma",
+	.type = CODEC_TYPE_AUDIO,
+	.id = CODEC_ID_DTS_MA,
+	.priv_data_size = sizeof(DCAContext),
+	.init = dca_decode_init,
+	.decode = dca_decode_frame,
+	.close = dca_decode_end,
+	.long_name = NULL_IF_CONFIG_SMALL("DTS-MA"),
+};
diff --git a/libavcodec/dca_parser.c b/libavcodec/dca_parser.c
index 49b2ecd..6b5b734 100644
--- a/libavcodec/dca_parser.c
+++ b/libavcodec/dca_parser.c
@@ -130,7 +130,7 @@
 }
 
 AVCodecParser dca_parser = {
-    {CODEC_ID_DTS},
+    {CODEC_ID_DTS, CODEC_ID_DTS_HD, CODEC_ID_DTS_MA},
     sizeof(DCAParseContext),
     dca_parse_init,
     dca_parse,
diff --git a/libavcodec/dct-test.c b/libavcodec/dct-test.c
old mode 100644
new mode 100755
index 48e7c5a..0e27e1c
--- a/libavcodec/dct-test.c
+++ b/libavcodec/dct-test.c
@@ -33,6 +33,7 @@
 #include <math.h>
 
 #include "libavutil/common.h"
+#include "libavutil/lfg.h"
 
 #include "simple_idct.h"
 #include "aandcttab.h"
@@ -41,14 +42,13 @@
 #include "x86/idct_xvid.h"
 
 #undef printf
-#undef random
 
 void *fast_memcpy(void *a, const void *b, size_t c){return memcpy(a,b,c);};
 
 /* reference fdct/idct */
-void ff_ref_fdct(DCTELEM *block);
-void ff_ref_idct(DCTELEM *block);
-void ff_ref_dct_init(void);
+void fdct(DCTELEM *block);
+void idct(DCTELEM *block);
+void init_fdct(void);
 
 void ff_mmx_idct(DCTELEM *data);
 void ff_mmxext_idct(DCTELEM *data);
@@ -90,57 +90,57 @@
 static int cpu_flags;
 
 struct algo algos[] = {
-  {"REF-DBL",         0, ff_ref_fdct,        ff_ref_fdct, NO_PERM},
-  {"FAAN",            0, ff_faandct,         ff_ref_fdct, FAAN_SCALE},
-  {"FAANI",           1, ff_faanidct,        ff_ref_idct, NO_PERM},
-  {"IJG-AAN-INT",     0, fdct_ifast,         ff_ref_fdct, SCALE_PERM},
-  {"IJG-LLM-INT",     0, ff_jpeg_fdct_islow, ff_ref_fdct, NO_PERM},
-  {"REF-DBL",         1, ff_ref_idct,        ff_ref_idct, NO_PERM},
-  {"INT",             1, j_rev_dct,          ff_ref_idct, MMX_PERM},
-  {"SIMPLE-C",        1, ff_simple_idct,     ff_ref_idct, NO_PERM},
+  {"REF-DBL",         0, fdct,               fdct, NO_PERM},
+  {"FAAN",            0, ff_faandct,         fdct, FAAN_SCALE},
+  {"FAANI",           1, ff_faanidct,        idct, NO_PERM},
+  {"IJG-AAN-INT",     0, fdct_ifast,         fdct, SCALE_PERM},
+  {"IJG-LLM-INT",     0, ff_jpeg_fdct_islow, fdct, NO_PERM},
+  {"REF-DBL",         1, idct,               idct, NO_PERM},
+  {"INT",             1, j_rev_dct,          idct, MMX_PERM},
+  {"SIMPLE-C",        1, ff_simple_idct,     idct, NO_PERM},
 
 #if HAVE_MMX
-  {"MMX",             0, ff_fdct_mmx,        ff_ref_fdct, NO_PERM, FF_MM_MMX},
+  {"MMX",             0, ff_fdct_mmx,        fdct, NO_PERM, FF_MM_MMX},
 #if HAVE_MMX2
-  {"MMX2",            0, ff_fdct_mmx2,       ff_ref_fdct, NO_PERM, FF_MM_MMXEXT},
-  {"SSE2",            0, ff_fdct_sse2,       ff_ref_fdct, NO_PERM, FF_MM_SSE2},
+  {"MMX2",            0, ff_fdct_mmx2,       fdct, NO_PERM, FF_MM_MMXEXT},
+  {"SSE2",            0, ff_fdct_sse2,       fdct, NO_PERM, FF_MM_SSE2},
 #endif
 
 #if CONFIG_GPL
-  {"LIBMPEG2-MMX",    1, ff_mmx_idct,        ff_ref_idct, MMX_PERM, FF_MM_MMX},
-  {"LIBMPEG2-MMXEXT", 1, ff_mmxext_idct,     ff_ref_idct, MMX_PERM, FF_MM_MMXEXT},
+  {"LIBMPEG2-MMX",    1, ff_mmx_idct,        idct, MMX_PERM, FF_MM_MMX},
+  {"LIBMPEG2-MMXEXT", 1, ff_mmxext_idct,     idct, MMX_PERM, FF_MM_MMXEXT},
 #endif
-  {"SIMPLE-MMX",      1, ff_simple_idct_mmx, ff_ref_idct, MMX_SIMPLE_PERM, FF_MM_MMX},
-  {"XVID-MMX",        1, ff_idct_xvid_mmx,   ff_ref_idct, NO_PERM, FF_MM_MMX},
-  {"XVID-MMX2",       1, ff_idct_xvid_mmx2,  ff_ref_idct, NO_PERM, FF_MM_MMXEXT},
-  {"XVID-SSE2",       1, ff_idct_xvid_sse2,  ff_ref_idct, SSE2_PERM, FF_MM_SSE2},
+  {"SIMPLE-MMX",      1, ff_simple_idct_mmx, idct, MMX_SIMPLE_PERM, FF_MM_MMX},
+  {"XVID-MMX",        1, ff_idct_xvid_mmx,   idct, NO_PERM, FF_MM_MMX},
+  {"XVID-MMX2",       1, ff_idct_xvid_mmx2,  idct, NO_PERM, FF_MM_MMXEXT},
+  {"XVID-SSE2",       1, ff_idct_xvid_sse2,  idct, SSE2_PERM, FF_MM_SSE2},
 #endif
 
 #if HAVE_ALTIVEC
-  {"altivecfdct",     0, fdct_altivec,       ff_ref_fdct, NO_PERM, FF_MM_ALTIVEC},
+  {"altivecfdct",     0, fdct_altivec,       fdct, NO_PERM, FF_MM_ALTIVEC},
 #endif
 
 #if ARCH_BFIN
-  {"BFINfdct",        0, ff_bfin_fdct,       ff_ref_fdct, NO_PERM},
-  {"BFINidct",        1, ff_bfin_idct,       ff_ref_idct, NO_PERM},
+  {"BFINfdct",        0, ff_bfin_fdct,       fdct, NO_PERM},
+  {"BFINidct",        1, ff_bfin_idct,       idct, NO_PERM},
 #endif
 
 #if ARCH_ARM
-  {"SIMPLE-ARM",      1, simple_idct_ARM,    ff_ref_idct, NO_PERM },
-  {"INT-ARM",         1, j_rev_dct_ARM,      ff_ref_idct, MMX_PERM },
+  {"SIMPLE-ARM",      1, simple_idct_ARM,    idct, NO_PERM },
+  {"INT-ARM",         1, j_rev_dct_ARM,      idct, MMX_PERM },
 #if HAVE_ARMV5TE
-  {"SIMPLE-ARMV5TE",  1, simple_idct_armv5te, ff_ref_idct, NO_PERM },
+  {"SIMPLE-ARMV5TE",  1, simple_idct_armv5te, idct, NO_PERM },
 #endif
 #if HAVE_ARMV6
-  {"SIMPLE-ARMV6",    1, ff_simple_idct_armv6, ff_ref_idct, MMX_PERM },
+  {"SIMPLE-ARMV6",    1, ff_simple_idct_armv6, idct, MMX_PERM },
 #endif
 #if HAVE_NEON
-  {"SIMPLE-NEON",     1, ff_simple_idct_neon, ff_ref_idct, PARTTRANS_PERM },
+  {"SIMPLE-NEON",     1, ff_simple_idct_neon, idct, PARTTRANS_PERM },
 #endif
 #endif /* ARCH_ARM */
 
 #if ARCH_ALPHA
-  {"SIMPLE-ALPHA",    1, ff_simple_idct_axp,  ff_ref_idct, NO_PERM },
+  {"SIMPLE-ALPHA",    1, ff_simple_idct_axp,  idct, NO_PERM },
 #endif
 
   { 0 }
@@ -208,8 +208,9 @@
     int64_t sysErr[64], sysErrMax=0;
     int maxout=0;
     int blockSumErrMax=0, blockSumErr;
+    AVLFG prn;
 
-    srandom(0);
+    av_lfg_init(&prn, 1);
 
     err_inf = 0;
     err2 = 0;
@@ -220,21 +221,21 @@
         switch(test){
         case 0:
             for(i=0;i<64;i++)
-                block1[i] = (random() % 512) -256;
+                block1[i] = (av_lfg_get(&prn) % 512) -256;
             if (is_idct){
-                ff_ref_fdct(block1);
+                fdct(block1);
 
                 for(i=0;i<64;i++)
                     block1[i]>>=3;
             }
         break;
         case 1:{
-            int num= (random()%10)+1;
+            int num = av_lfg_get(&prn) % 10 + 1;
             for(i=0;i<num;i++)
-                block1[random()%64] = (random() % 512) -256;
+                block1[av_lfg_get(&prn) % 64] = av_lfg_get(&prn) % 512 -256;
         }break;
         case 2:
-            block1[0]= (random()%4096)-2048;
+            block1[0] = av_lfg_get(&prn) % 4096 - 2048;
             block1[63]= (block1[0]&1)^1;
         break;
         }
@@ -319,7 +320,7 @@
 #if 1 // dump systematic errors
     for(i=0; i<64; i++){
         if(i%8==0) printf("\n");
-        printf("%5d ", (int)sysErr[i]);
+        printf("%7d ", (int)sysErr[i]);
     }
     printf("\n");
 #endif
@@ -334,9 +335,9 @@
     switch(test){
     case 0:
         for(i=0;i<64;i++)
-            block1[i] = (random() % 512) -256;
+            block1[i] = av_lfg_get(&prn) % 512 -256;
         if (is_idct){
-            ff_ref_fdct(block1);
+            fdct(block1);
 
             for(i=0;i<64;i++)
                 block1[i]>>=3;
@@ -344,10 +345,10 @@
     break;
     case 1:{
     case 2:
-        block1[0] = (random() % 512) -256;
-        block1[1] = (random() % 512) -256;
-        block1[2] = (random() % 512) -256;
-        block1[3] = (random() % 512) -256;
+        block1[0] = av_lfg_get(&prn) % 512 -256;
+        block1[1] = av_lfg_get(&prn) % 512 -256;
+        block1[2] = av_lfg_get(&prn) % 512 -256;
+        block1[3] = av_lfg_get(&prn) % 512 -256;
     }break;
     }
 
@@ -471,7 +472,9 @@
 {
     int it, i, it1, ti, ti1, err_max, v;
 
-    srandom(0);
+    AVLFG prn;
+
+    av_lfg_init(&prn, 1);
 
     /* just one test to see if code is correct (precision is less
        important here) */
@@ -480,7 +483,7 @@
 
         /* XXX: use forward transform to generate values */
         for(i=0;i<64;i++)
-            block1[i] = (random() % 256) - 128;
+            block1[i] = av_lfg_get(&prn) % 256 - 128;
         block1[0] += 1024;
 
         for(i=0; i<64; i++)
@@ -559,7 +562,7 @@
     int test=1;
     cpu_flags = mm_support();
 
-    ff_ref_dct_init();
+    init_fdct();
     idct_mmx_init();
 
     for(i=0;i<256;i++) cropTbl[i + MAX_NEG_CROP] = i;
diff --git a/libavcodec/dctref.c b/libavcodec/dctref.c
deleted file mode 100644
index faad057..0000000
--- a/libavcodec/dctref.c
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * reference discrete cosine transform (double precision)
- * Copyright (C) 2009 Dylan Yudaken
- *
- * 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/dctref.c
- * reference discrete cosine transform (double precision)
- *
- * @author Dylan Yudaken (dyudaken at gmail)
- *
- * @note This file could be optimized a lot, but is for
- * reference and so readability is better.
- */
-
-#include "libavutil/mathematics.h"
-static double coefficients[8 * 8];
-
-/**
- * Initialize the double precision discrete cosine transform
- * functions fdct & idct.
- */
-av_cold void ff_ref_dct_init(void)
-{
-    unsigned int i, j;
-
-    for (j = 0; j < 8; ++j) {
-        coefficients[j] = sqrt(0.125);
-        for (i = 8; i < 64; i += 8) {
-            coefficients[i + j] = 0.5 * cos(i * (j + 0.5) * M_PI / 64.0);
-        }
-    }
-}
-
-/**
- * Transform 8x8 block of data with a double precision forward DCT <br>
- * This is a reference implementation.
- *
- * @param block pointer to 8x8 block of data to transform
- */
-void ff_ref_fdct(short *block)
-{
-    /* implement the equation: block = coefficients * block * coefficients' */
-
-    unsigned int i, j, k;
-    double out[8 * 8];
-
-    /* out = coefficients * block */
-    for (i = 0; i < 64; i += 8) {
-        for (j = 0; j < 8; ++j) {
-            double tmp = 0;
-            for (k = 0; k < 8; ++k) {
-                tmp += coefficients[i + k] * block[k * 8 + j];
-            }
-            out[i + j] = tmp * 8;
-        }
-    }
-
-    /* block = out * (coefficients') */
-    for (j = 0; j < 8; ++j) {
-        for (i = 0; i < 64; i += 8) {
-            double tmp = 0;
-            for (k = 0; k < 8; ++k) {
-                tmp += out[i + k] * coefficients[j * 8 + k];
-            }
-            block[i + j] = floor(tmp + 0.499999999999);
-        }
-    }
-}
-
-/**
- * Transform 8x8 block of data with a double precision inverse DCT <br>
- * This is a reference implementation.
- *
- * @param block pointer to 8x8 block of data to transform
- */
-void ff_ref_idct(short *block)
-{
-    /* implement the equation: block = (coefficients') * block * coefficients */
-
-    unsigned int i, j, k;
-    double out[8 * 8];
-
-    /* out = block * coefficients */
-    for (i = 0; i < 64; i += 8) {
-        for (j = 0; j < 8; ++j) {
-            double tmp = 0;
-            for (k = 0; k < 8; ++k) {
-                tmp += block[i + k] * coefficients[k * 8 + j];
-            }
-            out[i + j] = tmp;
-        }
-    }
-
-    /* block = (coefficients') * out */
-    for (i = 0; i < 8; ++i) {
-        for (j = 0; j < 8; ++j) {
-            double tmp = 0;
-            for (k = 0; k < 64; k += 8) {
-                tmp += coefficients[k + i] * out[k + j];
-            }
-            block[i * 8 + j] = floor(tmp + 0.5);
-        }
-    }
-}
diff --git a/libavcodec/dpcm.c b/libavcodec/dpcm.c
old mode 100644
new mode 100755
diff --git a/libavcodec/dsicinav.c b/libavcodec/dsicinav.c
old mode 100644
new mode 100755
diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c
index 86a6c37..da41bf8 100644
--- a/libavcodec/dsputil.c
+++ b/libavcodec/dsputil.c
@@ -40,7 +40,9 @@
 void ff_spatial_dwt(int *buffer, int width, int height, int stride, int type, int decomposition_count);
 
 /* vorbis.c */
+#ifdef CONFIG_VORBIS_DECODER
 void vorbis_inverse_coupling(float *mag, float *ang, int blocksize);
+#endif
 
 /* ac3dec.c */
 void ff_ac3_downmix_c(float (*samples)[256], float (*matrix)[2], int out_ch, int in_ch, int len);
diff --git a/libavcodec/dump_extradata_bsf.c b/libavcodec/dump_extradata_bsf.c
old mode 100644
new mode 100755
diff --git a/libavcodec/dv.c b/libavcodec/dv.c
old mode 100644
new mode 100755
diff --git a/libavcodec/dvbsub.c b/libavcodec/dvbsub.c
old mode 100644
new mode 100755
diff --git a/libavcodec/dvbsub_parser.c b/libavcodec/dvbsub_parser.c
old mode 100644
new mode 100755
diff --git a/libavcodec/dvbsubdec.c b/libavcodec/dvbsubdec.c
old mode 100644
new mode 100755
diff --git a/libavcodec/dvdata.h b/libavcodec/dvdata.h
old mode 100644
new mode 100755
diff --git a/libavcodec/dvdsub_parser.c b/libavcodec/dvdsub_parser.c
old mode 100644
new mode 100755
diff --git a/libavcodec/dvdsubdec.c b/libavcodec/dvdsubdec.c
old mode 100644
new mode 100755
diff --git a/libavcodec/dvdsubenc.c b/libavcodec/dvdsubenc.c
old mode 100644
new mode 100755
diff --git a/libavcodec/eac3dec.c b/libavcodec/eac3dec.c
index f57c1cc..8af729d 100644
--- a/libavcodec/eac3dec.c
+++ b/libavcodec/eac3dec.c
@@ -20,6 +20,34 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+/*
+ * There are several features of E-AC-3 that this decoder does not yet support.
+ *
+ * Spectral Extension
+ *     There is a patch to get this working for the two samples we have that
+ *     use it, but it needs some minor changes in order to be accepted.
+ *
+ * Enhanced Coupling
+ *     No known samples exist.  If any ever surface, this feature should not be
+ *     too difficult to implement.
+ *
+ * Reduced Sample Rates
+ *     No known samples exist.  The spec also does not give clear information
+ *     on how this is to be implemented.
+ *
+ * Dependent Streams
+ *     Only the independent stream is currently decoded. Any dependent
+ *     streams are skipped.  We have only come across two examples of this, and
+ *     they are both just test streams, one for HD-DVD and the other for
+ *     Blu-ray.
+ *
+ * Transient Pre-noise Processing
+ *     This is side information which a decoder should use to reduce artifacts
+ *     caused by transients.  There are samples which are known to have this
+ *     information, but this decoder currently ignores it.
+ */
+
+
 #include "avcodec.h"
 #include "internal.h"
 #include "aac_ac3_parser.h"
diff --git a/libavcodec/elbg.c b/libavcodec/elbg.c
old mode 100644
new mode 100755
index 712c927..35f0688
--- a/libavcodec/elbg.c
+++ b/libavcodec/elbg.c
@@ -25,7 +25,7 @@
 
 #include <string.h>
 
-#include "libavutil/random.h"
+#include "libavutil/lfg.h"
 #include "elbg.h"
 #include "avcodec.h"
 
@@ -52,7 +52,7 @@
     int *utility_inc;
     int *nearest_cb;
     int *points;
-    AVRandomState *rand_state;
+    AVLFG *rand_state;
 } elbg_data;
 
 static inline int distance_limited(int *a, int *b, int dim, int limit)
@@ -105,7 +105,7 @@
 {
     int i=0;
     /* Using linear search, do binary if it ever turns to be speed critical */
-    int r = av_random(elbg->rand_state)%(elbg->utility_inc[elbg->numCB-1]-1) + 1;
+    int r = av_lfg_get(elbg->rand_state)%(elbg->utility_inc[elbg->numCB-1]-1) + 1;
     while (elbg->utility_inc[i] < r)
         i++;
 
@@ -318,7 +318,7 @@
 
 void ff_init_elbg(int *points, int dim, int numpoints, int *codebook,
                   int numCB, int max_steps, int *closest_cb,
-                  AVRandomState *rand_state)
+                  AVLFG *rand_state)
 {
     int i, k;
 
@@ -345,7 +345,7 @@
 
 void ff_do_elbg(int *points, int dim, int numpoints, int *codebook,
                 int numCB, int max_steps, int *closest_cb,
-                AVRandomState *rand_state)
+                AVLFG *rand_state)
 {
     int dist;
     elbg_data elbg_d;
diff --git a/libavcodec/elbg.h b/libavcodec/elbg.h
index cbc1f98..e6f577e 100644
--- a/libavcodec/elbg.h
+++ b/libavcodec/elbg.h
@@ -21,7 +21,7 @@
 #ifndef AVCODEC_ELBG_H
 #define AVCODEC_ELBG_H
 
-#include "libavutil/random.h"
+#include "libavutil/lfg.h"
 
 /**
  * Implementation of the Enhanced LBG Algorithm
@@ -35,11 +35,11 @@
  * @param numCB Number of points in the codebook.
  * @param num_steps The maximum number of steps. One step is already a good compromise between time and quality.
  * @param closest_cb Return the closest codebook to each point. Must be allocated.
- * @param rand_state A random number generator state. Should be already initialised by av_random_init.
+ * @param rand_state A random number generator state. Should be already initialized by av_lfg_init().
  */
 void ff_do_elbg(int *points, int dim, int numpoints, int *codebook,
                 int numCB, int num_steps, int *closest_cb,
-                AVRandomState *rand_state);
+                AVLFG *rand_state);
 
 /**
  * Initialize the **codebook vector for the elbg algorithm. If you have already
@@ -50,6 +50,6 @@
  */
 void ff_init_elbg(int *points, int dim, int numpoints, int *codebook,
                   int numCB, int num_steps, int *closest_cb,
-                  AVRandomState *rand_state);
+                  AVLFG *rand_state);
 
 #endif /* AVCODEC_ELBG_H */
diff --git a/libavcodec/error_resilience.c b/libavcodec/error_resilience.c
old mode 100644
new mode 100755
diff --git a/libavcodec/escape124.c b/libavcodec/escape124.c
old mode 100644
new mode 100755
diff --git a/libavcodec/eval.c b/libavcodec/eval.c
old mode 100644
new mode 100755
diff --git a/libavcodec/faandct.c b/libavcodec/faandct.c
old mode 100644
new mode 100755
diff --git a/libavcodec/faandct.h b/libavcodec/faandct.h
old mode 100644
new mode 100755
diff --git a/libavcodec/faanidct.c b/libavcodec/faanidct.c
old mode 100644
new mode 100755
diff --git a/libavcodec/fdctref.c b/libavcodec/fdctref.c
new file mode 100755
index 0000000..164883d
--- /dev/null
+++ b/libavcodec/fdctref.c
@@ -0,0 +1,157 @@
+/**
+ * @file libavcodec/fdctref.c
+ * forward discrete cosine transform, double precision.
+ */
+
+/* Copyright (C) 1996, MPEG Software Simulation Group. All Rights Reserved. */
+
+/*
+ * Disclaimer of Warranty
+ *
+ * These software programs are available to the user without any license fee or
+ * royalty on an "as is" basis.  The MPEG Software Simulation Group disclaims
+ * any and all warranties, whether express, implied, or statuary, including any
+ * implied warranties or merchantability or of fitness for a particular
+ * purpose.  In no event shall the copyright-holder be liable for any
+ * incidental, punitive, or consequential damages of any kind whatsoever
+ * arising from the use of these programs.
+ *
+ * This disclaimer of warranty extends to the user of these programs and user's
+ * customers, employees, agents, transferees, successors, and assigns.
+ *
+ * The MPEG Software Simulation Group does not represent or warrant that the
+ * programs furnished hereunder are free of infringement of any third-party
+ * patents.
+ *
+ * Commercial implementations of MPEG-1 and MPEG-2 video, including shareware,
+ * are subject to royalty fees to patent holders.  Many of these patents are
+ * general enough such that they are unavoidable regardless of implementation
+ * design.
+ */
+
+#include <math.h>
+
+#ifndef PI
+# ifdef M_PI
+#  define PI M_PI
+# else
+#  define PI 3.14159265358979323846
+# endif
+#endif
+
+/* global declarations */
+void init_fdct (void);
+void fdct (short *block);
+
+/* private data */
+static double c[8][8]; /* transform coefficients */
+
+void init_fdct(void)
+{
+  int i, j;
+  double s;
+
+  for (i=0; i<8; i++)
+  {
+    s = (i==0) ? sqrt(0.125) : 0.5;
+
+    for (j=0; j<8; j++)
+      c[i][j] = s * cos((PI/8.0)*i*(j+0.5));
+  }
+}
+
+void fdct(block)
+short *block;
+{
+        register int i, j;
+        double s;
+        double tmp[64];
+
+        for(i = 0; i < 8; i++)
+            for(j = 0; j < 8; j++)
+            {
+                    s = 0.0;
+
+/*
+ *                     for(k = 0; k < 8; k++)
+ *                         s += c[j][k] * block[8 * i + k];
+ */
+                s += c[j][0] * block[8 * i + 0];
+                s += c[j][1] * block[8 * i + 1];
+                s += c[j][2] * block[8 * i + 2];
+                s += c[j][3] * block[8 * i + 3];
+                s += c[j][4] * block[8 * i + 4];
+                s += c[j][5] * block[8 * i + 5];
+                s += c[j][6] * block[8 * i + 6];
+                s += c[j][7] * block[8 * i + 7];
+
+                    tmp[8 * i + j] = s;
+            }
+
+        for(j = 0; j < 8; j++)
+            for(i = 0; i < 8; i++)
+            {
+                    s = 0.0;
+
+/*
+ *                       for(k = 0; k < 8; k++)
+ *                    s += c[i][k] * tmp[8 * k + j];
+ */
+                s += c[i][0] * tmp[8 * 0 + j];
+                s += c[i][1] * tmp[8 * 1 + j];
+                s += c[i][2] * tmp[8 * 2 + j];
+                s += c[i][3] * tmp[8 * 3 + j];
+                s += c[i][4] * tmp[8 * 4 + j];
+                s += c[i][5] * tmp[8 * 5 + j];
+                s += c[i][6] * tmp[8 * 6 + j];
+                s += c[i][7] * tmp[8 * 7 + j];
+                s*=8.0;
+
+                    block[8 * i + j] = (short)floor(s + 0.499999);
+/*
+ * reason for adding 0.499999 instead of 0.5:
+ * s is quite often x.5 (at least for i and/or j = 0 or 4)
+ * and setting the rounding threshold exactly to 0.5 leads to an
+ * extremely high arithmetic implementation dependency of the result;
+ * s being between x.5 and x.500001 (which is now incorrectly rounded
+ * downwards instead of upwards) is assumed to occur less often
+ * (if at all)
+ */
+      }
+}
+
+/* perform IDCT matrix multiply for 8x8 coefficient block */
+
+void idct(block)
+short *block;
+{
+  int i, j, k, v;
+  double partial_product;
+  double tmp[64];
+
+  for (i=0; i<8; i++)
+    for (j=0; j<8; j++)
+    {
+      partial_product = 0.0;
+
+      for (k=0; k<8; k++)
+        partial_product+= c[k][j]*block[8*i+k];
+
+      tmp[8*i+j] = partial_product;
+    }
+
+  /* Transpose operation is integrated into address mapping by switching
+     loop order of i and j */
+
+  for (j=0; j<8; j++)
+    for (i=0; i<8; i++)
+    {
+      partial_product = 0.0;
+
+      for (k=0; k<8; k++)
+        partial_product+= c[k][i]*tmp[8*k+j];
+
+      v = (int) floor(partial_product+0.5);
+      block[8*i+j] = v;
+    }
+}
diff --git a/libavcodec/fft-test.c b/libavcodec/fft-test.c
old mode 100644
new mode 100755
index 92a0961..4f1ce98
--- a/libavcodec/fft-test.c
+++ b/libavcodec/fft-test.c
@@ -23,6 +23,7 @@
  * FFT and MDCT tests.
  */
 
+#include "libavutil/lfg.h"
 #include "dsputil.h"
 #include <math.h>
 #include <unistd.h>
@@ -31,7 +32,6 @@
 #include <string.h>
 
 #undef exit
-#undef random
 
 /* reference fft */
 
@@ -131,7 +131,9 @@
 
 float frandom(void)
 {
-    return (float)((random() & 0xffff) - 32768) / 32768.0;
+    AVLFG prn;
+    av_lfg_init(&prn, 1);
+    return (float)((av_lfg_get(&prn) & 0xffff) - 32768) / 32768.0;
 }
 
 int64_t gettime(void)
diff --git a/libavcodec/fft.c b/libavcodec/fft.c
old mode 100644
new mode 100755
index 296f634..a3f1151
--- a/libavcodec/fft.c
+++ b/libavcodec/fft.c
@@ -106,7 +106,7 @@
         s->imdct_half = ff_imdct_half_3dn;
         s->fft_calc   = ff_fft_calc_3dn;
     }
-#elif HAVE_ALTIVEC && !defined ALTIVEC_USE_REFERENCE_C_CODE
+#elif HAVE_ALTIVEC
     has_vectors = mm_support();
     if (has_vectors & FF_MM_ALTIVEC) {
         s->fft_calc = ff_fft_calc_altivec;
diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c
old mode 100644
new mode 100755
diff --git a/libavcodec/flac.c b/libavcodec/flac.c
new file mode 100755
index 0000000..a649e08
--- /dev/null
+++ b/libavcodec/flac.c
@@ -0,0 +1,43 @@
+/*
+ * FLAC common code
+ * Copyright (c) 2009 Justin Ruggles
+ *
+ * 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 "flac.h"
+
+int ff_flac_get_max_frame_size(int blocksize, int ch, int bps)
+{
+    /* Technically, there is no limit to FLAC frame size, but an encoder
+       should not write a frame that is larger than if verbatim encoding mode
+       were to be used. */
+
+    int count;
+
+    count = 16;                  /* frame header */
+    count += ch * ((7+bps+7)/8); /* subframe headers */
+    if (ch == 2) {
+        /* for stereo, need to account for using decorrelation */
+        count += (( 2*bps+1) * blocksize + 7) / 8;
+    } else {
+        count += ( ch*bps    * blocksize + 7) / 8;
+    }
+    count += 2; /* frame footer */
+
+    return count;
+}
diff --git a/libavcodec/flac.h b/libavcodec/flac.h
index 8af79f2..25494ed 100644
--- a/libavcodec/flac.h
+++ b/libavcodec/flac.h
@@ -29,7 +29,17 @@
 
 #include "avcodec.h"
 
-#define FLAC_STREAMINFO_SIZE 34
+#define FLAC_STREAMINFO_SIZE   34
+#define FLAC_MAX_CHANNELS       8
+#define FLAC_MIN_BLOCKSIZE     16
+#define FLAC_MAX_BLOCKSIZE  65535
+
+enum {
+    FLAC_CHMODE_INDEPENDENT =  0,
+    FLAC_CHMODE_LEFT_SIDE   =  8,
+    FLAC_CHMODE_RIGHT_SIDE  =  9,
+    FLAC_CHMODE_MID_SIDE    = 10,
+};
 
 enum {
     FLAC_METADATA_TYPE_STREAMINFO = 0,
@@ -47,23 +57,31 @@
     FLAC_EXTRADATA_FORMAT_FULL_HEADER = 1
 };
 
+#define FLACCOMMONINFO \
+    int samplerate;         /**< sample rate                             */\
+    int channels;           /**< number of channels                      */\
+    int bps;                /**< bits-per-sample                         */\
+
 /**
  * Data needed from the Streaminfo header for use by the raw FLAC demuxer
  * and/or the FLAC decoder.
  */
 #define FLACSTREAMINFO \
-    int min_blocksize;      /**< minimum block size, in samples          */\
+    FLACCOMMONINFO \
     int max_blocksize;      /**< maximum block size, in samples          */\
     int max_framesize;      /**< maximum frame size, in bytes            */\
-    int samplerate;         /**< sample rate                             */\
-    int channels;           /**< number of channels                      */\
-    int bps;                /**< bits-per-sample                         */\
     int64_t samples;        /**< total number of samples                 */\
 
 typedef struct FLACStreaminfo {
     FLACSTREAMINFO
 } FLACStreaminfo;
 
+typedef struct FLACFrameInfo {
+    FLACCOMMONINFO
+    int blocksize;          /**< block size of the frame                 */
+    int ch_mode;            /**< channel decorrelation mode              */
+} FLACFrameInfo;
+
 /**
  * Parse the Streaminfo metadata block
  * @param[out] avctx   codec context to set basic stream parameters
@@ -84,4 +102,22 @@
                                enum FLACExtradataFormat *format,
                                uint8_t **streaminfo_start);
 
+/**
+ * Parse the metadata block parameters from the header.
+ * @param[in]  block_header header data, at least 4 bytes
+ * @param[out] last indicator for last metadata block
+ * @param[out] type metadata block type
+ * @param[out] size metadata block size
+ */
+void ff_flac_parse_block_header(const uint8_t *block_header,
+                                int *last, int *type, int *size);
+
+/**
+ * Calculate an estimate for the maximum frame size based on verbatim mode.
+ * @param blocksize block size, in samples
+ * @param ch number of channels
+ * @param bps bits-per-sample
+ */
+int ff_flac_get_max_frame_size(int blocksize, int ch, int bps);
+
 #endif /* AVCODEC_FLAC_H */
diff --git a/libavcodec/flacdata.c b/libavcodec/flacdata.c
new file mode 100644
index 0000000..6fcbe39
--- /dev/null
+++ b/libavcodec/flacdata.c
@@ -0,0 +1,33 @@
+/*
+ * FLAC data
+ * Copyright (c) 2003 Alex Beregszaszi
+ *
+ * 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 "internal.h"
+
+const int ff_flac_sample_rate_table[16] =
+{ 0,
+  88200, 176400, 192000,
+  8000, 16000, 22050, 24000, 32000, 44100, 48000, 96000,
+  0, 0, 0, 0 };
+
+const int16_t ff_flac_blocksize_table[16] = {
+     0,    192, 576<<0, 576<<1, 576<<2, 576<<3,      0,      0,
+256<<0, 256<<1, 256<<2, 256<<3, 256<<4, 256<<5, 256<<6, 256<<7
+};
diff --git a/libavcodec/flacdata.h b/libavcodec/flacdata.h
new file mode 100644
index 0000000..96a50b9
--- /dev/null
+++ b/libavcodec/flacdata.h
@@ -0,0 +1,31 @@
+/*
+ * FLAC data header
+ * Copyright (c) 2003 Alex Beregszaszi
+ *
+ * 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_FLACDATA_H
+#define AVCODEC_FLACDATA_H
+
+#include "internal.h"
+
+extern const int ff_flac_sample_rate_table[16];
+
+extern const int16_t ff_flac_blocksize_table[16];
+
+#endif /* AVCODEC_FLACDATA_H */
diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c
index b3592f4..04e81c6 100644
--- a/libavcodec/flacdec.c
+++ b/libavcodec/flacdec.c
@@ -35,26 +35,18 @@
 
 #include <limits.h>
 
-#define ALT_BITSTREAM_READER
 #include "libavutil/crc.h"
 #include "avcodec.h"
+#include "internal.h"
 #include "bitstream.h"
+#include "bytestream.h"
 #include "golomb.h"
 #include "flac.h"
+#include "flacdata.h"
 
 #undef NDEBUG
 #include <assert.h>
 
-#define MAX_CHANNELS 8
-#define MAX_BLOCKSIZE 65535
-
-enum decorrelation_type {
-    INDEPENDENT,
-    LEFT_SIDE,
-    RIGHT_SIDE,
-    MID_SIDE,
-};
-
 typedef struct FLACContext {
     FLACSTREAMINFO
 
@@ -65,29 +57,19 @@
     int curr_bps;                           ///< bps for current subframe, adjusted for channel correlation and wasted bits
     int sample_shift;                       ///< shift required to make output samples 16-bit or 32-bit
     int is32;                               ///< flag to indicate if output should be 32-bit instead of 16-bit
-    enum decorrelation_type decorrelation;  ///< channel decorrelation type in the current frame
+    int ch_mode;                            ///< channel decorrelation type in the current frame
+    int got_streaminfo;                     ///< indicates if the STREAMINFO has been read
 
-    int32_t *decoded[MAX_CHANNELS];         ///< decoded samples
+    int32_t *decoded[FLAC_MAX_CHANNELS];    ///< decoded samples
     uint8_t *bitstream;
     unsigned int bitstream_size;
     unsigned int bitstream_index;
     unsigned int allocated_bitstream_size;
 } FLACContext;
 
-static const int sample_rate_table[] =
-{ 0,
-  88200, 176400, 192000,
-  8000, 16000, 22050, 24000, 32000, 44100, 48000, 96000,
-  0, 0, 0, 0 };
-
 static const int sample_size_table[] =
 { 0, 8, 12, 0, 16, 20, 24, 0 };
 
-static const int blocksize_table[] = {
-     0,    192, 576<<0, 576<<1, 576<<2, 576<<3,      0,      0,
-256<<0, 256<<1, 256<<2, 256<<3, 256<<4, 256<<5, 256<<6, 256<<7
-};
-
 static int64_t get_utf8(GetBitContext *gb)
 {
     int64_t val;
@@ -144,14 +126,14 @@
     /* initialize based on the demuxer-supplied streamdata header */
     ff_flac_parse_streaminfo(avctx, (FLACStreaminfo *)s, streaminfo);
     allocate_buffers(s);
+    s->got_streaminfo = 1;
 
     return 0;
 }
 
 static void dump_headers(AVCodecContext *avctx, FLACStreaminfo *s)
 {
-    av_log(avctx, AV_LOG_DEBUG, "  Blocksize: %d .. %d\n", s->min_blocksize,
-           s->max_blocksize);
+    av_log(avctx, AV_LOG_DEBUG, "  Max Blocksize: %d\n", s->max_blocksize);
     av_log(avctx, AV_LOG_DEBUG, "  Max Framesize: %d\n", s->max_framesize);
     av_log(avctx, AV_LOG_DEBUG, "  Samplerate: %d\n", s->samplerate);
     av_log(avctx, AV_LOG_DEBUG, "  Channels: %d\n", s->channels);
@@ -165,8 +147,8 @@
     assert(s->max_blocksize);
 
     if (s->max_framesize == 0 && s->max_blocksize) {
-        // FIXME header overhead
-        s->max_framesize= (s->channels * s->bps * s->max_blocksize + 7)/ 8;
+        s->max_framesize = ff_flac_get_max_frame_size(s->max_blocksize,
+                                                      s->channels, s->bps);
     }
 
     for (i = 0; i < s->channels; i++) {
@@ -186,9 +168,13 @@
     GetBitContext gb;
     init_get_bits(&gb, buffer, FLAC_STREAMINFO_SIZE*8);
 
-    /* mandatory streaminfo */
-    s->min_blocksize = get_bits(&gb, 16);
+    skip_bits(&gb, 16); /* skip min blocksize */
     s->max_blocksize = get_bits(&gb, 16);
+    if (s->max_blocksize < FLAC_MIN_BLOCKSIZE) {
+        av_log(avctx, AV_LOG_WARNING, "invalid max blocksize: %d\n",
+               s->max_blocksize);
+        s->max_blocksize = 16;
+    }
 
     skip_bits(&gb, 24); /* skip min frame size */
     s->max_framesize = get_bits_long(&gb, 24);
@@ -206,60 +192,78 @@
         avctx->sample_fmt = SAMPLE_FMT_S16;
 
     s->samples  = get_bits_long(&gb, 32) << 4;
-    s->samples |= get_bits_long(&gb, 4);
+    s->samples |= get_bits(&gb, 4);
 
-    skip_bits(&gb, 64); /* md5 sum */
-    skip_bits(&gb, 64); /* md5 sum */
+    skip_bits_long(&gb, 64); /* md5 sum */
+    skip_bits_long(&gb, 64); /* md5 sum */
 
     dump_headers(avctx, s);
 }
 
-/**
- * Parse a list of metadata blocks. This list of blocks must begin with
- * the fLaC marker.
- * @param s the flac decoding context containing the gb bit reader used to
- *          parse metadata
- * @return 1 if some metadata was read, 0 if no fLaC marker was found
- */
-static int metadata_parse(FLACContext *s)
+void ff_flac_parse_block_header(const uint8_t *block_header,
+                                int *last, int *type, int *size)
 {
-    int i, metadata_last, metadata_type, metadata_size, streaminfo_updated=0;
-    int initial_pos= get_bits_count(&s->gb);
+    int tmp = bytestream_get_byte(&block_header);
+    if (last)
+        *last = tmp & 0x80;
+    if (type)
+        *type = tmp & 0x7F;
+    if (size)
+        *size = bytestream_get_be24(&block_header);
+}
 
-    if (show_bits_long(&s->gb, 32) == MKBETAG('f','L','a','C')) {
-        skip_bits(&s->gb, 32);
+/**
+ * Parse the STREAMINFO from an inline header.
+ * @param s the flac decoding context
+ * @param buf input buffer, starting with the "fLaC" marker
+ * @param buf_size buffer size
+ * @return non-zero if metadata is invalid
+ */
+static int parse_streaminfo(FLACContext *s, const uint8_t *buf, int buf_size)
+{
+    int metadata_type, metadata_size;
 
-        do {
-            metadata_last = get_bits1(&s->gb);
-            metadata_type = get_bits(&s->gb, 7);
-            metadata_size = get_bits_long(&s->gb, 24);
-
-            if (get_bits_count(&s->gb) + 8*metadata_size > s->gb.size_in_bits) {
-                skip_bits_long(&s->gb, initial_pos - get_bits_count(&s->gb));
-                break;
-            }
-
-            if (metadata_size) {
-                switch (metadata_type) {
-                case FLAC_METADATA_TYPE_STREAMINFO:
-                    ff_flac_parse_streaminfo(s->avctx, (FLACStreaminfo *)s,
-                                             s->gb.buffer+get_bits_count(&s->gb)/8);
-                    streaminfo_updated = 1;
-
-                default:
-                    for (i = 0; i < metadata_size; i++)
-                        skip_bits(&s->gb, 8);
-                }
-            }
-        } while (!metadata_last);
-
-        if (streaminfo_updated)
-            allocate_buffers(s);
-        return 1;
+    if (buf_size < FLAC_STREAMINFO_SIZE+8) {
+        /* need more data */
+        return 0;
     }
+    ff_flac_parse_block_header(&buf[4], NULL, &metadata_type, &metadata_size);
+    if (metadata_type != FLAC_METADATA_TYPE_STREAMINFO ||
+        metadata_size != FLAC_STREAMINFO_SIZE) {
+        return AVERROR_INVALIDDATA;
+    }
+    ff_flac_parse_streaminfo(s->avctx, (FLACStreaminfo *)s, &buf[8]);
+    allocate_buffers(s);
+    s->got_streaminfo = 1;
+
     return 0;
 }
 
+/**
+ * Determine the size of an inline header.
+ * @param buf input buffer, starting with the "fLaC" marker
+ * @param buf_size buffer size
+ * @return number of bytes in the header, or 0 if more data is needed
+ */
+static int get_metadata_size(const uint8_t *buf, int buf_size)
+{
+    int metadata_last, metadata_size;
+    const uint8_t *buf_end = buf + buf_size;
+
+    buf += 4;
+    do {
+        ff_flac_parse_block_header(buf, &metadata_last, NULL, &metadata_size);
+        buf += 4;
+        if (buf + metadata_size > buf_end) {
+            /* need more data in order to read the complete header */
+            return 0;
+        }
+        buf += metadata_size;
+    } while (!metadata_last);
+
+    return buf_size - (buf_end - buf);
+}
+
 static int decode_residuals(FLACContext *s, int channel, int pred_order)
 {
     int i, tmp, partition, method_type, rice_order;
@@ -288,7 +292,7 @@
         if (tmp == (method_type == 0 ? 15 : 31)) {
             tmp = get_bits(&s->gb, 5);
             for (; i < samples; i++, sample++)
-                s->decoded[channel][sample] = get_sbits(&s->gb, tmp);
+                s->decoded[channel][sample] = get_sbits_long(&s->gb, tmp);
         } else {
             for (; i < samples; i++, sample++) {
                 s->decoded[channel][sample] = get_sr_golomb_flac(&s->gb, tmp, INT_MAX, 0);
@@ -308,7 +312,7 @@
 
     /* warm up samples */
     for (i = 0; i < pred_order; i++) {
-        decoded[i] = get_sbits(&s->gb, s->curr_bps);
+        decoded[i] = get_sbits_long(&s->gb, s->curr_bps);
     }
 
     if (decode_residuals(s, channel, pred_order) < 0)
@@ -359,7 +363,7 @@
 
     /* warm up samples */
     for (i = 0; i < pred_order; i++) {
-        decoded[i] = get_sbits(&s->gb, s->curr_bps);
+        decoded[i] = get_sbits_long(&s->gb, s->curr_bps);
     }
 
     coeff_prec = get_bits(&s->gb, 4) + 1;
@@ -424,10 +428,10 @@
 
     s->curr_bps = s->bps;
     if (channel == 0) {
-        if (s->decorrelation == RIGHT_SIDE)
+        if (s->ch_mode == FLAC_CHMODE_RIGHT_SIDE)
             s->curr_bps++;
     } else {
-        if (s->decorrelation == LEFT_SIDE || s->decorrelation == MID_SIDE)
+        if (s->ch_mode == FLAC_CHMODE_LEFT_SIDE || s->ch_mode == FLAC_CHMODE_MID_SIDE)
             s->curr_bps++;
     }
 
@@ -443,15 +447,19 @@
             wasted++;
         s->curr_bps -= wasted;
     }
+    if (s->curr_bps > 32) {
+        ff_log_missing_feature(s->avctx, "decorrelated bit depth > 32", 0);
+        return -1;
+    }
 
 //FIXME use av_log2 for types
     if (type == 0) {
-        tmp = get_sbits(&s->gb, s->curr_bps);
+        tmp = get_sbits_long(&s->gb, s->curr_bps);
         for (i = 0; i < s->blocksize; i++)
             s->decoded[channel][i] = tmp;
     } else if (type == 1) {
         for (i = 0; i < s->blocksize; i++)
-            s->decoded[channel][i] = get_sbits(&s->gb, s->curr_bps);
+            s->decoded[channel][i] = get_sbits_long(&s->gb, s->curr_bps);
     } else if ((type >= 8) && (type <= 12)) {
         if (decode_subframe_fixed(s, channel, type & ~0x8) < 0)
             return -1;
@@ -472,103 +480,143 @@
     return 0;
 }
 
-static int decode_frame(FLACContext *s, int alloc_data_size)
+/**
+ * Validate and decode a frame header.
+ * @param      avctx AVCodecContext to use as av_log() context
+ * @param      gb    GetBitContext from which to read frame header
+ * @param[out] fi    frame information
+ * @return non-zero on error, 0 if ok
+ */
+static int decode_frame_header(AVCodecContext *avctx, GetBitContext *gb,
+                               FLACFrameInfo *fi)
 {
-    int blocksize_code, sample_rate_code, sample_size_code, assignment, i, crc8;
-    int decorrelation, bps, blocksize, samplerate;
+    int bs_code, sr_code, bps_code;
 
-    blocksize_code = get_bits(&s->gb, 4);
+    /* frame sync code */
+    skip_bits(gb, 16);
 
-    sample_rate_code = get_bits(&s->gb, 4);
+    /* block size and sample rate codes */
+    bs_code = get_bits(gb, 4);
+    sr_code = get_bits(gb, 4);
 
-    assignment = get_bits(&s->gb, 4); /* channel assignment */
-    if (assignment < 8 && s->channels == assignment+1)
-        decorrelation = INDEPENDENT;
-    else if (assignment >=8 && assignment < 11 && s->channels == 2)
-        decorrelation = LEFT_SIDE + assignment - 8;
-    else {
-        av_log(s->avctx, AV_LOG_ERROR, "unsupported channel assignment %d (channels=%d)\n",
-               assignment, s->channels);
+    /* channels and decorrelation */
+    fi->ch_mode = get_bits(gb, 4);
+    if (fi->ch_mode < FLAC_MAX_CHANNELS) {
+        fi->channels = fi->ch_mode + 1;
+        fi->ch_mode = FLAC_CHMODE_INDEPENDENT;
+    } else if (fi->ch_mode <= FLAC_CHMODE_MID_SIDE) {
+        fi->channels = 2;
+    } else {
+        av_log(avctx, AV_LOG_ERROR, "invalid channel mode: %d\n", fi->ch_mode);
         return -1;
     }
 
-    sample_size_code = get_bits(&s->gb, 3);
-    if (sample_size_code == 0)
-        bps= s->bps;
-    else if ((sample_size_code != 3) && (sample_size_code != 7))
-        bps = sample_size_table[sample_size_code];
-    else {
-        av_log(s->avctx, AV_LOG_ERROR, "invalid sample size code (%d)\n",
-               sample_size_code);
+    /* bits per sample */
+    bps_code = get_bits(gb, 3);
+    if (bps_code == 3 || bps_code == 7) {
+        av_log(avctx, AV_LOG_ERROR, "invalid sample size code (%d)\n",
+               bps_code);
         return -1;
     }
-    if (bps > 16) {
+    fi->bps = sample_size_table[bps_code];
+
+    /* reserved bit */
+    if (get_bits1(gb)) {
+        av_log(avctx, AV_LOG_ERROR, "broken stream, invalid padding\n");
+        return -1;
+    }
+
+    /* sample or frame count */
+    if (get_utf8(gb) < 0) {
+        av_log(avctx, AV_LOG_ERROR, "utf8 fscked\n");
+        return -1;
+    }
+
+    /* blocksize */
+    if (bs_code == 0) {
+        av_log(avctx, AV_LOG_ERROR, "reserved blocksize code: 0\n");
+        return -1;
+    } else if (bs_code == 6) {
+        fi->blocksize = get_bits(gb, 8) + 1;
+    } else if (bs_code == 7) {
+        fi->blocksize = get_bits(gb, 16) + 1;
+    } else {
+        fi->blocksize = ff_flac_blocksize_table[bs_code];
+    }
+
+    /* sample rate */
+    if (sr_code < 12) {
+        fi->samplerate = ff_flac_sample_rate_table[sr_code];
+    } else if (sr_code == 12) {
+        fi->samplerate = get_bits(gb, 8) * 1000;
+    } else if (sr_code == 13) {
+        fi->samplerate = get_bits(gb, 16);
+    } else if (sr_code == 14) {
+        fi->samplerate = get_bits(gb, 16) * 10;
+    } else {
+        av_log(avctx, AV_LOG_ERROR, "illegal sample rate code %d\n",
+               sr_code);
+        return -1;
+    }
+
+    /* header CRC-8 check */
+    skip_bits(gb, 8);
+    if (av_crc(av_crc_get_table(AV_CRC_8_ATM), 0, gb->buffer,
+               get_bits_count(gb)/8)) {
+        av_log(avctx, AV_LOG_ERROR, "header crc mismatch\n");
+        return -1;
+    }
+
+    return 0;
+}
+
+static int decode_frame(FLACContext *s)
+{
+    int i;
+    GetBitContext *gb = &s->gb;
+    FLACFrameInfo fi;
+
+    if (decode_frame_header(s->avctx, gb, &fi)) {
+        av_log(s->avctx, AV_LOG_ERROR, "invalid frame header\n");
+        return -1;
+    }
+
+    if (fi.channels != s->channels) {
+        av_log(s->avctx, AV_LOG_ERROR, "switching channel layout mid-stream "
+                                       "is not supported\n");
+        return -1;
+    }
+    s->ch_mode = fi.ch_mode;
+
+    if (fi.bps && fi.bps != s->bps) {
+        av_log(s->avctx, AV_LOG_ERROR, "switching bps mid-stream is not "
+                                       "supported\n");
+        return -1;
+    }
+    if (s->bps > 16) {
         s->avctx->sample_fmt = SAMPLE_FMT_S32;
-        s->sample_shift = 32 - bps;
+        s->sample_shift = 32 - s->bps;
         s->is32 = 1;
     } else {
         s->avctx->sample_fmt = SAMPLE_FMT_S16;
-        s->sample_shift = 16 - bps;
+        s->sample_shift = 16 - s->bps;
         s->is32 = 0;
     }
-    s->bps = s->avctx->bits_per_raw_sample = bps;
 
-    if (get_bits1(&s->gb)) {
-        av_log(s->avctx, AV_LOG_ERROR, "broken stream, invalid padding\n");
-        return -1;
-    }
-
-    if (get_utf8(&s->gb) < 0) {
-        av_log(s->avctx, AV_LOG_ERROR, "utf8 fscked\n");
-        return -1;
-    }
-
-    if (blocksize_code == 0)
-        blocksize = s->min_blocksize;
-    else if (blocksize_code == 6)
-        blocksize = get_bits(&s->gb, 8)+1;
-    else if (blocksize_code == 7)
-        blocksize = get_bits(&s->gb, 16)+1;
-    else
-        blocksize = blocksize_table[blocksize_code];
-
-    if (blocksize > s->max_blocksize) {
-        av_log(s->avctx, AV_LOG_ERROR, "blocksize %d > %d\n", blocksize,
+    if (fi.blocksize > s->max_blocksize) {
+        av_log(s->avctx, AV_LOG_ERROR, "blocksize %d > %d\n", fi.blocksize,
                s->max_blocksize);
         return -1;
     }
+    s->blocksize = fi.blocksize;
 
-    if (blocksize * s->channels * sizeof(int16_t) > alloc_data_size)
-        return -1;
-
-    if (sample_rate_code == 0)
-        samplerate= s->samplerate;
-    else if (sample_rate_code < 12)
-        samplerate = sample_rate_table[sample_rate_code];
-    else if (sample_rate_code == 12)
-        samplerate = get_bits(&s->gb, 8) * 1000;
-    else if (sample_rate_code == 13)
-        samplerate = get_bits(&s->gb, 16);
-    else if (sample_rate_code == 14)
-        samplerate = get_bits(&s->gb, 16) * 10;
-    else {
-        av_log(s->avctx, AV_LOG_ERROR, "illegal sample rate code %d\n",
-               sample_rate_code);
-        return -1;
+    if (fi.samplerate == 0) {
+        fi.samplerate = s->samplerate;
+    } else if (fi.samplerate != s->samplerate) {
+        av_log(s->avctx, AV_LOG_WARNING, "sample rate changed from %d to %d\n",
+               s->samplerate, fi.samplerate);
     }
-
-    skip_bits(&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;
-    }
-
-    s->blocksize    = blocksize;
-    s->samplerate   = samplerate;
-    s->bps          = bps;
-    s->decorrelation= decorrelation;
+    s->samplerate = s->avctx->sample_rate = fi.samplerate;
 
 //    dump_headers(s->avctx, (FLACStreaminfo *)s);
 
@@ -578,10 +626,10 @@
             return -1;
     }
 
-    align_get_bits(&s->gb);
+    align_get_bits(gb);
 
     /* frame footer */
-    skip_bits(&s->gb, 16); /* data crc */
+    skip_bits(gb, 16); /* data crc */
 
     return 0;
 }
@@ -591,10 +639,11 @@
                             const uint8_t *buf, int buf_size)
 {
     FLACContext *s = avctx->priv_data;
-    int tmp = 0, i, j = 0, input_buf_size = 0;
+    int i, j = 0, input_buf_size = 0, bytes_read = 0;
     int16_t *samples_16 = data;
     int32_t *samples_32 = data;
     int alloc_data_size= *data_size;
+    int output_size;
 
     *data_size=0;
 
@@ -630,25 +679,50 @@
         }
     }
 
-    init_get_bits(&s->gb, buf, buf_size*8);
-
-    if (metadata_parse(s))
+    /* check that there is at least the smallest decodable amount of data.
+       this amount corresponds to the smallest valid FLAC frame possible.
+       FF F8 69 02 00 00 9A 00 00 34 46 */
+    if (buf_size < 11)
         goto end;
 
-    tmp = show_bits(&s->gb, 16);
-    if ((tmp & 0xFFFE) != 0xFFF8) {
+    /* check for inline header */
+    if (AV_RB32(buf) == MKBETAG('f','L','a','C')) {
+        if (!s->got_streaminfo && parse_streaminfo(s, buf, buf_size)) {
+            av_log(s->avctx, AV_LOG_ERROR, "invalid header\n");
+            return -1;
+        }
+        bytes_read = get_metadata_size(buf, buf_size);
+        goto end;
+    }
+
+    /* check for frame sync code and resync stream if necessary */
+    if ((AV_RB16(buf) & 0xFFFE) != 0xFFF8) {
+        const uint8_t *buf_end = buf + buf_size;
         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) & 0xFFFE) != 0xFFF8)
-            skip_bits(&s->gb, 8);
+        while (buf+2 < buf_end && (AV_RB16(buf) & 0xFFFE) != 0xFFF8)
+            buf++;
+        bytes_read = buf_size - (buf_end - buf);
         goto end; // we may not have enough bits left to decode a frame, so try next time
     }
-    skip_bits(&s->gb, 16);
-    if (decode_frame(s, alloc_data_size) < 0) {
+
+    /* decode frame */
+    init_get_bits(&s->gb, buf, buf_size*8);
+    if (decode_frame(s) < 0) {
         av_log(s->avctx, AV_LOG_ERROR, "decode_frame() failed\n");
         s->bitstream_size=0;
         s->bitstream_index=0;
         return -1;
     }
+    bytes_read = (get_bits_count(&s->gb)+7)/8;
+
+    /* check if allocated data size is large enough for output */
+    output_size = s->blocksize * s->channels * (s->is32 ? 4 : 2);
+    if (output_size > alloc_data_size) {
+        av_log(s->avctx, AV_LOG_ERROR, "output data size is larger than "
+                                       "allocated data size\n");
+        goto end;
+    }
+    *data_size = output_size;
 
 #define DECORRELATE(left, right)\
             assert(s->channels == 2);\
@@ -665,8 +739,8 @@
             }\
             break;
 
-    switch (s->decorrelation) {
-    case INDEPENDENT:
+    switch (s->ch_mode) {
+    case FLAC_CHMODE_INDEPENDENT:
         for (j = 0; j < s->blocksize; j++) {
             for (i = 0; i < s->channels; i++) {
                 if (s->is32)
@@ -676,31 +750,28 @@
             }
         }
         break;
-    case LEFT_SIDE:
+    case FLAC_CHMODE_LEFT_SIDE:
         DECORRELATE(a,a-b)
-    case RIGHT_SIDE:
+    case FLAC_CHMODE_RIGHT_SIDE:
         DECORRELATE(a+b,b)
-    case MID_SIDE:
+    case FLAC_CHMODE_MID_SIDE:
         DECORRELATE( (a-=b>>1) + b, a)
     }
 
-    *data_size = s->blocksize * s->channels * (s->is32 ? 4 : 2);
-
 end:
-    i= (get_bits_count(&s->gb)+7)/8;
-    if (i > buf_size) {
-        av_log(s->avctx, AV_LOG_ERROR, "overread: %d\n", i - buf_size);
+    if (bytes_read > buf_size) {
+        av_log(s->avctx, AV_LOG_ERROR, "overread: %d\n", bytes_read - buf_size);
         s->bitstream_size=0;
         s->bitstream_index=0;
         return -1;
     }
 
     if (s->bitstream_size) {
-        s->bitstream_index += i;
-        s->bitstream_size  -= i;
+        s->bitstream_index += bytes_read;
+        s->bitstream_size  -= bytes_read;
         return input_buf_size;
     } else
-        return i;
+        return bytes_read;
 }
 
 static av_cold int flac_decode_close(AVCodecContext *avctx)
diff --git a/libavcodec/flacenc.c b/libavcodec/flacenc.c
index 748906e..b517cfa 100644
--- a/libavcodec/flacenc.c
+++ b/libavcodec/flacenc.c
@@ -27,24 +27,14 @@
 #include "dsputil.h"
 #include "golomb.h"
 #include "lpc.h"
-
-#define FLAC_MAX_CH  8
-#define FLAC_MIN_BLOCKSIZE  16
-#define FLAC_MAX_BLOCKSIZE  65535
+#include "flac.h"
+#include "flacdata.h"
 
 #define FLAC_SUBFRAME_CONSTANT  0
 #define FLAC_SUBFRAME_VERBATIM  1
 #define FLAC_SUBFRAME_FIXED     8
 #define FLAC_SUBFRAME_LPC      32
 
-#define FLAC_CHMODE_NOT_STEREO      0
-#define FLAC_CHMODE_LEFT_RIGHT      1
-#define FLAC_CHMODE_LEFT_SIDE       8
-#define FLAC_CHMODE_RIGHT_SIDE      9
-#define FLAC_CHMODE_MID_SIDE       10
-
-#define FLAC_STREAMINFO_SIZE  34
-
 #define MAX_FIXED_ORDER     4
 #define MAX_PARTITION_ORDER 8
 #define MAX_PARTITIONS     (1 << MAX_PARTITION_ORDER)
@@ -82,7 +72,7 @@
 } FlacSubframe;
 
 typedef struct FlacFrame {
-    FlacSubframe subframes[FLAC_MAX_CH];
+    FlacSubframe subframes[FLAC_MAX_CHANNELS];
     int blocksize;
     int bs_code[2];
     uint8_t crc8;
@@ -92,11 +82,9 @@
 typedef struct FlacEncodeContext {
     PutBitContext pb;
     int channels;
-    int ch_code;
     int samplerate;
     int sr_code[2];
     int min_framesize;
-    int min_encoded_framesize;
     int max_framesize;
     int max_encoded_framesize;
     uint32_t frame_count;
@@ -109,20 +97,6 @@
     struct AVMD5 *md5ctx;
 } FlacEncodeContext;
 
-static const int flac_samplerates[16] = {
-    0, 0, 0, 0,
-    8000, 16000, 22050, 24000, 32000, 44100, 48000, 96000,
-    0, 0, 0, 0
-};
-
-static const int flac_blocksizes[16] = {
-    0,
-    192,
-    576, 1152, 2304, 4608,
-    0, 0,
-    256, 512, 1024, 2048, 4096, 8192, 16384, 32768
-};
-
 /**
  * Writes streaminfo metadata block to byte array
  */
@@ -159,11 +133,11 @@
     int blocksize;
 
     assert(samplerate > 0);
-    blocksize = flac_blocksizes[1];
+    blocksize = ff_flac_blocksize_table[1];
     target = (samplerate * block_time_ms) / 1000;
     for(i=0; i<16; i++) {
-        if(target >= flac_blocksizes[i] && flac_blocksizes[i] > blocksize) {
-            blocksize = flac_blocksizes[i];
+        if(target >= ff_flac_blocksize_table[i] && ff_flac_blocksize_table[i] > blocksize) {
+            blocksize = ff_flac_blocksize_table[i];
         }
     }
     return blocksize;
@@ -185,18 +159,17 @@
         return -1;
     }
 
-    if(channels < 1 || channels > FLAC_MAX_CH) {
+    if(channels < 1 || channels > FLAC_MAX_CHANNELS) {
         return -1;
     }
     s->channels = channels;
-    s->ch_code = s->channels-1;
 
     /* find samplerate in table */
     if(freq < 1)
         return -1;
     for(i=4; i<12; i++) {
-        if(freq == flac_samplerates[i]) {
-            s->samplerate = flac_samplerates[i];
+        if(freq == ff_flac_sample_rate_table[i]) {
+            s->samplerate = ff_flac_sample_rate_table[i];
             s->sr_code[0] = i;
             s->sr_code[1] = 0;
             break;
@@ -372,12 +345,8 @@
            s->options.lpc_coeff_precision);
 
     /* set maximum encoded frame size in verbatim mode */
-    if(s->channels == 2) {
-        s->max_framesize = 14 + ((s->avctx->frame_size * 33 + 7) >> 3);
-    } else {
-        s->max_framesize = 14 + (s->avctx->frame_size * s->channels * 2);
-    }
-    s->min_encoded_framesize = 0xFFFFFF;
+    s->max_framesize = ff_flac_get_max_frame_size(s->avctx->frame_size,
+                                                  s->channels, 16);
 
     /* initialize MD5 context */
     s->md5ctx = av_malloc(av_md5_size);
@@ -391,6 +360,7 @@
     avctx->extradata_size = FLAC_STREAMINFO_SIZE;
 
     s->frame_count = 0;
+    s->min_framesize = s->max_framesize;
 
     avctx->coded_frame = avcodec_alloc_frame();
     avctx->coded_frame->key_frame = 1;
@@ -406,8 +376,8 @@
     frame = &s->frame;
 
     for(i=0; i<16; i++) {
-        if(s->avctx->frame_size == flac_blocksizes[i]) {
-            frame->blocksize = flac_blocksizes[i];
+        if(s->avctx->frame_size == ff_flac_blocksize_table[i]) {
+            frame->blocksize = ff_flac_blocksize_table[i];
             frame->bs_code[0] = i;
             frame->bs_code[1] = 0;
             break;
@@ -1011,7 +981,7 @@
         }
     }
     if(best == 0) {
-        return FLAC_CHMODE_LEFT_RIGHT;
+        return FLAC_CHMODE_INDEPENDENT;
     } else if(best == 1) {
         return FLAC_CHMODE_LEFT_SIDE;
     } else if(best == 2) {
@@ -1036,14 +1006,14 @@
     right = frame->subframes[1].samples;
 
     if(ctx->channels != 2) {
-        frame->ch_mode = FLAC_CHMODE_NOT_STEREO;
+        frame->ch_mode = FLAC_CHMODE_INDEPENDENT;
         return;
     }
 
     frame->ch_mode = estimate_stereo_mode(left, right, n);
 
     /* perform decorrelation and adjust bits-per-sample */
-    if(frame->ch_mode == FLAC_CHMODE_LEFT_RIGHT) {
+    if(frame->ch_mode == FLAC_CHMODE_INDEPENDENT) {
         return;
     }
     if(frame->ch_mode == FLAC_CHMODE_MID_SIDE) {
@@ -1083,8 +1053,8 @@
     put_bits(&s->pb, 16, 0xFFF8);
     put_bits(&s->pb, 4, frame->bs_code[0]);
     put_bits(&s->pb, 4, s->sr_code[0]);
-    if(frame->ch_mode == FLAC_CHMODE_NOT_STEREO) {
-        put_bits(&s->pb, 4, s->ch_code);
+    if(frame->ch_mode == FLAC_CHMODE_INDEPENDENT) {
+        put_bits(&s->pb, 4, s->channels-1);
     } else {
         put_bits(&s->pb, 4, frame->ch_mode);
     }
@@ -1282,7 +1252,6 @@
 
     /* when the last block is reached, update the header in extradata */
     if (!data) {
-        s->min_framesize = s->min_encoded_framesize;
         s->max_framesize = s->max_encoded_framesize;
         av_md5_final(s->md5ctx, s->md5sum);
         write_streaminfo(s, avctx->extradata);
@@ -1326,8 +1295,8 @@
     update_md5_sum(s, samples);
     if (out_bytes > s->max_encoded_framesize)
         s->max_encoded_framesize = out_bytes;
-    if (out_bytes < s->min_encoded_framesize)
-        s->min_encoded_framesize = out_bytes;
+    if (out_bytes < s->min_framesize)
+        s->min_framesize = out_bytes;
 
     return out_bytes;
 }
diff --git a/libavcodec/flashsvenc.c b/libavcodec/flashsvenc.c
old mode 100644
new mode 100755
diff --git a/libavcodec/flicvideo.c b/libavcodec/flicvideo.c
old mode 100644
new mode 100755
diff --git a/libavcodec/fraps.c b/libavcodec/fraps.c
old mode 100644
new mode 100755
diff --git a/libavcodec/g726.c b/libavcodec/g726.c
old mode 100644
new mode 100755
diff --git a/libavcodec/g729.h b/libavcodec/g729.h
old mode 100644
new mode 100755
diff --git a/libavcodec/g729dec.c b/libavcodec/g729dec.c
old mode 100644
new mode 100755
diff --git a/libavcodec/gif.c b/libavcodec/gif.c
old mode 100644
new mode 100755
diff --git a/libavcodec/gifdec.c b/libavcodec/gifdec.c
old mode 100644
new mode 100755
diff --git a/libavcodec/golomb.c b/libavcodec/golomb.c
old mode 100644
new mode 100755
diff --git a/libavcodec/golomb.h b/libavcodec/golomb.h
old mode 100644
new mode 100755
diff --git a/libavcodec/h261.c b/libavcodec/h261.c
old mode 100644
new mode 100755
diff --git a/libavcodec/h261_parser.c b/libavcodec/h261_parser.c
old mode 100644
new mode 100755
diff --git a/libavcodec/h261data.h b/libavcodec/h261data.h
old mode 100644
new mode 100755
diff --git a/libavcodec/h261dec.c b/libavcodec/h261dec.c
old mode 100644
new mode 100755
diff --git a/libavcodec/h261enc.c b/libavcodec/h261enc.c
old mode 100644
new mode 100755
diff --git a/libavcodec/h263.c b/libavcodec/h263.c
old mode 100644
new mode 100755
index 2a25cda..b390279
--- a/libavcodec/h263.c
+++ b/libavcodec/h263.c
@@ -40,6 +40,7 @@
 #include "h263data.h"
 #include "mpeg4data.h"
 #include "mathops.h"
+#include "unary.h"
 
 //#undef NDEBUG
 //#include <assert.h>
@@ -661,12 +662,13 @@
                 time_pp= s->pp_field_time + field_select - i;
                 time_pb= s->pb_field_time + field_select - i;
             }
-            s->mv[0][i][0] = s->p_field_mv_table[i][0][mb_index][0]*time_pb/time_pp + mx;
-            s->mv[0][i][1] = s->p_field_mv_table[i][0][mb_index][1]*time_pb/time_pp + my;
+            // NARFLEX: SageTV Fix divide by zero errors that can happen here
+            s->mv[0][i][0] = (time_pp == 0) ? 0 : (s->p_field_mv_table[i][0][mb_index][0]*time_pb/time_pp + mx);
+            s->mv[0][i][1] = (time_pp == 0) ? 0 : (s->p_field_mv_table[i][0][mb_index][1]*time_pb/time_pp + my);
             s->mv[1][i][0] = mx ? s->mv[0][i][0] - s->p_field_mv_table[i][0][mb_index][0]
-                                : s->p_field_mv_table[i][0][mb_index][0]*(time_pb - time_pp)/time_pp;
+                                : ((time_pp == 0) ? 0 : (s->p_field_mv_table[i][0][mb_index][0]*(time_pb - time_pp)/time_pp));
             s->mv[1][i][1] = my ? s->mv[0][i][1] - s->p_field_mv_table[i][0][mb_index][1]
-                                : s->p_field_mv_table[i][0][mb_index][1]*(time_pb - time_pp)/time_pp;
+                                : ((time_pp == 0) ? 0 : (s->p_field_mv_table[i][0][mb_index][1]*(time_pb - time_pp)/time_pp));
         }
         return MB_TYPE_DIRECT2 | MB_TYPE_16x8 | MB_TYPE_L0L1 | MB_TYPE_INTERLACED;
     }else{
@@ -3055,7 +3057,7 @@
     uint8_t *start= pbBufPtr(&s->pb);
     uint8_t *end= s->pb.buf_end;
     int size= end - start;
-    int pb_size = (((long)start + size/3)&(~3)) - (long)start;
+    int pb_size = (((intptr_t)start + size/3)&(~3)) - (intptr_t)start;
     int tex_size= (size - 2*pb_size)&(~3);
 
     set_put_bits_buffer_size(&s->pb, pb_size);
@@ -3905,12 +3907,50 @@
     ff_set_qscale(s, s->qscale);
 }
 
+static int h263_skip_b_part(MpegEncContext *s, int cbp)
+{
+    DECLARE_ALIGNED(16, DCTELEM, dblock[64]);
+    int i, mbi;
+
+    /* we have to set s->mb_intra to zero to decode B-part of PB-frame correctly
+     * but real value should be restored in order to be used later (in OBMC condition)
+     */
+    mbi = s->mb_intra;
+    s->mb_intra = 0;
+    for (i = 0; i < 6; i++) {
+        if (h263_decode_block(s, dblock, i, cbp&32) < 0)
+            return -1;
+        cbp+=cbp;
+    }
+    s->mb_intra = mbi;
+    return 0;
+}
+
+static int h263_get_modb(GetBitContext *gb, int pb_frame, int *cbpb)
+{
+    int c, mv = 1;
+
+    if (pb_frame < 3) { // h.263 Annex G and i263 PB-frame
+        c = get_bits1(gb);
+        if (pb_frame == 2 && c)
+            mv = !get_bits1(gb);
+    } else { // h.263 Annex M improved PB-frame
+        mv = get_unary(gb, 0, 4) + 1;
+        c = mv & 1;
+        mv = !!(mv & 2);
+    }
+    if(c)
+        *cbpb = get_bits(gb, 6);
+    return mv;
+}
+
 int ff_h263_decode_mb(MpegEncContext *s,
                       DCTELEM block[6][64])
 {
     int cbpc, cbpy, i, cbp, pred_x, pred_y, mx, my, dquant;
     int16_t *mot_val;
     const int xy= s->mb_x + s->mb_y * s->mb_stride;
+    int cbpb = 0, pb_mv_count = 0;
 
     assert(!s->h263_pred);
 
@@ -3943,6 +3983,8 @@
         s->mb_intra = ((cbpc & 4) != 0);
         if (s->mb_intra) goto intra;
 
+        if(s->pb_frame && get_bits1(&s->gb))
+            pb_mv_count = h263_get_modb(&s->gb, s->pb_frame, &cbpb);
         cbpy = get_vlc2(&s->gb, cbpy_vlc.table, CBPY_VLC_BITS, 1);
 
         if(s->alt_inter_vlc==0 || (cbpc & 3)!=3)
@@ -4005,18 +4047,6 @@
                 mot_val[1] = my;
             }
         }
-
-        /* decode each block */
-        for (i = 0; i < 6; i++) {
-            if (h263_decode_block(s, block[i], i, cbp&32) < 0)
-                return -1;
-            cbp+=cbp;
-        }
-
-        if(s->obmc){
-            if(s->pict_type == FF_P_TYPE && s->mb_x+1<s->mb_width && s->mb_num_left != 1)
-                preview_obmc(s);
-        }
     } else if(s->pict_type==FF_B_TYPE) {
         int mb_type;
         const int stride= s->b8_stride;
@@ -4105,13 +4135,6 @@
         }
 
         s->current_picture.mb_type[xy]= mb_type;
-
-        /* decode each block */
-        for (i = 0; i < 6; i++) {
-            if (h263_decode_block(s, block[i], i, cbp&32) < 0)
-                return -1;
-            cbp+=cbp;
-        }
     } else { /* I-Frame */
         do{
             cbpc = get_vlc2(&s->gb, intra_MCBPC_vlc.table, INTRA_MCBPC_VLC_BITS, 2);
@@ -4137,6 +4160,8 @@
         }else
             s->ac_pred = 0;
 
+        if(s->pb_frame && get_bits1(&s->gb))
+            pb_mv_count = h263_get_modb(&s->gb, s->pb_frame, &cbpb);
         cbpy = get_vlc2(&s->gb, cbpy_vlc.table, CBPY_VLC_BITS, 1);
         if(cbpy<0){
             av_log(s->avctx, AV_LOG_ERROR, "I cbpy damaged at %d %d\n", s->mb_x, s->mb_y);
@@ -4147,12 +4172,26 @@
             h263_decode_dquant(s);
         }
 
-        /* decode each block */
-        for (i = 0; i < 6; i++) {
-            if (h263_decode_block(s, block[i], i, cbp&32) < 0)
-                return -1;
-            cbp+=cbp;
-        }
+        pb_mv_count += !!s->pb_frame;
+    }
+
+    while(pb_mv_count--){
+        h263_decode_motion(s, 0, 1);
+        h263_decode_motion(s, 0, 1);
+    }
+
+    /* decode each block */
+    for (i = 0; i < 6; i++) {
+        if (h263_decode_block(s, block[i], i, cbp&32) < 0)
+            return -1;
+        cbp+=cbp;
+    }
+
+    if(s->pb_frame && h263_skip_b_part(s, cbpb) < 0)
+        return -1;
+    if(s->obmc && !s->mb_intra){
+        if(s->pict_type == FF_P_TYPE && s->mb_x+1<s->mb_width && s->mb_num_left != 1)
+            preview_obmc(s);
     }
 end:
 
@@ -5066,10 +5105,7 @@
         s->obmc= get_bits1(&s->gb); /* Advanced prediction mode */
         s->unrestricted_mv = s->h263_long_vectors || s->obmc;
 
-        if (get_bits1(&s->gb) != 0) {
-            av_log(s->avctx, AV_LOG_ERROR, "H263 PB frame not supported\n");
-            return -1; /* not PB frame */
-        }
+        s->pb_frame = get_bits1(&s->gb);
         s->chroma_qscale= s->qscale = get_bits(&s->gb, 5);
         skip_bits1(&s->gb); /* Continuous Presence Multipoint mode: off */
 
@@ -5124,6 +5160,7 @@
         switch(s->pict_type){
         case 0: s->pict_type= FF_I_TYPE;break;
         case 1: s->pict_type= FF_P_TYPE;break;
+        case 2: s->pict_type= FF_P_TYPE;s->pb_frame = 3;break;
         case 3: s->pict_type= FF_B_TYPE;break;
         case 7: s->pict_type= FF_I_TYPE;break; //ZYGO
         default:
@@ -5213,6 +5250,13 @@
     s->mb_height = (s->height  + 15) / 16;
     s->mb_num = s->mb_width * s->mb_height;
 
+    if (s->pb_frame) {
+        skip_bits(&s->gb, 3); /* Temporal reference for B-pictures */
+        if (s->custom_pcf)
+            skip_bits(&s->gb, 2); //extended Temporal reference
+        skip_bits(&s->gb, 2); /* Quantization information for B-pictures */
+    }
+
     /* PEI */
     while (get_bits1(&s->gb) != 0) {
         skip_bits(&s->gb, 8);
@@ -6255,10 +6299,6 @@
     if(s->avctx->debug&FF_DEBUG_PICT_INFO)
         show_pict_info(s);
 
-    if(s->pb_frame){
-        av_log(s->avctx, AV_LOG_ERROR, "PB frame mode no supported\n");
-        return -1;      /* PB frame mode */
-    }
     return 0;
 }
 
diff --git a/libavcodec/h263_parser.c b/libavcodec/h263_parser.c
old mode 100644
new mode 100755
diff --git a/libavcodec/h263data.h b/libavcodec/h263data.h
old mode 100644
new mode 100755
diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
old mode 100644
new mode 100755
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 48c8028..a7ab3ae 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -3269,7 +3269,7 @@
  */
 static int execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){
     MpegEncContext * const s = &h->s;
-    int i, j;
+    int i, av_uninit(j);
     int current_ref_assigned=0;
     Picture *av_uninit(pic);
 
@@ -3277,7 +3277,7 @@
         av_log(h->s.avctx, AV_LOG_DEBUG, "no mmco here\n");
 
     for(i=0; i<mmco_count; i++){
-        int structure, av_uninit(frame_num);
+        int av_uninit(structure), av_uninit(frame_num);
         if(s->avctx->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);
 
@@ -3708,13 +3708,13 @@
         return -1;
     }
     if(!h0->pps_buffers[pps_id]) {
-        av_log(h->s.avctx, AV_LOG_ERROR, "non-existing PPS referenced\n");
+        av_log(h->s.avctx, AV_LOG_ERROR, "non-existing PPS %u referenced\n", pps_id);
         return -1;
     }
     h->pps= *h0->pps_buffers[pps_id];
 
     if(!h0->sps_buffers[h->pps.sps_id]) {
-        av_log(h->s.avctx, AV_LOG_ERROR, "non-existing SPS referenced\n");
+        av_log(h->s.avctx, AV_LOG_ERROR, "non-existing SPS %u referenced\n", h->pps.sps_id);
         return -1;
     }
     h->sps = *h0->sps_buffers[h->pps.sps_id];
@@ -4190,17 +4190,16 @@
             //first coefficient has suffix_length equal to 0 or 1
             if(prefix<14){ //FIXME try to build a large unified VLC table for all this
                 if(suffix_length)
-                    level_code= (prefix<<suffix_length) + get_bits(gb, suffix_length); //part
+                    level_code= (prefix<<1) + get_bits1(gb); //part
                 else
-                    level_code= (prefix<<suffix_length); //part
+                    level_code= prefix; //part
             }else if(prefix==14){
                 if(suffix_length)
-                    level_code= (prefix<<suffix_length) + get_bits(gb, suffix_length); //part
+                    level_code= (prefix<<1) + get_bits1(gb); //part
                 else
                     level_code= prefix + get_bits(gb, 4); //part
             }else{
-                level_code= (15<<suffix_length) + get_bits(gb, prefix-3); //part
-                if(suffix_length==0) level_code+=15; //FIXME doesn't make (much)sense
+                level_code= 30 + get_bits(gb, prefix-3); //part
                 if(prefix>=16)
                     level_code += (1<<(prefix-3))-4096;
             }
@@ -6497,7 +6496,7 @@
         int qp = s->current_picture.qscale_table[mb_xy];
         if(qp <= qp_thresh
            && (mb_x == 0 || ((qp + s->current_picture.qscale_table[mb_xy-1] + 1)>>1) <= qp_thresh)
-           && (mb_y == 0 || ((qp + s->current_picture.qscale_table[h->top_mb_xy] + 1)>>1) <= qp_thresh)){
+           && (h->top_mb_xy < 0 || ((qp + s->current_picture.qscale_table[h->top_mb_xy] + 1)>>1) <= qp_thresh)){
             return;
         }
     }
@@ -6799,6 +6798,7 @@
     if(h->sps.pic_struct_present_flag){
         unsigned int i, num_clock_ts;
         h->sei_pic_struct = get_bits(&s->gb, 4);
+        h->sei_ct_type    = 0;
 
         if (h->sei_pic_struct > SEI_PIC_STRUCT_FRAME_TRIPLING)
             return -1;
@@ -6808,7 +6808,7 @@
         for (i = 0 ; i < num_clock_ts ; i++){
             if(get_bits(&s->gb, 1)){                  /* clock_timestamp_flag */
                 unsigned int full_timestamp_flag;
-                skip_bits(&s->gb, 2);                 /* ct_type */
+                h->sei_ct_type |= 1<<get_bits(&s->gb, 2);
                 skip_bits(&s->gb, 1);                 /* nuit_field_based_flag */
                 skip_bits(&s->gb, 5);                 /* counting_type */
                 full_timestamp_flag = get_bits(&s->gb, 1);
@@ -6960,7 +6960,7 @@
     get_bits(&s->gb, 4); /* bit_rate_scale */
     get_bits(&s->gb, 4); /* cpb_size_scale */
     for(i=0; i<cpb_count; i++){
-        get_ue_golomb(&s->gb); /* bit_rate_value_minus1 */
+		get_ue_golomb(&s->gb); /* bit_rate_value_minus1 */
         get_ue_golomb(&s->gb); /* cpb_size_value_minus1 */
         get_bits1(&s->gb);     /* cbr_flag */
     }
@@ -7172,7 +7172,7 @@
     }
 
     sps->ref_frame_count= get_ue_golomb_31(&s->gb);
-    if(sps->ref_frame_count > MAX_PICTURE_COUNT-2 || sps->ref_frame_count > 16U){
+    if(sps->ref_frame_count > MAX_PICTURE_COUNT-2 || sps->ref_frame_count >= 32U){
         av_log(h->s.avctx, AV_LOG_ERROR, "too many reference frames\n");
         goto fail;
     }
@@ -7221,7 +7221,7 @@
         decode_vui_parameters(h, sps);
 
     if(s->avctx->debug&FF_DEBUG_PICT_INFO){
-        av_log(h->s.avctx, AV_LOG_DEBUG, "sps:%u profile:%d/%d poc:%d ref:%d %dx%d %s %s crop:%d/%d/%d/%d %s %s\n",
+        av_log(h->s.avctx, AV_LOG_DEBUG, "sps:%u profile:%d/%d poc:%d ref:%d %dx%d %s %s crop:%d/%d/%d/%d %s %s %d/%d\n",
                sps_id, sps->profile_idc, sps->level_idc,
                sps->poc_type,
                sps->ref_frame_count,
@@ -7231,7 +7231,9 @@
                sps->crop_left, sps->crop_right,
                sps->crop_top, sps->crop_bottom,
                sps->vui_parameters_present_flag ? "VUI" : "",
-               ((const char*[]){"Gray","420","422","444"})[sps->chroma_format_idc]
+               ((const char*[]){"Gray","420","422","444"})[sps->chroma_format_idc],
+               sps->timing_info_present_flag ? sps->num_units_in_tick : 0,
+               sps->timing_info_present_flag ? sps->time_scale : 0
                );
     }
 
@@ -7422,6 +7424,7 @@
         av_log(NULL, AV_LOG_ERROR,"%02X ", buf[i]);
     }
 #endif
+	
     if(!(s->flags2 & CODEC_FLAG2_CHUNKS)){
         h->current_slice = 0;
         if (!s->first_field)
@@ -7771,27 +7774,21 @@
 
         } else {
             cur->repeat_pict = 0;
-
             /* Signal interlacing information externally. */
             /* Prioritize picture timing SEI information over used decoding process if it exists. */
+            if (h->sei_ct_type)
+                cur->interlaced_frame = (h->sei_ct_type & (1<<1)) != 0;
+            else
+                cur->interlaced_frame = FIELD_OR_MBAFF_PICTURE;
+
             if(h->sps.pic_struct_present_flag){
                 switch (h->sei_pic_struct)
                 {
-                case SEI_PIC_STRUCT_FRAME:
-                    cur->interlaced_frame = 0;
-                    break;
-                case SEI_PIC_STRUCT_TOP_FIELD:
-                case SEI_PIC_STRUCT_BOTTOM_FIELD:
-                case SEI_PIC_STRUCT_TOP_BOTTOM:
-                case SEI_PIC_STRUCT_BOTTOM_TOP:
-                    cur->interlaced_frame = 1;
-                    break;
                 case SEI_PIC_STRUCT_TOP_BOTTOM_TOP:
                 case SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM:
                     // Signal the possibility of telecined film externally (pic_struct 5,6)
                     // From these hints, let the applications decide if they apply deinterlacing.
                     cur->repeat_pict = 1;
-                    cur->interlaced_frame = FIELD_OR_MBAFF_PICTURE;
                     break;
                 case SEI_PIC_STRUCT_FRAME_DOUBLING:
                     // Force progressive here, as doubling interlaced frame is a bad idea.
@@ -7890,7 +7887,14 @@
 
     assert(pict->data[0] || !*data_size);
     ff_print_debug_info(s, pict);
-//printf("out %d\n", (int)pict->data[0]);
+
+#if 0
+#undef printf
+if(pict->data[0]) printf("out %p, type %d, pts %lld, cpn %d, dpn %d, reference %d, repeat_pict %d, interlaced %d (s->picture_number = %d)\n", pict->data[0],
+		pict->pict_type, pict->pts, pict->coded_picture_number, pict->display_picture_number, pict->reference, pict->repeat_pict, pict->interlaced_frame,
+		s->picture_number
+	);
+#endif
 #if 0 //?
 
     /* Return the Picture timestamp as the frame number */
diff --git a/libavcodec/h264.h b/libavcodec/h264.h
old mode 100644
new mode 100755
index 587f1e3..fc9cef5
--- a/libavcodec/h264.h
+++ b/libavcodec/h264.h
@@ -504,6 +504,13 @@
     SEI_PicStructType sei_pic_struct;
 
     /**
+     * Bit set of clock types for fields/frames in picture timing SEI message.
+     * For each found ct_type, appropriate bit is set (e.g., bit 1 for
+     * interlaced).
+     */
+    int sei_ct_type;
+
+    /**
      * dpb_output_delay in picture timing SEI message, see H.264 C.2.2
      */
     int sei_dpb_output_delay;
diff --git a/libavcodec/h264_parser.c b/libavcodec/h264_parser.c
old mode 100644
new mode 100755
index 39433bb..4f64318
--- a/libavcodec/h264_parser.c
+++ b/libavcodec/h264_parser.c
@@ -70,7 +70,7 @@
             else            state>>=1; //2->1, 1->0, 0->0
         }else if(state<=5){
             int v= buf[i] & 0x1F;
-            if(v==7 || v==8 || v==9){
+            if(v==6 || v==7 || v==8 || v==9){
                 if(pc->frame_start_found){
                     i++;
                     goto found;
@@ -120,6 +120,7 @@
     /* set some sane default values */
     s->pict_type = FF_I_TYPE;
     s->key_frame = 0;
+	s->field_frame_flag = 0;
 
     h->s.avctx= avctx;
     h->sei_recovery_frame_cnt = -1;
@@ -190,6 +191,11 @@
             }else{
                 if(get_bits1(&h->s.gb)) { //field_pic_flag
                     h->s.picture_structure= PICT_TOP_FIELD + get_bits1(&h->s.gb); //bottom_field_flag
+					// STV: at least one interlaced frame will mark the stream as interlaced
+					if (!avctx->interlaced) {
+//						av_log(NULL, AV_LOG_INFO, "setting codec interlaced flag!!!\n");
+						avctx->interlaced = 1;
+					}
                 } else {
                     h->s.picture_structure= PICT_FRAME;
                 }
@@ -200,6 +206,7 @@
                     case SEI_PIC_STRUCT_TOP_FIELD:
                     case SEI_PIC_STRUCT_BOTTOM_FIELD:
                         s->repeat_pict = 0;
+						s->field_frame_flag = 1;
                         break;
                     case SEI_PIC_STRUCT_FRAME:
                     case SEI_PIC_STRUCT_TOP_BOTTOM:
@@ -222,6 +229,7 @@
                 }
             } else {
                 s->repeat_pict = h->s.picture_structure == PICT_FRAME ? 1 : 0;
+				s->field_frame_flag = !s->repeat_pict;
             }
 
             return 0; /* no need to evaluate the rest */
diff --git a/libavcodec/h264_parser.h b/libavcodec/h264_parser.h
old mode 100644
new mode 100755
diff --git a/libavcodec/h264data.h b/libavcodec/h264data.h
old mode 100644
new mode 100755
diff --git a/libavcodec/h264idct.c b/libavcodec/h264idct.c
old mode 100644
new mode 100755
diff --git a/libavcodec/h264pred.h b/libavcodec/h264pred.h
old mode 100644
new mode 100755
diff --git a/libavcodec/huffman.c b/libavcodec/huffman.c
old mode 100644
new mode 100755
diff --git a/libavcodec/huffyuv.c b/libavcodec/huffyuv.c
old mode 100644
new mode 100755
index dfa06d5..242589f
--- a/libavcodec/huffyuv.c
+++ b/libavcodec/huffyuv.c
@@ -738,7 +738,7 @@
         READ_2PIX(s->temp[0][2*i  ], s->temp[1][i], 1);
         READ_2PIX(s->temp[0][2*i+1], s->temp[2][i], 2);
     }
-    }
+}
 }
 
 static void decode_gray_bitstream(HYuvContext *s, int count){
diff --git a/libavcodec/idcinvideo.c b/libavcodec/idcinvideo.c
old mode 100644
new mode 100755
diff --git a/libavcodec/imgconvert.c b/libavcodec/imgconvert.c
old mode 100644
new mode 100755
index 1e0c66d..c48e938
--- a/libavcodec/imgconvert.c
+++ b/libavcodec/imgconvert.c
@@ -192,8 +192,8 @@
         .depth = 8,
         .x_chroma_shift = 0, .y_chroma_shift = 0,
     },
-    [PIX_FMT_RGB32] = {
-        .name = "rgb32",
+    [PIX_FMT_ARGB] = {
+        .name = "argb",
         .nb_channels = 4, .is_alpha = 1,
         .color_type = FF_COLOR_RGB,
         .pixel_type = FF_PIXEL_PACKED,
@@ -216,16 +216,32 @@
         .depth = 16,
         .x_chroma_shift = 0, .y_chroma_shift = 0,
     },
-    [PIX_FMT_RGB565] = {
-        .name = "rgb565",
+    [PIX_FMT_RGB565BE] = {
+        .name = "rgb565be",
         .nb_channels = 3,
         .color_type = FF_COLOR_RGB,
         .pixel_type = FF_PIXEL_PACKED,
         .depth = 5,
         .x_chroma_shift = 0, .y_chroma_shift = 0,
     },
-    [PIX_FMT_RGB555] = {
-        .name = "rgb555",
+    [PIX_FMT_RGB565LE] = {
+        .name = "rgb565le",
+        .nb_channels = 3,
+        .color_type = FF_COLOR_RGB,
+        .pixel_type = FF_PIXEL_PACKED,
+        .depth = 5,
+        .x_chroma_shift = 0, .y_chroma_shift = 0,
+    },
+    [PIX_FMT_RGB555BE] = {
+        .name = "rgb555be",
+        .nb_channels = 3,
+        .color_type = FF_COLOR_RGB,
+        .pixel_type = FF_PIXEL_PACKED,
+        .depth = 5,
+        .x_chroma_shift = 0, .y_chroma_shift = 0,
+    },
+    [PIX_FMT_RGB555LE] = {
+        .name = "rgb555le",
         .nb_channels = 3,
         .color_type = FF_COLOR_RGB,
         .pixel_type = FF_PIXEL_PACKED,
@@ -289,22 +305,27 @@
     [PIX_FMT_VDPAU_MPEG1] = {
         .name = "vdpau_mpeg1",
         .is_hwaccel = 1,
+        .x_chroma_shift = 1, .y_chroma_shift = 1,
     },
     [PIX_FMT_VDPAU_MPEG2] = {
         .name = "vdpau_mpeg2",
         .is_hwaccel = 1,
+        .x_chroma_shift = 1, .y_chroma_shift = 1,
     },
     [PIX_FMT_VDPAU_H264] = {
         .name = "vdpau_h264",
         .is_hwaccel = 1,
+        .x_chroma_shift = 1, .y_chroma_shift = 1,
     },
     [PIX_FMT_VDPAU_WMV3] = {
         .name = "vdpau_wmv3",
         .is_hwaccel = 1,
+        .x_chroma_shift = 1, .y_chroma_shift = 1,
     },
     [PIX_FMT_VDPAU_VC1] = {
         .name = "vdpau_vc1",
         .is_hwaccel = 1,
+        .x_chroma_shift = 1, .y_chroma_shift = 1,
     },
     [PIX_FMT_UYYVYY411] = {
         .name = "uyyvyy411",
@@ -314,24 +335,40 @@
         .depth = 8,
         .x_chroma_shift = 2, .y_chroma_shift = 0,
     },
-    [PIX_FMT_BGR32] = {
-        .name = "bgr32",
+    [PIX_FMT_ABGR] = {
+        .name = "abgr",
         .nb_channels = 4, .is_alpha = 1,
         .color_type = FF_COLOR_RGB,
         .pixel_type = FF_PIXEL_PACKED,
         .depth = 8,
         .x_chroma_shift = 0, .y_chroma_shift = 0,
     },
-    [PIX_FMT_BGR565] = {
-        .name = "bgr565",
+    [PIX_FMT_BGR565BE] = {
+        .name = "bgr565be",
         .nb_channels = 3,
         .color_type = FF_COLOR_RGB,
         .pixel_type = FF_PIXEL_PACKED,
         .depth = 5,
         .x_chroma_shift = 0, .y_chroma_shift = 0,
     },
-    [PIX_FMT_BGR555] = {
-        .name = "bgr555",
+    [PIX_FMT_BGR565LE] = {
+        .name = "bgr565le",
+        .nb_channels = 3,
+        .color_type = FF_COLOR_RGB,
+        .pixel_type = FF_PIXEL_PACKED,
+        .depth = 5,
+        .x_chroma_shift = 0, .y_chroma_shift = 0,
+    },
+    [PIX_FMT_BGR555BE] = {
+        .name = "bgr555be",
+        .nb_channels = 3,
+        .color_type = FF_COLOR_RGB,
+        .pixel_type = FF_PIXEL_PACKED,
+        .depth = 5,
+        .x_chroma_shift = 0, .y_chroma_shift = 0,
+    },
+    [PIX_FMT_BGR555LE] = {
+        .name = "bgr555le",
         .nb_channels = 3,
         .color_type = FF_COLOR_RGB,
         .pixel_type = FF_PIXEL_PACKED,
@@ -403,16 +440,16 @@
         .x_chroma_shift = 1, .y_chroma_shift = 1,
     },
 
-    [PIX_FMT_BGR32_1] = {
-        .name = "bgr32_1",
+    [PIX_FMT_BGRA] = {
+        .name = "bgra",
         .nb_channels = 4, .is_alpha = 1,
         .color_type = FF_COLOR_RGB,
         .pixel_type = FF_PIXEL_PACKED,
         .depth = 8,
         .x_chroma_shift = 0, .y_chroma_shift = 0,
     },
-    [PIX_FMT_RGB32_1] = {
-        .name = "rgb32_1",
+    [PIX_FMT_RGBA] = {
+        .name = "rgba",
         .nb_channels = 4, .is_alpha = 1,
         .color_type = FF_COLOR_RGB,
         .pixel_type = FF_PIXEL_PACKED,
@@ -424,24 +461,27 @@
     [PIX_FMT_VAAPI_MOCO] = {
         .name = "vaapi_moco",
         .is_hwaccel = 1,
+        .x_chroma_shift = 1, .y_chroma_shift = 1,
     },
     [PIX_FMT_VAAPI_IDCT] = {
         .name = "vaapi_idct",
         .is_hwaccel = 1,
+        .x_chroma_shift = 1, .y_chroma_shift = 1,
     },
     [PIX_FMT_VAAPI_VLD] = {
         .name = "vaapi_vld",
         .is_hwaccel = 1,
+        .x_chroma_shift = 1, .y_chroma_shift = 1,
     },
 };
 
-void avcodec_get_chroma_sub_sample(int pix_fmt, int *h_shift, int *v_shift)
+void avcodec_get_chroma_sub_sample(enum PixelFormat pix_fmt, int *h_shift, int *v_shift)
 {
     *h_shift = pix_fmt_info[pix_fmt].x_chroma_shift;
     *v_shift = pix_fmt_info[pix_fmt].y_chroma_shift;
 }
 
-const char *avcodec_get_pix_fmt_name(int pix_fmt)
+const char *avcodec_get_pix_fmt_name(enum PixelFormat pix_fmt)
 {
     if (pix_fmt < 0 || pix_fmt >= PIX_FMT_NB)
         return NULL;
@@ -449,7 +489,7 @@
         return pix_fmt_info[pix_fmt].name;
 }
 
-enum PixelFormat avcodec_get_pix_fmt(const char* name)
+static enum PixelFormat avcodec_get_pix_fmt_internal(const char *name)
 {
     int i;
 
@@ -459,7 +499,31 @@
     return PIX_FMT_NONE;
 }
 
-void avcodec_pix_fmt_string (char *buf, int buf_size, int pix_fmt)
+#ifdef WORDS_BIGENDIAN
+#   define X_NE(be, le) be
+#else
+#   define X_NE(be, le) le
+#endif
+
+enum PixelFormat avcodec_get_pix_fmt(const char *name)
+{
+    enum PixelFormat pix_fmt;
+
+    if (!strcmp(name, "rgb32"))
+        name = X_NE("argb", "bgra");
+    else if (!strcmp(name, "bgr32"))
+        name = X_NE("abgr", "rgba");
+
+    pix_fmt = avcodec_get_pix_fmt_internal(name);
+    if (pix_fmt == PIX_FMT_NONE) {
+        char name2[32];
+        snprintf(name2, sizeof(name2), "%s%s", name, X_NE("be", "le"));
+        pix_fmt = avcodec_get_pix_fmt_internal(name2);
+    }
+    return pix_fmt;
+}
+
+void avcodec_pix_fmt_string (char *buf, int buf_size, enum PixelFormat pix_fmt)
 {
     /* print header */
     if (pix_fmt < 0)
@@ -525,7 +589,7 @@
     return 0;
 }
 
-int ff_fill_linesize(AVPicture *picture, int pix_fmt, int width)
+int ff_fill_linesize(AVPicture *picture, enum PixelFormat pix_fmt, int width)
 {
     int w2;
     const PixFmtInfo *pinfo;
@@ -566,10 +630,10 @@
     case PIX_FMT_BGR24:
         picture->linesize[0] = width * 3;
         break;
-    case PIX_FMT_RGB32:
-    case PIX_FMT_BGR32:
-    case PIX_FMT_RGB32_1:
-    case PIX_FMT_BGR32_1:
+    case PIX_FMT_ARGB:
+    case PIX_FMT_ABGR:
+    case PIX_FMT_RGBA:
+    case PIX_FMT_BGRA:
         picture->linesize[0] = width * 4;
         break;
     case PIX_FMT_RGB48BE:
@@ -614,7 +678,7 @@
     return 0;
 }
 
-int ff_fill_pointer(AVPicture *picture, uint8_t *ptr, int pix_fmt,
+int ff_fill_pointer(AVPicture *picture, uint8_t *ptr, enum PixelFormat pix_fmt,
                     int height)
 {
     int size, h2, size2;
@@ -659,10 +723,10 @@
         return size + 2 * size2;
     case PIX_FMT_RGB24:
     case PIX_FMT_BGR24:
-    case PIX_FMT_RGB32:
-    case PIX_FMT_BGR32:
-    case PIX_FMT_RGB32_1:
-    case PIX_FMT_BGR32_1:
+    case PIX_FMT_ARGB:
+    case PIX_FMT_ABGR:
+    case PIX_FMT_RGBA:
+    case PIX_FMT_BGRA:
     case PIX_FMT_RGB48BE:
     case PIX_FMT_RGB48LE:
     case PIX_FMT_GRAY16BE:
@@ -705,7 +769,7 @@
 }
 
 int avpicture_fill(AVPicture *picture, uint8_t *ptr,
-                   int pix_fmt, int width, int height)
+                   enum PixelFormat pix_fmt, int width, int height)
 {
 
     if(avcodec_check_dimensions(NULL, width, height))
@@ -717,7 +781,7 @@
     return ff_fill_pointer(picture, ptr, pix_fmt, height);
 }
 
-int avpicture_layout(const AVPicture* src, int pix_fmt, int width, int height,
+int avpicture_layout(const AVPicture* src, enum PixelFormat pix_fmt, int width, int height,
                      unsigned char *dest, int dest_size)
 {
     const PixFmtInfo* pf = &pix_fmt_info[pix_fmt];
@@ -776,13 +840,24 @@
     return size;
 }
 
-int avpicture_get_size(int pix_fmt, int width, int height)
+int avpicture_get_size(enum PixelFormat pix_fmt, int width, int height)
 {
     AVPicture dummy_pict;
+    if(avcodec_check_dimensions(NULL, width, height))
+        return -1;
+    switch (pix_fmt) {
+    case PIX_FMT_RGB8:
+    case PIX_FMT_BGR8:
+    case PIX_FMT_RGB4_BYTE:
+    case PIX_FMT_BGR4_BYTE:
+    case PIX_FMT_GRAY8:
+        // do not include palette for these pseudo-paletted formats
+        return width * height;
+    }
     return avpicture_fill(&dummy_pict, NULL, pix_fmt, width, height);
 }
 
-int avcodec_get_pix_fmt_loss(int dst_pix_fmt, int src_pix_fmt,
+int avcodec_get_pix_fmt_loss(enum PixelFormat dst_pix_fmt, enum PixelFormat src_pix_fmt,
                              int has_alpha)
 {
     const PixFmtInfo *pf, *ps;
@@ -837,7 +912,7 @@
     return loss;
 }
 
-static int avg_bits_per_pixel(int pix_fmt)
+static int avg_bits_per_pixel(enum PixelFormat pix_fmt)
 {
     int bits;
     const PixFmtInfo *pf;
@@ -880,12 +955,13 @@
     return bits;
 }
 
-static int avcodec_find_best_pix_fmt1(int64_t pix_fmt_mask,
-                                      int src_pix_fmt,
+static enum PixelFormat avcodec_find_best_pix_fmt1(int64_t pix_fmt_mask,
+                                      enum PixelFormat src_pix_fmt,
                                       int has_alpha,
                                       int loss_mask)
 {
-    int dist, i, loss, min_dist, dst_pix_fmt;
+    int dist, i, loss, min_dist;
+    enum PixelFormat dst_pix_fmt;
 
     /* find exact color match with smallest size */
     dst_pix_fmt = -1;
@@ -905,10 +981,11 @@
     return dst_pix_fmt;
 }
 
-int avcodec_find_best_pix_fmt(int64_t pix_fmt_mask, int src_pix_fmt,
+enum PixelFormat avcodec_find_best_pix_fmt(int64_t pix_fmt_mask, enum PixelFormat src_pix_fmt,
                               int has_alpha, int *loss_ptr)
 {
-    int dst_pix_fmt, loss_mask, i;
+    enum PixelFormat dst_pix_fmt;
+    int loss_mask, i;
     static const int loss_mask_order[] = {
         ~0, /* no loss first */
         ~FF_LOSS_ALPHA,
@@ -992,7 +1069,7 @@
 }
 
 void av_picture_copy(AVPicture *dst, const AVPicture *src,
-              int pix_fmt, int width, int height)
+                     enum PixelFormat pix_fmt, int width, int height)
 {
     int i;
     const PixFmtInfo *pf = &pix_fmt_info[pix_fmt];
@@ -1025,357 +1102,6 @@
     }
 }
 
-/* XXX: totally non optimized */
-
-static void yuyv422_to_yuv420p(AVPicture *dst, const AVPicture *src,
-                              int width, int height)
-{
-    const uint8_t *p, *p1;
-    uint8_t *lum, *cr, *cb, *lum1, *cr1, *cb1;
-    int w;
-
-    p1 = src->data[0];
-    lum1 = dst->data[0];
-    cb1 = dst->data[1];
-    cr1 = dst->data[2];
-
-    for(;height >= 1; height -= 2) {
-        p = p1;
-        lum = lum1;
-        cb = cb1;
-        cr = cr1;
-        for(w = width; w >= 2; w -= 2) {
-            lum[0] = p[0];
-            cb[0] = p[1];
-            lum[1] = p[2];
-            cr[0] = p[3];
-            p += 4;
-            lum += 2;
-            cb++;
-            cr++;
-        }
-        if (w) {
-            lum[0] = p[0];
-            cb[0] = p[1];
-            cr[0] = p[3];
-            cb++;
-            cr++;
-        }
-        p1 += src->linesize[0];
-        lum1 += dst->linesize[0];
-        if (height>1) {
-            p = p1;
-            lum = lum1;
-            for(w = width; w >= 2; w -= 2) {
-                lum[0] = p[0];
-                lum[1] = p[2];
-                p += 4;
-                lum += 2;
-            }
-            if (w) {
-                lum[0] = p[0];
-            }
-            p1 += src->linesize[0];
-            lum1 += dst->linesize[0];
-        }
-        cb1 += dst->linesize[1];
-        cr1 += dst->linesize[2];
-    }
-}
-
-static void uyvy422_to_yuv420p(AVPicture *dst, const AVPicture *src,
-                              int width, int height)
-{
-    const uint8_t *p, *p1;
-    uint8_t *lum, *cr, *cb, *lum1, *cr1, *cb1;
-    int w;
-
-    p1 = src->data[0];
-
-    lum1 = dst->data[0];
-    cb1 = dst->data[1];
-    cr1 = dst->data[2];
-
-    for(;height >= 1; height -= 2) {
-        p = p1;
-        lum = lum1;
-        cb = cb1;
-        cr = cr1;
-        for(w = width; w >= 2; w -= 2) {
-            lum[0] = p[1];
-            cb[0] = p[0];
-            lum[1] = p[3];
-            cr[0] = p[2];
-            p += 4;
-            lum += 2;
-            cb++;
-            cr++;
-        }
-        if (w) {
-            lum[0] = p[1];
-            cb[0] = p[0];
-            cr[0] = p[2];
-            cb++;
-            cr++;
-        }
-        p1 += src->linesize[0];
-        lum1 += dst->linesize[0];
-        if (height>1) {
-            p = p1;
-            lum = lum1;
-            for(w = width; w >= 2; w -= 2) {
-                lum[0] = p[1];
-                lum[1] = p[3];
-                p += 4;
-                lum += 2;
-            }
-            if (w) {
-                lum[0] = p[1];
-            }
-            p1 += src->linesize[0];
-            lum1 += dst->linesize[0];
-        }
-        cb1 += dst->linesize[1];
-        cr1 += dst->linesize[2];
-    }
-}
-
-
-static void uyvy422_to_yuv422p(AVPicture *dst, const AVPicture *src,
-                              int width, int height)
-{
-    const uint8_t *p, *p1;
-    uint8_t *lum, *cr, *cb, *lum1, *cr1, *cb1;
-    int w;
-
-    p1 = src->data[0];
-    lum1 = dst->data[0];
-    cb1 = dst->data[1];
-    cr1 = dst->data[2];
-    for(;height > 0; height--) {
-        p = p1;
-        lum = lum1;
-        cb = cb1;
-        cr = cr1;
-        for(w = width; w >= 2; w -= 2) {
-            lum[0] = p[1];
-            cb[0] = p[0];
-            lum[1] = p[3];
-            cr[0] = p[2];
-            p += 4;
-            lum += 2;
-            cb++;
-            cr++;
-        }
-        p1 += src->linesize[0];
-        lum1 += dst->linesize[0];
-        cb1 += dst->linesize[1];
-        cr1 += dst->linesize[2];
-    }
-}
-
-
-static void yuyv422_to_yuv422p(AVPicture *dst, const AVPicture *src,
-                              int width, int height)
-{
-    const uint8_t *p, *p1;
-    uint8_t *lum, *cr, *cb, *lum1, *cr1, *cb1;
-    int w;
-
-    p1 = src->data[0];
-    lum1 = dst->data[0];
-    cb1 = dst->data[1];
-    cr1 = dst->data[2];
-    for(;height > 0; height--) {
-        p = p1;
-        lum = lum1;
-        cb = cb1;
-        cr = cr1;
-        for(w = width; w >= 2; w -= 2) {
-            lum[0] = p[0];
-            cb[0] = p[1];
-            lum[1] = p[2];
-            cr[0] = p[3];
-            p += 4;
-            lum += 2;
-            cb++;
-            cr++;
-        }
-        p1 += src->linesize[0];
-        lum1 += dst->linesize[0];
-        cb1 += dst->linesize[1];
-        cr1 += dst->linesize[2];
-    }
-}
-
-static void yuv422p_to_yuyv422(AVPicture *dst, const AVPicture *src,
-                              int width, int height)
-{
-    uint8_t *p, *p1;
-    const uint8_t *lum, *cr, *cb, *lum1, *cr1, *cb1;
-    int w;
-
-    p1 = dst->data[0];
-    lum1 = src->data[0];
-    cb1 = src->data[1];
-    cr1 = src->data[2];
-    for(;height > 0; height--) {
-        p = p1;
-        lum = lum1;
-        cb = cb1;
-        cr = cr1;
-        for(w = width; w >= 2; w -= 2) {
-            p[0] = lum[0];
-            p[1] = cb[0];
-            p[2] = lum[1];
-            p[3] = cr[0];
-            p += 4;
-            lum += 2;
-            cb++;
-            cr++;
-        }
-        p1 += dst->linesize[0];
-        lum1 += src->linesize[0];
-        cb1 += src->linesize[1];
-        cr1 += src->linesize[2];
-    }
-}
-
-static void yuv422p_to_uyvy422(AVPicture *dst, const AVPicture *src,
-                              int width, int height)
-{
-    uint8_t *p, *p1;
-    const uint8_t *lum, *cr, *cb, *lum1, *cr1, *cb1;
-    int w;
-
-    p1 = dst->data[0];
-    lum1 = src->data[0];
-    cb1 = src->data[1];
-    cr1 = src->data[2];
-    for(;height > 0; height--) {
-        p = p1;
-        lum = lum1;
-        cb = cb1;
-        cr = cr1;
-        for(w = width; w >= 2; w -= 2) {
-            p[1] = lum[0];
-            p[0] = cb[0];
-            p[3] = lum[1];
-            p[2] = cr[0];
-            p += 4;
-            lum += 2;
-            cb++;
-            cr++;
-        }
-        p1 += dst->linesize[0];
-        lum1 += src->linesize[0];
-        cb1 += src->linesize[1];
-        cr1 += src->linesize[2];
-    }
-}
-
-static void uyyvyy411_to_yuv411p(AVPicture *dst, const AVPicture *src,
-                              int width, int height)
-{
-    const uint8_t *p, *p1;
-    uint8_t *lum, *cr, *cb, *lum1, *cr1, *cb1;
-    int w;
-
-    p1 = src->data[0];
-    lum1 = dst->data[0];
-    cb1 = dst->data[1];
-    cr1 = dst->data[2];
-    for(;height > 0; height--) {
-        p = p1;
-        lum = lum1;
-        cb = cb1;
-        cr = cr1;
-        for(w = width; w >= 4; w -= 4) {
-            cb[0] = p[0];
-            lum[0] = p[1];
-            lum[1] = p[2];
-            cr[0] = p[3];
-            lum[2] = p[4];
-            lum[3] = p[5];
-            p += 6;
-            lum += 4;
-            cb++;
-            cr++;
-        }
-        p1 += src->linesize[0];
-        lum1 += dst->linesize[0];
-        cb1 += dst->linesize[1];
-        cr1 += dst->linesize[2];
-    }
-}
-
-
-static void yuv420p_to_yuyv422(AVPicture *dst, const AVPicture *src,
-                              int width, int height)
-{
-    int w, h;
-    uint8_t *line1, *line2, *linesrc = dst->data[0];
-    uint8_t *lum1, *lum2, *lumsrc = src->data[0];
-    uint8_t *cb1, *cb2 = src->data[1];
-    uint8_t *cr1, *cr2 = src->data[2];
-
-    for(h = height / 2; h--;) {
-        line1 = linesrc;
-        line2 = linesrc + dst->linesize[0];
-
-        lum1 = lumsrc;
-        lum2 = lumsrc + src->linesize[0];
-
-        cb1 = cb2;
-        cr1 = cr2;
-
-        for(w = width / 2; w--;) {
-                *line1++ = *lum1++; *line2++ = *lum2++;
-                *line1++ =          *line2++ = *cb1++;
-                *line1++ = *lum1++; *line2++ = *lum2++;
-                *line1++ =          *line2++ = *cr1++;
-        }
-
-        linesrc += dst->linesize[0] * 2;
-        lumsrc += src->linesize[0] * 2;
-        cb2 += src->linesize[1];
-        cr2 += src->linesize[2];
-    }
-}
-
-static void yuv420p_to_uyvy422(AVPicture *dst, const AVPicture *src,
-                              int width, int height)
-{
-    int w, h;
-    uint8_t *line1, *line2, *linesrc = dst->data[0];
-    uint8_t *lum1, *lum2, *lumsrc = src->data[0];
-    uint8_t *cb1, *cb2 = src->data[1];
-    uint8_t *cr1, *cr2 = src->data[2];
-
-    for(h = height / 2; h--;) {
-        line1 = linesrc;
-        line2 = linesrc + dst->linesize[0];
-
-        lum1 = lumsrc;
-        lum2 = lumsrc + src->linesize[0];
-
-        cb1 = cb2;
-        cr1 = cr2;
-
-        for(w = width / 2; w--;) {
-                *line1++ =          *line2++ = *cb1++;
-                *line1++ = *lum1++; *line2++ = *lum2++;
-                *line1++ =          *line2++ = *cr1++;
-                *line1++ = *lum1++; *line2++ = *lum2++;
-        }
-
-        linesrc += dst->linesize[0] * 2;
-        lumsrc += src->linesize[0] * 2;
-        cb2 += src->linesize[1];
-        cr2 += src->linesize[2];
-    }
-}
-
 /* 2x2 -> 1x1 */
 void ff_shrink22(uint8_t *dst, int dst_wrap,
                      const uint8_t *src, int src_wrap,
@@ -1462,630 +1188,14 @@
     }
 }
 
-/* XXX: add jpeg quantize code */
-
-#define TRANSP_INDEX (6*6*6)
-
-/* this is maybe slow, but allows for extensions */
-static inline unsigned char gif_clut_index(uint8_t r, uint8_t g, uint8_t b)
-{
-    return (((r) / 47) % 6) * 6 * 6 + (((g) / 47) % 6) * 6 + (((b) / 47) % 6);
-}
-
-static void build_rgb_palette(uint8_t *palette, int has_alpha)
-{
-    uint32_t *pal;
-    static const uint8_t pal_value[6] = { 0x00, 0x33, 0x66, 0x99, 0xcc, 0xff };
-    int i, r, g, b;
-
-    pal = (uint32_t *)palette;
-    i = 0;
-    for(r = 0; r < 6; r++) {
-        for(g = 0; g < 6; g++) {
-            for(b = 0; b < 6; b++) {
-                pal[i++] = (0xff << 24) | (pal_value[r] << 16) |
-                    (pal_value[g] << 8) | pal_value[b];
-            }
-        }
-    }
-    if (has_alpha)
-        pal[i++] = 0;
-    while (i < 256)
-        pal[i++] = 0xff000000;
-}
-
-/* copy bit n to bits 0 ... n - 1 */
-static inline unsigned int bitcopy_n(unsigned int a, int n)
-{
-    int mask;
-    mask = (1 << n) - 1;
-    return (a & (0xff & ~mask)) | ((-((a >> n) & 1)) & mask);
-}
-
-/* rgb555 handling */
-
-#define RGB_NAME rgb555
-
-#define RGB_IN(r, g, b, s)\
-{\
-    unsigned int v = ((const uint16_t *)(s))[0];\
-    r = bitcopy_n(v >> (10 - 3), 3);\
-    g = bitcopy_n(v >> (5 - 3), 3);\
-    b = bitcopy_n(v << 3, 3);\
-}
-
-
-#define RGB_OUT(d, r, g, b)\
-{\
-    ((uint16_t *)(d))[0] = ((r >> 3) << 10) | ((g >> 3) << 5) | (b >> 3);\
-}
-
-#define BPP 2
-
-#include "imgconvert_template.c"
-
-/* rgb565 handling */
-
-#define RGB_NAME rgb565
-
-#define RGB_IN(r, g, b, s)\
-{\
-    unsigned int v = ((const uint16_t *)(s))[0];\
-    r = bitcopy_n(v >> (11 - 3), 3);\
-    g = bitcopy_n(v >> (5 - 2), 2);\
-    b = bitcopy_n(v << 3, 3);\
-}
-
-#define RGB_OUT(d, r, g, b)\
-{\
-    ((uint16_t *)(d))[0] = ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3);\
-}
-
-#define BPP 2
-
-#include "imgconvert_template.c"
-
-/* bgr24 handling */
-
-#define RGB_NAME bgr24
-
-#define RGB_IN(r, g, b, s)\
-{\
-    b = (s)[0];\
-    g = (s)[1];\
-    r = (s)[2];\
-}
-
-#define RGB_OUT(d, r, g, b)\
-{\
-    (d)[0] = b;\
-    (d)[1] = g;\
-    (d)[2] = r;\
-}
-
-#define BPP 3
-
-#include "imgconvert_template.c"
-
-#undef RGB_IN
-#undef RGB_OUT
-#undef BPP
-
-/* rgb24 handling */
-
-#define RGB_NAME rgb24
-#define FMT_RGB24
-
-#define RGB_IN(r, g, b, s)\
-{\
-    r = (s)[0];\
-    g = (s)[1];\
-    b = (s)[2];\
-}
-
-#define RGB_OUT(d, r, g, b)\
-{\
-    (d)[0] = r;\
-    (d)[1] = g;\
-    (d)[2] = b;\
-}
-
-#define BPP 3
-
-#include "imgconvert_template.c"
-
-/* rgb32 handling */
-
-#define RGB_NAME rgb32
-#define FMT_RGB32
-
-#define RGB_IN(r, g, b, s)\
-{\
-    unsigned int v = ((const uint32_t *)(s))[0];\
-    r = (v >> 16) & 0xff;\
-    g = (v >> 8) & 0xff;\
-    b = v & 0xff;\
-}
-
-#define RGBA_IN(r, g, b, a, s)\
-{\
-    unsigned int v = ((const uint32_t *)(s))[0];\
-    a = (v >> 24) & 0xff;\
-    r = (v >> 16) & 0xff;\
-    g = (v >> 8) & 0xff;\
-    b = v & 0xff;\
-}
-
-#define RGBA_OUT(d, r, g, b, a)\
-{\
-    ((uint32_t *)(d))[0] = (a << 24) | (r << 16) | (g << 8) | b;\
-}
-
-#define BPP 4
-
-#include "imgconvert_template.c"
-
-static void mono_to_gray(AVPicture *dst, const AVPicture *src,
-                         int width, int height, int xor_mask)
-{
-    const unsigned char *p;
-    unsigned char *q;
-    int v, dst_wrap, src_wrap;
-    int y, w;
-
-    p = src->data[0];
-    src_wrap = src->linesize[0] - ((width + 7) >> 3);
-
-    q = dst->data[0];
-    dst_wrap = dst->linesize[0] - width;
-    for(y=0;y<height;y++) {
-        w = width;
-        while (w >= 8) {
-            v = *p++ ^ xor_mask;
-            q[0] = -(v >> 7);
-            q[1] = -((v >> 6) & 1);
-            q[2] = -((v >> 5) & 1);
-            q[3] = -((v >> 4) & 1);
-            q[4] = -((v >> 3) & 1);
-            q[5] = -((v >> 2) & 1);
-            q[6] = -((v >> 1) & 1);
-            q[7] = -((v >> 0) & 1);
-            w -= 8;
-            q += 8;
-        }
-        if (w > 0) {
-            v = *p++ ^ xor_mask;
-            do {
-                q[0] = -((v >> 7) & 1);
-                q++;
-                v <<= 1;
-            } while (--w);
-        }
-        p += src_wrap;
-        q += dst_wrap;
-    }
-}
-
-static void monowhite_to_gray(AVPicture *dst, const AVPicture *src,
-                               int width, int height)
-{
-    mono_to_gray(dst, src, width, height, 0xff);
-}
-
-static void monoblack_to_gray(AVPicture *dst, const AVPicture *src,
-                               int width, int height)
-{
-    mono_to_gray(dst, src, width, height, 0x00);
-}
-
-static void gray_to_mono(AVPicture *dst, const AVPicture *src,
-                         int width, int height, int xor_mask)
-{
-    int n;
-    const uint8_t *s;
-    uint8_t *d;
-    int j, b, v, n1, src_wrap, dst_wrap, y;
-
-    s = src->data[0];
-    src_wrap = src->linesize[0] - width;
-
-    d = dst->data[0];
-    dst_wrap = dst->linesize[0] - ((width + 7) >> 3);
-
-    for(y=0;y<height;y++) {
-        n = width;
-        while (n >= 8) {
-            v = 0;
-            for(j=0;j<8;j++) {
-                b = s[0];
-                s++;
-                v = (v << 1) | (b >> 7);
-            }
-            d[0] = v ^ xor_mask;
-            d++;
-            n -= 8;
-        }
-        if (n > 0) {
-            n1 = n;
-            v = 0;
-            while (n > 0) {
-                b = s[0];
-                s++;
-                v = (v << 1) | (b >> 7);
-                n--;
-            }
-            d[0] = (v << (8 - (n1 & 7))) ^ xor_mask;
-            d++;
-        }
-        s += src_wrap;
-        d += dst_wrap;
-    }
-}
-
-static void gray_to_monowhite(AVPicture *dst, const AVPicture *src,
-                              int width, int height)
-{
-    gray_to_mono(dst, src, width, height, 0xff);
-}
-
-static void gray_to_monoblack(AVPicture *dst, const AVPicture *src,
-                              int width, int height)
-{
-    gray_to_mono(dst, src, width, height, 0x00);
-}
-
-static void gray_to_gray16(AVPicture *dst, const AVPicture *src,
-                              int width, int height)
-{
-    int x, y, src_wrap, dst_wrap;
-    uint8_t *s, *d;
-    s = src->data[0];
-    src_wrap = src->linesize[0] - width;
-    d = dst->data[0];
-    dst_wrap = dst->linesize[0] - width * 2;
-    for(y=0; y<height; y++){
-        for(x=0; x<width; x++){
-            *d++ = *s;
-            *d++ = *s++;
-        }
-        s += src_wrap;
-        d += dst_wrap;
-    }
-}
-
-static void gray16_to_gray(AVPicture *dst, const AVPicture *src,
-                              int width, int height)
-{
-    int x, y, src_wrap, dst_wrap;
-    uint8_t *s, *d;
-    s = src->data[0];
-    src_wrap = src->linesize[0] - width * 2;
-    d = dst->data[0];
-    dst_wrap = dst->linesize[0] - width;
-    for(y=0; y<height; y++){
-        for(x=0; x<width; x++){
-            *d++ = *s;
-            s += 2;
-        }
-        s += src_wrap;
-        d += dst_wrap;
-    }
-}
-
-static void gray16be_to_gray(AVPicture *dst, const AVPicture *src,
-                              int width, int height)
-{
-    gray16_to_gray(dst, src, width, height);
-}
-
-static void gray16le_to_gray(AVPicture *dst, const AVPicture *src,
-                              int width, int height)
-{
-    AVPicture tmpsrc = *src;
-    tmpsrc.data[0]++;
-    gray16_to_gray(dst, &tmpsrc, width, height);
-}
-
-static void gray16_to_gray16(AVPicture *dst, const AVPicture *src,
-                              int width, int height)
-{
-    int x, y, src_wrap, dst_wrap;
-    uint16_t *s, *d;
-    s = (uint16_t*)src->data[0];
-    src_wrap = (src->linesize[0] - width * 2)/2;
-    d = (uint16_t*)dst->data[0];
-    dst_wrap = (dst->linesize[0] - width * 2)/2;
-    for(y=0; y<height; y++){
-        for(x=0; x<width; x++){
-            *d++ = bswap_16(*s++);
-        }
-        s += src_wrap;
-        d += dst_wrap;
-    }
-}
-
-
-typedef struct ConvertEntry {
-    void (*convert)(AVPicture *dst,
-                    const AVPicture *src, int width, int height);
-} ConvertEntry;
-
-/* Add each new conversion function in this table. In order to be able
-   to convert from any format to any format, the following constraints
-   must be satisfied:
-
-   - all FF_COLOR_RGB formats must convert to and from PIX_FMT_RGB24
-
-   - all FF_COLOR_GRAY formats must convert to and from PIX_FMT_GRAY8
-
-   - all FF_COLOR_RGB formats with alpha must convert to and from PIX_FMT_RGB32
-
-   - PIX_FMT_YUV444P and PIX_FMT_YUVJ444P must convert to and from
-     PIX_FMT_RGB24.
-
-   - PIX_FMT_422 must convert to and from PIX_FMT_422P.
-
-   The other conversion functions are just optimizations for common cases.
-*/
-static const ConvertEntry convert_table[PIX_FMT_NB][PIX_FMT_NB] = {
-    [PIX_FMT_YUV420P] = {
-        [PIX_FMT_YUYV422] = {
-            .convert = yuv420p_to_yuyv422,
-        },
-        [PIX_FMT_RGB555] = {
-            .convert = yuv420p_to_rgb555
-        },
-        [PIX_FMT_RGB565] = {
-            .convert = yuv420p_to_rgb565
-        },
-        [PIX_FMT_BGR24] = {
-            .convert = yuv420p_to_bgr24
-        },
-        [PIX_FMT_RGB24] = {
-            .convert = yuv420p_to_rgb24
-        },
-        [PIX_FMT_RGB32] = {
-            .convert = yuv420p_to_rgb32
-        },
-        [PIX_FMT_UYVY422] = {
-            .convert = yuv420p_to_uyvy422,
-        },
-    },
-    [PIX_FMT_YUV422P] = {
-        [PIX_FMT_YUYV422] = {
-            .convert = yuv422p_to_yuyv422,
-        },
-        [PIX_FMT_UYVY422] = {
-            .convert = yuv422p_to_uyvy422,
-        },
-    },
-    [PIX_FMT_YUV444P] = {
-        [PIX_FMT_RGB24] = {
-            .convert = yuv444p_to_rgb24
-        },
-    },
-    [PIX_FMT_YUVJ420P] = {
-        [PIX_FMT_RGB555] = {
-            .convert = yuvj420p_to_rgb555
-        },
-        [PIX_FMT_RGB565] = {
-            .convert = yuvj420p_to_rgb565
-        },
-        [PIX_FMT_BGR24] = {
-            .convert = yuvj420p_to_bgr24
-        },
-        [PIX_FMT_RGB24] = {
-            .convert = yuvj420p_to_rgb24
-        },
-        [PIX_FMT_RGB32] = {
-            .convert = yuvj420p_to_rgb32
-        },
-    },
-    [PIX_FMT_YUVJ444P] = {
-        [PIX_FMT_RGB24] = {
-            .convert = yuvj444p_to_rgb24
-        },
-    },
-    [PIX_FMT_YUYV422] = {
-        [PIX_FMT_YUV420P] = {
-            .convert = yuyv422_to_yuv420p,
-        },
-        [PIX_FMT_YUV422P] = {
-            .convert = yuyv422_to_yuv422p,
-        },
-    },
-    [PIX_FMT_UYVY422] = {
-        [PIX_FMT_YUV420P] = {
-            .convert = uyvy422_to_yuv420p,
-        },
-        [PIX_FMT_YUV422P] = {
-            .convert = uyvy422_to_yuv422p,
-        },
-    },
-    [PIX_FMT_RGB24] = {
-        [PIX_FMT_YUV420P] = {
-            .convert = rgb24_to_yuv420p
-        },
-        [PIX_FMT_RGB565] = {
-            .convert = rgb24_to_rgb565
-        },
-        [PIX_FMT_RGB555] = {
-            .convert = rgb24_to_rgb555
-        },
-        [PIX_FMT_RGB32] = {
-            .convert = rgb24_to_rgb32
-        },
-        [PIX_FMT_BGR24] = {
-            .convert = rgb24_to_bgr24
-        },
-        [PIX_FMT_GRAY8] = {
-            .convert = rgb24_to_gray
-        },
-        [PIX_FMT_PAL8] = {
-            .convert = rgb24_to_pal8
-        },
-        [PIX_FMT_YUV444P] = {
-            .convert = rgb24_to_yuv444p
-        },
-        [PIX_FMT_YUVJ420P] = {
-            .convert = rgb24_to_yuvj420p
-        },
-        [PIX_FMT_YUVJ444P] = {
-            .convert = rgb24_to_yuvj444p
-        },
-    },
-    [PIX_FMT_RGB32] = {
-        [PIX_FMT_RGB24] = {
-            .convert = rgb32_to_rgb24
-        },
-        [PIX_FMT_BGR24] = {
-            .convert = rgb32_to_bgr24
-        },
-        [PIX_FMT_RGB565] = {
-            .convert = rgb32_to_rgb565
-        },
-        [PIX_FMT_RGB555] = {
-            .convert = rgb32_to_rgb555
-        },
-        [PIX_FMT_PAL8] = {
-            .convert = rgb32_to_pal8
-        },
-        [PIX_FMT_YUV420P] = {
-            .convert = rgb32_to_yuv420p
-        },
-        [PIX_FMT_GRAY8] = {
-            .convert = rgb32_to_gray
-        },
-    },
-    [PIX_FMT_BGR24] = {
-        [PIX_FMT_RGB32] = {
-            .convert = bgr24_to_rgb32
-        },
-        [PIX_FMT_RGB24] = {
-            .convert = bgr24_to_rgb24
-        },
-        [PIX_FMT_YUV420P] = {
-            .convert = bgr24_to_yuv420p
-        },
-        [PIX_FMT_GRAY8] = {
-            .convert = bgr24_to_gray
-        },
-    },
-    [PIX_FMT_RGB555] = {
-        [PIX_FMT_RGB24] = {
-            .convert = rgb555_to_rgb24
-        },
-        [PIX_FMT_RGB32] = {
-            .convert = rgb555_to_rgb32
-        },
-        [PIX_FMT_YUV420P] = {
-            .convert = rgb555_to_yuv420p
-        },
-        [PIX_FMT_GRAY8] = {
-            .convert = rgb555_to_gray
-        },
-    },
-    [PIX_FMT_RGB565] = {
-        [PIX_FMT_RGB32] = {
-            .convert = rgb565_to_rgb32
-        },
-        [PIX_FMT_RGB24] = {
-            .convert = rgb565_to_rgb24
-        },
-        [PIX_FMT_YUV420P] = {
-            .convert = rgb565_to_yuv420p
-        },
-        [PIX_FMT_GRAY8] = {
-            .convert = rgb565_to_gray
-        },
-    },
-    [PIX_FMT_GRAY16BE] = {
-        [PIX_FMT_GRAY8] = {
-            .convert = gray16be_to_gray
-        },
-        [PIX_FMT_GRAY16LE] = {
-            .convert = gray16_to_gray16
-        },
-    },
-    [PIX_FMT_GRAY16LE] = {
-        [PIX_FMT_GRAY8] = {
-            .convert = gray16le_to_gray
-        },
-        [PIX_FMT_GRAY16BE] = {
-            .convert = gray16_to_gray16
-        },
-    },
-    [PIX_FMT_GRAY8] = {
-        [PIX_FMT_RGB555] = {
-            .convert = gray_to_rgb555
-        },
-        [PIX_FMT_RGB565] = {
-            .convert = gray_to_rgb565
-        },
-        [PIX_FMT_RGB24] = {
-            .convert = gray_to_rgb24
-        },
-        [PIX_FMT_BGR24] = {
-            .convert = gray_to_bgr24
-        },
-        [PIX_FMT_RGB32] = {
-            .convert = gray_to_rgb32
-        },
-        [PIX_FMT_MONOWHITE] = {
-            .convert = gray_to_monowhite
-        },
-        [PIX_FMT_MONOBLACK] = {
-            .convert = gray_to_monoblack
-        },
-        [PIX_FMT_GRAY16LE] = {
-            .convert = gray_to_gray16
-        },
-        [PIX_FMT_GRAY16BE] = {
-            .convert = gray_to_gray16
-        },
-    },
-    [PIX_FMT_MONOWHITE] = {
-        [PIX_FMT_GRAY8] = {
-            .convert = monowhite_to_gray
-        },
-    },
-    [PIX_FMT_MONOBLACK] = {
-        [PIX_FMT_GRAY8] = {
-            .convert = monoblack_to_gray
-        },
-    },
-    [PIX_FMT_PAL8] = {
-        [PIX_FMT_RGB555] = {
-            .convert = pal8_to_rgb555
-        },
-        [PIX_FMT_RGB565] = {
-            .convert = pal8_to_rgb565
-        },
-        [PIX_FMT_BGR24] = {
-            .convert = pal8_to_bgr24
-        },
-        [PIX_FMT_RGB24] = {
-            .convert = pal8_to_rgb24
-        },
-        [PIX_FMT_RGB32] = {
-            .convert = pal8_to_rgb32
-        },
-    },
-    [PIX_FMT_UYYVYY411] = {
-        [PIX_FMT_YUV411P] = {
-            .convert = uyyvyy411_to_yuv411p,
-        },
-    },
-
-};
 
 int avpicture_alloc(AVPicture *picture,
-                           int pix_fmt, int width, int height)
+                    enum PixelFormat pix_fmt, int width, int height)
 {
     int size;
     void *ptr;
 
-    size = avpicture_get_size(pix_fmt, width, height);
+    size = avpicture_fill(picture, NULL, pix_fmt, width, height);
     if(size<0)
         goto fail;
     ptr = av_malloc(size);
@@ -2137,7 +1247,7 @@
 }
 
 int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width,
-            int pix_fmt, int padtop, int padbottom, int padleft, int padright,
+                   enum PixelFormat pix_fmt, int padtop, int padbottom, int padleft, int padright,
             int *color)
 {
     uint8_t *optr;
@@ -2196,528 +1306,6 @@
     return 0;
 }
 
-#if !CONFIG_SWSCALE
-static uint8_t y_ccir_to_jpeg[256];
-static uint8_t y_jpeg_to_ccir[256];
-static uint8_t c_ccir_to_jpeg[256];
-static uint8_t c_jpeg_to_ccir[256];
-
-/* init various conversion tables */
-static av_cold void img_convert_init(void)
-{
-    int i;
-    uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
-
-    for(i = 0;i < 256; i++) {
-        y_ccir_to_jpeg[i] = Y_CCIR_TO_JPEG(i);
-        y_jpeg_to_ccir[i] = Y_JPEG_TO_CCIR(i);
-        c_ccir_to_jpeg[i] = C_CCIR_TO_JPEG(i);
-        c_jpeg_to_ccir[i] = C_JPEG_TO_CCIR(i);
-    }
-}
-
-/* apply to each pixel the given table */
-static void img_apply_table(uint8_t *dst, int dst_wrap,
-                            const uint8_t *src, int src_wrap,
-                            int width, int height, const uint8_t *table1)
-{
-    int n;
-    const uint8_t *s;
-    uint8_t *d;
-    const uint8_t *table;
-
-    table = table1;
-    for(;height > 0; height--) {
-        s = src;
-        d = dst;
-        n = width;
-        while (n >= 4) {
-            d[0] = table[s[0]];
-            d[1] = table[s[1]];
-            d[2] = table[s[2]];
-            d[3] = table[s[3]];
-            d += 4;
-            s += 4;
-            n -= 4;
-        }
-        while (n > 0) {
-            d[0] = table[s[0]];
-            d++;
-            s++;
-            n--;
-        }
-        dst += dst_wrap;
-        src += src_wrap;
-    }
-}
-
-/* XXX: use generic filter ? */
-/* XXX: in most cases, the sampling position is incorrect */
-
-/* 4x1 -> 1x1 */
-static void shrink41(uint8_t *dst, int dst_wrap,
-                     const uint8_t *src, int src_wrap,
-                     int width, int height)
-{
-    int w;
-    const uint8_t *s;
-    uint8_t *d;
-
-    for(;height > 0; height--) {
-        s = src;
-        d = dst;
-        for(w = width;w > 0; w--) {
-            d[0] = (s[0] + s[1] + s[2] + s[3] + 2) >> 2;
-            s += 4;
-            d++;
-        }
-        src += src_wrap;
-        dst += dst_wrap;
-    }
-}
-
-/* 2x1 -> 1x1 */
-static void shrink21(uint8_t *dst, int dst_wrap,
-                     const uint8_t *src, int src_wrap,
-                     int width, int height)
-{
-    int w;
-    const uint8_t *s;
-    uint8_t *d;
-
-    for(;height > 0; height--) {
-        s = src;
-        d = dst;
-        for(w = width;w > 0; w--) {
-            d[0] = (s[0] + s[1]) >> 1;
-            s += 2;
-            d++;
-        }
-        src += src_wrap;
-        dst += dst_wrap;
-    }
-}
-
-/* 1x2 -> 1x1 */
-static void shrink12(uint8_t *dst, int dst_wrap,
-                     const uint8_t *src, int src_wrap,
-                     int width, int height)
-{
-    int w;
-    uint8_t *d;
-    const uint8_t *s1, *s2;
-
-    for(;height > 0; height--) {
-        s1 = src;
-        s2 = s1 + src_wrap;
-        d = dst;
-        for(w = width;w >= 4; w-=4) {
-            d[0] = (s1[0] + s2[0]) >> 1;
-            d[1] = (s1[1] + s2[1]) >> 1;
-            d[2] = (s1[2] + s2[2]) >> 1;
-            d[3] = (s1[3] + s2[3]) >> 1;
-            s1 += 4;
-            s2 += 4;
-            d += 4;
-        }
-        for(;w > 0; w--) {
-            d[0] = (s1[0] + s2[0]) >> 1;
-            s1++;
-            s2++;
-            d++;
-        }
-        src += 2 * src_wrap;
-        dst += dst_wrap;
-    }
-}
-
-static void grow21_line(uint8_t *dst, const uint8_t *src,
-                        int width)
-{
-    int w;
-    const uint8_t *s1;
-    uint8_t *d;
-
-    s1 = src;
-    d = dst;
-    for(w = width;w >= 4; w-=4) {
-        d[1] = d[0] = s1[0];
-        d[3] = d[2] = s1[1];
-        s1 += 2;
-        d += 4;
-    }
-    for(;w >= 2; w -= 2) {
-        d[1] = d[0] = s1[0];
-        s1 ++;
-        d += 2;
-    }
-    /* only needed if width is not a multiple of two */
-    /* XXX: veryfy that */
-    if (w) {
-        d[0] = s1[0];
-    }
-}
-
-static void grow41_line(uint8_t *dst, const uint8_t *src,
-                        int width)
-{
-    int w, v;
-    const uint8_t *s1;
-    uint8_t *d;
-
-    s1 = src;
-    d = dst;
-    for(w = width;w >= 4; w-=4) {
-        v = s1[0];
-        d[0] = v;
-        d[1] = v;
-        d[2] = v;
-        d[3] = v;
-        s1 ++;
-        d += 4;
-    }
-}
-
-/* 1x1 -> 2x1 */
-static void grow21(uint8_t *dst, int dst_wrap,
-                   const uint8_t *src, int src_wrap,
-                   int width, int height)
-{
-    for(;height > 0; height--) {
-        grow21_line(dst, src, width);
-        src += src_wrap;
-        dst += dst_wrap;
-    }
-}
-
-/* 1x1 -> 1x2 */
-static void grow12(uint8_t *dst, int dst_wrap,
-                   const uint8_t *src, int src_wrap,
-                   int width, int height)
-{
-    for(;height > 0; height-=2) {
-        memcpy(dst, src, width);
-        dst += dst_wrap;
-        memcpy(dst, src, width);
-        dst += dst_wrap;
-        src += src_wrap;
-    }
-}
-
-/* 1x1 -> 2x2 */
-static void grow22(uint8_t *dst, int dst_wrap,
-                   const uint8_t *src, int src_wrap,
-                   int width, int height)
-{
-    for(;height > 0; height--) {
-        grow21_line(dst, src, width);
-        if (height%2)
-            src += src_wrap;
-        dst += dst_wrap;
-    }
-}
-
-/* 1x1 -> 4x1 */
-static void grow41(uint8_t *dst, int dst_wrap,
-                   const uint8_t *src, int src_wrap,
-                   int width, int height)
-{
-    for(;height > 0; height--) {
-        grow41_line(dst, src, width);
-        src += src_wrap;
-        dst += dst_wrap;
-    }
-}
-
-/* 1x1 -> 4x4 */
-static void grow44(uint8_t *dst, int dst_wrap,
-                   const uint8_t *src, int src_wrap,
-                   int width, int height)
-{
-    for(;height > 0; height--) {
-        grow41_line(dst, src, width);
-        if ((height & 3) == 1)
-            src += src_wrap;
-        dst += dst_wrap;
-    }
-}
-
-/* 1x2 -> 2x1 */
-static void conv411(uint8_t *dst, int dst_wrap,
-                    const uint8_t *src, int src_wrap,
-                    int width, int height)
-{
-    int w, c;
-    const uint8_t *s1, *s2;
-    uint8_t *d;
-
-    width>>=1;
-
-    for(;height > 0; height--) {
-        s1 = src;
-        s2 = src + src_wrap;
-        d = dst;
-        for(w = width;w > 0; w--) {
-            c = (s1[0] + s2[0]) >> 1;
-            d[0] = c;
-            d[1] = c;
-            s1++;
-            s2++;
-            d += 2;
-        }
-        src += src_wrap * 2;
-        dst += dst_wrap;
-    }
-}
-
-/* XXX: always use linesize. Return -1 if not supported */
-int img_convert(AVPicture *dst, int dst_pix_fmt,
-                const AVPicture *src, int src_pix_fmt,
-                int src_width, int src_height)
-{
-    static int initialized;
-    int i, ret, dst_width, dst_height, int_pix_fmt;
-    const PixFmtInfo *src_pix, *dst_pix;
-    const ConvertEntry *ce;
-    AVPicture tmp1, *tmp = &tmp1;
-
-    if (src_pix_fmt < 0 || src_pix_fmt >= PIX_FMT_NB ||
-        dst_pix_fmt < 0 || dst_pix_fmt >= PIX_FMT_NB)
-        return -1;
-    if (src_width <= 0 || src_height <= 0)
-        return 0;
-
-    if (!initialized) {
-        initialized = 1;
-        img_convert_init();
-    }
-
-    dst_width = src_width;
-    dst_height = src_height;
-
-    dst_pix = &pix_fmt_info[dst_pix_fmt];
-    src_pix = &pix_fmt_info[src_pix_fmt];
-    if (src_pix_fmt == dst_pix_fmt) {
-        /* no conversion needed: just copy */
-        av_picture_copy(dst, src, dst_pix_fmt, dst_width, dst_height);
-        return 0;
-    }
-
-    ce = &convert_table[src_pix_fmt][dst_pix_fmt];
-    if (ce->convert) {
-        /* specific conversion routine */
-        ce->convert(dst, src, dst_width, dst_height);
-        return 0;
-    }
-
-    /* gray to YUV */
-    if (is_yuv_planar(dst_pix) &&
-        src_pix_fmt == PIX_FMT_GRAY8) {
-        int w, h, y;
-        uint8_t *d;
-
-        if (dst_pix->color_type == FF_COLOR_YUV_JPEG) {
-            ff_img_copy_plane(dst->data[0], dst->linesize[0],
-                     src->data[0], src->linesize[0],
-                     dst_width, dst_height);
-        } else {
-            img_apply_table(dst->data[0], dst->linesize[0],
-                            src->data[0], src->linesize[0],
-                            dst_width, dst_height,
-                            y_jpeg_to_ccir);
-        }
-        /* fill U and V with 128 */
-        w = dst_width;
-        h = dst_height;
-        w >>= dst_pix->x_chroma_shift;
-        h >>= dst_pix->y_chroma_shift;
-        for(i = 1; i <= 2; i++) {
-            d = dst->data[i];
-            for(y = 0; y< h; y++) {
-                memset(d, 128, w);
-                d += dst->linesize[i];
-            }
-        }
-        return 0;
-    }
-
-    /* YUV to gray */
-    if (is_yuv_planar(src_pix) &&
-        dst_pix_fmt == PIX_FMT_GRAY8) {
-        if (src_pix->color_type == FF_COLOR_YUV_JPEG) {
-            ff_img_copy_plane(dst->data[0], dst->linesize[0],
-                     src->data[0], src->linesize[0],
-                     dst_width, dst_height);
-        } else {
-            img_apply_table(dst->data[0], dst->linesize[0],
-                            src->data[0], src->linesize[0],
-                            dst_width, dst_height,
-                            y_ccir_to_jpeg);
-        }
-        return 0;
-    }
-
-    /* YUV to YUV planar */
-    if (is_yuv_planar(dst_pix) && is_yuv_planar(src_pix)) {
-        int x_shift, y_shift, w, h, xy_shift;
-        void (*resize_func)(uint8_t *dst, int dst_wrap,
-                            const uint8_t *src, int src_wrap,
-                            int width, int height);
-
-        /* compute chroma size of the smallest dimensions */
-        w = dst_width;
-        h = dst_height;
-        if (dst_pix->x_chroma_shift >= src_pix->x_chroma_shift)
-            w >>= dst_pix->x_chroma_shift;
-        else
-            w >>= src_pix->x_chroma_shift;
-        if (dst_pix->y_chroma_shift >= src_pix->y_chroma_shift)
-            h >>= dst_pix->y_chroma_shift;
-        else
-            h >>= src_pix->y_chroma_shift;
-
-        x_shift = (dst_pix->x_chroma_shift - src_pix->x_chroma_shift);
-        y_shift = (dst_pix->y_chroma_shift - src_pix->y_chroma_shift);
-        xy_shift = ((x_shift & 0xf) << 4) | (y_shift & 0xf);
-        /* there must be filters for conversion at least from and to
-           YUV444 format */
-        switch(xy_shift) {
-        case 0x00:
-            resize_func = ff_img_copy_plane;
-            break;
-        case 0x10:
-            resize_func = shrink21;
-            break;
-        case 0x20:
-            resize_func = shrink41;
-            break;
-        case 0x01:
-            resize_func = shrink12;
-            break;
-        case 0x11:
-            resize_func = ff_shrink22;
-            break;
-        case 0x22:
-            resize_func = ff_shrink44;
-            break;
-        case 0xf0:
-            resize_func = grow21;
-            break;
-        case 0x0f:
-            resize_func = grow12;
-            break;
-        case 0xe0:
-            resize_func = grow41;
-            break;
-        case 0xff:
-            resize_func = grow22;
-            break;
-        case 0xee:
-            resize_func = grow44;
-            break;
-        case 0xf1:
-            resize_func = conv411;
-            break;
-        default:
-            /* currently not handled */
-            goto no_chroma_filter;
-        }
-
-        ff_img_copy_plane(dst->data[0], dst->linesize[0],
-                       src->data[0], src->linesize[0],
-                       dst_width, dst_height);
-
-        for(i = 1;i <= 2; i++)
-            resize_func(dst->data[i], dst->linesize[i],
-                        src->data[i], src->linesize[i],
-                        dst_width>>dst_pix->x_chroma_shift, dst_height>>dst_pix->y_chroma_shift);
-        /* if yuv color space conversion is needed, we do it here on
-           the destination image */
-        if (dst_pix->color_type != src_pix->color_type) {
-            const uint8_t *y_table, *c_table;
-            if (dst_pix->color_type == FF_COLOR_YUV) {
-                y_table = y_jpeg_to_ccir;
-                c_table = c_jpeg_to_ccir;
-            } else {
-                y_table = y_ccir_to_jpeg;
-                c_table = c_ccir_to_jpeg;
-            }
-            img_apply_table(dst->data[0], dst->linesize[0],
-                            dst->data[0], dst->linesize[0],
-                            dst_width, dst_height,
-                            y_table);
-
-            for(i = 1;i <= 2; i++)
-                img_apply_table(dst->data[i], dst->linesize[i],
-                                dst->data[i], dst->linesize[i],
-                                dst_width>>dst_pix->x_chroma_shift,
-                                dst_height>>dst_pix->y_chroma_shift,
-                                c_table);
-        }
-        return 0;
-    }
- no_chroma_filter:
-
-    /* try to use an intermediate format */
-    if (src_pix_fmt == PIX_FMT_YUYV422 ||
-        dst_pix_fmt == PIX_FMT_YUYV422) {
-        /* specific case: convert to YUV422P first */
-        int_pix_fmt = PIX_FMT_YUV422P;
-    } else if (src_pix_fmt == PIX_FMT_UYVY422 ||
-        dst_pix_fmt == PIX_FMT_UYVY422) {
-        /* specific case: convert to YUV422P first */
-        int_pix_fmt = PIX_FMT_YUV422P;
-    } else if (src_pix_fmt == PIX_FMT_UYYVYY411 ||
-        dst_pix_fmt == PIX_FMT_UYYVYY411) {
-        /* specific case: convert to YUV411P first */
-        int_pix_fmt = PIX_FMT_YUV411P;
-    } else if ((src_pix->color_type == FF_COLOR_GRAY &&
-                src_pix_fmt != PIX_FMT_GRAY8) ||
-               (dst_pix->color_type == FF_COLOR_GRAY &&
-                dst_pix_fmt != PIX_FMT_GRAY8)) {
-        /* gray8 is the normalized format */
-        int_pix_fmt = PIX_FMT_GRAY8;
-    } else if ((is_yuv_planar(src_pix) &&
-                src_pix_fmt != PIX_FMT_YUV444P &&
-                src_pix_fmt != PIX_FMT_YUVJ444P)) {
-        /* yuv444 is the normalized format */
-        if (src_pix->color_type == FF_COLOR_YUV_JPEG)
-            int_pix_fmt = PIX_FMT_YUVJ444P;
-        else
-            int_pix_fmt = PIX_FMT_YUV444P;
-    } else if ((is_yuv_planar(dst_pix) &&
-                dst_pix_fmt != PIX_FMT_YUV444P &&
-                dst_pix_fmt != PIX_FMT_YUVJ444P)) {
-        /* yuv444 is the normalized format */
-        if (dst_pix->color_type == FF_COLOR_YUV_JPEG)
-            int_pix_fmt = PIX_FMT_YUVJ444P;
-        else
-            int_pix_fmt = PIX_FMT_YUV444P;
-    } else {
-        /* the two formats are rgb or gray8 or yuv[j]444p */
-        if (src_pix->is_alpha && dst_pix->is_alpha)
-            int_pix_fmt = PIX_FMT_RGB32;
-        else
-            int_pix_fmt = PIX_FMT_RGB24;
-    }
-    if (src_pix_fmt == int_pix_fmt)
-        return -1;
-    if (avpicture_alloc(tmp, int_pix_fmt, dst_width, dst_height) < 0)
-        return -1;
-    ret = -1;
-    if (img_convert(tmp, int_pix_fmt,
-                    src, src_pix_fmt, src_width, src_height) < 0)
-        goto fail1;
-    if (img_convert(dst, dst_pix_fmt,
-                    tmp, int_pix_fmt, dst_width, dst_height) < 0)
-        goto fail1;
-    ret = 0;
- fail1:
-    avpicture_free(tmp);
-    return ret;
-}
-#endif
-
 /* NOTE: we scan all the pixels to have an exact information */
 static int get_alpha_info_pal8(const AVPicture *src, int width, int height)
 {
@@ -2745,7 +1333,7 @@
 }
 
 int img_get_alpha_info(const AVPicture *src,
-                       int pix_fmt, int width, int height)
+                       enum PixelFormat pix_fmt, int width, int height)
 {
     const PixFmtInfo *pf = &pix_fmt_info[pix_fmt];
     int ret;
@@ -2755,9 +1343,6 @@
     if (!pf->is_alpha)
         return 0;
     switch(pix_fmt) {
-    case PIX_FMT_RGB32:
-        ret = get_alpha_info_rgb32(src, width, height);
-        break;
     case PIX_FMT_PAL8:
         ret = get_alpha_info_pal8(src, width, height);
         break;
@@ -2954,7 +1539,7 @@
 }
 
 int avpicture_deinterlace(AVPicture *dst, const AVPicture *src,
-                          int pix_fmt, int width, int height)
+                          enum PixelFormat pix_fmt, int width, int height)
 {
     int i;
 
diff --git a/libavcodec/imgconvert.h b/libavcodec/imgconvert.h
index 3b5bed7..48e2f12 100644
--- a/libavcodec/imgconvert.h
+++ b/libavcodec/imgconvert.h
@@ -27,15 +27,12 @@
 #include <stdint.h>
 #include "avcodec.h"
 
-int ff_fill_linesize(AVPicture *picture, int pix_fmt, int width);
+int ff_fill_linesize(AVPicture *picture, enum PixelFormat pix_fmt, int width);
 
-int ff_fill_pointer(AVPicture *picture, uint8_t *ptr, int pix_fmt, int height);
+int ff_fill_pointer(AVPicture *picture, uint8_t *ptr, enum PixelFormat pix_fmt, int height);
 
 int ff_get_plane_bytewidth(enum PixelFormat pix_fmt, int width, int plane);
 
 int ff_set_systematic_pal(uint32_t pal[256], enum PixelFormat pix_fmt);
 
-int img_convert(AVPicture *dst, int dst_pix_fmt, const AVPicture *src,
-                int src_pix_fmt, int src_width, int src_height);
-
 #endif /* AVCODEC_IMGCONVERT_H */
diff --git a/libavcodec/imgconvert_template.c b/libavcodec/imgconvert_template.c
deleted file mode 100644
index d33bc7e..0000000
--- a/libavcodec/imgconvert_template.c
+++ /dev/null
@@ -1,875 +0,0 @@
-/*
- * templates for image conversion routines
- * Copyright (c) 2001, 2002, 2003 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 RGB_OUT
-#define RGB_OUT(d, r, g, b) RGBA_OUT(d, r, g, b, 0xff)
-#endif
-
-static void glue(yuv420p_to_, RGB_NAME)(AVPicture *dst, const AVPicture *src,
-                                        int width, int height)
-{
-    const uint8_t *y1_ptr, *y2_ptr, *cb_ptr, *cr_ptr;
-    uint8_t *d, *d1, *d2;
-    int w, y, cb, cr, r_add, g_add, b_add, width2;
-    uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
-    unsigned int r, g, b;
-
-    d = dst->data[0];
-    y1_ptr = src->data[0];
-    cb_ptr = src->data[1];
-    cr_ptr = src->data[2];
-    width2 = (width + 1) >> 1;
-    for(;height >= 2; height -= 2) {
-        d1 = d;
-        d2 = d + dst->linesize[0];
-        y2_ptr = y1_ptr + src->linesize[0];
-        for(w = width; w >= 2; w -= 2) {
-            YUV_TO_RGB1_CCIR(cb_ptr[0], cr_ptr[0]);
-            /* output 4 pixels */
-            YUV_TO_RGB2_CCIR(r, g, b, y1_ptr[0]);
-            RGB_OUT(d1, r, g, b);
-
-            YUV_TO_RGB2_CCIR(r, g, b, y1_ptr[1]);
-            RGB_OUT(d1 + BPP, r, g, b);
-
-            YUV_TO_RGB2_CCIR(r, g, b, y2_ptr[0]);
-            RGB_OUT(d2, r, g, b);
-
-            YUV_TO_RGB2_CCIR(r, g, b, y2_ptr[1]);
-            RGB_OUT(d2 + BPP, r, g, b);
-
-            d1 += 2 * BPP;
-            d2 += 2 * BPP;
-
-            y1_ptr += 2;
-            y2_ptr += 2;
-            cb_ptr++;
-            cr_ptr++;
-        }
-        /* handle odd width */
-        if (w) {
-            YUV_TO_RGB1_CCIR(cb_ptr[0], cr_ptr[0]);
-            YUV_TO_RGB2_CCIR(r, g, b, y1_ptr[0]);
-            RGB_OUT(d1, r, g, b);
-
-            YUV_TO_RGB2_CCIR(r, g, b, y2_ptr[0]);
-            RGB_OUT(d2, r, g, b);
-            d1 += BPP;
-            d2 += BPP;
-            y1_ptr++;
-            y2_ptr++;
-            cb_ptr++;
-            cr_ptr++;
-        }
-        d += 2 * dst->linesize[0];
-        y1_ptr += 2 * src->linesize[0] - width;
-        cb_ptr += src->linesize[1] - width2;
-        cr_ptr += src->linesize[2] - width2;
-    }
-    /* handle odd height */
-    if (height) {
-        d1 = d;
-        for(w = width; w >= 2; w -= 2) {
-            YUV_TO_RGB1_CCIR(cb_ptr[0], cr_ptr[0]);
-            /* output 2 pixels */
-            YUV_TO_RGB2_CCIR(r, g, b, y1_ptr[0]);
-            RGB_OUT(d1, r, g, b);
-
-            YUV_TO_RGB2_CCIR(r, g, b, y1_ptr[1]);
-            RGB_OUT(d1 + BPP, r, g, b);
-
-            d1 += 2 * BPP;
-
-            y1_ptr += 2;
-            cb_ptr++;
-            cr_ptr++;
-        }
-        /* handle width */
-        if (w) {
-            YUV_TO_RGB1_CCIR(cb_ptr[0], cr_ptr[0]);
-            /* output 2 pixels */
-            YUV_TO_RGB2_CCIR(r, g, b, y1_ptr[0]);
-            RGB_OUT(d1, r, g, b);
-            d1 += BPP;
-
-            y1_ptr++;
-            cb_ptr++;
-            cr_ptr++;
-        }
-    }
-}
-
-static void glue(yuvj420p_to_, RGB_NAME)(AVPicture *dst, const AVPicture *src,
-                                         int width, int height)
-{
-    const uint8_t *y1_ptr, *y2_ptr, *cb_ptr, *cr_ptr;
-    uint8_t *d, *d1, *d2;
-    int w, y, cb, cr, r_add, g_add, b_add, width2;
-    uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
-    unsigned int r, g, b;
-
-    d = dst->data[0];
-    y1_ptr = src->data[0];
-    cb_ptr = src->data[1];
-    cr_ptr = src->data[2];
-    width2 = (width + 1) >> 1;
-    for(;height >= 2; height -= 2) {
-        d1 = d;
-        d2 = d + dst->linesize[0];
-        y2_ptr = y1_ptr + src->linesize[0];
-        for(w = width; w >= 2; w -= 2) {
-            YUV_TO_RGB1(cb_ptr[0], cr_ptr[0]);
-            /* output 4 pixels */
-            YUV_TO_RGB2(r, g, b, y1_ptr[0]);
-            RGB_OUT(d1, r, g, b);
-
-            YUV_TO_RGB2(r, g, b, y1_ptr[1]);
-            RGB_OUT(d1 + BPP, r, g, b);
-
-            YUV_TO_RGB2(r, g, b, y2_ptr[0]);
-            RGB_OUT(d2, r, g, b);
-
-            YUV_TO_RGB2(r, g, b, y2_ptr[1]);
-            RGB_OUT(d2 + BPP, r, g, b);
-
-            d1 += 2 * BPP;
-            d2 += 2 * BPP;
-
-            y1_ptr += 2;
-            y2_ptr += 2;
-            cb_ptr++;
-            cr_ptr++;
-        }
-        /* handle odd width */
-        if (w) {
-            YUV_TO_RGB1(cb_ptr[0], cr_ptr[0]);
-            YUV_TO_RGB2(r, g, b, y1_ptr[0]);
-            RGB_OUT(d1, r, g, b);
-
-            YUV_TO_RGB2(r, g, b, y2_ptr[0]);
-            RGB_OUT(d2, r, g, b);
-            d1 += BPP;
-            d2 += BPP;
-            y1_ptr++;
-            y2_ptr++;
-            cb_ptr++;
-            cr_ptr++;
-        }
-        d += 2 * dst->linesize[0];
-        y1_ptr += 2 * src->linesize[0] - width;
-        cb_ptr += src->linesize[1] - width2;
-        cr_ptr += src->linesize[2] - width2;
-    }
-    /* handle odd height */
-    if (height) {
-        d1 = d;
-        for(w = width; w >= 2; w -= 2) {
-            YUV_TO_RGB1(cb_ptr[0], cr_ptr[0]);
-            /* output 2 pixels */
-            YUV_TO_RGB2(r, g, b, y1_ptr[0]);
-            RGB_OUT(d1, r, g, b);
-
-            YUV_TO_RGB2(r, g, b, y1_ptr[1]);
-            RGB_OUT(d1 + BPP, r, g, b);
-
-            d1 += 2 * BPP;
-
-            y1_ptr += 2;
-            cb_ptr++;
-            cr_ptr++;
-        }
-        /* handle width */
-        if (w) {
-            YUV_TO_RGB1(cb_ptr[0], cr_ptr[0]);
-            /* output 2 pixels */
-            YUV_TO_RGB2(r, g, b, y1_ptr[0]);
-            RGB_OUT(d1, r, g, b);
-            d1 += BPP;
-
-            y1_ptr++;
-            cb_ptr++;
-            cr_ptr++;
-        }
-    }
-}
-
-static void glue(RGB_NAME, _to_yuv420p)(AVPicture *dst, const AVPicture *src,
-                                        int width, int height)
-{
-    int wrap, wrap3, width2;
-    int r, g, b, r1, g1, b1, w;
-    uint8_t *lum, *cb, *cr;
-    const uint8_t *p;
-
-    lum = dst->data[0];
-    cb = dst->data[1];
-    cr = dst->data[2];
-
-    width2 = (width + 1) >> 1;
-    wrap = dst->linesize[0];
-    wrap3 = src->linesize[0];
-    p = src->data[0];
-    for(;height>=2;height -= 2) {
-        for(w = width; w >= 2; w -= 2) {
-            RGB_IN(r, g, b, p);
-            r1 = r;
-            g1 = g;
-            b1 = b;
-            lum[0] = RGB_TO_Y_CCIR(r, g, b);
-
-            RGB_IN(r, g, b, p + BPP);
-            r1 += r;
-            g1 += g;
-            b1 += b;
-            lum[1] = RGB_TO_Y_CCIR(r, g, b);
-            p += wrap3;
-            lum += wrap;
-
-            RGB_IN(r, g, b, p);
-            r1 += r;
-            g1 += g;
-            b1 += b;
-            lum[0] = RGB_TO_Y_CCIR(r, g, b);
-
-            RGB_IN(r, g, b, p + BPP);
-            r1 += r;
-            g1 += g;
-            b1 += b;
-            lum[1] = RGB_TO_Y_CCIR(r, g, b);
-
-            cb[0] = RGB_TO_U_CCIR(r1, g1, b1, 2);
-            cr[0] = RGB_TO_V_CCIR(r1, g1, b1, 2);
-
-            cb++;
-            cr++;
-            p += -wrap3 + 2 * BPP;
-            lum += -wrap + 2;
-        }
-        if (w) {
-            RGB_IN(r, g, b, p);
-            r1 = r;
-            g1 = g;
-            b1 = b;
-            lum[0] = RGB_TO_Y_CCIR(r, g, b);
-            p += wrap3;
-            lum += wrap;
-            RGB_IN(r, g, b, p);
-            r1 += r;
-            g1 += g;
-            b1 += b;
-            lum[0] = RGB_TO_Y_CCIR(r, g, b);
-            cb[0] = RGB_TO_U_CCIR(r1, g1, b1, 1);
-            cr[0] = RGB_TO_V_CCIR(r1, g1, b1, 1);
-            cb++;
-            cr++;
-            p += -wrap3 + BPP;
-            lum += -wrap + 1;
-        }
-        p += wrap3 + (wrap3 - width * BPP);
-        lum += wrap + (wrap - width);
-        cb += dst->linesize[1] - width2;
-        cr += dst->linesize[2] - width2;
-    }
-    /* handle odd height */
-    if (height) {
-        for(w = width; w >= 2; w -= 2) {
-            RGB_IN(r, g, b, p);
-            r1 = r;
-            g1 = g;
-            b1 = b;
-            lum[0] = RGB_TO_Y_CCIR(r, g, b);
-
-            RGB_IN(r, g, b, p + BPP);
-            r1 += r;
-            g1 += g;
-            b1 += b;
-            lum[1] = RGB_TO_Y_CCIR(r, g, b);
-            cb[0] = RGB_TO_U_CCIR(r1, g1, b1, 1);
-            cr[0] = RGB_TO_V_CCIR(r1, g1, b1, 1);
-            cb++;
-            cr++;
-            p += 2 * BPP;
-           lum += 2;
-        }
-        if (w) {
-            RGB_IN(r, g, b, p);
-            lum[0] = RGB_TO_Y_CCIR(r, g, b);
-            cb[0] = RGB_TO_U_CCIR(r, g, b, 0);
-            cr[0] = RGB_TO_V_CCIR(r, g, b, 0);
-        }
-    }
-}
-
-static void glue(RGB_NAME, _to_gray)(AVPicture *dst, const AVPicture *src,
-                                     int width, int height)
-{
-    const unsigned char *p;
-    unsigned char *q;
-    int r, g, b, dst_wrap, src_wrap;
-    int x, y;
-
-    p = src->data[0];
-    src_wrap = src->linesize[0] - BPP * width;
-
-    q = dst->data[0];
-    dst_wrap = dst->linesize[0] - width;
-
-    for(y=0;y<height;y++) {
-        for(x=0;x<width;x++) {
-            RGB_IN(r, g, b, p);
-            q[0] = RGB_TO_Y(r, g, b);
-            q++;
-            p += BPP;
-        }
-        p += src_wrap;
-        q += dst_wrap;
-    }
-}
-
-static void glue(gray_to_, RGB_NAME)(AVPicture *dst, const AVPicture *src,
-                                     int width, int height)
-{
-    const unsigned char *p;
-    unsigned char *q;
-    int r, dst_wrap, src_wrap;
-    int x, y;
-
-    p = src->data[0];
-    src_wrap = src->linesize[0] - width;
-
-    q = dst->data[0];
-    dst_wrap = dst->linesize[0] - BPP * width;
-
-    for(y=0;y<height;y++) {
-        for(x=0;x<width;x++) {
-            r = p[0];
-            RGB_OUT(q, r, r, r);
-            q += BPP;
-            p ++;
-        }
-        p += src_wrap;
-        q += dst_wrap;
-    }
-}
-
-static void glue(pal8_to_, RGB_NAME)(AVPicture *dst, const AVPicture *src,
-                                     int width, int height)
-{
-    const unsigned char *p;
-    unsigned char *q;
-    int r, g, b, dst_wrap, src_wrap;
-    int x, y;
-    uint32_t v;
-    const uint32_t *palette;
-
-    p = src->data[0];
-    src_wrap = src->linesize[0] - width;
-    palette = (uint32_t *)src->data[1];
-
-    q = dst->data[0];
-    dst_wrap = dst->linesize[0] - BPP * width;
-
-    for(y=0;y<height;y++) {
-        for(x=0;x<width;x++) {
-            v = palette[p[0]];
-            r = (v >> 16) & 0xff;
-            g = (v >> 8) & 0xff;
-            b = (v) & 0xff;
-#ifdef RGBA_OUT
-            {
-                int a;
-                a = (v >> 24) & 0xff;
-                RGBA_OUT(q, r, g, b, a);
-            }
-#else
-            RGB_OUT(q, r, g, b);
-#endif
-            q += BPP;
-            p ++;
-        }
-        p += src_wrap;
-        q += dst_wrap;
-    }
-}
-
-// RGB24 has optimized routines
-#if !defined(FMT_RGB32) && !defined(FMT_RGB24)
-/* alpha support */
-
-static void glue(rgb32_to_, RGB_NAME)(AVPicture *dst, const AVPicture *src,
-                                      int width, int height)
-{
-    const uint8_t *s;
-    uint8_t *d;
-    int src_wrap, dst_wrap, j, y;
-    unsigned int v, r, g, b;
-#ifdef RGBA_OUT
-    unsigned int a;
-#endif
-
-    s = src->data[0];
-    src_wrap = src->linesize[0] - width * 4;
-
-    d = dst->data[0];
-    dst_wrap = dst->linesize[0] - width * BPP;
-
-    for(y=0;y<height;y++) {
-        for(j = 0;j < width; j++) {
-            v = ((const uint32_t *)(s))[0];
-            r = (v >> 16) & 0xff;
-            g = (v >> 8) & 0xff;
-            b = v & 0xff;
-#ifdef RGBA_OUT
-            a = (v >> 24) & 0xff;
-            RGBA_OUT(d, r, g, b, a);
-#else
-            RGB_OUT(d, r, g, b);
-#endif
-            s += 4;
-            d += BPP;
-        }
-        s += src_wrap;
-        d += dst_wrap;
-    }
-}
-
-static void glue(RGB_NAME, _to_rgb32)(AVPicture *dst, const AVPicture *src,
-                                       int width, int height)
-{
-    const uint8_t *s;
-    uint8_t *d;
-    int src_wrap, dst_wrap, j, y;
-    unsigned int r, g, b;
-#ifdef RGBA_IN
-    unsigned int a;
-#endif
-
-    s = src->data[0];
-    src_wrap = src->linesize[0] - width * BPP;
-
-    d = dst->data[0];
-    dst_wrap = dst->linesize[0] - width * 4;
-
-    for(y=0;y<height;y++) {
-        for(j = 0;j < width; j++) {
-#ifdef RGBA_IN
-            RGBA_IN(r, g, b, a, s);
-            ((uint32_t *)(d))[0] = (a << 24) | (r << 16) | (g << 8) | b;
-#else
-            RGB_IN(r, g, b, s);
-            ((uint32_t *)(d))[0] = (0xff << 24) | (r << 16) | (g << 8) | b;
-#endif
-            d += 4;
-            s += BPP;
-        }
-        s += src_wrap;
-        d += dst_wrap;
-    }
-}
-
-#endif /* !defined(FMT_RGB32) */
-
-#ifndef FMT_RGB24
-
-static void glue(rgb24_to_, RGB_NAME)(AVPicture *dst, const AVPicture *src,
-                                      int width, int height)
-{
-    const uint8_t *s;
-    uint8_t *d;
-    int src_wrap, dst_wrap, j, y;
-    unsigned int r, g, b;
-
-    s = src->data[0];
-    src_wrap = src->linesize[0] - width * 3;
-
-    d = dst->data[0];
-    dst_wrap = dst->linesize[0] - width * BPP;
-
-    for(y=0;y<height;y++) {
-        for(j = 0;j < width; j++) {
-            r = s[0];
-            g = s[1];
-            b = s[2];
-            RGB_OUT(d, r, g, b);
-            s += 3;
-            d += BPP;
-        }
-        s += src_wrap;
-        d += dst_wrap;
-    }
-}
-
-static void glue(RGB_NAME, _to_rgb24)(AVPicture *dst, const AVPicture *src,
-                                      int width, int height)
-{
-    const uint8_t *s;
-    uint8_t *d;
-    int src_wrap, dst_wrap, j, y;
-    unsigned int r, g , b;
-
-    s = src->data[0];
-    src_wrap = src->linesize[0] - width * BPP;
-
-    d = dst->data[0];
-    dst_wrap = dst->linesize[0] - width * 3;
-
-    for(y=0;y<height;y++) {
-        for(j = 0;j < width; j++) {
-            RGB_IN(r, g, b, s)
-            d[0] = r;
-            d[1] = g;
-            d[2] = b;
-            d += 3;
-            s += BPP;
-        }
-        s += src_wrap;
-        d += dst_wrap;
-    }
-}
-
-#endif /* !FMT_RGB24 */
-
-#ifdef FMT_RGB24
-
-static void yuv444p_to_rgb24(AVPicture *dst, const AVPicture *src,
-                             int width, int height)
-{
-    const uint8_t *y1_ptr, *cb_ptr, *cr_ptr;
-    uint8_t *d, *d1;
-    int w, y, cb, cr, r_add, g_add, b_add;
-    uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
-    unsigned int r, g, b;
-
-    d = dst->data[0];
-    y1_ptr = src->data[0];
-    cb_ptr = src->data[1];
-    cr_ptr = src->data[2];
-    for(;height > 0; height --) {
-        d1 = d;
-        for(w = width; w > 0; w--) {
-            YUV_TO_RGB1_CCIR(cb_ptr[0], cr_ptr[0]);
-
-            YUV_TO_RGB2_CCIR(r, g, b, y1_ptr[0]);
-            RGB_OUT(d1, r, g, b);
-            d1 += BPP;
-
-            y1_ptr++;
-            cb_ptr++;
-            cr_ptr++;
-        }
-        d += dst->linesize[0];
-        y1_ptr += src->linesize[0] - width;
-        cb_ptr += src->linesize[1] - width;
-        cr_ptr += src->linesize[2] - width;
-    }
-}
-
-static void yuvj444p_to_rgb24(AVPicture *dst, const AVPicture *src,
-                              int width, int height)
-{
-    const uint8_t *y1_ptr, *cb_ptr, *cr_ptr;
-    uint8_t *d, *d1;
-    int w, y, cb, cr, r_add, g_add, b_add;
-    uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
-    unsigned int r, g, b;
-
-    d = dst->data[0];
-    y1_ptr = src->data[0];
-    cb_ptr = src->data[1];
-    cr_ptr = src->data[2];
-    for(;height > 0; height --) {
-        d1 = d;
-        for(w = width; w > 0; w--) {
-            YUV_TO_RGB1(cb_ptr[0], cr_ptr[0]);
-
-            YUV_TO_RGB2(r, g, b, y1_ptr[0]);
-            RGB_OUT(d1, r, g, b);
-            d1 += BPP;
-
-            y1_ptr++;
-            cb_ptr++;
-            cr_ptr++;
-        }
-        d += dst->linesize[0];
-        y1_ptr += src->linesize[0] - width;
-        cb_ptr += src->linesize[1] - width;
-        cr_ptr += src->linesize[2] - width;
-    }
-}
-
-static void rgb24_to_yuv444p(AVPicture *dst, const AVPicture *src,
-                             int width, int height)
-{
-    int src_wrap, x, y;
-    int r, g, b;
-    uint8_t *lum, *cb, *cr;
-    const uint8_t *p;
-
-    lum = dst->data[0];
-    cb = dst->data[1];
-    cr = dst->data[2];
-
-    src_wrap = src->linesize[0] - width * BPP;
-    p = src->data[0];
-    for(y=0;y<height;y++) {
-        for(x=0;x<width;x++) {
-            RGB_IN(r, g, b, p);
-            lum[0] = RGB_TO_Y_CCIR(r, g, b);
-            cb[0] = RGB_TO_U_CCIR(r, g, b, 0);
-            cr[0] = RGB_TO_V_CCIR(r, g, b, 0);
-            p += BPP;
-            cb++;
-            cr++;
-            lum++;
-        }
-        p += src_wrap;
-        lum += dst->linesize[0] - width;
-        cb += dst->linesize[1] - width;
-        cr += dst->linesize[2] - width;
-    }
-}
-
-static void rgb24_to_yuvj420p(AVPicture *dst, const AVPicture *src,
-                              int width, int height)
-{
-    int wrap, wrap3, width2;
-    int r, g, b, r1, g1, b1, w;
-    uint8_t *lum, *cb, *cr;
-    const uint8_t *p;
-
-    lum = dst->data[0];
-    cb = dst->data[1];
-    cr = dst->data[2];
-
-    width2 = (width + 1) >> 1;
-    wrap = dst->linesize[0];
-    wrap3 = src->linesize[0];
-    p = src->data[0];
-    for(;height>=2;height -= 2) {
-        for(w = width; w >= 2; w -= 2) {
-            RGB_IN(r, g, b, p);
-            r1 = r;
-            g1 = g;
-            b1 = b;
-            lum[0] = RGB_TO_Y(r, g, b);
-
-            RGB_IN(r, g, b, p + BPP);
-            r1 += r;
-            g1 += g;
-            b1 += b;
-            lum[1] = RGB_TO_Y(r, g, b);
-            p += wrap3;
-            lum += wrap;
-
-            RGB_IN(r, g, b, p);
-            r1 += r;
-            g1 += g;
-            b1 += b;
-            lum[0] = RGB_TO_Y(r, g, b);
-
-            RGB_IN(r, g, b, p + BPP);
-            r1 += r;
-            g1 += g;
-            b1 += b;
-            lum[1] = RGB_TO_Y(r, g, b);
-
-            cb[0] = RGB_TO_U(r1, g1, b1, 2);
-            cr[0] = RGB_TO_V(r1, g1, b1, 2);
-
-            cb++;
-            cr++;
-            p += -wrap3 + 2 * BPP;
-            lum += -wrap + 2;
-        }
-        if (w) {
-            RGB_IN(r, g, b, p);
-            r1 = r;
-            g1 = g;
-            b1 = b;
-            lum[0] = RGB_TO_Y(r, g, b);
-            p += wrap3;
-            lum += wrap;
-            RGB_IN(r, g, b, p);
-            r1 += r;
-            g1 += g;
-            b1 += b;
-            lum[0] = RGB_TO_Y(r, g, b);
-            cb[0] = RGB_TO_U(r1, g1, b1, 1);
-            cr[0] = RGB_TO_V(r1, g1, b1, 1);
-            cb++;
-            cr++;
-            p += -wrap3 + BPP;
-            lum += -wrap + 1;
-        }
-        p += wrap3 + (wrap3 - width * BPP);
-        lum += wrap + (wrap - width);
-        cb += dst->linesize[1] - width2;
-        cr += dst->linesize[2] - width2;
-    }
-    /* handle odd height */
-    if (height) {
-        for(w = width; w >= 2; w -= 2) {
-            RGB_IN(r, g, b, p);
-            r1 = r;
-            g1 = g;
-            b1 = b;
-            lum[0] = RGB_TO_Y(r, g, b);
-
-            RGB_IN(r, g, b, p + BPP);
-            r1 += r;
-            g1 += g;
-            b1 += b;
-            lum[1] = RGB_TO_Y(r, g, b);
-            cb[0] = RGB_TO_U(r1, g1, b1, 1);
-            cr[0] = RGB_TO_V(r1, g1, b1, 1);
-            cb++;
-            cr++;
-            p += 2 * BPP;
-           lum += 2;
-        }
-        if (w) {
-            RGB_IN(r, g, b, p);
-            lum[0] = RGB_TO_Y(r, g, b);
-            cb[0] = RGB_TO_U(r, g, b, 0);
-            cr[0] = RGB_TO_V(r, g, b, 0);
-        }
-    }
-}
-
-static void rgb24_to_yuvj444p(AVPicture *dst, const AVPicture *src,
-                              int width, int height)
-{
-    int src_wrap, x, y;
-    int r, g, b;
-    uint8_t *lum, *cb, *cr;
-    const uint8_t *p;
-
-    lum = dst->data[0];
-    cb = dst->data[1];
-    cr = dst->data[2];
-
-    src_wrap = src->linesize[0] - width * BPP;
-    p = src->data[0];
-    for(y=0;y<height;y++) {
-        for(x=0;x<width;x++) {
-            RGB_IN(r, g, b, p);
-            lum[0] = RGB_TO_Y(r, g, b);
-            cb[0] = RGB_TO_U(r, g, b, 0);
-            cr[0] = RGB_TO_V(r, g, b, 0);
-            p += BPP;
-            cb++;
-            cr++;
-            lum++;
-        }
-        p += src_wrap;
-        lum += dst->linesize[0] - width;
-        cb += dst->linesize[1] - width;
-        cr += dst->linesize[2] - width;
-    }
-}
-
-#endif /* FMT_RGB24 */
-
-#if defined(FMT_RGB24) || defined(FMT_RGB32)
-
-static void glue(RGB_NAME, _to_pal8)(AVPicture *dst, const AVPicture *src,
-                                     int width, int height)
-{
-    const unsigned char *p;
-    unsigned char *q;
-    int dst_wrap, src_wrap;
-    int x, y, has_alpha;
-    unsigned int r, g, b;
-
-    p = src->data[0];
-    src_wrap = src->linesize[0] - BPP * width;
-
-    q = dst->data[0];
-    dst_wrap = dst->linesize[0] - width;
-    has_alpha = 0;
-
-    for(y=0;y<height;y++) {
-        for(x=0;x<width;x++) {
-#ifdef RGBA_IN
-            {
-                unsigned int a;
-                RGBA_IN(r, g, b, a, p);
-                /* crude approximation for alpha ! */
-                if (a < 0x80) {
-                    has_alpha = 1;
-                    q[0] = TRANSP_INDEX;
-                } else {
-                    q[0] = gif_clut_index(r, g, b);
-                }
-            }
-#else
-            RGB_IN(r, g, b, p);
-            q[0] = gif_clut_index(r, g, b);
-#endif
-            q++;
-            p += BPP;
-        }
-        p += src_wrap;
-        q += dst_wrap;
-    }
-
-    build_rgb_palette(dst->data[1], has_alpha);
-}
-
-#endif /* defined(FMT_RGB24) || defined(FMT_RGB32) */
-
-#ifdef RGBA_IN
-
-static int glue(get_alpha_info_, RGB_NAME)(const AVPicture *src,
-                                           int width, int height)
-{
-    const unsigned char *p;
-    int src_wrap, ret, x, y;
-    unsigned int r, g, b, a;
-
-    p = src->data[0];
-    src_wrap = src->linesize[0] - BPP * width;
-    ret = 0;
-    for(y=0;y<height;y++) {
-        for(x=0;x<width;x++) {
-            RGBA_IN(r, g, b, a, p);
-            if (a == 0x00) {
-                ret |= FF_ALPHA_TRANSP;
-            } else if (a != 0xff) {
-                ret |= FF_ALPHA_SEMI_TRANSP;
-            }
-            p += BPP;
-        }
-        p += src_wrap;
-    }
-    return ret;
-}
-
-#endif /* RGBA_IN */
-
-#undef RGB_IN
-#undef RGBA_IN
-#undef RGB_OUT
-#undef RGBA_OUT
-#undef BPP
-#undef RGB_NAME
-#undef FMT_RGB24
-#undef FMT_RGB32
diff --git a/libavcodec/imgresample.c b/libavcodec/imgresample.c
old mode 100644
new mode 100755
index b332d07..7aa04bb
--- a/libavcodec/imgresample.c
+++ b/libavcodec/imgresample.c
@@ -20,11 +20,8 @@
  */
 
 /**
- * @file libavcodec/imgresample.c
+ * @file imgresample.c
  * High quality image resampling with polyphase filters .
- *
- * WARNING: This file is deprecated and will be removed after FFmpeg 0.5
- * release, do not lose your time improving it!
  */
 
 #include "avcodec.h"
@@ -400,6 +397,15 @@
         }
         /* apply vertical filter */
         phase_y = get_phase(src_y);
+        
+        if ((2 << POS_FRAC_BITS) == s->v_incr)
+        {
+            // Do a straight copy, don't bother to resample in the vertical dimension. That way
+            // we can avoid deinterlacing before we do the resample and just take fields.
+            memcpy(output, s->line_buf + ring_y*owidth, owidth);
+        }
+        else
+        {
 #if HAVE_MMX
         /* desactivated MMX because loss of precision */
         if ((mm_flags & FF_MM_MMX) && NB_TAPS == 4 && 0)
@@ -418,6 +424,7 @@
             v_resample(output, owidth,
                        s->line_buf + (ring_y - NB_TAPS + 1) * owidth, owidth,
                        &s->v_filters[phase_y][0]);
+        }
 
         src_y += s->v_incr;
 
@@ -575,7 +582,7 @@
  * Otherwise, frees context and gets a new one.
  *
  * Be warned that srcFilter, dstFilter are not checked, they are
- * assumed to remain valid.
+ * asumed to remain valid.
  */
 struct SwsContext *sws_getCachedContext(struct SwsContext *ctx,
                         int srcW, int srcH, int srcFormat,
diff --git a/libavcodec/imx_dump_header_bsf.c b/libavcodec/imx_dump_header_bsf.c
old mode 100644
new mode 100755
diff --git a/libavcodec/indeo2.c b/libavcodec/indeo2.c
old mode 100644
new mode 100755
diff --git a/libavcodec/indeo2data.h b/libavcodec/indeo2data.h
old mode 100644
new mode 100755
diff --git a/libavcodec/indeo3.c b/libavcodec/indeo3.c
old mode 100644
new mode 100755
diff --git a/libavcodec/indeo3data.h b/libavcodec/indeo3data.h
old mode 100644
new mode 100755
diff --git a/libavcodec/interplayvideo.c b/libavcodec/interplayvideo.c
old mode 100644
new mode 100755
diff --git a/libavcodec/intrax8dsp.c b/libavcodec/intrax8dsp.c
old mode 100644
new mode 100755
diff --git a/libavcodec/jfdctfst.c b/libavcodec/jfdctfst.c
old mode 100644
new mode 100755
diff --git a/libavcodec/jfdctint.c b/libavcodec/jfdctint.c
old mode 100644
new mode 100755
diff --git a/libavcodec/jpegls.c b/libavcodec/jpegls.c
old mode 100644
new mode 100755
diff --git a/libavcodec/jpegls.h b/libavcodec/jpegls.h
old mode 100644
new mode 100755
diff --git a/libavcodec/jpeglsdec.c b/libavcodec/jpeglsdec.c
old mode 100644
new mode 100755
diff --git a/libavcodec/jpeglsdec.h b/libavcodec/jpeglsdec.h
old mode 100644
new mode 100755
diff --git a/libavcodec/jpeglsenc.c b/libavcodec/jpeglsenc.c
old mode 100644
new mode 100755
diff --git a/libavcodec/jrevdct.c b/libavcodec/jrevdct.c
old mode 100644
new mode 100755
diff --git a/libavcodec/kmvc.c b/libavcodec/kmvc.c
old mode 100644
new mode 100755
diff --git a/libavcodec/latm_parser.c b/libavcodec/latm_parser.c
new file mode 100644
index 0000000..f9d310c
--- /dev/null
+++ b/libavcodec/latm_parser.c
@@ -0,0 +1,128 @@
+/*
+ * LATM parser
+ * Copyright (c) 2008 Paul Kendall <paul@kcbbs.gen.nz>
+ *
+ * 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 latm_parser.c
+ * LATM parser
+ */
+
+#include "parser.h"
+
+#define LATM_HEADER     0x56e000	// 0x2b7 (11 bits)
+#define LATM_MASK       0xFFE000	// top 11 bits
+#define LATM_SIZE_MASK  0x001FFF	// bottom 13 bits
+
+typedef struct LATMParseContext{
+    ParseContext pc;
+    int count;
+} LATMParseContext;
+
+/**
+ * finds the end of the current frame in the bitstream.
+ * @return the position of the first byte of the next frame, or -1
+ */
+static int latm_find_frame_end(AVCodecParserContext *s1, const uint8_t *buf,
+                               int buf_size) {
+    LATMParseContext *s = s1->priv_data;
+    ParseContext *pc = &s->pc;
+    int pic_found, i;
+    uint32_t state;
+
+    pic_found = pc->frame_start_found;
+    state = pc->state;
+
+    i = 0;
+    if(!pic_found){
+        for(i=0; i<buf_size; i++){
+            state = (state<<8) | buf[i];
+            if((state & LATM_MASK) == LATM_HEADER){
+                i++;
+                s->count = - i;
+                pic_found=1;
+                break;
+            }
+        }
+    }
+
+    if(pic_found){
+        /* EOF considered as end of frame */
+        if (buf_size == 0)
+            return 0;
+        if((state & LATM_SIZE_MASK) - s->count <= buf_size) {
+            pc->frame_start_found = 0;
+            pc->state = -1;
+            return (state & LATM_SIZE_MASK) - s->count;
+	}
+    }
+
+    s->count += buf_size;
+    pc->frame_start_found = pic_found;
+    pc->state = state;
+    return END_NOT_FOUND;
+}
+
+static int latm_parse(AVCodecParserContext *s1,
+                           AVCodecContext *avctx,
+                           const uint8_t **poutbuf, int *poutbuf_size,
+                           const uint8_t *buf, int buf_size)
+{
+    LATMParseContext *s = s1->priv_data;
+    ParseContext *pc = &s->pc;
+    int next;
+
+    if(s1->flags & PARSER_FLAG_COMPLETE_FRAMES){
+        next = buf_size;
+    }else{
+        next = latm_find_frame_end(s1, buf, buf_size);
+
+        if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) {
+            *poutbuf = NULL;
+            *poutbuf_size = 0;
+            return buf_size;
+        }
+    }
+    *poutbuf = buf;
+    *poutbuf_size = buf_size;
+    return next;
+}
+
+static int latm_split(AVCodecContext *avctx,
+                           const uint8_t *buf, int buf_size)
+{
+    int i;
+    uint32_t state= -1;
+
+    for(i=0; i<buf_size; i++){
+        state= (state<<8) | buf[i];
+        if((state & LATM_MASK) == LATM_HEADER)
+            return i-2;
+    }
+    return 0;
+}
+
+AVCodecParser aac_latm_parser = {
+    { CODEC_ID_AAC_LATM },
+    sizeof(LATMParseContext),
+    NULL,
+    latm_parse,
+    ff_parse_close,
+    latm_split,
+};
diff --git a/libavcodec/latmaac.c b/libavcodec/latmaac.c
new file mode 100644
index 0000000..6d46c68
--- /dev/null
+++ b/libavcodec/latmaac.c
@@ -0,0 +1,624 @@
+/*
+ * copyright (c) 2008 Paul Kendall <paul@kcbbs.gen.nz>
+ *
+ * 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 latmaac.c
+ * LATM wrapped AAC decoder
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+#include <sys/types.h>
+
+#include "parser.h"
+#include "bitstream.h"
+#include "mpeg4audio.h"
+#include "neaacdec.h"
+
+#define min(a,b) ((a)<(b) ? (a) : (b))
+
+
+/*
+    Note: This decoder filter is intended to decode LATM streams transferred
+    in MPEG transport streams which are only supposed to contain one program.
+    To do a more complex LATM demuxing a separate LATM demuxer should be used.
+*/
+
+#define AAC_NONE 0            // mode not detected (or indicated in mediatype)
+#define AAC_LATM 1            // LATM packets (ISO/IEC 14496-3  1.7.3 Multiplex layer)
+
+#define SYNC_LATM 0x2b7            // 11 bits
+
+#define MAX_SIZE 8*1024
+
+typedef struct AACConfig
+{
+    uint8_t    extra[64];            // should be way enough
+    int        extrasize;
+
+    int        audioObjectType;
+    int        samplingFrequencyIndex;
+    int        samplingFrequency;
+    int        channelConfiguration;
+    int        channels;
+} AACConfig;
+
+typedef struct AACParser
+{
+    AACConfig          config;
+    uint8_t            frameLengthType;
+    uint16_t           muxSlotLengthBytes;
+
+    uint8_t            audio_mux_version;
+    uint8_t            audio_mux_version_A;
+    int                taraFullness;
+    uint8_t            config_crc;
+    int64_t            other_data_bits;
+
+    int                mode;
+    int                offset;        // byte offset in "buf" buffer
+    uint8_t            buf[MAX_SIZE]; // allocated buffer
+    int                count;         // number of bytes written in buffer
+} AACParser;
+
+typedef struct AACDecoder 
+{
+    AACParser          *parser;
+    faacDecHandle      aac_decoder;
+    int                open;
+    uint32_t           in_samplerate;
+    uint8_t            in_channels;
+} AACDecoder;
+
+typedef struct {
+    AACDecoder*        decoder;
+} FAACContext;
+
+static inline int64_t latm_get_value(GetBitContext *b)
+{
+    uint8_t bytesForValue = get_bits(b, 2);
+    int64_t value = 0;
+    int i;
+    for (i=0; i<=bytesForValue; i++) {
+        value <<= 8;
+        value |= get_bits(b, 8);
+    }
+    return value;
+}
+
+static void readGASpecificConfig(struct AACConfig *cfg, GetBitContext *b, PutBitContext *o)
+{
+    int framelen_flag = get_bits(b, 1);
+    put_bits(o, 1, framelen_flag);
+    int dependsOnCoder = get_bits(b, 1);
+    put_bits(o, 1, dependsOnCoder);
+    int ext_flag;
+    int delay;
+    int layerNr;
+
+    if (dependsOnCoder) {
+        delay = get_bits(b, 14);
+        put_bits(o, 14, delay);
+    }
+    ext_flag = get_bits(b, 1);
+    put_bits(o, 1, ext_flag);
+    if (!cfg->channelConfiguration) {
+        // program config element
+        // TODO:
+    }
+
+    if (cfg->audioObjectType == 6 || cfg->audioObjectType == 20) {
+        layerNr = get_bits(b, 3);
+        put_bits(o, 3, layerNr);
+    }
+    if (ext_flag) {
+        if (cfg->audioObjectType == 22) {
+            skip_bits(b, 5);                    // numOfSubFrame
+            skip_bits(b, 11);                    // layer_length
+
+            put_bits(o, 16, 0);
+        }
+        if (cfg->audioObjectType == 17 ||
+            cfg->audioObjectType == 19 ||
+            cfg->audioObjectType == 20 ||
+            cfg->audioObjectType == 23) {
+
+            skip_bits(b, 3);                    // stuff
+            put_bits(o, 3, 0);
+        }
+
+        skip_bits(b, 1);                        // extflag3
+        put_bits(o, 1, 0);
+    }
+}
+
+static int readAudioSpecificConfig(struct AACConfig *cfg, GetBitContext *b)
+{
+    PutBitContext o;
+    init_put_bits(&o, cfg->extra, sizeof(cfg->extra));
+
+    // returns the number of bits read
+    int ret = 0;
+    int sbr_present = -1;
+
+    // object
+    cfg->audioObjectType = get_bits(b, 5);
+        put_bits(&o, 5, cfg->audioObjectType);
+    if (cfg->audioObjectType == 31) {
+        uint8_t n = get_bits(b, 6);
+        put_bits(&o, 6, n);
+        cfg->audioObjectType = 32 + n;
+    }
+
+    cfg->samplingFrequencyIndex = get_bits(b, 4);
+    cfg->samplingFrequency = ff_mpeg4audio_sample_rates[cfg->samplingFrequencyIndex];
+    put_bits(&o, 4, cfg->samplingFrequencyIndex);
+    if (cfg->samplingFrequencyIndex == 0x0f) {
+        uint32_t f = get_bits_long(b, 24);
+        put_bits(&o, 24, f);
+        cfg->samplingFrequency = f;
+    }
+    cfg->channelConfiguration = get_bits(b, 4);
+    put_bits(&o, 4, cfg->channelConfiguration);
+    cfg->channels = ff_mpeg4audio_channels[cfg->channelConfiguration];
+
+    if (cfg->audioObjectType == 5) {
+        sbr_present = 1;
+
+        // TODO: parsing !!!!!!!!!!!!!!!!
+    }
+
+    switch (cfg->audioObjectType) {
+    case 1:
+    case 2:
+    case 3:
+    case 4:
+    case 6:
+    case 7:
+    case 17:
+    case 19:
+    case 20:
+    case 21:
+    case 22:
+    case 23:
+        readGASpecificConfig(cfg, b, &o);
+        break;
+    }
+
+    if (sbr_present == -1) {
+        if (cfg->samplingFrequency <= 24000) {
+            cfg->samplingFrequency *= 2;
+        }            
+    }
+
+    // count the extradata
+    ret = put_bits_count(&o);
+    align_put_bits(&o);
+    flush_put_bits(&o);
+    cfg->extrasize = (ret + 7) >> 3;
+    return ret;
+}
+
+static void readStreamMuxConfig(struct AACParser *parser, GetBitContext *b)
+{
+    parser->audio_mux_version_A = 0;
+    parser->audio_mux_version = get_bits(b, 1);
+    if (parser->audio_mux_version == 1) {                // audioMuxVersion
+        parser->audio_mux_version_A = get_bits(b, 1);
+    }
+
+    if (parser->audio_mux_version_A == 0) {
+        if (parser->audio_mux_version == 1) {
+            parser->taraFullness = latm_get_value(b);
+        }
+        get_bits(b, 1);                    // allStreamSameTimeFraming = 1
+        get_bits(b, 6);                    // numSubFrames = 0
+        get_bits(b, 4);                    // numPrograms = 0
+
+        // for each program
+        get_bits(b, 3);                    // numLayer = 0
+
+        // for each layer
+        if (parser->audio_mux_version == 0) {
+            // audio specific config.
+            readAudioSpecificConfig(&parser->config, b);
+        } else {
+            int ascLen = latm_get_value(b);
+            ascLen -= readAudioSpecificConfig(&parser->config, b);
+
+            // fill bits
+            while (ascLen > 16) {
+                skip_bits(b, 16);
+                ascLen -= 16;
+            }
+            skip_bits(b, ascLen);                    
+        }
+
+        // these are not needed... perhaps
+        int frame_length_type = get_bits(b, 3);
+        parser->frameLengthType = frame_length_type;
+        if (frame_length_type == 0) {
+            get_bits(b, 8);
+        } else if (frame_length_type == 1) {
+            get_bits(b, 9);
+        } else if (frame_length_type == 3 ||
+            frame_length_type == 4 ||
+            frame_length_type == 5) {
+            int celp_table_index = get_bits(b, 6);
+        } else if (frame_length_type == 6 ||
+            frame_length_type == 7) {
+            int hvxc_table_index = get_bits(b, 1);
+        }
+
+        // other data
+        parser->other_data_bits = 0;
+        if (get_bits(b, 1)) {
+            // other data present
+            if (parser->audio_mux_version == 1) {
+                parser->other_data_bits = latm_get_value(b);
+            } else {
+                // other data not present
+                parser->other_data_bits = 0;
+                int esc, tmp;
+                do {
+                    parser->other_data_bits <<= 8;
+                    esc = get_bits(b, 1);
+                    tmp = get_bits(b, 8);
+                    parser->other_data_bits |= tmp;
+                } while (esc);
+            }
+        }
+
+        // CRC
+        if (get_bits(b, 1)) {
+            parser->config_crc = get_bits(b, 8);
+        }
+    } else {
+        // tbd
+    }
+}
+
+static void readPayloadLengthInfo(struct AACParser *parser, GetBitContext *b)
+{
+    uint8_t tmp;
+    if (parser->frameLengthType == 0) {
+        parser->muxSlotLengthBytes = 0;
+        do {
+            tmp = get_bits(b, 8);
+            parser->muxSlotLengthBytes += tmp;
+        } while (tmp == 255);
+    } else {
+        if (parser->frameLengthType == 5 ||
+            parser->frameLengthType == 7 ||
+            parser->frameLengthType == 3) {
+            get_bits(b, 2);
+        }
+    }
+}
+
+static void readAudioMuxElement(struct AACParser *parser, GetBitContext *b, uint8_t *payload, int *payloadsize)
+{
+    uint8_t    use_same_mux = get_bits(b, 1);
+    if (!use_same_mux) {
+        readStreamMuxConfig(parser, b);
+    }
+
+    if (parser->audio_mux_version_A == 0) {
+        int j;
+
+        readPayloadLengthInfo(parser, b);
+
+        // copy data
+        for (j=0; j<parser->muxSlotLengthBytes; j++) {
+            *payload++ = get_bits(b, 8);
+        }
+        *payloadsize = parser->muxSlotLengthBytes;
+
+        // ignore otherdata
+    } else {
+        // TBD
+    }
+}
+
+static int readAudioSyncStream(struct AACParser *parser, GetBitContext *b, int size, uint8_t *payload, int *payloadsize)
+{
+    // ISO/IEC 14496-3 Table 1.28 - Syntax of AudioMuxElement()
+    if (get_bits(b, 11) != 0x2b7) return -1;        // not LATM
+    int muxlength = get_bits(b, 13);
+
+    if (3+muxlength > size) return 0;            // not enough data
+
+    readAudioMuxElement(parser, b, payload, payloadsize);
+
+    // we don't parse anything else here...
+    return (3+muxlength);
+}
+
+
+static void flush_buf(struct AACParser *parser, int offset) {
+    int bytes_to_flush = min(parser->count, offset);
+    int left = (parser->count - bytes_to_flush);
+
+    if (bytes_to_flush > 0) {
+        if (left > 0) {
+            memcpy(parser->buf, parser->buf+bytes_to_flush, left);
+            parser->count = left;
+        } else {
+            parser->count = 0;
+        }
+    }
+}
+
+static struct AACParser *latm_create_parser()
+{
+    struct AACParser *parser = (struct AACParser *)av_malloc(sizeof(struct AACParser));
+    memset(parser, 0, sizeof(struct AACParser));
+    return parser;
+}
+
+static void latm_destroy_parser(struct AACParser *parser)
+{
+    av_free(parser);
+}
+
+static void latm_flush(struct AACParser *parser)
+{
+    parser->offset = 0;
+    parser->count = 0;
+}
+
+static void latm_write_data(struct AACParser *parser, uint8_t *data, int len)
+{
+    // buffer overflow check... just ignore the data before
+    if (parser->count + len > MAX_SIZE) {
+        flush_buf(parser, parser->offset);
+        parser->offset = 0;
+        if (parser->count + len > MAX_SIZE) {
+            int to_flush = (parser->count+len) - MAX_SIZE;
+            flush_buf(parser, to_flush);
+        }
+    }
+
+    // append data
+    memcpy(parser->buf+parser->count, data, len);
+    parser->count += len;
+}
+
+static int latm_parse_packet(struct AACParser *parser, uint8_t *data, int maxsize)
+{
+    /*
+        Return value is either number of bytes parsed or
+        -1 when failed.
+        0 = need more data.
+    */
+
+    uint8_t    *start = parser->buf + parser->offset;
+    int        bytes  = parser->count - parser->offset;
+    GetBitContext    b;
+    init_get_bits(&b, start, bytes);
+
+    if (parser->mode == AAC_LATM) {
+        int outsize = 0;
+        int    ret = readAudioSyncStream(parser, &b, bytes, data, &outsize);
+
+        if (ret < 0) return -1;
+        if (ret == 0) return 0;
+
+        // update the offset
+        parser->offset += ret;
+        return outsize;
+    }
+
+    // check for syncwords
+    while (bytes > 2) {
+        if (show_bits(&b, 11) == SYNC_LATM) {
+            // we must parse config first...
+            int outsize = 0;
+
+            // check if there is a complete packet available...
+            int ret = readAudioSyncStream(parser, &b, bytes, data, &outsize);
+            if (ret < 0) return -1;
+            if (ret == 0) return 0;
+            parser->offset += ret;
+
+            parser->mode = AAC_LATM;
+            return outsize;
+        }
+        skip_bits(&b, 8);
+        parser->offset++;
+        bytes--;
+    }
+    return 0;
+}
+
+static void aac_filter_close(AACDecoder *decoder)
+{
+    if (decoder->aac_decoder) {
+        NeAACDecClose(decoder->aac_decoder);
+        decoder->aac_decoder = NULL;
+    }
+    decoder->open = 0;
+}
+
+static int aac_decoder_open(AACDecoder *decoder)
+{
+    if (decoder->aac_decoder) return 0;
+
+    decoder->aac_decoder = NeAACDecOpen();
+    if (!decoder->aac_decoder) return -1;
+
+    // are we going to initialize from decoder specific info ?
+    if (decoder->parser->config.extrasize > 0) {
+        char ret = NeAACDecInit2(decoder->aac_decoder, (unsigned char*)decoder->parser->config.extra, decoder->parser->config.extrasize, &decoder->in_samplerate, &decoder->in_channels);
+        if (ret < 0) {
+            aac_filter_close(decoder);        // gone wrong ?
+            return -1;
+        }
+        decoder->open = 1;
+    } else {
+        // we'll open the decoder later...
+        decoder->open = 0;
+    }
+    return 0;
+}
+
+AACDecoder *aac_filter_create()
+{
+    AACDecoder *decoder = (AACDecoder *)av_malloc(sizeof(AACDecoder));
+    decoder->parser = latm_create_parser();
+    decoder->aac_decoder = NULL;
+    decoder->open = 0;
+    return (void *)decoder;
+}
+
+void aac_filter_destroy(AACDecoder *decoder)
+{
+    aac_filter_close(decoder);
+    latm_destroy_parser(decoder->parser);
+    av_free(decoder);
+}
+
+int aac_filter_receive(AACDecoder *decoder, void *out, int *out_size, uint8_t *data, int size)
+{
+    uint8_t    tempbuf[32*1024];
+    int        ret;
+    int        consumed = size;
+    int        decoded;
+    int        max_size = *out_size;
+    
+    *out_size = 0;
+
+    //-------------------------------------------------------------------------
+    // Multiplex Parsing
+    //-------------------------------------------------------------------------
+
+    latm_write_data(decoder->parser, data, size);
+
+    do {
+        ret = latm_parse_packet(decoder->parser, tempbuf, sizeof(tempbuf));
+                if (ret < 0) {
+                        latm_flush(decoder->parser);
+                        return consumed;
+                }
+        if (ret == 0) return consumed;
+
+        data = tempbuf;
+        size = ret;
+
+        //-------------------------------------------------------------------------
+        // Initialize decoder (if necessary)
+        //-------------------------------------------------------------------------
+        if (!decoder->open) {
+            aac_filter_close(decoder);
+            if (decoder->parser->mode == AAC_LATM) {
+                ret = aac_decoder_open(decoder);
+                if (ret < 0) return consumed;
+            }
+
+            if(!decoder->open) return consumed;
+        }
+
+        //-------------------------------------------------------------------------
+        // Decode samples
+        //-------------------------------------------------------------------------
+        NeAACDecFrameInfo    info;
+        void *buf = NeAACDecDecode(decoder->aac_decoder, &info, data, size);
+
+        if (buf) {
+            decoder->in_samplerate = info.samplerate;
+            decoder->in_channels = info.channels;
+
+            //---------------------------------------------------------------------
+            // Deliver decoded samples
+            //---------------------------------------------------------------------
+
+            // kram dekoduje 16-bit. my vypustame 16-bit. takze by to malo byt okej
+            decoded = info.samples * sizeof(short);
+
+            // napraskame tam sample
+            *out_size += decoded;
+            if(*out_size > max_size) {
+                av_log(NULL, AV_LOG_ERROR, "overflow!\n");
+            } else {
+                memcpy(out, buf, decoded);
+                out = (unsigned char *)out + decoded;
+            }
+        } else {
+            // need more data
+            break;
+        }
+
+    } while (1);    // decode all packets
+    return consumed;
+}
+
+void aac_filter_getinfo(AACDecoder *decoder, int *sample_rate, int *channels)
+{
+    if(!decoder->open) return;
+    *sample_rate = decoder->in_samplerate;
+    *channels = decoder->in_channels;
+}
+
+static int faac_decode_init(AVCodecContext *avctx)
+{
+    FAACContext *s = avctx->priv_data;
+    avctx->frame_size = 360;
+    avctx->sample_rate = 48000;
+    avctx->channels = 2;
+    avctx->bit_rate = 8192 * 8 * avctx->sample_rate / avctx->frame_size;
+    s->decoder = aac_filter_create();
+    return 0;
+}
+
+static int faac_decode_frame(AVCodecContext *avctx,
+                             void *data, int *data_size,
+                             uint8_t *buf, int buf_size)
+{
+    FAACContext *s = avctx->priv_data;
+    int ret;
+
+    if (s->decoder == NULL) faac_decode_init(avctx);
+    ret = aac_filter_receive(s->decoder, data, data_size, buf, buf_size);
+    aac_filter_getinfo(s->decoder, &(avctx->sample_rate), &(avctx->channels));
+    return ret;
+}
+
+static int faac_decode_end(AVCodecContext *avctx)
+{
+    FAACContext *s = avctx->priv_data;
+    if(s->decoder != NULL) {
+        aac_filter_destroy(s->decoder);
+    }
+    return 0;
+}
+
+AVCodec libfaad2_decoder = {
+    .name = "AAC_LATM",
+    .type = CODEC_TYPE_AUDIO,
+    .id = CODEC_ID_AAC_LATM,
+    .priv_data_size = sizeof (FAACContext),
+    .init = faac_decode_init,
+    .close = faac_decode_end,
+    .decode = faac_decode_frame,
+    .long_name = "AAC over LATM",
+};
+
diff --git a/libavcodec/lcl.h b/libavcodec/lcl.h
old mode 100644
new mode 100755
diff --git a/libavcodec/lcldec.c b/libavcodec/lcldec.c
old mode 100644
new mode 100755
diff --git a/libavcodec/lclenc.c b/libavcodec/lclenc.c
old mode 100644
new mode 100755
diff --git a/libavcodec/libamr.c b/libavcodec/libamr.c
old mode 100644
new mode 100755
index cfbd1bb..6a9de50
--- a/libavcodec/libamr.c
+++ b/libavcodec/libamr.c
@@ -25,13 +25,22 @@
  * This code implements both an AMR-NarrowBand (AMR-NB) and an AMR-WideBand
  * (AMR-WB) audio encoder/decoder through external reference code from
  * http://www.3gpp.org/. The license of the code from 3gpp is unclear so you
- * have to download the code separately.
+ * have to download the code separately. Two versions exists: One fixed-point
+ * and one floating-point. For some reason the float encoder is significantly
+ * faster at least on a P4 1.5GHz (0.9s instead of 9.9s on a 30s audio clip
+ * at MR102). Both float and fixed point are supported for AMR-NB, but only
+ * float for AMR-WB.
  *
  * \section AMR-NB
  *
+ * \subsection Float
  * The float version (default) can be downloaded from:
  * http://www.3gpp.org/ftp/Specs/archive/26_series/26.104/26104-610.zip
  *
+ * \subsection Fixed-point
+ * The fixed-point (TS26.073) can be downloaded from:
+ * http://www.3gpp.org/ftp/Specs/archive/26_series/26.073/26073-600.zip
+ *
  * \subsection Specification
  * The specification for AMR-NB can be found in TS 26.071
  * (http://www.3gpp.org/ftp/Specs/html-info/26071.htm) and some other
@@ -39,9 +48,14 @@
  *
  * \section AMR-WB
  *
+ * \subsection Float
  * The reference code can be downloaded from:
  * http://www.3gpp.org/ftp/Specs/archive/26_series/26.204/26204-600.zip
  *
+ * \subsection Fixed-point
+ * If someone wants to use the fixed point version it can be downloaded from:
+ * http://www.3gpp.org/ftp/Specs/archive/26_series/26.173/26173-571.zip.
+ *
  * \subsection Specification
  * The specification for AMR-WB can be found in TS 26.171
  * (http://www.3gpp.org/ftp/Specs/html-info/26171.htm) and some other
@@ -51,30 +65,31 @@
 
 #include "avcodec.h"
 
-static void amr_decode_fix_avctx(AVCodecContext *avctx)
-{
-    const int is_amr_wb = 1 + (avctx->codec_id == CODEC_ID_AMR_WB);
+#if CONFIG_LIBAMR_NB_FIXED
 
-    if (!avctx->sample_rate)
-        avctx->sample_rate = 8000 * is_amr_wb;
+#define MMS_IO
 
-    if (!avctx->channels)
-        avctx->channels = 1;
+#include "amr/sp_dec.h"
+#include "amr/d_homing.h"
+#include "amr/typedef.h"
+#include "amr/sp_enc.h"
+#include "amr/sid_sync.h"
+#include "amr/e_homing.h"
 
-    avctx->frame_size = 160 * is_amr_wb;
-    avctx->sample_fmt = SAMPLE_FMT_S16;
-}
-
-#if CONFIG_LIBAMR_NB
-
+#else
 #include <amrnb/interf_dec.h>
 #include <amrnb/interf_enc.h>
+#endif
 
 static const char nb_bitrate_unsupported[] =
     "bitrate not supported: use one of 4.75k, 5.15k, 5.9k, 6.7k, 7.4k, 7.95k, 10.2k or 12.2k\n";
+static const char wb_bitrate_unsupported[] =
+    "bitrate not supported: use one of 6.6k, 8.85k, 12.65k, 14.25k, 15.85k, 18.25k, 19.85k, 23.05k, or 23.85k\n";
 
-typedef struct AMR_bitrates {
-    int       rate;
+/* Common code for fixed and float version*/
+typedef struct AMR_bitrates
+{
+    int rate;
     enum Mode mode;
 } AMR_bitrates;
 
@@ -82,44 +97,86 @@
 static int getBitrateMode(int bitrate)
 {
     /* make the correspondance between bitrate and mode */
-    AMR_bitrates rates[] = { { 4750, MR475},
-                             { 5150, MR515},
-                             { 5900, MR59},
-                             { 6700, MR67},
-                             { 7400, MR74},
-                             { 7950, MR795},
-                             {10200, MR102},
-                             {12200, MR122}, };
+    AMR_bitrates rates[]={ {4750,MR475},
+                           {5150,MR515},
+                           {5900,MR59},
+                           {6700,MR67},
+                           {7400,MR74},
+                           {7950,MR795},
+                           {10200,MR102},
+                           {12200,MR122},
+                         };
     int i;
 
-    for (i = 0; i < 8; i++)
-        if (rates[i].rate == bitrate)
+    for(i=0;i<8;i++)
+    {
+        if(rates[i].rate==bitrate)
+        {
             return rates[i].mode;
+        }
+    }
     /* no bitrate matching, return an error */
     return -1;
 }
 
+static void amr_decode_fix_avctx(AVCodecContext * avctx)
+{
+    const int is_amr_wb = 1 + (avctx->codec_id == CODEC_ID_AMR_WB);
+
+    if(avctx->sample_rate == 0)
+    {
+        avctx->sample_rate = 8000 * is_amr_wb;
+    }
+
+    if(avctx->channels == 0)
+    {
+        avctx->channels = 1;
+    }
+
+    avctx->frame_size = 160 * is_amr_wb;
+    avctx->sample_fmt = SAMPLE_FMT_S16;
+}
+
+#if CONFIG_LIBAMR_NB_FIXED
+/* fixed point version*/
+/* frame size in serial bitstream file (frame type + serial stream + flags) */
+#define SERIAL_FRAMESIZE (1+MAX_SERIAL_SIZE+5)
+
 typedef struct AMRContext {
-    int   frameCount;
-    void *decState;
-    int  *enstate;
-    int   enc_bitrate;
+    int frameCount;
+    Speech_Decode_FrameState *speech_decoder_state;
+    enum RXFrameType rx_type;
+    enum Mode mode;
+    Word16 reset_flag;
+    Word16 reset_flag_old;
+
+    int enc_bitrate;
+    Speech_Encode_FrameState *enstate;
+    sid_syncState *sidstate;
+    enum TXFrameType tx_frametype;
 } AMRContext;
 
-static av_cold int amr_nb_decode_init(AVCodecContext *avctx)
+static av_cold int amr_nb_decode_init(AVCodecContext * avctx)
 {
     AMRContext *s = avctx->priv_data;
 
-    s->frameCount = 0;
-    s->decState   = Decoder_Interface_init();
-    if (!s->decState) {
-        av_log(avctx, AV_LOG_ERROR, "Decoder_Interface_init error\r\n");
+    s->frameCount=0;
+    s->speech_decoder_state=NULL;
+    s->rx_type = (enum RXFrameType)0;
+    s->mode= (enum Mode)0;
+    s->reset_flag=0;
+    s->reset_flag_old=1;
+
+    if(Speech_Decode_Frame_init(&s->speech_decoder_state, "Decoder"))
+    {
+        av_log(avctx, AV_LOG_ERROR, "Speech_Decode_Frame_init error\n");
         return -1;
     }
 
     amr_decode_fix_avctx(avctx);
 
-    if (avctx->channels > 1) {
+    if(avctx->channels > 1)
+    {
         av_log(avctx, AV_LOG_ERROR, "amr_nb: multichannel decoding not supported\n");
         return -1;
     }
@@ -127,7 +184,245 @@
     return 0;
 }
 
-static av_cold int amr_nb_decode_close(AVCodecContext *avctx)
+static av_cold int amr_nb_encode_init(AVCodecContext * avctx)
+{
+    AMRContext *s = avctx->priv_data;
+
+    s->frameCount=0;
+    s->speech_decoder_state=NULL;
+    s->rx_type = (enum RXFrameType)0;
+    s->mode= (enum Mode)0;
+    s->reset_flag=0;
+    s->reset_flag_old=1;
+
+    if(avctx->sample_rate!=8000)
+    {
+        av_log(avctx, AV_LOG_ERROR, "Only 8000Hz sample rate supported\n");
+        return -1;
+    }
+
+    if(avctx->channels!=1)
+    {
+        av_log(avctx, AV_LOG_ERROR, "Only mono supported\n");
+        return -1;
+    }
+
+    avctx->frame_size=160;
+    avctx->coded_frame= avcodec_alloc_frame();
+
+    if(Speech_Encode_Frame_init(&s->enstate, 0, "encoder") || sid_sync_init (&s->sidstate))
+    {
+        av_log(avctx, AV_LOG_ERROR, "Speech_Encode_Frame_init error\n");
+        return -1;
+    }
+
+    if((s->enc_bitrate=getBitrateMode(avctx->bit_rate))<0)
+    {
+        av_log(avctx, AV_LOG_ERROR, nb_bitrate_unsupported);
+        return -1;
+    }
+
+    return 0;
+}
+
+static av_cold int amr_nb_encode_close(AVCodecContext * avctx)
+{
+    AMRContext *s = avctx->priv_data;
+
+    Speech_Encode_Frame_exit(&s->enstate);
+    sid_sync_exit (&s->sidstate);
+    av_freep(&avctx->coded_frame);
+    return 0;
+}
+
+static av_cold int amr_nb_decode_close(AVCodecContext * avctx)
+{
+    AMRContext *s = avctx->priv_data;
+
+    Speech_Decode_Frame_exit(&s->speech_decoder_state);
+    return 0;
+}
+
+static int amr_nb_decode_frame(AVCodecContext * avctx,
+            void *data, int *data_size,
+            const uint8_t * buf, int buf_size)
+{
+    AMRContext *s = avctx->priv_data;
+    const uint8_t*amrData=buf;
+    int offset=0;
+    UWord8 toc, q, ft;
+    Word16 serial[SERIAL_FRAMESIZE];   /* coded bits */
+    Word16 *synth;
+    UWord8 *packed_bits;
+    static Word16 packed_size[16] = {12, 13, 15, 17, 19, 20, 26, 31, 5, 0, 0, 0, 0, 0, 0, 0};
+    int i;
+
+    //printf("amr_decode_frame data_size=%i buf=0x%X buf_size=%d frameCount=%d!!\n",*data_size,buf,buf_size,s->frameCount);
+
+    synth=data;
+
+    toc=amrData[offset];
+    /* read rest of the frame based on ToC byte */
+    q  = (toc >> 2) & 0x01;
+    ft = (toc >> 3) & 0x0F;
+
+    //printf("offset=%d, packet_size=%d amrData= 0x%X %X %X %X\n",offset,packed_size[ft],amrData[offset],amrData[offset+1],amrData[offset+2],amrData[offset+3]);
+
+    offset++;
+
+    packed_bits=amrData+offset;
+
+    offset+=packed_size[ft];
+
+    //Unsort and unpack bits
+    s->rx_type = UnpackBits(q, ft, packed_bits, &s->mode, &serial[1]);
+
+    //We have a new frame
+    s->frameCount++;
+
+    if (s->rx_type == RX_NO_DATA)
+    {
+        s->mode = s->speech_decoder_state->prev_mode;
+    }
+    else {
+        s->speech_decoder_state->prev_mode = s->mode;
+    }
+
+    /* if homed: check if this frame is another homing frame */
+    if (s->reset_flag_old == 1)
+    {
+        /* only check until end of first subframe */
+        s->reset_flag = decoder_homing_frame_test_first(&serial[1], s->mode);
+    }
+    /* produce encoder homing frame if homed & input=decoder homing frame */
+    if ((s->reset_flag != 0) && (s->reset_flag_old != 0))
+    {
+        for (i = 0; i < L_FRAME; i++)
+        {
+            synth[i] = EHF_MASK;
+        }
+    }
+    else
+    {
+        /* decode frame */
+        Speech_Decode_Frame(s->speech_decoder_state, s->mode, &serial[1], s->rx_type, synth);
+    }
+
+    //Each AMR-frame results in 160 16-bit samples
+    *data_size=160*2;
+
+    /* if not homed: check whether current frame is a homing frame */
+    if (s->reset_flag_old == 0)
+    {
+        /* check whole frame */
+        s->reset_flag = decoder_homing_frame_test(&serial[1], s->mode);
+    }
+    /* reset decoder if current frame is a homing frame */
+    if (s->reset_flag != 0)
+    {
+        Speech_Decode_Frame_reset(s->speech_decoder_state);
+    }
+    s->reset_flag_old = s->reset_flag;
+
+    return offset;
+}
+
+
+static int amr_nb_encode_frame(AVCodecContext *avctx,
+                            unsigned char *frame/*out*/, int buf_size, void *data/*in*/)
+{
+    short serial_data[250] = {0};
+    AMRContext *s = avctx->priv_data;
+    int written;
+
+    s->reset_flag = encoder_homing_frame_test(data);
+
+    Speech_Encode_Frame(s->enstate, s->enc_bitrate, data, &serial_data[1], &s->mode);
+
+    /* add frame type and mode */
+    sid_sync (s->sidstate, s->mode, &s->tx_frametype);
+
+    written = PackBits(s->mode, s->enc_bitrate, s->tx_frametype, &serial_data[1], frame);
+
+    if (s->reset_flag != 0)
+    {
+        Speech_Encode_Frame_reset(s->enstate);
+        sid_sync_reset(s->sidstate);
+    }
+    return written;
+}
+
+
+#elif CONFIG_LIBAMR_NB /* Float point version*/
+
+typedef struct AMRContext {
+    int frameCount;
+    void * decState;
+    int *enstate;
+    int enc_bitrate;
+} AMRContext;
+
+static av_cold int amr_nb_decode_init(AVCodecContext * avctx)
+{
+    AMRContext *s = avctx->priv_data;
+
+    s->frameCount=0;
+    s->decState=Decoder_Interface_init();
+    if(!s->decState)
+    {
+        av_log(avctx, AV_LOG_ERROR, "Decoder_Interface_init error\r\n");
+        return -1;
+    }
+
+    amr_decode_fix_avctx(avctx);
+
+    if(avctx->channels > 1)
+    {
+        av_log(avctx, AV_LOG_ERROR, "amr_nb: multichannel decoding not supported\n");
+        return -1;
+    }
+
+    return 0;
+}
+
+static av_cold int amr_nb_encode_init(AVCodecContext * avctx)
+{
+    AMRContext *s = avctx->priv_data;
+
+    s->frameCount=0;
+
+    if(avctx->sample_rate!=8000)
+    {
+        av_log(avctx, AV_LOG_ERROR, "Only 8000Hz sample rate supported\n");
+        return -1;
+    }
+
+    if(avctx->channels!=1)
+    {
+        av_log(avctx, AV_LOG_ERROR, "Only mono supported\n");
+        return -1;
+    }
+
+    avctx->frame_size=160;
+    avctx->coded_frame= avcodec_alloc_frame();
+
+    s->enstate=Encoder_Interface_init(0);
+    if(!s->enstate)
+    {
+        av_log(avctx, AV_LOG_ERROR, "Encoder_Interface_init error\n");
+        return -1;
+    }
+
+    if((s->enc_bitrate=getBitrateMode(avctx->bit_rate))<0)
+    {
+        av_log(avctx, AV_LOG_ERROR, nb_bitrate_unsupported);
+        return -1;
+    }
+
+    return 0;
+}
+
+static av_cold int amr_nb_decode_close(AVCodecContext * avctx)
 {
     AMRContext *s = avctx->priv_data;
 
@@ -135,39 +430,72 @@
     return 0;
 }
 
-static int amr_nb_decode_frame(AVCodecContext *avctx, void *data,
-                               int *data_size,
-                               const uint8_t *buf, int buf_size)
+static av_cold int amr_nb_encode_close(AVCodecContext * avctx)
 {
     AMRContext *s = avctx->priv_data;
-    const uint8_t *amrData = buf;
-    static const uint8_t block_size[16] = { 12, 13, 15, 17, 19, 20, 26, 31, 5, 0, 0, 0, 0, 0, 0, 0 };
+
+    Encoder_Interface_exit(s->enstate);
+    av_freep(&avctx->coded_frame);
+    return 0;
+}
+
+static int amr_nb_decode_frame(AVCodecContext * avctx,
+            void *data, int *data_size,
+            const uint8_t * buf, int buf_size)
+{
+    AMRContext *s = avctx->priv_data;
+    const uint8_t*amrData=buf;
+    static const uint8_t block_size[16]={ 12, 13, 15, 17, 19, 20, 26, 31, 5, 0, 0, 0, 0, 0, 0, 0 };
     enum Mode dec_mode;
     int packet_size;
 
-    /* av_log(NULL, AV_LOG_DEBUG, "amr_decode_frame buf=%p buf_size=%d frameCount=%d!!\n",
-              buf, buf_size, s->frameCount); */
+    /* av_log(NULL,AV_LOG_DEBUG,"amr_decode_frame buf=%p buf_size=%d frameCount=%d!!\n",buf,buf_size,s->frameCount); */
 
     dec_mode = (buf[0] >> 3) & 0x000F;
-    packet_size = block_size[dec_mode] + 1;
+    packet_size = block_size[dec_mode]+1;
 
-    if (packet_size > buf_size) {
-        av_log(avctx, AV_LOG_ERROR, "amr frame too short (%u, should be %u)\n",
-               buf_size, packet_size);
+    if(packet_size > buf_size) {
+        av_log(avctx, AV_LOG_ERROR, "amr frame too short (%u, should be %u)\n", buf_size, packet_size);
         return -1;
     }
 
     s->frameCount++;
-    /* av_log(NULL, AV_LOG_DEBUG, "packet_size=%d amrData= 0x%X %X %X %X\n",
-              packet_size, amrData[0], amrData[1], amrData[2], amrData[3]); */
+    /* av_log(NULL,AV_LOG_DEBUG,"packet_size=%d amrData= 0x%X %X %X %X\n",packet_size,amrData[0],amrData[1],amrData[2],amrData[3]); */
     /* call decoder */
     Decoder_Interface_Decode(s->decState, amrData, data, 0);
-    *data_size = 160 * 2;
+    *data_size=160*2;
 
     return packet_size;
 }
 
-AVCodec libamr_nb_decoder = {
+static int amr_nb_encode_frame(AVCodecContext *avctx,
+                            unsigned char *frame/*out*/, int buf_size, void *data/*in*/)
+{
+    AMRContext *s = avctx->priv_data;
+    int written;
+
+    if((s->enc_bitrate=getBitrateMode(avctx->bit_rate))<0)
+    {
+        av_log(avctx, AV_LOG_ERROR, nb_bitrate_unsupported);
+        return -1;
+    }
+
+    written = Encoder_Interface_Encode(s->enstate,
+        s->enc_bitrate,
+        data,
+        frame,
+        0);
+    /* av_log(NULL,AV_LOG_DEBUG,"amr_nb_encode_frame encoded %u bytes, bitrate %u, first byte was %#02x\n",written, s->enc_bitrate, frame[0] ); */
+
+    return written;
+}
+
+#endif
+
+#if CONFIG_LIBAMR_NB || CONFIG_LIBAMR_NB_FIXED
+
+AVCodec libamr_nb_decoder =
+{
     "libamr_nb",
     CODEC_TYPE_AUDIO,
     CODEC_ID_AMR_NB,
@@ -179,69 +507,8 @@
     .long_name = NULL_IF_CONFIG_SMALL("libamr-nb Adaptive Multi-Rate (AMR) Narrow-Band"),
 };
 
-static av_cold int amr_nb_encode_init(AVCodecContext *avctx)
+AVCodec libamr_nb_encoder =
 {
-    AMRContext *s = avctx->priv_data;
-
-    s->frameCount = 0;
-
-    if (avctx->sample_rate != 8000) {
-        av_log(avctx, AV_LOG_ERROR, "Only 8000Hz sample rate supported\n");
-        return -1;
-    }
-
-    if (avctx->channels != 1) {
-        av_log(avctx, AV_LOG_ERROR, "Only mono supported\n");
-        return -1;
-    }
-
-    avctx->frame_size  = 160;
-    avctx->coded_frame = avcodec_alloc_frame();
-
-    s->enstate=Encoder_Interface_init(0);
-    if (!s->enstate) {
-        av_log(avctx, AV_LOG_ERROR, "Encoder_Interface_init error\n");
-        return -1;
-    }
-
-    if ((s->enc_bitrate = getBitrateMode(avctx->bit_rate)) < 0) {
-        av_log(avctx, AV_LOG_ERROR, nb_bitrate_unsupported);
-        return -1;
-    }
-
-    return 0;
-}
-
-static av_cold int amr_nb_encode_close(AVCodecContext *avctx)
-{
-    AMRContext *s = avctx->priv_data;
-
-    Encoder_Interface_exit(s->enstate);
-    av_freep(&avctx->coded_frame);
-    return 0;
-}
-
-static int amr_nb_encode_frame(AVCodecContext *avctx,
-                               unsigned char *frame/*out*/,
-                               int buf_size, void *data/*in*/)
-{
-    AMRContext *s = avctx->priv_data;
-    int written;
-
-    if ((s->enc_bitrate = getBitrateMode(avctx->bit_rate)) < 0) {
-        av_log(avctx, AV_LOG_ERROR, nb_bitrate_unsupported);
-        return -1;
-    }
-
-    written = Encoder_Interface_Encode(s->enstate, s->enc_bitrate, data,
-                                       frame, 0);
-    /* av_log(NULL, AV_LOG_DEBUG, "amr_nb_encode_frame encoded %u bytes, bitrate %u, first byte was %#02x\n",
-              written, s->enc_bitrate, frame[0] ); */
-
-    return written;
-}
-
-AVCodec libamr_nb_encoder = {
     "libamr_nb",
     CODEC_TYPE_AUDIO,
     CODEC_ID_AMR_NB,
@@ -264,80 +531,85 @@
 #define typedef_h
 #endif
 
+#include <amrwb/enc_if.h>
 #include <amrwb/dec_if.h>
 #include <amrwb/if_rom.h>
 
-static const char wb_bitrate_unsupported[] =
-    "bitrate not supported: use one of 6.6k, 8.85k, 12.65k, 14.25k, 15.85k, 18.25k, 19.85k, 23.05k, or 23.85k\n";
-
-typedef struct AMRWB_bitrates {
+/* Common code for fixed and float version*/
+typedef struct AMRWB_bitrates
+{
     int rate;
     int mode;
 } AMRWB_bitrates;
 
-typedef struct AMRWBContext {
-    int    frameCount;
-    void  *state;
-    int    mode;
-    Word16 allow_dtx;
-} AMRWBContext;
-
-#if CONFIG_LIBAMR_WB_ENCODER
-
-#include <amrwb/enc_if.h>
-
 static int getWBBitrateMode(int bitrate)
 {
     /* make the correspondance between bitrate and mode */
-    AMRWB_bitrates rates[] = { { 6600, 0},
-                               { 8850, 1},
-                               {12650, 2},
-                               {14250, 3},
-                               {15850, 4},
-                               {18250, 5},
-                               {19850, 6},
-                               {23050, 7},
-                               {23850, 8}, };
+    AMRWB_bitrates rates[]={ {6600,0},
+                           {8850,1},
+                           {12650,2},
+                           {14250,3},
+                           {15850,4},
+                           {18250,5},
+                           {19850,6},
+                           {23050,7},
+                           {23850,8},
+                         };
     int i;
 
-    for (i = 0; i < 9; i++)
-        if (rates[i].rate == bitrate)
+    for(i=0;i<9;i++)
+    {
+        if(rates[i].rate==bitrate)
+        {
             return rates[i].mode;
+        }
+    }
     /* no bitrate matching, return an error */
     return -1;
 }
 
-static av_cold int amr_wb_encode_init(AVCodecContext *avctx)
+
+typedef struct AMRWBContext {
+    int frameCount;
+    void *state;
+    int mode;
+    Word16 allow_dtx;
+} AMRWBContext;
+
+static int amr_wb_encode_init(AVCodecContext * avctx)
 {
     AMRWBContext *s = avctx->priv_data;
 
-    s->frameCount = 0;
+    s->frameCount=0;
 
-    if (avctx->sample_rate != 16000) {
+    if(avctx->sample_rate!=16000)
+    {
         av_log(avctx, AV_LOG_ERROR, "Only 16000Hz sample rate supported\n");
         return -1;
     }
 
-    if (avctx->channels != 1) {
+    if(avctx->channels!=1)
+    {
         av_log(avctx, AV_LOG_ERROR, "Only mono supported\n");
         return -1;
     }
 
-    if ((s->mode = getWBBitrateMode(avctx->bit_rate)) < 0) {
+    if((s->mode=getWBBitrateMode(avctx->bit_rate))<0)
+    {
         av_log(avctx, AV_LOG_ERROR, wb_bitrate_unsupported);
         return -1;
     }
 
-    avctx->frame_size  = 320;
-    avctx->coded_frame = avcodec_alloc_frame();
+    avctx->frame_size=320;
+    avctx->coded_frame= avcodec_alloc_frame();
 
-    s->state     = E_IF_init();
-    s->allow_dtx = 0;
+    s->state = E_IF_init();
+    s->allow_dtx=0;
 
     return 0;
 }
 
-static int amr_wb_encode_close(AVCodecContext *avctx)
+static int amr_wb_encode_close(AVCodecContext * avctx)
 {
     AMRWBContext *s = avctx->priv_data;
 
@@ -348,13 +620,13 @@
 }
 
 static int amr_wb_encode_frame(AVCodecContext *avctx,
-                               unsigned char *frame/*out*/,
-                               int buf_size, void *data/*in*/)
+                            unsigned char *frame/*out*/, int buf_size, void *data/*in*/)
 {
     AMRWBContext *s = avctx->priv_data;
     int size;
 
-    if ((s->mode = getWBBitrateMode(avctx->bit_rate)) < 0) {
+    if((s->mode=getWBBitrateMode(avctx->bit_rate))<0)
+    {
         av_log(avctx, AV_LOG_ERROR, wb_bitrate_unsupported);
         return -1;
     }
@@ -362,7 +634,76 @@
     return size;
 }
 
-AVCodec libamr_wb_encoder = {
+static int amr_wb_decode_init(AVCodecContext * avctx)
+{
+    AMRWBContext *s = avctx->priv_data;
+
+    s->frameCount=0;
+    s->state = D_IF_init();
+
+    amr_decode_fix_avctx(avctx);
+
+    if(avctx->channels > 1)
+    {
+        av_log(avctx, AV_LOG_ERROR, "amr_wb: multichannel decoding not supported\n");
+        return -1;
+    }
+
+    return 0;
+}
+
+static int amr_wb_decode_frame(AVCodecContext * avctx,
+            void *data, int *data_size,
+            const uint8_t * buf, int buf_size)
+{
+    AMRWBContext *s = avctx->priv_data;
+    const uint8_t*amrData=buf;
+    int mode;
+    int packet_size;
+    static const uint8_t block_size[16] = {18, 23, 33, 37, 41, 47, 51, 59, 61, 6, 6, 0, 0, 0, 1, 1};
+
+    if(buf_size==0) {
+        /* nothing to do */
+        return 0;
+    }
+
+    mode = (amrData[0] >> 3) & 0x000F;
+    packet_size = block_size[mode];
+
+    if(packet_size > buf_size) {
+        av_log(avctx, AV_LOG_ERROR, "amr frame too short (%u, should be %u)\n", buf_size, packet_size+1);
+        return -1;
+    }
+
+    s->frameCount++;
+    D_IF_decode( s->state, amrData, data, _good_frame);
+    *data_size=320*2;
+    return packet_size;
+}
+
+static int amr_wb_decode_close(AVCodecContext * avctx)
+{
+    AMRWBContext *s = avctx->priv_data;
+
+    D_IF_exit(s->state);
+    return 0;
+}
+
+AVCodec libamr_wb_decoder =
+{
+    "libamr_wb",
+    CODEC_TYPE_AUDIO,
+    CODEC_ID_AMR_WB,
+    sizeof(AMRWBContext),
+    amr_wb_decode_init,
+    NULL,
+    amr_wb_decode_close,
+    amr_wb_decode_frame,
+    .long_name = NULL_IF_CONFIG_SMALL("libamr-wb Adaptive Multi-Rate (AMR) Wide-Band"),
+};
+
+AVCodec libamr_wb_encoder =
+{
     "libamr_wb",
     CODEC_TYPE_AUDIO,
     CODEC_ID_AMR_WB,
@@ -375,72 +716,4 @@
     .long_name = NULL_IF_CONFIG_SMALL("libamr-wb Adaptive Multi-Rate (AMR) Wide-Band"),
 };
 
-#endif
-
-static av_cold int amr_wb_decode_init(AVCodecContext *avctx)
-{
-    AMRWBContext *s = avctx->priv_data;
-
-    s->frameCount = 0;
-    s->state      = D_IF_init();
-
-    amr_decode_fix_avctx(avctx);
-
-    if (avctx->channels > 1) {
-        av_log(avctx, AV_LOG_ERROR, "amr_wb: multichannel decoding not supported\n");
-        return -1;
-    }
-
-    return 0;
-}
-
-static int amr_wb_decode_frame(AVCodecContext *avctx,
-                               void *data, int *data_size,
-                               const uint8_t *buf, int buf_size)
-{
-    AMRWBContext *s = avctx->priv_data;
-    const uint8_t *amrData = buf;
-    int mode;
-    int packet_size;
-    static const uint8_t block_size[16] = {18, 24, 33, 37, 41, 47, 51, 59, 61, 6, 6, 0, 0, 0, 1, 1};
-
-    if (!buf_size)
-        /* nothing to do */
-        return 0;
-
-    mode = (amrData[0] >> 3) & 0x000F;
-    packet_size = block_size[mode];
-
-    if (packet_size > buf_size) {
-        av_log(avctx, AV_LOG_ERROR, "amr frame too short (%u, should be %u)\n",
-               buf_size, packet_size + 1);
-        return -1;
-    }
-
-    s->frameCount++;
-    D_IF_decode(s->state, amrData, data, _good_frame);
-    *data_size = 320 * 2;
-    return packet_size;
-}
-
-static int amr_wb_decode_close(AVCodecContext *avctx)
-{
-    AMRWBContext *s = avctx->priv_data;
-
-    D_IF_exit(s->state);
-    return 0;
-}
-
-AVCodec libamr_wb_decoder = {
-    "libamr_wb",
-    CODEC_TYPE_AUDIO,
-    CODEC_ID_AMR_WB,
-    sizeof(AMRWBContext),
-    amr_wb_decode_init,
-    NULL,
-    amr_wb_decode_close,
-    amr_wb_decode_frame,
-    .long_name = NULL_IF_CONFIG_SMALL("libamr-wb Adaptive Multi-Rate (AMR) Wide-Band"),
-};
-
 #endif //CONFIG_LIBAMR_WB
diff --git a/libavcodec/libavcodec.v b/libavcodec/libavcodec.v
deleted file mode 100644
index 561a42c..0000000
--- a/libavcodec/libavcodec.v
+++ /dev/null
@@ -1,3 +0,0 @@
-LIBAVCODEC_$MAJOR {
-        global: *;
-};
diff --git a/libavcodec/libdirac_libschro.c b/libavcodec/libdirac_libschro.c
old mode 100644
new mode 100755
diff --git a/libavcodec/libfaac.c b/libavcodec/libfaac.c
old mode 100644
new mode 100755
diff --git a/libavcodec/libfaad.c b/libavcodec/libfaad.c
old mode 100644
new mode 100755
index 2cb2597..3746886
--- a/libavcodec/libfaad.c
+++ b/libavcodec/libfaad.c
@@ -318,20 +318,14 @@
     return 0;
 }
 
-#define AAC_CODEC(id, name, long_name_) \
-AVCodec name ## _decoder = {    \
-    #name,                      \
-    CODEC_TYPE_AUDIO,           \
-    id,                         \
-    sizeof(FAACContext),        \
-    faac_decode_init,           \
-    NULL,                       \
-    faac_decode_end,            \
-    faac_decode_frame,          \
-    .long_name = NULL_IF_CONFIG_SMALL(long_name_), \
-}
-
-// FIXME - raw AAC files - maybe just one entry will be enough
-AAC_CODEC(CODEC_ID_AAC, libfaad, "libfaad AAC (Advanced Audio Codec)");
-
-#undef AAC_CODEC
+AVCodec libfaad_decoder = {
+    "libfaad",
+    CODEC_TYPE_AUDIO,
+    CODEC_ID_AAC,
+    sizeof(FAACContext),
+    faac_decode_init,
+    NULL,
+    faac_decode_end,
+    faac_decode_frame,
+    .long_name = NULL_IF_CONFIG_SMALL("libfaad AAC (Advanced Audio Codec)"),
+};
diff --git a/libavcodec/libgsm.c b/libavcodec/libgsm.c
old mode 100644
new mode 100755
diff --git a/libavcodec/libmp3lame.c b/libavcodec/libmp3lame.c
old mode 100644
new mode 100755
diff --git a/libavcodec/libopencore-amr.c b/libavcodec/libopencore-amr.c
deleted file mode 100644
index 6ff8c3e..0000000
--- a/libavcodec/libopencore-amr.c
+++ /dev/null
@@ -1,323 +0,0 @@
-/*
- * AMR Audio decoder stub
- * Copyright (c) 2003 the ffmpeg project
- *
- * 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 "avcodec.h"
-
-static void amr_decode_fix_avctx(AVCodecContext *avctx)
-{
-    const int is_amr_wb = 1 + (avctx->codec_id == CODEC_ID_AMR_WB);
-
-    if (!avctx->sample_rate)
-        avctx->sample_rate = 8000 * is_amr_wb;
-
-    if (!avctx->channels)
-        avctx->channels = 1;
-
-    avctx->frame_size = 160 * is_amr_wb;
-    avctx->sample_fmt = SAMPLE_FMT_S16;
-}
-
-#if CONFIG_LIBOPENCORE_AMRNB
-
-#include <opencore-amrnb/interf_dec.h>
-#include <opencore-amrnb/interf_enc.h>
-
-static const char nb_bitrate_unsupported[] =
-    "bitrate not supported: use one of 4.75k, 5.15k, 5.9k, 6.7k, 7.4k, 7.95k, 10.2k or 12.2k\n";
-
-/* Common code for fixed and float version*/
-typedef struct AMR_bitrates {
-    int       rate;
-    enum Mode mode;
-} AMR_bitrates;
-
-/* Match desired bitrate */
-static int getBitrateMode(int bitrate)
-{
-    /* make the correspondance between bitrate and mode */
-    AMR_bitrates rates[] = { { 4750, MR475},
-                             { 5150, MR515},
-                             { 5900, MR59},
-                             { 6700, MR67},
-                             { 7400, MR74},
-                             { 7950, MR795},
-                             {10200, MR102},
-                             {12200, MR122}, };
-    int i;
-
-    for (i = 0; i < 8; i++)
-        if (rates[i].rate == bitrate)
-            return rates[i].mode;
-    /* no bitrate matching, return an error */
-    return -1;
-}
-
-typedef struct AMRContext {
-    int   frameCount;
-    void *decState;
-    int  *enstate;
-    int   enc_bitrate;
-} AMRContext;
-
-static av_cold int amr_nb_decode_init(AVCodecContext *avctx)
-{
-    AMRContext *s = avctx->priv_data;
-
-    s->frameCount = 0;
-    s->decState   = Decoder_Interface_init();
-    if (!s->decState) {
-        av_log(avctx, AV_LOG_ERROR, "Decoder_Interface_init error\r\n");
-        return -1;
-    }
-
-    amr_decode_fix_avctx(avctx);
-
-    if (avctx->channels > 1) {
-        av_log(avctx, AV_LOG_ERROR, "amr_nb: multichannel decoding not supported\n");
-        return -1;
-    }
-
-    return 0;
-}
-
-static av_cold int amr_nb_decode_close(AVCodecContext *avctx)
-{
-    AMRContext *s = avctx->priv_data;
-
-    Decoder_Interface_exit(s->decState);
-    return 0;
-}
-
-static int amr_nb_decode_frame(AVCodecContext *avctx, void *data,
-                               int *data_size,
-                               const uint8_t *buf, int buf_size)
-{
-    AMRContext *s = avctx->priv_data;
-    const uint8_t *amrData = buf;
-    static const uint8_t block_size[16] = { 12, 13, 15, 17, 19, 20, 26, 31, 5, 0, 0, 0, 0, 0, 0, 0 };
-    enum Mode dec_mode;
-    int packet_size;
-
-    /* av_log(NULL, AV_LOG_DEBUG, "amr_decode_frame buf=%p buf_size=%d frameCount=%d!!\n",
-              buf, buf_size, s->frameCount); */
-
-    dec_mode = (buf[0] >> 3) & 0x000F;
-    packet_size = block_size[dec_mode] + 1;
-
-    if (packet_size > buf_size) {
-        av_log(avctx, AV_LOG_ERROR, "amr frame too short (%u, should be %u)\n",
-               buf_size, packet_size);
-        return -1;
-    }
-
-    s->frameCount++;
-    /* av_log(NULL, AV_LOG_DEBUG, "packet_size=%d amrData= 0x%X %X %X %X\n",
-              packet_size, amrData[0], amrData[1], amrData[2], amrData[3]); */
-    /* call decoder */
-    Decoder_Interface_Decode(s->decState, amrData, data, 0);
-    *data_size = 160 * 2;
-
-    return packet_size;
-}
-
-AVCodec libopencore_amrnb_decoder = {
-    "libopencore_amrnb",
-    CODEC_TYPE_AUDIO,
-    CODEC_ID_AMR_NB,
-    sizeof(AMRContext),
-    amr_nb_decode_init,
-    NULL,
-    amr_nb_decode_close,
-    amr_nb_decode_frame,
-    .long_name = NULL_IF_CONFIG_SMALL("OpenCORE Adaptive Multi-Rate (AMR) Narrow-Band"),
-};
-
-static av_cold int amr_nb_encode_init(AVCodecContext *avctx)
-{
-    AMRContext *s = avctx->priv_data;
-
-    s->frameCount = 0;
-
-    if (avctx->sample_rate != 8000) {
-        av_log(avctx, AV_LOG_ERROR, "Only 8000Hz sample rate supported\n");
-        return -1;
-    }
-
-    if (avctx->channels != 1) {
-        av_log(avctx, AV_LOG_ERROR, "Only mono supported\n");
-        return -1;
-    }
-
-    avctx->frame_size  = 160;
-    avctx->coded_frame = avcodec_alloc_frame();
-
-    s->enstate=Encoder_Interface_init(0);
-    if (!s->enstate) {
-        av_log(avctx, AV_LOG_ERROR, "Encoder_Interface_init error\n");
-        return -1;
-    }
-
-    if ((s->enc_bitrate = getBitrateMode(avctx->bit_rate)) < 0) {
-        av_log(avctx, AV_LOG_ERROR, nb_bitrate_unsupported);
-        return -1;
-    }
-
-    return 0;
-}
-
-static av_cold int amr_nb_encode_close(AVCodecContext *avctx)
-{
-    AMRContext *s = avctx->priv_data;
-
-    Encoder_Interface_exit(s->enstate);
-    av_freep(&avctx->coded_frame);
-    return 0;
-}
-
-static int amr_nb_encode_frame(AVCodecContext *avctx,
-                               unsigned char *frame/*out*/,
-                               int buf_size, void *data/*in*/)
-{
-    AMRContext *s = avctx->priv_data;
-    int written;
-
-    if ((s->enc_bitrate = getBitrateMode(avctx->bit_rate)) < 0) {
-        av_log(avctx, AV_LOG_ERROR, nb_bitrate_unsupported);
-        return -1;
-    }
-
-    written = Encoder_Interface_Encode(s->enstate, s->enc_bitrate, data,
-                                       frame, 0);
-    /* av_log(NULL, AV_LOG_DEBUG, "amr_nb_encode_frame encoded %u bytes, bitrate %u, first byte was %#02x\n",
-              written, s->enc_bitrate, frame[0] ); */
-
-    return written;
-}
-
-AVCodec libopencore_amrnb_encoder = {
-    "libopencore_amrnb",
-    CODEC_TYPE_AUDIO,
-    CODEC_ID_AMR_NB,
-    sizeof(AMRContext),
-    amr_nb_encode_init,
-    amr_nb_encode_frame,
-    amr_nb_encode_close,
-    NULL,
-    .sample_fmts = (enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE},
-    .long_name = NULL_IF_CONFIG_SMALL("OpenCORE Adaptive Multi-Rate (AMR) Narrow-Band"),
-};
-
-#endif
-
-/* -----------AMR wideband ------------*/
-#if CONFIG_LIBOPENCORE_AMRWB
-
-#ifdef _TYPEDEF_H
-//To avoid duplicate typedefs from typedef in amr-nb
-#define typedef_h
-#endif
-
-#include <opencore-amrwb/dec_if.h>
-#include <opencore-amrwb/if_rom.h>
-
-static const char wb_bitrate_unsupported[] =
-    "bitrate not supported: use one of 6.6k, 8.85k, 12.65k, 14.25k, 15.85k, 18.25k, 19.85k, 23.05k, or 23.85k\n";
-
-/* Common code for fixed and float version*/
-typedef struct AMRWB_bitrates {
-    int rate;
-    int mode;
-} AMRWB_bitrates;
-
-typedef struct AMRWBContext {
-    int    frameCount;
-    void  *state;
-    int    mode;
-    Word16 allow_dtx;
-} AMRWBContext;
-
-static av_cold int amr_wb_decode_init(AVCodecContext *avctx)
-{
-    AMRWBContext *s = avctx->priv_data;
-
-    s->frameCount = 0;
-    s->state      = D_IF_init();
-
-    amr_decode_fix_avctx(avctx);
-
-    if (avctx->channels > 1) {
-        av_log(avctx, AV_LOG_ERROR, "amr_wb: multichannel decoding not supported\n");
-        return -1;
-    }
-
-    return 0;
-}
-
-static int amr_wb_decode_frame(AVCodecContext *avctx,
-                               void *data, int *data_size,
-                               const uint8_t *buf, int buf_size)
-{
-    AMRWBContext *s = avctx->priv_data;
-    const uint8_t *amrData = buf;
-    int mode;
-    int packet_size;
-    static const uint8_t block_size[16] = {18, 24, 33, 37, 41, 47, 51, 59, 61, 6, 6, 0, 0, 0, 1, 1};
-
-    if (!buf_size)
-        /* nothing to do */
-        return 0;
-
-    mode = (amrData[0] >> 3) & 0x000F;
-    packet_size = block_size[mode];
-
-    if (packet_size > buf_size) {
-        av_log(avctx, AV_LOG_ERROR, "amr frame too short (%u, should be %u)\n",
-               buf_size, packet_size + 1);
-        return -1;
-    }
-
-    s->frameCount++;
-    D_IF_decode(s->state, amrData, data, _good_frame);
-    *data_size = 320 * 2;
-    return packet_size;
-}
-
-static int amr_wb_decode_close(AVCodecContext *avctx)
-{
-    AMRWBContext *s = avctx->priv_data;
-
-    D_IF_exit(s->state);
-    return 0;
-}
-
-AVCodec libopencore_amrwb_decoder = {
-    "libopencore_amrwb",
-    CODEC_TYPE_AUDIO,
-    CODEC_ID_AMR_WB,
-    sizeof(AMRWBContext),
-    amr_wb_decode_init,
-    NULL,
-    amr_wb_decode_close,
-    amr_wb_decode_frame,
-    .long_name = NULL_IF_CONFIG_SMALL("OpenCORE Adaptive Multi-Rate (AMR) Wide-Band"),
-};
-
-#endif /* CONFIG_LIBOPENCORE_AMRWB */
diff --git a/libavcodec/libschroedinger.c b/libavcodec/libschroedinger.c
old mode 100644
new mode 100755
diff --git a/libavcodec/libvorbis.c b/libavcodec/libvorbis.c
old mode 100644
new mode 100755
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
old mode 100644
new mode 100755
index 645d45d..d82756b
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -27,15 +27,14 @@
 #include <string.h>
 
 typedef struct X264Context {
-    x264_param_t    params;
-    x264_t         *enc;
-    x264_picture_t  pic;
-    uint8_t        *sei;
-    int             sei_size;
-    AVFrame         out_pic;
+    x264_param_t params;
+    x264_t *enc;
+    x264_picture_t pic;
+    AVFrame out_pic;
 } X264Context;
 
-static void X264_log(void *p, int level, const char *fmt, va_list args)
+static void
+X264_log(void *p, int level, const char *fmt, va_list args)
 {
     static const int level_map[] = {
         [X264_LOG_ERROR]   = AV_LOG_ERROR,
@@ -44,75 +43,31 @@
         [X264_LOG_DEBUG]   = AV_LOG_DEBUG
     };
 
-    if (level < 0 || level > X264_LOG_DEBUG)
+    if(level < 0 || level > X264_LOG_DEBUG)
         return;
 
     av_vlog(p, level_map[level], fmt, args);
 }
 
-#if X264_BUILD >= 76
-static int encode_nals(AVCodecContext *ctx, uint8_t *buf, int size,
-                       x264_nal_t *nals, int nnal, int skip_sei)
+
+static int
+encode_nals(uint8_t *buf, int size, x264_nal_t *nals, int nnal)
 {
-    X264Context *x4 = ctx->priv_data;
     uint8_t *p = buf;
     int i;
 
-    /* Write the SEI as part of the first frame. */
-    if (x4->sei_size > 0 && nnal > 0) {
-        memcpy(p, x4->sei, x4->sei_size);
-        p += x4->sei_size;
-        x4->sei_size = 0;
-    }
-
-    for (i = 0; i < nnal; i++){
-        /* Don't put the SEI in extradata. */
-        if (skip_sei && nals[i].i_type == NAL_SEI) {
-            x4->sei_size = nals[i].i_payload;
-            x4->sei      = av_malloc(x4->sei_size);
-            memcpy(x4->sei, nals[i].p_payload, nals[i].i_payload);
-            continue;
-        }
-        memcpy(p, nals[i].p_payload, nals[i].i_payload);
-        p += nals[i].i_payload;
-    }
-
-    return p - buf;
-}
-#else
-static int encode_nals(AVCodecContext *ctx, uint8_t *buf, int size, x264_nal_t *nals, int nnal, int skip_sei)
-{
-    X264Context *x4 = ctx->priv_data;
-    uint8_t *p = buf;
-    int i, s;
-
-    /* Write the SEI as part of the first frame. */
-    if (x4->sei_size > 0 && nnal > 0) {
-        memcpy(p, x4->sei, x4->sei_size);
-        p += x4->sei_size;
-        x4->sei_size = 0;
-    }
-
-    for (i = 0; i < nnal; i++) {
-        /* Don't put the SEI in extradata. */
-        if (skip_sei && nals[i].i_type == NAL_SEI) {
-            x4->sei = av_malloc( 5 + nals[i].i_payload * 4 / 3 );
-            if(x264_nal_encode(x4->sei, &x4->sei_size, 1, nals + i) < 0)
-                return -1;
-            continue;
-        }
-        s = x264_nal_encode(p, &size, 1, nals + i);
-        if (s < 0)
+    for(i = 0; i < nnal; i++){
+        int s = x264_nal_encode(p, &size, 1, nals + i);
+        if(s < 0)
             return -1;
         p += s;
     }
 
     return p - buf;
 }
-#endif
 
-static int X264_frame(AVCodecContext *ctx, uint8_t *buf,
-                      int bufsize, void *data)
+static int
+X264_frame(AVCodecContext *ctx, uint8_t *buf, int bufsize, void *data)
 {
     X264Context *x4 = ctx->priv_data;
     AVFrame *frame = data;
@@ -120,30 +75,31 @@
     int nnal, i;
     x264_picture_t pic_out;
 
-    x4->pic.img.i_csp   = X264_CSP_I420;
+    x4->pic.img.i_csp = X264_CSP_I420;
     x4->pic.img.i_plane = 3;
 
     if (frame) {
-        for (i = 0; i < 3; i++) {
+        for(i = 0; i < 3; i++){
             x4->pic.img.plane[i] = frame->data[i];
             x4->pic.img.i_stride[i] = frame->linesize[i];
         }
 
-        x4->pic.i_pts  = frame->pts;
+        x4->pic.i_pts = frame->pts;
         x4->pic.i_type = X264_TYPE_AUTO;
     }
 
-    if (x264_encoder_encode(x4->enc, &nal, &nnal, frame? &x4->pic: NULL, &pic_out) < 0)
+    if(x264_encoder_encode(x4->enc, &nal, &nnal, frame? &x4->pic: NULL,
+                           &pic_out))
         return -1;
 
-    bufsize = encode_nals(ctx, buf, bufsize, nal, nnal, 0);
-    if (bufsize < 0)
+    bufsize = encode_nals(buf, bufsize, nal, nnal);
+    if(bufsize < 0)
         return -1;
 
-    /* FIXME: libx264 now provides DTS, but AVFrame doesn't have a field for it. */
+    /* FIXME: dts */
     x4->out_pic.pts = pic_out.i_pts;
 
-    switch (pic_out.i_type) {
+    switch(pic_out.i_type){
     case X264_TYPE_IDR:
     case X264_TYPE_I:
         x4->out_pic.pict_type = FF_I_TYPE;
@@ -157,194 +113,166 @@
         break;
     }
 
-#if X264_BUILD < 82
     x4->out_pic.key_frame = pic_out.i_type == X264_TYPE_IDR;
-#else
-    x4->out_pic.key_frame = pic_out.b_keyframe;
-#endif
-    x4->out_pic.quality   = (pic_out.i_qpplus1 - 1) * FF_QP2LAMBDA;
+    x4->out_pic.quality = (pic_out.i_qpplus1 - 1) * FF_QP2LAMBDA;
 
     return bufsize;
 }
 
-static av_cold int X264_close(AVCodecContext *avctx)
+static av_cold int
+X264_close(AVCodecContext *avctx)
 {
     X264Context *x4 = avctx->priv_data;
 
     av_freep(&avctx->extradata);
-    av_free(x4->sei);
 
-    if (x4->enc)
+    if(x4->enc)
         x264_encoder_close(x4->enc);
 
     return 0;
 }
 
-static av_cold int X264_init(AVCodecContext *avctx)
+static av_cold int
+X264_init(AVCodecContext *avctx)
 {
     X264Context *x4 = avctx->priv_data;
 
-    x4->sei_size = 0;
     x264_param_default(&x4->params);
 
-    x4->params.pf_log               = X264_log;
-    x4->params.p_log_private        = avctx;
+    x4->params.pf_log = X264_log;
+    x4->params.p_log_private = avctx;
 
-    x4->params.i_keyint_max         = avctx->gop_size;
-    x4->params.rc.i_bitrate         = avctx->bit_rate       / 1000;
+    x4->params.i_keyint_max = avctx->gop_size;
+    x4->params.rc.i_bitrate = avctx->bit_rate / 1000;
     x4->params.rc.i_vbv_buffer_size = avctx->rc_buffer_size / 1000;
-    x4->params.rc.i_vbv_max_bitrate = avctx->rc_max_rate    / 1000;
-    x4->params.rc.b_stat_write      = avctx->flags & CODEC_FLAG_PASS1;
-    if (avctx->flags & CODEC_FLAG_PASS2) {
-        x4->params.rc.b_stat_read = 1;
-    } else {
-        if (avctx->crf) {
-            x4->params.rc.i_rc_method   = X264_RC_CRF;
+    x4->params.rc.i_vbv_max_bitrate = avctx->rc_max_rate / 1000;
+    x4->params.rc.b_stat_write = avctx->flags & CODEC_FLAG_PASS1;
+    if(avctx->flags & CODEC_FLAG_PASS2) x4->params.rc.b_stat_read = 1;
+    else{
+        if(avctx->crf){
+            x4->params.rc.i_rc_method = X264_RC_CRF;
             x4->params.rc.f_rf_constant = avctx->crf;
-        } else if (avctx->cqp > -1) {
-            x4->params.rc.i_rc_method   = X264_RC_CQP;
+        }else if(avctx->cqp > -1){
+            x4->params.rc.i_rc_method = X264_RC_CQP;
             x4->params.rc.i_qp_constant = avctx->cqp;
         }
     }
 
     // if neither crf nor cqp modes are selected we have to enable the RC
     // we do it this way because we cannot check if the bitrate has been set
-    if (!(avctx->crf || (avctx->cqp > -1)))
-        x4->params.rc.i_rc_method = X264_RC_ABR;
+    if(!(avctx->crf || (avctx->cqp > -1))) x4->params.rc.i_rc_method = X264_RC_ABR;
 
-    x4->params.i_bframe          = avctx->max_b_frames;
-    x4->params.b_cabac           = avctx->coder_type == FF_CODER_TYPE_AC;
+    x4->params.i_bframe = avctx->max_b_frames;
+    x4->params.b_cabac = avctx->coder_type == FF_CODER_TYPE_AC;
     x4->params.i_bframe_adaptive = avctx->b_frame_strategy;
-    x4->params.i_bframe_bias     = avctx->bframebias;
-#if X264_BUILD >= 78
-    x4->params.i_bframe_pyramid  = avctx->flags2 & CODEC_FLAG2_BPYRAMID ? X264_B_PYRAMID_NORMAL : X264_B_PYRAMID_NONE;
-#else
-    x4->params.b_bframe_pyramid  = avctx->flags2 & CODEC_FLAG2_BPYRAMID;
-#endif
-    avctx->has_b_frames          = avctx->flags2 & CODEC_FLAG2_BPYRAMID ? 2 : !!avctx->max_b_frames;
+    x4->params.i_bframe_bias = avctx->bframebias;
+    x4->params.b_bframe_pyramid = avctx->flags2 & CODEC_FLAG2_BPYRAMID;
+    avctx->has_b_frames= avctx->flags2 & CODEC_FLAG2_BPYRAMID ? 2 : !!avctx->max_b_frames;
 
     x4->params.i_keyint_min = avctx->keyint_min;
-    if (x4->params.i_keyint_min > x4->params.i_keyint_max)
+    if(x4->params.i_keyint_min > x4->params.i_keyint_max)
         x4->params.i_keyint_min = x4->params.i_keyint_max;
 
-    x4->params.i_scenecut_threshold        = avctx->scenechange_threshold;
+    x4->params.i_scenecut_threshold = avctx->scenechange_threshold;
 
-    x4->params.b_deblocking_filter         = avctx->flags & CODEC_FLAG_LOOP_FILTER;
+    x4->params.b_deblocking_filter = avctx->flags & CODEC_FLAG_LOOP_FILTER;
     x4->params.i_deblocking_filter_alphac0 = avctx->deblockalpha;
-    x4->params.i_deblocking_filter_beta    = avctx->deblockbeta;
+    x4->params.i_deblocking_filter_beta = avctx->deblockbeta;
 
-    x4->params.rc.i_qp_min                 = avctx->qmin;
-    x4->params.rc.i_qp_max                 = avctx->qmax;
-    x4->params.rc.i_qp_step                = avctx->max_qdiff;
+    x4->params.rc.i_qp_min = avctx->qmin;
+    x4->params.rc.i_qp_max = avctx->qmax;
+    x4->params.rc.i_qp_step = avctx->max_qdiff;
 
-    x4->params.rc.f_qcompress       = avctx->qcompress; /* 0.0 => cbr, 1.0 => constant qp */
-    x4->params.rc.f_qblur           = avctx->qblur;     /* temporally blur quants */
+    x4->params.rc.f_qcompress = avctx->qcompress;  /* 0.0 => cbr, 1.0 => constant qp */
+    x4->params.rc.f_qblur = avctx->qblur;        /* temporally blur quants */
     x4->params.rc.f_complexity_blur = avctx->complexityblur;
 
-    x4->params.i_frame_reference    = avctx->refs;
+    x4->params.i_frame_reference = avctx->refs;
 
-    x4->params.i_width              = avctx->width;
-    x4->params.i_height             = avctx->height;
-    x4->params.vui.i_sar_width      = avctx->sample_aspect_ratio.num;
-    x4->params.vui.i_sar_height     = avctx->sample_aspect_ratio.den;
-#if X264_BUILD >= 81
-    x4->params.i_fps_num = x4->params.i_timebase_den = avctx->time_base.den;
-    x4->params.i_fps_den = x4->params.i_timebase_num = avctx->time_base.num;
-#endif
+    x4->params.i_width = avctx->width;
+    x4->params.i_height = avctx->height;
+    x4->params.vui.i_sar_width = avctx->sample_aspect_ratio.num;
+    x4->params.vui.i_sar_height = avctx->sample_aspect_ratio.den;
+    x4->params.i_fps_num = avctx->time_base.den;
+    x4->params.i_fps_den = avctx->time_base.num;
 
-    x4->params.analyse.inter    = 0;
-    if (avctx->partitions) {
-        if (avctx->partitions & X264_PART_I4X4)
+    x4->params.analyse.inter = 0;
+    if(avctx->partitions){
+        if(avctx->partitions & X264_PART_I4X4)
             x4->params.analyse.inter |= X264_ANALYSE_I4x4;
-        if (avctx->partitions & X264_PART_I8X8)
+        if(avctx->partitions & X264_PART_I8X8)
             x4->params.analyse.inter |= X264_ANALYSE_I8x8;
-        if (avctx->partitions & X264_PART_P8X8)
+        if(avctx->partitions & X264_PART_P8X8)
             x4->params.analyse.inter |= X264_ANALYSE_PSUB16x16;
-        if (avctx->partitions & X264_PART_P4X4)
+        if(avctx->partitions & X264_PART_P4X4)
             x4->params.analyse.inter |= X264_ANALYSE_PSUB8x8;
-        if (avctx->partitions & X264_PART_B8X8)
+        if(avctx->partitions & X264_PART_B8X8)
             x4->params.analyse.inter |= X264_ANALYSE_BSUB16x16;
     }
 
-    x4->params.analyse.i_direct_mv_pred  = avctx->directpred;
+    x4->params.analyse.i_direct_mv_pred = avctx->directpred;
 
     x4->params.analyse.b_weighted_bipred = avctx->flags2 & CODEC_FLAG2_WPRED;
-#if X264_BUILD >= 79
-    x4->params.analyse.i_weighted_pred = avctx->weighted_p_pred;
-#endif
 
-    if (avctx->me_method == ME_EPZS)
+    if(avctx->me_method == ME_EPZS)
         x4->params.analyse.i_me_method = X264_ME_DIA;
-    else if (avctx->me_method == ME_HEX)
+    else if(avctx->me_method == ME_HEX)
         x4->params.analyse.i_me_method = X264_ME_HEX;
-    else if (avctx->me_method == ME_UMH)
+    else if(avctx->me_method == ME_UMH)
         x4->params.analyse.i_me_method = X264_ME_UMH;
-    else if (avctx->me_method == ME_FULL)
+    else if(avctx->me_method == ME_FULL)
         x4->params.analyse.i_me_method = X264_ME_ESA;
-    else if (avctx->me_method == ME_TESA)
+    else if(avctx->me_method == ME_TESA)
         x4->params.analyse.i_me_method = X264_ME_TESA;
     else x4->params.analyse.i_me_method = X264_ME_HEX;
 
-    x4->params.analyse.i_me_range         = avctx->me_range;
-    x4->params.analyse.i_subpel_refine    = avctx->me_subpel_quality;
+    x4->params.analyse.i_me_range = avctx->me_range;
+    x4->params.analyse.i_subpel_refine = avctx->me_subpel_quality;
 
-    x4->params.analyse.b_mixed_references = avctx->flags2 & CODEC_FLAG2_MIXED_REFS;
-    x4->params.analyse.b_chroma_me        = avctx->me_cmp & FF_CMP_CHROMA;
-    x4->params.analyse.b_transform_8x8    = avctx->flags2 & CODEC_FLAG2_8X8DCT;
-    x4->params.analyse.b_fast_pskip       = avctx->flags2 & CODEC_FLAG2_FASTPSKIP;
+    x4->params.analyse.b_mixed_references =
+        avctx->flags2 & CODEC_FLAG2_MIXED_REFS;
+    x4->params.analyse.b_chroma_me = avctx->me_cmp & FF_CMP_CHROMA;
+    x4->params.analyse.b_transform_8x8 = avctx->flags2 & CODEC_FLAG2_8X8DCT;
+    x4->params.analyse.b_fast_pskip = avctx->flags2 & CODEC_FLAG2_FASTPSKIP;
 
-    x4->params.analyse.i_trellis          = avctx->trellis;
-    x4->params.analyse.i_noise_reduction  = avctx->noise_reduction;
+    x4->params.analyse.i_trellis = avctx->trellis;
+    x4->params.analyse.i_noise_reduction = avctx->noise_reduction;
 
-    if (avctx->level > 0)
-        x4->params.i_level_idc = avctx->level;
+    if(avctx->level > 0) x4->params.i_level_idc = avctx->level;
 
     x4->params.rc.f_rate_tolerance =
         (float)avctx->bit_rate_tolerance/avctx->bit_rate;
 
-    if ((avctx->rc_buffer_size != 0) &&
-        (avctx->rc_initial_buffer_occupancy <= avctx->rc_buffer_size)) {
+    if((avctx->rc_buffer_size != 0) &&
+            (avctx->rc_initial_buffer_occupancy <= avctx->rc_buffer_size)){
         x4->params.rc.f_vbv_buffer_init =
-            (float)avctx->rc_initial_buffer_occupancy / avctx->rc_buffer_size;
-    } else
-        x4->params.rc.f_vbv_buffer_init = 0.9;
+            (float)avctx->rc_initial_buffer_occupancy/avctx->rc_buffer_size;
+    }
+    else x4->params.rc.f_vbv_buffer_init = 0.9;
 
-#if X264_BUILD >= 69
-    x4->params.rc.b_mb_tree               = !!(avctx->flags2 & CODEC_FLAG2_MBTREE);
-#endif
-    x4->params.rc.f_ip_factor             = 1 / fabs(avctx->i_quant_factor);
-    x4->params.rc.f_pb_factor             = avctx->b_quant_factor;
+    x4->params.rc.f_ip_factor = 1/fabs(avctx->i_quant_factor);
+    x4->params.rc.f_pb_factor = avctx->b_quant_factor;
     x4->params.analyse.i_chroma_qp_offset = avctx->chromaoffset;
 
     x4->params.analyse.b_psnr = avctx->flags & CODEC_FLAG_PSNR;
-    x4->params.i_log_level    = X264_LOG_DEBUG;
+    x4->params.i_log_level = X264_LOG_DEBUG;
 
-    x4->params.b_aud          = avctx->flags2 & CODEC_FLAG2_AUD;
+    x4->params.b_aud = avctx->flags2 & CODEC_FLAG2_AUD;
 
-    x4->params.i_threads      = avctx->thread_count;
+    x4->params.i_threads = avctx->thread_count;
 
-    x4->params.b_interlaced   = avctx->flags & CODEC_FLAG_INTERLACED_DCT;
+    x4->params.b_interlaced = avctx->flags & CODEC_FLAG_INTERLACED_DCT;
 
-    if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER)
+    if(avctx->flags & CODEC_FLAG_GLOBAL_HEADER){
         x4->params.b_repeat_headers = 0;
+    }
 
     x4->enc = x264_encoder_open(&x4->params);
-    if (!x4->enc)
+    if(!x4->enc)
         return -1;
 
     avctx->coded_frame = &x4->out_pic;
 
-#if X264_BUILD >= 76
-    if (avctx->flags & CODEC_FLAG_GLOBAL_HEADER) {
-        x264_nal_t *nal;
-        int nnal, s;
-
-        s = x264_encoder_headers(x4->enc, &nal, &nnal);
-
-        avctx->extradata      = av_malloc(s);
-        avctx->extradata_size = encode_nals(avctx, avctx->extradata, s, nal, nnal, 1);
-    }
-#else
     if(avctx->flags & CODEC_FLAG_GLOBAL_HEADER){
         x264_nal_t *nal;
         int nnal, i, s = 0;
@@ -352,26 +280,25 @@
         x264_encoder_headers(x4->enc, &nal, &nnal);
 
         /* 5 bytes NAL header + worst case escaping */
-        for (i = 0; i < nnal; i++)
-             s += 5 + nal[i].i_payload * 4 / 3;
+        for(i = 0; i < nnal; i++)
+            s += 5 + nal[i].i_payload * 4 / 3;
 
         avctx->extradata = av_malloc(s);
-        avctx->extradata_size = encode_nals(avctx, avctx->extradata, s, nal, nnal, 1);
+        avctx->extradata_size = encode_nals(avctx->extradata, s, nal, nnal);
     }
-#endif
 
     return 0;
 }
 
 AVCodec libx264_encoder = {
-    .name           = "libx264",
-    .type           = CODEC_TYPE_VIDEO,
-    .id             = CODEC_ID_H264,
+    .name = "libx264",
+    .type = CODEC_TYPE_VIDEO,
+    .id = CODEC_ID_H264,
     .priv_data_size = sizeof(X264Context),
-    .init           = X264_init,
-    .encode         = X264_frame,
-    .close          = X264_close,
-    .capabilities   = CODEC_CAP_DELAY,
-    .pix_fmts       = (const enum PixelFormat[]) { PIX_FMT_YUV420P, PIX_FMT_NONE },
-    .long_name      = NULL_IF_CONFIG_SMALL("libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"),
+    .init = X264_init,
+    .encode = X264_frame,
+    .close = X264_close,
+    .capabilities = CODEC_CAP_DELAY,
+    .pix_fmts = (enum PixelFormat[]) { PIX_FMT_YUV420P, PIX_FMT_NONE },
+    .long_name = NULL_IF_CONFIG_SMALL("libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"),
 };
diff --git a/libavcodec/libxvid_internal.h b/libavcodec/libxvid_internal.h
old mode 100644
new mode 100755
diff --git a/libavcodec/libxvid_rc.c b/libavcodec/libxvid_rc.c
old mode 100644
new mode 100755
diff --git a/libavcodec/libxvidff.c b/libavcodec/libxvidff.c
old mode 100644
new mode 100755
diff --git a/libavcodec/ljpegenc.c b/libavcodec/ljpegenc.c
old mode 100644
new mode 100755
diff --git a/libavcodec/loco.c b/libavcodec/loco.c
old mode 100644
new mode 100755
diff --git a/libavcodec/lsp.c b/libavcodec/lsp.c
old mode 100644
new mode 100755
diff --git a/libavcodec/lsp.h b/libavcodec/lsp.h
old mode 100644
new mode 100755
diff --git a/libavcodec/lzw.c b/libavcodec/lzw.c
old mode 100644
new mode 100755
diff --git a/libavcodec/lzwenc.c b/libavcodec/lzwenc.c
old mode 100644
new mode 100755
diff --git a/libavcodec/mace.c b/libavcodec/mace.c
old mode 100644
new mode 100755
diff --git a/libavcodec/mathops.h b/libavcodec/mathops.h
index 880e946..b92a6be 100644
--- a/libavcodec/mathops.h
+++ b/libavcodec/mathops.h
@@ -113,5 +113,12 @@
 }
 #endif
 
+#ifndef sign_extend
+static inline av_const int sign_extend(int val, unsigned bits)
+{
+    return (val << (INT_BIT - bits)) >> (INT_BIT - bits);
+}
+#endif
+
 #endif /* AVCODEC_MATHOPS_H */
 
diff --git a/libavcodec/mdct.c b/libavcodec/mdct.c
old mode 100644
new mode 100755
diff --git a/libavcodec/mdec.c b/libavcodec/mdec.c
old mode 100644
new mode 100755
diff --git a/libavcodec/mjpeg.c b/libavcodec/mjpeg.c
old mode 100644
new mode 100755
diff --git a/libavcodec/mjpeg.h b/libavcodec/mjpeg.h
old mode 100644
new mode 100755
diff --git a/libavcodec/mjpeg_parser.c b/libavcodec/mjpeg_parser.c
old mode 100644
new mode 100755
diff --git a/libavcodec/mjpega_dump_header_bsf.c b/libavcodec/mjpega_dump_header_bsf.c
old mode 100644
new mode 100755
diff --git a/libavcodec/mjpegbdec.c b/libavcodec/mjpegbdec.c
old mode 100644
new mode 100755
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
old mode 100644
new mode 100755
diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c
old mode 100644
new mode 100755
diff --git a/libavcodec/mlib/dsputil_mlib.c b/libavcodec/mlib/dsputil_mlib.c
old mode 100644
new mode 100755
diff --git a/libavcodec/mlp.h b/libavcodec/mlp.h
index 032a8f6..c19b699 100644
--- a/libavcodec/mlp.h
+++ b/libavcodec/mlp.h
@@ -34,10 +34,10 @@
  */
 #define MAX_MATRICES        15
 
-/** Maximum number of substreams that can be decoded. This could also be set
- *  higher, but I haven't seen any examples with more than two.
+/** Maximum number of substreams that can be decoded.
+ *  MLP's limit is 2. TrueHD supports at least up to 3.
  */
-#define MAX_SUBSTREAMS      2
+#define MAX_SUBSTREAMS      3
 
 /** maximum sample frequency seen in files */
 #define MAX_SAMPLERATE      192000
diff --git a/libavcodec/mlp_parser.c b/libavcodec/mlp_parser.c
index b3e5b3a..34ee193 100644
--- a/libavcodec/mlp_parser.c
+++ b/libavcodec/mlp_parser.c
@@ -287,7 +287,7 @@
 }
 
 AVCodecParser mlp_parser = {
-    { CODEC_ID_MLP },
+    { CODEC_ID_MLP, CODEC_ID_TRUEHD },
     sizeof(MLPParseContext),
     mlp_init,
     mlp_parse,
diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c
index f1668af..9c1253f 100644
--- a/libavcodec/mlpdec.c
+++ b/libavcodec/mlpdec.c
@@ -58,6 +58,8 @@
     uint8_t     max_channel;
     //! The number of channels input into the rematrix stage.
     uint8_t     max_matrix_channel;
+    //! For each channel output by the matrix, the output channel to map it to
+    uint8_t     ch_assign[MAX_CHANNELS];
 
     //! The left shift applied to random noise in 0x31ea substreams.
     uint8_t     noise_shift;
@@ -76,6 +78,7 @@
 #define PARAM_FIR           (1 << 3)
 #define PARAM_IIR           (1 << 2)
 #define PARAM_HUFFOFFSET    (1 << 1)
+#define PARAM_PRESENCE      (1 << 0)
     //@}
 
     //@{
@@ -280,6 +283,10 @@
 
     if (mh.num_substreams == 0)
         return -1;
+    if (m->avctx->codec_id == CODEC_ID_MLP && mh.num_substreams > 2) {
+        av_log(m->avctx, AV_LOG_ERROR, "MLP only supports up to 2 substreams.\n");
+        return -1;
+    }
     if (mh.num_substreams > MAX_SUBSTREAMS) {
         av_log(m->avctx, AV_LOG_ERROR,
                "Number of substreams %d is larger than the maximum supported "
@@ -375,16 +382,19 @@
 
     skip_bits(gbp, 16);
 
+    memset(s->ch_assign, 0, sizeof(s->ch_assign));
+
     for (ch = 0; ch <= s->max_matrix_channel; ch++) {
         int ch_assign = get_bits(gbp, 6);
         dprintf(m->avctx, "ch_assign[%d][%d] = %d\n", substr, ch,
                 ch_assign);
-        if (ch_assign != ch) {
+        if (ch_assign > s->max_matrix_channel) {
             av_log(m->avctx, AV_LOG_ERROR,
-                   "Non-1:1 channel assignments are used in this stream. %s\n",
-                   sample_message);
+                   "Assignment of matrix channel %d to invalid output channel %d. %s\n",
+                   ch, ch_assign, sample_message);
             return -1;
         }
+        s->ch_assign[ch_assign] = ch;
     }
 
     checksum = ff_mlp_restart_checksum(buf, get_bits_count(gbp) - start_count);
@@ -416,7 +426,7 @@
     }
 
     if (substr == m->max_decoded_substream) {
-        m->avctx->channels = s->max_channel + 1;
+        m->avctx->channels = s->max_matrix_channel + 1;
     }
 
     return 0;
@@ -497,6 +507,7 @@
     SubStream *s = &m->substream[substr];
     unsigned int mat, ch;
 
+    if (s->param_presence_flags & PARAM_PRESENCE)
     if (get_bits1(gbp))
         s->param_presence_flags = get_bits(gbp, 8);
 
@@ -825,7 +836,7 @@
                                 uint8_t *data, unsigned int *data_size, int is32)
 {
     SubStream *s = &m->substream[substr];
-    unsigned int i, ch = 0;
+    unsigned int i, out_ch = 0;
     int32_t *data_32 = (int32_t*) data;
     int16_t *data_16 = (int16_t*) data;
 
@@ -833,15 +844,17 @@
         return -1;
 
     for (i = 0; i < s->blockpos; i++) {
-        for (ch = 0; ch <= s->max_channel; ch++) {
-            int32_t sample = m->sample_buffer[i][ch] << s->output_shift[ch];
-            s->lossless_check_data ^= (sample & 0xffffff) << ch;
+        for (out_ch = 0; out_ch <= s->max_matrix_channel; out_ch++) {
+            int mat_ch = s->ch_assign[out_ch];
+            int32_t sample = m->sample_buffer[i][mat_ch]
+                          << s->output_shift[mat_ch];
+            s->lossless_check_data ^= (sample & 0xffffff) << mat_ch;
             if (is32) *data_32++ = sample << 8;
             else      *data_16++ = sample >> 8;
         }
     }
 
-    *data_size = i * ch * (is32 ? 4 : 2);
+    *data_size = i * out_ch * (is32 ? 4 : 2);
 
     return 0;
 }
@@ -1038,6 +1051,7 @@
     return -1;
 }
 
+#if CONFIG_MLP_DECODER
 AVCodec mlp_decoder = {
     "mlp",
     CODEC_TYPE_AUDIO,
@@ -1047,6 +1061,20 @@
     NULL,
     NULL,
     read_access_unit,
-    .long_name = NULL_IF_CONFIG_SMALL("MLP (Meridian Lossless Packing)/TrueHD"),
+    .long_name = NULL_IF_CONFIG_SMALL("MLP (Meridian Lossless Packing)"),
 };
+#endif /* CONFIG_MLP_DECODER */
 
+#if CONFIG_TRUEHD_DECODER
+AVCodec truehd_decoder = {
+    "truehd",
+    CODEC_TYPE_AUDIO,
+    CODEC_ID_TRUEHD,
+    sizeof(MLPDecodeContext),
+    mlp_decode_init,
+    NULL,
+    NULL,
+    read_access_unit,
+    .long_name = NULL_IF_CONFIG_SMALL("TrueHD"),
+};
+#endif /* CONFIG_TRUEHD_DECODER */
diff --git a/libavcodec/mmvideo.c b/libavcodec/mmvideo.c
old mode 100644
new mode 100755
diff --git a/libavcodec/motion-test.c b/libavcodec/motion-test.c
old mode 100644
new mode 100755
index 38f5994..90f0a2e
--- a/libavcodec/motion-test.c
+++ b/libavcodec/motion-test.c
@@ -30,10 +30,10 @@
 #include <unistd.h>
 
 #include "dsputil.h"
+#include "libavutil/lfg.h"
 
 #undef exit
 #undef printf
-#undef random
 
 #define WIDTH 64
 #define HEIGHT 64
@@ -44,9 +44,12 @@
 void fill_random(uint8_t *tab, int size)
 {
     int i;
+    AVLFG prn;
+
+    av_lfg_init(&prn, 1);
     for(i=0;i<size;i++) {
 #if 1
-        tab[i] = random() % 256;
+        tab[i] = av_lfg_get(&prn) % 256;
 #else
         tab[i] = i;
 #endif
@@ -142,7 +145,7 @@
     ctx = avcodec_alloc_context();
     ctx->dsp_mask = FF_MM_FORCE;
     dsputil_init(&cctx, ctx);
-    for (c = 0; c < 2; c++) {
+    for (c = 0; c < 1; c++) {
         int x;
         ctx->dsp_mask = FF_MM_FORCE | flags[c];
         dsputil_init(&mmxctx, ctx);
diff --git a/libavcodec/motion_est_template.c b/libavcodec/motion_est_template.c
old mode 100644
new mode 100755
diff --git a/libavcodec/motionpixels.c b/libavcodec/motionpixels.c
old mode 100644
new mode 100755
diff --git a/libavcodec/mp3_header_compress_bsf.c b/libavcodec/mp3_header_compress_bsf.c
old mode 100644
new mode 100755
diff --git a/libavcodec/mp3_header_decompress_bsf.c b/libavcodec/mp3_header_decompress_bsf.c
old mode 100644
new mode 100755
diff --git a/libavcodec/mp3table.h b/libavcodec/mp3table.h
new file mode 100755
index 0000000..3e54775
--- /dev/null
+++ b/libavcodec/mp3table.h
@@ -0,0 +1,4654 @@
+static int8_t  table_4_3_exp[TABLE_4_3_SIZE]={
+0, 111, 111, 111, 110, 110, 110, 110, 109, 109, 109, 108, 108, 108, 108, 108, 
+108, 108, 107, 107, 107, 107, 107, 107, 107, 107, 107, 106, 107, 107, 106, 106, 
+107, 106, 106, 106, 106, 106, 106, 106, 106, 106, 106, 105, 106, 106, 105, 105, 
+106, 105, 105, 105, 106, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 105, 
+105, 105, 105, 104, 105, 105, 105, 104, 105, 105, 104, 104, 105, 105, 104, 104, 
+105, 104, 104, 104, 105, 104, 104, 104, 105, 104, 104, 104, 104, 104, 104, 104, 
+104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 103, 104, 104, 104, 103, 
+104, 104, 104, 103, 104, 104, 104, 103, 104, 104, 103, 103, 104, 104, 103, 103, 
+104, 104, 103, 103, 104, 104, 103, 103, 104, 103, 103, 103, 104, 103, 103, 103, 
+104, 103, 103, 103, 104, 103, 103, 103, 104, 103, 103, 103, 103, 103, 103, 103, 
+103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, 
+103, 103, 103, 102, 103, 103, 103, 102, 103, 103, 103, 102, 103, 103, 103, 102, 
+103, 103, 103, 102, 103, 103, 103, 102, 103, 103, 102, 102, 103, 103, 102, 102, 
+103, 103, 102, 102, 103, 103, 102, 102, 103, 103, 102, 102, 103, 103, 102, 102, 
+103, 103, 102, 102, 103, 102, 102, 102, 103, 102, 102, 102, 103, 102, 102, 102, 
+103, 102, 102, 102, 103, 102, 102, 102, 103, 102, 102, 102, 103, 102, 102, 102, 
+103, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 
+102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 102, 
+102, 102, 102, 102, 102, 102, 102, 101, 102, 102, 102, 101, 102, 102, 102, 101, 
+102, 102, 102, 101, 102, 102, 102, 101, 102, 102, 102, 101, 102, 102, 102, 101, 
+102, 102, 102, 101, 102, 102, 102, 101, 102, 102, 102, 101, 102, 102, 101, 101, 
+102, 102, 101, 101, 102, 102, 101, 101, 102, 102, 101, 101, 102, 102, 101, 101, 
+102, 102, 101, 101, 102, 102, 101, 101, 102, 102, 101, 101, 102, 102, 101, 101, 
+102, 102, 101, 101, 102, 102, 101, 101, 102, 102, 101, 101, 102, 101, 101, 101, 
+102, 101, 101, 101, 102, 101, 101, 101, 102, 101, 101, 101, 102, 101, 101, 101, 
+102, 101, 101, 101, 102, 101, 101, 101, 102, 101, 101, 101, 102, 101, 101, 101, 
+102, 101, 101, 101, 102, 101, 101, 101, 102, 101, 101, 101, 102, 101, 101, 101, 
+101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 
+101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 
+101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 
+101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 101, 100, 
+101, 101, 101, 100, 101, 101, 101, 100, 101, 101, 101, 100, 101, 101, 101, 100, 
+101, 101, 101, 100, 101, 101, 101, 100, 101, 101, 101, 100, 101, 101, 101, 100, 
+101, 101, 101, 100, 101, 101, 101, 100, 101, 101, 101, 100, 101, 101, 101, 100, 
+101, 101, 101, 100, 101, 101, 101, 100, 101, 101, 101, 100, 101, 101, 101, 100, 
+101, 101, 100, 100, 101, 101, 100, 100, 101, 101, 100, 100, 101, 101, 100, 100, 
+101, 101, 100, 100, 101, 101, 100, 100, 101, 101, 100, 100, 101, 101, 100, 100, 
+101, 101, 100, 100, 101, 101, 100, 100, 101, 101, 100, 100, 101, 101, 100, 100, 
+101, 101, 100, 100, 101, 101, 100, 100, 101, 101, 100, 100, 101, 101, 100, 100, 
+101, 101, 100, 100, 101, 101, 100, 100, 101, 101, 100, 100, 101, 100, 100, 100, 
+101, 100, 100, 100, 101, 100, 100, 100, 101, 100, 100, 100, 101, 100, 100, 100, 
+101, 100, 100, 100, 101, 100, 100, 100, 101, 100, 100, 100, 101, 100, 100, 100, 
+101, 100, 100, 100, 101, 100, 100, 100, 101, 100, 100, 100, 101, 100, 100, 100, 
+101, 100, 100, 100, 101, 100, 100, 100, 101, 100, 100, 100, 101, 100, 100, 100, 
+101, 100, 100, 100, 101, 100, 100, 100, 101, 100, 100, 100, 101, 100, 100, 100, 
+101, 100, 100, 100, 101, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 
+100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 
+100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 
+100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 
+100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 
+100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 
+100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 99, 
+100, 100, 100, 99, 100, 100, 100, 99, 100, 100, 100, 99, 100, 100, 100, 99, 
+100, 100, 100, 99, 100, 100, 100, 99, 100, 100, 100, 99, 100, 100, 100, 99, 
+100, 100, 100, 99, 100, 100, 100, 99, 100, 100, 100, 99, 100, 100, 100, 99, 
+100, 100, 100, 99, 100, 100, 100, 99, 100, 100, 100, 99, 100, 100, 100, 99, 
+100, 100, 100, 99, 100, 100, 100, 99, 100, 100, 100, 99, 100, 100, 100, 99, 
+100, 100, 100, 99, 100, 100, 100, 99, 100, 100, 100, 99, 100, 100, 100, 99, 
+100, 100, 100, 99, 100, 100, 100, 99, 100, 100, 100, 99, 100, 100, 99, 99, 
+100, 100, 99, 99, 100, 100, 99, 99, 100, 100, 99, 99, 100, 100, 99, 99, 
+100, 100, 99, 99, 100, 100, 99, 99, 100, 100, 99, 99, 100, 100, 99, 99, 
+100, 100, 99, 99, 100, 100, 99, 99, 100, 100, 99, 99, 100, 100, 99, 99, 
+100, 100, 99, 99, 100, 100, 99, 99, 100, 100, 99, 99, 100, 100, 99, 99, 
+100, 100, 99, 99, 100, 100, 99, 99, 100, 100, 99, 99, 100, 100, 99, 99, 
+100, 100, 99, 99, 100, 100, 99, 99, 100, 100, 99, 99, 100, 100, 99, 99, 
+100, 100, 99, 99, 100, 100, 99, 99, 100, 100, 99, 99, 100, 100, 99, 99, 
+100, 100, 99, 99, 100, 100, 99, 99, 100, 100, 99, 99, 100, 100, 99, 99, 
+100, 99, 99, 99, 100, 99, 99, 99, 100, 99, 99, 99, 100, 99, 99, 99, 
+100, 99, 99, 99, 100, 99, 99, 99, 100, 99, 99, 99, 100, 99, 99, 99, 
+100, 99, 99, 99, 100, 99, 99, 99, 100, 99, 99, 99, 100, 99, 99, 99, 
+100, 99, 99, 99, 100, 99, 99, 99, 100, 99, 99, 99, 100, 99, 99, 99, 
+100, 99, 99, 99, 100, 99, 99, 99, 100, 99, 99, 99, 100, 99, 99, 99, 
+100, 99, 99, 99, 100, 99, 99, 99, 100, 99, 99, 99, 100, 99, 99, 99, 
+100, 99, 99, 99, 100, 99, 99, 99, 100, 99, 99, 99, 100, 99, 99, 99, 
+100, 99, 99, 99, 100, 99, 99, 99, 100, 99, 99, 99, 100, 99, 99, 99, 
+100, 99, 99, 99, 100, 99, 99, 99, 100, 99, 99, 99, 100, 99, 99, 99, 
+100, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 
+99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 
+99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 
+99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 
+99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 
+99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 
+99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 
+99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 
+99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 
+99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 
+99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 98, 
+99, 99, 99, 98, 99, 99, 99, 98, 99, 99, 99, 98, 99, 99, 99, 98, 
+99, 99, 99, 98, 99, 99, 99, 98, 99, 99, 99, 98, 99, 99, 99, 98, 
+99, 99, 99, 98, 99, 99, 99, 98, 99, 99, 99, 98, 99, 99, 99, 98, 
+99, 99, 99, 98, 99, 99, 99, 98, 99, 99, 99, 98, 99, 99, 99, 98, 
+99, 99, 99, 98, 99, 99, 99, 98, 99, 99, 99, 98, 99, 99, 99, 98, 
+99, 99, 99, 98, 99, 99, 99, 98, 99, 99, 99, 98, 99, 99, 99, 98, 
+99, 99, 99, 98, 99, 99, 99, 98, 99, 99, 99, 98, 99, 99, 99, 98, 
+99, 99, 99, 98, 99, 99, 99, 98, 99, 99, 99, 98, 99, 99, 99, 98, 
+99, 99, 99, 98, 99, 99, 99, 98, 99, 99, 99, 98, 99, 99, 99, 98, 
+99, 99, 99, 98, 99, 99, 99, 98, 99, 99, 99, 98, 99, 99, 99, 98, 
+99, 99, 99, 98, 99, 99, 99, 98, 99, 99, 99, 98, 99, 99, 99, 98, 
+99, 99, 99, 98, 99, 99, 99, 98, 99, 99, 99, 98, 99, 99, 98, 98, 
+99, 99, 98, 98, 99, 99, 98, 98, 99, 99, 98, 98, 99, 99, 98, 98, 
+99, 99, 98, 98, 99, 99, 98, 98, 99, 99, 98, 98, 99, 99, 98, 98, 
+99, 99, 98, 98, 99, 99, 98, 98, 99, 99, 98, 98, 99, 99, 98, 98, 
+99, 99, 98, 98, 99, 99, 98, 98, 99, 99, 98, 98, 99, 99, 98, 98, 
+99, 99, 98, 98, 99, 99, 98, 98, 99, 99, 98, 98, 99, 99, 98, 98, 
+99, 99, 98, 98, 99, 99, 98, 98, 99, 99, 98, 98, 99, 99, 98, 98, 
+99, 99, 98, 98, 99, 99, 98, 98, 99, 99, 98, 98, 99, 99, 98, 98, 
+99, 99, 98, 98, 99, 99, 98, 98, 99, 99, 98, 98, 99, 99, 98, 98, 
+99, 99, 98, 98, 99, 99, 98, 98, 99, 99, 98, 98, 99, 99, 98, 98, 
+99, 99, 98, 98, 99, 99, 98, 98, 99, 99, 98, 98, 99, 99, 98, 98, 
+99, 99, 98, 98, 99, 99, 98, 98, 99, 99, 98, 98, 99, 99, 98, 98, 
+99, 99, 98, 98, 99, 99, 98, 98, 99, 99, 98, 98, 99, 99, 98, 98, 
+99, 99, 98, 98, 99, 99, 98, 98, 99, 99, 98, 98, 99, 99, 98, 98, 
+99, 99, 98, 98, 99, 99, 98, 98, 99, 98, 98, 98, 99, 98, 98, 98, 
+99, 98, 98, 98, 99, 98, 98, 98, 99, 98, 98, 98, 99, 98, 98, 98, 
+99, 98, 98, 98, 99, 98, 98, 98, 99, 98, 98, 98, 99, 98, 98, 98, 
+99, 98, 98, 98, 99, 98, 98, 98, 99, 98, 98, 98, 99, 98, 98, 98, 
+99, 98, 98, 98, 99, 98, 98, 98, 99, 98, 98, 98, 99, 98, 98, 98, 
+99, 98, 98, 98, 99, 98, 98, 98, 99, 98, 98, 98, 99, 98, 98, 98, 
+99, 98, 98, 98, 99, 98, 98, 98, 99, 98, 98, 98, 99, 98, 98, 98, 
+99, 98, 98, 98, 99, 98, 98, 98, 99, 98, 98, 98, 99, 98, 98, 98, 
+99, 98, 98, 98, 99, 98, 98, 98, 99, 98, 98, 98, 99, 98, 98, 98, 
+99, 98, 98, 98, 99, 98, 98, 98, 99, 98, 98, 98, 99, 98, 98, 98, 
+99, 98, 98, 98, 99, 98, 98, 98, 99, 98, 98, 98, 99, 98, 98, 98, 
+99, 98, 98, 98, 99, 98, 98, 98, 99, 98, 98, 98, 99, 98, 98, 98, 
+99, 98, 98, 98, 99, 98, 98, 98, 99, 98, 98, 98, 99, 98, 98, 98, 
+99, 98, 98, 98, 99, 98, 98, 98, 99, 98, 98, 98, 99, 98, 98, 98, 
+99, 98, 98, 98, 99, 98, 98, 98, 99, 98, 98, 98, 99, 98, 98, 98, 
+99, 98, 98, 98, 99, 98, 98, 98, 99, 98, 98, 98, 99, 98, 98, 98, 
+99, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 
+98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 
+98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 
+98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 
+98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 
+98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 
+98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 
+98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 
+98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 
+98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 
+98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 
+98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 
+98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 
+98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 
+98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 
+98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 
+98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 
+98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 98, 
+98, 98, 98, 97, 98, 98, 98, 97, 98, 98, 98, 97, 98, 98, 98, 97, 
+98, 98, 98, 97, 98, 98, 98, 97, 98, 98, 98, 97, 98, 98, 98, 97, 
+98, 98, 98, 97, 98, 98, 98, 97, 98, 98, 98, 97, 98, 98, 98, 97, 
+98, 98, 98, 97, 98, 98, 98, 97, 98, 98, 98, 97, 98, 98, 98, 97, 
+98, 98, 98, 97, 98, 98, 98, 97, 98, 98, 98, 97, 98, 98, 98, 97, 
+98, 98, 98, 97, 98, 98, 98, 97, 98, 98, 98, 97, 98, 98, 98, 97, 
+98, 98, 98, 97, 98, 98, 98, 97, 98, 98, 98, 97, 98, 98, 98, 97, 
+98, 98, 98, 97, 98, 98, 98, 97, 98, 98, 98, 97, 98, 98, 98, 97, 
+98, 98, 98, 97, 98, 98, 98, 97, 98, 98, 98, 97, 98, 98, 98, 97, 
+98, 98, 98, 97, 98, 98, 98, 97, 98, 98, 98, 97, 98, 98, 98, 97, 
+98, 98, 98, 97, 98, 98, 98, 97, 98, 98, 98, 97, 98, 98, 98, 97, 
+98, 98, 98, 97, 98, 98, 98, 97, 98, 98, 98, 97, 98, 98, 98, 97, 
+98, 98, 98, 97, 98, 98, 98, 97, 98, 98, 98, 97, 98, 98, 98, 97, 
+98, 98, 98, 97, 98, 98, 98, 97, 98, 98, 98, 97, 98, 98, 98, 97, 
+98, 98, 98, 97, 98, 98, 98, 97, 98, 98, 98, 97, 98, 98, 98, 97, 
+98, 98, 98, 97, 98, 98, 98, 97, 98, 98, 98, 97, 98, 98, 98, 97, 
+98, 98, 98, 97, 98, 98, 98, 97, 98, 98, 98, 97, 98, 98, 98, 97, 
+98, 98, 98, 97, 98, 98, 98, 97, 98, 98, 98, 97, 98, 98, 98, 97, 
+98, 98, 98, 97, 98, 98, 98, 97, 98, 98, 98, 97, 98, 98, 98, 97, 
+98, 98, 98, 97, 98, 98, 98, 97, 98, 98, 98, 97, 98, 98, 98, 97, 
+98, 98, 97, 97, 98, 98, 97, 97, 98, 98, 97, 97, 98, 98, 97, 97, 
+98, 98, 97, 97, 98, 98, 97, 97, 98, 98, 97, 97, 98, 98, 97, 97, 
+98, 98, 97, 97, 98, 98, 97, 97, 98, 98, 97, 97, 98, 98, 97, 97, 
+98, 98, 97, 97, 98, 98, 97, 97, 98, 98, 97, 97, 98, 98, 97, 97, 
+98, 98, 97, 97, 98, 98, 97, 97, 98, 98, 97, 97, 98, 98, 97, 97, 
+98, 98, 97, 97, 98, 98, 97, 97, 98, 98, 97, 97, 98, 98, 97, 97, 
+98, 98, 97, 97, 98, 98, 97, 97, 98, 98, 97, 97, 98, 98, 97, 97, 
+98, 98, 97, 97, 98, 98, 97, 97, 98, 98, 97, 97, 98, 98, 97, 97, 
+98, 98, 97, 97, 98, 98, 97, 97, 98, 98, 97, 97, 98, 98, 97, 97, 
+98, 98, 97, 97, 98, 98, 97, 97, 98, 98, 97, 97, 98, 98, 97, 97, 
+98, 98, 97, 97, 98, 98, 97, 97, 98, 98, 97, 97, 98, 98, 97, 97, 
+98, 98, 97, 97, 98, 98, 97, 97, 98, 98, 97, 97, 98, 98, 97, 97, 
+98, 98, 97, 97, 98, 98, 97, 97, 98, 98, 97, 97, 98, 98, 97, 97, 
+98, 98, 97, 97, 98, 98, 97, 97, 98, 98, 97, 97, 98, 98, 97, 97, 
+98, 98, 97, 97, 98, 98, 97, 97, 98, 98, 97, 97, 98, 98, 97, 97, 
+98, 98, 97, 97, 98, 98, 97, 97, 98, 98, 97, 97, 98, 98, 97, 97, 
+98, 98, 97, 97, 98, 98, 97, 97, 98, 98, 97, 97, 98, 98, 97, 97, 
+98, 98, 97, 97, 98, 98, 97, 97, 98, 98, 97, 97, 98, 98, 97, 97, 
+98, 98, 97, 97, 98, 98, 97, 97, 98, 98, 97, 97, 98, 98, 97, 97, 
+98, 98, 97, 97, 98, 98, 97, 97, 98, 98, 97, 97, 98, 98, 97, 97, 
+98, 98, 97, 97, 98, 98, 97, 97, 98, 98, 97, 97, 98, 98, 97, 97, 
+98, 98, 97, 97, 98, 98, 97, 97, 98, 98, 97, 97, 98, 98, 97, 97, 
+98, 98, 97, 97, 98, 98, 97, 97, 98, 98, 97, 97, 98, 98, 97, 97, 
+98, 98, 97, 97, 98, 97, 97, 97, 98, 97, 97, 97, 98, 97, 97, 97, 
+98, 97, 97, 97, 98, 97, 97, 97, 98, 97, 97, 97, 98, 97, 97, 97, 
+98, 97, 97, 97, 98, 97, 97, 97, 98, 97, 97, 97, 98, 97, 97, 97, 
+98, 97, 97, 97, 98, 97, 97, 97, 98, 97, 97, 97, 98, 97, 97, 97, 
+98, 97, 97, 97, 98, 97, 97, 97, 98, 97, 97, 97, 98, 97, 97, 97, 
+98, 97, 97, 97, 98, 97, 97, 97, 98, 97, 97, 97, 98, 97, 97, 97, 
+98, 97, 97, 97, 98, 97, 97, 97, 98, 97, 97, 97, 98, 97, 97, 97, 
+98, 97, 97, 97, 98, 97, 97, 97, 98, 97, 97, 97, 98, 97, 97, 97, 
+98, 97, 97, 97, 98, 97, 97, 97, 98, 97, 97, 97, 98, 97, 97, 97, 
+98, 97, 97, 97, 98, 97, 97, 97, 98, 97, 97, 97, 98, 97, 97, 97, 
+98, 97, 97, 97, 98, 97, 97, 97, 98, 97, 97, 97, 98, 97, 97, 97, 
+98, 97, 97, 97, 98, 97, 97, 97, 98, 97, 97, 97, 98, 97, 97, 97, 
+98, 97, 97, 97, 98, 97, 97, 97, 98, 97, 97, 97, 98, 97, 97, 97, 
+98, 97, 97, 97, 98, 97, 97, 97, 98, 97, 97, 97, 98, 97, 97, 97, 
+98, 97, 97, 97, 98, 97, 97, 97, 98, 97, 97, 97, 98, 97, 97, 97, 
+98, 97, 97, 97, 98, 97, 97, 97, 98, 97, 97, 97, 98, 97, 97, 97, 
+98, 97, 97, 97, 98, 97, 97, 97, 98, 97, 97, 97, 98, 97, 97, 97, 
+98, 97, 97, 97, 98, 97, 97, 97, 98, 97, 97, 97, 98, 97, 97, 97, 
+98, 97, 97, 97, 98, 97, 97, 97, 98, 97, 97, 97, 98, 97, 97, 97, 
+98, 97, 97, 97, 98, 97, 97, 97, 98, 97, 97, 97, 98, 97, 97, 97, 
+98, 97, 97, 97, 98, 97, 97, 97, 98, 97, 97, 97, 98, 97, 97, 97, 
+98, 97, 97, 97, 98, 97, 97, 97, 98, 97, 97, 97, 98, 97, 97, 97, 
+98, 97, 97, 97, 98, 97, 97, 97, 98, 97, 97, 97, 98, 97, 97, 97, 
+98, 97, 97, 97, 98, 97, 97, 97, 98, 97, 97, 97, 98, 97, 97, 97, 
+98, 97, 97, 97, 98, 97, 97, 97, 98, 97, 97, 97, 98, 97, 97, 97, 
+98, 97, 97, 97, 98, 97, 97, 97, 98, 97, 97, 97, 98, 97, 97, 97, 
+98, 97, 97, 97, 98, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 
+97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 
+97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 
+97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 
+97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 
+97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 
+97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 
+97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 
+97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 
+97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 
+97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 
+97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 
+97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 
+97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 
+97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 
+97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 
+97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 
+97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 
+97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 
+97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 
+97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 
+97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 
+97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 
+97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 
+97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 
+97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 
+97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 
+97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 
+97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 
+97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, 
+97, 97, 97, 97, 97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 
+97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 
+97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 
+97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 
+97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 
+97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 
+97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 
+97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 
+97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 
+97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 
+97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 
+97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 
+97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 
+97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 
+97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 
+97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 
+97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 
+97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 
+97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 
+97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 
+97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 
+97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 
+97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 
+97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 
+97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 
+97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 
+97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 
+97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 
+97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 
+97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 
+97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 
+97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 
+97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 
+97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 97, 97, 97, 96, 
+97, 97, 97, 96, 97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 
+97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 
+97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 
+97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 
+97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 
+97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 
+97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 
+97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 
+97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 
+97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 
+97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 
+97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 
+97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 
+97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 
+97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 
+97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 
+97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 
+97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 
+97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 
+97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 
+97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 
+97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 
+97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 
+97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 
+97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 
+97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 
+97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 
+97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 
+97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 
+97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 
+97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 
+97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 
+97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 
+97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 
+97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 
+97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 
+97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 
+97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 
+97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 97, 97, 96, 96, 
+97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 
+97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 
+97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 
+97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 
+97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 
+97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 
+97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 
+97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 
+97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 
+97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 
+97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 
+97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 
+97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 
+97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 
+97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 
+97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 
+97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 
+97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 
+97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 
+97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 
+97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 
+97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 
+97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 
+97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 
+97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 
+97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 
+97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 
+97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 
+97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 
+97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 
+97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 
+97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 
+97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 
+97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 
+97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 
+97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 
+97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 
+97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 
+97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 
+97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 
+97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 
+97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 
+97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 
+97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 97, 96, 96, 96, 
+97, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 
+96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 
+96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 
+96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 
+96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 
+96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 
+96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 
+96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 
+96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 
+96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 
+96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 
+96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 
+96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 
+96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 
+96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 
+96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 
+96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 
+96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 
+96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 
+96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 
+96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 
+96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 
+96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 
+96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 
+96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 
+96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 
+96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 
+96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 
+96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 
+96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 
+96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 
+96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 
+96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 
+96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 
+96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 
+96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 
+96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 
+96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 
+96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 
+96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 
+96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 
+96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 
+96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 
+96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 
+96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 
+96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 
+96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 
+96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 
+96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 
+96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 
+96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 
+96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 96, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 
+96, 96, 95, 95, 96, 96, 95, 95, 96, 96, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 96, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 
+95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 
+95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 95, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 95, 95, 94, 94, 
+95, 95, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 95, 94, 94, 94, 
+95, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, 
+94, 94, 94, 94, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 94, 94, 94, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 94, 94, 93, 93, 
+94, 94, 93, 93, 94, 94, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 94, 93, 93, 93, 
+94, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 
+93, 93, 93, 93, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, 
+93, 93, 93, 92, 93, 93, 93, 92, 93, 93, 93, 92, };
+static uint32_t  table_4_3_value[TABLE_4_3_SIZE]={
+0, 0, 0, 0, 1073741824, 1276901417, 1518500250, 1805811301, 1352829926, 1608794974, 1913190429, 1137589835, 1161452763, 1381207890, 1642542250, 1953322930, 
+1704458901, 2026954652, 1205234447, 1433273380, 1147545432, 1364669193, 1622874314, 1929933681, 1463338785, 1740212895, 2069473556, 1230516338, 1797244940, 2137296470, 1270844085, 1511296828, 
+2147483648, 1276901417, 1518500250, 1805811301, 1256328562, 1494034864, 1776716890, 2112884368, 1445816646, 1719375443, 2044693510, 1215782035, 1641736552, 1952364788, 1160883049, 1380530381, 
+1843691338, 1096265429, 1303686648, 1550353437, 2051340197, 1219734179, 1450516564, 1724964618, 1132193366, 1346412406, 1601163213, 1904114686, 1241285180, 1476145168, 1755442337, 2087584517, 
+1352829926, 1608794974, 1913190429, 1137589835, 1466724186, 1744238838, 2074261236, 1233363110, 1582874800, 1882365975, 1119261505, 1331033745, 1701197332, 2023075971, 1202928169, 1430530738, 
+1821614827, 1083138656, 1288076197, 1531789378, 1944056807, 1155943093, 1374655751, 1634750400, 2068458440, 1229912747, 1462620990, 1739359287, 1097379924, 1305012013, 1551929571, 1845565688, 
+1161452763, 1381207890, 1642542250, 1953322930, 1226421930, 1458469685, 1734422526, 2062587608, 1292263347, 1536768767, 1827536352, 1086659616, 1358954496, 1616078356, 1921851879, 1142739964, 
+1426474254, 1696373333, 2017339237, 1199517087, 1494802767, 1777630086, 2113970346, 1256974288, 1563921327, 1859826370, 1105859376, 1315095838, 1633812274, 1942941181, 1155279738, 1373866884, 
+1704458901, 2026954652, 1205234447, 1433273380, 1775845377, 2111847958, 1255712309, 1493302012, 1847956676, 1098801614, 1306702697, 1553940145, 1920778511, 1142101736, 1358195510, 1615175765, 
+1994297280, 1185816257, 1410181130, 1676997434, 2068500013, 1229937467, 1462650386, 1739394246, 2143374328, 1274458001, 1515594522, 1802355789, 1109454194, 1319370821, 1569005168, 1865872110, 
+1147545432, 1364669193, 1622874314, 1929933681, 1185955452, 1410346661, 1677194284, 1994531376, 1224679047, 1456397036, 1731957717, 2059656440, 1263711219, 1502814373, 1787157545, 2125300468, 
+1303047165, 1549592959, 1842786973, 1095727690, 1342682263, 1596727301, 1898839467, 1129056702, 1382612066, 1644212106, 1955308735, 1162633530, 1422832284, 1692042276, 2012188714, 1196454567, 
+1463338785, 1740212895, 2069473556, 1230516338, 1504127577, 1788719216, 2127157618, 1264815487, 1545194805, 1837556656, 1092617725, 1299348772, 1586536745, 1886720786, 1121850891, 1334113062, 
+1628149793, 1936207319, 1151275760, 1369105325, 1670030463, 1986012108, 1180889865, 1404322629, 1712175375, 2036131139, 1210690818, 1439762135, 1754581259, 2086560517, 1240676306, 1475421091, 
+1797244940, 2137296470, 1270844085, 1511296828, 1840163341, 1094167669, 1301191977, 1547386757, 1883333472, 1119836782, 1331717869, 1583688365, 1926752432, 1145653850, 1362419710, 1620199213, 
+1970417401, 1171617196, 1393295506, 1656916929, 2014325637, 1197725190, 1424343318, 1693839208, 2058474476, 1223976246, 1455561261, 1730963807, 2102861321, 1250368822, 1486947500, 1768288547, 
+2147483648, 1276901417, 1518500250, 1805811301, 1096169499, 1303572567, 1550217772, 1843530004, 1118712486, 1330380848, 1582098370, 1881442639, 1141369619, 1357324871, 1614140395, 1919547242, 
+1164139758, 1384403283, 1646342234, 1957841898, 1187021793, 1411614761, 1678702318, 1996324740, 1210014639, 1438958018, 1711219114, 2034993945, 1233117240, 1466431795, 1743891125, 2073847733, 
+1256328562, 1494034864, 1776716890, 2112884368, 1279647595, 1521766025, 1809694984, 1076051075, 1303073354, 1549624104, 1842824010, 1095749712, 1326604876, 1577607957, 1876102607, 1115537284, 
+1350241217, 1605716462, 1909529442, 1135412999, 1373981457, 1633948524, 1943103210, 1155376082, 1397824693, 1662303071, 1976822639, 1175425774, 1421770044, 1690779052, 2010686479, 1195561333, 
+1445816646, 1719375443, 2044693510, 1215782035, 1469963653, 1748091235, 2078842535, 1236087167, 1494210238, 1776925446, 2113132384, 1256476033, 1518555589, 1805877111, 1073780954, 1276947951, 
+1542998910, 1834945283, 1091064993, 1297502252, 1567539424, 1864129036, 1108417756, 1318138282, 1592176366, 1893427462, 1125838705, 1338855398, 1616908986, 1922839671, 1143327309, 1359652971, 
+1641736552, 1952364788, 1160883049, 1380530381, 1666658341, 1982001957, 1178505415, 1401487024, 1691673647, 2011750337, 1196193907, 1422522305, 1716781775, 2041609102, 1213948035, 1443635641, 
+1741982045, 2071577442, 1231767317, 1464826457, 1767273788, 2101654562, 1249651279, 1486094193, 1792656346, 2131839681, 1267599458, 1507438295, 1818129074, 1081066015, 1285611397, 1528858220, 
+1843691338, 1096265429, 1303686648, 1550353437, 1869342516, 1111517710, 1321824769, 1571923421, 1895081995, 1126822496, 1340025330, 1593567657, 1920909174, 1142179429, 1358287903, 1615285639, 
+1946823461, 1157588156, 1376612071, 1637076870, 1972824274, 1173048332, 1394997422, 1658940860, 1998911042, 1188559616, 1413443553, 1680877129, 2025083200, 1204121675, 1431950063, 1702885204, 
+2051340197, 1219734179, 1450516564, 1724964618, 2077681487, 1235396803, 1469142669, 1747114914, 2104106534, 1251109230, 1487827998, 1769335642, 2130614810, 1266871146, 1506572180, 1791626356, 
+1078602898, 1282682241, 1525374847, 1813986621, 1091939491, 1298542212, 1544235637, 1836416007, 1105316931, 1314450759, 1563154194, 1858914090, 1118734971, 1330407587, 1582130168, 1881480453, 
+1132193366, 1346412406, 1601163213, 1904114686, 1145691876, 1362464931, 1620252989, 1926816383, 1159230264, 1378564878, 1639399161, 1949585147, 1172808296, 1394711970, 1658601399, 1972420584, 
+1186425743, 1410905934, 1677859376, 1995322308, 1200082376, 1427146500, 1697172772, 2018289936, 1213777973, 1443433402, 1716541272, 2041323093, 1227512314, 1459766377, 1735964562, 2064421409, 
+1241285180, 1476145168, 1755442337, 2087584517, 1255096358, 1492569519, 1774974292, 2110812057, 1268945636, 1509039179, 1794560128, 2134103673, 1282832806, 1525553900, 1814199552, 1078729508, 
+1296757661, 1542113437, 1833892272, 1090438869, 1310720000, 1558717550, 1853638000, 1102179749, 1324719622, 1575365999, 1873436455, 1113951981, 1338756329, 1592058551, 1893287357, 1125755398, 
+1352829926, 1608794974, 1913190429, 1137589835, 1366940222, 1625575038, 1933145401, 1149455132, 1381087026, 1642398517, 1953152002, 1161351129, 1395270150, 1659265190, 1973209969, 1173277667, 
+1409489410, 1676174835, 1993319040, 1185234592, 1423744623, 1693127236, 2013478955, 1197221750, 1438035608, 1710122177, 2033689461, 1209238988, 1452362188, 1727159448, 2053950304, 1221286158, 
+1466724186, 1744238838, 2074261236, 1233363110, 1481121428, 1761360141, 2094622011, 1245469699, 1495553743, 1778523152, 2115032387, 1257605781, 1510020961, 1795727671, 2135492123, 1269771213, 
+1524522915, 1812973497, 1078000491, 1281965854, 1539059438, 1830260434, 1088279365, 1294189564, 1553630368, 1847588287, 1098582568, 1306442207, 1568235542, 1864956864, 1108909986, 1318723645, 
+1582874800, 1882365975, 1119261505, 1331033745, 1597547986, 1899815431, 1129637014, 1343372374, 1612254941, 1917305047, 1140036402, 1355739401, 1626995513, 1934834640, 1150459560, 1368134695, 
+1641769549, 1952404028, 1160906381, 1380558128, 1656576896, 1970013032, 1171376757, 1393009574, 1671417408, 1987661473, 1181870583, 1405488907, 1686290935, 2005349178, 1192387755, 1417996002, 
+1701197332, 2023075971, 1202928169, 1430530738, 1716136454, 2040841682, 1213491724, 1443092992, 1731108159, 2058646140, 1224078319, 1455682646, 1746112306, 2076489178, 1234687852, 1468299579, 
+1761148755, 2094370630, 1245320227, 1480943675, 1776217367, 2112290331, 1255975345, 1493614817, 1791318007, 2130248119, 1266653110, 1506312890, 1806450538, 1074121916, 1277353425, 1519037782, 
+1821614827, 1083138656, 1288076197, 1531789378, 1836810741, 1092174201, 1298821331, 1544567568, 1852038150, 1101228472, 1309588735, 1557372241, 1867296923, 1110301393, 1320378316, 1570203288, 
+1882586932, 1119392887, 1331189986, 1583060602, 1897908050, 1128502878, 1342023652, 1595944076, 1913260152, 1137631293, 1352879227, 1608853603, 1928643112, 1146778055, 1363756623, 1621789079, 
+1944056807, 1155943093, 1374655751, 1634750400, 1959501116, 1165126334, 1385576527, 1647737464, 1974975917, 1174327706, 1396518863, 1660750169, 1990481090, 1183547137, 1407482677, 1673788414, 
+2006016518, 1192784558, 1418467883, 1686852099, 2021582083, 1202039898, 1429474399, 1699941127, 2037177668, 1211313089, 1440502143, 1713055398, 2052803158, 1220604061, 1451551034, 1726194817, 
+2068458440, 1229912747, 1462620990, 1739359287, 2084143400, 1239239080, 1473711931, 1752548714, 2099857927, 1248582994, 1484823780, 1765763003, 2115601909, 1257944421, 1495956456, 1779002061, 
+2131375237, 1267323298, 1507109884, 1792265797, 2147177802, 1276719560, 1518283985, 1805554117, 1081504748, 1286133142, 1529478683, 1818866932, 1089435107, 1295563980, 1540693904, 1832204152, 
+1097379924, 1305012013, 1551929571, 1845565688, 1105339146, 1314477177, 1563185612, 1858951452, 1113312723, 1323959411, 1574461952, 1872361356, 1121300602, 1333458654, 1585758519, 1885795313, 
+1129302732, 1342974844, 1597075240, 1899253239, 1137319064, 1352507923, 1608412045, 1912735047, 1145349546, 1362057829, 1619768861, 1926240654, 1153394129, 1371624504, 1631145619, 1939769976, 
+1161452763, 1381207890, 1642542250, 1953322930, 1169525401, 1390807928, 1653958683, 1966899434, 1177611993, 1400424560, 1665394851, 1980499407, 1185712491, 1410057731, 1676850686, 1994122767, 
+1193826849, 1419707382, 1688326120, 2007769435, 1201955018, 1429373459, 1699821087, 2021439331, 1210096952, 1439055905, 1711335521, 2035132378, 1218252604, 1448754665, 1722869356, 2048848496, 
+1226421930, 1458469685, 1734422526, 2062587608, 1234604882, 1468200909, 1745994968, 2076349638, 1242801415, 1477948286, 1757586617, 2090134510, 1251011486, 1487711760, 1769197410, 2103942148, 
+1259235049, 1497491280, 1780827285, 2117772477, 1267472060, 1507286792, 1792476178, 2131625424, 1275722476, 1517098245, 1804144027, 2145500914, 1283986253, 1526925587, 1815830772, 1079699437, 
+1292263347, 1536768767, 1827536352, 1086659616, 1300553717, 1546627734, 1839260706, 1093630959, 1308857320, 1556502438, 1851003773, 1100613429, 1317174114, 1566392828, 1862765496, 1107606991, 
+1325504057, 1576298855, 1874545814, 1114611610, 1333847107, 1586220470, 1886344669, 1121627251, 1342203224, 1596157624, 1898162003, 1128653880, 1350572367, 1606110269, 1909997759, 1135691462, 
+1358954496, 1616078356, 1921851879, 1142739964, 1367349570, 1626061837, 1933724306, 1149799352, 1375757550, 1636060667, 1945614985, 1156869592, 1384178395, 1646074796, 1957523860, 1163950651, 
+1392612068, 1656104180, 1969450874, 1171042496, 1401058529, 1666148771, 1981395973, 1178145094, 1409517739, 1676208524, 1993359103, 1185258414, 1417989660, 1686283393, 2005340209, 1192382422, 
+1426474254, 1696373333, 2017339237, 1199517087, 1434971484, 1706478299, 2029356134, 1206662377, 1443481311, 1716598246, 2041390848, 1213818260, 1452003699, 1726733130, 2053443324, 1220984706, 
+1460538611, 1736882908, 2065513512, 1228161683, 1469086010, 1747047536, 2077601360, 1235349160, 1477645860, 1757226970, 2089706815, 1242547107, 1486218124, 1767421168, 2101829828, 1249755493, 
+1494802767, 1777630086, 2113970346, 1256974288, 1503399753, 1787853683, 2126128321, 1264203463, 1512009047, 1798091917, 2138303701, 1271442988, 1520630614, 1808344745, 1075248219, 1278692832, 
+1529264419, 1818612127, 1081353241, 1285952968, 1537910426, 1828894021, 1087466891, 1293223365, 1546568603, 1839190387, 1093589147, 1300503994, 1555238915, 1849501183, 1099719983, 1307794828, 
+1563921327, 1859826370, 1105859376, 1315095838, 1572615807, 1870165907, 1112007302, 1322406995, 1581322321, 1880519755, 1118163737, 1329728271, 1590040836, 1890887875, 1124328657, 1337059639, 
+1598771318, 1901270227, 1130502041, 1344401070, 1607513735, 1911666772, 1136683863, 1351752538, 1616268055, 1922077471, 1142874102, 1359114014, 1625034246, 1932502287, 1149072735, 1366485472, 
+1633812274, 1942941181, 1155279738, 1373866884, 1642602109, 1953394115, 1161495090, 1381258225, 1651403719, 1963861052, 1167718768, 1388659467, 1660217071, 1974341954, 1173950749, 1396070584, 
+1669042137, 1984836784, 1180191013, 1403491550, 1677878883, 1995345505, 1186439536, 1410922338, 1686727279, 2005868082, 1192696297, 1418362923, 1695587295, 2016404476, 1198961275, 1425813278, 
+1704458901, 2026954652, 1205234447, 1433273380, 1713342066, 2037518575, 1211515793, 1440743201, 1722236759, 2048096208, 1217805291, 1448222717, 1731142952, 2058687516, 1224102921, 1455711903, 
+1740060615, 2069292464, 1230408661, 1463210734, 1748989718, 2079911017, 1236722490, 1470719184, 1757930232, 2090543140, 1243044388, 1478237231, 1766882128, 2101188798, 1249374334, 1485764848, 
+1775845377, 2111847958, 1255712309, 1493302012, 1784819951, 2122520584, 1262058290, 1500848698, 1793805820, 2133206644, 1268412260, 1508404884, 1802802957, 2143906104, 1274774196, 1515970544, 
+1811811333, 1077309464, 1281144080, 1523545655, 1820830921, 1082672543, 1287521892, 1531130194, 1829861693, 1088042272, 1293907612, 1538724138, 1838903620, 1093418634, 1300301220, 1546327462, 
+1847956676, 1098801614, 1306702697, 1553940145, 1857020833, 1104191194, 1313112024, 1561562162, 1866096065, 1109587359, 1319529182, 1569193491, 1875182343, 1114990092, 1325954151, 1576834110, 
+1884279642, 1120399379, 1332386913, 1584483997, 1893387935, 1125815202, 1338827448, 1592143127, 1902507195, 1131237546, 1345275739, 1599811480, 1911637396, 1136666396, 1351731766, 1607489033, 
+1920778511, 1142101736, 1358195510, 1615175765, 1929930516, 1147543550, 1364666955, 1622871652, 1939093383, 1152991824, 1371146080, 1630576675, 1948267088, 1158446541, 1377632869, 1638290810, 
+1957451604, 1163907687, 1384127303, 1646014037, 1966646906, 1169375247, 1390629364, 1653746334, 1975852970, 1174849205, 1397139034, 1661487680, 1985069770, 1180329547, 1403656295, 1669238053, 
+1994297280, 1185816257, 1410181130, 1676997434, 2003535477, 1191309322, 1416713522, 1684765800, 2012784335, 1196808726, 1423253452, 1692543132, 2022043830, 1202314455, 1429800904, 1700329409, 
+2031313938, 1207826494, 1436355861, 1708124609, 2040594635, 1213344829, 1442918304, 1715928713, 2049885895, 1218869446, 1449488217, 1723741701, 2059187696, 1224400330, 1456065584, 1731563552, 
+2068500013, 1229937467, 1462650386, 1739394246, 2077822823, 1235480843, 1469242609, 1747233764, 2087156103, 1241030444, 1475842234, 1755082085, 2096499828, 1246586256, 1482449245, 1762939190, 
+2105853975, 1252148265, 1489063626, 1770805059, 2115218522, 1257716458, 1495685361, 1778679673, 2124593445, 1263290821, 1502314432, 1786563012, 2133978721, 1268871339, 1508950825, 1794455057, 
+2143374328, 1274458001, 1515594522, 1802355789, 1076390122, 1280050791, 1522245508, 1810265189, 1081098222, 1285649697, 1528903767, 1818183238, 1085811453, 1291254706, 1535569283, 1826109917, 
+1090529805, 1296865803, 1542242040, 1834045207, 1095253266, 1302482977, 1548922023, 1841989090, 1099981825, 1308106213, 1555609215, 1849941547, 1104715471, 1313735499, 1562303602, 1857902560, 
+1109454194, 1319370821, 1569005168, 1865872110, 1114197982, 1325012168, 1575713898, 1873850178, 1118946825, 1330659526, 1582429776, 1881836748, 1123700712, 1336312882, 1589152787, 1889831801, 
+1128459632, 1341972223, 1595882916, 1897835318, 1133223574, 1347637538, 1602620148, 1905847283, 1137992529, 1353308812, 1609364469, 1913867677, 1142766485, 1358986035, 1616115862, 1921896482, 
+1147545432, 1364669193, 1622874314, 1929933681, 1152329360, 1370358274, 1629639810, 1937979257, 1157118259, 1376053266, 1636412335, 1946033191, 1161912117, 1381754156, 1643191874, 1954095468, 
+1166710925, 1387460933, 1649978413, 1962166069, 1171514673, 1393173584, 1656771938, 1970244977, 1176323350, 1398892097, 1663572435, 1978332176, 1181136946, 1404616460, 1670379888, 1986427648, 
+1185955452, 1410346661, 1677194284, 1994531376, 1190778857, 1416082689, 1684015609, 2002643344, 1195607152, 1421824531, 1690843849, 2010763536, 1200440326, 1427572176, 1697678989, 2018891933, 
+1205278369, 1433325612, 1704521016, 2027028520, 1210121273, 1439084828, 1711369917, 2035173281, 1214969027, 1444849811, 1718225676, 2043326199, 1219821621, 1450620551, 1725088281, 2051487257, 
+1224679047, 1456397036, 1731957717, 2059656440, 1229541293, 1462179254, 1738833972, 2067833732, 1234408351, 1467967194, 1745717032, 2076019115, 1239280212, 1473760846, 1752606883, 2084212575, 
+1244156865, 1479560196, 1759503513, 2092414096, 1249038302, 1485365236, 1766406906, 2100623661, 1253924513, 1491175952, 1773317052, 2108841255, 1258815488, 1496992335, 1780233936, 2117066863, 
+1263711219, 1502814373, 1787157545, 2125300468, 1268611696, 1508642055, 1794087866, 2133542055, 1273516910, 1514475371, 1801024886, 2141791609, 1278426852, 1520314309, 1807968593, 1075024557, 
+1283341513, 1526158858, 1814918973, 1079157278, 1288260884, 1532009009, 1821876014, 1083293959, 1293184955, 1537864750, 1828839702, 1087434593, 1298113718, 1543726070, 1835810026, 1091579172, 
+1303047165, 1549592959, 1842786973, 1095727690, 1307985285, 1555465407, 1849770529, 1099880137, 1312928070, 1561343403, 1856760684, 1104036508, 1317875512, 1567226936, 1863757423, 1108196794, 
+1322827602, 1573115996, 1870760735, 1112360988, 1327784330, 1579010573, 1877770608, 1116529084, 1332745689, 1584910656, 1884787029, 1120701073, 1337711670, 1590816235, 1891809986, 1124876948, 
+1342682263, 1596727301, 1898839467, 1129056702, 1347657461, 1602643842, 1905875459, 1133240328, 1352637256, 1608565848, 1912917952, 1137427819, 1357621637, 1614493311, 1919966932, 1141619168, 
+1362610598, 1620426218, 1927022388, 1145814367, 1367604130, 1626364562, 1934084308, 1150013410, 1372602224, 1632308331, 1941152681, 1154216289, 1377604872, 1638257515, 1948227493, 1158422998, 
+1382612066, 1644212106, 1955308735, 1162633530, 1387623797, 1650172092, 1962396393, 1166847877, 1392640058, 1656137465, 1969490457, 1171066032, 1397660840, 1662108215, 1976590915, 1175287990, 
+1402686135, 1668084332, 1983697756, 1179513742, 1407715935, 1674065806, 1990810967, 1183743283, 1412750232, 1680052627, 1997930538, 1187976606, 1417789018, 1686044787, 2005056457, 1192213702, 
+1422832284, 1692042276, 2012188714, 1196454567, 1427880024, 1698045084, 2019327295, 1200699194, 1432932229, 1704053202, 2026472192, 1204947575, 1437988891, 1710066620, 2033623392, 1209199703, 
+1443050002, 1716085330, 2040780884, 1213455574, 1448115555, 1722109321, 2047944658, 1217715179, 1453185541, 1728138585, 2055114701, 1221978512, 1458259954, 1734173113, 2062291004, 1226245568, 
+1463338785, 1740212895, 2069473556, 1230516338, 1468422026, 1746257922, 2076662345, 1234790818, 1473509671, 1752308185, 2083857361, 1239069000, 1478601711, 1758363675, 2091058593, 1243350878, 
+1483698138, 1764424383, 2098266030, 1247636446, 1488798946, 1770490300, 2105479661, 1251925697, 1493904127, 1776561417, 2112699477, 1256218625, 1499013673, 1782637725, 2119925466, 1260515224, 
+1504127577, 1788719216, 2127157618, 1264815487, 1509245831, 1794805880, 2134395923, 1269119409, 1514368428, 1800897709, 2141640369, 1273426982, 1519495361, 1806994694, 1074445474, 1277738202, 
+1524626622, 1813096827, 1078073823, 1282053061, 1529762204, 1819204098, 1081705228, 1286371554, 1534902100, 1825316499, 1085339684, 1290693674, 1540046303, 1831434021, 1088977184, 1295019416, 
+1545194805, 1837556656, 1092617725, 1299348772, 1550347599, 1843684396, 1096261301, 1303681739, 1555504679, 1849817231, 1099907906, 1308018308, 1560666036, 1855955154, 1103557537, 1312358475, 
+1565831664, 1862098156, 1107210188, 1316702233, 1571001556, 1868246228, 1110865854, 1321049577, 1576175705, 1874399363, 1114524529, 1325400500, 1581354104, 1880557551, 1118186210, 1329754997, 
+1586536745, 1886720786, 1121850891, 1334113062, 1591723623, 1892889057, 1125518567, 1338474688, 1596914729, 1899062358, 1129189234, 1342839871, 1602110058, 1905240679, 1132862886, 1347208604, 
+1607309601, 1911424014, 1136539519, 1351580882, 1612513354, 1917612353, 1140219127, 1355956699, 1617721308, 1923805689, 1143901707, 1360336048, 1622933456, 1930004014, 1147587252, 1364718926, 
+1628149793, 1936207319, 1151275760, 1369105325, 1633370312, 1942415596, 1154967224, 1373495240, 1638595005, 1948628839, 1158661640, 1377888666, 1643823866, 1954847038, 1162359003, 1382285596, 
+1649056889, 1961070185, 1166059309, 1386686026, 1654294067, 1967298274, 1169762553, 1391089950, 1659535392, 1973531296, 1173468730, 1395497362, 1664780860, 1979769243, 1177177835, 1399908257, 
+1670030463, 1986012108, 1180889865, 1404322629, 1675284194, 1992259883, 1184604814, 1408740473, 1680542048, 1998512560, 1188322678, 1413161783, 1685804017, 2004770131, 1192043452, 1417586555, 
+1691070095, 2011032589, 1195767132, 1422014781, 1696340277, 2017299927, 1199493713, 1426446458, 1701614555, 2023572136, 1203223191, 1430881579, 1706892923, 2029849209, 1206955561, 1435320140, 
+1712175375, 2036131139, 1210690818, 1439762135, 1717461905, 2042417917, 1214428959, 1444207559, 1722752506, 2048709537, 1218169979, 1448656407, 1728047172, 2055005992, 1221913873, 1453108672, 
+1733345896, 2061307273, 1225660637, 1457564351, 1738648674, 2067613373, 1229410267, 1462023437, 1743955497, 2073924286, 1233162758, 1466485926, 1749266361, 2080240003, 1236918106, 1470951812, 
+1754581259, 2086560517, 1240676306, 1475421091, 1759900185, 2092885822, 1244437355, 1479893757, 1765223133, 2099215909, 1248201247, 1484369804, 1770550096, 2105550772, 1251967979, 1488849229, 
+1775881069, 2111890403, 1255737547, 1493332025, 1781216047, 2118234796, 1259509945, 1497818188, 1786555021, 2124583943, 1263285171, 1502307713, 1791897988, 2130937837, 1267063218, 1506800594, 
+1797244940, 2137296470, 1270844085, 1511296828, 1802595872, 2143659837, 1274627765, 1515796407, 1807950779, 1075013965, 1278414256, 1520299329, 1813309653, 1078200370, 1282203552, 1524805587, 
+1818672489, 1081389132, 1285995650, 1529315177, 1824039282, 1084580246, 1289790546, 1533828094, 1829410025, 1087773709, 1293588235, 1538344332, 1834784714, 1090969518, 1297388713, 1542863888, 
+1840163341, 1094167669, 1301191977, 1547386757, 1845545901, 1097368158, 1304998021, 1551912932, 1850932388, 1100570983, 1308806843, 1556442410, 1856322798, 1103776139, 1312618438, 1560975186, 
+1861717123, 1106983624, 1316432802, 1565511255, 1867115359, 1110193435, 1320249932, 1570050612, 1872517499, 1113405567, 1324069822, 1574593253, 1877923539, 1116620017, 1327892469, 1579139172, 
+1883333472, 1119836782, 1331717869, 1583688365, 1888747293, 1123055859, 1335546019, 1588240828, 1894164996, 1126277245, 1339376913, 1592796555, 1899586575, 1129500935, 1343210549, 1597355542, 
+1905012026, 1132726928, 1347046922, 1601917784, 1910441343, 1135955219, 1350886029, 1606483277, 1915874520, 1139185805, 1354727865, 1611052016, 1921311551, 1142418683, 1358572427, 1615623996, 
+1926752432, 1145653850, 1362419710, 1620199213, 1932197156, 1148891303, 1366269712, 1624777662, 1937645719, 1152131038, 1370122428, 1629359339, 1943098115, 1155373052, 1373977854, 1633944239, 
+1948554338, 1158617342, 1377835986, 1638532358, 1954014384, 1161863904, 1381696821, 1643123691, 1959478246, 1165112736, 1385560356, 1647718233, 1964945921, 1168363835, 1389426585, 1652315981, 
+1970417401, 1171617196, 1393295506, 1656916929, 1975892682, 1174872818, 1397167114, 1661521073, 1981371759, 1178130697, 1401041407, 1666128409, 1986854626, 1181390829, 1404918380, 1670738933, 
+1992341279, 1184653212, 1408798029, 1675352640, 1997831712, 1187917843, 1412680351, 1679969525, 2003325919, 1191184718, 1416565342, 1684589584, 2008823896, 1194453835, 1420452999, 1689212813, 
+2014325637, 1197725190, 1424343318, 1693839208, 2019831138, 1200998780, 1428236295, 1698468764, 2025340393, 1204274603, 1432131926, 1703101476, 2030853397, 1207552655, 1436030209, 1707737342, 
+2036370145, 1210832933, 1439931139, 1712376355, 2041890632, 1214115434, 1443834712, 1717018513, 2047414853, 1217400155, 1447740926, 1721663810, 2052942802, 1220687094, 1451649777, 1726312243, 
+2058474476, 1223976246, 1455561261, 1730963807, 2064009868, 1227267610, 1459475374, 1735618499, 2069548974, 1230561182, 1463392113, 1740276313, 2075091788, 1233856959, 1467311475, 1744937246, 
+2080638307, 1237154939, 1471233456, 1749601294, 2086188524, 1240455118, 1475158052, 1754268452, 2091742436, 1243757494, 1479085261, 1758938716, 2097300036, 1247062063, 1483015078, 1763612082, 
+2102861321, 1250368822, 1486947500, 1768288547, 2108426285, 1253677770, 1490882524, 1772968105, 2113994924, 1256988902, 1494820146, 1777650753, 2119567232, 1260302216, 1498760363, 1782336487, 
+2125143205, 1263617710, 1502703171, 1787025303, 2130722837, 1266935379, 1506648567, 1791717196, 2136306125, 1270255222, 1510596548, 1796412163, 2141893064, 1273577236, 1514547110, 1801110199, 
+2147483648, 1276901417, 1518500250, 1805811301, 1076538936, 1280227763, 1522455964, 1810515465, 1079337867, 1283556271, 1526414250, 1815222687, 1082138613, 1286886938, 1530375103, 1819932962, 
+1084941173, 1290219762, 1534338521, 1824646286, 1087745544, 1293554740, 1538304500, 1829362657, 1090551723, 1296891868, 1542273037, 1834082069, 1093359709, 1300231145, 1546244129, 1838804519, 
+1096169499, 1303572567, 1550217772, 1843530004, 1098981090, 1306916132, 1554193962, 1848258518, 1101794481, 1310261836, 1558172698, 1852990059, 1104609669, 1313609678, 1562153975, 1857724622, 
+1107426652, 1316959654, 1566137790, 1862462204, 1110245427, 1320311762, 1570124141, 1867202800, 1113065993, 1323665998, 1574113023, 1871946407, 1115888347, 1327022361, 1578104434, 1876693021, 
+1118712486, 1330380848, 1582098370, 1881442639, 1121538409, 1333741456, 1586094829, 1886195255, 1124366113, 1337104182, 1590093806, 1890950868, 1127195596, 1340469023, 1594095300, 1895709472, 
+1130026856, 1343835977, 1598099306, 1900471065, 1132859891, 1347205042, 1602105821, 1905235642, 1135694697, 1350576214, 1606114844, 1910003199, 1138531274, 1353949492, 1610126369, 1914773734, 
+1141369619, 1357324871, 1614140395, 1919547242, 1144209729, 1360702351, 1618156917, 1924323719, 1147051603, 1364081928, 1622175934, 1929103162, 1149895238, 1367463599, 1626197441, 1933885567, 
+1152740633, 1370847362, 1630221436, 1938670931, 1155587784, 1374233215, 1634247916, 1943459250, 1158436690, 1377621154, 1638276878, 1948250520, 1161287349, 1381011178, 1642308318, 1953044737, 
+1164139758, 1384403283, 1646342234, 1957841898, 1166993915, 1387797467, 1650378622, 1962642000, 1169849819, 1391193728, 1654417480, 1967445038, 1172707467, 1394592063, 1658458804, 1972251010, 
+1175566857, 1397992470, 1662502592, 1977059911, 1178427986, 1401394946, 1666548840, 1981871738, 1181290853, 1404799488, 1670597546, 1986686488, 1184155456, 1408206094, 1674648706, 1991504156, 
+1187021793, 1411614761, 1678702318, 1996324740, 1189889860, 1415025488, 1682758378, 2001148236, 1192759657, 1418438271, 1686816884, 2005974640, 1195631182, 1421853108, 1690877833, 2010803949, 
+1198504431, 1425269997, 1694941221, 2015636160, 1201379404, 1428688935, 1699007046, 2020471268, 1204256097, 1432109919, 1703075305, 2025309270, 1207134510, 1435532948, 1707145995, 2030150164, 
+1210014639, 1438958018, 1711219114, 2034993945, 1212896484, 1442385128, 1715294657, 2039840610, 1215780041, 1445814275, 1719372623, 2044690156, 1218665309, 1449245456, 1723453008, 2049542579, 
+1221552285, 1452678669, 1727535809, 2054397876, 1224440969, 1456113912, 1731621025, 2059256043, 1227331357, 1459551182, 1735708651, 2064117077, 1230223448, 1462990478, 1739798685, 2068980975, 
+1233117240, 1466431795, 1743891125, 2073847733, 1236012730, 1469875133, 1747985967, 2078717348, 1238909918, 1473320489, 1752083208, 2083589817, 1241808799, 1476767860, 1756182846, 2088465136, 
+1244709374, 1480217244, 1760284878, 2093343302, 1247611640, 1483668639, 1764389302, 2098224311, 1250515594, 1487122042, 1768496113, 2103108161, 1253421235, 1490577451, 1772605310, 2107994847, 
+1256328562, 1494034864, 1776716890, 2112884368, 1259237571, 1497494278, 1780830851, 2117776718, 1262148261, 1500955692, 1784947188, 2122671896, 1265060630, 1504419102, 1789065900, 2127569898, 
+1267974676, 1507884507, 1793186984, 2132470720, 1270890398, 1511351904, 1797310437, 2137374360, 1273807793, 1514821290, 1801436257, 2142280814, 1276726859, 1518292665, 1805564440, 2147190078, 
+1279647595, 1521766025, 1809694984, 1076051075, 1282569998, 1525241367, 1813827886, 1078508514, 1285494067, 1528718691, 1817963144, 1080967353, 1288419800, 1532197993, 1822100755, 1083427591, 
+1291347195, 1535679272, 1826240716, 1085889227, 1294276249, 1539162524, 1830383025, 1088352258, 1297206962, 1542647749, 1834527679, 1090816684, 1300139331, 1546134943, 1838674675, 1093282503, 
+1303073354, 1549624104, 1842824010, 1095749712, 1306009030, 1553115231, 1846975683, 1098218312, 1308946357, 1556608320, 1851129690, 1100688299, 1311885332, 1560103371, 1855286029, 1103159673, 
+1314825954, 1563600380, 1859444696, 1105632431, 1317768221, 1567099345, 1863605691, 1108106574, 1320712132, 1570600264, 1867769009, 1110582097, 1323657684, 1574103136, 1871934649, 1113059002, 
+1326604876, 1577607957, 1876102607, 1115537284, 1329553705, 1581114726, 1880272882, 1118016945, 1332504170, 1584623440, 1884445470, 1120497980, 1335456270, 1588134098, 1888620369, 1122980390, 
+1338410002, 1591646697, 1892797577, 1125464173, 1341365364, 1595161235, 1896977090, 1127949326, 1344322356, 1598677710, 1901158907, 1130435850, 1347280974, 1602196120, 1905343025, 1132923741, 
+1350241217, 1605716462, 1909529442, 1135412999, 1353203084, 1609238735, 1913718154, 1137903622, 1356166572, 1612762937, 1917909159, 1140395609, 1359131680, 1616289064, 1922102455, 1142888958, 
+1362098406, 1619817116, 1926298040, 1145383667, 1365066749, 1623347090, 1930495910, 1147879736, 1368036706, 1626878984, 1934696063, 1150377162, 1371008276, 1630412796, 1938898498, 1152875944, 
+1373981457, 1633948524, 1943103210, 1155376082, 1376956247, 1637486166, 1947310199, 1157877572, 1379932645, 1641025719, 1951519461, 1160380414, 1382910648, 1644567182, 1955730994, 1162884607, 
+1385890256, 1648110553, 1959944796, 1165390148, 1388871466, 1651655829, 1964160864, 1167897037, 1391854277, 1655203009, 1968379195, 1170405272, 1394838686, 1658752090, 1972599787, 1172914851, 
+1397824693, 1662303071, 1976822639, 1175425774, 1400812296, 1665855949, 1981047747, 1177938038, 1403801492, 1669410722, 1985275108, 1180451642, 1406792280, 1672967389, 1989504722, 1182966585, 
+1409784659, 1676525947, 1993736584, 1185482866, 1412778626, 1680086394, 1997970694, 1188000482, 1415774181, 1683648729, 2002207048, 1190519433, 1418771321, 1687212949, 2006445643, 1193039718, 
+1421770044, 1690779052, 2010686479, 1195561333, 1424770350, 1694347037, 2014929552, 1198084280, 1427772236, 1697916901, 2019174860, 1200608555, 1430775700, 1701488643, 2023422400, 1203134157, 
+1433780742, 1705062260, 2027672171, 1205661086, 1436787359, 1708637750, 2031924169, 1208189340, 1439795550, 1712215112, 2036178394, 1210718917, 1442805313, 1715794344, 2040434841, 1213249815, 
+1445816646, 1719375443, 2044693510, 1215782035, 1448829548, 1722958407, 2048954397, 1218315573, 1451844018, 1726543236, 2053217500, 1220850430, 1454860052, 1730129926, 2057482818, 1223386603, 
+1457877651, 1733718476, 2061750347, 1225924091, 1460896812, 1737308884, 2066020085, 1228462893, 1463917534, 1740901147, 2070292031, 1231003007, 1466939815, 1744495265, 2074566182, 1233544432, 
+1469963653, 1748091235, 2078842535, 1236087167, 1472989048, 1751689056, 2083121088, 1238631210, 1476015996, 1755288725, 2087401840, 1241176560, 1479044497, 1758890240, 2091684788, 1243723216, 
+1482074550, 1762493599, 2095969929, 1246271176, 1485106151, 1766098802, 2100257261, 1248820439, 1488139301, 1769705845, 2104546782, 1251371004, 1491173997, 1773314727, 2108838491, 1253922869, 
+1494210238, 1776925446, 2113132384, 1256476033, 1497248022, 1780538001, 2117428459, 1259030494, 1500287348, 1784152388, 2121726715, 1261586253, 1503328213, 1787768608, 2126027148, 1264143306, 
+1506370618, 1791386656, 2130329757, 1266701652, 1509414559, 1795006533, 2134634540, 1269261292, 1512460035, 1798628235, 2138941495, 1271822222, 1515507046, 1802251762, 2143250618, 1274384442, 
+1518555589, 1805877111, 1073780954, 1276947951, 1521605662, 1809504280, 1075937682, 1279512747, 1524657265, 1813133267, 1078095491, 1282078829, 1527710395, 1816764072, 1080254380, 1284646195, 
+1530765052, 1820396691, 1082414349, 1287214845, 1533821233, 1824031124, 1084575395, 1289784777, 1536878938, 1827667368, 1086737519, 1292355990, 1539938164, 1831305421, 1088900718, 1294928482, 
+1542998910, 1834945283, 1091064993, 1297502252, 1546061175, 1838586950, 1093230341, 1300077300, 1549124957, 1842230421, 1095396762, 1302653623, 1552190255, 1845875695, 1097564255, 1305231221, 
+1555257066, 1849522769, 1099732818, 1307810092, 1558325390, 1853171642, 1101902451, 1310390235, 1561395226, 1856822312, 1104073152, 1312971648, 1564466571, 1860474777, 1106244921, 1315554331, 
+1567539424, 1864129036, 1108417756, 1318138282, 1570613784, 1867785087, 1110591657, 1320723500, 1573689649, 1871442927, 1112766622, 1323309984, 1576767017, 1875102556, 1114942650, 1325897733, 
+1579845888, 1878763971, 1117119741, 1328486744, 1582926260, 1882427171, 1119297893, 1331077018, 1586008131, 1886092154, 1121477105, 1333668552, 1589091500, 1889758918, 1123657376, 1336261346, 
+1592176366, 1893427462, 1125838705, 1338855398, 1595262726, 1897097784, 1128021091, 1341450708, 1598350580, 1900769882, 1130204534, 1344047273, 1601439926, 1904443754, 1132389031, 1346645093, 
+1604530762, 1908119399, 1134574583, 1349244166, 1607623088, 1911796815, 1136761187, 1351844492, 1610716902, 1915476000, 1138948844, 1354446069, 1613812202, 1919156952, 1141137551, 1357048895, 
+1616908986, 1922839671, 1143327309, 1359652971, 1620007255, 1926524154, 1145518115, 1362258293, 1623107005, 1930210399, 1147709970, 1364864862, 1626208236, 1933898405, 1149902871, 1367472676, 
+1629310946, 1937588170, 1152096819, 1370081734, 1632415135, 1941279693, 1154291811, 1372692035, 1635520799, 1944972971, 1156487848, 1375303577, 1638627939, 1948668003, 1158684927, 1377916360, 
+1641736552, 1952364788, 1160883049, 1380530381, 1644846637, 1956063324, 1163082211, 1383145641, 1647958193, 1959763609, 1165282414, 1385762137, 1651071219, 1963465641, 1167483655, 1388379870, 
+1654185713, 1967169419, 1169685935, 1390998836, 1657301673, 1970874942, 1171889252, 1393619036, 1660419099, 1974582207, 1174093605, 1396240468, 1663537989, 1978291212, 1176298993, 1398863131, 
+1666658341, 1982001957, 1178505415, 1401487024, 1669780154, 1985714440, 1180712870, 1404112146, 1672903428, 1989428659, 1182921358, 1406738495, 1676028159, 1993144612, 1185130877, 1409366071, 
+1679154348, 1996862298, 1187341426, 1411994872, 1682281993, 2000581715, 1189553005, 1414624897, 1685411091, 2004302862, 1191765612, 1417256145, 1688541643, 2008025736, 1193979246, 1419888615, 
+1691673647, 2011750337, 1196193907, 1422522305, 1694807101, 2015476663, 1198409594, 1425157216, 1697942004, 2019204712, 1200626305, 1427793344, 1701078354, 2022934482, 1202844040, 1430430690, 
+1704216151, 2026665972, 1205062797, 1433069252, 1707355393, 2030399181, 1207282576, 1435709030, 1710496079, 2034134107, 1209503376, 1438350021, 1713638207, 2037870748, 1211725196, 1440992225, 
+1716781775, 2041609102, 1213948035, 1443635641, 1719926784, 2045349169, 1216171892, 1446280267, 1723073231, 2049090946, 1218396766, 1448926103, 1726221115, 2052834432, 1220622656, 1451573148, 
+1729370435, 2056579626, 1222849562, 1454221399, 1732521189, 2060326525, 1225077481, 1456870857, 1735673376, 2064075129, 1227306414, 1459521520, 1738826996, 2067825435, 1229536360, 1462173387, 
+1741982045, 2071577442, 1231767317, 1464826457, 1745138524, 2075331150, 1233999285, 1467480729, 1748296431, 2079086555, 1236232262, 1470136202, 1751455765, 2082843657, 1238466248, 1472792874, 
+1754616524, 2086602454, 1240701242, 1475450745, 1757778707, 2090362945, 1242937243, 1478109813, 1760942313, 2094125127, 1245174251, 1480770078, 1764107340, 2097889000, 1247412263, 1483431538, 
+1767273788, 2101654562, 1249651279, 1486094193, 1770441654, 2105421812, 1251891299, 1488758040, 1773610939, 2109190747, 1254132322, 1491423080, 1776781639, 2112961367, 1256374346, 1494089311, 
+1779953755, 2116733670, 1258617371, 1496756732, 1783127285, 2120507654, 1260861395, 1499425342, 1786302228, 2124283319, 1263106418, 1502095140, 1789478581, 2128060661, 1265352440, 1504766124, 
+1792656346, 2131839681, 1267599458, 1507438295, 1795835518, 2135620376, 1269847473, 1510111650, 1799016099, 2139402745, 1272096483, 1512786189, 1802198086, 2143186787, 1274346488, 1515461910, 
+1805381478, 2146972499, 1276597486, 1518138813, 1808566274, 1075379941, 1278849477, 1520816897, 1811752473, 1077274466, 1281102459, 1523496160, 1814940073, 1079169824, 1283356433, 1526176601, 
+1818129074, 1081066015, 1285611397, 1528858220, 1821319473, 1082963038, 1287867350, 1531541016, 1824511270, 1084860892, 1290124292, 1534224987, 1827704464, 1086759576, 1292382220, 1536910132, 
+1830899053, 1088659090, 1294641136, 1539596450, 1834095036, 1090559433, 1296901037, 1542283941, 1837292412, 1092460604, 1299161924, 1544972603, 1840491180, 1094362603, 1301423794, 1547662436, 
+1843691338, 1096265429, 1303686648, 1550353437, 1846892886, 1098169080, 1305950484, 1553045607, 1850095821, 1100073557, 1308215301, 1555738944, 1853300143, 1101978858, 1310481099, 1558433447, 
+1856505851, 1103884984, 1312747877, 1561129115, 1859712944, 1105791932, 1315015634, 1563825948, 1862921420, 1107699703, 1317284369, 1566523944, 1866131277, 1109608296, 1319554081, 1569223102, 
+1869342516, 1111517710, 1321824769, 1571923421, 1872555134, 1113427945, 1324096434, 1574624900, 1875769131, 1115338999, 1326369073, 1577327538, 1878984506, 1117250872, 1328642686, 1580031335, 
+1882201256, 1119163563, 1330917272, 1582736289, 1885419381, 1121077071, 1333192830, 1585442399, 1888638880, 1122991397, 1335469360, 1588149664, 1891859752, 1124906539, 1337746860, 1590858084, 
+1895081995, 1126822496, 1340025330, 1593567657, 1898305609, 1128739268, 1342304769, 1596278382, 1901530592, 1130656854, 1344585176, 1598990258, 1904756942, 1132575254, 1346866550, 1601703285, 
+1907984660, 1134494466, 1349148891, 1604417461, 1911213743, 1136414491, 1351432198, 1607132785, 1914444190, 1138335326, 1353716469, 1609849257, 1917676001, 1140256972, 1356001705, 1612566875, 
+1920909174, 1142179429, 1358287903, 1615285639, 1924143708, 1144102694, 1360575064, 1618005547, 1927379602, 1146026768, 1362863187, 1620726599, 1930616855, 1147951650, 1365152270, 1623448793, 
+1933855466, 1149877340, 1367442314, 1626172129, 1937095433, 1151803836, 1369733316, 1628896605, 1940336755, 1153731137, 1372025277, 1631622222, 1943579432, 1155659244, 1374318196, 1634348977, 
+1946823461, 1157588156, 1376612071, 1637076870, 1950068843, 1159517871, 1378906902, 1639805899, 1953315575, 1161448390, 1381202689, 1642536065, 1956563657, 1163379711, 1383499430, 1645267366, 
+1959813088, 1165311834, 1385797124, 1647999800, 1963063866, 1167244758, 1388095772, 1650733368, 1966315991, 1169178483, 1390395371, 1653468068, 1969569460, 1171113008, 1392695921, 1656203899, 
+1972824274, 1173048332, 1394997422, 1658940860, 1976080431, 1174984454, 1397299873, 1661678951, 1979337930, 1176921375, 1399603273, 1664418170, 1982596770, 1178859092, 1401907620, 1667158517, 
+1985856949, 1180797607, 1404212915, 1669899990, 1989118467, 1182736917, 1406519157, 1672642588, 1992381323, 1184677022, 1408826344, 1675386312, 1995645514, 1186617922, 1411134476, 1678131159, 
+1998911042, 1188559616, 1413443553, 1680877129, 2002177903, 1190502104, 1415753572, 1683624221, 2005446098, 1192445384, 1418064535, 1686372434, 2008715624, 1194389456, 1420376439, 1689121768, 
+2011986482, 1196334320, 1422689285, 1691872220, 2015258669, 1198279974, 1425003071, 1694623791, 2018532186, 1200226419, 1427317797, 1697376479, 2021807030, 1202173652, 1429633461, 1700130284, 
+2025083200, 1204121675, 1431950063, 1702885204, 2028360697, 1206070486, 1434267603, 1705641239, 2031639517, 1208020085, 1436586080, 1708398387, 2034919662, 1209970470, 1438905492, 1711156649, 
+2038201128, 1211921642, 1441225839, 1713916022, 2041483916, 1213873599, 1443547121, 1716676507, 2044768024, 1215826342, 1445869336, 1719438102, 2048053452, 1217779868, 1448192484, 1722200806, 
+2051340197, 1219734179, 1450516564, 1724964618, 2054628260, 1221689273, 1452841575, 1727729538, 2057917638, 1223645149, 1455167517, 1730495565, 2061208332, 1225601807, 1457494389, 1733262697, 
+2064500339, 1227559246, 1459822190, 1736030934, 2067793659, 1229517466, 1462150919, 1738800276, 2071088291, 1231476466, 1464480575, 1741570720, 2074384234, 1233436245, 1466811159, 1744342266, 
+2077681487, 1235396803, 1469142669, 1747114914, 2080980048, 1237358140, 1471475104, 1749888663, 2084279917, 1239320254, 1473808463, 1752663511, 2087581093, 1241283144, 1476142747, 1755439457, 
+2090883574, 1243246811, 1478477954, 1758216502, 2094187360, 1245211254, 1480814083, 1760994644, 2097492449, 1247176472, 1483151134, 1763773881, 2100798841, 1249142464, 1485489106, 1766554214, 
+2104106534, 1251109230, 1487827998, 1769335642, 2107415527, 1253076770, 1490167810, 1772118162, 2110725821, 1255045082, 1492508541, 1774901776, 2114037412, 1257014166, 1494850190, 1777686481, 
+2117350301, 1258984021, 1497192756, 1780472278, 2120664486, 1260954648, 1499536239, 1783259164, 2123979967, 1262926044, 1501880638, 1786047140, 2127296742, 1264898211, 1504225952, 1788836204, 
+2130614810, 1266871146, 1506572180, 1791626356, 2133934171, 1268844849, 1508919323, 1794417595, 2137254823, 1270819321, 1511267378, 1797209919, 2140576765, 1272794560, 1513616346, 1800003328, 
+2143899997, 1274770565, 1515966226, 1802797822, 2147224517, 1276747336, 1518317016, 1805593399, 1075275162, 1278724873, 1520668717, 1808390058, 1076938709, 1280703175, 1523021328, 1811187799, 
+1078602898, 1282682241, 1525374847, 1813986621, 1080267730, 1284662071, 1527729275, 1816786523, 1081933203, 1286642663, 1530084610, 1819587504, 1083599318, 1288624018, 1532440851, 1822389564, 
+1085266073, 1290606136, 1534797999, 1825192701, 1086933468, 1292589014, 1537156052, 1827996914, 1088601503, 1294572653, 1539515010, 1830802204, 1090270178, 1296557053, 1541874872, 1833608568, 
+1091939491, 1298542212, 1544235637, 1836416007, 1093609442, 1300528130, 1546597305, 1839224519, 1095280031, 1302514806, 1548959875, 1842034104, 1096951257, 1304502240, 1551323346, 1844844760, 
+1098623121, 1306490432, 1553687717, 1847656488, 1100295620, 1308479380, 1556052988, 1850469285, 1101968755, 1310469084, 1558419159, 1853283152, 1103642526, 1312459544, 1560786228, 1856098087, 
+1105316931, 1314450759, 1563154194, 1858914090, 1106991971, 1316442728, 1565523058, 1861731160, 1108667644, 1318435451, 1567892819, 1864549296, 1110343951, 1320428927, 1570263475, 1867368497, 
+1112020891, 1322423156, 1572635026, 1870188762, 1113698464, 1324418137, 1575007472, 1873010092, 1115376668, 1326413870, 1577380811, 1875832484, 1117055504, 1328410353, 1579755044, 1878655938, 
+1118734971, 1330407587, 1582130168, 1881480453, 1120415068, 1332405571, 1584506185, 1884306029, 1122095796, 1334404304, 1586883093, 1887132664, 1123777153, 1336403786, 1589260891, 1889960359, 
+1125459139, 1338404016, 1591639578, 1892789111, 1127141754, 1340404993, 1594019155, 1895618921, 1128824997, 1342406718, 1596399620, 1898449787, 1130508868, 1344409189, 1598780973, 1901281709, 
+1132193366, 1346412406, 1601163213, 1904114686, 1133878491, 1348416369, 1603546340, 1906948717, 1135564242, 1350421076, 1605930352, 1909783801, 1137250619, 1352426528, 1608315249, 1912619938, 
+1138937622, 1354432723, 1610701031, 1915457126, 1140625249, 1356439662, 1613087697, 1918295366, 1142313501, 1358447343, 1615475245, 1921134656, 1144002377, 1360455766, 1617863676, 1923974995, 
+1145691876, 1362464931, 1620252989, 1926816383, 1147381999, 1364474836, 1622643184, 1929658819, 1149072744, 1366485482, 1625034258, 1932502302, 1150764111, 1368496868, 1627426213, 1935346831, 
+1152456100, 1370508994, 1629819047, 1938192406, 1154148710, 1372521858, 1632212759, 1941039026, 1155841941, 1374535460, 1634607349, 1943886690, 1157535793, 1376549801, 1637002817, 1946735397, 
+1159230264, 1378564878, 1639399161, 1949585147, 1160925355, 1380580692, 1641796382, 1952435938, 1162621064, 1382597242, 1644194477, 1955287771, 1164317393, 1384614528, 1646593448, 1958140643, 
+1166014339, 1386632548, 1648993292, 1960994556, 1167711903, 1388651303, 1651394010, 1963849507, 1169410084, 1390670792, 1653795601, 1966705495, 1171108882, 1392691015, 1656198064, 1969562522, 
+1172808296, 1394711970, 1658601399, 1972420584, 1174508326, 1396733658, 1661005604, 1975279682, 1176208972, 1398756078, 1663410680, 1978139816, 1177910232, 1400779229, 1665816625, 1981000983, 
+1179612107, 1402803110, 1668223440, 1983863184, 1181314596, 1404827722, 1670631123, 1986726418, 1183017698, 1406853064, 1673039674, 1989590683, 1184721414, 1408879135, 1675449091, 1992455980, 
+1186425743, 1410905934, 1677859376, 1995322308, 1188130683, 1412933462, 1680270526, 1998189665, 1189836236, 1414961717, 1682682542, 2001058051, 1191542400, 1416990700, 1685095422, 2003927465, 
+1193249175, 1419020409, 1687509167, 2006797907, 1194956561, 1421050844, 1689923774, 2009669376, 1196664556, 1423082005, 1692339245, 2012541871, 1198373162, 1425113890, 1694755578, 2015415391, 
+1200082376, 1427146500, 1697172772, 2018289936, 1201792200, 1429179834, 1699590828, 2021165505, 1203502631, 1431213892, 1702009743, 2024042097, 1205213671, 1433248673, 1704429519, 2026919711, 
+1206925318, 1435284176, 1706850154, 2029798347, 1208637572, 1437320401, 1709271647, 2032678004, 1210350433, 1439357347, 1711693998, 2035558681, 1212063900, 1441395014, 1714117207, 2038440378, 
+1213777973, 1443433402, 1716541272, 2041323093, 1215492652, 1445472510, 1718966193, 2044206827, 1217207935, 1447512337, 1721391970, 2047091578, 1218923823, 1449552882, 1723818601, 2049977346, 
+1220640314, 1451594147, 1726246087, 2052864129, 1222357410, 1453636129, 1728674427, 2055751928, 1224075109, 1455678828, 1731103620, 2058640741, 1225793410, 1457722245, 1733533665, 2061530569, 
+1227512314, 1459766377, 1735964562, 2064421409, 1229231820, 1461811226, 1738396311, 2067313261, 1230951927, 1463856790, 1740828910, 2070206126, 1232672636, 1465903069, 1743262359, 2073100001, 
+1234393945, 1467950062, 1745696658, 2075994886, 1236115854, 1469997769, 1748131806, 2078890781, 1237838364, 1472046189, 1750567802, 2081787685, 1239561472, 1474095322, 1753004646, 2084685597, 
+1241285180, 1476145168, 1755442337, 2087584517, 1243009487, 1478195726, 1757880874, 2090484443, 1244734391, 1480246994, 1760320258, 2093385375, 1246459894, 1482298974, 1762760487, 2096287313, 
+1248185993, 1484351664, 1765201560, 2099190255, 1249912690, 1486405064, 1767643478, 2102094201, 1251639983, 1488459174, 1770086240, 2104999151, 1253367873, 1490513992, 1772529844, 2107905103, 
+1255096358, 1492569519, 1774974292, 2110812057, 1256825438, 1494625754, 1777419581, 2113720012, 1258555114, 1496682696, 1779865711, 2116628967, 1260285384, 1498740345, 1782312682, 2119538923, 
+1262016248, 1500798701, 1784760493, 2122449877, 1263747705, 1502857763, 1787209144, 2125361830, 1265479756, 1504917530, 1789658634, 2128274781, 1267212400, 1506978002, 1792108962, 2131188729, 
+1268945636, 1509039179, 1794560128, 2134103673, 1270679464, 1511101060, 1797012132, 2137019613, 1272413884, 1513163644, 1799464972, 2139936548, 1274148895, 1515226932, 1801918648, 2142854477, 
+1275884497, 1517290922, 1804373160, 2145773400, 1277620690, 1519355614, 1806828507, 1074346658, 1279357472, 1521421009, 1809284688, 1075807112, 1281094844, 1523487104, 1811741703, 1077268062, 
+1282832806, 1525553900, 1814199552, 1078729508, 1284571356, 1527621396, 1816658233, 1080191448, 1286310494, 1529689592, 1819117747, 1081653884, 1288050221, 1531758487, 1821578092, 1083116814, 
+1289790535, 1533828082, 1824039268, 1084580238, 1291531437, 1535898374, 1826501274, 1086044156, 1293272925, 1537969365, 1828964111, 1087508567, 1295015000, 1540041052, 1831427777, 1088973471, 
+1296757661, 1542113437, 1833892272, 1090438869, 1298500908, 1544186518, 1836357595, 1091904759, 1300244740, 1546260296, 1838823745, 1093371141, 1301989157, 1548334769, 1841290723, 1094838014, 
+1303734158, 1550409937, 1843758528, 1096305380, 1305479743, 1552485799, 1846227158, 1097773236, 1307225912, 1554562356, 1848696614, 1099241584, 1308972665, 1556639606, 1851166895, 1100710421, 
+1310720000, 1558717550, 1853638000, 1102179749, 1312467918, 1560796186, 1856109930, 1103649567, 1314216418, 1562875515, 1858582682, 1105119875, 1315965500, 1564955535, 1861056257, 1106590671, 
+1317715163, 1567036247, 1863530655, 1108061957, 1319465407, 1569117650, 1866005874, 1109533731, 1321216232, 1571199743, 1868481914, 1111005993, 1322967637, 1573282527, 1870958775, 1112478743, 
+1324719622, 1575365999, 1873436455, 1113951981, 1326472186, 1577450161, 1875914955, 1115425706, 1328225329, 1579535012, 1878394275, 1116899918, 1329979051, 1581620551, 1880874412, 1118374617, 
+1331733352, 1583706777, 1883355368, 1119849802, 1333488230, 1585793691, 1885837140, 1121325472, 1335243686, 1587881292, 1888319730, 1122801629, 1336999719, 1589969578, 1890803135, 1124278271, 
+1338756329, 1592058551, 1893287357, 1125755398, 1340513515, 1594148210, 1895772393, 1127233009, 1342271277, 1596238553, 1898258245, 1128711105, 1344029615, 1598329581, 1900744910, 1130189685, 
+1345788528, 1600421293, 1903232389, 1131668749, 1347548016, 1602513689, 1905720681, 1133148296, 1349308079, 1604606768, 1908209785, 1134628327, 1351068716, 1606700530, 1910699701, 1136108840, 
+1352829926, 1608794974, 1913190429, 1137589835, 1354591710, 1610890100, 1915681968, 1139071313, 1356354067, 1612985907, 1918174317, 1140553273, 1358116997, 1615082396, 1920667476, 1142035714, 
+1359880499, 1617179565, 1923161444, 1143518637, 1361644572, 1619277414, 1925656222, 1145002040, 1363409218, 1621375943, 1928151807, 1146485924, 1365174434, 1623475151, 1930648200, 1147970288, 
+1366940222, 1625575038, 1933145401, 1149455132, 1368706580, 1627675603, 1935643408, 1150940456, 1370473507, 1629776846, 1938142221, 1152426260, 1372241005, 1631878767, 1940641840, 1153912542, 
+1374009072, 1633981364, 1943142264, 1155399303, 1375777708, 1636084639, 1945643493, 1156886543, 1377546912, 1638188589, 1948145526, 1158374260, 1379316685, 1640293216, 1950648363, 1159862456, 
+1381087026, 1642398517, 1953152002, 1161351129, 1382857934, 1644504494, 1955656445, 1162840279, 1384629409, 1646611145, 1958161689, 1164329906, 1386401451, 1648718470, 1960667735, 1165820010, 
+1388174059, 1650826468, 1963174582, 1167310590, 1389947234, 1652935140, 1965682229, 1168801646, 1391720974, 1655044484, 1968190676, 1170293178, 1393495279, 1657154501, 1970699923, 1171785185, 
+1395270150, 1659265190, 1973209969, 1173277667, 1397045585, 1661376550, 1975720814, 1174770624, 1398821584, 1663488581, 1978232456, 1176264056, 1400598148, 1665601283, 1980744896, 1177757962, 
+1402375275, 1667714654, 1983258133, 1179252341, 1404152965, 1669828696, 1985772166, 1180747194, 1405931217, 1671943407, 1988286995, 1182242521, 1407710033, 1674058787, 1990802620, 1183738320, 
+1409489410, 1676174835, 1993319040, 1185234592, 1411269349, 1678291551, 1995836254, 1186731337, 1413049850, 1680408935, 1998354262, 1188228553, 1414830911, 1682526986, 2000873063, 1189726242, 
+1416612534, 1684645704, 2003392658, 1191224401, 1418394716, 1686765089, 2005913045, 1192723032, 1420177459, 1688885139, 2008434224, 1194222134, 1421960761, 1691005855, 2010956194, 1195721707, 
+1423744623, 1693127236, 2013478955, 1197221750, 1425529044, 1695249281, 2016002507, 1198722263, 1427314023, 1697371991, 2018526849, 1200223245, 1429099560, 1699495365, 2021051980, 1201724697, 
+1430885655, 1701619402, 2023577900, 1203226618, 1432672308, 1703744102, 2026104609, 1204729008, 1434459518, 1705869465, 2028632105, 1206231867, 1436247285, 1707995490, 2031160389, 1207735193, 
+1438035608, 1710122177, 2033689461, 1209238988, 1439824488, 1712249525, 2036219318, 1210743250, 1441613923, 1714377535, 2038749962, 1212247980, 1443403914, 1716506204, 2041281391, 1213753177, 
+1445194460, 1718635534, 2043813606, 1215258841, 1446985561, 1720765524, 2046346604, 1216764971, 1448777216, 1722896173, 2048880387, 1218271567, 1450569425, 1725027481, 2051414954, 1219778630, 
+1452362188, 1727159448, 2053950304, 1221286158, 1454155504, 1729292072, 2056486436, 1222794151, 1455949374, 1731425354, 2059023351, 1224302609, 1457743796, 1733559294, 2061561047, 1225811532, 
+1459538771, 1735693891, 2064099524, 1227320920, 1461334297, 1737829144, 2066638782, 1228830772, 1463130375, 1739965053, 2069178821, 1230341088, 1464927005, 1742101618, 2071719639, 1231851867, 
+1466724186, 1744238838, 2074261236, 1233363110, 1468521917, 1746376713, 2076803612, 1234874816, 1470320199, 1748515242, 2079346766, 1236386985, 1472119031, 1750654426, 2081890699, 1237899616, 
+1473918412, 1752794263, 2084435408, 1239412709, 1475718343, 1754934753, 2086980895, 1240926265, 1477518823, 1757075897, 2089527158, 1242440282, 1479319851, 1759217693, 2092074197, 1243954760, 
+1481121428, 1761360141, 2094622011, 1245469699, 1482923553, 1763503240, 2097170601, 1246985100, 1484726226, 1765646991, 2099719965, 1248500961, 1486529445, 1767791393, 2102270102, 1250017282, 
+1488333212, 1769936445, 2104821014, 1251534063, 1490137526, 1772082148, 2107372699, 1253051304, 1491942386, 1774228500, 2109925156, 1254569004, 1493747792, 1776375502, 2112478386, 1256087163, 
+1495553743, 1778523152, 2115032387, 1257605781, 1497360240, 1780671451, 2117587159, 1259124858, 1499167282, 1782820398, 2120142703, 1260644393, 1500974869, 1784969993, 2122699016, 1262164387, 
+1502783000, 1787120236, 2125256100, 1263684837, 1504591675, 1789271125, 2127813952, 1265205746, 1506400894, 1791422661, 2130372574, 1266727111, 1508210656, 1793574843, 2132931965, 1268248934, 
+1510020961, 1795727671, 2135492123, 1269771213, 1511831809, 1797881144, 2138053049, 1271293949, 1513643200, 1800035263, 2140614742, 1272817141, 1515455132, 1802190026, 2143177201, 1274340788, 
+1517267606, 1804345433, 2145740427, 1275864891, 1519080622, 1806501484, 1074152209, 1277389450, 1520894179, 1808658179, 1075434587, 1278914463, 1522708277, 1810815517, 1076717348, 1280439931, 
+1524522915, 1812973497, 1078000491, 1281965854, 1526338093, 1815132120, 1079284016, 1283492231, 1528153811, 1817291385, 1080567922, 1285019062, 1529970069, 1819451291, 1081852211, 1286546346, 
+1531786865, 1821611839, 1083136880, 1288074084, 1533604201, 1823773027, 1084421930, 1289602275, 1535422075, 1825934856, 1085707361, 1291130919, 1537240488, 1828097325, 1086993173, 1292660015, 
+1539059438, 1830260434, 1088279365, 1294189564, 1540878926, 1832424182, 1089565938, 1295719565, 1542698951, 1834588569, 1090852890, 1297250018, 1544519513, 1836753595, 1092140222, 1298780922, 
+1546340612, 1838919258, 1093427933, 1300312278, 1548162247, 1841085560, 1094716023, 1301844084, 1549984418, 1843252499, 1096004493, 1303376341, 1551807125, 1845420075, 1097293341, 1304909049, 
+1553630368, 1847588287, 1098582568, 1306442207, 1555454145, 1849757136, 1099872174, 1307975815, 1557278457, 1851926621, 1101162157, 1309509872, 1559103303, 1854096741, 1102452518, 1311044379, 
+1560928684, 1856267497, 1103743257, 1312579335, 1562754598, 1858438888, 1105034374, 1314114740, 1564581046, 1860610912, 1106325868, 1315650593, 1566408028, 1862783571, 1107617738, 1317186895, 
+1568235542, 1864956864, 1108909986, 1318723645, 1570063588, 1867130790, 1110202610, 1320260843, 1571892167, 1869305349, 1111495611, 1321798488, 1573721278, 1871480541, 1112788987, 1323336581, 
+1575550920, 1873656364, 1114082740, 1324875121, 1577381094, 1875832820, 1115376868, 1326414107, 1579211799, 1878009907, 1116671372, 1327953541, 1581043034, 1880187626, 1117966251, 1329493420, 
+1582874800, 1882365975, 1119261505, 1331033745, 1584707096, 1884544954, 1120557134, 1332574516, 1586539922, 1886724564, 1121853138, 1334115733, 1588373277, 1888904803, 1123149515, 1335657395, 
+1590207162, 1891085671, 1124446268, 1337199502, 1592041575, 1893267169, 1125743394, 1338742054, 1593876517, 1895449295, 1127040894, 1340285050, 1595711987, 1897632049, 1128338767, 1341828490, 
+1597547986, 1899815431, 1129637014, 1343372374, 1599384511, 1901999441, 1130935634, 1344916702, 1601221565, 1904184077, 1132234626, 1346461474, 1603059145, 1906369341, 1133533992, 1348006688, 
+1604897252, 1908555231, 1134833730, 1349552346, 1606735885, 1910741747, 1136133840, 1351098446, 1608575045, 1912928888, 1137434322, 1352644989, 1610414730, 1915116655, 1138735176, 1354191974, 
+1612254941, 1917305047, 1140036402, 1355739401, 1614095678, 1919494064, 1141337999, 1357287269, 1615936939, 1921683705, 1142639967, 1358835579, 1617778725, 1923873970, 1143942307, 1360384330, 
+1619621035, 1926064858, 1145245017, 1361933522, 1621463869, 1928256370, 1146548097, 1363483155, 1623307227, 1930448504, 1147851548, 1365033228, 1625151109, 1932641261, 1149155369, 1366583741, 
+1626995513, 1934834640, 1150459560, 1368134695, 1628840441, 1937028641, 1151764121, 1369686088, 1630685891, 1939223264, 1153069051, 1371237920, 1632531863, 1941418507, 1154374351, 1372790191, 
+1634378357, 1943614371, 1155680020, 1374342902, 1636225373, 1945810856, 1156986057, 1375896051, 1638072911, 1948007960, 1158292463, 1377449639, 1639920969, 1950205685, 1159599238, 1379003664, 
+1641769549, 1952404028, 1160906381, 1380558128, 1643618648, 1954602991, 1162213892, 1382113029, 1645468268, 1956802572, 1163521771, 1383668368, 1647318408, 1959002772, 1164830017, 1385224144, 
+1649169068, 1961203589, 1166138631, 1386780357, 1651020247, 1963405024, 1167447612, 1388337007, 1652871945, 1965607077, 1168756960, 1389894093, 1654724161, 1967809746, 1170066675, 1391451615, 
+1656576896, 1970013032, 1171376757, 1393009574, 1658430150, 1972216934, 1172687205, 1394567968, 1660283921, 1974421452, 1173998019, 1396126797, 1662138210, 1976626585, 1175309199, 1397686062, 
+1663993016, 1978832334, 1176620745, 1399245762, 1665848339, 1981038697, 1177932657, 1400805897, 1667704179, 1983245675, 1179244934, 1402366466, 1669560535, 1985453267, 1180557576, 1403927469, 
+1671417408, 1987661473, 1181870583, 1405488907, 1673274796, 1989870293, 1183183955, 1407050778, 1675132700, 1992079725, 1184497692, 1408613083, 1676991119, 1994289771, 1185811792, 1410175821, 
+1678850053, 1996500429, 1187126257, 1411738992, 1680709502, 1998711699, 1188441086, 1413302596, 1682569466, 2000923580, 1189756279, 1414866632, 1684429943, 2003136073, 1191071835, 1416431101, 
+1686290935, 2005349178, 1192387755, 1417996002, 1688152440, 2007562893, 1193704038, 1419561335, 1690014458, 2009777218, 1195020684, 1421127100, 1691876990, 2011992154, 1196337692, 1422693296, 
+1693740034, 2014207699, 1197655063, 1424259923, 1695603590, 2016423854, 1198972797, 1425826981, 1697467659, 2018640617, 1200290892, 1427394469, 1699332240, 2020857990, 1201609350, 1428962389, 
+1701197332, 2023075971, 1202928169, 1430530738, 1703062935, 2025294560, 1204247350, 1432099517, 1704929050, 2027513757, 1205566893, 1433668726, 1706795675, 2029733561, 1206886796, 1435238365, 
+1708662811, 2031953972, 1208207061, 1436808433, 1710530457, 2034174990, 1209527686, 1438378930, 1712398613, 2036396615, 1210848672, 1439949855, 1714267279, 2038618845, 1212170018, 1441521210, 
+1716136454, 2040841682, 1213491724, 1443092992, 1718006138, 2043065123, 1214813791, 1444665203, 1719876331, 2045289170, 1216136217, 1446237842, 1721747033, 2047513822, 1217459003, 1447810908, 
+1723618243, 2049739078, 1218782148, 1449384402, 1725489961, 2051964938, 1220105652, 1450958322, 1727362186, 2054191402, 1221429515, 1452532670, 1729234919, 2056418469, 1222753738, 1454107445, 
+1731108159, 2058646140, 1224078319, 1455682646, 1732981907, 2060874413, 1225403258, 1457258273, 1734856160, 2063103289, 1226728555, 1458834326, 1736730920, 2065332767, 1228054211, 1460410805, 
+1738606186, 2067562847, 1229380224, 1461987710, 1740481958, 2069793528, 1230706595, 1463565040, 1742358236, 2072024811, 1232033324, 1465142795, 1744235019, 2074256694, 1233360410, 1466720974, 
+1746112306, 2076489178, 1234687852, 1468299579, 1747990099, 2078722262, 1236015652, 1469878608, 1749868396, 2080955946, 1237343809, 1471458061, 1751747197, 2083190230, 1238672322, 1473037938, 
+1753626502, 2085425113, 1240001191, 1474618239, 1755506310, 2087660594, 1241330416, 1476198963, 1757386622, 2089896675, 1242659998, 1477780111, 1759267437, 2092133353, 1243989935, 1479361681, 
+1761148755, 2094370630, 1245320227, 1480943675, 1763030575, 2096608504, 1246650875, 1482526091, 1764912898, 2098846976, 1247981878, 1484108929, 1766795723, 2101086044, 1249313237, 1485692190, 
+1768679049, 2103325710, 1250644949, 1487275872, 1770562877, 2105565971, 1251977017, 1488859976, 1772447206, 2107806829, 1253309439, 1490444502, 1774332037, 2110048282, 1254642215, 1492029449, 
+1776217367, 2112290331, 1255975345, 1493614817, 1778103199, 2114532975, 1257308829, 1495200606, 1779989530, 2116776214, 1258642667, 1496786815, 1781876361, 2119020047, 1259976858, 1498373445, 
+1783763692, 2121264474, 1261311403, 1499960494, 1785651522, 2123509495, 1262646300, 1501547964, 1787539852, 2125755110, 1263981551, 1503135853, 1789428680, 2128001318, 1265317154, 1504724162, 
+1791318007, 2130248119, 1266653110, 1506312890, 1793207832, 2132495512, 1267989418, 1507902038, 1795098155, 2134743498, 1269326078, 1509491603, 1796988976, 2136992076, 1270663091, 1511081588, 
+1798880294, 2139241245, 1272000455, 1512671991, 1800772110, 2141491006, 1273338170, 1514262812, 1802664423, 2143741357, 1274676237, 1515854051, 1804557232, 2145992300, 1276014656, 1517445707, 
+1806450538, 1074121916, 1277353425, 1519037782, 1808344340, 1075247978, 1278692545, 1520630273, 1810238638, 1076374334, 1280032016, 1522223181, 1812133432, 1077500985, 1281371838, 1523816507, 
+1814028721, 1078627931, 1282712010, 1525410249, 1815924505, 1079755171, 1284052532, 1527004407, 1817820784, 1080882705, 1285393404, 1528598981, 1819717558, 1082010534, 1286734625, 1530193972, 
+1821614827, 1083138656, 1288076197, 1531789378, 1823512589, 1084267073, 1289418117, 1533385199, 1825410846, 1085395783, 1290760387, 1534981436, 1827309596, 1086524786, 1292103006, 1536578088, 
+1829208839, 1087654083, 1293445974, 1538175155, 1831108575, 1088783673, 1294789291, 1539772637, 1833008805, 1089913556, 1296132956, 1541370533, 1834909527, 1091043732, 1297476969, 1542968843, 
+1836810741, 1092174201, 1298821331, 1544567568, 1838712447, 1093304962, 1300166040, 1546166706, 1840614646, 1094436016, 1301511097, 1547766257, 1842517335, 1095567362, 1302856502, 1549366222, 
+1844420517, 1096699001, 1304202255, 1550966601, 1846324189, 1097830931, 1305548354, 1552567392, 1848228352, 1098963153, 1306894801, 1554168596, 1850133006, 1100095667, 1308241594, 1555770212, 
+1852038150, 1101228472, 1309588735, 1557372241, 1853943784, 1102361569, 1310936221, 1558974682, 1855849907, 1103494957, 1312284054, 1560577534, 1857756521, 1104628636, 1313632234, 1562180799, 
+1859663624, 1105762606, 1314980759, 1563784475, 1861571215, 1106896867, 1316329630, 1565388562, 1863479296, 1108031419, 1317678847, 1566993060, 1865387865, 1109166261, 1319028409, 1568597969, 
+1867296923, 1110301393, 1320378316, 1570203288, 1869206468, 1111436816, 1321728569, 1571809018, 1871116502, 1112572528, 1323079167, 1573415159, 1873027022, 1113708531, 1324430109, 1575021709, 
+1874938031, 1114844823, 1325781396, 1576628669, 1876849526, 1115981405, 1327133027, 1578236038, 1878761508, 1117118276, 1328485003, 1579843817, 1880673977, 1118255437, 1329837322, 1581452005, 
+1882586932, 1119392887, 1331189986, 1583060602, 1884500373, 1120530626, 1332542993, 1584669608, 1886414300, 1121668654, 1333896344, 1586279022, 1888328712, 1122806970, 1335250038, 1587888845, 
+1890243610, 1123945575, 1336604075, 1589499076, 1892158993, 1125084469, 1337958455, 1591109714, 1894074861, 1126223651, 1339313178, 1592720761, 1895991213, 1127363120, 1340668244, 1594332215, 
+1897908050, 1128502878, 1342023652, 1595944076, 1899825371, 1129642924, 1343379403, 1597556344, 1901743176, 1130783258, 1344735496, 1599169019, 1903661464, 1131923879, 1346091930, 1600782101, 
+1905580236, 1133064787, 1347448707, 1602395589, 1907499491, 1134205983, 1348805825, 1604009484, 1909419228, 1135347466, 1350163285, 1605623784, 1911339449, 1136489236, 1351521085, 1607238491, 
+1913260152, 1137631293, 1352879227, 1608853603, 1915181337, 1138773636, 1354237710, 1610469120, 1917103003, 1139916266, 1355596534, 1612085043, 1919025152, 1141059182, 1356955698, 1613701371, 
+1920947782, 1142202385, 1358315203, 1615318104, 1922870893, 1143345874, 1359675048, 1616935241, 1924794485, 1144489648, 1361035233, 1618552783, 1926718558, 1145633709, 1362395758, 1620170729, 
+1928643112, 1146778055, 1363756623, 1621789079, 1930568145, 1147922687, 1365117827, 1623407833, 1932493659, 1149067604, 1366479371, 1625026990, 1934419652, 1150212807, 1367841254, 1626646551, 
+1936346125, 1151358295, 1369203476, 1628266515, 1938273077, 1152504067, 1370566037, 1629886882, 1940200508, 1153650125, 1371928936, 1631507652, 1942128418, 1154796467, 1373292175, 1633128825, 
+1944056807, 1155943093, 1374655751, 1634750400, 1945985674, 1157090005, 1376019666, 1636372377, 1947915019, 1158237200, 1377383919, 1637994757, 1949844842, 1159384680, 1378748510, 1639617538, 
+1951775142, 1160532443, 1380113438, 1641240721, 1953705920, 1161680490, 1381478705, 1642864305, 1955637175, 1162828822, 1382844308, 1644488290, 1957568907, 1163977436, 1384210249, 1646112677, 
+1959501116, 1165126334, 1385576527, 1647737464, 1961433801, 1166275516, 1386943141, 1649362652, 1963366962, 1167424980, 1388310093, 1650988240, 1965300599, 1168574728, 1389677381, 1652614229, 
+1967234712, 1169724758, 1391045005, 1654240617, 1969169301, 1170875071, 1392412966, 1655867406, 1971104364, 1172025667, 1393781262, 1657494594, 1973039903, 1173176546, 1395149895, 1659122182, 
+1974975917, 1174327706, 1396518863, 1660750169, 1976912405, 1175479149, 1397888167, 1662378555, 1978849367, 1176630874, 1399257807, 1664007339, 1980786804, 1177782880, 1400627781, 1665636523, 
+1982724714, 1178935169, 1401998091, 1667266105, 1984663099, 1180087739, 1403368735, 1668896085, 1986601956, 1181240590, 1404739715, 1670526463, 1988541287, 1182393723, 1406111029, 1672157240, 
+1990481090, 1183547137, 1407482677, 1673788414, 1992421367, 1184700833, 1408854659, 1675419985, 1994362116, 1185854809, 1410226976, 1677051954, 1996303337, 1187009066, 1411599627, 1678684320, 
+1998245030, 1188163604, 1412972611, 1680317082, 2000187195, 1189318422, 1414345929, 1681950242, 2002129831, 1190473520, 1415719581, 1683583798, 2004072939, 1191628899, 1417093565, 1685217750, 
+2006016518, 1192784558, 1418467883, 1686852099, 2007960568, 1193940497, 1419842534, 1688486844, 2009905089, 1195096716, 1421217518, 1690121984, 2011850080, 1196253214, 1422592834, 1691757520, 
+2013795541, 1197409993, 1423968483, 1693393451, 2015741472, 1198567050, 1425344464, 1695029778, 2017687873, 1199724387, 1426720777, 1696666499, 2019634743, 1200882003, 1428097422, 1698303616, 
+2021582083, 1202039898, 1429474399, 1699941127, 2023529891, 1203198072, 1430851708, 1701579032, 2025478169, 1204356525, 1432229349, 1703217332, 2027426915, 1205515256, 1433607320, 1704856025, 
+2029376130, 1206674266, 1434985623, 1706495113, 2031325813, 1207833555, 1436364257, 1708134594, 2033275963, 1208993121, 1437743222, 1709774469, 2035226582, 1210152966, 1439122517, 1711414737, 
+2037177668, 1211313089, 1440502143, 1713055398, 2039129221, 1212473489, 1441882100, 1714696452, 2041081241, 1213634167, 1443262387, 1716337899, 2043033728, 1214795123, 1444643003, 1717979738, 
+2044986682, 1215956356, 1446023950, 1719621970, 2046940102, 1217117867, 1447405227, 1721264594, 2048893988, 1218279654, 1448786833, 1722907610, 2050848340, 1219441719, 1450168769, 1724551018, 
+2052803158, 1220604061, 1451551034, 1726194817, 2054758442, 1221766679, 1452933628, 1727839008, 2056714190, 1222929574, 1454316551, 1729483590, 2058670404, 1224092746, 1455699803, 1731128563, 
+2060627082, 1225256194, 1457083383, 1732773927, 2062584225, 1226419918, 1458467293, 1734419681, 2064541833, 1227583918, 1459851530, 1736065826, 2066499904, 1228748195, 1461236096, 1737712362, 
+2068458440, 1229912747, 1462620990, 1739359287, 2070417439, 1231077575, 1464006211, 1741006603, 2072376902, 1232242678, 1465391761, 1742654308, 2074336828, 1233408057, 1466777638, 1744302403, 
+2076297217, 1234573712, 1468163842, 1745950887, 2078258069, 1235739641, 1469550374, 1747599760, 2080219384, 1236905846, 1470937233, 1749249023, 2082181161, 1238072326, 1472324419, 1750898674, 
+2084143400, 1239239080, 1473711931, 1752548714, 2086106101, 1240406109, 1475099771, 1754199142, 2088069264, 1241573413, 1476487936, 1755849959, 2090032889, 1242740991, 1477876429, 1757501164, 
+2091996975, 1243908843, 1479265247, 1759152757, 2093961522, 1245076970, 1480654391, 1760804737, 2095926529, 1246245371, 1482043862, 1762457105, 2097891998, 1247414045, 1483433658, 1764109861, 
+2099857927, 1248582994, 1484823780, 1765763003, 2101824316, 1249752216, 1486214227, 1767416533, 2103791165, 1250921711, 1487604999, 1769070449, 2105758474, 1252091480, 1488996097, 1770724752, 
+2107726243, 1253261522, 1490387519, 1772379442, 2109694471, 1254431838, 1491779267, 1774034518, 2111663158, 1255602426, 1493171339, 1775689980, 2113632304, 1256773287, 1494563735, 1777345828, 
+2115601909, 1257944421, 1495956456, 1779002061, 2117571973, 1259115828, 1497349501, 1780658681, 2119542494, 1260287507, 1498742871, 1782315685, 2121513474, 1261459459, 1500136564, 1783973075, 
+2123484912, 1262631683, 1501530581, 1785630850, 2125456807, 1263804179, 1502924921, 1787289010, 2127429160, 1264976947, 1504319586, 1788947554, 2129401970, 1266149987, 1505714573, 1790606483, 
+2131375237, 1267323298, 1507109884, 1792265797, 2133348961, 1268496882, 1508505517, 1793925494, 2135323142, 1269670737, 1509901474, 1795585575, 2137297779, 1270844863, 1511297753, 1797246041, 
+2139272872, 1272019260, 1512694355, 1798906889, 2141248421, 1273193929, 1514091279, 1800568122, 2143224426, 1274368868, 1515488525, 1802229737, 2145200887, 1275544079, 1516886094, 1803891736, 
+2147177802, 1276719560, 1518283985, 1805554117, 1074577587, 1277895312, 1519682197, 1807216881, 1075566500, 1279071334, 1521080731, 1808880028, 1076555640, 1280247627, 1522479587, 1810543557, 
+1077545008, 1281424190, 1523878764, 1812207468, 1078534602, 1282601023, 1525278262, 1813871762, 1079524424, 1283778126, 1526678082, 1815536437, 1080514473, 1284955499, 1528078222, 1817201494, 
+1081504748, 1286133142, 1529478683, 1818866932, 1082495251, 1287311054, 1530879465, 1820532752, 1083485980, 1288489236, 1532280567, 1822198953, 1084476935, 1289667687, 1533681990, 1823865534, 
+1085468117, 1290846408, 1535083733, 1825532497, 1086459525, 1292025398, 1536485796, 1827199840, 1087451160, 1293204656, 1537888179, 1828867564, 1088443020, 1294384184, 1539290881, 1830535668, 
+1089435107, 1295563980, 1540693904, 1832204152, 1090427419, 1296744046, 1542097245, 1833873016, 1091419958, 1297924379, 1543500906, 1835542260, 1092412722, 1299104981, 1544904887, 1837211883, 
+1093405711, 1300285851, 1546309186, 1838881886, 1094398926, 1301466990, 1547713804, 1840552268, 1095392367, 1302648396, 1549118741, 1842223029, 1096386033, 1303830071, 1550523997, 1843894169, 
+1097379924, 1305012013, 1551929571, 1845565688, 1098374040, 1306194223, 1553335464, 1847237585, 1099368381, 1307376701, 1554741674, 1848909861, 1100362947, 1308559445, 1556148203, 1850582515, 
+1101357738, 1309742458, 1557555050, 1852255547, 1102352753, 1310925737, 1558962214, 1853928957, 1103347993, 1312109284, 1560369696, 1855602744, 1104343458, 1313293097, 1561777495, 1857276909, 
+1105339146, 1314477177, 1563185612, 1858951452, 1106335060, 1315661524, 1564594046, 1860626371, 1107331197, 1316846138, 1566002797, 1862301668, 1108327558, 1318031018, 1567411864, 1863977341, 
+1109324144, 1319216165, 1568821249, 1865653392, 1110320953, 1320401577, 1570230950, 1867329818, 1111317986, 1321587256, 1571640968, 1869006621, 1112315243, 1322773201, 1573051302, 1870683800, 
+1113312723, 1323959411, 1574461952, 1872361356, 1114310427, 1325145888, 1575872918, 1874039287, 1115308354, 1326332630, 1577284200, 1875717593, 1116306504, 1327519637, 1578695798, 1877396276, 
+1117304878, 1328706910, 1580107712, 1879075333, 1118303475, 1329894449, 1581519941, 1880754766, 1119302294, 1331082252, 1582932485, 1882434574, 1120301337, 1332270321, 1584345344, 1884114756, 
+1121300602, 1333458654, 1585758519, 1885795313, 1122300090, 1334647252, 1587172008, 1887476245, 1123299801, 1335836115, 1588585813, 1889157551, 1124299734, 1337025243, 1589999931, 1890839231, 
+1125299889, 1338214635, 1591414365, 1892521285, 1126300267, 1339404291, 1592829112, 1894203714, 1127300867, 1340594211, 1594244174, 1895886515, 1128301689, 1341784396, 1595659550, 1897569690, 
+1129302732, 1342974844, 1597075240, 1899253239, 1130303998, 1344165557, 1598491244, 1900937161, 1131305486, 1345356533, 1599907561, 1902621455, 1132307195, 1346547773, 1601324192, 1904306123, 
+1133309126, 1347739276, 1602741137, 1905991163, 1134311279, 1348931043, 1604158394, 1907676576, 1135313652, 1350123073, 1605575965, 1909362361, 1136316247, 1351315366, 1606993848, 1911048518, 
+1137319064, 1352507923, 1608412045, 1912735047, 1138322101, 1353700742, 1609830554, 1914421948, 1139325360, 1354893824, 1611249375, 1916109221, 1140328839, 1356087169, 1612668509, 1917796866, 
+1141332539, 1357280776, 1614087956, 1919484881, 1142336460, 1358474646, 1615507714, 1921173268, 1143340601, 1359668778, 1616927785, 1922862026, 1144344963, 1360863172, 1618348167, 1924551155, 
+1145349546, 1362057829, 1619768861, 1926240654, 1146354348, 1363252747, 1621189867, 1927930524, 1147359371, 1364447928, 1622611184, 1929620765, 1148364614, 1365643370, 1624032812, 1931311375, 
+1149370078, 1366839074, 1625454752, 1933002356, 1150375761, 1368035039, 1626877003, 1934693707, 1151381664, 1369231266, 1628299564, 1936385427, 1152387786, 1370427755, 1629722436, 1938077517, 
+1153394129, 1371624504, 1631145619, 1939769976, 1154400690, 1372821515, 1632569113, 1941462805, 1155407472, 1374018786, 1633992917, 1943156002, 1156414473, 1375216319, 1635417031, 1944849569, 
+1157421692, 1376414112, 1636841455, 1946543504, 1158429132, 1377612166, 1638266189, 1948237808, 1159436790, 1378810480, 1639691233, 1949932481, 1160444667, 1380009055, 1641116587, 1951627521, 
+1161452763, 1381207890, 1642542250, 1953322930, 1162461078, 1382406985, 1643968222, 1955018707, 1163469612, 1383606340, 1645394504, 1956714852, 1164478364, 1384805956, 1646821095, 1958411364, 
+1165487335, 1386005831, 1648247995, 1960108243, 1166496524, 1387205966, 1649675204, 1961805491, 1167505931, 1388406360, 1651102722, 1963503105, 1168515557, 1389607014, 1652530548, 1965201086, 
+1169525401, 1390807928, 1653958683, 1966899434, 1170535463, 1392009100, 1655387126, 1968598149, 1171545742, 1393210532, 1656815878, 1970297230, 1172556240, 1394412223, 1658244937, 1971996678, 
+1173566955, 1395614173, 1659674305, 1973696492, 1174577889, 1396816382, 1661103980, 1975396672, 1175589039, 1398018850, 1662533963, 1977097218, 1176600407, 1399221576, 1663964253, 1978798129, 
+1177611993, 1400424560, 1665394851, 1980499407, 1178623796, 1401627804, 1666825757, 1982201049, 1179635816, 1402831305, 1668256969, 1983903057, 1180648053, 1404035064, 1669688488, 1985605430, 
+1181660507, 1405239082, 1671120315, 1987308168, 1182673178, 1406443358, 1672552448, 1989011271, 1183686065, 1407647891, 1673984887, 1990714739, 1184699170, 1408852682, 1675417634, 1992418571, 
+1185712491, 1410057731, 1676850686, 1994122767, 1186726029, 1411263037, 1678284045, 1995827327, 1187739783, 1412468601, 1679717710, 1997532252, 1188753754, 1413674422, 1681151681, 1999237540, 
+1189767941, 1414880500, 1682585958, 2000943192, 1190782344, 1416086835, 1684020540, 2002649208, 1191796963, 1417293428, 1685455428, 2004355587, 1192811798, 1418500277, 1686890622, 2006062329, 
+1193826849, 1419707382, 1688326120, 2007769435, 1194842115, 1420914745, 1689761925, 2009476903, 1195857598, 1422122364, 1691198034, 2011184734, 1196873296, 1423330239, 1692634448, 2012892928, 
+1197889210, 1424538371, 1694071167, 2014601485, 1198905339, 1425746759, 1695508190, 2016310403, 1199921683, 1426955403, 1696945518, 2018019684, 1200938243, 1428164303, 1698383151, 2019729327, 
+1201955018, 1429373459, 1699821087, 2021439331, 1202972008, 1430582871, 1701259328, 2023149698, 1203989213, 1431792538, 1702697873, 2024860426, 1205006632, 1433002461, 1704136722, 2026571515, 
+1206024267, 1434212639, 1705575875, 2028282966, 1207042116, 1435423073, 1707015331, 2029994777, 1208060180, 1436633762, 1708455091, 2031706950, 1209078459, 1437844706, 1709895154, 2033419484, 
+1210096952, 1439055905, 1711335521, 2035132378, 1211115659, 1440267359, 1712776191, 2036845632, 1212134581, 1441479068, 1714217163, 2038559247, 1213153716, 1442691031, 1715658439, 2040273222, 
+1214173066, 1443903249, 1717100017, 2041987558, 1215192630, 1445115722, 1718541898, 2043702253, 1216212408, 1446328449, 1719984082, 2045417308, 1217232399, 1447541430, 1721426567, 2047132722, 
+1218252604, 1448754665, 1722869356, 2048848496, 1219273023, 1449968154, 1724312446, 2050564629, 1220293656, 1451181898, 1725755838, 2052281121, 1221314502, 1452395895, 1727199532, 2053997972, 
+1222335561, 1453610146, 1728643528, 2055715183, 1223356833, 1454824650, 1730087825, 2057432751, 1224378319, 1456039408, 1731532424, 2059150679, 1225400018, 1457254420, 1732977324, 2060868964, 
+1226421930, 1458469685, 1734422526, 2062587608, 1227444054, 1459685203, 1735868029, 2064306610, 1228466392, 1460900974, 1737313832, 2066025970, 1229488942, 1462116998, 1738759937, 2067745688, 
+1230511705, 1463333275, 1740206342, 2069465763, 1231534681, 1464549805, 1741653048, 2071186196, 1232557869, 1465766587, 1743100054, 2072906987, 1233581269, 1466983622, 1744547361, 2074628134, 
+1234604882, 1468200909, 1745994968, 2076349638, 1235628707, 1469418449, 1747442875, 2078071500, 1236652744, 1470636241, 1748891082, 2079793718, 1237676993, 1471854286, 1750339589, 2081516293, 
+1238701454, 1473072582, 1751788395, 2083239224, 1239726127, 1474291130, 1753237502, 2084962511, 1240751011, 1475509930, 1754686908, 2086686155, 1241776108, 1476728982, 1756136613, 2088410155, 
+1242801415, 1477948286, 1757586617, 2090134510, 1243826935, 1479167841, 1759036921, 2091859222, 1244852666, 1480387647, 1760487523, 2093584288, 1245878608, 1481607705, 1761938424, 2095309711, 
+1246904761, 1482828014, 1763389625, 2097035488, 1247931126, 1484048574, 1764841123, 2098761621, 1248957702, 1485269385, 1766292921, 2100488108, 1249984488, 1486490447, 1767745016, 2102214951, 
+1251011486, 1487711760, 1769197410, 2103942148, 1252038695, 1488933324, 1770650102, 2105669700, 1253066114, 1490155138, 1772103093, 2107397606, 1254093743, 1491377203, 1773556380, 2109125867, 
+1255121584, 1492599518, 1775009966, 2110854481, 1256149635, 1493822083, 1776463850, 2112583450, 1257177896, 1495044899, 1777918031, 2114312772, 1258206367, 1496267964, 1779372509, 2116042448, 
+1259235049, 1497491280, 1780827285, 2117772477, 1260263941, 1498714845, 1782282357, 2119502860, 1261293043, 1499938661, 1783737727, 2121233597, 1262322355, 1501162726, 1785193394, 2122964686, 
+1263351876, 1502387040, 1786649358, 2124696128, 1264381608, 1503611604, 1788105618, 2126427923, 1265411549, 1504836418, 1789562175, 2128160071, 1266441700, 1506061480, 1791019028, 2129892571, 
+1267472060, 1507286792, 1792476178, 2131625424, 1268502630, 1508512353, 1793933623, 2133358629, 1269533409, 1509738163, 1795391365, 2135092186, 1270564398, 1510964222, 1796849403, 2136826095, 
+1271595595, 1512190529, 1798307737, 2138560356, 1272627002, 1513417086, 1799766366, 2140294968, 1273658618, 1514643890, 1801225291, 2142029932, 1274690442, 1515870944, 1802684512, 2143765247, 
+1275722476, 1517098245, 1804144027, 2145500914, 1276754718, 1518325795, 1805603838, 2147236932, 1277787169, 1519553593, 1807063945, 1074486650, 1278819829, 1520781639, 1808524346, 1075355010, 
+1279852697, 1522009933, 1809985042, 1076223545, 1280885773, 1523238475, 1811446033, 1077092255, 1281919058, 1524467265, 1812907318, 1077961141, 1282952551, 1525696302, 1814368898, 1078830201, 
+1283986253, 1526925587, 1815830772, 1079699437, 1285020162, 1528155120, 1817292941, 1080568848, 1286054280, 1529384899, 1818755404, 1081438433, 1287088605, 1530614927, 1820218161, 1082308194, 
+1288123138, 1531845201, 1821681212, 1083178129, 1289157879, 1533075722, 1823144556, 1084048239, 1290192828, 1534306490, 1824608195, 1084918524, 1291227984, 1535537505, 1826072127, 1085788983, 
+1292263347, 1536768767, 1827536352, 1086659616, 1293298919, 1538000276, 1829000871, 1087530424, 1294334697, 1539232031, 1830465683, 1088401407, 1295370683, 1540464032, 1831930788, 1089272564, 
+1296406876, 1541696280, 1833396186, 1090143894, 1297443276, 1542928775, 1834861877, 1091015399, 1298479883, 1544161515, 1836327860, 1091887079, 1299516697, 1545394502, 1837794137, 1092758932, 
+1300553717, 1546627734, 1839260706, 1093630959, 1301590945, 1547861212, 1840727567, 1094503160, 1302628379, 1549094937, 1842194720, 1095375534, 1303666020, 1550328907, 1843662166, 1096248083, 
+1304703867, 1551563122, 1845129904, 1097120805, 1305741921, 1552797583, 1846597934, 1097993701, 1306780181, 1554032289, 1848066255, 1098866770, 1307818648, 1555267241, 1849534869, 1099740013, 
+1308857320, 1556502438, 1851003773, 1100613429, 1309896199, 1557737880, 1852472970, 1101487018, 1310935284, 1558973567, 1853942457, 1102360781, 1311974574, 1560209498, 1855412236, 1103234716, 
+1313014071, 1561445675, 1856882306, 1104108825, 1314053773, 1562682096, 1858352668, 1104983107, 1315093681, 1563918762, 1859823320, 1105857562, 1316133795, 1565155673, 1861294262, 1106732190, 
+1317174114, 1566392828, 1862765496, 1107606991, 1318214638, 1567630227, 1864237020, 1108481964, 1319255368, 1568867871, 1865708834, 1109357110, 1320296304, 1570105758, 1867180939, 1110232429, 
+1321337444, 1571343890, 1868653334, 1111107920, 1322378790, 1572582266, 1870126019, 1111983584, 1323420340, 1573820885, 1871598994, 1112859420, 1324462096, 1575059748, 1873072259, 1113735429, 
+1325504057, 1576298855, 1874545814, 1114611610, 1326546222, 1577538205, 1876019658, 1115487963, 1327588592, 1578777799, 1877493792, 1116364488, 1328631167, 1580017637, 1878968215, 1117241185, 
+1329673946, 1581257717, 1880442928, 1118118055, 1330716930, 1582498041, 1881917930, 1118995096, 1331760118, 1583738608, 1883393220, 1119872309, 1332803510, 1584979417, 1884868800, 1120749694, 
+1333847107, 1586220470, 1886344669, 1121627251, 1334890908, 1587461766, 1887820826, 1122504979, 1335934913, 1588703304, 1889297272, 1123382879, 1336979122, 1589945084, 1890774007, 1124260951, 
+1338023535, 1591187108, 1892251030, 1125139194, 1339068152, 1592429373, 1893728341, 1126017608, 1340112972, 1593671881, 1895205940, 1126896194, 1341157996, 1594914632, 1896683828, 1127774951, 
+1342203224, 1596157624, 1898162003, 1128653880, 1343248656, 1597400858, 1899640466, 1129532979, 1344294290, 1598644335, 1901119217, 1130412250, 1345340129, 1599888053, 1902598256, 1131291691, 
+1346386170, 1601132013, 1904077582, 1132171304, 1347432415, 1602376215, 1905557195, 1133051087, 1348478863, 1603620658, 1907037096, 1133931042, 1349525514, 1604865343, 1908517284, 1134811167, 
+1350572367, 1606110269, 1909997759, 1135691462, 1351619424, 1607355436, 1911478521, 1136571929, 1352666684, 1608600844, 1912959569, 1137452565, 1353714146, 1609846494, 1914440905, 1138333373, 
+1354761811, 1611092385, 1915922527, 1139214350, 1355809679, 1612338516, 1917404435, 1140095498, 1356857749, 1613584889, 1918886630, 1140976817, 1357906021, 1614831502, 1920369112, 1141858305, 
+1358954496, 1616078356, 1921851879, 1142739964, 1360003173, 1617325450, 1923334932, 1143621793, 1361052052, 1618572785, 1924818272, 1144503792, 1362101134, 1619820360, 1926301897, 1145385961, 
+1363150417, 1621068175, 1927785808, 1146268299, 1364199903, 1622316231, 1929270004, 1147150808, 1365249590, 1623564526, 1930754486, 1148033486, 1366299479, 1624813062, 1932239254, 1148916334, 
+1367349570, 1626061837, 1933724306, 1149799352, 1368399863, 1627310853, 1935209644, 1150682539, 1369450357, 1628560108, 1936695267, 1151565896, 1370501052, 1629809602, 1938181175, 1152449422, 
+1371551949, 1631059337, 1939667368, 1153333117, 1372603047, 1632309310, 1941153845, 1154216982, 1373654347, 1633559523, 1942640608, 1155101016, 1374705848, 1634809975, 1944127654, 1155985219, 
+1375757550, 1636060667, 1945614985, 1156869592, 1376809453, 1637311597, 1947102601, 1157754133, 1377861556, 1638562766, 1948590500, 1158638844, 1378913861, 1639814175, 1950078684, 1159523723, 
+1379966367, 1641065822, 1951567152, 1160408771, 1381019073, 1642317708, 1953055903, 1161293988, 1382071980, 1643569832, 1954544938, 1162179374, 1383125087, 1644822195, 1956034257, 1163064928, 
+1384178395, 1646074796, 1957523860, 1163950651, 1385231904, 1647327636, 1959013745, 1164836542, 1386285613, 1648580714, 1960503915, 1165722602, 1387339522, 1649834030, 1961994367, 1166608830, 
+1388393631, 1651087584, 1963485103, 1167495227, 1389447940, 1652341376, 1964976121, 1168381792, 1390502450, 1653595406, 1966467423, 1169268525, 1391557159, 1654849674, 1967959007, 1170155427, 
+1392612068, 1656104180, 1969450874, 1171042496, 1393667177, 1657358923, 1970943023, 1171929733, 1394722486, 1658613904, 1972435455, 1172817139, 1395777994, 1659869122, 1973928170, 1173704712, 
+1396833702, 1661124577, 1975421166, 1174592453, 1397889610, 1662380270, 1976914445, 1175480362, 1398945717, 1663636200, 1978408006, 1176368438, 1400002023, 1664892367, 1979901849, 1177256683, 
+1401058529, 1666148771, 1981395973, 1178145094, 1402115234, 1667405412, 1982890379, 1179033674, 1403172138, 1668662290, 1984385067, 1179922420, 1404229241, 1669919404, 1985880037, 1180811335, 
+1405286543, 1671176755, 1987375288, 1181700416, 1406344043, 1672434343, 1988870820, 1182589665, 1407401743, 1673692167, 1990366633, 1183479081, 1408459642, 1674950227, 1991862727, 1184368664, 
+1409517739, 1676208524, 1993359103, 1185258414, 1410576035, 1677467057, 1994855759, 1186148331, 1411634529, 1678725826, 1996352696, 1187038415, 1412693222, 1679984831, 1997849914, 1187928666, 
+1413752113, 1681244072, 1999347412, 1188819084, 1414811203, 1682503548, 2000845191, 1189709668, 1415870490, 1683763261, 2002343250, 1190600420, 1416929976, 1685023209, 2003841589, 1191491338, 
+1417989660, 1686283393, 2005340209, 1192382422, 1419049542, 1687543812, 2006839108, 1193273673, 1420109622, 1688804467, 2008338288, 1194165090, 1421169900, 1690065357, 2009837747, 1195056674, 
+1422230375, 1691326482, 2011337486, 1195948424, 1423291049, 1692587842, 2012837504, 1196840341, 1424351920, 1693849437, 2014337803, 1197732423, 1425412988, 1695111268, 2015838380, 1198624672, 
+1426474254, 1696373333, 2017339237, 1199517087, 1427535718, 1697635633, 2018840373, 1200409668, 1428597379, 1698898167, 2020341788, 1201302415, 1429659237, 1700160936, 2021843482, 1202195327, 
+1430721292, 1701423940, 2023345455, 1203088406, 1431783545, 1702687178, 2024847707, 1203981650, 1432845994, 1703950651, 2026350238, 1204875060, 1433908641, 1705214358, 2027853047, 1205768636, 
+1434971484, 1706478299, 2029356134, 1206662377, 1436034524, 1707742474, 2030859500, 1207556284, 1437097761, 1709006883, 2032363144, 1208450356, 1438161195, 1710271526, 2033867067, 1209344593, 
+1439224825, 1711536402, 2035371267, 1210238996, 1440288652, 1712801513, 2036875746, 1211133565, 1441352675, 1714066857, 2038380502, 1212028298, 1442416895, 1715332435, 2039885536, 1212923197, 
+1443481311, 1716598246, 2041390848, 1213818260, 1444545924, 1717864290, 2042896437, 1214713489, 1445610732, 1719130568, 2044402303, 1215608883, 1446675737, 1720397079, 2045908448, 1216504441, 
+1447740938, 1721663824, 2047414869, 1217400165, 1448806334, 1722930801, 2048921567, 1218296053, 1449871927, 1724198011, 2050428543, 1219192106, 1450937715, 1725465454, 2051935795, 1220088324, 
+1452003699, 1726733130, 2053443324, 1220984706, 1453069879, 1728001039, 2054951130, 1221881253, 1454136255, 1729269180, 2056459213, 1222777964, 1455202826, 1730537554, 2057967572, 1223674840, 
+1456269592, 1731806160, 2059476208, 1224571880, 1457336554, 1733074999, 2060985120, 1225469084, 1458403711, 1734344070, 2062494308, 1226366453, 1459471064, 1735613373, 2064003772, 1227263986, 
+1460538611, 1736882908, 2065513512, 1228161683, 1461606354, 1738152676, 2067023529, 1229059544, 1462674292, 1739422675, 2068533821, 1229957569, 1463742425, 1740692906, 2070044389, 1230855758, 
+1464810752, 1741963369, 2071555232, 1231754110, 1465879275, 1743234063, 2073066351, 1232652627, 1466947992, 1744504989, 2074577745, 1233551308, 1468016904, 1745776147, 2076089415, 1234450152, 
+1469086010, 1747047536, 2077601360, 1235349160, 1470155311, 1748319156, 2079113580, 1236248331, 1471224807, 1749591008, 2080626075, 1237147666, 1472294497, 1750863091, 2082138845, 1238047164, 
+1473364381, 1752135405, 2083651890, 1238946826, 1474434459, 1753407950, 2085165209, 1239846652, 1475504732, 1754680726, 2086678804, 1240746640, 1476575199, 1755953732, 2088192672, 1241646792, 
+1477645860, 1757226970, 2089706815, 1242547107, 1478716715, 1758500438, 2091221233, 1243447585, 1479787763, 1759774137, 2092735925, 1244348226, 1480859006, 1761048066, 2094250890, 1245249030, 
+1481930442, 1762322226, 2095766130, 1246149997, 1483002072, 1763596616, 2097281644, 1247051127, 1484073896, 1764871237, 2098797432, 1247952419, 1485145913, 1766146087, 2100313493, 1248853875, 
+1486218124, 1767421168, 2101829828, 1249755493, 1487290528, 1768696478, 2103346436, 1250657274, 1488363126, 1769972019, 2104863318, 1251559217, 1489435917, 1771247789, 2106380473, 1252461323, 
+1490508901, 1772523789, 2107897902, 1253363591, 1491582078, 1773800019, 2109415604, 1254266022, 1492655448, 1775076479, 2110933578, 1255168615, 1493729011, 1776353168, 2112451826, 1256071371, 
+1494802767, 1777630086, 2113970346, 1256974288, 1495876716, 1778907234, 2115489140, 1257877368, 1496950858, 1780184611, 2117008205, 1258780610, 1498025192, 1781462217, 2118527544, 1259684014, 
+1499099720, 1782740053, 2120047155, 1260587580, 1500174439, 1784018117, 2121567038, 1261491308, 1501249352, 1785296410, 2123087193, 1262395198, 1502324456, 1786574932, 2124607621, 1263299250, 
+1503399753, 1787853683, 2126128321, 1264203463, 1504475243, 1789132663, 2127649292, 1265107838, 1505550924, 1790411871, 2129170536, 1266012375, 1506626798, 1791691308, 2130692051, 1266917074, 
+1507702864, 1792970973, 2132213838, 1267821934, 1508779122, 1794250867, 2133735897, 1268726955, 1509855572, 1795530989, 2135258227, 1269632138, 1510932214, 1796811339, 2136780828, 1270537482, 
+1512009047, 1798091917, 2138303701, 1271442988, 1513086073, 1799372723, 2139826845, 1272348654, 1514163290, 1800653757, 2141350260, 1273254482, 1515240698, 1801935020, 2142873946, 1274160472, 
+1516318299, 1803216509, 2144397903, 1275066622, 1517396090, 1804498227, 2145922131, 1275972933, 1518474074, 1805780172, 2147446629, 1276879405, 1519552248, 1807062345, 1074485699, 1277786038, 
+1520630614, 1808344745, 1075248219, 1278692832, 1521709171, 1809627373, 1076010874, 1279599787, 1522787919, 1810910228, 1076773664, 1280506902, 1523866858, 1812193310, 1077536589, 1281414179, 
+1524945989, 1813476620, 1078299650, 1282321615, 1526025310, 1814760156, 1079062845, 1283229213, 1527104822, 1816043920, 1079826175, 1284136971, 1528184525, 1817327910, 1080589640, 1285044889, 
+1529264419, 1818612127, 1081353241, 1285952968, 1530344503, 1819896571, 1082116976, 1286861207, 1531424778, 1821181242, 1082880845, 1287769606, 1532505243, 1822466139, 1083644850, 1288678165, 
+1533585899, 1823751263, 1084408989, 1289586885, 1534666746, 1825036613, 1085173263, 1290495765, 1535747782, 1826322190, 1085937671, 1291404805, 1536829009, 1827607992, 1086702214, 1292314005, 
+1537910426, 1828894021, 1087466891, 1293223365, 1538992034, 1830180276, 1088231703, 1294132884, 1540073831, 1831466758, 1088996650, 1295042564, 1541155819, 1832753465, 1089761730, 1295952403, 
+1542237996, 1834040398, 1090526945, 1296862402, 1543320363, 1835327556, 1091292294, 1297772561, 1544402920, 1836614941, 1092057778, 1298682879, 1545485667, 1837902551, 1092823395, 1299593357, 
+1546568603, 1839190387, 1093589147, 1300503994, 1547651729, 1840478448, 1094355033, 1301414791, 1548735045, 1841766735, 1095121052, 1302325747, 1549818550, 1843055246, 1095887206, 1303236863, 
+1550902244, 1844343984, 1096653494, 1304148138, 1551986128, 1845632946, 1097419915, 1305059572, 1553070201, 1846922133, 1098186471, 1305971165, 1554154463, 1848211546, 1098953160, 1306882917, 
+1555238915, 1849501183, 1099719983, 1307794828, 1556323555, 1850791045, 1100486940, 1308706899, 1557408385, 1852081132, 1101254030, 1309619128, 1558493403, 1853371444, 1102021254, 1310531516, 
+1559578611, 1854661980, 1102788611, 1311444063, 1560664007, 1855952741, 1103556102, 1312356769, 1561749592, 1857243726, 1104323727, 1313269633, 1562835365, 1858534936, 1105091485, 1314182656, 
+1563921327, 1859826370, 1105859376, 1315095838, 1565007478, 1861118028, 1106627400, 1316009178, 1566093817, 1862409910, 1107395558, 1316922677, 1567180345, 1863702017, 1108163849, 1317836334, 
+1568267061, 1864994347, 1108932274, 1318750150, 1569353965, 1866286902, 1109700831, 1319664124, 1570441058, 1867579680, 1110469521, 1320578256, 1571528339, 1868872682, 1111238345, 1321492546, 
+1572615807, 1870165907, 1112007302, 1322406995, 1573703464, 1871459356, 1112776391, 1323321602, 1574791309, 1872753029, 1113545613, 1324236366, 1575879342, 1874046925, 1114314969, 1325151289, 
+1576967562, 1875341045, 1115084457, 1326066370, 1578055970, 1876635388, 1115854078, 1326981609, 1579144566, 1877929954, 1116623831, 1327897005, 1580233350, 1879224743, 1117393718, 1328812559, 
+1581322321, 1880519755, 1118163737, 1329728271, 1582411480, 1881814991, 1118933888, 1330644141, 1583500826, 1883110449, 1119704172, 1331560168, 1584590360, 1884406130, 1120474589, 1332476353, 
+1585680080, 1885702034, 1121245138, 1333392695, 1586769988, 1886998160, 1122015819, 1334309195, 1587860084, 1888294509, 1122786633, 1335225852, 1588950366, 1889591081, 1123557579, 1336142667, 
+1590040836, 1890887875, 1124328657, 1337059639, 1591131492, 1892184891, 1125099868, 1337976768, 1592222336, 1893482130, 1125871211, 1338894054, 1593313366, 1894779591, 1126642686, 1339811498, 
+1594404583, 1896077274, 1127414293, 1340729098, 1595495987, 1897375179, 1128186032, 1341646856, 1596587577, 1898673307, 1128957903, 1342564770, 1597679354, 1899971656, 1129729906, 1343482842, 
+1598771318, 1901270227, 1130502041, 1344401070, 1599863468, 1902569019, 1131274307, 1345319455, 1600955805, 1903868034, 1132046706, 1346237997, 1602048328, 1905167270, 1132819236, 1347156696, 
+1603141037, 1906466727, 1133591898, 1348075551, 1604233932, 1907766406, 1134364692, 1348994563, 1605327014, 1909066307, 1135137618, 1349913731, 1606420282, 1910366429, 1135910675, 1350833056, 
+1607513735, 1911666772, 1136683863, 1351752538, 1608607375, 1912967336, 1137457183, 1352672175, 1609701201, 1914268121, 1138230635, 1353591969, 1610795212, 1915569127, 1139004218, 1354511920, 
+1611889410, 1916870354, 1139777932, 1355432026, 1612983793, 1918171802, 1140551778, 1356352289, 1614078361, 1919473471, 1141325755, 1357272708, 1615173116, 1920775361, 1142099863, 1358193283, 
+1616268055, 1922077471, 1142874102, 1359114014, 1617363181, 1923379802, 1143648473, 1360034901, 1618458491, 1924682353, 1144422974, 1360955944, 1619553987, 1925985125, 1145197607, 1361877142, 
+1620649669, 1927288117, 1145972371, 1362798497, 1621745535, 1928591329, 1146747265, 1363720007, 1622841587, 1929894762, 1147522291, 1364641673, 1623937824, 1931198414, 1148297447, 1365563495, 
+1625034246, 1932502287, 1149072735, 1366485472, 1626130852, 1933806380, 1149848153, 1367407605, 1627227644, 1935110692, 1150623702, 1368329893, 1628324621, 1936415224, 1151399381, 1369252336, 
+1629421782, 1937719977, 1152175191, 1370174935, 1630519128, 1939024948, 1152951132, 1371097690, 1631616659, 1940330140, 1153727204, 1372020599, 1632714374, 1941635551, 1154503406, 1372943664, 
+1633812274, 1942941181, 1155279738, 1373866884, 1634910358, 1944247031, 1156056201, 1374790260, 1636008627, 1945553100, 1156832794, 1375713790, 1637107080, 1946859388, 1157609518, 1376637475, 
+1638205718, 1948165895, 1158386372, 1377561315, 1639304539, 1949472622, 1159163356, 1378485311, 1640403545, 1950779567, 1159940471, 1379409461, 1641502735, 1952086732, 1160717715, 1380333765, 
+1642602109, 1953394115, 1161495090, 1381258225, 1643701667, 1954701717, 1162272595, 1382182839, 1644801409, 1956009538, 1163050230, 1383107608, 1645901334, 1957317577, 1163827995, 1384032532, 
+1647001444, 1958625835, 1164605890, 1384957610, 1648101737, 1959934312, 1165383914, 1385882843, 1649202214, 1961243007, 1166162069, 1386808230, 1650302874, 1962551920, 1166940354, 1387733771, 
+1651403719, 1963861052, 1167718768, 1388659467, 1652504746, 1965170402, 1168497312, 1389585317, 1653605957, 1966479970, 1169275986, 1390511322, 1654707351, 1967789756, 1170054789, 1391437480, 
+1655808929, 1969099759, 1170833722, 1392363793, 1656910690, 1970409981, 1171612785, 1393290260, 1658012634, 1971720421, 1172391977, 1394216880, 1659114761, 1973031079, 1173171298, 1395143655, 
+1660217071, 1974341954, 1173950749, 1396070584, 1661319565, 1975653047, 1174730330, 1396997667, 1662422241, 1976964357, 1175510040, 1397924903, 1663525100, 1978275885, 1176289879, 1398852293, 
+1664628142, 1979587630, 1177069847, 1399779837, 1665731367, 1980899593, 1177849945, 1400707535, 1666834774, 1982211773, 1178630172, 1401635386, 1667938364, 1983524170, 1179410528, 1402563391, 
+1669042137, 1984836784, 1180191013, 1403491550, 1670146092, 1986149615, 1180971627, 1404419861, 1671250229, 1987462663, 1181752370, 1405348327, 1672354549, 1988775929, 1182533242, 1406276945, 
+1673459051, 1990089411, 1183314243, 1407205717, 1674563736, 1991403109, 1184095373, 1408134643, 1675668603, 1992717025, 1184876632, 1409063721, 1676773652, 1994031157, 1185658020, 1409992953, 
+1677878883, 1995345505, 1186439536, 1410922338, 1678984296, 1996660071, 1187221181, 1411851876, 1680089891, 1997974852, 1188002955, 1412781566, 1681195668, 1999289850, 1188784857, 1413711410, 
+1682301627, 2000605064, 1189566888, 1414641407, 1683407767, 2001920494, 1190349048, 1415571557, 1684514090, 2003236141, 1191131336, 1416501859, 1685620594, 2004552003, 1191913752, 1417432315, 
+1686727279, 2005868082, 1192696297, 1418362923, 1687834146, 2007184376, 1193478970, 1419293683, 1688941195, 2008500886, 1194261772, 1420224597, 1690048425, 2009817612, 1195044702, 1421155662, 
+1691155837, 2011134554, 1195827760, 1422086881, 1692263430, 2012451711, 1196610947, 1423018252, 1693371204, 2013769084, 1197394261, 1423949775, 1694479159, 2015086672, 1198177704, 1424881451, 
+1695587295, 2016404476, 1198961275, 1425813278, 1696695613, 2017722495, 1199744974, 1426745259, 1697804111, 2019040729, 1200528800, 1427677391, 1698912791, 2020359179, 1201312755, 1428609676, 
+1700021651, 2021677844, 1202096838, 1429542113, 1701130693, 2022996723, 1202881048, 1430474701, 1702239915, 2024315818, 1203665387, 1431407442, 1703349318, 2025635128, 1204449853, 1432340335, 
+1704458901, 2026954652, 1205234447, 1433273380, 1705568665, 2028274392, 1206019169, 1434206576, 1706678610, 2029594346, 1206804018, 1435139925, 1707788735, 2030914514, 1207588995, 1436073425, 
+1708899040, 2032234898, 1208374100, 1437007077, 1710009526, 2033555495, 1209159332, 1437940881, 1711120192, 2034876307, 1209944691, 1438874836, 1712231039, 2036197334, 1210730179, 1439808943, 
+1713342066, 2037518575, 1211515793, 1440743201, 1714453272, 2038840030, 1212301535, 1441677611, 1715564659, 2040161699, 1213087404, 1442612172, 1716676226, 2041483582, 1213873401, 1443546885, 
+1717787973, 2042805680, 1214659525, 1444481749, 1718899900, 2044127991, 1215445776, 1445416764, 1720012007, 2045450516, 1216232154, 1446351931, 1721124293, 2046773255, 1217018659, 1447287248, 
+1722236759, 2048096208, 1217805291, 1448222717, 1723349405, 2049419374, 1218592051, 1449158337, 1724462231, 2050742754, 1219378937, 1450094108, 1725575236, 2052066348, 1220165951, 1451030030, 
+1726688420, 2053390155, 1220953091, 1451966103, 1727801784, 2054714175, 1221740358, 1452902327, 1728915328, 2056038409, 1222527752, 1453838701, 1730029050, 2057362856, 1223315273, 1454775227, 
+1731142952, 2058687516, 1224102921, 1455711903, 1732257034, 2060012389, 1224890695, 1456648730, 1733371294, 2061337476, 1225678596, 1457585707, 1734485733, 2062662775, 1226466624, 1458522836, 
+1735600352, 2063988287, 1227254778, 1459460114, 1736715149, 2065314012, 1228043059, 1460397543, 1737830126, 2066639950, 1228831467, 1461335123, 1738945281, 2067966101, 1229620000, 1462272853, 
+1740060615, 2069292464, 1230408661, 1463210734, 1741176128, 2070619040, 1231197447, 1464148764, 1742291820, 2071945828, 1231986360, 1465086945, 1743407690, 2073272829, 1232775400, 1466025277, 
+1744523739, 2074600042, 1233564565, 1466963758, 1745639966, 2075927468, 1234353857, 1467902390, 1746756372, 2077255105, 1235143275, 1468841171, 1747872956, 2078582955, 1235932820, 1469780103, 
+1748989718, 2079911017, 1236722490, 1470719184, 1750106659, 2081239291, 1237512286, 1471658416, 1751223778, 2082567777, 1238302209, 1472597797, 1752341075, 2083896475, 1239092257, 1473537329, 
+1753458551, 2085225384, 1239882432, 1474477010, 1754576204, 2086554506, 1240672732, 1475416840, 1755694036, 2087883839, 1241463158, 1476356821, 1756812045, 2089213384, 1242253710, 1477296951, 
+1757930232, 2090543140, 1243044388, 1478237231, 1759048597, 2091873108, 1243835192, 1479177660, 1760167140, 2093203287, 1244626121, 1480118239, 1761285861, 2094533677, 1245417176, 1481058967, 
+1762404759, 2095864279, 1246208356, 1481999844, 1763523835, 2097195092, 1246999663, 1482940871, 1764643089, 2098526117, 1247791094, 1483882048, 1765762520, 2099857352, 1248582652, 1484823373, 
+1766882128, 2101188798, 1249374334, 1485764848, 1768001914, 2102520456, 1250166143, 1486706472, 1769121877, 2103852324, 1250958076, 1487648245, 1770242018, 2105184403, 1251750135, 1488590167, 
+1771362335, 2106516693, 1252542319, 1489532238, 1772482830, 2107849193, 1253334629, 1490474458, 1773603502, 2109181904, 1254127064, 1491416827, 1774724351, 2110514826, 1254919624, 1492359345, 
+1775845377, 2111847958, 1255712309, 1493302012, 1776966580, 2113181300, 1256505119, 1494244827, 1778087960, 2114514853, 1257298054, 1495187792, 1779209517, 2115848616, 1258091114, 1496130905, 
+1780331250, 2117182590, 1258884300, 1497074166, 1781453160, 2118516773, 1259677610, 1498017577, 1782575247, 2119851167, 1260471045, 1498961135, 1783697511, 2121185771, 1261264605, 1499904843, 
+1784819951, 2122520584, 1262058290, 1500848698, 1785942567, 2123855608, 1262852100, 1501792703, 1787065360, 2125190841, 1263646035, 1502736855, 1788188330, 2126526285, 1264440094, 1503681156, 
+1789311475, 2127861937, 1265234278, 1504625605, 1790434797, 2129197800, 1266028586, 1505570203, 1791558295, 2130533872, 1266823020, 1506514948, 1792681970, 2131870153, 1267617577, 1507459842, 
+1793805820, 2133206644, 1268412260, 1508404884, 1794929847, 2134543345, 1269207066, 1509350074, 1796054049, 2135880254, 1270001998, 1510295412, 1797178428, 2137217373, 1270797053, 1511240897, 
+1798302982, 2138554701, 1271592233, 1512186531, 1799427712, 2139892238, 1272387537, 1513132313, 1800552618, 2141229984, 1273182966, 1514078242, 1801677700, 2142567939, 1273978519, 1515024319, 
+1802802957, 2143906104, 1274774196, 1515970544, 1803928390, 2145244476, 1275569997, 1516916917, 1805053999, 2146583058, 1276365923, 1517863437, 1806179783, 1073960924, 1277161972, 1518810105, 
+1807305742, 1074630424, 1277958146, 1519756920, 1808431877, 1075300028, 1278754444, 1520703883, 1809558187, 1075969736, 1279550865, 1521650993, 1810684673, 1076639548, 1280347411, 1522598250, 
+1811811333, 1077309464, 1281144080, 1523545655, 1812938169, 1077979485, 1281940873, 1524493208, 1814065180, 1078649610, 1282737791, 1525440907, 1815192367, 1079319839, 1283534832, 1526388754, 
+1816319728, 1079990172, 1284331996, 1527336748, 1817447264, 1080660609, 1285129285, 1528284889, 1818574975, 1081331150, 1285926697, 1529233177, 1819702861, 1082001795, 1286724232, 1530181612, 
+1820830921, 1082672543, 1287521892, 1531130194, 1821959157, 1083343396, 1288319675, 1532078924, 1823087567, 1084014353, 1289117581, 1533027800, 1824216151, 1084685413, 1289915611, 1533976822, 
+1825344911, 1085356578, 1290713764, 1534925992, 1826473845, 1086027846, 1291512041, 1535875308, 1827602953, 1086699218, 1292310441, 1536824772, 1828732236, 1087370693, 1293108965, 1537774381, 
+1829861693, 1088042272, 1293907612, 1538724138, 1830991324, 1088713955, 1294706382, 1539674041, 1832121130, 1089385742, 1295505275, 1540624090, 1833251110, 1090057632, 1296304291, 1541574286, 
+1834381264, 1090729625, 1297103431, 1542524629, 1835511592, 1091401722, 1297902693, 1543475118, 1836642094, 1092073923, 1298702079, 1544425753, 1837772770, 1092746227, 1299501588, 1545376534, 
+1838903620, 1093418634, 1300301220, 1546327462, 1840034644, 1094091145, 1301100974, 1547278536, 1841165842, 1094763760, 1301900852, 1548229756, 1842297214, 1095436477, 1302700853, 1549181123, 
+1843428759, 1096109298, 1303500976, 1550132635, 1844560478, 1096782222, 1304301222, 1551084293, 1845692370, 1097455249, 1305101591, 1552036098, 1846824437, 1098128380, 1305902083, 1552988048, 
+1847956676, 1098801614, 1306702697, 1553940145, 1849089089, 1099474951, 1307503434, 1554892387, 1850221676, 1100148391, 1308304294, 1555844775, 1851354436, 1100821934, 1309105276, 1556797308, 
+1852487369, 1101495580, 1309906381, 1557749988, 1853620475, 1102169329, 1310707608, 1558702813, 1854753755, 1102843181, 1311508957, 1559655784, 1855887208, 1103517136, 1312310430, 1560608900, 
+1857020833, 1104191194, 1313112024, 1561562162, 1858154632, 1104865355, 1313913741, 1562515569, 1859288604, 1105539618, 1314715580, 1563469122, 1860422749, 1106213985, 1315517542, 1564422820, 
+1861557067, 1106888454, 1316319625, 1565376664, 1862691557, 1107563026, 1317121831, 1566330653, 1863826220, 1108237701, 1317924159, 1567284787, 1864961056, 1108912479, 1318726609, 1568239067, 
+1866096065, 1109587359, 1319529182, 1569193491, 1867231246, 1110262342, 1320331876, 1570148061, 1868366600, 1110937427, 1321134692, 1571102776, 1869502126, 1111612615, 1321937631, 1572057636, 
+1870637825, 1112287905, 1322740691, 1573012641, 1871773696, 1112963298, 1323543873, 1573967791, 1872909739, 1113638794, 1324347177, 1574923086, 1874045955, 1114314392, 1325150603, 1575878526, 
+1875182343, 1114990092, 1325954151, 1576834110, 1876318904, 1115665895, 1326757820, 1577789840, 1877455636, 1116341800, 1327561612, 1578745714, 1878592540, 1117017808, 1328365524, 1579701733, 
+1879729617, 1117693917, 1329169559, 1580657897, 1880866865, 1118370129, 1329973715, 1581614205, 1882004286, 1119046444, 1330777993, 1582570657, 1883141878, 1119722860, 1331582392, 1583527255, 
+1884279642, 1120399379, 1332386913, 1584483997, 1885417578, 1121075999, 1333191555, 1585440883, 1886555686, 1121752722, 1333996319, 1586397913, 1887693965, 1122429547, 1334801204, 1587355088, 
+1888832416, 1123106474, 1335606210, 1588312408, 1889971039, 1123783503, 1336411338, 1589269871, 1891109833, 1124460634, 1337216587, 1590227479, 1892248798, 1125137867, 1338021957, 1591185231, 
+1893387935, 1125815202, 1338827448, 1592143127, 1894527243, 1126492639, 1339633061, 1593101167, 1895666723, 1127170177, 1340438795, 1594059352, 1896806374, 1127847818, 1341244649, 1595017680, 
+1897946196, 1128525560, 1342050625, 1595976152, 1899086189, 1129203404, 1342856722, 1596934768, 1900226353, 1129881350, 1343662940, 1597893528, 1901366688, 1130559397, 1344469279, 1598852432, 
+1902507195, 1131237546, 1345275739, 1599811480, 1903647872, 1131915797, 1346082319, 1600770672, 1904788720, 1132594149, 1346889021, 1601730007, 1905929739, 1133272603, 1347695843, 1602689486, 
+1907070929, 1133951159, 1348502786, 1603649108, 1908212290, 1134629816, 1349309850, 1604608874, 1909353821, 1135308575, 1350117035, 1605568784, 1910495523, 1135987435, 1350924340, 1606528837, 
+1911637396, 1136666396, 1351731766, 1607489033, 1912779439, 1137345459, 1352539312, 1608449373, 1913921652, 1138024623, 1353346979, 1609409857, 1915064036, 1138703889, 1354154766, 1610370483, 
+1916206591, 1139383256, 1354962674, 1611331253, 1917349315, 1140062724, 1355770703, 1612292166, 1918492211, 1140742293, 1356578852, 1613253223, 1919635276, 1141421964, 1357387121, 1614214422, 
+1920778511, 1142101736, 1358195510, 1615175765, 1921921917, 1142781609, 1359004020, 1616137250, 1923065493, 1143461583, 1359812650, 1617098879, 1924209238, 1144141658, 1360621401, 1618060651, 
+1925353154, 1144821835, 1361430271, 1619022565, 1926497240, 1145502112, 1362239262, 1619984623, 1927641495, 1146182491, 1363048373, 1620946823, 1928785921, 1146862970, 1363857604, 1621909166, 
+1929930516, 1147543550, 1364666955, 1622871652, 1931075281, 1148224232, 1365476426, 1623834281, 1932220215, 1148905014, 1366286017, 1624797052, 1933365319, 1149585897, 1367095728, 1625759966, 
+1934510593, 1150266881, 1367905559, 1626723023, 1935656036, 1150947965, 1368715509, 1627686222, 1936801649, 1151629151, 1369525580, 1628649564, 1937947431, 1152310437, 1370335770, 1629613048, 
+1939093383, 1152991824, 1371146080, 1630576675, 1940239504, 1153673311, 1371956510, 1631540444, 1941385794, 1154354900, 1372767060, 1632504355, 1942532254, 1155036589, 1373577729, 1633468409, 
+1943678882, 1155718378, 1374388518, 1634432604, 1944825680, 1156400268, 1375199427, 1635396943, 1945972647, 1157082259, 1376010455, 1636361423, 1947119783, 1157764350, 1376821602, 1637326045, 
+1948267088, 1158446541, 1377632869, 1638290810, 1949414561, 1159128833, 1378444256, 1639255717, 1950562204, 1159811226, 1379255762, 1640220765, 1951710016, 1160493718, 1380067387, 1641185956, 
+1952857996, 1161176312, 1380879132, 1642151288, 1954006145, 1161859005, 1381690996, 1643116763, 1955154463, 1162541799, 1382502979, 1644082379, 1956302949, 1163224693, 1383315081, 1645048137, 
+1957451604, 1163907687, 1384127303, 1646014037, 1958600427, 1164590782, 1384939644, 1646980078, 1959749419, 1165273977, 1385752104, 1647946261, 1960898580, 1165957271, 1386564683, 1648912586, 
+1962047908, 1166640666, 1387377381, 1649879053, 1963197406, 1167324161, 1388190198, 1650845661, 1964347071, 1168007757, 1389003134, 1651812410, 1965496905, 1168691452, 1389816190, 1652779301, 
+1966646906, 1169375247, 1390629364, 1653746334, 1967797076, 1170059142, 1391442657, 1654713507, 1968947414, 1170743137, 1392256069, 1655680823, 1970097921, 1171427232, 1393069599, 1656648279, 
+1971248595, 1172111427, 1393883249, 1657615877, 1972399437, 1172795722, 1394697017, 1658583616, 1973550447, 1173480116, 1395510904, 1659551496, 1974701624, 1174164611, 1396324909, 1660519517, 
+1975852970, 1174849205, 1397139034, 1661487680, 1977004483, 1175533899, 1397953277, 1662455983, 1978156164, 1176218693, 1398767638, 1663424427, 1979308013, 1176903586, 1399582118, 1664393013, 
+1980460029, 1177588579, 1400396717, 1665361739, 1981612213, 1178273672, 1401211434, 1666330607, 1982764565, 1178958864, 1402026269, 1667299615, 1983917083, 1179644156, 1402841223, 1668268764, 
+1985069770, 1180329547, 1403656295, 1669238053, 1986222623, 1181015038, 1404471486, 1670207484, 1987375644, 1181700628, 1405286795, 1671177055, 1988528832, 1182386318, 1406102222, 1672146767, 
+1989682188, 1183072107, 1406917767, 1673116619, 1990835710, 1183757996, 1407733431, 1674086612, 1991989400, 1184443984, 1408549213, 1675056745, 1993143256, 1185130071, 1409365112, 1676027019, 
+1994297280, 1185816257, 1410181130, 1676997434, 1995451471, 1186502543, 1410997267, 1677967989, 1996605828, 1187188929, 1411813521, 1678938684, 1997760353, 1187875413, 1412629893, 1679909519, 
+1998915044, 1188561996, 1413446383, 1680880495, 2000069902, 1189248679, 1414262991, 1681851611, 2001224927, 1189935461, 1415079717, 1682822867, 2002380119, 1190622342, 1415896560, 1683794264, 
+2003535477, 1191309322, 1416713522, 1684765800, 2004691002, 1191996401, 1417530601, 1685737477, 2005846693, 1192683579, 1418347799, 1686709294, 2007002551, 1193370857, 1419165113, 1687681250, 
+2008158575, 1194058233, 1419982546, 1688653347, 2009314765, 1194745708, 1420800096, 1689625583, 2010471122, 1195433282, 1421617764, 1690597960, 2011627646, 1196120954, 1422435549, 1691570476, 
+2012784335, 1196808726, 1423253452, 1692543132, 2013941191, 1197496597, 1424071473, 1693515928, 2015098213, 1198184566, 1424889611, 1694488863, 2016255401, 1198872634, 1425707866, 1695461939, 
+2017412755, 1199560801, 1426526239, 1696435154, 2018570275, 1200249066, 1427344730, 1697408508, 2019727961, 1200937431, 1428163337, 1698382002, 2020885813, 1201625894, 1428982062, 1699355636, 
+2022043830, 1202314455, 1429800904, 1700329409, 2023202014, 1203003115, 1430619864, 1701303321, 2024360363, 1203691874, 1431438941, 1702277373, 2025518879, 1204380731, 1432258134, 1703251564, 
+2026677559, 1205069687, 1433077445, 1704225895, 2027836406, 1205758741, 1433896874, 1705200364, 2028995418, 1206447894, 1434716419, 1706174973, 2030154595, 1207137145, 1435536081, 1707149722, 
+2031313938, 1207826494, 1436355861, 1708124609, 2032473447, 1208515942, 1437175757, 1709099636, 2033633121, 1209205488, 1437995770, 1710074801, 2034792960, 1209895133, 1438815900, 1711050106, 
+2035952964, 1210584876, 1439636147, 1712025549, 2037113134, 1211274717, 1440456511, 1713001132, 2038273469, 1211964656, 1441276992, 1713976854, 2039433969, 1212654693, 1442097590, 1714952714, 
+2040594635, 1213344829, 1442918304, 1715928713, 2041755465, 1214035063, 1443739135, 1716904851, 2042916460, 1214725395, 1444560082, 1717881128, 2044077621, 1215415825, 1445381147, 1718857544, 
+2045238946, 1216106353, 1446202328, 1719834098, 2046400436, 1216796979, 1447023625, 1720810791, 2047562091, 1217487703, 1447845039, 1721787622, 2048723911, 1218178526, 1448666570, 1722764592, 
+2049885895, 1218869446, 1449488217, 1723741701, 2051048044, 1219560464, 1450309981, 1724718948, 2052210358, 1220251580, 1451131861, 1725696334, 2053372837, 1220942793, 1451953857, 1726673857, 
+2054535480, 1221634105, 1452775970, 1727651520, 2055698287, 1222325515, 1453598199, 1728629320, 2056861259, 1223017022, 1454420544, 1729607259, 2058024395, 1223708627, 1455243006, 1730585337, 
+2059187696, 1224400330, 1456065584, 1731563552, 2060351161, 1225092130, 1456888278, 1732541905, 2061514790, 1225784028, 1457711088, 1733520397, 2062678584, 1226476024, 1458534014, 1734499027, 
+2063842542, 1227168117, 1459357056, 1735477795, 2065006663, 1227860308, 1460180215, 1736456701, 2066170949, 1228552597, 1461003489, 1737435745, 2067335399, 1229244983, 1461826880, 1738414926, 
+2068500013, 1229937467, 1462650386, 1739394246, 2069664791, 1230630048, 1463474009, 1740373704, 2070829733, 1231322726, 1464297747, 1741353299, 2071994839, 1232015502, 1465121601, 1742333032, 
+2073160108, 1232708376, 1465945571, 1743312903, 2074325541, 1233401346, 1466769657, 1744292912, 2075491138, 1234094414, 1467593858, 1745273058, 2076656899, 1234787580, 1468418176, 1746253342, 
+2077822823, 1235480843, 1469242609, 1747233764, 2078988911, 1236174203, 1470067157, 1748214323, 2080155163, 1236867660, 1470891821, 1749195019, 2081321578, 1237561214, 1471716601, 1750175854, 
+2082488156, 1238254866, 1472541497, 1751156825, 2083654898, 1238948615, 1473366508, 1752137934, 2084821803, 1239642461, 1474191634, 1753119180, 2085988871, 1240336404, 1475016876, 1754100564, 
+2087156103, 1241030444, 1475842234, 1755082085, 2088323498, 1241724581, 1476667706, 1756063743, 2089491056, 1242418815, 1477493295, 1757045538, 2090658777, 1243113146, 1478318998, 1758027471, 
+2091826661, 1243807574, 1479144817, 1759009540, 2092994708, 1244502099, 1479970751, 1759991747, 2094162918, 1245196721, 1480796801, 1760974091, 2095331292, 1245891440, 1481622965, 1761956572, 
+2096499828, 1246586256, 1482449245, 1762939190, 2097668527, 1247281168, 1483275640, 1763921944, 2098837388, 1247976178, 1484102150, 1764904836, 2100006413, 1248671284, 1484928775, 1765887865, 
+2101175600, 1249366487, 1485755515, 1766871030, 2102344950, 1250061786, 1486582371, 1767854332, 2103514462, 1250757183, 1487409341, 1768837771, 2104684138, 1251452676, 1488236426, 1769821347, 
+2105853975, 1252148265, 1489063626, 1770805059, 2107023975, 1252843951, 1489890941, 1771788908, 2108194138, 1253539734, 1490718371, 1772772893, 2109364463, 1254235614, 1491545916, 1773757015, 
+2110534950, 1254931590, 1492373575, 1774741274, 2111705600, 1255627662, 1493201349, 1775725669, 2112876412, 1256323831, 1494029238, 1776710200, 2114047386, 1257020096, 1494857242, 1777694868, 
+2115218522, 1257716458, 1495685361, 1778679673, 2116389820, 1258412916, 1496513594, 1779664613, 2117561281, 1259109471, 1497341941, 1780649690, 2118732903, 1259806122, 1498170404, 1781634903, 
+2119904688, 1260502869, 1498998980, 1782620253, 2121076634, 1261199713, 1499827672, 1783605738, 2122248743, 1261896652, 1500656477, 1784591360, 2123421013, 1262593688, 1501485398, 1785577118, 
+2124593445, 1263290821, 1502314432, 1786563012, 2125766039, 1263988049, 1503143581, 1787549042, 2126938794, 1264685374, 1503972845, 1788535208, 2128111712, 1265382794, 1504802222, 1789521510, 
+2129284790, 1266080311, 1505631714, 1790507947, 2130458031, 1266777924, 1506461321, 1791494521, 2131631433, 1267475633, 1507291041, 1792481231, 2132804996, 1268173438, 1508120876, 1793468076, 
+2133978721, 1268871339, 1508950825, 1794455057, 2135152608, 1269569336, 1509780888, 1795442174, 2136326656, 1270267429, 1510611065, 1796429426, 2137500865, 1270965618, 1511441356, 1797416815, 
+2138675235, 1271663903, 1512271761, 1798404338, 2139849767, 1272362284, 1513102281, 1799391998, 2141024459, 1273060760, 1513932914, 1800379793, 2142199313, 1273759333, 1514763661, 1801367723, 
+2143374328, 1274458001, 1515594522, 1802355789, 2144549504, 1275156765, 1516425497, 1803343991, 2145724842, 1275855624, 1517256586, 1804332327, 2146900340, 1276554580, 1518087789, 1805320799, 
+1074037999, 1277253631, 1518919105, 1806309407, 1074625909, 1277952777, 1519750535, 1807298150, 1075213900, 1278652020, 1520582079, 1808287028, 1075801970, 1279351358, 1521413737, 1809276041, 
+1076390122, 1280050791, 1522245508, 1810265189, 1076978353, 1280750320, 1523077393, 1811254473, 1077566665, 1281449945, 1523909392, 1812243891, 1078155057, 1282149665, 1524741504, 1813233445, 
+1078743529, 1282849480, 1525573730, 1814223134, 1079332082, 1283549391, 1526406069, 1815212957, 1079920715, 1284249398, 1527238522, 1816202916, 1080509428, 1284949500, 1528071088, 1817193010, 
+1081098222, 1285649697, 1528903767, 1818183238, 1081687095, 1286349990, 1529736560, 1819173601, 1082276049, 1287050378, 1530569466, 1820164100, 1082865083, 1287750861, 1531402486, 1821154732, 
+1083454197, 1288451439, 1532235619, 1822145500, 1084043391, 1289152113, 1533068865, 1823136402, 1084632665, 1289852882, 1533902225, 1824127439, 1085222019, 1290553746, 1534735697, 1825118611, 
+1085811453, 1291254706, 1535569283, 1826109917, 1086400967, 1291955760, 1536402982, 1827101358, 1086990561, 1292656910, 1537236794, 1828092933, 1087580236, 1293358154, 1538070719, 1829084643, 
+1088169990, 1294059494, 1538904757, 1830076487, 1088759824, 1294760929, 1539738909, 1831068465, 1089349737, 1295462459, 1540573173, 1832060578, 1089939731, 1296164083, 1541407550, 1833052826, 
+1090529805, 1296865803, 1542242040, 1834045207, 1091119958, 1297567618, 1543076643, 1835037723, 1091710192, 1298269527, 1543911359, 1836030373, 1092300505, 1298971532, 1544746188, 1837023157, 
+1092890897, 1299673631, 1545581129, 1838016076, 1093481370, 1300375825, 1546416184, 1839009128, 1094071922, 1301078114, 1547251351, 1840002315, 1094662554, 1301780498, 1548086630, 1840995635, 
+1095253266, 1302482977, 1548922023, 1841989090, 1095844057, 1303185550, 1549757528, 1842982679, 1096434928, 1303888218, 1550593146, 1843976401, 1097025879, 1304590980, 1551428876, 1844970258, 
+1097616909, 1305293838, 1552264719, 1845964248, 1098208019, 1305996789, 1553100674, 1846958372, 1098799208, 1306699836, 1553936742, 1847952630, 1099390477, 1307402977, 1554772923, 1848947022, 
+1099981825, 1308106213, 1555609215, 1849941547, 1100573253, 1308809543, 1556445621, 1850936206, 1101164760, 1309512968, 1557282138, 1851930999, 1101756347, 1310216487, 1558118768, 1852925925, 
+1102348013, 1310920100, 1558955511, 1853920985, 1102939759, 1311623808, 1559792365, 1854916179, 1103531584, 1312327611, 1560629332, 1855911505, 1104123488, 1313031508, 1561466411, 1856906966, 
+1104715471, 1313735499, 1562303602, 1857902560, 1105307534, 1314439584, 1563140906, 1858898287, 1105899677, 1315143764, 1563978321, 1859894147, 1106491898, 1315848038, 1564815849, 1860890141, 
+1107084199, 1316552406, 1565653489, 1861886269, 1107676579, 1317256869, 1566491241, 1862882529, 1108269038, 1317961426, 1567329105, 1863878923, 1108861577, 1318666076, 1568167080, 1864875450, 
+1109454194, 1319370821, 1569005168, 1865872110, 1110046891, 1320075661, 1569843368, 1866868903, 1110639667, 1320780594, 1570681680, 1867865829, 1111232522, 1321485621, 1571520103, 1868862888, 
+1111825456, 1322190743, 1572358639, 1869860080, 1112418469, 1322895958, 1573197286, 1870857405, 1113011561, 1323601267, 1574036045, 1871854864, 1113604732, 1324306671, 1574874915, 1872852455, 
+1114197982, 1325012168, 1575713898, 1873850178, 1114791311, 1325717759, 1576552992, 1874848035, 1115384720, 1326423445, 1577392198, 1875846025, 1115978207, 1327129224, 1578231515, 1876844147, 
+1116571773, 1327835096, 1579070944, 1877842402, 1117165417, 1328541063, 1579910485, 1878840790, 1117759141, 1329247124, 1580750137, 1879839310, 1118352944, 1329953278, 1581589901, 1880837963, 
+1118946825, 1330659526, 1582429776, 1881836748, 1119540785, 1331365868, 1583269762, 1882835666, 1120134824, 1332072303, 1584109860, 1883834717, 1120728942, 1332778832, 1584950070, 1884833900, 
+1121323139, 1333485455, 1585790391, 1885833215, 1121917414, 1334192171, 1586630823, 1886832663, 1122511768, 1334898981, 1587471366, 1887832243, 1123106201, 1335605885, 1588312021, 1888831956, 
+1123700712, 1336312882, 1589152787, 1889831801, 1124295302, 1337019972, 1589993664, 1890831778, 1124889970, 1337727156, 1590834652, 1891831887, 1125484718, 1338434434, 1591675752, 1892832129, 
+1126079543, 1339141805, 1592516963, 1893832503, 1126674448, 1339849270, 1593358284, 1894833008, 1127269431, 1340556827, 1594199717, 1895833646, 1127864492, 1341264479, 1595041261, 1896834416, 
+1128459632, 1341972223, 1595882916, 1897835318, 1129054850, 1342680061, 1596724682, 1898836352, 1129650147, 1343387992, 1597566559, 1899837518, 1130245522, 1344096017, 1598408546, 1900838816, 
+1130840976, 1344804135, 1599250645, 1901840246, 1131436508, 1345512346, 1600092855, 1902841807, 1132032119, 1346220650, 1600935175, 1903843501, 1132627807, 1346929047, 1601777606, 1904845326, 
+1133223574, 1347637538, 1602620148, 1905847283, 1133819420, 1348346121, 1603462801, 1906849371, 1134415344, 1349054798, 1604305564, 1907851592, 1135011346, 1349763568, 1605148438, 1908853944, 
+1135607426, 1350472431, 1605991423, 1909856427, 1136203584, 1351181387, 1606834519, 1910859042, 1136799821, 1351890436, 1607677725, 1911861789, 1137396136, 1352599578, 1608521041, 1912864667, 
+1137992529, 1353308812, 1609364469, 1913867677, 1138589000, 1354018140, 1610208006, 1914870818, 1139185550, 1354727561, 1611051654, 1915874090, 1139782177, 1355437075, 1611895413, 1916877494, 
+1140378883, 1356146681, 1612739282, 1917881029, 1140975666, 1356856380, 1613583262, 1918884695, 1141572528, 1357566172, 1614427351, 1919888493, 1142169468, 1358276057, 1615271552, 1920892422, 
+1142766485, 1358986035, 1616115862, 1921896482, 1143363581, 1359696105, 1616960283, 1922900673, 1143960755, 1360406269, 1617804814, 1923904995, 1144558006, 1361116524, 1618649455, 1924909449, 
+1145155336, 1361826873, 1619494207, 1925914033, 1145752743, 1362537314, 1620339068, 1926918749, 1146350228, 1363247848, 1621184040, 1927923595, 1146947791, 1363958474, 1622029122, 1928928573, 
+1147545432, 1364669193, 1622874314, 1929933681, 1148143151, 1365380005, 1623719616, 1930938920, 1148740948, 1366090909, 1624565028, 1931944290, 1149338822, 1366801905, 1625410550, 1932949791, 
+1149936775, 1367512994, 1626256182, 1933955423, 1150534804, 1368224175, 1627101924, 1934961185, 1151132912, 1368935449, 1627947776, 1935967078, 1151731097, 1369646816, 1628793738, 1936973102, 
+1152329360, 1370358274, 1629639810, 1937979257, 1152927701, 1371069825, 1630485991, 1938985542, 1153526119, 1371781469, 1631332283, 1939991957, 1154124615, 1372493204, 1632178684, 1940998504, 
+1154723189, 1373205032, 1633025194, 1942005180, 1155321840, 1373916952, 1633871815, 1943011987, 1155920569, 1374628965, 1634718545, 1944018925, 1156519375, 1375341069, 1635565385, 1945025993, 
+1157118259, 1376053266, 1636412335, 1946033191, 1157717220, 1376765555, 1637259394, 1947040520, 1158316259, 1377477936, 1638106562, 1948047979, 1158915375, 1378190409, 1638953841, 1949055568, 
+1159514568, 1378902975, 1639801228, 1950063288, 1160113839, 1379615632, 1640648726, 1951071138, 1160713188, 1380328381, 1641496332, 1952079118, 1161312614, 1381041223, 1642344048, 1953087228, 
+1161912117, 1381754156, 1643191874, 1954095468, 1162511697, 1382467182, 1644039809, 1955103838, 1163111355, 1383180299, 1644887853, 1956112338, 1163711090, 1383893508, 1645736007, 1957120969, 
+1164310903, 1384606810, 1646584270, 1958129729, 1164910792, 1385320203, 1647432642, 1959138619, 1165510759, 1386033688, 1648281123, 1960147639, 1166110804, 1386747264, 1649129714, 1961156789, 
+1166710925, 1387460933, 1649978413, 1962166069, 1167311123, 1388174693, 1650827222, 1963175478, 1167911399, 1388888546, 1651676140, 1964185018, 1168511752, 1389602489, 1652525167, 1965194687, 
+1169112182, 1390316525, 1653374304, 1966204486, 1169712689, 1391030652, 1654223549, 1967214414, 1170313273, 1391744871, 1655072903, 1968224472, 1170913934, 1392459182, 1655922366, 1969234660, 
+1171514673, 1393173584, 1656771938, 1970244977, 1172115488, 1393888078, 1657621620, 1971255424, 1172716380, 1394602663, 1658471410, 1972266000, 1173317349, 1395317340, 1659321308, 1973276706, 
+1173918396, 1396032108, 1660171316, 1974287541, 1174519519, 1396746968, 1661021433, 1975298506, 1175120719, 1397461920, 1661871658, 1976309600, 1175721996, 1398176963, 1662721992, 1977320823, 
+1176323350, 1398892097, 1663572435, 1978332176, 1176924780, 1399607323, 1664422986, 1979343658, 1177526288, 1400322640, 1665273646, 1980355269, 1178127872, 1401038048, 1666124415, 1981367009, 
+1178729534, 1401753548, 1666975293, 1982378879, 1179331272, 1402469139, 1667826279, 1983390877, 1179933086, 1403184821, 1668677373, 1984403005, 1180534978, 1403900595, 1669528577, 1985415262, 
+1181136946, 1404616460, 1670379888, 1986427648, 1181738991, 1405332416, 1671231308, 1987440163, 1182341113, 1406048464, 1672082837, 1988452806, 1182943311, 1406764602, 1672934474, 1989465579, 
+1183545586, 1407480832, 1673786219, 1990478481, 1184147938, 1408197153, 1674638073, 1991491512, 1184750366, 1408913564, 1675490035, 1992504671, 1185352871, 1409630067, 1676342106, 1993517959, 
+1185955452, 1410346661, 1677194284, 1994531376, 1186558110, 1411063347, 1678046571, 1995544922, 1187160844, 1411780123, 1678898967, 1996558596, 1187763655, 1412496990, 1679751470, 1997572400, 
+1188366543, 1413213948, 1680604082, 1998586331, 1188969507, 1413930997, 1681456801, 1999600392, 1189572547, 1414648137, 1682309629, 2000614581, 1190175664, 1415365367, 1683162565, 2001628898, 
+1190778857, 1416082689, 1684015609, 2002643344, 1191382127, 1416800102, 1684868761, 2003657919, 1191985473, 1417517605, 1685722022, 2004672622, 1192588895, 1418235199, 1686575390, 2005687453, 
+1193192394, 1418952884, 1687428866, 2006702413, 1193795969, 1419670660, 1688282450, 2007717501, 1194399620, 1420388526, 1689136142, 2008732718, 1195003348, 1421106484, 1689989941, 2009748063, 
+1195607152, 1421824531, 1690843849, 2010763536, 1196211032, 1422542670, 1691697864, 2011779137, 1196814988, 1423260899, 1692551988, 2012794866, 1197419021, 1423979219, 1693406219, 2013810724, 
+1198023129, 1424697629, 1694260557, 2014826710, 1198627314, 1425416130, 1695115004, 2015842823, 1199231575, 1426134722, 1695969558, 2016859065, 1199835912, 1426853404, 1696824220, 2017875435, 
+1200440326, 1427572176, 1697678989, 2018891933, 1201044815, 1428291039, 1698533866, 2019908559, 1201649380, 1429009993, 1699388851, 2020925313, 1202254022, 1429729037, 1700243943, 2021942195, 
+1202858739, 1430448171, 1701099143, 2022959204, 1203463533, 1431167396, 1701954450, 2023976342, 1204068402, 1431886711, 1702809865, 2024993607, 1204673348, 1432606117, 1703665387, 2026011000, 
+1205278369, 1433325612, 1704521016, 2027028520, 1205883467, 1434045199, 1705376753, 2028046169, 1206488640, 1434764875, 1706232598, 2029063945, 1207093889, 1435484642, 1707088549, 2030081849, 
+1207699214, 1436204499, 1707944608, 2031099880, 1208304615, 1436924446, 1708800775, 2032118039, 1208910092, 1437644483, 1709657048, 2033136326, 1209515645, 1438364610, 1710513429, 2034154740, 
+1210121273, 1439084828, 1711369917, 2035173281, 1210726977, 1439805136, 1712226512, 2036191950, 1211332757, 1440525534, 1713083214, 2037210747, 1211938613, 1441246022, 1713940023, 2038229670, 
+1212544544, 1441966600, 1714796940, 2039248722, 1213150552, 1442687268, 1715653963, 2040267900, 1213756634, 1443408026, 1716511094, 2041287206, 1214362793, 1444128874, 1717368331, 2042306639, 
+1214969027, 1444849811, 1718225676, 2043326199, 1215575337, 1445570839, 1719083127, 2044345886, 1216181722, 1446291957, 1719940686, 2045365701, 1216788183, 1447013165, 1720798351, 2046385643, 
+1217394720, 1447734463, 1721656123, 2047405712, 1218001332, 1448455850, 1722514003, 2048425908, 1218608020, 1449177327, 1723371989, 2049446231, 1219214783, 1449898894, 1724230081, 2050466680, 
+1219821621, 1450620551, 1725088281, 2051487257, 1220428536, 1451342298, 1725946587, 2052507961, 1221035525, 1452064134, 1726805000, 2053528792, 1221642590, 1452786060, 1727663520, 2054549750, 
+1222249731, 1453508076, 1728522146, 2055570834, 1222856947, 1454230182, 1729380879, 2056592046, 1223464238, 1454952377, 1730239718, 2057613384, 1224071605, 1455674662, 1731098665, 2058634849, 
+1224679047, 1456397036, 1731957717, 2059656440, 1225286564, 1457119500, 1732816877, 2060678159, 1225894157, 1457842053, 1733676142, 2061700004, 1226501825, 1458564696, 1734535515, 2062721975, 
+1227109568, 1459287429, 1735394993, 2063744074, 1227717386, 1460010251, 1736254579, 2064766298, 1228325280, 1460733163, 1737114270, 2065788650, 1228933249, 1461456164, 1737974068, 2066811127, 
+1229541293, 1462179254, 1738833972, 2067833732, 1230149413, 1462902434, 1739693983, 2068856463, 1230757607, 1463625703, 1740554100, 2069879320, 1231365877, 1464349062, 1741414323, 2070902303, 
+1231974221, 1465072510, 1742274653, 2071925413, 1232582641, 1465796047, 1743135088, 2072948649, 1233191136, 1466519673, 1743995630, 2073972012, 1233799706, 1467243389, 1744856278, 2074995500, 
+1234408351, 1467967194, 1745717032, 2076019115, 1235017072, 1468691089, 1746577892, 2077042857, 1235625867, 1469415072, 1747438859, 2078066724, 1236234737, 1470139145, 1748299931, 2079090717, 
+1236843682, 1470863307, 1749161110, 2080114837, 1237452702, 1471587558, 1750022394, 2081139083, 1238061797, 1472311898, 1750883785, 2082163454, 1238670967, 1473036327, 1751745281, 2083187952, 
+1239280212, 1473760846, 1752606883, 2084212575, 1239889532, 1474485453, 1753468592, 2085237325, 1240498926, 1475210149, 1754330406, 2086262201, 1241108396, 1475934935, 1755192326, 2087287202, 
+1241717940, 1476659809, 1756054352, 2088312329, 1242327559, 1477384773, 1756916483, 2089337582, 1242937253, 1478109825, 1757778721, 2090362961, 1243547022, 1478834966, 1758641064, 2091388466, 
+1244156865, 1479560196, 1759503513, 2092414096, 1244766783, 1480285515, 1760366067, 2093439852, 1245376776, 1481010923, 1761228727, 2094465734, 1245986844, 1481736420, 1762091493, 2095491741, 
+1246596986, 1482462006, 1762954365, 2096517874, 1247207203, 1483187680, 1763817342, 2097544133, 1247817495, 1483913443, 1764680425, 2098570517, 1248427861, 1484639295, 1765543613, 2099597026, 
+1249038302, 1485365236, 1766406906, 2100623661, 1249648817, 1486091265, 1767270306, 2101650422, 1250259407, 1486817383, 1768133810, 2102677308, 1250870072, 1487543590, 1768997421, 2103704319, 
+1251480811, 1488269885, 1769861136, 2104731456, 1252091625, 1488996269, 1770724957, 2105758718, 1252702513, 1489722741, 1771588883, 2106786105, 1253313476, 1490449302, 1772452915, 2107813617, 
+1253924513, 1491175952, 1773317052, 2108841255, 1254535624, 1491902690, 1774181294, 2109869018, 1255146810, 1492629517, 1775045642, 2110896906, 1255758071, 1493356432, 1775910094, 2111924920, 
+1256369405, 1494083436, 1776774652, 2112953058, 1256980814, 1494810528, 1777639315, 2113981322, 1257592298, 1495537709, 1778504084, 2115009710, 1258203856, 1496264977, 1779368957, 2116038224, 
+1258815488, 1496992335, 1780233936, 2117066863, 1259427194, 1497719781, 1781099019, 2118095626, 1260038975, 1498447315, 1781964208, 2119124515, 1260650830, 1499174937, 1782829502, 2120153528, 
+1261262760, 1499902648, 1783694900, 2121182666, 1261874763, 1500630447, 1784560404, 2122211930, 1262486841, 1501358334, 1785426013, 2123241318, 1263098993, 1502086309, 1786291726, 2124270830, 
+1263711219, 1502814373, 1787157545, 2125300468, 1264323519, 1503542525, 1788023468, 2126330230, 1264935894, 1504270765, 1788889496, 2127360117, 1265548342, 1504999093, 1789755629, 2128390128, 
+1266160865, 1505727509, 1790621867, 2129420265, 1266773461, 1506456013, 1791488210, 2130450525, 1267386132, 1507184606, 1792354657, 2131480911, 1267998877, 1507913286, 1793221209, 2132511421, 
+1268611696, 1508642055, 1794087866, 2133542055, 1269224589, 1509370912, 1794954627, 2134572814, 1269837556, 1510099856, 1795821493, 2135603697, 1270450597, 1510828889, 1796688464, 2136634705, 
+1271063711, 1511558009, 1797555539, 2137665837, 1271676900, 1512287218, 1798422719, 2138697094, 1272290163, 1513016514, 1799290004, 2139728474, 1272903500, 1513745898, 1800157393, 2140759979, 
+1273516910, 1514475371, 1801024886, 2141791609, 1274130394, 1515204931, 1801892484, 2142823363, 1274743953, 1515934578, 1802760186, 2143855240, 1275357585, 1516664314, 1803627993, 2144887242, 
+1275971291, 1517394137, 1804495904, 2145919369, 1276585070, 1518124049, 1805363920, 2146951619, 1277198924, 1518854048, 1806232040, 1073991997, 1277812851, 1519584134, 1807100264, 1074508246, 
+1278426852, 1520314309, 1807968593, 1075024557, 1279040927, 1521044571, 1808837026, 1075540930, 1279655075, 1521774920, 1809705563, 1076057366, 1280269297, 1522505358, 1810574204, 1076573863, 
+1280883593, 1523235883, 1811442949, 1077090422, 1281497963, 1523966495, 1812311799, 1077607043, 1282112406, 1524697195, 1813180753, 1078123726, 1282726923, 1525427983, 1814049811, 1078640471, 
+1283341513, 1526158858, 1814918973, 1079157278, 1283956177, 1526889821, 1815788239, 1079674147, 1284570914, 1527620871, 1816657609, 1080191077, 1285185726, 1528352009, 1817527083, 1080708070, 
+1285800610, 1529083234, 1818396661, 1081225124, 1286415568, 1529814547, 1819266344, 1081742240, 1287030600, 1530545947, 1820136130, 1082259418, 1287645705, 1531277434, 1821006020, 1082776658, 
+1288260884, 1532009009, 1821876014, 1083293959, 1288876136, 1532740671, 1822746111, 1083811322, 1289491461, 1533472420, 1823616313, 1084328747, 1290106860, 1534204257, 1824486618, 1084846234, 
+1290722332, 1534936181, 1825357028, 1085363782, 1291337878, 1535668192, 1826227541, 1085881393, 1291953497, 1536400291, 1827098158, 1086399064, 1292569189, 1537132477, 1827968878, 1086916798, 
+1293184955, 1537864750, 1828839702, 1087434593, 1293800794, 1538597110, 1829710630, 1087952450, 1294416706, 1539329557, 1830581662, 1088470368, 1295032692, 1540062092, 1831452797, 1088988348, 
+1295648751, 1540794713, 1832324036, 1089506390, 1296264883, 1541527422, 1833195378, 1090024493, 1296881088, 1542260217, 1834066824, 1090542658, 1297497367, 1542993100, 1834938373, 1091060885, 
+1298113718, 1543726070, 1835810026, 1091579172, 1298730143, 1544459127, 1836681783, 1092097522, 1299346641, 1545192271, 1837553642, 1092615933, 1299963213, 1545925502, 1838425606, 1093134405, 
+1300579857, 1546658819, 1839297672, 1093652939, 1301196574, 1547392224, 1840169842, 1094171535, 1301813365, 1548125716, 1841042116, 1094690192, 1302430228, 1548859294, 1841914493, 1095208910, 
+1303047165, 1549592959, 1842786973, 1095727690, 1303664174, 1550326712, 1843659556, 1096246531, 1304281257, 1551060551, 1844532243, 1096765433, 1304898413, 1551794477, 1845405033, 1097284397, 
+1305515641, 1552528489, 1846277926, 1097803423, 1306132943, 1553262589, 1847150922, 1098322509, 1306750317, 1553996775, 1848024021, 1098841657, 1307367765, 1554731048, 1848897224, 1099360867, 
+1307985285, 1555465407, 1849770529, 1099880137, 1308602878, 1556199853, 1850643938, 1100399469, 1309220544, 1556934386, 1851517450, 1100918862, 1309838283, 1557669006, 1852391065, 1101438317, 
+1310456095, 1558403712, 1853264783, 1101957833, 1311073980, 1559138505, 1854138603, 1102477410, 1311691937, 1559873384, 1855012527, 1102997048, 1312309967, 1560608350, 1855886554, 1103516747, 
+1312928070, 1561343403, 1856760684, 1104036508, 1313546246, 1562078542, 1857634916, 1104556330, 1314164495, 1562813767, 1858509252, 1105076213, 1314782816, 1563549079, 1859383690, 1105596157, 
+1315401210, 1564284478, 1860258231, 1106116162, 1316019676, 1565019963, 1861132875, 1106636228, 1316638216, 1565755534, 1862007622, 1107156356, 1317256828, 1566491192, 1862882471, 1107676544, 
+1317875512, 1567226936, 1863757423, 1108196794, 1318494270, 1567962766, 1864632478, 1108717105, 1319113099, 1568698683, 1865507635, 1109237477, 1319732002, 1569434686, 1866382896, 1109757909, 
+1320350977, 1570170776, 1867258258, 1110278403, 1320970024, 1570906951, 1868133724, 1110798958, 1321589144, 1571643213, 1869009292, 1111319574, 1322208337, 1572379562, 1869884962, 1111840251, 
+1322827602, 1573115996, 1870760735, 1112360988, 1323446939, 1573852517, 1871636611, 1112881787, 1324066349, 1574589124, 1872512589, 1113402647, 1324685832, 1575325816, 1873388669, 1113923567, 
+1325305387, 1576062596, 1874264852, 1114444549, 1325925014, 1576799461, 1875141138, 1114965591, 1326544714, 1577536412, 1876017525, 1115486695, 1327164486, 1578273449, 1876894016, 1116007859, 
+1327784330, 1579010573, 1877770608, 1116529084, 1328404247, 1579747782, 1878647303, 1117050369, 1329024236, 1580485078, 1879524100, 1117571716, 1329644298, 1581222459, 1880400999, 1118093124, 
+1330264432, 1581959927, 1881278001, 1118614592, 1330884638, 1582697480, 1882155104, 1119136121, 1331504916, 1583435120, 1883032310, 1119657711, 1332125266, 1584172845, 1883909619, 1120179361, 
+1332745689, 1584910656, 1884787029, 1120701073, 1333366184, 1585648553, 1885664541, 1121222845, 1333986751, 1586386536, 1886542156, 1121744677, 1334607391, 1587124605, 1887419872, 1122266571, 
+1335228102, 1587862759, 1888297691, 1122788525, 1335848886, 1588601000, 1889175612, 1123310540, 1336469742, 1589339326, 1890053635, 1123832615, 1337090670, 1590077738, 1890931759, 1124354751, 
+1337711670, 1590816235, 1891809986, 1124876948, 1338332742, 1591554819, 1892688314, 1125399205, 1338953886, 1592293488, 1893566745, 1125921523, 1339575102, 1593032243, 1894445277, 1126443901, 
+1340196390, 1593771083, 1895323912, 1126966340, 1340817751, 1594510009, 1896202648, 1127488840, 1341439183, 1595249021, 1897081486, 1128011400, 1342060687, 1595988118, 1897960425, 1128534021, 
+1342682263, 1596727301, 1898839467, 1129056702, 1343303911, 1597466569, 1899718610, 1129579444, 1343925632, 1598205923, 1900597855, 1130102246, 1344547423, 1598945362, 1901477202, 1130625109, 
+1345169287, 1599684887, 1902356650, 1131148032, 1345791223, 1600424498, 1903236200, 1131671015, 1346413231, 1601164194, 1904115851, 1132194059, 1347035310, 1601903975, 1904995605, 1132717164, 
+1347657461, 1602643842, 1905875459, 1133240328, 1348279685, 1603383794, 1906755416, 1133763553, 1348901979, 1604123831, 1907635474, 1134286839, 1349524346, 1604863954, 1908515633, 1134810185, 
+1350146785, 1605604162, 1909395894, 1135333591, 1350769295, 1606344456, 1910276256, 1135857058, 1351391877, 1607084835, 1911156720, 1136380585, 1352014530, 1607825299, 1912037285, 1136904172, 
+1352637256, 1608565848, 1912917952, 1137427819, 1353260053, 1609306483, 1913798720, 1137951527, 1353882921, 1610047203, 1914679589, 1138475295, 1354505862, 1610788008, 1915560560, 1138999123, 
+1355128874, 1611528898, 1916441632, 1139523012, 1355751957, 1612269874, 1917322805, 1140046961, 1356375112, 1613010934, 1918204079, 1140570970, 1356998339, 1613752080, 1919085455, 1141095039, 
+1357621637, 1614493311, 1919966932, 1141619168, 1358245007, 1615234626, 1920848510, 1142143358, 1358868449, 1615976027, 1921730189, 1142667607, 1359491961, 1616717513, 1922611970, 1143191917, 
+1360115546, 1617459084, 1923493851, 1143716287, 1360739202, 1618200740, 1924375834, 1144240717, 1361362929, 1618942481, 1925257918, 1144765207, 1361986728, 1619684307, 1926140102, 1145289757, 
+1362610598, 1620426218, 1927022388, 1145814367, 1363234540, 1621168214, 1927904775, 1146339038, 1363858553, 1621910295, 1928787263, 1146863768, 1364482637, 1622652461, 1929669851, 1147388558, 
+1365106793, 1623394711, 1930552541, 1147913409, 1365731020, 1624137046, 1931435331, 1148438319, 1366355319, 1624879467, 1932318223, 1148963290, 1366979689, 1625621972, 1933201215, 1149488320, 
+1367604130, 1626364562, 1934084308, 1150013410, 1368228642, 1627107236, 1934967502, 1150538560, 1368853226, 1627849996, 1935850797, 1151063771, 1369477881, 1628592840, 1936734192, 1151589041, 
+1370102607, 1629335768, 1937617689, 1152114371, 1370727404, 1630078782, 1938501286, 1152639761, 1371352273, 1630821880, 1939384983, 1153165210, 1371977213, 1631565063, 1940268782, 1153690720, 
+1372602224, 1632308331, 1941152681, 1154216289, 1373227306, 1633051683, 1942036680, 1154741919, 1373852459, 1633795119, 1942920780, 1155267608, 1374477683, 1634538641, 1943804981, 1155793357, 
+1375102979, 1635282246, 1944689283, 1156319166, 1375728346, 1636025937, 1945573684, 1156845034, 1376353783, 1636769712, 1946458187, 1157370962, 1376979292, 1637513571, 1947342790, 1157896951, 
+1377604872, 1638257515, 1948227493, 1158422998, 1378230523, 1639001544, 1949112297, 1158949106, 1378856244, 1639745656, 1949997201, 1159475273, 1379482037, 1640489854, 1950882206, 1160001500, 
+1380107901, 1641234135, 1951767311, 1160527787, 1380733836, 1641978501, 1952652517, 1161054133, 1381359841, 1642722952, 1953537822, 1161580539, 1381985918, 1643467487, 1954423228, 1162107004, 
+1382612066, 1644212106, 1955308735, 1162633530, 1383238284, 1644956809, 1956194341, 1163160115, 1383864573, 1645701597, 1957080048, 1163686759, 1384490934, 1646446469, 1957965855, 1164213463, 
+1385117365, 1647191425, 1958851763, 1164740227, 1385743867, 1647936466, 1959737770, 1165267050, 1386370439, 1648681590, 1960623878, 1165793933, 1386997083, 1649426799, 1961510085, 1166320875, 
+1387623797, 1650172092, 1962396393, 1166847877, 1388250582, 1650917470, 1963282801, 1167374938, 1388877438, 1651662931, 1964169309, 1167902059, 1389504364, 1652408477, 1965055917, 1168429239, 
+1390131362, 1653154106, 1965942625, 1168956479, 1390758430, 1653899820, 1966829433, 1169483778, 1391385568, 1654645618, 1967716341, 1170011137, 1392012778, 1655391500, 1968603349, 1170538555, 
+1392640058, 1656137465, 1969490457, 1171066032, 1393267408, 1656883515, 1970377665, 1171593569, 1393894830, 1657629649, 1971264973, 1172121166, 1394522322, 1658375867, 1972152380, 1172648821, 
+1395149884, 1659122169, 1973039888, 1173176536, 1395777517, 1659868554, 1973927495, 1173704311, 1396405221, 1660615024, 1974815202, 1174232144, 1397032995, 1661361578, 1975703009, 1174760038, 
+1397660840, 1662108215, 1976590915, 1175287990, 1398288755, 1662854936, 1977478921, 1175816002, 1398916741, 1663601741, 1978367027, 1176344073, 1399544797, 1664348630, 1979255233, 1176872203, 
+1400172924, 1665095603, 1980143538, 1177400392, 1400801121, 1665842660, 1981031943, 1177928641, 1401429388, 1666589800, 1981920448, 1178456949, 1402057726, 1667337024, 1982809052, 1178985316, 
+1402686135, 1668084332, 1983697756, 1179513742, 1403314614, 1668831723, 1984586559, 1180042228, 1403943163, 1669579198, 1985475462, 1180570773, 1404571782, 1670326757, 1986364464, 1181099377, 
+1405200472, 1671074400, 1987253566, 1181628040, 1405829232, 1671822126, 1988142767, 1182156762, 1406458063, 1672569935, 1989032068, 1182685543, 1407086964, 1673317829, 1989921468, 1183214384, 
+1407715935, 1674065806, 1990810967, 1183743283, 1408344976, 1674813866, 1991700566, 1184272242, 1408974088, 1675562010, 1992590264, 1184801260, 1409603270, 1676310238, 1993480061, 1185330336, 
+1410232522, 1677058549, 1994369958, 1185859472, 1410861844, 1677806943, 1995259954, 1186388667, 1411491236, 1678555421, 1996150050, 1186917921, 1412120699, 1679303982, 1997040244, 1187447234, 
+1412750232, 1680052627, 1997930538, 1187976606, 1413379835, 1680801356, 1998820931, 1188506036, 1414009508, 1681550167, 1999711423, 1189035526, 1414639251, 1682299062, 2000602014, 1189565075, 
+1415269064, 1683048041, 2001492705, 1190094683, 1415898947, 1683797102, 2002383494, 1190624349, 1416528901, 1684546247, 2003274383, 1191154075, 1417158924, 1685295476, 2004165371, 1191683859, 
+1417789018, 1686044787, 2005056457, 1192213702, 1418419181, 1686794182, 2005947643, 1192743605, 1419049415, 1687543660, 2006838928, 1193273566, 1419679718, 1688293222, 2007730311, 1193803586, 
+1420310091, 1689042866, 2008621794, 1194333664, 1420940535, 1689792594, 2009513376, 1194863802, 1421571048, 1690542405, 2010405056, 1195393998, 1422201631, 1691292299, 2011296835, 1195924253, 
+1422832284, 1692042276, 2012188714, 1196454567, 1423463007, 1692792336, 2013080691, 1196984940, 1424093800, 1693542480, 2013972766, 1197515372, 1424724663, 1694292706, 2014864941, 1198045862, 
+1425355596, 1695043016, 2015757214, 1198576411, 1425986598, 1695793408, 2016649587, 1199107018, 1426617670, 1696543884, 2017542058, 1199637685, 1427248812, 1697294442, 2018434627, 1200168410, 
+1427880024, 1698045084, 2019327295, 1200699194, 1428511306, 1698795809, 2020220062, 1201230036, 1429142657, 1699546616, 2021112928, 1201760937, 1429774078, 1700297506, 2022005892, 1202291897, 
+1430405569, 1701048480, 2022898955, 1202822915, 1431037129, 1701799536, 2023792117, 1203353992, 1431668759, 1702550675, 2024685376, 1203885128, 1432300459, 1703301897, 2025578735, 1204416322, 
+1432932229, 1704053202, 2026472192, 1204947575, 1433564068, 1704804589, 2027365747, 1205478886, 1434195977, 1705556060, 2028259401, 1206010256, 1434827955, 1706307613, 2029153154, 1206541684, 
+1435460003, 1707059249, 2030047005, 1207073171, 1436092121, 1707810968, 2030940954, 1207604716, 1436724308, 1708562769, 2031835002, 1208136320, 1437356565, 1709314653, 2032729148, 1208667983, 
+1437988891, 1710066620, 2033623392, 1209199703, 1438621287, 1710818670, 2034517735, 1209731483, 1439253752, 1711570802, 2035412175, 1210263321, 1439886287, 1712323017, 2036306715, 1210795217, 
+1440518891, 1713075314, 2037201352, 1211327171, 1441151564, 1713827694, 2038096088, 1211859184, 1441784308, 1714580157, 2038990922, 1212391256, 1442417120, 1715332702, 2039885854, 1212923386, 
+1443050002, 1716085330, 2040780884, 1213455574, 1443682953, 1716838040, 2041676012, 1213987820, 1444315974, 1717590833, 2042571239, 1214520125, 1444949064, 1718343708, 2043466564, 1215052488, 
+1445582224, 1719096666, 2044361986, 1215584910, 1446215453, 1719849706, 2045257507, 1216117390, 1446848751, 1720602829, 2046153126, 1216649928, 1447482118, 1721356034, 2047048843, 1217182524, 
+1448115555, 1722109321, 2047944658, 1217715179, 1448749061, 1722862691, 2048840570, 1218247892, 1449382636, 1723616143, 2049736581, 1218780663, 1450016281, 1724369678, 2050632690, 1219313492, 
+1450649994, 1725123295, 2051528896, 1219846380, 1451283777, 1725876994, 2052425201, 1220379326, 1451917630, 1726630775, 2053321603, 1220912330, 1452551551, 1727384639, 2054218103, 1221445392, 
+1453185541, 1728138585, 2055114701, 1221978512, 1453819601, 1728892614, 2056011397, 1222511691, 1454453730, 1729646724, 2056908191, 1223044928, 1455087928, 1730400917, 2057805082, 1223578222, 
+1455722195, 1731155192, 2058702071, 1224111575, 1456356531, 1731909549, 2059599158, 1224644986, 1456990936, 1732663988, 2060496342, 1225178455, 1457625411, 1733418509, 2061393625, 1225711983, 
+1458259954, 1734173113, 2062291004, 1226245568, 1458894566, 1734927798, 2063188482, 1226779211, 1459529248, 1735682566, 2064086057, 1227312912, 1460163998, 1736437416, 2064983730, 1227846672, 
+1460798818, 1737192347, 2065881500, 1228380489, 1461433706, 1737947361, 2066779368, 1228914364, 1462068663, 1738702457, 2067677333, 1229448298, 1462703690, 1739457635, 2068575396, 1229982289, 
+1463338785, 1740212895, 2069473556, 1230516338, 1463973949, 1740968236, 2070371814, 1231050446, 1464609182, 1741723660, 2071270169, 1231584611, 1465244484, 1742479166, 2072168621, 1232118834, 
+1465879855, 1743234753, 2073067171, 1232653115, 1466515294, 1743990422, 2073965819, 1233187454, 1467150803, 1744746174, 2074864563, 1233721851, 1467786380, 1745502007, 2075763406, 1234256305, 
+1468422026, 1746257922, 2076662345, 1234790818, 1469057741, 1747013918, 2077561382, 1235325388, 1469693525, 1747769997, 2078460516, 1235860017, 1470329377, 1748526157, 2079359747, 1236394703, 
+1470965299, 1749282399, 2080259075, 1236929447, 1471601289, 1750038723, 2081158501, 1237464248, 1472237347, 1750795128, 2082058024, 1237999108, 1472873475, 1751551616, 2082957644, 1238534025, 
+1473509671, 1752308185, 2083857361, 1239069000, 1474145936, 1753064835, 2084757175, 1239604033, 1474782269, 1753821567, 2085657086, 1240139123, 1475418671, 1754578381, 2086557095, 1240674271, 
+1476055142, 1755335277, 2087457200, 1241209477, 1476691681, 1756092254, 2088357403, 1241744741, 1477328289, 1756849312, 2089257702, 1242280062, 1477964966, 1757606453, 2090158099, 1242815441, 
+1478601711, 1758363675, 2091058593, 1243350878, 1479238524, 1759120978, 2091959183, 1243886372, 1479875406, 1759878363, 2092859870, 1244421924, 1480512357, 1760635829, 2093760655, 1244957534, 
+1481149376, 1761393377, 2094661536, 1245493201, 1481786464, 1762151006, 2095562514, 1246028926, 1482423620, 1762908717, 2096463589, 1246564708, 1483060845, 1763666509, 2097364761, 1247100548, 
+1483698138, 1764424383, 2098266030, 1247636446, 1484335500, 1765182338, 2099167395, 1248172401, 1484972930, 1765940374, 2100068857, 1248708414, 1485610428, 1766698491, 2100970416, 1249244484, 
+1486247995, 1767456691, 2101872072, 1249780611, 1486885630, 1768214971, 2102773824, 1250316796, 1487523334, 1768973332, 2103675673, 1250853039, 1488161106, 1769731775, 2104577619, 1251389339, 
+1488798946, 1770490300, 2105479661, 1251925697, 1489436855, 1771248905, 2106381800, 1252462112, 1490074832, 1772007592, 2107284036, 1252998584, 1490712877, 1772766360, 2108186368, 1253535114, 
+1491350990, 1773525209, 2109088797, 1254071702, 1491989172, 1774284139, 2109991322, 1254608346, 1492627422, 1775043150, 2110893944, 1255145049, 1493265740, 1775802243, 2111796662, 1255681808, 
+1493904127, 1776561417, 2112699477, 1256218625, 1494542582, 1777320672, 2113602388, 1256755499, 1495181104, 1778080008, 2114505396, 1257292431, 1495819695, 1778839425, 2115408500, 1257829420, 
+1496458355, 1779598923, 2116311701, 1258366466, 1497097082, 1780358502, 2117214998, 1258903570, 1497735877, 1781118162, 2118118391, 1259440730, 1498374741, 1781877903, 2119021880, 1259977948, 
+1499013673, 1782637725, 2119925466, 1260515224, 1499652673, 1783397628, 2120829148, 1261052556, 1500291740, 1784157612, 2121732927, 1261589946, 1500930876, 1784917677, 2122636802, 1262127394, 
+1501570080, 1785677823, 2123540773, 1262664898, 1502209352, 1786438050, 2124444840, 1263202459, 1502848692, 1787198358, 2125349003, 1263740078, 1503488100, 1787958746, 2126253263, 1264277754, 
+1504127577, 1788719216, 2127157618, 1264815487, 1504767121, 1789479766, 2128062070, 1265353277, 1505406733, 1790240397, 2128966618, 1265891125, 1506046412, 1791001109, 2129871262, 1266429029, 
+1506686160, 1791761902, 2130776002, 1266966991, 1507325976, 1792522775, 2131680838, 1267505010, 1507965860, 1793283730, 2132585770, 1268043086, 1508605811, 1794044764, 2133490799, 1268581219, 
+1509245831, 1794805880, 2134395923, 1269119409, 1509885918, 1795567077, 2135301143, 1269657656, 1510526073, 1796328354, 2136206459, 1270195960, 1511166296, 1797089711, 2137111871, 1270734321, 
+1511806587, 1797851150, 2138017379, 1271272739, 1512446945, 1798612669, 2138922983, 1271811215, 1513087372, 1799374268, 2139828682, 1272349747, 1513727866, 1800135948, 2140734478, 1272888336, 
+1514368428, 1800897709, 2141640369, 1273426982, 1515009058, 1801659551, 2142546356, 1273965686, 1515649755, 1802421472, 2143452439, 1274504446, 1516290520, 1803183475, 2144358618, 1275043263, 
+1516931353, 1803945558, 2145264892, 1275582137, 1517572253, 1804707721, 2146171263, 1276121068, 1518213221, 1805469965, 2147077728, 1276660056, 1518854257, 1806232289, 1073992145, 1277199100, 
+1519495361, 1806994694, 1074445474, 1277738202, 1520136532, 1807757179, 1074898850, 1278277360, 1520777771, 1808519745, 1075352274, 1278816576, 1521419077, 1809282391, 1075805746, 1279355848, 
+1522060451, 1810045118, 1076259266, 1279895177, 1522701892, 1810807924, 1076712834, 1280434563, 1523343401, 1811570811, 1077166449, 1280974005, 1523984978, 1812333779, 1077620112, 1281513505, 
+1524626622, 1813096827, 1078073823, 1282053061, 1525268334, 1813859955, 1078527582, 1282592674, 1525910113, 1814623163, 1078981388, 1283132344, 1526551959, 1815386451, 1079435242, 1283672070, 
+1527193873, 1816149820, 1079889144, 1284211854, 1527835855, 1816913269, 1080343094, 1284751694, 1528477904, 1817676799, 1080797091, 1285291590, 1529120020, 1818440408, 1081251136, 1285831544, 
+1529762204, 1819204098, 1081705228, 1286371554, 1530404456, 1819967867, 1082159368, 1286911621, 1531046774, 1820731717, 1082613556, 1287451744, 1531689160, 1821495647, 1083067792, 1287991924, 
+1532331614, 1822259657, 1083522075, 1288532161, 1532974134, 1823023748, 1083976406, 1289072454, 1533616722, 1823787918, 1084430784, 1289612804, 1534259378, 1824552168, 1084885210, 1290153211, 
+1534902100, 1825316499, 1085339684, 1290693674, 1535544890, 1826080909, 1085794205, 1291234194, 1536187748, 1826845399, 1086248773, 1291774770, 1536830672, 1827609970, 1086703390, 1292315403, 
+1537473664, 1828374620, 1087158054, 1292856092, 1538116723, 1829139350, 1087612765, 1293396838, 1538759849, 1829904161, 1088067524, 1293937641, 1539403042, 1830669051, 1088522330, 1294478500, 
+1540046303, 1831434021, 1088977184, 1295019416, 1540689631, 1832199071, 1089432086, 1295560388, 1541333026, 1832964201, 1089887035, 1296101416, 1541976488, 1833729411, 1090342031, 1296642501, 
+1542620017, 1834494700, 1090797075, 1297183642, 1543263613, 1835260069, 1091252166, 1297724840, 1543907277, 1836025519, 1091707305, 1298266095, 1544551007, 1836791048, 1092162491, 1298807405, 
+1545194805, 1837556656, 1092617725, 1299348772, 1545838670, 1838322345, 1093073006, 1299890196, 1546482602, 1839088113, 1093528335, 1300431676, 1547126600, 1839853961, 1093983710, 1300973212, 
+1547770666, 1840619889, 1094439134, 1301514805, 1548414799, 1841385896, 1094894604, 1302056454, 1549058999, 1842151983, 1095350122, 1302598159, 1549703266, 1842918150, 1095805688, 1303139921, 
+1550347599, 1843684396, 1096261301, 1303681739, 1550992000, 1844450722, 1096716961, 1304223613, 1551636468, 1845217127, 1097172668, 1304765543, 1552281002, 1845983612, 1097628423, 1305307530, 
+1552925604, 1846750177, 1098084225, 1305849573, 1553570272, 1847516821, 1098540075, 1306391673, 1554215008, 1848283545, 1098995971, 1306933828, 1554859810, 1849050348, 1099451915, 1307476040, 
+1555504679, 1849817231, 1099907906, 1308018308, 1556149615, 1850584194, 1100363945, 1308560632, 1556794617, 1851351235, 1100820031, 1309103013, 1557439687, 1852118357, 1101276164, 1309645450, 
+1558084823, 1852885557, 1101732344, 1310187942, 1558730026, 1853652837, 1102188572, 1310730491, 1559375296, 1854420197, 1102644846, 1311273096, 1560020633, 1855187636, 1103101168, 1311815758, 
+1560666036, 1855955154, 1103557537, 1312358475, 1561311506, 1856722752, 1104013953, 1312901249, 1561957043, 1857490429, 1104470417, 1313444078, 1562602646, 1858258185, 1104926928, 1313986964, 
+1563248317, 1859026021, 1105383485, 1314529906, 1563894054, 1859793936, 1105840090, 1315072903, 1564539857, 1860561930, 1106296742, 1315615957, 1565185727, 1861330003, 1106753442, 1316159067, 
+1565831664, 1862098156, 1107210188, 1316702233, 1566477668, 1862866388, 1107666981, 1317245455, 1567123738, 1863634699, 1108123822, 1317788733, 1567769874, 1864403089, 1108580710, 1318332067, 
+1568416078, 1865171559, 1109037644, 1318875457, 1569062347, 1865940107, 1109494626, 1319418903, 1569708684, 1866708735, 1109951655, 1319962405, 1570355087, 1867477442, 1110408731, 1320505963, 
+1571001556, 1868246228, 1110865854, 1321049577, 1571648092, 1869015093, 1111323024, 1321593247, 1572294695, 1869784038, 1111780241, 1322136972, 1572941364, 1870553061, 1112237505, 1322680754, 
+1573588099, 1871322163, 1112694816, 1323224591, 1574234901, 1872091345, 1113152174, 1323768485, 1574881769, 1872860605, 1113609578, 1324312434, 1575528704, 1873629944, 1114067030, 1324856439, 
+1576175705, 1874399363, 1114524529, 1325400500, 1576822773, 1875168860, 1114982075, 1325944617, 1577469907, 1875938437, 1115439668, 1326488790, 1578117107, 1876708092, 1115897308, 1327033018, 
+1578764374, 1877477826, 1116354994, 1327577302, 1579411707, 1878247639, 1116812728, 1328121642, 1580059106, 1879017531, 1117270508, 1328666038, 1580706572, 1879787502, 1117728336, 1329210490, 
+1581354104, 1880557551, 1118186210, 1329754997, 1582001702, 1881327680, 1118644131, 1330299560, 1582649367, 1882097887, 1119102099, 1330844179, 1583297097, 1882868173, 1119560114, 1331388853, 
+1583944894, 1883638538, 1120018176, 1331933584, 1584592758, 1884408982, 1120476284, 1332478370, 1585240687, 1885179504, 1120934440, 1333023211, 1585888683, 1885950106, 1121392642, 1333568109, 
+1586536745, 1886720786, 1121850891, 1334113062, 1587184873, 1887491544, 1122309187, 1334658070, 1587833068, 1888262381, 1122767530, 1335203135, 1588481328, 1889033297, 1123225919, 1335748255, 
+1589129655, 1889804292, 1123684355, 1336293430, 1589778048, 1890575365, 1124142838, 1336838661, 1590426506, 1891346517, 1124601368, 1337383948, 1591075031, 1892117748, 1125059944, 1337929290, 
+1591723623, 1892889057, 1125518567, 1338474688, 1592372280, 1893660445, 1125977237, 1339020142, 1593021003, 1894431911, 1126435954, 1339565651, 1593669792, 1895203456, 1126894717, 1340111215, 
+1594318648, 1895975079, 1127353527, 1340656835, 1594967569, 1896746781, 1127812384, 1341202511, 1595616556, 1897518562, 1128271287, 1341748242, 1596265610, 1898290420, 1128730237, 1342294029, 
+1596914729, 1899062358, 1129189234, 1342839871, 1597563914, 1899834374, 1129648277, 1343385769, 1598213166, 1900606468, 1130107367, 1343931722, 1598862483, 1901378640, 1130566504, 1344477730, 
+1599511866, 1902150891, 1131025687, 1345023794, 1600161315, 1902923221, 1131484917, 1345569914, 1600810830, 1903695629, 1131944193, 1346116088, 1601460411, 1904468115, 1132403516, 1346662319, 
+1602110058, 1905240679, 1132862886, 1347208604, 1602759770, 1906013322, 1133322302, 1347754945, 1603409549, 1906786043, 1133781765, 1348301342, 1604059393, 1907558843, 1134241274, 1348847793, 
+1604709303, 1908331721, 1134700830, 1349394300, 1605359279, 1909104677, 1135160432, 1349940863, 1606009321, 1909877711, 1135620081, 1350487481, 1606659428, 1910650823, 1136079777, 1351034154, 
+1607309601, 1911424014, 1136539519, 1351580882, 1607959840, 1912197283, 1136999307, 1352127666, 1608610145, 1912970630, 1137459142, 1352674505, 1609260516, 1913744055, 1137919023, 1353221399, 
+1609910952, 1914517558, 1138378951, 1353768348, 1610561454, 1915291140, 1138838925, 1354315353, 1611212021, 1916064800, 1139298946, 1354862413, 1611862655, 1916838537, 1139759013, 1355409528, 
+1612513354, 1917612353, 1140219127, 1355956699, 1613164118, 1918386247, 1140679287, 1356503924, 1613814948, 1919160219, 1141139494, 1357051205, 1614465844, 1919934269, 1141599747, 1357598541, 
+1615116806, 1920708397, 1142060046, 1358145932, 1615767833, 1921482603, 1142520391, 1358693379, 1616418926, 1922256887, 1142980783, 1359240880, 1617070084, 1923031249, 1143441222, 1359788437, 
+1617721308, 1923805689, 1143901707, 1360336048, 1618372597, 1924580207, 1144362238, 1360883715, 1619023952, 1925354803, 1144822815, 1361431437, 1619675372, 1926129477, 1145283439, 1361979214, 
+1620326858, 1926904228, 1145744109, 1362527046, 1620978409, 1927679058, 1146204825, 1363074934, 1621630026, 1928453965, 1146665588, 1363622876, 1622281709, 1929228950, 1147126397, 1364170873, 
+1622933456, 1930004014, 1147587252, 1364718926, 1623585270, 1930779154, 1148048154, 1365267033, 1624237148, 1931554373, 1148509102, 1365815196, 1624889092, 1932329670, 1148970096, 1366363413, 
+1625541102, 1933105044, 1149431136, 1366911685, 1626193177, 1933880496, 1149892223, 1367460013, 1626845317, 1934656026, 1150353356, 1368008395, 1627497522, 1935431633, 1150814535, 1368556832, 
+1628149793, 1936207319, 1151275760, 1369105325, 1628802130, 1936983082, 1151737031, 1369653872, 1629454531, 1937758922, 1152198349, 1370202474, 1630106998, 1938534840, 1152659712, 1370751131, 
+1630759530, 1939310836, 1153121122, 1371299843, 1631412128, 1940086910, 1153582579, 1371848610, 1632064791, 1940863061, 1154044081, 1372397432, 1632717519, 1941639290, 1154505629, 1372946309, 
+1633370312, 1942415596, 1154967224, 1373495240, 1634023170, 1943191980, 1155428864, 1374044226, 1634676094, 1943968442, 1155890551, 1374593268, 1635329083, 1944744981, 1156352284, 1375142364, 
+1635982137, 1945521597, 1156814063, 1375691514, 1636635256, 1946298291, 1157275888, 1376240720, 1637288441, 1947075063, 1157737759, 1376789981, 1637941690, 1947851912, 1158199676, 1377339296, 
+1638595005, 1948628839, 1158661640, 1377888666, 1639248385, 1949405843, 1159123649, 1378438091, 1639901830, 1950182924, 1159585704, 1378987570, 1640555340, 1950960083, 1160047806, 1379537104, 
+1641208915, 1951737319, 1160509953, 1380086693, 1641862555, 1952514633, 1160972147, 1380636337, 1642516261, 1953292024, 1161434386, 1381186036, 1643170031, 1954069492, 1161896671, 1381735789, 
+1643823866, 1954847038, 1162359003, 1382285596, 1644477767, 1955624661, 1162821380, 1382835459, 1645131732, 1956402361, 1163283804, 1383385376, 1645785762, 1957180139, 1163746273, 1383935348, 
+1646439858, 1957957993, 1164208788, 1384485374, 1647094018, 1958735926, 1164671350, 1385035456, 1647748244, 1959513935, 1165133957, 1385585591, 1648402534, 1960292022, 1165596610, 1386135782, 
+1649056889, 1961070185, 1166059309, 1386686026, 1649711309, 1961848426, 1166522054, 1387236326, 1650365794, 1962626745, 1166984844, 1387786680, 1651020344, 1963405140, 1167447681, 1388337089, 
+1651674959, 1964183613, 1167910564, 1388887552, 1652329638, 1964962162, 1168373492, 1389438070, 1652984383, 1965740789, 1168836466, 1389988642, 1653639192, 1966519493, 1169299487, 1390539269, 
+1654294067, 1967298274, 1169762553, 1391089950, 1654949006, 1968077132, 1170225664, 1391640686, 1655604009, 1968856068, 1170688822, 1392191477, 1656259078, 1969635080, 1171152025, 1392742321, 
+1656914211, 1970414169, 1171615275, 1393293221, 1657569409, 1971193335, 1172078570, 1393844174, 1658224672, 1971972579, 1172541911, 1394395183, 1658880000, 1972751899, 1173005297, 1394946245, 
+1659535392, 1973531296, 1173468730, 1395497362, 1660190849, 1974310770, 1173932208, 1396048534, 1660846371, 1975090322, 1174395732, 1396599760, 1661501958, 1975869950, 1174859301, 1397151040, 
+1662157609, 1976649655, 1175322917, 1397702375, 1662813325, 1977429437, 1175786578, 1398253764, 1663469105, 1978209295, 1176250284, 1398805207, 1664124950, 1978989231, 1176714037, 1399356705, 
+1664780860, 1979769243, 1177177835, 1399908257, 1665436834, 1980549333, 1177641679, 1400459864, 1666092873, 1981329499, 1178105569, 1401011525, 1666748977, 1982109742, 1178569504, 1401563240, 
+1667405145, 1982890062, 1179033485, 1402115009, 1668061377, 1983670458, 1179497511, 1402666833, 1668717675, 1984450932, 1179961584, 1403218711, 1669374036, 1985231482, 1180425701, 1403770643, 
+1670030463, 1986012108, 1180889865, 1404322629, 1670686953, 1986792812, 1181354074, 1404874670, 1671343509, 1987573592, 1181818329, 1405426765, 1672000128, 1988354449, 1182282629, 1405978914, 
+1672656813, 1989135383, 1182746975, 1406531118, 1673313561, 1989916393, 1183211366, 1407083375, 1673970374, 1990697480, 1183675803, 1407635687, 1674627252, 1991478643, 1184140286, 1408188053, 
+1675284194, 1992259883, 1184604814, 1408740473, 1675941200, 1993041200, 1185069388, 1409292948, 1676598271, 1993822593, 1185534007, 1409845476, 1677255406, 1994604063, 1185998672, 1410398059, 
+1677912606, 1995385609, 1186463382, 1410950695, 1678569870, 1996167232, 1186928138, 1411503386, 1679227198, 1996948932, 1187392939, 1412056131, 1679884591, 1997730708, 1187857786, 1412608930, 
+1680542048, 1998512560, 1188322678, 1413161783, 1681199569, 1999294489, 1188787616, 1413714691, 1681857154, 2000076494, 1189252599, 1414267652, 1682514804, 2000858576, 1189717627, 1414820667, 
+1683172518, 2001640734, 1190182701, 1415373737, 1683830296, 2002422969, 1190647821, 1415926860, 1684488139, 2003205280, 1191112986, 1416480038, 1685146046, 2003987668, 1191578196, 1417033269, 
+1685804017, 2004770131, 1192043452, 1417586555, 1686462052, 2005552672, 1192508753, 1418139894, 1687120152, 2006335288, 1192974100, 1418693287, 1687778315, 2007117981, 1193439492, 1419246735, 
+1688436543, 2007900750, 1193904929, 1419800236, 1689094835, 2008683595, 1194370412, 1420353792, 1689753191, 2009466517, 1194835940, 1420907401, 1690411611, 2010249515, 1195301513, 1421461064, 
+1691070095, 2011032589, 1195767132, 1422014781, 1691728644, 2011815740, 1196232796, 1422568552, 1692387256, 2012598967, 1196698505, 1423122377, 1693045933, 2013382270, 1197164260, 1423676256, 
+1693704674, 2014165649, 1197630060, 1424230189, 1694363479, 2014949104, 1198095905, 1424784175, 1695022347, 2015732636, 1198561796, 1425338216, 1695681280, 2016516243, 1199027732, 1425892310, 
+1696340277, 2017299927, 1199493713, 1426446458, 1696999338, 2018083687, 1199959739, 1427000660, 1697658463, 2018867523, 1200425811, 1427554916, 1698317652, 2019651435, 1200891928, 1428109225, 
+1698976904, 2020435423, 1201358090, 1428663588, 1699636221, 2021219487, 1201824298, 1429218006, 1700295602, 2022003627, 1202290550, 1429772476, 1700955046, 2022787844, 1202756848, 1430327001, 
+1701614555, 2023572136, 1203223191, 1430881579, 1702274128, 2024356504, 1203689579, 1431436212, 1702933764, 2025140948, 1204156012, 1431990897, 1703593464, 2025925469, 1204622491, 1432545637, 
+1704253228, 2026710065, 1205089015, 1433100430, 1704913056, 2027494737, 1205555583, 1433655277, 1705572948, 2028279485, 1206022197, 1434210178, 1706232904, 2029064309, 1206488857, 1434765132, 
+1706892923, 2029849209, 1206955561, 1435320140, 1707553007, 2030634185, 1207422310, 1435875202, 1708213154, 2031419236, 1207889105, 1436430317, 1708873365, 2032204364, 1208355944, 1436985486, 
+1709533639, 2032989567, 1208822829, 1437540709, 1710193978, 2033774846, 1209289759, 1438095985, 1710854380, 2034560201, 1209756734, 1438651315, 1711514846, 2035345632, 1210223754, 1439206698, 
+1712175375, 2036131139, 1210690818, 1439762135, 1712835969, 2036916721, 1211157929, 1440317626, 1713496626, 2037702379, 1211625084, 1440873170, 1714157346, 2038488113, 1212092284, 1441428768, 
+1714818131, 2039273922, 1212559529, 1441984419, 1715478979, 2040059807, 1213026819, 1442540124, 1716139891, 2040845768, 1213494154, 1443095882, 1716800866, 2041631805, 1213961534, 1443651694, 
+1717461905, 2042417917, 1214428959, 1444207559, 1718123008, 2043204105, 1214896430, 1444763478, 1718784174, 2043990369, 1215363945, 1445319450, 1719445404, 2044776708, 1215831505, 1445875476, 
+1720106697, 2045563123, 1216299110, 1446431555, 1720768054, 2046349613, 1216766760, 1446987688, 1721429474, 2047136179, 1217234455, 1447543874, 1722090958, 2047922820, 1217702194, 1448100114, 
+1722752506, 2048709537, 1218169979, 1448656407, 1723414117, 2049496330, 1218637809, 1449212753, 1724075791, 2050283198, 1219105683, 1449769153, 1724737530, 2051070142, 1219573603, 1450325606, 
+1725399331, 2051857161, 1220041567, 1450882112, 1726061196, 2052644255, 1220509576, 1451438672, 1726723125, 2053431425, 1220977631, 1451995286, 1727385116, 2054218671, 1221445730, 1452551952, 
+1728047172, 2055005992, 1221913873, 1453108672, 1728709290, 2055793388, 1222382062, 1453665445, 1729371473, 2056580860, 1222850296, 1454222272, 1730033718, 2057368407, 1223318574, 1454779152, 
+1730696027, 2058156029, 1223786897, 1455336085, 1731358399, 2058943727, 1224255265, 1455893072, 1732020835, 2059731500, 1224723678, 1456450111, 1732683334, 2060519349, 1225192135, 1457007204, 
+1733345896, 2061307273, 1225660637, 1457564351, 1734008522, 2062095272, 1226129185, 1458121550, 1734671211, 2062883346, 1226597776, 1458678803, 1735333963, 2063671496, 1227066413, 1459236109, 
+1735996779, 2064459721, 1227535094, 1459793468, 1736659658, 2065248021, 1228003821, 1460350881, 1737322600, 2066036397, 1228472591, 1460908346, 1737985605, 2066824847, 1228941407, 1461465865, 
+1738648674, 2067613373, 1229410267, 1462023437, 1739311805, 2068401974, 1229879172, 1462581062, 1739975000, 2069190650, 1230348122, 1463138740, 1740638259, 2069979402, 1230817116, 1463696472, 
+1741301580, 2070768228, 1231286155, 1464254257, 1741964965, 2071557130, 1231755239, 1464812094, 1742628412, 2072346107, 1232224367, 1465369985, 1743291923, 2073135159, 1232693540, 1465927929, 
+1743955497, 2073924286, 1233162758, 1466485926, 1744619134, 2074713488, 1233632021, 1467043976, 1745282835, 2075502765, 1234101327, 1467602079, 1745946598, 2076292117, 1234570679, 1468160236, 
+1746610425, 2077081544, 1235040075, 1468718445, 1747274314, 2077871046, 1235509516, 1469276707, 1747938267, 2078660623, 1235979001, 1469835023, 1748602282, 2079450275, 1236448531, 1470393391, 
+1749266361, 2080240003, 1236918106, 1470951812, 1749930503, 2081029805, 1237387725, 1471510287, 1750594708, 2081819682, 1237857389, 1472068814, 1751258975, 2082609634, 1238327097, 1472627395, 
+1751923306, 2083399661, 1238796850, 1473186028, 1752587700, 2084189762, 1239266647, 1473744714, 1753252157, 2084979939, 1239736489, 1474303454, 1753916676, 2085770191, 1240206375, 1474862246, 
+1754581259, 2086560517, 1240676306, 1475421091, 1755245905, 2087350918, 1241146282, 1475979989, 1755910613, 2088141394, 1241616302, 1476538940, 1756575384, 2088931945, 1242086366, 1477097944, 
+1757240219, 2089722571, 1242556475, 1477657001, 1757905116, 2090513271, 1243026628, 1478216110, 1758570076, 2091304047, 1243496826, 1478775273, 1759235099, 2092094897, 1243967068, 1479334488, 
+1759900185, 2092885822, 1244437355, 1479893757, 1760565333, 2093676821, 1244907686, 1480453078, 1761230545, 2094467895, 1245378062, 1481012452, 1761895819, 2095259044, 1245848482, 1481571878, 
+1762561156, 2096050268, 1246318946, 1482131358, 1763226556, 2096841566, 1246789455, 1482690890, 1763892019, 2097632939, 1247260008, 1483250476, 1764557544, 2098424387, 1247730605, 1483810114, 
+1765223133, 2099215909, 1248201247, 1484369804, 1765888784, 2100007506, 1248671934, 1484929548, 1766554497, 2100799177, 1249142664, 1485489344, 1767220274, 2101590923, 1249613439, 1486049193, 
+1767886113, 2102382744, 1250084259, 1486609095, 1768552015, 2103174639, 1250555122, 1487169049, 1769217979, 2103966609, 1251026030, 1487729056, 1769884006, 2104758653, 1251496983, 1488289116, 
+1770550096, 2105550772, 1251967979, 1488849229, 1771216249, 2106342965, 1252439020, 1489409394, 1771882464, 2107135233, 1252910106, 1489969612, 1772548742, 2107927575, 1253381235, 1490529883, 
+1773215082, 2108719992, 1253852409, 1491090206, 1773881485, 2109512483, 1254323627, 1491650582, 1774547951, 2110305049, 1254794889, 1492211010, 1775214479, 2111097689, 1255266196, 1492771491, 
+1775881069, 2111890403, 1255737547, 1493332025, 1776547723, 2112683192, 1256208942, 1493892612, 1777214439, 2113476055, 1256680381, 1494453251, 1777881217, 2114268993, 1257151865, 1495013942, 
+1778548058, 2115062005, 1257623392, 1495574686, 1779214961, 2115855091, 1258094964, 1496135483, 1779881927, 2116648252, 1258566580, 1496696332, 1780548956, 2117441487, 1259038241, 1497257234, 
+1781216047, 2118234796, 1259509945, 1497818188, 1781883200, 2119028179, 1259981694, 1498379195, 1782550416, 2119821637, 1260453487, 1498940255, 1783217694, 2120615169, 1260925324, 1499501366, 
+1783885035, 2121408775, 1261397205, 1500062531, 1784552438, 2122202456, 1261869130, 1500623748, 1785219903, 2122996211, 1262341099, 1501185017, 1785887431, 2123790040, 1262813113, 1501746339, 
+1786555021, 2124583943, 1263285171, 1502307713, 1787222674, 2125377920, 1263757272, 1502869140, 1787890389, 2126171971, 1264229418, 1503430619, 1788558166, 2126966097, 1264701608, 1503992151, 
+1789226006, 2127760297, 1265173842, 1504553735, 1789893908, 2128554570, 1265646120, 1505115371, 1790561872, 2129348918, 1266118442, 1505677060, 1791229899, 2130143340, 1266590808, 1506238801, 
+1791897988, 2130937837, 1267063218, 1506800594, 1792566139, 2131732407, 1267535673, 1507362440, 1793234353, 2132527051, 1268008171, 1507924339, 1793902628, 2133321769, 1268480713, 1508486289, 
+1794570966, 2134116561, 1268953300, 1509048292, 1795239366, 2134911428, 1269425930, 1509610348, 1795907829, 2135706368, 1269898604, 1510172455, 1796576353, 2136501382, 1270371322, 1510734615, 
+1797244940, 2137296470, 1270844085, 1511296828, 1797913589, 2138091632, 1271316891, 1511859092, 1798582300, 2138886869, 1271789741, 1512421409, 1799251074, 2139682179, 1272262635, 1512983778, 
+1799919909, 2140477562, 1272735573, 1513546199, 1800588807, 2141273020, 1273208555, 1514108673, 1801257767, 2142068552, 1273681581, 1514671199, 1801926788, 2142864158, 1274154651, 1515233777, 
+1802595872, 2143659837, 1274627765, 1515796407, 1803265018, 2144455590, 1275100923, 1516359090, 1803934227, 2145251417, 1275574124, 1516921825, 1804603497, 2146047318, 1276047370, 1517484611, 
+1805272829, 2146843293, 1276520659, 1518047451, 1805942223, 1073819671, 1276993993, 1518610342, 1806611680, 1074217732, 1277467370, 1519173285, 1807281198, 1074615830, 1277940791, 1519736281, 
+1807950779, 1075013965, 1278414256, 1520299329, 1808620421, 1075412137, 1278887764, 1520862429, 1809290125, 1075810345, 1279361317, 1521425581, 1809959892, 1076208591, 1279834913, 1521988785, 
+1810629720, 1076606873, 1280308553, 1522552041, 1811299610, 1077005192, 1280782237, 1523115349, 1811969563, 1077403548, 1281255965, 1523678710, 1812639577, 1077801941, 1281729737, 1524242122, 
+1813309653, 1078200370, 1282203552, 1524805587, 1813979791, 1078598837, 1282677411, 1525369103, 1814649991, 1078997340, 1283151314, 1525932672, 1815320253, 1079395880, 1283625261, 1526496293, 
+1815990576, 1079794457, 1284099251, 1527059966, 1816660962, 1080193071, 1284573285, 1527623690, 1817331409, 1080591721, 1285047363, 1528187467, 1818001918, 1080990408, 1285521485, 1528751296, 
+1818672489, 1081389132, 1285995650, 1529315177, 1819343122, 1081787893, 1286469859, 1529879110, 1820013817, 1082186690, 1286944112, 1530443094, 1820684573, 1082585524, 1287418408, 1531007131, 
+1821355392, 1082984395, 1287892748, 1531571220, 1822026272, 1083383303, 1288367132, 1532135360, 1822697213, 1083782247, 1288841560, 1532699553, 1823368217, 1084181228, 1289316031, 1533263797, 
+1824039282, 1084580246, 1289790546, 1533828094, 1824710409, 1084979301, 1290265104, 1534392442, 1825381598, 1085378392, 1290739706, 1534956842, 1826052848, 1085777520, 1291214352, 1535521294, 
+1826724160, 1086176684, 1291689041, 1536085798, 1827395534, 1086575886, 1292163774, 1536650354, 1828066970, 1086975123, 1292638551, 1537214962, 1828738467, 1087374398, 1293113371, 1537779621, 
+1829410025, 1087773709, 1293588235, 1538344332, 1830081646, 1088173057, 1294063142, 1538909096, 1830753328, 1088572442, 1294538093, 1539473911, 1831425072, 1088971863, 1295013087, 1540038777, 
+1832096877, 1089371321, 1295488125, 1540603696, 1832768744, 1089770815, 1295963207, 1541168666, 1833440672, 1090170346, 1296438332, 1541733689, 1834112662, 1090569914, 1296913501, 1542298763, 
+1834784714, 1090969518, 1297388713, 1542863888, 1835456827, 1091369159, 1297863969, 1543429066, 1836129001, 1091768836, 1298339268, 1543994295, 1836801237, 1092168550, 1298814611, 1544559576, 
+1837473535, 1092568301, 1299289997, 1545124909, 1838145894, 1092968088, 1299765427, 1545690293, 1838818315, 1093367912, 1300240900, 1546255729, 1839490797, 1093767772, 1300716416, 1546821217, 
+1840163341, 1094167669, 1301191977, 1547386757, 1840835946, 1094567602, 1301667580, 1547952348, 1841508612, 1094967572, 1302143227, 1548517991, 1842181340, 1095367578, 1302618918, 1549083685, 
+1842854129, 1095767621, 1303094652, 1549649431, 1843526980, 1096167701, 1303570429, 1550215229, 1844199892, 1096567817, 1304046250, 1550781078, 1844872866, 1096967969, 1304522114, 1551346979, 
+1845545901, 1097368158, 1304998021, 1551912932, 1846218997, 1097768384, 1305473972, 1552478936, 1846892155, 1098168645, 1305949967, 1553044992, 1847565374, 1098568944, 1306426004, 1553611100, 
+1848238654, 1098969279, 1306902085, 1554177259, 1848911996, 1099369650, 1307378210, 1554743469, 1849585399, 1099770058, 1307854378, 1555309731, 1850258863, 1100170502, 1308330589, 1555876045, 
+1850932388, 1100570983, 1308806843, 1556442410, 1851605975, 1100971500, 1309283141, 1557008827, 1852279623, 1101372053, 1309759482, 1557575295, 1852953333, 1101772643, 1310235867, 1558141815, 
+1853627103, 1102173270, 1310712294, 1558708386, 1854300935, 1102573933, 1311188766, 1559275009, 1854974828, 1102974632, 1311665280, 1559841683, 1855648782, 1103375367, 1312141837, 1560408409, 
+1856322798, 1103776139, 1312618438, 1560975186, 1856996874, 1104176948, 1313095083, 1561542015, 1857671012, 1104577793, 1313571770, 1562108895, 1858345211, 1104978674, 1314048501, 1562675826, 
+1859019471, 1105379591, 1314525275, 1563242809, 1859693793, 1105780545, 1315002092, 1563809844, 1860368175, 1106181535, 1315478952, 1564376929, 1861042619, 1106582562, 1315955856, 1564944067, 
+1861717123, 1106983624, 1316432802, 1565511255, 1862391689, 1107384724, 1316909792, 1566078495, 1863066316, 1107785859, 1317386826, 1566645786, 1863741004, 1108187031, 1317863902, 1567213129, 
+1864415753, 1108588239, 1318341022, 1567780523, 1865090563, 1108989484, 1318818184, 1568347968, 1865765434, 1109390764, 1319295390, 1568915465, 1866440366, 1109792081, 1319772639, 1569483013, 
+1867115359, 1110193435, 1320249932, 1570050612, 1867790413, 1110594824, 1320727267, 1570618263, 1868465528, 1110996250, 1321204645, 1571185965, 1869140704, 1111397712, 1321682067, 1571753718, 
+1869815941, 1111799211, 1322159532, 1572321522, 1870491239, 1112200745, 1322637040, 1572889378, 1871166598, 1112602316, 1323114591, 1573457285, 1871842018, 1113003923, 1323592185, 1574025243, 
+1872517499, 1113405567, 1324069822, 1574593253, 1873193041, 1113807246, 1324547502, 1575161313, 1873868644, 1114208962, 1325025225, 1575729425, 1874544308, 1114610714, 1325502991, 1576297588, 
+1875220032, 1115012502, 1325980801, 1576865803, 1875895817, 1115414327, 1326458653, 1577434068, 1876571664, 1115816187, 1326936549, 1578002385, 1877247571, 1116218084, 1327414487, 1578570753, 
+1877923539, 1116620017, 1327892469, 1579139172, 1878599568, 1117021986, 1328370493, 1579707642, 1879275657, 1117423991, 1328848561, 1580276163, 1879951808, 1117826033, 1329326672, 1580844736, 
+1880628019, 1118228110, 1329804825, 1581413360, 1881304291, 1118630224, 1330283022, 1581982034, 1881980624, 1119032374, 1330761261, 1582550760, 1882657017, 1119434560, 1331239544, 1583119537, 
+1883333472, 1119836782, 1331717869, 1583688365, 1884009987, 1120239041, 1332196238, 1584257244, 1884686563, 1120641335, 1332674649, 1584826174, 1885363199, 1121043665, 1333153103, 1585395156, 
+1886039897, 1121446032, 1333631600, 1585964188, 1886716655, 1121848435, 1334110141, 1586533271, 1887393473, 1122250874, 1334588724, 1587102406, 1888070353, 1122653348, 1335067350, 1587671591, 
+1888747293, 1123055859, 1335546019, 1588240828, 1889424293, 1123458406, 1336024730, 1588810115, 1890101355, 1123860989, 1336503485, 1589379454, 1890778477, 1124263609, 1336982282, 1589948843, 
+1891455659, 1124666264, 1337461123, 1590518283, 1892132902, 1125068955, 1337940006, 1591087775, 1892810206, 1125471682, 1338418932, 1591657317, 1893487571, 1125874446, 1338897901, 1592226910, 
+1894164996, 1126277245, 1339376913, 1592796555, 1894842481, 1126680080, 1339855968, 1593366250, 1895520027, 1127082952, 1340335065, 1593935996, 1896197634, 1127485859, 1340814205, 1594505793, 
+1896875301, 1127888802, 1341293389, 1595075641, 1897553029, 1128291782, 1341772614, 1595645540, 1898230817, 1128694797, 1342251883, 1596215490, 1898908666, 1129097848, 1342731195, 1596785490, 
+1899586575, 1129500935, 1343210549, 1597355542, 1900264545, 1129904059, 1343689946, 1597925644, 1900942575, 1130307218, 1344169386, 1598495797, 1901620666, 1130710413, 1344648868, 1599066001, 
+1902298817, 1131113644, 1345128394, 1599636256, 1902977029, 1131516911, 1345607962, 1600206562, 1903655301, 1131920214, 1346087572, 1600776918, 1904333633, 1132323553, 1346567226, 1601347326, 
+1905012026, 1132726928, 1347046922, 1601917784, 1905690480, 1133130339, 1347526661, 1602488293, 1906368993, 1133533785, 1348006443, 1603058853, 1907047567, 1133937268, 1348486267, 1603629463, 
+1907726202, 1134340786, 1348966134, 1604200124, 1908404897, 1134744341, 1349446044, 1604770836, 1909083652, 1135147931, 1349925996, 1605341599, 1909762467, 1135551557, 1350405991, 1605912413, 
+1910441343, 1135955219, 1350886029, 1606483277, 1911120279, 1136358917, 1351366109, 1607054192, 1911799275, 1136762650, 1351846232, 1607625157, 1912478332, 1137166420, 1352326398, 1608196174, 
+1913157449, 1137570225, 1352806606, 1608767241, 1913836626, 1137974067, 1353286857, 1609338359, 1914515864, 1138377944, 1353767150, 1609909527, 1915195162, 1138781856, 1354247486, 1610480746, 
+1915874520, 1139185805, 1354727865, 1611052016, 1916553938, 1139589790, 1355208286, 1611623336, 1917233416, 1139993810, 1355688750, 1612194707, 1917912955, 1140397866, 1356169256, 1612766129, 
+1918592554, 1140801958, 1356649805, 1613337601, 1919272213, 1141206086, 1357130397, 1613909124, 1919951932, 1141610249, 1357611031, 1614480697, 1920631712, 1142014448, 1358091707, 1615052321, 
+1921311551, 1142418683, 1358572427, 1615623996, 1921991451, 1142822954, 1359053188, 1616195721, 1922671411, 1143227261, 1359533992, 1616767497, 1923351431, 1143631603, 1360014839, 1617339323, 
+1924031511, 1144035981, 1360495728, 1617911200, 1924711651, 1144440395, 1360976660, 1618483128, 1925391851, 1144844844, 1361457634, 1619055106, 1926072111, 1145249329, 1361938651, 1619627134, 
+1926752432, 1145653850, 1362419710, 1620199213, 1927432812, 1146058407, 1362900812, 1620771342, 1928113253, 1146462999, 1363381956, 1621343522, 1928793753, 1146867627, 1363863142, 1621915753, 
+1929474314, 1147272291, 1364344371, 1622488034, 1930154935, 1147676991, 1364825643, 1623060365, 1930835615, 1148081726, 1365306957, 1623632747, 1931516356, 1148486496, 1365788313, 1624205180, 
+1932197156, 1148891303, 1366269712, 1624777662, 1932878017, 1149296145, 1366751153, 1625350195, 1933558937, 1149701023, 1367232636, 1625922779, 1934239918, 1150105936, 1367714162, 1626495413, 
+1934920958, 1150510885, 1368195731, 1627068098, 1935602059, 1150915870, 1368677341, 1627640832, 1936283219, 1151320890, 1369158994, 1628213618, 1936964439, 1151725946, 1369640690, 1628786453, 
+1937645719, 1152131038, 1370122428, 1629359339, 1938327059, 1152536165, 1370604208, 1629932276, 1939008459, 1152941328, 1371086030, 1630505262, 1939689919, 1153346526, 1371567895, 1631078299, 
+1940371438, 1153751760, 1372049802, 1631651387, 1941053018, 1154157030, 1372531751, 1632224524, 1941734657, 1154562335, 1373013743, 1632797712, 1942416356, 1154967675, 1373495777, 1633370951, 
+1943098115, 1155373052, 1373977854, 1633944239, 1943779934, 1155778464, 1374459972, 1634517578, 1944461812, 1156183911, 1374942133, 1635090967, 1945143750, 1156589394, 1375424336, 1635664407, 
+1945825749, 1156994912, 1375906582, 1636237897, 1946507806, 1157400466, 1376388870, 1636811437, 1947189924, 1157806056, 1376871199, 1637385027, 1947872101, 1158211681, 1377353572, 1637958667, 
+1948554338, 1158617342, 1377835986, 1638532358, 1949236635, 1159023038, 1378318443, 1639106099, 1949918992, 1159428769, 1378800942, 1639679890, 1950601408, 1159834536, 1379283483, 1640253731, 
+1951283884, 1160240339, 1379766066, 1640827623, 1951966419, 1160646177, 1380248692, 1641401565, 1952649015, 1161052051, 1380731359, 1641975557, 1953331669, 1161457960, 1381214069, 1642549599, 
+1954014384, 1161863904, 1381696821, 1643123691, 1954697158, 1162269884, 1382179616, 1643697833, 1955379992, 1162675899, 1382662452, 1644272026, 1956062885, 1163081950, 1383145331, 1644846268, 
+1956745838, 1163488037, 1383628251, 1645420561, 1957428851, 1163894158, 1384111214, 1645994904, 1958111923, 1164300316, 1384594219, 1646569297, 1958795055, 1164706508, 1385077266, 1647143740, 
+1959478246, 1165112736, 1385560356, 1647718233, 1960161497, 1165519000, 1386043487, 1648292776, 1960844808, 1165925298, 1386526660, 1648867370, 1961528178, 1166331633, 1387009876, 1649442013, 
+1962211607, 1166738002, 1387493134, 1650016707, 1962895096, 1167144407, 1387976433, 1650591450, 1963578645, 1167550848, 1388459775, 1651166244, 1964262253, 1167957323, 1388943159, 1651741087, 
+1964945921, 1168363835, 1389426585, 1652315981, 1965629648, 1168770381, 1389910053, 1652890924, 1966313434, 1169176963, 1390393563, 1653465918, 1966997280, 1169583580, 1390877115, 1654040961, 
+1967681185, 1169990233, 1391360709, 1654616055, 1968365150, 1170396921, 1391844345, 1655191199, 1969049174, 1170803644, 1392328024, 1655766392, 1969733258, 1171210402, 1392811744, 1656341635, 
+1970417401, 1171617196, 1393295506, 1656916929, 1971101603, 1172024025, 1393779310, 1657492272, 1971785865, 1172430890, 1394263156, 1658067666, 1972470186, 1172837790, 1394747044, 1658643109, 
+1973154567, 1173244725, 1395230974, 1659218602, 1973839007, 1173651695, 1395714946, 1659794145, 1974523506, 1174058701, 1396198961, 1660369738, 1975208064, 1174465742, 1396683016, 1660945381, 
+1975892682, 1174872818, 1397167114, 1661521073, 1976577359, 1175279929, 1397651254, 1662096816, 1977262096, 1175687076, 1398135436, 1662672608, 1977946891, 1176094258, 1398619660, 1663248451, 
+1978631746, 1176501475, 1399103925, 1663824343, 1979316661, 1176908728, 1399588233, 1664400285, 1980001634, 1177316016, 1400072582, 1664976276, 1980686667, 1177723339, 1400556974, 1665552318, 
+1981371759, 1178130697, 1401041407, 1666128409, 1982056910, 1178538090, 1401525882, 1666704551, 1982742121, 1178945519, 1402010399, 1667280742, 1983427390, 1179352982, 1402494958, 1667856983, 
+1984112719, 1179760481, 1402979558, 1668433273, 1984798107, 1180168016, 1403464201, 1669009613, 1985483555, 1180575585, 1403948885, 1669586004, 1986169061, 1180983189, 1404433612, 1670162443, 
+1986854626, 1181390829, 1404918380, 1670738933, 1987540251, 1181798504, 1405403189, 1671315472, 1988225935, 1182206214, 1405888041, 1671892061, 1988911678, 1182613959, 1406372935, 1672468700, 
+1989597480, 1183021740, 1406857870, 1673045389, 1990283341, 1183429555, 1407342847, 1673622127, 1990969261, 1183837406, 1407827866, 1674198915, 1991655241, 1184245291, 1408312926, 1674775752, 
+1992341279, 1184653212, 1408798029, 1675352640, 1993027377, 1185061168, 1409283173, 1675929576, 1993713533, 1185469159, 1409768359, 1676506563, 1994399749, 1185877186, 1410253587, 1677083599, 
+1995086023, 1186285247, 1410738856, 1677660685, 1995772357, 1186693343, 1411224167, 1678237820, 1996458749, 1187101475, 1411709520, 1678815006, 1997145201, 1187509641, 1412194915, 1679392240, 
+1997831712, 1187917843, 1412680351, 1679969525, 1998518281, 1188326080, 1413165829, 1680546859, 1999204910, 1188734352, 1413651349, 1681124242, 1999891597, 1189142658, 1414136910, 1681701675, 
+2000578344, 1189551000, 1414622513, 1682279158, 2001265149, 1189959377, 1415108158, 1682856690, 2001952014, 1190367789, 1415593844, 1683434272, 2002638937, 1190776236, 1416079573, 1684011903, 
+2003325919, 1191184718, 1416565342, 1684589584, 2004012960, 1191593235, 1417051154, 1685167314, 2004700060, 1192001787, 1417537007, 1685745094, 2005387219, 1192410375, 1418022901, 1686322924, 
+2006074437, 1192818997, 1418508838, 1686900803, 2006761713, 1193227654, 1418994816, 1687478731, 2007449049, 1193636346, 1419480835, 1688056709, 2008136443, 1194045073, 1419966896, 1688634736, 
+2008823896, 1194453835, 1420452999, 1689212813, 2009511408, 1194862632, 1420939143, 1689790939, 2010198979, 1195271464, 1421425329, 1690369115, 2010886608, 1195680331, 1421911557, 1690947340, 
+2011574297, 1196089233, 1422397826, 1691525615, 2012262044, 1196498170, 1422884137, 1692103939, 2012949849, 1196907142, 1423370489, 1692682313, 2013637714, 1197316148, 1423856883, 1693260735, 
+2014325637, 1197725190, 1424343318, 1693839208, 2015013620, 1198134267, 1424829795, 1694417729, 2015701660, 1198543378, 1425316313, 1694996300, 2016389760, 1198952525, 1425802873, 1695574921, 
+2017077918, 1199361706, 1426289474, 1696153591, 2017766135, 1199770922, 1426776117, 1696732310, 2018454411, 1200180173, 1427262801, 1697311078, 2019142745, 1200589459, 1427749527, 1697889896, 
+2019831138, 1200998780, 1428236295, 1698468764, 2020519590, 1201408136, 1428723104, 1699047680, 2021208100, 1201817527, 1429209954, 1699626646, 2021896669, 1202226952, 1429696846, 1700205661, 
+2022585297, 1202636413, 1430183779, 1700784726, 2023273983, 1203045908, 1430670754, 1701363839, 2023962728, 1203455438, 1431157770, 1701943002, 2024651531, 1203865003, 1431644827, 1702522215, 
+2025340393, 1204274603, 1432131926, 1703101476, 2026029314, 1204684238, 1432619067, 1703680787, 2026718293, 1205093907, 1433106248, 1704260147, 2027407331, 1205503611, 1433593472, 1704839557, 
+2028096427, 1205913350, 1434080736, 1705419015, 2028785582, 1206323124, 1434568042, 1705998523, 2029474795, 1206732933, 1435055390, 1706578080, 2030164067, 1207142776, 1435542779, 1707157686, 
+2030853397, 1207552655, 1436030209, 1707737342, 2031542786, 1207962568, 1436517680, 1708317046, 2032232233, 1208372516, 1437005193, 1708896800, 2032921739, 1208782498, 1437492747, 1709476603, 
+2033611304, 1209192516, 1437980343, 1710056455, 2034300926, 1209602568, 1438467980, 1710636356, 2034990607, 1210012655, 1438955658, 1711216307, 2035680347, 1210422776, 1439443378, 1711796306, 
+2036370145, 1210832933, 1439931139, 1712376355, 2037060002, 1211243124, 1440418941, 1712956453, 2037749917, 1211653350, 1440906784, 1713536600, 2038439890, 1212063610, 1441394669, 1714116796, 
+2039129922, 1212473906, 1441882595, 1714697041, 2039820012, 1212884236, 1442370563, 1715277336, 2040510160, 1213294600, 1442858571, 1715857679, 2041200367, 1213705000, 1443346621, 1716438071, 
+2041890632, 1214115434, 1443834712, 1717018513, 2042580956, 1214525903, 1444322845, 1717599003, 2043271337, 1214936406, 1444811018, 1718179543, 2043961778, 1215346944, 1445299233, 1718760132, 
+2044652276, 1215757517, 1445787490, 1719340769, 2045342833, 1216168125, 1446275787, 1719921456, 2046033448, 1216578767, 1446764126, 1720502192, 2046724121, 1216989444, 1447252505, 1721082977, 
+2047414853, 1217400155, 1447740926, 1721663810, 2048105643, 1217810901, 1448229389, 1722244693, 2048796491, 1218221682, 1448717892, 1722825625, 2049487397, 1218632497, 1449206436, 1723406605, 
+2050178362, 1219043347, 1449695022, 1723987635, 2050869385, 1219454232, 1450183649, 1724568714, 2051560466, 1219865151, 1450672317, 1725149841, 2052251605, 1220276105, 1451161027, 1725731018, 
+2052942802, 1220687094, 1451649777, 1726312243, 2053634058, 1221098117, 1452138568, 1726893518, 2054325372, 1221509174, 1452627401, 1727474841, 2055016744, 1221920267, 1453116275, 1728056213, 
+2055708174, 1222331393, 1453605190, 1728637634, 2056399662, 1222742555, 1454094146, 1729219104, 2057091208, 1223153751, 1454583143, 1729800623, 2057782813, 1223564981, 1455072181, 1730382191, 
+2058474476, 1223976246, 1455561261, 1730963807, 2059166196, 1224387546, 1456050381, 1731545473, 2059857975, 1224798880, 1456539543, 1732127187, 2060549812, 1225210249, 1457028745, 1732708950, 
+2061241707, 1225621652, 1457517989, 1733290763, 2061933660, 1226033090, 1458007274, 1733872623, 2062625671, 1226444562, 1458496599, 1734454533, 2063317741, 1226856069, 1458985966, 1735036492, 
+2064009868, 1227267610, 1459475374, 1735618499, 2064702053, 1227679186, 1459964823, 1736200555, 2065394296, 1228090796, 1460454313, 1736782660, 2066086597, 1228502441, 1460943844, 1737364813, 
+2066778957, 1228914120, 1461433416, 1737947016, 2067471374, 1229325834, 1461923028, 1738529267, 2068163849, 1229737582, 1462412682, 1739111567, 2068856382, 1230149365, 1462902377, 1739693916, 
+2069548974, 1230561182, 1463392113, 1740276313, 2070241623, 1230973034, 1463881890, 1740858759, 2070934330, 1231384920, 1464371708, 1741441254, 2071627095, 1231796840, 1464861567, 1742023798, 
+2072319918, 1232208795, 1465351467, 1742606390, 2073012798, 1232620785, 1465841407, 1743189031, 2073705737, 1233032809, 1466331389, 1743771721, 2074398734, 1233444867, 1466821412, 1744354459, 
+2075091788, 1233856959, 1467311475, 1744937246, 2075784901, 1234269087, 1467801580, 1745520082, 2076478071, 1234681248, 1468291725, 1746102966, 2077171299, 1235093444, 1468781911, 1746685899, 
+2077864585, 1235505674, 1469272138, 1747268881, 2078557929, 1235917939, 1469762406, 1747851911, 2079251330, 1236330238, 1470252715, 1748434990, 2079944790, 1236742571, 1470743065, 1749018118, 
+2080638307, 1237154939, 1471233456, 1749601294, 2081331882, 1237567341, 1471723888, 1750184518, 2082025515, 1237979778, 1472214360, 1750767792, 2082719205, 1238392249, 1472704873, 1751351114, 
+2083412954, 1238804754, 1473195427, 1751934484, 2084106760, 1239217293, 1473686022, 1752517903, 2084800623, 1239629867, 1474176658, 1753101371, 2085494545, 1240042476, 1474667335, 1753684887, 
+2086188524, 1240455118, 1475158052, 1754268452, 2086882561, 1240867795, 1475648811, 1754852065, 2087576656, 1241280506, 1476139610, 1755435727, 2088270808, 1241693252, 1476630450, 1756019437, 
+2088965019, 1242106032, 1477121330, 1756603196, 2089659286, 1242518846, 1477612252, 1757187003, 2090353612, 1242931694, 1478103214, 1757770859, 2091047995, 1243344577, 1478594217, 1758354763, 
+2091742436, 1243757494, 1479085261, 1758938716, 2092436934, 1244170445, 1479576345, 1759522717, 2093131490, 1244583430, 1480067471, 1760106767, 2093826104, 1244996450, 1480558637, 1760690865, 
+2094520775, 1245409504, 1481049843, 1761275012, 2095215504, 1245822592, 1481541091, 1761859207, 2095910291, 1246235715, 1482032379, 1762443450, 2096605135, 1246648872, 1482523708, 1763027742, 
+2097300036, 1247062063, 1483015078, 1763612082, 2097994995, 1247475288, 1483506488, 1764196471, 2098690012, 1247888547, 1483997939, 1764780908, 2099385087, 1248301841, 1484489431, 1765365394, 
+2100080218, 1248715169, 1484980963, 1765949927, 2100775408, 1249128531, 1485472537, 1766534510, 2101470655, 1249541927, 1485964150, 1767119140, 2102165959, 1249955358, 1486455805, 1767703819, 
+2102861321, 1250368822, 1486947500, 1768288547, 2103556740, 1250782321, 1487439236, 1768873322, 2104252217, 1251195854, 1487931012, 1769458146, 2104947752, 1251609421, 1488422829, 1770043019, 
+2105643343, 1252023023, 1488914687, 1770627939, 2106338993, 1252436658, 1489406585, 1771212908, 2107034699, 1252850328, 1489898524, 1771797925, 2107730463, 1253264032, 1490390504, 1772382991, 
+2108426285, 1253677770, 1490882524, 1772968105, 2109122164, 1254091542, 1491374584, 1773553267, 2109818100, 1254505348, 1491866686, 1774138477, 2110514094, 1254919189, 1492358828, 1774723736, 
+2111210145, 1255333063, 1492851010, 1775309043, 2111906254, 1255746972, 1493343233, 1775894398, 2112602420, 1256160914, 1493835497, 1776479802, 2113298643, 1256574891, 1494327801, 1777065253, 
+2113994924, 1256988902, 1494820146, 1777650753, 2114691261, 1257402947, 1495312531, 1778236301, 2115387657, 1257817026, 1495804957, 1778821897, 2116084109, 1258231139, 1496297423, 1779407542, 
+2116780619, 1258645287, 1496789930, 1779993235, 2117477186, 1259059468, 1497282477, 1780578975, 2118173811, 1259473683, 1497775065, 1781164764, 2118870493, 1259887933, 1498267694, 1781750602, 
+2119567232, 1260302216, 1498760363, 1782336487, 2120264028, 1260716534, 1499253072, 1782922420, 2120960881, 1261130885, 1499745822, 1783508402, 2121657792, 1261545271, 1500238612, 1784094432, 
+2122354760, 1261959691, 1500731443, 1784680510, 2123051786, 1262374144, 1501224314, 1785266636, 2123748868, 1262788632, 1501717226, 1785852810, 2124446008, 1263203154, 1502210178, 1786439032, 
+2125143205, 1263617710, 1502703171, 1787025303, 2125840459, 1264032299, 1503196204, 1787611621, 2126537770, 1264446923, 1503689277, 1788197988, 2127235138, 1264861581, 1504182391, 1788784402, 
+2127932564, 1265276273, 1504675546, 1789370865, 2128630046, 1265690998, 1505168740, 1789957375, 2129327586, 1266105758, 1505661976, 1790543934, 2130025183, 1266520552, 1506155251, 1791130541, 
+2130722837, 1266935379, 1506648567, 1791717196, 2131420549, 1267350241, 1507141923, 1792303899, 2132118317, 1267765136, 1507635320, 1792890650, 2132816142, 1268180066, 1508128757, 1793477448, 
+2133514025, 1268595029, 1508622235, 1794064295, 2134211964, 1269010026, 1509115753, 1794651190, 2134909961, 1269425058, 1509609311, 1795238133, 2135608015, 1269840123, 1510102909, 1795825124, 
+2136306125, 1270255222, 1510596548, 1796412163, 2137004293, 1270670355, 1511090227, 1796999250, 2137702518, 1271085522, 1511583947, 1797586384, 2138400800, 1271500723, 1512077706, 1798173567, 
+2139099139, 1271915958, 1512571507, 1798760798, 2139797535, 1272331226, 1513065347, 1799348076, 2140495987, 1272746529, 1513559228, 1799935403, 2141194497, 1273161865, 1514053149, 1800522777, 
+2141893064, 1273577236, 1514547110, 1801110199, 2142591688, 1273992640, 1515041112, 1801697669, 2143290368, 1274408078, 1515535154, 1802285188, 2143989106, 1274823550, 1516029236, 1802872754, 
+2144687901, 1275239055, 1516523358, 1803460367, 2145386752, 1275654595, 1517017521, 1804048029, 2146085660, 1276070168, 1517511724, 1804635739, 2146784626, 1276485776, 1518005967, 1805223496, 
+2147483648, 1276901417, 1518500250, 1805811301, 1074091364, 1277317092, 1518994574, 1806399155, 1074440932, 1277732800, 1519488937, 1806987055, 1074790528, 1278148543, 1519983341, 1807575004, 
+1075140153, 1278564319, 1520477786, 1808163001, 1075489806, 1278980130, 1520972270, 1808751045, 1075839488, 1279395974, 1521466795, 1809339137, 1076189198, 1279811851, 1521961359, 1809927277, 
+1076538936, 1280227763, 1522455964, 1810515465, 1076888703, 1280643708, 1522950610, 1811103701, 1077238499, 1281059687, 1523445295, 1811691984, 1077588323, 1281475700, 1523940020, 1812280315, 
+1077938175, 1281891747, 1524434786, 1812868694, 1078288055, 1282307827, 1524929592, 1813457120, 1078637964, 1282723941, 1525424438, 1814045595, 1078987901, 1283140089, 1525919324, 1814634117, 
+1079337867, 1283556271, 1526414250, 1815222687, 1079687861, 1283972486, 1526909216, 1815811304, 1080037884, 1284388736, 1527404223, 1816399969, 1080387934, 1284805018, 1527899269, 1816988682, 
+1080738013, 1285221335, 1528394356, 1817577443, 1081088121, 1285637685, 1528889483, 1818166251, 1081438257, 1286054069, 1529384649, 1818755107, 1081788421, 1286470487, 1529879856, 1819344010, 
+1082138613, 1286886938, 1530375103, 1819932962, 1082488834, 1287303424, 1530870390, 1820521960, 1082839083, 1287719942, 1531365718, 1821111007, 1083189361, 1288136495, 1531861085, 1821700101, 
+1083539667, 1288553081, 1532356492, 1822289243, 1083890001, 1288969701, 1532851939, 1822878432, 1084240363, 1289386354, 1533347427, 1823467669, 1084590754, 1289803041, 1533842954, 1824056954, 
+1084941173, 1290219762, 1534338521, 1824646286, 1085291620, 1290636517, 1534834129, 1825235666, 1085642096, 1291053305, 1535329776, 1825825094, 1085992600, 1291470127, 1535825463, 1826414569, 
+1086343132, 1291886982, 1536321191, 1827004091, 1086693693, 1292303871, 1536816958, 1827593661, 1087044281, 1292720794, 1537312766, 1828183279, 1087394898, 1293137750, 1537808613, 1828772944, 
+1087745544, 1293554740, 1538304500, 1829362657, 1088096217, 1293971763, 1538800428, 1829952417, 1088446919, 1294388820, 1539296395, 1830542225, 1088797649, 1294805911, 1539792402, 1831132080, 
+1089148407, 1295223035, 1540288449, 1831721983, 1089499194, 1295640193, 1540784536, 1832311933, 1089850009, 1296057385, 1541280663, 1832901931, 1090200852, 1296474610, 1541776830, 1833491976, 
+1090551723, 1296891868, 1542273037, 1834082069, 1090902623, 1297309161, 1542769284, 1834672209, 1091253550, 1297726486, 1543265571, 1835262397, 1091604506, 1298143846, 1543761897, 1835852632, 
+1091955490, 1298561238, 1544258264, 1836442915, 1092306503, 1298978665, 1544754670, 1837033245, 1092657543, 1299396125, 1545251117, 1837623622, 1093008612, 1299813618, 1545747603, 1838214047, 
+1093359709, 1300231145, 1546244129, 1838804519, 1093710834, 1300648705, 1546740695, 1839395039, 1094061987, 1301066299, 1547237300, 1839985606, 1094413169, 1301483927, 1547733946, 1840576221, 
+1094764378, 1301901588, 1548230631, 1841166883, 1095115616, 1302319282, 1548727357, 1841757592, 1095466882, 1302737010, 1549224122, 1842348348, 1095818176, 1303154772, 1549720927, 1842939152, 
+1096169499, 1303572567, 1550217772, 1843530004, 1096520849, 1303990395, 1550714656, 1844120902, 1096872228, 1304408257, 1551211581, 1844711848, 1097223634, 1304826153, 1551708545, 1845302842, 
+1097575069, 1305244082, 1552205549, 1845893882, 1097926532, 1305662044, 1552702592, 1846484970, 1098278023, 1306080040, 1553199676, 1847076106, 1098629543, 1306498069, 1553696799, 1847667288, 
+1098981090, 1306916132, 1554193962, 1848258518, 1099332666, 1307334228, 1554691165, 1848849795, 1099684269, 1307752357, 1555188408, 1849441120, 1100035901, 1308170520, 1555685690, 1850032491, 
+1100387561, 1308588717, 1556183012, 1850623910, 1100739249, 1309006946, 1556680374, 1851215377, 1101090965, 1309425209, 1557177776, 1851806890, 1101442709, 1309843506, 1557675217, 1852398451, 
+1101794481, 1310261836, 1558172698, 1852990059, 1102146281, 1310680199, 1558670219, 1853581714, 1102498110, 1311098596, 1559167779, 1854173416, 1102849966, 1311517026, 1559665379, 1854765166, 
+1103201851, 1311935490, 1560163019, 1855356963, 1103553763, 1312353987, 1560660699, 1855948807, 1103905704, 1312772517, 1561158418, 1856540698, 1104257672, 1313191081, 1561656177, 1857132636, 
+1104609669, 1313609678, 1562153975, 1857724622, 1104961694, 1314028308, 1562651813, 1858316655, 1105313747, 1314446972, 1563149691, 1858908734, 1105665827, 1314865669, 1563647609, 1859500861, 
+1106017936, 1315284399, 1564145566, 1860093036, 1106370073, 1315703163, 1564643562, 1860685257, 1106722238, 1316121960, 1565141599, 1861277525, 1107074431, 1316540790, 1565639675, 1861869841, 
+1107426652, 1316959654, 1566137790, 1862462204, 1107778901, 1317378551, 1566635946, 1863054613, 1108131178, 1317797481, 1567134141, 1863647070, 1108483483, 1318216445, 1567632375, 1864239574, 
+1108835816, 1318635441, 1568130649, 1864832125, 1109188177, 1319054472, 1568628963, 1865424723, 1109540566, 1319473535, 1569127316, 1866017368, 1109892982, 1319892632, 1569625709, 1866610061, 
+1110245427, 1320311762, 1570124141, 1867202800, 1110597900, 1320730925, 1570622613, 1867795586, 1110950401, 1321150121, 1571121124, 1868388419, 1111302930, 1321569351, 1571619675, 1868981300, 
+1111655487, 1321988614, 1572118266, 1869574227, 1112008071, 1322407910, 1572616896, 1870167202, 1112360684, 1322827240, 1573115565, 1870760223, 1112713324, 1323246602, 1573614275, 1871353292, 
+1113065993, 1323665998, 1574113023, 1871946407, 1113418689, 1324085428, 1574611811, 1872539569, 1113771414, 1324504890, 1575110639, 1873132779, 1114124166, 1324924385, 1575609506, 1873726035, 
+1114476946, 1325343914, 1576108413, 1874319338, 1114829755, 1325763476, 1576607359, 1874912689, 1115182591, 1326183071, 1577106344, 1875506086, 1115535455, 1326602700, 1577605369, 1876099530, 
+1115888347, 1327022361, 1578104434, 1876693021, 1116241267, 1327442056, 1578603538, 1877286559, 1116594214, 1327861784, 1579102681, 1877880144, 1116947190, 1328281545, 1579601864, 1878473776, 
+1117300193, 1328701339, 1580101087, 1879067455, 1117653225, 1329121167, 1580600348, 1879661180, 1118006284, 1329541028, 1581099650, 1880254953, 1118359371, 1329960921, 1581598990, 1880848772, 
+1118712486, 1330380848, 1582098370, 1881442639, 1119065629, 1330800808, 1582597790, 1882036552, 1119418800, 1331220801, 1583097249, 1882630512, 1119771998, 1331640828, 1583596747, 1883224519, 
+1120125225, 1332060887, 1584096284, 1883818572, 1120478479, 1332480980, 1584595861, 1884412673, 1120831761, 1332901105, 1585095478, 1885006820, 1121185071, 1333321264, 1585595134, 1885601014, 
+1121538409, 1333741456, 1586094829, 1886195255, 1121891775, 1334161681, 1586594563, 1886789543, 1122245168, 1334581939, 1587094337, 1887383878, 1122598589, 1335002230, 1587594150, 1887978259, 
+1122952039, 1335422554, 1588094003, 1888572687, 1123305515, 1335842911, 1588593895, 1889167162, 1123659020, 1336263302, 1589093826, 1889761684, 1124012553, 1336683725, 1589593796, 1890356253, 
+1124366113, 1337104182, 1590093806, 1890950868, 1124719701, 1337524671, 1590593855, 1891545530, 1125073317, 1337945194, 1591093944, 1892140239, 1125426961, 1338365749, 1591594072, 1892734994, 
+1125780632, 1338786338, 1592094239, 1893329796, 1126134332, 1339206960, 1592594445, 1893924645, 1126488059, 1339627615, 1593094691, 1894519541, 1126841814, 1340048302, 1593594976, 1895114483, 
+1127195596, 1340469023, 1594095300, 1895709472, 1127549407, 1340889777, 1594595663, 1896304508, 1127903245, 1341310564, 1595096066, 1896899590, 1128257111, 1341731383, 1595596508, 1897494720, 
+1128611004, 1342152236, 1596096989, 1898089895, 1128964926, 1342573122, 1596597509, 1898685118, 1129318875, 1342994041, 1597098069, 1899280387, 1129672852, 1343414993, 1597598668, 1899875703, 
+1130026856, 1343835977, 1598099306, 1900471065, 1130380888, 1344256995, 1598599983, 1901066474, 1130734948, 1344678046, 1599100700, 1901661930, 1131089036, 1345099130, 1599601455, 1902257432, 
+1131443152, 1345520246, 1600102250, 1902852981, 1131797295, 1345941396, 1600603084, 1903448576, 1132151466, 1346362578, 1601103957, 1904044218, 1132505664, 1346783794, 1601604870, 1904639907, 
+1132859891, 1347205042, 1602105821, 1905235642, 1133214144, 1347626323, 1602606812, 1905831424, 1133568426, 1348047638, 1603107842, 1906427252, 1133922735, 1348468985, 1603608911, 1907023127, 
+1134277072, 1348890365, 1604110019, 1907619048, 1134631437, 1349311778, 1604611167, 1908215016, 1134985830, 1349733224, 1605112353, 1908811031, 1135340250, 1350154703, 1605613579, 1909407092, 
+1135694697, 1350576214, 1606114844, 1910003199, 1136049173, 1350997759, 1606616147, 1910599354, 1136403676, 1351419337, 1607117490, 1911195554, 1136758206, 1351840947, 1607618872, 1911791801, 
+1137112765, 1352262590, 1608120294, 1912388095, 1137467350, 1352684266, 1608621754, 1912984435, 1137821964, 1353105975, 1609123253, 1913580821, 1138176605, 1353527717, 1609624791, 1914177255, 
+1138531274, 1353949492, 1610126369, 1914773734, 1138885970, 1354371299, 1610627985, 1915370260, 1139240695, 1354793140, 1611129641, 1915966832, 1139595446, 1355215013, 1611631336, 1916563451, 
+1139950226, 1355636919, 1612133069, 1917160116, 1140305032, 1356058858, 1612634842, 1917756828, 1140659867, 1356480830, 1613136654, 1918353586, 1141014729, 1356902834, 1613638505, 1918950391, 
+1141369619, 1357324871, 1614140395, 1919547242, 1141724536, 1357746942, 1614642323, 1920144139, 1142079481, 1358169045, 1615144291, 1920741083, 1142434453, 1358591180, 1615646298, 1921338073, 
+1142789453, 1359013349, 1616148344, 1921935109, 1143144481, 1359435550, 1616650429, 1922532192, 1143499536, 1359857784, 1617152553, 1923129322, 1143854619, 1360280051, 1617654715, 1923726497, 
+1144209729, 1360702351, 1618156917, 1924323719, 1144564867, 1361124683, 1618659158, 1924920987, 1144920032, 1361547049, 1619161438, 1925518302, 1145275225, 1361969447, 1619663756, 1926115663, 
+1145630446, 1362391877, 1620166114, 1926713070, 1145985694, 1362814341, 1620668510, 1927310524, 1146340969, 1363236837, 1621170946, 1927908024, 1146696272, 1363659366, 1621673420, 1928505570, 
+1147051603, 1364081928, 1622175934, 1929103162, 1147406961, 1364504522, 1622678486, 1929700801, 1147762347, 1364927149, 1623181077, 1930298486, 1148117760, 1365349809, 1623683707, 1930896217, 
+1148473201, 1365772502, 1624186376, 1931493995, 1148828669, 1366195227, 1624689084, 1932091819, 1149184164, 1366617985, 1625191831, 1932689689, 1149539688, 1367040775, 1625694617, 1933287605, 
+1149895238, 1367463599, 1626197441, 1933885567, 1150250816, 1367886455, 1626700305, 1934483576, 1150606422, 1368309344, 1627203207, 1935081631, 1150962055, 1368732265, 1627706148, 1935679732, 
+1151317716, 1369155219, 1628209128, 1936277880, 1151673404, 1369578206, 1628712147, 1936876073, 1152029119, 1370001225, 1629215205, 1937474313, 1152384862, 1370424277, 1629718301, 1938072599, 
+1152740633, 1370847362, 1630221436, 1938670931, 1153096430, 1371270479, 1630724611, 1939269310, 1153452256, 1371693629, 1631227824, 1939867734, 1153808108, 1372116812, 1631731075, 1940466205, 
+1154163989, 1372540027, 1632234366, 1941064721, 1154519896, 1372963275, 1632737695, 1941663284, 1154875831, 1373386556, 1633241064, 1942261893, 1155231794, 1373809869, 1633744471, 1942860549, 
+1155587784, 1374233215, 1634247916, 1943459250, 1155943801, 1374656593, 1634751401, 1944057997, 1156299846, 1375080004, 1635254924, 1944656791, 1156655918, 1375503447, 1635758486, 1945255630, 
+1157012018, 1375926924, 1636262087, 1945854516, 1157368145, 1376350432, 1636765727, 1946453448, 1157724299, 1376773974, 1637269405, 1947052426, 1158080481, 1377197547, 1637773122, 1947651450, 
+1158436690, 1377621154, 1638276878, 1948250520, 1158792926, 1378044793, 1638780673, 1948849636, 1159149190, 1378468465, 1639284506, 1949448798, 1159505482, 1378892169, 1639788378, 1950048006, 
+1159861800, 1379315905, 1640292288, 1950647260, 1160218146, 1379739675, 1640796238, 1951246560, 1160574520, 1380163476, 1641300226, 1951845907, 1160930920, 1380587311, 1641804253, 1952445299, 
+1161287349, 1381011178, 1642308318, 1953044737, 1161643804, 1381435077, 1642812422, 1953644221, 1162000287, 1381859009, 1643316565, 1954243752, 1162356797, 1382282973, 1643820747, 1954843328, 
+1162713335, 1382706970, 1644324967, 1955442950, 1163069899, 1383131000, 1644829226, 1956042618, 1163426492, 1383555061, 1645333523, 1956642332, 1163783111, 1383979156, 1645837859, 1957242092, 
+1164139758, 1384403283, 1646342234, 1957841898, 1164496432, 1384827442, 1646846647, 1958441750, 1164853133, 1385251634, 1647351099, 1959041648, 1165209862, 1385675858, 1647855590, 1959641592, 
+1165566618, 1386100115, 1648360119, 1960241582, 1165923402, 1386524405, 1648864687, 1960841618, 1166280212, 1386948726, 1649369294, 1961441699, 1166637050, 1387373081, 1649873939, 1962041827, 
+1166993915, 1387797467, 1650378622, 1962642000, 1167350808, 1388221886, 1650883345, 1963242219, 1167707728, 1388646338, 1651388105, 1963842484, 1168064675, 1389070822, 1651892905, 1964442795, 
+1168421649, 1389495338, 1652397743, 1965043152, 1168778651, 1389919887, 1652902619, 1965643555, 1169135680, 1390344469, 1653407534, 1966244004, 1169492736, 1390769082, 1653912488, 1966844498, 
+1169849819, 1391193728, 1654417480, 1967445038, 1170206930, 1391618407, 1654922511, 1968045625, 1170564068, 1392043118, 1655427580, 1968646257, 1170921233, 1392467861, 1655932688, 1969246934, 
+1171278425, 1392892637, 1656437834, 1969847658, 1171635645, 1393317445, 1656943019, 1970448427, 1171992892, 1393742285, 1657448242, 1971049242, 1172350166, 1394167158, 1657953504, 1971650103, 
+1172707467, 1394592063, 1658458804, 1972251010, 1173064795, 1395017001, 1658964143, 1972851963, 1173422151, 1395441971, 1659469520, 1973452961, 1173779534, 1395866973, 1659974936, 1974054005, 
+1174136944, 1396292008, 1660480390, 1974655095, 1174494381, 1396717075, 1660985883, 1975256230, 1174851846, 1397142174, 1661491414, 1975857411, 1175209338, 1397567306, 1661996984, 1976458638, 
+1175566857, 1397992470, 1662502592, 1977059911, 1175924403, 1398417666, 1663008239, 1977661230, 1176281976, 1398842895, 1663513924, 1978262594, 1176639576, 1399268156, 1664019647, 1978864004, 
+1176997204, 1399693449, 1664525409, 1979465459, 1177354859, 1400118775, 1665031209, 1980066960, 1177712541, 1400544133, 1665537048, 1980668507, 1178070250, 1400969523, 1666042925, 1981270100, 
+1178427986, 1401394946, 1666548840, 1981871738, 1178785750, 1401820400, 1667054794, 1982473422, 1179143540, 1402245888, 1667560786, 1983075152, 1179501358, 1402671407, 1668066817, 1983676927, 
+1179859203, 1403096959, 1668572886, 1984278748, 1180217075, 1403522542, 1669078994, 1984880615, 1180574974, 1403948159, 1669585139, 1985482527, 1180932900, 1404373807, 1670091323, 1986084485, 
+1181290853, 1404799488, 1670597546, 1986686488, 1181648834, 1405225201, 1671103807, 1987288537, 1182006841, 1405650946, 1671610106, 1987890632, 1182364876, 1406076723, 1672116444, 1988492772, 
+1182722938, 1406502533, 1672622819, 1989094958, 1183081027, 1406928375, 1673129234, 1989697189, 1183439143, 1407354249, 1673635686, 1990299466, 1183797286, 1407780155, 1674142177, 1990901788, 
+1184155456, 1408206094, 1674648706, 1991504156, 1184513654, 1408632065, 1675155274, 1992106570, 1184871878, 1409058068, 1675661879, 1992709029, 1185230129, 1409484103, 1676168523, 1993311534, 
+1185588408, 1409910170, 1676675206, 1993914084, 1185946713, 1410336270, 1677181926, 1994516680, 1186305046, 1410762401, 1677688685, 1995119321, 1186663406, 1411188565, 1678195482, 1995722008, 
+1187021793, 1411614761, 1678702318, 1996324740, 1187380206, 1412040990, 1679209192, 1996927518, 1187738647, 1412467250, 1679716104, 1997530342, 1188097115, 1412893543, 1680223054, 1998133210, 
+1188455610, 1413319867, 1680730042, 1998736125, 1188814132, 1413746224, 1681237069, 1999339084, 1189172681, 1414172613, 1681744134, 1999942089, 1189531257, 1414599035, 1682251237, 2000545140, 
+1189889860, 1415025488, 1682758378, 2001148236, 1190248490, 1415451973, 1683265558, 2001751378, 1190607148, 1415878491, 1683772776, 2002354565, 1190965832, 1416305041, 1684280031, 2002957797, 
+1191324543, 1416731623, 1684787326, 2003561075, 1191683281, 1417158237, 1685294658, 2004164398, 1192042046, 1417584883, 1685802029, 2004767767, 1192400838, 1418011561, 1686309437, 2005371181, 
+1192759657, 1418438271, 1686816884, 2005974640, 1193118504, 1418865013, 1687324369, 2006578145, 1193477377, 1419291788, 1687831892, 2007181695, 1193836277, 1419718594, 1688339454, 2007785291, 
+1194195204, 1420145433, 1688847053, 2008388932, 1194554158, 1420572304, 1689354691, 2008992618, 1194913139, 1420999206, 1689862367, 2009596350, 1195272147, 1421426141, 1690370081, 2010200127, 
+1195631182, 1421853108, 1690877833, 2010803949, 1195990244, 1422280107, 1691385623, 2011407817, 1196349332, 1422707138, 1691893451, 2012011730, 1196708448, 1423134201, 1692401318, 2012615688, 
+1197067591, 1423561296, 1692909222, 2013219692, 1197426761, 1423988423, 1693417165, 2013823741, 1197785957, 1424415583, 1693925145, 2014427835, 1198145181, 1424842774, 1694433164, 2015031975, 
+1198504431, 1425269997, 1694941221, 2015636160, 1198863709, 1425697252, 1695449316, 2016240390, 1199223013, 1426124539, 1695957449, 2016844665, 1199582344, 1426551859, 1696465620, 2017448986, 
+1199941702, 1426979210, 1696973829, 2018053352, 1200301087, 1427406593, 1697482076, 2018657763, 1200660499, 1427834008, 1697990362, 2019262219, 1201019938, 1428261455, 1698498685, 2019866721, 
+1201379404, 1428688935, 1699007046, 2020471268, 1201738896, 1429116446, 1699515446, 2021075860, 1202098416, 1429543989, 1700023883, 2021680497, 1202457962, 1429971564, 1700532358, 2022285180, 
+1202817535, 1430399171, 1701040872, 2022889908, 1203177136, 1430826810, 1701549423, 2023494681, 1203536763, 1431254481, 1702058013, 2024099499, 1203896417, 1431682184, 1702566640, 2024704362, 
+1204256097, 1432109919, 1703075305, 2025309270, 1204615805, 1432537686, 1703584009, 2025914224, 1204975539, 1432965485, 1704092750, 2026519223, 1205335301, 1433393315, 1704601529, 2027124267, 
+1205695089, 1433821178, 1705110347, 2027729356, 1206054904, 1434249073, 1705619202, 2028334490, 1206414746, 1434676999, 1706128095, 2028939670, 1206774614, 1435104958, 1706637026, 2029544894, 
+1207134510, 1435532948, 1707145995, 2030150164, 1207494432, 1435960970, 1707655002, 2030755479, 1207854381, 1436389024, 1708164047, 2031360839, 1208214357, 1436817110, 1708673130, 2031966244, 
+1208574360, 1437245228, 1709182251, 2032571694, 1208934390, 1437673378, 1709691410, 2033177189, 1209294446, 1438101559, 1710200607, 2033782729, 1209654529, 1438529773, 1710709841, 2034388315, 
+1210014639, 1438958018, 1711219114, 2034993945, 1210374776, 1439386296, 1711728424, 2035599621, 1210734940, 1439814605, 1712237772, 2036205341, 1211095130, 1440242946, 1712747158, 2036811107, 
+1211455347, 1440671318, 1713256582, 2037416917, 1211815591, 1441099723, 1713766044, 2038022773, 1212175862, 1441528160, 1714275544, 2038628674, 1212536159, 1441956628, 1714785081, 2039234620, 
+1212896484, 1442385128, 1715294657, 2039840610, 1213256835, 1442813660, 1715804270, 2040446646, 1213617212, 1443242224, 1716313921, 2041052727, 1213977617, 1443670820, 1716823610, 2041658853, 
+1214338048, 1444099447, 1717333337, 2042265023, 1214698506, 1444528106, 1717843102, 2042871239, 1215058991, 1444956797, 1718352904, 2043477500, 1215419503, 1445385520, 1718862744, 2044083805, 
+1215780041, 1445814275, 1719372623, 2044690156, 1216140606, 1446243061, 1719882538, 2045296552, 1216501197, 1446671879, 1720392492, 2045902992, 1216861816, 1447100729, 1720902484, 2046509478, 
+1217222461, 1447529611, 1721412513, 2047116008, 1217583133, 1447958525, 1721922580, 2047722583, 1217943831, 1448387470, 1722432685, 2048329204, 1218304557, 1448816447, 1722942827, 2048935869, 
+1218665309, 1449245456, 1723453008, 2049542579, 1219026087, 1449674497, 1723963226, 2050149334, 1219386893, 1450103569, 1724473482, 2050756134, 1219747725, 1450532673, 1724983775, 2051362979, 
+1220108584, 1450961809, 1725494107, 2051969868, 1220469469, 1451390976, 1726004476, 2052576803, 1220830381, 1451820176, 1726514882, 2053183782, 1221191320, 1452249407, 1727025327, 2053790807, 
+1221552285, 1452678669, 1727535809, 2054397876, 1221913278, 1453107964, 1728046329, 2055004990, 1222274296, 1453537290, 1728556887, 2055612149, 1222635342, 1453966648, 1729067482, 2056219352, 
+1222996414, 1454396037, 1729578115, 2056826601, 1223357513, 1454825458, 1730088786, 2057433894, 1223718638, 1455254911, 1730599495, 2058041232, 1224079790, 1455684396, 1731110241, 2058648615, 
+1224440969, 1456113912, 1731621025, 2059256043, 1224802174, 1456543460, 1732131846, 2059863516, 1225163406, 1456973040, 1732642705, 2060471033, 1225524665, 1457402651, 1733153602, 2061078595, 
+1225885950, 1457832294, 1733664537, 2061686202, 1226247262, 1458261969, 1734175509, 2062293854, 1226608600, 1458691675, 1734686519, 2062901550, 1226969966, 1459121413, 1735197566, 2063509291, 
+1227331357, 1459551182, 1735708651, 2064117077, 1227692776, 1459980984, 1736219774, 2064724908, 1228054220, 1460410817, 1736730934, 2065332783, 1228415692, 1460840681, 1737242132, 2065940704, 
+1228777190, 1461270577, 1737753367, 2066548668, 1229138715, 1461700505, 1738264640, 2067156678, 1229500266, 1462130464, 1738775951, 2067764732, 1229861844, 1462560455, 1739287299, 2068372831, 
+1230223448, 1462990478, 1739798685, 2068980975, 1230585079, 1463420532, 1740310109, 2069589164, 1230946737, 1463850618, 1740821570, 2070197397, 1231308421, 1464280735, 1741333068, 2070805674, 
+1231670132, 1464710884, 1741844604, 2071413997, 1232031869, 1465141064, 1742356178, 2072022364, 1232393633, 1465571276, 1742867789, 2072630776, 1232755423, 1466001520, 1743379438, 2073239232, 
+1233117240, 1466431795, 1743891125, 2073847733, 1233479083, 1466862102, 1744402849, 2074456279, 1233840953, 1467292441, 1744914610, 2075064869, 1234202850, 1467722810, 1745426409, 2075673504, 
+1234564773, 1468153212, 1745938246, 2076282184, 1234926723, 1468583645, 1746450120, 2076890908, 1235288699, 1469014109, 1746962031, 2077499677, 1235650701, 1469444606, 1747473980, 2078108490, 
+1236012730, 1469875133, 1747985967, 2078717348, 1236374786, 1470305692, 1748497991, 2079326251, 1236736868, 1470736283, 1749010052, 2079935198, 1237098977, 1471166905, 1749522151, 2080544190, 
+1237461112, 1471597559, 1750034287, 2081153226, 1237823274, 1472028244, 1750546461, 2081762307, 1238185462, 1472458961, 1751058673, 2082371432, 1238547676, 1472889709, 1751570922, 2082980602, 
+1238909918, 1473320489, 1752083208, 2083589817, 1239272185, 1473751300, 1752595532, 2084199076, 1239634479, 1474182143, 1753107893, 2084808380, 1239996800, 1474613017, 1753620292, 2085417728, 
+1240359147, 1475043923, 1754132728, 2086027120, 1240721520, 1475474860, 1754645201, 2086636557, 1241083920, 1475905828, 1755157712, 2087246039, 1241446347, 1476336828, 1755670260, 2087855565, 
+1241808799, 1476767860, 1756182846, 2088465136, 1242171279, 1477198923, 1756695469, 2089074751, 1242533785, 1477630017, 1757208130, 2089684411, 1242896317, 1478061143, 1757720828, 2090294115, 
+1243258875, 1478492300, 1758233563, 2090903863, 1243621460, 1478923489, 1758746336, 2091513656, 1243984072, 1479354709, 1759259146, 2092123493, 1244346710, 1479785961, 1759771993, 2092733375, 
+1244709374, 1480217244, 1760284878, 2093343302, 1245072065, 1480648558, 1760797800, 2093953272, 1245434782, 1481079904, 1761310760, 2094563288, 1245797526, 1481511281, 1761823757, 2095173347, 
+1246160296, 1481942690, 1762336791, 2095783451, 1246523092, 1482374130, 1762849863, 2096393599, 1246885915, 1482805602, 1763362972, 2097003792, 1247248764, 1483237105, 1763876118, 2097614029, 
+1247611640, 1483668639, 1764389302, 2098224311, 1247974542, 1484100204, 1764902522, 2098834637, 1248337470, 1484531801, 1765415781, 2099445007, 1248700425, 1484963430, 1765929076, 2100055422, 
+1249063406, 1485395089, 1766442409, 2100665881, 1249426413, 1485826781, 1766955779, 2101276384, 1249789447, 1486258503, 1767469186, 2101886932, 1250152508, 1486690257, 1767982631, 2102497524, 
+1250515594, 1487122042, 1768496113, 2103108161, 1250878707, 1487553858, 1769009632, 2103718841, 1251241846, 1487985706, 1769523189, 2104329566, 1251605012, 1488417585, 1770036783, 2104940336, 
+1251968204, 1488849496, 1770550414, 2105551150, 1252331422, 1489281438, 1771064082, 2106162007, 1252694667, 1489713411, 1771577788, 2106772910, 1253057938, 1490145415, 1772091530, 2107383856, 
+1253421235, 1490577451, 1772605310, 2107994847, 1253784559, 1491009518, 1773119128, 2108605882, 1254147909, 1491441617, 1773632982, 2109216962, 1254511285, 1491873746, 1774146874, 2109828085, 
+1254874688, 1492305907, 1774660803, 2110439253, 1255238117, 1492738100, 1775174769, 2111050466, 1255601572, 1493170323, 1775688772, 2111661722, 1255965054, 1493602578, 1776202813, 2112273023, 
+1256328562, 1494034864, 1776716890, 2112884368, 1256692096, 1494467182, 1777231005, 2113495757, 1257055656, 1494899530, 1777745157, 2114107190, 1257419243, 1495331910, 1778259347, 2114718668, 
+1257782856, 1495764321, 1778773573, 2115330189, 1258146495, 1496196764, 1779287837, 2115941755, 1258510161, 1496629237, 1779802138, 2116553365, 1258873853, 1497061742, 1780316476, 2117165020, 
+1259237571, 1497494278, 1780830851, 2117776718, 1259601315, 1497926846, 1781345263, 2118388461, 1259965086, 1498359445, 1781859712, 2119000248, 1260328883, 1498792074, 1782374199, 2119612079, 
+1260692706, 1499224735, 1782888722, 2120223954, 1261056555, 1499657428, 1783403283, 2120835873, 1261420431, 1500090151, 1783917881, 2121447837, 1261784333, 1500522906, 1784432516, 2122059844, 
+1262148261, 1500955692, 1784947188, 2122671896, 1262512215, 1501388509, 1785461897, 2123283992, 1262876196, 1501821357, 1785976644, 2123896132, 1263240203, 1502254237, 1786491427, 2124508316, 
+1263604236, 1502687148, 1787006248, 2125120544, 1263968295, 1503120089, 1787521105, 2125732816, 1264332380, 1503553062, 1788036000, 2126345133, 1264696492, 1503986067, 1788550931, 2126957493, 
+1265060630, 1504419102, 1789065900, 2127569898, 1265424794, 1504852169, 1789580906, 2128182346, 1265788984, 1505285266, 1790095949, 2128794839, 1266153201, 1505718395, 1790611029, 2129407376, 
+1266517444, 1506151555, 1791126146, 2130019956, 1266881713, 1506584746, 1791641300, 2130632581, 1267246008, 1507017969, 1792156491, 2131245250, 1267610329, 1507451222, 1792671719, 2131857963, 
+1267974676, 1507884507, 1793186984, 2132470720, 1268339050, 1508317823, 1793702286, 2133083521, 1268703450, 1508751169, 1794217625, 2133696366, 1269067876, 1509184547, 1794733002, 2134309255, 
+1269432328, 1509617956, 1795248415, 2134922188, 1269796806, 1510051397, 1795763865, 2135535165, 1270161311, 1510484868, 1796279352, 2136148186, 1270525841, 1510918370, 1796794876, 2136761251, 
+1270890398, 1511351904, 1797310437, 2137374360, 1271254981, 1511785468, 1797826035, 2137987513, 1271619590, 1512219064, 1798341670, 2138600709, 1271984225, 1512652691, 1798857342, 2139213950, 
+1272348886, 1513086348, 1799373051, 2139827235, 1272713574, 1513520037, 1799888797, 2140440564, 1273078287, 1513953757, 1800404580, 2141053936, 1273443027, 1514387508, 1800920400, 2141667353, 
+1273807793, 1514821290, 1801436257, 2142280814, 1274172585, 1515255104, 1801952150, 2142894318, 1274537403, 1515688948, 1802468081, 2143507866, 1274902247, 1516122823, 1802984048, 2144121459, 
+1275267117, 1516556729, 1803500053, 2144735095, 1275632014, 1516990667, 1804016094, 2145348775, 1275996936, 1517424635, 1804532172, 2145962499, 1276361885, 1517858634, 1805048288, 2146576267, 
+1276726859, 1518292665, 1805564440, 2147190078, 1277091860, 1518726726, 1806080629, 1073901967, 1277456887, 1519160819, 1806596854, 1074208917, 1277821940, 1519594942, 1807113117, 1074515888, 
+1278187018, 1520029097, 1807629417, 1074822882, 1278552124, 1520463282, 1808145753, 1075129897, 1278917255, 1520897499, 1808662127, 1075436935, 1279282412, 1521331746, 1809178537, 1075743994, 
+1279647595, 1521766025, 1809694984, 1076051075, 1280012804, 1522200334, 1810211468, 1076358179, 1280378040, 1522634674, 1810727988, 1076665304, 1280743301, 1523069046, 1811244546, 1076972451, 
+1281108588, 1523503448, 1811761140, 1077279619, 1281473902, 1523937882, 1812277772, 1077586810, 1281839241, 1524372346, 1812794440, 1077894023, 1282204607, 1524806841, 1813311145, 1078201257, 
+1282569998, 1525241367, 1813827886, 1078508514, 1282935416, 1525675925, 1814344665, 1078815792, 1283300859, 1526110513, 1814861480, 1079123092, 1283666329, 1526545132, 1815378332, 1079430414, 
+1284031825, 1526979782, 1815895221, 1079737758, 1284397346, 1527414463, 1816412147, 1080045124, 1284762894, 1527849175, 1816929109, 1080352512, 1285128468, 1528283917, 1817446108, 1080659922, 
+1285494067, 1528718691, 1817963144, 1080967353, 1285859693, 1529153496, 1818480217, 1081274806, 1286225345, 1529588331, 1818997326, 1081582281, 1286591022, 1530023198, 1819514473, 1081889778, 
+1286956726, 1530458095, 1820031656, 1082197297, 1287322455, 1530893023, 1820548875, 1082504838, 1287688211, 1531327982, 1821066132, 1082812401, 1288053992, 1531762972, 1821583425, 1083119985, 
+1288419800, 1532197993, 1822100755, 1083427591, 1288785633, 1532633045, 1822618122, 1083735219, 1289151493, 1533068128, 1823135525, 1084042869, 1289517378, 1533503241, 1823652965, 1084350541, 
+1289883290, 1533938386, 1824170442, 1084658234, 1290249227, 1534373561, 1824687956, 1084965950, 1290615190, 1534808767, 1825205506, 1085273687, 1290981179, 1535244004, 1825723093, 1085581446, 
+1291347195, 1535679272, 1826240716, 1085889227, 1291713236, 1536114570, 1826758377, 1086197029, 1292079303, 1536549900, 1827276074, 1086504854, 1292445396, 1536985260, 1827793807, 1086812700, 
+1292811515, 1537420651, 1828311577, 1087120568, 1293177659, 1537856073, 1828829384, 1087428458, 1293543830, 1538291526, 1829347228, 1087736370, 1293910027, 1538727010, 1829865108, 1088044303, 
+1294276249, 1539162524, 1830383025, 1088352258, 1294642498, 1539598070, 1830900979, 1088660235, 1295008772, 1540033646, 1831418969, 1088968234, 1295375072, 1540469253, 1831936996, 1089276255, 
+1295741398, 1540904890, 1832455059, 1089584297, 1296107750, 1541340559, 1832973159, 1089892361, 1296474128, 1541776258, 1833491296, 1090200447, 1296840532, 1542211988, 1834009469, 1090508555, 
+1297206962, 1542647749, 1834527679, 1090816684, 1297573418, 1543083540, 1835045925, 1091124835, 1297939899, 1543519363, 1835564208, 1091433008, 1298306406, 1543955216, 1836082528, 1091741203, 
+1298672940, 1544391100, 1836600884, 1092049419, 1299039499, 1544827014, 1837119277, 1092357658, 1299406083, 1545262960, 1837637706, 1092665918, 1299772694, 1545698936, 1838156172, 1092974199, 
+1300139331, 1546134943, 1838674675, 1093282503, 1300505993, 1546570980, 1839193214, 1093590828, 1300872682, 1547007049, 1839711789, 1093899175, 1301239396, 1547443148, 1840230402, 1094207543, 
+1301606136, 1547879278, 1840749050, 1094515934, 1301972902, 1548315438, 1841267735, 1094824346, 1302339693, 1548751630, 1841786457, 1095132780, 1302706511, 1549187852, 1842305216, 1095441235, 
+1303073354, 1549624104, 1842824010, 1095749712, 1303440223, 1550060388, 1843342842, 1096058211, 1303807118, 1550496702, 1843861709, 1096366732, 1304174039, 1550933047, 1844380614, 1096675274, 
+1304540986, 1551369422, 1844899555, 1096983838, 1304907958, 1551805828, 1845418532, 1097292424, 1305274956, 1552242265, 1845937546, 1097601032, 1305641980, 1552678733, 1846456596, 1097909661, 
+1306009030, 1553115231, 1846975683, 1098218312, 1306376106, 1553551760, 1847494806, 1098526984, 1306743207, 1553988319, 1848013966, 1098835678, 1307110334, 1554424909, 1848533162, 1099144394, 
+1307477487, 1554861530, 1849052395, 1099453132, 1307844666, 1555298182, 1849571664, 1099761891, 1308211870, 1555734864, 1850090969, 1100070672, 1308579101, 1556171577, 1850610311, 1100379475, 
+1308946357, 1556608320, 1851129690, 1100688299, 1309313638, 1557045094, 1851649105, 1100997145, 1309680946, 1557481899, 1852168556, 1101306013, 1310048279, 1557918735, 1852688044, 1101614902, 
+1310415638, 1558355601, 1853207568, 1101923813, 1310783023, 1558792497, 1853727128, 1102232745, 1311150434, 1559229424, 1854246725, 1102541699, 1311517870, 1559666382, 1854766359, 1102850675, 
+1311885332, 1560103371, 1855286029, 1103159673, 1312252820, 1560540390, 1855805735, 1103468692, 1312620333, 1560977439, 1856325477, 1103777733, 1312987872, 1561414520, 1856845256, 1104086795, 
+1313355437, 1561851630, 1857365072, 1104395879, 1313723028, 1562288772, 1857884923, 1104704985, 1314090644, 1562725944, 1858404811, 1105014112, 1314458286, 1563163146, 1858924736, 1105323261, 
+1314825954, 1563600380, 1859444696, 1105632431, 1315193648, 1564037643, 1859964694, 1105941624, 1315561367, 1564474938, 1860484727, 1106250837, 1315929112, 1564912262, 1861004797, 1106560073, 
+1316296882, 1565349618, 1861524903, 1106869330, 1316664678, 1565787004, 1862045045, 1107178608, 1317032500, 1566224420, 1862565224, 1107487908, 1317400348, 1566661867, 1863085439, 1107797230, 
+1317768221, 1567099345, 1863605691, 1108106574, 1318136120, 1567536853, 1864125979, 1108415938, 1318504045, 1567974392, 1864646303, 1108725325, 1318871995, 1568411961, 1865166663, 1109034733, 
+1319239971, 1568849560, 1865687060, 1109344163, 1319607973, 1569287191, 1866207493, 1109653614, 1319976000, 1569724851, 1866727962, 1109963087, 1320344053, 1570162543, 1867248467, 1110272581, 
+1320712132, 1570600264, 1867769009, 1110582097, 1321080236, 1571038016, 1868289587, 1110891635, 1321448366, 1571475799, 1868810201, 1111201194, 1321816522, 1571913612, 1869330852, 1111510775, 
+1322184703, 1572351456, 1869851539, 1111820377, 1322552910, 1572789330, 1870372262, 1112130001, 1322921142, 1573227235, 1870893021, 1112439646, 1323289400, 1573665170, 1871413817, 1112749313, 
+1323657684, 1574103136, 1871934649, 1113059002, 1324025993, 1574541132, 1872455517, 1113368712, 1324394328, 1574979158, 1872976421, 1113678443, 1324762689, 1575417215, 1873497362, 1113988196, 
+1325131075, 1575855303, 1874018338, 1114297971, 1325499487, 1576293421, 1874539351, 1114607767, 1325867924, 1576731569, 1875060400, 1114917585, 1326236387, 1577169748, 1875581486, 1115227424, 
+1326604876, 1577607957, 1876102607, 1115537284, 1326973390, 1578046197, 1876623765, 1115847167, 1327341930, 1578484467, 1877144959, 1116157070, 1327710495, 1578922767, 1877666189, 1116466996, 
+1328079086, 1579361098, 1878187455, 1116776942, 1328447702, 1579799459, 1878708757, 1117086911, 1328816344, 1580237851, 1879230096, 1117396900, 1329185012, 1580676273, 1879751471, 1117706912, 
+1329553705, 1581114726, 1880272882, 1118016945, 1329922424, 1581553209, 1880794329, 1118326999, 1330291168, 1581991722, 1881315812, 1118637075, 1330659938, 1582430266, 1881837331, 1118947172, 
+1331028733, 1582868840, 1882358887, 1119257291, 1331397554, 1583307445, 1882880478, 1119567431, 1331766401, 1583746079, 1883402106, 1119877592, 1332135273, 1584184745, 1883923770, 1120187776, 
+1332504170, 1584623440, 1884445470, 1120497980, 1332873094, 1585062166, 1884967206, 1120808206, 1333242042, 1585500923, 1885488978, 1121118454, 1333611016, 1585939709, 1886010786, 1121428723, 
+1333980016, 1586378526, 1886532631, 1121739014, 1334349041, 1586817374, 1887054511, 1122049326, 1334718092, 1587256252, 1887576428, 1122359659, 1335087168, 1587695160, 1888098380, 1122670014, 
+1335456270, 1588134098, 1888620369, 1122980390, 1335825397, 1588573067, 1889142394, 1123290788, 1336194550, 1589012066, 1889664455, 1123601207, 1336563728, 1589451095, 1890186552, 1123911648, 
+1336932932, 1589890155, 1890708684, 1124222110, 1337302161, 1590329245, 1891230853, 1124532594, 1337671416, 1590768365, 1891753059, 1124843099, 1338040696, 1591207516, 1892275300, 1125153625, 
+1338410002, 1591646697, 1892797577, 1125464173, 1338779333, 1592085908, 1893319890, 1125774742, 1339148690, 1592525150, 1893842239, 1126085333, 1339518072, 1592964422, 1894364624, 1126395945, 
+1339887479, 1593403724, 1894887045, 1126706578, 1340256912, 1593843056, 1895409503, 1127017233, 1340626371, 1594282419, 1895931996, 1127327910, 1340995855, 1594721812, 1896454525, 1127638607, 
+1341365364, 1595161235, 1896977090, 1127949326, 1341734899, 1595600689, 1897499692, 1128260067, 1342104460, 1596040172, 1898022329, 1128570829, 1342474045, 1596479686, 1898545002, 1128881612, 
+1342843656, 1596919231, 1899067711, 1129192417, 1343213293, 1597358805, 1899590456, 1129503243, 1343582955, 1597798410, 1900113237, 1129814091, 1343952643, 1598238045, 1900636054, 1130124959, 
+1344322356, 1598677710, 1901158907, 1130435850, 1344692094, 1599117406, 1901681796, 1130746761, 1345061858, 1599557131, 1902204721, 1131057694, 1345431647, 1599996887, 1902727682, 1131368649, 
+1345801461, 1600436673, 1903250679, 1131679625, 1346171301, 1600876490, 1903773712, 1131990622, 1346541167, 1601316336, 1904296780, 1132301640, 1346911058, 1601756213, 1904819885, 1132612680, 
+1347280974, 1602196120, 1905343025, 1132923741, 1347650915, 1602636057, 1905866202, 1133234824, 1348020882, 1603076024, 1906389414, 1133545928, 1348390875, 1603516022, 1906912662, 1133857053, 
+1348760892, 1603956050, 1907435946, 1134168199, 1349130935, 1604396107, 1907959266, 1134479367, 1349501004, 1604836196, 1908482622, 1134790557, 1349871098, 1605276314, 1909006014, 1135101767, 
+1350241217, 1605716462, 1909529442, 1135412999, 1350611362, 1606156641, 1910052905, 1135724252, 1350981532, 1606596850, 1910576404, 1136035527, 1351351727, 1607037088, 1911099940, 1136346823, 
+1351721948, 1607477358, 1911623511, 1136658140, 1352092194, 1607917657, 1912147118, 1136969479, 1352462465, 1608357986, 1912670761, 1137280839, 1352832762, 1608798346, 1913194439, 1137592220, 
+1353203084, 1609238735, 1913718154, 1137903622, 1353573431, 1609679155, 1914241904, 1138215046, 1353943804, 1610119605, 1914765690, 1138526491, 1354314202, 1610560085, 1915289512, 1138837957, 
+1354684625, 1611000595, 1915813370, 1139149445, 1355055074, 1611441135, 1916337263, 1139460954, 1355425548, 1611881706, 1916861193, 1139772484, 1355796047, 1612322306, 1917385158, 1140084036, 
+1356166572, 1612762937, 1917909159, 1140395609, 1356537122, 1613203597, 1918433196, 1140707203, 1356907697, 1613644288, 1918957268, 1141018818, 1357278298, 1614085009, 1919481377, 1141330455, 
+1357648924, 1614525760, 1920005521, 1141642113, 1358019575, 1614966541, 1920529701, 1141953792, 1358390251, 1615407352, 1921053916, 1142265493, 1358760953, 1615848193, 1921578168, 1142577215, 
+1359131680, 1616289064, 1922102455, 1142888958, 1359502432, 1616729966, 1922626778, 1143200722, 1359873210, 1617170897, 1923151137, 1143512508, 1360244013, 1617611858, 1923675531, 1143824314, 
+1360614841, 1618052850, 1924199961, 1144136142, 1360985695, 1618493871, 1924724427, 1144447992, 1361356573, 1618934923, 1925248929, 1144759862, 1361727477, 1619376005, 1925773466, 1145071754, 
+1362098406, 1619817116, 1926298040, 1145383667, 1362469361, 1620258258, 1926822648, 1145695601, 1362840341, 1620699430, 1927347293, 1146007557, 1363211345, 1621140631, 1927871973, 1146319534, 
+1363582376, 1621581863, 1928396689, 1146631532, 1363953431, 1622023125, 1928921441, 1146943551, 1364324512, 1622464417, 1929446228, 1147255591, 1364695618, 1622905738, 1929971051, 1147567653, 
+1365066749, 1623347090, 1930495910, 1147879736, 1365437905, 1623788472, 1931020804, 1148191840, 1365809087, 1624229884, 1931545734, 1148503965, 1366180294, 1624671326, 1932070700, 1148816112, 
+1366551526, 1625112797, 1932595701, 1149128279, 1366922783, 1625554299, 1933120738, 1149440468, 1367294065, 1625995831, 1933645811, 1149752678, 1367665373, 1626437393, 1934170919, 1150064909, 
+1368036706, 1626878984, 1934696063, 1150377162, 1368408064, 1627320606, 1935221243, 1150689436, 1368779447, 1627762258, 1935746458, 1151001730, 1369150856, 1628203939, 1936271709, 1151314047, 
+1369522289, 1628645651, 1936796996, 1151626384, 1369893748, 1629087392, 1937322318, 1151938742, 1370265232, 1629529164, 1937847675, 1152251122, 1370636741, 1629970965, 1938373069, 1152563522, 
+1371008276, 1630412796, 1938898498, 1152875944, 1371379835, 1630854658, 1939423962, 1153188387, 1371751420, 1631296549, 1939949462, 1153500852, 1372123030, 1631738470, 1940474998, 1153813337, 
+1372494665, 1632180421, 1941000569, 1154125844, 1372866325, 1632622402, 1941526176, 1154438371, 1373238011, 1633064413, 1942051819, 1154750920, 1373609721, 1633506453, 1942577497, 1155063490, 
+1373981457, 1633948524, 1943103210, 1155376082, 1374353217, 1634390625, 1943628960, 1155688694, 1374725003, 1634832755, 1944154744, 1156001327, 1375096815, 1635274916, 1944680565, 1156313982, 
+1375468651, 1635717106, 1945206420, 1156626658, 1375840512, 1636159326, 1945732312, 1156939355, 1376212399, 1636601576, 1946258239, 1157252073, 1376584310, 1637043856, 1946784201, 1157564812, 
+1376956247, 1637486166, 1947310199, 1157877572, 1377328209, 1637928506, 1947836233, 1158190353, 1377700196, 1638370875, 1948362302, 1158503156, 1378072208, 1638813274, 1948888406, 1158815979, 
+1378444245, 1639255704, 1949414546, 1159128824, 1378816307, 1639698163, 1949940722, 1159441690, 1379188395, 1640140652, 1950466933, 1159754577, 1379560507, 1640583171, 1950993179, 1160067485, 
+1379932645, 1641025719, 1951519461, 1160380414, 1380304807, 1641468298, 1952045779, 1160693364, 1380676995, 1641910906, 1952572132, 1161006336, 1381049208, 1642353544, 1953098520, 1161319328, 
+1381421446, 1642796212, 1953624944, 1161632342, 1381793709, 1643238910, 1954151403, 1161945376, 1382165997, 1643681638, 1954677898, 1162258432, 1382538310, 1644124395, 1955204429, 1162571509, 
+1382910648, 1644567182, 1955730994, 1162884607, 1383283011, 1645009999, 1956257595, 1163197726, 1383655400, 1645452846, 1956784232, 1163510866, 1384027813, 1645895723, 1957310904, 1163824027, 
+1384400252, 1646338629, 1957837612, 1164137209, 1384772715, 1646781566, 1958364355, 1164450412, 1385145204, 1647224532, 1958891133, 1164763636, 1385517717, 1647667527, 1959417947, 1165076882, 
+1385890256, 1648110553, 1959944796, 1165390148, 1386262820, 1648553608, 1960471680, 1165703436, 1386635408, 1648996693, 1960998600, 1166016744, 1387008022, 1649439808, 1961525556, 1166330074, 
+1387380661, 1649882953, 1962052547, 1166643424, 1387753325, 1650326127, 1962579573, 1166956796, 1388126013, 1650769332, 1963106634, 1167270189, 1388498727, 1651212565, 1963633731, 1167583602, 
+1388871466, 1651655829, 1964160864, 1167897037, 1389244230, 1652099123, 1964688031, 1168210493, 1389617019, 1652542446, 1965215234, 1168523970, 1389989832, 1652985799, 1965742473, 1168837467, 
+1390362671, 1653429181, 1966269746, 1169150986, 1390735535, 1653872594, 1966797056, 1169464526, 1391108424, 1654316036, 1967324400, 1169778087, 1391481338, 1654759507, 1967851780, 1170091669, 
+1391854277, 1655203009, 1968379195, 1170405272, 1392227240, 1655646540, 1968906645, 1170718896, 1392600229, 1656090101, 1969434131, 1171032541, 1392973243, 1656533692, 1969961652, 1171346207, 
+1393346282, 1656977312, 1970489209, 1171659893, 1393719345, 1657420962, 1971016800, 1171973601, 1394092434, 1657864642, 1971544427, 1172287330, 1394465548, 1658308351, 1972072090, 1172601080, 
+1394838686, 1658752090, 1972599787, 1172914851, 1395211850, 1659195859, 1973127520, 1173228643, 1395585038, 1659639657, 1973655289, 1173542456, 1395958252, 1660083485, 1974183092, 1173856290, 
+1396331490, 1660527343, 1974710931, 1174170145, 1396704754, 1660971230, 1975238805, 1174484020, 1397078042, 1661415148, 1975766714, 1174797917, 1397451355, 1661859094, 1976294659, 1175111835, 
+1397824693, 1662303071, 1976822639, 1175425774, 1398198056, 1662747077, 1977350654, 1175739733, 1398571444, 1663191112, 1977878704, 1176053714, 1398944857, 1663635178, 1978406790, 1176367716, 
+1399318295, 1664079273, 1978934911, 1176681738, 1399691758, 1664523397, 1979463067, 1176995782, 1400065245, 1664967551, 1979991258, 1177309846, 1400438758, 1665411735, 1980519485, 1177623931, 
+1400812296, 1665855949, 1981047747, 1177938038, 1401185858, 1666300192, 1981576044, 1178252165, 1401559445, 1666744464, 1982104376, 1178566313, 1401933057, 1667188767, 1982632743, 1178880482, 
+1402306694, 1667633099, 1983161146, 1179194672, 1402680356, 1668077460, 1983689584, 1179508884, 1403054043, 1668521851, 1984218057, 1179823115, 1403427755, 1668966272, 1984746565, 1180137368, 
+1403801492, 1669410722, 1985275108, 1180451642, 1404175253, 1669855202, 1985803687, 1180765937, 1404549040, 1670299711, 1986332301, 1181080252, 1404922851, 1670744250, 1986860950, 1181394589, 
+1405296687, 1671188819, 1987389634, 1181708946, 1405670548, 1671633417, 1987918353, 1182023325, 1406044434, 1672078045, 1988447108, 1182337724, 1406418344, 1672522702, 1988975897, 1182652144, 
+1406792280, 1672967389, 1989504722, 1182966585, 1407166240, 1673412105, 1990033582, 1183281047, 1407540226, 1673856851, 1990562477, 1183595530, 1407914236, 1674301626, 1991091407, 1183910034, 
+1408288271, 1674746431, 1991620372, 1184224558, 1408662330, 1675191266, 1992149373, 1184539104, 1409036415, 1675636130, 1992678408, 1184853670, 1409410524, 1676081024, 1993207479, 1185168258, 
+1409784659, 1676525947, 1993736584, 1185482866, 1410158818, 1676970899, 1994265725, 1185797495, 1410533002, 1677415882, 1994794901, 1186112145, 1410907210, 1677860893, 1995324112, 1186426816, 
+1411281444, 1678305934, 1995853358, 1186741507, 1411655702, 1678751005, 1996382640, 1187056220, 1412029985, 1679196105, 1996911956, 1187370953, 1412404293, 1679641235, 1997441307, 1187685707, 
+1412778626, 1680086394, 1997970694, 1188000482, 1413152984, 1680531583, 1998500115, 1188315278, 1413527366, 1680976801, 1999029572, 1188630095, 1413901773, 1681422049, 1999559064, 1188944933, 
+1414276205, 1681867326, 2000088590, 1189259791, 1414650662, 1682312632, 2000618152, 1189574670, 1415025143, 1682757968, 2001147749, 1189889571, 1415399650, 1683203334, 2001677381, 1190204492, 
+1415774181, 1683648729, 2002207048, 1190519433, 1416148737, 1684094153, 2002736750, 1190834396, 1416523317, 1684539607, 2003266486, 1191149379, 1416897922, 1684985091, 2003796258, 1191464384, 
+1417272553, 1685430603, 2004326065, 1191779409, 1417647207, 1685876146, 2004855907, 1192094455, 1418021887, 1686321717, 2005385784, 1192409522, 1418396591, 1686767318, 2005915696, 1192724609, 
+1418771321, 1687212949, 2006445643, 1193039718, 1419146074, 1687658609, 2006975625, 1193354847, 1419520853, 1688104298, 2007505642, 1193669997, 1419895656, 1688550017, 2008035694, 1193985168, 
+1420270485, 1688995765, 2008565781, 1194300359, 1420645337, 1689441543, 2009095903, 1194615572, 1421020215, 1689887350, 2009626060, 1194930805, 1421395117, 1690333187, 2010156252, 1195246059, 
+1421770044, 1690779052, 2010686479, 1195561333, 1422144996, 1691224948, 2011216741, 1195876629, 1422519972, 1691670872, 2011747038, 1196191945, 1422894973, 1692116826, 2012277369, 1196507282, 
+1423269999, 1692562810, 2012807736, 1196822640, 1423645050, 1693008823, 2013338138, 1197138019, 1424020125, 1693454865, 2013868574, 1197453418, 1424395225, 1693900936, 2014399045, 1197768839, 
+1424770350, 1694347037, 2014929552, 1198084280, 1425145499, 1694793167, 2015460093, 1198399741, 1425520673, 1695239327, 2015990669, 1198715224, 1425895872, 1695685516, 2016521281, 1199030727, 
+1426271095, 1696131734, 2017051927, 1199346251, 1426646343, 1696577982, 2017582608, 1199661796, 1427021616, 1697024259, 2018113323, 1199977362, 1427396914, 1697470566, 2018644074, 1200292948, 
+1427772236, 1697916901, 2019174860, 1200608555, 1428147582, 1698363266, 2019705680, 1200924183, 1428522954, 1698809661, 2020236536, 1201239831, 1428898350, 1699256084, 2020767426, 1201555500, 
+1429273771, 1699702538, 2021298351, 1201871190, 1429649216, 1700149020, 2021829311, 1202186901, 1430024686, 1700595532, 2022360306, 1202502632, 1430400181, 1701042073, 2022891336, 1202818385, 
+1430775700, 1701488643, 2023422400, 1203134157, 1431151244, 1701935242, 2023953500, 1203449951, 1431526813, 1702381871, 2024484634, 1203765765, 1431902406, 1702828530, 2025015803, 1204081600, 
+1432278024, 1703275217, 2025547007, 1204397456, 1432653667, 1703721934, 2026078246, 1204713333, 1433029334, 1704168680, 2026609519, 1205029230, 1433405026, 1704615455, 2027140828, 1205345148, 
+1433780742, 1705062260, 2027672171, 1205661086, 1434156483, 1705509094, 2028203549, 1205977045, 1434532249, 1705955957, 2028734962, 1206293025, 1434908039, 1706402849, 2029266409, 1206609026, 
+1435283854, 1706849771, 2029797892, 1206925047, 1435659693, 1707296722, 2030329409, 1207241090, 1436035557, 1707743702, 2030860961, 1207557152, 1436411446, 1708190711, 2031392548, 1207873236, 
+1436787359, 1708637750, 2031924169, 1208189340, 1437163297, 1709084818, 2032455826, 1208505465, 1437539259, 1709531915, 2032987517, 1208821610, 1437915246, 1709979042, 2033519243, 1209137776, 
+1438291258, 1710426197, 2034051004, 1209453963, 1438667294, 1710873382, 2034582799, 1209770170, 1439043355, 1711320596, 2035114629, 1210086398, 1439419440, 1711767840, 2035646494, 1210402647, 
+1439795550, 1712215112, 2036178394, 1210718917, 1440171684, 1712662414, 2036710328, 1211035207, 1440547843, 1713109745, 2037242297, 1211351517, 1440924027, 1713557105, 2037774301, 1211667849, 
+1441300235, 1714004494, 2038306340, 1211984201, 1441676468, 1714451913, 2038838413, 1212300574, 1442052725, 1714899360, 2039370521, 1212616967, 1442429006, 1715346837, 2039902664, 1212933381, 
+1442805313, 1715794344, 2040434841, 1213249815, 1443181644, 1716241879, 2040967053, 1213566271, 1443557999, 1716689443, 2041499300, 1213882747, 1443934379, 1717137037, 2042031582, 1214199243, 
+1444310783, 1717584660, 2042563898, 1214515760, 1444687212, 1718032312, 2043096249, 1214832298, 1445063666, 1718479993, 2043628634, 1215148856, 1445440144, 1718927703, 2044161055, 1215465435, 
+1445816646, 1719375443, 2044693510, 1215782035, 1446193173, 1719823211, 2045225999, 1216098655, 1446569725, 1720271009, 2045758523, 1216415296, 1446946301, 1720718836, 2046291082, 1216731957, 
+1447322901, 1721166692, 2046823676, 1217048639, 1447699526, 1721614577, 2047356304, 1217365342, 1448076176, 1722062491, 2047888967, 1217682065, 1448452850, 1722510435, 2048421665, 1217998809, 
+1448829548, 1722958407, 2048954397, 1218315573, 1449206271, 1723406409, 2049487163, 1218632358, 1449583019, 1723854440, 2050019965, 1218949164, 1449959791, 1724302500, 2050552801, 1219265990, 
+1450336587, 1724750589, 2051085672, 1219582837, 1450713408, 1725198707, 2051618577, 1219899704, 1451090253, 1725646854, 2052151517, 1220216592, 1451467123, 1726095030, 2052684491, 1220533501, 
+1451844018, 1726543236, 2053217500, 1220850430, 1452220936, 1726991470, 2053750544, 1221167380, 1452597880, 1727439734, 2054283622, 1221484350, 1452974847, 1727888026, 2054816735, 1221801341, 
+1453351839, 1728336348, 2055349882, 1222118352, 1453728856, 1728784699, 2055883064, 1222435384, 1454105897, 1729233079, 2056416281, 1222752436, 1454482963, 1729681488, 2056949532, 1223069509, 
+1454860052, 1730129926, 2057482818, 1223386603, 1455237167, 1730578393, 2058016138, 1223703717, 1455614306, 1731026889, 2058549493, 1224020852, 1455991469, 1731475414, 2059082882, 1224338007, 
+1456368656, 1731923968, 2059616306, 1224655183, 1456745869, 1732372552, 2060149764, 1224972379, 1457123105, 1732821164, 2060683257, 1225289596, 1457500366, 1733269805, 2061216785, 1225606833, 
+1457877651, 1733718476, 2061750347, 1225924091, 1458254961, 1734167175, 2062283943, 1226241369, 1458632295, 1734615904, 2062817574, 1226558668, 1459009654, 1735064661, 2063351240, 1226875988, 
+1459387037, 1735513448, 2063884940, 1227193328, 1459764444, 1735962263, 2064418675, 1227510688, 1460141876, 1736411108, 2064952444, 1227828069, 1460519332, 1736859981, 2065486247, 1228145471, 
+1460896812, 1737308884, 2066020085, 1228462893, 1461274317, 1737757815, 2066553958, 1228780335, 1461651847, 1738206776, 2067087865, 1229097798, 1462029400, 1738655765, 2067621806, 1229415282, 
+1462406978, 1739104784, 2068155782, 1229732786, 1462784581, 1739553831, 2068689793, 1230050310, 1463162208, 1740002908, 2069223838, 1230367855, 1463539859, 1740452013, 2069757917, 1230685421, 
+1463917534, 1740901147, 2070292031, 1231003007, 1464295234, 1741350311, 2070826179, 1231320613, 1464672958, 1741799503, 2071360362, 1231638240, 1465050707, 1742248724, 2071894579, 1231955888, 
+1465428480, 1742697975, 2072428831, 1232273556, 1465806277, 1743147254, 2072963117, 1232591244, 1466184099, 1743596562, 2073497437, 1232908953, 1466561945, 1744045899, 2074031792, 1233226682, 
+1466939815, 1744495265, 2074566182, 1233544432, 1467317710, 1744944660, 2075100605, 1233862202, 1467695629, 1745394084, 2075635064, 1234179993, 1468073572, 1745843537, 2076169556, 1234497804, 
+1468451540, 1746293019, 2076704083, 1234815636, 1468829532, 1746742530, 2077238644, 1235133488, 1469207548, 1747192069, 2077773240, 1235451360, 1469585589, 1747641638, 2078307870, 1235769253, 
+1469963653, 1748091235, 2078842535, 1236087167, 1470341743, 1748540862, 2079377234, 1236405101, 1470719856, 1748990517, 2079911967, 1236723055, 1471097994, 1749440201, 2080446735, 1237041030, 
+1471476156, 1749889914, 2080981537, 1237359025, 1471854343, 1750339656, 2081516373, 1237677040, 1472232553, 1750789427, 2082051244, 1237995077, 1472610788, 1751239227, 2082586149, 1238313133, 
+1472989048, 1751689056, 2083121088, 1238631210, 1473367331, 1752138913, 2083656062, 1238949307, 1473745639, 1752588800, 2084191070, 1239267425, 1474123971, 1753038715, 2084726113, 1239585563, 
+1474502328, 1753488659, 2085261190, 1239903722, 1474880708, 1753938632, 2085796301, 1240221901, 1475259113, 1754388634, 2086331446, 1240540100, 1475637543, 1754838665, 2086866626, 1240858320, 
+1476015996, 1755288725, 2087401840, 1241176560, 1476394474, 1755738813, 2087937088, 1241494821, 1476772976, 1756188930, 2088472371, 1241813102, 1477151502, 1756639076, 2089007688, 1242131403, 
+1477530053, 1757089251, 2089543039, 1242449725, 1477908628, 1757539455, 2090078425, 1242768067, 1478287227, 1757989688, 2090613845, 1243086430, 1478665850, 1758439949, 2091149299, 1243404813, 
+1479044497, 1758890240, 2091684788, 1243723216, 1479423169, 1759340559, 2092220310, 1244041640, 1479801865, 1759790907, 2092755867, 1244360084, 1480180585, 1760241284, 2093291459, 1244678548, 
+1480559330, 1760691689, 2093827084, 1244997033, 1480938098, 1761142123, 2094362744, 1245315538, 1481316891, 1761592587, 2094898438, 1245634064, 1481695708, 1762043079, 2095434166, 1245952610, 
+1482074550, 1762493599, 2095969929, 1246271176, 1482453415, 1762944149, 2096505725, 1246589763, 1482832305, 1763394727, 2097041556, 1246908370, 1483211219, 1763845335, 2097577422, 1247226997, 
+1483590157, 1764295970, 2098113321, 1247545645, 1483969119, 1764746635, 2098649255, 1247864313, 1484348106, 1765197329, 2099185223, 1248183001, 1484727117, 1765648051, 2099721225, 1248501710, 
+1485106151, 1766098802, 2100257261, 1248820439, 1485485211, 1766549582, 2100793331, 1249139188, 1485864294, 1767000390, 2101329436, 1249457958, 1486243401, 1767451227, 2101865575, 1249776748, 
+1486622533, 1767902093, 2102401748, 1250095559, 1487001689, 1768352988, 2102937955, 1250414390, 1487380869, 1768803912, 2103474197, 1250733241, 1487760073, 1769254864, 2104010473, 1251052112, 
+1488139301, 1769705845, 2104546782, 1251371004, 1488518554, 1770156855, 2105083126, 1251689916, 1488897830, 1770607893, 2105619505, 1252008848, 1489277131, 1771058960, 2106155917, 1252327801, 
+1489656456, 1771510056, 2106692363, 1252646774, 1490035805, 1771961181, 2107228844, 1252965767, 1490415178, 1772412334, 2107765359, 1253284781, 1490794576, 1772863516, 2108301908, 1253603815, 
+1491173997, 1773314727, 2108838491, 1253922869, 1491553443, 1773765967, 2109375108, 1254241943, 1491932913, 1774217235, 2109911759, 1254561038, 1492312407, 1774668532, 2110448445, 1254880153, 
+1492691925, 1775119857, 2110985164, 1255199289, 1493071467, 1775571212, 2111521918, 1255518444, 1493451033, 1776022594, 2112058706, 1255837620, 1493830624, 1776474006, 2112595528, 1256156816, 
+1494210238, 1776925446, 2113132384, 1256476033, 1494589877, 1777376915, 2113669274, 1256795270, 1494969539, 1777828413, 2114206198, 1257114527, 1495349226, 1778279939, 2114743156, 1257433804, 
+1495728937, 1778731494, 2115280149, 1257753102, 1496108672, 1779183078, 2115817175, 1258072419, 1496488431, 1779634690, 2116354236, 1258391757, 1496868215, 1780086331, 2116891330, 1258711116, 
+1497248022, 1780538001, 2117428459, 1259030494, 1497627853, 1780989699, 2117965622, 1259349893, 1498007709, 1781441426, 2118502819, 1259669313, 1498387589, 1781893181, 2119040049, 1259988752, 
+1498767492, 1782344966, 2119577314, 1260308212, 1499147420, 1782796778, 2120114613, 1260627691, 1499527372, 1783248620, 2120651946, 1260947192, 1499907348, 1783700490, 2121189313, 1261266712, 
+1500287348, 1784152388, 2121726715, 1261586253, 1500667372, 1784604316, 2122264150, 1261905813, 1501047420, 1785056272, 2122801619, 1262225394, 1501427492, 1785508256, 2123339122, 1262544996, 
+1501807588, 1785960269, 2123876659, 1262864617, 1502187708, 1786412311, 2124414230, 1263184259, 1502567853, 1786864381, 2124951836, 1263503921, 1502948021, 1787316480, 2125489475, 1263823603, 
+1503328213, 1787768608, 2126027148, 1264143306, 1503708430, 1788220764, 2126564855, 1264463028, 1504088670, 1788672948, 2127102597, 1264782771, 1504468935, 1789125162, 2127640372, 1265102534, 
+1504849223, 1789577403, 2128178181, 1265422317, 1505229536, 1790029674, 2128716024, 1265742121, 1505609872, 1790481973, 2129253901, 1266061945, 1505990233, 1790934300, 2129791812, 1266381788, 
+1506370618, 1791386656, 2130329757, 1266701652, 1506751026, 1791839041, 2130867736, 1267021537, 1507131459, 1792291454, 2131405749, 1267341441, 1507511916, 1792743896, 2131943796, 1267661366, 
+1507892396, 1793196366, 2132481877, 1267981311, 1508272901, 1793648865, 2133019992, 1268301276, 1508653430, 1794101392, 2133558141, 1268621261, 1509033982, 1794553948, 2134096324, 1268941266, 
+1509414559, 1795006533, 2134634540, 1269261292, 1509795159, 1795459146, 2135172791, 1269581337, 1510175784, 1795911787, 2135711075, 1269901403, 1510556433, 1796364457, 2136249394, 1270221489, 
+1510937105, 1796817156, 2136787746, 1270541596, 1511317802, 1797269883, 2137326132, 1270861722, 1511698522, 1797722639, 2137864553, 1271181868, 1512079267, 1798175423, 2138403007, 1271502035, 
+1512460035, 1798628235, 2138941495, 1271822222, 1512840828, 1799081076, 2139480017, 1272142429, 1513221644, 1799533946, 2140018572, 1272462656, 1513602485, 1799986844, 2140557162, 1272782903, 
+1513983349, 1800439771, 2141095785, 1273103171, 1514364237, 1800892726, 2141634443, 1273423459, 1514745150, 1801345709, 2142173134, 1273743766, 1515126086, 1801798721, 2142711859, 1274064094, 
+1515507046, 1802251762, 2143250618, 1274384442, 1515888030, 1802704831, 2143789411, 1274704810, 1516269038, 1803157928, 2144328238, 1275025199, 1516650070, 1803611054, 2144867098, 1275345607, 
+1517031126, 1804064209, 2145405993, 1275666036, 1517412206, 1804517391, 2145944921, 1275986484, 1517793309, 1804970603, 2146483883, 1276306953, 1518174437, 1805423842, 2147022879, 1276627442, 
+1518555589, 1805877111, 1073780954, 1276947951, 1518936764, 1806330407, 1074050486, 1277268480, 1519317964, 1806783732, 1074320035, 1277589029, 1519699187, 1807237086, 1074589600, 1277909599, 
+1520080434, 1807690468, 1074859183, 1278230188, 1520461705, 1808143878, 1075128782, 1278550798, 1520843000, 1808597317, 1075398399, 1278871427, 1521224319, 1809050784, 1075668032, 1279192077, 
+1521605662, 1809504280, 1075937682, 1279512747, 1521987029, 1809957804, 1076207349, 1279833437, 1522368420, 1810411356, 1076477033, 1280154147, 1522749834, 1810864937, 1076746734, 1280474877, 
+1523131273, 1811318546, 1077016451, 1280795627, 1523512735, 1811772184, 1077286186, 1281116397, 1523894221, 1812225850, 1077555937, 1281437188, 1524275731, 1812679545, 1077825706, 1281757998, 
+1524657265, 1813133267, 1078095491, 1282078829, 1525038823, 1813587019, 1078365293, 1282399679, 1525420404, 1814040798, 1078635112, 1282720550, 1525802010, 1814494606, 1078904948, 1283041441, 
+1526183639, 1814948443, 1079174801, 1283362351, 1526565293, 1815402307, 1079444670, 1283683282, 1526946970, 1815856201, 1079714557, 1284004233, 1527328671, 1816310122, 1079984460, 1284325204, 
+1527710395, 1816764072, 1080254380, 1284646195, 1528092144, 1817218050, 1080524317, 1284967206, 1528473917, 1817672057, 1080794271, 1285288237, 1528855713, 1818126092, 1081064242, 1285609288, 
+1529237533, 1818580155, 1081334230, 1285930360, 1529619377, 1819034247, 1081604234, 1286251451, 1530001245, 1819488366, 1081874256, 1286572562, 1530383137, 1819942515, 1082144294, 1286893694, 
+1530765052, 1820396691, 1082414349, 1287214845, 1531146991, 1820850896, 1082684421, 1287536016, 1531528955, 1821305130, 1082954509, 1287857208, 1531910942, 1821759391, 1083224615, 1288178419, 
+1532292952, 1822213681, 1083494737, 1288499651, 1532674987, 1822667999, 1083764877, 1288820902, 1533057045, 1823122346, 1084035033, 1289142174, 1533439127, 1823576721, 1084305206, 1289463465, 
+1533821233, 1824031124, 1084575395, 1289784777, 1534203363, 1824485555, 1084845602, 1290106108, 1534585517, 1824940015, 1085115825, 1290427460, 1534967694, 1825394503, 1085386066, 1290748832, 
+1535349895, 1825849020, 1085656323, 1291070223, 1535732120, 1826303564, 1085926596, 1291391635, 1536114369, 1826758137, 1086196887, 1291713066, 1536496642, 1827212738, 1086467195, 1292034518, 
+1536878938, 1827667368, 1086737519, 1292355990, 1537261258, 1828122026, 1087007860, 1292677481, 1537643602, 1828576712, 1087278218, 1292998993, 1538025970, 1829031426, 1087548593, 1293320524, 
+1538408361, 1829486169, 1087818984, 1293642076, 1538790776, 1829940939, 1088089393, 1293963647, 1539173215, 1830395738, 1088359818, 1294285239, 1539555678, 1830850566, 1088630260, 1294606850, 
+1539938164, 1831305421, 1088900718, 1294928482, 1540320674, 1831760305, 1089171194, 1295250133, 1540703208, 1832215217, 1089441686, 1295571805, 1541085766, 1832670158, 1089712195, 1295893496, 
+1541468347, 1833125126, 1089982721, 1296215207, 1541850952, 1833580123, 1090253264, 1296536939, 1542233581, 1834035148, 1090523824, 1296858690, 1542616234, 1834490201, 1090794400, 1297180461, 
+1542998910, 1834945283, 1091064993, 1297502252, 1543381610, 1835400392, 1091335603, 1297824064, 1543764334, 1835855530, 1091606229, 1298145895, 1544147082, 1836310696, 1091876873, 1298467746, 
+1544529853, 1836765891, 1092147533, 1298789617, 1544912648, 1837221113, 1092418210, 1299111508, 1545295467, 1837676364, 1092688903, 1299433418, 1545678309, 1838131643, 1092959614, 1299755349, 
+1546061175, 1838586950, 1093230341, 1300077300, 1546444065, 1839042285, 1093501085, 1300399271, 1546826978, 1839497648, 1093771846, 1300721261, 1547209916, 1839953040, 1094042623, 1301043272, 
+1547592877, 1840408460, 1094313418, 1301365302, 1547975861, 1840863908, 1094584229, 1301687353, 1548358869, 1841319384, 1094855056, 1302009423, 1548741901, 1841774888, 1095125901, 1302331513, 
+1549124957, 1842230421, 1095396762, 1302653623, 1549508036, 1842685982, 1095667640, 1302975753, 1549891139, 1843141570, 1095938535, 1303297903, 1550274266, 1843597187, 1096209446, 1303620073, 
+1550657416, 1844052833, 1096480374, 1303942263, 1551040590, 1844508506, 1096751319, 1304264472, 1551423788, 1844964207, 1097022281, 1304586702, 1551807010, 1845419937, 1097293260, 1304908952, 
+1552190255, 1845875695, 1097564255, 1305231221, 1552573523, 1846331480, 1097835267, 1305553510, 1552956816, 1846787294, 1098106295, 1305875819, 1553340132, 1847243137, 1098377341, 1306198148, 
+1553723471, 1847699007, 1098648403, 1306520497, 1554106835, 1848154905, 1098919481, 1306842866, 1554490221, 1848610832, 1099190577, 1307165255, 1554873632, 1849066786, 1099461689, 1307487663, 
+1555257066, 1849522769, 1099732818, 1307810092, 1555640524, 1849978780, 1100003964, 1308132540, 1556024006, 1850434818, 1100275126, 1308455008, 1556407511, 1850890885, 1100546305, 1308777496, 
+1556791039, 1851346981, 1100817501, 1309100004, 1557174592, 1851803104, 1101088713, 1309422532, 1557558168, 1852259255, 1101359942, 1309745080, 1557941767, 1852715434, 1101631188, 1310067647, 
+1558325390, 1853171642, 1101902451, 1310390235, 1558709037, 1853627877, 1102173730, 1310712842, 1559092708, 1854084141, 1102445026, 1311035469, 1559476402, 1854540433, 1102716339, 1311358116, 
+1559860119, 1854996752, 1102987668, 1311680783, 1560243861, 1855453100, 1103259014, 1312003469, 1560627625, 1855909476, 1103530377, 1312326176, 1561011414, 1856365880, 1103801756, 1312648902, 
+1561395226, 1856822312, 1104073152, 1312971648, 1561779061, 1857278772, 1104344565, 1313294414, 1562162921, 1857735260, 1104615994, 1313617200, 1562546803, 1858191776, 1104887441, 1313940006, 
+1562930710, 1858648320, 1105158903, 1314262831, 1563314640, 1859104892, 1105430383, 1314585676, 1563698593, 1859561493, 1105701879, 1314908541, 1564082570, 1860018121, 1105973392, 1315231426, 
+1564466571, 1860474777, 1106244921, 1315554331, 1564850595, 1860931461, 1106516467, 1315877256, 1565234643, 1861388174, 1106788030, 1316200200, 1565618714, 1861844914, 1107059609, 1316523164, 
+1566002809, 1862301682, 1107331206, 1316846148, 1566386927, 1862758479, 1107602818, 1317169152, 1566771069, 1863215303, 1107874448, 1317492176, 1567155235, 1863672156, 1108146094, 1317815219, 
+1567539424, 1864129036, 1108417756, 1318138282, 1567923637, 1864585944, 1108689436, 1318461365, 1568307873, 1865042881, 1108961132, 1318784468, 1568692132, 1865499845, 1109232844, 1319107591, 
+1569076416, 1865956837, 1109504574, 1319430733, 1569460722, 1866413858, 1109776320, 1319753895, 1569845053, 1866870906, 1110048082, 1320077077, 1570229406, 1867327982, 1110319861, 1320400279, 
+1570613784, 1867785087, 1110591657, 1320723500, 1570998185, 1868242219, 1110863470, 1321046742, 1571382609, 1868699379, 1111135299, 1321370003, 1571767057, 1869156567, 1111407144, 1321693284, 
+1572151528, 1869613783, 1111679007, 1322016584, 1572536023, 1870071027, 1111950886, 1322339905, 1572920541, 1870528299, 1112222781, 1322663245, 1573305083, 1870985599, 1112494693, 1322986605, 
+1573689649, 1871442927, 1112766622, 1323309984, 1574074238, 1871900283, 1113038567, 1323633384, 1574458850, 1872357667, 1113310530, 1323956803, 1574843486, 1872815078, 1113582508, 1324280242, 
+1575228145, 1873272518, 1113854503, 1324603700, 1575612828, 1873729986, 1114126515, 1324927179, 1575997534, 1874187481, 1114398544, 1325250677, 1576382264, 1874645004, 1114670589, 1325574195, 
+1576767017, 1875102556, 1114942650, 1325897733, 1577151794, 1875560135, 1115214729, 1326221290, 1577536594, 1876017742, 1115486823, 1326544867, 1577921418, 1876475377, 1115758935, 1326868464, 
+1578306265, 1876933040, 1116031063, 1327192081, 1578691136, 1877390731, 1116303208, 1327515717, 1579076030, 1877848450, 1116575369, 1327839373, 1579460947, 1878306197, 1116847547, 1328163049, 
+1579845888, 1878763971, 1117119741, 1328486744, 1580230853, 1879221774, 1117391952, 1328810459, 1580615841, 1879679604, 1117664179, 1329134194, 1581000852, 1880137462, 1117936424, 1329457949, 
+1581385887, 1880595348, 1118208684, 1329781723, 1581770945, 1881053262, 1118480961, 1330105517, 1582156027, 1881511204, 1118753255, 1330429331, 1582541132, 1881969174, 1119025566, 1330753165, 
+1582926260, 1882427171, 1119297893, 1331077018, 1583311412, 1882885197, 1119570236, 1331400891, 1583696587, 1883343250, 1119842596, 1331724783, 1584081786, 1883801331, 1120114973, 1332048695, 
+1584467008, 1884259440, 1120387366, 1332372627, 1584852254, 1884717577, 1120659776, 1332696579, 1585237523, 1885175741, 1120932202, 1333020550, 1585622815, 1885633934, 1121204645, 1333344541, 
+1586008131, 1886092154, 1121477105, 1333668552, 1586393471, 1886550402, 1121749581, 1333992583, 1586778833, 1887008678, 1122022073, 1334316633, 1587164219, 1887466982, 1122294582, 1334640702, 
+1587549629, 1887925314, 1122567108, 1334964792, 1587935061, 1888383673, 1122839650, 1335288901, 1588320518, 1888842060, 1123112209, 1335613030, 1588705997, 1889300476, 1123384784, 1335937178, 
+1589091500, 1889758918, 1123657376, 1336261346, 1589477027, 1890217389, 1123929984, 1336585534, 1589862576, 1890675888, 1124202609, 1336909741, 1590248149, 1891134414, 1124475250, 1337233968, 
+1590633746, 1891592968, 1124747908, 1337558215, 1591019366, 1892051550, 1125020583, 1337882481, 1591405009, 1892510160, 1125293274, 1338206767, 1591790676, 1892968797, 1125565981, 1338531073, 
+1592176366, 1893427462, 1125838705, 1338855398, 1592562079, 1893886155, 1126111445, 1339179743, 1592947816, 1894344876, 1126384202, 1339504108, 1593333576, 1894803625, 1126656976, 1339828492, 
+1593719359, 1895262401, 1126929766, 1340152896, 1594105166, 1895721205, 1127202573, 1340477319, 1594490996, 1896180037, 1127475396, 1340801763, 1594876849, 1896638897, 1127748235, 1341126225, 
+1595262726, 1897097784, 1128021091, 1341450708, 1595648626, 1897556699, 1128293964, 1341775210, 1596034549, 1898015642, 1128566853, 1342099731, 1596420496, 1898474613, 1128839759, 1342424273, 
+1596806466, 1898933611, 1129112681, 1342748833, 1597192460, 1899392637, 1129385619, 1343073414, 1597578476, 1899851691, 1129658574, 1343398014, 1597964516, 1900310773, 1129931546, 1343722634, 
+1598350580, 1900769882, 1130204534, 1344047273, 1598736667, 1901229019, 1130477538, 1344371932, 1599122777, 1901688184, 1130750559, 1344696610, 1599508910, 1902147376, 1131023597, 1345021308, 
+1599895066, 1902606596, 1131296651, 1345346026, 1600281246, 1903065844, 1131569721, 1345670763, 1600667450, 1903525120, 1131842808, 1345995520, 1601053676, 1903984423, 1132115911, 1346320297, 
+1601439926, 1904443754, 1132389031, 1346645093, 1601826199, 1904903113, 1132662168, 1346969909, 1602212495, 1905362499, 1132935320, 1347294744, 1602598815, 1905821913, 1133208490, 1347619599, 
+1602985158, 1906281355, 1133481675, 1347944473, 1603371524, 1906740824, 1133754877, 1348269367, 1603757914, 1907200322, 1134028096, 1348594280, 1604144326, 1907659846, 1134301331, 1348919214, 
+1604530762, 1908119399, 1134574583, 1349244166, 1604917222, 1908578979, 1134847851, 1349569139, 1605303704, 1909038587, 1135121135, 1349894130, 1605690210, 1909498222, 1135394436, 1350219142, 
+1606076739, 1909957886, 1135667753, 1350544173, 1606463292, 1910417576, 1135941087, 1350869223, 1606849867, 1910877295, 1136214437, 1351194293, 1607236466, 1911337041, 1136487804, 1351519383, 
+1607623088, 1911796815, 1136761187, 1351844492, 1608009734, 1912256616, 1137034587, 1352169621, 1608396402, 1912716445, 1137308003, 1352494769, 1608783094, 1913176302, 1137581435, 1352819937, 
+1609169809, 1913636186, 1137854884, 1353145124, 1609556547, 1914096098, 1138128349, 1353470331, 1609943309, 1914556038, 1138401831, 1353795557, 1610330094, 1915016005, 1138675329, 1354120803, 
+1610716902, 1915476000, 1138948844, 1354446069, 1611103733, 1915936022, 1139222375, 1354771354, 1611490587, 1916396072, 1139495922, 1355096658, 1611877465, 1916856150, 1139769486, 1355421982, 
+1612264366, 1917316255, 1140043066, 1355747326, 1612651290, 1917776388, 1140316663, 1356072689, 1613038237, 1918236549, 1140590276, 1356398071, 1613425208, 1918696737, 1140863905, 1356723474, 
+1613812202, 1919156952, 1141137551, 1357048895, 1614199219, 1919617196, 1141411214, 1357374336, 1614586259, 1920077467, 1141684892, 1357699797, 1614973322, 1920537765, 1141958587, 1358025277, 
+1615360409, 1920998091, 1142232299, 1358350777, 1615747518, 1921458445, 1142506027, 1358676296, 1616134651, 1921918826, 1142779771, 1359001835, 1616521807, 1922379235, 1143053532, 1359327393, 
+1616908986, 1922839671, 1143327309, 1359652971, 1617296189, 1923300135, 1143601102, 1359978568, 1617683415, 1923760626, 1143874912, 1360304184, 1618070663, 1924221145, 1144148738, 1360629820, 
+1618457935, 1924681692, 1144422581, 1360955476, 1618845230, 1925142266, 1144696440, 1361281151, 1619232549, 1925602868, 1144970315, 1361606846, 1619619890, 1926063497, 1145244207, 1361932560, 
+1620007255, 1926524154, 1145518115, 1362258293, 1620394643, 1926984838, 1145792040, 1362584046, 1620782053, 1927445550, 1146065981, 1362909819, 1621169488, 1927906289, 1146339938, 1363235611, 
+1621556945, 1928367056, 1146613912, 1363561422, 1621944425, 1928827851, 1146887902, 1363887253, 1622331929, 1929288672, 1147161908, 1364213103, 1622719455, 1929749522, 1147435931, 1364538973, 
+1623107005, 1930210399, 1147709970, 1364864862, 1623494578, 1930671303, 1147984025, 1365190771, 1623882174, 1931132235, 1148258097, 1365516699, 1624269793, 1931593195, 1148532185, 1365842647, 
+1624657436, 1932054182, 1148806290, 1366168614, 1625045101, 1932515196, 1149080411, 1366494600, 1625432790, 1932976238, 1149354548, 1366820606, 1625820501, 1933437308, 1149628702, 1367146631, 
+1626208236, 1933898405, 1149902871, 1367472676, 1626595994, 1934359529, 1150177058, 1367798740, 1626983775, 1934820681, 1150451260, 1368124824, 1627371579, 1935281861, 1150725479, 1368450927, 
+1627759406, 1935743068, 1150999714, 1368777050, 1628147257, 1936204302, 1151273966, 1369103192, 1628535130, 1936665564, 1151548234, 1369429353, 1628923027, 1937126853, 1151822518, 1369755534, 
+1629310946, 1937588170, 1152096819, 1370081734, 1629698889, 1938049514, 1152371136, 1370407954, 1630086855, 1938510886, 1152645469, 1370734193, 1630474844, 1938972285, 1152919819, 1371060451, 
+1630862856, 1939433712, 1153194185, 1371386729, 1631250891, 1939895166, 1153468567, 1371713027, 1631638949, 1940356647, 1153742965, 1372039343, 1632027030, 1940818156, 1154017380, 1372365679, 
+1632415135, 1941279693, 1154291811, 1372692035, 1632803262, 1941741256, 1154566259, 1373018410, 1633191412, 1942202848, 1154840723, 1373344804, 1633579586, 1942664466, 1155115203, 1373671218, 
+1633967782, 1943126112, 1155389699, 1373997651, 1634356002, 1943587786, 1155664212, 1374324103, 1634744245, 1944049487, 1155938741, 1374650575, 1635132510, 1944511215, 1156213286, 1374977066, 
+1635520799, 1944972971, 1156487848, 1375303577, 1635909111, 1945434754, 1156762426, 1375630107, 1636297446, 1945896565, 1157037020, 1375956656, 1636685804, 1946358403, 1157311630, 1376283225, 
+1637074185, 1946820268, 1157586257, 1376609813, 1637462589, 1947282161, 1157860900, 1376936421, 1637851016, 1947744081, 1158135560, 1377263048, 1638239466, 1948206029, 1158410235, 1377589694, 
+1638627939, 1948668003, 1158684927, 1377916360, 1639016435, 1949130006, 1158959635, 1378243044, 1639404954, 1949592035, 1159234360, 1378569749, 1639793496, 1950054093, 1159509101, 1378896473, 
+1640182061, 1950516177, 1159783858, 1379223216, 1640570649, 1950978289, 1160058631, 1379549978, 1640959260, 1951440428, 1160333421, 1379876760, 1641347895, 1951902594, 1160608227, 1380203561, 
+1641736552, 1952364788, 1160883049, 1380530381, 1642125232, 1952827010, 1161157887, 1380857221, 1642513935, 1953289258, 1161432742, 1381184080, 1642902661, 1953751534, 1161707613, 1381510959, 
+1643291411, 1954213837, 1161982500, 1381837856, 1643680183, 1954676168, 1162257403, 1382164773, 1644068978, 1955138526, 1162532323, 1382491710, 1644457796, 1955600911, 1162807259, 1382818666, 
+1644846637, 1956063324, 1163082211, 1383145641, 1645235501, 1956525764, 1163357180, 1383472635, 1645624388, 1956988231, 1163632164, 1383799649, 1646013299, 1957450726, 1163907165, 1384126682, 
+1646402232, 1957913248, 1164182183, 1384453735, 1646791188, 1958375797, 1164457216, 1384780806, 1647180167, 1958838374, 1164732266, 1385107897, 1647569169, 1959300978, 1165007332, 1385435008, 
+1647958193, 1959763609, 1165282414, 1385762137, 1648347241, 1960226267, 1165557512, 1386089286, 1648736312, 1960688953, 1165832627, 1386416455, 1649125406, 1961151666, 1166107758, 1386743642, 
+1649514523, 1961614407, 1166382905, 1387070849, 1649903662, 1962077174, 1166658068, 1387398075, 1650292825, 1962539969, 1166933248, 1387725321, 1650682011, 1963002792, 1167208443, 1388052585, 
+1651071219, 1963465641, 1167483655, 1388379870, 1651460451, 1963928518, 1167758884, 1388707173, 1651849705, 1964391422, 1168034128, 1389034495, 1652238982, 1964854354, 1168309389, 1389361837, 
+1652628283, 1965317312, 1168584665, 1389689199, 1653017606, 1965780298, 1168859958, 1390016579, 1653406952, 1966243311, 1169135268, 1390343979, 1653796321, 1966706352, 1169410593, 1390671398, 
+1654185713, 1967169419, 1169685935, 1390998836, 1654575128, 1967632514, 1169961293, 1391326294, 1654964566, 1968095636, 1170236667, 1391653771, 1655354026, 1968558786, 1170512057, 1391981267, 
+1655743510, 1969021963, 1170787464, 1392308782, 1656133016, 1969485167, 1171062886, 1392636317, 1656522546, 1969948398, 1171338325, 1392963871, 1656912098, 1970411656, 1171613780, 1393291444, 
+1657301673, 1970874942, 1171889252, 1393619036, 1657691271, 1971338255, 1172164739, 1393946648, 1658080892, 1971801595, 1172440243, 1394274279, 1658470536, 1972264962, 1172715763, 1394601929, 
+1658860203, 1972728356, 1172991299, 1394929598, 1659249893, 1973191778, 1173266851, 1395257287, 1659639605, 1973655227, 1173542419, 1395584995, 1660029341, 1974118703, 1173818004, 1395912722, 
+1660419099, 1974582207, 1174093605, 1396240468, 1660808880, 1975045737, 1174369222, 1396568234, 1661198684, 1975509295, 1174644855, 1396896019, 1661588511, 1975972880, 1174920504, 1397223823, 
+1661978361, 1976436492, 1175196169, 1397551646, 1662368234, 1976900131, 1175471851, 1397879489, 1662758129, 1977363798, 1175747549, 1398207350, 1663148048, 1977827491, 1176023263, 1398535231, 
+1663537989, 1978291212, 1176298993, 1398863131, 1663927953, 1978754960, 1176574739, 1399191051, 1664317940, 1979218736, 1176850501, 1399518989, 1664707950, 1979682538, 1177126280, 1399846947, 
+1665097982, 1980146368, 1177402075, 1400174924, 1665488038, 1980610224, 1177677885, 1400502920, 1665878116, 1981074108, 1177953712, 1400830936, 1666268217, 1981538019, 1178229556, 1401158971, 
+1666658341, 1982001957, 1178505415, 1401487024, 1667048488, 1982465923, 1178781290, 1401815097, 1667438657, 1982929915, 1179057182, 1402143190, 1667828850, 1983393935, 1179333090, 1402471301, 
+1668219065, 1983857982, 1179609013, 1402799432, 1668609303, 1984322056, 1179884953, 1403127582, 1668999564, 1984786157, 1180160910, 1403455751, 1669389848, 1985250285, 1180436882, 1403783939, 
+1669780154, 1985714440, 1180712870, 1404112146, 1670170484, 1986178623, 1180988875, 1404440373, 1670560836, 1986642832, 1181264895, 1404768618, 1670951211, 1987107069, 1181540932, 1405096883, 
+1671341609, 1987571333, 1181816985, 1405425167, 1671732029, 1988035623, 1182093054, 1405753471, 1672122473, 1988499941, 1182369139, 1406081793, 1672512939, 1988964287, 1182645241, 1406410135, 
+1672903428, 1989428659, 1182921358, 1406738495, 1673293939, 1989893058, 1183197491, 1407066875, 1673684474, 1990357485, 1183473641, 1407395274, 1674075031, 1990821938, 1183749807, 1407723693, 
+1674465611, 1991286419, 1184025989, 1408052130, 1674856214, 1991750926, 1184302186, 1408380586, 1675246840, 1992215461, 1184578401, 1408709062, 1675637488, 1992680023, 1184854631, 1409037557, 
+1676028159, 1993144612, 1185130877, 1409366071, 1676418853, 1993609228, 1185407139, 1409694604, 1676809570, 1994073871, 1185683418, 1410023156, 1677200309, 1994538541, 1185959712, 1410351728, 
+1677591072, 1995003238, 1186236023, 1410680318, 1677981857, 1995467963, 1186512349, 1411008928, 1678372664, 1995932714, 1186788692, 1411337557, 1678763495, 1996397492, 1187065051, 1411666205, 
+1679154348, 1996862298, 1187341426, 1411994872, 1679545224, 1997327130, 1187617817, 1412323558, 1679936123, 1997791990, 1187894224, 1412652263, 1680327044, 1998256876, 1188170648, 1412980988, 
+1680717988, 1998721790, 1188447087, 1413309731, 1681108955, 1999186731, 1188723542, 1413638494, 1681499945, 1999651698, 1189000014, 1413967276, 1681890957, 2000116693, 1189276501, 1414296077, 
+1682281993, 2000581715, 1189553005, 1414624897, 1682673050, 2001046764, 1189829524, 1414953736, 1683064131, 2001511840, 1190106060, 1415282594, 1683455234, 2001976942, 1190382612, 1415611472, 
+1683846360, 2002442072, 1190659180, 1415940368, 1684237509, 2002907229, 1190935764, 1416269284, 1684628680, 2003372413, 1191212364, 1416598218, 1685019875, 2003837624, 1191488980, 1416927172, 
+1685411091, 2004302862, 1191765612, 1417256145, 1685802331, 2004768126, 1192042260, 1417585137, 1686193593, 2005233418, 1192318924, 1417914148, 1686584878, 2005698737, 1192595604, 1418243178, 
+1686976186, 2006164083, 1192872301, 1418572227, 1687367516, 2006629456, 1193149013, 1418901296, 1687758869, 2007094856, 1193425741, 1419230383, 1688150245, 2007560282, 1193702486, 1419559489, 
+1688541643, 2008025736, 1193979246, 1419888615, 1688933064, 2008491217, 1194256023, 1420217759, 1689324508, 2008956725, 1194532815, 1420546923, 1689715975, 2009422259, 1194809624, 1420876106, 
+1690107464, 2009887821, 1195086449, 1421205308, 1690498975, 2010353410, 1195363289, 1421534528, 1690890510, 2010819025, 1195640146, 1421863768, 1691282067, 2011284668, 1195917019, 1422193027, 
+1691673647, 2011750337, 1196193907, 1422522305, 1692065249, 2012216034, 1196470812, 1422851603, 1692456874, 2012681757, 1196747733, 1423180919, 1692848522, 2013147507, 1197024670, 1423510254, 
+1693240193, 2013613284, 1197301622, 1423839608, 1693631886, 2014079089, 1197578591, 1424168981, 1694023601, 2014544920, 1197855576, 1424498374, 1694415340, 2015010778, 1198132577, 1424827785, 
+1694807101, 2015476663, 1198409594, 1425157216, 1695198884, 2015942575, 1198686627, 1425486665, 1695590691, 2016408514, 1198963676, 1425816134, 1695982520, 2016874479, 1199240740, 1426145621, 
+1696374371, 2017340472, 1199517821, 1426475128, 1696766245, 2017806492, 1199794918, 1426804653, 1697158142, 2018272538, 1200072031, 1427134198, 1697550062, 2018738611, 1200349160, 1427463762, 
+1697942004, 2019204712, 1200626305, 1427793344, 1698333968, 2019670839, 1200903466, 1428122946, 1698725956, 2020136993, 1201180643, 1428452567, 1699117966, 2020603174, 1201457836, 1428782206, 
+1699509998, 2021069382, 1201735044, 1429111865, 1699902053, 2021535617, 1202012269, 1429441543, 1700294131, 2022001878, 1202289510, 1429771240, 1700686231, 2022468167, 1202566767, 1430100955, 
+1701078354, 2022934482, 1202844040, 1430430690, 1701470500, 2023400824, 1203121328, 1430760444, 1701862668, 2023867194, 1203398633, 1431090217, 1702254859, 2024333590, 1203675954, 1431420009, 
+1702647072, 2024800012, 1203953291, 1431749819, 1703039308, 2025266462, 1204230643, 1432079649, 1703431566, 2025732939, 1204508012, 1432409498, 1703823848, 2026199442, 1204785397, 1432739366, 
+1704216151, 2026665972, 1205062797, 1433069252, 1704608477, 2027132530, 1205340214, 1433399158, 1705000826, 2027599114, 1205617646, 1433729083, 1705393198, 2028065724, 1205895095, 1434059026, 
+1705785592, 2028532362, 1206172559, 1434388989, 1706178008, 2028999027, 1206450039, 1434718971, 1706570447, 2029465718, 1206727536, 1435048971, 1706962909, 2029932436, 1207005048, 1435378991, 
+1707355393, 2030399181, 1207282576, 1435709030, 1707747900, 2030865953, 1207560121, 1436039087, 1708140429, 2031332752, 1207837681, 1436369164, 1708532981, 2031799577, 1208115257, 1436699259, 
+1708925555, 2032266430, 1208392849, 1437029374, 1709318152, 2032733309, 1208670457, 1437359507, 1709710772, 2033200215, 1208948081, 1437689659, 1710103414, 2033667147, 1209225721, 1438019831, 
+1710496079, 2034134107, 1209503376, 1438350021, 1710888766, 2034601093, 1209781048, 1438680230, 1711281475, 2035068106, 1210058736, 1439010458, 1711674208, 2035535146, 1210336439, 1439340705, 
+1712066962, 2036002213, 1210614159, 1439670971, 1712459740, 2036469307, 1210891894, 1440001256, 1712852539, 2036936427, 1211169646, 1440331560, 1713245362, 2037403574, 1211447413, 1440661883, 
+1713638207, 2037870748, 1211725196, 1440992225, 1714031074, 2038337948, 1212002995, 1441322586, 1714423964, 2038805176, 1212280811, 1441652965, 1714816876, 2039272430, 1212558642, 1441983364, 
+1715209811, 2039739711, 1212836488, 1442313781, 1715602768, 2040207019, 1213114351, 1442644218, 1715995748, 2040674353, 1213392230, 1442974673, 1716388751, 2041141714, 1213670125, 1443305148, 
+1716781775, 2041609102, 1213948035, 1443635641, 1717174823, 2042076517, 1214225962, 1443966153, 1717567893, 2042543958, 1214503904, 1444296684, 1717960985, 2043011427, 1214781862, 1444627234, 
+1718354100, 2043478922, 1215059836, 1444957803, 1718747237, 2043946443, 1215337827, 1445288390, 1719140397, 2044413992, 1215615832, 1445618997, 1719533579, 2044881567, 1215893854, 1445949623, 
+1719926784, 2045349169, 1216171892, 1446280267, 1720320011, 2045816797, 1216449946, 1446610931, 1720713261, 2046284453, 1216728015, 1446941613, 1721106533, 2046752135, 1217006101, 1447272314, 
+1721499828, 2047219844, 1217284202, 1447603034, 1721893145, 2047687579, 1217562319, 1447933773, 1722286484, 2048155341, 1217840452, 1448264531, 1722679846, 2048623130, 1218118601, 1448595308, 
+1723073231, 2049090946, 1218396766, 1448926103, 1723466638, 2049558788, 1218674947, 1449256918, 1723860067, 2050026657, 1218953143, 1449587751, 1724253519, 2050494553, 1219231356, 1449918603, 
+1724646993, 2050962475, 1219509584, 1450249474, 1725040490, 2051430425, 1219787828, 1450580364, 1725434009, 2051898400, 1220066088, 1450911273, 1725827551, 2052366403, 1220344364, 1451242201, 
+1726221115, 2052834432, 1220622656, 1451573148, 1726614701, 2053302488, 1220900964, 1451904113, 1727008310, 2053770570, 1221179287, 1452235097, 1727401942, 2054238680, 1221457627, 1452566101, 
+1727795596, 2054706815, 1221735982, 1452897123, 1728189272, 2055174978, 1222014353, 1453228163, 1728582970, 2055643167, 1222292740, 1453559223, 1728976691, 2056111383, 1222571143, 1453890302, 
+1729370435, 2056579626, 1222849562, 1454221399, 1729764201, 2057047895, 1223127996, 1454552516, 1730157989, 2057516190, 1223406446, 1454883651, 1730551800, 2057984513, 1223684913, 1455214805, 
+1730945633, 2058452862, 1223963395, 1455545978, 1731339488, 2058921238, 1224241893, 1455877169, 1731733366, 2059389640, 1224520406, 1456208380, 1732127266, 2059858069, 1224798936, 1456539609, 
+1732521189, 2060326525, 1225077481, 1456870857, 1732915134, 2060795007, 1225356043, 1457202124, 1733309102, 2061263516, 1225634620, 1457533410, 1733703091, 2061732052, 1225913212, 1457864715, 
+1734097104, 2062200614, 1226191821, 1458196038, 1734491138, 2062669203, 1226470446, 1458527380, 1734885195, 2063137818, 1226749086, 1458858742, 1735279275, 2063606460, 1227027742, 1459190121, 
+1735673376, 2064075129, 1227306414, 1459521520, 1736067500, 2064543824, 1227585102, 1459852938, 1736461647, 2065012546, 1227863806, 1460184374, 1736855816, 2065481294, 1228142525, 1460515829, 
+1737250007, 2065950069, 1228421261, 1460847303, 1737644221, 2066418871, 1228700012, 1461178796, 1738038457, 2066887699, 1228978779, 1461510308, 1738432715, 2067356554, 1229257561, 1461841838, 
+1738826996, 2067825435, 1229536360, 1462173387, 1739221299, 2068294343, 1229815174, 1462504955, 1739615624, 2068763277, 1230094004, 1462836542, 1740009972, 2069232238, 1230372850, 1463168148, 
+1740404342, 2069701226, 1230651712, 1463499772, 1740798734, 2070170240, 1230930590, 1463831415, 1741193149, 2070639281, 1231209483, 1464163077, 1741587586, 2071108349, 1231488392, 1464494758, 
+1741982045, 2071577442, 1231767317, 1464826457, 1742376527, 2072046563, 1232046258, 1465158176, 1742771031, 2072515710, 1232325214, 1465489913, 1743165558, 2072984884, 1232604186, 1465821669, 
+1743560106, 2073454084, 1232883175, 1466153443, 1743954677, 2073923310, 1233162178, 1466485236, 1744349271, 2074392564, 1233441198, 1466817049, 1744743886, 2074861843, 1233720233, 1467148880, 
+1745138524, 2075331150, 1233999285, 1467480729, 1745533185, 2075800483, 1234278352, 1467812598, 1745927867, 2076269842, 1234557434, 1468144485, 1746322572, 2076739228, 1234836533, 1468476391, 
+1746717299, 2077208640, 1235115647, 1468808315, 1747112049, 2077678079, 1235394777, 1469140259, 1747506821, 2078147545, 1235673923, 1469472221, 1747901615, 2078617037, 1235953085, 1469804202, 
+1748296431, 2079086555, 1236232262, 1470136202, 1748691270, 2079556100, 1236511455, 1470468220, 1749086131, 2080025672, 1236790664, 1470800257, 1749481014, 2080495270, 1237069889, 1471132313, 
+1749875920, 2080964894, 1237349129, 1471464388, 1750270848, 2081434545, 1237628385, 1471796481, 1750665798, 2081904223, 1237907657, 1472128594, 1751060770, 2082373927, 1238186945, 1472460724, 
+1751455765, 2082843657, 1238466248, 1472792874, 1751850782, 2083313414, 1238745567, 1473125042, 1752245821, 2083783198, 1239024902, 1473457229, 1752640882, 2084253007, 1239304253, 1473789435, 
+1753035966, 2084722844, 1239583619, 1474121660, 1753431072, 2085192707, 1239863001, 1474453903, 1753826200, 2085662596, 1240142399, 1474786165, 1754221351, 2086132512, 1240421813, 1475118446, 
+1754616524, 2086602454, 1240701242, 1475450745, 1755011719, 2087072423, 1240980687, 1475783063, 1755406936, 2087542418, 1241260148, 1476115400, 1755802176, 2088012440, 1241539625, 1476447755, 
+1756197437, 2088482488, 1241819117, 1476780130, 1756592721, 2088952562, 1242098625, 1477112522, 1756988028, 2089422663, 1242378149, 1477444934, 1757383356, 2089892791, 1242657688, 1477777364, 
+1757778707, 2090362945, 1242937243, 1478109813, 1758174080, 2090833125, 1243216814, 1478442281, 1758569475, 2091303332, 1243496401, 1478774767, 1758964892, 2091773565, 1243776003, 1479107273, 
+1759360332, 2092243825, 1244055621, 1479439796, 1759755794, 2092714111, 1244335255, 1479772339, 1760151278, 2093184423, 1244614904, 1480104900, 1760546784, 2093654762, 1244894570, 1480437480, 
+1760942313, 2094125127, 1245174251, 1480770078, 1761337863, 2094595519, 1245453947, 1481102695, 1761733436, 2095065937, 1245733659, 1481435331, 1762129031, 2095536382, 1246013387, 1481767986, 
+1762524649, 2096006853, 1246293131, 1482100659, 1762920288, 2096477350, 1246572891, 1482433351, 1763315950, 2096947874, 1246852666, 1482766061, 1763711634, 2097418424, 1247132456, 1483098790, 
+1764107340, 2097889000, 1247412263, 1483431538, 1764503068, 2098359603, 1247692085, 1483764305, 1764898819, 2098830233, 1247971923, 1484097090, 1765294592, 2099300888, 1248251776, 1484429894, 
+1765690386, 2099771570, 1248531646, 1484762716, 1766086203, 2100242279, 1248811531, 1485095558, 1766482043, 2100713014, 1249091431, 1485428417, 1766877904, 2101183775, 1249371347, 1485761296, 
+1767273788, 2101654562, 1249651279, 1486094193, 1767669693, 2102125376, 1249931227, 1486427109, 1768065621, 2102596217, 1250211190, 1486760043, 1768461571, 2103067083, 1250491169, 1487092996, 
+1768857544, 2103537976, 1250771164, 1487425968, 1769253538, 2104008896, 1251051174, 1487758958, 1769649555, 2104479841, 1251331200, 1488091967, 1770045593, 2104950814, 1251611242, 1488424994, 
+1770441654, 2105421812, 1251891299, 1488758040, 1770837737, 2105892837, 1252171372, 1489091105, 1771233842, 2106363888, 1252451461, 1489424189, 1771629970, 2106834965, 1252731565, 1489757291, 
+1772026119, 2107306069, 1253011685, 1490090411, 1772422291, 2107777199, 1253291821, 1490423551, 1772818485, 2108248356, 1253571972, 1490756709, 1773214701, 2108719538, 1253852139, 1491089885, 
+1773610939, 2109190747, 1254132322, 1491423080, 1774007199, 2109661983, 1254412520, 1491756294, 1774403481, 2110133245, 1254692734, 1492089526, 1774799785, 2110604533, 1254972964, 1492422777, 
+1775196112, 2111075847, 1255253209, 1492756047, 1775592461, 2111547188, 1255533470, 1493089335, 1775988831, 2112018554, 1255813746, 1493422642, 1776385224, 2112489948, 1256094038, 1493755967, 
+1776781639, 2112961367, 1256374346, 1494089311, 1777178076, 2113432813, 1256654669, 1494422674, 1777574536, 2113904285, 1256935008, 1494756055, 1777971017, 2114375784, 1257215363, 1495089455, 
+1778367520, 2114847308, 1257495733, 1495422873, 1778764046, 2115318859, 1257776119, 1495756310, 1779160594, 2115790437, 1258056521, 1496089765, 1779557163, 2116262040, 1258336938, 1496423239, 
+1779953755, 2116733670, 1258617371, 1496756732, 1780350369, 2117205326, 1258897819, 1497090243, 1780747005, 2117677009, 1259178283, 1497423773, 1781143663, 2118148717, 1259458763, 1497757322, 
+1781540344, 2118620452, 1259739258, 1498090888, 1781937046, 2119092213, 1260019769, 1498424474, 1782333770, 2119564001, 1260300295, 1498758078, 1782730517, 2120035814, 1260580837, 1499091701, 
+1783127285, 2120507654, 1260861395, 1499425342, 1783524076, 2120979521, 1261141968, 1499759002, 1783920888, 2121451413, 1261422557, 1500092680, 1784317723, 2121923332, 1261703162, 1500426377, 
+1784714580, 2122395277, 1261983782, 1500760092, 1785111459, 2122867248, 1262264418, 1501093826, 1785508360, 2123339245, 1262545069, 1501427579, 1785905283, 2123811269, 1262825736, 1501761350, 
+1786302228, 2124283319, 1263106418, 1502095140, 1786699195, 2124755395, 1263387116, 1502428948, 1787096184, 2125227497, 1263667830, 1502762775, 1787493195, 2125699625, 1263948559, 1503096620, 
+1787890228, 2126171780, 1264229304, 1503430484, 1788287283, 2126643961, 1264510065, 1503764366, 1788684361, 2127116168, 1264790841, 1504098267, 1789081460, 2127588402, 1265071633, 1504432186, 
+1789478581, 2128060661, 1265352440, 1504766124, 1789875725, 2128532947, 1265633263, 1505100081, 1790272890, 2129005259, 1265914101, 1505434056, 1790670078, 2129477597, 1266194955, 1505768049, 
+1791067287, 2129949962, 1266475824, 1506102061, 1791464519, 2130422352, 1266756710, 1506436092, 1791861772, 2130894769, 1267037610, 1506770141, 1792259048, 2131367212, 1267318526, 1507104209, 
+1792656346, 2131839681, 1267599458, 1507438295, 1793053665, 2132312176, 1267880406, 1507772399, 1793451007, 2132784698, 1268161369, 1508106522, 1793848370, 2133257245, 1268442347, 1508440664, 
+1794245756, 2133729819, 1268723341, 1508774824, 1794643164, 2134202419, 1269004351, 1509109003, 1795040593, 2134675045, 1269285376, 1509443200, 1795438045, 2135147697, 1269566417, 1509777416, 
+1795835518, 2135620376, 1269847473, 1510111650, 1796233014, 2136093081, 1270128545, 1510445902, 1796630532, 2136565811, 1270409632, 1510780174, 1797028071, 2137038568, 1270690735, 1511114463, 
+1797425633, 2137511351, 1270971854, 1511448771, 1797823216, 2137984161, 1271252988, 1511783098, 1798220822, 2138456996, 1271534137, 1512117443, 1798618450, 2138929857, 1271815302, 1512451807, 
+1799016099, 2139402745, 1272096483, 1512786189, 1799413771, 2139875659, 1272377679, 1513120589, 1799811464, 2140348599, 1272658891, 1513455008, 1800209179, 2140821565, 1272940118, 1513789446, 
+1800606917, 2141294557, 1273221361, 1514123902, 1801004676, 2141767575, 1273502619, 1514458376, 1801402457, 2142240619, 1273783893, 1514792869, 1801800261, 2142713690, 1274065183, 1515127380, 
+1802198086, 2143186787, 1274346488, 1515461910, 1802595933, 2143659909, 1274627808, 1515796458, 1802993802, 2144133058, 1274909144, 1516131025, 1803391693, 2144606233, 1275190496, 1516465610, 
+1803789607, 2145079434, 1275471863, 1516800214, 1804187542, 2145552661, 1275753245, 1517134836, 1804585498, 2146025914, 1276034643, 1517469477, 1804983477, 2146499194, 1276316057, 1517804136, 
+1805381478, 2146972499, 1276597486, 1518138813, 1805779501, 2147445831, 1276878930, 1518473509, 1806177546, 1073959594, 1277160391, 1518808223, 1806575612, 1074196286, 1277441866, 1519142956, 
+1806973701, 1074432991, 1277723357, 1519477707, 1807371811, 1074669709, 1278004864, 1519812477, 1807769944, 1074906440, 1278286386, 1520147265, 1808168098, 1075143184, 1278567924, 1520482072, 
+1808566274, 1075379941, 1278849477, 1520816897, 1808964472, 1075616711, 1279131045, 1521151740, 1809362692, 1075853494, 1279412629, 1521486602, 1809760934, 1076090290, 1279694229, 1521821482, 
+1810159198, 1076327099, 1279975844, 1522156381, 1810557484, 1076563921, 1280257475, 1522491298, 1810955792, 1076800756, 1280539121, 1522826234, 1811354121, 1077037605, 1280820782, 1523161188, 
+1811752473, 1077274466, 1281102459, 1523496160, 1812150846, 1077511340, 1281384152, 1523831151, 1812549242, 1077748227, 1281665860, 1524166160, 1812947659, 1077985128, 1281947584, 1524501187, 
+1813346098, 1078222041, 1282229323, 1524836233, 1813744559, 1078458967, 1282511077, 1525171298, 1814143042, 1078695906, 1282792847, 1525506381, 1814541547, 1078932859, 1283074632, 1525841482, 
+1814940073, 1079169824, 1283356433, 1526176601, 1815338622, 1079406803, 1283638250, 1526511739, 1815737192, 1079643794, 1283920081, 1526846896, 1816135784, 1079880798, 1284201929, 1527182071, 
+1816534398, 1080117816, 1284483791, 1527517264, 1816933034, 1080354846, 1284765670, 1527852475, 1817331692, 1080591889, 1285047563, 1528187705, 1817730372, 1080828946, 1285329472, 1528522954, 
+1818129074, 1081066015, 1285611397, 1528858220, 1818527797, 1081303098, 1285893337, 1529193506, 1818926542, 1081540193, 1286175293, 1529528809, 1819325310, 1081777301, 1286457264, 1529864131, 
+1819724099, 1082014423, 1286739250, 1530199471, 1820122909, 1082251557, 1287021252, 1530534830, 1820521742, 1082488704, 1287303269, 1530870207, 1820920597, 1082725865, 1287585302, 1531205602, 
+1821319473, 1082963038, 1287867350, 1531541016, 1821718371, 1083200224, 1288149414, 1531876448, 1822117291, 1083437424, 1288431493, 1532211898, 1822516233, 1083674636, 1288713587, 1532547367, 
+1822915197, 1083911861, 1288995697, 1532882854, 1823314183, 1084149099, 1289277823, 1533218360, 1823713190, 1084386351, 1289559964, 1533553884, 1824112219, 1084623615, 1289842120, 1533889426, 
+1824511270, 1084860892, 1290124292, 1534224987, 1824910343, 1085098182, 1290406479, 1534560566, 1825309438, 1085335485, 1290688681, 1534896163, 1825708554, 1085572801, 1290970899, 1535231779, 
+1826107693, 1085810130, 1291253133, 1535567413, 1826506853, 1086047472, 1291535381, 1535903065, 1826906035, 1086284827, 1291817646, 1536238736, 1827305238, 1086522195, 1292099925, 1536574425, 
+1827704464, 1086759576, 1292382220, 1536910132, 1828103711, 1086996970, 1292664531, 1537245858, 1828502980, 1087234377, 1292946857, 1537581602, 1828902271, 1087471797, 1293229198, 1537917364, 
+1829301584, 1087709230, 1293511555, 1538253145, 1829700919, 1087946675, 1293793927, 1538588944, 1830100275, 1088184134, 1294076315, 1538924761, 1830499653, 1088421606, 1294358718, 1539260596, 
+1830899053, 1088659090, 1294641136, 1539596450, 1831298475, 1088896588, 1294923570, 1539932323, 1831697918, 1089134098, 1295206019, 1540268213, 1832097383, 1089371622, 1295488484, 1540604122, 
+1832496870, 1089609158, 1295770964, 1540940049, 1832896379, 1089846708, 1296053459, 1541275995, 1833295910, 1090084270, 1296335970, 1541611959, 1833695462, 1090321845, 1296618496, 1541947941, 
+1834095036, 1090559433, 1296901037, 1542283941, 1834494632, 1090797034, 1297183594, 1542619960, 1834894250, 1091034648, 1297466167, 1542955997, 1835293889, 1091272275, 1297748754, 1543292052, 
+1835693550, 1091509915, 1298031358, 1543628126, 1836093233, 1091747568, 1298313976, 1543964218, 1836492938, 1091985234, 1298596610, 1544300328, 1836892664, 1092222913, 1298879259, 1544636456, 
+1837292412, 1092460604, 1299161924, 1544972603, 1837692182, 1092698309, 1299444604, 1545308768, 1838091974, 1092936027, 1299727299, 1545644952, 1838491787, 1093173757, 1300010010, 1545981153, 
+1838891622, 1093411500, 1300292736, 1546317373, 1839291479, 1093649257, 1300575477, 1546653611, 1839691358, 1093887026, 1300858234, 1546989868, 1840091258, 1094124808, 1301141006, 1547326143, 
+1840491180, 1094362603, 1301423794, 1547662436, 1840891124, 1094600411, 1301706597, 1547998747, 1841291089, 1094838232, 1301989415, 1548335076, 1841691076, 1095076066, 1302272249, 1548671424, 
+1842091085, 1095313913, 1302555098, 1549007790, 1842491116, 1095551772, 1302837962, 1549344175, 1842891168, 1095789645, 1303120842, 1549680577, 1843291242, 1096027530, 1303403737, 1550016998, 
+1843691338, 1096265429, 1303686648, 1550353437, 1844091456, 1096503340, 1303969573, 1550689894, 1844491595, 1096741264, 1304252515, 1551026370, 1844891756, 1096979201, 1304535471, 1551362864, 
+1845291938, 1097217151, 1304818443, 1551699376, 1845692143, 1097455114, 1305101430, 1552035906, 1846092369, 1097693090, 1305384432, 1552372455, 1846492616, 1097931079, 1305667450, 1552709022, 
+1846892886, 1098169080, 1305950484, 1553045607, 1847293177, 1098407095, 1306233532, 1553382210, 1847693489, 1098645122, 1306516596, 1553718832, 1848093824, 1098883162, 1306799675, 1554055471, 
+1848494180, 1099121215, 1307082770, 1554392129, 1848894558, 1099359281, 1307365879, 1554728806, 1849294957, 1099597360, 1307649005, 1555065500, 1849695378, 1099835452, 1307932145, 1555402213, 
+1850095821, 1100073557, 1308215301, 1555738944, 1850496286, 1100311675, 1308498472, 1556075693, 1850896772, 1100549805, 1308781659, 1556412460, 1851297280, 1100787948, 1309064860, 1556749246, 
+1851697809, 1101026105, 1309348077, 1557086050, 1852098360, 1101264274, 1309631310, 1557422872, 1852498933, 1101502456, 1309914558, 1557759712, 1852899527, 1101740651, 1310197821, 1558096570, 
+1853300143, 1101978858, 1310481099, 1558433447, 1853700781, 1102217079, 1310764393, 1558770342, 1854101441, 1102455313, 1311047702, 1559107255, 1854502122, 1102693559, 1311331026, 1559444186, 
+1854902824, 1102931818, 1311614366, 1559781136, 1855303549, 1103170090, 1311897720, 1560118103, 1855704295, 1103408375, 1312181091, 1560455089, 1856105062, 1103646673, 1312464476, 1560792093, 
+1856505851, 1103884984, 1312747877, 1561129115, 1856906662, 1104123307, 1313031293, 1561466156, 1857307495, 1104361644, 1313314724, 1561803214, 1857708349, 1104599993, 1313598171, 1562140291, 
+1858109225, 1104838355, 1313881633, 1562477386, 1858510122, 1105076730, 1314165110, 1562814499, 1858911041, 1105315118, 1314448603, 1563151631, 1859311982, 1105553519, 1314732111, 1563488780, 
+1859712944, 1105791932, 1315015634, 1563825948, 1860113928, 1106030359, 1315299172, 1564163134, 1860514933, 1106268798, 1315582726, 1564500338, 1860915960, 1106507250, 1315866295, 1564837560, 
+1861317009, 1106745715, 1316149879, 1565174800, 1861718079, 1106984193, 1316433478, 1565512059, 1862119171, 1107222684, 1316717093, 1565849336, 1862520285, 1107461187, 1317000723, 1566186631, 
+1862921420, 1107699703, 1317284369, 1566523944, 1863322576, 1107938233, 1317568029, 1566861275, 1863723755, 1108176775, 1317851705, 1567198624, 1864124954, 1108415330, 1318135396, 1567535992, 
+1864526176, 1108653897, 1318419103, 1567873377, 1864927419, 1108892478, 1318702824, 1568210781, 1865328683, 1109131071, 1318986561, 1568548203, 1865729970, 1109369677, 1319270313, 1568885643, 
+1866131277, 1109608296, 1319554081, 1569223102, 1866532607, 1109846928, 1319837864, 1569560578, 1866933958, 1110085573, 1320121662, 1569898073, 1867335330, 1110324230, 1320405475, 1570235585, 
+1867736724, 1110562901, 1320689303, 1570573116, 1868138140, 1110801584, 1320973147, 1570910665, 1868539577, 1111040280, 1321257006, 1571248232, 1868941036, 1111278989, 1321540880, 1571585817, 
+1869342516, 1111517710, 1321824769, 1571923421, 1869744018, 1111756445, 1322108674, 1572261042, 1870145541, 1111995192, 1322392594, 1572598682, 1870547086, 1112233952, 1322676529, 1572936339, 
+1870948653, 1112472725, 1322960480, 1573274015, 1871350241, 1112711511, 1323244445, 1573611709, 1871751851, 1112950309, 1323528426, 1573949421, 1872153482, 1113189120, 1323812422, 1574287152, 
+1872555134, 1113427945, 1324096434, 1574624900, 1872956809, 1113666782, 1324380460, 1574962666, 1873358505, 1113905631, 1324664502, 1575300451, 1873760222, 1114144494, 1324948559, 1575638254, 
+1874161961, 1114383369, 1325232631, 1575976074, 1874563721, 1114622257, 1325516719, 1576313913, 1874965503, 1114861158, 1325800822, 1576651770, 1875367306, 1115100072, 1326084940, 1576989645, 
+1875769131, 1115338999, 1326369073, 1577327538, 1876170978, 1115577938, 1326653221, 1577665450, 1876572846, 1115816890, 1326937385, 1578003379, 1876974735, 1116055855, 1327221563, 1578341326, 
+1877376646, 1116294833, 1327505757, 1578679292, 1877778579, 1116533823, 1327789967, 1579017276, 1878180533, 1116772827, 1328074191, 1579355277, 1878582509, 1117011843, 1328358431, 1579693297, 
+1878984506, 1117250872, 1328642686, 1580031335, 1879386524, 1117489913, 1328926956, 1580369391, 1879788564, 1117728968, 1329211241, 1580707465, 1880190626, 1117968035, 1329495541, 1581045557, 
+1880592709, 1118207115, 1329779857, 1581383667, 1880994813, 1118446208, 1330064188, 1581721796, 1881396939, 1118685313, 1330348534, 1582059942, 1881799087, 1118924432, 1330632895, 1582398106, 
+1882201256, 1119163563, 1330917272, 1582736289, 1882603446, 1119402707, 1331201663, 1583074489, 1883005658, 1119641863, 1331486070, 1583412708, 1883407892, 1119881033, 1331770492, 1583750945, 
+1883810147, 1120120215, 1332054929, 1584089199, 1884212423, 1120359410, 1332339382, 1584427472, 1884614721, 1120598618, 1332623849, 1584765763, 1885017040, 1120837838, 1332908332, 1585104072, 
+1885419381, 1121077071, 1333192830, 1585442399, 1885821744, 1121316318, 1333477343, 1585780744, 1886224127, 1121555576, 1333761871, 1586119107, 1886626533, 1121794848, 1334046415, 1586457488, 
+1887028959, 1122034132, 1334330973, 1586795887, 1887431407, 1122273429, 1334615547, 1587134304, 1887833877, 1122512739, 1334900136, 1587472740, 1888236368, 1122752062, 1335184740, 1587811193, 
+1888638880, 1122991397, 1335469360, 1588149664, 1889041414, 1123230745, 1335753994, 1588488154, 1889443970, 1123470106, 1336038644, 1588826661, 1889846547, 1123709480, 1336323308, 1589165186, 
+1890249145, 1123948866, 1336607988, 1589503730, 1890651764, 1124188265, 1336892684, 1589842291, 1891054406, 1124427677, 1337177394, 1590180871, 1891457068, 1124667102, 1337462119, 1590519468, 
+1891859752, 1124906539, 1337746860, 1590858084, 1892262458, 1125145989, 1338031616, 1591196717, 1892665184, 1125385452, 1338316386, 1591535369, 1893067933, 1125624927, 1338601172, 1591874038, 
+1893470702, 1125864416, 1338885974, 1592212726, 1893873494, 1126103917, 1339170790, 1592551432, 1894276306, 1126343430, 1339455621, 1592890155, 1894679140, 1126582957, 1339740468, 1593228897, 
+1895081995, 1126822496, 1340025330, 1593567657, 1895484872, 1127062048, 1340310207, 1593906434, 1895887770, 1127301613, 1340595099, 1594245230, 1896290690, 1127541190, 1340880006, 1594584043, 
+1896693631, 1127780780, 1341164928, 1594922875, 1897096593, 1128020383, 1341449866, 1595261725, 1897499577, 1128259999, 1341734818, 1595600592, 1897902582, 1128499627, 1342019786, 1595939478, 
+1898305609, 1128739268, 1342304769, 1596278382, 1898708657, 1128978922, 1342589767, 1596617303, 1899111726, 1129218589, 1342874780, 1596956243, 1899514817, 1129458268, 1343159808, 1597295200, 
+1899917929, 1129697960, 1343444851, 1597634176, 1900321063, 1129937664, 1343729910, 1597973169, 1900724218, 1130177382, 1344014983, 1598312181, 1901127394, 1130417112, 1344300072, 1598651210, 
+1901530592, 1130656854, 1344585176, 1598990258, 1901933811, 1130896610, 1344870295, 1599329323, 1902337051, 1131136378, 1345155429, 1599668407, 1902740313, 1131376159, 1345440578, 1600007508, 
+1903143596, 1131615953, 1345725742, 1600346628, 1903546900, 1131855759, 1346010922, 1600685765, 1903950226, 1132095578, 1346296116, 1601024920, 1904353574, 1132335410, 1346581326, 1601364093, 
+1904756942, 1132575254, 1346866550, 1601703285, 1905160332, 1132815111, 1347151790, 1602042494, 1905563743, 1133054981, 1347437045, 1602381721, 1905967176, 1133294863, 1347722315, 1602720966, 
+1906370630, 1133534759, 1348007600, 1603060229, 1906774105, 1133774666, 1348292900, 1603399510, 1907177602, 1134014587, 1348578215, 1603738809, 1907581120, 1134254520, 1348863546, 1604078126, 
+1907984660, 1134494466, 1349148891, 1604417461, 1908388220, 1134734425, 1349434252, 1604756813, 1908791802, 1134974396, 1349719627, 1605096184, 1909195406, 1135214380, 1350005018, 1605435573, 
+1909599030, 1135454377, 1350290424, 1605774979, 1910002677, 1135694386, 1350575845, 1606114404, 1910406344, 1135934408, 1350861281, 1606453846, 1910810033, 1136174443, 1351146732, 1606793307, 
+1911213743, 1136414491, 1351432198, 1607132785, 1911617474, 1136654551, 1351717679, 1607472281, 1912021227, 1136894623, 1352003175, 1607811795, 1912425001, 1137134709, 1352288686, 1608151327, 
+1912828796, 1137374807, 1352574213, 1608490878, 1913232613, 1137614918, 1352859754, 1608830445, 1913636450, 1137855041, 1353145311, 1609170031, 1914040310, 1138095177, 1353430882, 1609509635, 
+1914444190, 1138335326, 1353716469, 1609849257, 1914848092, 1138575488, 1354002071, 1610188896, 1915252015, 1138815662, 1354287688, 1610528554, 1915655960, 1139055849, 1354573319, 1610868229, 
+1916059925, 1139296048, 1354858966, 1611207923, 1916463912, 1139536260, 1355144628, 1611547634, 1916867921, 1139776485, 1355430305, 1611887363, 1917271950, 1140016722, 1355715997, 1612227110, 
+1917676001, 1140256972, 1356001705, 1612566875, 1918080073, 1140497235, 1356287427, 1612906658, 1918484167, 1140737511, 1356573164, 1613246459, 1918888281, 1140977799, 1356858916, 1613586277, 
+1919292417, 1141218099, 1357144683, 1613926114, 1919696575, 1141458413, 1357430466, 1614265968, 1920100753, 1141698739, 1357716263, 1614605840, 1920504953, 1141939077, 1358002076, 1614945731, 
+1920909174, 1142179429, 1358287903, 1615285639, 1921313417, 1142419793, 1358573746, 1615625565, 1921717680, 1142660169, 1358859603, 1615965508, 1922121965, 1142900558, 1359145476, 1616305470, 
+1922526271, 1143140960, 1359431363, 1616645450, 1922930599, 1143381375, 1359717266, 1616985447, 1923334947, 1143621802, 1360003184, 1617325463, 1923739317, 1143862242, 1360289116, 1617665496, 
+1924143708, 1144102694, 1360575064, 1618005547, 1924548121, 1144343159, 1360861027, 1618345616, 1924952554, 1144583637, 1361147005, 1618685703, 1925357009, 1144824127, 1361432998, 1619025807, 
+1925761486, 1145064630, 1361719005, 1619365930, 1926165983, 1145305146, 1362005028, 1619706070, 1926570502, 1145545674, 1362291066, 1620046228, 1926975041, 1145786215, 1362577119, 1620386405, 
+1927379602, 1146026768, 1362863187, 1620726599, 1927784185, 1146267334, 1363149270, 1621066810, 1928188788, 1146507913, 1363435368, 1621407040, 1928593413, 1146748504, 1363721481, 1621747288, 
+1928998059, 1146989108, 1364007609, 1622087553, 1929402726, 1147229725, 1364293751, 1622427836, 1929807415, 1147470354, 1364579909, 1622768137, 1930212124, 1147710996, 1364866082, 1623108456, 
+1930616855, 1147951650, 1365152270, 1623448793, 1931021607, 1148192317, 1365438473, 1623789147, 1931426381, 1148432997, 1365724691, 1624129520, 1931831175, 1148673689, 1366010924, 1624469910, 
+1932235991, 1148914394, 1366297172, 1624810318, 1932640828, 1149155112, 1366583435, 1625150744, 1933045686, 1149395842, 1366869713, 1625491188, 1933450565, 1149636584, 1367156006, 1625831649, 
+1933855466, 1149877340, 1367442314, 1626172129, 1934260387, 1150118108, 1367728637, 1626512626, 1934665330, 1150358888, 1368014974, 1626853141, 1935070294, 1150599681, 1368301327, 1627193674, 
+1935475280, 1150840487, 1368587695, 1627534225, 1935880286, 1151081305, 1368874078, 1627874793, 1936285314, 1151322136, 1369160476, 1628215379, 1936690363, 1151562979, 1369446889, 1628555983, 
+1937095433, 1151803836, 1369733316, 1628896605, 1937500524, 1152044704, 1370019759, 1629237245, 1937905636, 1152285585, 1370306217, 1629577903, 1938310770, 1152526479, 1370592689, 1629918578, 
+1938715925, 1152767386, 1370879177, 1630259271, 1939121100, 1153008305, 1371165680, 1630599982, 1939526297, 1153249236, 1371452197, 1630940711, 1939931516, 1153490181, 1371738730, 1631281457, 
+1940336755, 1153731137, 1372025277, 1631622222, 1940742016, 1153972107, 1372311840, 1631963004, 1941147297, 1154213089, 1372598417, 1632303804, 1941552600, 1154454083, 1372885010, 1632644621, 
+1941957924, 1154695090, 1373171617, 1632985457, 1942363269, 1154936110, 1373458239, 1633326310, 1942768635, 1155177142, 1373744876, 1633667181, 1943174023, 1155418187, 1374031529, 1634008070, 
+1943579432, 1155659244, 1374318196, 1634348977, 1943984861, 1155900314, 1374604878, 1634689901, 1944390312, 1156141397, 1374891575, 1635030843, 1944795784, 1156382492, 1375178287, 1635371803, 
+1945201277, 1156623600, 1375465014, 1635712781, 1945606792, 1156864720, 1375751756, 1636053776, 1946012327, 1157105853, 1376038513, 1636394790, 1946417883, 1157346998, 1376325284, 1636735821, 
+1946823461, 1157588156, 1376612071, 1637076870, 1947229060, 1157829326, 1376898873, 1637417936, 1947634680, 1158070509, 1377185689, 1637759020, 1948040321, 1158311705, 1377472521, 1638100123, 
+1948445983, 1158552913, 1377759367, 1638441242, 1948851666, 1158794134, 1378046229, 1638782380, 1949257371, 1159035367, 1378333105, 1639123535, 1949663096, 1159276613, 1378619996, 1639464708, 
+1950068843, 1159517871, 1378906902, 1639805899, 1950474610, 1159759142, 1379193824, 1640147108, 1950880399, 1160000426, 1379480760, 1640488334, 1951286209, 1160241722, 1379767710, 1640829578, 
+1951692040, 1160483030, 1380054676, 1641170840, 1952097892, 1160724351, 1380341657, 1641512120, 1952503765, 1160965685, 1380628653, 1641853417, 1952909660, 1161207031, 1380915663, 1642194732, 
+1953315575, 1161448390, 1381202689, 1642536065, 1953721512, 1161689761, 1381489729, 1642877415, 1954127469, 1161931145, 1381776785, 1643218784, 1954533448, 1162172541, 1382063855, 1643560170, 
+1954939447, 1162413950, 1382350940, 1643901573, 1955345468, 1162655372, 1382638040, 1644242995, 1955751510, 1162896806, 1382925155, 1644584434, 1956157573, 1163138252, 1383212285, 1644925891, 
+1956563657, 1163379711, 1383499430, 1645267366, 1956969762, 1163621183, 1383786589, 1645608858, 1957375888, 1163862667, 1384073764, 1645950368, 1957782036, 1164104163, 1384360954, 1646291896, 
+1958188204, 1164345672, 1384648158, 1646633441, 1958594393, 1164587194, 1384935377, 1646975004, 1959000604, 1164828728, 1385222611, 1647316585, 1959406835, 1165070275, 1385509860, 1647658184, 
+1959813088, 1165311834, 1385797124, 1647999800, 1960219361, 1165553406, 1386084403, 1648341434, 1960625656, 1165794990, 1386371697, 1648683086, 1961031972, 1166036587, 1386659005, 1649024755, 
+1961438309, 1166278196, 1386946329, 1649366442, 1961844666, 1166519818, 1387233667, 1649708147, 1962251045, 1166761452, 1387521020, 1650049870, 1962657445, 1167003099, 1387808389, 1650391610, 
+1963063866, 1167244758, 1388095772, 1650733368, 1963470308, 1167486430, 1388383169, 1651075143, 1963876771, 1167728115, 1388670582, 1651416937, 1964283255, 1167969811, 1388958010, 1651758748, 
+1964689760, 1168211521, 1389245452, 1652100576, 1965096286, 1168453243, 1389532910, 1652442423, 1965502833, 1168694977, 1389820382, 1652784287, 1965909401, 1168936724, 1390107869, 1653126168, 
+1966315991, 1169178483, 1390395371, 1653468068, 1966722601, 1169420255, 1390682888, 1653809985, 1967129232, 1169662039, 1390970419, 1654151919, 1967535884, 1169903836, 1391257966, 1654493872, 
+1967942557, 1170145646, 1391545527, 1654835842, 1968349252, 1170387467, 1391833104, 1655177830, 1968755967, 1170629302, 1392120695, 1655519835, 1969162703, 1170871149, 1392408301, 1655861858, 
+1969569460, 1171113008, 1392695921, 1656203899, 1969976239, 1171354880, 1392983557, 1656545957, 1970383038, 1171596764, 1393271208, 1656888033, 1970789858, 1171838661, 1393558873, 1657230127, 
+1971196699, 1172080570, 1393846553, 1657572238, 1971603562, 1172322492, 1394134248, 1657914367, 1972010445, 1172564426, 1394421958, 1658256514, 1972417349, 1172806373, 1394709683, 1658598678, 
+1972824274, 1173048332, 1394997422, 1658940860, 1973231220, 1173290303, 1395285177, 1659283060, 1973638188, 1173532288, 1395572946, 1659625277, 1974045176, 1173774284, 1395860730, 1659967512, 
+1974452185, 1174016293, 1396148529, 1660309764, 1974859215, 1174258315, 1396436343, 1660652035, 1975266266, 1174500349, 1396724171, 1660994322, 1975673338, 1174742395, 1397012015, 1661336628, 
+1976080431, 1174984454, 1397299873, 1661678951, 1976487545, 1175226526, 1397587746, 1662021292, 1976894680, 1175468610, 1397875634, 1662363650, 1977301836, 1175710706, 1398163537, 1662706026, 
+1977709013, 1175952815, 1398451454, 1663048419, 1978116211, 1176194936, 1398739387, 1663390831, 1978523430, 1176437070, 1399027334, 1663733259, 1978930669, 1176679216, 1399315296, 1664075706, 
+1979337930, 1176921375, 1399603273, 1664418170, 1979745212, 1177163546, 1399891264, 1664760652, 1980152514, 1177405729, 1400179271, 1665103151, 1980559838, 1177647925, 1400467292, 1665445668, 
+1980967182, 1177890134, 1400755328, 1665788202, 1981374548, 1178132355, 1401043379, 1666130754, 1981781934, 1178374588, 1401331444, 1666473324, 1982189341, 1178616834, 1401619525, 1666815912, 
+1982596770, 1178859092, 1401907620, 1667158517, 1983004219, 1179101363, 1402195730, 1667501139, 1983411689, 1179343646, 1402483855, 1667843779, 1983819180, 1179585942, 1402771995, 1668186437, 
+1984226692, 1179828250, 1403060149, 1668529112, 1984634225, 1180070570, 1403348319, 1668871805, 1985041779, 1180312903, 1403636503, 1669214516, 1985449353, 1180555249, 1403924701, 1669557244, 
+1985856949, 1180797607, 1404212915, 1669899990, 1986264566, 1181039977, 1404501144, 1670242753, 1986672203, 1181282360, 1404789387, 1670585534, 1987079861, 1181524755, 1405077645, 1670928332, 
+1987487541, 1181767162, 1405365918, 1671271148, 1987895241, 1182009582, 1405654205, 1671613982, 1988302962, 1182252015, 1405942508, 1671956833, 1988710704, 1182494460, 1406230825, 1672299702, 
+1989118467, 1182736917, 1406519157, 1672642588, 1989526251, 1182979386, 1406807503, 1672985492, 1989934056, 1183221869, 1407095865, 1673328414, 1990341881, 1183464363, 1407384241, 1673671353, 
+1990749728, 1183706870, 1407672632, 1674014310, 1991157595, 1183949390, 1407961038, 1674357284, 1991565483, 1184191921, 1408249458, 1674700276, 1991973392, 1184434466, 1408537894, 1675043285, 
+1992381323, 1184677022, 1408826344, 1675386312, 1992789273, 1184919591, 1409114809, 1675729356, 1993197245, 1185162173, 1409403288, 1676072418, 1993605238, 1185404767, 1409691783, 1676415498, 
+1994013251, 1185647373, 1409980292, 1676758595, 1994421286, 1185889992, 1410268816, 1677101710, 1994829341, 1186132623, 1410557354, 1677444842, 1995237417, 1186375266, 1410845908, 1677787992, 
+1995645514, 1186617922, 1411134476, 1678131159, 1996053632, 1186860591, 1411423059, 1678474344, 1996461771, 1187103271, 1411711657, 1678817546, 1996869931, 1187345965, 1412000269, 1679160766, 
+1997278111, 1187588670, 1412288896, 1679504004, 1997686312, 1187831388, 1412577538, 1679847259, 1998094535, 1188074119, 1412866195, 1680190532, 1998502778, 1188316861, 1413154866, 1680533822, 
+1998911042, 1188559616, 1413443553, 1680877129, 1999319326, 1188802384, 1413732253, 1681220454, 1999727632, 1189045164, 1414020969, 1681563797, 2000135958, 1189287956, 1414309699, 1681907157, 
+2000544306, 1189530761, 1414598445, 1682250535, 2000952674, 1189773578, 1414887204, 1682593930, 2001361063, 1190016408, 1415175979, 1682937343, 2001769472, 1190259250, 1415464768, 1683280774, 
+2002177903, 1190502104, 1415753572, 1683624221, 2002586355, 1190744971, 1416042391, 1683967687, 2002994827, 1190987850, 1416331225, 1684311170, 2003403320, 1191230741, 1416620073, 1684654670, 
+2003811834, 1191473645, 1416908936, 1684998188, 2004220369, 1191716561, 1417197814, 1685341723, 2004628924, 1191959490, 1417486706, 1685685276, 2005037500, 1192202431, 1417775613, 1686028847, 
+2005446098, 1192445384, 1418064535, 1686372434, 2005854716, 1192688350, 1418353472, 1686716040, 2006263354, 1192931328, 1418642423, 1687059663, 2006672014, 1193174318, 1418931389, 1687403303, 
+2007080695, 1193417321, 1419220369, 1687746961, 2007489396, 1193660336, 1419509365, 1688090637, 2007898118, 1193903364, 1419798375, 1688434329, 2008306861, 1194146404, 1420087400, 1688778040, 
+2008715624, 1194389456, 1420376439, 1689121768, 2009124409, 1194632521, 1420665494, 1689465513, 2009533214, 1194875598, 1420954563, 1689809276, 2009942040, 1195118687, 1421243646, 1690153056, 
+2010350887, 1195361789, 1421532745, 1690496854, 2010759754, 1195604903, 1421821858, 1690840669, 2011168643, 1195848030, 1422110985, 1691184502, 2011577552, 1196091169, 1422400128, 1691528352, 
+2011986482, 1196334320, 1422689285, 1691872220, 2012395433, 1196577483, 1422978457, 1692216105, 2012804404, 1196820659, 1423267643, 1692560008, 2013213396, 1197063848, 1423556845, 1692903928, 
+2013622409, 1197307048, 1423846060, 1693247866, 2014031443, 1197550261, 1424135291, 1693591821, 2014440498, 1197793486, 1424424536, 1693935793, 2014849573, 1198036724, 1424713796, 1694279783, 
+2015258669, 1198279974, 1425003071, 1694623791, 2015667786, 1198523236, 1425292360, 1694967816, 2016076924, 1198766511, 1425581664, 1695311858, 2016486082, 1199009798, 1425870983, 1695655918, 
+2016895262, 1199253098, 1426160316, 1695999995, 2017304461, 1199496409, 1426449664, 1696344090, 2017713682, 1199739733, 1426739027, 1696688202, 2018122924, 1199983070, 1427028404, 1697032332, 
+2018532186, 1200226419, 1427317797, 1697376479, 2018941469, 1200469780, 1427607203, 1697720644, 2019350772, 1200713153, 1427896625, 1698064826, 2019760097, 1200956539, 1428186061, 1698409025, 
+2020169442, 1201199937, 1428475511, 1698753242, 2020578808, 1201443347, 1428764977, 1699097476, 2020988194, 1201686770, 1429054457, 1699441728, 2021397602, 1201930205, 1429343952, 1699785997, 
+2021807030, 1202173652, 1429633461, 1700130284, 2022216479, 1202417112, 1429922985, 1700474588, 2022625948, 1202660584, 1430212524, 1700818909, 2023035438, 1202904069, 1430502077, 1701163248, 
+2023444949, 1203147565, 1430791645, 1701507604, 2023854481, 1203391074, 1431081228, 1701851978, 2024264033, 1203634596, 1431370825, 1702196369, 2024673607, 1203878129, 1431660437, 1702540778, 
+2025083200, 1204121675, 1431950063, 1702885204, 2025492815, 1204365233, 1432239705, 1703229647, 2025902450, 1204608804, 1432529361, 1703574108, 2026312106, 1204852387, 1432819031, 1703918586, 
+2026721783, 1205095982, 1433108716, 1704263082, 2027131480, 1205339590, 1433398416, 1704607595, 2027541198, 1205583210, 1433688131, 1704952126, 2027950937, 1205826842, 1433977860, 1705296673, 
+2028360697, 1206070486, 1434267603, 1705641239, 2028770477, 1206314143, 1434557362, 1705985821, 2029180278, 1206557812, 1434847135, 1706330421, 2029590099, 1206801493, 1435136922, 1706675039, 
+2029999942, 1207045187, 1435426725, 1707019674, 2030409805, 1207288893, 1435716541, 1707364326, 2030819688, 1207532611, 1436006373, 1707708996, 2031229592, 1207776342, 1436296219, 1708053683, 
+2031639517, 1208020085, 1436586080, 1708398387, 2032049463, 1208263840, 1436875955, 1708743109, 2032459429, 1208507607, 1437165845, 1709087848, 2032869417, 1208751387, 1437455750, 1709432605, 
+2033279424, 1208995179, 1437745669, 1709777379, 2033689453, 1209238983, 1438035603, 1710122170, 2034099502, 1209482800, 1438325551, 1710466979, 2034509571, 1209726629, 1438615514, 1710811805, 
+2034919662, 1209970470, 1438905492, 1711156649, 2035329773, 1210214324, 1439195484, 1711501510, 2035739904, 1210458189, 1439485491, 1711846388, 2036150057, 1210702067, 1439775513, 1712191284, 
+2036560230, 1210945958, 1440065549, 1712536197, 2036970423, 1211189860, 1440355599, 1712881127, 2037380638, 1211433775, 1440645665, 1713226075, 2037790873, 1211677702, 1440935745, 1713571040, 
+2038201128, 1211921642, 1441225839, 1713916022, 2038611405, 1212165593, 1441515948, 1714261022, 2039021701, 1212409557, 1441806072, 1714606039, 2039432019, 1212653534, 1442096210, 1714951074, 
+2039842357, 1212897522, 1442386363, 1715296126, 2040252716, 1213141523, 1442676531, 1715641195, 2040663095, 1213385536, 1442966713, 1715986282, 2041073495, 1213629562, 1443256910, 1716331386, 
+2041483916, 1213873599, 1443547121, 1716676507, 2041894358, 1214117649, 1443837347, 1717021646, 2042304819, 1214361711, 1444127587, 1717366802, 2042715302, 1214605786, 1444417842, 1717711975, 
+2043125805, 1214849872, 1444708112, 1718057166, 2043536329, 1215093971, 1444998396, 1718402374, 2043946874, 1215338082, 1445288695, 1718747599, 2044357439, 1215582206, 1445579008, 1719092842, 
+2044768024, 1215826342, 1445869336, 1719438102, 2045178631, 1216070489, 1446159678, 1719783379, 2045589258, 1216314650, 1446450036, 1720128674, 2045999905, 1216558822, 1446740407, 1720473986, 
+2046410573, 1216803007, 1447030793, 1720819315, 2046821262, 1217047204, 1447321194, 1721164662, 2047231971, 1217291413, 1447611609, 1721510026, 2047642701, 1217535635, 1447902039, 1721855407, 
+2048053452, 1217779868, 1448192484, 1722200806, 2048464223, 1218024114, 1448482943, 1722546222, 2048875014, 1218268372, 1448773417, 1722891655, 2049285827, 1218512643, 1449063905, 1723237106, 
+2049696660, 1218756926, 1449354407, 1723582573, 2050107513, 1219001221, 1449644925, 1723928059, 2050518387, 1219245528, 1449935457, 1724273561, 2050929282, 1219489847, 1450226003, 1724619081, 
+2051340197, 1219734179, 1450516564, 1724964618, 2051751133, 1219978523, 1450807139, 1725310173, 2052162089, 1220222879, 1451097729, 1725655744, 2052573066, 1220467247, 1451388334, 1726001333, 
+2052984064, 1220711628, 1451678953, 1726346940, 2053395082, 1220956021, 1451969587, 1726692563, 2053806121, 1221200426, 1452260235, 1727038204, 2054217180, 1221444843, 1452550898, 1727383863, 
+2054628260, 1221689273, 1452841575, 1727729538, 2055039360, 1221933714, 1453132267, 1728075231, 2055450481, 1222178168, 1453422973, 1728420941, 2055861622, 1222422634, 1453713694, 1728766669, 
+2056272784, 1222667113, 1454004430, 1729112413, 2056683967, 1222911603, 1454295180, 1729458175, 2057095170, 1223156106, 1454585944, 1729803954, 2057506394, 1223400621, 1454876723, 1730149751, 
+2057917638, 1223645149, 1455167517, 1730495565, 2058328903, 1223889688, 1455458325, 1730841396, 2058740188, 1224134240, 1455749148, 1731187244, 2059151494, 1224378804, 1456039985, 1731533110, 
+2059562821, 1224623380, 1456330837, 1731878993, 2059974168, 1224867968, 1456621703, 1732224893, 2060385535, 1225112569, 1456912584, 1732570810, 2060796923, 1225357182, 1457203479, 1732916745, 
+2061208332, 1225601807, 1457494389, 1733262697, 2061619761, 1225846444, 1457785313, 1733608666, 2062031210, 1226091093, 1458076252, 1733954653, 2062442681, 1226335755, 1458367205, 1734300657, 
+2062854171, 1226580429, 1458658173, 1734646678, 2063265682, 1226825115, 1458949155, 1734992716, 2063677214, 1227069813, 1459240152, 1735338772, 2064088766, 1227314523, 1459531164, 1735684844, 
+2064500339, 1227559246, 1459822190, 1736030934, 2064911932, 1227803981, 1460113230, 1736377042, 2065323546, 1228048728, 1460404285, 1736723166, 2065735180, 1228293487, 1460695354, 1737069308, 
+2066146835, 1228538259, 1460986438, 1737415467, 2066558510, 1228783042, 1461277536, 1737761643, 2066970206, 1229027838, 1461568649, 1738107837, 2067381923, 1229272646, 1461859777, 1738454048, 
+2067793659, 1229517466, 1462150919, 1738800276, 2068205417, 1229762298, 1462442075, 1739146521, 2068617194, 1230007143, 1462733246, 1739492783, 2069028993, 1230252000, 1463024431, 1739839063, 
+2069440811, 1230496869, 1463315631, 1740185360, 2069852651, 1230741750, 1463606845, 1740531674, 2070264510, 1230986643, 1463898074, 1740878005, 2070676391, 1231231548, 1464189318, 1741224354, 
+2071088291, 1231476466, 1464480575, 1741570720, 2071500213, 1231721396, 1464771848, 1741917103, 2071912154, 1231966338, 1465063134, 1742263503, 2072324116, 1232211292, 1465354436, 1742609921, 
+2072736099, 1232456258, 1465645751, 1742956355, 2073148102, 1232701237, 1465937081, 1743302807, 2073560126, 1232946227, 1466228426, 1743649277, 2073972170, 1233191230, 1466519785, 1743995763, 
+2074384234, 1233436245, 1466811159, 1744342266, 2074796319, 1233681273, 1467102547, 1744688787, 2075208425, 1233926312, 1467393949, 1745035325, 2075620551, 1234171363, 1467685366, 1745381880, 
+2076032697, 1234416427, 1467976798, 1745728453, 2076444864, 1234661503, 1468268244, 1746075042, 2076857051, 1234906591, 1468559704, 1746421649, 2077269259, 1235151691, 1468851179, 1746768273, 
+2077681487, 1235396803, 1469142669, 1747114914, 2078093736, 1235641928, 1469434172, 1747461573, 2078506005, 1235887065, 1469725691, 1747808248, 2078918294, 1236132213, 1470017223, 1748154941, 
+2079330604, 1236377374, 1470308770, 1748501651, 2079742934, 1236622547, 1470600332, 1748848378, 2080155285, 1236867733, 1470891908, 1749195123, 2080567657, 1237112930, 1471183499, 1749541884, 
+2080980048, 1237358140, 1471475104, 1749888663, 2081392460, 1237603361, 1471766723, 1750235459, 2081804893, 1237848595, 1472058357, 1750582272, 2082217346, 1238093841, 1472350005, 1750929102, 
+2082629819, 1238339100, 1472641668, 1751275949, 2083042313, 1238584370, 1472933345, 1751622814, 2083454827, 1238829652, 1473225037, 1751969696, 2083867362, 1239074947, 1473516743, 1752316595, 
+2084279917, 1239320254, 1473808463, 1752663511, 2084692493, 1239565572, 1474100198, 1753010444, 2085105089, 1239810903, 1474391948, 1753357394, 2085517705, 1240056247, 1474683711, 1753704362, 
+2085930342, 1240301602, 1474975490, 1754051347, 2086342999, 1240546969, 1475267282, 1754398349, 2086755676, 1240792349, 1475559089, 1754745368, 2087168374, 1241037740, 1475850911, 1755092404, 
+2087581093, 1241283144, 1476142747, 1755439457, 2087993831, 1241528560, 1476434597, 1755786528, 2088406591, 1241773988, 1476726462, 1756133616, 2088819370, 1242019429, 1477018341, 1756480721, 
+2089232170, 1242264881, 1477310235, 1756827843, 2089644991, 1242510345, 1477602143, 1757174982, 2090057831, 1242755822, 1477894066, 1757522138, 2090470692, 1243001311, 1478186002, 1757869311, 
+2090883574, 1243246811, 1478477954, 1758216502, 2091296476, 1243492324, 1478769919, 1758563710, 2091709398, 1243737849, 1479061900, 1758910935, 2092122341, 1243983387, 1479353894, 1759258177, 
+2092535304, 1244228936, 1479645903, 1759605436, 2092948287, 1244474497, 1479937927, 1759952712, 2093361291, 1244720071, 1480229964, 1760300005, 2093774315, 1244965656, 1480522016, 1760647316, 
+2094187360, 1245211254, 1480814083, 1760994644, 2094600424, 1245456864, 1481106164, 1761341988, 2095013510, 1245702486, 1481398259, 1761689350, 2095426615, 1245948120, 1481690369, 1762036729, 
+2095839741, 1246193766, 1481982493, 1762384125, 2096252888, 1246439424, 1482274632, 1762731539, 2096666054, 1246685095, 1482566785, 1763078969, 2097079241, 1246930777, 1482858952, 1763426417, 
+2097492449, 1247176472, 1483151134, 1763773881, 2097905677, 1247422179, 1483443330, 1764121363, 2098318925, 1247667897, 1483735541, 1764468862, 2098732193, 1247913628, 1484027766, 1764816378, 
+2099145482, 1248159371, 1484320005, 1765163911, 2099558791, 1248405126, 1484612259, 1765511461, 2099972121, 1248650894, 1484904527, 1765859028, 2100385470, 1248896673, 1485196809, 1766206613, 
+2100798841, 1249142464, 1485489106, 1766554214, 2101212231, 1249388268, 1485781417, 1766901833, 2101625642, 1249634083, 1486073743, 1767249468, 2102039073, 1249879911, 1486366083, 1767597121, 
+2102452525, 1250125751, 1486658437, 1767944791, 2102865996, 1250371602, 1486950806, 1768292478, 2103279489, 1250617466, 1487243189, 1768640182, 2103693001, 1250863342, 1487535587, 1768987903, 
+2104106534, 1251109230, 1487827998, 1769335642, 2104520087, 1251355131, 1488120425, 1769683397, 2104933660, 1251601043, 1488412865, 1770031169, 2105347254, 1251846967, 1488705320, 1770378959, 
+2105760868, 1252092903, 1488997789, 1770726765, 2106174502, 1252338852, 1489290273, 1771074589, 2106588157, 1252584812, 1489582771, 1771422430, 2107001832, 1252830785, 1489875283, 1771770288, 
+2107415527, 1253076770, 1490167810, 1772118162, 2107829243, 1253322767, 1490460351, 1772466054, 2108242979, 1253568775, 1490752907, 1772813963, 2108656735, 1253814796, 1491045477, 1773161890, 
+2109070512, 1254060829, 1491338061, 1773509833, 2109484308, 1254306874, 1491630659, 1773857793, 2109898125, 1254552931, 1491923272, 1774205770, 2110311963, 1254799001, 1492215899, 1774553765, 
+2110725821, 1255045082, 1492508541, 1774901776, 2111139698, 1255291175, 1492801197, 1775249805, 2111553597, 1255537280, 1493093867, 1775597850, 2111967515, 1255783398, 1493386552, 1775945913, 
+2112381454, 1256029527, 1493679251, 1776293992, 2112795413, 1256275669, 1493971964, 1776642089, 2113209392, 1256521823, 1494264691, 1776990203, 2113623392, 1256767988, 1494557433, 1777338334, 
+2114037412, 1257014166, 1494850190, 1777686481, 2114451452, 1257260356, 1495142960, 1778034646, 2114865513, 1257506557, 1495435745, 1778382828, 2115279593, 1257752771, 1495728545, 1778731027, 
+2115693694, 1257998997, 1496021358, 1779079243, 2116107816, 1258245235, 1496314186, 1779427476, 2116521957, 1258491485, 1496607028, 1779775727, 2116936119, 1258737747, 1496899885, 1780123994, 
+2117350301, 1258984021, 1497192756, 1780472278, 2117764503, 1259230308, 1497485641, 1780820579, 2118178726, 1259476606, 1497778541, 1781168897, 2118592969, 1259722916, 1498071455, 1781517233, 
+2119007232, 1259969238, 1498364383, 1781865585, 2119421515, 1260215573, 1498657325, 1782213954, 2119835818, 1260461919, 1498950282, 1782562341, 2120250142, 1260708277, 1499243253, 1782910744, 
+2120664486, 1260954648, 1499536239, 1783259164, 2121078850, 1261201030, 1499829239, 1783607602, 2121493235, 1261447425, 1500122253, 1783956056, 2121907640, 1261693831, 1500415281, 1784304528, 
+2122322065, 1261940250, 1500708324, 1784653016, 2122736510, 1262186680, 1501001381, 1785001522, 2123150975, 1262433123, 1501294452, 1785350044, 2123565461, 1262679578, 1501587538, 1785698584, 
+2123979967, 1262926044, 1501880638, 1786047140, 2124394493, 1263172523, 1502173752, 1786395714, 2124809039, 1263419014, 1502466880, 1786744304, 2125223606, 1263665516, 1502760023, 1787092912, 
+2125638193, 1263912031, 1503053180, 1787441536, 2126052800, 1264158558, 1503346352, 1787790178, 2126467427, 1264405097, 1503639537, 1788138836, 2126882074, 1264651648, 1503932737, 1788487512, 
+2127296742, 1264898211, 1504225952, 1788836204, 2127711430, 1265144785, 1504519180, 1789184914, 2128126138, 1265391372, 1504812423, 1789533640, 2128540866, 1265637971, 1505105680, 1789882384, 
+2128955614, 1265884582, 1505398952, 1790231144, 2129370383, 1266131205, 1505692237, 1790579922, 2129785172, 1266377840, 1505985537, 1790928716, 2130199981, 1266624487, 1506278852, 1791277528, 
+2130614810, 1266871146, 1506572180, 1791626356, 2131029660, 1267117817, 1506865523, 1791975202, 2131444529, 1267364500, 1507158880, 1792324064, 2131859419, 1267611195, 1507452252, 1792672943, 
+2132274329, 1267857902, 1507745637, 1793021840, 2132689259, 1268104621, 1508039037, 1793370753, 2133104210, 1268351351, 1508332452, 1793719683, 2133519180, 1268598094, 1508625880, 1794068630, 
+2133934171, 1268844849, 1508919323, 1794417595, 2134349182, 1269091616, 1509212780, 1794766576, 2134764213, 1269338395, 1509506251, 1795115574, 2135179264, 1269585186, 1509799737, 1795464589, 
+2135594335, 1269831989, 1510093236, 1795813621, 2136009427, 1270078804, 1510386751, 1796162670, 2136424539, 1270325631, 1510680279, 1796511736, 2136839671, 1270572470, 1510973821, 1796860819, 
+2137254823, 1270819321, 1511267378, 1797209919, 2137669995, 1271066184, 1511560949, 1797559036, 2138085187, 1271313059, 1511854535, 1797908170, 2138500400, 1271559946, 1512148134, 1798257320, 
+2138915633, 1271806844, 1512441748, 1798606488, 2139330886, 1272053755, 1512735376, 1798955673, 2139746159, 1272300678, 1513029019, 1799304874, 2140161452, 1272547613, 1513322675, 1799654093, 
+2140576765, 1272794560, 1513616346, 1800003328, 2140992099, 1273041518, 1513910031, 1800352581, 2141407452, 1273288489, 1514203731, 1800701850, 2141822826, 1273535472, 1514497444, 1801051136, 
+2142238220, 1273782467, 1514791172, 1801400440, 2142653634, 1274029473, 1515084914, 1801749760, 2143069068, 1274276492, 1515378671, 1802099097, 2143484522, 1274523522, 1515672441, 1802448451, 
+2143899997, 1274770565, 1515966226, 1802797822, 2144315491, 1275017620, 1516260025, 1803147210, 2144731006, 1275264686, 1516553838, 1803496615, 2145146541, 1275511765, 1516847666, 1803846036, 
+2145562096, 1275758855, 1517141507, 1804195475, 2145977671, 1276005957, 1517435363, 1804544931, 2146393266, 1276253072, 1517729233, 1804894403, 2146808881, 1276500198, 1518023118, 1805243892, 
+2147224517, 1276747336, 1518317016, 1805593399, 1073820086, 1276994487, 1518610929, 1805942922, 1074027924, 1277241649, 1518904856, 1806292462, 1074235772, 1277488823, 1519198798, 1806642019, 
+1074443630, 1277736009, 1519492753, 1806991593, 1074651498, 1277983207, 1519786723, 1807341184, 1074859376, 1278230417, 1520080707, 1807690792, 1075067264, 1278477639, 1520374705, 1808040417, 
+1075275162, 1278724873, 1520668717, 1808390058, 1075483070, 1278972119, 1520962744, 1808739717, 1075690988, 1279219377, 1521256785, 1809089392, 1075898917, 1279466647, 1521550840, 1809439084, 
+1076106855, 1279713928, 1521844909, 1809788794, 1076314803, 1279961222, 1522138992, 1810138520, 1076522762, 1280208528, 1522433090, 1810488263, 1076730730, 1280455845, 1522727202, 1810838023, 
+1076938709, 1280703175, 1523021328, 1811187799, 1077146697, 1280950516, 1523315468, 1811537593, 1077354696, 1281197870, 1523609622, 1811887404, 1077562705, 1281445235, 1523903791, 1812237231, 
+1077770723, 1281692612, 1524197974, 1812587075, 1077978752, 1281940002, 1524492171, 1812936936, 1078186791, 1282187403, 1524786382, 1813286814, 1078394839, 1282434816, 1525080608, 1813636709, 
+1078602898, 1282682241, 1525374847, 1813986621, 1078810967, 1282929678, 1525669101, 1814336550, 1079019046, 1283177127, 1525963369, 1814686496, 1079227135, 1283424588, 1526257651, 1815036458, 
+1079435234, 1283672060, 1526551947, 1815386437, 1079643343, 1283919545, 1526846258, 1815736433, 1079851462, 1284167042, 1527140583, 1816086447, 1080059591, 1284414550, 1527434922, 1816436476, 
+1080267730, 1284662071, 1527729275, 1816786523, 1080475879, 1284909603, 1528023642, 1817136587, 1080684038, 1285157147, 1528318023, 1817486667, 1080892207, 1285404703, 1528612419, 1817836765, 
+1081100386, 1285652272, 1528906829, 1818186879, 1081308576, 1285899852, 1529201253, 1818537010, 1081516775, 1286147444, 1529495691, 1818887158, 1081724984, 1286395047, 1529790143, 1819237323, 
+1081933203, 1286642663, 1530084610, 1819587504, 1082141432, 1286890291, 1530379090, 1819937703, 1082349672, 1287137931, 1530673585, 1820287918, 1082557921, 1287385582, 1530968094, 1820638150, 
+1082766180, 1287633246, 1531262617, 1820988399, 1082974450, 1287880921, 1531557154, 1821338665, 1083182729, 1288128608, 1531851706, 1821688948, 1083391018, 1288376307, 1532146272, 1822039247, 
+1083599318, 1288624018, 1532440851, 1822389564, 1083807627, 1288871741, 1532735445, 1822739897, 1084015947, 1289119476, 1533030053, 1823090247, 1084224276, 1289367223, 1533324676, 1823440614, 
+1084432615, 1289614982, 1533619312, 1823790998, 1084640965, 1289862752, 1533913963, 1824141398, 1084849324, 1290110535, 1534208627, 1824491815, 1085057694, 1290358329, 1534503306, 1824842250, 
+1085266073, 1290606136, 1534797999, 1825192701, 1085474462, 1290853954, 1535092706, 1825543169, 1085682862, 1291101784, 1535387428, 1825893653, 1085891271, 1291349626, 1535682163, 1826244155, 
+1086099691, 1291597480, 1535976913, 1826594673, 1086308120, 1291845345, 1536271676, 1826945208, 1086516560, 1292093223, 1536566454, 1827295760, 1086725009, 1292341113, 1536861246, 1827646329, 
+1086933468, 1292589014, 1537156052, 1827996914, 1087141938, 1292836927, 1537450873, 1828347517, 1087350417, 1293084853, 1537745707, 1828698136, 1087558907, 1293332790, 1538040556, 1829048772, 
+1087767406, 1293580739, 1538335418, 1829399425, 1087975915, 1293828699, 1538630295, 1829750094, 1088184435, 1294076672, 1538925186, 1830100781, 1088392964, 1294324657, 1539220091, 1830451484, 
+1088601503, 1294572653, 1539515010, 1830802204, 1088810053, 1294820662, 1539809944, 1831152941, 1089018612, 1295068682, 1540104891, 1831503694, 1089227181, 1295316714, 1540399852, 1831854465, 
+1089435761, 1295564758, 1540694828, 1832205252, 1089644350, 1295812814, 1540989818, 1832556056, 1089852949, 1296060882, 1541284822, 1832906876, 1090061559, 1296308961, 1541579840, 1833257714, 
+1090270178, 1296557053, 1541874872, 1833608568, 1090478807, 1296805156, 1542169918, 1833959439, 1090687446, 1297053271, 1542464979, 1834310327, 1090896095, 1297301398, 1542760053, 1834661232, 
+1091104754, 1297549537, 1543055142, 1835012153, 1091313424, 1297797688, 1543350244, 1835363092, 1091522103, 1298045851, 1543645361, 1835714047, 1091730792, 1298294025, 1543940492, 1836065018, 
+1091939491, 1298542212, 1544235637, 1836416007, 1092148200, 1298790410, 1544530796, 1836767012, 1092356919, 1299038620, 1544825970, 1837118034, 1092565648, 1299286842, 1545121157, 1837469073, 
+1092774387, 1299535076, 1545416358, 1837820129, 1092983136, 1299783321, 1545711574, 1838171201, 1093191894, 1300031579, 1546006803, 1838522291, 1093400663, 1300279848, 1546302047, 1838873396, 
+1093609442, 1300528130, 1546597305, 1839224519, 1093818231, 1300776423, 1546892577, 1839575659, 1094027030, 1301024728, 1547187863, 1839926815, 1094235838, 1301273044, 1547483163, 1840277988, 
+1094444657, 1301521373, 1547778477, 1840629177, 1094653486, 1301769713, 1548073805, 1840980384, 1094862324, 1302018066, 1548369148, 1841331607, 1095071173, 1302266430, 1548664504, 1841682847, 
+1095280031, 1302514806, 1548959875, 1842034104, 1095488900, 1302763194, 1549255259, 1842385377, 1095697778, 1303011593, 1549550658, 1842736667, 1095906666, 1303260005, 1549846071, 1843087974, 
+1096115565, 1303508428, 1550141497, 1843439298, 1096324473, 1303756864, 1550436938, 1843790638, 1096533391, 1304005311, 1550732393, 1844141996, 1096742319, 1304253769, 1551027862, 1844493370, 
+1096951257, 1304502240, 1551323346, 1844844760, 1097160206, 1304750723, 1551618843, 1845196168, 1097369164, 1304999217, 1551914354, 1845547592, 1097578132, 1305247723, 1552209879, 1845899032, 
+1097787109, 1305496241, 1552505419, 1846250490, 1097996097, 1305744771, 1552800972, 1846601964, 1098205095, 1305993313, 1553096540, 1846953455, 1098414103, 1306241866, 1553392121, 1847304963, 
+1098623121, 1306490432, 1553687717, 1847656488, 1098832148, 1306739009, 1553983327, 1848008029, 1099041186, 1306987598, 1554278950, 1848359587, 1099250233, 1307236199, 1554574588, 1848711161, 
+1099459291, 1307484811, 1554870240, 1849062753, 1099668358, 1307733436, 1555165906, 1849414361, 1099877435, 1307982072, 1555461586, 1849765985, 1100086523, 1308230720, 1555757280, 1850117627, 
+1100295620, 1308479380, 1556052988, 1850469285, 1100504727, 1308728051, 1556348710, 1850820960, 1100713844, 1308976735, 1556644447, 1851172651, 1100922971, 1309225430, 1556940197, 1851524360, 
+1101132108, 1309474137, 1557235961, 1851876085, 1101341255, 1309722856, 1557531740, 1852227826, 1101550412, 1309971587, 1557827532, 1852579585, 1101759578, 1310220330, 1558123338, 1852931360, 
+1101968755, 1310469084, 1558419159, 1853283152, 1102177942, 1310717850, 1558714993, 1853634960, 1102387138, 1310966628, 1559010842, 1853986785, 1102596345, 1311215418, 1559306704, 1854338627, 
+1102805561, 1311464220, 1559602581, 1854690486, 1103014787, 1311713033, 1559898472, 1855042361, 1103224023, 1311961858, 1560194376, 1855394253, 1103433270, 1312210695, 1560490295, 1855746162, 
+1103642526, 1312459544, 1560786228, 1856098087, 1103851792, 1312708404, 1561082174, 1856450029, 1104061067, 1312957277, 1561378135, 1856801988, 1104270353, 1313206161, 1561674110, 1857153963, 
+1104479649, 1313455057, 1561970099, 1857505955, 1104688955, 1313703965, 1562266102, 1857857964, 1104898270, 1313952884, 1562562119, 1858209989, 1105107596, 1314201816, 1562858150, 1858562031, 
+1105316931, 1314450759, 1563154194, 1858914090, 1105526276, 1314699714, 1563450253, 1859266165, 1105735631, 1314948680, 1563746326, 1859618257, 1105944997, 1315197659, 1564042413, 1859970366, 
+1106154372, 1315446649, 1564338514, 1860322492, 1106363756, 1315695651, 1564634629, 1860674634, 1106573151, 1315944665, 1564930758, 1861026792, 1106782556, 1316193690, 1565226901, 1861378968, 
+1106991971, 1316442728, 1565523058, 1861731160, 1107201395, 1316691777, 1565819229, 1862083368, 1107410830, 1316940838, 1566115414, 1862435594, 1107620274, 1317189911, 1566411614, 1862787836, 
+1107829728, 1317438995, 1566707827, 1863140094, 1108039192, 1317688091, 1567004054, 1863492370, 1108248667, 1317937199, 1567300295, 1863844662, 1108458150, 1318186319, 1567596550, 1864196970, 
+1108667644, 1318435451, 1567892819, 1864549296, 1108877148, 1318684594, 1568189102, 1864901638, 1109086662, 1318933749, 1568485399, 1865253996, 1109296185, 1319182916, 1568781710, 1865606371, 
+1109505719, 1319432095, 1569078035, 1865958763, 1109715262, 1319681285, 1569374374, 1866311172, 1109924815, 1319930487, 1569670727, 1866663597, 1110134378, 1320179701, 1569967094, 1867016038, 
+1110343951, 1320428927, 1570263475, 1867368497, 1110553534, 1320678164, 1570559870, 1867720972, 1110763127, 1320927414, 1570856279, 1868073463, 1110972730, 1321176675, 1571152702, 1868425972, 
+1111182342, 1321425947, 1571449139, 1868778497, 1111391965, 1321675232, 1571745590, 1869131038, 1111601597, 1321924528, 1572042054, 1869483596, 1111811239, 1322173836, 1572338533, 1869836171, 
+1112020891, 1322423156, 1572635026, 1870188762, 1112230553, 1322672487, 1572931533, 1870541370, 1112440225, 1322921831, 1573228054, 1870893995, 1112649907, 1323171186, 1573524588, 1871246636, 
+1112859598, 1323420552, 1573821137, 1871599294, 1113069300, 1323669931, 1574117700, 1871951968, 1113279011, 1323919321, 1574414276, 1872304660, 1113488733, 1324168723, 1574710867, 1872657367, 
+1113698464, 1324418137, 1575007472, 1873010092, 1113908205, 1324667562, 1575304090, 1873362832, 1114117956, 1324917000, 1575600723, 1873715590, 1114327716, 1325166449, 1575897369, 1874068364, 
+1114537487, 1325415909, 1576194030, 1874421155, 1114747267, 1325665382, 1576490704, 1874773962, 1114957058, 1325914866, 1576787392, 1875126786, 1115166858, 1326164362, 1577084095, 1875479626, 
+1115376668, 1326413870, 1577380811, 1875832484, 1115586488, 1326663389, 1577677541, 1876185357, 1115796318, 1326912920, 1577974285, 1876538248, 1116006157, 1327162463, 1578271044, 1876891154, 
+1116216007, 1327412017, 1578567816, 1877244078, 1116425866, 1327661584, 1578864602, 1877597018, 1116635736, 1327911162, 1579161402, 1877949975, 1116845615, 1328160752, 1579458216, 1878302948, 
+1117055504, 1328410353, 1579755044, 1878655938, 1117265403, 1328659966, 1580051885, 1879008944, 1117475311, 1328909591, 1580348741, 1879361967, 1117685230, 1329159228, 1580645611, 1879715007, 
+1117895158, 1329408876, 1580942494, 1880068063, 1118105097, 1329658536, 1581239392, 1880421135, 1118315045, 1329908208, 1581536304, 1880774225, 1118525003, 1330157892, 1581833229, 1881127331, 
+1118734971, 1330407587, 1582130168, 1881480453, 1118944948, 1330657294, 1582427122, 1881833592, 1119154936, 1330907013, 1582724089, 1882186748, 1119364933, 1331156743, 1583021070, 1882539920, 
+1119574941, 1331406485, 1583318065, 1882893108, 1119784958, 1331656239, 1583615074, 1883246314, 1119994985, 1331906005, 1583912097, 1883599536, 1120205022, 1332155782, 1584209134, 1883952774, 
+1120415068, 1332405571, 1584506185, 1884306029, 1120625125, 1332655372, 1584803250, 1884659300, 1120835191, 1332905184, 1585100328, 1885012588, 1121045267, 1333155008, 1585397421, 1885365893, 
+1121255353, 1333404844, 1585694527, 1885719214, 1121465449, 1333654691, 1585991648, 1886072552, 1121675555, 1333904550, 1586288782, 1886425906, 1121885670, 1334154421, 1586585930, 1886779277, 
+1122095796, 1334404304, 1586883093, 1887132664, 1122305931, 1334654198, 1587180269, 1887486068, 1122516076, 1334904104, 1587477459, 1887839489, 1122726231, 1335154022, 1587774663, 1888192926, 
+1122936396, 1335403951, 1588071880, 1888546379, 1123146570, 1335653892, 1588369112, 1888899849, 1123356755, 1335903845, 1588666358, 1889253336, 1123566949, 1336153810, 1588963617, 1889606839, 
+1123777153, 1336403786, 1589260891, 1889960359, 1123987367, 1336653774, 1589558178, 1890313895, 1124197590, 1336903773, 1589855479, 1890667448, 1124407824, 1337153784, 1590152794, 1891021017, 
+1124618067, 1337403807, 1590450123, 1891374603, 1124828321, 1337653842, 1590747466, 1891728205, 1125038584, 1337903888, 1591044823, 1892081824, 1125248856, 1338153946, 1591342194, 1892435459, 
+1125459139, 1338404016, 1591639578, 1892789111, 1125669432, 1338654097, 1591936977, 1893142780, 1125879734, 1338904190, 1592234389, 1893496464, 1126090046, 1339154295, 1592531816, 1893850166, 
+1126300368, 1339404411, 1592829256, 1894203884, 1126510700, 1339654539, 1593126710, 1894557618, 1126721041, 1339904679, 1593424178, 1894911369, 1126931393, 1340154830, 1593721659, 1895265137, 
+1127141754, 1340404993, 1594019155, 1895618921, 1127352125, 1340655168, 1594316665, 1895972721, 1127562506, 1340905355, 1594614188, 1896326538, 1127772897, 1341155553, 1594911726, 1896680372, 
+1127983297, 1341405762, 1595209277, 1897034222, 1128193707, 1341655984, 1595506842, 1897388088, 1128404127, 1341906217, 1595804421, 1897741971, 1128614557, 1342156462, 1596102014, 1898095871, 
+1128824997, 1342406718, 1596399620, 1898449787, 1129035447, 1342656986, 1596697241, 1898803720, 1129245906, 1342907266, 1596994875, 1899157669, 1129456375, 1343157557, 1597292524, 1899511634, 
+1129666854, 1343407860, 1597590186, 1899865616, 1129877343, 1343658175, 1597887862, 1900219614, 1130087841, 1343908502, 1598185552, 1900573629, 1130298350, 1344158840, 1598483256, 1900927661, 
+1130508868, 1344409189, 1598780973, 1901281709, 1130719396, 1344659551, 1599078705, 1901635773, 1130929934, 1344909924, 1599376450, 1901989854, 1131140481, 1345160308, 1599674209, 1902343952, 
+1131351039, 1345410705, 1599971983, 1902698065, 1131561606, 1345661113, 1600269769, 1903052196, 1131772183, 1345911532, 1600567570, 1903406343, 1131982769, 1346161963, 1600865385, 1903760506, 
+1132193366, 1346412406, 1601163213, 1904114686, 1132403972, 1346662861, 1601461056, 1904468882, 1132614588, 1346913327, 1601758912, 1904823095, 1132825214, 1347163805, 1602056782, 1905177324, 
+1133035850, 1347414295, 1602354666, 1905531569, 1133246496, 1347664796, 1602652564, 1905885832, 1133457151, 1347915308, 1602950475, 1906240110, 1133667816, 1348165833, 1603248401, 1906594405, 
+1133878491, 1348416369, 1603546340, 1906948717, 1134089176, 1348666917, 1603844293, 1907303045, 1134299870, 1348917476, 1604142260, 1907657389, 1134510574, 1349168047, 1604440241, 1908011750, 
+1134721288, 1349418629, 1604738235, 1908366127, 1134932012, 1349669224, 1605036244, 1908720521, 1135142746, 1349919830, 1605334266, 1909074931, 1135353489, 1350170447, 1605632302, 1909429358, 
+1135564242, 1350421076, 1605930352, 1909783801, 1135775005, 1350671717, 1606228416, 1910138260, 1135985778, 1350922369, 1606526493, 1910492736, 1136196560, 1351173033, 1606824585, 1910847229, 
+1136407352, 1351423709, 1607122690, 1911201738, 1136618154, 1351674396, 1607420809, 1911556263, 1136828966, 1351925095, 1607718942, 1911910805, 1137039788, 1352175806, 1608017089, 1912265363, 
+1137250619, 1352426528, 1608315249, 1912619938, 1137461460, 1352677262, 1608613424, 1912974529, 1137672311, 1352928007, 1608911612, 1913329136, 1137883172, 1353178764, 1609209814, 1913683760, 
+1138094042, 1353429533, 1609508030, 1914038401, 1138304922, 1353680313, 1609806259, 1914393057, 1138515812, 1353931105, 1610104503, 1914747731, 1138726712, 1354181908, 1610402760, 1915102420, 
+1138937622, 1354432723, 1610701031, 1915457126, 1139148541, 1354683550, 1610999316, 1915811849, 1139359470, 1354934388, 1611297615, 1916166588, 1139570409, 1355185238, 1611595927, 1916521343, 
+1139781357, 1355436100, 1611894253, 1916876115, 1139992315, 1355686973, 1612192594, 1917230903, 1140203284, 1355937857, 1612490947, 1917585708, 1140414261, 1356188754, 1612789315, 1917940529, 
+1140625249, 1356439662, 1613087697, 1918295366, 1140836246, 1356690581, 1613386092, 1918650220, 1141047253, 1356941512, 1613684501, 1919005090, 1141258270, 1357192455, 1613982924, 1919359977, 
+1141469297, 1357443409, 1614281361, 1919714880, 1141680333, 1357694375, 1614579811, 1920069799, 1141891379, 1357945353, 1614878275, 1920424735, 1142102435, 1358196342, 1615176753, 1920779687, 
+1142313501, 1358447343, 1615475245, 1921134656, 1142524576, 1358698355, 1615773751, 1921489641, 1142735661, 1358949379, 1616072270, 1921844642, 1142946756, 1359200414, 1616370804, 1922199660, 
+1143157861, 1359451462, 1616669351, 1922554694, 1143368975, 1359702520, 1616967911, 1922909745, 1143580099, 1359953591, 1617266486, 1923264812, 1143791233, 1360204672, 1617565074, 1923619895, 
+1144002377, 1360455766, 1617863676, 1923974995, 1144213530, 1360706871, 1618162292, 1924330111, 1144424693, 1360957988, 1618460922, 1924685244, 1144635866, 1361209116, 1618759566, 1925040393, 
+1144847048, 1361460256, 1619058223, 1925395558, 1145058241, 1361711407, 1619356894, 1925750740, 1145269443, 1361962570, 1619655579, 1926105938, 1145480655, 1362213745, 1619954277, 1926461152, 
+1145691876, 1362464931, 1620252989, 1926816383, 1145903107, 1362716128, 1620551716, 1927171630, 1146114348, 1362967338, 1620850455, 1927526894, 1146325599, 1363218558, 1621149209, 1927882174, 
+1146536859, 1363469791, 1621447976, 1928237470, 1146748130, 1363721035, 1621746758, 1928592783, 1146959410, 1363972290, 1622045552, 1928948112, 1147170699, 1364223558, 1622344361, 1929303457, 
+1147381999, 1364474836, 1622643184, 1929658819, 1147593308, 1364726127, 1622942020, 1930014197, 1147804626, 1364977428, 1623240870, 1930369592, 1148015955, 1365228742, 1623539733, 1930725003, 
+1148227293, 1365480067, 1623838611, 1931080430, 1148438641, 1365731403, 1624137502, 1931435873, 1148649999, 1365982752, 1624436407, 1931791333, 1148861367, 1366234111, 1624735326, 1932146809, 
+1149072744, 1366485482, 1625034258, 1932502302, 1149284131, 1366736865, 1625333204, 1932857811, 1149495527, 1366988260, 1625632164, 1933213336, 1149706934, 1367239666, 1625931138, 1933568878, 
+1149918350, 1367491083, 1626230126, 1933924436, 1150129775, 1367742512, 1626529127, 1934280010, 1150341211, 1367993953, 1626828142, 1934635601, 1150552656, 1368245405, 1627127170, 1934991208, 
+1150764111, 1368496868, 1627426213, 1935346831, 1150975576, 1368748344, 1627725269, 1935702471, 1151187050, 1368999831, 1628024339, 1936058127, 1151398534, 1369251329, 1628323423, 1936413800, 
+1151610028, 1369502839, 1628622520, 1936769488, 1151821531, 1369754360, 1628921631, 1937125193, 1152033044, 1370005893, 1629220756, 1937480915, 1152244567, 1370257438, 1629519894, 1937836652, 
+1152456100, 1370508994, 1629819047, 1938192406, 1152667642, 1370760561, 1630118213, 1938548177, 1152879194, 1371012141, 1630417392, 1938903963, 1153090756, 1371263731, 1630716586, 1939259766, 
+1153302327, 1371515334, 1631015793, 1939615586, 1153513909, 1371766947, 1631315014, 1939971421, 1153725499, 1372018573, 1631614249, 1940327273, 1153937100, 1372270210, 1631913497, 1940683142, 
+1154148710, 1372521858, 1632212759, 1941039026, 1154360330, 1372773518, 1632512035, 1941394927, 1154571960, 1373025189, 1632811324, 1941750844, 1154783599, 1373276872, 1633110628, 1942106778, 
+1154995248, 1373528567, 1633409944, 1942462728, 1155206907, 1373780273, 1633709275, 1942818694, 1155418575, 1374031991, 1634008619, 1943174676, 1155630253, 1374283720, 1634307978, 1943530675, 
+1155841941, 1374535460, 1634607349, 1943886690, 1156053639, 1374787213, 1634906735, 1944242721, 1156265346, 1375038976, 1635206134, 1944598769, 1156477063, 1375290752, 1635505547, 1944954833, 
+1156688789, 1375542538, 1635804974, 1945310913, 1156900526, 1375794337, 1636104414, 1945667010, 1157112272, 1376046146, 1636403868, 1946023123, 1157324027, 1376297968, 1636703336, 1946379252, 
+1157535793, 1376549801, 1637002817, 1946735397, 1157747568, 1376801645, 1637302312, 1947091559, 1157959352, 1377053501, 1637601821, 1947447737, 1158171147, 1377305368, 1637901343, 1947803931, 
+1158382951, 1377557247, 1638200880, 1948160142, 1158594765, 1377809138, 1638500429, 1948516369, 1158806588, 1378061039, 1638799993, 1948872612, 1159018421, 1378312953, 1639099570, 1949228871, 
+1159230264, 1378564878, 1639399161, 1949585147, 1159442116, 1378816814, 1639698766, 1949941439, 1159653979, 1379068762, 1639998384, 1950297747, 1159865850, 1379320722, 1640298016, 1950654072, 
+1160077732, 1379572693, 1640597662, 1951010412, 1160289623, 1379824675, 1640897321, 1951366770, 1160501524, 1380076669, 1641196994, 1951723143, 1160713435, 1380328675, 1641496681, 1952079532, 
+1160925355, 1380580692, 1641796382, 1952435938, 1161137285, 1380832720, 1642096096, 1952792360, 1161349224, 1381084760, 1642395823, 1953148799, 1161561173, 1381336812, 1642695565, 1953505254, 
+1161773132, 1381588875, 1642995320, 1953861724, 1161985101, 1381840949, 1643295089, 1954218212, 1162197079, 1382093035, 1643594871, 1954574715, 1162409067, 1382345133, 1643894667, 1954931235, 
+1162621064, 1382597242, 1644194477, 1955287771, 1162833072, 1382849362, 1644494301, 1955644323, 1163045089, 1383101494, 1644794138, 1956000891, 1163257115, 1383353638, 1645093989, 1956357476, 
+1163469151, 1383605793, 1645393853, 1956714077, 1163681197, 1383857959, 1645693731, 1957070694, 1163893253, 1384110137, 1645993623, 1957427328, 1164105318, 1384362327, 1646293529, 1957783978, 
+1164317393, 1384614528, 1646593448, 1958140643, 1164529477, 1384866740, 1646893380, 1958497326, 1164741571, 1385118964, 1647193327, 1958854024, 1164953675, 1385371199, 1647493287, 1959210739, 
+1165165789, 1385623446, 1647793261, 1959567470, 1165377912, 1385875704, 1648093248, 1959924217, 1165590045, 1386127974, 1648393249, 1960280980, 1165802187, 1386380255, 1648693264, 1960637760, 
+1166014339, 1386632548, 1648993292, 1960994556, 1166226501, 1386884852, 1649293334, 1961351368, 1166438672, 1387137168, 1649593390, 1961708196, 1166650853, 1387389495, 1649893459, 1962065041, 
+1166863044, 1387641834, 1650193542, 1962421901, 1167075244, 1387894184, 1650493639, 1962778778, 1167287454, 1388146546, 1650793749, 1963135671, 1167499674, 1388398919, 1651093873, 1963492581, 
+1167711903, 1388651303, 1651394010, 1963849507, 1167924142, 1388903699, 1651694161, 1964206448, 1168136390, 1389156107, 1651994326, 1964563406, 1168348649, 1389408526, 1652294504, 1964920381, 
+1168560916, 1389660956, 1652594696, 1965277371, 1168773194, 1389913398, 1652894902, 1965634378, 1168985481, 1390165851, 1653195121, 1965991401, 1169197778, 1390418316, 1653495354, 1966348440, 
+1169410084, 1390670792, 1653795601, 1966705495, 1169622400, 1390923280, 1654095861, 1967062567, 1169834726, 1391175779, 1654396135, 1967419655, 1170047061, 1391428290, 1654696422, 1967776759, 
+1170259406, 1391680812, 1654996723, 1968133879, 1170471761, 1391933346, 1655297038, 1968491015, 1170684125, 1392185891, 1655597366, 1968848168, 1170896499, 1392438447, 1655897708, 1969205337, 
+1171108882, 1392691015, 1656198064, 1969562522, 1171321275, 1392943594, 1656498433, 1969919723, 1171533678, 1393196185, 1656798816, 1970276940, 1171746090, 1393448787, 1657099212, 1970634174, 
+1171958512, 1393701401, 1657399622, 1970991423, 1172170944, 1393954026, 1657700046, 1971348689, 1172383385, 1394206663, 1658000483, 1971705971, 1172595836, 1394459311, 1658300934, 1972063270, 
+1172808296, 1394711970, 1658601399, 1972420584, 1173020766, 1394964641, 1658901877, 1972777915, 1173233246, 1395217324, 1659202368, 1973135262, 1173445735, 1395470017, 1659502874, 1973492625, 
+1173658234, 1395722723, 1659803392, 1973850004, 1173870743, 1395975439, 1660103925, 1974207399, 1174083261, 1396228168, 1660404471, 1974564811, 1174295789, 1396480907, 1660705031, 1974922238, 
+1174508326, 1396733658, 1661005604, 1975279682, 1174720873, 1396986421, 1661306191, 1975637142, 1174933430, 1397239194, 1661606791, 1975994619, 1175145996, 1397491980, 1661907406, 1976352111, 
+1175358572, 1397744777, 1662208033, 1976709620, 1175571158, 1397997585, 1662508674, 1977067144, 1175783753, 1398250404, 1662809329, 1977424685, 1175996357, 1398503235, 1663109998, 1977782242, 
+1176208972, 1398756078, 1663410680, 1978139816, 1176421596, 1399008932, 1663711375, 1978497405, 1176634229, 1399261797, 1664012085, 1978855011, 1176846872, 1399514674, 1664312808, 1979212632, 
+1177059525, 1399767562, 1664613544, 1979570270, 1177272187, 1400020461, 1664914294, 1979927924, 1177484859, 1400273372, 1665215057, 1980285594, 1177697541, 1400526295, 1665515835, 1980643281, 
+1177910232, 1400779229, 1665816625, 1981000983, 1178122933, 1401032174, 1666117430, 1981358702, 1178335643, 1401285131, 1666418248, 1981716437, 1178548363, 1401538099, 1666719079, 1982074187, 
+1178761093, 1401791078, 1667019924, 1982431954, 1178973832, 1402044069, 1667320783, 1982789738, 1179186581, 1402297072, 1667621655, 1983147537, 1179399339, 1402550085, 1667922541, 1983505352, 
+1179612107, 1402803110, 1668223440, 1983863184, 1179824884, 1403056147, 1668524353, 1984221032, 1180037672, 1403309195, 1668825279, 1984578896, 1180250468, 1403562254, 1669126219, 1984936776, 
+1180463275, 1403815325, 1669427173, 1985294672, 1180676090, 1404068407, 1669728140, 1985652584, 1180888916, 1404321501, 1670029121, 1986010513, 1181101751, 1404574606, 1670330115, 1986368457, 
+1181314596, 1404827722, 1670631123, 1986726418, 1181527450, 1405080850, 1670932144, 1987084395, 1181740314, 1405333989, 1671233179, 1987442387, 1181953187, 1405587140, 1671534228, 1987800396, 
+1182166070, 1405840302, 1671835290, 1988158422, 1182378963, 1406093475, 1672136365, 1988516463, 1182591865, 1406346660, 1672437455, 1988874520, 1182804777, 1406599856, 1672738557, 1989232594, 
+1183017698, 1406853064, 1673039674, 1989590683, 1183230629, 1407106283, 1673340803, 1989948789, 1183443570, 1407359513, 1673641947, 1990306911, 1183656520, 1407612755, 1673943104, 1990665049, 
+1183869480, 1407866008, 1674244274, 1991023203, 1184082449, 1408119273, 1674545458, 1991381373, 1184295428, 1408372549, 1674846656, 1991739559, 1184508416, 1408625836, 1675147867, 1992097762, 
+1184721414, 1408879135, 1675449091, 1992455980, 1184934422, 1409132445, 1675750330, 1992814215, 1185147439, 1409385766, 1676051581, 1993172466, 1185360465, 1409639099, 1676352847, 1993530732, 
+1185573502, 1409892444, 1676654125, 1993889015, 1185786548, 1410145799, 1676955418, 1994247314, 1185999603, 1410399166, 1677256724, 1994605629, 1186212668, 1410652545, 1677558043, 1994963960, 
+1186425743, 1410905934, 1677859376, 1995322308, 1186638827, 1411159336, 1678160722, 1995680671, 1186851920, 1411412748, 1678462082, 1996039050, 1187065024, 1411666172, 1678763456, 1996397446, 
+1187278136, 1411919607, 1679064843, 1996755858, 1187491259, 1412173054, 1679366243, 1997114285, 1187704391, 1412426512, 1679667657, 1997472729, 1187917532, 1412679981, 1679969085, 1997831189, 
+1188130683, 1412933462, 1680270526, 1998189665, 1188343844, 1413186954, 1680571981, 1998548157, 1188557014, 1413440458, 1680873449, 1998906665, 1188770194, 1413693973, 1681174931, 1999265189, 
+1188983383, 1413947499, 1681476426, 1999623729, 1189196582, 1414201036, 1681777935, 1999982286, 1189409790, 1414454585, 1682079457, 2000340858, 1189623008, 1414708146, 1682380993, 2000699447, 
+1189836236, 1414961717, 1682682542, 2001058051, 1190049473, 1415215300, 1682984105, 2001416672, 1190262720, 1415468895, 1683285681, 2001775308, 1190475976, 1415722501, 1683587271, 2002133961, 
+1190689242, 1415976118, 1683888874, 2002492630, 1190902517, 1416229746, 1684190491, 2002851315, 1191115802, 1416483386, 1684492121, 2003210016, 1191329096, 1416737037, 1684793765, 2003568732, 
+1191542400, 1416990700, 1685095422, 2003927465, 1191755713, 1417244374, 1685397093, 2004286215, 1191969036, 1417498059, 1685698777, 2004644980, 1192182369, 1417751756, 1686000475, 2005003761, 
+1192395711, 1418005464, 1686302186, 2005362558, 1192609063, 1418259183, 1686603911, 2005721371, 1192822424, 1418512914, 1686905649, 2006080201, 1193035795, 1418766655, 1687207401, 2006439046, 
+1193249175, 1419020409, 1687509167, 2006797907, 1193462565, 1419274174, 1687810945, 2007156785, 1193675964, 1419527950, 1688112738, 2007515678, 1193889373, 1419781737, 1688414543, 2007874588, 
+1194102791, 1420035536, 1688716363, 2008233514, 1194316219, 1420289346, 1689018195, 2008592455, 1194529657, 1420543167, 1689320041, 2008951413, 1194743104, 1420797000, 1689621901, 2009310387, 
+1194956561, 1421050844, 1689923774, 2009669376, 1195170027, 1421304699, 1690225661, 2010028382, 1195383502, 1421558566, 1690527561, 2010387404, 1195596987, 1421812444, 1690829475, 2010746442, 
+1195810482, 1422066334, 1691131402, 2011105495, 1196023986, 1422320234, 1691433342, 2011464565, 1196237500, 1422574146, 1691735296, 2011823651, 1196451023, 1422828070, 1692037264, 2012182753, 
+1196664556, 1423082005, 1692339245, 2012541871, 1196878099, 1423335951, 1692641239, 2012901005, 1197091650, 1423589908, 1692943247, 2013260155, 1197305212, 1423843877, 1693245269, 2013619321, 
+1197518783, 1424097857, 1693547304, 2013978503, 1197732363, 1424351848, 1693849352, 2014337701, 1197945953, 1424605851, 1694151414, 2014696915, 1198159553, 1424859865, 1694453489, 2015056145, 
+1198373162, 1425113890, 1694755578, 2015415391, 1198586780, 1425367927, 1695057680, 2015774653, 1198800408, 1425621975, 1695359796, 2016133932, 1199014046, 1425876034, 1695661925, 2016493226, 
+1199227693, 1426130105, 1695964067, 2016852536, 1199441349, 1426384187, 1696266223, 2017211862, 1199655015, 1426638280, 1696568393, 2017571204, 1199868691, 1426892384, 1696870576, 2017930562, 
+1200082376, 1427146500, 1697172772, 2018289936, 1200296071, 1427400627, 1697474982, 2018649326, 1200509775, 1427654766, 1697777205, 2019008732, 1200723489, 1427908916, 1698079442, 2019368155, 
+1200937212, 1428163077, 1698381692, 2019727593, 1201150944, 1428417249, 1698683956, 2020087047, 1201364687, 1428671433, 1698986233, 2020446517, 1201578438, 1428925628, 1699288524, 2020806003, 
+1201792200, 1429179834, 1699590828, 2021165505, 1202005970, 1429434052, 1699893145, 2021525023, 1202219750, 1429688281, 1700195476, 2021884557, 1202433540, 1429942521, 1700497820, 2022244107, 
+1202647339, 1430196773, 1700800178, 2022603673, 1202861148, 1430451036, 1701102549, 2022963255, 1203074966, 1430705310, 1701404934, 2023322853, 1203288794, 1430959595, 1701707332, 2023682467, 
+1203502631, 1431213892, 1702009743, 2024042097, 1203716478, 1431468200, 1702312168, 2024401743, 1203930334, 1431722519, 1702614607, 2024761405, 1204144200, 1431976850, 1702917059, 2025121082, 
+1204358075, 1432231192, 1703219524, 2025480776, 1204571960, 1432485545, 1703522002, 2025840486, 1204785854, 1432739910, 1703824495, 2026200212, 1204999758, 1432994286, 1704127000, 2026559953, 
+1205213671, 1433248673, 1704429519, 2026919711, 1205427594, 1433503071, 1704732051, 2027279485, 1205641526, 1433757481, 1705034597, 2027639274, 1205855467, 1434011902, 1705337156, 2027999080, 
+1206069419, 1434266334, 1705639729, 2028358901, 1206283379, 1434520777, 1705942315, 2028718739, 1206497349, 1434775232, 1706244915, 2029078592, 1206711329, 1435029698, 1706547527, 2029438462, 
+1206925318, 1435284176, 1706850154, 2029798347, 1207139317, 1435538664, 1707152793, 2030158248, 1207353325, 1435793164, 1707455447, 2030518166, 1207567342, 1436047675, 1707758113, 2030878099, 
+1207781369, 1436302198, 1708060793, 2031238048, 1207995406, 1436556732, 1708363486, 2031598013, 1208209452, 1436811277, 1708666193, 2031957994, 1208423507, 1437065833, 1708968913, 2032317991, 
+1208637572, 1437320401, 1709271647, 2032678004, 1208851647, 1437574979, 1709574394, 2033038033, 1209065731, 1437829570, 1709877154, 2033398078, 1209279824, 1438084171, 1710179928, 2033758138, 
+1209493927, 1438338784, 1710482715, 2034118215, 1209708039, 1438593408, 1710785516, 2034478308, 1209922161, 1438848043, 1711088330, 2034838416, 1210136293, 1439102689, 1711391157, 2035198541, 
+1210350433, 1439357347, 1711693998, 2035558681, 1210564584, 1439612016, 1711996852, 2035918838, 1210778743, 1439866696, 1712299720, 2036279010, 1210992912, 1440121388, 1712602601, 2036639198, 
+1211207091, 1440376091, 1712905495, 2036999402, 1211421279, 1440630805, 1713208403, 2037359622, 1211635477, 1440885530, 1713511324, 2037719858, 1211849684, 1441140266, 1713814259, 2038080110, 
+1212063900, 1441395014, 1714117207, 2038440378, 1212278126, 1441649773, 1714420168, 2038800662, 1212492362, 1441904544, 1714723143, 2039160961, 1212706607, 1442159325, 1715026131, 2039521277, 
+1212920861, 1442414118, 1715329132, 2039881608, 1213135125, 1442668922, 1715632147, 2040241956, 1213349398, 1442923738, 1715935175, 2040602319, 1213563681, 1443178564, 1716238217, 2040962698, 
+1213777973, 1443433402, 1716541272, 2041323093, 1213992275, 1443688251, 1716844340, 2041683505, 1214206586, 1443943111, 1717147422, 2042043931, 1214420907, 1444197983, 1717450517, 2042404374, 
+1214635237, 1444452866, 1717753625, 2042764833, 1214849576, 1444707760, 1718056747, 2043125308, 1215063925, 1444962665, 1718359882, 2043485798, 1215278284, 1445217582, 1718663031, 2043846305, 
+1215492652, 1445472510, 1718966193, 2044206827, 1215707029, 1445727449, 1719269368, 2044567365, 1215921416, 1445982399, 1719572557, 2044927920, 1216135812, 1446237360, 1719875759, 2045288490, 
+1216350218, 1446492333, 1720178974, 2045649075, 1216564633, 1446747317, 1720482203, 2046009677, 1216779057, 1447002312, 1720785445, 2046370295, 1216993491, 1447257319, 1721088701, 2046730929, 
+1217207935, 1447512337, 1721391970, 2047091578, 1217422388, 1447767366, 1721695252, 2047452243, 1217636850, 1448022406, 1721998548, 2047812925, 1217851322, 1448277457, 1722301856, 2048173622, 
+1218065803, 1448532520, 1722605179, 2048534335, 1218280294, 1448787594, 1722908514, 2048895064, 1218494794, 1449042679, 1723211863, 2049255809, 1218709304, 1449297775, 1723515226, 2049616569, 
+1218923823, 1449552882, 1723818601, 2049977346, 1219138351, 1449808001, 1724121990, 2050338138, 1219352889, 1450063131, 1724425393, 2050698946, 1219567436, 1450318272, 1724728809, 2051059771, 
+1219781993, 1450573425, 1725032238, 2051420611, 1219996559, 1450828588, 1725335680, 2051781466, 1220211135, 1451083763, 1725639136, 2052142338, 1220425720, 1451338949, 1725942605, 2052503226, 
+1220640314, 1451594147, 1726246087, 2052864129, 1220854918, 1451849355, 1726549583, 2053225049, 1221069532, 1452104575, 1726853092, 2053585984, 1221284154, 1452359806, 1727156615, 2053946935, 
+1221498787, 1452615048, 1727460151, 2054307902, 1221713428, 1452870301, 1727763700, 2054668885, 1221928079, 1453125566, 1728067262, 2055029883, 1222142740, 1453380842, 1728370838, 2055390898, 
+1222357410, 1453636129, 1728674427, 2055751928, 1222572089, 1453891427, 1728978029, 2056112974, 1222786778, 1454146736, 1729281645, 2056474036, 1223001476, 1454402057, 1729585274, 2056835114, 
+1223216184, 1454657389, 1729888917, 2057196208, 1223430901, 1454912732, 1730192573, 2057557318, 1223645627, 1455168086, 1730496242, 2057918443, 1223860363, 1455423452, 1730799924, 2058279584, 
+1224075109, 1455678828, 1731103620, 2058640741, 1224289863, 1455934216, 1731407329, 2059001914, 1224504627, 1456189615, 1731711051, 2059363103, 1224719401, 1456445025, 1732014787, 2059724308, 
+1224934184, 1456700447, 1732318536, 2060085528, 1225148976, 1456955880, 1732622298, 2060446765, 1225363778, 1457211323, 1732926074, 2060808017, 1225578589, 1457466778, 1733229863, 2061169285, 
+1225793410, 1457722245, 1733533665, 2061530569, 1226008240, 1457977722, 1733837481, 2061891868, 1226223080, 1458233211, 1734141310, 2062253184, 1226437928, 1458488711, 1734445152, 2062614515, 
+1226652787, 1458744222, 1734749007, 2062975862, 1226867654, 1458999744, 1735052876, 2063337225, 1227082531, 1459255277, 1735356758, 2063698604, 1227297418, 1459510822, 1735660654, 2064059998, 
+1227512314, 1459766377, 1735964562, 2064421409, 1227727219, 1460021944, 1736268484, 2064782835, 1227942134, 1460277522, 1736572420, 2065144277, 1228157058, 1460533112, 1736876368, 2065505735, 
+1228371992, 1460788712, 1737180330, 2065867209, 1228586934, 1461044324, 1737484305, 2066228698, 1228801887, 1461299947, 1737788294, 2066590203, 1229016849, 1461555581, 1738092296, 2066951724, 
+1229231820, 1461811226, 1738396311, 2067313261, 1229446800, 1462066882, 1738700339, 2067674814, 1229661790, 1462322550, 1739004381, 2068036383, 1229876789, 1462578229, 1739308436, 2068397967, 
+1230091798, 1462833919, 1739612504, 2068759567, 1230306816, 1463089620, 1739916586, 2069121183, 1230521844, 1463345332, 1740220680, 2069482815, 1230736881, 1463601055, 1740524788, 2069844462, 
+1230951927, 1463856790, 1740828910, 2070206126, 1231166983, 1464112536, 1741133045, 2070567805, 1231382048, 1464368293, 1741437193, 2070929500, 1231597122, 1464624061, 1741741354, 2071291210, 
+1231812206, 1464879840, 1742045528, 2071652937, 1232027299, 1465135630, 1742349716, 2072014679, 1232242402, 1465391432, 1742653917, 2072376437, 1232457514, 1465647245, 1742958132, 2072738211, 
+1232672636, 1465903069, 1743262359, 2073100001, 1232887766, 1466158904, 1743566600, 2073461806, 1233102907, 1466414750, 1743870854, 2073823628, 1233318056, 1466670607, 1744175122, 2074185465, 
+1233533215, 1466926476, 1744479402, 2074547317, 1233748383, 1467182356, 1744783696, 2074909186, 1233963561, 1467438247, 1745088004, 2075271070, 1234178748, 1467694149, 1745392324, 2075632970, 
+1234393945, 1467950062, 1745696658, 2075994886, 1234609151, 1468205986, 1746001005, 2076356818, 1234824366, 1468461922, 1746305365, 2076718765, 1235039590, 1468717868, 1746609739, 2077080729, 
+1235254824, 1468973826, 1746914126, 2077442708, 1235470068, 1469229795, 1747218526, 2077804702, 1235685321, 1469485775, 1747522939, 2078166713, 1235900583, 1469741766, 1747827366, 2078528739, 
+1236115854, 1469997769, 1748131806, 2078890781, 1236331135, 1470253782, 1748436259, 2079252839, 1236546425, 1470509807, 1748740725, 2079614913, 1236761725, 1470765843, 1749045205, 2079977002, 
+1236977034, 1471021890, 1749349698, 2080339107, 1237192352, 1471277948, 1749654204, 2080701228, 1237407680, 1471534017, 1749958723, 2081063365, 1237623017, 1471790098, 1750263256, 2081425517, 
+1237838364, 1472046189, 1750567802, 2081787685, 1238053719, 1472302292, 1750872361, 2082149869, 1238269085, 1472558406, 1751176933, 2082512069, 1238484459, 1472814531, 1751481519, 2082874284, 
+1238699843, 1473070667, 1751786118, 2083236515, 1238915236, 1473326814, 1752090730, 2083598762, 1239130639, 1473582972, 1752395355, 2083961025, 1239346051, 1473839142, 1752699994, 2084323303, 
+1239561472, 1474095322, 1753004646, 2084685597, 1239776903, 1474351514, 1753309311, 2085047907, 1239992343, 1474607717, 1753613989, 2085410233, 1240207793, 1474863931, 1753918680, 2085772574, 
+1240423251, 1475120156, 1754223385, 2086134931, 1240638720, 1475376392, 1754528103, 2086497304, 1240854197, 1475632640, 1754832834, 2086859692, 1241069684, 1475888898, 1755137579, 2087222097, 
+1241285180, 1476145168, 1755442337, 2087584517, 1241500686, 1476401449, 1755747107, 2087946952, 1241716201, 1476657741, 1756051892, 2088309404, 1241931725, 1476914044, 1756356689, 2088671871, 
+1242147259, 1477170358, 1756661500, 2089034354, 1242362802, 1477426683, 1756966323, 2089396853, 1242578354, 1477683019, 1757271160, 2089759367, 1242793916, 1477939367, 1757576011, 2090121897, 
+1243009487, 1478195726, 1757880874, 2090484443, 1243225067, 1478452095, 1758185751, 2090847004, 1243440657, 1478708476, 1758490641, 2091209582, 1243656256, 1478964868, 1758795544, 2091572175, 
+1243871864, 1479221271, 1759100460, 2091934783, 1244087482, 1479477685, 1759405390, 2092297408, 1244303109, 1479734110, 1759710332, 2092660048, 1244518745, 1479990547, 1760015288, 2093022704, 
+1244734391, 1480246994, 1760320258, 2093385375, 1244950046, 1480503453, 1760625240, 2093748062, 1245165711, 1480759923, 1760930236, 2094110765, 1245381385, 1481016403, 1761235244, 2094473484, 
+1245597068, 1481272895, 1761540266, 2094836218, 1245812760, 1481529398, 1761845302, 2095198968, 1246028462, 1481785913, 1762150350, 2095561734, 1246244173, 1482042438, 1762455412, 2095924516, 
+1246459894, 1482298974, 1762760487, 2096287313, 1246675623, 1482555522, 1763065575, 2096650126, 1246891363, 1482812080, 1763370676, 2097012954, 1247107111, 1483068650, 1763675790, 2097375798, 
+1247322869, 1483325230, 1763980918, 2097738658, 1247538636, 1483581822, 1764286059, 2098101534, 1247754413, 1483838425, 1764591213, 2098464425, 1247970198, 1484095039, 1764896380, 2098827332, 
+1248185993, 1484351664, 1765201560, 2099190255, 1248401798, 1484608300, 1765506754, 2099553193, 1248617612, 1484864948, 1765811961, 2099916147, 1248833435, 1485121606, 1766117181, 2100279117, 
+1249049267, 1485378276, 1766422414, 2100642103, 1249265109, 1485634956, 1766727660, 2101005104, 1249480960, 1485891648, 1767032920, 2101368120, 1249696820, 1486148350, 1767338192, 2101731153, 
+1249912690, 1486405064, 1767643478, 2102094201, 1250128569, 1486661789, 1767948777, 2102457265, 1250344458, 1486918525, 1768254090, 2102820344, 1250560355, 1487175272, 1768559415, 2103183440, 
+1250776262, 1487432030, 1768864754, 2103546550, 1250992179, 1487688800, 1769170105, 2103909677, 1251208104, 1487945580, 1769475470, 2104272819, 1251424039, 1488202371, 1769780849, 2104635977, 
+1251639983, 1488459174, 1770086240, 2104999151, 1251855937, 1488715987, 1770391644, 2105362340, 1252071900, 1488972812, 1770697062, 2105725545, 1252287872, 1489229648, 1771002493, 2106088765, 
+1252503854, 1489486494, 1771307937, 2106452001, 1252719845, 1489743352, 1771613394, 2106815253, 1252935845, 1490000221, 1771918864, 2107178521, 1253151854, 1490257101, 1772224348, 2107541804, 
+1253367873, 1490513992, 1772529844, 2107905103, 1253583901, 1490770894, 1772835354, 2108268417, 1253799938, 1491027807, 1773140877, 2108631747, 1254015985, 1491284732, 1773446413, 2108995093, 
+1254232041, 1491541667, 1773751963, 2109358454, 1254448106, 1491798613, 1774057525, 2109721831, 1254664181, 1492055571, 1774363101, 2110085224, 1254880265, 1492312539, 1774668690, 2110448633, 
+1255096358, 1492569519, 1774974292, 2110812057, 1255312461, 1492826510, 1775279907, 2111175496, 1255528572, 1493083511, 1775585535, 2111538951, 1255744693, 1493340524, 1775891176, 2111902422, 
+1255960824, 1493597548, 1776196831, 2112265909, 1256176964, 1493854583, 1776502499, 2112629411, 1256393113, 1494111629, 1776808179, 2112992929, 1256609271, 1494368686, 1777113873, 2113356463, 
+1256825438, 1494625754, 1777419581, 2113720012, 1257041615, 1494882833, 1777725301, 2114083576, 1257257802, 1495139923, 1778031034, 2114447157, 1257473997, 1495397024, 1778336781, 2114810753, 
+1257690202, 1495654136, 1778642541, 2115174364, 1257906416, 1495911260, 1778948314, 2115537992, 1258122639, 1496168394, 1779254100, 2115901635, 1258338872, 1496425540, 1779559899, 2116265293, 
+1258555114, 1496682696, 1779865711, 2116628967, 1258771365, 1496939863, 1780171536, 2116992657, 1258987626, 1497197042, 1780477375, 2117356362, 1259203895, 1497454232, 1780783227, 2117720083, 
+1259420174, 1497711432, 1781089091, 2118083820, 1259636463, 1497968644, 1781394969, 2118447572, 1259852760, 1498225867, 1781700860, 2118811340, 1260069067, 1498483100, 1782006765, 2119175124, 
+1260285384, 1498740345, 1782312682, 2119538923, 1260501709, 1498997601, 1782618613, 2119902737, 1260718044, 1499254868, 1782924556, 2120266568, 1260934388, 1499512146, 1783230513, 2120630414, 
+1261150741, 1499769435, 1783536483, 2120994275, 1261367104, 1500026735, 1783842466, 2121358152, 1261583476, 1500284046, 1784148462, 2121722045, 1261799857, 1500541368, 1784454471, 2122085953, 
+1262016248, 1500798701, 1784760493, 2122449877, 1262232647, 1501056045, 1785066529, 2122813817, 1262449056, 1501313400, 1785372577, 2123177772, 1262665475, 1501570766, 1785678639, 2123541743, 
+1262881902, 1501828144, 1785984714, 2123905729, 1263098339, 1502085532, 1786290802, 2124269731, 1263314785, 1502342931, 1786596903, 2124633748, 1263531241, 1502600341, 1786903017, 2124997781, 
+1263747705, 1502857763, 1787209144, 2125361830, 1263964179, 1503115195, 1787515284, 2125725894, 1264180662, 1503372638, 1787821438, 2126089974, 1264397155, 1503630093, 1788127605, 2126454070, 
+1264613657, 1503887558, 1788433784, 2126818181, 1264830168, 1504145034, 1788739977, 2127182308, 1265046688, 1504402522, 1789046183, 2127546450, 1265263217, 1504660020, 1789352402, 2127910608, 
+1265479756, 1504917530, 1789658634, 2128274781, 1265696304, 1505175050, 1789964879, 2128638970, 1265912861, 1505432582, 1790271137, 2129003174, 1266129428, 1505690124, 1790577409, 2129367395, 
+1266346004, 1505947678, 1790883693, 2129731630, 1266562589, 1506205242, 1791189991, 2130095882, 1266779183, 1506462818, 1791496302, 2130460148, 1266995787, 1506720405, 1791802625, 2130824431, 
+1267212400, 1506978002, 1792108962, 2131188729, 1267429022, 1507235611, 1792415312, 2131553042, 1267645653, 1507493230, 1792721675, 2131917371, 1267862294, 1507750861, 1793028051, 2132281716, 
+1268078944, 1508008502, 1793334441, 2132646076, 1268295603, 1508266155, 1793640843, 2133010452, 1268512271, 1508523819, 1793947258, 2133374844, 1268728949, 1508781493, 1794253687, 2133739250, 
+1268945636, 1509039179, 1794560128, 2134103673, 1269162332, 1509296876, 1794866583, 2134468111, 1269379038, 1509554583, 1795173051, 2134832565, 1269595752, 1509812302, 1795479532, 2135197034, 
+1269812476, 1510070031, 1795786025, 2135561518, 1270029209, 1510327772, 1796092532, 2135926019, 1270245952, 1510585524, 1796399052, 2136290535, 1270462703, 1510843286, 1796705586, 2136655066, 
+1270679464, 1511101060, 1797012132, 2137019613, 1270896234, 1511358844, 1797318691, 2137384175, 1271113014, 1511616640, 1797625263, 2137748753, 1271329802, 1511874447, 1797931849, 2138113347, 
+1271546600, 1512132264, 1798238447, 2138477956, 1271763407, 1512390093, 1798545059, 2138842581, 1271980224, 1512647932, 1798851683, 2139207221, 1272197049, 1512905783, 1799158321, 2139571877, 
+1272413884, 1513163644, 1799464972, 2139936548, 1272630728, 1513421517, 1799771636, 2140301235, 1272847582, 1513679400, 1800078313, 2140665937, 1273064444, 1513937295, 1800385003, 2141030655, 
+1273281316, 1514195200, 1800691706, 2141395388, 1273498197, 1514453117, 1800998422, 2141760137, 1273715087, 1514711044, 1801305151, 2142124902, 1273931987, 1514968982, 1801611893, 2142489682, 
+1274148895, 1515226932, 1801918648, 2142854477, 1274365813, 1515484892, 1802225417, 2143219288, 1274582740, 1515742864, 1802532198, 2143584115, 1274799677, 1516000846, 1802838992, 2143948957, 
+1275016622, 1516258839, 1803145800, 2144313814, 1275233577, 1516516843, 1803452620, 2144678688, 1275450541, 1516774859, 1803759454, 2145043576, 1275667515, 1517032885, 1804066300, 2145408480, 
+1275884497, 1517290922, 1804373160, 2145773400, 1276101489, 1517548970, 1804680033, 2146138335, 1276318490, 1517807029, 1804986919, 2146503286, 1276535500, 1518065099, 1805293817, 2146868252, 
+1276752520, 1518323181, 1805600729, 2147233234, 1276969548, 1518581273, 1805907654, 1073799116, 1277186586, 1518839376, 1806214592, 1073981622, 1277403633, 1519097490, 1806521543, 1074164136, 
+1277620690, 1519355614, 1806828507, 1074346658, 1277837755, 1519613750, 1807135484, 1074529188, 1278054830, 1519871897, 1807442474, 1074711725, 1278271914, 1520130055, 1807749477, 1074894270, 
+1278489007, 1520388224, 1808056493, 1075076823, 1278706110, 1520646404, 1808363523, 1075259384, 1278923221, 1520904594, 1808670565, 1075441952, 1279140342, 1521162796, 1808977620, 1075624528, 
+1279357472, 1521421009, 1809284688, 1075807112, 1279574611, 1521679232, 1809591770, 1075989704, 1279791760, 1521937467, 1809898864, 1076172303, 1280008918, 1522195712, 1810205971, 1076354910, 
+1280226085, 1522453969, 1810513092, 1076537525, 1280443261, 1522712236, 1810820225, 1076720148, 1280660446, 1522970514, 1811127372, 1076902778, 1280877641, 1523228804, 1811434531, 1077085416, 
+1281094844, 1523487104, 1811741703, 1077268062, 1281312057, 1523745415, 1812048889, 1077450716, 1281529279, 1524003737, 1812356088, 1077633377, 1281746511, 1524262070, 1812663299, 1077816046, 
+1281963751, 1524520414, 1812970524, 1077998723, 1282181001, 1524778769, 1813277761, 1078181408, 1282398260, 1525037135, 1813585012, 1078364100, 1282615528, 1525295512, 1813892275, 1078546800, 
+1282832806, 1525553900, 1814199552, 1078729508, 1283050092, 1525812299, 1814506842, 1078912223, 1283267388, 1526070708, 1814814144, 1079094946, 1283484693, 1526329129, 1815121460, 1079277677, 
+1283702007, 1526587560, 1815428789, 1079460416, 1283919331, 1526846003, 1815736130, 1079643163, 1284136663, 1527104456, 1816043485, 1079825917, 1284354005, 1527362921, 1816350853, 1080008679, 
+1284571356, 1527621396, 1816658233, 1080191448, 1284788716, 1527879882, 1816965627, 1080374226, 1285006085, 1528138380, 1817273034, 1080557011, 1285223464, 1528396888, 1817580453, 1080739804, 
+1285440852, 1528655407, 1817887886, 1080922604, 1285658249, 1528913937, 1818195332, 1081105412, 1285875655, 1529172478, 1818502790, 1081288228, 1286093070, 1529431029, 1818810262, 1081471052, 
+1286310494, 1529689592, 1819117747, 1081653884, 1286527928, 1529948166, 1819425244, 1081836723, 1286745371, 1530206750, 1819732755, 1082019570, 1286962823, 1530465346, 1820040279, 1082202424, 
+1287180284, 1530723952, 1820347815, 1082385287, 1287397755, 1530982570, 1820655365, 1082568157, 1287615234, 1531241198, 1820962928, 1082751035, 1287832723, 1531499837, 1821270503, 1082933920, 
+1288050221, 1531758487, 1821578092, 1083116814, 1288267728, 1532017149, 1821885693, 1083299715, 1288485245, 1532275820, 1822193308, 1083482623, 1288702770, 1532534503, 1822500935, 1083665540, 
+1288920305, 1532793197, 1822808576, 1083848464, 1289137849, 1533051902, 1823116229, 1084031396, 1289355402, 1533310618, 1823423896, 1084214335, 1289572964, 1533569344, 1823731575, 1084397283, 
+1289790535, 1533828082, 1824039268, 1084580238, 1290008116, 1534086830, 1824346973, 1084763200, 1290225706, 1534345589, 1824654692, 1084946171, 1290443305, 1534604360, 1824962423, 1085129149, 
+1290660913, 1534863141, 1825270167, 1085312135, 1290878530, 1535121933, 1825577925, 1085495129, 1291096157, 1535380736, 1825885695, 1085678130, 1291313792, 1535639549, 1826193478, 1085861139, 
+1291531437, 1535898374, 1826501274, 1086044156, 1291749091, 1536157210, 1826809084, 1086227180, 1291966754, 1536416056, 1827116906, 1086410212, 1292184426, 1536674914, 1827424741, 1086593252, 
+1292402108, 1536933782, 1827732589, 1086776300, 1292619799, 1537192661, 1828040450, 1086959355, 1292837498, 1537451552, 1828348324, 1087142418, 1293055207, 1537710453, 1828656211, 1087325489, 
+1293272925, 1537969365, 1828964111, 1087508567, 1293490653, 1538228287, 1829272024, 1087691653, 1293708389, 1538487221, 1829579950, 1087874747, 1293926135, 1538746166, 1829887889, 1088057848, 
+1294143890, 1539005121, 1830195840, 1088240958, 1294361654, 1539264088, 1830503805, 1088424075, 1294579427, 1539523065, 1830811783, 1088607199, 1294797209, 1539782053, 1831119773, 1088790331, 
+1295015000, 1540041052, 1831427777, 1088973471, 1295232801, 1540300062, 1831735793, 1089156619, 1295450611, 1540559083, 1832043823, 1089339775, 1295668430, 1540818115, 1832351865, 1089522938, 
+1295886258, 1541077158, 1832659921, 1089706109, 1296104095, 1541336211, 1832967989, 1089889287, 1296321941, 1541595276, 1833276070, 1090072473, 1296539797, 1541854351, 1833584165, 1090255667, 
+1296757661, 1542113437, 1833892272, 1090438869, 1296975535, 1542372534, 1834200392, 1090622078, 1297193418, 1542631642, 1834508525, 1090805295, 1297411310, 1542890761, 1834816671, 1090988520, 
+1297629211, 1543149891, 1835124830, 1091171752, 1297847122, 1543409031, 1835433002, 1091354992, 1298065041, 1543668183, 1835741186, 1091538240, 1298282970, 1543927345, 1836049384, 1091721495, 
+1298500908, 1544186518, 1836357595, 1091904759, 1298718855, 1544445703, 1836665818, 1092088029, 1298936811, 1544704898, 1836974055, 1092271308, 1299154776, 1544964103, 1837282304, 1092454594, 
+1299372751, 1545223320, 1837590567, 1092637888, 1299590734, 1545482548, 1837898842, 1092821190, 1299808727, 1545741786, 1838207130, 1093004499, 1300026729, 1546001036, 1838515431, 1093187816, 
+1300244740, 1546260296, 1838823745, 1093371141, 1300462760, 1546519567, 1839132072, 1093554473, 1300680789, 1546778849, 1839440412, 1093737813, 1300898828, 1547038142, 1839748765, 1093921161, 
+1301116875, 1547297445, 1840057131, 1094104516, 1301334932, 1547556760, 1840365510, 1094287879, 1301552998, 1547816085, 1840673901, 1094471250, 1301771072, 1548075422, 1840982306, 1094654628, 
+1301989157, 1548334769, 1841290723, 1094838014, 1302207250, 1548594127, 1841599154, 1095021408, 1302425352, 1548853495, 1841907597, 1095204810, 1302643464, 1549112875, 1842216053, 1095388219, 
+1302861584, 1549372266, 1842524522, 1095571636, 1303079714, 1549631667, 1842833004, 1095755060, 1303297853, 1549891079, 1843141499, 1095938492, 1303516001, 1550150503, 1843450007, 1096121932, 
+1303734158, 1550409937, 1843758528, 1096305380, 1303952324, 1550669381, 1844067061, 1096488835, 1304170499, 1550928837, 1844375608, 1096672298, 1304388684, 1551188304, 1844684167, 1096855768, 
+1304606878, 1551447781, 1844992740, 1097039247, 1304825080, 1551707269, 1845301325, 1097222733, 1305043292, 1551966768, 1845609923, 1097406226, 1305261513, 1552226278, 1845918534, 1097589727, 
+1305479743, 1552485799, 1846227158, 1097773236, 1305697982, 1552745331, 1846535795, 1097956753, 1305916231, 1553004873, 1846844445, 1098140277, 1306134488, 1553264427, 1847153108, 1098323809, 
+1306352755, 1553523991, 1847461783, 1098507349, 1306571030, 1553783566, 1847770472, 1098690896, 1306789315, 1554043152, 1848079173, 1098874451, 1307007609, 1554302748, 1848387887, 1099058013, 
+1307225912, 1554562356, 1848696614, 1099241584, 1307444224, 1554821974, 1849005354, 1099425161, 1307662546, 1555081603, 1849314107, 1099608747, 1307880876, 1555341243, 1849622873, 1099792340, 
+1308099216, 1555600894, 1849931652, 1099975941, 1308317564, 1555860556, 1850240443, 1100159550, 1308535922, 1556120229, 1850549248, 1100343166, 1308754289, 1556379912, 1850858065, 1100526790, 
+1308972665, 1556639606, 1851166895, 1100710421, 1309191050, 1556899311, 1851475738, 1100894061, 1309409444, 1557159027, 1851784594, 1101077707, 1309627847, 1557418754, 1852093463, 1101261362, 
+1309846259, 1557678491, 1852402345, 1101445024, 1310064681, 1557938240, 1852711239, 1101628694, 1310283112, 1558197999, 1853020147, 1101812371, 1310501551, 1558457769, 1853329067, 1101996057, 
+1310720000, 1558717550, 1853638000, 1102179749, 1310938458, 1558977341, 1853946947, 1102363450, 1311156925, 1559237144, 1854255906, 1102547158, 1311375401, 1559496957, 1854564877, 1102730874, 
+1311593886, 1559756781, 1854873862, 1102914597, 1311812380, 1560016616, 1855182860, 1103098328, 1312030884, 1560276462, 1855491870, 1103282067, 1312249396, 1560536319, 1855800893, 1103465813, 
+1312467918, 1560796186, 1856109930, 1103649567, 1312686449, 1561056064, 1856418979, 1103833329, 1312904988, 1561315953, 1856728041, 1104017098, 1313123537, 1561575853, 1857037115, 1104200875, 
+1313342095, 1561835764, 1857346203, 1104384660, 1313560662, 1562095685, 1857655303, 1104568452, 1313779238, 1562355618, 1857964417, 1104752252, 1313997824, 1562615561, 1858273543, 1104936059, 
+1314216418, 1562875515, 1858582682, 1105119875, 1314435021, 1563135480, 1858891834, 1105303698, 1314653634, 1563395455, 1859200999, 1105487528, 1314872255, 1563655441, 1859510176, 1105671366, 
+1315090886, 1563915439, 1859819367, 1105855212, 1315309526, 1564175447, 1860128570, 1106039065, 1315528175, 1564435465, 1860437786, 1106222926, 1315746833, 1564695495, 1860747015, 1106406795, 
+1315965500, 1564955535, 1861056257, 1106590671, 1316184176, 1565215587, 1861365512, 1106774555, 1316402861, 1565475649, 1861674780, 1106958447, 1316621555, 1565735721, 1861984060, 1107142346, 
+1316840259, 1565995805, 1862293353, 1107326253, 1317058971, 1566255899, 1862602659, 1107510167, 1317277693, 1566516004, 1862911978, 1107694090, 1317496423, 1566776120, 1863221310, 1107878019, 
+1317715163, 1567036247, 1863530655, 1108061957, 1317933912, 1567296385, 1863840012, 1108245902, 1318152669, 1567556533, 1864149382, 1108429855, 1318371436, 1567816692, 1864458766, 1108613815, 
+1318590212, 1568076862, 1864768162, 1108797783, 1318808997, 1568337043, 1865077570, 1108981758, 1319027792, 1568597235, 1865386992, 1109165742, 1319246595, 1568857437, 1865696426, 1109349732, 
+1319465407, 1569117650, 1866005874, 1109533731, 1319684228, 1569377874, 1866315334, 1109717737, 1319903059, 1569638109, 1866624807, 1109901751, 1320121898, 1569898354, 1866934293, 1110085772, 
+1320340747, 1570158610, 1867243791, 1110269801, 1320559605, 1570418877, 1867553303, 1110453838, 1320778471, 1570679155, 1867862827, 1110637882, 1320997347, 1570939444, 1868172364, 1110821934, 
+1321216232, 1571199743, 1868481914, 1111005993, 1321435126, 1571460054, 1868791477, 1111190060, 1321654029, 1571720374, 1869101052, 1111374135, 1321872941, 1571980706, 1869410640, 1111558217, 
+1322091862, 1572241049, 1869720242, 1111742307, 1322310792, 1572501402, 1870029856, 1111926405, 1322529731, 1572761766, 1870339482, 1112110510, 1322748679, 1573022141, 1870649122, 1112294623, 
+1322967637, 1573282527, 1870958775, 1112478743, 1323186603, 1573542923, 1871268440, 1112662871, 1323405579, 1573803330, 1871578118, 1112847007, 1323624563, 1574063748, 1871887809, 1113031150, 
+1323843557, 1574324177, 1872197512, 1113215301, 1324062559, 1574584616, 1872507229, 1113399460, 1324281571, 1574845067, 1872816958, 1113583626, 1324500592, 1575105528, 1873126700, 1113767800, 
+1324719622, 1575365999, 1873436455, 1113951981, 1324938661, 1575626482, 1873746223, 1114136170, 1325157708, 1575886975, 1874056004, 1114320367, 1325376765, 1576147479, 1874365797, 1114504571, 
+1325595831, 1576407994, 1874675603, 1114688783, 1325814906, 1576668520, 1874985422, 1114873002, 1326033991, 1576929056, 1875295254, 1115057229, 1326253084, 1577189603, 1875605098, 1115241464, 
+1326472186, 1577450161, 1875914955, 1115425706, 1326691297, 1577710730, 1876224826, 1115609956, 1326910418, 1577971309, 1876534709, 1115794213, 1327129547, 1578231900, 1876844604, 1115978479, 
+1327348685, 1578492501, 1877154513, 1116162751, 1327567833, 1578753112, 1877464434, 1116347032, 1327786989, 1579013735, 1877774368, 1116531319, 1328006155, 1579274368, 1878084315, 1116715615, 
+1328225329, 1579535012, 1878394275, 1116899918, 1328444513, 1579795667, 1878704247, 1117084229, 1328663706, 1580056332, 1879014232, 1117268547, 1328882907, 1580317008, 1879324230, 1117452873, 
+1329102118, 1580577695, 1879634241, 1117637207, 1329321338, 1580838393, 1879944265, 1117821548, 1329540567, 1581099102, 1880254301, 1118005896, 1329759804, 1581359821, 1880564350, 1118190253, 
+1329979051, 1581620551, 1880874412, 1118374617, 1330198307, 1581881291, 1881184487, 1118558988, 1330417572, 1582142043, 1881494574, 1118743367, 1330636846, 1582402805, 1881804675, 1118927754, 
+1330856129, 1582663578, 1882114788, 1119112148, 1331075421, 1582924362, 1882424913, 1119296550, 1331294722, 1583185156, 1882735052, 1119480960, 1331514033, 1583445961, 1883045203, 1119665377, 
+1331733352, 1583706777, 1883355368, 1119849802, 1331952680, 1583967604, 1883665544, 1120034234, 1332172017, 1584228441, 1883975734, 1120218674, 1332391363, 1584489289, 1884285937, 1120403121, 
+1332610719, 1584750148, 1884596152, 1120587576, 1332830083, 1585011018, 1884906380, 1120772039, 1333049456, 1585271898, 1885216620, 1120956509, 1333268839, 1585532789, 1885526874, 1121140987, 
+1333488230, 1585793691, 1885837140, 1121325472, 1333707630, 1586054603, 1886147419, 1121509965, 1333927040, 1586315527, 1886457711, 1121694466, 1334146458, 1586576461, 1886768016, 1121878974, 
+1334365886, 1586837405, 1887078333, 1122063490, 1334585322, 1587098361, 1887388663, 1122248013, 1334804768, 1587359327, 1887699006, 1122432544, 1335024222, 1587620304, 1888009361, 1122617083, 
+1335243686, 1587881292, 1888319730, 1122801629, 1335463158, 1588142290, 1888630111, 1122986183, 1335682640, 1588403299, 1888940505, 1123170744, 1335902131, 1588664319, 1889250911, 1123355313, 
+1336121630, 1588925349, 1889561331, 1123539889, 1336341139, 1589186390, 1889871763, 1123724473, 1336560657, 1589447442, 1890182207, 1123909065, 1336780183, 1589708505, 1890492665, 1124093664, 
+1336999719, 1589969578, 1890803135, 1124278271, 1337219264, 1590230663, 1891113618, 1124462885, 1337438817, 1590491757, 1891424114, 1124647507, 1337658380, 1590752863, 1891734623, 1124832137, 
+1337877952, 1591013979, 1892045144, 1125016774, 1338097532, 1591275106, 1892355678, 1125201418, 1338317122, 1591536244, 1892666225, 1125386071, 1338536721, 1591797392, 1892976784, 1125570730, 
+1338756329, 1592058551, 1893287357, 1125755398, 1338975945, 1592319721, 1893597942, 1125940073, 1339195571, 1592580902, 1893908540, 1126124755, 1339415206, 1592842093, 1894219150, 1126309445, 
+1339634850, 1593103295, 1894529773, 1126494143, 1339854503, 1593364508, 1894840409, 1126678848, 1340074164, 1593625731, 1895151058, 1126863561, 1340293835, 1593886965, 1895461719, 1127048281, 
+1340513515, 1594148210, 1895772393, 1127233009, 1340733204, 1594409465, 1896083080, 1127417745, 1340952901, 1594670731, 1896393780, 1127602488, 1341172608, 1594932008, 1896704492, 1127787239, 
+1341392324, 1595193296, 1897015217, 1127971997, 1341612049, 1595454594, 1897325955, 1128156763, 1341831783, 1595715903, 1897636705, 1128341536, 1342051525, 1595977223, 1897947469, 1128526317, 
+1342271277, 1596238553, 1898258245, 1128711105, 1342491038, 1596499894, 1898569033, 1128895901, 1342710808, 1596761246, 1898879835, 1129080705, 1342930586, 1597022608, 1899190649, 1129265516, 
+1343150374, 1597283981, 1899501475, 1129450335, 1343370171, 1597545365, 1899812315, 1129635161, 1343589977, 1597806760, 1900123167, 1129819995, 1343809791, 1598068165, 1900434032, 1130004836, 
+1344029615, 1598329581, 1900744910, 1130189685, 1344249448, 1598591008, 1901055800, 1130374542, 1344469289, 1598852445, 1901366703, 1130559406, 1344689140, 1599113893, 1901677619, 1130744278, 
+1344909000, 1599375352, 1901988548, 1130929157, 1345128868, 1599636821, 1902299489, 1131114043, 1345348746, 1599898301, 1902610443, 1131298938, 1345568633, 1600159792, 1902921409, 1131483840, 
+1345788528, 1600421293, 1903232389, 1131668749, 1346008433, 1600682805, 1903543381, 1131853666, 1346228346, 1600944328, 1903854385, 1132038591, 1346448269, 1601205861, 1904165403, 1132223523, 
+1346668200, 1601467406, 1904476433, 1132408462, 1346888141, 1601728960, 1904787476, 1132593409, 1347108090, 1601990526, 1905098531, 1132778364, 1347328049, 1602252102, 1905409600, 1132963326, 
+1347548016, 1602513689, 1905720681, 1133148296, 1347767993, 1602775286, 1906031774, 1133333274, 1347987978, 1603036895, 1906342881, 1133518259, 1348207972, 1603298513, 1906654000, 1133703251, 
+1348427976, 1603560143, 1906965131, 1133888251, 1348647988, 1603821783, 1907276276, 1134073259, 1348868009, 1604083434, 1907587433, 1134258274, 1349088040, 1604345096, 1907898603, 1134443296, 
+1349308079, 1604606768, 1908209785, 1134628327, 1349528127, 1604868451, 1908520980, 1134813364, 1349748184, 1605130144, 1908832188, 1134998410, 1349968250, 1605391848, 1909143409, 1135183462, 
+1350188326, 1605653563, 1909454642, 1135368523, 1350408410, 1605915289, 1909765888, 1135553591, 1350628503, 1606177025, 1910077146, 1135738666, 1350848605, 1606438772, 1910388417, 1135923749, 
+1351068716, 1606700530, 1910699701, 1136108840, 1351288836, 1606962298, 1911010998, 1136293938, 1351508965, 1607224077, 1911322307, 1136479043, 1351729102, 1607485866, 1911633629, 1136664157, 
+1351949249, 1607747666, 1911944964, 1136849277, 1352169405, 1608009477, 1912256311, 1137034406, 1352389570, 1608271299, 1912567671, 1137219541, 1352609744, 1608533131, 1912879044, 1137404685, 
+1352829926, 1608794974, 1913190429, 1137589835, 1353050118, 1609056827, 1913501827, 1137774994, 1353270318, 1609318691, 1913813238, 1137960160, 1353490528, 1609580566, 1914124661, 1138145333, 
+1353710747, 1609842451, 1914436097, 1138330514, 1353930974, 1610104348, 1914747546, 1138515703, 1354151210, 1610366254, 1915059007, 1138700899, 1354371456, 1610628172, 1915370481, 1138886102, 
+1354591710, 1610890100, 1915681968, 1139071313, 1354811973, 1611152038, 1915993467, 1139256532, 1355032246, 1611413988, 1916304979, 1139441758, 1355252527, 1611675948, 1916616504, 1139626992, 
+1355472817, 1611937918, 1916928041, 1139812233, 1355693116, 1612199899, 1917239591, 1139997482, 1355913424, 1612461891, 1917551154, 1140182738, };
+static uint32_t  exp_table[512]={
+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, 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, 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, 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, 2, 2, 2, 3, 3, 4, 5, 6, 7, 8, 10, 11, 13, 
+16, 19, 23, 27, 32, 38, 45, 54, 64, 76, 91, 108, 128, 152, 181, 215, 
+256, 304, 362, 431, 512, 609, 724, 861, 1024, 1218, 1448, 1722, 2048, 2435, 2896, 3444, 
+4096, 4871, 5793, 6889, 8192, 9742, 11585, 13777, 16384, 19484, 23170, 27554, 32768, 38968, 46341, 55109, 
+65536, 77936, 92682, 110218, 131072, 155872, 185364, 220436, 262144, 311744, 370728, 440872, 524288, 623487, 741455, 881744, 
+1048576, 1246974, 1482910, 1763488, 2097152, 2493948, 2965821, 3526975, 4194304, 4987896, 5931642, 7053950, 8388608, 9975792, 11863283, 14107901, 
+16777216, 19951585, 23726566, 28215802, 33554432, 39903169, 47453133, 56431603, 67108864, 79806339, 94906266, 112863206, 134217728, 159612677, 189812531, 225726413, 
+268435456, 319225354, 379625062, 451452825, 536870912, 638450708, 759250125, 902905651, 1073741824, 1276901417, 1518500250, 1805811301, 2147483648, 2553802834, 3037000500, 3611622603, 
+0, 812638371, 1779033704, 2928277910, 0, 1625276742, 3558067408, 1561588523, 0, 3250553484, 2821167520, 3123177047, 0, 2206139673, 1347367744, 1951386797, 
+0, 117312050, 2694735487, 3902773595, 0, 234624099, 1094503678, 3510579894, 0, 469248199, 2189007357, 2726192491, 0, 938496398, 83047418, 1157417687, 
+0, 1876992795, 166094836, 2314835373, 0, 3753985591, 332189671, 334703450, 0, 3213003886, 664379343, 669406901, 0, 2131040476, 1328758686, 1338813802, 
+0, 4262080951, 2657517372, 2677627604, 0, 4229194606, 1020067448, 1060287911, 0, 4163421916, 2040134895, 2120575823, 0, 4031876537, 4080269790, 4241151645, 
+};
+static uint32_t  expval_table[512][16]={
+{ 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, },
+{ 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, },
+{ 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, },
+{ 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, },
+{ 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, 1, 1, 1, 1, 1, },
+{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, },
+{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, },
+{ 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, },
+{ 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, },
+{ 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, },
+{ 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, },
+{ 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, },
+{ 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, },
+{ 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, },
+{ 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, },
+{ 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 5, 5, },
+{ 0, 0, 0, 1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 5, 6, 7, },
+{ 0, 0, 1, 1, 1, 2, 2, 3, 3, 4, 5, 5, 6, 6, 7, 8, },
+{ 0, 0, 1, 1, 2, 2, 3, 3, 4, 5, 5, 6, 7, 8, 8, 9, },
+{ 0, 0, 1, 1, 2, 3, 3, 4, 5, 6, 6, 7, 8, 9, 10, 11, },
+{ 0, 0, 1, 2, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, },
+{ 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 16, },
+{ 0, 0, 1, 2, 3, 4, 5, 7, 8, 9, 11, 12, 14, 15, 17, 18, },
+{ 0, 1, 1, 3, 4, 5, 6, 8, 10, 11, 13, 15, 16, 18, 20, 22, },
+{ 0, 1, 2, 3, 4, 6, 8, 9, 11, 13, 15, 17, 19, 22, 24, 26, },
+{ 0, 1, 2, 4, 5, 7, 9, 11, 13, 16, 18, 21, 23, 26, 28, 31, },
+{ 0, 1, 3, 4, 6, 9, 11, 13, 16, 19, 22, 24, 27, 31, 34, 37, },
+{ 0, 1, 3, 5, 8, 10, 13, 16, 19, 22, 26, 29, 33, 36, 40, 44, },
+{ 0, 1, 4, 6, 9, 12, 15, 19, 23, 26, 30, 35, 39, 43, 48, 52, },
+{ 0, 2, 4, 7, 11, 14, 18, 23, 27, 31, 36, 41, 46, 51, 57, 62, },
+{ 0, 2, 5, 9, 13, 17, 22, 27, 32, 37, 43, 49, 55, 61, 67, 74, },
+{ 0, 2, 6, 10, 15, 20, 26, 32, 38, 45, 51, 58, 65, 73, 80, 88, },
+{ 0, 3, 7, 12, 18, 24, 31, 38, 45, 53, 61, 69, 78, 86, 95, 105, },
+{ 0, 3, 8, 15, 21, 29, 37, 45, 54, 63, 72, 82, 92, 103, 113, 124, },
+{ 0, 4, 10, 17, 25, 34, 44, 54, 64, 75, 86, 98, 110, 122, 135, 148, },
+{ 0, 5, 12, 21, 30, 41, 52, 64, 76, 89, 102, 116, 131, 145, 161, 176, },
+{ 0, 6, 14, 24, 36, 48, 62, 76, 91, 106, 122, 138, 155, 173, 191, 209, },
+{ 0, 7, 17, 29, 43, 58, 73, 90, 108, 126, 145, 165, 185, 206, 227, 249, },
+{ 0, 8, 20, 35, 51, 68, 87, 107, 128, 150, 172, 196, 220, 245, 270, 296, },
+{ 0, 10, 24, 41, 60, 81, 104, 127, 152, 178, 205, 233, 261, 291, 321, 352, },
+{ 0, 11, 29, 49, 72, 97, 123, 151, 181, 212, 244, 277, 311, 346, 382, 419, },
+{ 0, 13, 34, 58, 85, 115, 147, 180, 215, 252, 290, 329, 370, 411, 454, 498, },
+{ 0, 16, 40, 69, 102, 137, 174, 214, 256, 300, 345, 391, 440, 489, 540, 592, },
+{ 0, 19, 48, 82, 121, 163, 207, 255, 304, 356, 410, 465, 523, 582, 642, 704, },
+{ 0, 23, 57, 98, 144, 193, 247, 303, 362, 424, 487, 554, 622, 692, 763, 837, },
+{ 0, 27, 68, 116, 171, 230, 293, 360, 431, 504, 580, 658, 739, 823, 908, 995, },
+{ 0, 32, 81, 138, 203, 274, 349, 428, 512, 599, 689, 783, 879, 978, 1080, 1184, },
+{ 0, 38, 96, 165, 242, 325, 415, 510, 609, 712, 820, 931, 1045, 1163, 1284, 1408, },
+{ 0, 45, 114, 196, 287, 387, 493, 606, 724, 847, 975, 1107, 1243, 1383, 1527, 1674, },
+{ 0, 54, 136, 233, 342, 460, 587, 721, 861, 1008, 1159, 1317, 1479, 1645, 1816, 1991, },
+{ 0, 64, 161, 277, 406, 547, 698, 857, 1024, 1198, 1379, 1566, 1758, 1956, 2159, 2368, },
+{ 0, 76, 192, 329, 483, 651, 830, 1019, 1218, 1425, 1640, 1862, 2091, 2326, 2568, 2816, },
+{ 0, 91, 228, 392, 575, 774, 987, 1212, 1448, 1694, 1950, 2214, 2487, 2767, 3054, 3348, },
+{ 0, 108, 271, 466, 683, 920, 1174, 1441, 1722, 2015, 2319, 2633, 2957, 3290, 3632, 3982, },
+{ 0, 128, 323, 554, 813, 1094, 1396, 1714, 2048, 2396, 2758, 3131, 3517, 3913, 4319, 4735, },
+{ 0, 152, 384, 659, 967, 1301, 1660, 2038, 2435, 2850, 3279, 3724, 4182, 4653, 5136, 5631, },
+{ 0, 181, 456, 783, 1149, 1548, 1974, 2424, 2896, 3389, 3900, 4428, 4973, 5533, 6108, 6696, },
+{ 0, 215, 542, 931, 1367, 1841, 2347, 2883, 3444, 4030, 4638, 5266, 5914, 6580, 7264, 7964, },
+{ 0, 256, 645, 1108, 1625, 2189, 2791, 3428, 4096, 4793, 5515, 6263, 7033, 7825, 8638, 9470, },
+{ 0, 304, 767, 1317, 1933, 2603, 3319, 4077, 4871, 5699, 6559, 7448, 8364, 9306, 10272, 11262, },
+{ 0, 362, 912, 1566, 2299, 3095, 3947, 4848, 5793, 6778, 7800, 8857, 9946, 11067, 12216, 13393, },
+{ 0, 431, 1085, 1863, 2734, 3681, 4694, 5765, 6889, 8060, 9276, 10533, 11828, 13160, 14527, 15927, },
+{ 0, 512, 1290, 2215, 3251, 4378, 5582, 6856, 8192, 9585, 11031, 12525, 14066, 15650, 17276, 18941, },
+{ 0, 609, 1534, 2634, 3866, 5206, 6638, 8153, 9742, 11399, 13118, 14895, 16728, 18612, 20545, 22524, },
+{ 0, 724, 1825, 3133, 4598, 6191, 7894, 9696, 11585, 13555, 15600, 17714, 19893, 22133, 24432, 26786, },
+{ 0, 861, 2170, 3726, 5468, 7362, 9388, 11530, 13777, 16120, 18551, 21065, 23657, 26321, 29054, 31854, },
+{ 0, 1024, 2580, 4431, 6502, 8755, 11164, 13712, 16384, 19170, 22061, 25051, 28132, 31301, 34552, 37881, },
+{ 0, 1218, 3069, 5269, 7732, 10412, 13277, 16306, 19484, 22797, 26236, 29791, 33455, 37223, 41089, 45048, },
+{ 0, 1448, 3649, 6266, 9195, 12382, 15789, 19392, 23170, 27111, 31200, 35427, 39785, 44266, 48864, 53572, },
+{ 0, 1722, 4340, 7451, 10935, 14724, 18776, 23061, 27554, 32240, 37103, 42130, 47313, 52642, 58109, 63708, },
+{ 0, 2048, 5161, 8861, 13004, 17510, 22329, 27424, 32768, 38340, 44123, 50102, 56265, 62602, 69104, 75762, },
+{ 0, 2435, 6137, 10538, 15464, 20823, 26554, 32613, 38968, 45594, 52471, 59581, 66911, 74447, 82178, 90097, },
+{ 0, 2896, 7298, 12532, 18390, 24763, 31578, 38783, 46341, 54221, 62399, 70855, 79571, 88533, 97727, 107144, },
+{ 0, 3444, 8679, 14903, 21870, 29448, 37552, 46121, 55109, 64480, 74205, 84261, 94626, 105283, 116218, 127416, },
+{ 0, 4096, 10321, 17722, 26008, 35020, 44658, 54848, 65536, 76680, 88246, 100204, 112530, 125204, 138207, 151524, },
+{ 0, 4871, 12274, 21076, 30929, 41646, 53107, 65225, 77936, 91189, 104942, 119163, 133821, 148893, 164357, 180194, },
+{ 0, 5793, 14596, 25063, 36781, 49526, 63155, 77566, 92682, 108442, 124798, 141709, 159141, 177065, 195454, 214287, },
+{ 0, 6889, 17358, 29805, 43740, 58897, 75105, 92242, 110218, 128960, 148411, 168522, 189252, 210567, 232436, 254832, },
+{ 0, 8192, 20643, 35445, 52016, 70041, 89315, 109695, 131072, 153360, 176491, 200407, 225060, 250408, 276414, 303048, },
+{ 0, 9742, 24548, 42151, 61858, 83293, 106214, 130450, 155872, 182377, 209885, 238326, 267643, 297787, 328714, 360387, },
+{ 0, 11585, 29193, 50126, 73562, 99052, 126311, 155132, 185364, 216884, 249596, 283419, 318283, 354130, 390909, 428575, },
+{ 0, 13777, 34716, 59611, 87480, 117794, 150210, 184484, 220436, 257920, 296822, 337044, 378504, 421134, 464872, 509664, },
+{ 0, 16384, 41285, 70889, 104032, 140081, 178630, 219390, 262144, 306721, 352983, 400815, 450120, 500815, 552829, 606096, },
+{ 0, 19484, 49097, 84302, 123715, 166586, 212428, 260900, 311744, 364755, 419769, 476652, 535286, 595573, 657428, 720774, },
+{ 0, 23170, 58386, 100253, 147123, 198105, 252621, 310265, 370728, 433769, 499193, 566837, 636566, 708260, 781818, 857150, },
+{ 0, 27554, 69433, 119221, 174960, 235588, 300419, 368969, 440872, 515841, 593644, 674087, 757009, 842268, 929743, 1019328, },
+{ 0, 32768, 82570, 141779, 208064, 280162, 357260, 438781, 524288, 613442, 705965, 801629, 900240, 1001631, 1105658, 1212193, },
+{ 0, 38968, 98193, 168604, 247431, 333171, 424857, 521801, 623487, 729509, 839539, 953303, 1070572, 1191147, 1314856, 1441548, },
+{ 0, 46341, 116772, 200506, 294247, 396210, 505243, 620529, 741455, 867538, 998386, 1133675, 1273131, 1416520, 1563636, 1714299, },
+{ 0, 55109, 138866, 238443, 349920, 471175, 600838, 737938, 881744, 1031682, 1187287, 1348174, 1514017, 1684536, 1859487, 2038657, },
+{ 0, 65536, 165140, 283558, 416128, 560325, 714521, 877561, 1048576, 1226883, 1411930, 1603258, 1800480, 2003262, 2211315, 2424385, },
+{ 0, 77936, 196386, 337209, 494862, 666342, 849713, 1043602, 1246974, 1459018, 1679078, 1906606, 2141143, 2382293, 2629712, 2883096, },
+{ 0, 92682, 233544, 401011, 588493, 792419, 1010485, 1241059, 1482910, 1735075, 1996771, 2267350, 2546263, 2833040, 3127272, 3428598, },
+{ 0, 110218, 277732, 476885, 699841, 942350, 1201676, 1475876, 1763488, 2063364, 2374574, 2696348, 3028034, 3369072, 3718974, 4077314, },
+{ 0, 131072, 330281, 567116, 832255, 1120650, 1429042, 1755122, 2097152, 2453767, 2823861, 3206517, 3600960, 4006524, 4422630, 4848770, },
+{ 0, 155872, 392772, 674418, 989724, 1332685, 1699427, 2087204, 2493948, 2918037, 3358155, 3813212, 4282287, 4764587, 5259423, 5766192, },
+{ 0, 185364, 467088, 802023, 1176987, 1584838, 2020970, 2482117, 2965821, 3470150, 3993542, 4534699, 5092526, 5666080, 6254544, 6857197, },
+{ 0, 220436, 555464, 953771, 1399681, 1884701, 2403352, 2951752, 3526975, 4126727, 4749149, 5392697, 6056068, 6738143, 7437948, 8154627, },
+{ 0, 262144, 660561, 1134231, 1664511, 2241300, 2858084, 3510244, 4194304, 4907533, 5647721, 6413033, 7201919, 8013048, 8845261, 9697540, },
+{ 0, 311744, 785544, 1348836, 1979448, 2665370, 3398853, 4174407, 4987896, 5836074, 6716310, 7626425, 8564574, 9529173, 10518847, 11532384, },
+{ 0, 370728, 934175, 1604045, 2353974, 3169676, 4041941, 4964235, 5931642, 6940300, 7987084, 9069399, 10185052, 11332161, 12509088, 13714393, },
+{ 0, 440872, 1110928, 1907542, 2799362, 3769402, 4806704, 5903503, 7053950, 8253455, 9498297, 10785394, 12112136, 13476286, 14875896, 16309254, },
+{ 0, 524288, 1321123, 2268462, 3329021, 4482599, 5716167, 7020488, 8388608, 9815067, 11295443, 12826067, 14403839, 16026095, 17690521, 19395081, },
+{ 0, 623487, 1571089, 2697672, 3958896, 5330739, 6797707, 8348814, 9975792, 11672147, 13432621, 15252850, 17129147, 19058347, 21037694, 23064768, },
+{ 0, 741455, 1868350, 3208090, 4707947, 6339353, 8083881, 9928469, 11863283, 13880601, 15974168, 18138798, 20370104, 22664321, 25018175, 27428787, },
+{ 0, 881744, 2221855, 3815084, 5598724, 7538803, 9613409, 11807006, 14107901, 16506909, 18996594, 21570787, 24224272, 26952572, 29751792, 32618508, },
+{ 0, 1048576, 2642246, 4536925, 6658043, 8965199, 11432334, 14040976, 16777216, 19630134, 22590885, 25652134, 28807677, 32052191, 35381043, 38790162, },
+{ 0, 1246974, 3142178, 5395343, 7917792, 10661478, 13595413, 16697629, 19951585, 23344295, 26865241, 30505700, 34258295, 38116693, 42075388, 46129537, },
+{ 0, 1482910, 3736700, 6416181, 9415894, 12678706, 16167762, 19856939, 23726566, 27761201, 31948336, 36277595, 40740208, 45328643, 50036350, 54857573, },
+{ 0, 1763488, 4443710, 7630168, 11197448, 15077607, 19226818, 23614013, 28215802, 33013818, 37993189, 43141574, 48448545, 53905144, 59503584, 65237016, },
+{ 0, 2097152, 5284492, 9073850, 13316085, 17930397, 22864669, 28081952, 33554432, 39260268, 45181770, 51304267, 57615354, 64104381, 70762085, 77580324, },
+{ 0, 2493948, 6284355, 10790687, 15835583, 21322956, 27190826, 33395257, 39903169, 46688590, 53730483, 61011400, 68516589, 76233386, 84150775, 92259073, },
+{ 0, 2965821, 7473400, 12832361, 18831788, 25357411, 32335524, 39713878, 47453133, 55522403, 63896672, 72555191, 81480415, 90657285, 100072701, 109715146, },
+{ 0, 3526975, 8887421, 15260335, 22394897, 30155214, 38453636, 47228026, 56431603, 66027636, 75986377, 86283149, 96897090, 107810289, 119007168, 130474032, },
+{ 0, 4194304, 10568984, 18147699, 26632170, 35860795, 45729337, 56163904, 67108864, 78520535, 90363540, 102608534, 115230709, 128208762, 141524171, 155160648, },
+{ 0, 4987896, 12568711, 21581373, 31671166, 42645912, 54381653, 66790515, 79806339, 93377179, 107460965, 122022799, 137033179, 152466772, 168301551, 184518146, },
+{ 0, 5931642, 14946800, 25664723, 37663576, 50714822, 64671049, 79427755, 94906266, 111044806, 127793344, 145110381, 162960831, 181314570, 200145402, 219430292, },
+{ 0, 7053950, 17774841, 30520671, 44789793, 60310428, 76907271, 94456052, 112863206, 132055273, 151972754, 172566298, 193794180, 215620577, 238014336, 260948065, },
+{ 0, 8388608, 21137968, 36295399, 53264341, 71721590, 91458674, 112327809, 134217728, 157041070, 180727081, 205217069, 230461417, 256417525, 283048341, 310321295, },
+{ 0, 9975792, 25137421, 43162747, 63342333, 85291825, 108763306, 133581029, 159612677, 186754358, 214921930, 244045599, 274066357, 304933545, 336603102, 369036292, },
+{ 0, 11863283, 29893600, 51329445, 75327153, 101429645, 129342097, 158855511, 189812531, 222089611, 255586689, 290220762, 325921662, 362629141, 400290803, 438860584, },
+{ 0, 14107901, 35549682, 61041342, 89579586, 120620855, 153814542, 188912103, 225726413, 264110546, 303945509, 345132595, 387588359, 431241155, 476028671, 521896129, },
+{ 0, 16777216, 42275935, 72590798, 106528681, 143443179, 182917348, 224655618, 268435456, 314082140, 361454162, 410434138, 460922835, 512835049, 566096683, 620642590, },
+{ 0, 19951585, 50274843, 86325493, 126684666, 170583649, 217526612, 267162059, 319225354, 373508716, 429843861, 488091197, 548132714, 609867089, 673206203, 738072584, },
+{ 0, 23726566, 59787201, 102658891, 150654306, 202859289, 258684194, 317711021, 379625062, 444179223, 511173377, 580441524, 651843324, 725258282, 800581607, 877721168, },
+{ 0, 28215802, 71099365, 122082683, 179159172, 241241710, 307629085, 377824207, 451452825, 528221092, 607891017, 690265191, 775176719, 862482309, 952057343, 1043792258, },
+{ 0, 33554432, 84551870, 145181595, 213057363, 286886358, 365834696, 449311235, 536870912, 628164281, 722908323, 820868276, 921845669, 1025670099, 1132193366, 1241285180, },
+{ 0, 39903169, 100549686, 172650986, 253369332, 341167298, 435053224, 534324118, 638450708, 747017432, 859687721, 976182394, 1096265429, 1219734179, 1346412406, 1476145168, },
+{ 0, 47453133, 119574402, 205317781, 301308612, 405718579, 517368389, 635422042, 759250125, 888358445, 1022346755, 1160883049, 1303686648, 1450516564, 1601163213, 1755442337, },
+{ 0, 56431603, 142198729, 244165366, 358318345, 482483420, 615258169, 755648414, 902905651, 1056442184, 1215782035, 1380530381, 1550353437, 1724964618, 1904114686, 2087584517, },
+{ 0, 67108864, 169103741, 290363191, 426114725, 573772716, 731669392, 898622470, 1073741824, 1256328562, 1445816646, 1641736552, 1843691338, 2051340197, 2264386732, 2482570360, },
+{ 0, 79806339, 201099372, 345301972, 506738663, 682334597, 870106447, 1068648235, 1276901417, 1494034864, 1719375443, 1952364788, 2192530857, 2439468358, 2692824813, 2952290336, },
+{ 0, 94906266, 239148804, 410635562, 602617224, 811437157, 1034736778, 1270844085, 1518500250, 1776716890, 2044693510, 2321766097, 2607373295, 2901033128, 3202326427, 3510884673, },
+{ 0, 112863206, 284397459, 488330733, 716636690, 964966841, 1230516338, 1511296828, 1805811301, 2112884368, 2431564070, 2761060762, 3100706874, 3449929236, 3808229371, 4175169033, },
+{ 0, 134217728, 338207482, 580726382, 852229450, 1147545432, 1463338785, 1797244940, 2147483648, 2512657123, 2891633292, 3283473104, 3687382676, 4102680394, 233806168, 670173425, },
+{ 0, 159612677, 402198743, 690603945, 1013477326, 1364669193, 1740212895, 2137296470, 2553802834, 2988069728, 3438750885, 3904729577, 90094418, 583969419, 1090682330, 1609613376, },
+{ 0, 189812531, 478297607, 821271125, 1205234447, 1622874314, 2069473556, 2541688169, 3037000500, 3553433781, 4089387019, 348564899, 919779294, 1507098960, 2109685558, 2726802050, },
+{ 0, 225726413, 568794918, 976661465, 1433273380, 1929933681, 2461032677, 3022593655, 3611622603, 4225768735, 568160843, 1227154229, 1906446452, 2604891177, 3321491447, 4055370771, },
+{ 0, 268435456, 676414963, 1161452763, 1704458901, 2295090865, 2926677570, 3594489880, 0, 730346950, 1488299288, 2271978911, 3079798057, 3910393492, 467612336, 1340346849, },
+{ 0, 319225354, 804397487, 1381207890, 2026954652, 2729338386, 3480425789, 4274592941, 812638371, 1681172161, 2582534474, 3514491857, 180188837, 1167938839, 2181364659, 3219226752, },
+{ 0, 379625062, 956595215, 1642542250, 2410468894, 3245748628, 4138947112, 788409043, 1779033704, 2811900266, 3883806742, 697129798, 1839558589, 3014197919, 4219371115, 1158636805, },
+{ 0, 451452825, 1137589835, 1953322930, 2866546760, 3859867362, 627098058, 1750220014, 2928277910, 4156570174, 1136321687, 2454308458, 3812892905, 914815058, 2348015597, 3815774245, },
+{ 0, 536870912, 1352829926, 2322905526, 3408917802, 295214434, 1558387843, 2894012465, 0, 1460693900, 2976598577, 248990526, 1864628817, 3525819689, 935224672, 2680693699, },
+{ 0, 638450708, 1608794974, 2762415780, 4053909305, 1163709476, 2665884282, 4254218585, 1625276742, 3362344321, 870101652, 2734016419, 360377673, 2335877677, 67762022, 2143486208, },
+{ 0, 759250125, 1913190429, 3285084500, 525970492, 2196529960, 3982926927, 1576818085, 3558067408, 1328833236, 3472646189, 1394259595, 3679117178, 1733428542, 4143774935, 2317273609, },
+{ 0, 902905651, 2275179671, 3906645860, 1438126223, 3424767428, 1254196116, 3500440028, 1561588523, 4018173052, 2272643373, 613649619, 3330818513, 1829630115, 401063899, 3336581194, },
+{ 0, 1073741824, 2705659852, 350843757, 2522868308, 590428868, 3116775687, 1493057634, 0, 2921387800, 1658229858, 497981053, 3729257634, 2756672082, 1870449344, 1066420102, },
+{ 0, 1276901417, 3217589947, 1229864263, 3812851313, 2327418953, 1036801269, 4213469874, 3250553484, 2429721346, 1740203305, 1173065542, 720755347, 376788059, 135524045, 4286972417, },
+{ 0, 1518500250, 3826380858, 2275201703, 1051940985, 98092625, 3670886559, 3153636171, 2821167520, 2657666472, 2650325082, 2788519190, 3063267060, 3466857084, 3992582573, 339579923, },
+{ 0, 1805811301, 255392046, 3518324425, 2876252446, 2554567560, 2508392231, 2705912761, 3123177047, 3741378808, 250319450, 1227299238, 2366669730, 3659260231, 802127797, 2378195093, },
+{ 0, 2147483648, 1116352409, 701687514, 750769320, 1180857736, 1938584077, 2986115267, 0, 1547808304, 3316459715, 995962106, 3163547972, 1218376867, 3740898687, 2132840204, },
+{ 0, 2553802834, 2140212599, 2459728526, 3330735330, 359870610, 2073602537, 4131972453, 2206139673, 564475396, 3480406609, 2346131084, 1441510694, 753576118, 271048089, 4278977538, },
+{ 0, 3037000500, 3357794421, 255436110, 2103881970, 196185249, 3046805822, 2012305045, 1347367744, 1020365647, 1005682868, 1282071085, 1831566823, 2638746873, 3690197850, 679159846, },
+{ 0, 3611622603, 510784091, 2741681553, 1457537596, 814167825, 721817167, 1116858226, 1951386797, 3187790320, 500638901, 2454598477, 438372165, 3023553165, 1604255595, 461422890, },
+{ 0, 0, 2232704818, 1403375027, 1501538639, 2361715472, 3877168155, 1677263239, 0, 3095616609, 2337952135, 1991924211, 2032128649, 2436753734, 3186830079, 4265680408, },
+{ 0, 812638371, 4280425197, 624489756, 2366503364, 719741219, 4147205075, 3968977609, 117312050, 1128950792, 2665845922, 397294871, 2883021388, 1507152235, 542096179, 4262987779, },
+{ 0, 1779033704, 2420621546, 510872221, 4207763940, 392370498, 1798644347, 4024610091, 2694735487, 2040731295, 2011365736, 2564142170, 3663133646, 982526450, 3085428405, 1358319692, },
+{ 0, 2928277910, 1021568182, 1188395810, 2915075192, 1628335649, 1443634334, 2233716451, 3902773595, 2080613344, 1001277801, 614229658, 876744329, 1752139034, 3208511190, 922845779, },
+{ 0, 0, 170442339, 2806750055, 3003077279, 428463647, 3459369013, 3354526477, 0, 1896265921, 380936973, 3983848423, 4064257298, 578540172, 2078692862, 4236393519, },
+{ 0, 1625276742, 4265883098, 1248979512, 438039432, 1439482439, 3999442853, 3642987923, 234624099, 2257901584, 1036724548, 794589743, 1471075479, 3014304471, 1084192357, 4231008262, },
+{ 0, 3558067408, 546275796, 1021744441, 4120560584, 784740996, 3597288695, 3754252886, 1094503678, 4081462590, 4022731472, 833317044, 3031299997, 1965052899, 1875889514, 2716639383, },
+{ 0, 1561588523, 2043136365, 2376791621, 1535183089, 3256671299, 2887268668, 172465607, 3510579894, 4161226689, 2002555602, 1228459316, 1753488659, 3504278069, 2122055084, 1845691559, },
+{ 0, 0, 340884679, 1318532814, 1711187261, 856927294, 2623770730, 2414085658, 0, 3792531842, 761873946, 3672729550, 3833547299, 1157080345, 4157385723, 4177819743, },
+{ 0, 3250553484, 4236798900, 2497959024, 876078864, 2878964877, 3703918410, 2991008550, 469248199, 220835872, 2073449097, 1589179486, 2942150958, 1733641646, 2168384714, 4167049228, },
+{ 0, 2821167520, 1092551591, 2043488883, 3946153872, 1569481992, 2899610094, 3213538476, 2189007357, 3867957883, 3750495647, 1666634088, 1767632697, 3930105799, 3751779027, 1138311471, },
+{ 0, 3123177047, 4086272729, 458615945, 3070366178, 2218375301, 1479570039, 344931213, 2726192491, 4027486082, 4005111205, 2456918632, 3506977318, 2713588841, 4244110167, 3691383117, },
+{ 0, 0, 681769357, 2637065627, 3422374523, 1713854589, 952574165, 533204020, 0, 3290096388, 1523747892, 3050491804, 3372127302, 2314160690, 4019804150, 4060672190, },
+{ 0, 2206139673, 4178630505, 700950752, 1752157728, 1462962459, 3112869525, 1687049803, 938496398, 441671745, 4146898194, 3178358971, 1589334621, 3467283292, 41802132, 4039131161, },
+{ 0, 1347367744, 2185103183, 4086977765, 3597340447, 3138963984, 1504252891, 2132109656, 83047418, 3440948471, 3206023999, 3333268175, 3535265394, 3565244302, 3208590758, 2276622941, },
+{ 0, 1951386797, 3877578163, 917231891, 1845765060, 141783306, 2959140079, 689862426, 1157417687, 3760004867, 3715255113, 618869968, 2718987339, 1132210386, 4193253039, 3087798939, },
+{ 0, 0, 1363538715, 979163959, 2549781750, 3427709178, 1905148330, 1066408041, 0, 2285225480, 3047495785, 1806016311, 2449287308, 333354084, 3744641004, 3826377084, },
+{ 0, 117312050, 4062293714, 1401901505, 3504315456, 2925924917, 1930771754, 3374099606, 1876992795, 883343490, 3998829091, 2061750646, 3178669242, 2639599288, 83604264, 3783295025, },
+{ 0, 2694735487, 75239070, 3878988235, 2899713599, 1982960673, 3008505782, 4264219312, 166094836, 2586929645, 2117080702, 2371569055, 2775563492, 2835521307, 2122214220, 258278587, },
+{ 0, 3902773595, 3460189030, 1834463781, 3691530119, 283566612, 1623312862, 1379724852, 2314835373, 3225042438, 3135542931, 1237739936, 1143007383, 2264420772, 4091538781, 1880630581, },
+{ 0, 0, 2727077430, 1958327917, 804596203, 2560451060, 3810296660, 2132816081, 0, 275483665, 1800024274, 3612032623, 603607321, 666708168, 3194314712, 3357786872, },
+{ 0, 234624099, 3829620131, 2803803010, 2713663617, 1556882538, 3861543507, 2453231917, 3753985591, 1766686979, 3702690886, 4123501292, 2062371187, 984231280, 167208528, 3271622754, },
+{ 0, 1094503678, 150478139, 3463009174, 1504459901, 3965921345, 1722044268, 4233471328, 332189671, 878891994, 4234161403, 448170813, 1256159689, 1376075318, 4244428441, 516557173, },
+{ 0, 3510579894, 2625410764, 3668927563, 3088092943, 567133225, 3246625724, 2759449704, 334703450, 2155117580, 1976118565, 2475479871, 2286014766, 233874248, 3888110267, 3761261163, },
+{ 0, 0, 1159187564, 3916655835, 1609192407, 825934823, 3325626023, 4265632163, 0, 550967329, 3600048547, 2929097949, 1207214641, 1333416336, 2093662129, 2420606448, },
+{ 0, 469248199, 3364272966, 1312638724, 1132359937, 3113765076, 3428119718, 611496538, 3213003886, 3533373958, 3110414476, 3952035288, 4124742375, 1968462559, 334417056, 2248278213, },
+{ 0, 2189007357, 300956278, 2631051052, 3008919803, 3636875395, 3444088536, 4171975360, 664379343, 1757783988, 4173355510, 896341626, 2512319378, 2752150636, 4193889586, 1033114346, },
+{ 0, 2726192491, 955854232, 3042887830, 1881218590, 1134266450, 2198284151, 1223932112, 669406901, 15267865, 3952237130, 655992447, 277062236, 467748497, 3481253237, 3227555030, },
+{ 0, 0, 2318375127, 3538344374, 3218384814, 1651869647, 2356284750, 4236297029, 0, 1101934658, 2905129798, 1563228602, 2414429282, 2666832671, 4187324257, 546245599, },
+{ 0, 938496398, 2433578637, 2625277447, 2264719874, 1932562856, 2561272141, 1222993075, 2131040476, 2771780621, 1925861657, 3609103281, 3954517454, 3936925118, 668834112, 201589130, },
+{ 0, 83047418, 601912556, 967134807, 1722872310, 2978783493, 2593209776, 4048983423, 1328758686, 3515567976, 4051743725, 1792683252, 729671460, 1209333977, 4092811876, 2066228692, },
+{ 0, 1157417687, 1911708463, 1790808363, 3762437179, 2268532899, 101601007, 2447864224, 1338813802, 30535730, 3609506965, 1311984893, 554124472, 935496994, 2667539179, 2160142764, },
+{ 0, 0, 341782958, 2781721452, 2141802332, 3303739294, 417602205, 4177626763, 0, 2203869317, 1515292300, 3126457204, 533891268, 1038698046, 4079681219, 1092491199, },
+{ 0, 1876992795, 572189978, 955587598, 234472453, 3865125713, 827576986, 2445986150, 4262080951, 1248593946, 3851723313, 2923239265, 3614067612, 3578882941, 1337668225, 403178260, },
+{ 0, 166094836, 1203825112, 1934269615, 3445744619, 1662599691, 891452256, 3802999550, 2657517372, 2736168656, 3808520154, 3585366504, 1459342920, 2418667953, 3890656456, 4132457385, },
+{ 0, 2314835373, 3823416926, 3581616726, 3229907062, 242098502, 203202014, 600761152, 2677627604, 61071459, 2924046634, 2623969786, 1108248944, 1870993987, 1040111062, 25318232, },
+{ 0, 0, 683565917, 1268475608, 4283604663, 2312511291, 835204410, 4060286230, 0, 112771338, 3030584601, 1957947112, 1067782537, 2077396093, 3864395141, 2184982398, },
+{ 0, 3753985591, 1144379956, 1911175196, 468944906, 3435284129, 1655153971, 597005005, 4229194606, 2497187892, 3408479330, 1551511234, 2933167928, 2862798586, 2675336450, 806356520, },
+{ 0, 332189671, 2407650224, 3868539230, 2596521943, 3325199381, 1782904512, 3311031805, 1020067448, 1177370016, 3322073012, 2875765713, 2918685840, 542368611, 3486345616, 3969947473, },
+{ 0, 334703450, 3351866557, 2868266156, 2164846828, 484197005, 406404028, 1201522304, 1060287911, 122142918, 1553125972, 952972276, 2216497887, 3741987975, 2080222123, 50636463, },
+{ 0, 0, 1367131833, 2536951215, 4272242030, 330055286, 1670408820, 3825605163, 0, 225542676, 1766201906, 3915894224, 2135565074, 4154792185, 3433822986, 74997499, },
+{ 0, 3213003886, 2288759912, 3822350392, 937889811, 2575600962, 3310307942, 1194010010, 4163421916, 699408488, 2521991364, 3103022469, 1571368560, 1430629875, 1055705604, 1612713039, },
+{ 0, 664379343, 520333153, 3442111163, 898076590, 2355431466, 3565809025, 2327096313, 2040134895, 2354740033, 2349178728, 1456564129, 1542404383, 1084737222, 2677723935, 3644927650, },
+{ 0, 669406901, 2408765817, 1441565017, 34726361, 968394009, 812808055, 2403044609, 2120575823, 244285837, 3106251943, 1905944553, 138028478, 3189008653, 4160444246, 101272927, },
+{ 0, 0, 2734263667, 778935134, 4249516764, 660110572, 3340817639, 3356243030, 0, 451085351, 3532403811, 3536821153, 4271130147, 4014617074, 2572678677, 149994998, },
+{ 0, 2131040476, 282552528, 3349733489, 1875779623, 856234628, 2325648588, 2388020020, 4031876537, 1398816975, 749015433, 1911077641, 3142737120, 2861259750, 2111411208, 3225426079, },
+{ 0, 1328758686, 1040666305, 2589255031, 1796153179, 415895637, 2836650754, 359225330, 4080269790, 414512769, 403390160, 2913128258, 3084808766, 2169474444, 1060480574, 2994888004, },
+{ 0, 1338813802, 522564339, 2883130034, 69452721, 1936788018, 1625616111, 511121921, 4241151645, 488571674, 1917536590, 3811889105, 276056957, 2083050011, 4025921197, 202545854, },
+{ 0, 0, 1173560037, 1557870269, 4204066233, 1320221144, 2386667983, 2417518764, 0, 902170703, 2769840326, 2778675010, 4247292999, 3734266853, 850390057, 299989997, },
+{ 0, 4262080951, 565105055, 2404499682, 3751559245, 1712469256, 356329881, 481072744, 3768785777, 2797633950, 1498030866, 3822155283, 1990506944, 1427552205, 4222822415, 2155884862, },
+{ 0, 2657517372, 2081332610, 883542766, 3592306358, 831791274, 1378334211, 718450661, 3865572285, 829025538, 806780320, 1531289221, 1874650236, 43981591, 2120961148, 1694808712, },
+{ 0, 2677627604, 1045128678, 1471292771, 138905443, 3873576036, 3251232222, 1022243842, 4187335995, 977143347, 3835073180, 3328810914, 552113914, 4166100021, 3756875098, 405091707, },
+{ 0, 0, 2347120074, 3115740538, 4113165170, 2640442288, 478368670, 540070233, 0, 1804341405, 1244713356, 1262382724, 4199618702, 3173566409, 1700780114, 599979994, },
+{ 0, 4229194606, 1130210111, 514032068, 3208151194, 3424938512, 712659761, 962145487, 3242604258, 1300300605, 2996061732, 3349343269, 3981013887, 2855104410, 4150677534, 16802428, },
+{ 0, 1020067448, 4162665221, 1767085532, 2889645420, 1663582548, 2756668423, 1436901321, 3436177274, 1658051076, 1613560640, 3062578442, 3749300472, 87963182, 4241922296, 3389617424, },
+{ 0, 1060287911, 2090257355, 2942585542, 277810886, 3452184776, 2207497148, 2044487684, 4079704694, 1954286695, 3375179065, 2362654532, 1104227827, 4037232746, 3218782900, 810183414, },
+{ 0, 0, 399272852, 1936513780, 3931363044, 985917280, 956737340, 1080140465, 0, 3608682810, 2489426712, 2524765448, 4104270108, 2052165522, 3401560228, 1199959988, },
+{ 0, 4163421916, 2260420222, 1028064135, 2121335092, 2554909728, 1425319522, 1924290974, 2190241221, 2600601210, 1697156167, 2403719242, 3667060478, 1415241524, 4006387772, 33604855, },
+{ 0, 2040134895, 4030363145, 3534171063, 1484323544, 3327165096, 1218369549, 2873802642, 2577387251, 3316102153, 3227121279, 1830189587, 3203633649, 175926365, 4188877296, 2484267552, },
+{ 0, 2120575823, 4180514710, 1590203789, 555621772, 2609402257, 120027000, 4088975369, 3864442091, 3908573389, 2455390834, 430341769, 2208455654, 3779498196, 2142598504, 1620366828, },
+{ 0, 0, 798545705, 3873027559, 3567758792, 1971834561, 1913474680, 2160280930, 0, 2922398325, 683886128, 754563600, 3913572919, 4104331045, 2508153161, 2399919975, },
+{ 0, 4031876537, 225873147, 2056128270, 4242670184, 814852160, 2850639045, 3848581949, 85515146, 906235124, 3394312334, 512471189, 3039153661, 2830483048, 3717808248, 67209710, },
+{ 0, 4080269790, 3765758995, 2773374830, 2968647088, 2359362895, 2436739098, 1452637988, 859807206, 2337237010, 2159275262, 3660379174, 2112300002, 351852730, 4082787296, 673567809, },
+{ 0, 4241151645, 4066062124, 3180407577, 1111243543, 923837217, 240054000, 3882983442, 3433916886, 3522179482, 615814372, 860683538, 121944012, 3264029097, 4285197007, 3240733656, },
+};
diff --git a/libavcodec/mpc.c b/libavcodec/mpc.c
index ff010eb..441adee 100644
--- a/libavcodec/mpc.c
+++ b/libavcodec/mpc.c
@@ -25,7 +25,6 @@
  * divided into 32 subbands.
  */
 
-#include "libavutil/random.h"
 #include "avcodec.h"
 #include "bitstream.h"
 #include "dsputil.h"
diff --git a/libavcodec/mpc.h b/libavcodec/mpc.h
index df7915e..2720afe 100644
--- a/libavcodec/mpc.h
+++ b/libavcodec/mpc.h
@@ -28,7 +28,7 @@
 #ifndef AVCODEC_MPC_H
 #define AVCODEC_MPC_H
 
-#include "libavutil/random.h"
+#include "libavutil/lfg.h"
 #include "avcodec.h"
 #include "bitstream.h"
 #include "dsputil.h"
@@ -62,7 +62,7 @@
     int cur_frame, frames;
     uint8_t *bits;
     int buf_size;
-    AVRandomState rnd;
+    AVLFG rnd;
     int frames_to_skip;
     /* for synthesis */
     DECLARE_ALIGNED_16(MPA_INT, synth_buf[MPA_MAX_CHANNELS][512*2]);
diff --git a/libavcodec/mpc7.c b/libavcodec/mpc7.c
index 34f7693..b8735ac 100644
--- a/libavcodec/mpc7.c
+++ b/libavcodec/mpc7.c
@@ -25,7 +25,7 @@
  * divided into 32 subbands.
  */
 
-#include "libavutil/random.h"
+#include "libavutil/lfg.h"
 #include "avcodec.h"
 #include "bitstream.h"
 #include "dsputil.h"
@@ -53,7 +53,7 @@
         return -1;
     }
     memset(c->oldDSCF, 0, sizeof(c->oldDSCF));
-    av_random_init(&c->rnd, 0xDEADBEEF);
+    av_lfg_init(&c->rnd, 0xDEADBEEF);
     dsputil_init(&c->dsp, avctx);
     c->dsp.bswap_buf((uint32_t*)buf, (const uint32_t*)avctx->extradata, 4);
     ff_mpc_init();
@@ -118,7 +118,7 @@
     switch(idx){
     case -1:
         for(i = 0; i < SAMPLES_PER_BAND; i++){
-            *dst++ = (av_random(&c->rnd) & 0x3FC) - 510;
+            *dst++ = (av_lfg_get(&c->rnd) & 0x3FC) - 510;
         }
         break;
     case 1:
diff --git a/libavcodec/mpc8.c b/libavcodec/mpc8.c
index d235edd..ff7d5e5 100644
--- a/libavcodec/mpc8.c
+++ b/libavcodec/mpc8.c
@@ -25,7 +25,7 @@
  * divided into 32 subbands.
  */
 
-#include "libavutil/random.h"
+#include "libavutil/lfg.h"
 #include "avcodec.h"
 #include "bitstream.h"
 #include "dsputil.h"
@@ -100,7 +100,7 @@
         return -1;
     }
     memset(c->oldDSCF, 0, sizeof(c->oldDSCF));
-    av_random_init(&c->rnd, 0xDEADBEEF);
+    av_lfg_init(&c->rnd, 0xDEADBEEF);
     dsputil_init(&c->dsp, avctx);
 
     ff_mpc_init();
@@ -284,7 +284,7 @@
             switch(res){
             case -1:
                 for(j = 0; j < SAMPLES_PER_BAND; j++)
-                    c->Q[ch][off + j] = (av_random(&c->rnd) & 0x3FC) - 510;
+                    c->Q[ch][off + j] = (av_lfg_get(&c->rnd) & 0x3FC) - 510;
                 break;
             case 0:
                 break;
diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c
old mode 100644
new mode 100755
index 9e67ee5..b353b88
--- a/libavcodec/mpeg12.c
+++ b/libavcodec/mpeg12.c
@@ -2196,7 +2196,7 @@
  * Finds the end of the current frame in the bitstream.
  * @return the position of the first byte of the next frame, or -1
  */
-int ff_mpeg1_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size)
+int ff_mpeg1_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size, AVCodecParserContext *s)
 {
     int i;
     uint32_t state= pc->state;
@@ -2244,6 +2244,9 @@
                     return i-3;
                 }
             }
+            if(s && state == PICTURE_START_CODE){
+                ff_fetch_timestamp(s, i-4, 1);
+            }
         }
     }
     pc->state= state;
@@ -2276,7 +2279,7 @@
     }
 
     if(s2->flags&CODEC_FLAG_TRUNCATED){
-        int next= ff_mpeg1_find_frame_end(&s2->parse_context, buf, buf_size);
+        int next= ff_mpeg1_find_frame_end(&s2->parse_context, buf, buf_size, NULL);
 
         if( ff_combine_frame(&s2->parse_context, next, (const uint8_t **)&buf, &buf_size) < 0 )
             return buf_size;
diff --git a/libavcodec/mpeg12data.c b/libavcodec/mpeg12data.c
old mode 100644
new mode 100755
diff --git a/libavcodec/mpeg12data.h b/libavcodec/mpeg12data.h
old mode 100644
new mode 100755
diff --git a/libavcodec/mpeg12decdata.h b/libavcodec/mpeg12decdata.h
old mode 100644
new mode 100755
diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
old mode 100644
new mode 100755
diff --git a/libavcodec/mpeg4audio.c b/libavcodec/mpeg4audio.c
old mode 100644
new mode 100755
index ce5c723..9c7e02b
--- a/libavcodec/mpeg4audio.c
+++ b/libavcodec/mpeg4audio.c
@@ -61,9 +61,10 @@
         c->sbr = 1;
         c->ext_sample_rate = get_sample_rate(&gb, &c->ext_sampling_index);
         c->object_type = get_object_type(&gb);
-    } else
+    } else {
         c->ext_object_type = 0;
-
+        c->ext_sample_rate = 0;
+    }
     specific_config_bitindex = get_bits_count(&gb);
 
     if (c->ext_object_type != 5) {
diff --git a/libavcodec/mpeg4audio.h b/libavcodec/mpeg4audio.h
index 68ad310..70076e7 100644
--- a/libavcodec/mpeg4audio.h
+++ b/libavcodec/mpeg4audio.h
@@ -46,4 +46,47 @@
  */
 int ff_mpeg4audio_get_config(MPEG4AudioConfig *c, const uint8_t *buf, int buf_size);
 
+enum AudioObjectType {
+    AOT_NULL,
+                               // Support?                Name
+    AOT_AAC_MAIN,              ///< Y                       Main
+    AOT_AAC_LC,                ///< Y                       Low Complexity
+    AOT_AAC_SSR,               ///< N (code in SoC repo)    Scalable Sample Rate
+    AOT_AAC_LTP,               ///< N (code in SoC repo)    Long Term Prediction
+    AOT_SBR,                   ///< N (in progress)         Spectral Band Replication
+    AOT_AAC_SCALABLE,          ///< N                       Scalable
+    AOT_TWINVQ,                ///< N                       Twin Vector Quantizer
+    AOT_CELP,                  ///< N                       Code Excited Linear Prediction
+    AOT_HVXC,                  ///< N                       Harmonic Vector eXcitation Coding
+    AOT_TTSI             = 12, ///< N                       Text-To-Speech Interface
+    AOT_MAINSYNTH,             ///< N                       Main Synthesis
+    AOT_WAVESYNTH,             ///< N                       Wavetable Synthesis
+    AOT_MIDI,                  ///< N                       General MIDI
+    AOT_SAFX,                  ///< N                       Algorithmic Synthesis and Audio Effects
+    AOT_ER_AAC_LC,             ///< N                       Error Resilient Low Complexity
+    AOT_ER_AAC_LTP       = 19, ///< N                       Error Resilient Long Term Prediction
+    AOT_ER_AAC_SCALABLE,       ///< N                       Error Resilient Scalable
+    AOT_ER_TWINVQ,             ///< N                       Error Resilient Twin Vector Quantizer
+    AOT_ER_BSAC,               ///< N                       Error Resilient Bit-Sliced Arithmetic Coding
+    AOT_ER_AAC_LD,             ///< N                       Error Resilient Low Delay
+    AOT_ER_CELP,               ///< N                       Error Resilient Code Excited Linear Prediction
+    AOT_ER_HVXC,               ///< N                       Error Resilient Harmonic Vector eXcitation Coding
+    AOT_ER_HILN,               ///< N                       Error Resilient Harmonic and Individual Lines plus Noise
+    AOT_ER_PARAM,              ///< N                       Error Resilient Parametric
+    AOT_SSC,                   ///< N                       SinuSoidal Coding
+    AOT_PS,                    ///< N                       Parametric Stereo
+    AOT_SURROUND,              ///< N                       MPEG Surround
+    AOT_ESCAPE,                ///< N                       Escape Value
+    AOT_L1,                    ///< Y                       Layer 1
+    AOT_L2,                    ///< Y                       Layer 2
+    AOT_L3,                    ///< Y                       Layer 3
+    AOT_DST,                   ///< N                       Direct Stream Transfer
+    AOT_ALS,                   ///< N                       Audio LosslesS
+    AOT_SLS,                   ///< N                       Scalable LosslesS
+    AOT_SLS_NON_CORE,          ///< N                       Scalable LosslesS (non core)
+    AOT_ER_AAC_ELD,            ///< N                       Error Resilient Enhanced Low Delay
+    AOT_SMR_SIMPLE,            ///< N                       Symbolic Music Representation Simple
+    AOT_SMR_MAIN,              ///< N                       Symbolic Music Representation Main
+};
+
 #endif /* AVCODEC_MPEG4AUDIO_H */
diff --git a/libavcodec/mpeg4data.h b/libavcodec/mpeg4data.h
old mode 100644
new mode 100755
diff --git a/libavcodec/mpeg4video_parser.c b/libavcodec/mpeg4video_parser.c
old mode 100644
new mode 100755
diff --git a/libavcodec/mpegaudio.c b/libavcodec/mpegaudio.c
old mode 100644
new mode 100755
diff --git a/libavcodec/mpegaudio.h b/libavcodec/mpegaudio.h
old mode 100644
new mode 100755
diff --git a/libavcodec/mpegaudio_parser.c b/libavcodec/mpegaudio_parser.c
old mode 100644
new mode 100755
diff --git a/libavcodec/mpegaudiodata.c b/libavcodec/mpegaudiodata.c
old mode 100644
new mode 100755
diff --git a/libavcodec/mpegaudiodec.c b/libavcodec/mpegaudiodec.c
old mode 100644
new mode 100755
index e7bbd5d..822228e
--- a/libavcodec/mpegaudiodec.c
+++ b/libavcodec/mpegaudiodec.c
@@ -94,10 +94,14 @@
 static uint16_t band_index_long[9][23];
 /* XXX: free when all decoders are closed */
 #define TABLE_4_3_SIZE (8191 + 16)*4
+#ifdef EM8622
+#include "mp3table.h"
+#else
 static int8_t  table_4_3_exp[TABLE_4_3_SIZE];
 static uint32_t table_4_3_value[TABLE_4_3_SIZE];
 static uint32_t exp_table[512];
 static uint32_t expval_table[512][16];
+#endif
 /* intensity stereo coef table */
 static int32_t is_table[2][16];
 static int32_t is_table_lsf[2][2][16];
@@ -308,12 +312,29 @@
 }
 #endif
 
+#ifdef EM8622
+#include <sys/time.h>
+
+static long long inittime=0;
+
+static long long get_timebase()
+{
+  struct timeval tm;
+  gettimeofday(&tm, 0);
+  return tm.tv_sec * 1000000LL + (tm.tv_usec);
+}
+#endif
+
 static av_cold int decode_init(AVCodecContext * avctx)
 {
     MPADecodeContext *s = avctx->priv_data;
     static int init=0;
     int i, j, k;
 
+#ifdef EM8622
+    long long startinittime = get_timebase();
+#endif
+
     s->avctx = avctx;
 
     avctx->sample_fmt= OUT_FMT;
@@ -409,6 +430,7 @@
         /* compute n ^ (4/3) and store it in mantissa/exp format */
 
         int_pow_init();
+#ifndef EM8622
         for(i=1;i<TABLE_4_3_SIZE;i++) {
             double f, fm;
             int e, m;
@@ -428,6 +450,15 @@
             if((i&15)==1)
                 exp_table[exponent]= llrint(f);
         }
+#else
+		// Linking problem...
+		{
+			double f, fm;
+			int e, m;
+			f=1.0f;
+			fm = frexp(f, &e);
+		}
+#endif
 
         for(i=0;i<7;i++) {
             float f;
@@ -513,6 +544,10 @@
         }
 
         init = 1;
+#ifdef EM8622
+#undef fprintf
+	    fprintf(stderr,"mp3 init time %lld\n",get_timebase()-startinittime);
+#endif
     }
 
     if (avctx->codec_id == CODEC_ID_MP3ADU)
@@ -2273,7 +2308,7 @@
     if(ff_mpa_check_header(header) < 0){
         buf++;
 //        buf_size--;
-        av_log(avctx, AV_LOG_ERROR, "Header missing skipping one byte.\n");
+//        av_log(avctx, AV_LOG_ERROR, "Header missing skipping one byte.\n");
         goto retry;
     }
 
diff --git a/libavcodec/mpegaudiodecheader.c b/libavcodec/mpegaudiodecheader.c
old mode 100644
new mode 100755
diff --git a/libavcodec/mpegaudiodectab.h b/libavcodec/mpegaudiodectab.h
old mode 100644
new mode 100755
diff --git a/libavcodec/mpegaudioenc.c b/libavcodec/mpegaudioenc.c
old mode 100644
new mode 100755
diff --git a/libavcodec/mpegaudiotab.h b/libavcodec/mpegaudiotab.h
old mode 100644
new mode 100755
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 2af239b..6a7c7c0 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -165,6 +165,56 @@
 }
 
 /**
+ * Releases a frame buffer
+ */
+static void free_frame_buffer(MpegEncContext *s, Picture *pic)
+{
+    s->avctx->release_buffer(s->avctx, (AVFrame*)pic);
+    av_freep(&pic->hwaccel_picture_private);
+}
+
+/**
+ * Allocates a frame buffer
+ */
+static int alloc_frame_buffer(MpegEncContext *s, Picture *pic)
+{
+    int r;
+
+    if (s->avctx->hwaccel) {
+        assert(!pic->hwaccel_picture_private);
+        if (s->avctx->hwaccel->priv_data_size) {
+            pic->hwaccel_picture_private = av_mallocz(s->avctx->hwaccel->priv_data_size);
+            if (!pic->hwaccel_picture_private) {
+                av_log(s->avctx, AV_LOG_ERROR, "alloc_frame_buffer() failed (hwaccel private data allocation)\n");
+                return -1;
+            }
+        }
+    }
+
+    r = s->avctx->get_buffer(s->avctx, (AVFrame*)pic);
+
+    if (r<0 || !pic->age || !pic->type || !pic->data[0]) {
+        av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (%d %d %d %p)\n", r, pic->age, pic->type, pic->data[0]);
+        av_freep(&pic->hwaccel_picture_private);
+        return -1;
+    }
+
+    if (s->linesize && (s->linesize != pic->linesize[0] || s->uvlinesize != pic->linesize[1])) {
+        av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (stride changed)\n");
+        free_frame_buffer(s, pic);
+        return -1;
+    }
+
+    if (pic->linesize[1] != pic->linesize[2]) {
+        av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (uv stride mismatch)\n");
+        free_frame_buffer(s, pic);
+        return -1;
+    }
+
+    return 0;
+}
+
+/**
  * allocates a Picture
  * The pixels are allocated/set by calling get_buffer() if shared=0
  */
@@ -183,24 +233,8 @@
     }else{
         assert(!pic->data[0]);
 
-        r= s->avctx->get_buffer(s->avctx, (AVFrame*)pic);
-
-        if(r<0 || !pic->age || !pic->type || !pic->data[0]){
-            av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (%d %d %d %p)\n", r, pic->age, pic->type, pic->data[0]);
+        if (alloc_frame_buffer(s, pic) < 0)
             return -1;
-        }
-
-        if(s->linesize && (s->linesize != pic->linesize[0] || s->uvlinesize != pic->linesize[1])){
-            av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (stride changed)\n");
-            s->avctx->release_buffer(s->avctx, (AVFrame*)pic);
-            return -1;
-        }
-
-        if(pic->linesize[1] != pic->linesize[2]){
-            av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (uv stride mismatch)\n");
-            s->avctx->release_buffer(s->avctx, (AVFrame*)pic);
-            return -1;
-        }
 
         s->linesize  = pic->linesize[0];
         s->uvlinesize= pic->linesize[1];
@@ -249,7 +283,7 @@
     return 0;
 fail: //for the CHECKED_ALLOCZ macro
     if(r>=0)
-        s->avctx->release_buffer(s->avctx, (AVFrame*)pic);
+        free_frame_buffer(s, pic);
     return -1;
 }
 
@@ -260,7 +294,7 @@
     int i;
 
     if(pic->data[0] && pic->type!=FF_BUFFER_TYPE_SHARED){
-        s->avctx->release_buffer(s->avctx, (AVFrame*)pic);
+        free_frame_buffer(s, pic);
     }
 
     av_freep(&pic->mb_var);
@@ -839,7 +873,7 @@
     /* mark&release old frames */
     if (s->pict_type != FF_B_TYPE && s->last_picture_ptr && s->last_picture_ptr != s->next_picture_ptr && s->last_picture_ptr->data[0]) {
       if(s->out_format != FMT_H264 || s->codec_id == CODEC_ID_SVQ3){
-        avctx->release_buffer(avctx, (AVFrame*)s->last_picture_ptr);
+          free_frame_buffer(s, s->last_picture_ptr);
 
         /* release forgotten pictures */
         /* if(mpeg124/h263) */
@@ -847,7 +881,7 @@
             for(i=0; i<MAX_PICTURE_COUNT; i++){
                 if(s->picture[i].data[0] && &s->picture[i] != s->next_picture_ptr && s->picture[i].reference){
                     av_log(avctx, AV_LOG_ERROR, "releasing zombie picture\n");
-                    avctx->release_buffer(avctx, (AVFrame*)&s->picture[i]);
+                    free_frame_buffer(s, &s->picture[i]);
                 }
             }
         }
@@ -858,7 +892,7 @@
         /* release non reference frames */
         for(i=0; i<MAX_PICTURE_COUNT; i++){
             if(s->picture[i].data[0] && !s->picture[i].reference /*&& s->picture[i].type!=FF_BUFFER_TYPE_SHARED*/){
-                s->avctx->release_buffer(s->avctx, (AVFrame*)&s->picture[i]);
+                free_frame_buffer(s, &s->picture[i]);
             }
         }
 
@@ -885,6 +919,7 @@
         s->current_picture_ptr= (Picture*)pic;
         s->current_picture_ptr->top_field_first= s->top_field_first; //FIXME use only the vars from current_pic
         s->current_picture_ptr->interlaced_frame= !s->progressive_frame && !s->progressive_sequence;
+        avctx->interlaced = s->current_picture_ptr->interlaced_frame;
     }
 
     s->current_picture_ptr->pict_type= s->pict_type;
@@ -931,6 +966,33 @@
     s->hurry_up= s->avctx->hurry_up;
     s->error_recognition= avctx->error_recognition;
 
+	/* Update the MPEG encoding bitrate in case it's being dynamically adjusted */
+	if (s->encoding && s->bit_rate != avctx->bit_rate)
+	{
+		// Not sure if we want to set the max rate now or along w/ the bitrate
+		if (s->current_picture_ptr->key_frame)
+		{
+			int old_rate = avctx->bit_rate;
+			// Scale the initial complexity to match the new bitrate
+	//		avctx->rc_initial_cplx = avctx->rc_initial_cplx * avctx->bit_rate / s->bit_rate;
+			avctx->rc_max_rate = avctx->bit_rate;
+			s->bit_rate = avctx->bit_rate;
+#ifndef EM8622
+	 	    if(ff_rate_control_init(s, old_rate) < 0)
+#endif
+			        return -1;
+		}
+/*		else if (avctx->bit_rate > 4*s->bit_rate/3) // More than 33% increases in bitrate can handle a new keyframe on the bitrate increase
+		{
+			s->pict_type = I_TYPE;
+			// Scale the initial complexity to match the new bitrate
+			avctx->rc_initial_cplx = avctx->rc_initial_cplx * avctx->bit_rate / s->bit_rate;
+			s->bit_rate = avctx->bit_rate;
+		    if(ff_rate_control_init(s, 1) < 0)
+		        return -1;
+		}*/
+	}
+
     /* set dequantizer, we can't do it during init as it might change for mpeg4
        and we can't do it in the header decode as init is not called for mpeg4 there yet */
     if(s->mpeg_quant || s->codec_id == CODEC_ID_MPEG2VIDEO){
@@ -996,7 +1058,7 @@
         /* release non-reference frames */
         for(i=0; i<MAX_PICTURE_COUNT; i++){
             if(s->picture[i].data[0] && !s->picture[i].reference /*&& s->picture[i].type!=FF_BUFFER_TYPE_SHARED*/){
-                s->avctx->release_buffer(s->avctx, (AVFrame*)&s->picture[i]);
+                free_frame_buffer(s, &s->picture[i]);
             }
         }
     }
@@ -1096,8 +1158,7 @@
  */
 void ff_print_debug_info(MpegEncContext *s, AVFrame *pict){
 
-    if(s->avctx->hwaccel) return;
-    if(!pict || !pict->mb_type) return;
+    if(s->avctx->hwaccel || !pict || !pict->mb_type) return;
 
     if(s->avctx->debug&(FF_DEBUG_SKIP | FF_DEBUG_QP | FF_DEBUG_MB_TYPE)){
         int x,y;
@@ -2069,7 +2130,7 @@
     for(i=0; i<MAX_PICTURE_COUNT; i++){
        if(s->picture[i].data[0] && (   s->picture[i].type == FF_BUFFER_TYPE_INTERNAL
                                     || s->picture[i].type == FF_BUFFER_TYPE_USER))
-        avctx->release_buffer(avctx, (AVFrame*)&s->picture[i]);
+        free_frame_buffer(s, &s->picture[i]);
     }
     s->current_picture_ptr = s->last_picture_ptr = s->next_picture_ptr = NULL;
 
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
old mode 100644
new mode 100755
index 5620f1e..ef40083
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -769,7 +769,7 @@
 void ff_mpeg1_encode_init(MpegEncContext *s);
 void ff_mpeg1_encode_slice_header(MpegEncContext *s);
 void ff_mpeg1_clean_buffers(MpegEncContext *s);
-int ff_mpeg1_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size);
+int ff_mpeg1_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size, AVCodecParserContext *s);
 
 extern const uint8_t ff_mpeg4_y_dc_scale_table[32];
 extern const uint8_t ff_mpeg4_c_dc_scale_table[32];
diff --git a/libavcodec/mpegvideo_common.h b/libavcodec/mpegvideo_common.h
old mode 100644
new mode 100755
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 2500a41..0de2e57 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -709,7 +709,7 @@
                        s->inter_matrix, s->inter_quant_bias, avctx->qmin, 31, 0);
     }
 
-    if(ff_rate_control_init(s) < 0)
+    if(ff_rate_control_init(s, 0) < 0)
         return -1;
 
     return 0;
@@ -840,10 +840,11 @@
                 int w= s->width >>h_shift;
                 int h= s->height>>v_shift;
                 uint8_t *src= pic_arg->data[i];
-                uint8_t *dst= pic->data[i];
+                uint8_t *dst= pic->data[i] + INPLACE_OFFSET;
 
-                if(!s->avctx->rc_buffer_size)
-                    dst +=INPLACE_OFFSET;
+// NARFLEX: Disable this block and add above instead like they used to, it's causing FFMPEG to crash on placeshifter transcoding
+//                if(!s->avctx->rc_buffer_size)
+//                    dst +=INPLACE_OFFSET;
 
                 if(src_stride==dst_stride)
                     memcpy(dst, src, src_stride*h);
@@ -1141,7 +1142,8 @@
 
         ff_copy_picture(&s->new_picture, s->reordered_input_picture[0]);
 
-        if(s->reordered_input_picture[0]->type == FF_BUFFER_TYPE_SHARED || s->avctx->rc_buffer_size){
+		// NARFLEX: Disable this secondary if block, it's causing FFMPEG to crash on placeshifter transcoding
+        if(s->reordered_input_picture[0]->type == FF_BUFFER_TYPE_SHARED/* || s->avctx->rc_buffer_size*/){
             // input is a shared pix, so we can't modifiy it -> alloc a new one & ensure that the shared one is reuseable
 
             int i= ff_find_unused_picture(s, 0);
@@ -1229,7 +1231,8 @@
         if (CONFIG_MJPEG_ENCODER && s->out_format == FMT_MJPEG)
             ff_mjpeg_encode_picture_trailer(s);
 
-        if(avctx->rc_buffer_size){
+// NARFLEX: Disable this block, it's causing FFMPEG to crash on placeshifter transcoding
+/*        if(avctx->rc_buffer_size){
             RateControlContext *rcc= &s->rc_context;
             int max_size= rcc->buffer_index * avctx->rc_max_available_vbv_use;
 
@@ -1258,7 +1261,7 @@
             }
 
             assert(s->avctx->rc_max_rate);
-        }
+        }*/
 
         if(s->flags&CODEC_FLAG_PASS1)
             ff_write_pass1_stats(s);
@@ -1320,6 +1323,8 @@
         }
         s->total_bits += s->frame_bits;
         avctx->frame_bits  = s->frame_bits;
+// This can be used to get stats on the size of each video frame encoded
+//av_log(s->avctx, AV_LOG_QUIET, "%c frame bytes=%d\n", av_get_pict_type_char(s->pict_type), (int)s->frame_bits);
     }else{
         assert((pbBufPtr(&s->pb) == s->pb.buf));
         s->frame_bits=0;
@@ -2651,12 +2656,16 @@
     flush_put_bits(&dst->pb);
 }
 
+// NARFLEX: Doing dynamic adjustment of q based on bitrate has turned out to give pretty poor
+// results. It's better to count on buffering to smooth out higher frequency changes in the stream and
+// just use the overall rate as the target like we've been doing. That should be the most visually
+// pleasing as well.
 static int estimate_qp(MpegEncContext *s, int dry_run){
-    if (s->next_lambda){
+/*    if (s->next_lambda){
         s->current_picture_ptr->quality=
         s->current_picture.quality = s->next_lambda;
         if(!dry_run) s->next_lambda= 0;
-    } else if (!s->fixed_qscale) {
+    } else */ if (!s->fixed_qscale) {
         s->current_picture_ptr->quality=
         s->current_picture.quality = ff_rate_estimate_qscale(s, dry_run);
         if (s->current_picture.quality < 0)
diff --git a/libavcodec/mpegvideo_parser.c b/libavcodec/mpegvideo_parser.c
old mode 100644
new mode 100755
index 2ccb9ff..215c86c
--- a/libavcodec/mpegvideo_parser.c
+++ b/libavcodec/mpegvideo_parser.c
@@ -29,7 +29,6 @@
 {
     ParseContext1 *pc = s->priv_data;
     const uint8_t *buf_end;
-    const uint8_t *buf_start= buf;
     uint32_t start_code;
     int frame_rate_index, ext_type, bytes_left;
     int frame_rate_ext_n, frame_rate_ext_d;
@@ -44,8 +43,6 @@
         bytes_left = buf_end - buf;
         switch(start_code) {
         case PICTURE_START_CODE:
-            ff_fetch_timestamp(s, buf-buf_start-4, 1);
-
             if (bytes_left >= 2) {
                 s->pict_type = (buf[1] >> 3) & 7;
             }
@@ -137,7 +134,7 @@
     if(s->flags & PARSER_FLAG_COMPLETE_FRAMES){
         next= buf_size;
     }else{
-        next= ff_mpeg1_find_frame_end(pc, buf, buf_size);
+        next= ff_mpeg1_find_frame_end(pc, buf, buf_size, s);
 
         if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) {
             *poutbuf = NULL;
diff --git a/libavcodec/msmpeg4.c b/libavcodec/msmpeg4.c
old mode 100644
new mode 100755
diff --git a/libavcodec/msmpeg4data.c b/libavcodec/msmpeg4data.c
old mode 100644
new mode 100755
diff --git a/libavcodec/msmpeg4data.h b/libavcodec/msmpeg4data.h
old mode 100644
new mode 100755
diff --git a/libavcodec/msrle.c b/libavcodec/msrle.c
old mode 100644
new mode 100755
diff --git a/libavcodec/msvideo1.c b/libavcodec/msvideo1.c
old mode 100644
new mode 100755
diff --git a/libavcodec/nellymoser.c b/libavcodec/nellymoser.c
index d867e9e..00c2cfd 100644
--- a/libavcodec/nellymoser.c
+++ b/libavcodec/nellymoser.c
@@ -32,7 +32,6 @@
  */
 
 #include "nellymoser.h"
-#include "libavutil/random.h"
 #include "avcodec.h"
 #include "dsputil.h"
 
diff --git a/libavcodec/nellymoserdec.c b/libavcodec/nellymoserdec.c
index ec35369..d1f561e 100644
--- a/libavcodec/nellymoserdec.c
+++ b/libavcodec/nellymoserdec.c
@@ -32,7 +32,8 @@
  */
 
 #include "nellymoser.h"
-#include "libavutil/random.h"
+#include "libavutil/lfg.h"
+#include "libavutil/random_seed.h"
 #include "avcodec.h"
 #include "dsputil.h"
 
@@ -44,7 +45,7 @@
     AVCodecContext* avctx;
     DECLARE_ALIGNED_16(float,float_buf[NELLY_SAMPLES]);
     float           state[128];
-    AVRandomState   random_state;
+    AVLFG           random_state;
     GetBitContext   gb;
     int             add_bias;
     float           scale_bias;
@@ -107,7 +108,7 @@
         for (j = 0; j < NELLY_FILL_LEN; j++) {
             if (bits[j] <= 0) {
                 aptr[j] = M_SQRT1_2*pows[j];
-                if (av_random(&s->random_state) & 1)
+                if (av_lfg_get(&s->random_state) & 1)
                     aptr[j] *= -1.0;
             } else {
                 v = get_bits(&s->gb, bits[j]);
@@ -128,7 +129,7 @@
     NellyMoserDecodeContext *s = avctx->priv_data;
 
     s->avctx = avctx;
-    av_random_init(&s->random_state, 0);
+    av_lfg_init(&s->random_state, ff_random_get_seed());
     ff_mdct_init(&s->imdct_ctx, 8, 1);
 
     dsputil_init(&s->dsp, avctx);
diff --git a/libavcodec/noise_bsf.c b/libavcodec/noise_bsf.c
old mode 100644
new mode 100755
diff --git a/libavcodec/nuv.c b/libavcodec/nuv.c
old mode 100644
new mode 100755
diff --git a/libavcodec/oggivorbis.c b/libavcodec/oggivorbis.c
new file mode 100755
index 0000000..f8feb9a
--- /dev/null
+++ b/libavcodec/oggivorbis.c
@@ -0,0 +1,216 @@
+/*
+ * copyright (c) 2002 Mark Hills <mark@pogo.org.uk>
+ *
+ * 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 St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+/**
+ * @file oggvorbis.c
+ * Ogg Vorbis codec support via libvorbisenc.
+ * @author Mark Hills <mark@pogo.org.uk>
+ */
+
+#include <ivorbiscodec.h>
+
+#include "avcodec.h"
+
+#undef NDEBUG
+#include <assert.h>
+
+#define OGGVORBIS_FRAME_SIZE 64
+
+#define BUFFER_SIZE (1024*64)
+
+typedef struct OggVorbisContext {
+    vorbis_info vi ;
+    vorbis_dsp_state vd ;
+    vorbis_block vb ;
+    uint8_t buffer[BUFFER_SIZE];
+    int buffer_index;
+
+    /* decoder */
+    vorbis_comment vc ;
+    ogg_packet op;
+} OggVorbisContext ;
+
+
+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] = *p++ << 8;
+            hsizes[i] += *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->frame_size  = FFMIN(vorbis_info_blocksize(&context->vi, 0), 
+        vorbis_info_blocksize(&context->vi, 1))>>2;
+    avccontext->sample_fmt = SAMPLE_FMT_S16;
+    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, ogg_int32_t **pcm, char *buf, int channels) {
+    int i, j, val ;
+    ogg_int16_t *ptr, *data = (ogg_int16_t*)buf ;
+    ogg_int32_t *mono ;
+
+    for(i = 0 ; i < channels ; i++){
+        ptr = &data[i];
+        mono = pcm[i] ;
+
+        for(j = 0 ; j < samples ; j++) {
+
+            val = mono[j]>>9; // * 32767.f;
+
+            if(val > 32767) val = 32767 ;
+            if(val < -32768) val = -32768 ;
+
+            *ptr = val ;
+            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 ;
+    ogg_int32_t **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; i<op->bytes; 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 oggivorbis_decoder = {
+    "vorbis",
+    CODEC_TYPE_AUDIO,
+    CODEC_ID_VORBIS,
+    sizeof(OggVorbisContext),
+    oggvorbis_decode_init,
+    NULL,
+    oggvorbis_decode_close,
+    oggvorbis_decode_frame,
+    .capabilities= CODEC_CAP_DELAY,
+} ;
diff --git a/libavcodec/opt.c b/libavcodec/opt.c
old mode 100644
new mode 100755
diff --git a/libavcodec/opt.h b/libavcodec/opt.h
old mode 100644
new mode 100755
diff --git a/libavcodec/options.c b/libavcodec/options.c
index 1ab7818..3a941a0 100644
--- a/libavcodec/options.c
+++ b/libavcodec/options.c
@@ -122,7 +122,6 @@
 {"b_qfactor", "qp factor between p and b frames", OFFSET(b_quant_factor), FF_OPT_TYPE_FLOAT, 1.25, -FLT_MAX, FLT_MAX, V|E},
 {"rc_strategy", "ratecontrol method", OFFSET(rc_strategy), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
 {"b_strategy", "strategy to choose between I/P/B-frames", OFFSET(b_frame_strategy), FF_OPT_TYPE_INT, 0, INT_MIN, INT_MAX, V|E},
-{"wpredp", "weighted prediction analysis method", OFFSET(weighted_p_pred), FF_OPT_TYPE_INT, 0, INT_MIN, INT_MAX, V|E},
 {"hurry_up", NULL, OFFSET(hurry_up), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|D},
 {"ps", "rtp payload size in bits", OFFSET(rtp_payload_size), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
 {"mv_bits", NULL, OFFSET(mv_bits), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
@@ -383,13 +382,12 @@
 {"prediction_order_method", "search method for selecting prediction order", OFFSET(prediction_order_method), FF_OPT_TYPE_INT, -1, INT_MIN, INT_MAX, A|E},
 {"min_partition_order", NULL, OFFSET(min_partition_order), FF_OPT_TYPE_INT, -1, INT_MIN, INT_MAX, A|E},
 {"max_partition_order", NULL, OFFSET(max_partition_order), FF_OPT_TYPE_INT, -1, INT_MIN, INT_MAX, A|E},
-{"timecode_frame_start", "GOP timecode frame start number, in non drop frame format", OFFSET(timecode_frame_start), FF_OPT_TYPE_INT, 0, 0, INT_MAX, V|E},
+{"timecode_frame_start", "GOP timecode frame start number, in non drop frame format", OFFSET(timecode_frame_start), FF_OPT_TYPE_INT64, 0, 0, INT64_MAX, V|E},
 {"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},
 {"reservoir", "use bit reservoir", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_BIT_RESERVOIR, INT_MIN, INT_MAX, A|E, "flags2"},
-{"mbtree", "use macroblock tree ratecontrol (x264 only)", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_MBTREE, INT_MIN, INT_MAX, V|E, "flags2"},
 {"bits_per_raw_sample", NULL, OFFSET(bits_per_raw_sample), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX},
 {"channel_layout", NULL, OFFSET(channel_layout), FF_OPT_TYPE_INT64, DEFAULT, 0, INT64_MAX, A|E|D, "channel_layout"},
 {"request_channel_layout", NULL, OFFSET(request_channel_layout), FF_OPT_TYPE_INT64, DEFAULT, 0, INT64_MAX, A|D, "request_channel_layout"},
diff --git a/libavcodec/os2thread.c b/libavcodec/os2thread.c
old mode 100644
new mode 100755
diff --git a/libavcodec/parser.c b/libavcodec/parser.c
old mode 100644
new mode 100755
index d738a62..7f2eaf7
--- a/libavcodec/parser.c
+++ b/libavcodec/parser.c
@@ -78,6 +78,7 @@
     s->dts_sync_point       = INT_MIN;
     s->dts_ref_dts_delta    = INT_MIN;
     s->pts_dts_delta        = INT_MIN;
+	s->field_frame_flag     = 0;
     return s;
 }
 
@@ -85,17 +86,21 @@
     int i;
 
     s->dts= s->pts= AV_NOPTS_VALUE;
+    s->pos= -1;
     s->offset= 0;
     for(i = 0; i < AV_PARSER_PTS_NB; i++) {
-        if (   s->next_frame_offset + off >= s->cur_frame_offset[i]
+        if (   s->cur_offset + off >= s->cur_frame_offset[i]
             &&(s->     frame_offset       <  s->cur_frame_offset[i] || !s->frame_offset)
             //check is disabled  becausue mpeg-ts doesnt send complete PES packets
             && /*s->next_frame_offset + off <*/  s->cur_frame_end[i]){
             s->dts= s->cur_frame_dts[i];
             s->pts= s->cur_frame_pts[i];
+            s->pos= s->cur_frame_pos[i];
             s->offset = s->next_frame_offset - s->cur_frame_offset[i];
             if(remove)
                 s->cur_frame_offset[i]= INT64_MAX;
+            if(s->cur_offset + off < s->cur_frame_end[i])
+                break;
         }
     }
 }
@@ -123,6 +128,8 @@
  *          decode_frame(data, size);
  *   }
  * @endcode
+ *
+ * @deprecated Use av_parser_parse2() instead.
  */
 int av_parser_parse(AVCodecParserContext *s,
                     AVCodecContext *avctx,
@@ -130,6 +137,16 @@
                     const uint8_t *buf, int buf_size,
                     int64_t pts, int64_t dts)
 {
+    return av_parser_parse2(s, avctx, poutbuf, poutbuf_size, buf, buf_size, pts, dts, AV_NOPTS_VALUE);
+}
+
+int av_parser_parse2(AVCodecParserContext *s,
+                     AVCodecContext *avctx,
+                     uint8_t **poutbuf, int *poutbuf_size,
+                     const uint8_t *buf, int buf_size,
+                     int64_t pts, int64_t dts,
+                     int64_t pos)
+{
     int index, i;
     uint8_t dummy_buf[FF_INPUT_BUFFER_PADDING_SIZE];
 
@@ -139,20 +156,20 @@
         buf = dummy_buf;
     } else {
         /* add a new packet descriptor */
-        if(pts != AV_NOPTS_VALUE || dts != AV_NOPTS_VALUE){
             i = (s->cur_frame_start_index + 1) & (AV_PARSER_PTS_NB - 1);
             s->cur_frame_start_index = i;
             s->cur_frame_offset[i] = s->cur_offset;
             s->cur_frame_end[i] = s->cur_offset + buf_size;
             s->cur_frame_pts[i] = pts;
             s->cur_frame_dts[i] = dts;
-        }
+            s->cur_frame_pos[i] = pos;
     }
 
     if (s->fetch_timestamp){
         s->fetch_timestamp=0;
         s->last_pts = s->pts;
         s->last_dts = s->dts;
+        s->last_pos = s->pos;
         ff_fetch_timestamp(s, 0, 0);
     }
 
diff --git a/libavcodec/pcm.c b/libavcodec/pcm.c
old mode 100644
new mode 100755
index e8d6a79..40b56fc
--- a/libavcodec/pcm.c
+++ b/libavcodec/pcm.c
@@ -571,3 +571,4 @@
 PCM_CODEC  (CODEC_ID_PCM_U32BE, SAMPLE_FMT_S32, pcm_u32be, "PCM unsigned 32-bit big-endian");
 PCM_CODEC  (CODEC_ID_PCM_U32LE, SAMPLE_FMT_S32, pcm_u32le, "PCM unsigned 32-bit little-endian");
 PCM_CODEC  (CODEC_ID_PCM_ZORK,  SAMPLE_FMT_S16, pcm_zork, "PCM Zork");
+PCM_CODEC  (CODEC_ID_PCM_BD,   SAMPLE_FMT_S32, pcm_bd, "PCM signed 20|24-bit big-endian");
diff --git a/libavcodec/pcx.c b/libavcodec/pcx.c
old mode 100644
new mode 100755
diff --git a/libavcodec/pcxenc.c b/libavcodec/pcxenc.c
new file mode 100644
index 0000000..36f7d1d
--- /dev/null
+++ b/libavcodec/pcxenc.c
@@ -0,0 +1,206 @@
+/*
+ * PC Paintbrush PCX (.pcx) image encoder
+ * Copyright (c) 2009 Daniel Verkamp <daniel at drv.nu>
+ *
+ * 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
+ */
+
+/**
+ * PCX image encoder
+ * @file libavcodec/pcxenc.c
+ * @author Daniel Verkamp
+ * @sa http://www.qzx.com/pc-gpe/pcx.txt
+ */
+
+#include "avcodec.h"
+#include "bytestream.h"
+
+typedef struct PCXContext {
+    AVFrame picture;
+} PCXContext;
+
+static const uint32_t monoblack_pal[] = { 0x000000, 0xFFFFFF };
+
+static av_cold int pcx_encode_init(AVCodecContext *avctx)
+{
+    PCXContext *s = avctx->priv_data;
+
+    avcodec_get_frame_defaults(&s->picture);
+    avctx->coded_frame = &s->picture;
+
+    return 0;
+}
+
+/**
+ * PCX run-length encoder
+ * @param dst output buffer
+ * @param dst_size size of output buffer
+ * @param src input buffer
+ * @param src_plane_size size of one plane of input buffer in bytes
+ * @param nplanes number of planes in input buffer
+ * @return number of bytes written to dst or -1 on error
+ * @bug will not work for nplanes != 1 && bpp != 8
+ */
+static int pcx_rle_encode(      uint8_t *dst, int dst_size,
+                          const uint8_t *src, int src_plane_size, int nplanes)
+{
+    int p;
+    const uint8_t *dst_start = dst;
+
+    // check worst-case upper bound on dst_size
+    if (dst_size < 2LL * src_plane_size * nplanes || src_plane_size <= 0)
+        return -1;
+
+    for (p = 0; p < nplanes; p++) {
+        int count = 1;
+        const uint8_t *src_plane = src + p;
+        const uint8_t *src_plane_end = src_plane + src_plane_size * nplanes;
+        uint8_t prev = *src_plane;
+        src_plane += nplanes;
+
+        for (; ; src_plane += nplanes) {
+            if (src_plane < src_plane_end && *src_plane == prev && count < 0x3F) {
+                // current byte is same as prev
+                ++count;
+            } else {
+                // output prev * count
+                if (count != 1 || prev >= 0xC0)
+                    *dst++ = 0xC0 | count;
+                *dst++ = prev;
+
+                if (src_plane == src_plane_end)
+                    break;
+
+                // start new run
+                count = 1;
+                prev = *src_plane;
+            }
+        }
+    }
+
+    return dst - dst_start;
+}
+
+static int pcx_encode_frame(AVCodecContext *avctx,
+                            unsigned char *buf, int buf_size, void *data)
+{
+    PCXContext *s = avctx->priv_data;
+    AVFrame *const pict = &s->picture;
+    const uint8_t *buf_start = buf;
+    const uint8_t *buf_end   = buf + buf_size;
+
+    int bpp, nplanes, i, y, line_bytes, written;
+    const uint32_t *pal = NULL;
+    const uint8_t *src;
+
+    *pict = *(AVFrame *)data;
+    pict->pict_type = FF_I_TYPE;
+    pict->key_frame = 1;
+
+    if (avctx->width > 65535 || avctx->height > 65535) {
+        av_log(avctx, AV_LOG_ERROR, "image dimensions do not fit in 16 bits\n");
+        return -1;
+    }
+
+    switch (avctx->pix_fmt) {
+    case PIX_FMT_RGB24:
+        bpp = 8;
+        nplanes = 3;
+        break;
+    case PIX_FMT_RGB8:
+    case PIX_FMT_BGR8:
+    case PIX_FMT_RGB4_BYTE:
+    case PIX_FMT_BGR4_BYTE:
+    case PIX_FMT_GRAY8:
+    case PIX_FMT_PAL8:
+        bpp = 8;
+        nplanes = 1;
+        pal = (uint32_t *)pict->data[1];
+        break;
+    case PIX_FMT_MONOBLACK:
+        bpp = 1;
+        nplanes = 1;
+        pal = monoblack_pal;
+        break;
+    default:
+        av_log(avctx, AV_LOG_ERROR, "unsupported pixfmt\n");
+        return -1;
+    }
+
+    line_bytes = (avctx->width * bpp + 7) >> 3;
+    line_bytes = (line_bytes + 1) & ~1;
+
+    bytestream_put_byte(&buf, 10);                  // manufacturer
+    bytestream_put_byte(&buf, 5);                   // version
+    bytestream_put_byte(&buf, 1);                   // encoding
+    bytestream_put_byte(&buf, bpp);                 // bits per pixel per plane
+    bytestream_put_le16(&buf, 0);                   // x min
+    bytestream_put_le16(&buf, 0);                   // y min
+    bytestream_put_le16(&buf, avctx->width - 1);    // x max
+    bytestream_put_le16(&buf, avctx->height - 1);   // y max
+    bytestream_put_le16(&buf, 0);                   // horizontal DPI
+    bytestream_put_le16(&buf, 0);                   // vertical DPI
+    for (i = 0; i < 16; i++)
+        bytestream_put_be24(&buf, pal ? pal[i] : 0);// palette (<= 16 color only)
+    bytestream_put_byte(&buf, 0);                   // reserved
+    bytestream_put_byte(&buf, nplanes);             // number of planes
+    bytestream_put_le16(&buf, line_bytes);          // scanline plane size in bytes
+
+    while (buf - buf_start < 128)
+        *buf++= 0;
+
+    src = pict->data[0];
+
+    for (y = 0; y < avctx->height; y++) {
+        if ((written = pcx_rle_encode(buf, buf_end - buf,
+                                      src, line_bytes, nplanes)) < 0) {
+            av_log(avctx, AV_LOG_ERROR, "buffer too small\n");
+            return -1;
+        }
+        buf += written;
+        src += pict->linesize[0];
+    }
+
+    if (nplanes == 1 && bpp == 8) {
+        if (buf_end - buf < 257) {
+            av_log(avctx, AV_LOG_ERROR, "buffer too small\n");
+            return -1;
+        }
+        bytestream_put_byte(&buf, 12);
+        for (i = 0; i < 256; i++) {
+            bytestream_put_be24(&buf, pal[i]);
+        }
+    }
+
+    return buf - buf_start;
+}
+
+AVCodec pcx_encoder = {
+    "pcx",
+    CODEC_TYPE_VIDEO,
+    CODEC_ID_PCX,
+    sizeof(PCXContext),
+    pcx_encode_init,
+    pcx_encode_frame,
+    NULL,
+    .pix_fmts = (enum PixelFormat[]){
+        PIX_FMT_RGB24,
+        PIX_FMT_RGB8, PIX_FMT_BGR8, PIX_FMT_RGB4_BYTE, PIX_FMT_BGR4_BYTE, PIX_FMT_GRAY8, PIX_FMT_PAL8,
+        PIX_FMT_MONOBLACK,
+        PIX_FMT_NONE},
+    .long_name = NULL_IF_CONFIG_SMALL("PC Paintbrush PCX image"),
+};
diff --git a/libavcodec/pgssubdec.c b/libavcodec/pgssubdec.c
new file mode 100644
index 0000000..68a71e6
--- /dev/null
+++ b/libavcodec/pgssubdec.c
@@ -0,0 +1,462 @@
+/*
+ * PGS subtitle decoder
+ * Copyright (c) 2009 Stephen Backway
+ *
+ * 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
+ * PGS subtitle decoder
+ */
+
+#include "avcodec.h"
+#include "dsputil.h"
+#include "bytestream.h"
+#include "libavutil/colorspace.h"
+
+//#define DEBUG_PACKET_CONTENTS
+
+#define RGBA(r,g,b,a) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
+
+enum SegmentType {
+    PALETTE_SEGMENT      = 0x14,
+    PICTURE_SEGMENT      = 0x15,
+    PRESENTATION_SEGMENT = 0x16,
+    WINDOW_SEGMENT       = 0x17,
+    DISPLAY_SEGMENT      = 0x80,
+};
+
+typedef struct PGSSubPresentation {
+    int x;
+    int y;
+    int video_w;
+    int video_h;
+    int id_number;
+} PGSSubPresentation;
+
+typedef struct PGSSubPicture {
+    int          w;
+    int          h;
+    uint8_t      *rle;
+    unsigned int rle_buffer_size, rle_data_len;
+} PGSSubPicture;
+
+typedef struct PGSSubContext {
+    PGSSubPresentation presentation;
+    uint32_t           clut[256];
+    PGSSubPicture      picture;
+} PGSSubContext;
+
+static av_cold int init_decoder(AVCodecContext *avctx)
+{
+    avctx->pix_fmt     = PIX_FMT_RGB32;
+
+    return 0;
+}
+
+static av_cold int close_decoder(AVCodecContext *avctx)
+{
+    PGSSubContext *ctx = avctx->priv_data;
+
+    av_freep(&ctx->picture.rle);
+    ctx->picture.rle_buffer_size  = 0;
+
+    return 0;
+}
+
+/**
+ * Decode the RLE data.
+ *
+ * The subtitle is stored as an Run Length Encoded image.
+ *
+ * @param avctx contains the current codec context
+ * @param sub pointer to the processed subtitle data
+ * @param buf pointer to the RLE data to process
+ * @param buf_size size of the RLE data to process
+ */
+static int decode_rle(AVCodecContext *avctx, AVSubtitle *sub,
+                      const uint8_t *buf, unsigned int buf_size)
+{
+    const uint8_t *rle_bitmap_end;
+    int pixel_count, line_count;
+
+    rle_bitmap_end = buf + buf_size;
+
+    sub->rects[0]->pict.data[0] = av_malloc(sub->rects[0]->w * sub->rects[0]->h);
+
+    if (!sub->rects[0]->pict.data[0])
+        return -1;
+
+    pixel_count = 0;
+    line_count  = 0;
+
+    while (buf < rle_bitmap_end && line_count < sub->rects[0]->h) {
+        uint8_t flags, color;
+        int run;
+
+        color = bytestream_get_byte(&buf);
+        run   = 1;
+
+        if (color == 0x00) {
+            flags = bytestream_get_byte(&buf);
+            run   = flags & 0x3f;
+            if (flags & 0x40)
+                run = (run << 8) + bytestream_get_byte(&buf);
+            color = flags & 0x80 ? bytestream_get_byte(&buf) : 0;
+        }
+
+        if (run > 0 && pixel_count + run <= sub->rects[0]->w * sub->rects[0]->h) {
+            memset(sub->rects[0]->pict.data[0] + pixel_count, color, run);
+            pixel_count += run;
+        } else if (!run) {
+            /*
+             * New Line. Check if correct pixels decoded, if not display warning
+             * and adjust bitmap pointer to correct new line position.
+             */
+            if (pixel_count % sub->rects[0]->w > 0)
+                av_log(avctx, AV_LOG_ERROR, "Decoded %d pixels, when line should be %d pixels\n",
+                       pixel_count % sub->rects[0]->w, sub->rects[0]->w);
+            line_count++;
+        }
+    }
+
+    dprintf(avctx, "Pixel Count = %d, Area = %d\n", pixel_count, sub->rects[0]->w * sub->rects[0]->h);
+
+    return 0;
+}
+
+/**
+ * Parse the picture segment packet.
+ *
+ * The picture segment contains details on the sequence id,
+ * width, height and Run Length Encoded (RLE) bitmap data.
+ *
+ * @param avctx contains the current codec context
+ * @param buf pointer to the packet to process
+ * @param buf_size size of packet to process
+ * @todo TODO: Enable support for RLE data over multiple packets
+ */
+static int parse_picture_segment(AVCodecContext *avctx,
+                                  const uint8_t *buf, int buf_size)
+{
+    PGSSubContext *ctx = avctx->priv_data;
+
+    uint8_t sequence_desc;
+    unsigned int rle_bitmap_len, width, height;
+
+    /* skip 3 unknown bytes: Object ID (2 bytes), Version Number */
+    buf += 3;
+
+    /* Read the Sequence Description to determine if start of RLE data or appended to previous RLE */
+    sequence_desc = bytestream_get_byte(&buf);
+
+    if (!(sequence_desc & 0x80)) {
+        av_log(avctx, AV_LOG_ERROR, "Decoder does not support object data over multiple packets.\n");
+        return -1;
+    }
+
+    /* Decode rle bitmap length */
+    rle_bitmap_len = bytestream_get_be24(&buf);
+
+    /* Check to ensure we have enough data for rle_bitmap_length if just a single packet */
+    if (rle_bitmap_len > buf_size - 7) {
+        av_log(avctx, AV_LOG_ERROR, "Not enough RLE data for specified length of %d.\n", rle_bitmap_len);
+        return -1;
+    }
+
+    ctx->picture.rle_data_len = rle_bitmap_len;
+
+    /* Get bitmap dimensions from data */
+    width  = bytestream_get_be16(&buf);
+    height = bytestream_get_be16(&buf);
+
+    /* Make sure the bitmap is not too large */
+    if (ctx->presentation.video_w < width || ctx->presentation.video_h < height) {
+        av_log(avctx, AV_LOG_ERROR, "Bitmap dimensions larger then video.\n");
+        return -1;
+    }
+
+    ctx->picture.w = width;
+    ctx->picture.h = height;
+
+    av_fast_malloc(&ctx->picture.rle, &ctx->picture.rle_buffer_size, rle_bitmap_len);
+
+    if (!ctx->picture.rle)
+        return -1;
+
+    memcpy(ctx->picture.rle, buf, rle_bitmap_len);
+
+    return 0;
+}
+
+/**
+ * Parse the palette segment packet.
+ *
+ * The palette segment contains details of the palette,
+ * a maximum of 256 colors can be defined.
+ *
+ * @param avctx contains the current codec context
+ * @param buf pointer to the packet to process
+ * @param buf_size size of packet to process
+ */
+static void parse_palette_segment(AVCodecContext *avctx,
+                                  const uint8_t *buf, int buf_size)
+{
+    PGSSubContext *ctx = avctx->priv_data;
+
+    const uint8_t *buf_end = buf + buf_size;
+    const uint8_t *cm      = ff_cropTbl + MAX_NEG_CROP;
+    int color_id;
+    int y, cb, cr, alpha;
+    int r, g, b, r_add, g_add, b_add;
+
+    /* Skip two null bytes */
+    buf += 2;
+
+    while (buf < buf_end) {
+        color_id  = bytestream_get_byte(&buf);
+        y         = bytestream_get_byte(&buf);
+        cb        = bytestream_get_byte(&buf);
+        cr        = bytestream_get_byte(&buf);
+        alpha     = bytestream_get_byte(&buf);
+
+        YUV_TO_RGB1(cb, cr);
+        YUV_TO_RGB2(r, g, b, y);
+
+        dprintf(avctx, "Color %d := (%d,%d,%d,%d)\n", color_id, r, g, b, alpha);
+
+        /* Store color in palette */
+        ctx->clut[color_id] = RGBA(r,g,b,alpha);
+    }
+}
+
+/**
+ * Parse the presentation segment packet.
+ *
+ * The presentation segment contains details on the video
+ * width, video height, x & y subtitle position.
+ *
+ * @param avctx contains the current codec context
+ * @param buf pointer to the packet to process
+ * @param buf_size size of packet to process
+ * @todo TODO: Implement cropping
+ * @todo TODO: Implement forcing of subtitles
+ * @todo TODO: Blanking of subtitle
+ */
+static void parse_presentation_segment(AVCodecContext *avctx,
+                                       const uint8_t *buf, int buf_size)
+{
+    PGSSubContext *ctx = avctx->priv_data;
+
+    int x, y;
+    uint8_t block;
+
+    ctx->presentation.video_w = bytestream_get_be16(&buf);
+    ctx->presentation.video_h = bytestream_get_be16(&buf);
+
+    dprintf(avctx, "Video Dimensions %dx%d\n",
+            ctx->presentation.video_w, ctx->presentation.video_h);
+
+    /* Skip 1 bytes of unknown, frame rate? */
+    buf++;
+
+    ctx->presentation.id_number = bytestream_get_be16(&buf);
+
+    /* Next byte is the state. */
+    block = bytestream_get_byte(&buf);;
+    if (block == 0x80) {
+        /*
+         * Skip 7 bytes of unknown:
+         *     palette_update_flag (0x80),
+         *     palette_id_to_use,
+         *     Object Number (if > 0 determines if more data to process),
+         *     object_id_ref (2 bytes),
+         *     window_id_ref,
+         *     composition_flag (0x80 - object cropped, 0x40 - object forced)
+         */
+        buf += 7;
+
+        x = bytestream_get_be16(&buf);
+        y = bytestream_get_be16(&buf);
+
+        /* TODO If cropping, cropping_x, cropping_y, cropping_width, cropping_height (all 2 bytes).*/
+
+        dprintf(avctx, "Subtitle Placement x=%d, y=%d\n", x, y);
+
+        if (x > ctx->presentation.video_w || y > ctx->presentation.video_h) {
+            av_log(avctx, AV_LOG_ERROR, "Subtitle out of video bounds. x = %d, y = %d, video width = %d, video height = %d.\n",
+                   x, y, ctx->presentation.video_w, ctx->presentation.video_h);
+            x = 0; y = 0;
+        }
+
+        /* Fill in dimensions */
+        ctx->presentation.x = x;
+        ctx->presentation.y = y;
+    } else if (block == 0x00) {
+        /* TODO: Blank context as subtitle should not be displayed.
+         *       If the subtitle is blanked now the subtitle is not
+         *       on screen long enough to read, due to a delay in
+         *       initial display timing.
+         */
+    }
+}
+
+/**
+ * Parse the display segment packet.
+ *
+ * The display segment controls the updating of the display.
+ *
+ * @param avctx contains the current codec context
+ * @param data pointer to the data pertaining the subtitle to display
+ * @param buf pointer to the packet to process
+ * @param buf_size size of packet to process
+ * @todo TODO: Fix start time, relies on correct PTS, currently too late
+ *
+ * @todo TODO: Fix end time, normally cleared by a second display
+ * @todo       segment, which is currently ignored as it clears
+ * @todo       the subtitle too early.
+ */
+static int display_end_segment(AVCodecContext *avctx, void *data,
+                               const uint8_t *buf, int buf_size)
+{
+    AVSubtitle    *sub = data;
+    PGSSubContext *ctx = avctx->priv_data;
+
+    /*
+     *      The end display time is a timeout value and is only reached
+     *      if the next subtitle is later then timeout or subtitle has
+     *      not been cleared by a subsequent empty display command.
+     */
+
+    memset(sub, 0, sizeof(*sub));
+    sub->start_display_time = 0;
+    sub->end_display_time   = 20000;
+    sub->format             = 0;
+
+    sub->rects     = av_mallocz(sizeof(*sub->rects));
+    sub->rects[0]  = av_mallocz(sizeof(*sub->rects[0]));
+    sub->num_rects = 1;
+
+    sub->rects[0]->x    = ctx->presentation.x;
+    sub->rects[0]->y    = ctx->presentation.y;
+    sub->rects[0]->w    = ctx->picture.w;
+    sub->rects[0]->h    = ctx->picture.h;
+    sub->rects[0]->type = SUBTITLE_BITMAP;
+
+    /* Process bitmap */
+    sub->rects[0]->pict.linesize[0] = ctx->picture.w;
+
+    if (ctx->picture.rle)
+        if(decode_rle(avctx, sub, ctx->picture.rle, ctx->picture.rle_data_len) < 0)
+            return 0;
+
+    /* Allocate memory for colors */
+    sub->rects[0]->nb_colors    = 256;
+    sub->rects[0]->pict.data[1] = av_mallocz(AVPALETTE_SIZE);
+
+    memcpy(sub->rects[0]->pict.data[1], ctx->clut, sub->rects[0]->nb_colors * sizeof(uint32_t));
+
+    return 1;
+}
+
+static int decode(AVCodecContext *avctx, void *data, int *data_size,
+                         const uint8_t *buf, int buf_size)
+{
+    const uint8_t *buf_end;
+    uint8_t       segment_type;
+    int           segment_length;
+
+#ifdef DEBUG_PACKET_CONTENTS
+    int i;
+
+    av_log(avctx, AV_LOG_INFO, "PGS sub packet:\n");
+
+    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 & 15)
+        av_log(avctx, AV_LOG_INFO, "\n");
+#endif
+
+    *data_size = 0;
+
+    /* Ensure that we have received at a least a segment code and segment length */
+    if (buf_size < 3)
+        return -1;
+
+    buf_end = buf + buf_size;
+
+    /* Step through buffer to identify segments */
+    while (buf < buf_end) {
+        segment_type   = bytestream_get_byte(&buf);
+        segment_length = bytestream_get_be16(&buf);
+
+        dprintf(avctx, "Segment Length %d, Segment Type %x\n", segment_length, segment_type);
+
+        if (segment_type != DISPLAY_SEGMENT && segment_length > buf_end - buf)
+            break;
+
+        switch (segment_type) {
+        case PALETTE_SEGMENT:
+            parse_palette_segment(avctx, buf, segment_length);
+            break;
+        case PICTURE_SEGMENT:
+            parse_picture_segment(avctx, buf, segment_length);
+            break;
+        case PRESENTATION_SEGMENT:
+            parse_presentation_segment(avctx, buf, segment_length);
+            break;
+        case WINDOW_SEGMENT:
+            /*
+             * Window Segment Structure (No new information provided):
+             *     2 bytes: Unkown,
+             *     2 bytes: X position of subtitle,
+             *     2 bytes: Y position of subtitle,
+             *     2 bytes: Width of subtitle,
+             *     2 bytes: Height of subtitle.
+             */
+            break;
+        case DISPLAY_SEGMENT:
+            *data_size = display_end_segment(avctx, data, buf, segment_length);
+            break;
+        default:
+            av_log(avctx, AV_LOG_ERROR, "Unknown subtitle segment type 0x%x, length %d\n",
+                   segment_type, segment_length);
+            break;
+        }
+
+        buf += segment_length;
+    }
+
+    return buf_size;
+}
+
+AVCodec pgssub_decoder = {
+    "pgssub",
+    CODEC_TYPE_SUBTITLE,
+    CODEC_ID_HDMV_PGS_SUBTITLE,
+    sizeof(PGSSubContext),
+    init_decoder,
+    NULL,
+    close_decoder,
+    decode,
+    .long_name = NULL_IF_CONFIG_SMALL("HDMV Presentation Graphic Stream subtitles"),
+};
diff --git a/libavcodec/pixdesc.c b/libavcodec/pixdesc.c
index aac9cba..7cfc007 100644
--- a/libavcodec/pixdesc.c
+++ b/libavcodec/pixdesc.c
@@ -22,8 +22,9 @@
 #include "libavutil/pixfmt.h"
 #include "pixdesc.h"
 
-static const AVPixFmtDescriptor pix_fmt_desc[PIX_FMT_NB] = {
+const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB] = {
     [PIX_FMT_YUV422P] = {
+        .name = "yuv422p",
         .nb_channels  = 3,
         .log2_chroma_w= 1,
         .log2_chroma_h= 0,
@@ -34,6 +35,7 @@
         },
     },
     [PIX_FMT_YUV420P] = {
+        .name = "yuv420p",
         .nb_channels  = 3,
         .log2_chroma_w= 1,
         .log2_chroma_h= 1,
@@ -44,6 +46,7 @@
         },
     },
     [PIX_FMT_YUV410P] = {
+        .name = "yuv410p",
         .nb_channels  = 3,
         .log2_chroma_w= 2,
         .log2_chroma_h= 2,
@@ -54,6 +57,7 @@
         },
     },
     [PIX_FMT_NV12] = {
+        .name = "nv12",
         .nb_channels  = 3,
         .log2_chroma_w= 1,
         .log2_chroma_h= 1,
@@ -64,6 +68,7 @@
         },
     },
     [PIX_FMT_YUYV422] = {
+        .name = "yuyv422",
         .nb_channels  = 3,
         .log2_chroma_w= 1,
         .log2_chroma_h= 0,
@@ -74,6 +79,7 @@
         },
     },
     [PIX_FMT_UYVY422] = {
+        .name = "uyvy422",
         .nb_channels  = 3,
         .log2_chroma_w= 1,
         .log2_chroma_h= 0,
@@ -84,6 +90,7 @@
         },
     },
     [PIX_FMT_GRAY16LE] = {
+        .name = "gray16le",
         .nb_channels  = 1,
         .log2_chroma_w= 0,
         .log2_chroma_h= 0,
@@ -92,6 +99,7 @@
         },
     },
     [PIX_FMT_GRAY16BE] = {
+        .name = "gray16be",
         .nb_channels  = 1,
         .log2_chroma_w= 0,
         .log2_chroma_h= 0,
@@ -101,6 +109,7 @@
         .flags = PIX_FMT_BE,
     },
     [PIX_FMT_RGB24] = {
+        .name = "rgb24",
         .nb_channels  = 3,
         .log2_chroma_w= 0,
         .log2_chroma_h= 0,
@@ -111,6 +120,7 @@
         },
     },
     [PIX_FMT_RGBA] = {
+        .name = "rgba",
         .nb_channels  = 4,
         .log2_chroma_w= 0,
         .log2_chroma_h= 0,
@@ -122,6 +132,7 @@
         },
     },
     [PIX_FMT_RGB48LE] = {
+        .name = "rgb48le",
         .nb_channels  = 3,
         .log2_chroma_w= 0,
         .log2_chroma_h= 0,
@@ -132,6 +143,7 @@
         },
     },
     [PIX_FMT_RGB48BE] = {
+        .name = "rgb48be",
         .nb_channels  = 3,
         .log2_chroma_w= 0,
         .log2_chroma_h= 0,
@@ -142,9 +154,8 @@
         },
         .flags = PIX_FMT_BE,
     },
-//FIXME change pix fmt defines so that we have a LE & BE instead of a native-endian
-#if 0
-    [PIX_FMT_RGB565_LE] = {
+    [PIX_FMT_RGB565LE] = {
+        .name = "rgb565le",
         .nb_channels  = 3,
         .log2_chroma_w= 0,
         .log2_chroma_h= 0,
@@ -154,7 +165,8 @@
             {0,1,2,3,4},
         },
     },
-    [PIX_FMT_RGB565_BE] = {
+    [PIX_FMT_RGB565BE] = {
+        .name = "rgb565be",
         .nb_channels  = 3,
         .log2_chroma_w= 0,
         .log2_chroma_h= 0,
@@ -165,8 +177,8 @@
         },
         .flags = PIX_FMT_BE,
     },
-#endif
     [PIX_FMT_MONOBLACK] = {
+        .name = "monoblack",
         .nb_channels  = 1,
         .log2_chroma_w= 0,
         .log2_chroma_h= 0,
@@ -176,6 +188,7 @@
         .flags = PIX_FMT_BITSTREAM,
     },
     [PIX_FMT_PAL8] = {
+        .name = "pal8",
         .nb_channels  = 1,
         .log2_chroma_w= 0,
         .log2_chroma_h= 0,
diff --git a/libavcodec/pixdesc.h b/libavcodec/pixdesc.h
index 8db4923..f21d6f0 100644
--- a/libavcodec/pixdesc.h
+++ b/libavcodec/pixdesc.h
@@ -27,7 +27,7 @@
     uint16_t plane        :2;            ///< which of the 4 planes contains the component
     uint16_t step_minus1  :3;            ///< number of bytes between 2 horizontally consecutive pixels minus 1
     uint16_t offset_plus1 :3;            ///< number of bytes before the component of the first pixel plus 1
-    uint16_t shift        :3;            ///< number of lsb that must be shifted away to get the value
+    uint16_t shift        :3;            ///< number of least significant bits that must be shifted away to get the value
     uint16_t depth_minus1 :4;            ///< number of bits in the component minus 1
 }AVComponentDescriptor;
 
@@ -41,6 +41,7 @@
  *       are stored not what these values represent.
  */
 typedef struct AVPixFmtDescriptor{
+    const char *name;
     uint8_t nb_channels;        ///< The number of components each pixel has, (1-4)
 
     /**
@@ -63,9 +64,13 @@
 }AVPixFmtDescriptor;
 
 #define PIX_FMT_BE        1 ///< big-endian
-#define PIX_FMT_PAL       2 ///< Pixel format has a palette i data[1], values are indexes in this palette.
+#define PIX_FMT_PAL       2 ///< Pixel format has a palette in data[1], values are indexes in this palette.
 #define PIX_FMT_BITSTREAM 4 ///< All values of a component are bit-wise packed end to end.
 
+/**
+ * The array of all the pixel format descriptors.
+ */
+extern const AVPixFmtDescriptor av_pix_fmt_descriptors[];
 
 static inline void read_line(uint16_t *dst, const uint8_t *data[4], const int linesize[4], AVPixFmtDescriptor *desc, int x, int y, int c, int w)
 {
diff --git a/libavcodec/png.c b/libavcodec/png.c
old mode 100644
new mode 100755
diff --git a/libavcodec/png.h b/libavcodec/png.h
old mode 100644
new mode 100755
diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
old mode 100644
new mode 100755
diff --git a/libavcodec/pngenc.c b/libavcodec/pngenc.c
old mode 100644
new mode 100755
diff --git a/libavcodec/pnm.c b/libavcodec/pnm.c
old mode 100644
new mode 100755
index 4843d14..134e9f6
--- a/libavcodec/pnm.c
+++ b/libavcodec/pnm.c
@@ -138,7 +138,7 @@
                 avctx->pix_fmt = PIX_FMT_GRAY16BE;
                 if (s->maxval != 65535)
                     avctx->pix_fmt = PIX_FMT_GRAY16;
-            } if (avctx->pix_fmt == PIX_FMT_RGB24) {
+            } else if (avctx->pix_fmt == PIX_FMT_RGB24) {
                 if (s->maxval > 255)
                     avctx->pix_fmt = PIX_FMT_RGB48BE;
             } else {
diff --git a/libavcodec/pnm.h b/libavcodec/pnm.h
old mode 100644
new mode 100755
diff --git a/libavcodec/pnm_parser.c b/libavcodec/pnm_parser.c
old mode 100644
new mode 100755
diff --git a/libavcodec/pnmenc.c b/libavcodec/pnmenc.c
old mode 100644
new mode 100755
index 46afbab..69e6bed
--- a/libavcodec/pnmenc.c
+++ b/libavcodec/pnmenc.c
@@ -361,6 +361,21 @@
 #endif
 
 
+#if CONFIG_PGM_DECODER
+AVCodec pgm_decoder = {
+    "pgm",
+    CODEC_TYPE_VIDEO,
+    CODEC_ID_PGM,
+    sizeof(PNMContext),
+    common_init,
+    NULL,
+    NULL,
+    pnm_decode_frame,
+    .pix_fmts= (enum PixelFormat[]){PIX_FMT_GRAY8, PIX_FMT_GRAY16BE, PIX_FMT_NONE},
+    .long_name= NULL_IF_CONFIG_SMALL("PGM (Portable GrayMap) image"),
+};
+#endif
+
 #if CONFIG_PGM_ENCODER
 AVCodec pgm_encoder = {
     "pgm",
@@ -369,13 +384,26 @@
     sizeof(PNMContext),
     common_init,
     pnm_encode_frame,
-    NULL, //encode_end,
-    pnm_decode_frame,
     .pix_fmts= (enum PixelFormat[]){PIX_FMT_GRAY8, PIX_FMT_GRAY16BE, PIX_FMT_NONE},
     .long_name= NULL_IF_CONFIG_SMALL("PGM (Portable GrayMap) image"),
 };
 #endif // CONFIG_PGM_ENCODER
 
+#if CONFIG_PGMYUV_DECODER
+AVCodec pgmyuv_decoder = {
+    "pgmyuv",
+    CODEC_TYPE_VIDEO,
+    CODEC_ID_PGMYUV,
+    sizeof(PNMContext),
+    common_init,
+    NULL,
+    NULL,
+    pnm_decode_frame,
+    .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
+    .long_name= NULL_IF_CONFIG_SMALL("PGMYUV (Portable GrayMap YUV) image"),
+};
+#endif
+
 #if CONFIG_PGMYUV_ENCODER
 AVCodec pgmyuv_encoder = {
     "pgmyuv",
@@ -384,13 +412,26 @@
     sizeof(PNMContext),
     common_init,
     pnm_encode_frame,
-    NULL, //encode_end,
-    pnm_decode_frame,
     .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
     .long_name= NULL_IF_CONFIG_SMALL("PGMYUV (Portable GrayMap YUV) image"),
 };
 #endif // CONFIG_PGMYUV_ENCODER
 
+#if CONFIG_PPM_DECODER
+AVCodec ppm_decoder = {
+    "ppm",
+    CODEC_TYPE_VIDEO,
+    CODEC_ID_PPM,
+    sizeof(PNMContext),
+    common_init,
+    NULL,
+    NULL,
+    pnm_decode_frame,
+    .pix_fmts= (enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGB48BE, PIX_FMT_NONE},
+    .long_name= NULL_IF_CONFIG_SMALL("PPM (Portable PixelMap) image"),
+};
+#endif
+
 #if CONFIG_PPM_ENCODER
 AVCodec ppm_encoder = {
     "ppm",
@@ -399,13 +440,26 @@
     sizeof(PNMContext),
     common_init,
     pnm_encode_frame,
-    NULL, //encode_end,
-    pnm_decode_frame,
     .pix_fmts= (enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGB48BE, PIX_FMT_NONE},
     .long_name= NULL_IF_CONFIG_SMALL("PPM (Portable PixelMap) image"),
 };
 #endif // CONFIG_PPM_ENCODER
 
+#if CONFIG_PBM_DECODER
+AVCodec pbm_decoder = {
+    "pbm",
+    CODEC_TYPE_VIDEO,
+    CODEC_ID_PBM,
+    sizeof(PNMContext),
+    common_init,
+    NULL,
+    NULL,
+    pnm_decode_frame,
+    .pix_fmts= (enum PixelFormat[]){PIX_FMT_MONOWHITE, PIX_FMT_NONE},
+    .long_name= NULL_IF_CONFIG_SMALL("PBM (Portable BitMap) image"),
+};
+#endif
+
 #if CONFIG_PBM_ENCODER
 AVCodec pbm_encoder = {
     "pbm",
@@ -414,13 +468,26 @@
     sizeof(PNMContext),
     common_init,
     pnm_encode_frame,
-    NULL, //encode_end,
-    pnm_decode_frame,
     .pix_fmts= (enum PixelFormat[]){PIX_FMT_MONOWHITE, PIX_FMT_NONE},
     .long_name= NULL_IF_CONFIG_SMALL("PBM (Portable BitMap) image"),
 };
 #endif // CONFIG_PBM_ENCODER
 
+#if CONFIG_PAM_DECODER
+AVCodec pam_decoder = {
+    "pam",
+    CODEC_TYPE_VIDEO,
+    CODEC_ID_PAM,
+    sizeof(PNMContext),
+    common_init,
+    NULL,
+    NULL,
+    pnm_decode_frame,
+    .pix_fmts= (enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGB32, PIX_FMT_GRAY8, PIX_FMT_MONOWHITE, PIX_FMT_NONE},
+    .long_name= NULL_IF_CONFIG_SMALL("PAM (Portable AnyMap) image"),
+};
+#endif
+
 #if CONFIG_PAM_ENCODER
 AVCodec pam_encoder = {
     "pam",
@@ -429,8 +496,6 @@
     sizeof(PNMContext),
     common_init,
     pam_encode_frame,
-    NULL, //encode_end,
-    pnm_decode_frame,
     .pix_fmts= (enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGB32, PIX_FMT_GRAY8, PIX_FMT_MONOWHITE, PIX_FMT_NONE},
     .long_name= NULL_IF_CONFIG_SMALL("PAM (Portable AnyMap) image"),
 };
diff --git a/libavcodec/ppc/check_altivec.c b/libavcodec/ppc/check_altivec.c
old mode 100644
new mode 100755
diff --git a/libavcodec/ppc/dsputil_altivec.c b/libavcodec/ppc/dsputil_altivec.c
old mode 100644
new mode 100755
diff --git a/libavcodec/ppc/dsputil_altivec.h b/libavcodec/ppc/dsputil_altivec.h
old mode 100644
new mode 100755
diff --git a/libavcodec/ppc/dsputil_ppc.c b/libavcodec/ppc/dsputil_ppc.c
old mode 100644
new mode 100755
diff --git a/libavcodec/ppc/dsputil_ppc.h b/libavcodec/ppc/dsputil_ppc.h
old mode 100644
new mode 100755
diff --git a/libavcodec/ppc/fdct_altivec.c b/libavcodec/ppc/fdct_altivec.c
old mode 100644
new mode 100755
diff --git a/libavcodec/ppc/fft_altivec.c b/libavcodec/ppc/fft_altivec.c
old mode 100644
new mode 100755
diff --git a/libavcodec/ppc/gcc_fixes.h b/libavcodec/ppc/gcc_fixes.h
old mode 100644
new mode 100755
diff --git a/libavcodec/ppc/gmc_altivec.c b/libavcodec/ppc/gmc_altivec.c
old mode 100644
new mode 100755
diff --git a/libavcodec/ppc/h264_altivec.c b/libavcodec/ppc/h264_altivec.c
old mode 100644
new mode 100755
index b589be2..67d3367
--- a/libavcodec/ppc/h264_altivec.c
+++ b/libavcodec/ppc/h264_altivec.c
@@ -185,9 +185,9 @@
 void put_no_rnd_h264_chroma_mc8_altivec(uint8_t * dst, uint8_t * src, int stride, int h, int x, int y) {
    DECLARE_ALIGNED_16(signed int, ABCD[4]) =
                         {((8 - x) * (8 - y)),
-                             ((x) * (8 - y)),
-                         ((8 - x) * (y)),
-                             ((x) * (y))};
+                         ((    x) * (8 - y)),
+                         ((8 - x) * (    y)),
+                         ((    x) * (    y))};
     register int i;
     vec_u8 fperm;
     const vec_s32 vABCD = vec_ld(0, ABCD);
@@ -210,14 +210,14 @@
 
     if (((unsigned long)dst) % 16 == 0) {
         fperm = (vec_u8){0x10, 0x11, 0x12, 0x13,
-                           0x14, 0x15, 0x16, 0x17,
-                           0x08, 0x09, 0x0A, 0x0B,
-                           0x0C, 0x0D, 0x0E, 0x0F};
+                         0x14, 0x15, 0x16, 0x17,
+                         0x08, 0x09, 0x0A, 0x0B,
+                         0x0C, 0x0D, 0x0E, 0x0F};
     } else {
         fperm = (vec_u8){0x00, 0x01, 0x02, 0x03,
-                           0x04, 0x05, 0x06, 0x07,
-                           0x18, 0x19, 0x1A, 0x1B,
-                           0x1C, 0x1D, 0x1E, 0x1F};
+                         0x04, 0x05, 0x06, 0x07,
+                         0x18, 0x19, 0x1A, 0x1B,
+                         0x1C, 0x1D, 0x1E, 0x1F};
     }
 
     vsrcAuc = vec_ld(0, src);
diff --git a/libavcodec/ppc/h264_template_altivec.c b/libavcodec/ppc/h264_template_altivec.c
old mode 100644
new mode 100755
index 5f722d0..698de08
--- a/libavcodec/ppc/h264_template_altivec.c
+++ b/libavcodec/ppc/h264_template_altivec.c
@@ -103,14 +103,14 @@
 
     if (((unsigned long)dst) % 16 == 0) {
         fperm = (vec_u8){0x10, 0x11, 0x12, 0x13,
-                           0x14, 0x15, 0x16, 0x17,
-                           0x08, 0x09, 0x0A, 0x0B,
-                           0x0C, 0x0D, 0x0E, 0x0F};
+                         0x14, 0x15, 0x16, 0x17,
+                         0x08, 0x09, 0x0A, 0x0B,
+                         0x0C, 0x0D, 0x0E, 0x0F};
     } else {
         fperm = (vec_u8){0x00, 0x01, 0x02, 0x03,
-                           0x04, 0x05, 0x06, 0x07,
-                           0x18, 0x19, 0x1A, 0x1B,
-                           0x1C, 0x1D, 0x1E, 0x1F};
+                         0x04, 0x05, 0x06, 0x07,
+                         0x18, 0x19, 0x1A, 0x1B,
+                         0x1C, 0x1D, 0x1E, 0x1F};
     }
 
     vsrcAuc = vec_ld(0, src);
diff --git a/libavcodec/ppc/idct_altivec.c b/libavcodec/ppc/idct_altivec.c
old mode 100644
new mode 100755
diff --git a/libavcodec/ppc/imgresample_altivec.c b/libavcodec/ppc/imgresample_altivec.c
old mode 100644
new mode 100755
diff --git a/libavcodec/ppc/imgresample_altivec.h b/libavcodec/ppc/imgresample_altivec.h
old mode 100644
new mode 100755
diff --git a/libavcodec/ppc/mpegvideo_altivec.c b/libavcodec/ppc/mpegvideo_altivec.c
old mode 100644
new mode 100755
diff --git a/libavcodec/ppc/snow_altivec.c b/libavcodec/ppc/snow_altivec.c
old mode 100644
new mode 100755
diff --git a/libavcodec/ppc/util_altivec.h b/libavcodec/ppc/util_altivec.h
old mode 100644
new mode 100755
diff --git a/libavcodec/ppc/vc1dsp_altivec.c b/libavcodec/ppc/vc1dsp_altivec.c
old mode 100644
new mode 100755
diff --git a/libavcodec/ps2/dsputil_mmi.c b/libavcodec/ps2/dsputil_mmi.c
old mode 100644
new mode 100755
diff --git a/libavcodec/ps2/idct_mmi.c b/libavcodec/ps2/idct_mmi.c
old mode 100644
new mode 100755
diff --git a/libavcodec/ps2/mmi.h b/libavcodec/ps2/mmi.h
old mode 100644
new mode 100755
diff --git a/libavcodec/ps2/mpegvideo_mmi.c b/libavcodec/ps2/mpegvideo_mmi.c
old mode 100644
new mode 100755
diff --git a/libavcodec/pthread.c b/libavcodec/pthread.c
old mode 100644
new mode 100755
diff --git a/libavcodec/qcelp_lsp.c b/libavcodec/qcelp_lsp.c
index a29f262..af8e7c9 100644
--- a/libavcodec/qcelp_lsp.c
+++ b/libavcodec/qcelp_lsp.c
@@ -30,15 +30,6 @@
 #include "libavutil/mathematics.h"
 
 /**
- * initial coefficient to perform bandwidth expansion on LPC
- *
- * @note: 0.9883 looks like an approximation of 253/256.
- *
- * TIA/EIA/IS-733 2.4.3.3.6 6
- */
-#define QCELP_BANDWITH_EXPANSION_COEFF 0.9883
-
-/**
  * Computes the Pa / (1 + z(-1)) or Qa / (1 - z(-1)) coefficients
  * needed for LSP to LPC conversion.
  * We only need to calculate the 6 first elements of the polynomial.
@@ -48,16 +39,16 @@
  *
  * TIA/EIA/IS-733 2.4.3.3.5-1/2
  */
-static void lsp2polyf(const float *lspf, double *f, int lp_half_order)
+static void lsp2polyf(const double *lspf, double *f, int lp_half_order)
 {
     int i, j;
 
     f[0] = 1.0;
-    f[1] = -2 * cos(M_PI * lspf[0]);
+    f[1] = -2 * lspf[0];
     lspf -= 2;
     for(i=2; i<=lp_half_order; i++)
     {
-        double val = -2 * cos(M_PI * lspf[2*i]);
+        double val = -2 * lspf[2*i];
         f[i] = val * f[i-1] + 2*f[i-2];
         for(j=i-1; j>1; j--)
             f[j] += f[j-1] * val + f[j-2];
@@ -66,22 +57,15 @@
 }
 
 /**
- * Reconstructs LPC coefficients from the line spectral pair frequencies
- * and performs bandwidth expansion.
+ * Reconstructs LPC coefficients from the line spectral pair frequencies.
  *
  * @param lspf line spectral pair frequencies
  * @param lpc linear predictive coding coefficients
- *
- * @note: bandwith_expansion_coeff could be precalculated into a table
- *        but it seems to be slower on x86
- *
- * TIA/EIA/IS-733 2.4.3.3.5
  */
-void ff_qcelp_lspf2lpc(const float *lspf, float *lpc)
+void ff_celp_lspf2lpc(const double *lspf, float *lpc)
 {
     double pa[6], qa[6];
     int   i;
-    double bandwith_expansion_coeff = QCELP_BANDWITH_EXPANSION_COEFF * 0.5;
 
     lsp2polyf(lspf,     pa, 5);
     lsp2polyf(lspf + 1, qa, 5);
@@ -91,12 +75,7 @@
         double paf = pa[i+1] + pa[i];
         double qaf = qa[i+1] - qa[i];
 
-        lpc[i  ] = paf + qaf;
-        lpc[9-i] = paf - qaf;
-    }
-    for (i=0; i<10; i++)
-    {
-        lpc[i] *= bandwith_expansion_coeff;
-        bandwith_expansion_coeff *= QCELP_BANDWITH_EXPANSION_COEFF;
+        lpc[i  ] = 0.5*(paf+qaf);
+        lpc[9-i] = 0.5*(paf-qaf);
     }
 }
diff --git a/libavcodec/qcelpdata.h b/libavcodec/qcelpdata.h
index 0ab0be1..1c9fad0 100644
--- a/libavcodec/qcelpdata.h
+++ b/libavcodec/qcelpdata.h
@@ -550,4 +550,13 @@
  */
 #define QCELP_LSP_OCTAVE_PREDICTOR 29.0/32
 
+/**
+ * initial coefficient to perform bandwidth expansion on LPC
+ *
+ * @note: 0.9883 looks like an approximation of 253/256.
+ *
+ * TIA/EIA/IS-733 2.4.3.3.6 6
+ */
+#define QCELP_BANDWITH_EXPANSION_COEFF 0.9883
+
 #endif /* AVCODEC_QCELPDATA_H */
diff --git a/libavcodec/qcelpdec.c b/libavcodec/qcelpdec.c
index 3a18470..1889f21 100644
--- a/libavcodec/qcelpdec.c
+++ b/libavcodec/qcelpdec.c
@@ -37,6 +37,7 @@
 
 #include "celp_math.h"
 #include "celp_filters.h"
+#include "acelp_vectors.h"
 
 #undef NDEBUG
 #include <assert.h>
@@ -79,18 +80,7 @@
  *
  * TIA/EIA/IS-733 2.4.3.3.5
  */
-void ff_qcelp_lspf2lpc(const float *lspf, float *lpc);
-
-static void weighted_vector_sumf(float *out, const float *in_a,
-                                 const float *in_b, float weight_coeff_a,
-                                 float weight_coeff_b, int length)
-{
-    int i;
-
-    for(i=0; i<length; i++)
-        out[i] = weight_coeff_a * in_a[i]
-               + weight_coeff_b * in_b[i];
-}
+void ff_celp_lspf2lpc(const double *lspf, float *lpc);
 
 /**
  * Initialize the speech codec according to the specification.
@@ -174,7 +164,7 @@
             lspf[i-1] = FFMIN(lspf[i-1], (lspf[i] - QCELP_LSP_SPREAD_FACTOR));
 
         // Low-pass filter the LSP frequencies.
-        weighted_vector_sumf(lspf, lspf, q->prev_lspf, smooth, 1.0-smooth, 10);
+        ff_weighted_vector_sumf(lspf, lspf, q->prev_lspf, smooth, 1.0-smooth, 10);
     }else
     {
         q->octave_count = 0;
@@ -585,6 +575,36 @@
 }
 
 /**
+ * Reconstructs LPC coefficients from the line spectral pair frequencies
+ * and performs bandwidth expansion.
+ *
+ * @param lspf line spectral pair frequencies
+ * @param lpc linear predictive coding coefficients
+ *
+ * @note: bandwith_expansion_coeff could be precalculated into a table
+ *        but it seems to be slower on x86
+ *
+ * TIA/EIA/IS-733 2.4.3.3.5
+ */
+void lspf2lpc(const float *lspf, float *lpc)
+{
+    double lsf[10];
+    double bandwith_expansion_coeff = QCELP_BANDWITH_EXPANSION_COEFF;
+    int   i;
+
+    for (i=0; i<10; i++)
+        lsf[i] = cos(M_PI * lspf[i]);
+
+    ff_celp_lspf2lpc(lsf, lpc);
+
+    for (i=0; i<10; i++)
+    {
+        lpc[i] *= bandwith_expansion_coeff;
+        bandwith_expansion_coeff *= QCELP_BANDWITH_EXPANSION_COEFF;
+    }
+}
+
+/**
  * Interpolates LSP frequencies and computes LPC coefficients
  * for a given bitrate & pitch subframe.
  *
@@ -610,14 +630,14 @@
 
     if(weight != 1.0)
     {
-        weighted_vector_sumf(interpolated_lspf, curr_lspf, q->prev_lspf,
-                             weight, 1.0 - weight, 10);
-        ff_qcelp_lspf2lpc(interpolated_lspf, lpc);
+        ff_weighted_vector_sumf(interpolated_lspf, curr_lspf, q->prev_lspf,
+                                weight, 1.0 - weight, 10);
+        lspf2lpc(interpolated_lspf, lpc);
     }else if(q->bitrate >= RATE_QUARTER ||
              (q->bitrate == I_F_Q && !subframe_num))
-        ff_qcelp_lspf2lpc(curr_lspf, lpc);
+        lspf2lpc(curr_lspf, lpc);
     else if(q->bitrate == SILENCE && !subframe_num)
-        ff_qcelp_lspf2lpc(q->prev_lspf, lpc);
+        lspf2lpc(q->prev_lspf, lpc);
 }
 
 static qcelp_packet_rate buf_size2bitrate(const int buf_size)
@@ -802,7 +822,7 @@
 
     *data_size = 160 * sizeof(*outbuffer);
 
-    return buf_size;
+    return *data_size;
 }
 
 AVCodec qcelp_decoder =
diff --git a/libavcodec/qdm2.c b/libavcodec/qdm2.c
old mode 100644
new mode 100755
index e2f1a87..6775abc
--- a/libavcodec/qdm2.c
+++ b/libavcodec/qdm2.c
@@ -928,7 +928,7 @@
                                 unsigned index = qdm2_get_vlc(gb, &vlc_tab_type34, 0, 1);
                                 if (index < FF_ARRAY_ELEMS(type34_delta)) {
                                     samples[0] = type34_delta[index] / type34_div + type34_predictor;
-                                    type34_predictor = samples[0];
+                                type34_predictor = samples[0];
                                 } else
                                     samples[0] = SB_DITHERING_NOISE(sb,q->noise_idx);
                             }
diff --git a/libavcodec/qdm2data.h b/libavcodec/qdm2data.h
old mode 100644
new mode 100755
diff --git a/libavcodec/qdrw.c b/libavcodec/qdrw.c
old mode 100644
new mode 100755
diff --git a/libavcodec/qpeg.c b/libavcodec/qpeg.c
old mode 100644
new mode 100755
diff --git a/libavcodec/qtrle.c b/libavcodec/qtrle.c
old mode 100644
new mode 100755
diff --git a/libavcodec/ra144.c b/libavcodec/ra144.c
old mode 100644
new mode 100755
diff --git a/libavcodec/ra144.h b/libavcodec/ra144.h
old mode 100644
new mode 100755
diff --git a/libavcodec/ra288.c b/libavcodec/ra288.c
old mode 100644
new mode 100755
diff --git a/libavcodec/ra288.h b/libavcodec/ra288.h
old mode 100644
new mode 100755
diff --git a/libavcodec/rangecoder.c b/libavcodec/rangecoder.c
old mode 100644
new mode 100755
index 3c3220d..c9848e8
--- a/libavcodec/rangecoder.c
+++ b/libavcodec/rangecoder.c
@@ -111,13 +111,18 @@
 
 #ifdef TEST
 #define SIZE 10240
-#undef random
+
+#include "libavutil/lfg.h"
+
 int main(void){
     RangeCoder c;
     uint8_t b[9*SIZE];
     uint8_t r[9*SIZE];
     int i;
     uint8_t state[10]= {0};
+    AVLFG prn;
+
+    av_lfg_init(&prn, 1);
 
     ff_init_range_encoder(&c, b, SIZE);
     ff_build_rac_states(&c, 0.05*(1LL<<32), 128+64+32+16);
@@ -125,7 +130,7 @@
     memset(state, 128, sizeof(state));
 
     for(i=0; i<SIZE; i++){
-        r[i]= random()%7;
+        r[i] = av_lfg_get(&prn) % 7;
     }
 
     for(i=0; i<SIZE; i++){
diff --git a/libavcodec/rangecoder.h b/libavcodec/rangecoder.h
old mode 100644
new mode 100755
diff --git a/libavcodec/ratecontrol.c b/libavcodec/ratecontrol.c
index 7c0afa0..dbc3cde 100644
--- a/libavcodec/ratecontrol.c
+++ b/libavcodec/ratecontrol.c
@@ -62,7 +62,7 @@
     return rce->qscale * (double)(rce->i_tex_bits + rce->p_tex_bits+1)/ bits;
 }
 
-int ff_rate_control_init(MpegEncContext *s)
+int ff_rate_control_init(MpegEncContext *s, int old_bitrate)
 {
     RateControlContext *rcc= &s->rc_context;
     int i;
@@ -111,18 +111,23 @@
         av_log(s->avctx, AV_LOG_ERROR, "Error parsing rc_eq \"%s\": %s\n", s->avctx->rc_eq, error? error : "");
         return -1;
     }
-
-    for(i=0; i<5; i++){
-        rcc->pred[i].coeff= FF_QP2LAMBDA * 7.0;
-        rcc->pred[i].count= 1.0;
-
-        rcc->pred[i].decay= 0.4;
-        rcc->i_cplx_sum [i]=
-        rcc->p_cplx_sum [i]=
-        rcc->mv_bits_sum[i]=
-        rcc->qscale_sum [i]=
-        rcc->frame_count[i]= 1; // 1 is better because of 1/0 and such
-        rcc->last_qscale_for[i]=FF_QP2LAMBDA * 5;
+    
+    rcc->last_frame_rc_reset = (old_bitrate ? s->picture_number : 0);
+    s->total_bits = 0;
+    if (!old_bitrate)
+    {
+		for(i=0; i<5; i++){
+			rcc->pred[i].coeff= FF_QP2LAMBDA * 7.0;
+			rcc->pred[i].count= 1.0;
+	
+			rcc->pred[i].decay= 0.4;
+			rcc->i_cplx_sum [i]=
+			rcc->p_cplx_sum [i]=
+			rcc->mv_bits_sum[i]=
+			rcc->qscale_sum [i]=
+			rcc->frame_count[i]= 1; // 1 is better because of 1/0 and such
+			rcc->last_qscale_for[i]=FF_QP2LAMBDA * 5;
+		}
     }
     rcc->buffer_index= s->avctx->rc_initial_buffer_occupancy;
 
@@ -206,7 +211,7 @@
             return -1;
         }
         /* init stuff with the user specified complexity */
-        if(s->avctx->rc_initial_cplx){
+        if(!old_bitrate && s->avctx->rc_initial_cplx){
             for(i=0; i<60*30; i++){
                 double bits= s->avctx->rc_initial_cplx * (i/10000.0 + 1.0)*s->mb_num;
                 RateControlEntry rce;
@@ -246,7 +251,11 @@
                 rcc->pass1_wanted_bits+= s->bit_rate/(1/av_q2d(s->avctx->time_base)); //FIXME misbehaves a little for variable fps
             }
         }
-
+		else if (old_bitrate)
+		{
+	        rcc->pass1_wanted_bits *= ((double)old_bitrate)/s->bit_rate;
+	        rcc->pass1_rc_eq_output_sum *= ((double)old_bitrate)/s->bit_rate;
+		}
     }
 
     return 0;
@@ -666,9 +675,9 @@
     double diff;
     double short_term_q;
     double fps;
-    int picture_number= s->picture_number;
     int64_t wanted_bits;
     RateControlContext *rcc= &s->rc_context;
+    int picture_number= s->picture_number - rcc->last_frame_rc_reset;
     AVCodecContext *a= s->avctx;
     RateControlEntry local_rce, *rce;
     double bits;
diff --git a/libavcodec/ratecontrol.h b/libavcodec/ratecontrol.h
old mode 100644
new mode 100755
index 5673750..5016399
--- a/libavcodec/ratecontrol.h
+++ b/libavcodec/ratecontrol.h
@@ -80,6 +80,7 @@
     uint64_t qscale_sum[5];
     int frame_count[5];
     int last_non_b_pict_type;
+	int last_frame_rc_reset;      /// Narflex: for dynamic rate control
 
     void *non_lavc_opaque;        ///< context for non lavc rc code (for example xvid)
     float dry_run_qscale;         ///< for xvid rc
@@ -90,7 +91,7 @@
 struct MpegEncContext;
 
 /* rate control */
-int ff_rate_control_init(struct MpegEncContext *s);
+int ff_rate_control_init(struct MpegEncContext *s, int old_bitrate);
 float ff_rate_estimate_qscale(struct MpegEncContext *s, int dry_run);
 void ff_write_pass1_stats(struct MpegEncContext *s);
 void ff_rate_control_uninit(struct MpegEncContext *s);
diff --git a/libavcodec/raw.c b/libavcodec/raw.c
old mode 100644
new mode 100755
diff --git a/libavcodec/raw.h b/libavcodec/raw.h
old mode 100644
new mode 100755
diff --git a/libavcodec/rawdec.c b/libavcodec/rawdec.c
old mode 100644
new mode 100755
diff --git a/libavcodec/rawenc.c b/libavcodec/rawenc.c
old mode 100644
new mode 100755
diff --git a/libavcodec/rectangle.h b/libavcodec/rectangle.h
old mode 100644
new mode 100755
diff --git a/libavcodec/remove_extradata_bsf.c b/libavcodec/remove_extradata_bsf.c
old mode 100644
new mode 100755
diff --git a/libavcodec/resample.c b/libavcodec/resample.c
old mode 100644
new mode 100755
index c40f722..1857ab3
--- a/libavcodec/resample.c
+++ b/libavcodec/resample.c
@@ -39,9 +39,8 @@
 static const AVClass audioresample_context_class = { "ReSampleContext", context_to_name, options };
 
 struct ReSampleContext {
-    const AVClass *av_class;
     struct AVResampleContext *resample_context;
-    short *temp[2];
+    short *temp[6];
     int temp_len;
     float ratio;
     /* channel convert */
@@ -104,24 +103,25 @@
     }
 }
 
-/* XXX: should use more abstract 'N' channels system */
-static void stereo_split(short *output1, short *output2, short *input, int n)
+static void multichannel_split(short **outputs, short *input, int n, int chancount)
 {
-    int i;
+    int i,j;
 
-    for(i=0;i<n;i++) {
-        *output1++ = *input++;
-        *output2++ = *input++;
+    for(i=0;i<n;i++) 
+    {
+        for(j=0;j<chancount;j++)
+            outputs[j][i] = *input++;
     }
 }
 
-static void stereo_mux(short *output, short *input1, short *input2, int n)
+static void multichannel_mux(short *output, short **inputs, int n, int chancount)
 {
-    int i;
+    int i,j;
 
-    for(i=0;i<n;i++) {
-        *output++ = *input1++;
-        *output++ = *input2++;
+    for(i=0;i<n;i++) 
+    {
+        for(j=0;j<chancount;j++)
+            *output++ = inputs[j][i];
     }
 }
 
@@ -151,9 +151,9 @@
 {
     ReSampleContext *s;
 
-    if ( input_channels > 2)
+    if ( input_channels > 6)
       {
-        av_log(NULL, AV_LOG_ERROR, "Resampling with input channels greater than 2 unsupported.\n");
+        av_log(NULL, AV_LOG_ERROR, "Resampling can't handle more than 6 channels.");
         return NULL;
       }
 
@@ -206,14 +206,15 @@
  * input channels can't be greater than 2, so resample the 2 channels and then
  * expand to 6 channels after the resampling.
  */
-    if(s->filter_channels>2)
+    if(input_channels!=output_channels && s->filter_channels>2)
       s->filter_channels = 2;
 
+//    av_log(NULL, AV_LOG_ERROR, "s->filter_channels %d\n", s->filter_channels);
 #define TAPS 16
     s->resample_context= av_resample_init(output_rate, input_rate,
                          filter_length, log2_phase_count, linear, cutoff);
 
-    s->av_class= &audioresample_context_class;
+    *(AVClass**)s->resample_context = &audioresample_context_class;
 
     return s;
 }
@@ -233,10 +234,10 @@
 /* XXX: optimize it ! */
 int audio_resample(ReSampleContext *s, short *output, short *input, int nb_samples)
 {
-    int i, nb_samples1;
-    short *bufin[2];
-    short *bufout[2];
-    short *buftmp2[2], *buftmp3[2];
+    int i, nb_samples1, j;
+    short *bufin[6];
+    short *bufout[6];
+    short *buftmp2[6], *buftmp3[6];
     short *output_bak = NULL;
     int lenout;
 
@@ -279,9 +280,9 @@
     if (s->sample_fmt[1] != SAMPLE_FMT_S16) {
         output_bak = output;
 
-        if (!s->buffer_size[1] || s->buffer_size[1] < 2*lenout) {
+        if (!s->buffer_size[1] || s->buffer_size[1] < lenout) {
             av_free(s->buffer[1]);
-            s->buffer_size[1] = 2*lenout;
+            s->buffer_size[1] = lenout;
             s->buffer[1] = av_malloc(s->buffer_size[1]);
             if (!s->buffer[1]) {
                 av_log(s, AV_LOG_ERROR, "Could not allocate buffer\n");
@@ -300,8 +301,8 @@
     }
 
     /* make some zoom to avoid round pb */
-    bufout[0]= av_malloc( lenout * sizeof(short) );
-    bufout[1]= av_malloc( lenout * sizeof(short) );
+    for(j=0;j<s->filter_channels;j++)
+        bufout[j]= (short*) av_malloc( lenout * sizeof(short) );
 
     if (s->input_channels == 2 &&
         s->output_channels == 1) {
@@ -311,9 +312,11 @@
         buftmp3[0] = bufout[0];
         memcpy(buftmp2[0], input, nb_samples*sizeof(short));
     } else if (s->output_channels >= 2) {
-        buftmp3[0] = bufout[0];
-        buftmp3[1] = bufout[1];
-        stereo_split(buftmp2[0], buftmp2[1], input, nb_samples);
+        for(j=0;j<s->filter_channels;j++)
+        {
+            buftmp3[j] = bufout[j];
+        }
+        multichannel_split((short **)&buftmp2[0], input, nb_samples, s->filter_channels);
     } else {
         buftmp3[0] = output;
         memcpy(buftmp2[0], input, nb_samples*sizeof(short));
@@ -335,8 +338,8 @@
 
     if (s->output_channels == 2 && s->input_channels == 1) {
         mono_to_stereo(output, buftmp3[0], nb_samples1);
-    } else if (s->output_channels == 2) {
-        stereo_mux(output, buftmp3[0], buftmp3[1], nb_samples1);
+    } else if (s->output_channels == s->input_channels) {
+        multichannel_mux(output, (short **) &buftmp3[0], nb_samples1, s->input_channels);
     } else if (s->output_channels == 6) {
         ac3_5p1_mux(output, buftmp3[0], buftmp3[1], nb_samples1);
     }
@@ -357,16 +360,17 @@
     for(i=0; i<s->filter_channels; i++)
         av_free(bufin[i]);
 
-    av_free(bufout[0]);
-    av_free(bufout[1]);
+    for(j=0;j<s->filter_channels;j++)
+        av_free(bufout[j]);
     return nb_samples1;
 }
 
 void audio_resample_close(ReSampleContext *s)
 {
+	int j;
     av_resample_close(s->resample_context);
-    av_freep(&s->temp[0]);
-    av_freep(&s->temp[1]);
+    for(j=0; j<s->filter_channels; j++)
+        av_freep(&s->temp[j]);
     av_freep(&s->buffer[0]);
     av_freep(&s->buffer[1]);
     av_audio_convert_free(s->convert_ctx[0]);
diff --git a/libavcodec/resample2.c b/libavcodec/resample2.c
old mode 100644
new mode 100755
index 19fed30..6551b22
--- a/libavcodec/resample2.c
+++ b/libavcodec/resample2.c
@@ -57,6 +57,7 @@
 
 
 typedef struct AVResampleContext{
+    const AVClass *av_class;
     FELEM *filter_bank;
     int filter_length;
     int ideal_dst_incr;
diff --git a/libavcodec/rl.h b/libavcodec/rl.h
old mode 100644
new mode 100755
diff --git a/libavcodec/rle.c b/libavcodec/rle.c
old mode 100644
new mode 100755
diff --git a/libavcodec/roqvideo.c b/libavcodec/roqvideo.c
old mode 100644
new mode 100755
diff --git a/libavcodec/roqvideo.h b/libavcodec/roqvideo.h
old mode 100644
new mode 100755
index 2b69838..3fe11c6
--- a/libavcodec/roqvideo.h
+++ b/libavcodec/roqvideo.h
@@ -22,7 +22,7 @@
 #ifndef AVCODEC_ROQVIDEO_H
 #define AVCODEC_ROQVIDEO_H
 
-#include "libavutil/random.h"
+#include "libavutil/lfg.h"
 #include "avcodec.h"
 #include "dsputil.h"
 
@@ -58,7 +58,7 @@
     int width, height;
 
     /* Encoder only data */
-    AVRandomState randctx;
+    AVLFG randctx;
     uint64_t lambda;
 
     motion_vect *this_motion4;
diff --git a/libavcodec/roqvideodec.c b/libavcodec/roqvideodec.c
old mode 100644
new mode 100755
diff --git a/libavcodec/roqvideoenc.c b/libavcodec/roqvideoenc.c
index b9ab912..8cca312 100644
--- a/libavcodec/roqvideoenc.c
+++ b/libavcodec/roqvideoenc.c
@@ -929,7 +929,7 @@
 {
     RoqContext *enc = avctx->priv_data;
 
-    av_random_init(&enc->randctx, 1);
+    av_lfg_init(&enc->randctx, 1);
 
     enc->framesSinceKeyframe = 0;
     if ((avctx->width & 0xf) || (avctx->height & 0xf)) {
diff --git a/libavcodec/rpza.c b/libavcodec/rpza.c
old mode 100644
new mode 100755
diff --git a/libavcodec/rtjpeg.c b/libavcodec/rtjpeg.c
old mode 100644
new mode 100755
diff --git a/libavcodec/rtjpeg.h b/libavcodec/rtjpeg.h
old mode 100644
new mode 100755
diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c
old mode 100644
new mode 100755
diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c
index c4e3621..48fe370 100644
--- a/libavcodec/rv34.c
+++ b/libavcodec/rv34.c
@@ -533,7 +533,7 @@
         B[1] = cur_pic->motion_val[dir][mv_pos - s->b8_stride][1];
         has_B = 1;
     }
-    if((r->avail_cache[5-2] & type) & mask){
+    if(r->avail_cache[5-4] && (r->avail_cache[5-2] & type) & mask){
         C[0] = cur_pic->motion_val[dir][mv_pos - s->b8_stride + 2][0];
         C[1] = cur_pic->motion_val[dir][mv_pos - s->b8_stride + 2][1];
         has_C = 1;
@@ -787,15 +787,16 @@
     case RV34_MB_B_DIRECT:
         //surprisingly, it uses motion scheme from next reference frame
         next_bt = s->next_picture_ptr->mb_type[s->mb_x + s->mb_y * s->mb_stride];
-        if(IS_INTRA(next_bt))
+        if(IS_INTRA(next_bt) || IS_SKIP(next_bt)){
             fill_rectangle(s->current_picture_ptr->motion_val[0][s->mb_x * 2 + s->mb_y * 2 * s->b8_stride], 2, 2, s->b8_stride, 0, 4);
-        else
+            fill_rectangle(s->current_picture_ptr->motion_val[1][s->mb_x * 2 + s->mb_y * 2 * s->b8_stride], 2, 2, s->b8_stride, 0, 4);
+        }else
             for(j = 0; j < 2; j++)
                 for(i = 0; i < 2; i++)
                     for(k = 0; k < 2; k++)
                         for(l = 0; l < 2; l++)
                             s->current_picture_ptr->motion_val[l][mv_pos + i + j*s->b8_stride][k] = calc_add_mv(r, l, s->next_picture_ptr->motion_val[0][mv_pos + i + j*s->b8_stride][k]);
-        if(IS_16X16(next_bt)) //we can use whole macroblock MC
+        if(!(IS_16X8(next_bt) || IS_8X16(next_bt) || IS_8X8(next_bt))) //we can use whole macroblock MC
             rv34_mc_2mv(r, block_type);
         else
             rv34_mc_2mv_skip(r);
diff --git a/libavcodec/sgidec.c b/libavcodec/sgidec.c
old mode 100644
new mode 100755
diff --git a/libavcodec/sgienc.c b/libavcodec/sgienc.c
old mode 100644
new mode 100755
diff --git a/libavcodec/sh4/dsputil_align.c b/libavcodec/sh4/dsputil_align.c
old mode 100644
new mode 100755
diff --git a/libavcodec/sh4/dsputil_sh4.c b/libavcodec/sh4/dsputil_sh4.c
old mode 100644
new mode 100755
diff --git a/libavcodec/sh4/idct_sh4.c b/libavcodec/sh4/idct_sh4.c
old mode 100644
new mode 100755
diff --git a/libavcodec/sh4/qpel.c b/libavcodec/sh4/qpel.c
old mode 100644
new mode 100755
diff --git a/libavcodec/shorten.c b/libavcodec/shorten.c
old mode 100644
new mode 100755
index 6aacd5c..8f87a62
--- a/libavcodec/shorten.c
+++ b/libavcodec/shorten.c
@@ -147,7 +147,7 @@
 
     if (s->bitshift != 0)
         for (i = 0; i < s->blocksize; i++)
-            buffer[i] <<= s->bitshift;
+            buffer[s->nwrap + i] <<= s->bitshift;
 }
 
 
@@ -173,12 +173,12 @@
             s->offset[chan][i] = mean;
 }
 
-static inline int get_le32(GetBitContext *gb)
+static inline int shorten_get_le32(GetBitContext *gb)
 {
     return bswap_32(get_bits_long(gb, 32));
 }
 
-static inline short get_le16(GetBitContext *gb)
+static inline short shorten_get_le16(GetBitContext *gb)
 {
     return bswap_16(get_bits_long(gb, 16));
 }
@@ -191,30 +191,30 @@
     short wave_format;
 
     init_get_bits(&hb, header, header_size*8);
-    if (get_le32(&hb) != MKTAG('R','I','F','F')) {
+    if (shorten_get_le32(&hb) != MKTAG('R','I','F','F')) {
         av_log(avctx, AV_LOG_ERROR, "missing RIFF tag\n");
         return -1;
     }
 
-    chunk_size = get_le32(&hb);
+    chunk_size = shorten_get_le32(&hb);
 
-    if (get_le32(&hb) != MKTAG('W','A','V','E')) {
+    if (shorten_get_le32(&hb) != MKTAG('W','A','V','E')) {
         av_log(avctx, AV_LOG_ERROR, "missing WAVE tag\n");
         return -1;
     }
 
-    while (get_le32(&hb) != MKTAG('f','m','t',' ')) {
-        len = get_le32(&hb);
+    while (shorten_get_le32(&hb) != MKTAG('f','m','t',' ')) {
+        len = shorten_get_le32(&hb);
         skip_bits(&hb, 8*len);
     }
-    len = get_le32(&hb);
+    len = shorten_get_le32(&hb);
 
     if (len < 16) {
         av_log(avctx, AV_LOG_ERROR, "fmt chunk was too short\n");
         return -1;
     }
 
-    wave_format = get_le16(&hb);
+    wave_format = shorten_get_le16(&hb);
 
     switch (wave_format) {
         case WAVE_FORMAT_PCM:
@@ -224,11 +224,11 @@
             return -1;
     }
 
-    avctx->channels = get_le16(&hb);
-    avctx->sample_rate = get_le32(&hb);
-    avctx->bit_rate = get_le32(&hb) * 8;
-    avctx->block_align = get_le16(&hb);
-    avctx->bits_per_coded_sample = get_le16(&hb);
+    avctx->channels = shorten_get_le16(&hb);
+    avctx->sample_rate = shorten_get_le32(&hb);
+    avctx->bit_rate = shorten_get_le32(&hb) * 8;
+    avctx->block_align = shorten_get_le16(&hb);
+    avctx->bits_per_coded_sample = shorten_get_le16(&hb);
 
     if (avctx->bits_per_coded_sample != 16) {
         av_log(avctx, AV_LOG_ERROR, "unsupported number of bits per sample\n");
diff --git a/libavcodec/simple_idct.c b/libavcodec/simple_idct.c
old mode 100644
new mode 100755
diff --git a/libavcodec/simple_idct.h b/libavcodec/simple_idct.h
old mode 100644
new mode 100755
diff --git a/libavcodec/smacker.c b/libavcodec/smacker.c
old mode 100644
new mode 100755
diff --git a/libavcodec/smc.c b/libavcodec/smc.c
old mode 100644
new mode 100755
diff --git a/libavcodec/snow.c b/libavcodec/snow.c
index fbffce8..58fcbff 100644
--- a/libavcodec/snow.c
+++ b/libavcodec/snow.c
@@ -4029,7 +4029,7 @@
             avctx->stats_out = av_mallocz(256);
     }
     if((avctx->flags&CODEC_FLAG_PASS2) || !(avctx->flags&CODEC_FLAG_QSCALE)){
-        if(ff_rate_control_init(&s->m) < 0)
+        if(ff_rate_control_init(&s->m, 0) < 0)
             return -1;
     }
     s->pass1_rc= !(avctx->flags & (CODEC_FLAG_QSCALE|CODEC_FLAG_PASS2));
@@ -4696,7 +4696,8 @@
 #undef malloc
 #undef free
 #undef printf
-#undef random
+
+#include "libavutil/lfg.h"
 
 int main(void){
     int width=256;
@@ -4706,27 +4707,30 @@
     int i;
     s.spatial_decomposition_count=6;
     s.spatial_decomposition_type=1;
+    AVLFG prn;
+
+    av_lfg_init(&prn, 1);
 
     printf("testing 5/3 DWT\n");
     for(i=0; i<width*height; i++)
-        buffer[0][i]= buffer[1][i]= random()%54321 - 12345;
+        buffer[0][i] = buffer[1][i] = av_lfg_get(&prn) % 54321 - 12345;
 
     ff_spatial_dwt(buffer[0], width, height, width, s.spatial_decomposition_type, s.spatial_decomposition_count);
     ff_spatial_idwt(buffer[0], width, height, width, s.spatial_decomposition_type, s.spatial_decomposition_count);
 
     for(i=0; i<width*height; i++)
-        if(buffer[0][i]!= buffer[1][i]) printf("fsck: %d %d %d\n",i, buffer[0][i], buffer[1][i]);
+        if(buffer[0][i]!= buffer[1][i]) printf("fsck: %6d %12d %7d\n",i, buffer[0][i], buffer[1][i]);
 
     printf("testing 9/7 DWT\n");
     s.spatial_decomposition_type=0;
     for(i=0; i<width*height; i++)
-        buffer[0][i]= buffer[1][i]= random()%54321 - 12345;
+        buffer[0][i] = buffer[1][i] = av_lfg_get(&prn) % 54321 - 12345;
 
     ff_spatial_dwt(buffer[0], width, height, width, s.spatial_decomposition_type, s.spatial_decomposition_count);
     ff_spatial_idwt(buffer[0], width, height, width, s.spatial_decomposition_type, s.spatial_decomposition_count);
 
     for(i=0; i<width*height; i++)
-        if(FFABS(buffer[0][i] - buffer[1][i])>20) printf("fsck: %d %d %d\n",i, buffer[0][i], buffer[1][i]);
+        if(FFABS(buffer[0][i] - buffer[1][i])>20) printf("fsck: %6d %12d %7d\n",i, buffer[0][i], buffer[1][i]);
 
 #if 0
     printf("testing AC coder\n");
diff --git a/libavcodec/snow.h b/libavcodec/snow.h
old mode 100644
new mode 100755
diff --git a/libavcodec/sonic.c b/libavcodec/sonic.c
old mode 100644
new mode 100755
diff --git a/libavcodec/sp5x.h b/libavcodec/sp5x.h
old mode 100644
new mode 100755
diff --git a/libavcodec/sp5xdec.c b/libavcodec/sp5xdec.c
old mode 100644
new mode 100755
index f1e436c..920b32d
--- a/libavcodec/sp5xdec.c
+++ b/libavcodec/sp5xdec.c
@@ -88,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);
diff --git a/libavcodec/sparc/dsputil_vis.c b/libavcodec/sparc/dsputil_vis.c
old mode 100644
new mode 100755
diff --git a/libavcodec/sparc/vis.h b/libavcodec/sparc/vis.h
old mode 100644
new mode 100755
diff --git a/libavcodec/svq1.c b/libavcodec/svq1.c
old mode 100644
new mode 100755
diff --git a/libavcodec/svq1.h b/libavcodec/svq1.h
old mode 100644
new mode 100755
diff --git a/libavcodec/svq1_cb.h b/libavcodec/svq1_cb.h
old mode 100644
new mode 100755
diff --git a/libavcodec/svq1_vlc.h b/libavcodec/svq1_vlc.h
old mode 100644
new mode 100755
diff --git a/libavcodec/svq1dec.c b/libavcodec/svq1dec.c
old mode 100644
new mode 100755
diff --git a/libavcodec/svq1enc.c b/libavcodec/svq1enc.c
old mode 100644
new mode 100755
diff --git a/libavcodec/svq1enc_cb.h b/libavcodec/svq1enc_cb.h
old mode 100644
new mode 100755
diff --git a/libavcodec/svq3.c b/libavcodec/svq3.c
old mode 100644
new mode 100755
diff --git a/libavcodec/tiertexseqv.c b/libavcodec/tiertexseqv.c
old mode 100644
new mode 100755
diff --git a/libavcodec/truemotion1.c b/libavcodec/truemotion1.c
old mode 100644
new mode 100755
diff --git a/libavcodec/truemotion1data.h b/libavcodec/truemotion1data.h
old mode 100644
new mode 100755
diff --git a/libavcodec/truemotion2.c b/libavcodec/truemotion2.c
old mode 100644
new mode 100755
diff --git a/libavcodec/truespeech.c b/libavcodec/truespeech.c
old mode 100644
new mode 100755
diff --git a/libavcodec/truespeech_data.h b/libavcodec/truespeech_data.h
old mode 100644
new mode 100755
diff --git a/libavcodec/tscc.c b/libavcodec/tscc.c
old mode 100644
new mode 100755
diff --git a/libavcodec/tta.c b/libavcodec/tta.c
old mode 100644
new mode 100755
diff --git a/libavcodec/ulti.c b/libavcodec/ulti.c
old mode 100644
new mode 100755
diff --git a/libavcodec/ulti_cb.h b/libavcodec/ulti_cb.h
old mode 100644
new mode 100755
diff --git a/libavcodec/unary.h b/libavcodec/unary.h
old mode 100644
new mode 100755
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index acfafa1..04ed39a 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -65,8 +65,6 @@
 };
 
 static int volatile entangled_thread_counter=0;
-int (*ff_lockmgr_cb)(void **mutex, enum AVLockOp op);
-static void *codec_mutex;
 
 void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size)
 {
@@ -82,6 +80,17 @@
     return ptr;
 }
 
+void av_fast_malloc(void *ptr, unsigned int *size, unsigned int min_size)
+{
+    void **p = ptr;
+    if (min_size < *size)
+        return;
+    *size= FFMAX(17*min_size/16 + 32, min_size);
+    av_free(*p);
+    *p = av_malloc(*size);
+    if (!*p) *size = 0;
+}
+
 /* encoder management */
 static AVCodec *first_avcodec = NULL;
 
@@ -244,6 +253,7 @@
         int h_chroma_shift, v_chroma_shift;
         int size[4] = {0};
         int tmpsize;
+        int unaligned;
         AVPicture picture;
         int stride_align[4];
 
@@ -256,21 +266,28 @@
             h+= EDGE_WIDTH*2;
         }
 
-        ff_fill_linesize(&picture, s->pix_fmt, w);
+        do {
+            // NOTE: do not align linesizes individually, this breaks e.g. assumptions
+            // that linesize[0] == 2*linesize[1] in the MPEG-encoder for 4:2:2
+            ff_fill_linesize(&picture, s->pix_fmt, w);
+            // increase alignment of w for next try (rhs gives the lowest bit set in w)
+            w += w & ~(w-1);
 
-        for (i=0; i<4; i++){
+            unaligned = 0;
+            for (i=0; i<4; i++){
 //STRIDE_ALIGN is 8 for SSE* but this does not work for SVQ1 chroma planes
 //we could change STRIDE_ALIGN to 16 for x86/sse but it would increase the
 //picture size unneccessarily in some cases. The solution here is not
 //pretty and better ideas are welcome!
 #if HAVE_MMX
-            if(s->codec_id == CODEC_ID_SVQ1)
-                stride_align[i]= 16;
-            else
+                if(s->codec_id == CODEC_ID_SVQ1)
+                    stride_align[i]= 16;
+                else
 #endif
-            stride_align[i] = STRIDE_ALIGN;
-            picture.linesize[i] = ALIGN(picture.linesize[i], stride_align[i]);
-        }
+                stride_align[i] = STRIDE_ALIGN;
+                unaligned |= picture.linesize[i] % stride_align[i];
+            }
+        } while (unaligned);
 
         tmpsize = ff_fill_pointer(&picture, NULL, s->pix_fmt, h);
         if (tmpsize < 0)
@@ -422,12 +439,6 @@
 {
     int ret= -1;
 
-    /* If there is a user-supplied mutex locking routine, call it. */
-    if (ff_lockmgr_cb) {
-        if ((*ff_lockmgr_cb)(&codec_mutex, AV_LOCK_OBTAIN))
-            return -1;
-    }
-
     entangled_thread_counter++;
     if(entangled_thread_counter != 1){
         av_log(avctx, AV_LOG_ERROR, "insufficient thread locking around avcodec_open/close()\n");
@@ -472,11 +483,6 @@
     ret=0;
 end:
     entangled_thread_counter--;
-
-    /* Release any user-supplied mutex. */
-    if (ff_lockmgr_cb) {
-        (*ff_lockmgr_cb)(&codec_mutex, AV_LOCK_RELEASE);
-    }
     return ret;
 }
 
@@ -596,12 +602,6 @@
 
 int avcodec_close(AVCodecContext *avctx)
 {
-    /* If there is a user-supplied mutex locking routine, call it. */
-    if (ff_lockmgr_cb) {
-        if ((*ff_lockmgr_cb)(&codec_mutex, AV_LOCK_OBTAIN))
-            return -1;
-    }
-
     entangled_thread_counter++;
     if(entangled_thread_counter != 1){
         av_log(avctx, AV_LOG_ERROR, "insufficient thread locking around avcodec_open/close()\n");
@@ -617,11 +617,6 @@
     av_freep(&avctx->priv_data);
     avctx->codec = NULL;
     entangled_thread_counter--;
-
-    /* Release any user-supplied mutex. */
-    if (ff_lockmgr_cb) {
-        (*ff_lockmgr_cb)(&codec_mutex, AV_LOCK_RELEASE);
-    }
     return 0;
 }
 
@@ -728,6 +723,7 @@
             snprintf(buf + strlen(buf), buf_size - strlen(buf),
                      ", %dx%d",
                      enc->width, enc->height);
+			/* NARFLEX: We don't want DAR/PAR in the output string
             if (enc->sample_aspect_ratio.num) {
                 av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den,
                           enc->width*enc->sample_aspect_ratio.num,
@@ -737,14 +733,25 @@
                          " [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= av_gcd(enc->time_base.num, enc->time_base.den);
+				int laced = 0;
+				if (enc->codec_id == CODEC_ID_H264 /*&& enc->interlaced*/)
+					laced = 1; // STV: for some reason H.264 reports 2x frame rate (field rate)
                 snprintf(buf + strlen(buf), buf_size - strlen(buf),
                      ", %d/%d",
-                     enc->time_base.num/g, enc->time_base.den/g);
+					 enc->time_base.num/g, (laced) ? (enc->time_base.den/g) / 2 : enc->time_base.den/g);
             }
+			if (enc->sample_aspect_ratio.num && enc->sample_aspect_ratio.den) {
+				int g = av_gcd(enc->sample_aspect_ratio.num * enc->width, enc->sample_aspect_ratio.den * enc->height);
+				snprintf(buf + strlen(buf), buf_size - strlen(buf),
+					", AR: %d:%d", 
+					(enc->sample_aspect_ratio.num * enc->width)/g, (enc->sample_aspect_ratio.den * enc->height)/g);
+			}
         }
+		snprintf(buf + strlen(buf), buf_size - strlen(buf),
+			(enc->interlaced) ? ", interlaced" : ", progressive");
         if (encode) {
             snprintf(buf + strlen(buf), buf_size - strlen(buf),
                      ", q=%d-%d", enc->qmin, enc->qmax);
@@ -1176,19 +1183,3 @@
     }
     return NULL;
 }
-
-int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op))
-{
-    if (ff_lockmgr_cb) {
-        if (ff_lockmgr_cb(&codec_mutex, AV_LOCK_DESTROY))
-            return -1;
-    }
-
-    ff_lockmgr_cb = cb;
-
-    if (ff_lockmgr_cb) {
-        if (ff_lockmgr_cb(&codec_mutex, AV_LOCK_CREATE))
-            return -1;
-    }
-    return 0;
-}
diff --git a/libavcodec/vaapi.c b/libavcodec/vaapi.c
new file mode 100644
index 0000000..70949b9
--- /dev/null
+++ b/libavcodec/vaapi.c
@@ -0,0 +1,197 @@
+/*
+ * Video Acceleration API (video decoding)
+ * HW decode acceleration for MPEG-2, MPEG-4, H.264 and VC-1
+ *
+ * Copyright (C) 2008-2009 Splitted-Desktop Systems
+ *
+ * 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 "vaapi_internal.h"
+
+/**
+ * \addtogroup VAAPI_Decoding
+ *
+ * @{
+ */
+
+static void destroy_buffers(VADisplay display, VABufferID *buffers, unsigned int n_buffers)
+{
+    unsigned int i;
+    for (i = 0; i < n_buffers; i++) {
+        if (buffers[i]) {
+            vaDestroyBuffer(display, buffers[i]);
+            buffers[i] = 0;
+        }
+    }
+}
+
+static int render_picture(struct vaapi_context *vactx, VASurfaceID surface)
+{
+    VABufferID va_buffers[3];
+    unsigned int n_va_buffers = 0;
+
+    if (vaCreateBuffer(vactx->display, vactx->context_id,
+                       VAPictureParameterBufferType,
+                       vactx->pic_param_size,
+                       1, &vactx->pic_param,
+                       &vactx->pic_param_buf_id) != VA_STATUS_SUCCESS)
+        return -1;
+    va_buffers[n_va_buffers++] = vactx->pic_param_buf_id;
+
+    if (vactx->iq_matrix_present) {
+        if (vaCreateBuffer(vactx->display, vactx->context_id,
+                           VAIQMatrixBufferType,
+                           vactx->iq_matrix_size,
+                           1, &vactx->iq_matrix,
+                           &vactx->iq_matrix_buf_id) != VA_STATUS_SUCCESS)
+            return -1;
+        va_buffers[n_va_buffers++] = vactx->iq_matrix_buf_id;
+    }
+
+    if (vactx->bitplane_buffer) {
+        if (vaCreateBuffer(vactx->display, vactx->context_id,
+                           VABitPlaneBufferType,
+                           vactx->bitplane_buffer_size,
+                           1, vactx->bitplane_buffer,
+                           &vactx->bitplane_buf_id) != VA_STATUS_SUCCESS)
+            return -1;
+        va_buffers[n_va_buffers++] = vactx->bitplane_buf_id;
+    }
+
+    if (vaBeginPicture(vactx->display, vactx->context_id,
+                       surface) != VA_STATUS_SUCCESS)
+        return -1;
+
+    if (vaRenderPicture(vactx->display, vactx->context_id,
+                        va_buffers, n_va_buffers) != VA_STATUS_SUCCESS)
+        return -1;
+
+    if (vaRenderPicture(vactx->display, vactx->context_id,
+                        vactx->slice_buf_ids,
+                        vactx->n_slice_buf_ids) != VA_STATUS_SUCCESS)
+        return -1;
+
+    if (vaEndPicture(vactx->display, vactx->context_id) != VA_STATUS_SUCCESS)
+        return -1;
+
+    return 0;
+}
+
+static int commit_slices(struct vaapi_context *vactx)
+{
+    VABufferID *slice_buf_ids;
+    VABufferID slice_param_buf_id, slice_data_buf_id;
+
+    if (vactx->slice_count == 0)
+        return 0;
+
+    slice_buf_ids =
+        av_fast_realloc(vactx->slice_buf_ids,
+                        &vactx->slice_buf_ids_alloc,
+                        (vactx->n_slice_buf_ids + 2) * sizeof(slice_buf_ids[0]));
+    if (!slice_buf_ids)
+        return -1;
+    vactx->slice_buf_ids = slice_buf_ids;
+
+    slice_param_buf_id = 0;
+    if (vaCreateBuffer(vactx->display, vactx->context_id,
+                       VASliceParameterBufferType,
+                       vactx->slice_param_size,
+                       vactx->slice_count, vactx->slice_params,
+                       &slice_param_buf_id) != VA_STATUS_SUCCESS)
+        return -1;
+    vactx->slice_count = 0;
+
+    slice_data_buf_id = 0;
+    if (vaCreateBuffer(vactx->display, vactx->context_id,
+                       VASliceDataBufferType,
+                       vactx->slice_data_size,
+                       1, (void *)vactx->slice_data,
+                       &slice_data_buf_id) != VA_STATUS_SUCCESS)
+        return -1;
+    vactx->slice_data = NULL;
+    vactx->slice_data_size = 0;
+
+    slice_buf_ids[vactx->n_slice_buf_ids++] = slice_param_buf_id;
+    slice_buf_ids[vactx->n_slice_buf_ids++] = slice_data_buf_id;
+    return 0;
+}
+
+VASliceParameterBufferBase *ff_vaapi_alloc_slice(struct vaapi_context *vactx, const uint8_t *buffer, uint32_t size)
+{
+    uint8_t *slice_params;
+    VASliceParameterBufferBase *slice_param;
+
+    if (!vactx->slice_data)
+        vactx->slice_data = buffer;
+    if (vactx->slice_data + vactx->slice_data_size != buffer) {
+        if (commit_slices(vactx) < 0)
+            return NULL;
+        vactx->slice_data = buffer;
+    }
+
+    slice_params =
+        av_fast_realloc(vactx->slice_params,
+                        &vactx->slice_params_alloc,
+                        (vactx->slice_count + 1) * vactx->slice_param_size);
+    if (!slice_params)
+        return NULL;
+    vactx->slice_params = slice_params;
+
+    slice_param = (VASliceParameterBufferBase *)(slice_params + vactx->slice_count * vactx->slice_param_size);
+    slice_param->slice_data_size   = size;
+    slice_param->slice_data_offset = vactx->slice_data_size;
+    slice_param->slice_data_flag   = VA_SLICE_DATA_FLAG_ALL;
+
+    vactx->slice_count++;
+    vactx->slice_data_size += size;
+    return slice_param;
+}
+
+int ff_vaapi_common_end_frame(MpegEncContext *s)
+{
+    struct vaapi_context * const vactx = s->avctx->hwaccel_context;
+    int ret = -1;
+
+    dprintf(s->avctx, "ff_vaapi_common_end_frame()\n");
+
+    if (commit_slices(vactx) < 0)
+        goto done;
+    if (vactx->n_slice_buf_ids > 0) {
+        if (render_picture(vactx, ff_vaapi_get_surface(s->current_picture_ptr)) < 0)
+            goto done;
+        ff_draw_horiz_band(s, 0, s->avctx->height);
+    }
+    ret = 0;
+
+done:
+    destroy_buffers(vactx->display, &vactx->pic_param_buf_id, 1);
+    destroy_buffers(vactx->display, &vactx->iq_matrix_buf_id, 1);
+    destroy_buffers(vactx->display, &vactx->bitplane_buf_id, 1);
+    destroy_buffers(vactx->display, vactx->slice_buf_ids, vactx->n_slice_buf_ids);
+    av_freep(&vactx->bitplane_buffer);
+    av_freep(&vactx->slice_buf_ids);
+    av_freep(&vactx->slice_params);
+    vactx->n_slice_buf_ids     = 0;
+    vactx->slice_buf_ids_alloc = 0;
+    vactx->slice_count         = 0;
+    vactx->slice_params_alloc  = 0;
+    return ret;
+}
+
+/* @} */
diff --git a/libavcodec/vaapi.h b/libavcodec/vaapi.h
new file mode 100644
index 0000000..d620662
--- /dev/null
+++ b/libavcodec/vaapi.h
@@ -0,0 +1,232 @@
+/*
+ * Video Acceleration API (shared data between FFmpeg and the video player)
+ * HW decode acceleration for MPEG-2, MPEG-4, H.264 and VC-1
+ *
+ * Copyright (C) 2008-2009 Splitted-Desktop Systems
+ *
+ * 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_VAAPI_H
+#define AVCODEC_VAAPI_H
+
+#include <stdint.h>
+
+/**
+ * \defgroup VAAPI_Decoding VA API Decoding
+ * \ingroup Decoder
+ * @{
+ */
+
+/**
+ * This structure is used to share data between the FFmpeg library and
+ * the client video application.
+ * This shall be zero-allocated and available as
+ * AVCodecContext.hwaccel_context. All user members can be set once
+ * during initialization or through each AVCodecContext.get_buffer()
+ * function call. In any case, they must be valid prior to calling
+ * decoding functions.
+ */
+struct vaapi_context {
+    /**
+     * Window system dependent data
+     *
+     * - encoding: unused
+     * - decoding: Set by user
+     */
+    void *display;
+
+    /**
+     * Configuration ID
+     *
+     * - encoding: unused
+     * - decoding: Set by user
+     */
+    uint32_t config_id;
+
+    /**
+     * Context ID (video decode pipeline)
+     *
+     * - encoding: unused
+     * - decoding: Set by user
+     */
+    uint32_t context_id;
+
+    /**
+     * VAPictureParameterBuffer ID
+     *
+     * - encoding: unused
+     * - decoding: Set by libavcodec
+     */
+    VABufferID pic_param_buf_id;
+
+    /**
+     * VAIQMatrixBuffer ID
+     *
+     * - encoding: unused
+     * - decoding: Set by libavcodec
+     */
+    VABufferID iq_matrix_buf_id;
+
+    /**
+     * VABitPlaneBuffer ID (for VC-1 decoding)
+     *
+     * - encoding: unused
+     * - decoding: Set by libavcodec
+     */
+    VABufferID bitplane_buf_id;
+
+    /**
+     * Slice parameter/data buffer IDs
+     *
+     * - encoding: unused
+     * - decoding: Set by libavcodec
+     */
+    VABufferID *slice_buf_ids;
+
+    /**
+     * Number of effective slice buffer IDs to send to the HW
+     *
+     * - encoding: unused
+     * - decoding: Set by libavcodec
+     */
+    unsigned int n_slice_buf_ids;
+
+    /**
+     * Size of pre-allocated slice_buf_ids
+     *
+     * - encoding: unused
+     * - decoding: Set by libavcodec
+     */
+    unsigned int slice_buf_ids_alloc;
+
+    /**
+     * Picture parameter buffer
+     *
+     * - encoding: unused
+     * - decoding: Set by libavcodec
+     */
+    union {
+        VAPictureParameterBufferMPEG2 mpeg2;
+        VAPictureParameterBufferMPEG4 mpeg4;
+        VAPictureParameterBufferH264  h264;
+        VAPictureParameterBufferVC1   vc1;
+    } pic_param;
+
+    /**
+     * Size of a VAPictureParameterBuffer element
+     *
+     * - encoding: unused
+     * - decoding: Set by libavcodec
+     */
+    unsigned int pic_param_size;
+
+    /**
+     * Inverse quantization matrix buffer
+     *
+     * - encoding: unused
+     * - decoding: Set by libavcodec
+     */
+    union {
+        VAIQMatrixBufferMPEG2         mpeg2;
+        VAIQMatrixBufferMPEG4         mpeg4;
+        VAIQMatrixBufferH264          h264;
+    } iq_matrix;
+
+    /**
+     * Size of a VAIQMatrixBuffer element
+     *
+     * - encoding: unused
+     * - decoding: Set by libavcodec
+     */
+    unsigned int iq_matrix_size;
+
+    /**
+     * Flag: is quantization matrix present?
+     *
+     * - encoding: unused
+     * - decoding: Set by libavcodec
+     */
+    uint8_t iq_matrix_present;
+
+    /**
+     * VC-1 bitplane buffer
+     *
+     * - encoding: unused
+     * - decoding: Set by libavcodec
+     */
+    uint8_t *bitplane_buffer;
+
+    /**
+     * Size of VC-1 bitplane buffer
+     *
+     * - encoding: unused
+     * - decoding: Set by libavcodec
+     */
+    unsigned int bitplane_buffer_size;
+
+    /**
+     * Pointer to VASliceParameterBuffers
+     *
+     * - encoding: unused
+     * - decoding: Set by libavcodec
+     */
+    void *slice_params;
+
+    /**
+     * Size of a VASliceParameterBuffer element
+     *
+     * - encoding: unused
+     * - decoding: Set by libavcodec
+     */
+    unsigned int slice_param_size;
+
+    /**
+     * Size of pre-allocated slice_params
+     *
+     * - encoding: unused
+     * - decoding: Set by libavcodec
+     */
+    unsigned int slice_params_alloc;
+
+    /**
+     * Number of slices currently filled in
+     *
+     * - encoding: unused
+     * - decoding: Set by libavcodec
+     */
+    unsigned int slice_count;
+
+    /**
+     * Pointer to slice data buffer base
+     * - encoding: unused
+     * - decoding: Set by libavcodec
+     */
+    const uint8_t *slice_data;
+
+    /**
+     * Current size of slice data
+     *
+     * - encoding: unused
+     * - decoding: Set by libavcodec
+     */
+    uint32_t slice_data_size;
+};
+
+/* @} */
+
+#endif /* AVCODEC_VAAPI_H */
diff --git a/libavcodec/vaapi_internal.h b/libavcodec/vaapi_internal.h
new file mode 100644
index 0000000..3452890
--- /dev/null
+++ b/libavcodec/vaapi_internal.h
@@ -0,0 +1,59 @@
+/*
+ * Video Acceleration API (video decoding)
+ * HW decode acceleration for MPEG-2, MPEG-4, H.264 and VC-1
+ *
+ * Copyright (C) 2008-2009 Splitted-Desktop Systems
+ *
+ * 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_VAAPI_INTERNAL_H
+#define AVCODEC_VAAPI_INTERNAL_H
+
+#include <va/va.h>
+#include "vaapi.h"
+#include "avcodec.h"
+#include "mpegvideo.h"
+
+/**
+ * \addtogroup VAAPI_Decoding
+ *
+ * @{
+ */
+
+/** Extract VASurfaceID from a Picture */
+static inline VASurfaceID ff_vaapi_get_surface(Picture *pic)
+{
+    return (uintptr_t)pic->data[3];
+}
+
+/** Common AVHWAccel.end_frame() implementation */
+int ff_vaapi_common_end_frame(MpegEncContext *s);
+
+/**
+ * Allocate a new slice descriptor for the input slice.
+ *
+ * @param vactx the VA API context
+ * @param buffer the slice data buffer base
+ * @param size the size of the slice in bytes
+ * @return the newly allocated slice parameter
+ */
+VASliceParameterBufferBase *ff_vaapi_alloc_slice(struct vaapi_context *vactx, const uint8_t *buffer, uint32_t size);
+
+/* @} */
+
+#endif /* AVCODEC_VAAPI_INTERNAL_H */
diff --git a/libavcodec/vaapi_mpeg2.c b/libavcodec/vaapi_mpeg2.c
new file mode 100644
index 0000000..0e12dcc
--- /dev/null
+++ b/libavcodec/vaapi_mpeg2.c
@@ -0,0 +1,149 @@
+/*
+ * MPEG-2 HW decode acceleration through VA API
+ *
+ * Copyright (C) 2008-2009 Splitted-Desktop Systems
+ *
+ * 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 "vaapi_internal.h"
+#include "dsputil.h"
+
+/** Reconstruct bitstream f_code */
+static inline int mpeg2_get_f_code(MpegEncContext *s)
+{
+    return ((s->mpeg_f_code[0][0] << 12) | (s->mpeg_f_code[0][1] << 8) |
+            (s->mpeg_f_code[1][0] <<  4) |  s->mpeg_f_code[1][1]);
+}
+
+/** Determine frame start: first field for field picture or frame picture */
+static inline int mpeg2_get_is_frame_start(MpegEncContext *s)
+{
+    return s->first_field || s->picture_structure == PICT_FRAME;
+}
+
+static int vaapi_mpeg2_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size)
+{
+    struct MpegEncContext * const s = avctx->priv_data;
+    struct vaapi_context * const vactx = avctx->hwaccel_context;
+    VAPictureParameterBufferMPEG2 *pic_param;
+    VAIQMatrixBufferMPEG2 *iq_matrix;
+    int i;
+
+    dprintf(avctx, "vaapi_mpeg2_start_frame()\n");
+
+    vactx->pic_param_size   = sizeof(VAPictureParameterBufferMPEG2);
+    vactx->iq_matrix_size   = sizeof(VAIQMatrixBufferMPEG2);
+    vactx->slice_param_size = sizeof(VASliceParameterBufferMPEG2);
+
+    /* Fill in VAPictureParameterBufferMPEG2 */
+    pic_param = &vactx->pic_param.mpeg2;
+    pic_param->horizontal_size                                  = s->width;
+    pic_param->vertical_size                                    = s->height;
+    pic_param->forward_reference_picture                        = 0xffffffff;
+    pic_param->backward_reference_picture                       = 0xffffffff;
+    pic_param->picture_coding_type                              = s->pict_type;
+    pic_param->f_code                                           = mpeg2_get_f_code(s);
+    pic_param->picture_coding_extension.value                   = 0; /* reset all bits */
+    pic_param->picture_coding_extension.bits.intra_dc_precision = s->intra_dc_precision;
+    pic_param->picture_coding_extension.bits.picture_structure  = s->picture_structure;
+    pic_param->picture_coding_extension.bits.top_field_first    = s->top_field_first;
+    pic_param->picture_coding_extension.bits.frame_pred_frame_dct = s->frame_pred_frame_dct;
+    pic_param->picture_coding_extension.bits.concealment_motion_vectors = s->concealment_motion_vectors;
+    pic_param->picture_coding_extension.bits.q_scale_type       = s->q_scale_type;
+    pic_param->picture_coding_extension.bits.intra_vlc_format   = s->intra_vlc_format;
+    pic_param->picture_coding_extension.bits.alternate_scan     = s->alternate_scan;
+    pic_param->picture_coding_extension.bits.repeat_first_field = s->repeat_first_field;
+    pic_param->picture_coding_extension.bits.progressive_frame  = s->progressive_frame;
+    pic_param->picture_coding_extension.bits.is_first_field     = mpeg2_get_is_frame_start(s);
+
+    switch (s->pict_type) {
+    case FF_B_TYPE:
+        pic_param->backward_reference_picture = ff_vaapi_get_surface(&s->next_picture);
+        // fall-through
+    case FF_P_TYPE:
+        pic_param->forward_reference_picture = ff_vaapi_get_surface(&s->last_picture);
+        break;
+    }
+
+    /* Fill in VAIQMatrixBufferMPEG2 */
+    iq_matrix = &vactx->iq_matrix.mpeg2;
+    iq_matrix->load_intra_quantiser_matrix              = 1;
+    iq_matrix->load_non_intra_quantiser_matrix          = 1;
+    iq_matrix->load_chroma_intra_quantiser_matrix       = 1;
+    iq_matrix->load_chroma_non_intra_quantiser_matrix   = 1;
+    vactx->iq_matrix_present                            = 1;
+
+    for (i = 0; i < 64; i++) {
+        int n = s->dsp.idct_permutation[ff_zigzag_direct[i]];
+        iq_matrix->intra_quantiser_matrix[i]            = s->intra_matrix[n];
+        iq_matrix->non_intra_quantiser_matrix[i]        = s->inter_matrix[n];
+        iq_matrix->chroma_intra_quantiser_matrix[i]     = s->chroma_intra_matrix[n];
+        iq_matrix->chroma_non_intra_quantiser_matrix[i] = s->chroma_inter_matrix[n];
+    }
+    return 0;
+}
+
+static int vaapi_mpeg2_end_frame(AVCodecContext *avctx)
+{
+    return ff_vaapi_common_end_frame(avctx->priv_data);
+}
+
+static int vaapi_mpeg2_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
+{
+    MpegEncContext * const s = avctx->priv_data;
+    VASliceParameterBufferMPEG2 *slice_param;
+    GetBitContext gb;
+    uint32_t start_code, quantiser_scale_code, intra_slice_flag, macroblock_offset;
+
+    dprintf(avctx, "vaapi_mpeg2_decode_slice(): buffer %p, size %d\n", buffer, size);
+
+    /* Determine macroblock_offset */
+    init_get_bits(&gb, buffer, 8 * size);
+    start_code = get_bits(&gb, 32);
+    assert((start_code & 0xffffff00) == 0x00000100);
+    quantiser_scale_code = get_bits(&gb, 5);
+    intra_slice_flag = get_bits1(&gb);
+    if (intra_slice_flag) {
+        skip_bits(&gb, 8);
+        while (get_bits1(&gb) != 0)
+            skip_bits(&gb, 8);
+    }
+    macroblock_offset = get_bits_count(&gb);
+
+    /* Fill in VASliceParameterBufferMPEG2 */
+    slice_param = (VASliceParameterBufferMPEG2 *)ff_vaapi_alloc_slice(avctx->hwaccel_context, buffer, size);
+    if (!slice_param)
+        return -1;
+    slice_param->macroblock_offset              = macroblock_offset;
+    slice_param->slice_vertical_position        = s->mb_y;
+    slice_param->quantiser_scale_code           = quantiser_scale_code;
+    slice_param->intra_slice_flag               = intra_slice_flag;
+    return 0;
+}
+
+AVHWAccel mpeg2_vaapi_hwaccel = {
+    .name           = "mpeg2_vaapi",
+    .type           = CODEC_TYPE_VIDEO,
+    .id             = CODEC_ID_MPEG2VIDEO,
+    .pix_fmt        = PIX_FMT_VAAPI_VLD,
+    .capabilities   = 0,
+    .start_frame    = vaapi_mpeg2_start_frame,
+    .end_frame      = vaapi_mpeg2_end_frame,
+    .decode_slice   = vaapi_mpeg2_decode_slice,
+    .priv_data_size = 0,
+};
diff --git a/libavcodec/vb.c b/libavcodec/vb.c
old mode 100644
new mode 100755
diff --git a/libavcodec/vc1.c b/libavcodec/vc1.c
old mode 100644
new mode 100755
index 619e903..571d787
--- a/libavcodec/vc1.c
+++ b/libavcodec/vc1.c
@@ -4010,9 +4010,10 @@
 
     if (!avctx->extradata_size || !avctx->extradata) return -1;
     if (!(avctx->flags & CODEC_FLAG_GRAY))
-        avctx->pix_fmt = PIX_FMT_YUV420P;
+        avctx->pix_fmt = avctx->get_format(avctx, avctx->codec->pix_fmts);
     else
         avctx->pix_fmt = PIX_FMT_GRAY8;
+    avctx->hwaccel = ff_find_hwaccel(avctx->codec->id, avctx->pix_fmt);
     v->s.avctx = avctx;
     avctx->flags |= CODEC_FLAG_EMU_EDGE;
     v->s.flags |= CODEC_FLAG_EMU_EDGE;
@@ -4187,7 +4188,8 @@
                 if(size <= 0) continue;
                 switch(AV_RB32(start)){
                 case VC1_CODE_FRAME:
-                    if (s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)
+                    if (avctx->hwaccel ||
+                        s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)
                         buf_start = start;
                     buf_size2 = vc1_unescape_buffer(start + 4, size, buf2);
                     break;
@@ -4280,7 +4282,14 @@
     if ((CONFIG_VC1_VDPAU_DECODER || CONFIG_WMV3_VDPAU_DECODER)
         &&s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)
         ff_vdpau_vc1_decode_picture(s, buf_start, (buf + buf_size) - buf_start);
-    else {
+    else if (avctx->hwaccel) {
+        if (avctx->hwaccel->start_frame(avctx, buf, buf_size) < 0)
+            return -1;
+        if (avctx->hwaccel->decode_slice(avctx, buf_start, (buf + buf_size) - buf_start) < 0)
+            return -1;
+        if (avctx->hwaccel->end_frame(avctx) < 0)
+            return -1;
+    } else {
         ff_er_frame_start(s);
 
         v->bits = buf_size * 8;
@@ -4348,7 +4357,7 @@
     CODEC_CAP_DELAY,
     NULL,
     .long_name = NULL_IF_CONFIG_SMALL("SMPTE VC-1"),
-    .pix_fmts = ff_pixfmt_list_420
+    .pix_fmts = ff_hwaccel_pixfmt_list_420
 };
 
 AVCodec wmv3_decoder = {
@@ -4363,7 +4372,7 @@
     CODEC_CAP_DELAY,
     NULL,
     .long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 9"),
-    .pix_fmts = ff_pixfmt_list_420
+    .pix_fmts = ff_hwaccel_pixfmt_list_420
 };
 
 #if CONFIG_WMV3_VDPAU_DECODER
diff --git a/libavcodec/vc1.h b/libavcodec/vc1.h
old mode 100644
new mode 100755
diff --git a/libavcodec/vc1_parser.c b/libavcodec/vc1_parser.c
old mode 100644
new mode 100755
diff --git a/libavcodec/vc1data.c b/libavcodec/vc1data.c
old mode 100644
new mode 100755
diff --git a/libavcodec/vc1data.h b/libavcodec/vc1data.h
old mode 100644
new mode 100755
diff --git a/libavcodec/vc1dsp.c b/libavcodec/vc1dsp.c
old mode 100644
new mode 100755
diff --git a/libavcodec/vcr1.c b/libavcodec/vcr1.c
old mode 100644
new mode 100755
diff --git a/libavcodec/vdpau.c b/libavcodec/vdpau.c
index 034228d..4a7c86c 100644
--- a/libavcodec/vdpau.c
+++ b/libavcodec/vdpau.c
@@ -165,7 +165,7 @@
     render->info.h264.num_ref_idx_l1_active_minus1           = h->pps.ref_count[1] - 1;
     render->info.h264.log2_max_frame_num_minus4              = h->sps.log2_max_frame_num - 4;
     render->info.h264.pic_order_cnt_type                     = h->sps.poc_type;
-    render->info.h264.log2_max_pic_order_cnt_lsb_minus4      = h->sps.log2_max_poc_lsb - 4;
+    render->info.h264.log2_max_pic_order_cnt_lsb_minus4      = h->sps.poc_type ? 0 : h->sps.log2_max_poc_lsb - 4;
     render->info.h264.delta_pic_order_always_zero_flag       = h->sps.delta_pic_order_always_zero_flag;
     render->info.h264.direct_8x8_inference_flag              = h->sps.direct_8x8_inference_flag;
     render->info.h264.entropy_coding_mode_flag               = h->pps.cabac;
diff --git a/libavcodec/vmdav.c b/libavcodec/vmdav.c
old mode 100644
new mode 100755
diff --git a/libavcodec/vorbis.c b/libavcodec/vorbis.c
old mode 100644
new mode 100755
diff --git a/libavcodec/vorbis_data.c b/libavcodec/vorbis_data.c
old mode 100644
new mode 100755
diff --git a/libavcodec/vorbis_dec.c b/libavcodec/vorbis_dec.c
old mode 100644
new mode 100755
index 1321b08..7a1ea5d
--- a/libavcodec/vorbis_dec.c
+++ b/libavcodec/vorbis_dec.c
@@ -61,7 +61,7 @@
 struct vorbis_context_s;
 typedef
 int (* vorbis_floor_decode_func)
-    (struct vorbis_context_s *, vorbis_floor_data *, float *);
+             (struct vorbis_context_s *, vorbis_floor_data *, float *);
 typedef struct {
     uint_fast8_t floor_type;
     vorbis_floor_decode_func decode;
@@ -1447,9 +1447,9 @@
 {
     if (vr->type==2)
         return vorbis_residue_decode_internal(vc, vr, ch, do_not_decode, vec, vlen, ch_left, 2);
-    else if (vr->type == 1)
+    else if (vr->type==1)
         return vorbis_residue_decode_internal(vc, vr, ch, do_not_decode, vec, vlen, ch_left, 1);
-    else if (vr->type == 0)
+    else if (vr->type==0)
         return vorbis_residue_decode_internal(vc, vr, ch, do_not_decode, vec, vlen, ch_left, 0);
     else {
         av_log(vc->avccontext, AV_LOG_ERROR, " Invalid residue type while residue decode?! \n");
diff --git a/libavcodec/vp3.c b/libavcodec/vp3.c
old mode 100644
new mode 100755
diff --git a/libavcodec/vp3_parser.c b/libavcodec/vp3_parser.c
old mode 100644
new mode 100755
diff --git a/libavcodec/vp3data.h b/libavcodec/vp3data.h
old mode 100644
new mode 100755
diff --git a/libavcodec/vp3dsp.c b/libavcodec/vp3dsp.c
old mode 100644
new mode 100755
diff --git a/libavcodec/vp6.c b/libavcodec/vp6.c
index d9e9711..fbfa385 100644
--- a/libavcodec/vp6.c
+++ b/libavcodec/vp6.c
@@ -216,7 +216,7 @@
 }
 
 static int vp6_build_huff_tree(VP56Context *s, uint8_t coeff_model[],
-                               const uint8_t *map, unsigned size, VLC *vlc)
+                                const uint8_t *map, unsigned size, VLC *vlc)
 {
     Node nodes[2*size], *tmp = &nodes[size];
     int a, b, i;
@@ -233,7 +233,7 @@
     free_vlc(vlc);
     /* then build the huffman tree according to probabilities */
     return ff_huff_build_tree(s->avctx, vlc, size, nodes, vp6_huff_cmp,
-                              FF_HUFFMAN_FLAG_HNODE_FIRST);
+                       FF_HUFFMAN_FLAG_HNODE_FIRST);
 }
 
 static void vp6_parse_coeff_models(VP56Context *s)
diff --git a/libavcodec/vqavideo.c b/libavcodec/vqavideo.c
old mode 100644
new mode 100755
diff --git a/libavcodec/w32thread.c b/libavcodec/w32thread.c
old mode 100644
new mode 100755
diff --git a/libavcodec/wma.c b/libavcodec/wma.c
old mode 100644
new mode 100755
diff --git a/libavcodec/wma.h b/libavcodec/wma.h
old mode 100644
new mode 100755
diff --git a/libavcodec/wmadata.h b/libavcodec/wmadata.h
old mode 100644
new mode 100755
diff --git a/libavcodec/wmadec.c b/libavcodec/wmadec.c
old mode 100644
new mode 100755
diff --git a/libavcodec/wmv2.c b/libavcodec/wmv2.c
old mode 100644
new mode 100755
diff --git a/libavcodec/wmv2.h b/libavcodec/wmv2.h
old mode 100644
new mode 100755
diff --git a/libavcodec/wmv2dec.c b/libavcodec/wmv2dec.c
old mode 100644
new mode 100755
diff --git a/libavcodec/wmv2enc.c b/libavcodec/wmv2enc.c
old mode 100644
new mode 100755
diff --git a/libavcodec/wnv1.c b/libavcodec/wnv1.c
old mode 100644
new mode 100755
diff --git a/libavcodec/ws-snd1.c b/libavcodec/ws-snd1.c
old mode 100644
new mode 100755
diff --git a/libavcodec/x86/h264_idct_sse2.asm b/libavcodec/x86/h264_idct_sse2.asm
old mode 100644
new mode 100755
diff --git a/libavcodec/x86/x86inc.asm b/libavcodec/x86/x86inc.asm
index 3729b5b..fccabb8 100644
--- a/libavcodec/x86/x86inc.asm
+++ b/libavcodec/x86/x86inc.asm
@@ -35,7 +35,7 @@
         SECTION .text align=16
         fakegot:
     %else
-        SECTION .rodata align=16
+    SECTION .rodata align=16
     %endif
 %endmacro
 
diff --git a/libavcodec/xan.c b/libavcodec/xan.c
old mode 100644
new mode 100755
diff --git a/libavcodec/xl.c b/libavcodec/xl.c
old mode 100644
new mode 100755
diff --git a/libavcodec/zmbv.c b/libavcodec/zmbv.c
old mode 100644
new mode 100755
diff --git a/libavdevice/Makefile b/libavdevice/Makefile
old mode 100644
new mode 100755
diff --git a/libavdevice/alldevices.c b/libavdevice/alldevices.c
old mode 100644
new mode 100755
diff --git a/libavdevice/beosaudio.cpp b/libavdevice/beosaudio.cpp
old mode 100644
new mode 100755
diff --git a/libavdevice/bktr.c b/libavdevice/bktr.c
old mode 100644
new mode 100755
diff --git a/libavdevice/dv1394.c b/libavdevice/dv1394.c
old mode 100644
new mode 100755
diff --git a/libavdevice/dv1394.h b/libavdevice/dv1394.h
old mode 100644
new mode 100755
diff --git a/libavdevice/libavdevice.v b/libavdevice/libavdevice.v
deleted file mode 100644
index 663af85..0000000
--- a/libavdevice/libavdevice.v
+++ /dev/null
@@ -1,4 +0,0 @@
-LIBAVDEVICE_$MAJOR {
-        global: avdevice_*;
-        local: *;
-};
diff --git a/libavdevice/libdc1394.c b/libavdevice/libdc1394.c
old mode 100644
new mode 100755
diff --git a/libavdevice/v4l.c b/libavdevice/v4l.c
old mode 100644
new mode 100755
diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c
old mode 100644
new mode 100755
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 9da8f91..ccf7909 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -1,8 +1,7 @@
 include $(SUBDIR)../config.mak
 
 NAME = avfilter
-FFLIBS = avcodec avutil
-FFLIBS-$(CONFIG_SWSCALE)       += swscale
+FFLIBS = avcodec avutil swscale
 FFLIBS-$(CONFIG_AVFILTER_LAVF) += avformat
 
 HEADERS = avfilter.h
diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
old mode 100644
new mode 100755
diff --git a/libavfilter/formats.c b/libavfilter/formats.c
old mode 100644
new mode 100755
diff --git a/libavfilter/libavfilter.v b/libavfilter/libavfilter.v
deleted file mode 100644
index 83e8887..0000000
--- a/libavfilter/libavfilter.v
+++ /dev/null
@@ -1,4 +0,0 @@
-LIBAVFILTER_$MAJOR {
-        global: avfilter_*; av_*;
-        local: *;
-};
diff --git a/libavformat/4xm.c b/libavformat/4xm.c
old mode 100644
new mode 100755
diff --git a/libavformat/Makefile b/libavformat/Makefile
old mode 100644
new mode 100755
index b01fbbf..1e73ea0
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -53,7 +53,7 @@
 OBJS-$(CONFIG_EAC3_MUXER)                += raw.o
 OBJS-$(CONFIG_FFM_DEMUXER)               += ffmdec.o
 OBJS-$(CONFIG_FFM_MUXER)                 += ffmenc.o
-OBJS-$(CONFIG_FLAC_DEMUXER)              += flacdec.o raw.o id3v2.o
+OBJS-$(CONFIG_FLAC_DEMUXER)              += flacdec.o raw.o id3v2.o oggparsevorbis.o
 OBJS-$(CONFIG_FLAC_MUXER)                += flacenc.o
 OBJS-$(CONFIG_FLIC_DEMUXER)              += flic.o
 OBJS-$(CONFIG_FLV_DEMUXER)               += flvdec.o
@@ -188,6 +188,7 @@
 OBJS-$(CONFIG_RPL_DEMUXER)               += rpl.o
 OBJS-$(CONFIG_RTP_MUXER)                 += rtp.o         \
                                             rtp_aac.o     \
+                                            rtp_asf.o     \
                                             rtp_mpv.o     \
                                             rtpenc.o      \
                                             rtpenc_h264.o \
@@ -206,6 +207,8 @@
 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_TRUEHD_DEMUXER)            += raw.o id3v2.o
+OBJS-$(CONFIG_TRUEHD_MUXER)              += raw.o
 OBJS-$(CONFIG_TTA_DEMUXER)               += tta.o
 OBJS-$(CONFIG_TXD_DEMUXER)               += txd.o
 OBJS-$(CONFIG_VC1_DEMUXER)               += raw.o
@@ -214,6 +217,7 @@
 OBJS-$(CONFIG_VMD_DEMUXER)               += sierravmd.o
 OBJS-$(CONFIG_VOC_DEMUXER)               += vocdec.o voc.o
 OBJS-$(CONFIG_VOC_MUXER)                 += vocenc.o voc.o
+OBJS-$(CONFIG_VQF_DEMUXER)               += vqf.o
 OBJS-$(CONFIG_WAV_DEMUXER)               += wav.o riff.o raw.o
 OBJS-$(CONFIG_WAV_MUXER)                 += wav.o riff.o
 OBJS-$(CONFIG_WC3_DEMUXER)               += wc3movie.o
@@ -228,8 +232,6 @@
 OBJS-$(CONFIG_LIBNUT_DEMUXER)            += libnut.o riff.o
 OBJS-$(CONFIG_LIBNUT_MUXER)              += libnut.o riff.o
 
-OBJS-$(CONFIG_VHOOK)                     += framehook.o
-
 # protocols I/O
 OBJS+= avio.o aviobuf.o
 
@@ -240,5 +242,8 @@
 OBJS-$(CONFIG_RTP_PROTOCOL)              += rtpproto.o
 OBJS-$(CONFIG_TCP_PROTOCOL)              += tcp.o
 OBJS-$(CONFIG_UDP_PROTOCOL)              += udp.o
+OBJS-$(CONFIG_STV_PROTOCOL)              += stv.o
+
+TESTPROGS = timefilter
 
 include $(SUBDIR)../subdir.mak
diff --git a/libavformat/adtsenc.c b/libavformat/adtsenc.c
old mode 100644
new mode 100755
index 9916b92..70e252e
--- a/libavformat/adtsenc.c
+++ b/libavformat/adtsenc.c
@@ -42,7 +42,7 @@
     adts->sample_rate_index = get_bits(&gb, 4);
     adts->channel_conf = get_bits(&gb, 4);
 
-    if (adts->objecttype > 3) {
+    if (adts->objecttype > 3U) {
         av_log(s, AV_LOG_ERROR, "MPEG-4 AOT %d is not allowed in ADTS\n", adts->objecttype+1);
         return -1;
     }
@@ -54,6 +54,18 @@
         ff_log_missing_feature(s, "PCE based channel configuration", 0);
         return -1;
     }
+    if (get_bits(&gb, 1)) {
+        av_log(s, AV_LOG_ERROR, "960/120 MDCT window is not allowed in ADTS\n");
+        return -1;
+    }
+    if (get_bits(&gb, 1)) {
+        av_log(s, AV_LOG_ERROR, "Scalable configurations are not allowed in ADTS\n");
+        return -1;
+    }
+    if (get_bits(&gb, 1)) {
+        ff_log_missing_feature(s, "Signaled SBR or PS", 0);
+        return -1;
+    }
 
     adts->write_adts = 1;
 
diff --git a/libavformat/aiff.c b/libavformat/aiff.c
old mode 100644
new mode 100755
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
old mode 100644
new mode 100755
index 4be6a87..acd0ac0
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -182,12 +182,14 @@
     REGISTER_MUXER    (TGP, tgp);
     REGISTER_DEMUXER  (THP, thp);
     REGISTER_DEMUXER  (TIERTEXSEQ, tiertexseq);
+    REGISTER_MUXDEMUX (TRUEHD, truehd);
     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_DEMUXER  (VQF, vqf);
     REGISTER_MUXDEMUX (WAV, wav);
     REGISTER_DEMUXER  (WC3, wc3);
     REGISTER_DEMUXER  (WSAUD, wsaud);
@@ -207,4 +209,5 @@
     REGISTER_PROTOCOL (RTP, rtp);
     REGISTER_PROTOCOL (TCP, tcp);
     REGISTER_PROTOCOL (UDP, udp);
+    REGISTER_PROTOCOL (STV, stv);
 }
diff --git a/libavformat/amr.c b/libavformat/amr.c
old mode 100644
new mode 100755
diff --git a/libavformat/asf.c b/libavformat/asf.c
old mode 100644
new mode 100755
index bca212b..89da545
--- a/libavformat/asf.c
+++ b/libavformat/asf.c
@@ -21,99 +21,105 @@
 #include "asf.h"
 
 
-const GUID ff_asf_header = {
+const ff_asf_guid ff_asf_header = {
     0x30, 0x26, 0xB2, 0x75, 0x8E, 0x66, 0xCF, 0x11, 0xA6, 0xD9, 0x00, 0xAA, 0x00, 0x62, 0xCE, 0x6C
 };
 
-const GUID ff_asf_file_header = {
+const ff_asf_guid ff_asf_file_header = {
     0xA1, 0xDC, 0xAB, 0x8C, 0x47, 0xA9, 0xCF, 0x11, 0x8E, 0xE4, 0x00, 0xC0, 0x0C, 0x20, 0x53, 0x65
 };
 
-const GUID ff_asf_stream_header = {
+const ff_asf_guid ff_asf_stream_header = {
     0x91, 0x07, 0xDC, 0xB7, 0xB7, 0xA9, 0xCF, 0x11, 0x8E, 0xE6, 0x00, 0xC0, 0x0C, 0x20, 0x53, 0x65
 };
 
-const GUID ff_asf_ext_stream_header = {
+const ff_asf_guid ff_asf_ext_stream_header = {
     0xCB, 0xA5, 0xE6, 0x14, 0x72, 0xC6, 0x32, 0x43, 0x83, 0x99, 0xA9, 0x69, 0x52, 0x06, 0x5B, 0x5A
 };
 
-const GUID ff_asf_audio_stream = {
+const ff_asf_guid ff_asf_audio_stream = {
     0x40, 0x9E, 0x69, 0xF8, 0x4D, 0x5B, 0xCF, 0x11, 0xA8, 0xFD, 0x00, 0x80, 0x5F, 0x5C, 0x44, 0x2B
 };
 
-const GUID ff_asf_audio_conceal_none = {
+const ff_asf_guid ff_asf_audio_conceal_none = {
     // 0x40, 0xa4, 0xf1, 0x49, 0x4ece, 0x11d0, 0xa3, 0xac, 0x00, 0xa0, 0xc9, 0x03, 0x48, 0xf6
     // New value lifted from avifile
     0x00, 0x57, 0xfb, 0x20, 0x55, 0x5B, 0xCF, 0x11, 0xa8, 0xfd, 0x00, 0x80, 0x5f, 0x5c, 0x44, 0x2b
 };
 
-const GUID ff_asf_audio_conceal_spread = {
+const ff_asf_guid ff_asf_audio_conceal_spread = {
      0x50, 0xCD, 0xC3, 0xBF, 0x8F, 0x61, 0xCF, 0x11, 0x8B, 0xB2, 0x00, 0xAA, 0x00, 0xB4, 0xE2, 0x20
 };
 
-const GUID ff_asf_video_stream = {
+const ff_asf_guid ff_asf_video_stream = {
     0xC0, 0xEF, 0x19, 0xBC, 0x4D, 0x5B, 0xCF, 0x11, 0xA8, 0xFD, 0x00, 0x80, 0x5F, 0x5C, 0x44, 0x2B
 };
 
-const GUID ff_asf_video_conceal_none = {
+const ff_asf_guid ff_asf_video_conceal_none = {
     0x00, 0x57, 0xFB, 0x20, 0x55, 0x5B, 0xCF, 0x11, 0xA8, 0xFD, 0x00, 0x80, 0x5F, 0x5C, 0x44, 0x2B
 };
 
-const GUID ff_asf_command_stream = {
+const ff_asf_guid ff_asf_command_stream = {
     0xC0, 0xCF, 0xDA, 0x59, 0xE6, 0x59, 0xD0, 0x11, 0xA3, 0xAC, 0x00, 0xA0, 0xC9, 0x03, 0x48, 0xF6
 };
 
-const GUID ff_asf_comment_header = {
+const ff_asf_guid ff_asf_comment_header = {
     0x33, 0x26, 0xb2, 0x75, 0x8E, 0x66, 0xCF, 0x11, 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c
 };
 
-const GUID ff_asf_codec_comment_header = {
+const ff_asf_guid ff_asf_codec_comment_header = {
     0x40, 0x52, 0xD1, 0x86, 0x1D, 0x31, 0xD0, 0x11, 0xA3, 0xA4, 0x00, 0xA0, 0xC9, 0x03, 0x48, 0xF6
 };
-const GUID ff_asf_codec_comment1_header = {
+const ff_asf_guid ff_asf_codec_comment1_header = {
     0x41, 0x52, 0xd1, 0x86, 0x1D, 0x31, 0xD0, 0x11, 0xa3, 0xa4, 0x00, 0xa0, 0xc9, 0x03, 0x48, 0xf6
 };
 
-const GUID ff_asf_data_header = {
+const ff_asf_guid ff_asf_data_header = {
     0x36, 0x26, 0xb2, 0x75, 0x8E, 0x66, 0xCF, 0x11, 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c
 };
 
-const GUID ff_asf_head1_guid = {
+const ff_asf_guid ff_asf_head1_guid = {
     0xb5, 0x03, 0xbf, 0x5f, 0x2E, 0xA9, 0xCF, 0x11, 0x8e, 0xe3, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65
 };
 
-const GUID ff_asf_head2_guid = {
+const ff_asf_guid ff_asf_head2_guid = {
     0x11, 0xd2, 0xd3, 0xab, 0xBA, 0xA9, 0xCF, 0x11, 0x8e, 0xe6, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65
 };
 
-const GUID ff_asf_extended_content_header = {
+const ff_asf_guid ff_asf_extended_content_header = {
         0x40, 0xA4, 0xD0, 0xD2, 0x07, 0xE3, 0xD2, 0x11, 0x97, 0xF0, 0x00, 0xA0, 0xC9, 0x5E, 0xA8, 0x50
 };
 
-const GUID ff_asf_simple_index_header = {
+const ff_asf_guid ff_asf_simple_index_header = {
         0x90, 0x08, 0x00, 0x33, 0xB1, 0xE5, 0xCF, 0x11, 0x89, 0xF4, 0x00, 0xA0, 0xC9, 0x03, 0x49, 0xCB
 };
 
-const GUID ff_asf_ext_stream_embed_stream_header = {
+const ff_asf_guid ff_asf_ext_stream_embed_stream_header = {
         0xe2, 0x65, 0xfb, 0x3a, 0xEF, 0x47, 0xF2, 0x40, 0xac, 0x2c, 0x70, 0xa9, 0x0d, 0x71, 0xd3, 0x43
 };
 
-const GUID ff_asf_ext_stream_audio_stream = {
+const ff_asf_guid ff_asf_ext_stream_audio_stream = {
         0x9d, 0x8c, 0x17, 0x31, 0xE1, 0x03, 0x28, 0x45, 0xb5, 0x82, 0x3d, 0xf9, 0xdb, 0x22, 0xf5, 0x03
 };
 
-const GUID ff_asf_metadata_header = {
+const ff_asf_guid ff_asf_metadata_header = {
         0xea, 0xcb, 0xf8, 0xc5, 0xaf, 0x5b, 0x77, 0x48, 0x84, 0x67, 0xaa, 0x8c, 0x44, 0xfa, 0x4c, 0xca
 };
 
+const ff_asf_guid ff_asf_content_encryption_object = {
+        0xfb, 0xb3, 0x11, 0x22, 0x23, 0xbd, 0xd2, 0x11, 0xb4, 0xb7, 0x00, 0xa0, 0xc9, 0x55, 0xfc, 0x6e
+};
+
 /* I am not a number !!! This GUID is the one found on the PC used to
    generate the stream */
-const GUID ff_asf_my_guid = {
+const ff_asf_guid ff_asf_my_guid = {
     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
 };
 
 
 const AVMetadataConv ff_asf_metadata_conv[] = {
+#if 0
+	// DrD: we want the ASF names here...
     { "AlbumArtist", "artist"    },
     { "AlbumTitle" , "album"     },
     { "Author"     , "author"    },
@@ -121,5 +127,6 @@
     { "Copyright"  , "copyright" },
     { "TrackNumber", "track"     },
     { "Year"       , "year"      },
+#endif
     { 0 }
 };
diff --git a/libavformat/asf.h b/libavformat/asf.h
old mode 100644
new mode 100755
index 7e7225c..06f0f1b
--- a/libavformat/asf.h
+++ b/libavformat/asf.h
@@ -44,10 +44,10 @@
 
 } ASFStream;
 
-typedef uint8_t GUID[16];
+typedef uint8_t ff_asf_guid[16];
 
 typedef struct {
-    GUID guid;                  ///< generated by client computer
+    ff_asf_guid guid;                  ///< generated by client computer
     uint64_t file_size;         /**< in bytes
                                  *   invalid if broadcasting */
     uint64_t create_time;       /**< time of creation, in 100-nanosecond units since 1.1.1601
@@ -134,28 +134,29 @@
     ASFStream* asf_st;                   ///< currently decoded stream
 } ASFContext;
 
-extern const GUID ff_asf_header;
-extern const GUID ff_asf_file_header;
-extern const GUID ff_asf_stream_header;
-extern const GUID ff_asf_ext_stream_header;
-extern const GUID ff_asf_audio_stream;
-extern const GUID ff_asf_audio_conceal_none;
-extern const GUID ff_asf_audio_conceal_spread;
-extern const GUID ff_asf_video_stream;
-extern const GUID ff_asf_video_conceal_none;
-extern const GUID ff_asf_command_stream;
-extern const GUID ff_asf_comment_header;
-extern const GUID ff_asf_codec_comment_header;
-extern const GUID ff_asf_codec_comment1_header;
-extern const GUID ff_asf_data_header;
-extern const GUID ff_asf_head1_guid;
-extern const GUID ff_asf_head2_guid;
-extern const GUID ff_asf_extended_content_header;
-extern const GUID ff_asf_simple_index_header;
-extern const GUID ff_asf_ext_stream_embed_stream_header;
-extern const GUID ff_asf_ext_stream_audio_stream;
-extern const GUID ff_asf_metadata_header;
-extern const GUID ff_asf_my_guid;
+extern const ff_asf_guid ff_asf_header;
+extern const ff_asf_guid ff_asf_file_header;
+extern const ff_asf_guid ff_asf_stream_header;
+extern const ff_asf_guid ff_asf_ext_stream_header;
+extern const ff_asf_guid ff_asf_audio_stream;
+extern const ff_asf_guid ff_asf_audio_conceal_none;
+extern const ff_asf_guid ff_asf_audio_conceal_spread;
+extern const ff_asf_guid ff_asf_video_stream;
+extern const ff_asf_guid ff_asf_video_conceal_none;
+extern const ff_asf_guid ff_asf_command_stream;
+extern const ff_asf_guid ff_asf_comment_header;
+extern const ff_asf_guid ff_asf_codec_comment_header;
+extern const ff_asf_guid ff_asf_codec_comment1_header;
+extern const ff_asf_guid ff_asf_data_header;
+extern const ff_asf_guid ff_asf_head1_guid;
+extern const ff_asf_guid ff_asf_head2_guid;
+extern const ff_asf_guid ff_asf_extended_content_header;
+extern const ff_asf_guid ff_asf_simple_index_header;
+extern const ff_asf_guid ff_asf_ext_stream_embed_stream_header;
+extern const ff_asf_guid ff_asf_ext_stream_audio_stream;
+extern const ff_asf_guid ff_asf_metadata_header;
+extern const ff_asf_guid ff_asf_my_guid;
+extern const ff_asf_guid ff_asf_content_encryption_object;
 
 extern const AVMetadataConv ff_asf_metadata_conv[];
 
diff --git a/libavformat/asfcrypt.c b/libavformat/asfcrypt.c
old mode 100644
new mode 100755
diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c
index 074266b..080b5ec 100644
--- a/libavformat/asfdec.c
+++ b/libavformat/asfdec.c
@@ -34,11 +34,11 @@
 #define FRAME_HEADER_SIZE 17
 // Fix Me! FRAME_HEADER_SIZE may be different.
 
-static const GUID index_guid = {
+static const ff_asf_guid index_guid = {
     0x90, 0x08, 0x00, 0x33, 0xb1, 0xe5, 0xcf, 0x11, 0x89, 0xf4, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xcb
 };
 
-static const GUID stream_bitrate_guid = { /* (http://get.to/sdp) */
+static const ff_asf_guid stream_bitrate_guid = { /* (http://get.to/sdp) */
     0xce, 0x75, 0xf8, 0x7b, 0x8d, 0x46, 0xd1, 0x11, 0x8d, 0x82, 0x00, 0x60, 0x97, 0xc9, 0xa2, 0xb2
 };
 /**********************************/
@@ -48,10 +48,10 @@
 
 #ifdef DEBUG
 #define PRINT_IF_GUID(g,cmp) \
-if (!memcmp(g, &cmp, sizeof(GUID))) \
+if (!guidcmp(g, &cmp)) \
     dprintf(NULL, "(GUID: %s) ", #cmp)
 
-static void print_guid(const GUID *g)
+static void print_guid(const ff_asf_guid *g)
 {
     int i;
     PRINT_IF_GUID(g, ff_asf_header);
@@ -87,7 +87,12 @@
 #define print_guid(g)
 #endif
 
-static void get_guid(ByteIOContext *s, GUID *g)
+static int guidcmp(const void *g1, const void *g2)
+{
+    return memcmp(g1, g2, sizeof(ff_asf_guid));
+}
+
+static void get_guid(ByteIOContext *s, ff_asf_guid *g)
 {
     assert(sizeof(*g) == 16);
     get_buffer(s, *g, sizeof(*g));
@@ -125,43 +130,94 @@
 static int asf_probe(AVProbeData *pd)
 {
     /* check file header */
-    if (!memcmp(pd->buf, &ff_asf_header, sizeof(GUID)))
+    if (!guidcmp(pd->buf, &ff_asf_header))
         return AVPROBE_SCORE_MAX;
     else
         return 0;
 }
 
-static int get_value(ByteIOContext *pb, int type){
+static uint64_t get_value(ByteIOContext *pb, int type){
     switch(type){
-        case 2: return get_le32(pb);
-        case 3: return get_le32(pb);
+        case 2: return (uint64_t)get_le32(pb);
+        case 3: return (uint64_t)get_le32(pb);
         case 4: return get_le64(pb);
-        case 5: return get_le16(pb);
-        default:return INT_MIN;
+        case 5: return (uint64_t)get_le16(pb);
+        default:return INT64_MIN;
     }
 }
 
 static void get_tag(AVFormatContext *s, const char *key, int type, int len)
 {
-    char value[1024];
-    if (type <= 1) {         // unicode or byte
-        get_str16_nolen(s->pb, len, value, sizeof(value));
-    } else if (type <= 5) {  // boolean or DWORD or QWORD or WORD
+    char* value = NULL;
+
+	if ((type == 0) || (type == 1)) // unicode or byte
+	{
+		if (!strcmp(key, "WM/Picture")) 
+		{
+			// report picture offset/size so we can load it externally
+			uint64_t picPos;
+			
+			// skip the first four bytes (not sure what it is)
+			len -= 4;
+			get_le32(s->pb);
+			// Skip the null terminated wide string for mime type
+			while (len > 0)
+			{
+				len -= 2;
+				if (get_le16(s->pb) == 0)
+					break;
+			}
+			// Skip the next byte for pic type (this might be swapped with the next string
+			// so switch these two if this is wrong)
+			get_byte(s->pb);
+			len--;
+			// Skip null terminated wide string for description
+			while (len > 0)
+			{
+				len -= 2;
+				if (get_le16(s->pb) == 0)
+					break;
+			}
+			picPos = url_ftell(s->pb);
+			value = (char*) av_mallocz(1024);
+			snprintf(value, 1024, "%"PRIi64",%d", picPos, len);
+			url_fskip(s->pb, len);
+		}
+		else if (type == 0)
+		{
+			value = (char*) av_mallocz(len);
+			get_str16_nolen(s->pb, len, value, len);
+		}
+		else
+		{
+			url_fskip(s->pb, len);
+			return;
+		}
+	}
+	else if (type >= 2 && type <= 5)   // boolean or DWORD or QWORD or WORD
+	{
         uint64_t num = get_value(s->pb, type);
-        snprintf(value, sizeof(value), "%"PRIu64, num);
+        if (!strcmp(key, "WM/Track"))
+	        num++; // add 1 to WM/Track value so it's one based
+		value = (char*) av_mallocz(256);
+        snprintf(value, 256, "%"PRIu64, num);
     } else {
         url_fskip(s->pb, len);
         return;
     }
-    if (strncmp(key, "WM/", 3))
+#if 0
+	// DrD: Please leave the WM/ prefix
+    if (!strncmp(key, "WM/", 3))
         key += 3;
+#endif
     av_metadata_set(&s->metadata, key, value);
+	av_free(value);
 }
 
 static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
 {
     ASFContext *asf = s->priv_data;
-    GUID g;
+    ff_asf_guid g;
     ByteIOContext *pb = s->pb;
     AVStream *st;
     ASFStream *asf_st;
@@ -169,12 +225,13 @@
     int64_t gsize;
     AVRational dar[128];
     uint32_t bitrate[128];
+	int theFlags;
 
     memset(dar, 0, sizeof(dar));
     memset(bitrate, 0, sizeof(bitrate));
 
     get_guid(pb, &g);
-    if (memcmp(&g, &ff_asf_header, sizeof(GUID)))
+    if (guidcmp(&g, &ff_asf_header))
         return -1;
     get_le64(pb);
     get_le32(pb);
@@ -187,7 +244,7 @@
         dprintf(s, "%08"PRIx64": ", url_ftell(pb) - 24);
         print_guid(&g);
         dprintf(s, "  size=0x%"PRIx64"\n", gsize);
-        if (!memcmp(&g, &ff_asf_data_header, sizeof(GUID))) {
+        if (!guidcmp(&g, &ff_asf_data_header)) {
             asf->data_object_offset = url_ftell(pb);
             // if not streaming, gsize is not unlimited (how?), and there is enough space in the file..
             if (!(asf->hdr.flags & 0x01) && gsize >= 100) {
@@ -199,7 +256,7 @@
         }
         if (gsize < 24)
             return -1;
-        if (!memcmp(&g, &ff_asf_file_header, sizeof(GUID))) {
+        if (!guidcmp(&g, &ff_asf_file_header)) {
             get_guid(pb, &asf->hdr.guid);
             asf->hdr.file_size          = get_le64(pb);
             asf->hdr.create_time        = get_le64(pb);
@@ -213,7 +270,7 @@
             asf->hdr.max_pktsize        = get_le32(pb);
             asf->hdr.max_bitrate        = get_le32(pb);
             s->packet_size = asf->hdr.max_pktsize;
-        } else if (!memcmp(&g, &ff_asf_stream_header, sizeof(GUID))) {
+        } else if (!guidcmp(&g, &ff_asf_stream_header)) {
             enum CodecType type;
             int type_specific_size, sizeX;
             uint64_t total_size;
@@ -240,13 +297,13 @@
             get_guid(pb, &g);
 
             test_for_ext_stream_audio = 0;
-            if (!memcmp(&g, &ff_asf_audio_stream, sizeof(GUID))) {
+            if (!guidcmp(&g, &ff_asf_audio_stream)) {
                 type = CODEC_TYPE_AUDIO;
-            } else if (!memcmp(&g, &ff_asf_video_stream, sizeof(GUID))) {
+            } else if (!guidcmp(&g, &ff_asf_video_stream)) {
                 type = CODEC_TYPE_VIDEO;
-            } else if (!memcmp(&g, &ff_asf_command_stream, sizeof(GUID))) {
+            } else if (!guidcmp(&g, &ff_asf_command_stream)) {
                 type = CODEC_TYPE_DATA;
-            } else if (!memcmp(&g, &ff_asf_ext_stream_embed_stream_header, sizeof(GUID))) {
+            } else if (!guidcmp(&g, &ff_asf_ext_stream_embed_stream_header)) {
                 test_for_ext_stream_audio = 1;
                 type = CODEC_TYPE_UNKNOWN;
             } else {
@@ -256,7 +313,10 @@
             total_size = get_le64(pb);
             type_specific_size = get_le32(pb);
             get_le32(pb);
-            st->id = get_le16(pb) & 0x7f; /* stream id */
+			theFlags = get_le16(pb);
+            st->id = theFlags & 0x7f; /* stream id */
+            if (theFlags & 0x80)
+                av_metadata_set(&s->metadata, "ENCRYPTION", "MS-DRM");
             // mapping of asf ID to AV stream ID;
             asf->asfid2avid[st->id] = s->nb_streams - 1;
 
@@ -264,7 +324,7 @@
 
             if (test_for_ext_stream_audio) {
                 get_guid(pb, &g);
-                if (!memcmp(&g, &ff_asf_ext_stream_audio_stream, sizeof(GUID))) {
+                if (!guidcmp(&g, &ff_asf_ext_stream_audio_stream)) {
                     type = CODEC_TYPE_AUDIO;
                     is_dvr_ms_audio=1;
                     get_guid(pb, &g);
@@ -348,20 +408,20 @@
                     get_buffer(pb, st->codec->extradata, st->codec->extradata_size);
                 }
 
-        /* Extract palette from extradata if bpp <= 8 */
-        /* This code assumes that extradata contains only palette */
-        /* This is true for all paletted codecs implemented in ffmpeg */
-        if (st->codec->extradata_size && (st->codec->bits_per_coded_sample <= 8)) {
-            st->codec->palctrl = av_mallocz(sizeof(AVPaletteControl));
+                /* Extract palette from extradata if bpp <= 8 */
+                /* This code assumes that extradata contains only palette */
+                /* This is true for all paletted codecs implemented in ffmpeg */
+                if (st->codec->extradata_size && (st->codec->bits_per_coded_sample <= 8)) {
+                    st->codec->palctrl = av_mallocz(sizeof(AVPaletteControl));
 #ifdef WORDS_BIGENDIAN
-            for (i = 0; i < FFMIN(st->codec->extradata_size, AVPALETTE_SIZE)/4; i++)
-                st->codec->palctrl->palette[i] = bswap_32(((uint32_t*)st->codec->extradata)[i]);
+                    for (i = 0; i < FFMIN(st->codec->extradata_size, AVPALETTE_SIZE)/4; i++)
+                        st->codec->palctrl->palette[i] = bswap_32(((uint32_t*)st->codec->extradata)[i]);
 #else
-            memcpy(st->codec->palctrl->palette, st->codec->extradata,
-                   FFMIN(st->codec->extradata_size, AVPALETTE_SIZE));
+                    memcpy(st->codec->palctrl->palette, st->codec->extradata,
+                           FFMIN(st->codec->extradata_size, AVPALETTE_SIZE));
 #endif
-            st->codec->palctrl->palette_changed = 1;
-        }
+                    st->codec->palctrl->palette_changed = 1;
+                }
 
                 st->codec->codec_tag = tag1;
                 st->codec->codec_id = codec_get_id(codec_bmp_tags, tag1);
@@ -370,7 +430,7 @@
             }
             pos2 = url_ftell(pb);
             url_fskip(pb, gsize - (pos2 - pos1 + 24));
-        } else if (!memcmp(&g, &ff_asf_comment_header, sizeof(GUID))) {
+        } else if (!guidcmp(&g, &ff_asf_comment_header)) {
             int len1, len2, len3, len4, len5;
 
             len1 = get_le16(pb);
@@ -378,12 +438,16 @@
             len3 = get_le16(pb);
             len4 = get_le16(pb);
             len5 = get_le16(pb);
-            get_tag(s, "title"    , 0, len1);
-            get_tag(s, "author"   , 0, len2);
-            get_tag(s, "copyright", 0, len3);
-            get_tag(s, "comment"  , 0, len4);
+			if (len1 > 0)
+				get_tag(s, "Title"    , 0, len1);
+            if (len2 > 0)
+				get_tag(s, "Artist"   , 0, len2);
+			if (len3 > 0)
+				get_tag(s, "Copyright", 0, len3);
+			if (len4 > 0)
+				get_tag(s, "Comment"  , 0, len4);
             url_fskip(pb, len5);
-        } else if (!memcmp(&g, &stream_bitrate_guid, sizeof(GUID))) {
+        } else if (!guidcmp(&g, &stream_bitrate_guid)) {
             int stream_count = get_le16(pb);
             int j;
 
@@ -398,22 +462,21 @@
 //                av_log(s, AV_LOG_ERROR, "flags: 0x%x stream id %d, bitrate %d\n", flags, stream_id, bitrate);
                 asf->stream_bitrates[stream_id]= bitrate;
             }
-       } else if (!memcmp(&g, &ff_asf_extended_content_header, sizeof(GUID))) {
-                int desc_count, i;
+        } else if (!guidcmp(&g, &ff_asf_extended_content_header)) {
+            int desc_count, i;
 
-                desc_count = get_le16(pb);
-                for(i=0;i<desc_count;i++)
-                {
-                        int name_len,value_type,value_len;
-                        char name[1024];
+            desc_count = get_le16(pb);
+            for(i=0;i<desc_count;i++) {
+                    int name_len,value_type,value_len;
+                    char name[1024];
 
-                        name_len = get_le16(pb);
-                        get_str16_nolen(pb, name_len, name, sizeof(name));
-                        value_type = get_le16(pb);
-                        value_len = get_le16(pb);
-                        get_tag(s, name, value_type, value_len);
-                }
-        } else if (!memcmp(&g, &ff_asf_metadata_header, sizeof(GUID))) {
+                    name_len = get_le16(pb);
+                    get_str16_nolen(pb, name_len, name, sizeof(name));
+                    value_type = get_le16(pb);
+                    value_len  = get_le16(pb);
+                    get_tag(s, name, value_type, value_len);
+            }
+        } else if (!guidcmp(&g, &ff_asf_metadata_header)) {
             int n, stream_num, name_len, value_len, value_type, value_num;
             n = get_le16(pb);
 
@@ -436,7 +499,7 @@
                     else if(!strcmp(name, "AspectRatioY")) dar[stream_num].den= value_num;
                 }
             }
-        } else if (!memcmp(&g, &ff_asf_ext_stream_header, sizeof(GUID))) {
+        } else if (!guidcmp(&g, &ff_asf_ext_stream_header)) {
             int ext_len, payload_ext_ct, stream_ct;
             uint32_t ext_d, leak_rate, stream_num;
             int64_t pos_ex_st;
@@ -476,13 +539,13 @@
 
             // there could be a optional stream properties object to follow
             // if so the next iteration will pick it up
-        } else if (!memcmp(&g, &ff_asf_head1_guid, sizeof(GUID))) {
+        } else if (!guidcmp(&g, &ff_asf_head1_guid)) {
             int v1, v2;
             get_guid(pb, &g);
             v1 = get_le32(pb);
             v2 = get_le16(pb);
 #if 0
-        } else if (!memcmp(&g, &ff_asf_codec_comment_header, sizeof(GUID))) {
+        } else if (!guidcmp(&g, &ff_asf_codec_comment_header)) {
             int len, v1, n, num;
             char str[256], *q;
             char tag[16];
@@ -506,6 +569,9 @@
                 *q = '\0';
             }
 #endif
+        } else if (!guidcmp(&g, &ff_asf_content_encryption_object)) {
+			av_metadata_set(&s->metadata, "ENCRYPTION", "MS-DRM");
+			url_fseek(pb, gsize - 24, SEEK_CUR);
         } else if (url_feof(pb)) {
             return -1;
         } else {
@@ -696,6 +762,7 @@
 
 int ff_asf_parse_packet(AVFormatContext *s, ByteIOContext *pb, AVPacket *pkt)
 {
+    int ret;
     ASFContext *asf = s->priv_data;
     ASFStream *asf_st = 0;
     for (;;) {
@@ -771,7 +838,9 @@
                 av_free_packet(&asf_st->pkt);
             }
             /* new packet */
-            av_new_packet(&asf_st->pkt, asf->packet_obj_size);
+            ret = av_new_packet(&asf_st->pkt, asf->packet_obj_size);
+            if(ret<0)
+                return ret;
             asf_st->seq = asf->packet_seq;
             asf_st->pkt.dts = asf->packet_frag_timestamp;
             asf_st->pkt.stream_index = asf->stream_index;
@@ -982,7 +1051,7 @@
 
 static void asf_build_simple_index(AVFormatContext *s, int stream_index)
 {
-    GUID g;
+    ff_asf_guid g;
     ASFContext *asf = s->priv_data;
     int64_t gsize, itime;
     int64_t pos, current_pos, index_pts;
@@ -993,7 +1062,7 @@
 
     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))) {
+    if (!guidcmp(&g, &index_guid)) {
         gsize = get_le64(s->pb);
         get_guid(s->pb, &g);
         itime=get_le64(s->pb);
diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c
index 8b33071..168a221 100644
--- a/libavformat/asfenc.c
+++ b/libavformat/asfenc.c
@@ -197,7 +197,7 @@
 
 #define PREROLL_TIME 3100
 
-static void put_guid(ByteIOContext *s, const GUID *g)
+static void put_guid(ByteIOContext *s, const ff_asf_guid *g)
 {
     assert(sizeof(*g) == 16);
     put_buffer(s, *g, sizeof(*g));
@@ -220,7 +220,7 @@
     }while(c);
 }
 
-static int64_t put_header(ByteIOContext *pb, const GUID *g)
+static int64_t put_header(ByteIOContext *pb, const ff_asf_guid *g)
 {
     int64_t pos;
 
diff --git a/libavformat/au.c b/libavformat/au.c
old mode 100644
new mode 100755
diff --git a/libavformat/audiointerleave.c b/libavformat/audiointerleave.c
index d811f21..a3a6531 100644
--- a/libavformat/audiointerleave.c
+++ b/libavformat/audiointerleave.c
@@ -33,7 +33,7 @@
         AudioInterleaveContext *aic = st->priv_data;
 
         if (st->codec->codec_type == CODEC_TYPE_AUDIO)
-            av_fifo_free(&aic->fifo);
+            av_fifo_free(aic->fifo);
     }
 }
 
@@ -62,7 +62,7 @@
             aic->time_base = time_base;
 
             aic->fifo_size = 100* *aic->samples;
-            av_fifo_init(&aic->fifo, 100 * *aic->samples);
+            aic->fifo= av_fifo_alloc(100 * *aic->samples);
         }
     }
 
@@ -75,12 +75,12 @@
     AVStream *st = s->streams[stream_index];
     AudioInterleaveContext *aic = st->priv_data;
 
-    int size = FFMIN(av_fifo_size(&aic->fifo), *aic->samples * aic->sample_size);
-    if (!size || (!flush && size == av_fifo_size(&aic->fifo)))
+    int size = FFMIN(av_fifo_size(aic->fifo), *aic->samples * aic->sample_size);
+    if (!size || (!flush && size == av_fifo_size(aic->fifo)))
         return 0;
 
     av_new_packet(pkt, size);
-    av_fifo_read(&aic->fifo, pkt->data, size);
+    av_fifo_generic_read(aic->fifo, pkt->data, size, NULL);
 
     pkt->dts = pkt->pts = aic->dts;
     pkt->duration = av_rescale_q(*aic->samples, st->time_base, aic->time_base);
@@ -104,13 +104,13 @@
         AVStream *st = s->streams[pkt->stream_index];
         AudioInterleaveContext *aic = st->priv_data;
         if (st->codec->codec_type == CODEC_TYPE_AUDIO) {
-            unsigned new_size = av_fifo_size(&aic->fifo) + pkt->size;
+            unsigned new_size = av_fifo_size(aic->fifo) + pkt->size;
             if (new_size > aic->fifo_size) {
-                if (av_fifo_realloc2(&aic->fifo, new_size) < 0)
+                if (av_fifo_realloc2(aic->fifo, new_size) < 0)
                     return -1;
                 aic->fifo_size = new_size;
             }
-            av_fifo_generic_write(&aic->fifo, pkt->data, pkt->size, NULL);
+            av_fifo_generic_write(aic->fifo, pkt->data, pkt->size, NULL);
         } else {
             // rewrite pts and dts to be decoded time line position
             pkt->pts = pkt->dts = aic->dts;
diff --git a/libavformat/audiointerleave.h b/libavformat/audiointerleave.h
index 10684af..c948c36 100644
--- a/libavformat/audiointerleave.h
+++ b/libavformat/audiointerleave.h
@@ -27,7 +27,7 @@
 #include "avformat.h"
 
 typedef struct {
-    AVFifoBuffer fifo;
+    AVFifoBuffer *fifo;
     unsigned fifo_size;           ///< size of currently allocated FIFO
     uint64_t dts;                 ///< current dts
     int sample_size;              ///< size of one sample all channels included
diff --git a/libavformat/avc.c b/libavformat/avc.c
old mode 100644
new mode 100755
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
old mode 100644
new mode 100755
index 6b87144..ce8eb75
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -22,7 +22,7 @@
 #define AVFORMAT_AVFORMAT_H
 
 #define LIBAVFORMAT_VERSION_MAJOR 52
-#define LIBAVFORMAT_VERSION_MINOR 31
+#define LIBAVFORMAT_VERSION_MINOR 32
 #define LIBAVFORMAT_VERSION_MICRO  0
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
@@ -98,6 +98,12 @@
 int av_metadata_set(AVMetadata **pm, const char *key, const char *value);
 
 /**
+ * Reports the metadata in the given context. Data for the context and
+ * for each of the streams are reported.
+ */
+void av_metadata_dump(struct AVFormatContext *ic);
+
+/**
  * Convert all the metadata sets from ctx according to the source and
  * destination conversion tables.
  * @param d_conv destination tags format conversion table
@@ -163,6 +169,17 @@
 } AVPacket;
 #define PKT_FLAG_KEY   0x0001
 
+/**
+ * Normally, parsed container frames contain a complete video frame.
+ * However, for some formats (e.g., H.264), it is possible that a frame
+ * contains only a field. As fields have just half the duration of normal
+ * frame, frame rate detection would detect 2*fps instead of fps.
+ * By setting this field, frame rate detection will detect correct fps.
+ *
+ * Default 0, set to 1 by parser, if a frame containing single field detected.
+ */
+#define PKT_FLAG_FIELD 0x0002
+
 void av_destruct_packet_nofree(AVPacket *pkt);
 
 /**
diff --git a/libavformat/avi.h b/libavformat/avi.h
old mode 100644
new mode 100755
diff --git a/libavformat/avidec.c b/libavformat/avidec.c
old mode 100644
new mode 100755
index 78e5051..d499978
--- a/libavformat/avidec.c
+++ b/libavformat/avidec.c
@@ -31,6 +31,9 @@
 
 //#define DEBUG
 //#define DEBUG_SEEK
+//#define EM8622DEBUG
+//#define DEBUGAVIDEMUX
+//#define DEBUGAVINOINTER
 
 typedef struct AVIStream {
     int64_t frame_offset; /* current frame (video) or byte (audio) counter
@@ -48,6 +51,9 @@
     int prefix_count;
     uint32_t pal[256];
     int has_pal;
+#ifdef EM8622
+    int64_t INDXoffset;
+#endif
 } AVIStream;
 
 typedef struct {
@@ -126,6 +132,12 @@
     int i;
     int64_t last_pos= -1;
     int64_t filesize= url_fsize(s->pb);
+#ifdef EM8622
+    int j,k=0;
+    int64_t nextpos=0;
+    AVStream *st2=NULL;
+    AVIStream *ast2=NULL;
+#endif
 
 #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",
@@ -147,6 +159,10 @@
     if(index_type>1)
         return -1;
 
+#ifdef EM8622DEBUG
+    av_log(s, AV_LOG_ERROR, "Starting to parse ODML index\n");
+#endif
+
     if(filesize > 0 && base >= filesize){
         av_log(s, AV_LOG_ERROR, "ODML index invalid\n");
         if(base>>32 == (base & 0xFFFFFFFF) && (base & 0xFFFFFFFF) < filesize && filesize <= 0xFFFFFFFF)
@@ -155,6 +171,34 @@
             return -1;
     }
 
+#ifdef EM8622
+    // Find position of last data from this stream
+    {
+        nextpos=0;
+        if(st->nb_index_entries>=1)
+            nextpos = st->index_entries[st->nb_index_entries-1].pos;
+    }
+    // Find position of video keyframe after this pos
+    for(j=0;j<s->nb_streams;j++)
+    {
+        st2= s->streams[j];
+        ast2 = st->priv_data;
+        if(st2->codec->codec_type == CODEC_TYPE_VIDEO)
+        {
+            for(k=0;k<st2->nb_index_entries;k++)
+            {
+                if(st2->index_entries[k].pos>nextpos)
+                {
+                    nextpos=st2->index_entries[k].pos;
+                    break;
+                }
+            }
+            break;
+        }
+    }
+    av_log(s, AV_LOG_ERROR, "nextpos k=%d %lld\n", k, nextpos);
+#endif
+
     for(i=0; i<entries_in_use; i++){
         if(index_type){
             int64_t pos= get_le32(pb) + base - 8;
@@ -171,10 +215,41 @@
             if(last_pos == pos || pos == base - 8)
                 avi->non_interleaved= 1;
             if(last_pos != pos)
+            {
+#ifdef EM8622
+            if(key && st->codec->codec_type == CODEC_TYPE_VIDEO)
+            {
+                av_add_index_entry(st, pos, ast->cum_len / FFMAX(1, ast->sample_size), len, 0, (key) ? AVINDEX_KEYFRAME : 0);
+            }
+            if(st->codec->codec_type != CODEC_TYPE_VIDEO)
+            {
+                if(pos>=nextpos)
+                {
+                    //av_log(s, AV_LOG_ERROR, "adding keyframe %lld\n", pos);
+                    av_add_index_entry(st, pos, ast->cum_len / FFMAX(1, ast->sample_size), len, 0, (key) ? AVINDEX_KEYFRAME : 0);
+                    if(st2!=NULL)
+                    {
+                        for(;k<st2->nb_index_entries;k++)
+                        {
+                            if(st2->index_entries[k].pos>nextpos)
+                            {
+                                nextpos=st2->index_entries[k].pos;
+                                break;
+                            }
+                        }
+                        if(k==st2->nb_index_entries)
+                            nextpos=0x7FFFFFFFFFFFFFFFLL;
+                        //av_log(s, AV_LOG_ERROR, "nextpos k=%d %lld\n", k, nextpos);
+                    }
+                }
+            }
+#else
                 av_add_index_entry(st, pos, ast->cum_len / FFMAX(1, ast->sample_size), len, 0, key ? AVINDEX_KEYFRAME : 0);
+#endif
+            }
 
             if(ast->sample_size)
-                ast->cum_len += len;
+                ast->cum_len += (len+ast->sample_size-1)/ast->sample_size*ast->sample_size;
             else
                 ast->cum_len ++;
             last_pos= pos;
@@ -197,6 +272,9 @@
             url_fseek(pb, pos, SEEK_SET);
         }
     }
+#ifdef EM8622DEBUG
+    av_log(s, AV_LOG_ERROR, "Done parsing ODML index\n");
+#endif
     avi->index_loaded=1;
     return 0;
 }
@@ -248,7 +326,7 @@
     int codec_type, stream_index, frame_period, bit_rate;
     unsigned int size, nb_frames;
     int i;
-    AVStream *st;
+    AVStream *st = NULL;
     AVIStream *ast = NULL;
     int avih_width=0, avih_height=0;
     int amv_file_format=0;
@@ -260,7 +338,7 @@
 
     avi->fsize = url_fsize(pb);
     if(avi->fsize<=0)
-        avi->fsize= avi->riff_end;
+        avi->fsize= avi->riff_end == 8 ? INT64_MAX : avi->riff_end;
 
     /* first list tag */
     stream_index = -1;
@@ -415,7 +493,7 @@
             get_le32(pb); /* quality */
             ast->sample_size = get_le32(pb); /* sample ssize */
             ast->cum_len *= FFMAX(1, ast->sample_size);
-//            av_log(s, AV_LOG_DEBUG, "%d %d %d %d\n", ast->rate, ast->scale, ast->start, ast->sample_size);
+//            av_log(s, AV_LOG_ERROR, "%d %d %d\n",  ast->rate, ast->scale, ast->sample_size);
 
             switch(tag1) {
             case MKTAG('v', 'i', 'd', 's'):
@@ -437,6 +515,11 @@
                 av_log(s, AV_LOG_ERROR, "unknown stream type %X\n", tag1);
                 goto fail;
             }
+#ifdef EM8622DEBUG
+            av_log(s, AV_LOG_ERROR, "setting frame_offset to %"PRId64"\n", 
+                ast->cum_len);
+#endif
+
             ast->frame_offset= ast->cum_len;
             url_fskip(pb, size - 12 * 4);
             break;
@@ -519,10 +602,11 @@
                     break;
                 case CODEC_TYPE_AUDIO:
                     get_wav_header(pb, st->codec, size);
-                    if(ast->sample_size && st->codec->block_align && ast->sample_size != st->codec->block_align){
+                    if(/*ast->sample_size &&*/ st->codec->block_align && ast->sample_size != st->codec->block_align){
                         av_log(s, AV_LOG_WARNING, "sample size (%d) != block align (%d)\n", ast->sample_size, st->codec->block_align);
                         ast->sample_size= st->codec->block_align;
                     }
+
                     if (size%2) /* 2-aligned (fix for Stargate SG-1 - 3x18 - Shades of Grey.avi) */
                         url_fskip(pb, 1);
                     /* Force parsing as several audio frames can be in
@@ -553,8 +637,20 @@
             break;
         case MKTAG('i', 'n', 'd', 'x'):
             i= url_ftell(pb);
-            if(!url_is_streamed(pb) && !(s->flags & AVFMT_FLAG_IGNIDX)){
+            if(!url_is_streamed(pb) && !(s->flags & AVFMT_FLAG_IGNIDX))
+            {
+#ifdef EM8622
+				if(st->codec->codec_type == CODEC_TYPE_VIDEO)
+				{
+					read_braindead_odml_indx(s, 0);
+				}
+				else
+				{
+					ast->INDXoffset=i;
+				}
+#else
                 read_braindead_odml_indx(s, 0);
+#endif
             }
             url_fseek(pb, i+size, SEEK_SET);
             break;
@@ -625,6 +721,21 @@
         return -1;
     }
 
+#ifdef EM8622
+    for(i=0;i<s->nb_streams; i++)
+    {
+        int64_t oldoffset;
+        st= s->streams[i];
+        ast = st->priv_data;
+        if(ast->INDXoffset!=0)
+        {
+            oldoffset=url_ftell(pb);
+            url_fseek(pb, ast->INDXoffset, SEEK_SET);
+            read_braindead_odml_indx(s, 0);
+            url_fseek(pb, oldoffset, SEEK_SET);
+        }
+    }
+#endif
     if(!avi->index_loaded && !url_is_streamed(pb))
         avi_load_index(s);
     avi->index_loaded = 1;
@@ -677,6 +788,10 @@
                 ts /= ast->sample_size;
             ts= av_rescale(ts, AV_TIME_BASE * (int64_t)st->time_base.num, st->time_base.den);
 
+#ifdef DEBUGAVINOINTER
+            #undef fprintf
+            fprintf(stderr, "%"PRId64" %d/%d %"PRId64" %d\n", ts, st->time_base.num, st->time_base.den, ast->frame_offset, st->nb_index_entries);
+#endif
 //            av_log(s, AV_LOG_DEBUG, "%"PRId64" %d/%d %"PRId64"\n", ts, st->time_base.num, st->time_base.den, ast->frame_offset);
             if(ts < best_ts && st->nb_index_entries){
                 best_ts= ts;
@@ -684,9 +799,17 @@
                 best_stream_index= i;
             }
         }
+#ifdef DEBUGAVINOINTER
+            fprintf(stderr, "best_st %X\n", best_st);
+#endif
         if(!best_st)
-            return -1;
-
+        {
+            // JFT, we don't have a start point, try going where we found MOVI
+            url_fseek(s->pb, avi->movi_list + 8, SEEK_SET);
+            //return -1;
+        }
+        else
+        {
         best_ast = best_st->priv_data;
         best_ts= av_rescale(best_ts, best_st->time_base.den, AV_TIME_BASE * (int64_t)best_st->time_base.num); //FIXME a little ugly
         if(best_ast->remaining)
@@ -696,6 +819,10 @@
             if(i>=0)
                 best_ast->frame_offset= best_st->index_entries[i].timestamp
                                       * FFMAX(1, best_ast->sample_size);
+#ifdef EM8622DEBUG
+            av_log(s, AV_LOG_ERROR, "setting frame_offset to %"PRId64"\n", 
+                best_ast->frame_offset);
+#endif
         }
 
 //        av_log(s, AV_LOG_DEBUG, "%d\n", i);
@@ -712,6 +839,8 @@
                 best_ast->packet_size=
                 best_ast->remaining= best_st->index_entries[i].size;
         }
+
+        }
     }
 
 resync:
@@ -723,7 +852,11 @@
         if(ast->sample_size <= 1) // minorityreport.AVI block_align=1024 sample_size=1 IMA-ADPCM
             size= INT_MAX;
         else if(ast->sample_size < 32)
+#ifdef EM8622
+            size= 512*ast->sample_size;
+#else
             size= 64*ast->sample_size;
+#endif
         else
             size= ast->sample_size;
 
@@ -757,7 +890,12 @@
 //                pkt->dts += ast->start;
             if(ast->sample_size)
                 pkt->dts /= ast->sample_size;
-//av_log(s, AV_LOG_DEBUG, "dts:%"PRId64" offset:%"PRId64" %d/%d smpl_siz:%d base:%d st:%d size:%d\n", pkt->dts, ast->frame_offset, ast->scale, ast->rate, ast->sample_size, AV_TIME_BASE, avi->stream_index, size);
+#ifdef DEBUGAVIDEMUX
+            av_log(NULL, AV_LOG_ERROR, 
+                "dts:%"PRId64" offset:%"PRId64" %d/%d smpl_siz:%d base:%d st:%d size:%d\n",
+                pkt->dts, ast->frame_offset, ast->scale, ast->rate, 
+                ast->sample_size, AV_TIME_BASE, avi->stream_index, size);
+#endif
             pkt->stream_index = avi->stream_index;
 
             if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
@@ -776,13 +914,26 @@
                 pkt->flags |= PKT_FLAG_KEY;
             }
             if(ast->sample_size)
-                ast->frame_offset += pkt->size;
+                ast->frame_offset += (pkt->size+ast->sample_size-1)/ast->sample_size*ast->sample_size;
             else
                 ast->frame_offset++;
+#ifdef EM8622DEBUG
+            av_log(s, AV_LOG_ERROR, "setting frame_offset to %"PRId64"\n", 
+                ast->frame_offset);
+#endif
         }
         ast->remaining -= size;
         if(!ast->remaining){
             avi->stream_index= -1;
+#if 0
+            // NOTE: This was incorrectly comparing the size of the sample instead of the size of the chunk
+			// to determine if we need to eat another byte to align on a WORD
+			// Narflex - but they've changed this in the latest version of FFMPEG so I no longer am sure this is needed
+            if (ast->packet_size & 1) {
+				get_byte(pb);
+				size++;
+			}
+#endif
             ast->packet_size= 0;
         }
 
@@ -810,7 +961,9 @@
            ||(d[0] == 'J' && d[1] == 'U' && d[2] == 'N' && d[3] == 'K')
            ||(d[0] == 'i' && d[1] == 'd' && d[2] == 'x' && d[3] == '1')){
             url_fskip(pb, size);
-//av_log(s, AV_LOG_DEBUG, "SKIP\n");
+#ifdef DEBUGAVIDEMUX
+av_log(s, AV_LOG_DEBUG, "SKIP\n");
+#endif
             goto resync;
         }
 
@@ -848,8 +1001,14 @@
             if(   (st->discard >= AVDISCARD_DEFAULT && size==0)
                /*|| (st->discard >= AVDISCARD_NONKEY && !(pkt->flags & PKT_FLAG_KEY))*/ //FIXME needs a little reordering
                || st->discard >= AVDISCARD_ALL){
-                if(ast->sample_size) ast->frame_offset += pkt->size;
+               // JFT, when discarding use size not packet size
+               // If it is 0 should we increase the frame_offset?
+                if(ast->sample_size) ast->frame_offset += (size+ast->sample_size-1)/ast->sample_size*ast->sample_size;
                 else                 ast->frame_offset++;
+#ifdef EM8622DEBUG
+                av_log(s, AV_LOG_ERROR, "size==0 setting frame_offset to %"PRId64" with %d on stream %d\n",
+                    ast->frame_offset, ast->sample_size, n);
+#endif
                 url_fskip(pb, size);
                 goto resync;
             }
@@ -906,6 +1065,9 @@
     AVIStream *ast;
     unsigned int index, tag, flags, pos, len;
     unsigned last_pos= -1;
+#ifdef EM8622
+    int secondarystreams=0xFFFFFFFF;
+#endif
 
     nb_index_entries = size / 16;
     if (nb_index_entries <= 0)
@@ -941,9 +1103,24 @@
         if(last_pos == pos)
             avi->non_interleaved= 1;
         else
-            av_add_index_entry(st, pos, ast->cum_len / FFMAX(1, ast->sample_size), len, 0, (flags&AVIIF_INDEX) ? AVINDEX_KEYFRAME : 0);
+        {
+#ifdef EM8622
+			if(flags&AVIIF_INDEX && st->codec->codec_type == CODEC_TYPE_VIDEO)
+			{
+                av_add_index_entry(st, pos, ast->cum_len / FFMAX(1, ast->sample_size), len, 0, (flags&AVIIF_INDEX) ? AVINDEX_KEYFRAME : 0);
+				secondarystreams=1<<index;
+			}
+			if(index<32 && st->codec->codec_type != CODEC_TYPE_VIDEO && !(secondarystreams&(1<<index)))
+			{
+				av_add_index_entry(st, pos, ast->cum_len / FFMAX(1, ast->sample_size), len, 0, (flags&AVIIF_INDEX) ? AVINDEX_KEYFRAME : 0);
+				secondarystreams|=1<<index;
+			}
+#else
+			av_add_index_entry(st, pos, ast->cum_len / FFMAX(1, ast->sample_size), len, 0, (flags&AVIIF_INDEX) ? AVINDEX_KEYFRAME : 0);
+#endif
+        }
         if(ast->sample_size)
-            ast->cum_len += len;
+                ast->cum_len += (len+ast->sample_size-1)/ast->sample_size*ast->sample_size;
         else
             ast->cum_len ++;
         last_pos= pos;
@@ -1080,7 +1257,9 @@
                 index++;
         }
 
-//        av_log(s, AV_LOG_DEBUG, "%"PRId64" %d %"PRId64"\n", timestamp, index, st2->index_entries[index].timestamp);
+#ifdef EM8622DEBUG
+        av_log(s, AV_LOG_ERROR, "readseek %"PRId64" %d %"PRId64"\n", timestamp, index, st2->index_entries[index].timestamp);
+#endif
         /* extract the current frame number */
         ast2->frame_offset = st2->index_entries[index].timestamp;
         if(ast2->sample_size)
diff --git a/libavformat/avienc.c b/libavformat/avienc.c
old mode 100644
new mode 100755
diff --git a/libavformat/avio.c b/libavformat/avio.c
old mode 100644
new mode 100755
index 011bc88..b7d3c23
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -206,6 +206,13 @@
     return size;
 }
 
+int url_get_file_handle(URLContext *h)
+{
+    if (!h->prot->url_get_file_handle)
+        return -1;
+    return h->prot->url_get_file_handle(h);
+}
+
 int url_get_max_packet_size(URLContext *h)
 {
     return h->max_packet_size;
diff --git a/libavformat/avio.h b/libavformat/avio.h
old mode 100644
new mode 100755
index d154911..9d32fb0
--- a/libavformat/avio.h
+++ b/libavformat/avio.h
@@ -64,6 +64,8 @@
 #define URL_RDONLY 0
 #define URL_WRONLY 1
 #define URL_RDWR   2
+// Active files are files that are open and being written to (for DVR transcoding)
+#define URL_ACTIVEFILE 1024
 
 typedef int URLInterruptCB(void);
 
@@ -78,6 +80,15 @@
 int64_t url_filesize(URLContext *h);
 
 /**
+ * Return the file descriptor associated with this URL. For RTP, this
+ * will return only the RTP file descriptor, not the RTCP file descriptor.
+ * To get both, use rtp_get_file_handles().
+ *
+ * @return the file descriptor associated with this URL, or <0 on error.
+ */
+int url_get_file_handle(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.
@@ -144,6 +155,7 @@
     int (*url_read_pause)(URLContext *h, int pause);
     int64_t (*url_read_seek)(URLContext *h, int stream_index,
                              int64_t timestamp, int flags);
+    int (*url_get_file_handle)(URLContext *h);
 } URLProtocol;
 
 #if LIBAVFORMAT_VERSION_MAJOR < 53
@@ -389,6 +401,8 @@
 /* udp.c */
 int udp_set_remote_url(URLContext *h, const char *uri);
 int udp_get_local_port(URLContext *h);
+#if (LIBAVFORMAT_VERSION_MAJOR <= 52)
 int udp_get_file_handle(URLContext *h);
+#endif
 
 #endif /* AVFORMAT_AVIO_H */
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
old mode 100644
new mode 100755
index 3143a23..bcf3936
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -27,13 +27,6 @@
 
 #define IO_BUFFER_SIZE 32768
 
-/**
- * Do seeks within this distance ahead of the current buffer by skipping
- * data instead of calling the protocol seek function, for seekable
- * protocols.
- */
-#define SHORT_SEEK_THRESHOLD 4096
-
 static void fill_buffer(ByteIOContext *s);
 
 int init_put_byte(ByteIOContext *s,
@@ -117,7 +110,7 @@
         len = (s->buf_end - s->buf_ptr);
         if (len > size)
             len = size;
-        memcpy(s->buf_ptr, buf, len);
+        av_memcpy(s->buf_ptr, buf, len);
         s->buf_ptr += len;
 
         if (s->buf_ptr >= s->buf_end)
@@ -158,9 +151,8 @@
         offset1 >= 0 && offset1 < (s->buf_end - s->buffer)) {
         /* can do the seek inside the buffer */
         s->buf_ptr = s->buffer + offset1;
-    } else if ((s->is_streamed ||
-               offset1 <= s->buf_end + SHORT_SEEK_THRESHOLD - s->buffer) &&
-               !s->write_flag && offset1 >= 0) {
+    } else if(s->is_streamed && !s->write_flag &&
+              offset1 >= 0 && offset1 < (s->buf_end - s->buffer) + (1<<16)){
         while(s->pos < offset && !s->eof_reached)
             fill_buffer(s);
         if (s->eof_reached)
@@ -417,7 +409,7 @@
                     break;
             }
         } else {
-            memcpy(buf, s->buf_ptr, len);
+            av_memcpy(buf, s->buf_ptr, len);
             buf += len;
             s->buf_ptr += len;
             size -= len;
@@ -440,7 +432,7 @@
     }
     if (len > size)
         len = size;
-    memcpy(buf, s->buf_ptr, len);
+    av_memcpy(buf, s->buf_ptr, len);
     s->buf_ptr += len;
     return len;
 }
@@ -546,7 +538,7 @@
     } else {
         buffer_size = IO_BUFFER_SIZE;
     }
-    buffer = av_malloc(buffer_size);
+    buffer = av_mallocUncached(buffer_size);
     if (!buffer)
         return AVERROR(ENOMEM);
 
@@ -575,7 +567,7 @@
 int url_setbufsize(ByteIOContext *s, int buf_size)
 {
     uint8_t *buffer;
-    buffer = av_malloc(buf_size);
+    buffer = av_mallocUncached(buf_size);
     if (!buffer)
         return AVERROR(ENOMEM);
 
@@ -752,7 +744,7 @@
              return AVERROR(ENOMEM);
         d->allocated_size = new_allocated_size;
     }
-    memcpy(d->buffer + d->pos, buf, buf_size);
+    av_memcpy(d->buffer + d->pos, buf, buf_size);
     d->pos = new_size;
     if (d->pos > d->size)
         d->size = d->pos;
diff --git a/libavformat/avs.c b/libavformat/avs.c
old mode 100644
new mode 100755
diff --git a/libavformat/crcenc.c b/libavformat/crcenc.c
old mode 100644
new mode 100755
diff --git a/libavformat/cutils.c b/libavformat/cutils.c
old mode 100644
new mode 100755
diff --git a/libavformat/daud.c b/libavformat/daud.c
old mode 100644
new mode 100755
diff --git a/libavformat/dv.c b/libavformat/dv.c
old mode 100644
new mode 100755
index 256dcd4..7a0f803
--- a/libavformat/dv.c
+++ b/libavformat/dv.c
@@ -341,7 +341,7 @@
        ppcm[i] = c->audio_buf[i];
     }
     if (c->ach)
-        dv_extract_audio(buf, ppcm, c->sys);
+    	dv_extract_audio(buf, ppcm, c->sys);
     c->abytes += size;
 
     /* We work with 720p frames split in half, thus even frames have
diff --git a/libavformat/dv.h b/libavformat/dv.h
old mode 100644
new mode 100755
diff --git a/libavformat/dvenc.c b/libavformat/dvenc.c
old mode 100644
new mode 100755
index 4551cd5..c87697d
--- a/libavformat/dvenc.c
+++ b/libavformat/dvenc.c
@@ -38,7 +38,7 @@
     const DVprofile*  sys;           /* current DV profile, e.g.: 525/60, 625/50 */
     int               n_ast;         /* number of stereo audio streams (up to 2) */
     AVStream         *ast[2];        /* stereo audio streams */
-    AVFifoBuffer      audio_data[2]; /* FIFO for storing excessive amounts of PCM */
+    AVFifoBuffer     *audio_data[2]; /* FIFO for storing excessive amounts of PCM */
     int               frames;        /* current frame number */
     time_t            start_time;    /* recording start time */
     int               has_audio;     /* frame under contruction has audio */
@@ -189,8 +189,8 @@
                 if (of*2 >= size)
                     continue;
 
-                frame_ptr[d]   = av_fifo_peek(&c->audio_data[channel], of*2+1); // FIXME: maybe we have to admit
-                frame_ptr[d+1] = av_fifo_peek(&c->audio_data[channel], of*2);   //        that DV is a big-endian PCM
+                frame_ptr[d]   = av_fifo_peek(c->audio_data[channel], of*2+1); // FIXME: maybe we have to admit
+                frame_ptr[d+1] = av_fifo_peek(c->audio_data[channel], of*2);   //        that DV is a big-endian PCM
             }
             frame_ptr += 16 * 80; /* 15 Video DIFs + 1 Audio DIF */
         }
@@ -251,12 +251,12 @@
         for (i = 0; i < c->n_ast && st != c->ast[i]; i++);
 
           /* FIXME: we have to have more sensible approach than this one */
-        if (av_fifo_size(&c->audio_data[i]) + data_size >= 100*AVCODEC_MAX_AUDIO_FRAME_SIZE)
+        if (av_fifo_size(c->audio_data[i]) + data_size >= 100*AVCODEC_MAX_AUDIO_FRAME_SIZE)
             av_log(st->codec, AV_LOG_ERROR, "Can't process DV frame #%d. Insufficient video data or severe sync problem.\n", c->frames);
-        av_fifo_generic_write(&c->audio_data[i], data, data_size, NULL);
+        av_fifo_generic_write(c->audio_data[i], data, data_size, NULL);
 
         /* Let us see if we've got enough audio for one DV frame. */
-        c->has_audio |= ((reqasize <= av_fifo_size(&c->audio_data[i])) << i);
+        c->has_audio |= ((reqasize <= av_fifo_size(c->audio_data[i])) << i);
 
         break;
     default:
@@ -269,8 +269,8 @@
         c->has_audio = 0;
         for (i=0; i < c->n_ast; i++) {
             dv_inject_audio(c, i, *frame);
-            av_fifo_drain(&c->audio_data[i], reqasize);
-            c->has_audio |= ((reqasize <= av_fifo_size(&c->audio_data[i])) << i);
+            av_fifo_drain(c->audio_data[i], reqasize);
+            c->has_audio |= ((reqasize <= av_fifo_size(c->audio_data[i])) << i);
         }
 
         c->has_video = 0;
@@ -337,10 +337,10 @@
     c->start_time = (time_t)s->timestamp;
 
     for (i=0; i < c->n_ast; i++) {
-        if (c->ast[i] && av_fifo_init(&c->audio_data[i], 100*AVCODEC_MAX_AUDIO_FRAME_SIZE) < 0) {
+        if (c->ast[i] && !(c->audio_data[i]=av_fifo_alloc(100*AVCODEC_MAX_AUDIO_FRAME_SIZE))) {
             while (i > 0) {
                 i--;
-                av_fifo_free(&c->audio_data[i]);
+                av_fifo_free(c->audio_data[i]);
             }
             goto bail_out;
         }
@@ -356,7 +356,7 @@
 {
     int i;
     for (i=0; i < c->n_ast; i++)
-        av_fifo_free(&c->audio_data[i]);
+        av_fifo_free(c->audio_data[i]);
 }
 
 #if CONFIG_DV_MUXER
diff --git a/libavformat/eacdata.c b/libavformat/eacdata.c
old mode 100644
new mode 100755
diff --git a/libavformat/electronicarts.c b/libavformat/electronicarts.c
old mode 100644
new mode 100755
diff --git a/libavformat/ffm.h b/libavformat/ffm.h
old mode 100644
new mode 100755
diff --git a/libavformat/ffmdec.c b/libavformat/ffmdec.c
old mode 100644
new mode 100755
index e8e1891..535b01a
--- a/libavformat/ffmdec.c
+++ b/libavformat/ffmdec.c
@@ -66,19 +66,38 @@
     if (size <= len)
         return 1;
     pos = url_ftell(s->pb);
+    if (!ffm->write_index) {
+        if (pos == ffm->file_size)
+            return AVERROR_EOF;
+        avail_size = ffm->file_size - pos;
+    } else {
     if (pos == ffm->write_index) {
         /* exactly at the end of stream */
-        return 0;
+        return AVERROR(EAGAIN);
     } else if (pos < ffm->write_index) {
         avail_size = ffm->write_index - pos;
     } else {
         avail_size = (ffm->file_size - pos) + (ffm->write_index - FFM_PACKET_SIZE);
     }
+    }
     avail_size = (avail_size / ffm->packet_size) * (ffm->packet_size - FFM_HEADER_SIZE) + len;
     if (size <= avail_size)
         return 1;
     else
-        return 0;
+        return AVERROR(EAGAIN);
+}
+
+static int ffm_resync(AVFormatContext *s, int state)
+{
+    av_log(s, AV_LOG_ERROR, "resyncing\n");
+    while (state != PACKET_ID) {
+        if (url_feof(s->pb)) {
+            av_log(s, AV_LOG_ERROR, "cannot find FFM syncword\n");
+            return -1;
+        }
+        state = (state << 8) | get_byte(s->pb);
+    }
+    return 0;
 }
 
 /* first is true if we read the frame header */
@@ -87,7 +106,7 @@
 {
     FFMContext *ffm = s->priv_data;
     ByteIOContext *pb = s->pb;
-    int len, fill_size, size1, frame_offset;
+    int len, fill_size, size1, frame_offset, id;
 
     size1 = size;
     while (size > 0) {
@@ -101,7 +120,10 @@
             if (url_ftell(pb) == ffm->file_size)
                 url_fseek(pb, ffm->packet_size, SEEK_SET);
     retry_read:
-            get_be16(pb); /* PACKET_ID */
+            id = get_be16(pb); /* PACKET_ID */
+            if (id != PACKET_ID)
+                if (ffm_resync(s, id) < 0)
+                    return -1;
             fill_size = get_be16(pb);
             ffm->dts = get_be64(pb);
             frame_offset = get_be16(pb);
@@ -143,17 +165,16 @@
 
 //#define DEBUG_SEEK
 
-/* pos is between 0 and file_size - FFM_PACKET_SIZE. It is translated
-   by the write position inside this function */
+/* ensure that acutal seeking happens between FFM_PACKET_SIZE
+   and file_size - FFM_PACKET_SIZE */
 static void ffm_seek1(AVFormatContext *s, int64_t pos1)
 {
     FFMContext *ffm = s->priv_data;
     ByteIOContext *pb = s->pb;
     int64_t pos;
 
-    pos = pos1 + ffm->write_index;
-    if (pos >= ffm->file_size)
-        pos -= (ffm->file_size - FFM_PACKET_SIZE);
+    pos = FFMIN(pos1, ffm->file_size - FFM_PACKET_SIZE);
+    pos = FFMAX(pos, FFM_PACKET_SIZE);
 #ifdef DEBUG_SEEK
     av_log(s, AV_LOG_DEBUG, "seek to %"PRIx64" -> %"PRIx64"\n", pos1, pos);
 #endif
@@ -169,7 +190,7 @@
     url_fskip(pb, 4);
     dts = get_be64(pb);
 #ifdef DEBUG_SEEK
-    av_log(s, AV_LOG_DEBUG, "pts=%0.6f\n", pts / 1000000.0);
+    av_log(s, AV_LOG_DEBUG, "dts=%0.6f\n", dts / 1000000.0);
 #endif
     return dts;
 }
@@ -251,7 +272,8 @@
     /* get also filesize */
     if (!url_is_streamed(pb)) {
         ffm->file_size = url_fsize(pb);
-        adjust_write_index(s);
+        if (ffm->write_index)
+            adjust_write_index(s);
     } else {
         ffm->file_size = (UINT64_C(1) << 63) - 1;
     }
@@ -360,24 +382,21 @@
 {
     int size;
     FFMContext *ffm = s->priv_data;
-    int duration;
-
-    if (url_fsize(s->pb) == FFM_PACKET_SIZE)
-        return -1;
+    int duration, ret;
 
     switch(ffm->read_state) {
     case READ_HEADER:
-        if (!ffm_is_avail_data(s, FRAME_HEADER_SIZE+4)) {
-            return AVERROR(EAGAIN);
-        }
+        if ((ret = ffm_is_avail_data(s, FRAME_HEADER_SIZE+4)) < 0)
+            return ret;
+
         dprintf(s, "pos=%08"PRIx64" spos=%"PRIx64", write_index=%"PRIx64" size=%"PRIx64"\n",
                url_ftell(s->pb), s->pb->pos, ffm->write_index, ffm->file_size);
         if (ffm_read_data(s, ffm->header, FRAME_HEADER_SIZE, 1) !=
             FRAME_HEADER_SIZE)
-            return AVERROR(EAGAIN);
+            return -1;
         if (ffm->header[1] & FLAG_DTS)
             if (ffm_read_data(s, ffm->header+16, 4, 1) != 4)
-                return AVERROR(EAGAIN);
+                return -1;
 #if 0
         av_hexdump_log(s, AV_LOG_DEBUG, ffm->header, FRAME_HEADER_SIZE);
 #endif
@@ -385,9 +404,8 @@
         /* fall thru */
     case READ_DATA:
         size = AV_RB24(ffm->header + 2);
-        if (!ffm_is_avail_data(s, size)) {
-            return AVERROR(EAGAIN);
-        }
+        if ((ret = ffm_is_avail_data(s, size)) < 0)
+            return ret;
 
         duration = AV_RB24(ffm->header + 5);
 
@@ -397,7 +415,7 @@
             av_log(s, AV_LOG_ERROR, "invalid stream index %d\n", pkt->stream_index);
             av_free_packet(pkt);
             ffm->read_state = READ_HEADER;
-            return AVERROR(EAGAIN);
+            return -1;
         }
         pkt->pos = url_ftell(s->pb);
         if (ffm->header[1] & FLAG_KEY_FRAME)
@@ -407,7 +425,7 @@
         if (ffm_read_data(s, pkt->data, size, 0) != size) {
             /* bad case: desynchronized packet. we cancel all the packet loading */
             av_free_packet(pkt);
-            return AVERROR(EAGAIN);
+            return -1;
         }
         pkt->pts = AV_RB64(ffm->header+8);
         if (ffm->header[1] & FLAG_DTS)
@@ -435,8 +453,8 @@
 #endif
     /* find the position using linear interpolation (better than
        dichotomy in typical cases) */
-    pos_min = 0;
-    pos_max = ffm->file_size - 2 * FFM_PACKET_SIZE;
+    pos_min = FFM_PACKET_SIZE;
+    pos_max = ffm->file_size - FFM_PACKET_SIZE;
     while (pos_min <= pos_max) {
         pts_min = get_dts(s, pos_min);
         pts_max = get_dts(s, pos_max);
@@ -459,8 +477,7 @@
         }
     }
     pos = (flags & AVSEEK_FLAG_BACKWARD) ? pos_min : pos_max;
-    if (pos > 0)
-        pos -= FFM_PACKET_SIZE;
+
  found:
     ffm_seek1(s, pos);
 
diff --git a/libavformat/ffmenc.c b/libavformat/ffmenc.c
old mode 100644
new mode 100755
index 9a55264..3de4984
--- a/libavformat/ffmenc.c
+++ b/libavformat/ffmenc.c
@@ -93,8 +93,7 @@
     /* header */
     put_le32(pb, MKTAG('F', 'F', 'M', '1'));
     put_be32(pb, ffm->packet_size);
-    /* XXX: store write position in other file ? */
-    put_be64(pb, ffm->packet_size); /* current write position */
+    put_be64(pb, 0); /* current write position */
 
     put_be32(pb, s->nb_streams);
     bit_rate = 0;
@@ -224,15 +223,6 @@
 
     put_flush_packet(pb);
 
-    if (!url_is_streamed(pb)) {
-        int64_t size;
-        /* update the write offset */
-        size = url_ftell(pb);
-        url_fseek(pb, 8, SEEK_SET);
-        put_be64(pb, size);
-        put_flush_packet(pb);
-    }
-
     return 0;
 }
 
diff --git a/libavformat/file.c b/libavformat/file.c
old mode 100644
new mode 100755
index 88ac4db..074f104
--- a/libavformat/file.c
+++ b/libavformat/file.c
@@ -22,7 +22,7 @@
 #include "libavutil/avstring.h"
 #include "avformat.h"
 #include <fcntl.h>
-#if HAVE_SETMODE
+#if HAVE_SETMODE || defined(__MINGW32__)
 #include <io.h>
 #endif
 #include <unistd.h>
@@ -50,7 +50,42 @@
 #ifdef O_BINARY
     access |= O_BINARY;
 #endif
+#ifdef __MINGW32__
+	// Check for UTF-8 unicode pathname
+	int strl = strlen(filename);
+	wchar_t* wfilename = av_malloc(sizeof(wchar_t) * (1 + strl));
+	int wpos = 0;
+	int i = 0;
+	for (i = 0; i < strl; i++)
+	{
+		wfilename[wpos] = 0;
+		if ((filename[i] & 0x80) == 0)
+		{
+			// ASCII character
+			wfilename[wpos++] = filename[i];
+		}
+		else if (i + 1 < strl && ((filename[i] & 0xE0) == 0xC0) && ((filename[i + 1] & 0xC0) == 0x80))
+		{
+			// two octets for this character
+			wfilename[wpos++] = ((filename[i] & 0x1F) << 6) + (filename[i + 1] & 0x3F);
+			i++;
+		}
+		else if (i + 2 < strl && ((filename[i] & 0xF0) == 0xE0) && ((filename[i + 1] & 0xC0) == 0x80) && 
+			((filename[i + 2] & 0xC0) == 0x80))
+		{
+			// three octets for this character
+			wfilename[wpos++] = ((filename[i] & 0x0F) << 12) + ((filename[i + 1] & 0x3F) << 6) + (filename[i + 2] & 0x3F);
+			i+=2;
+		}
+		else
+			wfilename[wpos++] = filename[i];
+	}
+	wfilename[wpos] = 0;
+	fd = _wopen(wfilename, access, 0666);
+	av_free(wfilename);
+#else
     fd = open(filename, access, 0666);
+#endif
     if (fd < 0)
         return AVERROR(ENOENT);
     h->priv_data = (void *)(size_t)fd;
@@ -60,7 +95,20 @@
 static int file_read(URLContext *h, unsigned char *buf, int size)
 {
     int fd = (size_t)h->priv_data;
-    return read(fd, buf, size);
+    int rv;
+	do
+	{
+		rv = read(fd, buf, size);
+		if (rv <= 0 && ((h->flags & URL_ACTIVEFILE) == URL_ACTIVEFILE))
+		{
+			usleep(20000);
+	        if (url_interrupt_cb())
+	            return -EINTR;
+ 		}
+		else
+			break;
+	} while (1);
+	return rv;
 }
 
 static int file_write(URLContext *h, unsigned char *buf, int size)
@@ -82,6 +130,11 @@
     return close(fd);
 }
 
+static int file_get_handle(URLContext *h)
+{
+    return (intptr_t) h->priv_data;
+}
+
 URLProtocol file_protocol = {
     "file",
     file_open,
@@ -89,6 +142,7 @@
     file_write,
     file_seek,
     file_close,
+    .url_get_file_handle = file_get_handle,
 };
 
 /* pipe protocol */
@@ -120,4 +174,5 @@
     pipe_open,
     file_read,
     file_write,
+    .url_get_file_handle = file_get_handle,
 };
diff --git a/libavformat/flacdec.c b/libavformat/flacdec.c
index 83758b2..39c0f4c 100644
--- a/libavformat/flacdec.c
+++ b/libavformat/flacdec.c
@@ -19,15 +19,35 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavcodec/flac.h"
 #include "avformat.h"
 #include "raw.h"
 #include "id3v2.h"
+#include "oggdec.h"
+
+typedef struct FlacSeekPoint {
+    uint64_t samplenum; // time in the stream (in samples)
+    uint64_t offset; // offset from first frame
+    uint16_t samplecount; // number of samples in that frame
+} FlacSeekPoint;
+
+typedef struct FlacContext {
+    int hasseektable;
+    int firstpacket; // send a dts on first packets after seek
+    uint64_t firstdts;
+    int64_t frameoffset; // Offset of the first frame
+    uint32_t seekcount;
+    FlacSeekPoint *seekpoints;
+} FlacContext;
 
 static int flac_read_header(AVFormatContext *s,
                              AVFormatParameters *ap)
 {
+    FlacContext *flac = s->priv_data;
     uint8_t buf[ID3v2_HEADER_SIZE];
-    int ret;
+    int ret, metadata_last=0, metadata_type, metadata_size, found_streaminfo=0;
+    uint8_t header[4];
+    uint8_t *buffer=NULL;
     AVStream *st = av_new_stream(s, 0);
     if (!st)
         return AVERROR(ENOMEM);
@@ -36,6 +56,11 @@
     st->need_parsing = AVSTREAM_PARSE_FULL;
     /* the parameters will be extracted from the compressed bitstream */
 
+    flac->hasseektable=0;
+    flac->firstpacket=1;
+    flac->firstdts=0;
+    flac->seekcount=0;
+
     /* skip ID3v2 header if found */
     ret = get_buffer(s->pb, buf, ID3v2_HEADER_SIZE);
     if (ret == ID3v2_HEADER_SIZE && ff_id3v2_match(buf)) {
@@ -44,6 +69,120 @@
     } else {
         url_fseek(s->pb, 0, SEEK_SET);
     }
+
+    /* if fLaC marker is not found, assume there is no header */
+    if (get_le32(s->pb) != MKTAG('f','L','a','C')) {
+        url_fseek(s->pb, -4, SEEK_CUR);
+        return 0;
+    }
+
+    /* process metadata blocks */
+    while (!url_feof(s->pb) && !metadata_last) {
+        get_buffer(s->pb, header, 4);
+        ff_flac_parse_block_header(header, &metadata_last, &metadata_type,
+                                   &metadata_size);
+        switch (metadata_type) {
+        /* allocate and read metadata block for supported types */
+        case FLAC_METADATA_TYPE_STREAMINFO:
+        case FLAC_METADATA_TYPE_VORBIS_COMMENT:
+            buffer = av_mallocz(metadata_size + FF_INPUT_BUFFER_PADDING_SIZE);
+            if (!buffer) {
+                return AVERROR_NOMEM;
+            }
+            if (get_buffer(s->pb, buffer, metadata_size) != metadata_size) {
+                av_freep(&buffer);
+                return AVERROR_IO;
+            }
+            break;
+		// SageTV: report picture size and offset for external extraction
+		case FLAC_METADATA_TYPE_PICTURE: {
+			char value[64];
+			uint32_t length;
+			get_le32(s->pb);            // Skip picture type
+			length = get_be32(s->pb);
+			url_fskip(s->pb, length);   // mime type
+			length = get_be32(s->pb);
+			url_fskip(s->pb, length);   // description
+			url_fskip(s->pb, 16);       // DWORDS: width, height, depth, palette size
+			length = get_be32(s->pb);
+			snprintf(value, sizeof(value), "%d", length);
+			av_metadata_set(&s->metadata, "ThumbnailSize", value);
+			snprintf(value, sizeof(value), "%"PRIi64, url_ftell(s->pb));
+			av_metadata_set(&s->metadata, "ThumbnailOffset", value);
+			ret = url_fseek(s->pb, length, SEEK_CUR);
+			if (ret < 0)
+				return ret;
+			}
+			break;
+        case FLAC_METADATA_TYPE_SEEKTABLE:
+            // Each entry is 64 bits sample number, 64bits offset from first frame
+            // 16 bit number of samples
+            {
+                int32_t ind=0;
+                flac->seekcount=metadata_size/18;
+                flac->seekpoints = av_mallocz(flac->seekcount*sizeof(FlacSeekPoint));
+                if (!flac->seekpoints)
+                    return AVERROR(ENOMEM);
+                for(ind=0;ind<flac->seekcount;ind++)
+                {
+                    flac->seekpoints[ind].samplenum=get_be64(s->pb);
+                    flac->seekpoints[ind].offset=get_be64(s->pb);
+                    flac->seekpoints[ind].samplecount=get_be16(s->pb);
+                    metadata_size-=18;
+                }
+                flac->hasseektable=1;
+            }
+            break;
+			break;
+        /* skip metadata block for unsupported types */
+        default:
+            ret = url_fseek(s->pb, metadata_size, SEEK_CUR);
+            if (ret < 0)
+                return ret;
+        }
+
+        if (metadata_type == FLAC_METADATA_TYPE_STREAMINFO) {
+            FLACStreaminfo si;
+            /* STREAMINFO can only occur once */
+            if (found_streaminfo) {
+                av_freep(&buffer);
+                return AVERROR_INVALIDDATA;
+            }
+            if (metadata_size != FLAC_STREAMINFO_SIZE) {
+                av_freep(&buffer);
+                return AVERROR_INVALIDDATA;
+            }
+            found_streaminfo = 1;
+            st->codec->extradata      = buffer;
+            st->codec->extradata_size = metadata_size;
+            buffer = NULL;
+
+            /* get codec params from STREAMINFO header */
+            ff_flac_parse_streaminfo(st->codec, &si, st->codec->extradata);
+
+            /* set time base and duration */
+            if (si.samplerate > 0) {
+                av_set_pts_info(st, 64, 1, si.samplerate);
+                if (si.samples > 0)
+                    st->duration = si.samples;
+            }
+        } else {
+            /* STREAMINFO must be the first block */
+            if (!found_streaminfo) {
+                av_freep(&buffer);
+                return AVERROR_INVALIDDATA;
+            }
+            /* process supported blocks other than STREAMINFO */
+            if (metadata_type == FLAC_METADATA_TYPE_VORBIS_COMMENT) {
+                if (vorbis_comment(s, buffer, metadata_size)) {
+                    av_log(s, AV_LOG_WARNING, "error parsing VorbisComment metadata\n");
+                }
+            }
+            av_freep(&buffer);
+        }
+    }
+    // The index we have built doesn't use the right base
+    flac->frameoffset=url_ftell(s->pb);
     return 0;
 }
 
@@ -59,13 +198,105 @@
     else                                            return AVPROBE_SCORE_MAX/2;
 }
 
+#define FLAC_PACKET_SIZE 1024
+
+static int flac_read_partial_packet(AVFormatContext *s, AVPacket *pkt)
+{
+    FlacContext *flac = s->priv_data;
+    int ret, size;
+
+    size = FLAC_PACKET_SIZE;
+
+    if (av_new_packet(pkt, size) < 0)
+        return AVERROR(EIO);
+
+    if(flac->firstpacket)
+    {
+        pkt->dts=flac->firstdts;
+        flac->firstpacket=0;
+    }
+    pkt->pos= url_ftell(s->pb);
+    pkt->stream_index = 0;
+    ret = get_partial_buffer(s->pb, pkt->data, size);
+    if (ret <= 0) {
+        av_free_packet(pkt);
+        return AVERROR(EIO);
+    }
+    pkt->size = ret;
+    return ret;
+}
+
+static int flac_read_seek(AVFormatContext *s, int stream_index, int64_t sample_time, int flags)
+{
+    FlacContext *flac = s->priv_data;
+    AVStream *st;
+    int i, ret, ind;
+    uint64_t pos;
+    if (stream_index >= s->nb_streams)
+        return -1;
+    if (sample_time < 0)
+        sample_time = 0;
+    st = s->streams[stream_index];
+
+    for(ind=0;ind<flac->seekcount;ind++)
+    {
+        if(flac->seekpoints[ind].samplenum>=sample_time)
+            break;
+    }
+    ind-=1;
+    
+    if(ind<0)
+    {
+        pos=0;
+        flac->firstdts=0;
+    }
+    else
+    {
+        pos=flac->seekpoints[ind].offset;
+        flac->firstdts=flac->seekpoints[ind].samplenum;
+    }
+    pos+=flac->frameoffset;
+
+    if ((ret = url_fseek(s->pb, pos, SEEK_SET)) < 0)
+        return ret;
+
+    flac->firstpacket=1;
+
+    /* for each stream, reset read state */
+    for(i = 0; i < s->nb_streams; i++) {
+        st = s->streams[i];
+
+        if (st->parser) {
+            av_parser_close(st->parser);
+            st->parser = NULL;
+            av_free_packet(&st->cur_pkt);
+        }
+        st->last_IP_pts = AV_NOPTS_VALUE;
+        st->cur_dts = AV_NOPTS_VALUE; /* we set the current DTS to an unspecified origin */
+        st->reference_dts = AV_NOPTS_VALUE;
+        /* fail safe */
+        st->cur_ptr = NULL;
+        st->cur_len = 0;
+    }
+    return 0;
+}
+
+static int flac_read_close(AVFormatContext *s)
+{
+    FlacContext *flac = s->priv_data;
+    av_freep(&flac->seekpoints);
+    return 0;
+}
+
 AVInputFormat flac_demuxer = {
     "flac",
     NULL_IF_CONFIG_SMALL("raw FLAC"),
-    0,
+    sizeof(FlacContext),
     flac_probe,
     flac_read_header,
-    ff_raw_read_partial_packet,
+    flac_read_partial_packet,
+    flac_read_close,
+    flac_read_seek,
     .flags= AVFMT_GENERIC_INDEX,
     .extensions = "flac",
     .value = CODEC_ID_FLAC,
diff --git a/libavformat/flic.c b/libavformat/flic.c
old mode 100644
new mode 100755
diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
old mode 100644
new mode 100755
index 9bc2517..89b5ab4
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -28,6 +28,8 @@
 #include "avformat.h"
 #include "flv.h"
 
+//#define DEBUG_SEEK
+
 typedef struct {
     int wrong_dts; ///< wrong dts due to negative cts
 } FLVContext;
@@ -294,6 +296,106 @@
     return 0;
 }
 
+static int64_t flv_read_timestamp(AVFormatContext *s, int stream_index, int64_t *pos_arg, int64_t pos_limit)
+{
+    int64_t pos, pts;
+	int type, size, flags;
+	int extraBytes[6];
+	int pad;
+	int i,j;
+#ifdef DEBUG_SEEK
+	printf("FLV Seek stream_index=%d pos=0x%llx (%lld)\n", stream_index, *pos_arg, *pos_arg);
+#endif
+    pos = *pos_arg;
+	// Skip 4 bytes for the previous tag size or searching from a size one byte further will read back the same location
+    url_fseek(s->pb, pos + 4, SEEK_SET);
+    for(;;) {
+		// We may not be at a valid point in the stream
+		if (url_feof(s->pb))
+            return AV_NOPTS_VALUE;
+
+		pos = url_ftell(s->pb);
+		if (pos >= pos_limit)
+			return AV_NOPTS_VALUE;
+
+		// To see if we're at a valid point we check to see if the type byte is valid
+		// and if the padding is all zero.
+
+		//prevTagSize = get_be32(s->pb);
+		type = get_byte(s->pb);
+		if (type != 8 && type != 9 && type != 18)
+		{
+			continue;
+		}
+
+#ifdef DEBUG_SEEK
+	printf("FLV Seek found potential type code=%d pos=0x%llx\n", type, pos);
+#endif
+		for (i = 0; i < 6; i++)
+			extraBytes[i] = get_byte(s->pb);
+		pad = 0;
+		for (j = 0; j < 4 && !pad; j++)
+		{
+			pad = get_byte(s->pb);
+			if (pad != 0)
+			{
+				// Now we see if there were any valid type markers in the data we've read. If so
+				// then we'll need to seek back to check that one out further.
+				for (i = 0; i < 6; i++)
+				{
+					if (extraBytes[i] == 8 || extraBytes[i] == 9 || extraBytes[i] == 18)
+					{
+#ifdef DEBUG_SEEK
+	printf("FLV Seek found potential type ...skipping back code=%d pos=0x%llx\n", extraBytes[i], pos + 1 + i);
+#endif
+						url_fseek(s->pb, pos + 1 + i, SEEK_SET);
+						break;
+					}
+				}
+				if (i == 6 && (pad == 8 || pad == 9 || pad == 18))
+				{
+#ifdef DEBUG_SEEK
+	printf("FLV Seek found potential type ...skipping back-2 code=%d pos=0x%llx\n", pad, pos + 7 + j);
+#endif
+					url_fseek(s->pb, pos + 7 + j, SEEK_SET);
+				}
+			}
+		}
+		if (pad) // bad packet
+			continue;
+
+		size = (extraBytes[0] << 16) + (extraBytes[1] << 8) + extraBytes[2];
+		pts = (extraBytes[3] << 16) + (extraBytes[4] << 8) + extraBytes[5];
+
+#ifdef DEBUG_SEEK
+	printf("FLV Seek found stream tag type code=%d size=%d pts=%d\n", type, size, pts);
+#endif
+        // Check to see if the stream type matches
+		if ((type == 8 && s->streams[stream_index]->id == 1) ||
+			(type == 9 && s->streams[stream_index]->id == 0))
+		{
+#ifdef DEBUG_SEEK
+	printf("FLV Seek found matching stream index!\n");
+#endif
+			flags = get_byte(s->pb);
+			// Make sure it's a key frame!
+		    if (type == 8 || ((flags >> 4)==1))
+			{
+#ifdef DEBUG_SEEK
+	printf("FLV Seek found keyframe!\n");
+#endif
+				// Found it!
+				break;
+			}
+			url_fskip(s->pb, size + 3);
+			continue;
+		}
+		url_fskip(s->pb, size + 4);
+    }
+    *pos_arg = pos - 4; // go back the previousTagSize data
+    return pts;
+}
+
 static int flv_get_extradata(AVFormatContext *s, AVStream *st, int size)
 {
     av_free(st->codec->extradata);
@@ -313,7 +415,6 @@
     int64_t dts, pts = AV_NOPTS_VALUE;
     AVStream *st = NULL;
 
- retry:
  for(;;){
     pos = url_ftell(s->pb);
     url_fskip(s->pb, 4); /* size of previous packet */
@@ -381,7 +482,10 @@
  }
 
     // 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){
+	// NOTE: Narflex - do not read in the duration here because it requires seeking to the end of
+	// the stream which may not work right for active files (and we can't detect that at this point since
+	// it's not set yet). Besides, this duration isn't needed since it's also discovered when reading packets
+    if(0 && !url_is_streamed(s->pb) && s->duration==AV_NOPTS_VALUE){
         int size;
         const int64_t pos= url_ftell(s->pb);
         const int64_t fsize= url_fsize(s->pb);
@@ -436,10 +540,14 @@
                         st->codec->channels, st->codec->sample_rate);
             }
 
-            goto retry;
+            return AVERROR(EAGAIN);
         }
     }
 
+    /* skip empty data packets */
+    if (!size)
+        return AVERROR(EAGAIN);
+
     ret= av_get_packet(s->pb, pkt, size);
     if (ret <= 0) {
         return AVERROR(EIO);
@@ -457,6 +565,11 @@
     return ret;
 }
 
+static int flv_read_close(AVFormatContext *s)
+{
+    return 0;
+}
+
 AVInputFormat flv_demuxer = {
     "flv",
     NULL_IF_CONFIG_SMALL("FLV format"),
@@ -464,6 +577,9 @@
     flv_probe,
     flv_read_header,
     flv_read_packet,
+    flv_read_close,
+    NULL,
+    flv_read_timestamp,
     .extensions = "flv",
     .value = CODEC_ID_FLV1,
 };
diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c
old mode 100644
new mode 100755
diff --git a/libavformat/framecrcenc.c b/libavformat/framecrcenc.c
old mode 100644
new mode 100755
diff --git a/libavformat/framehook.c b/libavformat/framehook.c
deleted file mode 100644
index 494b30b..0000000
--- a/libavformat/framehook.c
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Video processing hooks
- * Copyright (c) 2000, 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
- */
-#include <errno.h>
-#include "config.h"
-#include "avformat.h"
-#include "framehook.h"
-
-#if HAVE_DLFCN_H
-#include <dlfcn.h>
-#endif
-
-
-typedef struct FrameHookEntry {
-    struct FrameHookEntry *next;
-    FrameHookConfigureFn Configure;
-    FrameHookProcessFn Process;
-    FrameHookReleaseFn Release;
-    void *ctx;
-} FrameHookEntry;
-
-static FrameHookEntry *first_hook;
-
-/* Returns 0 on OK */
-int frame_hook_add(int argc, char *argv[])
-{
-    void *loaded;
-    FrameHookEntry *fhe, **fhep;
-
-    if (argc < 1) {
-        return ENOENT;
-    }
-
-    loaded = dlopen(argv[0], RTLD_NOW);
-    if (!loaded) {
-        av_log(NULL, AV_LOG_ERROR, "%s\n", dlerror());
-        return -1;
-    }
-
-    fhe = av_mallocz(sizeof(*fhe));
-    if (!fhe) {
-        return AVERROR(ENOMEM);
-    }
-
-    fhe->Configure = dlsym(loaded, "Configure");
-    fhe->Process = dlsym(loaded, "Process");
-    fhe->Release = dlsym(loaded, "Release");    /* Optional */
-
-    if (!fhe->Process) {
-        av_log(NULL, AV_LOG_ERROR, "Failed to find Process entrypoint in %s\n", argv[0]);
-        return AVERROR(ENOENT);
-    }
-
-    if (!fhe->Configure && argc > 1) {
-        av_log(NULL, AV_LOG_ERROR, "Failed to find Configure entrypoint in %s\n", argv[0]);
-        return AVERROR(ENOENT);
-    }
-
-    if (argc > 1 || fhe->Configure) {
-        if (fhe->Configure(&fhe->ctx, argc, argv)) {
-            av_log(NULL, AV_LOG_ERROR, "Failed to Configure %s\n", argv[0]);
-            return AVERROR(EINVAL);
-        }
-    }
-
-    for (fhep = &first_hook; *fhep; fhep = &((*fhep)->next)) {
-    }
-
-    *fhep = fhe;
-
-    return 0;
-}
-
-void frame_hook_process(AVPicture *pict, enum PixelFormat pix_fmt, int width, int height, int64_t pts)
-{
-    if (first_hook) {
-        FrameHookEntry *fhe;
-
-        for (fhe = first_hook; fhe; fhe = fhe->next) {
-            fhe->Process(fhe->ctx, pict, pix_fmt, width, height, pts);
-        }
-    }
-}
-
-void frame_hook_release(void)
-{
-    FrameHookEntry *fhe;
-    FrameHookEntry *fhenext;
-
-    for (fhe = first_hook; fhe; fhe = fhenext) {
-        fhenext = fhe->next;
-        if (fhe->Release)
-            fhe->Release(fhe->ctx);
-        av_free(fhe);
-    }
-
-    first_hook = NULL;
-}
diff --git a/libavformat/framehook.h b/libavformat/framehook.h
deleted file mode 100644
index 0bad606..0000000
--- a/libavformat/framehook.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * video processing hooks
- * copyright (c) 2000, 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_FRAMEHOOK_H
-#define AVFORMAT_FRAMEHOOK_H
-
-#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
- */
-
-#include "libavcodec/avcodec.h"
-
-/* Function must be called 'Configure' */
-typedef int (FrameHookConfigure)(void **ctxp, int argc, char *argv[]);
-typedef FrameHookConfigure *FrameHookConfigureFn;
-extern FrameHookConfigure Configure;
-
-/* Function must be called 'Process' */
-typedef void (FrameHookProcess)(void *ctx, struct AVPicture *pict, enum PixelFormat pix_fmt, int width, int height, int64_t pts);
-typedef FrameHookProcess *FrameHookProcessFn;
-extern FrameHookProcess Process;
-
-/* Function must be called 'Release' */
-typedef void (FrameHookRelease)(void *ctx);
-typedef FrameHookRelease *FrameHookReleaseFn;
-extern FrameHookRelease Release;
-
-int frame_hook_add(int argc, char *argv[]);
-void frame_hook_process(struct AVPicture *pict, enum PixelFormat pix_fmt, int width, int height, int64_t pts);
-void frame_hook_release(void);
-
-#endif /* AVFORMAT_FRAMEHOOK_H */
diff --git a/libavformat/gif.c b/libavformat/gif.c
old mode 100644
new mode 100755
diff --git a/libavformat/gxfenc.c b/libavformat/gxfenc.c
index ca7b0c7..67ee796 100644
--- a/libavformat/gxfenc.c
+++ b/libavformat/gxfenc.c
@@ -29,13 +29,11 @@
 
 typedef struct GXFStreamContext {
     AudioInterleaveContext aic;
-    AVCodecContext *codec;
     uint32_t track_type;
     uint32_t sample_size;
     uint32_t sample_rate;
     uint16_t media_type;
     uint16_t media_info;
-    uint8_t index;
     int frame_rate_index;
     int lines_index;
     int fields;
@@ -45,38 +43,33 @@
     int p_per_gop;
     int b_per_i_or_p; ///< number of B frames per I frame or P frame
     int first_gop_closed;
-    int64_t current_dts;
-    int dts_delay;
+    unsigned order;   ///< interleaving order
 } GXFStreamContext;
 
 typedef struct GXFContext {
     uint32_t nb_fields;
-    uint32_t material_flags;
     uint16_t audio_tracks;
     uint16_t mpeg_tracks;
     int64_t creation_time;
     uint32_t umf_start_offset;
     uint32_t umf_track_offset;
     uint32_t umf_media_offset;
-    uint32_t umf_user_data_offset;
-    uint32_t umf_user_data_size;
     uint32_t umf_length;
     uint16_t umf_track_size;
     uint16_t umf_media_size;
-    int audio_written;
-    int sample_rate;
+    AVRational time_base;
     int flags;
-    AVFormatContext *fc;
+    GXFStreamContext timecode_track;
+    unsigned *flt_entries;    ///< offsets of packets /1024, starts after 2nd video field
+    unsigned flt_entries_nb;
+    uint64_t *map_offsets;    ///< offset of map packets
+    unsigned map_offsets_nb;
+    unsigned packet_count;
 } GXFContext;
 
-typedef struct GXF_Lines {
-    int height;
-    int index;
-} GXF_Lines;
-
-
-/* FIXME check if it is relevant */
-static const GXF_Lines gxf_lines_tab[] = {
+static const struct {
+    int height, index;
+} gxf_lines_tab[] = {
     { 480,  1 }, /* NTSC */
     { 512,  1 }, /* NTSC + VBI */
     { 576,  2 }, /* PAL */
@@ -104,16 +97,17 @@
     { 0, 0 },
 };
 
-#define SERVER_PATH "/space/"
-#define ES_NAME_PATTERN "ES."
+#define SERVER_PATH "EXT:/PDR/default/"
+#define ES_NAME_PATTERN "EXT:/PDR/default/ES."
 
-static int gxf_find_lines_index(GXFStreamContext *ctx)
+static int gxf_find_lines_index(AVStream *st)
 {
+    GXFStreamContext *sc = st->priv_data;
     int i;
 
     for (i = 0; i < 6; ++i) {
-        if (ctx->codec->height == gxf_lines_tab[i].height) {
-            ctx->lines_index = gxf_lines_tab[i].index;
+        if (st->codec->height == gxf_lines_tab[i].height) {
+            sc->lines_index = gxf_lines_tab[i].index;
             return 0;
         }
     }
@@ -166,46 +160,46 @@
     put_byte(pb, 0xE2); /* trailer 2 */
 }
 
-static int gxf_write_mpeg_auxiliary(ByteIOContext *pb, GXFStreamContext *ctx)
+static int gxf_write_mpeg_auxiliary(ByteIOContext *pb, AVStream *st)
 {
+    GXFStreamContext *sc = st->priv_data;
     char buffer[1024];
     int size, starting_line;
 
-    if (ctx->iframes) {
-        ctx->p_per_gop = ctx->pframes / ctx->iframes;
-        if (ctx->pframes % ctx->iframes)
-            ctx->p_per_gop++;
-        if (ctx->pframes) {
-            ctx->b_per_i_or_p = ctx->bframes / ctx->pframes;
-            if (ctx->bframes % ctx->pframes)
-                ctx->b_per_i_or_p++;
+    if (sc->iframes) {
+        sc->p_per_gop = sc->pframes / sc->iframes;
+        if (sc->pframes % sc->iframes)
+            sc->p_per_gop++;
+        if (sc->pframes) {
+            sc->b_per_i_or_p = sc->bframes / sc->pframes;
+            if (sc->bframes % sc->pframes)
+                sc->b_per_i_or_p++;
         }
-        if (ctx->p_per_gop > 9)
-            ctx->p_per_gop = 9; /* ensure value won't take more than one char */
-        if (ctx->b_per_i_or_p > 9)
-            ctx->b_per_i_or_p = 9; /* ensure value won't take more than one char */
+        if (sc->p_per_gop > 9)
+            sc->p_per_gop = 9; /* ensure value won't take more than one char */
+        if (sc->b_per_i_or_p > 9)
+            sc->b_per_i_or_p = 9; /* ensure value won't take more than one char */
     }
-    if (ctx->codec->height == 512 || ctx->codec->height == 608)
+    if (st->codec->height == 512 || st->codec->height == 608)
         starting_line = 7; // VBI
-    else if (ctx->codec->height == 480)
+    else if (st->codec->height == 480)
         starting_line = 20;
     else
         starting_line = 23; // default PAL
 
     size = snprintf(buffer, 1024, "Ver 1\nBr %.6f\nIpg 1\nPpi %d\nBpiop %d\n"
                     "Pix 0\nCf %d\nCg %d\nSl %d\nnl16 %d\nVi 1\nf1 1\n",
-                    (float)ctx->codec->bit_rate, ctx->p_per_gop, ctx->b_per_i_or_p,
-                    ctx->codec->pix_fmt == PIX_FMT_YUV422P ? 2 : 1, ctx->first_gop_closed == 1,
-                    starting_line, ctx->codec->height / 16);
+                    (float)st->codec->bit_rate, sc->p_per_gop, sc->b_per_i_or_p,
+                    st->codec->pix_fmt == PIX_FMT_YUV422P ? 2 : 1, sc->first_gop_closed == 1,
+                    starting_line, st->codec->height / 16);
     put_byte(pb, TRACK_MPG_AUX);
     put_byte(pb, size + 1);
     put_buffer(pb, (uint8_t *)buffer, size + 1);
     return size + 3;
 }
 
-static int gxf_write_timecode_auxiliary(ByteIOContext *pb, GXFStreamContext *ctx)
+static int gxf_write_timecode_auxiliary(ByteIOContext *pb, GXFStreamContext *sc)
 {
-    /* FIXME implement that */
     put_byte(pb, 0); /* fields */
     put_byte(pb, 0);  /* seconds */
     put_byte(pb, 0); /* minutes */
@@ -215,13 +209,15 @@
     return 8;
 }
 
-static int gxf_write_track_description(ByteIOContext *pb, GXFStreamContext *stream)
+static int gxf_write_track_description(AVFormatContext *s, GXFStreamContext *sc, int index)
 {
+    ByteIOContext *pb = s->pb;
     int64_t pos;
+    int mpeg = sc->track_type == 4 || sc->track_type == 9;
 
     /* track description section */
-    put_byte(pb, stream->media_type + 0x80);
-    put_byte(pb, stream->index + 0xC0);
+    put_byte(pb, sc->media_type + 0x80);
+    put_byte(pb, index + 0xC0);
 
     pos = url_ftell(pb);
     put_be16(pb, 0); /* size */
@@ -230,15 +226,15 @@
     put_byte(pb, TRACK_NAME);
     put_byte(pb, strlen(ES_NAME_PATTERN) + 3);
     put_tag(pb, ES_NAME_PATTERN);
-    put_be16(pb, stream->media_info);
+    put_be16(pb, sc->media_info);
     put_byte(pb, 0);
 
-    if (stream->codec->codec_id != CODEC_ID_MPEG2VIDEO) {
+    if (!mpeg) {
         /* auxiliary information */
         put_byte(pb, TRACK_AUX);
         put_byte(pb, 8);
-        if (stream->codec->codec_id == CODEC_ID_NONE)
-            gxf_write_timecode_auxiliary(pb, stream);
+        if (sc->track_type == 3)
+            gxf_write_timecode_auxiliary(pb, sc);
         else
             put_le64(pb, 0);
     }
@@ -248,31 +244,33 @@
     put_byte(pb, 4);
     put_be32(pb, 0);
 
-    if (stream->codec->codec_id == CODEC_ID_MPEG2VIDEO)
-        gxf_write_mpeg_auxiliary(pb, stream);
+    if (mpeg)
+        gxf_write_mpeg_auxiliary(pb, s->streams[index]);
 
     /* frame rate */
     put_byte(pb, TRACK_FPS);
     put_byte(pb, 4);
-    put_be32(pb, stream->frame_rate_index);
+    put_be32(pb, sc->frame_rate_index);
 
     /* lines per frame */
     put_byte(pb, TRACK_LINES);
     put_byte(pb, 4);
-    put_be32(pb, stream->lines_index);
+    put_be32(pb, sc->lines_index);
 
     /* fields per frame */
     put_byte(pb, TRACK_FPF);
     put_byte(pb, 4);
-    put_be32(pb, stream->fields);
+    put_be32(pb, sc->fields);
 
     return updateSize(pb, pos);
 }
 
-static int gxf_write_material_data_section(ByteIOContext *pb, GXFContext *ctx)
+static int gxf_write_material_data_section(AVFormatContext *s)
 {
+    GXFContext *gxf = s->priv_data;
+    ByteIOContext *pb = s->pb;
     int64_t pos;
-    const char *filename = strrchr(ctx->fc->filename, '/');
+    const char *filename = strrchr(s->filename, '/');
 
     pos = url_ftell(pb);
     put_be16(pb, 0); /* size */
@@ -281,7 +279,7 @@
     if (filename)
         filename++;
     else
-        filename = ctx->fc->filename;
+        filename = s->filename;
     put_byte(pb, MAT_NAME);
     put_byte(pb, strlen(SERVER_PATH) + strlen(filename) + 1);
     put_tag(pb, SERVER_PATH);
@@ -296,7 +294,7 @@
     /* last field */
     put_byte(pb, MAT_LAST_FIELD);
     put_byte(pb, 4);
-    put_be32(pb, ctx->nb_fields);
+    put_be32(pb, gxf->nb_fields);
 
     /* reserved */
     put_byte(pb, MAT_MARK_IN);
@@ -305,7 +303,7 @@
 
     put_byte(pb, MAT_MARK_OUT);
     put_byte(pb, 4);
-    put_be32(pb, ctx->nb_fields);
+    put_be32(pb, gxf->nb_fields);
 
     /* estimated size */
     put_byte(pb, MAT_SIZE);
@@ -315,139 +313,165 @@
     return updateSize(pb, pos);
 }
 
-static int gxf_write_track_description_section(ByteIOContext *pb, GXFContext *ctx)
+static int gxf_write_track_description_section(AVFormatContext *s)
 {
+    GXFContext *gxf = s->priv_data;
+    ByteIOContext *pb = s->pb;
     int64_t pos;
     int i;
 
     pos = url_ftell(pb);
     put_be16(pb, 0); /* size */
-    for (i = 0; i < ctx->fc->nb_streams; ++i)
-        gxf_write_track_description(pb, ctx->fc->streams[i]->priv_data);
+    for (i = 0; i < s->nb_streams; ++i)
+        gxf_write_track_description(s, s->streams[i]->priv_data, i);
+
+    gxf_write_track_description(s, &gxf->timecode_track, s->nb_streams);
+
     return updateSize(pb, pos);
 }
 
-static int gxf_write_map_packet(ByteIOContext *pb, GXFContext *ctx)
+static int gxf_write_map_packet(AVFormatContext *s, int rewrite)
 {
+    GXFContext *gxf = s->priv_data;
+    ByteIOContext *pb = s->pb;
     int64_t pos = url_ftell(pb);
 
+    if (!rewrite) {
+        if (!(gxf->map_offsets_nb % 30)) {
+            gxf->map_offsets = av_realloc(gxf->map_offsets,
+                                          (gxf->map_offsets_nb+30)*sizeof(*gxf->map_offsets));
+            if (!gxf->map_offsets) {
+                av_log(s, AV_LOG_ERROR, "could not realloc map offsets\n");
+                return -1;
+            }
+        }
+        gxf->map_offsets[gxf->map_offsets_nb++] = pos; // do not increment here
+    }
+
     gxf_write_packet_header(pb, PKT_MAP);
 
     /* preamble */
     put_byte(pb, 0xE0); /* version */
     put_byte(pb, 0xFF); /* reserved */
 
-    gxf_write_material_data_section(pb, ctx);
-    gxf_write_track_description_section(pb, ctx);
+    gxf_write_material_data_section(s);
+    gxf_write_track_description_section(s);
 
     return updatePacketSize(pb, pos);
 }
 
-#if 0
-static int gxf_write_flt_packet(ByteIOContext *pb, GXFContext *ctx)
+static int gxf_write_flt_packet(AVFormatContext *s)
 {
+    GXFContext *gxf = s->priv_data;
+    ByteIOContext *pb = s->pb;
     int64_t pos = url_ftell(pb);
-    int i;
+    int fields_per_flt = (gxf->nb_fields+1) / 1000 + 1;
+    int flt_entries = gxf->nb_fields / fields_per_flt - 1;
+    int i = 0;
 
     gxf_write_packet_header(pb, PKT_FLT);
 
-    put_le32(pb, 1000); /* number of fields */
-    put_le32(pb, 0); /* number of active flt entries */
+    put_le32(pb, fields_per_flt); /* number of fields */
+    put_le32(pb, flt_entries); /* number of active flt entries */
 
-    for (i = 0; i < 1000; ++i) {
-        put_le32(pb, 0);
+    if (gxf->flt_entries) {
+        for (i = 0; i < flt_entries; i++)
+            put_le32(pb, gxf->flt_entries[(i*fields_per_flt)>>1]);
     }
+
+    for (; i < 1000; i++)
+        put_le32(pb, 0);
+
     return updatePacketSize(pb, pos);
 }
-#endif
 
-static int gxf_write_umf_material_description(ByteIOContext *pb, GXFContext *ctx)
+static int gxf_write_umf_material_description(AVFormatContext *s)
 {
+    GXFContext *gxf = s->priv_data;
+    ByteIOContext *pb = s->pb;
+    int timecode_base = gxf->time_base.den == 60000 ? 60 : 50;
+
     // XXX drop frame
     uint32_t timecode =
-        ctx->nb_fields / (ctx->sample_rate * 3600) % 24 << 24 | // hours
-        ctx->nb_fields / (ctx->sample_rate * 60) % 60   << 16 | // minutes
-        ctx->nb_fields / ctx->sample_rate % 60          <<  8 | // seconds
-        ctx->nb_fields % ctx->sample_rate;                    // fields
+        gxf->nb_fields / (timecode_base * 3600) % 24 << 24 | // hours
+        gxf->nb_fields / (timecode_base * 60) % 60   << 16 | // minutes
+        gxf->nb_fields /  timecode_base % 60         <<  8 | // seconds
+        gxf->nb_fields %  timecode_base;                     // fields
 
-    put_le32(pb, ctx->flags);
-    put_le32(pb, ctx->nb_fields); /* length of the longest track */
-    put_le32(pb, ctx->nb_fields); /* length of the shortest track */
+    put_le32(pb, gxf->flags);
+    put_le32(pb, gxf->nb_fields); /* length of the longest track */
+    put_le32(pb, gxf->nb_fields); /* length of the shortest track */
     put_le32(pb, 0); /* mark in */
-    put_le32(pb, ctx->nb_fields); /* mark out */
+    put_le32(pb, gxf->nb_fields); /* mark out */
     put_le32(pb, 0); /* timecode mark in */
     put_le32(pb, timecode); /* timecode mark out */
-    put_le64(pb, ctx->fc->timestamp); /* modification time */
-    put_le64(pb, ctx->fc->timestamp); /* creation time */
+    put_le64(pb, s->timestamp); /* modification time */
+    put_le64(pb, s->timestamp); /* creation time */
     put_le16(pb, 0); /* reserved */
     put_le16(pb, 0); /* reserved */
-    put_le16(pb, ctx->audio_tracks);
-    put_le16(pb, 0); /* timecode track count */
+    put_le16(pb, gxf->audio_tracks);
+    put_le16(pb, 1); /* timecode track count */
     put_le16(pb, 0); /* reserved */
-    put_le16(pb, ctx->mpeg_tracks);
+    put_le16(pb, gxf->mpeg_tracks);
     return 48;
 }
 
-static int gxf_write_umf_payload(ByteIOContext *pb, GXFContext *ctx)
+static int gxf_write_umf_payload(AVFormatContext *s)
 {
-    put_le32(pb, ctx->umf_length); /* total length of the umf data */
+    GXFContext *gxf = s->priv_data;
+    ByteIOContext *pb = s->pb;
+
+    put_le32(pb, gxf->umf_length); /* total length of the umf data */
     put_le32(pb, 3); /* version */
-    put_le32(pb, ctx->fc->nb_streams);
-    put_le32(pb, ctx->umf_track_offset); /* umf track section offset */
-    put_le32(pb, ctx->umf_track_size);
-    put_le32(pb, ctx->fc->nb_streams);
-    put_le32(pb, ctx->umf_media_offset);
-    put_le32(pb, ctx->umf_media_size);
-    put_le32(pb, ctx->umf_user_data_offset); /* user data offset */
-    put_le32(pb, ctx->umf_user_data_size); /* user data size */
+    put_le32(pb, s->nb_streams+1);
+    put_le32(pb, gxf->umf_track_offset); /* umf track section offset */
+    put_le32(pb, gxf->umf_track_size);
+    put_le32(pb, s->nb_streams+1);
+    put_le32(pb, gxf->umf_media_offset);
+    put_le32(pb, gxf->umf_media_size);
+    put_le32(pb, gxf->umf_length); /* user data offset */
+    put_le32(pb, 0); /* user data size */
     put_le32(pb, 0); /* reserved */
     put_le32(pb, 0); /* reserved */
     return 48;
 }
 
-static int gxf_write_umf_track_description(ByteIOContext *pb, GXFContext *ctx)
+static int gxf_write_umf_track_description(AVFormatContext *s)
 {
+    ByteIOContext *pb = s->pb;
+    GXFContext *gxf = s->priv_data;
     int64_t pos = url_ftell(pb);
-    int tracks[255]={0};
     int i;
 
-    ctx->umf_track_offset = pos - ctx->umf_start_offset;
-    for (i = 0; i < ctx->fc->nb_streams; ++i) {
-        AVStream *st = ctx->fc->streams[i];
-        GXFStreamContext *sc = st->priv_data;
-        int id = 0;
-
-        switch (st->codec->codec_id) {
-        case CODEC_ID_MPEG1VIDEO: id= 'L'; break;
-        case CODEC_ID_MPEG2VIDEO: id= 'M'; break;
-        case CODEC_ID_PCM_S16LE:  id= 'A'; break;
-        case CODEC_ID_DVVIDEO:    id= sc->track_type == 6 ? 'E' : 'D'; break;
-        case CODEC_ID_MJPEG:      id= 'V'; break;
-        default:                  break;
-        }
-        sc->media_info= id << 8;
-        /* FIXME first 10 audio tracks are 0 to 9 next 22 are A to V */
-        sc->media_info |= '0' + (tracks[id]++);
+    gxf->umf_track_offset = pos - gxf->umf_start_offset;
+    for (i = 0; i < s->nb_streams; ++i) {
+        GXFStreamContext *sc = s->streams[i]->priv_data;
         put_le16(pb, sc->media_info);
         put_le16(pb, 1);
     }
+
+    put_le16(pb, gxf->timecode_track.media_info);
+    put_le16(pb, 1);
+
     return url_ftell(pb) - pos;
 }
 
-static int gxf_write_umf_media_mpeg(ByteIOContext *pb, GXFStreamContext *stream)
+static int gxf_write_umf_media_mpeg(ByteIOContext *pb, AVStream *st)
 {
-    if (stream->codec->pix_fmt == PIX_FMT_YUV422P)
+    GXFStreamContext *sc = st->priv_data;
+
+    if (st->codec->pix_fmt == PIX_FMT_YUV422P)
         put_le32(pb, 2);
     else
         put_le32(pb, 1); /* default to 420 */
-    put_le32(pb, stream->first_gop_closed == 1); /* closed = 1, open = 0, unknown = 255 */
+    put_le32(pb, sc->first_gop_closed == 1); /* closed = 1, open = 0, unknown = 255 */
     put_le32(pb, 3); /* top = 1, bottom = 2, frame = 3, unknown = 0 */
     put_le32(pb, 1); /* I picture per GOP */
-    put_le32(pb, stream->p_per_gop);
-    put_le32(pb, stream->b_per_i_or_p);
-    if (stream->codec->codec_id == CODEC_ID_MPEG2VIDEO)
+    put_le32(pb, sc->p_per_gop);
+    put_le32(pb, sc->b_per_i_or_p);
+    if (st->codec->codec_id == CODEC_ID_MPEG2VIDEO)
         put_le32(pb, 2);
-    else if (stream->codec->codec_id == CODEC_ID_MPEG1VIDEO)
+    else if (st->codec->codec_id == CODEC_ID_MPEG1VIDEO)
         put_le32(pb, 1);
     else
         put_le32(pb, 0);
@@ -455,21 +479,20 @@
     return 32;
 }
 
-static int gxf_write_umf_media_timecode(ByteIOContext *pb, GXFStreamContext *track)
+static int gxf_write_umf_media_timecode(ByteIOContext *pb, GXFStreamContext *sc)
 {
-    /* FIXME implement */
-    put_be32(pb, 0); /* drop frame flag */
-    put_be32(pb, 0); /* reserved */
-    put_be32(pb, 0); /* reserved */
-    put_be32(pb, 0); /* reserved */
-    put_be32(pb, 0); /* reserved */
-    put_be32(pb, 0); /* reserved */
-    put_be32(pb, 0); /* reserved */
-    put_be32(pb, 0); /* reserved */
+    put_le32(pb, 1); /* non drop frame */
+    put_le32(pb, 0); /* reserved */
+    put_le32(pb, 0); /* reserved */
+    put_le32(pb, 0); /* reserved */
+    put_le32(pb, 0); /* reserved */
+    put_le32(pb, 0); /* reserved */
+    put_le32(pb, 0); /* reserved */
+    put_le32(pb, 0); /* reserved */
     return 32;
 }
 
-static int gxf_write_umf_media_dv(ByteIOContext *pb, GXFStreamContext *track)
+static int gxf_write_umf_media_dv(ByteIOContext *pb, GXFStreamContext *sc)
 {
     int i;
 
@@ -479,7 +502,7 @@
     return 32;
 }
 
-static int gxf_write_umf_media_audio(ByteIOContext *pb, GXFStreamContext *track)
+static int gxf_write_umf_media_audio(ByteIOContext *pb, GXFStreamContext *sc)
 {
     put_le64(pb, av_dbl2int(1)); /* sound level to begin to */
     put_le64(pb, av_dbl2int(1)); /* sound level to begin to */
@@ -491,7 +514,7 @@
 }
 
 #if 0
-static int gxf_write_umf_media_mjpeg(ByteIOContext *pb, GXFStreamContext *track)
+static int gxf_write_umf_media_mjpeg(ByteIOContext *pb, GXFStreamContext *sc)
 {
     put_be64(pb, 0); /* FIXME FLOAT max chroma quant level */
     put_be64(pb, 0); /* FIXME FLOAT max luma quant level */
@@ -501,50 +524,59 @@
 }
 #endif
 
-static int gxf_write_umf_media_description(ByteIOContext *pb, GXFContext *ctx)
+static int gxf_write_umf_media_description(AVFormatContext *s)
 {
+    GXFContext *gxf = s->priv_data;
+    ByteIOContext *pb = s->pb;
     int64_t pos;
-    int i;
+    int i, j;
 
     pos = url_ftell(pb);
-    ctx->umf_media_offset = pos - ctx->umf_start_offset;
-    for (i = 0; i < ctx->fc->nb_streams; ++i) {
-        GXFStreamContext *sc = ctx->fc->streams[i]->priv_data;
-        char buffer[88];
+    gxf->umf_media_offset = pos - gxf->umf_start_offset;
+    for (i = 0; i <= s->nb_streams; ++i) {
+        GXFStreamContext *sc;
         int64_t startpos, curpos;
-        int path_size = strlen(ES_NAME_PATTERN);
 
-        memset(buffer, 0, 88);
+        if (i == s->nb_streams)
+            sc = &gxf->timecode_track;
+        else
+            sc = s->streams[i]->priv_data;
+
         startpos = url_ftell(pb);
         put_le16(pb, 0); /* length */
         put_le16(pb, sc->media_info);
         put_le16(pb, 0); /* reserved */
         put_le16(pb, 0); /* reserved */
-        put_le32(pb, ctx->nb_fields);
+        put_le32(pb, gxf->nb_fields);
         put_le32(pb, 0); /* attributes rw, ro */
         put_le32(pb, 0); /* mark in */
-        put_le32(pb, ctx->nb_fields); /* mark out */
-        strncpy(buffer, ES_NAME_PATTERN, path_size);
-        put_buffer(pb, (uint8_t *)buffer, path_size);
+        put_le32(pb, gxf->nb_fields); /* mark out */
+        put_buffer(pb, ES_NAME_PATTERN, sizeof(ES_NAME_PATTERN));
         put_be16(pb, sc->media_info);
-        put_buffer(pb, (uint8_t *)buffer + path_size + 2, 88 - path_size - 2);
+        for (j = sizeof(ES_NAME_PATTERN)+2; j < 88; j++)
+            put_byte(pb, 0);
         put_le32(pb, sc->track_type);
         put_le32(pb, sc->sample_rate);
         put_le32(pb, sc->sample_size);
         put_le32(pb, 0); /* reserved */
-        switch (sc->codec->codec_id) {
-        case CODEC_ID_MPEG2VIDEO:
-            gxf_write_umf_media_mpeg(pb, sc);
-            break;
-        case CODEC_ID_PCM_S16LE:
-            gxf_write_umf_media_audio(pb, sc);
-            break;
-        case CODEC_ID_DVVIDEO:
-            gxf_write_umf_media_dv(pb, sc);
-            break;
-        default:
+
+        if (sc == &gxf->timecode_track)
             gxf_write_umf_media_timecode(pb, sc); /* 8 0bytes */
+        else {
+            AVStream *st = s->streams[i];
+            switch (st->codec->codec_id) {
+            case CODEC_ID_MPEG2VIDEO:
+                gxf_write_umf_media_mpeg(pb, st);
+                break;
+            case CODEC_ID_PCM_S16LE:
+                gxf_write_umf_media_audio(pb, sc);
+                break;
+            case CODEC_ID_DVVIDEO:
+                gxf_write_umf_media_dv(pb, sc);
+                break;
+            }
         }
+
         curpos = url_ftell(pb);
         url_fseek(pb, startpos, SEEK_SET);
         put_le16(pb, curpos - startpos);
@@ -553,53 +585,57 @@
     return url_ftell(pb) - pos;
 }
 
-static int gxf_write_umf_user_data(ByteIOContext *pb, GXFContext *ctx)
+static int gxf_write_umf_packet(AVFormatContext *s)
 {
-    int64_t pos = url_ftell(pb);
-    ctx->umf_user_data_offset = pos - ctx->umf_start_offset;
-    put_le32(pb, 20);
-    put_le32(pb,  0);
-    put_le16(pb,  0);
-    put_le16(pb,  0);
-    put_le32(pb,  0);
-    put_byte(pb,  0);
-    put_byte(pb,  0);
-    put_byte(pb,  0);
-    put_byte(pb,  0);
-    return 20;
-}
-
-static int gxf_write_umf_packet(ByteIOContext *pb, GXFContext *ctx)
-{
+    GXFContext *gxf = s->priv_data;
+    ByteIOContext *pb = s->pb;
     int64_t pos = url_ftell(pb);
 
     gxf_write_packet_header(pb, PKT_UMF);
 
     /* preamble */
     put_byte(pb, 3); /* first and last (only) packet */
-    put_be32(pb, ctx->umf_length); /* data length */
+    put_be32(pb, gxf->umf_length); /* data length */
 
-    ctx->umf_start_offset = url_ftell(pb);
-    gxf_write_umf_payload(pb, ctx);
-    gxf_write_umf_material_description(pb, ctx);
-    ctx->umf_track_size = gxf_write_umf_track_description(pb, ctx);
-    ctx->umf_media_size = gxf_write_umf_media_description(pb, ctx);
-    ctx->umf_user_data_size = gxf_write_umf_user_data(pb, ctx);
-    ctx->umf_length = url_ftell(pb) - ctx->umf_start_offset;
+    gxf->umf_start_offset = url_ftell(pb);
+    gxf_write_umf_payload(s);
+    gxf_write_umf_material_description(s);
+    gxf->umf_track_size = gxf_write_umf_track_description(s);
+    gxf->umf_media_size = gxf_write_umf_media_description(s);
+    gxf->umf_length = url_ftell(pb) - gxf->umf_start_offset;
     return updatePacketSize(pb, pos);
 }
 
-#define GXF_NODELAY -5000
-
 static const int GXF_samples_per_frame[] = { 32768, 0 };
 
+static void gxf_init_timecode_track(GXFStreamContext *sc, GXFStreamContext *vsc)
+{
+    if (!vsc)
+        return;
+
+    sc->media_type = vsc->sample_rate == 60 ? 7 : 8;
+    sc->sample_rate = vsc->sample_rate;
+    sc->media_info = ('T'<<8) | '0';
+    sc->track_type = 3;
+    sc->frame_rate_index = vsc->frame_rate_index;
+    sc->lines_index = vsc->lines_index;
+    sc->sample_size = 16;
+    sc->fields = vsc->fields;
+}
+
 static int gxf_write_header(AVFormatContext *s)
 {
     ByteIOContext *pb = s->pb;
     GXFContext *gxf = s->priv_data;
-    int i;
+    GXFStreamContext *vsc = NULL;
+    uint8_t tracks[255] = {0};
+    int i, media_info = 0;
 
-    gxf->fc = s;
+    if (url_is_streamed(pb)) {
+        av_log(s, AV_LOG_ERROR, "gxf muxer does not support streamed output, patch welcome");
+        return -1;
+    }
+
     gxf->flags |= 0x00080000; /* material is simple clip */
     for (i = 0; i < s->nb_streams; ++i) {
         AVStream *st = s->streams[i];
@@ -608,9 +644,7 @@
             return AVERROR(ENOMEM);
         st->priv_data = sc;
 
-        sc->codec = st->codec;
-        sc->index = i;
-        sc->media_type = codec_get_tag(gxf_media_types, sc->codec->codec_id);
+        sc->media_type = codec_get_tag(gxf_media_types, st->codec->codec_id);
         if (st->codec->codec_type == CODEC_TYPE_AUDIO) {
             if (st->codec->codec_id != CODEC_ID_PCM_S16LE) {
                 av_log(s, AV_LOG_ERROR, "only 16 BIT PCM LE allowed for now\n");
@@ -633,40 +667,61 @@
             sc->fields = -2;
             gxf->audio_tracks++;
             gxf->flags |= 0x04000000; /* audio is 16 bit pcm */
-        } else if (sc->codec->codec_type == CODEC_TYPE_VIDEO) {
+            media_info = 'A';
+        } else if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
+            if (i != 0) {
+                av_log(s, AV_LOG_ERROR, "video stream must be the first track\n");
+                return -1;
+            }
             /* FIXME check from time_base ? */
-            if (sc->codec->height == 480 || sc->codec->height == 512) { /* NTSC or NTSC+VBI */
+            if (st->codec->height == 480 || st->codec->height == 512) { /* NTSC or NTSC+VBI */
                 sc->frame_rate_index = 5;
                 sc->sample_rate = 60;
                 gxf->flags |= 0x00000080;
+                gxf->time_base = (AVRational){ 1001, 60000 };
             } else { /* assume PAL */
                 sc->frame_rate_index = 6;
                 sc->media_type++;
                 sc->sample_rate = 50;
                 gxf->flags |= 0x00000040;
+                gxf->time_base = (AVRational){ 1, 50 };
             }
-            gxf->sample_rate = sc->sample_rate;
-            av_set_pts_info(st, 64, 1, st->codec->time_base.den);
-            sc->dts_delay = GXF_NODELAY;
-            if (gxf_find_lines_index(sc) < 0)
+            av_set_pts_info(st, 64, gxf->time_base.num, gxf->time_base.den);
+            if (gxf_find_lines_index(st) < 0)
                 sc->lines_index = -1;
             sc->sample_size = st->codec->bit_rate;
             sc->fields = 2; /* interlaced */
-            switch (sc->codec->codec_id) {
+
+            vsc = sc;
+
+            switch (st->codec->codec_id) {
+            case CODEC_ID_MJPEG:
+                sc->track_type = 1;
+                gxf->flags |= 0x00004000;
+                media_info = 'J';
+                break;
+            case CODEC_ID_MPEG1VIDEO:
+                sc->track_type = 9;
+                gxf->mpeg_tracks++;
+                media_info = 'L';
+                break;
             case CODEC_ID_MPEG2VIDEO:
                 sc->first_gop_closed = -1;
                 sc->track_type = 4;
                 gxf->mpeg_tracks++;
                 gxf->flags |= 0x00008000;
+                media_info = 'M';
                 break;
             case CODEC_ID_DVVIDEO:
-                if (sc->codec->pix_fmt == PIX_FMT_YUV422P) {
+                if (st->codec->pix_fmt == PIX_FMT_YUV422P) {
                     sc->media_type += 2;
                     sc->track_type = 6;
                     gxf->flags |= 0x00002000;
+                    media_info = 'E';
                 } else {
                     sc->track_type = 5;
                     gxf->flags |= 0x00001000;
+                    media_info = 'D';
                 }
                 break;
             default:
@@ -674,19 +729,28 @@
                 return -1;
             }
         }
+        /* FIXME first 10 audio tracks are 0 to 9 next 22 are A to V */
+        sc->media_info = media_info<<8 | ('0'+tracks[media_info]++);
+        sc->order = s->nb_streams - st->index;
     }
 
     if (ff_audio_interleave_init(s, GXF_samples_per_frame, (AVRational){ 1, 48000 }) < 0)
         return -1;
 
-    gxf_write_map_packet(pb, gxf);
-    //gxf_write_flt_packet(pb, gxf);
-    gxf_write_umf_packet(pb, gxf);
+    gxf_init_timecode_track(&gxf->timecode_track, vsc);
+    gxf->flags |= 0x200000; // time code track is non-drop frame
+
+    gxf_write_map_packet(s, 0);
+    gxf_write_flt_packet(s);
+    gxf_write_umf_packet(s);
+
+    gxf->packet_count = 3;
+
     put_flush_packet(pb);
     return 0;
 }
 
-static int gxf_write_eos_packet(ByteIOContext *pb, GXFContext *ctx)
+static int gxf_write_eos_packet(ByteIOContext *pb)
 {
     int64_t pos = url_ftell(pb);
 
@@ -696,20 +760,33 @@
 
 static int gxf_write_trailer(AVFormatContext *s)
 {
-    ByteIOContext *pb = s->pb;
     GXFContext *gxf = s->priv_data;
+    ByteIOContext *pb = s->pb;
     int64_t end;
+    int i;
 
     ff_audio_interleave_close(s);
 
-    gxf_write_eos_packet(pb, gxf);
+    gxf_write_eos_packet(pb);
     end = url_ftell(pb);
     url_fseek(pb, 0, SEEK_SET);
-    /* overwrite map and umf packets with new values */
-    gxf_write_map_packet(pb, gxf);
-    //gxf_write_flt_packet(pb, gxf);
-    gxf_write_umf_packet(pb, gxf);
+    /* overwrite map, flt and umf packets with new values */
+    gxf_write_map_packet(s, 1);
+    gxf_write_flt_packet(s);
+    gxf_write_umf_packet(s);
+    put_flush_packet(pb);
+    /* update duration in all map packets */
+    for (i = 1; i < gxf->map_offsets_nb; i++) {
+        url_fseek(pb, gxf->map_offsets[i], SEEK_SET);
+        gxf_write_map_packet(s, 1);
+        put_flush_packet(pb);
+    }
+
     url_fseek(pb, end, SEEK_SET);
+
+    av_freep(&gxf->flt_entries);
+    av_freep(&gxf->map_offsets);
+
     return 0;
 }
 
@@ -725,26 +802,30 @@
     return (buf[i+1]>>3)&7;
 }
 
-static int gxf_write_media_preamble(ByteIOContext *pb, GXFContext *ctx, AVPacket *pkt, int size)
+static int gxf_write_media_preamble(AVFormatContext *s, AVPacket *pkt, int size)
 {
-    GXFStreamContext *sc = ctx->fc->streams[pkt->stream_index]->priv_data;
+    GXFContext *gxf = s->priv_data;
+    ByteIOContext *pb = s->pb;
+    AVStream *st = s->streams[pkt->stream_index];
+    GXFStreamContext *sc = st->priv_data;
     unsigned field_nb;
     /* If the video is frame-encoded, the frame numbers shall be represented by
      * even field numbers.
      * see SMPTE360M-2004  6.4.2.1.3 Media field number */
-    if (sc->codec->codec_type == CODEC_TYPE_VIDEO) {
-        field_nb = ctx->nb_fields;
+    if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
+        field_nb = gxf->nb_fields;
     } else {
-        field_nb = av_rescale_rnd(pkt->dts, ctx->sample_rate, sc->codec->time_base.den, AV_ROUND_UP);
+        field_nb = av_rescale_rnd(pkt->dts, gxf->time_base.den,
+                                  (int64_t)48000*gxf->time_base.num, AV_ROUND_UP);
     }
 
     put_byte(pb, sc->media_type);
-    put_byte(pb, sc->index);
+    put_byte(pb, st->index);
     put_be32(pb, field_nb);
-    if (sc->codec->codec_type == CODEC_TYPE_AUDIO) {
+    if (st->codec->codec_type == CODEC_TYPE_AUDIO) {
         put_be16(pb, 0);
         put_be16(pb, size / 2);
-    } else if (sc->codec->codec_id == CODEC_ID_MPEG2VIDEO) {
+    } else if (st->codec->codec_id == CODEC_ID_MPEG2VIDEO) {
         int frame_type = gxf_parse_mpeg_frame(sc, pkt->data, pkt->size);
         if (frame_type == FF_I_TYPE) {
             put_byte(pb, 0x0d);
@@ -757,7 +838,7 @@
             sc->pframes++;
         }
         put_be24(pb, size);
-    } else if (sc->codec->codec_id == CODEC_ID_DVVIDEO) {
+    } else if (st->codec->codec_id == CODEC_ID_DVVIDEO) {
         put_byte(pb, size / 4096);
         put_be24(pb, 0);
     } else
@@ -768,40 +849,77 @@
     return 16;
 }
 
-static int gxf_write_media_packet(ByteIOContext *pb, GXFContext *ctx, AVPacket *pkt)
+static int gxf_write_packet(AVFormatContext *s, AVPacket *pkt)
 {
-    GXFStreamContext *sc = ctx->fc->streams[pkt->stream_index]->priv_data;
+    GXFContext *gxf = s->priv_data;
+    ByteIOContext *pb = s->pb;
+    AVStream *st = s->streams[pkt->stream_index];
     int64_t pos = url_ftell(pb);
     int padding = 0;
 
     gxf_write_packet_header(pb, PKT_MEDIA);
-    if (sc->codec->codec_id == CODEC_ID_MPEG2VIDEO && pkt->size % 4) /* MPEG-2 frames must be padded */
+    if (st->codec->codec_id == CODEC_ID_MPEG2VIDEO && pkt->size % 4) /* MPEG-2 frames must be padded */
         padding = 4 - pkt->size % 4;
-    else if (sc->codec->codec_type == CODEC_TYPE_AUDIO)
+    else if (st->codec->codec_type == CODEC_TYPE_AUDIO)
         padding = GXF_AUDIO_PACKET_SIZE - pkt->size;
-    gxf_write_media_preamble(pb, ctx, pkt, pkt->size + padding);
+    gxf_write_media_preamble(s, pkt, pkt->size + padding);
     put_buffer(pb, pkt->data, pkt->size);
     gxf_write_padding(pb, padding);
 
-    if (sc->codec->codec_type == CODEC_TYPE_VIDEO)
-        ctx->nb_fields += 2; // count fields
+    if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
+        if (!(gxf->flt_entries_nb % 500)) {
+            gxf->flt_entries = av_realloc(gxf->flt_entries,
+                                          (gxf->flt_entries_nb+500)*sizeof(*gxf->flt_entries));
+            if (!gxf->flt_entries) {
+                av_log(s, AV_LOG_ERROR, "could not reallocate flt entries\n");
+                return -1;
+            }
+        }
+        gxf->flt_entries[gxf->flt_entries_nb++] = url_ftell(pb) / 1024;
+        gxf->nb_fields += 2; // count fields
+    }
 
-    return updatePacketSize(pb, pos);
+    updatePacketSize(pb, pos);
+
+    gxf->packet_count++;
+    if (gxf->packet_count == 100) {
+        gxf_write_map_packet(s, 0);
+        gxf->packet_count = 0;
+    }
+
+    put_flush_packet(pb);
+
+    return 0;
 }
 
-static int gxf_write_packet(AVFormatContext *s, AVPacket *pkt)
+static int gxf_compare_field_nb(AVFormatContext *s, AVPacket *next, AVPacket *cur)
 {
     GXFContext *gxf = s->priv_data;
+    AVPacket *pkt[2] = { cur, next };
+    int i, field_nb[2];
+    GXFStreamContext *sc[2];
 
-    gxf_write_media_packet(s->pb, gxf, pkt);
-    put_flush_packet(s->pb);
-    return 0;
+    for (i = 0; i < 2; i++) {
+        AVStream *st = s->streams[pkt[i]->stream_index];
+        sc[i] = st->priv_data;
+        if (st->codec->codec_type == CODEC_TYPE_AUDIO) {
+            field_nb[i] = av_rescale_rnd(pkt[i]->dts, gxf->time_base.den,
+                                         (int64_t)48000*gxf->time_base.num, AV_ROUND_UP);
+            field_nb[i] &= ~1; // compare against even field number because audio must be before video
+        } else
+            field_nb[i] = pkt[i]->dts; // dts are field based
+    }
+
+    return field_nb[1] > field_nb[0] ||
+        (field_nb[1] == field_nb[0] && sc[1]->order > sc[0]->order);
 }
 
 static int gxf_interleave_packet(AVFormatContext *s, AVPacket *out, AVPacket *pkt, int flush)
 {
+    if (pkt && s->streams[pkt->stream_index]->codec->codec_type == CODEC_TYPE_VIDEO)
+        pkt->duration = 2; // enforce 2 fields
     return ff_audio_rechunk_interleave(s, out, pkt, flush,
-                               av_interleave_packet_per_dts, ff_interleave_compare_dts);
+                               av_interleave_packet_per_dts, gxf_compare_field_nb);
 }
 
 AVOutputFormat gxf_muxer = {
diff --git a/libavformat/http.c b/libavformat/http.c
old mode 100644
new mode 100755
index 2e6a1db..8f3f4ef
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -345,6 +345,13 @@
     return off;
 }
 
+static int
+http_get_file_handle(URLContext *h)
+{
+    HTTPContext *s = h->priv_data;
+    return url_get_file_handle(s->hd);
+}
+
 URLProtocol http_protocol = {
     "http",
     http_open,
@@ -352,4 +359,5 @@
     http_write,
     http_seek,
     http_close,
+    .url_get_file_handle = http_get_file_handle,
 };
diff --git a/libavformat/idcin.c b/libavformat/idcin.c
old mode 100644
new mode 100755
diff --git a/libavformat/idroq.c b/libavformat/idroq.c
old mode 100644
new mode 100755
diff --git a/libavformat/img2.c b/libavformat/img2.c
old mode 100644
new mode 100755
index 113f431..48f3dfc
--- a/libavformat/img2.c
+++ b/libavformat/img2.c
@@ -428,7 +428,7 @@
     "image2",
     NULL_IF_CONFIG_SMALL("image2 sequence"),
     "",
-    "bmp,jpeg,jpg,ljpg,pam,pbm,pgm,pgmyuv,png,ppm,sgi,tif,tiff,jp2",
+    "bmp,jpeg,jpg,ljpg,pam,pbm,pcx,pgm,pgmyuv,png,ppm,sgi,tif,tiff,jp2",
     sizeof(VideoData),
     CODEC_ID_NONE,
     CODEC_ID_MJPEG,
diff --git a/libavformat/ipmovie.c b/libavformat/ipmovie.c
old mode 100644
new mode 100755
diff --git a/libavformat/isom.c b/libavformat/isom.c
index b78d65e..4ca751f 100644
--- a/libavformat/isom.c
+++ b/libavformat/isom.c
@@ -209,6 +209,9 @@
     { CODEC_ID_DVAUDIO, MKTAG('v', 'd', 'v', 'a') },
     { CODEC_ID_DVAUDIO, MKTAG('d', 'v', 'c', 'a') },
 
+    { CODEC_ID_AC3, MKTAG('s', 'a', 'c', '3') }, /* Dolby AC-3 */
+    { CODEC_ID_EAC3, MKTAG('e', 'c', '-', '3') }, /* Dolby EAC-3 */
+
     { CODEC_ID_WMAV2, MKTAG('W', 'M', 'A', '2') },
 
     { CODEC_ID_NONE, 0 },
diff --git a/libavformat/isom.h b/libavformat/isom.h
old mode 100644
new mode 100755
index 2cad5b8..3e8ab45
--- a/libavformat/isom.h
+++ b/libavformat/isom.h
@@ -24,7 +24,9 @@
 #ifndef AVFORMAT_ISOM_H
 #define AVFORMAT_ISOM_H
 
+#include "avio.h"
 #include "riff.h"
+#include "dv.h"
 
 /* isom.c */
 extern const AVCodecTag ff_mp4_obj_type[];
@@ -35,9 +37,114 @@
 int ff_mov_iso639_to_lang(const char *lang, int mp4);
 int ff_mov_lang_to_iso639(unsigned code, char *to);
 
+/* the QuickTime file format is quite convoluted...
+ * it has lots of index tables, each indexing something in another one...
+ * Here we just use what is needed to read the chunks
+ */
+
 typedef struct {
     int count;
     int duration;
 } MOVStts;
 
+typedef struct {
+    int first;
+    int count;
+    int id;
+} MOVStsc;
+
+typedef struct {
+    uint32_t type;
+    char *path;
+} MOVDref;
+
+typedef struct {
+    uint32_t type;
+    int64_t offset;
+    int64_t size; /* total size (excluding the size and type fields) */
+} MOVAtom;
+
+struct MOVParseTableEntry;
+
+typedef struct {
+    unsigned track_id;
+    uint64_t base_data_offset;
+    uint64_t moof_offset;
+    unsigned stsd_id;
+    unsigned duration;
+    unsigned size;
+    unsigned flags;
+} MOVFragment;
+
+typedef struct {
+    unsigned track_id;
+    unsigned stsd_id;
+    unsigned duration;
+    unsigned size;
+    unsigned flags;
+} MOVTrackExt;
+
+typedef struct MOVStreamContext {
+    ByteIOContext *pb;
+    int ffindex; /* the ffmpeg stream id */
+    int next_chunk;
+    unsigned int chunk_count;
+    int64_t *chunk_offsets;
+    unsigned int stts_count;
+    MOVStts *stts_data;
+    unsigned int ctts_count;
+    MOVStts *ctts_data;
+    unsigned int stsc_count;
+    MOVStsc *stsc_data;
+    int ctts_index;
+    int ctts_sample;
+    unsigned int sample_size;
+    unsigned int sample_count;
+    int *sample_sizes;
+    unsigned int keyframe_count;
+    int *keyframes;
+    int time_scale;
+    int time_rate;
+    int time_offset; ///< time offset of the first edit list entry
+    int current_sample;
+    unsigned int bytes_per_frame;
+    unsigned int samples_per_frame;
+    int dv_audio_container;
+    int pseudo_stream_id; ///< -1 means demux all ids
+    int16_t audio_cid; ///< stsd audio compression id
+    unsigned drefs_count;
+    MOVDref *drefs;
+    int dref_id;
+    int wrong_dts; ///< dts are wrong due to negative ctts
+    int width;  ///< tkhd width
+    int height; ///< tkhd height
+#ifdef EM8622
+    unsigned int index_chunk;
+    unsigned int index_chunk_sample;
+    unsigned int index_stts_sample;
+    unsigned int index_sample_size;
+    int64_t index_current_dts;
+    int64_t index_current_offset;
+    unsigned int index_stts_index;
+    unsigned int index_stsc_index;
+    unsigned int index_stss_index;
+    unsigned int index_keyframe;
+#endif
+} MOVStreamContext;
+
+typedef struct MOVContext {
+    AVFormatContext *fc;
+    int time_scale;
+    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 */
+    DVDemuxContext *dv_demux;
+    AVFormatContext *dv_fctx;
+    int isom; /* 1 if file is ISO Media (mp4/3gp) */
+    MOVFragment fragment; ///< current fragment in moof atom
+    MOVTrackExt *trex_data;
+    unsigned trex_count;
+    int itunes_metadata; ///< metadata are itunes style
+} MOVContext;
+
 #endif /* AVFORMAT_ISOM_H */
diff --git a/libavformat/libavformat.v b/libavformat/libavformat.v
deleted file mode 100644
index da2311e..0000000
--- a/libavformat/libavformat.v
+++ /dev/null
@@ -1,3 +0,0 @@
-LIBAVFORMAT_$MAJOR {
-        global: *;
-};
diff --git a/libavformat/matroska.c b/libavformat/matroska.c
old mode 100644
new mode 100755
index 482a155..e560340
--- a/libavformat/matroska.c
+++ b/libavformat/matroska.c
@@ -45,6 +45,7 @@
     {"A_REAL/ATRC"      , CODEC_ID_ATRAC3},
     {"A_REAL/COOK"      , CODEC_ID_COOK},
 //    {"A_REAL/SIPR"      , CODEC_ID_SIPRO},
+    {"A_TRUEHD"         , CODEC_ID_TRUEHD},
     {"A_TTA1"           , CODEC_ID_TTA},
     {"A_VORBIS"         , CODEC_ID_VORBIS},
     {"A_WAVPACK4"       , CODEC_ID_WAVPACK},
@@ -56,6 +57,7 @@
     {"S_ASS"            , CODEC_ID_SSA},
     {"S_SSA"            , CODEC_ID_SSA},
     {"S_VOBSUB"         , CODEC_ID_DVD_SUBTITLE},
+    {"S_HDMV/PGS"       , CODEC_ID_HDMV_PGS_SUBTITLE},
 
     {"V_DIRAC"          , CODEC_ID_DIRAC},
     {"V_MJPEG"          , CODEC_ID_MJPEG},
diff --git a/libavformat/matroska.h b/libavformat/matroska.h
old mode 100644
new mode 100755
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
old mode 100644
new mode 100755
index 7350562..e026dc2
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -19,6 +19,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+// JFT: Added binblock to improve streaming and remove unneeded copy
+
 /**
  * @file libavformat/matroskadec.c
  * Matroska file demuxer
@@ -56,6 +58,7 @@
     EBML_NEST,
     EBML_PASS,
     EBML_STOP,
+    EBML_BINBLOCK,
 } EbmlType;
 
 typedef const struct EbmlSyntax {
@@ -73,6 +76,7 @@
 
 typedef struct {
     int nb_elem;
+    unsigned int elem_allocated_size; // for av_fast_realloc
     void *elem;
 } EbmlList;
 
@@ -83,6 +87,15 @@
 } EbmlBin;
 
 typedef struct {
+    int      size;
+    uint8_t *data;
+    int64_t  pos;
+    uint64_t track;
+    int16_t  block_time;
+    uint8_t  flags;
+} EbmlBinBlock;
+
+typedef struct {
     uint64_t version;
     uint64_t max_size;
     uint64_t id_length;
@@ -236,12 +249,15 @@
     /* What to skip before effectively reading a packet. */
     int skip_to_keyframe;
     uint64_t skip_to_timecode;
+
+    /* Do we need to add index */
+    int skip_index;
 } MatroskaDemuxContext;
 
 typedef struct {
     uint64_t duration;
     int64_t  reference;
-    EbmlBin  bin;
+    EbmlBinBlock  bin;
 } MatroskaBlock;
 
 typedef struct {
@@ -475,8 +491,8 @@
 };
 
 static EbmlSyntax matroska_blockgroup[] = {
-    { MATROSKA_ID_BLOCK,          EBML_BIN,  0, offsetof(MatroskaBlock,bin) },
-    { MATROSKA_ID_SIMPLEBLOCK,    EBML_BIN,  0, offsetof(MatroskaBlock,bin) },
+    { MATROSKA_ID_BLOCK,          EBML_BINBLOCK,  0, offsetof(MatroskaBlock,bin) },
+    { MATROSKA_ID_SIMPLEBLOCK,    EBML_BINBLOCK,  0, offsetof(MatroskaBlock,bin) },
     { MATROSKA_ID_BLOCKDURATION,  EBML_UINT, 0, offsetof(MatroskaBlock,duration), {.u=AV_NOPTS_VALUE} },
     { MATROSKA_ID_BLOCKREFERENCE, EBML_UINT, 0, offsetof(MatroskaBlock,reference) },
     { 0 }
@@ -631,7 +647,7 @@
 static int ebml_read_binary(ByteIOContext *pb, int length, EbmlBin *bin)
 {
     av_free(bin->data);
-    if (!(bin->data = av_malloc(length)))
+    if (!(bin->data = av_mallocUncached(length)))
         return AVERROR(ENOMEM);
 
     bin->size = length;
@@ -642,6 +658,44 @@
     return 0;
 }
 
+// This version creates the packets directly
+/*
+ * Read the next element as binary data.
+ * 0 is success, < 0 is failure.
+ */
+static int ebml_read_binary_block(MatroskaDemuxContext *matroska, ByteIOContext *pb, 
+    int length, EbmlBinBlock *bin)
+{
+    int size;
+    av_free(bin->data);
+    bin->pos  = url_ftell(pb);
+
+    if((size = ebml_read_num(matroska, pb,
+                         8, &bin->track))<0)
+        return AVERROR(EIO);
+    length-=size;
+
+    if(length<3)
+        return AVERROR(EIO);
+
+    bin->block_time = (get_byte(pb)&0xFF)<<8;
+    bin->block_time |= get_byte(pb)&0xFF;
+    bin->flags = get_byte(pb);
+    length-=3;
+
+    // Pad the data because it could be used for decode in a packet...
+    if (!(bin->data = av_mallocUncached(length+FF_INPUT_BUFFER_PADDING_SIZE)))
+        return AVERROR(ENOMEM);
+    memset(bin->data + length, 0, FF_INPUT_BUFFER_PADDING_SIZE);
+
+    bin->size = length;
+    if (get_buffer(pb, bin->data, length) != length)
+        return AVERROR(EIO);
+
+    return 0;
+}
+
+
 /*
  * Read the next element, but only the header. The contents
  * are supposed to be sub-elements which can be read separately.
@@ -752,14 +806,22 @@
     uint32_t id = syntax->id;
     uint64_t length;
     int res;
-    void *newelem;
 
     data = (char *)data + syntax->data_offset;
     if (syntax->list_elem_size) {
         EbmlList *list = data;
-        newelem = av_realloc(list->elem, (list->nb_elem+1)*syntax->list_elem_size);
-        if (!newelem)
+        // JFT: especially needed when we have no MMU
+        void *newelem = av_fast_realloc(list->elem, &list->elem_allocated_size,
+            (list->nb_elem+1)*syntax->list_elem_size);
+        if(!newelem)
+        {
+            av_log(matroska->ctx, AV_LOG_ERROR, "List allocation failed (size=%d)\n", 
+                   (list->nb_elem+1)*syntax->list_elem_size);
+            av_free(list->elem);
+            list->elem=NULL;
+            list->nb_elem=0;
             return AVERROR(ENOMEM);
+        }
         list->elem = newelem;
         data = (char*)list->elem + list->nb_elem*syntax->list_elem_size;
         memset(data, 0, syntax->list_elem_size);
@@ -783,6 +845,7 @@
                      return ebml_parse_nest(matroska, syntax->def.n, data);
     case EBML_PASS:  return ebml_parse_id(matroska, syntax->def.n, id, data);
     case EBML_STOP:  *(int *)data = 1;      return 1;
+    case EBML_BINBLOCK: res = ebml_read_binary_block(matroska, pb, length, data);  break;
     default:         return url_fseek(pb,length,SEEK_CUR)<0 ? AVERROR(EIO) : 0;
     }
     if (res == AVERROR_INVALIDDATA)
@@ -801,6 +864,7 @@
         case EBML_STR:
         case EBML_UTF8:  av_freep(data_off);                      break;
         case EBML_BIN:   av_freep(&((EbmlBin *)data_off)->data);  break;
+        case EBML_BINBLOCK:   av_freep(&((EbmlBinBlock *)data_off)->data);  break;
         case EBML_NEST:
             if (syntax[i].list_elem_size) {
                 EbmlList *list = data_off;
@@ -1146,6 +1210,8 @@
     Ebml ebml = { 0 };
     AVStream *st;
     int i, j;
+    int indexcount=0;
+	char* metaChapters = 0;
 
     matroska->ctx = s;
 
@@ -1377,7 +1443,7 @@
             if(st->codec->extradata == NULL)
                 return AVERROR(ENOMEM);
             st->codec->extradata_size = track->codec_priv.size;
-            memcpy(st->codec->extradata,
+            av_memcpy(st->codec->extradata,
                    track->codec_priv.data + extradata_offset,
                    track->codec_priv.size);
         }
@@ -1418,7 +1484,7 @@
             if(st->codec->extradata == NULL)
                 break;
             st->codec->extradata_size = attachements[j].bin.size;
-            memcpy(st->codec->extradata, attachements[j].bin.data, attachements[j].bin.size);
+            av_memcpy(st->codec->extradata, attachements[j].bin.data, attachements[j].bin.size);
 
             for (i=0; ff_mkv_mime_tags[i].id != CODEC_ID_NONE; i++) {
                 if (!strncmp(ff_mkv_mime_tags[i].str, attachements[j].mime,
@@ -1431,6 +1497,7 @@
         }
     }
 
+	// NARFLEX: Add metadata for the start of each chapter
     chapters = chapters_list->elem;
     for (i=0; i<chapters_list->nb_elem; i++)
         if (chapters[i].start != AV_NOPTS_VALUE && chapters[i].uid
@@ -1441,8 +1508,21 @@
                            chapters[i].title);
             av_metadata_set(&chapters[i].chapter->metadata,
                             "title", chapters[i].title);
+			if (!metaChapters)
+			{
+				metaChapters = (char*) av_malloc(chapters_list->nb_elem * 16);
+				metaChapters[0] = '\0';
+			}
+
+			av_strlcatf(metaChapters, chapters_list->nb_elem * 16, "%"PRIu64",", chapters[i].start/1000000);
             max_start = chapters[i].start;
         }
+	if (metaChapters)
+	{
+		av_metadata_set(&s->metadata, "chapterpoints", metaChapters);
+		av_free(metaChapters);
+		metaChapters = 0;
+	}
 
     index_list = &matroska->index;
     index = index_list->elem;
@@ -1458,13 +1538,34 @@
             MatroskaTrack *track = matroska_find_track_by_num(matroska,
                                                               pos[j].track);
             if (track && track->stream)
+            {
                 av_add_index_entry(track->stream,
                                    pos[j].pos + matroska->segment_start,
                                    index[i].time/index_scale, 0, 0,
                                    AVINDEX_KEYFRAME);
+                if(track->type == MATROSKA_TRACK_TYPE_VIDEO)
+                    indexcount+=1;
+            }
         }
     }
 
+    // Do we have an index per 30 seconds
+    matroska->skip_index = 0;
+
+#ifdef EM8622
+    if(matroska->duration && indexcount &&
+        matroska->ctx->duration/indexcount<30LL*AV_TIME_BASE)
+    {
+        matroska->skip_index = 1;
+    }
+
+/*    #undef fprintf
+    fprintf(stderr, "Matroska skip index %d (%d %lld %lld)\n",
+        matroska->skip_index, indexcount, matroska->ctx->duration,
+        matroska->ctx->duration/indexcount);
+*/
+#endif
+
     matroska_convert_tags(s);
 
     return 0;
@@ -1478,7 +1579,7 @@
                                    AVPacket *pkt)
 {
     if (matroska->num_packets > 0) {
-        memcpy(pkt, matroska->packets[0], sizeof(AVPacket));
+        av_memcpy(pkt, matroska->packets[0], sizeof(AVPacket));
         av_free(matroska->packets[0]);
         if (matroska->num_packets > 1) {
             void *newpackets;
@@ -1517,27 +1618,34 @@
 static int matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data,
                                 int size, int64_t pos, uint64_t cluster_time,
                                 uint64_t duration, int is_keyframe,
-                                int64_t cluster_pos)
+                                int64_t cluster_pos, uint64_t tracknum, int16_t block_time, uint8_t flags,
+                                uint8_t **dataptr)
 {
     uint64_t timecode = AV_NOPTS_VALUE;
     MatroskaTrack *track;
     int res = 0;
     AVStream *st;
     AVPacket *pkt;
-    int16_t block_time;
+//    int16_t block_time;
     uint32_t *lace_size = NULL;
-    int n, flags, laces = 0;
+//    flags
+    int n, laces = 0;
     uint64_t num;
 
-    if ((n = matroska_ebmlnum_uint(matroska, data, size, &num)) < 0) {
+    uint8_t *startdata=data; // To know when we can build packet with it
+    int startsize=size; // To know when we can build packet with it
+
+/*    if ((n = matroska_ebmlnum_uint(matroska, data, size, &num)) < 0) {
         av_log(matroska->ctx, AV_LOG_ERROR, "EBML block data error\n");
         return res;
     }
     data += n;
-    size -= n;
+    size -= n; */
+
+    num=tracknum;
 
     track = matroska_find_track_by_num(matroska, num);
-    if (size <= 3 || !track || !track->stream) {
+    if (/*size <= 3 ||*/ !track || !track->stream) {
         av_log(matroska->ctx, AV_LOG_INFO,
                "Invalid stream %"PRIu64" or size %u\n", num, size);
         return res;
@@ -1548,10 +1656,11 @@
     if (duration == AV_NOPTS_VALUE)
         duration = track->default_duration / matroska->time_scale;
 
-    block_time = AV_RB16(data);
+/*    block_time = AV_RB16(data);
     data += 2;
     flags = *data++;
-    size -= 3;
+    size -= 3; */
+    
     if (is_keyframe == -1)
         is_keyframe = flags & 0x80 ? PKT_FLAG_KEY : 0;
 
@@ -1561,8 +1670,14 @@
         if (track->type == MATROSKA_TRACK_TYPE_SUBTITLE
             && timecode < track->end_timecode)
             is_keyframe = 0;  /* overlapping subtitles are not key frame */
-        if (is_keyframe)
+        if (is_keyframe && matroska->skip_index==0)
+        {
+#ifdef EM8622
+            // We can't use much memory for our index, (set to 128K per stream)
+            ff_reduce_index(matroska->ctx, st->index);
+#endif
             av_add_index_entry(st, cluster_pos, timecode, 0,0,AVINDEX_KEYFRAME);
+        }
         track->end_timecode = FFMAX(track->end_timecode, timecode+duration);
     }
 
@@ -1697,18 +1812,30 @@
 
                 pkt = av_mallocz(sizeof(AVPacket));
                 /* XXX: prevent data copy... */
-                if (av_new_packet(pkt, pkt_size+offset) < 0) {
-                    av_free(pkt);
-                    res = AVERROR(ENOMEM);
-                    n = laces-1;
-                    break;
+                // JFT: Basic version of no copy for special case...
+                if(offset==0 && pkt_size==startsize && pkt_data==startdata)
+                {
+                    av_init_packet(pkt);
+                    pkt->data = startdata;
+                    pkt->size = startsize;
+                    pkt->destruct = av_destruct_packet;
+                    *dataptr=NULL; // So it won't be freed
                 }
-                if (offset)
-                    memcpy (pkt->data, encodings->compression.settings.data, offset);
-                memcpy (pkt->data+offset, pkt_data, pkt_size);
+                else
+                {
+                    if (av_new_packet(pkt, pkt_size+offset) < 0) {
+                        av_free(pkt);
+                        res = AVERROR(ENOMEM);
+                        n = laces-1;
+                        break;
+                    }
+                    if (offset)
+                        memcpy (pkt->data, encodings->compression.settings.data, offset);
+                    memcpy (pkt->data+offset, pkt_data, pkt_size);
 
-                if (pkt_data != data)
-                    av_free(pkt_data);
+                    if (pkt_data != data)
+                        av_free(pkt_data);
+                }
 
                 if (n == 0)
                     pkt->flags = is_keyframe;
@@ -1770,7 +1897,9 @@
                                      blocks[i].bin.data, blocks[i].bin.size,
                                      blocks[i].bin.pos,  cluster.timecode,
                                      blocks[i].duration, !blocks[i].reference,
-                                     pos);
+                                     pos, blocks[i].bin.track,
+                                     blocks[i].bin.block_time, blocks[i].bin.flags,
+                                     &blocks[i].bin.data);
     ebml_free(matroska_cluster, &cluster);
     if (res < 0)  matroska->done = 1;
     return res;
@@ -1817,14 +1946,14 @@
     index_min = index;
     for (i=0; i < matroska->tracks.nb_elem; i++) {
         tracks[i].end_timecode = 0;
-        if (tracks[i].type == MATROSKA_TRACK_TYPE_SUBTITLE
+/*        if (tracks[i].type == MATROSKA_TRACK_TYPE_SUBTITLE
             && !tracks[i].stream->discard != AVDISCARD_ALL) {
             index_sub = av_index_search_timestamp(tracks[i].stream, st->index_entries[index].timestamp, AVSEEK_FLAG_BACKWARD);
             if (index_sub >= 0
                 && st->index_entries[index_sub].pos < st->index_entries[index_min].pos
                 && st->index_entries[index].timestamp - st->index_entries[index_sub].timestamp < 30000000000/matroska->time_scale)
                 index_min = index_sub;
-        }
+        }*/
     }
 
     url_fseek(s->pb, st->index_entries[index_min].pos, SEEK_SET);
diff --git a/libavformat/metadata.c b/libavformat/metadata.c
index 54c66c9..de44643 100644
--- a/libavformat/metadata.c
+++ b/libavformat/metadata.c
@@ -46,6 +46,32 @@
     return NULL;
 }
 
+static void print_metadata(AVMetadata *m)
+{
+	unsigned int i;
+	
+	if (!m)
+		return;
+	
+	for (i = 0; i < m->count; i++) {
+		if (m->elems[i].key && m->elems[i].value)
+			av_log(NULL, AV_LOG_INFO, "META:%s=%s\n", m->elems[i].key, m->elems[i].value);
+	}
+}
+
+void av_metadata_dump(struct AVFormatContext *ic)
+{
+	unsigned int i;
+	
+	if (!ic)
+		return;
+	
+	print_metadata(ic->metadata);
+	
+	for (i = 0; i < ic->nb_streams; i++)
+		print_metadata(ic->streams[i]->metadata);
+}
+
 int av_metadata_set(AVMetadata **pm, const char *key, const char *value)
 {
     AVMetadata *m= *pm;
diff --git a/libavformat/mm.c b/libavformat/mm.c
old mode 100644
new mode 100755
index 1868e90..6c621ab
--- a/libavformat/mm.c
+++ b/libavformat/mm.c
@@ -162,6 +162,7 @@
         case MM_TYPE_AUDIO :
             if (av_get_packet(s->pb, pkt, length)<0)
                 return AVERROR(ENOMEM);
+            pkt->size = length;
             pkt->stream_index = 1;
             pkt->pts = mm->audio_pts++;
             return 0;
diff --git a/libavformat/mmf.c b/libavformat/mmf.c
old mode 100644
new mode 100755
diff --git a/libavformat/mov.c b/libavformat/mov.c
index c55b8b2..c8ffbd6 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1,6 +1,7 @@
 /*
  * MOV demuxer
  * Copyright (c) 2001 Fabrice Bellard
+ * Copyright (c) 2009 Baptiste Coudurier <baptiste dot coudurier at gmail dot com>
  *
  * This file is part of FFmpeg.
  *
@@ -22,15 +23,18 @@
 #include <limits.h>
 
 //#define DEBUG
+//#define DEBUG8622
+//#define DEBUG_METADATA
+//#define MOV_EXPORT_ALL_METADATA
 
 #include "libavutil/intreadwrite.h"
 #include "libavutil/avstring.h"
 #include "avformat.h"
 #include "riff.h"
 #include "isom.h"
-#include "dv.h"
 #include "libavcodec/mpeg4audio.h"
 #include "libavcodec/mpegaudiodata.h"
+#include "libavcodec/bitstream.h"
 
 #if CONFIG_ZLIB
 #include <zlib.h>
@@ -62,101 +66,6 @@
 #undef NDEBUG
 #include <assert.h>
 
-/* the QuickTime file format is quite convoluted...
- * it has lots of index tables, each indexing something in another one...
- * Here we just use what is needed to read the chunks
- */
-
-typedef struct {
-    int first;
-    int count;
-    int id;
-} MOVStsc;
-
-typedef struct {
-    uint32_t type;
-    char *path;
-} MOVDref;
-
-typedef struct {
-    uint32_t type;
-    int64_t offset;
-    int64_t size; /* total size (excluding the size and type fields) */
-} MOVAtom;
-
-struct MOVParseTableEntry;
-
-typedef struct {
-    unsigned track_id;
-    uint64_t base_data_offset;
-    uint64_t moof_offset;
-    unsigned stsd_id;
-    unsigned duration;
-    unsigned size;
-    unsigned flags;
-} MOVFragment;
-
-typedef struct {
-    unsigned track_id;
-    unsigned stsd_id;
-    unsigned duration;
-    unsigned size;
-    unsigned flags;
-} MOVTrackExt;
-
-typedef struct MOVStreamContext {
-    ByteIOContext *pb;
-    int ffindex; /* the ffmpeg stream id */
-    int next_chunk;
-    unsigned int chunk_count;
-    int64_t *chunk_offsets;
-    unsigned int stts_count;
-    MOVStts *stts_data;
-    unsigned int ctts_count;
-    MOVStts *ctts_data;
-    unsigned int stsc_count;
-    MOVStsc *stsc_data;
-    int ctts_index;
-    int ctts_sample;
-    unsigned int sample_size;
-    unsigned int sample_count;
-    int *sample_sizes;
-    unsigned int keyframe_count;
-    int *keyframes;
-    int time_scale;
-    int time_rate;
-    int time_offset; ///< time offset of the first edit list entry
-    int current_sample;
-    unsigned int bytes_per_frame;
-    unsigned int samples_per_frame;
-    int dv_audio_container;
-    int pseudo_stream_id; ///< -1 means demux all ids
-    int16_t audio_cid; ///< stsd audio compression id
-    unsigned drefs_count;
-    MOVDref *drefs;
-    int dref_id;
-    int wrong_dts; ///< dts are wrong due to negative ctts
-    int width;  ///< tkhd width
-    int height; ///< tkhd height
-} MOVStreamContext;
-
-typedef struct MOVContext {
-    AVFormatContext *fc;
-    int time_scale;
-    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 */
-    AVPaletteControl palette_control;
-    DVDemuxContext *dv_demux;
-    AVFormatContext *dv_fctx;
-    int isom; /* 1 if file is ISO Media (mp4/3gp) */
-    MOVFragment fragment; ///< current fragment in moof atom
-    MOVTrackExt *trex_data;
-    unsigned trex_count;
-    int itunes_metadata; ///< metadata are itunes style
-} MOVContext;
-
-
 /* XXX: it's the first time I make a recursive parser I think... sorry if it's ugly :P */
 
 /* those functions parse an atom */
@@ -172,6 +81,101 @@
 
 static const MOVParseTableEntry mov_default_parse_table[];
 
+static int mov_metadata_trkn(MOVContext *c, ByteIOContext *pb, unsigned len)
+{
+    char buf[16];
+	int data1, data2;
+
+    get_be16(pb); // unknown
+	data1 = get_be16(pb); // Track
+	data2 = get_be16(pb); // TotalTracks
+    snprintf(buf, sizeof(buf), "%d/%d", data1, data2); // track/total tracks
+    av_metadata_set(&c->fc->metadata, "track", buf);
+
+    return 0;
+}
+
+static int mov_read_udta_string(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
+{
+#ifdef MOV_EXPORT_ALL_METADATA
+    char tmp_key[5];
+#endif
+    char str[1024], key2[16], language[4] = {0};
+    const char *key = NULL;
+    uint16_t str_size;
+    int (*parse)(MOVContext*, ByteIOContext*, unsigned) = NULL;
+
+    switch (atom.type) {
+    case MKTAG(0xa9,'n','a','m'): key = "Title";     break;
+    case MKTAG( 'a','A','R','T'): key = "AlbumArtist"; break; // FIXME: Also in 'data' parser
+	case MKTAG(0xa9,'a','u','t'): key = "Author";    break;
+    case MKTAG(0xa9,'A','R','T'): key = "Artist";    break;
+    case MKTAG(0xa9,'w','r','t'): key = "Composer";  break;
+    case MKTAG(0xa9,'c','p','y'): key = "Copyright"; break;
+    case MKTAG(0xa9,'c','m','t'):
+    case MKTAG(0xa9,'i','n','f'): key = "Comment";   break;
+    case MKTAG(0xa9,'a','l','b'): key = "Album";     break;
+    case MKTAG(0xa9,'d','a','y'): key = "Year";      break;
+    case MKTAG(0xa9,'g','e','n'): key = "Genre";     break;
+    case MKTAG(0xa9,'t','o','o'):
+    case MKTAG(0xa9,'e','n','c'): key = "Muxer";     break;
+    case MKTAG( 't','r','k','n'): key = "Track";
+        parse = mov_metadata_trkn; break;
+    }
+
+    if (c->itunes_metadata && atom.size > 8) {
+        int data_size = get_be32(pb);
+        int tag = get_le32(pb);
+        if (tag == MKTAG('d','a','t','a')) {
+            get_be32(pb); // type
+            get_be32(pb); // unknown
+            str_size = data_size - 16;
+            atom.size -= 16;
+        } else return 0;
+    } else if (atom.size > 4 && key && !c->itunes_metadata) {
+        str_size = get_be16(pb); // string length
+        ff_mov_lang_to_iso639(get_be16(pb), language);
+        atom.size -= 4;
+    } else
+        str_size = atom.size;
+
+#ifdef MOV_EXPORT_ALL_METADATA
+    if (!key) {
+        snprintf(tmp_key, 5, "%.4s", (char*)&atom.type);
+        key = tmp_key;
+    }
+#endif
+
+    if (!key)
+        return 0;
+    if (atom.size < 0)
+        return -1;
+
+    str_size = FFMIN3(sizeof(str)-1, str_size, atom.size);
+
+    if (parse)
+        parse(c, pb, str_size);
+    else {
+        get_buffer(pb, str, str_size);
+        str[str_size] = 0;
+		// SageTV: Truncate "year" so it really only reports the year instead of the full date
+		if (!strncasecmp(key, "year", 4) && str_size > 4)
+			str[4] = 0;
+        av_metadata_set(&c->fc->metadata, key, str);
+        if (*language && strcmp(language, "und")) {
+            snprintf(key2, sizeof(key2), "%s-%s", key, language);
+            av_metadata_set(&c->fc->metadata, key2, str);
+        }
+    }
+#ifdef DEBUG_METADATA
+    av_log(c->fc, AV_LOG_DEBUG, "lang \"%3s\" ", language);
+    av_log(c->fc, AV_LOG_DEBUG, "tag \"%s\" value \"%s\" atom \"%.4s\" %d %lld\n",
+           key, str, (char*)&atom.type, str_size, atom.size);
+#endif
+
+    return 0;
+}
+
 static int mov_read_default(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
 {
     int64_t total_size = 0;
@@ -184,6 +188,7 @@
     if (atom.size < 0)
         atom.size = INT64_MAX;
     while(((total_size + 8) < atom.size) && !url_feof(pb) && !err) {
+        int (*parse)(MOVContext*, ByteIOContext*, MOVAtom) = NULL;
         a.size = atom.size;
         a.type=0;
         if(atom.size >= 8) {
@@ -209,17 +214,25 @@
             break;
         a.size = FFMIN(a.size, atom.size - total_size);
 
-        for (i = 0; mov_default_parse_table[i].type != 0
-             && mov_default_parse_table[i].type != a.type; i++)
-            /* empty */;
+        for (i = 0; mov_default_parse_table[i].type; i++)
+            if (mov_default_parse_table[i].type == a.type) {
+                parse = mov_default_parse_table[i].parse;
+                break;
+            }
 
-        if (mov_default_parse_table[i].type == 0) { /* skip leaf atoms data */
+        // container is user data
+        if (!parse && (atom.type == MKTAG('u','d','t','a') ||
+                       atom.type == MKTAG('i','l','s','t')))
+            parse = mov_read_udta_string;
+
+        if (!parse) { /* skip leaf atoms data */
             url_fskip(pb, a.size);
         } else {
             int64_t start_pos = url_ftell(pb);
             int64_t left;
-            err = mov_default_parse_table[i].parse(c, pb, a);
-            if (url_is_streamed(pb) && c->found_moov && c->found_mdat)
+            err = parse(c, pb, a);
+				// DrD: disable stream check as it prevents us from playing active files being downloaded
+            if (/*url_is_streamed(pb) &&*/ c->found_moov && c->found_mdat)
                 break;
             left = a.size - url_ftell(pb) + start_pos;
             if (left > 0) /* skip garbage at atom end */
@@ -313,10 +326,15 @@
 
 static int mov_read_hdlr(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
 {
-    AVStream *st = c->fc->streams[c->fc->nb_streams-1];
+    AVStream *st;
     uint32_t type;
     uint32_t ctype;
 
+    if (c->fc->nb_streams < 1) // meta before first trak
+        return 0;
+
+    st = c->fc->streams[c->fc->nb_streams-1];
+
     get_byte(pb); /* version */
     get_be24(pb); /* flags */
 
@@ -324,21 +342,18 @@
     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]);
-    if(!ctype)
-        c->isom = 1;
+    dprintf(c->fc, "ctype= %.4s (0x%08x)\n", (char*)&ctype, ctype);
+    dprintf(c->fc, "stype= %.4s\n", (char*)&type);
+
     if     (type == MKTAG('v','i','d','e'))
         st->codec->codec_type = CODEC_TYPE_VIDEO;
     else if(type == MKTAG('s','o','u','n'))
         st->codec->codec_type = CODEC_TYPE_AUDIO;
     else if(type == MKTAG('m','1','a',' '))
         st->codec->codec_id = CODEC_ID_MP2;
-    else if(type == MKTAG('s','u','b','p')) {
+    else if(type == MKTAG('s','u','b','p'))
         st->codec->codec_type = CODEC_TYPE_SUBTITLE;
-    }
+
     get_be32(pb); /* component  manufacture */
     get_be32(pb); /* component flags */
     get_be32(pb); /* component flags mask */
@@ -377,11 +392,11 @@
 #define MP4DecSpecificDescrTag          0x05
 
 static const AVCodecTag mp4_audio_types[] = {
-    { CODEC_ID_MP3ON4, 29 }, /* old mp3on4 draft */
-    { CODEC_ID_MP3ON4, 32 }, /* layer 1 */
-    { CODEC_ID_MP3ON4, 33 }, /* layer 2 */
-    { CODEC_ID_MP3ON4, 34 }, /* layer 3 */
-    { CODEC_ID_NONE,    0 },
+    { CODEC_ID_MP3ON4, AOT_PS   }, /* old mp3on4 draft */
+    { CODEC_ID_MP3ON4, AOT_L1   }, /* layer 1 */
+    { CODEC_ID_MP3ON4, AOT_L2   }, /* layer 2 */
+    { CODEC_ID_MP3ON4, AOT_L3   }, /* layer 3 */
+    { CODEC_ID_NONE,   AOT_NULL },
 };
 
 static int mov_read_esds(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
@@ -892,6 +907,7 @@
                 unsigned int color_start, color_count, color_end;
                 unsigned char r, g, b;
 
+                st->codec->palctrl = av_malloc(sizeof(*st->codec->palctrl));
                 if (color_greyscale) {
                     int color_index, color_dec;
                     /* compute the greyscale palette */
@@ -901,7 +917,7 @@
                     color_dec = 256 / (color_count - 1);
                     for (j = 0; j < color_count; j++) {
                         r = g = b = color_index;
-                        c->palette_control.palette[j] =
+                        st->codec->palctrl->palette[j] =
                             (r << 16) | (g << 8) | (b);
                         color_index -= color_dec;
                         if (color_index < 0)
@@ -922,7 +938,7 @@
                         r = color_table[j * 4 + 0];
                         g = color_table[j * 4 + 1];
                         b = color_table[j * 4 + 2];
-                        c->palette_control.palette[j] =
+                        st->codec->palctrl->palette[j] =
                             (r << 16) | (g << 8) | (b);
                     }
                 } else {
@@ -944,12 +960,11 @@
                             get_byte(pb);
                             b = get_byte(pb);
                             get_byte(pb);
-                            c->palette_control.palette[j] =
+                            st->codec->palctrl->palette[j] =
                                 (r << 16) | (g << 8) | (b);
                         }
                     }
                 }
-                st->codec->palctrl = &c->palette_control;
                 st->codec->palctrl->palette_changed = 1;
             } else
                 st->codec->palctrl = NULL;
@@ -1178,7 +1193,9 @@
 {
     AVStream *st;
     MOVStreamContext *sc;
-    unsigned int i, entries, sample_size;
+    unsigned int i, entries, sample_size, field_size, num_bytes;
+    GetBitContext gb;
+    unsigned char* buf;
 
     if (c->fc->nb_streams < 1)
         return 0;
@@ -1188,9 +1205,16 @@
     get_byte(pb); /* version */
     get_be24(pb); /* flags */
 
-    sample_size = get_be32(pb);
-    if (!sc->sample_size) /* do not overwrite value computed in stsd */
-        sc->sample_size = sample_size;
+    if (atom.type == MKTAG('s','t','s','z')) {
+        sample_size = get_be32(pb);
+        if (!sc->sample_size) /* do not overwrite value computed in stsd */
+            sc->sample_size = sample_size;
+        field_size = 32;
+    } else {
+        sample_size = 0;
+        get_be24(pb); /* reserved */
+        field_size = get_byte(pb);
+    }
     entries = get_be32(pb);
 
     dprintf(c->fc, "sample_size = %d sample_count = %d\n", sc->sample_size, entries);
@@ -1199,14 +1223,37 @@
     if (sample_size)
         return 0;
 
+    if (field_size != 4 && field_size != 8 && field_size != 16 && field_size != 32) {
+        av_log(c->fc, AV_LOG_ERROR, "Invalid sample field size %d\n", field_size);
+        return -1;
+    }
+
     if(entries >= UINT_MAX / sizeof(int))
         return -1;
     sc->sample_sizes = av_malloc(entries * sizeof(int));
     if (!sc->sample_sizes)
         return AVERROR(ENOMEM);
 
+    num_bytes = (entries*field_size+4)>>3;
+
+    buf = av_malloc(num_bytes+FF_INPUT_BUFFER_PADDING_SIZE);
+    if (!buf) {
+        av_freep(&sc->sample_sizes);
+        return AVERROR(ENOMEM);
+    }
+
+    if (get_buffer(pb, buf, num_bytes) < num_bytes) {
+        av_freep(&sc->sample_sizes);
+        av_free(buf);
+        return -1;
+    }
+
+    init_get_bits(&gb, buf, 8*num_bytes);
+
     for(i=0; i<entries; i++)
-        sc->sample_sizes[i] = get_be32(pb);
+        sc->sample_sizes[i] = get_bits_long(&gb, field_size);
+
+    av_free(buf);
     return 0;
 }
 
@@ -1311,8 +1358,15 @@
 
     /* adjust first dts according to edit list */
     if (sc->time_offset) {
+        int rescaled = sc->time_offset < 0 ? av_rescale(sc->time_offset, sc->time_scale, mov->time_scale) : sc->time_offset;
         assert(sc->time_offset % sc->time_rate == 0);
-        current_dts = - (sc->time_offset / sc->time_rate);
+        current_dts = - (rescaled / sc->time_rate);
+        if (sc->ctts_data && sc->ctts_data[0].duration / sc->stts_data[0].duration > 16) {
+            /* more than 16 frames delay, dts are likely wrong
+               this happens with files created by iMovie */
+            sc->wrong_dts = 1;
+            st->codec->has_b_frames = 1;
+        }
     }
 
     /* only use old uncompressed audio chunk demuxing when stts specifies it */
@@ -1333,7 +1387,7 @@
             for (j = 0; j < sc->stsc_data[stsc_index].count; j++) {
                 if (current_sample >= sc->sample_count) {
                     av_log(mov->fc, AV_LOG_ERROR, "wrong sample count\n");
-                    goto out;
+                    return;
                 }
                 keyframe = !sc->keyframe_count || current_sample+key_off == sc->keyframes[stss_index];
                 if (keyframe) {
@@ -1344,12 +1398,15 @@
                 sample_size = sc->sample_size > 0 ? sc->sample_size : sc->sample_sizes[current_sample];
                 if(sc->pseudo_stream_id == -1 ||
                    sc->stsc_data[stsc_index].id - 1 == sc->pseudo_stream_id) {
+#ifndef EM8622
                     av_add_index_entry(st, current_offset, current_dts, sample_size, distance,
                                     keyframe ? AVINDEX_KEYFRAME : 0);
+#endif
                     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);
                 }
+
                 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;
@@ -1384,7 +1441,9 @@
             } else
                 chunk_size = chunk_samples * sc->sample_size;
             for (j = 0; j < frames; j++) {
+#ifndef EM8622
                 av_add_index_entry(st, current_offset, current_dts, chunk_size, 0, AVINDEX_KEYFRAME);
+#endif
                 /* get chunk duration */
                 chunk_duration = 0;
                 while (chunk_samples > 0) {
@@ -1408,9 +1467,6 @@
             }
         }
     }
- out:
-    /* adjust sample count to avindex entries */
-    sc->sample_count = st->nb_index_entries;
 }
 
 static int mov_read_trak(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
@@ -1432,17 +1488,16 @@
         return ret;
 
     /* sanity checks */
-    if(sc->chunk_count && (!sc->stts_count || !sc->stsc_count ||
-                           (!sc->sample_size && !sc->sample_count))){
+    if (sc->chunk_count && (!sc->stts_count || !sc->stsc_count ||
+                            (!sc->sample_size && !sc->sample_count))) {
         av_log(c->fc, AV_LOG_ERROR, "stream %d, missing mandatory atoms, broken header\n",
                st->index);
-        sc->sample_count = 0; //ignore track
         return 0;
     }
-    if(!sc->time_rate)
-        sc->time_rate=1;
-    if(!sc->time_scale)
-        sc->time_scale= c->time_scale;
+    if (!sc->time_rate)
+        sc->time_rate = 1;
+    if (!sc->time_scale)
+        sc->time_scale = c->time_scale;
     av_set_pts_info(st, 64, sc->time_rate, sc->time_scale);
 
     if (st->codec->codec_type == CODEC_TYPE_AUDIO &&
@@ -1452,7 +1507,7 @@
         dprintf(c->fc, "frame size %d\n", st->codec->frame_size);
     }
 
-    if(st->duration != AV_NOPTS_VALUE){
+    if (st->duration != AV_NOPTS_VALUE) {
         assert(st->duration % sc->time_rate == 0);
         st->duration /= sc->time_rate;
     }
@@ -1473,20 +1528,63 @@
 #if CONFIG_H263_DECODER
     case CODEC_ID_H263:
 #endif
+#if CONFIG_H264_DECODER
+    case CODEC_ID_H264:
+#endif
 #if CONFIG_MPEG4_DECODER
     case CODEC_ID_MPEG4:
 #endif
-        st->codec->width= 0; /* let decoder init width/height */
+        st->codec->width = 0; /* let decoder init width/height */
         st->codec->height= 0;
         break;
     }
 
+#ifndef EM8622
     /* Do not need those anymore. */
     av_freep(&sc->chunk_offsets);
     av_freep(&sc->stsc_data);
     av_freep(&sc->sample_sizes);
     av_freep(&sc->keyframes);
     av_freep(&sc->stts_data);
+#else
+    sc->current_sample = 0;
+    sc->index_chunk=0;
+    sc->index_chunk_sample=0;
+    sc->index_stts_sample=0;
+    sc->index_current_dts=0;
+    sc->index_current_offset = sc->chunk_offsets[sc->index_chunk];
+    sc->index_stts_index=0;
+    sc->index_stsc_index=0;
+    sc->index_stss_index=0;
+    if (sc->sample_sizes || st->codec->codec_type == CODEC_TYPE_VIDEO || sc->dv_audio_container)
+    {
+        sc->index_sample_size=sc->sample_size > 0 ? sc->sample_size : sc->sample_sizes[sc->current_sample];
+    }
+    else
+    {
+        unsigned int chunk_samples, chunk_size;
+        unsigned int frames = 1;
+        chunk_samples = sc->stsc_data[sc->index_stsc_index].count;
+        if (sc->samples_per_frame > 0 &&
+            (chunk_samples * sc->bytes_per_frame % sc->samples_per_frame == 0)) {
+            if (sc->samples_per_frame < 160)
+                chunk_size = chunk_samples * sc->bytes_per_frame / sc->samples_per_frame;
+            else {
+                chunk_size = sc->bytes_per_frame;
+                frames = chunk_samples / sc->samples_per_frame;
+                chunk_samples = sc->samples_per_frame;
+            }
+        } else
+            chunk_size = chunk_samples * sc->sample_size;
+        sc->index_sample_size = chunk_size;
+    }
+    sc->index_keyframe= !sc->keyframe_count ||
+        sc->current_sample + 1 == sc->keyframes[sc->index_stss_index];;
+    if (sc->index_keyframe) {
+        if (sc->index_stss_index + 1 < sc->keyframe_count)
+            sc->index_stss_index++;
+    }
+#endif
 
     return 0;
 }
@@ -1502,70 +1600,15 @@
 
 static int mov_read_meta(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
 {
-    url_fskip(pb, 4); // version + flags
-    atom.size -= 4;
-    return mov_read_default(c, pb, atom);
-}
-
-static int mov_read_trkn(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
-{
-    char track[16];
-    get_be32(pb); // type
-    get_be32(pb); // unknown
-    snprintf(track, sizeof(track), "%d", get_be32(pb));
-    av_metadata_set(&c->fc->metadata, "track", track);
-    dprintf(c->fc, "%.4s %s\n", (char*)&atom.type, track);
-    return 0;
-}
-
-static int mov_read_udta_string(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
-{
-    char str[1024], key2[16], language[4] = {0};
-    const char *key = NULL;
-    uint16_t str_size;
-
-    if (c->itunes_metadata) {
-        int data_size = get_be32(pb);
-        int tag = get_le32(pb);
-        if (tag == MKTAG('d','a','t','a')) {
-            get_be32(pb); // type
-            get_be32(pb); // unknown
-            str_size = data_size - 16;
-            atom.size -= 16;
-        } else return 0;
-    } else {
-        str_size = get_be16(pb); // string length
-        ff_mov_lang_to_iso639(get_be16(pb), language);
+    while (atom.size > 8) {
+        uint32_t tag = get_le32(pb);
         atom.size -= 4;
+        if (tag == MKTAG('h','d','l','r')) {
+            url_fseek(pb, -8, SEEK_CUR);
+            atom.size += 8;
+            return mov_read_default(c, pb, atom);
+        }
     }
-    switch (atom.type) {
-    case MKTAG(0xa9,'n','a','m'): key = "title";     break;
-    case MKTAG(0xa9,'a','u','t'):
-    case MKTAG(0xa9,'A','R','T'):
-    case MKTAG(0xa9,'w','r','t'): key = "author";    break;
-    case MKTAG(0xa9,'c','p','y'): key = "copyright"; break;
-    case MKTAG(0xa9,'c','m','t'):
-    case MKTAG(0xa9,'i','n','f'): key = "comment";   break;
-    case MKTAG(0xa9,'a','l','b'): key = "album";     break;
-    case MKTAG(0xa9,'d','a','y'): key = "year";      break;
-    case MKTAG(0xa9,'g','e','n'): key = "genre";     break;
-    case MKTAG(0xa9,'t','o','o'):
-    case MKTAG(0xa9,'e','n','c'): key = "muxer";     break;
-    }
-    if (!key)
-        return 0;
-    if (atom.size < 0)
-        return -1;
-
-    str_size = FFMIN3(sizeof(str)-1, str_size, atom.size);
-    get_buffer(pb, str, str_size);
-    str[str_size] = 0;
-    av_metadata_set(&c->fc->metadata, key, str);
-    if (*language && strcmp(language, "und")) {
-        snprintf(key2, sizeof(key2), "%s-%s", key, language);
-        av_metadata_set(&c->fc->metadata, key2, str);
-    }
-    dprintf(c->fc, "%.4s %s %d %lld\n", (char*)&atom.type, str, str_size, atom.size);
     return 0;
 }
 
@@ -1708,7 +1751,7 @@
 static int mov_read_trun(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
 {
     MOVFragment *frag = &c->fragment;
-    AVStream *st;
+    AVStream *st = NULL;
     MOVStreamContext *sc;
     uint64_t offset;
     int64_t dts;
@@ -1716,9 +1759,16 @@
     unsigned entries, first_sample_flags = frag->flags;
     int flags, distance, i;
 
-    if (!frag->track_id || frag->track_id > c->fc->nb_streams)
+    for (i = 0; i < c->fc->nb_streams; i++) {
+        if (c->fc->streams[i]->id == frag->track_id) {
+            st = c->fc->streams[i];
+            break;
+        }
+    }
+    if (!st) {
+        av_log(c->fc, AV_LOG_ERROR, "could not find corresponding track id %d\n", frag->track_id);
         return -1;
-    st = c->fc->streams[frag->track_id-1];
+    }
     sc = st->priv_data;
     if (sc->pseudo_stream_id+1 != frag->stsd_id)
         return 0;
@@ -1770,7 +1820,6 @@
         offset += sample_size;
     }
     frag->moof_offset = offset;
-    sc->sample_count = st->nb_index_entries;
     st->duration = dts;
     return 0;
 }
@@ -1867,12 +1916,12 @@
 
     for(i=0; i<edit_count; i++){
         int time;
-        get_be32(pb); /* Track duration */
+        int duration = get_be32(pb); /* Track duration */
         time = get_be32(pb); /* Media time */
         get_be32(pb); /* Media rate */
-        if (i == 0 && time != -1) {
-            sc->time_offset = time;
-            sc->time_rate = av_gcd(sc->time_rate, time);
+        if (i == 0 && time >= -1) {
+            sc->time_offset = time != -1 ? time : -duration;
+            sc->time_rate = av_gcd(sc->time_rate, FFABS(sc->time_offset));
         }
     }
 
@@ -1884,6 +1933,90 @@
     return 0;
 }
 
+static int mov_read_data(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
+{
+	int data_len, int_data;
+	long data_type;
+	char *key = NULL;
+	char value[32] = "";
+	
+    data_len = get_be32(pb);
+    if (get_le32(pb) != MKTAG( 'd', 'a', 't', 'a' ))
+        return 0;
+
+    switch (atom.type) {
+			// SageTV added tags
+		case MKTAG('g','n','r','e'): key = "GenreIDBase1"; break;
+		case MKTAG('a','A','R','T'): key = "AlbumArtist";  break;
+		case MKTAG('d','i','s','k'): key = "Disk";         break;
+		case MKTAG('c','p','i','l'): key = "Compilation";  break;
+		default:
+			return 0;
+	}
+	
+	/* Data Types
+	 * 0 - integer (variable size)
+	 * 1 - character array
+	 * 
+	 */
+    data_type = get_be32(pb); /* data type */
+    get_be32(pb); /* junk */
+	data_len -= 16;
+	int_data = 0;
+	switch (data_type)
+	{
+		case 0: // ints
+		case 21: // boolean
+			if (data_len >= 6) {
+				int int_data1, int_data2;
+				get_be16(pb);
+				int_data1 = get_be16(pb);
+				int_data2 = get_be16(pb);
+				snprintf(value, sizeof(value), "%d/%d", int_data1, int_data2);
+			} else if (data_len >= 2) {
+				int_data = get_be16(pb);
+				snprintf(value, sizeof(value), "%d", int_data);
+			} else {
+				int_data = get_byte(pb);
+				snprintf(value, sizeof(value), "%d", int_data);
+			}
+			break;
+		default:
+		case 1:		// character data, should be handled by mov_read_udta_string instead!
+			break;
+	}
+	
+	if (key && strlen(value))
+		av_metadata_set(&c->fc->metadata, key, value);
+	
+	return 0;
+}
+
+/* 'meta' cover art atom */
+static int mov_read_covr(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
+{
+    int pos,data_len;
+	char value[64];
+    data_len = get_be32(pb);
+    if (get_le32(pb) != MKTAG( 'd', 'a', 't', 'a' ))
+        return 0;
+	/* Data Types
+	 * 0 - integer (variable size)
+	 * 1 - character array
+	 * 
+	 */
+    get_be32(pb); /* data type */
+    get_be32(pb); /* junk */
+	data_len -= 16;
+	pos = (int) url_ftell(pb);
+	
+	// set metadata: key "Picture", value "pos,data_len"
+	snprintf(value, sizeof(value), "%d,%d", pos, data_len);
+	av_metadata_set(&c->fc->metadata, "Picture", value);
+	
+	return 0;
+}
+
 static const MOVParseTableEntry mov_default_parse_table[] = {
 { MKTAG('a','v','s','s'), mov_read_extradata },
 { MKTAG('c','o','6','4'), mov_read_stco },
@@ -1919,34 +2052,37 @@
 { MKTAG('s','t','s','s'), mov_read_stss }, /* sync sample */
 { MKTAG('s','t','s','z'), mov_read_stsz }, /* sample size */
 { MKTAG('s','t','t','s'), mov_read_stts },
+{ MKTAG('s','t','z','2'), mov_read_stsz }, /* compact sample size */
 { MKTAG('t','k','h','d'), mov_read_tkhd }, /* track header */
 { MKTAG('t','f','h','d'), mov_read_tfhd }, /* track fragment header */
 { MKTAG('t','r','a','k'), mov_read_trak },
 { MKTAG('t','r','a','f'), mov_read_default },
 { MKTAG('t','r','e','x'), mov_read_trex },
-{ MKTAG('t','r','k','n'), mov_read_trkn },
 { MKTAG('t','r','u','n'), mov_read_trun },
 { MKTAG('u','d','t','a'), mov_read_default },
 { MKTAG('w','a','v','e'), mov_read_wave },
 { 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 },
-{ MKTAG(0xa9,'n','a','m'), mov_read_udta_string },
-{ MKTAG(0xa9,'w','r','t'), mov_read_udta_string },
-{ MKTAG(0xa9,'c','p','y'), mov_read_udta_string },
-{ MKTAG(0xa9,'i','n','f'), mov_read_udta_string },
-{ MKTAG(0xa9,'i','n','f'), mov_read_udta_string },
-{ MKTAG(0xa9,'A','R','T'), mov_read_udta_string },
-{ MKTAG(0xa9,'a','l','b'), mov_read_udta_string },
-{ MKTAG(0xa9,'c','m','t'), mov_read_udta_string },
-{ MKTAG(0xa9,'a','u','t'), mov_read_udta_string },
-{ MKTAG(0xa9,'d','a','y'), mov_read_udta_string },
-{ MKTAG(0xa9,'g','e','n'), mov_read_udta_string },
-{ MKTAG(0xa9,'e','n','c'), mov_read_udta_string },
-{ MKTAG(0xa9,'t','o','o'), mov_read_udta_string },
+
+// SageTV added tags
+{ MKTAG('g','n','r','e'), mov_read_data },
+// { MKTAG('a','A','R','T'), mov_read_data }, String? Should be handled by mov_read_udta_string
+{ MKTAG('d','i','s','k'), mov_read_data },
+{ MKTAG('c','p','i','l'), mov_read_data },
+{ MKTAG('c','o','v','r'), mov_read_covr },
+
 { 0, NULL }
 };
 
+static void mov_free_stream_context(MOVStreamContext *sc)
+{
+    if(sc) {
+        av_freep(&sc->ctts_data);
+        av_freep(&sc);
+    }
+}
+
 static int mov_probe(AVProbeData *p)
 {
     unsigned int offset;
@@ -1954,6 +2090,8 @@
     int score = 0;
 
     /* check file header */
+    if (p->buf_size <= 12)
+        return 0;
     offset = 0;
     for(;;) {
         /* ignore invalid offset */
@@ -2001,7 +2139,7 @@
 
     mov->fc = s;
     /* .mov and .mp4 aren't streamable anyway (only progressive download if moov is before mdat) */
-    if(!url_is_streamed(pb))
+    if(!url_is_streamed(pb) && ((((URLContext *) pb->opaque)->flags & URL_ACTIVEFILE) != URL_ACTIVEFILE))
         atom.size = url_fsize(pb);
     else
         atom.size = INT64_MAX;
@@ -2020,18 +2158,144 @@
     return 0;
 }
 
+extern int av_get_packet_nobuf(ByteIOContext *s, AVPacket *pkt, int size, int64_t pos);
+
+#ifdef EM8622
+static int UpdateIndex(MOVStreamContext *sc, AVStream *st)
+{
+//    av_log(NULL, AV_LOG_ERROR, "UpdateIndex(%X) at %d %d %d (sample_size %d)\n", st, sc->current_sample,
+//        sc->index_chunk, sc->index_chunk_sample, sc->sample_size);
+    if (sc->sample_sizes || st->codec->codec_type == CODEC_TYPE_VIDEO || sc->dv_audio_container) 
+    {
+        sc->index_current_offset += sc->index_sample_size;
+        assert(sc->stts_data[sc->index_stts_index].duration % sc->time_rate == 0);
+        sc->index_current_dts += sc->stts_data[sc->index_stts_index].duration / sc->time_rate;
+        sc->index_stts_sample++;
+        if (sc->index_stts_index + 1 < sc->stts_count && 
+            sc->index_stts_sample == sc->stts_data[sc->index_stts_index].count) {
+            sc->index_stts_sample = 0;
+            sc->index_stts_index++;
+        }
+        sc->current_sample++;
+        // Increase sample from chunk
+        sc->index_chunk_sample++;
+        if(sc->index_chunk_sample == sc->stsc_data[sc->index_stsc_index].count)
+        {
+            // We have reached end of current chunk, need to go to next chunk
+            sc->index_chunk++;
+            sc->index_chunk_sample=0;
+            if(sc->index_chunk==sc->chunk_count)
+            {
+                // We have reached end of all chunks..
+                // TODO: update state so end will be detected properly
+                return -1;
+            }
+            sc->index_current_offset = sc->chunk_offsets[sc->index_chunk];
+            if (sc->index_stsc_index + 1 < sc->stsc_count && 
+                sc->index_chunk + 1 == sc->stsc_data[sc->index_stsc_index + 1].first)
+                sc->index_stsc_index++;
+        }
+        if (sc->current_sample >= sc->sample_count) {
+            av_log(NULL, AV_LOG_ERROR, "wrong sample count\n");
+            goto out;
+        }
+        sc->index_keyframe = !sc->keyframe_count || 
+            sc->current_sample + 1 == sc->keyframes[sc->index_stss_index];
+        if (sc->index_keyframe) {
+            if (sc->index_stss_index + 1 < sc->keyframe_count)
+                sc->index_stss_index++;
+        }
+        sc->index_sample_size = 
+            sc->sample_size > 0 ? sc->sample_size : sc->sample_sizes[sc->current_sample];
+    }
+    else
+    {
+        unsigned int chunk_samples, chunk_size;
+        unsigned int frames = 1;
+        /* get chunk duration */
+        int64_t chunk_duration = 0;
+        while (sc->index_chunk_sample < sc->stsc_data[sc->index_stsc_index].count)
+        {
+            chunk_duration += sc->stts_data[sc->index_stts_index].duration / sc->time_rate;
+            sc->index_stts_sample++;
+            if (sc->index_stts_index + 1 < sc->stts_count && 
+                sc->index_stts_sample == sc->stts_data[sc->index_stts_index].count) {
+                sc->index_stts_sample = 0;
+                sc->index_stts_index++;
+            }
+            sc->current_sample++;
+            sc->index_chunk_sample++;
+        }
+        sc->index_current_dts += chunk_duration;
+
+        // Should always be true in index 2 mode...
+        if(sc->index_chunk_sample == sc->stsc_data[sc->index_stsc_index].count)
+        {
+            // We have reached end of current chunk, need to go to next chunk
+            sc->index_chunk++;
+            sc->index_chunk_sample=0;
+            if(sc->index_chunk==sc->chunk_count)
+            {
+                // We have reached end of all chunks..
+                // TODO: update state so end will be detected properly
+                return -1;
+            }
+            sc->index_current_offset = sc->chunk_offsets[sc->index_chunk];
+            if (sc->index_stsc_index + 1 < sc->stsc_count && 
+                sc->index_chunk + 1 == sc->stsc_data[sc->index_stsc_index + 1].first)
+                sc->index_stsc_index++;
+        }
+        if (sc->current_sample >= sc->sample_count) {
+            av_log(NULL, AV_LOG_ERROR, "wrong sample count\n");
+            goto out;
+        }
+        sc->index_keyframe = !sc->keyframe_count || 
+            sc->current_sample + 1 == sc->keyframes[sc->index_stss_index];
+        if (sc->index_keyframe) {
+            if (sc->index_stss_index + 1 < sc->keyframe_count)
+                sc->index_stss_index++;
+        }
+        // Use the chunk size instead
+        chunk_samples = sc->stsc_data[sc->index_stsc_index].count;
+        if (sc->samples_per_frame > 0 &&
+            (chunk_samples * sc->bytes_per_frame % sc->samples_per_frame == 0)) {
+            if (sc->samples_per_frame < 160)
+                chunk_size = chunk_samples * sc->bytes_per_frame / sc->samples_per_frame;
+            else {
+                chunk_size = sc->bytes_per_frame;
+                frames = chunk_samples / sc->samples_per_frame;
+                chunk_samples = sc->samples_per_frame;
+            }
+        } else
+            chunk_size = chunk_samples * sc->sample_size;
+
+        sc->index_sample_size = chunk_size;
+    }
+out:
+    return 0;
+}
+#endif
+
 static int mov_read_packet(AVFormatContext *s, AVPacket *pkt)
 {
     MOVContext *mov = s->priv_data;
     MOVStreamContext *sc = 0;
     AVIndexEntry *sample = 0;
+#ifdef EM8622
+    AVIndexEntry indexsample;
+#endif
     int64_t best_dts = INT64_MAX;
+	int activeWaitsLeft = 600;
     int i, ret;
  retry:
     for (i = 0; i < s->nb_streams; i++) {
         AVStream *st = s->streams[i];
+        // Don't read those for now because it had issue with streaming
+        if(st->codec->codec_type == CODEC_TYPE_DATA)
+            continue;
         MOVStreamContext *msc = st->priv_data;
-        if (st->discard != AVDISCARD_ALL && msc->pb && msc->current_sample < msc->sample_count) {
+#ifndef EM8622
+        if (st->discard != AVDISCARD_ALL && msc->pb && msc->current_sample < st->nb_index_entries) {
             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);
@@ -2045,6 +2309,22 @@
                 best_dts = dts;
                 sc = msc;
             }
+#else
+        if (st->discard != AVDISCARD_ALL && msc->pb && msc->current_sample < msc->sample_count) {
+            int64_t dts = av_rescale(msc->index_current_dts * (int64_t)msc->time_rate, AV_TIME_BASE, msc->time_scale);
+#ifdef DEBUG
+//            av_log(NULL, AV_LOG_ERROR, "stream %d, sample %ld, dts %"PRId64"\n", i, msc->current_sample, dts);
+#endif
+            if (dts < best_dts) {
+                best_dts = dts;
+                indexsample.pos=msc->index_current_offset;
+                indexsample.timestamp=msc->index_current_dts;
+                indexsample.flags=msc->index_keyframe!=0 ? AVINDEX_KEYFRAME : 0;
+                indexsample.size=msc->index_sample_size;
+                sample=&indexsample;
+                sc = msc;
+            }
+#endif
         }
     }
     if (!sample) {
@@ -2057,15 +2337,43 @@
         goto retry;
     }
     /* must be done just before reading, to avoid infinite loop on sample */
+#ifndef EM8622
     sc->current_sample++;
-    if (url_fseek(sc->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);
+#else
+    {
+        AVStream *st = s->streams[sc->ffindex];
+//        av_log(NULL, AV_LOG_ERROR, "before update index\n");
+        UpdateIndex(sc, st);
+//        av_log(NULL, AV_LOG_ERROR, "after update index\n");
+    }
+#endif
+    while (sample->pos >= url_fsize(s->pb)) 
+	{
+		int activeFile = ((((URLContext *) s->pb->opaque)->flags & URL_ACTIVEFILE) == URL_ACTIVEFILE);
+		if (activeFile)
+			break;
+		if (activeFile && activeWaitsLeft-- > 0)
+		{
+			usleep(50000);
+			continue;
+		}
+        av_log(mov->fc, AV_LOG_ERROR, "stream %d, offset 0x%"PRIx64": partial file\n", sc->ffindex, sample->pos);
         return -1;
     }
-    ret = av_get_packet(sc->pb, pkt, sample->size);
+#ifdef DEBUG8622
+//    av_log(mov->fc, AV_LOG_ERROR, "stream %d, offset 0x%"PRIx64" timestamp 0x%"PRIx64"\n", 
+//        sc->ffindex, sample->pos, sample->timestamp);
+#endif
+//    av_log(NULL, AV_LOG_ERROR, "before get_packet_nobuf 0x%"PRIx64" size %d\n",sample->pos, sample->size);
+//    fflush(stderr);
+//    usleep(50000);
+    ret = av_get_packet_nobuf(s->pb, pkt, sample->size, sample->pos);
     if (ret < 0)
+    {
+        av_log(NULL, AV_LOG_ERROR, "error reading with av_get_packet_nobuf at 0x%"PRIx64" with size %d\n",
+            sample->pos, sample->size);
         return ret;
+    }
 #if CONFIG_DV_DEMUXER
     if (mov->dv_demux && sc->dv_audio_container) {
         dv_produce_packet(mov->dv_demux, pkt, pkt->data, pkt->size);
@@ -2091,9 +2399,21 @@
             pkt->dts = AV_NOPTS_VALUE;
     } else {
         AVStream *st = s->streams[sc->ffindex];
-        int64_t next_dts = (sc->current_sample < sc->sample_count) ?
+#ifdef EM8622
+        // JFT verify that's right in all cases...
+        if (sc->sample_sizes || st->codec->codec_type == CODEC_TYPE_VIDEO || sc->dv_audio_container)
+        {
+            pkt->duration = sc->stts_data[sc->index_stts_index].duration / sc->time_rate;
+        }
+        else
+        {
+            pkt->duration = 0;
+        }
+#else
+        int64_t next_dts = (sc->current_sample < st->nb_index_entries) ?
             st->index_entries[sc->current_sample].timestamp : st->duration;
         pkt->duration = next_dts - pkt->dts;
+#endif
         pkt->pts = pkt->dts;
     }
     pkt->flags |= sample->flags & AVINDEX_KEYFRAME ? PKT_FLAG_KEY : 0;
@@ -2109,12 +2429,219 @@
     int sample, time_sample;
     int i;
 
+#ifdef DEBUG8622
+    av_log(NULL, AV_LOG_ERROR, "mov_seek_stream %lld\n", timestamp);
+#endif
+
+#ifndef EM8622
     sample = av_index_search_timestamp(st, timestamp, flags);
+#else
+    /* We use lower memory usage tables instead of index */
+    // First we need to find which sample is at the time timestamp with the ctts
+    sample = 0; // TODO: add algorithm to go through chunks time and find right sample
+    sc->index_current_dts=0;
+    sc->index_stts_index=0;
+    sc->index_stsc_index=0;
+    sc->index_stss_index=0;
+    sc->index_stts_sample=0;
+#ifdef DEBUG8622
+    av_log(NULL, AV_LOG_ERROR, "finding sample\n");
+#endif
+    while(sample<sc->sample_count && sc->index_current_dts<timestamp)
+    {
+        int64_t blockduration = ((int64_t)sc->stts_data[sc->index_stts_index].duration) *
+            ((int64_t)sc->stts_data[sc->index_stts_index].count)/sc->time_rate;
+#ifdef DEBUG8622
+        av_log(NULL, AV_LOG_ERROR, "current sample %d time %lld (block %lld) %d %d\n",
+            sample,sc->index_current_dts, blockduration, 
+            sc->stts_data[sc->index_stts_index].duration,
+            sc->stts_data[sc->index_stts_index].count);
+#endif
+        if(sc->index_current_dts+blockduration <= timestamp)
+        {
+            sample+=sc->stts_data[sc->index_stts_index].count;
+            sc->index_current_dts += blockduration;
+            if (sc->index_stts_index + 1 < sc->stts_count)
+            {
+                sc->index_stts_index+=1;
+            }
+        }
+        else // the time is in this stts block
+        {
+            int64_t samplecount = (timestamp-sc->index_current_dts)/
+                (sc->stts_data[sc->index_stts_index].duration/sc->time_rate);
+            sc->index_stts_sample=samplecount;
+            sample+=samplecount;
+            sc->index_current_dts += sc->stts_data[sc->index_stts_index].duration *
+            samplecount/sc->time_rate;
+            break;
+        }
+    }
+    sc->current_sample = sample;
+    // Find the previous keyframe if the stream contains keyframe/not keyframe samples
+    if(sc->keyframe_count>0)
+    {
+        while(sc->keyframes[sc->index_stss_index]<(sc->current_sample+1) && 
+            sc->index_stss_index < sc->keyframe_count)
+        {
+            sc->index_stss_index++;
+        }
+        if(sc->index_stss_index>0) sc->index_stss_index-=1;
+        sample=sc->keyframes[sc->index_stss_index]-1;
+        sc->current_sample = sample;
+        // Update the current dts with the frame count
+        sample=0;
+        sc->index_stts_sample=0;
+        sc->index_stts_index=0;
+        sc->index_current_dts=0;
+        while(sample<sc->current_sample)
+        {
+            int64_t blockduration = ((int64_t)sc->stts_data[sc->index_stts_index].duration) *
+                ((int64_t)sc->stts_data[sc->index_stts_index].count)/sc->time_rate;
+            //av_log(NULL, AV_LOG_ERROR, "current sample %d time %lld (block %lld)\n",
+            //    sample,sc->index_current_dts, blockduration);
+            if(sample+sc->stts_data[sc->index_stts_index].count <= sc->current_sample)
+            {
+                sample+=sc->stts_data[sc->index_stts_index].count;
+                sc->index_current_dts += blockduration;
+                if (sc->index_stts_index + 1 < sc->stts_count)
+                {
+                    sc->index_stts_index+=1;
+                }
+            }
+            else // the sample is in this stts block
+            {
+                int64_t samplecount = sc->current_sample-sample;
+                sc->index_stts_sample=samplecount;
+                sample+=samplecount;
+                sc->index_current_dts += sc->stts_data[sc->index_stts_index].duration *
+                samplecount/sc->time_rate;
+                break;
+            }
+        }
+    }
+    // Find the chunk in which the current sample is located
+    sc->index_chunk=0;
+    sc->index_chunk_sample=0;
+#ifdef DEBUG8622
+    av_log(NULL, AV_LOG_ERROR, "finding chunk for sample %d (%d %d %d)\n",sample, sc->current_sample,
+        sc->index_stsc_index, sc->stsc_data[sc->index_stsc_index].count);
+#endif
+    while(sc->current_sample && sc->current_sample >= sc->stsc_data[sc->index_stsc_index].count)
+    {
+        sc->index_chunk+=1;
+        sc->current_sample-=sc->stsc_data[sc->index_stsc_index].count;
+        if (sc->index_stsc_index + 1 < sc->stsc_count && 
+            sc->index_chunk + 1 == sc->stsc_data[sc->index_stsc_index + 1].first)
+            sc->index_stsc_index++;
+    }
+
+    if(sc->sample_size==0)
+    {
+        sc->index_chunk_sample=sc->current_sample;
+        sc->current_sample=sample;
+        sc->index_sample_size=sc->sample_size > 0 ? sc->sample_size : sc->sample_sizes[sc->current_sample];
+    }
+    else
+    {
+        // Index mode 2
+        sc->index_sample_size= sc->stsc_data[sc->index_stsc_index].count*sc->sample_size;
+        // Align to start of chunk
+        sc->index_chunk_sample=0;
+        sc->current_sample=sample-sc->current_sample;
+        // Update the current dts with the frame count
+        sample=0;
+        sc->index_stts_sample=0;
+        sc->index_stts_index=0;
+        sc->index_current_dts=0;
+        while(sample<sc->current_sample)
+        {
+            int64_t blockduration = ((int64_t)sc->stts_data[sc->index_stts_index].duration) *
+                ((int64_t)sc->stts_data[sc->index_stts_index].count)/sc->time_rate;
+            //av_log(NULL, AV_LOG_ERROR, "current sample %d time %lld (block %lld)\n",
+            //    sample,sc->index_current_dts, blockduration);
+            if(sample+sc->stts_data[sc->index_stts_index].count <= sc->current_sample)
+            {
+                sample+=sc->stts_data[sc->index_stts_index].count;
+                sc->index_current_dts += blockduration;
+                if (sc->index_stts_index + 1 < sc->stts_count)
+                {
+                    sc->index_stts_index+=1;
+                }
+            }
+            else // the sample is in this stts block
+            {
+                int64_t samplecount = sc->current_sample-sample;
+                sc->index_stts_sample=samplecount;
+                sample+=samplecount;
+                sc->index_current_dts += sc->stts_data[sc->index_stts_index].duration *
+                samplecount/sc->time_rate;
+                break;
+            }
+        }
+    }
+    sc->index_current_offset = sc->chunk_offsets[sc->index_chunk];
+    // Add sizes of samples in current chunk previous to current one to get current offset
+#ifdef DEBUG8622
+    av_log(NULL, AV_LOG_ERROR, "finding offset\n");
+#endif
+    if(sc->index_chunk_sample!=0)
+    {
+        for(i=0;i<sc->index_chunk_sample;i++)
+        {
+            sc->index_current_offset+= 
+                (sc->sample_size > 0 ? 
+                 sc->sample_size :
+                 sc->sample_sizes[sc->current_sample-sc->index_chunk_sample+i]);
+        }
+    }
+    // Find if current_sample is a keyframe and update stss index with next keyframe
+#ifdef DEBUG8622
+    av_log(NULL, AV_LOG_ERROR, "finding keyframe\n");
+#endif
+    if(!sc->keyframe_count)
+    {
+        sc->index_keyframe=1;
+    }
+    else
+    {
+        while(sc->keyframes[sc->index_stss_index]<(sc->current_sample+1) && 
+            sc->index_stss_index < sc->keyframe_count)
+        {
+            sc->index_stss_index++;
+        }
+        sc->index_keyframe= !sc->keyframe_count || 
+            sc->current_sample + 1 == sc->keyframes[sc->index_stss_index];
+        if (sc->index_keyframe) {
+            if (sc->index_stss_index + 1 < sc->keyframe_count)
+                sc->index_stss_index++;
+        }
+    }
+
+#ifdef DEBUG8622
+    av_log(NULL, AV_LOG_ERROR, "seek results\n"
+    "index_chunk %d "
+    "index_chunk_sample %d "
+    "index_stts_sample %d "
+    "index_sample_size %d "
+    "index_current_dts %lld "
+    "index_current_offset %lld "
+    "index_stts_index %d "
+    "index_stsc_index %d "
+    "index_stss_index %d "
+    "index_keyframe %d\n", 
+    sc->index_chunk, sc->index_chunk_sample, sc->index_stts_sample, sc->index_sample_size,
+    sc->index_current_dts, sc->index_current_offset, sc->index_stts_index,
+    sc->index_stsc_index, sc->index_stss_index, sc->index_keyframe);
+#endif
+
+#endif
     dprintf(st->codec, "stream %d, timestamp %"PRId64", sample %d\n", st->index, timestamp, sample);
     if (sample < 0) /* not sure what to do */
         return -1;
     sc->current_sample = sample;
     dprintf(st->codec, "stream %d, found sample %d\n", st->index, sc->current_sample);
+//    fprintf(stderr, "stream %d, found sample %ld has ctts %d\n", st->index, sc->current_sample, sc->ctts_data!=0);
     /* adjust ctts index */
     if (sc->ctts_data) {
         time_sample = 0;
@@ -2127,6 +2654,9 @@
             }
             time_sample = next;
         }
+/*        fprintf(stderr, "ctts %d %d\n", 
+            sc->sample_to_ctime_index,
+            sc->sample_to_ctime_sample);*/
     }
     return sample;
 }
@@ -2134,6 +2664,7 @@
 static int mov_read_seek(AVFormatContext *s, int stream_index, int64_t sample_time, int flags)
 {
     AVStream *st;
+    MOVStreamContext *sc;
     int64_t seek_timestamp, timestamp;
     int sample;
     int i;
@@ -2144,12 +2675,18 @@
         sample_time = 0;
 
     st = s->streams[stream_index];
+    sc = st->priv_data;
     sample = mov_seek_stream(st, sample_time, flags);
     if (sample < 0)
         return -1;
 
+#ifndef EM8622
     /* adjust seek timestamp to found sample timestamp */
     seek_timestamp = st->index_entries[sample].timestamp;
+#else
+    /* We use lower memory usage tables instead of index */
+    seek_timestamp=sc->index_current_dts;
+#endif
 
     for (i = 0; i < s->nb_streams; i++) {
         st = s->streams[i];
@@ -2164,26 +2701,41 @@
 
 static int mov_read_close(AVFormatContext *s)
 {
-    int i, j;
     MOVContext *mov = s->priv_data;
-    for(i=0; i<s->nb_streams; i++) {
-        MOVStreamContext *sc = s->streams[i]->priv_data;
+    int i, j;
+
+    for (i = 0; i < s->nb_streams; i++) {
+        AVStream *st = s->streams[i];
+        MOVStreamContext *sc = st->priv_data;
+
         av_freep(&sc->ctts_data);
-        for (j=0; j<sc->drefs_count; j++)
+        for (j = 0; j < sc->drefs_count; j++)
             av_freep(&sc->drefs[j].path);
         av_freep(&sc->drefs);
         if (sc->pb && sc->pb != s->pb)
             url_fclose(sc->pb);
+#ifdef EM8622
+        av_freep(&sc->chunk_offsets);
+        av_freep(&sc->stsc_data);
+        av_freep(&sc->sample_sizes);
+        av_freep(&sc->keyframes);
+        av_freep(&sc->stts_data);
+#endif
+
+        av_freep(&st->codec->palctrl);
     }
-    if(mov->dv_demux){
-        for(i=0; i<mov->dv_fctx->nb_streams; i++){
+
+    if (mov->dv_demux) {
+        for(i = 0; i < mov->dv_fctx->nb_streams; i++) {
             av_freep(&mov->dv_fctx->streams[i]->codec);
             av_freep(&mov->dv_fctx->streams[i]);
         }
         av_freep(&mov->dv_fctx);
         av_freep(&mov->dv_demux);
     }
+
     av_freep(&mov->trex_data);
+
     return 0;
 }
 
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
old mode 100644
new mode 100755
index f7af1b9..fe74cd0
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -2,6 +2,7 @@
  * MOV, 3GP, MP4 muxer
  * Copyright (c) 2003 Thomas Raivio
  * Copyright (c) 2004 Gildas Bazin <gbazin at videolan dot org>
+ * Copyright (c) 2009 Baptiste Coudurier <baptiste dot coudurier at gmail dot com>
  *
  * This file is part of FFmpeg.
  *
@@ -19,6 +20,7 @@
  * 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 "riff.h"
 #include "avio.h"
@@ -79,7 +81,7 @@
     int64_t mdat_pos;
     uint64_t mdat_size;
     long    timescale;
-    MOVTrack tracks[MAX_STREAMS];
+    MOVTrack *tracks;
 } MOVMuxContext;
 
 //FIXME support 64 bit variant with wide placeholders
@@ -570,6 +572,7 @@
     { CODEC_ID_ALAC,   MKTAG('a','l','a','c') },
     { CODEC_ID_AC3,    MKTAG('a','c','-','3') },
     { CODEC_ID_MOV_TEXT, MKTAG('t','x','3','g') },
+    { CODEC_ID_MOV_TEXT, MKTAG('t','e','x','t') },
     { CODEC_ID_NONE, 0 },
 };
 
@@ -586,7 +589,12 @@
         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_IPOD) {
-        tag = codec_get_tag(codec_ipod_tags, track->enc->codec_id);
+        if (track->enc->codec_type == CODEC_TYPE_SUBTITLE &&
+            (tag == MKTAG('t','x','3','g') ||
+             tag == MKTAG('t','e','x','t')))
+            track->tag = tag; // keep original tag
+        else
+            tag = codec_get_tag(codec_ipod_tags, track->enc->codec_id);
         if (!match_ext(s->filename, "m4a") && !match_ext(s->filename, "m4v"))
             av_log(s, AV_LOG_WARNING, "Warning, extension is not .m4a nor .m4v "
                    "Quicktime/Ipod might not play the file\n");
@@ -922,8 +930,8 @@
             hdlr_type = "soun";
             descr = "SoundHandler";
         } else if (track->enc->codec_type == CODEC_TYPE_SUBTITLE) {
-            if (track->mode == MODE_IPOD) hdlr_type = "sbtl";
-            else                          hdlr_type = "text";
+            if (track->tag == MKTAG('t','x','3','g')) hdlr_type = "sbtl";
+            else                                      hdlr_type = "text";
             descr = "SubtitleHandler";
         }
     }
@@ -951,8 +959,8 @@
     else if (track->enc->codec_type == CODEC_TYPE_AUDIO)
         mov_write_smhd_tag(pb);
     else if (track->enc->codec_type == CODEC_TYPE_SUBTITLE) {
-        if (track->mode == MODE_MOV) mov_write_gmhd_tag(pb);
-        else                         mov_write_nmhd_tag(pb);
+        if (track->tag == MKTAG('t','e','x','t')) mov_write_gmhd_tag(pb);
+        else                                      mov_write_nmhd_tag(pb);
     }
     if (track->mode == MODE_MOV) /* FIXME: Why do it for MODE_MOV only ? */
         mov_write_hdlr_tag(pb, NULL);
@@ -1656,6 +1664,10 @@
         }
     }
 
+    mov->tracks = av_mallocz(s->nb_streams*sizeof(*mov->tracks));
+    if (!mov->tracks)
+        return AVERROR(ENOMEM);
+
     for(i=0; i<s->nb_streams; i++){
         AVStream *st= s->streams[i];
         MOVTrack *track= &mov->tracks[i];
@@ -1670,7 +1682,7 @@
         if (!track->tag) {
             av_log(s, AV_LOG_ERROR, "track %d: could not find tag, "
                    "codec not currently supported in container\n", i);
-            return -1;
+            goto error;
         }
         if(st->codec->codec_type == CODEC_TYPE_VIDEO){
             if (track->tag == MKTAG('m','x','3','p') || track->tag == MKTAG('m','x','3','n') ||
@@ -1678,11 +1690,10 @@
                 track->tag == MKTAG('m','x','5','p') || track->tag == MKTAG('m','x','5','n')) {
                 if (st->codec->width != 720 || (st->codec->height != 608 && st->codec->height != 512)) {
                     av_log(s, AV_LOG_ERROR, "D-10/IMX must use 720x608 or 720x512 video resolution\n");
-                    return -1;
+                    goto error;
                 }
                 track->height = track->tag>>24 == 'n' ? 486 : 576;
-            } else
-                track->height = st->codec->height;
+            }
             track->timescale = st->codec->time_base.den;
             av_set_pts_info(st, 64, 1, st->codec->time_base.den);
             if (track->mode == MODE_MOV && track->timescale > 100000)
@@ -1695,7 +1706,7 @@
             av_set_pts_info(st, 64, 1, st->codec->sample_rate);
             if(!st->codec->frame_size && !av_get_bits_per_sample(st->codec->codec_id)) {
                 av_log(s, AV_LOG_ERROR, "track %d: codec frame size is not set\n", i);
-                return -1;
+                goto error;
             }else if(st->codec->frame_size > 1){ /* assume compressed audio */
                 track->audio_vbr = 1;
             }else{
@@ -1706,12 +1717,14 @@
                track->enc->codec_id == CODEC_ID_MP3 && track->enc->sample_rate < 16000){
                 av_log(s, AV_LOG_ERROR, "track %d: muxing mp3 at %dhz is not supported\n",
                        i, track->enc->sample_rate);
-                return -1;
+                goto error;
             }
         }else if(st->codec->codec_type == CODEC_TYPE_SUBTITLE){
             track->timescale = st->codec->time_base.den;
             av_set_pts_info(st, 64, 1, st->codec->time_base.den);
         }
+        if (!track->height)
+            track->height = st->codec->height;
     }
 
     mov_write_mdat_tag(pb, mov);
@@ -1721,6 +1734,9 @@
     put_flush_packet(pb);
 
     return 0;
+ error:
+    av_freep(&mov->tracks);
+    return -1;
 }
 
 static int mov_write_packet(AVFormatContext *s, AVPacket *pkt)
@@ -1843,6 +1859,8 @@
 
     put_flush_packet(pb);
 
+    av_freep(&mov->tracks);
+
     return res;
 }
 
@@ -1939,6 +1957,6 @@
     mov_write_packet,
     mov_write_trailer,
     .flags = AVFMT_GLOBALHEADER,
-    .codec_tag = (const AVCodecTag* const []){ff_mp4_obj_type, 0},
+    .codec_tag = (const AVCodecTag* const []){codec_ipod_tags, 0},
 };
 #endif
diff --git a/libavformat/mp3.c b/libavformat/mp3.c
old mode 100644
new mode 100755
index ca41408..b032f0c
--- a/libavformat/mp3.c
+++ b/libavformat/mp3.c
@@ -198,7 +198,8 @@
     }
 
     if (!strcmp(key, "genre")
-        && sscanf(dst, "(%d)", &genre) == 1 && genre <= ID3v1_GENRE_MAX)
+        && (sscanf(dst, "(%d)", &genre) == 1 || sscanf(dst, "%d", &genre) == 1)
+        && genre <= ID3v1_GENRE_MAX)
         av_strlcpy(dst, id3v1_genre_str[genre], sizeof(dst));
 
     if (*dst)
@@ -246,17 +247,8 @@
         goto error;
     }
 
-    if (isv34 && flags & 0x40) { /* Extended header present, just skip over it */
-        int extlen = id3v2_get_size(s->pb, 4);
-        if (version == 4)
-            extlen -= 4;     // in v2.4 the length includes the length field we just read
-
-        if (extlen < 0) {
-            reason = "invalid extended header length";
-            goto error;
-        }
-        url_fskip(s->pb, extlen);
-    }
+    if(isv34 && flags & 0x40) /* Extended header present, just skip over it */
+        url_fskip(s->pb, id3v2_get_size(s->pb, 4));
 
     while(len >= taghdrlen) {
         if(isv34) {
diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c
old mode 100644
new mode 100755
index a186cfb..6e79d91
--- a/libavformat/mpeg.c
+++ b/libavformat/mpeg.c
@@ -83,10 +83,12 @@
         return AVPROBE_SCORE_MAX/2+2; // +1 for .mpg
     if(priv1 + vid + audio > invalid && (priv1+vid+audio)*9 <= pspack*10)
         return AVPROBE_SCORE_MAX/2+2; // +1 for .mpg
+// STV version    if((!!vid ^ !!audio) && (audio+vid > 7) && !sys && !pspack && p->buf_size>2048) /* PES stream */
     if((!!vid ^ !!audio) && (audio > 4 || vid > 1) && !sys && !pspack && p->buf_size>2048) /* PES stream */
         return AVPROBE_SCORE_MAX/2+2;
 
     //02-Penguin.flac has sys:0 priv1:0 pspack:0 vid:0 audio:1
+	// NARFLEX: I've seen FLAC files with audio:2, so let's set it higher for safety
     return score;
 }
 
@@ -121,11 +123,21 @@
 static int64_t get_pts(ByteIOContext *pb, int c)
 {
     uint8_t buf[5];
-
+	int64_t rv;
+	
     buf[0] = c<0 ? get_byte(pb) : c;
     get_buffer(pb, buf+1, 4);
-
-    return ff_parse_pes_pts(buf);
+	
+	rv = ff_parse_pes_pts(buf);
+	
+	if (rv > (0x200000000LL - 30LL*90000LL))
+	{
+		// NARFLEX: This is in here to deal with MPEG2 files I keep running into that start with timestamps
+		// that are just about to rollover at 2^33 at the start of the file
+		// (a half second of audio usually at the start before it rolls over, and the video starts at zero)
+		rv = rv - 0x200000000LL;
+	}
+	return rv;
 }
 
 static int find_next_start_code(ByteIOContext *pb, int *size_ptr,
@@ -245,7 +257,7 @@
         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));
+//    av_log(NULL, AV_LOG_DEBUG, "startcode=%x pos=0x%"PRIx64"\n", startcode, url_ftell(s->pb));
     if (startcode < 0)
         return AVERROR(EIO);
     if (startcode == PACK_START_CODE)
@@ -278,10 +290,32 @@
         goto redo;
     }
 
+	/* STV: special case broken PS files produced by a bug in our muxer that created 0x00000100 start codes on some audio PES packets */
+	if(startcode == 0x100) {
+		int64_t loc = url_ftell(s->pb); 	// so we can rewind if necessary
+		int nextstart;
+		uint32_t hstate = 0xff;
+		len = get_be16(s->pb);
+		url_fskip(s->pb, len);	// skip past invalid PES packet (but has valid size)
+		
+		// check for valid start code
+		size = 8;
+		nextstart = find_next_start_code(s->pb, &size, &hstate);
+		if(nextstart != -1) {
+			// found valid start code, rewind a bit and goto redo
+			last_sync = loc + len;
+			goto error_redo;
+		}
+		
+		// probably just a corrupt stream, rewind and resume
+		url_fseek(s->pb, loc, SEEK_SET);
+		goto redo;
+	}
+	
     /* find matching stream */
     if (!((startcode >= 0x1c0 && startcode <= 0x1df) ||
           (startcode >= 0x1e0 && startcode <= 0x1ef) ||
-          (startcode == 0x1bd) || (startcode == 0x1fd)))
+          (startcode == 0x1bd) || (startcode == 0x1fa) || (startcode == 0x1fd)))
         goto redo;
     if (ppos) {
         *ppos = url_ftell(s->pb) - 4;
@@ -306,7 +340,7 @@
         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);
@@ -327,7 +361,7 @@
             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);
@@ -369,7 +403,10 @@
     else if( c!= 0xf )
         goto redo;
 
-    if (startcode == PRIVATE_STREAM_1 && !m->psm_es_type[startcode & 0xff]) {
+	// NARFLEX - I have no idea why they don't strip off the audio header junk
+	// if there's a PSM. I guess they assume then those headers aren't there; but that
+	// don't work for our PSMs
+    if (startcode == PRIVATE_STREAM_1 /*&& !m->psm_es_type[startcode & 0xff]*/) {
         startcode = get_byte(s->pb);
         len--;
         if (startcode >= 0x80 && startcode <= 0xcf) {
@@ -413,7 +450,7 @@
     enum CodecID codec_id = CODEC_ID_NONE;
     enum CodecType type;
     int64_t pts, dts, dummy_pos; //dummy_pos is needed for the index building to work
-    uint8_t dvdaudio_substream_type;
+    uint8_t av_uninit(dvdaudio_substream_type);
 
  redo:
     len = mpegps_read_pes_header(s, &dummy_pos, &startcode, &pts, &dts);
@@ -448,6 +485,9 @@
         } else if(es_type == STREAM_TYPE_AUDIO_AAC){
             codec_id = CODEC_ID_AAC;
             type = CODEC_TYPE_AUDIO;
+        } else if(es_type == STREAM_TYPE_AUDIO_AAC_LATM){
+            codec_id = CODEC_ID_AAC_LATM;
+            type = CODEC_TYPE_AUDIO;
         } else if(es_type == STREAM_TYPE_VIDEO_MPEG4){
             codec_id = CODEC_ID_MPEG4;
             type = CODEC_TYPE_VIDEO;
@@ -487,7 +527,7 @@
         codec_id = CODEC_ID_PCM_DVD;
     } else if (startcode >= 0xb0 && startcode <= 0xbf) {
         type = CODEC_TYPE_AUDIO;
-        codec_id = CODEC_ID_MLP;
+        codec_id = CODEC_ID_TRUEHD;
     } else if (startcode >= 0xc0 && startcode <= 0xcf) {
         /* Used for both AC-3 and E-AC-3 in EVOB files */
         type = CODEC_TYPE_AUDIO;
diff --git a/libavformat/mpeg.h b/libavformat/mpeg.h
old mode 100644
new mode 100755
index d09b2e8..c207d3a
--- a/libavformat/mpeg.h
+++ b/libavformat/mpeg.h
@@ -53,6 +53,7 @@
 #define STREAM_TYPE_PRIVATE_DATA    0x06
 #define STREAM_TYPE_AUDIO_AAC       0x0f
 #define STREAM_TYPE_VIDEO_MPEG4     0x10
+#define STREAM_TYPE_AUDIO_AAC_LATM  0x11
 #define STREAM_TYPE_VIDEO_H264      0x1b
 
 #define STREAM_TYPE_AUDIO_AC3       0x81
diff --git a/libavformat/mpegenc.c b/libavformat/mpegenc.c
old mode 100644
new mode 100755
index 0a740af..17e8a1b
--- a/libavformat/mpegenc.c
+++ b/libavformat/mpegenc.c
@@ -40,7 +40,7 @@
 } PacketDesc;
 
 typedef struct {
-    AVFifoBuffer fifo;
+    AVFifoBuffer *fifo;
     uint8_t id;
     int max_buffer_size; /* in bytes */
     int buffer_index;
@@ -381,7 +381,7 @@
         default:
             return -1;
         }
-        av_fifo_init(&stream->fifo, 16);
+        stream->fifo= av_fifo_alloc(16);
     }
     bitrate = 0;
     audio_bitrate = 0;
@@ -786,7 +786,7 @@
             startcode = 0x100 + id;
         }
 
-        stuffing_size = payload_size - av_fifo_size(&stream->fifo);
+        stuffing_size = payload_size - av_fifo_size(stream->fifo);
 
         // first byte does not fit -> reset pts/dts + stuffing
         if(payload_size <= trailer_size && pts != AV_NOPTS_VALUE){
@@ -913,8 +913,8 @@
         }
 
         /* output data */
-        assert(payload_size - stuffing_size <= av_fifo_size(&stream->fifo));
-        av_fifo_generic_read(&stream->fifo, payload_size - stuffing_size, &put_buffer, ctx->pb);
+        assert(payload_size - stuffing_size <= av_fifo_size(stream->fifo));
+        av_fifo_generic_read(stream->fifo, ctx->pb, payload_size - stuffing_size, &put_buffer);
         stream->bytes_to_iframe -= payload_size - stuffing_size;
     }else{
         payload_size=
@@ -1031,7 +1031,7 @@
     for(i=0; i<ctx->nb_streams; i++){
         AVStream *st = ctx->streams[i];
         StreamInfo *stream = st->priv_data;
-        const int avail_data=  av_fifo_size(&stream->fifo);
+        const int avail_data=  av_fifo_size(stream->fifo);
         const int space= stream->max_buffer_size - stream->buffer_index;
         int rel_space= 1024*space / stream->max_buffer_size;
         PacketDesc *next_pkt= stream->premux_packet;
@@ -1091,7 +1091,7 @@
     st = ctx->streams[best_i];
     stream = st->priv_data;
 
-    assert(av_fifo_size(&stream->fifo) > 0);
+    assert(av_fifo_size(stream->fifo) > 0);
 
     assert(avail_space >= s->packet_size || ignore_constraints);
 
@@ -1107,7 +1107,7 @@
 //av_log(ctx, AV_LOG_DEBUG, "dts:%f pts:%f scr:%f stream:%d\n", timestamp_packet->dts/90000.0, timestamp_packet->pts/90000.0, scr/90000.0, best_i);
         es_size= flush_packet(ctx, best_i, timestamp_packet->pts, timestamp_packet->dts, scr, trailer_size);
     }else{
-        assert(av_fifo_size(&stream->fifo) == trailer_size);
+        assert(av_fifo_size(stream->fifo) == trailer_size);
         es_size= flush_packet(ctx, best_i, AV_NOPTS_VALUE, AV_NOPTS_VALUE, scr, trailer_size);
     }
 
@@ -1170,18 +1170,19 @@
         stream->predecode_packet= pkt_desc;
     stream->next_packet= &pkt_desc->next;
 
-    if (av_fifo_realloc2(&stream->fifo, av_fifo_size(&stream->fifo) + size) < 0)
+    if (av_fifo_realloc2(stream->fifo, av_fifo_size(stream->fifo) + size) < 0)
         return -1;
 
     if (s->is_dvd){
-        if (is_iframe && (s->packet_number == 0 || (pts - stream->vobu_start_pts >= 36000))) { // min VOBU length 0.4 seconds (mpucoder)
-            stream->bytes_to_iframe = av_fifo_size(&stream->fifo);
+		// NARFLEX: SageTV, force I frame alignment if we're doing IFrame only mode since the PPC MPEG2 decoder requires that for parsing timestamps
+		if ((st->codec->codec_type == CODEC_TYPE_VIDEO && st->codec->gop_size == 0) || (is_iframe && (s->packet_number == 0 || (pts - stream->vobu_start_pts >= 36000)))) { // min VOBU length 0.4 seconds (mpucoder)
+            stream->bytes_to_iframe = av_fifo_size(stream->fifo);
             stream->align_iframe = 1;
             stream->vobu_start_pts = pts;
         }
     }
 
-    av_fifo_generic_write(&stream->fifo, buf, size, NULL);
+    av_fifo_generic_write(stream->fifo, buf, size, NULL);
 
     for(;;){
         int ret= output_packet(ctx, 0);
@@ -1213,8 +1214,8 @@
     for(i=0;i<ctx->nb_streams;i++) {
         stream = ctx->streams[i]->priv_data;
 
-        assert(av_fifo_size(&stream->fifo) == 0);
-        av_fifo_free(&stream->fifo);
+        assert(av_fifo_size(stream->fifo) == 0);
+        av_fifo_free(stream->fifo);
     }
     return 0;
 }
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
old mode 100644
new mode 100755
index 33e618c..102f595
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -36,6 +36,8 @@
 #define MAX_RESYNC_SIZE 4096
 #define REGISTRATION_DESCRIPTOR 5
 
+extern int bug_broken_dts;
+
 typedef struct PESContext PESContext;
 
 static PESContext* add_pes_stream(MpegTSContext *ts, int pid, int pcr_pid, int stream_type);
@@ -618,12 +620,20 @@
         p = desc_list_end;
 
 #ifdef DEBUG_SI
-        av_log(ts->stream, AV_LOG_DEBUG, "stream_type=%d pid=0x%x\n",
+        av_log(ts->stream, AV_LOG_DEBUG, "stream_type=0x%x pid=0x%x\n",
                stream_type, pid);
 #endif
 
         /* now create ffmpeg stream */
         switch(stream_type) {
+        case STREAM_TYPE_AUDIO_HDMV_DTS_HD:
+        case STREAM_TYPE_AUDIO_HDMV_DTS_HD_MASTER:
+        case STREAM_TYPE_AUDIO_HDMV_AC3_TRUE_HD:
+        case STREAM_TYPE_AUDIO_HDMV_AC3_PLUS:
+        case STREAM_TYPE_AUDIO_HDMV_LPCM:
+        case STREAM_TYPE_AUDIO_HDMV_SUBPICTURE:
+            if(!has_hdmv_descr)
+                break;
         case STREAM_TYPE_AUDIO_MPEG1:
         case STREAM_TYPE_AUDIO_MPEG2:
         case STREAM_TYPE_VIDEO_MPEG1:
@@ -633,6 +643,7 @@
         case STREAM_TYPE_VIDEO_VC1:
         case STREAM_TYPE_VIDEO_DIRAC:
         case STREAM_TYPE_AUDIO_AAC:
+        case STREAM_TYPE_AUDIO_AAC_LATM:
         case STREAM_TYPE_AUDIO_AC3:
         case STREAM_TYPE_AUDIO_DTS:
         case STREAM_TYPE_AUDIO_HDMV_DTS:
@@ -655,6 +666,9 @@
             break;
         default:
             /* we ignore the other streams */
+#ifdef DEBUG_SI
+			av_log(ts->stream, AV_LOG_DEBUG, " -- IGNORING unknown stream type 0x%x\n", stream_type);
+#endif
             break;
         }
 
@@ -857,14 +871,14 @@
                     pes->header[2] == 0x01) {
                     /* it must be an mpeg2 PES stream */
                     code = pes->header[3] | 0x100;
-                    if (!((code >= 0x1c0 && code <= 0x1df) ||
+                    if (!pes->st ||
+                        !((code >= 0x1c0 && code <= 0x1df) ||
                           (code >= 0x1e0 && code <= 0x1ef) ||
-                          (code == 0x1bd) || (code == 0x1fd)))
-                        goto skip;
-                    if (!pes->st) {
-                        /* allocate stream */
-                        new_pes_av_stream(pes, code);
-                    }
+                          (code == 0x1bd) || (code == 0x1fa) || (code == 0x1fd)))
+					{
+						pes->state = MPEGTS_SKIP;
+						continue;
+					}
                     pes->state = MPEGTS_PESHEADER_FILL;
                     pes->total_size = AV_RB16(pes->header + 4);
                     /* NOTE: a zero total size means the PES size is
@@ -875,7 +889,6 @@
                 } else {
                     /* otherwise, it should be a table */
                     /* skip packet */
-                skip:
                     pes->state = MPEGTS_SKIP;
                     continue;
                 }
@@ -908,6 +921,13 @@
                     pes->dts = get_pts(r);
                     r += 5;
                 }
+				// TODO: Finish this up
+                if (bug_broken_dts && (pes->dts != AV_NOPTS_VALUE)) {
+					// check against last DTS for this stream
+					// if it's lower than the last, then we're bugged and need to modify PTS values
+					
+					pes->dts = AV_NOPTS_VALUE;
+				}
                 /* we got the full header. We parse it and get the payload */
                 pes->state = MPEGTS_PAYLOAD;
             }
@@ -982,19 +1002,44 @@
         codec_type = CODEC_TYPE_AUDIO;
         codec_id = CODEC_ID_AAC;
         break;
+    case STREAM_TYPE_AUDIO_AAC_LATM:
+        codec_type = CODEC_TYPE_AUDIO;
+        codec_id = CODEC_ID_AAC_LATM;
+        break;
     case STREAM_TYPE_AUDIO_AC3:
+    case STREAM_TYPE_AUDIO_HDMV_AC3_PLUS:
         codec_type = CODEC_TYPE_AUDIO;
         codec_id = CODEC_ID_AC3;
         break;
-    case STREAM_TYPE_AUDIO_DTS:
-    case STREAM_TYPE_AUDIO_HDMV_DTS:
-        codec_type = CODEC_TYPE_AUDIO;
-        codec_id = CODEC_ID_DTS;
-        break;
-    case STREAM_TYPE_SUBTITLE_DVB:
+	case STREAM_TYPE_AUDIO_HDMV_AC3_TRUE_HD:
+		codec_type = CODEC_TYPE_AUDIO;
+		codec_id = CODEC_ID_TRUEHD;
+		break;
+	case STREAM_TYPE_AUDIO_DTS:
+	case STREAM_TYPE_AUDIO_HDMV_DTS:
+		codec_type = CODEC_TYPE_AUDIO;
+		codec_id = CODEC_ID_DTS;
+		break;
+    case STREAM_TYPE_AUDIO_HDMV_DTS_HD:
+		codec_type = CODEC_TYPE_AUDIO;
+		codec_id = CODEC_ID_DTS_HD;
+		break;
+	case STREAM_TYPE_AUDIO_HDMV_DTS_HD_MASTER:
+		codec_type = CODEC_TYPE_AUDIO;
+		codec_id = CODEC_ID_DTS_MA;
+		break;
+	case STREAM_TYPE_SUBTITLE_DVB:
         codec_type = CODEC_TYPE_SUBTITLE;
         codec_id = CODEC_ID_DVB_SUBTITLE;
         break;
+    case STREAM_TYPE_AUDIO_HDMV_LPCM:
+        codec_type = CODEC_TYPE_AUDIO;
+        codec_id = CODEC_ID_PCM_BD;
+        break;
+    case STREAM_TYPE_AUDIO_HDMV_SUBPICTURE:
+        codec_type = CODEC_TYPE_SUBTITLE;
+        codec_id = CODEC_ID_HDMV_PGS_SUBTITLE;
+        break;
     default:
         if (code >= 0x1c0 && code <= 0x1df) {
             codec_type = CODEC_TYPE_AUDIO;
@@ -1016,6 +1061,16 @@
         st->codec->codec_id = codec_id;
         st->need_parsing = AVSTREAM_PARSE_FULL;
         pes->st = st;
+        if(st->codec->codec_id == CODEC_ID_PCM_BD)
+        {
+            // We'll need to parse that...
+            st->codec->sample_rate = 48000;
+            st->codec->channels = 2;
+            st->codec->bits_per_coded_sample = 16;
+            st->codec->bit_rate = st->codec->channels *
+                                st->codec->sample_rate *
+                                st->codec->bits_per_coded_sample;
+        }
     }
     return st;
 }
@@ -1199,7 +1254,10 @@
 
     if (check_count < CHECK_COUNT)
         return -1;
-
+	
+	// sanity check the probe size, we don't need much data to determine if it's a valid TS
+	if((size < 0) ? (p->buf_size > (MAX_SCAN_PACKETS*TS_FEC_PACKET_SIZE)) : 0) return 0;
+	
     score     = analyze(p->buf, TS_PACKET_SIZE     *check_count, TS_PACKET_SIZE     , NULL)*CHECK_COUNT/check_count;
     dvhs_score= analyze(p->buf, TS_DVHS_PACKET_SIZE*check_count, TS_DVHS_PACKET_SIZE, NULL)*CHECK_COUNT/check_count;
     fec_score = analyze(p->buf, TS_FEC_PACKET_SIZE *check_count, TS_FEC_PACKET_SIZE , NULL)*CHECK_COUNT/check_count;
@@ -1209,7 +1267,7 @@
     if     (score > fec_score && score > dvhs_score && score > 6) return AVPROBE_SCORE_MAX + score     - CHECK_COUNT;
     else if(dvhs_score > score && dvhs_score > fec_score && dvhs_score > 6) return AVPROBE_SCORE_MAX + dvhs_score  - CHECK_COUNT;
     else if(                 fec_score > 6) return AVPROBE_SCORE_MAX + fec_score - CHECK_COUNT;
-    else                                    return -1;
+    else                                    return 0;
 #else
     /* only use the extension for safer guess */
     if (match_ext(p->filename, "ts"))
diff --git a/libavformat/mpegts.h b/libavformat/mpegts.h
old mode 100644
new mode 100755
index 4d06b1d..f5ecc4a
--- a/libavformat/mpegts.h
+++ b/libavformat/mpegts.h
@@ -50,13 +50,20 @@
 #define STREAM_TYPE_PRIVATE_DATA    0x06
 #define STREAM_TYPE_AUDIO_AAC       0x0f
 #define STREAM_TYPE_VIDEO_MPEG4     0x10
+#define STREAM_TYPE_AUDIO_AAC_LATM  0x11
 #define STREAM_TYPE_VIDEO_H264      0x1b
 #define STREAM_TYPE_VIDEO_VC1       0xea
 #define STREAM_TYPE_VIDEO_DIRAC     0xd1
 
+#define STREAM_TYPE_AUDIO_HDMV_LPCM 0x80
 #define STREAM_TYPE_AUDIO_AC3       0x81
 #define STREAM_TYPE_AUDIO_DTS       0x8a
 #define STREAM_TYPE_AUDIO_HDMV_DTS  0x82
+#define STREAM_TYPE_AUDIO_HDMV_AC3_TRUE_HD   0x83
+#define STREAM_TYPE_AUDIO_HDMV_AC3_PLUS      0x84
+#define STREAM_TYPE_AUDIO_HDMV_DTS_HD        0x85
+#define STREAM_TYPE_AUDIO_HDMV_DTS_HD_MASTER 0x86
+#define STREAM_TYPE_AUDIO_HDMV_SUBPICTURE    0x90
 
 #define STREAM_TYPE_SUBTITLE_DVB    0x100
 
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
old mode 100644
new mode 100755
diff --git a/libavformat/mpjpeg.c b/libavformat/mpjpeg.c
old mode 100644
new mode 100755
diff --git a/libavformat/msnwc_tcp.c b/libavformat/msnwc_tcp.c
old mode 100644
new mode 100755
diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 3933d4c..73b0a77 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -364,6 +364,8 @@
 
 static int mxf_add_metadata_set(MXFContext *mxf, void *metadata_set)
 {
+    if (mxf->metadata_sets_count+1 >= UINT_MAX / sizeof(*mxf->metadata_sets))
+        return AVERROR(ENOMEM);
     mxf->metadata_sets = av_realloc(mxf->metadata_sets, (mxf->metadata_sets_count + 1) * sizeof(*mxf->metadata_sets));
     if (!mxf->metadata_sets)
         return -1;
diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
index ab71b26..ab8f36b 100644
--- a/libavformat/mxfenc.c
+++ b/libavformat/mxfenc.c
@@ -36,6 +36,7 @@
 #include <time.h>
 
 #include "libavutil/fifo.h"
+#include "libavutil/random_seed.h"
 #include "libavcodec/bytestream.h"
 #include "audiointerleave.h"
 #include "avformat.h"
@@ -187,10 +188,12 @@
     int timecode_drop_frame; ///< time code use drop frame method frop mpeg-2 essence gop header
     int edit_unit_byte_count; ///< fixed edit unit byte count
     uint64_t body_offset;
+    uint32_t instance_number;
+    uint8_t umid[16];        ///< unique material identifier
 } MXFContext;
 
 static const uint8_t uuid_base[]            = { 0xAD,0xAB,0x44,0x24,0x2f,0x25,0x4d,0xc7,0x92,0xff,0x29,0xbd };
-static const uint8_t umid_base[]            = { 0x06,0x0A,0x2B,0x34,0x01,0x01,0x01,0x05,0x01,0x01,0x0D,0x00,0x13,0x00,0x00,0x00 };
+static const uint8_t umid_ul[]              = { 0x06,0x0A,0x2B,0x34,0x01,0x01,0x01,0x05,0x01,0x01,0x0D,0x00,0x13 };
 
 /**
  * complete key for operation pattern, partitions, and primer pack
@@ -307,10 +310,13 @@
     put_be16(pb, value);
 }
 
-static void mxf_write_umid(ByteIOContext *pb, enum MXFMetadataSetType type, int value)
+static void mxf_write_umid(AVFormatContext *s, int type)
 {
-    put_buffer(pb, umid_base, 16);
-    mxf_write_uuid(pb, type, value);
+    MXFContext *mxf = s->priv_data;
+    put_buffer(s->pb, umid_ul, 13);
+    put_be24(s->pb, mxf->instance_number);
+    put_buffer(s->pb, mxf->umid, 15);
+    put_byte(s->pb, type);
 }
 
 static void mxf_write_refs_count(ByteIOContext *pb, int ref_count)
@@ -693,7 +699,7 @@
         for (i = 0; i < 4; i++)
             put_be64(pb, 0);
     } else
-        mxf_write_umid(pb, SourcePackage, 0);
+        mxf_write_umid(s, 1);
 
     // write source track id
     mxf_write_local_tag(pb, 4, 0x1102);
@@ -932,7 +938,7 @@
 
     // write package umid
     mxf_write_local_tag(pb, 32, 0x4401);
-    mxf_write_umid(pb, type, 0);
+    mxf_write_umid(s, type == SourcePackage);
     PRINT_KEY(s, "package umid second part", pb->buf_ptr - 16);
 
     // package creation date
@@ -990,7 +996,7 @@
     mxf_write_uuid(pb, EssenceContainerData, 0);
 
     mxf_write_local_tag(pb, 32, 0x2701); // Linked Package UID
-    mxf_write_umid(pb, SourcePackage, 0);
+    mxf_write_umid(s, 1);
 
     mxf_write_local_tag(pb, 4, 0x3F07); // BodySID
     put_be32(pb, 1);
@@ -1362,7 +1368,7 @@
 
 static uint64_t mxf_parse_timestamp(time_t timestamp)
 {
-    struct tm *time = localtime(&timestamp);
+    struct tm *time = gmtime(&timestamp);
     return (uint64_t)(time->tm_year+1900) << 48 |
            (uint64_t)(time->tm_mon+1)     << 40 |
            (uint64_t) time->tm_mday       << 32 |
@@ -1371,6 +1377,18 @@
                       time->tm_sec        << 8;
 }
 
+static void mxf_gen_umid(AVFormatContext *s)
+{
+    MXFContext *mxf = s->priv_data;
+    uint32_t seed = ff_random_get_seed();
+    uint64_t umid = seed + 0x5294713400000000LL;
+
+    AV_WB64(mxf->umid  , umid);
+    AV_WB64(mxf->umid+8, umid>>8);
+
+    mxf->instance_number = seed;
+}
+
 static int mxf_write_header(AVFormatContext *s)
 {
     MXFContext *mxf = s->priv_data;
@@ -1378,6 +1396,9 @@
     uint8_t present[FF_ARRAY_ELEMS(mxf_essence_container_uls)] = {0};
     const int *samples_per_frame = NULL;
 
+    if (!s->nb_streams)
+        return -1;
+
     for (i = 0; i < s->nb_streams; i++) {
         AVStream *st = s->streams[i];
         MXFStreamContext *sc = av_mallocz(sizeof(*sc));
@@ -1469,6 +1490,9 @@
         mxf->essence_container_count = 1;
     }
 
+    if (!(s->streams[0]->codec->flags & CODEC_FLAG_BITEXACT))
+        mxf_gen_umid(s);
+
     for (i = 0; i < s->nb_streams; i++) {
         MXFStreamContext *sc = s->streams[i]->priv_data;
         // update element count
@@ -1476,7 +1500,8 @@
         sc->order = AV_RB32(sc->track_essence_element_key+12);
     }
 
-    mxf->timestamp = mxf_parse_timestamp(s->timestamp);
+    if (s->timestamp)
+        mxf->timestamp = mxf_parse_timestamp(s->timestamp);
     mxf->duration = -1;
 
     mxf->timecode_track = av_mallocz(sizeof(*mxf->timecode_track));
@@ -1555,7 +1580,7 @@
     klv_encode_ber4_length(pb, 35);
     put_byte(pb, 0x83); // UMID
     put_be16(pb, 0x20);
-    mxf_write_umid(pb, SourcePackage, 0);
+    mxf_write_umid(s, 1);
 }
 
 static void mxf_write_d10_video_packet(AVFormatContext *s, AVStream *st, AVPacket *pkt)
diff --git a/libavformat/nsvdec.c b/libavformat/nsvdec.c
old mode 100644
new mode 100755
diff --git a/libavformat/nutdec.c b/libavformat/nutdec.c
old mode 100644
new mode 100755
diff --git a/libavformat/nutenc.c b/libavformat/nutenc.c
old mode 100644
new mode 100755
diff --git a/libavformat/nuv.c b/libavformat/nuv.c
old mode 100644
new mode 100755
diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
old mode 100644
new mode 100755
index a810b95..24a0c46
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -102,8 +102,8 @@
                                    ogg->nstreams * sizeof (*ogg->streams));
 
         if (ogg->streams) {
-            memcpy(ogg->streams, ost->streams,
-                   ost->nstreams * sizeof(*ogg->streams));
+        memcpy(ogg->streams, ost->streams,
+               ost->nstreams * sizeof(*ogg->streams));
         } else {
             av_free(old_streams);
             ogg->nstreams = 0;
@@ -286,6 +286,8 @@
         }
     }else{
         os->psize = 0;
+        os->pstart = 0;
+        os->bufpos = 0;
     }
 
     if (os->bufsize - os->bufpos < size){
@@ -466,8 +468,10 @@
     url_fseek (s->pb, end, SEEK_SET);
 
     while (!ogg_read_page (s, &i)){
+		// NARFLEX: SageTV, I added the '&& !i' to this conditional so it took the first stream.
+		// I had test files that this fixed a duration detection problem on.
         if (ogg->streams[i].granule != -1 && ogg->streams[i].granule != 0 &&
-            ogg->streams[i].codec)
+            ogg->streams[i].codec && !i)
             idx = i;
     }
 
@@ -487,17 +491,12 @@
 ogg_read_header (AVFormatContext * s, AVFormatParameters * ap)
 {
     struct ogg *ogg = s->priv_data;
-    int i;
     ogg->curidx = -1;
     //linear headers seek from start
     if (ogg_get_headers (s) < 0){
         return -1;
     }
 
-    for (i = 0; i < ogg->nstreams; i++)
-        if (ogg->streams[i].header < 0)
-            ogg->streams[i].codec = NULL;
-
     //linear granulepos seek from end
     ogg_get_length (s);
 
diff --git a/libavformat/oggdec.h b/libavformat/oggdec.h
old mode 100644
new mode 100755
index d238e99..1d65ba7
--- a/libavformat/oggdec.h
+++ b/libavformat/oggdec.h
@@ -31,6 +31,12 @@
     const int8_t *magic;
     uint8_t magicsize;
     const int8_t *name;
+    /**
+     * Attempt to process a packet as a header
+     * @return 1 if the packet was a valid header,
+     *         0 if the packet was not a header (was a data packet)
+     *         -1 if an error occurred or for unsupported stream
+     */
     int (*header)(AVFormatContext *, int);
     int (*packet)(AVFormatContext *, int);
     uint64_t (*gptopts)(AVFormatContext *, int, uint64_t);
diff --git a/libavformat/oggparseflac.c b/libavformat/oggparseflac.c
old mode 100644
new mode 100755
diff --git a/libavformat/oggparseogm.c b/libavformat/oggparseogm.c
old mode 100644
new mode 100755
diff --git a/libavformat/oggparsespeex.c b/libavformat/oggparsespeex.c
index eb7709c..3f6d778 100644
--- a/libavformat/oggparsespeex.c
+++ b/libavformat/oggparsespeex.c
@@ -36,22 +36,25 @@
     AVStream *st = s->streams[idx];
     uint8_t *p = os->buf + os->pstart;
 
-    if (os->psize < 80)
-        return 1;
+    if (os->seq > 1)
+        return 0;
 
-    st->codec->codec_type = CODEC_TYPE_AUDIO;
-    st->codec->codec_id = CODEC_ID_SPEEX;
+    if (os->seq == 0) {
+        st->codec->codec_type = CODEC_TYPE_AUDIO;
+        st->codec->codec_id = CODEC_ID_SPEEX;
 
-    st->codec->sample_rate = AV_RL32(p + 36);
-    st->codec->channels = AV_RL32(p + 48);
-    st->codec->extradata_size = os->psize;
-    st->codec->extradata = av_malloc(st->codec->extradata_size);
-    memcpy(st->codec->extradata, p, st->codec->extradata_size);
+        st->codec->sample_rate = AV_RL32(p + 36);
+        st->codec->channels = AV_RL32(p + 48);
+        st->codec->extradata_size = os->psize;
+        st->codec->extradata = av_malloc(st->codec->extradata_size);
+        memcpy(st->codec->extradata, p, st->codec->extradata_size);
 
-    st->time_base.num = 1;
-    st->time_base.den = st->codec->sample_rate;
+        st->time_base.num = 1;
+        st->time_base.den = st->codec->sample_rate;
+    } else
+        vorbis_comment(s, p, os->psize);
 
-    return 0;
+    return 1;
 }
 
 const struct ogg_codec ff_speex_codec = {
diff --git a/libavformat/oggparsetheora.c b/libavformat/oggparsetheora.c
old mode 100644
new mode 100755
diff --git a/libavformat/oggparsevorbis.c b/libavformat/oggparsevorbis.c
old mode 100644
new mode 100755
index 82029da..7a4f562
--- a/libavformat/oggparsevorbis.c
+++ b/libavformat/oggparsevorbis.c
@@ -83,8 +83,10 @@
                 continue;
             }
 
-            for (j = 0; j < tl; j++)
-                tt[j] = toupper(t[j]);
+			// DrD: Don't convert to uppercase...
+//            for (j = 0; j < tl; j++)
+//                tt[j] = toupper(t[j]);
+			memcpy(tt, t, tl);
             tt[tl] = 0;
 
             memcpy(ct, v, vl);
diff --git a/libavformat/options.c b/libavformat/options.c
index a921b91..2e4eac6 100644
--- a/libavformat/options.c
+++ b/libavformat/options.c
@@ -52,7 +52,11 @@
 #endif
 {"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},
+#ifdef EM8622
+{"indexmem", "max memory used for timestamp index (per stream)", OFFSET(max_index_size), FF_OPT_TYPE_INT, 1<<17, 0, INT_MAX, D},
+#else
 {"indexmem", "max memory used for timestamp index (per stream)", OFFSET(max_index_size), FF_OPT_TYPE_INT, 1<<20, 0, INT_MAX, D},
+#endif
 {"rtbufsize", "max memory used for buffering real-time frames", OFFSET(max_picture_buffer), FF_OPT_TYPE_INT, 3041280, 0, INT_MAX, D}, /* defaults to 1s of 15fps 352x288 YUYV422 video */
 {"fdebug", "print specific debug info", OFFSET(debug), FF_OPT_TYPE_FLAGS, DEFAULT, 0, INT_MAX, E|D, "fdebug"},
 {"ts", NULL, 0, FF_OPT_TYPE_CONST, FF_FDEBUG_TS, INT_MIN, INT_MAX, E|D, "fdebug"},
diff --git a/libavformat/os_support.c b/libavformat/os_support.c
old mode 100644
new mode 100755
diff --git a/libavformat/os_support.h b/libavformat/os_support.h
old mode 100644
new mode 100755
diff --git a/libavformat/psxstr.c b/libavformat/psxstr.c
old mode 100644
new mode 100755
diff --git a/libavformat/pva.c b/libavformat/pva.c
old mode 100644
new mode 100755
diff --git a/libavformat/qtpalette.h b/libavformat/qtpalette.h
old mode 100644
new mode 100755
diff --git a/libavformat/raw.c b/libavformat/raw.c
index 224c26f..1682fcb 100644
--- a/libavformat/raw.c
+++ b/libavformat/raw.c
@@ -232,6 +232,7 @@
 
     if (block_align <= 0 || byte_rate <= 0)
         return -1;
+    if (timestamp < 0) timestamp = 0;
 
     /* compute the position by aligning it to block_align */
     pos = av_rescale_rnd(timestamp * byte_rate,
@@ -479,6 +480,7 @@
 #define DCA_MARKER_14B_LE 0xFF1F00E8
 #define DCA_MARKER_RAW_BE 0x7FFE8001
 #define DCA_MARKER_RAW_LE 0xFE7F0180
+#define DCA_HD_MARKER     0x64582025
 static int dts_probe(AVProbeData *p)
 {
     const uint8_t *buf, *bufp;
@@ -503,6 +505,10 @@
         if (state == DCA_MARKER_14B_LE)
             if ((bytestream_get_be16(&bufp) & 0xF0FF) == 0xF007)
                 return AVPROBE_SCORE_MAX/2+1;
+		
+		/* DTS Express streams only use the DCA HD marker... */
+		if (state == DCA_HD_MARKER)
+            return AVPROBE_SCORE_MAX/2+1;
     }
 
     return 0;
@@ -968,6 +974,35 @@
 };
 #endif
 
+#if CONFIG_TRUEHD_DEMUXER
+AVInputFormat truehd_demuxer = {
+    "truehd",
+    NULL_IF_CONFIG_SMALL("raw TrueHD"),
+    0,
+    NULL,
+    audio_read_header,
+    ff_raw_read_partial_packet,
+    .flags= AVFMT_GENERIC_INDEX,
+    .extensions = "thd",
+    .value = CODEC_ID_TRUEHD,
+};
+#endif
+
+#if CONFIG_TRUEHD_MUXER
+AVOutputFormat truehd_muxer = {
+    "truehd",
+    NULL_IF_CONFIG_SMALL("raw TrueHD"),
+    NULL,
+    "thd",
+    0,
+    CODEC_ID_TRUEHD,
+    CODEC_ID_NONE,
+    NULL,
+    raw_write_packet,
+    .flags= AVFMT_NOTIMESTAMPS,
+};
+#endif
+
 #if CONFIG_MPEG1VIDEO_MUXER
 AVOutputFormat mpeg1video_muxer = {
     "mpeg1video",
diff --git a/libavformat/rdt.c b/libavformat/rdt.c
index c96ed4a..7400a6d 100644
--- a/libavformat/rdt.c
+++ b/libavformat/rdt.c
@@ -315,10 +315,10 @@
         rdt->audio_pkt_cnt = res;
         if (rdt->audio_pkt_cnt > 0 &&
             st->codec->codec_id == CODEC_ID_AAC) {
-            memcpy (rdt->buffer, buf + pos, len - pos);
-            rdt->rmctx->pb = av_alloc_put_byte (rdt->buffer, len - pos, 0,
-                                                NULL, NULL, NULL, NULL);
-        }
+                memcpy (rdt->buffer, buf + pos, len - pos);
+                rdt->rmctx->pb = av_alloc_put_byte (rdt->buffer, len - pos, 0,
+                                                    NULL, NULL, NULL, NULL);
+            }
     } else {
         rdt->audio_pkt_cnt =
             ff_rm_retrieve_cache (rdt->rmctx, rdt->rmctx->pb,
diff --git a/libavformat/riff.c b/libavformat/riff.c
index 594eb63..c0bccb9 100644
--- a/libavformat/riff.c
+++ b/libavformat/riff.c
@@ -74,6 +74,7 @@
     { CODEC_ID_MPEG4,        MKTAG('E', 'P', 'H', 'V') }, /* Ephv MPEG-4 */
     { CODEC_ID_MPEG4,        MKTAG('E', 'M', '4', 'A') },
     { CODEC_ID_MPEG4,        MKTAG('M', '4', 'C', 'C') }, /* Divio MPEG-4 */
+    { CODEC_ID_MPEG4,        MKTAG('S', 'N', '4', '0') },
     { CODEC_ID_MSMPEG4V3,    MKTAG('D', 'I', 'V', '3') }, /* default signature when using MSMPEG4 */
     { CODEC_ID_MSMPEG4V3,    MKTAG('M', 'P', '4', '3') },
     { CODEC_ID_MSMPEG4V3,    MKTAG('M', 'P', 'G', '3') },
@@ -201,6 +202,8 @@
     { CODEC_ID_RPZA,         MKTAG('R', 'P', 'Z', 'A') },
     { CODEC_ID_RPZA,         MKTAG('r', 'p', 'z', 'a') },
     { CODEC_ID_SP5X,         MKTAG('S', 'P', '5', '4') },
+    { CODEC_ID_AURA,         MKTAG('A', 'U', 'R', 'A') },
+    { CODEC_ID_AURA2,        MKTAG('A', 'U', 'R', '2') },
     { CODEC_ID_NONE,         0 }
 };
 
diff --git a/libavformat/rm.h b/libavformat/rm.h
old mode 100644
new mode 100755
index 6e5d2c5..53dd019
--- a/libavformat/rm.h
+++ b/libavformat/rm.h
@@ -64,9 +64,9 @@
  * @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 (where >0 indicates there are cached samples that
- *         can be retrieved with subsequent calls to ff_rm_retrieve_cache()),
- *         errno codes on error
+ * @return <0 on error, 0 if a packet was placed in the \p pkt pointer. A
+ *         value >0 means that no data was placed in \p pkt, but that cached
+ *         data is available by calling ff_rm_retrieve_cache().
  */
 int ff_rm_parse_packet (AVFormatContext *s, ByteIOContext *pb,
                         AVStream *st, RMStream *rst, int len,
diff --git a/libavformat/rmdec.c b/libavformat/rmdec.c
old mode 100644
new mode 100755
index 65bc79c..eb75eb7
--- a/libavformat/rmdec.c
+++ b/libavformat/rmdec.c
@@ -172,10 +172,10 @@
                 return -1;
             }
 
-            if(sub_packet_size <= 0){
-                av_log(s, AV_LOG_ERROR, "sub_packet_size is invalid\n");
-                return -1;
-            }
+                if(sub_packet_size <= 0){
+                    av_log(s, AV_LOG_ERROR, "sub_packet_size is invalid\n");
+                    return -1;
+                }
 
             if (!strcmp(buf, "cook")) st->codec->codec_id = CODEC_ID_COOK;
             else if (!strcmp(buf, "sipr")) st->codec->codec_id = CODEC_ID_SIPR;
@@ -617,8 +617,8 @@
             if (++(ast->sub_packet_cnt) < h)
                 return -1;
             else {
-                ast->sub_packet_cnt = 0;
-                rm->audio_stream_num = st->index;
+             ast->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);
@@ -690,7 +690,7 @@
                st->codec->block_align);
     }
     rm->audio_pkt_cnt--;
-    pkt->flags = 0;
+        pkt->flags = 0;
     pkt->stream_index = st->index;
 
     return rm->audio_pkt_cnt;
@@ -705,22 +705,22 @@
     int64_t timestamp, pos;
     int flags;
 
-    if (rm->audio_pkt_cnt) {
-        // If there are queued audio packet return them first
-        st = s->streams[rm->audio_stream_num];
-        ff_rm_retrieve_cache(s, s->pb, st, st->priv_data, pkt);
+        if (rm->audio_pkt_cnt) {
+            // If there are queued audio packet return them first
+            st = s->streams[rm->audio_stream_num];
+            ff_rm_retrieve_cache(s, s->pb, st, st->priv_data, pkt);
     } else if (rm->old_format) {
-        RMStream *ast;
+                RMStream *ast;
 
-        st = s->streams[0];
-        ast = st->priv_data;
+                st = s->streams[0];
+                ast = st->priv_data;
         if (st->codec->codec_id == CODEC_ID_RA_288) {
             int x, y;
 
             for (y = 0; y < ast->sub_packet_h; y++)
                 for (x = 0; x < ast->sub_packet_h/2; x++)
                     if (get_buffer(pb, ast->pkt.data+x*2*ast->audio_framesize+y*ast->coded_framesize, ast->coded_framesize) <= 0)
-                        return AVERROR(EIO);
+                return AVERROR(EIO);
             rm->audio_stream_num = 0;
             rm->audio_pkt_cnt = ast->sub_packet_h * ast->audio_framesize / st->codec->block_align - 1;
             // Release first audio packet
@@ -728,7 +728,7 @@
             memcpy(pkt->data, ast->pkt.data, st->codec->block_align); //FIXME avoid this
             pkt->flags |= PKT_FLAG_KEY; // Mark first packet as keyframe
             pkt->stream_index = 0;
-        } else {
+            } else {
             /* just read raw bytes */
             len = RAW_PACKET_SIZE;
             len= av_get_packet(pb, pkt, len);
@@ -742,17 +742,17 @@
     } else {
         int seq=1;
 resync:
-        len=sync(s, &timestamp, &flags, &i, &pos);
+                len=sync(s, &timestamp, &flags, &i, &pos);
         if(len<0)
             return AVERROR(EIO);
-        st = s->streams[i];
+                    st = s->streams[i];
 
         if (ff_rm_parse_packet (s, s->pb, st, st->priv_data, len, pkt,
                                 &seq, &flags, &timestamp) < 0)
             goto resync;
 
         if((flags&2) && (seq&0x7F) == 1)
-            av_add_index_entry(st, pos, timestamp, 0, 0, AVINDEX_KEYFRAME);
+                av_add_index_entry(st, pos, timestamp, 0, 0, AVINDEX_KEYFRAME);
     }
 
     return 0;
diff --git a/libavformat/rmenc.c b/libavformat/rmenc.c
old mode 100644
new mode 100755
diff --git a/libavformat/rtp.c b/libavformat/rtp.c
old mode 100644
new mode 100755
diff --git a/libavformat/rtp.h b/libavformat/rtp.h
old mode 100644
new mode 100755
diff --git a/libavformat/rtp_aac.c b/libavformat/rtp_aac.c
old mode 100644
new mode 100755
diff --git a/libavformat/rtp_asf.c b/libavformat/rtp_asf.c
new file mode 100644
index 0000000..b64f470
--- /dev/null
+++ b/libavformat/rtp_asf.c
@@ -0,0 +1,91 @@
+/*
+ * Microsoft RTP/ASF support.
+ * Copyright (c) 2008 Ronald S. Bultje
+ *
+ * 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/rtp_asf.c
+ * @brief Microsoft RTP/ASF support
+ * @author Ronald S. Bultje <rbultje@ronald.bitfreak.net>
+ */
+
+#include <libavutil/base64.h>
+#include <libavutil/avstring.h>
+#include "rtp.h"
+#include "rtp_asf.h"
+#include "rtsp.h"
+#include "asf.h"
+
+void ff_wms_parse_sdp_a_line(AVFormatContext *s, const char *p)
+{
+    if (av_strstart(p, "pgmpu:data:application/vnd.ms.wms-hdr.asfv1;base64,", &p)) {
+        ByteIOContext pb;
+        RTSPState *rt = s->priv_data;
+        int len = strlen(p) * 6 / 8;
+        char *buf = av_mallocz(len);
+        av_base64_decode(buf, p, len);
+
+        init_put_byte(&pb, buf, len, 0, NULL, NULL, NULL, NULL);
+        if (rt->asf_ctx) {
+            av_close_input_stream(rt->asf_ctx);
+            rt->asf_ctx = NULL;
+        }
+        av_open_input_stream(&rt->asf_ctx, &pb, "", &asf_demuxer, NULL);
+        av_free(buf);
+        rt->asf_ctx->pb = NULL;
+    }
+}
+
+static int
+asfrtp_parse_sdp_line (AVFormatContext *s, int stream_index,
+                       PayloadContext *asf, const char *line)
+{
+    if (av_strstart(line, "stream:", &line)) {
+        RTSPState *rt = s->priv_data;
+
+        s->streams[stream_index]->id = strtol(line, NULL, 10);
+
+        if (rt->asf_ctx) {
+            int i;
+
+            for (i = 0; i < rt->asf_ctx->nb_streams; i++) {
+                if (s->streams[stream_index]->id == rt->asf_ctx->streams[i]->id) {
+                    *s->streams[stream_index]->codec =
+                        *rt->asf_ctx->streams[i]->codec;
+                    rt->asf_ctx->streams[i]->codec->extradata_size = 0;
+                    rt->asf_ctx->streams[i]->codec->extradata = NULL;
+                    av_set_pts_info(s->streams[stream_index], 32, 1, 1000);
+                }
+           }
+        }
+    }
+
+    return 0;
+}
+
+#define RTP_ASF_HANDLER(n, s, t) \
+RTPDynamicProtocolHandler ff_ms_rtp_ ## n ## _handler = { \
+    s, \
+    t, \
+    CODEC_ID_NONE, \
+    asfrtp_parse_sdp_line, \
+};
+
+RTP_ASF_HANDLER(asf_pfv, "x-asf-pf",  CODEC_TYPE_VIDEO);
+RTP_ASF_HANDLER(asf_pfa, "x-asf-pf",  CODEC_TYPE_AUDIO);
diff --git a/libavformat/rtp_asf.h b/libavformat/rtp_asf.h
new file mode 100644
index 0000000..2898894
--- /dev/null
+++ b/libavformat/rtp_asf.h
@@ -0,0 +1,43 @@
+/*
+ * Microsoft RTP/ASF support.
+ * Copyright (c) 2008 Ronald S. Bultje
+ *
+ * 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_RTP_ASF_H
+#define AVFORMAT_RTP_ASF_H
+
+#include "avformat.h"
+#include "rtpdec.h"
+
+/**
+ * Parse a Windows Media Server-specific SDP line
+ *
+ * @param s RTSP demux context
+ * @param line the SDP line to be parsed
+ */
+void ff_wms_parse_sdp_a_line(AVFormatContext *s, const char *p);
+
+/**
+ * Handlers for the x-asf-pf payloads (the payload ID for RTP/ASF).
+ * Defined and implemented in rtp_asf.c, registered in rtpdec.c.
+ */
+extern RTPDynamicProtocolHandler ff_ms_rtp_asf_pfv_handler,
+                                 ff_ms_rtp_asf_pfa_handler;
+
+#endif /* AVFORMAT_RTP_ASF_H */
diff --git a/libavformat/rtp_h264.c b/libavformat/rtp_h264.c
index 85133be..47cbf79 100644
--- a/libavformat/rtp_h264.c
+++ b/libavformat/rtp_h264.c
@@ -78,7 +78,7 @@
     assert(h264_data != NULL);
 
     if (!strcmp(attr, "packetization-mode")) {
-        av_log(NULL, AV_LOG_DEBUG, "H.264/RTP Packetization Mode: %d\n", atoi(value));
+        av_log(codec, AV_LOG_DEBUG, "RTP Packetization Mode: %d\n", atoi(value));
         h264_data->packetization_mode = atoi(value);
         /*
            Packetization Mode:
@@ -87,8 +87,8 @@
            2: Interleaved Mode: 25 (STAP-B), 26 (MTAP16), 27 (MTAP24), 28 (FU-A), and 29 (FU-B) are allowed.
          */
         if (h264_data->packetization_mode > 1)
-            av_log(stream, AV_LOG_ERROR,
-                   "H.264/RTP Interleaved RTP mode is not supported yet.");
+            av_log(codec, AV_LOG_ERROR,
+                   "Interleaved RTP mode is not supported yet.");
     } else if (!strcmp(attr, "profile-level-id")) {
         if (strlen(value) == 6) {
             char buffer[3];
@@ -105,8 +105,8 @@
             level_idc = strtol(buffer, NULL, 16);
 
             // set the parameters...
-            av_log(NULL, AV_LOG_DEBUG,
-                   "H.264/RTP Profile IDC: %x Profile IOP: %x Level: %x\n",
+            av_log(codec, AV_LOG_DEBUG,
+                   "RTP Profile IDC: %x Profile IOP: %x Level: %x\n",
                    profile_idc, profile_iop, level_idc);
             h264_data->profile_idc = profile_idc;
             h264_data->profile_iop = profile_iop;
@@ -150,11 +150,11 @@
                     codec->extradata= dest;
                     codec->extradata_size+= sizeof(start_sequence)+packet_size;
                 } else {
-                    av_log(NULL, AV_LOG_ERROR, "H.264/RTP Unable to allocate memory for extradata!");
+                    av_log(codec, AV_LOG_ERROR, "Unable to allocate memory for extradata!");
                 }
             }
         }
-        av_log(NULL, AV_LOG_DEBUG, "H.264/RTP Extradata set to %p (size: %d)!", codec->extradata, codec->extradata_size);
+        av_log(codec, AV_LOG_DEBUG, "Extradata set to %p (size: %d)!", codec->extradata, codec->extradata_size);
     }
 }
 
@@ -231,7 +231,7 @@
                             dst+= nal_size;
                         }
                     } else {
-                        av_log(NULL, AV_LOG_ERROR,
+                        av_log(ctx, AV_LOG_ERROR,
                                "nal size exceeds length: %d %d\n", nal_size, src_len);
                     }
 
@@ -240,7 +240,7 @@
                     src_len -= nal_size;
 
                     if (src_len < 0)
-                        av_log(NULL, AV_LOG_ERROR,
+                        av_log(ctx, AV_LOG_ERROR,
                                "Consumed more bytes than we got! (%d)\n", src_len);
                 } while (src_len > 2);      // because there could be rtp padding..
 
@@ -259,7 +259,7 @@
     case 26:                   // MTAP-16
     case 27:                   // MTAP-24
     case 29:                   // FU-B
-        av_log(NULL, AV_LOG_ERROR,
+        av_log(ctx, AV_LOG_ERROR,
                "Unhandled type (%d) (See RFC for implementation details\n",
                type);
         result= -1;
@@ -305,11 +305,13 @@
     case 30:                   // undefined
     case 31:                   // undefined
     default:
-        av_log(NULL, AV_LOG_ERROR, "Undefined type (%d)", type);
+        av_log(ctx, AV_LOG_ERROR, "Undefined type (%d)", type);
         result= -1;
         break;
     }
 
+    pkt->stream_index = st->index;
+
     return result;
 }
 
diff --git a/libavformat/rtp_mpv.c b/libavformat/rtp_mpv.c
old mode 100644
new mode 100755
diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c
old mode 100644
new mode 100755
index 3e833a1..2107c5e
--- a/libavformat/rtpdec.c
+++ b/libavformat/rtpdec.c
@@ -536,8 +536,8 @@
             break;
         }
 
-        // now perform timestamp things....
-        finalize_packet(s, pkt, timestamp);
+    // now perform timestamp things....
+    finalize_packet(s, pkt, timestamp);
     }
     return rv;
 }
diff --git a/libavformat/rtpdec.h b/libavformat/rtpdec.h
index c5350e7..1a243f8 100644
--- a/libavformat/rtpdec.h
+++ b/libavformat/rtpdec.h
@@ -69,7 +69,9 @@
 
 int rtp_get_local_port(URLContext *h);
 int rtp_set_remote_url(URLContext *h, const char *uri);
+#if (LIBAVFORMAT_VERSION_MAJOR <= 52)
 void rtp_get_file_handles(URLContext *h, int *prtp_fd, int *prtcp_fd);
+#endif
 
 /**
  * some rtp servers assume client is dead if they don't hear from them...
diff --git a/libavformat/rtpenc.c b/libavformat/rtpenc.c
old mode 100644
new mode 100755
diff --git a/libavformat/rtpproto.c b/libavformat/rtpproto.c
old mode 100644
new mode 100755
index 610a7f7..9d80ddf
--- a/libavformat/rtpproto.c
+++ b/libavformat/rtpproto.c
@@ -169,8 +169,8 @@
 
     /* just to ease handle access. XXX: need to suppress direct handle
        access */
-    s->rtp_fd = udp_get_file_handle(s->rtp_hd);
-    s->rtcp_fd = udp_get_file_handle(s->rtcp_hd);
+    s->rtp_fd = url_get_file_handle(s->rtp_hd);
+    s->rtcp_fd = url_get_file_handle(s->rtcp_hd);
 
     h->max_packet_size = url_get_max_packet_size(s->rtp_hd);
     h->is_streamed = 1;
@@ -296,6 +296,7 @@
     return udp_get_local_port(s->rtp_hd);
 }
 
+#if (LIBAVFORMAT_VERSION_MAJOR <= 52)
 /**
  * Return the rtp and rtcp file handles for select() usage to wait for
  * several RTP streams at the same time.
@@ -309,6 +310,13 @@
     *prtp_fd = s->rtp_fd;
     *prtcp_fd = s->rtcp_fd;
 }
+#endif
+
+static int rtp_get_file_handle(URLContext *h)
+{
+    RTPContext *s = h->priv_data;
+    return s->rtp_fd;
+}
 
 URLProtocol rtp_protocol = {
     "rtp",
@@ -317,4 +325,5 @@
     rtp_write,
     NULL, /* seek */
     rtp_close,
+    .url_get_file_handle = rtp_get_file_handle,
 };
diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index a7bd019..da7701c 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -495,14 +495,14 @@
             if (atoi(p) == 1)
                 rt->transport = RTSP_TRANSPORT_RDT;
         } else if (s->nb_streams > 0) {
-            if (rt->server_type == RTSP_SERVER_REAL)
-                ff_real_parse_sdp_a_line(s, s->nb_streams - 1, p);
+                if (rt->server_type == RTSP_SERVER_REAL)
+                    ff_real_parse_sdp_a_line(s, s->nb_streams - 1, p);
 
-            rtsp_st = s->streams[s->nb_streams - 1]->priv_data;
-            if (rtsp_st->dynamic_handler &&
-                rtsp_st->dynamic_handler->parse_sdp_a_line)
-                rtsp_st->dynamic_handler->parse_sdp_a_line(s, s->nb_streams - 1,
-                    rtsp_st->dynamic_protocol_context, buf);
+                rtsp_st = s->streams[s->nb_streams - 1]->priv_data;
+                if (rtsp_st->dynamic_handler &&
+                    rtsp_st->dynamic_handler->parse_sdp_a_line)
+                    rtsp_st->dynamic_handler->parse_sdp_a_line(s, s->nb_streams - 1,
+                        rtsp_st->dynamic_protocol_context, buf);
         }
         break;
     }
@@ -904,7 +904,7 @@
     for(j = RTSP_RTP_PORT_MIN, i = 0; i < rt->nb_rtsp_streams; ++i) {
         char transport[2048];
 
-        rtsp_st = rt->rtsp_streams[i];
+            rtsp_st = rt->rtsp_streams[i];
 
         /* RTP/UDP */
         if (lower_transport == RTSP_LOWER_TRANSPORT_UDP) {
@@ -1292,12 +1292,12 @@
                 rtsp_st = rt->rtsp_streams[i];
                 rtp_get_file_handles(rtsp_st->rtp_handle, &fd1, &fd2);
                 if (FD_ISSET(fd1, &rfds)) {
-                    ret = url_read(rtsp_st->rtp_handle, buf, buf_size);
-                    if (ret > 0) {
-                        *prtsp_st = rtsp_st;
-                        return ret;
+                        ret = url_read(rtsp_st->rtp_handle, buf, buf_size);
+                        if (ret > 0) {
+                            *prtsp_st = rtsp_st;
+                            return ret;
+                        }
                     }
-                }
             }
         }
     }
diff --git a/libavformat/rtsp.h b/libavformat/rtsp.h
old mode 100644
new mode 100755
index d44926a..4ad49ff
--- a/libavformat/rtsp.h
+++ b/libavformat/rtsp.h
@@ -158,6 +158,8 @@
 
 /**
  * Private data for the RTSP demuxer.
+ *
+ * @todo Use ByteIOContext instead of URLContext
  */
 typedef struct RTSPState {
     URLContext *rtsp_hd; /* RTSP TCP connexion handle */
@@ -223,6 +225,12 @@
      * before sending a new "Subscribe:" command. */
     char last_subscription[1024];
     //@}
+
+    /** The following are used for RTP/ASF streams */
+    //@{
+    /** ASF demuxer context for the embedded ASF stream from WMS servers */
+    AVFormatContext *asf_ctx;
+    //@}
 } RTSPState;
 
 /**
diff --git a/libavformat/rtspcodes.h b/libavformat/rtspcodes.h
old mode 100644
new mode 100755
diff --git a/libavformat/segafilm.c b/libavformat/segafilm.c
old mode 100644
new mode 100755
index c1da789..72fc25b
--- a/libavformat/segafilm.c
+++ b/libavformat/segafilm.c
@@ -114,11 +114,11 @@
         if (scratch[23] == 2)
             film->audio_type = CODEC_ID_ADPCM_ADX;
         else if (film->audio_channels > 0) {
-            if (film->audio_bits == 8)
-                film->audio_type = CODEC_ID_PCM_S8;
-            else if (film->audio_bits == 16)
-                film->audio_type = CODEC_ID_PCM_S16BE;
-            else
+        if (film->audio_bits == 8)
+            film->audio_type = CODEC_ID_PCM_S8;
+        else if (film->audio_bits == 16)
+            film->audio_type = CODEC_ID_PCM_S16BE;
+        else
                 film->audio_type = CODEC_ID_NONE;
         } else
             film->audio_type = CODEC_ID_NONE;
@@ -198,8 +198,8 @@
                 audio_frame_counter += (film->sample_table[i].sample_size * 32 /
                     (18 * film->audio_channels));
             else if (film->audio_type != CODEC_ID_NONE)
-                audio_frame_counter += (film->sample_table[i].sample_size /
-                    (film->audio_channels * film->audio_bits / 8));
+            audio_frame_counter += (film->sample_table[i].sample_size /
+                (film->audio_channels * film->audio_bits / 8));
         } else {
             film->sample_table[i].stream = film->video_stream_index;
             film->sample_table[i].pts = AV_RB32(&scratch[8]) & 0x7FFFFFFF;
diff --git a/libavformat/sierravmd.c b/libavformat/sierravmd.c
old mode 100644
new mode 100755
diff --git a/libavformat/smacker.c b/libavformat/smacker.c
old mode 100644
new mode 100755
index b4fc5f7..04dfe8d
--- a/libavformat/smacker.c
+++ b/libavformat/smacker.c
@@ -183,6 +183,7 @@
             ast[i]->codec->bits_per_coded_sample = (smk->rates[i] & SMK_AUD_16BITS) ? 16 : 8;
             if(ast[i]->codec->bits_per_coded_sample == 16 && ast[i]->codec->codec_id == CODEC_ID_PCM_U8)
                 ast[i]->codec->codec_id = CODEC_ID_PCM_S16LE;
+            ast[i]->codec->sample_fmt = ast[i]->codec->bits_per_coded_sample == 8 ? SAMPLE_FMT_U8 : SAMPLE_FMT_S16;
             av_set_pts_info(ast[i], 64, 1, ast[i]->codec->sample_rate
                     * ast[i]->codec->channels * ast[i]->codec->bits_per_coded_sample / 8);
         }
diff --git a/libavformat/sol.c b/libavformat/sol.c
old mode 100644
new mode 100755
diff --git a/libavformat/stv.c b/libavformat/stv.c
new file mode 100755
index 0000000..9a9dd4d
--- /dev/null
+++ b/libavformat/stv.c
@@ -0,0 +1,792 @@
+/*
+ *	SageTV Streaming protocol for ffmpeg client
+ *	Copyright (C) Jeffrey Kardatzke - 07/2006
+ *
+ * This library 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 of the License, or (at your option) any later version.
+ *
+ * This library 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 this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/*
+ * This allows you to stream files directly from a SageTV server
+ */
+
+#include "avformat.h"
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include "libavutil/avstring.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <inttypes.h>
+#include <errno.h>
+#ifndef __MINGW32__
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <netdb.h>
+#else
+#include <windows.h>
+#endif
+
+//#define DEBUG_STV
+
+#define ASKAHEAD 65536
+
+// OSX doesn't have MSG_NOSIGNAL defined, neither does cygwin
+#if (defined(__APPLE__) || defined(__MINGW32__))
+#define MSG_NOSIGNAL 0
+#endif
+
+typedef struct {
+  char host[256];
+  int port;
+  char url[1024];
+  int64_t actualSize;
+  int64_t pos;
+  int fd;
+  int readahead;
+  unsigned int readaheadfactor; // Set to 0 when go out of the read ahead buffer
+  unsigned long long aheaddiscarded;
+  unsigned char flushBuf[4096];
+} STVContext;
+
+#ifdef DEBUG_STV
+static long long get_timebase()
+{
+  struct timeval tm;
+  gettimeofday(&tm, 0);
+  return tm.tv_sec * 1000000LL + (tm.tv_usec);
+}
+#endif
+
+static int flushReadAhead(STVContext *p)
+{
+    p->aheaddiscarded+=p->readahead;
+    while(p->readahead)
+    {
+        int count = recv(p->fd, p->flushBuf, (p->readahead > 4096 ) ? 4096 : p->readahead, 0);
+        if(count<=0)
+        {
+            av_log(NULL, AV_LOG_ERROR, "FAILURE %d\n", __LINE__);
+            return -1;
+        }
+        p->readahead -= count;
+    }
+    p->readaheadfactor=0;
+    return 0;
+}
+
+#define SOCKET_ERROR -1
+#define INVALID_SOCKET -1
+#define RED_TIMEOUT 30000
+
+// Reads data from a socket into the array until the "\r\n" character
+// sequence is encountered. The returned value is the
+// number of bytes read or SOCKET_ERROR if an error occurs, 0
+// if the socket has been closed. The number of bytes will be
+// 2 more than the actual string length because the \r\n chars
+// are removed before this function returns.
+static int sockReadLine(int sd, char* buffer, int bufLen)
+{
+	int currRecv;
+	int newlineIndex = 0;
+	int endFound = 0;
+	int offset = 0;
+	int i = 0;
+	while (!endFound)
+	{
+		if (bufLen <= 0)
+			return SOCKET_ERROR;
+		currRecv = recv(sd, buffer + offset, bufLen, MSG_PEEK);
+		if (currRecv == SOCKET_ERROR)
+		{
+			return SOCKET_ERROR;
+		}
+
+		if (currRecv == 0)
+		{
+			return endFound ? 0 : SOCKET_ERROR;
+		}
+
+		// Scan the buffer for "\r\n" termination
+		for (i = 0; i < (currRecv + offset); i++)
+		{
+			if (buffer[i] == '\r')
+			{
+				if (buffer[i + 1] == '\n')
+				{
+					newlineIndex = i + 1;
+					endFound = 1;
+					break;
+				}
+			}
+		}
+		if (!endFound)
+		{
+			currRecv = recv(sd, buffer + offset, currRecv, 0);
+			if (currRecv == SOCKET_ERROR)
+			{
+				return SOCKET_ERROR;
+			}
+			if (currRecv == 0)
+			{
+				return endFound ? 0 : SOCKET_ERROR;
+			}
+			offset += currRecv;
+			bufLen -= currRecv;
+		}
+	}
+
+	currRecv = recv(sd, buffer + offset, (newlineIndex + 1) - offset, 0);
+	buffer[newlineIndex - 1] = '\0';
+	return currRecv;
+}
+
+static int OpenConnection(STVContext* p)
+{
+	int newfd=-1;
+	struct timeval tv;
+	struct sockaddr address;
+	struct sockaddr_in* inetAddress;
+	struct hostent* hostptr;
+	char data[512];
+	char host[256]; //the same size of STVContext.host
+	int  port;
+#ifdef __MINGW32__
+	int strl;
+	wchar_t* wfilename;
+	int wstrlen;
+	int dataIdx;
+#endif
+	int dataSize;
+	int res;
+	int window_size = 256 * 1024;
+	int wlen = 4;
+
+    #ifdef DEBUG_STV
+    av_log(NULL, AV_LOG_ERROR, "Opening conn to SageTV server\n");
+    #endif
+	newfd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
+	if (newfd == INVALID_SOCKET)
+	{
+        #ifdef DEBUG_STV
+        av_log(NULL, AV_LOG_ERROR,"FAILURE %d\n", __LINE__);
+        #endif
+		return 0;
+	}
+
+    setsockopt(newfd, SOL_SOCKET, SO_RCVBUF, &window_size, sizeof(window_size));
+    getsockopt(newfd, SOL_SOCKET, SO_RCVBUF,
+                         (char*) &window_size, &wlen );
+    av_log(NULL, AV_LOG_ERROR,"STV:// socket recv tcp window size %d\n",window_size);
+
+	// Set the socket timeout option. If a timeout occurs, then it'll be just
+	// like the server closed the socket.
+/*	tv.tv_sec = 30;
+	tv.tv_usec = 0;
+	setsockopt(newfd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv));
+	setsockopt(newfd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv));*/
+	// Set the socket linger option, this makes sure the QUIT message gets received
+	// by the server before the TCP reset message does.
+//	LINGER lingonberry;
+//	lingonberry.l_onoff = TRUE;
+//	lingonberry.l_linger = 1;
+//	if (setsockopt(stream->fd, SOL_SOCKET, SO_LINGER, (char*)&lingonberry, sizeof(LINGER)) == SOCKET_ERROR)
+//	{
+//		return STREAM_ERROR;
+//	}
+
+  port = 7818; //default port
+  char *pc = strchr( p->host, ':' );
+  if ( pc == NULL )
+  {
+    strncpy( host, p->host, sizeof(host)-1 );
+    host[sizeof(host)-1] = 0x0;
+  } else {
+    int len = pc - p->host;
+    if ( len > sizeof(host)-1 )
+      len = sizeof(host) - 1;
+    strncpy( host, p->host, len );
+    host[len] = 0;
+    port = atoi( pc+1 );
+    if ( port == 0 || len == 0 )
+    {
+      #ifdef DEBUG_STV
+      av_log(NULL, AV_LOG_ERROR,"STV:// wrong  host name.%s\n", p->host);
+      #endif
+      return 0;
+    }
+  }
+
+	inetAddress = (struct sockaddr_in*) ( (void *) &address); // cast it to IPV4 addressing
+	inetAddress->sin_family = PF_INET;
+	inetAddress->sin_port = htons(port);
+
+	hostptr = gethostbyname(host);
+	if (!hostptr)
+	{
+		close(newfd);
+        #ifdef DEBUG_STV
+        av_log(NULL, AV_LOG_ERROR, "FAILURE %d\n", __LINE__);
+        #endif
+		return 0;
+	}
+	
+#if !defined(MINGW32) // defined(__APPLE__)
+// Darwin/BSD doesn't have h_addr field, it has an array of addresses instead
+// Apparently neither does whatever lib is installed with Ubuntu 8.10 beta...
+#define h_addr h_addr_list[0]
+#endif
+    memcpy(&inetAddress->sin_addr.s_addr, hostptr->h_addr, hostptr->h_length );
+ 
+    if (connect(newfd, (struct sockaddr *) ((void *)&address), sizeof(address)) < 0)
+	{
+		close(newfd);
+        #ifdef DEBUG_STV
+        av_log(NULL, AV_LOG_ERROR, "FAILURE %d\n", __LINE__);
+        #endif
+		return 0;
+	}
+
+#ifdef __MINGW32__
+	// Check for UTF-8 unicode pathname
+	strl = strlen(p->url);
+	wfilename = av_malloc(sizeof(wchar_t) * (1 + strl));
+	int wpos = 0;
+	int i = 0;
+	for (i = 0; i < strl; i++)
+	{
+		wfilename[wpos] = 0;
+		if ((p->url[i] & 0x80) == 0)
+		{
+			// ASCII character
+			wfilename[wpos++] = p->url[i];
+		}
+		else if (i + 1 < strl && ((p->url[i] & 0xE0) == 0xC0) && ((p->url[i + 1] & 0xC0) == 0x80))
+		{
+			// two octets for this character
+			wfilename[wpos++] = ((p->url[i] & 0x1F) << 6) + (p->url[i + 1] & 0x3F);
+			i++;
+		}
+		else if (i + 2 < strl && ((p->url[i] & 0xF0) == 0xE0) && ((p->url[i + 1] & 0xC0) == 0x80) && 
+			((p->url[i + 2] & 0xC0) == 0x80))
+		{
+			// three octets for this character
+			wfilename[wpos++] = ((p->url[i] & 0x0F) << 12) + ((p->url[i + 1] & 0x3F) << 6) + (p->url[i + 2] & 0x3F);
+			i+=2;
+		}
+		else
+			wfilename[wpos++] = p->url[i];
+	}
+	wfilename[wpos] = 0;
+	strcpy(data, "OPENW ");
+	wstrlen = wcslen(wfilename);
+	dataIdx = strlen(data);
+	for (i = 0; i < wstrlen; i++, dataIdx+=2)
+	{
+		data[dataIdx] = ((wfilename[i] & 0xFF00) >> 8);
+		data[dataIdx + 1] = (wfilename[i] & 0xFF);
+	}
+	data[dataIdx++] = '\r';
+	data[dataIdx++] = '\n';
+	av_free(wfilename);
+	dataSize = dataIdx;
+#else
+	strcpy(data, "OPEN ");
+	av_strlcat(data, p->url, 512);
+	av_strlcat(data, "\r\n", 512);
+	dataSize = strlen(data);
+#endif
+	if (send(newfd, data, dataSize, MSG_NOSIGNAL) < dataSize)
+	{
+		close(newfd);
+        #ifdef DEBUG_STV
+        av_log(NULL, AV_LOG_ERROR, "FAILURE %d\n", __LINE__);
+        #endif
+		return 0;
+	}
+
+	if ((res = sockReadLine(newfd, data, sizeof(data))) <= 0 || strcmp(data, "OK"))
+	{
+		close(newfd);
+        #ifdef DEBUG_STV
+        av_log(NULL, AV_LOG_ERROR, "FAILURE %d\n", __LINE__);
+        #endif
+		return 0;
+	}
+	p->fd = newfd;
+	p->readahead=0;
+	p->readaheadfactor=0;
+	return 1;
+}
+
+int ReOpenConnection(STVContext* p)
+{
+    char data[512];
+	int dataSize;
+	int readaheadval=p->readahead;
+    #ifdef DEBUG_STV
+    av_log(NULL, AV_LOG_ERROR, "Reopening connection\n");
+    #endif
+    if (!p->url) return 0;
+	close(p->fd);
+	p->fd = 0;
+	if (OpenConnection(p))
+	{
+		// We must ask for same data in readahead
+        snprintf(data, 512, "READ %"PRId64" %d\r\n", p->pos, readaheadval);
+        dataSize = strlen(data);
+        #ifdef DEBUG_STV
+        av_log(NULL, AV_LOG_ERROR, "Sending cmd to SageTV Server:%s\n", data);
+        #endif
+        if (send(p->fd, data, dataSize, MSG_NOSIGNAL) < dataSize)
+        {
+            return 0;
+        }
+        p->readahead=readaheadval; // We must know how much ahead we were
+		return 1;
+	}
+	return 0;
+}
+
+static int64_t stv_seek(URLContext *h, int64_t pos, int whence)
+{
+	int64_t availSize;
+	char data[512];
+	int dataSize;
+	int nbytes;
+	char* spacePtr;
+	STVContext* p = h->priv_data;
+    flushReadAhead(p);
+    #ifdef DEBUG_STV
+    av_log(NULL, AV_LOG_ERROR, "stv_seek %"PRId64" %d active=%d\n", pos, whence, ((h->flags & URL_ACTIVEFILE) == URL_ACTIVEFILE));
+    #endif
+	if (pos >= 0 && ((h->flags & URL_ACTIVEFILE) == URL_ACTIVEFILE) && whence != SEEK_END && 
+		whence != AVSEEK_SIZE)
+	{
+		if (whence == SEEK_CUR)
+			p->pos += pos;
+		else if (whence == SEEK_SET)
+			p->pos = pos;
+		return p->pos;
+	}
+	
+	if ((h->flags & URL_ACTIVEFILE) == URL_ACTIVEFILE)
+	{
+        strcpy(data, "SIZE\r\n");
+        dataSize = strlen(data);
+        #ifdef DEBUG_STV
+        av_log(NULL, AV_LOG_ERROR, "Sending cmd to SageTV Server:%s", data);
+        #endif
+        if (send(p->fd, data, dataSize, MSG_NOSIGNAL) < dataSize)
+        {
+            #ifdef DEBUG_STV
+            av_log(NULL, AV_LOG_ERROR, "FAILURE %d\n", __LINE__);
+            #endif
+            if (!ReOpenConnection(p))
+            {
+                #ifdef DEBUG_STV
+                av_log(NULL, AV_LOG_ERROR, "FAILURE %d\n", __LINE__);
+                #endif
+                return 0;
+            }
+            if (send(p->fd, data, dataSize, MSG_NOSIGNAL) < dataSize)
+            {
+                #ifdef DEBUG_STV
+                av_log(NULL, AV_LOG_ERROR, "FAILURE %d\n", __LINE__);
+                #endif
+                return 0;
+            }
+        }
+        flushReadAhead(p);
+        nbytes = sockReadLine(p->fd, data, sizeof(data));
+        if (nbytes <= 0)
+        {
+            #ifdef DEBUG_STV
+            av_log(NULL, AV_LOG_ERROR, "FAILURE %d\n", __LINE__);
+            #endif
+            if (!ReOpenConnection(p))
+            {
+                #ifdef DEBUG_STV
+                av_log(NULL, AV_LOG_ERROR, "FAILURE %d\n", __LINE__);
+                #endif
+                return 0;
+            }
+            strcpy(data, "SIZE\r\n");
+            if (send(p->fd, data, dataSize, MSG_NOSIGNAL) < dataSize)
+            {
+                #ifdef DEBUG_STV
+                av_log(NULL, AV_LOG_ERROR, "FAILURE %d\n", __LINE__);
+                #endif
+                return 0;
+            }
+            flushReadAhead(p);
+            nbytes = sockReadLine(p->fd, data, sizeof(data));
+            if (nbytes <= 0)
+            {
+                #ifdef DEBUG_STV
+                av_log(NULL, AV_LOG_ERROR, "FAILURE %d\n", __LINE__);
+                #endif
+                return 0;
+            }
+        }
+        #ifdef DEBUG_STV
+        av_log(NULL, AV_LOG_ERROR, "Read back %s\n", data);
+        #endif
+        spacePtr = strchr(data, ' ');
+        if (!spacePtr)
+        {
+            #ifdef DEBUG_STV
+            av_log(NULL, AV_LOG_ERROR, "FAILURE %d\n", __LINE__);
+            #endif
+            return p->pos;
+        }
+        *spacePtr = '\0';
+        
+        availSize =  strtoll(data, NULL, 10);
+    }
+    else
+    {
+        availSize = p->actualSize;
+    }
+	if (whence == AVSEEK_SIZE)
+		return availSize;
+	if (whence == SEEK_CUR)
+		pos += p->pos;
+	else if (whence == SEEK_END)
+		pos += availSize;
+    #ifdef DEBUG_STV
+    av_log(NULL, AV_LOG_ERROR, "seek new pos %lld avail %lld\n", pos, availSize);
+    #endif
+	if (pos >= 0 && (pos <= availSize || ((h->flags & URL_ACTIVEFILE) == URL_ACTIVEFILE)))
+	{
+        #ifdef DEBUG_STV
+        av_log(NULL, AV_LOG_ERROR, "Setting stream pos to %lld\n", pos);
+        #endif
+		p->pos = pos;
+		return pos;
+	}
+	else
+	{
+        #ifdef DEBUG_STV
+        av_log(NULL, AV_LOG_ERROR, "FAILURE %d\n", __LINE__);
+        #endif
+		return p->pos;
+	}
+}
+
+static int64_t size(URLContext* h, STVContext* p, int64_t *availSize)
+{
+	char data[512];
+	int64_t otherAvail;
+	int dataSize;
+	int nbytes;
+	char* spacePtr;
+	int64_t totalSize;
+	if (!availSize)
+		availSize = &otherAvail;
+	strcpy(data, "SIZE\r\n");
+	dataSize = strlen(data);
+    #ifdef DEBUG_STV
+    av_log(NULL, AV_LOG_ERROR, "Sending2 cmd to SageTV Server:%s\n", data);
+    #endif
+	if (send(p->fd, data, dataSize, MSG_NOSIGNAL) < dataSize)
+	{
+        #ifdef DEBUG_STV
+        av_log(NULL, AV_LOG_ERROR, "FAILURE %d\n", __LINE__);
+        av_log(NULL, AV_LOG_ERROR, "socket write failed, reopening...\n");
+        #endif
+		if (!ReOpenConnection(p))
+		{
+            #ifdef DEBUG_STV
+            av_log(NULL, AV_LOG_ERROR, "FAILURE %d\n", __LINE__);
+            #endif
+			return 0;
+		}
+		if (send(p->fd, data, dataSize, MSG_NOSIGNAL) < dataSize)
+		{
+            #ifdef DEBUG_STV
+            av_log(NULL, AV_LOG_ERROR, "FAILURE %d\n", __LINE__);
+            #endif
+			return 0;
+		}
+	}
+
+    flushReadAhead(p);
+	nbytes = sockReadLine(p->fd, data, sizeof(data));
+	if (nbytes <= 0)
+	{
+        #ifdef DEBUG_STV
+        av_log(NULL, AV_LOG_ERROR, "FAILURE %d\n", __LINE__);
+        #endif
+		if (!ReOpenConnection(p))
+		{
+            #ifdef DEBUG_STV
+            av_log(NULL, AV_LOG_ERROR, "FAILURE %d\n", __LINE__);
+            #endif
+			return 0;
+		}
+		strcpy(data, "SIZE\r\n");
+		if (send(p->fd, data, dataSize, MSG_NOSIGNAL) < dataSize)
+		{
+            #ifdef DEBUG_STV
+            av_log(NULL, AV_LOG_ERROR, "FAILURE %d\n", __LINE__);
+            #endif
+			return 0;
+		}
+        flushReadAhead(p);
+		nbytes = sockReadLine(p->fd, data, sizeof(data));
+		if (nbytes <= 0)
+		{
+            #ifdef DEBUG_STV
+            av_log(NULL, AV_LOG_ERROR, "FAILURE %d\n", __LINE__);
+            #endif
+			return 0;
+		}
+	}
+    #ifdef DEBUG_STV
+    av_log(NULL, AV_LOG_ERROR, "Read back %s\n", data);
+    #endif
+	spacePtr = strchr(data, ' ');
+	if (!spacePtr)
+	{
+        #ifdef DEBUG_STV
+        av_log(NULL, AV_LOG_ERROR, "FAILURE %d\n", __LINE__);
+        #endif
+		return 0;
+	}
+	*spacePtr = '\0';
+	if (availSize)
+		*availSize = strtoll(data, NULL, 10);
+	totalSize = strtoll(spacePtr + 1, NULL, 10);
+	if (totalSize != *availSize)
+	{
+		h->flags = h->flags | URL_ACTIVEFILE;
+	}
+    #ifdef DEBUG_STV
+    av_log(NULL, AV_LOG_ERROR, "avail=%lld total=%lld\n", *availSize, totalSize);
+    #endif
+	return totalSize;
+}
+
+
+static int stv_read(URLContext *h, unsigned char* pbBuffer, int max_len)
+{
+	STVContext *p = h->priv_data;
+	char data[512];
+	int dataSize;
+	int nbytes;
+	char* pOriginalBuffer;
+	int originaldwBytesToRead;
+	int bytesRead;
+	int stv_read_len = max_len;
+
+	// Check on EOS condition
+	if ((h->flags & URL_ACTIVEFILE) == URL_ACTIVEFILE && ((max_len + p->pos) > p->actualSize))
+	{
+		int64_t totalSize;
+		totalSize = size(h, p, &p->actualSize);
+		if(totalSize==p->actualSize) h->flags&=~URL_ACTIVEFILE;
+		#ifdef DEBUG_STV
+		av_log(NULL, AV_LOG_ERROR, "Active file is :%d %lld %lld\n", 
+			h->flags & URL_ACTIVEFILE,totalSize,p->actualSize);
+		#endif
+	}
+	if (!p->actualSize && (h->flags & URL_ACTIVEFILE) != URL_ACTIVEFILE)
+	{
+		// Get the actual size and store it
+		size(h, p, &p->actualSize);
+	}
+	if (p->actualSize && (h->flags & URL_ACTIVEFILE) != URL_ACTIVEFILE)
+	{
+		p->readaheadfactor+=1;
+		if(p->readaheadfactor > 2)
+		{
+			max_len += ASKAHEAD - p->readahead;
+		}
+		if (max_len + p->pos > p->actualSize)
+		{
+			max_len = p->actualSize - p->pos;
+			if (max_len < 0)
+			{
+				max_len = 0;
+				return -1; // Signal EOF
+			}
+		}
+		p->readahead+=max_len;
+	}
+	else
+	{
+		p->readahead=max_len;
+	}
+	if (max_len <= 0) return 0;
+	if (stv_read_len > max_len ) stv_read_len = max_len;
+// Test JFT
+    #ifdef DEBUG_STV
+    av_log(NULL, AV_LOG_ERROR, "Read ahead values %d %d %d at %lld\n", 
+        p->readahead, p->readaheadfactor, max_len, get_timebase());
+    #endif
+
+	snprintf(data, 512, "READ %"PRId64" %d\r\n", p->pos+p->readahead-max_len, max_len);
+	dataSize = strlen(data);
+    #ifdef DEBUG_STV
+    av_log(NULL, AV_LOG_ERROR, "Sending cmd to SageTV Server:%s\n", data);
+    #endif
+	if (send(p->fd, data, dataSize, MSG_NOSIGNAL) < dataSize)
+	{
+        #ifdef DEBUG_STV
+        av_log(NULL, AV_LOG_ERROR, "FAILURE %d\n", __LINE__);
+        #endif
+		// Try to do it again...
+		if (!ReOpenConnection(p))
+		{
+            #ifdef DEBUG_STV
+            av_log(NULL, AV_LOG_ERROR, "FAILURE %d\n", __LINE__);
+            #endif
+			return 0;
+		}
+	}
+
+    #ifdef DEBUG_STV
+    av_log(NULL, AV_LOG_ERROR, "Before receiving reply");
+    #endif
+
+	pOriginalBuffer = pbBuffer;
+	originaldwBytesToRead = stv_read_len;
+	bytesRead = 0;
+	nbytes = recv(p->fd, (char*)pbBuffer, stv_read_len, 0);
+	while (nbytes > 0 && stv_read_len > 0)
+	{
+		stv_read_len -= nbytes;
+		pbBuffer += nbytes;
+		bytesRead += nbytes;
+		p->pos += nbytes;
+		p->readahead-= nbytes;
+		if (stv_read_len > 0)
+			nbytes = recv(p->fd, (char*)pbBuffer, stv_read_len, 0);
+	}
+	if (nbytes <= 0)
+	{
+        #ifdef DEBUG_STV
+        av_log(NULL, AV_LOG_ERROR, "FAILURE %d\n", __LINE__);
+        #endif
+		if (!ReOpenConnection(p))
+		{
+            #ifdef DEBUG_STV
+            av_log(NULL, AV_LOG_ERROR, "FAILURE %d\n", __LINE__);
+            #endif
+			return 0;
+		}
+        nbytes = recv(p->fd, (char*)pbBuffer, stv_read_len, 0);
+        while (nbytes > 0 && stv_read_len > 0)
+        {
+            stv_read_len -= nbytes;
+            pbBuffer += nbytes;
+            bytesRead += nbytes;
+            p->pos += nbytes;
+            p->readahead-= nbytes;
+            if (stv_read_len > 0)
+                nbytes = recv(p->fd, (char*)pbBuffer, stv_read_len, 0);
+        }
+		if (nbytes <= 0)
+		{
+            #ifdef DEBUG_STV
+            av_log(NULL, AV_LOG_ERROR, "FAILURE %d\n", __LINE__);
+            #endif
+			return 0;
+		}
+	}
+    #ifdef DEBUG_STV
+    av_log(NULL, AV_LOG_ERROR, "Read %d bytes from network (%lld %d)\n", 
+        bytesRead, p->actualSize, h->flags & URL_ACTIVEFILE);
+    #endif
+	return bytesRead;
+}
+
+static int stv_close(URLContext *h)
+{
+	STVContext *p = h->priv_data;
+	if (p->fd)
+	{
+		char* data = "QUIT\r\n";
+		int dataSize = strlen(data);
+        flushReadAhead(p);
+		send(p->fd, data, dataSize, MSG_NOSIGNAL);
+		close(p->fd);
+		p->fd = 0;
+	}
+#ifdef __MINGW32__
+	WSACleanup();
+#endif
+	av_free(p);
+	return 0;
+}
+
+static int stv_open(URLContext *h, const char *filename, int flags)
+{
+	STVContext *p;
+	char* fullURL;
+	char* pathSlash;
+    if (flags & URL_RDWR) {
+        return -ENOENT;
+    } else if (flags & URL_WRONLY) {
+        return -ENOENT;
+    } 
+
+	p = av_mallocz(sizeof(STVContext));
+	if (!p)
+		return -ENOMEM;
+#ifdef __MINGW32__
+	WSADATA wsaData;
+	if (WSAStartup(0x202,&wsaData) == SOCKET_ERROR) {
+		return AVERROR_IO;
+	}
+#endif
+	h->priv_data = p;
+	if (!av_strstart(filename, "stv://", (const char **)&fullURL))
+		goto fail;
+	pathSlash = strchr(fullURL, '/');
+	if (!pathSlash)
+		goto fail;
+	if (pathSlash - fullURL > 255)
+		goto fail;
+	strncpy(p->host, fullURL, pathSlash - fullURL);
+	av_strlcpy(p->url, pathSlash + 1, 1024);
+
+	if (!OpenConnection(p))
+		goto fail;
+
+	if ((h->flags & URL_ACTIVEFILE) == URL_ACTIVEFILE)
+		p->actualSize = 0;
+	else
+		size(h, p, &p->actualSize);
+
+	return 0;
+
+fail:
+	stv_close(h);
+    return AVERROR_IO;
+}
+
+URLProtocol stv_protocol = {
+	"stv",
+	stv_open,
+	stv_read,
+	NULL, /* write */
+	stv_seek,
+	stv_close,
+};
diff --git a/libavformat/swf.h b/libavformat/swf.h
old mode 100644
new mode 100755
index 0fee1e6..a4638bb
--- a/libavformat/swf.h
+++ b/libavformat/swf.h
@@ -75,7 +75,7 @@
     int video_frame_number;
     int frame_rate;
     int tag;
-    AVFifoBuffer audio_fifo;
+    AVFifoBuffer *audio_fifo;
     AVCodecContext *audio_enc, *video_enc;
 } SWFContext;
 
diff --git a/libavformat/swfdec.c b/libavformat/swfdec.c
old mode 100644
new mode 100755
diff --git a/libavformat/swfenc.c b/libavformat/swfenc.c
old mode 100644
new mode 100755
index b433f6b..8caf0d1
--- a/libavformat/swfenc.c
+++ b/libavformat/swfenc.c
@@ -192,7 +192,7 @@
                     return -1;
                 }
                 swf->audio_enc = enc;
-                av_fifo_init(&swf->audio_fifo, AUDIO_FIFO_SIZE);
+                swf->audio_fifo= av_fifo_alloc(AUDIO_FIFO_SIZE);
             } else {
                 av_log(s, AV_LOG_ERROR, "SWF muxer only supports MP3\n");
                 return -1;
@@ -414,12 +414,12 @@
     swf->swf_frame_number++;
 
     /* streaming sound always should be placed just before showframe tags */
-    if (swf->audio_enc && av_fifo_size(&swf->audio_fifo)) {
-        int frame_size = av_fifo_size(&swf->audio_fifo);
+    if (swf->audio_enc && av_fifo_size(swf->audio_fifo)) {
+        int frame_size = av_fifo_size(swf->audio_fifo);
         put_swf_tag(s, TAG_STREAMBLOCK | TAG_LONG);
         put_le16(pb, swf->sound_samples);
         put_le16(pb, 0); // seek samples
-        av_fifo_generic_read(&swf->audio_fifo, frame_size, &put_buffer, pb);
+        av_fifo_generic_read(swf->audio_fifo, pb, frame_size, &put_buffer);
         put_swf_end_tag(s);
 
         /* update FIFO */
@@ -444,12 +444,12 @@
     if (swf->swf_frame_number == 16000)
         av_log(enc, AV_LOG_INFO, "warning: Flash Player limit of 16000 frames reached\n");
 
-    if (av_fifo_size(&swf->audio_fifo) + size > AUDIO_FIFO_SIZE) {
+    if (av_fifo_size(swf->audio_fifo) + size > AUDIO_FIFO_SIZE) {
         av_log(s, AV_LOG_ERROR, "audio fifo too small to mux audio essence\n");
         return -1;
     }
 
-    av_fifo_generic_write(&swf->audio_fifo, buf, size, NULL);
+    av_fifo_generic_write(swf->audio_fifo, buf, size, NULL);
     swf->sound_samples += enc->frame_size;
 
     /* if audio only stream make sure we add swf frames */
@@ -481,7 +481,7 @@
         if (enc->codec_type == CODEC_TYPE_VIDEO)
             video_enc = enc;
         else
-            av_fifo_free(&swf->audio_fifo);
+            av_fifo_free(swf->audio_fifo);
     }
 
     put_swf_tag(s, TAG_END);
diff --git a/libavformat/tcp.c b/libavformat/tcp.c
old mode 100644
new mode 100755
index b81ab93..b7983e7
--- a/libavformat/tcp.c
+++ b/libavformat/tcp.c
@@ -181,6 +181,12 @@
     return 0;
 }
 
+static int tcp_get_file_handle(URLContext *h)
+{
+    TCPContext *s = h->priv_data;
+    return s->fd;
+}
+
 URLProtocol tcp_protocol = {
     "tcp",
     tcp_open,
@@ -188,4 +194,5 @@
     tcp_write,
     NULL, /* seek */
     tcp_close,
+    .url_get_file_handle = tcp_get_file_handle,
 };
diff --git a/libavformat/timefilter.c b/libavformat/timefilter.c
new file mode 100644
index 0000000..e794021
--- /dev/null
+++ b/libavformat/timefilter.c
@@ -0,0 +1,145 @@
+/*
+ * Delay Locked Loop based time filter
+ * Copyright (c) 2009 Samalyse
+ * Copyright (c) 2009 Michael Niedermayer
+ * Author: Olivier Guilyardi <olivier samalyse com>
+ *         Michael Niedermayer <michaelni gmx at>
+ *
+ * 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 "config.h"
+#include "avformat.h"
+#include "timefilter.h"
+
+struct TimeFilter {
+    /// Delay Locked Loop data. These variables refer to mathematical
+    /// concepts described in: http://www.kokkinizita.net/papers/usingdll.pdf
+    double cycle_time;
+    double feedback2_factor;
+    double feedback3_factor;
+    double clock_period;
+    int count;
+};
+
+TimeFilter * ff_timefilter_new(double clock_period, double feedback2_factor, double feedback3_factor)
+{
+    TimeFilter *self        = av_mallocz(sizeof(TimeFilter));
+    self->clock_period      = clock_period;
+    self->feedback2_factor  = feedback2_factor;
+    self->feedback3_factor  = feedback3_factor;
+    return self;
+}
+
+void ff_timefilter_destroy(TimeFilter *self)
+{
+    av_freep(&self);
+}
+
+void ff_timefilter_reset(TimeFilter *self)
+{
+    self->count      = 0;
+}
+
+double ff_timefilter_update(TimeFilter *self, double system_time, double period)
+{
+    self->count++;
+    if (self->count==1) {
+        /// init loop
+        self->cycle_time    = system_time;
+    } else {
+        double loop_error;
+        self->cycle_time   += self->clock_period * period;
+        /// calculate loop error
+        loop_error          = system_time - self->cycle_time;
+
+        /// update loop
+        self->cycle_time   += FFMAX(self->feedback2_factor, 1.0/(self->count)) * loop_error;
+        self->clock_period += self->feedback3_factor * loop_error / period;
+    }
+    return self->cycle_time;
+}
+
+#ifdef TEST
+#undef rand
+int main(void)
+{
+    double n0,n1;
+#define SAMPLES 1000
+    double ideal[SAMPLES];
+    double samples[SAMPLES];
+#if 1
+    for(n0= 0; n0<40; n0=2*n0+1){
+        for(n1= 0; n1<10; n1=2*n1+1){
+#else
+    {{
+        n0=7;
+        n1=1;
+#endif
+            double best_error= 1000000000;
+            double bestpar0=1;
+            double bestpar1=0.001;
+            int better, i;
+
+            srandom(123);
+            for(i=0; i<SAMPLES; i++){
+                ideal[i]  = 10 + i + n1*i/(1000);
+                samples[i]= ideal[i] + n0*(rand()-RAND_MAX/2)/(RAND_MAX*10LL);
+            }
+
+            do{
+                double par0, par1;
+                better=0;
+                for(par0= bestpar0*0.8; par0<=bestpar0*1.21; par0+=bestpar0*0.05){
+                    for(par1= bestpar1*0.8; par1<=bestpar1*1.21; par1+=bestpar1*0.05){
+                        double error=0;
+                        TimeFilter *tf= ff_timefilter_new(1, par0, par1);
+                        for(i=0; i<SAMPLES; i++){
+                            double filtered;
+                            filtered=  ff_timefilter_update(tf, samples[i], 1);
+                            error += (filtered - ideal[i]) * (filtered - ideal[i]);
+                        }
+                        ff_timefilter_destroy(tf);
+                        if(error < best_error){
+                            best_error= error;
+                            bestpar0= par0;
+                            bestpar1= par1;
+                            better=1;
+                        }
+                    }
+                }
+            }while(better);
+#if 0
+            double lastfil=9;
+            TimeFilter *tf= ff_timefilter_new(1, bestpar0, bestpar1);
+            for(i=0; i<SAMPLES; i++){
+                double filtered;
+                filtered=  ff_timefilter_update(tf, samples[i], 1);
+                printf("%f %f %f %f\n", i - samples[i] + 10, filtered - samples[i], samples[FFMAX(i, 1)] - samples[FFMAX(i-1, 0)], filtered - lastfil);
+                lastfil= filtered;
+            }
+            ff_timefilter_destroy(tf);
+#else
+            printf(" [%f %f %f]", bestpar0, bestpar1, best_error);
+#endif
+        }
+        printf("\n");
+    }
+    return 0;
+}
+#endif
diff --git a/libavformat/timefilter.h b/libavformat/timefilter.h
new file mode 100644
index 0000000..ded8ec7
--- /dev/null
+++ b/libavformat/timefilter.h
@@ -0,0 +1,97 @@
+/*
+ * Delay Locked Loop based time filter prototypes and declarations
+ * Copyright (c) 2009 Samalyse
+ * Copyright (c) 2009 Michael Niedermayer
+ * Author: Olivier Guilyardi <olivier samalyse com>
+ *         Michael Niedermayer <michaelni gmx at>
+ *
+ * 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_TIMEFILTER_H
+#define AVFORMAT_TIMEFILTER_H
+
+/**
+ * Opaque type representing a time filter state
+ *
+ * The purpose of this filter is to provide a way to compute accurate time
+ * stamps that can be compared to wall clock time, especially when dealing
+ * with two clocks: the system clock and a hardware device clock, such as
+ * a soundcard.
+ */
+typedef struct TimeFilter TimeFilter;
+
+
+/**
+ * Create a new Delay Locked Loop time filter
+ *
+ * feedback2_factor and feedback3_factor are the factors used for the
+ * multiplications that are respectively performed in the second and third
+ * feedback paths of the loop.
+ *
+ * Unless you know what you are doing, you should set these as follow:
+ *
+ * o = 2 * M_PI * bandwidth * period
+ * feedback2_factor = sqrt(2 * o)
+ * feedback3_factor = o * o
+ *
+ * Where bandwidth is up to you to choose. Smaller values will filter out more
+ * of the jitter, but also take a longer time for the loop to settle. A good
+ * starting point is something between 0.3 and 3 Hz.
+ *
+ * @param clock_period period of the hardware clock in seconds
+ *        (for example 1.0/44100)
+ *
+ * For more details about these parameters and background concepts please see:
+ * http://www.kokkinizita.net/papers/usingdll.pdf
+ */
+TimeFilter * ff_timefilter_new(double clock_period, double feedback2_factor, double feedback3_factor);
+
+/**
+ * Update the filter
+ *
+ * This function must be called in real time, at each process cycle.
+ *
+ * @param period the device cycle duration in clock_periods. For example, at
+ * 44.1kHz and a buffer size of 512 frames, period = 512 when clock_period
+ * was 1.0/44100, or 512/44100 if clock_period was 1.
+ *
+ * system_time, in seconds, should be the value of the system clock time,
+ * at (or as close as possible to) the moment the device hardware interrupt
+ * occured (or any other event the device clock raises at the beginning of a
+ * cycle).
+ *
+ * @return the filtered time, in seconds
+ */
+double ff_timefilter_update(TimeFilter *self, double system_time, double period);
+
+/**
+ * Reset the filter
+ *
+ * This function should mainly be called in case of XRUN.
+ *
+ * Warning: after calling this, the filter is in an undetermined state until
+ * the next call to ff_timefilter_update()
+ */
+void ff_timefilter_reset(TimeFilter *);
+
+/**
+ * Free all resources associated with the filter
+ */
+void ff_timefilter_destroy(TimeFilter *);
+
+#endif /* AVFORMAT_TIMEFILTER_H */
diff --git a/libavformat/tta.c b/libavformat/tta.c
old mode 100644
new mode 100755
diff --git a/libavformat/txd.c b/libavformat/txd.c
index bf62ac6..0fd33e6 100644
--- a/libavformat/txd.c
+++ b/libavformat/txd.c
@@ -64,7 +64,7 @@
     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");
+        av_log(s, AV_LOG_ERROR, "marker does not match\n");
         return AVERROR(EIO);
     }
 
@@ -78,7 +78,7 @@
         case TXD_TEXTURE:
             goto next_chunk;
         default:
-            av_log(NULL, AV_LOG_ERROR, "unknown chunk id %i\n", id);
+            av_log(s, AV_LOG_ERROR, "unknown chunk id %i\n", id);
             return AVERROR(EIO);
     }
 
diff --git a/libavformat/udp.c b/libavformat/udp.c
old mode 100644
new mode 100755
index 70d0e2b..a89de00
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -326,6 +326,9 @@
  * streams at the same time.
  * @param h media file context
  */
+#if (LIBAVFORMAT_VERSION_MAJOR >= 53)
+static
+#endif
 int udp_get_file_handle(URLContext *h)
 {
     UDPContext *s = h->priv_data;
@@ -528,4 +531,5 @@
     udp_write,
     NULL, /* seek */
     udp_close,
+    .url_get_file_handle = udp_get_file_handle,
 };
diff --git a/libavformat/utils.c b/libavformat/utils.c
old mode 100644
new mode 100755
index 223d567..3d2c6a3
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -28,6 +28,11 @@
 #include <time.h>
 #include <strings.h>
 
+#if defined(__MINGW32__)
+#include <sys/types.h>
+#include <sys/timeb.h>
+#endif
+
 #undef NDEBUG
 #include <assert.h>
 
@@ -281,7 +286,7 @@
     uint8_t *data;
     if((unsigned)size > (unsigned)size + FF_INPUT_BUFFER_PADDING_SIZE)
         return AVERROR(ENOMEM);
-    data = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
+    data = av_mallocUncached(size + FF_INPUT_BUFFER_PADDING_SIZE);
     if (!data)
         return AVERROR(ENOMEM);
     memset(data + size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
@@ -311,6 +316,35 @@
     return ret;
 }
 
+int av_get_packet_nobuf(ByteIOContext *s, AVPacket *pkt, int size, int64_t pos)
+{
+    int buffer_size;
+    int ret= av_new_packet(pkt, size);
+
+    if(ret<0)
+        return ret;
+
+    buffer_size=s->buffer_size;
+    s->buffer_size=0; // Temporarily so it won't fill the buffer
+
+    pkt->pos= pos;
+
+    s->buf_ptr = s->buffer;
+    s->buf_end = s->buffer;
+    url_fseek(s, pos, SEEK_SET);
+
+    ret= get_buffer(s, pkt->data, size);
+    if(ret<=0)
+        av_free_packet(pkt);
+    else
+        pkt->size= ret;
+
+    s->buffer_size=buffer_size;
+
+    return ret;
+}
+
+
 int av_dup_packet(AVPacket *pkt)
 {
     if (((pkt->destruct == av_destruct_packet_nofree) || (pkt->destruct == NULL)) && pkt->data) {
@@ -318,11 +352,11 @@
         /* 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);
+        data = av_mallocUncached(pkt->size + FF_INPUT_BUFFER_PADDING_SIZE);
         if (!data) {
             return AVERROR(ENOMEM);
         }
-        memcpy(data, pkt->data, pkt->size);
+        av_memcpy(data, pkt->data, pkt->size);
         memset(data + pkt->size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
         pkt->data = data;
         pkt->destruct = av_destruct_packet;
@@ -353,12 +387,14 @@
                 score = 50;
             }
         }
+//		if(score) av_log(NULL, AV_LOG_DEBUG, "format %s probe scored %d\n", fmt1->name, score);
         if (score > *score_max) {
             *score_max = score;
             fmt = fmt1;
         }else if (score == *score_max)
             fmt = NULL;
     }
+//    if(fmt) av_log(NULL, AV_LOG_DEBUG, " ------------  Found format: %s\n", fmt->name);
     return fmt;
 }
 
@@ -572,6 +608,7 @@
 
 int av_read_packet(AVFormatContext *s, AVPacket *pkt)
 {
+    int packetbufsize=0;
     int ret;
     AVStream *st;
 
@@ -623,7 +660,25 @@
                 if(st->codec->codec_id != CODEC_ID_PROBE){
                     pd->buf_size=0;
                     av_freep(&pd->buf);
-                }
+                } else {
+					// bail if the probe size gets too big
+					// do this after we probe in case something causes us to overrun our limit before we have a chance
+					AVPacketList *pktlist1=s->raw_packet_buffer;
+					while(pktlist1)
+					{
+						packetbufsize+=pktlist1->pkt.size;
+						pktlist1=pktlist1->next;
+					}
+					// NARFLEX: David had set this at 1MB; but we had MPEG2PS recordings that failed unless it was 2MB
+					if(packetbufsize > (3*1024*1024)) 
+					{
+						// set the codec type to data so it doesn't show up as some other random type
+						st->codec->codec_type = CODEC_TYPE_DATA;
+						st->codec->codec_id = CODEC_ID_NONE;
+						pd->buf_size=0;
+						av_freep(&pd->buf);
+					}
+				}
             }
         }
     }
@@ -856,7 +911,7 @@
     /* This may be redundant, but it should not hurt. */
     if(pkt->dts != AV_NOPTS_VALUE && pkt->pts != AV_NOPTS_VALUE && pkt->pts > pkt->dts)
         presentation_delayed = 1;
-
+//if (st->codec->codec_type == CODEC_TYPE_VIDEO)
 //    av_log(NULL, AV_LOG_DEBUG, "IN delayed:%d pts:%"PRId64", dts:%"PRId64" cur_dts:%"PRId64" st:%d pc:%p\n", presentation_delayed, pkt->pts, pkt->dts, st->cur_dts, pkt->stream_index, pc);
     /* interpolate PTS and DTS if they are not present */
     //We skip H264 currently because delay and has_b_frames are not reliably set
@@ -915,7 +970,8 @@
             st->cur_dts = pkt->dts;
     }
 
-//    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);
+//if (st->codec->codec_type == CODEC_TYPE_VIDEO)
+//    av_log(NULL, AV_LOG_ERROR, "OUT delayed:%d/%d pts:%"PRId64", dts:%"PRId64" cur_dts:%"PRId64"\n", presentation_delayed, delay, pkt->pts, pkt->dts, st->cur_dts);
 
     /* update flags */
     if(is_intra_only(st->codec))
@@ -928,8 +984,11 @@
         else if (pc->key_frame == -1 && pc->pict_type == FF_I_TYPE)
             pkt->flags |= PKT_FLAG_KEY;
     }
-    if (pc)
+    if (pc) {
         pkt->convergence_duration = pc->convergence_duration;
+		if (pc->field_frame_flag)
+			pkt->flags |= PKT_FLAG_FIELD;
+	}
 }
 
 void av_destruct_packet_nofree(AVPacket *pkt)
@@ -954,11 +1013,17 @@
                 *pkt = st->cur_pkt; st->cur_pkt.data= NULL;
                 compute_pkt_fields(s, st, NULL, pkt);
                 s->cur_st = NULL;
+                if ((s->iformat->flags & AVFMT_GENERIC_INDEX) &&
+                    (pkt->flags & PKT_FLAG_KEY) && pkt->dts != AV_NOPTS_VALUE) {
+                    ff_reduce_index(s, st->index);
+                    av_add_index_entry(st, pkt->pos, pkt->dts, 0, 0, AVINDEX_KEYFRAME);
+                }
                 break;
             } else if (st->cur_len > 0 && st->discard < AVDISCARD_ALL) {
-                len = av_parser_parse(st->parser, st->codec, &pkt->data, &pkt->size,
-                                      st->cur_ptr, st->cur_len,
-                                      st->cur_pkt.pts, st->cur_pkt.dts);
+                len = av_parser_parse2(st->parser, st->codec, &pkt->data, &pkt->size,
+                                       st->cur_ptr, st->cur_len,
+                                       st->cur_pkt.pts, st->cur_pkt.dts,
+                                       st->cur_pkt.pos);
                 st->cur_pkt.pts = AV_NOPTS_VALUE;
                 st->cur_pkt.dts = AV_NOPTS_VALUE;
                 /* increment read pointer */
@@ -967,12 +1032,12 @@
 
                 /* return packet if any */
                 if (pkt->size) {
-                    pkt->pos = st->cur_pkt.pos;              // Isn't quite accurate but close.
                 got_packet:
                     pkt->duration = 0;
                     pkt->stream_index = st->index;
                     pkt->pts = st->parser->pts;
                     pkt->dts = st->parser->dts;
+                    pkt->pos = st->parser->pos;
                     pkt->destruct = av_destruct_packet_nofree;
                     compute_pkt_fields(s, st, st->parser, pkt);
 
@@ -1000,10 +1065,11 @@
                 for(i = 0; i < s->nb_streams; i++) {
                     st = s->streams[i];
                     if (st->parser && st->need_parsing) {
-                        av_parser_parse(st->parser, st->codec,
+                        av_parser_parse2(st->parser, st->codec,
                                         &pkt->data, &pkt->size,
                                         NULL, 0,
-                                        AV_NOPTS_VALUE, AV_NOPTS_VALUE);
+                                        AV_NOPTS_VALUE, AV_NOPTS_VALUE,
+                                        AV_NOPTS_VALUE);
                         if (pkt->size)
                             goto got_packet;
                     }
@@ -1285,11 +1351,11 @@
     return  m;
 }
 
-#define DEBUG_SEEK
+//#define DEBUG_SEEK
 
 int av_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts, int flags){
     AVInputFormat *avif= s->iformat;
-    int64_t pos_min, pos_max, pos, pos_limit;
+    int64_t av_uninit(pos_min), av_uninit(pos_max), pos, pos_limit;
     int64_t ts_min, ts_max, ts;
     int index;
     AVStream *st;
@@ -1317,8 +1383,8 @@
             pos_min= e->pos;
             ts_min= e->timestamp;
 #ifdef DEBUG_SEEK
-        av_log(s, AV_LOG_DEBUG, "using cached pos_min=0x%"PRIx64" dts_min=%"PRId64"\n",
-               pos_min,ts_min);
+            av_log(s, AV_LOG_DEBUG, "using cached pos_min=0x%"PRIx64" dts_min=%"PRId64"\n",
+                   pos_min,ts_min);
 #endif
         }else{
             assert(index==0);
@@ -1333,8 +1399,8 @@
             ts_max= e->timestamp;
             pos_limit= pos_max - e->min_distance;
 #ifdef DEBUG_SEEK
-        av_log(s, AV_LOG_DEBUG, "using cached pos_max=0x%"PRIx64" pos_limit=0x%"PRIx64" dts_max=%"PRId64"\n",
-               pos_max,pos_limit, ts_max);
+            av_log(s, AV_LOG_DEBUG, "using cached pos_max=0x%"PRIx64" pos_limit=0x%"PRIx64" dts_max=%"PRId64"\n",
+                   pos_max,pos_limit, ts_max);
 #endif
         }
     }
@@ -1432,7 +1498,9 @@
         else
             no_change=0;
 #ifdef DEBUG_SEEK
-av_log(s, AV_LOG_DEBUG, "%"PRId64" %"PRId64" %"PRId64" / %"PRId64" %"PRId64" %"PRId64" target:%"PRId64" limit:%"PRId64" start:%"PRId64" noc:%d\n", pos_min, pos, pos_max, ts_min, ts, ts_max, target_ts, pos_limit, start_pos, no_change);
+        av_log(s, AV_LOG_DEBUG, "%"PRId64" %"PRId64" %"PRId64" / %"PRId64" %"PRId64" %"PRId64" target:%"PRId64" limit:%"PRId64" start:%"PRId64" noc:%d\n",
+               pos_min, pos, pos_max, ts_min, ts, ts_max, target_ts, pos_limit,
+               start_pos, no_change);
 #endif
         if(ts == AV_NOPTS_VALUE){
             av_log(s, AV_LOG_ERROR, "read_timestamp() failed in the middle\n");
@@ -1511,11 +1579,14 @@
                 return ret;
             av_update_cur_dts(s, st, ie->timestamp);
         }else{
-            if ((ret = url_fseek(s->pb, 0, SEEK_SET)) < 0)
+            if ((ret = url_fseek(s->pb, s->data_offset, SEEK_SET)) < 0)
                 return ret;
         }
         for(i=0;; i++) {
-            int ret = av_read_frame(s, &pkt);
+            int ret;
+            do{
+                ret = av_read_frame(s, &pkt);
+            }while(ret == AVERROR(EAGAIN));
             if(ret<0)
                 break;
             av_free_packet(&pkt);
@@ -1577,6 +1648,28 @@
         return av_seek_frame_generic(s, stream_index, timestamp, flags);
 }
 
+int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags)
+{
+    if(min_ts > ts || max_ts < ts)
+        return -1;
+
+    av_read_frame_flush(s);
+
+    if (s->iformat->read_seek2)
+        return s->iformat->read_seek2(s, stream_index, min_ts, ts, max_ts, flags);
+
+    if(s->iformat->read_timestamp){
+        //try to seek via read_timestamp()
+    }
+
+    //Fallback to old API if new is not implemented but old is
+    //Note the old has somewat different sematics
+    if(s->iformat->read_seek || 1)
+        return av_seek_frame(s, stream_index, ts, flags | (ts - min_ts > (uint64_t)(max_ts - ts) ? AVSEEK_FLAG_BACKWARD : 0));
+
+    // try some generic seek like av_seek_frame_generic() but with new ts semantics
+}
+
 /*******************************************************/
 
 /**
@@ -1738,7 +1831,9 @@
         if (i == ic->nb_streams)
             break;
 
-        ret = av_read_packet(ic, pkt);
+        do{
+            ret = av_read_packet(ic, pkt);
+        }while(ret == AVERROR(EAGAIN));
         if (ret != 0)
             break;
         read_size += pkt->size;
@@ -1763,7 +1858,9 @@
         if (read_size >= DURATION_MAX_READ_SIZE)
             break;
 
-        ret = av_read_packet(ic, pkt);
+        do{
+            ret = av_read_packet(ic, pkt);
+        }while(ret == AVERROR(EAGAIN));
         if (ret != 0)
             break;
         read_size += pkt->size;
@@ -1795,8 +1892,12 @@
 {
     int64_t file_size;
 
+	/* If we're in active file mode, then this loop will go on forever so realize that
+	   and stop us if we've found 2 streams*/
+	int activeFile = ((((URLContext *) ic->pb->opaque)->flags & URL_ACTIVEFILE) == URL_ACTIVEFILE);
+	
     /* get the file size, if possible */
-    if (ic->iformat->flags & AVFMT_NOFILE) {
+    if (ic->iformat->flags & AVFMT_NOFILE || activeFile) {
         file_size = 0;
     } else {
         file_size = url_fsize(ic->pb);
@@ -1846,7 +1947,8 @@
         val = enc->sample_rate && enc->channels && enc->sample_fmt != SAMPLE_FMT_NONE;
         if(!enc->frame_size &&
            (enc->codec_id == CODEC_ID_VORBIS ||
-            enc->codec_id == CODEC_ID_AAC))
+            enc->codec_id == CODEC_ID_AAC ||
+            enc->codec_id == CODEC_ID_DTS))
             return 0;
         break;
     case CODEC_TYPE_VIDEO:
@@ -1878,6 +1980,9 @@
   if(!has_codec_parameters(st->codec)){
     switch(st->codec->codec_type) {
     case CODEC_TYPE_VIDEO:
+#ifdef EM8622
+        st->codec->skip_frame=AVDISCARD_ALL;
+#endif
         ret = avcodec_decode_video(st->codec, &picture,
                                    &got_picture, data, size);
         break;
@@ -1996,7 +2101,7 @@
 
 int av_find_stream_info(AVFormatContext *ic)
 {
-    int i, count, ret, read_size, j;
+    int i, count, ret, read_size, j, has_video;
     AVStream *st;
     AVPacket pkt1, *pkt;
     int64_t last_dts[MAX_STREAMS];
@@ -2033,6 +2138,7 @@
 
     count = 0;
     read_size = 0;
+	has_video = 0;
     for(;;) {
         if(url_interrupt_cb()){
             ret= AVERROR(EINTR);
@@ -2044,6 +2150,8 @@
             st = ic->streams[i];
             if (!has_codec_parameters(st->codec))
                 break;
+			if (st->codec->codec_type == CODEC_TYPE_VIDEO)
+				has_video = 1;
             /* variable fps and no guess at the real fps */
             if(   tb_unreliable(st->codec)
                && duration_count[i]<20 && st->codec->codec_type == CODEC_TYPE_VIDEO)
@@ -2062,16 +2170,26 @@
                 ret = count;
                 break;
             }
-        }
-        /* we did not get all the codec info, but we read too much data */
-        if (read_size >= MAX_READ_SIZE) {
-            ret = count;
-            break;
-        }
+			/* If we're in active file mode, then this loop will go on forever so realize that
+			   and stop us if we've found 2 streams (w/ at least one video) */
+			if ((((URLContext *) ic->pb->opaque)->flags & URL_ACTIVEFILE) == URL_ACTIVEFILE && ic->nb_streams >= 2 && has_video)
+			{
+				ret = count;
+				break;
+	        }
+        }// else {
+			/* we did not get all the codec info, but we read too much data */
+			if (read_size >= MAX_READ_SIZE) {
+				ret = count;
+				break;
+			}
+//        }
 
         /* NOTE: a new stream can be added there if no header in file
            (AVFMTCTX_NOHEADER) */
         ret = av_read_frame_internal(ic, &pkt1);
+        if(ret == AVERROR(EAGAIN))
+            continue;
         if (ret < 0) {
             /* EOF or error */
             ret = -1; /* we could not have all the codec parameters before EOF */
@@ -2097,16 +2215,23 @@
         read_size += pkt->size;
 
         st = ic->streams[pkt->stream_index];
-        if(codec_info_nb_frames[st->index]>1)
+        if(codec_info_nb_frames[st->index]>1) {
+            if (st->time_base.den > 0 && av_rescale_q(codec_info_duration[st->index], st->time_base, AV_TIME_BASE_Q) >= ic->max_analyze_duration)
+                break;
             codec_info_duration[st->index] += pkt->duration;
+        }
         if (pkt->duration != 0)
             codec_info_nb_frames[st->index]++;
 
+#ifndef EM8622
         {
             int index= pkt->stream_index;
             int64_t last= last_dts[index];
             int64_t duration= pkt->dts - last;
 
+			if (pkt->flags & PKT_FLAG_FIELD)
+				duration *= 2; // two fields are needed per frame
+
             if(pkt->dts != AV_NOPTS_VALUE && last != AV_NOPTS_VALUE && duration>0){
                 double dur= duration * av_q2d(st->time_base);
 
@@ -2128,6 +2253,7 @@
             if(last == AV_NOPTS_VALUE || duration_count[index]<=1)
                 last_dts[pkt->stream_index]= pkt->dts;
         }
+#endif
         if(st->parser && st->parser->parser->split && !st->codec->extradata){
             int i= st->parser->parser->split(st->codec, pkt->data, pkt->size);
             if(i){
@@ -2159,9 +2285,6 @@
              (st->codec->codec_id == CODEC_ID_MPEG4 && !st->need_parsing))*/)
             try_decode_frame(st, pkt->data, pkt->size);
 
-        if (st->time_base.den > 0 && av_rescale_q(codec_info_duration[st->index], st->time_base, AV_TIME_BASE_Q) >= ic->max_analyze_duration) {
-            break;
-        }
         count++;
     }
 
@@ -2793,12 +2916,14 @@
     }
 }
 
+#if 0
 static void print_fps(double d, const char *postfix){
     uint64_t v= lrintf(d*100);
     if     (v% 100      ) av_log(NULL, AV_LOG_INFO, ", %3.2f %s", d, postfix);
     else if(v%(100*1000)) av_log(NULL, AV_LOG_INFO, ", %1.0f %s", d, postfix);
     else                  av_log(NULL, AV_LOG_INFO, ", %1.0fk %s", d/1000, postfix);
 }
+#endif
 
 /* "user interface" functions */
 static void dump_stream_format(AVFormatContext *ic, int i, int index, int is_output)
@@ -2830,12 +2955,26 @@
                  display_aspect_ratio.num, display_aspect_ratio.den);
     }
     if(st->codec->codec_type == CODEC_TYPE_VIDEO){
+#if 1
+		double rate = 0.0;
+		
+		if(st->r_frame_rate.den && st->r_frame_rate.num)
+			rate = av_q2d(st->r_frame_rate);
+		else
+			rate = 1/av_q2d(st->codec->time_base);
+		
+//		if (st->codec->interlaced && st->codec->codec_id == CODEC_ID_H264)
+//			rate /= 2; // interlaced H.264 shows as double frame rate (field rate)
+		
+		av_log(NULL, AV_LOG_INFO, ", %5.2f fps", rate);
+#else
         if(st->r_frame_rate.den && st->r_frame_rate.num)
             print_fps(av_q2d(st->r_frame_rate), "tbr");
         if(st->time_base.den && st->time_base.num)
             print_fps(1/av_q2d(st->time_base), "tbn");
         if(st->codec->time_base.den && st->codec->time_base.num)
             print_fps(1/av_q2d(st->codec->time_base), "tbc");
+#endif
     }
     av_log(NULL, AV_LOG_INFO, "\n");
 }
@@ -2916,9 +3055,17 @@
 
 int64_t av_gettime(void)
 {
+#if defined(CONFIG_WINCE)
+    return timeGetTime() * INT64_C(1000);
+#elif defined(__MINGW32__)
+    struct timeb tb;
+    _ftime(&tb);
+    return ((int64_t)tb.time * INT64_C(1000) + (int64_t)tb.millitm) * INT64_C(1000);
+#else
     struct timeval tv;
     gettimeofday(&tv,NULL);
     return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec;
+#endif
 }
 
 int64_t parse_date(const char *datestr, int duration)
diff --git a/libavformat/vc1testenc.c b/libavformat/vc1testenc.c
old mode 100644
new mode 100755
diff --git a/libavformat/voc.h b/libavformat/voc.h
old mode 100644
new mode 100755
diff --git a/libavformat/vocdec.c b/libavformat/vocdec.c
old mode 100644
new mode 100755
diff --git a/libavformat/vocenc.c b/libavformat/vocenc.c
old mode 100644
new mode 100755
diff --git a/libavformat/vqf.c b/libavformat/vqf.c
new file mode 100644
index 0000000..d2b48dd
--- /dev/null
+++ b/libavformat/vqf.c
@@ -0,0 +1,256 @@
+/*
+ * VQF demuxer
+ * Copyright (c) 2009 Vitor Sessak
+ *
+ * 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 "libavutil/intreadwrite.h"
+
+typedef struct VqfContext {
+    int frame_bit_len;
+    uint8_t last_frame_bits;
+    int remaining_bits;
+} VqfContext;
+
+static int vqf_probe(AVProbeData *probe_packet)
+{
+    if (AV_RL32(probe_packet->buf) != MKTAG('T','W','I','N'))
+        return 0;
+
+    if (!memcmp(probe_packet->buf + 4, "97012000", 8))
+        return AVPROBE_SCORE_MAX;
+
+    if (!memcmp(probe_packet->buf + 4, "00052200", 8))
+        return AVPROBE_SCORE_MAX;
+
+    return AVPROBE_SCORE_MAX/2;
+}
+
+static void add_metadata(AVFormatContext *s, const char *tag,
+                         unsigned int tag_len, unsigned int remaining)
+{
+    char buf[2048];
+    int len = FFMIN3(tag_len, remaining, sizeof(buf) - 1);
+
+    if (len != tag_len)
+        av_log(s, AV_LOG_ERROR, "Warning: truncating metadata!\n");
+
+    get_buffer(s->pb, buf, len);
+    buf[len] = 0;
+    av_metadata_set(&s->metadata, tag, buf);
+}
+
+static int vqf_read_header(AVFormatContext *s, AVFormatParameters *ap)
+{
+    VqfContext *c = s->priv_data;
+    AVStream *st  = av_new_stream(s, 0);
+    int chunk_tag;
+    int rate_flag = -1;
+    int header_size;
+    int read_bitrate = 0;
+    int size;
+
+    if (!st)
+        return AVERROR(ENOMEM);
+
+    url_fskip(s->pb, 12);
+
+    header_size = get_be32(s->pb);
+
+    st->codec->codec_type = CODEC_TYPE_AUDIO;
+    st->codec->codec_id   = CODEC_ID_TWINVQ;
+    st->start_time = 0;
+
+    do {
+        int len;
+        chunk_tag = get_le32(s->pb);
+
+        if (chunk_tag == MKTAG('D','A','T','A'))
+            break;
+
+        len = get_be32(s->pb);
+
+        if ((unsigned) len > INT_MAX/2) {
+            av_log(s, AV_LOG_ERROR, "Malformed header\n");
+            return -1;
+        }
+
+        header_size -= 8;
+
+        switch(chunk_tag){
+        case MKTAG('C','O','M','M'):
+            st->codec->channels = get_be32(s->pb) + 1;
+            read_bitrate        = get_be32(s->pb);
+            rate_flag           = get_be32(s->pb);
+            url_fskip(s->pb, len-12);
+
+            st->codec->bit_rate              = read_bitrate*1000;
+            st->codec->bits_per_coded_sample = 16;
+            break;
+        case MKTAG('N','A','M','E'):
+            add_metadata(s, "title"    , len, header_size);
+            break;
+        case MKTAG('(','c',')',' '):
+            add_metadata(s, "copyright", len, header_size);
+            break;
+        case MKTAG('A','U','T','H'):
+            add_metadata(s, "author"   , len, header_size);
+            break;
+        case MKTAG('A','L','B','M'):
+            add_metadata(s, "album"    , len, header_size);
+            break;
+        case MKTAG('T','R','C','K'):
+            add_metadata(s, "track"    , len, header_size);
+            break;
+        case MKTAG('C','O','M','T'):
+            add_metadata(s, "comment"  , len, header_size);
+            break;
+        case MKTAG('F','I','L','E'):
+            add_metadata(s, "filename" , len, header_size);
+            break;
+        case MKTAG('D','S','I','Z'):
+            add_metadata(s, "size"     , len, header_size);
+            break;
+        case MKTAG('D','A','T','E'):
+            add_metadata(s, "date"     , len, header_size);
+            break;
+        case MKTAG('G','E','N','R'):
+            add_metadata(s, "genre"    , len, header_size);
+            break;
+        default:
+            av_log(s, AV_LOG_ERROR, "Unknown chunk: %c%c%c%c\n",
+                   ((char*)&chunk_tag)[0], ((char*)&chunk_tag)[1],
+                   ((char*)&chunk_tag)[2], ((char*)&chunk_tag)[3]);
+            url_fskip(s->pb, FFMIN(len, header_size));
+            break;
+        }
+
+        header_size -= len;
+
+    } while (header_size >= 0);
+
+    switch (rate_flag) {
+    case -1:
+        av_log(s, AV_LOG_ERROR, "COMM tag not found!\n");
+        return -1;
+    case 44:
+        st->codec->sample_rate = 44100;
+        break;
+    case 22:
+        st->codec->sample_rate = 22050;
+        break;
+    case 11:
+        st->codec->sample_rate = 11025;
+        break;
+    default:
+        st->codec->sample_rate = rate_flag*1000;
+        break;
+    }
+
+    switch (((st->codec->sample_rate/1000) << 8) +
+            read_bitrate/st->codec->channels) {
+    case (11<<8) + 8 :
+    case (8 <<8) + 8 :
+    case (11<<8) + 10:
+    case (22<<8) + 32:
+        size = 512;
+        break;
+    case (16<<8) + 16:
+    case (22<<8) + 20:
+    case (22<<8) + 24:
+        size = 1024;
+        break;
+    case (44<<8) + 40:
+    case (44<<8) + 48:
+        size = 2048;
+        break;
+    default:
+        av_log(s, AV_LOG_ERROR, "Mode not suported: %d Hz, %d kb/s.\n",
+               st->codec->sample_rate, st->codec->bit_rate);
+        return -1;
+    }
+    c->frame_bit_len = st->codec->bit_rate*size/st->codec->sample_rate;
+
+    return 0;
+}
+
+static int vqf_read_packet(AVFormatContext *s, AVPacket *pkt)
+{
+    VqfContext *c = s->priv_data;
+    int ret;
+    int size = (c->frame_bit_len - c->remaining_bits + 7)>>3;
+
+    pkt->pos          = url_ftell(s->pb);
+    pkt->stream_index = 0;
+
+    if (av_new_packet(pkt, size+2) < 0)
+        return AVERROR(EIO);
+
+    pkt->data[0] = 8 - c->remaining_bits; // Number of bits to skip
+    pkt->data[1] = c->last_frame_bits;
+    ret = get_buffer(s->pb, pkt->data+2, size);
+
+    if (ret<=0) {
+        av_free_packet(pkt);
+        return AVERROR(EIO);
+    }
+
+    c->last_frame_bits = pkt->data[size+1];
+    c->remaining_bits  = (size << 3) - c->frame_bit_len + c->remaining_bits;
+
+    return size+2;
+}
+
+static int vqf_read_seek(AVFormatContext *s,
+                         int stream_index, int64_t timestamp, int flags)
+{
+    VqfContext *c = s->priv_data;
+    AVStream *st;
+    int ret;
+    int64_t pos;
+
+    st = s->streams[stream_index];
+    pos = av_rescale_rnd(timestamp * st->codec->bit_rate,
+                         st->time_base.num,
+                         st->time_base.den * (int64_t)c->frame_bit_len,
+                         (flags & AVSEEK_FLAG_BACKWARD) ?
+                                                   AV_ROUND_DOWN : AV_ROUND_UP);
+    pos *= c->frame_bit_len;
+
+    st->cur_dts = av_rescale(pos, st->time_base.den,
+                             st->codec->bit_rate * (int64_t)st->time_base.num);
+
+    if ((ret = url_fseek(s->pb, ((pos-7) >> 3) + s->data_offset, SEEK_SET)) < 0)
+        return ret;
+
+    c->remaining_bits = -7 - ((pos-7)&7);
+    return 0;
+}
+
+AVInputFormat vqf_demuxer = {
+    "vqf",
+    NULL_IF_CONFIG_SMALL("Nippon Telegraph and Telephone Corporation (NTT) TwinVQ"),
+    sizeof(VqfContext),
+    vqf_probe,
+    vqf_read_header,
+    vqf_read_packet,
+    NULL,
+    vqf_read_seek,
+    .extensions = "vqf",
+};
diff --git a/libavformat/wav.c b/libavformat/wav.c
old mode 100644
new mode 100755
index f9a3444..58a3217
--- a/libavformat/wav.c
+++ b/libavformat/wav.c
@@ -157,6 +157,68 @@
         return 0;
 }
 
+/* Most WAV files with DTS audio are broken and use 0x01 (PCM) as format
+   ID instead of 0x2001 (DTS). If the format found is 0x01, check the first
+   bytes after 'data' for a valid DTS header. */
+static void find_dts_header (ByteIOContext *pb, AVCodecContext *codec)
+{
+	int sizeLeft = (int)(pb->buf_end - pb->buf_ptr);
+	// Make sure there's 2 matches
+	int matchesLeft = 2;
+	int matchNow = 0;
+	int dtsBitSize = 0;
+	for (int i = 0; i < sizeLeft; i++)
+	{
+
+	  /* 14 bits and little endian bitstream */
+	  if (pb->buf_ptr[i] == 0xff && pb->buf_ptr[i+1] == 0x1f &&
+		  pb->buf_ptr[i+2] == 0x00 && pb->buf_ptr[i+3] == 0xe8 &&
+		  (pb->buf_ptr[i+4] & 0xf0) == 0xf0 && pb->buf_ptr[i+5] == 0x07)
+	  {
+		  matchNow = 1;
+		  dtsBitSize = 14;
+	  }
+
+	  /* 14 bits and big endian bitstream */
+	  if (pb->buf_ptr[i] == 0x1f && pb->buf_ptr[i+1] == 0xff &&
+		  pb->buf_ptr[i+2] == 0xe8 && pb->buf_ptr[i+3] == 0x00 &&
+		  pb->buf_ptr[i+4] == 0x07 && (pb->buf_ptr[i+5] & 0xf0) == 0xf0)
+	  {
+		  matchNow = 1;
+		  dtsBitSize = 14;
+	  }
+    
+	  /* 16 bits and little endian bitstream */
+	  if (pb->buf_ptr[i] == 0xfe && pb->buf_ptr[i+1] == 0x7f &&
+		  pb->buf_ptr[i+2] == 0x01 && pb->buf_ptr[i+3] == 0x80)
+	  {
+		  matchNow = 1;
+		  dtsBitSize = 16;
+	  }
+    
+	  /* 16 bits and big endian bitstream */
+	  if (pb->buf_ptr[i] == 0x7f && pb->buf_ptr[i+1] == 0xfe &&
+		  pb->buf_ptr[i+2] == 0x80 && pb->buf_ptr[i+3] == 0x01)
+	  {
+		  matchNow = 1;
+		  dtsBitSize = 16;
+	  }
+
+	  if (matchNow)
+	  {
+		matchNow = 0;
+		matchesLeft--;
+		if (matchesLeft == 0)
+		{
+			codec->codec_id = CODEC_ID_DTS;
+			codec->sub_id = (dtsBitSize == 14) ? 1 : 2;
+			break;
+		}
+	  }
+	}
+}
+
+
 /* wav input */
 static int wav_read_header(AVFormatContext *s,
                            AVFormatParameters *ap)
@@ -193,7 +255,14 @@
     size = find_tag(pb, MKTAG('d', 'a', 't', 'a'));
     if (size < 0)
         return -1;
+
     wav->data_end= url_ftell(pb) + size;
+
+    /* check if it's really PCM or hidden DTS */
+    if (codec_get_id (codec_wav_tags,
+                      st->codec->codec_tag) == CODEC_ID_PCM_S16LE)
+      find_dts_header (pb, st->codec);
+      
     return 0;
 }
 
diff --git a/libavformat/wc3movie.c b/libavformat/wc3movie.c
old mode 100644
new mode 100755
index 6d7592f..59b11ae
--- a/libavformat/wc3movie.c
+++ b/libavformat/wc3movie.c
@@ -293,7 +293,7 @@
         /* get the next chunk preamble */
         if ((ret = get_buffer(pb, preamble, WC3_PREAMBLE_SIZE)) !=
             WC3_PREAMBLE_SIZE)
-            ret = AVERROR(EIO);
+            return AVERROR(EIO);
 
         fourcc_tag = AV_RL32(&preamble[0]);
         /* chunk sizes are 16-bit aligned */
diff --git a/libavformat/westwood.c b/libavformat/westwood.c
old mode 100644
new mode 100755
index 7ca1797..d2736ac
--- a/libavformat/westwood.c
+++ b/libavformat/westwood.c
@@ -279,8 +279,10 @@
     /* there are 0 or more chunks before the FINF chunk; iterate until
      * FINF has been skipped and the file will be ready to be demuxed */
     do {
-        if (get_buffer(pb, scratch, VQA_PREAMBLE_SIZE) != VQA_PREAMBLE_SIZE)
+        if (get_buffer(pb, scratch, VQA_PREAMBLE_SIZE) != VQA_PREAMBLE_SIZE) {
+            av_free(st->codec->extradata);
             return AVERROR(EIO);
+        }
         chunk_tag = AV_RB32(&scratch[0]);
         chunk_size = AV_RB32(&scratch[4]);
 
diff --git a/libavformat/yuv4mpeg.c b/libavformat/yuv4mpeg.c
old mode 100644
new mode 100755
diff --git a/libavutil/Makefile b/libavutil/Makefile
old mode 100644
new mode 100755
index 3357de0..8428446
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -16,7 +16,6 @@
           md5.h                                                         \
           mem.h                                                         \
           pixfmt.h                                                      \
-          random.h                                                      \
           rational.h                                                    \
           sha1.h
 
@@ -35,19 +34,17 @@
        mathematics.o                                                    \
        md5.o                                                            \
        mem.o                                                            \
-       random.o                                                         \
+       random_seed.o                                                    \
        rational.o                                                       \
        rc4.o                                                            \
        sha1.o                                                           \
        tree.o                                                           \
        utils.o                                                          \
 
-TESTS = $(addsuffix -test$(EXESUF), adler32 aes base64 crc des lls md5 pca random sha1 softfloat tree)
+TESTPROGS = adler32 aes base64 crc des lls md5 pca sha1 softfloat tree
 
 DIRS = arm bfin sh4 x86
 
 include $(SUBDIR)../subdir.mak
 
 $(SUBDIR)lzo-test$(EXESUF): EXTRALIBS += -llzo2
-
-CLEANFILES = lzo-test$(EXESUF)
diff --git a/libavutil/aes.c b/libavutil/aes.c
index cc3537a..49c23e1 100644
--- a/libavutil/aes.c
+++ b/libavutil/aes.c
@@ -192,10 +192,9 @@
 }
 
 #ifdef TEST
+#include "lfg.h"
 #include "log.h"
 
-#undef random
-
 int main(void){
     int i,j;
     AVAES ae, ad, b;
@@ -209,10 +208,12 @@
         {0x73, 0x22, 0x81, 0xc0, 0xa0, 0xaa, 0xb8, 0xf7, 0xa5, 0x4a, 0x0c, 0x67, 0xa0, 0xc4, 0x5e, 0xcf},
         {0x6d, 0x25, 0x1e, 0x69, 0x44, 0xb0, 0x51, 0xe0, 0x4e, 0xaa, 0x6f, 0xb4, 0xdb, 0xf7, 0x84, 0x65}};
     uint8_t temp[16];
+    AVLFG prn;
 
     av_aes_init(&ae, "PI=3.141592654..", 128, 0);
     av_aes_init(&ad, "PI=3.141592654..", 128, 1);
-    av_log_level= AV_LOG_DEBUG;
+    av_log_set_level(AV_LOG_DEBUG);
+    av_lfg_init(&prn, 1);
 
     for(i=0; i<2; i++){
         av_aes_init(&b, rkey[i], 128, 1);
@@ -224,7 +225,7 @@
 
     for(i=0; i<10000; i++){
         for(j=0; j<16; j++){
-            pt[j]= random();
+            pt[j] = av_lfg_get(&prn);
         }
 {START_TIMER
         av_aes_crypt(&ae, temp, pt, 1, NULL, 0);
diff --git a/libavutil/arm/bswap.h b/libavutil/arm/bswap.h
index 65c73c5..d19f972 100644
--- a/libavutil/arm/bswap.h
+++ b/libavutil/arm/bswap.h
@@ -23,6 +23,25 @@
 #include "config.h"
 #include "libavutil/common.h"
 
+#ifdef __ARMCC_VERSION
+
+#if HAVE_ARMV6
+#define bswap_16 bswap_16
+static av_always_inline av_const uint16_t bswap_16(uint16_t x)
+{
+    __asm { rev16 x, x }
+    return x;
+}
+
+#define bswap_32 bswap_32
+static av_always_inline av_const uint32_t bswap_32(uint32_t x)
+{
+    return __rev(x);
+}
+#endif /* HAVE_ARMV6 */
+
+#else /* __ARMCC_VERSION */
+
 #if HAVE_ARMV6
 #define bswap_16 bswap_16
 static av_always_inline av_const uint16_t bswap_16(uint16_t x)
@@ -48,4 +67,6 @@
     return x;
 }
 
+#endif /* __ARMCC_VERSION */
+
 #endif /* AVUTIL_ARM_BSWAP_H */
diff --git a/libavutil/avutil.h b/libavutil/avutil.h
old mode 100644
new mode 100755
index b908a69..dfc129b
--- a/libavutil/avutil.h
+++ b/libavutil/avutil.h
@@ -34,8 +34,8 @@
 #define AV_VERSION_DOT(a, b, c) a ##.## b ##.## c
 #define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c)
 
-#define LIBAVUTIL_VERSION_MAJOR 49
-#define LIBAVUTIL_VERSION_MINOR 15
+#define LIBAVUTIL_VERSION_MAJOR 50
+#define LIBAVUTIL_VERSION_MINOR  2
 #define LIBAVUTIL_VERSION_MICRO  0
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
diff --git a/libavutil/bswap.h b/libavutil/bswap.h
old mode 100644
new mode 100755
diff --git a/libavutil/colorspace.h b/libavutil/colorspace.h
new file mode 100644
index 0000000..f438159
--- /dev/null
+++ b/libavutil/colorspace.h
@@ -0,0 +1,111 @@
+/*
+ * Colorspace conversion defines
+ * Copyright (c) 2001, 2002, 2003 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
+ * Various defines for YUV<->RGB conversion
+ */
+
+#ifndef AVUTIL_COLORSPACE_H
+#define AVUTIL_COLORSPACE_H
+
+#define SCALEBITS 10
+#define ONE_HALF  (1 << (SCALEBITS - 1))
+#define FIX(x)    ((int) ((x) * (1<<SCALEBITS) + 0.5))
+
+#define YUV_TO_RGB1_CCIR(cb1, cr1)\
+{\
+    cb = (cb1) - 128;\
+    cr = (cr1) - 128;\
+    r_add = FIX(1.40200*255.0/224.0) * cr + ONE_HALF;\
+    g_add = - FIX(0.34414*255.0/224.0) * cb - FIX(0.71414*255.0/224.0) * cr + \
+            ONE_HALF;\
+    b_add = FIX(1.77200*255.0/224.0) * cb + ONE_HALF;\
+}
+
+#define YUV_TO_RGB2_CCIR(r, g, b, y1)\
+{\
+    y = ((y1) - 16) * FIX(255.0/219.0);\
+    r = cm[(y + r_add) >> SCALEBITS];\
+    g = cm[(y + g_add) >> SCALEBITS];\
+    b = cm[(y + b_add) >> SCALEBITS];\
+}
+
+#define YUV_TO_RGB1(cb1, cr1)\
+{\
+    cb = (cb1) - 128;\
+    cr = (cr1) - 128;\
+    r_add = FIX(1.40200) * cr + ONE_HALF;\
+    g_add = - FIX(0.34414) * cb - FIX(0.71414) * cr + ONE_HALF;\
+    b_add = FIX(1.77200) * cb + ONE_HALF;\
+}
+
+#define YUV_TO_RGB2(r, g, b, y1)\
+{\
+    y = (y1) << SCALEBITS;\
+    r = cm[(y + r_add) >> SCALEBITS];\
+    g = cm[(y + g_add) >> SCALEBITS];\
+    b = cm[(y + b_add) >> SCALEBITS];\
+}
+
+#define Y_CCIR_TO_JPEG(y)\
+ cm[((y) * FIX(255.0/219.0) + (ONE_HALF - 16 * FIX(255.0/219.0))) >> SCALEBITS]
+
+#define Y_JPEG_TO_CCIR(y)\
+ (((y) * FIX(219.0/255.0) + (ONE_HALF + (16 << SCALEBITS))) >> SCALEBITS)
+
+#define C_CCIR_TO_JPEG(y)\
+ cm[(((y) - 128) * FIX(127.0/112.0) + (ONE_HALF + (128 << SCALEBITS))) >> SCALEBITS]
+
+/* NOTE: the clamp is really necessary! */
+static inline int C_JPEG_TO_CCIR(int y) {
+    y = (((y - 128) * FIX(112.0/127.0) + (ONE_HALF + (128 << SCALEBITS))) >> SCALEBITS);
+    if (y < 16)
+        y = 16;
+    return y;
+}
+
+
+#define RGB_TO_Y(r, g, b) \
+((FIX(0.29900) * (r) + FIX(0.58700) * (g) + \
+  FIX(0.11400) * (b) + ONE_HALF) >> SCALEBITS)
+
+#define RGB_TO_U(r1, g1, b1, shift)\
+(((- FIX(0.16874) * r1 - FIX(0.33126) * g1 +         \
+     FIX(0.50000) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)
+
+#define RGB_TO_V(r1, g1, b1, shift)\
+(((FIX(0.50000) * r1 - FIX(0.41869) * g1 -           \
+   FIX(0.08131) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)
+
+#define RGB_TO_Y_CCIR(r, g, b) \
+((FIX(0.29900*219.0/255.0) * (r) + FIX(0.58700*219.0/255.0) * (g) + \
+  FIX(0.11400*219.0/255.0) * (b) + (ONE_HALF + (16 << SCALEBITS))) >> SCALEBITS)
+
+#define RGB_TO_U_CCIR(r1, g1, b1, shift)\
+(((- FIX(0.16874*224.0/255.0) * r1 - FIX(0.33126*224.0/255.0) * g1 +         \
+     FIX(0.50000*224.0/255.0) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)
+
+#define RGB_TO_V_CCIR(r1, g1, b1, shift)\
+(((FIX(0.50000*224.0/255.0) * r1 - FIX(0.41869*224.0/255.0) * g1 -           \
+   FIX(0.08131*224.0/255.0) * b1 + (ONE_HALF << shift) - 1) >> (SCALEBITS + shift)) + 128)
+
+#endif /* AVUTIL_COLORSPACE_H */
diff --git a/libavutil/common.h b/libavutil/common.h
old mode 100644
new mode 100755
diff --git a/libavutil/crc.c b/libavutil/crc.c
old mode 100644
new mode 100755
diff --git a/libavutil/crc.h b/libavutil/crc.h
old mode 100644
new mode 100755
diff --git a/libavutil/des.c b/libavutil/des.c
index 79fd531..43f6c4a 100644
--- a/libavutil/des.c
+++ b/libavutil/des.c
@@ -284,14 +284,6 @@
     return in;
 }
 
-#if LIBAVUTIL_VERSION_MAJOR < 50
-uint64_t ff_des_encdec(uint64_t in, uint64_t key, int decrypt) {
-    uint64_t K[16];
-    gen_roundkeys(K, key);
-    return des_encdec(in, K, decrypt);
-}
-#endif
-
 int av_des_init(AVDES *d, const uint8_t *key, int key_bits, int decrypt) {
     if (key_bits != 64 && key_bits != 192)
         return -1;
@@ -390,16 +382,16 @@
     uint64_t key[3];
     uint64_t data;
     uint64_t ct;
+    uint64_t roundkeys[16];
     gettimeofday(&tv, NULL);
     srand(tv.tv_sec * 1000 * 1000 + tv.tv_usec);
-#if LIBAVUTIL_VERSION_MAJOR < 50
     key[0] = AV_RB64(test_key);
     data = AV_RB64(plain);
-    if (ff_des_encdec(data, key[0], 0) != AV_RB64(crypt)) {
+    gen_roundkeys(roundkeys, key[0]);
+    if (des_encdec(data, roundkeys, 0) != AV_RB64(crypt)) {
         printf("Test 1 failed\n");
         return 1;
     }
-#endif
     av_des_init(&d, test_key, 64, 0);
     av_des_crypt(&d, tmp, plain, 1, NULL, 0);
     if (memcmp(tmp, crypt, sizeof(crypt))) {
diff --git a/libavutil/fifo.c b/libavutil/fifo.c
old mode 100644
new mode 100755
index 86236f7..52ace0e
--- a/libavutil/fifo.c
+++ b/libavutil/fifo.c
@@ -22,65 +22,57 @@
 #include "common.h"
 #include "fifo.h"
 
-int av_fifo_init(AVFifoBuffer *f, unsigned int size)
+AVFifoBuffer *av_fifo_alloc(unsigned int size)
 {
-    size= FFMAX(size, size+1);
-    f->wptr = f->rptr =
+    AVFifoBuffer *f= av_mallocz(sizeof(AVFifoBuffer));
+    if(!f)
+        return NULL;
     f->buffer = av_malloc(size);
     f->end = f->buffer + size;
+    av_fifo_reset(f);
     if (!f->buffer)
-        return -1;
-    return 0;
+        av_freep(&f);
+    return f;
 }
 
 void av_fifo_free(AVFifoBuffer *f)
 {
-    av_free(f->buffer);
+    if(f){
+        av_free(f->buffer);
+        av_free(f);
+    }
+}
+
+void av_fifo_reset(AVFifoBuffer *f)
+{
+    f->wptr = f->rptr = f->buffer;
+    f->wndx = f->rndx = 0;
 }
 
 int av_fifo_size(AVFifoBuffer *f)
 {
-    int size = f->wptr - f->rptr;
-    if (size < 0)
-        size += f->end - f->buffer;
-    return size;
+    return (uint32_t)(f->wndx - f->rndx);
 }
 
-int av_fifo_read(AVFifoBuffer *f, uint8_t *buf, int buf_size)
-{
-    return av_fifo_generic_read(f, buf_size, NULL, buf);
-}
-
-#if LIBAVUTIL_VERSION_MAJOR < 50
-void av_fifo_realloc(AVFifoBuffer *f, unsigned int new_size) {
-    av_fifo_realloc2(f, new_size);
-}
-#endif
-
 int av_fifo_realloc2(AVFifoBuffer *f, unsigned int new_size) {
     unsigned int old_size= f->end - f->buffer;
 
-    if(old_size <= new_size){
+    if(old_size < new_size){
         int len= av_fifo_size(f);
-        AVFifoBuffer f2;
+        AVFifoBuffer *f2= av_fifo_alloc(new_size);
 
-        if (av_fifo_init(&f2, new_size) < 0)
+        if (!f2)
             return -1;
-        av_fifo_read(f, f2.buffer, len);
-        f2.wptr += len;
+        av_fifo_generic_read(f, f2->buffer, len, NULL);
+        f2->wptr += len;
+        f2->wndx += len;
         av_free(f->buffer);
-        *f= f2;
+        *f= *f2;
+        av_free(f2);
     }
     return 0;
 }
 
-#if LIBAVUTIL_VERSION_MAJOR < 50
-void av_fifo_write(AVFifoBuffer *f, const uint8_t *buf, int size)
-{
-    av_fifo_generic_write(f, (void *)buf, size, NULL);
-}
-#endif
-
 int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, int (*func)(void*, void*, int))
 {
     int total = size;
@@ -93,17 +85,20 @@
             memcpy(f->wptr, src, len);
             src = (uint8_t*)src + len;
         }
+// Write memory barrier needed for SMP here in theory
         f->wptr += len;
         if (f->wptr >= f->end)
             f->wptr = f->buffer;
+        f->wndx += len;
         size -= len;
     } while (size > 0);
     return total - size;
 }
 
 
-int av_fifo_generic_read(AVFifoBuffer *f, int buf_size, void (*func)(void*, void*, int), void* dest)
+int av_fifo_generic_read(AVFifoBuffer *f, void *dest, int buf_size, void (*func)(void*, void*, int))
 {
+// Read memory barrier needed for SMP here in theory
     do {
         int len = FFMIN(f->end - f->rptr, buf_size);
         if(func) func(dest, f->rptr, len);
@@ -111,6 +106,7 @@
             memcpy(dest, f->rptr, len);
             dest = (uint8_t*)dest + len;
         }
+// memory barrier needed for SMP here in theory
         av_fifo_drain(f, len);
         buf_size -= len;
     } while (buf_size > 0);
@@ -123,4 +119,5 @@
     f->rptr += size;
     if (f->rptr >= f->end)
         f->rptr -= f->end - f->buffer;
+    f->rndx += size;
 }
diff --git a/libavutil/fifo.h b/libavutil/fifo.h
old mode 100644
new mode 100755
index 1a549f2..d353844
--- a/libavutil/fifo.h
+++ b/libavutil/fifo.h
@@ -31,15 +31,15 @@
 typedef struct AVFifoBuffer {
     uint8_t *buffer;
     uint8_t *rptr, *wptr, *end;
+    uint32_t rndx, wndx;
 } AVFifoBuffer;
 
 /**
  * Initializes an AVFifoBuffer.
- * @param *f AVFifoBuffer to initialize
  * @param size of FIFO
- * @return <0 for failure >=0 otherwise
+ * @return AVFifoBuffer or NULL if mem allocation failure
  */
-int av_fifo_init(AVFifoBuffer *f, unsigned int size);
+AVFifoBuffer *av_fifo_alloc(unsigned int size);
 
 /**
  * Frees an AVFifoBuffer.
@@ -48,6 +48,12 @@
 void av_fifo_free(AVFifoBuffer *f);
 
 /**
+ * Resets the AVFifoBuffer to the state right after av_fifo_alloc, in particular it is emptied.
+ * @param *f AVFifoBuffer to reset
+ */
+void av_fifo_reset(AVFifoBuffer *f);
+
+/**
  * Returns the amount of data in bytes in the AVFifoBuffer, that is the
  * amount of data you can read from it.
  * @param *f AVFifoBuffer to read from
@@ -56,31 +62,13 @@
 int av_fifo_size(AVFifoBuffer *f);
 
 /**
- * Reads data from an AVFifoBuffer.
- * @param *f AVFifoBuffer to read from
- * @param *buf data destination
- * @param buf_size number of bytes to read
- */
-int av_fifo_read(AVFifoBuffer *f, uint8_t *buf, int buf_size);
-
-/**
  * Feeds data from an AVFifoBuffer to a user-supplied callback.
  * @param *f AVFifoBuffer to read from
  * @param buf_size number of bytes to read
  * @param *func generic read function
  * @param *dest data destination
  */
-int av_fifo_generic_read(AVFifoBuffer *f, int buf_size, void (*func)(void*, void*, int), void* dest);
-
-#if LIBAVUTIL_VERSION_MAJOR < 50
-/**
- * Writes data into an AVFifoBuffer.
- * @param *f AVFifoBuffer to write to
- * @param *buf data source
- * @param size data size
- */
-attribute_deprecated void av_fifo_write(AVFifoBuffer *f, const uint8_t *buf, int size);
-#endif
+int av_fifo_generic_read(AVFifoBuffer *f, void *dest, int buf_size, void (*func)(void*, void*, int));
 
 /**
  * Feeds data from a user-supplied callback to an AVFifoBuffer.
@@ -96,16 +84,6 @@
  */
 int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, int (*func)(void*, void*, int));
 
-#if LIBAVUTIL_VERSION_MAJOR < 50
-/**
- * Resizes an AVFifoBuffer.
- * @param *f AVFifoBuffer to resize
- * @param size new AVFifoBuffer size in bytes
- * @see av_fifo_realloc2()
- */
-attribute_deprecated void av_fifo_realloc(AVFifoBuffer *f, unsigned int size);
-#endif
-
 /**
  * Resizes an AVFifoBuffer.
  * @param *f AVFifoBuffer to resize
diff --git a/libavutil/integer.c b/libavutil/integer.c
old mode 100644
new mode 100755
diff --git a/libavutil/integer.h b/libavutil/integer.h
old mode 100644
new mode 100755
diff --git a/libavutil/internal.h b/libavutil/internal.h
old mode 100644
new mode 100755
index 792fd29..a41a946
--- a/libavutil/internal.h
+++ b/libavutil/internal.h
@@ -134,7 +134,7 @@
             );\
         ret;\
     })
-#elif HAVE_ARMV6
+#elif HAVE_ARMV6 && HAVE_INLINE_ASM
 static inline av_const int FASTDIV(int a, int b)
 {
     int r, t;
@@ -145,7 +145,7 @@
                      : "=&r"(r), "=&r"(t) : "r"(a), "r"(b), "r"(ff_inverse));
     return r;
 }
-#elif ARCH_ARM
+#elif ARCH_ARM && HAVE_INLINE_ASM
 static inline av_const int FASTDIV(int a, int b)
 {
     int r, t;
@@ -224,11 +224,11 @@
 #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
+#define rand rand_is_forbidden_due_to_state_trashing_use_av_lfg_get
 #undef  srand
-#define srand srand_is_forbidden_due_to_state_trashing_use_av_random_init
+#define srand srand_is_forbidden_due_to_state_trashing_use_av_lfg_init
 #undef  random
-#define random random_is_forbidden_due_to_state_trashing_use_av_random
+#define random random_is_forbidden_due_to_state_trashing_use_av_lfg_get
 #undef  sprintf
 #define sprintf sprintf_is_forbidden_due_to_security_issues_use_snprintf
 #undef  strcat
@@ -256,11 +256,11 @@
 }
 
 #if defined(__ICC) || defined(__SUNPRO_C)
-    #define DECLARE_ALIGNED(n,t,v)      t __attribute__ ((aligned (n))) v
+    #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 __attribute__ ((aligned (n))) v
-    #define DECLARE_ASM_CONST(n,t,v)    static const t attribute_used __attribute__ ((aligned (n))) v
+    #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
diff --git a/libavutil/intfloat_readwrite.c b/libavutil/intfloat_readwrite.c
old mode 100644
new mode 100755
index bfe36a6..e26aaa8
--- a/libavutil/intfloat_readwrite.c
+++ b/libavutil/intfloat_readwrite.c
@@ -25,6 +25,7 @@
  * portable IEEE float/double read/write functions
  */
 
+#include <math.h>
 #include "common.h"
 #include "intfloat_readwrite.h"
 
diff --git a/libavutil/intfloat_readwrite.h b/libavutil/intfloat_readwrite.h
old mode 100644
new mode 100755
diff --git a/libavutil/lfg.c b/libavutil/lfg.c
old mode 100644
new mode 100755
index 337ee9e..e876d18
--- a/libavutil/lfg.c
+++ b/libavutil/lfg.c
@@ -56,7 +56,7 @@
 //            av_log(NULL,AV_LOG_ERROR, "%X\n", av_lfg_get(&state));
             x+=av_lfg_get(&state);
         }
-        STOP_TIMER("624 calls of av_random");
+        STOP_TIMER("624 calls of av_lfg_get");
     }
     av_log(NULL, AV_LOG_ERROR, "final value:%X\n", x);
     return 0;
diff --git a/libavutil/libavutil.v b/libavutil/libavutil.v
deleted file mode 100644
index ec52f2b..0000000
--- a/libavutil/libavutil.v
+++ /dev/null
@@ -1,4 +0,0 @@
-LIBAVUTIL_$MAJOR {
-        global: av_*; ff_*; avutil_*;
-        local: *;
-};
diff --git a/libavutil/lls.c b/libavutil/lls.c
old mode 100644
new mode 100755
diff --git a/libavutil/log.c b/libavutil/log.c
old mode 100644
new mode 100755
diff --git a/libavutil/lzo.c b/libavutil/lzo.c
old mode 100644
new mode 100755
diff --git a/libavutil/lzo.h b/libavutil/lzo.h
old mode 100644
new mode 100755
diff --git a/libavutil/mathematics.c b/libavutil/mathematics.c
old mode 100644
new mode 100755
index ff488a7..f57cf8e
--- a/libavutil/mathematics.c
+++ b/libavutil/mathematics.c
@@ -55,12 +55,6 @@
     else  return a;
 }
 
-#if LIBAVUTIL_VERSION_MAJOR < 50
-int64_t ff_gcd(int64_t a, int64_t b){
-    return av_gcd(a, b);
-}
-#endif
-
 int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd){
     int64_t r=0;
     assert(c > 0);
diff --git a/libavutil/mathematics.h b/libavutil/mathematics.h
old mode 100644
new mode 100755
diff --git a/libavutil/mem.c b/libavutil/mem.c
old mode 100644
new mode 100755
index 1ce0b77..b74b3a6
--- a/libavutil/mem.c
+++ b/libavutil/mem.c
@@ -25,6 +25,7 @@
  */
 
 #include "config.h"
+#include "log.h"
 
 #include <limits.h>
 #include <stdlib.h>
@@ -55,6 +56,11 @@
     if(size > (INT_MAX-16) )
         return NULL;
 
+#ifdef EM8622
+    if(size > 8*1024*1024)
+        return NULL;
+#endif
+
 #if CONFIG_MEMALIGN_HACK
     ptr = malloc(size+16);
     if(!ptr)
@@ -99,8 +105,30 @@
     return ptr;
 }
 
+#ifdef EM8622UNCACHED
+
+typedef void* mspace;
+extern mspace create_mspace_with_base(void* base, size_t capacity, int locked);
+extern void* mspace_malloc(mspace msp, size_t bytes);
+extern void mspace_free(mspace msp, void* mem);
+extern size_t mspace_footprint(mspace msp);
+extern void* mspace_memalign(mspace msp, size_t alignment, size_t bytes);
+
+#define UNCACHEDCOUNT 3
+// 1 page less than 2 megs
+#define UNCACHEDSIZE 2*1024*1022
+static unsigned int uncachedmembuf[UNCACHEDCOUNT] = {0,};
+static mspace uncachedmem[UNCACHEDCOUNT] = {NULL, };
+#undef fprintf
+#undef fflush
+#endif
+
+#undef fprintf
+#undef fflush
+
 void *av_realloc(void *ptr, unsigned int size)
 {
+    int i;
 #if CONFIG_MEMALIGN_HACK
     int diff;
 #endif
@@ -109,6 +137,24 @@
     if(size > (INT_MAX-16) )
         return NULL;
 
+	/* catch cases of runaway memor allocation */
+	if(size > (16*1024*1024))	// warning if > 16 megs
+		fprintf(stderr, "WARNING: Large av_realloc, size=%d\n", size);
+#ifdef EM8622
+    if(size > 8*1024*1024)
+        return NULL;
+#endif
+#ifdef EM8622UNCACHED
+    
+    for(i=0;i<UNCACHEDCOUNT;i++)
+    {
+        if (ptr && ((unsigned int)ptr)>= uncachedmembuf[i] && ((unsigned int)ptr) < (uncachedmembuf[i]+UNCACHEDSIZE))
+        {
+            fprintf(stderr, "realloc in uncached? %X\n",(unsigned int)ptr);
+            return NULL;
+        }
+    }
+#endif
 #if CONFIG_MEMALIGN_HACK
     //FIXME this isn't aligned correctly, though it probably isn't needed
     if(!ptr) return av_malloc(size);
@@ -121,9 +167,63 @@
 #endif
 }
 
+#ifdef EM8622UNCACHED
+
+static mspace initUncached(int size, int index)
+{
+    void *buffer = av_malloc(size);
+    mspace m1;
+    unsigned char *tmpbuf = av_malloc(16384);
+    int i;
+    fprintf(stderr, "Creating mspace at %X\n",(unsigned int)buffer);
+    buffer = (void *) (((unsigned int)buffer)&0x7FFFFFFF);
+    // Clean cache
+    for(i=0;i<16384;i++) tmpbuf[i]=i;
+    uncachedmembuf[index] = (unsigned int)buffer;
+    m1 = create_mspace_with_base(buffer, size, 0);
+    av_free(tmpbuf);
+    return m1;
+}
+
+void *av_mallocUncached(unsigned int size)
+{
+    int i;
+    static int initialized=0;
+    void *outptr;
+    if(!initialized)
+    {
+        for(i=0;i<UNCACHEDCOUNT;i++)
+        {
+            uncachedmem[i] = initUncached(UNCACHEDSIZE, i);
+        }
+        initialized=1;
+    }
+    for(i=0;i<UNCACHEDCOUNT;i++)
+    {
+        outptr = mspace_memalign(uncachedmem[i], 16, size);
+        if(outptr!=NULL) return outptr;
+    }
+//    fprintf(stderr, "Allocating %d bytes uncached ret %X\n", size, (unsigned int)outptr);
+    return outptr;
+}
+
+#endif
+
 void av_free(void *ptr)
 {
     /* XXX: this test should not be needed on most libcs */
+#ifdef EM8622UNCACHED
+    int i;
+    for(i=0;i<UNCACHEDCOUNT;i++)
+    {
+        if (ptr && ((unsigned int)ptr)>= uncachedmembuf[i] && ((unsigned int)ptr) < (uncachedmembuf[i]+UNCACHEDSIZE))
+        {
+//            fprintf(stderr, "Freeing %X\n", (unsigned int)ptr);
+            mspace_free(uncachedmem[i], ptr);
+            return;
+        }
+    }
+#endif
     if (ptr)
 #if CONFIG_MEMALIGN_HACK
         free((char*)ptr - ((char*)ptr)[-1]);
@@ -159,3 +259,41 @@
     return ptr;
 }
 
+#ifdef EM8622UNCACHED
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#endif
+
+// We implement this to use kernel copy
+void *av_memcpy(void *dest, const void *src, unsigned int size)
+{
+#ifdef EM8622UNCACHED
+    static int devmemfd=-1;
+    static unsigned long long bytescopied=0;
+
+    if(devmemfd<0)
+    {
+        devmemfd=open("/dev/mem",O_RDWR);
+    }
+    #undef fprintf
+   /* fprintf(stderr, "av_memcpy: pread %X %X %X\n",(unsigned int)dest, (unsigned int)src, size);
+    fflush(stderr);
+    usleep(1000);*/
+    if(((((unsigned int)dest)|((unsigned int)src))&0x80000000)==0 && size > 256)
+    {
+        lseek(devmemfd, ((unsigned int)src), SEEK_SET);
+        if(read(devmemfd, dest, size)!=size)
+        {
+            fprintf(stderr, "av_memcpy: pread %X %X %X failed\n",(unsigned int)dest, (unsigned int)src, size);
+        }
+        bytescopied+=size;
+        return dest;
+    }
+    else
+#endif
+    {
+        return memcpy(dest,src,size);
+    }
+}
diff --git a/libavutil/mem.h b/libavutil/mem.h
old mode 100644
new mode 100755
index e50553a..1b37ad4
--- a/libavutil/mem.h
+++ b/libavutil/mem.h
@@ -101,4 +101,12 @@
  */
 void av_freep(void *ptr);
 
+void *av_memcpy(void *dest, const void *src, unsigned int size);
+
+#ifdef EM8622UNCACHED
+void *av_mallocUncached(unsigned int size);
+#else
+#define av_mallocUncached av_malloc
+#endif
+
 #endif /* AVUTIL_MEM_H */
diff --git a/libavutil/pca.c b/libavutil/pca.c
index f803d3b..09c542b 100644
--- a/libavutil/pca.c
+++ b/libavutil/pca.c
@@ -164,9 +164,9 @@
 #ifdef TEST
 
 #undef printf
-#undef random
 #include <stdio.h>
 #include <stdlib.h>
+#include "lfg.h"
 
 int main(void){
     PCA *pca;
@@ -174,15 +174,18 @@
 #define LEN 8
     double eigenvector[LEN*LEN];
     double eigenvalue[LEN];
+    AVLFG prn;
+
+    av_lfg_init(&prn, 1);
 
     pca= ff_pca_init(LEN);
 
     for(i=0; i<9000000; i++){
         double v[2*LEN+100];
         double sum=0;
-        int pos= random()%LEN;
-        int v2= (random()%101) - 50;
-        v[0]= (random()%101) - 50;
+        int pos = av_lfg_get(&prn) % LEN;
+        int v2  = av_lfg_get(&prn) % 101 - 50;
+        v[0]    = av_lfg_get(&prn) % 101 - 50;
         for(j=1; j<8; j++){
             if(j<=pos) v[j]= v[0];
             else       v[j]= v2;
@@ -191,7 +194,7 @@
 /*        for(j=0; j<LEN; j++){
             v[j] -= v[pos];
         }*/
-//        sum += random()%10;
+//        sum += av_lfg_get(&prn) % 10;
 /*        for(j=0; j<LEN; j++){
             v[j] -= sum/LEN;
         }*/
diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h
index a682d21..21a72a8 100644
--- a/libavutil/pixfmt.h
+++ b/libavutil/pixfmt.h
@@ -63,11 +63,8 @@
     PIX_FMT_BGR24,     ///< packed RGB 8:8:8, 24bpp, BGRBGR...
     PIX_FMT_YUV422P,   ///< planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
     PIX_FMT_YUV444P,   ///< planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
-    PIX_FMT_RGB32,     ///< packed RGB 8:8:8, 32bpp, (msb)8A 8R 8G 8B(lsb), in CPU endianness
     PIX_FMT_YUV410P,   ///< planar YUV 4:1:0,  9bpp, (1 Cr & Cb sample per 4x4 Y samples)
     PIX_FMT_YUV411P,   ///< planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
-    PIX_FMT_RGB565,    ///< packed RGB 5:6:5, 16bpp, (msb)   5R 6G 5B(lsb), in CPU endianness
-    PIX_FMT_RGB555,    ///< packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), in CPU endianness, most significant bit to 0
     PIX_FMT_GRAY8,     ///<        Y        ,  8bpp
     PIX_FMT_MONOWHITE, ///<        Y        ,  1bpp, 0 is white, 1 is black
     PIX_FMT_MONOBLACK, ///<        Y        ,  1bpp, 0 is black, 1 is white
@@ -79,9 +76,6 @@
     PIX_FMT_XVMC_MPEG2_IDCT,
     PIX_FMT_UYVY422,   ///< packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
     PIX_FMT_UYYVYY411, ///< packed YUV 4:1:1, 12bpp, Cb Y0 Y1 Cr Y2 Y3
-    PIX_FMT_BGR32,     ///< packed RGB 8:8:8, 32bpp, (msb)8A 8B 8G 8R(lsb), in CPU endianness
-    PIX_FMT_BGR565,    ///< packed RGB 5:6:5, 16bpp, (msb)   5B 6G 5R(lsb), in CPU endianness
-    PIX_FMT_BGR555,    ///< packed RGB 5:5:5, 16bpp, (msb)1A 5B 5G 5R(lsb), in CPU endianness, most significant bit to 1
     PIX_FMT_BGR8,      ///< packed RGB 3:3:2,  8bpp, (msb)2B 3G 3R(lsb)
     PIX_FMT_BGR4,      ///< packed RGB 1:2:1,  4bpp, (msb)1B 2G 1R(lsb)
     PIX_FMT_BGR4_BYTE, ///< packed RGB 1:2:1,  8bpp, (msb)1B 2G 1R(lsb)
@@ -91,8 +85,10 @@
     PIX_FMT_NV12,      ///< planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 for UV
     PIX_FMT_NV21,      ///< as above, but U and V bytes are swapped
 
-    PIX_FMT_RGB32_1,   ///< packed RGB 8:8:8, 32bpp, (msb)8R 8G 8B 8A(lsb), in CPU endianness
-    PIX_FMT_BGR32_1,   ///< packed RGB 8:8:8, 32bpp, (msb)8B 8G 8R 8A(lsb), in CPU endianness
+    PIX_FMT_ARGB,      ///< packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
+    PIX_FMT_RGBA,      ///< packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
+    PIX_FMT_ABGR,      ///< packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
+    PIX_FMT_BGRA,      ///< packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
 
     PIX_FMT_GRAY16BE,  ///<        Y        , 16bpp, big-endian
     PIX_FMT_GRAY16LE,  ///<        Y        , 16bpp, little-endian
@@ -106,32 +102,39 @@
     PIX_FMT_VDPAU_VC1, ///< VC-1 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
     PIX_FMT_RGB48BE,   ///< packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, big-endian
     PIX_FMT_RGB48LE,   ///< packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, little-endian
-    PIX_FMT_VAAPI_MOCO, ///< HW acceleration through VA API at motion compensation entry-point, Picture.data[0] contains a vaapi_render_state struct which contains macroblocks as well as various fields extracted from headers
-    PIX_FMT_VAAPI_IDCT, ///< HW acceleration through VA API at IDCT entry-point, Picture.data[0] contains a vaapi_render_state struct which contains fields extracted from headers
-    PIX_FMT_VAAPI_VLD,  ///< HW decoding through VA API, Picture.data[0] contains a vaapi_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
+
+    PIX_FMT_RGB565BE,  ///< packed RGB 5:6:5, 16bpp, (msb)   5R 6G 5B(lsb), big-endian
+    PIX_FMT_RGB565LE,  ///< packed RGB 5:6:5, 16bpp, (msb)   5R 6G 5B(lsb), little-endian
+    PIX_FMT_RGB555BE,  ///< packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), big-endian, most significant bit to 0
+    PIX_FMT_RGB555LE,  ///< packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), little-endian, most significant bit to 0
+
+    PIX_FMT_BGR565BE,  ///< packed BGR 5:6:5, 16bpp, (msb)   5B 6G 5R(lsb), big-endian
+    PIX_FMT_BGR565LE,  ///< packed BGR 5:6:5, 16bpp, (msb)   5B 6G 5R(lsb), little-endian
+    PIX_FMT_BGR555BE,  ///< packed BGR 5:5:5, 16bpp, (msb)1A 5B 5G 5R(lsb), big-endian, most significant bit to 1
+    PIX_FMT_BGR555LE,  ///< packed BGR 5:5:5, 16bpp, (msb)1A 5B 5G 5R(lsb), little-endian, most significant bit to 1
+
+    PIX_FMT_VAAPI_MOCO, ///< HW acceleration through VA API at motion compensation entry-point, Picture.data[3] contains a vaapi_render_state struct which contains macroblocks as well as various fields extracted from headers
+    PIX_FMT_VAAPI_IDCT, ///< HW acceleration through VA API at IDCT entry-point, Picture.data[3] contains a vaapi_render_state struct which contains fields extracted from headers
+    PIX_FMT_VAAPI_VLD,  ///< HW decoding through VA API, Picture.data[3] contains a vaapi_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
     PIX_FMT_NB,        ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions
 };
 
 #ifdef WORDS_BIGENDIAN
-#define PIX_FMT_RGBA PIX_FMT_RGB32_1
-#define PIX_FMT_BGRA PIX_FMT_BGR32_1
-#define PIX_FMT_ARGB PIX_FMT_RGB32
-#define PIX_FMT_ABGR PIX_FMT_BGR32
-#define PIX_FMT_GRAY16 PIX_FMT_GRAY16BE
-#define PIX_FMT_RGB48 PIX_FMT_RGB48BE
+#   define PIX_FMT_NE(be, le) PIX_FMT_##be
 #else
-#define PIX_FMT_RGBA PIX_FMT_BGR32
-#define PIX_FMT_BGRA PIX_FMT_RGB32
-#define PIX_FMT_ARGB PIX_FMT_BGR32_1
-#define PIX_FMT_ABGR PIX_FMT_RGB32_1
-#define PIX_FMT_GRAY16 PIX_FMT_GRAY16LE
-#define PIX_FMT_RGB48 PIX_FMT_RGB48LE
+#   define PIX_FMT_NE(be, le) PIX_FMT_##le
 #endif
 
-#if LIBAVUTIL_VERSION_INT < (50<<16)
-#define PIX_FMT_UYVY411 PIX_FMT_UYYVYY411
-#define PIX_FMT_RGBA32  PIX_FMT_RGB32
-#define PIX_FMT_YUV422  PIX_FMT_YUYV422
-#endif
+#define PIX_FMT_RGB32   PIX_FMT_NE(ARGB, BGRA)
+#define PIX_FMT_RGB32_1 PIX_FMT_NE(RGBA, ABGR)
+#define PIX_FMT_BGR32   PIX_FMT_NE(ABGR, RGBA)
+#define PIX_FMT_BGR32_1 PIX_FMT_NE(BGRA, ARGB)
+
+#define PIX_FMT_GRAY16 PIX_FMT_NE(GRAY16BE, GRAY16LE)
+#define PIX_FMT_RGB48  PIX_FMT_NE(RGB48BE,  RGB48LE)
+#define PIX_FMT_RGB565 PIX_FMT_NE(RGB565BE, RGB565LE)
+#define PIX_FMT_RGB555 PIX_FMT_NE(RGB555BE, RGB555LE)
+#define PIX_FMT_BGR565 PIX_FMT_NE(BGR565BE, BGR565LE)
+#define PIX_FMT_BGR555 PIX_FMT_NE(BGR555BE, BGR555LE)
 
 #endif /* AVUTIL_PIXFMT_H */
diff --git a/libavutil/random.c b/libavutil/random.c
deleted file mode 100644
index 5597e1d..0000000
--- a/libavutil/random.c
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Mersenne Twister PRNG algorithm
- * Copyright (c) 2006 Ryan Martell
- * Based on a C program for MT19937, with initialization improved 2002/1/26.
- * Coded by Takuji Nishimura and Makoto Matsumoto.
- *
- * 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
- */
-
-
-/**
- * See http://en.wikipedia.org/wiki/Mersenne_twister
- * for an explanation of this algorithm.
- */
-#include <stdio.h>
-#include "random.h"
-
-
-/* period parameters */
-#define M 397
-#define A 0x9908b0df /* constant vector a */
-#define UPPER_MASK 0x80000000 /* most significant w-r bits */
-#define LOWER_MASK 0x7fffffff /* least significant r bits */
-
-/** Initializes mt[AV_RANDOM_N] with a seed. */
-void av_random_init(AVRandomState *state, unsigned int seed)
-{
-    int index;
-
-    /*
-     This differs from the Wikipedia article.  Source is from the
-     Makoto Matsumoto and Takuji Nishimura code, with the following comment:
-     */
-     /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */
-     /* In the previous versions, MSBs of the seed affect   */
-     /* only MSBs of the array mt[].                        */
-    state->mt[0] = seed & 0xffffffff;
-    for (index = 1; index < AV_RANDOM_N; index++) {
-        unsigned int prev= state->mt[index - 1];
-        state->mt[index] = (1812433253UL * (prev ^ (prev>>30)) + index) & 0xffffffff;
-    }
-    state->index= index; // Will cause it to generate untempered numbers in the first iteration.
-}
-
-#if LIBAVUTIL_VERSION_MAJOR < 50
-void av_init_random(unsigned int seed, AVRandomState *state)
-{
-    av_random_init(state, seed);
-}
-#endif
-
-/** Generates AV_RANDOM_N words at one time (which will then be tempered later).
- * av_random calls this; you shouldn't. */
-void av_random_generate_untempered_numbers(AVRandomState *state)
-{
-    int kk;
-    unsigned int y;
-
-    for (kk = 0; kk < AV_RANDOM_N - M; kk++) {
-        y = (state->mt[kk] & UPPER_MASK) | (state->mt[kk + 1] & LOWER_MASK);
-        state->mt[kk] = state->mt[kk + M] ^ (y >> 1) ^ ((y&1)*A);
-    }
-    for (; kk < AV_RANDOM_N - 1; kk++) {
-        y = (state->mt[kk] & UPPER_MASK) | (state->mt[kk + 1] & LOWER_MASK);
-        state->mt[kk] = state->mt[kk + (M - AV_RANDOM_N)] ^ (y >> 1) ^ ((y&1)*A);
-    }
-    y = (state->mt[AV_RANDOM_N - 1] & UPPER_MASK) | (state->mt[0] & LOWER_MASK);
-    state->mt[AV_RANDOM_N - 1] = state->mt[M - 1] ^ (y >> 1) ^ ((y&1)*A);
-    state->index = 0;
-}
-
-#ifdef TEST
-#include "common.h"
-#include "log.h"
-int main(void)
-{
-    int x=0;
-    int i, j;
-    AVRandomState state;
-
-    av_random_init(&state, 0xdeadbeef);
-    for (j = 0; j < 10000; j++) {
-        START_TIMER
-        for (i = 0; i < 624; i++) {
-            x+= av_random(&state);
-        }
-        STOP_TIMER("624 calls of av_random");
-    }
-    av_log(NULL, AV_LOG_ERROR, "final value:%X\n", x);
-    return 0;
-}
-#endif
diff --git a/libavutil/random.h b/libavutil/random.h
deleted file mode 100644
index 4d16eb9..0000000
--- a/libavutil/random.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Mersenne Twister PRNG algorithm
- * Copyright (c) 2006 Ryan Martell
- * Based on a C program for MT19937, with initialization improved 2002/1/26.
- * Coded by Takuji Nishimura and Makoto Matsumoto.
- *
- * 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_RANDOM_H
-#define AVUTIL_RANDOM_H
-
-#define AV_RANDOM_N 624
-
-#include "avutil.h"
-#include "common.h"
-
-typedef struct {
-    unsigned int mt[AV_RANDOM_N]; ///< the array for the state vector
-    int index; ///< Current untempered value we use as the base.
-} AVRandomState;
-
-
-#if LIBAVUTIL_VERSION_MAJOR < 50
-attribute_deprecated void av_init_random(unsigned int seed, AVRandomState *state);
-#endif
-void av_random_init(AVRandomState *state, unsigned int seed); ///< To be inlined, the struct must be visible. So it does not make sense to try and keep it opaque with malloc/free-like calls.
-void av_random_generate_untempered_numbers(AVRandomState *state); ///< Regenerate the untempered numbers (must be done every 624 iterations, or it will loop).
-
-/**
- * Generates a random number from the interval [0,0xffffffff].
- *
- * Please do NOT use the Mersenne Twister, it is slow. Use the random number
- * generator from lfg.c/h or a simple LCG like state = state*1664525+1013904223.
- * If you still choose to use MT, expect that you will have to provide
- * some evidence that it makes a difference for the case where you use it.
- */
-static inline unsigned int av_random(AVRandomState *state)
-{
-    unsigned int y;
-
-    // Regenerate the untempered numbers if we should...
-    if (state->index >= AV_RANDOM_N)
-        av_random_generate_untempered_numbers(state);
-
-    // Grab one...
-    y = state->mt[state->index++];
-
-    /* Now temper (Mersenne Twister coefficients). The coefficients for MT19937 are.. */
-    y ^= (y >> 11);
-    y ^= (y << 7) & 0x9d2c5680;
-    y ^= (y << 15) & 0xefc60000;
-    y ^= (y >> 18);
-
-    return y;
-}
-
-/** Returns a random number in the range [0-1] as double. */
-static inline double av_random_real1(AVRandomState *state)
-{
-    /* divided by 2^32-1 */
-    return av_random(state) * (1.0 / 4294967296.0);
-}
-
-#endif /* AVUTIL_RANDOM_H */
diff --git a/libavutil/random_seed.c b/libavutil/random_seed.c
new file mode 100644
index 0000000..2b2985d
--- /dev/null
+++ b/libavutil/random_seed.c
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2009 Baptiste Coudurier <baptiste.coudurier@gmail.com>
+ *
+ * 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 <unistd.h>
+#include <fcntl.h>
+#include "timer.h"
+#include "random_seed.h"
+
+uint32_t ff_random_get_seed(void)
+{
+    uint32_t seed;
+    int fd;
+
+    if ((fd = open("/dev/random", O_RDONLY)) == -1)
+        fd = open("/dev/urandom", O_RDONLY);
+    if (fd != -1){
+        read(fd, &seed, 4);
+        close(fd);
+        return seed;
+    }
+#ifdef AV_READ_TIME
+    seed = AV_READ_TIME();
+#endif
+    // XXX what to do ?
+    return seed;
+}
diff --git a/libavutil/random_seed.h b/libavutil/random_seed.h
new file mode 100644
index 0000000..a954381
--- /dev/null
+++ b/libavutil/random_seed.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2009 Baptiste Coudurier <baptiste.coudurier@gmail.com>
+ *
+ * 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_RANDOM_SEED_H
+#define AVUTIL_RANDOM_SEED_H
+
+#include <stdint.h>
+
+/**
+ * Gets a seed to use in conjunction with random functions.
+ */
+uint32_t ff_random_get_seed(void);
+
+#endif /* AVUTIL_RANDOM_SEED_H */
diff --git a/libavutil/rational.c b/libavutil/rational.c
old mode 100644
new mode 100755
diff --git a/libavutil/rational.h b/libavutil/rational.h
old mode 100644
new mode 100755
diff --git a/libavutil/rc4.c b/libavutil/rc4.c
old mode 100644
new mode 100755
index e6e7dc9..4e52ba5
--- a/libavutil/rc4.c
+++ b/libavutil/rc4.c
@@ -59,11 +59,3 @@
     }
     r->x = x; r->y = y;
 }
-
-#if LIBAVUTIL_VERSION_MAJOR < 50
-void ff_rc4_enc(const uint8_t *key, int keylen, uint8_t *data, int datalen) {
-    AVRC4 r;
-    av_rc4_init(&r, key, keylen * 8, 0);
-    av_rc4_crypt(&r, data, data, datalen, NULL, 0);
-}
-#endif
diff --git a/libavutil/softfloat.c b/libavutil/softfloat.c
old mode 100644
new mode 100755
index a5757c2..efa0420
--- a/libavutil/softfloat.c
+++ b/libavutil/softfloat.c
@@ -32,7 +32,7 @@
     SoftFloat sf1, sf2;
     double d1, d2;
     int i, j;
-av_log_level = AV_LOG_DEBUG;
+    av_log_set_level(AV_LOG_DEBUG);
 
     d1= 1;
     for(i= 0; i<10; i++){
diff --git a/libavutil/tree.c b/libavutil/tree.c
index c9a19fa..62437ff 100644
--- a/libavutil/tree.c
+++ b/libavutil/tree.c
@@ -144,7 +144,9 @@
 #endif
 
 #ifdef TEST
-#undef random
+
+#include "lfg.h"
+
 static int check(AVTreeNode *t){
     if(t){
         int left= check(t->child[0]);
@@ -179,9 +181,12 @@
 int main(void){
     int i,k;
     AVTreeNode *root= NULL, *node=NULL;
+    AVLFG prn;
+
+    av_lfg_init(&prn, 1);
 
     for(i=0; i<10000; i++){
-        int j= (random()%86294);
+        int j = av_lfg_get(&prn) % 86294;
         if(check(root) > 999){
             av_log(NULL, AV_LOG_ERROR, "FATAL error %d\n", i);
         print(root, 0);
@@ -192,7 +197,7 @@
             node= av_mallocz(av_tree_node_size);
         av_tree_insert(&root, (void*)(j+1), cmp, &node);
 
-        j= (random()%86294);
+        j = av_lfg_get(&prn) % 86294;
         {
             AVTreeNode *node2=NULL;
             av_log(NULL, AV_LOG_ERROR, "removing %4d\n", j);
diff --git a/libavutil/utils.c b/libavutil/utils.c
old mode 100644
new mode 100755
diff --git a/libavutil/x86_cpu.h b/libavutil/x86_cpu.h
index d29b7d8..08d3146 100644
--- a/libavutil/x86_cpu.h
+++ b/libavutil/x86_cpu.h
@@ -62,6 +62,8 @@
 #    define REGc    ecx
 #    define REGd    edx
 #    define REGSP   esp
+#else
+typedef int x86_reg;
 #endif
 
 #define HAVE_7REGS (ARCH_X86_64 || (HAVE_EBX_AVAILABLE && HAVE_EBP_AVAILABLE))
diff --git a/libpostproc/Makefile b/libpostproc/Makefile
old mode 100644
new mode 100755
diff --git a/libpostproc/libpostproc.v b/libpostproc/libpostproc.v
deleted file mode 100644
index e65d76f..0000000
--- a/libpostproc/libpostproc.v
+++ /dev/null
@@ -1,4 +0,0 @@
-LIBPOSTPROC_$MAJOR {
-        global: postproc_*; pp_*;
-        local: *;
-};
diff --git a/libpostproc/postprocess.c b/libpostproc/postprocess.c
old mode 100644
new mode 100755
index b5b6649..4cfbaad
--- a/libpostproc/postprocess.c
+++ b/libpostproc/postprocess.c
@@ -554,7 +554,7 @@
 
 //Note: we have C, MMX, MMX2, 3DNOW version there is no 3DNOW+MMX2 one
 //Plain C versions
-#if !(HAVE_MMX || HAVE_ALTIVEC) || CONFIG_RUNTIME_CPUDETECT
+#if !(HAVE_MMX || HAVE_ALTIVEC) || defined (RUNTIME_CPUDETECT)
 #define COMPILE_C
 #endif
 
@@ -564,15 +564,15 @@
 
 #if ARCH_X86
 
-#if (HAVE_MMX && !HAVE_AMD3DNOW && !HAVE_MMX2) || CONFIG_RUNTIME_CPUDETECT
+#if (HAVE_MMX && !HAVE_AMD3DNOW && !HAVE_MMX2) || defined (RUNTIME_CPUDETECT)
 #define COMPILE_MMX
 #endif
 
-#if HAVE_MMX2 || CONFIG_RUNTIME_CPUDETECT
+#if HAVE_MMX2 || defined (RUNTIME_CPUDETECT)
 #define COMPILE_MMX2
 #endif
 
-#if (HAVE_AMD3DNOW && !HAVE_MMX2) || CONFIG_RUNTIME_CPUDETECT
+#if (HAVE_AMD3DNOW && !HAVE_MMX2) || defined (RUNTIME_CPUDETECT)
 #define COMPILE_3DNOW
 #endif
 #endif /* ARCH_X86 */
@@ -645,7 +645,7 @@
     // Using ifs here as they are faster than function pointers although the
     // difference would not be measurable here but it is much better because
     // someone might exchange the CPU whithout restarting MPlayer ;)
-#if CONFIG_RUNTIME_CPUDETECT
+#ifdef RUNTIME_CPUDETECT
 #if ARCH_X86
     // ordered per speed fastest first
     if(c->cpuCaps & PP_CPU_CAPS_MMX2)
@@ -664,7 +664,7 @@
 #endif
             postProcess_C(src, srcStride, dst, dstStride, width, height, QPs, QPStride, isColor, c);
 #endif
-#else //CONFIG_RUNTIME_CPUDETECT
+#else //RUNTIME_CPUDETECT
 #if   HAVE_MMX2
             postProcess_MMX2(src, srcStride, dst, dstStride, width, height, QPs, QPStride, isColor, c);
 #elif HAVE_AMD3DNOW
@@ -676,7 +676,7 @@
 #else
             postProcess_C(src, srcStride, dst, dstStride, width, height, QPs, QPStride, isColor, c);
 #endif
-#endif //!CONFIG_RUNTIME_CPUDETECT
+#endif //!RUNTIME_CPUDETECT
 }
 
 //static void postProcess(uint8_t src[], int srcStride, uint8_t dst[], int dstStride, int width, int height,
diff --git a/libpostproc/postprocess.h b/libpostproc/postprocess.h
old mode 100644
new mode 100755
diff --git a/libpostproc/postprocess_altivec_template.c b/libpostproc/postprocess_altivec_template.c
old mode 100644
new mode 100755
diff --git a/libpostproc/postprocess_internal.h b/libpostproc/postprocess_internal.h
old mode 100644
new mode 100755
diff --git a/libpostproc/postprocess_template.c b/libpostproc/postprocess_template.c
old mode 100644
new mode 100755
diff --git a/libswscale/Makefile b/libswscale/Makefile
index 6d500ab..61f5e5a 100644
--- a/libswscale/Makefile
+++ b/libswscale/Makefile
@@ -7,18 +7,23 @@
 
 OBJS = rgb2rgb.o swscale.o swscale_avoption.o yuv2rgb.o
 
-OBJS-$(ARCH_BFIN)          +=  internal_bfin.o swscale_bfin.o yuv2rgb_bfin.o
-OBJS-$(CONFIG_MLIB)        +=  yuv2rgb_mlib.o
-OBJS-$(HAVE_ALTIVEC)       +=  yuv2rgb_altivec.o
-OBJS-$(HAVE_VIS)           +=  yuv2rgb_vis.o
+OBJS-$(ARCH_BFIN)          +=  internal_bfin.o swscale_bfin.o bfin/yuv2rgb_bfin.o
+OBJS-$(CONFIG_MLIB)        +=  mlib/yuv2rgb_mlib.o
+OBJS-$(HAVE_ALTIVEC)       +=  ppc/yuv2rgb_altivec.o
+OBJS-$(HAVE_VIS)           +=  sparc/yuv2rgb_vis.o
 
-TESTS = cs_test swscale-example
+MMX-OBJS-$(CONFIG_GPL)     +=  x86/yuv2rgb_mmx.o        \
 
-CLEANFILES = cs_test swscale-example
+OBJS-$(HAVE_MMX)           +=  $(MMX-OBJS-yes)
+
+EXAMPLES  = swscale-example
+TESTPROGS = colorspace
+
+DIRS = bfin mlib ppc sparc x86
 
 include $(SUBDIR)../subdir.mak
 
-$(SUBDIR)cs_test: $(SUBDIR)cs_test.o $(SUBDIR)$(LIBNAME)
+$(SUBDIR)colorspace-test: $(SUBDIR)colorspace-test.o $(SUBDIR)$(LIBNAME)
 
 $(SUBDIR)swscale-example: $(SUBDIR)swscale-example.o $(SUBDIR)$(LIBNAME)
 $(SUBDIR)swscale-example: EXTRALIBS += -lm
diff --git a/libswscale/bfin/yuv2rgb_bfin.c b/libswscale/bfin/yuv2rgb_bfin.c
new file mode 100644
index 0000000..39e1ec8
--- /dev/null
+++ b/libswscale/bfin/yuv2rgb_bfin.c
@@ -0,0 +1,203 @@
+/*
+ * Copyright (C) 2007 Marc Hoffman <marc.hoffman@analog.com>
+ *
+ * Blackfin video color space converter operations
+ * convert I420 YV12 to RGB in various formats
+ *
+ * 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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <inttypes.h>
+#include <assert.h>
+#include "config.h"
+#include <unistd.h>
+#include "libswscale/rgb2rgb.h"
+#include "libswscale/swscale.h"
+#include "libswscale/swscale_internal.h"
+
+#ifdef __FDPIC__
+#define L1CODE __attribute__ ((l1_text))
+#else
+#define L1CODE
+#endif
+
+void ff_bfin_yuv2rgb555_line(uint8_t *Y, uint8_t *U, uint8_t *V, uint8_t *out,
+                             int w, uint32_t *coeffs) L1CODE;
+
+void ff_bfin_yuv2rgb565_line(uint8_t *Y, uint8_t *U, uint8_t *V, uint8_t *out,
+                             int w, uint32_t *coeffs) L1CODE;
+
+void ff_bfin_yuv2rgb24_line(uint8_t *Y, uint8_t *U, uint8_t *V, uint8_t *out,
+                            int w, uint32_t *coeffs) L1CODE;
+
+typedef void (* ltransform)(uint8_t *Y, uint8_t *U, uint8_t *V, uint8_t *out,
+                            int w, uint32_t *coeffs);
+
+
+static void bfin_prepare_coefficients(SwsContext *c, int rgb, int masks)
+{
+    int oy;
+    oy      = c->yOffset&0xffff;
+    oy      = oy >> 3; // keep everything U8.0 for offset calculation
+
+    c->oc   = 128*0x01010101U;
+    c->oy   =  oy*0x01010101U;
+
+    /* copy 64bit vector coeffs down to 32bit vector coeffs */
+    c->cy  = c->yCoeff;
+    c->zero = 0;
+
+    if (rgb) {
+        c->crv = c->vrCoeff;
+        c->cbu = c->ubCoeff;
+        c->cgu = c->ugCoeff;
+        c->cgv = c->vgCoeff;
+    } else {
+        c->crv = c->ubCoeff;
+        c->cbu = c->vrCoeff;
+        c->cgu = c->vgCoeff;
+        c->cgv = c->ugCoeff;
+    }
+
+
+    if (masks == 555) {
+        c->rmask = 0x001f * 0x00010001U;
+        c->gmask = 0x03e0 * 0x00010001U;
+        c->bmask = 0x7c00 * 0x00010001U;
+    } else if (masks == 565) {
+        c->rmask = 0x001f * 0x00010001U;
+        c->gmask = 0x07e0 * 0x00010001U;
+        c->bmask = 0xf800 * 0x00010001U;
+    }
+}
+
+static int core_yuv420_rgb(SwsContext *c,
+                           uint8_t **in, int *instrides,
+                           int srcSliceY, int srcSliceH,
+                           uint8_t **oplanes, int *outstrides,
+                           ltransform lcscf, int rgb, int masks)
+{
+    uint8_t *py,*pu,*pv,*op;
+    int w  = instrides[0];
+    int h2 = srcSliceH>>1;
+    int i;
+
+    bfin_prepare_coefficients(c, rgb, masks);
+
+    py = in[0];
+    pu = in[1+(1^rgb)];
+    pv = in[1+(0^rgb)];
+
+    op = oplanes[0] + srcSliceY*outstrides[0];
+
+    for (i=0;i<h2;i++) {
+
+        lcscf(py, pu, pv, op, w, &c->oy);
+
+        py += instrides[0];
+        op += outstrides[0];
+
+        lcscf(py, pu, pv, op, w, &c->oy);
+
+        py += instrides[0];
+        pu += instrides[1];
+        pv += instrides[2];
+        op += outstrides[0];
+    }
+
+    return srcSliceH;
+}
+
+
+static int bfin_yuv420_rgb555(SwsContext *c,
+                              uint8_t **in, int *instrides,
+                              int srcSliceY, int srcSliceH,
+                              uint8_t **oplanes, int *outstrides)
+{
+    return core_yuv420_rgb(c, in, instrides, srcSliceY, srcSliceH, oplanes,
+                           outstrides, ff_bfin_yuv2rgb555_line, 1, 555);
+}
+
+static int bfin_yuv420_bgr555(SwsContext *c,
+                              uint8_t **in, int *instrides,
+                              int srcSliceY, int srcSliceH,
+                              uint8_t **oplanes, int *outstrides)
+{
+    return core_yuv420_rgb(c, in, instrides, srcSliceY, srcSliceH, oplanes,
+                           outstrides, ff_bfin_yuv2rgb555_line, 0, 555);
+}
+
+static int bfin_yuv420_rgb24(SwsContext *c,
+                             uint8_t **in, int *instrides,
+                             int srcSliceY, int srcSliceH,
+                             uint8_t **oplanes, int *outstrides)
+{
+    return core_yuv420_rgb(c, in, instrides, srcSliceY, srcSliceH, oplanes,
+                           outstrides, ff_bfin_yuv2rgb24_line, 1, 888);
+}
+
+static int bfin_yuv420_bgr24(SwsContext *c,
+                             uint8_t **in, int *instrides,
+                             int srcSliceY, int srcSliceH,
+                             uint8_t **oplanes, int *outstrides)
+{
+    return core_yuv420_rgb(c, in, instrides, srcSliceY, srcSliceH, oplanes,
+                           outstrides, ff_bfin_yuv2rgb24_line, 0, 888);
+}
+
+static int bfin_yuv420_rgb565(SwsContext *c,
+                              uint8_t **in, int *instrides,
+                              int srcSliceY, int srcSliceH,
+                              uint8_t **oplanes, int *outstrides)
+{
+    return core_yuv420_rgb(c, in, instrides, srcSliceY, srcSliceH, oplanes,
+                           outstrides, ff_bfin_yuv2rgb565_line, 1, 565);
+}
+
+static int bfin_yuv420_bgr565(SwsContext *c,
+                              uint8_t **in, int *instrides,
+                              int srcSliceY, int srcSliceH,
+                              uint8_t **oplanes, int *outstrides)
+{
+    return core_yuv420_rgb(c, in, instrides, srcSliceY, srcSliceH, oplanes,
+                           outstrides, ff_bfin_yuv2rgb565_line, 0, 565);
+}
+
+
+SwsFunc ff_yuv2rgb_get_func_ptr_bfin(SwsContext *c)
+{
+    SwsFunc f;
+
+    switch(c->dstFormat) {
+    case PIX_FMT_RGB555: f = bfin_yuv420_rgb555; break;
+    case PIX_FMT_BGR555: f = bfin_yuv420_bgr555; break;
+    case PIX_FMT_RGB565: f = bfin_yuv420_rgb565; break;
+    case PIX_FMT_BGR565: f = bfin_yuv420_bgr565; break;
+    case PIX_FMT_RGB24:  f = bfin_yuv420_rgb24;  break;
+    case PIX_FMT_BGR24:  f = bfin_yuv420_bgr24;  break;
+    default:
+        return 0;
+    }
+
+    av_log(c, AV_LOG_INFO, "BlackFin accelerated color space converter %s\n",
+           sws_format_name (c->dstFormat));
+
+    return f;
+}
diff --git a/libswscale/cs_test.c b/libswscale/colorspace-test.c
similarity index 100%
rename from libswscale/cs_test.c
rename to libswscale/colorspace-test.c
diff --git a/libswscale/libswscale.v b/libswscale/libswscale.v
deleted file mode 100644
index 06e907a..0000000
--- a/libswscale/libswscale.v
+++ /dev/null
@@ -1,3 +0,0 @@
-LIBSWSCALE_$MAJOR {
-        global: *;
-};
diff --git a/libswscale/yuv2rgb_mlib.c b/libswscale/mlib/yuv2rgb_mlib.c
similarity index 97%
rename from libswscale/yuv2rgb_mlib.c
rename to libswscale/mlib/yuv2rgb_mlib.c
index 6824791..a4bdd19 100644
--- a/libswscale/yuv2rgb_mlib.c
+++ b/libswscale/mlib/yuv2rgb_mlib.c
@@ -28,7 +28,7 @@
 #include <stdlib.h>
 #include <assert.h>
 
-#include "swscale.h"
+#include "libswscale/swscale.h"
 
 static int mlib_YUV2ARGB420_32(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
                                int srcSliceH, uint8_t* dst[], int dstStride[]){
@@ -73,7 +73,7 @@
 }
 
 
-SwsFunc sws_yuv2rgb_init_mlib(SwsContext *c)
+SwsFunc ff_yuv2rgb_init_mlib(SwsContext *c)
 {
     switch(c->dstFormat){
     case PIX_FMT_RGB24: return mlib_YUV2RGB420_24;
diff --git a/libswscale/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
similarity index 98%
rename from libswscale/yuv2rgb_altivec.c
rename to libswscale/ppc/yuv2rgb_altivec.c
index b3a87a0..dc5894c 100644
--- a/libswscale/yuv2rgb_altivec.c
+++ b/libswscale/ppc/yuv2rgb_altivec.c
@@ -91,9 +91,9 @@
 #include <inttypes.h>
 #include <assert.h>
 #include "config.h"
-#include "rgb2rgb.h"
-#include "swscale.h"
-#include "swscale_internal.h"
+#include "libswscale/rgb2rgb.h"
+#include "libswscale/swscale.h"
+#include "libswscale/swscale_internal.h"
 
 #undef PROFILE_THE_BEAST
 #undef INC_SCALING
@@ -690,7 +690,7 @@
 
    So we just fall back to the C codes for this.
 */
-SwsFunc sws_yuv2rgb_init_altivec (SwsContext *c)
+SwsFunc ff_yuv2rgb_init_altivec(SwsContext *c)
 {
     if (!(c->flags & SWS_CPU_CAPS_ALTIVEC))
         return NULL;
@@ -750,7 +750,7 @@
     return NULL;
 }
 
-void sws_yuv2rgb_altivec_init_tables (SwsContext *c, const int inv_table[4],int brightness,int contrast, int saturation)
+void ff_yuv2rgb_init_tables_altivec(SwsContext *c, const int inv_table[4], int brightness, int contrast, int saturation)
 {
     union {
         signed short tmp[8] __attribute__ ((aligned(16)));
@@ -786,7 +786,7 @@
 
 
 void
-altivec_yuv2packedX (SwsContext *c,
+ff_yuv2packedX_altivec(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)
diff --git a/libswscale/rgb2rgb.c b/libswscale/rgb2rgb.c
index ad69265..59b8e30 100644
--- a/libswscale/rgb2rgb.c
+++ b/libswscale/rgb2rgb.c
@@ -87,6 +87,19 @@
                      long width, long height,
                      long srcStride1, long srcStride2,
                      long srcStride3, long dstStride);
+void (*uyvytoyuv420)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src,
+                                      long width, long height,
+                                      long lumStride, long chromStride, long srcStride);
+void (*uyvytoyuv422)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src,
+                                      long width, long height,
+                                      long lumStride, long chromStride, long srcStride);
+void (*yuyvtoyuv420)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src,
+                                      long width, long height,
+                                      long lumStride, long chromStride, long srcStride);
+void (*yuyvtoyuv422)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src,
+                                      long width, long height,
+                                      long lumStride, long chromStride, long srcStride);
+
 
 #if ARCH_X86 && CONFIG_GPL
 DECLARE_ASM_CONST(8, uint64_t, mmx_null)     = 0x0000000000000000ULL;
diff --git a/libswscale/rgb2rgb.h b/libswscale/rgb2rgb.h
index df912c8..3850ef2 100644
--- a/libswscale/rgb2rgb.h
+++ b/libswscale/rgb2rgb.h
@@ -142,6 +142,20 @@
                             long srcStride1, long srcStride2,
                             long srcStride3, long dstStride);
 
+
+extern void (*uyvytoyuv420)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src,
+                                      long width, long height,
+                                      long lumStride, long chromStride, long srcStride);
+extern void (*uyvytoyuv422)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src,
+                                      long width, long height,
+                                      long lumStride, long chromStride, long srcStride);
+extern void (*yuyvtoyuv420)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src,
+                                      long width, long height,
+                                      long lumStride, long chromStride, long srcStride);
+extern void (*yuyvtoyuv422)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src,
+                                      long width, long height,
+                                      long lumStride, long chromStride, long srcStride);
+
 void sws_rgb2rgb_init(int flags);
 
 #endif /* SWSCALE_RGB2RGB_H */
diff --git a/libswscale/rgb2rgb_template.c b/libswscale/rgb2rgb_template.c
index e95b628..09a57ca 100644
--- a/libswscale/rgb2rgb_template.c
+++ b/libswscale/rgb2rgb_template.c
@@ -1202,6 +1202,25 @@
     }
 }
 
+/*
+ * mm0 = 00 B3 00 B2 00 B1 00 B0
+ * mm1 = 00 G3 00 G2 00 G1 00 G0
+ * mm2 = 00 R3 00 R2 00 R1 00 R0
+ * mm6 = FF FF FF FF FF FF FF FF
+ * mm7 = 00 00 00 00 00 00 00 00
+ */
+#define PACK_RGB32 \
+    "packuswb   %%mm7, %%mm0    \n\t" /* 00 00 00 00 B3 B2 B1 B0 */ \
+    "packuswb   %%mm7, %%mm1    \n\t" /* 00 00 00 00 G3 G2 G1 G0 */ \
+    "packuswb   %%mm7, %%mm2    \n\t" /* 00 00 00 00 R3 R2 R1 R0 */ \
+    "punpcklbw  %%mm1, %%mm0    \n\t" /* G3 B3 G2 B2 G1 B1 G0 B0 */ \
+    "punpcklbw  %%mm6, %%mm2    \n\t" /* FF R3 FF R2 FF R1 FF R0 */ \
+    "movq       %%mm0, %%mm3    \n\t"                               \
+    "punpcklwd  %%mm2, %%mm0    \n\t" /* FF R1 G1 B1 FF R0 G0 B0 */ \
+    "punpckhwd  %%mm2, %%mm3    \n\t" /* FF R3 G3 B3 FF R2 G2 B2 */ \
+    MOVNTQ"     %%mm0,  %0      \n\t"                               \
+    MOVNTQ"     %%mm3, 8%0      \n\t"                               \
+
 static inline void RENAME(rgb15to32)(const uint8_t *src, uint8_t *dst, long src_size)
 {
     const uint16_t *end;
@@ -1214,6 +1233,7 @@
 #if HAVE_MMX
     __asm__ volatile(PREFETCH"    %0"::"m"(*s):"memory");
     __asm__ volatile("pxor    %%mm7,%%mm7    \n\t":::"memory");
+    __asm__ volatile("pcmpeqd %%mm6,%%mm6    \n\t":::"memory");
     mm_end = end - 3;
     while (s < mm_end)
     {
@@ -1228,25 +1248,7 @@
         "psllq         $3, %%mm0    \n\t"
         "psrlq         $2, %%mm1    \n\t"
         "psrlq         $7, %%mm2    \n\t"
-        "movq       %%mm0, %%mm3    \n\t"
-        "movq       %%mm1, %%mm4    \n\t"
-        "movq       %%mm2, %%mm5    \n\t"
-        "punpcklwd  %%mm7, %%mm0    \n\t"
-        "punpcklwd  %%mm7, %%mm1    \n\t"
-        "punpcklwd  %%mm7, %%mm2    \n\t"
-        "punpckhwd  %%mm7, %%mm3    \n\t"
-        "punpckhwd  %%mm7, %%mm4    \n\t"
-        "punpckhwd  %%mm7, %%mm5    \n\t"
-        "psllq         $8, %%mm1    \n\t"
-        "psllq        $16, %%mm2    \n\t"
-        "por        %%mm1, %%mm0    \n\t"
-        "por        %%mm2, %%mm0    \n\t"
-        "psllq         $8, %%mm4    \n\t"
-        "psllq        $16, %%mm5    \n\t"
-        "por        %%mm4, %%mm3    \n\t"
-        "por        %%mm5, %%mm3    \n\t"
-        MOVNTQ"     %%mm0,  %0      \n\t"
-        MOVNTQ"     %%mm3, 8%0      \n\t"
+        PACK_RGB32
         :"=m"(*d)
         :"m"(*s),"m"(mask15b),"m"(mask15g),"m"(mask15r)
         :"memory");
@@ -1292,6 +1294,7 @@
 #if HAVE_MMX
     __asm__ volatile(PREFETCH"    %0"::"m"(*s):"memory");
     __asm__ volatile("pxor    %%mm7,%%mm7    \n\t":::"memory");
+    __asm__ volatile("pcmpeqd %%mm6,%%mm6    \n\t":::"memory");
     mm_end = end - 3;
     while (s < mm_end)
     {
@@ -1306,25 +1309,7 @@
         "psllq         $3, %%mm0    \n\t"
         "psrlq         $3, %%mm1    \n\t"
         "psrlq         $8, %%mm2    \n\t"
-        "movq       %%mm0, %%mm3    \n\t"
-        "movq       %%mm1, %%mm4    \n\t"
-        "movq       %%mm2, %%mm5    \n\t"
-        "punpcklwd  %%mm7, %%mm0    \n\t"
-        "punpcklwd  %%mm7, %%mm1    \n\t"
-        "punpcklwd  %%mm7, %%mm2    \n\t"
-        "punpckhwd  %%mm7, %%mm3    \n\t"
-        "punpckhwd  %%mm7, %%mm4    \n\t"
-        "punpckhwd  %%mm7, %%mm5    \n\t"
-        "psllq         $8, %%mm1    \n\t"
-        "psllq        $16, %%mm2    \n\t"
-        "por        %%mm1, %%mm0    \n\t"
-        "por        %%mm2, %%mm0    \n\t"
-        "psllq         $8, %%mm4    \n\t"
-        "psllq        $16, %%mm5    \n\t"
-        "por        %%mm4, %%mm3    \n\t"
-        "por        %%mm5, %%mm3    \n\t"
-        MOVNTQ"     %%mm0, %0       \n\t"
-        MOVNTQ"     %%mm3, 8%0      \n\t"
+        PACK_RGB32
         :"=m"(*d)
         :"m"(*s),"m"(mask16b),"m"(mask16g),"m"(mask16r)
         :"memory");
@@ -1354,7 +1339,7 @@
 
 static inline void RENAME(rgb32tobgr32)(const uint8_t *src, uint8_t *dst, long src_size)
 {
-    long idx = 15 - src_size;
+    x86_reg idx = 15 - src_size;
     const uint8_t *s = src-idx;
     uint8_t *d = dst-idx;
 #if HAVE_MMX
@@ -1420,7 +1405,7 @@
 {
     unsigned i;
 #if HAVE_MMX
-    long mmx_size= 23 - src_size;
+    x86_reg mmx_size= 23 - src_size;
     __asm__ volatile (
     "test             %%"REG_a", %%"REG_a"          \n\t"
     "jns                     2f                     \n\t"
@@ -1491,7 +1476,7 @@
                                            long lumStride, long chromStride, long dstStride, long vertLumPerChroma)
 {
     long y;
-    const long chromWidth= width>>1;
+    const x86_reg chromWidth= width>>1;
     for (y=0; y<height; y++)
     {
 #if HAVE_MMX
@@ -1643,7 +1628,7 @@
                                            long lumStride, long chromStride, long dstStride, long vertLumPerChroma)
 {
     long y;
-    const long chromWidth= width>>1;
+    const x86_reg chromWidth= width>>1;
     for (y=0; y<height; y++)
     {
 #if HAVE_MMX
@@ -1773,7 +1758,7 @@
                                       long lumStride, long chromStride, long srcStride)
 {
     long y;
-    const long chromWidth= width>>1;
+    const x86_reg chromWidth= width>>1;
     for (y=0; y<height; y+=2)
     {
 #if HAVE_MMX
@@ -1915,7 +1900,7 @@
 
     for (y=1; y<srcHeight; y++){
 #if HAVE_MMX2 || HAVE_AMD3DNOW
-        const long mmxSize= srcWidth&~15;
+        const x86_reg mmxSize= srcWidth&~15;
         __asm__ volatile(
         "mov           %4, %%"REG_a"            \n\t"
         "1:                                     \n\t"
@@ -1959,7 +1944,7 @@
 
         );
 #else
-        const long mmxSize=1;
+        const x86_reg mmxSize=1;
 #endif
         dst[0        ]= (3*src[0] +   src[srcStride])>>2;
         dst[dstStride]= (  src[0] + 3*src[srcStride])>>2;
@@ -2011,7 +1996,7 @@
                                       long lumStride, long chromStride, long srcStride)
 {
     long y;
-    const long chromWidth= width>>1;
+    const x86_reg chromWidth= width>>1;
     for (y=0; y<height; y+=2)
     {
 #if HAVE_MMX
@@ -2138,7 +2123,7 @@
                                        long lumStride, long chromStride, long srcStride)
 {
     long y;
-    const long chromWidth= width>>1;
+    const x86_reg chromWidth= width>>1;
 #if HAVE_MMX
     for (y=0; y<height-2; y+=2)
     {
@@ -2211,7 +2196,7 @@
             MOVNTQ"                  %%mm0, (%1, %%"REG_a") \n\t"
             "add                        $8,      %%"REG_a"  \n\t"
             " js                        1b                  \n\t"
-            : : "r" (src+width*3), "r" (ydst+width), "g" (-width)
+            : : "r" (src+width*3), "r" (ydst+width), "g" ((x86_reg)-width)
             : "%"REG_a, "%"REG_d
             );
             ydst += lumStride;
@@ -2455,7 +2440,7 @@
         "add                    $16, %%"REG_a"  \n\t"
         "cmp                     %3, %%"REG_a"  \n\t"
         " jb                     1b             \n\t"
-        ::"r"(dest), "r"(src1), "r"(src2), "r" (width-15)
+        ::"r"(dest), "r"(src1), "r"(src2), "r" ((x86_reg)width-15)
         : "memory", "%"REG_a""
         );
 #else
@@ -2481,7 +2466,7 @@
         "add                    $16, %%"REG_a"  \n\t"
         "cmp                     %3, %%"REG_a"  \n\t"
         " jb                     1b             \n\t"
-        ::"r"(dest), "r"(src1), "r"(src2), "r" (width-15)
+        ::"r"(dest), "r"(src1), "r"(src2), "r" ((x86_reg)width-15)
         : "memory", "%"REG_a
         );
 #endif
@@ -2516,7 +2501,8 @@
                                        long srcStride1, long srcStride2,
                                        long dstStride1, long dstStride2)
 {
-    long y,x,w,h;
+    x86_reg y;
+    long x,w,h;
     w=width/2; h=height/2;
 #if HAVE_MMX
     __asm__ volatile(
@@ -2619,7 +2605,8 @@
                                         long srcStride1, long srcStride2,
                                         long srcStride3, long dstStride)
 {
-    long y,x,w,h;
+    x86_reg x;
+    long y,w,h;
     w=width/2; h=height;
     for (y=0;y<h;y++){
     const uint8_t* yp=src1+srcStride1*y;
@@ -2704,6 +2691,354 @@
 #endif
 }
 
+static void RENAME(extract_even)(const uint8_t *src, uint8_t *dst, x86_reg count)
+{
+    dst +=   count;
+    src += 2*count;
+    count= - count;
+
+#if HAVE_MMX
+    if(count <= -16){
+        count += 15;
+        __asm__ volatile(
+            "pcmpeqw       %%mm7, %%mm7        \n\t"
+            "psrlw            $8, %%mm7        \n\t"
+            "1:                                \n\t"
+            "movq -30(%1, %0, 2), %%mm0        \n\t"
+            "movq -22(%1, %0, 2), %%mm1        \n\t"
+            "movq -14(%1, %0, 2), %%mm2        \n\t"
+            "movq  -6(%1, %0, 2), %%mm3        \n\t"
+            "pand          %%mm7, %%mm0        \n\t"
+            "pand          %%mm7, %%mm1        \n\t"
+            "pand          %%mm7, %%mm2        \n\t"
+            "pand          %%mm7, %%mm3        \n\t"
+            "packuswb      %%mm1, %%mm0        \n\t"
+            "packuswb      %%mm3, %%mm2        \n\t"
+            MOVNTQ"        %%mm0,-15(%2, %0)   \n\t"
+            MOVNTQ"        %%mm2,- 7(%2, %0)   \n\t"
+            "add             $16, %0           \n\t"
+            " js 1b                            \n\t"
+            : "+r"(count)
+            : "r"(src), "r"(dst)
+        );
+        count -= 15;
+    }
+#endif
+    while(count<0){
+        dst[count]= src[2*count];
+        count++;
+    }
+}
+
+static void RENAME(extract_even2)(const uint8_t *src, uint8_t *dst0, uint8_t *dst1, x86_reg count)
+{
+    dst0+=   count;
+    dst1+=   count;
+    src += 4*count;
+    count= - count;
+#if HAVE_MMX
+    if(count <= -8){
+        count += 7;
+        __asm__ volatile(
+            "pcmpeqw       %%mm7, %%mm7        \n\t"
+            "psrlw            $8, %%mm7        \n\t"
+            "1:                                \n\t"
+            "movq -28(%1, %0, 4), %%mm0        \n\t"
+            "movq -20(%1, %0, 4), %%mm1        \n\t"
+            "movq -12(%1, %0, 4), %%mm2        \n\t"
+            "movq  -4(%1, %0, 4), %%mm3        \n\t"
+            "pand          %%mm7, %%mm0        \n\t"
+            "pand          %%mm7, %%mm1        \n\t"
+            "pand          %%mm7, %%mm2        \n\t"
+            "pand          %%mm7, %%mm3        \n\t"
+            "packuswb      %%mm1, %%mm0        \n\t"
+            "packuswb      %%mm3, %%mm2        \n\t"
+            "movq          %%mm0, %%mm1        \n\t"
+            "movq          %%mm2, %%mm3        \n\t"
+            "psrlw            $8, %%mm0        \n\t"
+            "psrlw            $8, %%mm2        \n\t"
+            "pand          %%mm7, %%mm1        \n\t"
+            "pand          %%mm7, %%mm3        \n\t"
+            "packuswb      %%mm2, %%mm0        \n\t"
+            "packuswb      %%mm3, %%mm1        \n\t"
+            MOVNTQ"        %%mm0,- 7(%3, %0)   \n\t"
+            MOVNTQ"        %%mm1,- 7(%2, %0)   \n\t"
+            "add              $8, %0           \n\t"
+            " js 1b                            \n\t"
+            : "+r"(count)
+            : "r"(src), "r"(dst0), "r"(dst1)
+        );
+        count -= 7;
+    }
+#endif
+    while(count<0){
+        dst0[count]= src[4*count+0];
+        dst1[count]= src[4*count+2];
+        count++;
+    }
+}
+
+static void RENAME(extract_even2avg)(const uint8_t *src0, const uint8_t *src1, uint8_t *dst0, uint8_t *dst1, x86_reg count)
+{
+    dst0 +=   count;
+    dst1 +=   count;
+    src0 += 4*count;
+    src1 += 4*count;
+    count= - count;
+#ifdef PAVGB
+    if(count <= -8){
+        count += 7;
+        __asm__ volatile(
+            "pcmpeqw        %%mm7, %%mm7        \n\t"
+            "psrlw             $8, %%mm7        \n\t"
+            "1:                                \n\t"
+            "movq  -28(%1, %0, 4), %%mm0        \n\t"
+            "movq  -20(%1, %0, 4), %%mm1        \n\t"
+            "movq  -12(%1, %0, 4), %%mm2        \n\t"
+            "movq   -4(%1, %0, 4), %%mm3        \n\t"
+            PAVGB" -28(%2, %0, 4), %%mm0        \n\t"
+            PAVGB" -20(%2, %0, 4), %%mm1        \n\t"
+            PAVGB" -12(%2, %0, 4), %%mm2        \n\t"
+            PAVGB" - 4(%2, %0, 4), %%mm3        \n\t"
+            "pand           %%mm7, %%mm0        \n\t"
+            "pand           %%mm7, %%mm1        \n\t"
+            "pand           %%mm7, %%mm2        \n\t"
+            "pand           %%mm7, %%mm3        \n\t"
+            "packuswb       %%mm1, %%mm0        \n\t"
+            "packuswb       %%mm3, %%mm2        \n\t"
+            "movq           %%mm0, %%mm1        \n\t"
+            "movq           %%mm2, %%mm3        \n\t"
+            "psrlw             $8, %%mm0        \n\t"
+            "psrlw             $8, %%mm2        \n\t"
+            "pand           %%mm7, %%mm1        \n\t"
+            "pand           %%mm7, %%mm3        \n\t"
+            "packuswb       %%mm2, %%mm0        \n\t"
+            "packuswb       %%mm3, %%mm1        \n\t"
+            MOVNTQ"         %%mm0,- 7(%4, %0)   \n\t"
+            MOVNTQ"         %%mm1,- 7(%3, %0)   \n\t"
+            "add               $8, %0           \n\t"
+            " js 1b                            \n\t"
+            : "+r"(count)
+            : "r"(src0), "r"(src1), "r"(dst0), "r"(dst1)
+        );
+        count -= 7;
+    }
+#endif
+    while(count<0){
+        dst0[count]= (src0[4*count+0]+src1[4*count+0])>>1;
+        dst1[count]= (src0[4*count+2]+src1[4*count+2])>>1;
+        count++;
+    }
+}
+
+static void RENAME(extract_odd2)(const uint8_t *src, uint8_t *dst0, uint8_t *dst1, x86_reg count)
+{
+    dst0+=   count;
+    dst1+=   count;
+    src += 4*count;
+    count= - count;
+#if HAVE_MMX
+    if(count <= -8){
+        count += 7;
+        __asm__ volatile(
+            "pcmpeqw       %%mm7, %%mm7        \n\t"
+            "psrlw            $8, %%mm7        \n\t"
+            "1:                                \n\t"
+            "movq -28(%1, %0, 4), %%mm0        \n\t"
+            "movq -20(%1, %0, 4), %%mm1        \n\t"
+            "movq -12(%1, %0, 4), %%mm2        \n\t"
+            "movq  -4(%1, %0, 4), %%mm3        \n\t"
+            "psrlw            $8, %%mm0        \n\t"
+            "psrlw            $8, %%mm1        \n\t"
+            "psrlw            $8, %%mm2        \n\t"
+            "psrlw            $8, %%mm3        \n\t"
+            "packuswb      %%mm1, %%mm0        \n\t"
+            "packuswb      %%mm3, %%mm2        \n\t"
+            "movq          %%mm0, %%mm1        \n\t"
+            "movq          %%mm2, %%mm3        \n\t"
+            "psrlw            $8, %%mm0        \n\t"
+            "psrlw            $8, %%mm2        \n\t"
+            "pand          %%mm7, %%mm1        \n\t"
+            "pand          %%mm7, %%mm3        \n\t"
+            "packuswb      %%mm2, %%mm0        \n\t"
+            "packuswb      %%mm3, %%mm1        \n\t"
+            MOVNTQ"        %%mm0,- 7(%3, %0)   \n\t"
+            MOVNTQ"        %%mm1,- 7(%2, %0)   \n\t"
+            "add              $8, %0           \n\t"
+            " js 1b                            \n\t"
+            : "+r"(count)
+            : "r"(src), "r"(dst0), "r"(dst1)
+        );
+        count -= 7;
+    }
+#endif
+    src++;
+    while(count<0){
+        dst0[count]= src[4*count+0];
+        dst1[count]= src[4*count+2];
+        count++;
+    }
+}
+
+static void RENAME(extract_odd2avg)(const uint8_t *src0, const uint8_t *src1, uint8_t *dst0, uint8_t *dst1, x86_reg count)
+{
+    dst0 +=   count;
+    dst1 +=   count;
+    src0 += 4*count;
+    src1 += 4*count;
+    count= - count;
+#ifdef PAVGB
+    if(count <= -8){
+        count += 7;
+        __asm__ volatile(
+            "pcmpeqw        %%mm7, %%mm7        \n\t"
+            "psrlw             $8, %%mm7        \n\t"
+            "1:                                \n\t"
+            "movq  -28(%1, %0, 4), %%mm0        \n\t"
+            "movq  -20(%1, %0, 4), %%mm1        \n\t"
+            "movq  -12(%1, %0, 4), %%mm2        \n\t"
+            "movq   -4(%1, %0, 4), %%mm3        \n\t"
+            PAVGB" -28(%2, %0, 4), %%mm0        \n\t"
+            PAVGB" -20(%2, %0, 4), %%mm1        \n\t"
+            PAVGB" -12(%2, %0, 4), %%mm2        \n\t"
+            PAVGB" - 4(%2, %0, 4), %%mm3        \n\t"
+            "psrlw             $8, %%mm0        \n\t"
+            "psrlw             $8, %%mm1        \n\t"
+            "psrlw             $8, %%mm2        \n\t"
+            "psrlw             $8, %%mm3        \n\t"
+            "packuswb       %%mm1, %%mm0        \n\t"
+            "packuswb       %%mm3, %%mm2        \n\t"
+            "movq           %%mm0, %%mm1        \n\t"
+            "movq           %%mm2, %%mm3        \n\t"
+            "psrlw             $8, %%mm0        \n\t"
+            "psrlw             $8, %%mm2        \n\t"
+            "pand           %%mm7, %%mm1        \n\t"
+            "pand           %%mm7, %%mm3        \n\t"
+            "packuswb       %%mm2, %%mm0        \n\t"
+            "packuswb       %%mm3, %%mm1        \n\t"
+            MOVNTQ"         %%mm0,- 7(%4, %0)   \n\t"
+            MOVNTQ"         %%mm1,- 7(%3, %0)   \n\t"
+            "add               $8, %0           \n\t"
+            " js 1b                            \n\t"
+            : "+r"(count)
+            : "r"(src0), "r"(src1), "r"(dst0), "r"(dst1)
+        );
+        count -= 7;
+    }
+#endif
+    src0++;
+    src1++;
+    while(count<0){
+        dst0[count]= (src0[4*count+0]+src1[4*count+0])>>1;
+        dst1[count]= (src0[4*count+2]+src1[4*count+2])>>1;
+        count++;
+    }
+}
+
+static void RENAME(yuyvtoyuv420)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src,
+                                      long width, long height,
+                                      long lumStride, long chromStride, long srcStride)
+{
+    long y;
+    const long chromWidth= -((-width)>>1);
+
+    for (y=0; y<height; y++){
+        RENAME(extract_even)(src, ydst, width);
+        if(y&1){
+            RENAME(extract_odd2avg)(src-srcStride, src, udst, vdst, chromWidth);
+            udst+= chromStride;
+            vdst+= chromStride;
+        }
+
+        src += srcStride;
+        ydst+= lumStride;
+    }
+#if HAVE_MMX
+    __asm__(
+        EMMS"       \n\t"
+        SFENCE"     \n\t"
+        ::: "memory"
+        );
+#endif
+}
+
+static void RENAME(yuyvtoyuv422)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src,
+                                      long width, long height,
+                                      long lumStride, long chromStride, long srcStride)
+{
+    long y;
+    const long chromWidth= -((-width)>>1);
+
+    for (y=0; y<height; y++){
+        RENAME(extract_even)(src, ydst, width);
+        RENAME(extract_odd2)(src, udst, vdst, chromWidth);
+
+        src += srcStride;
+        ydst+= lumStride;
+        udst+= chromStride;
+        vdst+= chromStride;
+    }
+#if HAVE_MMX
+    __asm__(
+        EMMS"       \n\t"
+        SFENCE"     \n\t"
+        ::: "memory"
+        );
+#endif
+}
+
+static void RENAME(uyvytoyuv420)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src,
+                                      long width, long height,
+                                      long lumStride, long chromStride, long srcStride)
+{
+    long y;
+    const long chromWidth= -((-width)>>1);
+
+    for (y=0; y<height; y++){
+        RENAME(extract_even)(src+1, ydst, width);
+        if(y&1){
+            RENAME(extract_even2avg)(src-srcStride, src, udst, vdst, chromWidth);
+            udst+= chromStride;
+            vdst+= chromStride;
+        }
+
+        src += srcStride;
+        ydst+= lumStride;
+    }
+#if HAVE_MMX
+    __asm__(
+        EMMS"       \n\t"
+        SFENCE"     \n\t"
+        ::: "memory"
+        );
+#endif
+}
+
+static void RENAME(uyvytoyuv422)(uint8_t *ydst, uint8_t *udst, uint8_t *vdst, const uint8_t *src,
+                                      long width, long height,
+                                      long lumStride, long chromStride, long srcStride)
+{
+    long y;
+    const long chromWidth= -((-width)>>1);
+
+    for (y=0; y<height; y++){
+        RENAME(extract_even)(src+1, ydst, width);
+        RENAME(extract_even2)(src, udst, vdst, chromWidth);
+
+        src += srcStride;
+        ydst+= lumStride;
+        udst+= chromStride;
+        vdst+= chromStride;
+    }
+#if HAVE_MMX
+    __asm__(
+        EMMS"       \n\t"
+        SFENCE"     \n\t"
+        ::: "memory"
+        );
+#endif
+}
+
 static inline void RENAME(rgb2rgb_init)(void){
     rgb15to16       = RENAME(rgb15to16);
     rgb15tobgr24    = RENAME(rgb15tobgr24);
@@ -2728,11 +3063,15 @@
     yuv422ptoyuy2   = RENAME(yuv422ptoyuy2);
     yuv422ptouyvy   = RENAME(yuv422ptouyvy);
     yuy2toyv12      = RENAME(yuy2toyv12);
-//    uyvytoyv12      = RENAME(uyvytoyv12);
 //    yvu9toyv12      = RENAME(yvu9toyv12);
     planar2x        = RENAME(planar2x);
     rgb24toyv12     = RENAME(rgb24toyv12);
     interleaveBytes = RENAME(interleaveBytes);
     vu9_to_vu12     = RENAME(vu9_to_vu12);
     yvu9_to_yuy2    = RENAME(yvu9_to_yuy2);
+
+    uyvytoyuv420    = RENAME(uyvytoyuv420);
+    uyvytoyuv422    = RENAME(uyvytoyuv422);
+    yuyvtoyuv420    = RENAME(yuyvtoyuv420);
+    yuyvtoyuv422    = RENAME(yuyvtoyuv422);
 }
diff --git a/libswscale/yuv2rgb_vis.c b/libswscale/sparc/yuv2rgb_vis.c
similarity index 98%
rename from libswscale/yuv2rgb_vis.c
rename to libswscale/sparc/yuv2rgb_vis.c
index 2e2737a..cdbe140 100644
--- a/libswscale/yuv2rgb_vis.c
+++ b/libswscale/sparc/yuv2rgb_vis.c
@@ -22,8 +22,8 @@
 #include <inttypes.h>
 #include <stdlib.h>
 
-#include "swscale.h"
-#include "swscale_internal.h"
+#include "libswscale/swscale.h"
+#include "libswscale/swscale_internal.h"
 
 #define YUV2RGB_INIT \
     "wr %%g0, 0x10, %%gsr \n\t" \
@@ -184,7 +184,7 @@
   return srcSliceH;
 }
 
-SwsFunc sws_yuv2rgb_init_vis(SwsContext *c) {
+SwsFunc ff_yuv2rgb_init_vis(SwsContext *c){
     c->sparc_coeffs[5]=c->yCoeff;
     c->sparc_coeffs[6]=c->vgCoeff;
     c->sparc_coeffs[7]=c->vrCoeff;
diff --git a/libswscale/swscale-example.c b/libswscale/swscale-example.c
index 87b9ba0..e89930f 100644
--- a/libswscale/swscale-example.c
+++ b/libswscale/swscale-example.c
@@ -26,6 +26,7 @@
 
 #undef HAVE_AV_CONFIG_H
 #include "libavutil/avutil.h"
+#include "libavutil/lfg.h"
 #include "swscale.h"
 #include "swscale_internal.h"
 
@@ -48,19 +49,20 @@
 
 // test by ref -> src -> dst -> out & compare out against ref
 // ref & out are YV12
-static int doTest(uint8_t *ref[3], int refStride[3], int w, int h, int srcFormat, int dstFormat,
+static int doTest(uint8_t *ref[4], int refStride[4], int w, int h, int srcFormat, int dstFormat,
                   int srcW, int srcH, int dstW, int dstH, int flags){
-    uint8_t *src[3];
-    uint8_t *dst[3];
-    uint8_t *out[3];
-    int srcStride[3], dstStride[3];
+    uint8_t *src[4] = {0};
+    uint8_t *dst[4] = {0};
+    uint8_t *out[4] = {0};
+    int srcStride[4], dstStride[4];
     int i;
-    uint64_t ssdY, ssdU, ssdV;
-    struct SwsContext *srcContext, *dstContext, *outContext;
+    uint64_t ssdY, ssdU, ssdV, ssdA=0;
+    struct SwsContext *srcContext = NULL, *dstContext = NULL,
+                      *outContext = NULL;
     int res;
 
     res = 0;
-    for (i=0; i<3; i++){
+    for (i=0; i<4; i++){
         // avoid stride % bpp != 0
         if (srcFormat==PIX_FMT_RGB24 || srcFormat==PIX_FMT_BGR24)
             srcStride[i]= srcW*3;
@@ -83,11 +85,10 @@
         }
     }
 
-    dstContext = outContext = NULL;
-    srcContext= sws_getContext(w, h, PIX_FMT_YUV420P, srcW, srcH, srcFormat, flags, NULL, NULL, NULL);
+    srcContext= sws_getContext(w, h, PIX_FMT_YUVA420P, srcW, srcH, srcFormat, flags, NULL, NULL, NULL);
     if (!srcContext) {
         fprintf(stderr, "Failed to get %s ---> %s\n",
-                sws_format_name(PIX_FMT_YUV420P),
+                sws_format_name(PIX_FMT_YUVA420P),
                 sws_format_name(srcFormat));
         res = -1;
 
@@ -102,11 +103,11 @@
 
         goto end;
     }
-    outContext= sws_getContext(dstW, dstH, dstFormat, w, h, PIX_FMT_YUV420P, flags, NULL, NULL, NULL);
+    outContext= sws_getContext(dstW, dstH, dstFormat, w, h, PIX_FMT_YUVA420P, flags, NULL, NULL, NULL);
     if (!outContext) {
         fprintf(stderr, "Failed to get %s ---> %s\n",
                 sws_format_name(dstFormat),
-                sws_format_name(PIX_FMT_YUV420P));
+                sws_format_name(PIX_FMT_YUVA420P));
         res = -1;
 
         goto end;
@@ -121,17 +122,20 @@
     ssdY= getSSD(ref[0], out[0], refStride[0], refStride[0], w, h);
     ssdU= getSSD(ref[1], out[1], refStride[1], refStride[1], (w+1)>>1, (h+1)>>1);
     ssdV= getSSD(ref[2], out[2], refStride[2], refStride[2], (w+1)>>1, (h+1)>>1);
+    if (isALPHA(srcFormat) && isALPHA(dstFormat))
+        ssdA= getSSD(ref[3], out[3], refStride[3], refStride[3], w, h);
 
     if (srcFormat == PIX_FMT_GRAY8 || dstFormat==PIX_FMT_GRAY8) ssdU=ssdV=0; //FIXME check that output is really gray
 
     ssdY/= w*h;
     ssdU/= w*h/4;
     ssdV/= w*h/4;
+    ssdA/= w*h;
 
-    printf(" %s %dx%d -> %s %4dx%4d flags=%2d SSD=%5lld,%5lld,%5lld\n",
+    printf(" %s %dx%d -> %s %4dx%4d flags=%2d SSD=%5lld,%5lld,%5lld,%5lld\n",
            sws_format_name(srcFormat), srcW, srcH,
            sws_format_name(dstFormat), dstW, dstH,
-           flags, ssdY, ssdU, ssdV);
+           flags, ssdY, ssdU, ssdV, ssdA);
     fflush(stdout);
 
     end:
@@ -140,7 +144,7 @@
     sws_freeContext(dstContext);
     sws_freeContext(outContext);
 
-    for (i=0; i<3; i++){
+    for (i=0; i<4; i++){
         free(src[i]);
         free(dst[i]);
         free(out[i]);
@@ -149,7 +153,7 @@
     return res;
 }
 
-static void selfTest(uint8_t *src[3], int stride[3], int w, int h){
+static void selfTest(uint8_t *src[4], int stride[4], int w, int h){
     enum PixelFormat srcFormat, dstFormat;
     int srcW, srcH, dstW, dstH;
     int flags;
@@ -189,17 +193,20 @@
     uint8_t *rgb_data = malloc (W*H*4);
     uint8_t *rgb_src[3]= {rgb_data, NULL, NULL};
     int rgb_stride[3]={4*W, 0, 0};
-    uint8_t *data = malloc (3*W*H);
-    uint8_t *src[3]= {data, data+W*H, data+W*H*2};
-    int stride[3]={W, W, W};
+    uint8_t *data = malloc (4*W*H);
+    uint8_t *src[4]= {data, data+W*H, data+W*H*2, data+W*H*3};
+    int stride[4]={W, W, W, W};
     int x, y;
     struct SwsContext *sws;
+    AVLFG rand;
 
-    sws= sws_getContext(W/12, H/12, PIX_FMT_RGB32, W, H, PIX_FMT_YUV420P, 2, NULL, NULL, NULL);
+    sws= sws_getContext(W/12, H/12, PIX_FMT_RGB32, W, H, PIX_FMT_YUVA420P, 2, NULL, NULL, NULL);
+
+    av_lfg_init(&rand, 1);
 
     for (y=0; y<H; y++){
         for (x=0; x<W*4; x++){
-            rgb_data[ x + y*4*W]= random();
+            rgb_data[ x + y*4*W]= av_lfg_get(&rand);
         }
     }
     sws_scale(sws, rgb_src, rgb_stride, 0, H, src, stride);
diff --git a/libswscale/swscale.c b/libswscale/swscale.c
index dd8f27a..316f451 100644
--- a/libswscale/swscale.c
+++ b/libswscale/swscale.c
@@ -68,6 +68,10 @@
 #define MAP_ANONYMOUS MAP_ANON
 #endif
 #endif
+#if HAVE_VIRTUALALLOC
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#endif
 #include "swscale.h"
 #include "swscale_internal.h"
 #include "rgb2rgb.h"
@@ -133,6 +137,7 @@
     )
 #define isSupportedOut(x)   (       \
            (x)==PIX_FMT_YUV420P     \
+        || (x)==PIX_FMT_YUVA420P    \
         || (x)==PIX_FMT_YUYV422     \
         || (x)==PIX_FMT_UYVY422     \
         || (x)==PIX_FMT_YUV444P     \
@@ -469,7 +474,7 @@
 
 static inline void yuv2yuvXinC(int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize,
                                int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,
-                               uint8_t *dest, uint8_t *uDest, uint8_t *vDest, int dstW, int chrDstW)
+                               int16_t **alpSrc, uint8_t *dest, uint8_t *uDest, uint8_t *vDest, uint8_t *aDest, int dstW, int chrDstW)
 {
     //FIXME Optimize (just quickly written not optimized..)
     int i;
@@ -498,6 +503,17 @@
             uDest[i]= av_clip_uint8(u>>19);
             vDest[i]= av_clip_uint8(v>>19);
         }
+
+    if (CONFIG_SWSCALE_ALPHA && aDest)
+        for (i=0; i<dstW; i++){
+            int val=1<<18;
+            int j;
+            for (j=0; j<lumFilterSize; j++)
+                val += alpSrc[j][i] * lumFilter[j];
+
+            aDest[i]= av_clip_uint8(val>>19);
+        }
+
 }
 
 static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize,
@@ -551,13 +567,14 @@
         }
 }
 
-#define YSCALE_YUV_2_PACKEDX_NOCLIP_C(type) \
+#define YSCALE_YUV_2_PACKEDX_NOCLIP_C(type,alpha) \
     for (i=0; i<(dstW>>1); i++){\
         int j;\
         int Y1 = 1<<18;\
         int Y2 = 1<<18;\
         int U  = 1<<18;\
         int V  = 1<<18;\
+        int av_unused A1, A2;\
         type av_unused *r, *b, *g;\
         const int i2= 2*i;\
         \
@@ -575,9 +592,19 @@
         Y2>>=19;\
         U >>=19;\
         V >>=19;\
+        if (alpha){\
+            A1 = 1<<18;\
+            A2 = 1<<18;\
+            for (j=0; j<lumFilterSize; j++){\
+                A1 += alpSrc[j][i2  ] * lumFilter[j];\
+                A2 += alpSrc[j][i2+1] * lumFilter[j];\
+            }\
+            A1>>=19;\
+            A2>>=19;\
+        }\
 
-#define YSCALE_YUV_2_PACKEDX_C(type) \
-        YSCALE_YUV_2_PACKEDX_NOCLIP_C(type)\
+#define YSCALE_YUV_2_PACKEDX_C(type,alpha) \
+        YSCALE_YUV_2_PACKEDX_NOCLIP_C(type,alpha)\
         if ((Y1|Y2|U|V)&256)\
         {\
             if (Y1>255)   Y1=255; \
@@ -588,14 +615,19 @@
             else if (U<0) U=0;    \
             if (V>255)    V=255;  \
             else if (V<0) V=0;    \
+        }\
+        if (alpha && ((A1|A2)&256)){\
+            A1=av_clip_uint8(A1);\
+            A2=av_clip_uint8(A2);\
         }
 
-#define YSCALE_YUV_2_PACKEDX_FULL_C \
+#define YSCALE_YUV_2_PACKEDX_FULL_C(rnd,alpha) \
     for (i=0; i<dstW; i++){\
         int j;\
         int Y = 0;\
         int U = -128<<19;\
         int V = -128<<19;\
+        int av_unused A;\
         int R,G,B;\
         \
         for (j=0; j<lumFilterSize; j++){\
@@ -608,9 +640,17 @@
         Y >>=10;\
         U >>=10;\
         V >>=10;\
+        if (alpha){\
+            A = rnd;\
+            for (j=0; j<lumFilterSize; j++)\
+                A += alpSrc[j][i     ] * lumFilter[j];\
+            A >>=19;\
+            if (A&256)\
+                A = av_clip_uint8(A);\
+        }\
 
-#define YSCALE_YUV_2_RGBX_FULL_C(rnd) \
-    YSCALE_YUV_2_PACKEDX_FULL_C\
+#define YSCALE_YUV_2_RGBX_FULL_C(rnd,alpha) \
+    YSCALE_YUV_2_PACKEDX_FULL_C(rnd>>3,alpha)\
         Y-= c->yuv2rgb_y_offset;\
         Y*= c->yuv2rgb_y_coeff;\
         Y+= rnd;\
@@ -652,19 +692,25 @@
             else if (Y2<0)Y2=0;   \
         }
 
-#define YSCALE_YUV_2_RGBX_C(type) \
-    YSCALE_YUV_2_PACKEDX_C(type)  /* FIXME fix tables so that clipping is not needed and then use _NOCLIP*/\
+#define YSCALE_YUV_2_RGBX_C(type,alpha) \
+    YSCALE_YUV_2_PACKEDX_C(type,alpha)  /* FIXME fix tables so that clipping is not needed and then use _NOCLIP*/\
     r = (type *)c->table_rV[V];   \
     g = (type *)(c->table_gU[U] + c->table_gV[V]); \
     b = (type *)c->table_bU[U];   \
 
-#define YSCALE_YUV_2_PACKED2_C   \
+#define YSCALE_YUV_2_PACKED2_C(type,alpha)   \
     for (i=0; i<(dstW>>1); i++){ \
         const int i2= 2*i;       \
         int Y1= (buf0[i2  ]*yalpha1+buf1[i2  ]*yalpha)>>19;           \
         int Y2= (buf0[i2+1]*yalpha1+buf1[i2+1]*yalpha)>>19;           \
         int U= (uvbuf0[i     ]*uvalpha1+uvbuf1[i     ]*uvalpha)>>19;  \
         int V= (uvbuf0[i+VOFW]*uvalpha1+uvbuf1[i+VOFW]*uvalpha)>>19;  \
+        type av_unused *r, *b, *g;                                    \
+        int av_unused A1, A2;                                         \
+        if (alpha){\
+            A1= (abuf0[i2  ]*yalpha1+abuf1[i2  ]*yalpha)>>19;         \
+            A2= (abuf0[i2+1]*yalpha1+abuf1[i2+1]*yalpha)>>19;         \
+        }\
 
 #define YSCALE_YUV_2_GRAY16_2_C   \
     for (i=0; i<(dstW>>1); i++){ \
@@ -672,20 +718,25 @@
         int Y1= (buf0[i2  ]*yalpha1+buf1[i2  ]*yalpha)>>11;           \
         int Y2= (buf0[i2+1]*yalpha1+buf1[i2+1]*yalpha)>>11;           \
 
-#define YSCALE_YUV_2_RGB2_C(type) \
-    YSCALE_YUV_2_PACKED2_C\
-    type *r, *b, *g;\
+#define YSCALE_YUV_2_RGB2_C(type,alpha) \
+    YSCALE_YUV_2_PACKED2_C(type,alpha)\
     r = (type *)c->table_rV[V];\
     g = (type *)(c->table_gU[U] + c->table_gV[V]);\
     b = (type *)c->table_bU[U];\
 
-#define YSCALE_YUV_2_PACKED1_C \
+#define YSCALE_YUV_2_PACKED1_C(type,alpha) \
     for (i=0; i<(dstW>>1); i++){\
         const int i2= 2*i;\
         int Y1= buf0[i2  ]>>7;\
         int Y2= buf0[i2+1]>>7;\
         int U= (uvbuf1[i     ])>>7;\
         int V= (uvbuf1[i+VOFW])>>7;\
+        type av_unused *r, *b, *g;\
+        int av_unused A1, A2;\
+        if (alpha){\
+            A1= abuf0[i2  ]>>7;\
+            A2= abuf0[i2+1]>>7;\
+        }\
 
 #define YSCALE_YUV_2_GRAY16_1_C \
     for (i=0; i<(dstW>>1); i++){\
@@ -693,24 +744,28 @@
         int Y1= buf0[i2  ]<<1;\
         int Y2= buf0[i2+1]<<1;\
 
-#define YSCALE_YUV_2_RGB1_C(type) \
-    YSCALE_YUV_2_PACKED1_C\
-    type *r, *b, *g;\
+#define YSCALE_YUV_2_RGB1_C(type,alpha) \
+    YSCALE_YUV_2_PACKED1_C(type,alpha)\
     r = (type *)c->table_rV[V];\
     g = (type *)(c->table_gU[U] + c->table_gV[V]);\
     b = (type *)c->table_bU[U];\
 
-#define YSCALE_YUV_2_PACKED1B_C \
+#define YSCALE_YUV_2_PACKED1B_C(type,alpha) \
     for (i=0; i<(dstW>>1); i++){\
         const int i2= 2*i;\
         int Y1= buf0[i2  ]>>7;\
         int Y2= buf0[i2+1]>>7;\
         int U= (uvbuf0[i     ] + uvbuf1[i     ])>>8;\
         int V= (uvbuf0[i+VOFW] + uvbuf1[i+VOFW])>>8;\
+        type av_unused *r, *b, *g;\
+        int av_unused A1, A2;\
+        if (alpha){\
+            A1= abuf0[i2  ]>>7;\
+            A2= abuf0[i2+1]>>7;\
+        }\
 
-#define YSCALE_YUV_2_RGB1B_C(type) \
-    YSCALE_YUV_2_PACKED1B_C\
-    type *r, *b, *g;\
+#define YSCALE_YUV_2_RGB1B_C(type,alpha) \
+    YSCALE_YUV_2_PACKED1B_C(type,alpha)\
     r = (type *)c->table_rV[V];\
     g = (type *)(c->table_gU[U] + c->table_gV[V]);\
     b = (type *)c->table_bU[U];\
@@ -768,17 +823,52 @@
 #define YSCALE_YUV_2_ANYRGB_C(func, func2, func_g16, func_monoblack)\
     switch(c->dstFormat)\
     {\
-    case PIX_FMT_RGB32:\
-    case PIX_FMT_BGR32:\
-    case PIX_FMT_RGB32_1:\
-    case PIX_FMT_BGR32_1:\
-        func(uint32_t)\
-            ((uint32_t*)dest)[i2+0]= r[Y1] + g[Y1] + b[Y1];\
-            ((uint32_t*)dest)[i2+1]= r[Y2] + g[Y2] + b[Y2];\
+    case PIX_FMT_RGBA:\
+    case PIX_FMT_BGRA:\
+        if (CONFIG_SMALL){\
+            int needAlpha = CONFIG_SWSCALE_ALPHA && c->alpPixBuf;\
+            func(uint32_t,needAlpha)\
+                ((uint32_t*)dest)[i2+0]= r[Y1] + g[Y1] + b[Y1] + (needAlpha ? (A1<<24) : 0);\
+                ((uint32_t*)dest)[i2+1]= r[Y2] + g[Y2] + b[Y2] + (needAlpha ? (A2<<24) : 0);\
+            }\
+        }else{\
+            if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf){\
+                func(uint32_t,1)\
+                    ((uint32_t*)dest)[i2+0]= r[Y1] + g[Y1] + b[Y1] + (A1<<24);\
+                    ((uint32_t*)dest)[i2+1]= r[Y2] + g[Y2] + b[Y2] + (A2<<24);\
+                }\
+            }else{\
+                func(uint32_t,0)\
+                    ((uint32_t*)dest)[i2+0]= r[Y1] + g[Y1] + b[Y1];\
+                    ((uint32_t*)dest)[i2+1]= r[Y2] + g[Y2] + b[Y2];\
+                }\
+            }\
+        }\
+        break;\
+    case PIX_FMT_ARGB:\
+    case PIX_FMT_ABGR:\
+        if (CONFIG_SMALL){\
+            int needAlpha = CONFIG_SWSCALE_ALPHA && c->alpPixBuf;\
+            func(uint32_t,needAlpha)\
+                ((uint32_t*)dest)[i2+0]= r[Y1] + g[Y1] + b[Y1] + (needAlpha ? A1 : 0);\
+                ((uint32_t*)dest)[i2+1]= r[Y2] + g[Y2] + b[Y2] + (needAlpha ? A2 : 0);\
+            }\
+        }else{\
+            if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf){\
+                func(uint32_t,1)\
+                    ((uint32_t*)dest)[i2+0]= r[Y1] + g[Y1] + b[Y1] + A1;\
+                    ((uint32_t*)dest)[i2+1]= r[Y2] + g[Y2] + b[Y2] + A2;\
+                }\
+            }else{\
+                func(uint32_t,0)\
+                    ((uint32_t*)dest)[i2+0]= r[Y1] + g[Y1] + b[Y1];\
+                    ((uint32_t*)dest)[i2+1]= r[Y2] + g[Y2] + b[Y2];\
+                }\
+            }\
         }                \
         break;\
     case PIX_FMT_RGB24:\
-        func(uint8_t)\
+        func(uint8_t,0)\
             ((uint8_t*)dest)[0]= r[Y1];\
             ((uint8_t*)dest)[1]= g[Y1];\
             ((uint8_t*)dest)[2]= b[Y1];\
@@ -789,7 +879,7 @@
         }\
         break;\
     case PIX_FMT_BGR24:\
-        func(uint8_t)\
+        func(uint8_t,0)\
             ((uint8_t*)dest)[0]= b[Y1];\
             ((uint8_t*)dest)[1]= g[Y1];\
             ((uint8_t*)dest)[2]= r[Y1];\
@@ -808,7 +898,7 @@
             const int dr2= dither_2x2_8[y&1    ][1];\
             const int dg2= dither_2x2_4[y&1    ][1];\
             const int db2= dither_2x2_8[(y&1)^1][1];\
-            func(uint16_t)\
+            func(uint16_t,0)\
                 ((uint16_t*)dest)[i2+0]= r[Y1+dr1] + g[Y1+dg1] + b[Y1+db1];\
                 ((uint16_t*)dest)[i2+1]= r[Y2+dr2] + g[Y2+dg2] + b[Y2+db2];\
             }\
@@ -823,7 +913,7 @@
             const int dr2= dither_2x2_8[y&1    ][1];\
             const int dg2= dither_2x2_8[y&1    ][0];\
             const int db2= dither_2x2_8[(y&1)^1][1];\
-            func(uint16_t)\
+            func(uint16_t,0)\
                 ((uint16_t*)dest)[i2+0]= r[Y1+dr1] + g[Y1+dg1] + b[Y1+db1];\
                 ((uint16_t*)dest)[i2+1]= r[Y2+dr2] + g[Y2+dg2] + b[Y2+db2];\
             }\
@@ -834,7 +924,7 @@
         {\
             const uint8_t * const d64= dither_8x8_73[y&7];\
             const uint8_t * const d32= dither_8x8_32[y&7];\
-            func(uint8_t)\
+            func(uint8_t,0)\
                 ((uint8_t*)dest)[i2+0]= r[Y1+d32[(i2+0)&7]] + g[Y1+d32[(i2+0)&7]] + b[Y1+d64[(i2+0)&7]];\
                 ((uint8_t*)dest)[i2+1]= r[Y2+d32[(i2+1)&7]] + g[Y2+d32[(i2+1)&7]] + b[Y2+d64[(i2+1)&7]];\
             }\
@@ -845,7 +935,7 @@
         {\
             const uint8_t * const d64= dither_8x8_73 [y&7];\
             const uint8_t * const d128=dither_8x8_220[y&7];\
-            func(uint8_t)\
+            func(uint8_t,0)\
                 ((uint8_t*)dest)[i]= r[Y1+d128[(i2+0)&7]] + g[Y1+d64[(i2+0)&7]] + b[Y1+d128[(i2+0)&7]]\
                                  + ((r[Y2+d128[(i2+1)&7]] + g[Y2+d64[(i2+1)&7]] + b[Y2+d128[(i2+1)&7]])<<4);\
             }\
@@ -856,7 +946,7 @@
         {\
             const uint8_t * const d64= dither_8x8_73 [y&7];\
             const uint8_t * const d128=dither_8x8_220[y&7];\
-            func(uint8_t)\
+            func(uint8_t,0)\
                 ((uint8_t*)dest)[i2+0]= r[Y1+d128[(i2+0)&7]] + g[Y1+d64[(i2+0)&7]] + b[Y1+d128[(i2+0)&7]];\
                 ((uint8_t*)dest)[i2+1]= r[Y2+d128[(i2+1)&7]] + g[Y2+d64[(i2+1)&7]] + b[Y2+d128[(i2+1)&7]];\
             }\
@@ -905,15 +995,15 @@
 
 static inline void yuv2packedXinC(SwsContext *c, int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize,
                                   int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,
-                                  uint8_t *dest, int dstW, int y)
+                                  int16_t **alpSrc, uint8_t *dest, int dstW, int y)
 {
     int i;
-    YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGBX_C, YSCALE_YUV_2_PACKEDX_C(void), YSCALE_YUV_2_GRAY16_C, YSCALE_YUV_2_MONOX_C)
+    YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGBX_C, YSCALE_YUV_2_PACKEDX_C(void,0), YSCALE_YUV_2_GRAY16_C, YSCALE_YUV_2_MONOX_C)
 }
 
 static inline void yuv2rgbXinC_full(SwsContext *c, int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize,
                                     int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,
-                                    uint8_t *dest, int dstW, int y)
+                                    int16_t **alpSrc, uint8_t *dest, int dstW, int y)
 {
     int i;
     int step= fmt_depth(c->dstFormat)/8;
@@ -922,30 +1012,72 @@
     switch(c->dstFormat){
     case PIX_FMT_ARGB:
         dest++;
-        aidx= -1;
+        aidx= 0;
     case PIX_FMT_RGB24:
         aidx--;
     case PIX_FMT_RGBA:
-        YSCALE_YUV_2_RGBX_FULL_C(1<<21)
-            dest[aidx]= 255;
-            dest[0]= R>>22;
-            dest[1]= G>>22;
-            dest[2]= B>>22;
-            dest+= step;
+        if (CONFIG_SMALL){
+            int needAlpha = CONFIG_SWSCALE_ALPHA && c->alpPixBuf;
+            YSCALE_YUV_2_RGBX_FULL_C(1<<21, needAlpha)
+                dest[aidx]= needAlpha ? A : 255;
+                dest[0]= R>>22;
+                dest[1]= G>>22;
+                dest[2]= B>>22;
+                dest+= step;
+            }
+        }else{
+            if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf){
+                YSCALE_YUV_2_RGBX_FULL_C(1<<21, 1)
+                    dest[aidx]= A;
+                    dest[0]= R>>22;
+                    dest[1]= G>>22;
+                    dest[2]= B>>22;
+                    dest+= step;
+                }
+            }else{
+                YSCALE_YUV_2_RGBX_FULL_C(1<<21, 0)
+                    dest[aidx]= 255;
+                    dest[0]= R>>22;
+                    dest[1]= G>>22;
+                    dest[2]= B>>22;
+                    dest+= step;
+                }
+            }
         }
         break;
     case PIX_FMT_ABGR:
         dest++;
-        aidx= -1;
+        aidx= 0;
     case PIX_FMT_BGR24:
         aidx--;
     case PIX_FMT_BGRA:
-        YSCALE_YUV_2_RGBX_FULL_C(1<<21)
-            dest[aidx]= 255;
-            dest[0]= B>>22;
-            dest[1]= G>>22;
-            dest[2]= R>>22;
-            dest+= step;
+        if (CONFIG_SMALL){
+            int needAlpha = CONFIG_SWSCALE_ALPHA && c->alpPixBuf;
+            YSCALE_YUV_2_RGBX_FULL_C(1<<21, needAlpha)
+                dest[aidx]= needAlpha ? A : 255;
+                dest[0]= B>>22;
+                dest[1]= G>>22;
+                dest[2]= R>>22;
+                dest+= step;
+            }
+        }else{
+            if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf){
+                YSCALE_YUV_2_RGBX_FULL_C(1<<21, 1)
+                    dest[aidx]= A;
+                    dest[0]= B>>22;
+                    dest[1]= G>>22;
+                    dest[2]= R>>22;
+                    dest+= step;
+                }
+            }else{
+                YSCALE_YUV_2_RGBX_FULL_C(1<<21, 0)
+                    dest[aidx]= 255;
+                    dest[0]= B>>22;
+                    dest[1]= G>>22;
+                    dest[2]= R>>22;
+                    dest+= step;
+                }
+            }
         }
         break;
     default:
@@ -953,29 +1085,39 @@
     }
 }
 
+static void fillPlane(uint8_t* plane, int stride, int width, int height, int y, uint8_t val){
+    int i;
+    uint8_t *ptr = plane + stride*y;
+    for (i=0; i<height; i++){
+        memset(ptr, val, width);
+        ptr += stride;
+    }
+}
+
 //Note: we have C, X86, MMX, MMX2, 3DNOW versions, there is no 3DNOW+MMX2 one
 //Plain C versions
-#if ((!HAVE_MMX || !CONFIG_GPL) && !HAVE_ALTIVEC) || CONFIG_RUNTIME_CPUDETECT
+#if !HAVE_MMX || defined (RUNTIME_CPUDETECT) || !CONFIG_GPL
 #define COMPILE_C
 #endif
 
 #if ARCH_PPC
-#if HAVE_ALTIVEC
+#if (HAVE_ALTIVEC || defined (RUNTIME_CPUDETECT)) && CONFIG_GPL
+#undef COMPILE_C
 #define COMPILE_ALTIVEC
 #endif
 #endif //ARCH_PPC
 
 #if ARCH_X86
 
-#if ((HAVE_MMX && !HAVE_AMD3DNOW && !HAVE_MMX2) || CONFIG_RUNTIME_CPUDETECT) && CONFIG_GPL
+#if ((HAVE_MMX && !HAVE_AMD3DNOW && !HAVE_MMX2) || defined (RUNTIME_CPUDETECT)) && CONFIG_GPL
 #define COMPILE_MMX
 #endif
 
-#if (HAVE_MMX2 || CONFIG_RUNTIME_CPUDETECT) && CONFIG_GPL
+#if (HAVE_MMX2 || defined (RUNTIME_CPUDETECT)) && CONFIG_GPL
 #define COMPILE_MMX2
 #endif
 
-#if ((HAVE_AMD3DNOW && !HAVE_MMX2) || CONFIG_RUNTIME_CPUDETECT) && CONFIG_GPL
+#if ((HAVE_AMD3DNOW && !HAVE_MMX2) || defined (RUNTIME_CPUDETECT)) && CONFIG_GPL
 #define COMPILE_3DNOW
 #endif
 #endif //ARCH_X86
@@ -1456,13 +1598,13 @@
 static void initMMX2HScaler(int dstW, int xInc, uint8_t *funnyCode, int16_t *filter, int32_t *filterPos, int numSplits)
 {
     uint8_t *fragmentA;
-    long imm8OfPShufW1A;
-    long imm8OfPShufW2A;
-    long fragmentLengthA;
+    x86_reg imm8OfPShufW1A;
+    x86_reg imm8OfPShufW2A;
+    x86_reg fragmentLengthA;
     uint8_t *fragmentB;
-    long imm8OfPShufW1B;
-    long imm8OfPShufW2B;
-    long fragmentLengthB;
+    x86_reg imm8OfPShufW1B;
+    x86_reg imm8OfPShufW2B;
+    x86_reg fragmentLengthB;
     int fragmentPos;
 
     int xpos, i;
@@ -1621,7 +1763,7 @@
         }
         xpos+=xInc;
     }
-    filterPos[i/2]= xpos>>16; // needed to jump to the next part
+    filterPos[((i/2)+1)&(~1)]= xpos>>16; // needed to jump to the next part
 }
 #endif /* COMPILE_MMX2 */
 
@@ -1636,8 +1778,8 @@
 
 static SwsFunc getSwsFunc(int flags){
 
-#if CONFIG_RUNTIME_CPUDETECT
-#if ARCH_X86 && CONFIG_GPL
+#if defined(RUNTIME_CPUDETECT) && CONFIG_GPL
+#if ARCH_X86
     // ordered per speed fastest first
     if (flags & SWS_CPU_CAPS_MMX2)
         return swScale_MMX2;
@@ -1649,15 +1791,15 @@
         return swScale_C;
 
 #else
-#if ARCH_PPC && defined COMPILE_ALTIVEC
+#if ARCH_PPC
     if (flags & SWS_CPU_CAPS_ALTIVEC)
         return swScale_altivec;
     else
         return swScale_C;
 #endif
     return swScale_C;
-#endif /* ARCH_X86 && CONFIG_GPL */
-#else //CONFIG_RUNTIME_CPUDETECT
+#endif /* ARCH_X86 */
+#else //RUNTIME_CPUDETECT
 #if   HAVE_MMX2
     return swScale_MMX2;
 #elif HAVE_AMD3DNOW
@@ -1669,7 +1811,7 @@
 #else
     return swScale_C;
 #endif
-#endif //!CONFIG_RUNTIME_CPUDETECT
+#endif //!RUNTIME_CPUDETECT
 }
 
 static int PlanarToNV12Wrapper(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
@@ -1735,6 +1877,56 @@
     return srcSliceH;
 }
 
+static int YUYV2YUV420Wrapper(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
+                               int srcSliceH, uint8_t* dstParam[], int dstStride[]){
+    uint8_t *ydst=dstParam[0] + dstStride[0]*srcSliceY;
+    uint8_t *udst=dstParam[1] + dstStride[1]*srcSliceY/2;
+    uint8_t *vdst=dstParam[2] + dstStride[2]*srcSliceY/2;
+
+    yuyvtoyuv420(ydst, udst, vdst, src[0], c->srcW, srcSliceH, dstStride[0], dstStride[1], srcStride[0]);
+
+    if (dstParam[3])
+        fillPlane(dstParam[3], dstStride[3], c->srcW, srcSliceH, srcSliceY, 255);
+
+    return srcSliceH;
+}
+
+static int YUYV2YUV422Wrapper(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
+                               int srcSliceH, uint8_t* dstParam[], int dstStride[]){
+    uint8_t *ydst=dstParam[0] + dstStride[0]*srcSliceY;
+    uint8_t *udst=dstParam[1] + dstStride[1]*srcSliceY;
+    uint8_t *vdst=dstParam[2] + dstStride[2]*srcSliceY;
+
+    yuyvtoyuv422(ydst, udst, vdst, src[0], c->srcW, srcSliceH, dstStride[0], dstStride[1], srcStride[0]);
+
+    return srcSliceH;
+}
+
+static int UYVY2YUV420Wrapper(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
+                               int srcSliceH, uint8_t* dstParam[], int dstStride[]){
+    uint8_t *ydst=dstParam[0] + dstStride[0]*srcSliceY;
+    uint8_t *udst=dstParam[1] + dstStride[1]*srcSliceY/2;
+    uint8_t *vdst=dstParam[2] + dstStride[2]*srcSliceY/2;
+
+    uyvytoyuv420(ydst, udst, vdst, src[0], c->srcW, srcSliceH, dstStride[0], dstStride[1], srcStride[0]);
+
+    if (dstParam[3])
+        fillPlane(dstParam[3], dstStride[3], c->srcW, srcSliceH, srcSliceY, 255);
+
+    return srcSliceH;
+}
+
+static int UYVY2YUV422Wrapper(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
+                               int srcSliceH, uint8_t* dstParam[], int dstStride[]){
+    uint8_t *ydst=dstParam[0] + dstStride[0]*srcSliceY;
+    uint8_t *udst=dstParam[1] + dstStride[1]*srcSliceY;
+    uint8_t *vdst=dstParam[2] + dstStride[2]*srcSliceY;
+
+    uyvytoyuv422(ydst, udst, vdst, src[0], c->srcW, srcSliceH, dstStride[0], dstStride[1], srcStride[0]);
+
+    return srcSliceH;
+}
+
 static int pal2rgbWrapper(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
                           int srcSliceH, uint8_t* dst[], int dstStride[]){
     const enum PixelFormat srcFormat= c->srcFormat;
@@ -1861,6 +2053,8 @@
         dst[2]+(srcSliceY>>1)*dstStride[2],
         c->srcW, srcSliceH,
         dstStride[0], dstStride[1], srcStride[0]);
+    if (dst[3])
+        fillPlane(dst[3], dstStride[3], c->srcW, srcSliceH, srcSliceY, 255);
     return srcSliceH;
 }
 
@@ -1883,13 +2077,15 @@
         }
     }
 
-    if (c->dstFormat==PIX_FMT_YUV420P){
+    if (c->dstFormat==PIX_FMT_YUV420P || c->dstFormat==PIX_FMT_YUVA420P){
         planar2x(src[1], dst[1], c->chrSrcW, c->chrSrcH, srcStride[1], dstStride[1]);
         planar2x(src[2], dst[2], c->chrSrcW, c->chrSrcH, srcStride[2], dstStride[2]);
     }else{
         planar2x(src[1], dst[2], c->chrSrcW, c->chrSrcH, srcStride[1], dstStride[2]);
         planar2x(src[2], dst[1], c->chrSrcW, c->chrSrcH, srcStride[2], dstStride[1]);
     }
+    if (dst[3])
+        fillPlane(dst[3], dstStride[3], c->srcW, srcSliceH, srcSliceY, 255);
     return srcSliceH;
 }
 
@@ -1925,17 +2121,17 @@
                       int srcSliceH, uint8_t* dst[], int dstStride[])
 {
     int plane;
-    for (plane=0; plane<3; plane++)
+    for (plane=0; plane<4; plane++)
     {
-        int length= plane==0 ? c->srcW  : -((-c->srcW  )>>c->chrDstHSubSample);
-        int y=      plane==0 ? srcSliceY: -((-srcSliceY)>>c->chrDstVSubSample);
-        int height= plane==0 ? srcSliceH: -((-srcSliceH)>>c->chrDstVSubSample);
+        int length= (plane==0 || plane==3) ? c->srcW  : -((-c->srcW  )>>c->chrDstHSubSample);
+        int y=      (plane==0 || plane==3) ? srcSliceY: -((-srcSliceY)>>c->chrDstVSubSample);
+        int height= (plane==0 || plane==3) ? srcSliceH: -((-srcSliceH)>>c->chrDstVSubSample);
 
-        if ((isGray(c->srcFormat) || isGray(c->dstFormat)) && plane>0)
-        {
-            if (!isGray(c->dstFormat))
-                memset(dst[plane], 128, dstStride[plane]*height);
-        }
+        if (!dst[plane]) continue;
+        // ignore palette for GRAY8
+        if (plane == 1 && !dst[2]) continue;
+        if (!src[plane] || (plane == 1 && !src[2]))
+            fillPlane(dst[plane], dstStride[plane], length, height, y, (plane==3) ? 255 : 128);
         else
         {
             if (dstStride[plane]==srcStride[plane] && srcStride[plane] > 0)
@@ -1979,6 +2175,8 @@
         srcPtr+= srcStride[0];
         dstPtr+= dstStride[0];
     }
+    if (dst[3])
+        fillPlane(dst[3], dstStride[3], length, height, y, 255);
     return srcSliceH;
 }
 
@@ -2132,12 +2330,12 @@
     c->yuv2rgb_u2g_coeff= (int16_t)roundToInt16(cgu<<13);
     c->yuv2rgb_u2b_coeff= (int16_t)roundToInt16(cbu<<13);
 
-    sws_yuv2rgb_c_init_tables(c, inv_table, srcRange, brightness, contrast, saturation);
+    ff_yuv2rgb_c_init_tables(c, inv_table, srcRange, brightness, contrast, saturation);
     //FIXME factorize
 
 #ifdef COMPILE_ALTIVEC
     if (c->flags & SWS_CPU_CAPS_ALTIVEC)
-        sws_yuv2rgb_altivec_init_tables (c, inv_table, brightness, contrast, saturation);
+        ff_yuv2rgb_init_tables_altivec(c, inv_table, brightness, contrast, saturation);
 #endif
     return 0;
 }
@@ -2193,7 +2391,7 @@
         __asm__ volatile("emms\n\t"::: "memory");
 #endif
 
-#if !CONFIG_RUNTIME_CPUDETECT //ensure that the flags match the compiled variant if cpudetect is off
+#if !defined(RUNTIME_CPUDETECT) || !CONFIG_GPL //ensure that the flags match the compiled variant if cpudetect is off
     flags &= ~(SWS_CPU_CAPS_MMX|SWS_CPU_CAPS_MMX2|SWS_CPU_CAPS_3DNOW|SWS_CPU_CAPS_ALTIVEC|SWS_CPU_CAPS_BFIN);
 #if   HAVE_MMX2
     flags |= SWS_CPU_CAPS_MMX|SWS_CPU_CAPS_MMX2;
@@ -2206,7 +2404,7 @@
 #elif ARCH_BFIN
     flags |= SWS_CPU_CAPS_BFIN;
 #endif
-#endif /* CONFIG_RUNTIME_CPUDETECT */
+#endif /* RUNTIME_CPUDETECT */
     if (clip_table[512] != 255) globalInit();
     if (!rgb15to16) sws_rgb2rgb_init(flags);
 
@@ -2334,16 +2532,16 @@
         if ((srcFormat==PIX_FMT_YUV420P || srcFormat==PIX_FMT_YUV422P || srcFormat==PIX_FMT_YUVA420P) && (isBGR(dstFormat) || isRGB(dstFormat))
             && !(flags & SWS_ACCURATE_RND) && !(dstH&1))
         {
-            c->swScale= sws_yuv2rgb_get_func_ptr(c);
+            c->swScale= ff_yuv2rgb_get_func_ptr(c);
         }
 
-        if (srcFormat==PIX_FMT_YUV410P && dstFormat==PIX_FMT_YUV420P && !(flags & SWS_BITEXACT))
+        if (srcFormat==PIX_FMT_YUV410P && (dstFormat==PIX_FMT_YUV420P || dstFormat==PIX_FMT_YUVA420P) && !(flags & SWS_BITEXACT))
         {
             c->swScale= yvu9toyv12Wrapper;
         }
 
         /* bgr24toYV12 */
-        if (srcFormat==PIX_FMT_BGR24 && dstFormat==PIX_FMT_YUV420P && !(flags & SWS_ACCURATE_RND))
+        if (srcFormat==PIX_FMT_BGR24 && (dstFormat==PIX_FMT_YUV420P || dstFormat==PIX_FMT_YUVA420P) && !(flags & SWS_ACCURATE_RND))
             c->swScale= bgr24toyv12Wrapper;
 
         /* RGB/BGR -> RGB/BGR (no dither needed forms) */
@@ -2390,6 +2588,14 @@
                     c->swScale= PlanarToUyvyWrapper;
             }
         }
+        if(srcFormat == PIX_FMT_YUYV422 && (dstFormat == PIX_FMT_YUV420P || dstFormat == PIX_FMT_YUVA420P))
+            c->swScale= YUYV2YUV420Wrapper;
+        if(srcFormat == PIX_FMT_UYVY422 && (dstFormat == PIX_FMT_YUV420P || dstFormat == PIX_FMT_YUVA420P))
+            c->swScale= UYVY2YUV420Wrapper;
+        if(srcFormat == PIX_FMT_YUYV422 && dstFormat == PIX_FMT_YUV422P)
+            c->swScale= YUYV2YUV422Wrapper;
+        if(srcFormat == PIX_FMT_UYVY422 && dstFormat == PIX_FMT_YUV422P)
+            c->swScale= UYVY2YUV422Wrapper;
 
 #ifdef COMPILE_ALTIVEC
         if ((c->flags & SWS_CPU_CAPS_ALTIVEC) &&
@@ -2406,6 +2612,7 @@
         /* simple copy */
         if (  srcFormat == dstFormat
             || (srcFormat == PIX_FMT_YUVA420P && dstFormat == PIX_FMT_YUV420P)
+            || (srcFormat == PIX_FMT_YUV420P && dstFormat == PIX_FMT_YUVA420P)
             || (isPlanarYUV(srcFormat) && isGray(dstFormat))
             || (isPlanarYUV(dstFormat) && isGray(srcFormat)))
         {
@@ -2501,10 +2708,13 @@
         if (c->canMMX2BeUsed && (flags & SWS_FAST_BILINEAR))
         {
 #ifdef MAP_ANONYMOUS
-            c->funnyYCode = (uint8_t*)mmap(NULL, MAX_FUNNY_CODE_SIZE, PROT_EXEC | PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
-            c->funnyUVCode = (uint8_t*)mmap(NULL, MAX_FUNNY_CODE_SIZE, PROT_EXEC | PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
+            c->funnyYCode  = mmap(NULL, MAX_FUNNY_CODE_SIZE, PROT_EXEC | PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
+            c->funnyUVCode = mmap(NULL, MAX_FUNNY_CODE_SIZE, PROT_EXEC | PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
+#elif HAVE_VIRTUALALLOC
+            c->funnyYCode  = VirtualAlloc(NULL, MAX_FUNNY_CODE_SIZE, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
+            c->funnyUVCode = VirtualAlloc(NULL, MAX_FUNNY_CODE_SIZE, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
 #else
-            c->funnyYCode = av_malloc(MAX_FUNNY_CODE_SIZE);
+            c->funnyYCode  = av_malloc(MAX_FUNNY_CODE_SIZE);
             c->funnyUVCode = av_malloc(MAX_FUNNY_CODE_SIZE);
 #endif
 
@@ -2577,12 +2787,17 @@
     // allocate pixbufs (we use dynamic allocation because otherwise we would need to
     c->lumPixBuf= av_malloc(c->vLumBufSize*2*sizeof(int16_t*));
     c->chrPixBuf= av_malloc(c->vChrBufSize*2*sizeof(int16_t*));
+    if (CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat) && isALPHA(c->dstFormat))
+        c->alpPixBuf= av_malloc(c->vLumBufSize*2*sizeof(int16_t*));
     //Note we need at least one pixel more at the end because of the MMX code (just in case someone wanna replace the 4000/8000)
     /* align at 16 bytes for AltiVec */
     for (i=0; i<c->vLumBufSize; i++)
         c->lumPixBuf[i]= c->lumPixBuf[i+c->vLumBufSize]= av_mallocz(VOF+1);
     for (i=0; i<c->vChrBufSize; i++)
         c->chrPixBuf[i]= c->chrPixBuf[i+c->vChrBufSize]= av_malloc((VOF+1)*2);
+    if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf)
+        for (i=0; i<c->vLumBufSize; i++)
+            c->alpPixBuf[i]= c->alpPixBuf[i+c->vLumBufSize]= av_mallocz(VOF+1);
 
     //try to avoid drawing green stuff between the right end and the stride end
     for (i=0; i<c->vChrBufSize; i++) memset(c->chrPixBuf[i], 64, (VOF+1)*2);
@@ -2725,7 +2940,7 @@
 int sws_scale(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
               int srcSliceH, uint8_t* dst[], int dstStride[]){
     int i;
-    uint8_t* src2[4]= {src[0], src[1], src[2]};
+    uint8_t* src2[4]= {src[0], src[1], src[2], src[3]};
 
     if (c->sliceDir == 0 && srcSliceY != 0 && srcSliceY + srcSliceH != c->srcH) {
         av_log(c, AV_LOG_ERROR, "Slices start in the middle!\n");
@@ -2799,21 +3014,23 @@
     // copy strides, so they can safely be modified
     if (c->sliceDir == 1) {
         // slices go from top to bottom
-        int srcStride2[4]= {srcStride[0], srcStride[1], srcStride[2]};
-        int dstStride2[4]= {dstStride[0], dstStride[1], dstStride[2]};
+        int srcStride2[4]= {srcStride[0], srcStride[1], srcStride[2], srcStride[3]};
+        int dstStride2[4]= {dstStride[0], dstStride[1], dstStride[2], dstStride[3]};
         return c->swScale(c, src2, srcStride2, srcSliceY, srcSliceH, dst, dstStride2);
     } else {
         // slices go from bottom to top => we flip the image internally
         uint8_t* dst2[4]= {dst[0] + (c->dstH-1)*dstStride[0],
                            dst[1] + ((c->dstH>>c->chrDstVSubSample)-1)*dstStride[1],
-                           dst[2] + ((c->dstH>>c->chrDstVSubSample)-1)*dstStride[2]};
-        int srcStride2[4]= {-srcStride[0], -srcStride[1], -srcStride[2]};
-        int dstStride2[4]= {-dstStride[0], -dstStride[1], -dstStride[2]};
+                           dst[2] + ((c->dstH>>c->chrDstVSubSample)-1)*dstStride[2],
+                           dst[3] + (c->dstH-1)*dstStride[3]};
+        int srcStride2[4]= {-srcStride[0], -srcStride[1], -srcStride[2], -srcStride[3]};
+        int dstStride2[4]= {-dstStride[0], -dstStride[1], -dstStride[2], -dstStride[3]};
 
         src2[0] += (srcSliceH-1)*srcStride[0];
         if (!usePal(c->srcFormat))
             src2[1] += ((srcSliceH>>c->chrSrcVSubSample)-1)*srcStride[1];
         src2[2] += ((srcSliceH>>c->chrSrcVSubSample)-1)*srcStride[2];
+        src2[3] += (srcSliceH-1)*srcStride[3];
 
         return c->swScale(c, src2, srcStride2, c->srcH-srcSliceY-srcSliceH, srcSliceH, dst2, dstStride2);
     }
@@ -3131,6 +3348,12 @@
         av_freep(&c->chrPixBuf);
     }
 
+    if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf){
+        for (i=0; i<c->vLumBufSize; i++)
+            av_freep(&c->alpPixBuf[i]);
+        av_freep(&c->alpPixBuf);
+    }
+
     av_freep(&c->vLumFilter);
     av_freep(&c->vChrFilter);
     av_freep(&c->hLumFilter);
@@ -3147,10 +3370,13 @@
 
 #if ARCH_X86 && CONFIG_GPL
 #ifdef MAP_ANONYMOUS
-    if (c->funnyYCode) munmap(c->funnyYCode, MAX_FUNNY_CODE_SIZE);
+    if (c->funnyYCode ) munmap(c->funnyYCode , MAX_FUNNY_CODE_SIZE);
     if (c->funnyUVCode) munmap(c->funnyUVCode, MAX_FUNNY_CODE_SIZE);
+#elif HAVE_VIRTUALALLOC
+    if (c->funnyYCode ) VirtualFree(c->funnyYCode , MAX_FUNNY_CODE_SIZE, MEM_RELEASE);
+    if (c->funnyUVCode) VirtualFree(c->funnyUVCode, MAX_FUNNY_CODE_SIZE, MEM_RELEASE);
 #else
-    av_free(c->funnyYCode);
+    av_free(c->funnyYCode );
     av_free(c->funnyUVCode);
 #endif
     c->funnyYCode=NULL;
diff --git a/libswscale/swscale_altivec_template.c b/libswscale/swscale_altivec_template.c
index 0bf620b..a008b96 100644
--- a/libswscale/swscale_altivec_template.c
+++ b/libswscale/swscale_altivec_template.c
@@ -6,18 +6,18 @@
  *
  * 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 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.
  *
  * 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.
+ * 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 Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
+ * You should have received a copy of the GNU 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
  */
 
diff --git a/libswscale/swscale_bfin.c b/libswscale/swscale_bfin.c
index ed7d957..0c3ea4d 100644
--- a/libswscale/swscale_bfin.c
+++ b/libswscale/swscale_bfin.c
@@ -37,16 +37,16 @@
 #define L1CODE
 #endif
 
-int ff_bfin_uyvytoyv12 (const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
-                        long width, long height,
-                        long lumStride, long chromStride, long srcStride) L1CODE;
+int ff_bfin_uyvytoyv12(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
+                       long width, long height,
+                       long lumStride, long chromStride, long srcStride) L1CODE;
 
-int ff_bfin_yuyvtoyv12 (const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
-                        long width, long height,
-                        long lumStride, long chromStride, long srcStride) L1CODE;
+int ff_bfin_yuyvtoyv12(const uint8_t *src, uint8_t *ydst, uint8_t *udst, uint8_t *vdst,
+                       long width, long height,
+                       long lumStride, long chromStride, long srcStride) L1CODE;
 
-static int uyvytoyv12_unscaled (SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
-                                int srcSliceH, uint8_t* dst[], int dstStride[])
+static int uyvytoyv12_unscaled(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
+                               int srcSliceH, uint8_t* dst[], int dstStride[])
 {
     uint8_t *dsty = dst[0] + dstStride[0]*srcSliceY;
     uint8_t *dstu = dst[1] + dstStride[1]*srcSliceY/2;
@@ -54,13 +54,14 @@
     uint8_t *ip   = src[0] + srcStride[0]*srcSliceY;
     int w         = dstStride[0];
 
-    ff_bfin_uyvytoyv12 (ip, dsty, dstu, dstv, w, srcSliceH, dstStride[0], dstStride[1], srcStride[0]);
+    ff_bfin_uyvytoyv12(ip, dsty, dstu, dstv, w, srcSliceH,
+                       dstStride[0], dstStride[1], srcStride[0]);
 
     return srcSliceH;
 }
 
-static int yuyvtoyv12_unscaled (SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
-                                int srcSliceH, uint8_t* dst[], int dstStride[])
+static int yuyvtoyv12_unscaled(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
+                               int srcSliceH, uint8_t* dst[], int dstStride[])
 {
     uint8_t *dsty = dst[0] + dstStride[0]*srcSliceY;
     uint8_t *dstu = dst[1] + dstStride[1]*srcSliceY/2;
@@ -68,13 +69,14 @@
     uint8_t *ip   = src[0] + srcStride[0]*srcSliceY;
     int w         = dstStride[0];
 
-    ff_bfin_yuyvtoyv12 (ip, dsty, dstu, dstv, w, srcSliceH, dstStride[0], dstStride[1], srcStride[0]);
+    ff_bfin_yuyvtoyv12(ip, dsty, dstu, dstv, w, srcSliceH,
+                       dstStride[0], dstStride[1], srcStride[0]);
 
     return srcSliceH;
 }
 
 
-void ff_bfin_get_unscaled_swscale (SwsContext *c)
+void ff_bfin_get_unscaled_swscale(SwsContext *c)
 {
     SwsFunc swScale = c->swScale;
     if (c->flags & SWS_CPU_CAPS_BFIN)
diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h
index cdf3754..91f05ad 100644
--- a/libswscale/swscale_internal.h
+++ b/libswscale/swscale_internal.h
@@ -87,6 +87,7 @@
 
     int16_t **lumPixBuf;
     int16_t **chrPixBuf;
+    int16_t **alpPixBuf;
     int16_t *hLumFilter;
     int16_t *hLumFilterPos;
     int16_t *hChrFilter;
@@ -156,6 +157,8 @@
 #define VROUNDER_OFFSET       "11*8+4*4*256*2+16"
 #define U_TEMP                "11*8+4*4*256*2+24"
 #define V_TEMP                "11*8+4*4*256*2+32"
+#define Y_TEMP                "11*8+4*4*256*2+40"
+#define ALP_MMX_FILTER_OFFSET "11*8+4*4*256*2+48"
 
     uint64_t redDither   __attribute__((aligned(8)));
     uint64_t greenDither __attribute__((aligned(8)));
@@ -176,6 +179,8 @@
     uint64_t vRounder     __attribute__((aligned(8)));
     uint64_t u_temp       __attribute__((aligned(8)));
     uint64_t v_temp       __attribute__((aligned(8)));
+    uint64_t y_temp       __attribute__((aligned(8)));
+    int32_t  alpMmxFilter[4*MAX_FILTER_SIZE];
 
 #if HAVE_ALTIVEC
 
@@ -212,12 +217,16 @@
 } SwsContext;
 //FIXME check init (where 0)
 
-SwsFunc sws_yuv2rgb_get_func_ptr (SwsContext *c);
-int sws_yuv2rgb_c_init_tables (SwsContext *c, const int inv_table[4], int fullRange, int brightness, int contrast, int saturation);
+SwsFunc ff_yuv2rgb_get_func_ptr(SwsContext *c);
+int ff_yuv2rgb_c_init_tables(SwsContext *c, const int inv_table[4], int fullRange, int brightness, int contrast, int saturation);
 
-void sws_yuv2rgb_altivec_init_tables (SwsContext *c, const int inv_table[4],int brightness,int contrast, int saturation);
-SwsFunc sws_yuv2rgb_init_altivec (SwsContext *c);
-void altivec_yuv2packedX (SwsContext *c,
+void ff_yuv2rgb_init_tables_altivec(SwsContext *c, const int inv_table[4], int brightness, int contrast, int saturation);
+SwsFunc ff_yuv2rgb_init_mmx(SwsContext *c);
+SwsFunc ff_yuv2rgb_init_vis(SwsContext *c);
+SwsFunc ff_yuv2rgb_init_mlib(SwsContext *c);
+SwsFunc ff_yuv2rgb_init_altivec(SwsContext *c);
+SwsFunc ff_yuv2rgb_get_func_ptr_bfin(SwsContext *c);
+void ff_yuv2packedX_altivec(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);
@@ -228,6 +237,7 @@
 #define isPlanarYUV(x)  (           \
            (x)==PIX_FMT_YUV410P     \
         || (x)==PIX_FMT_YUV420P     \
+        || (x)==PIX_FMT_YUVA420P    \
         || (x)==PIX_FMT_YUV411P     \
         || (x)==PIX_FMT_YUV422P     \
         || (x)==PIX_FMT_YUV444P     \
diff --git a/libswscale/swscale_template.c b/libswscale/swscale_template.c
index 9016778..971b69c 100644
--- a/libswscale/swscale_template.c
+++ b/libswscale/swscale_template.c
@@ -230,28 +230,28 @@
     "test                  %%"REG_S", %%"REG_S"     \n\t"\
     " jnz                         2b                \n\t"\
 
-#define YSCALEYUV2PACKEDX_YA(offset) \
+#define YSCALEYUV2PACKEDX_YA(offset,coeff,src1,src2,dst1,dst2) \
     "lea                "offset"(%0), %%"REG_d"     \n\t"\
     "mov                 (%%"REG_d"), %%"REG_S"     \n\t"\
-    "movq      "VROUNDER_OFFSET"(%0), %%mm1         \n\t"\
-    "movq                      %%mm1, %%mm7         \n\t"\
+    "movq      "VROUNDER_OFFSET"(%0), "#dst1"       \n\t"\
+    "movq                    "#dst1", "#dst2"       \n\t"\
     ASMALIGN(4)\
     "2:                                             \n\t"\
-    "movq               8(%%"REG_d"), %%mm0         \n\t" /* filterCoeff */\
-    "movq  (%%"REG_S", %%"REG_a", 2), %%mm2         \n\t" /* Y1srcData */\
-    "movq 8(%%"REG_S", %%"REG_a", 2), %%mm5         \n\t" /* Y2srcData */\
+    "movq               8(%%"REG_d"), "#coeff"      \n\t" /* filterCoeff */\
+    "movq  (%%"REG_S", %%"REG_a", 2), "#src1"       \n\t" /* Y1srcData */\
+    "movq 8(%%"REG_S", %%"REG_a", 2), "#src2"       \n\t" /* Y2srcData */\
     "add                         $16, %%"REG_d"            \n\t"\
     "mov                 (%%"REG_d"), %%"REG_S"     \n\t"\
-    "pmulhw                    %%mm0, %%mm2         \n\t"\
-    "pmulhw                    %%mm0, %%mm5         \n\t"\
-    "paddw                     %%mm2, %%mm1         \n\t"\
-    "paddw                     %%mm5, %%mm7         \n\t"\
+    "pmulhw                 "#coeff", "#src1"       \n\t"\
+    "pmulhw                 "#coeff", "#src2"       \n\t"\
+    "paddw                   "#src1", "#dst1"       \n\t"\
+    "paddw                   "#src2", "#dst2"       \n\t"\
     "test                  %%"REG_S", %%"REG_S"     \n\t"\
     " jnz                         2b                \n\t"\
 
 #define YSCALEYUV2PACKEDX \
     YSCALEYUV2PACKEDX_UV \
-    YSCALEYUV2PACKEDX_YA(LUM_MMX_FILTER_OFFSET) \
+    YSCALEYUV2PACKEDX_YA(LUM_MMX_FILTER_OFFSET,%%mm0,%%mm2,%%mm5,%%mm1,%%mm7) \
 
 #define YSCALEYUV2PACKEDX_END                 \
     :: "r" (&c->redDither),                   \
@@ -458,11 +458,11 @@
     "pmulhw "VG_COEFF"("#c"), %%mm4     \n\t"\
     /* mm2=(U-128)8, mm3=ug, mm4=vg mm5=(V-128)8 */\
 
-#define REAL_YSCALEYUV2RGB_YA(index, c) \
-    "movq  (%0, "#index", 2), %%mm0     \n\t" /*buf0[eax]*/\
-    "movq  (%1, "#index", 2), %%mm1     \n\t" /*buf1[eax]*/\
-    "movq 8(%0, "#index", 2), %%mm6     \n\t" /*buf0[eax]*/\
-    "movq 8(%1, "#index", 2), %%mm7     \n\t" /*buf1[eax]*/\
+#define REAL_YSCALEYUV2RGB_YA(index, c, b1, b2) \
+    "movq  ("#b1", "#index", 2), %%mm0     \n\t" /*buf0[eax]*/\
+    "movq  ("#b2", "#index", 2), %%mm1     \n\t" /*buf1[eax]*/\
+    "movq 8("#b1", "#index", 2), %%mm6     \n\t" /*buf0[eax]*/\
+    "movq 8("#b2", "#index", 2), %%mm7     \n\t" /*buf1[eax]*/\
     "psubw             %%mm1, %%mm0     \n\t" /* buf0[eax] - buf1[eax]*/\
     "psubw             %%mm7, %%mm6     \n\t" /* buf0[eax] - buf1[eax]*/\
     "pmulhw "LUM_MMX_FILTER_OFFSET"+8("#c"), %%mm0  \n\t" /* (buf0[eax] - buf1[eax])yalpha1>>16*/\
@@ -501,11 +501,11 @@
     "packuswb          %%mm6, %%mm5     \n\t"\
     "packuswb          %%mm3, %%mm4     \n\t"\
 
-#define YSCALEYUV2RGB_YA(index, c) REAL_YSCALEYUV2RGB_YA(index, c)
+#define YSCALEYUV2RGB_YA(index, c, b1, b2) REAL_YSCALEYUV2RGB_YA(index, c, b1, b2)
 
 #define YSCALEYUV2RGB(index, c) \
     REAL_YSCALEYUV2RGB_UV(index, c) \
-    REAL_YSCALEYUV2RGB_YA(index, c) \
+    REAL_YSCALEYUV2RGB_YA(index, c, %0, %1) \
     REAL_YSCALEYUV2RGB_COEFF(c)
 
 #define REAL_YSCALEYUV2PACKED1(index, c) \
@@ -644,6 +644,14 @@
 
 #define YSCALEYUV2RGB1b(index, c)  REAL_YSCALEYUV2RGB1b(index, c)
 
+#define REAL_YSCALEYUV2RGB1_ALPHA(index) \
+    "movq  (%1, "#index", 2), %%mm7     \n\t" /* abuf0[index  ]     */\
+    "movq 8(%1, "#index", 2), %%mm1     \n\t" /* abuf0[index+4]     */\
+    "psraw                $7, %%mm7     \n\t" /* abuf0[index  ] >>7 */\
+    "psraw                $7, %%mm1     \n\t" /* abuf0[index+4] >>7 */\
+    "packuswb          %%mm1, %%mm7     \n\t"
+#define YSCALEYUV2RGB1_ALPHA(index) REAL_YSCALEYUV2RGB1_ALPHA(index)
+
 #define REAL_WRITEBGR32(dst, dstw, index, b, g, r, a, q0, q2, q3, t) \
     "movq       "#b", "#q2"     \n\t" /* B */\
     "movq       "#r", "#t"      \n\t" /* R */\
@@ -909,8 +917,8 @@
 
 
 static inline void RENAME(yuv2yuvX)(SwsContext *c, int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize,
-                                    int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,
-                                    uint8_t *dest, uint8_t *uDest, uint8_t *vDest, long dstW, long chrDstW)
+                                    int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize, int16_t **alpSrc,
+                                    uint8_t *dest, uint8_t *uDest, uint8_t *vDest, uint8_t *aDest, long dstW, long chrDstW)
 {
 #if HAVE_MMX
     if(!(c->flags & SWS_BITEXACT)){
@@ -919,6 +927,9 @@
                 YSCALEYUV2YV12X_ACCURATE(   "0", CHR_MMX_FILTER_OFFSET, uDest, chrDstW)
                 YSCALEYUV2YV12X_ACCURATE(AV_STRINGIFY(VOF), CHR_MMX_FILTER_OFFSET, vDest, chrDstW)
             }
+            if (CONFIG_SWSCALE_ALPHA && aDest){
+                YSCALEYUV2YV12X_ACCURATE(   "0", ALP_MMX_FILTER_OFFSET, aDest, dstW)
+            }
 
             YSCALEYUV2YV12X_ACCURATE("0", LUM_MMX_FILTER_OFFSET, dest, dstW)
         }else{
@@ -926,6 +937,9 @@
                 YSCALEYUV2YV12X(   "0", CHR_MMX_FILTER_OFFSET, uDest, chrDstW)
                 YSCALEYUV2YV12X(AV_STRINGIFY(VOF), CHR_MMX_FILTER_OFFSET, vDest, chrDstW)
             }
+            if (CONFIG_SWSCALE_ALPHA && aDest){
+                YSCALEYUV2YV12X(   "0", ALP_MMX_FILTER_OFFSET, aDest, dstW)
+            }
 
             YSCALEYUV2YV12X("0", LUM_MMX_FILTER_OFFSET, dest, dstW)
         }
@@ -939,7 +953,7 @@
 #else //HAVE_ALTIVEC
 yuv2yuvXinC(lumFilter, lumSrc, lumFilterSize,
             chrFilter, chrSrc, chrFilterSize,
-            dest, uDest, vDest, dstW, chrDstW);
+            alpSrc, dest, uDest, vDest, aDest, dstW, chrDstW);
 #endif //!HAVE_ALTIVEC
 }
 
@@ -952,34 +966,38 @@
              dest, uDest, dstW, chrDstW, dstFormat);
 }
 
-static inline void RENAME(yuv2yuv1)(SwsContext *c, int16_t *lumSrc, int16_t *chrSrc,
-                                    uint8_t *dest, uint8_t *uDest, uint8_t *vDest, long dstW, long chrDstW)
+static inline void RENAME(yuv2yuv1)(SwsContext *c, int16_t *lumSrc, int16_t *chrSrc, int16_t *alpSrc,
+                                    uint8_t *dest, uint8_t *uDest, uint8_t *vDest, uint8_t *aDest, long dstW, long chrDstW)
 {
     int i;
 #if HAVE_MMX
     if(!(c->flags & SWS_BITEXACT)){
-        long p= uDest ? 3 : 1;
-        uint8_t *src[3]= {lumSrc + dstW, chrSrc + chrDstW, chrSrc + VOFW + chrDstW};
-        uint8_t *dst[3]= {dest, uDest, vDest};
-        long counter[3] = {dstW, chrDstW, chrDstW};
+        long p= 4;
+        uint8_t *src[4]= {alpSrc + dstW, lumSrc + dstW, chrSrc + chrDstW, chrSrc + VOFW + chrDstW};
+        uint8_t *dst[4]= {aDest, dest, uDest, vDest};
+        x86_reg counter[4]= {dstW, dstW, chrDstW, chrDstW};
 
         if (c->flags & SWS_ACCURATE_RND){
             while(p--){
-                __asm__ volatile(
-                    YSCALEYUV2YV121_ACCURATE
-                    :: "r" (src[p]), "r" (dst[p] + counter[p]),
-                    "g" (-counter[p])
-                    : "%"REG_a
-                );
+                if (dst[p]){
+                    __asm__ volatile(
+                        YSCALEYUV2YV121_ACCURATE
+                        :: "r" (src[p]), "r" (dst[p] + counter[p]),
+                        "g" (-counter[p])
+                        : "%"REG_a
+                    );
+                }
             }
         }else{
             while(p--){
-                __asm__ volatile(
-                    YSCALEYUV2YV121
-                    :: "r" (src[p]), "r" (dst[p] + counter[p]),
-                    "g" (-counter[p])
-                    : "%"REG_a
-                );
+                if (dst[p]){
+                    __asm__ volatile(
+                        YSCALEYUV2YV121
+                        :: "r" (src[p]), "r" (dst[p] + counter[p]),
+                        "g" (-counter[p])
+                        : "%"REG_a
+                    );
+                }
             }
         }
         return;
@@ -1013,6 +1031,12 @@
             uDest[i]= u;
             vDest[i]= v;
         }
+
+    if (CONFIG_SWSCALE_ALPHA && aDest)
+        for (i=0; i<dstW; i++){
+            int val= (alpSrc[i]+64)>>7;
+            aDest[i]= av_clip_uint8(val);
+        }
 }
 
 
@@ -1021,20 +1045,36 @@
  */
 static inline void RENAME(yuv2packedX)(SwsContext *c, int16_t *lumFilter, int16_t **lumSrc, int lumFilterSize,
                                        int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,
-                                       uint8_t *dest, long dstW, long dstY)
+                                       int16_t **alpSrc, uint8_t *dest, long dstW, long dstY)
 {
 #if HAVE_MMX
-    long dummy=0;
+    x86_reg dummy=0;
     if(!(c->flags & SWS_BITEXACT)){
         if (c->flags & SWS_ACCURATE_RND){
             switch(c->dstFormat){
             case PIX_FMT_RGB32:
-                YSCALEYUV2PACKEDX_ACCURATE
-                YSCALEYUV2RGBX
-                "pcmpeqd %%mm7, %%mm7 \n\t"
-                WRITEBGR32(%4, %5, %%REGa, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)
+                if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf){
+                    YSCALEYUV2PACKEDX_ACCURATE
+                    YSCALEYUV2RGBX
+                    "movq                      %%mm2, "U_TEMP"(%0)  \n\t"
+                    "movq                      %%mm4, "V_TEMP"(%0)  \n\t"
+                    "movq                      %%mm5, "Y_TEMP"(%0)  \n\t"
+                    YSCALEYUV2PACKEDX_ACCURATE_YA(ALP_MMX_FILTER_OFFSET)
+                    "movq               "Y_TEMP"(%0), %%mm5         \n\t"
+                    "psraw                        $3, %%mm1         \n\t"
+                    "psraw                        $3, %%mm7         \n\t"
+                    "packuswb                  %%mm7, %%mm1         \n\t"
+                    WRITEBGR32(%4, %5, %%REGa, %%mm3, %%mm4, %%mm5, %%mm1, %%mm0, %%mm7, %%mm2, %%mm6)
 
-                YSCALEYUV2PACKEDX_END
+                    YSCALEYUV2PACKEDX_END
+                }else{
+                    YSCALEYUV2PACKEDX_ACCURATE
+                    YSCALEYUV2RGBX
+                    "pcmpeqd %%mm7, %%mm7 \n\t"
+                    WRITEBGR32(%4, %5, %%REGa, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)
+
+                    YSCALEYUV2PACKEDX_END
+                }
                 return;
             case PIX_FMT_BGR24:
                 YSCALEYUV2PACKEDX_ACCURATE
@@ -1095,11 +1135,22 @@
             switch(c->dstFormat)
             {
             case PIX_FMT_RGB32:
-                YSCALEYUV2PACKEDX
-                YSCALEYUV2RGBX
-                "pcmpeqd %%mm7, %%mm7 \n\t"
-                WRITEBGR32(%4, %5, %%REGa, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)
-                YSCALEYUV2PACKEDX_END
+                if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf){
+                    YSCALEYUV2PACKEDX
+                    YSCALEYUV2RGBX
+                    YSCALEYUV2PACKEDX_YA(ALP_MMX_FILTER_OFFSET, %%mm0, %%mm3, %%mm6, %%mm1, %%mm7)
+                    "psraw                        $3, %%mm1         \n\t"
+                    "psraw                        $3, %%mm7         \n\t"
+                    "packuswb                  %%mm7, %%mm1         \n\t"
+                    WRITEBGR32(%4, %5, %%REGa, %%mm2, %%mm4, %%mm5, %%mm1, %%mm0, %%mm7, %%mm3, %%mm6)
+                    YSCALEYUV2PACKEDX_END
+                }else{
+                    YSCALEYUV2PACKEDX
+                    YSCALEYUV2RGBX
+                    "pcmpeqd %%mm7, %%mm7 \n\t"
+                    WRITEBGR32(%4, %5, %%REGa, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)
+                    YSCALEYUV2PACKEDX_END
+                }
                 return;
             case PIX_FMT_BGR24:
                 YSCALEYUV2PACKEDX
@@ -1160,26 +1211,26 @@
 #endif /* HAVE_MMX */
 #if HAVE_ALTIVEC
     /* The following list of supported dstFormat values should
-       match what's found in the body of altivec_yuv2packedX() */
-    if (!(c->flags & SWS_BITEXACT) &&
+       match what's found in the body of ff_yuv2packedX_altivec() */
+    if (!(c->flags & SWS_BITEXACT) && !c->alpPixBuf &&
        (c->dstFormat==PIX_FMT_ABGR  || c->dstFormat==PIX_FMT_BGRA  ||
         c->dstFormat==PIX_FMT_BGR24 || c->dstFormat==PIX_FMT_RGB24 ||
         c->dstFormat==PIX_FMT_RGBA  || c->dstFormat==PIX_FMT_ARGB))
-            altivec_yuv2packedX (c, lumFilter, lumSrc, lumFilterSize,
-                                 chrFilter, chrSrc, chrFilterSize,
-                                 dest, dstW, dstY);
+            ff_yuv2packedX_altivec(c, lumFilter, lumSrc, lumFilterSize,
+                                   chrFilter, chrSrc, chrFilterSize,
+                                   dest, dstW, dstY);
     else
 #endif
         yuv2packedXinC(c, lumFilter, lumSrc, lumFilterSize,
                        chrFilter, chrSrc, chrFilterSize,
-                       dest, dstW, dstY);
+                       alpSrc, dest, dstW, dstY);
 }
 
 /**
  * vertical bilinear scale YV12 to RGB
  */
 static inline void RENAME(yuv2packed2)(SwsContext *c, uint16_t *buf0, uint16_t *buf1, uint16_t *uvbuf0, uint16_t *uvbuf1,
-                          uint8_t *dest, int dstW, int yalpha, int uvalpha, int y)
+                          uint16_t *abuf0, uint16_t *abuf1, uint8_t *dest, int dstW, int yalpha, int uvalpha, int y)
 {
     int  yalpha1=4095- yalpha;
     int uvalpha1=4095-uvalpha;
@@ -1191,19 +1242,62 @@
         {
             //Note 8280 == DSTW_OFFSET but the preprocessor can't handle that there :(
             case PIX_FMT_RGB32:
-                __asm__ volatile(
-                "mov %%"REG_b", "ESP_OFFSET"(%5)        \n\t"
-                "mov        %4, %%"REG_b"               \n\t"
-                "push %%"REG_BP"                        \n\t"
-                YSCALEYUV2RGB(%%REGBP, %5)
-                "pcmpeqd %%mm7, %%mm7                   \n\t"
-                WRITEBGR32(%%REGb, 8280(%5), %%REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)
-                "pop %%"REG_BP"                         \n\t"
-                "mov "ESP_OFFSET"(%5), %%"REG_b"        \n\t"
+                if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf){
+#if ARCH_X86_64
+                    __asm__ volatile(
+                    YSCALEYUV2RGB(%%REGBP, %5)
+                    YSCALEYUV2RGB_YA(%%REGBP, %5, %6, %7)
+                    "psraw                  $3, %%mm1       \n\t" /* abuf0[eax] - abuf1[eax] >>7*/
+                    "psraw                  $3, %%mm7       \n\t" /* abuf0[eax] - abuf1[eax] >>7*/
+                    "packuswb            %%mm7, %%mm1       \n\t"
+                    WRITEBGR32(%4, 8280(%5), %%REGBP, %%mm2, %%mm4, %%mm5, %%mm1, %%mm0, %%mm7, %%mm3, %%mm6)
 
-                :: "c" (buf0), "d" (buf1), "S" (uvbuf0), "D" (uvbuf1), "m" (dest),
-                "a" (&c->redDither)
-                );
+                    :: "c" (buf0), "d" (buf1), "S" (uvbuf0), "D" (uvbuf1), "r" (dest),
+                    "a" (&c->redDither)
+                    ,"r" (abuf0), "r" (abuf1)
+                    : "%"REG_BP
+                    );
+#else
+                    *(uint16_t **)(&c->u_temp)=abuf0;
+                    *(uint16_t **)(&c->v_temp)=abuf1;
+                    __asm__ volatile(
+                    "mov %%"REG_b", "ESP_OFFSET"(%5)        \n\t"
+                    "mov        %4, %%"REG_b"               \n\t"
+                    "push %%"REG_BP"                        \n\t"
+                    YSCALEYUV2RGB(%%REGBP, %5)
+                    "push                   %0              \n\t"
+                    "push                   %1              \n\t"
+                    "mov          "U_TEMP"(%5), %0          \n\t"
+                    "mov          "V_TEMP"(%5), %1          \n\t"
+                    YSCALEYUV2RGB_YA(%%REGBP, %5, %0, %1)
+                    "psraw                  $3, %%mm1       \n\t" /* abuf0[eax] - abuf1[eax] >>7*/
+                    "psraw                  $3, %%mm7       \n\t" /* abuf0[eax] - abuf1[eax] >>7*/
+                    "packuswb            %%mm7, %%mm1       \n\t"
+                    "pop                    %1              \n\t"
+                    "pop                    %0              \n\t"
+                    WRITEBGR32(%%REGb, 8280(%5), %%REGBP, %%mm2, %%mm4, %%mm5, %%mm1, %%mm0, %%mm7, %%mm3, %%mm6)
+                    "pop %%"REG_BP"                         \n\t"
+                    "mov "ESP_OFFSET"(%5), %%"REG_b"        \n\t"
+
+                    :: "c" (buf0), "d" (buf1), "S" (uvbuf0), "D" (uvbuf1), "m" (dest),
+                    "a" (&c->redDither)
+                    );
+#endif
+                }else{
+                    __asm__ volatile(
+                    "mov %%"REG_b", "ESP_OFFSET"(%5)        \n\t"
+                    "mov        %4, %%"REG_b"               \n\t"
+                    "push %%"REG_BP"                        \n\t"
+                    YSCALEYUV2RGB(%%REGBP, %5)
+                    "pcmpeqd %%mm7, %%mm7                   \n\t"
+                    WRITEBGR32(%%REGb, 8280(%5), %%REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)
+                    "pop %%"REG_BP"                         \n\t"
+                    "mov "ESP_OFFSET"(%5), %%"REG_b"        \n\t"
+
+                    :: "c" (buf0), "d" (buf1), "S" (uvbuf0), "D" (uvbuf1), "m" (dest),
+                    "a" (&c->redDither)
+                    );
+                }
                 return;
             case PIX_FMT_BGR24:
                 __asm__ volatile(
@@ -1279,14 +1373,14 @@
         }
     }
 #endif //HAVE_MMX
-YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGB2_C, YSCALE_YUV_2_PACKED2_C, YSCALE_YUV_2_GRAY16_2_C, YSCALE_YUV_2_MONO2_C)
+YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGB2_C, YSCALE_YUV_2_PACKED2_C(void,0), YSCALE_YUV_2_GRAY16_2_C, YSCALE_YUV_2_MONO2_C)
 }
 
 /**
  * YV12 to RGB without scaling or interpolating
  */
 static inline void RENAME(yuv2packed1)(SwsContext *c, uint16_t *buf0, uint16_t *uvbuf0, uint16_t *uvbuf1,
-                          uint8_t *dest, int dstW, int uvalpha, int dstFormat, int flags, int y)
+                          uint16_t *abuf0, uint8_t *dest, int dstW, int uvalpha, int dstFormat, int flags, int y)
 {
     const int yalpha1=0;
     int i;
@@ -1296,7 +1390,7 @@
 
     if (flags&SWS_FULL_CHR_H_INT)
     {
-        RENAME(yuv2packed2)(c, buf0, buf0, uvbuf0, uvbuf1, dest, dstW, 0, uvalpha, y);
+        RENAME(yuv2packed2)(c, buf0, buf0, uvbuf0, uvbuf1, abuf0, abuf0, dest, dstW, 0, uvalpha, y);
         return;
     }
 
@@ -1307,19 +1401,35 @@
             switch(dstFormat)
             {
             case PIX_FMT_RGB32:
-                __asm__ volatile(
-                "mov %%"REG_b", "ESP_OFFSET"(%5)        \n\t"
-                "mov        %4, %%"REG_b"               \n\t"
-                "push %%"REG_BP"                        \n\t"
-                YSCALEYUV2RGB1(%%REGBP, %5)
-                "pcmpeqd %%mm7, %%mm7                   \n\t"
-                WRITEBGR32(%%REGb, 8280(%5), %%REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)
-                "pop %%"REG_BP"                         \n\t"
-                "mov "ESP_OFFSET"(%5), %%"REG_b"        \n\t"
+                if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf){
+                    __asm__ volatile(
+                    "mov %%"REG_b", "ESP_OFFSET"(%5)        \n\t"
+                    "mov        %4, %%"REG_b"               \n\t"
+                    "push %%"REG_BP"                        \n\t"
+                    YSCALEYUV2RGB1(%%REGBP, %5)
+                    YSCALEYUV2RGB1_ALPHA(%%REGBP)
+                    WRITEBGR32(%%REGb, 8280(%5), %%REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)
+                    "pop %%"REG_BP"                         \n\t"
+                    "mov "ESP_OFFSET"(%5), %%"REG_b"        \n\t"
 
-                :: "c" (buf0), "d" (buf1), "S" (uvbuf0), "D" (uvbuf1), "m" (dest),
-                "a" (&c->redDither)
-                );
+                    :: "c" (buf0), "d" (abuf0), "S" (uvbuf0), "D" (uvbuf1), "m" (dest),
+                    "a" (&c->redDither)
+                    );
+                }else{
+                    __asm__ volatile(
+                    "mov %%"REG_b", "ESP_OFFSET"(%5)        \n\t"
+                    "mov        %4, %%"REG_b"               \n\t"
+                    "push %%"REG_BP"                        \n\t"
+                    YSCALEYUV2RGB1(%%REGBP, %5)
+                    "pcmpeqd %%mm7, %%mm7                   \n\t"
+                    WRITEBGR32(%%REGb, 8280(%5), %%REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)
+                    "pop %%"REG_BP"                         \n\t"
+                    "mov "ESP_OFFSET"(%5), %%"REG_b"        \n\t"
+
+                    :: "c" (buf0), "d" (buf1), "S" (uvbuf0), "D" (uvbuf1), "m" (dest),
+                    "a" (&c->redDither)
+                    );
+                }
                 return;
             case PIX_FMT_BGR24:
                 __asm__ volatile(
@@ -1400,19 +1510,35 @@
             switch(dstFormat)
             {
             case PIX_FMT_RGB32:
-                __asm__ volatile(
-                "mov %%"REG_b", "ESP_OFFSET"(%5)        \n\t"
-                "mov        %4, %%"REG_b"               \n\t"
-                "push %%"REG_BP"                        \n\t"
-                YSCALEYUV2RGB1b(%%REGBP, %5)
-                "pcmpeqd %%mm7, %%mm7                   \n\t"
-                WRITEBGR32(%%REGb, 8280(%5), %%REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)
-                "pop %%"REG_BP"                         \n\t"
-                "mov "ESP_OFFSET"(%5), %%"REG_b"        \n\t"
+                if (CONFIG_SWSCALE_ALPHA && c->alpPixBuf){
+                    __asm__ volatile(
+                    "mov %%"REG_b", "ESP_OFFSET"(%5)        \n\t"
+                    "mov        %4, %%"REG_b"               \n\t"
+                    "push %%"REG_BP"                        \n\t"
+                    YSCALEYUV2RGB1b(%%REGBP, %5)
+                    YSCALEYUV2RGB1_ALPHA(%%REGBP)
+                    WRITEBGR32(%%REGb, 8280(%5), %%REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)
+                    "pop %%"REG_BP"                         \n\t"
+                    "mov "ESP_OFFSET"(%5), %%"REG_b"        \n\t"
 
-                :: "c" (buf0), "d" (buf1), "S" (uvbuf0), "D" (uvbuf1), "m" (dest),
-                "a" (&c->redDither)
-                );
+                    :: "c" (buf0), "d" (abuf0), "S" (uvbuf0), "D" (uvbuf1), "m" (dest),
+                    "a" (&c->redDither)
+                    );
+                }else{
+                    __asm__ volatile(
+                    "mov %%"REG_b", "ESP_OFFSET"(%5)        \n\t"
+                    "mov        %4, %%"REG_b"               \n\t"
+                    "push %%"REG_BP"                        \n\t"
+                    YSCALEYUV2RGB1b(%%REGBP, %5)
+                    "pcmpeqd %%mm7, %%mm7                   \n\t"
+                    WRITEBGR32(%%REGb, 8280(%5), %%REGBP, %%mm2, %%mm4, %%mm5, %%mm7, %%mm0, %%mm1, %%mm3, %%mm6)
+                    "pop %%"REG_BP"                         \n\t"
+                    "mov "ESP_OFFSET"(%5), %%"REG_b"        \n\t"
+
+                    :: "c" (buf0), "d" (buf1), "S" (uvbuf0), "D" (uvbuf1), "m" (dest),
+                    "a" (&c->redDither)
+                    );
+                }
                 return;
             case PIX_FMT_BGR24:
                 __asm__ volatile(
@@ -1492,9 +1618,9 @@
 #endif /* HAVE_MMX */
     if (uvalpha < 2048)
     {
-        YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGB1_C, YSCALE_YUV_2_PACKED1_C, YSCALE_YUV_2_GRAY16_1_C, YSCALE_YUV_2_MONO2_C)
+        YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGB1_C, YSCALE_YUV_2_PACKED1_C(void,0), YSCALE_YUV_2_GRAY16_1_C, YSCALE_YUV_2_MONO2_C)
     }else{
-        YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGB1B_C, YSCALE_YUV_2_PACKED1B_C, YSCALE_YUV_2_GRAY16_1_C, YSCALE_YUV_2_MONO2_C)
+        YSCALE_YUV_2_ANYRGB_C(YSCALE_YUV_2_RGB1B_C, YSCALE_YUV_2_PACKED1B_C(void,0), YSCALE_YUV_2_GRAY16_1_C, YSCALE_YUV_2_MONO2_C)
     }
 }
 
@@ -1515,7 +1641,7 @@
     "movq                %%mm0, (%2, %%"REG_a") \n\t"
     "add                    $8, %%"REG_a"       \n\t"
     " js                    1b                  \n\t"
-    : : "g" (-width), "r" (src+width*2), "r" (dst+width)
+    : : "g" ((x86_reg)-width), "r" (src+width*2), "r" (dst+width)
     : "%"REG_a
     );
 #else
@@ -1546,7 +1672,7 @@
     "movd                %%mm1, (%2, %%"REG_a") \n\t"
     "add                    $4, %%"REG_a"       \n\t"
     " js                    1b                  \n\t"
-    : : "g" (-width), "r" (src1+width*4), "r" (dstU+width), "r" (dstV+width)
+    : : "g" ((x86_reg)-width), "r" (src1+width*4), "r" (dstU+width), "r" (dstV+width)
     : "%"REG_a
     );
 #else
@@ -1576,7 +1702,7 @@
     "movq              %%mm0, (%2, %%"REG_a")   \n\t"
     "add                  $8, %%"REG_a"         \n\t"
     " js                  1b                    \n\t"
-    : : "g" (-width), "r" (src+width*2), "r" (dst+width)
+    : : "g" ((x86_reg)-width), "r" (src+width*2), "r" (dst+width)
     : "%"REG_a
     );
 #else
@@ -1607,7 +1733,7 @@
     "movd                %%mm1, (%2, %%"REG_a") \n\t"
     "add                    $4, %%"REG_a"       \n\t"
     " js                    1b                  \n\t"
-    : : "g" (-width), "r" (src1+width*4), "r" (dstU+width), "r" (dstV+width)
+    : : "g" ((x86_reg)-width), "r" (src1+width*4), "r" (dstU+width), "r" (dstV+width)
     : "%"REG_a
     );
 #else
@@ -1642,6 +1768,13 @@
 BGR2Y(uint16_t, rgb16ToY, 0, 0, 0, 0xF800, 0x07E0, 0x001F, RY    , GY<<5, BY<<11, RGB2YUV_SHIFT+8)
 BGR2Y(uint16_t, rgb15ToY, 0, 0, 0, 0x7C00, 0x03E0, 0x001F, RY    , GY<<5, BY<<10, RGB2YUV_SHIFT+7)
 
+static inline void RENAME(abgrToA)(uint8_t *dst, uint8_t *src, long width, uint32_t *unused){
+    int i;
+    for (i=0; i<width; i++){
+        dst[i]= src[4*i];
+    }
+}
+
 #define BGR2UV(type, name, shr, shg, shb, maska, maskr, maskg, maskb, RU, GU, BU, RV, GV, BV, S)\
 static inline void RENAME(name)(uint8_t *dstU, uint8_t *dstV, uint8_t *src, uint8_t *dummy, long width, uint32_t *unused)\
 {\
@@ -1663,7 +1796,7 @@
     {\
         int pix0= ((type*)src)[2*i+0];\
         int pix1= ((type*)src)[2*i+1];\
-        int g= (pix0&(maskg|maska))+(pix1&(maskg|maska));\
+        int g= (pix0&~(maskr|maskb))+(pix1&~(maskr|maskb));\
         int b= ((pix0+pix1-g)&(maskb|(2*maskb)))>>shb;\
         int r= ((pix0+pix1-g)&(maskr|(2*maskr)))>>shr;\
         g&= maskg|(2*maskg);\
@@ -1731,7 +1864,7 @@
         "add                        $4, %%"REG_a"   \n\t"
         " js                        1b              \n\t"
     : "+r" (src)
-    : "r" (dst+width), "g" (-width)
+    : "r" (dst+width), "g" ((x86_reg)-width)
     : "%"REG_a
     );
 }
@@ -1739,7 +1872,7 @@
 static inline void RENAME(bgr24ToUV_mmx)(uint8_t *dstU, uint8_t *dstV, uint8_t *src, long width, int srcFormat)
 {
     __asm__ volatile(
-        "movq                   24(%4), %%mm6       \n\t"
+        "movq                    24+%4, %%mm6       \n\t"
         "mov                        %3, %%"REG_a"   \n\t"
         "pxor                    %%mm7, %%mm7       \n\t"
         "1:                                         \n\t"
@@ -1750,9 +1883,9 @@
         "punpcklbw               %%mm7, %%mm1       \n\t"
         "movq                    %%mm0, %%mm2       \n\t"
         "movq                    %%mm1, %%mm3       \n\t"
-        "pmaddwd                  (%4), %%mm0       \n\t"
-        "pmaddwd                 8(%4), %%mm1       \n\t"
-        "pmaddwd                16(%4), %%mm2       \n\t"
+        "pmaddwd                    %4, %%mm0       \n\t"
+        "pmaddwd                  8+%4, %%mm1       \n\t"
+        "pmaddwd                 16+%4, %%mm2       \n\t"
         "pmaddwd                 %%mm6, %%mm3       \n\t"
         "paddd                   %%mm1, %%mm0       \n\t"
         "paddd                   %%mm3, %%mm2       \n\t"
@@ -1764,9 +1897,9 @@
         "punpcklbw               %%mm7, %%mm3       \n\t"
         "movq                    %%mm1, %%mm4       \n\t"
         "movq                    %%mm3, %%mm5       \n\t"
-        "pmaddwd                  (%4), %%mm1       \n\t"
-        "pmaddwd                 8(%4), %%mm3       \n\t"
-        "pmaddwd                16(%4), %%mm4       \n\t"
+        "pmaddwd                    %4, %%mm1       \n\t"
+        "pmaddwd                  8+%4, %%mm3       \n\t"
+        "pmaddwd                 16+%4, %%mm4       \n\t"
         "pmaddwd                 %%mm6, %%mm5       \n\t"
         "paddd                   %%mm3, %%mm1       \n\t"
         "paddd                   %%mm5, %%mm4       \n\t"
@@ -1789,7 +1922,7 @@
         "add                        $4, %%"REG_a"   \n\t"
         " js                        1b              \n\t"
     : "+r" (src)
-    : "r" (dstU+width), "r" (dstV+width), "g" (-width), "r"(ff_bgr24toUV[srcFormat == PIX_FMT_RGB24])
+    : "r" (dstU+width), "r" (dstV+width), "g" ((x86_reg)-width), "m"(ff_bgr24toUV[srcFormat == PIX_FMT_RGB24][0])
     : "%"REG_a
     );
 }
@@ -1951,7 +2084,7 @@
     assert(filterSize % 4 == 0 && filterSize>0);
     if (filterSize==4) // Always true for upscaling, sometimes for down, too.
     {
-        long counter= -2*dstW;
+        x86_reg counter= -2*dstW;
         filter-= counter*2;
         filterPos-= counter/2;
         dst-= counter/2;
@@ -1997,7 +2130,7 @@
     }
     else if (filterSize==8)
     {
-        long counter= -2*dstW;
+        x86_reg counter= -2*dstW;
         filter-= counter*4;
         filterPos-= counter/2;
         dst-= counter/2;
@@ -2055,7 +2188,7 @@
     else
     {
         uint8_t *offset = src+filterSize;
-        long counter= -2*dstW;
+        x86_reg counter= -2*dstW;
         //filter-= counter*filterSize/2;
         filterPos-= counter/2;
         dst-= counter/2;
@@ -2098,7 +2231,7 @@
 
         : "+r" (counter), "+r" (filter)
         : "m" (filterPos), "m" (dst), "m"(offset),
-          "m" (src), "r" (filterSize*2)
+          "m" (src), "r" ((x86_reg)filterSize*2)
         : "%"REG_a, "%"REG_c, "%"REG_d
         );
     }
@@ -2130,7 +2263,7 @@
                                    int flags, int canMMX2BeUsed, int16_t *hLumFilter,
                                    int16_t *hLumFilterPos, int hLumFilterSize, void *funnyYCode,
                                    int srcFormat, uint8_t *formatConvBuffer, int16_t *mmx2Filter,
-                                   int32_t *mmx2FilterPos, uint32_t *pal)
+                                   int32_t *mmx2FilterPos, uint32_t *pal, int isAlpha)
 {
     if (srcFormat==PIX_FMT_YUYV422 || srcFormat==PIX_FMT_GRAY16BE)
     {
@@ -2144,12 +2277,18 @@
     }
     else if (srcFormat==PIX_FMT_RGB32)
     {
-        RENAME(bgr32ToY)(formatConvBuffer, src, srcW, pal);
+        if (isAlpha)
+            RENAME(abgrToA)(formatConvBuffer, src+3, srcW, pal);
+        else
+            RENAME(bgr32ToY)(formatConvBuffer, src, srcW, pal);
         src= formatConvBuffer;
     }
     else if (srcFormat==PIX_FMT_RGB32_1)
     {
-        RENAME(bgr32ToY)(formatConvBuffer, src+ALT32_CORR, srcW, pal);
+        if (isAlpha)
+            RENAME(abgrToA)(formatConvBuffer, src, srcW, pal);
+        else
+            RENAME(bgr32ToY)(formatConvBuffer, src+ALT32_CORR, srcW, pal);
         src= formatConvBuffer;
     }
     else if (srcFormat==PIX_FMT_BGR24)
@@ -2169,12 +2308,18 @@
     }
     else if (srcFormat==PIX_FMT_BGR32)
     {
-        RENAME(rgb32ToY)(formatConvBuffer, src, srcW, pal);
+        if (isAlpha)
+            RENAME(abgrToA)(formatConvBuffer, src+3, srcW, pal);
+        else
+            RENAME(rgb32ToY)(formatConvBuffer, src, srcW, pal);
         src= formatConvBuffer;
     }
     else if (srcFormat==PIX_FMT_BGR32_1)
     {
-        RENAME(rgb32ToY)(formatConvBuffer, src+ALT32_CORR, srcW, pal);
+        if (isAlpha)
+            RENAME(abgrToA)(formatConvBuffer, src, srcW, pal);
+        else
+            RENAME(rgb32ToY)(formatConvBuffer, src+ALT32_CORR, srcW, pal);
         src= formatConvBuffer;
     }
     else if (srcFormat==PIX_FMT_RGB24)
@@ -2289,7 +2434,7 @@
         else
         {
 #endif /* HAVE_MMX2 */
-        long xInc_shr16 = xInc >> 16;
+        x86_reg xInc_shr16 = xInc >> 16;
         uint16_t xInc_mask = xInc & 0xffff;
         //NO MMX just normal asm ...
         __asm__ volatile(
@@ -2347,7 +2492,7 @@
 #endif /* ARCH_X86 */
     }
 
-    if(c->srcRange != c->dstRange && !(isRGB(c->dstFormat) || isBGR(c->dstFormat))){
+    if(!isAlpha && c->srcRange != c->dstRange && !(isRGB(c->dstFormat) || isBGR(c->dstFormat))){
         int i;
         //FIXME all pal and rgb srcFormats could do this convertion as well
         //FIXME all scalers more complex than bilinear could do half of this transform
@@ -2575,7 +2720,7 @@
         else
         {
 #endif /* HAVE_MMX2 */
-            long xInc_shr16 = (long) (xInc >> 16);
+            x86_reg xInc_shr16 = (x86_reg) (xInc >> 16);
             uint16_t xInc_mask = xInc & 0xffff;
             __asm__ volatile(
             "xor %%"REG_a", %%"REG_a"               \n\t" // i
@@ -2613,9 +2758,9 @@
 /* GCC 3.3 makes MPlayer crash on IA-32 machines when using "g" operand here,
    which is needed to support GCC 4.0. */
 #if ARCH_X86_64 && ((__GNUC__ > 3) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
-            :: "m" (src1), "m" (dst), "g" ((long)dstWidth), "m" (xInc_shr16), "m" (xInc_mask),
+            :: "m" (src1), "m" (dst), "g" (dstWidth), "m" (xInc_shr16), "m" (xInc_mask),
 #else
-            :: "m" (src1), "m" (dst), "m" ((long)dstWidth), "m" (xInc_shr16), "m" (xInc_mask),
+            :: "m" (src1), "m" (dst), "m" (dstWidth), "m" (xInc_shr16), "m" (xInc_mask),
 #endif
             "r" (src2)
             : "%"REG_a, "%"REG_d, "%ecx", "%"REG_D, "%esi"
@@ -2683,12 +2828,14 @@
     int16_t *hChrFilter= c->hChrFilter;
     int32_t *lumMmxFilter= c->lumMmxFilter;
     int32_t *chrMmxFilter= c->chrMmxFilter;
+    int32_t *alpMmxFilter= c->alpMmxFilter;
     const int vLumFilterSize= c->vLumFilterSize;
     const int vChrFilterSize= c->vChrFilterSize;
     const int hLumFilterSize= c->hLumFilterSize;
     const int hChrFilterSize= c->hChrFilterSize;
     int16_t **lumPixBuf= c->lumPixBuf;
     int16_t **chrPixBuf= c->chrPixBuf;
+    int16_t **alpPixBuf= c->alpPixBuf;
     const int vLumBufSize= c->vLumBufSize;
     const int vChrBufSize= c->vChrBufSize;
     uint8_t *funnyYCode= c->funnyYCode;
@@ -2709,10 +2856,12 @@
     if (isPacked(c->srcFormat)){
         src[0]=
         src[1]=
-        src[2]= src[0];
+        src[2]=
+        src[3]= src[0];
         srcStride[0]=
         srcStride[1]=
-        srcStride[2]= srcStride[0];
+        srcStride[2]=
+        srcStride[3]= srcStride[0];
     }
     srcStride[1]<<= c->vChrDrop;
     srcStride[2]<<= c->vChrDrop;
@@ -2733,7 +2882,7 @@
     //printf("sws Strides:%d %d %d -> %d %d %d\n", srcStride[0],srcStride[1],srcStride[2],
     //dstStride[0],dstStride[1],dstStride[2]);
 
-    if (dstStride[0]%8 !=0 || dstStride[1]%8 !=0 || dstStride[2]%8 !=0)
+    if (dstStride[0]%8 !=0 || dstStride[1]%8 !=0 || dstStride[2]%8 !=0 || dstStride[3]%8 != 0)
     {
         static int warnedAlready=0; //FIXME move this into the context perhaps
         if (flags & SWS_PRINT_INFO && !warnedAlready)
@@ -2762,6 +2911,7 @@
         const int chrDstY= dstY>>c->chrDstVSubSample;
         unsigned char *uDest=dst[1]+dstStride[1]*chrDstY;
         unsigned char *vDest=dst[2]+dstStride[2]*chrDstY;
+        unsigned char *aDest=(CONFIG_SWSCALE_ALPHA && alpPixBuf) ? dst[3]+dstStride[3]*dstY : NULL;
 
         const int firstLumSrcY= vLumFilterPos[dstY]; //First line needed as input
         const int firstChrSrcY= vChrFilterPos[chrDstY]; //First line needed as input
@@ -2783,17 +2933,23 @@
             //Do horizontal scaling
             while(lastInLumBuf < lastLumSrcY)
             {
-                uint8_t *s= src[0]+(lastInLumBuf + 1 - srcSliceY)*srcStride[0];
+                uint8_t *src1= src[0]+(lastInLumBuf + 1 - srcSliceY)*srcStride[0];
+                uint8_t *src2= src[3]+(lastInLumBuf + 1 - srcSliceY)*srcStride[3];
                 lumBufIndex++;
                 //printf("%d %d %d %d\n", lumBufIndex, vLumBufSize, lastInLumBuf,  lastLumSrcY);
                 assert(lumBufIndex < 2*vLumBufSize);
                 assert(lastInLumBuf + 1 - srcSliceY < srcSliceH);
                 assert(lastInLumBuf + 1 - srcSliceY >= 0);
                 //printf("%d %d\n", lumBufIndex, vLumBufSize);
-                RENAME(hyscale)(c, lumPixBuf[ lumBufIndex ], dstW, s, srcW, lumXInc,
+                RENAME(hyscale)(c, lumPixBuf[ lumBufIndex ], dstW, src1, srcW, lumXInc,
                                 flags, canMMX2BeUsed, hLumFilter, hLumFilterPos, hLumFilterSize,
                                 funnyYCode, c->srcFormat, formatConvBuffer,
-                                c->lumMmx2Filter, c->lumMmx2FilterPos, pal);
+                                c->lumMmx2Filter, c->lumMmx2FilterPos, pal, 0);
+                if (CONFIG_SWSCALE_ALPHA && alpPixBuf)
+                    RENAME(hyscale)(c, alpPixBuf[ lumBufIndex ], dstW, src2, srcW, lumXInc,
+                                    flags, canMMX2BeUsed, hLumFilter, hLumFilterPos, hLumFilterSize,
+                                    funnyYCode, c->srcFormat, formatConvBuffer,
+                                    c->lumMmx2Filter, c->lumMmx2FilterPos, pal, 1);
                 lastInLumBuf++;
             }
             while(lastInChrBuf < lastChrSrcY)
@@ -2827,15 +2983,21 @@
             //Do horizontal scaling
             while(lastInLumBuf+1 < srcSliceY + srcSliceH)
             {
-                uint8_t *s= src[0]+(lastInLumBuf + 1 - srcSliceY)*srcStride[0];
+                uint8_t *src1= src[0]+(lastInLumBuf + 1 - srcSliceY)*srcStride[0];
+                uint8_t *src2= src[3]+(lastInLumBuf + 1 - srcSliceY)*srcStride[3];
                 lumBufIndex++;
                 assert(lumBufIndex < 2*vLumBufSize);
                 assert(lastInLumBuf + 1 - srcSliceY < srcSliceH);
                 assert(lastInLumBuf + 1 - srcSliceY >= 0);
-                RENAME(hyscale)(c, lumPixBuf[ lumBufIndex ], dstW, s, srcW, lumXInc,
+                RENAME(hyscale)(c, lumPixBuf[ lumBufIndex ], dstW, src1, srcW, lumXInc,
                                 flags, canMMX2BeUsed, hLumFilter, hLumFilterPos, hLumFilterSize,
                                 funnyYCode, c->srcFormat, formatConvBuffer,
-                                c->lumMmx2Filter, c->lumMmx2FilterPos, pal);
+                                c->lumMmx2Filter, c->lumMmx2FilterPos, pal, 0);
+                if (CONFIG_SWSCALE_ALPHA && alpPixBuf)
+                    RENAME(hyscale)(c, alpPixBuf[ lumBufIndex ], dstW, src2, srcW, lumXInc,
+                                    flags, canMMX2BeUsed, hLumFilter, hLumFilterPos, hLumFilterSize,
+                                    funnyYCode, c->srcFormat, formatConvBuffer,
+                                    c->lumMmx2Filter, c->lumMmx2FilterPos, pal, 1);
                 lastInLumBuf++;
             }
             while(lastInChrBuf+1 < (chrSrcSliceY + chrSrcSliceH))
@@ -2872,6 +3034,7 @@
         {
             int16_t **lumSrcPtr= lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize;
             int16_t **chrSrcPtr= chrPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;
+            int16_t **alpSrcPtr= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? alpPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize : NULL;
 #if HAVE_MMX
             int i;
         if (flags & SWS_ACCURATE_RND){
@@ -2882,6 +3045,12 @@
                           lumMmxFilter[s*i+APCK_COEF/4  ]=
                           lumMmxFilter[s*i+APCK_COEF/4+1]= vLumFilter[dstY*vLumFilterSize + i    ]
                     + (vLumFilterSize>1 ? vLumFilter[dstY*vLumFilterSize + i + 1]<<16 : 0);
+                if (CONFIG_SWSCALE_ALPHA && alpPixBuf){
+                    *(void**)&alpMmxFilter[s*i              ]= alpSrcPtr[i  ];
+                    *(void**)&alpMmxFilter[s*i+APCK_PTR2/4  ]= alpSrcPtr[i+(vLumFilterSize>1)];
+                              alpMmxFilter[s*i+APCK_COEF/4  ]=
+                              alpMmxFilter[s*i+APCK_COEF/4+1]= lumMmxFilter[s*i+APCK_COEF/4  ];
+                }
             }
             for (i=0; i<vChrFilterSize; i+=2){
                 *(void**)&chrMmxFilter[s*i              ]= chrSrcPtr[i  ];
@@ -2898,6 +3067,12 @@
                 lumMmxFilter[4*i+2]=
                 lumMmxFilter[4*i+3]=
                     ((uint16_t)vLumFilter[dstY*vLumFilterSize + i])*0x10001;
+                if (CONFIG_SWSCALE_ALPHA && alpPixBuf){
+                    alpMmxFilter[4*i+0]= (int32_t)alpSrcPtr[i];
+                    alpMmxFilter[4*i+1]= (uint64_t)alpSrcPtr[i] >> 32;
+                    alpMmxFilter[4*i+2]=
+                    alpMmxFilter[4*i+3]= lumMmxFilter[4*i+2];
+                }
             }
             for (i=0; i<vChrFilterSize; i++)
             {
@@ -2925,14 +3100,15 @@
                 {
                     int16_t *lumBuf = lumPixBuf[0];
                     int16_t *chrBuf= chrPixBuf[0];
-                    RENAME(yuv2yuv1)(c, lumBuf, chrBuf, dest, uDest, vDest, dstW, chrDstW);
+                    int16_t *alpBuf= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? alpPixBuf[0] : NULL;
+                    RENAME(yuv2yuv1)(c, lumBuf, chrBuf, alpBuf, dest, uDest, vDest, aDest, dstW, chrDstW);
                 }
                 else //General YV12
                 {
                     RENAME(yuv2yuvX)(c,
                         vLumFilter+dstY*vLumFilterSize   , lumSrcPtr, vLumFilterSize,
                         vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
-                        dest, uDest, vDest, dstW, chrDstW);
+                        alpSrcPtr, dest, uDest, vDest, aDest, dstW, chrDstW);
                 }
             }
             else
@@ -2946,9 +3122,10 @@
                         yuv2rgbXinC_full(c, //FIXME write a packed1_full function
                             vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize,
                             vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
-                            dest, dstW, dstY);
+                            alpSrcPtr, dest, dstW, dstY);
                     }else{
                         RENAME(yuv2packed1)(c, *lumSrcPtr, *chrSrcPtr, *(chrSrcPtr+1),
+                            alpPixBuf ? *alpSrcPtr : NULL,
                             dest, dstW, chrAlpha, dstFormat, flags, dstY);
                     }
                 }
@@ -2964,9 +3141,10 @@
                         yuv2rgbXinC_full(c, //FIXME write a packed2_full function
                             vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize,
                             vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
-                            dest, dstW, dstY);
+                            alpSrcPtr, dest, dstW, dstY);
                     }else{
                         RENAME(yuv2packed2)(c, *lumSrcPtr, *(lumSrcPtr+1), *chrSrcPtr, *(chrSrcPtr+1),
+                            alpPixBuf ? *alpSrcPtr : NULL, alpPixBuf ? *(alpSrcPtr+1) : NULL,
                             dest, dstW, lumAlpha, chrAlpha, dstY);
                     }
                 }
@@ -2976,12 +3154,12 @@
                         yuv2rgbXinC_full(c,
                             vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize,
                             vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
-                            dest, dstW, dstY);
+                            alpSrcPtr, dest, dstW, dstY);
                     }else{
                         RENAME(yuv2packedX)(c,
                             vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize,
                             vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
-                            dest, dstW, dstY);
+                            alpSrcPtr, dest, dstW, dstY);
                     }
                 }
             }
@@ -2990,6 +3168,7 @@
         {
             int16_t **lumSrcPtr= lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize;
             int16_t **chrSrcPtr= chrPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize;
+            int16_t **alpSrcPtr= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? alpPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize : NULL;
             if (dstFormat == PIX_FMT_NV12 || dstFormat == PIX_FMT_NV21){
                 const int chrSkipMask= (1<<c->chrDstVSubSample)-1;
                 if (dstY&chrSkipMask) uDest= NULL; //FIXME split functions in lumi / chromi
@@ -3005,7 +3184,7 @@
                 yuv2yuvXinC(
                     vLumFilter+dstY*vLumFilterSize   , lumSrcPtr, vLumFilterSize,
                     vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
-                    dest, uDest, vDest, dstW, chrDstW);
+                    alpSrcPtr, dest, uDest, vDest, aDest, dstW, chrDstW);
             }
             else
             {
@@ -3015,17 +3194,20 @@
                     yuv2rgbXinC_full(c,
                         vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize,
                         vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
-                        dest, dstW, dstY);
+                        alpSrcPtr, dest, dstW, dstY);
                 }else{
                     yuv2packedXinC(c,
                         vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize,
                         vChrFilter+dstY*vChrFilterSize, chrSrcPtr, vChrFilterSize,
-                        dest, dstW, dstY);
+                        alpSrcPtr, dest, dstW, dstY);
                 }
             }
         }
     }
 
+    if ((dstFormat == PIX_FMT_YUVA420P) && !alpPixBuf)
+        fillPlane(dst[3], dstStride[3], dstW, dstY-lastDstY, lastDstY, 255);
+
 #if HAVE_MMX
     __asm__ volatile(SFENCE:::"memory");
     __asm__ volatile(EMMS:::"memory");
diff --git a/libswscale/x86/yuv2rgb_mmx.c b/libswscale/x86/yuv2rgb_mmx.c
new file mode 100644
index 0000000..ced537f
--- /dev/null
+++ b/libswscale/x86/yuv2rgb_mmx.c
@@ -0,0 +1,89 @@
+/*
+ * software YUV to RGB converter
+ *
+ * Copyright (C) 2009 Konstantin Shishkov
+ *
+ * MMX/MMX2 template stuff (needed for fast movntq support),
+ * 1,4,8bpp support and context / deglobalize stuff
+ * by Michael Niedermayer (michaelni@gmx.at)
+ *
+ * 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 <stdio.h>
+#include <stdlib.h>
+#include <inttypes.h>
+#include <assert.h>
+
+#include "config.h"
+#include "libswscale/rgb2rgb.h"
+#include "libswscale/swscale.h"
+#include "libswscale/swscale_internal.h"
+#include "libavutil/x86_cpu.h"
+
+#define DITHER1XBPP // only for MMX
+
+/* hope these constant values are cache line aligned */
+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;
+
+//MMX versions
+#undef RENAME
+#undef HAVE_MMX2
+#undef HAVE_AMD3DNOW
+#define HAVE_MMX2 0
+#define HAVE_AMD3DNOW 0
+#define RENAME(a) a ## _MMX
+#include "yuv2rgb_template.c"
+
+//MMX2 versions
+#undef RENAME
+#undef HAVE_MMX2
+#define HAVE_MMX2 1
+#define RENAME(a) a ## _MMX2
+#include "yuv2rgb_template.c"
+
+SwsFunc ff_yuv2rgb_init_mmx(SwsContext *c)
+{
+    if (c->flags & SWS_CPU_CAPS_MMX2) {
+        switch (c->dstFormat) {
+        case PIX_FMT_RGB32:
+            if (CONFIG_SWSCALE_ALPHA && c->srcFormat == PIX_FMT_YUVA420P){
+                if (HAVE_7REGS) return yuva420_rgb32_MMX2;
+                break;
+            }else return yuv420_rgb32_MMX2;
+        case PIX_FMT_BGR24:  return yuv420_rgb24_MMX2;
+        case PIX_FMT_RGB565: return yuv420_rgb16_MMX2;
+        case PIX_FMT_RGB555: return yuv420_rgb15_MMX2;
+        }
+    }
+    if (c->flags & SWS_CPU_CAPS_MMX) {
+        switch (c->dstFormat) {
+        case PIX_FMT_RGB32:
+            if (CONFIG_SWSCALE_ALPHA && c->srcFormat == PIX_FMT_YUVA420P){
+                if (HAVE_7REGS) return yuva420_rgb32_MMX;
+                break;
+            }else return yuv420_rgb32_MMX;
+        case PIX_FMT_BGR24:  return yuv420_rgb24_MMX;
+        case PIX_FMT_RGB565: return yuv420_rgb16_MMX;
+        case PIX_FMT_RGB555: return yuv420_rgb15_MMX;
+        }
+    }
+
+    return NULL;
+}
diff --git a/libswscale/yuv2rgb_template.c b/libswscale/x86/yuv2rgb_template.c
similarity index 95%
rename from libswscale/yuv2rgb_template.c
rename to libswscale/x86/yuv2rgb_template.c
index f55568b..798eff0 100644
--- a/libswscale/yuv2rgb_template.c
+++ b/libswscale/x86/yuv2rgb_template.c
@@ -137,7 +137,7 @@
         uint8_t *py = src[0] + y*srcStride[0];                \
         uint8_t *pu = src[1] + (y>>1)*srcStride[1];           \
         uint8_t *pv = src[2] + (y>>1)*srcStride[2];           \
-        long index= -h_size/2;                                \
+        x86_reg index= -h_size/2;                                \
 
 #define YUV2RGB_INIT                                                       \
         /* This MMX assembly code deals with a SINGLE scan line at a time, \
@@ -162,7 +162,8 @@
         "add $"AV_STRINGIFY(depth*8)", %1    \n\t" \
         "add                       $4, %0    \n\t" \
         " js                       1b        \n\t" \
-\
+
+#define YUV2RGB_OPERANDS \
         : "+r" (index), "+r" (image) \
         : "r" (pu - index), "r" (pv - index), "r"(&c->redDither), "r" (py - 2*index) \
         ); \
@@ -170,6 +171,14 @@
     __asm__ volatile (EMMS); \
     return srcSliceH; \
 
+#define YUV2RGB_OPERANDS_ALPHA \
+        : "+r" (index), "+r" (image) \
+        : "r" (pu - index), "r" (pv - index), "r"(&c->redDither), "r" (py - 2*index), "r" (pa - 2*index) \
+        ); \
+    } \
+    __asm__ volatile (EMMS); \
+    return srcSliceH; \
+
 static inline int RENAME(yuv420_rgb16)(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
                                        int srcSliceH, uint8_t* dst[], int dstStride[]){
     int y, h_size;
@@ -223,6 +232,7 @@
         MOVNTQ "   %%mm5, 8 (%1);" /* store pixel 4-7 */
 
     YUV2RGB_ENDLOOP(2)
+    YUV2RGB_OPERANDS
 }
 
 static inline int RENAME(yuv420_rgb15)(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
@@ -280,6 +290,7 @@
         MOVNTQ " %%mm5, 8 (%1);" /* store pixel 4-7 */
 
     YUV2RGB_ENDLOOP(2)
+    YUV2RGB_OPERANDS
 }
 
 static inline int RENAME(yuv420_rgb24)(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
@@ -394,6 +405,7 @@
 #endif
 
     YUV2RGB_ENDLOOP(3)
+    YUV2RGB_OPERANDS
 }
 
 #define RGB_PLANAR2PACKED32                                             \
@@ -450,4 +462,23 @@
         RGB_PLANAR2PACKED32
 
     YUV2RGB_ENDLOOP(4)
+    YUV2RGB_OPERANDS
+}
+
+static inline int RENAME(yuva420_rgb32)(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
+                                        int srcSliceH, uint8_t* dst[], int dstStride[]){
+#if HAVE_7REGS
+    int y, h_size;
+
+    YUV2RGB_LOOP(4)
+
+        uint8_t *pa = src[3] + y*srcStride[3];
+        YUV2RGB_INIT
+        YUV2RGB
+        "movq     (%6, %0, 2), %%mm3;"            /* Load 8 A A7 A6 A5 A4 A3 A2 A1 A0 */
+        RGB_PLANAR2PACKED32
+
+    YUV2RGB_ENDLOOP(4)
+    YUV2RGB_OPERANDS_ALPHA
+#endif
 }
diff --git a/libswscale/yuv2rgb.c b/libswscale/yuv2rgb.c
index c95d07c..d8438c0 100644
--- a/libswscale/yuv2rgb.c
+++ b/libswscale/yuv2rgb.c
@@ -3,7 +3,6 @@
  *
  * Copyright (C) 2009 Konstantin Shishkov
  *
- * MMX/MMX2 template stuff (needed for fast movntq support),
  * 1,4,8bpp support and context / deglobalize stuff
  * by Michael Niedermayer (michaelni@gmx.at)
  *
@@ -33,38 +32,12 @@
 #include "rgb2rgb.h"
 #include "swscale.h"
 #include "swscale_internal.h"
-
-#define DITHER1XBPP // only for MMX
+#include "libavutil/x86_cpu.h"
 
 extern const uint8_t dither_8x8_32[8][8];
 extern const uint8_t dither_8x8_73[8][8];
 extern const uint8_t dither_8x8_220[8][8];
 
-#if HAVE_MMX && CONFIG_GPL
-
-/* hope these constant values are cache line aligned */
-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;
-
-//MMX versions
-#undef RENAME
-#undef HAVE_MMX2
-#undef HAVE_AMD3DNOW
-#define HAVE_MMX2 0
-#define HAVE_AMD3DNOW 0
-#define RENAME(a) a ## _MMX
-#include "yuv2rgb_template.c"
-
-//MMX2 versions
-#undef RENAME
-#undef HAVE_MMX2
-#define HAVE_MMX2 1
-#define RENAME(a) a ## _MMX2
-#include "yuv2rgb_template.c"
-
-#endif /* HAVE_MMX && CONFIG_GPL */
-
 const int32_t ff_yuv2rgb_coeffs[8][4] = {
     {117504, 138453, 13954, 34903}, /* no sequence_display_extension */
     {117504, 138453, 13954, 34903}, /* ITU-R Rec. 709 (1990) */
@@ -101,12 +74,18 @@
     Y = src[2*i+1];                                          \
     dst[6*i+3] = b[Y]; dst[6*i+4] = g[Y]; dst[6*i+5] = r[Y];
 
-#define YUV2RGBFUNC(func_name, dst_type) \
+#define PUTRGBA(dst,ysrc,asrc,i,o,s)                    \
+    Y = ysrc[2*i+o];                                    \
+    dst[2*i  ] = r[Y] + g[Y] + b[Y] + (asrc[2*i  ]<<s); \
+    Y = ysrc[2*i+1-o];                                  \
+    dst[2*i+1] = r[Y] + g[Y] + b[Y] + (asrc[2*i+1]<<s);
+
+#define YUV2RGBFUNC(func_name, dst_type, alpha) \
 static int func_name(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, \
                      int srcSliceH, uint8_t* dst[], int dstStride[]){\
     int y;\
 \
-    if (c->srcFormat == PIX_FMT_YUV422P) {\
+    if (!alpha && c->srcFormat == PIX_FMT_YUV422P) {\
         srcStride[1] *= 2;\
         srcStride[2] *= 2;\
     }\
@@ -119,7 +98,12 @@
         uint8_t *py_2 = py_1 + srcStride[0];\
         uint8_t *pu = src[1] + (y>>1)*srcStride[1];\
         uint8_t *pv = src[2] + (y>>1)*srcStride[2];\
+        uint8_t av_unused *pa_1, *pa_2;\
         unsigned int h_size = c->dstW>>3;\
+        if (alpha){\
+            pa_1 = src[3] + y*srcStride[3];\
+            pa_2 = pa_1 + srcStride[3];\
+        }\
         while (h_size--) {\
             int av_unused U, V;\
             int Y;\
@@ -145,7 +129,7 @@
     ENDYUV2RGBLINE(dst_delta)\
     ENDYUV2RGBFUNC()
 
-YUV2RGBFUNC(yuv2rgb_c_32, uint32_t)
+YUV2RGBFUNC(yuv2rgb_c_32, uint32_t, 0)
     LOADCHROMA(0);
     PUTRGB(dst_1,py_1,0,0);
     PUTRGB(dst_2,py_2,0,1);
@@ -174,7 +158,69 @@
     PUTRGB(dst_1,py_1,1,0);
 ENDYUV2RGBFUNC()
 
-YUV2RGBFUNC(yuv2rgb_c_24_rgb, uint8_t)
+YUV2RGBFUNC(yuva2rgba_c, uint32_t, 1)
+    LOADCHROMA(0);
+    PUTRGBA(dst_1,py_1,pa_1,0,0,24);
+    PUTRGBA(dst_2,py_2,pa_2,0,1,24);
+
+    LOADCHROMA(1);
+    PUTRGBA(dst_2,py_2,pa_1,1,1,24);
+    PUTRGBA(dst_1,py_1,pa_2,1,0,24);
+    LOADCHROMA(1);
+    PUTRGBA(dst_2,py_2,pa_1,1,1,24);
+    PUTRGBA(dst_1,py_1,pa_2,1,0,24);
+
+    LOADCHROMA(2);
+    PUTRGBA(dst_1,py_1,pa_1,2,0,24);
+    PUTRGBA(dst_2,py_2,pa_2,2,1,24);
+
+    LOADCHROMA(3);
+    PUTRGBA(dst_2,py_2,pa_1,3,1,24);
+    PUTRGBA(dst_1,py_1,pa_2,3,0,24);
+    pa_1 += 8;\
+    pa_2 += 8;\
+ENDYUV2RGBLINE(8)
+    LOADCHROMA(0);
+    PUTRGBA(dst_1,py_1,pa_1,0,0,24);
+    PUTRGBA(dst_2,py_2,pa_2,0,1,24);
+
+    LOADCHROMA(1);
+    PUTRGBA(dst_2,py_2,pa_1,1,1,24);
+    PUTRGBA(dst_1,py_1,pa_2,1,0,24);
+ENDYUV2RGBFUNC()
+
+YUV2RGBFUNC(yuva2argb_c, uint32_t, 1)
+    LOADCHROMA(0);
+    PUTRGBA(dst_1,py_1,pa_1,0,0,0);
+    PUTRGBA(dst_2,py_2,pa_2,0,1,0);
+
+    LOADCHROMA(1);
+    PUTRGBA(dst_2,py_2,pa_2,1,1,0);
+    PUTRGBA(dst_1,py_1,pa_1,1,0,0);
+    LOADCHROMA(1);
+    PUTRGBA(dst_2,py_2,pa_2,1,1,0);
+    PUTRGBA(dst_1,py_1,pa_1,1,0,0);
+
+    LOADCHROMA(2);
+    PUTRGBA(dst_1,py_1,pa_1,2,0,0);
+    PUTRGBA(dst_2,py_2,pa_2,2,1,0);
+
+    LOADCHROMA(3);
+    PUTRGBA(dst_2,py_2,pa_2,3,1,0);
+    PUTRGBA(dst_1,py_1,pa_1,3,0,0);
+    pa_1 += 8;\
+    pa_2 += 8;\
+ENDYUV2RGBLINE(8)
+    LOADCHROMA(0);
+    PUTRGBA(dst_1,py_1,pa_1,0,0,0);
+    PUTRGBA(dst_2,py_2,pa_2,0,1,0);
+
+    LOADCHROMA(1);
+    PUTRGBA(dst_2,py_2,pa_2,1,1,0);
+    PUTRGBA(dst_1,py_1,pa_1,1,0,0);
+ENDYUV2RGBFUNC()
+
+YUV2RGBFUNC(yuv2rgb_c_24_rgb, uint8_t, 0)
     LOADCHROMA(0);
     PUTRGB24(dst_1,py_1,0);
     PUTRGB24(dst_2,py_2,0);
@@ -201,7 +247,7 @@
 ENDYUV2RGBFUNC()
 
 // only trivial mods from yuv2rgb_c_24_rgb
-YUV2RGBFUNC(yuv2rgb_c_24_bgr, uint8_t)
+YUV2RGBFUNC(yuv2rgb_c_24_bgr, uint8_t, 0)
     LOADCHROMA(0);
     PUTBGR24(dst_1,py_1,0);
     PUTBGR24(dst_2,py_2,0);
@@ -229,7 +275,7 @@
 
 // This is exactly the same code as yuv2rgb_c_32 except for the types of
 // r, g, b, dst_1, dst_2
-YUV2RGBFUNC(yuv2rgb_c_16, uint16_t)
+YUV2RGBFUNC(yuv2rgb_c_16, uint16_t, 0)
     LOADCHROMA(0);
     PUTRGB(dst_1,py_1,0,0);
     PUTRGB(dst_2,py_2,0,1);
@@ -249,7 +295,7 @@
 
 // This is exactly the same code as yuv2rgb_c_32 except for the types of
 // r, g, b, dst_1, dst_2
-YUV2RGBFUNC(yuv2rgb_c_8, uint8_t)
+YUV2RGBFUNC(yuv2rgb_c_8, uint8_t, 0)
     LOADCHROMA(0);
     PUTRGB(dst_1,py_1,0,0);
     PUTRGB(dst_2,py_2,0,1);
@@ -268,7 +314,7 @@
 CLOSEYUV2RGBFUNC(8)
 
 // r, g, b, dst_1, dst_2
-YUV2RGBFUNC(yuv2rgb_c_8_ordered_dither, uint8_t)
+YUV2RGBFUNC(yuv2rgb_c_8_ordered_dither, uint8_t, 0)
     const uint8_t *d32 = dither_8x8_32[y&7];
     const uint8_t *d64 = dither_8x8_73[y&7];
 #define PUTRGB8(dst,src,i,o)                                    \
@@ -297,7 +343,7 @@
 
 // This is exactly the same code as yuv2rgb_c_32 except for the types of
 // r, g, b, dst_1, dst_2
-YUV2RGBFUNC(yuv2rgb_c_4, uint8_t)
+YUV2RGBFUNC(yuv2rgb_c_4, uint8_t, 0)
     int acc;
 #define PUTRGB4(dst,src,i)          \
     Y = src[2*i];                   \
@@ -323,7 +369,7 @@
     PUTRGB4(dst_1,py_1,3);
 CLOSEYUV2RGBFUNC(4)
 
-YUV2RGBFUNC(yuv2rgb_c_4_ordered_dither, uint8_t)
+YUV2RGBFUNC(yuv2rgb_c_4_ordered_dither, uint8_t, 0)
     const uint8_t *d64 =  dither_8x8_73[y&7];
     const uint8_t *d128 = dither_8x8_220[y&7];
     int acc;
@@ -354,7 +400,7 @@
 
 // This is exactly the same code as yuv2rgb_c_32 except for the types of
 // r, g, b, dst_1, dst_2
-YUV2RGBFUNC(yuv2rgb_c_4b, uint8_t)
+YUV2RGBFUNC(yuv2rgb_c_4b, uint8_t, 0)
     LOADCHROMA(0);
     PUTRGB(dst_1,py_1,0,0);
     PUTRGB(dst_2,py_2,0,1);
@@ -372,7 +418,7 @@
     PUTRGB(dst_1,py_1,3,0);
 CLOSEYUV2RGBFUNC(8)
 
-YUV2RGBFUNC(yuv2rgb_c_4b_ordered_dither, uint8_t)
+YUV2RGBFUNC(yuv2rgb_c_4b_ordered_dither, uint8_t, 0)
     const uint8_t *d64 =  dither_8x8_73[y&7];
     const uint8_t *d128 = dither_8x8_220[y&7];
 
@@ -399,7 +445,7 @@
     PUTRGB4DB(dst_1,py_1,3,6);
 CLOSEYUV2RGBFUNC(8)
 
-YUV2RGBFUNC(yuv2rgb_c_1_ordered_dither, uint8_t)
+YUV2RGBFUNC(yuv2rgb_c_1_ordered_dither, uint8_t, 0)
         const uint8_t *d128 = dither_8x8_220[y&7];
         char out_1 = 0, out_2 = 0;
         g= c->table_gU[128] + c->table_gV[128];
@@ -426,41 +472,26 @@
     dst_2[0]= out_2;
 CLOSEYUV2RGBFUNC(1)
 
-SwsFunc sws_yuv2rgb_get_func_ptr(SwsContext *c)
+SwsFunc ff_yuv2rgb_get_func_ptr(SwsContext *c)
 {
     SwsFunc t = NULL;
 #if (HAVE_MMX2 || HAVE_MMX) && CONFIG_GPL
-    if (c->flags & SWS_CPU_CAPS_MMX2) {
-        switch (c->dstFormat) {
-        case PIX_FMT_RGB32:  return yuv420_rgb32_MMX2;
-        case PIX_FMT_BGR24:  return yuv420_rgb24_MMX2;
-        case PIX_FMT_RGB565: return yuv420_rgb16_MMX2;
-        case PIX_FMT_RGB555: return yuv420_rgb15_MMX2;
-        }
-    }
-    if (c->flags & SWS_CPU_CAPS_MMX) {
-        switch (c->dstFormat) {
-        case PIX_FMT_RGB32:  return yuv420_rgb32_MMX;
-        case PIX_FMT_BGR24:  return yuv420_rgb24_MMX;
-        case PIX_FMT_RGB565: return yuv420_rgb16_MMX;
-        case PIX_FMT_RGB555: return yuv420_rgb15_MMX;
-        }
-    }
+     t = ff_yuv2rgb_init_mmx(c);
 #endif
 #if HAVE_VIS
-    t = sws_yuv2rgb_init_vis(c);
+    t = ff_yuv2rgb_init_vis(c);
 #endif
 #if CONFIG_MLIB
-    t = sws_yuv2rgb_init_mlib(c);
+    t = ff_yuv2rgb_init_mlib(c);
 #endif
-#if HAVE_ALTIVEC
+#if HAVE_ALTIVEC && CONFIG_GPL
     if (c->flags & SWS_CPU_CAPS_ALTIVEC)
-        t = sws_yuv2rgb_init_altivec(c);
+        t = ff_yuv2rgb_init_altivec(c);
 #endif
 
 #if ARCH_BFIN
     if (c->flags & SWS_CPU_CAPS_BFIN)
-        t = sws_ff_bfin_yuv2rgb_get_func_ptr(c);
+        t = ff_yuv2rgb_get_func_ptr_bfin(c);
 #endif
 
     if (t)
@@ -469,10 +500,10 @@
     av_log(c, AV_LOG_WARNING, "No accelerated colorspace conversion found.\n");
 
     switch (c->dstFormat) {
-    case PIX_FMT_BGR32_1:
-    case PIX_FMT_RGB32_1:
-    case PIX_FMT_BGR32:
-    case PIX_FMT_RGB32:      return yuv2rgb_c_32;
+    case PIX_FMT_ARGB:
+    case PIX_FMT_ABGR:       if (CONFIG_SWSCALE_ALPHA && c->srcFormat == PIX_FMT_YUVA420P) return yuva2argb_c;
+    case PIX_FMT_RGBA:
+    case PIX_FMT_BGRA:       return (CONFIG_SWSCALE_ALPHA && c->srcFormat == PIX_FMT_YUVA420P) ? yuva2rgba_c : yuv2rgb_c_32;
     case PIX_FMT_RGB24:      return yuv2rgb_c_24_rgb;
     case PIX_FMT_BGR24:      return yuv2rgb_c_24_bgr;
     case PIX_FMT_RGB565:
@@ -517,8 +548,8 @@
     }
 }
 
-av_cold int sws_yuv2rgb_c_init_tables(SwsContext *c, const int inv_table[4], int fullRange,
-                                      int brightness, int contrast, int saturation)
+av_cold int ff_yuv2rgb_c_init_tables(SwsContext *c, const int inv_table[4], int fullRange,
+                                     int brightness, int contrast, int saturation)
 {
     const int isRgb =      c->dstFormat==PIX_FMT_RGB32
                         || c->dstFormat==PIX_FMT_RGB32_1
@@ -533,7 +564,7 @@
     uint8_t *y_table;
     uint16_t *y_table16;
     uint32_t *y_table32;
-    int i, base, rbase, gbase, bbase, abase;
+    int i, base, rbase, gbase, bbase, abase, needAlpha;
     const int yoffs = fullRange ? 384 : 326;
 
     int64_t crv =  inv_table[0];
@@ -659,13 +690,15 @@
         rbase = base + (isRgb ? 16 : 0);
         gbase = base + 8;
         bbase = base + (isRgb ? 0 : 16);
-        abase = (base + 24) & 31;
+        needAlpha = CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat);
+        if (!needAlpha)
+            abase = (base + 24) & 31;
         c->yuvTable = av_malloc(1024*3*4);
         y_table32 = c->yuvTable;
         yb = -(384<<16) - oy;
         for (i = 0; i < 1024; i++) {
             uint8_t yval = av_clip_uint8((yb + 0x8000) >> 16);
-            y_table32[i     ] = (yval << rbase) + (255 << abase);
+            y_table32[i     ] = (yval << rbase) + (needAlpha ? 0 : (255 << abase));
             y_table32[i+1024] = yval << gbase;
             y_table32[i+2048] = yval << bbase;
             yb += cy;
diff --git a/libswscale/yuv2rgb_bfin.c b/libswscale/yuv2rgb_bfin.c
deleted file mode 100644
index 58cc5b6..0000000
--- a/libswscale/yuv2rgb_bfin.c
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * Copyright (C) 2007 Marc Hoffman <marc.hoffman@analog.com>
- *
- * Blackfin video color space converter operations
- * convert I420 YV12 to RGB in various formats
- *
- * 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 <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <inttypes.h>
-#include <assert.h>
-#include "config.h"
-#include <unistd.h>
-#include "rgb2rgb.h"
-#include "swscale.h"
-#include "swscale_internal.h"
-
-#ifdef __FDPIC__
-#define L1CODE __attribute__ ((l1_text))
-#else
-#define L1CODE
-#endif
-
-void ff_bfin_yuv2rgb555_line (uint8_t *Y, uint8_t *U, uint8_t *V, uint8_t *out,
-                              int w, uint32_t *coeffs) L1CODE;
-
-void ff_bfin_yuv2rgb565_line (uint8_t *Y, uint8_t *U, uint8_t *V, uint8_t *out,
-                              int w, uint32_t *coeffs) L1CODE;
-
-void ff_bfin_yuv2rgb24_line (uint8_t *Y, uint8_t *U, uint8_t *V, uint8_t *out,
-                             int w, uint32_t *coeffs) L1CODE;
-
-typedef void (* ltransform)(uint8_t *Y, uint8_t *U, uint8_t *V, uint8_t *out,
-                            int w, uint32_t *coeffs);
-
-
-static void bfin_prepare_coefficients (SwsContext *c, int rgb, int masks)
-{
-    int oy;
-    oy      = c->yOffset&0xffff;
-    oy      = oy >> 3; // keep everything U8.0 for offset calculation
-
-    c->oc   = 128*0x01010101U;
-    c->oy   =  oy*0x01010101U;
-
-    /* copy 64bit vector coeffs down to 32bit vector coeffs */
-    c->cy  = c->yCoeff;
-    c->zero = 0;
-
-    if (rgb) {
-        c->crv = c->vrCoeff;
-        c->cbu = c->ubCoeff;
-        c->cgu = c->ugCoeff;
-        c->cgv = c->vgCoeff;
-    } else {
-        c->crv = c->ubCoeff;
-        c->cbu = c->vrCoeff;
-        c->cgu = c->vgCoeff;
-        c->cgv = c->ugCoeff;
-    }
-
-
-    if (masks == 555) {
-        c->rmask = 0x001f * 0x00010001U;
-        c->gmask = 0x03e0 * 0x00010001U;
-        c->bmask = 0x7c00 * 0x00010001U;
-    } else if (masks == 565) {
-        c->rmask = 0x001f * 0x00010001U;
-        c->gmask = 0x07e0 * 0x00010001U;
-        c->bmask = 0xf800 * 0x00010001U;
-    }
-}
-
-static int core_yuv420_rgb (SwsContext *c,
-                            uint8_t **in, int *instrides,
-                            int srcSliceY, int srcSliceH,
-                            uint8_t **oplanes, int *outstrides,
-                            ltransform lcscf, int rgb, int masks)
-{
-    uint8_t *py,*pu,*pv,*op;
-    int w  = instrides[0];
-    int h2 = srcSliceH>>1;
-    int i;
-
-    bfin_prepare_coefficients (c, rgb, masks);
-
-    py = in[0];
-    pu = in[1+(1^rgb)];
-    pv = in[1+(0^rgb)];
-
-    op = oplanes[0] + srcSliceY*outstrides[0];
-
-    for (i=0;i<h2;i++) {
-
-        lcscf (py, pu, pv, op, w, &c->oy);
-
-        py += instrides[0];
-        op += outstrides[0];
-
-        lcscf (py, pu, pv, op, w, &c->oy);
-
-        py += instrides[0];
-        pu += instrides[1];
-        pv += instrides[2];
-        op += outstrides[0];
-    }
-
-    return srcSliceH;
-}
-
-
-static int bfin_yuv420_rgb555 (SwsContext *c,
-                               uint8_t **in, int *instrides,
-                               int srcSliceY, int srcSliceH,
-                               uint8_t **oplanes, int *outstrides)
-{
-    return core_yuv420_rgb (c, in, instrides, srcSliceY, srcSliceH, oplanes, outstrides,
-                            ff_bfin_yuv2rgb555_line, 1, 555);
-}
-
-static int bfin_yuv420_bgr555 (SwsContext *c,
-                               uint8_t **in, int *instrides,
-                               int srcSliceY, int srcSliceH,
-                               uint8_t **oplanes, int *outstrides)
-{
-    return core_yuv420_rgb (c, in, instrides, srcSliceY, srcSliceH, oplanes, outstrides,
-                            ff_bfin_yuv2rgb555_line, 0, 555);
-}
-
-static int bfin_yuv420_rgb24 (SwsContext *c,
-                              uint8_t **in, int *instrides,
-                              int srcSliceY, int srcSliceH,
-                              uint8_t **oplanes, int *outstrides)
-{
-    return core_yuv420_rgb (c, in, instrides, srcSliceY, srcSliceH, oplanes, outstrides,
-                            ff_bfin_yuv2rgb24_line, 1, 888);
-}
-
-static int bfin_yuv420_bgr24 (SwsContext *c,
-                              uint8_t **in, int *instrides,
-                              int srcSliceY, int srcSliceH,
-                              uint8_t **oplanes, int *outstrides)
-{
-    return core_yuv420_rgb (c, in, instrides, srcSliceY, srcSliceH, oplanes, outstrides,
-                            ff_bfin_yuv2rgb24_line, 0, 888);
-}
-
-static int bfin_yuv420_rgb565 (SwsContext *c,
-                               uint8_t **in, int *instrides,
-                               int srcSliceY, int srcSliceH,
-                               uint8_t **oplanes, int *outstrides)
-{
-    return core_yuv420_rgb (c, in, instrides, srcSliceY, srcSliceH, oplanes, outstrides,
-                            ff_bfin_yuv2rgb565_line, 1, 565);
-}
-
-static int bfin_yuv420_bgr565 (SwsContext *c,
-                               uint8_t **in, int *instrides,
-                               int srcSliceY, int srcSliceH,
-                               uint8_t **oplanes, int *outstrides)
-{
-    return core_yuv420_rgb (c, in, instrides, srcSliceY, srcSliceH, oplanes, outstrides,
-                            ff_bfin_yuv2rgb565_line, 0, 565);
-}
-
-
-SwsFunc ff_bfin_yuv2rgb_get_func_ptr (SwsContext *c)
-{
-    SwsFunc f;
-
-    switch(c->dstFormat) {
-    case PIX_FMT_RGB555: f = bfin_yuv420_rgb555; break;
-    case PIX_FMT_BGR555: f = bfin_yuv420_bgr555; break;
-    case PIX_FMT_RGB565: f = bfin_yuv420_rgb565; break;
-    case PIX_FMT_BGR565: f = bfin_yuv420_bgr565; break;
-    case PIX_FMT_RGB24:  f = bfin_yuv420_rgb24;  break;
-    case PIX_FMT_BGR24:  f = bfin_yuv420_bgr24;  break;
-    default:
-        return 0;
-    }
-
-    av_log(c, AV_LOG_INFO, "BlackFin accelerated color space converter %s\n",
-           sws_format_name (c->dstFormat));
-
-    return f;
-}
diff --git a/output_example.c b/output_example.c
old mode 100644
new mode 100755
diff --git a/subdir.mak b/subdir.mak
old mode 100644
new mode 100755
index a5f83c5..997f552
--- a/subdir.mak
+++ b/subdir.mak
@@ -27,9 +27,9 @@
 $(SUBDIR)$(SLIBNAME): $(SUBDIR)$(SLIBNAME_WITH_MAJOR)
 	cd ./$(SUBDIR) && $(LN_S) $(SLIBNAME_WITH_MAJOR) $(SLIBNAME)
 
-$(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(OBJS) $(SUBDIR)lib$(NAME).ver
+$(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(OBJS)
 	$(SLIB_CREATE_DEF_CMD)
-	$(CC) $(SHFLAGS) $(FFLDFLAGS) -o $$@ $$(filter-out $(SUBDIR)lib$(NAME).ver $(DEP_LIBS),$$^) $(FFEXTRALIBS) $(EXTRAOBJS)
+	$(CC) $(SHFLAGS) $(FFLDFLAGS) -o $$@ $$(filter-out $(DEP_LIBS),$$^) $(FFEXTRALIBS) $(EXTRAOBJS)
 	$(SLIB_EXTRA_CMD)
 
 ifdef SUBDIR
@@ -39,7 +39,7 @@
 
 install-lib$(NAME)-shared: $(SUBDIR)$(SLIBNAME)
 	install -d "$(SHLIBDIR)"
-	install -m 755 $(SUBDIR)$(SLIBNAME) "$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)"
+	install -m 755 $$< "$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)"
 	$(STRIP) "$(SHLIBDIR)/$(SLIBNAME_WITH_VERSION)"
 	cd "$(SHLIBDIR)" && \
 		$(LN_S) $(SLIBNAME_WITH_VERSION) $(SLIBNAME_WITH_MAJOR)
@@ -49,7 +49,7 @@
 
 install-lib$(NAME)-static: $(SUBDIR)$(LIBNAME)
 	install -d "$(LIBDIR)"
-	install -m 644 $(SUBDIR)$(LIBNAME) "$(LIBDIR)"
+	install -m 644 $$< "$(LIBDIR)"
 	$(LIB_INSTALL_EXTRA_CMD)
 
 install-headers::
diff --git a/tests/audiogen.c b/tests/audiogen.c
old mode 100644
new mode 100755
diff --git a/tests/ffmpeg.regression.ref b/tests/ffmpeg.regression.ref
old mode 100644
new mode 100755
index 7db54e3..259d8ca
--- a/tests/ffmpeg.regression.ref
+++ b/tests/ffmpeg.regression.ref
@@ -118,12 +118,12 @@
 9086168 ./tests/data/a-jpegls.avi
 012717e7c928641410eaa6abaf126fdc *./tests/data/jpegls.vsynth.out.yuv
 stddev:    2.84 PSNR: 39.05 bytes:  7603200/  7603200
-99ef24bf57718fd29a7a91b22af2b3fe *./tests/data/a-rv10.rm
-667935 ./tests/data/a-rv10.rm
+1cc26cf6711df770e81bcfce36f28011 *./tests/data/a-rv10.rm
+667915 ./tests/data/a-rv10.rm
 d507be4253a9c8211a3738c58ba28118 *./tests/data/rv10.vsynth.out.yuv
 stddev:    8.06 PSNR: 29.99 bytes:  7603200/  7603200
-d1caf150a7b53db8fd5eb8c1d0701daf *./tests/data/a-rv20.rm
-640876 ./tests/data/a-rv20.rm
+02f1ec304a066c3bfb355adbdf4c5977 *./tests/data/a-rv20.rm
+640856 ./tests/data/a-rv20.rm
 297dc46da1a256c0a97158c036c30c7f *./tests/data/rv20.vsynth.out.yuv
 stddev:    8.26 PSNR: 29.77 bytes:  7603200/  7603200
 d13292f4583618d1b7b525a9ee010dff *./tests/data/a-asv1.avi
@@ -175,8 +175,8 @@
 83f8df5d5f84480566af548bb037fceb *./tests/data/mp2.vsynth.out.wav
 stddev: 9328.41 PSNR: 16.92 bytes:  1055276/  1058444
 stddev: 4394.71 PSNR: 23.46 bytes:  1053352/  1058444
-aefe11ab5067621a1c674859d6413891 *./tests/data/a-ac3.rm
-98203 ./tests/data/a-ac3.rm
+3bfe347421de458dbfe572b8d4047b46 *./tests/data/a-ac3.rm
+98183 ./tests/data/a-ac3.rm
 39878597b1d65cce473639a7d8c93b02 *./tests/data/a-g726.wav
 24279 ./tests/data/a-g726.wav
 888f2f016e608d044a1bacbca5497ed2 *./tests/data/g726.vsynth.out.wav
diff --git a/tests/ffserver.regression.ref b/tests/ffserver.regression.ref
old mode 100644
new mode 100755
index a99da76..9fc7497
--- a/tests/ffserver.regression.ref
+++ b/tests/ffserver.regression.ref
@@ -1,10 +1,10 @@
 18c4ba0e8e7adb781216e38de61c2e39  ff-test_h.avi
-4f11d850f564af3359951b46ed1e571e  ff-test_l.avi
+f84767c7af61f360f4b443c2c73f322f  ff-test_l.avi
 d976848a9e4d5d8fc2659e4841cdece5  ff-test.swf
-37ccf79cb3a50fda99173e5ba4b44d55  ff-test_h.asf
-3e2bff2fda1fe2ed334e639aa6839f0c  ff-test_l.asf
-60550d751dfa5172d878f7dd670e3aa4  ff-test_h.rm
-6218946abd1c4af92f05a8a6208b1e1c  ff-test_l.rm
+28fd87d5075b9b011aad57292f271a04  ff-test_h.asf
+a31ccd3aba2551e60b9fb1c156fca2f8  ff-test_l.asf
+3279d3ed0ef2d1347b5eda84db2cf3e6  ff-test_h.rm
+440231fe3cf0849887390b4d67d6894a  ff-test_l.rm
 e0dc91430660c619e97b5c82e0f398fc  ff-test.jpg
-84b9702e34b9e21a84bb29519fc1e3cc  ff-test_small.jpg
-a22cc793b9f938cc05cd0c56ccf9423c  ff-test.mjpg
+0d6c98fc8a4f00560fe34e94e26880a9  ff-test_small.jpg
+e2a315d7ac0576279f8b4d917999615a  ff-test.mjpg
diff --git a/tests/lena.pnm b/tests/lena.pnm
old mode 100644
new mode 100755
Binary files differ
diff --git a/tests/libav.regression.ref b/tests/libav.regression.ref
old mode 100644
new mode 100755
index f8c945f..972507e
--- a/tests/libav.regression.ref
+++ b/tests/libav.regression.ref
@@ -4,18 +4,24 @@
 bd9e0012aa39e956605387dd499365fb *./tests/data/b-libav.asf
 339775 ./tests/data/b-libav.asf
 ./tests/data/b-libav.asf CRC=0x74113749
-c351132527ccb1e8cab06cc0822fde23 *./tests/data/b-libav.rm
-355417 ./tests/data/b-libav.rm
+db5797d4c00c8b15e2e44216389be591 *./tests/data/b-libav.rm
+355387 ./tests/data/b-libav.rm
 bdb7484c68db722f66ba1630cf79844c *./tests/data/b-libav.mpg
 378880 ./tests/data/b-libav.mpg
 ./tests/data/b-libav.mpg CRC=0x2b71a386
+259a87c8d22aab76665047ecdbfa9267 *./tests/data/b-libav.mxf
+535097 ./tests/data/b-libav.mxf
+./tests/data/b-libav.mxf CRC=0xd7ff387d
+0a7cc51de3da754ce36dffeeda290c45 *./tests/data/b-libav.mxf_d10
+5330989 ./tests/data/b-libav.mxf_d10
+./tests/data/b-libav.mxf_d10 CRC=0xd241c8b6
 c0cc2ae4df6a8b3df84986929a393116 *./tests/data/b-libav.ts
 471316 ./tests/data/b-libav.ts
 ./tests/data/b-libav.ts CRC=0xcc4948e1
 1b28a16652bb8ac528b33f7478ca18b6 *./tests/data/b-libav.swf
 335771 ./tests/data/b-libav.swf
 ./tests/data/b-libav.swf CRC=0xe14e8847
-3dbacdc3fccb551f8ab54c32f648e7a8 *./tests/data/b-libav.ffm
+49d04c063b7741d3ee8f85c92baa69bf *./tests/data/b-libav.ffm
 380928 ./tests/data/b-libav.ffm
 ./tests/data/b-libav.ffm CRC=0x2b71a386
 8617c30b4e862199555fd75890473e66 *./tests/data/b-libav.flv
@@ -27,8 +33,8 @@
 913b6199765b1dcba196706574621c2f *./tests/data/b-libav.dv
 3600000 ./tests/data/b-libav.dv
 ./tests/data/b-libav.dv CRC=0x7787e173
-8441d11ebee0465f1a672586485f3506 *./tests/data/b-libav.gxf
-805996 ./tests/data/b-libav.gxf
+1623fca05b137d378bffd5050bcb9eb3 *./tests/data/b-libav.gxf
+810268 ./tests/data/b-libav.gxf
 ./tests/data/b-libav.gxf CRC=0x9c06676e
 66a6584f9e83e8ea3af822a3ba71fbbe *./tests/data/b-libav.nut
 329264 ./tests/data/b-libav.nut
@@ -41,7 +47,7 @@
 ./tests/data/b-pbmpipe.pbm CRC=0x806e17d8
 aff140ce80a1c86c1bf54118ad23da7b *./tests/data/b-pgmpipe.pgm
 2534775 ./tests/data/b-pgmpipe.pgm
-./tests/data/b-pgmpipe.pgm CRC=0x0e82c482
+./tests/data/b-pgmpipe.pgm CRC=0xf485870f
 9169b1f1ca56f01a6e1f5041572aa1d4 *./tests/data/b-ppmpipe.ppm
 7603575 ./tests/data/b-ppmpipe.ppm
 ./tests/data/b-ppmpipe.ppm CRC=0x79bd6ce6
@@ -50,7 +56,7 @@
 b977a4fedff90a79baf70c8e02986820 *./tests/data/b-libav.y4m
 3801810 ./tests/data/b-libav.y4m
 0a6d74b54396884f117669965b57d3b5 *./tests/data/b-libav02.pgm
-./tests/data/b-libav%02d.pgm CRC=0xc8032eb1
+./tests/data/b-libav%02d.pgm CRC=0x7e552eb1
 101391 ./tests/data/b-libav02.pgm
 dbe42bd8d9ca0acbd2673bd739705f0f *./tests/data/b-libav02.ppm
 ./tests/data/b-libav%02d.ppm CRC=0x6f775c0d
@@ -91,7 +97,7 @@
 8d117c49d6b210abe783d1b0b897cec7 *./tests/data/b-libav.voc
 32768 ./tests/data/b-libav.voc
 ./tests/data/b-libav.voc CRC=0x49972c8c
-9268c90bd2623a5ab3c2a1a751826f69 *./tests/data/b-libav.ogg
+767a75e9abf9754bfdc880d6faed69cf *./tests/data/b-libav.ogg
 14210 ./tests/data/b-libav.ogg
 ./tests/data/b-libav.ogg CRC=0x37a143ea
 52bb2f530036c657edc512965258d735 *./tests/data/b-libav-yuv420p.yuv
@@ -132,3 +138,6 @@
 304128 ./tests/data/b-libav-yuv440p.yuv
 10c8507ad38d0ce5e8cd0f1dd49b0d26 *./tests/data/b-libav-yuvj440p.yuv
 304128 ./tests/data/b-libav-yuvj440p.yuv
+574fb8fe0b2fe8cc0b3ded8549c052d4 *./tests/data/b-libav02.pcx
+./tests/data/b-libav%02d.pcx CRC=0x6f775c0d
+363436 ./tests/data/b-libav02.pcx
diff --git a/tests/regression.sh b/tests/regression.sh
index 529a703..888860f 100755
--- a/tests/regression.sh
+++ b/tests/regression.sh
@@ -499,6 +499,11 @@
 do_libav mpg
 fi
 
+if [ -n "$do_mxf" ] ; then
+do_libav mxf "-ar 48000 -bf 2 -timecode_frame_start 264363"
+do_libav mxf_d10 "-ar 48000 -ac 2 -r 25 -s 720x576 -padtop 32 -vcodec mpeg2video -intra -flags +ildct+low_delay -dc 10 -flags2 +ivlc+non_linear_q -qscale 1 -ps 1 -qmin 1 -rc_max_vbv_use 1 -rc_min_vbv_use 1 -pix_fmt yuv422p -minrate 30000k -maxrate 30000k -b 30000k -bufsize 1200000 -top 1 -rc_init_occupancy 1200000 -qmax 12 -f mxf_d10"
+fi
+
 if [ -n "$do_ts" ] ; then
 do_libav ts
 fi
@@ -596,6 +601,10 @@
 do_image_formats jpg "-flags +bitexact -dct fastint -idct simple -pix_fmt yuvj420p" "-f image2"
 fi
 
+if [ -n "$do_pcx" ] ; then
+do_image_formats pcx
+fi
+
 # audio only
 
 if [ -n "$do_wav" ] ; then
diff --git a/tests/rotozoom.c b/tests/rotozoom.c
old mode 100644
new mode 100755
diff --git a/tests/rotozoom.regression.ref b/tests/rotozoom.regression.ref
old mode 100644
new mode 100755
index fc1ee65..2e64893
--- a/tests/rotozoom.regression.ref
+++ b/tests/rotozoom.regression.ref
@@ -118,12 +118,12 @@
 8334630 ./tests/data/a-jpegls.avi
 592b3321994e26a990deb3a0a1415de9 *./tests/data/jpegls.rotozoom.out.yuv
 stddev:    0.65 PSNR: 51.83 bytes:  7603200/  7603200
-989a42671603dc1a7e6b156dccf0e820 *./tests/data/a-rv10.rm
-154330 ./tests/data/a-rv10.rm
+b1467b0e8d8cad730e36d1e8ab49d573 *./tests/data/a-rv10.rm
+154310 ./tests/data/a-rv10.rm
 61213b91b359697ebcefb9e0a53ac54a *./tests/data/rv10.rotozoom.out.yuv
 stddev:    5.43 PSNR: 33.41 bytes:  7603200/  7603200
-1b1cbff8e78602de498b4314cb991e72 *./tests/data/a-rv20.rm
-132754 ./tests/data/a-rv20.rm
+d864475aa16d84dd99de13e65003672a *./tests/data/a-rv20.rm
+132734 ./tests/data/a-rv20.rm
 c66afdcc0daac2f1b4167b9811968877 *./tests/data/rv20.rotozoom.out.yuv
 stddev:    5.42 PSNR: 33.44 bytes:  7603200/  7603200
 4eb34d2de25f67a2706456e999338fe9 *./tests/data/a-asv1.avi
@@ -175,8 +175,8 @@
 83f8df5d5f84480566af548bb037fceb *./tests/data/mp2.rotozoom.out.wav
 stddev: 9328.41 PSNR: 16.92 bytes:  1055276/  1058444
 stddev: 4394.71 PSNR: 23.46 bytes:  1053352/  1058444
-aefe11ab5067621a1c674859d6413891 *./tests/data/a-ac3.rm
-98203 ./tests/data/a-ac3.rm
+3bfe347421de458dbfe572b8d4047b46 *./tests/data/a-ac3.rm
+98183 ./tests/data/a-ac3.rm
 39878597b1d65cce473639a7d8c93b02 *./tests/data/a-g726.wav
 24279 ./tests/data/a-g726.wav
 888f2f016e608d044a1bacbca5497ed2 *./tests/data/g726.rotozoom.out.wav
diff --git a/tests/seek.regression.ref b/tests/seek.regression.ref
index 3589b73..44166d0 100644
--- a/tests/seek.regression.ref
+++ b/tests/seek.regression.ref
@@ -42,19 +42,22 @@
 ----------------
 tests/data/a-adpcm_ima.wav
 ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:60 size:4096 flags:1
-ret:-1 st:-1 ts:-1.000000 flags:0
+ret: 0 st:-1 ts:-1.000000 flags:0
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:60 size:4096 flags:1
 ret: 0 st:-1 ts:1.894167 flags:1
 ret: 0 st: 0 dts:1.856009 pts:1.856009 pos:29756 size:4096 flags:1
 ret: 0 st: 0 ts:0.788345 flags:0
 ret: 0 st: 0 dts:0.831995 pts:0.831995 pos:13372 size:4096 flags:1
-ret:-1 st: 0 ts:-0.317506 flags:1
+ret: 0 st: 0 ts:-0.317506 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:60 size:4096 flags:1
 ret: 0 st:-1 ts:2.576668 flags:0
 ret: 0 st: 0 dts:2.623991 pts:2.623991 pos:42044 size:4096 flags:1
 ret: 0 st:-1 ts:1.470835 flags:1
 ret: 0 st: 0 dts:1.408005 pts:1.408005 pos:22588 size:4096 flags:1
 ret: 0 st: 0 ts:0.365011 flags:0
 ret: 0 st: 0 dts:0.383991 pts:0.383991 pos:6204 size:4096 flags:1
-ret:-1 st: 0 ts:-0.740839 flags:1
+ret: 0 st: 0 ts:-0.740839 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:60 size:4096 flags:1
 ret: 0 st:-1 ts:2.153336 flags:0
 ret: 0 st: 0 dts:2.176009 pts:2.176009 pos:34876 size:4096 flags:1
 ret: 0 st:-1 ts:1.047503 flags:1
@@ -67,89 +70,104 @@
 ret: 0 st: 0 dts:1.791995 pts:1.791995 pos:28732 size:4096 flags:1
 ret: 0 st:-1 ts:0.624171 flags:1
 ret: 0 st: 0 dts:0.576009 pts:0.576009 pos:9276 size:4096 flags:1
-ret:-1 st: 0 ts:-0.481655 flags:0
+ret: 0 st: 0 ts:-0.481655 flags:0
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:60 size:4096 flags:1
 ret: 0 st: 0 ts:2.412494 flags:1
 ret: 0 st: 0 dts:2.368005 pts:2.368005 pos:37948 size:4096 flags:1
 ret: 0 st:-1 ts:1.306672 flags:0
 ret: 0 st: 0 dts:1.343991 pts:1.343991 pos:21564 size:4096 flags:1
 ret: 0 st:-1 ts:0.200839 flags:1
 ret: 0 st: 0 dts:0.191995 pts:0.191995 pos:3132 size:4096 flags:1
-ret:-1 st: 0 ts:-0.904989 flags:0
+ret: 0 st: 0 ts:-0.904989 flags:0
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:60 size:4096 flags:1
 ret: 0 st: 0 ts:1.989184 flags:1
 ret: 0 st: 0 dts:1.983991 pts:1.983991 pos:31804 size:4096 flags:1
 ret: 0 st:-1 ts:0.883340 flags:0
 ret: 0 st: 0 dts:0.896009 pts:0.896009 pos:14396 size:4096 flags:1
-ret:-1 st:-1 ts:-0.222493 flags:1
+ret: 0 st:-1 ts:-0.222493 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:60 size:4096 flags:1
 ret: 0 st: 0 ts:2.671678 flags:0
 ret: 0 st: 0 dts:2.688005 pts:2.688005 pos:43068 size:4096 flags:1
 ret: 0 st: 0 ts:1.565850 flags:1
 ret: 0 st: 0 dts:1.536009 pts:1.536009 pos:24636 size:4096 flags:1
 ret: 0 st:-1 ts:0.460008 flags:0
 ret: 0 st: 0 dts:0.511995 pts:0.511995 pos:8252 size:4096 flags:1
-ret:-1 st:-1 ts:-0.645825 flags:1
+ret: 0 st:-1 ts:-0.645825 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:60 size:4096 flags:1
 ----------------
 tests/data/a-adpcm_qt.aiff
 ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:72 size:4080 flags:1
-ret:-1 st:-1 ts:-1.000000 flags:0
+ret: 0 st:-1 ts:-1.000000 flags:0
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:72 size:4080 flags:1
 ret: 0 st:-1 ts:1.894167 flags:1
 ret: 0 st: 0 dts:1.894059 pts:1.894059 pos:88812 size:4080 flags:1
 ret: 0 st: 0 ts:0.788345 flags:0
 ret: 0 st: 0 dts:0.789546 pts:0.789546 pos:37064 size:4080 flags:1
-ret:-1 st: 0 ts:-0.317506 flags:1
+ret: 0 st: 0 ts:-0.317506 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:72 size:4080 flags:1
 ret: 0 st:-1 ts:2.576668 flags:0
 ret: 0 st: 0 dts:2.577642 pts:2.577642 pos:120840 size:4080 flags:1
 ret: 0 st:-1 ts:1.470835 flags:1
 ret: 0 st: 0 dts:1.470249 pts:1.470249 pos:68956 size:4080 flags:1
 ret: 0 st: 0 ts:0.365011 flags:0
 ret: 0 st: 0 dts:0.365737 pts:0.365737 pos:17208 size:4080 flags:1
-ret:-1 st: 0 ts:-0.740839 flags:1
+ret: 0 st: 0 ts:-0.740839 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:72 size:4080 flags:1
 ret: 0 st:-1 ts:2.153336 flags:0
 ret: 0 st: 0 dts:2.153855 pts:2.153855 pos:100984 size:4080 flags:1
 ret: 0 st:-1 ts:1.047503 flags:1
 ret: 0 st: 0 dts:1.046440 pts:1.046440 pos:49100 size:4080 flags:1
-ret:-1 st: 0 ts:-0.058322 flags:0
+ret: 0 st: 0 ts:-0.058322 flags:0
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:72 size:4080 flags:1
 ret: 0 st: 0 ts:2.835828 flags:1
 ret: 0 st: 0 dts:2.834535 pts:2.834535 pos:132876 size:4080 flags:1
 ret: 0 st:-1 ts:1.730004 flags:0
 ret: 0 st: 0 dts:1.730045 pts:1.730045 pos:81128 size:4080 flags:1
 ret: 0 st:-1 ts:0.624171 flags:1
 ret: 0 st: 0 dts:0.624082 pts:0.624082 pos:29312 size:4080 flags:1
-ret:-1 st: 0 ts:-0.481655 flags:0
+ret: 0 st: 0 ts:-0.481655 flags:0
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:72 size:4080 flags:1
 ret: 0 st: 0 ts:2.412494 flags:1
 ret: 0 st: 0 dts:2.412200 pts:2.412200 pos:113088 size:4080 flags:1
 ret: 0 st:-1 ts:1.306672 flags:0
 ret: 0 st: 0 dts:1.307687 pts:1.307687 pos:61340 size:4080 flags:1
 ret: 0 st:-1 ts:0.200839 flags:1
 ret: 0 st: 0 dts:0.200295 pts:0.200295 pos:9456 size:4080 flags:1
-ret:-1 st: 0 ts:-0.904989 flags:0
+ret: 0 st: 0 ts:-0.904989 flags:0
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:72 size:4080 flags:1
 ret: 0 st: 0 ts:1.989184 flags:1
 ret: 0 st: 0 dts:1.988390 pts:1.988390 pos:93232 size:4080 flags:1
 ret: 0 st:-1 ts:0.883340 flags:0
 ret: 0 st: 0 dts:0.883900 pts:0.883900 pos:41484 size:4080 flags:1
-ret:-1 st:-1 ts:-0.222493 flags:1
+ret: 0 st:-1 ts:-0.222493 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:72 size:4080 flags:1
 ret: 0 st: 0 ts:2.671678 flags:0
 ret: 0 st: 0 dts:2.671995 pts:2.671995 pos:125260 size:4080 flags:1
 ret: 0 st: 0 ts:1.565850 flags:1
 ret: 0 st: 0 dts:1.564580 pts:1.564580 pos:73376 size:4080 flags:1
 ret: 0 st:-1 ts:0.460008 flags:0
 ret: 0 st: 0 dts:0.460091 pts:0.460091 pos:21628 size:4080 flags:1
-ret:-1 st:-1 ts:-0.645825 flags:1
+ret: 0 st:-1 ts:-0.645825 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:72 size:4080 flags:1
 ----------------
 tests/data/a-adpcm_ms.wav
 ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:56 size:4096 flags:1
-ret:-1 st:-1 ts:-1.000000 flags:0
+ret: 0 st:-1 ts:-1.000000 flags:0
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:56 size:4096 flags:1
 ret: 0 st:-1 ts:1.894167 flags:1
 ret: 0 st: 0 dts:1.856009 pts:1.856009 pos:29752 size:4096 flags:1
 ret: 0 st: 0 ts:0.788345 flags:0
 ret: 0 st: 0 dts:0.831995 pts:0.831995 pos:13368 size:4096 flags:1
-ret:-1 st: 0 ts:-0.317506 flags:1
+ret: 0 st: 0 ts:-0.317506 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:56 size:4096 flags:1
 ret: 0 st:-1 ts:2.576668 flags:0
 ret: 0 st: 0 dts:2.623991 pts:2.623991 pos:42040 size:4096 flags:1
 ret: 0 st:-1 ts:1.470835 flags:1
 ret: 0 st: 0 dts:1.408005 pts:1.408005 pos:22584 size:4096 flags:1
 ret: 0 st: 0 ts:0.365011 flags:0
 ret: 0 st: 0 dts:0.383991 pts:0.383991 pos:6200 size:4096 flags:1
-ret:-1 st: 0 ts:-0.740839 flags:1
+ret: 0 st: 0 ts:-0.740839 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:56 size:4096 flags:1
 ret: 0 st:-1 ts:2.153336 flags:0
 ret: 0 st: 0 dts:2.176009 pts:2.176009 pos:34872 size:4096 flags:1
 ret: 0 st:-1 ts:1.047503 flags:1
@@ -162,26 +180,30 @@
 ret: 0 st: 0 dts:1.791995 pts:1.791995 pos:28728 size:4096 flags:1
 ret: 0 st:-1 ts:0.624171 flags:1
 ret: 0 st: 0 dts:0.576009 pts:0.576009 pos:9272 size:4096 flags:1
-ret:-1 st: 0 ts:-0.481655 flags:0
+ret: 0 st: 0 ts:-0.481655 flags:0
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:56 size:4096 flags:1
 ret: 0 st: 0 ts:2.412494 flags:1
 ret: 0 st: 0 dts:2.368005 pts:2.368005 pos:37944 size:4096 flags:1
 ret: 0 st:-1 ts:1.306672 flags:0
 ret: 0 st: 0 dts:1.343991 pts:1.343991 pos:21560 size:4096 flags:1
 ret: 0 st:-1 ts:0.200839 flags:1
 ret: 0 st: 0 dts:0.191995 pts:0.191995 pos:3128 size:4096 flags:1
-ret:-1 st: 0 ts:-0.904989 flags:0
+ret: 0 st: 0 ts:-0.904989 flags:0
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:56 size:4096 flags:1
 ret: 0 st: 0 ts:1.989184 flags:1
 ret: 0 st: 0 dts:1.983991 pts:1.983991 pos:31800 size:4096 flags:1
 ret: 0 st:-1 ts:0.883340 flags:0
 ret: 0 st: 0 dts:0.896009 pts:0.896009 pos:14392 size:4096 flags:1
-ret:-1 st:-1 ts:-0.222493 flags:1
+ret: 0 st:-1 ts:-0.222493 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:56 size:4096 flags:1
 ret: 0 st: 0 ts:2.671678 flags:0
 ret: 0 st: 0 dts:2.688005 pts:2.688005 pos:43064 size:4096 flags:1
 ret: 0 st: 0 ts:1.565850 flags:1
 ret: 0 st: 0 dts:1.536009 pts:1.536009 pos:24632 size:4096 flags:1
 ret: 0 st:-1 ts:0.460008 flags:0
 ret: 0 st: 0 dts:0.511995 pts:0.511995 pos:8248 size:4096 flags:1
-ret:-1 st:-1 ts:-0.645825 flags:1
+ret: 0 st:-1 ts:-0.645825 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:56 size:4096 flags:1
 ----------------
 tests/data/a-adpcm_swf.flv
 ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:208 size:2053 flags:1
@@ -236,19 +258,22 @@
 ----------------
 tests/data/a-adpcm_yam.wav
 ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:56 size:4096 flags:1
-ret:-1 st:-1 ts:-1.000000 flags:0
+ret: 0 st:-1 ts:-1.000000 flags:0
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:56 size:4096 flags:1
 ret: 0 st:-1 ts:1.894167 flags:1
 ret: 0 st: 0 dts:1.856009 pts:1.856009 pos:29752 size:4096 flags:1
 ret: 0 st: 0 ts:0.788345 flags:0
 ret: 0 st: 0 dts:0.831995 pts:0.831995 pos:13368 size:4096 flags:1
-ret:-1 st: 0 ts:-0.317506 flags:1
+ret: 0 st: 0 ts:-0.317506 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:56 size:4096 flags:1
 ret: 0 st:-1 ts:2.576668 flags:0
 ret: 0 st: 0 dts:2.623991 pts:2.623991 pos:42040 size:4096 flags:1
 ret: 0 st:-1 ts:1.470835 flags:1
 ret: 0 st: 0 dts:1.408005 pts:1.408005 pos:22584 size:4096 flags:1
 ret: 0 st: 0 ts:0.365011 flags:0
 ret: 0 st: 0 dts:0.383991 pts:0.383991 pos:6200 size:4096 flags:1
-ret:-1 st: 0 ts:-0.740839 flags:1
+ret: 0 st: 0 ts:-0.740839 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:56 size:4096 flags:1
 ret: 0 st:-1 ts:2.153336 flags:0
 ret: 0 st: 0 dts:2.176009 pts:2.176009 pos:34872 size:4096 flags:1
 ret: 0 st:-1 ts:1.047503 flags:1
@@ -261,26 +286,30 @@
 ret: 0 st: 0 dts:1.791995 pts:1.791995 pos:28728 size:4096 flags:1
 ret: 0 st:-1 ts:0.624171 flags:1
 ret: 0 st: 0 dts:0.576009 pts:0.576009 pos:9272 size:4096 flags:1
-ret:-1 st: 0 ts:-0.481655 flags:0
+ret: 0 st: 0 ts:-0.481655 flags:0
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:56 size:4096 flags:1
 ret: 0 st: 0 ts:2.412494 flags:1
 ret: 0 st: 0 dts:2.368005 pts:2.368005 pos:37944 size:4096 flags:1
 ret: 0 st:-1 ts:1.306672 flags:0
 ret: 0 st: 0 dts:1.343991 pts:1.343991 pos:21560 size:4096 flags:1
 ret: 0 st:-1 ts:0.200839 flags:1
 ret: 0 st: 0 dts:0.191995 pts:0.191995 pos:3128 size:4096 flags:1
-ret:-1 st: 0 ts:-0.904989 flags:0
+ret: 0 st: 0 ts:-0.904989 flags:0
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:56 size:4096 flags:1
 ret: 0 st: 0 ts:1.989184 flags:1
 ret: 0 st: 0 dts:1.983991 pts:1.983991 pos:31800 size:4096 flags:1
 ret: 0 st:-1 ts:0.883340 flags:0
 ret: 0 st: 0 dts:0.896009 pts:0.896009 pos:14392 size:4096 flags:1
-ret:-1 st:-1 ts:-0.222493 flags:1
+ret: 0 st:-1 ts:-0.222493 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:56 size:4096 flags:1
 ret: 0 st: 0 ts:2.671678 flags:0
 ret: 0 st: 0 dts:2.688005 pts:2.688005 pos:43064 size:4096 flags:1
 ret: 0 st: 0 ts:1.565850 flags:1
 ret: 0 st: 0 dts:1.536009 pts:1.536009 pos:24632 size:4096 flags:1
 ret: 0 st:-1 ts:0.460008 flags:0
 ret: 0 st: 0 dts:0.511995 pts:0.511995 pos:8248 size:4096 flags:1
-ret:-1 st:-1 ts:-0.645825 flags:1
+ret: 0 st:-1 ts:-0.645825 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:56 size:4096 flags:1
 ----------------
 tests/data/a-asv1.avi
 ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:5668 size:14316 flags:1
@@ -585,31 +614,31 @@
 ret:-1 st:-1 ts:-0.645825 flags:1
 ----------------
 tests/data/a-flac.flac
-ret: 0 st: 0 dts:-102481911520608.625000 pts:-102481911520608.625000 pos:0 size:1024 flags:1
+ret: 0 st: 0 dts:-209146758205323.718750 pts:-209146758205323.718750 pos:42 size:1024 flags:1
 ret:-1 st:-1 ts:-1.000000 flags:0
 ret:-1 st:-1 ts:1.894167 flags:1
-ret:-1 st: 0 ts:0.788333 flags:0
-ret:-1 st: 0 ts:-0.317500 flags:1
+ret:-1 st: 0 ts:0.788345 flags:0
+ret:-1 st: 0 ts:-0.317506 flags:1
 ret:-1 st:-1 ts:2.576668 flags:0
 ret:-1 st:-1 ts:1.470835 flags:1
-ret:-1 st: 0 ts:0.365000 flags:0
-ret:-1 st: 0 ts:-0.740833 flags:1
+ret:-1 st: 0 ts:0.365011 flags:0
+ret:-1 st: 0 ts:-0.740839 flags:1
 ret:-1 st:-1 ts:2.153336 flags:0
 ret:-1 st:-1 ts:1.047503 flags:1
-ret:-1 st: 0 ts:-0.058333 flags:0
-ret:-1 st: 0 ts:2.835833 flags:1
+ret:-1 st: 0 ts:-0.058322 flags:0
+ret:-1 st: 0 ts:2.835828 flags:1
 ret:-1 st:-1 ts:1.730004 flags:0
 ret:-1 st:-1 ts:0.624171 flags:1
-ret:-1 st: 0 ts:-0.481667 flags:0
-ret:-1 st: 0 ts:2.412500 flags:1
+ret:-1 st: 0 ts:-0.481655 flags:0
+ret:-1 st: 0 ts:2.412494 flags:1
 ret:-1 st:-1 ts:1.306672 flags:0
 ret:-1 st:-1 ts:0.200839 flags:1
 ret:-1 st: 0 ts:-0.904989 flags:0
-ret:-1 st: 0 ts:1.989178 flags:1
+ret:-1 st: 0 ts:1.989184 flags:1
 ret:-1 st:-1 ts:0.883340 flags:0
 ret:-1 st:-1 ts:-0.222493 flags:1
 ret:-1 st: 0 ts:2.671678 flags:0
-ret:-1 st: 0 ts:1.565844 flags:1
+ret:-1 st: 0 ts:1.565850 flags:1
 ret:-1 st:-1 ts:0.460008 flags:0
 ret:-1 st:-1 ts:-0.645825 flags:1
 ----------------
@@ -711,193 +740,201 @@
 ----------------
 tests/data/a-g726.wav
 ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:56 size:4096 flags:1
-ret:-1 st:-1 ts:-1.000000 flags:0
+ret: 0 st:-1 ts:-1.000000 flags:0
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:56 size:4096 flags:1
 ret: 0 st:-1 ts:1.894167 flags:1
 ret: 0 st: 0 dts:1.894000 pts:1.894000 pos:7632 size:4096 flags:1
 ret: 0 st: 0 ts:0.788375 flags:0
 ret: 0 st: 0 dts:0.788500 pts:0.788500 pos:3210 size:4096 flags:1
-ret:-1 st: 0 ts:-0.317500 flags:1
+ret: 0 st: 0 ts:-0.317500 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:56 size:4096 flags:1
 ret: 0 st:-1 ts:2.576668 flags:0
 ret: 0 st: 0 dts:2.576750 pts:2.576750 pos:10363 size:4096 flags:1
 ret: 0 st:-1 ts:1.470835 flags:1
 ret: 0 st: 0 dts:1.470750 pts:1.470750 pos:5939 size:4096 flags:1
 ret: 0 st: 0 ts:0.365000 flags:0
 ret: 0 st: 0 dts:0.365000 pts:0.365000 pos:1516 size:4096 flags:1
-ret:-1 st: 0 ts:-0.740875 flags:1
+ret: 0 st: 0 ts:-0.740875 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:56 size:4096 flags:1
 ret: 0 st:-1 ts:2.153336 flags:0
 ret: 0 st: 0 dts:2.153500 pts:2.153500 pos:8670 size:4096 flags:1
 ret: 0 st:-1 ts:1.047503 flags:1
 ret: 0 st: 0 dts:1.047500 pts:1.047500 pos:4246 size:4096 flags:1
-ret:-1 st: 0 ts:-0.058375 flags:0
+ret: 0 st: 0 ts:-0.058375 flags:0
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:56 size:4096 flags:1
 ret: 0 st: 0 ts:2.835875 flags:1
 ret: 0 st: 0 dts:2.835750 pts:2.835750 pos:11399 size:4096 flags:1
 ret: 0 st:-1 ts:1.730004 flags:0
 ret: 0 st: 0 dts:1.730000 pts:1.730000 pos:6976 size:4096 flags:1
 ret: 0 st:-1 ts:0.624171 flags:1
 ret: 0 st: 0 dts:0.624000 pts:0.624000 pos:2552 size:4096 flags:1
-ret:-1 st: 0 ts:-0.481625 flags:0
+ret: 0 st: 0 ts:-0.481625 flags:0
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:56 size:4096 flags:1
 ret: 0 st: 0 ts:2.412500 flags:1
 ret: 0 st: 0 dts:2.412500 pts:2.412500 pos:9706 size:4096 flags:1
 ret: 0 st:-1 ts:1.306672 flags:0
 ret: 0 st: 0 dts:1.306750 pts:1.306750 pos:5283 size:4096 flags:1
 ret: 0 st:-1 ts:0.200839 flags:1
 ret: 0 st: 0 dts:0.200750 pts:0.200750 pos:859 size:4096 flags:1
-ret:-1 st: 0 ts:-0.905000 flags:0
+ret: 0 st: 0 ts:-0.905000 flags:0
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:56 size:4096 flags:1
 ret: 0 st: 0 ts:1.989125 flags:1
 ret: 0 st: 0 dts:1.989000 pts:1.989000 pos:8012 size:4096 flags:1
 ret: 0 st:-1 ts:0.883340 flags:0
 ret: 0 st: 0 dts:0.883500 pts:0.883500 pos:3590 size:4096 flags:1
-ret:-1 st:-1 ts:-0.222493 flags:1
+ret: 0 st:-1 ts:-0.222493 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:56 size:4096 flags:1
 ret: 0 st: 0 ts:2.671625 flags:0
 ret: 0 st: 0 dts:2.671750 pts:2.671750 pos:10743 size:4096 flags:1
 ret: 0 st: 0 ts:1.565875 flags:1
 ret: 0 st: 0 dts:1.565750 pts:1.565750 pos:6319 size:4096 flags:1
 ret: 0 st:-1 ts:0.460008 flags:0
 ret: 0 st: 0 dts:0.460000 pts:0.460000 pos:1896 size:4096 flags:1
-ret:-1 st:-1 ts:-0.645825 flags:1
+ret: 0 st:-1 ts:-0.645825 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:56 size:4096 flags:1
 ----------------
 tests/data/a-h261.avi
-ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:15314 size:9645 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:5660 size:9645 flags:1
 ret: 0 st:-1 ts:-1.000000 flags:0
-ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:15314 size:9645 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:5660 size:9645 flags:1
 ret: 0 st:-1 ts:1.894167 flags:1
-ret: 0 st: 0 dts:1.440000 pts:1.440000 pos:137900 size:11377 flags:1
+ret: 0 st: 0 dts:1.440000 pts:1.440000 pos:126514 size:11377 flags:1
 ret: 0 st: 0 ts:0.800000 flags:0
-ret: 0 st: 0 dts:0.960000 pts:0.960000 pos:92402 size:10322 flags:1
+ret: 0 st: 0 dts:0.960000 pts:0.960000 pos:82072 size:10322 flags:1
 ret:-1 st: 0 ts:-0.320000 flags:1
 ret:-1 st:-1 ts:2.576668 flags:0
 ret: 0 st:-1 ts:1.470835 flags:1
-ret: 0 st: 0 dts:1.440000 pts:1.440000 pos:137900 size:11377 flags:1
+ret: 0 st: 0 dts:1.440000 pts:1.440000 pos:126514 size:11377 flags:1
 ret: 0 st: 0 ts:0.360000 flags:0
-ret: 0 st: 0 dts:0.480000 pts:0.480000 pos:54090 size:9404 flags:1
+ret: 0 st: 0 dts:0.480000 pts:0.480000 pos:44678 size:9404 flags:1
 ret:-1 st: 0 ts:-0.760000 flags:1
 ret:-1 st:-1 ts:2.153336 flags:0
 ret: 0 st:-1 ts:1.047503 flags:1
-ret: 0 st: 0 dts:0.960000 pts:0.960000 pos:92402 size:10322 flags:1
+ret: 0 st: 0 dts:0.960000 pts:0.960000 pos:82072 size:10322 flags:1
 ret: 0 st: 0 ts:-0.040000 flags:0
-ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:15314 size:9645 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:5660 size:9645 flags:1
 ret: 0 st: 0 ts:2.840000 flags:1
-ret: 0 st: 0 dts:1.920000 pts:1.920000 pos:187598 size:11707 flags:1
+ret: 0 st: 0 dts:1.920000 pts:1.920000 pos:175882 size:11707 flags:1
 ret: 0 st:-1 ts:1.730004 flags:0
-ret: 0 st: 0 dts:1.920000 pts:1.920000 pos:187598 size:11707 flags:1
+ret: 0 st: 0 dts:1.920000 pts:1.920000 pos:175882 size:11707 flags:1
 ret: 0 st:-1 ts:0.624171 flags:1
-ret: 0 st: 0 dts:0.480000 pts:0.480000 pos:54090 size:9404 flags:1
+ret: 0 st: 0 dts:0.480000 pts:0.480000 pos:44678 size:9404 flags:1
 ret: 0 st: 0 ts:-0.480000 flags:0
-ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:15314 size:9645 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:5660 size:9645 flags:1
 ret: 0 st: 0 ts:2.400000 flags:1
-ret: 0 st: 0 dts:1.920000 pts:1.920000 pos:187598 size:11707 flags:1
+ret: 0 st: 0 dts:1.920000 pts:1.920000 pos:175882 size:11707 flags:1
 ret: 0 st:-1 ts:1.306672 flags:0
-ret: 0 st: 0 dts:1.440000 pts:1.440000 pos:137900 size:11377 flags:1
+ret: 0 st: 0 dts:1.440000 pts:1.440000 pos:126514 size:11377 flags:1
 ret: 0 st:-1 ts:0.200839 flags:1
-ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:15314 size:9645 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:5660 size:9645 flags:1
 ret: 0 st: 0 ts:-0.920000 flags:0
-ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:15314 size:9645 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:5660 size:9645 flags:1
 ret: 0 st: 0 ts:2.000000 flags:1
-ret: 0 st: 0 dts:1.920000 pts:1.920000 pos:187598 size:11707 flags:1
+ret: 0 st: 0 dts:1.920000 pts:1.920000 pos:175882 size:11707 flags:1
 ret: 0 st:-1 ts:0.883340 flags:0
-ret: 0 st: 0 dts:0.960000 pts:0.960000 pos:92402 size:10322 flags:1
+ret: 0 st: 0 dts:0.960000 pts:0.960000 pos:82072 size:10322 flags:1
 ret:-1 st:-1 ts:-0.222493 flags:1
 ret:-1 st: 0 ts:2.680000 flags:0
 ret: 0 st: 0 ts:1.560000 flags:1
-ret: 0 st: 0 dts:1.440000 pts:1.440000 pos:137900 size:11377 flags:1
+ret: 0 st: 0 dts:1.440000 pts:1.440000 pos:126514 size:11377 flags:1
 ret: 0 st:-1 ts:0.460008 flags:0
-ret: 0 st: 0 dts:0.480000 pts:0.480000 pos:54090 size:9404 flags:1
+ret: 0 st: 0 dts:0.480000 pts:0.480000 pos:44678 size:9404 flags:1
 ret:-1 st:-1 ts:-0.645825 flags:1
 ----------------
 tests/data/a-h263.avi
-ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:16050 size:10381 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:5660 size:10381 flags:1
 ret: 0 st:-1 ts:-1.000000 flags:0
-ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:16050 size:10381 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:5660 size:10381 flags:1
 ret: 0 st:-1 ts:1.894167 flags:1
-ret: 0 st: 0 dts:1.440000 pts:1.440000 pos:116018 size:12296 flags:1
+ret: 0 st: 0 dts:1.440000 pts:1.440000 pos:103714 size:12296 flags:1
 ret: 0 st: 0 ts:0.800000 flags:0
-ret: 0 st: 0 dts:0.960000 pts:0.960000 pos:77940 size:11128 flags:1
+ret: 0 st: 0 dts:0.960000 pts:0.960000 pos:66804 size:11128 flags:1
 ret:-1 st: 0 ts:-0.320000 flags:1
 ret:-1 st:-1 ts:2.576668 flags:0
 ret: 0 st:-1 ts:1.470835 flags:1
-ret: 0 st: 0 dts:1.440000 pts:1.440000 pos:116018 size:12296 flags:1
+ret: 0 st: 0 dts:1.440000 pts:1.440000 pos:103714 size:12296 flags:1
 ret: 0 st: 0 ts:0.360000 flags:0
-ret: 0 st: 0 dts:0.480000 pts:0.480000 pos:46548 size:10090 flags:1
+ret: 0 st: 0 dts:0.480000 pts:0.480000 pos:36450 size:10090 flags:1
 ret:-1 st: 0 ts:-0.760000 flags:1
 ret:-1 st:-1 ts:2.153336 flags:0
 ret: 0 st:-1 ts:1.047503 flags:1
-ret: 0 st: 0 dts:0.960000 pts:0.960000 pos:77940 size:11128 flags:1
+ret: 0 st: 0 dts:0.960000 pts:0.960000 pos:66804 size:11128 flags:1
 ret: 0 st: 0 ts:-0.040000 flags:0
-ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:16050 size:10381 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:5660 size:10381 flags:1
 ret: 0 st: 0 ts:2.840000 flags:1
-ret: 0 st: 0 dts:1.920000 pts:1.920000 pos:157298 size:12731 flags:1
+ret: 0 st: 0 dts:1.920000 pts:1.920000 pos:144558 size:12731 flags:1
 ret: 0 st:-1 ts:1.730004 flags:0
-ret: 0 st: 0 dts:1.920000 pts:1.920000 pos:157298 size:12731 flags:1
+ret: 0 st: 0 dts:1.920000 pts:1.920000 pos:144558 size:12731 flags:1
 ret: 0 st:-1 ts:0.624171 flags:1
-ret: 0 st: 0 dts:0.480000 pts:0.480000 pos:46548 size:10090 flags:1
+ret: 0 st: 0 dts:0.480000 pts:0.480000 pos:36450 size:10090 flags:1
 ret: 0 st: 0 ts:-0.480000 flags:0
-ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:16050 size:10381 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:5660 size:10381 flags:1
 ret: 0 st: 0 ts:2.400000 flags:1
-ret: 0 st: 0 dts:1.920000 pts:1.920000 pos:157298 size:12731 flags:1
+ret: 0 st: 0 dts:1.920000 pts:1.920000 pos:144558 size:12731 flags:1
 ret: 0 st:-1 ts:1.306672 flags:0
-ret: 0 st: 0 dts:1.440000 pts:1.440000 pos:116018 size:12296 flags:1
+ret: 0 st: 0 dts:1.440000 pts:1.440000 pos:103714 size:12296 flags:1
 ret: 0 st:-1 ts:0.200839 flags:1
-ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:16050 size:10381 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:5660 size:10381 flags:1
 ret: 0 st: 0 ts:-0.920000 flags:0
-ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:16050 size:10381 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:5660 size:10381 flags:1
 ret: 0 st: 0 ts:2.000000 flags:1
-ret: 0 st: 0 dts:1.920000 pts:1.920000 pos:157298 size:12731 flags:1
+ret: 0 st: 0 dts:1.920000 pts:1.920000 pos:144558 size:12731 flags:1
 ret: 0 st:-1 ts:0.883340 flags:0
-ret: 0 st: 0 dts:0.960000 pts:0.960000 pos:77940 size:11128 flags:1
+ret: 0 st: 0 dts:0.960000 pts:0.960000 pos:66804 size:11128 flags:1
 ret:-1 st:-1 ts:-0.222493 flags:1
 ret:-1 st: 0 ts:2.680000 flags:0
 ret: 0 st: 0 ts:1.560000 flags:1
-ret: 0 st: 0 dts:1.440000 pts:1.440000 pos:116018 size:12296 flags:1
+ret: 0 st: 0 dts:1.440000 pts:1.440000 pos:103714 size:12296 flags:1
 ret: 0 st:-1 ts:0.460008 flags:0
-ret: 0 st: 0 dts:0.480000 pts:0.480000 pos:46548 size:10090 flags:1
+ret: 0 st: 0 dts:0.480000 pts:0.480000 pos:36450 size:10090 flags:1
 ret:-1 st:-1 ts:-0.645825 flags:1
 ----------------
 tests/data/a-h263p.avi
-ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:41876 size:36208 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:5660 size:36208 flags:1
 ret: 0 st:-1 ts:-1.000000 flags:0
-ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:41876 size:36208 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:5660 size:36208 flags:1
 ret: 0 st:-1 ts:1.894167 flags:1
-ret: 0 st: 0 dts:1.440000 pts:1.440000 pos:615098 size:45151 flags:1
+ret: 0 st: 0 dts:1.440000 pts:1.440000 pos:569938 size:45151 flags:1
 ret: 0 st: 0 ts:0.800000 flags:0
-ret: 0 st: 0 dts:0.960000 pts:0.960000 pos:396904 size:40907 flags:1
+ret: 0 st: 0 dts:0.960000 pts:0.960000 pos:355988 size:40907 flags:1
 ret:-1 st: 0 ts:-0.320000 flags:1
 ret:-1 st:-1 ts:2.576668 flags:0
 ret: 0 st:-1 ts:1.470835 flags:1
-ret: 0 st: 0 dts:1.440000 pts:1.440000 pos:615098 size:45151 flags:1
+ret: 0 st: 0 dts:1.440000 pts:1.440000 pos:569938 size:45151 flags:1
 ret: 0 st: 0 ts:0.360000 flags:0
-ret: 0 st: 0 dts:0.480000 pts:0.480000 pos:207578 size:36515 flags:1
+ret: 0 st: 0 dts:0.480000 pts:0.480000 pos:171054 size:36515 flags:1
 ret:-1 st: 0 ts:-0.760000 flags:1
 ret:-1 st:-1 ts:2.153336 flags:0
 ret: 0 st:-1 ts:1.047503 flags:1
-ret: 0 st: 0 dts:0.960000 pts:0.960000 pos:396904 size:40907 flags:1
+ret: 0 st: 0 dts:0.960000 pts:0.960000 pos:355988 size:40907 flags:1
 ret: 0 st: 0 ts:-0.040000 flags:0
-ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:41876 size:36208 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:5660 size:36208 flags:1
 ret: 0 st: 0 ts:2.840000 flags:1
-ret: 0 st: 0 dts:1.920000 pts:1.920000 pos:850798 size:46411 flags:1
+ret: 0 st: 0 dts:1.920000 pts:1.920000 pos:804378 size:46411 flags:1
 ret: 0 st:-1 ts:1.730004 flags:0
-ret: 0 st: 0 dts:1.920000 pts:1.920000 pos:850798 size:46411 flags:1
+ret: 0 st: 0 dts:1.920000 pts:1.920000 pos:804378 size:46411 flags:1
 ret: 0 st:-1 ts:0.624171 flags:1
-ret: 0 st: 0 dts:0.480000 pts:0.480000 pos:207578 size:36515 flags:1
+ret: 0 st: 0 dts:0.480000 pts:0.480000 pos:171054 size:36515 flags:1
 ret: 0 st: 0 ts:-0.480000 flags:0
-ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:41876 size:36208 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:5660 size:36208 flags:1
 ret: 0 st: 0 ts:2.400000 flags:1
-ret: 0 st: 0 dts:1.920000 pts:1.920000 pos:850798 size:46411 flags:1
+ret: 0 st: 0 dts:1.920000 pts:1.920000 pos:804378 size:46411 flags:1
 ret: 0 st:-1 ts:1.306672 flags:0
-ret: 0 st: 0 dts:1.440000 pts:1.440000 pos:615098 size:45151 flags:1
+ret: 0 st: 0 dts:1.440000 pts:1.440000 pos:569938 size:45151 flags:1
 ret: 0 st:-1 ts:0.200839 flags:1
-ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:41876 size:36208 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:5660 size:36208 flags:1
 ret: 0 st: 0 ts:-0.920000 flags:0
-ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:41876 size:36208 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:5660 size:36208 flags:1
 ret: 0 st: 0 ts:2.000000 flags:1
-ret: 0 st: 0 dts:1.920000 pts:1.920000 pos:850798 size:46411 flags:1
+ret: 0 st: 0 dts:1.920000 pts:1.920000 pos:804378 size:46411 flags:1
 ret: 0 st:-1 ts:0.883340 flags:0
-ret: 0 st: 0 dts:0.960000 pts:0.960000 pos:396904 size:40907 flags:1
+ret: 0 st: 0 dts:0.960000 pts:0.960000 pos:355988 size:40907 flags:1
 ret:-1 st:-1 ts:-0.222493 flags:1
 ret:-1 st: 0 ts:2.680000 flags:0
 ret: 0 st: 0 ts:1.560000 flags:1
-ret: 0 st: 0 dts:1.440000 pts:1.440000 pos:615098 size:45151 flags:1
+ret: 0 st: 0 dts:1.440000 pts:1.440000 pos:569938 size:45151 flags:1
 ret: 0 st:-1 ts:0.460008 flags:0
-ret: 0 st: 0 dts:0.480000 pts:0.480000 pos:207578 size:36515 flags:1
+ret: 0 st: 0 dts:0.480000 pts:0.480000 pos:171054 size:36515 flags:1
 ret:-1 st:-1 ts:-0.645825 flags:1
 ----------------
 tests/data/a-huffyuv.avi
@@ -949,147 +986,147 @@
 ret:-1 st:-1 ts:-0.645825 flags:1
 ----------------
 tests/data/a-jpegls.avi
-ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:169742 size:164074 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:5660 size:164074 flags:1
 ret: 0 st:-1 ts:-1.000000 flags:0
-ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:169742 size:164074 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:5660 size:164074 flags:1
 ret: 0 st:-1 ts:1.894167 flags:1
-ret: 0 st: 0 dts:1.880000 pts:1.880000 pos:7980434 size:176295 flags:1
+ret: 0 st: 0 dts:1.880000 pts:1.880000 pos:7804130 size:176295 flags:1
 ret: 0 st: 0 ts:0.800000 flags:0
-ret: 0 st: 0 dts:0.800000 pts:0.800000 pos:3337444 size:164643 flags:1
+ret: 0 st: 0 dts:0.800000 pts:0.800000 pos:3172792 size:164643 flags:1
 ret:-1 st: 0 ts:-0.320000 flags:1
 ret:-1 st:-1 ts:2.576668 flags:0
 ret: 0 st:-1 ts:1.470835 flags:1
-ret: 0 st: 0 dts:1.480000 pts:1.480000 pos:6227092 size:174097 flags:1
+ret: 0 st: 0 dts:1.480000 pts:1.480000 pos:6052986 size:174097 flags:1
 ret: 0 st: 0 ts:0.360000 flags:0
-ret: 0 st: 0 dts:0.360000 pts:0.360000 pos:1559648 size:157283 flags:1
+ret: 0 st: 0 dts:0.360000 pts:0.360000 pos:1402356 size:157283 flags:1
 ret:-1 st: 0 ts:-0.760000 flags:1
 ret:-1 st:-1 ts:2.153336 flags:0
 ret: 0 st:-1 ts:1.047503 flags:1
-ret: 0 st: 0 dts:1.040000 pts:1.040000 pos:4338670 size:168401 flags:1
+ret: 0 st: 0 dts:1.040000 pts:1.040000 pos:4170260 size:168401 flags:1
 ret: 0 st: 0 ts:-0.040000 flags:0
-ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:169742 size:164074 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:5660 size:164074 flags:1
 ret: 0 st: 0 ts:2.840000 flags:1
-ret: 0 st: 0 dts:1.960000 pts:1.960000 pos:-1 size:176793 flags:1
+ret: 0 st: 0 dts:1.960000 pts:1.960000 pos:8157028 size:176793 flags:1
 ret: 0 st:-1 ts:1.730004 flags:0
-ret: 0 st: 0 dts:1.720000 pts:1.720000 pos:7277100 size:175326 flags:1
+ret: 0 st: 0 dts:1.720000 pts:1.720000 pos:7101766 size:175326 flags:1
 ret: 0 st:-1 ts:0.624171 flags:1
-ret: 0 st: 0 dts:0.640000 pts:0.640000 pos:2681802 size:162522 flags:1
+ret: 0 st: 0 dts:0.640000 pts:0.640000 pos:2519272 size:162522 flags:1
 ret: 0 st: 0 ts:-0.480000 flags:0
-ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:169742 size:164074 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:5660 size:164074 flags:1
 ret: 0 st: 0 ts:2.400000 flags:1
-ret: 0 st: 0 dts:1.960000 pts:1.960000 pos:-1 size:176793 flags:1
+ret: 0 st: 0 dts:1.960000 pts:1.960000 pos:8157028 size:176793 flags:1
 ret: 0 st:-1 ts:1.306672 flags:0
-ret: 0 st: 0 dts:1.320000 pts:1.320000 pos:5533022 size:172183 flags:1
+ret: 0 st: 0 dts:1.320000 pts:1.320000 pos:5360830 size:172183 flags:1
 ret: 0 st:-1 ts:0.200839 flags:1
-ret: 0 st: 0 dts:0.200000 pts:0.200000 pos:934434 size:154579 flags:1
+ret: 0 st: 0 dts:0.200000 pts:0.200000 pos:779846 size:154579 flags:1
 ret: 0 st: 0 ts:-0.920000 flags:0
-ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:169742 size:164074 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:5660 size:164074 flags:1
 ret: 0 st: 0 ts:2.000000 flags:1
-ret: 0 st: 0 dts:1.960000 pts:1.960000 pos:-1 size:176793 flags:1
+ret: 0 st: 0 dts:1.960000 pts:1.960000 pos:8157028 size:176793 flags:1
 ret: 0 st:-1 ts:0.883340 flags:0
-ret: 0 st: 0 dts:0.880000 pts:0.880000 pos:3668866 size:166017 flags:1
+ret: 0 st: 0 dts:0.880000 pts:0.880000 pos:3502840 size:166017 flags:1
 ret:-1 st:-1 ts:-0.222493 flags:1
 ret:-1 st: 0 ts:2.680000 flags:0
 ret: 0 st: 0 ts:1.560000 flags:1
-ret: 0 st: 0 dts:1.560000 pts:1.560000 pos:6576288 size:174815 flags:1
+ret: 0 st: 0 dts:1.560000 pts:1.560000 pos:6401464 size:174815 flags:1
 ret: 0 st:-1 ts:0.460008 flags:0
-ret: 0 st: 0 dts:0.480000 pts:0.480000 pos:2036096 size:159659 flags:1
+ret: 0 st: 0 dts:0.480000 pts:0.480000 pos:1876428 size:159659 flags:1
 ret:-1 st:-1 ts:-0.645825 flags:1
 ----------------
 tests/data/a-ljpeg.avi
-ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:101738 size:96069 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:5660 size:96069 flags:1
 ret: 0 st:-1 ts:-1.000000 flags:0
-ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:101738 size:96069 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:5660 size:96069 flags:1
 ret: 0 st:-1 ts:1.894167 flags:1
-ret: 0 st: 0 dts:1.880000 pts:1.880000 pos:4576754 size:94870 flags:1
+ret: 0 st: 0 dts:1.880000 pts:1.880000 pos:4481876 size:94870 flags:1
 ret: 0 st: 0 ts:0.800000 flags:0
-ret: 0 st: 0 dts:0.800000 pts:0.800000 pos:1997804 size:95465 flags:1
+ret: 0 st: 0 dts:0.800000 pts:0.800000 pos:1902330 size:95465 flags:1
 ret:-1 st: 0 ts:-0.320000 flags:1
 ret:-1 st:-1 ts:2.576668 flags:0
 ret: 0 st:-1 ts:1.470835 flags:1
-ret: 0 st: 0 dts:1.480000 pts:1.480000 pos:3623468 size:95724 flags:1
+ret: 0 st: 0 dts:1.480000 pts:1.480000 pos:3527736 size:95724 flags:1
 ret: 0 st: 0 ts:0.360000 flags:0
-ret: 0 st: 0 dts:0.360000 pts:0.360000 pos:949600 size:94635 flags:1
+ret: 0 st: 0 dts:0.360000 pts:0.360000 pos:854956 size:94635 flags:1
 ret:-1 st: 0 ts:-0.760000 flags:1
 ret:-1 st:-1 ts:2.153336 flags:0
 ret: 0 st:-1 ts:1.047503 flags:1
-ret: 0 st: 0 dts:1.040000 pts:1.040000 pos:2571236 size:95649 flags:1
+ret: 0 st: 0 dts:1.040000 pts:1.040000 pos:2475578 size:95649 flags:1
 ret: 0 st: 0 ts:-0.040000 flags:0
-ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:101738 size:96069 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:5660 size:96069 flags:1
 ret: 0 st: 0 ts:2.840000 flags:1
-ret: 0 st: 0 dts:1.960000 pts:1.960000 pos:-1 size:94595 flags:1
+ret: 0 st: 0 dts:1.960000 pts:1.960000 pos:4671510 size:94595 flags:1
 ret: 0 st:-1 ts:1.730004 flags:0
-ret: 0 st: 0 dts:1.720000 pts:1.720000 pos:4196712 size:95353 flags:1
+ret: 0 st: 0 dts:1.720000 pts:1.720000 pos:4101350 size:95353 flags:1
 ret: 0 st:-1 ts:0.624171 flags:1
-ret: 0 st: 0 dts:0.640000 pts:0.640000 pos:1615714 size:95410 flags:1
+ret: 0 st: 0 dts:0.640000 pts:0.640000 pos:1520296 size:95410 flags:1
 ret: 0 st: 0 ts:-0.480000 flags:0
-ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:101738 size:96069 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:5660 size:96069 flags:1
 ret: 0 st: 0 ts:2.400000 flags:1
-ret: 0 st: 0 dts:1.960000 pts:1.960000 pos:-1 size:94595 flags:1
+ret: 0 st: 0 dts:1.960000 pts:1.960000 pos:4671510 size:94595 flags:1
 ret: 0 st:-1 ts:1.306672 flags:0
-ret: 0 st: 0 dts:1.320000 pts:1.320000 pos:3240722 size:95587 flags:1
+ret: 0 st: 0 dts:1.320000 pts:1.320000 pos:3145126 size:95587 flags:1
 ret: 0 st:-1 ts:0.200839 flags:1
-ret: 0 st: 0 dts:0.200000 pts:0.200000 pos:571508 size:94261 flags:1
+ret: 0 st: 0 dts:0.200000 pts:0.200000 pos:477238 size:94261 flags:1
 ret: 0 st: 0 ts:-0.920000 flags:0
-ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:101738 size:96069 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:5660 size:96069 flags:1
 ret: 0 st: 0 ts:2.000000 flags:1
-ret: 0 st: 0 dts:1.960000 pts:1.960000 pos:-1 size:94595 flags:1
+ret: 0 st: 0 dts:1.960000 pts:1.960000 pos:4671510 size:94595 flags:1
 ret: 0 st:-1 ts:0.883340 flags:0
-ret: 0 st: 0 dts:0.880000 pts:0.880000 pos:2188850 size:95528 flags:1
+ret: 0 st: 0 dts:0.880000 pts:0.880000 pos:2093314 size:95528 flags:1
 ret:-1 st:-1 ts:-0.222493 flags:1
 ret:-1 st: 0 ts:2.680000 flags:0
 ret: 0 st: 0 ts:1.560000 flags:1
-ret: 0 st: 0 dts:1.560000 pts:1.560000 pos:3814762 size:95615 flags:1
+ret: 0 st: 0 dts:1.560000 pts:1.560000 pos:3719138 size:95615 flags:1
 ret: 0 st:-1 ts:0.460008 flags:0
-ret: 0 st: 0 dts:0.480000 pts:0.480000 pos:1234290 size:95032 flags:1
+ret: 0 st: 0 dts:0.480000 pts:0.480000 pos:1139250 size:95032 flags:1
 ret:-1 st:-1 ts:-0.645825 flags:1
 ----------------
 tests/data/a-mjpeg.avi
-ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:18318 size:12650 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:5660 size:12650 flags:1
 ret: 0 st:-1 ts:-1.000000 flags:0
-ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:18318 size:12650 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:5660 size:12650 flags:1
 ret: 0 st:-1 ts:1.894167 flags:1
-ret: 0 st: 0 dts:1.880000 pts:1.880000 pos:672134 size:15508 flags:1
+ret: 0 st: 0 dts:1.880000 pts:1.880000 pos:656618 size:15508 flags:1
 ret: 0 st: 0 ts:0.800000 flags:0
-ret: 0 st: 0 dts:0.800000 pts:0.800000 pos:271828 size:13522 flags:1
+ret: 0 st: 0 dts:0.800000 pts:0.800000 pos:258298 size:13522 flags:1
 ret:-1 st: 0 ts:-0.320000 flags:1
 ret:-1 st:-1 ts:2.576668 flags:0
 ret: 0 st:-1 ts:1.470835 flags:1
-ret: 0 st: 0 dts:1.480000 pts:1.480000 pos:517864 size:15224 flags:1
+ret: 0 st: 0 dts:1.480000 pts:1.480000 pos:502632 size:15224 flags:1
 ret: 0 st: 0 ts:0.360000 flags:0
-ret: 0 st: 0 dts:0.360000 pts:0.360000 pos:128128 size:12453 flags:1
+ret: 0 st: 0 dts:0.360000 pts:0.360000 pos:115666 size:12453 flags:1
 ret:-1 st: 0 ts:-0.760000 flags:1
 ret:-1 st:-1 ts:2.153336 flags:0
 ret: 0 st:-1 ts:1.047503 flags:1
-ret: 0 st: 0 dts:1.040000 pts:1.040000 pos:355318 size:14170 flags:1
+ret: 0 st: 0 dts:1.040000 pts:1.040000 pos:341140 size:14170 flags:1
 ret: 0 st: 0 ts:-0.040000 flags:0
-ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:18318 size:12650 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:5660 size:12650 flags:1
 ret: 0 st: 0 ts:2.840000 flags:1
-ret: 0 st: 0 dts:1.960000 pts:1.960000 pos:-1 size:15576 flags:1
+ret: 0 st: 0 dts:1.960000 pts:1.960000 pos:687716 size:15576 flags:1
 ret: 0 st:-1 ts:1.730004 flags:0
-ret: 0 st: 0 dts:1.720000 pts:1.720000 pos:610160 size:15432 flags:1
+ret: 0 st: 0 dts:1.720000 pts:1.720000 pos:594720 size:15432 flags:1
 ret: 0 st:-1 ts:0.624171 flags:1
-ret: 0 st: 0 dts:0.640000 pts:0.640000 pos:218176 size:13273 flags:1
+ret: 0 st: 0 dts:0.640000 pts:0.640000 pos:204894 size:13273 flags:1
 ret: 0 st: 0 ts:-0.480000 flags:0
-ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:18318 size:12650 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:5660 size:12650 flags:1
 ret: 0 st: 0 ts:2.400000 flags:1
-ret: 0 st: 0 dts:1.960000 pts:1.960000 pos:-1 size:15576 flags:1
+ret: 0 st: 0 dts:1.960000 pts:1.960000 pos:687716 size:15576 flags:1
 ret: 0 st:-1 ts:1.306672 flags:0
-ret: 0 st: 0 dts:1.320000 pts:1.320000 pos:457384 size:14799 flags:1
+ret: 0 st: 0 dts:1.320000 pts:1.320000 pos:442576 size:14799 flags:1
 ret: 0 st:-1 ts:0.200839 flags:1
-ret: 0 st: 0 dts:0.200000 pts:0.200000 pos:78608 size:12233 flags:1
+ret: 0 st: 0 dts:0.200000 pts:0.200000 pos:66366 size:12233 flags:1
 ret: 0 st: 0 ts:-0.920000 flags:0
-ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:18318 size:12650 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:5660 size:12650 flags:1
 ret: 0 st: 0 ts:2.000000 flags:1
-ret: 0 st: 0 dts:1.960000 pts:1.960000 pos:-1 size:15576 flags:1
+ret: 0 st: 0 dts:1.960000 pts:1.960000 pos:687716 size:15576 flags:1
 ret: 0 st:-1 ts:0.883340 flags:0
-ret: 0 st: 0 dts:0.880000 pts:0.880000 pos:299236 size:13726 flags:1
+ret: 0 st: 0 dts:0.880000 pts:0.880000 pos:285502 size:13726 flags:1
 ret:-1 st:-1 ts:-0.222493 flags:1
 ret:-1 st: 0 ts:2.680000 flags:0
 ret: 0 st: 0 ts:1.560000 flags:1
-ret: 0 st: 0 dts:1.560000 pts:1.560000 pos:548542 size:15322 flags:1
+ret: 0 st: 0 dts:1.560000 pts:1.560000 pos:533212 size:15322 flags:1
 ret: 0 st:-1 ts:0.460008 flags:0
-ret: 0 st: 0 dts:0.480000 pts:0.480000 pos:165966 size:12726 flags:1
+ret: 0 st: 0 dts:0.480000 pts:0.480000 pos:153232 size:12726 flags:1
 ret:-1 st:-1 ts:-0.645825 flags:1
 ----------------
 tests/data/a-mp2.mp2
@@ -1148,387 +1185,387 @@
 ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:0 size:417 flags:1
 ----------------
 tests/data/a-mpeg1.mpg
-ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:9216 size:9779 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:0 size:9779 flags:1
 ret: 0 st:-1 ts:-1.000000 flags:0
-ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:9216 size:9779 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:0 size:9779 flags:1
 ret: 0 st:-1 ts:1.894167 flags:1
-ret: 0 st: 0 dts:1.440000 pts:-7686143364045.646484 pos:135509 size:11796 flags:1
+ret: 0 st: 0 dts:1.440000 pts:-7686143364045.646484 pos:124245 size:11796 flags:1
 ret: 0 st: 0 ts:0.788334 flags:0
-ret: 0 st: 0 dts:0.960000 pts:-7686143364045.646484 pos:86934 size:10792 flags:1
+ret: 0 st: 0 dts:0.960000 pts:-7686143364045.646484 pos:76694 size:10792 flags:1
 ret:-1 st: 0 ts:-0.317499 flags:1
 ret:-1 st:-1 ts:2.576668 flags:0
 ret: 0 st:-1 ts:1.470835 flags:1
-ret: 0 st: 0 dts:1.440000 pts:-7686143364045.646484 pos:135509 size:11796 flags:1
+ret: 0 st: 0 dts:1.440000 pts:-7686143364045.646484 pos:124245 size:11796 flags:1
 ret: 0 st: 0 ts:0.365002 flags:0
-ret: 0 st: 0 dts:0.480000 pts:-7686143364045.646484 pos:46937 size:9873 flags:1
+ret: 0 st: 0 dts:0.480000 pts:-7686143364045.646484 pos:37721 size:9873 flags:1
 ret:-1 st: 0 ts:-0.740831 flags:1
 ret:-1 st:-1 ts:2.153336 flags:0
 ret: 0 st:-1 ts:1.047503 flags:1
-ret: 0 st: 0 dts:0.960000 pts:-7686143364045.646484 pos:86934 size:10792 flags:1
+ret: 0 st: 0 dts:0.960000 pts:-7686143364045.646484 pos:76694 size:10792 flags:1
 ret: 0 st: 0 ts:-0.058330 flags:0
-ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:9216 size:9779 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:0 size:9779 flags:1
 ret: 0 st: 0 ts:2.835837 flags:1
-ret: 0 st: 0 dts:1.920000 pts:-7686143364045.646484 pos:188353 size:12057 flags:1
+ret: 0 st: 0 dts:1.920000 pts:-7686143364045.646484 pos:177089 size:12057 flags:1
 ret: 0 st:-1 ts:1.730004 flags:0
-ret: 0 st: 0 dts:1.920000 pts:-7686143364045.646484 pos:188353 size:12057 flags:1
+ret: 0 st: 0 dts:1.920000 pts:-7686143364045.646484 pos:177089 size:12057 flags:1
 ret: 0 st:-1 ts:0.624171 flags:1
-ret: 0 st: 0 dts:0.480000 pts:-7686143364045.646484 pos:46937 size:9873 flags:1
+ret: 0 st: 0 dts:0.480000 pts:-7686143364045.646484 pos:37721 size:9873 flags:1
 ret: 0 st: 0 ts:-0.481662 flags:0
-ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:9216 size:9779 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:0 size:9779 flags:1
 ret: 0 st: 0 ts:2.412505 flags:1
-ret: 0 st: 0 dts:1.920000 pts:-7686143364045.646484 pos:188353 size:12057 flags:1
+ret: 0 st: 0 dts:1.920000 pts:-7686143364045.646484 pos:177089 size:12057 flags:1
 ret: 0 st:-1 ts:1.306672 flags:0
-ret: 0 st: 0 dts:1.440000 pts:-7686143364045.646484 pos:135509 size:11796 flags:1
+ret: 0 st: 0 dts:1.440000 pts:-7686143364045.646484 pos:124245 size:11796 flags:1
 ret: 0 st:-1 ts:0.200839 flags:1
-ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:9216 size:9779 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:0 size:9779 flags:1
 ret: 0 st: 0 ts:-0.904994 flags:0
-ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:9216 size:9779 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:0 size:9779 flags:1
 ret: 0 st: 0 ts:1.989173 flags:1
-ret: 0 st: 0 dts:1.920000 pts:-7686143364045.646484 pos:188353 size:12057 flags:1
+ret: 0 st: 0 dts:1.920000 pts:-7686143364045.646484 pos:177089 size:12057 flags:1
 ret: 0 st:-1 ts:0.883340 flags:0
-ret: 0 st: 0 dts:0.960000 pts:-7686143364045.646484 pos:86934 size:10792 flags:1
+ret: 0 st: 0 dts:0.960000 pts:-7686143364045.646484 pos:76694 size:10792 flags:1
 ret:-1 st:-1 ts:-0.222493 flags:1
 ret:-1 st: 0 ts:2.671674 flags:0
 ret: 0 st: 0 ts:1.565841 flags:1
-ret: 0 st: 0 dts:1.440000 pts:-7686143364045.646484 pos:135509 size:11796 flags:1
+ret: 0 st: 0 dts:1.440000 pts:-7686143364045.646484 pos:124245 size:11796 flags:1
 ret: 0 st:-1 ts:0.460008 flags:0
-ret: 0 st: 0 dts:0.480000 pts:-7686143364045.646484 pos:46937 size:9873 flags:1
+ret: 0 st: 0 dts:0.480000 pts:-7686143364045.646484 pos:37721 size:9873 flags:1
 ret:-1 st:-1 ts:-0.645825 flags:1
 ----------------
 tests/data/a-mpeg1b.mpg
-ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:11264 size:11817 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:0 size:11817 flags:1
 ret: 0 st:-1 ts:-1.000000 flags:0
-ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:11264 size:11817 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:0 size:11817 flags:1
 ret: 0 st:-1 ts:1.894167 flags:1
-ret: 0 st: 0 dts:1.800000 pts:-7686143364045.646484 pos:212858 size:14837 flags:1
+ret: 0 st: 0 dts:1.800000 pts:-7686143364045.646484 pos:198522 size:14837 flags:1
 ret: 0 st: 0 ts:0.788334 flags:0
-ret: 0 st: 0 dts:0.840000 pts:-7686143364045.646484 pos:94832 size:13267 flags:1
+ret: 0 st: 0 dts:0.840000 pts:-7686143364045.646484 pos:82544 size:13267 flags:1
 ret:-1 st: 0 ts:-0.317499 flags:1
 ret:-1 st:-1 ts:2.576668 flags:0
 ret: 0 st:-1 ts:1.470835 flags:1
-ret: 0 st: 0 dts:1.320000 pts:-7686143364045.646484 pos:151065 size:14470 flags:1
+ret: 0 st: 0 dts:1.320000 pts:-7686143364045.646484 pos:136729 size:14470 flags:1
 ret: 0 st: 0 ts:0.365002 flags:0
-ret: 0 st: 0 dts:0.840000 pts:-7686143364045.646484 pos:94832 size:13267 flags:1
+ret: 0 st: 0 dts:0.840000 pts:-7686143364045.646484 pos:82544 size:13267 flags:1
 ret:-1 st: 0 ts:-0.740831 flags:1
 ret:-1 st:-1 ts:2.153336 flags:0
 ret: 0 st:-1 ts:1.047503 flags:1
-ret: 0 st: 0 dts:0.840000 pts:-7686143364045.646484 pos:94832 size:13267 flags:1
+ret: 0 st: 0 dts:0.840000 pts:-7686143364045.646484 pos:82544 size:13267 flags:1
 ret: 0 st: 0 ts:-0.058330 flags:0
-ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:11264 size:11817 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:0 size:11817 flags:1
 ret: 0 st: 0 ts:2.835837 flags:1
-ret: 0 st: 0 dts:1.800000 pts:-7686143364045.646484 pos:212858 size:14837 flags:1
+ret: 0 st: 0 dts:1.800000 pts:-7686143364045.646484 pos:198522 size:14837 flags:1
 ret: 0 st:-1 ts:1.730004 flags:0
-ret: 0 st: 0 dts:1.800000 pts:-7686143364045.646484 pos:212858 size:14837 flags:1
+ret: 0 st: 0 dts:1.800000 pts:-7686143364045.646484 pos:198522 size:14837 flags:1
 ret: 0 st:-1 ts:0.624171 flags:1
-ret: 0 st: 0 dts:0.360000 pts:-7686143364045.646484 pos:46883 size:12009 flags:1
+ret: 0 st: 0 dts:0.360000 pts:-7686143364045.646484 pos:35619 size:12009 flags:1
 ret: 0 st: 0 ts:-0.481662 flags:0
-ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:11264 size:11817 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:0 size:11817 flags:1
 ret: 0 st: 0 ts:2.412505 flags:1
-ret: 0 st: 0 dts:1.800000 pts:-7686143364045.646484 pos:212858 size:14837 flags:1
+ret: 0 st: 0 dts:1.800000 pts:-7686143364045.646484 pos:198522 size:14837 flags:1
 ret: 0 st:-1 ts:1.306672 flags:0
-ret: 0 st: 0 dts:1.320000 pts:-7686143364045.646484 pos:151065 size:14470 flags:1
+ret: 0 st: 0 dts:1.320000 pts:-7686143364045.646484 pos:136729 size:14470 flags:1
 ret: 0 st:-1 ts:0.200839 flags:1
-ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:11264 size:11817 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:0 size:11817 flags:1
 ret: 0 st: 0 ts:-0.904994 flags:0
-ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:11264 size:11817 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:0 size:11817 flags:1
 ret: 0 st: 0 ts:1.989173 flags:1
-ret: 0 st: 0 dts:1.800000 pts:-7686143364045.646484 pos:212858 size:14837 flags:1
+ret: 0 st: 0 dts:1.800000 pts:-7686143364045.646484 pos:198522 size:14837 flags:1
 ret: 0 st:-1 ts:0.883340 flags:0
-ret: 0 st: 0 dts:1.320000 pts:-7686143364045.646484 pos:151065 size:14470 flags:1
+ret: 0 st: 0 dts:1.320000 pts:-7686143364045.646484 pos:136729 size:14470 flags:1
 ret:-1 st:-1 ts:-0.222493 flags:1
 ret:-1 st: 0 ts:2.671674 flags:0
 ret: 0 st: 0 ts:1.565841 flags:1
-ret: 0 st: 0 dts:1.320000 pts:-7686143364045.646484 pos:151065 size:14470 flags:1
+ret: 0 st: 0 dts:1.320000 pts:-7686143364045.646484 pos:136729 size:14470 flags:1
 ret: 0 st:-1 ts:0.460008 flags:0
-ret: 0 st: 0 dts:0.840000 pts:-7686143364045.646484 pos:94832 size:13267 flags:1
+ret: 0 st: 0 dts:0.840000 pts:-7686143364045.646484 pos:82544 size:13267 flags:1
 ret:-1 st:-1 ts:-0.645825 flags:1
 ----------------
 tests/data/a-mpeg2.mpg
-ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:9216 size:9911 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:0 size:9911 flags:1
 ret: 0 st:-1 ts:-1.000000 flags:0
-ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:9216 size:9911 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:0 size:9911 flags:1
 ret: 0 st:-1 ts:1.894167 flags:1
-ret: 0 st: 0 dts:1.440000 pts:-7686143364045.646484 pos:139189 size:11918 flags:1
+ret: 0 st: 0 dts:1.440000 pts:-7686143364045.646484 pos:127925 size:11918 flags:1
 ret: 0 st: 0 ts:0.788334 flags:0
-ret: 0 st: 0 dts:0.960000 pts:-7686143364045.646484 pos:89343 size:10909 flags:1
+ret: 0 st: 0 dts:0.960000 pts:-7686143364045.646484 pos:79103 size:10909 flags:1
 ret:-1 st: 0 ts:-0.317499 flags:1
 ret:-1 st:-1 ts:2.576668 flags:0
 ret: 0 st:-1 ts:1.470835 flags:1
-ret: 0 st: 0 dts:1.440000 pts:-7686143364045.646484 pos:139189 size:11918 flags:1
+ret: 0 st: 0 dts:1.440000 pts:-7686143364045.646484 pos:127925 size:11918 flags:1
 ret: 0 st: 0 ts:0.365002 flags:0
-ret: 0 st: 0 dts:0.480000 pts:-7686143364045.646484 pos:48208 size:9985 flags:1
+ret: 0 st: 0 dts:0.480000 pts:-7686143364045.646484 pos:38992 size:9985 flags:1
 ret:-1 st: 0 ts:-0.740831 flags:1
 ret:-1 st:-1 ts:2.153336 flags:0
 ret: 0 st:-1 ts:1.047503 flags:1
-ret: 0 st: 0 dts:0.960000 pts:-7686143364045.646484 pos:89343 size:10909 flags:1
+ret: 0 st: 0 dts:0.960000 pts:-7686143364045.646484 pos:79103 size:10909 flags:1
 ret: 0 st: 0 ts:-0.058330 flags:0
-ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:9216 size:9911 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:0 size:9911 flags:1
 ret: 0 st: 0 ts:2.835837 flags:1
-ret: 0 st: 0 dts:1.920000 pts:-7686143364045.646484 pos:193402 size:12183 flags:1
+ret: 0 st: 0 dts:1.920000 pts:-7686143364045.646484 pos:182138 size:12183 flags:1
 ret: 0 st:-1 ts:1.730004 flags:0
-ret: 0 st: 0 dts:1.920000 pts:-7686143364045.646484 pos:193402 size:12183 flags:1
+ret: 0 st: 0 dts:1.920000 pts:-7686143364045.646484 pos:182138 size:12183 flags:1
 ret: 0 st:-1 ts:0.624171 flags:1
-ret: 0 st: 0 dts:0.480000 pts:-7686143364045.646484 pos:48208 size:9985 flags:1
+ret: 0 st: 0 dts:0.480000 pts:-7686143364045.646484 pos:38992 size:9985 flags:1
 ret: 0 st: 0 ts:-0.481662 flags:0
-ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:9216 size:9911 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:0 size:9911 flags:1
 ret: 0 st: 0 ts:2.412505 flags:1
-ret: 0 st: 0 dts:1.920000 pts:-7686143364045.646484 pos:193402 size:12183 flags:1
+ret: 0 st: 0 dts:1.920000 pts:-7686143364045.646484 pos:182138 size:12183 flags:1
 ret: 0 st:-1 ts:1.306672 flags:0
-ret: 0 st: 0 dts:1.440000 pts:-7686143364045.646484 pos:139189 size:11918 flags:1
+ret: 0 st: 0 dts:1.440000 pts:-7686143364045.646484 pos:127925 size:11918 flags:1
 ret: 0 st:-1 ts:0.200839 flags:1
-ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:9216 size:9911 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:0 size:9911 flags:1
 ret: 0 st: 0 ts:-0.904994 flags:0
-ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:9216 size:9911 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:0 size:9911 flags:1
 ret: 0 st: 0 ts:1.989173 flags:1
-ret: 0 st: 0 dts:1.920000 pts:-7686143364045.646484 pos:193402 size:12183 flags:1
+ret: 0 st: 0 dts:1.920000 pts:-7686143364045.646484 pos:182138 size:12183 flags:1
 ret: 0 st:-1 ts:0.883340 flags:0
-ret: 0 st: 0 dts:0.960000 pts:-7686143364045.646484 pos:89343 size:10909 flags:1
+ret: 0 st: 0 dts:0.960000 pts:-7686143364045.646484 pos:79103 size:10909 flags:1
 ret:-1 st:-1 ts:-0.222493 flags:1
 ret:-1 st: 0 ts:2.671674 flags:0
 ret: 0 st: 0 ts:1.565841 flags:1
-ret: 0 st: 0 dts:1.440000 pts:-7686143364045.646484 pos:139189 size:11918 flags:1
+ret: 0 st: 0 dts:1.440000 pts:-7686143364045.646484 pos:127925 size:11918 flags:1
 ret: 0 st:-1 ts:0.460008 flags:0
-ret: 0 st: 0 dts:0.480000 pts:-7686143364045.646484 pos:48208 size:9985 flags:1
+ret: 0 st: 0 dts:0.480000 pts:-7686143364045.646484 pos:38992 size:9985 flags:1
 ret:-1 st:-1 ts:-0.645825 flags:1
 ----------------
 tests/data/a-mpeg2i.mpg
-ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:9216 size:9961 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:0 size:9961 flags:1
 ret: 0 st:-1 ts:-1.000000 flags:0
-ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:9216 size:9961 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:0 size:9961 flags:1
 ret: 0 st:-1 ts:1.894167 flags:1
-ret: 0 st: 0 dts:1.440000 pts:-7686143364045.646484 pos:143871 size:11970 flags:1
+ret: 0 st: 0 dts:1.440000 pts:-7686143364045.646484 pos:132607 size:11970 flags:1
 ret: 0 st: 0 ts:0.788334 flags:0
-ret: 0 st: 0 dts:0.960000 pts:-7686143364045.646484 pos:92392 size:10965 flags:1
+ret: 0 st: 0 dts:0.960000 pts:-7686143364045.646484 pos:82152 size:10965 flags:1
 ret:-1 st: 0 ts:-0.317499 flags:1
 ret:-1 st:-1 ts:2.576668 flags:0
 ret: 0 st:-1 ts:1.470835 flags:1
-ret: 0 st: 0 dts:1.440000 pts:-7686143364045.646484 pos:143871 size:11970 flags:1
+ret: 0 st: 0 dts:1.440000 pts:-7686143364045.646484 pos:132607 size:11970 flags:1
 ret: 0 st: 0 ts:0.365002 flags:0
-ret: 0 st: 0 dts:0.480000 pts:-7686143364045.646484 pos:49762 size:10045 flags:1
+ret: 0 st: 0 dts:0.480000 pts:-7686143364045.646484 pos:40546 size:10045 flags:1
 ret:-1 st: 0 ts:-0.740831 flags:1
 ret:-1 st:-1 ts:2.153336 flags:0
 ret: 0 st:-1 ts:1.047503 flags:1
-ret: 0 st: 0 dts:0.960000 pts:-7686143364045.646484 pos:92392 size:10965 flags:1
+ret: 0 st: 0 dts:0.960000 pts:-7686143364045.646484 pos:82152 size:10965 flags:1
 ret: 0 st: 0 ts:-0.058330 flags:0
-ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:9216 size:9961 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:0 size:9961 flags:1
 ret: 0 st: 0 ts:2.835837 flags:1
-ret: 0 st: 0 dts:1.920000 pts:-7686143364045.646484 pos:199693 size:12232 flags:1
+ret: 0 st: 0 dts:1.920000 pts:-7686143364045.646484 pos:188429 size:12232 flags:1
 ret: 0 st:-1 ts:1.730004 flags:0
-ret: 0 st: 0 dts:1.920000 pts:-7686143364045.646484 pos:199693 size:12232 flags:1
+ret: 0 st: 0 dts:1.920000 pts:-7686143364045.646484 pos:188429 size:12232 flags:1
 ret: 0 st:-1 ts:0.624171 flags:1
-ret: 0 st: 0 dts:0.480000 pts:-7686143364045.646484 pos:49762 size:10045 flags:1
+ret: 0 st: 0 dts:0.480000 pts:-7686143364045.646484 pos:40546 size:10045 flags:1
 ret: 0 st: 0 ts:-0.481662 flags:0
-ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:9216 size:9961 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:0 size:9961 flags:1
 ret: 0 st: 0 ts:2.412505 flags:1
-ret: 0 st: 0 dts:1.920000 pts:-7686143364045.646484 pos:199693 size:12232 flags:1
+ret: 0 st: 0 dts:1.920000 pts:-7686143364045.646484 pos:188429 size:12232 flags:1
 ret: 0 st:-1 ts:1.306672 flags:0
-ret: 0 st: 0 dts:1.440000 pts:-7686143364045.646484 pos:143871 size:11970 flags:1
+ret: 0 st: 0 dts:1.440000 pts:-7686143364045.646484 pos:132607 size:11970 flags:1
 ret: 0 st:-1 ts:0.200839 flags:1
-ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:9216 size:9961 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:0 size:9961 flags:1
 ret: 0 st: 0 ts:-0.904994 flags:0
-ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:9216 size:9961 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:0 size:9961 flags:1
 ret: 0 st: 0 ts:1.989173 flags:1
-ret: 0 st: 0 dts:1.920000 pts:-7686143364045.646484 pos:199693 size:12232 flags:1
+ret: 0 st: 0 dts:1.920000 pts:-7686143364045.646484 pos:188429 size:12232 flags:1
 ret: 0 st:-1 ts:0.883340 flags:0
-ret: 0 st: 0 dts:0.960000 pts:-7686143364045.646484 pos:92392 size:10965 flags:1
+ret: 0 st: 0 dts:0.960000 pts:-7686143364045.646484 pos:82152 size:10965 flags:1
 ret:-1 st:-1 ts:-0.222493 flags:1
 ret:-1 st: 0 ts:2.671674 flags:0
 ret: 0 st: 0 ts:1.565841 flags:1
-ret: 0 st: 0 dts:1.440000 pts:-7686143364045.646484 pos:143871 size:11970 flags:1
+ret: 0 st: 0 dts:1.440000 pts:-7686143364045.646484 pos:132607 size:11970 flags:1
 ret: 0 st:-1 ts:0.460008 flags:0
-ret: 0 st: 0 dts:0.480000 pts:-7686143364045.646484 pos:49762 size:10045 flags:1
+ret: 0 st: 0 dts:0.480000 pts:-7686143364045.646484 pos:40546 size:10045 flags:1
 ret:-1 st:-1 ts:-0.645825 flags:1
 ----------------
 tests/data/a-mpeg2ivlc-qprd.mpg
-ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:15360 size:16239 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:0 size:16239 flags:1
 ret: 0 st:-1 ts:-1.000000 flags:0
-ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:15360 size:16239 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:0 size:16239 flags:1
 ret: 0 st:-1 ts:1.894167 flags:1
-ret: 0 st: 0 dts:1.840000 pts:-7686143364045.646484 pos:241597 size:12278 flags:1
+ret: 0 st: 0 dts:1.840000 pts:-7686143364045.646484 pos:230333 size:12278 flags:1
 ret: 0 st: 0 ts:0.788334 flags:0
-ret: 0 st: 0 dts:0.880000 pts:-7686143364045.646484 pos:181240 size:13625 flags:1
+ret: 0 st: 0 dts:0.880000 pts:-7686143364045.646484 pos:167928 size:13625 flags:1
 ret:-1 st: 0 ts:-0.317499 flags:1
 ret:-1 st:-1 ts:2.576668 flags:0
 ret: 0 st:-1 ts:1.470835 flags:1
-ret: 0 st: 0 dts:1.360000 pts:-7686143364045.646484 pos:212338 size:12777 flags:1
+ret: 0 st: 0 dts:1.360000 pts:-7686143364045.646484 pos:200050 size:12777 flags:1
 ret: 0 st: 0 ts:0.365002 flags:0
-ret: 0 st: 0 dts:0.400000 pts:-7686143364045.646484 pos:130237 size:29165 flags:1
+ret: 0 st: 0 dts:0.400000 pts:-7686143364045.646484 pos:101565 size:29165 flags:1
 ret:-1 st: 0 ts:-0.740831 flags:1
 ret:-1 st:-1 ts:2.153336 flags:0
 ret: 0 st:-1 ts:1.047503 flags:1
-ret: 0 st: 0 dts:0.880000 pts:-7686143364045.646484 pos:181240 size:13625 flags:1
+ret: 0 st: 0 dts:0.880000 pts:-7686143364045.646484 pos:167928 size:13625 flags:1
 ret: 0 st: 0 ts:-0.058330 flags:0
-ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:15360 size:16239 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:0 size:16239 flags:1
 ret: 0 st: 0 ts:2.835837 flags:1
-ret: 0 st: 0 dts:1.840000 pts:-7686143364045.646484 pos:241597 size:12278 flags:1
+ret: 0 st: 0 dts:1.840000 pts:-7686143364045.646484 pos:230333 size:12278 flags:1
 ret: 0 st:-1 ts:1.730004 flags:0
-ret: 0 st: 0 dts:1.840000 pts:-7686143364045.646484 pos:241597 size:12278 flags:1
+ret: 0 st: 0 dts:1.840000 pts:-7686143364045.646484 pos:230333 size:12278 flags:1
 ret: 0 st:-1 ts:0.624171 flags:1
-ret: 0 st: 0 dts:0.400000 pts:-7686143364045.646484 pos:130237 size:29165 flags:1
+ret: 0 st: 0 dts:0.400000 pts:-7686143364045.646484 pos:101565 size:29165 flags:1
 ret: 0 st: 0 ts:-0.481662 flags:0
-ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:15360 size:16239 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:0 size:16239 flags:1
 ret: 0 st: 0 ts:2.412505 flags:1
-ret: 0 st: 0 dts:1.840000 pts:-7686143364045.646484 pos:241597 size:12278 flags:1
+ret: 0 st: 0 dts:1.840000 pts:-7686143364045.646484 pos:230333 size:12278 flags:1
 ret: 0 st:-1 ts:1.306672 flags:0
-ret: 0 st: 0 dts:1.360000 pts:-7686143364045.646484 pos:212338 size:12777 flags:1
+ret: 0 st: 0 dts:1.360000 pts:-7686143364045.646484 pos:200050 size:12777 flags:1
 ret: 0 st:-1 ts:0.200839 flags:1
-ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:15360 size:16239 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:0 size:16239 flags:1
 ret: 0 st: 0 ts:-0.904994 flags:0
-ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:15360 size:16239 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:0 size:16239 flags:1
 ret: 0 st: 0 ts:1.989173 flags:1
-ret: 0 st: 0 dts:1.840000 pts:-7686143364045.646484 pos:241597 size:12278 flags:1
+ret: 0 st: 0 dts:1.840000 pts:-7686143364045.646484 pos:230333 size:12278 flags:1
 ret: 0 st:-1 ts:0.883340 flags:0
-ret: 0 st: 0 dts:1.360000 pts:-7686143364045.646484 pos:212338 size:12777 flags:1
+ret: 0 st: 0 dts:1.360000 pts:-7686143364045.646484 pos:200050 size:12777 flags:1
 ret:-1 st:-1 ts:-0.222493 flags:1
 ret:-1 st: 0 ts:2.671674 flags:0
 ret: 0 st: 0 ts:1.565841 flags:1
-ret: 0 st: 0 dts:1.360000 pts:-7686143364045.646484 pos:212338 size:12777 flags:1
+ret: 0 st: 0 dts:1.360000 pts:-7686143364045.646484 pos:200050 size:12777 flags:1
 ret: 0 st:-1 ts:0.460008 flags:0
-ret: 0 st: 0 dts:0.880000 pts:-7686143364045.646484 pos:181240 size:13625 flags:1
+ret: 0 st: 0 dts:0.880000 pts:-7686143364045.646484 pos:167928 size:13625 flags:1
 ret:-1 st:-1 ts:-0.645825 flags:1
 ----------------
 tests/data/a-mpeg2reuse.mpg
-ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:20480 size:20829 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:0 size:20829 flags:1
 ret: 0 st:-1 ts:-1.000000 flags:0
-ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:20480 size:20829 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:0 size:20829 flags:1
 ret: 0 st:-1 ts:1.894167 flags:1
-ret: 0 st: 0 dts:1.840000 pts:-7686143364045.646484 pos:373661 size:26840 flags:1
+ret: 0 st: 0 dts:1.840000 pts:-7686143364045.646484 pos:347037 size:26840 flags:1
 ret: 0 st: 0 ts:0.788334 flags:0
-ret: 0 st: 0 dts:0.880000 pts:-7686143364045.646484 pos:167721 size:23537 flags:1
+ret: 0 st: 0 dts:0.880000 pts:-7686143364045.646484 pos:145193 size:23537 flags:1
 ret:-1 st: 0 ts:-0.317499 flags:1
 ret:-1 st:-1 ts:2.576668 flags:0
 ret: 0 st:-1 ts:1.470835 flags:1
-ret: 0 st: 0 dts:1.360000 pts:-7686143364045.646484 pos:264461 size:26192 flags:1
+ret: 0 st: 0 dts:1.360000 pts:-7686143364045.646484 pos:238861 size:26192 flags:1
 ret: 0 st: 0 ts:0.365002 flags:0
-ret: 0 st: 0 dts:0.400000 pts:-7686143364045.646484 pos:85877 size:21295 flags:1
+ret: 0 st: 0 dts:0.400000 pts:-7686143364045.646484 pos:65397 size:21295 flags:1
 ret:-1 st: 0 ts:-0.740831 flags:1
 ret:-1 st:-1 ts:2.153336 flags:0
 ret: 0 st:-1 ts:1.047503 flags:1
-ret: 0 st: 0 dts:0.880000 pts:-7686143364045.646484 pos:167721 size:23537 flags:1
+ret: 0 st: 0 dts:0.880000 pts:-7686143364045.646484 pos:145193 size:23537 flags:1
 ret: 0 st: 0 ts:-0.058330 flags:0
-ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:20480 size:20829 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:0 size:20829 flags:1
 ret: 0 st: 0 ts:2.835837 flags:1
-ret: 0 st: 0 dts:1.840000 pts:-7686143364045.646484 pos:373661 size:26840 flags:1
+ret: 0 st: 0 dts:1.840000 pts:-7686143364045.646484 pos:347037 size:26840 flags:1
 ret: 0 st:-1 ts:1.730004 flags:0
-ret: 0 st: 0 dts:1.840000 pts:-7686143364045.646484 pos:373661 size:26840 flags:1
+ret: 0 st: 0 dts:1.840000 pts:-7686143364045.646484 pos:347037 size:26840 flags:1
 ret: 0 st:-1 ts:0.624171 flags:1
-ret: 0 st: 0 dts:0.400000 pts:-7686143364045.646484 pos:85877 size:21295 flags:1
+ret: 0 st: 0 dts:0.400000 pts:-7686143364045.646484 pos:65397 size:21295 flags:1
 ret: 0 st: 0 ts:-0.481662 flags:0
-ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:20480 size:20829 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:0 size:20829 flags:1
 ret: 0 st: 0 ts:2.412505 flags:1
-ret: 0 st: 0 dts:1.840000 pts:-7686143364045.646484 pos:373661 size:26840 flags:1
+ret: 0 st: 0 dts:1.840000 pts:-7686143364045.646484 pos:347037 size:26840 flags:1
 ret: 0 st:-1 ts:1.306672 flags:0
-ret: 0 st: 0 dts:1.360000 pts:-7686143364045.646484 pos:264461 size:26192 flags:1
+ret: 0 st: 0 dts:1.360000 pts:-7686143364045.646484 pos:238861 size:26192 flags:1
 ret: 0 st:-1 ts:0.200839 flags:1
-ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:20480 size:20829 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:0 size:20829 flags:1
 ret: 0 st: 0 ts:-0.904994 flags:0
-ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:20480 size:20829 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:0 size:20829 flags:1
 ret: 0 st: 0 ts:1.989173 flags:1
-ret: 0 st: 0 dts:1.840000 pts:-7686143364045.646484 pos:373661 size:26840 flags:1
+ret: 0 st: 0 dts:1.840000 pts:-7686143364045.646484 pos:347037 size:26840 flags:1
 ret: 0 st:-1 ts:0.883340 flags:0
-ret: 0 st: 0 dts:1.360000 pts:-7686143364045.646484 pos:264461 size:26192 flags:1
+ret: 0 st: 0 dts:1.360000 pts:-7686143364045.646484 pos:238861 size:26192 flags:1
 ret:-1 st:-1 ts:-0.222493 flags:1
 ret:-1 st: 0 ts:2.671674 flags:0
 ret: 0 st: 0 ts:1.565841 flags:1
-ret: 0 st: 0 dts:1.360000 pts:-7686143364045.646484 pos:264461 size:26192 flags:1
+ret: 0 st: 0 dts:1.360000 pts:-7686143364045.646484 pos:238861 size:26192 flags:1
 ret: 0 st:-1 ts:0.460008 flags:0
-ret: 0 st: 0 dts:0.880000 pts:-7686143364045.646484 pos:167721 size:23537 flags:1
+ret: 0 st: 0 dts:0.880000 pts:-7686143364045.646484 pos:145193 size:23537 flags:1
 ret:-1 st:-1 ts:-0.645825 flags:1
 ----------------
 tests/data/a-mpeg2thread.mpg
-ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:9216 size:9961 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:0 size:9961 flags:1
 ret: 0 st:-1 ts:-1.000000 flags:0
-ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:9216 size:9961 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:0 size:9961 flags:1
 ret: 0 st:-1 ts:1.894167 flags:1
-ret: 0 st: 0 dts:1.840000 pts:-7686143364045.646484 pos:172485 size:12232 flags:1
+ret: 0 st: 0 dts:1.840000 pts:-7686143364045.646484 pos:161221 size:12232 flags:1
 ret: 0 st: 0 ts:0.788334 flags:0
-ret: 0 st: 0 dts:0.880000 pts:-7686143364045.646484 pos:79253 size:10965 flags:1
+ret: 0 st: 0 dts:0.880000 pts:-7686143364045.646484 pos:69013 size:10965 flags:1
 ret:-1 st: 0 ts:-0.317499 flags:1
 ret:-1 st:-1 ts:2.576668 flags:0
 ret: 0 st:-1 ts:1.470835 flags:1
-ret: 0 st: 0 dts:1.360000 pts:-7686143364045.646484 pos:123712 size:11970 flags:1
+ret: 0 st: 0 dts:1.360000 pts:-7686143364045.646484 pos:112448 size:11970 flags:1
 ret: 0 st: 0 ts:0.365002 flags:0
-ret: 0 st: 0 dts:0.400000 pts:-7686143364045.646484 pos:40457 size:10045 flags:1
+ret: 0 st: 0 dts:0.400000 pts:-7686143364045.646484 pos:31241 size:10045 flags:1
 ret:-1 st: 0 ts:-0.740831 flags:1
 ret:-1 st:-1 ts:2.153336 flags:0
 ret: 0 st:-1 ts:1.047503 flags:1
-ret: 0 st: 0 dts:0.880000 pts:-7686143364045.646484 pos:79253 size:10965 flags:1
+ret: 0 st: 0 dts:0.880000 pts:-7686143364045.646484 pos:69013 size:10965 flags:1
 ret: 0 st: 0 ts:-0.058330 flags:0
-ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:9216 size:9961 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:0 size:9961 flags:1
 ret: 0 st: 0 ts:2.835837 flags:1
-ret: 0 st: 0 dts:1.840000 pts:-7686143364045.646484 pos:172485 size:12232 flags:1
+ret: 0 st: 0 dts:1.840000 pts:-7686143364045.646484 pos:161221 size:12232 flags:1
 ret: 0 st:-1 ts:1.730004 flags:0
-ret: 0 st: 0 dts:1.840000 pts:-7686143364045.646484 pos:172485 size:12232 flags:1
+ret: 0 st: 0 dts:1.840000 pts:-7686143364045.646484 pos:161221 size:12232 flags:1
 ret: 0 st:-1 ts:0.624171 flags:1
-ret: 0 st: 0 dts:0.400000 pts:-7686143364045.646484 pos:40457 size:10045 flags:1
+ret: 0 st: 0 dts:0.400000 pts:-7686143364045.646484 pos:31241 size:10045 flags:1
 ret: 0 st: 0 ts:-0.481662 flags:0
-ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:9216 size:9961 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:0 size:9961 flags:1
 ret: 0 st: 0 ts:2.412505 flags:1
-ret: 0 st: 0 dts:1.840000 pts:-7686143364045.646484 pos:172485 size:12232 flags:1
+ret: 0 st: 0 dts:1.840000 pts:-7686143364045.646484 pos:161221 size:12232 flags:1
 ret: 0 st:-1 ts:1.306672 flags:0
-ret: 0 st: 0 dts:1.360000 pts:-7686143364045.646484 pos:123712 size:11970 flags:1
+ret: 0 st: 0 dts:1.360000 pts:-7686143364045.646484 pos:112448 size:11970 flags:1
 ret: 0 st:-1 ts:0.200839 flags:1
-ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:9216 size:9961 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:0 size:9961 flags:1
 ret: 0 st: 0 ts:-0.904994 flags:0
-ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:9216 size:9961 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:0 size:9961 flags:1
 ret: 0 st: 0 ts:1.989173 flags:1
-ret: 0 st: 0 dts:1.840000 pts:-7686143364045.646484 pos:172485 size:12232 flags:1
+ret: 0 st: 0 dts:1.840000 pts:-7686143364045.646484 pos:161221 size:12232 flags:1
 ret: 0 st:-1 ts:0.883340 flags:0
-ret: 0 st: 0 dts:1.360000 pts:-7686143364045.646484 pos:123712 size:11970 flags:1
+ret: 0 st: 0 dts:1.360000 pts:-7686143364045.646484 pos:112448 size:11970 flags:1
 ret:-1 st:-1 ts:-0.222493 flags:1
 ret:-1 st: 0 ts:2.671674 flags:0
 ret: 0 st: 0 ts:1.565841 flags:1
-ret: 0 st: 0 dts:1.360000 pts:-7686143364045.646484 pos:123712 size:11970 flags:1
+ret: 0 st: 0 dts:1.360000 pts:-7686143364045.646484 pos:112448 size:11970 flags:1
 ret: 0 st:-1 ts:0.460008 flags:0
-ret: 0 st: 0 dts:0.880000 pts:-7686143364045.646484 pos:79253 size:10965 flags:1
+ret: 0 st: 0 dts:0.880000 pts:-7686143364045.646484 pos:69013 size:10965 flags:1
 ret:-1 st:-1 ts:-0.645825 flags:1
 ----------------
 tests/data/a-mpeg2threadivlc.mpg
-ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:9216 size:9954 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:0 size:9954 flags:1
 ret: 0 st:-1 ts:-1.000000 flags:0
-ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:9216 size:9954 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:0 size:9954 flags:1
 ret: 0 st:-1 ts:1.894167 flags:1
-ret: 0 st: 0 dts:1.840000 pts:-7686143364045.646484 pos:171933 size:11930 flags:1
+ret: 0 st: 0 dts:1.840000 pts:-7686143364045.646484 pos:160669 size:11930 flags:1
 ret: 0 st: 0 ts:0.788334 flags:0
-ret: 0 st: 0 dts:0.880000 pts:-7686143364045.646484 pos:79182 size:10791 flags:1
+ret: 0 st: 0 dts:0.880000 pts:-7686143364045.646484 pos:68942 size:10791 flags:1
 ret:-1 st: 0 ts:-0.317499 flags:1
 ret:-1 st:-1 ts:2.576668 flags:0
 ret: 0 st:-1 ts:1.470835 flags:1
-ret: 0 st: 0 dts:1.360000 pts:-7686143364045.646484 pos:123457 size:11697 flags:1
+ret: 0 st: 0 dts:1.360000 pts:-7686143364045.646484 pos:112193 size:11697 flags:1
 ret: 0 st: 0 ts:0.365002 flags:0
-ret: 0 st: 0 dts:0.400000 pts:-7686143364045.646484 pos:40451 size:9980 flags:1
+ret: 0 st: 0 dts:0.400000 pts:-7686143364045.646484 pos:31235 size:9980 flags:1
 ret:-1 st: 0 ts:-0.740831 flags:1
 ret:-1 st:-1 ts:2.153336 flags:0
 ret: 0 st:-1 ts:1.047503 flags:1
-ret: 0 st: 0 dts:0.880000 pts:-7686143364045.646484 pos:79182 size:10791 flags:1
+ret: 0 st: 0 dts:0.880000 pts:-7686143364045.646484 pos:68942 size:10791 flags:1
 ret: 0 st: 0 ts:-0.058330 flags:0
-ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:9216 size:9954 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:0 size:9954 flags:1
 ret: 0 st: 0 ts:2.835837 flags:1
-ret: 0 st: 0 dts:1.840000 pts:-7686143364045.646484 pos:171933 size:11930 flags:1
+ret: 0 st: 0 dts:1.840000 pts:-7686143364045.646484 pos:160669 size:11930 flags:1
 ret: 0 st:-1 ts:1.730004 flags:0
-ret: 0 st: 0 dts:1.840000 pts:-7686143364045.646484 pos:171933 size:11930 flags:1
+ret: 0 st: 0 dts:1.840000 pts:-7686143364045.646484 pos:160669 size:11930 flags:1
 ret: 0 st:-1 ts:0.624171 flags:1
-ret: 0 st: 0 dts:0.400000 pts:-7686143364045.646484 pos:40451 size:9980 flags:1
+ret: 0 st: 0 dts:0.400000 pts:-7686143364045.646484 pos:31235 size:9980 flags:1
 ret: 0 st: 0 ts:-0.481662 flags:0
-ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:9216 size:9954 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:0 size:9954 flags:1
 ret: 0 st: 0 ts:2.412505 flags:1
-ret: 0 st: 0 dts:1.840000 pts:-7686143364045.646484 pos:171933 size:11930 flags:1
+ret: 0 st: 0 dts:1.840000 pts:-7686143364045.646484 pos:160669 size:11930 flags:1
 ret: 0 st:-1 ts:1.306672 flags:0
-ret: 0 st: 0 dts:1.360000 pts:-7686143364045.646484 pos:123457 size:11697 flags:1
+ret: 0 st: 0 dts:1.360000 pts:-7686143364045.646484 pos:112193 size:11697 flags:1
 ret: 0 st:-1 ts:0.200839 flags:1
-ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:9216 size:9954 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:0 size:9954 flags:1
 ret: 0 st: 0 ts:-0.904994 flags:0
-ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:9216 size:9954 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-7686143364045.646484 pos:0 size:9954 flags:1
 ret: 0 st: 0 ts:1.989173 flags:1
-ret: 0 st: 0 dts:1.840000 pts:-7686143364045.646484 pos:171933 size:11930 flags:1
+ret: 0 st: 0 dts:1.840000 pts:-7686143364045.646484 pos:160669 size:11930 flags:1
 ret: 0 st:-1 ts:0.883340 flags:0
-ret: 0 st: 0 dts:1.360000 pts:-7686143364045.646484 pos:123457 size:11697 flags:1
+ret: 0 st: 0 dts:1.360000 pts:-7686143364045.646484 pos:112193 size:11697 flags:1
 ret:-1 st:-1 ts:-0.222493 flags:1
 ret:-1 st: 0 ts:2.671674 flags:0
 ret: 0 st: 0 ts:1.565841 flags:1
-ret: 0 st: 0 dts:1.360000 pts:-7686143364045.646484 pos:123457 size:11697 flags:1
+ret: 0 st: 0 dts:1.360000 pts:-7686143364045.646484 pos:112193 size:11697 flags:1
 ret: 0 st:-1 ts:0.460008 flags:0
-ret: 0 st: 0 dts:0.880000 pts:-7686143364045.646484 pos:79182 size:10791 flags:1
+ret: 0 st: 0 dts:0.880000 pts:-7686143364045.646484 pos:68942 size:10791 flags:1
 ret:-1 st:-1 ts:-0.645825 flags:1
 ----------------
 tests/data/a-mpeg4-Q.avi
@@ -2481,97 +2518,113 @@
 ----------------
 tests/data/b-libav.aif
 ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:54 size:4096 flags:1
-ret:-1 st:-1 ts:-1.000000 flags:0
+ret: 0 st:-1 ts:-1.000000 flags:0
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:54 size:4096 flags:1
 ret: 0 st:-1 ts:1.894167 flags:1
 ret: 0 st: 0 dts:-209146758205323.718750 pts:-209146758205323.718750 pos:167120 size:0 flags:1
 ret: 0 st: 0 ts:0.788345 flags:0
 ret: 0 st: 0 dts:0.788345 pts:0.788345 pos:69586 size:4096 flags:1
-ret:-1 st: 0 ts:-0.317506 flags:1
+ret: 0 st: 0 ts:-0.317506 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:54 size:4096 flags:1
 ret: 0 st:-1 ts:2.576668 flags:0
 ret: 0 st: 0 dts:-209146758205323.718750 pts:-209146758205323.718750 pos:227316 size:0 flags:1
 ret: 0 st:-1 ts:1.470835 flags:1
 ret: 0 st: 0 dts:-209146758205323.718750 pts:-209146758205323.718750 pos:129782 size:0 flags:1
 ret: 0 st: 0 ts:0.365011 flags:0
 ret: 0 st: 0 dts:0.365011 pts:0.365011 pos:32248 size:4096 flags:1
-ret:-1 st: 0 ts:-0.740839 flags:1
+ret: 0 st: 0 ts:-0.740839 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:54 size:4096 flags:1
 ret: 0 st:-1 ts:2.153336 flags:0
 ret: 0 st: 0 dts:-209146758205323.718750 pts:-209146758205323.718750 pos:189978 size:0 flags:1
 ret: 0 st:-1 ts:1.047503 flags:1
 ret: 0 st: 0 dts:-209146758205323.718750 pts:-209146758205323.718750 pos:92444 size:0 flags:1
-ret:-1 st: 0 ts:-0.058322 flags:0
+ret: 0 st: 0 ts:-0.058322 flags:0
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:54 size:4096 flags:1
 ret: 0 st: 0 ts:2.835828 flags:1
 ret: 0 st: 0 dts:-209146758205323.718750 pts:-209146758205323.718750 pos:250174 size:0 flags:1
 ret: 0 st:-1 ts:1.730004 flags:0
 ret: 0 st: 0 dts:-209146758205323.718750 pts:-209146758205323.718750 pos:152640 size:0 flags:1
 ret: 0 st:-1 ts:0.624171 flags:1
 ret: 0 st: 0 dts:0.624172 pts:0.624172 pos:55106 size:4096 flags:1
-ret:-1 st: 0 ts:-0.481655 flags:0
+ret: 0 st: 0 ts:-0.481655 flags:0
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:54 size:4096 flags:1
 ret: 0 st: 0 ts:2.412494 flags:1
 ret: 0 st: 0 dts:-209146758205323.718750 pts:-209146758205323.718750 pos:212836 size:0 flags:1
 ret: 0 st:-1 ts:1.306672 flags:0
 ret: 0 st: 0 dts:-209146758205323.718750 pts:-209146758205323.718750 pos:115302 size:0 flags:1
 ret: 0 st:-1 ts:0.200839 flags:1
 ret: 0 st: 0 dts:0.200839 pts:0.200839 pos:17768 size:4096 flags:1
-ret:-1 st: 0 ts:-0.904989 flags:0
+ret: 0 st: 0 ts:-0.904989 flags:0
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:54 size:4096 flags:1
 ret: 0 st: 0 ts:1.989184 flags:1
 ret: 0 st: 0 dts:-209146758205323.718750 pts:-209146758205323.718750 pos:175500 size:0 flags:1
 ret: 0 st:-1 ts:0.883340 flags:0
 ret: 0 st: 0 dts:0.883333 pts:0.883333 pos:77964 size:4096 flags:1
-ret:-1 st:-1 ts:-0.222493 flags:1
+ret: 0 st:-1 ts:-0.222493 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:54 size:4096 flags:1
 ret: 0 st: 0 ts:2.671678 flags:0
 ret: 0 st: 0 dts:-209146758205323.718750 pts:-209146758205323.718750 pos:235696 size:0 flags:1
 ret: 0 st: 0 ts:1.565850 flags:1
 ret: 0 st: 0 dts:-209146758205323.718750 pts:-209146758205323.718750 pos:138162 size:0 flags:1
 ret: 0 st:-1 ts:0.460008 flags:0
 ret: 0 st: 0 dts:0.460000 pts:0.460000 pos:40626 size:4096 flags:1
-ret:-1 st:-1 ts:-0.645825 flags:1
+ret: 0 st:-1 ts:-0.645825 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:54 size:4096 flags:1
 ----------------
 tests/data/b-libav.al
 ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:0 size:1024 flags:1
-ret:-1 st:-1 ts:-1.000000 flags:0
+ret: 0 st:-1 ts:-1.000000 flags:0
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:0 size:1024 flags:1
 ret: 0 st:-1 ts:1.894167 flags:1
 ret: 0 st: 0 dts:1.894150 pts:1.894150 pos:41766 size:1024 flags:1
 ret: 0 st: 0 ts:0.788345 flags:0
 ret: 0 st: 0 dts:0.788345 pts:0.788345 pos:17383 size:1024 flags:1
-ret:-1 st: 0 ts:-0.317506 flags:1
+ret: 0 st: 0 ts:-0.317506 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:0 size:1024 flags:1
 ret: 0 st:-1 ts:2.576668 flags:0
 ret:-5
 ret: 0 st:-1 ts:1.470835 flags:1
 ret: 0 st: 0 dts:1.470839 pts:1.470839 pos:32432 size:1024 flags:1
 ret: 0 st: 0 ts:0.364989 flags:0
 ret: 0 st: 0 dts:0.364989 pts:0.364989 pos:8048 size:1024 flags:1
-ret:-1 st: 0 ts:-0.740816 flags:1
+ret: 0 st: 0 ts:-0.740816 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:0 size:1024 flags:1
 ret: 0 st:-1 ts:2.153336 flags:0
 ret:-5
 ret: 0 st:-1 ts:1.047503 flags:1
 ret: 0 st: 0 dts:1.047483 pts:1.047483 pos:23097 size:1024 flags:1
-ret:-1 st: 0 ts:-0.058322 flags:0
+ret: 0 st: 0 ts:-0.058322 flags:0
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:0 size:1024 flags:1
 ret: 0 st: 0 ts:2.835828 flags:1
 ret:-5
 ret: 0 st:-1 ts:1.730004 flags:0
 ret: 0 st: 0 dts:1.730023 pts:1.730023 pos:38147 size:1024 flags:1
 ret: 0 st:-1 ts:0.624171 flags:1
 ret: 0 st: 0 dts:0.624172 pts:0.624172 pos:13763 size:1024 flags:1
-ret:-1 st: 0 ts:-0.481678 flags:0
+ret: 0 st: 0 ts:-0.481678 flags:0
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:0 size:1024 flags:1
 ret: 0 st: 0 ts:2.412517 flags:1
 ret:-5
 ret: 0 st:-1 ts:1.306672 flags:0
 ret: 0 st: 0 dts:1.306667 pts:1.306667 pos:28812 size:1024 flags:1
 ret: 0 st:-1 ts:0.200839 flags:1
 ret: 0 st: 0 dts:0.200816 pts:0.200816 pos:4428 size:1024 flags:1
-ret:-1 st: 0 ts:-0.904989 flags:0
+ret: 0 st: 0 ts:-0.904989 flags:0
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:0 size:1024 flags:1
 ret: 0 st: 0 ts:1.989161 flags:1
 ret: 0 st: 0 dts:1.989161 pts:1.989161 pos:43861 size:683 flags:1
 ret: 0 st:-1 ts:0.883340 flags:0
 ret: 0 st: 0 dts:0.883356 pts:0.883356 pos:19478 size:1024 flags:1
-ret:-1 st:-1 ts:-0.222493 flags:1
+ret: 0 st:-1 ts:-0.222493 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:0 size:1024 flags:1
 ret: 0 st: 0 ts:2.671655 flags:0
 ret:-5
 ret: 0 st: 0 ts:1.565850 flags:1
 ret: 0 st: 0 dts:1.565850 pts:1.565850 pos:34527 size:1024 flags:1
 ret: 0 st:-1 ts:0.460008 flags:0
 ret: 0 st: 0 dts:0.460000 pts:0.460000 pos:10143 size:1024 flags:1
-ret:-1 st:-1 ts:-0.645825 flags:1
+ret: 0 st:-1 ts:-0.645825 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:0 size:1024 flags:1
 ----------------
 tests/data/b-libav.asf
 ret: 0 st: 0 dts:3.100000 pts:3.100000 pos:575 size:28874 flags:1
@@ -2630,50 +2683,58 @@
 ----------------
 tests/data/b-libav.au
 ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:24 size:4096 flags:1
-ret:-1 st:-1 ts:-1.000000 flags:0
+ret: 0 st:-1 ts:-1.000000 flags:0
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:24 size:4096 flags:1
 ret: 0 st:-1 ts:1.894167 flags:1
 ret: 0 st: 0 dts:-209146758205323.718750 pts:-209146758205323.718750 pos:167090 size:0 flags:1
 ret: 0 st: 0 ts:0.788345 flags:0
 ret: 0 st: 0 dts:0.788345 pts:0.788345 pos:69556 size:4096 flags:1
-ret:-1 st: 0 ts:-0.317506 flags:1
+ret: 0 st: 0 ts:-0.317506 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:24 size:4096 flags:1
 ret: 0 st:-1 ts:2.576668 flags:0
 ret: 0 st: 0 dts:-209146758205323.718750 pts:-209146758205323.718750 pos:227286 size:0 flags:1
 ret: 0 st:-1 ts:1.470835 flags:1
 ret: 0 st: 0 dts:-209146758205323.718750 pts:-209146758205323.718750 pos:129752 size:0 flags:1
 ret: 0 st: 0 ts:0.365011 flags:0
 ret: 0 st: 0 dts:0.365011 pts:0.365011 pos:32218 size:4096 flags:1
-ret:-1 st: 0 ts:-0.740839 flags:1
+ret: 0 st: 0 ts:-0.740839 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:24 size:4096 flags:1
 ret: 0 st:-1 ts:2.153336 flags:0
 ret: 0 st: 0 dts:-209146758205323.718750 pts:-209146758205323.718750 pos:189948 size:0 flags:1
 ret: 0 st:-1 ts:1.047503 flags:1
 ret: 0 st: 0 dts:-209146758205323.718750 pts:-209146758205323.718750 pos:92414 size:0 flags:1
-ret:-1 st: 0 ts:-0.058322 flags:0
+ret: 0 st: 0 ts:-0.058322 flags:0
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:24 size:4096 flags:1
 ret: 0 st: 0 ts:2.835828 flags:1
 ret: 0 st: 0 dts:-209146758205323.718750 pts:-209146758205323.718750 pos:250144 size:0 flags:1
 ret: 0 st:-1 ts:1.730004 flags:0
 ret: 0 st: 0 dts:-209146758205323.718750 pts:-209146758205323.718750 pos:152610 size:0 flags:1
 ret: 0 st:-1 ts:0.624171 flags:1
 ret: 0 st: 0 dts:0.624172 pts:0.624172 pos:55076 size:4096 flags:1
-ret:-1 st: 0 ts:-0.481655 flags:0
+ret: 0 st: 0 ts:-0.481655 flags:0
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:24 size:4096 flags:1
 ret: 0 st: 0 ts:2.412494 flags:1
 ret: 0 st: 0 dts:-209146758205323.718750 pts:-209146758205323.718750 pos:212806 size:0 flags:1
 ret: 0 st:-1 ts:1.306672 flags:0
 ret: 0 st: 0 dts:-209146758205323.718750 pts:-209146758205323.718750 pos:115272 size:0 flags:1
 ret: 0 st:-1 ts:0.200839 flags:1
 ret: 0 st: 0 dts:0.200839 pts:0.200839 pos:17738 size:4096 flags:1
-ret:-1 st: 0 ts:-0.904989 flags:0
+ret: 0 st: 0 ts:-0.904989 flags:0
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:24 size:4096 flags:1
 ret: 0 st: 0 ts:1.989184 flags:1
 ret: 0 st: 0 dts:-209146758205323.718750 pts:-209146758205323.718750 pos:175470 size:0 flags:1
 ret: 0 st:-1 ts:0.883340 flags:0
 ret: 0 st: 0 dts:0.883333 pts:0.883333 pos:77934 size:4096 flags:1
-ret:-1 st:-1 ts:-0.222493 flags:1
+ret: 0 st:-1 ts:-0.222493 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:24 size:4096 flags:1
 ret: 0 st: 0 ts:2.671678 flags:0
 ret: 0 st: 0 dts:-209146758205323.718750 pts:-209146758205323.718750 pos:235666 size:0 flags:1
 ret: 0 st: 0 ts:1.565850 flags:1
 ret: 0 st: 0 dts:-209146758205323.718750 pts:-209146758205323.718750 pos:138132 size:0 flags:1
 ret: 0 st:-1 ts:0.460008 flags:0
 ret: 0 st: 0 dts:0.460000 pts:0.460000 pos:40596 size:4096 flags:1
-ret:-1 st:-1 ts:-0.645825 flags:1
+ret: 0 st:-1 ts:-0.645825 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:24 size:4096 flags:1
 ----------------
 tests/data/b-libav.avi
 ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:9908 size:28118 flags:1
@@ -2779,7 +2840,7 @@
 tests/data/b-libav.ffm
 ret: 0 st: 0 dts:-0.040000 pts:0.000000 pos:8192 size:24795 flags:1
 ret: 0 st:-1 ts:-1.000000 flags:0
-ret: 0 st: 1 dts:0.940408 pts:0.940408 pos:380928 size:209 flags:1
+ret: 0 st: 0 dts:-0.040000 pts:0.000000 pos:8192 size:24795 flags:1
 ret: 0 st:-1 ts:1.894167 flags:1
 ret: 0 st: 1 dts:0.940408 pts:0.940408 pos:380928 size:209 flags:1
 ret: 0 st: 0 ts:0.788334 flags:0
@@ -2787,7 +2848,7 @@
 ret: 0 st: 0 ts:-0.317499 flags:1
 ret: 0 st: 0 dts:-0.040000 pts:0.000000 pos:8192 size:24795 flags:1
 ret: 0 st: 1 ts:2.576668 flags:0
-ret: 0 st: 1 dts:0.888163 pts:0.888163 pos:356352 size:209 flags:1
+ret: 0 st: 1 dts:0.940408 pts:0.940408 pos:380928 size:209 flags:1
 ret: 0 st: 1 ts:1.470835 flags:1
 ret: 0 st: 1 dts:0.940408 pts:0.940408 pos:380928 size:209 flags:1
 ret: 0 st:-1 ts:0.365002 flags:0
@@ -2795,27 +2856,27 @@
 ret: 0 st:-1 ts:-0.740831 flags:1
 ret: 0 st: 0 dts:-0.040000 pts:0.000000 pos:8192 size:24795 flags:1
 ret: 0 st: 0 ts:2.153336 flags:0
-ret: 0 st: 1 dts:0.888163 pts:0.888163 pos:356352 size:209 flags:1
+ret: 0 st: 1 dts:0.940408 pts:0.940408 pos:380928 size:209 flags:1
 ret: 0 st: 0 ts:1.047503 flags:1
 ret: 0 st: 1 dts:0.940408 pts:0.940408 pos:380928 size:209 flags:1
 ret: 0 st: 1 ts:-0.058330 flags:0
-ret: 0 st: 1 dts:0.940408 pts:0.940408 pos:380928 size:209 flags:1
+ret: 0 st: 0 dts:-0.040000 pts:0.000000 pos:8192 size:24795 flags:1
 ret: 0 st: 1 ts:2.835837 flags:1
 ret: 0 st: 1 dts:0.940408 pts:0.940408 pos:380928 size:209 flags:1
 ret: 0 st:-1 ts:1.730004 flags:0
-ret: 0 st: 1 dts:0.888163 pts:0.888163 pos:356352 size:209 flags:1
-ret: 0 st:-1 ts:0.624171 flags:1
-ret: 0 st: 1 dts:0.600816 pts:0.600816 pos:266240 size:209 flags:1
-ret: 0 st: 0 ts:-0.481662 flags:0
 ret: 0 st: 1 dts:0.940408 pts:0.940408 pos:380928 size:209 flags:1
+ret: 0 st:-1 ts:0.624171 flags:1
+ret: 0 st: 1 dts:0.653061 pts:0.653061 pos:282624 size:209 flags:1
+ret: 0 st: 0 ts:-0.481662 flags:0
+ret: 0 st: 0 dts:-0.040000 pts:0.000000 pos:8192 size:24795 flags:1
 ret: 0 st: 0 ts:2.412505 flags:1
 ret: 0 st: 1 dts:0.940408 pts:0.940408 pos:380928 size:209 flags:1
 ret: 0 st: 1 ts:1.306672 flags:0
-ret: 0 st: 1 dts:0.888163 pts:0.888163 pos:356352 size:209 flags:1
-ret: 0 st: 1 ts:0.200839 flags:1
-ret: 0 st: 1 dts:0.182857 pts:0.182857 pos:102400 size:209 flags:1
-ret: 0 st:-1 ts:-0.904994 flags:0
 ret: 0 st: 1 dts:0.940408 pts:0.940408 pos:380928 size:209 flags:1
+ret: 0 st: 1 ts:0.200839 flags:1
+ret: 0 st: 1 dts:0.208980 pts:0.208980 pos:118784 size:209 flags:1
+ret: 0 st:-1 ts:-0.904994 flags:0
+ret: 0 st: 0 dts:-0.040000 pts:0.000000 pos:8192 size:24795 flags:1
 ret: 0 st:-1 ts:1.989173 flags:1
 ret: 0 st: 1 dts:0.940408 pts:0.940408 pos:380928 size:209 flags:1
 ret: 0 st: 0 ts:0.883340 flags:0
@@ -2823,7 +2884,7 @@
 ret: 0 st: 0 ts:-0.222493 flags:1
 ret: 0 st: 0 dts:-0.040000 pts:0.000000 pos:8192 size:24795 flags:1
 ret: 0 st: 1 ts:2.671674 flags:0
-ret: 0 st: 1 dts:0.888163 pts:0.888163 pos:356352 size:209 flags:1
+ret: 0 st: 1 dts:0.940408 pts:0.940408 pos:380928 size:209 flags:1
 ret: 0 st: 1 ts:1.565841 flags:1
 ret: 0 st: 1 dts:0.940408 pts:0.940408 pos:380928 size:209 flags:1
 ret: 0 st:-1 ts:0.460008 flags:0
@@ -2907,59 +2968,59 @@
 ret:-22 st:-1 ts:-0.645825 flags:1
 ----------------
 tests/data/b-libav.gxf
-ret: 0 st: 0 dts:0.000000 pts:-184467440737095520.000000 pos:752 size:55076 flags:1
+ret: 0 st: 1 dts:0.000000 pts:0.000000 pos:5024 size:65536 flags:1
 ret: 0 st:-1 ts:-1.000000 flags:0
-ret: 0 st: 1 dts:0.000000 pts:0.000000 pos:55860 size:65536 flags:1
+ret: 0 st: 1 dts:0.000000 pts:0.000000 pos:5024 size:65536 flags:1
 ret: 0 st:-1 ts:1.894167 flags:1
-ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751660 size:54320 flags:1
+ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:755932 size:54320 flags:1
 ret: 0 st: 0 ts:0.780000 flags:0
-ret: 0 st: 0 dts:0.800000 pts:-184467440737095520.000000 pos:661360 size:22568 flags:0
+ret: 0 st: 0 dts:0.800000 pts:-184467440737095520.000000 pos:665632 size:22568 flags:0
 ret: 0 st: 0 ts:-0.320000 flags:1
-ret: 0 st: 0 dts:0.000000 pts:-184467440737095520.000000 pos:752 size:55076 flags:1
+ret: 0 st: 1 dts:0.000000 pts:0.000000 pos:5024 size:65536 flags:1
 ret: 0 st: 1 ts:2.580000 flags:0
-ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751660 size:54320 flags:1
+ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:755932 size:54320 flags:1
 ret: 0 st: 1 ts:1.480000 flags:1
-ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751660 size:54320 flags:1
-ret: 0 st:-1 ts:0.365002 flags:0
-ret: 0 st: 0 dts:0.360000 pts:-184467440737095520.000000 pos:303896 size:23176 flags:0
-ret: 0 st:-1 ts:-0.740831 flags:1
-ret: 0 st: 0 dts:0.000000 pts:-184467440737095520.000000 pos:752 size:55076 flags:1
-ret: 0 st: 0 ts:2.160000 flags:0
-ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751660 size:54320 flags:1
-ret: 0 st: 0 ts:1.040000 flags:1
-ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751660 size:54320 flags:1
-ret: 0 st: 1 ts:-0.060000 flags:0
-ret: 0 st: 1 dts:0.000000 pts:0.000000 pos:55860 size:65536 flags:1
-ret: 0 st: 1 ts:2.840000 flags:1
-ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751660 size:54320 flags:1
-ret: 0 st:-1 ts:1.730004 flags:0
-ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751660 size:54320 flags:1
-ret: 0 st:-1 ts:0.624171 flags:1
-ret: 0 st: 0 dts:0.600000 pts:-184467440737095520.000000 pos:476172 size:23728 flags:0
-ret: 0 st: 0 ts:-0.480000 flags:0
-ret: 0 st: 1 dts:0.000000 pts:0.000000 pos:55860 size:65536 flags:1
-ret: 0 st: 0 ts:2.420000 flags:1
-ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751660 size:54320 flags:1
-ret: 0 st: 1 ts:1.300000 flags:0
-ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751660 size:54320 flags:1
-ret: 0 st: 1 ts:0.200000 flags:1
-ret: 0 st: 0 dts:0.200000 pts:-184467440737095520.000000 pos:211056 size:20944 flags:0
-ret: 0 st:-1 ts:-0.904994 flags:0
-ret: 0 st: 1 dts:0.000000 pts:0.000000 pos:55860 size:65536 flags:1
-ret: 0 st:-1 ts:1.989173 flags:1
-ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751660 size:54320 flags:1
-ret: 0 st: 0 ts:0.880000 flags:0
-ret: 0 st: 0 dts:0.880000 pts:-184467440737095520.000000 pos:706776 size:22456 flags:0
-ret: 0 st: 0 ts:-0.220000 flags:1
-ret: 0 st: 0 dts:0.000000 pts:-184467440737095520.000000 pos:752 size:55076 flags:1
-ret: 0 st: 1 ts:2.680000 flags:0
-ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751660 size:54320 flags:1
-ret: 0 st: 1 ts:1.560000 flags:1
-ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751660 size:54320 flags:1
+ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:755932 size:54320 flags:1
+ret: 0 st: 2 ts:0.360000 flags:0
+ret: 0 st: 0 dts:0.360000 pts:-184467440737095520.000000 pos:308168 size:23176 flags:0
+ret: 0 st: 2 ts:-0.740000 flags:1
+ret: 0 st: 1 dts:0.000000 pts:0.000000 pos:5024 size:65536 flags:1
+ret: 0 st:-1 ts:2.153336 flags:0
+ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:755932 size:54320 flags:1
+ret: 0 st:-1 ts:1.047503 flags:1
+ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:755932 size:54320 flags:1
+ret: 0 st: 0 ts:-0.060000 flags:0
+ret: 0 st: 1 dts:0.000000 pts:0.000000 pos:5024 size:65536 flags:1
+ret: 0 st: 0 ts:2.840000 flags:1
+ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:755932 size:54320 flags:1
+ret: 0 st: 1 ts:1.740000 flags:0
+ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:755932 size:54320 flags:1
+ret: 0 st: 1 ts:0.620000 flags:1
+ret: 0 st: 0 dts:0.640000 pts:-184467440737095520.000000 pos:504204 size:22976 flags:0
+ret: 0 st: 2 ts:-0.480000 flags:0
+ret: 0 st: 1 dts:0.000000 pts:0.000000 pos:5024 size:65536 flags:1
+ret: 0 st: 2 ts:2.420000 flags:1
+ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:755932 size:54320 flags:1
+ret: 0 st:-1 ts:1.306672 flags:0
+ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:755932 size:54320 flags:1
+ret: 0 st:-1 ts:0.200839 flags:1
+ret: 0 st: 0 dts:0.200000 pts:-184467440737095520.000000 pos:215328 size:20944 flags:0
+ret: 0 st: 0 ts:-0.900000 flags:0
+ret: 0 st: 1 dts:0.000000 pts:0.000000 pos:5024 size:65536 flags:1
+ret: 0 st: 0 ts:1.980000 flags:1
+ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:755932 size:54320 flags:1
+ret: 0 st: 1 ts:0.880000 flags:0
+ret: 0 st: 0 dts:0.880000 pts:-184467440737095520.000000 pos:711048 size:22456 flags:0
+ret: 0 st: 1 ts:-0.220000 flags:1
+ret: 0 st: 1 dts:0.000000 pts:0.000000 pos:5024 size:65536 flags:1
+ret: 0 st: 2 ts:2.680000 flags:0
+ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:755932 size:54320 flags:1
+ret: 0 st: 2 ts:1.560000 flags:1
+ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:755932 size:54320 flags:1
 ret: 0 st:-1 ts:0.460008 flags:0
-ret: 0 st: 0 dts:0.480000 pts:-184467440737095520.000000 pos:371520 size:53804 flags:1
+ret: 0 st: 0 dts:0.480000 pts:-184467440737095520.000000 pos:375792 size:53804 flags:1
 ret: 0 st:-1 ts:-0.645825 flags:1
-ret: 0 st: 0 dts:0.000000 pts:-184467440737095520.000000 pos:752 size:55076 flags:1
+ret: 0 st: 1 dts:0.000000 pts:0.000000 pos:5024 size:65536 flags:1
 ----------------
 tests/data/b-libav.mkv
 ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:505 size:28088 flags:1
@@ -3150,6 +3211,116 @@
 ret: 0 st:-1 ts:-0.645825 flags:1
 ret: 0 st: 1 dts:0.500000 pts:0.500000 pos:-1 size:208 flags:1
 ----------------
+tests/data/b-libav.mxf
+ret: 0 st: 0 dts:0.000000 pts:-368934881474191040.000000 pos:6144 size:24921 flags:1
+ret: 0 st:-1 ts:-1.000000 flags:0
+ret: 0 st: 0 dts:0.000000 pts:-368934881474191040.000000 pos:6144 size:24921 flags:1
+ret: 0 st:-1 ts:1.894167 flags:1
+ret:-1
+ret: 0 st: 0 ts:0.800000 flags:0
+ret:-1
+ret: 0 st: 0 ts:-0.320000 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-368934881474191040.000000 pos:6144 size:24921 flags:1
+ret: 0 st: 1 ts:2.560000 flags:0
+ret:-1
+ret: 0 st: 1 ts:1.480000 flags:1
+ret:-1
+ret: 0 st:-1 ts:0.365002 flags:0
+ret: 0 st: 0 dts:0.360000 pts:-368934881474191040.000000 pos:6144 size:24921 flags:1
+ret: 0 st:-1 ts:-0.740831 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-368934881474191040.000000 pos:6144 size:24921 flags:1
+ret: 0 st: 0 ts:2.160000 flags:0
+ret:-1
+ret: 0 st: 0 ts:1.040000 flags:1
+ret:-1
+ret: 0 st: 1 ts:-0.040000 flags:0
+ret: 0 st: 0 dts:0.000000 pts:-368934881474191040.000000 pos:6144 size:24921 flags:1
+ret: 0 st: 1 ts:2.840000 flags:1
+ret:-1
+ret: 0 st:-1 ts:1.730004 flags:0
+ret:-1
+ret: 0 st:-1 ts:0.624171 flags:1
+ret:-1
+ret: 0 st: 0 ts:-0.480000 flags:0
+ret: 0 st: 0 dts:0.000000 pts:-368934881474191040.000000 pos:6144 size:24921 flags:1
+ret: 0 st: 0 ts:2.400000 flags:1
+ret:-1
+ret: 0 st: 1 ts:1.320000 flags:0
+ret:-1
+ret: 0 st: 1 ts:0.200000 flags:1
+ret: 0 st: 0 dts:0.200000 pts:-368934881474191040.000000 pos:6144 size:24921 flags:1
+ret: 0 st:-1 ts:-0.904994 flags:0
+ret: 0 st: 0 dts:0.000000 pts:-368934881474191040.000000 pos:6144 size:24921 flags:1
+ret: 0 st:-1 ts:1.989173 flags:1
+ret:-1
+ret: 0 st: 0 ts:0.880000 flags:0
+ret:-1
+ret: 0 st: 0 ts:-0.240000 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-368934881474191040.000000 pos:6144 size:24921 flags:1
+ret: 0 st: 1 ts:2.680000 flags:0
+ret:-1
+ret: 0 st: 1 ts:1.560000 flags:1
+ret:-1
+ret: 0 st:-1 ts:0.460008 flags:0
+ret: 0 st: 0 dts:0.480000 pts:-368934881474191040.000000 pos:6144 size:24921 flags:1
+ret: 0 st:-1 ts:-0.645825 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-368934881474191040.000000 pos:6144 size:24921 flags:1
+----------------
+tests/data/b-libav.mxf_d10
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:6144 size:150000 flags:1
+ret: 0 st:-1 ts:-1.000000 flags:0
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:6144 size:150000 flags:1
+ret: 0 st:-1 ts:1.894167 flags:1
+ret:-1
+ret: 0 st: 0 ts:0.800000 flags:0
+ret:-1
+ret: 0 st: 0 ts:-0.320000 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:6144 size:150000 flags:1
+ret: 0 st: 1 ts:2.560000 flags:0
+ret:-1
+ret: 0 st: 1 ts:1.480000 flags:1
+ret:-1
+ret: 0 st:-1 ts:0.365002 flags:0
+ret: 0 st: 0 dts:0.360000 pts:0.360000 pos:6144 size:150000 flags:1
+ret: 0 st:-1 ts:-0.740831 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:6144 size:150000 flags:1
+ret: 0 st: 0 ts:2.160000 flags:0
+ret:-1
+ret: 0 st: 0 ts:1.040000 flags:1
+ret:-1
+ret: 0 st: 1 ts:-0.040000 flags:0
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:6144 size:150000 flags:1
+ret: 0 st: 1 ts:2.840000 flags:1
+ret:-1
+ret: 0 st:-1 ts:1.730004 flags:0
+ret:-1
+ret: 0 st:-1 ts:0.624171 flags:1
+ret:-1
+ret: 0 st: 0 ts:-0.480000 flags:0
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:6144 size:150000 flags:1
+ret: 0 st: 0 ts:2.400000 flags:1
+ret:-1
+ret: 0 st: 1 ts:1.320000 flags:0
+ret:-1
+ret: 0 st: 1 ts:0.200000 flags:1
+ret: 0 st: 0 dts:0.200000 pts:0.200000 pos:6144 size:150000 flags:1
+ret: 0 st:-1 ts:-0.904994 flags:0
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:6144 size:150000 flags:1
+ret: 0 st:-1 ts:1.989173 flags:1
+ret:-1
+ret: 0 st: 0 ts:0.880000 flags:0
+ret:-1
+ret: 0 st: 0 ts:-0.240000 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:6144 size:150000 flags:1
+ret: 0 st: 1 ts:2.680000 flags:0
+ret:-1
+ret: 0 st: 1 ts:1.560000 flags:1
+ret:-1
+ret: 0 st:-1 ts:0.460008 flags:0
+ret: 0 st: 0 dts:0.480000 pts:0.480000 pos:6144 size:150000 flags:1
+ret: 0 st:-1 ts:-0.645825 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:6144 size:150000 flags:1
+----------------
 tests/data/b-libav.nut
 ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:279 size:28088 flags:1
 ret: 0 st:-1 ts:-1.000000 flags:0
@@ -3403,7 +3574,7 @@
 ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:398 size:31393 flags:1
 ----------------
 tests/data/b-libav.swf
-ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:65 size:31385 flags:0
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:55 size:31385 flags:0
 ret:-1 st:-1 ts:-1.000000 flags:0
 ret:-1 st:-1 ts:1.894167 flags:1
 ret:-1 st: 0 ts:0.800000 flags:0
@@ -3432,106 +3603,114 @@
 ret:-1 st:-1 ts:-0.645825 flags:1
 ----------------
 tests/data/b-libav.ts
-ret: 0 st: 0 dts:0.660000 pts:0.700000 pos:29328 size:24921 flags:1
+ret: 0 st: 0 dts:0.660000 pts:0.700000 pos:564 size:24921 flags:1
 ret: 0 st:-1 ts:-1.000000 flags:0
 ret: 0 st: 0 dts:0.030522 pts:-102481911520608.625000 pos:29328 size:22036 flags:1
 ret: 0 st:-1 ts:1.894167 flags:1
-ret: 0 st: 0 dts:1.887078 pts:-102481911520608.625000 pos:101520 size:7907 flags:1
+ret: 0 st: 0 dts:1.887078 pts:-102481911520608.625000 pos:29328 size:7907 flags:1
 ret: 0 st: 0 ts:0.788333 flags:0
-ret: 0 st: 0 dts:0.795878 pts:-102481911520608.625000 pos:50948 size:9043 flags:1
+ret: 0 st: 0 dts:0.795878 pts:-102481911520608.625000 pos:101520 size:9043 flags:1
 ret: 0 st: 0 ts:-0.317500 flags:1
-ret: 0 st: 0 dts:0.019156 pts:-102481911520608.625000 pos:29328 size:22036 flags:1
+ret: 0 st: 0 dts:0.019156 pts:-102481911520608.625000 pos:50948 size:22036 flags:1
 ret: 0 st: 1 ts:2.576667 flags:0
-ret: 0 st: 0 dts:2.580444 pts:-102481911520608.625000 pos:134044 size:5727 flags:1
+ret: 0 st: 0 dts:2.580444 pts:-102481911520608.625000 pos:29328 size:5727 flags:1
 ret: 0 st: 1 ts:1.470833 flags:1
-ret: 0 st: 0 dts:1.466511 pts:-102481911520608.625000 pos:83472 size:10244 flags:1
+ret: 0 st: 0 dts:1.466511 pts:-102481911520608.625000 pos:134044 size:10244 flags:1
 ret: 0 st:-1 ts:0.365002 flags:0
-ret: 0 st: 0 dts:0.379100 pts:-102481911520608.625000 pos:29328 size:7376 flags:1
+ret: 0 st: 0 dts:0.379100 pts:-102481911520608.625000 pos:83472 size:7376 flags:1
 ret: 0 st:-1 ts:-0.740831 flags:1
 ret: 0 st: 0 dts:0.019156 pts:-102481911520608.625000 pos:29328 size:22036 flags:1
 ret: 0 st: 0 ts:2.153333 flags:0
-ret: 0 st: 0 dts:2.156089 pts:-102481911520608.625000 pos:115996 size:8674 flags:1
+ret: 0 st: 0 dts:2.156089 pts:-102481911520608.625000 pos:29328 size:8674 flags:1
 ret: 0 st: 0 ts:1.047500 flags:1
-ret: 0 st: 0 dts:1.042156 pts:-102481911520608.625000 pos:68996 size:11942 flags:1
+ret: 0 st: 0 dts:1.042156 pts:-102481911520608.625000 pos:115996 size:11942 flags:1
 ret: 0 st: 1 ts:-0.058333 flags:0
-ret: 0 st: 0 dts:0.030522 pts:-102481911520608.625000 pos:29328 size:22036 flags:1
+ret: 0 st: 0 dts:0.030522 pts:-102481911520608.625000 pos:68996 size:22036 flags:1
 ret: 0 st: 1 ts:2.835833 flags:1
-ret: 0 st: 0 dts:2.822933 pts:-102481911520608.625000 pos:152092 size:10429 flags:1
+ret: 0 st: 0 dts:2.822933 pts:-102481911520608.625000 pos:29328 size:10429 flags:1
 ret: 0 st:-1 ts:1.730004 flags:0
-ret: 0 st: 0 dts:1.731733 pts:-102481911520608.625000 pos:101520 size:13769 flags:1
+ret: 0 st: 0 dts:1.731733 pts:-102481911520608.625000 pos:152092 size:13769 flags:1
 ret: 0 st:-1 ts:0.624171 flags:1
-ret: 0 st: 0 dts:0.617800 pts:-102481911520608.625000 pos:50948 size:14905 flags:1
+ret: 0 st: 0 dts:0.617800 pts:-102481911520608.625000 pos:101520 size:14905 flags:1
 ret: 0 st: 0 ts:-0.481667 flags:0
-ret: 0 st: 0 dts:0.030522 pts:-102481911520608.625000 pos:29328 size:22036 flags:1
+ret: 0 st: 0 dts:0.030522 pts:-102481911520608.625000 pos:50948 size:22036 flags:1
 ret: 0 st: 0 ts:2.412500 flags:1
-ret: 0 st: 0 dts:2.406156 pts:-102481911520608.625000 pos:134044 size:13938 flags:1
+ret: 0 st: 0 dts:2.406156 pts:-102481911520608.625000 pos:119568 size:13938 flags:1
 ret: 0 st: 1 ts:1.306667 flags:0
-ret: 0 st: 0 dts:1.314956 pts:-102481911520608.625000 pos:68996 size:3107 flags:1
+ret: 0 st: 0 dts:1.314956 pts:-102481911520608.625000 pos:65424 size:3107 flags:1
 ret: 0 st: 1 ts:0.200844 flags:1
-ret: 0 st: 0 dts:0.193444 pts:-102481911520608.625000 pos:29328 size:16166 flags:1
+ret: 0 st: 0 dts:0.193444 pts:-102481911520608.625000 pos:68996 size:16166 flags:1
 ret: 0 st:-1 ts:-0.904994 flags:0
 ret: 0 st: 0 dts:0.030522 pts:-102481911520608.625000 pos:29328 size:22036 flags:1
 ret: 0 st:-1 ts:1.989173 flags:1
-ret: 0 st: 0 dts:1.981800 pts:-102481911520608.625000 pos:101520 size:2039 flags:1
+ret: 0 st: 0 dts:1.981800 pts:-102481911520608.625000 pos:29328 size:2039 flags:1
 ret: 0 st: 0 ts:0.883344 flags:0
-ret: 0 st: 0 dts:0.890600 pts:-102481911520608.625000 pos:50948 size:3175 flags:1
+ret: 0 st: 0 dts:0.890600 pts:-102481911520608.625000 pos:101520 size:3175 flags:1
 ret: 0 st: 0 ts:-0.222489 flags:1
-ret: 0 st: 0 dts:0.019156 pts:-102481911520608.625000 pos:29328 size:22036 flags:1
+ret: 0 st: 0 dts:0.019156 pts:-102481911520608.625000 pos:50948 size:22036 flags:1
 ret: 0 st: 1 ts:2.671678 flags:0
-ret: 0 st: 0 dts:2.682744 pts:-102481911520608.625000 pos:134044 size:2253 flags:1
+ret: 0 st: 0 dts:2.682744 pts:-102481911520608.625000 pos:29328 size:2253 flags:1
 ret: 0 st: 1 ts:1.565844 flags:1
-ret: 0 st: 0 dts:1.557444 pts:-102481911520608.625000 pos:83472 size:5682 flags:1
+ret: 0 st: 0 dts:1.557444 pts:-102481911520608.625000 pos:134044 size:5682 flags:1
 ret: 0 st:-1 ts:0.460008 flags:0
-ret: 0 st: 0 dts:0.466244 pts:-102481911520608.625000 pos:29328 size:4446 flags:1
+ret: 0 st: 0 dts:0.466244 pts:-102481911520608.625000 pos:83472 size:4446 flags:1
 ret: 0 st:-1 ts:-0.645825 flags:1
 ret: 0 st: 0 dts:0.019156 pts:-102481911520608.625000 pos:29328 size:22036 flags:1
 ----------------
 tests/data/b-libav.ul
 ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:0 size:1024 flags:1
-ret:-1 st:-1 ts:-1.000000 flags:0
+ret: 0 st:-1 ts:-1.000000 flags:0
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:0 size:1024 flags:1
 ret: 0 st:-1 ts:1.894167 flags:1
 ret: 0 st: 0 dts:1.894150 pts:1.894150 pos:41766 size:1024 flags:1
 ret: 0 st: 0 ts:0.788345 flags:0
 ret: 0 st: 0 dts:0.788345 pts:0.788345 pos:17383 size:1024 flags:1
-ret:-1 st: 0 ts:-0.317506 flags:1
+ret: 0 st: 0 ts:-0.317506 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:0 size:1024 flags:1
 ret: 0 st:-1 ts:2.576668 flags:0
 ret:-5
 ret: 0 st:-1 ts:1.470835 flags:1
 ret: 0 st: 0 dts:1.470839 pts:1.470839 pos:32432 size:1024 flags:1
 ret: 0 st: 0 ts:0.364989 flags:0
 ret: 0 st: 0 dts:0.364989 pts:0.364989 pos:8048 size:1024 flags:1
-ret:-1 st: 0 ts:-0.740816 flags:1
+ret: 0 st: 0 ts:-0.740816 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:0 size:1024 flags:1
 ret: 0 st:-1 ts:2.153336 flags:0
 ret:-5
 ret: 0 st:-1 ts:1.047503 flags:1
 ret: 0 st: 0 dts:1.047483 pts:1.047483 pos:23097 size:1024 flags:1
-ret:-1 st: 0 ts:-0.058322 flags:0
+ret: 0 st: 0 ts:-0.058322 flags:0
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:0 size:1024 flags:1
 ret: 0 st: 0 ts:2.835828 flags:1
 ret:-5
 ret: 0 st:-1 ts:1.730004 flags:0
 ret: 0 st: 0 dts:1.730023 pts:1.730023 pos:38147 size:1024 flags:1
 ret: 0 st:-1 ts:0.624171 flags:1
 ret: 0 st: 0 dts:0.624172 pts:0.624172 pos:13763 size:1024 flags:1
-ret:-1 st: 0 ts:-0.481678 flags:0
+ret: 0 st: 0 ts:-0.481678 flags:0
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:0 size:1024 flags:1
 ret: 0 st: 0 ts:2.412517 flags:1
 ret:-5
 ret: 0 st:-1 ts:1.306672 flags:0
 ret: 0 st: 0 dts:1.306667 pts:1.306667 pos:28812 size:1024 flags:1
 ret: 0 st:-1 ts:0.200839 flags:1
 ret: 0 st: 0 dts:0.200816 pts:0.200816 pos:4428 size:1024 flags:1
-ret:-1 st: 0 ts:-0.904989 flags:0
+ret: 0 st: 0 ts:-0.904989 flags:0
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:0 size:1024 flags:1
 ret: 0 st: 0 ts:1.989161 flags:1
 ret: 0 st: 0 dts:1.989161 pts:1.989161 pos:43861 size:683 flags:1
 ret: 0 st:-1 ts:0.883340 flags:0
 ret: 0 st: 0 dts:0.883356 pts:0.883356 pos:19478 size:1024 flags:1
-ret:-1 st:-1 ts:-0.222493 flags:1
+ret: 0 st:-1 ts:-0.222493 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:0 size:1024 flags:1
 ret: 0 st: 0 ts:2.671655 flags:0
 ret:-5
 ret: 0 st: 0 ts:1.565850 flags:1
 ret: 0 st: 0 dts:1.565850 pts:1.565850 pos:34527 size:1024 flags:1
 ret: 0 st:-1 ts:0.460008 flags:0
 ret: 0 st: 0 dts:0.460000 pts:0.460000 pos:10143 size:1024 flags:1
-ret:-1 st:-1 ts:-0.645825 flags:1
+ret: 0 st:-1 ts:-0.645825 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:0 size:1024 flags:1
 ----------------
 tests/data/b-libav.voc
 ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:32 size:512 flags:1
@@ -3564,50 +3743,58 @@
 ----------------
 tests/data/b-libav.wav
 ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:44 size:4096 flags:1
-ret:-1 st:-1 ts:-1.000000 flags:0
+ret: 0 st:-1 ts:-1.000000 flags:0
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:44 size:4096 flags:1
 ret: 0 st:-1 ts:1.894167 flags:1
 ret:-5
 ret: 0 st: 0 ts:0.788345 flags:0
 ret: 0 st: 0 dts:0.788345 pts:0.788345 pos:69576 size:4096 flags:1
-ret:-1 st: 0 ts:-0.317506 flags:1
+ret: 0 st: 0 ts:-0.317506 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:44 size:4096 flags:1
 ret: 0 st:-1 ts:2.576668 flags:0
 ret:-5
 ret: 0 st:-1 ts:1.470835 flags:1
 ret:-5
 ret: 0 st: 0 ts:0.365011 flags:0
 ret: 0 st: 0 dts:0.365011 pts:0.365011 pos:32238 size:4096 flags:1
-ret:-1 st: 0 ts:-0.740839 flags:1
+ret: 0 st: 0 ts:-0.740839 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:44 size:4096 flags:1
 ret: 0 st:-1 ts:2.153336 flags:0
 ret:-5
 ret: 0 st:-1 ts:1.047503 flags:1
 ret:-5
-ret:-1 st: 0 ts:-0.058322 flags:0
+ret: 0 st: 0 ts:-0.058322 flags:0
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:44 size:4096 flags:1
 ret: 0 st: 0 ts:2.835828 flags:1
 ret:-5
 ret: 0 st:-1 ts:1.730004 flags:0
 ret:-5
 ret: 0 st:-1 ts:0.624171 flags:1
 ret: 0 st: 0 dts:0.624172 pts:0.624172 pos:55096 size:4096 flags:1
-ret:-1 st: 0 ts:-0.481655 flags:0
+ret: 0 st: 0 ts:-0.481655 flags:0
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:44 size:4096 flags:1
 ret: 0 st: 0 ts:2.412494 flags:1
 ret:-5
 ret: 0 st:-1 ts:1.306672 flags:0
 ret:-5
 ret: 0 st:-1 ts:0.200839 flags:1
 ret: 0 st: 0 dts:0.200839 pts:0.200839 pos:17758 size:4096 flags:1
-ret:-1 st: 0 ts:-0.904989 flags:0
+ret: 0 st: 0 ts:-0.904989 flags:0
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:44 size:4096 flags:1
 ret: 0 st: 0 ts:1.989184 flags:1
 ret:-5
 ret: 0 st:-1 ts:0.883340 flags:0
 ret: 0 st: 0 dts:0.883333 pts:0.883333 pos:77954 size:4096 flags:1
-ret:-1 st:-1 ts:-0.222493 flags:1
+ret: 0 st:-1 ts:-0.222493 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:44 size:4096 flags:1
 ret: 0 st: 0 ts:2.671678 flags:0
 ret:-5
 ret: 0 st: 0 ts:1.565850 flags:1
 ret:-5
 ret: 0 st:-1 ts:0.460008 flags:0
 ret: 0 st: 0 dts:0.460000 pts:0.460000 pos:40616 size:4096 flags:1
-ret:-1 st:-1 ts:-0.645825 flags:1
+ret: 0 st:-1 ts:-0.645825 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:44 size:4096 flags:1
 ----------------
 tests/data/b-libav.y4m
 ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:66 size:152064 flags:1
diff --git a/tests/seek_test.c b/tests/seek_test.c
old mode 100644
new mode 100755
index b4e0e41..c2d0646
--- a/tests/seek_test.c
+++ b/tests/seek_test.c
@@ -23,6 +23,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 
+#include "libavutil/common.h"
 #include "libavformat/avformat.h"
 
 #undef exit
@@ -70,7 +71,7 @@
 
     for(i=0; ; i++){
         AVPacket pkt;
-        AVStream *st;
+        AVStream *av_uninit(st);
 
         memset(&pkt, 0, sizeof(pkt));
         if(ret>=0){
@@ -91,7 +92,9 @@
             st= ic->streams[stream_id];
             timestamp= av_rescale_q(timestamp, AV_TIME_BASE_Q, st->time_base);
         }
-        ret = av_seek_frame(ic, stream_id, timestamp, (i&1)*AVSEEK_FLAG_BACKWARD);
+        //FIXME fully test the new seek API
+        if(i&1) ret = avformat_seek_file(ic, stream_id, INT64_MIN, timestamp, timestamp, 0);
+        else    ret = avformat_seek_file(ic, stream_id, timestamp, timestamp, INT64_MAX, 0);
         printf("ret:%2d st:%2d ts:%f flags:%d\n", ret, stream_id, timestamp*(stream_id<0 ? 1.0/AV_TIME_BASE : av_q2d(st->time_base)), i&1);
     }
 
diff --git a/tests/test.conf b/tests/test.conf
old mode 100644
new mode 100755
diff --git a/tests/tiny_psnr.c b/tests/tiny_psnr.c
old mode 100644
new mode 100755
diff --git a/tests/videogen.c b/tests/videogen.c
old mode 100644
new mode 100755
diff --git a/tools/cws2fws.c b/tools/cws2fws.c
old mode 100644
new mode 100755
diff --git a/tools/patcheck b/tools/patcheck
index 89c0667..ab1e237 100755
--- a/tools/patcheck
+++ b/tools/patcheck
@@ -19,7 +19,7 @@
     arg="$1"
     msg="$2"
     shift 2
-    grep $OPT '^+' $* | grep -v ':+++'| egrep --color=always -- "$arg"> $TMP && echo -e "\n$msg"
+    grep $OPT '^+' $* | grep -v ':+++'| egrep --color=always -- "$arg"> $TMP && printf "\n$msg\n"
     cat $TMP
 }
 
@@ -28,7 +28,7 @@
     varg="$2"
     msg="$3"
     shift 3
-    grep $OPT '^+' $* | grep -v ':+++' | egrep -v -- "$varg" | egrep --color=always -- "$arg" > $TMP && echo -e "\n$msg"
+    grep $OPT '^+' $* | grep -v ':+++' | egrep -v -- "$varg" | egrep --color=always -- "$arg" > $TMP && printf "\n$msg\n"
     cat $TMP
 }
 
@@ -48,7 +48,7 @@
 hiegrep '-= *1 *;'      'can be simplified to --' $*
 hiegrep '((!|=)= *(0|NULL)[^0-9a-z]|[^0-9a-z](0|NULL) *(!|=)=)' 'x==0 / x!=0 can be simplified to !x / x' $*
 
-egrep $OPT '^\+ *(const *|)static' $*| egrep --color=always '[^=]= *(0|NULL)[^0-9a-zA-Z]'> $TMP && echo -e '\nuseless 0 init'
+egrep $OPT '^\+ *(const *|)static' $*| egrep --color=always '[^=]= *(0|NULL)[^0-9a-zA-Z]'> $TMP && printf '\nuseless 0 init\n'
 cat $TMP
 hiegrep '# *ifdef * (HAVE|CONFIG)_' 'ifdefs that should be #if' $*
 
@@ -72,7 +72,7 @@
 
 hiegrep2 '\.long_name *=' 'NULL_IF_CONFIG_SMAL' 'missing NULL_IF_CONFIG_SMAL' $*
 
-#egrep $OPT '^\+.*const ' $*| grep -v 'static'> $TMP && echo -e '\nnon static const'
+#egrep $OPT '^\+.*const ' $*| grep -v 'static'> $TMP && printf '\nnon static const\n'
 #cat $TMP
 
 hiegrep2 "$ERE_TYPES" '(static|av_|ff_|typedef|:\+[^a-zA-Z_])' 'Non static with no ff_/av_ prefix' $*
@@ -90,11 +90,11 @@
     grep " *$doxpar *[),]" $file | grep -v '@param' >/dev/null || grep --color=always "@param *$doxpar" $file >>$TMP
 done
 if test -e $TMP ; then
-    echo -e '\nmismatching doxy params'
+    printf '\nmismatching doxy params\n'
     cat $TMP
 fi
 
-egrep -B2 $OPT '^(\+|) *('"$ERE_TYPES"'|# *define)' $* | egrep -A2 --color=always '(:|-)\+[^/]*/(\*([^*]|$)|/([^/]|$))' > $TMP && echo -e "\n Non doxy comments"
+egrep -B2 $OPT '^(\+|) *('"$ERE_TYPES"'|# *define)' $* | egrep -A2 --color=always '(:|-)\+[^/]*/(\*([^*]|$)|/([^/]|$))' > $TMP && printf "\n Non doxy comments\n"
 cat $TMP
 
 rm $TMP
@@ -112,30 +112,30 @@
            egrep -v $i' *= *(0x|)[0-9]{1,};'>/dev/null || echo "possibly constant     :"$i >> $TMP
 done
 if test -e $TMP ; then
-    echo -e '\npossibly unused variables'
+    printf '\npossibly unused variables\n'
     cat $TMP
 fi
 
-grep '^Index:.*Changelog' $* >/dev/null || echo -e "\nMissing changelog entry (ignore if minor change)"
+grep '^Index:.*Changelog' $* >/dev/null || printf "\nMissing changelog entry (ignore if minor change)\n"
 
-cat $* | tr '\n' '@' | egrep --color=always -o '(fprintf|av_log|printf)\([^)]*\)[+ ;@]*\1'  >$TMP && echo -e "\nMergeable calls"
+cat $* | tr '\n' '@' | egrep --color=always -o '(fprintf|av_log|printf)\([^)]*\)[+ ;@]*\1'  >$TMP && printf "\nMergeable calls\n"
 cat $TMP | tr '@' '\n'
 
-cat $* | tr '\n' '@' | egrep --color=always -o '\+ *if *\( *([A-Za-z0-9_]*) *[<>]=? *[0-9]* *\) * \1 *= *[0-9]* *;[ @\\+]*else *if *\( *\1 *[<>]=? *[0-9]* *\) *\1 *= *[0-9]* *;'  >$TMP && echo -e "\nav_clip / av_clip_uint8 / av_clip_int16 / ..."
+cat $* | tr '\n' '@' | egrep --color=always -o '\+ *if *\( *([A-Za-z0-9_]*) *[<>]=? *[0-9]* *\) * \1 *= *[0-9]* *;[ @\\+]*else *if *\( *\1 *[<>]=? *[0-9]* *\) *\1 *= *[0-9]* *;'  >$TMP && printf "\nav_clip / av_clip_uint8 / av_clip_int16 / ...\n"
 cat $TMP | tr '@' '\n'
 
-cat $* | tr '\n' '@' | egrep --color=always -o '\+ *if *\( *([A-Za-z0-9_]*) *[<>]=? *([A-Za-z0-9_]*) *\)[ @\\+]*(\1|\2) *= *(\1|\2) *;'  >$TMP && echo -e "\nFFMIN/FFMAX"
+cat $* | tr '\n' '@' | egrep --color=always -o '\+ *if *\( *([A-Za-z0-9_]*) *[<>]=? *([A-Za-z0-9_]*) *\)[ @\\+]*(\1|\2) *= *(\1|\2) *;'  >$TMP && printf "\nFFMIN/FFMAX\n"
 cat $TMP | tr '@' '\n'
 
-cat $* | tr '\n' '@' | egrep --color=always -o '\+ *if *\( *([A-Za-z0-9_]*) *\)[ @\\+]*av_free(p|) *\( *(&|) *\1[^-.]'  >$TMP && echo -e "\nav_free(NULL) is safe"
+cat $* | tr '\n' '@' | egrep --color=always -o '\+ *if *\( *([A-Za-z0-9_]*) *\)[ @\\+]*av_free(p|) *\( *(&|) *\1[^-.]'  >$TMP && printf "\nav_free(NULL) is safe\n"
 cat $TMP | tr '@' '\n'
 
-cat $* | tr '\n' '@' | egrep --color=always -o '[^a-zA-Z0-9_]([a-zA-Z0-9_]*) *= *av_malloc *\([^)]*\)[ @;\\+]*memset *\( *\1'  >$TMP && echo -e "\nav_mallocz()"
+cat $* | tr '\n' '@' | egrep --color=always -o '[^a-zA-Z0-9_]([a-zA-Z0-9_]*) *= *av_malloc *\([^)]*\)[ @;\\+]*memset *\( *\1'  >$TMP && printf "\nav_mallocz()\n"
 cat $TMP | tr '@' '\n'
 
 
 # doesnt work
-#cat $* | tr '\n' '@' | egrep -o '[^a-zA-Z_0-9]([a-zA-Z][a-zA-Z_0-9]*) *=[^=].*\1' | egrep -o '[^a-zA-Z_0-9]([a-zA-Z][a-zA-Z_0-9]*) *=[^=].*\1 *=[^=]'  >$TMP && echo -e "\nPossibly written 2x before read"
+#cat $* | tr '\n' '@' | egrep -o '[^a-zA-Z_0-9]([a-zA-Z][a-zA-Z_0-9]*) *=[^=].*\1' | egrep -o '[^a-zA-Z_0-9]([a-zA-Z][a-zA-Z_0-9]*) *=[^=].*\1 *=[^=]'  >$TMP && printf "\nPossibly written 2x before read\n"
 #cat $TMP | tr '@' '\n'
 
 exit
diff --git a/tools/pktdumper.c b/tools/pktdumper.c
old mode 100644
new mode 100755
diff --git a/tools/qt-faststart.c b/tools/qt-faststart.c
old mode 100644
new mode 100755
diff --git a/tools/trasher.c b/tools/trasher.c
old mode 100644
new mode 100755
index baf1bc3..c7a0c7a
--- a/tools/trasher.c
+++ b/tools/trasher.c
@@ -18,6 +18,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#define _XOPEN_SOURCE 600
 #include <stdio.h>
 #include <stdlib.h>
 #include <time.h>
diff --git a/vhook/drawtext.c b/vhook/drawtext.c
deleted file mode 100644
index 8638d60..0000000
--- a/vhook/drawtext.c
+++ /dev/null
@@ -1,531 +0,0 @@
-/*
- * drawtext.c: print text over the screen
- ******************************************************************************
- * Options:
- * -f <filename>    font filename (MANDATORY!!!)
- * -s <pixel_size>  font size in pixels [default 16]
- * -b               print background
- * -o               outline glyphs (use the bg color)
- * -x <pos>         x position ( >= 0) [default 0]
- * -y <pos>         y position ( >= 0) [default 0]
- * -t <text>        text to print (will be passed to strftime())
- *                  MANDATORY: will be used even when -T is used.
- *                  in this case, -t will be used if some error
- *                  occurs
- * -T <filename>    file with the text (re-read every frame)
- * -c <#RRGGBB>     foreground color ('internet' way) [default #ffffff]
- * -C <#RRGGBB>     background color ('internet' way) [default #000000]
- *
- ******************************************************************************
- * Features:
- * - True Type, Type1 and others via FreeType2 library
- * - Font kerning (better output)
- * - Line Wrap (if the text doesn't fit, the next char go to the next line)
- * - Background box
- * - Outline
- ******************************************************************************
- * Author: Gustavo Sverzut Barbieri <gsbarbieri@yahoo.com.br>
- *
- * 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
- */
-
-#define MAXSIZE_TEXT 1024
-
-#include "libavformat/framehook.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <stdarg.h>
-#include <string.h>
-#include <unistd.h>
-#undef time
-#include <sys/time.h>
-#include <time.h>
-
-#include <ft2build.h>
-#include FT_FREETYPE_H
-#include FT_GLYPH_H
-
-#define SCALEBITS 10
-#define ONE_HALF  (1 << (SCALEBITS - 1))
-#define FIX(x)    ((int) ((x) * (1<<SCALEBITS) + 0.5))
-
-#define RGB_TO_YUV(rgb_color, yuv_color) do { \
-  yuv_color[0] = (FIX(0.29900)    * rgb_color[0] + FIX(0.58700) * rgb_color[1] + FIX(0.11400) * rgb_color[2] + ONE_HALF) >> SCALEBITS; \
-  yuv_color[2] = ((FIX(0.50000)   * rgb_color[0] - FIX(0.41869) * rgb_color[1] - FIX(0.08131) * rgb_color[2] + ONE_HALF - 1) >> SCALEBITS) + 128; \
-  yuv_color[1] = ((- FIX(0.16874) * rgb_color[0] - FIX(0.33126) * rgb_color[1] + FIX(0.50000) * rgb_color[2] + ONE_HALF - 1) >> SCALEBITS) + 128; \
-} while (0)
-
-#define COPY_3(dst,src) { \
-    dst[0]=src[0]; \
-    dst[1]=src[1]; \
-    dst[2]=src[2]; \
-}
-
-
-
-#define SET_PIXEL(picture, yuv_color, x, y) { \
-    picture->data[0][ (x) + (y)*picture->linesize[0] ] = yuv_color[0]; \
-    picture->data[1][ ((x/2) + (y/2)*picture->linesize[1]) ] = yuv_color[1]; \
-    picture->data[2][ ((x/2) + (y/2)*picture->linesize[2]) ] = yuv_color[2]; \
-}
-
-#define GET_PIXEL(picture, yuv_color, x, y) { \
-    yuv_color[0] = picture->data[0][ (x) + (y)*picture->linesize[0] ]; \
-    yuv_color[1] = picture->data[1][ (x/2) + (y/2)*picture->linesize[1] ]; \
-    yuv_color[2] = picture->data[2][ (x/2) + (y/2)*picture->linesize[2] ]; \
-}
-
-
-typedef struct {
-  unsigned char *text;
-  char *file;
-  unsigned int x;
-  unsigned int y;
-  int bg;
-  int outline;
-  unsigned char bgcolor[3]; /* YUV */
-  unsigned char fgcolor[3]; /* YUV */
-  FT_Library library;
-  FT_Face    face;
-  FT_Glyph   glyphs[ 255 ];
-  FT_Bitmap  bitmaps[ 255 ];
-  int        advance[ 255 ];
-  int        bitmap_left[ 255 ];
-  int        bitmap_top[ 255 ];
-  unsigned int glyphs_index[ 255 ];
-  int        text_height;
-  int        baseline;
-  int use_kerning;
-} ContextInfo;
-
-
-void Release(void *ctx)
-{
-    if (ctx)
-        av_free(ctx);
-}
-
-
-static int ParseColor(char *text, unsigned char yuv_color[3])
-{
-  char tmp[3];
-  unsigned char rgb_color[3];
-  int i;
-
-  tmp[2] = '\0';
-
-  if ((!text) || (strlen(text) != 7) || (text[0] != '#') )
-    return -1;
-
-  for (i=0; i < 3; i++)
-    {
-      tmp[0] = text[i*2+1];
-      tmp[1] = text[i*2+2];
-
-      rgb_color[i] = strtol(tmp, NULL, 16);
-    }
-
-  RGB_TO_YUV(rgb_color, yuv_color);
-
-  return 0;
-}
-
-int Configure(void **ctxp, int argc, char *argv[])
-{
-    int c;
-    int error;
-    ContextInfo *ci=NULL;
-    char *font=NULL;
-    unsigned int size=16;
-    FT_BBox bbox;
-    int yMax, yMin;
-    *ctxp = av_mallocz(sizeof(ContextInfo));
-    ci = (ContextInfo *) *ctxp;
-
-    /* configure Context Info */
-    ci->text = NULL;
-    ci->file = NULL;
-    ci->x = ci->y = 0;
-    ci->fgcolor[0]=255;
-    ci->fgcolor[1]=128;
-    ci->fgcolor[2]=128;
-    ci->bgcolor[0]=0;
-    ci->fgcolor[1]=128;
-    ci->fgcolor[2]=128;
-    ci->bg = 0;
-    ci->outline = 0;
-    ci->text_height = 0;
-
-    optind = 1;
-    while ((c = getopt(argc, argv, "f:t:T:x:y:s:c:C:bo")) > 0) {
-      switch (c) {
-      case 'f':
-        font = optarg;
-        break;
-      case 't':
-        ci->text = av_strdup(optarg);
-        break;
-      case 'T':
-        ci->file = av_strdup(optarg);
-        break;
-      case 'x':
-        ci->x = (unsigned int) atoi(optarg);
-        break;
-      case 'y':
-        ci->y = (unsigned int) atoi(optarg);
-        break;
-      case 's':
-        size = (unsigned int) atoi(optarg);
-        break;
-      case 'c':
-        if (ParseColor(optarg, ci->fgcolor) == -1)
-          {
-            av_log(NULL, AV_LOG_ERROR, "Invalid foreground color: '%s'. You must specify the color in the internet way(packaged hex): #RRGGBB, ie: -c #ffffff (for white foreground)\n", optarg);
-            return -1;
-          }
-        break;
-      case 'C':
-        if (ParseColor(optarg, ci->bgcolor) == -1)
-          {
-            av_log(NULL, AV_LOG_ERROR, "Invalid background color: '%s'. You must specify the color in the internet way(packaged hex): #RRGGBB, ie: -C #ffffff (for white background)\n", optarg);
-            return -1;
-          }
-        break;
-      case 'b':
-        ci->bg=1;
-        break;
-      case 'o':
-        ci->outline=1;
-        break;
-      case '?':
-        av_log(NULL, AV_LOG_ERROR, "Unrecognized argument '%s'\n", argv[optind]);
-        return -1;
-      }
-    }
-
-    if (!ci->text)
-      {
-        av_log(NULL, AV_LOG_ERROR, "No text provided (-t text)\n");
-        return -1;
-      }
-
-    if (ci->file)
-      {
-        FILE *fp;
-        if ((fp=fopen(ci->file, "r")) == NULL)
-          {
-            av_log(NULL, AV_LOG_INFO, "WARNING: The file could not be opened. Using text provided with -t switch: %s", strerror(errno));
-          }
-        else
-          {
-            fclose(fp);
-          }
-      }
-
-    if (!font)
-      {
-        av_log(NULL, AV_LOG_ERROR, "No font file provided! (-f filename)\n");
-        return -1;
-      }
-
-    if ((error = FT_Init_FreeType(&(ci->library))) != 0)
-      {
-        av_log(NULL, AV_LOG_ERROR, "Could not load FreeType (error# %d).\n", error);
-        return -1;
-      }
-
-    if ((error = FT_New_Face( ci->library, font, 0, &(ci->face) )) != 0)
-      {
-        av_log(NULL, AV_LOG_ERROR, "Could not load face: %s  (error# %d).\n", font, error);
-        return -1;
-      }
-
-    if ((error = FT_Set_Pixel_Sizes( ci->face, 0, size)) != 0)
-      {
-        av_log(NULL, AV_LOG_ERROR, "Could not set font size to %d pixels (error# %d).\n", size, error);
-        return -1;
-      }
-
-    ci->use_kerning = FT_HAS_KERNING(ci->face);
-
-    /* load and cache glyphs */
-    yMax = -32000;
-    yMin =  32000;
-    for (c=0; c < 256; c++)
-      {
-        /* Load char */
-        error = FT_Load_Char( ci->face, (unsigned char) c, FT_LOAD_RENDER | FT_LOAD_MONOCHROME );
-        if (error) continue;  /* ignore errors */
-
-        /* Save bitmap */
-        ci->bitmaps[c] = ci->face->glyph->bitmap;
-        /* Save bitmap left */
-        ci->bitmap_left[c] = ci->face->glyph->bitmap_left;
-        /* Save bitmap top */
-        ci->bitmap_top[c] = ci->face->glyph->bitmap_top;
-
-        /* Save advance */
-        ci->advance[c] = ci->face->glyph->advance.x >> 6;
-
-        /* Save glyph */
-        error = FT_Get_Glyph( ci->face->glyph, &(ci->glyphs[c]) );
-        /* Save glyph index */
-        ci->glyphs_index[c] = FT_Get_Char_Index( ci->face, (unsigned char) c );
-
-        /* Measure text height to calculate text_height (or the maximum text height) */
-        FT_Glyph_Get_CBox( ci->glyphs[ c ], ft_glyph_bbox_pixels, &bbox );
-        if (bbox.yMax > yMax)
-          yMax = bbox.yMax;
-        if (bbox.yMin < yMin)
-          yMin = bbox.yMin;
-
-      }
-
-    ci->text_height = yMax - yMin;
-    ci->baseline = yMax;
-
-    return 0;
-}
-
-
-
-
-static inline void draw_glyph(AVPicture *picture, FT_Bitmap *bitmap, unsigned int x, unsigned int y, unsigned int width, unsigned int height, unsigned char yuv_fgcolor[3], unsigned char yuv_bgcolor[3], int outline)
-{
-  int r, c;
-  int spixel, dpixel[3], in_glyph=0;
-
-  if (bitmap->pixel_mode == ft_pixel_mode_mono)
-    {
-      in_glyph = 0;
-      for (r=0; (r < bitmap->rows) && (r+y < height); r++)
-        {
-          for (c=0; (c < bitmap->width) && (c+x < width); c++)
-            {
-              /* pixel in the picture (destination) */
-              GET_PIXEL(picture, dpixel, (c+x), (y+r));
-
-              /* pixel in the glyph bitmap (source) */
-              spixel = bitmap->buffer[r*bitmap->pitch +c/8] & (0x80>>(c%8));
-
-              if (spixel)
-                COPY_3(dpixel, yuv_fgcolor);
-
-              if (outline)
-                {
-                  /* border detection: */
-                  if ( (!in_glyph) && (spixel) )
-                    /* left border detected */
-                    {
-                      in_glyph = 1;
-                      /* draw left pixel border */
-                      if (c-1 >= 0)
-                        SET_PIXEL(picture, yuv_bgcolor, (c+x-1), (y+r));
-                    }
-                  else if ( (in_glyph) && (!spixel) )
-                    /* right border detected */
-                    {
-                      in_glyph = 0;
-                      /* 'draw' right pixel border */
-                      COPY_3(dpixel, yuv_bgcolor);
-                    }
-
-                  if (in_glyph)
-                    /* see if we have a top/bottom border */
-                    {
-                      /* top */
-                      if ( (r-1 >= 0) && (! bitmap->buffer[(r-1)*bitmap->pitch +c/8] & (0x80>>(c%8))) )
-                        /* we have a top border */
-                        SET_PIXEL(picture, yuv_bgcolor, (c+x), (y+r-1));
-
-                      /* bottom */
-                      if ( (r+1 < height) && (! bitmap->buffer[(r+1)*bitmap->pitch +c/8] & (0x80>>(c%8))) )
-                        /* we have a bottom border */
-                        SET_PIXEL(picture, yuv_bgcolor, (c+x), (y+r+1));
-
-                    }
-                }
-
-              SET_PIXEL(picture, dpixel, (c+x), (y+r));
-            }
-        }
-    }
-}
-
-
-static inline void draw_box(AVPicture *picture, unsigned int x, unsigned int y, unsigned int width, unsigned int height, unsigned char yuv_color[3])
-{
-  int i, j;
-
-  for (j = 0; (j < height); j++)
-    for (i = 0; (i < width); i++)
-      {
-        SET_PIXEL(picture, yuv_color, (i+x), (y+j));
-      }
-
-}
-
-
-
-
-void Process(void *ctx, AVPicture *picture, enum PixelFormat pix_fmt, int width, int height, int64_t pts)
-{
-  ContextInfo *ci = (ContextInfo *) ctx;
-  FT_Face face = ci->face;
-  FT_GlyphSlot  slot = face->glyph;
-  unsigned char *text = ci->text;
-  unsigned char c;
-  int x = 0, y = 0, i=0, size=0;
-  unsigned char buff[MAXSIZE_TEXT];
-  unsigned char tbuff[MAXSIZE_TEXT];
-  time_t now = time(0);
-  int str_w, str_w_max;
-  FT_Vector pos[MAXSIZE_TEXT];
-  FT_Vector delta;
-
-  if (ci->file)
-    {
-      int fd = open(ci->file, O_RDONLY);
-
-      if (fd < 0)
-        {
-          text = ci->text;
-          av_log(NULL, AV_LOG_INFO, "WARNING: The file could not be opened. Using text provided with -t switch: %s", strerror(errno));
-        }
-      else
-        {
-          int l = read(fd, tbuff, sizeof(tbuff) - 1);
-
-          if (l >= 0)
-            {
-              tbuff[l] = 0;
-              text = tbuff;
-            }
-          else
-            {
-              text = ci->text;
-              av_log(NULL, AV_LOG_INFO, "WARNING: The file could not be read. Using text provided with -t switch: %s", strerror(errno));
-            }
-          close(fd);
-        }
-    }
-  else
-    {
-      text = ci->text;
-    }
-
-  strftime(buff, sizeof(buff), text, localtime(&now));
-
-  text = buff;
-
-  size = strlen(text);
-
-
-
-
-  /* measure string size and save glyphs position*/
-  str_w = str_w_max = 0;
-  x = ci->x;
-  y = ci->y;
-  for (i=0; i < size; i++)
-    {
-      c = text[i];
-
-      /* kerning */
-      if ( (ci->use_kerning) && (i > 0) && (ci->glyphs_index[c]) )
-        {
-          FT_Get_Kerning( ci->face,
-                          ci->glyphs_index[ text[i-1] ],
-                          ci->glyphs_index[c],
-                          ft_kerning_default,
-                          &delta );
-
-          x += delta.x >> 6;
-        }
-
-      if (( (x + ci->advance[ c ]) >= width ) || ( c == '\n' ))
-        {
-          str_w = width - ci->x - 1;
-
-          y += ci->text_height;
-          x = ci->x;
-        }
-
-
-      /* save position */
-      pos[i].x = x + ci->bitmap_left[c];
-      pos[i].y = y - ci->bitmap_top[c] + ci->baseline;
-
-
-      x += ci->advance[c];
-
-
-      if (str_w > str_w_max)
-        str_w_max = str_w;
-
-    }
-
-
-
-
-  if (ci->bg)
-    {
-      /* Check if it doesn't pass the limits */
-      if ( str_w_max + ci->x >= width )
-        str_w_max = width - ci->x - 1;
-      if ( y >= height )
-        y = height - 1 - 2*ci->y;
-
-      /* Draw Background */
-      draw_box( picture, ci->x, ci->y, str_w_max, y - ci->y, ci->bgcolor );
-    }
-
-
-
-  /* Draw Glyphs */
-  for (i=0; i < size; i++)
-    {
-      c = text[i];
-
-      if (
-          ( (c == '_') && (text == ci->text) ) || /* skip '_' (consider as space)
-                                                     IF text was specified in cmd line
-                                                     (which doesn't like nested quotes)  */
-          ( c == '\n' ) /* Skip new line char, just go to new line */
-          )
-        continue;
-
-        /* now, draw to our target surface */
-        draw_glyph( picture,
-                    &(ci->bitmaps[ c ]),
-                    pos[i].x,
-                    pos[i].y,
-                    width,
-                    height,
-                    ci->fgcolor,
-                    ci->bgcolor,
-                    ci->outline );
-
-      /* increment pen position */
-      x += slot->advance.x >> 6;
-    }
-
-
-}
-
diff --git a/vhook/fish.c b/vhook/fish.c
deleted file mode 100644
index 3806df3..0000000
--- a/vhook/fish.c
+++ /dev/null
@@ -1,382 +0,0 @@
-/*
- * Fish Detector Hook
- * Copyright (c) 2002 Philip Gladstone
- *
- * This file implements a fish detector. It is used to see when a
- * goldfish passes in front of the camera. It does this by counting
- * the number of input pixels that fall within a particular HSV
- * range.
- *
- * It takes a multitude of arguments:
- *
- * -h <num>-<num>    the range of H values that are fish
- * -s <num>-<num>    the range of S values that are fish
- * -v <num>-<num>    the range of V values that are fish
- * -z                zap all non-fish values to black
- * -l <num>          limit the number of saved files to <num>
- * -i <num>          only check frames every <num> seconds
- * -t <num>          the threshold for the amount of fish pixels (range 0-1)
- * -d                turn debugging on
- * -D <directory>    where to put the fish images
- *
- * 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 <stdlib.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <stdarg.h>
-#include <string.h>
-#include <time.h>
-#include <stdio.h>
-#include <dirent.h>
-
-#include "libavformat/avformat.h"
-#include "libavformat/framehook.h"
-#include "libavcodec/dsputil.h"
-#include "libswscale/swscale.h"
-#undef fprintf
-
-static int sws_flags = SWS_BICUBIC;
-
-#define SCALEBITS 10
-#define ONE_HALF  (1 << (SCALEBITS - 1))
-#define FIX(x)    ((int) ((x) * (1<<SCALEBITS) + 0.5))
-
-#define YUV_TO_RGB1_CCIR(cb1, cr1)\
-{\
-    cb = (cb1) - 128;\
-    cr = (cr1) - 128;\
-    r_add = FIX(1.40200*255.0/224.0) * cr + ONE_HALF;\
-    g_add = - FIX(0.34414*255.0/224.0) * cb - FIX(0.71414*255.0/224.0) * cr + \
-                    ONE_HALF;\
-    b_add = FIX(1.77200*255.0/224.0) * cb + ONE_HALF;\
-}
-
-#define YUV_TO_RGB2_CCIR(r, g, b, y1)\
-{\
-    yt = ((y1) - 16) * FIX(255.0/219.0);\
-    r = cm[(yt + r_add) >> SCALEBITS];\
-    g = cm[(yt + g_add) >> SCALEBITS];\
-    b = cm[(yt + b_add) >> SCALEBITS];\
-}
-
-
-
-
-typedef struct {
-    int h;  /* 0 .. 360 */
-    int s;  /* 0 .. 255 */
-    int v;  /* 0 .. 255 */
-} HSV;
-
-typedef struct {
-    int zapping;
-    int threshold;
-    HSV dark, bright;
-    char *dir;
-    int file_limit;
-    int debug;
-    int min_interval;
-    int64_t next_pts;
-    int inset;
-    int min_width;
-    struct SwsContext *toRGB_convert_ctx;
-} ContextInfo;
-
-static void dorange(const char *s, int *first, int *second, int maxval)
-{
-    sscanf(s, "%d-%d", first, second);
-    if (*first > maxval)
-        *first = maxval;
-    if (*second > maxval)
-        *second = maxval;
-}
-
-void Release(void *ctx)
-{
-    ContextInfo *ci;
-    ci = (ContextInfo *) ctx;
-
-    if (ctx) {
-        sws_freeContext(ci->toRGB_convert_ctx);
-        av_free(ctx);
-    }
-}
-
-int Configure(void **ctxp, int argc, char *argv[])
-{
-    ContextInfo *ci;
-    int c;
-
-    *ctxp = av_mallocz(sizeof(ContextInfo));
-    ci = (ContextInfo *) *ctxp;
-
-    optind = 1;
-
-    ci->dir = av_strdup("/tmp");
-    ci->threshold = 100;
-    ci->file_limit = 100;
-    ci->min_interval = 1000000;
-    ci->inset = 10;     /* Percent */
-
-    while ((c = getopt(argc, argv, "w:i:dh:s:v:zl:t:D:")) > 0) {
-        switch (c) {
-            case 'h':
-                dorange(optarg, &ci->dark.h, &ci->bright.h, 360);
-                break;
-            case 's':
-                dorange(optarg, &ci->dark.s, &ci->bright.s, 255);
-                break;
-            case 'v':
-                dorange(optarg, &ci->dark.v, &ci->bright.v, 255);
-                break;
-            case 'z':
-                ci->zapping = 1;
-                break;
-            case 'l':
-                ci->file_limit = atoi(optarg);
-                break;
-            case 'i':
-                ci->min_interval = 1000000 * atof(optarg);
-                break;
-            case 't':
-                ci->threshold = atof(optarg) * 1000;
-                if (ci->threshold > 1000 || ci->threshold < 0) {
-                    av_log(NULL, AV_LOG_ERROR, "Invalid threshold value '%s' (range is 0-1)\n", optarg);
-                    return -1;
-                }
-                break;
-            case 'w':
-                ci->min_width = atoi(optarg);
-                break;
-            case 'd':
-                ci->debug++;
-                break;
-            case 'D':
-                ci->dir = av_strdup(optarg);
-                break;
-            default:
-                av_log(NULL, AV_LOG_ERROR, "Unrecognized argument '%s'\n", argv[optind]);
-                return -1;
-        }
-    }
-
-    av_log(NULL, AV_LOG_INFO, "Fish detector configured:\n");
-    av_log(NULL, AV_LOG_INFO, "    HSV range: %d,%d,%d - %d,%d,%d\n",
-                        ci->dark.h,
-                        ci->dark.s,
-                        ci->dark.v,
-                        ci->bright.h,
-                        ci->bright.s,
-                        ci->bright.v);
-    av_log(NULL, AV_LOG_INFO, "    Threshold is %d%% pixels\n", ci->threshold / 10);
-
-
-    return 0;
-}
-
-static void get_hsv(HSV *hsv, int r, int g, int b)
-{
-    int i, v, x, f;
-
-    x = (r < g) ? r : g;
-    if (b < x)
-        x = b;
-    v = (r > g) ? r : g;
-    if (b > v)
-        v = b;
-
-    if (v == x) {
-        hsv->h = 0;
-        hsv->s = 0;
-        hsv->v = v;
-        return;
-    }
-
-    if (r == v) {
-        f = g - b;
-        i = 0;
-    } else if (g == v) {
-        f = b - r;
-        i = 2 * 60;
-    } else {
-        f = r - g;
-        i = 4 * 60;
-    }
-
-    hsv->h = i + (60 * f) / (v - x);
-    if (hsv->h < 0)
-        hsv->h += 360;
-
-    hsv->s = (255 * (v - x)) / v;
-    hsv->v = v;
-
-    return;
-}
-
-void Process(void *ctx, AVPicture *picture, enum PixelFormat pix_fmt, int width, int height, int64_t pts)
-{
-    ContextInfo *ci = (ContextInfo *) ctx;
-    uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
-    int rowsize = picture->linesize[0];
-
-#if 0
-    av_log(NULL, AV_LOG_DEBUG, "pix_fmt = %d, width = %d, pts = %lld, ci->next_pts = %lld\n",
-        pix_fmt, width, pts, ci->next_pts);
-#endif
-
-    if (pts < ci->next_pts)
-        return;
-
-    if (width < ci->min_width)
-        return;
-
-    ci->next_pts = pts + 1000000;
-
-    if (pix_fmt == PIX_FMT_YUV420P) {
-        uint8_t *y, *u, *v;
-        int width2 = width >> 1;
-        int inrange = 0;
-        int pixcnt;
-        int h;
-        int h_start, h_end;
-        int w_start, w_end;
-
-        h_end = 2 * ((ci->inset * height) / 200);
-        h_start = height - h_end;
-
-        w_end = (ci->inset * width2) / 100;
-        w_start = width2 - w_end;
-
-        pixcnt = ((h_start - h_end) >> 1) * (w_start - w_end);
-
-        y = picture->data[0] + h_end * picture->linesize[0] + w_end * 2;
-        u = picture->data[1] + h_end * picture->linesize[1] / 2 + w_end;
-        v = picture->data[2] + h_end * picture->linesize[2] / 2 + w_end;
-
-        for (h = h_start; h > h_end; h -= 2) {
-            int w;
-
-            for (w = w_start; w > w_end; w--) {
-                unsigned int r,g,b;
-                HSV hsv;
-                int cb, cr, yt, r_add, g_add, b_add;
-
-                YUV_TO_RGB1_CCIR(u[0], v[0]);
-                YUV_TO_RGB2_CCIR(r, g, b, y[0]);
-
-                get_hsv(&hsv, r, g, b);
-
-                if (ci->debug > 1)
-                    av_log(NULL, AV_LOG_DEBUG, "(%d,%d,%d) -> (%d,%d,%d)\n",
-                        r,g,b,hsv.h,hsv.s,hsv.v);
-
-
-                if (hsv.h >= ci->dark.h && hsv.h <= ci->bright.h &&
-                    hsv.s >= ci->dark.s && hsv.s <= ci->bright.s &&
-                    hsv.v >= ci->dark.v && hsv.v <= ci->bright.v) {
-                    inrange++;
-                } else if (ci->zapping) {
-                    y[0] = y[1] = y[rowsize] = y[rowsize + 1] = 16;
-                    u[0] = 128;
-                    v[0] = 128;
-                }
-
-                y+= 2;
-                u++;
-                v++;
-            }
-
-            y += picture->linesize[0] * 2 - (w_start - w_end) * 2;
-            u += picture->linesize[1] - (w_start - w_end);
-            v += picture->linesize[2] - (w_start - w_end);
-        }
-
-        if (ci->debug)
-            av_log(NULL, AV_LOG_INFO, "Fish: Inrange=%d of %d = %d threshold\n", inrange, pixcnt, 1000 * inrange / pixcnt);
-
-        if (inrange * 1000 / pixcnt >= ci->threshold) {
-            /* Save to file */
-            int size;
-            char *buf;
-            AVPicture picture1;
-            static int frame_counter;
-            static int foundfile;
-
-            if ((frame_counter++ % 20) == 0) {
-                /* Check how many files we have */
-                DIR *d;
-
-                foundfile = 0;
-
-                d = opendir(ci->dir);
-                if (d) {
-                    struct dirent *dent;
-
-                    while ((dent = readdir(d))) {
-                        if (strncmp("fishimg", dent->d_name, 7) == 0) {
-                            if (strcmp(".ppm", dent->d_name + strlen(dent->d_name) - 4) == 0) {
-                                foundfile++;
-                            }
-                        }
-                    }
-                    closedir(d);
-                }
-            }
-
-            if (foundfile < ci->file_limit) {
-                FILE *f;
-                char fname[256];
-
-                size = avpicture_get_size(PIX_FMT_RGB24, width, height);
-                buf = av_malloc(size);
-
-                avpicture_fill(&picture1, buf, PIX_FMT_RGB24, width, height);
-
-                // if we already got a SWS context, let's realloc if is not re-useable
-                ci->toRGB_convert_ctx = sws_getCachedContext(ci->toRGB_convert_ctx,
-                                            width, height, pix_fmt,
-                                            width, height, PIX_FMT_RGB24,
-                                            sws_flags, NULL, NULL, NULL);
-                if (ci->toRGB_convert_ctx == NULL) {
-                    av_log(NULL, AV_LOG_ERROR,
-                           "Cannot initialize the toRGB conversion context\n");
-                    return;
-                }
-                // img_convert parameters are          2 first destination, then 4 source
-                // sws_scale   parameters are context, 4 first source,      then 2 destination
-                sws_scale(ci->toRGB_convert_ctx,
-                              picture->data, picture->linesize, 0, height,
-                              picture1.data, picture1.linesize);
-
-                    /* Write out the PPM file */
-                    snprintf(fname, sizeof(fname), "%s/fishimg%ld_%"PRId64".ppm", ci->dir, (long)(av_gettime() / 1000000), pts);
-                    f = fopen(fname, "w");
-                    if (f) {
-                        fprintf(f, "P6 %d %d 255\n", width, height);
-                        if (!fwrite(buf, width * height * 3, 1, f))
-                            av_log(ctx, AV_LOG_ERROR, "Couldn't write to PPM file %s\n", fname);
-                        fclose(f);
-                    }
-
-                av_free(buf);
-                ci->next_pts = pts + ci->min_interval;
-            }
-        }
-    }
-}
-
diff --git a/vhook/imlib2.c b/vhook/imlib2.c
deleted file mode 100644
index ffe873c..0000000
--- a/vhook/imlib2.c
+++ /dev/null
@@ -1,493 +0,0 @@
-/*
- * imlib2 based hook
- * Copyright (c) 2002 Philip Gladstone
- *
- * This module is very much intended as an example of what could be done.
- *
- * One caution is that this is an expensive process -- in particular the
- * conversion of the image into RGB and back is time consuming. For some
- * special cases -- e.g. painting black text -- it would be faster to paint
- * the text into a bitmap and then combine it directly into the YUV
- * image. However, this code is fast enough to handle 10 fps of 320x240 on a
- * 900MHz Duron in maybe 15% of the CPU.
-
- * See further statistics on Pentium4, 3GHz, FFMpeg is SVN-r6798
- * Input movie is 20.2 seconds of PAL DV on AVI
- * Output movie is DVD compliant VOB.
- *
-   ffmpeg -i input.avi -target pal-dvd out.vob
-   #   13.516s  just transcode
-   ffmpeg -i input.avi -vhook /usr/local/bin/vhook/null.dll -target pal-dvd out.vob
-   #   23.546s  transcode and img_convert
-   ffmpeg -i input.avi -vhook \
-     'vhook/imlib2.dll -c red -F Vera/20 -x 150-0.5*N -y 70+0.25*N -t Hello_person' \
-     -target pal-dvd out.vob
-   #   21.454s  transcode, img_convert and move text around
-   ffmpeg -i input.avi -vhook \
-     'vhook/imlib2.dll -x 150-0.5*N -y 70+0.25*N -i /usr/share/imlib2/data/images/bulb.png' \
-     -target pal-dvd out.vob
-   #   20.828s  transcode, img_convert and move image around
- *
- * 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 "libavformat/framehook.h"
-#include "libswscale/swscale.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <fcntl.h>
-#include <stdarg.h>
-#include <string.h>
-#include <strings.h>
-#include <unistd.h>
-#undef time
-#include <sys/time.h>
-#include <time.h>
-#include <Imlib2.h>
-#include "libavcodec/eval.h"
-
-const char *const_names[]={
-    "PI",
-    "E",
-    "N",  // frame number (starting at zero)
-    "H",  // frame height
-    "W",  // frame width
-    "h",  // image height
-    "w",  // image width
-    "X",  // previous x
-    "Y",  // previous y
-    NULL
-};
-
-static int sws_flags = SWS_BICUBIC;
-
-typedef struct {
-    int dummy;
-    Imlib_Font fn;
-    char *text;
-    char *file;
-    int r, g, b, a;
-    AVEvalExpr *eval_r, *eval_g, *eval_b, *eval_a;
-    char *expr_R, *expr_G, *expr_B, *expr_A;
-    int eval_colors;
-    double x, y;
-    char *fileImage;
-    struct CachedImage *cache;
-    Imlib_Image imageOverlaid;
-    AVEvalExpr *eval_x, *eval_y;
-    char *expr_x, *expr_y;
-    int frame_number;
-    int imageOverlaid_width, imageOverlaid_height;
-
-    // This vhook first converts frame to RGB ...
-    struct SwsContext *toRGB_convert_ctx;
-    // ... and then converts back frame from RGB to initial format
-    struct SwsContext *fromRGB_convert_ctx;
-} ContextInfo;
-
-typedef struct CachedImage {
-    struct CachedImage *next;
-    Imlib_Image image;
-    int width;
-    int height;
-} CachedImage;
-
-void Release(void *ctx)
-{
-    ContextInfo *ci;
-    ci = (ContextInfo *) ctx;
-
-    if (ci->cache) {
-        imlib_context_set_image(ci->cache->image);
-        imlib_free_image();
-        av_free(ci->cache);
-    }
-    if (ctx) {
-        if (ci->imageOverlaid) {
-            imlib_context_set_image(ci->imageOverlaid);
-            imlib_free_image();
-        }
-        ff_eval_free(ci->eval_x);
-        ff_eval_free(ci->eval_y);
-        ff_eval_free(ci->eval_r);
-        ff_eval_free(ci->eval_g);
-        ff_eval_free(ci->eval_b);
-        ff_eval_free(ci->eval_a);
-
-        av_free(ci->expr_x);
-        av_free(ci->expr_y);
-        av_free(ci->expr_R);
-        av_free(ci->expr_G);
-        av_free(ci->expr_B);
-        av_free(ci->expr_A);
-        sws_freeContext(ci->toRGB_convert_ctx);
-        sws_freeContext(ci->fromRGB_convert_ctx);
-        av_free(ctx);
-    }
-}
-
-int Configure(void **ctxp, int argc, char *argv[])
-{
-    int c;
-    ContextInfo *ci;
-    char *rgbtxt = 0;
-    const char *font = "LucidaSansDemiBold/16";
-    char *fp = getenv("FONTPATH");
-    char *color = 0;
-    FILE *f;
-    char *p;
-    const char *error;
-
-    *ctxp = av_mallocz(sizeof(ContextInfo));
-    ci = (ContextInfo *) *ctxp;
-
-    ci->x = 0.0;
-    ci->y = 0.0;
-    ci->expr_x = "0.0";
-    ci->expr_y = "0.0";
-
-    optind = 1;
-
-    /* Use ':' to split FONTPATH */
-    if (fp)
-        while ((p = strchr(fp, ':'))) {
-            *p = 0;
-            imlib_add_path_to_font_path(fp);
-            fp = p + 1;
-        }
-    if ((fp) && (*fp))
-        imlib_add_path_to_font_path(fp);
-
-
-    while ((c = getopt(argc, argv, "R:G:B:A:C:c:f:F:t:x:y:i:")) > 0) {
-        switch (c) {
-            case 'R':
-                ci->expr_R = av_strdup(optarg);
-                ci->eval_colors = 1;
-                break;
-            case 'G':
-                ci->expr_G = av_strdup(optarg);
-                ci->eval_colors = 1;
-                break;
-            case 'B':
-                ci->expr_B = av_strdup(optarg);
-                ci->eval_colors = 1;
-                break;
-            case 'A':
-                ci->expr_A = av_strdup(optarg);
-                break;
-            case 'C':
-                rgbtxt = optarg;
-                break;
-            case 'c':
-                color = optarg;
-                break;
-            case 'F':
-                font = optarg;
-                break;
-            case 't':
-                ci->text = av_strdup(optarg);
-                break;
-            case 'f':
-                ci->file = av_strdup(optarg);
-                break;
-            case 'x':
-                ci->expr_x = av_strdup(optarg);
-                break;
-            case 'y':
-                ci->expr_y = av_strdup(optarg);
-                break;
-            case 'i':
-                ci->fileImage = av_strdup(optarg);
-                break;
-            case '?':
-                av_log(NULL, AV_LOG_ERROR, "Unrecognized argument '%s'\n", argv[optind]);
-                return -1;
-        }
-    }
-
-    if (ci->eval_colors && !(ci->expr_R && ci->expr_G && ci->expr_B))
-    {
-        av_log(NULL, AV_LOG_ERROR, "You must specify expressions for all or no colors.\n");
-        return -1;
-    }
-
-    if (ci->text || ci->file) {
-        ci->fn = imlib_load_font(font);
-        if (!ci->fn) {
-            av_log(NULL, AV_LOG_ERROR, "Failed to load font '%s'\n", font);
-            return -1;
-        }
-        imlib_context_set_font(ci->fn);
-        imlib_context_set_direction(IMLIB_TEXT_TO_RIGHT);
-    }
-
-    if (color) {
-        char buff[256];
-        int done = 0;
-
-        if (ci->eval_colors)
-        {
-            av_log(NULL, AV_LOG_ERROR, "You must not specify both a color name and expressions for the colors.\n");
-            return -1;
-        }
-
-        if (rgbtxt)
-            f = fopen(rgbtxt, "r");
-        else
-        {
-            f = fopen("/usr/share/X11/rgb.txt", "r");
-            if (!f)
-                f = fopen("/usr/lib/X11/rgb.txt", "r");
-        }
-        if (!f) {
-            av_log(NULL, AV_LOG_ERROR, "Failed to find RGB color names file\n");
-            return -1;
-        }
-        while (fgets(buff, sizeof(buff), f)) {
-            int r, g, b;
-            char colname[80];
-
-            if (sscanf(buff, "%d %d %d %64s", &r, &g, &b, colname) == 4 &&
-                strcasecmp(colname, color) == 0) {
-                ci->r = r;
-                ci->g = g;
-                ci->b = b;
-                /* fprintf(stderr, "%s -> %d,%d,%d\n", colname, r, g, b); */
-                done = 1;
-                break;
-            }
-        }
-        fclose(f);
-        if (!done) {
-            av_log(NULL, AV_LOG_ERROR, "Unable to find color '%s' in rgb.txt\n", color);
-            return -1;
-        }
-    } else if (ci->eval_colors) {
-        if (!(ci->eval_r = ff_parse(ci->expr_R, const_names, NULL, NULL, NULL, NULL, &error))){
-            av_log(NULL, AV_LOG_ERROR, "Couldn't parse R expression '%s': %s\n", ci->expr_R, error);
-            return -1;
-        }
-        if (!(ci->eval_g = ff_parse(ci->expr_G, const_names, NULL, NULL, NULL, NULL, &error))){
-            av_log(NULL, AV_LOG_ERROR, "Couldn't parse G expression '%s': %s\n", ci->expr_G, error);
-            return -1;
-        }
-        if (!(ci->eval_b = ff_parse(ci->expr_B, const_names, NULL, NULL, NULL, NULL, &error))){
-            av_log(NULL, AV_LOG_ERROR, "Couldn't parse B expression '%s': %s\n", ci->expr_B, error);
-            return -1;
-        }
-    }
-
-    if (ci->expr_A) {
-        if (!(ci->eval_a = ff_parse(ci->expr_A, const_names, NULL, NULL, NULL, NULL, &error))){
-            av_log(NULL, AV_LOG_ERROR, "Couldn't parse A expression '%s': %s\n", ci->expr_A, error);
-            return -1;
-        }
-    } else {
-        ci->a = 255;
-    }
-
-    if (!(ci->eval_colors || ci->eval_a))
-        imlib_context_set_color(ci->r, ci->g, ci->b, ci->a);
-
-    /* load the image (for example, credits for a movie) */
-    if (ci->fileImage) {
-        ci->imageOverlaid = imlib_load_image_immediately(ci->fileImage);
-        if (!(ci->imageOverlaid)){
-            av_log(NULL, AV_LOG_ERROR, "Couldn't load image '%s'\n", ci->fileImage);
-            return -1;
-        }
-        imlib_context_set_image(ci->imageOverlaid);
-        ci->imageOverlaid_width  = imlib_image_get_width();
-        ci->imageOverlaid_height = imlib_image_get_height();
-    }
-
-    if (!(ci->eval_x = ff_parse(ci->expr_x, const_names, NULL, NULL, NULL, NULL, &error))){
-        av_log(NULL, AV_LOG_ERROR, "Couldn't parse x expression '%s': %s\n", ci->expr_x, error);
-        return -1;
-    }
-
-    if (!(ci->eval_y = ff_parse(ci->expr_y, const_names, NULL, NULL, NULL, NULL, &error))){
-        av_log(NULL, AV_LOG_ERROR, "Couldn't parse y expression '%s': %s\n", ci->expr_y, error);
-        return -1;
-    }
-
-    return 0;
-}
-
-static Imlib_Image get_cached_image(ContextInfo *ci, int width, int height)
-{
-    CachedImage *cache;
-
-    for (cache = ci->cache; cache; cache = cache->next) {
-        if (width == cache->width && height == cache->height)
-            return cache->image;
-    }
-
-    return NULL;
-}
-
-static void put_cached_image(ContextInfo *ci, Imlib_Image image, int width, int height)
-{
-    CachedImage *cache = av_mallocz(sizeof(*cache));
-
-    cache->image = image;
-    cache->width = width;
-    cache->height = height;
-    cache->next = ci->cache;
-    ci->cache = cache;
-}
-
-void Process(void *ctx, AVPicture *picture, enum PixelFormat pix_fmt, int width, int height, int64_t pts)
-{
-    ContextInfo *ci = (ContextInfo *) ctx;
-    AVPicture picture1;
-    Imlib_Image image;
-    DATA32 *data;
-
-    image = get_cached_image(ci, width, height);
-
-    if (!image) {
-        image = imlib_create_image(width, height);
-        put_cached_image(ci, image, width, height);
-    }
-
-    imlib_context_set_image(image);
-    data = imlib_image_get_data();
-
-    avpicture_fill(&picture1, (uint8_t *) data, PIX_FMT_RGB32, width, height);
-
-    // if we already got a SWS context, let's realloc if is not re-useable
-    ci->toRGB_convert_ctx = sws_getCachedContext(ci->toRGB_convert_ctx,
-                                width, height, pix_fmt,
-                                width, height, PIX_FMT_RGB32,
-                                sws_flags, NULL, NULL, NULL);
-    if (ci->toRGB_convert_ctx == NULL) {
-        av_log(NULL, AV_LOG_ERROR,
-               "Cannot initialize the toRGB conversion context\n");
-        return;
-    }
-
-// img_convert parameters are          2 first destination, then 4 source
-// sws_scale   parameters are context, 4 first source,      then 2 destination
-    sws_scale(ci->toRGB_convert_ctx,
-             picture->data, picture->linesize, 0, height,
-             picture1.data, picture1.linesize);
-
-    imlib_image_set_has_alpha(0);
-
-    {
-        int wid, hig, h_a, v_a;
-        char buff[1000];
-        char tbuff[1000];
-        const char *tbp = ci->text;
-        time_t now = time(0);
-        char *p, *q;
-        int y;
-
-        double const_values[]={
-            M_PI,
-            M_E,
-            ci->frame_number,         // frame number (starting at zero)
-            height,                   // frame height
-            width,                    // frame width
-            ci->imageOverlaid_height, // image height
-            ci->imageOverlaid_width,  // image width
-            ci->x,                    // previous x
-            ci->y,                    // previous y
-            0
-        };
-
-        if (ci->file) {
-            int fd = open(ci->file, O_RDONLY);
-
-            if (fd < 0) {
-                tbp = "[File not found]";
-            } else {
-                int l = read(fd, tbuff, sizeof(tbuff) - 1);
-
-                if (l >= 0) {
-                    tbuff[l] = 0;
-                    tbp = tbuff;
-                } else {
-                    tbp = "[I/O Error]";
-                }
-                close(fd);
-            }
-        }
-
-        if (tbp)
-            strftime(buff, sizeof(buff), tbp, localtime(&now));
-        else if (!(ci->imageOverlaid))
-            strftime(buff, sizeof(buff), "[No data]", localtime(&now));
-
-        ci->x = ff_parse_eval(ci->eval_x, const_values, ci);
-        ci->y = ff_parse_eval(ci->eval_y, const_values, ci);
-        y = ci->y;
-
-        if (ci->eval_a) {
-            ci->a = ff_parse_eval(ci->eval_a, const_values, ci);
-        }
-
-        if (ci->eval_colors) {
-            ci->r = ff_parse_eval(ci->eval_r, const_values, ci);
-            ci->g = ff_parse_eval(ci->eval_g, const_values, ci);
-            ci->b = ff_parse_eval(ci->eval_b, const_values, ci);
-        }
-
-        if (ci->eval_colors || ci->eval_a) {
-            imlib_context_set_color(ci->r, ci->g, ci->b, ci->a);
-        }
-
-        if (!(ci->imageOverlaid))
-        for (p = buff; p; p = q) {
-            q = strchr(p, '\n');
-            if (q)
-                *q++ = 0;
-
-            imlib_text_draw_with_return_metrics(ci->x, y, p, &wid, &hig, &h_a, &v_a);
-            y += v_a;
-        }
-
-        if (ci->imageOverlaid) {
-            imlib_context_set_image(image);
-            imlib_blend_image_onto_image(ci->imageOverlaid, 0,
-                0, 0, ci->imageOverlaid_width, ci->imageOverlaid_height,
-                ci->x, ci->y, ci->imageOverlaid_width, ci->imageOverlaid_height);
-        }
-
-    }
-
-    ci->fromRGB_convert_ctx = sws_getCachedContext(ci->fromRGB_convert_ctx,
-                                    width, height, PIX_FMT_RGB32,
-                                    width, height, pix_fmt,
-                                    sws_flags, NULL, NULL, NULL);
-    if (ci->fromRGB_convert_ctx == NULL) {
-        av_log(NULL, AV_LOG_ERROR,
-               "Cannot initialize the fromRGB conversion context\n");
-        return;
-    }
-// img_convert parameters are          2 first destination, then 4 source
-// sws_scale   parameters are context, 4 first source,      then 2 destination
-    sws_scale(ci->fromRGB_convert_ctx,
-             picture1.data, picture1.linesize, 0, height,
-             picture->data, picture->linesize);
-
-    ci->frame_number++;
-}
-
diff --git a/vhook/null.c b/vhook/null.c
deleted file mode 100644
index 1f957fb..0000000
--- a/vhook/null.c
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Null Video Hook
- * Copyright (c) 2002 Philip Gladstone
- *
- * 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 <stdio.h>
-
-#include "libavformat/framehook.h"
-#include "libswscale/swscale.h"
-
-static int sws_flags = SWS_BICUBIC;
-
-typedef struct {
-    int dummy;
-
-    // This vhook first converts frame to RGB ...
-    struct SwsContext *toRGB_convert_ctx;
-
-    // ... and later converts back frame from RGB to initial format
-    struct SwsContext *fromRGB_convert_ctx;
-
-} ContextInfo;
-
-void Release(void *ctx)
-{
-    ContextInfo *ci;
-    ci = (ContextInfo *) ctx;
-
-    if (ctx) {
-        sws_freeContext(ci->toRGB_convert_ctx);
-        sws_freeContext(ci->fromRGB_convert_ctx);
-        av_free(ctx);
-    }
-}
-
-int Configure(void **ctxp, int argc, char *argv[])
-{
-    av_log(NULL, AV_LOG_DEBUG, "Called with argc=%d\n", argc);
-
-    *ctxp = av_mallocz(sizeof(ContextInfo));
-    return 0;
-}
-
-void Process(void *ctx, AVPicture *picture, enum PixelFormat pix_fmt, int width, int height, int64_t pts)
-{
-    ContextInfo *ci = (ContextInfo *) ctx;
-    char *buf = 0;
-    AVPicture picture1;
-    AVPicture *pict = picture;
-
-    (void) ci;
-
-    if (pix_fmt != PIX_FMT_RGB24) {
-        int size;
-
-        size = avpicture_get_size(PIX_FMT_RGB24, width, height);
-        buf = av_malloc(size);
-
-        avpicture_fill(&picture1, buf, PIX_FMT_RGB24, width, height);
-
-        // if we already got a SWS context, let's realloc if is not re-useable
-        ci->toRGB_convert_ctx = sws_getCachedContext(ci->toRGB_convert_ctx,
-                                    width, height, pix_fmt,
-                                    width, height, PIX_FMT_RGB24,
-                                    sws_flags, NULL, NULL, NULL);
-        if (ci->toRGB_convert_ctx == NULL) {
-            av_log(NULL, AV_LOG_ERROR,
-                   "Cannot initialize the toRGB conversion context\n");
-            return;
-        }
-// img_convert parameters are          2 first destination, then 4 source
-// sws_scale   parameters are context, 4 first source,      then 2 destination
-        sws_scale(ci->toRGB_convert_ctx,
-            picture->data, picture->linesize, 0, height,
-            picture1.data, picture1.linesize);
-
-        pict = &picture1;
-    }
-
-    /* Insert filter code here */
-
-    if (pix_fmt != PIX_FMT_RGB24) {
-        ci->fromRGB_convert_ctx = sws_getCachedContext(ci->fromRGB_convert_ctx,
-                                        width, height, PIX_FMT_RGB24,
-                                        width, height, pix_fmt,
-                                        sws_flags, NULL, NULL, NULL);
-        if (ci->fromRGB_convert_ctx == NULL) {
-            av_log(NULL, AV_LOG_ERROR,
-                   "Cannot initialize the fromRGB conversion context\n");
-            return;
-        }
-// img_convert parameters are          2 first destination, then 4 source
-// sws_scale   parameters are context, 4 first source,      then 2 destination
-        sws_scale(ci->fromRGB_convert_ctx,
-            picture1.data, picture1.linesize, 0, height,
-            picture->data, picture->linesize);
-    }
-
-    av_free(buf);
-}
-
diff --git a/vhook/ppm.c b/vhook/ppm.c
deleted file mode 100644
index 86fad1d..0000000
--- a/vhook/ppm.c
+++ /dev/null
@@ -1,374 +0,0 @@
-/*
- * PPM Video Hook
- * Copyright (c) 2003 Charles Yates
- *
- * 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 <stdio.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <ctype.h>
-#include "libavutil/avstring.h"
-#include "libavformat/framehook.h"
-#include "libavformat/avformat.h"
-#include "libswscale/swscale.h"
-#undef fprintf
-
-static int sws_flags = SWS_BICUBIC;
-
-/** Bi-directional pipe structure.
-*/
-
-typedef struct rwpipe
-{
-    int pid;
-    FILE *reader;
-    FILE *writer;
-}
-rwpipe;
-
-/** Create a bidirectional pipe for the given command.
-*/
-
-static rwpipe *rwpipe_open( int argc, char *argv[] )
-{
-    rwpipe *this = av_mallocz( sizeof( rwpipe ) );
-
-    if ( this != NULL )
-    {
-        int input[ 2 ];
-        int output[ 2 ];
-
-        if (!pipe( input ))
-            return NULL;
-
-        if (!pipe( output ))
-            return NULL;
-
-        this->pid = fork();
-
-        if ( this->pid == 0 )
-        {
-#define COMMAND_SIZE 10240
-            char *command = av_mallocz( COMMAND_SIZE );
-            int i;
-
-            strcpy( command, "" );
-            for ( i = 0; i < argc; i ++ )
-            {
-                av_strlcat( command, argv[ i ], COMMAND_SIZE );
-                av_strlcat( command, " ", COMMAND_SIZE );
-            }
-
-            dup2( output[ 0 ], STDIN_FILENO );
-            dup2( input[ 1 ], STDOUT_FILENO );
-
-            close( input[ 0 ] );
-            close( input[ 1 ] );
-            close( output[ 0 ] );
-            close( output[ 1 ] );
-
-            execl("/bin/sh", "sh", "-c", command, (char*)NULL );
-            _exit( 255 );
-        }
-        else
-        {
-            close( input[ 1 ] );
-            close( output[ 0 ] );
-
-            this->reader = fdopen( input[ 0 ], "r" );
-            this->writer = fdopen( output[ 1 ], "w" );
-        }
-    }
-
-    return this;
-}
-
-/** Read data from the pipe.
-*/
-
-static FILE *rwpipe_reader( rwpipe *this )
-{
-    if ( this != NULL )
-        return this->reader;
-    else
-        return NULL;
-}
-
-/** Write data to the pipe.
-*/
-
-static FILE *rwpipe_writer( rwpipe *this )
-{
-    if ( this != NULL )
-        return this->writer;
-    else
-        return NULL;
-}
-
-/* Read a number from the pipe - assumes PNM style headers.
-*/
-
-static int rwpipe_read_number( rwpipe *rw )
-{
-    int value = 0;
-    int c = 0;
-    FILE *in = rwpipe_reader( rw );
-
-    do
-    {
-        c = fgetc( in );
-
-        while( c != EOF && !isdigit( c ) && c != '#' )
-            c = fgetc( in );
-
-        if ( c == '#' )
-            while( c != EOF && c != '\n' )
-                c = fgetc( in );
-    }
-    while ( c != EOF && !isdigit( c ) );
-
-    while( c != EOF && isdigit( c ) )
-    {
-        value = value * 10 + ( c - '0' );
-        c = fgetc( in );
-    }
-
-    return value;
-}
-
-/** Read a PPM P6 header.
-*/
-
-static int rwpipe_read_ppm_header( rwpipe *rw, int *width, int *height )
-{
-    char line[ 3 ];
-    FILE *in = rwpipe_reader( rw );
-    int max;
-
-    if (!fgets( line, 3, in ))
-        return -1;
-
-    if ( !strncmp( line, "P6", 2 ) )
-    {
-        *width = rwpipe_read_number( rw );
-        *height = rwpipe_read_number( rw );
-        max = rwpipe_read_number( rw );
-        return max != 255 || *width <= 0 || *height <= 0;
-    }
-    return 1;
-}
-
-/** Close the pipe and process.
-*/
-
-static void rwpipe_close( rwpipe *this )
-{
-    if ( this != NULL )
-    {
-        fclose( this->reader );
-        fclose( this->writer );
-        waitpid( this->pid, NULL, 0 );
-        av_free( this );
-    }
-}
-
-/** Context info for this vhook - stores the pipe and image buffers.
-*/
-
-typedef struct
-{
-    rwpipe *rw;
-    int size1;
-    char *buf1;
-    int size2;
-    char *buf2;
-
-    // This vhook first converts frame to RGB ...
-    struct SwsContext *toRGB_convert_ctx;
-    // ... then processes it via a PPM command pipe ...
-    // ... and finally converts back frame from RGB to initial format
-    struct SwsContext *fromRGB_convert_ctx;
-}
-ContextInfo;
-
-/** Initialise the context info for this vhook.
-*/
-
-int Configure(void **ctxp, int argc, char *argv[])
-{
-    if ( argc > 1 )
-    {
-        *ctxp = av_mallocz(sizeof(ContextInfo));
-        if ( *ctxp != NULL && argc > 1 )
-        {
-            ContextInfo *info = (ContextInfo *)*ctxp;
-            info->rw = rwpipe_open( argc - 1, &argv[ 1 ] );
-            return 0;
-        }
-    }
-    return 1;
-}
-
-/** Process a frame.
-*/
-
-void Process(void *ctx, AVPicture *picture, enum PixelFormat pix_fmt, int width, int height, int64_t pts)
-{
-    int err = 0;
-    ContextInfo *ci = (ContextInfo *) ctx;
-    AVPicture picture1;
-    AVPicture picture2;
-    AVPicture *pict = picture;
-    int out_width;
-    int out_height;
-    int i;
-    uint8_t *ptr = NULL;
-    FILE *in = rwpipe_reader( ci->rw );
-    FILE *out = rwpipe_writer( ci->rw );
-
-    /* Check that we have a pipe to talk to. */
-    if ( in == NULL || out == NULL )
-        err = 1;
-
-    /* Convert to RGB24 if necessary */
-    if ( !err && pix_fmt != PIX_FMT_RGB24 )
-    {
-        int size = avpicture_get_size(PIX_FMT_RGB24, width, height);
-
-        if ( size != ci->size1 )
-        {
-            av_free( ci->buf1 );
-            ci->buf1 = av_malloc(size);
-            ci->size1 = size;
-            err = ci->buf1 == NULL;
-        }
-
-        if ( !err )
-        {
-            avpicture_fill(&picture1, ci->buf1, PIX_FMT_RGB24, width, height);
-
-            // if we already got a SWS context, let's realloc if is not re-useable
-            ci->toRGB_convert_ctx = sws_getCachedContext(ci->toRGB_convert_ctx,
-                                        width, height, pix_fmt,
-                                        width, height, PIX_FMT_RGB24,
-                                        sws_flags, NULL, NULL, NULL);
-            if (ci->toRGB_convert_ctx == NULL) {
-                av_log(NULL, AV_LOG_ERROR,
-                       "Cannot initialize the toRGB conversion context\n");
-                return;
-            }
-
-// img_convert parameters are          2 first destination, then 4 source
-// sws_scale   parameters are context, 4 first source,      then 2 destination
-            sws_scale(ci->toRGB_convert_ctx,
-                     picture->data, picture->linesize, 0, height,
-                     picture1.data, picture1.linesize);
-
-            pict = &picture1;
-        }
-    }
-
-    /* Write out the PPM */
-    if ( !err )
-    {
-        ptr = pict->data[ 0 ];
-        fprintf( out, "P6\n%d %d\n255\n", width, height );
-        for ( i = 0; !err && i < height; i ++ )
-        {
-            err = !fwrite( ptr, width * 3, 1, out );
-            ptr += pict->linesize[ 0 ];
-        }
-        if ( !err )
-            err = fflush( out );
-    }
-
-    /* Read the PPM returned. */
-    if ( !err && !rwpipe_read_ppm_header( ci->rw, &out_width, &out_height ) )
-    {
-        int size = avpicture_get_size(PIX_FMT_RGB24, out_width, out_height);
-
-        if ( size != ci->size2 )
-        {
-            av_free( ci->buf2 );
-            ci->buf2 = av_malloc(size);
-            ci->size2 = size;
-            err = ci->buf2 == NULL;
-        }
-
-        if ( !err )
-        {
-            avpicture_fill(&picture2, ci->buf2, PIX_FMT_RGB24, out_width, out_height);
-            ptr = picture2.data[ 0 ];
-            for ( i = 0; !err && i < out_height; i ++ )
-            {
-                err = !fread( ptr, out_width * 3, 1, in );
-                ptr += picture2.linesize[ 0 ];
-            }
-        }
-    }
-
-    /* Convert the returned PPM back to the input format */
-    if ( !err )
-    {
-        /* The out_width/out_height returned from the PPM
-         * filter won't necessarily be the same as width and height
-         * but it will be scaled anyway to width/height.
-         */
-        av_log(NULL, AV_LOG_DEBUG,
-                  "PPM vhook: Input dimensions: %d x %d Output dimensions: %d x %d\n",
-                  width, height, out_width, out_height);
-        ci->fromRGB_convert_ctx = sws_getCachedContext(ci->fromRGB_convert_ctx,
-                                        out_width, out_height, PIX_FMT_RGB24,
-                                        width,     height,     pix_fmt,
-                                        sws_flags, NULL, NULL, NULL);
-        if (ci->fromRGB_convert_ctx == NULL) {
-            av_log(NULL, AV_LOG_ERROR,
-                   "Cannot initialize the fromRGB conversion context\n");
-            return;
-        }
-
-// img_convert parameters are          2 first destination, then 4 source
-// sws_scale   parameters are context, 4 first source,      then 2 destination
-        sws_scale(ci->fromRGB_convert_ctx,
-                 picture2.data, picture2.linesize, 0, out_height,
-                 picture->data, picture->linesize);
-    }
-}
-
-/** Clean up the effect.
-*/
-
-void Release(void *ctx)
-{
-    ContextInfo *ci;
-    ci = (ContextInfo *) ctx;
-
-    if (ctx)
-    {
-        rwpipe_close( ci->rw );
-        av_free( ci->buf1 );
-        av_free( ci->buf2 );
-        sws_freeContext(ci->toRGB_convert_ctx);
-        sws_freeContext(ci->fromRGB_convert_ctx);
-        av_free(ctx);
-    }
-}
-
diff --git a/vhook/watermark.c b/vhook/watermark.c
deleted file mode 100644
index 1d4be28..0000000
--- a/vhook/watermark.c
+++ /dev/null
@@ -1,655 +0,0 @@
-/*
- * Watermark Hook
- * Copyright (c) 2005 Marcus Engene myfirstname(at)mylastname.se
- *
- * parameters for watermark:
- *  -m nbr = nbr is 0..1. 0 is the default mode, see below.
- *  -t nbr = nbr is six digit hex. Threshold.
- *  -f file = file is the watermark image filename. You must specify this!
- *
- * MODE 0:
- * The watermark picture works like this (assuming color intensities 0..0xff):
- * Per color do this:
- * If mask color is 0x80, no change to the original frame.
- * If mask color is < 0x80 the abs difference is subtracted from the frame. If
- * result < 0, result = 0
- * If mask color is > 0x80 the abs difference is added to the frame. If result
- * > 0xff, result = 0xff
- *
- * You can override the 0x80 level with the -t flag. E.g. if threshold is
- * 000000 the color value of watermark is added to the destination.
- *
- * This way a mask that is visible both in light pictures and in dark can be
- * made (fex by using a picture generated by Gimp and the bump map tool).
- *
- * An example watermark file is at
- * http://engene.se/ffmpeg_watermark.gif
- *
- * MODE 1:
- * Per color do this:
- * If mask color > threshold color then the watermark pixel is used.
- *
- * Example usage:
- *  ffmpeg -i infile -vhook '/path/watermark.so -f wm.gif' -an out.mov
- *  ffmpeg -i infile -vhook '/path/watermark.so -f wm.gif -m 1 -t 222222' -an out.mov
- *
- * Note that the entire vhook argument is encapsulated in ''. This
- * way, arguments to the vhook won't be mixed up with those for ffmpeg.
- *
- * 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 <stdlib.h>
-//#include <fcntl.h>
-#include <unistd.h>
-#include <stdarg.h>
-
-#include "libavutil/common.h"
-#include "libavformat/avformat.h"
-#include "libavformat/framehook.h"
-#include "libswscale/swscale.h"
-
-static int sws_flags = SWS_BICUBIC;
-
-typedef struct {
-    char            filename[2000];
-    int             x_size;
-    int             y_size;
-
-    /* get_watermark_picture() variables */
-    AVFormatContext *pFormatCtx;
-    const char     *p_ext;
-    int             videoStream;
-    int             frameFinished;
-    AVCodecContext *pCodecCtx;
-    AVCodec        *pCodec;
-    AVFrame        *pFrame;
-    AVPacket        packet;
-    int             numBytes;
-    uint8_t        *buffer;
-    int             i;
-    AVInputFormat  *file_iformat;
-    AVStream       *st;
-    int             is_done;
-    AVFrame        *pFrameRGB;
-    int             thrR;
-    int             thrG;
-    int             thrB;
-    int             mode;
-
-    // This vhook first converts frame to RGB ...
-    struct SwsContext *toRGB_convert_ctx;
-    // ... then converts a watermark and applies it to the RGB frame ...
-    struct SwsContext *watermark_convert_ctx;
-    // ... and finally converts back frame from RGB to initial format
-    struct SwsContext *fromRGB_convert_ctx;
-} ContextInfo;
-
-int get_watermark_picture(ContextInfo *ci, int cleanup);
-
-
-/****************************************************************************
- *
- ****************************************************************************/
-void Release(void *ctx)
-{
-    ContextInfo *ci;
-    ci = (ContextInfo *) ctx;
-
-    if (ci) {
-        get_watermark_picture(ci, 1);
-        sws_freeContext(ci->toRGB_convert_ctx);
-        sws_freeContext(ci->watermark_convert_ctx);
-        sws_freeContext(ci->fromRGB_convert_ctx);
-    }
-    av_free(ctx);
-}
-
-
-/****************************************************************************
- *
- ****************************************************************************/
-int Configure(void **ctxp, int argc, char *argv[])
-{
-    ContextInfo *ci;
-    int c;
-    int tmp = 0;
-
-    if (0 == (*ctxp = av_mallocz(sizeof(ContextInfo)))) return -1;
-    ci = (ContextInfo *) *ctxp;
-
-    optind = 1;
-
-    // Struct is mallocz:ed so no need to reset.
-    ci->thrR = 0x80;
-    ci->thrG = 0x80;
-    ci->thrB = 0x80;
-
-    while ((c = getopt(argc, argv, "f:m:t:")) > 0) {
-        switch (c) {
-            case 'f':
-                strncpy(ci->filename, optarg, 1999);
-                ci->filename[1999] = 0;
-                break;
-            case 'm':
-                ci->mode = atoi(optarg);
-                break;
-            case 't':
-                if (1 != sscanf(optarg, "%x", &tmp)) {
-                    av_log(NULL, AV_LOG_ERROR, "Watermark: argument to -t must be a 6 digit hex number\n");
-                    return -1;
-                }
-                ci->thrR = (tmp >> 16) & 0xff;
-                ci->thrG = (tmp >> 8) & 0xff;
-                ci->thrB = (tmp >> 0) & 0xff;
-                break;
-            default:
-                av_log(NULL, AV_LOG_ERROR, "Watermark: Unrecognized argument '%s'\n", argv[optind]);
-                return -1;
-        }
-    }
-
-    //
-    if (0 == ci->filename[0]) {
-        av_log(NULL, AV_LOG_ERROR, "Watermark: There is no filename specified.\n");
-        return -1;
-    }
-
-    av_register_all();
-    return get_watermark_picture(ci, 0);
-}
-
-
-/****************************************************************************
- * For mode 0 (the original one)
- ****************************************************************************/
-static void Process0(void *ctx,
-              AVPicture *picture,
-              enum PixelFormat pix_fmt,
-              int src_width,
-              int src_height,
-              int64_t pts)
-{
-    ContextInfo *ci = (ContextInfo *) ctx;
-    char *buf = 0;
-    AVPicture picture1;
-    AVPicture *pict = picture;
-
-    AVFrame *pFrameRGB;
-    int xm_size;
-    int ym_size;
-
-    int x;
-    int y;
-    int offs, offsm;
-    int mpoffs;
-    uint32_t *p_pixel = 0;
-    uint32_t pixel_meck;
-    uint32_t pixel;
-    uint32_t pixelm;
-    int tmp;
-    int thrR = ci->thrR;
-    int thrG = ci->thrG;
-    int thrB = ci->thrB;
-
-    if (pix_fmt != PIX_FMT_RGB32) {
-        int size;
-
-        size = avpicture_get_size(PIX_FMT_RGB32, src_width, src_height);
-        buf = av_malloc(size);
-
-        avpicture_fill(&picture1, buf, PIX_FMT_RGB32, src_width, src_height);
-
-        // if we already got a SWS context, let's realloc if is not re-useable
-        ci->toRGB_convert_ctx = sws_getCachedContext(ci->toRGB_convert_ctx,
-                                    src_width, src_height, pix_fmt,
-                                    src_width, src_height, PIX_FMT_RGB32,
-                                    sws_flags, NULL, NULL, NULL);
-        if (ci->toRGB_convert_ctx == NULL) {
-            av_log(NULL, AV_LOG_ERROR,
-                   "Cannot initialize the toRGB conversion context\n");
-            return;
-        }
-
-// img_convert parameters are          2 first destination, then 4 source
-// sws_scale   parameters are context, 4 first source,      then 2 destination
-        sws_scale(ci->toRGB_convert_ctx,
-                 picture->data, picture->linesize, 0, src_height,
-                 picture1.data, picture1.linesize);
-
-        pict = &picture1;
-    }
-
-    /* Insert filter code here */ /* ok */
-
-    // Get me next frame
-    if (0 > get_watermark_picture(ci, 0)) {
-        return;
-    }
-    // These are the three original static variables in the ffmpeg hack.
-    pFrameRGB = ci->pFrameRGB;
-    xm_size = ci->x_size;
-    ym_size = ci->y_size;
-
-    // I'll do the *4 => <<2 crap later. Most compilers understand that anyway.
-    // According to avcodec.h PIX_FMT_RGB32 is handled in endian specific manner.
-    for (y=0; y<src_height; y++) {
-        offs = y * (src_width * 4);
-        offsm = (((y * ym_size) / src_height) * 4) * xm_size; // offsm first in maskline. byteoffs!
-        for (x=0; x<src_width; x++) {
-            mpoffs = offsm + (((x * xm_size) / src_width) * 4);
-            p_pixel = (uint32_t *)&((pFrameRGB->data[0])[mpoffs]);
-            pixelm = *p_pixel;
-            p_pixel = (uint32_t *)&((pict->data[0])[offs]);
-            pixel = *p_pixel;
-//          pixelm = *((uint32_t *)&(pFrameRGB->data[mpoffs]));
-            pixel_meck = pixel & 0xff000000;
-
-            // R
-            tmp = (int)((pixel >> 16) & 0xff) + (int)((pixelm >> 16) & 0xff) - thrR;
-            if (tmp > 255) tmp = 255;
-            if (tmp < 0) tmp = 0;
-            pixel_meck |= (tmp << 16) & 0xff0000;
-            // G
-            tmp = (int)((pixel >> 8) & 0xff) + (int)((pixelm >> 8) & 0xff) - thrG;
-            if (tmp > 255) tmp = 255;
-            if (tmp < 0) tmp = 0;
-            pixel_meck |= (tmp << 8) & 0xff00;
-            // B
-            tmp = (int)((pixel >> 0) & 0xff) + (int)((pixelm >> 0) & 0xff) - thrB;
-            if (tmp > 255) tmp = 255;
-            if (tmp < 0) tmp = 0;
-            pixel_meck |= (tmp << 0) & 0xff;
-
-
-            // test:
-            //pixel_meck = pixel & 0xff000000;
-            //pixel_meck |= (pixelm & 0x00ffffff);
-
-            *p_pixel = pixel_meck;
-
-            offs += 4;
-        } // foreach X
-    } // foreach Y
-
-
-
-
-    if (pix_fmt != PIX_FMT_RGB32) {
-        ci->fromRGB_convert_ctx = sws_getCachedContext(ci->fromRGB_convert_ctx,
-                                      src_width, src_height, PIX_FMT_RGB32,
-                                      src_width, src_height, pix_fmt,
-                                      sws_flags, NULL, NULL, NULL);
-        if (ci->fromRGB_convert_ctx == NULL) {
-            av_log(NULL, AV_LOG_ERROR,
-                   "Cannot initialize the fromRGB conversion context\n");
-            return;
-        }
-// img_convert parameters are          2 first destination, then 4 source
-// sws_scale   parameters are context, 4 first source,      then 2 destination
-        sws_scale(ci->fromRGB_convert_ctx,
-                 picture1.data, picture1.linesize, 0, src_height,
-                 picture->data, picture->linesize);
-    }
-
-    av_free(buf);
-}
-
-
-/****************************************************************************
- * For mode 1 (the original one)
- ****************************************************************************/
-static void Process1(void *ctx,
-              AVPicture *picture,
-              enum PixelFormat pix_fmt,
-              int src_width,
-              int src_height,
-              int64_t pts)
-{
-    ContextInfo *ci = (ContextInfo *) ctx;
-    char *buf = 0;
-    AVPicture picture1;
-    AVPicture *pict = picture;
-
-    AVFrame *pFrameRGB;
-    int xm_size;
-    int ym_size;
-
-    int x;
-    int y;
-    int offs, offsm;
-    int mpoffs;
-    uint32_t *p_pixel = 0;
-    uint32_t pixel;
-    uint32_t pixelm;
-
-    if (pix_fmt != PIX_FMT_RGB32) {
-        int size;
-
-        size = avpicture_get_size(PIX_FMT_RGB32, src_width, src_height);
-        buf = av_malloc(size);
-
-        avpicture_fill(&picture1, buf, PIX_FMT_RGB32, src_width, src_height);
-
-        // if we already got a SWS context, let's realloc if is not re-useable
-        ci->toRGB_convert_ctx = sws_getCachedContext(ci->toRGB_convert_ctx,
-                                    src_width, src_height, pix_fmt,
-                                    src_width, src_height, PIX_FMT_RGB32,
-                                    sws_flags, NULL, NULL, NULL);
-        if (ci->toRGB_convert_ctx == NULL) {
-            av_log(NULL, AV_LOG_ERROR,
-                   "Cannot initialize the toRGB conversion context\n");
-            return;
-        }
-
-// img_convert parameters are          2 first destination, then 4 source
-// sws_scale   parameters are context, 4 first source,      then 2 destination
-        sws_scale(ci->toRGB_convert_ctx,
-                 picture->data, picture->linesize, 0, src_height,
-                 picture1.data, picture1.linesize);
-
-        pict = &picture1;
-    }
-
-    /* Insert filter code here */ /* ok */
-
-    // Get me next frame
-    if (0 > get_watermark_picture(ci, 0)) {
-        return;
-    }
-    // These are the three original static variables in the ffmpeg hack.
-    pFrameRGB = ci->pFrameRGB;
-    xm_size = ci->x_size;
-    ym_size = ci->y_size;
-
-    // I'll do the *4 => <<2 crap later. Most compilers understand that anyway.
-    // According to avcodec.h PIX_FMT_RGB32 is handled in endian specific manner.
-    for (y=0; y<src_height; y++) {
-        offs = y * (src_width * 4);
-        offsm = (((y * ym_size) / src_height) * 4) * xm_size; // offsm first in maskline. byteoffs!
-        for (x=0; x<src_width; x++) {
-            mpoffs = offsm + (((x * xm_size) / src_width) * 4);
-            p_pixel = (uint32_t *)&((pFrameRGB->data[0])[mpoffs]);
-            pixelm = *p_pixel; /* watermark pixel */
-            p_pixel = (uint32_t *)&((pict->data[0])[offs]);
-            pixel = *p_pixel;
-
-            if (((pixelm >> 16) & 0xff) > ci->thrR ||
-                ((pixelm >>  8) & 0xff) > ci->thrG ||
-                ((pixelm >>  0) & 0xff) > ci->thrB)
-            {
-                *p_pixel = pixelm;
-            } else {
-                *p_pixel = pixel;
-            }
-            offs += 4;
-        } // foreach X
-    } // foreach Y
-
-    if (pix_fmt != PIX_FMT_RGB32) {
-        ci->fromRGB_convert_ctx = sws_getCachedContext(ci->fromRGB_convert_ctx,
-                                      src_width, src_height, PIX_FMT_RGB32,
-                                      src_width, src_height, pix_fmt,
-                                      sws_flags, NULL, NULL, NULL);
-        if (ci->fromRGB_convert_ctx == NULL) {
-            av_log(NULL, AV_LOG_ERROR,
-                   "Cannot initialize the fromRGB conversion context\n");
-            return;
-        }
-// img_convert parameters are          2 first destination, then 4 source
-// sws_scale   parameters are context, 4 first source,      then 2 destination
-        sws_scale(ci->fromRGB_convert_ctx,
-                 picture1.data, picture1.linesize, 0, src_height,
-                 picture->data, picture->linesize);
-    }
-
-    av_free(buf);
-}
-
-
-/****************************************************************************
- * This is the function ffmpeg.c callbacks.
- ****************************************************************************/
-void Process(void *ctx,
-             AVPicture *picture,
-             enum PixelFormat pix_fmt,
-             int src_width,
-             int src_height,
-             int64_t pts)
-{
-    ContextInfo *ci = (ContextInfo *) ctx;
-    if (1 == ci->mode) {
-        Process1(ctx, picture, pix_fmt, src_width, src_height, pts);
-    } else {
-        Process0(ctx, picture, pix_fmt, src_width, src_height, pts);
-    }
-}
-
-
-/****************************************************************************
- * When cleanup == 0, we try to get the next frame. If no next frame, nothing
- * is done.
- *
- * This code follows the example on
- * http://www.inb.uni-luebeck.de/~boehme/using_libavcodec.html
- *
- * 0 = ok, -1 = error
- ****************************************************************************/
-int get_watermark_picture(ContextInfo *ci, int cleanup)
-{
-    if (1 == ci->is_done && 0 == cleanup) return 0;
-
-    // Yes, *pFrameRGB arguments must be null the first time otherwise it's not good..
-    // This block is only executed the first time we enter this function.
-    if (0 == ci->pFrameRGB &&
-        0 == cleanup)
-    {
-
-        /*
-         * The last three parameters specify the file format, buffer size and format
-         * parameters; by simply specifying NULL or 0 we ask libavformat to auto-detect
-         * the format and use a default buffer size. (Didn't work!)
-         */
-        if (av_open_input_file(&ci->pFormatCtx, ci->filename, NULL, 0, NULL) != 0) {
-
-            // Martin says this should not be necessary but it failed for me sending in
-            // NULL instead of file_iformat to av_open_input_file()
-            ci->i = strlen(ci->filename);
-            if (0 == ci->i) {
-                av_log(NULL, AV_LOG_ERROR, "get_watermark_picture() No filename to watermark vhook\n");
-                return -1;
-            }
-            while (ci->i > 0) {
-                if (ci->filename[ci->i] == '.') {
-                    ci->i++;
-                    break;
-                }
-                ci->i--;
-            }
-               ci->p_ext = &(ci->filename[ci->i]);
-            ci->file_iformat = av_find_input_format (ci->p_ext);
-            if (0 == ci->file_iformat) {
-                av_log(NULL, AV_LOG_INFO, "get_watermark_picture() attempt to use image2 for [%s]\n", ci->p_ext);
-                ci->file_iformat = av_find_input_format ("image2");
-            }
-            if (0 == ci->file_iformat) {
-                av_log(NULL, AV_LOG_ERROR, "get_watermark_picture() Really failed to find iformat [%s]\n", ci->p_ext);
-                return -1;
-            }
-            // now continues the Martin template.
-
-            if (av_open_input_file(&ci->pFormatCtx, ci->filename, ci->file_iformat, 0, NULL)!=0) {
-                av_log(NULL, AV_LOG_ERROR, "get_watermark_picture() Failed to open input file [%s]\n", ci->filename);
-                return -1;
-            }
-        }
-
-        /*
-         * This fills the streams field of the AVFormatContext with valid information.
-         */
-        if(av_find_stream_info(ci->pFormatCtx)<0) {
-            av_log(NULL, AV_LOG_ERROR, "get_watermark_picture() Failed to find stream info\n");
-            return -1;
-        }
-
-        /*
-         * As mentioned in the introduction, we'll handle only video streams, not audio
-         * streams. To make things nice and easy, we simply use the first video stream we
-         * find.
-         */
-        ci->videoStream=-1;
-        for(ci->i = 0; ci->i < ci->pFormatCtx->nb_streams; ci->i++)
-            if(ci->pFormatCtx->streams[ci->i]->codec->codec_type==CODEC_TYPE_VIDEO)
-            {
-                ci->videoStream = ci->i;
-                break;
-            }
-        if(ci->videoStream == -1) {
-            av_log(NULL, AV_LOG_ERROR, "get_watermark_picture() Failed to find any video stream\n");
-            return -1;
-        }
-
-        ci->st = ci->pFormatCtx->streams[ci->videoStream];
-        ci->x_size = ci->st->codec->width;
-        ci->y_size = ci->st->codec->height;
-
-        // Get a pointer to the codec context for the video stream
-        ci->pCodecCtx = ci->pFormatCtx->streams[ci->videoStream]->codec;
-
-
-        /*
-         * OK, so now we've got a pointer to the so-called codec context for our video
-         * stream, but we still have to find the actual codec and open it.
-         */
-        // Find the decoder for the video stream
-        ci->pCodec = avcodec_find_decoder(ci->pCodecCtx->codec_id);
-        if(ci->pCodec == NULL) {
-            av_log(NULL, AV_LOG_ERROR, "get_watermark_picture() Failed to find any codec\n");
-            return -1;
-        }
-
-
-        // Open codec
-        if(avcodec_open(ci->pCodecCtx, ci->pCodec)<0) {
-            av_log(NULL, AV_LOG_ERROR, "get_watermark_picture() Failed to open codec\n");
-            return -1;
-        }
-
-        // Hack to correct wrong frame rates that seem to be generated by some
-        // codecs
-        if (ci->pCodecCtx->time_base.den>1000 && ci->pCodecCtx->time_base.num==1)
-            ci->pCodecCtx->time_base.num=1000;
-
-        /*
-         * Allocate a video frame to store the decoded images in.
-         */
-        ci->pFrame = avcodec_alloc_frame();
-
-
-        /*
-         * The RGB image pFrameRGB (of type AVFrame *) is allocated like this:
-         */
-        // Allocate an AVFrame structure
-        ci->pFrameRGB=avcodec_alloc_frame();
-        if(ci->pFrameRGB==NULL) {
-            av_log(NULL, AV_LOG_ERROR, "get_watermark_picture() Failed to alloc pFrameRGB\n");
-            return -1;
-        }
-
-        // Determine required buffer size and allocate buffer
-        ci->numBytes = avpicture_get_size(PIX_FMT_RGB32, ci->pCodecCtx->width,
-            ci->pCodecCtx->height);
-        ci->buffer = av_malloc(ci->numBytes);
-
-        // Assign appropriate parts of buffer to image planes in pFrameRGB
-        avpicture_fill((AVPicture *)ci->pFrameRGB, ci->buffer, PIX_FMT_RGB32,
-            ci->pCodecCtx->width, ci->pCodecCtx->height);
-    }
-    // TODO loop, pingpong etc?
-    if (0 == cleanup)
-    {
-//        av_log(NULL, AV_LOG_DEBUG, "get_watermark_picture() Get a frame\n");
-        while(av_read_frame(ci->pFormatCtx, &ci->packet)>=0)
-        {
-            // Is this a packet from the video stream?
-            if(ci->packet.stream_index == ci->videoStream)
-            {
-                // Decode video frame
-                avcodec_decode_video(ci->pCodecCtx, ci->pFrame, &ci->frameFinished,
-                    ci->packet.data, ci->packet.size);
-
-                // Did we get a video frame?
-                if(ci->frameFinished)
-                {
-                    // Convert the image from its native format to RGB32
-                    ci->watermark_convert_ctx =
-                        sws_getCachedContext(ci->watermark_convert_ctx,
-                            ci->pCodecCtx->width, ci->pCodecCtx->height, ci->pCodecCtx->pix_fmt,
-                            ci->pCodecCtx->width, ci->pCodecCtx->height, PIX_FMT_RGB32,
-                            sws_flags, NULL, NULL, NULL);
-                    if (ci->watermark_convert_ctx == NULL) {
-                        av_log(NULL, AV_LOG_ERROR,
-                              "Cannot initialize the watermark conversion context\n");
-                        return -1;
-                    }
-// img_convert parameters are          2 first destination, then 4 source
-// sws_scale   parameters are context, 4 first source,      then 2 destination
-                    sws_scale(ci->watermark_convert_ctx,
-                             ci->pFrame->data, ci->pFrame->linesize, 0, ci->pCodecCtx->height,
-                             ci->pFrameRGB->data, ci->pFrameRGB->linesize);
-
-                    // Process the video frame (save to disk etc.)
-                    //fprintf(stderr,"banan() New frame!\n");
-                    //DoSomethingWithTheImage(ci->pFrameRGB);
-                    return 0;
-                }
-            }
-
-            // Free the packet that was allocated by av_read_frame
-            av_free_packet(&ci->packet);
-        }
-        ci->is_done = 1;
-        return 0;
-    } // if 0 != cleanup
-
-    if (0 != cleanup)
-    {
-        // Free the RGB image
-        av_freep(&ci->buffer);
-        av_freep(&ci->pFrameRGB);
-
-        // Close the codec
-        if (0 != ci->pCodecCtx) {
-            avcodec_close(ci->pCodecCtx);
-            ci->pCodecCtx = 0;
-        }
-
-        // Close the video file
-        if (0 != ci->pFormatCtx) {
-            av_close_input_file(ci->pFormatCtx);
-            ci->pFormatCtx = 0;
-        }
-
-        ci->is_done = 0;
-    }
-    return 0;
-}
-
-
-void parse_arg_file(const char *filename)
-{
-}