summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Clark <rob@ti.com>2010-11-24 18:15:28 -0600
committerRob Clark <rob@ti.com>2010-11-24 23:45:32 -0600
commitce6fa3d9459189fe8bb86f4b82cad328d5393474 (patch)
tree52ccdb0108649b8b1c4799a4382637bc3adccacf
initial commit
-rw-r--r--.gitignore23
-rw-r--r--.gitmodules3
-rw-r--r--AUTHORS1
-rw-r--r--COPYING504
-rw-r--r--ChangeLog3
-rw-r--r--Makefile.am3
-rw-r--r--NEWS1
-rw-r--r--README22
-rwxr-xr-xautogen.sh121
m---------common0
-rw-r--r--configure.ac137
-rw-r--r--src/Makefile.am20
-rw-r--r--src/gstducati.c102
-rw-r--r--src/gstducati.h47
-rw-r--r--src/gstducatih264dec.c126
-rw-r--r--src/gstducatih264dec.h55
-rw-r--r--src/gstducatividdec.c658
-rw-r--r--src/gstducatividdec.h105
18 files changed, 1931 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..a8f06d8
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,23 @@
+aclocal.m4
+autom4te.cache
+autoregen.sh
+config.*
+configure
+autoregen.sh
+libtool
+INSTALL
+ABOUT-NLS
+Makefile
+Makefile.in
+depcomp
+install-sh
+ltmain.sh
+missing
+stamp-*
+*~
+*.lo
+*.la
+.deps
+.libs
+po
+compile
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..a6b1eda
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "common"]
+ path = common
+ url = git://anongit.freedesktop.org/gstreamer/common
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..418e821
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1 @@
+Rob Clark <rob@ti.com>
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..5ab7695
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,504 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+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 this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. 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 not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+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
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the 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
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "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
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY 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
+LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey 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 library's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ 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.1 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
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+ <signature of Ty Coon>, 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
+
+
diff --git a/ChangeLog b/ChangeLog
new file mode 100644
index 0000000..d72f0ea
--- /dev/null
+++ b/ChangeLog
@@ -0,0 +1,3 @@
+2010-11-22 Rob Clark <rob@ti.com>
+
+ * initial version
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..1ea48a2
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,3 @@
+SUBDIRS = src
+
+EXTRA_DIST = autogen.sh m4 po
diff --git a/NEWS b/NEWS
new file mode 100644
index 0000000..3474a99
--- /dev/null
+++ b/NEWS
@@ -0,0 +1 @@
+Nothing much yet.
diff --git a/README b/README
new file mode 100644
index 0000000..696ecb9
--- /dev/null
+++ b/README
@@ -0,0 +1,22 @@
+WHAT IT IS
+----------
+
+gst-ducati is a plugin for using the hw accellerated codecs on IVA-HD via the
+codec-engine API. Uses the libdce (distributed codec-engine) library to
+use the codec on ducati.
+
+WHY IS IT?
+----------
+
+An OpenMAX-like API is provided by TI along with modified gst-openmax
+plugins. So gst-ducati is not needed in that sense. But libdce and this
+was an interesting project for me to try on my free time.
+
+TODO
+----
++ flush (for seek/eos)
++ mpeg4, vc1, vp6, vp7
++ fallbacks for sink elements not providing TILER buffers to decode into
++ search the code for XXX or TODO ;-)
+
+
diff --git a/autogen.sh b/autogen.sh
new file mode 100755
index 0000000..93f924a
--- /dev/null
+++ b/autogen.sh
@@ -0,0 +1,121 @@
+#!/bin/sh
+# Run this to generate all the initial makefiles, etc.
+
+DIE=0
+package=gst-ducati
+srcfile=src/gstducati.c
+
+# Make sure we have common
+if test ! -f common/gst-autogen.sh;
+then
+ echo "+ Setting up common submodule"
+ git submodule init
+fi
+git submodule update
+
+# source helper functions
+if test ! -f common/gst-autogen.sh;
+then
+ echo There is something wrong with your source tree.
+ echo You are missing common/gst-autogen.sh
+ exit 1
+fi
+. common/gst-autogen.sh
+
+# install pre-commit hook for doing clean commits
+if test ! \( -x .git/hooks/pre-commit -a -L .git/hooks/pre-commit \);
+then
+ rm -f .git/hooks/pre-commit
+ ln -s ../../common/hooks/pre-commit.hook .git/hooks/pre-commit
+fi
+
+touch ChangeLog
+
+CONFIGURE_DEF_OPT='--enable-maintainer-mode'
+
+autogen_options $@
+
+printf "+ check for build tools"
+if test ! -z "$NOCHECK"; then echo " skipped"; else echo; fi
+version_check "autoconf" "$AUTOCONF autoconf autoconf270 autoconf269 autoconf268 autoconf267 autoconf266 autoconf265 autoconf264 autoconf263 autoconf262 autoconf261 autoconf260" \
+ "ftp://ftp.gnu.org/pub/gnu/autoconf/" 2 60 || DIE=1
+version_check "automake" "$AUTOMAKE automake automake-1.11 automake-1.10" \
+ "ftp://ftp.gnu.org/pub/gnu/automake/" 1 10 || DIE=1
+version_check "autopoint" "autopoint" \
+ "ftp://ftp.gnu.org/pub/gnu/gettext/" 0 17 || DIE=1
+version_check "libtoolize" "$LIBTOOLIZE libtoolize glibtoolize" \
+ "ftp://ftp.gnu.org/pub/gnu/libtool/" 1 5 0 || DIE=1
+version_check "pkg-config" "" \
+ "http://www.freedesktop.org/software/pkgconfig" 0 8 0 || DIE=1
+
+die_check $DIE
+
+aclocal_check || DIE=1
+autoheader_check || DIE=1
+
+die_check $DIE
+
+# if no arguments specified then this will be printed
+if test -z "$*"; then
+ echo "+ checking for autogen.sh options"
+ echo " This autogen script will automatically run ./configure as:"
+ echo " ./configure $CONFIGURE_DEF_OPT"
+ echo " To pass any additional options, please specify them on the $0"
+ echo " command line."
+fi
+
+toplevel_check $srcfile
+
+# autopoint
+# older autopoint (< 0.12) has a tendency to complain about mkinstalldirs
+if test -x mkinstalldirs; then rm mkinstalldirs; fi
+# first remove patch if necessary, then run autopoint, then reapply
+if test -f po/Makefile.in.in;
+then
+ patch -p0 -R < common/gettext.patch
+fi
+tool_run "$autopoint --force"
+patch -p0 < common/gettext.patch
+
+tool_run "$libtoolize" "--copy --force"
+tool_run "$aclocal" "-I m4 -I common/m4 $ACLOCAL_FLAGS"
+tool_run "$autoheader"
+
+# touch the stamp-h.in build stamp so we don't re-run autoheader in maintainer mode -- wingo
+echo timestamp > stamp-h.in 2> /dev/null
+
+tool_run "$autoconf"
+tool_run "$automake" "-a -c"
+
+# if enable exists, add an -enable option for each of the lines in that file
+if test -f enable; then
+ for a in `cat enable`; do
+ CONFIGURE_FILE_OPT="--enable-$a"
+ done
+fi
+
+# if disable exists, add an -disable option for each of the lines in that file
+if test -f disable; then
+ for a in `cat disable`; do
+ CONFIGURE_FILE_OPT="$CONFIGURE_FILE_OPT --disable-$a"
+ done
+fi
+
+test -n "$NOCONFIGURE" && {
+ echo "+ skipping configure stage for package $package, as requested."
+ echo "+ autogen.sh done."
+ exit 0
+}
+
+echo "+ running configure ... "
+test ! -z "$CONFIGURE_DEF_OPT" && echo " ./configure default flags: $CONFIGURE_DEF_OPT"
+test ! -z "$CONFIGURE_EXT_OPT" && echo " ./configure external flags: $CONFIGURE_EXT_OPT"
+test ! -z "$CONFIGURE_FILE_OPT" && echo " ./configure enable/disable flags: $CONFIGURE_FILE_OPT"
+echo
+
+./configure $CONFIGURE_DEF_OPT $CONFIGURE_EXT_OPT $CONFIGURE_FILE_OPT || {
+ echo " configure failed"
+ exit 1
+}
+
+echo "Now type 'make' to compile $package."
diff --git a/common b/common
new file mode 160000
+Subproject 011bcc8a0fc7f798ee874a7ba899123fb2470e2
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..c70edfe
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,137 @@
+dnl required version of autoconf
+AC_PREREQ([2.53])
+
+dnl TODO: fill in your package name and package version here
+AC_INIT([gst-ducati],[0.10.0])
+
+dnl required versions of gstreamer and plugins-base
+GST_MAJORMINOR=0.10
+GST_REQUIRED=0.10.30
+
+AC_CONFIG_SRCDIR([src/gstducati.c])
+AC_CONFIG_HEADERS([config.h])
+
+dnl required version of automake
+AM_INIT_AUTOMAKE([1.10])
+
+dnl enable mainainer mode by default
+AM_MAINTAINER_MODE
+
+dnl sets host_* variables
+AC_CANONICAL_HOST
+
+dnl use pretty build output with automake >= 1.11
+m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])],
+ [AM_DEFAULT_VERBOSITY=1
+ AC_SUBST(AM_DEFAULT_VERBOSITY)])
+
+dnl check for tools
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_PROG_INSTALL
+AC_PROG_LIBTOOL
+
+PKG_CHECK_MODULES([CHECK], [check], HAVE_CHECK=yes, HAVE_CHECK=no)
+
+dnl Keep correct libtool macros in-tree.
+AC_CONFIG_MACRO_DIR([m4])
+
+dnl initialize GStreamer macros
+AG_GST_INIT
+dnl define an ERROR_CFLAGS Makefile variable
+AG_GST_SET_ERROR_CFLAGS($GST_CVS)
+
+dnl set up gettext
+dnl the version check needs to stay here because autopoint greps for it
+AM_GNU_GETTEXT_VERSION([0.17])
+AM_GNU_GETTEXT([external])
+AG_GST_GETTEXT([gst-ducati-$GST_MAJORMINOR])
+
+dnl add GStreamer arguments
+AG_GST_ARG_DEBUG
+AG_GST_ARG_PROFILING
+AG_GST_ARG_VALGRIND
+AG_GST_ARG_GCOV
+
+AG_GST_ARG_WITH_PKG_CONFIG_PATH
+AG_GST_ARG_WITH_PACKAGE_NAME
+AG_GST_ARG_WITH_PACKAGE_ORIGIN
+
+dnl required version of libtool
+LT_PREREQ([2.2.6])
+LT_INIT
+
+dnl give error and exit if we don't have pkgconfig
+AC_CHECK_PROG(HAVE_PKGCONFIG, pkg-config, [ ], [
+ AC_MSG_ERROR([You need to have pkg-config installed!])
+])
+
+dnl Check for tiler memmgr
+PKG_CHECK_MODULES([MEMMGR], [libmemmgr])
+
+dnl Check for required codec-engine library..
+PKG_CHECK_MODULES(LIBDCE, [libdce >= 1.0.0])
+
+dnl Check for the required version of GStreamer core (and gst-plugins-base)
+dnl This will export GST_CFLAGS and GST_LIBS variables for use in Makefile.am
+PKG_CHECK_MODULES(GST, [
+ gstreamer-0.10 >= $GST_REQUIRED
+ gstreamer-base-0.10 >= $GST_REQUIRED
+], [
+ AC_SUBST(GST_CFLAGS)
+ AC_SUBST(GST_LIBS)
+], [
+ AC_MSG_ERROR([
+ You need to install or upgrade the GStreamer development
+ packages on your system. On debian-based systems these are
+ libgstreamer0.10-dev and libgstreamer-plugins-base0.10-dev.
+ on RPM-based systems gstreamer0.10-devel, libgstreamer0.10-devel
+ or similar. The minimum version required is $GST_REQUIRED.
+ ])
+])
+
+dnl set license and copyright notice
+GST_LICENSE="LGPL"
+AC_DEFINE_UNQUOTED(GST_LICENSE, "$GST_LICENSE", [GStreamer license])
+AC_SUBST(GST_LICENSE)
+
+dnl set GStreamer plug-in dir
+AG_GST_SET_PLUGINDIR
+
+dnl GST_OPTION_CFLAGS
+if test "x$USE_DEBUG" = xyes; then
+ PROFILE_CFLAGS="-g"
+fi
+AC_SUBST(PROFILE_CFLAGS)
+
+DEPRECATED_CFLAGS="-DGST_DISABLE_DEPRECATED"
+AC_SUBST(DEPRECATED_CFLAGS)
+
+dnl every flag in GST_OPTION_CFLAGS can be overridden at make time
+GST_OPTION_CFLAGS="\$(ERROR_CFLAGS) \$(DEBUG_CFLAGS) \$(PROFILE_CFLAGS) \$(GCOV_CFLAGS) \$(OPT_CFLAGS) \$(DEPRECATED_CFLAGS)"
+AC_SUBST(GST_OPTION_CFLAGS)
+
+dnl our libraries need to be versioned correctly
+AC_SUBST(GST_LT_LDFLAGS)
+
+dnl FIXME: do we want to rename to GST_ALL_* ?
+dnl prefer internal headers to already installed ones
+dnl also add builddir include for enumtypes and marshal
+dnl add GST_OPTION_CFLAGS, but overridable
+GST_CFLAGS="-I\$(top_srcdir)/gst-libs -I\$(top_builddir)/gst-libs $GST_CFLAGS \$(GST_OPTION_CFLAGS)"
+AC_SUBST(GST_CFLAGS)
+AC_SUBST(GST_LIBS)
+
+dnl LDFLAGS really should only contain flags, not libs - they get added before
+dnl whatevertarget_LIBS and -L flags here affect the rest of the linking
+GST_ALL_LDFLAGS=""
+AC_SUBST(GST_ALL_LDFLAGS)
+
+dnl this really should only contain flags, not libs - they get added before
+dnl whatevertarget_LIBS and -L flags here affect the rest of the linking
+GST_PLUGIN_LDFLAGS="-module -avoid-version -export-symbols-regex '^[_]*gst_plugin_desc\$\$' $GST_ALL_LDFLAGS"
+AC_SUBST(GST_PLUGIN_LDFLAGS)
+
+AC_CONFIG_FILES([Makefile src/Makefile])
+AC_OUTPUT
+
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 0000000..2ab0022
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1,20 @@
+plugin_LTLIBRARIES = libgstducati.la
+
+# headers we need but don't want installed
+noinst_HEADERS = \
+ gstducatih264dec.h \
+ gstducatividdec.h \
+ gstducati.h
+
+# sources used to compile this plug-in
+libgstducati_la_SOURCES = \
+ gstducatih264dec.c \
+ gstducatividdec.c \
+ gstducati.c \
+ $(noinst_HEADERS)
+
+# compiler and linker flags used to compile this plugin, set in configure.ac
+libgstducati_la_CFLAGS = $(GST_CFLAGS) $(MEMMGR_CFLAGS) $(LIBDCE_CFLAGS)
+libgstducati_la_LIBADD = $(GST_LIBS) $(MEMMGR_LIBS) $(LIBDCE_LIBS)
+libgstducati_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) $(GST_ALL_LDFLAGS)
+libgstducati_la_LIBTOOLFLAGS = --tag=disable-static
diff --git a/src/gstducati.c b/src/gstducati.c
new file mode 100644
index 0000000..66d139b
--- /dev/null
+++ b/src/gstducati.c
@@ -0,0 +1,102 @@
+/*
+ * GStreamer
+ * Copyright (c) 2010, Texas Instruments Incorporated
+ *
+ * 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
+ * version 2.1 of the License.
+ *
+ * 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
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <gst/gst.h>
+
+#include "gstducatih264dec.h"
+
+GST_DEBUG_CATEGORY (gst_ducati_debug);
+
+static gboolean
+plugin_init (GstPlugin * plugin)
+{
+ GST_DEBUG_CATEGORY_INIT (gst_ducati_debug, "ducati", 0, "ducati");
+
+ return gst_element_register (plugin, "ducatih264dec", GST_RANK_PRIMARY,
+ GST_TYPE_DUCATIH264DEC);
+}
+
+void *
+gst_ducati_alloc_1d (gint sz)
+{
+ MemAllocBlock block = {
+ .pixelFormat = PIXEL_FMT_PAGE,
+ .dim.len = sz,
+ };
+ return MemMgr_Alloc (&block, 1);
+}
+
+void *
+gst_ducati_alloc_2d (gint width, gint height)
+{
+ MemAllocBlock block[] = { {
+ .pixelFormat = PIXEL_FMT_8BIT,
+ .dim = {.area = {
+ .width = width,
+ .height = height,
+ }}
+ }, {
+ .pixelFormat = PIXEL_FMT_16BIT,
+ .dim = {.area = {
+ .width = width,
+ .height = height / 2,
+ }}
+ }
+ };
+ return MemMgr_Alloc (block, 2);
+}
+
+XDAS_Int16
+gst_ducati_get_mem_type (SSPtr paddr)
+{
+ if ((0x60000000 <= paddr) && (paddr < 0x68000000))
+ return XDM_MEMTYPE_TILED8;
+ if ((0x68000000 <= paddr) && (paddr < 0x70000000))
+ return XDM_MEMTYPE_TILED16;
+ if ((0x70000000 <= paddr) && (paddr < 0x78000000))
+ return XDM_MEMTYPE_TILED32;
+ if ((0x78000000 <= paddr) && (paddr < 0x80000000))
+ return XDM_MEMTYPE_RAW;
+ return -1;
+}
+
+/* PACKAGE: this is usually set by autotools depending on some _INIT macro
+ * in configure.ac and then written into and defined in config.h, but we can
+ * just set it ourselves here in case someone doesn't use autotools to
+ * compile this code. GST_PLUGIN_DEFINE needs PACKAGE to be defined.
+ */
+#ifndef PACKAGE
+# define PACKAGE "ducati"
+#endif
+
+GST_PLUGIN_DEFINE (
+ GST_VERSION_MAJOR,
+ GST_VERSION_MINOR,
+ "ducati",
+ "Hardware accellerated codecs for OMAP4",
+ plugin_init,
+ VERSION,
+ "LGPL",
+ "GStreamer",
+ "http://gstreamer.net/"
+)
diff --git a/src/gstducati.h b/src/gstducati.h
new file mode 100644
index 0000000..9897eab
--- /dev/null
+++ b/src/gstducati.h
@@ -0,0 +1,47 @@
+/*
+ * GStreamer
+ * Copyright (c) 2010, Texas Instruments Incorporated
+ *
+ * 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
+ * version 2.1 of the License.
+ *
+ * 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
+ */
+
+#ifndef __GST_DUCATI_H__
+#define __GST_DUCATI_H__
+
+#include <stdint.h>
+#include <string.h>
+
+#include <gst/gst.h>
+
+#include <tiler.h>
+#include <tilermem.h>
+#include <memmgr.h>
+#include <dce.h>
+#include <xdc/std.h>
+#include <ti/sdo/ce/Engine.h>
+#include <ti/sdo/ce/video3/viddec3.h>
+
+G_BEGIN_DECLS
+
+GST_DEBUG_CATEGORY_EXTERN (gst_ducati_debug);
+#define GST_CAT_DEFAULT gst_ducati_debug
+
+void * gst_ducati_alloc_1d (gint sz);
+void * gst_ducati_alloc_2d (gint width, gint height);
+XDAS_Int16 gst_ducati_get_mem_type (SSPtr paddr);
+
+G_END_DECLS
+
+#endif /* __GST_DUCATI_H__ */
diff --git a/src/gstducatih264dec.c b/src/gstducatih264dec.c
new file mode 100644
index 0000000..324826c
--- /dev/null
+++ b/src/gstducatih264dec.c
@@ -0,0 +1,126 @@
+/*
+ * GStreamer
+ * Copyright (c) 2010, Texas Instruments Incorporated
+ *
+ * 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
+ * version 2.1 of the License.
+ *
+ * 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
+ */
+
+/**
+ * SECTION:element-ducatih264dec
+ *
+ * FIXME:Describe ducatih264dec here.
+ *
+ * <refsect2>
+ * <title>Example launch line</title>
+ * |[
+ * gst-launch -v -m fakesrc ! ducatih264dec ! fakesink silent=TRUE
+ * ]|
+ * </refsect2>
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <gst/gst.h>
+#include <gst/video/video.h>
+
+#include "gstducatih264dec.h"
+
+
+#define PADX 32
+#define PADY 24
+
+
+GST_BOILERPLATE (GstDucatiH264Dec, gst_ducati_h264dec, GstDucatiVidDec,
+ GST_TYPE_DUCATIVIDDEC);
+
+static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS ("video/x-h264, "
+// "alignment = au, " /* only entire frames */
+// "stream-format = byte-stream, " /* only byte-stream */
+ "width = (int)[ 16, 2048 ], "
+ "height = (int)[ 16, 2048 ], "
+ "framerate = (fraction)[ 0, max ];")
+ );
+
+/* GstDucatiVideDec vmethod implementations */
+
+static void
+gst_ducati_h264dec_update_buffer_size (GstDucatiVidDec * self)
+{
+ gint w = self->width;
+ gint h = self->height;
+
+ /* calculate output buffer parameters: */
+ self->padded_width = (w + (2 * PADX) + 127) & 0xFFFFFF80;
+ self->padded_height = h + 4 * PADY;
+ self->min_buffers = MIN (16, 32768 / ((w / 16) * (h / 16))) + 3;
+}
+
+static gboolean
+gst_ducati_h264dec_allocate_params (GstDucatiVidDec * self, gint params_sz,
+ gint dynparams_sz, gint status_sz, gint inargs_sz, gint outargs_sz)
+{
+ gboolean ret = parent_class->allocate_params (self,
+ sizeof (IH264VDEC_Params), sizeof (IH264VDEC_DynamicParams),
+ sizeof (IH264VDEC_Status), sizeof (IH264VDEC_InArgs),
+ sizeof (IH264VDEC_OutArgs));
+
+ if (ret) {
+ IH264VDEC_Params *params = (IH264VDEC_Params *) self->params;
+ self->params->displayDelay = IVIDDEC3_DISPLAY_DELAY_AUTO;
+ params->maxNumRefFrames = IH264VDEC_NUM_REFFRAMES_AUTO;
+ params->pConstantMemory = 0;
+ }
+
+ return ret;
+}
+
+/* GObject vmethod implementations */
+
+static void
+gst_ducati_h264dec_base_init (gpointer gclass)
+{
+ GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
+
+ gst_element_class_set_details_simple (element_class,
+ "DucatiH264Dec",
+ "Codec/Decoder/Video",
+ "Decodes video in H.264/AVC format with ducati",
+ "Rob Clark <rob@ti.com>");
+
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&sink_factory));
+}
+
+static void
+gst_ducati_h264dec_class_init (GstDucatiH264DecClass * klass)
+{
+ GstDucatiVidDecClass *bclass = GST_DUCATIVIDDEC_CLASS (klass);
+ bclass->codec_name = "ivahd_h264dec";
+ bclass->update_buffer_size =
+ GST_DEBUG_FUNCPTR (gst_ducati_h264dec_update_buffer_size);
+ bclass->allocate_params =
+ GST_DEBUG_FUNCPTR (gst_ducati_h264dec_allocate_params);
+}
+
+static void
+gst_ducati_h264dec_init (GstDucatiH264Dec * self,
+ GstDucatiH264DecClass * gclass)
+{
+}
diff --git a/src/gstducatih264dec.h b/src/gstducatih264dec.h
new file mode 100644
index 0000000..ce0e636
--- /dev/null
+++ b/src/gstducatih264dec.h
@@ -0,0 +1,55 @@
+/*
+ * GStreamer
+ * Copyright (c) 2010, Texas Instruments Incorporated
+ *
+ * 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
+ * version 2.1 of the License.
+ *
+ * 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
+ */
+
+#ifndef __GST_DUCATIH264DEC_H__
+#define __GST_DUCATIH264DEC_H__
+
+#include <gst/gst.h>
+
+#include "gstducatividdec.h"
+
+#include <ti/sdo/codecs/h264dec/ih264vdec.h>
+
+
+G_BEGIN_DECLS
+
+#define GST_TYPE_DUCATIH264DEC (gst_ducati_h264dec_get_type())
+#define GST_DUCATIH264DEC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_DUCATIH264DEC, GstDucatiH264Dec))
+#define GST_DUCATIH264DEC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_DUCATIH264DEC, GstDucatiH264DecClass))
+#define GST_IS_DUCATIH264DEC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_DUCATIH264DEC))
+#define GST_IS_DUCATIH264DEC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_DUCATIH264DEC))
+
+typedef struct _GstDucatiH264Dec GstDucatiH264Dec;
+typedef struct _GstDucatiH264DecClass GstDucatiH264DecClass;
+
+struct _GstDucatiH264Dec
+{
+ GstDucatiVidDec parent;
+};
+
+struct _GstDucatiH264DecClass
+{
+ GstDucatiVidDecClass parent_class;
+};
+
+GType gst_ducati_h264dec_get_type (void);
+
+G_END_DECLS
+
+#endif /* __GST_DUCATIH264DEC_H__ */
diff --git a/src/gstducatividdec.c b/src/gstducatividdec.c
new file mode 100644
index 0000000..cac3c27
--- /dev/null
+++ b/src/gstducatividdec.c
@@ -0,0 +1,658 @@
+/*
+ * GStreamer
+ * Copyright (c) 2010, Texas Instruments Incorporated
+ *
+ * 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
+ * version 2.1 of the License.
+ *
+ * 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
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <gst/gst.h>
+#include <gst/video/video.h>
+
+#include "gstducatividdec.h"
+
+GST_BOILERPLATE (GstDucatiVidDec, gst_ducati_viddec, GstElement,
+ GST_TYPE_ELEMENT);
+
+static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV_STRIDED ("NV12", "[ 0, max ]"))
+ );
+
+/* helper functions */
+
+static void
+engine_close (GstDucatiVidDec * self)
+{
+ if (self->engine) {
+ Engine_close (self->engine);
+ self->engine = NULL;
+ }
+
+ if (self->params) {
+ dce_free (self->params);
+ self->params = NULL;
+ }
+
+ if (self->dynParams) {
+ dce_free (self->dynParams);
+ self->dynParams = NULL;
+ }
+
+ if (self->status) {
+ dce_free (self->status);
+ self->status = NULL;
+ }
+
+ if (self->inBufs) {
+ dce_free (self->inBufs);
+ self->inBufs = NULL;
+ }
+
+ if (self->outBufs) {
+ dce_free (self->outBufs);
+ self->outBufs = NULL;
+ }
+
+ if (self->inArgs) {
+ dce_free (self->inArgs);
+ self->inArgs = NULL;
+ }
+
+ if (self->outArgs) {
+ dce_free (self->outArgs);
+ self->outArgs = NULL;
+ }
+}
+
+static gboolean
+engine_open (GstDucatiVidDec * self)
+{
+ gboolean ret;
+
+ if (G_UNLIKELY (self->engine)) {
+ return TRUE;
+ }
+
+ GST_DEBUG_OBJECT (self, "opening engine");
+
+ self->engine = Engine_open ("ivahd_vidsvr", NULL, NULL);
+ if (G_UNLIKELY (!self->engine)) {
+ GST_ERROR_OBJECT (self, "could not create engine");
+ return FALSE;
+ }
+
+ ret = GST_DUCATIVIDDEC_GET_CLASS (self)->allocate_params (self,
+ sizeof (IVIDDEC3_Params), sizeof (IVIDDEC3_DynamicParams),
+ sizeof (IVIDDEC3_Status), sizeof (IVIDDEC3_InArgs),
+ sizeof (IVIDDEC3_OutArgs));
+
+ return ret;
+}
+
+static void
+codec_delete (GstDucatiVidDec * self)
+{
+ if (self->codec) {
+ //XXX this crashes ducati:
+ //VIDDEC3_delete(self->codec);
+ self->codec = NULL;
+ }
+
+ if (self->input) {
+ MemMgr_Free (self->input);
+ self->input = NULL;
+ }
+}
+
+static gboolean
+codec_create (GstDucatiVidDec * self)
+{
+ gint err;
+ const gchar *codec_name;
+
+ codec_delete (self);
+
+ if (G_UNLIKELY (!self->engine)) {
+ GST_ERROR_OBJECT (self, "no engine");
+ return FALSE;
+ }
+
+ /* these need to be set before VIDDEC3_create */
+ self->params->maxWidth = (self->width + 15) & ~0xf; /* round up to MB */
+ self->params->maxHeight = (self->height + 15) & ~0xf; /* round up to MB */
+
+ codec_name = GST_DUCATIVIDDEC_GET_CLASS (self)->codec_name;
+
+ /* create codec: */
+ GST_DEBUG_OBJECT (self, "creating codec: %s", codec_name);
+ self->codec = VIDDEC3_create (self->engine, (char *)codec_name, self->params);
+
+ if (!self->codec) {
+ return FALSE;
+ }
+
+ err = VIDDEC3_control(self->codec, XDM_SETPARAMS, self->dynParams, self->status);
+ if (err) {
+ GST_ERROR_OBJECT (self, "failed XDM_SETPARAMS");
+ return FALSE;
+ }
+
+#if 0
+ /* not entirely sure why we need to call this here.. just copying omx.. */
+ err = VIDDEC3_control(self->codec, XDM_GETBUFINFO, self->dynParams, self->status);
+ if (err) {
+ GST_ERROR_OBJECT (self, "failed XDM_GETBUFINFO");
+ return FALSE;
+ }
+#endif
+
+ /* allocate input buffer and initialize inBufs: */
+ self->inBufs->numBufs = 1;
+ self->input = gst_ducati_alloc_1d (self->width * self->height);
+ self->inBufs->descs[0].buf = (XDAS_Int8 *) TilerMem_VirtToPhys (self->input);
+ self->inBufs->descs[0].memType = XDM_MEMTYPE_RAW;
+
+ return TRUE;
+}
+
+static XDAS_Int32
+codec_prepare_outbuf (GstDucatiVidDec * self, GstBuffer * buf)
+{
+ XDAS_Int16 y_type, uv_type;
+ guint8 *y_vaddr, *uv_vaddr;
+ SSPtr y_paddr, uv_paddr;
+
+ y_vaddr = GST_BUFFER_DATA (buf);
+ uv_vaddr = y_vaddr + self->stride * self->padded_height;
+
+ y_paddr = TilerMem_VirtToPhys (y_vaddr);
+ uv_paddr = TilerMem_VirtToPhys (uv_vaddr);
+
+ y_type = gst_ducati_get_mem_type (y_paddr);
+ uv_type = gst_ducati_get_mem_type (uv_paddr);
+
+ if ((y_type < 0) || (uv_type < 0)) {
+ return 0;
+ }
+
+ if (!self->outBufs->numBufs) {
+ /* initialize output buffer type */
+ self->outBufs->numBufs = 2;
+ self->outBufs->descs[0].memType = y_type;
+ self->outBufs->descs[0].bufSize.tileMem.width = self->padded_width;
+ self->outBufs->descs[0].bufSize.tileMem.height = self->padded_height;
+ self->outBufs->descs[1].memType = uv_type;
+ /* note that UV interleaved width is same a Y: */
+ self->outBufs->descs[1].bufSize.tileMem.width = self->padded_width;
+ self->outBufs->descs[1].bufSize.tileMem.height = self->padded_height / 2;
+ } else {
+ /* verify output buffer type matches what we've already given
+ * to the codec
+ */
+ // TODO
+ }
+
+ self->outBufs->descs[0].buf = (XDAS_Int8 *)y_paddr;
+ self->outBufs->descs[1].buf = (XDAS_Int8 *)uv_paddr;
+
+ return (XDAS_Int32) buf; // XXX use lookup table
+}
+
+static GstBuffer *
+codec_get_outbuf (GstDucatiVidDec * self, XDAS_Int32 id)
+{
+ GstBuffer *buf = (GstBuffer *) id; // XXX use lookup table
+ if (buf) {
+ gst_buffer_ref (buf);
+ }
+ return buf;
+}
+
+static void
+codec_unlock_outbuf (GstDucatiVidDec * self, XDAS_Int32 id)
+{
+ GstBuffer *buf = (GstBuffer *) id; // XXX use lookup table
+ if (buf) {
+ gst_buffer_unref (buf);
+ }
+}
+
+static gboolean
+codec_flush (GstDucatiVidDec * self)
+{
+ if (G_UNLIKELY (!self->codec)) {
+ GST_WARNING_OBJECT (self, "no codec");
+ return TRUE;
+ }
+
+ GST_WARNING_OBJECT (self, "TODO");
+
+ return FALSE;
+}
+
+/* GstDucatiVidDec vmethod default implementations */
+
+static gboolean
+gst_ducati_viddec_allocate_params (GstDucatiVidDec * self, gint params_sz,
+ gint dynparams_sz, gint status_sz, gint inargs_sz, gint outargs_sz)
+{
+
+ /* allocate params: */
+ self->params = dce_alloc (params_sz);
+ if (G_UNLIKELY (!self->params)) {
+ return FALSE;
+ }
+ self->params->size = params_sz;
+ self->params->maxFrameRate = 30000;
+ //h264, mpeg4:
+ //note mpeg4 and h263 are same..
+ self->params->maxBitRate = 10000000;
+ //vc1:
+ //self->params->maxBitRate = 45000000;
+
+ self->params->dataEndianness = XDM_BYTE;
+ self->params->forceChromaFormat = XDM_YUV_420SP;
+ self->params->operatingMode = IVIDEO_DECODE_ONLY;
+
+ //mpeg4:
+ //self->params->displayDelay = IVIDDEC3_DISPLAY_DELAY_1;
+
+ //vc1:
+ //self->params->displayDelay = IVIDDEC3_DISPLAY_DELAY_1;
+
+
+ self->params->displayBufsMode = IVIDDEC3_DISPLAYBUFS_EMBEDDED;
+ self->params->inputDataMode = IVIDEO_ENTIREFRAME;
+ self->params->outputDataMode = IVIDEO_ENTIREFRAME;
+ self->params->numInputDataUnits = 0;
+ self->params->numOutputDataUnits = 0;
+
+ //vp6, vp7:
+ //self->params->numInputDataUnits = 1;
+ //self->params->numOutputDataUnits = 1;
+
+ self->params->metadataType[0] = IVIDEO_METADATAPLANE_NONE;
+ self->params->metadataType[1] = IVIDEO_METADATAPLANE_NONE;
+ self->params->metadataType[2] = IVIDEO_METADATAPLANE_NONE;
+ self->params->errorInfoMode = IVIDEO_ERRORINFO_OFF;
+
+ //mpeg4:
+ //((IMPEG4VDEC_Params *) self->params)->outloopDeBlocking = 0;
+ //((IMPEG4VDEC_Params *) self->params)->sorensonSparkStream = 0;
+ //((IMPEG4VDEC_Params *) self->params)->ErrorConcealmentON = 1;
+
+
+ /* allocate dynParams: */
+ self->dynParams = dce_alloc (dynparams_sz);
+ if (G_UNLIKELY (!self->dynParams)) {
+ return FALSE;
+ }
+ self->dynParams->size = dynparams_sz;
+ self->dynParams->decodeHeader = XDM_DECODE_AU;
+ self->dynParams->displayWidth = 0;
+ self->dynParams->frameSkipMode = IVIDEO_NO_SKIP;
+ self->dynParams->newFrameFlag = XDAS_TRUE;
+
+ //mpeg4:
+ //self->dynParams->lateAcquireArg = IRES_HDVICP2_UNKNOWNLATEACQUIREARG;
+
+ /* allocate status: */
+ self->status = dce_alloc (status_sz);
+ if (G_UNLIKELY (!self->status)) {
+ return FALSE;
+ }
+ self->status->size = status_sz;
+
+ /* allocate inBufs/outBufs: */
+ self->inBufs = dce_alloc (sizeof (XDM2_BufDesc));
+ self->outBufs = dce_alloc (sizeof (XDM2_BufDesc));
+ if (G_UNLIKELY (!self->inBufs) || G_UNLIKELY (!self->outBufs)) {
+ return FALSE;
+ }
+
+ /* allocate inArgs/outArgs: */
+ self->inArgs = dce_alloc (inargs_sz);
+ self->outArgs = dce_alloc (outargs_sz);
+ if (G_UNLIKELY (!self->inArgs) || G_UNLIKELY (!self->outArgs)) {
+ return FALSE;
+ }
+ self->inArgs->size = inargs_sz;
+ self->outArgs->size = outargs_sz;
+}
+
+static GstBuffer *
+gst_ducati_viddec_push_input (GstDucatiVidDec * self, GstBuffer * buf)
+{
+ /* just copy entire buffer */
+ self->inArgs->numBytes = GST_BUFFER_SIZE (buf);
+ self->inBufs->descs[0].bufSize.bytes = self->inArgs->numBytes;
+ GST_DEBUG_OBJECT (self, "push: %d bytes)", self->inArgs->numBytes);
+ memcpy (self->input, GST_BUFFER_DATA (buf), self->inArgs->numBytes);
+ gst_buffer_unref (buf);
+ return NULL;
+}
+
+/* GstElement vmethod implementations */
+
+static gboolean
+gst_ducati_viddec_set_caps (GstPad * pad, GstCaps * caps)
+{
+ gboolean ret = TRUE;
+ GstDucatiVidDec *self = GST_DUCATIVIDDEC (gst_pad_get_parent (pad));
+ GstStructure *s;
+
+ g_return_val_if_fail (caps, FALSE);
+ g_return_val_if_fail (gst_caps_is_fixed (caps), FALSE);
+
+ s = gst_caps_get_structure (caps, 0);
+
+ if (pad == self->sinkpad) {
+ gint width, height, frn, frd;
+ GST_INFO_OBJECT (self, "setcaps (sink): %" GST_PTR_FORMAT, caps);
+
+ if (gst_structure_get_int (s, "width", &width) &&
+ gst_structure_get_int (s, "height", &height) &&
+ gst_structure_get_fraction (s, "framerate", &frn, &frd)) {
+ GstCaps *outcaps;
+
+ /* ok, these caps seem sane.. grab the required values and construct
+ * appropriate output caps
+ */
+ self->width = width;
+ self->height = height;
+ self->stride = 4096; /* TODO: don't hardcode */
+
+ /* update output/padded sizes:
+ */
+ GST_DUCATIVIDDEC_GET_CLASS (self)->update_buffer_size (self);
+
+ self->outsize =
+ GST_ROUND_UP_2 (self->stride * self->padded_height * 3) / 2;
+
+ outcaps = gst_caps_new_simple ("video/x-raw-yuv-strided",
+ "rowstride", G_TYPE_INT, self->stride,
+ "format", GST_TYPE_FOURCC, GST_MAKE_FOURCC ('N','V','1','2'),
+ "width", G_TYPE_INT, self->padded_width,
+ "height", G_TYPE_INT, self->padded_height,
+ "framerate", GST_TYPE_FRACTION, frn, frd,
+ NULL);
+
+ GST_DEBUG_OBJECT (self, "outcaps: %" GST_PTR_FORMAT, outcaps);
+
+ ret = gst_pad_set_caps (self->srcpad, outcaps);
+ gst_caps_unref (outcaps);
+
+ if (!ret) {
+ GST_WARNING_OBJECT (self, "failed to set caps");
+ return FALSE;
+ }
+ } else {
+ GST_WARNING_OBJECT (self, "missing required fields");
+ return FALSE;
+ }
+ } else {
+ GST_INFO_OBJECT (self, "setcaps (src): %" GST_PTR_FORMAT, caps);
+ // XXX check to make sure caps are ok.. keep track if we
+ // XXX need to handle unstrided buffers..
+ GST_WARNING_OBJECT (self, "TODO");
+ }
+
+ gst_object_unref (self);
+
+ return gst_pad_set_caps (pad, caps);
+}
+
+static gboolean
+gst_ducati_viddec_query (GstPad * pad, GstQuery * query)
+{
+ GstDucatiVidDec *self = GST_DUCATIVIDDEC (GST_OBJECT_PARENT (pad));
+
+ switch (GST_QUERY_TYPE (query)) {
+ case GST_QUERY_BUFFERS:
+ GST_DEBUG_OBJECT (self, "min buffers: %d", self->min_buffers);
+ gst_query_set_buffers_count (query, self->min_buffers);
+
+ GST_DEBUG_OBJECT (self, "min dimensions: %dx%d",
+ self->padded_width, self->padded_height);
+ gst_query_set_buffers_dimensions (query,
+ self->padded_width, self->padded_height);
+ return TRUE;
+ default:
+ return FALSE;
+ }
+}
+
+static GstFlowReturn
+gst_ducati_viddec_chain (GstPad * pad, GstBuffer * buf)
+{
+ GstDucatiVidDec *self = GST_DUCATIVIDDEC (GST_OBJECT_PARENT (pad));
+ GstFlowReturn ret;
+ Int32 err;
+ gint i;
+ GstBuffer *outbuf = NULL;
+
+ if (G_UNLIKELY (!self->engine)) {
+ GST_ERROR_OBJECT (self, "no engine");
+ return GST_FLOW_ERROR;
+ }
+
+ /* do this before creating codec to ensure reverse caps negotiation
+ * happens first:
+ */
+ ret = gst_pad_alloc_buffer_and_set_caps (self->srcpad, 0, self->outsize,
+ GST_PAD_CAPS (self->srcpad), &outbuf);
+
+ if (ret != GST_FLOW_OK) {
+ /* TODO: if we had our own buffer class, we could allocate our own
+ * output buffer from TILER...
+ */
+ GST_WARNING_OBJECT (self, "ret=%d", ret);
+ GST_WARNING_OBJECT (self, "TODO: allocate output TILER buffer");
+ return ret;
+ }
+
+ if (G_UNLIKELY (!self->codec)) {
+ if (!codec_create (self)) {
+ GST_ERROR_OBJECT (self, "could not create codec");
+ return GST_FLOW_ERROR;
+ }
+ }
+
+ GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (buf);
+ GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (buf);
+
+ self->inArgs->inputID = codec_prepare_outbuf (self, outbuf);
+ if (!self->inArgs->inputID) {
+ GST_ERROR_OBJECT (self, "could not prepare output buffer");
+ return GST_FLOW_ERROR;
+ }
+
+ buf = GST_DUCATIVIDDEC_GET_CLASS (self)->push_input (self, buf);
+
+ if (buf) {
+ // XXX
+ GST_WARNING_OBJECT (self, "TODO.. can't push more than one.. need loop");
+ gst_buffer_unref (buf);
+ buf = NULL;
+ }
+
+ //XXX t = mark (NULL);
+ err = VIDDEC3_process (self->codec,
+ self->inBufs, self->outBufs,
+ self->inArgs, self->outArgs);
+ //XXX GST_DEBUG_OBJECT (self, "processed returned in: %dus", mark (&t));
+ if (err) {
+ GST_ERROR_OBJECT (self, "process returned error: %d %08x",
+ err, self->outArgs->extendedError);
+ return GST_FLOW_ERROR;
+ }
+
+ for (i = 0; self->outArgs->outputID[i]; i++) {
+#if 0
+ /* calculate offset to region of interest */
+ XDM_Rect *r = &(outArgs->displayBufs.bufDesc[0].activeFrameRegion);
+ int yoff = (r->topLeft.y * 4096) + r->topLeft.x;
+ int uvoff = (r->topLeft.y * 4096 / 2) + r->topLeft.x;
+ // XXX do something..
+#endif
+
+ outbuf = codec_get_outbuf (self, self->outArgs->outputID[i]);
+ gst_pad_push (self->srcpad, outbuf);
+ }
+
+ for (i = 0; self->outArgs->freeBufID[i]; i++) {
+ codec_unlock_outbuf (self, self->outArgs->freeBufID[i]);
+ }
+
+ if (self->outArgs->outBufsInUseFlag) {
+ GST_WARNING_OBJECT (self, "TODO... outBufsInUseFlag"); // XXX
+ }
+
+ return GST_FLOW_OK;
+}
+
+static gboolean
+gst_ducati_viddec_event (GstPad * pad, GstEvent * event)
+{
+ GstDucatiVidDec *self = GST_DUCATIVIDDEC (GST_OBJECT_PARENT (pad));
+ gboolean ret = TRUE;
+
+ GST_INFO_OBJECT (self, "begin: event=%s", GST_EVENT_TYPE_NAME (event));
+
+ switch (GST_EVENT_TYPE (event)) {
+ case GST_EVENT_EOS:
+ case GST_EVENT_FLUSH_STOP:
+ if (!codec_flush (self)) {
+ GST_ERROR_OBJECT (self, "could not flush");
+ return FALSE;
+ }
+ /* fall-through */
+ default:
+ ret = gst_pad_push_event (self->srcpad, event);
+ break;
+ }
+
+ GST_LOG_OBJECT (self, "end");
+
+ return ret;
+}
+
+static GstStateChangeReturn
+gst_ducati_viddec_change_state (GstElement * element,
+ GstStateChange transition)
+{
+ GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
+ GstDucatiVidDec *self = GST_DUCATIVIDDEC (element);
+
+ GST_INFO_OBJECT (self, "begin: changing state %s -> %s",
+ gst_element_state_get_name (GST_STATE_TRANSITION_CURRENT (transition)),
+ gst_element_state_get_name (GST_STATE_TRANSITION_NEXT (transition)));
+
+ switch (transition) {
+ case GST_STATE_CHANGE_NULL_TO_READY:
+ if (!engine_open (self)) {
+ GST_ERROR_OBJECT (self, "could not open");
+ return GST_STATE_CHANGE_FAILURE;
+ }
+ break;
+ default:
+ break;
+ }
+
+ ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
+
+ if (ret == GST_STATE_CHANGE_FAILURE)
+ goto leave;
+
+ switch (transition) {
+ case GST_STATE_CHANGE_READY_TO_NULL:
+ codec_delete (self);
+ engine_close (self);
+ break;
+ default:
+ break;
+ }
+
+leave:
+ GST_LOG_OBJECT (self, "end");
+
+ return ret;
+}
+
+/* GObject vmethod implementations */
+
+static void
+gst_ducati_viddec_finalize (GObject * obj)
+{
+ GstDucatiVidDec *self = GST_DUCATIVIDDEC (obj);
+
+ codec_delete (self);
+ engine_close (self);
+
+ G_OBJECT_CLASS (parent_class)->finalize (obj);
+}
+
+static void
+gst_ducati_viddec_base_init (gpointer gclass)
+{
+ GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
+
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&src_factory));
+}
+
+static void
+gst_ducati_viddec_class_init (GstDucatiVidDecClass * klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
+
+ gobject_class->finalize = gst_ducati_viddec_finalize;
+ gstelement_class->change_state = gst_ducati_viddec_change_state;
+
+ klass->allocate_params =
+ GST_DEBUG_FUNCPTR (gst_ducati_viddec_allocate_params);
+ klass->push_input =
+ GST_DEBUG_FUNCPTR (gst_ducati_viddec_push_input);
+}
+
+static void
+gst_ducati_viddec_init (GstDucatiVidDec * self, GstDucatiVidDecClass * klass)
+{
+ GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
+
+ self->sinkpad = gst_pad_new_from_template (
+ gst_element_class_get_pad_template (gstelement_class, "sink"), "sink");
+ gst_pad_set_setcaps_function (self->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_ducati_viddec_set_caps));
+ gst_pad_set_chain_function (self->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_ducati_viddec_chain));
+ gst_pad_set_event_function (self->sinkpad,
+ GST_DEBUG_FUNCPTR (gst_ducati_viddec_event));
+
+ self->srcpad = gst_pad_new_from_static_template (&src_factory, "src");
+ gst_pad_set_setcaps_function (self->srcpad,
+ GST_DEBUG_FUNCPTR (gst_ducati_viddec_set_caps));
+ gst_pad_set_query_function (self->srcpad,
+ GST_DEBUG_FUNCPTR (gst_ducati_viddec_query));
+
+ gst_element_add_pad (GST_ELEMENT (self), self->sinkpad);
+ gst_element_add_pad (GST_ELEMENT (self), self->srcpad);
+}
diff --git a/src/gstducatividdec.h b/src/gstducatividdec.h
new file mode 100644
index 0000000..dfb505a
--- /dev/null
+++ b/src/gstducatividdec.h
@@ -0,0 +1,105 @@
+/*
+ * GStreamer
+ * Copyright (c) 2010, Texas Instruments Incorporated
+ *
+ * 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
+ * version 2.1 of the License.
+ *
+ * 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
+ */
+
+#ifndef __GST_DUCATIVIDDEC_H__
+#define __GST_DUCATIVIDDEC_H__
+
+#include <gst/gst.h>
+
+#include "gstducati.h"
+
+
+G_BEGIN_DECLS
+
+// XXX move these
+GST_DEBUG_CATEGORY_EXTERN (gst_ducati_debug);
+
+
+#define GST_TYPE_DUCATIVIDDEC (gst_ducati_viddec_get_type())
+#define GST_DUCATIVIDDEC(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_DUCATIVIDDEC, GstDucatiVidDec))
+#define GST_DUCATIVIDDEC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_DUCATIVIDDEC, GstDucatiVidDecClass))
+#define GST_IS_DUCATIVIDDEC(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_DUCATIVIDDEC))
+#define GST_IS_DUCATIVIDDEC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_DUCATIVIDDEC))
+#define GST_DUCATIVIDDEC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_DUCATIVIDDEC, GstDucatiVidDecClass))
+
+typedef struct _GstDucatiVidDec GstDucatiVidDec;
+typedef struct _GstDucatiVidDecClass GstDucatiVidDecClass;
+
+struct _GstDucatiVidDec
+{
+ GstElement parent;
+
+ GstPad *sinkpad, *srcpad;
+
+ /* minimum output size required by the codec: */
+ gint outsize;
+
+ /* minimum number of buffers required by the codec: */
+ gint min_buffers;
+
+ /* input (unpadded) size of video: */
+ gint width, height;
+
+ /* output (padded) size including any codec padding: */
+ gint padded_width, padded_height;
+
+ /* output stride (>= padded_width) */
+ gint stride;
+
+ /* input buffer, allocated when codec is created: */
+ guint8 *input;
+
+ Engine_Handle engine;
+ VIDDEC3_Handle codec;
+ VIDDEC3_Params *params;
+ VIDDEC3_DynamicParams *dynParams;
+ VIDDEC3_Status *status;
+ XDM2_BufDesc *inBufs;
+ XDM2_BufDesc *outBufs;
+ VIDDEC3_InArgs *inArgs;
+ VIDDEC3_OutArgs *outArgs;
+};
+
+struct _GstDucatiVidDecClass
+{
+ GstElementClass parent_class;
+
+ const gchar *codec_name;
+
+ /**
+ * Called when the input buffer size changes, to recalculate codec required
+ * output buffer size and minimum count
+ */
+ void (*update_buffer_size) (GstDucatiVidDec * self);
+
+ gboolean (*allocate_params) (GstDucatiVidDec * self, gint params_sz,
+ gint dynparams_sz, gint status_sz, gint inargs_sz, gint outargs_sz);
+
+ /**
+ * Push input data into codec's input buffer, returning a sub-buffer of
+ * any remaining data, or NULL if none. Consumes reference to 'buf'
+ */
+ GstBuffer * (*push_input) (GstDucatiVidDec * self, GstBuffer * buf);
+};
+
+GType gst_ducati_viddec_get_type (void);
+
+G_END_DECLS
+
+#endif /* __GST_DUCATIVIDDEC_H__ */